update
This commit is contained in:
parent
b56669ae8f
commit
735da8a43a
|
|
@ -18,13 +18,13 @@
|
|||
"\tremoveIfExists: ${13:true},",
|
||||
"\tcustomCheck: (doc: Document, options: ElementOptions) => ${14:true},",
|
||||
"\tchildren: [$15]",
|
||||
"}, ${16:container});"
|
||||
]
|
||||
"}, ${16:container});",
|
||||
],
|
||||
},
|
||||
"appendElement - minimum": {
|
||||
"scope": "javascript,typescript",
|
||||
"prefix": "appendElement",
|
||||
"body": "appendElement({ tag: '$1' }, $2);"
|
||||
"body": "appendElement({ tag: '$1' }, $2);",
|
||||
},
|
||||
"register Notifier": {
|
||||
"scope": "javascript,typescript",
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
"\t) => {",
|
||||
"\t\t$0",
|
||||
"\t}",
|
||||
"});"
|
||||
]
|
||||
}
|
||||
"});",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ function onUpdateItems(items: Zotero.Item[], forceFetch: boolean = false) {
|
|||
if (!item.getField("title")) {
|
||||
return false;
|
||||
}
|
||||
if (!forceFetch && (item.key in tldrs.get())) {
|
||||
if (!forceFetch && item.key in tldrs.get()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -119,4 +119,6 @@ export class DataStorage {
|
|||
}
|
||||
}
|
||||
|
||||
export const tldrs = DataStorage.instance<string, string | false>("fetchedItems.json");
|
||||
export const tldrs = DataStorage.instance<string, string | false>(
|
||||
"fetchedItems.json",
|
||||
);
|
||||
|
|
|
|||
|
|
@ -38,21 +38,28 @@ export class TLDRFetcher {
|
|||
match = true;
|
||||
}
|
||||
if (match && info.tldr) {
|
||||
let note = new Zotero.Item('note');
|
||||
let note = new Zotero.Item("note");
|
||||
if (noteKey) {
|
||||
const obj = Zotero.Items.getByLibraryAndKey(this.zoteroItem.libraryID, noteKey);
|
||||
if (obj && obj instanceof Zotero.Item && this.zoteroItem.getNotes().includes(obj.id)) {
|
||||
const obj = Zotero.Items.getByLibraryAndKey(
|
||||
this.zoteroItem.libraryID,
|
||||
noteKey,
|
||||
);
|
||||
if (
|
||||
obj &&
|
||||
obj instanceof Zotero.Item &&
|
||||
this.zoteroItem.getNotes().includes(obj.id)
|
||||
) {
|
||||
note = obj;
|
||||
}
|
||||
}
|
||||
note.setNote(`<p>TL;DR</p>\n<p>${info.tldr}</p>`)
|
||||
note.setNote(`<p>TL;DR</p>\n<p>${info.tldr}</p>`);
|
||||
note.parentID = this.zoteroItem.id;
|
||||
await note.saveTx();
|
||||
await tldrs.modify((data: any) => {
|
||||
data[this.zoteroItem.key] = note.key;
|
||||
return data;
|
||||
});
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
await tldrs.modify((data: any) => {
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
"target": "ES2016",
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true
|
||||
"strict": true,
|
||||
},
|
||||
"include": ["src", "typings", "node_modules/zotero-types"],
|
||||
"exclude": ["build", "addon"]
|
||||
"exclude": ["build", "addon"],
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue