@@ -22,6 +22,7 @@ import 'codemirror/addon/search/match-highlighter';
2222import 'codemirror/addon/search/jump-to-line' ;
2323import 'codemirror/addon/edit/matchbrackets' ;
2424import 'codemirror/addon/edit/closebrackets' ;
25+ import 'codemirror/addon/selection/mark-selection' ;
2526
2627import { JSHINT } from 'jshint' ;
2728import { CSSLint } from 'csslint' ;
@@ -37,7 +38,7 @@ import Timer from '../components/Timer';
3738import EditorAccessibility from '../components/EditorAccessibility' ;
3839import { metaKey , } from '../../../utils/metaKey' ;
3940
40- import search from '../../../utils/codemirror-search' ;
41+ import '../../../utils/codemirror-search' ;
4142
4243import beepUrl from '../../../sounds/audioAlert.mp3' ;
4344import UnsavedChangesDotIcon from '../../../images/unsaved-changes-dot.svg' ;
@@ -55,8 +56,6 @@ import * as UserActions from '../../User/actions';
5556import * as ToastActions from '../actions/toast' ;
5657import * as ConsoleActions from '../actions/console' ;
5758
58- search ( CodeMirror ) ;
59-
6059const beautifyCSS = beautifyJS . css ;
6160const beautifyHTML = beautifyJS . html ;
6261
@@ -86,6 +85,7 @@ class Editor extends React.Component {
8685 this . showFind = this . showFind . bind ( this ) ;
8786 this . findNext = this . findNext . bind ( this ) ;
8887 this . findPrev = this . findPrev . bind ( this ) ;
88+ this . showReplace = this . showReplace . bind ( this ) ;
8989 this . getContent = this . getContent . bind ( this ) ;
9090 }
9191
@@ -106,6 +106,7 @@ class Editor extends React.Component {
106106 highlightSelectionMatches : true , // highlight current search match
107107 matchBrackets : true ,
108108 autoCloseBrackets : this . props . autocloseBracketsQuotes ,
109+ styleSelectedText : true ,
109110 lint : {
110111 onUpdateLinting : ( ( annotations ) => {
111112 this . props . hideRuntimeErrorWarning ( ) ;
@@ -122,6 +123,7 @@ class Editor extends React.Component {
122123
123124 delete this . _cm . options . lint . options . errors ;
124125
126+ const replaceCommand = metaKey === 'Ctrl' ? `${ metaKey } -H` : `${ metaKey } -Option-F` ;
125127 this . _cm . setOption ( 'extraKeys' , {
126128 Tab : ( cm ) => {
127129 // might need to specify and indent more?
@@ -137,6 +139,7 @@ class Editor extends React.Component {
137139 [ `${ metaKey } -F` ] : 'findPersistent' ,
138140 [ `${ metaKey } -G` ] : 'findNext' ,
139141 [ `Shift-${ metaKey } -G` ] : 'findPrev' ,
142+ replaceCommand : 'replace' ,
140143 } ) ;
141144
142145 this . initializeDocuments ( this . props . files ) ;
@@ -170,6 +173,7 @@ class Editor extends React.Component {
170173 showFind : this . showFind ,
171174 findNext : this . findNext ,
172175 findPrev : this . findPrev ,
176+ showReplace : this . showReplace ,
173177 getContent : this . getContent
174178 } ) ;
175179 }
@@ -283,6 +287,10 @@ class Editor extends React.Component {
283287 this . _cm . execCommand ( 'findPersistent' ) ;
284288 }
285289
290+ showReplace ( ) {
291+ this . _cm . execCommand ( 'replace' ) ;
292+ }
293+
286294 tidyCode ( ) {
287295 const beautifyOptions = {
288296 indent_size : INDENTATION_AMOUNT ,
0 commit comments