2.3.29 • Published 18 days ago

zotero-plugin-toolkit v2.3.29

Weekly downloads
-
License
MIT
Repository
github
Last release
18 days ago

Zotero Plugin Toolkit

Intro

This repo is published as an NPM package zotero-plugin-toolkit, which provides useful APIs for Zotero plugin developers.

API Documentation

Modules

  • ZoteroToolkit: Contains all modules of this library. Start from import ZoteroToolkit from "zotero-plugin-toolkit" to get familiar with the APIs.

  • Basic Tool

  • Tools

    • UI: Create elements and manage them automatically.

    • Reader: Reader instance APIs.

    • ExtraField: Get/set extra fields APIs.

  • Managers

  • Helpers

    • Clipboard: Copy text/rich text/image.

    • FilePicker: Open file picker.

    • ProgressWindow: Open progress window.

    • VirtualizedTable: Create a VirtualizedTable (an advanced table view element, which is used by the Zotero item tree, collections tree, item picker, etc.)

    • Dialog: Create a dialog window(a superset of XUL dialog). With data-binding, auto-layout, and control buttons.

  • Utils

    • Debug Bridge: Use zotero://ztoolkit-debug/?file=x.js&run=y()&password=zzz&app=m

      See https://github.com/windingwind/zotero-plugin-template/blob/main/scripts/reload.mjs for example.

      Parameters (all parameters should be URLEncoded):

      • file: the path of JS file to run if provided. starts with file:///.
      • run: the JS script to run if provided.
      • password: the value of extensions.zotero.debug-bridge.password. If the password is not empty in Zotero and not provided in the call, the command won't run; otherwise a popup will show to ask user if to execute the command.
      • app: The app name to show in the popup.
    • Plugin Bridge: Use zotero://plugin/?action=install&url=x.xpi

      Parameters (all parameters should be URLEncoded):

      • action: install.
      • url: the url of plugin xpi to install.
      • minVersion: the required minimal version of Zotero if provided.
      • maxVersion: the required maximal version of Zotero if provided.

Usage

  1. Run npm install --save zotero-plugin-toolkit.

  2. Import the toolkit class

import ZoteroToolkit from "zotero-plugin-toolkit";
/* Alternatively, import class you need to minify the plugin size
 * ```ts
 * import { BasicTool } from "zotero-plugin-toolkit/dist/basic";
 * import { UITool } from "zotero-plugin-toolkit/dist/tools/ui";
 */
const ztoolkit = new ZoteroToolkit();
  1. Use the toolkit following this API Documentation
ztoolkit.log("This is Zotero:", toolkit.getGlobal("Zotero"));

⚠️All Manager classes have register method with corresponding unregister/unregisterAll. Don't forget to unregister when plugin exits.

This repo depends on zotero-types. See its hompage for more details about Zotero type definitions.

Examples

This package is integrated into the Zotero Plugin Template. You can find examples there.

If you are new to Zotero plugins/looking for solutions to migrate from Zotero 6 to 7, please take a look at that repo.

The API documentation also contains example code for some APIs.

Contributing

Setup

  1. Fork this repo.

  2. Make sure you have nodejs and npm installed. Clone the repo folder and install dependencies:

git clone https://github.com/windingwind/zotero-plugin-toolkit
cd zotero-plugin-toolkit
npm install

Build

Run npm run build.

  • Package .js and .d.ts under ./dist;

  • Documentations under ./docs.

Test Locally

Test it with your plugin or use Zotero Plugin Template as a playground.

Run npm install /path/to/this/repo under the playground repo folder, the lib will be installed from your local build.

The playground uses the latest build. No need to npm install again if you rebuild this lib.

Release

npm run release. Tagged pushes will trigger a npm-publish GitHub action.

Disclaimer

Use this code under MIT License. No warranties are provided. Keep the laws of your locality in mind!

If you want to change the license, please contact me at wyzlshx@foxmail.com

My Zotero Plugins

2.3.29

18 days ago

2.3.28

1 month ago

2.3.26

1 month ago

2.3.24

2 months ago

2.3.25

2 months ago

2.3.23

2 months ago

2.3.22

2 months ago

2.3.21

2 months ago

2.3.20

3 months ago

2.3.17

3 months ago

2.3.19

3 months ago

2.3.16

4 months ago

2.3.13

5 months ago

2.3.15

5 months ago

2.3.14

5 months ago

2.3.12

5 months ago

2.3.11

5 months ago

2.3.10

5 months ago

2.2.1

9 months ago

2.2.0

9 months ago

2.2.3

9 months ago

2.2.2

9 months ago

2.2.5

9 months ago

2.2.4

9 months ago

2.2.7

9 months ago

2.2.6

9 months ago

2.3.8

7 months ago

2.3.7

8 months ago

2.1.9

9 months ago

2.3.9

7 months ago

2.3.0

8 months ago

2.3.2

8 months ago

2.1.4

11 months ago

2.3.1

8 months ago

2.3.4

8 months ago

2.1.6

9 months ago

2.3.3

8 months ago

2.1.5

10 months ago

2.3.6

8 months ago

2.1.8

9 months ago

2.3.5

8 months ago

2.1.7

9 months ago

2.2.9

8 months ago

2.2.8

8 months ago

1.0.7

1 year ago

1.0.6

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.5

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.1

1 year ago

1.1.9

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.2

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.3

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

2.1.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago