Skip to content

Table-safe diff rendering + id-aware block pairing - #2990

Draft
YousefED wants to merge 5 commits into
fix/versioning-diff-rerenderfrom
fix/matchnodes-table-ids
Draft

Table-safe diff rendering + id-aware block pairing#2990
YousefED wants to merge 5 commits into
fix/versioning-diff-rerenderfrom
fix/matchnodes-table-ids

Conversation

@YousefED

@YousefED YousefED commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #2989.

Fix 1: tables in diff mode

  • fixTables is now blocked while the editor is read-only (a filterTransaction on fixTablesKey meta in TableExtension, mirroring AIExtension's ai-writing gate). A rendered diff shows inconsistent tables on purpose (deleted/inserted row and column copies); letting prosemirror-tables "repair" them:
    • rewrote the displayed diff,
    • wrote the normalization back into the suggestion Y-doc through the read-only merged viewer's binding (the phantom empty cells removed from the tables.concurrent snapshots were exactly these artifacts), and
    • could crash the merge outright — the gallery's "Delete row vs add column" scenario (lib0 'Unexpected case') no longer crashes, verified in-browser; its knownCrash flag is removed.
  • The table-dimension pairing rule in blockMatchNodes (replace-when-both-dims-changed) is removed along with its helper; with the gate in place it guarded nothing, and removing it produced zero behavior changes in the suite.

Fix 2: pair blocks by id in blockMatchNodes

Containers with different block ids never pair in place (enforced only when both sides carry ids, so id-less external content still pairs by shape; delta attrs are op-wrapped — the values are compared). Pairing different blocks diffed one into the other, which rendered e.g. a full-document replacement as edits inside the first deleted block. Now the replacement renders as its own inserted block below the deleted document — resolving the documented issue on the "Delete a whole document" scenario (note removed).

The DiffVersioningExtension test fixture gives its before/after docs a stable id: they model one block at two points in time, the only shape real versioning inputs have (snapshots preserve ids).

Gallery notes

The six concurrent table scenarios now share one low-severity note: concurrent structural table edits aren't conflict-free — a pre-existing collaboration limitation (not diff-specific); a dedicated table CRDT in Yjs + BlockNote is the follow-up. The resolved "Merge cells" phantom-column and "Delete a whole document" placement notes are removed.

Validation

  • y-prosemirror e2e, all three browsers: 387 passed / 0 failed; snapshot churn reviewed hunk-by-hunk (all removed content = fixTables write-back artifacts, plus the intended remove-all shape change).
  • Core y + api unit suites: 472 passed.
  • In-browser: delete-whole-document diff placement, and the formerly-crashing "Delete row vs add column" suggestion merge.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved read-only table behavior by preventing unintended automatic table corrections.
    • Improved collaborative editing comparisons so blocks with different identities are handled correctly.
    • Improved version comparisons to recognize edits to the same block more accurately.
  • Documentation
    • Added consistent guidance for known low-severity limitations when merging concurrent table changes.
    • Clarified feedback for scenarios involving simultaneous table edits, row additions, and column changes.

prosemirror-tables' tableEditing() appends a normalizing fixTables
transaction whenever it sees an inconsistent table — and a rendered diff
shows inconsistent tables on purpose (deleted/inserted row and column
copies). Letting it run while a diff is displayed rewrote the very diff
being shown, wrote the normalization back into the suggestion Y-doc
through the read-only merged viewer's binding (the phantom empty cells in
the concurrent-table snapshots), and could crash the merge outright (the
'Delete row vs add column' gallery scenario: fixTables fed y-prosemirror
a delta Yjs can't apply). Read-only editors shouldn't self-normalize at
all: block fixTables transactions while the editor isn't editable,
mirroring AIExtension's ai-writing gate.
… rule

Two containers with different block ids are different blocks, no matter
how similar their content — pairing them diffed one block into the other
in place, which rendered e.g. a full-document replacement as edits inside
the first deleted block instead of a separately inserted one. Only
enforced when both sides carry an id (delta attrs are op-wrapped; compare
values), so id-less external content still pairs by shape.

The table-dimension pairing rule (replace the table when both dimensions
changed) is removed: with fixTables gated in diff mode the rendered
inconsistent tables it guarded against are displayed as-is, and the rule
produced no observable behavior differences in the suite.

The DiffVersioning test fixture now gives its before/after docs a stable
id — they model one block at two points in time, which is the only shape
real versioning inputs have (snapshots preserve ids across versions).
- 'Delete a whole document': resolved note removed (the replacement block
  now renders as its own insert below the deleted document).
- 'Merge cells': phantom-deleted-column note removed (it was the
  fixTables write-back, now gated).
- 'Delete row vs add column': no longer crashes with the fixTables gate
  (verified in-browser) — knownCrash flag and note removed.
- All six concurrent table scenarios share one low-severity note: table
  merges aren't conflict-free (pre-existing collaboration limitation,
  not diff-specific; a dedicated table CRDT is the follow-up).
