@embedpdf/plugin-annotation 2.4.1 → 2.6.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 (71) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +1061 -430
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/annotation-plugin.d.ts +24 -6
  6. package/dist/lib/geometry/index.d.ts +1 -0
  7. package/dist/lib/geometry/rotation.d.ts +32 -0
  8. package/dist/lib/handlers/types.d.ts +3 -1
  9. package/dist/lib/index.d.ts +1 -0
  10. package/dist/lib/patching/base-patch.d.ts +87 -0
  11. package/dist/lib/patching/index.d.ts +1 -0
  12. package/dist/lib/patching/insert-upright.d.ts +20 -0
  13. package/dist/lib/patching/patch-registry.d.ts +14 -1
  14. package/dist/lib/patching/patch-utils.d.ts +54 -1
  15. package/dist/lib/patching/patches/circle.patch.d.ts +3 -0
  16. package/dist/lib/patching/patches/freetext.patch.d.ts +3 -0
  17. package/dist/lib/patching/patches/index.d.ts +4 -0
  18. package/dist/lib/patching/patches/square.patch.d.ts +3 -0
  19. package/dist/lib/patching/patches/stamp.patch.d.ts +3 -0
  20. package/dist/lib/tools/default-tools.d.ts +32 -0
  21. package/dist/lib/tools/types.d.ts +20 -1
  22. package/dist/lib/types.d.ts +67 -3
  23. package/dist/preact/adapter.d.ts +3 -0
  24. package/dist/preact/index.cjs +1 -1
  25. package/dist/preact/index.cjs.map +1 -1
  26. package/dist/preact/index.js +797 -128
  27. package/dist/preact/index.js.map +1 -1
  28. package/dist/react/adapter.d.ts +2 -1
  29. package/dist/react/index.cjs +1 -1
  30. package/dist/react/index.cjs.map +1 -1
  31. package/dist/react/index.js +797 -128
  32. package/dist/react/index.js.map +1 -1
  33. package/dist/shared/components/annotation-container.d.ts +10 -2
  34. package/dist/shared/components/annotation-layer.d.ts +9 -3
  35. package/dist/shared/components/annotations.d.ts +4 -1
  36. package/dist/shared/components/group-selection-box.d.ts +12 -4
  37. package/dist/shared/components/render-annotation.d.ts +2 -1
  38. package/dist/shared/components/types.d.ts +51 -1
  39. package/dist/shared-preact/components/annotation-container.d.ts +10 -2
  40. package/dist/shared-preact/components/annotation-layer.d.ts +9 -3
  41. package/dist/shared-preact/components/annotations.d.ts +4 -1
  42. package/dist/shared-preact/components/group-selection-box.d.ts +12 -4
  43. package/dist/shared-preact/components/render-annotation.d.ts +2 -1
  44. package/dist/shared-preact/components/types.d.ts +51 -1
  45. package/dist/shared-react/components/annotation-container.d.ts +10 -2
  46. package/dist/shared-react/components/annotation-layer.d.ts +9 -3
  47. package/dist/shared-react/components/annotations.d.ts +4 -1
  48. package/dist/shared-react/components/group-selection-box.d.ts +12 -4
  49. package/dist/shared-react/components/render-annotation.d.ts +2 -1
  50. package/dist/shared-react/components/types.d.ts +51 -1
  51. package/dist/svelte/components/AnnotationLayer.svelte.d.ts +8 -2
  52. package/dist/svelte/components/Annotations.svelte.d.ts +7 -1
  53. package/dist/svelte/components/GroupSelectionBox.svelte.d.ts +11 -3
  54. package/dist/svelte/components/RenderAnnotation.svelte.d.ts +1 -0
  55. package/dist/svelte/components/types.d.ts +14 -1
  56. package/dist/svelte/index.cjs +1 -1
  57. package/dist/svelte/index.cjs.map +1 -1
  58. package/dist/svelte/index.js +1171 -332
  59. package/dist/svelte/index.js.map +1 -1
  60. package/dist/svelte/types.d.ts +53 -0
  61. package/dist/vue/components/annotation-container.vue.d.ts +35 -9
  62. package/dist/vue/components/annotation-layer.vue.d.ts +29 -5
  63. package/dist/vue/components/annotations.vue.d.ts +278 -134
  64. package/dist/vue/components/group-selection-box.vue.d.ts +35 -10
  65. package/dist/vue/components/render-annotation.vue.d.ts +2 -0
  66. package/dist/vue/index.cjs +1 -1
  67. package/dist/vue/index.cjs.map +1 -1
  68. package/dist/vue/index.js +949 -163
  69. package/dist/vue/index.js.map +1 -1
  70. package/dist/vue/types.d.ts +52 -0
  71. package/package.json +11 -10
@@ -1,7 +1,7 @@
1
1
  import { PdfAnnotationObject } from '@embedpdf/models';
2
2
  import { TrackedAnnotation } from '../../index.ts';
3
3
  import { JSX, CSSProperties } from '../../react/adapter.ts';
4
- import { CustomAnnotationRenderer, ResizeHandleUI, AnnotationSelectionMenuRenderFn, VertexHandleUI, GroupSelectionMenuRenderFn, BoxedAnnotationRenderer } from './types';
4
+ import { CustomAnnotationRenderer, ResizeHandleUI, AnnotationSelectionMenuRenderFn, VertexHandleUI, RotationHandleUI, GroupSelectionMenuRenderFn, BoxedAnnotationRenderer, SelectionOutline } from './types';
5
5
  import { VertexConfig } from '../types';
