1

How can I set some custom configurations for the CKeditor module? I want to set spell check SCAYT on by default, and a few other things like that. Ideally, I would like to create my own custom config file somewhere sensible that won't be overwritten.

5

Look at hook_wysiwyg_settings_alter

Act on editor profile settings.

This hook is invoked from wysiwyg_get_editor_config() after the JavaScript settings have been generated for an editor profile and before the settings are added to the page. The settings may be customized or enhanced; typically with options that cannot be controlled through Wysiwyg module's administrative UI currently.

Modules implementing this hook to enforce settings that can also be controlled through the UI should also implement hook_form_wysiwyg_profile_form_alter() to adjust or at least indicate on the editor profile configuration form that certain/affected settings cannot be changed.

Additionally this blog post by Fuse Interactive: WYSIWYG MODULE + CKEDITOR: TAMING THE BEAST goes into great depths on how to make use of this hook. From the blog post ...

/**
 * Implements hook_wysiwyg_editor_settings_alter()
 */
function ckeditor_custom_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', 'ckeditor_custom') .
                                '/ckeditor_custom_config.js';

    // We are also going to specify a custom body id and class
    $settings['bodyId'] = 'ckeditor_custom_id';
    $settings['bodyClass'] = 'ckeditor_custom_class';

    // To see what's in $settings and $context, install the devel module 
    // And run the variables through the dpm() function. 
  }
}
0

Here is the code inspired by @tenken

/**
 * Implements hook_wysiwyg_editor_settings_alter()
 *
 * @see http://docs.cksource.com/CKEditor_3.x/Howto/Enabling_SCAYT
 */
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') {
    // Make Scayt enabled by default.
    $settings['scayt_autoStartup'] = 'true';
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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