import React, { useState, useEffect, useRef } from 'react'; import { useSortable } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; import { motion, AnimatePresence } from 'framer-motion'; import { GripVertical, Trash2, Copy, Plus } from 'lucide-react'; import { StoryboardCard as StoryboardCardType, DialogueItem as DialogueItemType, CharacterOption, mockCharacterOptions } from '@/app/model/enums'; import DialogueItem from './dialogue-item'; import KeywordText from './keyword-text'; import { DndContext, closestCenter } from '@dnd-kit/core'; import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'; interface StoryboardCardProps { card: StoryboardCardType; onUpdate: (updates: Partial) => void; onDelete: () => void; onDuplicate: () => void; } const EditableField: React.FC<{ label: string; value: string; onChange: (value: string) => void; className?: string; }> = ({ label, value, onChange, className = '' }) => { const [isEditing, setIsEditing] = useState(false); const [editValue, setEditValue] = useState(value); const textareaRef = useRef(null); const handleSave = () => { onChange(editValue); setIsEditing(false); }; // 自动调整文本框高度 useEffect(() => { if (isEditing && textareaRef.current) { textareaRef.current.style.height = 'auto'; textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`; } }, [isEditing, editValue]); return (
{label}
{isEditing ? (