-
Notifications
You must be signed in to change notification settings - Fork 95
/
hotkeys.js
77 lines (71 loc) · 1.35 KB
/
hotkeys.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import {
LINK, IMAGE, BLOCK_QUOTE, UL_LIST, OL_LIST,
MARK_BOLD, MARK_ITALIC, MARK_CODE, HR, LINEBREAK,
HEADINGBREAK
} from './schema';
const HOTKEYS = {
'mod+b': {
type: 'mark',
code: MARK_BOLD,
},
'mod+i': {
type: 'mark',
code: MARK_ITALIC,
},
'mod+shift+9': {
type: 'mark',
code: MARK_CODE,
},
'mod+shift+7': {
type: 'block',
code: OL_LIST,
},
'mod+shift+8': {
type: 'block',
code: UL_LIST,
},
'mod+shift+.': {
type: 'block',
code: BLOCK_QUOTE,
},
'mod+shift+g': {
type: 'image',
code: IMAGE,
},
'mod+z': {
type: 'special',
code: 'undo',
},
'mod+shift+z': {
type: 'special',
code: 'redo',
},
'mod+k': {
type: 'link',
code: LINK,
},
'mod+enter': {
type: 'horizontal_rule',
code: HR,
},
'shift+enter': {
type: 'linebreak',
code: LINEBREAK,
},
'enter': {
type: 'headingbreak',
code: HEADINGBREAK
}
};
export const ENTER_LIST = {
[OL_LIST]: true,
[UL_LIST]: true,
};
export const ENTER_BLOCK = {
[BLOCK_QUOTE]: true,
...ENTER_LIST
};
export const formattingHotKeys = ['mod+b', 'mod+i', 'mod+shift+7', 'mod+shift+8', 'mod+shift+9', 'mod+shift+.', 'mod+shift+g', 'mod+k', 'mod+enter', 'shift+enter', 'enter'];
export const ENTER = 'enter';
export const ENTER_SHIFT = 'shift+enter';
export default HOTKEYS;