首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未显示CKeditor 4插件按钮

未显示CKeditor 4插件按钮
EN

Stack Overflow用户
提问于 2017-12-08 20:13:09
回答 1查看 458关注 0票数 0

我有一个可以工作的扩展插件(myplugin),它扩展了drupalimagecaption插件,扩展了drupalimage,扩展了原始图片插件。现在我想给myplugin插件添加一个额外的工具栏按钮。下面是我尝试添加的方法:

代码语言:javascript
复制
(function (CKEDITOR) {

  'use strict';

  CKEDITOR.plugins.add('myplugin', {
    icons: 'drupalimage,DoubleImage',
    requires: 'drupalimagecaption',
    hidpi: true,

    beforeInit: function (editor) {
      // [...] Here are some overwrites

      var imageSaveCallback = function (data) {
        editor.fire('saveSnapshot');
        var content = data.image_render;
        editor.insertHtml(content);
        editor.fire('saveSnapshot');
      };

      // Implementation before initializing plugin.
      editor.addCommand('InsertDoubleImage', {
        canUndo: true,
        exec: function (editor, data) {
          Drupal.ckeditor.openDialog(editor,
            Drupal.url('mydrupalmodule/dialog/double_image/' + editor.config.drupal.format),
            {},
            imageSaveCallback,
            {}
          );
        }
      });

      // Register the toolbar button.
      if (editor.ui.addButton) {
        editor.ui.addButton('DoubleImage', {
          label: Drupal.t('Upload Double Image'),
          command: 'InsertDoubleImage'
        });
      }
    }
  });

})(CKEDITOR);

我的主要问题是,为什么这个按钮没有出现在drupal的管理UI中,所以我不能添加到CKeditor的工具栏中。我还有一个PHP类,它加载这个文件(这个脚本所在的位置),我还在那里定义了new和current按钮:

代码语言:javascript
复制
public function getButtons() {
  return [
    'DrupalImage' => array(
      'label' => t('Single Image Popup'),
      'image' => drupal_get_path('module', 'mydrupalmodule') . '/js/plugins/elevation/icons/drupalimage.png',
    ),
    'DoubleImage' => array(
      'label' => t('Double Image Popup'),
      'image' => drupal_get_path('module', 'mydrupalmodule') . '/js/plugins/elevation/icons/DoubleImage.png',
    ),
  ];
}

实际上我不知道我错过了什么,我也找不到为什么不想工作……(仅覆盖有效,但按钮不显示...)如果你覆盖了一个现有的插件就不能添加新的按钮?

EN

回答 1

Stack Overflow用户

发布于 2017-12-08 22:04:06

好了,我找到问题了。如果我想在Drupal8中为CKeditor创建一个插件,我需要扩展CKEditorPluginBase,而不是PluginBase类。它们在DrupalImageCaption类(我将其用作基类)中扩展了PluginBase,但这在我的示例中不起作用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47714194

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档