mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Fix remaining errors in editor/*.svelte files
This commit is contained in:
parent
6081a02558
commit
cf38cb334e
3 changed files with 15 additions and 14 deletions
|
@ -6,11 +6,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import { onMount, createEventDispatcher, getContext } from "svelte";
|
import { onMount, createEventDispatcher, getContext } from "svelte";
|
||||||
import { nightModeKey } from "./contextKeys";
|
import { nightModeKey } from "./contextKeys";
|
||||||
|
|
||||||
export let id: string;
|
export let id: string | undefined = undefined;
|
||||||
let className = "";
|
let className = "";
|
||||||
export { className as class };
|
export { className as class };
|
||||||
|
|
||||||
export let tooltip: string;
|
export let tooltip: string | undefined = undefined;
|
||||||
|
|
||||||
let buttonRef: HTMLButtonElement;
|
let buttonRef: HTMLButtonElement;
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
<script lang="typescript" context="module">
|
<script lang="typescript" context="module">
|
||||||
import { writable } from "svelte/store";
|
import { writable } from "svelte/store";
|
||||||
|
|
||||||
type T = unknown;
|
type UpdaterMap = Map<string, (event: Event) => boolean>;
|
||||||
|
type StateMap = Map<string, boolean>;
|
||||||
type UpdaterMap = Map<string, (event: Event) => T>;
|
|
||||||
type StateMap = Map<string, T>;
|
|
||||||
|
|
||||||
const updaterMap = new Map() as UpdaterMap;
|
const updaterMap = new Map() as UpdaterMap;
|
||||||
const stateMap = new Map() as StateMap;
|
const stateMap = new Map() as StateMap;
|
||||||
const stateStore = writable(stateMap);
|
const stateStore = writable(stateMap);
|
||||||
|
|
||||||
function updateAllStateWithCallback(callback: (key: string) => T): void {
|
function updateAllStateWithCallback(callback: (key: string) => boolean): void {
|
||||||
stateStore.update(
|
stateStore.update(
|
||||||
(map: StateMap): StateMap => {
|
(map: StateMap): StateMap => {
|
||||||
const newMap = new Map() as StateMap;
|
const newMap = new Map() as StateMap;
|
||||||
|
@ -29,11 +27,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateAllState(event: Event): void {
|
export function updateAllState(event: Event): void {
|
||||||
updateAllStateWithCallback((key: string): T => updaterMap.get(key)!(event));
|
updateAllStateWithCallback((key: string): boolean =>
|
||||||
|
updaterMap.get(key)!(event)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resetAllState(state: T): void {
|
export function resetAllState(state: boolean): void {
|
||||||
updateAllStateWithCallback((): T => state);
|
updateAllStateWithCallback((): boolean => state);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateStateByKey(key: string, event: Event): void {
|
function updateStateByKey(key: string, event: Event): void {
|
||||||
|
@ -48,8 +48,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
<script lang="typescript">
|
<script lang="typescript">
|
||||||
export let key: string;
|
export let key: string;
|
||||||
export let update: (event: Event) => T;
|
export let update: (event: Event) => boolean;
|
||||||
export let state: T;
|
|
||||||
|
let state: boolean = false;
|
||||||
|
|
||||||
updaterMap.set(key, update);
|
updaterMap.set(key, update);
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"lib/*": ["../bazel-bin/ts/lib/*"],
|
"lib/*": ["../bazel-bin/ts/lib/*"],
|
||||||
"sveltelib/*": ["../bazel-bin/ts/sveltelib/*"],
|
|
||||||
"components/*": ["../bazel-bin/ts/components/*"],
|
|
||||||
"html-filter/*": ["../bazel-bin/ts/html-filter/*"]
|
"html-filter/*": ["../bazel-bin/ts/html-filter/*"]
|
||||||
|
/* "sveltelib/*": ["../bazel-bin/ts/sveltelib/*"], */
|
||||||
|
/* "components/*": ["../bazel-bin/ts/components/*"], */
|
||||||
},
|
},
|
||||||
"importsNotUsedAsValues": "error",
|
"importsNotUsedAsValues": "error",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
|
|
Loading…
Reference in a new issue