diff --git a/src/editor/model.ts b/src/editor/model.ts index b9850a7ba7..59c7691d89 100644 --- a/src/editor/model.ts +++ b/src/editor/model.ts @@ -352,8 +352,6 @@ export default class EditorModel { * @param {Object} pos * @param {string} str * @param {string} inputType the source of the input, see html InputEvent.inputType - * @param {bool} options.validate Whether characters will be validated by the part. - * Validating allows the inserted text to be parsed according to the part rules. * @return {Number} how far from position (in characters) the insertion ended. * This can be more than the length of `str` when crossing non-editable parts, which are skipped. */ @@ -384,7 +382,13 @@ export default class EditorModel { } while (str) { const newPart = this._partCreator.createPartForInput(str, index, inputType); + const oldStr = str; str = newPart.appendUntilRejected(str, inputType); + if (str === oldStr) { + // nothing changed, break out of this infinite loop and log an error + console.error(`Failed to update model for input (str ${str}) (type ${inputType})`); + break; + } this.insertPart(index, newPart); index += 1; }