Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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();
share|improve this answer
    
Thanks Bainternet! –  Shaan Sep 26 '11 at 21:38
    
And just for ppl to note, you can replace the selected content using tinyMCE.activeEditor.selection.setContent('<div>sample content</div>'); –  Shaan Sep 27 '11 at 2:26
    
So, you could use this as a replacement to send_to_editor, could you not? –  Manny Fleurmond Mar 20 '13 at 14:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.