mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00

* Update to Svelte 5
* Fix `<tr> is invalid inside <table>`
* Update sveltekit-svg to match svelte version
Fixes deck options failing to load, and a bunch of warnings with
./yarn dev
* Fix graph tooltips
* Fix editor loading
* Fix MathJax editor not loading
* Formatting
* Fix new formatting errors
* Merge remote-tracking branch 'origin/main' into svelte5
* Remove slot inside EditorToolbar
I think this is just stray code left over from a refactor, but I'm
not 100% sure.
Fixes
Error: Object literal may only specify known properties, and 'children' does not exist in type '{ size: number; wrap: boolean; api?: Partial<EditorToolbarAPI> | undefined; }'. (ts)
<div class="note-editor">
<EditorToolbar {size} {wrap} api={toolbar}>
<slot slot="notetypeButtons" name="notetypeButtons" />
* Fix component typing error
* Comment out svelte/internal exports, so editor loads
* Fix image occlusions in editor
* Revert "Remove slot inside EditorToolbar"
This reverts commit b3095e07ac
,
which prevented the Preview button from showing in the browser.
This will break our tests again.
* Update vite
* Disable routes/tmp for now
* Fix references issue in routes/tmp
106 lines
2.7 KiB
Svelte
106 lines
2.7 KiB
Svelte
<!--
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
-->
|
|
<script lang="ts">
|
|
import type { OpChanges, Progress } from "@generated/anki/collection_pb";
|
|
import { runWithBackendProgress } from "@tslib/progress";
|
|
|
|
import { pageTheme } from "$lib/sveltelib/theme";
|
|
|
|
type ResultWithChanges = OpChanges | { changes?: OpChanges };
|
|
|
|
export let task: () => Promise<ResultWithChanges | undefined>;
|
|
export let result: ResultWithChanges | undefined;
|
|
export let error: Error | undefined;
|
|
let label: string = "";
|
|
|
|
function onUpdate(progress: Progress) {
|
|
if (
|
|
progress.value.value &&
|
|
progress.value.case !== "none" &&
|
|
label !== progress.value.value.toString()
|
|
) {
|
|
label = progress.value.value.toString();
|
|
}
|
|
}
|
|
$: (async () => {
|
|
if (!result && !error) {
|
|
try {
|
|
result = await runWithBackendProgress(task, onUpdate);
|
|
} catch (err) {
|
|
if (err instanceof Error) {
|
|
error = err;
|
|
} else {
|
|
throw err;
|
|
}
|
|
}
|
|
}
|
|
})();
|
|
</script>
|
|
|
|
<!-- spinner taken from https://loading.io/css/; CC0 -->
|
|
{#if !result}
|
|
<div class="progress">
|
|
<div class="spinner" class:nightMode={$pageTheme.isDark}>
|
|
<div></div>
|
|
<div></div>
|
|
<div></div>
|
|
<div></div>
|
|
</div>
|
|
<div id="label">{label}</div>
|
|
</div>
|
|
{/if}
|
|
|
|
<style lang="scss">
|
|
.progress {
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
}
|
|
|
|
.spinner {
|
|
display: block;
|
|
position: relative;
|
|
width: 80px;
|
|
height: 80px;
|
|
margin: 0 auto;
|
|
|
|
div {
|
|
display: block;
|
|
position: absolute;
|
|
width: 64px;
|
|
height: 64px;
|
|
margin: 8px;
|
|
border: 8px solid #000;
|
|
border-radius: 50%;
|
|
animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
|
border-color: #000 transparent transparent transparent;
|
|
}
|
|
&.nightMode div {
|
|
border-top-color: #fff;
|
|
}
|
|
div:nth-child(1) {
|
|
animation-delay: -0.45s;
|
|
}
|
|
div:nth-child(2) {
|
|
animation-delay: -0.3s;
|
|
}
|
|
div:nth-child(3) {
|
|
animation-delay: -0.15s;
|
|
}
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% {
|
|
transform: rotate(0deg);
|
|
}
|
|
100% {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
#label {
|
|
text-align: center;
|
|
}
|
|
</style>
|