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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
import type { ShortcutKey } from "@/types/keybinding";
export type TActionCategory =
| "playback"
| "navigation"
| "editing"
| "selection"
| "history"
| "timeline"
| "controls";
export interface TActionDefinition {
description: string;
category: TActionCategory;
defaultShortcuts?: ShortcutKey[];
args?: Record<string, unknown>;
}
export const ACTIONS = {
"toggle-play": {
description: "Play/Pause",
category: "playback",
defaultShortcuts: ["space", "k"],
},
"stop-playback": {
description: "Stop playback",
category: "playback",
},
"seek-forward": {
description: "Seek forward 1 second",
category: "playback",
defaultShortcuts: ["l"],
args: { seconds: "number" },
},
"seek-backward": {
description: "Seek backward 1 second",
category: "playback",
defaultShortcuts: ["j"],
args: { seconds: "number" },
},
"frame-step-forward": {
description: "Frame step forward",
category: "navigation",
defaultShortcuts: ["right"],
},
"frame-step-backward": {
description: "Frame step backward",
category: "navigation",
defaultShortcuts: ["left"],
},
"jump-forward": {
description: "Jump forward 5 seconds",
category: "navigation",
defaultShortcuts: ["shift+right"],
args: { seconds: "number" },
},
"jump-backward": {
description: "Jump backward 5 seconds",
category: "navigation",
defaultShortcuts: ["shift+left"],
args: { seconds: "number" },
},
"goto-start": {
description: "Go to timeline start",
category: "navigation",
defaultShortcuts: ["home", "enter"],
},
"goto-end": {
description: "Go to timeline end",
category: "navigation",
defaultShortcuts: ["end"],
},
split: {
description: "Split elements at playhead",
category: "editing",
defaultShortcuts: ["s"],
},
"split-left": {
description: "Split and remove left",
category: "editing",
defaultShortcuts: ["q"],
},
"split-right": {
description: "Split and remove right",
category: "editing",
defaultShortcuts: ["w"],
},
"delete-selected": {
description: "Delete selected elements",
category: "editing",
defaultShortcuts: ["backspace", "delete"],
},
"copy-selected": {
description: "Copy selected elements",
category: "editing",
defaultShortcuts: ["ctrl+c"],
},
"paste-copied": {
description: "Paste elements at playhead",
category: "editing",
defaultShortcuts: ["ctrl+v"],
},
"toggle-snapping": {
description: "Toggle snapping",
category: "editing",
defaultShortcuts: ["n"],
},
"select-all": {
description: "Select all elements",
category: "selection",
defaultShortcuts: ["ctrl+a"],
},
"duplicate-selected": {
description: "Duplicate selected element",
category: "selection",
defaultShortcuts: ["ctrl+d"],
},
"toggle-elements-muted-selected": {
description: "Mute/unmute selected elements",
category: "selection",
},
"toggle-elements-visibility-selected": {
description: "Show/hide selected elements",
category: "selection",
},
"toggle-bookmark": {
description: "Toggle bookmark at playhead",
category: "timeline",
},
undo: {
description: "Undo",
category: "history",
defaultShortcuts: ["ctrl+z"],
},
redo: {
description: "Redo",
category: "history",
defaultShortcuts: ["ctrl+shift+z", "ctrl+y"],
},
} as const satisfies Record<string, TActionDefinition>;
export type TAction = keyof typeof ACTIONS;
export function getActionDefinition(action: TAction): TActionDefinition {
return ACTIONS[action];
}
export function getDefaultShortcuts(): Record<ShortcutKey, TAction> {
const shortcuts: Record<string, TAction> = {};
for (const [action, def] of Object.entries(ACTIONS) as Array<
[TAction, TActionDefinition]
>) {
if (def.defaultShortcuts) {
for (const shortcut of def.defaultShortcuts) {
shortcuts[shortcut] = action;
}
}
}
return shortcuts as Record<ShortcutKey, TAction>;
}
|