chore: code generator button should only display in code node (#9842)

This commit is contained in:
非法操作 2024-10-25 15:00:12 +08:00 committed by GitHub
parent 1b5adf40da
commit 84a9d2d072
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 3 deletions

View File

@ -29,6 +29,7 @@ type Props = {
codeLanguages: CodeLanguage codeLanguages: CodeLanguage
fileList?: FileEntity[] fileList?: FileEntity[]
showFileList?: boolean showFileList?: boolean
showCodeGenerator?: boolean
} }
const Base: FC<Props> = ({ const Base: FC<Props> = ({
@ -44,6 +45,7 @@ const Base: FC<Props> = ({
codeLanguages, codeLanguages,
fileList = [], fileList = [],
showFileList, showFileList,
showCodeGenerator = false,
}) => { }) => {
const ref = useRef<HTMLDivElement>(null) const ref = useRef<HTMLDivElement>(null)
const { const {
@ -76,9 +78,11 @@ const Base: FC<Props> = ({
e.stopPropagation() e.stopPropagation()
}}> }}>
{headerRight} {headerRight}
<div className='ml-1'> {showCodeGenerator && (
<CodeGeneratorButton onGenerated={onGenerated} codeLanguages={codeLanguages}/> <div className='ml-1'>
</div> <CodeGeneratorButton onGenerated={onGenerated} codeLanguages={codeLanguages}/>
</div>
)}
{!isCopied {!isCopied
? ( ? (
<Clipboard className='mx-1 w-3.5 h-3.5 text-gray-500 cursor-pointer' onClick={handleCopy} /> <Clipboard className='mx-1 w-3.5 h-3.5 text-gray-500 cursor-pointer' onClick={handleCopy} />

View File

@ -31,6 +31,7 @@ export type Props = {
noWrapper?: boolean noWrapper?: boolean
isExpand?: boolean isExpand?: boolean
showFileList?: boolean showFileList?: boolean
showCodeGenerator?: boolean
} }
export const languageMap = { export const languageMap = {
@ -63,6 +64,7 @@ const CodeEditor: FC<Props> = ({
noWrapper, noWrapper,
isExpand, isExpand,
showFileList, showFileList,
showCodeGenerator = false,
}) => { }) => {
const [isFocus, setIsFocus] = React.useState(false) const [isFocus, setIsFocus] = React.useState(false)
const [isMounted, setIsMounted] = React.useState(false) const [isMounted, setIsMounted] = React.useState(false)
@ -207,6 +209,7 @@ const CodeEditor: FC<Props> = ({
codeLanguages={language} codeLanguages={language}
fileList={fileList} fileList={fileList}
showFileList={showFileList} showFileList={showFileList}
showCodeGenerator={showCodeGenerator}
> >
{main} {main}
</Base> </Base>

View File

@ -92,6 +92,7 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
language={inputs.code_language} language={inputs.code_language}
value={inputs.code} value={inputs.code}
onChange={handleCodeChange} onChange={handleCodeChange}
showCodeGenerator={true}
/> />
</div> </div>
<Split /> <Split />