This commit is contained in:
ytshen 2024-04-16 22:56:23 +08:00
parent 50956fefff
commit a26f5fd0a9
6 changed files with 51 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,4 @@
itemPaneSection-header =
.label = 翻译
itemPaneSection-sidenav =
.tooltiptext = 翻译

View File

@ -0,0 +1,4 @@
itemPaneSection-header =
.label = 翻译
itemPaneSection-sidenav =
.tooltiptext = 翻译

View File

@ -41,7 +41,7 @@
},
"homepage": "https://github.com/syt2/zotero-tldr#readme",
"dependencies": {
"zotero-plugin-toolkit": "^2.3.25"
"zotero-plugin-toolkit": "^2.3.29"
},
"devDependencies": {
"@types/node": "^20.4.2",
@ -58,6 +58,6 @@
"release-it": "^16.1.0",
"replace-in-file": "^7.0.1",
"typescript": "^5.1.6",
"zotero-types": "^1.0.16"
"zotero-types": "^1.3.11"
}
}
}

View File

@ -73,6 +73,46 @@ export class UIFactory {
// tldr行
static async registerTLDRItemBoxRow() {
const registeredID = Zotero.ItemPaneManager.registerSection({
paneID: config.addonRef,
pluginID: config.addonID,
header: {
l10nID: `${config.addonRef}-itemPaneSection-header`,
icon: `chrome://${config.addonRef}/content/icons/favicon@16.png`,
},
sidenav: {
l10nID: `${config.addonRef}-itemPaneSection-sidenav`,
icon: `chrome://${config.addonRef}/content/icons/favicon@20.png`,
},
onRender: ({ body, item, editable, tabType }: any) => {
const noteKey = tldrs.get()[item.key];
let str = "";
if (noteKey) {
const obj = Zotero.Items.getByLibraryAndKey(item.libraryID, noteKey);
if (
obj &&
obj instanceof Zotero.Item &&
item.getNotes().includes(obj.id)
) {
str = obj.getNote();
if (str.startsWith("<p>TL;DR</p>\n<p>")) {
str = str.slice("<p>TL;DR</p>\n<p>".length);
}
if (str.endsWith("</p>")) {
str = str.slice(0, -4);
}
}
}
body.textContent = str;
// body.textContent
// = JSON.stringify({
// id: item?.id,
// editable,
// tabType,
// });
},
});
return;
await ztoolkit.ItemBox.register(
"TLDR",
getString("itembox-tldrlabel"),