Skip to Content
API Referencecollab-adapter-react

@stesura/collab-adapter-react

React bindings for collaboration: the mount hooks for the Pitter Patter server tier and the local tier, rooms, presence and connection UI, and the comment and proofread adapters that sync through the collab backend. The plugins underneath are in @stesura/collab-adapter.

Server collaboration

useCollabEditor

Editor state synced through a Pitter Patter CollabAuthority. Reads docId, apiBasePath and fetch from the nearest CollabProvider.

Returns the same shape as useLocalEditor (editorState, dispatch, pluginFactory, schema) plus docStatus and reconnect. docStatus:

  • “gone”: the doc was removed (410 from any loop). Terminal.
  • “error”: hydration can never succeed (terminal status, failure ceiling, unparseable snapshot) or the server refuses this client’s protocol version (426). Terminal.
  • “schema-mismatch”: the server refused this client’s schema at the handshake, the snapshot names a node or mark the schema lacks, or a polled commit does not parse: the server or another client runs a different schema. Terminal; a reload picks up the new bundle. onError gets a SchemaMismatchError with the unknown types or both fingerprints.
  • “disconnected”: a sync loop stopped on a terminal status or repeated failures. Recoverable: the editor keeps the unconfirmed edits, reconnect() resumes, and so does any send that gets through. Switching to view mode while disconnected is left to the host.
Parameters:
NameTypeDefault
__0UseCollabEditorArgs
Returns:
{ editorState: EditorState | null; dispatch: DispatchFn; pluginFactory: (args: { editorId: string; parentEditorId?: string; currentUser?: CurrentUser; }) => (Plugin<...> | Plugin<...>)[]; schema: Schema<...>; docStatus: "error" | ... 4 more ... | "disconnected"; reconnect: () => void | undefined; }

UseCollabEditorArgs

Arguments for useCollabEditor.

The connection re-initialises only when the provider’s docId, apiBasePath or fetch changes (or after a 412 resync). schema is fixed per mount, and editorId, configuration, pluginOptions, extraPlugins, initialContent and presenceCursorDisplay are read when the connection initialises; remount with a React key to change them. Read live: transactionModifier, getPresenceDisplayName, getPresenceAvatar, onInlineImageRejected, onUnmergedEdits, onError and the current user (presence re-announces when it resolves).

NameTypeDefault
editorIdstring
schemaSchema<any, any>
configurationConfigPluginProps
pluginOptionsStesuraPluginsOptions
extraPlugins(args: { editorId: string; parentEditorId?: string; }) => Plugin<any>[]

Extra plugins for the editor, appended after the collab-bound stack.

transactionModifierTransactionModifierFn
initialContentNode | Fragment | Content
getPresenceDisplayName(userId: string) => string

Maps a remote userId to its cursor label name. Synchronous; defaults to the raw userId.

getPresenceAvatar(userId: string) => string | undefined

Maps a remote userId to its cursor avatar URL. Without one, the cursor shows initials.

presenceCursorDisplayPresenceCursorDisplay

How remote carets are labelled: "avatar" (name on hover, the default), "avatar-name" or "name".

onInlineImageRejected() => void

Called each time a dropped/pasted image is refused. Collab docs never embed base64 images (they bloat every commit and can exceed the payload cap), so with no upload strategy installed, images are refused; surface that to the user.

onEditRejected() => void

Called when an edit was too large to apply: refused before it applied (a bulk command over the collab document’s step limit, lower on very long sections), or refused by the server (over its step or size cap) and undone, keeping anything typed after it. Tell the user, e.g. “The change was too large to apply. Nothing was changed.”

onUnmergedEdits(unmerged: UnmergedEdits) => void

Called when edits the server will never merge are dropped, with the user’s version of the document so the host can offer it back. A client behind the server’s commit window rebases its edits across what it missed and calls this only for what no longer applied (reason: "gap"), or with all of them when the server has no step maps that far back ("stale"). Edits over the server’s size cap that can’t be undone alone (see onEditRejected): "tooLarge". The editor then shows the server’s document, with whatever merged.

