ckeditor5-elements / ElementContextMenu
Class: ElementContextMenu
Shows the menu of an element when the user right-clicks it, or opens the context menu with the keyboard (the menu key, or Shift+F10) while the cursor is in it.
The items come from the elementContextMenu editor config option only (see ElementMenuConfig): commands, submenus and '|' separators. Without it, or when it returns no items for an element, the native context menu shows. The menu itself is shown by the ElementMenu plugin.
Extends
Constructors
Constructor
new ElementContextMenu(editor): ElementContextMenu;Parameters
| Parameter | Type |
|---|---|
editor | Editor |
Returns
ElementContextMenu
Inherit Doc
Inherited from
Plugin.constructor
Accessors
pluginName
Get Signature
get static pluginName(): "ElementContextMenu";Returns
"ElementContextMenu"
requires
Get Signature
get static requires(): readonly [typeof ElementMenu];Returns
readonly [typeof ElementMenu]
Methods
getModelElement()
getModelElement(viewElement):
| ModelElement
| null;Returns the closest model element mapped to the given view element or its ancestors, skipping the root.
Parameters
| Parameter | Type |
|---|---|
viewElement | ViewElement |
Returns
| ModelElement | null
init()
init(): void;Returns
void
open()
open(element, target): 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 elementContextMenu config option.
Returns false when there are no items, so the caller can let the native context menu show instead.
Parameters
| Parameter | Type |
|---|---|
element | ModelElement |
target | RectSource |
Returns
boolean
openAtSelection()
openAtSelection(): boolean;Opens the menu of the element at the selection (the selected element, or the element with the cursor), next to the selection.
Returns false when there is no such element or no items.
Returns
boolean