@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.
Files changed (53) hide show
  1. package/dist/assets/{hyperframes-player-CtwXT8nW.js → hyperframes-player-ClW2l0Vl.js} +1 -1
  2. package/dist/assets/{index-CNO8BPjF.js → index-CGfRmZQd.js} +1 -1
  3. package/dist/assets/{index-CrRO-B3w.js → index-DxWNzvQJ.js} +187 -187
  4. package/dist/index.d.ts +73 -2
  5. package/dist/index.html +1 -1
  6. package/dist/index.js +2475 -2228
  7. package/package.json +8 -8
  8. package/src/captions/components/CaptionOverlay.tsx +7 -14
  9. package/src/captions/keyboard.test.ts +12 -1
  10. package/src/captions/keyboard.ts +8 -8
  11. package/src/components/EditorShell.tsx +2 -1
  12. package/src/components/TimelineToolPicker.tsx +6 -4
  13. package/src/components/TimelineToolbar.tsx +22 -18
  14. package/src/components/editor/GestureRecordControl.tsx +8 -3
  15. package/src/components/editor/InspectorHeaderActions.tsx +3 -1
  16. package/src/components/editor/PropertyPanelFlatFooter.tsx +3 -1
  17. package/src/components/editor/PropertyPanelFlatHeader.tsx +3 -1
  18. package/src/components/editor/SnapToolbar.tsx +11 -5
  19. package/src/components/editor/domEditNudge.test.ts +17 -1
  20. package/src/components/editor/domEditNudge.ts +16 -13
  21. package/src/components/editor/marqueeCommit.ts +2 -1
  22. package/src/hooks/appHotkeysDispatch.ts +104 -118
  23. package/src/hooks/linkShortcuts.test.ts +20 -0
  24. package/src/hooks/linkShortcuts.ts +11 -11
  25. package/src/hooks/useAppHotkeys.test.ts +201 -0
  26. package/src/hooks/useAppHotkeys.ts +1 -4
  27. package/src/hooks/useAutomationSelectionKeyboard.ts +7 -18
  28. package/src/hooks/useKeyframeKeyboard.ts +2 -3
  29. package/src/hooks/useTimelineDeleteOps.ts +2 -1
  30. package/src/index.ts +9 -1
  31. package/src/player/components/BeatStrip.tsx +2 -1
  32. package/src/player/components/ClipContextMenu.tsx +9 -6
  33. package/src/player/components/PlayerControls.tsx +3 -2
  34. package/src/player/components/ShortcutsPanel.tsx +3 -2
  35. package/src/player/components/TimelineClipFades.tsx +2 -1
  36. package/src/player/components/clipMenuLinkItems.tsx +5 -4
  37. package/src/player/components/studioCombo.test.ts +99 -0
  38. package/src/player/components/studioCombo.ts +108 -0
  39. package/src/player/components/studioShortcuts.test.tsx +124 -0
  40. package/src/player/components/studioShortcuts.ts +245 -96
  41. package/src/player/components/timelineClipDragGestureLifecycle.ts +2 -1
  42. package/src/player/components/timelineEditing.ts +2 -2
  43. package/src/player/components/useTimelineClipDrag.ts +2 -1
  44. package/src/player/components/useTimelineKeyboardActor.ts +7 -18
  45. package/src/player/components/useTimelineKeyframeHandlers.ts +2 -1
  46. package/src/player/components/useTimelineRangeSelection.ts +3 -2
  47. package/src/player/hooks/usePlaybackKeyboard.test.ts +164 -4
  48. package/src/player/hooks/usePlaybackKeyboard.ts +94 -102
  49. package/src/player/hooks/useShadowPreviewReload.ts +11 -4
  50. package/src/player/hooks/useShadowReloadRetry.ts +68 -0
  51. package/src/player/hooks/useTimelinePlayer.shadowRetry.test.ts +85 -0
  52. package/src/player/hooks/useTimelinePlayer.test.ts +19 -13
  53. package/src/player/lib/playbackShortcuts.ts +16 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/studio",
3
- "version": "0.8.229",
3
+ "version": "0.8.231",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -60,12 +60,12 @@
60
60
  "dockview-react": "8.3.1",
61
61
  "gsap": "^3.13.0",
62
62
  "mediabunny": "^1.45.3",
