Documentation Index
Fetch the complete documentation index at: https://docs.superdoc.dev/llms.txt
Use this file to discover all available pages before exploring further.
useSuperDocDocument() exposes { ready, mode }. ui.document.setMode('suggesting') flips the editor into Suggest mode. ui.document.export({ exportType: ['docx'] }) returns a downloadable DOCX. ui.document.replaceFile(file) swaps the open document.
Edit and Suggest mode
Suggest mode records every edit as a tracked change. Edit mode applies edits directly. Toggle from your toolbar.'editing', 'suggesting', 'viewing'. The controller mirrors the host’s documentMode, so external mode changes flow back into the hook.
Export to DOCX
| Field | Type | Meaning |
|---|---|---|
exportType | string[] | ['docx'] for Word format. |
commentsType | 'internal' | 'external' | 'external' exports comments as Word comments; 'internal' keeps them in private metadata. |
triggerDownload | boolean | When true, the browser saves the file. When false, you get the blob back. |
Replace the open file
For round-trip testing or document switchers.replaceFile runs the engine’s import path and then re-emits commentsLoaded so your comments sidebar refreshes automatically (relevant when modules.comments: false).
What the hook returns
| Field | Type | Meaning |
|---|---|---|
ready | boolean | The editor has reported ready. |
mode | 'editing' | 'suggesting' | 'viewing' | null | Mirrors superdoc.config.documentMode. |
dirty | boolean | True when the document has unsaved changes. |
useSuperDocDocument re-renders only when ready, mode, or dirty flips. A typing-only edit triggers it once (when dirty flips false → true) and not again until dirty clears.
Unsaved-changes indicator
dirty flips to true on any editor transaction that mutates the document. Selection-only transactions leave it alone. ui.document.export(...) clears it on success; a rejected export keeps it set so the user can retry. ui.document.replaceFile(...) clears it too. Undo-to-clean is intentionally not tracked: hitting undo until the document matches its on-open state still reads as dirty. Apps that want Word/GDocs “no unsaved changes” semantics layer their own edit-count diff on top.
Trade-offs
setModeforwards to the host. SSR / non-browser stubs that omit the setter fall back to a no-op.exportis async and rejects on host errors. Unhandled rejections are noisy; always wrap.replaceFilerebuilds the document model. Selection, scroll position, and undo history reset.

