Revise Editor SDK menu

<ReviseEditor />

Props and helpers exported from revise.

TSX
import ReviseEditor from "revise";
import "revise/style.css";

Documents#

initialDocumentsreadonly ReviseDocumentInput[]

Documents opened on mount. Each needs a stable host-owned id and either a source (DOCX, ODT, RTF, Markdown, plain text, or HTML; docx is accepted as a legacy alias) or a collaboration config joining an existing room. See formats and collaboration.

activeDocumentIdstring | null

Controlled active document ID. Pair with onActiveDocumentChange.

defaultActiveDocumentIdstring | null

Initial active document ID for uncontrolled use. Defaults to the first document.

Behavior#

currentUserEditorUserIdentity | null

Author identity for comments, tracked changes, and collaboration presence.

role"editor" | "suggester" | "viewer"default: "editor"

Capability limit for all documents (overridable via ReviseDocumentInput.role). Cannot be escalated from inside the editor. See roles.

settingsReviseEditorSettings

Behavior settings under settings.trackedChanges:

  • markupStyle: "revise" (default) or "word" (red redlines, underlined insertions, struck-through deletions, no background tint).
  • showRemovalsInReview: start review with deleted text shown inline (default false).
  • strictMode: preserve other authors' pending suggestions on agent/tool edits rather than overwriting them (default true).

See tracked changes.

agentReviseAgentConfig

Backend, credentials, model, author name, turnStream, or stagingWorker for the delegated agent. See delegation and edits staged in a worker.

defaultDocumentMode"editing" | "suggesting" | "viewing"default: "editing"

Initial mode on open (uncontrolled). Use view.setDocumentMode() to change open documents.

defaultZoomnumber | 'fit-width'default: "fit-width"

Initial zoom level.

defaultCommentsOpenbooleandefault: true

Whether the comments panel starts open.

autoFocusbooleandefault: true

Focus the editor when a document becomes active. Pass false to focus only on click.

wasmHotPathsbooleandefault: false

Enable Rust/WASM acceleration for word diff, agent text matching, and document statistics. Available only via the revise/full entry point; falls back to TypeScript if WebAssembly is unavailable.

fontsreadonly ReviseFontDefinition[]

Additional fonts listed in the font picker. Load font files via @font-face or CSS.

onImageUpload(file: File, documentId: string) => Promise<string>

Upload handler for inserted, pasted, or dropped images; resolve to the image URL. Without it, images embed as data URLs. Files over 10 MB are rejected before upload; rejections show a notice and invoke onError.

onImportFile(file: File, documentId: string) => void

Enables the ribbon Import button (unless showImportButton={false}) and drag-and-drop import for document files (DOCX, ODT, RTF, Markdown, HTML, text, XML). Image drops still insert images. Your callback decides how to open the file.

showImportButtonbooleandefault: true

With onImportFile, show the Import button in the ribbon. Set false to import only via drag-and-drop or uploadPlaceholder.

uploadPlaceholderbooleandefault: false

With onImportFile, show an upload prompt in empty editable documents that invokes onImportFile.

Chrome#

toolbarMode"native" | "compact" | "floating" | "none"default: "native"

"native" (full ribbon), "compact" (centered subset for ~760px hosts), "floating" (floating full ribbon card), or "none" (no toolbar).

showClipboardButtonsbooleandefault: true

Show Paste, Cut, and Copy in the ribbon. Set false in sandboxed iframes without clipboard-write.

showTitleBarbooleandefault: true

Show the title bar above the ribbon (editable title, optional mode toggle, Review).

showTabsbooleandefault: false

Show the built-in tab strip.

findShortcut"editor" | "browser"default: "editor"

"editor" opens built-in find-and-replace on Cmd/Ctrl+F; "browser" leaves the shortcut to native browser find.

showDocumentModeTogglebooleandefault: false

Show the Editing/Suggesting toggle in the title bar.

onNewTab() => void

Renders a "+" button on the tab strip when provided.

Appearance#

theme"light" | "dark"default: "light"

Editor theme, scoped to this instance.

canvasBackgroundstring

CSS background behind the page.

pageBackgroundstring

CSS color for the page surface.

pageBorderColorstring

CSS color for the page border.

classNamestring
styleReact.CSSProperties

Callbacks and telemetry#

onReady(editor: ReviseEditorHandle) => void

Fires when the editor mounts (before documents finish opening). Store the handle and register subscriptions here.

onDocumentReady(document: ReviseDocumentHandle) => void

Fires once per document after parsing completes.

onChange(documentId: string, document: ReviseDocument) => void

Fires on every content mutation. Debounce before saving.

onDocumentsChange(state: ReviseDocumentCollectionState) => void

Fires when the open document list or statuses change.

onActiveDocumentChange(documentId: string | null) => void
onDocumentTitleChange(documentId: string, title: string) => void
onDocumentModeChange(documentId: string, mode: ReviseDocumentMode) => void
onZoomChange(documentId: string, zoom: ReviseZoom) => void
onAgentEvent(documentId: string, event: ReviseAgentEvent) => void
onAnalyticsEvent(event: string, properties?) => void

Internal instrumentation events routed only to this callback. Event names and shapes are internal and may change.

telemetrybooleandefault: true

Sends one anonymous ping per page load to Revise with the SDK version and browser Origin header (development hosts are counted without storing origin; no cookies, user data, or document content). Set false to disable. Separate from on-demand asset downloads (setAssetBaseUrl()). See license.

licenseKeystring

Commercial license key, verified offline against Revise's signature and never transmitted. Without a valid key, the editor runs identically and logs one console notice per page load. See license key.

onError(error: Error, documentId?: string) => void

Parse and runtime errors. Failed opens also set status: "error" in collection state.

Helpers#

createEmptyDocx(title?)Promise<Blob>

Generates a blank DOCX Blob.

TypeScript
import { createEmptyDocx } from "revise";
setAssetBaseUrl(url)(url: string | null | false) => void

Overrides the base URL for optional on-demand static assets (fonts/, katex.min.css, tree-sitter/). PDF export WebAssembly and PDF import codecs are bundled directly in revise. Defaults to https://revise.io; pass your self-hosted path (for example "/revise" populated via npx @reviseio/assets copy public/revise), false (or "") to disable remote asset fetches completely, or null to restore the default. Also exported from revise/server.