如何 运行 Ckeditor 中的插件无需点击

how to run a plugin in Ckeditor without click

我正在尝试 运行 ckeditor 插件 "showblocks" 使用几种不同的问答方法,但没有任何效果。有谁知道如何在不点击的情况下 运行 插件?

CKEDITOR.tools.callFunction(199, this);
CKEDITOR.instances['editor1'].execCommand('show blocks');

命令的名称是"showblocks",不是"show blocks"(字与字之间没有space)。

CKEDITOR.instances['editor1'].execCommand('showblocks');

编辑:阅读您的评论后,您试图在 ckeditor 加载时自动执行 showblocks,但在 ckeditor 完全加载并准备好进行交互之前,您无法执行此操作。此外,配置选项称为 startupOutlineBlocks。您有 3 个选项。

第一个选项(使用 startupOutlineBlocks 全局启用 showblocks):

CKEDITOR.config.startupOutlineBlocks = true;

第二个选项(为特定实例启用显示块):

CKEDITOR.replace('editor1', {
    startupOutlineBlocks: true
});

第三个选项(在 ckeditor 使用 instanceReady 事件完全加载后执行 showblocks 命令):

CKEDITOR.replace('editor1', {
    on: {
        instanceReady: function(evt) {
            this.execCommand('showblocks');
        }
    }
});

如果您启用了更好的第一个或第二个选项,则不需要第三个选项。