기존 GhiVideo 저장소 HEAD의 트래킹 소스 362개 파일을 복제. (node_modules·storage·빌드 산출물·대용량 미디어는 .gitignore 규칙대로 제외) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
26 lines
900 B
TypeScript
26 lines
900 B
TypeScript
import { create } from 'zustand';
|
|
import type { Annotation } from '@abcvideo/shared';
|
|
|
|
interface AnnotationStore {
|
|
annotations: Annotation[];
|
|
setAnnotations: (a: Annotation[]) => void;
|
|
addAnnotation: (a: Annotation) => void;
|
|
updateAnnotation: (id: string, a: Partial<Annotation>) => void;
|
|
removeAnnotation: (id: string) => void;
|
|
}
|
|
|
|
export const useAnnotationStore = create<AnnotationStore>((set) => ({
|
|
annotations: [],
|
|
setAnnotations: (annotations) => set({ annotations }),
|
|
addAnnotation: (annotation) =>
|
|
set((s) => ({
|
|
annotations: [...s.annotations, annotation].sort((a, b) => a.timeStart - b.timeStart),
|
|
})),
|
|
updateAnnotation: (id, update) =>
|
|
set((s) => ({
|
|
annotations: s.annotations.map((a) => (a.id === id ? { ...a, ...update } : a)),
|
|
})),
|
|
removeAnnotation: (id) =>
|
|
set((s) => ({ annotations: s.annotations.filter((a) => a.id !== id) })),
|
|
}));
|