Skip to content

Commit

Permalink
🚧 update toolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
volatile-static committed Sep 26, 2024
1 parent dd039c7 commit 5702b59
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 89 deletions.
141 changes: 72 additions & 69 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"tdesign-vue-next": "^1.10.1",
"vue": "^3.5.4",
"zotero-plugin-scaffold": "^0.1.4",
"zotero-plugin-toolkit": "^3.0.4"
"zotero-plugin-toolkit": "^4.0.1"
},
"devDependencies": {
"@gitee/typescript-sdk-v5": "^5.4.85",
Expand Down
19 changes: 11 additions & 8 deletions src/bootstrap/addon.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import * as toolBase from 'zotero-plugin-toolkit/dist/basic';
import { ExtraFieldTool } from 'zotero-plugin-toolkit/dist/tools/extraField';
import { MenuManager } from 'zotero-plugin-toolkit/dist/managers/menu';
import { PatchHelper } from 'zotero-plugin-toolkit/dist/helpers/patch';
import { UITool } from 'zotero-plugin-toolkit/dist/tools/ui';
import {
UITool,
ExtraFieldTool,
MenuManager,
PatchHelper,
BasicTool,
unregister
} from 'zotero-plugin-toolkit';
import { config, name as packageName } from '../../package.json';
import ReadingHistory from './modules/history/history';
import { onAddonLoad, onHistoryRecord, onItemSelect, onMainWindowLoad } from './events';
Expand All @@ -15,7 +18,7 @@ type DefaultPrefs = Omit<
excludedTags: number[];
};

export default class Addon extends toolBase.BasicTool {
export default class Addon extends BasicTool {
readonly extraField: ExtraFieldTool;
readonly ui: UITool;
readonly menu: MenuManager;
Expand Down Expand Up @@ -151,7 +154,7 @@ export default class Addon extends toolBase.BasicTool {
onMainWindowLoad(win);
} else {
onAddonLoad();
onMainWindowLoad(Zotero.getMainWindow() as unknown as MainWindow);
Zotero.getMainWindows().forEach(onMainWindowLoad);
}
} catch (error) {
this.log(error);
Expand All @@ -168,7 +171,7 @@ export default class Addon extends toolBase.BasicTool {
);
(Zotero.getActiveZoteroPane().itemsView as any).onSelect.removeListener(onItemSelect);
await this.worker.close();
toolBase.unregister(this);
unregister(this);
}

async test(key: string) { // create a new file attachment
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { config } from '../../package.json';
import { addDebugMenu } from './modules/debug';
import { ICON_URL, DebuggerBackend } from './modules/utils';
import { waitForReader } from 'zotero-plugin-toolkit/dist/utils/wait';
import { waitForReader } from 'zotero-plugin-toolkit/dist/utils/wait.js';
import { mountMinimap, updateMinimap } from './modules/minimap/minimap';
import { registerPanels, renderSummaryPanel, updateDashboard } from './modules/sidebar';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/modules/global.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BasicTool } from "zotero-plugin-toolkit/dist/basic";
import { BasicTool } from "zotero-plugin-toolkit";

const basicTool = new BasicTool();
export const G = basicTool.getGlobal;
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/modules/history/history.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BasicTool, BasicOptions, ManagerTool } from "zotero-plugin-toolkit/dist/basic";
import { BasicTool, BasicOptions, ManagerTool } from "zotero-plugin-toolkit";
import { AttachmentRecord, PageRecord } from "./data";
import { name as packageName } from "../../../../package.json";

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/modules/images/components.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClipboardHelper } from 'zotero-plugin-toolkit/dist/helpers/clipboard';
import { ClipboardHelper } from 'zotero-plugin-toolkit';
import { React } from '../global';

const ReaderContext = React.createContext<(position: _ZoteroTypes.Reader.PDFPosition) => void>(() => {});
Expand Down
10 changes: 5 additions & 5 deletions src/bootstrap/modules/images/images.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TagElementProps } from 'zotero-plugin-toolkit/dist/tools/ui';
import { ClipboardHelper } from 'zotero-plugin-toolkit/dist/helpers/clipboard';
import type { TagElementProps } from 'zotero-plugin-toolkit';
import { ClipboardHelper } from 'zotero-plugin-toolkit';
import { isPDFReader, isEpubReader, isWebReader, PdfImageListener } from '../utils';
import { React, ReactDOM } from '../global';
import View, { type LoadedPages } from './components';
Expand Down Expand Up @@ -130,9 +130,9 @@ class PDFImages extends ReaderImages<'pdf'> {
addon.getGlobal('console').time('render' + pageNum + '-' + imgNum);
try {
const view = React.createElement(View, {
pages: this.loadedPages,
onNavigate: position => this.reader.navigate({ position }),
});
pages: this.loadedPages,
onNavigate: position => this.reader.navigate({ position }),
});
ReactDOM.render(view, this.imagesView);
} catch (error) {
addon.log(error);
Expand Down
3 changes: 1 addition & 2 deletions src/bootstrap/modules/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ClipboardHelper } from 'zotero-plugin-toolkit/dist/helpers/clipboard';
import { FilePickerHelper } from 'zotero-plugin-toolkit/dist/helpers/filePicker';
import { ClipboardHelper, FilePickerHelper } from 'zotero-plugin-toolkit';
import { WorkerManagerBase, WorkerRequest, WorkerResponse } from '../../worker/manager';

export const ICON_URL = 'resource://chartero/icons/icon.svg';
Expand Down

0 comments on commit 5702b59

Please sign in to comment.