From ed8f85fb5e5106dba237e2a166e57acaa28e8fbe Mon Sep 17 00:00:00 2001 From: GermanJablo <43938777+GermanJablo@users.noreply.github.com> Date: Fri, 3 Nov 2023 10:03:15 -0300 Subject: [PATCH] fix Heading.insertNewAfter (#5198) Co-authored-by: EgonBolton <43938777+EgonBolton@users.noreply.github.com> --- packages/lexical-rich-text/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/lexical-rich-text/src/index.ts b/packages/lexical-rich-text/src/index.ts index 769a58d39ae..fb1340a3e21 100644 --- a/packages/lexical-rich-text/src/index.ts +++ b/packages/lexical-rich-text/src/index.ts @@ -361,7 +361,9 @@ export class HeadingNode extends ElementNode { newElement.setDirection(direction); this.insertAfter(newElement, restoreSelection); if (anchorOffet === 0 && !this.isEmpty() && selection) { - this.replace($createParagraphNode(), restoreSelection); + const paragraph = $createParagraphNode(); + paragraph.select(); + this.replace(paragraph, true); } return newElement; }