我在TinyMCE v3.5.10
中有一些html编码的文字,比如This is a <br/>market
。
我正在尝试提取html以及上述行的等效纯文本。在IE,Firefox和Chrome上,上述行呈现为:
This is a
market
,这与使用tinyMCE.get('inputText').getContent({format: 'text'});
在Firefox上,换行符被删除,我得到的是:This is a market.
,而不是我所期待的。
我对tinyMCE的初始化:
tinymce.init({
selector: "textarea",
plugins : "contextmenu", //,mainMenuBar",//,goToPage",
mode : "textareas",
theme : "advanced",
editor_deselector: "mceNoEditor",
theme_advanced_layout_manager : "SimpleLayout",
//toolbar : false,
//menubar : false, //removes the top menu bar.
//layout items.
theme_advanced_buttons1 : "",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
//theme_advanced_toolbar : false,
theme_advanced_toolbar_location : "external",
theme_advanced_toolbar_align : "left",
statusbar : false,
theme_advanced_statusbar_location : "external",
theme_advanced_resizing : true,
theme_advanced_path : false,
//theme_advanced_buttons1 : "openFile,|,chooseVoice,setReadingMode,setReadingSpeed,|,lookupDictionary,translate,pictureDictionary,|,settings,|,logout",
//theme_advanced_buttons1 : "backToLibrary,|,play,setReadingSpeed,|,lookupDictionary,translate,pictureDictionary,|,pronounce,|,settings,|,moreOptions",
//paste_text_sticky: false,
//paste_text_sticky_default: false,
nowrap : false,
button_tile_map : true,
entity_encoding : "raw",
force_br_newlines : true,
forced_root_block : "", // Needed for 3.x
//valid_elements : "h1,h2,h3,h4,h5,h6,p,br,span[class|title|onmouseover|onmouseout|onclick|style],div[style],img[src|width|height|alt],hr,i",
event_elements : "span",
/*
paste_text_sticky : true,
pasteAsPlainText : true,
paste_auto_cleanup_on_paste : true,
paste_remove_styles: true,
paste_remove_styles_if_webkit: true,
paste_strip_class_attributes: true,
*/
setup: function(editor) {
editor.onInit.add(function(editor) {
editor.pasteAsPlainText = true;
//call function to create custom context (right-click) menu.
console.log("creating custom context menu.");
editor.plugins.contextmenu.onContextMenu.add(createCustomContextMenu);
//create bottom status bar for going to page number.
//goToPagePlugin();
});
}
});
正如您所看到的,我认为这可能是因为paste_as_plain_text
被设置为true,但即使将其评论也似乎没有任何效果。
非常欢迎任何帮助。