update: toolkit 2.0.0

This commit is contained in:
windingwind 2023-02-07 22:56:00 +08:00
parent e2112995ad
commit 296f03944a
6 changed files with 23 additions and 13 deletions

10
.vscode/launch.json vendored
View File

@ -9,14 +9,20 @@
"request": "launch", "request": "launch",
"name": "Restart", "name": "Restart",
"runtimeExecutable": "npm", "runtimeExecutable": "npm",
"runtimeArgs": ["run", "restart"], "runtimeArgs": [
"run",
"restart"
],
}, },
{ {
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"name": "Restart in Prod Mode", "name": "Restart in Prod Mode",
"runtimeExecutable": "npm", "runtimeExecutable": "npm",
"runtimeArgs": ["run", "restart-prod"], "runtimeArgs": [
"run",
"restart-prod"
],
} }
] ]
} }

View File

@ -37,7 +37,7 @@
}, },
"homepage": "https://github.com/windingwind/zotero-addon-template#readme", "homepage": "https://github.com/windingwind/zotero-addon-template#readme",
"dependencies": { "dependencies": {
"zotero-plugin-toolkit": "^1.1.1" "zotero-plugin-toolkit": "^2.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^18.11.17", "@types/node": "^18.11.17",
@ -51,4 +51,4 @@
"typescript": "^4.9.4", "typescript": "^4.9.4",
"zotero-types": "^1.0.6" "zotero-types": "^1.0.6"
} }
} }

View File

@ -130,7 +130,7 @@ function onShortcuts(type: string) {
KeyExampleFactory.exampleShortcutSmallerCallback(); KeyExampleFactory.exampleShortcutSmallerCallback();
break; break;
case "confliction": case "confliction":
KeyExampleFactory.exampleShortcutConflictionCallback(); KeyExampleFactory.exampleShortcutConflictingCallback();
break; break;
default: default:
break; break;

View File

@ -17,6 +17,10 @@ if (!basicTool.getGlobal("Zotero")[config.addonInstance]) {
ztoolkit.basicOptions.log.disableConsole = addon.data.env === "production"; ztoolkit.basicOptions.log.disableConsole = addon.data.env === "production";
ztoolkit.UI.basicOptions.ui.enableElementJSONLog = ztoolkit.UI.basicOptions.ui.enableElementJSONLog =
addon.data.env === "development"; addon.data.env === "development";
ztoolkit.UI.basicOptions.ui.enableElementDOMLog =
addon.data.env === "development";
ztoolkit.basicOptions.debug.disableDebugBridgePassword =
addon.data.env === "development";
Zotero[config.addonInstance] = addon; Zotero[config.addonInstance] = addon;
// Trigger addon hook for initialization // Trigger addon hook for initialization
addon.hooks.onStartup(); addon.hooks.onStartup();

View File

@ -165,16 +165,16 @@ export class KeyExampleFactory {
} }
@example @example
static exampleShortcutConflictionCallback() { static exampleShortcutConflictingCallback() {
const conflictionGroups = ztoolkit.Shortcut.checkAllKeyConfliction(); const conflictingGroups = ztoolkit.Shortcut.checkAllKeyConflicting();
new ztoolkit.ProgressWindow("Check Key Confliction") new ztoolkit.ProgressWindow("Check Key Conflicting")
.createLine({ .createLine({
text: `${conflictionGroups.length} groups of confliction keys found. Details are in the debug output/console.`, text: `${conflictingGroups.length} groups of conflicting keys found. Details are in the debug output/console.`,
}) })
.show(-1); .show(-1);
ztoolkit.log( ztoolkit.log(
"Conflictions:", "Conflicting:",
conflictionGroups, conflictingGroups,
"All keys:", "All keys:",
ztoolkit.Shortcut.getAll() ztoolkit.Shortcut.getAll()
); );
@ -667,7 +667,7 @@ export class HelperExampleFactory {
@example @example
static clipboardExample() { static clipboardExample() {
new ztoolkit.Clibpoard() new ztoolkit.Clipboard()
.addText( .addText(
"![Plugin Template](https://github.com/windingwind/zotero-plugin-template)", "![Plugin Template](https://github.com/windingwind/zotero-plugin-template)",
"text/unicode" "text/unicode"

View File

@ -46,7 +46,7 @@ async function updatePrefsUI() {
// with addon.data.prefs.window.document // with addon.data.prefs.window.document
// Or bind some events to the elements // Or bind some events to the elements
const renderLock = ztoolkit.getGlobal("Zotero").Promise.defer(); const renderLock = ztoolkit.getGlobal("Zotero").Promise.defer();
const tableHelper = new ztoolkit.VirtualizedTabel(addon.data.prefs?.window!) const tableHelper = new ztoolkit.VirtualizedTable(addon.data.prefs?.window!)
.setContainerId(`${config.addonRef}-table-container`) .setContainerId(`${config.addonRef}-table-container`)
.setProp({ .setProp({
id: `${config.addonRef}-prefs-table`, id: `${config.addonRef}-prefs-table`,