We are trying to add a custom dropdown to CKeditor that will have a list of pre-set values we will find and replace, for the life of me, I cannot find a simple way to do this. Looking at TinyMCE it is very easy:
http://www.tinymce.com/tryit/menubutton.php
Is there a simple solution like this for CKEditor, we would rather not have to swap CKeditor out for TinyMCE just for this feature. I found a plugin called PlaceHolder but that doesn't quite do what we want and to be honest, I was hoping to do this without plugins and just configure on initialization the way TinyMCE does.
Many thanks for any insight.
It's all about 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' );
}
} );
}
}
} );
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