@hyperframes/studio 0.8.229 → 0.8.231
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{hyperframes-player-CtwXT8nW.js → hyperframes-player-ClW2l0Vl.js} +1 -1
- package/dist/assets/{index-CNO8BPjF.js → index-CGfRmZQd.js} +1 -1
- package/dist/assets/{index-CrRO-B3w.js → index-DxWNzvQJ.js} +187 -187
- package/dist/index.d.ts +73 -2
- package/dist/index.html +1 -1
- package/dist/index.js +2475 -2228
- package/package.json +8 -8
- package/src/captions/components/CaptionOverlay.tsx +7 -14
- package/src/captions/keyboard.test.ts +12 -1
- package/src/captions/keyboard.ts +8 -8
- package/src/components/EditorShell.tsx +2 -1
- package/src/components/TimelineToolPicker.tsx +6 -4
- package/src/components/TimelineToolbar.tsx +22 -18
- package/src/components/editor/GestureRecordControl.tsx +8 -3
- package/src/components/editor/InspectorHeaderActions.tsx +3 -1
- package/src/components/editor/PropertyPanelFlatFooter.tsx +3 -1
- package/src/components/editor/PropertyPanelFlatHeader.tsx +3 -1
- package/src/components/editor/SnapToolbar.tsx +11 -5
- package/src/components/editor/domEditNudge.test.ts +17 -1
- package/src/components/editor/domEditNudge.ts +16 -13
- package/src/components/editor/marqueeCommit.ts +2 -1
- package/src/hooks/appHotkeysDispatch.ts +104 -118
- package/src/hooks/linkShortcuts.test.ts +20 -0
- package/src/hooks/linkShortcuts.ts +11 -11
- package/src/hooks/useAppHotkeys.test.ts +201 -0
- package/src/hooks/useAppHotkeys.ts +1 -4
- package/src/hooks/useAutomationSelectionKeyboard.ts +7 -18
- package/src/hooks/useKeyframeKeyboard.ts +2 -3
- package/src/hooks/useTimelineDeleteOps.ts +2 -1
- package/src/index.ts +9 -1
- package/src/player/components/BeatStrip.tsx +2 -1
- package/src/player/components/ClipContextMenu.tsx +9 -6
- package/src/player/components/PlayerControls.tsx +3 -2
- package/src/player/components/ShortcutsPanel.tsx +3 -2
- package/src/player/components/TimelineClipFades.tsx +2 -1
- package/src/player/components/clipMenuLinkItems.tsx +5 -4
- package/src/player/components/studioCombo.test.ts +99 -0
- package/src/player/components/studioCombo.ts +108 -0
- package/src/player/components/studioShortcuts.test.tsx +124 -0
- package/src/player/components/studioShortcuts.ts +245 -96
- package/src/player/components/timelineClipDragGestureLifecycle.ts +2 -1
- package/src/player/components/timelineEditing.ts +2 -2
- package/src/player/components/useTimelineClipDrag.ts +2 -1
- package/src/player/components/useTimelineKeyboardActor.ts +7 -18
- package/src/player/components/useTimelineKeyframeHandlers.ts +2 -1
- package/src/player/components/useTimelineRangeSelection.ts +3 -2
- package/src/player/hooks/usePlaybackKeyboard.test.ts +164 -4
- package/src/player/hooks/usePlaybackKeyboard.ts +94 -102
- package/src/player/hooks/useShadowPreviewReload.ts +11 -4
- package/src/player/hooks/useShadowReloadRetry.ts +68 -0
- package/src/player/hooks/useTimelinePlayer.shadowRetry.test.ts +85 -0
- package/src/player/hooks/useTimelinePlayer.test.ts +19 -13
- package/src/player/lib/playbackShortcuts.ts +16 -7
|
@@ -1,12 +1,153 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
import {
|
|
3
|
+
type ComboEvent,
|
|
4
|
+
comboClashKey,
|
|
5
|
+
comboText,
|
|
6
|
+
formatCombo,
|
|
7
|
+
matchCombo,
|
|
8
|
+
parseCombo,
|
|
9
|
+
} from "./studioCombo";
|
|
10
|
+
|
|
11
|
+
/** Every single-character bare key Studio answers, by action. */
|
|
12
|
+
export const DEFAULT_STUDIO_KEYS = {
|
|
3
13
|
fullscreen: "f",
|
|
4
14
|
split: "s",
|
|
5
15
|
record: "r",
|
|
6
16
|
addKeyframe: "k",
|
|
7
17
|
audioGain: "g",
|
|
8
18
|
zoomSelection: "z",
|
|
9
|
-
|
|
19
|
+
mute: "m",
|
|
20
|
+
pause: "k",
|
|
21
|
+
shuttleBack: "j",
|
|
22
|
+
shuttleForward: "l",
|
|
23
|
+
inPoint: "i",
|
|
24
|
+
outPoint: "o",
|
|
25
|
+
seekToIn: "a",
|
|
26
|
+
seekToOut: "e",
|
|
27
|
+
selectTool: "v",
|
|
28
|
+
razorTool: "b",
|
|
29
|
+
selectLeftward: "[",
|
|
30
|
+
selectRightward: "]",
|
|
31
|
+
exitRazor: "a",
|
|
32
|
+
snap: "s",
|
|
33
|
+
grid: "g",
|
|
34
|
+
timelineSnap: "n",
|
|
35
|
+
playPause: "Space",
|
|
36
|
+
frameBack: "ArrowLeft",
|
|
37
|
+
frameForward: "ArrowRight",
|
|
38
|
+
frameBackTen: "shift+ArrowLeft",
|
|
39
|
+
frameForwardTen: "shift+ArrowRight",
|
|
40
|
+
loop: "shift+l",
|
|
41
|
+
clearInPoint: "shift+i",
|
|
42
|
+
clearOutPoint: "shift+o",
|
|
43
|
+
undo: "mod+z",
|
|
44
|
+
redo: "mod+shift+z",
|
|
45
|
+
redoAlt: "ctrl+y",
|
|
46
|
+
tabCompositions: "mod+1",
|
|
47
|
+
tabAssets: "mod+2",
|
|
48
|
+
group: "mod+g",
|
|
49
|
+
ungroup: "mod+shift+g",
|
|
50
|
+
copy: "mod+c",
|
|
51
|
+
paste: "mod+v",
|
|
52
|
+
cut: "mod+x",
|
|
53
|
+
duplicate: "mod+d",
|
|
54
|
+
linkToggle: "mod+l",
|
|
55
|
+
detachAudio: "alt+shift+d",
|
|
56
|
+
deleteLinked: "alt+Backspace",
|
|
57
|
+
deleteLinkedAlt: "alt+Delete",
|
|
58
|
+
deleteSelected: "Delete",
|
|
59
|
+
deleteSelectedAlt: "Backspace",
|
|
60
|
+
resetKeyframes: "Backspace",
|
|
61
|
+
nudgeLeft: "ArrowLeft",
|
|
62
|
+
nudgeRight: "ArrowRight",
|
|
63
|
+
nudgeUp: "ArrowUp",
|
|
64
|
+
nudgeDown: "ArrowDown",
|
|
65
|
+
nudgeLeftTen: "shift+ArrowLeft",
|
|
66
|
+
nudgeRightTen: "shift+ArrowRight",
|
|
67
|
+
nudgeUpTen: "shift+ArrowUp",
|
|
68
|
+
nudgeDownTen: "shift+ArrowDown",
|
|
69
|
+
captionSelectAll: "mod+a",
|
|
70
|
+
pickupClip: "Space",
|
|
71
|
+
pickupUp: "ArrowUp",
|
|
72
|
+
pickupDown: "ArrowDown",
|
|
73
|
+
pickupDrop: "Enter",
|
|
74
|
+
cancel: "Escape",
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type StudioKeyAction = keyof typeof DEFAULT_STUDIO_KEYS;
|
|
78
|
+
export type StudioKeys = Readonly<Record<StudioKeyAction, string>>;
|
|
79
|
+
|
|
80
|
+
const SHARED_BY_DESIGN: ReadonlyArray<readonly [StudioKeyAction, StudioKeyAction]> = [
|
|
81
|
+
["pause", "addKeyframe"],
|
|
82
|
+
["seekToIn", "exitRazor"],
|
|
83
|
+
["split", "snap"],
|
|
84
|
+
["audioGain", "grid"],
|
|
85
|
+
["playPause", "pickupClip"],
|
|
86
|
+
["frameBack", "nudgeLeft"],
|
|
87
|
+
["frameForward", "nudgeRight"],
|
|
88
|
+
["frameBackTen", "nudgeLeftTen"],
|
|
89
|
+
["frameForwardTen", "nudgeRightTen"],
|
|
90
|
+
["nudgeUp", "pickupUp"],
|
|
91
|
+
["nudgeDown", "pickupDown"],
|
|
92
|
+
["deleteSelectedAlt", "resetKeyframes"],
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
let current: StudioKeys = DEFAULT_STUDIO_KEYS;
|
|
96
|
+
const listeners = new Set<() => void>();
|
|
97
|
+
|
|
98
|
+
const sharedByDesign = (a: StudioKeyAction, b: StudioKeyAction) =>
|
|
99
|
+
SHARED_BY_DESIGN.some(([x, y]) => (x === a && y === b) || (x === b && y === a));
|
|
100
|
+
|
|
101
|
+
function findClash(keys: StudioKeys): string | null {
|
|
102
|
+
const actions = Object.keys(keys) as StudioKeyAction[];
|
|
103
|
+
const clashKey = (action: StudioKeyAction) => comboClashKey(parseCombo(keys[action])!);
|
|
104
|
+
for (const [i, a] of actions.entries()) {
|
|
105
|
+
for (const b of actions.slice(i + 1)) {
|
|
106
|
+
if (clashKey(a) === clashKey(b) && !sharedByDesign(a, b))
|
|
107
|
+
return `${a} and ${b} both on "${keys[a]}"`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function resolve(overrides: Partial<Record<StudioKeyAction, string>>): StudioKeys {
|
|
114
|
+
const next: Record<string, string> = { ...DEFAULT_STUDIO_KEYS };
|
|
115
|
+
for (const [action, text] of Object.entries(overrides)) {
|
|
116
|
+
const combo = typeof text === "string" ? parseCombo(text) : null;
|
|
117
|
+
if (!Object.hasOwn(DEFAULT_STUDIO_KEYS, action) || !combo) {
|
|
118
|
+
console.warn(
|
|
119
|
+
`Studio keys: using defaults, "${action}" is not a known action with a valid combo`,
|
|
120
|
+
);
|
|
121
|
+
return DEFAULT_STUDIO_KEYS;
|
|
122
|
+
}
|
|
123
|
+
next[action] = comboText(combo);
|
|
124
|
+
}
|
|
125
|
+
const clash = findClash(next as StudioKeys);
|
|
126
|
+
if (!clash) return next as StudioKeys;
|
|
127
|
+
console.warn(`Studio keys: using defaults, ${clash}`);
|
|
128
|
+
return DEFAULT_STUDIO_KEYS;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Replaces the host key map; a bad map is refused whole. null restores the defaults. */
|
|
132
|
+
export function setStudioKeys(overrides: Partial<Record<StudioKeyAction, string>> | null) {
|
|
133
|
+
current = overrides ? resolve(overrides) : DEFAULT_STUDIO_KEYS;
|
|
134
|
+
for (const listener of listeners) listener();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export const getStudioKeys = (): StudioKeys => current;
|
|
138
|
+
export const getStudioKey = (action: StudioKeyAction): string => current[action];
|
|
139
|
+
|
|
140
|
+
function subscribe(listener: () => void) {
|
|
141
|
+
listeners.add(listener);
|
|
142
|
+
return () => listeners.delete(listener);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const useStudioKeys = (): StudioKeys => useSyncExternalStore(subscribe, getStudioKeys);
|
|
146
|
+
|
|
147
|
+
export function useShortcutSections(host?: readonly ShortcutSection[]): readonly ShortcutSection[] {
|
|
148
|
+
const keys = useStudioKeys();
|
|
149
|
+
return host ?? buildShortcutSections(keys);
|
|
150
|
+
}
|
|
10
151
|
|
|
11
152
|
export interface ShortcutHint {
|
|
12
153
|
key: string;
|
|
@@ -18,96 +159,104 @@ export interface ShortcutSection {
|
|
|
18
159
|
hints: readonly ShortcutHint[];
|
|
19
160
|
}
|
|
20
161
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export
|
|
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
|
-
]
|
|
162
|
+
export const keyHint = (action: StudioKeyAction, keys: StudioKeys = current) =>
|
|
163
|
+
formatCombo(parseCombo(keys[action])!);
|
|
164
|
+
|
|
165
|
+
export const matchesKey = (e: ComboEvent, action: StudioKeyAction) =>
|
|
166
|
+
matchCombo(e, parseCombo(current[action])!);
|
|
167
|
+
|
|
168
|
+
export function buildShortcutSections(keys: StudioKeys): readonly ShortcutSection[] {
|
|
169
|
+
const k = (action: StudioKeyAction) => keyHint(action, keys);
|
|
170
|
+
return [
|
|
171
|
+
{
|
|
172
|
+
title: "Playback",
|
|
173
|
+
hints: [
|
|
174
|
+
{ key: k("playPause"), label: "Play / Pause" },
|
|
175
|
+
{ key: k("shuttleBack"), label: "Play backward" },
|
|
176
|
+
{ key: k("pause"), label: "Stop" },
|
|
177
|
+
{ key: k("shuttleForward"), label: "Play forward" },
|
|
178
|
+
{ key: k("mute"), label: "Toggle mute" },
|
|
179
|
+
{ key: k("loop"), label: "Toggle loop" },
|
|
180
|
+
{ key: `${k("frameBack")}/${k("frameForward")}`, label: "Step 1 frame" },
|
|
181
|
+
{ key: `${k("frameBackTen")}/${k("frameForwardTen")}`, label: "Step 10 frames" },
|
|
182
|
+
{ key: k("fullscreen"), label: "Toggle fullscreen" },
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
title: "Keyframes (when an element is selected)",
|
|
187
|
+
hints: [
|
|
188
|
+
{ key: k("addKeyframe"), label: "Add / remove keyframe at playhead" },
|
|
189
|
+
{ key: k("deleteSelected"), label: "Delete selected keyframe" },
|
|
190
|
+
{ key: k("record"), label: "Record gesture" },
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
title: "Editing",
|
|
195
|
+
hints: [
|
|
196
|
+
{ key: k("undo"), label: "Undo" },
|
|
197
|
+
{ key: k("redo"), label: "Redo" },
|
|
198
|
+
{ key: k("copy"), label: "Copy element" },
|
|
199
|
+
{ key: k("paste"), label: "Paste element" },
|
|
200
|
+
{ key: k("cut"), label: "Cut element" },
|
|
201
|
+
{ key: k("split"), label: "Split clip at playhead" },
|
|
202
|
+
{ key: k("zoomSelection"), label: "Zoom timeline to selected clips" },
|
|
203
|
+
{ key: k("audioGain"), label: "Audio Gain for clips with sound" },
|
|
204
|
+
{ key: "⇧Click", label: "Razor tool: split all tracks" },
|
|
205
|
+
{ key: k("selectLeftward"), label: "Select clips starting before the playhead" },
|
|
206
|
+
{ key: k("selectRightward"), label: "Select clips running at or after the playhead" },
|
|
207
|
+
{ key: k("group"), label: "Group elements" },
|
|
208
|
+
{ key: k("ungroup"), label: "Ungroup" },
|
|
209
|
+
{ key: k("deleteSelected"), label: "Delete selected element (no keyframe selected)" },
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
title: "Gesture recording modifiers",
|
|
214
|
+
hints: [
|
|
215
|
+
{ key: "Drag", label: "Record x / y position" },
|
|
216
|
+
{ key: "Scroll", label: "Record z depth" },
|
|
217
|
+
{ key: "⇧ Drag", label: "Record rotationX / rotationY" },
|
|
218
|
+
{ key: "⌥ Drag", label: "Record rotation" },
|
|
219
|
+
{ key: "⌘ Drag↕", label: "Record opacity" },
|
|
220
|
+
{ key: "⌘ Scroll", label: "Record scale" },
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
title: "Canvas",
|
|
225
|
+
hints: [
|
|
226
|
+
{ key: "Drag", label: "Move element / add keyframe" },
|
|
227
|
+
{ key: "⌥ Drag", label: "Move entire animation path" },
|
|
228
|
+
{ key: "⇧ Drag", label: "Uniform resize" },
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
title: "Crop",
|
|
233
|
+
hints: [
|
|
234
|
+
{ key: "Drag edge", label: "Crop a side" },
|
|
235
|
+
{ key: "Drag center", label: "Reposition the crop" },
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
title: "Panels",
|
|
240
|
+
hints: [
|
|
241
|
+
{ key: k("tabCompositions"), label: "Compositions tab" },
|
|
242
|
+
{ key: k("tabAssets"), label: "Assets tab" },
|
|
243
|
+
],
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
title: "Work area",
|
|
247
|
+
hints: [
|
|
248
|
+
{ key: k("inPoint"), label: "Set in-point" },
|
|
249
|
+
{ key: k("clearInPoint"), label: "Clear in-point" },
|
|
250
|
+
{ key: k("outPoint"), label: "Set out-point" },
|
|
251
|
+
{ key: k("clearOutPoint"), label: "Clear out-point" },
|
|
252
|
+
{ key: k("seekToIn"), label: "Jump to in-point" },
|
|
253
|
+
{ key: k("seekToOut"), label: "Jump to out-point" },
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export const getShortcutSections = () => buildShortcutSections(current);
|
|
260
|
+
|
|
261
|
+
export const DEFAULT_SHORTCUT_SECTIONS: readonly ShortcutSection[] =
|
|
262
|
+
buildShortcutSections(DEFAULT_STUDIO_KEYS);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TimelineTrackInsertLayout } from "./timelineTrackInsertLayout";
|
|
2
|
+
import { matchesKey } from "./studioShortcuts";
|
|
2
3
|
import type { Dispatch, RefObject, SetStateAction } from "react";
|
|
3
4
|
import { resolveTimelineDragEscape } from "./timelineEditing";
|
|
4
5
|
import { commitDraggedClipMove } from "./timelineClipDragCommit";
|
|
@@ -407,7 +408,7 @@ export function mountTimelineClipDragGestureLifecycle({
|
|
|
407
408
|
|
|
408
409
|
const handleWindowKeyDown = (event: KeyboardEvent) => {
|
|
409
410
|
const decision = resolveTimelineDragEscape({
|
|
410
|
-
|
|
411
|
+
cancelPressed: matchesKey(event, "cancel"),
|
|
411
412
|
drag: draggedClipRef.current,
|
|
412
413
|
resize: resizingClipRef.current,
|
|
413
414
|
blocked: blockedClipRef.current,
|
|
@@ -555,7 +555,7 @@ export function resolveTimelineDragEscape(input: TimelineDragEscapeInput): {
|
|
|
555
555
|
cancel: boolean;
|
|
556
556
|
suppressClick: boolean;
|
|
557
557
|
} {
|
|
558
|
-
if (input.
|
|
558
|
+
if (!input.cancelPressed || (!input.drag && !input.resize && !input.blocked)) {
|
|
559
559
|
return { cancel: false, suppressClick: false };
|
|
560
560
|
}
|
|
561
561
|
return {
|
|
@@ -565,7 +565,7 @@ export function resolveTimelineDragEscape(input: TimelineDragEscapeInput): {
|
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
export interface TimelineDragEscapeInput {
|
|
568
|
-
|
|
568
|
+
cancelPressed: boolean;
|
|
569
569
|
drag: { started: boolean } | null;
|
|
570
570
|
resize: { started: boolean } | null;
|
|
571
571
|
blocked: { started: boolean } | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useRef, useState, useCallback, useMemo, useEffect } from "react";
|
|
2
|
+
import { matchesKey } from "./studioShortcuts";
|
|
2
3
|
import { useMountEffect } from "../../hooks/useMountEffect";
|
|
3
4
|
import { markTimelineMotion } from "./timelineMotion";
|
|
4
5
|
import {
|
|
@@ -546,7 +547,7 @@ export function useTimelineClipDrag({
|
|
|
546
547
|
return;
|
|
547
548
|
}
|
|
548
549
|
if (resizingClipRef.current) return;
|
|
549
|
-
if (event
|
|
550
|
+
if (!matchesKey(event, "pickupClip") || event.repeat) return;
|
|
550
551
|
if (viewport) pickup(event, viewport);
|
|
551
552
|
};
|
|
552
553
|
window.addEventListener("keydown", handleKeyDown, true);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback, useMemo, type FocusEvent, type KeyboardEvent, type RefObject } from "react";
|
|
2
|
+
import { matchesKey } from "./studioShortcuts";
|
|
2
3
|
import { usePlayerStore, type TimelineElement } from "../store/playerStore";
|
|
3
4
|
import { RULER_H, TRACK_H, type TimelineRowGeometry } from "./timelineLayout";
|
|
4
5
|
import {
|
|
@@ -24,24 +25,12 @@ type ClipPickupAction =
|
|
|
24
25
|
| { kind: "focus" }
|
|
25
26
|
| { kind: "consume" };
|
|
26
27
|
|
|
27
|
-
function clipPickupKeyboardAction(event: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return { kind: "move", step: -1 };
|
|
34
|
-
case "ArrowDown":
|
|
35
|
-
return { kind: "move", step: 1 };
|
|
36
|
-
case "Enter":
|
|
37
|
-
return { kind: event.repeat ? "focus" : "commit" };
|
|
38
|
-
case "Escape":
|
|
39
|
-
return { kind: "cancel" };
|
|
40
|
-
case " ":
|
|
41
|
-
return { kind: "consume" };
|
|
42
|
-
default:
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
28
|
+
function clipPickupKeyboardAction(event: globalThis.KeyboardEvent): ClipPickupAction | null {
|
|
29
|
+
if (matchesKey(event, "pickupUp")) return { kind: "move", step: -1 };
|
|
30
|
+
if (matchesKey(event, "pickupDown")) return { kind: "move", step: 1 };
|
|
31
|
+
if (matchesKey(event, "pickupDrop")) return { kind: event.repeat ? "focus" : "commit" };
|
|
32
|
+
if (matchesKey(event, "cancel")) return { kind: "cancel" };
|
|
33
|
+
return matchesKey(event, "pickupClip") ? { kind: "consume" } : null;
|
|
45
34
|
}
|
|
46
35
|
|
|
47
36
|
export function handleClipPickupKeyboardEvent(
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type MouseEvent as ReactMouseEvent,
|
|
4
4
|
type PointerEvent as ReactPointerEvent,
|
|
5
5
|
} from "react";
|
|
6
|
+
import { matchesKey } from "./studioShortcuts";
|
|
6
7
|
import { clipToTweenPercentage } from "../../components/editor/KeyframeNavigation";
|
|
7
8
|
import { progressAtTime, runEaseOf, timeAtProgress } from "../../utils/gsapKeyframeEases";
|
|
8
9
|
import {
|
|
@@ -451,7 +452,7 @@ export function beginTimelineKeyframeRetime(
|
|
|
451
452
|
if (actor.phase === "active" && matchesPointer(event)) cancel(actor);
|
|
452
453
|
};
|
|
453
454
|
const onKeyDown = (event: KeyboardEvent) => {
|
|
454
|
-
if (event
|
|
455
|
+
if (matchesKey(event, "cancel")) cancel(actor);
|
|
455
456
|
};
|
|
456
457
|
|
|
457
458
|
window.addEventListener("pointermove", onPointerMove, true);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useRef, useState, useCallback, useEffect } from "react";
|
|
2
|
+
import { matchesKey } from "./studioShortcuts";
|
|
2
3
|
import {
|
|
3
4
|
applyTimelineAutoScrollStep,
|
|
4
5
|
resolveTimelineAutoScrollLoopAction,
|
|
@@ -537,13 +538,13 @@ export function useTimelineRangeSelection({
|
|
|
537
538
|
// otherwise it clears any lingering multi-selection.
|
|
538
539
|
useEffect(() => {
|
|
539
540
|
const onBandEscape = (e: KeyboardEvent) => {
|
|
540
|
-
if (e
|
|
541
|
+
if (!matchesKey(e, "cancel") || !(marqueeRef.current || isRangeSelecting.current)) return;
|
|
541
542
|
e.preventDefault();
|
|
542
543
|
e.stopPropagation();
|
|
543
544
|
cancelActiveGesture(true, true);
|
|
544
545
|
};
|
|
545
546
|
const onKeyDown = (e: KeyboardEvent) => {
|
|
546
|
-
if (e
|
|
547
|
+
if (!matchesKey(e, "cancel")) return;
|
|
547
548
|
const store = usePlayerStore.getState();
|
|
548
549
|
if (isDragging.current) {
|
|
549
550
|
cancelActiveGesture(true, true);
|