Skip to content

Commit

Permalink
update: zotero-types 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed May 6, 2024
1 parent 271229d commit ea730e6
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import details from "../package.json" assert { type: "json" };
import details from "../package.json" with { type: "json" };
import {
Logger,
clearFolder,
Expand Down
4 changes: 1 addition & 3 deletions src/elements/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ 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);
}

MozXULElement.insertFTLIfNeeded("branding/brand.ftl");
MozXULElement.insertFTLIfNeeded("zotero.ftl");
// @ts-ignore
if (document.l10n && this.shadowRoot) {
// @ts-ignore
document.l10n.connectRoot(this.shadowRoot);
}

Expand Down
2 changes: 1 addition & 1 deletion src/elements/linkCreator/notePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -146,6 +145,7 @@ export class NotePicker extends PluginCEBase {
searchBox,
);

// @ts-ignore
searchBox.updateMode();
}

Expand Down
4 changes: 2 additions & 2 deletions src/extras/customElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ 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,
"bn-note-preview": NotePreview,
"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)) {
Expand Down
1 change: 0 additions & 1 deletion src/extras/linkCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")!;
Expand Down
1 change: 0 additions & 1 deletion src/extras/workspaceWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ window.addEventListener("DOMContentLoaded", () => {
{ once: true },
);

// @ts-ignore
window.arguments[0]._initPromise.resolve();
});

Expand Down
1 change: 1 addition & 0 deletions src/modules/noteLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function registerNoteLinkProxyHandler() {
this.doAction(uri);
},
};
// @ts-ignore
Services.io.getProtocolHandler("zotero").wrappedJSObject._extensions[
"zotero://note"
] = openNoteExtension;
Expand Down
6 changes: 3 additions & 3 deletions src/modules/sync/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit ea730e6

Please sign in to comment.