Commit 65ac4ded authored by Joel's avatar Joel

feat: template transform code tooltip

parent 671654da
...@@ -42,8 +42,8 @@ const Base: FC<Props> = ({ ...@@ -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 = { ...@@ -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> = ({ ...@@ -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' ...@@ -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 = () => { ...@@ -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 = { ...@@ -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,18 +18,19 @@ const translation = { ...@@ -18,18 +18,19 @@ const translation = {
output: '生成内容', output: '生成内容',
usage: '模型用量信息', usage: '模型用量信息',
}, },
},
code: { code: {
inputVars: '输入变量', inputVars: '输入变量',
}, },
templateTransform: { templateTransform: {
inputVars: '输入变量', inputVars: '输入变量',
code: '代码', code: '代码',
codeSupportTip: '只支持 Jinja2',
outputVars: { outputVars: {
output: '转换后内容', output: '转换后内容',
}, },
}, },
}, },
},
} }
export default translation export default translation
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment