update: zotero-types 2.0.0

This commit is contained in:
windingwind 2024-05-06 21:14:22 +08:00
parent 271229d6fe
commit ea730e6947
10 changed files with 12 additions and 15 deletions

View File

@ -90,7 +90,7 @@
"replace-in-file": "^7.0.2",
"typescript": "^5.3.3",
"xslt3": "^2.6.0",
"zotero-types": "^1.3.24"
"zotero-types": "^2.0.0"
},
"eslintConfig": {
"env": {

View File

@ -1,4 +1,4 @@
import details from "../package.json" assert { type: "json" };
import details from "../package.json" with { type: "json" };
import {
Logger,
clearFolder,

View File

@ -13,7 +13,7 @@ export class PluginCEBase extends XULElementBase {
}
this.attachShadow({ mode: "open" });
// Following the connectedCallback from XULElementBase
let content = this.content;
let content: Node = this.content;
if (content) {
content = document.importNode(content, true);
this.shadowRoot?.append(content);
@ -21,9 +21,7 @@ export class PluginCEBase extends XULElementBase {
MozXULElement.insertFTLIfNeeded("branding/brand.ftl");
MozXULElement.insertFTLIfNeeded("zotero.ftl");
// @ts-ignore
if (document.l10n && this.shadowRoot) {
// @ts-ignore
document.l10n.connectRoot(this.shadowRoot);
}

View File

@ -136,7 +136,6 @@ export class NotePicker extends PluginCEBase {
}
loadQuickSearch() {
// @ts-ignore
const searchBox = document.createXULElement("quick-search-textbox");
searchBox.id = "zotero-tb-search";
searchBox.setAttribute("timeout", "250");
@ -146,6 +145,7 @@ export class NotePicker extends PluginCEBase {
searchBox,
);
// @ts-ignore
searchBox.updateMode();
}

View File

@ -12,7 +12,7 @@ import { OutboundCreator } from "../elements/linkCreator/outboundCreator";
const elements = {
"bn-context": ContextPane,
"bn-outline": OutlinePane,
"bn-details": DetailsPane as unknown as CustomElementConstructor,
"bn-details": DetailsPane,
"bn-workspace": Workspace,
"bn-note-picker": NotePicker,
"bn-note-outline": OutlinePicker,
@ -20,7 +20,7 @@ const elements = {
"bn-inbound-creator": InboundCreator,
"bn-outbound-creator": OutboundCreator,
"bn-related-box": NoteRelatedBox,
};
} as unknown as Record<string, CustomElementConstructor>;
for (const [key, constructor] of Object.entries(elements)) {
if (!customElements.get(key)) {

View File

@ -48,7 +48,6 @@ function init() {
window.resizeTo(Number(size[0] || "800"), Number(size[1] || "600"));
}, 0);
// @ts-ignore
io = window.arguments[0];
tabbox = document.querySelector("#top-container")!;

View File

@ -18,7 +18,6 @@ window.addEventListener("DOMContentLoaded", () => {
{ once: true },
);
// @ts-ignore
window.arguments[0]._initPromise.resolve();
});

View File

@ -16,6 +16,7 @@ export function registerNoteLinkProxyHandler() {
this.doAction(uri);
},
};
// @ts-ignore
Services.io.getProtocolHandler("zotero").wrappedJSObject._extensions[
"zotero://note"
] = openNoteExtension;

View File

@ -158,7 +158,7 @@ async function getMDStatus(
ret.filedir = formatPath(pathSplit.slice(0, -1).join("/"));
ret.filename = pathSplit.pop() || "";
const stat = await IOUtils.stat(filepath);
ret.lastmodify = new Date(stat.lastModified);
ret.lastmodify = new Date(stat.lastModified || 0);
}
} catch (e) {
ztoolkit.log(e);
@ -191,9 +191,9 @@ async function getMDFileName(noteId: number, searchDir?: string) {
entry.name.split(".").shift()?.split("-").pop() === noteItem.key
) {
const stat = await IOUtils.stat(entry.path);
if (stat.lastModified > matchedDate) {
if (stat.lastModified || 0 > matchedDate) {
matchedFileName = entry.name;
matchedDate = stat.lastModified;
matchedDate = stat.lastModified || 0;
}
}
}

View File

@ -5,9 +5,9 @@ function isWindowAlive(win?: Window) {
}
function getFocusedWindow() {
const wins = Services.wm.getEnumerator(null) as Window[];
const wins = Services.wm.getEnumerator("") as unknown as Window[];
for (const win of wins) {
if (win.document.hasFocus()) {
if (win.document?.hasFocus()) {
return win;
}
}