From fcb172f665bd4c5118733d49fede29dbefdf8eee Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 26 Apr 2012 19:45:18 +0400 Subject: [PATCH] do not store clipboard state in textinput --- lib/ace/keyboard/textinput.js | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index 3c514537..10f12865 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -61,7 +61,6 @@ var TextInput = function(parentNode, host) { var copied = false; var pasted = false; var tempStyle = ''; - var outsideCopyText = ""; function select() { try { @@ -105,7 +104,7 @@ var TextInput = function(parentNode, host) { var onTextInput = function(e) { setTimeout(function () { if (!inCompostion) - sendText(e.data); + sendText(e.data); }, 0); }; @@ -135,12 +134,9 @@ var TextInput = function(parentNode, host) { var onCopy = function(e) { copied = true; - outsideCopyText = ""; var copyText = host.getCopyText(); - if(copyText) { + if(copyText) text.value = copyText; - host.onCopy(); - } else e.preventDefault(); select(); @@ -151,7 +147,6 @@ var TextInput = function(parentNode, host) { var onCut = function(e) { copied = true; - outsideCopyText = ""; var copyText = host.getCopyText(); if(copyText) { text.value = copyText; @@ -164,24 +159,8 @@ var TextInput = function(parentNode, host) { }, 0); }; - // these emit methods can be used for outside of the keyboard command context - this.emitCut = function() { - onCut(); - outsideCopyText = text.value; - } - - this.emitCopy = function() { - onCopy(); - outsideCopyText = text.value; - } - - this.emitPaste = function() { - pasted = true; - sendText(outsideCopyText); - } - event.addCommandKeyListener(text, host.onCommandKey.bind(host)); - + if (useragent.isOldIE) { var keytable = { 13:1, 27:1 }; event.addListener(text, "keyup", function (e) { @@ -205,10 +184,7 @@ var TextInput = function(parentNode, host) { // Some browsers support the event.clipboardData API. Use this to get // the pasted content which increases speed if pasting a lot of lines. if (e.clipboardData && e.clipboardData.getData) { - if (outsideCopyText.length > 0) - sendText(outsideCopyText); - else - sendText(e.clipboardData.getData("text/plain")); + sendText(e.clipboardData.getData("text/plain")); e.preventDefault(); } else {