superdoc/ui gives you the state and actions to drive it.
The layer model
Three layers, each with one job:
The Document API mutates the document.
superdoc/ui is what your UI subscribes to. Built-in modules are SuperDoc’s own consumer of those layers. Turn them off when you’re providing your own.
What it looks like
bold flips active or disabled.
What’s in this section
React setup
Provider, onReady, hooks. The scaffolding every page below builds on.
Toolbar and commands
Wire your buttons to bold, italic, lists, undo, redo, and every other built-in command.
Custom commands
Register your own commands. Override built-ins. Drive AI actions, clause inserts, business logic.
Comments
Custom comments sidebar with the typed selection-capture flow.
Track changes
Custom tracked-change review panel. Accept, reject, navigate.
Right-click menu
Custom context menu wired through
contextAt and getContextMenuItems(context).Selection and viewport
Read the selection. Scroll an entity into view. Capture and restore selections that survive focus changes. Resolve a click point to a caret.
Document control
Switch between editing and suggesting. Export to DOCX. Replace the open file.
Three surfaces, three subjects
Custom-UI apps tend to land on the same shape: a toolbar, a floating bubble menu, a right-click menu. Each one answers a different “what’s the subject of this action?” question. Keep them strictly separated.
The controller surfaces this split directly. The toolbar reads
state.selection to gate format buttons. The bubble menu anchors via ui.selection.getAnchorRect({ placement: 'start' }). The context menu opens against ui.viewport.contextAt({ x, y }) and dispatches via item.invoke(). Same controller, same hooks, three jobs.

