-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathactions.ts
88 lines (80 loc) · 2.28 KB
/
actions.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import * as monaco from "monaco-editor/esm/vs/editor/editor.api.js";
import {Nullable} from "../typings/common";
enum ACTION_NAME {
SPECIFIC_PAGE = "specificPage",
FIRST_PAGE = "firstPage",
PREV_PAGE = "prevPage",
NEXT_PAGE = "nextPage",
LAST_PAGE = "lastPage",
PAGE_TOP = "pageTop",
PAGE_BOTTOM = "pageBottom"
}
type EditorAction = {
actionName: Nullable<ACTION_NAME>,
label: string,
keyBindings: monaco.KeyCode[],
}
/**
* Actions that can be performed in the editor. Actions without a name are not triggered by Monaco
* but will be displayed in a help dialog.
*/
/* eslint-disable sort-keys */
const EDITOR_ACTIONS : EditorAction[] = [
{
actionName: null,
label: "Focus on Editor",
keyBindings: [monaco.KeyCode.Backquote],
},
{
actionName: ACTION_NAME.FIRST_PAGE,
label: "First page",
keyBindings: [monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.BracketLeft],
},
{
actionName: ACTION_NAME.PREV_PAGE,
label: "Previous page",
keyBindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.BracketLeft],
},
{
actionName: ACTION_NAME.NEXT_PAGE,
label: "Next page",
keyBindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.BracketRight],
},
{
actionName: ACTION_NAME.LAST_PAGE,
label: "Last page",
keyBindings: [monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.BracketRight],
},
{
actionName: ACTION_NAME.PAGE_TOP,
label: "Top of page",
keyBindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyU],
},
{
actionName: ACTION_NAME.PAGE_BOTTOM,
label: "Bottom of page",
keyBindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyI],
},
];
/* eslint-enable sort-keys */
type NavigationActionsMap = {
[ACTION_NAME.SPECIFIC_PAGE]: {
pageNum: number,
},
[ACTION_NAME.FIRST_PAGE]: null,
[ACTION_NAME.PREV_PAGE]: null,
[ACTION_NAME.NEXT_PAGE]: null,
[ACTION_NAME.LAST_PAGE]: null,
};
type NavigationAction = {
[T in keyof NavigationActionsMap]:
{ code: T, args: NavigationActionsMap[T] }
} [keyof NavigationActionsMap];
export {
ACTION_NAME,
EDITOR_ACTIONS,
};
export type {
EditorAction,
NavigationAction,
};