For Plugin Developers Looking for Compatibilities Between Zotero 6 and 7

181 views
Skip to first unread message

XY Wong

unread,
Dec 16, 2022, 6:32:21 AM12/16/22
to zotero-dev
Hi,

I've made some updates to the plugin template: https://github.com/windingwind/zotero-addon-template/

New features:
  • A toolkit for migrating from Zotero 6 to Zotero 7. These APIs keep compatibility on both Zotero 6 and 7;
  • UI APIs to maintain plugin elements automatically. Otherwise, you have to remember to clean up elements on the exit;
  • UI APIs for Preference panes on Zotero 6. This allows you to use Prefs on Zotero 6 and only need to maintain one prefs.xhtml for two platforms.
  • UI APIs for menu items, which are the most frequently used in overlay mode. Migrate from overlay easily with these APIs.

The example XPI is here: Releases · windingwind/zotero-addon-template (github.com). Tested on both Zotero 6 and 7.

Snipaste_2022-12-16_19-16-45.png

208078502-75d547b7-1cff-4538-802a-3d5127a8b617.png

XY Wong

unread,
Dec 18, 2022, 2:49:23 AM12/18/22
to zotero-dev
Some updates to the addon template:

  1. Preference pane elements with the `preference` attribute automatically bind to the corresponding Zotero Preference. Once the pref or the element status changes, the other will be updated. (As Zotero 7 acts)
  2. Some global variables: Zotero, ZoteroPane, window, document. They are available in all plugin code scopes, the same as in overlay plugins. This can hugely reduce the work needed to change to Zotero 7.

Here is an example of changing an overlay plugin to bootstrap(which runs on both Zotero 6 and 7) using this template:


Very easy and straightforward! Hope this will be helpful.

黄瓜小王子

unread,
Dec 23, 2022, 6:20:52 AM12/23/22
to zoter...@googlegroups.com
Nice work, I hope this template will save me a lot of work


From: zoter...@googlegroups.com <zoter...@googlegroups.com> on behalf of XY Wong <wyz...@foxmail.com>
Sent: Sunday, December 18, 2022 3:49:23 PM
To: zotero-dev <zoter...@googlegroups.com>
Subject: Re: For Plugin Developers Looking for Compatibilities Between Zotero 6 and 7
 
--
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/42dd2f92-82b8-40a3-a7c2-1fe590aff2d0n%40googlegroups.com.

XY Wong

unread,
Jan 5, 2023, 9:33:35 AM1/5/23
to zotero-dev
Some refactorings and updates: add many new examples to the plugin template. All examples are in `src/modules/examples.ts`

Basic Examples
  • registerNotifier
  • registerPrefs, unregisterPrefs
UI Examples
  • registerStyleSheet(the official make-it-red example)
  • registerRightClickMenuItem
  • registerRightClickMenuPopup
  • registerWindowMenuWithSeprator
  • registerExtraColumn
  • registerExtraColumnWithCustomCell
  • registerCustomCellRenderer
  • registerLibraryTabPanel
  • registerReaderTabPanel
  • unregisterUIExamples
The code structure is also refactored. The plugin template now turns to a modulized event-driven style, more flexible and extensive compared to the object-oriented style.

All event hooks are listed in the `src/hooks.ts`: onStartup, onShutdown, onNotify, onPrefsEvent, and other custom hooks. Functions are in `src/modules`.

Welcome discussions & contributions with new examples!
Reply all
Reply to author
Forward
0 new messages