ReviseEditorHandle
Imperative controllers exposed via onReady and ref.
onReady (and ref) provide a ReviseEditorHandle. Controller identities are stable for the component lifetime.
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:
editor.review.next();
editor.review.forDocument("exhibit-a").next();
editor.document("exhibit-a").review.next(); // equivalentScoped 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)booleanactivate(documentId)booleanget(documentId?)ReviseDocumentHandle | nullrequire(documentId?)ReviseDocumentHandleSame as get, but throws if not found.
getActiveId()string | nulllist()ReviseOpenDocument[]getState()ReviseDocumentCollectionStatesubscribe(listener)() => voidtools#
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?)ReviseSuggestionDecisionrejectAllSuggestions(documentId?)ReviseSuggestionDecisiontoolbar#
getState() / subscribe(listener)ReviseToolbarStateCurrent formatting marks, block type, undo/redo availability, and review counts.
setActiveTab(tab) / openFind()voidSwitches 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>):
| Area | Methods |
|---|---|
| History & clipboard | undo(), redo(), copy(), copyAs("plaintext" | "markdown" | "html"), cut(), paste(), pasteTextOnly(), pasteFormattingOnly() |
| Inline | toggleInline(command), toggleBold(), toggleItalic(), toggleUnderline(), toggleStrikethrough(), toggleDoubleStrikethrough(), toggleSmallCaps(), toggleAllCaps(), toggleCode(), toggleLatex(), toggleSuperscript(), toggleSubscript(), clearFormatting() |
| Typography | setFontFamily(fontFamily?), setFontSize(fontSizePt?), setLetterSpacing(spacing?), setTextColor(color?), setHighlightColor(color?) |
| Paragraph | setHeading(level?: 1 | 2 | 3 | 4 | 5 | 6), setAlignment(alignment?: "left" | "center" | "right" | "justify"), setLineSpacing(spacing?), toggleList("ordered" | "unordered" | "todo"), createLink(), increaseIndent(), decreaseIndent() |
| Insert | insertTable(rows, columns), insertImage(file: File), insertContainer(), insertCodeBlock(language?), insertMathBlock(content?), insertDiagram(content?), insertFootnote(kind?: "footnote" | "endnote"), insertPageNumber(), insertPageBreak(), insertSectionBreak() |
| Review | openReview(), 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)voidsetDocumentMode(mode)voidsetCommentsOpen(open)voidsetReviewOpen(open)voidreview#
getState() / subscribe(listener)ReviseReviewStatePanel state, target counts, suggestion IDs, active comment, view mode, and comment threads.
| Area | Methods |
|---|---|
| Navigation | open, close, previous, next, nextAgentSuggestion, navigateToSuggestion, navigateWithinSuggestions |
| Decisions | acceptCurrent, rejectCurrent, acceptAll, rejectAll, acceptSuggestions, rejectSuggestions |
| Preview | previewCurrent, previewAll, previewSuggestions |
| Display | setShowRemovals, setSuggestionViewMode, getOpenSuggestionIds |
| Comments | openComments, 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 | nullSingle change by ID, or null if resolved.
selection#
getSnapshot()ReviseSelectionSnapshotobserve(listener) / subscribe(listener)() => voidcapture()ReviseSelectionCapture | nullCaptures selection before focus leaves the editor (null if no selection/caret).
restore(capture)ReviseSelectionRestoreResultRestores a captured selection and focuses the editor.
clear()voidzoom#
getState()ReviseZoomStatesetZoom(zoom) / fitWidth()voidsubscribe(listener)() => voidagent#
run(task, options?)Promise<ReviseAgentRunResult>steer(message)booleancancel()voidsubscribe(listener)() => voidcomments#
Thread-scoped delegated agent runs:
run(threadId, prompt?)Promise<ReviseCommentAgentRunResult>steer(threadId, message)booleancancel(threadId)voidgetState(threadId)ReviseCommentAgentState | undefinedsubscribe(listener)() => voidPublishes ReadonlyMap<string, ReviseCommentAgentState>.
collaboration#
getState()ReviseCollaborationState{ enabled, synced, peers } (includes local participant with isLocal: true; empty without awareness).
subscribe(listener)() => voidConvenience#
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().
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.