@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
blocknote Ready Ready Preview Aug 20, 2026 2:26pm
blocknote-website Ready Ready Preview Aug 20, 2026 2:26pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ee87f36-b70c-4095-8f3d-a3f278c31485

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • No files to review - (🔄 Check again to try again)

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6160c7aa-f8f1-4c16-b826-352bb769766b

📥 Commits

Reviewing files that changed from the base of the PR and between 2904965 and e5d13a1.

⛔ Files ignored due to path filters (2)
  • tests/src/end-to-end/y-prosemirror/__snapshots__/addRemoveBlocks.test.tsx.snap is excluded by !**/*.snap, !**/__snapshots__/**
  • tests/src/end-to-end/y-prosemirror/__snapshots__/tables.concurrent.test.tsx.snap is excluded by !**/*.snap, !**/__snapshots__/**
📒 Files selected for processing (4)
  • examples/07-collaboration/14-suggestion-gallery/src/scenarios.ts
  • packages/core/src/blocks/Table/TableExtension.ts
  • packages/core/src/y/extensions/DiffVersioningExtension.test.ts
  • packages/core/src/y/extensions/blockMatchNodes.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The PR filters automatic table-fixing transactions in read-only editors, matches diff blocks by stable IDs, updates diff fixtures, and consolidates feedback for concurrent table scenarios.

Changes

Core behavior and collaboration scenarios

Layer / File(s) Summary
Read-only table transaction filtering
packages/core/src/blocks/Table/TableExtension.ts
TableExtension registers a keyed plugin that rejects fixTables transactions when the editor is not editable.
ID-based block diff matching
packages/core/src/y/extensions/blockMatchNodes.ts, packages/core/src/y/extensions/DiffVersioningExtension.test.ts
Block containers with different IDs no longer match in place. Diff fixtures use a stable block ID.
Shared concurrent table feedback
examples/07-collaboration/14-suggestion-gallery/src/scenarios.ts
Six table scenarios use shared low-severity feedback. Scenario-specific crash, phantom-column, and paragraph-placement notes are removed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to e5d13

The PR changes diff rendering and block pairing while reporting focused browser and unit validation; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: nperez0111

Poem

A rabbit guards the tables bright,
Blocks find their IDs just right.
Fixes pause when editors rest,
Shared notes guide each merge test.
Hop, hop—diffs now match their best!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the two primary changes: safer table diff rendering and ID-aware block pairing.
Description check ✅ Passed The description explains the rationale, changes, impact, testing results, and additional context, although it omits the template checklist and media section.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/matchnodes-table-ids

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Aug 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@2990

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@2990

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@2990

@blocknote/diagram-block

npm i https://pkg.pr.new/@blocknote/diagram-block@2990

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@2990

@blocknote/math-block

npm i https://pkg.pr.new/@blocknote/math-block@2990

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@2990

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@2990

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@2990

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@2990

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@2990

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@2990

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@2990

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@2990

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@2990

commit: bf2e469

@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://TypeCellOS.github.io/BlockNote/pr-preview/pr-2990/

Built to branch gh-pages at 2026-08-20 14:31 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@nperez0111 nperez0111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great

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.

2 participants