prevent inserting parts at index -1 for empty documents

pull/21833/head
Bruno Windels 2019-07-11 18:33:22 +02:00
parent 06fb892df9
commit dedf978948
1 changed files with 4 additions and 0 deletions

View File

@ -244,6 +244,10 @@ export default class EditorModel {
addLen += part.text.length - offset; addLen += part.text.length - offset;
index += 1; index += 1;
} }
} else if (index < 0) {
// if position was not found (index: -1, as happens for empty editor)
// reset it to insert as first part
index = 0;
} }
while (str) { while (str) {
const newPart = this._partCreator.createPartForInput(str); const newPart = this._partCreator.createPartForInput(str);