From 41115a96c005c29a68d4a4fc321f88d6f7a01aa1 Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Mon, 18 Dec 2023 21:41:17 +0800 Subject: [PATCH] perf: prompt textarea (#625) --- .../common/Textarea/PromptTextarea/index.tsx | 70 +++++++------------ .../core/module/AIChatSettingsModal.tsx | 10 ++- .../render/RenderInput/templates/Textarea.tsx | 28 +++++--- .../app/detail/components/AdEdit/Header.tsx | 4 +- .../detail/components/SimpleEdit/index.tsx | 5 +- 5 files changed, 52 insertions(+), 65 deletions(-) diff --git a/projects/app/src/components/common/Textarea/PromptTextarea/index.tsx b/projects/app/src/components/common/Textarea/PromptTextarea/index.tsx index 8a8c61479..063ea87d4 100644 --- a/projects/app/src/components/common/Textarea/PromptTextarea/index.tsx +++ b/projects/app/src/components/common/Textarea/PromptTextarea/index.tsx @@ -1,4 +1,4 @@ -import React, { useMemo, useState } from 'react'; +import React, { useRef } from 'react'; import { Box, @@ -16,11 +16,13 @@ import MyModal from '@/components/MyModal'; type Props = TextareaProps & { title?: string; - showSetModalModeIcon?: boolean; // variables: string[]; }; const PromptTextarea = (props: Props) => { + const ModalTextareaRef = useRef(null); + const TextareaRef = useRef(null); + const { t } = useTranslation(); const { title = t('core.app.edit.Prompt Editor'), value, ...childProps } = props; @@ -28,21 +30,30 @@ const PromptTextarea = (props: Props) => { return ( <> - + {isOpen && ( - + )} @@ -53,23 +64,26 @@ const PromptTextarea = (props: Props) => { export default PromptTextarea; const Editor = React.memo(function Editor({ - showSetModalModeIcon = true, - onSetModalMode, + onOpenModal, + textareaRef, ...props -}: Props & { onSetModalMode?: () => void }) { +}: Props & { + textareaRef: React.RefObject; + onOpenModal?: () => void; +}) { const { t } = useTranslation(); return ( -