onErrorCollabErrorReporter

Telemetry sink for failures the sync loops handle internally (retries, terminal statuses, abandoned commits). Without it they only reach the console.

CollabProvider

Provides the collab document connection (docId, API base path, authenticated fetch) and wires comments to the backend’s /threads routes; thread sync pauses while the page is hidden.

Pass comments={false} if the backend doesn’t serve the thread routes: the comments UI then uses the no-op adapter instead of flagging thread sync as failed on the first 404.

headers and credentials apply to every request under this provider: sync, presence and comments alike.

Parameters:
NameTypeDefault
__0CollabProviderProps
Returns:
string | number | bigint | boolean | Element | Iterable<ReactNode> | Promise<AwaitedReactNode> | null

CollabProviderProps

Props of CollabProvider.

NameTypeDefault
childrenReactNode
docIdstring | undefined

undefined while the id is still resolving; the provider then renders CollabProviderProps.loadingState instead of children.

apiBasePathstring

Prefix for the collab API routes, e.g. /demo. Defaults to "" (same origin).

commentsboolean

Sync comment threads through the backend’s /threads routes. Default true; set false if the backend doesn’t serve them (comments then render empty).

loadingStateReactNode

Shown while docId is undefined. Defaults to the editor skeleton; null renders nothing.

onErrorCollabErrorReporter

Telemetry sink for thread-sync failures. See UseCollabEditorArgs.onError.

onUnmergedComment(unmerged: UnmergedComment) => void

A comment written offline the server would not take once it was sent (refused, its thread or document deleted meanwhile): the thread as the user left it, to tell them and offer their text back, as UseCollabEditorArgs.onUnmergedEdits does for the document. Read live.

headersCollabHeaders

Sent on every request, typically a bearer token.

credentialsRequestCredentials

"include" for cookie auth against a collab server on another origin.

UnmergedComment

Comments written offline are kept and sent once the server answers, across a tab close too. When the server then refuses one, or its thread or document was deleted meanwhile, onUnmergedComment gets it as UnmergedComment: the thread as the user left it, to tell them and offer their text back.

A comment write made offline that was dropped when it was finally sent, handed to the host so the user can be told and their text recovered. "refused": the server refused it (status); "deleted": the thread was removed for good meanwhile; "gone": the document was.

NameTypeDefault
reason"gone" | "refused" | "deleted"
threadIdstring
threadSerializedThread

The thread as the user left it.

statusnumber

useCollabDoc / useOptionalCollabDoc

The enclosing document’s docId (always set), apiBasePath and authenticated fetch.

Parameters:
This function does not accept any parameters.
Returns:
CollabDocContextType

Like useCollabDoc, but returns undefined outside a CollabProvider.

Parameters:
This function does not accept any parameters.
Returns:
CollabDocContextType | undefined

Both return a CollabDocContextType: the provider’s CollabConnection (docId, apiBasePath) plus a fetch carrying its headers and credentials.

What useCollabDoc returns.

NameTypeDefault
docIdstring
apiBasePathstring

Prefix for the collab API routes, e.g. /demo. Defaults to "" (same origin).

fetch{ (input: URL | RequestInfo, init?: RequestInit | undefined): Promise<Response>; (input: string | Request | URL, init?: RequestInit | undefined): Promise<...>; }

fetch carrying the provider’s headers and credentials; use it for every collab request.

Local collaboration

The offline, multi-tab tier. The backend and its errors are in @stesura/collab-adapter-local.

useLocalCollabEditor

Offline, multi-tab collaborative editor: the pitter-patter engine running against IndexedDB + BroadcastChannel (@stesura/collab-adapter-local) instead of a server. Same shape as useCollabEditor minus reconnect; no presence, threads or proofread cache.

