> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reducto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Types: editor: Collaboration

## `CollabOptions`

Not exported by name. You get it from the API.

| Name | Type | Description |
| - | - | - |
| `block?` | `number` | This writer's id block (1 and up), unique among the writers of the document. New links, pictures, comments and lists take ids inside it, so two writers never mint the same one. |
| `observe?` | `(applied: AppliedChange) => void` | Every change the document takes from now on: typing, remote, applied, undo and redo. |
| `onError?` | `(error: unknown) => void` | A remote change failed to apply: the copy has drifted and must be reopened. |
| `presence?` | `(presence: Presence) => void` | Where this writer's selection now is, for the other writers. |
| `send?` | `(out: Outgoing) => void` | Where this writer's changes go. Without it the editor sequences its own: one writer, no server. |
| `seq?` | `number` | Server change the open document reflects; 0 without `send`. |

## `LiveDocInfo`

Import from `@reductoai/docx-editor`.

| Name | Type | Description |
| - | - | - |
| `created` | `number` | |
| `id` | `string` | |
| `kind` | `"docx"` | |
| `name` | `string` | |
| `updated` | `number` | |

## `LiveExec`

Import from `@reductoai/docx-editor`.

| Name | Type | Description |
| - | - | - |
| `author` | `string` | |
| `done` | `boolean` | |
| `error?` | `string` | |
| `execId` | `string` | |
| `lines` | `string[]` | |
| `result?` | `unknown` | |
| `seq?` | `number` | |

## `LiveOp`

An op the server sequenced, as every subscriber gets it.

Import from `@reductoai/docx-editor`.

| Name | Type | Description |
| - | - | - |
| `at` | `number` | |
| `author` | `string` | |
| `change` | `CollabChange` | |
| `client?` | `string` | |
| `clientOpId?` | `string` | |
| `code?` | `string` | |
| `intent?` | `string` | |
| `logs?` | `string[]` | |
| `result?` | `unknown` | |
| `seq` | `number` | |
| `type` | `"edit" \| "exec" \| "replace"` | |

## `LiveOptions`

Import from `@reductoai/docx-editor`.

| Name | Type | Description |
| - | - | - |
| `doc` | `string` | The document id: one your backend created with `PUT /docs/:id`. |
| `keepalive?` | `number` | Milliseconds between keepalive pings while the socket is open, so a proxy or load balancer does not close an idle socket. A ping with no answer by the next one drops the socket and reconnects. 0 turns it off. Only a server that says it answers pings gets them. Default 30000. |
| `name?` | `string` | Shown to other editors and the default revision author; with a token, the server uses the token's `name` instead. `setRevisionAuthor` overrides it. |
| `onError?` | `(error: DocserverError) => void` | Called on anything the editor cannot recover from without reloading; default console.error. The error is a `DocserverError`: quote its `traceId` to whoever runs the server. |
| `peerColor?` | `(name: string) => string \| undefined` | The colour of each other writer's caret, range and name tag, e.g. to match your own avatars. Each tab paints with its own function, so give every tab the same one. Return undefined to keep the default `peerColor(name)`. |
| `token?` | `string \| (() => string \| Promise<string>)` | The access token, or a function that fetches one from your backend. It is called again on every reconnect and request, so a short-lived token renews itself. |
| `url?` | `string` | The docserver's origin, e.g. `https://docs.example.com`. Default: this page's. |

## `LivePeer`

Import from `@reductoai/docx-editor`.

| Name | Type | Description |
| - | - | - |
| `client` | `string` | |
| `name` | `string` | |
| `presence?` | `LivePresence` | |

## `LivePresence`

Not exported by name. You get it from the API.

| Name | Type | Description |
| - | - | - |
| `anchor` | `number` | |
| `focus` | `number` | |
| `seq` | `number` | |
| `story?` | `string` | |

## `LiveSession`

Import from `@reductoai/docx-editor`.

| Name | Type | Description |
| - | - | - |
| `client` | `string` | |
| `state` | `LiveState` | |
| `close()` | `() => void` | |
| `download()` | `() => Promise<Uint8Array<ArrayBufferLike>>` | The current bytes, from the server. |
| `exec()` | `(code: string) => void` | Runs Office.js code on the server copy; its edits arrive as ops, its logs in `state.execs`. |
| `subscribe()` | `(fn: (state: LiveState) => void) => () => void` | `fn` runs after every change of `state`; the return value unsubscribes. |
| `synced()` | `() => Promise<void>` | Resolves when the server has every edit this tab made before the call, so exec code, `download` and other tabs see them. Waits through a reconnect; rejects if the tab closes or reloads first. |

## `LiveState`

Import from `@reductoai/docx-editor`.

| Name | Type | Description |
| - | - | - |
| `error` | `string` | |
| `errorTrace?` | `string` | The trace id of the last error, when the server gave one. |
| `execs` | `LiveExec[]` | |
| `info` | `LiveDocInfo \| null` | |
| `layoutMismatch?` | `{ editor: string; server: string }` | Set when the server lays out with another @reductoai/docx version than this editor: its page images and the pages agent code names can break elsewhere than the pages on screen. |
| `ops` | `LiveOp[]` | |
| `peers` | `LivePeer[]` | |
| `readOnly` | `boolean` | |
| `seq` | `number` | |
| `status` | `LiveStatus` | |
| `traceId?` | `string` | The live connection's trace id: the server's log lines for this tab's edits carry it. |

## `LiveStatus`

Import from `@reductoai/docx-editor`.

```ts theme={null}
type LiveStatus = "loading" | "connecting" | "live" | "offline" | "closed"
```

## `LiveStep`

A step of a drag in progress: the host relayouts it like any edit, but the
steps of one drag form one undo entry. The step sent without `live` when
the pointer lifts joins that entry and closes it.

Not exported by name. You get it from the API.

| Name | Type | Description |
| - | - | - |
| `live?` | `boolean` | |

## `Peer`

Another writer in the session and where their selection was last reported.

Import from `@reductoai/docx-editor`, `@reductoai/docx-editor/model`.

| Name | Type | Description |
| - | - | - |
| `id` | `string` | |
| `name` | `string` | |
| `presence` | `Presence` | |

## `PeerCursor`

A peer's selection placed on this replica.

Import from `@reductoai/docx-editor`, `@reductoai/docx-editor/model`.

| Name | Type | Description |
| - | - | - |
| `anchor` | `Position` | |
| `focus` | `Position` | |
| `id` | `string` | |
| `name` | `string` | |
