From 82ad3d5bc0e4d0e789b954b143c34ccd0a2dc259 Mon Sep 17 00:00:00 2001
From: "zhoulibin@xiaoxin" <125377187@qq.com>
Date: Tue, 23 Jul 2024 00:14:37 +0800
Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=9D=A1=E7=9B=AE=E4=B8=8B?=
=?UTF-8?q?=E6=89=80=E6=9C=89PDF=E6=96=87=E4=BB=B6=E5=92=8C=E6=B3=A8?=
=?UTF-8?q?=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/action/action-annotation-row.ts | 15 +++++-------
src/modules/annotationsToNote.tsx | 38 ++++++++++++++---------------
src/utils/zzlb.ts | 24 +++++++++---------
3 files changed, 37 insertions(+), 40 deletions(-)
diff --git a/src/action/action-annotation-row.ts b/src/action/action-annotation-row.ts
index 7f8708b3..532a9ea7 100644
--- a/src/action/action-annotation-row.ts
+++ b/src/action/action-annotation-row.ts
@@ -168,20 +168,18 @@ export function init() {
async function getHtml() {
const selectedItems = ZoteroPane.getSelectedItems();
const item = selectedItems[0];
- //if (!item) return null; // 提前退出,如果没有选中的项
- //@ts-ignore isEPUBAttachment
+ //if (!item) return null; // 提前退出,如果没有选中的项
const attachments = Zotero.Items.get(item.getAttachments()).filter(
(i) =>
i.isPDFAttachment() ||
i.isSnapshotAttachment() ||
- // @ts-ignore isEPUBAttachment
i.isEPUBAttachment() ||
i.isWebAttachment(),
);
let res = `
${item.getField("title")}
`;
const allAnnotations = []; // 在函数作用域内声明数组来收集所有注释
for (const attachment of attachments) {
- //@ts-ignore getFilename
+
res += `@@@${attachment.getFilename()}
`;
const annotations = attachment.getAnnotations();
allAnnotations.push(...annotations); // 使用扩展运算符将annotations数组的每个元素添加到allAnnotations数组中
@@ -203,13 +201,12 @@ export function init() {
annotationObj.attachmentItemID = annotationItem.parentItem?.id; // @ts-ignore 111
delete annotationObj.key;
for (const key in annotationObj) {
- // @ts-ignore 111
+
annotationObj[key] = annotationObj[key] || "";
- } // @ts-ignore 111
+ }
annotationObj.tags = annotationObj.tags || [];
return annotationObj;
} catch (e2) {
- // @ts-ignore 111
Zotero.logError(e2);
return null;
}
@@ -226,9 +223,9 @@ export function init() {
const annotationJSONList = [] as _ZoteroTypes.Annotations.AnnotationJson[];
for (const ann of annotations) {
const annJson = await parseAnnotationJSON(ann);
- //@ts-ignore11111
+
if (options.ignoreComment && annJson?.comment) {
- //@ts-ignore11111
+
annJson.comment = "";
}
if (annJson) annotationJSONList.push(annJson);
diff --git a/src/modules/annotationsToNote.tsx b/src/modules/annotationsToNote.tsx
index 4aa34d5e..666556cc 100644
--- a/src/modules/annotationsToNote.tsx
+++ b/src/modules/annotationsToNote.tsx
@@ -124,7 +124,7 @@ function buildMenu(collectionOrItem: "collection" | "item") {
{
//粘贴pdf注释
tag: "menuitem",
- label: "粘贴条目下pdf注释",
+ label: "粘贴条目下pdf注释-用作者年份标题识别不同的条目",
icon: iconBaseUrl + "favicon.png",
commandListener: async (ev: Event) => {
const items = await getSelectedItems(collectionOrItem);
@@ -217,7 +217,7 @@ function buildMenu(collectionOrItem: "collection" | "item") {
{
//相同PDF合并,注释合并
tag: "menuitem",
- label: "相同PDF合并,注释合并",
+ label: "合并条目下所有PDF文件和注释",
icon: iconBaseUrl + "favicon.png",
commandListener: async (ev: Event) => {
const items = await getSelectedItems(collectionOrItem);
@@ -1836,24 +1836,24 @@ function createActionTag(div: HTMLElement | undefined, action: () => void | unde
// },
action
? {
- tag: "button",
- namespace: "html",
- properties: { textContent: "确定生成" },
- // styles: {
- // padding: "6px",
- // background: "#f99",
- // margin: "1px",
- // },
- listeners: [
- {
- type: "click",
- listener: (ev: any) => {
- stopPropagation(ev);
- action();
- },
+ tag: "button",
+ namespace: "html",
+ properties: { textContent: "确定生成" },
+ // styles: {
+ // padding: "6px",
+ // background: "#f99",
+ // margin: "1px",
+ // },
+ listeners: [
+ {
+ type: "click",
+ listener: (ev: any) => {
+ stopPropagation(ev);
+ action();
},
- ],
- }
+ },
+ ],
+ }
: { tag: "span" },
...others,
];
diff --git a/src/utils/zzlb.ts b/src/utils/zzlb.ts
index c52684cb..1314c235 100644
--- a/src/utils/zzlb.ts
+++ b/src/utils/zzlb.ts
@@ -278,12 +278,12 @@ const memAllTagsInLibraryAsync = memoize(async () => {
);
const itemTags = getPref("item-tags")
? items.flatMap((f) =>
- f.getTags().map((a) => ({
- tag: a.tag,
- type: a.type,
- dateModified: f.dateModified,
- })),
- )
+ f.getTags().map((a) => ({
+ tag: a.tag,
+ type: a.type,
+ dateModified: f.dateModified,
+ })),
+ )
: [];
return groupBy([...tags, ...itemTags], (t14) => t14.tag);
});
@@ -409,7 +409,7 @@ export async function openAnnotation(itemOrKeyOrId: Zotero.Item | string | numbe
}
}
-export async function injectCSSToReader() {}
+export async function injectCSSToReader() { }
export const memSVG = memoize(
async (href) => await getFileContent(href),
@@ -445,11 +445,11 @@ export async function injectCSS(doc: Document | HTMLDivElement, filename: string
ignoreIfExists: true,
},
doc.querySelector("linkset") ||
- doc.querySelector("head") ||
- doc.querySelector("body") ||
- doc.querySelector("div") ||
- doc.children[0] ||
- doc,
+ doc.querySelector("head") ||
+ doc.querySelector("body") ||
+ doc.querySelector("div") ||
+ doc.children[0] ||
+ doc,
);
// ztoolkit.log("加载css", d);
}