6
6
  interface AnnotationContainerProps<T extends PdfAnnotationObject> {
7
7
  scale: number;
@@ -17,21 +17,29 @@ interface AnnotationContainerProps<T extends PdfAnnotationObject> {
17
17
  isMultiSelected?: boolean;
18
18
  isDraggable: boolean;
19
19
  isResizable: boolean;
20
+ isRotatable?: boolean;
20
21
  lockAspectRatio?: boolean;
21
22
  style?: CSSProperties;
22
23
  vertexConfig?: VertexConfig<T>;
23
24
  selectionMenu?: AnnotationSelectionMenuRenderFn;
25
+ /** @deprecated Use `selectionOutline.offset` instead */
24
26
  outlineOffset?: number;
25
27
  onDoubleClick?: (event: any) => void;
26
28
  onSelect: (event: any) => void;
27
29
  zIndex?: number;
28
30
  resizeUI?: ResizeHandleUI;
29
31
  vertexUI?: VertexHandleUI;
32
+ rotationUI?: RotationHandleUI;
33
+ /** @deprecated Use `selectionOutline.color` instead */
30
34
  selectionOutlineColor?: string;
35
+ /** Customize the selection outline (color, style, width, offset) */
36
+ selectionOutline?: SelectionOutline;
31
37
  customAnnotationRenderer?: CustomAnnotationRenderer<T>;
32
38
  /** Passed from parent but not used - destructured to prevent DOM spread */
33
39
  groupSelectionMenu?: GroupSelectionMenuRenderFn;
34
40
  /** Passed from parent but not used - destructured to prevent DOM spread */
41
+ groupSelectionOutline?: SelectionOutline;
42
+ /** Passed from parent but not used - destructured to prevent DOM spread */
35
43
  annotationRenderers?: BoxedAnnotationRenderer[];
36
44
  }
37
45
  /**
@@ -39,5 +47,5 @@ interface AnnotationContainerProps<T extends PdfAnnotationObject> {
39
47
  * When isMultiSelected is true, the container becomes passive - drag/resize
40
48
  * is handled by the GroupSelectionBox instead.
41
49
  */
42
- export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, documentId, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, isSelected, isMultiSelected, isDraggable, isResizable, lockAspectRatio, style, vertexConfig, selectionMenu, outlineOffset, onDoubleClick, onSelect, zIndex, resizeUI, vertexUI, selectionOutlineColor, customAnnotationRenderer, groupSelectionMenu: _groupSelectionMenu, annotationRenderers: _annotationRenderers, ...props }: AnnotationContainerProps<T>): JSX.Element;
50
+ export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, documentId, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, isSelected, isMultiSelected, isDraggable, isResizable, isRotatable, lockAspectRatio, style, vertexConfig, selectionMenu, outlineOffset, onDoubleClick, onSelect, zIndex, resizeUI, vertexUI, rotationUI, selectionOutlineColor, selectionOutline, customAnnotationRenderer, groupSelectionMenu: _groupSelectionMenu, groupSelectionOutline: _groupSelectionOutline, annotationRenderers: _annotationRenderers, ...props }: AnnotationContainerProps<T>): JSX.Element;
43
51
  export {};
@@ -1,5 +1,5 @@
1
1
  import { HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
2
- import { ResizeHandleUI, VertexHandleUI, CustomAnnotationRenderer, AnnotationSelectionMenuRenderFn, GroupSelectionMenuRenderFn, BoxedAnnotationRenderer } from './types';
2
+ import { ResizeHandleUI, VertexHandleUI, RotationHandleUI, SelectionOutline, CustomAnnotationRenderer, AnnotationSelectionMenuRenderFn, GroupSelectionMenuRenderFn, BoxedAnnotationRenderer } from './types';
3
3
  import { PdfAnnotationObject } from '@embedpdf/models';
4
4
  type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
5
5
  /** The ID of the document that this layer displays annotations for */
@@ -16,12 +16,18 @@ type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
16
16
  resizeUI?: ResizeHandleUI;
17
17
  /** Customize vertex handles */
18
18
  vertexUI?: VertexHandleUI;
19
- /** Customize selection outline color */
19
+ /** Customize rotation handle */
20
+ rotationUI?: RotationHandleUI;
21
+ /** @deprecated Use `selectionOutline` instead */
20
22
  selectionOutlineColor?: string;
23
+ /** Customize the selection outline for individual annotations */
24
+ selectionOutline?: SelectionOutline;
25
+ /** Customize the selection outline for the group selection box (falls back to selectionOutline) */
26
+ groupSelectionOutline?: SelectionOutline;
21
27
  /** Customize annotation renderer */
22
28
  customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;
23
29
  /** Custom renderers for specific annotation types (provided by external plugins) */
24
30
  annotationRenderers?: BoxedAnnotationRenderer[];
25
31
  };
26
- export declare function AnnotationLayer({ style, documentId, pageIndex, scale: overrideScale, rotation: overrideRotation, selectionMenu, groupSelectionMenu, resizeUI, vertexUI, selectionOutlineColor, customAnnotationRenderer, annotationRenderers, ...props }: AnnotationLayerProps): import("react/jsx-runtime").JSX.Element;
32
+ export declare function AnnotationLayer({ style, documentId, pageIndex, scale: overrideScale, rotation: overrideRotation, selectionMenu, groupSelectionMenu, resizeUI, vertexUI, rotationUI, selectionOutlineColor, selectionOutline, groupSelectionOutline, customAnnotationRenderer, annotationRenderers, ...props }: AnnotationLayerProps): import("react/jsx-runtime").JSX.Element;
27
33
  export {};
@@ -1,5 +1,5 @@
1
1
  import { PdfAnnotationObject } from '@embedpdf/models';
