How to add a plugin to CKeditor with a package ?

Permalink 2 users found helpful
5.7 use a nice way to add plugin to redactor but what about CKEditor ? HOw to updgrade my package ?

View Replies: View Best Answer
mnakalay replied on at Permalink Best Answer Reply

First, you put your plugin somewhere in your package. Personally, I put it in js/plugins/pluginHandle.

Then you add a file register.js inside the folder just next to the plugin.js file

In that file you add:

if (typeof CKEDITOR !== 'undefined') {
    CKEDITOR.plugins.addExternal('pluginHandle', CCM_REL + '/packages/package_folder/js/plugins/pluginHandle/');

Then, in your package's controller, you need to activate the plugin.
You need those libraries:
use Concrete\Core\Editor\Plugin;
use Concrete\Core\Asset\AssetList as AssetList;
use \Concrete\Core\Support\Facade\Application as Application;

Then put this code in the on_start() function:
$app = Application::getFacadeApplication();
$editor = $app->make('editor');
$pluginManager = $editor->getPluginManager();
$al = AssetList::getInstance();
$al->register('javascript', 'editor/ckeditor4/pluginHandle',  'js/plugins/pluginHandle/register.js', array(), 'package_handle');
$al->registerGroup('editor/ckeditor4/pluginHandle', array( array('javascript', 'editor/ckeditor4/pluginHandle')));
$plugin = new Plugin();
$plugin->setName('Plugin Name');
if (!$pluginManager->isAvailable($plugin)) {
if (!$pluginManager->isSelected($plugin)) {
    $key = $plugin->getKey();

Make sure you replace all instances of 'PluginHandle' with your actual plugin handle and 'Plugin Name' with the plugin name and 'package_handle' with the package handle.
It should work.
sebastienj replied on at Permalink Reply
Wow ! Thanks for this quick and complete reply. I will try it !