Skip to content

Commit 0e5b4a4

Browse files
committed
fix: style for esm
1 parent b4c4201 commit 0e5b4a4

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/monaco-editor/monaco-loader.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,31 @@ function setAllValidations(
109109
/** Load the Monaco editor. */
110110
async function loadMonacoFromEsmCdn(): Promise<Monaco> {
111111
let error = new Error();
112-
const urlList = ["https://cdn.jsdelivr.net/npm/monaco-editor/+esm"];
112+
const urlList = [
113+
{
114+
script: "https://cdn.jsdelivr.net/npm/monaco-editor/+esm",
115+
style: "https://cdn.jsdelivr.net/npm/monaco-editor/min/vs/style.min.css",
116+
},
117+
];
113118

114119
if (typeof monacoVersion !== "undefined") {
115-
urlList.unshift(
116-
`https://cdn.jsdelivr.net/npm/monaco-editor@${monacoVersion}/+esm`,
117-
);
120+
urlList.unshift({
121+
script: `https://cdn.jsdelivr.net/npm/monaco-editor@${monacoVersion}/+esm`,
122+
style: `https://cdn.jsdelivr.net/npm/monaco-editor@${
123+
monacoVersion
124+
}/min/vs/style.min.css`,
125+
});
118126
}
119127
for (const url of urlList) {
120128
try {
121-
const result = await importFromCDN(url);
129+
const result = await importFromCDN(url.script);
130+
131+
if (typeof document !== "undefined") {
132+
const link = document.createElement("link");
133+
link.rel = "stylesheet";
134+
link.href = url.style;
135+
document.head.append(link);
136+
}
122137
return result as Monaco;
123138
} catch (e: unknown) {
124139
// eslint-disable-next-line no-console -- OK

0 commit comments

Comments
 (0)