perf:textarea auto height (#2967)

* perf:textarea auto height

* optimize editor height & fix variable label split
This commit is contained in:
heheer
2024-10-22 18:33:02 +08:00
committed by shilin66
parent 90dcb35b40
commit f8a45a63bb
11 changed files with 100 additions and 46 deletions

View File

@@ -33,7 +33,7 @@ import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
import { AppContext } from '../../../context';
import { VariableInputItem } from '@/components/core/chat/ChatContainer/ChatBox/components/VariableInput';
import LightRowTabs from '@fastgpt/web/components/common/Tabs/LightRowTabs';
import PromptEditor from '@fastgpt/web/components/common/Textarea/PromptEditor';
import MyTextarea from '@/components/common/Textarea/MyTextarea';
const MyRightDrawer = dynamic(
() => import('@fastgpt/web/components/common/MyDrawer/MyRightDrawer')
@@ -270,16 +270,16 @@ export const useDebug = () => {
const RenderInput = (() => {
if (input.valueType === WorkflowIOValueTypeEnum.string) {
return (
<PromptEditor
<MyTextarea
autoHeight
minH={40}
maxH={160}
bg={'myGray.50'}
placeholder={t(input.placeholder || ('' as any))}
value={getValues(`nodeVariables.${input.key}`)}
onChange={(e) => {
setValue(`nodeVariables.${input.key}`, e);
setValue(`nodeVariables.${input.key}`, e.target.value);
}}
minH={50}
maxH={150}
showOpenModal={false}
placeholder={t(input.placeholder || ('' as any))}
bg={'myGray.50'}
/>
);
}

View File

@@ -34,7 +34,7 @@ import { useFieldArray, UseFormReturn } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import MyIcon from '@fastgpt/web/components/common/Icon';
import DndDrag, { Draggable } from '@fastgpt/web/components/common/DndDrag';
import PromptEditor from '@fastgpt/web/components/common/Textarea/PromptEditor';
import MyTextarea from '@/components/common/Textarea/MyTextarea';
type ListValueType = { id: string; value: string; label: string }[];
@@ -316,15 +316,12 @@ const InputTypeConfig = ({
</NumberInput>
)}
{inputType === FlowNodeInputTypeEnum.input && (
<PromptEditor
value={defaultValue}
onChange={(e) => {
setValue('defaultValue', e);
}}
minH={40}
maxH={200}
showOpenModal={false}
<MyTextarea
{...register('defaultValue')}
bg={'myGray.50'}
autoHeight
minH={40}
maxH={100}
/>
)}
{inputType === FlowNodeInputTypeEnum.JSONEditor && (

View File

@@ -1,4 +1,4 @@
import React, { Dispatch, useMemo, useState } from 'react';
import React, { Dispatch, useMemo } from 'react';
import { NodeProps } from 'reactflow';
import NodeCard from '../render/NodeCard';
import { FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d';
@@ -10,7 +10,7 @@ import MyTextarea from '@/components/common/Textarea/MyTextarea';
import { AppContext } from '../../../../context';
import { AppChatConfigType, AppDetailType } from '@fastgpt/global/core/app/type';
import { getAppChatConfig } from '@fastgpt/global/core/workflow/utils';
import { useCreation, useMount } from 'ahooks';
import { useMount } from 'ahooks';
import ChatFunctionTip from '@/components/core/app/Tip';
import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';
import { WorkflowContext } from '../../../context';
@@ -96,6 +96,9 @@ function Instruction({ chatConfig: { instruction }, setAppDetail }: ComponentPro
resize={'both'}
placeholder={t('workflow:plugin.Instruction_Tip')}
value={instruction}
autoHeight
minH={100}
maxH={240}
onChange={(e) => {
setAppDetail((state) => ({
...state,