Expose onUpdateHook/onShownHook via package

This commit is contained in:
Damien Elmes 2023-05-31 15:19:09 +10:00
parent 88f613aaf0
commit 1e00b7d4c4
2 changed files with 13 additions and 1 deletions

View file

@ -26,7 +26,8 @@ type AnkiPackages =
| "anki/theme"
| "anki/location"
| "anki/surround"
| "anki/ui";
| "anki/ui"
| "anki/reviewer";
type PackageDeprecation<T extends Record<string, unknown>> = {
[key in keyof T]?: string;
};

View file

@ -17,6 +17,7 @@ globalThis.anki.mutateNextCardStates = mutateNextCardStates;
globalThis.anki.setupImageCloze = setupImageCloze;
import { bridgeCommand } from "@tslib/bridgecommand";
import { registerPackage } from "@tslib/runtime-require";
import { allImagesLoaded, preloadAnswerImages } from "./images";
import { preloadResources } from "./preload";
@ -261,3 +262,13 @@ document.addEventListener("focusout", (event) => {
document.body.removeChild(dummyButton);
}
});
registerPackage("anki/reviewer", {
// If you append a function to this each time the question or answer
// is shown, it will be called before MathJax has been rendered.
onUpdateHook,
// If you append a function to this each time the question or answer
// is shown, it will be called after images have been preloaded and
// MathJax has been rendered.
onShownHook,
});