Undo is plain prosemirror-history: the collab-commit plugin speaks prosemirror-collab’s rebased/addToHistory protocol, so undo reverts only local edits.

docStatus:

  • “deleted”: the doc row was removed (deleteDoc); sync has stopped. Terminal.
  • “error”: the document cannot be loaded (terminal store error, failure ceiling, or a snapshot the schema cannot parse). Terminal.
  • “schema-mismatch”: the snapshot names a node or mark this tab’s schema lacks, or another tab’s commit does not parse: that tab runs a newer bundle. Terminal; a reload fixes it. onError gets a SchemaMismatchError naming the unknown types. A tab that falls behind the retained commit window re-hydrates from the snapshot instead.

backend is the one syncing (the caller’s, else the shared default), e.g. for createLocalHistorySource. Null during server rendering, where there is no IndexedDB.

Parameters:
NameTypeDefault
__0UseLocalCollabEditorArgs
Returns:
{ editorState: EditorState | null; dispatch: DispatchFn; pluginFactory: PluginCallback; schema: Schema<any, any>; docStatus: LocalCollabDocStatus; backend: LocalCollabBackend | null; }

UseLocalCollabEditorArgs

Arguments for useLocalCollabEditor: useCollabEditor’s without the presence options and initialContent, plus docId and an optional local backend.

NameTypeDefault
schemaSchema<any, any>
onErrorCollabErrorReporter

Telemetry sink for failures the sync loops handle internally (retries, terminal statuses, abandoned commits). Without it they only reach the console.

onInlineImageRejected() => void

Called each time a dropped/pasted image is refused. Collab docs never embed base64 images (they bloat every commit and can exceed the payload cap), so with no upload strategy installed, images are refused; surface that to the user.

editorIdstring
configurationConfigPluginProps
pluginOptionsStesuraPluginsOptions
extraPlugins(args: { editorId: string; parentEditorId?: string; }) => Plugin<any>[]

Extra plugins for the editor, appended after the collab-bound stack.

transactionModifierTransactionModifierFn
onEditRejected() => void

Called when an edit was too large to apply: refused before it applied (a bulk command over the collab document’s step limit, lower on very long sections), or refused by the server (over its step or size cap) and undone, keeping anything typed after it. Tell the user, e.g. “The change was too large to apply. Nothing was changed.”

onUnmergedEdits(unmerged: UnmergedEdits) => void

Called when edits the server will never merge are dropped, with the user’s version of the document so the host can offer it back. A client behind the server’s commit window rebases its edits across what it missed and calls this only for what no longer applied (reason: "gap"), or with all of them when the server has no step maps that far back ("stale"). Edits over the server’s size cap that can’t be undone alone (see onEditRejected): "tooLarge". The editor then shows the server’s document, with whatever merged.

docIdstring

Document id inside the local IndexedDB database. Passed directly; no provider needed.

backendLocalCollabBackend

Backend to sync through. Defaults to a shared singleton per schema (database "stesura-collab-local"). Pass your own createLocalCollabBackend to set dbName, snapshotInterval, migrations or createInitialDoc (the local equivalent of initialContent: backend-level so every tab seeds identically).

Must be referentially stable. A new backend re-inits the connection, and the hook never closes a caller-owned backend, so an inline one leaks an IndexedDB connection and a BroadcastChannel per render.

LocalCollabDocStatus

export type LocalCollabDocStatus = "loading" | "ready" | "deleted" | "error" | "schema-mismatch";

useLocalCollabEditor’s docStatus.

LocalCommentProvider

Comments for the local (IndexedDB) collab setup: the local counterpart of CollabProvider’s thread wiring, over a LocalThreadStore. Use next to useLocalCollabEditor with the same docId; threads sync across tabs.

Parameters:
NameTypeDefault
__0{ docId: string; children: ReactNode; backend?: LocalCollabBackend; onError?: CollabErrorReporter; }
Returns:
Element

