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

Bug: "text/plain" clipboard data of copied table cells is incorrect #6541

Closed
mshafer opened this issue Aug 22, 2024 · 5 comments · Fixed by #6548
Closed

Bug: "text/plain" clipboard data of copied table cells is incorrect #6541

mshafer opened this issue Aug 22, 2024 · 5 comments · Fixed by #6548
Assignees
Labels
tables Relates to Lexical Tables

Comments

@mshafer
Copy link

mshafer commented Aug 22, 2024

When copying table cells from Lexical, the text/plain data is incorrect – it contains duplicated/nested versions of the content.

Copying this table:
image

Results in this text content when pasted in a text editor:
image

Lexical version: v0.17.0+dev.esm (current Lexical Playground version)

Steps To Reproduce

  1. Insert a table into the Lexical Playground
  2. Select cells from the table, then copy the cells
  3. Open a plain text editor and paste the content.
  4. Expect just the original cell content, observe that it contains duplicated versions of the original content

The current behavior

text/plain clipboard data of copied table cells contains duplicated content.

The expected behavior

text/plain clipboard data should be a simple representation of the original table cell content, with no duplication

Impact of fix

Any users of tables will get correct content when pasting into plain text environments. The current issue does not seem to impact copy paste of the text/html or application/x-lexical-editor versions of the data on the clipboard.

@etrepum
Copy link
Collaborator

etrepum commented Aug 24, 2024

I can't reproduce this, what exactly is the selection you have and which browser are you using?

@mshafer
Copy link
Author

mshafer commented Aug 24, 2024

It's a table selection with the anchor at the top-left cell and the focus in the bottom-right cell:
image

Inspecting the ClipboardEvent in Chrome shows:

> event.clipboardData.getData("text/plain")
'A\n\nB\n\n1\n\n2A\n\nBAAABBB1\n\n2111222'

This is in Chrome 128.0.6613.85.

Interestingly if I instead do a range selection that spans over the entire table, the pasted plaintext content is then correct.

@etrepum
Copy link
Collaborator

etrepum commented Aug 24, 2024

And how exactly are you copying the table in this scenario and which platform are you using? On macOS, I can't get cmd-C or the Chrome's edit menu copy to trigger the copy with a table selection on the current playground, but it does work with a range selection that includes the table

@mshafer
Copy link
Author

mshafer commented Aug 24, 2024

Oh yes I'm on macOS as well (Sonoma 14.4.1), and in the examples above I was using cmd-C to trigger the copy.

I can also reproduce the same behaviour using either "Edit > Copy" from Chrome's menu bar, or right-clicking a table cell and selecting "Copy". (In between each of these tests I copied some other text to wipe my clipboard data, just to be sure.)

Happy to share screen recordings of any of this if that helps.

@ivailop7 ivailop7 added the tables Relates to Lexical Tables label Aug 24, 2024
@ivailop7 ivailop7 self-assigned this Aug 24, 2024
@mshafer
Copy link
Author

mshafer commented Aug 25, 2024

Thank you for the fix, @etrepum and @ivailop7!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tables Relates to Lexical Tables
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants