10

I've installed and configured the WYSIWYG module (latest dev) to use CKEditor, and I have downloaded the latest version of CKEditor (latest full release) to sites/all/libraries. I'm able to use the editor.

I need to customize a few additional things, so I'm applying configuration changes to config.js in sites/all/libraries/ckeditor/config.js. However, it seems like this file is not even being used or read at all. I tested this hypothesis by adjusting the stock config.js as so:

CKEDITOR.editorConfig = function( config ) {
    // Define changes to default configuration here. For example:
    config.allowedContent = true;
    alert('Hello!');
};

alert('World!');

Whenever I load the editor, I would expect to get either one or two alerts, one saying either Hello! or World! or both. However, no alert windows are launched.

How does one customize the configuration of CKEditor when using the WYSIWYG module?

3 Answers 3

13

This took some research, but I found this article which describes how to do it.

The meat of the article is the following hook, which defines a custom config file:

<?php
/**
 * Implements hook_wysiwyg_editor_settings_alter()
 */
function MODULENAME_wysiwyg_editor_settings_alter(&$settings, $context)
{
    // The $context variable contains information about the wysiwyg profile we're using
    // In this case we just need to check that the editor being used is ckeditor
    if ($context['profile']->editor == 'ckeditor')
    {

        // The $settings variable contains all the config options ckeditor uses. 
        // The array keys correspond directly with any setting that can be applied 
        // to CKEditor - as outlined in the CKEditor docs: 
        // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html 
        // Another way to override configuration is to use your own configuration javascript
        // file. In this case, we're going to add our own configuration file that will
        // Hold our stylesSet customizations... 
        $settings['customConfig'] = base_path() . drupal_get_path('module', 'MODULENAME') . '/ckeditor_custom_config.js';
    }
}
2
  • This worked perfectly for me. The problem is that you require an additional custom module to actually config CKEditor. Once you do this, it works just fine and you have full control over CKEditor. Commented Sep 18, 2015 at 18:14
  • This works partly for me. Not all settings in the ckeditor_custom_config.js are honoured, but some are. Others work if you put them straight into the modules function $settings variable. Confusing.
    – commonpike
    Commented Jul 14, 2017 at 10:24
-1

I had a similar problem, and it turns out that CKEditor was caching the config.js file. Not even pressing control-F5 would solve that: I had to delete the cache manually from the browser's setting.

Hope this helps someone =)

1
  • It shouldn't have been cached if you disabled aggregation of JS files in /admin/config/development/performance and cleared your cache there as well. Hope this helps stop someone from making 100 different files for 100 different commits. Commented Sep 18, 2015 at 18:16
-3

All you need to do is to edit /sites/all/modules/ckeditor/ckeditor.config.js instead of ckeditor/config.js file.

2
  • 3
    You shouldn't be hacking contrib modules. Especially without information around providing a patch (if it is a bug fix, which this is not.) drupal.org/node/1054616
    – Christian
    Commented Sep 24, 2014 at 0:19
  • 1
    WYSIWYG version doesn't live there anyway.
    – circusdei
    Commented Aug 25, 2016 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.