Skip to content

Commit

Permalink
Check if not rootNode before removing
Browse files Browse the repository at this point in the history
  • Loading branch information
strdr4605 committed Sep 13, 2024
1 parent 919f570 commit 4244757
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/lexical/src/LexicalSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1356,8 +1356,10 @@ export class RangeSelection implements BaseSelection {
if (rightPart) {
const rightPartParent = rightPart.getParentOrThrow();
last.insertAfter(rightPart);
// Remove redundant paragraph
rightPartParent.getParentOrThrow().remove();
if (!$isRootNode(rightPartParent.getParentOrThrow())) {
// Remove redundant paragraph
rightPartParent.getParentOrThrow().remove();
}
rightPart.selectStart();
}
return;
Expand Down Expand Up @@ -1439,8 +1441,10 @@ export class RangeSelection implements BaseSelection {
if (rightPart) {
const rightPartParent = rightPart.getParentOrThrow();
newBlock.append(rightPart);
// Remove redundant paragraph
rightPartParent.getParentOrThrow().remove();
if (!$isRootNode(rightPartParent.getParentOrThrow())) {
// Remove redundant paragraph
rightPartParent.getParentOrThrow().remove();
}
}
newBlock.append(...nodesToInsert);
newBlock.selectStart();
Expand Down

0 comments on commit 4244757

Please sign in to comment.