SuperEditor exposes both high-level methods and direct ProseMirror access.

Content Methods

getHTML

Get document as HTML string.
options
Object
Configuration options
Returns: string - HTML representation
const html = editor.getHTML();
// With nested lists preserved
const html = editor.getHTML({ unflattenLists: true });

getJSON

Get document as ProseMirror JSON. Returns: Object - ProseMirror document JSON
const json = editor.getJSON();

getUpdatedJson

Get JSON prepared for export with comment processing. Returns: Object - Export-ready JSON
const json = editor.getUpdatedJson();

Export Methods

exportDocx

Export document as DOCX file.
options
Object
Export configuration
Returns: Promise<Blob> - DOCX file blob
const blob = await editor.exportDocx({
  isFinalDoc: true,
  commentsType: 'clean'
});

loadXmlData

Load and parse DOCX file data.
fileSource
File | Blob | string
required
DOCX file source
isNode
boolean
default:"false"
Whether running in Node.js
Returns: Promise<[xmlFiles, mediaUrls, mediaBase64, fonts]>
const [xmlFiles, mediaUrls, mediaBase64, fonts] = 
  await Editor.loadXmlData(docxFile);

Editor Control

mount

Mount editor to DOM element.
element
HTMLElement
required
Target DOM element
editor.mount(document.querySelector('#new-container'));

unmount

Unmount editor from DOM (keeps instance alive).
editor.unmount();

destroy

Completely destroy editor and clean up.
This is irreversible. The editor instance cannot be used after calling destroy.
editor.destroy();

focus

Focus the editor.
editor.focus();

setEditable

Set editor editability.
editable
boolean
required
Whether editor should be editable
emitUpdate
boolean
default:"true"
Whether to emit update event
editor.setEditable(false); // Read-only
editor.setEditable(true, false); // Editable without event

Mode Control

setDocumentMode

Change document editing mode.
mode
string
required
Document mode
editor.setDocumentMode('suggesting');

Command Methods

chain

Create a command chain. Returns: ChainedCommands - Chainable command object
editor.chain()
  .focus()
  .selectAll()
  .toggleBold()
  .run();

can

Check if commands can run without executing. Returns: Commands - Commands in check mode
if (editor.can().toggleBold()) {
  // Bold button should be enabled
}

Direct Commands

Access all commands directly.
editor.commands.toggleBold();
editor.commands.insertTable({ rows: 3, cols: 3 });
editor.commands.setTextSelection({ from: 10, to: 20 });

Content Manipulation

replaceContent

Replace entire editor content.
content
Object
required
ProseMirror JSON content
editor.replaceContent(newJsonContent);

replaceNodeWithHTML

Replace specific node with HTML.
node
Node
required
ProseMirror node to replace
html
string
required
HTML replacement
const tableNode = editor.getNodesOfType('table')[0];
editor.replaceNodeWithHTML(tableNode, '<table>...</table>');

replaceFile

Replace current DOCX file.
newFile
File | Blob
required
New DOCX file
Returns: Promise<void>
await editor.replaceFile(newDocxFile);

Annotation Methods

These methods are available with the field-annotation extension.

annotate

Apply field annotations to document.
values
Array
required
Annotation values
hiddenIds
Array<string>
default:"[]"
Field IDs to hide
removeEmpty
boolean
default:"false"
Remove empty fields
editor.annotate([
  { input_id: 'field1', input_value: 'John Doe' },
  { input_id: 'field2', input_value: 'CEO' }
], ['field3'], true);

previewAnnotations

Preview annotations (reversible).
values
Array
required
Annotation values
hiddenIds
Array<string>
Field IDs to hide
editor.previewAnnotations(values, hiddenIds);

closePreview

Revert annotation preview.
editor.closePreview();

Search Methods

Search for text or regex.
query
string | RegExp
required
Search query
Returns: Array<SearchResult> - Search matches
const results = editor.search('hello');
const results = editor.search(/\d{3}-\d{2}-\d{4}/g); // SSN pattern

Utility Methods

getNodesOfType

Get all nodes of specific type.
type
string
required
Node type name
Returns: Array<Node> - Matching nodes
const tables = editor.getNodesOfType('table');

isActive

Check if node or mark is active.
name
string | Object
required
Node/mark name or attributes
attributes
Object
Additional attributes to check
Returns: boolean - Whether active
editor.isActive('bold');
editor.isActive('heading', { level: 2 });
editor.isActive({ textAlign: 'center' });

getAttributes

Get attributes of active node or mark.
nameOrType
string | NodeType | MarkType
required
Name or type to get attributes for
Returns: Object - Attributes
const attrs = editor.getAttributes('link');
console.log(attrs.href);

Properties

state
EditorState
ProseMirror EditorState
view
EditorView
ProseMirror EditorView
schema
Schema
ProseMirror Schema
commands
Commands
All available commands
helpers
Object
Extension helper methods
storage
Object
Extension storage
isEditable
boolean
Whether editor is editable
isDestroyed
boolean
Whether editor is destroyed
isFocused
boolean
Whether editor has focus