diff --git a/ts/editor/CodeMirror.svelte b/ts/editor/CodeMirror.svelte index 755365544..204d22161 100644 --- a/ts/editor/CodeMirror.svelte +++ b/ts/editor/CodeMirror.svelte @@ -40,11 +40,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html /** * Convenience function for editor.setOption. */ - function setOption( + async function setOption( key: T, value: CodeMirrorLib.EditorConfiguration[T], - ): void { - editorPromise.then((editor) => editor.setOption(key, value)); + ): Promise { + const editor = await editorPromise; + editor.setOption(key, value); } const direction = getContext>(directionKey); @@ -62,14 +63,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const dispatch = createEventDispatcher(); - onMount(() => - editorPromise.then((editor) => { - setupCodeMirror(editor, code); - editor.on("change", () => dispatch("change", editor.getValue())); - editor.on("focus", () => dispatch("focus")); - editor.on("blur", () => dispatch("blur")); - }), - ); + onMount(async () => { + const editor = await editorPromise; + setupCodeMirror(editor, code); + editor.on("change", () => dispatch("change", editor.getValue())); + editor.on("focus", () => dispatch("focus")); + editor.on("blur", () => dispatch("blur")); + });