@embedpdf/plugin-annotation 1.0.11 → 1.0.13

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 (109) hide show
  1. package/dist/index.cjs +2 -693
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +1 -266
  4. package/dist/index.js +509 -164
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/actions.d.ts +104 -0
  7. package/dist/lib/annotation-plugin.d.ts +34 -0
  8. package/dist/lib/helpers.d.ts +18 -0
  9. package/dist/lib/index.d.ts +12 -0
  10. package/dist/lib/manifest.d.ts +4 -0
  11. package/dist/lib/patching/derived-rect.d.ts +2 -0
  12. package/dist/lib/patching/index.d.ts +4 -0
  13. package/dist/lib/patching/line-ending-handlers.d.ts +20 -0
  14. package/dist/lib/patching/line-endings.d.ts +13 -0
  15. package/dist/lib/patching/patch-utils.d.ts +7 -0
  16. package/dist/lib/reducer.d.ts +5 -0
  17. package/dist/lib/selectors.d.ts +25 -0
  18. package/dist/lib/types.d.ts +168 -0
  19. package/dist/lib/utils.d.ts +11 -0
  20. package/dist/lib/variant-key.d.ts +8 -0
  21. package/dist/preact/adapter.d.ts +8 -0
  22. package/dist/preact/core.d.ts +1 -0
  23. package/dist/preact/index.cjs +2 -1038
  24. package/dist/preact/index.cjs.map +1 -1
  25. package/dist/preact/index.d.ts +1 -28
  26. package/dist/preact/index.js +2150 -539
  27. package/dist/preact/index.js.map +1 -1
  28. package/dist/preact/interaction-manager.d.ts +1 -0
  29. package/dist/preact/selection.d.ts +1 -0
  30. package/dist/react/adapter.d.ts +2 -0
  31. package/dist/react/core.d.ts +1 -0
  32. package/dist/react/index.cjs +2 -0
  33. package/dist/react/index.cjs.map +1 -0
  34. package/dist/react/index.d.ts +1 -0
  35. package/dist/react/index.js +2624 -0
  36. package/dist/react/index.js.map +1 -0
  37. package/dist/react/interaction-manager.d.ts +1 -0
  38. package/dist/react/selection.d.ts +1 -0
  39. package/dist/shared-preact/components/annotation-container.d.ts +24 -0
  40. package/dist/shared-preact/components/annotation-layer.d.ts +13 -0
  41. package/dist/shared-preact/components/annotations/circle-paint.d.ts +10 -0
  42. package/dist/shared-preact/components/annotations/circle.d.ts +29 -0
  43. package/dist/shared-preact/components/annotations/ink-highlight-paint.d.ts +0 -0
  44. package/dist/shared-preact/components/annotations/ink-paint.d.ts +18 -0
  45. package/dist/shared-preact/components/annotations/ink.d.ts +25 -0
  46. package/dist/shared-preact/components/annotations/line-paint.d.ts +10 -0
  47. package/dist/shared-preact/components/annotations/line.d.ts +33 -0
  48. package/dist/shared-preact/components/annotations/polygon-paint.d.ts +9 -0
  49. package/dist/shared-preact/components/annotations/polygon.d.ts +17 -0
  50. package/dist/shared-preact/components/annotations/polyline-paint.d.ts +10 -0
  51. package/dist/shared-preact/components/annotations/polyline.d.ts +17 -0
  52. package/dist/shared-preact/components/annotations/square-paint.d.ts +10 -0
  53. package/dist/shared-preact/components/annotations/square.d.ts +29 -0
  54. package/dist/shared-preact/components/annotations.d.ts +11 -0
  55. package/dist/shared-preact/components/counter-rotate-container.d.ts +32 -0
  56. package/dist/shared-preact/components/index.d.ts +1 -0
  57. package/dist/shared-preact/components/render-annotation.d.ts +11 -0
  58. package/dist/shared-preact/components/resize-handles.d.ts +9 -0
  59. package/dist/shared-preact/components/text-markup/highlight.d.ts +13 -0
  60. package/dist/shared-preact/components/text-markup/squiggly.d.ts +13 -0
  61. package/dist/shared-preact/components/text-markup/strikeout.d.ts +13 -0
  62. package/dist/shared-preact/components/text-markup/underline.d.ts +13 -0
  63. package/dist/shared-preact/components/text-markup.d.ts +6 -0
  64. package/dist/shared-preact/components/vertex-editor.d.ts +19 -0
  65. package/dist/shared-preact/hooks/index.d.ts +1 -0
  66. package/dist/shared-preact/hooks/use-annotation.d.ts +11 -0
  67. package/dist/shared-preact/hooks/use-drag-resize.d.ts +31 -0
  68. package/dist/shared-preact/index.d.ts +2 -0
  69. package/dist/shared-preact/patch-ink.d.ts +16 -0
  70. package/dist/shared-preact/patchers.d.ts +9 -0
  71. package/dist/shared-preact/types.d.ts +12 -0
  72. package/dist/shared-preact/vertex-patchers.d.ts +10 -0
  73. package/dist/shared-react/components/annotation-container.d.ts +24 -0
  74. package/dist/shared-react/components/annotation-layer.d.ts +13 -0
  75. package/dist/shared-react/components/annotations/circle-paint.d.ts +10 -0
  76. package/dist/shared-react/components/annotations/circle.d.ts +29 -0
  77. package/dist/shared-react/components/annotations/ink-highlight-paint.d.ts +0 -0
  78. package/dist/shared-react/components/annotations/ink-paint.d.ts +17 -0
  79. package/dist/shared-react/components/annotations/ink.d.ts +25 -0
  80. package/dist/shared-react/components/annotations/line-paint.d.ts +10 -0
  81. package/dist/shared-react/components/annotations/line.d.ts +33 -0
  82. package/dist/shared-react/components/annotations/polygon-paint.d.ts +9 -0
  83. package/dist/shared-react/components/annotations/polygon.d.ts +17 -0
  84. package/dist/shared-react/components/annotations/polyline-paint.d.ts +10 -0
  85. package/dist/shared-react/components/annotations/polyline.d.ts +17 -0
  86. package/dist/shared-react/components/annotations/square-paint.d.ts +10 -0
  87. package/dist/shared-react/components/annotations/square.d.ts +29 -0
  88. package/dist/shared-react/components/annotations.d.ts +11 -0
  89. package/dist/shared-react/components/counter-rotate-container.d.ts +32 -0
  90. package/dist/shared-react/components/index.d.ts +1 -0
  91. package/dist/shared-react/components/render-annotation.d.ts +11 -0
  92. package/dist/shared-react/components/resize-handles.d.ts +9 -0
  93. package/dist/shared-react/components/text-markup/highlight.d.ts +13 -0
  94. package/dist/shared-react/components/text-markup/squiggly.d.ts +13 -0
  95. package/dist/shared-react/components/text-markup/strikeout.d.ts +13 -0
  96. package/dist/shared-react/components/text-markup/underline.d.ts +13 -0
  97. package/dist/shared-react/components/text-markup.d.ts +6 -0
  98. package/dist/shared-react/components/vertex-editor.d.ts +19 -0
  99. package/dist/shared-react/hooks/index.d.ts +1 -0
  100. package/dist/shared-react/hooks/use-annotation.d.ts +11 -0
  101. package/dist/shared-react/hooks/use-drag-resize.d.ts +31 -0
  102. package/dist/shared-react/index.d.ts +2 -0
  103. package/dist/shared-react/patch-ink.d.ts +16 -0
  104. package/dist/shared-react/patchers.d.ts +9 -0
  105. package/dist/shared-react/types.d.ts +12 -0
  106. package/dist/shared-react/vertex-patchers.d.ts +10 -0
  107. package/package.json +17 -15
  108. package/dist/index.d.cts +0 -266
  109. package/dist/preact/index.d.cts +0 -28
