@@ -5,7 +5,7 @@ import CodeMirror from 'codemirror'
5
5
import 'codemirror-mode-elixir'
6
6
import attachmentManagement from 'browser/main/lib/dataApi/attachmentManagement'
7
7
import convertModeName from 'browser/lib/convertModeName'
8
- import { options , TableEditor } from '@susisu/mte-kernel'
8
+ import { options , TableEditor , Alignment } from '@susisu/mte-kernel'
9
9
import TextEditorInterface from 'browser/lib/TextEditorInterface'
10
10
import eventEmitter from 'browser/main/lib/eventEmitter'
11
11
import iconv from 'iconv-lite'
@@ -143,7 +143,7 @@ export default class CodeEditor extends React.Component {
143
143
override : true
144
144
}
145
145
} )
146
-
146
+
147
147
this . setMode ( this . props . mode )
148
148
149
149
this . editor . on ( 'focus' , this . focusHandler )
@@ -164,11 +164,11 @@ export default class CodeEditor extends React.Component {
164
164
CodeMirror . Vim . defineEx ( 'qw' , 'qw' , this . quitEditor )
165
165
CodeMirror . Vim . map ( 'ZZ' , ':q' , 'normal' )
166
166
this . setState ( { isReady : true } )
167
-
167
+
168
168
const editorIntf = new TextEditorInterface ( this . editor )
169
169
this . tableEditor = new TableEditor ( editorIntf )
170
170
eventEmitter . on ( 'code:format-table' , this . formatTable )
171
-
171
+
172
172
const defaultKeyMap = CodeMirror . normalizeKeyMap ( {
173
173
Tab : function ( cm ) {
174
174
const cursor = cm . getCursor ( )
@@ -221,52 +221,52 @@ export default class CodeEditor extends React.Component {
221
221
return CodeMirror . Pass
222
222
}
223
223
} )
224
-
225
- if ( this . props . enableTableEditor ) {
224
+
225
+ if ( this . props . enableTableEditor ) {
226
226
const opts = options ( {
227
227
smartCursor : true
228
228
} )
229
-
229
+
230
230
const editorKeyMap = CodeMirror . normalizeKeyMap ( {
231
- 'Tab' : ( ) => { this . tableEditor . nextCell ( opts ) } ,
232
- 'Shift-Tab' : ( ) => { this . tableEditor . previousCell ( opts ) } ,
233
- 'Enter' : ( ) => { this . tableEditor . nextRow ( opts ) } ,
234
- 'Ctrl-Enter' : ( ) => { this . tableEditor . escape ( opts ) } ,
235
- 'Cmd-Enter' : ( ) => { this . tableEditor . escape ( opts ) } ,
236
- 'Shift-Ctrl-Left' : ( ) => { this . tableEditor . alignColumn ( Alignment . LEFT , opts ) } ,
237
- 'Shift-Cmd-Left' : ( ) => { this . tableEditor . alignColumn ( Alignment . LEFT , opts ) } ,
238
- 'Shift-Ctrl-Right' : ( ) => { this . tableEditor . alignColumn ( Alignment . RIGHT , opts ) } ,
239
- 'Shift-Cmd-Right' : ( ) => { this . tableEditor . alignColumn ( Alignment . RIGHT , opts ) } ,
240
- 'Shift-Ctrl-Up' : ( ) => { this . tableEditor . alignColumn ( Alignment . CENTER , opts ) } ,
241
- 'Shift-Cmd-Up' : ( ) => { this . tableEditor . alignColumn ( Alignment . CENTER , opts ) } ,
242
- 'Shift-Ctrl-Down' : ( ) => { this . tableEditor . alignColumn ( Alignment . NONE , opts ) } ,
243
- 'Shift-Cmd-Down' : ( ) => { this . tableEditor . alignColumn ( Alignment . NONE , opts ) } ,
244
- 'Ctrl-Left' : ( ) => { this . tableEditor . moveFocus ( 0 , - 1 , opts ) } ,
245
- 'Cmd-Left' : ( ) => { this . tableEditor . moveFocus ( 0 , - 1 , opts ) } ,
246
- 'Ctrl-Right' : ( ) => { this . tableEditor . moveFocus ( 0 , 1 , opts ) } ,
247
- 'Cmd-Right' : ( ) => { this . tableEditor . moveFocus ( 0 , 1 , opts ) } ,
248
- 'Ctrl-Up' : ( ) => { this . tableEditor . moveFocus ( - 1 , 0 , opts ) } ,
249
- 'Cmd-Up' : ( ) => { this . tableEditor . moveFocus ( - 1 , 0 , opts ) } ,
250
- 'Ctrl-Down' : ( ) => { this . tableEditor . moveFocus ( 1 , 0 , opts ) } ,
251
- 'Cmd-Down' : ( ) => { this . tableEditor . moveFocus ( 1 , 0 , opts ) } ,
252
- 'Ctrl-K Ctrl-I' : ( ) => { this . tableEditor . insertRow ( opts ) } ,
253
- 'Cmd-K Cmd-I' : ( ) => { this . tableEditor . insertRow ( opts ) } ,
254
- 'Ctrl-L Ctrl-I' : ( ) => { this . tableEditor . deleteRow ( opts ) } ,
255
- 'Cmd-L Cmd-I' : ( ) => { this . tableEditor . deleteRow ( opts ) } ,
256
- 'Ctrl-K Ctrl-J' : ( ) => { this . tableEditor . insertColumn ( opts ) } ,
257
- 'Cmd-K Cmd-J' : ( ) => { this . tableEditor . insertColumn ( opts ) } ,
258
- 'Ctrl-L Ctrl-J' : ( ) => { this . tableEditor . deleteColumn ( opts ) } ,
259
- 'Cmd-L Cmd-J' : ( ) => { this . tableEditor . deleteColumn ( opts ) } ,
260
- 'Alt-Shift-Ctrl-Left' : ( ) => { this . tableEditor . moveColumn ( - 1 , opts ) } ,
261
- 'Alt-Shift-Cmd-Left' : ( ) => { this . tableEditor . moveColumn ( - 1 , opts ) } ,
231
+ 'Tab' : ( ) => { this . tableEditor . nextCell ( opts ) } ,
232
+ 'Shift-Tab' : ( ) => { this . tableEditor . previousCell ( opts ) } ,
233
+ 'Enter' : ( ) => { this . tableEditor . nextRow ( opts ) } ,
234
+ 'Ctrl-Enter' : ( ) => { this . tableEditor . escape ( opts ) } ,
235
+ 'Cmd-Enter' : ( ) => { this . tableEditor . escape ( opts ) } ,
236
+ 'Shift-Ctrl-Left' : ( ) => { this . tableEditor . alignColumn ( Alignment . LEFT , opts ) } ,
237
+ 'Shift-Cmd-Left' : ( ) => { this . tableEditor . alignColumn ( Alignment . LEFT , opts ) } ,
238
+ 'Shift-Ctrl-Right' : ( ) => { this . tableEditor . alignColumn ( Alignment . RIGHT , opts ) } ,
239
+ 'Shift-Cmd-Right' : ( ) => { this . tableEditor . alignColumn ( Alignment . RIGHT , opts ) } ,
240
+ 'Shift-Ctrl-Up' : ( ) => { this . tableEditor . alignColumn ( Alignment . CENTER , opts ) } ,
241
+ 'Shift-Cmd-Up' : ( ) => { this . tableEditor . alignColumn ( Alignment . CENTER , opts ) } ,
242
+ 'Shift-Ctrl-Down' : ( ) => { this . tableEditor . alignColumn ( Alignment . NONE , opts ) } ,
243
+ 'Shift-Cmd-Down' : ( ) => { this . tableEditor . alignColumn ( Alignment . NONE , opts ) } ,
244
+ 'Ctrl-Left' : ( ) => { this . tableEditor . moveFocus ( 0 , - 1 , opts ) } ,
245
+ 'Cmd-Left' : ( ) => { this . tableEditor . moveFocus ( 0 , - 1 , opts ) } ,
246
+ 'Ctrl-Right' : ( ) => { this . tableEditor . moveFocus ( 0 , 1 , opts ) } ,
247
+ 'Cmd-Right' : ( ) => { this . tableEditor . moveFocus ( 0 , 1 , opts ) } ,
248
+ 'Ctrl-Up' : ( ) => { this . tableEditor . moveFocus ( - 1 , 0 , opts ) } ,
249
+ 'Cmd-Up' : ( ) => { this . tableEditor . moveFocus ( - 1 , 0 , opts ) } ,
250
+ 'Ctrl-Down' : ( ) => { this . tableEditor . moveFocus ( 1 , 0 , opts ) } ,
251
+ 'Cmd-Down' : ( ) => { this . tableEditor . moveFocus ( 1 , 0 , opts ) } ,
252
+ 'Ctrl-K Ctrl-I' : ( ) => { this . tableEditor . insertRow ( opts ) } ,
253
+ 'Cmd-K Cmd-I' : ( ) => { this . tableEditor . insertRow ( opts ) } ,
254
+ 'Ctrl-L Ctrl-I' : ( ) => { this . tableEditor . deleteRow ( opts ) } ,
255
+ 'Cmd-L Cmd-I' : ( ) => { this . tableEditor . deleteRow ( opts ) } ,
256
+ 'Ctrl-K Ctrl-J' : ( ) => { this . tableEditor . insertColumn ( opts ) } ,
257
+ 'Cmd-K Cmd-J' : ( ) => { this . tableEditor . insertColumn ( opts ) } ,
258
+ 'Ctrl-L Ctrl-J' : ( ) => { this . tableEditor . deleteColumn ( opts ) } ,
259
+ 'Cmd-L Cmd-J' : ( ) => { this . tableEditor . deleteColumn ( opts ) } ,
260
+ 'Alt-Shift-Ctrl-Left' : ( ) => { this . tableEditor . moveColumn ( - 1 , opts ) } ,
261
+ 'Alt-Shift-Cmd-Left' : ( ) => { this . tableEditor . moveColumn ( - 1 , opts ) } ,
262
262
'Alt-Shift-Ctrl-Right' : ( ) => { this . tableEditor . moveColumn ( 1 , opts ) } ,
263
- 'Alt-Shift-Cmd-Right' : ( ) => { this . tableEditor . moveColumn ( 1 , opts ) } ,
264
- 'Alt-Shift-Ctrl-Up' : ( ) => { this . tableEditor . moveRow ( - 1 , opts ) } ,
265
- 'Alt-Shift-Cmd-Up' : ( ) => { this . tableEditor . moveRow ( - 1 , opts ) } ,
266
- 'Alt-Shift-Ctrl-Down' : ( ) => { this . tableEditor . moveRow ( 1 , opts ) } ,
267
- 'Alt-Shift-Cmd-Down' : ( ) => { this . tableEditor . moveRow ( 1 , opts ) }
263
+ 'Alt-Shift-Cmd-Right' : ( ) => { this . tableEditor . moveColumn ( 1 , opts ) } ,
264
+ 'Alt-Shift-Ctrl-Up' : ( ) => { this . tableEditor . moveRow ( - 1 , opts ) } ,
265
+ 'Alt-Shift-Cmd-Up' : ( ) => { this . tableEditor . moveRow ( - 1 , opts ) } ,
266
+ 'Alt-Shift-Ctrl-Down' : ( ) => { this . tableEditor . moveRow ( 1 , opts ) } ,
267
+ 'Alt-Shift-Cmd-Down' : ( ) => { this . tableEditor . moveRow ( 1 , opts ) }
268
268
} )
269
-
269
+
270
270
const updateActiveState = ( ) => {
271
271
const active = this . tableEditor . cursorIsInTable ( opts )
272
272
if ( active ) {
@@ -276,7 +276,7 @@ export default class CodeEditor extends React.Component {
276
276
this . tableEditor . resetSmartCursor ( )
277
277
}
278
278
}
279
-
279
+
280
280
this . editor . on ( 'cursorActivity' , ( ) => {
281
281
if ( ! editorIntf . transaction ) {
282
282
updateActiveState ( )
0 commit comments