Ckeditor 如何在编辑器内联中隐藏工具栏

Ckeditor 如何在编辑器内联中隐藏工具栏,ckeditor,Ckeditor,我有一个应用程序需要内联编辑器,但没有工具栏。对于内嵌编辑器部分,我有: CKEDITOR.disableAutoInline = true; var editor = CKEDITOR.inline('editable', {on: { instanceReady: function() {periodic();} }}); var periodic = (function() { var data, oldData; return function() {

我有一个应用程序需要内联编辑器,但没有工具栏。对于内嵌编辑器部分,我有:

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.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);
    };
})();

我发现另一个链接似乎解决了我的问题: 脚本似乎工作正常,但我仍然不确定它是否是一种正确的方式:

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

在我看来,我通过两种方式做到了这一点:

1使用removePlugins选项,只需删除工具栏即可:

在这里,您还可以使用allowedContent来允许ACF的内容

CKEDITOR.inline( 'editable', {
    removePlugins: 'toolbar',
    allowedContent: 'p h1 h2 strong em; a[!href]; img[!src,width,height];'
} );
2使用CSS-不是标准方法:有点棘手

只需将css设置为在工具栏上显示:无,如

.cke_inner {
    display: none;
}

希望它能帮助别人。

在我看来,我用两种方式来做:

1使用removePlugins选项,只需删除工具栏即可:

在这里,您还可以使用allowedContent来允许ACF的内容

CKEDITOR.inline( 'editable', {
    removePlugins: 'toolbar',
    allowedContent: 'p h1 h2 strong em; a[!href]; img[!src,width,height];'
} );
2使用CSS-不是标准方法:有点棘手

只需将css设置为在工具栏上显示:无,如

.cke_inner {
    display: none;
}
希望它能帮助别人。

我更新了答案,解释没有工具栏时没有配置高级内容筛选器,所以你需要手动执行此操作。我更新了答案,解释没有工具栏时没有配置高级内容筛选器,所以你需要手动执行此操作。