{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rich-text-editor-collaboration",
  "title": "Collaboration",
  "description": "Binds the editor document to a Yjs document, so every peer edits the same shared state.",
  "dependencies": [
    "@tiptap/extension-collaboration@3.32.2",
    "@tiptap/y-tiptap@3.3.0",
    "yjs@13.6.33"
  ],
  "registryDependencies": [
    "litingyes/blocove/rich-text-editor-extension"
  ],
  "files": [
    {
      "path": "src/registry/blocove/ui/rich-text-editor/collaboration.tsx",
      "content": "import type * as Y from 'yjs'\nimport type { ExtensionComponent } from '@/lib/blocove/rich-text-editor-extension'\nimport { Collaboration } from '@tiptap/extension-collaboration'\nimport { defineExtensionComponent } from '@/lib/blocove/rich-text-editor-extension'\n\n/**\n * A collaborator advertised through the provider's awareness. The caret, the\n * presence bar and the cursor decorations all read this shape.\n */\nexport interface CollaborationUser {\n  name: string\n  /** Cursor and avatar colour, as a CSS colour. */\n  color?: string\n  /** Avatar image URL; initials are rendered without one. */\n  avatar?: string\n  [key: string]: unknown\n}\n\n/** The awareness instance a collaboration provider exposes. */\nexport interface CollaborationAwareness {\n  clientID: number\n  getStates: () => Map<number, Record<string, unknown>>\n  on: (event: 'change' | 'update', handler: () => void) => void\n  off: (event: 'change' | 'update', handler: () => void) => void\n}\n\n/**\n * The part of a collaboration provider the editor items read. It is structural\n * on purpose: Hocuspocus, a Tiptap Cloud provider or a local transport all fit,\n * and the items never import a provider package.\n */\nexport interface CollaborationProvider {\n  awareness: CollaborationAwareness | null\n  /** Current connection status, when the provider exposes one. */\n  status?: string\n  on?: (event: 'status', handler: (payload: { status?: string }) => void) => void\n  off?: (event: 'status', handler: (payload: { status?: string }) => void) => void\n}\n\nexport interface EditorCollaborationProps {\n  /** The Yjs document every peer syncs into. Create one with `new Y.Doc()`. */\n  document: Y.Doc\n  /** The field inside the document. Defaults to `\"default\"`. */\n  field?: string\n}\n\n/**\n * Binds the editor document to a Yjs document instead of an HTML string.\n *\n * The editor stops seeding its content from `value` or `defaultValue` once this\n * extension is declared: the shared document is the source of truth, and the\n * sync plugin owns the transactions that write to it.\n */\nexport const EditorCollaboration: ExtensionComponent<EditorCollaborationProps>\n  = defineExtensionComponent('collaboration', ({ document, field }) => {\n    if (!document) {\n      throw new Error(\n        '[blocove/rich-text-editor] EditorCollaboration requires the Yjs document every peer syncs into. Create one with `new Y.Doc()` and share it through your provider.',\n      )\n    }\n\n    return [\n      Collaboration.configure({\n        document,\n        field: field ?? 'default',\n      }),\n    ]\n  })\n",
      "type": "registry:ui",
      "target": "components/blocove/rich-text-editor/collaboration.tsx"
    }
  ],
  "categories": [
    "rich-text-editor",
    "collaboration"
  ],
  "type": "registry:ui"
}