-
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; Fix context menu pasting supporting lexical format to maintain style #6765
Bug Fix; Fix context menu pasting supporting lexical format to maintain style #6765
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
export function $getClipboardDataFromSelection( | ||
selection: BaseSelection | null = $getSelection(), | ||
editor: LexicalEditor = $getEditor(), | ||
): LexicalClipboardData { | ||
const clipboardData: LexicalClipboardData = { | ||
'text/plain': selection ? selection.getTextContent() : '', | ||
'web application/x-lexical-editor': $getLexicalContent(editor, selection), | ||
}; | ||
if (selection) { | ||
const editor = $getEditor(); | ||
for (const [mimeType, $editorFn] of clipboardDataFunctions) { |
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 don't think we need any of the changes in this function, since clipboardDataFunctions
will handle the export of the new web custom type
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.
Co-authored-by: Bob Ippolito <bob@redivi.com>
Co-authored-by: Bob Ippolito <bob@redivi.com>
Could we add a test please. Happy to merge quickly, once we have a test. |
I think there may still be some issues here, perhaps only the async api can write web custom formats, or maybe it needs to be serialized in some other way to get picked up. The docs are not very clear on this. Possibly the execCommand hack could be done here to solve it a different way? I won't have a lot of time to investigate further until next week |
update: think i found a solution and just tested it. need to clean my code up and create tests and will push commits tomorrow thinkt im also gonna make a new PR and close this one |
Description
clipboard API doesnt support "application/x-lexical-editor" type which is causing pasting through context menu to lose orignal style of copied text
Trying to register application/x-lexical-format in the but $onPasteForRichText is only storing text/html and text/plain
Describe the changes in this pull request
Closes #6720 (attempts to)
see video for more info
Recording.2024-10-25.131106.mp4
Test plan
TBD
Before
After
TBD