Skip to content

Open source CapCut alternative.

TypeScript

fix(site): lay a block down at its own length so it fills the gap it was made for

David Le61cc3a8b5f2e
diff --git a/site/src/cut/lib/store.test.ts b/site/src/cut/lib/store.test.ts
index d5852dcb..be196e0a 100644
--- a/site/src/cut/lib/store.test.ts
+++ b/site/src/cut/lib/store.test.ts
@@ -431,6 +431,17 @@ describe("video placement", () => {
expect(clipById(resident.id).track).toBe(2); // renumbered above the insert
});
+ test("a block fills a gap its own length at the time asked", () => {
+ const block: MediaAsset = { ...asset(0.5, "image"), fileName: "", block: { label: "s22" } };
+ const before = vclip({ track: 0, start: 0, out: 12.7 });
+ const after = vclip({ track: 0, start: 13.2, out: 2 });
+ useEditor.setState({ assets: [block], clips: [before, after] });
+ const id = s().addClipFromAsset(block.id, 12.7)!;
+ expect(clipById(id).start).toBeCloseTo(12.7);
+ expect(clipLen(clipById(id))).toBeCloseTo(0.5);
+ expectLaneSound(videoLane(0));
+ });
+
});
describe("committed video updates (AI chat / inspector)", () => {
diff --git a/site/src/cut/lib/store.ts b/site/src/cut/lib/store.ts
index 23536c76..af4922fa 100644
--- a/site/src/cut/lib/store.ts
+++ b/site/src/cut/lib/store.ts
@@ -3155,7 +3155,8 @@ export const useEditor = create<EditorState>((baseSet, get, api) => {
const asset = get().assets.find((a) => a.id === assetId);
if (!asset || (asset.type !== "video" && asset.type !== "image")) return null;
push();
- const out = asset.type === "image" ? IMAGE_CLIP_SECONDS : asset.duration;
+ // A block runs its shot's own length, so it fits the gap it was made for.
+ const out = asset.type === "image" && !asset.block ? IMAGE_CLIP_SECONDS : asset.duration;
const len = Math.max(MIN_LEN, out);
const row = track0Clips(get().clips);
// An explicit target time always wins (a drop at the pointer, AI placing