and
wrapped by
@@ -245,7 +247,7 @@ function note2rehype(str: string) {
replace(_n, p);
}
}
- }
+ },
);
// Make sure empty
under root node is removed
@@ -259,7 +261,7 @@ function note2rehype(str: string) {
parentNode.children.splice(parentNode.children.indexOf(_n), 1);
}
}
- }
+ },
);
return rehype;
}
@@ -310,13 +312,13 @@ async function rehype2remark(rehype: HRoot) {
if (node.properties.style) {
hasStyle = true;
}
- }
+ },
);
- if (0 && hasStyle) {
- return h(node, "styleTable", toHtml(node));
- } else {
- return defaultHandlers.table(h, node);
- }
+ // if (0 && hasStyle) {
+ // return h(node, "styleTable", toHtml(node));
+ // } else {
+ return defaultHandlers.table(h, node);
+ // }
},
wrapper: (h, node) => {
return h(node, "wrapper", toText(node));
@@ -389,7 +391,7 @@ function remark2md(remark: MRoot) {
},
},
} as any)
- .stringify(remark)
+ .stringify(remark),
);
}
@@ -401,7 +403,7 @@ function md2remark(str: string) {
.replace(
/!\[.*\]\((.*)\)/g,
(s: string) =>
- `/g)![0].slice(1, -1))})`
+ `/g)![0].slice(1, -1))})`,
);
const remark = unified()
.use(remarkGfm)
@@ -439,7 +441,7 @@ function rehype2note(rehype: HRoot) {
(node: any) => {
node.tagName = "span";
node.properties.style = "text-decoration: line-through";
- }
+ },
);
// Code node
@@ -454,7 +456,7 @@ function rehype2note(rehype: HRoot) {
node.value = toText(node);
node.type = "text";
}
- }
+ },
);
// Table node with style
@@ -472,14 +474,14 @@ function rehype2note(rehype: HRoot) {
if (node.properties.style) {
hasStyle = true;
}
- }
+ },
);
if (hasStyle) {
node.value = toHtml(node).replace(/[\r\n]/g, "");
node.children = [];
node.type = "raw";
}
- }
+ },
);
// Convert thead to tbody
@@ -490,7 +492,7 @@ function rehype2note(rehype: HRoot) {
node.value = toHtml(node).slice(7, -8);
node.children = [];
node.type = "raw";
- }
+ },
);
// Wrap lines in list with
(for diff)
@@ -522,9 +524,9 @@ function rehype2note(rehype: HRoot) {
node.children = node.children.filter(
(_n: { type: string; value: string }) =>
_n.type === "element" ||
- (_n.type === "text" && _n.value.replace(/[\r\n]/g, ""))
+ (_n.type === "text" && _n.value.replace(/[\r\n]/g, "")),
);
- }
+ },
);
// Math node
@@ -550,7 +552,7 @@ function rehype2note(rehype: HRoot) {
node.tagName = "pre";
}
node.properties.className = "math";
- }
+ },
);
// Ignore link rel attribute, which exists in note
@@ -559,7 +561,7 @@ function rehype2note(rehype: HRoot) {
(node: any) => node.type === "element" && (node as any).tagName === "a",
(node: any) => {
node.properties.rel = undefined;
- }
+ },
);
// Ignore empty lines, as they are not parsed to md
@@ -610,7 +612,7 @@ function getN2MRehypeHighlightNodes(rehype: HRoot) {
(node: any) =>
node.type === "element" &&
node.properties?.className?.includes("highlight"),
- (node) => nodes.push(node)
+ (node) => nodes.push(node),
);
return new Array(...new Set(nodes));
}
@@ -622,7 +624,7 @@ function getN2MRehypeCitationNodes(rehype: HRoot) {
(node: any) =>
node.type === "element" &&
node.properties?.className?.includes("citation"),
- (node) => nodes.push(node)
+ (node) => nodes.push(node),
);
return new Array(...new Set(nodes));
}
@@ -636,7 +638,7 @@ function getN2MRehypeNoteLinkNodes(rehype: any) {
node.tagName === "a" &&
node.properties?.href &&
/zotero:\/\/note\/\w+\/\w+\//.test(node.properties?.href),
- (node) => nodes.push(node)
+ (node) => nodes.push(node),
);
return new Array(...new Set(nodes));
}
@@ -649,14 +651,14 @@ function getN2MRehypeImageNodes(rehype: any) {
node.type === "element" &&
node.tagName === "img" &&
node.properties?.dataAttachmentKey,
- (node) => nodes.push(node)
+ (node) => nodes.push(node),
);
return new Array(...new Set(nodes));
}
function processN2MRehypeHighlightNodes(
nodes: string | any[],
- mode: NodeMode = NodeMode.default
+ mode: NodeMode = NodeMode.default,
) {
if (!nodes.length) {
return;
@@ -665,7 +667,7 @@ function processN2MRehypeHighlightNodes(
let annotation;
try {
annotation = JSON.parse(
- decodeURIComponent(node.properties.dataAnnotation)
+ decodeURIComponent(node.properties.dataAnnotation),
);
} catch (e) {
continue;
@@ -674,20 +676,20 @@ function processN2MRehypeHighlightNodes(
continue;
}
// annotation.uri was used before note-editor v4
- let uri = annotation.attachmentURI || annotation.uri;
- let position = annotation.position;
+ const uri = annotation.attachmentURI || annotation.uri;
+ const position = annotation.position;
if (typeof uri === "string" && typeof position === "object") {
let openURI;
- let uriParts = uri.split("/");
- let libraryType = uriParts[3];
- let key = uriParts[uriParts.length - 1];
+ const uriParts = uri.split("/");
+ const libraryType = uriParts[3];
+ const key = uriParts[uriParts.length - 1];
if (libraryType === "users") {
openURI = "zotero://open-pdf/library/items/" + key;
}
// groups
else {
- let groupID = uriParts[4];
+ const groupID = uriParts[4];
openURI = "zotero://open-pdf/groups/" + groupID + "/items/" + key;
}
@@ -709,7 +711,7 @@ function processN2MRehypeHighlightNodes(
randomString(
8,
Zotero.Utilities.Internal.md5(node.properties.dataAnnotation),
- Zotero.Utilities.allowedKeyChars
+ Zotero.Utilities.allowedKeyChars,
);
if (mode === NodeMode.wrap) {
@@ -731,7 +733,7 @@ function processN2MRehypeHighlightNodes(
function processN2MRehypeCitationNodes(
nodes: string | any[],
- mode: NodeMode = NodeMode.default
+ mode: NodeMode = NodeMode.default,
) {
if (!nodes.length) {
return;
@@ -747,19 +749,19 @@ function processN2MRehypeCitationNodes(
continue;
}
- let uris: any[] = [];
- for (let citationItem of citation.citationItems) {
- let uri = citationItem.uris[0];
+ const uris: any[] = [];
+ for (const citationItem of citation.citationItems) {
+ const uri = citationItem.uris[0];
if (typeof uri === "string") {
- let uriParts = uri.split("/");
- let libraryType = uriParts[3];
- let key = uriParts[uriParts.length - 1];
+ const uriParts = uri.split("/");
+ const libraryType = uriParts[3];
+ const key = uriParts[uriParts.length - 1];
if (libraryType === "users") {
uris.push("zotero://select/library/items/" + key);
}
// groups
else {
- let groupID = uriParts[4];
+ const groupID = uriParts[4];
uris.push("zotero://select/groups/" + groupID + "/items/" + key);
}
}
@@ -772,7 +774,7 @@ function processN2MRehypeCitationNodes(
(_n: any) => _n.properties?.className.includes("citation-item"),
(_n: any) => {
return childNodes?.push(_n);
- }
+ },
);
// For unknown reasons, the element will be duplicated. Remove them.
@@ -797,7 +799,7 @@ function processN2MRehypeCitationNodes(
const citationKey = randomString(
8,
Zotero.Utilities.Internal.md5(node.properties.dataCitation),
- Zotero.Utilities.allowedKeyChars
+ Zotero.Utilities.allowedKeyChars,
);
if (mode === NodeMode.wrap) {
newNode.children.splice(0, 0, h("wrapperleft", `cite:${citationKey}`));
@@ -817,7 +819,7 @@ function processN2MRehypeCitationNodes(
async function processN2MRehypeNoteLinkNodes(
nodes: string | any[],
dir: string,
- mode: NodeMode = NodeMode.default
+ mode: NodeMode = NodeMode.default,
) {
if (!nodes.length) {
return;
@@ -835,7 +837,7 @@ async function processN2MRehypeNoteLinkNodes(
const linkKey = randomString(
8,
Zotero.Utilities.Internal.md5(node.properties.href),
- Zotero.Utilities.allowedKeyChars
+ Zotero.Utilities.allowedKeyChars,
);
if (mode === NodeMode.wrap) {
const newNode = h("span", [
@@ -843,7 +845,7 @@ async function processN2MRehypeNoteLinkNodes(
h(
node.tagName,
Object.assign(node.properties, { href: link }),
- node.children
+ node.children,
),
h("wrapperright", `note:${linkKey}`),
]);
@@ -869,25 +871,25 @@ async function processN2MRehypeImageNodes(
dir: string,
skipSavingImages: boolean = false,
absolutePath: boolean = false,
- mode: NodeMode = NodeMode.default
+ mode: NodeMode = NodeMode.default,
) {
if (!nodes.length) {
return;
}
for (const node of nodes) {
- let imgKey = node.properties.dataAttachmentKey;
+ const imgKey = node.properties.dataAttachmentKey;
const attachmentItem = (await Zotero.Items.getByLibraryAndKeyAsync(
libraryID,
- imgKey
+ imgKey,
)) as Zotero.Item;
if (!attachmentItem) {
continue;
}
- let oldFile = String(await attachmentItem.getFilePathAsync());
- let ext = oldFile.split(".").pop();
- let newAbsPath = formatPath(`${dir}/${imgKey}.${ext}`);
+ const oldFile = String(await attachmentItem.getFilePathAsync());
+ const ext = oldFile.split(".").pop();
+ const newAbsPath = formatPath(`${dir}/${imgKey}.${ext}`);
let newFile = oldFile;
try {
// Don't overwrite
@@ -898,7 +900,7 @@ async function processN2MRehypeImageNodes(
newFile = newFile.replace(/\\/g, "/");
}
newFile = Zotero.File.normalizeToUnix(
- absolutePath ? newFile : `attachments/${newFile.split(/\//).pop()}`
+ absolutePath ? newFile : `attachments/${newFile.split(/\//).pop()}`,
);
} catch (e) {
ztoolkit.log(e);
@@ -922,7 +924,7 @@ function getM2NRehypeAnnotationNodes(rehype: any) {
visit(
rehype,
(node: any) => node.type === "element" && node.properties?.dataAnnotation,
- (node: any) => nodes.push(node)
+ (node: any) => nodes.push(node),
);
return new Array(...new Set(nodes));
}
@@ -933,7 +935,7 @@ function getM2NRehypeHighlightNodes(rehype: any) {
rehype,
(node: any) =>
node.type === "element" && node.properties?.ztype === "zhighlight",
- (node) => nodes.push(node)
+ (node) => nodes.push(node),
);
return new Array(...new Set(nodes));
}
@@ -945,7 +947,7 @@ function getM2NRehypeCitationNodes(rehype: any) {
(node: any) =>
node.type === "element" &&
(node.properties?.ztype === "zcitation" || node.properties?.dataCitation),
- (node) => nodes.push(node)
+ (node) => nodes.push(node),
);
return new Array(...new Set(nodes));
}
@@ -956,7 +958,7 @@ function getM2NRehypeNoteLinkNodes(rehype: any) {
rehype,
(node: any) =>
node.type === "element" && node.properties?.ztype === "znotelink",
- (node) => nodes.push(node)
+ (node) => nodes.push(node),
);
return new Array(...new Set(nodes));
}
@@ -966,7 +968,7 @@ function getM2NRehypeImageNodes(rehype: any) {
visit(
rehype,
(node: any) => node.type === "element" && node.tagName === "img",
- (node) => nodes.push(node)
+ (node) => nodes.push(node),
);
return new Array(...new Set(nodes));
}
@@ -1002,7 +1004,7 @@ function processM2NRehypeHighlightNodes(nodes: string | any[]) {
async function processM2NRehypeCitationNodes(
nodes: string | any[],
- isImport: boolean = false
+ isImport: boolean = false,
) {
if (!nodes.length) {
return;
@@ -1021,10 +1023,10 @@ async function processM2NRehypeCitationNodes(
// "properties": {}
// }
const dataCitation = JSON.parse(
- decodeURIComponent(node.properties.dataCitation)
+ decodeURIComponent(node.properties.dataCitation),
);
const ids = dataCitation.citationItems.map((c: { uris: string[] }) =>
- Zotero.URI.getURIItemID(c.uris[0])
+ Zotero.URI.getURIItemID(c.uris[0]),
);
const html = (await parseCitationHTML(ids)) || "";
const newNode = note2rehype(html);
@@ -1040,7 +1042,7 @@ async function processM2NRehypeCitationNodes(
(_n: any) => _n.properties?.className.includes("citation-item"),
(_n) => {
_n.children = [{ type: "text", value: toText(_n) }];
- }
+ },
);
delete node.properties?.ztype;
}
@@ -1064,7 +1066,7 @@ async function processM2NRehypeImageNodes(
nodes: any[],
noteItem: Zotero.Item,
fileDir: string,
- isImport: boolean = false
+ isImport: boolean = false,
) {
if (!nodes.length || (isImport && !noteItem)) {
return;
@@ -1074,7 +1076,7 @@ async function processM2NRehypeImageNodes(
if (isImport) {
// We encode the src in md2remark and decode it here.
let src = Zotero.File.normalizeToUnix(
- decodeURIComponent(node.properties.src)
+ decodeURIComponent(node.properties.src),
);
const srcType = (src as string).startsWith("data:")
? "b64"
diff --git a/src/modules/createNote.ts b/src/modules/createNote.ts
index ba554c4..686925b 100644
--- a/src/modules/createNote.ts
+++ b/src/modules/createNote.ts
@@ -11,23 +11,23 @@ async function createWorkspaceNote() {
}
const confirmOperation = window.confirm(
`${getString(
- "menuAddNote.newMainNote.confirmHead"
+ "menuAddNote.newMainNote.confirmHead",
// @ts-ignore
)} '${currentCollection.getName()}' ${getString(
- "menuAddNote.newMainNote.confirmTail"
- )}`
+ "menuAddNote.newMainNote.confirmTail",
+ )}`,
);
if (!confirmOperation) {
return;
}
const header = window.prompt(
getString("menuAddNote.newMainNote.enterNoteTitle"),
- `New Note ${new Date().toLocaleString()}`
+ `New Note ${new Date().toLocaleString()}`,
);
const noteID = await ZoteroPane.newNote();
const noteItem = Zotero.Items.get(noteID);
noteItem.setNote(
- `
${header}
\n`
+ `${header}
\n`,
);
await noteItem.saveTx();
addon.hooks.onSetWorkspaceNote(noteID, "main");
@@ -47,10 +47,8 @@ function getLibraryParentId() {
function getReaderParentId() {
const currentReader = Zotero.Reader.getByTabID(Zotero_Tabs.selectedID);
- if (currentReader) {
- }
const parentItemId = Zotero.Items.get(
- currentReader?.itemID || -1
+ currentReader?.itemID || -1,
).parentItemID;
return parentItemId;
}
@@ -58,11 +56,11 @@ function getReaderParentId() {
async function createNoteFromTemplate(noteType: "standalone"): Promise;
async function createNoteFromTemplate(
noteType: "item",
- parentType: "reader" | "library"
+ parentType: "reader" | "library",
): Promise;
async function createNoteFromTemplate(
noteType: "standalone" | "item",
- parentType?: "reader" | "library"
+ parentType?: "reader" | "library",
) {
if (noteType === "item") {
const parentItemId =
@@ -94,7 +92,7 @@ async function createNoteFromMD() {
const filepaths = await new ztoolkit.FilePicker(
"Import MarkDown",
"multiple",
- [[`MarkDown(*.md)`, `*.md`]]
+ [[`MarkDown(*.md)`, `*.md`]],
).open();
if (!filepaths) {
diff --git a/src/modules/editor/image.ts b/src/modules/editor/image.ts
index bda6f9b..b669efb 100644
--- a/src/modules/editor/image.ts
+++ b/src/modules/editor/image.ts
@@ -12,7 +12,7 @@ export function initEditorImagePreviewer(editor: Zotero.EditorInstance) {
addon.hooks.onShowImageViewer(
imageList.map((elem) => elem.src),
imageList.indexOf(e.target as HTMLImageElement),
- editor._item.getNoteTitle()
+ editor._item.getNoteTitle(),
);
};
editor._iframeWindow.document.addEventListener("dblclick", (e) => {
diff --git a/src/modules/editor/initalize.ts b/src/modules/editor/initalize.ts
index 2241479..03cffa2 100644
--- a/src/modules/editor/initalize.ts
+++ b/src/modules/editor/initalize.ts
@@ -11,12 +11,12 @@ export function registerEditorInstanceHook() {
apply: (
target,
thisArg,
- argumentsList: [instance: Zotero.EditorInstance]
+ argumentsList: [instance: Zotero.EditorInstance],
) => {
target.apply(thisArg, argumentsList);
argumentsList.forEach(onEditorInstanceCreated);
},
- }
+ },
);
}
diff --git a/src/modules/editor/inject.ts b/src/modules/editor/inject.ts
index 36b30ae..eb4afea 100644
--- a/src/modules/editor/inject.ts
+++ b/src/modules/editor/inject.ts
@@ -7,12 +7,12 @@ export async function injectEditorScripts(win: Window) {
id: "betternotes-script",
properties: {
innerHTML: await getFileContent(
- rootURI + "chrome/content/scripts/editorScript.js"
+ rootURI + "chrome/content/scripts/editorScript.js",
),
},
ignoreIfExists: true,
},
- win.document.head
+ win.document.head,
);
}
@@ -60,6 +60,6 @@ export function injectEditorCSS(win: Window) {
},
ignoreIfExists: true,
},
- win.document.head
+ win.document.head,
);
}
diff --git a/src/modules/editor/menu.ts b/src/modules/editor/menu.ts
index d9eb69b..453d00d 100644
--- a/src/modules/editor/menu.ts
+++ b/src/modules/editor/menu.ts
@@ -31,8 +31,8 @@ export function initEditorMenu(editor: Zotero.EditorInstance) {
editor._iframeWindow.prompt(
getString("editor.resizeImage.prompt"),
// @ts-ignore
- getEditorCore(editor).view.state.selection.node?.attrs?.width
- ) || ""
+ getEditorCore(editor).view.state.selection.node?.attrs?.width,
+ ) || "",
);
if (newWidth && newWidth > 10) {
updateImageDimensionsAtCursor(editor, newWidth);
diff --git a/src/modules/editor/popup.ts b/src/modules/editor/popup.ts
index 26a7ac0..d868535 100644
--- a/src/modules/editor/popup.ts
+++ b/src/modules/editor/popup.ts
@@ -38,7 +38,7 @@ export function initEditorPopup(editor: Zotero.EditorInstance) {
childList: true,
attributes: true,
attributeFilter: ["href"],
- }
+ },
);
}
@@ -68,7 +68,7 @@ async function updateEditorLinkPopup(editor: Zotero.EditorInstance) {
const templateText = await addon.api.template.runTemplate(
"[QuickImportV2]",
"link, noteItem",
- [link, editorNote]
+ [link, editorNote],
);
// auto insert to anchor position
updateURLAtCursor(
@@ -76,8 +76,8 @@ async function updateEditorLinkPopup(editor: Zotero.EditorInstance) {
undefined,
getNoteLink(
linkNote,
- Object.assign({}, linkParams, { ignore: true })
- )!
+ Object.assign({}, linkParams, { ignore: true }),
+ )!,
);
insert(editor, templateText);
} else {
@@ -86,14 +86,14 @@ async function updateEditorLinkPopup(editor: Zotero.EditorInstance) {
undefined,
getNoteLink(
linkNote,
- Object.assign({}, linkParams, { ignore: null })
- )!
+ Object.assign({}, linkParams, { ignore: null }),
+ )!,
);
const lineIndex = getLineAtCursor(editor);
del(
editor,
getPositionAtLine(editor, lineIndex),
- getPositionAtLine(editor, lineIndex + 1)
+ getPositionAtLine(editor, lineIndex + 1),
);
}
},
@@ -117,7 +117,7 @@ async function updateEditorLinkPopup(editor: Zotero.EditorInstance) {
updateURLAtCursor(
editor,
linkNote.getNoteTitle(),
- getURLAtCursor(editor)
+ getURLAtCursor(editor),
);
},
},
@@ -184,7 +184,7 @@ async function updateEditorLinkPopup(editor: Zotero.EditorInstance) {
// }
} else {
Array.from(_window.document.querySelectorAll(".link-popup-extra")).forEach(
- (elem) => elem.remove()
+ (elem) => elem.remove(),
);
}
}
@@ -220,9 +220,9 @@ function updateEditorImagePopup(editor: Zotero.EditorInstance) {
editor._iframeWindow.document
.querySelector(".primary-editor")
?.querySelector(".selected")
- ?.querySelector("img") as HTMLImageElement
+ ?.querySelector("img") as HTMLImageElement,
),
- editor._item.getNoteTitle()
+ editor._item.getNoteTitle(),
);
},
},
@@ -245,8 +245,8 @@ function updateEditorImagePopup(editor: Zotero.EditorInstance) {
getString("editor.resizeImage.prompt"),
// @ts-ignore
getEditorCore(editor).view.state.selection.node?.attrs
- ?.width
- ) || ""
+ ?.width,
+ ) || "",
);
if (newWidth && newWidth > 10) {
updateImageDimensionsAtCursor(editor, newWidth);
@@ -257,6 +257,6 @@ function updateEditorImagePopup(editor: Zotero.EditorInstance) {
},
],
},
- editor._iframeWindow.document.querySelector(".image-popup")!
+ editor._iframeWindow.document.querySelector(".image-popup")!,
);
}
diff --git a/src/modules/editor/toolbar.ts b/src/modules/editor/toolbar.ts
index 16a37ce..984b409 100644
--- a/src/modules/editor/toolbar.ts
+++ b/src/modules/editor/toolbar.ts
@@ -25,14 +25,14 @@ export async function initEditorToolbar(editor: Zotero.EditorInstance) {
ICONS.settings,
getString("editor.toolbar.settings.title"),
"end",
- (e) => {}
+ (e) => {},
);
settingsButton.addEventListener("click", async (ev) => {
ev.stopPropagation();
function removePopup() {
const popup = editor._iframeWindow.document.querySelector(
- `#${makeId("settings-popup")}`
+ `#${makeId("settings-popup")}`,
);
if (popup) {
popup.remove();
@@ -116,7 +116,7 @@ export async function initEditorToolbar(editor: Zotero.EditorInstance) {
`${
e.editor._item.getNoteTitle().trim() || link
}`,
- "text/html"
+ "text/html",
)
.copy();
showHint(`Link ${link} copied`);
@@ -158,7 +158,7 @@ export async function initEditorToolbar(editor: Zotero.EditorInstance) {
settingsButton,
`${config.addonRef}-settings-popup`,
"right",
- settingsMenuData
+ settingsMenuData,
).then((popup) => {
settingsButton.querySelector(".toolbar-button")?.classList.add("active");
editor._iframeWindow.document.addEventListener("click", removePopup);
@@ -173,7 +173,7 @@ export async function initEditorToolbar(editor: Zotero.EditorInstance) {
"middle",
ztoolkit.UI.createElement(editor._iframeWindow.document, "div", {
properties: { innerHTML: getString("editor.toolbar.main") },
- })
+ }),
);
} else {
const onTriggerMenu = (ev: MouseEvent) => {
@@ -188,7 +188,7 @@ export async function initEditorToolbar(editor: Zotero.EditorInstance) {
linkButton,
`${config.addonRef}-link-popup`,
"middle",
- linkMenu
+ linkMenu,
);
};
@@ -207,7 +207,7 @@ export async function initEditorToolbar(editor: Zotero.EditorInstance) {
return;
}
const lineIndex = parseInt(
- (ev.target as HTMLDivElement).id.split("-").pop() || "-1"
+ (ev.target as HTMLDivElement).id.split("-").pop() || "-1",
);
const forwardLink = getNoteLink(noteItem);
const backLink = getNoteLink(mainNote, { ignore: true, lineIndex });
@@ -221,9 +221,9 @@ export async function initEditorToolbar(editor: Zotero.EditorInstance) {
noteItem.getNoteTitle().trim() || forwardLink,
noteItem,
mainNote,
- ]
+ ],
),
- lineIndex
+ lineIndex,
);
addLineToNote(
noteItem,
@@ -236,8 +236,8 @@ export async function initEditorToolbar(editor: Zotero.EditorInstance) {
noteItem,
mainNote,
"",
- ]
- )
+ ],
+ ),
);
onExitMenu(ev);
ev.stopPropagation();
@@ -250,7 +250,7 @@ export async function initEditorToolbar(editor: Zotero.EditorInstance) {
ICONS.addon,
getString("editor.toolbar.link.title"),
"middle",
- onClickMenu
+ onClickMenu,
);
linkButton.addEventListener("mouseenter", onTriggerMenu);
@@ -312,7 +312,7 @@ function getLinkMenuData(editor: Zotero.EditorInstance): PopupData[] {
getPref("editor.link.insertPosition")
? node.model.lineIndex - 1
: node.model.endIndex
- }`
+ }`,
),
text: node.model.name,
prefix: "·".repeat(node.model.level - 1),
@@ -323,7 +323,7 @@ function getLinkMenuData(editor: Zotero.EditorInstance): PopupData[] {
async function registerEditorToolbar(
editor: Zotero.EditorInstance,
- id: string
+ id: string,
) {
await editor._initPromise;
const _document = editor._iframeWindow.document;
@@ -359,7 +359,7 @@ async function registerEditorToolbarDropdown(
icon: string,
title: string,
position: "start" | "middle" | "end",
- callback: (e: MouseEvent & { editor: Zotero.EditorInstance }) => any
+ callback: (e: MouseEvent & { editor: Zotero.EditorInstance }) => any,
) {
await editor._initPromise;
const _document = editor._iframeWindow.document;
@@ -386,7 +386,7 @@ async function registerEditorToolbarDropdown(
Object.assign(e, { editor });
if (callback) {
callback(
- e as any as MouseEvent & { editor: Zotero.EditorInstance }
+ e as any as MouseEvent & { editor: Zotero.EditorInstance },
);
}
},
@@ -414,7 +414,7 @@ async function registerEditorToolbarPopup(
dropdown: HTMLDivElement,
id: string,
align: "middle" | "left" | "right",
- popupLines: PopupData[]
+ popupLines: PopupData[],
) {
await editor._initPromise;
const popup = ztoolkit.UI.appendElement(
@@ -449,7 +449,7 @@ async function registerEditorToolbarPopup(
props.callback(
e as any as MouseEvent & {
editor: Zotero.EditorInstance;
- }
+ },
);
},
},
@@ -458,7 +458,7 @@ async function registerEditorToolbarPopup(
}),
removeIfExists: true,
},
- dropdown
+ dropdown,
) as HTMLDivElement;
let style: string = "";
if (align === "middle") {
@@ -476,7 +476,7 @@ async function registerEditorToolbarElement(
editor: Zotero.EditorInstance,
toolbar: HTMLDivElement,
position: "start" | "middle" | "end",
- elem: HTMLElement
+ elem: HTMLElement,
) {
await editor._initPromise;
toolbar.querySelector(`.${position}`)?.append(elem);
diff --git a/src/modules/export/api.ts b/src/modules/export/api.ts
index ffdf401..34573a1 100644
--- a/src/modules/export/api.ts
+++ b/src/modules/export/api.ts
@@ -22,7 +22,7 @@ async function exportNotes(
exportDocx?: boolean;
exportPDF?: boolean;
exportFreeMind?: boolean;
- }
+ },
) {
let inputNoteItems = noteItems;
// If embedLink or exportNote, create a new note item
@@ -51,26 +51,26 @@ async function exportNotes(
if (options.standaloneLink) {
const linkedNoteIds = [] as number[];
for (const noteItem of inputNoteItems) {
- let linkedIds: number[] = getLinkedNotesRecursively(
+ const linkedIds: number[] = getLinkedNotesRecursively(
getNoteLink(noteItem) || "",
- linkedNoteIds
+ linkedNoteIds,
);
linkedNoteIds.push(...linkedIds);
}
const targetNoteItemIds = inputNoteItems.map((item) => item.id);
linkedNoteItems = Zotero.Items.get(
- linkedNoteIds.filter((id) => !targetNoteItemIds.includes(id))
+ linkedNoteIds.filter((id) => !targetNoteItemIds.includes(id)),
);
}
const allNoteItems = Array.from(
- new Set(inputNoteItems.concat(linkedNoteItems))
+ new Set(inputNoteItems.concat(linkedNoteItems)),
);
if (options.exportMD) {
if (options.setAutoSync) {
const raw = await new ztoolkit.FilePicker(
`${getString("fileInterface.sync")} MarkDown File`,
- "folder"
+ "folder",
).open();
if (raw) {
const syncDir = formatPath(raw);
@@ -136,7 +136,7 @@ async function toMD(
filename?: string;
keepNoteLink?: boolean;
withYAMLHeader?: boolean;
- } = {}
+ } = {},
) {
let filename = options.filename;
if (!filename) {
@@ -144,7 +144,7 @@ async function toMD(
`${Zotero.getString("fileInterface.export")} MarkDown File`,
"save",
[["MarkDown File(*.md)", "*.md"]],
- `${noteItem.getNoteTitle()}.md`
+ `${noteItem.getNoteTitle()}.md`,
).open();
if (!raw) return;
filename = formatPath(raw, ".md");
@@ -155,7 +155,7 @@ async function toMD(
async function toSync(
noteItem: Zotero.Item,
syncDir: string,
- overwrite: boolean = false
+ overwrite: boolean = false,
) {
if (!overwrite && addon.api.sync.isSyncNote(noteItem.id)) {
return;
@@ -175,7 +175,7 @@ async function toDocx(noteItem: Zotero.Item) {
`${Zotero.getString("fileInterface.export")} MS Word Docx`,
"save",
[["MS Word Docx File(*.docx)", "*.docx"]],
- `${noteItem.getNoteTitle()}.docx`
+ `${noteItem.getNoteTitle()}.docx`,
).open();
if (!raw) return;
const filename = formatPath(raw, ".docx");
@@ -187,7 +187,7 @@ async function toFreeMind(noteItem: Zotero.Item) {
`${Zotero.getString("fileInterface.export")} FreeMind XML`,
"save",
[["FreeMind XML File(*.mm)", "*.mm"]],
- `${noteItem.getNoteTitle()}.mm`
+ `${noteItem.getNoteTitle()}.mm`,
).open();
if (!raw) return;
const filename = formatPath(raw, ".mm");
@@ -197,9 +197,9 @@ async function toFreeMind(noteItem: Zotero.Item) {
async function embedLinkedNotes(noteItem: Zotero.Item): Promise {
const parser = ztoolkit.getDOMParser();
- let newLines: string[] = [];
+ const newLines: string[] = [];
const noteLines = getLinesInNote(noteItem);
- for (let i in noteLines) {
+ for (const i in noteLines) {
newLines.push(noteLines[i]);
const doc = parser.parseFromString(noteLines[i], "text/html");
const linkParams = Array.from(doc.querySelectorAll("a"))
@@ -210,7 +210,7 @@ async function embedLinkedNotes(noteItem: Zotero.Item): Promise {
const html = await addon.api.template.runTemplate(
"[QuickImportV2]",
"link, noteItem",
- [linkParam.link, noteItem]
+ [linkParam.link, noteItem],
);
newLines.push(html);
}
diff --git a/src/modules/export/docx.ts b/src/modules/export/docx.ts
index 5cc0f0f..9ecd4c5 100644
--- a/src/modules/export/docx.ts
+++ b/src/modules/export/docx.ts
@@ -35,7 +35,7 @@ async function note2docx(noteItem: Zotero.Item) {
jobId,
message: htmlDoc,
},
- "*"
+ "*",
);
await lock.promise;
worker.contentWindow?.removeEventListener("message", listener);
@@ -47,7 +47,7 @@ async function getWorker() {
return addon.data.export.docx.worker;
}
const worker = Zotero.Browser.createHiddenBrowser(
- window
+ window,
) as HTMLIFrameElement;
await waitUtilAsync(() => worker.contentDocument?.readyState === "complete");
@@ -57,11 +57,11 @@ async function getWorker() {
tag: "script",
properties: {
innerHTML: await getFileContent(
- rootURI + "chrome/content/scripts/docxWorker.js"
+ rootURI + "chrome/content/scripts/docxWorker.js",
),
},
},
- doc?.head!
+ doc!.head,
);
addon.data.export.docx.worker = worker;
return worker;
diff --git a/src/modules/export/exportWindow.ts b/src/modules/export/exportWindow.ts
index 95cfd9f..e8cfbb6 100644
--- a/src/modules/export/exportWindow.ts
+++ b/src/modules/export/exportWindow.ts
@@ -17,7 +17,7 @@ enum OPTIONS {
export async function showExportNoteOptions(
noteIds: number[],
- overwriteOptions: Record = {}
+ overwriteOptions: Record = {},
) {
const items = Zotero.Items.get(noteIds);
const noteItems: Zotero.Item[] = [];
@@ -33,17 +33,20 @@ export async function showExportNoteOptions(
return;
}
const dataKeys = Object.keys(OPTIONS).filter(
- (value) => typeof value === "string"
+ (value) => typeof value === "string",
+ );
+ const data = dataKeys.reduce(
+ (acc, key) => {
+ acc[key] = getPref(`export.${key}`) as boolean;
+ return acc;
+ },
+ {} as Record,
);
- const data = dataKeys.reduce((acc, key) => {
- acc[key] = getPref(`export.${key}`) as boolean;
- return acc;
- }, {} as Record);
data.loadCallback = () => {
const doc = dialog.window.document;
const standaloneLinkRadio = doc.querySelector(
- "#standaloneLink"
+ "#standaloneLink",
) as HTMLInputElement;
const autoSyncRadio = doc.querySelector("#setAutoSync") as HTMLInputElement;
function updateSyncCheckbox() {
@@ -56,7 +59,7 @@ export async function showExportNoteOptions(
}
}
Array.from(doc.querySelectorAll('input[name="linkMode"]')).forEach((elem) =>
- elem.addEventListener("change", updateSyncCheckbox)
+ elem.addEventListener("change", updateSyncCheckbox),
);
updateSyncCheckbox();
};
@@ -77,7 +80,7 @@ export async function showExportNoteOptions(
properties: {
innerHTML: `${getString("export.target")}: ${fill(
slice(noteItems[0].getNoteTitle(), 40),
- 40
+ 40,
)}${
noteItems.length > 1 ? ` and ${noteItems.length - 1} more` : ""
}`,
@@ -114,7 +117,7 @@ export async function showExportNoteOptions(
if (data._lastButtonId === "confirm") {
await addon.api.$export.exportNotes(
noteItems,
- Object.assign(data as Record, overwriteOptions)
+ Object.assign(data as Record, overwriteOptions),
);
dataKeys.forEach((key) => {
setPref(`export.${key}`, Boolean(data[key]));
@@ -187,7 +190,7 @@ function makeCheckboxLine(dataKey: string, callback?: (ev: Event) => void) {
function makeRadioLine(
dataKey: string,
radioName: string,
- callback?: (ev: Event) => void
+ callback?: (ev: Event) => void,
) {
return {
tag: "div",
diff --git a/src/modules/export/freemind.ts b/src/modules/export/freemind.ts
index fd1018a..08b26ea 100644
--- a/src/modules/export/freemind.ts
+++ b/src/modules/export/freemind.ts
@@ -12,10 +12,10 @@ export async function saveFreeMind(filename: string, noteId: number) {
async function note2mm(
noteItem: Zotero.Item,
- options: { withContent?: boolean } = { withContent: true }
+ options: { withContent?: boolean } = { withContent: true },
) {
const root = getNoteTree(noteItem, false);
- const textNodeForEach = (e: Node, callbackfn: Function) => {
+ const textNodeForEach = (e: Node, callbackfn: (e: any) => void) => {
if (e.nodeType === document.TEXT_NODE) {
callbackfn(e);
return;
@@ -57,7 +57,7 @@ async function note2mm(
};
const convertNode = (node: TreeModel.Node) => {
mmXML += ``;
if (
options.withContent &&
@@ -70,9 +70,9 @@ async function note2mm(
node.model.lineIndex,
node.hasChildren()
? node.children[0].model.lineIndex
- : node.model.endIndex + 1
+ : node.model.endIndex + 1,
)
- .join("\n")
+ .join("\n"),
)}