I'd like to use the CSS files of an existing theme, wich can be done by selecting 'Use theme CSS'
and I'd like to add some exceptions to it by specifying the path to an extra CSS file.

To make this work, I had to alter the inc file of my editor.
Eg. in ckeditor.inc :
Change

      if ($config['css_setting'] == 'theme') {
        $settings['contentsCss'] = wysiwyg_get_css();
      }
      elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
        $settings['contentsCss'] = explode(',', strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())));
      }

to

      if ($config['css_setting'] == 'theme') {
        $settings['contentsCss'] = wysiwyg_get_css();
      } else {
        $settings['contentsCss'] = array();
      }
      if (isset($config['css_path'])) {
        $contentsCss = explode(',', strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())));
        $settings['contentsCss'] = array_merge($settings['contentsCss'], $contentsCss);
      }

Still TODO: change the descriptions of the admin form fields accordingly and provide a decent patch.

Comments

twod’s picture

Hmm, you could also override the contentsCss setting in hook_wysiwyg_editor_settings_alter(), would that suffice?

function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'ckeditor') {
    $settings['contentsCss'][] = 'some/css/files/to/always/include.css';
  }
}

If we add this feature, it would need to default to the current behavior and perhaps include a checkbox to toggle merging in the custom list with the theme stylesheets.