63
- "@hyperframes/core": "0.8.229",
64
- "@hyperframes/parsers": "0.8.229",
65
- "@hyperframes/sdk": "0.8.229",
66
- "@hyperframes/shader-transitions": "0.8.229",
67
- "@hyperframes/studio-server": "0.8.229",
68
- "@hyperframes/player": "0.8.229"
63
+ "@hyperframes/parsers": "0.8.231",
64
+ "@hyperframes/shader-transitions": "0.8.231",
65
+ "@hyperframes/sdk": "0.8.231",
66
+ "@hyperframes/core": "0.8.231",
67
+ "@hyperframes/studio-server": "0.8.231",
68
+ "@hyperframes/player": "0.8.231"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@tailwindcss/vite": "^4.3.3",
@@ -82,7 +82,7 @@
82
82
  "vite": "^6.4.2",
83
83
  "vitest": "^4.1.11",
84
84
  "zustand": "^5.0.0",
85
- "@hyperframes/producer": "0.8.229"
85
+ "@hyperframes/producer": "0.8.231"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "react": "19",
@@ -2,7 +2,8 @@ import { memo, useEffect, useState, useCallback, useRef } from "react";
2
2
  import { useLivePreviewIframe } from "../../player/store/previewIframeStore";
3
3
  import { useCaptionStore } from "../store";
4
4
  import { usePlayerStore } from "../../player";
