Revise Editor SDK menu

ReviseEditorHandle

Imperative controllers exposed via onReady and ref.

onReady (and ref) provide a ReviseEditorHandle. Controller identities are stable for the component lifetime.

TypeScript
const editor = useRef<ReviseEditorHandle | null>(null);

<ReviseEditor onReady={(handle) => (editor.current = handle)} />;

Routing#

Document-scoped controllers default to the active document or can target a specific document ID:

TypeScript
editor.review.next();
editor.review.forDocument("exhibit-a").next();
editor.document("exhibit-a").review.next(); // equivalent

Scoped controllers: tools, toolbar, review, view, zoom, selection, agent, comments, collaboration.

documents#

open(document, options?)Promise<ReviseDocumentHandle>

Opens and parses a document. Pass { activate: false } to load in the background.

close(documentId)boolean
activate(documentId)boolean
get(documentId?)ReviseDocumentHandle | null
require(documentId?)ReviseDocumentHandle

Same as get, but throws if not found.

getActiveId()string | null
list()ReviseOpenDocument[]
getState()ReviseDocumentCollectionState
subscribe(listener)() => void

tools#

getDefinitions()ReviseEditorToolDefinition[]

Document-local JSON schemas (excludes revise_run_agent). editor.getToolDefinitions() returns executable wrappers and includes revise_run_agent when an agent is configured.

execute(name, input?, options?)Promise<ReviseToolResult<Name>>

Typed tool execution; expected rejections return { ok: false, error }. Options: { documentId?, directMode? }. context_notes is optional and defaults to "N/A".

executeDynamic(name, input?, options?)Promise<ReviseToolResult<string>>

Untyped execution for model calls, browser-only tools (get_selection, view_image, revise_run_agent), and model-provided document_id.

call(name, input?, options?)Promise<ReviseToolResponse<Name>>

Returns the success payload or throws ReviseToolError.

exportDocx(documentId?)Promise<Blob>
export(options?, documentId?)Promise<Blob>

Exports "docx" (default), "pdf", "html", "markdown", or "txt". mode: "review" (default) keeps tracked changes/comments in .docx and accepts them in other formats; "final" accepts all changes and drops comments. See export.

acceptAllSuggestions(documentId?)ReviseSuggestionDecision
rejectAllSuggestions(documentId?)ReviseSuggestionDecision

toolbar#

getState() / subscribe(listener)ReviseToolbarState

Current formatting marks, block type, undo/redo availability, and review counts.

setActiveTab(tab) / openFind()void

Switches the ribbon row ("edit" | "layout" | "insert" | "review"; "tools" is ignored in the SDK—use editor.getStatistics() for word/character counts). Page and section breaks are on "layout".

Commands return false when inapplicable (copy/copyAs return Promise<void>; paste*/insertImage return Promise<boolean>):

AreaMethods
History & clipboardundo(), redo(), copy(), copyAs("plaintext" | "markdown" | "html"), cut(), paste(), pasteTextOnly(), pasteFormattingOnly()
InlinetoggleInline(command), toggleBold(), toggleItalic(), toggleUnderline(), toggleStrikethrough(), toggleDoubleStrikethrough(), toggleSmallCaps(), toggleAllCaps(), toggleCode(), toggleLatex(), toggleSuperscript(), toggleSubscript(), clearFormatting()
TypographysetFontFamily(fontFamily?), setFontSize(fontSizePt?), setLetterSpacing(spacing?), setTextColor(color?), setHighlightColor(color?)
ParagraphsetHeading(level?: 1 | 2 | 3 | 4 | 5 | 6), setAlignment(alignment?: "left" | "center" | "right" | "justify"), setLineSpacing(spacing?), toggleList("ordered" | "unordered" | "todo"), createLink(), increaseIndent(), decreaseIndent()
InsertinsertTable(rows, columns), insertImage(file: File), insertContainer(), insertCodeBlock(language?), insertMathBlock(content?), insertDiagram(content?), insertFootnote(kind?: "footnote" | "endnote"), insertPageNumber(), insertPageBreak(), insertSectionBreak()
ReviewopenReview(), closeReview(), reviewPrevious(), reviewNext(), acceptCurrent(), rejectCurrent(), acceptAll(), rejectAll(), setShowRemovals(show), setSuggestionViewMode("all-markup" | "final" | "original")

