zazvorniki
zazvorniki

Reputation: 3602

Tinymce paste includes styles

I have a tinymce form and it's working for the most part, but when I copy something from either the internet or a word processor and try and paste it in, the inline styles stay with it.

I have tried to solve this a few ways already, but have had no luck. It seems like this style tag is haunting me!

I would just remove the style tag altogether, and I did try this, but when I do that nullifies the styles you can add in the tinymce, such as text align...and I don't really want to do that.

This is what I have at the moment, you can see I was trying to remove the styles on paste, but it's just not working. Some help would be much appreciated!

tinyMCE.init({
mode : "exact",
elements : "wStory",
plugins : "paste",
theme: "advanced",
width: "80em",
height: "700px",
paste_auto_cleanup_on_paste : true,
paste_remove_styles: true,
paste_remove_styles_if_webkit: true,
paste_strip_class_attributes: true,
theme_advanced_buttons1:"bold,italic,underline,strikethrough,hr,|,justifyleft,justifycenter,justifyright,justifyfull,outdent, indent,|,cleanup,|,forecolor, |,undo,redo,|,link, unlink",
theme_advanced_toolbar_location:"top",
theme_advanced_toolbar_align:"center",
theme_advanced_resizing:false,
width:"100%",height:"700px",
invalid_elements: "span, div",
theme_advanced_path:false,
setup : function(ed) {
    ed.onInit.add(function(ed) {
    ed.pasteAsPlainText = true;
});
},

});

Upvotes: 2

Views: 4536

Answers (2)

Akash Kadam
Akash Kadam

Reputation: 11

init={{
  menubar: false,
  plugins: "lists advlist paste",
  toolbar: "bullist numlist",
  contenteditable: edit,
  entity_encoding: "raw",
  paste_webkit_styles: "none",
  paste_remove_styles_if_webkit: true,
}}

it removes styles when copy paste.

Upvotes: 1

zazvorniki
zazvorniki

Reputation: 3602

For some odd reason, nothing I did work in the latest tinymce. I hope this helps someone else who runs into this

  cleanup_on_startup : true,
  fix_list_elements : false,
  fix_nesting : false,
  fix_table_elements : false,
  paste_use_dialog : true,
  paste_auto_cleanup_on_paste : true,

I had to paste these in the init function. This allows for it to post plain text and then when the user places styles like centering it adds a paragraph tags around the specified text

Upvotes: 2

Related Questions