-
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-selection] Bug Fix / Fixes text formatting with segmented and token nodes #6059 #6062
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hi @lacroixdavid1! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
This looks interesting, never stumbled upon this issue. For @Sahejkm @zurfyx and @potatowagon to comment, |
Not sure how other editors handle it in general, currently GDocs doesn't even allow partial selection of @mention node, would it be ok to assume partial selection as full selection from formatting point of view ? @zurfyx wdyt ?
@lacroixdavid1 could you help explain this scenario via a video recording ? Thanks! |
It's pretty easy to repro the issue on the playground by just inserting a mention, selecting it partially, and applying bold format. |
I think these are actually probably the correct semantics for token/segmented nodes. The whole point of these is that they are a single "unit" and are interacted with as such from a creation/deletion standpoint. The only other way I could think to deal with this would be to treat the styled portion of the node as and additional segment, rather than splitting the node and removing the token/segmented characteristics entirely. |
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.
I'm good with this, but would like a second pair of eyes given that core selection is particularly prone to cause widespread issues.
For the following example, the MentionNode was changed from BeforeAfter |
Any progress on this one? Seems like a great improvement. Thanks! |
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.
LGTM, @zurfyx to sign off as well
Any chances of getting this one merged into 0.15.1? 🙏 pls |
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.
Thank you, this makes a lot of sense! This actually makes me realize that we should recheck if there's any other codepath that can potentially mangle a segmented node like this. Segmented nodes should only segment in one way, separators, you shouldn't be able to split a Mention node arbritrary (at least not via user-input).
Thank you, guys. Lexical is very solid and has a bright future. |
Thank you for this change! It works very well, I found only one issue regarding: |
Description
It is currently only possible to format token nodes by selecting them entirely. They won't be formatted if they are in the middle of the range selection. Also, if the selection offset is in the middle of the node, it will split the node.
This PR ensures middle nodes are formated, just like when selecting them entirely. Also, it prevents breaking segmented or token nodes in the middle of the text where they shouldn't be allowed.
#6059
Test plan
Added unit tests to the PR. See LexicalSelection.test.tsx.
Before
After