feat: create annotation note with tags

resolve: #5
This commit is contained in:
xiangyu 2022-05-16 16:55:37 +08:00
parent 69365cad14
commit 982e4efc0b
3 changed files with 7 additions and 6 deletions

View File

@ -783,6 +783,10 @@ class AddonEvents extends AddonBase {
`<div data-schema-version="8"><p>${annotationItem.annotationComment}</p>\n</div>`
);
}
const tags = annotationItem.getTags();
for (const tag of tags) {
note.addTag(tag.tag, tag.type);
}
await note.saveTx();
let libraryID = note.libraryID;
let library = Zotero.Libraries.get(libraryID);

View File

@ -327,11 +327,11 @@ class AddonViews extends AddonBase {
updateButton.setAttribute("id", "update-note-link");
updateButton.setAttribute(
"title",
`Update Linked Note: ${note.getNoteTitle()}`
`Update Link Text: ${note.getNoteTitle()}`
);
updateButton.innerHTML = `<svg t="1652685521153" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7063" width="16" height="16"><path d="M271.914667 837.418667C182.314667 756.522667 128 637.653333 128 508.714667 128 304.896 263.338667 129.834667 450.986667 85.333333L469.333333 170.026667c-150.016 35.584-258.304 175.658667-258.304 338.688 0 106.069333 45.866667 203.562667 121.258667 268.373333L426.666667 682.666667v256H170.666667l101.248-101.248zM727.082667 168.917333C831.530667 249.045333 896 377.088 896 517.077333c0 202.922667-135.338667 377.258667-322.986667 421.589334L554.666667 854.357333c150.016-35.456 258.304-174.933333 258.304-337.322666 0-117.12-56.405333-223.786667-146.901334-287.146667L554.666667 341.333333V85.333333h256l-83.584 83.584z" p-id="7064"></path></svg>`;
updateButton.addEventListener("click", async (e) => {
Zotero.debug("Update Linked Note");
Zotero.debug("ZBN: Update Link Text");
const noteLines = this._Addon.knowledge.getLinesInNote();
let line = noteLines[this._Addon.knowledge.currentLine];
Zotero.debug(line);
@ -343,7 +343,6 @@ class AddonViews extends AddonBase {
let linkPart = line.slice(linkStart, linkEnd);
let link = this._Addon.knowledge.getLinkFromText(linkPart);
let currentNote: ZoteroItem;
Zotero.debug(link);
if (link) {
currentNote = (await this._Addon.knowledge.getNoteFromLink(link))
.item;
@ -367,9 +366,6 @@ class AddonViews extends AddonBase {
currentNote = (await this._Addon.knowledge.getNoteFromLink(link))
.item;
}
Zotero.debug("----");
Zotero.debug(link);
Zotero.debug(linkPart);
}
if (!linkPart) {
return;

1
typing/global.d.ts vendored
View File

@ -89,6 +89,7 @@ declare interface ZoteroItem {
isAttachment: () => boolean;
isAnnotation: () => boolean;
isPDFAttachment: () => boolean;
addTag: (name: string, type: number) => boolean;
itemTypeID: number;
libraryID: number;
parentID: number;