CommandItem
CommandItem
为自定义菜单、工具或快捷方式的定义,应用于以下接口:
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
// 菜单项
type CommandItem = {
label: string;
value: string;
disabled?: boolean;
description?: string;
icon?: string | Uint8Array; // svg字符串 或 图片二进制数据。PS:iconUrl也存在时,优先使用icon数据
iconUrl?: string;
};
// 不携带图标的菜单项
type CommandItemWithoutIcon = Omit<CommandItem, "icon" | "iconUrl">;
// 分割线
type SeparatorItem = {
separator: true;
};
ToolItem
type ToolItem =
| SeparatorItem
| (CommandItem & {
children?: Array<ToolItem>;
});
ContextMenuItem
type ContextMenuItem =
| SeparatorItem
| (CommandItemWithoutIcon & {
children?: Array<ContextMenuItem>;
});
ShortcutItem
type SubShortcutItem = CommandItemWithoutIcon & {
children?: Array<SubShortcutItem>;
};
type ShortcutItem = CommandItem & {
children?: Array<SubShortcutItem>;
};