Skip to content

Type Editor


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

ParameterTypeDescription
specMenuItemSpecThe 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

MenuItemSpec

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

ParameterTypeDefault valueDescription
viewPmEditorViewundefinedThe editor view instance
showLabelbooleanfalseWhether to show the label (if applicable)
isLegacybooleanfalseBackward compatibility mode
parentMenuElement?ParentMenuElementundefinedThe 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

NameTypeDefined in
domHTMLElementpackages/menu/src/menubar/MenuItem.ts:54
update()(state) => booleanpackages/menu/src/menubar/MenuItem.ts:54

Implementation of

MenuElement.render