Skip to content

Commit

Permalink
fix: header node - collapse on start to be always the last header tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasho Mihajlov authored and adrians5j committed Jul 21, 2023
1 parent 278fd9c commit c66ed37
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/lexical-editor/src/nodes/HeadingNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c66ed37

Please sign in to comment.