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

BuiltInActionNEW

BuiltInAction:

Built-in actions have pre-defined IDs from BuiltInActionId and automatically use default handlers if not provided. This allows you to customize things without having to reimplement internal functionality.

import { defaultActions } from '@nutrient-sdk/document-authoring';
// Remove all built-in actions except bold built-in (handler auto-populated)
editor.setActions([{ id: 'formatting.bold', label: 'Bold', shortcuts: ['Mod+B'] }]);
// Override the default handler for bold
editor.setActions([
...defaultActions.filter(({ id }) => id !== 'formatting.bold'),
{
id: 'formatting.bold',
label: 'Bold',
shortcuts: ['Mod+B'],
handler: () => {
console.log('Custom bold implementation');
},
},
]);
// Customize shortcuts and labels while keeping default behavior
editor.setActions([
...defaultActions.filter(({ id }) => id !== 'document.export-pdf'),
{ id: 'document.export-pdf', label: 'Download PDF', shortcuts: ['Mod+P'] },
]);

id: BuiltInActionId


label: string


optional description: string


optional shortcuts: string[]

Keyboard shortcuts for the action. Use “Mod” as the primary modifier key - it will be automatically resolved to:

  • “Ctrl” on Windows/Linux
  • ”⌘” (Command) on Mac

Examples:

  • “Mod+B” becomes “Ctrl+B” on Windows, “⌘B” on Mac
  • “Mod+Shift+P” becomes “Ctrl+Shift+P” on Windows, ”⌘⇧P” on Mac

optional icon: string

Icon as data URI (e.g., data:image/svg+xml;base64,… or data:image/png;base64,…). Only data:image/ URIs are allowed for security.


optional isEnabled: () => boolean

boolean


optional handler: (…args) => void | Promise<void>

Handler function - optional for built-in actions (defaults will be used if omitted)

unknown[]

void | Promise<void>