Ticket #3516: 3516.patch
File 3516.patch, 3.7 KB (added by , 16 years ago) |
---|
-
_source/plugins/find/dialogs/find.js
26 26 */ 27 27 var cursorStep = function() 28 28 { 29 var obj ={29 return { 30 30 textNode : this.textNode, 31 31 offset : this.offset, 32 32 character : this.textNode ? 33 33 this.textNode.getText().charAt( this.offset ) : null, 34 34 hitMatchBoundary : this._.matchBoundary 35 35 }; 36 return obj;37 36 }; 38 37 39 38 var pages = [ 'find', 'replace' ], … … 72 71 var highlightStyle = new CKEDITOR.style( editor.config.find_highlight ); 73 72 74 73 /** 75 * Iterator which walk through document char by char. 76 * @param {Object} start 77 * @param {Number} offset 78 * @param {Boolean} isStrict 74 * Iterator which walk through the specified range char by char. By 75 * default the walking will not stop at the character boundaries, until 76 * the end of the range is encountered. 77 * @param { CKEDITOR.dom.range } range 78 * @param {Boolean} matchWord Whether the walking will stop at character boundary. 79 79 */ 80 80 var characterWalker = function( range , matchWord ) 81 81 { … … 193 193 range.setEnd( last.textNode, last.offset + 1 ); 194 194 return range; 195 195 }, 196 196 /** 197 * Reflect the latest changes from dom range. 198 */ 197 199 updateFromDomRange : function( domRange ) 198 200 { 199 var startNode = domRange.startContainer,200 startIndex = domRange.startOffset,201 endNode = domRange.endContainer,202 endIndex = domRange.endOffset,203 boundaryNodes = domRange.getBoundaryNodes();204 205 if ( startNode.type != CKEDITOR.NODE_TEXT )206 {207 startNode = boundaryNodes.startNode;208 while ( startNode.type != CKEDITOR.NODE_TEXT )209 startNode = startNode.getFirst();210 startIndex = 0;211 }212 213 if ( endNode.type != CKEDITOR.NODE_TEXT )214 {215 endNode = boundaryNodes.endNode;216 while ( endNode.type != CKEDITOR.NODE_TEXT )217 endNode = endNode.getLast();218 endIndex = endNode.getLength();219 }220 221 // If the endNode is an empty text node, our walker would just walk through222 // it without stopping. So need to backtrack to the nearest non-emtpy text223 // node.224 if ( endNode.getLength() < 1 )225 {226 while ( ( endNode = endNode.getPreviousSourceNode() )227 && !( endNode.type == CKEDITOR.NODE_TEXT228 && endNode.getLength() > 0 ) )229 { /*jsl:pass*/ }230 231 endIndex = endNode.getLength();232 }233 234 // Rebuild the character range.235 201 var cursor, 236 walker = new characterWalker( 237 getRangeAfterCursor( 238 ( { textNode: startNode, offset : startIndex } ), 239 true ) ); 202 walker = new characterWalker( domRange ); 240 203 this._.cursors = []; 241 204 do 242 205 { 243 206 cursor = walker.next(); 244 this._.cursors.push( cursor ); 207 if ( cursor.character ) 208 this._.cursors.push( cursor ); 245 209 } 246 while ( !( cursor.textNode.equals( endNode ) 247 && cursor.offset == endIndex - 1 ) ); 210 while ( cursor.character ); 248 211 this._.rangeLength = this._.cursors.length; 249 212 }, 250 213 … … 439 402 this._.state = this._.overlap[ this._.state ]; 440 403 } 441 404 442 return null;443 405 }, 444 406 445 407 reset : function() … … 557 519 }; 558 520 559 521 /** 560 * Get the default cursor which is the start of this document.561 */562 function getDefaultStartCursor()563 {564 return { textNode : editor.document.getBody(), offset: 0 };565 }566 567 /**568 522 * The range in which find/replace happened, receive from user 569 523 * selection prior. 570 524 */