@@ -62,7 +62,11 @@ const beautifyHTML = beautifyJS.html;
62
62
window . JSHINT = JSHINT ;
63
63
window . CSSLint = CSSLint ;
64
64
window . HTMLHint = HTMLHint ;
65
- delete CodeMirror . keyMap . sublime [ 'Shift-Tab' ] ;
65
+
66
+
67
+ // delete CodeMirror.keyMap.sublime['Shift-Cmd-F'];
68
+
69
+ console . log ( CodeMirror . keyMap . sublime ) ;
66
70
67
71
const IS_TAB_INDENT = false ;
68
72
const INDENTATION_AMOUNT = 2 ;
@@ -88,6 +92,7 @@ class Editor extends React.Component {
88
92
this . findPrev = this . findPrev . bind ( this ) ;
89
93
this . showReplace = this . showReplace . bind ( this ) ;
90
94
this . getContent = this . getContent . bind ( this ) ;
95
+ this . handleKey = this . handleKey . bind ( this ) ;
91
96
}
92
97
93
98
componentDidMount ( ) {
@@ -155,14 +160,21 @@ class Editor extends React.Component {
155
160
}
156
161
} , 1000 ) ) ;
157
162
158
- this . _cm . on ( 'keyup' , ( ) => {
163
+ this . map = { } ;
164
+
165
+ this . _cm . on ( 'keyup' , ( _cm , e ) => {
159
166
const temp = this . props . t ( 'Editor.KeyUpLineNumber' , { lineNumber : parseInt ( ( this . _cm . getCursor ( ) . line ) + 1 , 10 ) } ) ;
160
167
document . getElementById ( 'current-line' ) . innerHTML = temp ;
168
+ this . handleKey ( this . map , e ) ;
161
169
} ) ;
162
170
163
171
this . _cm . on ( 'keydown' , ( _cm , e ) => {
164
- // 9 === Tab
165
- if ( e . keyCode === 9 && e . shiftKey ) {
172
+ this . handleKey ( this . map , e ) ;
173
+ // 91 === Cmd
174
+ // 16 === Shift
175
+ // 70 === f
176
+ if ( this . map [ 91 ] && this . map [ 16 ] && this . map [ 70 ] ) {
177
+ e . preventDefault ( ) ; // prevent browser's default behaviour
166
178
this . tidyCode ( ) ;
167
179
}
168
180
} ) ;
@@ -192,7 +204,7 @@ class Editor extends React.Component {
192
204
193
205
componentDidUpdate ( prevProps ) {
194
206
if ( this . props . file . content !== prevProps . file . content &&
195
- this . props . file . content !== this . _cm . getValue ( ) ) {
207
+ this . props . file . content !== this . _cm . getValue ( ) ) {
196
208
const oldDoc = this . _cm . swapDoc ( this . _docs [ this . props . file . id ] ) ;
197
209
this . _docs [ prevProps . file . id ] = oldDoc ;
198
210
this . _cm . focus ( ) ;
@@ -327,6 +339,10 @@ class Editor extends React.Component {
327
339
}
328
340
}
329
341
342
+ handleKey ( map , e ) { // update the state of each key pressed and released
343
+ map [ e . keyCode ] = e . type === 'keydown' ;
344
+ }
345
+
330
346
render ( ) {
331
347
const editorSectionClass = classNames ( {
332
348
'editor' : true ,
0 commit comments