/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
// Style object for highlights: (#5018)\r
// 1. Defined as full match style to avoid compromising ordinary text color styles.\r
// 2. Must be apply onto inner-most text to avoid conflicting with ordinary text color styles visually.\r
- var highlightStyle = new CKEDITOR.style( CKEDITOR.tools.extend( { fullMatch : true, childRule : function(){ return 0; } },\r
- editor.config.find_highlight ) );\r
+ var highlightStyle = new CKEDITOR.style(\r
+ CKEDITOR.tools.extend( { attributes : { 'data-cke-highlight': 1 }, fullMatch : 1, ignoreReadonly : 1, childRule : function(){ return 0; } },\r
+ editor.config.find_highlight, true ) );\r
\r
/**\r
* Iterator which walk through the specified range char by char. By\r
if ( this._.matchWord && !currentTextNode\r
|| this._.walker._.end )\r
break;\r
- }\r
+ }\r
// Found a fresh text node.\r
this.textNode = currentTextNode;\r
if ( currentTextNode )\r
tail = cursors[ cursors.length - 1 ],\r
head = cursors[ 0 ];\r
\r
- var headWalker = new characterWalker( getRangeBeforeCursor( head ), true ),\r
- tailWalker = new characterWalker( getRangeAfterCursor( tail ), true );\r
+ var rangeBefore = getRangeBeforeCursor( head ),\r
+ rangeAfter = getRangeAfterCursor( tail );\r
+\r
+ // The word boundary checks requires to trim the text nodes. (#9036)\r
+ rangeBefore.trim();\r
+ rangeAfter.trim();\r
+\r
+ var headWalker = new characterWalker( rangeBefore, true ),\r
+ tailWalker = new characterWalker( rangeAfter, true );\r
\r
if ( ! ( isWordSeparator( headWalker.back().character )\r
&& isWordSeparator( tailWalker.next().character ) ) )\r
},\r
{\r
type : 'button',\r
+ id : 'btnFind',\r
align : 'left',\r
style : 'width:100%',\r
label : lang.find,\r
]\r
},\r
{\r
- type : 'vbox',\r
- padding : 0,\r
+ type : 'fieldset',\r
+ label : CKEDITOR.tools.htmlEncode( lang.findOptions ),\r
+ style : 'margin-top:29px',\r
children :\r
[\r
{\r
- type : 'checkbox',\r
- id : 'txtFindCaseChk',\r
- isChanged : false,\r
- style : 'margin-top:28px',\r
- label : lang.matchCase\r
- },\r
- {\r
- type : 'checkbox',\r
- id : 'txtFindWordChk',\r
- isChanged : false,\r
- label : lang.matchWord\r
- },\r
- {\r
- type : 'checkbox',\r
- id : 'txtFindCyclic',\r
- isChanged : false,\r
- 'default' : true,\r
- label : lang.matchCyclic\r
+ type : 'vbox',\r
+ padding : 0,\r
+ children :\r
+ [\r
+ {\r
+ type : 'checkbox',\r
+ id : 'txtFindCaseChk',\r
+ isChanged : false,\r
+ label : lang.matchCase\r
+ },\r
+ {\r
+ type : 'checkbox',\r
+ id : 'txtFindWordChk',\r
+ isChanged : false,\r
+ label : lang.matchWord\r
+ },\r
+ {\r
+ type : 'checkbox',\r
+ id : 'txtFindCyclic',\r
+ isChanged : false,\r
+ 'default' : true,\r
+ label : lang.matchCyclic\r
+ }\r
+ ]\r
}\r
]\r
}\r
},\r
{\r
type : 'button',\r
+ id : 'btnFindReplace',\r
align : 'left',\r
style : 'width:100%',\r
label : lang.replace,\r
},\r
{\r
type : 'button',\r
+ id : 'btnReplaceAll',\r
align : 'left',\r
style : 'width:100%',\r
label : lang.replaceAll,\r
]\r
},\r
{\r
- type : 'vbox',\r
- padding : 0,\r
+ type : 'fieldset',\r
+ label : CKEDITOR.tools.htmlEncode( lang.findOptions ),\r
children :\r
[\r
{\r
- type : 'checkbox',\r
- id : 'txtReplaceCaseChk',\r
- isChanged : false,\r
- label : lang\r
- .matchCase\r
- },\r
- {\r
- type : 'checkbox',\r
- id : 'txtReplaceWordChk',\r
- isChanged : false,\r
- label : lang\r
- .matchWord\r
- },\r
- {\r
- type : 'checkbox',\r
- id : 'txtReplaceCyclic',\r
- isChanged : false,\r
- 'default' : true,\r
- label : lang\r
- .matchCyclic\r
+ type : 'vbox',\r
+ padding : 0,\r
+ children :\r
+ [\r
+ {\r
+ type : 'checkbox',\r
+ id : 'txtReplaceCaseChk',\r
+ isChanged : false,\r
+ label : lang.matchCase\r
+ },\r
+ {\r
+ type : 'checkbox',\r
+ id : 'txtReplaceWordChk',\r
+ isChanged : false,\r
+ label : lang.matchWord\r
+ },\r
+ {\r
+ type : 'checkbox',\r
+ id : 'txtReplaceCyclic',\r
+ isChanged : false,\r
+ 'default' : true,\r
+ label : lang.matchCyclic\r
+ }\r
+ ]\r
}\r
]\r
}\r
// Establish initial searching start position.\r
finder.searchRange = getSearchRange();\r
\r
+ // Fill in the find field with selected text.\r
+ var selectedText = this.getParentEditor().getSelection().getSelectedText(),\r
+ patternFieldId = ( startupPage == 'find' ? 'txtFindFind' : 'txtFindReplace' );\r
+\r
+ var field = this.getContentElement( startupPage, patternFieldId );\r
+ field.setValue( selectedText );\r
+ field.select();\r
+\r
this.selectPage( startupPage );\r
+\r
+ this[ ( startupPage == 'find' && this._.editor.readOnly? 'hide' : 'show' ) + 'Page' ]( 'replace');\r
},\r
onHide : function()\r
{\r