【问题标题】:customer button ckeditor Cannot set property 'name' of undefined客户按钮 ckeditor 无法设置未定义的属性“名称”
【发布时间】:2022-03-03 23:01:42
【问题描述】:

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

在我的 plugin.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”。 但在那之后我得到“未捕获的类型错误:无法设置未定义的属性'名称'”

这个名字指的是哪里?

【问题讨论】:

    标签: javascript ckeditor


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2019-01-31
      • 2021-08-03
      • 2019-06-23
      • 2019-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-27
      相关资源
      最近更新 更多