From 950a52f4fc4f7adea530f67577c2aff97b97bbbe Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 29 Mar 2024 16:19:00 +0800 Subject: [PATCH] feat: input var ui --- web/app/components/base/prompt-editor/index.tsx | 4 +++- .../base/prompt-editor/plugins/placeholder.tsx | 5 ++++- .../components/input-support-select-var.tsx | 9 +++++---- .../nodes/http/components/api-input.tsx | 17 ++++++----------- web/i18n/en-US/workflow.ts | 1 + web/i18n/zh-Hans/workflow.ts | 1 + 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/web/app/components/base/prompt-editor/index.tsx b/web/app/components/base/prompt-editor/index.tsx index 0111946620..981d41e246 100644 --- a/web/app/components/base/prompt-editor/index.tsx +++ b/web/app/components/base/prompt-editor/index.tsx @@ -61,6 +61,7 @@ import { useEventEmitterContextContext } from '@/context/event-emitter' export type PromptEditorProps = { className?: string placeholder?: string + placeholderClassName?: string style?: React.CSSProperties value?: string editable?: boolean @@ -78,6 +79,7 @@ export type PromptEditorProps = { const PromptEditor: FC = ({ className, placeholder, + placeholderClassName, style, value, editable = true, @@ -136,7 +138,7 @@ const PromptEditor: FC = ({
} - placeholder={} + placeholder={} ErrorBoundary={LexicalErrorBoundary} /> { const { t } = useTranslation() return ( -
+
{value || t('common.promptEditor.placeholder')}
) diff --git a/web/app/components/workflow/nodes/_base/components/input-support-select-var.tsx b/web/app/components/workflow/nodes/_base/components/input-support-select-var.tsx index 3646b2af07..cdb0c9dbec 100644 --- a/web/app/components/workflow/nodes/_base/components/input-support-select-var.tsx +++ b/web/app/components/workflow/nodes/_base/components/input-support-select-var.tsx @@ -9,6 +9,7 @@ import PromptEditor from '@/app/components/base/prompt-editor' type Props = { className?: string placeholder?: string + placeholderClassName?: string promptMinHeightClassName?: string value: string onChange: (value: string) => void @@ -21,14 +22,14 @@ type Props = { const Editor: FC = ({ className, placeholder, - promptMinHeightClassName = 'min-h-[30px]', + placeholderClassName, + promptMinHeightClassName = 'min-h-[20px]', value, onChange, onFocusChange, readOnly, nodesOutputVars, }) => { - // const { t } = useTranslation() const { getNode } = useWorkflow() const [isFocus, { @@ -45,9 +46,9 @@ const Editor: FC = ({
<> = ({ url, onUrlChange, }) => { + const { t } = useTranslation() + const inputRef = useRef(null) const [isFocus, setIsFocus] = useState(false) const availableVarList = useAvailableVarList(nodeId, { @@ -65,23 +68,15 @@ const ApiInput: FC = ({ readonly={readonly} /> - {/* */}
) diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index 01cb5665de..47b0083c89 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -203,6 +203,7 @@ const translation = { http: { inputVars: 'Input Variables', api: 'API', + apiPlaceholder: 'Enter URL, type ‘/’ insert variable', notStartWithHttp: 'API should start with http:// or https://', key: 'Key', value: 'Value', diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index 5063e1a32d..935ccc4042 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -203,6 +203,7 @@ const translation = { http: { inputVars: '输入变量', api: 'API', + apiPlaceholder: '输入 URL,输入变量时请键入‘/’', notStartWithHttp: 'API 应该以 http:// 或 https:// 开头', key: '键', value: '值',