ckeditor5-elements / ElementSelectable
Class: ElementSelectable
Makes elements selectable as a whole, which is what CKEditor's widgets do, without them: it does not change the view of the element, and does not need the Widget plugin. The elements are matched by name or by a filter function, and they are the elementSelectable editor config option:
elementSelectable: ['callout', 'divider', element => element.hasAttribute('card')];An element is selected (the model selection is on it, and the view has a fake selection and the ck-elements-selected class):
- By a click on the element. An element that has content, e.g. a container, is selected by a click on the element itself, not on its content: a click in its text puts the cursor there, as it does without the plugin. An element with no content (an object) is selected by a click anywhere in it.
- By the left and right arrow keys: when the next step of the cursor enters or passes a selectable element (at the end of a block, or before an inline element), the key selects it instead. With an element selected, the arrow keys move the cursor to the content after (right, down) or before (left, up) it, or select the next selectable element, if it is just there.
- By the Esc key: with the cursor in an element, it selects the closest selectable one around the cursor, unless something else handles Esc first, e.g. closes a balloon.
A selected element is deleted, replaced by typing and copied, as any selected content.
Names are made selectable in the model schema (isSelectable), so the selection on them is kept: a filter cannot, so the elements it matches must be selectable already (e.g. objects). Features can add elements with ElementSelectable#add.
Extends
Constructors
Constructor
new ElementSelectable(editor): ElementSelectable;Parameters
| Parameter | Type |
|---|---|
editor | Editor |
Returns
ElementSelectable
Inherit Doc
Inherited from
Plugin.constructor
Accessors
pluginName
Get Signature
get static pluginName(): "ElementSelectable";Returns
"ElementSelectable"
Methods
add()
add(...matchers): void;Makes more elements selectable, as the elementSelectable option does: a name of a model element, or a filter. Used by features that add elements, e.g. the element schema.
Parameters
| Parameter | Type |
|---|---|
...matchers | ElementMatcher[] |
Returns
void
afterInit()
afterInit(): void;Returns
void
init()
init(): void;Returns
void
isSelectable()
isSelectable(element): boolean;Returns whether the element can be selected by this plugin: it matches a name or a filter.
Parameters
| Parameter | Type |
|---|---|
element | ModelElement |
Returns
boolean