Reputation: 885
I am using TinyMCE editor, while selecting a single tag it returns correct value using this function editor.selection.getNode()
. but when i am selecting two tags data it returns all HTML content from the editor.
Example given below Screenshot
Upvotes: 0
Views: 176
Reputation: 1102
The structure of the content area of the TinyMCE editor is a full DOM tree with <head>
and <body>
elements. (These are usually obscured from the end user unless the Full Page plugin is used.)
As stated in the documentation, .getNode()
returns:
...the currently selected element or the common ancestor element for both start and end of the selection.
With HTML like:
<h1>Heading</h1>
<p>Paragraph text.</p>
the "common ancestor element" for the selection would be the <body>
element that wraps all content in the editor.
Upvotes: 2