4
votes

Not sure if any of you have done this or not, but wanted to put some feelers out there.

I have a TinyMce editor (in an MVC3 view) which a user can basically create an email "template" in. In addition, I have another textarea without TinyMce.

I want to be able to copy the plain text from the TinyMce to the textarea (it will be the "plain-text" version of the email). I've seen some js to strip out the code, but I'd like to take the links ( tags) and copy the URLs out as well.

Let me know if you have any questions! I greatly appreciate any help you may be able to give!

2

2 Answers

1
votes

What you need here is to get the content first, strip out some of the contents, and then put it in your textarea. This is not that difficult:

  1. var content = tinymce.get('my_editor_id').getContent({format : 'raw', no_events : 1});
  2. Use the function strip_tags descibed here to strip out unwanted tags

// keep p,div and br tags in this example content = strip_tags( content,'<p><div><br>');

  1. document.getElementsById('my_textarea').innerHTML = content;
0
votes

I don't suppose $("#TinyMceContainer").text() works?