Ticket #8050: 8050_7.patch

File 8050_7.patch, 3.3 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/autogrow/plugin.js

     
    77 * @file AutoGrow plugin
    88 */
    99(function(){
     10
     11        // Actual content height, figured out by appending check the last element's document position.
     12        function contentHeight( doc )
     13        {
     14                // Create a temporary marker element.
     15                var marker = CKEDITOR.dom.element.createFromHtml( '<span style="margin:0;padding:0;border:0;clear:both;width:1px;height:1px;display:block;">' + ( CKEDITOR.env.webkit ? '&nbsp;' : '' ) + '</span>', doc );
     16                var body = doc.getBody();
     17                body.append( marker );
     18
     19                var height = marker.getDocumentPosition( doc ).y + marker.$.offsetHeight;
     20                marker.remove();
     21                return height;
     22        }
     23
    1024        var resizeEditor = function( editor )
    1125        {
    1226                if ( !editor.window )
    1327                        return;
     28
    1429                var doc = editor.document,
     30                        body = doc.getBody(),
     31                        htmlElement = doc.getDocumentElement(),
    1532                        currentHeight = editor.window.getViewPaneSize().height,
    16                         newHeight;
     33                        newHeight = contentHeight( doc ),
     34                        // Quirks mode overflows body, standards overflows document element
     35                        scrollable = doc.$.compatMode == 'BackCompat' ? body : htmlElement;
    1736
    18                 // We can not use documentElement to calculate the height for IE (#6061).
    19                 // It is not good for IE Quirks, yet using offsetHeight would also not work as expected (#6408).
    20                 // We do the same for FF because of the html height workaround (#6341).
    21                 if ( CKEDITOR.env.ie || CKEDITOR.env.gecko )
    22                         newHeight = doc.getBody().$.scrollHeight + ( CKEDITOR.env.ie && CKEDITOR.env.quirks ? 0 : 24 );
    23                 else
    24                         newHeight = doc.getDocumentElement().$.offsetHeight;
     37                // Minor adjustment for each browser, or specified by user.
     38                newHeight += ( editor.config.autoGrow_bottomSpace !== undefined || ( CKEDITOR.env.ie9Compat ? 0 : CKEDITOR.env.ie || CKEDITOR.env.opera ? -20 :  20 ) );
    2539
    26                 var min = editor.config.autoGrow_minHeight,
    27                         max = editor.config.autoGrow_maxHeight;
    28                 ( min == undefined ) && ( editor.config.autoGrow_minHeight = min = 200 );
    29                 if ( min )
    30                         newHeight = Math.max( newHeight, min );
    31                 if ( max )
    32                         newHeight = Math.min( newHeight, max );
     40                var min = editor.config.autoGrow_minHeight || 200,
     41                        max = editor.config.autoGrow_maxHeight || Infinity;
     42
     43                newHeight = Math.max( newHeight, min );
     44                newHeight = Math.min( newHeight, max );
    3345
    3446                if ( newHeight != currentHeight )
    3547                {
    3648                        newHeight = editor.fire( 'autoGrow', { currentHeight : currentHeight, newHeight : newHeight } ).newHeight;
    3749                        editor.resize( editor.container.getStyle( 'width' ), newHeight, true );
     50
     51                        if ( newHeight < max )
     52                                scrollable.setStyle( 'overflow-y', 'hidden' );
     53                        else
     54                                scrollable.removeStyle( 'overflow-y' );
    3855                }
    3956        };
    4057        CKEDITOR.plugins.add( 'autogrow',
     
    86103 * @param {Number} data.newHeight The new height of the editor (after the resizing). It can be changed
    87104 *                              to determine another height to be used instead.
    88105 */
     106
     107
     108/**
     109 *  Extra height in pixel to leave between the bottom boundary of content with document size when auto resizing.
     110 * @name CKEDITOR.config.autoGrow_bottomSpace
     111 * @type Number
     112 * @default 20px
     113 * @since 3.6.2
     114 */
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy