@embedpdf/plugin-annotation 1.3.15 → 1.4.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.
- package/dist/shared/components/annotation-container.d.ts +31 -0
- package/dist/shared/components/annotation-layer.d.ts +23 -0
- package/dist/shared/components/annotation-paint-layer.d.ts +6 -0
- package/dist/shared/components/annotations/circle.d.ts +29 -0
- package/dist/shared/components/annotations/free-text.d.ts +14 -0
- package/dist/shared/components/annotations/ink.d.ts +25 -0
- package/dist/shared/components/annotations/line.d.ts +33 -0
- package/dist/shared/components/annotations/polygon.d.ts +20 -0
- package/dist/shared/components/annotations/polyline.d.ts +17 -0
- package/dist/shared/components/annotations/square.d.ts +29 -0
- package/dist/shared/components/annotations/stamp.d.ts +12 -0
- package/dist/shared/components/annotations.d.ts +16 -0
- package/dist/shared/components/index.d.ts +1 -0
- package/dist/shared/components/preview-renderer.d.ts +7 -0
- package/dist/shared/components/render-annotation.d.ts +11 -0
- package/dist/shared/components/text-markup/highlight.d.ts +13 -0
- package/dist/shared/components/text-markup/squiggly.d.ts +13 -0
- package/dist/shared/components/text-markup/strikeout.d.ts +13 -0
- package/dist/shared/components/text-markup/underline.d.ts +13 -0
- package/dist/shared/components/text-markup.d.ts +6 -0
- package/dist/shared/components/types.d.ts +51 -0
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/use-annotation.d.ts +15 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/types.d.ts +10 -0
- package/package.json +11 -11
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PdfAnnotationObject } from '@embedpdf/models';
|
|
2
|
+
import { TrackedAnnotation } from '../../index.ts';
|
|
3
|
+
import { JSX, CSSProperties } from '../../react/adapter.ts';
|
|
4
|
+
import { CustomAnnotationRenderer, ResizeHandleUI, SelectionMenuProps, VertexHandleUI } from './types';
|
|
5
|
+
import { VertexConfig } from '../types';
|
|
6
|
+
interface AnnotationContainerProps<T extends PdfAnnotationObject> {
|
|
7
|
+
scale: number;
|
|
8
|
+
pageIndex: number;
|
|
9
|
+
rotation: number;
|
|
10
|
+
pageWidth: number;
|
|
11
|
+
pageHeight: number;
|
|
12
|
+
trackedAnnotation: TrackedAnnotation<T>;
|
|
13
|
+
children: JSX.Element | ((annotation: T) => JSX.Element);
|
|
14
|
+
isSelected: boolean;
|
|
15
|
+
isDraggable: boolean;
|
|
16
|
+
isResizable: boolean;
|
|
17
|
+
lockAspectRatio?: boolean;
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
vertexConfig?: VertexConfig<T>;
|
|
20
|
+
selectionMenu?: (props: SelectionMenuProps) => JSX.Element;
|
|
21
|
+
outlineOffset?: number;
|
|
22
|
+
onDoubleClick?: (event: any) => void;
|
|
23
|
+
onSelect: (event: any) => void;
|
|
24
|
+
zIndex?: number;
|
|
25
|
+
resizeUI?: ResizeHandleUI;
|
|
26
|
+
vertexUI?: VertexHandleUI;
|
|
27
|
+
selectionOutlineColor?: string;
|
|
28
|
+
customAnnotationRenderer?: CustomAnnotationRenderer<T>;
|
|
29
|
+
}
|
|
30
|
+
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;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
|
|
2
|
+
import { SelectionMenu, ResizeHandleUI, VertexHandleUI, CustomAnnotationRenderer } from './types';
|
|
3
|
+
import { PdfAnnotationObject } from '@embedpdf/models';
|
|
4
|
+
type AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
5
|
+
pageIndex: number;
|
|
6
|
+
scale: number;
|
|
7
|
+
pageWidth: number;
|
|
8
|
+
pageHeight: number;
|
|
9
|
+
rotation: number;
|
|
10
|
+
/** Customize selection menu across all annotations on this layer */
|
|
11
|
+
selectionMenu?: SelectionMenu;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
/** Customize resize handles */
|
|
14
|
+
resizeUI?: ResizeHandleUI;
|
|
15
|
+
/** Customize vertex handles */
|
|
16
|
+
vertexUI?: VertexHandleUI;
|
|
17
|
+
/** Customize selection outline color */
|
|
18
|
+
selectionOutlineColor?: string;
|
|
19
|
+
/** Customize annotation renderer */
|
|
20
|
+
customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;
|
|
21
|
+
};
|
|
22
|
+
export declare function AnnotationLayer({ style, pageIndex, scale, selectionMenu, resizeUI, vertexUI, pageWidth, pageHeight, rotation, selectionOutlineColor, customAnnotationRenderer, ...props }: AnnotationLayerProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MouseEvent, TouchEvent } from '../../../react/adapter.ts';
|
|
2
|
+
import { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';
|
|
3
|
+
interface CircleProps {
|
|
4
|
+
/** Whether the annotation is selected */
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
/** Fill colour – defaults to PDFium’s black if omitted */
|
|
7
|
+
color?: string;
|
|
8
|
+
/** Stroke colour – defaults to same as fill when omitted */
|
|
9
|
+
strokeColor?: string;
|
|
10
|
+
/** 0 – 1 */
|
|
11
|
+
opacity?: number;
|
|
12
|
+
/** Stroke width in PDF units */
|
|
13
|
+
strokeWidth: number;
|
|
14
|
+
/** Stroke type – defaults to solid when omitted */
|
|
15
|
+
strokeStyle?: PdfAnnotationBorderStyle;
|
|
16
|
+
/** Stroke dash array – defaults to undefined when omitted */
|
|
17
|
+
strokeDashArray?: number[];
|
|
18
|
+
/** Bounding box of the annotation */
|
|
19
|
+
rect: Rect;
|
|
20
|
+
/** Current page zoom factor */
|
|
21
|
+
scale: number;
|
|
22
|
+
/** Click handler (used for selection) */
|
|
23
|
+
onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;
|
|
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, isSelected, }: CircleProps): JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MouseEvent, TouchEvent } from '../../../react/adapter.ts';
|
|
2
|
+
import { PdfFreeTextAnnoObject } from '@embedpdf/models';
|
|
3
|
+
import { TrackedAnnotation } from '../../../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> | TouchEvent<HTMLDivElement>) => void;
|
|
11
|
+
onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function FreeText({ isSelected, isEditing, annotation, pageIndex, scale, onClick, }: FreeTextProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MouseEvent, TouchEvent } from '../../../react/adapter.ts';
|
|
2
|
+
import { PdfInkListObject, Rect } from '@embedpdf/models';
|
|
3
|
+
interface InkProps {
|
|
4
|
+
/** Whether the annotation is selected */
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
/** Stroke colour (falls back to PDFium default black) */
|
|
7
|
+
color?: string;
|
|
8
|
+
/** 0 – 1 */
|
|
9
|
+
opacity?: number;
|
|
10
|
+
/** Line width in PDF units */
|
|
11
|
+
strokeWidth: number;
|
|
12
|
+
/** Array of strokes — exactly as in your JSON */
|
|
13
|
+
inkList: PdfInkListObject[];
|
|
14
|
+
/** Bounding box of the whole annotation */
|
|
15
|
+
rect: Rect;
|
|
16
|
+
/** Page zoom factor */
|
|
17
|
+
scale: number;
|
|
18
|
+
/** Callback for when the annotation is clicked */
|
|
19
|
+
onClick?: (e: MouseEvent<SVGPathElement> | TouchEvent<SVGPathElement>) => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Renders a PDF Ink annotation (free-hand drawing) as SVG.
|
|
23
|
+
*/
|
|
24
|
+
export declare function Ink({ isSelected, color, opacity, strokeWidth, inkList, rect, scale, onClick, }: InkProps): JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MouseEvent, TouchEvent } 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> | TouchEvent<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,20 @@
|
|
|
1
|
+
import { MouseEvent, TouchEvent } 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> | TouchEvent<SVGElement>) => void;
|
|
15
|
+
currentVertex?: Position;
|
|
16
|
+
handleSize?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function Polygon({ rect, vertices, color, strokeColor, opacity, strokeWidth, strokeStyle, strokeDashArray, scale, isSelected, onClick, currentVertex, // A preview-only prop
|
|
19
|
+
handleSize, }: PolygonProps): JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MouseEvent, TouchEvent } 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> | TouchEvent<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,29 @@
|
|
|
1
|
+
import { MouseEvent, TouchEvent } from '../../../react/adapter.ts';
|
|
2
|
+
import { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';
|
|
3
|
+
interface SquareProps {
|
|
4
|
+
/** Whether the annotation is selected */
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
/** Fill colour – defaults to PDFium’s black if omitted */
|
|
7
|
+
color?: string;
|
|
8
|
+
/** Stroke colour – defaults to same as fill when omitted */
|
|
9
|
+
strokeColor?: string;
|
|
10
|
+
/** 0 – 1 */
|
|
11
|
+
opacity?: number;
|
|
12
|
+
/** Stroke width in PDF units */
|
|
13
|
+
strokeWidth: number;
|
|
14
|
+
/** Stroke type – defaults to solid when omitted */
|
|
15
|
+
strokeStyle?: PdfAnnotationBorderStyle;
|
|
16
|
+
/** Stroke dash array – defaults to undefined when omitted */
|
|
17
|
+
strokeDashArray?: number[];
|
|
18
|
+
/** Bounding box of the annotation (PDF units) */
|
|
19
|
+
rect: Rect;
|
|
20
|
+
/** Current page zoom factor */
|
|
21
|
+
scale: number;
|
|
22
|
+
/** Click handler (used for selection) */
|
|
23
|
+
onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Renders a PDF Square annotation (rectangle) as SVG.
|
|
27
|
+
*/
|
|
28
|
+
export declare function Square({ isSelected, color, strokeColor, opacity, strokeWidth, strokeStyle, strokeDashArray, rect, scale, onClick, }: SquareProps): JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MouseEvent, TouchEvent } from '../../../react/adapter.ts';
|
|
2
|
+
import { PdfStampAnnoObject } from '@embedpdf/models';
|
|
3
|
+
import { TrackedAnnotation } from '../../../index.ts';
|
|
4
|
+
interface StampProps {
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
annotation: TrackedAnnotation<PdfStampAnnoObject>;
|
|
7
|
+
pageIndex: number;
|
|
8
|
+
scale: number;
|
|
9
|
+
onClick: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function Stamp({ isSelected, annotation, pageIndex, scale, onClick }: StampProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PdfAnnotationObject } from '@embedpdf/models';
|
|
2
|
+
import { CustomAnnotationRenderer, ResizeHandleUI, SelectionMenu, VertexHandleUI } from './types';
|
|
3
|
+
interface AnnotationsProps {
|
|
4
|
+
pageIndex: number;
|
|
5
|
+
scale: number;
|
|
6
|
+
rotation: number;
|
|
7
|
+
pageWidth: number;
|
|
8
|
+
pageHeight: number;
|
|
9
|
+
selectionMenu?: SelectionMenu;
|
|
10
|
+
resizeUI?: ResizeHandleUI;
|
|
11
|
+
vertexUI?: VertexHandleUI;
|
|
12
|
+
selectionOutlineColor?: string;
|
|
13
|
+
customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;
|
|
14
|
+
}
|
|
15
|
+
export declare function Annotations(annotationsProps: AnnotationsProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './annotation-layer';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HTMLAttributes, CSSProperties } from '../../react/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, style, ...props }: RenderAnnotationProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CSSProperties, MouseEvent, TouchEvent } from '../../../react/adapter.ts';
|
|
2
|
+
import { Rect } from '@embedpdf/models';
|
|
3
|
+
type HighlightProps = {
|
|
4
|
+
color?: string;
|
|
5
|
+
opacity?: number;
|
|
6
|
+
segmentRects: Rect[];
|
|
7
|
+
rect?: Rect;
|
|
8
|
+
scale: number;
|
|
9
|
+
onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
};
|
|
12
|
+
export declare function Highlight({ color, opacity, segmentRects, rect, scale, onClick, style, }: HighlightProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CSSProperties, MouseEvent, TouchEvent } from '../../../react/adapter.ts';
|
|
2
|
+
import { Rect } from '@embedpdf/models';
|
|
3
|
+
type SquigglyProps = {
|
|
4
|
+
color?: string;
|
|
5
|
+
opacity?: number;
|
|
6
|
+
segmentRects: Rect[];
|
|
7
|
+
rect?: Rect;
|
|
8
|
+
scale: number;
|
|
9
|
+
onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
};
|
|
12
|
+
export declare function Squiggly({ color, opacity, segmentRects, rect, scale, onClick, style, }: SquigglyProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CSSProperties, MouseEvent, TouchEvent } from '../../../react/adapter.ts';
|
|
2
|
+
import { Rect } from '@embedpdf/models';
|
|
3
|
+
type StrikeoutProps = {
|
|
4
|
+
color?: string;
|
|
5
|
+
opacity?: number;
|
|
6
|
+
segmentRects: Rect[];
|
|
7
|
+
rect?: Rect;
|
|
8
|
+
scale: number;
|
|
9
|
+
onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
};
|
|
12
|
+
export declare function Strikeout({ color, opacity, segmentRects, rect, scale, onClick, style, }: StrikeoutProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CSSProperties, MouseEvent, TouchEvent } from '../../../react/adapter.ts';
|
|
2
|
+
import { Rect } from '@embedpdf/models';
|
|
3
|
+
type UnderlineProps = {
|
|
4
|
+
color?: string;
|
|
5
|
+
opacity?: number;
|
|
6
|
+
segmentRects: Rect[];
|
|
7
|
+
rect?: Rect;
|
|
8
|
+
scale: number;
|
|
9
|
+
onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
};
|
|
12
|
+
export declare function Underline({ color, opacity, segmentRects, rect, scale, onClick, style, }: UnderlineProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PdfAnnotationObject, Rect } from '@embedpdf/models';
|
|
2
|
+
import { TrackedAnnotation } from '../../index.ts';
|
|
3
|
+
import { HandleElementProps, MenuWrapperProps } from '../../react/utils.ts';
|
|
4
|
+
import { JSX } from '../../react/adapter.ts';
|
|
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;
|
|
13
|
+
export type HandleProps = HandleElementProps & {
|
|
14
|
+
backgroundColor?: string;
|
|
15
|
+
};
|
|
16
|
+
/** UI customization for resize handles */
|
|
17
|
+
export interface ResizeHandleUI {
|
|
18
|
+
/** Handle size in CSS px (default: 12) */
|
|
19
|
+
size?: number;
|
|
20
|
+
/** Default background color for the handle (used by default renderer) */
|
|
21
|
+
color?: string;
|
|
22
|
+
/** Custom renderer for each handle (overrides default) */
|
|
23
|
+
component?: (p: HandleProps) => JSX.Element;
|
|
24
|
+
}
|
|
25
|
+
/** UI customization for vertex handles */
|
|
26
|
+
export interface VertexHandleUI {
|
|
27
|
+
/** Handle size in CSS px (default: 12) */
|
|
28
|
+
size?: number;
|
|
29
|
+
/** Default background color for the handle (used by default renderer) */
|
|
30
|
+
color?: string;
|
|
31
|
+
/** Custom renderer for each vertex (overrides default) */
|
|
32
|
+
component?: (p: HandleProps) => JSX.Element;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Props for the custom annotation renderer
|
|
36
|
+
*/
|
|
37
|
+
export interface CustomAnnotationRendererProps<T extends PdfAnnotationObject> {
|
|
38
|
+
annotation: T;
|
|
39
|
+
children: JSX.Element;
|
|
40
|
+
isSelected: boolean;
|
|
41
|
+
scale: number;
|
|
42
|
+
rotation: number;
|
|
43
|
+
pageWidth: number;
|
|
44
|
+
pageHeight: number;
|
|
45
|
+
pageIndex: number;
|
|
46
|
+
onSelect: (event: any) => void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Custom renderer for an annotation
|
|
50
|
+
*/
|
|
51
|
+
export type CustomAnnotationRenderer<T extends PdfAnnotationObject> = (props: CustomAnnotationRendererProps<T>) => JSX.Element | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-annotation';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AnnotationPlugin, AnnotationState } from '../../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('../../index.ts').AnnotationCapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export declare const useAnnotation: () => {
|
|
13
|
+
state: AnnotationState;
|
|
14
|
+
provides: Readonly<import('../../index.ts').AnnotationCapability> | null;
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PdfAnnotationObject, Position } from '@embedpdf/models';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for vertex configuration - handles annotation-specific vertex logic
|
|
4
|
+
*/
|
|
5
|
+
export interface VertexConfig<T extends PdfAnnotationObject> {
|
|
6
|
+
/** Extract vertices from annotation - handles different vertex formats */
|
|
7
|
+
extractVertices: (annotation: T) => Position[];
|
|
8
|
+
/** Transform annotation when vertices change */
|
|
9
|
+
transformAnnotation: (annotation: T, vertices: Position[]) => Partial<T>;
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-annotation",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -29,26 +29,26 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@embedpdf/models": "1.
|
|
33
|
-
"@embedpdf/utils": "1.
|
|
32
|
+
"@embedpdf/models": "1.4.0",
|
|
33
|
+
"@embedpdf/utils": "1.4.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/react": "^18.2.0",
|
|
37
37
|
"typescript": "^5.0.0",
|
|
38
|
-
"@embedpdf/
|
|
39
|
-
"@embedpdf/
|
|
40
|
-
"@embedpdf/plugin-selection": "1.
|
|
41
|
-
"@embedpdf/plugin-history": "1.
|
|
38
|
+
"@embedpdf/plugin-interaction-manager": "1.4.0",
|
|
39
|
+
"@embedpdf/build": "1.1.0",
|
|
40
|
+
"@embedpdf/plugin-selection": "1.4.0",
|
|
41
|
+
"@embedpdf/plugin-history": "1.4.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=16.8.0",
|
|
45
45
|
"react-dom": ">=16.8.0",
|
|
46
46
|
"preact": "^10.26.4",
|
|
47
47
|
"vue": ">=3.2.0",
|
|
48
|
-
"@embedpdf/
|
|
49
|
-
"@embedpdf/plugin-
|
|
50
|
-
"@embedpdf/plugin-
|
|
51
|
-
"@embedpdf/
|
|
48
|
+
"@embedpdf/core": "1.4.0",
|
|
49
|
+
"@embedpdf/plugin-interaction-manager": "1.4.0",
|
|
50
|
+
"@embedpdf/plugin-selection": "1.4.0",
|
|
51
|
+
"@embedpdf/plugin-history": "1.4.0"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|
|
54
54
|
"dist",
|