Ticket #6161 (closed Bug: fixed)

Opened 4 years ago

Last modified 3 years ago

Autogrow plugin should resize on instanceReady too.

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

Description

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 http://ckeditor.com/license
    {
        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

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

Change History

comment:1 Changed 4 years ago by 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 4 years ago by comp615

comment:2 Changed 4 years ago by comp615

  • 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 4 years ago by comp615

added mode event

comment:3 Changed 4 years ago by comp615

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 4 years ago by tigris

  • 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 4 years ago by tigris

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

comment:6 Changed 4 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 4 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 4 years ago by alfonsoml

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 4 years ago by ohlavacek

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 3 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) { ev.editor.fire('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 3 years ago by exim

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

comment:11 Changed 3 years ago by garry.yao

  • Status changed from new to closed
  • Keywords HasPatch Discussion removed
  • Resolution set to fixed
  • Milestone set to CKEditor 3.6.2

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

Note: See TracTickets for help on using tickets.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy