我刚刚学习Drupal并想在CKEditor上添加一个按钮 . 我尝试了一些技巧,但我永远无法看到一个新按钮 . 这是我到目前为止的模块 .

任何人都可以告诉我为什么这段代码不起作用?


这是除了包括的文件之外的其他文件的列表:

  • image.png(/sites/all/modules/excel_to_html/images/image.png) - 图标

  • excel_to_html.info(/sites/all/modules/excel_to_html/excel_to_html.info)

excel_to_html.module

位置:/sites/all/modules/excel_to_html/excel_to_html.module

<?php
function excel_to_html_ckeditor_plugin() {
  return array(
        'plugin_name' => array(
            'name' => 'excel_to_html',
            'desc' => t('Plugin description'),
            'path' =>  drupal_get_path('module', 'excel_to_html')  .'/plugins/excel_to_html/',
            'buttons' => array(
                array('label' => 'Button label', 'icon' => '/images/image.png'),
            )
        )
    );
}

plugin.js

位置:/sites/all/modules/excel_to_html/plugins/excel_to_html/plugin.js

(function() {
  CKEDITOR.plugins.add('excel_to_html', 
  {
        icons: 'images/image.png',

        init: function(editor) 
        {
          editor.addCommand('excel_convert', 
          {
              exec : function(editor) 
              {
                alert('testing button!');
                //var selected_text = editor.getSelection().getSelectedText();
              }
          });
          editor.ui.addButton('excel_to_html', 
          {
            label: 'Convert Excel to table',
            command: 'excel_convert',
            icon: this.path + 'images/image.png'
          });
        },
        afterInit: function (editor) 
        {
            alert('done');
        }
  });
})();