I don't think the :cols
and :rows
do affect the Redactor box in any way, which is sad (or I'm doing something wrong). To change the height, you can use add a <div>
and define the div in your .css file (Note that you must use "redactor_box"). Here's what worked for me:
This is my edit.html.erb
:
<div class="redactor_box">
<%= f.text_area :content, placeholder: "Blog entry goes here...", :class => "redactor"%>
</div>
This is my custom.css.scss
:
.redactor_box {
width: 600px;
}
You can change some of the box's behavior too. In the terminal, run:
rails generate redactor:config
This will create a config file called app\assets\redactor-rails\config.js
. Now go to Redactor's website and find documentation. You can insert the key:value pairs into the app\assets\redactor-rails\config.js
file.
This is what the file is like when it was freshly generated:
$(document).ready(
function(){
var csrf_token = $('meta[name=csrf-token]').attr('content');
var csrf_param = $('meta[name=csrf-param]').attr('content');
var params;
if (csrf_param !== undefined && csrf_token !== undefined) {
params = csrf_param + "=" + encodeURIComponent(csrf_token);
}
$('.redactor').redactor(
{ "imageUpload":"/redactor_rails/pictures?" + params,
"imageGetJson":"/redactor_rails/pictures",
"fileUpload":"/redactor_rails/documents?" + params,
"fileGetJson":"/redactor_rails/documents",
"path":"/assets/redactor-rails",
"css":"style.css"
}
);
})
Now, simply add key:value pairs after "css":"style.css"
. For example, the below code will disable the box from expanding.
$(document).ready(
function(){
var csrf_token = $('meta[name=csrf-token]').attr('content');
var csrf_param = $('meta[name=csrf-param]').attr('content');
var params;
if (csrf_param !== undefined && csrf_token !== undefined) {
params = csrf_param + "=" + encodeURIComponent(csrf_token);
}
$('.redactor').redactor(
{ "imageUpload":"/redactor_rails/pictures?" + params,
"imageGetJson":"/redactor_rails/pictures",
"fileUpload":"/redactor_rails/documents?" + params,
"fileGetJson":"/redactor_rails/documents",
"path":"/assets/redactor-rails",
"css":"style.css",
"autoresize":"false"
}
);
});
There are a bunch of other settings you can change. Just go to the documentation section on Redactor's website.