Optimize Playground

This commit is contained in:
2024-01-19 18:28:53 +08:00
parent 343152c9d3
commit f3dc9d0e4f
4 changed files with 38 additions and 13 deletions

View File

@@ -13,6 +13,7 @@ import Editor from '@/components/Playground/CodeEditor/Editor'
interface CodeEditorProps {
theme?: ITheme
showFileSelector?: boolean
tsconfig?: ITsconfig
files: IFiles
readonly?: boolean
@@ -30,6 +31,7 @@ interface CodeEditorProps {
const CodeEditor = ({
theme,
showFileSelector = true,
tsconfig,
files,
readonly,
@@ -119,19 +121,21 @@ const CodeEditor = ({
return (
<>
<FlexBox data-component={'playground-code-editor'}>
<FileSelector
files={files}
readonly={readonly}
notRemovableFiles={notRemovable}
selectedFileName={
onSelectedFileChange ? propsSelectedFileName : selectedFileName
}
onChange={handleOnChangeSelectedFile}
onRemoveFile={handleOnRemoveFile}
onUpdateFileName={handleOnUpdateFileName}
onAddFile={handleOnAddFile}
onError={handleOnError}
/>
{showFileSelector && (
<FileSelector
files={files}
readonly={readonly}
notRemovableFiles={notRemovable}
selectedFileName={
onSelectedFileChange ? propsSelectedFileName : selectedFileName
}
onChange={handleOnChangeSelectedFile}
onRemoveFile={handleOnRemoveFile}
onUpdateFileName={handleOnUpdateFileName}
onAddFile={handleOnAddFile}
onError={handleOnError}
/>
)}
<Editor
tsconfig={tsconfig}
theme={theme}