The VS Code of video editing, built for agents.
TypeScript
feat: add timeline navigation shortcuts and corresponding icons
konstantin-paulus2a54059ea83d
diff --git a/apps/web/src/assets/icons/timeline.go-to-end.svg b/apps/web/src/assets/icons/timeline.go-to-end.svgnew file mode 100644index 00000000..f12b7495--- /dev/null+++ b/apps/web/src/assets/icons/timeline.go-to-end.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M18.5 7.5V17.5M11.5 7.5V17.5L16.5 12.5L11.5 7.5ZM6.5 7.5V17.5L11.5 12.5L6.5 7.5Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/apps/web/src/assets/icons/timeline.go-to-selection-end.svg b/apps/web/src/assets/icons/timeline.go-to-selection-end.svgnew file mode 100644index 00000000..fecb0375--- /dev/null+++ b/apps/web/src/assets/icons/timeline.go-to-selection-end.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M15.5 7.5H17.5V17.5H15.5M7.5 12.5H14.5M11.5 9.5L14.5 12.5L11.5 15.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/apps/web/src/assets/icons/timeline.go-to-selection-start.svg b/apps/web/src/assets/icons/timeline.go-to-selection-start.svgnew file mode 100644index 00000000..fa2526d4--- /dev/null+++ b/apps/web/src/assets/icons/timeline.go-to-selection-start.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M9.5 7.5H7.5V17.5H9.5M17.5 12.5H10.5M13.5 9.5L10.5 12.5L13.5 15.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/apps/web/src/assets/icons/timeline.go-to-start.svg b/apps/web/src/assets/icons/timeline.go-to-start.svgnew file mode 100644index 00000000..29821b18--- /dev/null+++ b/apps/web/src/assets/icons/timeline.go-to-start.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M6.5 7.5V17.5M13.5 7.5V17.5L8.5 12.5L13.5 7.5ZM18.5 7.5V17.5L13.5 12.5L18.5 7.5Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/apps/web/src/assets/icons/timeline.next-frame.svg b/apps/web/src/assets/icons/timeline.next-frame.svgnew file mode 100644index 00000000..609745b6--- /dev/null+++ b/apps/web/src/assets/icons/timeline.next-frame.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M11.5 7.5V17.5L18.5 12.5L11.5 7.5ZM8.5 7.5V17.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/apps/web/src/assets/icons/timeline.previous-frame.svg b/apps/web/src/assets/icons/timeline.previous-frame.svgnew file mode 100644index 00000000..6b6141f6--- /dev/null+++ b/apps/web/src/assets/icons/timeline.previous-frame.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M13.5 7.5V17.5L6.5 12.5L13.5 7.5ZM16.5 7.5V17.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/apps/web/src/assets/icons/timeline.shuttle-backward.svg b/apps/web/src/assets/icons/timeline.shuttle-backward.svgnew file mode 100644index 00000000..8fd9688c--- /dev/null+++ b/apps/web/src/assets/icons/timeline.shuttle-backward.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M11.5 7.5V17.5L5.5 12.5L11.5 7.5ZM17.5 7.5V17.5L11.5 12.5L17.5 7.5Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/apps/web/src/assets/icons/timeline.shuttle-forward.svg b/apps/web/src/assets/icons/timeline.shuttle-forward.svgnew file mode 100644index 00000000..4c5710a0--- /dev/null+++ b/apps/web/src/assets/icons/timeline.shuttle-forward.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M13.5 7.5V17.5L19.5 12.5L13.5 7.5ZM7.5 7.5V17.5L13.5 12.5L7.5 7.5Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/apps/web/src/assets/icons/timeline.skip-back.svg b/apps/web/src/assets/icons/timeline.skip-back.svgnew file mode 100644index 00000000..caf2166d--- /dev/null+++ b/apps/web/src/assets/icons/timeline.skip-back.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M11.5 6.5A6 6 0 1 1 5.5 12.5M13.5 4.5L11.5 6.5L13.5 8.5M10.5 11.5L11.5 10.5V14.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/apps/web/src/assets/icons/timeline.skip-forward.svg b/apps/web/src/assets/icons/timeline.skip-forward.svgnew file mode 100644index 00000000..f19d8ec4--- /dev/null+++ b/apps/web/src/assets/icons/timeline.skip-forward.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M13.5 6.5A6 6 0 1 0 19.5 12.5M11.5 4.5L13.5 6.5L11.5 8.5M12.5 11.5L13.5 10.5V14.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/apps/web/src/assets/icons/timeline.stop.svg b/apps/web/src/assets/icons/timeline.stop.svgnew file mode 100644index 00000000..fa7804d9--- /dev/null+++ b/apps/web/src/assets/icons/timeline.stop.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<rect x="7.5" y="7.5" width="10" height="10" rx="1.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/apps/web/src/components/commands/shortcuts.tsx b/apps/web/src/components/commands/shortcuts.tsxindex 7f3e52a3..215c68f2 100644--- a/apps/web/src/components/commands/shortcuts.tsx+++ b/apps/web/src/components/commands/shortcuts.tsx@@ -8,13 +8,24 @@import { For } from "solid-js";import { useWorld } from "@diffusionstudio/koota-solid";-import { getActiveEntity, isGroupLike, isSequence, togglePlayback } from "@diffusionstudio/runtime";+import {+ FrameRate,+ getActiveEntity,+ isGroupLike,+ isSequence,+ shuttlePlayback,+ stopPlayback,+ togglePlayback,+} from "@diffusionstudio/runtime";import { useCommand } from "@/context/commands";import {getEditHistory,groupSelection,redoEdit,restackSelection,+ seekBy,+ seekToSelectionEdge,+ seekToTimelineEdge,splitAtPlayhead,toggleSelectionHidden,undoEdit,@@ -53,6 +64,17 @@ type Shortcut = {const selection = ({ nodes }: ShortcutState) => nodes.length > 0;const activeScene = ({ scene }: ShortcutState) => scene !== null;+/** Clips to seek to the edges of: the active scene is where they are, not one of them. */+const selectedClips = ({ nodes, scene }: ShortcutState) => scene !== null && nodes.some((node) => node !== scene);++/** Runs `action` on the active scene, if there is one. */+const onActiveScene = (action: (world: World, scene: Entity) => void) => (world: World) => {+ const scene = getActiveEntity(world);+ if (scene) action(world, scene);+};++const seekSeconds = (seconds: number) => (world: World) =>+ seekBy(world, Math.round(seconds * (world.get(FrameRate)?.value ?? 30)));const SHORTCUTS: Shortcut[] = [{@@ -138,12 +160,119 @@ const SHORTCUTS: Shortcut[] = [icon: "play",keys: ["Space"],keywords: ["playback", "stop"],- run: (world) => {- const scene = getActiveEntity(world);- if (scene) togglePlayback(world, scene);- },+ run: onActiveScene(togglePlayback),+ available: activeScene,+ },+ {+ id: "play-forward",+ title: "Play forward",+ group: "Timeline",+ icon: "timeline.shuttle-forward",+ keys: ["L"],+ keywords: ["shuttle", "faster"],+ run: onActiveScene((world, scene) => shuttlePlayback(world, scene, 1)),+ available: activeScene,+ },+ {+ id: "play-backward",+ title: "Play backward",+ group: "Timeline",+ icon: "timeline.shuttle-backward",+ keys: ["J"],+ keywords: ["shuttle", "reverse", "rewind"],+ run: onActiveScene((world, scene) => shuttlePlayback(world, scene, -1)),+ available: activeScene,+ },+ {+ id: "stop-playback",+ title: "Stop playback",+ group: "Timeline",+ icon: "timeline.stop",+ keys: ["K"],+ keywords: ["shuttle", "pause"],+ run: onActiveScene(stopPlayback),+ available: activeScene,+ },+ {+ id: "next-frame",+ title: "Go to next frame",+ group: "Timeline",+ icon: "timeline.next-frame",+ keys: ["D"],+ keywords: ["step", "jump", "forward"],+ run: (world) => seekBy(world, 1),+ available: activeScene,+ },+ {+ id: "previous-frame",+ title: "Go to previous frame",+ group: "Timeline",+ icon: "timeline.previous-frame",+ keys: ["A"],+ keywords: ["step", "jump", "back"],+ run: (world) => seekBy(world, -1),+ available: activeScene,+ },+ {+ id: "skip-forward",+ title: "Skip forward 1 second",+ group: "Timeline",+ icon: "timeline.skip-forward",+ keys: ["W"],+ keywords: ["jump", "seek"],+ run: seekSeconds(1),+ available: activeScene,+ },+ {+ id: "skip-back",+ title: "Skip back 1 second",+ group: "Timeline",+ icon: "timeline.skip-back",+ keys: ["S"],+ keywords: ["jump", "seek"],+ run: seekSeconds(-1),available: activeScene,},+ {+ id: "go-to-start",+ title: "Go to start",+ group: "Timeline",+ icon: "timeline.go-to-start",+ keys: ["Home"],+ keywords: ["jump", "beginning", "first frame"],+ run: (world) => seekToTimelineEdge(world, "start"),+ available: activeScene,+ },+ {+ id: "go-to-end",+ title: "Go to end",+ group: "Timeline",+ icon: "timeline.go-to-end",+ keys: ["End"],+ keywords: ["jump", "last frame"],+ run: (world) => seekToTimelineEdge(world, "end"),+ available: activeScene,+ },+ {+ id: "go-to-selection-start",+ title: "Go to selection start",+ group: "Timeline",+ icon: "timeline.go-to-selection-start",+ keys: [";"],+ keywords: ["jump", "clip", "in point"],+ run: (world) => seekToSelectionEdge(world, "start"),+ available: selectedClips,+ },+ {+ id: "go-to-selection-end",+ title: "Go to selection end",+ group: "Timeline",+ icon: "timeline.go-to-selection-end",+ keys: ["'"],+ keywords: ["jump", "clip", "out point"],+ run: (world) => seekToSelectionEdge(world, "end"),+ available: selectedClips,+ },{id: "split",title: "Split at playhead",