import React, { useRef, useState } from 'react'; import { Box, Button, ModalBody, ModalFooter, Textarea, TextareaProps, useDisclosure } from '@chakra-ui/react'; import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; import { useTranslation } from 'next-i18next'; import MyIcon from '@fastgpt/web/components/common/Icon'; import MyModal from '@fastgpt/web/components/common/MyModal'; import ResizeTextarea from 'react-textarea-autosize'; type Props = TextareaProps & { title?: string; iconSrc?: string; autoHeight?: boolean; }; const MyTextarea = React.forwardRef(function MyTextarea(props, ref) { const ModalTextareaRef = useRef(null); const TextareaRef = useRef(null); const { t } = useTranslation(); const { title = t('common:core.app.edit.Prompt Editor'), iconSrc = 'modal/edit', autoHeight = false, onChange, maxH, minH, ...childProps } = props; const { isOpen, onOpen, onClose } = useDisclosure(); return ( <> {isOpen && ( )} ); }); export default React.memo(MyTextarea); const Editor = React.memo(function Editor({ onOpenModal, textareaRef, autoHeight = false, onChange, maxH, minH, showResize, ...props }: Props & { textareaRef: React.RefObject; onOpenModal?: () => void; showResize?: boolean; }) { const { t } = useTranslation(); const [scrollHeight, setScrollHeight] = useState(0); return (