@embedpdf/plugin-annotation 1.0.12 → 1.0.14

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 (74) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +391 -31
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/annotation-plugin.d.ts +1 -0
  6. package/dist/lib/helpers.d.ts +24 -0
  7. package/dist/lib/index.d.ts +2 -0
  8. package/dist/lib/patching/derived-rect.d.ts +2 -0
  9. package/dist/lib/patching/index.d.ts +4 -0
  10. package/dist/lib/patching/line-ending-handlers.d.ts +20 -0
  11. package/dist/lib/patching/line-endings.d.ts +13 -0
  12. package/dist/lib/patching/patch-utils.d.ts +7 -0
  13. package/dist/lib/selectors.d.ts +17 -5
  14. package/dist/lib/types.d.ts +97 -12
  15. package/dist/preact/adapter.d.ts +6 -1
  16. package/dist/preact/index.cjs +1 -1
  17. package/dist/preact/index.cjs.map +1 -1
  18. package/dist/preact/index.js +2348 -447
  19. package/dist/preact/index.js.map +1 -1
  20. package/dist/react/adapter.d.ts +6 -1
  21. package/dist/react/index.cjs +1 -1
  22. package/dist/react/index.cjs.map +1 -1
  23. package/dist/react/index.js +2347 -446
  24. package/dist/react/index.js.map +1 -1
  25. package/dist/shared-preact/components/annotation-container.d.ts +14 -8
  26. package/dist/shared-preact/components/annotation-layer.d.ts +3 -1
  27. package/dist/shared-preact/components/annotations/circle-paint.d.ts +10 -0
  28. package/dist/shared-preact/components/annotations/circle.d.ts +29 -0
  29. package/dist/shared-preact/components/annotations/free-text-paint.d.ts +10 -0
  30. package/dist/shared-preact/components/annotations/free-text.d.ts +13 -0
  31. package/dist/shared-preact/components/annotations/ink-paint.d.ts +2 -1
  32. package/dist/shared-preact/components/annotations/ink.d.ts +3 -1
  33. package/dist/shared-preact/components/annotations/line-paint.d.ts +10 -0
  34. package/dist/shared-preact/components/annotations/line.d.ts +33 -0
  35. package/dist/shared-preact/components/annotations/polygon-paint.d.ts +9 -0
  36. package/dist/shared-preact/components/annotations/polygon.d.ts +17 -0
  37. package/dist/shared-preact/components/annotations/polyline-paint.d.ts +10 -0
  38. package/dist/shared-preact/components/annotations/polyline.d.ts +17 -0
  39. package/dist/shared-preact/components/annotations/square-paint.d.ts +10 -0
  40. package/dist/shared-preact/components/annotations/square.d.ts +29 -0
  41. package/dist/shared-preact/components/annotations.d.ts +4 -0
  42. package/dist/shared-preact/components/counter-rotate-container.d.ts +32 -0
  43. package/dist/shared-preact/components/resize-handles.d.ts +9 -0
  44. package/dist/shared-preact/components/vertex-editor.d.ts +19 -0
  45. package/dist/shared-preact/hooks/use-drag-resize.d.ts +31 -0
  46. package/dist/shared-preact/{resize-ink.d.ts → patch-ink.d.ts} +3 -4
  47. package/dist/shared-preact/patchers.d.ts +9 -0
  48. package/dist/shared-preact/types.d.ts +11 -0
  49. package/dist/shared-preact/vertex-patchers.d.ts +10 -0
  50. package/dist/shared-react/components/annotation-container.d.ts +14 -8
  51. package/dist/shared-react/components/annotation-layer.d.ts +3 -1
  52. package/dist/shared-react/components/annotations/circle-paint.d.ts +10 -0
  53. package/dist/shared-react/components/annotations/circle.d.ts +29 -0
  54. package/dist/shared-react/components/annotations/free-text-paint.d.ts +10 -0
  55. package/dist/shared-react/components/annotations/free-text.d.ts +13 -0
  56. package/dist/shared-react/components/annotations/ink.d.ts +3 -1
  57. package/dist/shared-react/components/annotations/line-paint.d.ts +10 -0
  58. package/dist/shared-react/components/annotations/line.d.ts +33 -0
  59. package/dist/shared-react/components/annotations/polygon-paint.d.ts +9 -0
  60. package/dist/shared-react/components/annotations/polygon.d.ts +17 -0
  61. package/dist/shared-react/components/annotations/polyline-paint.d.ts +10 -0
  62. package/dist/shared-react/components/annotations/polyline.d.ts +17 -0
  63. package/dist/shared-react/components/annotations/square-paint.d.ts +10 -0
  64. package/dist/shared-react/components/annotations/square.d.ts +29 -0
  65. package/dist/shared-react/components/annotations.d.ts +4 -0
  66. package/dist/shared-react/components/counter-rotate-container.d.ts +32 -0
  67. package/dist/shared-react/components/resize-handles.d.ts +9 -0
  68. package/dist/shared-react/components/vertex-editor.d.ts +19 -0
  69. package/dist/shared-react/hooks/use-drag-resize.d.ts +31 -0
  70. package/dist/shared-react/{resize-ink.d.ts → patch-ink.d.ts} +3 -4
  71. package/dist/shared-react/patchers.d.ts +9 -0
  72. package/dist/shared-react/types.d.ts +11 -0
  73. package/dist/shared-react/vertex-patchers.d.ts +10 -0
  74. package/package.json +9 -9
