How can I open my own XHTML dialog in a plugin?

44 views
Skip to first unread message

Alain Borel

unread,
Jul 21, 2025, 8:31:19 AMJul 21
to zotero-dev
Hello everybody,

I'm trying to update the obsolete Zotero ODF Scan plugin https://zotero-odf-scan.github.io/zotero-odf-scan/ for Zotero 7 (hopefully v8 as well...) - it looks like it could be useful for some people, for example Scrivener users (as seen on https://forums.zotero.org/discussion/comment/490952#Comment_490952 , for example).

Right now I'm stuck with something that looks very basic, so I'm probably missing something along the way.

When the relevant command is selected from the main menu, the plugin needs to open a dialog similar to what the native Zotero RTF scan. I have looked at the Zotero Github repository, apparently the dialog is opened from chrome/content/zotero/zoteroPane.xhtml as:

window.openDialog('chrome://zotero/content/rtfScan.xhtml', 'rtfScan', 'chrome,centerscreen');

This also works when I copy it vertbatim into my Javascript code, but when I try to specifiy my own XHTML template as the first argument nothing happens. Not even en error message.
I guess I need to figure out the proper reference to the resource inside my plugin, but I don't understand how to do that. I have tried several variants (just the file name, rootURI + filename, ...) nothing seems to work.
In case something was wrong with my XHTML I have included a copy of the original rtfScan.xhtml in my XPI as myrtfScan.xhtml and tried to load that, but it doesn't change anything: the dialog doesn't open.,

Can anybody tell me what I should do? It's probably quite simple but I'd be happy if someone could offer their guidance.

Thanks in advance,
Alain Borel

XY Wong

unread,
Jul 21, 2025, 8:33:55 AMJul 21
to zotero-dev
Please make sure you register the resources before accessing them with `chrome://`. For example: https://github.com/windingwind/zotero-plugin-template/blob/dfd8682d771bd96fda9fcec4d9a5f3b8591d9447/addon/bootstrap.js#L20-L26

Alain Borel

unread,
Jul 21, 2025, 9:02:17 AMJul 21
to zotero-dev
Thanks for the pointer but I'm still  not getting it. I have copied lines 20-26 from the plugin template into my bootstrap.js (and declared the chromeHandle variable at the top).
My main script does this:

window.openDialog('chrome://content/myRtfScan.xhtml', 'odfScan', 'chrome,centerscreen');

Still no dialog or relevant error message as far as I can see. A log instruction I have inserted just after the window.openDialog() call is running just fine, so there's no sign of a crash either.

I'm not even sure I want/need to use `chrome://` , I'd be quite happy with a relative path if it's possible

Sorry if I'm being dense...
Alain

XY Wong

unread,
Jul 21, 2025, 9:06:35 AMJul 21
to zotero-dev
The URL will be `chrome://content/${YOUR_DEFINED_KEY}/myRtfScan.xhtml`, depending on what key you gave to the registration. Also please make sure the registration resource location is correctly pointing to the folder in your plugin.

XY Wong

unread,
Jul 21, 2025, 9:07:09 AMJul 21
to zotero-dev
Sorry, it should be `chrome://${YOUR_DEFINED_KEY}/content/myRtfScan.xhtml`

Alain Borel

unread,
Jul 22, 2025, 1:59:39 AMJul 22
to zotero-dev
All right!

Opening my dialog is working now. Back to work :-)

Thanks again,
Alain
Reply all
Reply to author
Forward
0 new messages