mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00

* Restore $deckOptions * Avoid error in logs when using ./yarn dev or mobile clients (dae)
27 lines
805 B
TypeScript
27 lines
805 B
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
import { registerPackage } from "./runtime-require";
|
|
|
|
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 bridgeCommandsAvailable(): boolean {
|
|
return !!window.bridgeCommand;
|
|
}
|
|
|
|
export function bridgeCommand<T>(command: string, callback?: (value: T) => void): void {
|
|
window.bridgeCommand<T>(command, callback);
|
|
}
|
|
|
|
registerPackage("anki/bridgecommand", {
|
|
bridgeCommand,
|
|
});
|