This commit is contained in:
shenyutao 2024-03-13 17:14:35 +08:00
parent a9d13a20c6
commit f93d22d29b
2 changed files with 5 additions and 10 deletions

View File

@ -30,7 +30,7 @@ async function onMainWindowLoad(win: Window): Promise<void> {
UIFactory.registerRightClickMenuItem();
UIFactory.registerRightClickCollectionMenuItem();
UIFactory.registerTLDRItemBoxRow();
onLoad();

View File

@ -71,7 +71,6 @@ export class UIFactory {
});
}
// tldr行
static async registerTLDRItemBoxRow() {
await ztoolkit.ItemBox.register(
@ -80,20 +79,17 @@ export class UIFactory {
(field, unformatted, includeBaseMapped, item, original) => {
const noteKey = tldrs.get()[item.key];
if (noteKey) {
const obj = Zotero.Items.getByLibraryAndKey(
item.libraryID,
noteKey,
);
const obj = Zotero.Items.getByLibraryAndKey(item.libraryID, noteKey);
if (
obj &&
obj instanceof Zotero.Item &&
item.getNotes().includes(obj.id)
) {
let str = obj.getNote();
if (str.startsWith('<p>TL;DR</p>\n<p>')) {
str = str.slice('<p>TL;DR</p>\n<p>'.length);
if (str.startsWith("<p>TL;DR</p>\n<p>")) {
str = str.slice("<p>TL;DR</p>\n<p>".length);
}
if (str.endsWith('</p>')) {
if (str.endsWith("</p>")) {
str = str.slice(0, -4);
}
return str;
@ -118,5 +114,4 @@ export class UIFactory {
},
);
}
}