mirror of https://gitee.com/godoos/godoos.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1009 B
1009 B
Customize Contextmenu
How to Use
import Editor from "@hufe921/canvas-editor"
const instance = new Editor(container, <IElement[]>data, options)
instance.register.contextMenuList([
{
key?: string;
isDivider?: boolean;
icon?: string;
name?: string; // Use %s for selection text. Example: Search: %s
shortCut?: string;
disable?: boolean;
when?: (payload: IContextMenuContext) => boolean;
callback?: (command: Command, context: IContextMenuContext) => any;
childMenus?: IRegisterContextMenu[];
}
])
getContextMenuList
Feature: Get context menu list
Usage:
const contextMenuList = await instance.register.getContextMenuList()
Remark:
// Example of modifying internal contextmenu
contextmenuList.forEach(menu => {
// Find the menu item through the menu key and modify its properties
if (menu.key === INTERNAL_CONTEXT_MENU_KEY.GLOBAL.PASTE) {
menu.when = () => false
}
})