mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-14 08:43:12 +00:00
Update itext_key_behavior.mixin.js
Remove cancelOnInput logic, a normal e.preventDefault + stopPropagation is enough. Take in account already selected text when deciding how much text we are inserting during input event
This commit is contained in:
parent
f46813499d
commit
c943d369a2
1 changed files with 5 additions and 4 deletions
|
|
@ -81,14 +81,14 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
|
|||
* @param {Event} e Event object
|
||||
*/
|
||||
onInput: function(e) {
|
||||
if (!this.isEditing || this._cancelOnInput) {
|
||||
this._cancelOnInput = false;
|
||||
if (!this.isEditing) {
|
||||
return;
|
||||
}
|
||||
var offset = this.selectionStart || 0,
|
||||
offsetEnd = this.selectionEnd || 0,
|
||||
textLength = this.text.length,
|
||||
newTextLength = this.hiddenTextarea.value.length,
|
||||
diff = newTextLength - textLength,
|
||||
diff = newTextLength - textLength + offsetEnd - offset,
|
||||
charsToInsert = this.hiddenTextarea.value.slice(offset, offset + diff);
|
||||
this.insertChars(charsToInsert);
|
||||
e.stopPropagation();
|
||||
|
|
@ -149,7 +149,8 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
|
|||
if (copiedText) {
|
||||
this.insertChars(copiedText, useCopiedStyle);
|
||||
}
|
||||
this._cancelOnInput = true;
|
||||
e.stopImmediatePropagation();
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue