mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Fix Firefox cursor position bug after paste
We merge a faux block with contents from after a split point when inserting HTML. The merge function presumes this block has already had fixCursor run on it to ensure we add the <br>s some browsers need to support correct cursor focusing. Fixes #451
This commit is contained in:
parent
c0479f3fdf
commit
752a42d917
2 changed files with 6 additions and 2 deletions
|
@ -37,9 +37,12 @@ const fixCursor = (node: Node): Node => {
|
|||
fixer = document.createTextNode('');
|
||||
}
|
||||
}
|
||||
} else if (node instanceof Element && !node.querySelector('BR')) {
|
||||
} else if (
|
||||
(node instanceof Element || node instanceof DocumentFragment) &&
|
||||
!node.querySelector('BR')
|
||||
) {
|
||||
fixer = createElement('BR');
|
||||
let parent: Element = node;
|
||||
let parent: Element | DocumentFragment = node;
|
||||
let child: Element | null;
|
||||
while ((child = parent.lastElementChild) && !isInline(child)) {
|
||||
parent = child;
|
||||
|
|
|
@ -425,6 +425,7 @@ const insertTreeFragmentIntoRange = (
|
|||
// Insert inline content saved from before.
|
||||
if (blockContentsAfterSplit && block) {
|
||||
const tempRange = range.cloneRange();
|
||||
fixCursor(blockContentsAfterSplit);
|
||||
mergeWithBlock(block, blockContentsAfterSplit, tempRange, root);
|
||||
range.setEnd(tempRange.endContainer, tempRange.endOffset);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue