fix(preset-gfm): incorrect table parsing when pasting from Google Docs - #2283
Merged
Merged
Conversation
Google Docs tables use only <td>, never <th>. ProseMirror auto-inserts an empty table_header_row, resulting in an extra row with empty cells. Promote the first data row to header when there are 2+ data rows. For single-row tables, keep existing fallback (empty header cells). Also add recursive traversal in the paste rule so tables nested inside wrapper nodes are found and fixed. Closes #2259
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@milkdown/components
@milkdown/core
@milkdown/crepe
@milkdown/ctx
@milkdown/exception
@milkdown/kit
@milkdown/prose
@milkdown/transformer
@milkdown/utils
@milkdown/react
@milkdown/vue
@milkdown/plugin-automd
@milkdown/plugin-block
@milkdown/plugin-clipboard
@milkdown/plugin-collab
@milkdown/plugin-cursor
@milkdown/plugin-emoji
@milkdown/plugin-highlight
@milkdown/plugin-history
@milkdown/plugin-indent
@milkdown/plugin-listener
@milkdown/plugin-prism
@milkdown/plugin-slash
@milkdown/plugin-tooltip
@milkdown/plugin-trailing
@milkdown/plugin-upload
@milkdown/preset-commonmark
@milkdown/preset-gfm
@milkdown/theme-nord
commit: |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2259
Google Docs tables only use
<td>, never<th>. When pasting such a table, ProseMirror's schema (content: 'table_header_row table_row+') auto-inserts an emptytable_header_row, and the paste rule fills it with empty<br>cells — producing N+1 rows instead of N.The fix promotes the first data row to become the header row (converting
table_cell→table_header) when there are 2+ data rows. For single-row tables, the existing fallback (empty header cells) is kept to satisfy thetable_row+constraint.Also switched from flat
slice.content.forEachto a recursive traversal so tables nested inside wrapper nodes (e.g. Google Docs'<b><div>…</div></b>structure) are found and fixed.How did you test this change?
E2E tests.