mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
feat: code editor base
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { useState } from 'react'
|
||||
import { useCallback, useState } from 'react'
|
||||
import useVarList from '../_base/hooks/use-var-list'
|
||||
import type { CodeNodeType } from './types'
|
||||
import type { CodeLanguage, CodeNodeType } from './types'
|
||||
|
||||
const useConfig = (initInputs: CodeNodeType) => {
|
||||
const [inputs, setInputs] = useState<CodeNodeType>(initInputs)
|
||||
@ -9,10 +9,20 @@ const useConfig = (initInputs: CodeNodeType) => {
|
||||
setInputs,
|
||||
})
|
||||
|
||||
const handleCodeChange = useCallback((code: string) => {
|
||||
setInputs(prev => ({ ...prev, code }))
|
||||
}, [setInputs])
|
||||
|
||||
const handleCodeLanguageChange = useCallback((codeLanguage: CodeLanguage) => {
|
||||
setInputs(prev => ({ ...prev, code_language: codeLanguage }))
|
||||
}, [setInputs])
|
||||
|
||||
return {
|
||||
inputs,
|
||||
handleVarListChange,
|
||||
handleAddVariable,
|
||||
handleCodeChange,
|
||||
handleCodeLanguageChange,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user