-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Bug Fix: ContextMenu Paste option not preserving style #6780
Bug Fix: ContextMenu Paste option not preserving style #6780
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
@@ -1358,7 +1358,7 @@ function applyTextFormatFromStyle( | |||
if (shouldApply && !lexicalNode.hasFormat(shouldApply)) { | |||
lexicalNode.toggleFormat(shouldApply); | |||
} | |||
|
|||
lexicalNode.setStyle(style.cssText); |
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.
This is one workaround it but it breaks other things, it's not generally desirable or backwards compatible for all styles to be imported because the editor doesn't know how to work with most of the styles available in CSS and you would be stuck with them since you can't manage them from the editor. For example if you pasted some text with margins or padding or something like that you wouldn't really be able to get rid of it without deleting the text.
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.
In this particular case, the solution should be implemented such that it only works in the playground via some configuration and doesn't change the existing import behavior of TextNode
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.
In this particular case, the solution should be implemented such that it only works in the playground via some configuration and doesn't change the existing import behavior of TextNode
should i do something similiar like the above code? such as only supporting certain custom styles like font size and background color and not sure what else
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.
Yes, but in order to maintain backwards compatibility the code has to be done somewhere else. I replied to your discord with an untested sketch of some code that will probably get close, using the html import configuration option that will be documented via #6762
…yle function to only support specific style properties
…hub.com/citruscai/lexical into fix/contextmenu-paste-style-consistency
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.
Everything looks good, only one test failure this run and it's a flaky test that has passed before and passes locally for me. In the last commit I added some extra locking around clipboard related tests to hopefully make them more reliable.
I think this is good to go and will get merged shortly. Great work!
Description
When you paste a text with a different font size or custom style using the context menu, the pasted text loses it's style and is the default style.
Closes #6720
Test plan
Before
lexicalpastebug.mp4
After
lexicalpastefix.mp4