Editor Modes
Understanding the four editor modes: editing, suggesting, viewing, and readOnly.
Overview
The editor supports four modes that control how users interact with the document:
| Mode | Prop | Description |
|---|---|---|
| Editing | mode="editing" | Full editing — changes are applied directly |
| Suggesting | mode="suggesting" | Track changes — edits are recorded as suggestions |
| Viewing | mode="viewing" | Read-only with toolbar visible — users can zoom, print, navigate |
| Read-Only | readOnly={true} | Minimal preview — no toolbar, no rulers, no interaction UI |
Editing Mode
The default mode. Users can freely edit the document — type text, format, insert tables and images, etc. All changes are applied directly to the document.
<DocxEditor
documentBuffer={buffer}
mode="editing"
/>Suggesting Mode
Enables track changes. All edits are recorded as insertions and deletions that can be accepted or rejected. This is useful for collaborative editing workflows.
<DocxEditor
documentBuffer={buffer}
mode="suggesting"
author="Jane Doe"
/>The author prop sets who is credited for each tracked change. The toolbar shows accept/reject controls for suggestions.
Viewing Mode
A read-only mode that keeps the toolbar visible. Users can zoom, print, navigate headings, and use the document outline — but they cannot edit content. This is the right choice for document review UIs where users still need toolbar controls.
<DocxEditor
documentBuffer={buffer}
mode="viewing"
/>Read-Only Mode
The most minimal mode. Hides the toolbar, rulers, and all editing UI. The document is rendered as a static preview. Use this for embedding documents in pages where no interaction is needed.
<DocxEditor
documentBuffer={buffer}
readOnly
/>Controlled Mode Switching
You can let users switch modes at runtime using onModeChange:
function App() {
const [mode, setMode] = useState<'editing' | 'suggesting' | 'viewing'>('editing');
return (
<div>
<select value={mode} onChange={(e) => setMode(e.target.value as any)}>
<option value="editing">Editing</option>
<option value="suggesting">Suggesting</option>
<option value="viewing">Viewing</option>
</select>
<DocxEditor
documentBuffer={buffer}
mode={mode}
onModeChange={setMode}
author="Jane Doe"
/>
</div>
);
}The onModeChange callback fires when the user switches modes through the toolbar's built-in mode selector (if visible). Passing both mode and onModeChange makes it a controlled component.
Mode Comparison
| Feature | Editing | Suggesting | Viewing | Read-Only |
|---|---|---|---|---|
| Text editing | Yes | Yes (tracked) | No | No |
| Toolbar visible | Yes | Yes | Yes | No |
| Rulers | Configurable | Configurable | Configurable | No |
| Zoom controls | Yes | Yes | Yes | No |
| Yes | Yes | Yes | No | |
| Comments | Yes | Yes | View only | No |
| Track changes UI | No | Yes | View only | No |
| Document outline | Configurable | Configurable | Configurable | No |