Rooms

Multi-document suites. See Rooms & suites.

RoomProvider

Provides a room’s live manifest. Nest one CollabProvider per open document inside it; the manifest lists what exists. Polling pauses while the page is hidden.

headers and credentials apply to the room requests only; pass the same ones to each nested CollabProvider.

Parameters:
NameTypeDefault
__0RoomProviderProps
Returns:
Element

RoomProviderProps

Props of RoomProvider.

NameTypeDefault
childrenReactNode
roomIdstring
apiBasePathstring

Base path prefixed to the /api/rooms routes, e.g. /demo.

onErrorCollabErrorReporter

Telemetry sink for manifest-sync failures (always logged to the console too).

presence{ userId: string; info?: JsonObject; }

Announces this user in the room (avatars, who focuses what; see useRoomPresence). Without it the room is watched but this client is not announced. The server takes the user from the session when it wires resolvePresenceUser; info is display data.

headersCollabHeaders

Sent on every request, typically a bearer token.

credentialsRequestCredentials

"include" for cookie auth against a collab server on another origin.

useRoomManifest

The nearest room’s manifest plus mutations.

docs is never updated optimistically: addDoc/removeDoc resolve once the server has written, and the change arrives through the same long-poll every client sees, so all clients converge on one ordering.

failed means polling stopped for good; loading is false by then, so an empty room and one that could not load are distinguishable.

Parameters:
This function does not accept any parameters.
Returns:
{ docs: RoomDoc[]; loading: boolean; failed: boolean; addDoc: (entry: NewRoomDoc) => Promise<void>; removeDoc: (docId: string) => Promise<void>; }

useRoom

The nearest room’s roomId and apiBasePath. Use useRoomManifest for its contents.

Parameters:
This function does not accept any parameters.
Returns:
{ roomId: string; apiBasePath: string; }

useRoomPresence

Who else is in the nearest room (one entry per client, so a user with two tabs shows twice; group by userId for avatars), and setFocus to say what this client is on. Requires the RoomProvider’s presence prop to announce this client.

Parameters:
This function does not accept any parameters.
Returns:
{ clientId: string; others: RoomPresenceIndicator[]; setFocus: (focus: RoomPresenceFocus | null) => void; }

RoomDoc

One document’s entry in a room manifest (matches the server’s RoomDocEntry).

NameTypeDefault
docIdstring
titlestring
positionnumber
schemaNamestring

The named schema the doc uses, for building its editor (useCollabEditor’s schema). Absent from servers before named schemas.

NewRoomDoc is what addDoc takes: a RoomDoc plus an optional initialContent.

Presence and connection

Both hooks read the sync loops the mount hook already runs, so they report nothing until that document’s editor is mounted. See Presence.

CollabPresenceRoster

Accessible list of who is in the document: the current user first, then each remote user (deduped by userId), with arrivals and departures announced through a polite live region.

The in-document carets are aria-hidden (ARIA inside .ProseMirror leaks into the prose), so this is the only presence information screen readers get. Render it in the chrome, or build your own on useDocPresence with the same two parts. Unstyled beyond a colour swatch per user.

Parameters:
NameTypeDefault
__0CollabPresenceRosterProps
Returns:
Element

Props of CollabPresenceRoster.

NameTypeDefault
docIdstring

Defaults to the nearest CollabProvider’s document.

getDisplayName(userId: string) => string | undefined

Resolves a userId to a display name. Unresolved users are announced as anonymous.

maxVisiblenumber

Users shown individually before the rest collapse into a count. Defaults to 4.

classNamestring

useDocPresence

The latest raw presence snapshot for a document, keyed by clientId. Fed by useCollabEditor’s presence poll, so it is empty until that document’s editor is mounted.

Unfiltered, unlike the presence plugin’s state: it includes the local user’s other sessions and indicators with no document position. Dedupe by userId for a “who’s here” UI.

