This commit is contained in:
Sidharth Vinod
2021-06-02 23:42:24 +05:30
parent e2c2eb03ba
commit 6a0d3e4b89
+14 -4
View File
@@ -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();