feat(workflow): add disableVariableInsertion prop to form input and trigger components

This commit is contained in:
zhsama
2025-10-15 18:20:13 +08:00
parent c03b790888
commit 729e0e9b1e
6 changed files with 37 additions and 15 deletions

View File

@ -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 = ({
<PromptEditor
key={controlPromptEditorRerenderKey}
wrapperClassName={cn(
'w-full rounded-lg border border-transparent bg-components-input-bg-normal px-2 py-1',
'min-h-8 w-full rounded-lg border border-transparent bg-components-input-bg-normal px-2 py-1',
'hover:border-components-input-border-hover hover:bg-components-input-bg-hover',
'focus-within:border-components-input-border-active focus-within:bg-components-input-bg-active focus-within:shadow-xs',
)}
@ -45,7 +47,7 @@ const MixedVariableTextInput = ({
editable={!readOnly}
value={value}
workflowVariableBlock={{
show: true,
show: !disableVariableInsertion,
variables: nodesOutputVars || [],
workflowNodesMap: availableNodes.reduce((acc, node) => {
acc[node.id] = {
@ -63,7 +65,7 @@ const MixedVariableTextInput = ({
showManageInputField,
onManageInputField,
}}
placeholder={<Placeholder />}
placeholder={<Placeholder disableVariableInsertion={disableVariableInsertion} />}
onChange={onChange}
/>
)

View File

@ -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 = () => {
>
<div className='flex grow items-center'>
{t('workflow.nodes.tool.insertPlaceholder1')}
<div className='system-kbd mx-0.5 flex h-4 w-4 items-center justify-center rounded bg-components-kbd-bg-gray text-text-placeholder'>/</div>
<div
className='system-sm-regular cursor-pointer text-components-input-text-placeholder underline decoration-dotted decoration-auto underline-offset-auto hover:text-text-tertiary'
onMouseDown={((e) => {
e.preventDefault()
e.stopPropagation()
handleInsert('/')
})}
>
{t('workflow.nodes.tool.insertPlaceholder2')}
</div>
{(!disableVariableInsertion) && (
<>
<div className='system-kbd mx-0.5 flex h-4 w-4 items-center justify-center rounded bg-components-kbd-bg-gray text-text-placeholder'>/</div>
<div
className='system-sm-regular cursor-pointer text-components-input-text-placeholder underline decoration-dotted decoration-auto underline-offset-auto hover:text-text-tertiary'
onMouseDown={((e) => {
e.preventDefault()
e.stopPropagation()
handleInsert('/')
})}
>
{t('workflow.nodes.tool.insertPlaceholder2')}
</div>
</>
)}
</div>
<Badge
className='shrink-0'