feat: implement reveal in media feature

This commit is contained in:
Maze Winther
2025-08-18 10:54:28 +02:00
parent 13dff382c4
commit 756a7c7caa
5 changed files with 145 additions and 57 deletions
@@ -4,6 +4,7 @@ import {
Scissors,
Trash2,
Copy,
Search,
RefreshCw,
EyeOff,
Eye,
@@ -29,6 +30,7 @@ import {
ContextMenuSeparator,
ContextMenuTrigger,
} from "../../ui/context-menu";
import { useMediaPanelStore } from "../media-panel/store";
export function TimelineElement({
element,
@@ -69,6 +71,8 @@ export function TimelineElement({
onUpdateDuration: updateElementDuration,
});
const { requestRevealMedia } = useMediaPanelStore.getState();
const effectiveDuration =
element.duration - element.trimStart - element.trimEnd;
const elementWidth = Math.max(
@@ -166,6 +170,16 @@ export function TimelineElement({
input.click();
};
const handleRevealInMedia = (e: React.MouseEvent) => {
e.stopPropagation();
if (element.type !== "media") {
toast.error("Reveal is only available for media clips");
return;
}
requestRevealMedia(element.mediaId);
};
const renderElementContent = () => {
if (element.type === "text") {
return (
@@ -348,10 +362,16 @@ export function TimelineElement({
Duplicate {element.type === "text" ? "text" : "clip"}
</ContextMenuItem>
{element.type === "media" && (
<ContextMenuItem onClick={handleReplaceClip}>
<RefreshCw className="h-4 w-4 mr-2" />
Replace clip
</ContextMenuItem>
<>
<ContextMenuItem onClick={handleRevealInMedia}>
<Search className="h-4 w-4 mr-2" />
Reveal in media
</ContextMenuItem>
<ContextMenuItem onClick={handleReplaceClip}>
<RefreshCw className="h-4 w-4 mr-2" />
Replace clip
</ContextMenuItem>
</>
)}
<ContextMenuSeparator />
<ContextMenuItem