diff --git a/web/app/components/base/prompt-editor/plugins/hitl-input-block/pre-populate.tsx b/web/app/components/base/prompt-editor/plugins/hitl-input-block/pre-populate.tsx index cc71969dcd..22e09a8b1a 100644 --- a/web/app/components/base/prompt-editor/plugins/hitl-input-block/pre-populate.tsx +++ b/web/app/components/base/prompt-editor/plugins/hitl-input-block/pre-populate.tsx @@ -2,8 +2,8 @@ import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker' import type { ValueSelector } from '@/app/components/workflow/types' import type { FC } from 'react' -import React from 'react' -import { useTranslation } from 'react-i18next' +import React, { useCallback, useState } from 'react' +import { Trans, useTranslation } from 'react-i18next' import Textarea from '../../../textarea' import TagLabel from './tag-label' import cn from '@/utils/classnames' @@ -21,18 +21,24 @@ type Props = { const i18nPrefix = 'workflow.nodes.humanInput.insertInputField' -const Placeholder = () => { +type PlaceholderProps = { + onTypeClick: (isVariable: boolean) => void +} +const Placeholder = ({ + onTypeClick, +}: PlaceholderProps) => { const { t } = useTranslation() return ( -
-
- {t(`${i18nPrefix}.add`)} - - {t(`${i18nPrefix}.or`)} - - {t(`${i18nPrefix}.users`)} +
+
+ onTypeClick(false)}>{t(`${i18nPrefix}.staticContent`)}, + variable: onTypeClick(true)}>{t(`${i18nPrefix}.variable`)}, + }} + />
-
{t(`${i18nPrefix}.prePopulateFieldPlaceholderEnd`)}
) } @@ -48,10 +54,17 @@ const PrePopulate: FC = ({ }) => { const { t } = useTranslation() + const [onPlaceholderClicked, setOnPlaceholderClicked] = useState(false) + const handlePlaceholderTypeClick = useCallback((isVar: boolean) => { + setOnPlaceholderClicked(true) + onIsVariableChange?.(isVar) + }, [onIsVariableChange]) + + const isShowPlaceholder = !onPlaceholderClicked && (isVariable ? (!valueSelector || valueSelector.length === 0) : !value) + if (isShowPlaceholder) + return + const main = (() => { - const isShowPlaceholder = isVariable ? (!valueSelector || valueSelector.length === 0) : !value - if (isShowPlaceholder) - return if (isVariable) { return ( void } const TagLabel: FC = ({ type, - text, + children, + className, + onClick, }) => { const Icon = type === 'edit' ? RiEditLine : Variable02 return ( -
+
-
{text}
+
{children}
) } diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index 9241039fc9..9de21e10fd 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -966,12 +966,9 @@ const translation = { saveResponseAs: 'Save Response As', saveResponseAsPlaceholder: 'Name this variable for later reference', prePopulateField: 'Pre-populate Field', - add: 'Add', + prePopulateFieldPlaceholder: 'Add or users will see this content initially, or leave empty.', staticContent: 'Static Content', - or: 'or', variable: 'variable', - users: 'users', - prePopulateFieldPlaceholderEnd: 'will see initially, or leave empty.', insert: 'Insert', useVarInstead: 'Use Variable Instead', useConstantInstead: 'Use Constant Instead', diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index c6cbedac7f..7e8d5effee 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -967,12 +967,9 @@ const translation = { saveResponseAs: '保存响应为', saveResponseAsPlaceholder: '为此变量命名以便将来引用', prePopulateField: '预填充字段', - add: '添加', + prePopulateFieldPlaceholder: '添加 用户将最初看到此内容,或留空。', staticContent: '静态内容', - or: '或', variable: '变量', - users: '用户', - prePopulateFieldPlaceholderEnd: '将最初看到,或留空。', insert: '插入', useVarInstead: '使用变量代替', useConstantInstead: '使用常量代替',