Returns an array of HTML Elements based on Selection. If no Selection is specified, returns the HTML Element corresponding to the current Selection.


Parameters:

Name

Type

Attribute

Description

selectionObject

Object

{
    anchor: { Position },
    focus:  { Position }
}

[ Optional ] A selection object with an anchor position and a focus position. If this value is not present, it operates based on the current selection.

Return:

TypeDescription
HTML Element[]An array of HTML Elements corresponding to Selection. In the caret state, the HTML Element where the caret is located is returned as an array.



Example:

var elements = editor.getHTMLElements();
console.log(elements[0].innerHTML);


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