Class: FSubmenu
This is the builder for add a menu that can contains submenus to Univer. You shall
never construct this class by yourself. Instead, call createSubmenu
of FUniver to
create a instance.
Please notice that until the appendTo
method is called, the menu item is not added to the UI.
Extends
FMenuBase
Methods
addSeparator()
addSeparator(): this
Add a separator to the submenu.
Returns
this
The FSubmenu itself for chaining calls.
addSubmenu()
addSubmenu(submenu): this
Add a menu to the submenu. It can be a FMenu or a FSubmenu.
Parameters
Parameter | Type | Description |
---|---|---|
submenu | FMenu | FSubmenu | Menu to add to the submenu. |
Returns
this
The FSubmenu itself for chaining calls.
appendTo()
appendTo(path): void
Append the menu to any menu position on Univer UI.
Parameters
Parameter | Type | Description |
---|---|---|
path | string | …[] | Some predefined path to append the menu. The paths can be an array, or an array joined by ` |
Returns
void
Example
// This menu item will appear on every `contextMenu.others` section.
univerAPI.createMenu({
id: 'custom-menu-id-1',
title: 'Custom Menu 1',
action: () => {},
}).appendTo('contextMenu.others');
// This menu item will only appear on the `contextMenu.others` section on the main area.
univerAPI.createMenu({
id: 'custom-menu-id-2',
title: 'Custom Menu 2',
action: () => { console.log(123); },
}).appendTo(['contextMenu.mainArea', 'contextMenu.others']);
Inherited from
FMenuBase.appendTo