Skip to content

Commit 994a115

Browse files
authored
chore: wait monaco editor in playground (#761)
1 parent fd1cbd2 commit 994a115

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

explorer-v2/src/lib/scripts/monaco-loader.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,24 @@ export async function loadMonacoEditor() {
8484
(editorLoaded = new Promise((resolve) => {
8585
if (typeof window !== 'undefined') {
8686
// eslint-disable-next-line n/no-missing-require -- ignore
87-
window.require(['vs/editor/editor.main'], (r) => {
88-
resolve(r);
87+
window.require(['vs/editor/editor.main'], () => {
88+
waitForMonacoReady().then(() => resolve(window.monaco));
8989
});
9090
}
9191
}))
9292
);
9393
}
94+
95+
function waitForMonacoReady() {
96+
return new Promise((resolve) => {
97+
function check() {
98+
if (window.monaco && window.monaco.editor && window.monaco.editor.create) {
99+
resolve();
100+
return;
101+
}
102+
setTimeout(check, 0);
103+
}
104+
105+
check();
106+
});
107+
}

0 commit comments

Comments
 (0)