Skip to content

Commit

Permalink
Fix UI and Upgrade ztoolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenglongMa committed Feb 6, 2024
1 parent 9f0c243 commit 66d6cdb
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 29 deletions.
12 changes: 6 additions & 6 deletions addon/chrome/content/preferences.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
</linkset>
<vbox id="zotero-prefpane-__addonRef__" onload="Zotero.__addonInstance__.hooks.onPrefsEvent('load', {window})">

<label>
<html:h1>__addonName__</html:h1>
</label>
<!--<label>-->
<!-- <html:h1>__addonName__</html:h1>-->
<!--</label>-->
<vbox class="pref-section">
<groupbox>
<label>
<html:h1 data-l10n-id="pref-duplicate-detection-title"></html:h1>
</label>
<!-- <label>-->
<!-- <html:h1 data-l10n-id="pref-duplicate-detection-title"></html:h1>-->
<!-- </label>-->

<label>
<html:h2 data-l10n-id="pref-action-title"></html:h2>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"homepage": "https://chenglongma.com/zoplicate/",
"dependencies": {
"zotero-plugin-toolkit": "^2.3.16"
"zotero-plugin-toolkit": "^2.3.19"
},
"devDependencies": {
"@types/node": "^20.10.4",
Expand Down
3 changes: 1 addition & 2 deletions src/modules/preferenceScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { config, homepage } from "../../package.json";
import { getString } from "../utils/locale";

export function registerPrefs() {
ztoolkit.PreferencePane.register({
Zotero.PreferencePanes.register({
pluginID: config.addonID,
src: rootURI + "chrome/content/preferences.xhtml",
label: getString("prefs-title"),
image: `chrome://${config.addonRef}/content/icons/favicon.png`,
helpURL: homepage,
defaultXUL: true,
});
}

Expand Down
47 changes: 27 additions & 20 deletions src/utils/ztoolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { config } from "../../package.json";
export { createZToolkit };

function createZToolkit() {
const _ztoolkit = new ZoteroToolkit();
// const _ztoolkit = new ZoteroToolkit();
/**
* Alternatively, import toolkit modules you use to minify the plugin size.
* You can add the modules under the `MyToolkit` class below and uncomment the following line.
*/
// const _ztoolkit = new MyToolkit();
const _ztoolkit = new MyToolkit();
initZToolkit(_ztoolkit);
return _ztoolkit;
}
Expand All @@ -29,21 +29,28 @@ function initZToolkit(_ztoolkit: ReturnType<typeof createZToolkit>) {
);
}

// import { BasicTool, unregister } from "zotero-plugin-toolkit/dist/basic";
// import { UITool } from "zotero-plugin-toolkit/dist/tools/ui";
// import { PreferencePaneManager } from "zotero-plugin-toolkit/dist/managers/preferencePane";
//
// class MyToolkit extends BasicTool {
// UI: UITool;
// PreferencePane: PreferencePaneManager;
//
// constructor() {
// super();
// this.UI = new UITool(this);
// this.PreferencePane = new PreferencePaneManager(this);
// }
//
// unregisterAll() {
// unregister(this);
// }
// }
import {
BasicTool,
makeHelperTool,
unregister,
} from "zotero-plugin-toolkit/dist/basic";
import { UITool } from "zotero-plugin-toolkit/dist/tools/ui";
import { DialogHelper } from "zotero-plugin-toolkit/dist/helpers/dialog";
import { ProgressWindowHelper } from "zotero-plugin-toolkit/dist/helpers/progressWindow";

class MyToolkit extends BasicTool {
UI: UITool;
Dialog: typeof DialogHelper;
ProgressWindow: typeof ProgressWindowHelper;

constructor() {
super();
this.UI = new UITool(this);
this.ProgressWindow = makeHelperTool(ProgressWindowHelper, this);
this.Dialog = makeHelperTool(DialogHelper, this);
}

unregisterAll() {
unregister(this);
}
}

0 comments on commit 66d6cdb

Please sign in to comment.