Skip to content

ckeditor5-elements / getElementAtSelection

Function: getElementAtSelection() ​

ts
function getElementAtSelection(selection): 
  | ModelElement
  | null;

Returns the element at the selection: the selected element (e.g. an image), or the element with the cursor, i.e. the parent of the start of the selection. Never a root: null when the selection is directly in one.

Parameters ​

ParameterType
selection| ModelSelection | ModelDocumentSelection

Returns ​

| ModelElement | null