Feat(Editor): Support autoload Native API

This commit is contained in:
2024-10-15 16:44:50 +08:00
parent 2a32489617
commit 07f24333d9
2 changed files with 38 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import { IEditorOptions, IFiles, ITheme, ITsconfig } from '@/components/Playgrou
import { fileNameToLanguage, tsconfigJsonDiagnosticsOptions } from '@/components/Playground/files'
import { useEditor, useTypesProgress } from '@/components/Playground/CodeEditor/Editor/hooks'
import { MonacoEditorConfig } from '@/components/Playground/CodeEditor/Editor/monacoConfig'
import nativeApiDTS from '@/components/Playground/CodeEditor/Editor/_NativeApi.d.ts?raw'
interface EditorProps {
tsconfig?: ITsconfig
@@ -85,6 +86,10 @@ const Editor = ({
}
jsxSyntaxHighlightRef.current = loadJsxSyntaxHighlight(editor, monaco)
monaco.languages.typescript.typescriptDefaults.addExtraLib(
nativeApiDTS,
'file:///node_modules/_NativeApi.d.ts'
)
void autoLoadExtraLib(editor, monaco, file.value, onWatch)
}