Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/slate/keyboard/actions.ts
1697 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
/*
7
Keyboard shortcuts related to our redux actions.
8
*/
9
10
import { register } from "./register";
11
12
register(
13
[
14
{ key: "s", ctrl: true },
15
{ key: "s", meta: true },
16
],
17
({ extra }) => {
18
extra?.actions.save?.(true);
19
return true;
20
}
21
);
22
23
register(
24
[
25
{ key: ",", ctrl: true, shift: true },
26
{ key: ",", meta: true, shift: true },
27
],
28
({ extra }) => {
29
extra?.actions.change_font_size?.(-1);
30
return true;
31
}
32
);
33
34
register(
35
[
36
{ key: ".", ctrl: true, shift: true },
37
{ key: ".", meta: true, shift: true },
38
],
39
({ extra }) => {
40
extra?.actions.change_font_size?.(+1);
41
return true;
42
}
43
);
44
45
register(
46
[
47
{ key: "z", meta: true },
48
{ key: "z", ctrl: true },
49
],
50
({ editor, extra }) => {
51
if (extra == null) return false;
52
if (extra.actions.undo != null) {
53
editor.saveValue(true);
54
extra.actions.undo(extra.id);
55
}
56
editor.resetHasUnsavedChanges();
57
//ReactEditor.focus(editor);
58
return true;
59
}
60
);
61
62
register(
63
[
64
{ key: "z", meta: true, shift: true },
65
{ key: "z", ctrl: true, shift: true },
66
],
67
({ editor, extra }) => {
68
if (extra == null) return false;
69
if (extra.actions.redo != null) {
70
editor.saveValue(true);
71
extra.actions.redo(extra.id);
72
}
73
editor.resetHasUnsavedChanges();
74
//ReactEditor.focus(editor);
75
return true;
76
}
77
);
78
79