Skip to content

fix(plugin-clipboard, preset-gfm): fix pasting multiple tables from Google Docs - #2286

Merged
Saul-Mirone merged 3 commits into
mainfrom
fix/google-docs-multi-table-paste
Mar 23, 2026
Merged

Saul-Mirone merged 3 commits into
mainfrom
fix/google-docs-multi-table-paste

Conversation

@Saul-Mirone

Copy link
Copy Markdown
Member

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:

  1. Google Docs wraps all pasted content in <b style="font-weight:normal;" id="docs-internal-guid-..."> with <div> wrappers around each table. ProseMirror's parseSlice fails to parse the second table inside these wrappers, breaking it into orphaned table_row nodes and empty paragraphs.

  2. The clipboard plugin was re-parsing the HTML independently (ignoring ProseMirror's pre-processed Slice), which bypassed both transformPastedHTML and the paste rules (transformPasted).

Fix:

  • Add transformPastedHTML in the clipboard plugin to strip Google Docs <b> and <div> wrappers before ProseMirror parses the HTML.
  • Use ProseMirror's pre-processed Slice (3rd arg to handlePaste) when HTML is present, instead of re-parsing.
  • In the table paste rule, detect orphaned table_row nodes at the top level of a fragment and re-wrap them into proper tables.

@changeset-bot

changeset-bot Bot commented Mar 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 98512ab

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Mar 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
milkdown-storybook Ready Ready Preview, Comment Mar 23, 2026 2:47pm

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Mar 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

@milkdown/components

npm i https://pkg.pr.new/@milkdown/components@2286

@milkdown/core

npm i https://pkg.pr.new/@milkdown/core@2286

@milkdown/crepe

npm i https://pkg.pr.new/@milkdown/crepe@2286

@milkdown/ctx

npm i https://pkg.pr.new/@milkdown/ctx@2286

@milkdown/exception

npm i https://pkg.pr.new/@milkdown/exception@2286

@milkdown/kit

npm i https://pkg.pr.new/@milkdown/kit@2286

@milkdown/prose

npm i https://pkg.pr.new/@milkdown/prose@2286

@milkdown/transformer

npm i https://pkg.pr.new/@milkdown/transformer@2286

@milkdown/utils

npm i https://pkg.pr.new/@milkdown/utils@2286

@milkdown/react

npm i https://pkg.pr.new/@milkdown/react@2286

@milkdown/vue

npm i https://pkg.pr.new/@milkdown/vue@2286

@milkdown/plugin-automd

npm i https://pkg.pr.new/@milkdown/plugin-automd@2286

@milkdown/plugin-block

npm i https://pkg.pr.new/@milkdown/plugin-block@2286

@milkdown/plugin-clipboard

npm i https://pkg.pr.new/@milkdown/plugin-clipboard@2286

@milkdown/plugin-collab

npm i https://pkg.pr.new/@milkdown/plugin-collab@2286

@milkdown/plugin-cursor

npm i https://pkg.pr.new/@milkdown/plugin-cursor@2286

@milkdown/plugin-emoji

npm i https://pkg.pr.new/@milkdown/plugin-emoji@2286

@milkdown/plugin-highlight

npm i https://pkg.pr.new/@milkdown/plugin-highlight@2286

@milkdown/plugin-history

npm i https://pkg.pr.new/@milkdown/plugin-history@2286

@milkdown/plugin-indent

npm i https://pkg.pr.new/@milkdown/plugin-indent@2286

@milkdown/plugin-listener

npm i https://pkg.pr.new/@milkdown/plugin-listener@2286

@milkdown/plugin-prism

npm i https://pkg.pr.new/@milkdown/plugin-prism@2286

@milkdown/plugin-slash

npm i https://pkg.pr.new/@milkdown/plugin-slash@2286

@milkdown/plugin-tooltip

npm i https://pkg.pr.new/@milkdown/plugin-tooltip@2286

@milkdown/plugin-trailing

npm i https://pkg.pr.new/@milkdown/plugin-trailing@2286

@milkdown/plugin-upload

npm i https://pkg.pr.new/@milkdown/plugin-upload@2286

@milkdown/preset-commonmark

npm i https://pkg.pr.new/@milkdown/preset-commonmark@2286

@milkdown/preset-gfm

npm i https://pkg.pr.new/@milkdown/preset-gfm@2286

@milkdown/theme-nord

npm i https://pkg.pr.new/@milkdown/theme-nord@2286

commit: 98512ab

@Saul-Mirone
Saul-Mirone added this pull request to the merge queue Mar 23, 2026
Merged via the queue into main with commit b35ab27 Mar 23, 2026
14 checks passed
@Saul-Mirone
Saul-Mirone deleted the fix/google-docs-multi-table-paste branch March 23, 2026 15:26

This branch was successfully deployed

1 active deployment
Preview 98512ab4 Deployed Mar 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Incorrect table parsing when pasting content from Google Docs in Milkdown

1 participant