[BUG] Copy-pasting tables into table cells is still possible and produces messed-up markdown.
- [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
- Go to https://mdxeditor.dev/editor/demo
- Insert a table
- Copy some content from an other page containing a table, or a table from Excel (with Ctrl+C)
- Put the cursor inside one table cell in the markdown editor
- Paste the content (Ctrl+V)
- Check the markdown (source) view and observe the broken syntax
Expected behavior
There are different ways how this could work
- The table is cut out from the pasted content so only the non-table part is pasted.
- The pasted content still contains the table but is pasted after the originally targeted table
- 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
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
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.
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:
After:
It also extends the table with new rows and columns if the content does not fit
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
After
This is not great, but supporting the first case might limit the cases where the resulting markdown is broken.
Do you want to work on a PR for that? happy to accept one.