New official API for custom rows in the item pane's info section

509 views
Skip to first unread message

XY Wong

unread,
Nov 15, 2024, 7:29:40 AM11/15/24
to zotero-dev
Hi everyone!

I am glad to announce that the new official API for the custom row in the item pane's info section is ready.

Zotero 7.0.10-beta.2 adds an API for creating a custom row in the item pane's info section.


We will continuously bring more APIs in the future.

Emiliano Heyns

unread,
Nov 17, 2024, 10:20:30 AM11/17/24
to zotero-dev
Can a refresh function be added? I will be using this to display the BBT citation key, and that can change without the item changing.

XY Wong

unread,
Nov 21, 2024, 8:47:49 AM11/21/24
to zotero-dev
Since 7.0.10-beta.3+56ae6d979, you can use `Zotero.ItemPaneManager.refreshInfoRow(rowID)` to trigger an update to the fields refresh, only if your data source isn't bound to the item changing. The `rowID` is the return of the `registerInfoRow()` call.

Emiliano Heyns

unread,
Nov 21, 2024, 9:36:33 AM11/21/24
to zotero-dev
Can I check what item is being displayed, so I don't call it unnecessarily?

XY Wong

unread,
Nov 21, 2024, 9:43:25 AM11/21/24
to zotero-dev
Unfortunately I think that's not possible. There can be multiple instances of the info box and it's impossible to check what items they are displaying.

Emiliano Heyns

unread,
Nov 21, 2024, 9:46:28 AM11/21/24
to zotero-dev
That means it's OK for me to call this if any citekey changes then?

XY Wong

unread,
Nov 21, 2024, 9:54:31 AM11/21/24
to zotero-dev
Calling a refresh will force all info boxes to fetch the string of the specific row from its `onGetData` and assign it to the DOM, that's all the performance cost it will take. I think it would be fine if this call isn't repeated at a super high frequency.

Emiliano Heyns

unread,
Nov 26, 2024, 2:25:06 PM11/26/24
to zotero-dev
It won't happen frequently, and it's fast even on very large databases.

Emiliano Heyns

unread,
Nov 26, 2024, 2:29:06 PM11/26/24
to zotero-dev
Will there be something similar for registerColumn(s)?

XY Wong

unread,
Nov 26, 2024, 6:23:11 PM11/26/24
to zoter...@googlegroups.com
Can use Zotero.ItemTreeManager.refreshColumns()

Note that the item tree cannot be partially refreshed and this call will refresh the whole table.

--
You received this message because you are subscribed to a topic in the Google Groups "zotero-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zotero-dev/LlIz_maLBCU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zotero-dev+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/zotero-dev/1f1d28c6-1aaa-41bc-9d0b-a73b3511b068n%40googlegroups.com.

Emiliano Heyns

unread,
Nov 27, 2024, 3:29:01 AM11/27/24
to zotero-dev
Can I see whether my column is being displayed? That would cut down on unnecessary refreshes. Citekey displays are fast, but I can't speak for the rest of the columns.

XY Wong

unread,
Nov 27, 2024, 5:01:06 AM11/27/24
to zotero-dev
For now, you can check `ZoteroPane.itemPane.itemsView._columnPrefs[columnDataKey].hidden`, where the `columnDataKey` is the return of the `registerColumn`.

Emiliano Heyns

unread,
Nov 28, 2024, 10:51:25 AM11/28/24
to zotero-dev
I have this code:

const rowID = Zotero.ItemPaneManager.registerInfoRow({
            rowID: 'better-bibtex-citation-key',
            pluginID: 'better...@iris-advies.com',
            label: { l10nID: 'better-bibtex_item-pane_info_citation-key_label' },
            position: 'start',
            multiline: false,
            nowrap: false,
            editable: false,
            onGetData({ item }) {
              log.debug('3081:', item.id, item.getField('citationKey'))
              return item.getField('citationKey') as string
            },
            /*
            onSetData({ rowID, item, tabType, editable, value }) {
              Zotero.debug(`Set custom info row ${rowID} of item ${item.id} to ${value}`);
            },
            */
          })

but the field keeps displaying the value of the first item it happened to display, and I don't see anything in the logs when I click around (getField is monkey-patched to retrieve the citationKey, but I have also added logging there, and I also don't see those). No relevant errors in the log.

XY Wong

unread,
Nov 29, 2024, 4:33:50 AM11/29/24
to zotero-dev
Thanks for the feedback. Will be fixed soon.

Emiliano Heyns

unread,
Nov 29, 2024, 8:29:26 AM11/29/24
to zotero-dev
On Wednesday, November 27, 2024 at 12:23:11 AM UTC+1 XY Wong wrote:
Can use Zotero.ItemTreeManager.refreshColumns()

Note that the item tree cannot be partially refreshed and this call will refresh the whole table.

And the item pane, apparently, which seems undesirable: https://github.com/retorquere/zotero-better-bibtex/issues/3094

XY Wong

unread,
Nov 29, 2024, 10:28:56 AM11/29/24
to zotero-dev
Could you please provide the steps to reproduce the issue?

Dan Stillman

unread,
Nov 30, 2024, 12:47:07 AM11/30/24
to zoter...@googlegroups.com
This should be fixed in the latest beta, 7.0.11-beta.2.

Dan Stillman

unread,
Dec 6, 2024, 9:44:20 AM12/6/24
to zoter...@googlegroups.com
Fixed now in 7.0.11.

Do test before using!
--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zotero-dev+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/zotero-dev/010001937b9bbd90-9a26eb1b-b9cc-472b-949b-78d94070564b-000000%40email.amazonses.com.

Emiliano Heyns

unread,
Jan 13, 2025, 9:51:52 AMJan 13
to zotero-dev
Works! Is there a way to show info in the row that is not part of the data? I want to show whether a key is pinned; I'd rather not add the pin icon to the displayed field (interferes with copy-paste) and I don't see a way I can add it dynamically to the label.

XY Wong

unread,
Jan 13, 2025, 10:01:31 AMJan 13
to zotero-dev
Currently, no - but it's possible to allow plugins to change `l10nArgs` in the future so that you can dynamically change the label.

Although probably we can add support for buttons in custom field rows in the future, they would be hidden unless hovered, as other field buttons. Other elements or direct UI access here are not allowed for UI consistency. Thus, custom buttons/icons might not be useful to indicate if a key is pinned.

Do you think changing the l10nArgs of the label would fulfill your need?

Emiliano Heyns

unread,
Jan 13, 2025, 10:08:29 AMJan 13
to zotero-dev
Yep, that would do it, I'm using '\uD83D\uDCCC' as a pin, and I could just replace that with a space when it's not pinned
Reply all
Reply to author
Forward
0 new messages