【问题标题】:How do you add plugin buttons to the left of the default buttons in a redactor editor's toolbar?如何在编辑器编辑器工具栏中的默认按钮左侧添加插件按钮?
【发布时间】:2015-04-29 05:54:58
【问题描述】:

我正在使用一个编辑器编辑器,它使用几个默认按钮和一些插件按钮(例如“fontfamily”、“fontcolor”、“fontsize”)。我想重新排序按钮,以便可以将插件按钮放置在默认按钮之前(即左侧)。编辑器 API 似乎不支持此功能。我该怎么做?

【问题讨论】:

    标签: redactor redactor.js


    【解决方案1】:

    您需要编辑插件代码,这是一个非常基本的插件示例:

    if (!RedactorPlugins) var RedactorPlugins = {};
    
    RedactorPlugins.custombutton = function()
    {
        return {
            init: function()
            {
                var button = this.button.add('custom-button', 'Add Button');
                this.button.addCallback(button, this.custombutton.show);
            },
            show: function()
            {
                console.log('myplugin show');
        };
    };
    

    您需要调整这一行(如下),它将在 init 方法中。

    var button = this.button.add('custom-button', 'Add Button');
    

    this.button.add 默认在工具栏末尾插入按钮。你可以在这里阅读更多关于其他选项的信息http://imperavi.com/redactor/docs/api/button/

    但要在开始时添加,您将需要 addFirst:

    var button = this.button.addFirst('custom-button', 'Add Button');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-15
      • 2011-07-28
      • 2022-01-05
      相关资源
      最近更新 更多