@@ -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 {};
@@ -0,0 +1,11 @@
1
+ import { SelectionMenu } from '../types';
2
+ interface AnnotationsProps {
3
+ pageIndex: number;
4
+ scale: number;
5
+ rotation: number;
6
+ pageWidth: number;
7
+ pageHeight: number;
8
+ selectionMenu?: SelectionMenu;
9
+ }
10
+ export declare function Annotations(annotationsProps: AnnotationsProps): import("preact").JSX.Element;
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 @@
1
+ export * from './annotation-layer';
@@ -0,0 +1,11 @@
1
+ import { HTMLAttributes, CSSProperties } from '../../preact/adapter.ts';
2
+ import { PdfAnnotationObject } from '@embedpdf/models';
3
+ type RenderAnnotationProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {
4
+ pageIndex: number;
5
+ annotation: PdfAnnotationObject;
6
+ scaleFactor?: number;
7
+ dpr?: number;
8
+ style?: CSSProperties;
9
+ };
10
+ export declare function RenderAnnotation({ pageIndex, annotation, scaleFactor, dpr, style, ...props }: RenderAnnotationProps): import("preact").JSX.Element;
11
+ 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,13 @@
1
+ import { HTMLAttributes, CSSProperties, MouseEvent } from '../../../preact/adapter.ts';
2
+ import { Rect } from '@embedpdf/models';
3
+ type HighlightProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
+ color?: string;
5
+ opacity?: number;
6
+ rects: Rect[];
7
+ rect?: Rect;
8
+ scale: number;
9
+ onClick?: (e: MouseEvent<HTMLDivElement>) => void;
10
+ style?: CSSProperties;
11
+ };
12
+ export declare function Highlight({ color, opacity, rects, rect, scale, onClick, style, ...props }: HighlightProps): import("preact").JSX.Element;
13
+ export {};
@@ -0,0 +1,13 @@
1
+ import { HTMLAttributes, CSSProperties, MouseEvent } from '../../../preact/adapter.ts';
2
+ import { Rect } from '@embedpdf/models';
3
+ type SquigglyProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
+ color?: string;
5
+ opacity?: number;
6
+ rects: Rect[];
7
+ rect?: Rect;
8
+ scale: number;
9
+ onClick?: (e: MouseEvent<HTMLDivElement>) => void;
10
+ style?: CSSProperties;
11
+ };
12
+ export declare function Squiggly({ color, opacity, rects, rect, scale, onClick, style, ...props }: SquigglyProps): import("preact").JSX.Element;
13
+ export {};
@@ -0,0 +1,13 @@
1
+ import { HTMLAttributes, CSSProperties, MouseEvent } from '../../../preact/adapter.ts';
2
+ import { Rect } from '@embedpdf/models';
3
+ type StrikeoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
+ color?: string;
5
+ opacity?: number;
6
+ rects: Rect[];
7
+ rect?: Rect;
8
+ scale: number;
9
+ onClick?: (e: MouseEvent<HTMLDivElement>) => void;
10
+ style?: CSSProperties;
11
+ };
12
+ export declare function Strikeout({ color, opacity, rects, rect, scale, onClick, style, ...props }: StrikeoutProps): import("preact").JSX.Element;
13
+ export {};
@@ -0,0 +1,13 @@
1
+ import { HTMLAttributes, CSSProperties, MouseEvent } from '../../../preact/adapter.ts';
2
+ import { Rect } from '@embedpdf/models';
3
+ type UnderlineProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
+ color?: string;
5
+ opacity?: number;
6
+ rects: Rect[];
7
+ rect?: Rect;
8
+ scale: number;
9
+ onClick?: (e: MouseEvent<HTMLDivElement>) => void;
10
+ style?: CSSProperties;
11
+ };
12
+ export declare function Underline({ color, opacity, rects, rect, scale, onClick, style, ...props }: UnderlineProps): import("preact").JSX.Element;
13
+ export {};
@@ -0,0 +1,6 @@
1
+ interface TextMarkupProps {
2
+ pageIndex: number;
3
+ scale: number;
4
+ }
5
+ export declare function TextMarkup({ pageIndex, scale }: TextMarkupProps): import("preact").JSX.Element | null;
6
+ 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 @@
1
+ export * from './use-annotation';
@@ -0,0 +1,11 @@
1
+ import { AnnotationPlugin } from '../../lib/index.ts';
2
+ export declare const useAnnotationPlugin: () => {
3
+ plugin: AnnotationPlugin | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ export declare const useAnnotationCapability: () => {
8
+ provides: Readonly<import('../../lib/index.ts').AnnotationCapability> | null;
9
+ isLoading: boolean;
10
+ ready: Promise<void>;
11
+ };
@@ -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 {};
@@ -0,0 +1,2 @@
1
+ export * from './hooks';
2
+ export * from './components';
@@ -0,0 +1,16 @@
1
+ import { PdfInkAnnoObject } from '@embedpdf/models';
2
+ import { ComputePatch } from './patchers';
3
+ /**
4
+ * Computes a patch for resizing an ink annotation.
5
+ * - Scales all points in inkList to fit the new rect.
6
+ * - Scales strokeWidth proportionally (using average scale factor).
7
+ * - Handles non-uniform scaling (stretch).
8
+ * - Optionally preserves aspect ratio (set uniform=true).
9
+ *
10
+ * @param original The original ink annotation object.
11
+ * @param newRect The new bounding rect after resize.
12
+ * @param direction The resize handle direction (affects origin adjustments if needed).
13
+ * @param uniform If true, constrains to uniform scaling (uses min scale factor).
14
+ * @returns Partial patch { rect, inkList, strokeWidth } to apply.
15
+ */
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>;
@@ -0,0 +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';
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;
@@ -0,0 +1,24 @@
1
+ import { JSX, HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
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'> & {
7
+ scale: number;
8
+ isSelected?: boolean;
9
+ pageIndex: number;
10
+ pageWidth: number;
11
+ pageHeight: number;
12
+ rotation: number;
13
+ trackedAnnotation: TrackedAnnotation<T>;
14
+ children: JSX.Element | ((annotation: T) => JSX.Element);
15
+ style?: CSSProperties;
16
+ isDraggable?: boolean;
17
+ isResizable?: boolean;
18
+ outlineOffset?: number;
19
+ selectionMenu?: (props: SelectionMenuProps) => JSX.Element;
20
+ computeVertices?: (annotation: T) => Position[];
21
+ computePatch?: ComputePatch<T>;
22
+ };
23
+ export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, style, outlineOffset, isSelected, isDraggable, isResizable, computeVertices, computePatch, selectionMenu, ...props }: AnnotationContainerProps<T>): JSX.Element;
24
+ export {};
@@ -0,0 +1,13 @@
1
+ import { HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
2
+ import { SelectionMenu } from '../types';
3
+ type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
+ pageIndex: number;
5
+ scale: number;
6
+ pageWidth: number;
7
+ pageHeight: number;
8
+ rotation: number;
9
+ selectionMenu?: SelectionMenu;
10
+ style?: CSSProperties;
11
+ };
12
+ export declare function AnnotationLayer({ pageIndex, scale, pageWidth, pageHeight, rotation, selectionMenu, style, ...props }: AnnotationLayerProps): import("react/jsx-runtime").JSX.Element;
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,17 @@
1
+ interface InkPaintProps {
2
+ /** Index of the page this layer lives on */
3
+ pageIndex: number;
4
+ /** Scale of the page */
5
+ scale: number;
6
+ /** Width of the page */
7
+ pageWidth: number;
8
+ /** Height of the page */
9
+ pageHeight: number;
10
+ }
11
+ /**
12
+ * Allows the user to draw freehand ink annotations.
13
+ * Hook it into the interaction-manager with modeId = 'inkPaint'.
14
+ * 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
+ export declare const InkPaint: ({ pageIndex, scale, pageWidth, pageHeight }: InkPaintProps) => import("react/jsx-runtime").JSX.Element | null;
17
+ export {};
@@ -0,0 +1,25 @@
1
+ import { MouseEvent } from '../../../react/adapter.ts';
2
+ import { PdfInkListObject, Rect } from '@embedpdf/models';
3
+ interface InkProps {
4
+ /** Stroke colour (falls back to PDFium default black) */
5
+ color?: string;
6
+ /** 0 – 1 */
7
+ opacity?: number;
8
+ /** Line width in PDF units */
9
+ strokeWidth: number;
10
+ /** Array of strokes — exactly as in your JSON */
11
+ inkList: PdfInkListObject[];
12
+ /** Bounding box of the whole annotation */
13
+ rect: Rect;
14
+ /** Page zoom factor */
15
+ scale: number;
16
+ /** Callback for when the annotation is clicked */
17
+ onClick?: (e: MouseEvent<SVGPathElement>) => void;
18
+ /** Cursor on the ink */
19
+ cursor?: string;
20
+ }
21
+ /**
22
+ * Renders a PDF Ink annotation (free-hand drawing) as SVG.
23
+ */
24
+ export declare function Ink({ color, opacity, strokeWidth, inkList, rect, scale, onClick, cursor, }: InkProps): JSX.Element;
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 {};
@@ -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("react/jsx-runtime").JSX.Element | null;
9
+ export {};
@@ -0,0 +1,17 @@
1
+ import { MouseEvent } from '../../../react/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("react/jsx-runtime").JSX.Element | null;
10
+ export {};
@@ -0,0 +1,17 @@
1
+ import { MouseEvent } from '../../../react/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 {};