@embedpdf/plugin-annotation 2.9.1 → 2.10.0

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.
Files changed (77) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +3072 -2652
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +25 -6
  6. package/dist/lib/annotation-plugin.d.ts +15 -12
  7. package/dist/lib/handlers/index.d.ts +1 -0
  8. package/dist/lib/handlers/link.handler.d.ts +3 -0
  9. package/dist/lib/handlers/types.d.ts +9 -1
  10. package/dist/lib/helpers.d.ts +12 -5
  11. package/dist/lib/index.d.ts +4 -0
  12. package/dist/lib/reducer.d.ts +1 -1
  13. package/dist/lib/tools/default-tools.d.ts +147 -301
  14. package/dist/lib/tools/tools-utils.d.ts +448 -22
  15. package/dist/lib/tools/types.d.ts +35 -2
  16. package/dist/lib/types.d.ts +105 -24
  17. package/dist/preact/index.cjs +1 -1
  18. package/dist/preact/index.cjs.map +1 -1
  19. package/dist/preact/index.js +192 -87
  20. package/dist/preact/index.js.map +1 -1
  21. package/dist/react/index.cjs +1 -1
  22. package/dist/react/index.cjs.map +1 -1
  23. package/dist/react/index.js +192 -87
  24. package/dist/react/index.js.map +1 -1
  25. package/dist/shared/components/annotation-navigation-handler.d.ts +1 -0
  26. package/dist/shared/components/annotations/link-locked.d.ts +3 -0
  27. package/dist/shared/components/annotations/stamp.d.ts +1 -1
  28. package/dist/shared/components/preview-renderer.d.ts +4 -3
  29. package/dist/shared/components/types.d.ts +21 -4
  30. package/dist/shared/hooks/index.d.ts +1 -0
  31. package/dist/shared/hooks/use-annotation.d.ts +2 -2
  32. package/dist/shared/hooks/use-ios-zoom-prevention.d.ts +16 -0
  33. package/dist/shared-preact/components/annotation-navigation-handler.d.ts +1 -0
  34. package/dist/shared-preact/components/annotations/link-locked.d.ts +3 -0
  35. package/dist/shared-preact/components/annotations/stamp.d.ts +1 -1
  36. package/dist/shared-preact/components/preview-renderer.d.ts +4 -3
  37. package/dist/shared-preact/components/types.d.ts +21 -4
  38. package/dist/shared-preact/hooks/index.d.ts +1 -0
  39. package/dist/shared-preact/hooks/use-annotation.d.ts +2 -2
  40. package/dist/shared-preact/hooks/use-ios-zoom-prevention.d.ts +15 -0
  41. package/dist/shared-react/components/annotation-navigation-handler.d.ts +1 -0
  42. package/dist/shared-react/components/annotations/link-locked.d.ts +3 -0
  43. package/dist/shared-react/components/annotations/stamp.d.ts +1 -1
  44. package/dist/shared-react/components/preview-renderer.d.ts +4 -3
  45. package/dist/shared-react/components/types.d.ts +21 -4
  46. package/dist/shared-react/hooks/index.d.ts +1 -0
  47. package/dist/shared-react/hooks/use-annotation.d.ts +2 -2
  48. package/dist/shared-react/hooks/use-ios-zoom-prevention.d.ts +16 -0
  49. package/dist/svelte/components/AnnotationNavigationHandler.svelte.d.ts +3 -0
  50. package/dist/svelte/components/PreviewRenderer.svelte.d.ts +3 -2
  51. package/dist/svelte/components/annotations/LinkLockedMode.svelte.d.ts +5 -0
  52. package/dist/svelte/components/annotations/LinkPreview.svelte.d.ts +10 -0
  53. package/dist/svelte/components/annotations/Stamp.svelte.d.ts +1 -1
  54. package/dist/svelte/context/renderer-registry.svelte.d.ts +1 -1
  55. package/dist/svelte/context/types.d.ts +20 -3
  56. package/dist/svelte/hooks/index.d.ts +1 -0
  57. package/dist/svelte/hooks/use-annotation.svelte.d.ts +1 -1
  58. package/dist/svelte/hooks/use-ios-zoom-prevention.svelte.d.ts +6 -0
  59. package/dist/svelte/index.cjs +1 -1
  60. package/dist/svelte/index.cjs.map +1 -1
  61. package/dist/svelte/index.js +401 -228
  62. package/dist/svelte/index.js.map +1 -1
  63. package/dist/vue/components/annotation-navigation-handler.vue.d.ts +3 -0
  64. package/dist/vue/components/annotations/link-locked.vue.d.ts +5 -0
  65. package/dist/vue/components/annotations/link-preview.vue.d.ts +10 -0
  66. package/dist/vue/components/annotations/stamp.vue.d.ts +2 -2
  67. package/dist/vue/components/preview-renderer.vue.d.ts +3 -2
  68. package/dist/vue/context/renderer-registry.d.ts +1 -1
  69. package/dist/vue/context/types.d.ts +20 -3
  70. package/dist/vue/hooks/index.d.ts +1 -0
  71. package/dist/vue/hooks/use-annotation.d.ts +24 -2
  72. package/dist/vue/hooks/use-ios-zoom-prevention.d.ts +7 -0
  73. package/dist/vue/index.cjs +1 -1
  74. package/dist/vue/index.cjs.map +1 -1
  75. package/dist/vue/index.js +402 -262
  76. package/dist/vue/index.js.map +1 -1
  77. package/package.json +12 -10
@@ -1,27 +1,453 @@
1
- import { AnnotationTool } from './types';
1
+ import { ToolMapFromList } from './types';
2
2
  import { defaultTools } from './default-tools';
3
- type DefaultTool = (typeof defaultTools)[number];
4
- export type ToolMap = {
5
- [T in DefaultTool as T['id']]: T;
6
- };
3
+ export type ToolMap = ToolMapFromList<typeof defaultTools>;
7
4
  /**
8
5
  * A factory that creates a type-safe predicate function for a specific tool ID.
9
6
  * This is more reliable for TypeScript's type inference than a single generic function.
10
7
  */
11
- export declare function createToolPredicate<K extends keyof ToolMap>(id: K): (tool: AnnotationTool<any> | undefined) => tool is ToolMap[K];
12
- export declare const isHighlightTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["highlight"];
13
- export declare const isSquigglyTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["squiggly"];
14
- export declare const isUnderlineTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["underline"];
15
- export declare const isStrikeoutTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["strikeout"];
16
- export declare const isInkTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["ink"];
17
- export declare const isInkHighlighterTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["inkHighlighter"];
18
- export declare const isSquareTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["square"];
19
- export declare const isCircleTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["circle"];
20
- export declare const isLineTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["line"];
21
- export declare const isPolylineTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["polyline"];
22
- export declare const isPolygonTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["polygon"];
23
- export declare const isFreeTextTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["freeText"];
24
- export declare const isStampTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["stamp"];
25
- export declare const isInsertTextTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["insertText"];
26
- export declare const isReplaceTextTool: (tool: AnnotationTool<any> | undefined) => tool is ToolMap["replaceText"];
27
- export {};
8
+ export declare function createToolPredicate<K extends keyof ToolMap>(id: K): (tool: {
9
+ id: string;
10
+ } | undefined) => tool is ToolMap[K];
11
+ export declare const isHighlightTool: (tool: {
12
+ id: string;
13
+ } | undefined) => tool is {
14
+ id: "highlight";
15
+ name: string;
16
+ labelKey: string;
17
+ categories: string[];
18
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 1;
19
+ interaction: {
20
+ exclusive: false;
21
+ textSelection: true;
22
+ isDraggable: false;
23
+ isResizable: false;
24
+ isRotatable: false;
25
+ isGroupDraggable: false;
26
+ isGroupResizable: false;
27
+ };
28
+ defaults: {
29
+ type: import("@embedpdf/models").PdfAnnotationSubtype.HIGHLIGHT;
30
+ strokeColor: string;
31
+ color: string;
32
+ opacity: number;
33
+ blendMode: import("@embedpdf/models").PdfBlendMode.Multiply;
34
+ };
35
+ };
36
+ export declare const isSquigglyTool: (tool: {
37
+ id: string;
38
+ } | undefined) => tool is {
39
+ id: "squiggly";
40
+ name: string;
41
+ labelKey: string;
42
+ categories: string[];
43
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 1;
44
+ interaction: {
45
+ exclusive: false;
46
+ textSelection: true;
47
+ isDraggable: false;
48
+ isResizable: false;
49
+ isRotatable: false;
50
+ isGroupDraggable: false;
51
+ isGroupResizable: false;
52
+ };
53
+ defaults: {
54
+ type: import("@embedpdf/models").PdfAnnotationSubtype.SQUIGGLY;
55
+ strokeColor: string;
56
+ color: string;
57
+ opacity: number;
58
+ blendMode?: undefined;
59
+ };
60
+ };
61
+ export declare const isUnderlineTool: (tool: {
62
+ id: string;
63
+ } | undefined) => tool is {
64
+ id: "underline";
65
+ name: string;
66
+ labelKey: string;
67
+ categories: string[];
68
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 1;
69
+ interaction: {
70
+ exclusive: false;
71
+ textSelection: true;
72
+ isDraggable: false;
73
+ isResizable: false;
74
+ isRotatable: false;
75
+ isGroupDraggable: false;
76
+ isGroupResizable: false;
77
+ };
78
+ defaults: {
79
+ type: import("@embedpdf/models").PdfAnnotationSubtype.UNDERLINE;
80
+ strokeColor: string;
81
+ color: string;
82
+ opacity: number;
83
+ blendMode?: undefined;
84
+ };
85
+ };
86
+ export declare const isStrikeoutTool: (tool: {
87
+ id: string;
88
+ } | undefined) => tool is {
89
+ id: "strikeout";
90
+ name: string;
91
+ labelKey: string;
92
+ categories: string[];
93
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 1;
94
+ interaction: {
95
+ exclusive: false;
96
+ textSelection: true;
97
+ isDraggable: false;
98
+ isResizable: false;
99
+ isRotatable: false;
100
+ isGroupDraggable: false;
101
+ isGroupResizable: false;
102
+ };
103
+ defaults: {
104
+ type: import("@embedpdf/models").PdfAnnotationSubtype.STRIKEOUT;
105
+ strokeColor: string;
106
+ color: string;
107
+ opacity: number;
108
+ blendMode?: undefined;
109
+ };
110
+ };
111
+ export declare const isInkTool: (tool: {
112
+ id: string;
113
+ } | undefined) => tool is {
114
+ id: "ink";
115
+ name: string;
116
+ labelKey: string;
117
+ categories: string[];
118
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 5;
119
+ interaction: {
120
+ exclusive: false;
121
+ cursor: string;
122
+ isDraggable: true;
123
+ isResizable: true;
124
+ lockAspectRatio: false;
125
+ lockGroupAspectRatio?: undefined;
126
+ };
127
+ defaults: {
128
+ type: import("@embedpdf/models").PdfAnnotationSubtype.INK;
129
+ strokeColor: string;
130
+ color: string;
131
+ opacity: number;
132
+ strokeWidth: number;
133
+ intent?: undefined;
134
+ blendMode?: undefined;
135
+ };
136
+ behavior: {
137
+ commitDelay: number;
138
+ smartLineRecognition?: undefined;
139
+ smartLineThreshold?: undefined;
140
+ };
141
+ transform: import('..').PatchFunction<import('@embedpdf/models').PdfInkAnnoObject>;
142
+ pointerHandler: import('..').HandlerFactory<import('@embedpdf/models').PdfInkAnnoObject>;
143
+ };
144
+ export declare const isInkHighlighterTool: (tool: {
145
+ id: string;
146
+ } | undefined) => tool is {
147
+ id: "inkHighlighter";
148
+ name: string;
149
+ labelKey: string;
150
+ categories: string[];
151
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 10;
152
+ interaction: {
153
+ exclusive: false;
154
+ cursor: string;
155
+ isDraggable: true;
156
+ isResizable: true;
157
+ lockAspectRatio: false;
158
+ lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
159
+ };
160
+ defaults: {
161
+ type: import("@embedpdf/models").PdfAnnotationSubtype.INK;
162
+ intent: string;
163
+ strokeColor: string;
164
+ color: string;
165
+ opacity: number;
166
+ strokeWidth: number;
167
+ blendMode: import("@embedpdf/models").PdfBlendMode.Multiply;
168
+ };
169
+ behavior: {
170
+ commitDelay: number;
171
+ smartLineRecognition: true;
172
+ smartLineThreshold: number;
173
+ };
174
+ transform: import('..').PatchFunction<import('@embedpdf/models').PdfInkAnnoObject>;
175
+ pointerHandler: import('..').HandlerFactory<import('@embedpdf/models').PdfInkAnnoObject>;
176
+ };
177
+ export declare const isSquareTool: (tool: {
178
+ id: string;
179
+ } | undefined) => tool is {
180
+ id: "square";
181
+ name: string;
182
+ labelKey: string;
183
+ categories: string[];
184
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 1;
185
+ interaction: {
186
+ exclusive: false;
187
+ cursor: string;
188
+ isDraggable: true;
189
+ isResizable: true;
190
+ lockAspectRatio: false;
191
+ lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
192
+ };
193
+ defaults: {
194
+ type: import("@embedpdf/models").PdfAnnotationSubtype.SQUARE;
195
+ color: string;
196
+ opacity: number;
197
+ strokeWidth: number;
198
+ strokeColor: string;
199
+ strokeStyle: import("@embedpdf/models").PdfAnnotationBorderStyle.SOLID;
200
+ };
201
+ clickBehavior: {
202
+ enabled: true;
203
+ defaultSize: {
204
+ width: number;
205
+ height: number;
206
+ };
207
+ };
208
+ transform: import('..').PatchFunction<import('@embedpdf/models').PdfSquareAnnoObject>;
209
+ pointerHandler: import('..').HandlerFactory<import('@embedpdf/models').PdfSquareAnnoObject>;
210
+ };
211
+ export declare const isCircleTool: (tool: {
212
+ id: string;
213
+ } | undefined) => tool is {
214
+ id: "circle";
215
+ name: string;
216
+ labelKey: string;
217
+ categories: string[];
218
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 1;
219
+ interaction: {
220
+ exclusive: false;
221
+ cursor: string;
222
+ isDraggable: true;
223
+ isResizable: true;
224
+ lockAspectRatio: false;
225
+ lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
226
+ };
227
+ defaults: {
228
+ type: import("@embedpdf/models").PdfAnnotationSubtype.CIRCLE;
229
+ color: string;
230
+ opacity: number;
231
+ strokeWidth: number;
232
+ strokeColor: string;
233
+ strokeStyle: import("@embedpdf/models").PdfAnnotationBorderStyle.SOLID;
234
+ };
235
+ clickBehavior: {
236
+ enabled: true;
237
+ defaultSize: {
238
+ width: number;
239
+ height: number;
240
+ };
241
+ };
242
+ transform: import('..').PatchFunction<import('@embedpdf/models').PdfCircleAnnoObject>;
243
+ pointerHandler: import('..').HandlerFactory<import('@embedpdf/models').PdfCircleAnnoObject>;
244
+ };
245
+ export declare const isLineTool: (tool: {
246
+ id: string;
247
+ } | undefined) => tool is {
248
+ id: "line";
249
+ name: string;
250
+ labelKey: string;
251
+ categories: string[];
252
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 5;
253
+ interaction: {
254
+ exclusive: false;
255
+ cursor: string;
256
+ isDraggable: true;
257
+ isResizable: false;
258
+ lockAspectRatio: false;
259
+ isGroupResizable: true;
260
+ lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
261
+ };
262
+ defaults: {
263
+ type: import("@embedpdf/models").PdfAnnotationSubtype.LINE;
264
+ color: string;
265
+ opacity: number;
266
+ strokeWidth: number;
267
+ strokeColor: string;
268
+ intent?: undefined;
269
+ lineEndings?: undefined;
270
+ };
271
+ clickBehavior: {
272
+ enabled: true;
273
+ defaultLength: number;
274
+ defaultAngle: number;
275
+ };
276
+ transform: import('..').PatchFunction<import('@embedpdf/models').PdfLineAnnoObject>;
277
+ pointerHandler: import('..').HandlerFactory<import('@embedpdf/models').PdfLineAnnoObject>;
278
+ };
279
+ export declare const isPolylineTool: (tool: {
280
+ id: string;
281
+ } | undefined) => tool is {
282
+ id: "polyline";
283
+ name: string;
284
+ labelKey: string;
285
+ categories: string[];
286
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 1;
287
+ interaction: {
288
+ exclusive: false;
289
+ cursor: string;
290
+ isDraggable: true;
291
+ isResizable: false;
292
+ lockAspectRatio: false;
293
+ isGroupResizable: true;
294
+ lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
295
+ };
296
+ defaults: {
297
+ type: import("@embedpdf/models").PdfAnnotationSubtype.POLYLINE;
298
+ color: string;
299
+ opacity: number;
300
+ strokeWidth: number;
301
+ strokeColor: string;
302
+ };
303
+ transform: import('..').PatchFunction<import('@embedpdf/models').PdfPolylineAnnoObject>;
304
+ pointerHandler: import('..').HandlerFactory<import('@embedpdf/models').PdfPolylineAnnoObject>;
305
+ };
306
+ export declare const isPolygonTool: (tool: {
307
+ id: string;
308
+ } | undefined) => tool is {
309
+ id: "polygon";
310
+ name: string;
311
+ labelKey: string;
312
+ categories: string[];
313
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 1;
314
+ interaction: {
315
+ exclusive: false;
316
+ cursor: string;
317
+ isDraggable: true;
318
+ isResizable: false;
319
+ lockAspectRatio: false;
320
+ isGroupResizable: true;
321
+ lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
322
+ };
323
+ defaults: {
324
+ type: import("@embedpdf/models").PdfAnnotationSubtype.POLYGON;
325
+ color: string;
326
+ opacity: number;
327
+ strokeWidth: number;
328
+ strokeColor: string;
329
+ };
330
+ transform: import('..').PatchFunction<import('@embedpdf/models').PdfPolygonAnnoObject>;
331
+ pointerHandler: import('..').HandlerFactory<import('@embedpdf/models').PdfPolygonAnnoObject>;
332
+ };
333
+ export declare const isFreeTextTool: (tool: {
334
+ id: string;
335
+ } | undefined) => tool is {
336
+ id: "freeText";
337
+ name: string;
338
+ labelKey: string;
339
+ categories: string[];
340
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 1;
341
+ interaction: {
342
+ exclusive: false;
343
+ cursor: string;
344
+ isDraggable: true;
345
+ isResizable: true;
346
+ lockAspectRatio: false;
347
+ lockGroupAspectRatio: (a: import('@embedpdf/models').PdfAnnotationObject) => boolean;
348
+ };
349
+ defaults: {
350
+ type: import("@embedpdf/models").PdfAnnotationSubtype.FREETEXT;
351
+ contents: string;
352
+ fontSize: number;
353
+ fontColor: string;
354
+ fontFamily: import("@embedpdf/models").PdfStandardFont.Helvetica;
355
+ textAlign: import("@embedpdf/models").PdfTextAlignment.Left;
356
+ verticalAlign: import("@embedpdf/models").PdfVerticalAlignment.Top;
357
+ color: string;
358
+ backgroundColor: string;
359
+ opacity: number;
360
+ };
361
+ clickBehavior: {
362
+ enabled: true;
363
+ defaultSize: {
364
+ width: number;
365
+ height: number;
366
+ };
367
+ defaultContent: string;
368
+ };
369
+ behavior: {
370
+ insertUpright: true;
371
+ editAfterCreate: true;
372
+ selectAfterCreate: true;
373
+ };
374
+ transform: import('..').PatchFunction<import('@embedpdf/models').PdfFreeTextAnnoObject>;
375
+ pointerHandler: import('..').HandlerFactory<import('@embedpdf/models').PdfFreeTextAnnoObject>;
376
+ };
377
+ export declare const isStampTool: (tool: {
378
+ id: string;
379
+ } | undefined) => tool is {
380
+ id: "stamp";
381
+ name: string;
382
+ labelKey: string;
383
+ categories: string[];
384
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 1;
385
+ interaction: {
386
+ exclusive: false;
387
+ cursor: string;
388
+ isDraggable: true;
389
+ isResizable: true;
390
+ lockAspectRatio: true;
391
+ lockGroupAspectRatio: true;
392
+ };
393
+ defaults: {
394
+ type: import("@embedpdf/models").PdfAnnotationSubtype.STAMP;
395
+ };
396
+ behavior: {
397
+ insertUpright: true;
398
+ useAppearanceStream: false;
399
+ };
400
+ transform: import('..').PatchFunction<import('@embedpdf/models').PdfStampAnnoObject>;
401
+ pointerHandler: import('..').HandlerFactory<import('@embedpdf/models').PdfStampAnnoObject>;
402
+ };
403
+ export declare const isInsertTextTool: (tool: {
404
+ id: string;
405
+ } | undefined) => tool is {
406
+ id: "insertText";
407
+ name: string;
408
+ labelKey: string;
409
+ categories: string[];
410
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 1 | 2;
411
+ interaction: {
412
+ exclusive: false;
413
+ textSelection: true;
414
+ showSelectionRects: true;
415
+ isDraggable: false;
416
+ isResizable: false;
417
+ isRotatable: false;
418
+ isGroupDraggable: false;
419
+ isGroupResizable: false;
420
+ };
421
+ defaults: {
422
+ type: import("@embedpdf/models").PdfAnnotationSubtype.CARET;
423
+ strokeColor: string;
424
+ opacity: number;
425
+ intent: string;
426
+ };
427
+ selectionHandler: import('..').SelectionHandlerFactory<import('@embedpdf/models').PdfCaretAnnoObject>;
428
+ };
429
+ export declare const isReplaceTextTool: (tool: {
430
+ id: string;
431
+ } | undefined) => tool is {
432
+ id: "replaceText";
433
+ name: string;
434
+ labelKey: string;
435
+ categories: string[];
436
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 2;
437
+ interaction: {
438
+ exclusive: false;
439
+ textSelection: true;
440
+ isDraggable: false;
441
+ isResizable: false;
442
+ isRotatable: false;
443
+ isGroupDraggable: false;
444
+ isGroupResizable: false;
445
+ };
446
+ defaults: {
447
+ type: import("@embedpdf/models").PdfAnnotationSubtype.STRIKEOUT;
448
+ strokeColor: string;
449
+ opacity: number;
450
+ intent: string;
451
+ };
452
+ selectionHandler: import('..').SelectionHandlerFactory<import('@embedpdf/models').PdfStrikeOutAnnoObject>;
453
+ };
@@ -1,4 +1,6 @@
1
1
  import { PdfAnnotationObject, PdfAnnotationSubtype, Size } from '@embedpdf/models';
