I created a module that uses a jQuery syntax highlighting plugin. In that module I worked out how to create a custom button in ckeditor that inserts a pre tag, this all works fine. Can anyone tell me the proper way to add more than just one button.
Here is the code so far:
.module
<?php
/**
* Implementation of hook_ckeditor_plugin().
*/
function wa_syntaxhighlight_ckeditor_plugin() {
return array('syntax' => array(
'name' => 'syntax',
'desc' => t('Plugin for inserting Syntax Highlighting tags.'),
'path' => drupal_get_path('module', 'wa_syntaxhighlight') .'/plugins/syntax/',
'buttons' => array(
'Syntax' => array(
'icon' => 'images/icon.png',
'label' => 'Syntax',
),
),
));
}
?>
plugin.js
/**
* @file Plugin for inserting Syntax Highlighting tags.
*/
( function() {
CKEDITOR.plugins.add( 'syntax',
{
requires : [ 'styles', 'button' ],
init : function( editor )
{
var addButtonCommand = function( commandName, styleDefiniton )
{
var style = new CKEDITOR.style( styleDefiniton );
editor.attachStyleStateChange( style, function( state ) {
!editor.readOnly && editor.getCommand( commandName ).setState( state );
});