Skip to content

Commit

Permalink
add: ItemPane custom info row example
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Nov 29, 2024
1 parent d842292 commit 255e057
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions addon/locale/en-US/mainWindow.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ item-section-example2-sidenav-tooltip =
.tooltiptext = This is Plugin Template section (reader)
item-section-example2-button-tooltip =
.tooltiptext = Unregister this section
item-info-row-example-label = Example Row
1 change: 1 addition & 0 deletions addon/locale/zh-CN/mainWindow.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ item-section-example2-sidenav-tooltip =
.tooltiptext = 这是插件模板面板(阅读器)
item-section-example2-button-tooltip =
.tooltiptext = 移除此面板
item-info-row-example-label = 示例行
2 changes: 2 additions & 0 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ async function onStartup() {

await UIExampleFactory.registerExtraColumnWithCustomCell();

UIExampleFactory.registerItemPaneCustomInfoRow();

UIExampleFactory.registerItemPaneSection();

UIExampleFactory.registerReaderItemPaneSection();
Expand Down
19 changes: 19 additions & 0 deletions src/modules/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
static registerItemPaneSection() {
Zotero.ItemPaneManager.registerSection({
Expand Down

0 comments on commit 255e057

Please sign in to comment.