Ticket #7173: 7173_2.patch

File 7173_2.patch, 3.8 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/autogrow/plugin.js

     
    77 * @file AutoGrow plugin
    88 */
    99(function(){
    10         var resizeEditor = function( editor )
    11         {
    12                 if ( !editor.window )
    13                         return;
    14                 var doc = editor.document,
    15                         currentHeight = editor.window.getViewPaneSize().height,
    16                         newHeight;
     10
     11        CKEDITOR.plugins.add( 'autogrow',
     12        {
     13                init : function( editor )
     14                {
     15                        var lastContentHeight;
     16                        var resizeEditor = function( editor )
     17                        {
     18                                if ( !editor.window )
     19                                        return;
     20
     21                                var doc = editor.document,
     22                                        resizeable = editor.getResizable( 1 ),
     23                                        body = doc.getBody().$,
     24                                        htmlElement = doc.getDocumentElement().$,
     25                                        currentHeight = resizeable.$.offsetHeight,
     26                                        newHeight;
    1727
    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;
     28                                var delta =
     29                                                // Delta height by checking scrollHeight.
     30                                                ( CKEDITOR.env.ie && CKEDITOR.env.quirks ? body.scrollHeight - body.clientHeight
     31                                                                : htmlElement.scrollHeight - ( htmlElement.clientHeight || htmlElement.offsetHeight ) )
     32                                                // Negative scrollHeight (content reduced) is not supported in some browsers, figure it out by watching over the content size.
     33                                                || ( body.clientHeight < lastContentHeight ? body.clientHeight - lastContentHeight : 0 );
    2534
    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 );
     35                                if ( delta )
     36                                {
     37                                        newHeight = currentHeight + delta;
     38                                        var min = editor.config.autoGrow_minHeight,
     39                                                max = editor.config.autoGrow_maxHeight;
     40
     41                                        ( min == undefined ) && ( editor.config.autoGrow_minHeight = min = 200 );
     42                                        if ( min )
     43                                                newHeight = Math.max( newHeight, min );
     44                                        if ( max )
     45                                                newHeight = Math.min( newHeight, max );
    3346
    34                 if ( newHeight != currentHeight )
    35                 {
    36                         newHeight = editor.fire( 'autoGrow', { currentHeight : currentHeight, newHeight : newHeight } ).newHeight;
    37                         editor.resize( editor.container.getStyle( 'width' ), newHeight, true );
    38                 }
    39         };
    40         CKEDITOR.plugins.add( 'autogrow',
    41         {
    42                 init : function( editor )
    43                 {
     47                                        if ( newHeight != currentHeight )
     48                                        {
     49                                                newHeight = editor.fire( 'autoGrow', { currentHeight : currentHeight, newHeight : newHeight } ).newHeight;
     50                                                resizeable.setStyle( 'height', newHeight + 'px' );
     51                                                editor.fire( 'resize' );
     52                                        }
     53                                }
     54
     55                                lastContentHeight = body.clientHeight;
     56                        };
     57
    4458                        for ( var eventName in { contentDom:1, key:1, selectionChange:1, insertElement:1 } )
    4559                        {
    4660                                editor.on( eventName, function( evt )
  • _source/themes/default/theme.js

     
    335335 * @returns {CKEDITOR.dom.element} The resizable element.
    336336 * @example
    337337 */
    338 CKEDITOR.editor.prototype.getResizable = function()
     338CKEDITOR.editor.prototype.getResizable = function( resizeContents )
    339339{
    340         return this.container;
     340        return resizeContents ? CKEDITOR.document.getById( 'cke_contents_' + this.name ) : this.container;
    341341};
    342342
    343343/**
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy