Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Jun 2, 2021
1 parent e2c2eb0 commit 6a0d3e4
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/lib/components/editor/editor.svelte
Expand Up @@ -35,12 +35,22 @@
}
const dispatch = createEventDispatcher<EditorEvents>();
const loadMonaco = async () => {
let i = 0;
while (i++ < 10) {
try {
//@ts-ignore : This is a hack to handle a svelte-kit error when importing monaco.
Monaco = monaco;
return;
} catch {
await new Promise((r) => setTimeout(r, 500));
}
}
alert('Loading Monaco Editor failed. Please try refreshing the page.');
};
onMount(async () => {
//@ts-ignore : This is a hack to handle a svelte-kit error when importing monaco.
Monaco = monaco;
await loadMonaco(); // Fix https://github.com/mermaid-js/mermaid-live-editor/issues/175
initEditor(Monaco);
editor = Monaco.editor.create(divEl, editorOptions);
editor.onDidChangeModelContent(() => {
text = editor.getValue();
Expand Down

0 comments on commit 6a0d3e4

Please sign in to comment.