Skip to content

Type Editor


Type Editor / @type-editor/menu / types/MenuElement / MenuElement

Interface: MenuElement

Defined in: packages/menu/src/types/MenuElement.ts:10

The types defined in this module aren't the only thing you can display in your menu. Anything that conforms to this interface can be put into a menu structure.

Methods

render()

ts
render(
   view,
   showLabel?,
   isLegacy?,
   parentMenuElement?): {
  dom: HTMLElement;
  update: (state) => boolean;
};

Defined in: packages/menu/src/types/MenuElement.ts:24

Render the element for display in the menu. Must return a DOM element and a function that can be used to update the element to a new state. The update function must return false if the update hid the entire element.

Parameters

ParameterTypeDescription
viewPmEditorViewThe editor view instance
showLabel?booleanWhether to show the label (if applicable, e.g. in DropdownMenu)
isLegacy?booleanBackward compatibility mode
parentMenuElement?ParentMenuElementThe 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/types/MenuElement.ts:24
update()(state) => booleanpackages/menu/src/types/MenuElement.ts:24