【发布时间】:2015-04-29 05:54:58
【问题描述】:
我正在使用一个编辑器编辑器,它使用几个默认按钮和一些插件按钮(例如“fontfamily”、“fontcolor”、“fontsize”)。我想重新排序按钮,以便可以将插件按钮放置在默认按钮之前(即左侧)。编辑器 API 似乎不支持此功能。我该怎么做?
【问题讨论】:
标签: redactor redactor.js
我正在使用一个编辑器编辑器,它使用几个默认按钮和一些插件按钮(例如“fontfamily”、“fontcolor”、“fontsize”)。我想重新排序按钮,以便可以将插件按钮放置在默认按钮之前(即左侧)。编辑器 API 似乎不支持此功能。我该怎么做?
【问题讨论】:
标签: redactor redactor.js
您需要编辑插件代码,这是一个非常基本的插件示例:
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');
【讨论】: