Skip to content
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

Fix DecoratorNodes being treated as block elements #5371

Merged
merged 3 commits into from Jan 17, 2024

Conversation

9larsons
Copy link
Contributor

closes #5369

This is a result of the larger insertNodes changes in v0.12.3+.

Causal code:
https://github.com/facebook/lexical/pull/5002/files#diff-33353db27f56a5d74e7281df0a8a2fc223eef41e9dc2efc723a412560a0148c9R561-R563

INTERNAL_$isBlock is treating (non-inline) DecoratorNodes as block elements, causing ElementNode methods being called on decorator nodes that result in broken functionality.

While someone could extend the decorator node class to have the indent and format properties, they are generally not elements and should not be treated as such.

Copy link

vercel bot commented Dec 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2024 11:55am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2024 11:55am

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 11, 2023
Copy link
Contributor

@GermanJablo GermanJablo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised that no tests are breaking, since I made insertNodes considering the decorators (which in fact before were not included as blocks and I had to include them for it to work).

I haven't reviewed insertNodes in detail again, so for my part the only thing I can point out at a glance is a comment about the return type.

packages/lexical-selection/src/range-selection.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@GermanJablo GermanJablo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@zurfyx zurfyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this! The terminology for this function is not correct. We have originally referred to blocks as a piece of content that ocuppies the entire horizontal space, resembling display: block on the browser. Decorator nodes can be blocks so I'd be inclined the say that we have to fix this instead https://github.com/facebook/lexical/blob/main/packages/lexical-selection/src/range-selection.ts#L77

Stamping to unblock since it's been about a month since this was open but ideally we want to iterate on this

@zurfyx zurfyx merged commit 6e54c04 into facebook:main Jan 17, 2024
45 checks passed
amanharwara pushed a commit to standardnotes/lexical that referenced this pull request Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: INTERNAL_$isBlock treats decorator nodes incorrectly
5 participants