mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
feat: new var input editor
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { MAX_VAR_KEY_LENGHT, VAR_ITEM_TEMPLATE, getMaxVarNameLength } from '@/config'
|
||||
import { MAX_VAR_KEY_LENGHT, VAR_ITEM_TEMPLATE, VAR_ITEM_TEMPLATE_IN_WORKFLOW, getMaxVarNameLength } from '@/config'
|
||||
import { CONTEXT_PLACEHOLDER_TEXT, HISTORY_PLACEHOLDER_TEXT, PRE_PROMPT_PLACEHOLDER_TEXT, QUERY_PLACEHOLDER_TEXT } from '@/app/components/base/prompt-editor/constants'
|
||||
import { InputVarType } from '@/app/components/workflow/types'
|
||||
|
||||
const otherAllowedRegex = /^[a-zA-Z0-9_]+$/
|
||||
|
||||
@ -21,6 +22,24 @@ export const getNewVar = (key: string, type: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const getNewVarInWorkflow = (key: string, type = InputVarType.textInput) => {
|
||||
const { max_length, ...rest } = VAR_ITEM_TEMPLATE_IN_WORKFLOW
|
||||
if (type !== InputVarType.textInput) {
|
||||
return {
|
||||
...rest,
|
||||
type,
|
||||
variable: key,
|
||||
label: key.slice(0, getMaxVarNameLength(key)),
|
||||
}
|
||||
}
|
||||
return {
|
||||
...VAR_ITEM_TEMPLATE_IN_WORKFLOW,
|
||||
type,
|
||||
variable: key,
|
||||
label: key.slice(0, getMaxVarNameLength(key)),
|
||||
}
|
||||
}
|
||||
|
||||
const checkKey = (key: string, canBeEmpty?: boolean) => {
|
||||
if (key.length === 0 && !canBeEmpty)
|
||||
return 'canNoBeEmpty'
|
||||
|
||||
Reference in New Issue
Block a user