import { useEffect, useMemo, useState } from "react"; import { convertFileSrc } from "@tauri-apps/api/core"; import type { HotspotAction } from "../../types/annotations"; import { useEditor } from "./EditorContext"; interface DraftTextInputProps { value: string; placeholder?: string; multiline?: boolean; rows?: number; className: string; onCommit: (value: string) => void; onFocus?: () => void; } function DraftTextInput({ value, placeholder, multiline = false, rows = 3, className, onCommit, onFocus, }: DraftTextInputProps) { const [draft, setDraft] = useState(value); useEffect(() => { setDraft(value); }, [value]); const commit = () => { if (!multiline) { const normalized = draft.trim(); if (normalized === "") { setDraft(value); return; } if (normalized === value) { setDraft(normalized); return; } onCommit(normalized); setDraft(normalized); return; } if (draft === value) return; onCommit(draft); }; if (multiline) { return (