是否可以创建由工具栏按钮组成的下拉式菜单?
我想在工具栏上有一个按钮,它将对齐按钮(可能还有其他按钮)分组到一个下拉菜单中。
谢谢
最佳答案
问题并不难,但您仍然需要编写几行代码。 pluginsLoaded
中的以下逻辑可以(应该)在一个全新插件(可以称为“groupped-justify”)的init
中定义。否则,如果执行得太晚,例如生成工具栏后,整个代码没有任何意义。
参见 official plugin development guide了解更多。
另见 jsFiddle有一个工作示例。
CKEDITOR.replace( 'editor', {
plugins: 'wysiwygarea,sourcearea,basicstyles,toolbar,menu,menubutton,justify',
on: {
pluginsLoaded: function() {
var editor = this,
items = {};
editor.addMenuGroup( 'some_group' );
items.justifyleft = {
label: editor.lang.justify.left,
group: 'some_group',
command: 'justifyleft',
order: 1
};
items.justifyright = {
label: editor.lang.justify.right,
group: 'some_group',
command: 'justifyright',
order: 2
};
editor.addMenuItems( items );
editor.ui.add( 'Groupped', CKEDITOR.UI_MENUBUTTON, {
label: 'Groupped justify',
// Disable in source mode.
modes: {
wysiwyg: 1
},
icon: 'JustifyLeft',
onMenu: function() {
var active = {};
// Make all items active.
for ( var p in items )
active[ p ] = CKEDITOR.TRISTATE_OFF;
return active;
}
} );
}
}
} );
关于javascript - CKEditor 4 的下拉工具栏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22629143/