ZoteroPane

99 views
Skip to first unread message

Emiliano Heyns

unread,
Jun 6, 2023, 3:54:51 AM6/6/23
to zotero-dev
What is ZoteroPane, conceptually? I know it gathers some functionality that's centered around the main UI, but is that just it, functionality gathered for the main UI?

I also see there can be more than one (given getZoteroPanes), how am I to understand that, and can I get the associated Window objects from these ZoteroPanes?

Dan Stillman

unread,
Jun 6, 2023, 4:59:25 AM6/6/23
to zoter...@googlegroups.com
On 6/6/23 3:54 AM, Emiliano Heyns wrote:
> What is ZoteroPane, conceptually? I know it gathers some functionality
> that's centered around the main UI, but is that just it, functionality
> gathered for the main UI?

It's window-level functionality. `Zotero` is XPCOM scope, so it's code
unrelated to a window, whereas `ZoteroPane` applies to the main window,
with functions that access `window` and `document`. On a literal level,
zoteroPane.js is just a script loaded by zoteroPane.xhtml, which is the
document for the main Zotero window.

I'm sure there are a few functions that don't technically belong there
because they don't access properties of the window, but mostly that's
what it is.

> I also see there can be more than one (given getZoteroPanes), how am I
> to understand that

That's for the once and future (and current, if you find the right hack)
ability to open multiple Zotero library windows.

> can I get the associated Window objects from these ZoteroPanes?

You would generally get the ZoteroPane from the window
(window.ZoteroPane), not the other way around, but
`ZoteroPane.document.ownerGlobal` would give you the window.

Emiliano Heyns

unread,
Jun 6, 2023, 8:00:59 AM6/6/23
to zotero-dev
When monkey-patching itemTree.prototype._renderCell, which `document` should I use there to make new elements? Zotero.getMainWindow().document ?

Dan Stillman

unread,
Jun 6, 2023, 6:05:59 PM6/6/23
to zoter...@googlegroups.com
On 6/6/23 8:00 AM, Emiliano Heyns wrote:
> When monkey-patching itemTree.prototype._renderCell, which `document`
> should I use there to make new elements? Zotero.getMainWindow().document ?

No, you'd want to get the document that it's a part of. Haven't tested,
but should be tree.window.document.

https://github.com/zotero/zotero/blob/6106e379c96a26897ead32a300190e2327a11f3e/chrome/content/zotero/libraryTree.js#L46-L48

Emiliano Heyns

unread,
Jun 6, 2023, 6:44:02 PM6/6/23
to zotero-dev
That looks to work perfectly, thanks!

Emiliano Heyns

unread,
Jul 24, 2023, 7:36:19 AM7/24/23
to zotero-dev
I am patching itemTree.prototype.getColumns and itemTree.prototype._renderCell (for both Zotero 6 and 7) to add the citekey column, but when reloading the main window on MacOS (cmd-w and reopen), the citekey column is missing. I had expected this patch to survive across a reopening of ZoteroPane. Should I re-patch these two on reload?

XY Wong

unread,
Jul 24, 2023, 10:02:36 PM7/24/23
to zotero-dev
The new API to register custom columns is on the way, so at least on Z7 you don't need to monkey-patch it anymore. And on Z6, I'm afraid yes, you need to detect window close/reopen and patch again.

Emiliano Heyns

unread,
Jul 24, 2023, 10:11:14 PM7/24/23
to zotero-dev
I tried re-patching, but it had no effect. The citation key column was absent from the column picker.

Will the availability of the new API be announced here?

XY Wong

unread,
Jul 24, 2023, 10:18:02 PM7/24/23
to zotero-dev
Yes. Sorry, I do not have much time to investigate how to do that on Z6, but the API works well after the main window close-reopen on Z7.
Reply all
Reply to author
Forward
0 new messages