@embedpdf/plugin-annotation 1.1.1 → 1.2.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 (107) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +1916 -390
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +21 -15
  6. package/dist/lib/annotation-plugin.d.ts +30 -7
  7. package/dist/lib/handlers/circle.handler.d.ts +3 -0
  8. package/dist/lib/handlers/click-detector.d.ts +27 -0
  9. package/dist/lib/handlers/free-text.handler.d.ts +3 -0
  10. package/dist/lib/handlers/index.d.ts +8 -0
  11. package/dist/lib/handlers/ink.handler.d.ts +3 -0
  12. package/dist/lib/handlers/line.handler.d.ts +3 -0
  13. package/dist/lib/handlers/polygon.handler.d.ts +3 -0
  14. package/dist/lib/handlers/polyline.handler.d.ts +3 -0
  15. package/dist/lib/handlers/square.handler.d.ts +3 -0
  16. package/dist/lib/handlers/stamp.handler.d.ts +3 -0
  17. package/dist/lib/handlers/types.d.ts +139 -0
  18. package/dist/lib/helpers.d.ts +1 -6
  19. package/dist/lib/index.d.ts +3 -1
  20. package/dist/lib/patching/index.d.ts +1 -1
  21. package/dist/lib/patching/patch-registry.d.ts +27 -0
  22. package/dist/lib/patching/patches/index.d.ts +4 -0
  23. package/dist/lib/patching/patches/ink.patch.d.ts +3 -0
  24. package/dist/lib/patching/patches/line.patch.d.ts +3 -0
  25. package/dist/lib/patching/patches/polygon.patch.d.ts +3 -0
  26. package/dist/lib/patching/patches/polyline.patch.d.ts +3 -0
  27. package/dist/lib/selectors.d.ts +8 -12
  28. package/dist/lib/tools/default-tools.d.ts +450 -0
  29. package/dist/lib/tools/tools-utils.d.ts +25 -0
  30. package/dist/lib/tools/types.d.ts +96 -0
  31. package/dist/lib/types.d.ts +78 -161
  32. package/dist/lib/utils/index.d.ts +1 -0
  33. package/dist/lib/utils/use-state.d.ts +12 -0
  34. package/dist/preact/adapter.d.ts +1 -5
  35. package/dist/preact/index.cjs +1 -1
  36. package/dist/preact/index.cjs.map +1 -1
  37. package/dist/preact/index.js +390 -1795
  38. package/dist/preact/index.js.map +1 -1
  39. package/dist/react/adapter.d.ts +2 -4
  40. package/dist/react/index.cjs +1 -1
  41. package/dist/react/index.cjs.map +1 -1
  42. package/dist/react/index.js +391 -1794
  43. package/dist/react/index.js.map +1 -1
  44. package/dist/shared-preact/components/annotation-container.d.ts +18 -16
  45. package/dist/shared-preact/components/annotation-layer.d.ts +9 -2
  46. package/dist/shared-preact/components/annotation-paint-layer.d.ts +6 -0
  47. package/dist/shared-preact/components/annotations/free-text.d.ts +1 -0
  48. package/dist/shared-preact/components/annotations/polygon.d.ts +4 -1
  49. package/dist/shared-preact/components/annotations.d.ts +4 -1
  50. package/dist/shared-preact/components/preview-renderer.d.ts +7 -0
  51. package/dist/shared-preact/components/text-markup/highlight.d.ts +2 -2
  52. package/dist/shared-preact/components/text-markup/squiggly.d.ts +2 -2
  53. package/dist/shared-preact/components/text-markup/strikeout.d.ts +2 -2
  54. package/dist/shared-preact/components/text-markup/underline.d.ts +2 -2
  55. package/dist/shared-preact/types.d.ts +32 -2
  56. package/dist/shared-react/components/annotation-container.d.ts +18 -16
  57. package/dist/shared-react/components/annotation-layer.d.ts +9 -2
  58. package/dist/shared-react/components/annotation-paint-layer.d.ts +6 -0
  59. package/dist/shared-react/components/annotations/free-text.d.ts +1 -0
  60. package/dist/shared-react/components/annotations/polygon.d.ts +4 -1
  61. package/dist/shared-react/components/annotations.d.ts +4 -1
  62. package/dist/shared-react/components/preview-renderer.d.ts +7 -0
  63. package/dist/shared-react/components/text-markup/highlight.d.ts +2 -2
  64. package/dist/shared-react/components/text-markup/squiggly.d.ts +2 -2
  65. package/dist/shared-react/components/text-markup/strikeout.d.ts +2 -2
  66. package/dist/shared-react/components/text-markup/underline.d.ts +2 -2
  67. package/dist/shared-react/types.d.ts +32 -2
  68. package/dist/vue/hooks/index.d.ts +1 -0
  69. package/dist/vue/hooks/use-annotation.d.ts +3 -0
  70. package/dist/vue/index.cjs +2 -0
  71. package/dist/vue/index.cjs.map +1 -0
  72. package/dist/vue/index.d.ts +2 -0
  73. package/dist/vue/index.js +10 -0
  74. package/dist/vue/index.js.map +1 -0
  75. package/package.json +18 -11
  76. package/dist/lib/patching/derived-rect.d.ts +0 -2
  77. package/dist/lib/variant-key.d.ts +0 -8
  78. package/dist/shared-preact/components/annotations/circle-paint.d.ts +0 -10
  79. package/dist/shared-preact/components/annotations/free-text-paint.d.ts +0 -10
  80. package/dist/shared-preact/components/annotations/ink-highlight-paint.d.ts +0 -0
  81. package/dist/shared-preact/components/annotations/ink-paint.d.ts +0 -18
  82. package/dist/shared-preact/components/annotations/line-paint.d.ts +0 -10
  83. package/dist/shared-preact/components/annotations/polygon-paint.d.ts +0 -9
  84. package/dist/shared-preact/components/annotations/polyline-paint.d.ts +0 -10
  85. package/dist/shared-preact/components/annotations/square-paint.d.ts +0 -10
  86. package/dist/shared-preact/components/annotations/stamp-paint.d.ts +0 -8
  87. package/dist/shared-preact/components/resize-handles.d.ts +0 -9
  88. package/dist/shared-preact/components/vertex-editor.d.ts +0 -19
  89. package/dist/shared-preact/hooks/use-drag-resize.d.ts +0 -38
  90. package/dist/shared-preact/patch-ink.d.ts +0 -16
  91. package/dist/shared-preact/patchers.d.ts +0 -9
  92. package/dist/shared-preact/vertex-patchers.d.ts +0 -10
  93. package/dist/shared-react/components/annotations/circle-paint.d.ts +0 -10
  94. package/dist/shared-react/components/annotations/free-text-paint.d.ts +0 -10
  95. package/dist/shared-react/components/annotations/ink-highlight-paint.d.ts +0 -0
  96. package/dist/shared-react/components/annotations/ink-paint.d.ts +0 -17
  97. package/dist/shared-react/components/annotations/line-paint.d.ts +0 -10
  98. package/dist/shared-react/components/annotations/polygon-paint.d.ts +0 -9
  99. package/dist/shared-react/components/annotations/polyline-paint.d.ts +0 -10
  100. package/dist/shared-react/components/annotations/square-paint.d.ts +0 -10
  101. package/dist/shared-react/components/annotations/stamp-paint.d.ts +0 -8
  102. package/dist/shared-react/components/resize-handles.d.ts +0 -9
  103. package/dist/shared-react/components/vertex-editor.d.ts +0 -19
  104. package/dist/shared-react/hooks/use-drag-resize.d.ts +0 -38
  105. package/dist/shared-react/patch-ink.d.ts +0 -16
  106. package/dist/shared-react/patchers.d.ts +0 -9
  107. package/dist/shared-react/vertex-patchers.d.ts +0 -10
@@ -0,0 +1,450 @@
1
+ import { PdfAnnotationBorderStyle, PdfAnnotationLineEnding, PdfAnnotationSubtype, PdfBlendMode, PdfStandardFont, PdfTextAlignment, PdfVerticalAlignment } from '@embedpdf/models';
2
+ export declare const defaultTools: ({
3
+ id: "highlight";
4
+ name: string;
5
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 1 | 0;
6
+ interaction: {
7
+ mode: string;
8
+ exclusive: false;
9
+ textSelection: true;
10
+ cursor?: undefined;
11
+ };
12
+ defaults: {
13
+ type: PdfAnnotationSubtype.HIGHLIGHT;
14
+ color: string;
15
+ opacity: number;
16
+ blendMode: PdfBlendMode.Multiply;
17
+ strokeWidth?: undefined;
18
+ intent?: undefined;
19
+ strokeColor?: undefined;
20
+ strokeStyle?: undefined;
21
+ lineEndings?: undefined;
22
+ contents?: undefined;
23
+ fontSize?: undefined;
24
+ fontColor?: undefined;
25
+ fontFamily?: undefined;
26
+ textAlign?: undefined;
27
+ verticalAlign?: undefined;
28
+ backgroundColor?: undefined;
29
+ };
30
+ clickBehavior?: undefined;
31
+ } | {
32
+ id: "underline";
33
+ name: string;
34
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 1 | 0;
35
+ interaction: {
36
+ mode: string;
37
+ exclusive: false;
38
+ textSelection: true;
39
+ cursor?: undefined;
40
+ };
41
+ defaults: {
42
+ type: PdfAnnotationSubtype.UNDERLINE;
43
+ color: string;
44
+ opacity: number;
45
+ blendMode?: undefined;
46
+ strokeWidth?: undefined;
47
+ intent?: undefined;
48
+ strokeColor?: undefined;
49
+ strokeStyle?: undefined;
50
+ lineEndings?: undefined;
51
+ contents?: undefined;
52
+ fontSize?: undefined;
53
+ fontColor?: undefined;
54
+ fontFamily?: undefined;
55
+ textAlign?: undefined;
56
+ verticalAlign?: undefined;
57
+ backgroundColor?: undefined;
58
+ };
59
+ clickBehavior?: undefined;
60
+ } | {
61
+ id: "strikeout";
62
+ name: string;
63
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 1 | 0;
64
+ interaction: {
65
+ mode: string;
66
+ exclusive: false;
67
+ textSelection: true;
68
+ cursor?: undefined;
69
+ };
70
+ defaults: {
71
+ type: PdfAnnotationSubtype.STRIKEOUT;
72
+ color: string;
73
+ opacity: number;
74
+ blendMode?: undefined;
75
+ strokeWidth?: undefined;
76
+ intent?: undefined;
77
+ strokeColor?: undefined;
78
+ strokeStyle?: undefined;
79
+ lineEndings?: undefined;
80
+ contents?: undefined;
81
+ fontSize?: undefined;
82
+ fontColor?: undefined;
83
+ fontFamily?: undefined;
84
+ textAlign?: undefined;
85
+ verticalAlign?: undefined;
86
+ backgroundColor?: undefined;
87
+ };
88
+ clickBehavior?: undefined;
89
+ } | {
90
+ id: "squiggly";
91
+ name: string;
92
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 1 | 0;
93
+ interaction: {
94
+ mode: string;
95
+ exclusive: false;
96
+ textSelection: true;
97
+ cursor?: undefined;
98
+ };
99
+ defaults: {
100
+ type: PdfAnnotationSubtype.SQUIGGLY;
101
+ color: string;
102
+ opacity: number;
103
+ blendMode?: undefined;
104
+ strokeWidth?: undefined;
105
+ intent?: undefined;
106
+ strokeColor?: undefined;
107
+ strokeStyle?: undefined;
108
+ lineEndings?: undefined;
109
+ contents?: undefined;
110
+ fontSize?: undefined;
111
+ fontColor?: undefined;
112
+ fontFamily?: undefined;
113
+ textAlign?: undefined;
114
+ verticalAlign?: undefined;
115
+ backgroundColor?: undefined;
116
+ };
117
+ clickBehavior?: undefined;
118
+ } | {
119
+ id: "ink";
120
+ name: string;
121
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 5;
122
+ interaction: {
123
+ mode: string;
124
+ exclusive: false;
125
+ cursor: string;
126
+ textSelection?: undefined;
127
+ };
128
+ defaults: {
129
+ type: PdfAnnotationSubtype.INK;
130
+ color: string;
131
+ opacity: number;
132
+ strokeWidth: number;
133
+ blendMode?: undefined;
134
+ intent?: undefined;
135
+ strokeColor?: undefined;
136
+ strokeStyle?: undefined;
137
+ lineEndings?: undefined;
138
+ contents?: undefined;
139
+ fontSize?: undefined;
140
+ fontColor?: undefined;
141
+ fontFamily?: undefined;
142
+ textAlign?: undefined;
143
+ verticalAlign?: undefined;
144
+ backgroundColor?: undefined;
145
+ };
146
+ clickBehavior?: undefined;
147
+ } | {
148
+ id: "inkHighlighter";
149
+ name: string;
150
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 10;
151
+ interaction: {
152
+ mode: string;
153
+ exclusive: false;
154
+ cursor: string;
155
+ textSelection?: undefined;
156
+ };
157
+ defaults: {
158
+ type: PdfAnnotationSubtype.INK;
159
+ intent: string;
160
+ color: string;
161
+ opacity: number;
162
+ strokeWidth: number;
163
+ blendMode: PdfBlendMode.Multiply;
164
+ strokeColor?: undefined;
165
+ strokeStyle?: undefined;
166
+ lineEndings?: undefined;
167
+ contents?: undefined;
168
+ fontSize?: undefined;
169
+ fontColor?: undefined;
170
+ fontFamily?: undefined;
171
+ textAlign?: undefined;
172
+ verticalAlign?: undefined;
173
+ backgroundColor?: undefined;
174
+ };
175
+ clickBehavior?: undefined;
176
+ } | {
177
+ id: "circle";
178
+ name: string;
179
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 1 | 0;
180
+ interaction: {
181
+ mode: string;
182
+ exclusive: false;
183
+ cursor: string;
184
+ textSelection?: undefined;
185
+ };
186
+ defaults: {
187
+ type: PdfAnnotationSubtype.CIRCLE;
188
+ color: string;
189
+ opacity: number;
190
+ strokeWidth: number;
191
+ strokeColor: string;
192
+ strokeStyle: PdfAnnotationBorderStyle.SOLID;
193
+ blendMode?: undefined;
194
+ intent?: undefined;
195
+ lineEndings?: undefined;
196
+ contents?: undefined;
197
+ fontSize?: undefined;
198
+ fontColor?: undefined;
199
+ fontFamily?: undefined;
200
+ textAlign?: undefined;
201
+ verticalAlign?: undefined;
202
+ backgroundColor?: undefined;
203
+ };
204
+ clickBehavior: {
205
+ enabled: true;
206
+ defaultSize: {
207
+ width: number;
208
+ height: number;
209
+ };
210
+ defaultLength?: undefined;
211
+ defaultAngle?: undefined;
212
+ defaultContent?: undefined;
213
+ };
214
+ } | {
215
+ id: "square";
216
+ name: string;
217
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 1 | 0;
218
+ interaction: {
219
+ mode: string;
220
+ exclusive: false;
221
+ cursor: string;
222
+ textSelection?: undefined;
223
+ };
224
+ defaults: {
225
+ type: PdfAnnotationSubtype.SQUARE;
226
+ color: string;
227
+ opacity: number;
228
+ strokeWidth: number;
229
+ strokeColor: string;
230
+ strokeStyle: PdfAnnotationBorderStyle.SOLID;
231
+ blendMode?: undefined;
232
+ intent?: undefined;
233
+ lineEndings?: undefined;
234
+ contents?: undefined;
235
+ fontSize?: undefined;
236
+ fontColor?: undefined;
237
+ fontFamily?: undefined;
238
+ textAlign?: undefined;
239
+ verticalAlign?: undefined;
240
+ backgroundColor?: undefined;
241
+ };
242
+ clickBehavior: {
243
+ enabled: true;
244
+ defaultSize: {
245
+ width: number;
246
+ height: number;
247
+ };
248
+ defaultLength?: undefined;
249
+ defaultAngle?: undefined;
250
+ defaultContent?: undefined;
251
+ };
252
+ } | {
253
+ id: "line";
254
+ name: string;
255
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 5;
256
+ interaction: {
257
+ mode: string;
258
+ exclusive: false;
259
+ cursor: string;
260
+ textSelection?: undefined;
261
+ };
262
+ defaults: {
263
+ type: PdfAnnotationSubtype.LINE;
264
+ color: string;
265
+ opacity: number;
266
+ strokeWidth: number;
267
+ strokeColor: string;
268
+ blendMode?: undefined;
269
+ intent?: undefined;
270
+ strokeStyle?: undefined;
271
+ lineEndings?: undefined;
272
+ contents?: undefined;
273
+ fontSize?: undefined;
274
+ fontColor?: undefined;
275
+ fontFamily?: undefined;
276
+ textAlign?: undefined;
277
+ verticalAlign?: undefined;
278
+ backgroundColor?: undefined;
279
+ };
280
+ clickBehavior: {
281
+ enabled: true;
282
+ defaultLength: number;
283
+ defaultAngle: number;
284
+ defaultSize?: undefined;
285
+ defaultContent?: undefined;
286
+ };
287
+ } | {
288
+ id: "lineArrow";
289
+ name: string;
290
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 0 | 10;
291
+ interaction: {
292
+ mode: string;
293
+ exclusive: false;
294
+ cursor: string;
295
+ textSelection?: undefined;
296
+ };
297
+ defaults: {
298
+ type: PdfAnnotationSubtype.LINE;
299
+ intent: string;
300
+ color: string;
301
+ opacity: number;
302
+ strokeWidth: number;
303
+ strokeColor: string;
304
+ lineEndings: {
305
+ start: PdfAnnotationLineEnding.None;
306
+ end: PdfAnnotationLineEnding.OpenArrow;
307
+ };
308
+ blendMode?: undefined;
309
+ strokeStyle?: undefined;
310
+ contents?: undefined;
311
+ fontSize?: undefined;
312
+ fontColor?: undefined;
313
+ fontFamily?: undefined;
314
+ textAlign?: undefined;
315
+ verticalAlign?: undefined;
316
+ backgroundColor?: undefined;
317
+ };
318
+ clickBehavior: {
319
+ enabled: true;
320
+ defaultLength: number;
321
+ defaultAngle: number;
322
+ defaultSize?: undefined;
323
+ defaultContent?: undefined;
324
+ };
325
+ } | {
326
+ id: "polyline";
327
+ name: string;
328
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 1 | 0;
329
+ interaction: {
330
+ mode: string;
331
+ exclusive: false;
332
+ cursor: string;
333
+ textSelection?: undefined;
334
+ };
335
+ defaults: {
336
+ type: PdfAnnotationSubtype.POLYLINE;
337
+ color: string;
338
+ opacity: number;
339
+ strokeWidth: number;
340
+ strokeColor: string;
341
+ blendMode?: undefined;
342
+ intent?: undefined;
343
+ strokeStyle?: undefined;
344
+ lineEndings?: undefined;
345
+ contents?: undefined;
346
+ fontSize?: undefined;
347
+ fontColor?: undefined;
348
+ fontFamily?: undefined;
349
+ textAlign?: undefined;
350
+ verticalAlign?: undefined;
351
+ backgroundColor?: undefined;
352
+ };
353
+ clickBehavior?: undefined;
354
+ } | {
355
+ id: "polygon";
356
+ name: string;
357
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 1 | 0;
358
+ interaction: {
359
+ mode: string;
360
+ exclusive: false;
361
+ cursor: string;
362
+ textSelection?: undefined;
363
+ };
364
+ defaults: {
365
+ type: PdfAnnotationSubtype.POLYGON;
366
+ color: string;
367
+ opacity: number;
368
+ strokeWidth: number;
369
+ strokeColor: string;
370
+ blendMode?: undefined;
371
+ intent?: undefined;
372
+ strokeStyle?: undefined;
373
+ lineEndings?: undefined;
374
+ contents?: undefined;
375
+ fontSize?: undefined;
376
+ fontColor?: undefined;
377
+ fontFamily?: undefined;
378
+ textAlign?: undefined;
379
+ verticalAlign?: undefined;
380
+ backgroundColor?: undefined;
381
+ };
382
+ clickBehavior?: undefined;
383
+ } | {
384
+ id: "freeText";
385
+ name: string;
386
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 1 | 0;
387
+ interaction: {
388
+ mode: string;
389
+ exclusive: false;
390
+ cursor: string;
391
+ textSelection?: undefined;
392
+ };
393
+ defaults: {
394
+ type: PdfAnnotationSubtype.FREETEXT;
395
+ contents: string;
396
+ fontSize: number;
397
+ fontColor: string;
398
+ fontFamily: PdfStandardFont.Helvetica;
399
+ textAlign: PdfTextAlignment.Left;
400
+ verticalAlign: PdfVerticalAlignment.Top;
401
+ backgroundColor: string;
402
+ opacity: number;
403
+ color?: undefined;
404
+ blendMode?: undefined;
405
+ strokeWidth?: undefined;
406
+ intent?: undefined;
407
+ strokeColor?: undefined;
408
+ strokeStyle?: undefined;
409
+ lineEndings?: undefined;
410
+ };
411
+ clickBehavior: {
412
+ enabled: true;
413
+ defaultSize: {
414
+ width: number;
415
+ height: number;
416
+ };
417
+ defaultContent: string;
418
+ defaultLength?: undefined;
419
+ defaultAngle?: undefined;
420
+ };
421
+ } | {
422
+ id: "stamp";
423
+ name: string;
424
+ matchScore: (a: import('@embedpdf/models').PdfAnnotationObject) => 1 | 0;
425
+ interaction: {
426
+ mode: string;
427
+ exclusive: false;
428
+ cursor: string;
429
+ textSelection?: undefined;
430
+ };
431
+ defaults: {
432
+ type: PdfAnnotationSubtype.STAMP;
433
+ color?: undefined;
434
+ opacity?: undefined;
435
+ blendMode?: undefined;
436
+ strokeWidth?: undefined;
437
+ intent?: undefined;
438
+ strokeColor?: undefined;
439
+ strokeStyle?: undefined;
440
+ lineEndings?: undefined;
441
+ contents?: undefined;
442
+ fontSize?: undefined;
443
+ fontColor?: undefined;
444
+ fontFamily?: undefined;
445
+ textAlign?: undefined;
446
+ verticalAlign?: undefined;
447
+ backgroundColor?: undefined;
448
+ };
449
+ clickBehavior?: undefined;
450
+ })[];
@@ -0,0 +1,25 @@
1
+ import { AnnotationTool } from './types';
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
+ };
7
+ /**
8
+ * A factory that creates a type-safe predicate function for a specific tool ID.
9
+ * This is more reliable for TypeScript's type inference than a single generic function.
10
+ */
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 {};
@@ -0,0 +1,96 @@
1
+ import { PdfAnnotationObject, PdfAnnotationSubtype, Size } from '@embedpdf/models';
2
+ /**
3
+ * Specific configuration for Stamp tools.
4
+ */
5
+ export interface StampToolConfig {
6
+ /** The base64 or URL source for the stamp's image. */
7
+ imageSrc?: string;
8
+ imageSize?: Size;
9
+ }
10
+ /**
11
+ * Click behavior for shape annotations (Circle, Square)
12
+ */
13
+ export interface ShapeClickBehavior {
14
+ /** If true, creates annotation on click with default size */
15
+ enabled: boolean;
16
+ /** Default size to use when clicking (PDF units) */
17
+ defaultSize: Size;
18
+ }
19
+ /**
20
+ * Click behavior for line annotations
21
+ */
22
+ export interface LineClickBehavior {
23
+ /** If true, creates annotation on click with default length */
24
+ enabled: boolean;
25
+ /** Default length of the line */
26
+ defaultLength: number;
27
+ /** Default angle in radians (0 = horizontal right) */
28
+ defaultAngle?: number;
29
+ }
30
+ /**
31
+ * Click behavior for free text annotations
32
+ */
33
+ export interface FreeTextClickBehavior {
34
+ /** If true, creates annotation on click with default size */
35
+ enabled: boolean;
36
+ /** Default size for the text box */
37
+ defaultSize: Size;
38
+ /** Optional default content */
39
+ defaultContent?: string;
40
+ }
41
+ /**
42
+ * A central, extensible map that associates an annotation subtype
43
+ * with its unique tool configuration interface.
44
+ */
45
+ export interface ToolConfigMap {
46
+ [PdfAnnotationSubtype.STAMP]: StampToolConfig;
47
+ }
48
+ /**
49
+ * Map of annotation subtypes to their click behavior configuration
50
+ */
51
+ export interface ClickBehaviorMap {
52
+ [PdfAnnotationSubtype.CIRCLE]: ShapeClickBehavior;
53
+ [PdfAnnotationSubtype.SQUARE]: ShapeClickBehavior;
54
+ [PdfAnnotationSubtype.LINE]: LineClickBehavior;
55
+ [PdfAnnotationSubtype.FREETEXT]: FreeTextClickBehavior;
56
+ }
57
+ type GetToolConfig<T extends PdfAnnotationObject> = T['type'] extends keyof ToolConfigMap ? ToolConfigMap[T['type']] : {};
58
+ type ClickBehaviorFor<T extends PdfAnnotationObject> = Extract<T['type'], keyof ClickBehaviorMap> extends never ? {} : {
59
+ clickBehavior?: ClickBehaviorMap[Extract<T['type'], keyof ClickBehaviorMap>];
60
+ };
61
+ /**
62
+ * The primary interface for defining an annotation tool.
63
+ * Uses a type alias to properly combine the base interface with conditional properties.
64
+ */
65
+ export type AnnotationTool<T extends PdfAnnotationObject = PdfAnnotationObject> = {
66
+ /** A unique identifier, e.g., 'ink', 'arrow' */
67
+ id: string;
68
+ /** A user-facing name for UI elements, e.g., 'Pen' */
69
+ name: string;
70
+ /**
71
+ * Determines how well this tool matches an existing annotation.
72
+ * Higher numbers indicate a more specific match.
73
+ */
74
+ matchScore: (annotation: PdfAnnotationObject) => number;
75
+ /**
76
+ * The defaults combine the base annotation properties (Partial<T>)
77
+ * with any custom tool configuration (C) found in the ToolConfigMap.
78
+ */
79
+ defaults: Partial<T> & GetToolConfig<T>;
80
+ /** Defines how this tool interacts with the viewer. */
81
+ interaction: {
82
+ mode: string;
83
+ exclusive: boolean;
84
+ cursor?: string;
85
+ /** If true, this interaction mode is activated by selecting text. */
86
+ textSelection?: boolean;
87
+ };
88
+ /** Tool-specific behavior settings that override plugin defaults */
89
+ behavior?: {
90
+ /** When true, deactivate this tool after creating an annotation. Overrides plugin config. */
91
+ deactivateToolAfterCreate?: boolean;
92
+ /** When true, select the annotation immediately after creation. Overrides plugin config. */
93
+ selectAfterCreate?: boolean;
94
+ };
95
+ } & ClickBehaviorFor<T>;
96
+ export {};