@@ -1,19 +1,25 @@
1
- import { JSX, HTMLAttributes, CSSProperties } from '../../preact/adapter.ts';
1
+ import { JSX, HTMLAttributes, CSSProperties, MouseEvent } from '../../preact/adapter.ts';
2
2
  import { TrackedAnnotation } from '../../lib/index.ts';
3
- import { PdfAnnotationObject, Rect } from '@embedpdf/models';
4
- import { ResizeDirection } from '../../shared/types';
5
- type AnnotationContainerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style' | 'children'> & {
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'> & {
6
7
  scale: number;
7
8
  isSelected?: boolean;
8
9
  pageIndex: number;
10
+ pageWidth: number;
11
+ pageHeight: number;
9
12
  rotation: number;
10
- trackedAnnotation: TrackedAnnotation;
11
- children: JSX.Element | ((annotation: PdfAnnotationObject) => JSX.Element);
13
+ trackedAnnotation: TrackedAnnotation<T>;
14
+ children: JSX.Element | ((annotation: T) => JSX.Element);
12
15
  style?: CSSProperties;
13
16
  isDraggable?: boolean;
14
17
  isResizable?: boolean;
15
18
  outlineOffset?: number;
16
- computeResizePatch?: (original: PdfAnnotationObject, newRect: Rect, direction: ResizeDirection) => Partial<PdfAnnotationObject>;
19
+ onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;
20
+ selectionMenu?: (props: SelectionMenuProps) => JSX.Element;
21
+ computeVertices?: (annotation: T) => Position[];
22
+ computePatch?: ComputePatch<T>;
17
23
  };
18
- export declare function AnnotationContainer({ scale, pageIndex, rotation, trackedAnnotation, children, style, outlineOffset, isSelected, isDraggable, isResizable, computeResizePatch, ...props }: AnnotationContainerProps): JSX.Element;
24
+ export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, style, outlineOffset, isSelected, isDraggable, isResizable, computeVertices, computePatch, selectionMenu, onDoubleClick, ...props }: AnnotationContainerProps<T>): JSX.Element;
19
25
  export {};
@@ -1,11 +1,13 @@
1
1
  import { HTMLAttributes, CSSProperties } from '../../preact/adapter.ts';
2
+ import { SelectionMenu } from '../types';
2
3
  type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
3
4
  pageIndex: number;
4
5
  scale: number;
5
6
  pageWidth: number;
6
7
  pageHeight: number;
7
8
  rotation: number;
9
+ selectionMenu?: SelectionMenu;
8
10
  style?: CSSProperties;
9
11
  };
10
- export declare function AnnotationLayer({ pageIndex, scale, pageWidth, pageHeight, rotation, style, ...props }: AnnotationLayerProps): import("preact").JSX.Element;
12
+ export declare function AnnotationLayer({ pageIndex, scale, pageWidth, pageHeight, rotation, selectionMenu, style, ...props }: AnnotationLayerProps): import("preact").JSX.Element;
11
13
  export {};