Parameters:
NameTypeDefault
docIdstring

defaults to the nearest CollabProvider’s docId.

Returns:
DocPresenceSnapshot

DocPresenceSnapshot is what it returns: a Record<clientId, PresenceIndicator>.

useDocConnection

A document’s sync connection status. Fed by useCollabEditor’s own requests (no extra network), so it stays “connecting” until that document’s editor is mounted.

Parameters:
NameTypeDefault
docIdstring

defaults to the nearest CollabProvider’s docId.

Returns:
DocConnectionStatus
export type DocConnectionStatus = "connecting" | "online" | "offline";

Health of a document’s server sync, written by useCollabEditor: “connecting” until its first request resolves, then whether hydrate, commit polls and commit sends are getting through.

CollabConnectionStatus

A status-bar dot and label for the nearest CollabProvider’s document, from useDocConnection. Renders nothing outside a provider. Mount it through a UI extension’s StatusBarElements.

Comments

CollabProvider and LocalCommentProvider wire these for you; use them directly to put comments on a backend of your own. See the adapter contract.

createCollabCommentAdapter

A CommentAdapter over any ThreadMirror (ThreadStoreClient or LocalThreadStore): whole-thread writes, soft deletes, reactions.

A new thread’s editor fragment comes from metadata.editorId (set by the comments UI), falling back to "default"; later writes keep the stored record’s editorId.

Parameters:
NameTypeDefault
storeThreadMirror
currentUser{ id: string; name?: string; avatar?: string; }
Returns:
CommentAdapter

Thread mirrors

ThreadMirror is the abstract in-memory mirror of a document’s threads that createCollabCommentAdapter reads; each record is a ThreadMirrorRecord ({ editorId, data }). Two implementations ship:

ClassSyncsOptions
ThreadStoreClientAgainst the server’s /threads routes: hydrate, then long-poll. Writes PUT the whole thread (last write wins)ThreadStoreClientOptions
LocalThreadStoreIn IndexedDB, across tabs over a BroadcastChannelLocalThreadStoreOptions

ThreadStoreClient stops with a ThreadSyncTerminatedError (its status says why) when the server answers a status retrying can’t fix, such as an expired session.

Options for ThreadStoreClient.

NameTypeDefault
onErrorCollabErrorReporter

Telemetry sink for poll/write failures the client handles internally.

onUnmergedComment(unmerged: UnmergedComment) => void

Called for each comment write made offline that the server would not take. start() can replace it.

fetch{ (input: URL | RequestInfo, init?: RequestInit | undefined): Promise<Response>; (input: string | Request | URL, init?: RequestInit | undefined): Promise<...>; }

Carries the host’s auth. CollabProvider passes its own; defaults to the global fetch (no auth headers, no protocol header).

userIdstring

start() only: whose writes this client keeps when the server can’t be reached, so another user signing in on this browser never sends them. Defaults to "anonymous".

Options for LocalThreadStore.

NameTypeDefault
dbNamestring

The collab backend’s dbName; namespaces this store’s database and cross-tab channel.

onDocDeleted(docId: string, callback: () => void) => () => void

Deletion signal for the document (LocalCollabBackend.onDocDeleted in practice). When it fires, the document’s thread rows are purged: the backend knows nothing about threads, so without it a re-created docId would inherit the deleted document’s comments.

onErrorCollabErrorReporter

useThreadSyncFailed

Whether comment sync for docId has stopped for good (terminal status, too many failures in a row, or a failed local IndexedDB load). The mirror keeps what it last held, so treat this as an “out of date” banner rather than a reason to hide the panel.

Parameters:
NameTypeDefault
docIdstring
Returns:
boolean

noopCommentAdapter

A CommentAdapter with no backend: no threads, and createThread returns an empty, unpersisted thread. CollabProvider uses it when comments={false}.

Proofread

Proofread adapters stored through the collab backend. See Proofread.

