admin管理员组

文章数量:1391811

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 ?

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 ?

Share Improve this question asked Sep 14, 2017 at 9:44 CouimCouim 7473 gold badges13 silver badges29 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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

本文标签: javascripttinyMCE get the current selected HTML elementStack Overflow