Skip to content

ckeditor5-elements / ElementMenuView

Class: ElementMenuView ​

The menu of an element: CKEditor's dropdown menu (DropdownMenuRootListView), built from commands, submenus and separators.

CKEditor builds the menu and handles it: the nested menus (opened on click, hover, or the right arrow; placed where they fit), the keyboard, and right-to-left languages. This view only connects the buttons to the commands: they reflect the command title, icon and state for the target, and execute the command for it. It also adds the separators, which CKEditor's menu definitions do not have.

Missing items are skipped, and submenus without items, and separators at the start or the end, or repeated ones. Submenus are enabled when one of their items is. Right-clicking the menu does not open the native context menu.

Extends ​

Constructors ​

Constructor ​

ts
new ElementMenuView(
   locale, 
   bodyCollection, 
   items, 
   target
): ElementMenuView;

Parameters ​

ParameterType
localeLocale
bodyCollectionBodyCollection
itemsreadonly ( | ElementMenuItem | null | undefined)[]
targetElementOrPosition

Returns ​

ElementMenuView

Overrides ​

DropdownMenuRootListView.constructor

Properties ​

isEmpty ​

ts
readonly isEmpty: boolean;

Whether the menu has no items: all were missing.


target ​

ts
readonly target: ElementOrPosition;

The element or position the commands are executed for.

Methods ​

render() ​

ts
render(): void;

Renders the menu: CKEditor builds it from the definitions; then the buttons are connected to the commands, and the separators are added.

Returns ​

void

Overrides ​

DropdownMenuRootListView.render