Skip to content

CommandItem

CommandItem is the definition of a custom menu, tool or shortcut, and is applied to the following interfaces:

  • pixso.setTopTools(tools: Tool[]): void
  • pixso.setBottomTools(tools: Tool[]): void
  • pixso.stickyToolbar.open(tools: Tool[]): void
  • pixso.setContextMenus(menus: ContextMenuItem[]): void
  • pixso.setShortcuts(shortcuts: ShortcutItem[]): void
typescript
interface CommandItem = {
  label: string;
  value: string;
  disabled?: boolean;
  description?: string;
  icon?: string | Uint8Array; // svg string or image binary data. PS: When iconUrl also exists, icon data will be used first.
  iconUrl?: string;
  children: Array<CommandItem>
};

type CommandItemWithoutIcon = Omit<CommandItem, "icon" | "iconUrl">;

type SeparatorItem = {
  separator: true;
};

ToolItem

typescript
type ToolItem =
  | SeparatorItem
  | (CommandItem & {
      children?: Array<ToolItem>;
    });

ContextMenuItem

typescript
type ContextMenuItem =
  | SeparatorItem
  | (CommandItemWithoutIcon & {
      children?: Array<ContextMenuItem>;
    });

ShortcutItem

typescript
type SubShortcutItem = CommandItemWithoutIcon & {
  children?: Array<SubShortcutItem>;
};

type ShortcutItem = CommandItem & {
  children?: Array<SubShortcutItem>;
};