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…
…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?