Customization

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>

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>

Group rows with Group, Separator, and Submenu.

Configure file actions

Set these props on DocxEditor.Menu.

PropBehavior
onOpenReplaces the default file picker.
onOpenFileReceives the file before the default open action loads it.
onSaveReplaces the default save and download.
fileNameDefault download name, without extension.
exportersMarkdown and PDF conversion handlers. Print uses the PDF handler.
printSettingstrue (default) asks what markup to print. false prints the current view.
onPageSetupOpens your UI when popups.pageSetup is absent.
onReportIssueReplaces 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.

PartOptions
DocxEditor.Menut, preset, overflow, child menus.
DocxEditor.ContextMenut, preset, disabled, onOpenChange.
Named menu: File, Format, Insert, Review, Helppreset. Replaces its menu in place.
Menu.Entryid, label or labelKey, icon, preset. Appends a menu.
Menu.ItemslotId, labelKey, shortcutKey.
Context menu command partsicon, labelKey, shortcutKey.
Menu.Rowicon, shortcut, disabled, title, active, selected, onSelect.
Menu.Group, Menu.Submenulabel or labelKey. Submenu also takes paths.
Menu.SeparatorclassName 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: false hides 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. disabled restores the browser menu everywhere.

See also