getHTMLElements

Release 2.11.0+

Returns an array of HTML elements covered by selection. If selection is omitted, uses the current selection.

Parameters

NameTypeDescription
[selection]object(Optional) { anchor: Position, focus: Position } — if omitted, the current selection is used.

Returns

TypeDescription
HTMLElement[]Array of HTML elements within the selection

Example

// Without explicit selection
var elements = editor.getHTMLElements();
console.log(elements[0].innerHTML);

// With explicit selection
var selection = editor.getSelection();
var elements = editor.getHTMLElements(selection);
console.log(elements[0].innerHTML);