I'm looking to set a min height on the redactor text area. The vendor site shows how it can be done, but doesn't specify where to add this code snippet.

$R('#content', {
  minHeight: '500px'

I added that to the redactor.js file in the vendor/craftcms/redactor/lib/redactor folder, but it didn't work. Can someone point me in the right direction? I'm trying to avoid installing additional plugins like Control Panel CSS just to do that one thing.

Additionally, is there a way to preserve line breaks in the text area? I work only in the code view mode and after every save, line breaks disappear. I did a search and found some pages on Github that talk about the issue, but I couldn't find a resolution.

1 Answer 1


The redactor configs are stored inside the config/redactor directory.

Make sure you're editing the right config that your field uses (eg Standard) and add:


... to that file. The configs use JSON so when you see a Redactor configuration, that's how Craft is going to initialize it.

To answer your other question, Redactor is not really designed as a code editor—it's really for end users editing text in a WYSIWYG fashion.

I was able to get Redactor to keep line breaks in tact and keep comments using something like:

  "cleanOnEnter": false,
  "removeComments": false

You might also want to turn off HTML purifier (or modify its own config).

FWIW it's probably much easier to use a dedicated field type for editing code, such as the CodeMirror plugin.

  • 1
    The min-height worked, thank you. I have the HTML purifier off but it still removed line breaks after adding those other two lines. That's okay though, I'm going to check out the CodeMirror plugin. Thanks!
    – Jake1293
    Jun 30, 2020 at 1:22

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.