Merge branch 'add/copypaste' of github.com:ajaxorg/ace into ui/navbar
This commit is contained in:
commit
2e4d326b3f
1 changed files with 20 additions and 2 deletions
|
|
@ -134,9 +134,12 @@ var TextInput = function(parentNode, host) {
|
||||||
|
|
||||||
var onCopy = function(e) {
|
var onCopy = function(e) {
|
||||||
copied = true;
|
copied = true;
|
||||||
|
outsideCopyText = "";
|
||||||
var copyText = host.getCopyText();
|
var copyText = host.getCopyText();
|
||||||
if(copyText)
|
if(copyText) {
|
||||||
text.value = copyText;
|
text.value = copyText;
|
||||||
|
host.onCopy();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
select();
|
select();
|
||||||
|
|
@ -147,6 +150,7 @@ var TextInput = function(parentNode, host) {
|
||||||
|
|
||||||
var onCut = function(e) {
|
var onCut = function(e) {
|
||||||
copied = true;
|
copied = true;
|
||||||
|
outsideCopyText = "";
|
||||||
var copyText = host.getCopyText();
|
var copyText = host.getCopyText();
|
||||||
if(copyText) {
|
if(copyText) {
|
||||||
text.value = copyText;
|
text.value = copyText;
|
||||||
|
|
@ -159,6 +163,17 @@ var TextInput = function(parentNode, host) {
|
||||||
}, 0);
|
}, 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;
|
||||||
|
}
|
||||||
|
|
||||||
event.addCommandKeyListener(text, host.onCommandKey.bind(host));
|
event.addCommandKeyListener(text, host.onCommandKey.bind(host));
|
||||||
|
|
||||||
if (useragent.isOldIE) {
|
if (useragent.isOldIE) {
|
||||||
|
|
@ -184,7 +199,10 @@ var TextInput = function(parentNode, host) {
|
||||||
// Some browsers support the event.clipboardData API. Use this to get
|
// Some browsers support the event.clipboardData API. Use this to get
|
||||||
// the pasted content which increases speed if pasting a lot of lines.
|
// the pasted content which increases speed if pasting a lot of lines.
|
||||||
if (e.clipboardData && e.clipboardData.getData) {
|
if (e.clipboardData && e.clipboardData.getData) {
|
||||||
sendText(e.clipboardData.getData("text/plain"));
|
if (outsideCopyText.length > 0)
|
||||||
|
sendText(outsideCopyText);
|
||||||
|
else
|
||||||
|
sendText(e.clipboardData.getData("text/plain"));
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue