Ticket #3783: 3783.patch

File 3783.patch, 5.2 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/list/plugin.js

     
    486486                                var mergeSibling, listCommand = this;
    487487                                ( mergeSibling = function( rtl ){
    488488
    489                                         var sibling = listNode[ rtl ? 'getPrevious' : 'getNext' ].call( listNode, true );
     489                                        var sibling = listNode[ rtl ?
     490                                                'getPrevious' : 'getNext' ]( CKEDITOR.dom.walker.whitespaces( true ) );
    490491                                        if ( sibling && sibling.getName &&
    491492                                             sibling.getName() == listCommand.type )
    492493                                        {
  • _source/plugins/wysiwygarea/plugin.js

     
    166166                        var children = fixedBlock.getChildren(),
    167167                                count = children.count(),
    168168                                firstChild,
    169                                 previousElement = fixedBlock.getPrevious( true ),
    170                                 nextElement = fixedBlock.getNext( true ),
     169                                whitespaceGuard = CKEDITOR.dom.walker.whitespaces( true ),
     170                                previousElement = fixedBlock.getPrevious( whitespaceGuard ),
     171                                nextElement = fixedBlock.getNext( whitespaceGuard ),
    171172                                enterBlock;
    172173                        if ( previousElement && previousElement.getName
    173174                                 && !( previousElement.getName() in nonExitableElementNames ) )
  • _source/core/dom/node.js

     
    350350                        return node;
    351351                },
    352352
    353                 getPrevious : function( ignoreSpaces )
     353                getPrevious : function( guard )
    354354                {
    355                         var previous = this.$.previousSibling;
    356                         while ( ignoreSpaces && previous && ( previous.nodeType == CKEDITOR.NODE_TEXT )
    357                                         && !CKEDITOR.tools.trim( previous.nodeValue ) )
     355                        var previous = this.$;
     356                        do
     357                        {
    358358                                previous = previous.previousSibling;
     359                        }
     360                        while ( previous && guard && !guard( new CKEDITOR.dom.element( previous ) ) )
    359361
    360362                        return previous ? new CKEDITOR.dom.node( previous ) : null;
    361363                },
    362364
    363365                /**
    364366                 * Gets the node that follows this element in its parent's child list.
    365                  * @param {Boolean} ignoreSpaces Whether should ignore empty text nodes.
    366                  * @returns {CKEDITOR.dom.node} The next node or null if not
    367                  *              available.
     367                 * @returns {CKEDITOR.dom.node} The next node or null if not available.
    368368                 * @example
    369369                 * var element = CKEDITOR.dom.element.createFromHtml( '<div><b>Example</b> <i>next</i></div>' );
    370370                 * var first = <b>element.getFirst().getNext()</b>;
    371371                 * alert( first.getName() );  // "i"
    372372                 */
    373                 getNext : function( ignoreSpaces )
     373                getNext : function( guard )
    374374                {
    375                         var next = this.$.nextSibling;
    376                         while ( ignoreSpaces && next && ( next.nodeType == CKEDITOR.NODE_TEXT )
    377                                   && !CKEDITOR.tools.trim( next.nodeValue ) )
     375                        var next = this.$;
     376                        do
     377                        {
    378378                                next = next.nextSibling;
     379                        }
     380                        while ( next && guard && !guard( new CKEDITOR.dom.element( next ) ) )
    379381
    380382                        return next ? new CKEDITOR.dom.node( next ) : null;
    381383                },
  • _source/plugins/domiterator/plugin.js

     
    287287
    288288                        if ( removeLastBr )
    289289                        {
     290                                // Ignore bookmark nodes.(#3783)
     291                                var bookmarkGuard = CKEDITOR.dom.walker.bookmark( false, true );
     292
    290293                                var lastChild = block.getLast();
    291294                                if ( lastChild && lastChild.type == CKEDITOR.NODE_ELEMENT && lastChild.getName() == 'br' )
    292295                                {
    293296                                        // Take care not to remove the block expanding <br> in non-IE browsers.
    294                                         if ( CKEDITOR.env.ie || lastChild.getPrevious() || lastChild.getNext() )
     297                                        if ( CKEDITOR.env.ie
     298                                                 || lastChild.getPrevious( bookmarkGuard )
     299                                                 || lastChild.getNext( bookmarkGuard ) )
    295300                                                lastChild.remove();
    296301                                }
    297302                        }
  • _source/core/dom/walker.js

     
    379379
    380380                return function( node )
    381381                {
    382                         var retval, parent;
     382                        var isBookmark, parent;
    383383                        // Is bookmark inner text node?
    384                         retval = ( node && !node.getName && ( parent = node.getParent() )
     384                        isBookmark = ( node && !node.getName && ( parent = node.getParent() )
    385385                                                && isBookmarkNode( parent ) );
    386386                        // Is bookmark node?
    387                         retval = contentOnly ? retval : retval || isBookmarkNode( node );
    388                         return isReject ? !retval : !!retval;
     387                        isBookmark = contentOnly ? isBookmark : isBookmark || isBookmarkNode( node );
     388                        return isReject ^ isBookmark;
    389389                };
    390390        };
    391391
     392        /**
     393         * Whether the node contains only white-spaces characters.
     394         * @param isReject
     395         */
     396        CKEDITOR.dom.walker.whitespaces = function( isReject )
     397        {
     398                return function( node )
     399                {
     400                        var isWhitespace = node && ( node.type == CKEDITOR.NODE_TEXT )
     401                                                        && !CKEDITOR.tools.trim( node.getText() )
     402                        return isReject ^ isWhitespace;
     403                };
     404        }
     405
    392406})();
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy