CommandItem
CommandItem 为自定义菜单、工具或快捷方式的定义,应用于以下接口:
pixso.setTopTools(tools: Tool[]): voidpixso.setTopLeftTools(tools: Tool[]): voidpixso.setBottomTools(tools: Tool[]): voidpixso.stickyToolbar.open(tools: Tool[]): voidpixso.setContextMenus(menus: ContextMenuItem[]): voidpixso.setShortcuts(shortcuts: ShortcutItem[]): void
typescript
// 菜单项
type CommandItem = {
label: string;
value: string;
disabled?: boolean;
description?: string;
icon?: string | Uint8Array; // svg字符串 或 图片二进制数据。PS:iconUrl也存在时,优先使用icon数据
iconUrl?: string;
size?: number; // 图标尺寸,仅 top-left 工具支持
tippy?: {
showOnCreate?: boolean; // 是否创建后默认展示 tooltip,仅 top-left 工具支持
maxWidth?: number; // tooltip 最大宽度,仅 top-left 工具支持
placement?: "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end"; // tooltip 位置,默认 "bottom",仅 top-left 工具支持
};
guide?: {
// 常驻引导气泡,仅 top-left 工具支持
// 开启后以 PxGuideCard 形式锚定在工具图标上,不会自动消失
// 仅在用户点击关闭按钮或点击工具图标时关闭,关闭后不做持久化
enabled: boolean;
title?: string; // 标题
content?: string; // 正文内容,缺省时使用 label
closeText?: string; // 关闭按钮文案,默认「我知道了」
};
};
// 不携带图标的菜单项
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>;
};