3 3 Votes

TinyMCE: Insert Text as Plain Text without any Formatting

Question by Guest | 06/05/2014 at 16:33

When copying some text out of a Word file or an HTML document into my TinyMCE-Editor, the text always contains many formatting such as colors, boxes or tables that should not be taken over.

Of course, it is different when I copy a unformatted text, for example out of a plain text editor.

How can I achieve that even original formatted text will be copied as plain text without any formatting into the TinyMCE-Editor?


Stefan Trost

Show Profile | Message
2Best Answer
2 Votes

TinyMCE is providing a plugin called "paste" that can care about this thing. The property "paste_as_text" should be set to "true".

Here is an example of how to include the plugin:

  selector: "textarea",
  plugins: "paste",
  paste_as_text: true

In your case, also using "paste_word_valid_elements" instead of "paste_as_text" could be helpful. You can use it like that:

  selector: "textarea",
  plugins: "paste",
  paste_word_valid_elements: "h1,h2,h3,b,strong,i,em"

With this property, you can define some HTML tags that are allowed to be taken over from Word. All other elements are removed automatically. So, it is possible, for example, to take over headings or bold words but not every formatting.
06/05/2014 at 17:23

ReplyPositive Negative

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own articles on askingbox.com. How to do.