add: ItemPane custom info row example

This commit is contained in:
windingwind 2024-11-29 10:58:56 +01:00
parent d842292073
commit 255e057006
4 changed files with 23 additions and 0 deletions

View File

@ -8,3 +8,4 @@ item-section-example2-sidenav-tooltip =
.tooltiptext = This is Plugin Template section (reader) .tooltiptext = This is Plugin Template section (reader)
item-section-example2-button-tooltip = item-section-example2-button-tooltip =
.tooltiptext = Unregister this section .tooltiptext = Unregister this section
item-info-row-example-label = Example Row

View File

@ -8,3 +8,4 @@ item-section-example2-sidenav-tooltip =
.tooltiptext = 这是插件模板面板(阅读器) .tooltiptext = 这是插件模板面板(阅读器)
item-section-example2-button-tooltip = item-section-example2-button-tooltip =
.tooltiptext = 移除此面板 .tooltiptext = 移除此面板
item-info-row-example-label = 示例行

View File

@ -28,6 +28,8 @@ async function onStartup() {
await UIExampleFactory.registerExtraColumnWithCustomCell(); await UIExampleFactory.registerExtraColumnWithCustomCell();
UIExampleFactory.registerItemPaneCustomInfoRow();
UIExampleFactory.registerItemPaneSection(); UIExampleFactory.registerItemPaneSection();
UIExampleFactory.registerReaderItemPaneSection(); UIExampleFactory.registerReaderItemPaneSection();

View File

@ -221,6 +221,25 @@ export class UIExampleFactory {
}); });
} }
@example
static registerItemPaneCustomInfoRow() {
Zotero.ItemPaneManager.registerInfoRow({
rowID: "example",
pluginID: addon.data.config.addonID,
editable: true,
label: {
l10nID: getLocaleID("item-info-row-example-label"),
},
position: "afterCreators",
onGetData: ({ item }) => {
return item.getField("title");
},
onSetData: ({ item, value }) => {
item.setField("title", value);
},
});
}
@example @example
static registerItemPaneSection() { static registerItemPaneSection() {
Zotero.ItemPaneManager.registerSection({ Zotero.ItemPaneManager.registerSection({