This package contains type definitions for Zotero (https://www.zotero.org/) plugin.
npm package: https://www.npmjs.com/package/zotero-types
-
Run
npm install --save-dev zotero-types
. -
No need to import the type declaration in your TypeScript code. If your IDE does not recognize the definitions, add the path to typing file in the include of
tsconfig.json
:// tsconfig.json { "include": ["src", "node_modules/zotero-types"], }
Example:
// Example 1: get Zotero.Item by id
const item = Zotero.Items.get(1234);
// Example 2: use XUL.Element type with specific properties
const exportFiles = document.querySelector(
"#menu_export_files",
) as XULMenuItemElement;
exportFiles.disabled = true;
// Example 3: use platform APIs (OS)
const filepath = "/path/to/file";
if (await IOUtils.exists(filepath)) {
let contentRaw = await IOUtils.readUTF8(filepath);
}
Note
If you are using pnpm
as the package manager for your project, you need to additionally do one of the following things:
- Add
public-hoist-pattern[]=*@types/bluebird*
to.npmrc
. - Add
@types/bulebird
to thedevDependencies
.
See also:
@types
are not hoisted by default in pnpm v7: pnpm/pnpm#4920 (comment)- Dependency Hoisting Settings: https://pnpm.io/npmrc#public-hoist-pattern
This type definition only contains frequently used typings and is not complete. Please check the source code of Zotero here: https://github.com/zotero/zotero.
The d.ts
files of Zotero are set accordingly to their corresponding file in the Zotero repository.
Planning to merge to https://github.com/DefinitelyTyped/DefinitelyTyped/
To release this to the npm package, use npm run release
.
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 [email protected]
Part of the code of this repo refers to other open-source projects within the allowed scope.
- zotero-better-bibtex(
d.ts
)
- 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
- zotero-theme: Customize Zotero theme