1

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 1

2

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();
2
  • And just for ppl to note, you can replace the selected content using tinyMCE.activeEditor.selection.setContent('<div>sample content</div>');
    – Shaan
    Commented 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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