view#

getState() / subscribe(listener)ReviseViewState

{ ready, title, documentMode, readOnly, commentsOpen, commentCount, reviewOpen, reviewTargetCount }

setTitle(title)void
setDocumentMode(mode)void
setCommentsOpen(open)void
setReviewOpen(open)void

review#

getState() / subscribe(listener)ReviseReviewState

Panel state, target counts, suggestion IDs, active comment, view mode, and comment threads.

AreaMethods
Navigationopen, close, previous, next, nextAgentSuggestion, navigateToSuggestion, navigateWithinSuggestions
DecisionsacceptCurrent, rejectCurrent, acceptAll, rejectAll, acceptSuggestions, rejectSuggestions
PreviewpreviewCurrent, previewAll, previewSuggestions
DisplaysetShowRemovals, setSuggestionViewMode, getOpenSuggestionIds
CommentsopenComments, closeComments, selectComment, addCommentAtSelection, addCommentToRanges, addCommentToBlock, addCommentForSuggestion, replyToComment, setCommentResolved, deleteComment, getRelatedSuggestionIds, acceptCommentSuggestions, rejectCommentSuggestions
listChanges()ReviseTrackedChange[]

Computes pending changes on demand (not part of subscribed state). See custom review panel.

getChange(suggestionId)ReviseTrackedChange | null

Single change by ID, or null if resolved.

selection#

getSnapshot()ReviseSelectionSnapshot
observe(listener) / subscribe(listener)() => void
capture()ReviseSelectionCapture | null

Captures selection before focus leaves the editor (null if no selection/caret).

restore(capture)ReviseSelectionRestoreResult

Restores a captured selection and focuses the editor.

clear()void

zoom#

getState()ReviseZoomState
setZoom(zoom) / fitWidth()void
subscribe(listener)() => void

agent#

run(task, options?)Promise<ReviseAgentRunResult>
steer(message)boolean
cancel()void
subscribe(listener)() => void

comments#

Thread-scoped delegated agent runs:

run(threadId, prompt?)Promise<ReviseCommentAgentRunResult>
steer(threadId, message)boolean
cancel(threadId)void
getState(threadId)ReviseCommentAgentState | undefined
subscribe(listener)() => void

Publishes ReadonlyMap<string, ReviseCommentAgentState>.

collaboration#

getState()ReviseCollaborationState

{ enabled, synced, peers } (includes local participant with isLocal: true; empty without awareness).

subscribe(listener)() => void

Convenience#

Active-document shorthands (accept an optional documentId). onReady fires before documents open: subscriptions are safe immediately, but document actions require onDocumentReady or await editor.whenReady().

TypeScript
await editor.whenReady(documentId?);  // resolves to ReviseDocumentHandle
editor.getRole(documentId?);          // "editor" | "suggester" | "viewer"
editor.getDocument(documentId?);
editor.getStatistics(documentId?);    // { wordCount, characterCount }
editor.getDocumentMode(documentId?);
editor.setDocumentMode(mode, documentId?);
editor.getToolDefinitions(documentId?);
editor.focus(documentId?);
editor.openReview(documentId?);
editor.closeReview(documentId?);
editor.openComments(documentId?);
editor.closeComments(documentId?);

getStatistics() runs without a layout pass; counts include pending insertions and exclude pending deletions (or reflect rejected state in "original" view mode). ReviseDocumentHandle (returned by editor.document(id) / whenReady()) also exposes getSourceFidelity(): ReviseSourceFidelityReport.