Skip to content

ckeditor5-elements / ElementQuickInsert

Class: ElementQuickInsert ​

Opens a menu with a search field and the elements allowed at the selection, on Alt+Enter (Option+Enter on macOS; see ElementQuickInsertConfig.keystroke). Choosing an element inserts it with the quickInsert command.

The menu is shown by the ElementMenu plugin. The quickInsertBefore and quickInsertAfter commands (see QuickInsertPositionCommand) open it for the position before or after an element; list them in the elementContextMenu config, e.g. as an "Insert" submenu.

The menu closes when the document changes while it is open, so it never inserts at an outdated position.

Extends ​

Constructors ​

Constructor ​

ts
new ElementQuickInsert(editor): ElementQuickInsert;

Parameters ​

ParameterType
editorEditor

Returns ​

ElementQuickInsert

Overrides ​

Plugin.constructor

Accessors ​

pluginName ​

Get Signature ​

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

"ElementQuickInsert"


requires ​

Get Signature ​

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

readonly [typeof ElementMenu]

Methods ​

getItems() ​

ts
getItems(elementOrPosition?): QuickInsertItem[];

Returns the elements that can be inserted at the target (a position, the position before an element, or the selection), with their labels.

Parameters ​

ParameterType
elementOrPosition?ElementOrPosition

Returns ​

QuickInsertItem[]


hasItems() ​

ts
hasItems(elementOrPosition?): boolean;

Whether an element can be inserted at the target (a position, the position before an element, or the selection), as getItems lists them: it stops at the first one, e.g. for whether a command is enabled.

Parameters ​

ParameterType
elementOrPosition?ElementOrPosition

Returns ​

boolean


init() ​

ts
init(): void;

Returns ​

void


open() ​

ts
open(elementOrPosition?, domTarget?): boolean;

Opens the menu for inserting at the target (a position, the position before an element, or the selection), next to the given DOM target. By default, the menu is next to the element, or the selection.

Returns false when nothing can be inserted at the target because it cannot be edited, or there is nothing to show the menu next to.

Parameters ​

ParameterType
elementOrPosition?ElementOrPosition
domTarget?RectSource

Returns ​

boolean