From 1ac96564a0dc1be11a39365bd59c8504e4d694a0 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 26 Mar 2024 16:35:53 +0800 Subject: [PATCH] feat: http node hightlight node --- .../configuration/base/var-highlight/index.tsx | 8 +++++--- .../_base/components/support-var-input/index.tsx | 15 ++++++++------- web/app/components/workflow/nodes/http/node.tsx | 8 +++++++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/web/app/components/app/configuration/base/var-highlight/index.tsx b/web/app/components/app/configuration/base/var-highlight/index.tsx index 64c907d664..3dd6c14902 100644 --- a/web/app/components/app/configuration/base/var-highlight/index.tsx +++ b/web/app/components/app/configuration/base/var-highlight/index.tsx @@ -6,15 +6,17 @@ import s from './style.module.css' export type IVarHighlightProps = { name: string + className?: string } const VarHighlight: FC = ({ name, + className = '', }) => { return (
{'{{'} {name} @@ -23,8 +25,8 @@ const VarHighlight: FC = ({ ) } -export const varHighlightHTML = ({ name }: IVarHighlightProps) => { - const html = `
+export const varHighlightHTML = ({ name, className = '' }: IVarHighlightProps) => { + const html = `
{{ ${name} }} diff --git a/web/app/components/workflow/nodes/_base/components/support-var-input/index.tsx b/web/app/components/workflow/nodes/_base/components/support-var-input/index.tsx index aadcf02de6..921ad57172 100644 --- a/web/app/components/workflow/nodes/_base/components/support-var-input/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/support-var-input/index.tsx @@ -4,10 +4,10 @@ import React from 'react' import cn from 'classnames' import { varHighlightHTML } from '@/app/components/app/configuration/base/var-highlight' type Props = { - isFocus: boolean - onFocus: () => void + isFocus?: boolean + onFocus?: () => void value: string - children: React.ReactNode + children?: React.ReactNode wrapClassName?: string textClassName?: string readonly?: boolean @@ -25,22 +25,23 @@ const SupportVarInput: FC = ({ const withHightContent = (value || '') .replace(//g, '>') - .replace(/\{\{([^}]+)\}\}/g, varHighlightHTML({ name: '$1' })) // `{{$1}}` + .replace(/\{\{([^}]+)\}\}/g, varHighlightHTML({ name: '$1', className: '!mb-0' })) // `{{$1}}` .replace(/\n/g, '
') return (
- {(isFocus && !readonly) + {(isFocus && !readonly && children) ? ( children ) : (
diff --git a/web/app/components/workflow/nodes/http/node.tsx b/web/app/components/workflow/nodes/http/node.tsx index 8ed5877207..161bf97f8f 100644 --- a/web/app/components/workflow/nodes/http/node.tsx +++ b/web/app/components/workflow/nodes/http/node.tsx @@ -2,6 +2,7 @@ import type { FC } from 'react' import React from 'react' import type { HttpNodeType } from './types' import type { NodeProps } from '@/app/components/workflow/types' +import SupportVarInput from '@/app/components/workflow/nodes/_base/components/support-var-input' const Node: FC> = ({ data, @@ -11,7 +12,12 @@ const Node: FC> = ({
{method}
-
{url}
+
)