@zzalai/leafer-point-annotation 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  - 📤 多格式导出:JSON / COCO / YOLO / Mask (dataURL / Blob / File)
14
14
  - 📱 支持自定义工具栏(隐藏内置工具栏,调用 ref API 自行构建)
15
15
  - 🔒 `enableBrush: false` 可完全禁用笔刷,仅保留点标注
16
- - ⌨️ 丰富的键盘快捷键(`v` `p` `b` `e` `Ctrl+Z` `Ctrl+Y` `Delete` 等)
16
+ - ⌨️ 丰富的键盘快捷键(`v` `p` `b` `e` `Ctrl+Z` `Ctrl+Y` `Delete` 等,需 `options.enableHotkeys: true`)
17
17
 
18
18
  ---
19
19
 
@@ -149,6 +149,8 @@ interface OptionsSource {
149
149
  enableBrush?: boolean // 是否启用笔刷(默认 true);
150
150
  // false 时笔刷按钮/面板不渲染,
151
151
  // brushTool/eraserTool/mask 导出等方法失效
152
+ enableHotkeys?: boolean // 是否启用键盘快捷键(默认 false);
153
+ // true 时才绑定 v/p/b/e/Ctrl+Z 等快捷键
152
154
 
153
155
  // ============ UI 开关 ============
154
156
  showToolbar?: boolean // 是否显示内置工具栏(默认 true)
@@ -527,21 +529,23 @@ function handlePoints(points: any[]) {
527
529
 
528
530
  ## 快捷键
529
531
 
530
- > 生效条件:**画布获得焦点** 或 **鼠标 hover 在画布上**
532
+ > 生效条件:**`options.enableHotkeys: true`** + (**画布获得焦点** 或 **鼠标 hover 在画布上**)
533
+ >
534
+ > `enableHotkeys` 默认 `false`,需显式传 `true` 才会绑定快捷键。
531
535
 
532
536
  | 按键 | 功能 | 限制 |
533
537
  |------|------|------|
534
- | `v` | 选择工具 | - |
535
- | `p` | 点标注工具 | - |
536
- | `b` | 笔刷工具 | 需 `enableBrush=true` |
537
- | `e` | 橡皮擦工具 | 需 `enableBrush=true` |
538
- | `Ctrl + Z` | 撤销 | - |
539
- | `Ctrl + Y` | 重做 | - |
540
- | `Delete` | 删除选中的点 | - |
541
- | `Ctrl + +` | 放大 | - |
542
- | `Ctrl + -` | 缩小 | - |
543
- | `Ctrl + 0` | 重置缩放 | - |
544
- | `Alt` | 显示/隐藏快捷键提示浮层 | - |
538
+ | `v` | 选择工具 | `enableHotkeys=true` |
539
+ | `p` | 点标注工具 | `enableHotkeys=true` |
540
+ | `b` | 笔刷工具 | 需 `enableHotkeys=true` + `enableBrush=true` |
541
+ | `e` | 橡皮擦工具 | 需 `enableHotkeys=true` + `enableBrush=true` |
542
+ | `Ctrl + Z` | 撤销 | `enableHotkeys=true` |
543
+ | `Ctrl + Y` | 重做 | `enableHotkeys=true` |
544
+ | `Delete` | 删除选中的点 | `enableHotkeys=true` |
545
+ | `Ctrl + +` | 放大 | `enableHotkeys=true` |
546
+ | `Ctrl + -` | 缩小 | `enableHotkeys=true` |
547
+ | `Ctrl + 0` | 重置缩放 | `enableHotkeys=true` |
548
+ | `Alt` | 显示/隐藏快捷键提示浮层 | `enableHotkeys=true` |
545
549
 
546
550
  ---
547
551
 
package/README_EN.md CHANGED
@@ -13,7 +13,7 @@ English | [中文](README.md)
13
13
  - 📤 **Multi-format Export** - JSON / COCO / YOLO / Mask (dataURL / Blob / File)
14
14
  - 📱 **Custom Toolbar Support** - Hide built-in toolbar and build custom UI via ref API
15
15
  - 🔒 **Brush Disabling** - Use `enableBrush: false` to disable all brush functionality for point-only annotation
16
- - ⌨️ **Rich Keyboard Shortcuts** - `v`, `p`, `b`, `e`, `Ctrl+Z`, `Ctrl+Y`, `Delete`, and more
16
+ - ⌨️ **Rich Keyboard Shortcuts** - `v`, `p`, `b`, `e`, `Ctrl+Z`, `Ctrl+Y`, `Delete`, and more (requires `options.enableHotkeys: true`)
17
17
 
18
18
  ---
19
19
 
@@ -154,6 +154,8 @@ interface OptionsSource {
154
154
  enableBrush?: boolean // Whether to enable brush (default: true);
155
155
  // When false, brush buttons/panel are not rendered,
156
156
  // and brushTool/eraserTool/mask export methods are disabled
157
+ enableHotkeys?: boolean // Whether to enable keyboard shortcuts (default: false);
158
+ // Shortcuts v/p/b/e/Ctrl+Z are only bound when true
157
159
 
158
160
  // ============ UI Toggles ============
159
161
  showToolbar?: boolean // Whether to show built-in toolbar (default: true)
@@ -532,21 +534,23 @@ function handlePoints(points: any[]) {
532
534
 
533
535
  ## Keyboard Shortcuts
534
536
 
535
- > Effective when: **Canvas has focus** or **mouse hovers over canvas**
537
+ > Effective when: **`options.enableHotkeys: true`** + (**Canvas has focus** OR **mouse hovers over canvas**)
538
+ >
539
+ > `enableHotkeys` defaults to `false`. You must explicitly pass `true` to bind keyboard shortcuts.
536
540
 
537
541
  | Key | Function | Restriction |
538
542
  |-----|----------|-------------|
539
- | `v` | Select tool | - |
540
- | `p` | Point annotation tool | - |
541
- | `b` | Brush tool | Requires `enableBrush=true` |
542
- | `e` | Eraser tool | Requires `enableBrush=true` |
543
- | `Ctrl + Z` | Undo | - |
544
- | `Ctrl + Y` | Redo | - |
545
- | `Delete` | Delete selected point | - |
546
- | `Ctrl + +` | Zoom in | - |
547
- | `Ctrl + -` | Zoom out | - |
548
- | `Ctrl + 0` | Reset zoom | - |
549
- | `Alt` | Show/Hide shortcut hint overlay | - |
543
+ | `v` | Select tool | Requires `enableHotkeys=true` |
544
+ | `p` | Point annotation tool | Requires `enableHotkeys=true` |
545
+ | `b` | Brush tool | Requires `enableHotkeys=true` + `enableBrush=true` |
546
+ | `e` | Eraser tool | Requires `enableHotkeys=true` + `enableBrush=true` |
547
+ | `Ctrl + Z` | Undo | Requires `enableHotkeys=true` |
548
+ | `Ctrl + Y` | Redo | Requires `enableHotkeys=true` |
549
+ | `Delete` | Delete selected point | Requires `enableHotkeys=true` |
550
+ | `Ctrl + +` | Zoom in | Requires `enableHotkeys=true` |
551
+ | `Ctrl + -` | Zoom out | Requires `enableHotkeys=true` |
552
+ | `Ctrl + 0` | Reset zoom | Requires `enableHotkeys=true` |
553
+ | `Alt` | Show/Hide shortcut hint overlay | Requires `enableHotkeys=true` |
550
554
 
551
555
  ---
552
556