Architecture
Component boundary, canvas rendering, document sessions, fragments, and modes.
The boundary#
The SDK owns
- Parsing DOCX, ODT, RTF, Markdown, plain text, and HTML
- The document model and its Yjs session
- Canvas layout, pagination, and rendering
- Keyboard input, selection, and undo history
- Tracked changes and comment threads
- The agent tool runtime
Your application owns
- File loading and storage
- Document IDs
- Collaboration transport, if enabled
- Authentication, permissions, and tenancy
- Persistence and versioning
- Agent loop and model calls
- Any custom UI chrome
Document content does not leave the browser unless you configure a collaboration provider or a delegated agent backend. PDF export WebAssembly and PDF import codecs are bundled in revise; optional static assets (fallback PDF fonts, KaTeX CSS/fonts, Tree-sitter grammars) load from https://revise.io by default (self-host via @reviseio/assets + setAssetBaseUrl(), or disable with setAssetBaseUrl(false)), and the editor sends one anonymous version ping per page load (disable with telemetry={false}).
With revise/server, a Node process can also create, read, edit, and export the same Yjs documents.
Canvas rendering#
Revise renders to <canvas> using its own layout engine, text measurement, and hit testing rather than contenteditable, ProseMirror, or Slate. Page geometry follows Word (per-section page sizes and margins, running headers/footers, flowing footnotes, and DOCX-matched measurement).
Document content is not in the DOM. All reads and writes go through the handle or agent tools. Canvas rectangles and hit-test APIs are not exposed.
Document sessions#
ReviseEditor keeps every open document mounted, preserving caret, selection, scroll position, formatting context, search, review/comment state, zoom, and in-flight agent runs across tab switches.
Every document-local controller supports active-document and explicit routing:
editor.review.next(); // active document
editor.review.forDocument("exhibit-a").next(); // explicit document
editor.document("exhibit-a").review.next(); // equivalentRead collection state via editor.documents.getState() and editor.documents.subscribe().
Tool state is scoped per document session, not per call. Reads, edits, and search_result_id handles persist across tools.execute() calls until the document is closed or reloaded.
Document fragments#
Each document stores content in three fragments:
| Fragment | Contents |
|---|---|
content | Document body. Block operations and agent indices address only this fragment. |
chrome | Running headers and footers, per side, slot, and section. |
notes | Footnote and endnote bodies, referenced inline from content. |
Adding notes or headers does not shift body block indices.
Editing modes#
Each document has an independent mode, configurable at open time and changeable via view.setDocumentMode():
Changes apply directly (default).
Changes record as tracked suggestions.
Read-only.
Agent tool calls (tools.call, tools.execute, tools.executeDynamic) create tracked changes by default regardless of whether the document is in "editing" or "suggesting" mode. Delegated agent.run() also creates tracked changes by default on non-empty documents (empty documents auto-enable direct mode unless directMode is specified) and rejects in "viewing" mode. Pass { directMode: true } to apply edits directly. See tracked changes and agent tools.
Mode is not a permission boundary; any code with the handle can change it. To restrict a participant's actions, set a role.