X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Ffind%2Fdialogs%2Ffind.js;h=5f8c34214a2c11e7f2bab3f90692fddc2ff927f5;hb=fb481ba0a7d298e3e7b9034fcb9f2afdc6e8e796;hp=c0f7d3734041842349fd94e7f0bfd9f2e97026c6;hpb=039a051ccf3901311661022a30afd60fc38130c9;p=ckeditor.git diff --git a/_source/plugins/find/dialogs/find.js b/_source/plugins/find/dialogs/find.js index c0f7d37..5f8c342 100644 --- a/_source/plugins/find/dialogs/find.js +++ b/_source/plugins/find/dialogs/find.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -71,8 +71,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Style object for highlights: (#5018) // 1. Defined as full match style to avoid compromising ordinary text color styles. // 2. Must be apply onto inner-most text to avoid conflicting with ordinary text color styles visually. - var highlightStyle = new CKEDITOR.style( CKEDITOR.tools.extend( { fullMatch : true, childRule : function(){ return 0; } }, - editor.config.find_highlight ) ); + var highlightStyle = new CKEDITOR.style( + CKEDITOR.tools.extend( { attributes : { 'data-cke-highlight': 1 }, fullMatch : 1, ignoreReadonly : 1, childRule : function(){ return 0; } }, + editor.config.find_highlight, true ) ); /** * Iterator which walk through the specified range char by char. By @@ -154,7 +155,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( this._.matchWord && !currentTextNode || this._.walker._.end ) break; - } + } // Found a fresh text node. this.textNode = currentTextNode; if ( currentTextNode ) @@ -494,8 +495,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license tail = cursors[ cursors.length - 1 ], head = cursors[ 0 ]; - var headWalker = new characterWalker( getRangeBeforeCursor( head ), true ), - tailWalker = new characterWalker( getRangeAfterCursor( tail ), true ); + var rangeBefore = getRangeBeforeCursor( head ), + rangeAfter = getRangeAfterCursor( tail ); + + // The word boundary checks requires to trim the text nodes. (#9036) + rangeBefore.trim(); + rangeAfter.trim(); + + var headWalker = new characterWalker( rangeBefore, true ), + tailWalker = new characterWalker( rangeAfter, true ); if ( ! ( isWordSeparator( headWalker.back().character ) && isWordSeparator( tailWalker.next().character ) ) ) @@ -604,7 +612,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license title : lang.title, resizable : CKEDITOR.DIALOG_RESIZE_NONE, minWidth : 350, - minHeight : 165, + minHeight : 170, buttons : [ CKEDITOR.dialog.cancelButton ], // Cancel button only. contents : [ { @@ -628,6 +636,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }, { type : 'button', + id : 'btnFind', align : 'left', style : 'width:100%', label : lang.find, @@ -645,29 +654,36 @@ For licensing, see LICENSE.html or http://ckeditor.com/license ] }, { - type : 'vbox', - padding : 0, + type : 'fieldset', + label : CKEDITOR.tools.htmlEncode( lang.findOptions ), + style : 'margin-top:29px', children : [ { - type : 'checkbox', - id : 'txtFindCaseChk', - isChanged : false, - style : 'margin-top:28px', - label : lang.matchCase - }, - { - type : 'checkbox', - id : 'txtFindWordChk', - isChanged : false, - label : lang.matchWord - }, - { - type : 'checkbox', - id : 'txtFindCyclic', - isChanged : false, - 'default' : true, - label : lang.matchCyclic + type : 'vbox', + padding : 0, + children : + [ + { + type : 'checkbox', + id : 'txtFindCaseChk', + isChanged : false, + label : lang.matchCase + }, + { + type : 'checkbox', + id : 'txtFindWordChk', + isChanged : false, + label : lang.matchWord + }, + { + type : 'checkbox', + id : 'txtFindCyclic', + isChanged : false, + 'default' : true, + label : lang.matchCyclic + } + ] } ] } @@ -693,6 +709,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }, { type : 'button', + id : 'btnFindReplace', align : 'left', style : 'width:100%', label : lang.replace, @@ -726,6 +743,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }, { type : 'button', + id : 'btnReplaceAll', align : 'left', style : 'width:100%', label : lang.replaceAll, @@ -765,31 +783,35 @@ For licensing, see LICENSE.html or http://ckeditor.com/license ] }, { - type : 'vbox', - padding : 0, + type : 'fieldset', + label : CKEDITOR.tools.htmlEncode( lang.findOptions ), children : [ { - type : 'checkbox', - id : 'txtReplaceCaseChk', - isChanged : false, - label : lang - .matchCase - }, - { - type : 'checkbox', - id : 'txtReplaceWordChk', - isChanged : false, - label : lang - .matchWord - }, - { - type : 'checkbox', - id : 'txtReplaceCyclic', - isChanged : false, - 'default' : true, - label : lang - .matchCyclic + type : 'vbox', + padding : 0, + children : + [ + { + type : 'checkbox', + id : 'txtReplaceCaseChk', + isChanged : false, + label : lang.matchCase + }, + { + type : 'checkbox', + id : 'txtReplaceWordChk', + isChanged : false, + label : lang.matchWord + }, + { + type : 'checkbox', + id : 'txtReplaceCyclic', + isChanged : false, + 'default' : true, + label : lang.matchCyclic + } + ] } ] } @@ -850,7 +872,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Establish initial searching start position. finder.searchRange = getSearchRange(); + // Fill in the find field with selected text. + var selectedText = this.getParentEditor().getSelection().getSelectedText(), + patternFieldId = ( startupPage == 'find' ? 'txtFindFind' : 'txtFindReplace' ); + + var field = this.getContentElement( startupPage, patternFieldId ); + field.setValue( selectedText ); + field.select(); + this.selectPage( startupPage ); + + this[ ( startupPage == 'find' && this._.editor.readOnly? 'hide' : 'show' ) + 'Page' ]( 'replace'); }, onHide : function() {