Skip to content

ckeditor5-elements / ElementToolbar

Class: ElementToolbar ​

Shows floating toolbars for elements, configured by the elementToolbar editor config option (see ElementToolbarDefinition): the toolbar of the closest element at the selection that matches, next to it, while the editor is focused. When toolbars match nested elements, the toolbar of the innermost one shows.

The toolbars are CKEditor's widget toolbars (WidgetToolbarRepository), as the image and table toolbars: they are placed and hidden by CKEditor, and Alt+F10 focuses them. Unlike widget toolbars, they show for any element, also when the selection is inside it, and their command buttons act on that element: "Move up" in the toolbar of a note moves the note, not the paragraph with the cursor.

Extends ​

Constructors ​

Constructor ​

ts
new ElementToolbar(editor): ElementToolbar;

Parameters ​

ParameterType
editorEditor

Returns ​

ElementToolbar

Inherit Doc ​

Inherited from ​

Plugin.constructor

Accessors ​

pluginName ​

Get Signature ​

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

"ElementToolbar"


requires ​

Get Signature ​

ts
get static requires(): readonly [typeof WidgetToolbarRepository];
Returns ​

readonly [typeof WidgetToolbarRepository]

Methods ​

afterInit() ​

ts
afterInit(): void;

Registers the toolbars, after the other plugins registered their commands and components.

Returns ​

void


getElement() ​

ts
getElement(element): 
  | ModelElement
  | null;

Returns the closest element at the selection that matches: the selected element, or the innermost element with the selection, or one of their ancestors. Never a root.

Parameters ​

ParameterType
elementElementMatcher

Returns ​

| ModelElement | null