Skip to content

Instantly share code, notes, and snippets.

@vkareh
Forked from kevinchampion/ckeditor.api.php
Created March 12, 2013 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vkareh/5146128 to your computer and use it in GitHub Desktop.
Save vkareh/5146128 to your computer and use it in GitHub Desktop.
/**
* Hook to register the CKEditor plugin - it would appear in the plugins list on the profile setting page.
*/
function hook_ckeditor_plugin() {
return array(
'plugin_name' => array(
// Name of the plugin used to write it.
'name' => 'plugin_name',
// Description of the plugin - it would be displayed in the plugins management section of profile settings.
'desc' => t('Plugin description'),
// The full path to the CKEditor plugins directory, with the trailing slash.
'path' => drupal_get_path('module', 'my_module') . '/plugin_dir/',
'buttons' => array(
'button_name' => array(
'icon' => 'path to button icon',
'label' => 'Button Label',
)
)
)
);
}
CKEDITOR.plugins.load=CKEDITOR.tools.override(CKEDITOR.plugins.load,function(b){var c={};return function(a,f,e){var d={},g=function(a){b.call(this,a,function(a){CKEDITOR.tools.extend(d,a);var b=[],k;for(k in a){var m=a[k],l=m&&m.requires;if(!c[k]){if(m.icons)for(var j=m.icons.split(","),q=0;q<j.length;q++)CKEDITOR.skin.addIcon(j[q],m.path+"icons/"+j[q]+".png");c[k]=1}if(l){l.split&&(l=l.split(","));for(m=0;m<l.length;m++)d[l[m]]||b.push(l[m])}}if(b.length)g.call(this,b);else{for(k in d){m=d[k];if(m.onLoad&&
!m.onLoad._called){m.onLoad()===false&&delete d[k];m.onLoad._called=1}}f&&f.call(e||window,d)}},this)};g.call(this,a)}});CKEDITOR.plugins.setLang=function(b,c,a){var f=this.get(b),b=f.langEntries||(f.langEntries={}),f=f.lang||(f.lang=[]);f.split&&(f=f.split(","));CKEDITOR.tools.indexOf(f,c)==-1&&f.push(c);b[c]=a};CKEDITOR.ui=function(b){if(b.ui)return b.ui;this.items={};this.instances={};this.editor=b;this._={handlers:{}};return this};
/**
* Implements hook_ckeditor_plugin().
*/
function media_crop_ckeditor_plugin() {
return array(
'media_crop_ckeditor' => array(
// Name of the plugin used to write it.
'name' => 'Media Crop',
// Description of the plugin - it would be displayed in the plugins management section of profile settings.
'desc' => t('Plugin for manual cropping of media embedded images.'),
// The full path to the CKEditor plugins directory, with the trailing slash.
'path' => drupal_get_path('module', 'media_crop') . '/plugins/media_crop_ckeditor/',
'buttons' => array(
'button_name' => array(
'icon' => 'plugin.png',
'label' => 'Media crop',
)
)
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment