fix(ui): ensure Monaco editor CSS loads
This commit is contained in:
@@ -51,6 +51,20 @@ function ensureLoaderScript(): Promise<void> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ensureEditorCss(): void {
|
||||||
|
if (typeof document === "undefined") return
|
||||||
|
const existing = document.querySelector('link[data-monaco-editor-css="true"]')
|
||||||
|
if (existing) return
|
||||||
|
|
||||||
|
// Some environments don't reliably load `vs/css!` plugin resources.
|
||||||
|
// Loading the core stylesheet explicitly keeps Monaco visible.
|
||||||
|
const link = document.createElement("link")
|
||||||
|
link.rel = "stylesheet"
|
||||||
|
link.href = `${LOCAL_VS_ROOT}/editor/editor.main.css`
|
||||||
|
;(link as any).dataset.monacoEditorCss = "true"
|
||||||
|
document.head.appendChild(link)
|
||||||
|
}
|
||||||
|
|
||||||
function configureWorkers() {
|
function configureWorkers() {
|
||||||
const globalAny = globalThis as any
|
const globalAny = globalThis as any
|
||||||
const prevEnv = globalAny.MonacoEnvironment ?? {}
|
const prevEnv = globalAny.MonacoEnvironment ?? {}
|
||||||
@@ -140,6 +154,7 @@ export async function loadMonaco(): Promise<MonacoApi> {
|
|||||||
monacoPromise = (async () => {
|
monacoPromise = (async () => {
|
||||||
await ensureLoaderScript()
|
await ensureLoaderScript()
|
||||||
configureWorkers()
|
configureWorkers()
|
||||||
|
ensureEditorCss()
|
||||||
|
|
||||||
const online = await canReachCdn()
|
const online = await canReachCdn()
|
||||||
const requireConfig = getRequireConfig()
|
const requireConfig = getRequireConfig()
|
||||||
|
|||||||
Reference in New Issue
Block a user