mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-21 23:03:11 -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
|
||||
if (startContainer instanceof Text && endContainer instanceof Text) {
|
||||
startContainer.appendData(endContainer.data);
|
||||
node = endContainer.previousSibling;
|
||||
if (node && node instanceof Text && endContainer instanceof Text) {
|
||||
endOffset = node.length;
|
||||
node.appendData(endContainer.data);
|
||||
detach(endContainer);
|
||||
endContainer = startContainer;
|
||||
endOffset = startOffset;
|
||||
endContainer = node;
|
||||
}
|
||||
|
||||
range.setStart(startContainer, startOffset);
|
||||
|
|
Loading…
Reference in a new issue