2
+ import { HandlerFactory, SelectionHandlerFactory } from '../handlers/types';
3
+ import { PatchFunction } from '../patching/patch-registry';
2
4
  /**
3
5
  * A dynamic boolean property that can be either a static boolean
4
6
  * or a function that receives the annotation and returns a boolean.
@@ -65,6 +67,8 @@ export interface ClickBehaviorMap {
65
67
  [PdfAnnotationSubtype.SQUARE]: ShapeClickBehavior;
66
68
  [PdfAnnotationSubtype.LINE]: LineClickBehavior;
67
69
  [PdfAnnotationSubtype.FREETEXT]: FreeTextClickBehavior;
70
+ [PdfAnnotationSubtype.WIDGET]: ShapeClickBehavior;
71
+ [PdfAnnotationSubtype.LINK]: ShapeClickBehavior;
68
72
  }
69
73
  type GetToolConfig<T extends PdfAnnotationObject> = T['type'] extends keyof ToolConfigMap ? ToolConfigMap[T['type']] : {};
70
74
  type ClickBehaviorFor<T extends PdfAnnotationObject> = Extract<T['type'], keyof ClickBehaviorMap> extends never ? {} : {
@@ -118,11 +122,15 @@ type InkBehaviorFor<T extends PdfAnnotationObject> = [T] extends [
118
122
  * The primary interface for defining an annotation tool.
119
123
  * Uses a type alias to properly combine the base interface with conditional properties.
120
124
  */
121
- export type AnnotationTool<T extends PdfAnnotationObject = PdfAnnotationObject> = {
125
+ export type AnnotationTool<T extends PdfAnnotationObject = PdfAnnotationObject, TId extends string = string> = {
122
126
  /** A unique identifier, e.g., 'ink', 'arrow' */
123
- id: string;
127
+ id: TId;
124
128
  /** A user-facing name for UI elements, e.g., 'Pen' */
125
129
  name: string;
130
+ /** Translation key for the tool label, e.g., 'annotation.ink'. Used by the UI for i18n. */
131
+ labelKey?: string;
132
+ /** Category tags for authoring mode control, e.g., `['annotation', 'form']`. */
133
+ categories?: string[];
126
134
  /**
127
135
  * Determines how well this tool matches an existing annotation.
128
136
  * Higher numbers indicate a more specific match.
@@ -170,5 +178,30 @@ export type AnnotationTool<T extends PdfAnnotationObject = PdfAnnotationObject>
170
178
  /** Override whether this annotation type uses AP rendering before editing (default: true) */
171
179
  useAppearanceStream?: boolean;
172
180
  } & InsertUprightBehaviorFor<T> & InkBehaviorFor<T>;
181
+ /** Pointer-based creation handler (drag-to-create, click-to-place). */
182
+ pointerHandler?: HandlerFactory<T>;
183
+ /** Text-selection-based creation handler. */
184
+ selectionHandler?: SelectionHandlerFactory<T>;
185
+ /** Transform function for move, resize, rotate, and property-update operations. */
186
+ transform?: PatchFunction<T>;
173
187
  } & ClickBehaviorFor<T>;
188
+ export interface AnnotationToolRecord {
189
+ id: string;
190
+ defaults: Record<string, unknown>;
191
+ }
192
+ export type AnnotationToolMap = Record<string, AnnotationToolRecord>;
193
+ export type ToolId<TMap extends AnnotationToolMap> = Extract<keyof TMap, string>;
194
+ export type ToolById<TMap extends AnnotationToolMap, TId extends ToolId<TMap>> = TMap[TId];
195
+ export type ToolMapFromList<TTools extends readonly {
196
+ id: string;
197
+ }[]> = {
198
+ [T in TTools[number] as T['id']]: T;
199
+ };
200
+ export type UpsertToolMap<TMap extends AnnotationToolMap, TTool extends AnnotationTool> = Omit<TMap, TTool['id']> & {
201
+ [K in TTool['id']]: TTool;
202
+ };
203
+ /**
204
+ * Helper to preserve literal IDs and concrete tool typing.
205
+ */
206
+ export declare const defineAnnotationTool: <const TTool extends AnnotationTool<any>>(tool: TTool) => TTool;
174
207
  export {};