Skip to content

ckeditor5-elements / ElementMenu

Class: ElementMenu ​

Shows menus in a balloon: the menu of an element, built from commands, submenus and separators (see open), or any view, e.g. the quick insert search (see show).

The element context menu, the breadcrumbs and quick insert show their menus with it. The menu of an element is CKEditor's dropdown menu (see ElementMenuView).

Executing an item closes the menu. Esc and clicking outside close it too; Esc returns the focus to the editor, or to ElementMenuShowOptions.returnFocusTo.

Extends ​

Constructors ​

Constructor ​

ts
new ElementMenu(editor): ElementMenu;

Parameters ​

ParameterType
editorEditor

Returns ​

ElementMenu

Inherit Doc ​

Inherited from ​

Plugin.constructor

Properties ​

view ​

ts
view: 
  | FocusableView
  | null = null;

The view in the open menu, if any.

Accessors ​

pluginName ​

Get Signature ​

ts
get static pluginName(): "ElementMenu";
Returns ​

"ElementMenu"


requires ​

Get Signature ​

ts
get static requires(): readonly [typeof ContextualBalloon, typeof Notification];
Returns ​

readonly [typeof ContextualBalloon, typeof Notification]

Methods ​

destroy() ​

ts
destroy(): void;

Returns ​

void

Inherit Doc ​

Overrides ​

Plugin.destroy


hide() ​

ts
hide(): void;

Hides the open menu, if any.

Returns ​

void


init() ​

ts
init(): void;

Returns ​

void


open() ​

ts
open(
   element, 
   target, 
   config, 
   __namedParameters?
): boolean;

Opens the menu of the element next to the target (e.g. a button, or a DOMRect in viewport coordinates), with the items from the config callback. The menu closes when the element is removed.

Returns false when there are no items.

Parameters ​

ParameterType
elementModelElement
targetRectSource
configElementMenuConfig
__namedParameters?ElementMenuShowOptions

Returns ​

boolean


show() ​

ts
show(
   view, 
   target, 
   __namedParameters?
): void;

Shows the view (e.g. a menu) next to the target (e.g. a button, or a DOMRect in viewport coordinates), and focuses it. The menu closes when the view, or an item of CKEditor's dropdown menu in it, fires execute.

Parameters ​

ParameterType
viewFocusableView
targetRectSource
__namedParameters?ElementMenuShowOptions

Returns ​

void