Aravinthan M
Aravinthan M

Reputation: 885

Tiny MCE Editor Selection Issue in Angular

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

enter image description here enter image description here

Upvotes: 0

Views: 176

Answers (1)

Tiny Lincoln
Tiny Lincoln

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

Related Questions