Document operations
export
Export the document with various options.
Returns: Promise<Blob> - Document blob
save
Save document if in collaboration mode.
Returns: Promise<void>
getHTML
Get HTML content of all editors.
Returns: string[] - Array of HTML strings, one per editor
Collaboration methods
upgradeToCollaboration
Promote a local SuperDoc instance into collaboration without creating a new instance.
Returns: Promise<void>
Requirements:
- The SuperDoc instance must already be ready
- The instance must not already be collaborative
- The current instance must contain a single DOCX document
- You must provide a matching
{ ydoc, provider }pair
SuperDoc waits for provider sync internally. You do not need to wait for the
provider’s
sync event before calling this method.Mode control
setDocumentMode
Change the document mode.
lockSuperdoc
Lock or unlock the document.
setHighContrastMode
Enable/disable high contrast mode.
UI methods
setActiveEditor
Set which editor is currently active. Useful when working with multiple documents.
setDisableContextMenu
Toggle the custom context menu at runtime.
openSurface
Open a dialog or floating surface above the document.
Returns: SurfaceHandle
Surface request. Set
mode to 'dialog' or 'floating', then provide content via render (framework-agnostic) or component (Vue). See Surfaces for the full request shape.closeSurface
Close a specific surface by id, or the topmost active surface when no id is provided. When both a dialog and a floating surface are open, the dialog closes first.
setTrackedChangesPreferences
Override how tracked changes are rendered in the layout engine.
toggleRuler
Toggle ruler visibility.
getZoom
Get the current zoom level as a percentage.
Returns: number - Current zoom level (e.g., 100, 150, 200). Defaults to 100.
setZoom
Set an explicit zoom level and switch zoom mode to manual. Use setZoomMode('fit-width') to turn automatic fitting back on.
setZoomMode
Switch between manual zoom and automatic fit-width zoom. 'fit-width' keeps DOCX and PDF documents fitted to the available container width, using the bounds from zoom.fitWidth. Calling setZoom() switches back to 'manual'.
getZoomState
Get the current zoom mode, value, latest fit calculation, and effective fit bounds.
Returns: SuperDocZoomState - { mode, value, fitZoom, min, max }. fitZoom is null before the first viewport measurement.
getViewportMetrics
Get the latest fit-width measurements. Use this when you need custom zoom behavior instead of zoom.mode: 'fit-width'.
Returns: SuperDocViewportMetrics | null - { availableWidth, documentWidth, fitZoom }, or null until the first measurement (editors still mounting).
focus
Focus the active editor or first available.
Search methods
search
Search for text or regex in active editor.
Returns: Array<SearchResult> - Search matches
goToSearchResult
Navigate to a search result.
Comments methods
addCommentsList and removeCommentsList mount the built-in comments sidebar. For custom React UI, render your own panel from useSuperDocComments instead: see Custom UI › Comments. The methods below stay supported for apps using the built-in sidebar.addCommentsList
Add a comments list to the specified element.
removeCommentsList
Remove the comments list.
scrollToComment
Scroll to a comment in the document and set it as active.
Returns: boolean: true if the comment was found, false otherwise.
scrollToElement
Scroll to any document element by its ID. Pass a paragraph nodeId, comment entityId, or tracked change entityId: the method figures out what kind of element it is and scrolls there.
The element’s stable ID. Get this from
query.match results (address.nodeId), comments.list (entityId), or trackChanges.list (entityId).Promise<boolean>: true if the element was found and scrolled to, false otherwise. Never throws.
For DOCX-imported documents, paragraph
nodeId values come from the OOXML paraId attribute and are stable across sessions. See cross-session block addressing for the full pattern.User management
addSharedUser
Add a user to the shared users list.
removeSharedUser
Remove a user from shared users.
Lifecycle
destroy
Completely destroy the SuperDoc instance.
Event methods
on
Subscribe to an event.
once
Subscribe to an event once.
off
Unsubscribe from an event.
Schema introspection
getSchemaIntrospection
Returns a JSON schema summary with all nodes, marks, and their attributes. Useful for AI agents that need schema context.
TypeScript types
SuperDoc exports TypeScript interfaces for all node and mark types:NodeName, NodeAttrs<N>, MarkName, MarkAttrs<M>, and specific interfaces like ParagraphAttrs, TableAttrs, ImageAttrs, etc.
Properties
activeEditor
Currently active editor instance. Returns null before the ready event.
For new code, prefer the typed surfaces.
superdoc.activeEditor.commands.X() is the chain-command path; it stays supported for backwards compatibility but isn’t the recommended starting point. Use editor.doc.* for document mutations (insert, replace, format, comments, tracked changes) and ui.commands.* for React UI dispatch (typed, memoized per command).
