Is it possible to create a drop down style menu consisting of toolbar buttons?
I want to have a button on the toolbar which groups the alignment buttons (and possibly others) into a drop down menu.
Thanks
The problem is not that hard but still you got to write a couple lines of code. The following logic inside pluginsLoaded
can (should) be defined in init
of a totally new plugin (which could be called "groupped-justify"). Otherwise, if executed too late, e.g. after toolbar was generated, the whole code makes no sense.
See the official plugin development guide to know more.
Also see the jsFiddle with a working example.
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;
}
} );
}
}
} );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With