From c66ed37e9e2b10d656a2bc2ec2335c4f6d26a2c4 Mon Sep 17 00:00:00 2001 From: Sasho Mihajlov Date: Fri, 21 Jul 2023 13:59:07 +0200 Subject: [PATCH] fix: header node - collapse on start to be always the last header tag --- packages/lexical-editor/src/nodes/HeadingNode.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/lexical-editor/src/nodes/HeadingNode.ts b/packages/lexical-editor/src/nodes/HeadingNode.ts index c4228f5fe2a..120c5fb567e 100644 --- a/packages/lexical-editor/src/nodes/HeadingNode.ts +++ b/packages/lexical-editor/src/nodes/HeadingNode.ts @@ -10,7 +10,7 @@ import { HeadingTagType, SerializedHeadingNode as BaseSerializedHeadingNode } from "@lexical/rich-text"; -import { $createParagraphNode, ParagraphNode } from "~/nodes/ParagraphNode"; +import { ParagraphNode } from "~/nodes/ParagraphNode"; export type SerializeHeadingNode = Spread< { @@ -152,9 +152,7 @@ export class HeadingNode } override collapseAtStart(): true { - const newElement = !this.isEmpty() - ? $createHeadingNode(this.getTag()) - : $createParagraphNode(); + const newElement = $createHeadingNode(this.getTag()); const children = this.getChildren(); children.forEach(child => newElement.append(child)); this.replace(newElement);