I already have a custom TinyMCE button that returns the selected text using

var selected = tinyMCE.activeEditor.selection.getContent();

However, when a user creates a WordPress “link” like this…

link

…and the user selects the “Link” text, my selected variable will only contain the word “Link”. What I need it to contain is the entire <a>, with the src and target and everything, so that I can parse it and inject a shortcode instead.

I have already tried .getContent({format: 'raw'}); and the result is the same.

How can I get TinyMCE to give me the selected underlying markup as well?

1 Answer
1

I was able to do what I wanted to do by using .getNode() instead.

Leave a Reply

Your email address will not be published. Required fields are marked *