createCollabProofreadCacheFactory

A ProofreadCacheAdapter factory backed by the /proofread/:field routes of @stesura/collab-adapter-server (one shared bucket per doc + field). Pass it to proofreadPlugin({ createCache }).

The adapter contract is synchronous, so each field keeps an in-memory mirror shared by all its instances: one hydration GET when the first instance is created (never overriding locally touched ids), writes debounced ~2s and POSTed with keepalive.

No live cross-tab or cross-client sync: a stale mirror only means a node gets re-checked.

Parameters:
NameTypeDefault
__0{ docId: string; apiBasePath?: string; onError?: CollabErrorReporter; } & CollabTransportOptions
Returns:
CreateProofreadCache

createCollabProofreadDictionaryFactory

A ProofreadDictionaryAdapter factory backed by an app-level dictionary endpoint ({apiBasePath}/api/proofread/dictionary by default). Pass it to proofreadPlugin({ createDictionary }).

Identity-scoped: the endpoint returns the session user’s effective dictionary and takes no doc id, so document access never exposes a dictionary. Same sync model as the proofread cache (in-memory mirror, one hydration, debounced keepalive write-through) plus cross-tab BroadcastChannel updates; hydration is retried with backoff.

Known limitation: the retry queue is in memory. Writes still failing when the last adapter is destroyed are dropped, so a word added offline is lost if the page closes first.

Parameters:
NameTypeDefault
__0{ apiBasePath?: string; endpoint?: string; onError?: CollabErrorReporter; } & CollabTransportOptions
Returns:
CreateProofreadDictionary

Guests

For demos and anonymous editing. Real apps pass their authenticated user to StesuraUserProvider.

useGuestUser

A guest CollabUser for demos and anonymous editing, stable for the component’s lifetime. Name and colour derive from the id (guestProfile), so pass guestProfile to your resolveUsers to show other guests the same way. Real apps should pass their authenticated user to StesuraUserProvider.

Parameters:
NameTypeDefault
__0UseGuestUserOptions
Returns:
CollabUser

Options for useGuestUser.

NameTypeDefault
storageKeystring

localStorage key that keeps the guest’s id across reloads, so a visitor keeps their name and colour. Omit for a new guest on every mount.

avatarsreadonly string[]

Avatar URLs to pick from by id (see guestProfile).

overridesPartial<CollabUser>

guestProfile

A guest’s display profile, derived from the id alone: every peer computes the same name, colour and avatar for the same id, so no user directory is needed. Names come from fixed word lists, so a shared public document never shows anything a visitor typed. The colour is the one the presence cursor already uses for this id. The avatar is picked from avatars; without any, it is empty and the UI falls back to initials.

Parameters:
NameTypeDefault
idstring
avatarsreadonly string[]
Returns:
Pick<CollabUser, "name" | "color" | "avatar">

Version history

The panel, its review-tab button and the hooks under them. See Version history.

createVersionHistoryUiExtension

Version history as one UI extension: a review-tab button and the right panel. The panel reads the enclosing CollabProvider’s routes, or a DocHistoryProvider’s source (the local backend). Build it once, outside render: uiExtensions must be a stable array.

Parameters:
NameTypeDefault
optionsVersionHistoryPanelProps
Returns:
StesuraUIExtension

VersionHistoryPanel

The version history right panel: the versions newest first, “Name current version”, and a read-only preview of any version with “Restore this version”. Reads its history from DocHistoryProvider, else the enclosing CollabProvider; renders nothing without either.

Parameters:
NameTypeDefault
__0VersionHistoryPanelProps
Returns:
Element | null

Options shared by the panel and createVersionHistoryUiExtension.

NameTypeDefault
getAuthorName(authorId: string) => string

Display name for a version’s authorId. Default: the id itself.

DocHistorySource

What the panel and hooks read from. Under a CollabProvider it’s the server’s history routes; otherwise pass one through DocHistoryProvider.

