diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx index 4fe9e69bce..b867d9f64e 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx @@ -188,6 +188,7 @@ const Item: FC = ({ } onClick={handleChosen} onMouseDown={(e) => { + e.preventDefault() e.stopPropagation() e.nativeEvent.stopImmediatePropagation() }} diff --git a/web/app/components/workflow/nodes/human-input/components/variable-in-markdown.tsx b/web/app/components/workflow/nodes/human-input/components/variable-in-markdown.tsx index f46d890fb8..3127ceff32 100644 --- a/web/app/components/workflow/nodes/human-input/components/variable-in-markdown.tsx +++ b/web/app/components/workflow/nodes/human-input/components/variable-in-markdown.tsx @@ -1,38 +1,42 @@ import React from 'react' -import { visit } from 'unist-util-visit' export function rehypeVariable() { return (tree: any) => { - visit(tree, 'text', (node: any, index: number, parent: any) => { - if (!parent || parent.type !== 'element') return - const tag = parent.tagName - if (tag === 'code' || tag === 'pre') return + const iterate = (node: any) => { + console.log(node.type) + } + tree.children.forEach(iterate) - const value: string = node.value - const regex = /\{\{#\$(.+?)#\}\}/g - let m: RegExpExecArray | null - let last = 0 - const parts: any[] = [] + // visit(tree, 'text', (node: any, index: number, parent: any) => { + // if (!parent || parent.type !== 'element') return + // const tag = parent.tagName + // if (tag === 'code' || tag === 'pre') return - while ((m = regex.exec(value))) { - if (m.index > last) - parts.push({ type: 'text', value: value.slice(last, m.index) }) + // const value: string = node.value + // const regex = /\{\{#\$(.+?)#\}\}/g + // let m: RegExpExecArray | null + // let last = 0 + // const parts: any[] = [] - parts.push({ - type: 'element', - tagName: 'variable', - properties: { path: m[1].trim() }, - children: [], // 也可放文本 children - }) - last = m.index + m[0].length - } + // while ((m = regex.exec(value))) { + // if (m.index > last) + // parts.push({ type: 'text', value: value.slice(last, m.index) }) - if (!parts.length) return - if (last < value.length) - parts.push({ type: 'text', value: value.slice(last) }) + // parts.push({ + // type: 'element', + // tagName: 'variable', + // properties: { path: m[1].trim() }, + // children: [], + // }) + // last = m.index + m[0].length + // } - parent.children.splice(index, 1, ...parts) - }) + // if (!parts.length) return + // if (last < value.length) + // parts.push({ type: 'text', value: value.slice(last) }) + + // parent.children.splice(index, 1, ...parts) + // }) } }