【问题标题】:Add a custom button to CKEditor向 CKEditor 添加自定义按钮
【发布时间】:2012-04-26 05:09:58
【问题描述】:

您好,我想在 drupal 中为 CKEditor 添加一个自定义按钮。我创建了一个插件,但它没有显示在我的 ckeditor 工具栏中。有人能帮我吗?代码如下

插件.js

CKEDITOR.plugins.add('newplugin',
{
    init: function(editor)
    {
        var pluginName = 'newplugin';
        CKEDITOR.dialog.add(pluginName, this.path + 'plugin.js');
        editor.addCommand(pluginName, new CKEDITOR.dialogCommand(pluginName));
        editor.ui.addButton('Newplugin',
            {
                label: 'Footnote or Citation',
        icon: this.path + 'newplugin.png',
                command: pluginName
            });
    }
});

config.js
CKEDITOR.editorConfig = function( config )
{


config.extraPlugins = 'newplugin';
config.toolbar = [
['Bold'],['Italic'],['newplugin']
]
};

【问题讨论】:

  • Drupal 使用...CKEditor? 编辑: 啊... YUI 富编辑器
  • 感谢您的回复。是的,它使用了 CKEditor

标签: jquery drupal-7 ckeditor


【解决方案1】:

您使用的是所见即所得的模块吗?如果是这样,您必须创建一个实现所见即所得挂钩的模块,以将按钮添加到配置中。这可以使用以下代码完成:

function yourtheme_wysiwyg_plugin($editor, $version) {
    switch ($editor) {
        return array(
            'PluginName' => array(
                'path' => "Path to plugin directory",
                'filename' => 'plugin.js',
                'buttons' => array(
                    'Newplugin' => t('New Plugin'),
                ),
                'load' => TRUE,
                'internal' => FALSE,
            ),
        );
        break;
    }
}

然后将主题上传到 Drupal 并清除缓存。该按钮现在应该出现在 WYSIWYG 管理页面上的按钮列表中,您可以在其中选中复选框并启用该按钮。

【讨论】:

    猜你喜欢
    • 2015-12-19
    • 2011-06-09
    • 2018-01-31
    • 1970-01-01
    • 2022-10-07
    • 1970-01-01
    • 2010-11-11
    • 2011-10-18
    • 1970-01-01
    相关资源
    最近更新 更多