diff --git a/apps/web/package.json b/apps/web/package.json index bc12e24..27c0771 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -68,4 +68,4 @@ "tsx": "^4.7.1", "typescript": "^5" } -} +} \ No newline at end of file diff --git a/apps/web/src/components/editor/media-panel.tsx b/apps/web/src/components/editor/media-panel.tsx index dfe0836..7ca22cc 100644 --- a/apps/web/src/components/editor/media-panel.tsx +++ b/apps/web/src/components/editor/media-panel.tsx @@ -1,14 +1,15 @@ "use client"; -import { Button } from "../ui/button"; -import { AspectRatio } from "../ui/aspect-ratio"; -import { DragOverlay } from "../ui/drag-overlay"; -import { useMediaStore, type MediaItem } from "@/stores/media-store"; -import { processMediaFiles } from "@/lib/media-processing"; -import { Plus, Image, Video, Music, Trash2, Upload } from "lucide-react"; import { useDragDrop } from "@/hooks/use-drag-drop"; +import { processMediaFiles } from "@/lib/media-processing"; +import { useMediaStore, type MediaItem } from "@/stores/media-store"; +import { useTimelineStore } from "@/stores/timeline-store"; +import { Image, Music, Plus, Trash2, Upload, Video } from "lucide-react"; import { useEffect, useRef, useState } from "react"; import { toast } from "sonner"; +import { AspectRatio } from "../ui/aspect-ratio"; +import { Button } from "../ui/button"; +import { DragOverlay } from "../ui/drag-overlay"; // MediaPanel lets users add, view, and drag media (images, videos, audio) into the project. // You can upload files or drag them from your computer. Dragging from here to the timeline adds them to your video project. @@ -58,6 +59,15 @@ export function MediaPanel() { const handleRemove = (e: React.MouseEvent, id: string) => { // Remove a media item from the store e.stopPropagation(); + + + // Remove tracks automatically when delete media + const { tracks, removeTrack } = useTimelineStore.getState(); + tracks.forEach((track) => { + if (track.clips.some((clip) => clip.mediaId === id)) { + removeTrack(track.id); + } + }); removeMediaItem(id); }; diff --git a/apps/web/src/components/editor/timeline.tsx b/apps/web/src/components/editor/timeline.tsx index 15e5fc1..683687d 100644 --- a/apps/web/src/components/editor/timeline.tsx +++ b/apps/web/src/components/editor/timeline.tsx @@ -781,15 +781,15 @@ export function Timeline() {
{(() => { @@ -852,10 +852,10 @@ export function Timeline() {
@@ -1681,10 +1681,10 @@ function TimelineTrackContent({ return (
{ e.preventDefault(); @@ -1710,10 +1710,10 @@ function TimelineTrackContent({ {track.clips.length === 0 ? (
{isDropping