如何在编校编辑器工具栏中默认按钮的左侧添加插件按钮



我正在使用一个编校编辑器,它使用几个默认按钮和许多插件按钮(例如'fontfamily'、'fontcolor'、'fontsize')。我想对按钮重新排序,以便插件按钮可以放置在默认按钮之前(即左侧)。这似乎不受编校器 API 的本机支持。我该怎么做?

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

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/

但是要在开始时添加,您需要首先添加:

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

最新更新