| const value = formSchema.default | const value = formSchema.default | ||||
| newValues[formSchema.variable] = { | newValues[formSchema.variable] = { | ||||
| type: 'constant', | type: 'constant', | ||||
| value: formSchema.default, | |||||
| value: typeof formSchema.default === 'string' ? formSchema.default.replace(/\n/g, '\\n') : formSchema.default, | |||||
| } | } | ||||
| newValues[formSchema.variable] = correctInitialData(formSchema.type, newValues[formSchema.variable], value) | newValues[formSchema.variable] = correctInitialData(formSchema.type, newValues[formSchema.variable], value) | ||||
| } | } |
| } from '@/app/components/workflow/types' | } from '@/app/components/workflow/types' | ||||
| import { BlockEnum } from '@/app/components/workflow/types' | import { BlockEnum } from '@/app/components/workflow/types' | ||||
| import cn from '@/utils/classnames' | import cn from '@/utils/classnames' | ||||
| import { useStore } from '@/app/components/workflow/store' | |||||
| type MixedVariableTextInputProps = { | type MixedVariableTextInputProps = { | ||||
| readOnly?: boolean | readOnly?: boolean | ||||
| onManageInputField, | onManageInputField, | ||||
| }: MixedVariableTextInputProps) => { | }: MixedVariableTextInputProps) => { | ||||
| const { t } = useTranslation() | const { t } = useTranslation() | ||||
| const controlPromptEditorRerenderKey = useStore(s => s.controlPromptEditorRerenderKey) | |||||
| return ( | return ( | ||||
| <PromptEditor | <PromptEditor | ||||
| key={controlPromptEditorRerenderKey} | |||||
| wrapperClassName={cn( | wrapperClassName={cn( | ||||
| 'w-full rounded-lg border border-transparent bg-components-input-bg-normal px-2 py-1', | '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', | 'hover:border-components-input-border-hover hover:bg-components-input-bg-hover', |
| const { schemaTypeDefinitions } = useMatchSchemaType() | const { schemaTypeDefinitions } = useMatchSchemaType() | ||||
| if (isLoading) { | if (isLoading) { | ||||
| return <div className='flex h-[200px] items-center justify-center'> | |||||
| <Loading /> | |||||
| </div> | |||||
| return ( | |||||
| <div className='flex h-[200px] items-center justify-center'> | |||||
| <Loading /> | |||||
| </div> | |||||
| ) | |||||
| } | } | ||||
| return ( | return ( |
| import { useTranslation } from 'react-i18next' | import { useTranslation } from 'react-i18next' | ||||
| import produce from 'immer' | import produce from 'immer' | ||||
| import { useBoolean } from 'ahooks' | import { useBoolean } from 'ahooks' | ||||
| import { useStore } from '../../store' | |||||
| import { useStore, useWorkflowStore } from '../../store' | |||||
| import type { ToolNodeType, ToolVarInputs } from './types' | import type { ToolNodeType, ToolVarInputs } from './types' | ||||
| import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' | import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' | ||||
| import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud' | import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud' | ||||
| import { canFindTool } from '@/utils' | import { canFindTool } from '@/utils' | ||||
| const useConfig = (id: string, payload: ToolNodeType) => { | const useConfig = (id: string, payload: ToolNodeType) => { | ||||
| const workflowStore = useWorkflowStore() | |||||
| const { nodesReadOnly: readOnly } = useNodesReadOnly() | const { nodesReadOnly: readOnly } = useNodesReadOnly() | ||||
| const { handleFetchAllTools } = useFetchToolsData() | const { handleFetchAllTools } = useFetchToolsData() | ||||
| const { t } = useTranslation() | const { t } = useTranslation() | ||||
| if (!currTool) | if (!currTool) | ||||
| return | return | ||||
| const inputsWithDefaultValue = formattingParameters() | const inputsWithDefaultValue = formattingParameters() | ||||
| const { setControlPromptEditorRerenderKey } = workflowStore.getState() | |||||
| setInputs(inputsWithDefaultValue) | setInputs(inputsWithDefaultValue) | ||||
| setTimeout(() => setControlPromptEditorRerenderKey(Date.now())) | |||||
| }, [currTool]) | }, [currTool]) | ||||
| // setting when call | // setting when call |