Ticket #3352: 3352.patch
File 3352.patch, 3.6 KB (added by , 16 years ago) |
---|
-
_source/plugins/domiterator/plugin.js
11 11 12 12 (function() 13 13 { 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 ) 16 21 { 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 45 24 { 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 ); 53 27 } 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; 59 32 } 60 33 61 34 var iterator = function( range ) … … 93 66 range = this.range.clone(); 94 67 range.enlarge( this.forceBrBreak ? CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS : CKEDITOR.ENLARGE_BLOCK_CONTENTS ); 95 68 96 this._.nextNode = getTouchedStartNode( range);97 this._.lastNode = getTouchedEndNode( range);69 this._.nextNode = range.getTouchedStartNode(); 70 this._.lastNode = range.getTouchedEndNode(); 98 71 99 72 // Let's reuse this variable. 100 73 range = null; … … 231 204 232 205 if ( isLast ) 233 206 break; 234 235 currentNode = getNextSourceNode( currentNode, continueFromSibling, null,lastNode );207 208 currentNode = getNextSourceNode( currentNode, lastNode ); 236 209 } 237 210 238 211 // Now, based on the processed range, look for (or create) the block to be returned. … … 303 276 // lists) or the next sibling <li>. 304 277 305 278 this._.nextNode = ( block.equals( lastNode ) ? null : 306 getNextSourceNode( range.getBoundaryNodes().endNode, true, null, lastNode ) );279 getNextSourceNode( range.getBoundaryNodes().endNode, lastNode ) ); 307 280 } 308 281 } 309 282 … … 330 303 // above block can be removed or changed, so we can rely on it for the 331 304 // next interation. 332 305 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 ); 334 308 335 309 return block; 336 310 }