diff options
author | Jason <jason.daurus@gmail.com> | 2016-06-15 00:46:59 +0800 |
---|---|---|
committer | Jason <jason.daurus@gmail.com> | 2016-06-17 04:38:35 +0800 |
commit | f5c597a9e351b8dfb84f0fe3f09046e772482fc6 (patch) | |
tree | 8f44cc55513a04b64b4e79d4d9c18f59f100cfaf /web/src/js/components/ValueEditor.jsx | |
parent | e5bf1e930a5b6ba0b3300b02daf792d65d795202 (diff) | |
download | mitmproxy-f5c597a9e351b8dfb84f0fe3f09046e772482fc6.tar.gz mitmproxy-f5c597a9e351b8dfb84f0fe3f09046e772482fc6.tar.bz2 mitmproxy-f5c597a9e351b8dfb84f0fe3f09046e772482fc6.zip |
[web] Editor & Prompt
Diffstat (limited to 'web/src/js/components/ValueEditor.jsx')
-rwxr-xr-x | web/src/js/components/ValueEditor.jsx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/web/src/js/components/ValueEditor.jsx b/web/src/js/components/ValueEditor.jsx new file mode 100755 index 00000000..0316924f --- /dev/null +++ b/web/src/js/components/ValueEditor.jsx @@ -0,0 +1,36 @@ +import React, { Component, PropTypes } from 'react' +import ReactDOM from 'react-dom' +import ValidateEditor from './ValueEditor/ValidateEditor' + +export default class ValueEditor extends Component { + + static contextTypes = { + returnFocus: PropTypes.func, + } + + static propTypes = { + content: PropTypes.string.isRequired, + onDone: PropTypes.func.isRequired, + inline: PropTypes.bool, + } + + constructor(props) { + super(props) + this.focus = this.focus.bind(this) + } + + render() { + var tag = this.props.inline ? "span" : 'div' + return ( + <ValidateEditor + {...this.props} + onStop={() => this.context.returnFocus()} + tag={tag} + /> + ) + } + + focus() { + ReactDOM.findDOMNode(this).focus(); + } +} |