客户按钮 ckeditor 无法设置未定义的属性“名称”

customer button ckeditor Cannot set property 'name' of undefined

本文关键字:属性 名称 未定义 设置 按钮 ckeditor 客户      更新时间:2023-09-26

这是我第一次使用ckeditor,我正在尝试做一个自定义按钮。

在我的插件中.js:

CKEDITOR.plugins.add('save-post',
{
    init: function (editor) {
    var pluginName = "save-post";
    //CKEDITOR.dialog.add(pluginName, this.path + 'dialogs/save-post.js');
    editor.addCommand(pluginName, SaveBlogPost());
    editor.ui.addButton('save-post',
    {
        label: 'save-post',
        command: pluginName
    });
  }
});

这是另一个js文件:

function SaveBlogPost() {
    console.log("SAVEBLOGPOST");
 };

控制台在创建编辑器实例时写出"SAVEBLOGPOST"。但是在那之后我得到"未捕获的类型错误:无法设置未定义的属性'名称'"

这个名字指的是哪里?

"addCommand" 方法需要一个命令定义作为第二个参数。您可以在此处找到文档和工作示例:http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-addCommand