I’m going to build an app soon that
I’m going to build an app soon that requires collaborative rich text editing, and I was wondering whether anyone here has thoughts about what kind of role Convex might play in such an application. Is collaborative editing (of any kind) the sort of feature that Convex can or will be able to support?
6 Replies
Hey! Great question!
I think the main question is how collaborative you want the editing to be.
If users will mostly edit rich text fields one at a time but want to see eachothers changes in realtime, Convex should work fine. You can save the rich text data within a document and have mutations that set the text to the new version every keystroke.
Obviously this won't work if two users are truly typing simultaneously because the last writer will over-write the other user's changes, but in many apps this is good enough.
If you want full Google Docs-style collaborative editing, you really need operational transforms which Convex doesn't currently support. Some day we may add this, but it's only really needed for a specific slice of apps, so it's not a focus right now (but I'll count this as a feature request!).
@RJ here's a bare-bones demo of collaborative editing with Convex that @lee put together: https://github.com/ldanilek/code_share
GitHub
GitHub - ldanilek/code_share
Contribute to ldanilek/code_share development by creating an account on GitHub.
re not supporting operations transforms, this is true in that we don't have APIs for them and we may someday, but in the meantime you can write them yourself or use a library like CodeMirror that implements them like Lee's code above
I am interested in Google Docs-style collaborative editing, but it's a great reminder that for many use cases you can probably get good enough behavior simply with reactive querying.
Thanks, I'll check this out!
The other popular solution for collaborative editing these days is CRDTs, through libraries like Yjs.
I guess my main concern was that I thought that OT-/CRDT-style collaborative editing solutions (and I've done more research into CRDTs here, so really I'm thinking of that) generally expected you to store docs/data that are being actively edited in memory somehow, through e.g. a long-running process that communicates with a Redis cache, in order to achieve sufficiently good performance beyond non-trivial scale.
But probably I should just do some experimenting with Convex first and see how it goes!
Good luck, please let us know what you find out!
In a prev project using the CodeMirror OT for collab code editing a couple years ago but with similar big-picture architecture as Convex this worked well, not doing it all in memory but actually hitting the db for each (slightly batched) edit.
There are some details to get right. Since CodeMirror can do the rebasing if you see bad perf it should manifest as chunkier updates from other clients.
That's definitely a good sign! I'll gladly keep you all updated. Thanks 🙂