File tree Expand file tree Collapse file tree 3 files changed +37
-58
lines changed Expand file tree Collapse file tree 3 files changed +37
-58
lines changed Original file line number Diff line number Diff line change @@ -12,57 +12,27 @@ editor:
12
12
13
13
# Keyboard shortcuts (see https://craig.is/killing/mice)
14
14
shortcuts :
15
- -
16
- keys : mod+s
17
- method : sync
18
- -
19
- keys : mod+shift+b
20
- method : bold
21
- -
22
- keys : mod+shift+i
23
- method : italic
24
- -
25
- keys : mod+shift+l
26
- method : link
27
- -
28
- keys : mod+shift+l
29
- method : link
30
- -
31
- keys : mod+shift+q
32
- method : quote
33
- -
34
- keys : mod+shift+k
35
- method : code
36
- -
37
- keys : mod+shift+g
38
- method : image
39
- -
40
- keys : mod+shift+o
41
- method : olist
42
- -
43
- keys : mod+shift+o
44
- method : olist
45
- -
46
- keys : mod+shift+u
47
- method : ulist
48
- -
49
- keys : mod+shift+h
50
- method : heading
51
- -
52
- keys : mod+shift+r
53
- method : hr
54
- -
55
- keys : = = > space
56
- method : expand
57
- params :
58
- - ' ==> '
59
- - ' ⇒ '
60
- -
61
- keys : < = = space
62
- method : expand
63
- params :
64
- - ' <== '
65
- - ' ⇐ '
15
+ mod+s : sync
16
+ mod+shift+b : bold
17
+ mod+shift+i : italic
18
+ mod+shift+l : link
19
+ mod+shift+q : quote
20
+ mod+shift+k : code
21
+ mod+shift+g : image
22
+ mod+shift+o : olist
23
+ mod+shift+u : ulist
24
+ mod+shift+h : heading
25
+ mod+shift+r : hr
26
+ ' = = > space ' :
27
+ method : expand
28
+ params :
29
+ - ' ==> '
30
+ - ' ⇒ '
31
+ ' < = = space ' :
32
+ method : expand
33
+ params :
34
+ - ' <== '
35
+ - ' ⇐ '
66
36
67
37
# Default content for new files
68
38
newFileContent : |
Original file line number Diff line number Diff line change @@ -31,8 +31,8 @@ const methods = {
31
31
return true ;
32
32
} ,
33
33
expand ( param1 , param2 ) {
34
- const text = param1 && `${ param1 } ` ;
35
- const replacement = param2 && `${ param2 } ` ;
34
+ const text = `${ param1 || '' } ` ;
35
+ const replacement = `${ param2 || '' } ` ;
36
36
if ( text && replacement ) {
37
37
setTimeout ( ( ) => {
38
38
const selectionMgr = editorEngineSvc . clEditor . selectionMgr ;
@@ -58,15 +58,20 @@ store.watch(
58
58
Mousetrap . reset ( ) ;
59
59
60
60
const shortcuts = computedSettings . shortcuts ;
61
- shortcuts . forEach ( ( shortcut ) => {
62
- if ( shortcut . keys ) {
63
- const method = shortcut . method || shortcut ;
61
+ Object . keys ( shortcuts ) . forEach ( ( key ) => {
62
+ const shortcut = shortcuts [ key ] ;
63
+ if ( shortcut ) {
64
+ const method = `${ shortcut . method || shortcut } ` ;
64
65
let params = shortcut . params || [ ] ;
65
66
if ( ! Array . isArray ( params ) ) {
66
67
params = [ params ] ;
67
68
}
68
69
if ( Object . prototype . hasOwnProperty . call ( methods , method ) ) {
69
- Mousetrap . bind ( `${ shortcut . keys } ` , ( ) => ! methods [ method ] . apply ( null , params ) ) ;
70
+ try {
71
+ Mousetrap . bind ( `${ key } ` , ( ) => ! methods [ method ] . apply ( null , params ) ) ;
72
+ } catch ( e ) {
73
+ // Ignore
74
+ }
70
75
}
71
76
}
72
77
} ) ;
Original file line number Diff line number Diff line change @@ -88,7 +88,11 @@ module.getters.computedSettings = (state, getters) => {
88
88
return opt ;
89
89
}
90
90
Object . keys ( obj ) . forEach ( ( key ) => {
91
- obj [ key ] = override ( obj [ key ] , opt [ key ] ) ;
91
+ if ( key === 'shortcuts' ) {
92
+ obj [ key ] = Object . assign ( obj [ key ] , opt [ key ] ) ;
93
+ } else {
94
+ obj [ key ] = override ( obj [ key ] , opt [ key ] ) ;
95
+ }
92
96
} ) ;
93
97
return obj ;
94
98
} ;
You can’t perform that action at this time.
0 commit comments