Methods are functions you call on the SuperDoc instance to perform actions.

Document Operations

export

Export the document with various options.
options
Object
Export configuration
Returns: Promise<Blob> - Document blob
const blob = await superdoc.export({
  isFinalDoc: true,
  commentsType: 'clean'
});

save

Save document if in collaboration mode. Returns: Promise<void>
await superdoc.save();

getHTML

Get HTML content of all editors.
options
Object
HTML options
Returns: string[] - Array of HTML strings, one per editor
const htmlArray = superdoc.getHTML();

Mode Control

setDocumentMode

Change the document mode.
mode
string
required
New document mode
superdoc.setDocumentMode('suggesting');

lockSuperdoc

Lock or unlock the document.
isLocked
boolean
required
Lock state
lockedBy
User
User who locked the document
superdoc.lockSuperdoc(true, currentUser);

setHighContrastMode

Enable/disable high contrast mode.
enabled
boolean
required
High contrast state
superdoc.setHighContrastMode(true);

UI Methods

toggleRuler

Toggle ruler visibility.
superdoc.toggleRuler();

togglePagination

Toggle pagination mode.
superdoc.togglePagination();

focus

Focus the active editor or first available.
superdoc.focus();

Search Methods

Search for text or regex in active editor.
query
string | RegExp
required
Search query
Returns: Array<SearchResult> - Search matches
const results = superdoc.search('contract');
const results = superdoc.search(/section \d+/gi);

goToSearchResult

Navigate to a search result.
match
SearchResult
required
Search result to navigate to
superdoc.goToSearchResult(results[0]);

Comments Methods

addCommentsList

Add a comments list to the specified element.
element
string | HTMLElement
required
Container for comments list
superdoc.addCommentsList('#comments-sidebar');

removeCommentsList

Remove the comments list.
superdoc.removeCommentsList();

User Management

addSharedUser

Add a user to the shared users list.
user
User
required
User to add
superdoc.addSharedUser({
  name: 'Jane Smith',
  email: 'jane@example.com'
});

removeSharedUser

Remove a user from shared users.
email
string
required
Email of user to remove
superdoc.removeSharedUser('jane@example.com');

Lifecycle Methods

destroy

Completely destroy the SuperDoc instance.
This is irreversible. Cleans up all resources, events, and DOM.
superdoc.destroy();

Event Methods

on

Subscribe to an event.
event
string
required
Event name
handler
function
required
Event handler
superdoc.on('ready', ({ superdoc }) => {
  console.log('SuperDoc ready');
});

once

Subscribe to an event once.
event
string
required
Event name
handler
function
required
Event handler
superdoc.once('ready', () => {
  // Only called once
});

off

Unsubscribe from an event.
event
string
required
Event name
handler
function
required
Handler to remove
superdoc.off('ready', handler);

Method Patterns

Async Operations

async function exportDocument() {
  try {
    const blob = await superdoc.export({
      isFinalDoc: true
    });
    saveToFile(blob);
  } catch (error) {
    console.error('Export failed:', error);
  }
}

Waiting for Ready

Some methods require SuperDoc to be ready
superdoc.once('ready', () => {
  // Now safe to use all methods
  superdoc.search('term');
  superdoc.setDocumentMode('suggesting');
});