Skip to content

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

Open

Description

@vinczemarton
  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • 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: #686

Activity

  1. petyosi commented on May 28, 2025

    @petyosi
    Contributor

    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.

  2. vinczemarton commented on May 28, 2025

    @vinczemarton
    Author

    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.

  3. petyosi commented on May 28, 2025

    @petyosi
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions