@@ -22,6 +22,7 @@ import 'codemirror/addon/search/match-highlighter';
22
22
import 'codemirror/addon/search/jump-to-line' ;
23
23
import 'codemirror/addon/edit/matchbrackets' ;
24
24
import 'codemirror/addon/edit/closebrackets' ;
25
+ import 'codemirror/addon/selection/mark-selection' ;
25
26
26
27
import { JSHINT } from 'jshint' ;
27
28
import { CSSLint } from 'csslint' ;
@@ -37,7 +38,7 @@ import Timer from '../components/Timer';
37
38
import EditorAccessibility from '../components/EditorAccessibility' ;
38
39
import { metaKey , } from '../../../utils/metaKey' ;
39
40
40
- import search from '../../../utils/codemirror-search' ;
41
+ import '../../../utils/codemirror-search' ;
41
42
42
43
import beepUrl from '../../../sounds/audioAlert.mp3' ;
43
44
import UnsavedChangesDotIcon from '../../../images/unsaved-changes-dot.svg' ;
@@ -55,8 +56,6 @@ import * as UserActions from '../../User/actions';
55
56
import * as ToastActions from '../actions/toast' ;
56
57
import * as ConsoleActions from '../actions/console' ;
57
58
58
- search ( CodeMirror ) ;
59
-
60
59
const beautifyCSS = beautifyJS . css ;
61
60
const beautifyHTML = beautifyJS . html ;
62
61
@@ -86,6 +85,7 @@ class Editor extends React.Component {
86
85
this . showFind = this . showFind . bind ( this ) ;
87
86
this . findNext = this . findNext . bind ( this ) ;
88
87
this . findPrev = this . findPrev . bind ( this ) ;
88
+ this . showReplace = this . showReplace . bind ( this ) ;
89
89
this . getContent = this . getContent . bind ( this ) ;
90
90
}
91
91
@@ -106,6 +106,7 @@ class Editor extends React.Component {
106
106
highlightSelectionMatches : true , // highlight current search match
107
107
matchBrackets : true ,
108
108
autoCloseBrackets : this . props . autocloseBracketsQuotes ,
109
+ styleSelectedText : true ,
109
110
lint : {
110
111
onUpdateLinting : ( ( annotations ) => {
111
112
this . props . hideRuntimeErrorWarning ( ) ;
@@ -122,6 +123,7 @@ class Editor extends React.Component {
122
123
123
124
delete this . _cm . options . lint . options . errors ;
124
125
126
+ const replaceCommand = metaKey === 'Ctrl' ? `${ metaKey } -H` : `${ metaKey } -Option-F` ;
125
127
this . _cm . setOption ( 'extraKeys' , {
126
128
Tab : ( cm ) => {
127
129
// might need to specify and indent more?
@@ -137,6 +139,7 @@ class Editor extends React.Component {
137
139
[ `${ metaKey } -F` ] : 'findPersistent' ,
138
140
[ `${ metaKey } -G` ] : 'findNext' ,
139
141
[ `Shift-${ metaKey } -G` ] : 'findPrev' ,
142
+ replaceCommand : 'replace' ,
140
143
} ) ;
141
144
142
145
this . initializeDocuments ( this . props . files ) ;
@@ -170,6 +173,7 @@ class Editor extends React.Component {
170
173
showFind : this . showFind ,
171
174
findNext : this . findNext ,
172
175
findPrev : this . findPrev ,
176
+ showReplace : this . showReplace ,
173
177
getContent : this . getContent
174
178
} ) ;
175
179
}
@@ -283,6 +287,10 @@ class Editor extends React.Component {
283
287
this . _cm . execCommand ( 'findPersistent' ) ;
284
288
}
285
289
290
+ showReplace ( ) {
291
+ this . _cm . execCommand ( 'replace' ) ;
292
+ }
293
+
286
294
tidyCode ( ) {
287
295
const beautifyOptions = {
288
296
indent_size : INDENTATION_AMOUNT ,
0 commit comments