Ticket #6957: 6957.patch
File 6957.patch, 5.5 KB (added by , 13 years ago) |
---|
-
_source/plugins/find/dialogs/find.js
68 68 69 69 var findDialog = function( editor, startupPage ) 70 70 { 71 // Style object for highlights: (#5018)72 // 1. Defined as full match style to avoid compromising ordinary text color styles.73 // 2. Must be apply onto inner-most text to avoid conflicting with ordinary text color styles visually.74 var highlightStyle = new CKEDITOR.style( CKEDITOR.tools.extend( { fullMatch : true, childRule : function(){ return 0; } },75 editor.config.find_highlight ) );76 77 71 /** 78 72 * Iterator which walk through the specified range char by char. By 79 73 * default the walking will not stop at the character boundaries, until … … 252 246 if ( this._.cursors.length < 1 ) 253 247 return; 254 248 255 // Remove the previous highlight if there's one. 256 if ( this._.highlightRange ) 257 this.removeHighlight(); 249 var range = this.toDomRange(); 250 range.select(); 258 251 259 // Apply the highlight. 260 var range = this.toDomRange(), 261 bookmark = range.createBookmark(); 262 highlightStyle.applyToRange( range ); 263 range.moveToBookmark( bookmark ); 264 this._.highlightRange = range; 265 266 // Scroll the editor to the highlighted area. 267 var element = range.startContainer; 268 if ( element.type != CKEDITOR.NODE_ELEMENT ) 269 element = element.getParent(); 270 element.scrollIntoView(); 271 272 // Update the character cursors. 273 this.updateFromDomRange( range ); 274 }, 252 if ( !CKEDITOR.env.ie ) 253 { 254 // Scroll the range into view for non-IEs. 255 var root = range.getCommonAncestor( 1, 1 ); 256 root.scrollIntoView(); 257 } 258 else 259 { 260 // Update the character range in IE 261 // after making a selection. 262 this.updateFromDomRange( range ); 263 } 275 264 276 /** 277 * Remove highlighted find result. 278 */ 279 removeHighlight : function() 280 { 281 if ( !this._.highlightRange ) 282 return; 283 284 var bookmark = this._.highlightRange.createBookmark(); 285 highlightStyle.removeFromRange( this._.highlightRange ); 286 this._.highlightRange.moveToBookmark( bookmark ); 287 this.updateFromDomRange( this._.highlightRange ); 288 this._.highlightRange = null; 265 this._.highlightRange = range; 289 266 }, 290 267 291 268 isReadOnly : function() 292 269 { 293 if ( !this._.highlightRange )294 return 0;295 296 270 return this._.highlightRange.startContainer.isReadOnly(); 297 271 }, 298 272 … … 454 428 || wordSeparatorRegex.test( c ); 455 429 }; 456 430 431 function toggleDesignMode( on ) 432 { 433 if ( CKEDITOR.env.ie && editor.mode == 'wysiwyg' ) 434 editor.document.getBody().$.contentEditable = !!on; 435 } 436 457 437 var finder = { 458 438 searchRange : null, 459 439 matchRange : null, … … 466 446 pattern.length ); 467 447 else 468 448 { 469 this.matchRange.removeHighlight();470 449 this.matchRange = this.matchRange.getNextCharacterRange( pattern.length ); 471 450 } 472 451 … … 509 488 } 510 489 511 490 this.matchRange.clearMatched(); 512 this.matchRange.removeHighlight();513 491 // Clear current session and restart with the default search 514 492 // range. 515 493 // Re-run the finding once for cyclic.(#3517) … … 543 521 && !this.matchRange._.isReplaced && !this.matchRange.isReadOnly() ) 544 522 { 545 523 // Turn off highlight for a while when saving snapshots. 546 this.matchRange.removeHighlight();547 524 var domRange = this.matchRange.toDomRange(); 548 525 var text = editor.document.createText( newString ); 549 526 if ( !isReplaceAll ) … … 742 719 743 720 // Scope to full document. 744 721 finder.searchRange = getSearchRange( 1 ); 745 if ( finder.matchRange ) 746 { 747 finder.matchRange.removeHighlight(); 748 finder.matchRange = null; 749 } 722 finder.matchRange = null; 750 723 editor.fire( 'saveSnapshot' ); 751 724 while ( finder.replace( dialog, 752 725 dialog.getValueOf( 'replace', 'txtFindReplace' ), … … 850 823 }, 851 824 onShow : function() 852 825 { 826 toggleDesignMode( 0 ); 827 853 828 // Establish initial searching start position. 854 829 finder.searchRange = getSearchRange(); 855 830 … … 867 842 }, 868 843 onHide : function() 869 844 { 845 toggleDesignMode( 1 ); 846 870 847 var range; 871 848 if ( finder.matchRange && finder.matchRange.isMatched() ) 872 849 { 873 finder.matchRange.removeHighlight();874 850 editor.focus(); 875 876 851 range = finder.matchRange.toDomRange(); 877 852 if ( range ) 878 853 editor.getSelection().selectRanges( [ range ] ); -
_source/plugins/find/plugin.js
31 31 32 32 requires : [ 'styles' ] 33 33 } ); 34 35 /**36 * Defines the style to be used to highlight results with the find dialog.37 * @type Object38 * @default { element : 'span', styles : { 'background-color' : '#004', 'color' : '#fff' } }39 * @example40 * // Highlight search results with blue on yellow.41 * config.find_highlight =42 * {43 * element : 'span',44 * styles : { 'background-color' : '#ff0', 'color' : '#00f' }45 * };46 */47 CKEDITOR.config.find_highlight = { element : 'span', styles : { 'background-color' : '#004', 'color' : '#fff' } };