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:
- 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
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
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
1 Answer
Reset to default 3Using 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
版权声明:本文标题:javascript - How to allow HTML tags with TinyMCE paste plugin? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744997723a2636778.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论