-
Notifications
You must be signed in to change notification settings - Fork 51
/
keys.ts
67 lines (61 loc) · 1.68 KB
/
keys.ts
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
import {
baseKeymap,
chainCommands,
exitCode,
joinDown,
joinUp,
lift,
selectParentNode,
} from 'prosemirror-commands'
import { redo, undo } from 'prosemirror-history'
import { undoInputRule } from 'prosemirror-inputrules'
import { keymap } from 'prosemirror-keymap'
import { Plugin } from 'prosemirror-state'
import { goToNextCell } from 'prosemirror-tables'
import {
insertNodeHorizontalRule,
insertNodeLineBreak,
liftListItemCommand,
sinkListItemCommand,
splitListItemCommand,
toggleMarkBold,
toggleMarkCode,
toggleMarkItalic,
toggleMarkUnderline,
wrapInBlockquote,
} from './commands'
export const listKeys = (): Plugin =>
keymap({
'Mod-]': sinkListItemCommand,
'Mod-[': liftListItemCommand,
Tab: sinkListItemCommand,
'Shift-Tab': liftListItemCommand,
Enter: splitListItemCommand,
})
// TODO: sink/lift headings
export const tableKeys = (): Plugin =>
keymap({
Tab: goToNextCell(1),
'Shift-Tab': goToNextCell(-1),
})
export const editorKeys = (): Plugin =>
keymap({
'Mod-z': undo,
'Shift-Mod-z': redo,
Backspace: undoInputRule,
'Mod-y': redo,
'Alt-ArrowUp': joinUp,
'Alt-ArrowDown': joinDown,
'Mod-BracketLeft': lift,
Escape: selectParentNode,
'Meta-b': toggleMarkBold,
'Meta-i': toggleMarkItalic,
'Ctrl-`': toggleMarkCode,
'Mod-u': toggleMarkUnderline,
'Ctrl->': wrapInBlockquote,
'Mod-Enter': chainCommands(exitCode, insertNodeLineBreak),
'Shift-Enter': chainCommands(exitCode, insertNodeLineBreak),
'Ctrl-Enter': chainCommands(exitCode, insertNodeLineBreak), // mac-only?
'Mod-_': insertNodeHorizontalRule,
})
export const baseKeys = (): Plugin => keymap(baseKeymap)