Where a document’s version history lives: the server’s history routes, or the local backend. The panel and useDocHistory only talk to this.

NameTypeDefault
keystring

Identifies the history read: every hook on one key shares one list.

list(opts?: { limit?: number; before?: number; } | undefined) => Promise<SnapshotMeta[]>

Newest first; before pages by version.

get(version: number) => Promise<Snapshot | null>

One version with its document, or null.

saveVersion(label: string) => Promise<{ version: number; }>

Names the current version.

restore(version: number) => Promise<{ version: number; }>

Makes version the current content. Resolves the new head.

History over @stesura/collab-adapter-server’s routes (useCollabDoc() supplies the args).

Parameters:
NameTypeDefault
__0{ docId: string; apiBasePath?: string; fetch: { (input: URL | RequestInfo, init?: RequestInit | undefined): Promise<Response>; (input: string | ... 1 more ... | URL, init?: RequestInit | undefined): Promise<...>; }; }
Returns:
DocHistorySource

History over @stesura/collab-adapter-local’s IndexedDB backend.

Parameters:
NameTypeDefault
__0{ backend: LocalCollabBackend; docId: string; authorId?: string; }
Returns:
DocHistorySource

DocHistoryProvider / useDocHistorySource

Supplies the version history panel with a DocHistorySource. Only needed where no CollabProvider is (the local backend: createLocalHistorySource), or to override it. Null defers to the CollabProvider, if any.

Parameters:
NameTypeDefault
__0{ source: DocHistorySource | null; children: ReactNode; }
Returns:
Element

The DocHistoryProvider’s source, else the enclosing CollabProvider’s routes, else null.

Parameters:
This function does not accept any parameters.
Returns:
DocHistorySource | null

useDocHistory / useSnapshot

A document’s version history, shared by every caller on the same source. Loads when the first caller mounts, so opening the panel always shows a fresh list; no polling, since history changes rarely and a restore reaches the editor as an ordinary commit. saveVersion and restore refresh the list and reject on failure.

Parameters:
NameTypeDefault
sourceDocHistorySource
Returns:
{ refresh: () => Promise<void>; loadMore: () => Promise<void>; saveVersion: (label: string) => Promise<{ version: number; }>; restore: (version: number) => Promise<{ version: number; }>; snapshots: SnapshotMeta[]; status: "error" | ... 2 more ... | "idle"; hasMore: boolean; }

What useDocHistory reads.

NameTypeDefault
snapshotsSnapshotMeta[]
status"error" | "loading" | "ready" | "idle"
hasMoreboolean

More (older) versions exist past the loaded ones.

One version with its document, loaded on first use and cached.

Parameters:
NameTypeDefault
sourceDocHistorySource
versionnumber
Returns:
SnapshotState

What useSnapshot reads.

NameTypeDefault
status"error" | "loading" | "ready"
snapshotSnapshot | null

Other exports

ExportDescription
VersionHistoryGroupThe review-tab group with the Version history button, for a custom toolbar.
VersionPreviewDialogOne version, read-only, with Restore this version behind a confirmation. The panel opens it.
VERSION_HISTORY_PANEL"version-history", the right-panel action the panel opens under.
HISTORY_PAGE_SIZE50, versions per page of the history list.
DocHistoryRequestErrorA history request the server refused; carries its status.

Failure containment

CollabErrorBoundary

Wrap the comments and presence UI (not the editor) in it, so a bad thread or decoration shows a “collaboration unavailable” notice instead of breaking the page. See Failure containment.

Props of CollabErrorBoundary.

NameTypeDefault
childrenReactNode
fallback(props: FallbackProps) => ReactNode

Rendered after a render throw. Defaults to a “collaboration unavailable, retry” notice.

onErrorCollabErrorReporter

Same reporter as the hooks’ onError.

scopestring

Defaults to "react.errorBoundary".

docIdstring

Attached to the report.

Last updated on