我想知道,我找了幾個小時後找到解決這個問題的方法。如何使用TinyMCE粘貼插件允許HTML標籤?
我想在我的全能TinyMCE的編輯兩種模式:
- 允許複製/粘貼HTML文本或Word/OpenOffice的文字與大多數樣式和格式屬性
- 粘貼插件默認啓用,並刪除大部分的HTML,,但允許簡單的格式。
我能夠複製/粘貼大多數樣式的HTML文本或Word/OpenOffice文本。 默認情況下也啓用粘貼插件按鈕。
但是我不知道如何在插件配置糊允許一些HTML標籤,特別列表(OL,UL,LI),換行符(BR)和簡單的格式(B,I,U),如果粘貼插件按鈕被點擊。
我試着修改paste_postprocess
和paste_preprocess
函數,但是沒有找到解決辦法。還配置valid_elements
不會使我成功。
我的設置(重要部件):
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
我的TinyMCE版本:3.4.9。所有在Firefox 20上使用Firefox 20的測試。 – malisokan 2013-04-22 14:21:46