@@ -0,0 +1,10 @@
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 {};
@@ -0,0 +1,29 @@
1
+ import { MouseEvent } from '../../../preact/adapter.ts';
2
+ import { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';
3
+ interface CircleProps {
4
+ /** Fill colour – defaults to PDFium’s black if omitted */
5
+ color?: string;
6
+ /** Stroke colour – defaults to same as fill when omitted */
7
+ strokeColor?: string;
8
+ /** 0 – 1 */
9
+ opacity?: number;
10
+ /** Stroke width in PDF units */
11
+ strokeWidth: number;
12
+ /** Stroke type – defaults to solid when omitted */
13
+ strokeStyle?: PdfAnnotationBorderStyle;
14
+ /** Stroke dash array – defaults to undefined when omitted */
15
+ strokeDashArray?: number[];
16
+ /** Bounding box of the annotation */
17
+ rect: Rect;
18
+ /** Current page zoom factor */
19
+ scale: number;
20
+ /** Click handler (used for selection) */
21
+ onClick?: (e: MouseEvent<SVGElement>) => void;
22
+ /** Cursor shown over the annotation */
23
+ cursor?: string;
24
+ }
25
+ /**
26
+ * Renders a PDF Circle annotation (ellipse) as SVG.
27
+ */
28
+ export declare function Circle({ color, strokeColor, opacity, strokeWidth, strokeStyle, strokeDashArray, rect, scale, onClick, cursor, }: CircleProps): JSX.Element;
29
+ export {};
@@ -0,0 +1,10 @@
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 {};
@@ -0,0 +1,13 @@
1
+ import { MouseEvent } from '../../../preact/adapter.ts';
2
+ import { PdfFreeTextAnnoObject } from '@embedpdf/models';
3
+ import { TrackedAnnotation } from '../../../lib/index.ts';
4
+ interface FreeTextProps {
5
+ isSelected: boolean;
6
+ isEditing: boolean;
7
+ annotation: TrackedAnnotation<PdfFreeTextAnnoObject>;
8
+ pageIndex: number;
9
+ scale: number;
10
+ onClick?: (e: MouseEvent<HTMLDivElement>) => void;
11
+ }
12
+ export declare function FreeText({ isSelected, isEditing, annotation, pageIndex, scale, onClick, }: FreeTextProps): import("preact").JSX.Element;
13
+ export {};
@@ -1,3 +1,4 @@
1
+ import { JSX } from '../../../preact/adapter.ts';
1
2
  interface InkPaintProps {
2
3
  /** Index of the page this layer lives on */
3
4
  pageIndex: number;
@@ -13,5 +14,5 @@ interface InkPaintProps {
13
14
  * Hook it into the interaction-manager with modeId = 'inkPaint'.
14
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.
15
16
  */
16
- export declare const InkPaint: ({ pageIndex, scale, pageWidth, pageHeight }: InkPaintProps) => import("preact").JSX.Element | null;
17
+ export declare const InkPaint: ({ pageIndex, scale, pageWidth, pageHeight }: InkPaintProps) => JSX.Element | null;
17
18
  export {};
@@ -15,9 +15,11 @@ interface InkProps {
15
15
  scale: number;
16
16
  /** Callback for when the annotation is clicked */
17
17
  onClick?: (e: MouseEvent<SVGPathElement>) => void;
18
+ /** Cursor on the ink */
19
+ cursor?: string;
18
20
  }
19
21
  /**
20
22
  * Renders a PDF Ink annotation (free-hand drawing) as SVG.
21
23
  */
22
- export declare function Ink({ color, opacity, strokeWidth, inkList, rect, scale, onClick, }: InkProps): JSX.Element;
24
+ export declare function Ink({ color, opacity, strokeWidth, inkList, rect, scale, onClick, cursor, }: InkProps): JSX.Element;
23
25
  export {};
@@ -0,0 +1,10 @@
1
+ interface LinePaintProps {
2
+ pageIndex: number;
3
+ scale: number;
4
+ pageWidth: number;
5
+ pageHeight: number;
6
+ /** Optional preview cursor */
7
+ cursor?: string;
8
+ }
9
+ export declare const LinePaint: ({ pageIndex, scale, pageWidth, pageHeight, cursor }: LinePaintProps) => import("preact").JSX.Element | null;
10
+ export {};
@@ -0,0 +1,33 @@
1
+ import { MouseEvent } from '../../../preact/adapter.ts';
2
+ import { Rect, LinePoints, LineEndings, PdfAnnotationBorderStyle } from '@embedpdf/models';
3
+ interface LineProps {
4
+ /** interior colour */
5
+ color?: string;
6
+ /** 0 – 1 */
7
+ opacity?: number;
8
+ /** Stroke width in PDF units */
9
+ strokeWidth: number;
10
+ /** Stroke colour (falls back to PDFium default black) */
11
+ strokeColor?: string;
12
+ /** Stroke style */
13
+ strokeStyle?: PdfAnnotationBorderStyle;
14
+ /** Stroke dash array */
15
+ strokeDashArray?: number[];
16
+ /** Bounding box of the annotation */
17
+ rect: Rect;
18
+ /** Line start / end points (page units) */
19
+ linePoints: LinePoints;
20
+ /** Line endings (eg. OpenArrow / Butt) */
21
+ lineEndings?: LineEndings;
22
+ /** Current page zoom factor */
23
+ scale: number;
24
+ /** Click handler (used for selection) */
25
+ onClick?: (e: MouseEvent<SVGElement>) => void;
26
+ /** Whether the annotation is selected */
27
+ isSelected: boolean;
28
+ }
29
+ /**
30
+ * Renders a PDF Line annotation as SVG (with arrow/butt endings).
31
+ */
32
+ export declare function Line({ color, opacity, strokeWidth, strokeColor, strokeStyle, strokeDashArray, rect, linePoints, lineEndings, scale, onClick, isSelected, }: LineProps): JSX.Element;
33
+ export {};
@@ -0,0 +1,9 @@
1
+ interface PolygonPaintProps {
2
+ pageIndex: number;
3
+ scale: number;
4
+ pageWidth: number;
5
+ pageHeight: number;
6
+ cursor?: string;
7
+ }
8
+ export declare const PolygonPaint: ({ pageIndex, scale, pageWidth, pageHeight, cursor, }: PolygonPaintProps) => import("preact").JSX.Element | null;
9
+ export {};
@@ -0,0 +1,17 @@
1
+ import { MouseEvent } from '../../../preact/adapter.ts';
2
+ import { Rect, Position, PdfAnnotationBorderStyle } from '@embedpdf/models';
3
+ interface PolygonProps {
4
+ rect: Rect;
5
+ vertices: Position[];
6
+ color?: string;
7
+ strokeColor?: string;
8
+ opacity?: number;
9
+ strokeWidth: number;
10
+ strokeStyle?: PdfAnnotationBorderStyle;
11
+ strokeDashArray?: number[];
12
+ scale: number;
13
+ isSelected: boolean;
14
+ onClick?: (e: MouseEvent<SVGElement>) => void;
15
+ }
16
+ export declare function Polygon({ rect, vertices, color, strokeColor, opacity, strokeWidth, strokeStyle, strokeDashArray, scale, isSelected, onClick, }: PolygonProps): JSX.Element;
17
+ export {};
@@ -0,0 +1,10 @@
1
+ interface PolylinePaintProps {
2
+ pageIndex: number;
3
+ scale: number;
4
+ pageWidth: number;
5
+ pageHeight: number;
6
+ /** Optional preview cursor */
7
+ cursor?: string;
8
+ }
9
+ export declare const PolylinePaint: ({ pageIndex, scale, pageWidth, pageHeight, cursor, }: PolylinePaintProps) => import("preact").JSX.Element | null;
10
+ export {};
@@ -0,0 +1,17 @@
1
+ import { MouseEvent } from '../../../preact/adapter.ts';
2
+ import { Rect, Position, LineEndings } from '@embedpdf/models';
3
+ interface PolylineProps {
4
+ rect: Rect;
5
+ vertices: Position[];
6
+ color?: string;
7
+ strokeColor?: string;
8
+ opacity?: number;
9
+ strokeWidth: number;
10
+ scale: number;
11
+ isSelected: boolean;
12
+ onClick?: (e: MouseEvent<SVGElement>) => void;
13
+ /** Optional start & end endings */
14
+ lineEndings?: LineEndings;
15
+ }
16
+ export declare function Polyline({ rect, vertices, color, strokeColor, opacity, strokeWidth, scale, isSelected, onClick, lineEndings, }: PolylineProps): JSX.Element;
17
+ export {};
@@ -0,0 +1,10 @@
1
+ interface SquarePaintProps {
2
+ pageIndex: number;
3
+ scale: number;
4
+ pageWidth: number;
5
+ pageHeight: number;
6
+ /** Optional preview cursor */
7
+ cursor?: string;
8
+ }
9
+ export declare const SquarePaint: ({ pageIndex, scale, pageWidth, pageHeight, cursor, }: SquarePaintProps) => import("preact").JSX.Element | null;
10
+ export {};
@@ -0,0 +1,29 @@
1
+ import { MouseEvent } from '../../../preact/adapter.ts';
2
+ import { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';
3
+ interface SquareProps {
4
+ /** Fill colour – defaults to PDFium’s black if omitted */
5
+ color?: string;
6
+ /** Stroke colour – defaults to same as fill when omitted */
7
+ strokeColor?: string;
8
+ /** 0 – 1 */
9
+ opacity?: number;
10
+ /** Stroke width in PDF units */
11
+ strokeWidth: number;
12
+ /** Stroke type – defaults to solid when omitted */
13
+ strokeStyle?: PdfAnnotationBorderStyle;
14
+ /** Stroke dash array – defaults to undefined when omitted */
15
+ strokeDashArray?: number[];
16
+ /** Bounding box of the annotation (PDF units) */
17
+ rect: Rect;
18
+ /** Current page zoom factor */
19
+ scale: number;
20
+ /** Click handler (used for selection) */
21
+ onClick?: (e: MouseEvent<SVGElement>) => void;
22
+ /** Cursor shown over the annotation */
23
+ cursor?: string;
24
+ }
25
+ /**
26
+ * Renders a PDF Square annotation (rectangle) as SVG.
27
+ */
28
+ export declare function Square({ color, strokeColor, opacity, strokeWidth, strokeStyle, strokeDashArray, rect, scale, onClick, cursor, }: SquareProps): JSX.Element;
29
+ export {};
@@ -1,7 +1,11 @@
1
+ import { SelectionMenu } from '../types';
1
2
  interface AnnotationsProps {
2
3
  pageIndex: number;
3
4
  scale: number;
4
5
  rotation: number;
6
+ pageWidth: number;
7
+ pageHeight: number;
8
+ selectionMenu?: SelectionMenu;
5
9
  }
6
10
  export declare function Annotations(annotationsProps: AnnotationsProps): import("preact").JSX.Element;
7
11
  export {};
@@ -0,0 +1,32 @@
1
+ import { Rect, Rotation } from '@embedpdf/models';
2
+ import { ReactNode, CSSProperties, PointerEvent } from '../../preact/adapter.ts';
3
+ interface CounterRotateProps {
4
+ rect: Rect;
5
+ rotation: Rotation;
6
+ }
7
+ interface CounterTransformResult {
8
+ matrix: string;
9
+ width: number;
10
+ height: number;
11
+ }
12
+ /**
13
+ * Given an already-placed rect (left/top/width/height in px) and the page rotation,
14
+ * return the counter-rotation matrix + adjusted width/height.
15
+ *
16
+ * transform-origin is expected to be "0 0".
17
+ * left/top DO NOT change, apply them as-is.
18
+ */
19
+ export declare function getCounterRotation(rect: Rect, rotation: Rotation): CounterTransformResult;
20
+ export interface MenuWrapperProps {
21
+ style: CSSProperties;
22
+ onPointerDown: (e: PointerEvent<HTMLDivElement>) => void;
23
+ }
24
+ interface CounterRotateComponentProps extends CounterRotateProps {
25
+ children: (props: {
26
+ matrix: string;
27
+ rect: Rect;
28
+ menuWrapperProps: MenuWrapperProps;
29
+ }) => ReactNode;
30
+ }
31
+ export declare function CounterRotate({ children, ...props }: CounterRotateComponentProps): import("preact").JSX.Element;
32
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ResizeDirection } from '../types';
2
+ import { PointerEvent } from '../../preact/adapter.ts';
3
+ interface Props {
4
+ rotation: number;
5
+ outlineOffset?: number;
6
+ startResize: (d: ResizeDirection) => (e: PointerEvent<HTMLDivElement>) => void;
7
+ }
8
+ export declare function ResizeHandles({ rotation, outlineOffset, startResize }: Props): import("preact").JSX.Element;
9
+ export {};
@@ -0,0 +1,19 @@
1
+ import { JSX } from '../../preact/adapter.ts';
2
+ import { Position, Rect } from '@embedpdf/models';
3
+ export interface VertexEditorProps {
4
+ /** Bounding box (PDF units) of the annotation */
5
+ rect: Rect;
6
+ /** Page rotation (0-3) */
7
+ rotation: number;
8
+ /** Current zoom factor */
9
+ scale: number;
10
+ /** Array of vertices in PDF units */
11
+ vertices: Position[];
12
+ /** Called *every* drag frame with new vertices */
13
+ onEdit: (v: Position[]) => void;
14
+ /** Called once at end of drag to commit changes */
15
+ onCommit: (v: Position[]) => void;
16
+ /** Size of handle in CSS px */
17
+ handleSize?: number;
18
+ }
19
+ export declare function VertexEditor({ rect, rotation, scale, vertices, onEdit, onCommit, handleSize, }: VertexEditorProps): JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { PointerEvent } from '../../preact/adapter.ts';
2
+ import { PdfAnnotationObject, Position, Rect } from '@embedpdf/models';
3
+ import { TrackedAnnotation } from '../../lib/index.ts';
4
+ import { ResizeDirection } from '../types';
5
+ import { ComputePatch } from '../patchers';
6
+ interface UseDragResizeOpts<T extends PdfAnnotationObject> {
7
+ scale: number;
8
+ pageWidth: number;
9
+ pageHeight: number;
10
+ rotation: number;
11
+ tracked: TrackedAnnotation<T>;
12
+ isSelected: boolean;
13
+ isDraggable: boolean;
14
+ isResizable: boolean;
15
+ computePatch?: ComputePatch<T>;
16
+ computeVertices?: (a: T) => Position[];
17
+ currentRect: Rect;
18
+ setCurrentRect: (r: Rect) => void;
19
+ setCurrentVertices: (v: Position[]) => void;
20
+ setPreviewObject: (p: Partial<T> | null) => void;
21
+ commit: (patch: Partial<T>) => void;
22
+ }
23
+ export declare function useDragResize<T extends PdfAnnotationObject>({ scale, pageWidth, pageHeight, rotation, tracked, isSelected, isDraggable, isResizable, computePatch, computeVertices, currentRect, setCurrentRect, setCurrentVertices, setPreviewObject, commit, }: UseDragResizeOpts<T>): {
24
+ rootHandlers: {
25
+ onPointerDown: (e: PointerEvent<HTMLDivElement>) => void;
26
+ onPointerMove: (e: PointerEvent<HTMLDivElement>) => void;
27
+ onPointerUp: () => void;
28
+ };
29
+ startResize: (direction: ResizeDirection) => (e: PointerEvent<HTMLDivElement>) => void;
30
+ };
31
+ export {};
@@ -1,5 +1,5 @@
1
- import { PdfAnnotationObject, PdfInkAnnoObject, Rect } from '@embedpdf/models';
2
- import { ResizeDirection } from './types';
1
+ import { PdfInkAnnoObject } from '@embedpdf/models';
2
+ import { ComputePatch } from './patchers';
3
3
  /**
4
4
  * Computes a patch for resizing an ink annotation.
5
5
  * - Scales all points in inkList to fit the new rect.
@@ -13,5 +13,4 @@ import { ResizeDirection } from './types';
13
13
  * @param uniform If true, constrains to uniform scaling (uses min scale factor).
14
14
  * @returns Partial patch { rect, inkList, strokeWidth } to apply.
15
15
  */
16
- export declare function resizeInkAnnotation(original: PdfAnnotationObject, // Assumes type=INK
17
- newRect: Rect, direction: ResizeDirection, uniform?: boolean): Partial<PdfInkAnnoObject>;
16
+ export declare const patchInk: ComputePatch<PdfInkAnnoObject>;
@@ -0,0 +1,9 @@
1
+ import { PdfAnnotationObject, Rect, Position } from '@embedpdf/models';
2
+ import { ResizeDirection } from './types';
3
+ export interface PatchContext {
4
+ rect: Rect;
5
+ vertices?: Position[];
6
+ direction?: ResizeDirection;
7
+ uniform?: boolean;
8
+ }
9
+ export type ComputePatch<T extends PdfAnnotationObject> = (original: T, ctx: PatchContext) => Partial<T>;
@@ -1 +1,12 @@
1
+ import { Rect } from '@embedpdf/models';
2
+ import { TrackedAnnotation } from '../lib/index.ts';
3
+ import { JSX } from '../preact/adapter.ts';
4
+ import { MenuWrapperProps } from './components/counter-rotate-container';
1
5
  export type ResizeDirection = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'none';
6
+ export interface SelectionMenuProps {
7
+ annotation: TrackedAnnotation;
8
+ selected: boolean;
9
+ rect: Rect;
10
+ menuWrapperProps: MenuWrapperProps;
11
+ }
12
+ export type SelectionMenu = (props: SelectionMenuProps) => JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { PdfAnnotationSubtype, PdfAnnotationObject, PdfLineAnnoObject, PdfPolylineAnnoObject, PdfPolygonAnnoObject, Rect, Position } from '@embedpdf/models';
2
+ export interface PatchContext {
3
+ rect: Rect;
4
+ vertices?: Position[];
5
+ }
6
+ export type PatchFn<T extends PdfAnnotationObject> = (original: T, ctx: PatchContext) => Partial<T>;
7
+ export declare const patchLine: PatchFn<PdfLineAnnoObject>;
8
+ export declare const patchPolyline: PatchFn<PdfPolylineAnnoObject>;
9
+ export declare const patchPolygon: PatchFn<PdfPolygonAnnoObject>;
10
+ export declare function getPatchFn(type: PdfAnnotationSubtype): PatchFn<PdfLineAnnoObject> | PatchFn<PdfPolylineAnnoObject> | PatchFn<PdfPolygonAnnoObject> | undefined;
@@ -1,19 +1,25 @@
1
- import { JSX, HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
1
+ import { JSX, HTMLAttributes, CSSProperties, MouseEvent } from '../../react/adapter.ts';
2
2
  import { TrackedAnnotation } from '../../lib/index.ts';
3
- import { PdfAnnotationObject, Rect } from '@embedpdf/models';
4
- import { ResizeDirection } from '../../shared/types';
5
- type AnnotationContainerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style' | 'children'> & {
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'> & {
6
7
  scale: number;
7
8
  isSelected?: boolean;
8
9
  pageIndex: number;
10
+ pageWidth: number;
11
+ pageHeight: number;
9
12
  rotation: number;
10
- trackedAnnotation: TrackedAnnotation;
11
- children: JSX.Element | ((annotation: PdfAnnotationObject) => JSX.Element);
13
+ trackedAnnotation: TrackedAnnotation<T>;
14
+ children: JSX.Element | ((annotation: T) => JSX.Element);
12
15
  style?: CSSProperties;
13
16
  isDraggable?: boolean;
14
17
  isResizable?: boolean;
15
18
  outlineOffset?: number;
16
- computeResizePatch?: (original: PdfAnnotationObject, newRect: Rect, direction: ResizeDirection) => Partial<PdfAnnotationObject>;
19
+ onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;
20
+ selectionMenu?: (props: SelectionMenuProps) => JSX.Element;
21
+ computeVertices?: (annotation: T) => Position[];
22
+ computePatch?: ComputePatch<T>;
17
23
  };
18
- export declare function AnnotationContainer({ scale, pageIndex, rotation, trackedAnnotation, children, style, outlineOffset, isSelected, isDraggable, isResizable, computeResizePatch, ...props }: AnnotationContainerProps): JSX.Element;
24
+ export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, style, outlineOffset, isSelected, isDraggable, isResizable, computeVertices, computePatch, selectionMenu, onDoubleClick, ...props }: AnnotationContainerProps<T>): JSX.Element;
19
25
  export {};
@@ -1,11 +1,13 @@
1
1
  import { HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
2
+ import { SelectionMenu } from '../types';
2
3
  type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
3
4
  pageIndex: number;
4
5
  scale: number;
5
6
  pageWidth: number;
6
7
  pageHeight: number;
7
8
  rotation: number;
9
+ selectionMenu?: SelectionMenu;
8
10
  style?: CSSProperties;
9
11
  };
10
- export declare function AnnotationLayer({ pageIndex, scale, pageWidth, pageHeight, rotation, style, ...props }: AnnotationLayerProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function AnnotationLayer({ pageIndex, scale, pageWidth, pageHeight, rotation, selectionMenu, style, ...props }: AnnotationLayerProps): import("react/jsx-runtime").JSX.Element;
11
13
  export {};
@@ -0,0 +1,10 @@
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("react/jsx-runtime").JSX.Element | null;
10
+ export {};
@@ -0,0 +1,29 @@
1
+ import { MouseEvent } from '../../../react/adapter.ts';
2
+ import { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';
3
+ interface CircleProps {
4
+ /** Fill colour – defaults to PDFium’s black if omitted */
5
+ color?: string;
6
+ /** Stroke colour – defaults to same as fill when omitted */
7
+ strokeColor?: string;
8
+ /** 0 – 1 */
9
+ opacity?: number;
10
+ /** Stroke width in PDF units */
11
+ strokeWidth: number;
12
+ /** Stroke type – defaults to solid when omitted */
13
+ strokeStyle?: PdfAnnotationBorderStyle;
14
+ /** Stroke dash array – defaults to undefined when omitted */
15
+ strokeDashArray?: number[];
16
+ /** Bounding box of the annotation */
17
+ rect: Rect;
18
+ /** Current page zoom factor */
19
+ scale: number;
20
+ /** Click handler (used for selection) */
21
+ onClick?: (e: MouseEvent<SVGElement>) => void;
22
+ /** Cursor shown over the annotation */
23
+ cursor?: string;
24
+ }
25
+ /**
26
+ * Renders a PDF Circle annotation (ellipse) as SVG.
27
+ */
28
+ export declare function Circle({ color, strokeColor, opacity, strokeWidth, strokeStyle, strokeDashArray, rect, scale, onClick, cursor, }: CircleProps): JSX.Element;
29
+ export {};
@@ -0,0 +1,10 @@
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("react/jsx-runtime").JSX.Element | null;
10
+ export {};
@@ -0,0 +1,13 @@
1
+ import { MouseEvent } from '../../../react/adapter.ts';
2
+ import { PdfFreeTextAnnoObject } from '@embedpdf/models';
3
+ import { TrackedAnnotation } from '../../../lib/index.ts';
4
+ interface FreeTextProps {
5
+ isSelected: boolean;
6
+ isEditing: boolean;
7
+ annotation: TrackedAnnotation<PdfFreeTextAnnoObject>;
8
+ pageIndex: number;
9
+ scale: number;
10
+ onClick?: (e: MouseEvent<HTMLDivElement>) => void;
11
+ }
12
+ export declare function FreeText({ isSelected, isEditing, annotation, pageIndex, scale, onClick, }: FreeTextProps): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -15,9 +15,11 @@ interface InkProps {
15
15
  scale: number;
16
16
  /** Callback for when the annotation is clicked */
17
17
  onClick?: (e: MouseEvent<SVGPathElement>) => void;
18
+ /** Cursor on the ink */
19
+ cursor?: string;
18
20
  }
19
21
  /**
20
22
  * Renders a PDF Ink annotation (free-hand drawing) as SVG.
21
23
  */
22
- export declare function Ink({ color, opacity, strokeWidth, inkList, rect, scale, onClick, }: InkProps): JSX.Element;
24
+ export declare function Ink({ color, opacity, strokeWidth, inkList, rect, scale, onClick, cursor, }: InkProps): JSX.Element;
23
25
  export {};
@@ -0,0 +1,10 @@
1
+ interface LinePaintProps {
2
+ pageIndex: number;
3
+ scale: number;
4
+ pageWidth: number;
5
+ pageHeight: number;
6
+ /** Optional preview cursor */
7
+ cursor?: string;
8
+ }
9
+ export declare const LinePaint: ({ pageIndex, scale, pageWidth, pageHeight, cursor }: LinePaintProps) => import("react/jsx-runtime").JSX.Element | null;
10
+ export {};
@@ -0,0 +1,33 @@
1
+ import { MouseEvent } from '../../../react/adapter.ts';
2
+ import { Rect, LinePoints, LineEndings, PdfAnnotationBorderStyle } from '@embedpdf/models';
3
+ interface LineProps {
4
+ /** interior colour */
5
+ color?: string;
6
+ /** 0 – 1 */
7
+ opacity?: number;
8
+ /** Stroke width in PDF units */
9
+ strokeWidth: number;
10
+ /** Stroke colour (falls back to PDFium default black) */
11
+ strokeColor?: string;
12
+ /** Stroke style */
13
+ strokeStyle?: PdfAnnotationBorderStyle;
14
+ /** Stroke dash array */
15
+ strokeDashArray?: number[];
16
+ /** Bounding box of the annotation */
17
+ rect: Rect;
18
+ /** Line start / end points (page units) */
19
+ linePoints: LinePoints;
20
+ /** Line endings (eg. OpenArrow / Butt) */
21
+ lineEndings?: LineEndings;
22
+ /** Current page zoom factor */
23
+ scale: number;
24
+ /** Click handler (used for selection) */
25
+ onClick?: (e: MouseEvent<SVGElement>) => void;
26
+ /** Whether the annotation is selected */
27
+ isSelected: boolean;
28
+ }
29
+ /**
30
+ * Renders a PDF Line annotation as SVG (with arrow/butt endings).
31
+ */
32
+ export declare function Line({ color, opacity, strokeWidth, strokeColor, strokeStyle, strokeDashArray, rect, linePoints, lineEndings, scale, onClick, isSelected, }: LineProps): JSX.Element;
33
+ export {};