@embedpdf/plugin-annotation 1.2.0 → 1.3.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 (31) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +115 -53
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/tools/default-tools.d.ts +42 -14
  6. package/dist/lib/tools/types.d.ts +5 -1
  7. package/dist/preact/index.cjs +1 -1
  8. package/dist/preact/index.cjs.map +1 -1
  9. package/dist/preact/index.js +78 -41
  10. package/dist/preact/index.js.map +1 -1
  11. package/dist/react/index.cjs +1 -1
  12. package/dist/react/index.cjs.map +1 -1
  13. package/dist/react/index.js +78 -41
  14. package/dist/react/index.js.map +1 -1
  15. package/dist/shared-preact/components/annotation-container.d.ts +4 -2
  16. package/dist/shared-preact/components/annotation-layer.d.ts +5 -2
  17. package/dist/shared-preact/components/annotations.d.ts +3 -1
  18. package/dist/shared-preact/components/text-markup/highlight.d.ts +3 -3
  19. package/dist/shared-preact/components/text-markup/squiggly.d.ts +3 -3
  20. package/dist/shared-preact/components/text-markup/strikeout.d.ts +3 -3
  21. package/dist/shared-preact/components/text-markup/underline.d.ts +3 -3
  22. package/dist/shared-preact/types.d.ts +17 -0
  23. package/dist/shared-react/components/annotation-container.d.ts +4 -2
  24. package/dist/shared-react/components/annotation-layer.d.ts +5 -2
  25. package/dist/shared-react/components/annotations.d.ts +3 -1
  26. package/dist/shared-react/components/text-markup/highlight.d.ts +3 -3
  27. package/dist/shared-react/components/text-markup/squiggly.d.ts +3 -3
  28. package/dist/shared-react/components/text-markup/strikeout.d.ts +3 -3
  29. package/dist/shared-react/components/text-markup/underline.d.ts +3 -3
  30. package/dist/shared-react/types.d.ts +17 -0
  31. package/package.json +12 -11
@@ -1,6 +1,6 @@
1
- import { HTMLAttributes, CSSProperties, MouseEvent, TouchEvent } from '../../../preact/adapter.ts';
1
+ import { CSSProperties, MouseEvent, TouchEvent } from '../../../preact/adapter.ts';
2
2
  import { Rect } from '@embedpdf/models';
