update: make toolkit accessible

This commit is contained in:
xiangyu 2023-01-06 14:47:49 +08:00
parent f87cdfa1ef
commit d42abcbfcc
2 changed files with 5 additions and 2 deletions

View File

@ -1,3 +1,4 @@
import ZoteroToolkit from "zotero-plugin-toolkit";
import hooks from "./hooks";
class Addon {
@ -5,6 +6,7 @@ class Addon {
alive: boolean;
// Env type, see build.js
env: "development" | "production";
ztoolkit: ZoteroToolkit;
locale?: {
stringBundle: any;
};
@ -19,6 +21,7 @@ class Addon {
this.data = {
alive: true,
env: __env__,
ztoolkit: new ZoteroToolkit(),
};
this.hooks = hooks;
}

View File

@ -1,4 +1,4 @@
import ZoteroToolkit, { ZoteroCompat } from "zotero-plugin-toolkit";
import { ZoteroCompat } from "zotero-plugin-toolkit";
import Addon from "./addon";
import { config } from "../package.json";
@ -11,8 +11,8 @@ if (!compat.getGlobal("Zotero").AddonTemplate) {
_globalThis.Zotero_Tabs = compat.getGlobal("Zotero_Tabs");
_globalThis.window = compat.getGlobal("window");
_globalThis.document = compat.getGlobal("document");
_globalThis.ztoolkit = new ZoteroToolkit();
_globalThis.addon = new Addon();
_globalThis.ztoolkit = addon.data.ztoolkit;
ztoolkit.Tool.logOptionsGlobal.prefix = `[${config.addonName}]`;
ztoolkit.Tool.logOptionsGlobal.disableConsole =
addon.data.env === "production";