5
- import { shouldHandleCaptionNudgeKey, isEditableEventTarget } from "../keyboard";
5
+ import { resolveCaptionNudge, isEditableEventTarget } from "../keyboard";
6
+ import { matchesKey } from "../../player/components/studioShortcuts";
6
7
  import {
7
8
  readWordBoxes,
8
9
  getWordEl,
@@ -171,7 +172,7 @@ export const CaptionOverlay = memo(function CaptionOverlay({ iframeRef }: Captio
171
172
  const { selectedSegmentIds: sel, model: m } = store;
172
173
 
173
174
  // Escape: cancel an in-flight drag first, else clear the selection.
174
- if (e.key === "Escape") {
175
+ if (matchesKey(e, "cancel")) {
175
176
  if (cancelActiveDrag()) {
176
177
  e.preventDefault();
177
178
  scheduleTick();
@@ -185,28 +186,20 @@ export const CaptionOverlay = memo(function CaptionOverlay({ iframeRef }: Captio
185
186
  }
186
187
 
187
188
  // ⌘A / Ctrl+A selects every caption word (unless typing in a field).
188
- if (
189
- (e.metaKey || e.ctrlKey) &&
190
- e.key.toLowerCase() === "a" &&
191
- !e.shiftKey &&
192
- !e.altKey &&
193
- !isEditableEventTarget(e.target)
194
- ) {
189
+ if (matchesKey(e, "captionSelectAll") && !isEditableEventTarget(e.target)) {
195
190
  e.preventDefault();
196
191
  store.selectAll();
197
192
  return;
198
193
  }
199
194
 
200
195
  if (sel.size === 0 || !m) return;
201
- const arrow = e.key;
202
196
  // Pass the event target so arrows inside inputs keep their native
203
197
  // behavior instead of nudging the canvas word.
204
- if (!shouldHandleCaptionNudgeKey(e, e.target)) return;
198
+ const nudge = resolveCaptionNudge(e, e.target);
199
+ if (!nudge) return;
205
200
 
206
201
  e.preventDefault();
207
- const step = e.shiftKey ? 10 : 1;
208
- const dx = arrow === "ArrowLeft" ? -step : arrow === "ArrowRight" ? step : 0;
209
- const dy = arrow === "ArrowUp" ? -step : arrow === "ArrowDown" ? step : 0;
202
+ const { dx, dy } = nudge;
210
203
 
211
204
  const iframe = iframeRef.current;
212
205
  const win = iframe?.contentWindow;
@@ -1,6 +1,7 @@
1
1
  // @vitest-environment happy-dom
2
2
 
3
- import { describe, expect, it } from "vitest";
3
+ import { afterEach, describe, expect, it } from "vitest";
4
+ import { setStudioKeys } from "../player/components/studioShortcuts";
4
5
  import { shouldHandleCaptionNudgeKey } from "./keyboard";
5
6
 
6
7
  function mockKeyboardEvent(
@@ -60,3 +61,13 @@ describe("shouldHandleCaptionNudgeKey", () => {
60
61
  expect(shouldHandleCaptionNudgeKey(mockKeyboardEvent("ArrowRight"), player)).toBe(false);
61
62
  });
62
63
  });
64
+
65
+ describe("shouldHandleCaptionNudgeKey: remapped", () => {
66
+ afterEach(() => setStudioKeys(null));
67
+
68
+ it("follows the canvas nudge keys", () => {
69
+ setStudioKeys({ nudgeUp: "u" });
70
+ expect(shouldHandleCaptionNudgeKey(mockKeyboardEvent("ArrowUp"))).toBe(false);
71
+ expect(shouldHandleCaptionNudgeKey(mockKeyboardEvent("u"))).toBe(true);
72
+ });
73
+ });
@@ -1,18 +1,18 @@
1
1
  import { isEditableTarget } from "../utils/timelineDiscovery";
2
2
  import { ownsPlainKeys } from "../utils/typingTarget";
3
+ import { resolveCanvasNudgeDelta } from "../components/editor/domEditNudge";
3
4
 
4
- const CAPTION_NUDGE_KEYS = new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
5
+ type CaptionNudgeKeyEvent = Parameters<typeof resolveCanvasNudgeDelta>[0];
5
6
 
6
- type CaptionNudgeKeyEvent = Pick<KeyboardEvent, "altKey" | "ctrlKey" | "metaKey" | "key">;
7
+ export function resolveCaptionNudge(event: CaptionNudgeKeyEvent, target?: EventTarget | null) {
8
+ if (target != null && ownsPlainKeys(target)) return null;
9
+ return resolveCanvasNudgeDelta(event);
10
+ }
7
11
 
8
- export function shouldHandleCaptionNudgeKey(
12
+ export const shouldHandleCaptionNudgeKey = (
9
13
  event: CaptionNudgeKeyEvent,
10
14
  target?: EventTarget | null,
11
- ): boolean {
12
- if (event.metaKey || event.ctrlKey || event.altKey) return false;
13
- if (target != null && ownsPlainKeys(target)) return false;
14
- return CAPTION_NUDGE_KEYS.has(event.key);
15
- }
15
+ ): boolean => resolveCaptionNudge(event, target) !== null;
16
16
 
17
17
  // Single editable-target check for the caption surface — re-exported from the
18
18
  // shared timeline helper so the two never diverge (it also covers ARIA
@@ -1,4 +1,5 @@
1
1
  import { memo, useCallback, type ReactNode } from "react";
2
+ import { matchesKey } from "../player/components/studioShortcuts";
2
3
  import { PreviewPane } from "./nle/PreviewPane";
3
4
  import { TimelinePane } from "./nle/TimelinePane";
4
5
  import { PreviewOverlays } from "./nle/PreviewOverlays";
@@ -293,7 +294,7 @@ function EditorShellBody({
293
294
  // Keyboard: Escape to pop composition level
294
295
  const handleKeyDown = useCallback(
295
296
  (e: React.KeyboardEvent) => {
296
- if (e.key === "Escape" && compositionStack.length > 1) {
297
+ if (matchesKey(e, "cancel") && compositionStack.length > 1) {
297
298
  updateCompositionStack((prev) => prev.slice(0, -1));
298
299
  }
299
300
  },
@@ -5,6 +5,7 @@ import { Scissors } from "../icons/SystemIcons";
5
5
  import { Menu, MenuItem } from "./ui";
6
6
  import { cn } from "./ui/cn";
7
7
  import { flatIdle } from "./timelineToolbarStyles";
8
+ import { keyHint, useStudioKeys } from "../player/components/studioShortcuts";
8
9
 
9
10
  function SelectIcon() {
10
11
  return (
@@ -25,18 +26,19 @@ interface ToolRow {
25
26
  /** One button for the active timeline tool; its menu switches tools or selects clips around the playhead. */
26
27
  export function TimelineToolPicker({ showSelectAroundPlayhead = true }) {
27
28
  const activeTool = usePlayerStore((s) => s.activeTool);
29
+ const keys = useStudioKeys();
28
30
  const store = () => usePlayerStore.getState();
29
31
  const rows: ToolRow[] = [
30
32
  {
31
33
  label: "Select",
32
- shortcut: "V",
34
+ shortcut: keyHint("selectTool", keys),
33
35
  icon: <SelectIcon />,
34
36
  active: activeTool === "select",
35
37
  run: () => store().setActiveTool("select"),
36
38
  },
37
39
  {
38
40
  label: "Split",
39
- shortcut: "B",
41
+ shortcut: keyHint("razorTool", keys),
40
42
  icon: <Scissors size={16} />,
41
43
  active: activeTool === "razor",
42
44
  run: () => store().setActiveTool("razor"),
@@ -46,14 +48,14 @@ export function TimelineToolPicker({ showSelectAroundPlayhead = true }) {
46
48
  rows.push(
47
49
  {
48
50
  label: "Select leftward",
49
- shortcut: "[",
51
+ shortcut: keyHint("selectLeftward", keys),
50
52
  icon: <ArrowLineLeft size={16} aria-hidden="true" />,
51
53
  active: false,
52
54
  run: () => store().selectLeftward(),
53
55
  },
54
56
  {
55
57
  label: "Select rightward",
56
- shortcut: "]",
58
+ shortcut: keyHint("selectRightward", keys),
57
59
  icon: <ArrowLineRight size={16} aria-hidden="true" />,
58
60
  active: false,
59
61
  run: () => store().selectRightward(),
@@ -40,10 +40,7 @@ import { LinkedSelectionToggle } from "./LinkedSelectionToggle";
40
40
  import { useProjectHasAudio } from "../utils/audioMeterMath";
41
41
  import { canAddBeatAt, addBeatAtCompositionTime } from "../utils/beatEditActions";
42
42
  import { isTypingTarget } from "../utils/typingTarget";
43
- import {
44
- SPLIT_SHORTCUT_HINT,
45
- ZOOM_SELECTION_SHORTCUT_HINT,
46
- } from "../player/components/studioShortcuts";
43
+ import { keyHint, matchesKey, useStudioKeys } from "../player/components/studioShortcuts";
47
44
  import type { TimelineProps } from "../player/components/TimelineTypes";
48
45
 
49
46
  interface DomEditSessionSlice extends EnableKeyframesSession {
@@ -155,7 +152,7 @@ function useKeyframeToggle(session?: DomEditSessionSlice) {
155
152
  export const TimelineToolbar = memo(function TimelineToolbar({
156
153
  domEditSession,
157
154
  onSplitElement,
158
- splitShortcut = SPLIT_SHORTCUT_HINT,
155
+ splitShortcut,
159
156
  history,
160
157
  showHistory = true,
161
158
  showSelectAroundPlayhead = true,
@@ -163,6 +160,8 @@ export const TimelineToolbar = memo(function TimelineToolbar({
163
160
  showKeyframes = true,
164
161
  rightActions,
165
162
  }: TimelineToolbarProps) {
163
+ const keys = useStudioKeys();
164
+ const kf = keyHint("addKeyframe", keys);
166
165
  const timelineSnapEnabled = usePlayerStore((s) => s.timelineSnapEnabled);
167
166
  const setTimelineSnapEnabled = usePlayerStore((s) => s.setTimelineSnapEnabled);
168
167
  const rippleEditEnabled = usePlayerStore((s) => s.rippleEditEnabled);
@@ -199,7 +198,7 @@ export const TimelineToolbar = memo(function TimelineToolbar({
199
198
  onToggle: onToggleKeyframe,
200
199
  } = useKeyframeToggle(domEditSession);
201
200
 
202
- // Wire the "Add keyframe (K)" shortcut the toolbar advertises. Active only when
201
+ // Wire the Add keyframe shortcut the toolbar advertises. Active only when
203
202
  // there's a keyframeable selection; otherwise K stays JKL-pause in playback.
204
203
  useKeyframeKeyboard({
205
204
  enabled: showKeyframes && Boolean(onToggleKeyframe),
@@ -214,8 +213,7 @@ export const TimelineToolbar = memo(function TimelineToolbar({
214
213
  // Skip when typing in an input/contenteditable.
215
214
  useEffect(() => {
216
215
  const onKeyDown = (e: KeyboardEvent) => {
217
- if (e.key !== "n" && e.key !== "N") return;
218
- if (e.metaKey || e.ctrlKey || e.altKey) return;
216
+ if (!matchesKey(e, "timelineSnap")) return;
219
217
  if (isTypingTarget(e.target)) return;
220
218
  const store = usePlayerStore.getState();
221
219
  store.setTimelineSnapEnabled(!store.timelineSnapEnabled);
@@ -233,7 +231,13 @@ export const TimelineToolbar = memo(function TimelineToolbar({
233
231
  {/* Divider: tool-mode | editing-actions */}
234
232
  <div aria-hidden="true" className="mx-1 h-4 w-px bg-neutral-800" />
235
233
  <LinkedSelectionToggle />
236
- <Tooltip label={timelineSnapEnabled ? "Snapping on (N)" : "Snapping off (N)"}>
234
+ <Tooltip
235
+ label={
236
+ timelineSnapEnabled
237
+ ? `Snapping on (${keyHint("timelineSnap", keys)})`
238
+ : `Snapping off (${keyHint("timelineSnap", keys)})`
239
+ }
240
+ >
237
241
  <button
238
242
  type="button"
239
243
  onClick={() => setTimelineSnapEnabled(!timelineSnapEnabled)}
@@ -286,17 +290,17 @@ export const TimelineToolbar = memo(function TimelineToolbar({
286
290
  ? "Select an animated element to add keyframes"
287
291
  : keyframeIsMotionPath
288
292
  ? keyframeWillExtend
289
- ? "Extend motion path to playhead (K)"
293
+ ? `Extend motion path to playhead (${kf})`
290
294
  : keyframeState === "active"
291
- ? "Remove waypoint from motion path (K)"
292
- : "Add waypoint to motion path (K)"
295
+ ? `Remove waypoint from motion path (${kf})`
296
+ : `Add waypoint to motion path (${kf})`
293
297
  : keyframeState === "active"
294
- ? "Remove keyframe at playhead (K)"
298
+ ? `Remove keyframe at playhead (${kf})`
295
299
  : keyframeState === "inactive"
296
300
  ? keyframeWillExtend
297
- ? "Add keyframe at playhead, extends animation (K)"
298
- : "Add keyframe at playhead (K)"
299
- : "Add keyframe (K)"
301
+ ? `Add keyframe at playhead, extends animation (${kf})`
302
+ : `Add keyframe at playhead (${kf})`
303
+ : `Add keyframe (${kf})`
300
304
  }
301
305
  >
302
306
  <button
@@ -393,7 +397,7 @@ export const TimelineToolbar = memo(function TimelineToolbar({
393
397
  <Tooltip
394
398
  label={
395
399
  canSplit
396
- ? `Split at playhead (${splitShortcut})`
400
+ ? `Split at playhead (${splitShortcut ?? keyHint("split", keys)})`
397
401
  : splittable
398
402
  ? "Move the playhead inside the clip to split"
399
403
  : "Select a clip to split"
@@ -502,7 +506,7 @@ export const TimelineToolbar = memo(function TimelineToolbar({
502
506
  <Tooltip
503
507
  label={
504
508
  canZoomSelection
505
- ? `Zoom to selected clips (${ZOOM_SELECTION_SHORTCUT_HINT})`
509
+ ? `Zoom to selected clips (${keyHint("zoomSelection", keys)})`
506
510
  : "Select a clip to zoom the timeline"
507
511
  }
508
512
  >
@@ -1,4 +1,5 @@
1
1
  import { useTrackDesignInput } from "../../contexts/DesignPanelInputContext";
2
+ import { keyHint, useStudioKeys } from "../../player/components/studioShortcuts";
2
3
 
3
4
  export type GestureRecordingState = "idle" | "recording" | "preview";
4
5
 
@@ -29,6 +30,7 @@ export function GestureRecordPanelButton({
29
30
  recordingDuration,
30
31
  onToggleRecording,
31
32
  }: GestureRecordPanelButtonProps) {
33
+ const recordKey = keyHint("record", useStudioKeys());
32
34
  const recording = recordingState === "recording";
33
35
  const track = useTrackDesignInput();
34
36
 
@@ -49,8 +51,8 @@ export function GestureRecordPanelButton({
49
51
  >
50
52
  <GestureRecordIcon recording={recording} />
51
53
  {recording
52
- ? `Stop recording ${(recordingDuration ?? 0).toFixed(1)}s -- press R`
53
- : "Record gesture (R) -- move pointer to capture motion"}
54
+ ? `Stop recording ${(recordingDuration ?? 0).toFixed(1)}s -- press ${recordKey}`
55
+ : `Record gesture (${recordKey}) -- move pointer to capture motion`}
54
56
  </button>
55
57
  </div>
56
58
  );
@@ -67,8 +69,11 @@ export function GestureRecordBadge({
67
69
  recordingState,
68
70
  onToggleRecording,
69
71
  }: GestureRecordBadgeProps) {
72
+ const recordKey = keyHint("record", useStudioKeys());
70
73
  const recording = recordingState === "recording";
71
- const label = recording ? "Stop gesture recording (R)" : "Record gesture (R)";
74
+ const label = recording
75
+ ? `Stop gesture recording (${recordKey})`
76
+ : `Record gesture (${recordKey})`;
72
77
 
73
78
  return (
74
79
  <button
@@ -4,6 +4,8 @@ import { useTrackDesignInput } from "../../contexts/DesignPanelInputContext";
4
4
  import type { DomEditSelection } from "./domEditingTypes";
5
5
 
6
6
  /** The action buttons in the inspector header: visibility, Ungroup (groups only), copy, clear. */
7
+ import { keyHint, useStudioKeys } from "../../player/components/studioShortcuts";
8
+
7
9
  export function InspectorHeaderActions({
8
10
  element,
9
11
  copied,
@@ -53,7 +55,7 @@ export function InspectorHeaderActions({
53
55
  track("button", "Ungroup");
54
56
  onUngroup();
55
57
  }}
56
- title="Ungroup (⌘⇧G)"
58
+ title={`Ungroup (${keyHint("ungroup", useStudioKeys())})`}
57
59
  className="flex h-6 items-center rounded-sm px-2 text-[11px] font-medium text-neutral-400 transition-colors hover:bg-neutral-800 hover:text-neutral-200"
58
60
  >
59
61
  Ungroup
@@ -1,4 +1,5 @@
1
1
  import { useTrackDesignInput } from "../../contexts/DesignPanelInputContext";
2
+ import { keyHint, useStudioKeys } from "../../player/components/studioShortcuts";
2
3
 
3
4
  export function PropertyPanelFlatFooter({
4
5
  onAskAgent,
@@ -13,9 +14,10 @@ export function PropertyPanelFlatFooter({
13
14
  }) {
14
15
  const track = useTrackDesignInput();
15
16
  const recording = recordingState === "recording";
17
+ const recordKey = keyHint("record", useStudioKeys());
16
18
  const recordTitle = recording
17
19
  ? `Stop recording ${(recordingDuration ?? 0).toFixed(1)}s`
18
- : "Record gesture (R)";
20
+ : `Record gesture (${recordKey})`;
19
21
 
20
22
  return (
21
23
  // No border-t here: every possible element immediately above this footer
@@ -9,6 +9,8 @@ const ICON_COLOR_BY_KIND = {
9
9
  other: "text-panel-container",
10
10
  } as const;
11
11
 
12
+ import { keyHint, useStudioKeys } from "../../player/components/studioShortcuts";
13
+
12
14
  export function PropertyPanelFlatHeader({
13
15
  name,
14
16
  meta,
@@ -54,7 +56,7 @@ export function PropertyPanelFlatHeader({
54
56
  <button
55
57
  type="button"
56
58
  aria-label="Ungroup"
57
- title="Ungroup (⌘⇧G)"
59
+ title={`Ungroup (${keyHint("ungroup", useStudioKeys())})`}
58
60
  onClick={() => {
59
61
  track("button", "Ungroup");
60
62
  onUngroup?.();
@@ -4,9 +4,11 @@ import { MagnetStraight, GridFour, Path, Ruler, FrameCorners } from "@phosphor-i
4
4
  import { usePlayerStore } from "../../player/store/playerStore";
5
5
  import { usePreviewOverlayContext } from "./PreviewOverlayProvider";
6
6
  import { ownsPlainKeys } from "../../utils/typingTarget";
7
+ import { keyHint, matchesKey, useStudioKeys } from "../../player/components/studioShortcuts";
7
8
 
8
9
  // fallow-ignore-next-line complexity
9
10
  export const SnapToolbar = memo(function SnapToolbar() {
11
+ const keys = useStudioKeys();
10
12
  const [gridPopoverOpen, setGridPopoverOpen] = useState(false);
11
13
  const { state, actions } = usePreviewOverlayContext();
12
14
  const { snapPrefs: prefs, rulerVisible, safeMarginsVisible } = state;
@@ -51,12 +53,12 @@ export const SnapToolbar = memo(function SnapToolbar() {
51
53
  if (e.defaultPrevented) return;
52
54
  if (ownsPlainKeys(e.target)) return;
53
55
  if (e.target instanceof HTMLIFrameElement) return;
54
- if (e.key === "s" && !e.metaKey && !e.ctrlKey && !e.altKey) {
56
+ if (matchesKey(e, "snap")) {
55
57
  e.preventDefault();
56
58
  updatePrefs({ snapEnabled: !prefs.snapEnabled });
57
59
  if (!e.repeat) trackPreviewFeatureUsed("snapping", "keyboard");
58
60
  }
59
- if (e.key === "g" && !e.metaKey && !e.ctrlKey && !e.altKey) {
61
+ if (matchesKey(e, "grid")) {
60
62
  e.preventDefault();
61
63
  updatePrefs({ gridVisible: !prefs.gridVisible });
62
64
  if (!e.repeat) trackPreviewFeatureUsed("grid", "keyboard");
@@ -137,7 +139,11 @@ export const SnapToolbar = memo(function SnapToolbar() {
137
139
  : "bg-black/40 text-white/60 hover:bg-black/60 hover:text-white/80"
138
140
  }`}
139
141
  onClick={toggleSnap}
140
- title={prefs.snapEnabled ? "Snap enabled (S)" : "Snap disabled (S)"}
142
+ title={
143
+ prefs.snapEnabled
144
+ ? `Snap enabled (${keyHint("snap", keys)})`
145
+ : `Snap disabled (${keyHint("snap", keys)})`
146
+ }
141
147
  aria-label="Toggle snap"
142
148
  >
143
149
  <MagnetStraight size={16} weight={prefs.snapEnabled ? "fill" : "regular"} />
@@ -160,8 +166,8 @@ export const SnapToolbar = memo(function SnapToolbar() {
160
166
  }}
161
167
  title={
162
168
  prefs.gridVisible
163
- ? "Grid visible (G). Right-click for spacing options"
164
- : "Grid hidden (G). Right-click for spacing options"
169
+ ? `Grid visible (${keyHint("grid", keys)}). Right-click for spacing options`
170
+ : `Grid hidden (${keyHint("grid", keys)}). Right-click for spacing options`
165
171
  }
166
172
  aria-label="Toggle grid"
167
173
  >
@@ -1,4 +1,5 @@
1
- import { describe, expect, it } from "vitest";
1
+ import { afterEach, describe, expect, it } from "vitest";
2
+ import { setStudioKeys } from "../../player/components/studioShortcuts";
2
3
  import {
3
4
  CANVAS_NUDGE_SHIFT_STEP_PX,
4
5
  CANVAS_NUDGE_STEP_PX,
@@ -78,3 +79,18 @@ describe("canCanvasNudgeTargets", () => {
78
79
  expect(canCanvasNudgeTargets([movable, locked])).toBe(false);
79
80
  });
80
81
  });
82
+
83
+ describe("resolveCanvasNudgeDelta: remapped keys", () => {
84
+ afterEach(() => setStudioKeys(null));
85
+
86
+ it("a remapped direction and step key answer and the arrow goes dead", () => {
87
+ setStudioKeys({ nudgeLeft: "h", nudgeRightTen: "alt+l" });
88
+ expect(resolveCanvasNudgeDelta(mockKeyboardEvent("ArrowLeft"))).toBeNull();
89
+ expect(resolveCanvasNudgeDelta(mockKeyboardEvent("h"))).toEqual({ dx: -1, dy: 0 });
90
+ expect(resolveCanvasNudgeDelta(mockKeyboardEvent("l", { altKey: true }))).toEqual({
91
+ dx: 10,
92
+ dy: 0,
93
+ });
94
+ expect(resolveCanvasNudgeDelta(mockKeyboardEvent("ArrowRight", { shiftKey: true }))).toBeNull();
95
+ });
96
+ });
@@ -6,7 +6,7 @@
6
6
  * mutually exclusively (caption edit mode returns before the DOM overlay).
7
7
  */
8
8
 
9
- const CANVAS_NUDGE_KEYS = new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
9
+ import { matchesKey, type StudioKeyAction } from "../../player/components/studioShortcuts";
10
10
 
11
11
  export const CANVAS_NUDGE_STEP_PX = 1;
12
12
  export const CANVAS_NUDGE_SHIFT_STEP_PX = 10;
@@ -16,22 +16,25 @@ export const CANVAS_NUDGE_COMMIT_DEBOUNCE_MS = 400;
16
16
  type CanvasNudgeKeyEvent = Pick<
17
17
  KeyboardEvent,
18
18
  "altKey" | "ctrlKey" | "metaKey" | "shiftKey" | "key"
19
- >;
19
+ > & { code?: string };
20
20
 
21
- /**
22
- * Arrow key → composition-px delta (Shift = 10). Null when the key is not a
23
- * plain/Shift arrow, so browser and app shortcut chords pass through.
24
- */
21
+ const NUDGES: ReadonlyArray<[StudioKeyAction, number, number, number]> = [
22
+ ["nudgeLeft", -1, 0, CANVAS_NUDGE_STEP_PX],
23
+ ["nudgeRight", 1, 0, CANVAS_NUDGE_STEP_PX],
24
+ ["nudgeUp", 0, -1, CANVAS_NUDGE_STEP_PX],
25
+ ["nudgeDown", 0, 1, CANVAS_NUDGE_STEP_PX],
26
+ ["nudgeLeftTen", -1, 0, CANVAS_NUDGE_SHIFT_STEP_PX],
27
+ ["nudgeRightTen", 1, 0, CANVAS_NUDGE_SHIFT_STEP_PX],
28
+ ["nudgeUpTen", 0, -1, CANVAS_NUDGE_SHIFT_STEP_PX],
29
+ ["nudgeDownTen", 0, 1, CANVAS_NUDGE_SHIFT_STEP_PX],
30
+ ];
31
+
32
+ /** Nudge key (default: arrows, Shift = 10) to a composition-px delta; null for any other key. */
25
33
  export function resolveCanvasNudgeDelta(
26
34
  event: CanvasNudgeKeyEvent,
27
35
  ): { dx: number; dy: number } | null {
28
- if (event.metaKey || event.ctrlKey || event.altKey) return null;
29
- if (!CANVAS_NUDGE_KEYS.has(event.key)) return null;
30
- const step = event.shiftKey ? CANVAS_NUDGE_SHIFT_STEP_PX : CANVAS_NUDGE_STEP_PX;
31
- return {
32
- dx: event.key === "ArrowLeft" ? -step : event.key === "ArrowRight" ? step : 0,
33
- dy: event.key === "ArrowUp" ? -step : event.key === "ArrowDown" ? step : 0,
34
- };
36
+ const hit = NUDGES.find(([action]) => matchesKey(event, action));
37
+ return hit ? { dx: hit[1] * hit[3], dy: hit[2] * hit[3] } : null;
35
38
  }
36
39
 
37
40
  export interface CanvasNudgeTarget {
@@ -1,4 +1,5 @@
1
1
  import type { DomSelectionResult } from "../../hooks/useDomSelectionTypes";
2
+ import { matchesKey } from "../../player/components/studioShortcuts";
2
3
  import { trackPreviewFeatureUsed } from "../../utils/previewFeatureUsage";
3
4
  // fallow-ignore-file code-duplication
4
5
  import { useCallback, useEffect, useRef, useState } from "react";
@@ -233,7 +234,7 @@ export function useMarqueeGestures<T>(deps: MarqueeGesturesDeps<T>): MarqueeGest
233
234
 
234
235
  useEffect(() => {
235
236
  const cancelBandBeforeHostEscape = (e: KeyboardEvent) => {
236
- if (e.key !== "Escape" || !marqueeRef.current) return;
237
+ if (!matchesKey(e, "cancel") || !marqueeRef.current) return;
237
238
  e.preventDefault();
238
239
  e.stopPropagation();
239
240
  cancel();