Page tree
Skip to end of metadata
Go to start of metadata

RELEASE 2.11.0 OR ABOVE

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:

If selection is not specified
var elements = editor.getHTMLElements();
console.log(elements[0].innerHTML);
If selection is specified
var selection = editor.getSelection();
var elements = editor.getHTMLElements(selection);
console.log(elements[0].innerHTML);
  • No labels