X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Ffind%2Fdialogs%2Ffind.js;h=bc9f8a4317db5d81e62c08e629b98fb752613878;hp=8b668397955bb453ab4d7a582e836d786561506a;hb=e371ddf8abcb89013e20e6d0dd746adec344d0e5;hpb=055b6b0792ce7dc53d47af606b367c04b927c2ab diff --git a/_source/plugins/find/dialogs/find.js b/_source/plugins/find/dialogs/find.js index 8b66839..bc9f8a4 100644 --- a/_source/plugins/find/dialogs/find.js +++ b/_source/plugins/find/dialogs/find.js @@ -5,15 +5,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license (function() { - function nonEmptyText( node ) + var isReplace; + + function findEvaluator( node ) { - return ( node.type == CKEDITOR.NODE_TEXT && node.getLength() > 0 ); + return node.type == CKEDITOR.NODE_TEXT && node.getLength() > 0 && ( !isReplace || !node.isReadOnly() ); } /** * Elements which break characters been considered as sequence. */ - function nonCharactersBoundary ( node ) + function nonCharactersBoundary( node ) { return !( node.type == CKEDITOR.NODE_ELEMENT && node.isBlockBoundary( CKEDITOR.tools.extend( {}, CKEDITOR.dtd.$empty, CKEDITOR.dtd.$nonEditable ) ) ); @@ -84,7 +86,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var walker = new CKEDITOR.dom.walker( range ); walker.guard = matchWord ? nonCharactersBoundary : null; - walker[ 'evaluator' ] = nonEmptyText; + walker[ 'evaluator' ] = findEvaluator; walker.breakOnFalse = true; this._ = { @@ -251,8 +253,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license this.removeHighlight(); // Apply the highlight. - var range = this.toDomRange(); + var range = this.toDomRange(), + bookmark = range.createBookmark(); highlightStyle.applyToRange( range ); + range.moveToBookmark( bookmark ); this._.highlightRange = range; // Scroll the editor to the highlighted area. @@ -273,11 +277,21 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( !this._.highlightRange ) return; + var bookmark = this._.highlightRange.createBookmark(); highlightStyle.removeFromRange( this._.highlightRange ); + this._.highlightRange.moveToBookmark( bookmark ); this.updateFromDomRange( this._.highlightRange ); this._.highlightRange = null; }, + isReadOnly : function() + { + if ( !this._.highlightRange ) + return 0; + + return this._.highlightRange.startContainer.isReadOnly(); + }, + moveBack : function() { var retval = this._.walker.back(), @@ -514,13 +528,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license replace : function( dialog, pattern, newString, matchCase, matchWord, matchCyclic , isReplaceAll ) { + isReplace = 1; + // Successiveness of current replace/find. var result = false; // 1. Perform the replace when there's already a match here. // 2. Otherwise perform the find but don't replace it immediately. if ( this.matchRange && this.matchRange.isMatched() - && !this.matchRange._.isReplaced ) + && !this.matchRange._.isReplaced && !this.matchRange.isReadOnly() ) { // Turn off highlight for a while when saving snapshots. this.matchRange.removeHighlight(); @@ -550,6 +566,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license else result = this.find( pattern, matchCase, matchWord, matchCyclic, !isReplaceAll ); + isReplace = 0; + return result; } };