ThreePipe
    Preparing search index...

    Interface ViewerAction

    An action: a command that a person runs from a key, a toolbar, a menu or a command palette. A plugin defines it once and registers it with viewer.actions.register (ViewerActions.register); a UI lists and runs it.

    interface ViewerAction {
        capture?: boolean;
        group?: string;
        icon?: string;
        id: string;
        label: string;
        priority?: number;
        repeat?: boolean;
        shortcut?: string | string[];
        enabled?(): boolean;
        run(): void | ViewerActionResult | Promise<void | ViewerActionResult>;
    }
    Index
    capture?: boolean

    The key runs before the handlers of the element with the focus (in the capture phase on the window), and the key stops there. For a key of an open card that must win over a key of the canvas: the arrows of an open annotation over the arrow keys of the camera controls. It runs only while the focus is in the viewer (its canvas, a card in its container) or on the page, so a focused panel (a list) keeps its keys. Default: false, a focused element has its keys first.

    group?: string

    A group for a UI, like 'Edit' or 'Camera' (ViewerActions.list)

    icon?: string

    An icon for a UI: an SVG string, or the name of an icon of the UI

    id: string

    Unique id, like 'undo' or 'editorCamera.toggleEditing'. A new action with the same id replaces the old one.

    label: string

    The name in a menu or a tooltip

    priority?: number

    When two enabled actions have the same key, the one with the higher priority runs (then the one registered last). Default: 0. An action that ends a mode (Escape that ends the pivot edit) is above one that acts on the selection (Escape that clears it).

    repeat?: boolean

    A held key runs the action again on each repeat of the key. Default: false, the action runs once per press.

    shortcut?: string | string[]

    The key, like 'Mod+Z' (Mod: Cmd on a Mac, Ctrl on other platforms), 'Shift+D' or 'Delete', or a list of keys that run it (['Delete', 'Backspace']). See parseShortcut and matchShortcut. An app changes it with ViewerActions.setShortcut.

    • The action can run now. Default: always. A key of a disabled action is left to other handlers.

      Returns boolean