@hyperframes/studio 0.8.230 → 0.9.0
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-Dv5Ew1Dr.js → hyperframes-player-z-8ElsHL.js} +1 -1
- package/dist/assets/{index-hiL49K7x.js → index-CBZs_Rm3.js} +1 -1
- package/dist/assets/{index-BvqtI0ko.js → index-M-AHqD2Z.js} +153 -153
- package/dist/index.d.ts +40 -0
- package/dist/index.html +1 -1
- package/dist/index.js +530 -432
- 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/TimelineToolbar.tsx +2 -3
- package/src/components/editor/InspectorHeaderActions.tsx +3 -1
- package/src/components/editor/PropertyPanelFlatHeader.tsx +3 -1
- package/src/components/editor/SnapToolbar.tsx +3 -3
- 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 +94 -107
- package/src/hooks/linkShortcuts.test.ts +20 -0
- package/src/hooks/linkShortcuts.ts +11 -11
- package/src/hooks/useAppHotkeys.test.ts +143 -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/player/components/BeatStrip.tsx +2 -1
- package/src/player/components/ClipContextMenu.tsx +3 -3
- 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 +16 -1
- package/src/player/components/studioShortcuts.ts +85 -29
- 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 +87 -4
- package/src/player/hooks/usePlaybackKeyboard.ts +78 -82
- package/src/player/hooks/useTimelinePlayer.test.ts +19 -13
- package/src/player/lib/playbackShortcuts.ts +13 -16
|
@@ -66,7 +66,7 @@ describe("studio key resolver", () => {
|
|
|
66
66
|
expect(hintFor("Toggle loop")).toBe("⇧L");
|
|
67
67
|
setStudioKeys({ shuttleForward: "y" });
|
|
68
68
|
expect(hintFor("Play forward")).toBe("Y");
|
|
69
|
-
expect(hintFor("Toggle loop")).toBe("⇧
|
|
69
|
+
expect(hintFor("Toggle loop")).toBe("⇧L");
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
it("refuses a map that binds two actions to one key and keeps every default", () => {
|
|
@@ -107,3 +107,18 @@ describe("studio key resolver", () => {
|
|
|
107
107
|
act(() => root.unmount());
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
|
+
|
|
111
|
+
describe("lists follow combos", () => {
|
|
112
|
+
it("shows the remapped combos and keeps today's default text", () => {
|
|
113
|
+
expect(hintFor("Undo")).toBe("⌘Z");
|
|
114
|
+
expect(hintFor("Redo")).toBe("⌘⇧Z");
|
|
115
|
+
expect(hintFor("Play / Pause")).toBe("Space");
|
|
116
|
+
expect(hintFor("Step 1 frame")).toBe("←/→");
|
|
117
|
+
expect(hintFor("Step 10 frames")).toBe("⇧←/⇧→");
|
|
118
|
+
expect(hintFor("Toggle loop")).toBe("⇧L");
|
|
119
|
+
setStudioKeys({ undo: "mod+u", playPause: "p", frameBack: "y", frameForward: "u" });
|
|
120
|
+
expect(hintFor("Undo")).toBe("⌘U");
|
|
121
|
+
expect(hintFor("Play / Pause")).toBe("P");
|
|
122
|
+
expect(hintFor("Step 1 frame")).toBe("Y/U");
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { useSyncExternalStore } from "react";
|
|
2
|
+
import {
|
|
3
|
+
type ComboEvent,
|
|
4
|
+
comboClashKey,
|
|
5
|
+
comboText,
|
|
6
|
+
formatCombo,
|
|
7
|
+
matchCombo,
|
|
8
|
+
parseCombo,
|
|
9
|
+
} from "./studioCombo";
|
|
2
10
|
|
|
3
11
|
/** Every single-character bare key Studio answers, by action. */
|
|
4
12
|
export const DEFAULT_STUDIO_KEYS = {
|
|
@@ -24,6 +32,46 @@ export const DEFAULT_STUDIO_KEYS = {
|
|
|
24
32
|
snap: "s",
|
|
25
33
|
grid: "g",
|
|
26
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",
|
|
27
75
|
};
|
|
28
76
|
|
|
29
77
|
export type StudioKeyAction = keyof typeof DEFAULT_STUDIO_KEYS;
|
|
@@ -34,6 +82,14 @@ const SHARED_BY_DESIGN: ReadonlyArray<readonly [StudioKeyAction, StudioKeyAction
|
|
|
34
82
|
["seekToIn", "exitRazor"],
|
|
35
83
|
["split", "snap"],
|
|
36
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"],
|
|
37
93
|
];
|
|
38
94
|
|
|
39
95
|
let current: StudioKeys = DEFAULT_STUDIO_KEYS;
|
|
@@ -44,9 +100,11 @@ const sharedByDesign = (a: StudioKeyAction, b: StudioKeyAction) =>
|
|
|
44
100
|
|
|
45
101
|
function findClash(keys: StudioKeys): string | null {
|
|
46
102
|
const actions = Object.keys(keys) as StudioKeyAction[];
|
|
103
|
+
const clashKey = (action: StudioKeyAction) => comboClashKey(parseCombo(keys[action])!);
|
|
47
104
|
for (const [i, a] of actions.entries()) {
|
|
48
105
|
for (const b of actions.slice(i + 1)) {
|
|
49
|
-
if (
|
|
106
|
+
if (clashKey(a) === clashKey(b) && !sharedByDesign(a, b))
|
|
107
|
+
return `${a} and ${b} both on "${keys[a]}"`;
|
|
50
108
|
}
|
|
51
109
|
}
|
|
52
110
|
return null;
|
|
@@ -54,18 +112,15 @@ function findClash(keys: StudioKeys): string | null {
|
|
|
54
112
|
|
|
55
113
|
function resolve(overrides: Partial<Record<StudioKeyAction, string>>): StudioKeys {
|
|
56
114
|
const next: Record<string, string> = { ...DEFAULT_STUDIO_KEYS };
|
|
57
|
-
for (const [action,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
typeof key !== "string" ||
|
|
61
|
-
[...key].length !== 1
|
|
62
|
-
) {
|
|
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) {
|
|
63
118
|
console.warn(
|
|
64
|
-
`Studio keys: using defaults, "${action}" is not a known action with
|
|
119
|
+
`Studio keys: using defaults, "${action}" is not a known action with a valid combo`,
|
|
65
120
|
);
|
|
66
121
|
return DEFAULT_STUDIO_KEYS;
|
|
67
122
|
}
|
|
68
|
-
next[action] =
|
|
123
|
+
next[action] = comboText(combo);
|
|
69
124
|
}
|
|
70
125
|
const clash = findClash(next as StudioKeys);
|
|
71
126
|
if (!clash) return next as StudioKeys;
|
|
@@ -104,10 +159,11 @@ export interface ShortcutSection {
|
|
|
104
159
|
hints: readonly ShortcutHint[];
|
|
105
160
|
}
|
|
106
161
|
|
|
107
|
-
const hintKey = (key: string) => key.toUpperCase();
|
|
108
|
-
|
|
109
162
|
export const keyHint = (action: StudioKeyAction, keys: StudioKeys = current) =>
|
|
110
|
-
|
|
163
|
+
formatCombo(parseCombo(keys[action])!);
|
|
164
|
+
|
|
165
|
+
export const matchesKey = (e: ComboEvent, action: StudioKeyAction) =>
|
|
166
|
+
matchCombo(e, parseCombo(current[action])!);
|
|
111
167
|
|
|
112
168
|
export function buildShortcutSections(keys: StudioKeys): readonly ShortcutSection[] {
|
|
113
169
|
const k = (action: StudioKeyAction) => keyHint(action, keys);
|
|
@@ -115,14 +171,14 @@ export function buildShortcutSections(keys: StudioKeys): readonly ShortcutSectio
|
|
|
115
171
|
{
|
|
116
172
|
title: "Playback",
|
|
117
173
|
hints: [
|
|
118
|
-
{ key: "
|
|
174
|
+
{ key: k("playPause"), label: "Play / Pause" },
|
|
119
175
|
{ key: k("shuttleBack"), label: "Play backward" },
|
|
120
176
|
{ key: k("pause"), label: "Stop" },
|
|
121
177
|
{ key: k("shuttleForward"), label: "Play forward" },
|
|
122
178
|
{ key: k("mute"), label: "Toggle mute" },
|
|
123
|
-
{ key:
|
|
124
|
-
{ key: "
|
|
125
|
-
{ key: "
|
|
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" },
|
|
126
182
|
{ key: k("fullscreen"), label: "Toggle fullscreen" },
|
|
127
183
|
],
|
|
128
184
|
},
|
|
@@ -130,27 +186,27 @@ export function buildShortcutSections(keys: StudioKeys): readonly ShortcutSectio
|
|
|
130
186
|
title: "Keyframes (when an element is selected)",
|
|
131
187
|
hints: [
|
|
132
188
|
{ key: k("addKeyframe"), label: "Add / remove keyframe at playhead" },
|
|
133
|
-
{ key: "
|
|
189
|
+
{ key: k("deleteSelected"), label: "Delete selected keyframe" },
|
|
134
190
|
{ key: k("record"), label: "Record gesture" },
|
|
135
191
|
],
|
|
136
192
|
},
|
|
137
193
|
{
|
|
138
194
|
title: "Editing",
|
|
139
195
|
hints: [
|
|
140
|
-
{ key: "
|
|
141
|
-
{ key: "
|
|
142
|
-
{ key: "
|
|
143
|
-
{ key: "
|
|
144
|
-
{ key: "
|
|
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" },
|
|
145
201
|
{ key: k("split"), label: "Split clip at playhead" },
|
|
146
202
|
{ key: k("zoomSelection"), label: "Zoom timeline to selected clips" },
|
|
147
203
|
{ key: k("audioGain"), label: "Audio Gain for clips with sound" },
|
|
148
204
|
{ key: "⇧Click", label: "Razor tool: split all tracks" },
|
|
149
205
|
{ key: k("selectLeftward"), label: "Select clips starting before the playhead" },
|
|
150
206
|
{ key: k("selectRightward"), label: "Select clips running at or after the playhead" },
|
|
151
|
-
{ key: "
|
|
152
|
-
{ key: "
|
|
153
|
-
{ key: "
|
|
207
|
+
{ key: k("group"), label: "Group elements" },
|
|
208
|
+
{ key: k("ungroup"), label: "Ungroup" },
|
|
209
|
+
{ key: k("deleteSelected"), label: "Delete selected element (no keyframe selected)" },
|
|
154
210
|
],
|
|
155
211
|
},
|
|
156
212
|
{
|
|
@@ -182,17 +238,17 @@ export function buildShortcutSections(keys: StudioKeys): readonly ShortcutSectio
|
|
|
182
238
|
{
|
|
183
239
|
title: "Panels",
|
|
184
240
|
hints: [
|
|
185
|
-
{ key: "
|
|
186
|
-
{ key: "
|
|
241
|
+
{ key: k("tabCompositions"), label: "Compositions tab" },
|
|
242
|
+
{ key: k("tabAssets"), label: "Assets tab" },
|
|
187
243
|
],
|
|
188
244
|
},
|
|
189
245
|
{
|
|
190
246
|
title: "Work area",
|
|
191
247
|
hints: [
|
|
192
248
|
{ key: k("inPoint"), label: "Set in-point" },
|
|
193
|
-
{ key:
|
|
249
|
+
{ key: k("clearInPoint"), label: "Clear in-point" },
|
|
194
250
|
{ key: k("outPoint"), label: "Set out-point" },
|
|
195
|
-
{ key:
|
|
251
|
+
{ key: k("clearOutPoint"), label: "Clear out-point" },
|
|
196
252
|
{ key: k("seekToIn"), label: "Jump to in-point" },
|
|
197
253
|
{ key: k("seekToOut"), label: "Jump to out-point" },
|
|
198
254
|
],
|
|
@@ -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);
|
|
@@ -76,11 +76,19 @@ function setupHook(): HookHandle {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
function keydown(init: {
|
|
79
|
+
function keydown(init: {
|
|
80
|
+
code: string;
|
|
81
|
+
key: string;
|
|
82
|
+
shiftKey?: boolean;
|
|
83
|
+
metaKey?: boolean;
|
|
84
|
+
altKey?: boolean;
|
|
85
|
+
}): KeyboardEvent {
|
|
80
86
|
return new KeyboardEvent("keydown", {
|
|
81
87
|
code: init.code,
|
|
82
88
|
key: init.key,
|
|
83
89
|
shiftKey: init.shiftKey ?? false,
|
|
90
|
+
metaKey: init.metaKey ?? false,
|
|
91
|
+
altKey: init.altKey ?? false,
|
|
84
92
|
cancelable: true,
|
|
85
93
|
});
|
|
86
94
|
}
|
|
@@ -199,7 +207,7 @@ describe("usePlaybackKeyboard — keyboard layout independence (#834)", () => {
|
|
|
199
207
|
expect(spies.seek).toHaveBeenCalledWith(1.5, { keepPlaying: true });
|
|
200
208
|
});
|
|
201
209
|
|
|
202
|
-
it("Shift+A
|
|
210
|
+
it("Shift+A is a different combo from A: it neither jumps to the in-point nor exits the razor", () => {
|
|
203
211
|
const { dispatch, spies } = setupHook();
|
|
204
212
|
usePlayerStore.setState({ inPoint: 1.5, activeTool: "razor" });
|
|
205
213
|
|
|
@@ -207,7 +215,8 @@ describe("usePlaybackKeyboard — keyboard layout independence (#834)", () => {
|
|
|
207
215
|
dispatch(keydown({ code: "KeyA", key: "a", shiftKey: true }));
|
|
208
216
|
});
|
|
209
217
|
|
|
210
|
-
expect(spies.seek).
|
|
218
|
+
expect(spies.seek).not.toHaveBeenCalled();
|
|
219
|
+
expect(usePlayerStore.getState().activeTool).toBe("razor");
|
|
211
220
|
});
|
|
212
221
|
});
|
|
213
222
|
|
|
@@ -369,7 +378,7 @@ describe("usePlaybackKeyboard — keys the host can remap", () => {
|
|
|
369
378
|
expect(spies.play).not.toHaveBeenCalled();
|
|
370
379
|
press(dispatch, "y");
|
|
371
380
|
expect(spies.play).toHaveBeenCalledTimes(1);
|
|
372
|
-
press(dispatch, "
|
|
381
|
+
press(dispatch, "l", true);
|
|
373
382
|
expect(usePlayerStore.getState().loopEnabled).toBe(true);
|
|
374
383
|
});
|
|
375
384
|
|
|
@@ -400,3 +409,77 @@ describe("usePlaybackKeyboard — keys the host can remap", () => {
|
|
|
400
409
|
expect(spies.seek).toHaveBeenCalledWith(3, { keepPlaying: true });
|
|
401
410
|
});
|
|
402
411
|
});
|
|
412
|
+
|
|
413
|
+
describe("usePlaybackKeyboard: space, arrows, loop and clear keys are combos", () => {
|
|
414
|
+
const send = (dispatch: HookHandle["dispatch"], init: Partial<Parameters<typeof keydown>[0]>) =>
|
|
415
|
+
act(() => {
|
|
416
|
+
dispatch(keydown({ code: "", key: "", ...init }));
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it("Space, arrows (Shift = 10), Shift+L and Shift+I answer by default", () => {
|
|
420
|
+
const { dispatch, spies } = setupHook();
|
|
421
|
+
usePlayerStore.setState({ isPlaying: false, inPoint: 1, loopEnabled: false });
|
|
422
|
+
send(dispatch, { code: "Space", key: " " });
|
|
423
|
+
expect(spies.play).toHaveBeenCalledTimes(1);
|
|
424
|
+
send(dispatch, { code: "ArrowRight", key: "ArrowRight", shiftKey: true });
|
|
425
|
+
send(dispatch, { code: "ArrowLeft", key: "ArrowLeft" });
|
|
426
|
+
expect(spies.seek).toHaveBeenCalledTimes(2);
|
|
427
|
+
send(dispatch, { code: "KeyL", key: "L", shiftKey: true });
|
|
428
|
+
expect(usePlayerStore.getState().loopEnabled).toBe(true);
|
|
429
|
+
send(dispatch, { code: "KeyI", key: "I", shiftKey: true });
|
|
430
|
+
expect(usePlayerStore.getState().inPoint).toBeNull();
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
it("a remapped key answers and the old one does not", () => {
|
|
434
|
+
setStudioKeys({
|
|
435
|
+
playPause: "p",
|
|
436
|
+
frameForward: "x",
|
|
437
|
+
loop: "mod+shift+u",
|
|
438
|
+
clearInPoint: "shift+y",
|
|
439
|
+
});
|
|
440
|
+
const { dispatch, spies } = setupHook();
|
|
441
|
+
usePlayerStore.setState({ isPlaying: false, inPoint: 1, loopEnabled: false });
|
|
442
|
+
send(dispatch, { code: "Space", key: " " });
|
|
443
|
+
send(dispatch, { code: "ArrowRight", key: "ArrowRight" });
|
|
444
|
+
send(dispatch, { code: "KeyL", key: "L", shiftKey: true });
|
|
445
|
+
send(dispatch, { code: "KeyI", key: "I", shiftKey: true });
|
|
446
|
+
expect(spies.play).not.toHaveBeenCalled();
|
|
447
|
+
expect(spies.seek).not.toHaveBeenCalled();
|
|
448
|
+
expect(usePlayerStore.getState().loopEnabled).toBe(false);
|
|
449
|
+
expect(usePlayerStore.getState().inPoint).toBe(1);
|
|
450
|
+
send(dispatch, { code: "KeyP", key: "p" });
|
|
451
|
+
expect(spies.play).toHaveBeenCalledTimes(1);
|
|
452
|
+
send(dispatch, { code: "KeyX", key: "x" });
|
|
453
|
+
expect(spies.seek).toHaveBeenCalledTimes(1);
|
|
454
|
+
send(dispatch, { code: "KeyY", key: "Y", shiftKey: true });
|
|
455
|
+
expect(usePlayerStore.getState().inPoint).toBeNull();
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
describe("usePlaybackKeyboard: modifier combos and named keys", () => {
|
|
460
|
+
const send = (dispatch: HookHandle["dispatch"], init: Parameters<typeof keydown>[0]) =>
|
|
461
|
+
act(() => {
|
|
462
|
+
dispatch(keydown(init));
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
it("a playback action remapped to a Cmd or Alt combo answers, and the plain key does not", () => {
|
|
466
|
+
setStudioKeys({ playPause: "mod+p", mute: "alt+m" });
|
|
467
|
+
const { dispatch, spies } = setupHook();
|
|
468
|
+
usePlayerStore.setState({ isPlaying: false, audioMuted: false });
|
|
469
|
+
send(dispatch, { code: "KeyP", key: "p", metaKey: true });
|
|
470
|
+
expect(spies.play).toHaveBeenCalledTimes(1);
|
|
471
|
+
send(dispatch, { code: "KeyM", key: "µ", altKey: true });
|
|
472
|
+
expect(usePlayerStore.getState().audioMuted).toBe(true);
|
|
473
|
+
send(dispatch, { code: "KeyP", key: "p" });
|
|
474
|
+
expect(spies.play).toHaveBeenCalledTimes(1);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it("holding a stop key that is a named key still frame-steps instead of shuttling", () => {
|
|
478
|
+
setStudioKeys({ pause: "Home" });
|
|
479
|
+
const { dispatch, spies } = setupHook();
|
|
480
|
+
send(dispatch, { code: "Home", key: "Home" });
|
|
481
|
+
send(dispatch, { code: "KeyJ", key: "j" });
|
|
482
|
+
expect(spies.seek).toHaveBeenCalledTimes(1);
|
|
483
|
+
expect(spies.playBackward).not.toHaveBeenCalled();
|
|
484
|
+
});
|
|
485
|
+
});
|