@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
@@ -1,26 +1,28 @@
1
- import { JSX, HTMLAttributes, CSSProperties, MouseEvent } from '../../preact/adapter.ts';
1
+ import { PdfAnnotationObject } from '@embedpdf/models';
2
2
  import { TrackedAnnotation } from '../../lib/index.ts';
3
- import { PdfAnnotationObject, Position } from '@embedpdf/models';
4
- import { SelectionMenuProps } from '../../shared/types';
5
- import { ComputePatch } from '../patchers';
6
- type AnnotationContainerProps<T extends PdfAnnotationObject> = Omit<HTMLAttributes<HTMLDivElement>, 'style' | 'children'> & {
3
+ import { JSX, CSSProperties } from '../../preact/adapter.ts';
4
+ import { ResizeHandleUI, SelectionMenuProps, VertexConfig, VertexHandleUI } from '../types';
5
+ interface AnnotationContainerProps<T extends PdfAnnotationObject> {
7
6
  scale: number;
8
- isSelected?: boolean;
9
7
  pageIndex: number;
8
+ rotation: number;
10
9
  pageWidth: number;
11
10
  pageHeight: number;
12
- rotation: number;
13
11
  trackedAnnotation: TrackedAnnotation<T>;
14
12
  children: JSX.Element | ((annotation: T) => JSX.Element);
13
+ isSelected: boolean;
14
+ isDraggable: boolean;
15
+ isResizable: boolean;
16
+ lockAspectRatio?: boolean;
15
17
  style?: CSSProperties;
16
- isDraggable?: boolean;
17
- isResizable?: boolean;
18
- outlineOffset?: number;
19
- onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;
18
+ vertexConfig?: VertexConfig<T>;
20
19
  selectionMenu?: (props: SelectionMenuProps) => JSX.Element;
21
- computeVertices?: (annotation: T) => Position[];
22
- computePatch?: ComputePatch<T>;
23
- lockAspectRatio?: boolean;
24
- };
25
- export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, style, outlineOffset, isSelected, isDraggable, isResizable, lockAspectRatio, computeVertices, computePatch, selectionMenu, onDoubleClick, ...props }: AnnotationContainerProps<T>): JSX.Element;
20
+ outlineOffset?: number;
21
+ onDoubleClick?: (event: any) => void;
22
+ zIndex?: number;
23
+ resizeUI?: ResizeHandleUI;
24
+ vertexUI?: VertexHandleUI;
25
+ selectionOutlineColor?: string;
26
+ }
27
+ export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, isSelected, isDraggable, isResizable, lockAspectRatio, style, vertexConfig, selectionMenu, outlineOffset, onDoubleClick, zIndex, resizeUI, vertexUI, selectionOutlineColor, ...props }: AnnotationContainerProps<T>): JSX.Element;
26
28
  export {};
@@ -1,13 +1,20 @@
1
1
  import { HTMLAttributes, CSSProperties } from '../../preact/adapter.ts';
2
- import { SelectionMenu } from '../types';
2
+ import { SelectionMenu, ResizeHandleUI, VertexHandleUI } from '../types';
3
3
  type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  pageIndex: number;
5
5
  scale: number;
6
6
  pageWidth: number;
7
7
  pageHeight: number;
8
8
  rotation: number;
9
+ /** Customize selection menu across all annotations on this layer */
9
10
  selectionMenu?: SelectionMenu;
10
11
  style?: CSSProperties;
12
+ /** Customize resize handles */
13
+ resizeUI?: ResizeHandleUI;
14
+ /** Customize vertex handles */
15
+ vertexUI?: VertexHandleUI;
16
+ /** Customize selection outline color */
17
+ selectionOutlineColor?: string;
11
18
  };
12
- export declare function AnnotationLayer({ pageIndex, scale, pageWidth, pageHeight, rotation, selectionMenu, style, ...props }: AnnotationLayerProps): import("preact").JSX.Element;
19
+ export declare function AnnotationLayer({ style, pageIndex, scale, selectionMenu, resizeUI, vertexUI, pageWidth, pageHeight, rotation, selectionOutlineColor, ...props }: AnnotationLayerProps): import("preact").JSX.Element;
13
20
  export {};
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ pageIndex: number;
3
+ scale: number;
4
+ }
5
+ export declare function AnnotationPaintLayer({ pageIndex, scale }: Props): import("preact").JSX.Element;
6
+ export {};
@@ -8,6 +8,7 @@ interface FreeTextProps {
8
8
  pageIndex: number;
9
9
  scale: number;
10
10
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
11
+ onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;
11
12
  }
