Hey everyone,

does anyone know how to enable the autoGrow-Plugin from CKEditor? I do have a custom module already. So maybe I can add autoGrow support via this?

My Module:

function wysiwygsetting_wysiwyg_editor_settings_alter(&$settings, $context) {
   if ($context['profile']->editor == 'ckeditor') {
     $settings['uiColor'] = '#141B20';
	 $settings['scayt_sLang'] = 'de_DE';
	 $settings['height'] = 100;
	 $settings['wsc_lang'] = 'de_DE';
	 $settings['bodyId'] = 'primary';
	 $settings['bodyClass'] = 'singlepage';	 
   }
}

Thanks for your help everyone! And thanks for all the work with the module!

Comments

TwoD’s picture

Status: Active » Fixed

You could append it to the list of extra plugins to load ($settings['extraPlugins']), but we also have a hook to provide Wysiwyg with metadata about plugins so they can be added to the "Buttons and plugins list". It is mentioned in wysiwyg.api.php, but I'll provide the minimum code you need.

/**
 * Implements hook_wysiwyg_plugin().
 */
function wysiwygsettings_wysiwyg_plugin($editor, $version) {
  if ($editor == 'ckeditor') {
    return array(
      'autogrow' => array(
        'url' => 'http://rev.ckeditor.com/ckeditor/trunk/7646/_samples/autogrow.html',
        'extensions' => array('autogrow' => t('AutoGrow plugin')),
        'options' => array(
          // This sets some default values you can override in hook_wsiwyg_editor_settings_alter(), or use for hook_form_alter().
          'autoGrow_maxHeight' => 500,
          'autoGrow_onStartup' => TRUE,
        ),
        'load' => TRUE,
        'internal' => TRUE, // This plugin is bundled with CKEditor, no need to set 'path' or 'filename'.
      ),
    );
  }
}

You could also automatically disable the resize plugin from your settings hook when this one is detected:

function wysiwygsetting_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'ckeditor') {
    // Only disable resize if autogrow is enabled and removePlugins is empty or does not already contain 'resize'.
    if (strpos($settings['extraPlugins'], 'autogrow') !== FALSE && (empty($settings['removePlugins']) || strpos($settings['removePlugins'], 'resize') === FALSE)) {
      $settings['removePlugins'] .= (empty($settings['removePlugins']) ? 'resize' : ',resize');
    }
  }
}
Yucom’s picture

Status: Fixed » Closed (fixed)

Just wanted to say thanks! Everythings working fine now!

Thanks for all the work!