Ticket #5479: 5479_10.patch

File 5479_10.patch, 4.7 KB (added by Garry Yao, 13 years ago)
  • _source/core/dom/element.js

     
    234234                                this.append( new CKEDITOR.dom.text( text ) );
    235235                },
    236236
    237                 appendBogus : function()
    238                 {
    239                         var lastChild = this.getLast() ;
    240 
    241                         // Ignore empty/spaces text.
    242                         while ( lastChild && lastChild.type == CKEDITOR.NODE_TEXT && !CKEDITOR.tools.rtrim( lastChild.getText() ) )
    243                                 lastChild = lastChild.getPrevious();
    244                         if ( !lastChild || !lastChild.is || !lastChild.is( 'br' ) )
    245                         {
    246                                 var bogus = CKEDITOR.env.opera ?
    247                                                 this.getDocument().createText('') :
    248                                                 this.getDocument().createElement( 'br' );
    249 
    250                                 CKEDITOR.env.gecko && bogus.setAttribute( 'type', '_moz' );
    251 
    252                                 this.append( bogus );
    253                         }
    254                 },
    255 
    256237                /**
    257238                * Retrieve block element's filler node if existed.
    258239                */
  • _source/core/dom/walker.js

     
    449449                return false;
    450450        };
    451451
     452        // Append a filler node at the end of an element if not exists.
     453        CKEDITOR.dom.element.prototype.appendBogus = function()
     454        {
     455                var lastChild = this.getLast( fillerEvaluator ) ;
     456                if ( !lastChild || !lastChild.is || !lastChild.is( 'br' ) )
     457                {
     458                        var bogus = CKEDITOR.env.opera ?
     459                                        this.getDocument().createText('') :
     460                                        this.getDocument().createElement( 'br' );
     461
     462                        CKEDITOR.env.gecko && bogus.setAttribute( 'type', '_moz' );
     463
     464                        this.append( bogus );
     465                }
     466        };
     467
     468
    452469})();
  • _source/plugins/wysiwygarea/plugin.js

     
    304304                return block.getOuterHtml().match( emptyParagraphRegexp );
    305305        }
    306306
    307         isNotWhitespace = CKEDITOR.dom.walker.whitespaces( true );
    308 
    309307        // Gecko need a key event to 'wake up' the editing
    310308        // ability when document is empty.(#3864, #5781)
    311309        function activateEditing( editor )
     
    359357
    360358                CKEDITOR.env.gecko && activateEditing( editor );
    361359
     360                // Remove the padding body node used in IE.
     361                if ( CKEDITOR.env.ie )
     362                {
     363                        var start = range.collapsed && range.startContainer;
     364                        if ( start.type == CKEDITOR.NODE_ELEMENT && start.is( 'span') && start.data( 'cke-bogus') )
     365                        {
     366                                range.moveToPosition( start, CKEDITOR.POSITION_BEFORE_START );
     367                                start.remove();
     368                                range.select();
     369                                return;
     370                        }
     371                }
     372
    362373                // When enterMode set to block, we'll establing new paragraph only if we're
    363374                // selecting inline contents right under body. (#3657)
    364375                if ( enterMode != CKEDITOR.ENTER_BR
     
    396407                                {
    397408                                        element = fixedBlock.getPrevious( isNotWhitespace );
    398409                                        if ( element &&
    399                                                  element.type == CKEDITOR.NODE_ELEMENT &&
    400                                                  !nonExitable( element ) )
     410                                                 element.type == CKEDITOR.NODE_ELEMENT )
    401411                                        {
    402                                                 range.moveToElementEditEnd( element );
    403                                                 fixedBlock.remove();
    404                                         }
    405                                 }
    406                         }
     412                                                if ( !nonExitable( element ) )
     413                                                {
     414                                                        range.moveToElementEditEnd( element );
     415                                                        fixedBlock.remove();
     416                                                }
     417                                                else if ( element.getDirection() )
     418                                                        fixedBlock.setAttribute( 'dir', element.getDirection() );
     419                                        }
     420                                }
     421                        }
    407422
    408423                        range.select();
    409424                        // Notify non-IE that selection has changed.
     
    423438                walkerRange.selectNodeContents( body );
    424439                walker.evaluator = function( node )
    425440                {
    426                         return node.type == CKEDITOR.NODE_ELEMENT && ( node.getName() in nonExitableElementNames );
     441                        return node.type == CKEDITOR.NODE_ELEMENT && nonExitable( node );
    427442                };
    428443                walker.guard = function( node, isMoveout )
    429444                {
     
    444459
    445460                        if ( !CKEDITOR.env.ie )
    446461                                paddingBlock.appendBogus();
    447                 }
    448         }
     462                        else if ( paddingBlock.is( 'body' ) )
     463                        {
     464                                // IE need at least a node to show the cursor, use a zero height br
     465                                // to fly under the radar, additionally wrap the br element with an extra span ,
     466                                // so selection change event could be easily captured when cursor move inside of it.
     467                                var paddingNode = CKEDITOR.dom.element.createFromHtml( '<span data-cke-bogus=1>' +
     468                                        '<br data-cke-temp=1 style="line-height:0"/></span>', editor.document );
     469                                paddingBlock.append( paddingNode );
     470                        }
     471                }
     472        }
    449473
    450474        CKEDITOR.plugins.add( 'wysiwygarea',
    451475        {
     
    11671191                                }
    11681192                        });
    11691193
    1170                 }
    1171         });
     1194                                        }
     1195                        });
    11721196
    11731197        // Fixing Firefox 'Back-Forward Cache' break design mode. (#4514)
    11741198        if ( CKEDITOR.env.gecko )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy