TinyMCE返回没有HTML的内容

Neh*_*hal 2 javascript wysiwyg tinymce

我正在使用内联编辑器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>
Run Code Online (Sandbox Code Playgroud)

使用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'
    });
});
Run Code Online (Sandbox Code Playgroud)

Neh*_*hal 8

在插件库中进行任何修改总是不可取的,但这确实需要一些修改.问题在于'ipweditor.js'工具.它在内部创建新的tinyMCE编辑器对象,并从tinyMCE以"文本"格式获得响应.

var r =options.editor.getContent({format : 'text'});
Run Code Online (Sandbox Code Playgroud)

我们需要用'html'替换'text'

var r =options.editor.getContent({format : 'html'});
Run Code Online (Sandbox Code Playgroud)

最好使此格式设置也是动态的,因此在初始设置中附加设置变量并从那里获取值.

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);
Run Code Online (Sandbox Code Playgroud)

现在使用设置中定义的格式进行检索.

var r =options.editor.getContent({format : options.format});
Run Code Online (Sandbox Code Playgroud)