Skip to content

Instantly share code, notes, and snippets.

@manoj-apare
Last active July 9, 2016 23:37
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 manoj-apare/4b87a52ddd19e70f6a5ea88722fe7cc9 to your computer and use it in GitHub Desktop.
Save manoj-apare/4b87a52ddd19e70f6a5ea88722fe7cc9 to your computer and use it in GitHub Desktop.
(function ($, Drupal, CKEDITOR) {
var myPluginSaveCallback = function(data) {
var content = data.image_render;
insertContent(content);
};
CKEDITOR.plugins.add('myplugin', {
icons: 'imagepopup',
hidpi: true,
beforeInit: function (editor) {
// Implementation before initializing plugin.
editor.addCommand( 'editmyplugin', {
canUndo: true,
exec: function (editor, data) {
// Populate existing values of form.
var existingValues = {};
// Open dialog form.
Drupal.ckeditor.openDialog(editor,
Drupal.url('my_module/dialog/image/' + editor.config.drupal.format),
existingValues,
myPluginSaveCallback,
{}
);
}
});
editor.ui.addButton('MyPlugin', {
label: Drupal.t('My plugin'),
// Note that we use the original image2 command!
command: 'editmyplugin'
});
insertContent = function(html) {
editor.insertHtml(html);
}
},
});
})(jQuery, Drupal, CKEDITOR);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment