diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-05-01 20:45:27 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-05-01 20:45:31 +0200 |
commit | bb965b8e34095697da13f313673960feaee63b0f (patch) | |
tree | 973a03fee0dc7894b7df628932bd59a8caa5b981 | |
parent | c780fc7bdf818ce1a445b526ff3e5afc6c05807f (diff) | |
download | mitmproxy-bb965b8e34095697da13f313673960feaee63b0f.tar.gz mitmproxy-bb965b8e34095697da13f313673960feaee63b0f.tar.bz2 mitmproxy-bb965b8e34095697da13f313673960feaee63b0f.zip |
web: try harder to fix editor
-rw-r--r-- | libmproxy/web/static/app.js | 9 | ||||
-rw-r--r-- | web/src/js/components/editor.js | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/libmproxy/web/static/app.js b/libmproxy/web/static/app.js index 3531174e..b9767153 100644 --- a/libmproxy/web/static/app.js +++ b/libmproxy/web/static/app.js @@ -735,9 +735,15 @@ var EditorBase = React.createClass({displayName: "EditorBase", onBlur: this._stop, onKeyDown: this.onKeyDown, onInput: this.onInput, + onPaste: this.onPaste, dangerouslySetInnerHTML: html}) ); }, + onPaste: function(e){ + e.preventDefault(); + var content = e.clipboardData.getData("text/plain"); + document.execCommand("insertHTML", false, content); + }, onFocus: function (e) { this.setState({editable: true}, function () { React.findDOMNode(this).focus(); @@ -775,7 +781,7 @@ var EditorBase = React.createClass({displayName: "EditorBase", this.cancel(); break; case utils.Key.ENTER: - if (this.props.submitOnEnter) { + if (this.props.submitOnEnter && !e.shiftKey) { e.preventDefault(); this.stop(); } @@ -787,7 +793,6 @@ var EditorBase = React.createClass({displayName: "EditorBase", onInput: function () { var node = React.findDOMNode(this); var content = this.props.nodeToContent(node); - node.innerHTML = this.props.contentToHtml(content); this.props.onInput && this.props.onInput(content); } }); diff --git a/web/src/js/components/editor.js b/web/src/js/components/editor.js index 714a8e2a..129fef08 100644 --- a/web/src/js/components/editor.js +++ b/web/src/js/components/editor.js @@ -49,9 +49,15 @@ var EditorBase = React.createClass({ onBlur={this._stop} onKeyDown={this.onKeyDown} onInput={this.onInput} + onPaste={this.onPaste} dangerouslySetInnerHTML={html} />; }, + onPaste: function(e){ + e.preventDefault(); + var content = e.clipboardData.getData("text/plain"); + document.execCommand("insertHTML", false, content); + }, onFocus: function (e) { this.setState({editable: true}, function () { React.findDOMNode(this).focus(); @@ -89,7 +95,7 @@ var EditorBase = React.createClass({ this.cancel(); break; case utils.Key.ENTER: - if (this.props.submitOnEnter) { + if (this.props.submitOnEnter && !e.shiftKey) { e.preventDefault(); this.stop(); } @@ -101,7 +107,6 @@ var EditorBase = React.createClass({ onInput: function () { var node = React.findDOMNode(this); var content = this.props.nodeToContent(node); - node.innerHTML = this.props.contentToHtml(content); this.props.onInput && this.props.onInput(content); } }); |