prevent autocomplete when doing bulk insertion (paste, drop text)

This commit is contained in:
Bruno Windels 2019-07-11 18:32:58 +02:00
parent 507b89fc61
commit 06fb892df9
2 changed files with 27 additions and 8 deletions

View file

@ -69,7 +69,7 @@ class BasePart {
// inserts str at offset if all the characters in str were accepted, otherwise don't do anything
// return whether the str was accepted or not.
insertAll(offset, str) {
validateAndInsert(offset, str) {
for (let i = 0; i < str.length; ++i) {
const chr = str.charAt(i);
if (!this.acceptsInsertion(chr)) {
@ -82,6 +82,16 @@ class BasePart {
return true;
}
insert(offset, str) {
if (this.canEdit) {
const beforeInsert = this._text.substr(0, offset);
const afterInsert = this._text.substr(offset);
this._text = beforeInsert + str + afterInsert;
return true;
}
return false;
}
createAutoComplete() {}
trim(len) {