From b08327cb4b5c5be5d6a3ef4772fa6086769ec1cc Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 28 Feb 2024 16:24:54 +0800 Subject: [PATCH] feat: edit body --- .../_base/components/editor/code-editor.tsx | 1 + .../_base/components/editor/text-editor.tsx | 54 +++++++ .../nodes/http/components/api-input.tsx | 18 +-- .../nodes/http/components/edit-body/index.tsx | 134 ++++++++++++++++++ .../components/key-value/bulk-edit/index.tsx | 29 ++-- .../nodes/http/hooks/use-key-value-list.ts | 7 +- .../components/workflow/nodes/http/mock.ts | 6 +- .../components/workflow/nodes/http/panel.tsx | 23 ++- .../components/workflow/nodes/http/types.ts | 22 ++- .../workflow/nodes/http/use-config.ts | 29 +++- 10 files changed, 281 insertions(+), 42 deletions(-) create mode 100644 web/app/components/workflow/nodes/_base/components/editor/text-editor.tsx create mode 100644 web/app/components/workflow/nodes/http/components/edit-body/index.tsx diff --git a/web/app/components/workflow/nodes/_base/components/editor/code-editor.tsx b/web/app/components/workflow/nodes/_base/components/editor/code-editor.tsx index dcc20c8975..d8e819c118 100644 --- a/web/app/components/workflow/nodes/_base/components/editor/code-editor.tsx +++ b/web/app/components/workflow/nodes/_base/components/editor/code-editor.tsx @@ -7,6 +7,7 @@ type Props = { value: string onChange: (value: string) => void title: JSX.Element + language?: string headerRight?: JSX.Element } diff --git a/web/app/components/workflow/nodes/_base/components/editor/text-editor.tsx b/web/app/components/workflow/nodes/_base/components/editor/text-editor.tsx new file mode 100644 index 0000000000..2e0d9f1049 --- /dev/null +++ b/web/app/components/workflow/nodes/_base/components/editor/text-editor.tsx @@ -0,0 +1,54 @@ +'use client' +import type { FC } from 'react' +import React, { useCallback } from 'react' +import { useBoolean } from 'ahooks' +import Base from './base' + +type Props = { + value: string + onChange: (value: string) => void + title: JSX.Element + headerRight?: JSX.Element + minHeight?: number + onBlur?: () => void +} + +const TextEditor: FC = ({ + value, + onChange, + title, + headerRight, + minHeight, + onBlur, +}) => { + const [isFocus, { + setTrue: setIsFocus, + setFalse: setIsNotFocus, + }] = useBoolean(false) + + const handleBlur = useCallback(() => { + setIsNotFocus() + onBlur?.() + }, [setIsNotFocus, onBlur]) + + return ( +
+ +