# @embedpdf/plugin-commands — . BoundCommand [InterfaceDeclaration] (from packages/plugin/commands/src/contract.ts): export interface BoundCommand extends ResolvedCommand{ readonly run: () => Promise; readonly shortcutLabel: string | null; } COMMANDS_DEFAULTS [VariableDeclaration] (from packages/plugin/commands/src/contract.ts): COMMANDS_DEFAULTS: CommandsSettings ={ commands: [], appState: undefined, disabledCategories: [], disabledCommands: [], notAllowed: 'hide', } CommandContext [InterfaceDeclaration] (from packages/core/main/src/command-types.ts): export interface CommandContext{ readonly documentId: string | null; readonly appState: AppState; readonly args?: unknown; readonly signal?: AbortSignal; get(token: CapabilityToken): T; tryGet(token: CapabilityToken): T | null; } CommandDefinition [InterfaceDeclaration] (from packages/core/main/src/command-types.ts): export interface CommandDefinition{ readonly id: string; readonly label?: string; readonly labelKey?: string; readonly icon?: string; iconAccent?(context: CommandContext): IconAccent | null; readonly shortcut?: string | readonly string[]; readonly shortcutInTextFields?: boolean; readonly categories?: readonly string[]; readonly requires?: readonly Permission[]; allowed?(context: CommandContext): boolean; readonly notAllowedKey?: string; locked?(context: CommandContext): SettingLock | null; readonly menu?: string; readonly panel?: | string |{ readonly id: string; readonly exclusive?: string; readonly focus?: boolean} ; readonly modal?: string; enabled?(context: CommandContext): boolean; active?(context: CommandContext): boolean; visible?(context: CommandContext): boolean; labelParams?(context: CommandContext): Readonly>; run?(context: CommandContext): void | Promise; } CommandExecutedEvent [InterfaceDeclaration] (from packages/plugin/commands/src/contract.ts): export interface CommandExecutedEvent{ readonly commandId: CommandId; readonly documentId: string | null; readonly args: unknown; } CommandExecutionFailedEvent [InterfaceDeclaration] (from packages/plugin/commands/src/contract.ts): export interface CommandExecutionFailedEvent{ readonly commandId: CommandId; readonly documentId: string | null; readonly error: PluginErrorInfo; } CommandFamily [InterfaceDeclaration] (from packages/core/main/src/command-types.ts): export interface CommandFamily{ readonly prefix: string; readonly names: (context: CommandContext) => readonly string[]; readonly command: (name: string) => Omit; } CommandId [TypeAliasDeclaration] (from packages/plugin/commands/src/contract.ts): export type CommandId = string; CommandRefusal [InterfaceDeclaration] (from packages/plugin/commands/src/contract.ts): export interface CommandRefusal{ readonly reason: 'turned-off' | 'not-allowed' | 'locked'; readonly message: string; } CommandsCapability [InterfaceDeclaration] (from packages/plugin/commands/src/contract.ts): export interface CommandsCapability extends SettingsApi{ registerCommand(definition: CommandDefinition, options?: RegisterCommandOptions): Unsubscribe; registerCommands( definitions: readonly CommandDefinition[], options?: RegisterCommandOptions, ): Unsubscribe; hasCommand(id: CommandId): boolean; getCommand(id: CommandId): CommandDefinition | null; listCommandIds(): readonly CommandId[]; resolveCommand(id: CommandId, documentId?: string): ResolvedCommand | null; listCommands(documentId?: string): readonly ResolvedCommand[]; searchCommands(query: string, documentId?: string): readonly ResolvedCommand[]; listShortcuts(): readonly{ readonly commandId: CommandId; readonly shortcut: string} []; execute(id: CommandId, options?: ExecuteOptions): Promise; canExecute(id: CommandId, documentId?: string): boolean; getRefusal(id: CommandId, documentId?: string): CommandRefusal | null; getDisabledCategories(): readonly string[]; isCategoryDisabled(category: string): boolean; disableCategory(category: string): void; enableCategory(category: string): void; setDisabledCategories(categories: readonly string[]): void; getDisabledCommands(): readonly CommandId[]; isCommandDisabled(id: CommandId): boolean; disableCommand(id: CommandId): void; enableCommand(id: CommandId): void; setDisabledCommands(ids: readonly CommandId[]): void; readonly onExecuted: EventHook; readonly onExecutionFailed: EventHook; } CommandsConfig [TypeAliasDeclaration] (from packages/plugin/commands/src/contract.ts): export type CommandsConfig = Omit< DeepPartial, 'commands' | 'appState' > &{ readonly commands?: readonly (CommandDefinition | CommandFamily)[]; readonly appState?: AppState; } ; CommandsSettings [InterfaceDeclaration] (from packages/plugin/commands/src/contract.ts): export interface CommandsSettings{ readonly commands: readonly (CommandDefinition | CommandFamily)[]; readonly appState: unknown; readonly disabledCategories: readonly string[]; readonly disabledCommands: readonly CommandId[]; readonly notAllowed: NotAllowedMode; } CommandsToken [VariableDeclaration] (from packages/plugin/commands/src/token.ts): CommandsToken = createCapabilityToken('commands', { hint: `add commandsPlugin() from '@embedpdf/plugin-commands' to your plugins list`, } ) ExecuteOptions [InterfaceDeclaration] (from packages/plugin/commands/src/contract.ts): export interface ExecuteOptions extends OperationOptions{ documentId?: string; args?: unknown; } ExecuteResult [TypeAliasDeclaration] (from packages/plugin/commands/src/contract.ts): export type ExecuteResult = |{ readonly status: 'executed'} |{ readonly status: 'rejected'; readonly reason: 'not-found' | 'disabled' | 'hidden'} ; IconAccent [InterfaceDeclaration] (from packages/core/main/src/command-types.ts): export interface IconAccent{ readonly primary?: string; readonly secondary?: string; } NotAllowedMode [TypeAliasDeclaration] (from packages/plugin/commands/src/contract.ts): export type NotAllowedMode = 'hide' | 'disable'; RegisterCommandOptions [InterfaceDeclaration] (from packages/plugin/commands/src/contract.ts): export interface RegisterCommandOptions{ replace?: boolean; } ResolvedCommand [InterfaceDeclaration] (from packages/plugin/commands/src/contract.ts): export interface ResolvedCommand{ readonly id: string; readonly label: string; readonly icon?: string; readonly iconAccent?: IconAccent; readonly shortcuts: readonly string[]; readonly menu?: string; readonly enabled: boolean; readonly active: boolean; readonly pressable: boolean; readonly visible: boolean; readonly categories: readonly string[]; readonly disabledReason?: string; } boundCommandOf [FunctionDeclaration] (from packages/plugin/commands/src/contract.ts): export function boundCommandOf( command: ResolvedCommand, execute: (id: CommandId) => Promise, options:{ readonly isMac: boolean} , ): BoundCommand{ const [first] = command.shortcuts; return{ ...command, run: () => execute(command.id), shortcutLabel: first === undefined ? null : formatShortcut(first, { isMac: options.isMac} ), } ; } commandsPlugin [VariableDeclaration] (from packages/plugin/commands/src/commands.plugin.ts): commandsPlugin = (config?: CommandsConfig) => definePlugin({ id: 'commands', scope: 'workspace', token: CommandsToken, optional: [I18nToken, ShellToken], resolvesAnyCapability: true, settings:{ defaults: COMMANDS_DEFAULTS, registered: config as CommandsConfig | undefined, whole: ['appState'], } , create: createCommandsController, inScope: (commands, documentId) => ({ ...commands, resolveCommand: (id, target = documentId) => commands.resolveCommand(id, target), listCommands: (target = documentId) => commands.listCommands(target), searchCommands: (query, target = documentId) => commands.searchCommands(query, target), execute: (id, options) => commands.execute(id, { ...options, documentId: options?.documentId ?? documentId} ), canExecute: (id, target = documentId) => commands.canExecute(id, target), getRefusal: (id, target = documentId) => commands.getRefusal(id, target), } ), } ) resolvedCommandsEqual [VariableDeclaration] (from packages/plugin/commands/src/contract.ts): resolvedCommandsEqual = ( left: ResolvedCommand | null, right: ResolvedCommand | null, ): boolean =>{ if (left === right) return true; if (!left || !right) return false; return ( left.id === right.id && left.label === right.label && left.icon === right.icon && left.iconAccent?.primary === right.iconAccent?.primary && left.iconAccent?.secondary === right.iconAccent?.secondary && left.menu === right.menu && left.enabled === right.enabled && left.active === right.active && left.pressable === right.pressable && left.visible === right.visible && left.disabledReason === right.disabledReason && left.shortcuts.length === right.shortcuts.length && left.shortcuts.every((shortcut, index) => shortcut === right.shortcuts[index]) ); } unknownCommandWarning [VariableDeclaration] (from packages/plugin/commands/src/contract.ts): unknownCommandWarning = (id: CommandId, known: Iterable): string => `no command "${ id} "${ didYouMean(id, known)} : it shows as neither visible nor enabled` unregisteredCommand [VariableDeclaration] (from packages/plugin/commands/src/contract.ts): unregisteredCommand = (id: CommandId): ResolvedCommand => ({ id, label: id, shortcuts: [], enabled: false, active: false, pressable: false, visible: false, categories: [], } )