Skip to main content

Document lifecycle

open

Open a document from a file, URL, or buffer.
string | File | Blob | Buffer
Document source. Omit for a blank document.
OpenOptions
This is the instance method. For one-liner creation, use the static Editor.open() factory — see Configuration.

close

Close the current document. The editor instance stays alive for reuse.

save

Save back to the original source path (Node.js only).
SaveOptions
Throws if the editor was opened from a Blob/Buffer instead of a file path. Use saveTo() or exportDocument() instead.

saveTo

Save to a specific path (Node.js only).
string
required
File path

exportDocument

Export as a Blob (browser) or Buffer (Node.js).

exportDocx

Lower-level export with additional control. Returns: Promise<Blob> in the browser, Promise<Buffer> in headless/Node.js mode.
Object

replaceFile

Replace the current DOCX with a new file.

Content

getHTML

getJSON

getMarkdown

replaceContent

Replace the entire document content.

replaceNodeWithHTML

Replace a specific node with HTML.

Editor control

mount / unmount

destroy

Permanently destroy the editor.
Irreversible. The instance cannot be used after this.

focus / blur

setEditable

setDocumentMode

Commands

Deprecated. Editor commands (editor.commands) will be removed in a future version. Use the Document API (editor.doc) for programmatic document operations. See available operations for the full list.
All commands are accessed via editor.commands:

insertContent

Insert content with automatic format detection.
string | Object
required
Content to insert
Object
HTML and Markdown inline styles are stripped on import to ensure Word compatibility.

Document metadata

getMetadata

getDocumentIdentifier

Get a stable identifier (GUID or content hash).

isDocumentModified

Schema

getSchemaSummaryJSON

Generate a summary of the document schema. Useful for AI agents that need to understand the document structure.

Position & coordinates

getElementAtPos

Get the DOM element at a document position.
number
required
Document position

getNodesOfType

Get all nodes of a specific type.

isActive

Check if a node or mark is active.

getAttributes

Get attributes of the active node or mark.

Page & layout

getPageStyles

updatePageStyle

Properties