Skip to main content
Handwritten reference for the controller surface. Mirrors the page order above.

Provider and hooks

Imported from superdoc/ui/react.

<SuperDocUIProvider>

Holds one controller per editor mount. Wrap your app once.

useSetSuperDoc()

Returns the setter the editor mount component calls in onReady. Most components don’t use this directly.

useSuperDocUI()

Returns the controller, or null until ready.

useSuperDocCommand(id)

Subscribes to one command’s state. See Toolbar and commands.

useSuperDocSelection()

Returns the live selection slice. See Selection and viewport.

useSuperDocComments()

Returns the comments slice. See Comments.

useSuperDocTrackChanges()

Returns the tracked-changes slice. See Track changes.

useSuperDocDocument()

Returns the document slice. See Document control.

useSuperDocToolbar()

Returns the full toolbar snapshot. Re-renders on any command change. Prefer useSuperDocCommand per button when possible.

useSuperDocFontOptions()

Returns font-family picker options for custom toolbar UIs. The list includes the built-in defaults plus fonts used by the active document, sorted alphabetically.
Use option.value with ui.toolbar.execute('font-family', option.value). Use option.previewFamily only to render the row preview.

useSuperDocFontSizeOptions()

Returns the default font-size picker options for custom toolbar UIs.
Use option.value with ui.toolbar.execute('font-size', option.value).

useSuperDocSlice(picker, initial)

Subscribe to any slice from ui.select(...). Use when the typed hooks above don’t cover what you need.

useSuperDocHost()

Returns the host SuperDoc instance. Reserved for operations the controller doesn’t bridge yet.

Controller handles

Imported from superdoc/ui. The provider handles construction; you typically reach these through useSuperDocUI() + the typed hooks.

ui.commands

Built-in dispatch and custom-command registration.

ui.comments

Live snapshot, mutations, navigation.

ui.trackChanges

Live list, accept / reject, navigation.

ui.document

Mode, export, replace.

ui.zoom

Zoom state, viewport metrics, and the two mutations. The snapshot updates on value changes, mode-only transitions, and viewport metric updates.
In React, useSuperDocZoom() returns the same snapshot plus bound set / setMode actions. The toolbar registry also exposes a zoom-fit-width toggle command for custom toolbars.

ui.selection

Live slice, capture, restore, painted geometry.

ui.viewport

Geometry. Browser-only.

ui.toolbar

Aggregate toolbar surface. Mirrors the headless-toolbar shape.
payload is optional. Pass it for built-ins like font-size, font-family, and link that accept a value; omit it for togglable built-ins like bold or italic.

ui.fonts

Read-only font picker options for custom toolbar UIs.
Family options have { label, value, previewFamily }. Apply value through the font-family command. Size options have { label, value }. Apply value through the font-size command.

ui.select(selector, equality?)

Raw selector substrate underlying every domain handle.

ui.destroy()

Tears down every subscription. The provider calls this on unmount.

Types

Imported from superdoc/ui. For the source of truth, the types ship with the superdoc package and are exported alongside the runtime values.