@embedpdf/plugin-annotation 1.0.13 → 1.0.15

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 (32) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +103 -49
  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 +9 -2
  7. package/dist/lib/types.d.ts +48 -7
  8. package/dist/preact/adapter.d.ts +6 -0
  9. package/dist/preact/index.cjs +1 -1
  10. package/dist/preact/index.cjs.map +1 -1
  11. package/dist/preact/index.js +500 -9
  12. package/dist/preact/index.js.map +1 -1
  13. package/dist/react/adapter.d.ts +6 -1
  14. package/dist/react/index.cjs +1 -1
  15. package/dist/react/index.cjs.map +1 -1
  16. package/dist/react/index.js +500 -9
  17. package/dist/react/index.js.map +1 -1
  18. package/dist/shared-preact/components/annotation-container.d.ts +4 -2
  19. package/dist/shared-preact/components/annotations/free-text-paint.d.ts +10 -0
  20. package/dist/shared-preact/components/annotations/free-text.d.ts +13 -0
  21. package/dist/shared-preact/components/annotations/stamp-paint.d.ts +8 -0
  22. package/dist/shared-preact/components/annotations/stamp.d.ts +12 -0
  23. package/dist/shared-preact/components/render-annotation.d.ts +1 -1
  24. package/dist/shared-preact/hooks/use-drag-resize.d.ts +5 -2
  25. package/dist/shared-react/components/annotation-container.d.ts +4 -2
  26. package/dist/shared-react/components/annotations/free-text-paint.d.ts +10 -0
  27. package/dist/shared-react/components/annotations/free-text.d.ts +13 -0
  28. package/dist/shared-react/components/annotations/stamp-paint.d.ts +8 -0
  29. package/dist/shared-react/components/annotations/stamp.d.ts +12 -0
  30. package/dist/shared-react/components/render-annotation.d.ts +1 -1
  31. package/dist/shared-react/hooks/use-drag-resize.d.ts +5 -2
  32. package/package.json +9 -9
@@ -1,4 +1,4 @@
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
3
  import { PdfAnnotationObject, Position } from '@embedpdf/models';
4
4
  import { SelectionMenuProps } from '../../shared/types';
@@ -16,9 +16,11 @@ type AnnotationContainerProps<T extends PdfAnnotationObject> = Omit<HTMLAttribut
16
16
  isDraggable?: boolean;
17
17
  isResizable?: boolean;
18
18
  outlineOffset?: number;
19
+ onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;
19
20
  selectionMenu?: (props: SelectionMenuProps) => JSX.Element;
20
21
  computeVertices?: (annotation: T) => Position[];
21
22
  computePatch?: ComputePatch<T>;
23
+ lockAspectRatio?: boolean;
22
24
  };
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;
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;
24
26
  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 {};
@@ -0,0 +1,8 @@
1
+ interface StampPaintProps {
2
+ pageIndex: number;
3
+ scale: number;
4
+ pageWidth: number;
5
+ pageHeight: number;
6
+ }
7
+ export declare const StampPaint: ({ pageIndex, scale, pageWidth, pageHeight }: StampPaintProps) => import("preact").JSX.Element | null;
8
+ export {};
@@ -0,0 +1,12 @@
1
+ import { MouseEvent } from '../../../preact/adapter.ts';
2
+ import { PdfStampAnnoObject } from '@embedpdf/models';
3
+ import { TrackedAnnotation } from '../../../lib/index.ts';
4
+ interface StampProps {
5
+ isSelected: boolean;
6
+ annotation: TrackedAnnotation<PdfStampAnnoObject>;
7
+ pageIndex: number;
8
+ scale: number;
9
+ onClick: (e: MouseEvent<HTMLDivElement>) => void;
10
+ }
11
+ export declare function Stamp({ isSelected, annotation, pageIndex, scale, onClick }: StampProps): import("preact").JSX.Element;
12
+ export {};
@@ -7,5 +7,5 @@ type RenderAnnotationProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {
7
7
  dpr?: number;
8
8
  style?: CSSProperties;
9
9
  };
10
- export declare function RenderAnnotation({ pageIndex, annotation, scaleFactor, dpr, style, ...props }: RenderAnnotationProps): import("preact").JSX.Element;
10
+ export declare function RenderAnnotation({ pageIndex, annotation, scaleFactor, style, ...props }: RenderAnnotationProps): import("preact").JSX.Element;
11
11
  export {};
@@ -14,17 +14,20 @@ interface UseDragResizeOpts<T extends PdfAnnotationObject> {
14
14
  isResizable: boolean;
15
15
  computePatch?: ComputePatch<T>;
16
16
  computeVertices?: (a: T) => Position[];
17
+ lockAspectRatio?: boolean;
17
18
  currentRect: Rect;
18
19
  setCurrentRect: (r: Rect) => void;
19
20
  setCurrentVertices: (v: Position[]) => void;
20
21
  setPreviewObject: (p: Partial<T> | null) => void;
21
22
  commit: (patch: Partial<T>) => void;
22
23
  }
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
+ export declare function useDragResize<T extends PdfAnnotationObject>({ scale, pageWidth, pageHeight, rotation, tracked, isSelected, isDraggable, isResizable, computePatch, computeVertices, lockAspectRatio, currentRect, setCurrentRect, setCurrentVertices, setPreviewObject, commit, }: UseDragResizeOpts<T>): {
24
25
  rootHandlers: {
25
26
  onPointerDown: (e: PointerEvent<HTMLDivElement>) => void;
26
27
  onPointerMove: (e: PointerEvent<HTMLDivElement>) => void;
27
- onPointerUp: () => void;
28
+ onPointerUp: (e?: PointerEvent<HTMLDivElement>) => void;
29
+ onPointerCancel: () => void;
30
+ onLostPointerCapture: () => void;
28
31
  };
29
32
  startResize: (direction: ResizeDirection) => (e: PointerEvent<HTMLDivElement>) => void;
30
33
  };
