Ticket #5479: 5479_4.patch

File 5479_4.patch, 3.6 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/wysiwygarea/plugin.js

     
    410410                        if ( !CKEDITOR.env.ie )
    411411                                editor.selectionChange();
    412412                }
    413 
    414                 // All browsers are incapable to moving cursor out of certain non-exitable
    415                 // blocks (e.g. table, list, pre) at the end of document, make this happen by
    416                 // place a bogus node there, which would be later removed by dataprocessor.
    417                 var walkerRange = new CKEDITOR.dom.range( editor.document ),
    418                         walker = new CKEDITOR.dom.walker( walkerRange );
    419                 walkerRange.selectNodeContents( body );
    420                 walker.evaluator = function( node )
    421                 {
    422                         return node.type == CKEDITOR.NODE_ELEMENT && ( node.getName() in nonExitableElementNames );
    423                 };
    424                 walker.guard = function( node, isMoveout )
    425                 {
    426                         return !( ( node.type == CKEDITOR.NODE_TEXT && isNotWhitespace( node ) ) || isMoveout );
    427                 };
    428 
    429                 if ( walker.previous() )
    430                 {
    431                         editor.fire( 'updateSnapshot' );
    432                         restoreDirty( editor );
    433                         CKEDITOR.env.ie && restoreSelection( selection );
    434 
    435                         var paddingBlock;
    436                         if ( enterMode != CKEDITOR.ENTER_BR )
    437                                 paddingBlock = body.append( new CKEDITOR.dom.element( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) );
    438                         else
    439                                 paddingBlock = body;
    440 
    441                         if ( !CKEDITOR.env.ie )
    442                                 paddingBlock.appendBogus();
    443                 }
    444         }
     413        }
    445414
    446415        CKEDITOR.plugins.add( 'wysiwygarea',
    447416        {
     
    686655                                                        } );
    687656                                                }
    688657
     658                                                // In certain situation when browsers are incapable to moving cursor out of certain non-exitable
     659                                                // blocks (e.g. table, list, pre) at the end of document, make this happen by
     660                                                // placing a padding area, when clicked put cursor at the end of body.
     661                                                var htmlElement = domDocument.getDocumentElement(),
     662                                                        body = domDocument.getBody(),
     663                                                        nonWhiteSpaces = CKEDITOR.dom.walker.whitespaces( 1 ),
     664                                                        bodyPad = htmlElement.append( 'div' );
     665                                                bodyPad.addClass( 'cke_body_pad' );
     666                                                bodyPad.setStyles( { width : '100%', height : '1em' } );
     667                                                bodyPad.on( 'click', function()
     668                                                {
     669                                                        var last = body.getLast( nonWhiteSpaces );
     670                                                        if ( last.type == CKEDITOR.NODE_TEXT || !nonExitable( last ) )
     671                                                                return;
     672
     673                                                        var range = new CKEDITOR.dom.range( domDocument );
     674                                                        range.moveToPosition( body, CKEDITOR.POSITION_BEFORE_END );
     675                                                        range.select();
     676                                                });
     677
     678
    689679                                                // IE standard compliant in editing frame doesn't focus the editor when
    690680                                                // clicking outside actual content, manually apply the focus. (#1659)
    691681                                                if ( CKEDITOR.env.ie
     
    699689                                                                // Setting focus directly on editor doesn't work, we
    700690                                                                // have to use here a temporary element to 'redirect'
    701691                                                                // the focus.
    702                                                                 if ( evt.data.getTarget().equals( htmlElement ) )
     692                                                                if ( !evt.data.getTarget().getAscendant( 'body' ) )
    703693                                                                {
    704694                                                                        if ( CKEDITOR.env.gecko && CKEDITOR.env.version >= 10900 )
    705695                                                                                blinkCursor();
     
    11631153                                }
    11641154                        });
    11651155
    1166                 }
    1167         });
     1156                        var dataProcessor = editor.dataProcessor,
     1157                                htmlFilter = dataProcessor && dataProcessor.htmlFilter;
     1158
     1159                        htmlFilter && htmlFilter.addRules(
     1160                        {
     1161                                elements :
     1162                                {
     1163                                        div : function( element )
     1164                                        {
     1165                                                var attributes = element.attributes;
     1166                                                if ( attributes[ 'class' ] == 'cke_body_pad' )
     1167                                                        return false;
     1168                                        }
     1169                                }
     1170                        });
     1171                }
     1172        });
    11681173
    11691174        // Fixing Firefox 'Back-Forward Cache' break design mode. (#4514)
    11701175        if ( CKEDITOR.env.gecko )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy