[lexical-yjs] Feature: Allow passing in custom syncCursorPositions
function to collab hook
#7053
+20
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofsyncCursorPositions
, 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.