Skip to main content
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.
Modes: 'editing', 'suggesting', 'viewing'. The controller mirrors the host’s documentMode, so external mode changes flow back into the hook.

Export to DOCX

Options: Export rejects if the host can’t produce the format. Wrap your toolbar button in try/catch and surface the error inline.

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

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

  • setMode forwards to the host. SSR / non-browser stubs that omit the setter fall back to a no-op.
  • export is async and rejects on host errors. Unhandled rejections are noisy; always wrap.
  • replaceFile rebuilds the document model. Selection, scroll position, and undo history reset.