diff --git a/ts/graphs/GraphsPage.svelte b/ts/graphs/GraphsPage.svelte index f26aae9fa..2597a09f0 100644 --- a/ts/graphs/GraphsPage.svelte +++ b/ts/graphs/GraphsPage.svelte @@ -8,6 +8,7 @@ import type pb from "anki/backend_proto"; import { getGraphData, RevlogRange, daysToRevlogRange } from "./graph-helpers"; import { getPreferences } from "./preferences"; + import { bridgeCommand } from "anki/bridgecommand"; export let i18n: I18n; export let nightMode: boolean; diff --git a/ts/lib/bridgecommand.ts b/ts/lib/bridgecommand.ts index b7a0f721b..927e7dd03 100644 --- a/ts/lib/bridgecommand.ts +++ b/ts/lib/bridgecommand.ts @@ -1,7 +1,17 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +declare global { + interface Window { + bridgeCommand(command: string, callback?: (value: T) => void): void; + } +} + /// HTML tag pointing to a bridge command. export function bridgeLink(command: string, label: string): string { return `${label}`; } + +export function bridgeCommand(command: string, callback?: (value: T) => void): void { + window.bridgeCommand(command, callback); +}