added save as

This commit is contained in:
2026-04-15 20:51:24 -06:00
parent af8e0cf6eb
commit f121d71f5f
6 changed files with 319 additions and 88 deletions

View File

@ -15,6 +15,7 @@ import type {
} from '../types/project';
interface EditorState {
projectFilePath: string | null;
videoPath: string | null;
videoUrl: string | null;
exportedAudioPath: string | null; // path to modified audio from a previous export
@ -48,6 +49,7 @@ interface EditorState {
interface EditorActions {
setBackendUrl: (url: string) => void;
setProjectFilePath: (path: string | null) => void;
loadVideo: (path: string) => void;
setExportedAudioPath: (path: string | null) => void;
setTranscriptionModel: (model: string | null) => void;
@ -101,6 +103,7 @@ function getStoredZonePreviewPaddingSeconds() {
}
const initialState: EditorState = {
projectFilePath: null,
videoPath: null,
videoUrl: null,
exportedAudioPath: null,
@ -163,6 +166,8 @@ export const useEditorStore = create<EditorState & EditorActions>()(
setBackendUrl: (url) => set({ backendUrl: url }),
setProjectFilePath: (path) => set({ projectFilePath: path }),
setExportedAudioPath: (path) => set({ exportedAudioPath: path }),
setTranscriptionModel: (model) => set({ transcriptionModel: model }),
@ -203,6 +208,7 @@ export const useEditorStore = create<EditorState & EditorActions>()(
...initialState,
backendUrl,
zonePreviewPaddingSeconds,
projectFilePath: null,
videoPath: path,
videoUrl: url,
});
@ -478,7 +484,7 @@ export const useEditorStore = create<EditorState & EditorActions>()(
},
loadProject: (data) => {
const { backendUrl, zonePreviewPaddingSeconds } = get();
const { backendUrl, zonePreviewPaddingSeconds, projectFilePath } = get();
const url = `${backendUrl}/file?path=${encodeURIComponent(data.videoPath)}`;
let globalIdx = 0;
@ -492,6 +498,7 @@ export const useEditorStore = create<EditorState & EditorActions>()(
...initialState,
backendUrl,
zonePreviewPaddingSeconds,
projectFilePath,
videoPath: data.videoPath,
videoUrl: url,
words: data.words || [],
@ -514,7 +521,7 @@ export const useEditorStore = create<EditorState & EditorActions>()(
reset: () => {
const { zonePreviewPaddingSeconds } = get();
set({ ...initialState, zonePreviewPaddingSeconds });
set({ ...initialState, zonePreviewPaddingSeconds, projectFilePath: null });
},
}),
{ limit: 100 },