diff --git a/ts/lib/runtime-require.ts b/ts/lib/runtime-require.ts index e0832cf0b..af6acdb4d 100644 --- a/ts/lib/runtime-require.ts +++ b/ts/lib/runtime-require.ts @@ -26,7 +26,8 @@ type AnkiPackages = | "anki/theme" | "anki/location" | "anki/surround" - | "anki/ui"; + | "anki/ui" + | "anki/reviewer"; type PackageDeprecation> = { [key in keyof T]?: string; }; diff --git a/ts/reviewer/index.ts b/ts/reviewer/index.ts index 9ec947d81..7825f8472 100644 --- a/ts/reviewer/index.ts +++ b/ts/reviewer/index.ts @@ -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, +});