feat: add insert annotation

This commit is contained in:
huaqo
2026-04-23 20:13:10 +02:00
parent effe0bbd96
commit 85b152f570
7 changed files with 384 additions and 191 deletions
+47
View File
@@ -0,0 +1,47 @@
import type { ZoteroResponse } from "./ZoteroResponse";
import { ZoteroItem } from "./ZoteroItem";
export class ZoteroAnnotation {
constructor(
public key: string,
public attachmentItemKey: string,
public parentItemKey: string,
public parentItem?: ZoteroItem,
public text: string = "",
public comment: string = "",
public color: string = "",
public pageLabel: string = "",
){}
static fromResponse(item: ZoteroResponse): ZoteroAnnotation {
return new ZoteroAnnotation(
item.key ?? "",
item.data?.parentItem ?? "",
"",
undefined,
item.data?.annotationText ?? "",
item.data?.annotationComment ?? "",
item.data?.annotationColor ?? "",
item.data?.pageLabel ?? "",
);
}
toString(): string {
return [
this.key,
this.text,
this.comment,
this.color,
this.pageLabel,
this.parentItem?.title,
this.parentItem?.creators,
this.parentItem?.year,
this.parentItemKey,
this.attachmentItemKey,
]
.filter(Boolean)
.join(" ");
}
}