2013-05-29 77 views
2

我有一个需要内嵌CKEditor但没有工具栏的应用程序。对于内嵌CKEditor的一部分,我有:如何在CKEditor中嵌入工具栏

CKEDITOR.disableAutoInline = true; 
var editor = CKEDITOR.inline('editable', {on: { 
    instanceReady: function() {periodic();} 
}}); 

var periodic = (function() { 
    var data, oldData; 
    return function() { 
     if ((data = editor.getData()) !== oldData) { 
      oldData = data; 
      $.post("update.php", {txt:data}); 
     } 
     setTimeout(periodic, 1000); 
    }; 
})(); 

然后在工具栏的隐藏部分,我发现这个:CKEditor 4 Inline: How to hide toolbar on demand?

//Whenever CKEditor loses focus, We will hide the corresponding toolbar DIV. 
function hideToolBarDiv(event) { 
    // Select the correct toolbar DIV and hide it. 
    //'event.editor.name' returns the name of the DIV receiving focus. 
    $('#'+event.editor.name+'TBdiv').hide(); 
} 

问题是,我不知道如何将这两个结合在一起:)我欣赏任何提示。谢谢。

+0

可能重复[我可以使用没有工具栏的CKEditor?](http://stackoverflow.com/questions/13611386/can-i-use-ckeditor-without-a-toolbar) – Reinmar

+0

我更新了我的答案在http://stackoverflow.com/ questions/13611386/can-i-use-ckeditor-without-a-toolbar解释高级内容过滤器没有配置没有工具栏,因此您需要手动执行此操作。 – Reinmar

回答

4

我发现,似乎解决我的问题,另一个链接:Can I use CKEditor without a toolbar? 脚本似乎是正常的工作,虽然我仍然不知道这是否是一个正确的方式来做到这一点:的

CKEDITOR.disableAutoInline = true; 
var editor = CKEDITOR.inline('editable', { 
    removePlugins: 'toolbar', 
    allowedContent: 'p h1 h2 strong em; a[!href]; img[!src,width,height]' 
    on: {instanceReady: function() {periodic();}} 
}); 

var periodic = (function() { 
    var data, oldData; 
    return function() { 
     if ((data = editor.getData()) !== oldData) { 
      oldData = data; 
      $.post("update.php", {txt:data}); 
     } 
     setTimeout(periodic, 1000); 
    }; 
})();