Zotero Plugin Template and TypeScript Definition Package Available Now

244 views
Skip to first unread message

XY Wong

unread,
Aug 29, 2022, 7:36:48 AM8/29/22
to zotero-dev
Hi everyone,

I'm the author of these plugins: PDF Translate, Better Notes, PDF Preview, and Zotero Tag.

I introduce two repos to those who want to create their own plugin and developers that would definitely be helpful:
- The Zotero Plugin Template/Framework: https://github.com/windingwind/zotero-addon-template
- The NPM package of TypeScript definition d.ts for Zotero: https://github.com/windingwind/zotero-types (npm page: https://www.npmjs.com/package/zotero-types). You can also use it as a handbook of Zotero API.

As a Zotero plugin developer, I've been using TypeScript(TS ) in my several plugins for a long time. TS is more advanced than JS, making it easier to maintain the plugins using auto-complete and type-checking and preventing possible type bugs.

I've witnessed many Zotero users who want to create a plugin to customize their Zotero.  However, to the best of my knowledge, there are NO Zotero plugin frameworks using TS for beginners and the official documentation is out-of-date.

I've also witnessed many Zotero plugin owners spending a lot of time debugging tons of JavaScript code, without auto-complete and type-checking. Using TS could be a solution, but most developers are not familiar with TS and do not know how to.

If you want to start coding your own Zotero plugin, I recommend you to start with the Zotero Plugin Template and you can run the Hello World demo in 5 minutes if you are familiar with any programming language.

If you are a Zotero plugin maintainer or owner, I strongly recommend you migrate to TS with this typing package!

I and two other authors write a documentation about how to create your Zotero plugin(in Chinese): https://zotero-chinese.feishu.cn/wiki/wikcn2498hSjibbd4vDRre5pPmQ

*The typing package is not complete or fully correct yet. I test it in my plugins. If you find any declaration missing or incorrect, please post an issue or pr on Github.

Bo An

unread,
Aug 29, 2022, 12:53:30 PM8/29/22
to zotero-dev
Hi XY,

Thanks so much. retorquere's plugin generator supports Typescript, which I currently use (https://github.com/retorquere/generator-zotero-plugin), but your template is certainly a welcome addition!

And thank you for the definitions! It's much more complete than the one I was using.

Great work!

Best,
Bo

Dan Stillman

unread,
Sep 1, 2022, 5:45:14 PM9/1/22
to zoter...@googlegroups.com
This should be changed to create bootstrapped extensions. Zotero 7 will
support bootstrapped extensions exclusively, so any work on an overlay
extension at this point would be time wasted. (We'll have more info on
Zotero 7 soon.)

See Zutilo for an example of a bootstrapped extension.

XY Wong

unread,
Sep 2, 2022, 11:53:52 AM9/2/22
to zotero-dev
Thank you, Dan, glad to know Zotero 7 is on the way.

It should not be too complicated to switch to bootstrapped I guess. Not very familiar with that. I'll check what I can do.

XY Wong

unread,
Sep 4, 2022, 11:08:35 PM9/4/22
to zotero-dev
BTW, would XUL elements be supported in the Zotero 7?

And is it possible to provide another way to allow plugins to add content to the Zotero pref-window, as overlay will no longer be supported?
Many plugins use an overlay to add their settings page to the pref-window. Would it be possible to have an official API to add the elements to the pref-window? Otherwise, plugins may have to add extra entrance in the menus for their setting windows, which would break user habits(and watching if the pref-window is opened is not that efficient)

Sorry if I have any misunderstanding. Thank you and the Zotero team for the excellent platform for plugin developers!
在2022年9月2日星期五 UTC+8 05:45:14<Dan Stillman> 写道:

Dan Stillman

unread,
Sep 5, 2022, 9:28:20 PM9/5/22
to zoter...@googlegroups.com
We're going to be providing much more info on Zotero 7 soon.

Short answers for these questions:

1) It's complicated.

2) Yes, there'll be a new way to add a pref pane.
--
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 on the web visit https://groups.google.com/d/msgid/zotero-dev/461951bc-2775-44bd-ad83-76eba4a23c07n%40googlegroups.com.

XY Wong

unread,
Sep 13, 2022, 12:54:06 AM9/13/22
to zotero-dev
Hi,
I've made a new branch `bootstrap` for this addon template, which is also set to the default branch.

The addon will be loaded using `addon/bootstrap.js` and the root object will be injected to `Zotero` as always. Unlike Zutilo, which loads the root object of the addon independently, hooking it under `Zotero` is more convenient.

See logic init in `src/events.ts` and UI init in`src/views.ts`. The `addon/overlay.xul` is removed now.

Once more APIs are available for bootstrap mode addons, I'll add them to the `zotero-types` package.

Reply all
Reply to author
Forward
0 new messages