facebook / facebook/lexical

Consider DecoratorNode in $insertNodeToNearestRoot

Open
#5,949 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
23.9k
Forks
2.2k
Avg merge
1d 16h
Merged PRs (30d)
61

Description

DecoratorNode is not treated as ElementNode from this commit (https://github.com/facebook/lexical/pull/5371) on, but In `$insertNodeToNearestRoot` method, `getTopLevelElementOrThrow` is called if the selection is not a range selection. It causes error while the focus node is a DecoratorNode.

https://github.com/facebook/lexical/blob/686217de2d88a428eae3c7fd4159ef28117e0861/packages/lexical-utils/src/index.ts#L473

And another feature in this method should which I think it should be modified is checking `empty` after splitting node in range selection, otherwise it may create one more empty line.

Another question is why does this method end with inserting another paragraph node?

Contributor guide

Open the contributing guide

Research direction

Read packages/lexical-utils/src/index.ts at $insertNodeToNearestRoot and trace the linked getTopLevelElementOrThrow call through the DecoratorNode and range-selection paths. Reproduce the non-range DecoratorNode failure and the post-split empty-line case; done means both cases behave without the reported error or unintended extra paragraph, and the method’s final insertion behavior is clarified.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.