also process first part when processing empty and mergeable parts

this was preventing clearing an emtpy plain part when inserting
a pill-candidate at the beginning of the model, which
prevented a caret node from being inserted before the pill.
This commit is contained in:
Bruno Windels 2019-06-19 10:57:29 +02:00
parent 75fc769742
commit 607fc328ed

View file

@ -158,11 +158,11 @@ export default class EditorModel {
}
_mergeAdjacentParts(docPos) {
let prevPart = this._parts[0];
for (let i = 1; i < this._parts.length; ++i) {
let prevPart;
for (let i = 0; i < this._parts.length; ++i) {
let part = this._parts[i];
const isEmpty = !part.text.length;
const isMerged = !isEmpty && prevPart.merge(part);
const isMerged = !isEmpty && prevPart && prevPart.merge(part);
if (isEmpty || isMerged) {
// remove empty or merged part
part = prevPart;