From 74a753af23e4c8d236b61cd0702598d481842ab5 Mon Sep 17 00:00:00 2001 From: Gerard Rovira Date: Sun, 5 May 2024 14:50:36 -0400 Subject: [PATCH 1/2] CharacterLimit prefer replace over insertBefore --- packages/lexical-react/src/shared/useCharacterLimit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } From d9911022798cb224c8e603df76a16f3b9d96c127 Mon Sep 17 00:00:00 2001 From: Gerard Rovira Date: Sun, 5 May 2024 14:54:05 -0400 Subject: [PATCH 2/2] add todo --- packages/lexical/src/LexicalUtils.ts | 1 + 1 file changed, 1 insertion(+) 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) {