diff --git a/source/node/MergeSplit.ts b/source/node/MergeSplit.ts index 0b1a4be..4e8f5fe 100644 --- a/source/node/MergeSplit.ts +++ b/source/node/MergeSplit.ts @@ -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; diff --git a/source/range/InsertDelete.ts b/source/range/InsertDelete.ts index 6e0e621..c31c069 100644 --- a/source/range/InsertDelete.ts +++ b/source/range/InsertDelete.ts @@ -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); }