update: ztoolkit v3

This commit is contained in:
windingwind 2024-09-08 16:52:27 +02:00
parent 73b4765069
commit 887d71487e
5 changed files with 10 additions and 17 deletions

8
package-lock.json generated
View File

@ -35,7 +35,7 @@
"unist-util-visit": "^5.0.0",
"unist-util-visit-parents": "^6.0.1",
"yamljs": "^0.3.0",
"zotero-plugin-toolkit": "^2.3.37"
"zotero-plugin-toolkit": "^3.0.2"
},
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
@ -14400,9 +14400,9 @@
}
},
"node_modules/zotero-plugin-toolkit": {
"version": "2.3.37",
"resolved": "https://registry.npmjs.org/zotero-plugin-toolkit/-/zotero-plugin-toolkit-2.3.37.tgz",
"integrity": "sha512-C1e9o+pWR8vPJQaGpHPDKEsWcTJwjef90vX+kQQ6aDlXYNomhtHNXHmweIQWoufNQz26wQQkFFU1zkvIQ4Ff6A==",
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/zotero-plugin-toolkit/-/zotero-plugin-toolkit-3.0.2.tgz",
"integrity": "sha512-99WKlyBRt1bMj+4w7ZY6mMsrHJiuTfOtM9ev2U2qUb8qK8x4/050H7jq7dR0B53udPY95G3IIwXn18LQdylGnw==",
"dependencies": {
"zotero-types": "^2.0.3"
}

View File

@ -56,7 +56,7 @@
"unist-util-visit": "^5.0.0",
"unist-util-visit-parents": "^6.0.1",
"yamljs": "^0.3.0",
"zotero-plugin-toolkit": "^2.3.37"
"zotero-plugin-toolkit": "^3.0.2"
},
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",

View File

@ -25,9 +25,10 @@ async function note2mm(
};
let lines: string[] = [];
if (options.withContent) {
const doc = ztoolkit
.getDOMParser()
.parseFromString(await renderNoteHTML(noteItem), "text/html");
const doc = new DOMParser().parseFromString(
await renderNoteHTML(noteItem),
"text/html",
);
textNodeForEach(doc.body, (e: Text) => {
e.data = htmlEscape(doc, e.data);
});

View File

@ -94,9 +94,7 @@ export function getLinkedNotesRecursively(
if (ignoreIds.includes(noteItem.id)) {
return [];
}
const doc = ztoolkit
.getDOMParser()
.parseFromString(noteItem.getNote(), "text/html");
const doc = new DOMParser().parseFromString(noteItem.getNote(), "text/html");
const links = Array.from(doc.querySelectorAll("a"));
return links.reduce(
(acc, link) => {

View File

@ -34,18 +34,14 @@ import { DialogHelper } from "zotero-plugin-toolkit/dist/helpers/dialog";
import { FilePickerHelper } from "zotero-plugin-toolkit/dist/helpers/filePicker";
import { ProgressWindowHelper } from "zotero-plugin-toolkit/dist/helpers/progressWindow";
import { VirtualizedTableHelper } from "zotero-plugin-toolkit/dist/helpers/virtualizedTable";
import { LibraryTabPanelManager } from "zotero-plugin-toolkit/dist/managers/libraryTabPanel";
import { MenuManager } from "zotero-plugin-toolkit/dist/managers/menu";
import { PromptManager } from "zotero-plugin-toolkit/dist/managers/prompt";
import { ReaderTabPanelManager } from "zotero-plugin-toolkit/dist/managers/readerTabPanel";
import { LargePrefHelper } from "zotero-plugin-toolkit/dist/helpers/largePref";
import { GuideHelper } from "zotero-plugin-toolkit/dist/helpers/guide";
class MyToolkit extends BasicTool {
UI: UITool;
Prompt: PromptManager;
LibraryTabPanel: LibraryTabPanelManager;
ReaderTabPanel: ReaderTabPanelManager;
Menu: MenuManager;
Clipboard: typeof ClipboardHelper;
FilePicker: typeof FilePickerHelper;
@ -59,8 +55,6 @@ class MyToolkit extends BasicTool {
super();
this.UI = new UITool(this);
this.Prompt = new PromptManager(this);
this.LibraryTabPanel = new LibraryTabPanelManager(this);
this.ReaderTabPanel = new ReaderTabPanelManager(this);
this.Menu = new MenuManager(this);
this.Clipboard = ClipboardHelper;
this.FilePicker = FilePickerHelper;