feat: attribution / suggestion-mode support (Yjs v14)#2843
Conversation
Adds full attribution support (suggestion mode + version diffs) to BlockNote on
the Yjs v14 rewrite, integrating @y/prosemirror's DiffAttributionManager.
- canonical `y-attributed-insert/delete/format` marks + `{name}--attributed`
variant nodes; relaxed blockContainer content expression
- `getBlockNode` abstraction (replaces "firstChild is the block"); getBlockFromPos
builds the block from the specific variant node so a container holding two
block-content variants (deleted + inserted) renders without throwing
"Block type does not match"
- UniqueID skips y-prosemirror sync/reconcile transactions, so BlockNote no
longer injects random ids into reconciled content (which never converged ->
infinite loop / freeze)
- block input rules defer the type change under attribution, avoiding the
@handlewithcare split-dispatch vs synchronous-reconcile "mismatched
transaction" throw that froze the editor on the `# ` shortcut
- deleted content is read-only + stripped on paste; attribution CSS
(green insert / red-strike delete / amber format)
- attribution-aware re-exports; 4-pane suggestion-mode demo; raw-PM and
full-editor (convergence + fuzz) test suites
Depends on the vendored Yjs v14 rc deps (vendor/*.tgz) until they are published.
See attribution-changes.md for the full design doc.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Someone is attempting to deploy a commit to the TypeCell Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
Adds full attribution support (suggestion mode + version diffs) to BlockNote on the Yjs v14 rewrite, integrating
@y/prosemirror'sDiffAttributionManager. In suggestion mode, edits render as tracked changes (green = inserted, red strike-through = deleted, amber = formatting) that can be accepted or rejected.Full design rationale and a step-by-step "how to reproduce the implementation" are in
attribution-changes.md.What's included
y-attributed-insert/delete/formatmarks +{name}--attributedvariant nodes; relaxedblockContainercontent expression; agetBlockNodeabstraction that replaces the "firstChild is the block" assumption.syncPlugin/configureYProsemirrorwired through the Collaboration extension with anattributionManager.acceptAllChanges/rejectAllChanges/acceptChanges/rejectChangesandgetBlockNode/canonicalBlockName/isDeletedNodere-exported from@blocknote/core.examples/01-basic/01-minimal.Suggestion-mode freeze fixes (the interesting bits)
getBlockFromPosbuilds the block from the specific variant node at the position, so a container holding a deleted paragraph next to an inserted heading renders both instead of throwing"Block type does not match"(a throwing NodeView re-renders forever = freeze).UniqueIDskips y-prosemirror's sync/reconcile transactions — BlockNote no longer injects randomv4()ids into reconciled content, which otherwise never equals the Yjs state and loops forever.@handlewithcare/prosemirror-inputrulessplit-dispatch vs synchronous-reconcile"Applying a mismatched transaction"throw that froze the editor on the#markdown shortcut.This depends on the unreleased Yjs v14 rewrite (
@y/y14.0.0-rc.17,lib01.0.0-rc.14,@y/prosemirror2.0.0-4), vendored as tarballs undervendor/via pnpmoverridesuntil they are published. Upstream CI will not pass until those are released — hence opening as a draft for discussion.🤖 Generated with Claude Code