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