Document operations
export
Export the document with various options.
Object
Export configuration
Promise<Blob> - Document blob
save
Save document if in collaboration mode.
Returns: Promise<void>
getHTML
Get HTML content of all editors.
Object
HTML options
string[] - Array of HTML strings, one per editor
Collaboration methods
upgradeToCollaboration
Promote a local SuperDoc instance into collaboration without creating a new instance.
Object
required
Upgrade configuration
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.
string
required
New document mode
lockSuperdoc
Lock or unlock the document.
boolean
required
Lock state
User
User who locked the document
setHighContrastMode
Enable/disable high contrast mode.
boolean
required
High contrast state
UI methods
setActiveEditor
Set which editor is currently active. Useful when working with multiple documents.
Editor
required
Editor instance to set as active
setDisableContextMenu
Toggle the custom context menu at runtime.
boolean
default:"true"
Whether to disable the context menu
openSurface
Open a dialog or floating surface above the document.
Returns: SurfaceHandle
Object
required
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.
Object
toggleRuler
Toggle ruler visibility.
string
deprecated
getZoom
Get the current zoom level as a percentage.
Returns: number - Current zoom level (e.g., 100, 150, 200). Defaults to 100.
setZoom
Set the zoom level for all documents. Propagates to all presentation editors, PDF viewers, and whiteboard layers.
number
required
Zoom level as a percentage (e.g.,
100, 150, 200). Must be a positive finite number.focus
Focus the active editor or first available.
Search methods
search
Search for text or regex in active editor.
string | RegExp
required
Search query
Array<SearchResult> - Search matches
goToSearchResult
Navigate to a search result.
SearchResult
required
Search result to navigate to
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.
HTMLElement
required
Container element for the comments list
removeCommentsList
Remove the comments list.
scrollToComment
Scroll to a comment in the document and set it as active.
string
required
The comment ID to scroll to
object
Scroll behavior options
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.
string
required
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.
User
required
User to add
removeSharedUser
Remove a user from shared users.
string
required
Email of user to remove
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.
Object
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).
