这一切都与editor.ui.addRichCombo
(JSFiddle)有关:
CKEDITOR.replace( 'editor', {
toolbarGroups: [
{ name: 'mode' },
{ name: 'basicstyles' }
],
on: {
pluginsLoaded: function() {
var editor = this,
config = editor.config;
editor.ui.addRichCombo( 'my-combo', {
label: 'My Dropdown Label',
title: 'My Dropdown Title',
toolbar: 'basicstyles,0',
panel: {
css: [ CKEDITOR.skin.getPath( 'editor' ) ].concat( config.contentsCss ),
multiSelect: false,
attributes: { 'aria-label': 'My Dropdown Title' }
},
init: function() {
this.startGroup( 'My Dropdown Group #1' );
this.add( 'foo', 'Foo!' );
this.add( 'bar', 'Bar!' );
this.startGroup( 'My Dropdown Group #2' );
this.add( 'ping', 'Ping!' );
this.add( 'pong', 'Pong!' );
},
onClick: function( value ) {
editor.focus();
editor.fire( 'saveSnapshot' );
editor.insertHtml( value );
editor.fire( 'saveSnapshot' );
}
} );
}
}
} );