Problem
Design a collaborative rich-text editor supporting real-time multi-user editing, formatting, and presence.
Discussion areas
- Editing model: contentEditable vs a model-driven editor (ProseMirror/Slate-like). Maintain a document model, not raw HTML.
- Concurrency: Operational Transformation (OT) or CRDT to merge concurrent edits without conflicts. Discuss trade-offs (OT needs a central server; CRDTs are eventually consistent and P2P-friendly).
- Sync: send small ops over WebSocket; server broadcasts/transforms; clients apply and acknowledge; handle offline edits and reconnection.
- Presence: show collaborators' cursors/selections (broadcast cursor positions, map to local doc positions after transforms).
- Formatting: bold/italic/lists/headings as marks/attributes in the model; undo/redo per-user.
- Performance: debounce/batch ops, virtualize very long docs, incremental rendering.
- Persistence: autosave, version history, conflict-free reconciliation.