mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
Use async functions in .svelte files (#1693)
* Use async functions in CodeMirror.svelte
* Fix using async functions by modifying svelte-preprocess output
* Revert "Fix using async functions by modifying svelte-preprocess output"
This reverts commit 94c9cadaaa
.
Trying a different fix.
* Change TypeScript target to ES2019
This commit is contained in:
parent
6941bccde4
commit
92bf23df99
2 changed files with 12 additions and 12 deletions
|
@ -40,11 +40,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
/**
|
/**
|
||||||
* Convenience function for editor.setOption.
|
* Convenience function for editor.setOption.
|
||||||
*/
|
*/
|
||||||
function setOption<T extends keyof CodeMirrorLib.EditorConfiguration>(
|
async function setOption<T extends keyof CodeMirrorLib.EditorConfiguration>(
|
||||||
key: T,
|
key: T,
|
||||||
value: CodeMirrorLib.EditorConfiguration[T],
|
value: CodeMirrorLib.EditorConfiguration[T],
|
||||||
): void {
|
): Promise<void> {
|
||||||
editorPromise.then((editor) => editor.setOption(key, value));
|
const editor = await editorPromise;
|
||||||
|
editor.setOption(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const direction = getContext<Writable<"ltr" | "rtl">>(directionKey);
|
const direction = getContext<Writable<"ltr" | "rtl">>(directionKey);
|
||||||
|
@ -62,14 +63,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
onMount(() =>
|
onMount(async () => {
|
||||||
editorPromise.then((editor) => {
|
const editor = await editorPromise;
|
||||||
setupCodeMirror(editor, code);
|
setupCodeMirror(editor, code);
|
||||||
editor.on("change", () => dispatch("change", editor.getValue()));
|
editor.on("change", () => dispatch("change", editor.getValue()));
|
||||||
editor.on("focus", () => dispatch("focus"));
|
editor.on("focus", () => dispatch("focus"));
|
||||||
editor.on("blur", () => dispatch("blur"));
|
editor.on("blur", () => dispatch("blur"));
|
||||||
}),
|
});
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="code-mirror">
|
<div class="code-mirror">
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"composite": true,
|
"composite": true,
|
||||||
"target": "es6",
|
"target": "es2019",
|
||||||
"module": "es2020",
|
"module": "es2020",
|
||||||
"lib": [
|
"lib": [
|
||||||
"es2017",
|
"es2017",
|
||||||
|
|
Loading…
Reference in a new issue