Ticket #5479: 5479_7.patch

File 5479_7.patch, 5.1 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/elementspath/plugin.js

     
    179179
    180180                                                if ( name == 'body' )
    181181                                                        break;
     182                                                else if ( name == 'html' )
     183                                                        return;
    182184
    183185                                                element = element.getParent();
    184186                                        }
  • _source/plugins/wysiwygarea/plugin.js

     
    359359
    360360                CKEDITOR.env.gecko && activateEditing( editor );
    361361
     362                if ( CKEDITOR.env.ie )
     363                {
     364                        var start = range.collapsed && range.startContainer;
     365                        if ( start.type == CKEDITOR.NODE_ELEMENT && start.is( 'span') && start.data( 'cke-bogus') )
     366                        {
     367                                range.moveToPosition( start, CKEDITOR.POSITION_BEFORE_START );
     368                                start.remove();
     369                                range.select();
     370                                return;
     371                        }
     372                }
     373
    362374                // When enterMode set to block, we'll establing new paragraph only if we're
    363375                // selecting inline contents right under body. (#3657)
    364376                if ( enterMode != CKEDITOR.ENTER_BR
     
    410422                        if ( !CKEDITOR.env.ie )
    411423                                editor.selectionChange();
    412424                }
    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         }
     425        }
    445426
    446427        CKEDITOR.plugins.add( 'wysiwygarea',
    447428        {
     
    686667                                                        } );
    687668                                                }
    688669
     670                                                // In certain situation when browsers are incapable to moving cursor out of certain non-exitable
     671                                                // blocks (e.g. table, list, pre) at the end of document, make this happen by
     672                                                // placing a padding area, when clicked put cursor at the end of body.
     673                                                var htmlElement = domDocument.getDocumentElement(),
     674                                                        body = domDocument.getBody(),
     675                                                        nonWhiteSpaces = CKEDITOR.dom.walker.whitespaces( 1 ),
     676                                                        bodyPad = htmlElement.append( 'div' );
     677                                                bodyPad.setAttribute( 'contentEditable', false );
     678                                                bodyPad.addClass( 'cke_body_pad' );
     679                                                bodyPad.setStyles( { width : '100%', height : '1em' } );
     680                                                bodyPad.on( 'click', function()
     681                                                {
     682                                                        var last = body.getLast( nonWhiteSpaces );
     683                                                        if ( last.type == CKEDITOR.NODE_TEXT || !nonExitable( last ) )
     684                                                                return;
     685
     686                                                        if ( !CKEDITOR.env.ie )
     687                                                                body.appendBogus();
     688                                                        else
     689                                                        {
     690                                                                // IE need at least a node to show the cursor, make it
     691                                                                // as <span><br /></span> to capture selection change
     692                                                                // event.
     693                                                                var paddingNode = CKEDITOR.dom.element.createFromHtml( '<span data-cke-bogus=1>' +
     694                                                                        '<br data-cke-temp=1 style="line-height:0"/></span>', domDocument );
     695
     696                                                                body.append( paddingNode );
     697                                                        }
     698
     699                                                        var range = new CKEDITOR.dom.range( domDocument );
     700                                                        range.moveToPosition( body, CKEDITOR.POSITION_BEFORE_END );
     701                                                        range.select();
     702                                                });
     703
     704
    689705                                                // IE standard compliant in editing frame doesn't focus the editor when
    690706                                                // clicking outside actual content, manually apply the focus. (#1659)
    691707                                                if ( CKEDITOR.env.ie
     
    699715                                                                // Setting focus directly on editor doesn't work, we
    700716                                                                // have to use here a temporary element to 'redirect'
    701717                                                                // the focus.
    702                                                                 if ( evt.data.getTarget().equals( htmlElement ) )
     718                                                                if ( !evt.data.getTarget().getAscendant( 'body' ) )
    703719                                                                {
    704720                                                                        if ( CKEDITOR.env.gecko && CKEDITOR.env.version >= 10900 )
    705721                                                                                blinkCursor();
     
    11631179                                }
    11641180                        });
    11651181
    1166                 }
    1167         });
     1182                        var dataProcessor = editor.dataProcessor,
     1183                                htmlFilter = dataProcessor && dataProcessor.htmlFilter;
     1184
     1185                        htmlFilter && htmlFilter.addRules(
     1186                        {
     1187                                elements :
     1188                                {
     1189                                        div : function( element )
     1190                                        {
     1191                                                var attributes = element.attributes;
     1192                                                if ( attributes[ 'class' ] == 'cke_body_pad' )
     1193                                                        return false;
     1194                                        }
     1195                                }
     1196                        });
     1197                }
     1198        });
    11681199
    11691200        // Fixing Firefox 'Back-Forward Cache' break design mode. (#4514)
    11701201        if ( CKEDITOR.env.gecko )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy