import { cn } from '@heroui/react'; import { useEffect, useRef, useState } from 'react'; export type MessageEditAreaProps = { isUser: boolean; editedMessage: string; onEditChange: (content: string) => void; onEditAreaShow: () => void; }; export const MessageEditArea = ({ isUser, editedMessage, onEditChange, onEditAreaShow, }: MessageEditAreaProps) => { const textareaRef = useRef(null); const [wrapHeight, setWrapHeight] = useState(0); // biome-ignore lint/correctness/useExhaustiveDependencies: useMount useEffect(() => { const t = textareaRef.current; if (t) { const parent = t.parentElement; console.log(parent); t.style.height = 'auto'; t.style.height = t.scrollHeight + 'px'; if (parent) { parent.style.height = t?.scrollHeight + 'px'; } t.focus(); // 光标移到最后 const length = t.value.length; t.setSelectionRange(length, length); onEditAreaShow(); } }, []); return (