mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Fix merging text nodes after delete
startContainer is not necessarily a sibling to endContainer at this point. endContainer is definitely at the right level of the hierarchy so instead just get the previous sibling from this and merge with that if it's also a text node.
This commit is contained in:
parent
196f325fc0
commit
3def29e081
1 changed files with 5 additions and 4 deletions
|
@ -134,11 +134,12 @@ const extractContentsOfRange = (
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge text nodes if adjacent
|
// Merge text nodes if adjacent
|
||||||
if (startContainer instanceof Text && endContainer instanceof Text) {
|
node = endContainer.previousSibling;
|
||||||
startContainer.appendData(endContainer.data);
|
if (node && node instanceof Text && endContainer instanceof Text) {
|
||||||
|
endOffset = node.length;
|
||||||
|
node.appendData(endContainer.data);
|
||||||
detach(endContainer);
|
detach(endContainer);
|
||||||
endContainer = startContainer;
|
endContainer = node;
|
||||||
endOffset = startOffset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
range.setStart(startContainer, startOffset);
|
range.setStart(startContainer, startOffset);
|
||||||
|
|
Loading…
Reference in a new issue