-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lexical] Chore: Added missing isInline
function to TextNode
#7226
base: main
Are you sure you want to change the base?
[lexical] Chore: Added missing isInline
function to TextNode
#7226
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Not sure if this PR requires any unit tests. |
isInline
function to TextNodeisInline
function to TextNode
This might make sense, but there should already be guards to prevent this from happening on nodes other than ElementNode and DecoratorNode. Did you run into a situation where this exception occurs? If so, that’s where the unit test should be. I think otherwise it might make more sense to move this to the ElementNode and DecoratorNode interfaces specifically because those are the only two types of nodes where it may return something meaningful. |
/** | ||
* @returns true if the text node is inline, false otherwise. | ||
*/ | ||
isInline(): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this does make sense to implement on TextNode, it would make sense to also narrow the implementation to return only true, because it's not permitted for any subclass to return false
isInline(): boolean { | |
isInline(): true { |
Also if we do decide to implement this, there's a fourth node that extends LexicalNode that should implement isInline: LineBreakNode. That would cover all of the expected cases, since the value for LexicalNode isn't exported there's no reasonable way to add another class to the hierarchy. |
Description
LexicalNode expects the extender Node to implement
isInline
. However, it is missing fromTextNode
implementation.lexical/packages/lexical/src/LexicalNode.ts
Lines 317 to 323 in 054fb46
Test plan
Before
isInline
function on aTextNode
instance.Invariant
will throw an error --LexicalNode: Node TextNode does not implement .isInline().
After
isInline
function on aTextNode
instance.true
.