Type Editor / @type-editor/menu / menubar/MenuItem / MenuItem
Class: MenuItem
Defined in: packages/menu/src/menubar/MenuItem.ts:15
An icon or label that, when clicked, executes a command.
Implements
Constructors
Constructor
ts
new MenuItem(spec): MenuItem;Defined in: packages/menu/src/menubar/MenuItem.ts:23
Create a menu item.
Parameters
| Parameter | Type | Description |
|---|---|---|
spec | MenuItemSpec | The spec used to create this item. |
Returns
MenuItem
Accessors
spec
Get Signature
ts
get spec(): MenuItemSpec;Defined in: packages/menu/src/menubar/MenuItem.ts:27
Returns
Methods
render()
ts
render(
view,
showLabel?,
isLegacy?,
parentMenuElement?): {
dom: HTMLElement;
update: (state) => boolean;
};Defined in: packages/menu/src/menubar/MenuItem.ts:42
Renders the menu element according to its display spec, and adds an event handler which executes the command when the representation is clicked.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
view | PmEditorView | undefined | The editor view instance |
showLabel | boolean | false | Whether to show the label (if applicable) |
isLegacy | boolean | false | Backward compatibility mode |
parentMenuElement? | ParentMenuElement | undefined | The parent menu element to notify of updates of child elements (especially in dropdown menus) |
Returns
ts
{
dom: HTMLElement;
update: (state) => boolean;
}An object containing the DOM element and an update function
| Name | Type | Defined in |
|---|---|---|
dom | HTMLElement | packages/menu/src/menubar/MenuItem.ts:54 |
update() | (state) => boolean | packages/menu/src/menubar/MenuItem.ts:54 |