Skip to main content

Open a document

A document is a File, Blob, or ArrayBuffer in any of the supported formats. Pass documents in initialDocuments, or open them at runtime:
open() resolves to a ReviseDocumentHandle when the document is parsed and ready. A new document becomes active by default. Pass { activate: false } to open it in the background.
You assign document IDs. Each must be stable and unique within one editor instance. Callbacks, tool routing, and forDocument() use them. Do not reuse an ID for different content.

Per-document options

Any editor-wide option can be overridden per document:

Switch and close

Closing a document does not save it. Export it first if you need the file.

Observe the document list

Each entry has a status of "opening", "ready", or "error", and an error string when parsing failed. Use them to render tabs with loading and error states.

Controlled or uncontrolled

By default, the component tracks the active document. To control it from your own state, pass activeDocumentId and handle onActiveDocumentChange:
defaultActiveDocumentId sets the initial active document without controlling it.

Export

Read content

Read the document tree for your own logic, such as word counts, validation, or autosave:
onChange(documentId, document) fires on every edit from the user, your toolbar, or an agent.
onChange fires on every keystroke. Debounce before saving. Use measure_document or a cheap check instead of walking the whole tree on every call.