Skip to main content

CommandManager

from v9.3

CommandManager is a shared command registry for shortcuts, widgets, and host automation surfaces. It stores command metadata separately from command handlers so UI surfaces can list commands without receiving the raw implementations.

Import​

import {
CommandManager,
commandManager,
type CommandDefinition,
type CommandDescriptor
} from '@deck.gl-community/panels';

Usage​

const manager = new CommandManager();

const unregister = manager.registerCommand({
id: 'view.reset',
label: 'Reset view',
description: 'Reset the current viewport.',
do: () => resetView()
});

manager.executeCommand('view.reset');
unregister();

Automation​

Commands default to exposure: 'user'. Use exposure: 'automation' or exposure: 'all' when a host automation surface should be able to execute a command through executeCommandAsync.

manager.registerCommand({
id: 'selection.clear',
label: 'Clear selection',
exposure: 'all',
do: () => clearSelection()
});

Remarks​

  • listCommands({exposure: 'user'}) includes user commands and commands with exposure: 'all'.
  • executeCommandAsync validates command exposure and optional argument schemas before invoking a command.
  • installAutomation records host-provided automation surfaces for docs or application-specific command help surfaces.