Replies: 2 comments 12 replies
-
Hi @bjarkih, Thanks for bringing this up. The current cursor implementation definitely could need some love 😅. I've been meaning to work on improving it for quite some time now but couldn't yet find the time to do so. I'll set aside a bit of time this weekend to write a better implementation. |
Beta Was this translation helpful? Give feedback.
-
In our implementation, we do not update the decorate function, therefore we do not have frequent re-renders due to decorations. That being said, not sure what exactly you use for plugins, but i'll share our experience nonetheless. TLDR we found that the problem is slate-react, rather than slate-yjs. If the decorator function changes, the editor re-renders. We use a decorator function that pulls decorations from a WeakMap, so the decorator function is constant, and therefore not the reason for re-renders. Here's the catch though, provided you use slate-react: slate-react needs to invalidate the path to where the cursor is in order to update the cursor. To do so, we decorate all the nodes from the root to the selection like so:
In other words, we decorate the selection, but also add memo invalidation decorations along the path. |
Beta Was this translation helpful? Give feedback.
-
Hi all, and thanks for great work on Slate Yjs!
I have a question around the performance of the cursor decorator provided by the sample
useCursors
implementation. When editing a document that another user is editing at the same time, we're updating thedecorate
function as the remote cursor positions change, which leads to frequent re-renderings of the Slate editor. For me, this leads to a visibly sluggish editor experience as soon as multiple users are editing the same part of the document tree.Has anyone else encountered the same problem and, hopefully, found some solutions or workarounds? Any input appreciated!
Bjarki
Beta Was this translation helpful? Give feedback.
All reactions