Opened 14 years ago

Closed 13 years ago

#6161 closed Bug (fixed)

Autogrow plugin should resize on instanceReady too.

Reported by: Scott Bronson Owned by:
Priority: Normal Milestone: CKEditor 3.6.2
Component: General Version: 3.4.1
Keywords: Cc: fckeditor@…


The autogrow plugin should resize the editor when starting up too. Otherwise there's a good chance that the editor size will jump when you first click on it. The patch is trivial:

--- a/public/app/ckeditor/_source/plugins/autogrow/plugin.js
+++ b/public/app/ckeditor/_source/plugins/autogrow/plugin.js
@@ -37,7 +37,7 @@ For licensing, see LICENSE.html or
        init : function( editor )
-           for ( var eventName in { contentDom:1, key:1, selectionChange:1, insertElement:1 } )
+           for ( var eventName in { instanceReady:1, contentDom:1, key:1, selectionChange:1, insertElement:1 } )
                editor.on( eventName, function( evt )

Attachments (3)

6161.patch (539 bytes) - added by Charlie 14 years ago.
6161_2.patch (547 bytes) - added by Charlie 14 years ago.
added mode event
6161_2.2.patch (1.0 KB) - added by exim 13 years ago.
Added config.autoGrow_onStartup (default: false) to maintain previous AutoGrow behavior

Download all attachments as: .zip

Change History (14)

comment:1 Changed 14 years ago by Scott Bronson

I just noticed that contentDom is probably supposed to handle this.

All I can say is, on Firefox 3.6, resizing only contentDom causes the edit area to come up in its original size. Then, when you click or keypress, it pops to the right size. Resizing on instanceReady brings it up the correct size.

Changed 14 years ago by Charlie

Attachment: 6161.patch added

comment:2 Changed 14 years ago by Charlie

Keywords: HasPatch added

I second this motion. I just attached the exact change you made as a patch file for easier access initally, then I had another thought looking at the patch, turns out I was right. It should also fire on the mode event.

To test this bug, if you make some very long source code and copy it...then empty the editor in WYSIWYG, then go to source, paste, and hit source. The editor should grow, but again doesn't until you click it.

Finally, the editor doesn't grow or shrink at all in Source mode. I see that this is intentionally so in the code, as removing this causes an error, but would it theoretically be possible to have that functionality? I'm not sure if that would make it more or less useful (As source code is always longer it would be constantly growing and shrinking)

Changed 14 years ago by Charlie

Attachment: 6161_2.patch added

added mode event

comment:3 Changed 14 years ago by Charlie

Perhaps it should also resize when you resize an object? In theory if you sized an image below the editor, the editor should grow accordingly when done. I'm not sure how to put this in, resize or resizestart? Perhaps someone else knows better if this is possible.

comment:4 Changed 14 years ago by Danial Pearce

Cc: fckeditor@… added

I tried this patch but it doesn't seem to fix it for me? I am running 3.4 stable though, not the nightly build or anything.

comment:5 Changed 14 years ago by Danial Pearce

Ignore me. It works fine. I was calling CKEDITOR.replace() twice which confused autogrow instanceReady event.

comment:6 Changed 14 years ago by Dinu

I second this make it into the trunk. It would be awfully nice if the autogrow were more intimately connected to the editor though; for instance, when replacing a div, the editor is first sized to config.height then autogrow'ed... if the div is large this causes the page to swirl around quite noticeably... also the scrollbars that always pop up before the resize... It would be great if this were tied directly upper in the chain of events so the plugin would work in-flow.

comment:7 Changed 13 years ago by Garry Yao

Keywords: Discussion added

I understand you point, but instead there exist some others want to grow the editor only when editing, so their initial page layout is not broken, in that sense we may have to revert the editor size on blur instead.

So, we'd provide a config "autoGrowOnlyEditing" to control this, set to "true" by default maybe.

comment:8 Changed 13 years ago by Alfonso Martínez de Lizarrondo

I'm not sure that the people that wants to preserve a layout are gonna enable a setting like autogrow.

As you say, if they want it to behave that way we should revert to the original size on blur, but I haven't see any report about that request, so I don't think that there are really so much people wanting this.

I would prefer to fix the current problem and when someone request the alternative behavior then deal with it (but leaving the current behavior as the default one as it seems more logical for a CMS)

comment:9 Changed 13 years ago by Ondrej Hlavacek

instanceReady event fires only once - if I create and destroy multiple editors in a page, only the first one is resized with this event.

comment:10 Changed 13 years ago by exim

If anybody is looking for a temporary workaround that doesn't involve patching any of the CKEditor code then add this to the javascript code you use to configure/instantiate the editor:

CKEDITOR.on('instanceReady', function(ev) {'contentDom'); });

The code above will fire the contentDom event every time a new editor is instantiated causing it to resize immediately after loading. This said I still hope that a proper config setting will be added to CKEditor though so workarounds like this will no longer be needed.

Changed 13 years ago by exim

Attachment: 6161_2.2.patch added

Added config.autoGrow_onStartup (default: false) to maintain previous AutoGrow behavior

comment:11 Changed 13 years ago by Garry Yao

Keywords: HasPatch Discussion removed
Milestone: CKEditor 3.6.2
Resolution: fixed
Status: newclosed

Fixed with [7199]. Tests are to be handled by #8050.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy