View as Markdown

API reference: @salmonui/rich-text/collab

createCollaborationfunction

import { createCollaboration } from '@salmonui/rich-text/collab';
function createCollaboration(options: CollaborationOptions): RichTextExtension;

The collaboration extension: pass it in extensions (keep it stable, for example in useMemo per doc). It binds the editor to the Y.Doc (ySyncPlugin), shows remote cursors (yCursorPlugin, when awareness is given) and replaces the engine history with the per-user Yjs undo manager (yUndoPlugin): undo and redo, their keys and the toolbar buttons revert only the local user's changes. The Y.Doc is the source of truth, so do not drive a collaborative editor with a controlled value.