fix(plugin-clipboard, preset-gfm): fix pasting multiple tables from Google Docs - #2286
Merged
Merged
Conversation
|
|
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.
Closes #2259
The previous fix (#2283) resolved Case A (pasting a single table) but Case B (pasting a full document with multiple tables and text) was still broken — only the first table was parsed correctly, and remaining tables became plain text.
Root cause:
Google Docs wraps all pasted content in
<b style="font-weight:normal;" id="docs-internal-guid-...">with<div>wrappers around each table. ProseMirror'sparseSlicefails to parse the second table inside these wrappers, breaking it into orphanedtable_rownodes and empty paragraphs.The clipboard plugin was re-parsing the HTML independently (ignoring ProseMirror's pre-processed Slice), which bypassed both
transformPastedHTMLand the paste rules (transformPasted).Fix:
transformPastedHTMLin the clipboard plugin to strip Google Docs<b>and<div>wrappers before ProseMirror parses the HTML.handlePaste) when HTML is present, instead of re-parsing.table_rownodes at the top level of a fragment and re-wrap them into proper tables.