# Collaborative Editor A complete collaborative editor: the shared document, the cursors, the presence bar and the connection status. ## Installation ```bash npx shadcn@latest add litingyes/blocove/rich-text-editor-collaboration-block ``` > Typography requires [shadcn/typeset](https://ui.shadcn.com/docs/typeset). Copy `typeset.css` next to your main stylesheet, import it after Tailwind and add the `.typeset-docs` preset. This example also uses: `rich-text-editor-collaboration-block`, `rich-text-editor-bold`, `rich-text-editor-italic`, `rich-text-editor-link`, `rich-text-editor-collaboration`, `rich-text-editor-collaboration-caret`, `rich-text-editor-presence`. ```bash npx shadcn@latest add litingyes/blocove/rich-text-editor-collaboration-block litingyes/blocove/rich-text-editor-bold litingyes/blocove/rich-text-editor-italic litingyes/blocove/rich-text-editor-link litingyes/blocove/rich-text-editor-collaboration litingyes/blocove/rich-text-editor-collaboration-caret litingyes/blocove/rich-text-editor-presence ``` The block owns no transport: create the Yjs document and the provider in the app, connect them to your Hocuspocus server, and pass them in. It takes no `value` or `defaultValue` because the shared document is the source of truth; seed the Yjs document server-side (or with the first peer) instead of the React tree. `onChange` also fires for remote edits, since every peer sees the same document. ## Usage ### Use the block ```tsx import { RichTextEditorCollaborationBlock } from "@/components/blocove/rich-text-editor-collaboration-block" import { HocuspocusProvider } from "@hocuspocus/provider" import * as Y from "yjs" const sharedDocument = new Y.Doc() const provider = new HocuspocusProvider({ url: "wss://collab.example.com", name: "product-launch", document: sharedDocument, }) const user = { name: "Ada Lovelace", color: "#2563eb" } export function DocumentEditor() { return ( console.log(html)} /> ) } ``` ## API Reference ### RichTextEditorCollaborationBlock The shared document, the cursors, the presence bar and the connection status, composed in one file. | Prop | Type | Default | | --- | --- | --- | | `document` | `Y.Doc` | `required` | | `provider` | `CollaborationProvider` | `required` | | `user` | `CollaborationUser` | `required` | | `placeholder` | `string` | `"Start writing together…"` | | `editable` | `boolean` | `true` | | `onChange` | `(html: string) => void` | - | | `presenceLimit` | `number` | `4` | | `className` | `string` | - | ## Registry dependencies - `litingyes/blocove/rich-text-editor` - `litingyes/blocove/rich-text-editor-text` - `litingyes/blocove/rich-text-editor-paragraph` - `litingyes/blocove/rich-text-editor-hard-break` - `litingyes/blocove/rich-text-editor-bold` - `litingyes/blocove/rich-text-editor-italic` - `litingyes/blocove/rich-text-editor-link` - `litingyes/blocove/rich-text-editor-collaboration` - `litingyes/blocove/rich-text-editor-collaboration-caret` - `litingyes/blocove/rich-text-editor-presence` Namespace: `npx shadcn@latest add @blocove/rich-text-editor-collaboration-block`