@@ -54,14 +54,74 @@ export default {
5454 } ,
5555 /**
5656 * Show a ContextMenu in page, same as `this.$contextmenu`
57+ *
58+ * For example:
59+ *
60+ * ```ts
61+ * onContextMenu(e : MouseEvent) {
62+ * //prevent the browser's default menu
63+ * e.preventDefault();
64+ * //show your menu
65+ * ContextMenu.showContextMenu({
66+ * x: e.x,
67+ * y: e.y,
68+ * items: [
69+ * {
70+ * label: "A menu item",
71+ * onClick: () => {
72+ * alert("You click a menu item");
73+ * }
74+ * },
75+ * {
76+ * label: "A submenu",
77+ * children: [
78+ * { label: "Item1" },
79+ * { label: "Item2" },
80+ * { label: "Item3" },
81+ * ]
82+ * },
83+ * ]
84+ * });
85+ * }
86+ * ```
87+ *
88+ * You can pass customSlots to custom rendering this menu.
89+ *
90+ * For example, custom rendering #itemRender and #separatorRender:
91+ * ```ts
92+ * ContextMenu.showContextMenu({
93+ * ...
94+ * } as MenuOptions, {
95+ * //Use slot in function mode
96+ * itemRender: ({ disabled, label, icon, showRightArrow, onClick, onMouseEnter }) => [ h('div', {
97+ * class: 'my-menu-item'+(disabled?' disabled':''),
98+ * onMouseenter: onMouseEnter,
99+ * onClick: onClick,
100+ * }, [
101+ * icon ? h('img', { src: icon }) : h('div', { class: 'icon-place-holder' }),
102+ * h('span', label),
103+ * showRightArrow ? h('span', { class: 'right-arraw' }, '>>') : h('div'),
104+ * ]) ],
105+ * separatorRender: () => [ h('div', { class: 'my-menu-sperator' }) ]
106+ * })
107+ * ```
108+ *
57109 * @param options The options of ContextMenu
58110 * @param customSlots You can provide some custom slots to customize the rendering style of the menu. These slots are the same as the slots of component ContextMenu.
59111 * @returns Menu instance
60112 */
61113 showContextMenu ( options : MenuOptions , customSlots ?: Record < string , Slot > ) : ContextMenuInstance {
62114 return $contextmenu ( options , customSlots ) ;
63115 } ,
64- //Close the currently open menu
116+ /**
117+ * Get if there is a menu open now.
118+ */
119+ isAnyContextMenuOpen ( ) {
120+
121+ } ,
122+ /**
123+ * Close the currently open menu
124+ */
65125 closeContextMenu,
66126 //Tools
67127 transformMenuPosition,
0 commit comments