@annotorious/plugin-tools

中文文档
1.6.0发布于 2026/03/06BSD-3-ClauseTypeScriptESM + CJS零依赖近 30 天下载 8628

Additional drawing tools for Annotorious

原始使用文档
文档目录8 节
  1. Installation
  2. Tools
  3. 1. Ellipse
  4. 2. Line
  5. 3. Path
  6. Usage
  7. Image Annotator
  8. OpenSeadragon Annotator

Annotorious Tools Plugin

An Annotorious plugin that adds additional drawing tools.

A screenshot of the Annotorious Tools plugin, showing ellipse and path annotations.

Installation

npm install @annotorious/plugin-tools

Tools

1. Ellipse

Draw ellipses or circles.

  • Hold SHIFT – Constrain aspect ratio to circle
  • Hold CTRL – Draw from the center outward

2. Line

Draw a straight line between two points.

3. Path

Create polylines made of straight or curved segments.

Drawing:

  • Click (or click and drag if drawingMode is set to drag) to start.
  • Click to add more points.
  • Open path: Double-click to finish.
  • Closed shape: Click back on the first point.

Editing:

  • Delete points: Press Del or Backspace while points are selected to remove those points from the path.
  • Toggle corner/curve: Click a point to switch between corner and smooth curve (handles will appear when a single point is selected).
  • Adjust curvature: Drag the handles to refine the shape.
  • Sharp corner between curves: Hold Alt while dragging a handle to move it independently.
  • Re-link handles: Double-click the point to snap handles back together.
  • Select multiple points: Hold Ctrl (or Option on Mac) while clicking a point to add it to the selection

Usage

The plugin works with both Annotorious versions: Image Annotator and OpenSeadragon Annotator.

Image Annotator

import { createImageAnnotator } from '@annotorious/annotorious';
import { mountPlugin as mountToolsPlugin } from '@annotorious/plugin-tools';

import '@annotorious/annotorious/annotorious.css';
import '@annotorious/plugin-tools/annotorious-plugin-tools.css';

var anno = createImageAnnotator('sample-image', {
  /** Annotorious init options **/
});

mountToolsPlugin(anno);

// ['rectangle', 'polygon', 'ellipse', 'line', 'path']
console.log(anno.listDrawingTools());

anno.setDrawingTool('path');

OpenSeadragon Annotator

import OpenSeadragon from 'openseadragon';
import { createOSDAnnotator } from '@annotorious/openseadragon';
import { mountPlugin as mountToolsPlugin } from '../src';

import '@annotorious/openseadragon/annotorious-openseadragon.css';
import '@annotorious/plugin-tools/annotorious-plugin-tools.css';

const viewer = OpenSeadragon({
  /** OpenSeadragon init options **/
});

const anno = createOSDAnnotator(viewer, {
  /** Annotorious init options **/
});

mountToolsPlugin(anno);

// ['rectangle', 'polygon', 'ellipse', 'line', 'path']
console.log(anno.listDrawingTools());

anno.setDrawingTool('path');

版本与发布记录

@annotorious/plugin-tools 共发布 17 个版本,首次发布于 2024/09/07;过去 12 个月发布了 2 个版本。

版本发布日期距今
1.6.0latest2026/03/068 个月前
1.5.02026/03/068 个月前
1.4.62025/10/311 年前
1.4.52025/08/221.2 年前
1.4.42025/08/081.2 年前
1.4.32025/07/311.3 年前

关于 @annotorious/plugin-tools 的常见问题

@annotorious/plugin-tools 是什么?

Additional drawing tools for Annotorious

如何安装 @annotorious/plugin-tools?

在项目目录运行 npm install @annotorious/plugin-tools,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@annotorious/annotorious(^3.7.22)、@annotorious/openseadragon(^3.7.22)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@annotorious/plugin-tools 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@annotorious/plugin-tools 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@annotorious/plugin-tools 可以商用吗?

@annotorious/plugin-tools 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@annotorious/plugin-tools 的下载量有多少?

根据 npm 官方下载统计,@annotorious/plugin-tools 在 2026/10/06 – 2026/11/04 这 30 天内被下载 8,628 次,日均约 288 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@annotorious/plugin-tools 还在维护吗?

最新版本 1.6.0 发布于 2026/03/06(8 个月前);至今共发布 17 个版本,其中过去 12 个月发布了 2 个;首次发布于 2024/09/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。