Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lexical-yjs] Feature: Allow passing in custom syncCursorPositions function to collab hook #7053

Merged
merged 3 commits into from
Jan 15, 2025

Conversation

amanharwara
Copy link
Contributor

Description

We created a custom syncCursorPositions function in our app to allow for more advanced styling and behavior than what the implementation exported by @lexical/yjs allows (which requires some CSS trickery even just to customize basic styling)

However we were noticing that sometimes some of the cursors would use the styles from the Lexical impl and not ours, even though those styles didn't exist in our codebase. It turned out that the syncYjsChangesToLexical function calls the lexical implementation of syncCursorPositions, so depending on which implementation ran first, some cursors would use incorrect styles. Also, the lexical implementation removes cursors for user states which are not focusing, while ours does not. This would cause flickering of the cursors since the Lexical impl would remove them and then ours would add them back.

Currently we have used yarn patch to remove this call, but I think it makes sense to allow a custom function to be passed so that it becomes possible to have a custom implementation of collab cursors without the existing lexical implementation also running.

Copy link

vercel bot commented Jan 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 9:23am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 9:23am

@facebook-github-bot facebook-github-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 Jan 15, 2025
Copy link

size-limit report 📦

Path Size
lexical - cjs 29.02 KB (0%)
lexical - esm 28.84 KB (0%)
@lexical/rich-text - cjs 37.97 KB (0%)
@lexical/rich-text - esm 30.9 KB (0%)
@lexical/plain-text - cjs 36.54 KB (0%)
@lexical/plain-text - esm 28.15 KB (0%)
@lexical/react - cjs 39.77 KB (0%)
@lexical/react - esm 32.26 KB (0%)

Copy link
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.

Seems reasonable and straightforward

@etrepum etrepum enabled auto-merge January 15, 2025 23:18
@etrepum etrepum added this pull request to the merge queue Jan 15, 2025
Merged via the queue into facebook:main with commit 136a565 Jan 15, 2025
40 checks passed
@amanharwara amanharwara deleted the custom-sync-cursor-positions branch January 16, 2025 07:21
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants