mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
33 lines
997 B
TypeScript
33 lines
997 B
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
import { get } from "svelte/store";
|
|
|
|
import { addOrUpdateNote } from "../add-or-update-note.svelte";
|
|
import type { IOMode } from "../lib";
|
|
import { hideAllGuessOne } from "../store";
|
|
import type { PageLoad } from "./$types";
|
|
|
|
async function save(): Promise<void> {
|
|
addOrUpdateNote(globalThis["anki"].imageOcclusion.mode, get(hideAllGuessOne));
|
|
}
|
|
|
|
export const load = (async ({ params }) => {
|
|
let mode: IOMode;
|
|
if (/^\d+/.test(params.imagePathOrNoteId)) {
|
|
mode = { kind: "edit", noteId: BigInt(params.imagePathOrNoteId) };
|
|
} else {
|
|
mode = { kind: "add", imagePath: params.imagePathOrNoteId, notetypeId: 0n };
|
|
}
|
|
|
|
// for adding note from mobile devices
|
|
globalThis.anki = globalThis.anki || {};
|
|
globalThis.anki.imageOcclusion = {
|
|
mode,
|
|
save,
|
|
};
|
|
|
|
return {
|
|
mode,
|
|
};
|
|
}) satisfies PageLoad;
|