"use client"; import { useRef } from "react"; import { FileUp, Sparkles, Trash2 } from "lucide-react"; import type { Caption } from "@/types"; import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/textarea"; import { parseSrt } from "@/lib/srt-parser"; import { autoSyncCaptions, captionsToText } from "@/lib/timing"; interface CaptionEditorProps { text: string; captions: Caption[]; animationSpeed: number; onTextChange: (text: string) => void; onCaptionsChange: (captions: Caption[]) => void; } export function CaptionEditor({ text, captions, animationSpeed, onTextChange, onCaptionsChange, }: CaptionEditorProps) { const fileRef = useRef(null); const handleAutoSync = () => { if (!text.trim()) return; onCaptionsChange(autoSyncCaptions(text, animationSpeed)); }; const handleSrtUpload = async (file: File) => { const content = await file.text(); const parsed = parseSrt(content); if (parsed.length === 0) return; onCaptionsChange(parsed); onTextChange(captionsToText(parsed)); }; return (

Caption Text

{captions.length} words