Add bridgeCommand helper function
This commit is contained in:
parent
5a987d77b2
commit
5abd7ae6f3
@ -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;
|
||||
|
@ -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<T>(command: string, callback?: (value: T) => void): void;
|
||||
}
|
||||
}
|
||||
|
||||
/// HTML <a> tag pointing to a bridge command.
|
||||
export function bridgeLink(command: string, label: string): string {
|
||||
return `<a href="javascript:bridgeCommand('${command}')">${label}</a>`;
|
||||
}
|
||||
|
||||
export function bridgeCommand<T>(command: string, callback?: (value: T) => void): void {
|
||||
window.bridgeCommand<T>(command, callback);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user