Skip to content
Document Authoring DA  API Docs v1.22.2
npmGitHub

ContextMenuActionItem>= v1.23.0

ContextMenuActionItem:

{
type: "action";
}

Context menu item that runs a registered action.

The item shows the action’s label and icon. It is hidden when the action isn’t registered, and disabled when the action can’t run, for example when its isEnabled() returns false or the editor is in view mode and the action’s capabilities aren’t allowed there. The action must be registered via DocAuthEditor.setActions or UIOptions.actions.

editor.setActions([
{
id: 'custom.uppercase',
label: 'Uppercase',
isEnabled: () => !!editor.getSelectionContent({ format: 'text' }),
handler: () => {
const text = editor.getSelectionContent({ format: 'text' });
if (text) editor.insertContentAtCursor({ content: text.toUpperCase() });
},
},
]);
editor.setContextMenuConfig({
text: { items: [{ type: 'action', id: 'uppercase', actionId: 'custom.uppercase' }] },
});

ContextMenuConfig for the full context menu configuration.

type: "action"


id: string

Unique ID for this context menu item


actionId: string

ID of the action to run when this item is chosen