Copy text (plain text) from tinymce to textarea

Not sure if any of you did this or not, but wanted some of them to be there.

I have a TinyMce editor (in the MVC3 view) that the user can basically create an “email template" for. In addition, I have another text box without TinyMce.

I want to be able to copy plain text from TinyMce into a text box (this will be a text version of the email). I saw some js to cross out the code, but I would like to take the links (tags) and copy the urls. Also

Let me know if you have any questions! I am very grateful for any help you can give!

+4
source share
2 answers

What you need is to first get the content, cut out some of the content, and then put it in the text box. It is not so difficult:

  • var content = tinymce.get('my_editor_id').getContent({format : 'raw', no_events : 1});
  • Use the strip_tags descibed function here to cut 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;
+1
source

I do not assume that $ ("# TinyMceContainer"). does text () work?

0
source

Source: https://habr.com/ru/post/1394124/


All Articles