Merge branch 'master' of github.com:ajaxorg/ace
This commit is contained in:
commit
dd45dfd661
2 changed files with 25 additions and 3 deletions
|
|
@ -675,6 +675,16 @@ var Document = function(text, mode) {
|
|||
},
|
||||
|
||||
this.replace = function(range, text) {
|
||||
// Shortcut: Nothing to replace in this case.
|
||||
if (text.length == 0 && range.isEmpty()) {
|
||||
return range.start;
|
||||
} else
|
||||
// Shortcut: If the text we want to insert is the same as it is already
|
||||
// in the document, we don't have to replace anything.
|
||||
if (text == this.getTextRange(range)) {
|
||||
return range.end;
|
||||
}
|
||||
|
||||
this.$remove(range);
|
||||
if (text) {
|
||||
var end = this.$insert(range.start, text);
|
||||
|
|
|
|||
|
|
@ -54,9 +54,9 @@ var TextInput = function(parentNode, host) {
|
|||
var inCompostion = false;
|
||||
var copied = false;
|
||||
|
||||
function sendText() {
|
||||
function sendText(valueToSend) {
|
||||
if (!copied) {
|
||||
var value = text.value;
|
||||
var value = valueToSend || text.value;
|
||||
if (value) {
|
||||
if (value.charCodeAt(value.length-1) == PLACEHOLDER.charCodeAt(0)) {
|
||||
value = value.slice(0, -1);
|
||||
|
|
@ -116,7 +116,19 @@ var TextInput = function(parentNode, host) {
|
|||
|
||||
event.addListener(text, "keypress", onTextInput);
|
||||
event.addListener(text, "textInput", onTextInput);
|
||||
event.addListener(text, "paste", onTextInput);
|
||||
event.addListener(text, "paste", function(e) {
|
||||
// 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) {
|
||||
sendText(e.clipboardData.getData("text/plain"));
|
||||
e.preventDefault();
|
||||
} else
|
||||
// If a browser doesn't support any of the things above, use the regular
|
||||
// method to detect the pasted input.
|
||||
{
|
||||
onTextInput();
|
||||
}
|
||||
});
|
||||
event.addListener(text, "propertychange", onTextInput);
|
||||
|
||||
event.addListener(text, "copy", onCopy);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue