Hi!
Does anyone know a simple way how to resize the editor according to editor content? When creating editor instance, I pass some html as editor value (objEditor.Value = some_html;), and now I would like to automatically set editor height big enough so that scrollbar wouldn't appear...
Any tips&tricks?
Thanks,
Dino
Does anyone know a simple way how to resize the editor according to editor content? When creating editor instance, I pass some html as editor value (objEditor.Value = some_html;), and now I would like to automatically set editor height big enough so that scrollbar wouldn't appear...
Any tips&tricks?
Thanks,
Dino
RE: Automatic height resize
RE: Automatic height resize
/**
* Resize height of (outer) editor frame to match inner height of contents
* @param fckEditor = editor instance reference
* @param min = minimum height (in pixels)
* @param max = maximum height
*/
function resizeHeightToContents(fckEditor, min, max) {
var frameHeight = fckEditor.EditorWindow.parent.innerHeight; //outer frame which includes menu bar
var editHeight = fckEditor.EditorWindow.innerHeight; //inner content frame
var contentHeight = fckEditor.EditorDocument.body.offsetHeight;
var heightDiff = contentHeight - editHeight;
if ((heightDiff < 0) && (frameHeight > min)) {
//shrink editor frame
frameHeight += heightDiff;
if (frameHeight < min) frameHeight = min;
fckEditor.EditorWindow.parent.frameElement.style.height = frameHeight;
}
else if ((heightDiff > 0) && (frameHeight < max)) {
//expand editor frame
frameHeight += heightDiff;
if (frameHeight > max) frameHeight = max;
fckEditor.EditorWindow.parent.frameElement.style.height = frameHeight;
}
}
Re: RE: Automatic height resize
For me it works in Firefox 2.0.11 (Mac & PC) but not in IE7. I would need this functionality but I dont know Firefox/IE differences in Javascript well enough to fix it. Anyone willing to help?


EDIT: I found that I can enable the Autogrow plugin by uncommenting a line in fckconfig.js. The editor then resizes correctly in IE. It resized in Firefox as well, but there is another problem: when the page first loads, the editor resizes itself to be far too large. When I click on it to select its focus, it shrinsk down to the correct size. See attached images. The empty space is in some cases much larger that what is shown in these images, so it can be a quite annoying problem.
--- After loading page, before click inside editor ---
--- After click inside editor ---