windingwind / zotero-plugin-toolkit

Toolkit for Zotero Plugin Developers.
https://www.npmjs.com/package/zotero-plugin-toolkit
MIT License
112 stars 13 forks source link
npm-package zotero zotero-addon zotero-api zotero-plugin

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

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";
 * import { UITool } from "zotero-plugin-toolkit";
 */
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.

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