mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 01:26:33 +08:00
feat: template transform code tooltip
This commit is contained in:
parent
671654da71
commit
65ac4dedcc
@ -42,8 +42,8 @@ const Base: FC<Props> = ({
|
|||||||
return (
|
return (
|
||||||
<div className={cn(className, 'rounded-lg border', isFocus ? 'bg-white border-gray-200' : 'bg-gray-100 border-gray-100')}>
|
<div className={cn(className, 'rounded-lg border', isFocus ? 'bg-white border-gray-200' : 'bg-gray-100 border-gray-100')}>
|
||||||
<div className='flex justify-between items-center h-7 pt-1 pl-3 pr-1'>
|
<div className='flex justify-between items-center h-7 pt-1 pl-3 pr-1'>
|
||||||
<div className=''>{title}</div>
|
<div className='text-xs font-semibold text-gray-700'>{title}</div>
|
||||||
<div className='flex'>
|
<div className='flex items-center'>
|
||||||
{headerRight}
|
{headerRight}
|
||||||
{!isCopied
|
{!isCopied
|
||||||
? (
|
? (
|
||||||
|
|||||||
@ -7,12 +7,14 @@ type Props = {
|
|||||||
value: string
|
value: string
|
||||||
onChange: (value: string) => void
|
onChange: (value: string) => void
|
||||||
title: JSX.Element
|
title: JSX.Element
|
||||||
|
headerRight?: JSX.Element
|
||||||
}
|
}
|
||||||
|
|
||||||
const CodeEditor: FC<Props> = ({
|
const CodeEditor: FC<Props> = ({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
title,
|
title,
|
||||||
|
headerRight,
|
||||||
}) => {
|
}) => {
|
||||||
const [isFocus, setIsFocus] = React.useState(false)
|
const [isFocus, setIsFocus] = React.useState(false)
|
||||||
|
|
||||||
@ -21,6 +23,7 @@ const CodeEditor: FC<Props> = ({
|
|||||||
<Base
|
<Base
|
||||||
title={title}
|
title={title}
|
||||||
value={value}
|
value={value}
|
||||||
|
headerRight={headerRight}
|
||||||
isFocus={isFocus}
|
isFocus={isFocus}
|
||||||
minHeight={86}
|
minHeight={86}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import Field from '@/app/components/workflow/nodes/_base/components/field'
|
|||||||
import Split from '@/app/components/workflow/nodes/_base/components/split'
|
import Split from '@/app/components/workflow/nodes/_base/components/split'
|
||||||
import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
|
import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
|
||||||
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
|
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
|
||||||
|
import { HelpCircle } from '@/app/components/base/icons/src/vender/line/general'
|
||||||
|
|
||||||
const i18nPrefix = 'workflow.nodes.templateTransform'
|
const i18nPrefix = 'workflow.nodes.templateTransform'
|
||||||
|
|
||||||
@ -38,7 +39,19 @@ const Panel: FC = () => {
|
|||||||
<Split />
|
<Split />
|
||||||
<CodeEditor
|
<CodeEditor
|
||||||
title={
|
title={
|
||||||
<div>{t(`${i18nPrefix}.code`)}</div>
|
<div className='uppercase'>{t(`${i18nPrefix}.code`)}</div>
|
||||||
|
}
|
||||||
|
headerRight={
|
||||||
|
<div className='flex items-center'>
|
||||||
|
<a
|
||||||
|
className='flex items-center space-x-0.5 h-[18px] text-xs font-normal text-gray-500'
|
||||||
|
href="https://jinja.palletsprojects.com/en/3.1.x/templates/"
|
||||||
|
target='_blank'>
|
||||||
|
<span>{t(`${i18nPrefix}.codeSupportTip`)}</span>
|
||||||
|
<HelpCircle className='w-3 h-3' />
|
||||||
|
</a>
|
||||||
|
<div className='mx-1.5 w-px h-3 bg-gray-200'></div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
value={inputs.template}
|
value={inputs.template}
|
||||||
onChange={handleCodeChange}
|
onChange={handleCodeChange}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ const translation = {
|
|||||||
templateTransform: {
|
templateTransform: {
|
||||||
inputVars: 'Input Variables',
|
inputVars: 'Input Variables',
|
||||||
code: 'Code',
|
code: 'Code',
|
||||||
|
codeSupportTip: 'Only supports Jinja2',
|
||||||
outputVars: {
|
outputVars: {
|
||||||
output: 'Transformed content',
|
output: 'Transformed content',
|
||||||
},
|
},
|
||||||
|
|||||||
@ -18,15 +18,16 @@ const translation = {
|
|||||||
output: '生成内容',
|
output: '生成内容',
|
||||||
usage: '模型用量信息',
|
usage: '模型用量信息',
|
||||||
},
|
},
|
||||||
code: {
|
},
|
||||||
inputVars: '输入变量',
|
code: {
|
||||||
},
|
inputVars: '输入变量',
|
||||||
templateTransform: {
|
},
|
||||||
inputVars: '输入变量',
|
templateTransform: {
|
||||||
code: '代码',
|
inputVars: '输入变量',
|
||||||
outputVars: {
|
code: '代码',
|
||||||
output: '转换后内容',
|
codeSupportTip: '只支持 Jinja2',
|
||||||
},
|
outputVars: {
|
||||||
|
output: '转换后内容',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user