Skip to content

fix(versioning): diff structural changes made by the old Yjs binding - #3167

Merged
YousefED merged 0 commit into
fix/version-diff-cascade-attributionfrom
fix/legacy-version-diff-structure
Oct 8, 2026
Merged

YousefED merged 0 commit into
fix/version-diff-cascade-attributionfrom
fix/legacy-version-diff-structure

Conversation

@YousefED

@YousefED YousefED commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #3166.

Problem

The old y-prosemirror (Yjs v13) binding stored some structural changes inside the same block container. These changes are:

  • a type change of a block;
  • a block that gets or loses nested children;
  • a table resize.

The current binding prevents this with blockMatchNodes. It stores these changes as a replaced block.

Version history can make a diff of such an old change. The merged render then has two block contents (or two groups) in one container. The schema does not allow this. Thus, @y/prosemirror drops it and shows no error. The changed block is not in the diff. For example, a paragraph → heading change shows only the deleted paragraph.

Change

snapshotPreview.ts: before the diff renders, splitChangedBlocks examines the decoded snapshot. The snapshot is a temporary copy. It is never the live document or the stored document. Some blocks existed in the baseline, and blockMatchNodes considers them changed. splitChangedBlocks replaces each of these blocks with a new copy. The diff then shows a deleted block next to an inserted block. This is the same diff as for a change by the current binding.

The copy and the local deletion get the attributions of the original. They are converted to the correct kind. Thus, the change keeps its author: "Deleted by"/"Inserted by" the user who made the change.

Covered (for each case, the diff is the same as for a change by the current binding, with the same authors)

  • type change (paragraph → heading);
  • type change of a block with nested children;
  • type change and a text edit in the same block;
  • nesting change (a block gets a child group);
  • table resize in the two dimensions;
  • plain text edits by the old binding: not split (control test).

Not covered

  • Known issue: concurrent table resizes by the current binding. Two users can resize a table at the same time. splitChangedBlocks then also splits this table, although the current binding made the change. The diff then shows the whole table as deleted and inserted again. The versioning snapshot records this. For example, "Delete row vs add column" shows the whole table as deleted by A and inserted by B. Other examples are "Add column vs add row" and "A adds column then row, B adds column". We will examine this again.
  • Suggestion mode over type changes from the old binding: live suggestions do not use snapshotPreview. This needs a binding transformer.
  • Restore of a version across such a change: not tested.
  • Concurrent type changes between two clients with the old binding: these clients delete the block before history sees it. The block is attributed to one of the clients. See the provenance discussion in feat!: rebuild version history and customize snapshot actions #3090.
  • Performance: for each comparison, the split makes a delta of the two versions for each block that existed in the baseline. We did not measure this on large documents.

Tests

The tests are in #3090, in legacyYjsDocBinding.test.ts:

  • a control: the type-change diff of the current binding, with authors;
  • a parameterised "old binding diffs like the current binding" test for the five structural cases;
  • a text-edit control. This control must not split.

On #3090, the 5 structural cases are marked it.fails, with the comment "To be fixed by #3167". This PR changes them to normal tests.

The tests for the new binding use gc: false documents, as stored history does.

Versioning snapshot (tests/src/end-to-end/y-prosemirror/__snapshots__/versioning.test.tsx.snap): this PR changes only the table scenarios with two users that resize the same table. See the known issue above.

@vercel

vercel Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
blocknote Ready Ready Preview Oct 8, 2026 2:28pm UTC
blocknote-website Ready Ready Preview Oct 8, 2026 2:28pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 Oct 8, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

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

@blocknote/code-block

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

@blocknote/core

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

@blocknote/diagram-block

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

@blocknote/mantine

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

@blocknote/math-block

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

@blocknote/react

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

@blocknote/server-util

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

@blocknote/shadcn

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

@blocknote/xl-ai

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

@blocknote/xl-docx-exporter

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

@blocknote/xl-email-exporter

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

@blocknote/xl-multi-column

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

@blocknote/xl-odt-exporter

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

@blocknote/xl-pdf-exporter

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

@blocknote/xl-typst-exporter

npm i https://pkg.pr.new/@blocknote/xl-typst-exporter@3167

commit: c3ed733

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-08 14:26 UTC

@YousefED
YousefED added this pull request to stack #3169 October 8, 2026 04:22
@YousefED
YousefED force-pushed the fix/legacy-version-diff-structure branch from c3ed733 to b2ceae6 Compare October 8, 2026 14:25
@YousefED
YousefED merged commit b2ceae6 into main Oct 8, 2026
@YousefED
YousefED deleted the fix/legacy-version-diff-structure branch October 8, 2026 14:25
@YousefED
YousefED restored the fix/legacy-version-diff-structure branch October 8, 2026 14:26

This branch was successfully deployed

2 active deployments
Preview – blocknote-website — b2ceae6c Deployed Oct 8, 2026 by vercel[bot]
Preview – blocknote — b2ceae6c Deployed Oct 8, 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.

1 participant