12
13
  export declare function FreeText({ isSelected, isEditing, annotation, pageIndex, scale, onClick, }: FreeTextProps): import("preact").JSX.Element;
13
14
  export {};
@@ -12,6 +12,9 @@ interface PolygonProps {
12
12
  scale: number;
13
13
  isSelected: boolean;
14
14
  onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;
15
+ currentVertex?: Position;
16
+ handleSize?: number;
15
17
  }
16
- export declare function Polygon({ rect, vertices, color, strokeColor, opacity, strokeWidth, strokeStyle, strokeDashArray, scale, isSelected, onClick, }: PolygonProps): JSX.Element;
18
+ export declare function Polygon({ rect, vertices, color, strokeColor, opacity, strokeWidth, strokeStyle, strokeDashArray, scale, isSelected, onClick, currentVertex, // A preview-only prop
19
+ handleSize, }: PolygonProps): JSX.Element;
17
20
  export {};
@@ -1,4 +1,4 @@
1
- import { SelectionMenu } from '../types';
1
+ import { ResizeHandleUI, SelectionMenu, VertexHandleUI } from '../types';
2
2
  interface AnnotationsProps {
3
3
  pageIndex: number;
4
4
  scale: number;
@@ -6,6 +6,9 @@ interface AnnotationsProps {
6
6
  pageWidth: number;
7
7
  pageHeight: number;
8
8
  selectionMenu?: SelectionMenu;
9
+ resizeUI?: ResizeHandleUI;
10
+ vertexUI?: VertexHandleUI;
11
+ selectionOutlineColor?: string;
9
12
  }
10
13
  export declare function Annotations(annotationsProps: AnnotationsProps): import("preact").JSX.Element;
11
14
  export {};
@@ -0,0 +1,7 @@
1
+ import { AnyPreviewState } from '../../lib/index.ts';
2
+ interface Props {
3
+ preview: AnyPreviewState;
4
+ scale: number;
5
+ }
6
+ export declare function PreviewRenderer({ preview, scale }: Props): import("preact").JSX.Element | null;
7
+ export {};
@@ -3,11 +3,11 @@ import { Rect } from '@embedpdf/models';
3
3
  type HighlightProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  color?: string;
5
5
  opacity?: number;
6
- rects: Rect[];
6
+ segmentRects: Rect[];
7
7
  rect?: Rect;
8
8
  scale: number;
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Highlight({ color, opacity, rects, rect, scale, onClick, style, ...props }: HighlightProps): import("preact").JSX.Element;
12
+ export declare function Highlight({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: HighlightProps): import("preact").JSX.Element;
13
13
  export {};
@@ -3,11 +3,11 @@ import { Rect } from '@embedpdf/models';
3
3
  type SquigglyProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  color?: string;
5
5
  opacity?: number;
6
- rects: Rect[];
6
+ segmentRects: Rect[];
7
7
  rect?: Rect;
8
8
  scale: number;
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Squiggly({ color, opacity, rects, rect, scale, onClick, style, ...props }: SquigglyProps): import("preact").JSX.Element;
12
+ export declare function Squiggly({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: SquigglyProps): import("preact").JSX.Element;
13
13
  export {};
@@ -3,11 +3,11 @@ import { Rect } from '@embedpdf/models';
3
3
  type StrikeoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  color?: string;
5
5
  opacity?: number;
6
- rects: Rect[];
6
+ segmentRects: Rect[];
7
7
  rect?: Rect;
8
8
  scale: number;
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Strikeout({ color, opacity, rects, rect, scale, onClick, style, ...props }: StrikeoutProps): import("preact").JSX.Element;
12
+ export declare function Strikeout({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: StrikeoutProps): import("preact").JSX.Element;
13
13
  export {};
@@ -3,11 +3,11 @@ import { Rect } from '@embedpdf/models';
3
3
  type UnderlineProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  color?: string;
5
5
  opacity?: number;
6
- rects: Rect[];
6
+ segmentRects: Rect[];
7
7
  rect?: Rect;
8
8
  scale: number;
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Underline({ color, opacity, rects, rect, scale, onClick, style, ...props }: UnderlineProps): import("preact").JSX.Element;
12
+ export declare function Underline({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: UnderlineProps): import("preact").JSX.Element;
13
13
  export {};
@@ -1,7 +1,7 @@
1
- import { Rect } from '@embedpdf/models';
1
+ import { PdfAnnotationObject, Position, Rect } from '@embedpdf/models';
2
2
  import { TrackedAnnotation } from '../lib/index.ts';
3
+ import { HandleElementProps, MenuWrapperProps } from '../preact/utils.ts';
3
4
  import { JSX } from '../preact/adapter.ts';
4
- import { MenuWrapperProps } from '../preact/utils.ts';
5
5
  export type ResizeDirection = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'none';
6
6
  export interface SelectionMenuProps {
7
7
  annotation: TrackedAnnotation;
@@ -10,3 +10,33 @@ export interface SelectionMenuProps {
10
10
  menuWrapperProps: MenuWrapperProps;
11
11
  }
12
12
  export type SelectionMenu = (props: SelectionMenuProps) => JSX.Element;
13
+ /**
14
+ * Interface for vertex configuration - handles annotation-specific vertex logic
15
+ */
16
+ export interface VertexConfig<T extends PdfAnnotationObject> {
17
+ /** Extract vertices from annotation - handles different vertex formats */
18
+ extractVertices: (annotation: T) => Position[];
19
+ /** Transform annotation when vertices change */
20
+ transformAnnotation: (annotation: T, vertices: Position[]) => Partial<T>;
21
+ }
22
+ export type HandleProps = HandleElementProps & {
23
+ backgroundColor?: string;
24
+ };
25
+ /** UI customization for resize handles */
26
+ export interface ResizeHandleUI {
27
+ /** Handle size in CSS px (default: 12) */
28
+ size?: number;
29
+ /** Default background color for the handle (used by default renderer) */
30
+ color?: string;
31
+ /** Custom renderer for each handle (overrides default) */
32
+ component?: (p: HandleProps) => JSX.Element;
33
+ }
34
+ /** UI customization for vertex handles */
35
+ export interface VertexHandleUI {
36
+ /** Handle size in CSS px (default: 12) */
37
+ size?: number;
38
+ /** Default background color for the handle (used by default renderer) */
39
+ color?: string;
40
+ /** Custom renderer for each vertex (overrides default) */
41
+ component?: (p: HandleProps) => JSX.Element;
42
+ }
@@ -1,26 +1,28 @@
1
- import { JSX, HTMLAttributes, CSSProperties, MouseEvent } from '../../react/adapter.ts';
1
+ import { PdfAnnotationObject } from '@embedpdf/models';
2
2
  import { TrackedAnnotation } from '../../lib/index.ts';
3
- import { PdfAnnotationObject, Position } from '@embedpdf/models';
4
- import { SelectionMenuProps } from '../../shared/types';
5
- import { ComputePatch } from '../patchers';
6
- type AnnotationContainerProps<T extends PdfAnnotationObject> = Omit<HTMLAttributes<HTMLDivElement>, 'style' | 'children'> & {
3
+ import { JSX, CSSProperties } from '../../react/adapter.ts';
4
+ import { ResizeHandleUI, SelectionMenuProps, VertexConfig, VertexHandleUI } from '../types';
5
+ interface AnnotationContainerProps<T extends PdfAnnotationObject> {
7
6
  scale: number;
8
- isSelected?: boolean;
9
7
  pageIndex: number;
8
+ rotation: number;
10
9
  pageWidth: number;
11
10
  pageHeight: number;
12
- rotation: number;
13
11
  trackedAnnotation: TrackedAnnotation<T>;
14
12
  children: JSX.Element | ((annotation: T) => JSX.Element);
13
+ isSelected: boolean;
14
+ isDraggable: boolean;
15
+ isResizable: boolean;
16
+ lockAspectRatio?: boolean;
15
17
  style?: CSSProperties;
16
- isDraggable?: boolean;
17
- isResizable?: boolean;
18
- outlineOffset?: number;
19
- onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;
18
+ vertexConfig?: VertexConfig<T>;
20
19
  selectionMenu?: (props: SelectionMenuProps) => JSX.Element;
21
- computeVertices?: (annotation: T) => Position[];
22
- computePatch?: ComputePatch<T>;
23
- lockAspectRatio?: boolean;
24
- };
25
- export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, style, outlineOffset, isSelected, isDraggable, isResizable, lockAspectRatio, computeVertices, computePatch, selectionMenu, onDoubleClick, ...props }: AnnotationContainerProps<T>): JSX.Element;
20
+ outlineOffset?: number;
21
+ onDoubleClick?: (event: any) => void;
22
+ zIndex?: number;
23
+ resizeUI?: ResizeHandleUI;
24
+ vertexUI?: VertexHandleUI;
25
+ selectionOutlineColor?: string;
26
+ }
27
+ export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, isSelected, isDraggable, isResizable, lockAspectRatio, style, vertexConfig, selectionMenu, outlineOffset, onDoubleClick, zIndex, resizeUI, vertexUI, selectionOutlineColor, ...props }: AnnotationContainerProps<T>): JSX.Element;
26
28
  export {};
@@ -1,13 +1,20 @@
1
1
  import { HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
2
- import { SelectionMenu } from '../types';
2
+ import { SelectionMenu, ResizeHandleUI, VertexHandleUI } from '../types';
3
3
  type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  pageIndex: number;
5
5
  scale: number;
6
6
  pageWidth: number;
7
7
  pageHeight: number;
8
8
  rotation: number;
9
+ /** Customize selection menu across all annotations on this layer */
9
10
  selectionMenu?: SelectionMenu;
10
11
  style?: CSSProperties;
12
+ /** Customize resize handles */
13
+ resizeUI?: ResizeHandleUI;
14
+ /** Customize vertex handles */
15
+ vertexUI?: VertexHandleUI;
16
+ /** Customize selection outline color */
17
+ selectionOutlineColor?: string;
11
18
  };
12
- export declare function AnnotationLayer({ pageIndex, scale, pageWidth, pageHeight, rotation, selectionMenu, style, ...props }: AnnotationLayerProps): import("react/jsx-runtime").JSX.Element;
19
+ export declare function AnnotationLayer({ style, pageIndex, scale, selectionMenu, resizeUI, vertexUI, pageWidth, pageHeight, rotation, selectionOutlineColor, ...props }: AnnotationLayerProps): import("react/jsx-runtime").JSX.Element;
13
20
  export {};
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ pageIndex: number;
3
+ scale: number;
4
+ }
5
+ export declare function AnnotationPaintLayer({ pageIndex, scale }: Props): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -8,6 +8,7 @@ interface FreeTextProps {
8
8
  pageIndex: number;
9
9
  scale: number;
10
10
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
11
+ onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;
11
12
  }
12
13
  export declare function FreeText({ isSelected, isEditing, annotation, pageIndex, scale, onClick, }: FreeTextProps): import("react/jsx-runtime").JSX.Element;
13
14
  export {};
@@ -12,6 +12,9 @@ interface PolygonProps {
12
12
  scale: number;
13
13
  isSelected: boolean;
14
14
  onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;
15
+ currentVertex?: Position;
16
+ handleSize?: number;
15
17
  }
16
- export declare function Polygon({ rect, vertices, color, strokeColor, opacity, strokeWidth, strokeStyle, strokeDashArray, scale, isSelected, onClick, }: PolygonProps): JSX.Element;
18
+ export declare function Polygon({ rect, vertices, color, strokeColor, opacity, strokeWidth, strokeStyle, strokeDashArray, scale, isSelected, onClick, currentVertex, // A preview-only prop
19
+ handleSize, }: PolygonProps): JSX.Element;
17
20
  export {};
@@ -1,4 +1,4 @@
1
- import { SelectionMenu } from '../types';
1
+ import { ResizeHandleUI, SelectionMenu, VertexHandleUI } from '../types';
2
2
  interface AnnotationsProps {
3
3
  pageIndex: number;
4
4
  scale: number;
@@ -6,6 +6,9 @@ interface AnnotationsProps {
6
6
  pageWidth: number;
7
7
  pageHeight: number;
8
8
  selectionMenu?: SelectionMenu;
9
+ resizeUI?: ResizeHandleUI;
10
+ vertexUI?: VertexHandleUI;
11
+ selectionOutlineColor?: string;
9
12
  }
10
13
  export declare function Annotations(annotationsProps: AnnotationsProps): import("react/jsx-runtime").JSX.Element;
11
14
  export {};
@@ -0,0 +1,7 @@
1
+ import { AnyPreviewState } from '../../lib/index.ts';
2
+ interface Props {
3
+ preview: AnyPreviewState;
4
+ scale: number;
5
+ }
6
+ export declare function PreviewRenderer({ preview, scale }: Props): import("react/jsx-runtime").JSX.Element | null;
7
+ export {};
@@ -3,11 +3,11 @@ import { Rect } from '@embedpdf/models';
3
3
  type HighlightProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  color?: string;
5
5
  opacity?: number;
6
- rects: Rect[];
6
+ segmentRects: Rect[];
7
7
  rect?: Rect;
8
8
  scale: number;
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Highlight({ color, opacity, rects, rect, scale, onClick, style, ...props }: HighlightProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function Highlight({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: HighlightProps): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -3,11 +3,11 @@ import { Rect } from '@embedpdf/models';
3
3
  type SquigglyProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  color?: string;
5
5
  opacity?: number;
6
- rects: Rect[];
6
+ segmentRects: Rect[];
7
7
  rect?: Rect;
8
8
  scale: number;
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Squiggly({ color, opacity, rects, rect, scale, onClick, style, ...props }: SquigglyProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function Squiggly({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: SquigglyProps): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -3,11 +3,11 @@ import { Rect } from '@embedpdf/models';
3
3
  type StrikeoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  color?: string;
5
5
  opacity?: number;
6
- rects: Rect[];
6
+ segmentRects: Rect[];
7
7
  rect?: Rect;
8
8
  scale: number;
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Strikeout({ color, opacity, rects, rect, scale, onClick, style, ...props }: StrikeoutProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function Strikeout({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: StrikeoutProps): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -3,11 +3,11 @@ import { Rect } from '@embedpdf/models';
3
3
  type UnderlineProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  color?: string;
5
5
  opacity?: number;
6
- rects: Rect[];
6
+ segmentRects: Rect[];
7
7
  rect?: Rect;
8
8
  scale: number;
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Underline({ color, opacity, rects, rect, scale, onClick, style, ...props }: UnderlineProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function Underline({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: UnderlineProps): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -1,7 +1,7 @@
1
- import { Rect } from '@embedpdf/models';
1
+ import { PdfAnnotationObject, Position, Rect } from '@embedpdf/models';
2
2
  import { TrackedAnnotation } from '../lib/index.ts';
3
+ import { HandleElementProps, MenuWrapperProps } from '../react/utils.ts';
3
4
  import { JSX } from '../react/adapter.ts';
4
- import { MenuWrapperProps } from '../react/utils.ts';
5
5
  export type ResizeDirection = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'none';
6
6
  export interface SelectionMenuProps {
7
7
  annotation: TrackedAnnotation;
@@ -10,3 +10,33 @@ export interface SelectionMenuProps {
10
10
  menuWrapperProps: MenuWrapperProps;
11
11
  }
12
12
  export type SelectionMenu = (props: SelectionMenuProps) => JSX.Element;
13
+ /**
14
+ * Interface for vertex configuration - handles annotation-specific vertex logic
15
+ */
16
+ export interface VertexConfig<T extends PdfAnnotationObject> {
17
+ /** Extract vertices from annotation - handles different vertex formats */
18
+ extractVertices: (annotation: T) => Position[];
19
+ /** Transform annotation when vertices change */
20
+ transformAnnotation: (annotation: T, vertices: Position[]) => Partial<T>;
21
+ }
22
+ export type HandleProps = HandleElementProps & {
23
+ backgroundColor?: string;
24
+ };
25
+ /** UI customization for resize handles */
26
+ export interface ResizeHandleUI {
27
+ /** Handle size in CSS px (default: 12) */
28
+ size?: number;
29
+ /** Default background color for the handle (used by default renderer) */
30
+ color?: string;
31
+ /** Custom renderer for each handle (overrides default) */
32
+ component?: (p: HandleProps) => JSX.Element;
33
+ }
34
+ /** UI customization for vertex handles */
35
+ export interface VertexHandleUI {
36
+ /** Handle size in CSS px (default: 12) */
37
+ size?: number;
38
+ /** Default background color for the handle (used by default renderer) */
39
+ color?: string;
40
+ /** Custom renderer for each vertex (overrides default) */
41
+ component?: (p: HandleProps) => JSX.Element;
42
+ }
@@ -0,0 +1 @@
1
+ export * from './use-annotation';
@@ -0,0 +1,3 @@
1
+ import { AnnotationPlugin } from '../../lib/index.ts';
2
+ export declare const useAnnotationPlugin: () => import('@embedpdf/core/vue').PluginState<AnnotationPlugin>;
3
+ export declare const useAnnotationCapability: () => import('@embedpdf/core/vue').CapabilityState<Readonly<import('../../lib/index.ts').AnnotationCapability>>;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/vue"),t=require("@embedpdf/plugin-annotation");exports.useAnnotationCapability=()=>e.useCapability(t.AnnotationPlugin.id),exports.useAnnotationPlugin=()=>e.usePlugin(t.AnnotationPlugin.id),Object.keys(t).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})}));
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/vue/hooks/use-annotation.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { AnnotationPlugin } from '@embedpdf/plugin-annotation';\n\nexport const useAnnotationPlugin = () => usePlugin<AnnotationPlugin>(AnnotationPlugin.id);\nexport const useAnnotationCapability = () => useCapability<AnnotationPlugin>(AnnotationPlugin.id);\n"],"names":["useCapability","AnnotationPlugin","id","usePlugin"],"mappings":"+LAIuC,IAAMA,gBAAgCC,EAAAA,iBAAiBC,gCAD3D,IAAMC,YAA4BF,EAAAA,iBAAiBC"}
@@ -0,0 +1,2 @@
1
+ export * from './hooks';
2
+ export * from '../lib/index.ts';
@@ -0,0 +1,10 @@
1
+ import { usePlugin, useCapability } from "@embedpdf/core/vue";
2
+ import { AnnotationPlugin } from "@embedpdf/plugin-annotation";
3
+ export * from "@embedpdf/plugin-annotation";
4
+ const useAnnotationPlugin = () => usePlugin(AnnotationPlugin.id);
5
+ const useAnnotationCapability = () => useCapability(AnnotationPlugin.id);
6
+ export {
7
+ useAnnotationCapability,
8
+ useAnnotationPlugin
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/vue/hooks/use-annotation.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { AnnotationPlugin } from '@embedpdf/plugin-annotation';\n\nexport const useAnnotationPlugin = () => usePlugin<AnnotationPlugin>(AnnotationPlugin.id);\nexport const useAnnotationCapability = () => useCapability<AnnotationPlugin>(AnnotationPlugin.id);\n"],"names":[],"mappings":";;;AAGO,MAAM,sBAAsB,MAAM,UAA4B,iBAAiB,EAAE;AACjF,MAAM,0BAA0B,MAAM,cAAgC,iBAAiB,EAAE;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-annotation",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -20,28 +20,34 @@
20
20
  "types": "./dist/react/index.d.ts",
21
21
  "import": "./dist/react/index.js",
22
22
  "require": "./dist/react/index.cjs"
23
+ },
24
+ "./vue": {
25
+ "types": "./dist/vue/index.d.ts",
26
+ "import": "./dist/vue/index.js",
27
+ "require": "./dist/vue/index.cjs"
23
28
  }
24
29
  },
25
30
  "dependencies": {
26
- "@embedpdf/models": "1.1.1",
27
- "@embedpdf/utils": "1.1.1"
31
+ "@embedpdf/models": "1.2.0",
32
+ "@embedpdf/utils": "1.2.0"
28
33
  },
29
34
  "devDependencies": {
30
35
  "@types/react": "^18.2.0",
31
36
  "typescript": "^5.0.0",
32
37
  "@embedpdf/build": "1.0.0",
33
- "@embedpdf/plugin-interaction-manager": "1.1.1",
34
- "@embedpdf/plugin-selection": "1.1.1",
35
- "@embedpdf/plugin-history": "1.1.1"
38
+ "@embedpdf/plugin-interaction-manager": "1.2.0",
39
+ "@embedpdf/plugin-history": "1.2.0",
40
+ "@embedpdf/plugin-selection": "1.2.0"
36
41
  },
37
42
  "peerDependencies": {
38
43
  "react": ">=16.8.0",
39
44
  "react-dom": ">=16.8.0",
40
45
  "preact": "^10.26.4",
41
- "@embedpdf/core": "1.1.1",
42
- "@embedpdf/plugin-interaction-manager": "1.1.1",
43
- "@embedpdf/plugin-history": "1.1.1",
44
- "@embedpdf/plugin-selection": "1.1.1"
46
+ "vue": ">=3.2.0",
47
+ "@embedpdf/core": "1.2.0",
48
+ "@embedpdf/plugin-selection": "1.2.0",
49
+ "@embedpdf/plugin-history": "1.2.0",
50
+ "@embedpdf/plugin-interaction-manager": "1.2.0"
45
51
  },
46
52
  "files": [
47
53
  "dist",
@@ -63,7 +69,8 @@
63
69
  "build:base": "vite build --mode base",
64
70
  "build:react": "vite build --mode react",
65
71
  "build:preact": "vite build --mode preact",
66
- "build": "pnpm run clean && concurrently -c auto -n base,react,preact \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\"",
72
+ "build:vue": "vite build --mode vue",
73
+ "build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\"",
67
74
  "clean": "rimraf dist",
68
75
  "lint": "eslint src --color",
69
76
  "lint:fix": "eslint src --color --fix"
@@ -1,2 +0,0 @@
1
- import { PdfAnnotationObject, Rect } from '@embedpdf/models';
2
- export declare function deriveRect(a: PdfAnnotationObject): Rect;
@@ -1,8 +0,0 @@
1
- import { PdfAnnotationSubtype, PdfAnnotationObject } from '@embedpdf/models';
2
- export type VariantKey = string;
3
- export declare const makeVariantKey: (subtype: PdfAnnotationSubtype, intent?: string | null | undefined) => VariantKey;
4
- export declare const parseVariantKey: (key: VariantKey) => {
5
- subtype: PdfAnnotationSubtype;
6
- intent?: string;
7
- };
8
- export declare const variantKeyFromAnnotation: (a: PdfAnnotationObject) => VariantKey;
@@ -1,10 +0,0 @@
1
- interface CirclePaintProps {
2
- pageIndex: number;
3
- scale: number;
4
- pageWidth: number;
5
- pageHeight: number;
6
- /** Optional preview cursor */
7
- cursor?: string;
8
- }
9
- export declare const CirclePaint: ({ pageIndex, scale, pageWidth, pageHeight, cursor, }: CirclePaintProps) => import("preact").JSX.Element | null;
10
- export {};
@@ -1,10 +0,0 @@
1
- interface FreeTextPaintProps {
2
- pageIndex: number;
3
- scale: number;
4
- pageWidth: number;
5
- pageHeight: number;
6
- /** Optional preview cursor */
7
- cursor?: string;
8
- }
9
- export declare const FreeTextPaint: ({ pageIndex, scale, pageWidth, pageHeight, cursor, }: FreeTextPaintProps) => import("preact").JSX.Element | null;
10
- export {};
@@ -1,18 +0,0 @@
1
- import { JSX } from '../../../preact/adapter.ts';
2
- interface InkPaintProps {
3
- /** Index of the page this layer lives on */
4
- pageIndex: number;
5
- /** Scale of the page */
6
- scale: number;
7
- /** Width of the page */
8
- pageWidth: number;
9
- /** Height of the page */
10
- pageHeight: number;
11
- }
12
- /**
13
- * Allows the user to draw freehand ink annotations.
14
- * Hook it into the interaction-manager with modeId = 'inkPaint'.
15
- * Supports multi-stroke annotations: if the user starts a new stroke within 3 seconds of releasing the previous one, it adds to the same annotation.
16
- */
17
- export declare const InkPaint: ({ pageIndex, scale, pageWidth, pageHeight }: InkPaintProps) => JSX.Element | null;
18
- export {};