admin管理员组

文章数量:1406328

I was wondering that I couldn't find a solution to this problem, after searching several hours.

I want two modes in my almighty TinyMCE editor:

  1. Allow to copy/paste HTML text or Word/OpenOffice text with most styles and formatting attributes
  2. Enable by default the paste plug-in and remove most of the HTML, but allow simple formatting.

I am able to copy/paste HTML text or Word/OpenOffice text with most styles. Also the paste plug-in button is enabled by default.

However I am not sure how to configure the paste plug-in to allow some HTML Tags, particular lists (ol, ul, li), line breaks (br) and simple formatting (b, i, u), if the paste plug-in button was clicked.

I tried to modify the paste_postprocess and paste_preprocess function, but did not find a solution. Also configuring valid_elements does not brought me success.

My settings (the important parts):

plugins : "paste,tabfocus,table,safari",
paste_auto_cleanup_on_paste : true,
paste_create_paragraphs: false,
paste_create_linebreaks : false,
paste_postprocess : function(pl, o) { },
paste_preprocess : function(pl, o) { },
paste_remove_spans:true,
paste_remove_styles:true,
paste_remove_styles_if_webkit:true,
paste_retain_style_properties:"none",
paste_strip_class_attributes:"all",
paste_text_sticky:true,
convert_urls : false,
entity_encoding : "raw",
valid_elements : "em/i,strong/b,ol,ul,li,br",
force_br_newlines : true,
force_p_newlines : false,
forced_root_block : false,
invalid_elements : "font",
setup : function(ed) {
  ed.onInit.add(function(ed) {
    ed.pasteAsPlainText = true; // select "paste" on startup
  });
},
verify_html : false

I was wondering that I couldn't find a solution to this problem, after searching several hours.

I want two modes in my almighty TinyMCE editor:

  1. Allow to copy/paste HTML text or Word/OpenOffice text with most styles and formatting attributes
  2. Enable by default the paste plug-in and remove most of the HTML, but allow simple formatting.

I am able to copy/paste HTML text or Word/OpenOffice text with most styles. Also the paste plug-in button is enabled by default.

However I am not sure how to configure the paste plug-in to allow some HTML Tags, particular lists (ol, ul, li), line breaks (br) and simple formatting (b, i, u), if the paste plug-in button was clicked.

I tried to modify the paste_postprocess and paste_preprocess function, but did not find a solution. Also configuring valid_elements does not brought me success.

My settings (the important parts):

plugins : "paste,tabfocus,table,safari",
paste_auto_cleanup_on_paste : true,
paste_create_paragraphs: false,
paste_create_linebreaks : false,
paste_postprocess : function(pl, o) { },
paste_preprocess : function(pl, o) { },
paste_remove_spans:true,
paste_remove_styles:true,
paste_remove_styles_if_webkit:true,
paste_retain_style_properties:"none",
paste_strip_class_attributes:"all",
paste_text_sticky:true,
convert_urls : false,
entity_encoding : "raw",
valid_elements : "em/i,strong/b,ol,ul,li,br",
force_br_newlines : true,
force_p_newlines : false,
forced_root_block : false,
invalid_elements : "font",
setup : function(ed) {
  ed.onInit.add(function(ed) {
    ed.pasteAsPlainText = true; // select "paste" on startup
  });
},
verify_html : false
Share Improve this question edited Jan 16, 2017 at 8:59 Richard 4,4157 gold badges38 silver badges58 bronze badges asked Apr 22, 2013 at 9:50 malisokanmalisokan 5,4673 gold badges22 silver badges19 bronze badges 1
  • My TinyMCE Version: 3.4.9. All Tests on Windows XP with Firefox 20. – malisokan Commented Apr 22, 2013 at 14:21
Add a ment  | 

1 Answer 1

Reset to default 3

Using the paste config setting paste_preprocess you may filter the ining content and only keep the tags you want to keep. Have a closer look here: TinyMCE Paste As Plain Text

本文标签: javascriptHow to allow HTML tags with TinyMCE paste pluginStack Overflow