diff --git a/packages/lexical-react/src/shared/useCharacterLimit.ts b/packages/lexical-react/src/shared/useCharacterLimit.ts index df592ebf9c6..56887d43391 100644 --- a/packages/lexical-react/src/shared/useCharacterLimit.ts +++ b/packages/lexical-react/src/shared/useCharacterLimit.ts @@ -224,7 +224,7 @@ function $wrapOverflowedNodes(offset: number): void { function $wrapNode(node: LexicalNode): OverflowNode { const overflowNode = $createOverflowNode(); - node.insertBefore(overflowNode); + node.replace(overflowNode); overflowNode.append(node); return overflowNode; } diff --git a/packages/lexical/src/LexicalUtils.ts b/packages/lexical/src/LexicalUtils.ts index 52d78f07f36..c4bc5ae882f 100644 --- a/packages/lexical/src/LexicalUtils.ts +++ b/packages/lexical/src/LexicalUtils.ts @@ -264,6 +264,7 @@ function internalMarkParentElementsAsDirty( } } +// TODO #6031 this function or their callers have to adjust selection (i.e. insertBefore) export function removeFromParent(node: LexicalNode): void { const oldParent = node.getParent(); if (oldParent !== null) {