mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-10 22:20:14 +00:00
feat(studio): add media treatment inspector
This commit is contained in:
@@ -9,6 +9,7 @@ import { addBlockToProject } from "../utils/blockInstaller";
|
||||
import type { BlockParam } from "@hyperframes/core/registry";
|
||||
import type { EditHistoryKind } from "../utils/editHistory";
|
||||
import type { RightPanelTab } from "../utils/studioHelpers";
|
||||
import type { MediaOverlayPlacement } from "../components/editor/propertyPanelTypes";
|
||||
|
||||
interface BlockCtxDeps {
|
||||
activeCompPath: string | null;
|
||||
@@ -46,6 +47,7 @@ export interface UseBlockHandlersResult {
|
||||
>;
|
||||
handleAddBlock: (blockName: string) => void;
|
||||
handleTimelineBlockDrop: (blockName: string, placement: { start: number; track: number }) => void;
|
||||
handleAddMediaOverlay: (blockName: string, placement: MediaOverlayPlacement) => Promise<void>;
|
||||
handlePreviewBlockDrop: (blockName: string, position: { left: number; top: number }) => void;
|
||||
}
|
||||
|
||||
@@ -151,6 +153,25 @@ export function useBlockHandlers({
|
||||
[projectId, blockCtx, previewIframeRef, runBlockInstall],
|
||||
);
|
||||
|
||||
const handleAddMediaOverlay = useCallback(
|
||||
async (blockName: string, placement: MediaOverlayPlacement) => {
|
||||
if (!projectId) return;
|
||||
const { compositionPath, ...timelinePlacement } = placement;
|
||||
await runBlockInstall(blockName, () =>
|
||||
addBlockToProject({
|
||||
projectId,
|
||||
blockName,
|
||||
...blockCtx,
|
||||
activeCompPath: compositionPath ?? blockCtx.activeCompPath,
|
||||
placement: timelinePlacement,
|
||||
previewIframe: previewIframeRef.current,
|
||||
currentTime: usePlayerStore.getState().currentTime,
|
||||
}),
|
||||
);
|
||||
},
|
||||
[projectId, blockCtx, previewIframeRef, runBlockInstall],
|
||||
);
|
||||
|
||||
const handlePreviewBlockDrop = useCallback(
|
||||
(blockName: string, position: { left: number; top: number }) => {
|
||||
if (!projectId) return;
|
||||
@@ -173,6 +194,7 @@ export function useBlockHandlers({
|
||||
setActiveBlockParams,
|
||||
handleAddBlock,
|
||||
handleTimelineBlockDrop,
|
||||
handleAddMediaOverlay,
|
||||
handlePreviewBlockDrop,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user