mirror of https://github.com/vector-im/riot-web
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.pull/21833/head
parent
75fc769742
commit
607fc328ed
|
@ -158,11 +158,11 @@ export default class EditorModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
_mergeAdjacentParts(docPos) {
|
_mergeAdjacentParts(docPos) {
|
||||||
let prevPart = this._parts[0];
|
let prevPart;
|
||||||
for (let i = 1; i < this._parts.length; ++i) {
|
for (let i = 0; i < this._parts.length; ++i) {
|
||||||
let part = this._parts[i];
|
let part = this._parts[i];
|
||||||
const isEmpty = !part.text.length;
|
const isEmpty = !part.text.length;
|
||||||
const isMerged = !isEmpty && prevPart.merge(part);
|
const isMerged = !isEmpty && prevPart && prevPart.merge(part);
|
||||||
if (isEmpty || isMerged) {
|
if (isEmpty || isMerged) {
|
||||||
// remove empty or merged part
|
// remove empty or merged part
|
||||||
part = prevPart;
|
part = prevPart;
|
||||||
|
|
Loading…
Reference in New Issue