Javascript CKEditor 4的下拉工具栏按钮
是否可以创建由工具栏按钮组成的下拉式菜单 我想在工具栏上有一个按钮,用于将对齐按钮(可能还有其他按钮)分组到下拉菜单中Javascript CKEditor 4的下拉工具栏按钮,javascript,jquery,drop-down-menu,ckeditor,toolbar,Javascript,Jquery,Drop Down Menu,Ckeditor,Toolbar,是否可以创建由工具栏按钮组成的下拉式菜单 我想在工具栏上有一个按钮,用于将对齐按钮(可能还有其他按钮)分组到下拉菜单中 谢谢问题没那么难,但你还是得写几行代码。pluginsload中的以下逻辑可以(应该)在全新插件的init中定义(可以称为“groupped justify”)。否则,如果执行得太晚,例如,在生成工具栏之后,整个代码将毫无意义 请参阅以了解更多信息 另请参见带有工作示例的 CKEDITOR.replace( 'editor', { plugins: 'wysiwygar
谢谢问题没那么难,但你还是得写几行代码。
pluginsload
中的以下逻辑可以(应该)在全新插件的init
中定义(可以称为“groupped justify”)。否则,如果执行得太晚,例如,在生成工具栏之后,整个代码将毫无意义
请参阅以了解更多信息
另请参见带有工作示例的
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;
}
} );
}
}
} );
我有@oleq建议的相同代码。在我的例子中,我需要在plugininit上使用它们,因此无法显示菜单项,因为items对象中的“command”导致了一个错误。我不知道为什么会发生这种情况,但我设法通过删除命令并向每个项添加onClick事件来修复它
items.flleft = {
label: "Add and align left",
group: 'some_group',
icon: this.path + 'icons/imgtemplate_left.png',
order: 1,
onClick: function(){
// Do stuff on menu item clicked
}
};
希望这有帮助非常感谢oleq。你为我节省了很多时间。Micheal接受这一正确答案。