"use client" import { useEffect, useState } from "react" import { toast } from "sonner" import { SharedMessageEditor, type UploadedMessageEditorImage, } from "@/components/chat/shared-message-editor" import { fetchQuickReplyListAll, type AdminQuickReply } from "@/lib/api/admin" type AgentMessageEditorProps = { disabled?: boolean uploadingAsset?: boolean onSend: (html: string) => Promise onUploadImage: (file: File) => Promise onSendAttachment: (file: File) => Promise } export function AgentMessageEditor({ disabled = false, uploadingAsset = false, onSend, onUploadImage, onSendAttachment, }: AgentMessageEditorProps) { const [quickReplies, setQuickReplies] = useState([]) const [loadingQuickReplies, setLoadingQuickReplies] = useState(true) const [quickReplyPickerOpen, setQuickReplyPickerOpen] = useState(false) useEffect(() => { let cancelled = false void fetchQuickReplyListAll() .then((list) => { if (!cancelled) { setQuickReplies(list) } }) .catch((error) => { if (!cancelled) { toast.error(error instanceof Error ? error.message : "加载快捷回复失败") } }) .finally(() => { if (!cancelled) { setLoadingQuickReplies(false) } }) return () => { cancelled = true } }, []) return ( ) }