2013-02-14 132 views
1

我正在使用内联编辑器ipweditor工具,它在内部使用tinyMCE编辑器。在他们的演示页面上,它使用旧版本的tinyMCE,它不在我的IE中工作。所以我更新了tinyMCE的最新版本。TinyMCE返回无HTML内容

在老版本的TinyMCE中,它将所有HTML标签返回给我定义的内容,而在新版本中,它仅向我返回没有HTML标签的文本。 以下是jsFiddle demo的链接。任何人都知道我应该如何配置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' 
    }); 
}); 

回答

5

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

var r =options.editor.getContent({format : 'text'}); 

我们需要“HTML”

var r =options.editor.getContent({format : 'html'}); 

它更优选使该格式设置也动态的,所以添加在inital设置的设置变量,并从中获取价值,以取代“文本”。

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}); 
1

您可以使用content.previousHere是一个修改小提琴。

+0

确实'content.pervious'显示带有HTML标签的文本,但是我想用所有HTML标签编辑文本'content.current'。 – Nehal 2013-02-14 11:40:22

+0

看起来像ipweditor不支持(或需要特别配置 - 检查文档)。解决这个问题的另一种方法是在提交之前使用tinymce编辑器命令(当ipweditor提交被调用时,编辑器对象不见了!)。 – Thariama 2013-02-14 12:43:44

+1

@Tharima:是的,问题出在ipweditor上。它在内部创建tinyMCE的另一个对象,并以“文本”格式获取内容,需要用“html”替换它。 – Nehal 2013-02-14 13:58:38