So I understand that the visual editor uses something called TinyMCE. How do I retrieve the html that the user selects from the visual editor? I am basically trying to create a button that gets the selected html and replaces it.
1 Answer
The visual editor (TinyMCE) has its own API and since its a JavaScript Based editor you can get the selection using JavaScript very easily
tinyMCE.activeEditor.selection.getContent();
-
And just for ppl to note, you can replace the selected content using tinyMCE.activeEditor.selection.setContent('<div>sample content</div>');– ShaanCommented Sep 27, 2011 at 2:26
-
So, you could use this as a replacement to
send_to_editor
, could you not? Commented Mar 20, 2013 at 14:42