[英]TinyMCE return content without HTML
我正在使用內聯編輯器ipweditor工具,該工具在內部使用 tinyMCE 編輯器。 在他們的演示頁面上,它使用的是舊版本的 tinyMCE,它在我的 IE 中不起作用。 所以我用最新版本更新了tinyMCE。
在舊版本的 TinyMCE 中,它返回我定義的所有 HTML 標簽的內容,而在新版本中,它只返回沒有 HTML 標簽的文本。 這是 jsFiddle演示的鏈接。 任何人都知道如何配置 tinyMCE,以便它也返回 HTML 標簽。
HTML
<div style="display:none">
<form method="post" action="somepage">
<textarea name="content" style="width:100%"></textarea>
</form>
</div>
<div style="border: solid thin gray; padding:5px;">
<div class="my_text"><b> <span>Click me! I am editable and WYSIWYG!!!</span></b>
</div>
Javascript
$(document).ready(function () {
var ed = new tinymce.Editor('content', {
mode: "exact",
theme: "advanced",
plugins: "emotions,table",
theme_advanced_toolbar_location: "top",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: true,
theme_advanced_buttons1: "bold,italic,underline,fontselect,fontsizeselect,forecolor,backcolor,|,code,",
theme_advanced_buttons2: "",
theme_advanced_buttons3: "",
table_default_cellspacing: 0,
table_default_border: 1,
remove_linebreaks: false
});
$('.my_text').editable({
type: 'wysiwyg',
editor: ed,
onSubmit: function submitData(content) {
alert(content.current);
},
submit: 'save',
cancel: 'cancel'
});
});
在插件庫中進行任何修改總是不可取的,但這確實需要一些修改。 問題出在“ipweditor.js”工具上。 它正在內部創建新的 tinyMCE 編輯器對象,並從 tinyMCE 以“文本”格式獲取響應。
var r =options.editor.getContent({format : 'text'});
我們需要用 'html' 替換 'text'
var r =options.editor.getContent({format : 'html'});
最好使這種格式設置也是動態的,因此在初始設置中附加一個設置變量並從那里獲取值。
var defaults = {
onEdit: null,
onSubmit: null,
onCancel: null,
editClass: null,
submit: null,
cancel: null,
type: 'text', //text, textarea or select
submitBy: 'blur', //blur,change,dblclick,click
editBy: 'click',
editor: 'non',
options: null,
format:'text'
}
var options = $.extend(defaults, options);
現在使用設置中定義的格式進行檢索。
var r =options.editor.getContent({format : options.format});
您可以使用content.previous
。 這是一個修改過的小提琴。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.