import { useState, useEffect } from "react"; import { RichTextArea } from "../core/RichTextArea"; import type { Message } from "../../../core/types"; import Quote from "../core/Quote"; import AnimatedHeight from "../core/animations/AnimatedHeight"; interface ChatInputWrapperProps { onSendMessage: (message: string) => void; onSaveEdit?: (content: string) => void; replyTo?: Message | null; replyToVisible: boolean; onClearReply?: () => void; onCloseReply?: () => void; editingMessage?: Message | null; editVisible?: boolean; onClearEdit?: () => void; onCloseEdit?: () => void; } export function ChatInputWrapper({ onSendMessage, onSaveEdit, replyTo, replyToVisible, onClearReply, onCloseReply, editingMessage, editVisible = false, onClearEdit, onCloseEdit }: ChatInputWrapperProps) { const [message, setMessage] = useState(""); // When entering edit mode, preload the message content useEffect(() => { if (editingMessage) { setMessage(editingMessage.content || ""); } }, [editingMessage]); const handleSubmit = async (e: React.FormEvent | Event) => { e.preventDefault(); if (message.trim()) { if (editingMessage && onSaveEdit) { onSaveEdit(message); setMessage(""); if (onClearEdit) onClearEdit(); } else { onSendMessage(message); setMessage(""); if (onClearReply) onClearReply(); } } }; return (