# @salmonui/rich-text/collab API reference

> 6 exported symbols of @salmonui/rich-text/collab: 3 functions and 3 interfaces.

Canonical: https://salmonui.dev/docs/reference/rich-text/collab

```ts
import { … } from '@salmonui/rich-text/collab';
```

## Functions

### collaborationDocToHtml

Kind: function

Page: https://salmonui.dev/docs/reference/rich-text/collab/collaborationDocToHtml

```ts
function collaborationDocToHtml(doc: Y.Doc, options?: CollaborationHtmlOptions): Promise<string>;
```

Sanitized HTML of a Y.Doc (server rendering, persistence, previews with RichTextContent).

### createCollaboration

Kind: function

Page: https://salmonui.dev/docs/reference/rich-text/collab/createCollaboration

```ts
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`.

### seedCollaborationDoc

Kind: function

Page: https://salmonui.dev/docs/reference/rich-text/collab/seedCollaborationDoc

```ts
function seedCollaborationDoc(doc: Y.Doc, html: string, options?: CollaborationHtmlOptions): Promise<void>;
```

Seeds an empty Y.Doc with HTML (sanitized and parsed through the shared
schema), on the server or by the first client. Seed a doc only once: an
editor bound to a seeded doc renders the doc, not its own `value`. Loads
the engine on demand, so the `/collab` entry stays small.

## Interfaces

### CollaborationHtmlOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/rich-text/collab/CollaborationHtmlOptions

```ts
interface CollaborationHtmlOptions {
    readonly fragment?: string;
    readonly embedHosts?: readonly string[];
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `fragment` | `readonly fragment?: string;` | optional |  |
| `embedHosts` | `readonly embedHosts?: readonly string[];` | optional |  |

### CollaborationOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/rich-text/collab/CollaborationOptions

```ts
interface CollaborationOptions {
    readonly doc: Y.Doc;
    readonly fragment?: string;
    readonly awareness?: Awareness;
    readonly user: CollaborationUser;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `doc` | `readonly doc: Y.Doc;` |  | The shared document. Seed it once (see seedCollaborationDoc); the editor then renders its content. |
| `fragment` | `readonly fragment?: string;` | optional | Name of the Y.XmlFragment holding the content (default `'prosemirror'`). |
| `awareness` | `readonly awareness?: Awareness;` | optional | Presence: remote cursors and selections with the user's name and color. |
| `user` | `readonly user: CollaborationUser;` |  |  |

### CollaborationUser

Kind: interface

Page: https://salmonui.dev/docs/reference/rich-text/collab/CollaborationUser

```ts
interface CollaborationUser {
    readonly id: string;
    readonly name: string;
    readonly color: string;
}
```

The local user as remote peers see them (cursor label and color).

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: string;` |  |  |
| `name` | `readonly name: string;` |  |  |
| `color` | `readonly color: string;` |  | A CSS color for the remote cursor and selection, for example `#2563eb`. |