2
- import { CustomAnnotationRenderer, ResizeHandleUI, AnnotationSelectionMenuRenderFn, GroupSelectionMenuRenderFn, VertexHandleUI, BoxedAnnotationRenderer } from './types';
2
+ import { CustomAnnotationRenderer, ResizeHandleUI, AnnotationSelectionMenuRenderFn, GroupSelectionMenuRenderFn, VertexHandleUI, RotationHandleUI, SelectionOutline, BoxedAnnotationRenderer } from './types';
3
3
  interface AnnotationsProps {
4
4
  documentId: string;
5
5
  pageIndex: number;
@@ -11,7 +11,10 @@ interface AnnotationsProps {
11
11
  groupSelectionMenu?: GroupSelectionMenuRenderFn;
12
12
  resizeUI?: ResizeHandleUI;
13
13
  vertexUI?: VertexHandleUI;
14
+ rotationUI?: RotationHandleUI;
14
15
  selectionOutlineColor?: string;
16
+ selectionOutline?: SelectionOutline;
17
+ groupSelectionOutline?: SelectionOutline;
15
18
  customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;
16
19
  /** Custom renderers for specific annotation types (provided by external plugins) */
17
20
  annotationRenderers?: BoxedAnnotationRenderer[];
@@ -1,5 +1,5 @@
1
1
  import { TrackedAnnotation } from '../../index.ts';
2
- import { ResizeHandleUI, GroupSelectionMenuRenderFn } from './types';
2
+ import { ResizeHandleUI, RotationHandleUI, GroupSelectionMenuRenderFn, SelectionOutline } from './types';
3
3
  interface GroupSelectionBoxProps {
4
4
  documentId: string;
5
5
  pageIndex: number;
@@ -13,12 +13,20 @@ interface GroupSelectionBoxProps {
13
13
  isDraggable: boolean;
14
14
  /** Whether the group is resizable (all annotations must be group-resizable) */
15
15
  isResizable: boolean;
16
+ /** Whether the group can be rotated */
17
+ isRotatable?: boolean;
18
+ /** Whether to lock aspect ratio during group resize */
19
+ lockAspectRatio?: boolean;
16
20
  /** Resize handle UI customization */
17
21
  resizeUI?: ResizeHandleUI;
18
- /** Selection outline color */
22
+ /** Rotation handle UI customization */
23
+ rotationUI?: RotationHandleUI;
24
+ /** @deprecated Use `selectionOutline.color` instead */
19
25
  selectionOutlineColor?: string;
20
- /** Outline offset */
26
+ /** @deprecated Use `selectionOutline.offset` instead */
21
27
  outlineOffset?: number;
28
+ /** Customize the selection outline (color, style, width, offset) */
29
+ selectionOutline?: SelectionOutline;
22
30
  /** Z-index for the group box */
23
31
  zIndex?: number;
24
32
  /** Group selection menu render function */
@@ -28,5 +36,5 @@ interface GroupSelectionBoxProps {
28
36
  * GroupSelectionBox renders a bounding box around all selected annotations
29
37
  * with drag and resize handles for group manipulation.
30
38
  */
31
- export declare function GroupSelectionBox({ documentId, pageIndex, scale, rotation, pageWidth, pageHeight, selectedAnnotations, isDraggable, isResizable, resizeUI, selectionOutlineColor, outlineOffset, zIndex, groupSelectionMenu, }: GroupSelectionBoxProps): JSX.Element | null;
39
+ export declare function GroupSelectionBox({ documentId, pageIndex, scale, rotation, pageWidth, pageHeight, selectedAnnotations, isDraggable, isResizable, isRotatable, lockAspectRatio, resizeUI, rotationUI, selectionOutlineColor, outlineOffset, selectionOutline, zIndex, groupSelectionMenu, }: GroupSelectionBoxProps): JSX.Element | null;
32
40
  export {};
@@ -7,6 +7,7 @@ type RenderAnnotationProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {
7
7
  scaleFactor?: number;
8
8
  dpr?: number;
9
9
  style?: CSSProperties;
10
+ unrotated?: boolean;
10
11
  };
11
- export declare function RenderAnnotation({ documentId, pageIndex, annotation, scaleFactor, style, ...props }: RenderAnnotationProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function RenderAnnotation({ documentId, pageIndex, annotation, scaleFactor, unrotated, style, ...props }: RenderAnnotationProps): import("react/jsx-runtime").JSX.Element;
12
13
  export {};
@@ -1,7 +1,7 @@
1
1
  import { PdfAnnotationObject } from '@embedpdf/models';
2
2
  import { TrackedAnnotation } from '../../index.ts';
3
3
  import { HandleElementProps, SelectionMenuPropsBase, SelectionMenuRenderFn } from '../../react/utils.ts';
4
- import { JSX, MouseEvent, TouchEvent } from '../../react/adapter.ts';
4
+ import { JSX, CSSProperties, MouseEvent, TouchEvent } from '../../react/adapter.ts';
5
5
  export type ResizeDirection = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'none';
6
6
  export interface AnnotationSelectionContext {
7
7
  type: 'annotation';
@@ -38,6 +38,56 @@ export interface VertexHandleUI {
38
38
  /** Custom renderer for each vertex (overrides default) */
39
39
  component?: (p: HandleProps) => JSX.Element;
40
40
  }
41
+ /** Props for the rotation handle component */
42
+ export interface RotationHandleComponentProps extends HandleProps {
43
+ /** Props for the connector line element */
44
+ connectorStyle?: CSSProperties;
45
+ /** Whether to show the connector line */
46
+ showConnector?: boolean;
47
+ /** Color for the icon inside the handle (default: '#007ACC') */
48
+ iconColor?: string;
49
+ /** Resolved border configuration */
50
+ border?: RotationHandleBorder;
51
+ }
52
+ export type BorderStyle = 'solid' | 'dashed' | 'dotted';
53
+ export interface SelectionOutline {
54
+ /** Outline color (default: '#007ACC') */
55
+ color?: string;
56
+ /** Outline style (default: 'solid' for single, 'dashed' for group) */
57
+ style?: BorderStyle;
58
+ /** Outline width in px (default: 1 for single, 2 for group) */
59
+ width?: number;
60
+ /** Outline offset in px (default: 1 for single, 2 for group) */
61
+ offset?: number;
62
+ }
63
+ /** Border configuration for the rotation handle */
64
+ export interface RotationHandleBorder {
65
+ /** Border color (default: '#007ACC') */
66
+ color?: string;
67
+ /** Border style (default: 'solid') */
68
+ style?: BorderStyle;
69
+ /** Border width in px (default: 1) */
70
+ width?: number;
71
+ }
72
+ /** UI customization for rotation handle */
73
+ export interface RotationHandleUI {
74
+ /** Handle size in CSS px (default: 16) */
75
+ size?: number;
76
+ /** Gap in CSS px between the bounding box edge and the rotation handle center (default: 20) */
77
+ margin?: number;
78
+ /** Default background color for the handle (default: 'white') */
79
+ color?: string;
80
+ /** Color for the connector line (default: '#007ACC') */
81
+ connectorColor?: string;
82
+ /** Whether to show the connector line (default: true) */
83
+ showConnector?: boolean;
84
+ /** Color for the icon inside the handle (default: '#007ACC') */
85
+ iconColor?: string;
86
+ /** Border configuration for the handle */
87
+ border?: RotationHandleBorder;
88
+ /** Custom renderer for the rotation handle (overrides default) */
89
+ component?: (p: RotationHandleComponentProps) => JSX.Element;
90
+ }
41
91
  /**
42
92
  * Props for the custom annotation renderer
43
93
  */
@@ -1,7 +1,7 @@
1
1
  import { PdfAnnotationObject } from '@embedpdf/models';
2
2
  import { TrackedAnnotation } from '../../lib/index.ts';
3
3
  import { JSX, CSSProperties } from '../../preact/adapter.ts';
4
- import { CustomAnnotationRenderer, ResizeHandleUI, AnnotationSelectionMenuRenderFn, VertexHandleUI, GroupSelectionMenuRenderFn, BoxedAnnotationRenderer } from './types';
4
+ import { CustomAnnotationRenderer, ResizeHandleUI, AnnotationSelectionMenuRenderFn, VertexHandleUI, RotationHandleUI, GroupSelectionMenuRenderFn, BoxedAnnotationRenderer, SelectionOutline } from './types';
5
5
  import { VertexConfig } from '../types';
6
6
  interface AnnotationContainerProps<T extends PdfAnnotationObject> {
7
7
  scale: number;
@@ -17,21 +17,29 @@ interface AnnotationContainerProps<T extends PdfAnnotationObject> {
17
17
  isMultiSelected?: boolean;
18
18
  isDraggable: boolean;
19
19
  isResizable: boolean;
20
+ isRotatable?: boolean;
20
21
  lockAspectRatio?: boolean;
21
22
  style?: CSSProperties;
22
23
  vertexConfig?: VertexConfig<T>;
23
24
  selectionMenu?: AnnotationSelectionMenuRenderFn;
25
+ /** @deprecated Use `selectionOutline.offset` instead */
24
26
  outlineOffset?: number;
25
27
  onDoubleClick?: (event: any) => void;
26
28
  onSelect: (event: any) => void;
27
29
  zIndex?: number;
28
30
  resizeUI?: ResizeHandleUI;
29
31
  vertexUI?: VertexHandleUI;
32
+ rotationUI?: RotationHandleUI;
33
+ /** @deprecated Use `selectionOutline.color` instead */
30
34
  selectionOutlineColor?: string;
35
+ /** Customize the selection outline (color, style, width, offset) */
36
+ selectionOutline?: SelectionOutline;
31
37
  customAnnotationRenderer?: CustomAnnotationRenderer<T>;
32
38
  /** Passed from parent but not used - destructured to prevent DOM spread */
33
39
  groupSelectionMenu?: GroupSelectionMenuRenderFn;
34
40
  /** Passed from parent but not used - destructured to prevent DOM spread */
41
+ groupSelectionOutline?: SelectionOutline;
42
+ /** Passed from parent but not used - destructured to prevent DOM spread */
35
43
  annotationRenderers?: BoxedAnnotationRenderer[];
36
44
  }
37
45
  /**
@@ -39,5 +47,5 @@ interface AnnotationContainerProps<T extends PdfAnnotationObject> {
39
47
  * When isMultiSelected is true, the container becomes passive - drag/resize
40
48
  * is handled by the GroupSelectionBox instead.
41
49
  */
42
- export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, documentId, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, isSelected, isMultiSelected, isDraggable, isResizable, lockAspectRatio, style, vertexConfig, selectionMenu, outlineOffset, onDoubleClick, onSelect, zIndex, resizeUI, vertexUI, selectionOutlineColor, customAnnotationRenderer, groupSelectionMenu: _groupSelectionMenu, annotationRenderers: _annotationRenderers, ...props }: AnnotationContainerProps<T>): JSX.Element;
50
+ export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, documentId, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, isSelected, isMultiSelected, isDraggable, isResizable, isRotatable, lockAspectRatio, style, vertexConfig, selectionMenu, outlineOffset, onDoubleClick, onSelect, zIndex, resizeUI, vertexUI, rotationUI, selectionOutlineColor, selectionOutline, customAnnotationRenderer, groupSelectionMenu: _groupSelectionMenu, groupSelectionOutline: _groupSelectionOutline, annotationRenderers: _annotationRenderers, ...props }: AnnotationContainerProps<T>): JSX.Element;
43
51
  export {};
@@ -1,5 +1,5 @@
1
1
  import { HTMLAttributes, CSSProperties } from '../../preact/adapter.ts';
2
- import { ResizeHandleUI, VertexHandleUI, CustomAnnotationRenderer, AnnotationSelectionMenuRenderFn, GroupSelectionMenuRenderFn, BoxedAnnotationRenderer } from './types';
2
+ import { ResizeHandleUI, VertexHandleUI, RotationHandleUI, SelectionOutline, CustomAnnotationRenderer, AnnotationSelectionMenuRenderFn, GroupSelectionMenuRenderFn, BoxedAnnotationRenderer } from './types';
3
3
  import { PdfAnnotationObject } from '@embedpdf/models';
4
4
  type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
5
5
  /** The ID of the document that this layer displays annotations for */
@@ -16,12 +16,18 @@ type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
16
16
  resizeUI?: ResizeHandleUI;
17
17
  /** Customize vertex handles */
18
18
  vertexUI?: VertexHandleUI;
19
- /** Customize selection outline color */
19
+ /** Customize rotation handle */
20
+ rotationUI?: RotationHandleUI;
21
+ /** @deprecated Use `selectionOutline` instead */
20
22
  selectionOutlineColor?: string;
23
+ /** Customize the selection outline for individual annotations */
24
+ selectionOutline?: SelectionOutline;
25
+ /** Customize the selection outline for the group selection box (falls back to selectionOutline) */
26
+ groupSelectionOutline?: SelectionOutline;
21
27
  /** Customize annotation renderer */
22
28
  customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;
23
29
  /** Custom renderers for specific annotation types (provided by external plugins) */
24
30
  annotationRenderers?: BoxedAnnotationRenderer[];
25
31
  };
26
- export declare function AnnotationLayer({ style, documentId, pageIndex, scale: overrideScale, rotation: overrideRotation, selectionMenu, groupSelectionMenu, resizeUI, vertexUI, selectionOutlineColor, customAnnotationRenderer, annotationRenderers, ...props }: AnnotationLayerProps): import("preact").JSX.Element;
32
+ export declare function AnnotationLayer({ style, documentId, pageIndex, scale: overrideScale, rotation: overrideRotation, selectionMenu, groupSelectionMenu, resizeUI, vertexUI, rotationUI, selectionOutlineColor, selectionOutline, groupSelectionOutline, customAnnotationRenderer, annotationRenderers, ...props }: AnnotationLayerProps): import("preact").JSX.Element;
27
33
  export {};
@@ -1,5 +1,5 @@
1
1
  import { PdfAnnotationObject } from '@embedpdf/models';
2
- import { CustomAnnotationRenderer, ResizeHandleUI, AnnotationSelectionMenuRenderFn, GroupSelectionMenuRenderFn, VertexHandleUI, BoxedAnnotationRenderer } from './types';
2
+ import { CustomAnnotationRenderer, ResizeHandleUI, AnnotationSelectionMenuRenderFn, GroupSelectionMenuRenderFn, VertexHandleUI, RotationHandleUI, SelectionOutline, BoxedAnnotationRenderer } from './types';
3
3
  interface AnnotationsProps {
4
4
  documentId: string;
5
5
  pageIndex: number;
@@ -11,7 +11,10 @@ interface AnnotationsProps {
11
11
  groupSelectionMenu?: GroupSelectionMenuRenderFn;
12
12
  resizeUI?: ResizeHandleUI;
13
13
  vertexUI?: VertexHandleUI;
14
+ rotationUI?: RotationHandleUI;
14
15
  selectionOutlineColor?: string;
16
+ selectionOutline?: SelectionOutline;
17
+ groupSelectionOutline?: SelectionOutline;
15
18
  customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;
16
19
  /** Custom renderers for specific annotation types (provided by external plugins) */
17
20
  annotationRenderers?: BoxedAnnotationRenderer[];
@@ -1,5 +1,5 @@
1
1
  import { TrackedAnnotation } from '../../lib/index.ts';
2
- import { ResizeHandleUI, GroupSelectionMenuRenderFn } from './types';
2
+ import { ResizeHandleUI, RotationHandleUI, GroupSelectionMenuRenderFn, SelectionOutline } from './types';
3
3
  interface GroupSelectionBoxProps {
4
4
  documentId: string;
5
5
  pageIndex: number;
@@ -13,12 +13,20 @@ interface GroupSelectionBoxProps {
13
13
  isDraggable: boolean;
14
14
  /** Whether the group is resizable (all annotations must be group-resizable) */
15
15
  isResizable: boolean;
16
+ /** Whether the group can be rotated */
17
+ isRotatable?: boolean;
18
+ /** Whether to lock aspect ratio during group resize */
19
+ lockAspectRatio?: boolean;
16
20
  /** Resize handle UI customization */
17
21
  resizeUI?: ResizeHandleUI;
18
- /** Selection outline color */
22
+ /** Rotation handle UI customization */
23
+ rotationUI?: RotationHandleUI;
24
+ /** @deprecated Use `selectionOutline.color` instead */
19
25
  selectionOutlineColor?: string;
20
- /** Outline offset */
26
+ /** @deprecated Use `selectionOutline.offset` instead */
21
27
  outlineOffset?: number;
28
+ /** Customize the selection outline (color, style, width, offset) */
29
+ selectionOutline?: SelectionOutline;
22
30
  /** Z-index for the group box */
23
31
  zIndex?: number;
24
32
  /** Group selection menu render function */
@@ -28,5 +36,5 @@ interface GroupSelectionBoxProps {
28
36
  * GroupSelectionBox renders a bounding box around all selected annotations
29
37
  * with drag and resize handles for group manipulation.
30
38
  */
31
- export declare function GroupSelectionBox({ documentId, pageIndex, scale, rotation, pageWidth, pageHeight, selectedAnnotations, isDraggable, isResizable, resizeUI, selectionOutlineColor, outlineOffset, zIndex, groupSelectionMenu, }: GroupSelectionBoxProps): JSX.Element | null;
39
+ export declare function GroupSelectionBox({ documentId, pageIndex, scale, rotation, pageWidth, pageHeight, selectedAnnotations, isDraggable, isResizable, isRotatable, lockAspectRatio, resizeUI, rotationUI, selectionOutlineColor, outlineOffset, selectionOutline, zIndex, groupSelectionMenu, }: GroupSelectionBoxProps): JSX.Element | null;
32
40
  export {};
@@ -7,6 +7,7 @@ type RenderAnnotationProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {
7
7
  scaleFactor?: number;
8
8
  dpr?: number;
9
9
  style?: CSSProperties;
10
+ unrotated?: boolean;
10
11
  };
11
- export declare function RenderAnnotation({ documentId, pageIndex, annotation, scaleFactor, style, ...props }: RenderAnnotationProps): import("preact").JSX.Element;
12
+ export declare function RenderAnnotation({ documentId, pageIndex, annotation, scaleFactor, unrotated, style, ...props }: RenderAnnotationProps): import("preact").JSX.Element;
12
13
  export {};
@@ -1,7 +1,7 @@
1
1
  import { PdfAnnotationObject } from '@embedpdf/models';
2
2
  import { TrackedAnnotation } from '../../lib/index.ts';
3
3
  import { HandleElementProps, SelectionMenuPropsBase, SelectionMenuRenderFn } from '../../preact/utils.ts';
4
- import { JSX, MouseEvent, TouchEvent } from '../../preact/adapter.ts';
4
+ import { JSX, CSSProperties, MouseEvent, TouchEvent } from '../../preact/adapter.ts';
5
5
  export type ResizeDirection = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'none';
6
6
  export interface AnnotationSelectionContext {
7
7
  type: 'annotation';
@@ -38,6 +38,56 @@ export interface VertexHandleUI {
38
38
  /** Custom renderer for each vertex (overrides default) */
39
39
  component?: (p: HandleProps) => JSX.Element;
40
40
  }
41
+ /** Props for the rotation handle component */
42
+ export interface RotationHandleComponentProps extends HandleProps {
43
+ /** Props for the connector line element */
44
+ connectorStyle?: CSSProperties;
45
+ /** Whether to show the connector line */
46
+ showConnector?: boolean;
47
+ /** Color for the icon inside the handle (default: '#007ACC') */
48
+ iconColor?: string;
49
+ /** Resolved border configuration */
50
+ border?: RotationHandleBorder;
51
+ }
52
+ export type BorderStyle = 'solid' | 'dashed' | 'dotted';
53
+ export interface SelectionOutline {
54
+ /** Outline color (default: '#007ACC') */
55
+ color?: string;
56
+ /** Outline style (default: 'solid' for single, 'dashed' for group) */
57
+ style?: BorderStyle;
58
+ /** Outline width in px (default: 1 for single, 2 for group) */
59
+ width?: number;
60
+ /** Outline offset in px (default: 1 for single, 2 for group) */
61
+ offset?: number;
62
+ }
63
+ /** Border configuration for the rotation handle */
64
+ export interface RotationHandleBorder {
65
+ /** Border color (default: '#007ACC') */
66
+ color?: string;
67
+ /** Border style (default: 'solid') */
68
+ style?: BorderStyle;
69
+ /** Border width in px (default: 1) */
70
+ width?: number;
71
+ }
72
+ /** UI customization for rotation handle */
73
+ export interface RotationHandleUI {
74
+ /** Handle size in CSS px (default: 16) */
75
+ size?: number;
76
+ /** Gap in CSS px between the bounding box edge and the rotation handle center (default: 20) */
77
+ margin?: number;
78
+ /** Default background color for the handle (default: 'white') */
79
+ color?: string;
80
+ /** Color for the connector line (default: '#007ACC') */
81
+ connectorColor?: string;
82
+ /** Whether to show the connector line (default: true) */
83
+ showConnector?: boolean;
84
+ /** Color for the icon inside the handle (default: '#007ACC') */
85
+ iconColor?: string;
86
+ /** Border configuration for the handle */
87
+ border?: RotationHandleBorder;
88
+ /** Custom renderer for the rotation handle (overrides default) */
89
+ component?: (p: RotationHandleComponentProps) => JSX.Element;
90
+ }
41
91
  /**
42
92
  * Props for the custom annotation renderer
43
93
  */
@@ -1,7 +1,7 @@
1
1
  import { PdfAnnotationObject } from '@embedpdf/models';
2
2
  import { TrackedAnnotation } from '../../lib/index.ts';
3
3
  import { JSX, CSSProperties } from '../../react/adapter.ts';
4
- import { CustomAnnotationRenderer, ResizeHandleUI, AnnotationSelectionMenuRenderFn, VertexHandleUI, GroupSelectionMenuRenderFn, BoxedAnnotationRenderer } from './types';
4
+ import { CustomAnnotationRenderer, ResizeHandleUI, AnnotationSelectionMenuRenderFn, VertexHandleUI, RotationHandleUI, GroupSelectionMenuRenderFn, BoxedAnnotationRenderer, SelectionOutline } from './types';
5
5
  import { VertexConfig } from '../types';
6
6
  interface AnnotationContainerProps<T extends PdfAnnotationObject> {
7
7
  scale: number;
@@ -17,21 +17,29 @@ interface AnnotationContainerProps<T extends PdfAnnotationObject> {
17
17
  isMultiSelected?: boolean;
18
18
  isDraggable: boolean;
19
19
  isResizable: boolean;
20
+ isRotatable?: boolean;
20
21
  lockAspectRatio?: boolean;
21
22
  style?: CSSProperties;
22
23
  vertexConfig?: VertexConfig<T>;
23
24
  selectionMenu?: AnnotationSelectionMenuRenderFn;
25
+ /** @deprecated Use `selectionOutline.offset` instead */
24
26
  outlineOffset?: number;
25
27
  onDoubleClick?: (event: any) => void;
26
28
  onSelect: (event: any) => void;
27
29
  zIndex?: number;
28
30
  resizeUI?: ResizeHandleUI;
29
31
  vertexUI?: VertexHandleUI;
32
+ rotationUI?: RotationHandleUI;
33
+ /** @deprecated Use `selectionOutline.color` instead */
30
34
  selectionOutlineColor?: string;
35
+ /** Customize the selection outline (color, style, width, offset) */
36
+ selectionOutline?: SelectionOutline;
31
37
  customAnnotationRenderer?: CustomAnnotationRenderer<T>;
32
38
  /** Passed from parent but not used - destructured to prevent DOM spread */
33
39
  groupSelectionMenu?: GroupSelectionMenuRenderFn;
34
40
  /** Passed from parent but not used - destructured to prevent DOM spread */
41
+ groupSelectionOutline?: SelectionOutline;
42
+ /** Passed from parent but not used - destructured to prevent DOM spread */
35
43
  annotationRenderers?: BoxedAnnotationRenderer[];
36
44
  }
37
45
  /**
@@ -39,5 +47,5 @@ interface AnnotationContainerProps<T extends PdfAnnotationObject> {
39
47
  * When isMultiSelected is true, the container becomes passive - drag/resize
40
48
  * is handled by the GroupSelectionBox instead.
41
49
  */
42
- export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, documentId, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, isSelected, isMultiSelected, isDraggable, isResizable, lockAspectRatio, style, vertexConfig, selectionMenu, outlineOffset, onDoubleClick, onSelect, zIndex, resizeUI, vertexUI, selectionOutlineColor, customAnnotationRenderer, groupSelectionMenu: _groupSelectionMenu, annotationRenderers: _annotationRenderers, ...props }: AnnotationContainerProps<T>): JSX.Element;
50
+ export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, documentId, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, isSelected, isMultiSelected, isDraggable, isResizable, isRotatable, lockAspectRatio, style, vertexConfig, selectionMenu, outlineOffset, onDoubleClick, onSelect, zIndex, resizeUI, vertexUI, rotationUI, selectionOutlineColor, selectionOutline, customAnnotationRenderer, groupSelectionMenu: _groupSelectionMenu, groupSelectionOutline: _groupSelectionOutline, annotationRenderers: _annotationRenderers, ...props }: AnnotationContainerProps<T>): JSX.Element;
43
51
  export {};
@@ -1,5 +1,5 @@
1
1
  import { HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
2
- import { ResizeHandleUI, VertexHandleUI, CustomAnnotationRenderer, AnnotationSelectionMenuRenderFn, GroupSelectionMenuRenderFn, BoxedAnnotationRenderer } from './types';
2
+ import { ResizeHandleUI, VertexHandleUI, RotationHandleUI, SelectionOutline, CustomAnnotationRenderer, AnnotationSelectionMenuRenderFn, GroupSelectionMenuRenderFn, BoxedAnnotationRenderer } from './types';
3
3
  import { PdfAnnotationObject } from '@embedpdf/models';
4
4
  type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
5
5
  /** The ID of the document that this layer displays annotations for */
@@ -16,12 +16,18 @@ type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
16
16
  resizeUI?: ResizeHandleUI;
17
17
  /** Customize vertex handles */
18
18
  vertexUI?: VertexHandleUI;
19
- /** Customize selection outline color */
19
+ /** Customize rotation handle */
20
+ rotationUI?: RotationHandleUI;
21
+ /** @deprecated Use `selectionOutline` instead */
20
22
  selectionOutlineColor?: string;
23
+ /** Customize the selection outline for individual annotations */
24
+ selectionOutline?: SelectionOutline;
25
+ /** Customize the selection outline for the group selection box (falls back to selectionOutline) */
26
+ groupSelectionOutline?: SelectionOutline;
21
27
  /** Customize annotation renderer */
22
28
  customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;
23
29
  /** Custom renderers for specific annotation types (provided by external plugins) */
24
30
  annotationRenderers?: BoxedAnnotationRenderer[];
25
31
  };
26
- export declare function AnnotationLayer({ style, documentId, pageIndex, scale: overrideScale, rotation: overrideRotation, selectionMenu, groupSelectionMenu, resizeUI, vertexUI, selectionOutlineColor, customAnnotationRenderer, annotationRenderers, ...props }: AnnotationLayerProps): import("react/jsx-runtime").JSX.Element;
32
+ export declare function AnnotationLayer({ style, documentId, pageIndex, scale: overrideScale, rotation: overrideRotation, selectionMenu, groupSelectionMenu, resizeUI, vertexUI, rotationUI, selectionOutlineColor, selectionOutline, groupSelectionOutline, customAnnotationRenderer, annotationRenderers, ...props }: AnnotationLayerProps): import("react/jsx-runtime").JSX.Element;
27
33
  export {};
@@ -1,5 +1,5 @@
1
1
  import { PdfAnnotationObject } from '@embedpdf/models';
2
- import { CustomAnnotationRenderer, ResizeHandleUI, AnnotationSelectionMenuRenderFn, GroupSelectionMenuRenderFn, VertexHandleUI, BoxedAnnotationRenderer } from './types';
2
+ import { CustomAnnotationRenderer, ResizeHandleUI, AnnotationSelectionMenuRenderFn, GroupSelectionMenuRenderFn, VertexHandleUI, RotationHandleUI, SelectionOutline, BoxedAnnotationRenderer } from './types';
3
3
  interface AnnotationsProps {
4
4
  documentId: string;
5
5
  pageIndex: number;
@@ -11,7 +11,10 @@ interface AnnotationsProps {
11
11
  groupSelectionMenu?: GroupSelectionMenuRenderFn;
12
12
  resizeUI?: ResizeHandleUI;
13
13
  vertexUI?: VertexHandleUI;
14
+ rotationUI?: RotationHandleUI;
14
15
  selectionOutlineColor?: string;
16
+ selectionOutline?: SelectionOutline;
17
+ groupSelectionOutline?: SelectionOutline;
15
18
  customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;
16
19
  /** Custom renderers for specific annotation types (provided by external plugins) */
17
20
  annotationRenderers?: BoxedAnnotationRenderer[];
@@ -1,5 +1,5 @@
1
1
  import { TrackedAnnotation } from '../../lib/index.ts';
2
- import { ResizeHandleUI, GroupSelectionMenuRenderFn } from './types';
2
+ import { ResizeHandleUI, RotationHandleUI, GroupSelectionMenuRenderFn, SelectionOutline } from './types';
3
3
  interface GroupSelectionBoxProps {
4
4
  documentId: string;
5
5
  pageIndex: number;
@@ -13,12 +13,20 @@ interface GroupSelectionBoxProps {
13
13
  isDraggable: boolean;
14
14
  /** Whether the group is resizable (all annotations must be group-resizable) */
15
15
  isResizable: boolean;
16
+ /** Whether the group can be rotated */
17
+ isRotatable?: boolean;
18
+ /** Whether to lock aspect ratio during group resize */
19
+ lockAspectRatio?: boolean;
16
20
  /** Resize handle UI customization */
17
21
  resizeUI?: ResizeHandleUI;
18
- /** Selection outline color */
22
+ /** Rotation handle UI customization */
23
+ rotationUI?: RotationHandleUI;
24
+ /** @deprecated Use `selectionOutline.color` instead */
19
25
  selectionOutlineColor?: string;
20
- /** Outline offset */
26
+ /** @deprecated Use `selectionOutline.offset` instead */
21
27
  outlineOffset?: number;
28
+ /** Customize the selection outline (color, style, width, offset) */
29
+ selectionOutline?: SelectionOutline;
22
30
  /** Z-index for the group box */
23
31
  zIndex?: number;
24
32
  /** Group selection menu render function */
@@ -28,5 +36,5 @@ interface GroupSelectionBoxProps {
28
36
  * GroupSelectionBox renders a bounding box around all selected annotations
29
37
  * with drag and resize handles for group manipulation.
30
38
  */
31
- export declare function GroupSelectionBox({ documentId, pageIndex, scale, rotation, pageWidth, pageHeight, selectedAnnotations, isDraggable, isResizable, resizeUI, selectionOutlineColor, outlineOffset, zIndex, groupSelectionMenu, }: GroupSelectionBoxProps): JSX.Element | null;
39
+ export declare function GroupSelectionBox({ documentId, pageIndex, scale, rotation, pageWidth, pageHeight, selectedAnnotations, isDraggable, isResizable, isRotatable, lockAspectRatio, resizeUI, rotationUI, selectionOutlineColor, outlineOffset, selectionOutline, zIndex, groupSelectionMenu, }: GroupSelectionBoxProps): JSX.Element | null;
32
40
  export {};
@@ -7,6 +7,7 @@ type RenderAnnotationProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {
7
7
  scaleFactor?: number;
8
8
  dpr?: number;
9
9
  style?: CSSProperties;
10
+ unrotated?: boolean;
10
11
  };
11
- export declare function RenderAnnotation({ documentId, pageIndex, annotation, scaleFactor, style, ...props }: RenderAnnotationProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function RenderAnnotation({ documentId, pageIndex, annotation, scaleFactor, unrotated, style, ...props }: RenderAnnotationProps): import("react/jsx-runtime").JSX.Element;
12
13
  export {};
@@ -1,7 +1,7 @@
1
1
  import { PdfAnnotationObject } from '@embedpdf/models';
2
2
  import { TrackedAnnotation } from '../../lib/index.ts';
3
3
  import { HandleElementProps, SelectionMenuPropsBase, SelectionMenuRenderFn } from '../../react/utils.ts';
4
- import { JSX, MouseEvent, TouchEvent } from '../../react/adapter.ts';
4
+ import { JSX, CSSProperties, MouseEvent, TouchEvent } from '../../react/adapter.ts';
5
5
  export type ResizeDirection = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'none';
6
6
  export interface AnnotationSelectionContext {
7
7
  type: 'annotation';
@@ -38,6 +38,56 @@ export interface VertexHandleUI {
38
38
  /** Custom renderer for each vertex (overrides default) */
39
39
  component?: (p: HandleProps) => JSX.Element;
40
40
  }
41
+ /** Props for the rotation handle component */
42
+ export interface RotationHandleComponentProps extends HandleProps {
43
+ /** Props for the connector line element */
44
+ connectorStyle?: CSSProperties;
45
+ /** Whether to show the connector line */
46
+ showConnector?: boolean;
47
+ /** Color for the icon inside the handle (default: '#007ACC') */
48
+ iconColor?: string;
49
+ /** Resolved border configuration */
50
+ border?: RotationHandleBorder;
51
+ }
52
+ export type BorderStyle = 'solid' | 'dashed' | 'dotted';
53
+ export interface SelectionOutline {
54
+ /** Outline color (default: '#007ACC') */
55
+ color?: string;
56
+ /** Outline style (default: 'solid' for single, 'dashed' for group) */
57
+ style?: BorderStyle;
58
+ /** Outline width in px (default: 1 for single, 2 for group) */
59
+ width?: number;
60
+ /** Outline offset in px (default: 1 for single, 2 for group) */
61
+ offset?: number;
62
+ }
63
+ /** Border configuration for the rotation handle */
64
+ export interface RotationHandleBorder {
65
+ /** Border color (default: '#007ACC') */
66
+ color?: string;
67
+ /** Border style (default: 'solid') */
68
+ style?: BorderStyle;
69
+ /** Border width in px (default: 1) */
70
+ width?: number;
71
+ }
72
+ /** UI customization for rotation handle */
73
+ export interface RotationHandleUI {
74
+ /** Handle size in CSS px (default: 16) */
75
+ size?: number;
76
+ /** Gap in CSS px between the bounding box edge and the rotation handle center (default: 20) */
77
+ margin?: number;
78
+ /** Default background color for the handle (default: 'white') */
79
+ color?: string;
80
+ /** Color for the connector line (default: '#007ACC') */
81
+ connectorColor?: string;
82
+ /** Whether to show the connector line (default: true) */
83
+ showConnector?: boolean;
84
+ /** Color for the icon inside the handle (default: '#007ACC') */
85
+ iconColor?: string;
86
+ /** Border configuration for the handle */
87
+ border?: RotationHandleBorder;
88
+ /** Custom renderer for the rotation handle (overrides default) */
89
+ component?: (p: RotationHandleComponentProps) => JSX.Element;
90
+ }
41
91
  /**
42
92
  * Props for the custom annotation renderer
43
93
  */