@docx-editor.dev/pro/vue/hocuspocus

@docx-editor.dev/pro/vue/hocuspocus — Vue composable that owns a Hocuspocus room.

Import this subpath only when you use Hocuspocus. @docx-editor.dev/pro/vue does not load a network provider.

Functions (1)

useHocuspocusCollaborationfunctionSource ↗

Own a Hocuspocus collaboration room for a Vue host.

The default Pro Vue entry does not import this composable. Import it from @docx-editor.dev/pro/vue/hocuspocus so a review-only bundle does not load a network provider.

declare function useHocuspocusCollaboration(options?: MaybeRefOrGetter<UseHocuspocusCollaborationOptions | null>): UseHocuspocusCollaborationReturn;

Interfaces (5)

CollaborationIdentityUpdateinterfaceSource ↗

Display-identity fields a live session can update.

actorId and role are attribution and stay immutable for the session lifetime, so this type cannot name them.

interface CollaborationIdentityUpdate
MemberTypeSummary
color?stringNew presence color, at most 64 characters.
name?stringNew display name, 1 to 256 characters after trimming.

CollaborationSessioninterfaceSource ↗

Host-facing collaboration session.

A host reads identity, status, presence, and undo. The editor attaches [EditorCollaborationSession](EditorCollaborationSession) internally and never through this type.

interface CollaborationSession
MemberTypeSummary
canRedoWhether the shared undo history holds a local step to redo.
canUndoWhether the shared undo history holds a local step to undo.
documentIdstringThe room's document id.
identityCollaborationIdentityThe validated local identity.
offlineEditing?booleanWhether edits continue while the transport is down (`disconnected`). Set by the `offlineEditing` option; absent means true.
participantsParticipants in presence, this replica included. Capped at 256.
redoRedo this participant's last undone step. Returns false when refused.
remoteSelectionsOther participants' selections, resolved into this replica's addresses.
sessionIdstringUnique identity for this attachment lifetime.
setIdentityUpdate the display name and color mid-session, when the replica supports it.
statusCurrent lifecycle state.
statusSnapshotCached status, current reason, and last failure.
subscribeParticipantsCall `listener` when the participant list changes. Returns the unsubscribe function.
subscribeRemoteSelectionsCall `listener` when a remote selection changes. Returns the unsubscribe function.
subscribeStatusCall `listener` on each status or reason change. Returns the unsubscribe function.
undoUndo this participant's last step; others' edits stay. Returns false when refused.

UseHocuspocusCollaborationConnectOptionsinterfaceSource ↗

Arguments for [UseHocuspocusCollaborationReturn.connect](UseHocuspocusCollaborationReturn.connect).

interface UseHocuspocusCollaborationConnectOptions
MemberTypeSummary
bootstrapUseHocuspocusCollaborationBootstrapWhether to seed the room, join it, or let the peers decide.
identityCollaborationIdentityThe local participant. Recorded as the author of this replica's changes.
offlineEditing?booleanAdmit local edits while the transport is `disconnected`. Buffered updates merge on reconnect. On by default; pass `false` to pause editing while disconnected. See [CreateDocumentCollaborationOptions.offlineEditing](CreateDocumentCollaborationOptions.offlineEditing).
roomIdstringRoom name on the server, also the document id. Make one with `createCollaborationRoomId`.
syncedTimeoutMs?numberBound on the wait for the server's initial sync. Default 30000 ms.
token?string | (() => string | Promise<string>)Authentication token the provider sends in its auth handshake. Pass a callback and the provider re-evaluates it on every reconnect, which is how expiring JWTs renew.
urlstringHocuspocus server WebSocket URL, for example `wss://collab.example.test`.

UseHocuspocusCollaborationOptionsinterfaceSource ↗

Input for [useHocuspocusCollaboration](useHocuspocusCollaboration).

interface UseHocuspocusCollaborationOptions
MemberTypeSummary
modules?readonly EditorModule[]Host modules. The hook adds `collaborationModule` when a room is ready. A host collaboration contribution is a configuration error and throws.
room?UseHocuspocusCollaborationConnectOptions | nullConnect this room when the composable starts. Omit it and call [UseHocuspocusCollaborationReturn.connect](UseHocuspocusCollaborationReturn.connect) after the user chooses a room. A different room, server, bootstrap kind, or `actorId` leaves the old room and connects the new one, and `null` leaves. A room opened with `connect` stays.

UseHocuspocusCollaborationReturninterfaceSource ↗

Values [useHocuspocusCollaboration](useHocuspocusCollaboration) returns.

interface UseHocuspocusCollaborationReturn
MemberTypeSummary
connect(options: UseHocuspocusCollaborationConnectOptions) => Promise<CollaborationFailure | null>Connect a room. RESOLVES with the failure, or null on success — it does not reject.
documentReadonly<Ref<Uint8Array | null>>The room's document as `.docx` bytes to mount. Null until the room is ready.
errorReadonly<Ref<CollaborationFailure | null>>The connect failure or session failure, or null. Check it before `document`.
leave(nextDocument: Uint8Array) => voidDestroy the room and carry on editing locally.
modulesReadonly<Ref<readonly EditorModule[]>>Modules to pass to the editor. They include the collaboration module once ready.
pendingReadonly<Ref<boolean>>True while a connect is in progress.
providerReadonly<Ref<HocuspocusProvider | null>>The owned `@hocuspocus/provider` instance. Null while no room is connected.
rejoin(nextDocument: Uint8Array) => Promise<CollaborationFailure | null>Recover a session that reached status `error`: leave with `nextDocument`, then connect again to the same room with the same identity, url, and token.
sessionReadonly<Ref<CollaborationSession | null>>The live session for status and presence. Null while no room is connected.
unsyncedChangesReadonly<Ref<number>>Local changes the server has not confirmed yet. More than zero while edits made offline wait for the connection, and for a moment after each edit while online. Warn before the page closes while it is above zero, or those edits are lost:
ydocReadonly<Ref<Y.Doc | null>>The room's shared Yjs document, owned by the composable. Null while no room is connected.

Type aliases (1)

UseHocuspocusCollaborationBootstraptypeSource ↗

Bootstrap for one Hocuspocus room.

type UseHocuspocusCollaborationBootstrap = CollaborationBootstrap;