Collaborative Editable Voids #279
-
First of all Thank you @BitPhinix for building out such a nice example. It has taken me some time to wrap my head around what is going on here. I'm working on building something similar to Taskade where each "item" in a list would be an editable void with a forced layout. I'm expanding off your example and everything is working fine, but edits made to the nested editors are not collaborative or saved by the y-websocket server. I'm thinking it is because the slate editors are being created without a corresponding Y.Doc, but the editable voids are being created in the same editor that has the corresponding y.doc. Does anyone have any advice on how I could approach this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi @Bartlett-Will, It's hard to give you specific advice for your implementation without knowing more details but the first thing I would try is to avoid nested editors to avoid the overhead of having multiple slate instances on the same page. While it isn't obvious in a lot of cases it is almost always doable and the better way to go. If you can't avoid nested editors you could reference the nested doc by key and use a different shared type for it. E.g. const doc = new Y.Doc();
// Main editor
const sharedType = doc.getArray<SyncElement>('content');
const yjsEditor = withYjs(editor, sharedType);
// Nested editor
const nestedEditorSharedType = doc.getArray<SyncElement>('nested-id'); // Referenced by key in the void block
const yjsEditor = withYjs(editor, nestedEditorSharedType); Although you might need some custom cursor sync code in that case. Or you might want to create entirely different Yjs documents for your nested editors which would make it easier to reference the content of the nested editors in other documents. Hope this helps, definitely let me know if something is unclear or you need help with anything else |
Beta Was this translation helpful? Give feedback.
Hi @Bartlett-Will,
It's hard to give you specific advice for your implementation without knowing more details but the first thing I would try is to avoid nested editors to avoid the overhead of having multiple slate instances on the same page. While it isn't obvious in a lot of cases it is almost always doable and the better way to go.
If you can't avoid nested editors you could reference the nested doc by key and use a different shared type for it. E.g.