添加按钮到Drupal ckeditor

时间:2016-10-05 19:48:07

标签: drupal ckeditor

我刚刚学习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');
        }
  });
})();

0 个答案:

没有答案