3
- type HighlightProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
3
+ type HighlightProps = {
4
4
  color?: string;
5
5
  opacity?: number;
6
6
  segmentRects: Rect[];
@@ -9,5 +9,5 @@ type HighlightProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Highlight({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: HighlightProps): import("preact").JSX.Element;
12
+ export declare function Highlight({ color, opacity, segmentRects, rect, scale, onClick, style, }: HighlightProps): import("preact").JSX.Element;
13
13
  export {};
@@ -1,6 +1,6 @@
1
- import { HTMLAttributes, CSSProperties, MouseEvent, TouchEvent } from '../../../preact/adapter.ts';
1
+ import { CSSProperties, MouseEvent, TouchEvent } from '../../../preact/adapter.ts';
2
2
  import { Rect } from '@embedpdf/models';
3
- type SquigglyProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
3
+ type SquigglyProps = {
4
4
  color?: string;
5
5
  opacity?: number;
6
6
  segmentRects: Rect[];
@@ -9,5 +9,5 @@ type SquigglyProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Squiggly({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: SquigglyProps): import("preact").JSX.Element;
12
+ export declare function Squiggly({ color, opacity, segmentRects, rect, scale, onClick, style, }: SquigglyProps): import("preact").JSX.Element;
13
13
  export {};
@@ -1,6 +1,6 @@
1
- import { HTMLAttributes, CSSProperties, MouseEvent, TouchEvent } from '../../../preact/adapter.ts';
1
+ import { CSSProperties, MouseEvent, TouchEvent } from '../../../preact/adapter.ts';
2
2
  import { Rect } from '@embedpdf/models';
3
- type StrikeoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
3
+ type StrikeoutProps = {
4
4
  color?: string;
5
5
  opacity?: number;
6
6
  segmentRects: Rect[];
@@ -9,5 +9,5 @@ type StrikeoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Strikeout({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: StrikeoutProps): import("preact").JSX.Element;
12
+ export declare function Strikeout({ color, opacity, segmentRects, rect, scale, onClick, style, }: StrikeoutProps): import("preact").JSX.Element;
13
13
  export {};
@@ -1,6 +1,6 @@
1
- import { HTMLAttributes, CSSProperties, MouseEvent, TouchEvent } from '../../../preact/adapter.ts';
1
+ import { CSSProperties, MouseEvent, TouchEvent } from '../../../preact/adapter.ts';
2
2
  import { Rect } from '@embedpdf/models';
3
- type UnderlineProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
3
+ type UnderlineProps = {
4
4
  color?: string;
5
5
  opacity?: number;
6
6
  segmentRects: Rect[];
@@ -9,5 +9,5 @@ type UnderlineProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Underline({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: UnderlineProps): import("preact").JSX.Element;
12
+ export declare function Underline({ color, opacity, segmentRects, rect, scale, onClick, style, }: UnderlineProps): import("preact").JSX.Element;
13
13
  export {};
@@ -40,3 +40,20 @@ export interface VertexHandleUI {
40
40
  /** Custom renderer for each vertex (overrides default) */
41
41
  component?: (p: HandleProps) => JSX.Element;
42
42
  }
43
+ /**
44
+ * Props for the custom annotation renderer
45
+ */
46
+ export interface CustomAnnotationRendererProps<T extends PdfAnnotationObject> {
47
+ annotation: T;
48
+ isSelected: boolean;
49
+ scale: number;
50
+ rotation: number;
51
+ pageWidth: number;
52
+ pageHeight: number;
53
+ pageIndex: number;
54
+ onSelect: (event: any) => void;
55
+ }
56
+ /**
57
+ * Custom renderer for an annotation
58
+ */
59
+ export type CustomAnnotationRenderer<T extends PdfAnnotationObject> = (props: CustomAnnotationRendererProps<T>) => JSX.Element | null;
@@ -1,7 +1,7 @@
1
1
  import { PdfAnnotationObject } from '@embedpdf/models';
2
2
  import { TrackedAnnotation } from '../../lib/index.ts';
3
3
  import { JSX, CSSProperties } from '../../react/adapter.ts';
4
- import { ResizeHandleUI, SelectionMenuProps, VertexConfig, VertexHandleUI } from '../types';
4
+ import { CustomAnnotationRenderer, ResizeHandleUI, SelectionMenuProps, VertexConfig, VertexHandleUI } from '../types';
5
5
  interface AnnotationContainerProps<T extends PdfAnnotationObject> {
6
6
  scale: number;
7
7
  pageIndex: number;
@@ -19,10 +19,12 @@ interface AnnotationContainerProps<T extends PdfAnnotationObject> {
19
19
  selectionMenu?: (props: SelectionMenuProps) => JSX.Element;
20
20
  outlineOffset?: number;
21
21
  onDoubleClick?: (event: any) => void;
22
+ onSelect: (event: any) => void;
22
23
  zIndex?: number;
23
24
  resizeUI?: ResizeHandleUI;
24
25
  vertexUI?: VertexHandleUI;
25
26
  selectionOutlineColor?: string;
27
+ customAnnotationRenderer?: CustomAnnotationRenderer<T>;
26
28
  }
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;
29
+ export declare function AnnotationContainer<T extends PdfAnnotationObject>({ scale, pageIndex, rotation, pageWidth, pageHeight, trackedAnnotation, children, isSelected, isDraggable, isResizable, lockAspectRatio, style, vertexConfig, selectionMenu, outlineOffset, onDoubleClick, onSelect, zIndex, resizeUI, vertexUI, selectionOutlineColor, customAnnotationRenderer, ...props }: AnnotationContainerProps<T>): JSX.Element;
28
30
  export {};
@@ -1,5 +1,6 @@
1
1
  import { HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
2
- import { SelectionMenu, ResizeHandleUI, VertexHandleUI } from '../types';
2
+ import { SelectionMenu, ResizeHandleUI, VertexHandleUI, CustomAnnotationRenderer } from '../types';
3
+ import { PdfAnnotationObject } from '@embedpdf/models';
3
4
  type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
5
  pageIndex: number;
5
6
  scale: number;
@@ -15,6 +16,8 @@ type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
15
16
  vertexUI?: VertexHandleUI;
16
17
  /** Customize selection outline color */
17
18
  selectionOutlineColor?: string;
19
+ /** Customize annotation renderer */
20
+ customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;
18
21
  };
19
- export declare function AnnotationLayer({ style, pageIndex, scale, selectionMenu, resizeUI, vertexUI, pageWidth, pageHeight, rotation, selectionOutlineColor, ...props }: AnnotationLayerProps): import("react/jsx-runtime").JSX.Element;
22
+ export declare function AnnotationLayer({ style, pageIndex, scale, selectionMenu, resizeUI, vertexUI, pageWidth, pageHeight, rotation, selectionOutlineColor, customAnnotationRenderer, ...props }: AnnotationLayerProps): import("react/jsx-runtime").JSX.Element;
20
23
  export {};
@@ -1,4 +1,5 @@
1
- import { ResizeHandleUI, SelectionMenu, VertexHandleUI } from '../types';
1
+ import { PdfAnnotationObject } from '@embedpdf/models';
2
+ import { CustomAnnotationRenderer, ResizeHandleUI, SelectionMenu, VertexHandleUI } from '../types';
2
3
  interface AnnotationsProps {
3
4
  pageIndex: number;
4
5
  scale: number;
@@ -9,6 +10,7 @@ interface AnnotationsProps {
9
10
  resizeUI?: ResizeHandleUI;
10
11
  vertexUI?: VertexHandleUI;
11
12
  selectionOutlineColor?: string;
13
+ customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;
12
14
  }
13
15
  export declare function Annotations(annotationsProps: AnnotationsProps): import("react/jsx-runtime").JSX.Element;
14
16
  export {};
@@ -1,6 +1,6 @@
1
- import { HTMLAttributes, CSSProperties, MouseEvent, TouchEvent } from '../../../react/adapter.ts';
1
+ import { CSSProperties, MouseEvent, TouchEvent } from '../../../react/adapter.ts';
2
2
  import { Rect } from '@embedpdf/models';
3
- type HighlightProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
3
+ type HighlightProps = {
4
4
  color?: string;
5
5
  opacity?: number;
6
6
  segmentRects: Rect[];
@@ -9,5 +9,5 @@ type HighlightProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Highlight({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: HighlightProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function Highlight({ color, opacity, segmentRects, rect, scale, onClick, style, }: HighlightProps): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -1,6 +1,6 @@
1
- import { HTMLAttributes, CSSProperties, MouseEvent, TouchEvent } from '../../../react/adapter.ts';
1
+ import { CSSProperties, MouseEvent, TouchEvent } from '../../../react/adapter.ts';
2
2
  import { Rect } from '@embedpdf/models';
3
- type SquigglyProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
3
+ type SquigglyProps = {
4
4
  color?: string;
5
5
  opacity?: number;
6
6
  segmentRects: Rect[];
@@ -9,5 +9,5 @@ type SquigglyProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Squiggly({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: SquigglyProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function Squiggly({ color, opacity, segmentRects, rect, scale, onClick, style, }: SquigglyProps): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -1,6 +1,6 @@
1
- import { HTMLAttributes, CSSProperties, MouseEvent, TouchEvent } from '../../../react/adapter.ts';
1
+ import { CSSProperties, MouseEvent, TouchEvent } from '../../../react/adapter.ts';
2
2
  import { Rect } from '@embedpdf/models';
3
- type StrikeoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
3
+ type StrikeoutProps = {
4
4
  color?: string;
5
5
  opacity?: number;
6
6
  segmentRects: Rect[];
@@ -9,5 +9,5 @@ type StrikeoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Strikeout({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: StrikeoutProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function Strikeout({ color, opacity, segmentRects, rect, scale, onClick, style, }: StrikeoutProps): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -1,6 +1,6 @@
1
- import { HTMLAttributes, CSSProperties, MouseEvent, TouchEvent } from '../../../react/adapter.ts';
1
+ import { CSSProperties, MouseEvent, TouchEvent } from '../../../react/adapter.ts';
2
2
  import { Rect } from '@embedpdf/models';
3
- type UnderlineProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
3
+ type UnderlineProps = {
4
4
  color?: string;
5
5
  opacity?: number;
6
6
  segmentRects: Rect[];
@@ -9,5 +9,5 @@ type UnderlineProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
9
9
  onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
10
10
  style?: CSSProperties;
11
11
  };
12
- export declare function Underline({ color, opacity, segmentRects, rect, scale, onClick, style, ...props }: UnderlineProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function Underline({ color, opacity, segmentRects, rect, scale, onClick, style, }: UnderlineProps): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -40,3 +40,20 @@ export interface VertexHandleUI {
40
40
  /** Custom renderer for each vertex (overrides default) */
41
41
  component?: (p: HandleProps) => JSX.Element;
42
42
  }
43
+ /**
44
+ * Props for the custom annotation renderer
45
+ */
46
+ export interface CustomAnnotationRendererProps<T extends PdfAnnotationObject> {
47
+ annotation: T;
48
+ isSelected: boolean;
49
+ scale: number;
50
+ rotation: number;
51
+ pageWidth: number;
52
+ pageHeight: number;
53
+ pageIndex: number;
54
+ onSelect: (event: any) => void;
55
+ }
56
+ /**
57
+ * Custom renderer for an annotation
58
+ */
59
+ export type CustomAnnotationRenderer<T extends PdfAnnotationObject> = (props: CustomAnnotationRendererProps<T>) => JSX.Element | null;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-annotation",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
+ "license": "MIT",
5
6
  "main": "./dist/index.cjs",
6
7
  "module": "./dist/index.js",
7
8
  "types": "./dist/index.d.ts",
@@ -28,26 +29,26 @@
28
29
  }
29
30
  },
30
31
  "dependencies": {
31
- "@embedpdf/models": "1.2.0",
32
- "@embedpdf/utils": "1.2.0"
32
+ "@embedpdf/models": "1.3.0",
33
+ "@embedpdf/utils": "1.3.0"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@types/react": "^18.2.0",
36
37
  "typescript": "^5.0.0",
37
- "@embedpdf/build": "1.0.0",
38
- "@embedpdf/plugin-interaction-manager": "1.2.0",
39
- "@embedpdf/plugin-history": "1.2.0",
40
- "@embedpdf/plugin-selection": "1.2.0"
38
+ "@embedpdf/build": "1.0.1",
39
+ "@embedpdf/plugin-interaction-manager": "1.3.0",
40
+ "@embedpdf/plugin-selection": "1.3.0",
41
+ "@embedpdf/plugin-history": "1.3.0"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "react": ">=16.8.0",
44
45
  "react-dom": ">=16.8.0",
45
46
  "preact": "^10.26.4",
46
47
  "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"
48
+ "@embedpdf/plugin-interaction-manager": "1.3.0",
49
+ "@embedpdf/core": "1.3.0",
50
+ "@embedpdf/plugin-history": "1.3.0",
51
+ "@embedpdf/plugin-selection": "1.3.0"
51
52
  },
52
53
  "files": [
53
54
  "dist",