From 729e0e9b1e7afe87aa20d7a32bb46252c15d26fd Mon Sep 17 00:00:00 2001 From: zhsama Date: Wed, 15 Oct 2025 18:20:13 +0800 Subject: [PATCH] feat(workflow): add disableVariableInsertion prop to form input and trigger components --- .../_base/components/form-input-item.tsx | 3 ++ .../mixed-variable-text-input/index.tsx | 8 +++-- .../mixed-variable-text-input/placeholder.tsx | 32 ++++++++++++------- .../components/trigger-form/index.tsx | 3 ++ .../components/trigger-form/item.tsx | 3 ++ .../workflow/nodes/trigger-plugin/panel.tsx | 3 ++ 6 files changed, 37 insertions(+), 15 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/form-input-item.tsx b/web/app/components/workflow/nodes/_base/components/form-input-item.tsx index b5fdccde01..7dd9bcb414 100644 --- a/web/app/components/workflow/nodes/_base/components/form-input-item.tsx +++ b/web/app/components/workflow/nodes/_base/components/form-input-item.tsx @@ -42,6 +42,7 @@ type Props = { onManageInputField?: () => void extraParams?: Record providerType?: string + disableVariableInsertion?: boolean } const FormInputItem: FC = ({ @@ -57,6 +58,7 @@ const FormInputItem: FC = ({ onManageInputField, extraParams, providerType, + disableVariableInsertion = false, }) => { const language = useLanguage() const [toolsOptions, setToolsOptions] = useState(null) @@ -286,6 +288,7 @@ const FormInputItem: FC = ({ availableNodes={availableNodesWithParent} showManageInputField={showManageInputField} onManageInputField={onManageInputField} + disableVariableInsertion={disableVariableInsertion} /> )} {isNumber && isConstant && ( diff --git a/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx b/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx index ec35f9a60a..fa50727123 100644 --- a/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx +++ b/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx @@ -20,6 +20,7 @@ type MixedVariableTextInputProps = { onChange?: (text: string) => void showManageInputField?: boolean onManageInputField?: () => void + disableVariableInsertion?: boolean } const MixedVariableTextInput = ({ readOnly = false, @@ -29,6 +30,7 @@ const MixedVariableTextInput = ({ onChange, showManageInputField, onManageInputField, + disableVariableInsertion = false, }: MixedVariableTextInputProps) => { const { t } = useTranslation() const controlPromptEditorRerenderKey = useStore(s => s.controlPromptEditorRerenderKey) @@ -37,7 +39,7 @@ const MixedVariableTextInput = ({ { acc[node.id] = { @@ -63,7 +65,7 @@ const MixedVariableTextInput = ({ showManageInputField, onManageInputField, }} - placeholder={} + placeholder={} onChange={onChange} /> ) diff --git a/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/placeholder.tsx b/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/placeholder.tsx index 75d4c91996..d6e0bbc059 100644 --- a/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/placeholder.tsx +++ b/web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/placeholder.tsx @@ -6,7 +6,11 @@ import { $insertNodes } from 'lexical' import { CustomTextNode } from '@/app/components/base/prompt-editor/plugins/custom-text/node' import Badge from '@/app/components/base/badge' -const Placeholder = () => { +type PlaceholderProps = { + disableVariableInsertion?: boolean +} + +const Placeholder = ({ disableVariableInsertion = false }: PlaceholderProps) => { const { t } = useTranslation() const [editor] = useLexicalComposerContext() @@ -28,17 +32,21 @@ const Placeholder = () => { >
{t('workflow.nodes.tool.insertPlaceholder1')} -
/
-
{ - e.preventDefault() - e.stopPropagation() - handleInsert('/') - })} - > - {t('workflow.nodes.tool.insertPlaceholder2')} -
+ {(!disableVariableInsertion) && ( + <> +
/
+
{ + e.preventDefault() + e.stopPropagation() + handleInsert('/') + })} + > + {t('workflow.nodes.tool.insertPlaceholder2')} +
+ + )}
+ disableVariableInsertion?: boolean } const TriggerForm: FC = ({ @@ -29,6 +30,7 @@ const TriggerForm: FC = ({ currentTrigger, currentProvider, extraParams, + disableVariableInsertion = false, }) => { return (
@@ -45,6 +47,7 @@ const TriggerForm: FC = ({ currentTrigger={currentTrigger} currentProvider={currentProvider} extraParams={extraParams} + disableVariableInsertion={disableVariableInsertion} /> )) } diff --git a/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item.tsx b/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item.tsx index 79d427075c..22331aa578 100644 --- a/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item.tsx +++ b/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item.tsx @@ -25,6 +25,7 @@ type Props = { currentTrigger?: Event currentProvider?: TriggerWithProvider extraParams?: Record + disableVariableInsertion?: boolean } const TriggerFormItem: FC = ({ @@ -37,6 +38,7 @@ const TriggerFormItem: FC = ({ currentTrigger, currentProvider, extraParams, + disableVariableInsertion = false, }) => { const language = useLanguage() const { name, label, type, required, tooltip, input_schema } = schema @@ -93,6 +95,7 @@ const TriggerFormItem: FC = ({ currentProvider={currentProvider} providerType='trigger' extraParams={extraParams} + disableVariableInsertion={disableVariableInsertion} /> {isShowSchema && ( diff --git a/web/app/components/workflow/nodes/trigger-plugin/panel.tsx b/web/app/components/workflow/nodes/trigger-plugin/panel.tsx index a412df39c1..dcce6a204c 100644 --- a/web/app/components/workflow/nodes/trigger-plugin/panel.tsx +++ b/web/app/components/workflow/nodes/trigger-plugin/panel.tsx @@ -8,6 +8,7 @@ import useConfig from './use-config' import TriggerForm from './components/trigger-form' import StructureOutputItem from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show' import { Type } from '../llm/types' +import { BlockEnum } from '@/app/components/workflow/types' const Panel: FC> = ({ id, @@ -24,6 +25,7 @@ const Panel: FC> = ({ currentProvider, currentTrigger, } = useConfig(id, data) + const disableVariableInsertion = data.type === BlockEnum.TriggerPlugin // Convert output schema to VarItem format const outputVars = Object.entries(outputSchema.properties || {}).map(([name, schema]: [string, any]) => ({ @@ -46,6 +48,7 @@ const Panel: FC> = ({ onChange={setTriggerParameterValue} currentProvider={currentProvider} currentTrigger={currentTrigger} + disableVariableInsertion={disableVariableInsertion} />