@@ -1,4 +1,4 @@
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
3
  import { PdfAnnotationObject, Position } from '@embedpdf/models';
4
4
  import { SelectionMenuProps } from '../../shared/types';
@@ -16,9 +16,11 @@ type AnnotationContainerProps<T extends PdfAnnotationObject> = Omit<HTMLAttribut
16
16
  isDraggable?: boolean;
17
17
  isResizable?: boolean;
18
18
  outlineOffset?: number;
19
+ onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;
19
20
  selectionMenu?: (props: SelectionMenuProps) => JSX.Element;
20
21
  computeVertices?: (annotation: T) => Position[];
21
22
  computePatch?: ComputePatch<T>;
23
+ lockAspectRatio?: boolean;
22
24
  };
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;
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;
24
26
  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 {};
@@ -0,0 +1,8 @@
1
+ interface StampPaintProps {
2
+ pageIndex: number;
3
+ scale: number;
4
+ pageWidth: number;
5
+ pageHeight: number;
6
+ }
7
+ export declare const StampPaint: ({ pageIndex, scale, pageWidth, pageHeight }: StampPaintProps) => import("react/jsx-runtime").JSX.Element | null;
8
+ export {};
@@ -0,0 +1,12 @@
1
+ import { MouseEvent } from '../../../react/adapter.ts';
2
+ import { PdfStampAnnoObject } from '@embedpdf/models';
3
+ import { TrackedAnnotation } from '../../../lib/index.ts';
4
+ interface StampProps {
5
+ isSelected: boolean;
6
+ annotation: TrackedAnnotation<PdfStampAnnoObject>;
7
+ pageIndex: number;
8
+ scale: number;
9
+ onClick: (e: MouseEvent<HTMLDivElement>) => void;
10
+ }
11
+ export declare function Stamp({ isSelected, annotation, pageIndex, scale, onClick }: StampProps): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -7,5 +7,5 @@ type RenderAnnotationProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {
7
7
  dpr?: number;
8
8
  style?: CSSProperties;
9
9
  };
10
- export declare function RenderAnnotation({ pageIndex, annotation, scaleFactor, dpr, style, ...props }: RenderAnnotationProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function RenderAnnotation({ pageIndex, annotation, scaleFactor, style, ...props }: RenderAnnotationProps): import("react/jsx-runtime").JSX.Element;
11
11
  export {};
@@ -14,17 +14,20 @@ interface UseDragResizeOpts<T extends PdfAnnotationObject> {
14
14
  isResizable: boolean;
15
15
  computePatch?: ComputePatch<T>;
16
16
  computeVertices?: (a: T) => Position[];
17
+ lockAspectRatio?: boolean;
17
18
  currentRect: Rect;
18
19
  setCurrentRect: (r: Rect) => void;
19
20
  setCurrentVertices: (v: Position[]) => void;
20
21
  setPreviewObject: (p: Partial<T> | null) => void;
21
22
  commit: (patch: Partial<T>) => void;
22
23
  }
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
+ export declare function useDragResize<T extends PdfAnnotationObject>({ scale, pageWidth, pageHeight, rotation, tracked, isSelected, isDraggable, isResizable, computePatch, computeVertices, lockAspectRatio, currentRect, setCurrentRect, setCurrentVertices, setPreviewObject, commit, }: UseDragResizeOpts<T>): {
24
25
  rootHandlers: {
25
26
  onPointerDown: (e: PointerEvent<HTMLDivElement>) => void;
26
27
  onPointerMove: (e: PointerEvent<HTMLDivElement>) => void;
27
- onPointerUp: () => void;
28
+ onPointerUp: (e?: PointerEvent<HTMLDivElement>) => void;
29
+ onPointerCancel: () => void;
30
+ onLostPointerCapture: () => void;
28
31
  };
29
32
  startResize: (direction: ResizeDirection) => (e: PointerEvent<HTMLDivElement>) => void;
30
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-annotation",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -18,24 +18,24 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@embedpdf/models": "1.0.13"
21
+ "@embedpdf/models": "1.0.15"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/react": "^18.2.0",
25
25
  "typescript": "^5.0.0",
26
- "@embedpdf/plugin-selection": "1.0.13",
27
- "@embedpdf/plugin-interaction-manager": "1.0.13",
28
26
  "@embedpdf/build": "1.0.0",
29
- "@embedpdf/plugin-history": "1.0.13"
27
+ "@embedpdf/plugin-interaction-manager": "1.0.15",
28
+ "@embedpdf/plugin-history": "1.0.15",
29
+ "@embedpdf/plugin-selection": "1.0.15"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">=16.8.0",
33
33
  "react-dom": ">=16.8.0",
34
34
  "preact": "^10.26.4",
35
- "@embedpdf/core": "1.0.13",
36
- "@embedpdf/plugin-history": "1.0.13",
37
- "@embedpdf/plugin-interaction-manager": "1.0.13",
38
- "@embedpdf/plugin-selection": "1.0.13"
35
+ "@embedpdf/core": "1.0.15",
36
+ "@embedpdf/plugin-interaction-manager": "1.0.15",
37
+ "@embedpdf/plugin-selection": "1.0.15",
38
+ "@embedpdf/plugin-history": "1.0.15"
39
39
  },
40
40
  "files": [
41
41
  "dist",