Menus
Customize the DOCX editor menu bar and context menu with packaged commands, application actions, and file handlers.
Compose DocxEditor.Menu and DocxEditor.ContextMenu independently. Packaged rows take their label, icon, state, and command from the editor.
Customize menu actions
Set preset={false} to choose every row. ContextMenu.Slot with a slotId renders a packaged command.
<DocxEditor.ContextMenu preset={false}>
<DocxEditor.ContextMenu.Cut />
<DocxEditor.ContextMenu.Copy />
<DocxEditor.ContextMenu.Slot slotId="format.clear" />
</DocxEditor.ContextMenu><DocxEditor.ContextMenu :preset="false">
<DocxEditor.ContextMenu.Cut />
<DocxEditor.ContextMenu.Copy />
<DocxEditor.ContextMenu.Slot slot-id="format.clear" />
</DocxEditor.ContextMenu>To remove one default row, add its slot or named part with hidden: <DocxEditor.ContextMenu.Slot slotId="review.addComment" hidden />.
For slot identifiers, see Chrome slot reference.
Add an application action
ContextMenu.Item runs your handler. To disable it, pass disabled and disabledReason.
<DocxEditor.ContextMenu>
<DocxEditor.ContextMenu.Item label="Ask legal" onSelect={askLegal} />
</DocxEditor.ContextMenu><DocxEditor.ContextMenu>
<DocxEditor.ContextMenu.Item label="Ask legal" @select="askLegal" />
</DocxEditor.ContextMenu>Group rows with Group, Separator, and Submenu.
Configure file actions
Set these props on DocxEditor.Menu.
| Prop | Behavior |
|---|---|
onOpen | Replaces the default file picker. |
onOpenFile | Receives the file before the default open action loads it. |
onSave | Replaces the default save and download. |
fileName | Default download name, without extension. |
exporters | Markdown and PDF conversion handlers. Print uses the PDF handler. |
printSettings | true (default) asks what markup to print. false prints the current view. |
onPageSetup | Opens your UI when popups.pageSetup is absent. |
onReportIssue | Replaces the support action. reportIssue={false} removes it. |
For converter wiring, see Export and Print.
Configure menu parts
Every part accepts className. Most accept hidden and children.
| Part | Options |
|---|---|
DocxEditor.Menu | t, preset, overflow, child menus. |
DocxEditor.ContextMenu | t, preset, disabled, onOpenChange. |
Named menu: File, Format, Insert, Review, Help | preset. Replaces its menu in place. |
Menu.Entry | id, label or labelKey, icon, preset. Appends a menu. |
Menu.Item | slotId, labelKey, shortcutKey. |
| Context menu command parts | icon, labelKey, shortcutKey. |
Menu.Row | icon, shortcut, disabled, title, active, selected, onSelect. |
Menu.Group, Menu.Submenu | label or labelKey. Submenu also takes paths. |
Menu.Separator | className only. |
Use title to explain a disabled row.
Limits
- A hidden row does not block its operation in other controls, shortcuts, or the API.
- A missing export handler produces an error when the user requests that conversion.
popups.export: falsehides export progress. It does not cancel conversion.- Browser clipboard access can refuse Paste. Keep the supplied refusal feedback.
- Built-in menus handle keyboard navigation, Escape, dismissal, and selection protection, also for custom rows. A menu built from hooks must do this itself.
- The context menu opens on pages and the canvas around them.
disabledrestores the browser menu everywhere.