How change/manage the default height, ser for the editor-window of the wysiwyg-text-area ?

Comments

TwoD’s picture

Status: Active » Fixed

There's currently no GUI setting for this, but it can be changed via code by implementing hook_wysiwyg_editor_settings_alter() in a small module:

function MYMODLENAME_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'ckeditor') {
    $settings['height'] = 500;
   }
}

Please also see #964978: Document hook_wysiwyg_editor_settings_alter() and #507696: Allow individual width/height per field.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

bryancasler’s picture

subscribe

Babymaggie’s picture

I know this is an old thread but I have just stumbled across it and wanted to say thanks to TwoD.

I have managed to follow your simple instructions to create a new module that works.

Can you please let me know how to alter it so as it checks if the ckeditor is being used for comments and only adjust the height if it is.

Is this possible? I think would be a simple if statement but I am only beginning to pick up programming so I'm not sure.

Many thanks

jienckebd’s picture

TwoD -- thanks. I've been banging my head trying to do this through CSS.

Babymaggie, you probably figured it out by now but one way is to check the URL to see if you're currently on a comment. Eg.

function MYMODLENAME_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'ckeditor') {
    // check if currently viewing a comment
    if (arg(0) == 'comment') {
      $settings['height'] = 200;
    }
    else {
      $settings['height'] = 500;
    }
  }
}
Babymaggie’s picture

Thanks to jienckebd for your helpful reply.

I had actually given up on this until I saw your post.

After a little bit of tinkering now works for me aswell :)

Thank you

StuartDH’s picture

I use the following in my theme's css to change the default height of the ckeditor textarea window

.cke_contents {
height: 200px !important;
}

Hope this helps

Stuart

jay-dee-ess’s picture

Thanks, Stuart.

amirtaiar’s picture

Thank you all,
I have been following and created the module but no success. I activate the module but the height remain.
Is it because I am using the admin seven layout and not the theme layout for editing pages?

HorsePunchKid’s picture

@amirtaiar Have you tried clearing your cache? I believe Drupal caches information about what modules implement what hooks.

jienckebd’s picture

Amirtaiar,

The module should run on all of your themes so the Seven theme shouldn't be causing your problem. Can you post the code you're using?

Also, try adding the below code to the MYMODLENAME_wysiwyg_editor_settings_alter and load the page with the ckeditor you're trying to change. If you don't see the contents of $context above the ckeditor, the function isn't running so the problem would be with the way you set up your module.

drupal_set_message(print_r($context));

Anonymous’s picture

Hi,

I tried CSS and a custom module but no one worked. The solution was to go in the Drupal's configuration > CKEditor > your_profile > Advanced options > Custom JavaScript configuration and add the following command :

config.height = '600px';

And don't forget the ; at the end or it'll not work ! thx to Olivier for the trick.. damn.

gapa’s picture

I was searching for quick and simple solution and this one really worked.
tnx

ressa’s picture

Thanks for sharing @rbulle.

danilocgsilva’s picture

Issue summary: View changes

It would be great if there were some way to control the editor's height through GUI. For example, there's the row settings in the body's content type fields settings that have no effect when the editor is enabled. It seems to me that, specifically this setting, is the perfect one available in GUI to control the editor's height, because also it is rather intuitive to suppose that this options is designed to this and too, allow by field control over the height. But, how bind this field value with the editor's height? All the above solutions seems to be somewhat dirty an counter-intuitive...

wranvaud’s picture

Thanks rbulle, that was easy. All other css or js tricks I've seen on the web failed.

Paulraj Augustin’s picture

#7 works. But I couldn't able to resize the editor.

#12 works fine. Thanks.

BamaJohn’s picture

Thanks to rbulle! - #12 worked great for me.

TwoD’s picture

FYI: If #12 worked, your're NOT using Wysiwyg module. You're using ckeditor.module to control the CKEditor library.

Since this issue is quite old by now, I should probably also mention that the -dev snapshots now adapt the editor height to better match the height of the original textarea by default. If you want a fixed height, use #1.

kumkum29’s picture

Hello,

I can confirm that if you use the last Wysiwyg dev version (2014-Oct-18) the height of the editor is null.
So, if you use the solution #1 in your admin theme (in template.php), the problem is resolved.

Anil Kumar Vallur’s picture

#12 comment did the trick for me.

ressa’s picture

In Drupal 8, put this in a custom module:

// change the ckeditor's settings
function mymodule_stuff_editor_js_settings_alter(array &$settings) {
  foreach (array_keys($settings['editor']['formats']) as $text_format_id) {
    if ($settings['editor']['formats'][$text_format_id]['editor'] === 'ckeditor') {
      $settings['editor']['formats'][$text_format_id]['editorSettings']['height'] = '600px';
    }
  }
}

NOTE: As @TwoD notes, the above code is for CKEditor in Drupal 8, which has been added as the default editor.

TwoD’s picture

@ressa, that has nothing to with Wysiwyg module, since it does not exist for D8.

That hook is for the D8 Editor module. (Which happens to be partially based on Wysiwyg, but still, a completely separate project.)

ressa’s picture

Oh yeah, I see, thanks for clarifying that.

rubyji’s picture

#15 is right. It seems logical that CKEditor should follow the setting in the field's definition.