Skip to content

The shadcn editor ​

A video editor for an UberScene file, built from shadcn/ui components. Like any shadcn component, it is not a package your app depends on: npx shadcn add copies its source into your app, and from then on the files are yours to change.

The editor: layers, the preview, the inspector and a timeline of titles

Try the editor → Drag a bar on the timeline, then open the Source tab: the file has changed by the one value you dragged.

Work in progress

The editor installs from the registry today, but the packages it imports (@uberscene/editor, @uberscene/sdk) reach npm with the next release. Until then it runs inside the UberScene repository.

What you get ​

sh
npx shadcn add https://uberscene.prefixtree.xyz/r/editor.json

This writes components/editor/ into your app, adds the shadcn components it is built from (button, slider, resizable, tabs, select and a few more), and installs @uberscene/editor, @uberscene/player and @uberscene/sdk.

FilePartWhat it does
editor.tsxeditorThe whole editor: layers, the picture and its transport, the inspector, then the timeline and the file in tabs. Keyboard shortcuts.
timeline.tsx, key-lanes.tsx, bar-media.tsx, use-thumbnails.tseditor-timelineA row per track and a bar per element. Click to select, drag to move, drag an end to trim. Video and image bars show a filmstrip of what they play, and bars with sound their waveform (see Footage on the bars). Under the selected element, a lane per keyed value with a diamond per key, and a marked lane for a value a generator moves (see Keys). Each drag is one undoable edit.
layers.tsxeditor-layersEvery element, grouped by track. A click selects it.
transport.tsxeditor-transportPlay and pause, a scrubber, the time, the speed and mute.
inspector.tsx, key-inspector.tsx, typography.tsx, fields.tsxeditor-inspectorThe key picked on the timeline (its value and easing), or a generator's params. The selected element's timing, text and every prop its schema lists, as fields. Titles and captions get a typography panel laid out as a design tool's: preset, font, weight, size, line height, letter spacing, alignment, italic and decoration, colour, background, stroke and shadow, each showing the value the text has now. A prop written as code in the file shows locked.
handles.tsx, handles-math.ts, use-auto-key.tseditor-handlesA frame over the selected overlay on the picture, where it is drawn: drag inside to move it, a corner to scale it, the grip above it to turn it (see Move, scale and rotate on the picture). The Auto-key toggle above the picture.
source.tsxeditor-sourceThe file with every edit written in, the changed lines marked, to copy or download.
The typography panel: preset h1, Space Grotesk, Bold 700 at 96, line height 1.05, letter spacing 6, centred, italic, colour #ffcf5a

Each part is its own item, so you can take one: npx shadcn add https://uberscene.prefixtree.xyz/r/editor-timeline.json gives you the timeline alone.

Footage on the bars ​

A video bar shows a strip of its frames at the zoom you are at: the stretch of the file it plays, from its in at its speed, run backwards when it is reversed, so a trim or a slip changes the strip as you drag. An image bar shows its picture. A sound, and a clip with sound, shows its waveform under its label, read from the waveform that uberscene add measured, or decoded once in the browser when the manifest has none. Each row draws on one canvas behind its bars, for the part in view only, and keeps the pictures it decoded (createThumbnailer in @uberscene/player), so scrolling back decodes nothing.

Keys ​

Select an element and its keys show under its bar, one lane per value that has them (transform.opacity, box.x, effects.0.radius).

  • Pick a diamond to see its value and the easing into it in the inspector, and change either.
  • Drag a diamond to move the key. It lands on a frame.
  • + on a lane adds a key at the playhead, holding the value the picture shows there, so nothing moves until you change it.
  • Key a value, under the lanes, starts a lane on a value that has no keys yet, from what the file writes.
  • Delete removes the picked key, not the element.

A value a generator moves (a wiggle, a drift, a loop) shows as a dashed lane. Pick it to edit the generator's params, or to remove it, which leaves the value it was added to. Each of these is one undoable edit, written into the file.

Move, scale and rotate on the picture ​

Select a title, a shape, an SVG, a sticker or a layer while the playhead is inside it, and a frame shows over it on the picture around what it draws (a title's words, not the box they sit in), turned and scaled as it is drawn, under the camera and whatever it follows.

  • Drag inside the frame to move it. Its box.x and box.y change in its own numbers, so under a zoomed or turned camera it still follows the pointer. A box that was centred gets the place it was drawn at, its origin kept.
  • Drag a corner to scale it about its anchor (transform.scale). Hold Shift to scale one axis only.
  • Drag the grip above it to turn it about its anchor (transform.rotation). Hold Shift to turn by 15° steps.

The frame shows the result while you drag, and letting go makes one edit, which one undo takes back. With Auto-key on (the toggle above the picture, or K), a drag writes a key at the playhead, on its frame, instead of a new value; a value that already has keys always gets a key there, whatever the toggle says. A value written as code, bound to a name the file declares, or moved by a generator keeps its grip hidden. A click inside the frame that does not drag selects what is under it, as a click on the picture does.

Put it in a page ​

tsx
import { buildSourceIndex, collectModule, Executor } from "@uberscene/sdk";
import "@uberscene/player/fonts.css";

import { VideoEditor } from "@/components/editor/editor";
import * as file from "./video";
import source from "./video.tsx?raw";

// The source index tells the editor which props are written as code, so it shows them locked.
const executor = new Executor({
  tree: collectModule(file, {}, { index: buildSourceIndex(source) }),
  manifest: { assets: {} },
});

export function App() {
  return <VideoEditor executor={executor} source={source} element={file.default()} />;
}

media takes the footage by asset id (a Blob or a URL), as the player does. The demo's file is all titles, so it needs none.

KeyDoes
SpacePlay and pause.
Cmd/Ctrl+Z, Shift+Cmd/Ctrl+ZUndo, redo.
DeleteRemove the selection.
Left, RightMove the selection by a frame; with Shift, by a second.
KTurn auto-key on or off: a drag on the picture writes keys at the playhead.

Make it yours ​

The files are plain React and Tailwind, so change them as you would any component in your app: restyle the bars, put the inspector in a sheet, add a column of thumbnails. What they do comes from two places that stay in npm, so a fix there reaches you without copying anything again:

  • @uberscene/editor: <Editor.Root> holds one player, one selection and the edit history for every part inside it. useSelection(), useEdit() and useEditor() read them from any depth.
  • @uberscene/sdk: the actions every edit runs, the resolver that places each element in time, and the fold that writes the edits back into the file's text. Editing explains all three.

Keep that split when you change a part: put a new gesture's logic in an action, and keep the component to what is drawn. To build an editor without shadcn, use <Editor.Root>, its unstyled Preview, Layers and Timeline, and the hooks; the package README lists them.

The demo is the test bed ​

The editor's source lives in packages/editor/registry, and the demo in packages/editor/app imports it from there, so what you install is what runs at /editor/ and what is tested. Each end-to-end test makes an edit with the pointer or the keyboard, reads the file it leaves, and runs the same actions through the SDK with no editor around it, to check both write the same file. The tests found two bugs in the SDK before this page was written.

Next ​

  • Editing: the actions, the patch log and the fold the editor is built on.
  • Player: the player the editor's preview is.

MIT licensed.