editor icon indicating copy to clipboard operation
editor copied to clipboard

[BUG] Copy-pasting tables into table cells is still possible and produces messed-up markdown.

Open vinczemarton opened this issue 8 months ago • 3 comments

  • [X] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [x] I have read the documentation and cannot find an answer.

Describe the bug

Copy-pasting tables into table cells is still possible and produces messed-up markdown.

To Reproduce

  1. Go to https://mdxeditor.dev/editor/demo
  2. Insert a table
  3. Copy some content from an other page containing a table, or a table from Excel (with Ctrl+C)
  4. Put the cursor inside one table cell in the markdown editor
  5. Paste the content (Ctrl+V)
  6. Check the markdown (source) view and observe the broken syntax

Expected behavior

There are different ways how this could work

  1. The table is cut out from the pasted content so only the non-table part is pasted.
  2. The pasted content still contains the table but is pasted after the originally targeted table
  3. A separate HTML extension is installed where it uses html tables instead of the GFM table syntax, which supports table nesting (but I imagine it is significantly more tedious to do than the others).

Screenshots

Image

Desktop (please complete the following information):

  • OS: [e.g. MacOS, Windows] - MacOS
  • Browser: Chrome, Firefox

Additional context

Please do not disable table copy-pasting in general to fix this, copy-pasting tables from excel or html is a fantastic feature.

I have found this related issue which was fixed by disabling the table button: https://github.com/mdx-editor/editor/issues/686

vinczemarton avatar May 28 '25 12:05 vinczemarton

While I agree with the problem, I believe that solution 1 and 2 are counter-intuitive, while, as you suggested, 3 is google sheets level of complexity.

petyosi avatar May 28 '25 13:05 petyosi

I'm looking around how what other wysiwyg solutions come up with and for example confluence does it fairly elegantly

If you only paste in table content (e.g. excel cells) it will completely overwrite table cells:

Before:

Image Image

After:

Image

It also extends the table with new rows and columns if the content does not fit

Image

Unfortunately while this is close to what I expect to happen and circumvents nested tables, if I have content on my clipboard that is not only tabulated data it will copy the content containing the table directly into the cell:

Before

Image

After

Image

This is not great, but supporting the first case might limit the cases where the resulting markdown is broken.

vinczemarton avatar May 28 '25 13:05 vinczemarton

Do you want to work on a PR for that? happy to accept one.

petyosi avatar May 28 '25 16:05 petyosi