Ticket #3352: 3352.patch

File 3352.patch, 3.6 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/domiterator/plugin.js

     
    1111
    1212(function()
    1313{
    14         // Functions ported over from v2.
    15         function getTouchedStartNode( range )
     14       
     15        /**
     16         * Find next source order node, ignore bookmark nodes and stop at the specified end node.
     17         * @param {Object} currentNode
     18         * @param {Object} endNode
     19         */
     20        function getNextSourceNode( currentNode, endNode )
    1621        {
    17                 var container = range.startContainer;
    18 
    19                 if ( range.collapsed || container.type != CKEDITOR.NODE_ELEMENT )
    20                         return container;
    21 
    22                 return container.getChildCount() > range.startOffset ? container.getChild( range.startOffset ) : container;
    23         }
    24 
    25         function getTouchedEndNode( range )
    26         {
    27                 var container = range.endContainer;
    28 
    29                 if ( range.collapsed || container.type != CKEDITOR.NODE_ELEMENT )
    30                         return container;
    31 
    32                 return container.getChildCount() > range.endOffset ? container.getChild( range.endOffset ) : container;
    33         }
    34 
    35         function getNextSourceNode( currentNode, startFromSibling, nodeType, stopSearchNode )
    36         {
    37                 if ( !currentNode )
    38                         return null;
    39 
    40                 var node;
    41 
    42                 if ( !startFromSibling && currentNode.getFirst && currentNode.getFirst() )
    43                         node = currentNode.getFirst();
    44                 else
     22                var next = currentNode;
     23                do
    4524                {
    46                         if ( stopSearchNode && currentNode.equals( stopSearchNode ) )
    47                                 return null;
    48 
    49                         node = currentNode.getNext();
    50 
    51                         if ( !node && ( !stopSearchNode || !stopSearchNode.equals( currentNode.parentNode ) ) )
    52                                 return getNextSourceNode( currentNode.getParent(), true, nodeType, stopSearchNode );
     25                        next = next.getNextSourceNode(
     26                                true, null, endNode );
    5327                }
    54 
    55                 if ( nodeType && node && node.type != nodeType )
    56                         return getNextSourceNode( node, false, nodeType, stopSearchNode );
    57 
    58                 return node;
     28                while( next && next.getName
     29                                        && next.getName() == 'span'
     30                                        && next.getAttribute( '_fck_bookmark' ) )
     31                return next;
    5932        }
    6033
    6134        var iterator = function( range )
     
    9366                                range = this.range.clone();
    9467                                range.enlarge( this.forceBrBreak ? CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS : CKEDITOR.ENLARGE_BLOCK_CONTENTS );
    9568
    96                                 this._.nextNode = getTouchedStartNode( range );
    97                                 this._.lastNode = getTouchedEndNode( range );
     69                                this._.nextNode = range.getTouchedStartNode();
     70                                this._.lastNode = range.getTouchedEndNode();
    9871
    9972                                // Let's reuse this variable.
    10073                                range = null;
     
    231204
    232205                                if ( isLast )
    233206                                        break;
    234 
    235                                 currentNode = getNextSourceNode( currentNode, continueFromSibling, null, lastNode );
     207                               
     208                                currentNode = getNextSourceNode( currentNode, lastNode );
    236209                        }
    237210
    238211                        // Now, based on the processed range, look for (or create) the block to be returned.
     
    303276                                        // lists) or the next sibling <li>.
    304277
    305278                                        this._.nextNode = ( block.equals( lastNode ) ? null :
    306                                                         getNextSourceNode( range.getBoundaryNodes().endNode, true, null, lastNode ) );
     279                                                getNextSourceNode( range.getBoundaryNodes().endNode, lastNode ) );
    307280                                }
    308281                        }
    309282
     
    330303                        // above block can be removed or changed, so we can rely on it for the
    331304                        // next interation.
    332305                        if ( !this._.nextNode )
    333                                 this._.nextNode = ( isLast || block.equals( lastNode ) ) ? null : getNextSourceNode( block, true, null, lastNode );
     306                                this._.nextNode = ( isLast || block.equals( lastNode ) ) ? null :
     307                                        getNextSourceNode( block, lastNode );
    334308
    335309                        return block;
    336310                }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy