Last active
July 9, 2016 23:37
-
-
Save manoj-apare/4b87a52ddd19e70f6a5ea88722fe7cc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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