From a7033da9751bb909a5831a4a56bdbfda0cdb997b Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 21 Dec 2014 23:01:01 +0400 Subject: [PATCH] convert paste into command --- .../ace/lib/ace/commands/default_commands.js | 12 ++++++++++++ node_modules/ace/lib/ace/editor.js | 9 ++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/node_modules/ace/lib/ace/commands/default_commands.js b/node_modules/ace/lib/ace/commands/default_commands.js index f1e267c1..dddce931 100644 --- a/node_modules/ace/lib/ace/commands/default_commands.js +++ b/node_modules/ace/lib/ace/commands/default_commands.js @@ -423,6 +423,12 @@ exports.commands = [{ exec: function() {}, passEvent: true, readOnly: true +}, { + name: "copy", + exec: function(editor) { + // placeholder for replay macro + }, + readOnly: true }, // commands disabled in readOnly mode @@ -439,6 +445,12 @@ exports.commands = [{ }, scrollIntoView: "cursor", multiSelectAction: "forEach" +}, { + name: "paste", + exec: function(editor, text) { + editor.$handlePaste(text); + }, + scrollIntoView: "cursor" }, { name: "removeline", bindKey: bindKey("Ctrl-D", "Command-D"), diff --git a/node_modules/ace/lib/ace/editor.js b/node_modules/ace/lib/ace/editor.js index 500cfc45..0602e7fd 100644 --- a/node_modules/ace/lib/ace/editor.js +++ b/node_modules/ace/lib/ace/editor.js @@ -903,10 +903,10 @@ var Editor = function(renderer, session) { * **/ this.onPaste = function(text) { - // todo this should change when paste becomes a command - if (this.$readOnly) - return; - + this.commands.exec("paste", this, text); + }; + + this.$handlePaste = function(text) { var e = {text: text}; this._signal("paste", e); text = e.text; @@ -927,7 +927,6 @@ var Editor = function(renderer, session) { this.session.insert(range.start, lines[i]); } } - this.renderer.scrollCursorIntoView(); }; this.execCommand = function(command, args) {