zotero-plugin-toolkit 中文文档教程
Zotero插件工具包
简介
此存储库作为NPM包zotero-plugin-toolkit发布,它提供了有用的API适用于 Zotero 插件开发人员。
模块
ZoteroToolkit:包含以下所有模块这个图书馆。从
从“zotero-plugin-toolkit”导入 ZoteroToolkit
开始熟悉 API。getGlobal:获取引导插件沙箱的全局变量。
Zotero
、ZoteroPane
、window
、document
以及window
下的任何变量。带类型提示。log:输出到
Zotero.debug
和console.log< /代码>。可以根据开发/生产环境进行自定义。
createXULElement/getDOMParser:兼容 Zotero 6 和 Zotero 6 7+。请参阅 https://www.zotero.org/support/dev/zotero7for_developers
工具
UI:创建元素并自动管理它们。
Reader:Reader 实例 API。
ExtraField:获取/设置额外字段 API。
管理器
ItemTree:注册额外的列/自定义单元格。
PreferencePane
:注册 Zotero 6 和 Zotero 的首选项窗格7+。请参阅 https://www.zotero.org/support/dev/zotero7for_developersLibraryTabPanel:在库右侧注册额外的选项卡面板。
ReaderTabPanel:在阅读器右侧边栏中注册额外的选项卡面板。
菜单:注册菜单/弹出菜单。
快捷方式:注册快捷键。
助手
剪贴板:复制文本/富文本/图像。
FilePicker:打开文件选择器。
ProgressWindow:打开进度窗口。
VirtualizedTable:创建VirtualizedTable(高级表格视图元素,由Zotero项目树、集合树、项目使用) picker等)
对话框:创建一个对话框窗口(XUL 对话框的超集)。具有数据绑定、自动布局和控制按钮。
用法
运行
npm install --save zotero-plugin-toolkit
。导入工具包类
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();
- 按照此API文档使用工具包
ztoolkit.log("This is Zotero:", toolkit.getGlobal("Zotero"));
⚠️所有 Manager 类都有
register
方法以及相应的unregister/unregisterAll
。插件退出时不要忘记取消注册。此存储库取决于 zotero-types。有关 Zotero 类型定义的更多详细信息,请参阅其主页。
示例
此包集成到 Zotero 插件模板中。您可以在那里找到示例。
如果您不熟悉 Zotero 插件/正在寻找从 Zotero 6 迁移到 7 的解决方案,请查看该存储库。
API 文档还包含一些 API 的示例代码。
贡献
设置
分叉此存储库。
确保您已安装
nodejs
和npm
。克隆 repo 文件夹并安装依赖项:
git clone https://github.com/windingwind/zotero-plugin-toolkit
cd zotero-plugin-toolkit
npm install
Build
Run npm run build
。
./dist
下的.js
包和.d.ts
;./docs
下的文档。
本地测试
使用您的插件进行测试或使用 Zotero 插件模板 作为游乐场。
在 Playground repo 文件夹下运行 npm install /path/to/this/repo
,该库将从本地构建安装。
游乐场采用最新的建筑。如果重建此库,则无需再次 npm install。
发布
npm run release
。标记的推送将触发 npm-publish GitHub 操作。
免责声明
根据 MIT 许可证使用此代码。不提供任何保证。请牢记您所在地区的法律!
如果您想更改许可证,请通过 wyzlshx@foxmail.com 联系我
我的 Zotero 插件
- zotero-better-notes:关于笔记管理的一切。一切尽在佐特罗。
- zotero-pdf-preview:Zotero 的 PDF 预览。
- zotero-pdf-translate:Zotero 6 的 PDF 翻译。
- zotero-tag:自动标记项目/批量标记
Zotero Plugin Toolkit
Intro
This repo is published as an NPM package zotero-plugin-toolkit, which provides useful APIs for Zotero plugin developers.
Modules
ZoteroToolkit: Contains all modules of this library. Start from
import ZoteroToolkit from "zotero-plugin-toolkit"
to get familiar with the APIs.getGlobal: Get global variables for bootstrapped plugin sandbox.
Zotero
,ZoteroPane
,window
,document
, and any variables underwindow
. With type hint.log: Output to both
Zotero.debug
andconsole.log
. Can be customized depending on dev/prod environment.createXULElement/getDOMParser: Compatible on Zotero 6 & 7+. See https://www.zotero.org/support/dev/zotero7for_developers
Tools
UI: Create elements and manage them automatically.
Reader: Reader instance APIs.
ExtraField: Get/set extra fields APIs.
Managers
ItemTree: Register extra columns/custom cell.
PreferencePane
: Register preference pane for Zotero 6 & 7+. See https://www.zotero.org/support/dev/zotero7for_developersLibraryTabPanel: Register extra tab panel in the library right-sidebar.
ReaderTabPanel: Register extra tab panel in the reader right-sidebars.
Menu: Register menu/menu popup.
Shortcut: Register shortcut keys.
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.
Usage
Run
npm install --save zotero-plugin-toolkit
.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();
- Use the toolkit following this API Documentation
ztoolkit.log("This is Zotero:", toolkit.getGlobal("Zotero"));
⚠️All Manager classes have
register
method with correspondingunregister/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
Fork this repo.
Make sure you have
nodejs
andnpm
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
- zotero-better-notes: Everything about note management. All in Zotero.
- zotero-pdf-preview: PDF Preview for Zotero.
- zotero-pdf-translate: PDF Translation for Zotero 6.
- zotero-tag: Automatically tag items/Batch tagging