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.
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?
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?