Finish Playground
This commit is contained in:
@@ -64,10 +64,10 @@ const FileSelector: React.FC<FileSelectorProps> = ({
|
||||
}
|
||||
|
||||
const handleOnCancel = () => {
|
||||
onError?.('')
|
||||
if (!creating) {
|
||||
return
|
||||
}
|
||||
|
||||
tabs.pop()
|
||||
setTabs([...tabs])
|
||||
setCreating(false)
|
||||
@@ -111,7 +111,10 @@ const FileSelector: React.FC<FileSelectorProps> = ({
|
||||
return false
|
||||
}
|
||||
|
||||
if (tabs.includes(newFileName) && newFileName !== oldFileName) {
|
||||
if (
|
||||
tabs.map((item) => item.toLowerCase()).includes(newFileName.toLowerCase()) &&
|
||||
newFileName.toLowerCase() !== oldFileName.toLowerCase()
|
||||
) {
|
||||
onError?.(`File "${newFileName}" already exists.`)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
[data-component=playground-code-editor] {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
.playground-code-editor-message {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
color: white;
|
||||
background-color: #FF4D4FAA;
|
||||
padding: 5px 10px;
|
||||
font-size: 1.6em;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import _ from 'lodash'
|
||||
import '@/components/Playground/CodeEditor/code-editor.scss'
|
||||
import { IEditorOptions, IFiles, ITheme } from '@/components/Playground/shared'
|
||||
import {
|
||||
ENTRY_FILE_NAME,
|
||||
fileNameToLanguage,
|
||||
getFileNameList,
|
||||
IMPORT_MAP_FILE_NAME
|
||||
@@ -44,7 +43,7 @@ const CodeEditor: React.FC<CodeEditorProps> = ({
|
||||
...props
|
||||
}) => {
|
||||
const filteredFilesName = getFileNameList(files).filter(
|
||||
(item) => ![IMPORT_MAP_FILE_NAME, ENTRY_FILE_NAME].includes(item) && !files[item].hidden
|
||||
(item) => ![IMPORT_MAP_FILE_NAME].includes(item) && !files[item].hidden
|
||||
)
|
||||
const propsSelectedFileName =
|
||||
props.selectedFileName || (filteredFilesName.length ? filteredFilesName[0] : '')
|
||||
@@ -148,7 +147,7 @@ const CodeEditor: React.FC<CodeEditorProps> = ({
|
||||
onChange={handleOnChangeFileContent}
|
||||
onJumpFile={handleOnChangeSelectedFile}
|
||||
/>
|
||||
{errorMsg && <div className={'playground-code-editor-message'}>{errorMsg}</div>}
|
||||
{errorMsg && <div className={'playground-error-message'}>{errorMsg}</div>}
|
||||
</FlexBox>
|
||||
</>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user