Couim
Couim

Reputation: 747

tinyMCE get the current selected HTML element

I've an editor in which I can select text and display it by the following code :

alert(tinyMCE.activeEditor.selection.getContent({format : "html"}));

the issue is the function returns only text and not HtmlElement. So I can't see, for example, the node which encapsulate this selected text. I would like to get the content but by an HtmlElement to deal with nodes.

Any suggestions ?

Upvotes: 4

Views: 7043

Answers (1)

Michael Fromin
Michael Fromin

Reputation: 13726

Take a look at getNode():

tinymce.activeEditor.selection.getNode();

The API calls available on a selection are documented here: https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.dom.selection/#getNode

Upvotes: 5

Related Questions