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:
- Allow to copy/paste HTML text or Word/OpenOffice text with most styles and formatting attributes
- 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