ruby-on-railsrubytrix

Trix WYSIWYG Editor change default rows/vertical height of textfield


I read through the Trix documentation and an answer did not jump out at me for this. It appears that the Trix WYSIWYG editor defaults to 3 displayed rows:

trix before

Any chance this can be toggled to more rows, for example: 15 or so rows: enter image description here


Solution

  • It is a matter of setting the min-height css attribute. Using javascript, this works if you only have one trix-editor on the page:

    $('trix-editor').css("min-height", "350px");
    

    If you have multiple trix editors on the page and you only want to change the default height for that one: what I did is I wrapped the trix editor in a div, set a class on that div, and used find:

    $('.solution-trix-field-wrapper').find($('trix-editor')).css("min-height", "350px");