问题
Is it possible to have basic styles(like bold, italic, underline, etc) in right click context menu?
回答1:
Of course, it is. Firstly, you have to add context menu group and items. For example,
editor.addMenuGroup('basicstyles', 1);
editor.addMenuItems( {
'bold': {
label: 'Make it bold!',
command: 'bold',
group: 'basicstyles'
} // add here more buttons like this
} );
Next, you need to add context menu listeners.Simply, it looks like:
editor.contextMenu.addListener( function( element, selection ) {
return {
bold: CKEDITOR.TRISTATE_OFF // , anotherCommand:CKEDITOR.TRISTATE_OFF, etc
}
} );
Done! You'll need to get some more complicated logic for listeners. See plugin.js
code in clipboard
plugin for example.
来源:https://stackoverflow.com/questions/24316207/ckeditor-possible-to-have-context-menu-for-basic-styles