Open source CapCut alternative.
TypeScript
feat(site): move effect, transition and element pickers into side panel tabs
David Le02a08a3ff253
diff --git a/site/src/components/ui/scroll-area.tsx b/site/src/components/ui/scroll-area.tsxnew file mode 100644index 00000000..97f56aaa--- /dev/null+++ b/site/src/components/ui/scroll-area.tsx@@ -0,0 +1,75 @@+"use client"++import * as React from "react"+import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area"++import { cn } from "@/lib/utils"++/**+ * A vertical scroll container with a thin scrollbar that floats over the+ * content: it fades in while the pointer is inside or the view is scrolling,+ * and it takes no width from the layout, so a narrow column keeps every pixel+ * it has. `contentClassName` styles the scrolling content itself — padding and+ * layout belong there, sizing on the outer element.+ */+function ScrollArea({+ className,+ contentClassName,+ children,+ ...props+}: ScrollAreaPrimitive.Root.Props & { contentClassName?: string }) {+ return (+ <ScrollAreaPrimitive.Root+ data-slot="scroll-area"+ className={cn("relative", className)}+ {...props}+ >+ <ScrollAreaPrimitive.Viewport+ data-slot="scroll-area-viewport"+ className="size-full rounded-[inherit] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"+ >+ <ScrollAreaPrimitive.Content+ data-slot="scroll-area-content"+ className={contentClassName}+ // The part ships `min-width: fit-content` for horizontal scrolling;+ // this one scrolls down only, and fit-content lets one long unbroken+ // line widen the column past its own bounds.+ style={{ minWidth: "auto" }}+ >+ {children}+ </ScrollAreaPrimitive.Content>+ </ScrollAreaPrimitive.Viewport>+ <ScrollBar />+ <ScrollAreaPrimitive.Corner data-slot="scroll-area-corner" />+ </ScrollAreaPrimitive.Root>+ )+}++function ScrollBar({+ className,+ orientation = "vertical",+ ...props+}: ScrollAreaPrimitive.Scrollbar.Props) {+ return (+ <ScrollAreaPrimitive.Scrollbar+ data-slot="scroll-area-scrollbar"+ orientation={orientation}+ className={cn(+ // The track stays a comfortable grab target; the padding is what makes+ // the thumb inside it read as a hairline.+ "z-10 flex touch-none p-[3px] opacity-0 transition-opacity select-none data-hovering:opacity-100 data-scrolling:opacity-100 data-scrolling:duration-0",+ orientation === "vertical" && "h-full w-2.5",+ orientation === "horizontal" && "h-2.5 flex-col",+ className+ )}+ {...props}+ >+ <ScrollAreaPrimitive.Thumb+ data-slot="scroll-area-thumb"+ className="relative flex-1 rounded-full bg-foreground/25"+ />+ </ScrollAreaPrimitive.Scrollbar>+ )+}++export { ScrollArea, ScrollBar }diff --git a/site/src/cut/components/AnimationTiles.tsx b/site/src/cut/components/AnimationTiles.tsxnew file mode 100644index 00000000..6d648891--- /dev/null+++ b/site/src/cut/components/AnimationTiles.tsx@@ -0,0 +1,166 @@+"use client";++import { useEffect, useRef, useState } from "react";+import { Ban, Image as ImageIcon } from "lucide-react";+import {+ evalOverlayAnim,+ OVERLAY_ANIM_STYLE_IDS,+ OVERLAY_ANIM_STYLE_LABELS,+ OVERLAY_LOOP_STYLE_IDS,+ OVERLAY_LOOP_STYLE_LABELS,+ type OverlayAnimStyle,+ type OverlayLoopStyle,+} from "@donkeycut/effects-kit";+import { Tile } from "@/cut/components/PanelTile";++/**+ * The animation picker: a grid of tiles that play their animation on a+ * stand-in shape, so the motion is chosen by watching rather than by reading a+ * name. Only the tile under the pointer moves — a dozen shapes all cycling at+ * once is noise, and it makes the one you are actually looking at harder to+ * read.+ *+ * Every tile samples `evalOverlayAnim` — the same function the preview, the+ * in-tab export and the frame sampler use. A tile therefore cannot promise+ * motion the export will not deliver, and a new style animates here the moment+ * the evaluator learns it.+ */++/** Demo timing: a ramp, then a beat of rest, then round again. */+const DEMO_RAMP = 0.6;+const DEMO_HOLD = 0.55;+const DEMO_CYCLE = DEMO_RAMP + DEMO_HOLD;++/** Design px that map to the tile's preview stage. The evaluator works in px at+ * a 1080 short side; a slide travels 120 of them, which has to read inside a+ * stage a few dozen pixels wide. Low enough that a slide clearly leaves. */+const DEMO_REFERENCE_PX = 190;++/** What a typewriter tile types. */+const DEMO_WORD = "Text";++type Slot = "in" | "out" | "loop";++function demoStateAt(slot: Slot, style: string, t: number) {+ if (slot === "loop") {+ return evalOverlayAnim({ loop: { style: style as OverlayLoopStyle, speed: 1 } }, t, 60);+ }+ const local = t % DEMO_CYCLE;+ const anim =+ slot === "in"+ ? { in: { style: style as OverlayAnimStyle, seconds: DEMO_RAMP } }+ : { out: { style: style as OverlayAnimStyle, seconds: DEMO_RAMP } };+ // The exit sits at the tail of the window, so an Out tile rests first and+ // then leaves — the shape of the thing it is previewing.+ return evalOverlayAnim(anim, local, DEMO_CYCLE);+}++export function AnimationTiles({+ slot,+ value,+ isText,+ onPick,+}: {+ slot: Slot;+ /** The style in use, or undefined for none. */+ value?: string;+ /** Typewriter is offered on titles only. */+ isText: boolean;+ onPick: (style: string | null) => void;+}) {+ const ids: string[] =+ slot === "loop"+ ? OVERLAY_LOOP_STYLE_IDS+ : OVERLAY_ANIM_STYLE_IDS.filter((s) => s !== "typewriter" || isText);+ const labels: Record<string, string> =+ slot === "loop" ? OVERLAY_LOOP_STYLE_LABELS : OVERLAY_ANIM_STYLE_LABELS;++ // One clock for the whole grid, writing transforms straight to the elements:+ // a dozen tiles animating through React state would re-render the inspector+ // every frame for pixels React has no say over.+ const shapes = useRef(new Map<string, HTMLElement>());+ const register = (id: string) => (el: HTMLElement | null) => {+ if (el) shapes.current.set(id, el);+ else shapes.current.delete(id);+ };++ const [hovered, setHovered] = useState<string | null>(null);++ useEffect(() => {+ const el = hovered ? shapes.current.get(hovered) : null;+ if (!el) return;+ const rest = () => {+ el.style.transform = "";+ el.style.opacity = "";+ if (el.dataset.word) el.textContent = el.dataset.word;+ };+ if (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return rest;+ let start = 0;+ let raf = 0;+ const tick = (now: number) => {+ if (!start) start = now;+ const st = demoStateAt(slot, hovered!, (now - start) / 1000);+ const px = (v: number) => (v * el.clientWidth) / DEMO_REFERENCE_PX;+ el.style.transform = `translate(${px(st.dx)}px, ${px(st.dy)}px) rotate(${st.rotate}deg) scale(${st.scale})`;+ el.style.opacity = String(st.alpha);+ if (st.textProgress !== undefined) {+ el.textContent = DEMO_WORD.slice(0, Math.ceil(st.textProgress * DEMO_WORD.length));+ }+ raf = requestAnimationFrame(tick);+ };+ raf = requestAnimationFrame(tick);+ // Back to rest on the way out, so a tile never freezes mid-animation.+ return () => {+ cancelAnimationFrame(raf);+ rest();+ };+ }, [hovered, slot]);++ // The stage is the tile's own width with no frame of its own: the tile is+ // already a card, and a second one inside it would both box the motion in and+ // steal the room the motion needs. Clipping is what sells a slide leaving.+ const stage = "grid h-11 w-full place-items-center overflow-hidden";+ const tile = "gap-1 px-1 pt-1.5 pb-1";++ return (+ <div className="grid grid-cols-3 gap-1.5">+ <Tile selected={!value} onClick={() => onPick(null)} label="None" className={tile}>+ <span className={stage}>+ <Ban className="size-7 text-muted-foreground/60" />+ </span>+ </Tile>+ {ids.map((id) => (+ <Tile+ key={id}+ selected={value === id}+ onClick={() => onPick(id)}+ label={labels[id]}+ className={tile}+ onHover={(on) => setHovered(on ? id : (h) => (h === id ? null : h))}+ >+ <span className={stage}>+ {id === "typewriter" ? (+ <span+ ref={register(id)}+ data-word={DEMO_WORD}+ className="text-[13px] font-semibold text-foreground"+ style={{ willChange: "transform" }}+ >+ {DEMO_WORD}+ </span>+ ) : (+ // Its own wrapper, so the animated transform never fights the+ // icon's sizing.+ <span ref={register(id)} className="block" style={{ willChange: "transform" }}>+ {/* Carries the tile's own muted color and the light stroke the+ transition tiles use, so a grid of stand-ins doesn't read+ heavier than the picture it stands in for. */}+ <ImageIcon className="size-7" strokeWidth={1.5} />+ </span>+ )}+ </span>+ </Tile>+ ))}+ </div>+ );+}diff --git a/site/src/cut/components/AssetRefs.tsx b/site/src/cut/components/AssetRefs.tsxindex 197bb368..af091da8 100644--- a/site/src/cut/components/AssetRefs.tsx+++ b/site/src/cut/components/AssetRefs.tsx@@ -117,6 +117,49 @@ export function RefHandleBadge({ handle, className }: { handle: string; classNam/** A legible reference-token pill for image tiles: dark so it reads over any* image, showing the mention to type (`@i2`, `@nature-dunes`). Caller controls* visibility (shown on hover). */+/**+ * A generated asset's @handle on its tile: shown on hover or focus, and a+ * button — clicking it puts the reference on the clipboard, which is how a+ * sticker or a render made earlier gets typed into a prompt somewhere else.+ * The same pill on every generation tab, so the gesture is learned once.+ */+export function CopyHandlePill({+ handle,+ name,+ className,+}: {+ handle?: string;+ name: string;+ className?: string;+}) {+ const [copied, setCopied] = useState(false);+ const token = handle ? `@${handle}` : mentionToken(name);+ return (+ <button+ type="button"+ title="Copy reference"+ aria-label={`Copy reference ${token}`}+ className={cn(+ "absolute top-1 left-1 max-w-[calc(100%-0.5rem)] rounded-[5px] opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100",+ className+ )}+ onClick={(e) => {+ // The tile under it takes a click as "pick me"; copying is its own act.+ e.stopPropagation();+ void navigator.clipboard+ .writeText(token)+ .then(() => {+ setCopied(true);+ setTimeout(() => setCopied(false), 1200);+ })+ .catch(() => {});+ }}+ >+ <RefHandlePill token={copied ? "Copied" : token} />+ </button>+ );+}+export function RefHandlePill({ token, className }: { token: string; className?: string }) {return (<spandiff --git a/site/src/cut/components/AudioPanel.tsx b/site/src/cut/components/AudioPanel.tsxindex ac5d1672..a44755dd 100644--- a/site/src/cut/components/AudioPanel.tsx+++ b/site/src/cut/components/AudioPanel.tsx@@ -57,6 +57,7 @@ import { useSpeakerVoice, useSpeechLanguage, VoicePicker } from "@/cut/componentimport { GeneratedAssetMenu } from "@/cut/components/GeneratedAssetMenu";import { cn } from "@/lib/utils";import { scrimIconButton } from "@/cut/components/iconButton";+import { ScrollArea } from "@/components/ui/scroll-area";/** Starting points for the direction prompt — picking one fills the input so* it can be tweaked before generating. */@@ -113,7 +114,7 @@ export function AudioPanel({<AudioSubTabs value={sub} onChange={onSub} /></div>- <div className="flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-3.5 pb-4">+ <ScrollArea className="min-h-0 flex-1" contentClassName="flex flex-col gap-5 px-3.5 pb-4">{sub === "voice" ? (<>{!readOnly && <VoiceGenerator projectId={projectId} />}@@ -130,7 +131,7 @@ export function AudioPanel({<ProjectMusic projectId={projectId} onTogglePlay={togglePlay} playingUrl={playingUrl} /></>)}- </div>+ </ScrollArea></>);}diff --git a/site/src/cut/components/ClipEffectsPanel.tsx b/site/src/cut/components/ClipEffectsPanel.tsxdeleted file mode 100644index 7af7a8a1..00000000--- a/site/src/cut/components/ClipEffectsPanel.tsx+++ /dev/null@@ -1,508 +0,0 @@-"use client";--import { Fragment, useRef, useState } from "react";-import {- ArrowDown,- ArrowDownToLine,- ArrowLeft,- ArrowLeftToLine,- ArrowRight,- ArrowRightToLine,- ArrowUp,- ArrowUpToLine,- Ban,- Blend,- ChevronLeft,- Circle,- Droplets,- Expand,- FoldHorizontal,- Haze,- Moon,- Sparkles,- Sun,- Target,- UnfoldHorizontal,- ZoomIn,- type LucideIcon,-} from "lucide-react";-import { Slider } from "@/components/ui/slider";-import { parsePercentInput, parseSecondsInput, ScrubValue } from "@/cut/components/ScrubValue";-import { getClipSpans, useEditor } from "@/cut/lib/store";-import { lookCssFilter } from "@/cut/lib/looks";-import {- ANIM_DEFAULT_SECONDS,- ANIM_STYLE_IDS,- ANIM_STYLE_LABELS,- LOOK_IDS,- LOOK_LABELS,- TRANSITION_MAX,- TRANSITION_STYLE_GROUPS,- TRANSITION_STYLE_LABELS,- type AnimStyle,- type LookStyle,- type TransitionStyle,- type VideoClip,-} from "@/cut/lib/types";-import { cn } from "@/lib/utils";--const TRANSITION_TILE_ICONS: Record<TransitionStyle, LucideIcon> = {- crossfade: Blend,- crosszoom: Expand,- dipblack: Moon,- dipwhite: Sun,- blur: Droplets,- pushleft: ArrowLeft,- pushright: ArrowRight,- pushup: ArrowUp,- pushdown: ArrowDown,- wipeleft: ArrowLeftToLine,- wiperight: ArrowRightToLine,- wipeup: ArrowUpToLine,- wipedown: ArrowDownToLine,- circleopen: Circle,- circleclose: Target,- splitopen: UnfoldHorizontal,- splitclose: FoldHorizontal,-};--const ANIM_TILE_ICONS: Record<AnimStyle, LucideIcon> = {- fade: Haze,- zoom: ZoomIn,- pop: Sparkles,- slideleft: ArrowLeft,- slideright: ArrowRight,- slideup: ArrowUp,- slidedown: ArrowDown,-};--/** The entry row's compact readout: which effect categories are set (the row- * is 8.5rem wide — exact style names don't fit, the tabs inside do). */-export function effectsSummary(clip: VideoClip, hasNext: boolean): string {- const parts: string[] = [];- if (hasNext && (clip.transition ?? 0) > 0) parts.push("Transition");- if (clip.animIn) parts.push("In");- if (clip.animOut) parts.push("Out");- if (clip.look) parts.push("Look");- return parts.join(" · ") || "None";-}--/** One undo checkpoint per slider drag (mirrors the Inspector's helper —- * importing it would cycle back through Inspector). */-function useSliderCheckpoint() {- const active = useRef(false);- return {- begin() {- if (active.current) return;- active.current = true;- useEditor.getState().pushHistory();- },- end() {- active.current = false;- },- };-}--function Tile({- selected,- onClick,- label,- className,- children,-}: {- selected: boolean;- onClick: () => void;- label: string;- className?: string;- children: React.ReactNode;-}) {- return (- <button- type="button"- aria-pressed={selected}- className={cn(- "flex flex-col items-center gap-1.5 rounded-lg border border-border p-2.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",- selected && "bg-primary/10 text-foreground ring-2 ring-[#0a84ff] ring-offset-1 ring-offset-card",- className- )}- onClick={onClick}- >- {children}- <span className="leading-none">{label}</span>- </button>- );-}--function GridLabel({ children }: { children: React.ReactNode }) {- return (- <div className="col-span-2 mt-1.5 text-[10.5px] font-semibold uppercase tracking-wide text-muted-foreground/70 first:mt-0">- {children}- </div>- );-}--type Tab = "transition" | "in" | "out" | "looks";--/**- * The effects sub-page a clip panel pushes into: segmented tabs over card- * grids — the transition into the next clip, the clip's own entrance/exit- * animations, and its filter look — with the active effect's duration or- * intensity slider beneath the grid.- */-export function ClipEffectsPanel({- clip,- hasNext,- onBack,-}: {- clip: VideoClip;- hasNext: boolean;- onBack: () => void;-}) {- const [tab, setTab] = useState<Tab>(hasNext ? "transition" : "in");- const [xfadeDraft, setXfadeDraft] = useState<number | null>(null);- const ck = useSliderCheckpoint();- // Upper tracks composite via alpha, so only the animations expressible as- // alpha/zoom ramps are offered there (the rest would silently degrade).- const animStyles = clip.track > 0 ? (["fade", "zoom"] as AnimStyle[]) : ANIM_STYLE_IDS;- const xfade = xfadeDraft ?? clip.transition ?? 0;-- // Picking or retuning an effect immediately plays the affected stretch of- // the real timeline in the preview — seek just ahead of it, play, and- // auto-pause just after — so every option shows itself on the actual- // footage. Windows are computed from fresh state (setting a transition can- // slide the following clips).- const PREVIEW_LEAD = 0.4;- const PREVIEW_TAIL = 0.35;- const previewTransition = () => {- const s = useEditor.getState();- const spans = getClipSpans(s.clips, s.assets, clip.track);- const i = spans.findIndex((sp) => sp.clip.id === clip.id);- const sp = spans[i];- const next = spans[i + 1];- if (!sp || !next || sp.transitionOut <= 0) return;- s.previewRange(next.start - PREVIEW_LEAD, next.start + sp.transitionOut + PREVIEW_TAIL);- };- const previewAnim = (which: "in" | "out") => {- const s = useEditor.getState();- const sp = getClipSpans(s.clips, s.assets, clip.track).find((x) => x.clip.id === clip.id);- const fresh = s.clips.find((c) => c.id === clip.id);- const a = which === "in" ? fresh?.animIn : fresh?.animOut;- if (!sp || !a) return;- if (which === "in") s.previewRange(sp.start - 0.25, sp.start + a.seconds + PREVIEW_TAIL);- else s.previewRange(sp.start + sp.len - a.seconds - PREVIEW_LEAD, sp.start + sp.len + 0.25);- };- const previewLook = () => {- // A look is static — landing the playhead on the clip's own footage- // shows it instantly; no play-through needed.- const s = useEditor.getState();- const sp = getClipSpans(s.clips, s.assets, clip.track).find((x) => x.clip.id === clip.id);- if (!sp) return;- if (s.currentTime < sp.start || s.currentTime >= sp.start + sp.len) {- s.seek(sp.start + sp.len / 2);- }- };-- const pickTransition = (style: TransitionStyle | null) => {- // Picking a style with the length still at zero turns the transition on- // at a sensible default.- if (style === null) {- useEditor.getState().setClipTransition(clip.id, 0);- return;- }- useEditor.getState().setClipTransition(clip.id, xfade >= 0.05 ? xfade : 0.5, style);- previewTransition();- };- const pickAnim = (which: "in" | "out", style: AnimStyle | null) => {- const current = which === "in" ? clip.animIn : clip.animOut;- useEditor- .getState()- .setClipAnim(- clip.id,- which,- style ? { style, seconds: current?.seconds ?? ANIM_DEFAULT_SECONDS } : null- );- if (style) previewAnim(which);- };- const setAnimSeconds = (which: "in" | "out", seconds: number) => {- const current = which === "in" ? clip.animIn : clip.animOut;- if (!current) return;- ck.begin();- useEditor.getState().updateClipTransient(clip.id, {- [which === "in" ? "animIn" : "animOut"]: {- style: current.style,- seconds: Math.max(0.1, Math.min(TRANSITION_MAX, seconds)),- },- });- };- const setLookAmount = (v: number) => {- if (!clip.look) return;- ck.begin();- useEditor.getState().updateClipTransient(clip.id, {- lookAmount: v >= 1 ? undefined : Math.max(0.05, v),- });- };-- const tabs: { id: Tab; label: string; disabled?: boolean; title?: string }[] = [- {- id: "transition",- label: "Transition",- disabled: !hasNext,- title: hasNext ? undefined : "Needs a following clip on this track",- },- { id: "in", label: "In" },- { id: "out", label: "Out" },- { id: "looks", label: "Looks" },- ];- // Never sit on a disabled tab (e.g. picking a transition disables Out while- // Out is open): fall to the first enabled one.- const activeTab = tabs.find((t) => t.id === tab && !t.disabled)- ? tab- : (tabs.find((t) => !t.disabled)?.id ?? "looks");- const anim = activeTab === "in" ? clip.animIn : activeTab === "out" ? clip.animOut : undefined;-- return (- <>- <div className="flex h-10 shrink-0 items-center gap-1 px-2.5 text-sm font-semibold tracking-tight">- <button- type="button"- aria-label="Back"- className="clip-fx-back grid size-6 place-items-center rounded text-muted-foreground transition-colors hover:text-foreground"- onClick={onBack}- >- <ChevronLeft className="size-4" />- </button>- Effects- </div>- <div className="flex flex-col gap-2 px-3.5 pb-4">- <div className="flex shrink-0 rounded-lg bg-muted p-0.5 text-[11.5px] font-medium">- {tabs.map((t) => (- <button- key={t.id}- type="button"- disabled={t.disabled}- title={t.title}- className={cn(- "clip-fx-tab flex-1 rounded-md px-1.5 py-1 transition-colors",- activeTab === t.id- ? "bg-neutral-900 text-white"- : "text-muted-foreground hover:text-foreground",- t.disabled && "cursor-not-allowed opacity-40 hover:text-muted-foreground"- )}- onClick={() => !t.disabled && setTab(t.id)}- >- {t.label}- </button>- ))}- </div>-- {activeTab === "transition" && (- <>- <div className="grid grid-cols-2 gap-1.5">- <Tile- selected={(clip.transition ?? 0) <= 0}- onClick={() => pickTransition(null)}- label="None"- className="clip-fx-none"- >- <Ban className="size-4" />- </Tile>- {TRANSITION_STYLE_GROUPS.map((g) => (- <Fragment key={g.label}>- <GridLabel>{g.label}</GridLabel>- {g.ids.map((id) => {- const Icon = TRANSITION_TILE_ICONS[id];- return (- <Tile- key={id}- selected={- (clip.transition ?? 0) > 0 && (clip.transitionStyle ?? "crossfade") === id- }- onClick={() => pickTransition(id)}- label={TRANSITION_STYLE_LABELS[id]}- className={`clip-fx-t-${id}`}- >- <Icon className="size-4" />- </Tile>- );- })}- </Fragment>- ))}- </div>- {(clip.transition ?? 0) > 0 && (- <div className="flex items-center gap-2 pt-1">- <span className="w-14 shrink-0 text-[11.5px] text-muted-foreground">Length</span>- <Slider- className="clip-xfade data-horizontal:w-24"- min={0.1}- max={TRANSITION_MAX}- step={0.1}- value={xfade}- onValueChange={(v) => setXfadeDraft(Number(v))}- onValueCommitted={() => {- if (xfadeDraft != null) {- useEditor.getState().setClipTransition(clip.id, xfadeDraft);- previewTransition();- }- setXfadeDraft(null);- }}- />- <ScrubValue- label="Transition length"- className="w-9 text-muted-foreground"- value={xfade}- min={0}- max={TRANSITION_MAX}- step={0.1}- format={(v) => `${v.toFixed(1)}s`}- parse={parseSecondsInput}- onScrub={setXfadeDraft}- onCommit={(v) => {- useEditor.getState().setClipTransition(clip.id, v);- previewTransition();- setXfadeDraft(null);- }}- />- </div>- )}- </>- )}-- {(activeTab === "in" || activeTab === "out") && (- <>- <div className="grid grid-cols-2 gap-1.5">- <Tile- selected={!anim}- onClick={() => pickAnim(activeTab, null)}- label="None"- className="clip-fx-none"- >- <Ban className="size-4" />- </Tile>- {animStyles.map((id) => {- const Icon = ANIM_TILE_ICONS[id];- return (- <Tile- key={id}- selected={anim?.style === id}- onClick={() => pickAnim(activeTab, id)}- label={ANIM_STYLE_LABELS[id]}- className={`clip-fx-a-${id}`}- >- <Icon className="size-4" />- </Tile>- );- })}- </div>- {anim && (- <div className="flex items-center gap-2 pt-1">- <span className="w-14 shrink-0 text-[11.5px] text-muted-foreground">Length</span>- <Slider- className="clip-fx-anim-secs data-horizontal:w-24"- min={0.1}- max={TRANSITION_MAX}- step={0.1}- value={anim.seconds}- onValueChange={(v) => setAnimSeconds(activeTab, Number(v))}- onValueCommitted={() => {- ck.end();- previewAnim(activeTab);- }}- />- <ScrubValue- label="Animation length"- className="w-9 text-muted-foreground"- value={anim.seconds}- min={0.1}- max={TRANSITION_MAX}- step={0.1}- format={(v) => `${v.toFixed(1)}s`}- parse={parseSecondsInput}- onScrub={(v) => setAnimSeconds(activeTab, v)}- onCommit={(v) => {- setAnimSeconds(activeTab, v);- ck.end();- previewAnim(activeTab);- }}- />- </div>- )}- </>- )}-- {activeTab === "looks" && (- <>- <div className="grid grid-cols-2 gap-1.5">- <Tile- selected={!clip.look}- onClick={() => useEditor.getState().setClipLook(clip.id, null)}- label="None"- className="clip-fx-none"- >- <LookSwatch />- </Tile>- {LOOK_IDS.map((id) => (- <Tile- key={id}- selected={clip.look === id}- onClick={() => {- useEditor.getState().setClipLook(clip.id, id, clip.lookAmount);- previewLook();- }}- label={LOOK_LABELS[id]}- className={`clip-fx-l-${id}`}- >- <LookSwatch look={id} />- </Tile>- ))}- </div>- {clip.look && (- <div className="flex items-center gap-2 pt-1">- <span className="w-14 shrink-0 text-[11.5px] text-muted-foreground">Intensity</span>- <Slider- className="clip-fx-look-amount data-horizontal:w-24"- min={0.05}- max={1}- step={0.05}- value={clip.lookAmount ?? 1}- onValueChange={(v) => setLookAmount(Number(v))}- onValueCommitted={() => ck.end()}- />- <ScrubValue- label="Look intensity"- className="w-9 text-muted-foreground"- value={clip.lookAmount ?? 1}- min={0.05}- max={1}- step={0.05}- format={(v) => `${Math.round(v * 100)}%`}- parse={parsePercentInput}- onScrub={setLookAmount}- onCommit={(v) => {- setLookAmount(v);- ck.end();- }}- />- </div>- )}- </>- )}- </div>- </>- );-}--/** A look tile's thumbnail: one shared colorful gradient run through the- * look's own CSS filter, so the tiles are the single source of truth with the- * preview grading. No look = the unfiltered gradient. */-function LookSwatch({ look }: { look?: LookStyle }) {- return (- <span- aria-hidden- className="h-8 w-full rounded-md"- style={{- background: "linear-gradient(135deg,#f59e0b 0%,#ec4899 50%,#3b82f6 100%)",- filter: look ? lookCssFilter(look, 1) || undefined : undefined,- }}- />- );-}diff --git a/site/src/cut/components/Editor.tsx b/site/src/cut/components/Editor.tsxindex 276ad2f4..d751f5ed 100644--- a/site/src/cut/components/Editor.tsx+++ b/site/src/cut/components/Editor.tsx@@ -26,6 +26,10 @@ import { enrichAsset, importFileToProject, prepareImport } from "@/cut/lib/media// Side-effect import: registers the brief-to-video resume subscription, so a// persisted run resumes on project load even when the AI panel never mounts.import "@/cut/lib/genScene";+// Side-effect import: registers the bundled Google font families (build-time+// self-hosted) into the shared font registry before any text renders.+import "@/cut/lib/googleFonts";+import { syncFontAssets } from "@/cut/lib/fontAssets";import { installDevHooks } from "@/cut/lib/devHooks";import { ensureCloudThreads } from "@/cut/lib/chatCloud";import { readProjectThreads, writeActiveChat } from "@/cut/lib/chatThreads";@@ -36,6 +40,7 @@ import { resolveProjectPlacement } from "@/cut/lib/residency";import {docAudioClips,docClips,+ docOverlays,projectDuration,serializeDoc,storedAssets,@@ -96,10 +101,15 @@ export function Editor({const aiOpen = useEditor((s) => s.aiOpen);const sharedFeatures = useEditor((s) => s.sharedFeatures);// The inspector only earns its column when the selection has a panel to- // show; otherwise (nothing selected, or a subtitle cue) it is an empty white- // panel, so collapse it and let the preview take the space.+ // show; otherwise (nothing selected, a subtitle cue, a transition bar — the+ // Transitions tab is its panel) it is an empty white panel, so collapse it+ // and let the preview take the space.const hasInspector = useEditor(- (s) => !s.readOnly && s.selection != null && s.selection.kind !== "cue"+ (s) =>+ !s.readOnly &&+ s.selection != null &&+ s.selection.kind !== "cue" &&+ s.selection.kind !== "transition");const [importing, setImporting] = useState(0);// Files being probed and named, plus the ones already placed whose bytes are@@ -107,6 +117,10 @@ export function Editor({const sending = useEditor((s) =>s.assets.reduce((n, a) => (a.upload && !a.upload.error ? n + 1 : n), 0));+ // Uploaded fonts become live FontFaces the moment their assets exist (and+ // drop out when deleted), so titles set in them never measure a fallback.+ const assetsForFonts = useEditor((s) => s.assets);+ useEffect(() => syncFontAssets(assetsForFonts), [assetsForFonts]);const [conflictReloaded, setConflictReloaded] = useState(false);const [shareGone, setShareGone] = useState(false);// This project lives on this Mac and the Donkey app isn't answering. Nothing@@ -512,7 +526,7 @@ export function Editor({// held out of the document, and holding one is not an edit.docClips(s.clips, s.assets) !== (last.clips as unknown) ||docAudioClips(s.audioClips, s.assets) !== (last.audioClips as unknown) ||- s.overlays !== (last.overlays as unknown) ||+ docOverlays(s.overlays) !== (last.overlays as unknown) ||s.templates !== (last.templates as unknown) ||s.subtitles !== (last.subtitles as unknown) ||s.aspect !== last.aspect ||@@ -760,7 +774,7 @@ export function Editor({s.setAiOpen(!s.aiOpen);} else if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "b") {e.preventDefault();- // iMovie: cut at the skimmer when the mouse is over the timeline.+ // Cut at the skimmer when the mouse is over the timeline.s.splitAtPlayhead(s.skimTime ?? undefined);} else if (e.key.toLowerCase() === "s" && !e.metaKey && !e.ctrlKey) {s.splitAtPlayhead(s.skimTime ?? undefined);diff --git a/site/src/cut/components/EffectsPanel.tsx b/site/src/cut/components/EffectsPanel.tsxnew file mode 100644index 00000000..0e3fc50f--- /dev/null+++ b/site/src/cut/components/EffectsPanel.tsx@@ -0,0 +1,201 @@+"use client";++import { useEffect, useRef, useState } from "react";+import {+ EFFECT_IDS,+ EFFECT_LABELS,+ effectPreviewState,+ type EffectId,+} from "@donkeycut/effects-kit";+import { PICKED_RING, useAssetPick } from "@/cut/lib/assetPick";+import { clearElementDrag, setElementDragData } from "@/cut/lib/assetDrag";+import { useEditor } from "@/cut/lib/store";+import { isEffectOverlay, type EffectOverlay } from "@/cut/lib/types";+import { cn } from "@/lib/utils";+import { ScrollArea } from "@/components/ui/scroll-area";++/**+ * The Effects tab: time-ranged treatments over the finished picture — the+ * footage and everything laid over it. Two families in one list, the+ * treatments (grain, VHS, glitch, blur, vignette, light leak, flash, shake)+ * and the graded looks (vintage, noir, halation…). Drag one onto the timeline+ * to place it; a click only picks the tile, the same as every other panel.+ *+ * Select an effect on the timeline and the tab follows it: its tile is the+ * marked one, and a click on another tile changes that element to it. The+ * click never places anything — with an effect selected it retunes what is+ * already there, and with nothing selected it just picks.+ */+export function EffectsPanel() {+ const live = useEditor((s) => {+ if (s.selection?.kind !== "overlay") return null;+ const o = s.overlays.find((x) => x.id === s.selection!.id);+ return o && isEffectOverlay(o) ? o : null;+ });+ return (+ <>+ <div className="flex h-12 shrink-0 items-center pr-2.5 pl-4">+ <span className="text-sm font-semibold tracking-tight">Effects</span>+ </div>++ {/* The top pad is the selected tile's ring and its offset: the grid+ starts at the scroll edge, and a ring drawn outside the tile would be+ cut off there. */}+ <ScrollArea className="min-h-0 flex-1" contentClassName="px-3.5 pt-1 pb-4">+ <div className="grid grid-cols-2 gap-2">+ {EFFECT_IDS.map((id) => (+ <EffectTile key={id} id={id} live={live} />+ ))}+ </div>+ </ScrollArea>+ </>+ );+}++/** One effect: the preview fills the tile with its name under it, a click+ * picks it (or swaps the selected element to it), and a drag onto the timeline+ * places it. Hovering runs the preview — the flash pulses, the glitch tears,+ * the shake moves. */+function EffectTile({ id, live }: { id: EffectId; live: EffectOverlay | null }) {+ const { picked, pick } = useAssetPick(`effect:${id}`);+ const [hover, setHover] = useState(false);+ const t = useSwatchClock(hover);+ const ref = useRef<HTMLButtonElement>(null);+ // What the selection means for this tile: it wears the ring when it is the+ // selected element's effect, and a click swaps that element onto it.+ const isLive = live?.effect === id;+ const marked = live ? isLive : picked;+ useEffect(() => {+ // Selecting an effect far down the list brings its tile into view.+ if (isLive) ref.current?.scrollIntoView({ block: "nearest" });+ }, [isLive]);+ return (+ <button+ ref={ref}+ type="button"+ aria-pressed={marked}+ title={+ live+ ? `Change the selected effect to ${EFFECT_LABELS[id]}`+ : `Drag ${EFFECT_LABELS[id]} onto the timeline`+ }+ draggable+ onDragStart={(e) => setElementDragData(e, { kind: "effect", effect: id })}+ onDragEnd={clearElementDrag}+ onPointerEnter={() => setHover(true)}+ onPointerLeave={() => setHover(false)}+ onFocus={() => setHover(true)}+ onBlur={() => setHover(false)}+ onClick={() => {+ if (!live) return pick();+ if (!isLive) useEditor.getState().updateOverlay(live.id, { effect: id });+ }}+ className={cn(+ // Scroll margin keeps the whole tile — selection ring included — clear+ // of the scroller's edges when scrollIntoView lands it there.+ "flex scroll-m-2 flex-col overflow-hidden rounded-lg border border-border text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground",+ marked && PICKED_RING+ )}+ >+ <EffectSwatch id={id} t={t} className="h-16 w-full rounded-none" />+ <span className="py-1.5 leading-none">{EFFECT_LABELS[id]}</span>+ </button>+ );+}++/** Seconds into the effect the preview stands at: still at rest, running while+ * the tile is hovered so the time-varying effects show what they do. */+const SWATCH_T = 0.12; // seconds in — past a flash's white peak+const LOOP_S = 1.4;++function useSwatchClock(running: boolean): number {+ const [t, setT] = useState(SWATCH_T);+ useEffect(() => {+ if (!running) return;+ let raf = 0;+ let from = 0;+ const step = (now: number) => {+ if (!from) from = now;+ setT(((now - from) / 1000) % LOOP_S);+ raf = requestAnimationFrame(step);+ };+ raf = requestAnimationFrame(step);+ // Back to the resting frame as the pointer leaves.+ return () => {+ cancelAnimationFrame(raf);+ setT(SWATCH_T);+ };+ }, [running]);+ return t;+}++/** What an effect does to a picture, on a stand-in picture: the same preview+ * state the canvas pass reads, over a gradient with a bright disc in it so+ * blur, grain, vignette, tearing and shake all read at tile size. */+export function EffectSwatch({+ id,+ t = SWATCH_T,+ className,+}: {+ id: EffectId;+ t?: number;+ className?: string;+}) {+ const st = effectPreviewState(id, 0.9, t);+ const wash = st.washes?.[0];+ // The shake's offset is in design pixels against a 1080 short side; the+ // swatch is a fraction of that, so it needs the room exaggerated to read.+ const pct = (px: number) => (px / 1080) * 800;+ const shake =+ st.dx || st.dy || st.zoom+ ? `translate(${pct(st.dx ?? 0).toFixed(2)}%, ${pct(st.dy ?? 0).toFixed(2)}%) scale(${st.zoom ?? 1})`+ : undefined;+ // A zoom scales about the point it holds; everything else about the middle.+ const origin = st.origin ? `${st.origin.x * 100}% ${st.origin.y * 100}%` : undefined;+ const scene = "absolute inset-0 bg-[linear-gradient(135deg,#5b7cfa_0%,#c04cc0_55%,#f0a12e_100%)]";+ return (+ <span className={cn("relative block overflow-hidden rounded-md bg-black", className)}>+ {!!st.ghostFrac && (+ <span+ className={cn(scene, "opacity-60 mix-blend-screen")}+ style={{ transform: `translateX(${(st.ghostFrac * 900).toFixed(2)}%)` }}+ />+ )}+ <span+ className={scene}+ style={{ filter: st.cssFilter || undefined, transform: shake, transformOrigin: origin }}+ >+ <span className="absolute top-1/4 left-[18%] size-1/3 rounded-full bg-white/85" />+ </span>+ {!!st.grain && (+ <span+ className="absolute inset-0 bg-[radial-gradient(circle_at_1px_1px,#fff_0.5px,transparent_0)] bg-[length:3px_3px]"+ style={{ opacity: Math.min(0.9, st.grain * 3) }}+ />+ )}+ {!!st.vignette && st.vignette > 0 && (+ <span+ className="absolute inset-0"+ style={{+ background: `radial-gradient(circle at 50% 50%, transparent 30%, rgba(0,0,0,${st.vignette.toFixed(2)}) 100%)`,+ }}+ />+ )}+ {wash && (+ <span+ className="absolute inset-0"+ style={{+ background: wash.color,+ opacity: Math.min(0.7, wash.alpha * 2.5),+ // The recipe names its wash with a canvas composite op; the ones+ // effects use are CSS blend modes by the same name.+ mixBlendMode: wash.mode as React.CSSProperties["mixBlendMode"],+ }}+ />+ )}+ {!!st.flash && (+ <span className="absolute inset-0 bg-white" style={{ opacity: Math.min(0.75, st.flash) }} />+ )}+ </span>+ );+}diff --git a/site/src/cut/components/ElementsPanel.tsx b/site/src/cut/components/ElementsPanel.tsxnew file mode 100644index 00000000..e6ac64b4--- /dev/null+++ b/site/src/cut/components/ElementsPanel.tsx@@ -0,0 +1,282 @@+"use client";++import { ChevronLeft, ChevronRight, Sparkles } from "lucide-react";+import { Tile } from "@/cut/components/PanelTile";+import { SectionTitle } from "@/cut/components/SectionTitle";+import { clearElementDrag, setElementDragData, type ElementDrag } from "@/cut/lib/assetDrag";+import { PICKED_RING, useAssetPick } from "@/cut/lib/assetPick";+import { useEditor } from "@/cut/lib/store";+import { SHAPE_LABELS, type ShapeKind } from "@/cut/lib/types";+import { useLocalPref } from "@/cut/lib/uiState";+import { cn } from "@/lib/utils";+import { CreateSticker, StickerTile, useProjectStickers } from "./Stickers";+import { ScrollArea } from "@/components/ui/scroll-area";++/**+ * The Elements tab: what you lay over the picture — the project's stickers+ * and the shapes.+ *+ * It browses in two levels. The top level is a shelf: each category shows a+ * row of what's in it and a "View all" into the category's own full grid.+ * The chips jump straight to a category, and the back arrow returns to the+ * shelf. A click picks a tile and nothing else, wherever it is; dragging one+ * onto the timeline is what places it (`assetPick.ts`).+ */++type Category = "stickers" | "shapes";++const CATEGORIES: { id: Category; label: string }[] = [+ { id: "stickers", label: "Stickers" },+ { id: "shapes", label: "Shapes" },+];++const SHAPE_KINDS = Object.keys(SHAPE_LABELS) as ShapeKind[];++/** How many of a category the shelf shows before "View all". */+const PEEK = 4;++export function ElementsPanel({ projectId }: { projectId: string }) {+ const readOnly = useEditor((s) => s.readOnly);+ const [view, setView] = useLocalPref<Category | "all">(+ "cut-elements-view",+ "all",+ (v) => v === "all" || CATEGORIES.some((c) => c.id === v)+ );+ const { stickers, handleOf } = useProjectStickers();++ const stickerTiles = (limit?: number) =>+ (limit ? stickers.slice(0, limit) : stickers).map((a) => (+ <StickerTile+ key={a.id}+ asset={a}+ projectId={projectId}+ handle={handleOf(a.id)}+ readOnly={readOnly}+ />+ ));++ return (+ <>+ <div className="flex h-12 shrink-0 items-center gap-1 pr-2.5 pl-4">+ {view !== "all" && (+ <button+ type="button"+ title="All elements"+ aria-label="All elements"+ className="-ml-2 grid size-6 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"+ onClick={() => setView("all")}+ >+ <ChevronLeft className="size-4" />+ </button>+ )}+ <span className="text-sm font-semibold tracking-tight">+ {view === "all" ? "Elements" : CATEGORIES.find((c) => c.id === view)?.label}+ </span>+ </div>++ <ScrollArea className="min-h-0 flex-1" contentClassName="flex flex-col gap-4 px-3.5 pb-4">+ <div className="flex shrink-0 flex-wrap gap-1.5">+ <Chip active={view === "all"} onClick={() => setView("all")}>+ All+ </Chip>+ {CATEGORIES.map((c) => (+ <Chip key={c.id} active={view === c.id} onClick={() => setView(c.id)}>+ {c.label}+ </Chip>+ ))}+ </div>++ {view === "all" && (+ <>+ <Section title="Stickers" onViewAll={() => setView("stickers")}>+ <div className="grid grid-cols-4 gap-1.5">+ {!readOnly && (+ <PeekTile title="Create a sticker" onClick={() => setView("stickers")}>+ <Sparkles className="size-4 text-muted-foreground" />+ </PeekTile>+ )}+ {stickerTiles(readOnly ? PEEK : PEEK - 1)}+ </div>+ </Section>++ <Section title="Shapes" onViewAll={() => setView("shapes")}>+ <div className="grid grid-cols-4 gap-1.5">+ {SHAPE_KINDS.slice(0, PEEK).map((k) => (+ <ShapePeek key={k} shape={k} />+ ))}+ </div>+ </Section>+ </>+ )}++ {view === "stickers" && (+ <>+ {!readOnly && <CreateSticker projectId={projectId} />}+ {stickers.length > 0 ? (+ <div className="grid shrink-0 grid-cols-2 gap-1.5">{stickerTiles()}</div>+ ) : (+ <p className="px-2 py-6 text-center text-xs leading-relaxed text-balance text-muted-foreground">+ Stickers you make land here, cut out and ready to place.+ </p>+ )}+ </>+ )}++ {view === "shapes" && (+ <div className="grid shrink-0 grid-cols-3 gap-1.5">+ {SHAPE_KINDS.map((k) => (+ <ShapeTile key={k} shape={k} />+ ))}+ </div>+ )}+ </ScrollArea>+ </>+ );+}++/** A category filter at the top of the panel; picking one opens its grid. */+function Chip({+ active,+ onClick,+ children,+}: {+ active: boolean;+ onClick: () => void;+ children: React.ReactNode;+}) {+ return (+ <button+ type="button"+ aria-pressed={active}+ onClick={onClick}+ className={cn(+ "rounded-full border px-2.5 py-1 text-[11.5px] font-medium transition-colors",+ active+ ? "border-primary bg-primary text-primary-foreground"+ : "border-input text-muted-foreground hover:bg-muted hover:text-foreground"+ )}+ >+ {children}+ </button>+ );+}++/** One shelf row: the category's name, a way into it, and its peek. */+function Section({+ title,+ onViewAll,+ children,+}: {+ title: string;+ onViewAll: () => void;+ children: React.ReactNode;+}) {+ return (+ <section className="flex shrink-0 flex-col gap-1.5">+ <div className="flex items-center justify-between gap-2">+ <SectionTitle>{title}</SectionTitle>+ <button+ type="button"+ className="flex items-center gap-0.5 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground"+ onClick={onViewAll}+ >+ View all+ <ChevronRight className="size-3" />+ </button>+ </div>+ {children}+ </section>+ );+}++/** A square on a shelf row — the preview carries the meaning, so the name+ * rides the tooltip and the grid inside the category carries the label. */+function PeekTile({+ title,+ onClick,+ picked,+ drag,+ children,+}: {+ title: string;+ onClick: () => void;+ picked?: boolean;+ /** What this tile places when dragged onto the timeline. */+ drag?: ElementDrag;+ children: React.ReactNode;+}) {+ return (+ <button+ type="button"+ title={title}+ aria-label={title}+ aria-pressed={picked}+ draggable={!!drag}+ onDragStart={drag ? (e) => setElementDragData(e, drag) : undefined}+ onDragEnd={drag ? clearElementDrag : undefined}+ className={cn(+ "grid aspect-square w-full place-items-center overflow-hidden rounded-lg border border-border p-1.5 transition-colors hover:bg-muted/60",+ picked && PICKED_RING+ )}+ onClick={onClick}+ >+ {children}+ </button>+ );+}++/** A shape on the shelf row and in the Shapes grid: a click picks it, a drag+ * onto the timeline places it. */+function ShapePeek({ shape }: { shape: ShapeKind }) {+ const { picked, pick } = useAssetPick(`shape:${shape}`);+ return (+ <PeekTile+ title={`Drag ${SHAPE_LABELS[shape]} onto the timeline`}+ picked={picked}+ drag={{ kind: "shape", shape }}+ onClick={pick}+ >+ <ShapeSwatch shape={shape} className="size-6" />+ </PeekTile>+ );+}++function ShapeTile({ shape }: { shape: ShapeKind }) {+ const { picked, pick } = useAssetPick(`shape:${shape}`);+ return (+ <Tile+ selected={picked}+ label={SHAPE_LABELS[shape]}+ title={`Drag ${SHAPE_LABELS[shape]} onto the timeline`}+ className={cn(picked && PICKED_RING)}+ onClick={pick}+ draggable+ onDragStart={(e) => setElementDragData(e, { kind: "shape", shape })}+ onDragEnd={clearElementDrag}+ >+ <ShapeSwatch shape={shape} className="size-7" />+ </Tile>+ );+}++/** A shape's silhouette, drawn the way the painter lays it out. */+function ShapeSwatch({ shape, className }: { shape: ShapeKind; className?: string }) {+ return (+ <svg+ viewBox="0 0 24 24"+ fill="currentColor"+ aria-hidden+ className={cn("text-foreground", className)}+ >+ {shape === "rect" && <rect x="3" y="6" width="18" height="12" rx="2" />}+ {shape === "ellipse" && <ellipse cx="12" cy="12" rx="9.5" ry="7" />}+ {shape === "line" && <rect x="2" y="11" width="20" height="2" rx="1" />}+ {shape === "arrow" && (+ <>+ <rect x="2" y="11" width="14" height="2" rx="1" />+ <polygon points="22,12 14,7.5 14,16.5" />+ </>+ )}+ </svg>+ );+}diff --git a/site/src/cut/components/ExportDialog.tsx b/site/src/cut/components/ExportDialog.tsxindex 6263705c..be1ead6a 100644--- a/site/src/cut/components/ExportDialog.tsx+++ b/site/src/cut/components/ExportDialog.tsx@@ -29,9 +29,10 @@ export function ExportDialog() {const clips = useEditor((s) => s.clips);const assets = useEditor((s) => s.assets);const audioClips = useEditor((s) => s.audioClips);+ const overlays = useEditor((s) => s.overlays);const duration = useMemo(- () => projectDuration({ clips, audioClips }),- [clips, audioClips]+ () => projectDuration({ clips, audioClips, overlays }),+ [clips, audioClips, overlays]);// "Original" leads: sized from the footage on the timeline, so it is always// the highest option. The fixed presets follow, flipped to the aspect.diff --git a/site/src/cut/components/GeneratePanel.tsx b/site/src/cut/components/GeneratePanel.tsxindex 9e4f0b53..a7a0b1bd 100644--- a/site/src/cut/components/GeneratePanel.tsx+++ b/site/src/cut/components/GeneratePanel.tsx@@ -6,6 +6,7 @@ import { Button } from "@/components/ui/button";import { DropdownMenuItem } from "@/components/ui/dropdown-menu";import { MEDIA_CORS } from "@/cut/lib/mediaCors";import { clearAssetDrag, setAssetDragData } from "@/cut/lib/assetDrag";+import { PICKED_RING, useAssetPick } from "@/cut/lib/assetPick";import {collectRefs,mentionToken,@@ -31,12 +32,13 @@ import {type VideoModelOption,} from "@/cut/lib/videoModels";import { cn } from "@/lib/utils";-import { MentionTextarea, RefChips, RefHandlePill } from "./AssetRefs";+import { CopyHandlePill, MentionTextarea, RefChips } from "./AssetRefs";import { DictationControl } from "./MicDictation";import { GeneratedAssetMenu } from "./GeneratedAssetMenu";import { HostedErrorText } from "./hostedError";import { cardIconButton } from "./iconButton";import { PillSelect } from "./PillSelect";+import { ScrollArea } from "@/components/ui/scroll-area";// The generate-video panel: an always-on column in the Video tab, sitting left// of the stock-clip browser. Clicking a stock tile loads its saved prompt here.@@ -114,10 +116,11 @@ export function GenerateVideoPanel({ projectId }: { projectId: string }) {<span className="text-sm font-semibold tracking-tight">Generate video</span></div>- <div+ <ScrollArearef={attachTarget}{...targetProps}- className="relative flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3.5 pb-4"+ className="min-h-0 flex-1"+ contentClassName="flex flex-col gap-3 px-3.5 pb-4">{!readOnly && (<>{/* Composer: the character and attached references ride inside the@@ -251,7 +254,7 @@ export function GenerateVideoPanel({ projectId }: { projectId: string }) {))}</div>)}- </div>+ </ScrollArea></>);}@@ -267,6 +270,7 @@ function JobRow({ job, handle }: { job: GenerateJob; handle?: string }) {const elapsed = useElapsed(job.status === "running" ? job.startedAt : null);const tileRef = useRef<HTMLDivElement>(null);const videoRef = useRef<HTMLVideoElement>(null);+ const { picked, pick } = useAssetPick(job.assetId ?? "");// Render history keeps every settled job; a preview loads only on screen.const [inViewRef, seen] = useInView<HTMLButtonElement>();@@ -327,7 +331,7 @@ function JobRow({ job, handle }: { job: GenerateJob; handle?: string }) {return (<divref={tileRef}- className="gen-job group relative overflow-hidden rounded-lg"+ className={cn("gen-job group relative overflow-hidden rounded-lg", picked && PICKED_RING)}onMouseEnter={() => {const v = videoRef.current;if (!v) return;@@ -362,7 +366,7 @@ function JobRow({ job, handle }: { job: GenerateJob; handle?: string }) {}}}onDragEnd={clearAssetDrag}- onClick={() => useVideoGen.getState().openWith(job.prompt)}+ onClick={pick}><videocrossOrigin={MEDIA_CORS}@@ -375,12 +379,7 @@ function JobRow({ job, handle }: { job: GenerateJob; handle?: string }) {className="aspect-[16/10] w-full bg-black object-cover"/></button>- {handle && (- <RefHandlePill- token={`@${handle}`}- className="absolute top-1 left-1 opacity-0 transition-opacity group-hover:opacity-100"- />- )}+ <CopyHandlePill handle={handle} name={asset.name} /><div className="pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent px-2 py-1.5 opacity-0 transition-opacity group-hover:opacity-100"><span className="block truncate text-[11px] font-medium text-white">{job.prompt}</span></div>@@ -412,15 +411,20 @@ function JobRow({ job, handle }: { job: GenerateJob; handle?: string }) {projectId={job.projectId}triggerClassName="grid size-5 place-items-center rounded-full bg-black/45 text-white opacity-0 transition-opacity group-hover:opacity-100 data-popup-open:opacity-100 hover:bg-black/65"before={- <DropdownMenuItem- onClick={() =>- void navigator.clipboard- .writeText(handle ? `@${handle}` : mentionToken(asset.name))- .catch(() => {})- }- >- <Copy /> Copy reference- </DropdownMenuItem>+ <>+ <DropdownMenuItem onClick={() => useVideoGen.getState().openWith(job.prompt)}>+ <Sparkles /> Use this prompt+ </DropdownMenuItem>+ <DropdownMenuItem+ onClick={() =>+ void navigator.clipboard+ .writeText(handle ? `@${handle}` : mentionToken(asset.name))+ .catch(() => {})+ }+ >+ <Copy /> Copy reference+ </DropdownMenuItem>+ </>}onDelete={() => {// The render dies for real: the tile goes with its job row, anddiff --git a/site/src/cut/components/ImageGenPanel.tsx b/site/src/cut/components/ImageGenPanel.tsxindex b0ae7089..667cdd70 100644--- a/site/src/cut/components/ImageGenPanel.tsx+++ b/site/src/cut/components/ImageGenPanel.tsx@@ -7,6 +7,7 @@ import { DropdownMenuItem } from "@/components/ui/dropdown-menu";import { SectionTitle } from "@/cut/components/SectionTitle";import { MEDIA_CORS } from "@/cut/lib/mediaCors";import { clearAssetDrag, setAssetDragData } from "@/cut/lib/assetDrag";+import { PICKED_RING, useAssetPick } from "@/cut/lib/assetPick";import { collectRefs, mentionToken, useRefCandidates, useAssetDrop } from "@/cut/lib/assetRef";import { genPulseOverlay, useGenPulse } from "@/cut/lib/genNotify";import { useElapsed } from "@/cut/hooks/useElapsed";@@ -23,12 +24,13 @@ import { refsFromDroppedFiles } from "@/cut/lib/refMedia";import { useEditor } from "@/cut/lib/store";import { nearestAspect, type MediaAsset } from "@/cut/lib/types";import { cn } from "@/lib/utils";-import { MentionTextarea, RefChips, RefHandlePill } from "./AssetRefs";+import { CopyHandlePill, MentionTextarea, RefChips } from "./AssetRefs";import { DictationControl } from "./MicDictation";import { cardIconButton } from "./iconButton";import { PillSelect } from "./PillSelect";import { GeneratedAssetMenu } from "./GeneratedAssetMenu";import { HostedErrorText } from "./hostedError";+import { ScrollArea } from "@/components/ui/scroll-area";// The generate-image panel: an always-on column in the Image tab, sitting left// of the stock browser. Clicking a stock tile loads its saved prompt here; the@@ -106,7 +108,7 @@ export function ImageGenPanel({ projectId }: { projectId: string }) {<span className="text-sm font-semibold tracking-tight">Generate image</span></div>- <div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3.5 pb-4">+ <ScrollArea className="min-h-0 flex-1" contentClassName="flex flex-col gap-3 px-3.5 pb-4">{!readOnly && (<>{/* Composer: attached references ride as little image thumbnails insidethe input box, above the prompt (Claude-style). */}@@ -216,7 +218,7 @@ export function ImageGenPanel({ projectId }: { projectId: string }) {))}</div>)}- </div>+ </ScrollArea></div>);}@@ -237,8 +239,12 @@ function GeneratedTile({}) {const tileRef = useRef<HTMLDivElement>(null);const pulse = useGenPulse("image", asset.id);+ const { picked, pick } = useAssetPick(asset.id);return (- <div ref={tileRef} className="group relative overflow-hidden rounded-lg">+ <div+ ref={tileRef}+ className={cn("group relative overflow-hidden rounded-lg", picked && PICKED_RING)}+ ><buttonclassName="block w-full outline-none focus-visible:ring-2 focus-visible:ring-ring"title={asset.name}@@ -257,7 +263,7 @@ function GeneratedTile({}}}onDragEnd={clearAssetDrag}- onClick={() => useImageGen.getState().openWith(asset.name)}+ onClick={pick}>{/* eslint-disable-next-line @next/next/no-img-element -- engine media file, not Next-optimizable */}<img crossOrigin={MEDIA_CORS}@@ -267,12 +273,7 @@ function GeneratedTile({className="aspect-[16/10] w-full bg-black object-cover transition-transform group-hover:scale-[1.04]"/></button>- {handle && (- <RefHandlePill- token={`@${handle}`}- className="absolute top-1 left-1 opacity-0 transition-opacity group-hover:opacity-100"- />- )}+ <CopyHandlePill handle={handle} name={asset.name} /><div className="pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent px-2 py-1.5 opacity-0 transition-opacity group-hover:opacity-100"><span className="block truncate text-[11px] font-medium text-white">{asset.name}</span></div>@@ -297,15 +298,20 @@ function GeneratedTile({projectId={projectId}triggerClassName="grid size-5 place-items-center rounded-full bg-black/45 text-white opacity-0 transition-opacity group-hover:opacity-100 data-popup-open:opacity-100 hover:bg-black/65"before={- <DropdownMenuItem- onClick={() =>- void navigator.clipboard- .writeText(handle ? `@${handle}` : mentionToken(asset.name))- .catch(() => {})- }- >- <Copy /> Copy reference- </DropdownMenuItem>+ <>+ <DropdownMenuItem onClick={() => useImageGen.getState().openWith(asset.name)}>+ <Sparkles /> Use this prompt+ </DropdownMenuItem>+ <DropdownMenuItem+ onClick={() =>+ void navigator.clipboard+ .writeText(handle ? `@${handle}` : mentionToken(asset.name))+ .catch(() => {})+ }+ >+ <Copy /> Copy reference+ </DropdownMenuItem>+ </>}after={<DropdownMenuItemdiff --git a/site/src/cut/components/Inspector.tsx b/site/src/cut/components/Inspector.tsxindex 43a0eb15..813064e0 100644--- a/site/src/cut/components/Inspector.tsx+++ b/site/src/cut/components/Inspector.tsx@@ -1,7 +1,7 @@"use client";import { useCallback, useEffect, useMemo, useRef, useState } from "react";-import { Bold, ChevronLeft, ChevronRight, Info, RotateCcw, SlidersHorizontal, Smile, Wand2 } from "lucide-react";+import { AlignCenter, AlignLeft, AlignRight, Bold, ChevronLeft, ChevronRight, Diamond, Info, Italic, RotateCcw, SlidersHorizontal, Smile, Trash2, Wand2 } from "lucide-react";import { Button } from "@/components/ui/button";import { EmojiPicker } from "@/cut/components/EmojiPicker";import {@@ -20,7 +20,25 @@ import {TooltipTrigger,} from "@/components/ui/tooltip";import { Textarea } from "@/components/ui/textarea";+import {+ EFFECT_LABELS,+ hasOverlayKeys,+ KEY_EPSILON,+ keyIndexAt,+ poseAt,+ type OverlayKey,+ OVERLAY_ANIM_DEFAULT_SECONDS,+ OVERLAY_ANIM_MAX_SECONDS,+ OVERLAY_ANIM_MIN_SECONDS,+ ZOOM_LEVELS,+ ZOOM_RAMP_MAX,+ zoomRampOf,+ type OverlayAnim,+ type OverlayAnimStyle,+ type OverlayLoopStyle,+} from "@donkeycut/effects-kit";import { clipWindow, useEditor, type EditorState } from "@/cut/lib/store";+import { AnimationTiles } from "@/cut/components/AnimationTiles";import { GenerateSubtitlesAudio } from "@/cut/components/VoicePicker";import {parseNumberInput,@@ -30,30 +48,48 @@ import {parseTimeInput,ScrubValue,} from "@/cut/components/ScrubValue";-import { PLATE_COLOR, PLATE_OPACITY, PLATE_RADIUS } from "@/cut/lib/textRender";+import { PLATE_COLOR, PLATE_OPACITY, PLATE_RADIUS, plateFill } from "@/cut/lib/textRender";+import {+ deleteStylePreset,+ listStylePresets,+ saveStylePreset,+ type StylePreset,+} from "@/cut/lib/stylePresets";import { writeTextStyle } from "@/cut/lib/textStyle";import { formatTime } from "@/cut/lib/time";import {- FONTS,+ allFonts,+ fontStack,+ frameOf,GRADE_HUE_MAX,GRADE_MAX,+ isEffectOverlay,+ isShapeOverlay,+ isTextOverlay,LAYOUTS,+ onFontsChanged,rectOf,regionLabel,+ SHAPE_LABELS,SPEED_FLOOR,SPEED_MAX,SPEED_MIN,+ clampOverlayPos,type AudioClip,type ColorGrade,type FrameRect,type LayoutId,+ type EffectOverlay,+ type Overlay,+ type ShapeOverlay,+ type StickerOverlay,type TextOverlay,type VideoClip,} from "@/cut/lib/types";-import { ClipEffectsPanel, effectsSummary } from "@/cut/components/ClipEffectsPanel";-import { autoGradeFromImageData, isNeutralGrade, normalizeGrade } from "@/cut/lib/colorGrade";+import { autoGradeFromImageData, isNeutralGrade, normalizeGrade } from "@donkeycut/effects-kit";import { getPreviewCanvas, sampleClipFrameData } from "@/cut/lib/previewCanvas";import { cn } from "@/lib/utils";+import { ScrollArea } from "@/components/ui/scroll-area";const SWATCHES = ["#FFFFFF", "#111114", "#FFD60A", "#FF375F", "#0A84FF", "#30D158"];@@ -161,19 +197,30 @@ export function Inspector() {selection?.kind === "audio" ? s.audioClips.find((c) => c.id === selection.id) : undefined);const overlay = useEditor((s) =>- selection?.kind === "text" ? s.overlays.find((o) => o.id === selection.id) : undefined+ selection?.kind === "overlay" ? s.overlays.find((o) => o.id === selection.id) : undefined);return (- <aside className="flex min-h-0 flex-col overflow-y-auto border-l border-border bg-card">+ <ScrollArea+ render={<aside />}+ className="flex min-h-0 flex-col border-l border-border bg-card"+ >{clip ? (<ClipPanel key={clip.id} clip={clip} />) : audio ? (<AudioPanel key={audio.id} clip={audio} />) : overlay ? (- <TextPanel key={overlay.id} overlay={overlay} />+ isTextOverlay(overlay) ? (+ <TextPanel key={overlay.id} overlay={overlay} />+ ) : isShapeOverlay(overlay) ? (+ <ShapePanel key={overlay.id} overlay={overlay} />+ ) : isEffectOverlay(overlay) ? (+ <EffectPanel key={overlay.id} overlay={overlay} />+ ) : (+ <StickerPanel key={overlay.id} overlay={overlay} />+ )) : null}- </aside>+ </ScrollArea>);}@@ -201,38 +248,87 @@ function ClipHead({ name, time }: { name?: string; time: string }) {function Row({label,info,+ grow,children,}: {label: string;/** Hoverable (i) after the label explaining what the control does. */info?: React.ReactNode;+ /** Stretch the control over the row's free width; the default hugs the+ * control to the right edge at its own size. */+ grow?: boolean;children: React.ReactNode;}) {return (<div className="flex min-h-9 items-center justify-between gap-2.5"><span className="flex shrink-0 items-center gap-1 text-[13px] text-muted-foreground">{label}- {info && (- <TooltipProvider>- <Tooltip>- <TooltipTrigger- className="grid size-4 place-items-center text-muted-foreground/70 transition-colors hover:text-foreground"- aria-label={`About ${label.toLowerCase()}`}- >- <Info className="size-3.5" />- </TooltipTrigger>- <TooltipContent side="bottom" className="max-w-60">- {info}- </TooltipContent>- </Tooltip>- </TooltipProvider>- )}+ {info && <InfoTip label={label}>{info}</InfoTip>}</span>- <div className="flex min-w-0 items-center gap-2">{children}</div>+ <div className={cn("flex min-w-0 items-center gap-2", grow && "grow")}>{children}</div></div>);}+/** Hoverable (i) explaining the control it follows. */+function InfoTip({ label, children }: { label: string; children: React.ReactNode }) {+ return (+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger+ className="grid size-4 place-items-center text-muted-foreground/70 transition-colors hover:text-foreground"+ aria-label={`About ${label.toLowerCase()}`}+ >+ <Info className="size-3.5" />+ </TooltipTrigger>+ <TooltipContent side="bottom" className="max-w-60">+ {children}+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ );+}++/**+ * A named group of rows under a hairline. A section that owns a feature carries+ * the switch that turns it on and holds its rows back until it is, so the panel+ * reads as a short list of what the element actually has and grows only where+ * it was asked to. Pass no `onEnabledChange` for a group that is always open.+ */+function Section({+ title,+ info,+ enabled,+ onEnabledChange,+ aside,+ children,+}: {+ title: string;+ info?: React.ReactNode;+ enabled?: boolean;+ onEnabledChange?: (enabled: boolean) => void;+ /** Controls that belong to the group as a whole, sat at the end of its title. */+ aside?: React.ReactNode;+ children?: React.ReactNode;+}) {+ const gated = !!onEnabledChange;+ return (+ <section className="mt-1.5 border-t border-border pt-1.5">+ <div className="flex min-h-9 items-center justify-between gap-2">+ <span className="flex min-w-0 items-center gap-1 text-[13px] font-medium">+ <span className="truncate">{title}</span>+ {info && <InfoTip label={title}>{info}</InfoTip>}+ </span>+ {aside}+ {gated && (+ <Switch checked={!!enabled} onCheckedChange={onEnabledChange} aria-label={title} />+ )}+ </div>+ {(!gated || enabled) && children}+ </section>+ );+}+const Value = ({ children, className }: { children: React.ReactNode; className?: string }) => (<span className={cn("font-mono text-[11.5px] tabular-nums", className)}>{children}</span>);@@ -306,21 +402,12 @@ function LayoutButtons({function ClipPanel({ clip }: { clip: VideoClip }) {const asset = useEditor((s) => s.assets.find((a) => a.id === clip.assetId));const updateClip = useEditor((s) => s.updateClip);- // A transition hands this clip into the next one on its own track — every- // track carries transitions — so offer it whenever a same-track clip- // follows this one.- const hasNext = useEditor((s) =>- s.clips.some((c) => c.track === clip.track && c.start > clip.start + 1e-6)- );const [speedDraft, setSpeedDraft] = useState<number | null>(null);const [volumeDraft, setVolumeDraft] = useState<number | null>(null);- // The panel can push into the color-grade or effects subview. Each subview- // remembers which clip opened it, so selecting another clip lands back on- // the main view without an effect.+ // The panel can push into the color-grade subview, which remembers which+ // clip opened it, so selecting another clip lands back on the main view.const [colorFor, setColorFor] = useState<string | null>(null);- const [effectsFor, setEffectsFor] = useState<string | null>(null);- const view =- colorFor === clip.id ? "color" : effectsFor === clip.id ? "effects" : "main";+ const view = colorFor === clip.id ? "color" : "main";const volume = volumeDraft ?? clip.volume ?? 1;const speed = speedDraft ?? clip.speed ?? 1;const speedLen = (clip.out - clip.in) / (speed > 0 ? speed : 1);@@ -330,9 +417,6 @@ function ClipPanel({ clip }: { clip: VideoClip }) {if (view === "color") {return <ColorPanel clip={clip} onBack={() => setColorFor(null)} />;}- if (view === "effects") {- return <ClipEffectsPanel clip={clip} hasNext={hasNext} onBack={() => setEffectsFor(null)} />;- }return (<><div className="flex flex-col gap-1 px-3.5 pb-4">@@ -436,16 +520,6 @@ function ClipPanel({ clip }: { clip: VideoClip }) {<ChevronRight className="size-3.5" /></button></Row>- <Row label="Effects">- <button- type="button"- className="clip-effects flex h-8 w-[8.5rem] items-center justify-between rounded-md border border-input px-2.5 text-[11.5px] font-medium text-muted-foreground transition-colors hover:text-foreground"- onClick={() => setEffectsFor(clip.id)}- >- <span className="truncate">{effectsSummary(clip, hasNext)}</span>- <ChevronRight className="size-3.5 shrink-0" />- </button>- </Row>{/* Audio */}<div className="my-1.5 h-px bg-border" />@@ -1026,7 +1100,17 @@ function TextPanel({ overlay: o }: { overlay: TextOverlay }) {const sizeCk = useSliderCheckpoint();const radiusCk = useSliderCheckpoint();const opacityCk = useSliderCheckpoint();+ const spacingCk = useSliderCheckpoint();+ const lineHeightCk = useSliderCheckpoint();+ const strokeCk = useSliderCheckpoint();+ const shadowCk = useSliderCheckpoint();const taRef = useRef<HTMLTextAreaElement>(null);+ // The font menu re-reads the registry when Google families finish+ // registering or an uploaded font lands (the bump re-renders, and the+ // render re-reads allFonts()).+ const [, bumpFonts] = useState(0);+ useEffect(() => onFontsChanged(() => bumpFonts((n) => n + 1)), []);+ const fonts = allFonts();// Remember this title's look across clips and projects, so the next new title// starts from the same style.@@ -1035,14 +1119,19 @@ function TextPanel({ overlay: o }: { overlay: TextOverlay }) {size: o.size,font: o.font,weight: o.weight,+ italic: o.italic,color: o.color,+ stroke: o.stroke,+ letterSpacing: o.letterSpacing,+ lineHeight: o.lineHeight,+ align: o.align,shadow: o.shadow,plate: o.plate,plateColor: o.plateColor,plateOpacity: o.plateOpacity,plateRadius: o.plateRadius,});- }, [o.size, o.font, o.weight, o.color, o.shadow, o.plate, o.plateColor, o.plateOpacity, o.plateRadius]);+ }, [o.size, o.font, o.weight, o.italic, o.color, o.stroke, o.letterSpacing, o.lineHeight, o.align, o.shadow, o.plate, o.plateColor, o.plateOpacity, o.plateRadius]);const insertEmoji = (emoji: string) => {const ta = taRef.current;@@ -1088,19 +1177,20 @@ function TextPanel({ overlay: o }: { overlay: TextOverlay }) {}/></div>+ <StylePresetsRow overlay={o} /><Row label="Font"><Selectvalue={o.font}- items={Object.fromEntries(FONTS.map((f) => [f.id, f.label]))}+ items={Object.fromEntries(fonts.map((f) => [f.id, f.label]))}onValueChange={(v) => update(o.id, { font: v as TextOverlay["font"] })}><SelectTrigger size="sm" className="w-28"><SelectValue /></SelectTrigger><SelectContent>- {FONTS.map((f) => (+ {fonts.map((f) => (<SelectItem key={f.id} value={f.id}>- {f.label}+ <span style={{ fontFamily: f.stack }}>{f.label}</span></SelectItem>))}</SelectContent>@@ -1115,6 +1205,40 @@ function TextPanel({ overlay: o }: { overlay: TextOverlay }) {><Bold /></Button>+ <Button+ variant="outline"+ size="icon-sm"+ aria-label="Italic"+ aria-pressed={!!o.italic}+ className={cn(o.italic && "border-primary bg-primary/15 text-primary")}+ onClick={() => update(o.id, { italic: o.italic ? undefined : true })}+ >+ <Italic />+ </Button>+ </Row>+ <Row label="Align">+ {(+ [+ ["left", AlignLeft],+ ["center", AlignCenter],+ ["right", AlignRight],+ ] as const+ ).map(([a, Icon]) => {+ const active = (o.align ?? "center") === a;+ return (+ <Button+ key={a}+ variant="outline"+ size="icon-sm"+ aria-label={`Align ${a}`}+ aria-pressed={active}+ className={cn(active && "border-primary bg-primary/15 text-primary")}+ onClick={() => update(o.id, { align: a === "center" ? undefined : a })}+ >+ <Icon />+ </Button>+ );+ })}</Row><Row label="Size"><Slider@@ -1156,15 +1280,157 @@ function TextPanel({ overlay: o }: { overlay: TextOverlay }) {onCommit={(c) => update(o.id, { color: c })}/></Row>- <Row label="Shadow">- <Switch checked={o.shadow} onCheckedChange={(v) => update(o.id, { shadow: v })} />+ <Row label="Spacing">+ <Slider+ className="data-horizontal:w-24"+ min={-0.05}+ max={0.3}+ step={0.005}+ value={o.letterSpacing ?? 0}+ onValueChange={(v) => {+ spacingCk.begin();+ useEditor.getState().updateOverlayTransient(o.id, {+ letterSpacing: Math.abs(Number(v)) < 0.0025 ? undefined : Number(v),+ });+ }}+ onValueCommitted={spacingCk.end}+ />+ <Value className="w-9 text-muted-foreground">+ {Math.round((o.letterSpacing ?? 0) * 100)}+ </Value></Row>- <Row label="Backdrop">- <Switch checked={o.plate} onCheckedChange={(v) => update(o.id, { plate: v })} />+ <Row label="Line height">+ <Slider+ className="data-horizontal:w-24"+ min={0.8}+ max={2}+ step={0.05}+ value={o.lineHeight ?? 1.25}+ onValueChange={(v) => {+ lineHeightCk.begin();+ useEditor.getState().updateOverlayTransient(o.id, {+ lineHeight: Math.abs(Number(v) - 1.25) < 0.025 ? undefined : Number(v),+ });+ }}+ onValueCommitted={lineHeightCk.end}+ />+ <Value className="w-9 text-muted-foreground">{(o.lineHeight ?? 1.25).toFixed(2)}</Value></Row>- {o.plate && (+ <Section+ title="Outline"+ enabled={!!o.stroke}+ onEnabledChange={(v) =>+ update(o.id, { stroke: v ? { color: "#111114", width: 0.04 } : undefined })+ }+ >+ {o.stroke && (+ <>+ <Row label="Color">+ <ColorSwatches+ value={o.stroke.color}+ onBegin={() => useEditor.getState().pushHistory()}+ onLive={(c) =>+ useEditor.getState().updateOverlayTransient(o.id, {+ stroke: { ...o.stroke!, color: c },+ })+ }+ onCommit={(c) => update(o.id, { stroke: { ...o.stroke!, color: c } })}+ />+ </Row>+ <Row label="Width">+ <Slider+ className="data-horizontal:w-24"+ min={0.01}+ max={0.15}+ step={0.005}+ value={o.stroke.width}+ onValueChange={(v) => {+ strokeCk.begin();+ useEditor.getState().updateOverlayTransient(o.id, {+ stroke: { ...o.stroke!, width: Number(v) },+ });+ }}+ onValueCommitted={strokeCk.end}+ />+ <Value className="w-9 text-muted-foreground">+ {Math.round(o.stroke.width * 100)}+ </Value>+ </Row>+ </>+ )}+ </Section>+ <Section+ title="Shadow"+ enabled={!!o.shadow}+ onEnabledChange={(v) => update(o.id, { shadow: v })}+ ><>- <Row label="Backdrop color">+ <Row label="Color">+ <ColorSwatches+ value={(typeof o.shadow === "object" ? o.shadow.color : undefined) ?? "#000000"}+ onBegin={() => useEditor.getState().pushHistory()}+ onLive={(c) =>+ useEditor.getState().updateOverlayTransient(o.id, {+ shadow: { ...(typeof o.shadow === "object" ? o.shadow : {}), color: c },+ })+ }+ onCommit={(c) =>+ update(o.id, {+ shadow: { ...(typeof o.shadow === "object" ? o.shadow : {}), color: c },+ })+ }+ />+ </Row>+ <Row label="Blur">+ <Slider+ className="data-horizontal:w-24"+ min={0}+ max={60}+ step={1}+ value={(typeof o.shadow === "object" ? o.shadow.blur : undefined) ?? 14}+ onValueChange={(v) => {+ shadowCk.begin();+ useEditor.getState().updateOverlayTransient(o.id, {+ shadow: { ...(typeof o.shadow === "object" ? o.shadow : {}), blur: Number(v) },+ });+ }}+ onValueCommitted={shadowCk.end}+ />+ <Value className="w-9 text-muted-foreground">+ {(typeof o.shadow === "object" ? o.shadow.blur : undefined) ?? 14}+ </Value>+ </Row>+ <Row label="Opacity">+ <Slider+ className="data-horizontal:w-24"+ min={0}+ max={1}+ step={0.01}+ value={(typeof o.shadow === "object" ? o.shadow.opacity : undefined) ?? 0.65}+ onValueChange={(v) => {+ shadowCk.begin();+ useEditor.getState().updateOverlayTransient(o.id, {+ shadow: {+ ...(typeof o.shadow === "object" ? o.shadow : {}),+ opacity: Number(v),+ },+ });+ }}+ onValueCommitted={shadowCk.end}+ />+ <Value className="w-9 text-muted-foreground">+ {Math.round(((typeof o.shadow === "object" ? o.shadow.opacity : undefined) ?? 0.65) * 100)}+ </Value>+ </Row>+ </>+ </Section>+ <Section+ title="Backdrop"+ enabled={o.plate}+ onEnabledChange={(v) => update(o.id, { plate: v })}+ >+ <>+ <Row label="Color"><ColorSwatchesvalue={o.plateColor ?? PLATE_COLOR}onBegin={() => useEditor.getState().pushHistory()}@@ -1239,10 +1505,829 @@ function TextPanel({ overlay: o }: { overlay: TextOverlay }) {/></Row></>+ </Section>+ <Section+ title="Behind speaker"+ info="Sit the text behind the person in the shot. Needs a clearly separated subject; with no person detected it shows as a normal title."+ enabled={!!o.behindSubject}+ onEnabledChange={(v) => update(o.id, { behindSubject: v || undefined })}+ />+ <TransformRows overlay={o} />+ <GroupRow overlay={o} />+ <AnimationRows overlay={o} />+ </div>+ </>+ );+}++/** Named text-style presets from the shared Library: chips that apply a saved+ * look to the selected title, plus saving the current look under a name. */+function StylePresetsRow({ overlay: o }: { overlay: TextOverlay }) {+ const [presets, setPresets] = useState<StylePreset[] | null>(null);+ const [naming, setNaming] = useState(false);+ const [name, setName] = useState("");+ const [busy, setBusy] = useState(false);++ useEffect(() => {+ let live = true;+ listStylePresets()+ .then((p) => live && setPresets(p))+ .catch(() => live && setPresets([]));+ return () => {+ live = false;+ };+ }, []);++ const save = async () => {+ const projectId = useEditor.getState().projectId;+ const trimmed = name.trim();+ if (!projectId || !trimmed || busy) return;+ setBusy(true);+ try {+ const p = await saveStylePreset(projectId, trimmed, o);+ if (p) setPresets((prev) => [p, ...(prev ?? [])]);+ setNaming(false);+ setName("");+ } catch {+ // Signed out or offline shelf — the chips just don't gain one.+ } finally {+ setBusy(false);+ }+ };++ if (presets === null) return null;+ return (+ <div className="mb-1.5">+ <div className="mb-1 flex items-center justify-between">+ <span className="text-[13px] text-muted-foreground">Styles</span>+ {!naming && (+ <button+ type="button"+ className="text-[11.5px] text-muted-foreground transition-colors hover:text-foreground"+ onClick={() => setNaming(true)}+ >+ Save style+ </button>)}- <p className="mt-2.5 text-[11.5px] leading-relaxed text-muted-foreground">- Drag the title in the preview to place it; use the corner handle to resize.- </p>+ </div>+ {naming && (+ <div className="mb-1.5 flex items-center gap-1.5">+ <input+ autoFocus+ className="h-7 min-w-0 flex-1 rounded-md border border-input bg-transparent px-2 text-[12px] outline-none focus:border-ring"+ placeholder="Style name"+ value={name}+ onChange={(e) => setName(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === "Enter") void save();+ if (e.key === "Escape") setNaming(false);+ }}+ />+ <Button size="sm" variant="outline" disabled={busy || !name.trim()} onClick={() => void save()}>+ Save+ </Button>+ </div>+ )}+ {presets.length > 0 && (+ <div className="flex flex-wrap gap-1.5">+ {presets.map((p) => (+ <span key={`${p.residency}:${p.id}`} className="group relative">+ <button+ type="button"+ title={`Apply ${p.name}`}+ className="flex items-center gap-1.5 rounded-md border border-input px-2 py-1 text-[11.5px] transition-colors hover:border-ring"+ onClick={() => useEditor.getState().updateOverlay(o.id, { ...p.style })}+ >+ <span+ className="leading-none"+ style={{+ fontFamily: fontStack(p.style.font),+ fontWeight: p.style.weight,+ fontStyle: p.style.italic ? "italic" : undefined,+ color: p.style.color,+ textShadow: p.style.shadow ? "0 1px 2px rgba(0,0,0,0.5)" : undefined,+ background: p.style.plate ? plateFill(p.style) : undefined,+ borderRadius: p.style.plate ? 3 : undefined,+ padding: p.style.plate ? "0 3px" : undefined,+ }}+ >+ Aa+ </span>+ {p.name}+ </button>+ <button+ type="button"+ title={`Delete ${p.name}`}+ aria-label={`Delete style ${p.name}`}+ className="absolute -top-1.5 -right-1.5 hidden size-4 place-items-center rounded-full bg-black/60 text-[9px] text-white group-hover:grid"+ onClick={() => {+ void deleteStylePreset(p).catch(() => {});+ setPresets((prev) => (prev ?? []).filter((x) => x !== p));+ }}+ >+ ✕+ </button>+ </span>+ ))}+ </div>+ )}+ </div>+ );+}++/** Preset In / Out / Loop animation, shared by every overlay kind. Neutral+ * (all slots off) stores as absence. */+function AnimationRows({ overlay: o }: { overlay: Overlay }) {+ const lengthCk = useSliderCheckpoint();+ const speedCk = useSliderCheckpoint();+ const anim = o.anim ?? {};+ const dur = Math.max(0.2, o.end - o.start);+ const writeAnim = (patch: Partial<OverlayAnim>) => {+ const next = { ...anim, ...patch };+ if (!next.in) delete next.in;+ if (!next.out) delete next.out;+ if (!next.loop) delete next.loop;+ const value = next.in || next.out || next.loop ? next : undefined;+ // A grouped element's animation stamps the whole group.+ const st = useEditor.getState();+ const peers = o.groupId ? st.overlays.filter((x) => x.groupId === o.groupId) : [];+ const ids = peers.length > 1 ? peers.map((p) => p.id) : [o.id];+ st.updateOverlaysTransient(ids.map((id) => ({ id, patch: { anim: value } })));+ };+ /** A discrete change — its own undo step. */+ const setAnim = (patch: Partial<OverlayAnim>) => {+ useEditor.getState().pushHistory();+ writeAnim(patch);+ };+ /** A drag — one undo step for the whole gesture, not one per frame. */+ const dragAnim = (ck: ReturnType<typeof useSliderCheckpoint>, patch: Partial<OverlayAnim>) => {+ ck.begin();+ writeAnim(patch);+ };+ // In / Out / Loop pick from the same grid, one slot at a time — the tiles+ // are big enough to read the motion, which three stacked grids would not be.+ const [slot, setSlot] = useState<"in" | "out" | "loop">("in");+ const active = anim[slot];+ const seconds =+ slot === "loop" ? undefined : (anim[slot] as OverlayAnim["in"])?.seconds;+ const pick = (style: string | null) => {+ if (!style) return setAnim({ [slot]: undefined });+ if (slot === "loop") {+ setAnim({ loop: { style: style as OverlayLoopStyle, speed: anim.loop?.speed ?? 1 } });+ return;+ }+ setAnim({+ [slot]: {+ style: style as OverlayAnimStyle,+ seconds: seconds ?? OVERLAY_ANIM_DEFAULT_SECONDS,+ },+ });+ };++ return (+ <Section title="Animation">+ <div className="mt-0.5 mb-2 flex shrink-0 rounded-lg bg-muted p-0.5 text-[11.5px] font-medium">+ {(["in", "out", "loop"] as const).map((id) => (+ <button+ key={id}+ type="button"+ className={cn(+ "flex-1 rounded-md px-1.5 py-1 capitalize transition-colors",+ slot === id+ ? "bg-neutral-900 text-white"+ : "text-muted-foreground hover:text-foreground",+ // A dot marks a slot that is already set, so switching tabs is+ // not the only way to see what an element is doing.+ anim[id] && slot !== id && "text-foreground"+ )}+ onClick={() => setSlot(id)}+ >+ {id}+ {anim[id] ? " ●" : ""}+ </button>+ ))}+ </div>+ <AnimationTiles+ slot={slot}+ value={active?.style}+ isText={isTextOverlay(o)}+ onPick={pick}+ />+ {slot !== "loop" && active && (+ <Row label="Length">+ <Slider+ className="data-horizontal:w-24"+ min={OVERLAY_ANIM_MIN_SECONDS}+ max={Math.min(OVERLAY_ANIM_MAX_SECONDS, dur)}+ step={0.05}+ value={seconds ?? OVERLAY_ANIM_DEFAULT_SECONDS}+ onValueChange={(v) =>+ dragAnim(lengthCk, {+ [slot]: { style: active.style as OverlayAnimStyle, seconds: Number(v) },+ })+ }+ onValueCommitted={lengthCk.end}+ />+ <Value className="w-9 text-muted-foreground">+ {(seconds ?? OVERLAY_ANIM_DEFAULT_SECONDS).toFixed(2)}s+ </Value>+ </Row>+ )}+ {slot === "loop" && anim.loop && (+ <Row label="Speed">+ <Slider+ className="data-horizontal:w-24"+ min={0.25}+ max={4}+ step={0.25}+ value={anim.loop.speed}+ onValueChange={(v) =>+ dragAnim(speedCk, { loop: { ...anim.loop!, speed: Number(v) } })+ }+ onValueCommitted={speedCk.end}+ />+ <Value className="w-9 text-muted-foreground">{anim.loop.speed.toFixed(2)}×</Value>+ </Row>+ )}+ </Section>+ );+}++/** Group / Ungroup, shown when the selection can form one or the element is+ * in one. Grouping is shallow by design: select-one-selects-all, and gestures+ * apply member-relative deltas. */+function GroupRow({ overlay: o }: { overlay: Overlay }) {+ const selectedOverlays = useEditor(+ (s) => s.multiSelection.filter((x) => x?.kind === "overlay").length+ );+ if (o.groupId) {+ return (+ <Row label="Group">+ <Button+ size="sm"+ variant="outline"+ onClick={() => useEditor.getState().ungroupOverlays(o.groupId!)}+ >+ Ungroup+ </Button>+ </Row>+ );+ }+ if (selectedOverlays < 2) return null;+ return (+ <Row label="Group">+ <Button size="sm" variant="outline" onClick={() => useEditor.getState().groupSelectedOverlays()}>+ Group {selectedOverlays} elements+ </Button>+ </Row>+ );+}++/** Rotation and opacity, shared by every overlay kind. Neutral values store+ * as absence so untouched elements carry nothing. */+function TransformRows({ overlay: o }: { overlay: Overlay }) {+ const rotationCk = useSliderCheckpoint();+ const opacityCk = useSliderCheckpoint();+ const scaleCk = useSliderCheckpoint();+ const posCk = useSliderCheckpoint();+ const now = useEditor((s) => s.currentTime);+ // With keys in play these rows edit the pose at the playhead rather than the+ // element's resting fields — which is what makes them a track.+ const keyed = hasOverlayKeys(o);+ const tLocal = localTimeOf(o, now);+ const pose = poseAt(o, tLocal);+ const setKey = (patch: Partial<Omit<OverlayKey, "t">>) =>+ useEditor.getState().setOverlayKey(o.id, tLocal, patch, { transient: true });+ const setRotation = (v: number) => {+ const deg = Math.round(v);+ if (keyed) return setKey({ rotation: deg });+ useEditor.getState().updateOverlayTransient(o.id, { rotation: deg === 0 ? undefined : deg });+ };+ const setOpacity = (v: number) => {+ const a = Math.max(0, Math.min(1, v));+ if (keyed) return setKey({ opacity: a });+ useEditor.getState().updateOverlayTransient(o.id, { opacity: a >= 0.995 ? undefined : a });+ };+ // Position reads as a percentage of the frame, which is what the document+ // stores — an element sits in the same spot at any aspect, and the number+ // means the same thing on a square as on a widescreen.+ const setPos = (axis: "x" | "y", pct: number) => {+ const v = clampOverlayPos(pct / 100);+ if (keyed) return setKey({ [axis]: v });+ useEditor.getState().updateOverlayTransient(o.id, { [axis]: v });+ };+ return (+ <Section title="Transform">+ <KeyframeControls overlay={o} />+ <Row label="Position">+ {(["x", "y"] as const).map((axis) => (+ <span key={axis} className="flex items-center gap-1">+ <span className="text-[11px] text-muted-foreground/70 uppercase">{axis}</span>+ <ScrubValue+ label={`${axis.toUpperCase()} position`}+ className="w-9 text-muted-foreground"+ value={pose[axis] * 100}+ min={2}+ max={98}+ step={0.5}+ keyStep={1}+ format={(v) => String(Math.round(v))}+ parse={parseNumberInput}+ onScrub={(v) => {+ posCk.begin();+ setPos(axis, v);+ }}+ onCommit={(v) => {+ posCk.begin();+ setPos(axis, v);+ posCk.end();+ }}+ />+ </span>+ ))}+ </Row>+ {keyed && (+ <Row label="Scale">+ <Slider+ className="data-horizontal:w-24"+ min={0.1}+ max={4}+ step={0.01}+ value={pose.scale}+ onValueChange={(v) => {+ scaleCk.begin();+ setKey({ scale: Number(v) });+ }}+ onValueCommitted={scaleCk.end}+ />+ <Value className="w-9 text-muted-foreground">{Math.round(pose.scale * 100)}%</Value>+ </Row>+ )}+ <Row label="Rotation">+ <Slider+ className="data-horizontal:w-24"+ min={-180}+ max={180}+ step={1}+ value={keyed ? pose.rotation : (o.rotation ?? 0)}+ onValueChange={(v) => {+ rotationCk.begin();+ setRotation(Number(v));+ }}+ onValueCommitted={rotationCk.end}+ />+ <ScrubValue+ label="Rotation"+ className="w-9 text-muted-foreground"+ value={keyed ? pose.rotation : (o.rotation ?? 0)}+ min={-180}+ max={180}+ step={1}+ format={(v) => `${Math.round(v)}°`}+ parse={parseNumberInput}+ onScrub={(v) => {+ rotationCk.begin();+ setRotation(v);+ }}+ onCommit={(v) => {+ rotationCk.begin();+ setRotation(v);+ rotationCk.end();+ }}+ />+ </Row>+ <Row label="Opacity">+ <Slider+ className="data-horizontal:w-24"+ min={0}+ max={1}+ step={0.01}+ value={keyed ? pose.opacity : (o.opacity ?? 1)}+ onValueChange={(v) => {+ opacityCk.begin();+ setOpacity(Number(v));+ }}+ onValueCommitted={opacityCk.end}+ />+ <ScrubValue+ label="Opacity"+ className="w-9 text-muted-foreground"+ value={keyed ? pose.opacity : (o.opacity ?? 1)}+ min={0}+ max={1}+ step={0.01}+ format={(v) => String(Math.round(v * 100))}+ parse={parsePercentInput}+ onScrub={(v) => {+ opacityCk.begin();+ setOpacity(v);+ }}+ onCommit={(v) => {+ opacityCk.begin();+ setOpacity(v);+ opacityCk.end();+ }}+ />+ </Row>+ </Section>+ );+}++/** Seconds into the element at the playhead, clamped to its own window. */+function localTimeOf(o: Overlay, now: number): number {+ return Math.max(0, Math.min(now - o.start, Math.max(0.1, o.end - o.start)));+}++/**+ * The keyframe track: the first row of Transform, because a key holds exactly+ * what the rows under it show. The diamond stores that pose where the playhead+ * stands, the arrows walk the keys already set, and the bin drops the one under+ * the playhead. A key has no form of its own — it is edited by moving the+ * element or pulling those same rows.+ */+function KeyframeControls({ overlay: o }: { overlay: Overlay }) {+ const now = useEditor((s) => s.currentTime);+ const seek = useEditor((s) => s.seek);+ const keys = o.kf ?? [];+ const inWindow = now >= o.start - 1e-6 && now <= o.end + 1e-6;+ const tLocal = localTimeOf(o, now);+ const here = keyIndexAt(keys, tLocal);+ const prev = [...keys].reverse().find((k) => k.t < tLocal - KEY_EPSILON);+ const next = keys.find((k) => k.t > tLocal + KEY_EPSILON);+ const st = () => useEditor.getState();+ return (+ <Row label="Keyframes">+ <Button+ size="sm"+ variant="ghost"+ className="size-7 p-0"+ disabled={!inWindow}+ title={here >= 0 ? "Update the key here" : "Add a key at the playhead"}+ aria-label={here >= 0 ? "Update the key here" : "Add a key at the playhead"}+ onClick={() => st().setOverlayKey(o.id, tLocal)}+ >+ <Diamond className={cn("size-3.5", here >= 0 && "fill-current")} />+ </Button>+ <Button+ size="sm"+ variant="ghost"+ className="size-7 p-0"+ disabled={!prev}+ title="Previous key"+ aria-label="Previous key"+ onClick={() => prev && seek(o.start + prev.t)}+ >+ <ChevronLeft className="size-3.5" />+ </Button>+ <Button+ size="sm"+ variant="ghost"+ className="size-7 p-0"+ disabled={!next}+ title="Next key"+ aria-label="Next key"+ onClick={() => next && seek(o.start + next.t)}+ >+ <ChevronRight className="size-3.5" />+ </Button>+ {keys.length > 0 && <Value className="text-muted-foreground">{keys.length}</Value>}+ <Button+ size="sm"+ variant="ghost"+ // Icons centre in a 28px box; the value columns below run to the panel+ // edge. The pull-right lands this glyph on the same edge as their text.+ className="-mr-1.5 size-7 p-0 text-muted-foreground"+ disabled={here < 0}+ title="Remove the key here"+ aria-label="Remove the key here"+ onClick={() => st().removeOverlayKey(o.id, tLocal)}+ >+ <Trash2 className="size-3.5" />+ </Button>+ </Row>+ );+}++function ShapePanel({ overlay: o }: { overlay: ShapeOverlay }) {+ const update = useEditor((s) => s.updateOverlay);+ const fillCk = useSliderCheckpoint();+ const radiusCk = useSliderCheckpoint();+ const strokeCk = useSliderCheckpoint();+ const boxShape = o.shape === "rect" || o.shape === "ellipse";+ return (+ <>+ <PanelTitle>{SHAPE_LABELS[o.shape]}</PanelTitle>+ <div className="flex flex-col gap-1 px-3.5 pb-4">+ <Row label={boxShape ? "Fill" : "Color"}>+ <ColorSwatches+ value={o.fill}+ onBegin={() => useEditor.getState().pushHistory()}+ onLive={(c) => useEditor.getState().updateOverlayTransient(o.id, { fill: c })}+ onCommit={(c) => update(o.id, { fill: c })}+ />+ </Row>+ {boxShape && (+ <Row label="Fill opacity">+ <Slider+ className="data-horizontal:w-24"+ min={0}+ max={1}+ step={0.01}+ value={o.fillOpacity ?? 1}+ onValueChange={(v) => {+ fillCk.begin();+ useEditor.getState().updateOverlayTransient(o.id, {+ fillOpacity: Number(v) >= 0.995 ? undefined : Number(v),+ });+ }}+ onValueCommitted={fillCk.end}+ />+ <Value className="w-9 text-muted-foreground">+ {Math.round((o.fillOpacity ?? 1) * 100)}+ </Value>+ </Row>+ )}+ {o.shape === "rect" && (+ <Row label="Corner radius">+ <Slider+ className="data-horizontal:w-24"+ min={0}+ max={120}+ step={1}+ value={o.radius ?? 0}+ onValueChange={(v) => {+ radiusCk.begin();+ useEditor.getState().updateOverlayTransient(o.id, {+ radius: Number(v) === 0 ? undefined : Number(v),+ });+ }}+ onValueCommitted={radiusCk.end}+ />+ <Value className="w-9 text-muted-foreground">{Math.round(o.radius ?? 0)}</Value>+ </Row>+ )}+ {boxShape && (+ <Section+ title="Outline"+ enabled={!!o.stroke}+ onEnabledChange={(v) =>+ update(o.id, { stroke: v ? { color: "#111114", width: 6 } : undefined })+ }+ >+ {o.stroke && (+ <>+ <Row label="Color">+ <ColorSwatches+ value={o.stroke.color}+ onBegin={() => useEditor.getState().pushHistory()}+ onLive={(c) =>+ useEditor.getState().updateOverlayTransient(o.id, {+ stroke: { ...o.stroke!, color: c },+ })+ }+ onCommit={(c) => update(o.id, { stroke: { ...o.stroke!, color: c } })}+ />+ </Row>+ <Row label="Width">+ <Slider+ className="data-horizontal:w-24"+ min={1}+ max={40}+ step={1}+ value={o.stroke.width}+ onValueChange={(v) => {+ strokeCk.begin();+ useEditor.getState().updateOverlayTransient(o.id, {+ stroke: { ...o.stroke!, width: Number(v) },+ });+ }}+ onValueCommitted={strokeCk.end}+ />+ <Value className="w-9 text-muted-foreground">{o.stroke.width}</Value>+ </Row>+ </>+ )}+ </Section>+ )}+ <TransformRows overlay={o} />+ <GroupRow overlay={o} />+ <AnimationRows overlay={o} />+ </div>+ </>+ );+}++function EffectPanel({ overlay: o }: { overlay: EffectOverlay }) {+ const amountCk = useSliderCheckpoint();+ return (+ <>+ <PanelTitle>{EFFECT_LABELS[o.effect]}</PanelTitle>+ {/* Which effect this is belongs to the Effects tab: it marks this one and+ swaps it on a click, so the panel is only its knobs. */}+ <div className="flex flex-col gap-1 px-3.5 pb-4">+ {o.effect === "zoom" ? (+ <ZoomTarget overlay={o} />+ ) : (+ <Row label="Amount">+ <Slider+ className="data-horizontal:w-24"+ min={0.05}+ max={1}+ step={0.01}+ value={o.amount ?? 0.5}+ onValueChange={(v) => {+ amountCk.begin();+ useEditor.getState().updateOverlayTransient(o.id, { amount: Number(v) });+ }}+ onValueCommitted={amountCk.end}+ />+ <Value className="w-9 text-muted-foreground">+ {Math.round((o.amount ?? 0.5) * 100)}+ </Value>+ </Row>+ )}+ <GroupRow overlay={o} />+ </div>+ </>+ );+}++/** The focus puck's diameter, in px — `size-5` on the element below. */+const PUCK = 20;++/**+ * Where a zoom lands and how close it gets.+ *+ * The stage mirrors the live preview, so the point is chosen against the+ * picture the zoom will sit on: drag the puck onto what matters. Depth is+ * three steps — a zoom is a choice of how close, and a slider of it is a+ * decision nobody wants to make twice.+ */+function ZoomTarget({ overlay: o }: { overlay: EffectOverlay }) {+ const aspect = useEditor((s) => s.aspect);+ const frame = frameOf(aspect);+ const canvasRef = useRef<HTMLCanvasElement>(null);+ const portrait = frame.h > frame.w;+ const focus = { x: o.focus?.x ?? 0.5, y: o.focus?.y ?? 0.5 };+ const amount = o.amount ?? 0.5;+ // How long the push in takes: the far left is a cut straight to the close+ // shot, everything right of it moves the camera in over that many seconds.+ const ramp = zoomRampOf(o.ramp);+ const rampCk = useSliderCheckpoint();++ useEffect(() => {+ let raf = 0;+ const tick = () => {+ raf = requestAnimationFrame(tick);+ const dst = canvasRef.current;+ const src = getPreviewCanvas();+ const ctx = dst?.getContext("2d");+ if (!dst || !src || !ctx) return;+ ctx.clearRect(0, 0, dst.width, dst.height);+ ctx.drawImage(src, 0, 0, dst.width, dst.height);+ };+ raf = requestAnimationFrame(tick);+ return () => cancelAnimationFrame(raf);+ }, []);++ const aim = (e: React.PointerEvent<HTMLDivElement>) => {+ const r = e.currentTarget.getBoundingClientRect();+ useEditor.getState().updateOverlayTransient(o.id, {+ focus: {+ x: Math.max(0, Math.min(1, (e.clientX - r.left) / r.width)),+ y: Math.max(0, Math.min(1, (e.clientY - r.top) / r.height)),+ },+ });+ };++ return (+ <div className="flex flex-col items-center gap-2 pt-1">+ <div+ className="relative cursor-grab overflow-hidden rounded-lg bg-black select-none active:cursor-grabbing"+ style={{+ aspectRatio: `${frame.w} / ${frame.h}`,+ height: portrait ? 168 : undefined,+ width: portrait ? undefined : "100%",+ }}+ onPointerDown={(e) => {+ if (e.button !== 0) return;+ e.currentTarget.setPointerCapture(e.pointerId);+ useEditor.getState().pushHistory();+ aim(e);+ }}+ onPointerMove={(e) => {+ if (e.buttons & 1) aim(e);+ }}+ >+ <canvas+ ref={canvasRef}+ width={Math.round(frame.w / 5)}+ height={Math.round(frame.h / 5)}+ className="pointer-events-none block size-full"+ />+ {/* The puck rides its point, pulled back by its own radius at the+ edges so the whole of it stays on the picture. */}+ <div+ className="pointer-events-none absolute size-5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-[#0a84ff] ring-2 ring-white/90 shadow-[0_1px_4px_rgba(0,0,0,0.45)]"+ style={{+ left: `calc(${focus.x * 100}% + ${((0.5 - focus.x) * PUCK).toFixed(2)}px)`,+ top: `calc(${focus.y * 100}% + ${((0.5 - focus.y) * PUCK).toFixed(2)}px)`,+ }}+ />+ </div>+ <div className="flex w-full flex-col">+ <Row label="Depth" grow>+ {/* The segmented control the rest of the inspector uses — bordered+ box, dark pill on the chosen one — stretched over the row's+ free width. */}+ <div className="flex min-w-0 grow rounded-lg border border-input p-0.5 text-[11.5px] font-medium">+ {ZOOM_LEVELS.map((l) => (+ <button+ key={l.id}+ type="button"+ aria-pressed={Math.abs(amount - l.amount) < 0.01}+ className={cn(+ `zoom-${l.id} flex-1 rounded-md px-1 py-1 whitespace-nowrap transition-colors`,+ Math.abs(amount - l.amount) < 0.01+ ? "bg-neutral-900 text-white"+ : "text-muted-foreground hover:text-foreground"+ )}+ onClick={() => useEditor.getState().updateOverlay(o.id, { amount: l.amount })}+ >+ {l.label}+ </button>+ ))}+ </div>+ </Row>+ <Row label="Speed">+ <Slider+ className="data-horizontal:w-24"+ min={0}+ max={ZOOM_RAMP_MAX}+ step={0.1}+ value={ramp}+ onValueChange={(v) => {+ rampCk.begin();+ useEditor.getState().updateOverlayTransient(o.id, { ramp: Number(v) });+ }}+ onValueCommitted={rampCk.end}+ />+ <ScrubValue+ label="Zoom speed"+ className="w-9 text-muted-foreground"+ value={ramp}+ min={0}+ max={ZOOM_RAMP_MAX}+ step={0.1}+ format={(v) => `${v.toFixed(1)}s`}+ parse={parseSecondsInput}+ onScrub={(v) => {+ rampCk.begin();+ useEditor.getState().updateOverlayTransient(o.id, { ramp: v });+ }}+ onCommit={(v) => {+ useEditor.getState().updateOverlay(o.id, { ramp: v });+ rampCk.end();+ }}+ />+ </Row>+ </div>+ </div>+ );+}++function StickerPanel({ overlay: o }: { overlay: StickerOverlay }) {+ const widthCk = useSliderCheckpoint();+ const asset = useEditor((s) =>+ o.assetId ? s.assets.find((a) => a.id === o.assetId) : undefined+ );+ return (+ <>+ <PanelTitle>Sticker</PanelTitle>+ <div className="flex flex-col gap-1 px-3.5 pb-4">+ {asset ? (+ <div className="mb-1 truncate text-[12px] text-muted-foreground" title={asset.name}>+ {asset.name}+ </div>+ ) : null}+ <Row label="Size">+ <Slider+ className="data-horizontal:w-24"+ min={0.02}+ max={1}+ step={0.01}+ value={o.w}+ onValueChange={(v) => {+ widthCk.begin();+ useEditor.getState().updateOverlayTransient(o.id, { w: Number(v) });+ }}+ onValueCommitted={widthCk.end}+ />+ <Value className="w-9 text-muted-foreground">{Math.round(o.w * 100)}</Value>+ </Row>+ <TransformRows overlay={o} />+ <GroupRow overlay={o} />+ <AnimationRows overlay={o} /></div></>);diff --git a/site/src/cut/components/PanelTile.tsx b/site/src/cut/components/PanelTile.tsxnew file mode 100644index 00000000..dd780c2b--- /dev/null+++ b/site/src/cut/components/PanelTile.tsx@@ -0,0 +1,62 @@+"use client";++import { cn } from "@/lib/utils";++/**+ * A pickable square in a panel grid: a preview above, its name below. Clip+ * effects and overlay animations both choose from grids of these, so the+ * selected ring, hover and sizing are decided once.+ */+export function Tile({+ ref,+ selected,+ onClick,+ onHover,+ label,+ className,+ draggable,+ onDragStart,+ onDragEnd,+ title,+ children,+}: {+ /** For a grid that scrolls a tile into view. */+ ref?: React.Ref<HTMLButtonElement>;+ selected: boolean;+ onClick: () => void;+ /** Pointer entering or leaving — a tile whose preview only plays on hover. */+ onHover?: (inside: boolean) => void;+ label: string;+ className?: string;+ /** A tile that places something by being dragged onto the timeline. */+ draggable?: boolean;+ onDragStart?: React.DragEventHandler<HTMLButtonElement>;+ onDragEnd?: React.DragEventHandler<HTMLButtonElement>;+ title?: string;+ children: React.ReactNode;+}) {+ return (+ <button+ ref={ref}+ type="button"+ aria-pressed={selected}+ title={title}+ draggable={draggable}+ onDragStart={onDragStart}+ onDragEnd={onDragEnd}+ onPointerEnter={() => onHover?.(true)}+ onPointerLeave={() => onHover?.(false)}+ onFocus={() => onHover?.(true)}+ onBlur={() => onHover?.(false)}+ className={cn(+ "flex flex-col items-center gap-1.5 rounded-lg border border-border p-2.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",+ selected && "bg-primary/10 text-foreground ring-2 ring-[#0a84ff] ring-offset-1 ring-offset-card",+ className+ )}+ onClick={onClick}+ >+ {children}+ <span className="leading-none">{label}</span>+ </button>+ );+}diff --git a/site/src/cut/components/SidePanel.tsx b/site/src/cut/components/SidePanel.tsxindex 6253ed90..2c6eadaf 100644--- a/site/src/cut/components/SidePanel.tsx+++ b/site/src/cut/components/SidePanel.tsx@@ -1,8 +1,9 @@"use client";import { Fragment, useEffect, useRef, useState } from "react";-import { Captions, Check, Clapperboard, ClipboardList, Copy, Download, Ellipsis, Film, FolderOpen, FolderPlus, Image as ImageIcon, Loader2, Music, Plus, Trash2, Upload, X } from "lucide-react";+import { Captions, Check, Clapperboard, ClipboardList, Copy, Download, Ellipsis, Film, FolderOpen, FolderPlus, Image as ImageIcon, Loader2, Music, Plus, Shapes, Sparkles, Trash2, Upload, X, Blend } from "lucide-react";import { Button } from "@/components/ui/button";+import { ScrollArea } from "@/components/ui/scroll-area";import { LiveElapsed } from "@/cut/components/Elapsed";import {AlertDialog,@@ -66,6 +67,7 @@ import {type LibraryTemplateItem,} from "@/cut/lib/library";import { activeResidency, availableResidencies, type Residency } from "@/cut/lib/residency";+import { isStylePresetTemplate } from "@/cut/lib/stylePresets";import { retryUpload } from "@/cut/lib/importQueue";import { isMediaFile, revealMedia } from "@/cut/lib/media";import { mediaUrl, TRANSITION_MAX } from "@/cut/lib/types";@@ -85,6 +87,9 @@ import { FolderCrumb, FolderShelf } from "./desktopFolders";import { TemplateCard } from "./TemplateCard";import { GenerateVideoPanel } from "./GeneratePanel";import { ImageGenPanel } from "./ImageGenPanel";+import { EffectsPanel } from "./EffectsPanel";+import { TransitionsPanel } from "./TransitionsPanel";+import { ElementsPanel } from "./ElementsPanel";import { StockImagesPanel } from "./StockImagesPanel";import { SampleLibrary } from "./StockMusicPanel";import { StockVideosPanel } from "./StockVideosPanel";@@ -102,6 +107,9 @@ type Tab = SidePanelTab;const TABS: { id: Tab; label: string; icon: typeof Film }[] = [{ id: "media", label: "Media", icon: Clapperboard },{ id: "library", label: "Library", icon: FolderOpen },+ { id: "elements", label: "Elements", icon: Shapes },+ { id: "effects", label: "Effects", icon: Sparkles },+ { id: "transitions", label: "Transitions", icon: Blend },{ id: "video", label: "Video", icon: Film },{ id: "image", label: "Image", icon: ImageIcon },{ id: "audio", label: "Audio", icon: Music },@@ -229,17 +237,16 @@ export function SidePanel({return (<div className="flex min-h-0 border-r border-border bg-card">{/* Icon rail — its divider drops when collapsed so the panel's outer- border becomes the single line between the rail and the canvas.- It scrolls down its own length when a short window cannot show every- tab, and never sideways: `overflow-y-auto` alone would not say that,- since an axis left visible beside a scrolling one computes to auto,- and a scrollbar that takes its width out of a fixed 68px is enough to- push the widest label past the edge. */}- <div+ border becomes the single line between the rail and the canvas. It+ scrolls down its own length when a short window cannot show every tab;+ the floating scrollbar keeps all 68px for the tiles, so the widest+ label still fits. */}+ <ScrollAreaclassName={cn(- "flex min-h-0 w-[68px] shrink-0 flex-col items-center gap-1 overflow-x-hidden overflow-y-auto py-3",+ "min-h-0 w-[68px] shrink-0",tab !== null && "border-r border-border")}+ contentClassName="flex flex-col items-center gap-1 py-3">{visibleTabs.map(({ id, label, icon: Icon }, tabIndex) => {// The open tab never badges — its completions are already on screen.@@ -247,8 +254,11 @@ export function SidePanel({// Full width of the rail, whatever a scrollbar has left of it, so a// label that no longer fits ellipsises inside the tile rather than// running out past both edges of a centred one.+ // Side padding stays off the label: the rail is 68px and the longest+ // name needs all of it, so the tile pads the tap area vertically and+ // the label runs edge to edge.const tileClass =- "flex w-full min-w-0 shrink-0 flex-col items-center gap-1 rounded-lg px-2 py-1.5 text-muted-foreground transition-colors hover:text-foreground";+ "flex w-full min-w-0 shrink-0 flex-col items-center gap-1 rounded-lg px-1 py-1.5 text-muted-foreground transition-colors hover:text-foreground";const inner = (<><span@@ -263,7 +273,7 @@ export function SidePanel({</span><spanclassName={cn(- "w-full truncate text-center text-[10px] font-medium",+ "w-full truncate text-center text-[10px] font-medium tracking-tight",tab === id && "text-foreground")}>@@ -325,7 +335,7 @@ export function SidePanel({</Fragment>);})}- </div>+ </ScrollArea>{tab === null ? null : (<div className="flex min-h-0">@@ -391,6 +401,9 @@ export function SidePanel({<MediaPanel projectId={projectId} onImport={onImport} importing={importing} />)}{tab === "library" && <LibraryPanel projectId={projectId} />}+ {tab === "elements" && <ElementsPanel projectId={projectId} />}+ {tab === "effects" && <EffectsPanel />}+ {tab === "transitions" && <TransitionsPanel />}{tab === "subtitles" && <SubtitlesPanel />}{tab === "publish" && <PublishPanel />}</div>@@ -531,7 +544,9 @@ function MediaPanel({// Only user-imported media lives here; anything Cut created (recordings, AI// generations, voiceovers, freeze frames, stock adds) is tagged with an// `origin` and stays where it was made.- const assets = useEditor((s) => s.assets).filter((a) => a.origin == null);+ // Fonts are project assets (their bytes live in media/) but they belong to+ // the text inspector's font menu, never the Media grid.+ const assets = useEditor((s) => s.assets).filter((a) => a.origin == null && a.type !== "font");const templates = useEditor((s) => s.templates);const exportOpen = useEditor((s) => s.exportOpen);// A render that finishes in the background (dialog closed) drops a new file in@@ -641,7 +656,7 @@ function MediaPanel({</div>)}- <div className="min-h-0 flex-1 overflow-y-auto pb-3.5">+ <ScrollArea className="min-h-0 flex-1" contentClassName="pb-3.5">{templates.length > 0 && (<div className="flex flex-col gap-1.5 px-3.5 pb-3">{templates.map((t) => (@@ -783,7 +798,7 @@ function MediaPanel({</div></div>)}- </div>+ </ScrollArea>{preview && (<PlatformPreviewDialogprojectId={projectId}@@ -1068,7 +1083,9 @@ function LibraryPanel({ projectId }: { projectId: string }) {.then((d) => {setAssets(d.assets);setFolders(d.folders);- setTemplates(d.templates);+ // Saved text styles ride the template rails but are not templates:+ // they belong to the text inspector, not this shelf.+ setTemplates(d.templates.filter((t) => !isStylePresetTemplate(t)));}).catch(() => setAssets([]));@@ -1309,7 +1326,10 @@ function LibraryPanel({ projectId }: { projectId: string }) {</div>) : null) : (- <div className="grid min-h-0 flex-1 grid-cols-2 content-start gap-2.5 overflow-y-auto px-3.5 pb-3.5">+ <ScrollArea+ className="min-h-0 flex-1"+ contentClassName="grid grid-cols-2 content-start gap-2.5 px-3.5 pb-3.5"+ >{shown.map((a) => (<LibraryCardkey={a.id}@@ -1327,7 +1347,7 @@ function LibraryPanel({ projectId }: { projectId: string }) {</span></div>)}- </div>+ </ScrollArea>)}<AlertDialog open={!!deleting} onOpenChange={(o) => !o && setDeleting(null)}>@@ -1420,7 +1440,7 @@ function PublishPanel() {return (<><PanelHead title="Details" />- <div className="flex min-h-0 flex-col gap-4 overflow-y-auto px-3.5 pb-4">+ <ScrollArea className="min-h-0" contentClassName="flex flex-col gap-4 px-3.5 pb-4">{!readOnly && (<div className="flex flex-col gap-1.5"><SectionTitle>Video</SectionTitle>@@ -1553,7 +1573,7 @@ function PublishPanel() {{count.toLocaleString()} / {CAPTION_LIMIT.toLocaleString()}</p></div>- </div>+ </ScrollArea></>);}diff --git a/site/src/cut/components/StockImagesPanel.tsx b/site/src/cut/components/StockImagesPanel.tsxindex 8741d41b..6f750f0d 100644--- a/site/src/cut/components/StockImagesPanel.tsx+++ b/site/src/cut/components/StockImagesPanel.tsx@@ -10,6 +10,7 @@ import { STOCK_CATEGORIES, type StockCategory, type StockImage } from "@/cut/libimport { STOCK_IMAGES } from "@/cut/lib/stockManifest";import { cn } from "@/lib/utils";import { CopyRefButton, RefHandlePill } from "./AssetRefs";+import { ScrollArea } from "@/components/ui/scroll-area";/** A readable title from a stock id, e.g. "business-boardroom" → "Business Boardroom". */const titleFromId = (id: string) =>@@ -71,7 +72,7 @@ export function StockImagesPanel() {</span></div>- <div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3.5 pb-4">+ <ScrollArea className="min-h-0 flex-1" contentClassName="flex flex-col gap-3 px-3.5 pb-4"><label className="flex shrink-0 items-center gap-2 rounded-lg border border-input px-2.5 py-1.5 focus-within:border-ring"><Search className="size-3.5 shrink-0 text-muted-foreground" /><input@@ -125,7 +126,7 @@ export function StockImagesPanel() {);})())}- </div>+ </ScrollArea></>);}diff --git a/site/src/cut/components/StockMusicPanel.tsx b/site/src/cut/components/StockMusicPanel.tsxindex 49f59330..7d6c6607 100644--- a/site/src/cut/components/StockMusicPanel.tsx+++ b/site/src/cut/components/StockMusicPanel.tsx@@ -13,6 +13,7 @@ import { STOCK_MUSIC } from "@/cut/lib/stockMusicManifest";import { useEditor } from "@/cut/lib/store";import { formatTime } from "@/cut/lib/time";import { cn } from "@/lib/utils";+import { ScrollArea } from "@/components/ui/scroll-area";/** The category header already names the genre, so drop the id's leading* category segment: "cinematic-rising-strings" → "Rising Strings". */@@ -66,7 +67,7 @@ export function SampleLibrary({ projectId }: { projectId: string }) {))}</div></div>- <div className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-3.5 pb-4">+ <ScrollArea className="min-h-0 flex-1" contentClassName="flex flex-col gap-4 px-3.5 pb-4">{sections.map(({ category, items }) => (<div key={category} className="flex flex-col gap-2"><div className="text-[13px] font-semibold tracking-tight">{category}</div>@@ -92,7 +93,7 @@ export function SampleLibrary({ projectId }: { projectId: string }) {</div></div>))}- </div>+ </ScrollArea></>);}diff --git a/site/src/cut/components/StockVideosPanel.tsx b/site/src/cut/components/StockVideosPanel.tsxindex 2c2a94b7..813f2e43 100644--- a/site/src/cut/components/StockVideosPanel.tsx+++ b/site/src/cut/components/StockVideosPanel.tsx@@ -10,6 +10,7 @@ import { STOCK_CATEGORIES, stockTitle, type StockCategory, type StockVideo } froimport { STOCK_VIDEOS } from "@/cut/lib/stockVideoManifest";import { cn } from "@/lib/utils";import { CopyRefButton, RefHandlePill } from "./AssetRefs";+import { ScrollArea } from "@/components/ui/scroll-area";// The Video tab's reference browser: a catalog of AI-generated stock clips.// Every clip carries the prompt that made it — clicking one loads that@@ -94,7 +95,7 @@ export function StockVideosPanel() {);return (- <div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3.5 pt-3 pb-4">+ <ScrollArea className="min-h-0 flex-1" contentClassName="flex flex-col gap-3 px-3.5 pt-3 pb-4">{STOCK_VIDEOS.length === 0 ? (<p className="text-[11px] leading-relaxed text-muted-foreground">No stock videos are bundled yet.@@ -147,7 +148,7 @@ export function StockVideosPanel() {)}</>)}- </div>+ </ScrollArea>);}diff --git a/site/src/cut/components/SubtitlesPanel.tsx b/site/src/cut/components/SubtitlesPanel.tsxindex 19cfe614..8d7746db 100644--- a/site/src/cut/components/SubtitlesPanel.tsx+++ b/site/src/cut/components/SubtitlesPanel.tsx@@ -36,6 +36,7 @@ import {type WordAccentMode,} from "@/cut/lib/types";import { cn } from "@/lib/utils";+import { ScrollArea } from "@/components/ui/scroll-area";const LOCALES = [["en-US", "English (US)"],@@ -210,7 +211,10 @@ function OptionsTab() {const look = karaokeLook(captionStyle(subtitles.style), subtitles);return (- <div className="sub-options flex min-h-0 flex-1 flex-col gap-2.5 overflow-y-auto px-4 py-3">+ <ScrollArea+ className="sub-options min-h-0 flex-1"+ contentClassName="flex flex-col gap-2.5 px-4 py-3"+ ><div className="mb-1 border-b border-border pb-3"><GenerateSubtitlesAudio /></div>@@ -360,7 +364,7 @@ function OptionsTab() {<p className="sub-position-hint -mt-1 text-[11px] leading-relaxed text-muted-foreground">Drag the caption on the video to reposition every subtitle.</p>- </div>+ </ScrollArea>);}@@ -371,7 +375,10 @@ function StylesTab() {const style = subtitles.style ?? "clean";return (- <div className="sub-styles flex min-h-0 flex-1 flex-col gap-2.5 overflow-y-auto px-4 py-3">+ <ScrollArea+ className="sub-styles min-h-0 flex-1"+ contentClassName="flex flex-col gap-2.5 px-4 py-3"+ ><div className="flex flex-col gap-1.5">{Object.values(CAPTION_STYLES).map((cs) => (<button@@ -410,7 +417,7 @@ function StylesTab() {</button>))}</div>- </div>+ </ScrollArea>);}@@ -529,7 +536,10 @@ function Transcript({ cues }: { cues: SubtitleCue[] }) {});return (- <div className="sub-transcript min-h-0 flex-1 select-text overflow-y-auto px-4 py-3">+ <ScrollArea+ className="sub-transcript min-h-0 flex-1"+ contentClassName="select-text px-4 py-3"+ >{paragraphs.map((para) => (<p key={para[0].cue.id} className="mb-4 text-[12.5px] leading-[1.9]">{para.map(({ cue, gap }) => (@@ -537,7 +547,7 @@ function Transcript({ cues }: { cues: SubtitleCue[] }) {))}</p>))}- </div>+ </ScrollArea>);}diff --git a/site/src/cut/components/TemplateCard.tsx b/site/src/cut/components/TemplateCard.tsxindex 97a01250..97614a63 100644--- a/site/src/cut/components/TemplateCard.tsx+++ b/site/src/cut/components/TemplateCard.tsx@@ -32,6 +32,8 @@ import { MEDIA_CORS } from "@/cut/lib/mediaCors";import { useAssetDrop, type AssetRef } from "@/cut/lib/assetRef";import { cardIconButton } from "@/cut/components/iconButton";import { formatTime } from "@/cut/lib/time";+import { EFFECT_LABELS } from "@donkeycut/effects-kit";+import { SHAPE_LABELS } from "@/cut/lib/types";import type { LibraryTemplate, TemplateMedia } from "@/cut/lib/types";import { cn } from "@/lib/utils";@@ -114,7 +116,14 @@ export function TemplateCard({})),...t.texts.map((o) => ({icon: Type,- label: o.text || "Title",+ label:+ o.kind === "shape"+ ? SHAPE_LABELS[o.shape]+ : o.kind === "sticker"+ ? "Sticker"+ : o.kind === "effect"+ ? EFFECT_LABELS[o.effect]+ : o.text || "Title",time: o.end - o.start,})),...(t.cues.lengthdiff --git a/site/src/cut/components/TransitionsPanel.tsx b/site/src/cut/components/TransitionsPanel.tsxnew file mode 100644index 00000000..0871dd7b--- /dev/null+++ b/site/src/cut/components/TransitionsPanel.tsx@@ -0,0 +1,406 @@+"use client";++import { useEffect, useRef, useState } from "react";+import {+ ArrowDown,+ ArrowDownToLine,+ ArrowLeft,+ ArrowLeftToLine,+ ArrowRight,+ ArrowRightToLine,+ ArrowUp,+ ArrowUpToLine,+ Blend,+ Circle,+ Droplets,+ Expand,+ FoldHorizontal,+ Moon,+ Sun,+ Target,+ Trash2,+ UnfoldHorizontal,+ type LucideIcon,+} from "lucide-react";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";+import { Slider } from "@/components/ui/slider";+import { Tile } from "@/cut/components/PanelTile";+import { parseSecondsInput, ScrubValue } from "@/cut/components/ScrubValue";+import { SectionTitle } from "@/cut/components/SectionTitle";+import { clearElementDrag, setElementDragData } from "@/cut/lib/assetDrag";+import { PICKED_RING, useAssetPick } from "@/cut/lib/assetPick";+import { getClipSpans, resolveTransitions, useEditor } from "@/cut/lib/store";+import {+ ANIM_DEFAULT_SECONDS,+ ANIM_STYLE_IDS,+ ANIM_STYLE_LABELS,+ TRANSITION_MAX,+ TRANSITION_STYLE_GROUPS,+ TRANSITION_STYLE_IDS,+ TRANSITION_STYLE_LABELS,+ type AnimStyle,+ type TimelineTransition,+ type TransitionStyle,+ type VideoClip,+} from "@/cut/lib/types";+import { cn } from "@/lib/utils";+import { ScrollArea } from "@/components/ui/scroll-area";++const TILE_ICONS: Record<TransitionStyle, LucideIcon> = {+ crossfade: Blend,+ crosszoom: Expand,+ dipblack: Moon,+ dipwhite: Sun,+ blur: Droplets,+ pushleft: ArrowLeft,+ pushright: ArrowRight,+ pushup: ArrowUp,+ pushdown: ArrowDown,+ wipeleft: ArrowLeftToLine,+ wiperight: ArrowRightToLine,+ wipeup: ArrowUpToLine,+ wipedown: ArrowDownToLine,+ circleopen: Circle,+ circleclose: Target,+ splitopen: UnfoldHorizontal,+ splitclose: FoldHorizontal,+};++/**+ * The Transitions tab: how one clip hands over to the next, and how a clip+ * enters and leaves on its own.+ *+ * Drag a tile onto the timeline and it takes the nearest place with a handover+ * to make: a cut between two clips, or a clip's own head or tail, where it+ * arrives from or leaves to nothing. On the timeline it is a bar of its own+ * above the tracks: drag it along the track to move it, drag its edge to+ * retime it. A click here only picks the tile, the same as every other panel.+ *+ * Select a clip and the top of the tab becomes that clip's controls: the+ * transition it already carries, and its entrance and exit. Select one that+ * already has a transition and the tab follows it — its style is the marked+ * tile, and a click on another tile changes that transition to it. The click+ * never places anything: with nothing transitioned it only picks.+ */+export function TransitionsPanel() {+ // The bar the tab is tuned to: a selected bar directly, or the one playing+ // the selected clip's cut.+ const live = useEditor((s) => {+ if (s.selection?.kind === "transition")+ return s.transitions.find((t) => t.id === s.selection!.id) ?? null;+ if (s.selection?.kind !== "clip") return null;+ const roles = resolveTransitions(s.clips, s.transitions);+ return (+ s.transitions.find((t) => {+ const r = roles.get(t.id);+ return !!r && r.kind === "cut" && r.clipId === s.selection!.id;+ }) ?? null+ );+ });+ return (+ <>+ <div className="flex h-12 shrink-0 items-center pr-2.5 pl-4">+ <span className="text-sm font-semibold tracking-tight">Transitions</span>+ </div>++ <ScrollArea className="min-h-0 flex-1" contentClassName="px-3.5 pb-4">+ <SelectedClip />+ {TRANSITION_STYLE_GROUPS.map((g) => (+ <section key={g.label} className="mb-3 flex flex-col gap-1.5">+ <SectionTitle>{g.label}</SectionTitle>+ <div className="grid grid-cols-2 gap-1.5">+ {g.ids.map((id) => (+ <TransitionTile key={id} style={id} live={live} />+ ))}+ </div>+ </section>+ ))}+ </ScrollArea>+ </>+ );+}++function TransitionTile({+ style,+ live,+}: {+ style: TransitionStyle;+ live: TimelineTransition | null;+}) {+ const { picked, pick } = useAssetPick(`transition:${style}`);+ const ref = useRef<HTMLButtonElement>(null);+ const Icon = TILE_ICONS[style];+ // What the selection means for this tile: it wears the ring when it is the+ // live bar's style, and a click swaps that bar onto it.+ const isLive = !!live && live.style === style;+ const marked = live ? isLive : picked;+ useEffect(() => {+ // Selecting a transition brings its tile into view — the list is long+ // enough that its group is often scrolled away.+ if (isLive) ref.current?.scrollIntoView({ block: "nearest" });+ }, [isLive]);+ return (+ <Tile+ ref={ref}+ selected={marked}+ label={TRANSITION_STYLE_LABELS[style]}+ title={+ live+ ? `Change the selected transition to ${TRANSITION_STYLE_LABELS[style]}`+ : `Drag ${TRANSITION_STYLE_LABELS[style]} onto the transition track`+ }+ // Scroll margin keeps the whole tile — selection ring included — clear+ // of the scroller's edges when scrollIntoView lands it there.+ className={cn("scroll-m-2", marked && PICKED_RING)}+ onClick={() => {+ if (!live) return pick();+ if (!isLive) useEditor.getState().updateTransition(live.id, { style });+ previewBar(live);+ }}+ draggable+ onDragStart={(e) => setElementDragData(e, { kind: "transition", style })}+ onDragEnd={clearElementDrag}+ >+ <Icon className="size-4" />+ </Tile>+ );+}++/** How far ahead of a handover the preview starts, and how long it runs past+ * it, so a change plays itself on the real footage. */+const PREVIEW_LEAD = 0.4;+const PREVIEW_TAIL = 0.35;++/** Play a bar's window on the real footage: a beat ahead of it, a beat past. */+function previewBar(t: { start: number; seconds: number }) {+ const s = useEditor.getState();+ s.previewRange(Math.max(0, t.start - PREVIEW_LEAD), t.start + t.seconds + PREVIEW_TAIL);+}++/** Play the clip's handover into the next one: every change to it shows itself+ * on the real footage. The blend runs across the clip's own tail, ending at+ * the cut, so the window starts ahead of the blend and runs a beat past it. */+function previewTransition(clip: VideoClip) {+ const s = useEditor.getState();+ const spans = getClipSpans(s.clips, s.assets, clip.track);+ const i = spans.findIndex((sp) => sp.clip.id === clip.id);+ const sp = spans[i];+ const next = spans[i + 1];+ if (!sp || !next || sp.transitionOut <= 0) return;+ s.previewRange(next.start - sp.transitionOut - PREVIEW_LEAD, next.start + PREVIEW_TAIL);+}++/**+ * The selected clip's own handovers: the transition it hands over with, and its+ * entrance and exit. The transition block appears once the clip carries one —+ * transitions are placed by dragging a tile onto the track, and this is where+ * the one already there is retuned. In and Out are the same clip's own+ * arrival and departure — what a transition becomes on an open edge.+ */+function SelectedClip() {+ const clip = useEditor((s) =>+ s.selection?.kind === "clip" ? s.clips.find((c) => c.id === s.selection!.id) : undefined+ );+ const hasNext = useEditor((s) =>+ clip ? s.clips.some((c) => c.track === clip.track && c.start > clip.start + 1e-6) : false+ );+ if (!clip) return null;+ const xfade = clip.transition ?? 0;+ return (+ <section className="mb-4 flex flex-col gap-1 border-b border-border pb-2">+ <SectionTitle className="mb-0.5">Selected clip</SectionTitle>+ {hasNext && xfade > 0 && <ClipTransition clip={clip} />}+ <ClipAnim clip={clip} which="in" />+ <ClipAnim clip={clip} which="out" />+ </section>+ );+}++function ClipTransition({ clip }: { clip: VideoClip }) {+ const style = clip.transitionStyle ?? "crossfade";+ // Retiming a transition slides the clips behind it, so the drag runs on a+ // draft and lands once — the layout moves on release.+ const [draft, setDraft] = useState<number | null>(null);+ const len = draft ?? clip.transition ?? 0;+ const preview = () => previewTransition(clip);+ return (+ <>+ <Row label="Transition">+ <Select+ value={style}+ items={TRANSITION_STYLE_LABELS}+ onValueChange={(v) => {+ useEditor.getState().setClipTransition(clip.id, len, v as TransitionStyle);+ preview();+ }}+ >+ <SelectTrigger size="sm" className="clip-xstyle w-28">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {TRANSITION_STYLE_IDS.map((id) => (+ <SelectItem key={id} value={id}>+ {TRANSITION_STYLE_LABELS[id]}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <button+ type="button"+ aria-label="Remove transition"+ title="Remove transition"+ className="clip-xremove grid size-7 place-items-center rounded-md text-muted-foreground transition-colors hover:text-foreground"+ onClick={() => useEditor.getState().setClipTransition(clip.id, 0)}+ >+ <Trash2 className="size-3.5" />+ </button>+ </Row>+ <Row label="Length">+ <LengthSlider+ className="clip-xfade"+ value={len}+ min={0.1}+ onChange={setDraft}+ onCommit={(v) => {+ useEditor.getState().setClipTransition(clip.id, v, style);+ setDraft(null);+ preview();+ }}+ />+ </Row>+ </>+ );+}++function ClipAnim({ clip, which }: { clip: VideoClip; which: "in" | "out" }) {+ const anim = which === "in" ? clip.animIn : clip.animOut;+ // The length drag runs on a draft and lands once on release — the bar+ // behind this edge moves on commit.+ const [draft, setDraft] = useState<number | null>(null);+ // Upper tracks composite through alpha, so only the animations expressible as+ // alpha and zoom ramps are offered there.+ const styles = clip.track > 0 ? (["fade", "zoom"] as AnimStyle[]) : ANIM_STYLE_IDS;+ const labels: Record<string, string> = { none: "None", ...ANIM_STYLE_LABELS };+ const preview = () => {+ const s = useEditor.getState();+ const sp = getClipSpans(s.clips, s.assets, clip.track).find((x) => x.clip.id === clip.id);+ const fresh = s.clips.find((c) => c.id === clip.id);+ const a = which === "in" ? fresh?.animIn : fresh?.animOut;+ if (!sp || !a) return;+ if (which === "in") s.previewRange(sp.start - 0.25, sp.start + a.seconds + PREVIEW_TAIL);+ else s.previewRange(sp.start + sp.len - a.seconds - PREVIEW_LEAD, sp.start + sp.len + 0.25);+ };+ const commitSeconds = (seconds: number) => {+ if (!anim) return;+ useEditor.getState().setClipAnim(clip.id, which, { style: anim.style, seconds });+ setDraft(null);+ };+ return (+ <>+ <Row label={which === "in" ? "In" : "Out"}>+ <Select+ value={anim?.style ?? "none"}+ items={labels}+ onValueChange={(v) => {+ useEditor+ .getState()+ .setClipAnim(+ clip.id,+ which,+ v === "none"+ ? null+ : {+ style: v as AnimStyle,+ seconds: anim?.seconds ?? ANIM_DEFAULT_SECONDS,+ }+ );+ if (v !== "none") preview();+ }}+ >+ <SelectTrigger size="sm" className={`clip-anim-${which} w-28`}>+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value="none">None</SelectItem>+ {styles.map((id) => (+ <SelectItem key={id} value={id}>+ {ANIM_STYLE_LABELS[id]}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </Row>+ {anim && (+ <Row label="Length">+ <LengthSlider+ className={`clip-anim-${which}-secs`}+ value={draft ?? anim.seconds}+ min={0.1}+ onChange={setDraft}+ onCommit={(v) => {+ commitSeconds(v);+ preview();+ }}+ />+ </Row>+ )}+ </>+ );+}++/** Seconds of a handover: slider plus a scrubbable readout, one undo+ * checkpoint per drag. */+function LengthSlider({+ className,+ value,+ min,+ onChange,+ onCommit,+}: {+ className?: string;+ value: number;+ min: number;+ onChange: (v: number) => void;+ onCommit: (v: number) => void;+}) {+ return (+ <>+ <Slider+ className={cn(className, "data-horizontal:w-24")}+ min={min}+ max={TRANSITION_MAX}+ step={0.1}+ value={value}+ onValueChange={(v) => onChange(Number(v))}+ onValueCommitted={(v) => onCommit(Number(v))}+ />+ <ScrubValue+ label="Length"+ className="w-9 text-muted-foreground"+ value={value}+ min={min}+ max={TRANSITION_MAX}+ step={0.1}+ format={(v) => `${v.toFixed(1)}s`}+ parse={parseSecondsInput}+ onScrub={onChange}+ onCommit={onCommit}+ />+ </>+ );+}++function Row({ label, children }: { label: string; children: React.ReactNode }) {+ return (+ <div className="flex min-h-9 items-center justify-between gap-2.5">+ <span className="shrink-0 text-[13px] text-muted-foreground">{label}</span>+ <div className="flex min-w-0 items-center gap-1.5">{children}</div>+ </div>+ );+}diff --git a/site/src/cut/lib/assetDrag.ts b/site/src/cut/lib/assetDrag.tsindex 513a1191..c6ea76ea 100644--- a/site/src/cut/lib/assetDrag.ts+++ b/site/src/cut/lib/assetDrag.ts@@ -4,7 +4,8 @@ import type React from "react";import { clearRefDrag, refFromAsset, refFromLibrary, setRefDragData } from "./assetRef";import type { LibraryAsset, LibraryTemplateItem } from "./library";import { useEditor } from "./store";-import type { LibraryTemplate } from "./types";+import type { LibraryTemplate, ShapeKind, TransitionStyle } from "./types";+import type { EffectId } from "@donkeycut/effects-kit";/** Internal HTML5 drag payload for project media assets. The custom MIME* keeps these drags invisible to the window-level OS-file import overlay,@@ -89,6 +90,45 @@ export function hasTemplateDrag(e: React.DragEvent | DragEvent): boolean {return !!dt && Array.from(dt.types).includes(TEMPLATE_MIME);}+/**+ * A new element dragged out of a panel — a shape or an effect. It exists+ * nowhere yet, so the drag carries what to build rather than an id, and the+ * timeline makes it where it lands.+ */+export const ELEMENT_MIME = "application/x-cut-element";++export type ElementDrag =+ | { kind: "shape"; shape: ShapeKind }+ | { kind: "effect"; effect: EffectId }+ /** A transition joins two clips, so this one lands on a cut rather than at+ * the pointer's exact time. */+ | { kind: "transition"; style: TransitionStyle };++let inFlightElement: ElementDrag | null = null;++export function setElementDragData(e: React.DragEvent, spec: ElementDrag) {+ e.dataTransfer.setData(+ ELEMENT_MIME,+ spec.kind === "shape" ? spec.shape : spec.kind === "effect" ? spec.effect : spec.style+ );+ e.dataTransfer.effectAllowed = "copy";+ inFlightElement = spec;+}++/** The element being dragged, readable during `dragover` and on drop. */+export function draggingElement(): ElementDrag | null {+ return inFlightElement;+}++export function hasElementDrag(e: React.DragEvent | DragEvent): boolean {+ const dt = "dataTransfer" in e ? e.dataTransfer : null;+ return !!dt && Array.from(dt.types).includes(ELEMENT_MIME);+}++export function clearElementDrag() {+ inFlightElement = null;+}+/** Use the card itself as the drag ghost: a clone at rendered size, so the* ghost matches the card exactly — rounded corners, fills, labels. Live* `<video>`/`<canvas>` content is baked into the clone (clones of those paintdiff --git a/site/src/cut/lib/assetPick.ts b/site/src/cut/lib/assetPick.tsnew file mode 100644index 00000000..f9a6ba83--- /dev/null+++ b/site/src/cut/lib/assetPick.ts@@ -0,0 +1,37 @@+"use client";++/**+ * The generated asset a user has picked, shared by every generation tab.+ *+ * Picking is what a click on a tile means — in the Elements, Image and Video+ * tabs alike. It is deliberately not "use this now": a click used to add a+ * sticker straight to the timeline, which made browsing what you had made an+ * edit. Adding, expanding, copying and deleting are the tile's own buttons;+ * the click just says which one you mean.+ *+ * One picked id across all the tabs, so picking in one clears the last.+ */++import { create } from "zustand";++interface PickedAsset {+ id: string | null;+ /** Pick `id`, or unpick it when it is already the picked one. */+ pick: (id: string) => void;+ clear: () => void;+}++export const usePickedAsset = create<PickedAsset>((set) => ({+ id: null,+ pick: (id) => set((s) => ({ id: s.id === id ? null : id })),+ clear: () => set({ id: null }),+}));++/** Whether this tile is the picked one, and the click that toggles it. */+export function useAssetPick(assetId: string): { picked: boolean; pick: () => void } {+ const picked = usePickedAsset((s) => s.id) === assetId;+ return { picked, pick: () => usePickedAsset.getState().pick(assetId) };+}++/** The ring a picked tile wears. One class string so the tabs cannot drift. */+export const PICKED_RING = "ring-2 ring-[#0a84ff] ring-offset-1 ring-offset-card";diff --git a/site/src/cut/lib/assetRef.ts b/site/src/cut/lib/assetRef.tsindex 3e4d38c1..214930d8 100644--- a/site/src/cut/lib/assetRef.ts+++ b/site/src/cut/lib/assetRef.ts@@ -66,7 +66,9 @@ export const refFromAsset = (a: MediaAsset): AssetRef => ({scope: "project",id: a.id,name: a.name,- kind: a.type,+ // Fonts have no card and no drag source, and `projectRefs` keeps them out+ // of the @-mention candidates; the arm only keeps the mapping total.+ kind: a.type === "font" ? "text" : a.type,url: a.url,duration: a.duration,});@@ -376,11 +378,13 @@ let libraryLoad: Promise<LibraryAsset[]> | null = null;* anything that shows one resolves it from the current asset list.* Chat-owned assets (origin "chat") are a run's internals — character sheets,* keyframes, takes — visible nowhere the user works, so they don't become- * candidates; a take placed on the timeline is reachable as its clip (@c2). */+ * candidates; a take placed on the timeline is reachable as its clip (@c2).+ * Uploaded fonts are project assets too, but there is nothing to say about a+ * typeface file in a prompt, so they stay out of the handle numbering. */export function projectRefs(assets: MediaAsset[]): AssetRef[] {const counters = { v: 0, i: 0, a: 0 };return assets- .filter((a) => a.origin !== "chat")+ .filter((a) => a.origin !== "chat" && a.type !== "font").map((a) => {const prefix = a.type === "image" ? "i" : a.type === "video" ? "v" : "a";counters[prefix] += 1;diff --git a/site/src/cut/lib/panelRequest.ts b/site/src/cut/lib/panelRequest.tsindex 92d4dd56..ce3f8206 100644--- a/site/src/cut/lib/panelRequest.ts+++ b/site/src/cut/lib/panelRequest.ts@@ -12,6 +12,9 @@ import type { SidePanelTab } from "./types";export const SIDE_PANEL_TABS: SidePanelTab[] = ["media","library",+ "elements",+ "effects",+ "transitions","video","image","audio",diff --git a/site/src/cut/lib/refMedia.ts b/site/src/cut/lib/refMedia.tsindex c09e26a5..28404c9d 100644--- a/site/src/cut/lib/refMedia.ts+++ b/site/src/cut/lib/refMedia.ts@@ -246,6 +246,35 @@ export async function refToInlineImage(ref: AssetRef): Promise<InlineImage> {return captureFrame(ref.url, sourceDuration(ref), ref.t !== undefined ? { at: ref.t } : undefined);}+/**+ * Put the picture a ref points at on the system clipboard, as a PNG so it+ * pastes into anything that takes an image.+ *+ * The blob goes in as a promise rather than an awaited value: Safari ties a+ * clipboard write to the gesture that asked for it, and decoding a frame first+ * spends that gesture. Throws when the frame cannot be read or the browser+ * refuses the write, which is the caller's cue to say so.+ */+export async function copyRefImage(ref: AssetRef): Promise<void> {+ const png = (async () => {+ const inline = await refToInlineImage(ref);+ const bytes = Uint8Array.from(atob(inline.data), (c) => c.charCodeAt(0));+ const blob = new Blob([bytes], { type: inline.mimeType });+ if (inline.mimeType === "image/png") return blob;+ // Clipboard image writes are PNG everywhere; a JPEG frame re-encodes.+ const bitmap = await createImageBitmap(blob);+ const canvas = document.createElement("canvas");+ canvas.width = bitmap.width;+ canvas.height = bitmap.height;+ canvas.getContext("2d")!.drawImage(bitmap, 0, 0);+ bitmap.close();+ return new Promise<Blob>((resolve, reject) =>+ canvas.toBlob((b) => (b ? resolve(b) : reject(new Error("Could not encode the frame."))), "image/png")+ );+ })();+ await navigator.clipboard.write([new ClipboardItem({ "image/png": png })]);+}+/** Reference images for a whole ref list, in order; skips nothing — a broken* ref fails the call so the user knows the reference didn't ride along. */export function refsToInlineImages(refs: AssetRef[]): Promise<InlineImage[]> {