Is there a way to set the height of CKEditor 3.0 to a percentage, such as 100%, such that it takes up the whole window?
I am currently using absolute values, but the
After a lot of fiddling with this resizing stuff on ckeditor 4 I made up this which works perfectly perfectly for me:
in config.js:
// prevent flashing of resizing by setting the content panel to zero height before it is resized
config.height = '0px';
config.width = '100%';
jQuery:
$(document).ready(function(){
// resize the editor(s) while the instance is ready
CKEDITOR.on('instanceReady', function() {
var textEditHeight = $(".textPanel").height();
var ckTopHeight = $("#cke_1_top").height();
var ckContentsHeight = $("#cke_1_contents").height();
for (var i = 1; i < 10; i++) {
$("#cke_"+i+"_contents").height( (textEditHeight - ckTopHeight - 10) + "px");
}
});
// resize the editor(s) while resizing the browser
$(window).resize(function(){
var textEditHeight = $(".textPanel").height();
var ckTopHeight = $("#cke_1_top").height();
var ckContentsHeight = $("#cke_1_contents").height();
for (var i = 1; i < 10; i++) {
$("#cke_"+i+"_contents").height( (textEditHeight - ckTopHeight - 10) + "px");
}
});
});
I have multiple instances of the editor of the exact same size in tabs, for every language one, hence the for loop. If you have one editor you can leave that line away and use the standard id cke_1_contents.
In this example the heights are taken from the first editors toolbar (cke_1_top) and contentpanel (cke_1_contents). The .textPanel height is the surrounding div were the editor should fit in. I added 10px because I needed that for my layout.
I think it can be a littlebit more efficiënt (it initiates the resizing as many times as there are editors) but for now it is finally working flawlessly in all my recent browsers (ff, ie, chrome and safari).
Put this property in your css config file:
.cke_reset{
min-height: 200px;
}
I have been looking for a clean way to get the CKEditor window to be the same height as the textarea it is replacing. I'm using Drupal, and this is how I did it ...
In my theme I load up a javascript file, (using "scripts[] = default.js" in my .info file).
In this file I have:
$(document).ready(function(){
// Set CKEditor height
if (typeof CKEDITOR!='undefined') {
CKEDITOR.on( 'instanceReady', function( e ) {
e.editor.element.show();
var elHeight = $(e.editor.element.$).height();
e.editor.element.hide();
e.editor.resize('100%', elHeight, true);
});
}
}
The beauty of this is you can then change the height using css.
I had been changing the settings.height via the wysiwyg module in wysiwyg/editors/js/ckeditor-3.0.js
Drupal.wysiwyg.editor.attach.ckeditor = function(context, params, settings) {
// Apply editor instance settings.
CKEDITOR.config.customConfig = '';
// Match the height of the replaced field
settings.height = $('#' + params.field).height();
}
but this would get overwritten during updates, so went with the top solution.
The documentation on ckeditor for CKEDITOR.config.height say that they do not support percentage units e.g.: 30%; however, there is a td with a class of cke_contents. if you set the height on that (with an absolute value it will work).
It seems that ckeditor does not have a good solution for this problem. The only other way I can think of is to use javascript to change the style on the above td.