Skip to content

[lexical-yjs][lexical-react] Feature: commands for diffing two yjs snapshots in collab v2#7903

Merged
etrepum merged 2 commits intofacebook:mainfrom
james-atticus:yjs-v2-snapshot-diff
Oct 6, 2025
Merged

[lexical-yjs][lexical-react] Feature: commands for diffing two yjs snapshots in collab v2#7903
etrepum merged 2 commits intofacebook:mainfrom
james-atticus:yjs-v2-snapshot-diff

Conversation

@james-atticus
Copy link
Copy Markdown
Contributor

Description

Extends the collab v2 sync logic to add support for comparing two versions (Yjs snapshots) of a Lexical document. Determining what text has been added/removed is handled by Yjs' YText.toDelta. For non-text nodes, I've adapted the logic from the y-prosemirror binding.

Two new commands are defined in @lexical/yjs with handlers implemented in @lexical/react. I've also added a basic plugin in the playground for adding snapshots and comparing the latest editor state with said snapshots.

Test plan

Added unit tests to cover the commands handled in @lexical/react. Demo of the playground code:

lexical-version-diff.mp4

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 6, 2025
@vercel
Copy link
Copy Markdown

vercel bot commented Oct 6, 2025

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

Project Deployment Preview Comments Updated (UTC)
lexical Ready Ready Preview Comment Oct 6, 2025 6:33am
lexical-playground Ready Ready Preview Comment Oct 6, 2025 6:33am

Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

Wow, this is a really great demo of collab v2! I didn't have a super thorough look at all of the details but it seems very isolated to collab v2

@etrepum etrepum added this pull request to the merge queue Oct 6, 2025
Merged via the queue into facebook:main with commit 757abe0 Oct 6, 2025
43 of 71 checks passed
@etrepum etrepum mentioned this pull request Oct 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants