@embedpdf/plugin-annotation 2.10.1 → 2.11.1

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 (49) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +19 -14
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +2 -1
  6. package/dist/lib/annotation-plugin.d.ts +1 -1
  7. package/dist/lib/handlers/types.d.ts +17 -5
  8. package/dist/lib/index.d.ts +1 -0
  9. package/dist/lib/tools/default-tools.d.ts +12 -12
  10. package/dist/lib/tools/tools-utils.d.ts +9 -9
  11. package/dist/lib/tools/types.d.ts +1 -1
  12. package/dist/lib/types.d.ts +5 -4
  13. package/dist/preact/index.cjs +1 -1
  14. package/dist/preact/index.cjs.map +1 -1
  15. package/dist/preact/index.js +48 -45
  16. package/dist/preact/index.js.map +1 -1
  17. package/dist/react/index.cjs +1 -1
  18. package/dist/react/index.cjs.map +1 -1
  19. package/dist/react/index.js +48 -45
  20. package/dist/react/index.js.map +1 -1
  21. package/dist/shared/components/types.d.ts +19 -5
  22. package/dist/shared-preact/components/types.d.ts +19 -5
  23. package/dist/shared-react/components/types.d.ts +19 -5
  24. package/dist/svelte/components/annotations/CirclePreview.svelte.d.ts +10 -0
  25. package/dist/svelte/components/annotations/FreeTextPreview.svelte.d.ts +10 -0
  26. package/dist/svelte/components/annotations/InkPreview.svelte.d.ts +10 -0
  27. package/dist/svelte/components/annotations/LinePreview.svelte.d.ts +10 -0
  28. package/dist/svelte/components/annotations/PolygonPreview.svelte.d.ts +10 -0
  29. package/dist/svelte/components/annotations/PolylinePreview.svelte.d.ts +10 -0
  30. package/dist/svelte/components/annotations/SquarePreview.svelte.d.ts +10 -0
  31. package/dist/svelte/context/types.d.ts +19 -5
  32. package/dist/svelte/index.cjs +1 -1
  33. package/dist/svelte/index.cjs.map +1 -1
  34. package/dist/svelte/index.js +247 -425
  35. package/dist/svelte/index.js.map +1 -1
  36. package/dist/vue/components/annotations/circle-preview.vue.d.ts +10 -0
  37. package/dist/vue/components/annotations/free-text-preview.vue.d.ts +10 -0
  38. package/dist/vue/components/annotations/ink-preview.vue.d.ts +10 -0
  39. package/dist/vue/components/annotations/line-preview.vue.d.ts +10 -0
  40. package/dist/vue/components/annotations/polygon-preview.vue.d.ts +10 -0
  41. package/dist/vue/components/annotations/polyline-preview.vue.d.ts +10 -0
  42. package/dist/vue/components/annotations/square-preview.vue.d.ts +10 -0
  43. package/dist/vue/context/types.d.ts +19 -5
  44. package/dist/vue/hooks/use-annotation.d.ts +2 -0
  45. package/dist/vue/index.cjs +1 -1
  46. package/dist/vue/index.cjs.map +1 -1
  47. package/dist/vue/index.js +279 -163
  48. package/dist/vue/index.js.map +1 -1
  49. package/package.json +12 -12
@@ -1,5 +1,5 @@
1
1
  import { PdfAnnotationObject, PdfBlendMode, Rect } from '@embedpdf/models';
2
- import { TrackedAnnotation } from '../../index.ts';
2
+ import { TrackedAnnotation, PreviewState } from '../../index.ts';
3
3
  import { HandleElementProps, SelectionMenuPropsBase, SelectionMenuRenderFn } from '../../react/utils.ts';
4
4
  import { JSX, CSSProperties, MouseEvent } from '../../react/adapter.ts';
5
5
  import { VertexConfig } from '../types';
@@ -144,16 +144,24 @@ export interface SelectOverrideHelpers {
144
144
  export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject, P = never> {
145
145
  /** Unique identifier for this renderer (usually matches tool id) */
146
146
  id: string;
147
- /** Returns true if this renderer should handle the annotation */
148
- matches: (annotation: PdfAnnotationObject) => annotation is T;
149
- /** The component to render the annotation */
150
- render: (props: AnnotationRendererProps<T>) => JSX.Element;
147
+ /** Returns true if this renderer should handle the annotation. Optional for preview-only renderers. */
148
+ matches?: (annotation: PdfAnnotationObject) => annotation is T;
149
+ /** The component to render the annotation. Optional for preview-only renderers. */
150
+ render?: (props: AnnotationRendererProps<T>) => JSX.Element;
151
+ /** Returns true if this renderer should handle the given preview state */
152
+ matchesPreview?: (preview: PreviewState) => boolean;
151
153
  /** Render a preview during drag-to-create. P is the preview data type. */
152
154
  renderPreview?: (props: {
153
155
  data: P;
154
156
  bounds: Rect;
155
157
  scale: number;
156
158
  }) => JSX.Element;
159
+ /** Extra styles merged onto the preview container div (e.g. mixBlendMode for ink). */
160
+ previewContainerStyle?: (props: {
161
+ data: P;
162
+ bounds: Rect;
163
+ scale: number;
164
+ }) => CSSProperties;
157
165
  /** Vertex configuration for annotations with draggable vertices (line, polyline, polygon) */
158
166
  vertexConfig?: VertexConfig<T>;
159
167
  /** z-index for the annotation container (default: 1, text markup uses 0) */
@@ -194,11 +202,17 @@ export interface BoxedAnnotationRenderer {
194
202
  id: string;
195
203
  matches: (annotation: PdfAnnotationObject) => boolean;
196
204
  render: (props: AnnotationRendererProps) => JSX.Element;
205
+ matchesPreview?: (preview: PreviewState) => boolean;
197
206
  renderPreview?: (props: {
198
207
  data: unknown;
199
208
  bounds: Rect;
200
209
  scale: number;
201
210
  }) => JSX.Element;
211
+ previewContainerStyle?: (props: {
212
+ data: unknown;
213
+ bounds: Rect;
214
+ scale: number;
215
+ }) => CSSProperties;
202
216
  vertexConfig?: VertexConfig<PdfAnnotationObject>;
203
217
  zIndex?: number;
204
218
  defaultBlendMode?: PdfBlendMode;
@@ -1,5 +1,5 @@
1
1
  import { PdfAnnotationObject, PdfBlendMode, Rect } from '@embedpdf/models';
2
- import { TrackedAnnotation } from '../../lib/index.ts';
2
+ import { TrackedAnnotation, PreviewState } from '../../lib/index.ts';
3
3
  import { HandleElementProps, SelectionMenuPropsBase, SelectionMenuRenderFn } from '../../preact/utils.ts';
4
4
  import { JSX, CSSProperties, MouseEvent } from '../../preact/adapter.ts';
5
5
  import { VertexConfig } from '../types';
@@ -144,16 +144,24 @@ export interface SelectOverrideHelpers {
144
144
  export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject, P = never> {
145
145
  /** Unique identifier for this renderer (usually matches tool id) */
146
146
  id: string;
147
- /** Returns true if this renderer should handle the annotation */
148
- matches: (annotation: PdfAnnotationObject) => annotation is T;
149
- /** The component to render the annotation */
150
- render: (props: AnnotationRendererProps<T>) => JSX.Element;
147
+ /** Returns true if this renderer should handle the annotation. Optional for preview-only renderers. */
148
+ matches?: (annotation: PdfAnnotationObject) => annotation is T;
149
+ /** The component to render the annotation. Optional for preview-only renderers. */
150
+ render?: (props: AnnotationRendererProps<T>) => JSX.Element;
151
+ /** Returns true if this renderer should handle the given preview state */
152
+ matchesPreview?: (preview: PreviewState) => boolean;
151
153
  /** Render a preview during drag-to-create. P is the preview data type. */
152
154
  renderPreview?: (props: {
153
155
  data: P;
154
156
  bounds: Rect;
155
157
  scale: number;
156
158
  }) => JSX.Element;
159
+ /** Extra styles merged onto the preview container div (e.g. mixBlendMode for ink). */
160
+ previewContainerStyle?: (props: {
161
+ data: P;
162
+ bounds: Rect;
163
+ scale: number;
164
+ }) => CSSProperties;
157
165
  /** Vertex configuration for annotations with draggable vertices (line, polyline, polygon) */
158
166
  vertexConfig?: VertexConfig<T>;
159
167
  /** z-index for the annotation container (default: 1, text markup uses 0) */
@@ -194,11 +202,17 @@ export interface BoxedAnnotationRenderer {
194
202
  id: string;
195
203
  matches: (annotation: PdfAnnotationObject) => boolean;
196
204
  render: (props: AnnotationRendererProps) => JSX.Element;
205
+ matchesPreview?: (preview: PreviewState) => boolean;
197
206
  renderPreview?: (props: {
198
207
  data: unknown;
199
208
  bounds: Rect;
200
209
  scale: number;
201
210
  }) => JSX.Element;
211
+ previewContainerStyle?: (props: {
212
+ data: unknown;
213
+ bounds: Rect;
214
+ scale: number;
215
+ }) => CSSProperties;
202
216
  vertexConfig?: VertexConfig<PdfAnnotationObject>;
203
217
  zIndex?: number;
204
218
  defaultBlendMode?: PdfBlendMode;
@@ -1,5 +1,5 @@
1
1
  import { PdfAnnotationObject, PdfBlendMode, Rect } from '@embedpdf/models';
2
- import { TrackedAnnotation } from '../../lib/index.ts';
2
+ import { TrackedAnnotation, PreviewState } from '../../lib/index.ts';
3
3
  import { HandleElementProps, SelectionMenuPropsBase, SelectionMenuRenderFn } from '../../react/utils.ts';
4
4
  import { JSX, CSSProperties, MouseEvent } from '../../react/adapter.ts';
5
5
  import { VertexConfig } from '../types';
@@ -144,16 +144,24 @@ export interface SelectOverrideHelpers {
144
144
  export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject, P = never> {
145
145
  /** Unique identifier for this renderer (usually matches tool id) */
146
146
  id: string;
147
- /** Returns true if this renderer should handle the annotation */
148
- matches: (annotation: PdfAnnotationObject) => annotation is T;
149
- /** The component to render the annotation */
150
- render: (props: AnnotationRendererProps<T>) => JSX.Element;
147
+ /** Returns true if this renderer should handle the annotation. Optional for preview-only renderers. */
148
+ matches?: (annotation: PdfAnnotationObject) => annotation is T;
149
+ /** The component to render the annotation. Optional for preview-only renderers. */
150
+ render?: (props: AnnotationRendererProps<T>) => JSX.Element;
151
+ /** Returns true if this renderer should handle the given preview state */
152
+ matchesPreview?: (preview: PreviewState) => boolean;
151
153
  /** Render a preview during drag-to-create. P is the preview data type. */
152
154
  renderPreview?: (props: {
153
155
  data: P;
154
156
  bounds: Rect;
155
157
  scale: number;
156
158
  }) => JSX.Element;
159
+ /** Extra styles merged onto the preview container div (e.g. mixBlendMode for ink). */
160
+ previewContainerStyle?: (props: {
161
+ data: P;
162
+ bounds: Rect;
163
+ scale: number;
164
+ }) => CSSProperties;
157
165
  /** Vertex configuration for annotations with draggable vertices (line, polyline, polygon) */
158
166
  vertexConfig?: VertexConfig<T>;
159
167
  /** z-index for the annotation container (default: 1, text markup uses 0) */
@@ -194,11 +202,17 @@ export interface BoxedAnnotationRenderer {
194
202
  id: string;
195
203
  matches: (annotation: PdfAnnotationObject) => boolean;
196
204
  render: (props: AnnotationRendererProps) => JSX.Element;
205
+ matchesPreview?: (preview: PreviewState) => boolean;
197
206
  renderPreview?: (props: {
198
207
  data: unknown;
199
208
  bounds: Rect;
200
209
  scale: number;
201
210
  }) => JSX.Element;
211
+ previewContainerStyle?: (props: {
212
+ data: unknown;
213
+ bounds: Rect;
214
+ scale: number;
215
+ }) => CSSProperties;
202
216
  vertexConfig?: VertexConfig<PdfAnnotationObject>;
203
217
  zIndex?: number;
204
218
  defaultBlendMode?: PdfBlendMode;
@@ -0,0 +1,10 @@
1
+ import { Rect } from '@embedpdf/models';
2
+ import { CirclePreviewData } from '../../../lib/index.ts';
3
+ interface CirclePreviewProps {
4
+ data: CirclePreviewData;
5
+ bounds: Rect;
6
+ scale: number;
7
+ }
8
+ declare const CirclePreview: import('svelte', { with: { "resolution-mode": "import" } }).Component<CirclePreviewProps, {}, "">;
9
+ type CirclePreview = ReturnType<typeof CirclePreview>;
10
+ export default CirclePreview;
@@ -0,0 +1,10 @@
1
+ import { Rect } from '@embedpdf/models';
2
+ import { FreeTextPreviewData } from '../../../lib/index.ts';
3
+ interface FreeTextPreviewProps {
4
+ data: FreeTextPreviewData;
5
+ bounds: Rect;
6
+ scale: number;
7
+ }
8
+ declare const FreeTextPreview: import('svelte', { with: { "resolution-mode": "import" } }).Component<FreeTextPreviewProps, {}, "">;
9
+ type FreeTextPreview = ReturnType<typeof FreeTextPreview>;
10
+ export default FreeTextPreview;
@@ -0,0 +1,10 @@
1
+ import { Rect } from '@embedpdf/models';
2
+ import { InkPreviewData } from '../../../lib/index.ts';
3
+ interface InkPreviewProps {
4
+ data: InkPreviewData;
5
+ bounds: Rect;
6
+ scale: number;
7
+ }
8
+ declare const InkPreview: import('svelte', { with: { "resolution-mode": "import" } }).Component<InkPreviewProps, {}, "">;
9
+ type InkPreview = ReturnType<typeof InkPreview>;
10
+ export default InkPreview;
@@ -0,0 +1,10 @@
1
+ import { Rect } from '@embedpdf/models';
2
+ import { LinePreviewData } from '../../../lib/index.ts';
3
+ interface LinePreviewProps {
4
+ data: LinePreviewData;
5
+ bounds: Rect;
6
+ scale: number;
7
+ }
8
+ declare const LinePreview: import('svelte', { with: { "resolution-mode": "import" } }).Component<LinePreviewProps, {}, "">;
9
+ type LinePreview = ReturnType<typeof LinePreview>;
10
+ export default LinePreview;
@@ -0,0 +1,10 @@
1
+ import { Rect } from '@embedpdf/models';
2
+ import { PolygonPreviewData } from '../../../lib/index.ts';
3
+ interface PolygonPreviewProps {
4
+ data: PolygonPreviewData;
5
+ bounds: Rect;
6
+ scale: number;
7
+ }
8
+ declare const PolygonPreview: import('svelte', { with: { "resolution-mode": "import" } }).Component<PolygonPreviewProps, {}, "">;
9
+ type PolygonPreview = ReturnType<typeof PolygonPreview>;
10
+ export default PolygonPreview;
@@ -0,0 +1,10 @@
1
+ import { Rect } from '@embedpdf/models';
2
+ import { PolylinePreviewData } from '../../../lib/index.ts';
3
+ interface PolylinePreviewProps {
4
+ data: PolylinePreviewData;
5
+ bounds: Rect;
6
+ scale: number;
7
+ }
8
+ declare const PolylinePreview: import('svelte', { with: { "resolution-mode": "import" } }).Component<PolylinePreviewProps, {}, "">;
9
+ type PolylinePreview = ReturnType<typeof PolylinePreview>;
10
+ export default PolylinePreview;
@@ -0,0 +1,10 @@
1
+ import { Rect } from '@embedpdf/models';
2
+ import { SquarePreviewData } from '../../../lib/index.ts';
3
+ interface SquarePreviewProps {
4
+ data: SquarePreviewData;
5
+ bounds: Rect;
6
+ scale: number;
7
+ }
8
+ declare const SquarePreview: import('svelte', { with: { "resolution-mode": "import" } }).Component<SquarePreviewProps, {}, "">;
9
+ type SquarePreview = ReturnType<typeof SquarePreview>;
10
+ export default SquarePreview;
@@ -1,6 +1,6 @@
1
1
  import { Component } from 'svelte';
2
2
  import { PdfAnnotationObject, PdfBlendMode, Rect } from '@embedpdf/models';
3
- import { TrackedAnnotation } from '../../lib/index.ts';
3
+ import { TrackedAnnotation, PreviewState } from '../../lib/index.ts';
4
4
  import { VertexConfig } from '../../shared-svelte/types';
5
5
  /**
6
6
  * Properly typed event for annotation interactions (click, select, etc.)
@@ -38,10 +38,10 @@ export interface SelectOverrideHelpers {
38
38
  export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject, P = never> {
39
39
  /** Unique identifier for this renderer */
40
40
  id: string;
41
- /** Returns true if this renderer handles the annotation */
42
- matches: (annotation: PdfAnnotationObject) => annotation is T;
43
- /** Svelte component to render the annotation */
44
- component: Component<AnnotationRendererProps<T>>;
41
+ /** Returns true if this renderer handles the annotation. Optional for preview-only renderers. */
42
+ matches?: (annotation: PdfAnnotationObject) => annotation is T;
43
+ /** Svelte component to render the annotation. Optional for preview-only renderers. */
44
+ component?: Component<AnnotationRendererProps<T>>;
45
45
  /** Vertex configuration for annotations with draggable vertices (line, polyline, polygon) */
46
46
  vertexConfig?: VertexConfig<T>;
47
47
  /** z-index for the annotation container (default: 1, text markup uses 0) */
@@ -69,12 +69,20 @@ export interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnno
69
69
  selectOverride?: (e: AnnotationInteractionEvent, annotation: TrackedAnnotation<T>, helpers: SelectOverrideHelpers) => void;
70
70
  /** Return true to hide the selection menu for this annotation */
71
71
  hideSelectionMenu?: (annotation: T) => boolean;
72
+ /** Returns true if this renderer should handle the given preview state */
73
+ matchesPreview?: (preview: PreviewState) => boolean;
72
74
  /** Render a preview during drag-to-create. P is the preview data type. */
73
75
  renderPreview?: Component<{
74
76
  data: P;
75
77
  bounds: Rect;
76
78
  scale: number;
77
79
  }>;
80
+ /** Extra styles merged onto the preview container div (e.g. mix-blend-mode for ink). */
81
+ previewContainerStyle?: (props: {
82
+ data: P;
83
+ bounds: Rect;
84
+ scale: number;
85
+ }) => string;
78
86
  /** When true, the annotation is completely hidden when locked (e.g., form widgets defer to the form-filling layer). */
79
87
  hiddenWhenLocked?: boolean;
80
88
  /** Optional locked-mode renderer. When the annotation is locked, this replaces `component` inside the container. */
@@ -105,11 +113,17 @@ export interface BoxedAnnotationRenderer {
105
113
  onDoubleClick?: (annotationId: string, setEditingId: (id: string) => void) => void;
106
114
  selectOverride?: (e: AnnotationInteractionEvent, annotation: TrackedAnnotation, helpers: SelectOverrideHelpers) => void;
107
115
  hideSelectionMenu?: (annotation: PdfAnnotationObject) => boolean;
116
+ matchesPreview?: (preview: PreviewState) => boolean;
108
117
  renderPreview?: Component<{
109
118
  data: unknown;
110
119
  bounds: Rect;
111
120
  scale: number;
112
121
  }>;
122
+ previewContainerStyle?: (props: {
123
+ data: unknown;
124
+ bounds: Rect;
125
+ scale: number;
126
+ }) => string;
113
127
  hiddenWhenLocked?: boolean;
114
128
  renderLocked?: Component<AnnotationRendererProps>;
115
129
  }