diff --git a/package-lock.json b/package-lock.json index 0c916a7..c10ee3c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -64,7 +64,7 @@ "typescript": "^5.3.3", "xslt3": "^2.6.0", "zotero-plugin-scaffold": "^0.1.6", - "zotero-types": "^2.0.1" + "zotero-types": "^3.0.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -3751,9 +3751,9 @@ } }, "node_modules/core-js": { - "version": "3.37.0", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.37.0.tgz", - "integrity": "sha512-fu5vHevQ8ZG4og+LXug8ulUtVxjOcEYvifJr7L5Bfq9GOztVqsKd9/59hUk2ZSbCrS3BqUr3EpaYGIYzq7g3Ug==", + "version": "3.38.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.38.1.tgz", + "integrity": "sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw==", "hasInstallScript": true, "funding": { "type": "opencollective", @@ -9157,9 +9157,9 @@ } }, "node_modules/nan": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.20.0.tgz", - "integrity": "sha512-bk3gXBZDGILuuo/6sKtr0DQmSThYHLtNCdSdXk9YkxD/jK6X2vmCyyXBBxyqZ4XcnzTyYEAThfX3DCEnLf6igw==", + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.22.0.tgz", + "integrity": "sha512-nbajikzWTMwsW+eSsNm3QwlOs7het9gGJU5dDZzRTQGk03vyBOauxgI4VakDzE0PtsGTmXPsXTbbjVhRwR5mpw==", "optional": true }, "node_modules/natural-compare": { @@ -9856,9 +9856,9 @@ "dev": true }, "node_modules/pdfjs-dist": { - "version": "4.6.82", - "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-4.6.82.tgz", - "integrity": "sha512-BUOryeRFwvbLe0lOU6NhkJNuVQUp06WxlJVVCsxdmJ4y5cU3O3s3/0DunVdK1PMm7v2MUw52qKYaidhDH1Z9+w==", + "version": "4.7.76", + "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-4.7.76.tgz", + "integrity": "sha512-8y6wUgC/Em35IumlGjaJOCm3wV4aY/6sqnIT3fVW/67mXsOZ9HWBn8GDKmJUK0GSzpbmX3gQqwfoFayp78Mtqw==", "engines": { "node": ">=18" }, @@ -12215,9 +12215,9 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" }, "node_modules/type": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", - "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.3.tgz", + "integrity": "sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ==" }, "node_modules/type-check": { "version": "0.4.0", @@ -13598,10 +13598,22 @@ "node": ">=18" } }, + "node_modules/zotero-plugin-toolkit/node_modules/zotero-types": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/zotero-types/-/zotero-types-2.2.1.tgz", + "integrity": "sha512-alsjWn7i3pJq7b9+2XT2WbxZtWk4WWH4EIUi6o+Xx7/uz8TQDA0PFY2mS91gL8VXWKXMrSBJKYEbkvMMR6KuKA==", + "dependencies": { + "@types/bluebird": "^3.5.42", + "@types/react": "18.3.1", + "epubjs": "^0.3.93", + "pdfjs-dist": "^4.4.0" + } + }, "node_modules/zotero-types": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/zotero-types/-/zotero-types-2.2.0.tgz", - "integrity": "sha512-Th63hgO+OhWgCy3rSQOSTnEIuhK5gPUsG/No8jqxSGKKksd7b6DQ/V7glmdXieoZEJpzoV0bWyZEQflWU5obHQ==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/zotero-types/-/zotero-types-3.0.0.tgz", + "integrity": "sha512-1v8O4FKJhjrGTdwc4EmHMvpDClHO5Au4b62EuiZtcoJSjEJDUdbI3Dy2CQLXlaDWuTE6MeBY+lB77C3z48aaSg==", + "dev": true, "dependencies": { "@types/bluebird": "^3.5.42", "@types/react": "18.3.1", diff --git a/package.json b/package.json index 5bad210..e599e09 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "typescript": "^5.3.3", "xslt3": "^2.6.0", "zotero-plugin-scaffold": "^0.1.6", - "zotero-types": "^2.0.1" + "zotero-types": "^3.0.0" }, "eslintConfig": { "env": { diff --git a/src/elements/base.ts b/src/elements/base.ts index b8816eb..55698ff 100644 --- a/src/elements/base.ts +++ b/src/elements/base.ts @@ -51,7 +51,7 @@ export class PluginCEBase extends XULElementBase { const selector = `#${this._wrapID(key)}`; return (this.querySelector(selector) || this.shadowRoot?.querySelector(selector)) as - | XUL.Element + | XULElement | HTMLElement | null; } diff --git a/src/elements/linkCreator/notePicker.ts b/src/elements/linkCreator/notePicker.ts index 281bfc2..056d53d 100644 --- a/src/elements/linkCreator/notePicker.ts +++ b/src/elements/linkCreator/notePicker.ts @@ -22,7 +22,7 @@ export class NotePicker extends PluginCEBase { openedNotesView!: VirtualizedTableHelper; recentNotesView!: VirtualizedTableHelper; - _collectionsList!: XUL.Box; + _collectionsList!: XULBoxElement; openedNotes: Zotero.Item[] = []; @@ -101,7 +101,7 @@ export class NotePicker extends PluginCEBase { this._collectionsList = this.querySelector( "#zotero-collections-tree-container", - ) as XUL.Box; + ) as XULBoxElement; this._restoreState(); @@ -459,7 +459,7 @@ export class NotePicker extends PluginCEBase { _persistState() { let state = getPrefJSON(persistKey); - const collectionsListWidth = getComputedStyle(this._collectionsList).width; + const collectionsListWidth = getComputedStyle(this._collectionsList)?.width; if (state?.collectionsListWidth === collectionsListWidth) { return; } @@ -477,7 +477,7 @@ export class NotePicker extends PluginCEBase { if ( typeof state.collectionsListWidth === "string" && state.collectionsListWidth !== - Number(getComputedStyle(this._collectionsList).width) + Number(getComputedStyle(this._collectionsList)?.width) ) { this._collectionsList.style.width = state.collectionsListWidth; } diff --git a/src/elements/workspace/outlinePane.ts b/src/elements/workspace/outlinePane.ts index 8297363..3d1de10 100644 --- a/src/elements/workspace/outlinePane.ts +++ b/src/elements/workspace/outlinePane.ts @@ -236,7 +236,7 @@ export class OutlinePane extends PluginCEBase { // Update set outline menu this._queryID("setOutlinePopup")?.childNodes.forEach((elem) => - (elem as XUL.MenuItem).removeAttribute("checked"), + (elem as XULMenuItemElement).removeAttribute("checked"), ); this._queryID( Object.keys(OutlinePane.outlineMenuIDs)[this.outlineType], @@ -268,7 +268,7 @@ export class OutlinePane extends PluginCEBase { toolbarButtonCommandHandler = async (ev: Event) => { if (!this.item) return; - const type = this._unwrapID((ev.target as XUL.ToolBarButton).id); + const type = this._unwrapID((ev.target as XULToolBarButtonElement).id); switch (type) { case "useTreeView": case "useMindMap": diff --git a/src/elements/workspace/workspace.ts b/src/elements/workspace/workspace.ts index 926b402..f1a8752 100644 --- a/src/elements/workspace/workspace.ts +++ b/src/elements/workspace/workspace.ts @@ -21,11 +21,11 @@ export class Workspace extends PluginCEBase { _editorElement!: EditorElement; _outline!: OutlinePane; - _editorContainer!: XUL.Box; + _editorContainer!: XULBoxElement; _context!: ContextPane; - _leftSplitter!: XUL.Splitter; - _rightSplitter!: XUL.Splitter; + _leftSplitter!: XULSplitterElement; + _rightSplitter!: XULSplitterElement; resizeOb!: ResizeObserver; @@ -93,14 +93,14 @@ export class Workspace extends PluginCEBase { this._outline = this._queryID("left-container") as unknown as OutlinePane; - this._editorContainer = this._queryID("center-container") as XUL.Box; + this._editorContainer = this._queryID("center-container") as XULBoxElement; this._editorElement = this._queryID("editor-main") as EditorElement; this._outline._editorElement = this._editorElement; this._context = this._queryID("right-container") as unknown as ContextPane; - this._leftSplitter = this._queryID("left-splitter") as XUL.Splitter; - this._rightSplitter = this._queryID("right-splitter") as XUL.Splitter; + this._leftSplitter = this._queryID("left-splitter") as XULSplitterElement; + this._rightSplitter = this._queryID("right-splitter") as XULSplitterElement; this._leftSplitter.addEventListener("mouseup", () => { this._persistState(); diff --git a/src/extras/linkCreator.ts b/src/extras/linkCreator.ts index 7c082fd..3141491 100644 --- a/src/extras/linkCreator.ts +++ b/src/extras/linkCreator.ts @@ -2,7 +2,7 @@ import { getPref, setPref } from "../utils/prefs"; import { InboundCreator } from "../elements/linkCreator/inboundCreator"; import { OutboundCreator } from "../elements/linkCreator/outboundCreator"; -let tabbox: XUL.TabBox; +let tabbox: XULTabBoxElement; let inboundCreator: InboundCreator; let outboundCreator: OutboundCreator; diff --git a/src/modules/editor/image.ts b/src/modules/editor/image.ts index b669efb..27d6e67 100644 --- a/src/modules/editor/image.ts +++ b/src/modules/editor/image.ts @@ -5,12 +5,12 @@ export function initEditorImagePreviewer(editor: Zotero.EditorInstance) { const imgs = editor._iframeWindow.document .querySelector(".primary-editor") ?.querySelectorAll("img"); - if (!imgs) { + if (!imgs?.length) { return; } const imageList = Array.from(imgs); addon.hooks.onShowImageViewer( - imageList.map((elem) => elem.src), + imageList.map((elem) => (elem as HTMLImageElement)?.src), imageList.indexOf(e.target as HTMLImageElement), editor._item.getNoteTitle(), ); diff --git a/src/modules/editor/menu.ts b/src/modules/editor/menu.ts index 47b3fc6..2405464 100644 --- a/src/modules/editor/menu.ts +++ b/src/modules/editor/menu.ts @@ -14,10 +14,10 @@ export function initEditorMenu(editor: Zotero.EditorInstance) { return; } editor._popup.setAttribute("bn-init", addon.data.uid); - (editor._popup as XUL.Menu).addEventListener("popupshowing", (ev) => { + (editor._popup as XULMenuElement).addEventListener("popupshowing", (ev) => { const menuitemID = makeId("resizeImage"); if ( - !(editor._popup as XUL.Menu).querySelector(`#${menuitemID}`) && + !(editor._popup as XULMenuElement).querySelector(`#${menuitemID}`) && isImageAtCursor(editor) ) { ztoolkit.Menu.register(editor._popup, { diff --git a/src/modules/editor/popup.ts b/src/modules/editor/popup.ts index 38d6b91..e4c1637 100644 --- a/src/modules/editor/popup.ts +++ b/src/modules/editor/popup.ts @@ -153,7 +153,7 @@ async function updateEditorLinkPopup(editor: Zotero.EditorInstance) { linkPopup?.append(insertButton, updateButton, openButton); } else { Array.from(_window.document.querySelectorAll(".link-popup-extra")).forEach( - (elem) => elem.remove(), + (elem) => (elem as HTMLElement)?.remove(), ); } } @@ -184,7 +184,7 @@ function updateEditorImagePopup(editor: Zotero.EditorInstance) { } const imageList = Array.from(imgs); addon.hooks.onShowImageViewer( - imageList.map((elem) => elem.src), + imageList.map((elem) => (elem as HTMLImageElement)?.src), imageList.indexOf( editor._iframeWindow.document .querySelector(".primary-editor") diff --git a/src/modules/export/api.ts b/src/modules/export/api.ts index 534edd7..2350991 100644 --- a/src/modules/export/api.ts +++ b/src/modules/export/api.ts @@ -221,9 +221,9 @@ async function embedLinkedNotes(noteItem: Zotero.Item): Promise { for (const i in noteLines) { newLines.push(noteLines[i]); const doc = parser.parseFromString(noteLines[i], "text/html"); - const linkParams = Array.from(doc.querySelectorAll("a")) - .filter((a) => a.href.startsWith("zotero://note/")) - .map((a) => getNoteLinkParams(a.href)) + const linkParams = (Array.from(doc.querySelectorAll("a")) as HTMLAnchorElement[]) + .filter((a) => a?.href.startsWith("zotero://note/")) + .map((a) => getNoteLinkParams(a?.href)) .filter((p) => p.noteItem && !p.ignore); for (const linkParam of linkParams) { const html = await addon.api.template.runTemplate( @@ -248,11 +248,10 @@ async function embedLinkedNotes(noteItem: Zotero.Item): Promise { seenCitationItemIDs.push(currentID); } } - return `
${newLines.join("\n")}
`; + return `
${newLines.join("\n")}
`; } function getNoteCitationData(noteItem: Zotero.Item) { diff --git a/src/modules/export/docx.ts b/src/modules/export/docx.ts index b55416f..0e9b1e9 100644 --- a/src/modules/export/docx.ts +++ b/src/modules/export/docx.ts @@ -49,7 +49,7 @@ async function parseDocxFields(html: string, worker: HTMLIFrameElement) { const mathCache = {} as MathCache; - for (const elem of Array.from(doc.querySelectorAll("math"))) { + for (const elem of (Array.from(doc.querySelectorAll("math")) as MathMLElement[])) { let str = (await sendWorkerTask( worker, "parseMML", @@ -101,7 +101,7 @@ async function parseDocxFields(html: string, worker: HTMLIFrameElement) { ); const citationElements = Array.from( doc.querySelectorAll(".citation[data-citation]"), - ); + ) as HTMLElement[]; for (let i = 0; i < citationElements.length; i++) { const elem = citationElements[i]; /* @@ -122,9 +122,8 @@ async function parseDocxFields(html: string, worker: HTMLIFrameElement) { citationItems.push(item); } const properties = citation.properties; - const formattedCitation = `${ - elem.textContent || "Zotero Citation" - } - Please click Zotero - Refresh in Word/LibreOffice to update all fields.`; + const formattedCitation = `${elem.textContent || "Zotero Citation" + } - Please click Zotero - Refresh in Word/LibreOffice to update all fields.`; properties.formattedCitation = formattedCitation; properties.plainCitation = formattedCitation + " "; properties.noteIndex = 0; diff --git a/src/modules/export/exportWindow.ts b/src/modules/export/exportWindow.ts index e6da423..49fb452 100644 --- a/src/modules/export/exportWindow.ts +++ b/src/modules/export/exportWindow.ts @@ -59,7 +59,7 @@ export async function showExportNoteOptions( } } Array.from(doc.querySelectorAll('input[name="linkMode"]')).forEach((elem) => - elem.addEventListener("change", updateSyncCheckbox), + (elem as HTMLInputElement).addEventListener("change", updateSyncCheckbox), ); updateSyncCheckbox(); }; @@ -177,11 +177,11 @@ function makeCheckboxLine(dataKey: string, callback?: (ev: Event) => void) { }, listeners: callback ? [ - { - type: "change", - listener: callback, - }, - ] + { + type: "change", + listener: callback, + }, + ] : [], }, ], @@ -223,11 +223,11 @@ function makeRadioLine( }, listeners: callback ? [ - { - type: "change", - listener: callback, - }, - ] + { + type: "change", + listener: callback, + }, + ] : [], }, ], diff --git a/src/modules/menu.ts b/src/modules/menu.ts index 98d1f55..0ccaf16 100644 --- a/src/modules/menu.ts +++ b/src/modules/menu.ts @@ -45,7 +45,7 @@ export function registerMenus(win: Window) { // menuFile const menuFileAnchor = win.document.querySelector( "#menu_newCollection", - ) as XUL.MenuItem; + ) as XULMenuItemElement; ztoolkit.Menu.register( "menuFile", @@ -105,7 +105,7 @@ export function registerMenus(win: Window) { // create note menu in library const newNoteMenu = win.document .querySelector("#zotero-tb-note-add") - ?.querySelector("menupopup") as XUL.MenuPopup; + ?.querySelector("menupopup") as XULMenuPopupElement; ztoolkit.Menu.register(newNoteMenu, { tag: "menuitem", label: getString("menuAddNote.newTemplateStandaloneNote"), @@ -130,7 +130,7 @@ export function registerMenus(win: Window) { ztoolkit.Menu.register( win.document.querySelector( "#context-pane-add-child-note-button-popup", - ) as XUL.MenuPopup, + ) as XULMenuPopupElement, { tag: "menuitem", label: getString("menuAddReaderNote.newTemplateNote"), diff --git a/src/modules/template/editorWindow.ts b/src/modules/template/editorWindow.ts index a40897c..f92a684 100644 --- a/src/modules/template/editorWindow.ts +++ b/src/modules/template/editorWindow.ts @@ -191,7 +191,7 @@ export async function showTemplateEditor() { _window.document .querySelector("#editor-type") ?.addEventListener("command", (ev) => { - updateSnippets((ev.target as XUL.MenuList)?.value); + updateSnippets((ev.target as XULMenuListElement)?.value); }); addon.data.template.editor.window?.focus(); const editorWin = (_window.document.querySelector("#editor") as any) @@ -278,15 +278,15 @@ function updateEditor() { const templateType = win.document.querySelector( "#editor-type", - ) as XUL.MenuList; + ) as XULMenuListElement; const templateName = win.document.querySelector( "#editor-name", ) as HTMLInputElement; const editor = win?.document.getElementById("editor") as HTMLIFrameElement; - const saveTemplate = win?.document.getElementById("save") as XUL.Button; - const deleteTemplate = win?.document.getElementById("delete") as XUL.Button; - const resetTemplate = win?.document.getElementById("reset") as XUL.Button; - const shareTemplate = win?.document.getElementById("share") as XUL.Button; + const saveTemplate = win?.document.getElementById("save") as XULButtonElement | null; + const deleteTemplate = win?.document.getElementById("delete") as XULButtonElement | null; + const resetTemplate = win?.document.getElementById("reset") as XULButtonElement | null; + const shareTemplate = win?.document.getElementById("share") as XULButtonElement | null; const formats = win?.document.getElementById( "formats-container", ) as HTMLDivElement; @@ -299,11 +299,11 @@ function updateEditor() { templateName.value = ""; templateName.setAttribute("disabled", "true"); editor.hidden = true; - saveTemplate.setAttribute("disabled", "true"); - deleteTemplate.setAttribute("disabled", "true"); - deleteTemplate.hidden = false; - shareTemplate.setAttribute("disabled", "true"); - resetTemplate.hidden = true; + saveTemplate?.setAttribute("disabled", "true"); + deleteTemplate?.setAttribute("disabled", "true"); + deleteTemplate && (deleteTemplate.hidden = false); + shareTemplate?.setAttribute("disabled", "true"); + resetTemplate && (resetTemplate.hidden = true); formats.hidden = true; snippets.hidden = true; } else { @@ -312,20 +312,20 @@ function updateEditor() { if (!addon.api.template.SYSTEM_TEMPLATE_NAMES.includes(name)) { templateType.removeAttribute("disabled"); templateName.removeAttribute("disabled"); - deleteTemplate.hidden = false; - resetTemplate.hidden = true; + deleteTemplate && (deleteTemplate.hidden = false); + resetTemplate && (resetTemplate.hidden = true); } else { templateType.setAttribute("disabled", "true"); templateName.setAttribute("disabled", "true"); - deleteTemplate.setAttribute("disabled", "true"); - deleteTemplate.hidden = true; - resetTemplate.hidden = false; + deleteTemplate?.setAttribute("disabled", "true"); + deleteTemplate && (deleteTemplate.hidden = true); + resetTemplate && (resetTemplate.hidden = false); } addon.data.template.editor.editor.setValue(templateText); editor.hidden = false; - saveTemplate.removeAttribute("disabled"); - deleteTemplate.removeAttribute("disabled"); - shareTemplate.removeAttribute("disabled"); + saveTemplate?.removeAttribute("disabled"); + deleteTemplate?.removeAttribute("disabled"); + shareTemplate?.removeAttribute("disabled"); formats.hidden = false; snippets.hidden = false; updateSnippets( @@ -534,7 +534,7 @@ function saveSelectedTemplate() { const templateType = win.document.querySelector( "#editor-type", - ) as XUL.MenuList; + ) as XULMenuListElement; const templateName = win.document.querySelector( "#editor-name", ) as HTMLInputElement; @@ -608,7 +608,7 @@ function resetSelectedTemplate() { if (addon.api.template.SYSTEM_TEMPLATE_NAMES.includes(name)) { addon.data.template.editor.editor.setValue( addon.api.template.DEFAULT_TEMPLATES.find((t) => t.name === name)?.text || - "", + "", ); showHint(`Template ${name} is reset. Please save before leaving.`); } @@ -631,9 +631,9 @@ pluginVersion: "${version}" savedAt: "${new Date().toISOString()}" content: |- ${content - .split("\n") - .map((line) => ` ${line}`) - .join("\n")} + .split("\n") + .map((line) => ` ${line}`) + .join("\n")} `; new ztoolkit.Clipboard().addText(yaml, "text/plain").copy(); showHint( diff --git a/src/modules/workspace/content.ts b/src/modules/workspace/content.ts index 99b2c09..acae7ca 100644 --- a/src/modules/workspace/content.ts +++ b/src/modules/workspace/content.ts @@ -1,7 +1,7 @@ import { Workspace } from "../../elements/workspace/workspace"; import { waitUtilAsync } from "../../utils/wait"; -export async function initWorkspace(container: XUL.Box, item: Zotero.Item) { +export async function initWorkspace(container: XULBoxElement, item: Zotero.Item) { if (!container) { return; } diff --git a/src/modules/workspace/window.ts b/src/modules/workspace/window.ts index 853d65c..88b73a0 100644 --- a/src/modules/workspace/window.ts +++ b/src/modules/workspace/window.ts @@ -17,7 +17,7 @@ export async function openWorkspaceWindow( const container = win.document.querySelector( "#workspace-container", - ) as XUL.Box; + ) as XULBoxElement; const workspace = await addon.hooks.onInitWorkspace(container, item); workspace?.scrollEditorTo(options); diff --git a/src/utils/link.ts b/src/utils/link.ts index 3a01c45..ddeb705 100644 --- a/src/utils/link.ts +++ b/src/utils/link.ts @@ -95,13 +95,13 @@ export function getLinkedNotesRecursively( return []; } const doc = new DOMParser().parseFromString(noteItem.getNote(), "text/html"); - const links = Array.from(doc.querySelectorAll("a")); + const links = Array.from(doc.querySelectorAll("a")) as HTMLAnchorElement[]; return links.reduce( (acc, link) => { - const linkParams = getNoteLinkParams(link.href); + const linkParams = getNoteLinkParams(link?.href); if (linkParams.noteItem) { acc.push(linkParams.noteItem.id); - acc.push(...getLinkedNotesRecursively(link.href, acc)); + acc.push(...getLinkedNotesRecursively(link?.href, acc)); } return acc; }, diff --git a/src/utils/note.ts b/src/utils/note.ts index 56995e3..9859334 100644 --- a/src/utils/note.ts +++ b/src/utils/note.ts @@ -58,8 +58,7 @@ async function setLinesToNote(note: Zotero.Item, lines: string[]) { } else { const noteHead = noteText.substring(0, containerIndex); note.setNote( - `${noteHead}data-schema-version="${ - config.dataSchemaVersion + `${noteHead}data-schema-version="${config.dataSchemaVersion }">${lines.join("\n")}`, ); } @@ -167,7 +166,7 @@ async function renderNoteHTML( const bgNodes = doc.querySelectorAll( "span[style]", ) as NodeListOf; - for (const node of Array.from(bgNodes)) { + for (const node of Array.from(bgNodes) as HTMLSpanElement[]) { // Browser converts #RRGGBBAA hex color to rgba function, and we convert it to rgb function, // because word processors don't understand colors with alpha channel if ( @@ -359,7 +358,7 @@ async function copyEmbeddedImagesInHTML( if (await attachment.fileExists()) { const nodes = Array.from( doc.querySelectorAll(`img[data-attachment-key="${attachment.key}"]`), - ); + ) as HTMLImageElement[]; if (nodes.length) { let copiedAttachment: Zotero.Item; await Zotero.DB.executeTransaction(async () => { @@ -370,7 +369,7 @@ async function copyEmbeddedImagesInHTML( }); }); nodes.forEach((node) => - node.setAttribute("data-attachment-key", copiedAttachment.key), + node?.setAttribute("data-attachment-key", copiedAttachment.key), Node ); } } diff --git a/typings/editor.d.ts b/typings/editor.d.ts index dbaaacc..76f91c9 100644 --- a/typings/editor.d.ts +++ b/typings/editor.d.ts @@ -43,7 +43,7 @@ declare interface EditorCore { declare type EditorAPI = typeof import("../src/extras/editorScript").BetterNotesEditorAPI; -declare interface EditorElement extends XUL.Box { +declare interface EditorElement extends XULBoxElement { _iframe: HTMLIFrameElement; _editorInstance: Zotero.EditorInstance; _initialized?: boolean;