@embedpdf/plugin-annotation 2.1.2 → 2.2.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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -2
- package/dist/index.js.map +1 -1
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +13 -6
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +13 -6
- package/dist/react/index.js.map +1 -1
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +10 -6
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +19 -6
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -10
package/dist/react/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/react/adapter.ts","../../src/shared/hooks/use-annotation.ts","../../src/shared/components/annotation-container.tsx","../../src/shared/components/text-markup/highlight.tsx","../../src/shared/components/text-markup/underline.tsx","../../src/shared/components/text-markup/strikeout.tsx","../../src/shared/components/text-markup/squiggly.tsx","../../src/shared/components/annotations/ink.tsx","../../src/shared/components/annotations/square.tsx","../../src/shared/components/annotations/circle.tsx","../../src/shared/components/annotations/line.tsx","../../src/shared/components/annotations/polyline.tsx","../../src/shared/components/annotations/polygon.tsx","../../src/shared/components/annotations/free-text.tsx","../../src/shared/components/render-annotation.tsx","../../src/shared/components/annotations/stamp.tsx","../../src/shared/components/annotations.tsx","../../src/shared/components/text-markup.tsx","../../src/shared/components/preview-renderer.tsx","../../src/shared/components/annotation-paint-layer.tsx","../../src/shared/components/annotation-layer.tsx"],"sourcesContent":["export {\n Fragment,\n useEffect,\n useRef,\n useState,\n useCallback,\n useMemo,\n useLayoutEffect,\n JSX,\n ChangeEvent,\n} from 'react';\nexport type {\n ReactNode,\n HTMLAttributes,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n TouchEvent,\n} from 'react';\n\nexport const suppressContentEditableWarningProps = {\n suppressContentEditableWarning: true,\n};\n","import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport {\n AnnotationPlugin,\n AnnotationDocumentState,\n initialDocumentState,\n} from '@embedpdf/plugin-annotation';\nimport { useState, useEffect } from '@framework';\n\nexport const useAnnotationPlugin = () => usePlugin<AnnotationPlugin>(AnnotationPlugin.id);\nexport const useAnnotationCapability = () => useCapability<AnnotationPlugin>(AnnotationPlugin.id);\n\n/**\n * Hook for annotation state for a specific document\n * @param documentId Document ID\n */\nexport const useAnnotation = (documentId: string) => {\n const { provides } = useAnnotationCapability();\n const [state, setState] = useState<AnnotationDocumentState>(\n provides?.forDocument(documentId)?.getState() ?? initialDocumentState(),\n );\n\n useEffect(() => {\n if (!provides) return;\n\n const scope = provides.forDocument(documentId);\n\n // Get initial state\n setState(scope.getState());\n\n // Subscribe to state changes\n return scope.onStateChange((newState) => {\n setState(newState);\n });\n }, [provides, documentId]);\n\n return {\n state,\n provides: provides?.forDocument(documentId) ?? null,\n };\n};\n","import { PdfAnnotationObject } from '@embedpdf/models';\nimport {\n CounterRotate,\n useDoublePressProps,\n useInteractionHandles,\n} from '@embedpdf/utils/@framework';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\nimport { useState, JSX, CSSProperties, useRef, useEffect, useMemo } from '@framework';\n\nimport { useAnnotationCapability } from '../hooks';\nimport {\n CustomAnnotationRenderer,\n ResizeHandleUI,\n AnnotationSelectionMenuRenderFn,\n VertexHandleUI,\n} from './types';\nimport { VertexConfig } from '../types';\n\ninterface AnnotationContainerProps<T extends PdfAnnotationObject> {\n scale: number;\n documentId: string;\n pageIndex: number;\n rotation: number;\n pageWidth: number;\n pageHeight: number;\n trackedAnnotation: TrackedAnnotation<T>;\n children: JSX.Element | ((annotation: T) => JSX.Element);\n isSelected: boolean;\n isDraggable: boolean;\n isResizable: boolean;\n lockAspectRatio?: boolean;\n style?: CSSProperties;\n vertexConfig?: VertexConfig<T>;\n selectionMenu?: AnnotationSelectionMenuRenderFn;\n outlineOffset?: number;\n onDoubleClick?: (event: any) => void; // You'll need to import proper MouseEvent type\n onSelect: (event: any) => void;\n zIndex?: number;\n resizeUI?: ResizeHandleUI;\n vertexUI?: VertexHandleUI;\n selectionOutlineColor?: string;\n customAnnotationRenderer?: CustomAnnotationRenderer<T>;\n}\n\n// Simplified AnnotationContainer\nexport function AnnotationContainer<T extends PdfAnnotationObject>({\n scale,\n documentId,\n pageIndex,\n rotation,\n pageWidth,\n pageHeight,\n trackedAnnotation,\n children,\n isSelected,\n isDraggable,\n isResizable,\n lockAspectRatio = false,\n style = {},\n vertexConfig,\n selectionMenu,\n outlineOffset = 1,\n onDoubleClick,\n onSelect,\n zIndex = 1,\n resizeUI,\n vertexUI,\n selectionOutlineColor = '#007ACC',\n customAnnotationRenderer,\n ...props\n}: AnnotationContainerProps<T>): JSX.Element {\n const [preview, setPreview] = useState<T>(trackedAnnotation.object);\n const { provides: annotationCapability } = useAnnotationCapability();\n const gestureBaseRef = useRef<T | null>(null);\n\n // Get scoped API for this document (memoized to prevent infinite loops)\n const annotationProvides = useMemo(\n () => (annotationCapability ? annotationCapability.forDocument(documentId) : null),\n [annotationCapability, documentId],\n );\n\n const currentObject = preview\n ? { ...trackedAnnotation.object, ...preview }\n : trackedAnnotation.object;\n\n // Defaults retain current behavior\n const HANDLE_COLOR = resizeUI?.color ?? '#007ACC';\n const VERTEX_COLOR = vertexUI?.color ?? '#007ACC';\n const HANDLE_SIZE = resizeUI?.size ?? 12;\n const VERTEX_SIZE = vertexUI?.size ?? 12;\n\n const { dragProps, vertices, resize } = useInteractionHandles({\n controller: {\n element: currentObject.rect,\n vertices: vertexConfig?.extractVertices(currentObject),\n constraints: {\n minWidth: 10,\n minHeight: 10,\n boundingBox: { width: pageWidth, height: pageHeight },\n },\n maintainAspectRatio: lockAspectRatio,\n pageRotation: rotation,\n scale: scale,\n enabled: isSelected,\n onUpdate: (event) => {\n if (!event.transformData?.type) return;\n\n if (event.state === 'start') {\n gestureBaseRef.current = currentObject;\n }\n\n const transformType = event.transformData.type;\n const base = gestureBaseRef.current ?? currentObject;\n\n const changes = event.transformData.changes.vertices\n ? vertexConfig?.transformAnnotation(base, event.transformData.changes.vertices)\n : { rect: event.transformData.changes.rect };\n\n const patched = annotationCapability?.transformAnnotation<T>(base, {\n type: transformType,\n changes: changes as Partial<T>,\n metadata: event.transformData.metadata,\n });\n\n if (patched) {\n setPreview((prev) => ({\n ...prev,\n ...patched,\n }));\n }\n\n if (event.state === 'end' && patched) {\n gestureBaseRef.current = null;\n annotationProvides?.updateAnnotation(pageIndex, trackedAnnotation.object.id, patched);\n }\n },\n },\n resizeUI: {\n handleSize: HANDLE_SIZE,\n spacing: outlineOffset,\n offsetMode: 'outside',\n includeSides: lockAspectRatio ? false : true,\n zIndex: zIndex + 1,\n },\n vertexUI: {\n vertexSize: VERTEX_SIZE,\n zIndex: zIndex + 2,\n },\n includeVertices: vertexConfig ? true : false,\n });\n\n const doubleProps = useDoublePressProps(onDoubleClick);\n\n useEffect(() => {\n setPreview(trackedAnnotation.object);\n }, [trackedAnnotation.object]);\n\n return (\n <div data-no-interaction>\n <div\n {...(isDraggable && isSelected ? dragProps : {})}\n {...doubleProps}\n style={{\n position: 'absolute',\n left: currentObject.rect.origin.x * scale,\n top: currentObject.rect.origin.y * scale,\n width: currentObject.rect.size.width * scale,\n height: currentObject.rect.size.height * scale,\n outline: isSelected ? `1px solid ${selectionOutlineColor}` : 'none',\n outlineOffset: isSelected ? `${outlineOffset}px` : '0px',\n pointerEvents: isSelected ? 'auto' : 'none',\n touchAction: 'none',\n cursor: isSelected && isDraggable ? 'move' : 'default',\n zIndex,\n ...style,\n }}\n {...props}\n >\n {(() => {\n const childrenRender =\n typeof children === 'function' ? children(currentObject) : children;\n // Check for custom renderer first\n const customRender = customAnnotationRenderer?.({\n annotation: currentObject,\n children: childrenRender,\n isSelected,\n scale,\n rotation,\n pageWidth,\n pageHeight,\n pageIndex,\n onSelect,\n });\n if (customRender !== null && customRender !== undefined) {\n return customRender;\n }\n\n // Fall back to default children rendering\n return childrenRender;\n })()}\n\n {isSelected &&\n isResizable &&\n resize.map(({ key, ...hProps }) =>\n resizeUI?.component ? (\n resizeUI.component({\n key,\n ...hProps,\n backgroundColor: HANDLE_COLOR,\n })\n ) : (\n <div\n key={key}\n {...hProps}\n style={{ ...hProps.style, backgroundColor: HANDLE_COLOR }}\n />\n ),\n )}\n\n {isSelected &&\n vertices.map(({ key, ...vProps }) =>\n vertexUI?.component ? (\n vertexUI.component({\n key,\n ...vProps,\n backgroundColor: VERTEX_COLOR,\n })\n ) : (\n <div\n key={key}\n {...vProps}\n style={{ ...vProps.style, backgroundColor: VERTEX_COLOR }}\n />\n ),\n )}\n </div>\n {/* CounterRotate remains unchanged */}\n {selectionMenu && (\n <CounterRotate\n rect={{\n origin: {\n x: currentObject.rect.origin.x * scale,\n y: currentObject.rect.origin.y * scale,\n },\n size: {\n width: currentObject.rect.size.width * scale,\n height: currentObject.rect.size.height * scale,\n },\n }}\n rotation={rotation}\n >\n {(props) =>\n selectionMenu({\n ...props,\n context: {\n type: 'annotation',\n annotation: trackedAnnotation,\n pageIndex,\n },\n selected: isSelected,\n placement: {\n suggestTop: false,\n },\n })\n }\n </CounterRotate>\n )}\n </div>\n );\n}\n","import { CSSProperties, MouseEvent, TouchEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype HighlightProps = {\n color?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n};\n\nexport function Highlight({\n color = '#FFFF00',\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n}: HighlightProps) {\n return (\n <>\n {segmentRects.map((b, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n position: 'absolute',\n left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,\n top: (rect ? b.origin.y - rect.origin.y : b.origin.y) * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background: color,\n opacity: opacity,\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : undefined,\n ...style,\n }}\n />\n ))}\n </>\n );\n}\n","import { CSSProperties, MouseEvent, TouchEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype UnderlineProps = {\n color?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n};\n\nexport function Underline({\n color = '#FFFF00',\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n}: UnderlineProps) {\n const thickness = 2 * scale; // 2 CSS px at 100 % zoom\n\n return (\n <>\n {segmentRects.map((r, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n position: 'absolute',\n left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,\n top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : 0,\n ...style,\n }}\n >\n {/* Visual underline */}\n <div\n style={{\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n height: thickness,\n background: color,\n opacity: opacity,\n pointerEvents: 'none',\n }}\n />\n </div>\n ))}\n </>\n );\n}\n","import { CSSProperties, MouseEvent, TouchEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype StrikeoutProps = {\n color?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n};\n\nexport function Strikeout({\n color = '#FFFF00',\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n}: StrikeoutProps) {\n const thickness = 2 * scale;\n\n return (\n <>\n {segmentRects.map((r, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n position: 'absolute',\n left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,\n top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : 0,\n ...style,\n }}\n >\n {/* Visual strikeout line */}\n <div\n style={{\n position: 'absolute',\n left: 0,\n top: '50%',\n width: '100%',\n height: thickness,\n background: color,\n opacity: opacity,\n transform: 'translateY(-50%)',\n pointerEvents: 'none',\n }}\n />\n </div>\n ))}\n </>\n );\n}\n","import { CSSProperties, MouseEvent, TouchEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype SquigglyProps = {\n color?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n};\n\nexport function Squiggly({\n color = '#FFFF00',\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n}: SquigglyProps) {\n const amplitude = 2 * scale; // wave height\n const period = 6 * scale; // wave length\n\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${period}\" height=\"${amplitude * 2}\" viewBox=\"0 0 ${period} ${amplitude * 2}\">\n <path d=\"M0 ${amplitude} Q ${period / 4} 0 ${period / 2} ${amplitude} T ${period} ${amplitude}\"\n fill=\"none\" stroke=\"${color}\" stroke-width=\"${amplitude}\" stroke-linecap=\"round\"/>\n </svg>`;\n\n // Completely escape the SVG markup\n const svgDataUri = `url(\"data:image/svg+xml;utf8,${encodeURIComponent(svg)}\")`;\n\n return (\n <>\n {segmentRects.map((r, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n position: 'absolute',\n left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,\n top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : 0,\n ...style,\n }}\n >\n {/* Visual squiggly line */}\n <div\n style={{\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n height: amplitude * 2,\n backgroundImage: svgDataUri,\n backgroundRepeat: 'repeat-x',\n backgroundSize: `${period}px ${amplitude * 2}px`,\n opacity: opacity,\n pointerEvents: 'none',\n }}\n />\n </div>\n ))}\n </>\n );\n}\n","import { useMemo, MouseEvent, TouchEvent } from '@framework';\nimport { PdfInkListObject, Rect } from '@embedpdf/models';\n\n/* ---------------------------------------------------------------- *\\\n|* Types *|\n\\* ---------------------------------------------------------------- */\n\ninterface InkProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Stroke colour (falls back to PDFium default black) */\n color?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Line width in PDF units */\n strokeWidth: number;\n /** Array of strokes — exactly as in your JSON */\n inkList: PdfInkListObject[];\n /** Bounding box of the whole annotation */\n rect: Rect;\n /** Page zoom factor */\n scale: number;\n /** Callback for when the annotation is clicked */\n onClick?: (e: MouseEvent<SVGPathElement> | TouchEvent<SVGPathElement>) => void;\n}\n\n/**\n * Renders a PDF Ink annotation (free-hand drawing) as SVG.\n */\nexport function Ink({\n isSelected,\n color = '#000000',\n opacity = 1,\n strokeWidth,\n inkList,\n rect,\n scale,\n onClick,\n}: InkProps): JSX.Element {\n /* convert each stroke to an SVG <path d=\"\"> string */\n const paths = useMemo(() => {\n return inkList.map(({ points }) => {\n let d = '';\n points.forEach(({ x, y }, i) => {\n // localise to the annotation’s own bbox so viewBox can stay tidy\n const lx = x - rect.origin.x;\n const ly = y - rect.origin.y;\n d += (i === 0 ? 'M' : 'L') + lx + ' ' + ly + ' ';\n });\n return d.trim();\n });\n }, [inkList, rect]);\n\n /* absolute placement + scaling just like your text-markup components */\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n {paths.map((d, i) => (\n <path\n key={i}\n d={d}\n fill=\"none\"\n opacity={opacity}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visibleStroke',\n stroke: color,\n strokeWidth: strokeWidth,\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n }}\n />\n ))}\n </svg>\n );\n}\n","import { useMemo, MouseEvent, TouchEvent } from '@framework';\nimport { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';\n\n/* ---------------------------------------------------------------- *\\\n|* Types *|\n\\* ---------------------------------------------------------------- */\n\ninterface SquareProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Fill colour – defaults to PDFium’s black if omitted */\n color?: string;\n /** Stroke colour – defaults to same as fill when omitted */\n strokeColor?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Stroke width in PDF units */\n strokeWidth: number;\n /** Stroke type – defaults to solid when omitted */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array – defaults to undefined when omitted */\n strokeDashArray?: number[];\n /** Bounding box of the annotation (PDF units) */\n rect: Rect;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;\n}\n\n/**\n * Renders a PDF Square annotation (rectangle) as SVG.\n */\nexport function Square({\n isSelected,\n color = '#000000',\n strokeColor,\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n rect,\n scale,\n onClick,\n}: SquareProps): JSX.Element {\n /* ------------------------------------------------------------------ */\n /* geometry helpers */\n /* ------------------------------------------------------------------ */\n const { width, height, x, y } = useMemo(() => {\n // Full bounding box *includes* stroke width.\n const outerW = rect.size.width;\n const outerH = rect.size.height;\n\n // Remove the stroke so the visible fill matches the preview.\n const innerW = Math.max(outerW - strokeWidth, 0);\n const innerH = Math.max(outerH - strokeWidth, 0);\n\n return {\n width: innerW,\n height: innerH,\n x: strokeWidth / 2,\n y: strokeWidth / 2,\n };\n }, [rect, strokeWidth]);\n\n const svgWidth = (width + strokeWidth) * scale;\n const svgHeight = (height + strokeWidth) * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width: svgWidth,\n height: svgHeight,\n pointerEvents: 'none',\n zIndex: 2,\n }}\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${width + strokeWidth} ${height + strokeWidth}`}\n >\n <rect\n x={x}\n y={y}\n width={width}\n height={height}\n fill={color}\n opacity={opacity}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n stroke: strokeColor ?? color,\n strokeWidth,\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n </svg>\n );\n}\n","import { useMemo, MouseEvent, TouchEvent } from '@framework';\nimport { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';\n\n/* ---------------------------------------------------------------- *\\\n|* Types *|\n\\* ---------------------------------------------------------------- */\n\ninterface CircleProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Fill colour – defaults to PDFium’s black if omitted */\n color?: string;\n /** Stroke colour – defaults to same as fill when omitted */\n strokeColor?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Stroke width in PDF units */\n strokeWidth: number;\n /** Stroke type – defaults to solid when omitted */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array – defaults to undefined when omitted */\n strokeDashArray?: number[];\n /** Bounding box of the annotation */\n rect: Rect;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;\n}\n\n/**\n * Renders a PDF Circle annotation (ellipse) as SVG.\n */\nexport function Circle({\n color = '#000000',\n strokeColor,\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n rect,\n scale,\n onClick,\n isSelected,\n}: CircleProps): JSX.Element {\n /* ------------------------------------------------------------------ */\n /* geometry helpers */\n /* ------------------------------------------------------------------ */\n const { width, height, cx, cy, rx, ry } = useMemo(() => {\n // Full bounding box *includes* stroke width.\n const outerW = rect.size.width;\n const outerH = rect.size.height;\n\n // Remove the stroke so the visible fill matches the preview.\n const innerW = Math.max(outerW - strokeWidth, 0);\n const innerH = Math.max(outerH - strokeWidth, 0);\n\n return {\n width: outerW,\n height: outerH,\n // Centre of the fill sits strokeWidth/2 in from the edges\n cx: strokeWidth / 2 + innerW / 2,\n cy: strokeWidth / 2 + innerH / 2,\n rx: innerW / 2,\n ry: innerH / 2,\n };\n }, [rect, strokeWidth]);\n\n const svgWidth = width * scale;\n const svgHeight = height * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width: svgWidth,\n height: svgHeight,\n pointerEvents: 'none',\n zIndex: 2,\n }}\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${width} ${height}`}\n >\n <ellipse\n cx={cx}\n cy={cy}\n rx={rx}\n ry={ry}\n fill={color}\n opacity={opacity}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n stroke: strokeColor ?? color,\n strokeWidth,\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n </svg>\n );\n}\n","import { useMemo, MouseEvent, TouchEvent } from '@framework';\nimport { Rect, LinePoints, LineEndings, PdfAnnotationBorderStyle } from '@embedpdf/models';\nimport { patching } from '@embedpdf/plugin-annotation';\n\n/* ---------------------------------------------------------------- *\\\n|* Types *|\n\\* ---------------------------------------------------------------- */\n\ninterface LineProps {\n /** interior colour */\n color?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Stroke width in PDF units */\n strokeWidth: number;\n /** Stroke colour (falls back to PDFium default black) */\n strokeColor?: string;\n /** Stroke style */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array */\n strokeDashArray?: number[];\n /** Bounding box of the annotation */\n rect: Rect;\n /** Line start / end points (page units) */\n linePoints: LinePoints;\n /** Line endings (eg. OpenArrow / Butt) */\n lineEndings?: LineEndings;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;\n /** Whether the annotation is selected */\n isSelected: boolean;\n}\n\n/**\n * Renders a PDF Line annotation as SVG (with arrow/butt endings).\n */\nexport function Line({\n color = 'transparent',\n opacity = 1,\n strokeWidth,\n strokeColor = '#000000',\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n rect,\n linePoints,\n lineEndings,\n scale,\n onClick,\n isSelected,\n}: LineProps): JSX.Element {\n /* -------------------------------------------------------------- */\n /* Localise the line within its own bounding box */\n /* -------------------------------------------------------------- */\n const { x1, y1, x2, y2 } = useMemo(() => {\n return {\n x1: linePoints.start.x - rect.origin.x,\n y1: linePoints.start.y - rect.origin.y,\n x2: linePoints.end.x - rect.origin.x,\n y2: linePoints.end.y - rect.origin.y,\n };\n }, [linePoints, rect]);\n\n /* -------------------------------------------------------------- */\n /* Arrow-head path data via shared factory */\n /* -------------------------------------------------------------- */\n const endings = useMemo(() => {\n const angle = Math.atan2(y2 - y1, x2 - x1);\n return {\n start: patching.createEnding(lineEndings?.start, strokeWidth, angle + Math.PI, x1, y1),\n end: patching.createEnding(lineEndings?.end, strokeWidth, angle, x2, y2),\n };\n }, [lineEndings, strokeWidth, x1, y1, x2, y2]);\n\n /* -------------------------------------------------------------- */\n /* Absolute placement + scaling (same pattern as other shapes) */\n /* -------------------------------------------------------------- */\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n {/* Main line */}\n <line\n x1={x1}\n y1={y1}\n x2={x2}\n y2={y2}\n opacity={opacity}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visibleStroke',\n stroke: strokeColor,\n strokeWidth,\n strokeLinecap: 'butt',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n\n {/* Optional arrowheads / butt caps */}\n {endings.start && (\n <path\n d={endings.start.d}\n transform={endings.start.transform}\n onPointerDown={onClick}\n onTouchStart={onClick}\n stroke={strokeColor}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n strokeWidth,\n strokeLinecap: 'butt',\n pointerEvents: isSelected ? 'none' : endings.start.filled ? 'visible' : 'visibleStroke',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n fill={endings.start.filled ? color : 'none'}\n />\n )}\n {endings.end && (\n <path\n d={endings.end.d}\n transform={endings.end.transform}\n stroke={strokeColor}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n strokeWidth,\n strokeLinecap: 'butt',\n pointerEvents: isSelected ? 'none' : endings.end.filled ? 'visible' : 'visibleStroke',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n fill={endings.end.filled ? color : 'none'}\n />\n )}\n </svg>\n );\n}\n","import { MouseEvent, TouchEvent, useMemo } from '@framework';\nimport { Rect, Position, LineEndings } from '@embedpdf/models';\nimport { patching } from '@embedpdf/plugin-annotation';\n\ninterface PolylineProps {\n rect: Rect;\n vertices: Position[];\n color?: string;\n strokeColor?: string;\n opacity?: number;\n strokeWidth: number;\n scale: number;\n isSelected: boolean;\n onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;\n /** Optional start & end endings */\n lineEndings?: LineEndings;\n}\n\nexport function Polyline({\n rect,\n vertices,\n color = 'transparent',\n strokeColor = '#000000',\n opacity = 1,\n strokeWidth,\n scale,\n isSelected,\n onClick,\n lineEndings,\n}: PolylineProps): JSX.Element {\n // Localise vertices to annotation rect\n const localPts = useMemo(\n () => vertices.map(({ x, y }) => ({ x: x - rect.origin.x, y: y - rect.origin.y })),\n [vertices, rect],\n );\n\n // Build path data \"M x0 y0 L x1 y1 ...\"\n const pathData = useMemo(() => {\n if (!localPts.length) return '';\n const [first, ...rest] = localPts;\n return (\n `M ${first.x} ${first.y} ` +\n rest\n .map((p) => `L ${p.x} ${p.y} `)\n .join('')\n .trim()\n );\n }, [localPts]);\n\n // Compute endings (angles from first→second, last-1→last)\n const endings = useMemo(() => {\n if (localPts.length < 2) return { start: null, end: null };\n const toAngle = (a: Position, b: Position) => Math.atan2(b.y - a.y, b.x - a.x);\n\n // Calculate angles in the direction of the line segments\n const startRad = toAngle(localPts[0], localPts[1]); // direction FROM first TO second\n const endRad = toAngle(localPts[localPts.length - 2], localPts[localPts.length - 1]); // direction FROM second-to-last TO last\n\n const start = patching.createEnding(\n lineEndings?.start,\n strokeWidth,\n startRad + Math.PI, // tip points outward from line start\n localPts[0].x,\n localPts[0].y,\n );\n const end = patching.createEnding(\n lineEndings?.end,\n strokeWidth,\n endRad, // tip points in line direction\n localPts[localPts.length - 1].x,\n localPts[localPts.length - 1].y,\n );\n return { start, end };\n }, [localPts, lineEndings, strokeWidth]);\n\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n <path\n d={pathData}\n onPointerDown={onClick}\n onTouchStart={onClick}\n opacity={opacity}\n style={{\n fill: 'none',\n stroke: strokeColor ?? color,\n strokeWidth,\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visibleStroke',\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter',\n }}\n />\n {endings.start && (\n <path\n d={endings.start.d}\n transform={endings.start.transform}\n stroke={strokeColor}\n fill={endings.start.filled ? color : 'none'}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n strokeWidth,\n pointerEvents: isSelected ? 'none' : endings.start.filled ? 'visible' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n )}\n {endings.end && (\n <path\n d={endings.end.d}\n transform={endings.end.transform}\n stroke={strokeColor}\n fill={endings.end.filled ? color : 'none'}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n strokeWidth,\n pointerEvents: isSelected ? 'none' : endings.end.filled ? 'visible' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n )}\n </svg>\n );\n}\n","import { useMemo, MouseEvent, TouchEvent } from '@framework';\nimport { Rect, Position, PdfAnnotationBorderStyle } from '@embedpdf/models';\n\ninterface PolygonProps {\n rect: Rect;\n vertices: Position[];\n color?: string;\n strokeColor?: string;\n opacity?: number;\n strokeWidth: number;\n strokeStyle?: PdfAnnotationBorderStyle;\n strokeDashArray?: number[];\n scale: number;\n isSelected: boolean;\n onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;\n\n // New optional props for preview rendering\n currentVertex?: Position;\n handleSize?: number;\n}\n\nexport function Polygon({\n rect,\n vertices,\n color = 'transparent',\n strokeColor = '#000000',\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n scale,\n isSelected,\n onClick,\n currentVertex, // A preview-only prop\n handleSize = 14, // in CSS pixels\n}: PolygonProps): JSX.Element {\n const allPoints = currentVertex ? [...vertices, currentVertex] : vertices;\n\n const localPts = useMemo(\n () => allPoints.map(({ x, y }) => ({ x: x - rect.origin.x, y: y - rect.origin.y })),\n [allPoints, rect],\n );\n\n const pathData = useMemo(() => {\n if (!localPts.length) return '';\n const [first, ...rest] = localPts;\n const isPreview = !!currentVertex;\n // Don't close the path with 'Z' if it's a preview\n return (\n `M ${first.x} ${first.y} ` +\n rest.map((p) => `L ${p.x} ${p.y}`).join(' ') +\n (isPreview ? '' : ' Z')\n ).trim();\n }, [localPts, currentVertex]);\n\n const isPreviewing = currentVertex && vertices.length > 0;\n\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n <path\n d={pathData}\n onPointerDown={onClick}\n onTouchStart={onClick}\n opacity={opacity}\n style={{\n fill: currentVertex ? 'none' : color, // No fill during preview\n stroke: strokeColor ?? color,\n strokeWidth,\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n {/* --- Preview-only elements --- */}\n {isPreviewing && vertices.length > 1 && (\n <path\n d={`M ${localPts[localPts.length - 1].x} ${localPts[localPts.length - 1].y} L ${localPts[0].x} ${localPts[0].y}`}\n fill=\"none\"\n style={{ stroke: strokeColor, strokeWidth, strokeDasharray: '4,4', opacity: 0.7 }}\n />\n )}\n {isPreviewing && vertices.length >= 2 && (\n <rect\n x={localPts[0].x - handleSize / scale / 2}\n y={localPts[0].y - handleSize / scale / 2}\n width={handleSize / scale}\n height={handleSize / scale}\n fill={strokeColor}\n opacity={0.4}\n stroke={strokeColor}\n strokeWidth={strokeWidth / 2}\n />\n )}\n </svg>\n );\n}\n","import {\n MouseEvent,\n TouchEvent,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n suppressContentEditableWarningProps,\n} from '@framework';\nimport {\n PdfFreeTextAnnoObject,\n PdfVerticalAlignment,\n standardFontCss,\n textAlignmentToCss,\n} from '@embedpdf/models';\nimport { useAnnotationCapability } from '../..';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\n\ninterface FreeTextProps {\n isSelected: boolean;\n isEditing: boolean;\n annotation: TrackedAnnotation<PdfFreeTextAnnoObject>;\n pageIndex: number;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;\n onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;\n}\n\nexport function FreeText({\n isSelected,\n isEditing,\n annotation,\n pageIndex,\n scale,\n onClick,\n}: FreeTextProps) {\n const editorRef = useRef<HTMLSpanElement>(null);\n const { provides: annotationProvides } = useAnnotationCapability();\n const [isIOS, setIsIOS] = useState(false);\n\n useEffect(() => {\n if (isEditing && editorRef.current) {\n const editor = editorRef.current;\n editor.focus();\n\n const selection = window.getSelection();\n if (selection) {\n const range = document.createRange();\n range.selectNodeContents(editor);\n range.collapse(false);\n selection.removeAllRanges();\n selection.addRange(range);\n }\n }\n }, [isEditing]);\n\n useLayoutEffect(() => {\n try {\n const nav = navigator as any;\n const ios =\n /iPad|iPhone|iPod/.test(navigator.userAgent) ||\n (navigator.platform === 'MacIntel' && nav?.maxTouchPoints > 1);\n setIsIOS(ios);\n } catch {\n setIsIOS(false);\n }\n }, []);\n\n const handleBlur = () => {\n if (!annotationProvides) return;\n if (!editorRef.current) return;\n annotationProvides.updateAnnotation(pageIndex, annotation.object.id, {\n contents: editorRef.current.innerText,\n });\n };\n\n // iOS zoom prevention: keep focused font-size >= 16px, visually scale down if needed.\n const computedFontPx = annotation.object.fontSize * scale;\n const MIN_IOS_FOCUS_FONT_PX = 16;\n const needsComp =\n isIOS && isEditing && computedFontPx > 0 && computedFontPx < MIN_IOS_FOCUS_FONT_PX;\n const adjustedFontPx = needsComp ? MIN_IOS_FOCUS_FONT_PX : computedFontPx;\n const scaleComp = needsComp ? computedFontPx / MIN_IOS_FOCUS_FONT_PX : 1;\n const invScalePercent = needsComp ? 100 / scaleComp : 100;\n\n return (\n <div\n style={{\n position: 'absolute',\n width: annotation.object.rect.size.width * scale,\n height: annotation.object.rect.size.height * scale,\n cursor: isSelected && !isEditing ? 'move' : 'default',\n pointerEvents: isSelected && !isEditing ? 'none' : 'auto',\n zIndex: 2,\n }}\n onPointerDown={onClick}\n onTouchStart={onClick}\n >\n <span\n ref={editorRef}\n onBlur={handleBlur}\n tabIndex={0}\n style={{\n color: annotation.object.fontColor,\n fontSize: adjustedFontPx,\n fontFamily: standardFontCss(annotation.object.fontFamily),\n textAlign: textAlignmentToCss(annotation.object.textAlign),\n flexDirection: 'column',\n justifyContent:\n annotation.object.verticalAlign === PdfVerticalAlignment.Top\n ? 'flex-start'\n : annotation.object.verticalAlign === PdfVerticalAlignment.Middle\n ? 'center'\n : 'flex-end',\n display: 'flex',\n backgroundColor: annotation.object.backgroundColor,\n opacity: annotation.object.opacity,\n width: needsComp ? `${invScalePercent}%` : '100%',\n height: needsComp ? `${invScalePercent}%` : '100%',\n lineHeight: '1.18',\n overflow: 'hidden',\n cursor: isEditing ? 'text' : 'pointer',\n outline: 'none',\n transform: needsComp ? `scale(${scaleComp})` : undefined,\n transformOrigin: 'top left',\n }}\n contentEditable={isEditing}\n {...suppressContentEditableWarningProps}\n >\n {annotation.object.contents}\n </span>\n </div>\n );\n}\n","import { Fragment, HTMLAttributes, CSSProperties, useEffect, useRef, useState } from '@framework';\nimport { AppearanceMode, ignore, PdfAnnotationObject, PdfErrorCode } from '@embedpdf/models';\n\nimport { useAnnotationCapability } from '../hooks/use-annotation';\n\ntype RenderAnnotationProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n documentId: string;\n pageIndex: number;\n annotation: PdfAnnotationObject;\n scaleFactor?: number;\n dpr?: number;\n style?: CSSProperties;\n};\n\nexport function RenderAnnotation({\n documentId,\n pageIndex,\n annotation,\n scaleFactor = 1,\n style,\n ...props\n}: RenderAnnotationProps) {\n const { provides: annotationProvides } = useAnnotationCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n const { width, height } = annotation.rect.size;\n\n useEffect(() => {\n if (annotationProvides) {\n const task = annotationProvides.forDocument(documentId).renderAnnotation({\n pageIndex,\n annotation,\n options: {\n scaleFactor,\n dpr: window.devicePixelRatio,\n },\n });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [pageIndex, scaleFactor, annotationProvides, documentId, annotation.id, width, height]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n display: 'block',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n","import { MouseEvent, TouchEvent } from '@framework';\nimport { PdfStampAnnoObject } from '@embedpdf/models';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\nimport { RenderAnnotation } from '../render-annotation';\n\ninterface StampProps {\n isSelected: boolean;\n annotation: TrackedAnnotation<PdfStampAnnoObject>;\n documentId: string;\n pageIndex: number;\n scale: number;\n onClick: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;\n}\n\nexport function Stamp({\n isSelected,\n annotation,\n documentId,\n pageIndex,\n scale,\n onClick,\n}: StampProps) {\n return (\n <div\n style={{\n position: 'absolute',\n width: '100%',\n height: '100%',\n zIndex: 2,\n pointerEvents: isSelected ? 'none' : 'auto',\n cursor: 'pointer',\n }}\n onPointerDown={onClick}\n onTouchStart={onClick}\n >\n <RenderAnnotation\n documentId={documentId}\n pageIndex={pageIndex}\n annotation={{ ...annotation.object, id: annotation.object.id }}\n scaleFactor={scale}\n />\n </div>\n );\n}\n","import { blendModeToCss, PdfAnnotationObject, PdfBlendMode } from '@embedpdf/models';\nimport {\n getAnnotationsByPageIndex,\n getSelectedAnnotationByPageIndex,\n isHighlight,\n isInk,\n isSquiggly,\n isCircle,\n isStrikeout,\n isUnderline,\n TrackedAnnotation,\n isSquare,\n isLine,\n isPolyline,\n isPolygon,\n isFreeText,\n isStamp,\n} from '@embedpdf/plugin-annotation';\nimport { PointerEventHandlers } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/@framework';\nimport { useSelectionCapability } from '@embedpdf/plugin-selection/@framework';\nimport {\n useMemo,\n useState,\n useEffect,\n useCallback,\n MouseEvent,\n Fragment,\n TouchEvent,\n} from '@framework';\n\nimport { useAnnotationCapability } from '../hooks';\nimport { AnnotationContainer } from './annotation-container';\nimport { Highlight } from './text-markup/highlight';\nimport { Underline } from './text-markup/underline';\nimport { Strikeout } from './text-markup/strikeout';\nimport { Squiggly } from './text-markup/squiggly';\nimport { Ink } from './annotations/ink';\nimport { Square } from './annotations/square';\nimport {\n CustomAnnotationRenderer,\n ResizeHandleUI,\n AnnotationSelectionMenuRenderFn,\n VertexHandleUI,\n} from './types';\nimport { Circle } from './annotations/circle';\nimport { Line } from './annotations/line';\nimport { Polyline } from './annotations/polyline';\nimport { Polygon } from './annotations/polygon';\nimport { FreeText } from './annotations/free-text';\nimport { Stamp } from './annotations/stamp';\n\ninterface AnnotationsProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n rotation: number;\n pageWidth: number;\n pageHeight: number;\n selectionMenu?: AnnotationSelectionMenuRenderFn;\n resizeUI?: ResizeHandleUI;\n vertexUI?: VertexHandleUI;\n selectionOutlineColor?: string;\n customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;\n}\n\nexport function Annotations(annotationsProps: AnnotationsProps) {\n const { documentId, pageIndex, scale, selectionMenu } = annotationsProps;\n const { provides: annotationCapability } = useAnnotationCapability();\n const { provides: selectionProvides } = useSelectionCapability();\n const [annotations, setAnnotations] = useState<TrackedAnnotation[]>([]);\n const { register } = usePointerHandlers({ documentId, pageIndex });\n const [selectionState, setSelectionState] = useState<TrackedAnnotation | null>(null);\n const [editingId, setEditingId] = useState<string | null>(null);\n\n // Get scoped API for this document (memoized to prevent infinite loops)\n const annotationProvides = useMemo(\n () => (annotationCapability ? annotationCapability.forDocument(documentId) : null),\n [annotationCapability, documentId],\n );\n\n useEffect(() => {\n if (annotationProvides) {\n // Initialize with current state immediately\n const currentState = annotationProvides.getState();\n setAnnotations(getAnnotationsByPageIndex(currentState, pageIndex));\n setSelectionState(getSelectedAnnotationByPageIndex(currentState, pageIndex));\n\n // Then subscribe to changes\n return annotationProvides.onStateChange((state) => {\n setAnnotations(getAnnotationsByPageIndex(state, pageIndex));\n setSelectionState(getSelectedAnnotationByPageIndex(state, pageIndex));\n });\n }\n }, [annotationProvides, pageIndex]);\n\n const handlers = useMemo(\n (): PointerEventHandlers<MouseEvent> => ({\n onPointerDown: (_, pe) => {\n // Only deselect if clicking directly on the layer (not on an annotation)\n if (pe.target === pe.currentTarget && annotationProvides) {\n annotationProvides.deselectAnnotation();\n setEditingId(null);\n }\n },\n }),\n [annotationProvides],\n );\n\n const handleClick = useCallback(\n (e: MouseEvent | TouchEvent, annotation: TrackedAnnotation) => {\n e.stopPropagation();\n if (annotationProvides && selectionProvides) {\n annotationProvides.selectAnnotation(pageIndex, annotation.object.id);\n selectionProvides.clear();\n if (annotation.object.id !== editingId) {\n setEditingId(null);\n }\n }\n },\n [annotationProvides, selectionProvides, editingId, pageIndex],\n );\n\n useEffect(() => {\n return register(handlers, {\n documentId,\n });\n }, [register, handlers]);\n\n return (\n <>\n {annotations.map((annotation) => {\n const isSelected = selectionState?.object.id === annotation.object.id;\n const isEditing = editingId === annotation.object.id;\n const tool = annotationProvides?.findToolForAnnotation(annotation.object);\n\n if (isInk(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? true}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Ink\n {...obj}\n isSelected={isSelected}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isSquare(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? true}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Square\n {...obj}\n isSelected={isSelected}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isCircle(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? true}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Circle\n {...obj}\n isSelected={isSelected}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isUnderline(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? false}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n zIndex={0}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Underline {...obj} scale={scale} onClick={(e) => handleClick(e, annotation)} />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isStrikeout(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? false}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n zIndex={0}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Strikeout {...obj} scale={scale} onClick={(e) => handleClick(e, annotation)} />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isSquiggly(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? false}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n zIndex={0}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Squiggly {...obj} scale={scale} onClick={(e) => handleClick(e, annotation)} />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isHighlight(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? false}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n zIndex={0}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Multiply),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Highlight {...obj} scale={scale} onClick={(e) => handleClick(e, annotation)} />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isLine(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n vertexConfig={{\n extractVertices: (annotation) => [\n annotation.linePoints.start,\n annotation.linePoints.end,\n ],\n transformAnnotation: (annotation, vertices) => {\n return {\n ...annotation,\n linePoints: {\n start: vertices[0],\n end: vertices[1],\n },\n };\n },\n }}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Fragment>\n <Line\n {...obj}\n isSelected={isSelected}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n </Fragment>\n )}\n </AnnotationContainer>\n );\n }\n\n if (isPolyline(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n vertexConfig={{\n extractVertices: (annotation) => annotation.vertices,\n transformAnnotation: (annotation, vertices) => {\n return {\n ...annotation,\n vertices,\n };\n },\n }}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Fragment>\n <Polyline\n {...obj}\n isSelected={isSelected}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n </Fragment>\n )}\n </AnnotationContainer>\n );\n }\n\n if (isPolygon(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n vertexConfig={{\n extractVertices: (annotation) => annotation.vertices,\n transformAnnotation: (annotation, vertices) => {\n return {\n ...annotation,\n vertices,\n };\n },\n }}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Fragment>\n <Polygon\n {...obj}\n isSelected={isSelected}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n </Fragment>\n )}\n </AnnotationContainer>\n );\n }\n\n if (isFreeText(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={(tool?.interaction.isDraggable ?? true) && !isEditing}\n isResizable={tool?.interaction.isResizable ?? true}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n onDoubleClick={(e) => {\n e.stopPropagation();\n setEditingId(annotation.object.id);\n }}\n {...annotationsProps}\n >\n {(object) => (\n <FreeText\n isSelected={isSelected}\n isEditing={isEditing}\n annotation={{\n ...annotation,\n object,\n }}\n pageIndex={pageIndex}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isStamp(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? true}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(_object) => (\n <Stamp\n isSelected={isSelected}\n annotation={annotation}\n documentId={documentId}\n pageIndex={pageIndex}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n )}\n </AnnotationContainer>\n );\n }\n\n /* --------- fallback: an unsupported subtype --------------- */\n return null;\n })}\n </>\n );\n}\n","import { blendModeToCss, PdfAnnotationSubtype, PdfBlendMode, Rect } from '@embedpdf/models';\nimport { AnnotationTool } from '@embedpdf/plugin-annotation';\nimport { useSelectionCapability } from '@embedpdf/plugin-selection/@framework';\n\nimport { useEffect, useState } from '@framework';\nimport { useAnnotationCapability } from '../hooks';\nimport { Highlight } from './text-markup/highlight';\nimport { Squiggly } from './text-markup/squiggly';\nimport { Underline } from './text-markup/underline';\nimport { Strikeout } from './text-markup/strikeout';\n\ninterface TextMarkupProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n}\n\nexport function TextMarkup({ documentId, pageIndex, scale }: TextMarkupProps) {\n const { provides: selectionProvides } = useSelectionCapability();\n const { provides: annotationProvides } = useAnnotationCapability();\n const [rects, setRects] = useState<Array<Rect>>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n const [activeTool, setActiveTool] = useState<AnnotationTool | null>(null);\n\n useEffect(() => {\n if (!selectionProvides) return;\n\n return selectionProvides.forDocument(documentId).onSelectionChange(() => {\n setRects(selectionProvides.forDocument(documentId).getHighlightRectsForPage(pageIndex));\n setBoundingRect(selectionProvides.forDocument(documentId).getBoundingRectForPage(pageIndex));\n });\n }, [selectionProvides, documentId, pageIndex]);\n\n useEffect(() => {\n if (!annotationProvides) return;\n\n // Initialize with current active tool\n setActiveTool(annotationProvides.forDocument(documentId).getActiveTool());\n\n return annotationProvides\n .forDocument(documentId)\n .onActiveToolChange((event) => setActiveTool(event));\n }, [annotationProvides, documentId]);\n\n if (!boundingRect) return null;\n if (!activeTool || !activeTool.defaults) return null;\n\n switch (activeTool.defaults.type) {\n case PdfAnnotationSubtype.UNDERLINE:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Normal),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Underline\n color={activeTool.defaults?.color}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.HIGHLIGHT:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Multiply),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Highlight\n color={activeTool.defaults?.color}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.STRIKEOUT:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Normal),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Strikeout\n color={activeTool.defaults?.color}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.SQUIGGLY:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Normal),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Squiggly\n color={activeTool.defaults?.color}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n default:\n return null;\n }\n}\n","import { AnyPreviewState } from '@embedpdf/plugin-annotation';\nimport { Circle } from './annotations/circle';\nimport { Square } from './annotations/square';\nimport { Polygon } from './annotations/polygon';\nimport { PdfAnnotationSubtype } from '@embedpdf/models';\nimport { Polyline } from './annotations/polyline';\nimport { Line } from './annotations/line';\nimport { Ink } from './annotations/ink';\n\ninterface Props {\n preview: AnyPreviewState;\n scale: number;\n}\n\nexport function PreviewRenderer({ preview, scale }: Props) {\n const { bounds } = preview;\n\n const style = {\n position: 'absolute' as const,\n left: bounds.origin.x * scale,\n top: bounds.origin.y * scale,\n width: bounds.size.width * scale,\n height: bounds.size.height * scale,\n pointerEvents: 'none' as const,\n zIndex: 10,\n };\n\n // Use type guards for proper type narrowing\n if (preview.type === PdfAnnotationSubtype.CIRCLE) {\n return (\n <div style={style}>\n <Circle isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.SQUARE) {\n return (\n <div style={style}>\n <Square isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.POLYGON) {\n return (\n <div style={style}>\n <Polygon isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.POLYLINE) {\n return (\n <div style={style}>\n <Polyline isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.LINE) {\n return (\n <div style={style}>\n <Line isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.INK) {\n return (\n <div style={style}>\n <Ink isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.FREETEXT) {\n return (\n <div style={style}>\n {/* Render a simple dashed border preview */}\n <div\n style={{\n width: '100%',\n height: '100%',\n border: `1px dashed ${preview.data.fontColor || '#000000'}`,\n backgroundColor: 'transparent',\n }}\n />\n </div>\n );\n }\n\n return null;\n}\n","import { useEffect, useMemo, useRef, useState } from '@framework';\nimport { useAnnotationPlugin } from '../hooks';\nimport { AnyPreviewState, HandlerServices } from '@embedpdf/plugin-annotation';\nimport { PreviewRenderer } from './preview-renderer';\n\ninterface Props {\n documentId: string;\n pageIndex: number;\n scale: number;\n}\n\nexport function AnnotationPaintLayer({ documentId, pageIndex, scale }: Props) {\n const { plugin: annotationPlugin } = useAnnotationPlugin();\n const [previews, setPreviews] = useState<Map<string, AnyPreviewState>>(new Map());\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n\n const services = useMemo<HandlerServices>(\n () => ({\n requestFile: ({ accept, onFile }) => {\n if (!fileInputRef.current) return;\n const input = fileInputRef.current;\n input.accept = accept;\n input.onchange = (e) => {\n const file = (e.target as HTMLInputElement).files?.[0];\n if (file) {\n onFile(file);\n input.value = '';\n }\n };\n input.click();\n },\n processImage: ({ source, maxWidth, maxHeight, onComplete }) => {\n const canvas = canvasRef.current;\n if (!canvas || !canvas.getContext) return;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n\n const img = new Image();\n img.crossOrigin = 'Anonymous';\n img.onload = () => {\n let { naturalWidth: width, naturalHeight: height } = img;\n\n // --- SCALING LOGIC ---\n // Calculate the scale factor to fit within maxWidth and maxHeight\n const scaleX = maxWidth ? maxWidth / width : 1;\n const scaleY = maxHeight ? maxHeight / height : 1;\n const scaleFactor = Math.min(scaleX, scaleY, 1); // Ensure we don't scale up\n\n const finalWidth = width * scaleFactor;\n const finalHeight = height * scaleFactor;\n\n canvas.width = finalWidth;\n canvas.height = finalHeight;\n ctx.drawImage(img, 0, 0, finalWidth, finalHeight);\n\n const imageData = ctx.getImageData(0, 0, finalWidth, finalHeight);\n if (typeof source !== 'string') URL.revokeObjectURL(img.src);\n\n onComplete({ imageData, width: finalWidth, height: finalHeight });\n };\n img.src = typeof source === 'string' ? source : URL.createObjectURL(source);\n },\n }),\n [],\n );\n\n useEffect(() => {\n if (!annotationPlugin) return;\n\n return annotationPlugin.registerPageHandlers(documentId, pageIndex, scale, {\n services,\n onPreview: (toolId, state) => {\n setPreviews((prev) => {\n const next = new Map(prev);\n if (state) {\n next.set(toolId, state);\n } else {\n next.delete(toolId);\n }\n return next;\n });\n },\n });\n }, [documentId, pageIndex, scale, annotationPlugin, services]);\n\n return (\n <>\n {/* Hidden DOM elements required by services */}\n <input ref={fileInputRef} type=\"file\" style={{ display: 'none' }} />\n <canvas ref={canvasRef} style={{ display: 'none' }} />\n\n {/* Render any active previews from any tool */}\n {Array.from(previews.entries()).map(([toolId, preview]) => (\n <PreviewRenderer key={toolId} preview={preview} scale={scale} />\n ))}\n </>\n );\n}\n","import { HTMLAttributes, CSSProperties, useMemo } from '@framework';\nimport { useDocumentState } from '@embedpdf/core/@framework';\nimport { Annotations } from './annotations';\nimport { TextMarkup } from './text-markup';\nimport {\n ResizeHandleUI,\n VertexHandleUI,\n CustomAnnotationRenderer,\n AnnotationSelectionMenuRenderFn,\n} from './types';\nimport { AnnotationPaintLayer } from './annotation-paint-layer';\nimport { PdfAnnotationObject, Rotation } from '@embedpdf/models';\n\ntype AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n /** The ID of the document that this layer displays annotations for */\n documentId: string;\n pageIndex: number;\n scale?: number;\n rotation?: number;\n /** Customize selection menu across all annotations on this layer */\n selectionMenu?: AnnotationSelectionMenuRenderFn;\n style?: CSSProperties;\n /** Customize resize handles */\n resizeUI?: ResizeHandleUI;\n /** Customize vertex handles */\n vertexUI?: VertexHandleUI;\n /** Customize selection outline color */\n selectionOutlineColor?: string;\n /** Customize annotation renderer */\n customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;\n};\n\nexport function AnnotationLayer({\n style,\n documentId,\n pageIndex,\n scale: overrideScale,\n rotation: overrideRotation,\n selectionMenu,\n resizeUI,\n vertexUI,\n selectionOutlineColor,\n customAnnotationRenderer,\n ...props\n}: AnnotationLayerProps) {\n const documentState = useDocumentState(documentId);\n const page = documentState?.document?.pages?.[pageIndex];\n const width = page?.size?.width ?? 0;\n const height = page?.size?.height ?? 0;\n\n const actualScale = useMemo(() => {\n if (overrideScale !== undefined) return overrideScale;\n return documentState?.scale ?? 1;\n }, [overrideScale, documentState?.scale]);\n\n const actualRotation = useMemo(() => {\n if (overrideRotation !== undefined) return overrideRotation;\n return documentState?.rotation ?? Rotation.Degree0;\n }, [overrideRotation, documentState?.rotation]);\n\n return (\n <div\n style={{\n ...style,\n }}\n {...props}\n >\n <Annotations\n documentId={documentId}\n selectionMenu={selectionMenu}\n pageIndex={pageIndex}\n scale={actualScale}\n rotation={actualRotation}\n pageWidth={width}\n pageHeight={height}\n resizeUI={resizeUI}\n vertexUI={vertexUI}\n selectionOutlineColor={selectionOutlineColor}\n customAnnotationRenderer={customAnnotationRenderer}\n />\n <TextMarkup documentId={documentId} pageIndex={pageIndex} scale={actualScale} />\n <AnnotationPaintLayer documentId={documentId} pageIndex={pageIndex} scale={actualScale} />\n </div>\n );\n}\n"],"names":["suppressContentEditableWarningProps","suppressContentEditableWarning","useAnnotationPlugin","usePlugin","AnnotationPlugin","id","useAnnotationCapability","useCapability","AnnotationContainer","scale","documentId","pageIndex","rotation","pageWidth","pageHeight","trackedAnnotation","children","isSelected","isDraggable","isResizable","lockAspectRatio","style","vertexConfig","selectionMenu","outlineOffset","onDoubleClick","onSelect","zIndex","resizeUI","vertexUI","selectionOutlineColor","customAnnotationRenderer","props","preview","setPreview","useState","object","provides","annotationCapability","gestureBaseRef","useRef","annotationProvides","useMemo","forDocument","currentObject","HANDLE_COLOR","color","VERTEX_COLOR","HANDLE_SIZE","size","VERTEX_SIZE","dragProps","vertices","resize","useInteractionHandles","controller","element","rect","extractVertices","constraints","minWidth","minHeight","boundingBox","width","height","maintainAspectRatio","pageRotation","enabled","onUpdate","event","_a","transformData","type","state","current","transformType","base","changes","transformAnnotation","patched","metadata","prev","updateAnnotation","handleSize","spacing","offsetMode","includeSides","vertexSize","includeVertices","doubleProps","useDoublePressProps","useEffect","jsxs","position","left","origin","x","top","y","outline","pointerEvents","touchAction","cursor","childrenRender","customRender","annotation","map","key","hProps","component","backgroundColor","jsx","vProps","CounterRotate","context","selected","placement","suggestTop","Highlight","opacity","segmentRects","onClick","Fragment","b","i","onPointerDown","onTouchStart","background","Underline","thickness","r","bottom","Strikeout","transform","Squiggly","amplitude","period","svgDataUri","encodeURIComponent","backgroundImage","backgroundRepeat","backgroundSize","Ink","strokeWidth","inkList","paths","points","d","forEach","lx","ly","trim","overflow","viewBox","fill","stroke","strokeLinecap","strokeLinejoin","Square","strokeColor","strokeStyle","PdfAnnotationBorderStyle","SOLID","strokeDashArray","outerW","outerH","Math","max","svgWidth","svgHeight","DASHED","strokeDasharray","join","Circle","cx","cy","rx","ry","innerW","innerH","Line","linePoints","lineEndings","x1","y1","x2","y2","start","end","endings","angle","atan2","patching","createEnding","PI","filled","Polyline","localPts","pathData","length","first","rest","p","toAngle","a","startRad","endRad","Polygon","currentVertex","allPoints","isPreview","isPreviewing","FreeText","isEditing","editorRef","isIOS","setIsIOS","editor","focus","selection","window","getSelection","range","document","createRange","selectNodeContents","collapse","removeAllRanges","addRange","useLayoutEffect","nav","navigator","ios","test","userAgent","platform","maxTouchPoints","computedFontPx","fontSize","needsComp","adjustedFontPx","scaleComp","invScalePercent","ref","onBlur","contents","innerText","tabIndex","fontColor","fontFamily","standardFontCss","textAlign","textAlignmentToCss","flexDirection","justifyContent","verticalAlign","PdfVerticalAlignment","Top","Middle","display","lineHeight","transformOrigin","contentEditable","RenderAnnotation","scaleFactor","imageUrl","setImageUrl","urlRef","task","renderAnnotation","options","dpr","devicePixelRatio","wait","blob","url","URL","createObjectURL","ignore","revokeObjectURL","abort","code","PdfErrorCode","Cancelled","message","src","onLoad","Stamp","Annotations","annotationsProps","selectionProvides","useSelectionCapability","annotations","setAnnotations","register","usePointerHandlers","selectionState","setSelectionState","editingId","setEditingId","currentState","getState","getAnnotationsByPageIndex","getSelectedAnnotationByPageIndex","onStateChange","handlers","_","pe","target","currentTarget","deselectAnnotation","handleClick","useCallback","e","stopPropagation","selectAnnotation","clear","tool","findToolForAnnotation","isInk","interaction","mixBlendMode","blendModeToCss","blendMode","PdfBlendMode","Normal","obj","isSquare","isCircle","isUnderline","isStrikeout","isSquiggly","isHighlight","Multiply","isLine","isPolyline","isPolygon","isFreeText","isStamp","_object","TextMarkup","rects","setRects","boundingRect","setBoundingRect","activeTool","setActiveTool","onSelectionChange","getHighlightRectsForPage","getBoundingRectForPage","getActiveTool","onActiveToolChange","defaults","PdfAnnotationSubtype","UNDERLINE","inset","_b","_c","HIGHLIGHT","_d","_e","_f","STRIKEOUT","_g","_h","_i","SQUIGGLY","_j","_k","_l","PreviewRenderer","bounds","CIRCLE","data","SQUARE","POLYGON","POLYLINE","LINE","INK","FREETEXT","border","AnnotationPaintLayer","plugin","annotationPlugin","previews","setPreviews","Map","fileInputRef","canvasRef","services","requestFile","accept","onFile","input","onchange","file","files","value","click","processImage","source","maxWidth","maxHeight","onComplete","canvas","getContext","ctx","img","Image","crossOrigin","onload","naturalWidth","naturalHeight","scaleX","scaleY","min","finalWidth","finalHeight","drawImage","imageData","getImageData","registerPageHandlers","onPreview","toolId","next","set","delete","Array","from","entries","overrideScale","overrideRotation","documentState","useDocumentState","page","pages","actualScale","actualRotation","Rotation","Degree0","setState","initialDocumentState","scope","newState"],"mappings":"0XAoBaA,EAAsC,CACjDC,gCAAgC,GCbrBC,EAAsB,IAAMC,YAA4BC,EAAAA,iBAAiBC,IACzEC,EAA0B,IAAMC,gBAAgCH,EAAAA,iBAAiBC,ICoCvF,SAASG,GAAmDC,MACjEA,EAAAC,WACAA,EAAAC,UACAA,EAAAC,SACAA,EAAAC,UACAA,EAAAC,WACAA,EAAAC,kBACAA,EAAAC,SACAA,EAAAC,WACAA,EAAAC,YACAA,EAAAC,YACAA,EAAAC,gBACAA,GAAkB,EAAAC,MAClBA,EAAQ,CAAA,EAAAC,aACRA,EAAAC,cACAA,EAAAC,cACAA,EAAgB,EAAAC,cAChBA,EAAAC,SACAA,EAAAC,OACAA,EAAS,EAAAC,SACTA,EAAAC,SACAA,EAAAC,sBACAA,EAAwB,UAAAC,yBACxBA,KACGC,IAEH,MAAOC,EAASC,GAAcC,EAAAA,SAAYpB,EAAkBqB,SACpDC,SAAUC,GAAyBhC,IACrCiC,EAAiBC,EAAAA,OAAiB,MAGlCC,EAAqBC,EAAAA,QACzB,IAAOJ,EAAuBA,EAAqBK,YAAYjC,GAAc,KAC7E,CAAC4B,EAAsB5B,IAGnBkC,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C,OAAA,EAAAA,EAAepa,WAAY0a,EAAAA,SAASC,QAC1C,CAACR,EAAkB,MAAAC,OAAA,EAAAA,EAAepa,WAErC,OACEgF,EAAAA,KAAC,MAAA,CACCvE,MAAO,IACFA,MAEDW,EAEJhB,SAAA,CAAA+F,EAAAA,IAACiL,EAAA,CACCtR,aACAa,gBACAZ,YACAF,MAAO2a,EACPxa,SAAUya,EACVxa,UAAWkD,EACXjD,WAAYkD,EACZpC,WACAC,WACAC,wBACAC,6BAEFgF,EAAAA,IAACqO,EAAA,CAAW1U,aAAwBC,YAAsBF,MAAO2a,IACjErU,EAAAA,IAAC8Q,EAAA,CAAqBnX,aAAwBC,YAAsBF,MAAO2a,MAGjF,wBnBrE8B1a,UAC5B,MAAM2B,SAAEA,GAAa/B,KACdmE,EAAO+W,GAAYrZ,EAAAA,UACxB,OAAAmC,mBAAU3B,YAAYjC,SAAtB,EAAA4D,EAAmCuO,aAAc4I,EAAAA,wBAiBnD,OAdA9V,EAAAA,UAAU,KACR,IAAKtD,EAAU,OAEf,MAAMqZ,EAAQrZ,EAASM,YAAYjC,GAMnC,OAHA8a,EAASE,EAAM7I,YAGR6I,EAAM1I,cAAe2I,IAC1BH,EAASG,MAEV,CAACtZ,EAAU3B,IAEP,CACL+D,QACApC,UAAU,MAAAA,OAAA,EAAAA,EAAUM,YAAYjC,KAAe"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/react/adapter.ts","../../src/shared/hooks/use-annotation.ts","../../src/shared/components/annotation-container.tsx","../../src/shared/components/text-markup/highlight.tsx","../../src/shared/components/text-markup/underline.tsx","../../src/shared/components/text-markup/strikeout.tsx","../../src/shared/components/text-markup/squiggly.tsx","../../src/shared/components/annotations/ink.tsx","../../src/shared/components/annotations/square.tsx","../../src/shared/components/annotations/circle.tsx","../../src/shared/components/annotations/line.tsx","../../src/shared/components/annotations/polyline.tsx","../../src/shared/components/annotations/polygon.tsx","../../src/shared/components/annotations/free-text.tsx","../../src/shared/components/render-annotation.tsx","../../src/shared/components/annotations/stamp.tsx","../../src/shared/components/annotations.tsx","../../src/shared/components/text-markup.tsx","../../src/shared/components/preview-renderer.tsx","../../src/shared/components/annotation-paint-layer.tsx","../../src/shared/components/annotation-layer.tsx"],"sourcesContent":["export {\n Fragment,\n useEffect,\n useRef,\n useState,\n useCallback,\n useMemo,\n useLayoutEffect,\n JSX,\n ChangeEvent,\n} from 'react';\nexport type {\n ReactNode,\n HTMLAttributes,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n TouchEvent,\n} from 'react';\n\nexport const suppressContentEditableWarningProps = {\n suppressContentEditableWarning: true,\n};\n","import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport {\n AnnotationPlugin,\n AnnotationDocumentState,\n initialDocumentState,\n} from '@embedpdf/plugin-annotation';\nimport { useState, useEffect } from '@framework';\n\nexport const useAnnotationPlugin = () => usePlugin<AnnotationPlugin>(AnnotationPlugin.id);\nexport const useAnnotationCapability = () => useCapability<AnnotationPlugin>(AnnotationPlugin.id);\n\n/**\n * Hook for annotation state for a specific document\n * @param documentId Document ID\n */\nexport const useAnnotation = (documentId: string) => {\n const { provides } = useAnnotationCapability();\n const [state, setState] = useState<AnnotationDocumentState>(\n provides?.forDocument(documentId)?.getState() ?? initialDocumentState(),\n );\n\n useEffect(() => {\n if (!provides) return;\n\n const scope = provides.forDocument(documentId);\n\n // Get initial state\n setState(scope.getState());\n\n // Subscribe to state changes\n return scope.onStateChange((newState) => {\n setState(newState);\n });\n }, [provides, documentId]);\n\n return {\n state,\n provides: provides?.forDocument(documentId) ?? null,\n };\n};\n","import { PdfAnnotationObject } from '@embedpdf/models';\nimport {\n CounterRotate,\n useDoublePressProps,\n useInteractionHandles,\n} from '@embedpdf/utils/@framework';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\nimport { useState, JSX, CSSProperties, useRef, useEffect, useMemo } from '@framework';\nimport { useDocumentPermissions } from '@embedpdf/core/@framework';\n\nimport { useAnnotationCapability } from '../hooks';\nimport {\n CustomAnnotationRenderer,\n ResizeHandleUI,\n AnnotationSelectionMenuRenderFn,\n VertexHandleUI,\n} from './types';\nimport { VertexConfig } from '../types';\n\ninterface AnnotationContainerProps<T extends PdfAnnotationObject> {\n scale: number;\n documentId: string;\n pageIndex: number;\n rotation: number;\n pageWidth: number;\n pageHeight: number;\n trackedAnnotation: TrackedAnnotation<T>;\n children: JSX.Element | ((annotation: T) => JSX.Element);\n isSelected: boolean;\n isDraggable: boolean;\n isResizable: boolean;\n lockAspectRatio?: boolean;\n style?: CSSProperties;\n vertexConfig?: VertexConfig<T>;\n selectionMenu?: AnnotationSelectionMenuRenderFn;\n outlineOffset?: number;\n onDoubleClick?: (event: any) => void; // You'll need to import proper MouseEvent type\n onSelect: (event: any) => void;\n zIndex?: number;\n resizeUI?: ResizeHandleUI;\n vertexUI?: VertexHandleUI;\n selectionOutlineColor?: string;\n customAnnotationRenderer?: CustomAnnotationRenderer<T>;\n}\n\n// Simplified AnnotationContainer\nexport function AnnotationContainer<T extends PdfAnnotationObject>({\n scale,\n documentId,\n pageIndex,\n rotation,\n pageWidth,\n pageHeight,\n trackedAnnotation,\n children,\n isSelected,\n isDraggable,\n isResizable,\n lockAspectRatio = false,\n style = {},\n vertexConfig,\n selectionMenu,\n outlineOffset = 1,\n onDoubleClick,\n onSelect,\n zIndex = 1,\n resizeUI,\n vertexUI,\n selectionOutlineColor = '#007ACC',\n customAnnotationRenderer,\n ...props\n}: AnnotationContainerProps<T>): JSX.Element {\n const [preview, setPreview] = useState<T>(trackedAnnotation.object);\n const { provides: annotationCapability } = useAnnotationCapability();\n const { canModifyAnnotations } = useDocumentPermissions(documentId);\n const gestureBaseRef = useRef<T | null>(null);\n\n // Override props based on permission\n const effectiveIsDraggable = canModifyAnnotations && isDraggable;\n const effectiveIsResizable = canModifyAnnotations && isResizable;\n\n // Get scoped API for this document (memoized to prevent infinite loops)\n const annotationProvides = useMemo(\n () => (annotationCapability ? annotationCapability.forDocument(documentId) : null),\n [annotationCapability, documentId],\n );\n\n const currentObject = preview\n ? { ...trackedAnnotation.object, ...preview }\n : trackedAnnotation.object;\n\n // Defaults retain current behavior\n const HANDLE_COLOR = resizeUI?.color ?? '#007ACC';\n const VERTEX_COLOR = vertexUI?.color ?? '#007ACC';\n const HANDLE_SIZE = resizeUI?.size ?? 12;\n const VERTEX_SIZE = vertexUI?.size ?? 12;\n\n const { dragProps, vertices, resize } = useInteractionHandles({\n controller: {\n element: currentObject.rect,\n vertices: vertexConfig?.extractVertices(currentObject),\n constraints: {\n minWidth: 10,\n minHeight: 10,\n boundingBox: { width: pageWidth, height: pageHeight },\n },\n maintainAspectRatio: lockAspectRatio,\n pageRotation: rotation,\n scale: scale,\n enabled: isSelected,\n onUpdate: (event) => {\n if (!event.transformData?.type) return;\n\n if (event.state === 'start') {\n gestureBaseRef.current = currentObject;\n }\n\n const transformType = event.transformData.type;\n const base = gestureBaseRef.current ?? currentObject;\n\n const changes = event.transformData.changes.vertices\n ? vertexConfig?.transformAnnotation(base, event.transformData.changes.vertices)\n : { rect: event.transformData.changes.rect };\n\n const patched = annotationCapability?.transformAnnotation<T>(base, {\n type: transformType,\n changes: changes as Partial<T>,\n metadata: event.transformData.metadata,\n });\n\n if (patched) {\n setPreview((prev) => ({\n ...prev,\n ...patched,\n }));\n }\n\n if (event.state === 'end' && patched) {\n gestureBaseRef.current = null;\n annotationProvides?.updateAnnotation(pageIndex, trackedAnnotation.object.id, patched);\n }\n },\n },\n resizeUI: {\n handleSize: HANDLE_SIZE,\n spacing: outlineOffset,\n offsetMode: 'outside',\n includeSides: lockAspectRatio ? false : true,\n zIndex: zIndex + 1,\n },\n vertexUI: {\n vertexSize: VERTEX_SIZE,\n zIndex: zIndex + 2,\n },\n includeVertices: vertexConfig ? true : false,\n });\n\n // Wrap onDoubleClick to respect permissions\n const guardedOnDoubleClick = useMemo(() => {\n if (!canModifyAnnotations || !onDoubleClick) return undefined;\n return onDoubleClick;\n }, [canModifyAnnotations, onDoubleClick]);\n\n const doubleProps = useDoublePressProps(guardedOnDoubleClick);\n\n useEffect(() => {\n setPreview(trackedAnnotation.object);\n }, [trackedAnnotation.object]);\n\n return (\n <div data-no-interaction>\n <div\n {...(effectiveIsDraggable && isSelected ? dragProps : {})}\n {...doubleProps}\n style={{\n position: 'absolute',\n left: currentObject.rect.origin.x * scale,\n top: currentObject.rect.origin.y * scale,\n width: currentObject.rect.size.width * scale,\n height: currentObject.rect.size.height * scale,\n outline: isSelected ? `1px solid ${selectionOutlineColor}` : 'none',\n outlineOffset: isSelected ? `${outlineOffset}px` : '0px',\n pointerEvents: isSelected ? 'auto' : 'none',\n touchAction: 'none',\n cursor: isSelected && effectiveIsDraggable ? 'move' : 'default',\n zIndex,\n ...style,\n }}\n {...props}\n >\n {(() => {\n const childrenRender =\n typeof children === 'function' ? children(currentObject) : children;\n // Check for custom renderer first\n const customRender = customAnnotationRenderer?.({\n annotation: currentObject,\n children: childrenRender,\n isSelected,\n scale,\n rotation,\n pageWidth,\n pageHeight,\n pageIndex,\n onSelect,\n });\n if (customRender !== null && customRender !== undefined) {\n return customRender;\n }\n\n // Fall back to default children rendering\n return childrenRender;\n })()}\n\n {isSelected &&\n effectiveIsResizable &&\n resize.map(({ key, ...hProps }) =>\n resizeUI?.component ? (\n resizeUI.component({\n key,\n ...hProps,\n backgroundColor: HANDLE_COLOR,\n })\n ) : (\n <div\n key={key}\n {...hProps}\n style={{ ...hProps.style, backgroundColor: HANDLE_COLOR }}\n />\n ),\n )}\n\n {isSelected &&\n canModifyAnnotations &&\n vertices.map(({ key, ...vProps }) =>\n vertexUI?.component ? (\n vertexUI.component({\n key,\n ...vProps,\n backgroundColor: VERTEX_COLOR,\n })\n ) : (\n <div\n key={key}\n {...vProps}\n style={{ ...vProps.style, backgroundColor: VERTEX_COLOR }}\n />\n ),\n )}\n </div>\n {/* CounterRotate remains unchanged */}\n {selectionMenu && (\n <CounterRotate\n rect={{\n origin: {\n x: currentObject.rect.origin.x * scale,\n y: currentObject.rect.origin.y * scale,\n },\n size: {\n width: currentObject.rect.size.width * scale,\n height: currentObject.rect.size.height * scale,\n },\n }}\n rotation={rotation}\n >\n {(props) =>\n selectionMenu({\n ...props,\n context: {\n type: 'annotation',\n annotation: trackedAnnotation,\n pageIndex,\n },\n selected: isSelected,\n placement: {\n suggestTop: false,\n },\n })\n }\n </CounterRotate>\n )}\n </div>\n );\n}\n","import { CSSProperties, MouseEvent, TouchEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype HighlightProps = {\n color?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n};\n\nexport function Highlight({\n color = '#FFFF00',\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n}: HighlightProps) {\n return (\n <>\n {segmentRects.map((b, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n position: 'absolute',\n left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,\n top: (rect ? b.origin.y - rect.origin.y : b.origin.y) * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background: color,\n opacity: opacity,\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : undefined,\n ...style,\n }}\n />\n ))}\n </>\n );\n}\n","import { CSSProperties, MouseEvent, TouchEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype UnderlineProps = {\n color?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n};\n\nexport function Underline({\n color = '#FFFF00',\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n}: UnderlineProps) {\n const thickness = 2 * scale; // 2 CSS px at 100 % zoom\n\n return (\n <>\n {segmentRects.map((r, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n position: 'absolute',\n left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,\n top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : 0,\n ...style,\n }}\n >\n {/* Visual underline */}\n <div\n style={{\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n height: thickness,\n background: color,\n opacity: opacity,\n pointerEvents: 'none',\n }}\n />\n </div>\n ))}\n </>\n );\n}\n","import { CSSProperties, MouseEvent, TouchEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype StrikeoutProps = {\n color?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n};\n\nexport function Strikeout({\n color = '#FFFF00',\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n}: StrikeoutProps) {\n const thickness = 2 * scale;\n\n return (\n <>\n {segmentRects.map((r, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n position: 'absolute',\n left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,\n top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : 0,\n ...style,\n }}\n >\n {/* Visual strikeout line */}\n <div\n style={{\n position: 'absolute',\n left: 0,\n top: '50%',\n width: '100%',\n height: thickness,\n background: color,\n opacity: opacity,\n transform: 'translateY(-50%)',\n pointerEvents: 'none',\n }}\n />\n </div>\n ))}\n </>\n );\n}\n","import { CSSProperties, MouseEvent, TouchEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype SquigglyProps = {\n color?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n};\n\nexport function Squiggly({\n color = '#FFFF00',\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n}: SquigglyProps) {\n const amplitude = 2 * scale; // wave height\n const period = 6 * scale; // wave length\n\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${period}\" height=\"${amplitude * 2}\" viewBox=\"0 0 ${period} ${amplitude * 2}\">\n <path d=\"M0 ${amplitude} Q ${period / 4} 0 ${period / 2} ${amplitude} T ${period} ${amplitude}\"\n fill=\"none\" stroke=\"${color}\" stroke-width=\"${amplitude}\" stroke-linecap=\"round\"/>\n </svg>`;\n\n // Completely escape the SVG markup\n const svgDataUri = `url(\"data:image/svg+xml;utf8,${encodeURIComponent(svg)}\")`;\n\n return (\n <>\n {segmentRects.map((r, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n position: 'absolute',\n left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,\n top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : 0,\n ...style,\n }}\n >\n {/* Visual squiggly line */}\n <div\n style={{\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n height: amplitude * 2,\n backgroundImage: svgDataUri,\n backgroundRepeat: 'repeat-x',\n backgroundSize: `${period}px ${amplitude * 2}px`,\n opacity: opacity,\n pointerEvents: 'none',\n }}\n />\n </div>\n ))}\n </>\n );\n}\n","import { useMemo, MouseEvent, TouchEvent } from '@framework';\nimport { PdfInkListObject, Rect } from '@embedpdf/models';\n\n/* ---------------------------------------------------------------- *\\\n|* Types *|\n\\* ---------------------------------------------------------------- */\n\ninterface InkProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Stroke colour (falls back to PDFium default black) */\n color?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Line width in PDF units */\n strokeWidth: number;\n /** Array of strokes — exactly as in your JSON */\n inkList: PdfInkListObject[];\n /** Bounding box of the whole annotation */\n rect: Rect;\n /** Page zoom factor */\n scale: number;\n /** Callback for when the annotation is clicked */\n onClick?: (e: MouseEvent<SVGPathElement> | TouchEvent<SVGPathElement>) => void;\n}\n\n/**\n * Renders a PDF Ink annotation (free-hand drawing) as SVG.\n */\nexport function Ink({\n isSelected,\n color = '#000000',\n opacity = 1,\n strokeWidth,\n inkList,\n rect,\n scale,\n onClick,\n}: InkProps): JSX.Element {\n /* convert each stroke to an SVG <path d=\"\"> string */\n const paths = useMemo(() => {\n return inkList.map(({ points }) => {\n let d = '';\n points.forEach(({ x, y }, i) => {\n // localise to the annotation’s own bbox so viewBox can stay tidy\n const lx = x - rect.origin.x;\n const ly = y - rect.origin.y;\n d += (i === 0 ? 'M' : 'L') + lx + ' ' + ly + ' ';\n });\n return d.trim();\n });\n }, [inkList, rect]);\n\n /* absolute placement + scaling just like your text-markup components */\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n {paths.map((d, i) => (\n <path\n key={i}\n d={d}\n fill=\"none\"\n opacity={opacity}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visibleStroke',\n stroke: color,\n strokeWidth: strokeWidth,\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n }}\n />\n ))}\n </svg>\n );\n}\n","import { useMemo, MouseEvent, TouchEvent } from '@framework';\nimport { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';\n\n/* ---------------------------------------------------------------- *\\\n|* Types *|\n\\* ---------------------------------------------------------------- */\n\ninterface SquareProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Fill colour – defaults to PDFium’s black if omitted */\n color?: string;\n /** Stroke colour – defaults to same as fill when omitted */\n strokeColor?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Stroke width in PDF units */\n strokeWidth: number;\n /** Stroke type – defaults to solid when omitted */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array – defaults to undefined when omitted */\n strokeDashArray?: number[];\n /** Bounding box of the annotation (PDF units) */\n rect: Rect;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;\n}\n\n/**\n * Renders a PDF Square annotation (rectangle) as SVG.\n */\nexport function Square({\n isSelected,\n color = '#000000',\n strokeColor,\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n rect,\n scale,\n onClick,\n}: SquareProps): JSX.Element {\n /* ------------------------------------------------------------------ */\n /* geometry helpers */\n /* ------------------------------------------------------------------ */\n const { width, height, x, y } = useMemo(() => {\n // Full bounding box *includes* stroke width.\n const outerW = rect.size.width;\n const outerH = rect.size.height;\n\n // Remove the stroke so the visible fill matches the preview.\n const innerW = Math.max(outerW - strokeWidth, 0);\n const innerH = Math.max(outerH - strokeWidth, 0);\n\n return {\n width: innerW,\n height: innerH,\n x: strokeWidth / 2,\n y: strokeWidth / 2,\n };\n }, [rect, strokeWidth]);\n\n const svgWidth = (width + strokeWidth) * scale;\n const svgHeight = (height + strokeWidth) * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width: svgWidth,\n height: svgHeight,\n pointerEvents: 'none',\n zIndex: 2,\n }}\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${width + strokeWidth} ${height + strokeWidth}`}\n >\n <rect\n x={x}\n y={y}\n width={width}\n height={height}\n fill={color}\n opacity={opacity}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n stroke: strokeColor ?? color,\n strokeWidth,\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n </svg>\n );\n}\n","import { useMemo, MouseEvent, TouchEvent } from '@framework';\nimport { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';\n\n/* ---------------------------------------------------------------- *\\\n|* Types *|\n\\* ---------------------------------------------------------------- */\n\ninterface CircleProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Fill colour – defaults to PDFium’s black if omitted */\n color?: string;\n /** Stroke colour – defaults to same as fill when omitted */\n strokeColor?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Stroke width in PDF units */\n strokeWidth: number;\n /** Stroke type – defaults to solid when omitted */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array – defaults to undefined when omitted */\n strokeDashArray?: number[];\n /** Bounding box of the annotation */\n rect: Rect;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;\n}\n\n/**\n * Renders a PDF Circle annotation (ellipse) as SVG.\n */\nexport function Circle({\n color = '#000000',\n strokeColor,\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n rect,\n scale,\n onClick,\n isSelected,\n}: CircleProps): JSX.Element {\n /* ------------------------------------------------------------------ */\n /* geometry helpers */\n /* ------------------------------------------------------------------ */\n const { width, height, cx, cy, rx, ry } = useMemo(() => {\n // Full bounding box *includes* stroke width.\n const outerW = rect.size.width;\n const outerH = rect.size.height;\n\n // Remove the stroke so the visible fill matches the preview.\n const innerW = Math.max(outerW - strokeWidth, 0);\n const innerH = Math.max(outerH - strokeWidth, 0);\n\n return {\n width: outerW,\n height: outerH,\n // Centre of the fill sits strokeWidth/2 in from the edges\n cx: strokeWidth / 2 + innerW / 2,\n cy: strokeWidth / 2 + innerH / 2,\n rx: innerW / 2,\n ry: innerH / 2,\n };\n }, [rect, strokeWidth]);\n\n const svgWidth = width * scale;\n const svgHeight = height * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width: svgWidth,\n height: svgHeight,\n pointerEvents: 'none',\n zIndex: 2,\n }}\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${width} ${height}`}\n >\n <ellipse\n cx={cx}\n cy={cy}\n rx={rx}\n ry={ry}\n fill={color}\n opacity={opacity}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n stroke: strokeColor ?? color,\n strokeWidth,\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n </svg>\n );\n}\n","import { useMemo, MouseEvent, TouchEvent } from '@framework';\nimport { Rect, LinePoints, LineEndings, PdfAnnotationBorderStyle } from '@embedpdf/models';\nimport { patching } from '@embedpdf/plugin-annotation';\n\n/* ---------------------------------------------------------------- *\\\n|* Types *|\n\\* ---------------------------------------------------------------- */\n\ninterface LineProps {\n /** interior colour */\n color?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Stroke width in PDF units */\n strokeWidth: number;\n /** Stroke colour (falls back to PDFium default black) */\n strokeColor?: string;\n /** Stroke style */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array */\n strokeDashArray?: number[];\n /** Bounding box of the annotation */\n rect: Rect;\n /** Line start / end points (page units) */\n linePoints: LinePoints;\n /** Line endings (eg. OpenArrow / Butt) */\n lineEndings?: LineEndings;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;\n /** Whether the annotation is selected */\n isSelected: boolean;\n}\n\n/**\n * Renders a PDF Line annotation as SVG (with arrow/butt endings).\n */\nexport function Line({\n color = 'transparent',\n opacity = 1,\n strokeWidth,\n strokeColor = '#000000',\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n rect,\n linePoints,\n lineEndings,\n scale,\n onClick,\n isSelected,\n}: LineProps): JSX.Element {\n /* -------------------------------------------------------------- */\n /* Localise the line within its own bounding box */\n /* -------------------------------------------------------------- */\n const { x1, y1, x2, y2 } = useMemo(() => {\n return {\n x1: linePoints.start.x - rect.origin.x,\n y1: linePoints.start.y - rect.origin.y,\n x2: linePoints.end.x - rect.origin.x,\n y2: linePoints.end.y - rect.origin.y,\n };\n }, [linePoints, rect]);\n\n /* -------------------------------------------------------------- */\n /* Arrow-head path data via shared factory */\n /* -------------------------------------------------------------- */\n const endings = useMemo(() => {\n const angle = Math.atan2(y2 - y1, x2 - x1);\n return {\n start: patching.createEnding(lineEndings?.start, strokeWidth, angle + Math.PI, x1, y1),\n end: patching.createEnding(lineEndings?.end, strokeWidth, angle, x2, y2),\n };\n }, [lineEndings, strokeWidth, x1, y1, x2, y2]);\n\n /* -------------------------------------------------------------- */\n /* Absolute placement + scaling (same pattern as other shapes) */\n /* -------------------------------------------------------------- */\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n {/* Main line */}\n <line\n x1={x1}\n y1={y1}\n x2={x2}\n y2={y2}\n opacity={opacity}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visibleStroke',\n stroke: strokeColor,\n strokeWidth,\n strokeLinecap: 'butt',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n\n {/* Optional arrowheads / butt caps */}\n {endings.start && (\n <path\n d={endings.start.d}\n transform={endings.start.transform}\n onPointerDown={onClick}\n onTouchStart={onClick}\n stroke={strokeColor}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n strokeWidth,\n strokeLinecap: 'butt',\n pointerEvents: isSelected ? 'none' : endings.start.filled ? 'visible' : 'visibleStroke',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n fill={endings.start.filled ? color : 'none'}\n />\n )}\n {endings.end && (\n <path\n d={endings.end.d}\n transform={endings.end.transform}\n stroke={strokeColor}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n strokeWidth,\n strokeLinecap: 'butt',\n pointerEvents: isSelected ? 'none' : endings.end.filled ? 'visible' : 'visibleStroke',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n fill={endings.end.filled ? color : 'none'}\n />\n )}\n </svg>\n );\n}\n","import { MouseEvent, TouchEvent, useMemo } from '@framework';\nimport { Rect, Position, LineEndings } from '@embedpdf/models';\nimport { patching } from '@embedpdf/plugin-annotation';\n\ninterface PolylineProps {\n rect: Rect;\n vertices: Position[];\n color?: string;\n strokeColor?: string;\n opacity?: number;\n strokeWidth: number;\n scale: number;\n isSelected: boolean;\n onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;\n /** Optional start & end endings */\n lineEndings?: LineEndings;\n}\n\nexport function Polyline({\n rect,\n vertices,\n color = 'transparent',\n strokeColor = '#000000',\n opacity = 1,\n strokeWidth,\n scale,\n isSelected,\n onClick,\n lineEndings,\n}: PolylineProps): JSX.Element {\n // Localise vertices to annotation rect\n const localPts = useMemo(\n () => vertices.map(({ x, y }) => ({ x: x - rect.origin.x, y: y - rect.origin.y })),\n [vertices, rect],\n );\n\n // Build path data \"M x0 y0 L x1 y1 ...\"\n const pathData = useMemo(() => {\n if (!localPts.length) return '';\n const [first, ...rest] = localPts;\n return (\n `M ${first.x} ${first.y} ` +\n rest\n .map((p) => `L ${p.x} ${p.y} `)\n .join('')\n .trim()\n );\n }, [localPts]);\n\n // Compute endings (angles from first→second, last-1→last)\n const endings = useMemo(() => {\n if (localPts.length < 2) return { start: null, end: null };\n const toAngle = (a: Position, b: Position) => Math.atan2(b.y - a.y, b.x - a.x);\n\n // Calculate angles in the direction of the line segments\n const startRad = toAngle(localPts[0], localPts[1]); // direction FROM first TO second\n const endRad = toAngle(localPts[localPts.length - 2], localPts[localPts.length - 1]); // direction FROM second-to-last TO last\n\n const start = patching.createEnding(\n lineEndings?.start,\n strokeWidth,\n startRad + Math.PI, // tip points outward from line start\n localPts[0].x,\n localPts[0].y,\n );\n const end = patching.createEnding(\n lineEndings?.end,\n strokeWidth,\n endRad, // tip points in line direction\n localPts[localPts.length - 1].x,\n localPts[localPts.length - 1].y,\n );\n return { start, end };\n }, [localPts, lineEndings, strokeWidth]);\n\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n <path\n d={pathData}\n onPointerDown={onClick}\n onTouchStart={onClick}\n opacity={opacity}\n style={{\n fill: 'none',\n stroke: strokeColor ?? color,\n strokeWidth,\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visibleStroke',\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter',\n }}\n />\n {endings.start && (\n <path\n d={endings.start.d}\n transform={endings.start.transform}\n stroke={strokeColor}\n fill={endings.start.filled ? color : 'none'}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n strokeWidth,\n pointerEvents: isSelected ? 'none' : endings.start.filled ? 'visible' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n )}\n {endings.end && (\n <path\n d={endings.end.d}\n transform={endings.end.transform}\n stroke={strokeColor}\n fill={endings.end.filled ? color : 'none'}\n onPointerDown={onClick}\n onTouchStart={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n strokeWidth,\n pointerEvents: isSelected ? 'none' : endings.end.filled ? 'visible' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n )}\n </svg>\n );\n}\n","import { useMemo, MouseEvent, TouchEvent } from '@framework';\nimport { Rect, Position, PdfAnnotationBorderStyle } from '@embedpdf/models';\n\ninterface PolygonProps {\n rect: Rect;\n vertices: Position[];\n color?: string;\n strokeColor?: string;\n opacity?: number;\n strokeWidth: number;\n strokeStyle?: PdfAnnotationBorderStyle;\n strokeDashArray?: number[];\n scale: number;\n isSelected: boolean;\n onClick?: (e: MouseEvent<SVGElement> | TouchEvent<SVGElement>) => void;\n\n // New optional props for preview rendering\n currentVertex?: Position;\n handleSize?: number;\n}\n\nexport function Polygon({\n rect,\n vertices,\n color = 'transparent',\n strokeColor = '#000000',\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n scale,\n isSelected,\n onClick,\n currentVertex, // A preview-only prop\n handleSize = 14, // in CSS pixels\n}: PolygonProps): JSX.Element {\n const allPoints = currentVertex ? [...vertices, currentVertex] : vertices;\n\n const localPts = useMemo(\n () => allPoints.map(({ x, y }) => ({ x: x - rect.origin.x, y: y - rect.origin.y })),\n [allPoints, rect],\n );\n\n const pathData = useMemo(() => {\n if (!localPts.length) return '';\n const [first, ...rest] = localPts;\n const isPreview = !!currentVertex;\n // Don't close the path with 'Z' if it's a preview\n return (\n `M ${first.x} ${first.y} ` +\n rest.map((p) => `L ${p.x} ${p.y}`).join(' ') +\n (isPreview ? '' : ' Z')\n ).trim();\n }, [localPts, currentVertex]);\n\n const isPreviewing = currentVertex && vertices.length > 0;\n\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n <path\n d={pathData}\n onPointerDown={onClick}\n onTouchStart={onClick}\n opacity={opacity}\n style={{\n fill: currentVertex ? 'none' : color, // No fill during preview\n stroke: strokeColor ?? color,\n strokeWidth,\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n {/* --- Preview-only elements --- */}\n {isPreviewing && vertices.length > 1 && (\n <path\n d={`M ${localPts[localPts.length - 1].x} ${localPts[localPts.length - 1].y} L ${localPts[0].x} ${localPts[0].y}`}\n fill=\"none\"\n style={{ stroke: strokeColor, strokeWidth, strokeDasharray: '4,4', opacity: 0.7 }}\n />\n )}\n {isPreviewing && vertices.length >= 2 && (\n <rect\n x={localPts[0].x - handleSize / scale / 2}\n y={localPts[0].y - handleSize / scale / 2}\n width={handleSize / scale}\n height={handleSize / scale}\n fill={strokeColor}\n opacity={0.4}\n stroke={strokeColor}\n strokeWidth={strokeWidth / 2}\n />\n )}\n </svg>\n );\n}\n","import {\n MouseEvent,\n TouchEvent,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n suppressContentEditableWarningProps,\n} from '@framework';\nimport {\n PdfFreeTextAnnoObject,\n PdfVerticalAlignment,\n standardFontCss,\n textAlignmentToCss,\n} from '@embedpdf/models';\nimport { useAnnotationCapability } from '../..';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\n\ninterface FreeTextProps {\n isSelected: boolean;\n isEditing: boolean;\n annotation: TrackedAnnotation<PdfFreeTextAnnoObject>;\n pageIndex: number;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;\n onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;\n}\n\nexport function FreeText({\n isSelected,\n isEditing,\n annotation,\n pageIndex,\n scale,\n onClick,\n}: FreeTextProps) {\n const editorRef = useRef<HTMLSpanElement>(null);\n const { provides: annotationProvides } = useAnnotationCapability();\n const [isIOS, setIsIOS] = useState(false);\n\n useEffect(() => {\n if (isEditing && editorRef.current) {\n const editor = editorRef.current;\n editor.focus();\n\n const selection = window.getSelection();\n if (selection) {\n const range = document.createRange();\n range.selectNodeContents(editor);\n range.collapse(false);\n selection.removeAllRanges();\n selection.addRange(range);\n }\n }\n }, [isEditing]);\n\n useLayoutEffect(() => {\n try {\n const nav = navigator as any;\n const ios =\n /iPad|iPhone|iPod/.test(navigator.userAgent) ||\n (navigator.platform === 'MacIntel' && nav?.maxTouchPoints > 1);\n setIsIOS(ios);\n } catch {\n setIsIOS(false);\n }\n }, []);\n\n const handleBlur = () => {\n if (!annotationProvides) return;\n if (!editorRef.current) return;\n annotationProvides.updateAnnotation(pageIndex, annotation.object.id, {\n contents: editorRef.current.innerText,\n });\n };\n\n // iOS zoom prevention: keep focused font-size >= 16px, visually scale down if needed.\n const computedFontPx = annotation.object.fontSize * scale;\n const MIN_IOS_FOCUS_FONT_PX = 16;\n const needsComp =\n isIOS && isEditing && computedFontPx > 0 && computedFontPx < MIN_IOS_FOCUS_FONT_PX;\n const adjustedFontPx = needsComp ? MIN_IOS_FOCUS_FONT_PX : computedFontPx;\n const scaleComp = needsComp ? computedFontPx / MIN_IOS_FOCUS_FONT_PX : 1;\n const invScalePercent = needsComp ? 100 / scaleComp : 100;\n\n return (\n <div\n style={{\n position: 'absolute',\n width: annotation.object.rect.size.width * scale,\n height: annotation.object.rect.size.height * scale,\n cursor: isSelected && !isEditing ? 'move' : 'default',\n pointerEvents: isSelected && !isEditing ? 'none' : 'auto',\n zIndex: 2,\n }}\n onPointerDown={onClick}\n onTouchStart={onClick}\n >\n <span\n ref={editorRef}\n onBlur={handleBlur}\n tabIndex={0}\n style={{\n color: annotation.object.fontColor,\n fontSize: adjustedFontPx,\n fontFamily: standardFontCss(annotation.object.fontFamily),\n textAlign: textAlignmentToCss(annotation.object.textAlign),\n flexDirection: 'column',\n justifyContent:\n annotation.object.verticalAlign === PdfVerticalAlignment.Top\n ? 'flex-start'\n : annotation.object.verticalAlign === PdfVerticalAlignment.Middle\n ? 'center'\n : 'flex-end',\n display: 'flex',\n backgroundColor: annotation.object.backgroundColor,\n opacity: annotation.object.opacity,\n width: needsComp ? `${invScalePercent}%` : '100%',\n height: needsComp ? `${invScalePercent}%` : '100%',\n lineHeight: '1.18',\n overflow: 'hidden',\n cursor: isEditing ? 'text' : 'pointer',\n outline: 'none',\n transform: needsComp ? `scale(${scaleComp})` : undefined,\n transformOrigin: 'top left',\n }}\n contentEditable={isEditing}\n {...suppressContentEditableWarningProps}\n >\n {annotation.object.contents}\n </span>\n </div>\n );\n}\n","import { Fragment, HTMLAttributes, CSSProperties, useEffect, useRef, useState } from '@framework';\nimport { AppearanceMode, ignore, PdfAnnotationObject, PdfErrorCode } from '@embedpdf/models';\n\nimport { useAnnotationCapability } from '../hooks/use-annotation';\n\ntype RenderAnnotationProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n documentId: string;\n pageIndex: number;\n annotation: PdfAnnotationObject;\n scaleFactor?: number;\n dpr?: number;\n style?: CSSProperties;\n};\n\nexport function RenderAnnotation({\n documentId,\n pageIndex,\n annotation,\n scaleFactor = 1,\n style,\n ...props\n}: RenderAnnotationProps) {\n const { provides: annotationProvides } = useAnnotationCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n const { width, height } = annotation.rect.size;\n\n useEffect(() => {\n if (annotationProvides) {\n const task = annotationProvides.forDocument(documentId).renderAnnotation({\n pageIndex,\n annotation,\n options: {\n scaleFactor,\n dpr: window.devicePixelRatio,\n },\n });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [pageIndex, scaleFactor, annotationProvides, documentId, annotation.id, width, height]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n display: 'block',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n","import { MouseEvent, TouchEvent } from '@framework';\nimport { PdfStampAnnoObject } from '@embedpdf/models';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\nimport { RenderAnnotation } from '../render-annotation';\n\ninterface StampProps {\n isSelected: boolean;\n annotation: TrackedAnnotation<PdfStampAnnoObject>;\n documentId: string;\n pageIndex: number;\n scale: number;\n onClick: (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => void;\n}\n\nexport function Stamp({\n isSelected,\n annotation,\n documentId,\n pageIndex,\n scale,\n onClick,\n}: StampProps) {\n return (\n <div\n style={{\n position: 'absolute',\n width: '100%',\n height: '100%',\n zIndex: 2,\n pointerEvents: isSelected ? 'none' : 'auto',\n cursor: 'pointer',\n }}\n onPointerDown={onClick}\n onTouchStart={onClick}\n >\n <RenderAnnotation\n documentId={documentId}\n pageIndex={pageIndex}\n annotation={{ ...annotation.object, id: annotation.object.id }}\n scaleFactor={scale}\n />\n </div>\n );\n}\n","import { blendModeToCss, PdfAnnotationObject, PdfBlendMode } from '@embedpdf/models';\nimport {\n getAnnotationsByPageIndex,\n getSelectedAnnotationByPageIndex,\n isHighlight,\n isInk,\n isSquiggly,\n isCircle,\n isStrikeout,\n isUnderline,\n TrackedAnnotation,\n isSquare,\n isLine,\n isPolyline,\n isPolygon,\n isFreeText,\n isStamp,\n} from '@embedpdf/plugin-annotation';\nimport { PointerEventHandlers } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/@framework';\nimport { useSelectionCapability } from '@embedpdf/plugin-selection/@framework';\nimport {\n useMemo,\n useState,\n useEffect,\n useCallback,\n MouseEvent,\n Fragment,\n TouchEvent,\n} from '@framework';\n\nimport { useAnnotationCapability } from '../hooks';\nimport { AnnotationContainer } from './annotation-container';\nimport { Highlight } from './text-markup/highlight';\nimport { Underline } from './text-markup/underline';\nimport { Strikeout } from './text-markup/strikeout';\nimport { Squiggly } from './text-markup/squiggly';\nimport { Ink } from './annotations/ink';\nimport { Square } from './annotations/square';\nimport {\n CustomAnnotationRenderer,\n ResizeHandleUI,\n AnnotationSelectionMenuRenderFn,\n VertexHandleUI,\n} from './types';\nimport { Circle } from './annotations/circle';\nimport { Line } from './annotations/line';\nimport { Polyline } from './annotations/polyline';\nimport { Polygon } from './annotations/polygon';\nimport { FreeText } from './annotations/free-text';\nimport { Stamp } from './annotations/stamp';\n\ninterface AnnotationsProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n rotation: number;\n pageWidth: number;\n pageHeight: number;\n selectionMenu?: AnnotationSelectionMenuRenderFn;\n resizeUI?: ResizeHandleUI;\n vertexUI?: VertexHandleUI;\n selectionOutlineColor?: string;\n customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;\n}\n\nexport function Annotations(annotationsProps: AnnotationsProps) {\n const { documentId, pageIndex, scale, selectionMenu } = annotationsProps;\n const { provides: annotationCapability } = useAnnotationCapability();\n const { provides: selectionProvides } = useSelectionCapability();\n const [annotations, setAnnotations] = useState<TrackedAnnotation[]>([]);\n const { register } = usePointerHandlers({ documentId, pageIndex });\n const [selectionState, setSelectionState] = useState<TrackedAnnotation | null>(null);\n const [editingId, setEditingId] = useState<string | null>(null);\n\n // Get scoped API for this document (memoized to prevent infinite loops)\n const annotationProvides = useMemo(\n () => (annotationCapability ? annotationCapability.forDocument(documentId) : null),\n [annotationCapability, documentId],\n );\n\n useEffect(() => {\n if (annotationProvides) {\n // Initialize with current state immediately\n const currentState = annotationProvides.getState();\n setAnnotations(getAnnotationsByPageIndex(currentState, pageIndex));\n setSelectionState(getSelectedAnnotationByPageIndex(currentState, pageIndex));\n\n // Then subscribe to changes\n return annotationProvides.onStateChange((state) => {\n setAnnotations(getAnnotationsByPageIndex(state, pageIndex));\n setSelectionState(getSelectedAnnotationByPageIndex(state, pageIndex));\n });\n }\n }, [annotationProvides, pageIndex]);\n\n const handlers = useMemo(\n (): PointerEventHandlers<MouseEvent> => ({\n onPointerDown: (_, pe) => {\n // Only deselect if clicking directly on the layer (not on an annotation)\n if (pe.target === pe.currentTarget && annotationProvides) {\n annotationProvides.deselectAnnotation();\n setEditingId(null);\n }\n },\n }),\n [annotationProvides],\n );\n\n const handleClick = useCallback(\n (e: MouseEvent | TouchEvent, annotation: TrackedAnnotation) => {\n e.stopPropagation();\n if (annotationProvides && selectionProvides) {\n annotationProvides.selectAnnotation(pageIndex, annotation.object.id);\n selectionProvides.clear();\n if (annotation.object.id !== editingId) {\n setEditingId(null);\n }\n }\n },\n [annotationProvides, selectionProvides, editingId, pageIndex],\n );\n\n useEffect(() => {\n return register(handlers, {\n documentId,\n });\n }, [register, handlers]);\n\n return (\n <>\n {annotations.map((annotation) => {\n const isSelected = selectionState?.object.id === annotation.object.id;\n const isEditing = editingId === annotation.object.id;\n const tool = annotationProvides?.findToolForAnnotation(annotation.object);\n\n if (isInk(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? true}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Ink\n {...obj}\n isSelected={isSelected}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isSquare(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? true}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Square\n {...obj}\n isSelected={isSelected}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isCircle(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? true}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Circle\n {...obj}\n isSelected={isSelected}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isUnderline(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? false}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n zIndex={0}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Underline {...obj} scale={scale} onClick={(e) => handleClick(e, annotation)} />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isStrikeout(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? false}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n zIndex={0}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Strikeout {...obj} scale={scale} onClick={(e) => handleClick(e, annotation)} />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isSquiggly(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? false}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n zIndex={0}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Squiggly {...obj} scale={scale} onClick={(e) => handleClick(e, annotation)} />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isHighlight(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? false}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n zIndex={0}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Multiply),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Highlight {...obj} scale={scale} onClick={(e) => handleClick(e, annotation)} />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isLine(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n vertexConfig={{\n extractVertices: (annotation) => [\n annotation.linePoints.start,\n annotation.linePoints.end,\n ],\n transformAnnotation: (annotation, vertices) => {\n return {\n ...annotation,\n linePoints: {\n start: vertices[0],\n end: vertices[1],\n },\n };\n },\n }}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Fragment>\n <Line\n {...obj}\n isSelected={isSelected}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n </Fragment>\n )}\n </AnnotationContainer>\n );\n }\n\n if (isPolyline(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n vertexConfig={{\n extractVertices: (annotation) => annotation.vertices,\n transformAnnotation: (annotation, vertices) => {\n return {\n ...annotation,\n vertices,\n };\n },\n }}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Fragment>\n <Polyline\n {...obj}\n isSelected={isSelected}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n </Fragment>\n )}\n </AnnotationContainer>\n );\n }\n\n if (isPolygon(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? false}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n vertexConfig={{\n extractVertices: (annotation) => annotation.vertices,\n transformAnnotation: (annotation, vertices) => {\n return {\n ...annotation,\n vertices,\n };\n },\n }}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(obj) => (\n <Fragment>\n <Polygon\n {...obj}\n isSelected={isSelected}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n </Fragment>\n )}\n </AnnotationContainer>\n );\n }\n\n if (isFreeText(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={(tool?.interaction.isDraggable ?? true) && !isEditing}\n isResizable={tool?.interaction.isResizable ?? true}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n onDoubleClick={(e) => {\n e.stopPropagation();\n setEditingId(annotation.object.id);\n }}\n {...annotationsProps}\n >\n {(object) => (\n <FreeText\n isSelected={isSelected}\n isEditing={isEditing}\n annotation={{\n ...annotation,\n object,\n }}\n pageIndex={pageIndex}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n )}\n </AnnotationContainer>\n );\n }\n\n if (isStamp(annotation)) {\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isDraggable={tool?.interaction.isDraggable ?? true}\n isResizable={tool?.interaction.isResizable ?? true}\n lockAspectRatio={tool?.interaction.lockAspectRatio ?? false}\n selectionMenu={selectionMenu}\n onSelect={(e) => handleClick(e, annotation)}\n style={{\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }}\n {...annotationsProps}\n >\n {(_object) => (\n <Stamp\n isSelected={isSelected}\n annotation={annotation}\n documentId={documentId}\n pageIndex={pageIndex}\n scale={scale}\n onClick={(e) => handleClick(e, annotation)}\n />\n )}\n </AnnotationContainer>\n );\n }\n\n /* --------- fallback: an unsupported subtype --------------- */\n return null;\n })}\n </>\n );\n}\n","import { blendModeToCss, PdfAnnotationSubtype, PdfBlendMode, Rect } from '@embedpdf/models';\nimport { AnnotationTool } from '@embedpdf/plugin-annotation';\nimport { useSelectionCapability } from '@embedpdf/plugin-selection/@framework';\n\nimport { useEffect, useState } from '@framework';\nimport { useAnnotationCapability } from '../hooks';\nimport { Highlight } from './text-markup/highlight';\nimport { Squiggly } from './text-markup/squiggly';\nimport { Underline } from './text-markup/underline';\nimport { Strikeout } from './text-markup/strikeout';\n\ninterface TextMarkupProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n}\n\nexport function TextMarkup({ documentId, pageIndex, scale }: TextMarkupProps) {\n const { provides: selectionProvides } = useSelectionCapability();\n const { provides: annotationProvides } = useAnnotationCapability();\n const [rects, setRects] = useState<Array<Rect>>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n const [activeTool, setActiveTool] = useState<AnnotationTool | null>(null);\n\n useEffect(() => {\n if (!selectionProvides) return;\n\n return selectionProvides.forDocument(documentId).onSelectionChange(() => {\n setRects(selectionProvides.forDocument(documentId).getHighlightRectsForPage(pageIndex));\n setBoundingRect(selectionProvides.forDocument(documentId).getBoundingRectForPage(pageIndex));\n });\n }, [selectionProvides, documentId, pageIndex]);\n\n useEffect(() => {\n if (!annotationProvides) return;\n\n // Initialize with current active tool\n setActiveTool(annotationProvides.forDocument(documentId).getActiveTool());\n\n return annotationProvides\n .forDocument(documentId)\n .onActiveToolChange((event) => setActiveTool(event));\n }, [annotationProvides, documentId]);\n\n if (!boundingRect) return null;\n if (!activeTool || !activeTool.defaults) return null;\n\n switch (activeTool.defaults.type) {\n case PdfAnnotationSubtype.UNDERLINE:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Normal),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Underline\n color={activeTool.defaults?.color}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.HIGHLIGHT:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Multiply),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Highlight\n color={activeTool.defaults?.color}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.STRIKEOUT:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Normal),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Strikeout\n color={activeTool.defaults?.color}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.SQUIGGLY:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Normal),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Squiggly\n color={activeTool.defaults?.color}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n default:\n return null;\n }\n}\n","import { AnyPreviewState } from '@embedpdf/plugin-annotation';\nimport { Circle } from './annotations/circle';\nimport { Square } from './annotations/square';\nimport { Polygon } from './annotations/polygon';\nimport { PdfAnnotationSubtype } from '@embedpdf/models';\nimport { Polyline } from './annotations/polyline';\nimport { Line } from './annotations/line';\nimport { Ink } from './annotations/ink';\n\ninterface Props {\n preview: AnyPreviewState;\n scale: number;\n}\n\nexport function PreviewRenderer({ preview, scale }: Props) {\n const { bounds } = preview;\n\n const style = {\n position: 'absolute' as const,\n left: bounds.origin.x * scale,\n top: bounds.origin.y * scale,\n width: bounds.size.width * scale,\n height: bounds.size.height * scale,\n pointerEvents: 'none' as const,\n zIndex: 10,\n };\n\n // Use type guards for proper type narrowing\n if (preview.type === PdfAnnotationSubtype.CIRCLE) {\n return (\n <div style={style}>\n <Circle isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.SQUARE) {\n return (\n <div style={style}>\n <Square isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.POLYGON) {\n return (\n <div style={style}>\n <Polygon isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.POLYLINE) {\n return (\n <div style={style}>\n <Polyline isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.LINE) {\n return (\n <div style={style}>\n <Line isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.INK) {\n return (\n <div style={style}>\n <Ink isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.FREETEXT) {\n return (\n <div style={style}>\n {/* Render a simple dashed border preview */}\n <div\n style={{\n width: '100%',\n height: '100%',\n border: `1px dashed ${preview.data.fontColor || '#000000'}`,\n backgroundColor: 'transparent',\n }}\n />\n </div>\n );\n }\n\n return null;\n}\n","import { useEffect, useMemo, useRef, useState } from '@framework';\nimport { useAnnotationPlugin } from '../hooks';\nimport { AnyPreviewState, HandlerServices } from '@embedpdf/plugin-annotation';\nimport { PreviewRenderer } from './preview-renderer';\n\ninterface Props {\n documentId: string;\n pageIndex: number;\n scale: number;\n}\n\nexport function AnnotationPaintLayer({ documentId, pageIndex, scale }: Props) {\n const { plugin: annotationPlugin } = useAnnotationPlugin();\n const [previews, setPreviews] = useState<Map<string, AnyPreviewState>>(new Map());\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n\n const services = useMemo<HandlerServices>(\n () => ({\n requestFile: ({ accept, onFile }) => {\n if (!fileInputRef.current) return;\n const input = fileInputRef.current;\n input.accept = accept;\n input.onchange = (e) => {\n const file = (e.target as HTMLInputElement).files?.[0];\n if (file) {\n onFile(file);\n input.value = '';\n }\n };\n input.click();\n },\n processImage: ({ source, maxWidth, maxHeight, onComplete }) => {\n const canvas = canvasRef.current;\n if (!canvas || !canvas.getContext) return;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n\n const img = new Image();\n img.crossOrigin = 'Anonymous';\n img.onload = () => {\n let { naturalWidth: width, naturalHeight: height } = img;\n\n // --- SCALING LOGIC ---\n // Calculate the scale factor to fit within maxWidth and maxHeight\n const scaleX = maxWidth ? maxWidth / width : 1;\n const scaleY = maxHeight ? maxHeight / height : 1;\n const scaleFactor = Math.min(scaleX, scaleY, 1); // Ensure we don't scale up\n\n const finalWidth = width * scaleFactor;\n const finalHeight = height * scaleFactor;\n\n canvas.width = finalWidth;\n canvas.height = finalHeight;\n ctx.drawImage(img, 0, 0, finalWidth, finalHeight);\n\n const imageData = ctx.getImageData(0, 0, finalWidth, finalHeight);\n if (typeof source !== 'string') URL.revokeObjectURL(img.src);\n\n onComplete({ imageData, width: finalWidth, height: finalHeight });\n };\n img.src = typeof source === 'string' ? source : URL.createObjectURL(source);\n },\n }),\n [],\n );\n\n useEffect(() => {\n if (!annotationPlugin) return;\n\n return annotationPlugin.registerPageHandlers(documentId, pageIndex, scale, {\n services,\n onPreview: (toolId, state) => {\n setPreviews((prev) => {\n const next = new Map(prev);\n if (state) {\n next.set(toolId, state);\n } else {\n next.delete(toolId);\n }\n return next;\n });\n },\n });\n }, [documentId, pageIndex, scale, annotationPlugin, services]);\n\n return (\n <>\n {/* Hidden DOM elements required by services */}\n <input ref={fileInputRef} type=\"file\" style={{ display: 'none' }} />\n <canvas ref={canvasRef} style={{ display: 'none' }} />\n\n {/* Render any active previews from any tool */}\n {Array.from(previews.entries()).map(([toolId, preview]) => (\n <PreviewRenderer key={toolId} preview={preview} scale={scale} />\n ))}\n </>\n );\n}\n","import { HTMLAttributes, CSSProperties, useMemo } from '@framework';\nimport { useDocumentState } from '@embedpdf/core/@framework';\nimport { Annotations } from './annotations';\nimport { TextMarkup } from './text-markup';\nimport {\n ResizeHandleUI,\n VertexHandleUI,\n CustomAnnotationRenderer,\n AnnotationSelectionMenuRenderFn,\n} from './types';\nimport { AnnotationPaintLayer } from './annotation-paint-layer';\nimport { PdfAnnotationObject, Rotation } from '@embedpdf/models';\n\ntype AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n /** The ID of the document that this layer displays annotations for */\n documentId: string;\n pageIndex: number;\n scale?: number;\n rotation?: number;\n /** Customize selection menu across all annotations on this layer */\n selectionMenu?: AnnotationSelectionMenuRenderFn;\n style?: CSSProperties;\n /** Customize resize handles */\n resizeUI?: ResizeHandleUI;\n /** Customize vertex handles */\n vertexUI?: VertexHandleUI;\n /** Customize selection outline color */\n selectionOutlineColor?: string;\n /** Customize annotation renderer */\n customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;\n};\n\nexport function AnnotationLayer({\n style,\n documentId,\n pageIndex,\n scale: overrideScale,\n rotation: overrideRotation,\n selectionMenu,\n resizeUI,\n vertexUI,\n selectionOutlineColor,\n customAnnotationRenderer,\n ...props\n}: AnnotationLayerProps) {\n const documentState = useDocumentState(documentId);\n const page = documentState?.document?.pages?.[pageIndex];\n const width = page?.size?.width ?? 0;\n const height = page?.size?.height ?? 0;\n\n const actualScale = useMemo(() => {\n if (overrideScale !== undefined) return overrideScale;\n return documentState?.scale ?? 1;\n }, [overrideScale, documentState?.scale]);\n\n const actualRotation = useMemo(() => {\n if (overrideRotation !== undefined) return overrideRotation;\n return documentState?.rotation ?? Rotation.Degree0;\n }, [overrideRotation, documentState?.rotation]);\n\n return (\n <div\n style={{\n ...style,\n }}\n {...props}\n >\n <Annotations\n documentId={documentId}\n selectionMenu={selectionMenu}\n pageIndex={pageIndex}\n scale={actualScale}\n rotation={actualRotation}\n pageWidth={width}\n pageHeight={height}\n resizeUI={resizeUI}\n vertexUI={vertexUI}\n selectionOutlineColor={selectionOutlineColor}\n customAnnotationRenderer={customAnnotationRenderer}\n />\n <TextMarkup documentId={documentId} pageIndex={pageIndex} scale={actualScale} />\n <AnnotationPaintLayer documentId={documentId} pageIndex={pageIndex} scale={actualScale} />\n </div>\n );\n}\n"],"names":["suppressContentEditableWarningProps","suppressContentEditableWarning","useAnnotationPlugin","usePlugin","AnnotationPlugin","id","useAnnotationCapability","useCapability","AnnotationContainer","scale","documentId","pageIndex","rotation","pageWidth","pageHeight","trackedAnnotation","children","isSelected","isDraggable","isResizable","lockAspectRatio","style","vertexConfig","selectionMenu","outlineOffset","onDoubleClick","onSelect","zIndex","resizeUI","vertexUI","selectionOutlineColor","customAnnotationRenderer","props","preview","setPreview","useState","object","provides","annotationCapability","canModifyAnnotations","useDocumentPermissions","gestureBaseRef","useRef","effectiveIsDraggable","effectiveIsResizable","annotationProvides","useMemo","forDocument","currentObject","HANDLE_COLOR","color","VERTEX_COLOR","HANDLE_SIZE","size","VERTEX_SIZE","dragProps","vertices","resize","useInteractionHandles","controller","element","rect","extractVertices","constraints","minWidth","minHeight","boundingBox","width","height","maintainAspectRatio","pageRotation","enabled","onUpdate","event","_a","transformData","type","state","current","transformType","base","changes","transformAnnotation","patched","metadata","prev","updateAnnotation","handleSize","spacing","offsetMode","includeSides","vertexSize","includeVertices","guardedOnDoubleClick","doubleProps","useDoublePressProps","useEffect","jsxs","position","left","origin","x","top","y","outline","pointerEvents","touchAction","cursor","childrenRender","customRender","annotation","map","key","hProps","component","backgroundColor","jsx","vProps","CounterRotate","context","selected","placement","suggestTop","Highlight","opacity","segmentRects","onClick","Fragment","b","i","onPointerDown","onTouchStart","background","Underline","thickness","r","bottom","Strikeout","transform","Squiggly","amplitude","period","svgDataUri","encodeURIComponent","backgroundImage","backgroundRepeat","backgroundSize","Ink","strokeWidth","inkList","paths","points","d","forEach","lx","ly","trim","overflow","viewBox","fill","stroke","strokeLinecap","strokeLinejoin","Square","strokeColor","strokeStyle","PdfAnnotationBorderStyle","SOLID","strokeDashArray","outerW","outerH","Math","max","svgWidth","svgHeight","DASHED","strokeDasharray","join","Circle","cx","cy","rx","ry","innerW","innerH","Line","linePoints","lineEndings","x1","y1","x2","y2","start","end","endings","angle","atan2","patching","createEnding","PI","filled","Polyline","localPts","pathData","length","first","rest","p","toAngle","a","startRad","endRad","Polygon","currentVertex","allPoints","isPreview","isPreviewing","FreeText","isEditing","editorRef","isIOS","setIsIOS","editor","focus","selection","window","getSelection","range","document","createRange","selectNodeContents","collapse","removeAllRanges","addRange","useLayoutEffect","nav","navigator","ios","test","userAgent","platform","maxTouchPoints","computedFontPx","fontSize","needsComp","adjustedFontPx","scaleComp","invScalePercent","ref","onBlur","contents","innerText","tabIndex","fontColor","fontFamily","standardFontCss","textAlign","textAlignmentToCss","flexDirection","justifyContent","verticalAlign","PdfVerticalAlignment","Top","Middle","display","lineHeight","transformOrigin","contentEditable","RenderAnnotation","scaleFactor","imageUrl","setImageUrl","urlRef","task","renderAnnotation","options","dpr","devicePixelRatio","wait","blob","url","URL","createObjectURL","ignore","revokeObjectURL","abort","code","PdfErrorCode","Cancelled","message","src","onLoad","Stamp","Annotations","annotationsProps","selectionProvides","useSelectionCapability","annotations","setAnnotations","register","usePointerHandlers","selectionState","setSelectionState","editingId","setEditingId","currentState","getState","getAnnotationsByPageIndex","getSelectedAnnotationByPageIndex","onStateChange","handlers","_","pe","target","currentTarget","deselectAnnotation","handleClick","useCallback","e","stopPropagation","selectAnnotation","clear","tool","findToolForAnnotation","isInk","interaction","mixBlendMode","blendModeToCss","blendMode","PdfBlendMode","Normal","obj","isSquare","isCircle","isUnderline","isStrikeout","isSquiggly","isHighlight","Multiply","isLine","isPolyline","isPolygon","isFreeText","isStamp","_object","TextMarkup","rects","setRects","boundingRect","setBoundingRect","activeTool","setActiveTool","onSelectionChange","getHighlightRectsForPage","getBoundingRectForPage","getActiveTool","onActiveToolChange","defaults","PdfAnnotationSubtype","UNDERLINE","inset","_b","_c","HIGHLIGHT","_d","_e","_f","STRIKEOUT","_g","_h","_i","SQUIGGLY","_j","_k","_l","PreviewRenderer","bounds","CIRCLE","data","SQUARE","POLYGON","POLYLINE","LINE","INK","FREETEXT","border","AnnotationPaintLayer","plugin","annotationPlugin","previews","setPreviews","Map","fileInputRef","canvasRef","services","requestFile","accept","onFile","input","onchange","file","files","value","click","processImage","source","maxWidth","maxHeight","onComplete","canvas","getContext","ctx","img","Image","crossOrigin","onload","naturalWidth","naturalHeight","scaleX","scaleY","min","finalWidth","finalHeight","drawImage","imageData","getImageData","registerPageHandlers","onPreview","toolId","next","set","delete","Array","from","entries","overrideScale","overrideRotation","documentState","useDocumentState","page","pages","actualScale","actualRotation","Rotation","Degree0","setState","initialDocumentState","scope","newState"],"mappings":"0XAoBaA,EAAsC,CACjDC,gCAAgC,GCbrBC,EAAsB,IAAMC,YAA4BC,EAAAA,iBAAiBC,IACzEC,EAA0B,IAAMC,gBAAgCH,EAAAA,iBAAiBC,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