<ReviseEditor />
Props and helpers exported from revise.
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 | nullControlled active document ID. Pair with onActiveDocumentChange.
defaultActiveDocumentIdstring | nullInitial active document ID for uncontrolled use. Defaults to the first document.
Behavior#
currentUserEditorUserIdentity | nullAuthor 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.
settingsReviseEditorSettingsBehavior 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 (defaultfalse).strictMode: preserve other authors' pending suggestions on agent/tool edits rather than overwriting them (defaulttrue).
See tracked changes.
agentReviseAgentConfigBackend, 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: trueWhether the comments panel starts open.
autoFocusbooleandefault: trueFocus the editor when a document becomes active. Pass false to focus only on click.
wasmHotPathsbooleandefault: falseEnable 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) => voidEnables 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: trueWith onImportFile, show the Import button in the ribbon. Set false to import only via drag-and-drop or uploadPlaceholder.
uploadPlaceholderbooleandefault: falseWith 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: trueShow Paste, Cut, and Copy in the ribbon. Set false in sandboxed iframes without clipboard-write.
showTitleBarbooleandefault: trueShow the title bar above the ribbon (editable title, optional mode toggle, Review).
showTabsbooleandefault: falseShow 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: falseShow the Editing/Suggesting toggle in the title bar.
onNewTab() => voidRenders a "+" button on the tab strip when provided.
Appearance#
theme"light" | "dark"default: "light"Editor theme, scoped to this instance.
canvasBackgroundstringCSS background behind the page.
pageBackgroundstringCSS color for the page surface.
pageBorderColorstringCSS color for the page border.
classNamestringstyleReact.CSSPropertiesCallbacks and telemetry#
onReady(editor: ReviseEditorHandle) => voidFires when the editor mounts (before documents finish opening). Store the handle and register subscriptions here.
onDocumentReady(document: ReviseDocumentHandle) => voidFires once per document after parsing completes.
onChange(documentId: string, document: ReviseDocument) => voidFires on every content mutation. Debounce before saving.
onDocumentsChange(state: ReviseDocumentCollectionState) => voidFires when the open document list or statuses change.
onActiveDocumentChange(documentId: string | null) => voidonDocumentTitleChange(documentId: string, title: string) => voidonDocumentModeChange(documentId: string, mode: ReviseDocumentMode) => voidonZoomChange(documentId: string, zoom: ReviseZoom) => voidonAgentEvent(documentId: string, event: ReviseAgentEvent) => voidonAnalyticsEvent(event: string, properties?) => voidInternal instrumentation events routed only to this callback. Event names and shapes are internal and may change.
telemetrybooleandefault: trueSends 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.
licenseKeystringCommercial 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) => voidParse and runtime errors. Failed opens also set status: "error" in collection state.
Helpers#
createEmptyDocx(title?)Promise<Blob>Generates a blank DOCX Blob.
import { createEmptyDocx } from "revise";setAssetBaseUrl(url)(url: string | null | false) => voidOverrides 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.