Optimize CodeEditor

This commit is contained in:
2024-01-22 16:06:09 +08:00
parent 3a973a3c93
commit 8a954abedf
3 changed files with 6 additions and 4 deletions

View File

@@ -48,7 +48,8 @@ const Editor = ({
tsconfig.compilerOptions tsconfig.compilerOptions
) )
files && if (files) {
monaco.editor.getModels().forEach((model) => model.dispose())
Object.entries(files).forEach(([key]) => { Object.entries(files).forEach(([key]) => {
if (!monaco.editor.getModel(monaco.Uri.parse(`file:///${key}`))) { if (!monaco.editor.getModel(monaco.Uri.parse(`file:///${key}`))) {
monaco.editor.createModel( monaco.editor.createModel(
@@ -58,6 +59,7 @@ const Editor = ({
) )
} }
}) })
}
} }
const handleOnEditorDidMount = (editor: editor.IStandaloneCodeEditor, monaco: Monaco) => { const handleOnEditorDidMount = (editor: editor.IStandaloneCodeEditor, monaco: Monaco) => {

View File

@@ -49,7 +49,6 @@ export const base64ToFiles = (base64: string): IFiles => {
try { try {
return JSON.parse(base64ToStr(base64)) as IFiles return JSON.parse(base64ToStr(base64)) as IFiles
} catch (e) { } catch (e) {
console.error(e)
return {} return {}
} }
} }

View File

@@ -139,6 +139,7 @@
}, },
"jsx": { "jsx": {
"description": "Specify what JSX code is generated.", "description": "Specify what JSX code is generated.",
"type": "number",
"enum": [0, 1, 2, 3, 4, 5], "enum": [0, 1, 2, 3, 4, 5],
"markdownDescription": "Specify what JSX code is generated.\n\n0 = none\n\n1 = preserve\n\n2 = react\n\n3 = react-native\n\n4 = react-jsx\n\n5 = react-jsxdev" "markdownDescription": "Specify what JSX code is generated.\n\n0 = none\n\n1 = preserve\n\n2 = react\n\n3 = react-native\n\n4 = react-jsx\n\n5 = react-jsxdev"
}, },
@@ -316,7 +317,7 @@
}, },
"newLine": { "newLine": {
"description": "Set the newline character for emitting files.", "description": "Set the newline character for emitting files.",
"type": "string", "type": "number",
"enum": [0, 1], "enum": [0, 1],
"markdownDescription": "Set the newline character for emitting files.\n\n0 = CarriageReturnLineFeed\n\n1 = LineFeed" "markdownDescription": "Set the newline character for emitting files.\n\n0 = CarriageReturnLineFeed\n\n1 = LineFeed"
}, },
@@ -558,7 +559,7 @@
"target": { "target": {
"description": "Set the JavaScript language version for emitted JavaScript and include compatible library declarations.", "description": "Set the JavaScript language version for emitted JavaScript and include compatible library declarations.",
"type": "number", "type": "number",
"default": "ES3", "default": 0,
"enum": [0, 1, 2, 3, 4, 5, 6, 7, 99, 100, 99], "enum": [0, 1, 2, 3, 4, 5, 6, 7, 99, 100, 99],
"markdownDescription": "Set the JavaScript language version for emitted JavaScript and include compatible library declarations.\n\n0 = ES3\n\n1 = ES5\n\n2 = ES2015\n\n3 = ES2016\n\n4 = ES2017\n\n5 = ES2018\n\n6 = ES2019\n\n7 = ES2020\n\n99 = ESNext\n\n100 = JSON\n\n99 = Latest" "markdownDescription": "Set the JavaScript language version for emitted JavaScript and include compatible library declarations.\n\n0 = ES3\n\n1 = ES5\n\n2 = ES2015\n\n3 = ES2016\n\n4 = ES2017\n\n5 = ES2018\n\n6 = ES2019\n\n7 = ES2020\n\n99 = ESNext\n\n100 = JSON\n\n99 = Latest"
}, },