mirror of
https://github.com/langgenius/dify.git
synced 2026-02-07 03:21:22 +08:00
feat: node hitl render
This commit is contained in:
parent
177be06d09
commit
922aeb7c21
@ -21,7 +21,7 @@ const HITLInputComponent: FC<QueryBlockComponentProps> = ({
|
||||
return (
|
||||
<div
|
||||
className={`
|
||||
inline-flex h-6 items-center rounded-[5px] border border-transparent bg-[#FFF6ED] pl-1 pr-0.5 hover:bg-[#FFEAD5]
|
||||
flex h-6 items-center rounded-[5px] border-[1.5px] border-components-input-border-active bg-background-default-hover pl-1 pr-0.5 hover:bg-[#FFEAD5]
|
||||
${isSelected && '!border-[#FD853A]'}
|
||||
`}
|
||||
ref={ref}
|
||||
|
||||
@ -18,7 +18,7 @@ import { HITL_INPUT_REG } from '@/config'
|
||||
|
||||
const REGEX = new RegExp(HITL_INPUT_REG)
|
||||
|
||||
const QueryBlockReplacementBlock = ({
|
||||
const HITLInputReplacementBlock = ({
|
||||
onInsert,
|
||||
}: QueryBlockType) => {
|
||||
const [editor] = useLexicalComposerContext()
|
||||
@ -31,7 +31,7 @@ const QueryBlockReplacementBlock = ({
|
||||
const createHITLInputBlockNode = useCallback((textNode: TextNode): QueryBlockNode => {
|
||||
if (onInsert)
|
||||
onInsert()
|
||||
const varName = textNode.getTextContent().split('.')[1]
|
||||
const varName = textNode.getTextContent().split('.')[1].replace(/#}}$/, '')
|
||||
return $applyNodeReplacement($createHITLInputNode(varName))
|
||||
}, [onInsert])
|
||||
|
||||
@ -59,4 +59,4 @@ const QueryBlockReplacementBlock = ({
|
||||
return null
|
||||
}
|
||||
|
||||
export default memo(QueryBlockReplacementBlock)
|
||||
export default memo(HITLInputReplacementBlock)
|
||||
|
||||
@ -34,7 +34,7 @@ export class HITLInputNode extends DecoratorNode<React.JSX.Element> {
|
||||
|
||||
createDOM(): HTMLElement {
|
||||
const div = document.createElement('div')
|
||||
div.classList.add('inline-flex', 'items-center', 'align-middle')
|
||||
div.classList.add('flex', 'w-full', 'items-center', 'align-middle')
|
||||
return div
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ export class HITLInputNode extends DecoratorNode<React.JSX.Element> {
|
||||
}
|
||||
|
||||
getTextContent(): string {
|
||||
return `{{#$outputs.${this.getVariableName()}#}}`
|
||||
return `{{#$output.${this.getVariableName()}#}}`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -255,7 +255,7 @@ export const VAR_REGEX = /\{\{(#[a-zA-Z0-9_-]{1,50}(\.[a-zA-Z_]\w{0,29}){1,10}#)
|
||||
|
||||
export const resetReg = () => VAR_REGEX.lastIndex = 0
|
||||
|
||||
export const HITL_INPUT_REG = /\{\{#$output\.([a-zA-Z_]\w{0,29}){1,10}#\}\}/gi
|
||||
export const HITL_INPUT_REG = /\{\{(#\$output\.([a-zA-Z_]\w{0,29}){1,10}#)\}\}/gi
|
||||
export const resetHITLInputReg = () => HITL_INPUT_REG.lastIndex = 0
|
||||
|
||||
export const DISABLE_UPLOAD_IMAGE_AS_ICON = process.env.NEXT_PUBLIC_DISABLE_UPLOAD_IMAGE_AS_ICON === 'true'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user