Collaborative Editor
A complete collaborative editor: the shared document, the cursors, the presence bar and the connection status.
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.
Preview
Installation
Add the item with the shadcn CLI, or copy the source manually.
pnpm dlx shadcn@latest add litingyes/blocove/rich-text-editor-collaboration-blockRequires a shadcn/ui project set up with Base UI primitives. Blocove is developed against the b0 preset, but it installs no base config or theme tokens: your own preset, fonts and colors stay in place.
Or install from the namespace after adding the registry: npx shadcn@latest add @blocove/rich-text-editor-collaboration-block
This example also uses: rich-text-editor-collaboration-blockrich-text-editor-boldrich-text-editor-italicrich-text-editor-linkrich-text-editor-collaborationrich-text-editor-collaboration-caretrich-text-editor-presence
pnpm dlx 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-presencetypeset.css next to your stylesheet, import it after Tailwind and add the .typeset-docs preset. See the Rich text editor setup.Usage
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 ( <RichTextEditorCollaborationBlock document={sharedDocument} provider={provider} user={user} onChange={html => console.log(html)} /> )}API Reference
Props accepted by the exported components.
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 | - |