【发布时间】:2014-10-07 08:47:16
【问题描述】:
我有一个关于将一些 CkEditor 工具栏选项分组到下拉菜单的问题。例如,如果我将此选项 ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'] 添加到工具栏,我会得到 4 个按钮。由于我认为这是工具栏中的浪费空间,因此我想将所有 4 个选项放到下拉列表中 - 只有 1 个(选中)可见。
这可能吗?我找到了这个解决方案
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;
}
} );
}
}
} );
在http://jsfiddle.net/oleq/vmYCF/ 上,但正如您所看到的,现在我有两个选项 - 4 个按钮 + 下拉菜单,所以这对我来说是不可接受的。而且在那种情况下,我无法设置其他工具栏(我不知道为什么不这样做)。
感谢您的帮助
最好的问候
【问题讨论】:
-
你有没有想过这个问题?
标签: javascript drop-down-menu ckeditor toolbar