@embedpdf/plugin-redaction 2.15.0 → 3.0.0-next.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/LICENSE +192 -21
- package/README.md +109 -0
- package/dist/index.cjs +227 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +89 -0
- package/dist/index.d.ts +89 -1
- package/dist/index.js +220 -1532
- package/dist/index.js.map +1 -1
- package/package.json +22 -67
- package/dist/lib/actions.d.ts +0 -113
- package/dist/lib/handlers/index.d.ts +0 -0
- package/dist/lib/index.d.ts +0 -11
- package/dist/lib/manifest.d.ts +0 -4
- package/dist/lib/redaction-plugin.d.ts +0 -153
- package/dist/lib/reducer.d.ts +0 -6
- package/dist/lib/selectors.d.ts +0 -5
- package/dist/lib/tools.d.ts +0 -64
- package/dist/lib/types.d.ts +0 -142
- package/dist/preact/adapter.d.ts +0 -10
- package/dist/preact/annotation.d.ts +0 -1
- package/dist/preact/core.d.ts +0 -1
- package/dist/preact/index.cjs +0 -2
- package/dist/preact/index.cjs.map +0 -1
- package/dist/preact/index.d.ts +0 -1
- package/dist/preact/index.js +0 -520
- package/dist/preact/index.js.map +0 -1
- package/dist/preact/utils.d.ts +0 -1
- package/dist/react/adapter.d.ts +0 -2
- package/dist/react/annotation.d.ts +0 -1
- package/dist/react/core.d.ts +0 -1
- package/dist/react/index.cjs +0 -2
- package/dist/react/index.cjs.map +0 -1
- package/dist/react/index.d.ts +0 -1
- package/dist/react/index.js +0 -519
- package/dist/react/index.js.map +0 -1
- package/dist/react/utils.d.ts +0 -1
- package/dist/shared/components/annotations/index.d.ts +0 -2
- package/dist/shared/components/annotations/redact-area.d.ts +0 -18
- package/dist/shared/components/annotations/redact-highlight.d.ts +0 -18
- package/dist/shared/components/highlight.d.ts +0 -14
- package/dist/shared/components/index.d.ts +0 -5
- package/dist/shared/components/marquee-redact.d.ts +0 -15
- package/dist/shared/components/pending-redactions.d.ts +0 -12
- package/dist/shared/components/redact-renderer-registration.d.ts +0 -5
- package/dist/shared/components/redact-renderers.d.ts +0 -7
- package/dist/shared/components/redaction-layer.d.ts +0 -16
- package/dist/shared/components/selection-redact.d.ts +0 -7
- package/dist/shared/components/types.d.ts +0 -9
- package/dist/shared/hooks/index.d.ts +0 -1
- package/dist/shared/hooks/use-redaction.d.ts +0 -15
- package/dist/shared/index.d.ts +0 -4
- package/dist/shared-preact/components/annotations/index.d.ts +0 -2
- package/dist/shared-preact/components/annotations/redact-area.d.ts +0 -18
- package/dist/shared-preact/components/annotations/redact-highlight.d.ts +0 -18
- package/dist/shared-preact/components/highlight.d.ts +0 -14
- package/dist/shared-preact/components/index.d.ts +0 -5
- package/dist/shared-preact/components/marquee-redact.d.ts +0 -15
- package/dist/shared-preact/components/pending-redactions.d.ts +0 -12
- package/dist/shared-preact/components/redact-renderer-registration.d.ts +0 -5
- package/dist/shared-preact/components/redact-renderers.d.ts +0 -7
- package/dist/shared-preact/components/redaction-layer.d.ts +0 -16
- package/dist/shared-preact/components/selection-redact.d.ts +0 -7
- package/dist/shared-preact/components/types.d.ts +0 -9
- package/dist/shared-preact/hooks/index.d.ts +0 -1
- package/dist/shared-preact/hooks/use-redaction.d.ts +0 -15
- package/dist/shared-preact/index.d.ts +0 -4
- package/dist/shared-react/components/annotations/index.d.ts +0 -2
- package/dist/shared-react/components/annotations/redact-area.d.ts +0 -18
- package/dist/shared-react/components/annotations/redact-highlight.d.ts +0 -18
- package/dist/shared-react/components/highlight.d.ts +0 -14
- package/dist/shared-react/components/index.d.ts +0 -5
- package/dist/shared-react/components/marquee-redact.d.ts +0 -15
- package/dist/shared-react/components/pending-redactions.d.ts +0 -12
- package/dist/shared-react/components/redact-renderer-registration.d.ts +0 -5
- package/dist/shared-react/components/redact-renderers.d.ts +0 -7
- package/dist/shared-react/components/redaction-layer.d.ts +0 -16
- package/dist/shared-react/components/selection-redact.d.ts +0 -7
- package/dist/shared-react/components/types.d.ts +0 -9
- package/dist/shared-react/hooks/index.d.ts +0 -1
- package/dist/shared-react/hooks/use-redaction.d.ts +0 -15
- package/dist/shared-react/index.d.ts +0 -4
- package/dist/svelte/components/RedactRendererRegistration.svelte.d.ts +0 -7
- package/dist/svelte/components/annotations/RedactArea.svelte.d.ts +0 -5
- package/dist/svelte/components/annotations/RedactHighlight.svelte.d.ts +0 -5
- package/dist/svelte/components/annotations/index.d.ts +0 -2
- package/dist/svelte/components/highlight.svelte.d.ts +0 -14
- package/dist/svelte/components/index.d.ts +0 -8
- package/dist/svelte/components/marquee-redact.svelte.d.ts +0 -16
- package/dist/svelte/components/pending-redactions.svelte.d.ts +0 -15
- package/dist/svelte/components/redact-renderers.d.ts +0 -7
- package/dist/svelte/components/redaction-layer.svelte.d.ts +0 -20
- package/dist/svelte/components/selection-redact.svelte.d.ts +0 -8
- package/dist/svelte/hooks/index.d.ts +0 -1
- package/dist/svelte/hooks/use-redaction.svelte.d.ts +0 -21
- package/dist/svelte/index.cjs +0 -2
- package/dist/svelte/index.cjs.map +0 -1
- package/dist/svelte/index.d.ts +0 -5
- package/dist/svelte/index.js +0 -801
- package/dist/svelte/index.js.map +0 -1
- package/dist/svelte/types.d.ts +0 -10
- package/dist/vue/components/annotations/index.d.ts +0 -2
- package/dist/vue/components/annotations/redact-area.vue.d.ts +0 -6
- package/dist/vue/components/annotations/redact-highlight.vue.d.ts +0 -6
- package/dist/vue/components/highlight.vue.d.ts +0 -17
- package/dist/vue/components/index.d.ts +0 -8
- package/dist/vue/components/marquee-redact.vue.d.ts +0 -19
- package/dist/vue/components/pending-redactions.vue.d.ts +0 -68
- package/dist/vue/components/redact-renderer-registration.vue.d.ts +0 -13
- package/dist/vue/components/redact-renderers.d.ts +0 -7
- package/dist/vue/components/redaction-layer.vue.d.ts +0 -50
- package/dist/vue/components/selection-redact.vue.d.ts +0 -8
- package/dist/vue/components/types.d.ts +0 -9
- package/dist/vue/hooks/index.d.ts +0 -1
- package/dist/vue/hooks/use-redaction.d.ts +0 -12
- package/dist/vue/index.cjs +0 -2
- package/dist/vue/index.cjs.map +0 -1
- package/dist/vue/index.d.ts +0 -5
- package/dist/vue/index.js +0 -638
- package/dist/vue/index.js.map +0 -1
package/dist/react/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/shared/components/annotations/redact-highlight.tsx","../../src/shared/components/annotations/redact-area.tsx","../../src/shared/components/redact-renderers.tsx","../../src/shared/components/redact-renderer-registration.tsx","../../src/shared/hooks/use-redaction.ts","../../src/shared/components/marquee-redact.tsx","../../src/shared/components/highlight.tsx","../../src/shared/components/selection-redact.tsx","../../src/shared/components/pending-redactions.tsx","../../src/shared/components/redaction-layer.tsx","../../src/shared/index.ts"],"sourcesContent":["import { CSSProperties, MouseEvent, useState } from '@framework';\nimport {\n PdfRedactAnnoObject,\n PdfStandardFont,\n PdfTextAlignment,\n Rect,\n standardFontCssProperties,\n textAlignmentToCss,\n} from '@embedpdf/models';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\n\nexport interface RedactHighlightProps {\n annotation: TrackedAnnotation<PdfRedactAnnoObject>;\n isSelected: boolean;\n scale: number;\n pageIndex: number;\n onClick?: (e: MouseEvent<Element>) => void;\n style?: CSSProperties;\n}\n\n/**\n * Renders a text-based redact annotation using QuadPoints/segmentRects.\n * Default: shows strokeColor (C) border only, no fill.\n * Hovered: shows redaction preview with color (IC) as background fill + overlayText.\n * Selected: no border (AnnotationContainer handles selection styling).\n */\nexport function RedactHighlight({\n annotation,\n isSelected,\n scale,\n onClick,\n style,\n}: RedactHighlightProps) {\n const [isHovered, setIsHovered] = useState(false);\n const { object } = annotation;\n\n const segmentRects = object.segmentRects ?? [];\n const rect = object.rect;\n\n // C - Border/stroke color\n const strokeColor = object.strokeColor ?? '#FF0000';\n // IC - Interior color (background fill when redaction is applied)\n const color = object.color ?? '#000000';\n // CA - Opacity (0-1)\n const opacity = object.opacity ?? 1;\n // OC - Overlay text color (Adobe extension), fallback to fontColor\n const textColor = object.fontColor ?? object.overlayColor ?? '#FFFFFF';\n // Overlay text properties\n const overlayText = object.overlayText;\n const overlayTextRepeat = object.overlayTextRepeat ?? false;\n const fontSize = object.fontSize ?? 12;\n const fontFamily = object.fontFamily ?? PdfStandardFont.Helvetica;\n const textAlign = object.textAlign ?? PdfTextAlignment.Center;\n\n // Calculate how many times to repeat text (approximate)\n const renderOverlayText = () => {\n if (!overlayText) return null;\n if (!overlayTextRepeat) return overlayText;\n // Repeat text multiple times to fill the space\n const reps = 10; // Enough repetitions to fill most containers\n return Array(reps).fill(overlayText).join(' ');\n };\n\n return (\n <div\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n style={{ position: 'absolute', inset: 0 }}\n >\n {segmentRects.map((b: Rect, i: number) => (\n <div\n key={i}\n onPointerDown={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 // Default: transparent background with strokeColor (C) border\n // Hovered: color (IC) background fill, no border\n // Selected: no border (container handles it)\n background: isHovered ? color : 'transparent',\n border: !isHovered ? `2px solid ${strokeColor}` : 'none',\n opacity: isHovered ? opacity : 1,\n boxSizing: 'border-box',\n pointerEvents: 'auto',\n cursor: 'pointer',\n display: 'flex',\n alignItems: 'center',\n justifyContent:\n textAlign === PdfTextAlignment.Left\n ? 'flex-start'\n : textAlign === PdfTextAlignment.Right\n ? 'flex-end'\n : 'center',\n overflow: 'hidden',\n ...style,\n }}\n >\n {isHovered && overlayText && (\n <span\n style={{\n color: textColor,\n fontSize: Math.min(fontSize * scale, b.size.height * scale * 0.8),\n ...standardFontCssProperties(fontFamily),\n textAlign: textAlignmentToCss(textAlign),\n whiteSpace: overlayTextRepeat ? 'normal' : 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n lineHeight: 1,\n }}\n >\n {renderOverlayText()}\n </span>\n )}\n </div>\n ))}\n </div>\n );\n}\n","import { CSSProperties, MouseEvent, useState } from '@framework';\nimport {\n PdfRedactAnnoObject,\n PdfStandardFont,\n PdfTextAlignment,\n standardFontCssProperties,\n textAlignmentToCss,\n} from '@embedpdf/models';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\n\nexport interface RedactAreaProps {\n annotation: TrackedAnnotation<PdfRedactAnnoObject>;\n isSelected: boolean;\n scale: number;\n pageIndex: number;\n onClick?: (e: MouseEvent<Element>) => void;\n style?: CSSProperties;\n}\n\n/**\n * Renders an area-based redact annotation (marquee redaction).\n * Default: shows strokeColor (C) border only, no fill.\n * Hovered: shows redaction preview with color (IC) as background fill + overlayText.\n * Selected: no border (AnnotationContainer handles selection styling).\n */\nexport function RedactArea({ annotation, isSelected, scale, onClick, style }: RedactAreaProps) {\n const [isHovered, setIsHovered] = useState(false);\n const { object } = annotation;\n\n // C - Border/stroke color\n const strokeColor = object.strokeColor ?? '#FF0000';\n // IC - Interior color (background fill when redaction is applied)\n const color = object.color ?? '#000000';\n // CA - Opacity (0-1)\n const opacity = object.opacity ?? 1;\n // OC - Overlay text color (Adobe extension), fallback to fontColor\n const textColor = object.fontColor ?? object.overlayColor ?? '#FFFFFF';\n // Overlay text properties\n const overlayText = object.overlayText;\n const overlayTextRepeat = object.overlayTextRepeat ?? false;\n const fontSize = object.fontSize ?? 12;\n const fontFamily = object.fontFamily ?? PdfStandardFont.Helvetica;\n const textAlign = object.textAlign ?? PdfTextAlignment.Center;\n\n // Calculate how many times to repeat text (approximate)\n const renderOverlayText = () => {\n if (!overlayText) return null;\n if (!overlayTextRepeat) return overlayText;\n // Repeat text multiple times to fill the space\n const reps = 10; // Enough repetitions to fill most containers\n return Array(reps).fill(overlayText).join(' ');\n };\n\n return (\n <div\n onPointerDown={!isSelected ? onClick : undefined}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n style={{\n position: 'absolute',\n inset: 0,\n // Default: transparent background with strokeColor (C) border\n // Hovered: color (IC) background fill, no border\n // Selected: no border (container handles it)\n background: isHovered ? color : 'transparent',\n border: !isHovered ? `2px solid ${strokeColor}` : 'none',\n opacity: isHovered ? opacity : 1,\n boxSizing: 'border-box',\n pointerEvents: 'auto',\n cursor: isSelected ? 'move' : 'pointer',\n display: 'flex',\n alignItems: 'center',\n justifyContent:\n textAlign === PdfTextAlignment.Left\n ? 'flex-start'\n : textAlign === PdfTextAlignment.Right\n ? 'flex-end'\n : 'center',\n overflow: 'hidden',\n ...style,\n }}\n >\n {isHovered && overlayText && (\n <span\n style={{\n color: textColor,\n fontSize: fontSize * scale,\n ...standardFontCssProperties(fontFamily),\n textAlign: textAlignmentToCss(textAlign),\n whiteSpace: overlayTextRepeat ? 'normal' : 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n padding: '4px',\n }}\n >\n {renderOverlayText()}\n </span>\n )}\n </div>\n );\n}\n","import { PdfAnnotationSubtype, PdfRedactAnnoObject } from '@embedpdf/models';\nimport { createRenderer, BoxedAnnotationRenderer } from '@embedpdf/plugin-annotation/@framework';\nimport { RedactHighlight } from './annotations/redact-highlight';\nimport { RedactArea } from './annotations/redact-area';\n\n/**\n * Boxed annotation renderers for Redact annotations.\n * Type safety is enforced at definition time via createRenderer.\n * These are automatically registered with the annotation plugin via context.\n */\nexport const redactRenderers: BoxedAnnotationRenderer[] = [\n createRenderer<PdfRedactAnnoObject>({\n id: 'redactHighlight',\n matches: (a): a is PdfRedactAnnoObject =>\n a.type === PdfAnnotationSubtype.REDACT &&\n 'segmentRects' in a &&\n (a.segmentRects?.length ?? 0) > 0,\n render: ({ annotation, isSelected, scale, pageIndex, onClick }) => (\n <RedactHighlight\n annotation={annotation}\n isSelected={isSelected}\n scale={scale}\n pageIndex={pageIndex}\n onClick={onClick}\n />\n ),\n interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },\n useAppearanceStream: false,\n }),\n createRenderer<PdfRedactAnnoObject>({\n id: 'redactArea',\n matches: (a): a is PdfRedactAnnoObject =>\n a.type === PdfAnnotationSubtype.REDACT &&\n (!('segmentRects' in a) || !(a.segmentRects?.length ?? 0)),\n render: ({ annotation, isSelected, scale, pageIndex, onClick }) => (\n <RedactArea\n annotation={annotation}\n isSelected={isSelected}\n scale={scale}\n pageIndex={pageIndex}\n onClick={onClick}\n />\n ),\n interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },\n useAppearanceStream: false,\n }),\n];\n","import { useRegisterRenderers } from '@embedpdf/plugin-annotation/@framework';\nimport { redactRenderers } from '../components/redact-renderers';\n\n/**\n * Utility component that registers redact renderers once at app level.\n * Added via addUtility() so it mounts once, not per-page.\n */\nexport function RedactRendererRegistration() {\n useRegisterRenderers(redactRenderers);\n return null;\n}\n","import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport {\n initialDocumentState,\n RedactionPlugin,\n RedactionDocumentState,\n RedactionScope,\n} from '@embedpdf/plugin-redaction';\nimport { useState, useEffect, useMemo } from '@framework';\n\nexport const useRedactionPlugin = () => usePlugin<RedactionPlugin>(RedactionPlugin.id);\nexport const useRedactionCapability = () => useCapability<RedactionPlugin>(RedactionPlugin.id);\n\nexport const useRedaction = (\n documentId: string,\n): {\n state: RedactionDocumentState;\n provides: RedactionScope | null;\n} => {\n const { provides } = useRedactionCapability();\n const [state, setState] = useState<RedactionDocumentState>(initialDocumentState);\n\n const scope = useMemo(\n () => (provides ? provides.forDocument(documentId) : null),\n [provides, documentId],\n );\n\n useEffect(() => {\n if (!scope) {\n setState(initialDocumentState);\n return;\n }\n\n // Set initial state\n try {\n setState(scope.getState());\n } catch (e) {\n // Handle case where state might not be ready\n setState(initialDocumentState);\n }\n\n // Subscribe to changes\n const unsubscribe = scope.onStateChange((newState) => {\n setState(newState);\n });\n\n return unsubscribe;\n }, [scope]);\n\n return {\n state,\n provides: scope,\n };\n};\n","import { useEffect, useState } from '@framework';\nimport { useDocumentState } from '@embedpdf/core/@framework';\nimport { Rect } from '@embedpdf/models';\n\nimport { useRedactionPlugin } from '../hooks/use-redaction';\n\ninterface MarqueeRedactProps {\n /** The ID of the document */\n documentId: string;\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale?: number;\n /** Optional CSS class applied to the marquee rectangle */\n className?: string;\n /** Stroke / fill colours (defaults below) */\n stroke?: string;\n fill?: string;\n}\n\nexport const MarqueeRedact = ({\n documentId,\n pageIndex,\n scale: scaleOverride,\n className,\n stroke,\n fill = 'transparent',\n}: MarqueeRedactProps) => {\n const { plugin: redactionPlugin } = useRedactionPlugin();\n const documentState = useDocumentState(documentId);\n\n const [rect, setRect] = useState<Rect | null>(null);\n\n const scale = scaleOverride ?? documentState?.scale ?? 1;\n\n // Get stroke color from plugin (annotation mode uses tool defaults, legacy uses red)\n // Allow prop override for backwards compatibility\n const strokeColor = stroke ?? redactionPlugin?.getPreviewStrokeColor() ?? 'red';\n\n useEffect(() => {\n if (!redactionPlugin || !documentId) return;\n return redactionPlugin.onRedactionMarqueeChange(documentId, (data) => {\n setRect(data.pageIndex === pageIndex ? data.rect : null);\n });\n }, [redactionPlugin, documentId, pageIndex]);\n\n if (!rect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n pointerEvents: 'none',\n left: rect.origin.x * scale,\n top: rect.origin.y * scale,\n width: rect.size.width * scale,\n height: rect.size.height * scale,\n border: `1px solid ${strokeColor}`,\n background: fill,\n boxSizing: 'border-box',\n }}\n className={className}\n />\n );\n};\n","import { HTMLAttributes, CSSProperties, MouseEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype HighlightProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n color?: string;\n opacity?: number;\n border?: string;\n rects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n};\n\nexport function Highlight({\n color = '#FFFF00',\n opacity = 1,\n border = '1px solid red',\n rects,\n rect,\n scale,\n onClick,\n style,\n ...props\n}: HighlightProps) {\n return (\n <>\n {rects.map((b, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n style={{\n position: 'absolute',\n border,\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 {...props}\n />\n ))}\n </>\n );\n}\n","import { Rect } from '@embedpdf/models';\nimport { useEffect, useState } from '@framework';\nimport { useRedactionPlugin } from '../hooks';\nimport { Highlight } from './highlight';\n\ninterface SelectionRedactProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n}\n\nexport function SelectionRedact({ documentId, pageIndex, scale }: SelectionRedactProps) {\n const { plugin: redactionPlugin } = useRedactionPlugin();\n const [rects, setRects] = useState<Array<Rect>>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n\n // Get stroke color from plugin (annotation mode uses tool defaults, legacy uses red)\n const strokeColor = redactionPlugin?.getPreviewStrokeColor() ?? 'red';\n\n useEffect(() => {\n if (!redactionPlugin) return;\n return redactionPlugin.onRedactionSelectionChange(documentId, (formattedSelection) => {\n const selection = formattedSelection.find((s) => s.pageIndex === pageIndex);\n setRects(selection?.segmentRects ?? []);\n setBoundingRect(selection?.rect ?? null);\n });\n }, [redactionPlugin, documentId, pageIndex]);\n\n if (!boundingRect) return null;\n\n return (\n <div\n style={{\n mixBlendMode: 'normal',\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Highlight\n color={'transparent'}\n opacity={1}\n rects={rects}\n scale={scale}\n border={`1px solid ${strokeColor}`}\n />\n </div>\n );\n}\n","import { Fragment, useEffect, useState, useCallback, MouseEvent } from '@framework';\nimport { CounterRotate } from '@embedpdf/utils/@framework';\nimport { useRedactionCapability } from '../hooks';\nimport { RedactionItem } from '@embedpdf/plugin-redaction';\nimport { Highlight } from './highlight';\nimport { RedactionSelectionMenuRenderFn } from './types';\nimport { Rotation } from '@embedpdf/models';\n\ninterface PendingRedactionsProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n rotation: Rotation;\n bboxStroke?: string;\n selectionMenu?: RedactionSelectionMenuRenderFn;\n}\n\nexport function PendingRedactions({\n documentId,\n pageIndex,\n scale,\n bboxStroke = 'rgba(0,0,0,0.8)',\n rotation = Rotation.Degree0,\n selectionMenu,\n}: PendingRedactionsProps) {\n const { provides: redaction } = useRedactionCapability();\n const [items, setItems] = useState<RedactionItem[]>([]);\n const [selectedId, setSelectedId] = useState<string | null>(null);\n\n useEffect(() => {\n if (!redaction) return;\n\n // Use document-scoped hooks so we only receive events for this document\n const scoped = redaction.forDocument(documentId);\n\n // Initialize with current state - only show legacy mode items\n const currentState = scoped.getState();\n setItems((currentState.pending[pageIndex] ?? []).filter((it) => it.source === 'legacy'));\n setSelectedId(\n currentState.selected && currentState.selected.page === pageIndex\n ? currentState.selected.id\n : null,\n );\n\n // Subscribe to future changes - only show legacy mode items\n const off1 = scoped.onPendingChange((map) => {\n setItems((map[pageIndex] ?? []).filter((it) => it.source === 'legacy'));\n });\n const off2 = scoped.onSelectedChange((sel) => {\n setSelectedId(sel && sel.page === pageIndex ? sel.id : null);\n });\n\n return () => {\n off1?.();\n off2?.();\n };\n }, [redaction, documentId, pageIndex]);\n\n const select = useCallback(\n (e: MouseEvent, id: string) => {\n e.stopPropagation();\n if (!redaction) return;\n redaction.forDocument(documentId).selectPending(pageIndex, id);\n },\n [redaction, documentId, pageIndex],\n );\n\n if (!items.length) return null;\n\n return (\n <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>\n {items.map((it) => {\n if (it.kind === 'area') {\n const r = it.rect;\n return (\n <Fragment key={it.id}>\n <div\n style={{\n position: 'absolute',\n left: r.origin.x * scale,\n top: r.origin.y * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n outline: selectedId === it.id ? `1px solid ${bboxStroke}` : 'none',\n outlineOffset: '2px',\n border: `1px solid ${it.markColor}`,\n pointerEvents: 'auto',\n cursor: 'pointer',\n }}\n onPointerDown={(e) => select(e, it.id)}\n />\n {selectionMenu && (\n <CounterRotate\n rect={{\n origin: { x: r.origin.x * scale, y: r.origin.y * scale },\n size: { width: r.size.width * scale, height: r.size.height * scale },\n }}\n rotation={rotation}\n >\n {(props) =>\n selectionMenu({\n ...props,\n context: {\n type: 'redaction',\n item: it,\n pageIndex,\n },\n selected: selectedId === it.id,\n placement: {\n suggestTop: false,\n },\n })\n }\n </CounterRotate>\n )}\n </Fragment>\n );\n }\n\n const b = it.rect;\n return (\n <Fragment key={it.id}>\n <div\n style={{\n position: 'absolute',\n left: b.origin.x * scale,\n top: b.origin.y * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background: 'transparent',\n outline: selectedId === it.id ? `1px solid ${bboxStroke}` : 'none',\n outlineOffset: '2px',\n pointerEvents: 'auto',\n cursor: selectedId === it.id ? 'pointer' : 'default',\n }}\n >\n <Highlight\n rect={b}\n rects={it.rects}\n color=\"transparent\"\n border={`1px solid ${it.markColor}`}\n scale={scale}\n onClick={(e) => select(e, it.id)}\n />\n </div>\n {selectionMenu && (\n <CounterRotate\n rect={{\n origin: { x: b.origin.x * scale, y: b.origin.y * scale },\n size: { width: b.size.width * scale, height: b.size.height * scale },\n }}\n rotation={rotation}\n >\n {(props) =>\n selectionMenu({\n ...props,\n context: {\n type: 'redaction',\n item: it,\n pageIndex,\n },\n selected: selectedId === it.id,\n placement: {\n suggestTop: false,\n },\n })\n }\n </CounterRotate>\n )}\n </Fragment>\n );\n })}\n </div>\n );\n}\n","import { Fragment, useMemo } from '@framework';\nimport { useDocumentState } from '@embedpdf/core/@framework';\nimport { MarqueeRedact } from './marquee-redact';\nimport { SelectionRedact } from './selection-redact';\nimport { PendingRedactions } from './pending-redactions';\nimport { Rotation } from '@embedpdf/models';\nimport { RedactionSelectionMenuRenderFn } from './types';\n\ninterface RedactionLayerProps {\n /** The ID of the document this layer belongs to */\n documentId: string;\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Current render scale for this page */\n scale?: number;\n /** Page rotation (for counter-rotating menus, etc.) */\n rotation?: Rotation;\n /** Optional menu renderer for a selected redaction */\n selectionMenu?: RedactionSelectionMenuRenderFn;\n}\n\nexport const RedactionLayer = ({\n documentId,\n pageIndex,\n scale,\n rotation,\n selectionMenu,\n}: RedactionLayerProps) => {\n const documentState = useDocumentState(documentId);\n const page = documentState?.document?.pages?.[pageIndex];\n\n const actualScale = useMemo(() => {\n if (scale !== undefined) return scale;\n return documentState?.scale ?? 1;\n }, [scale, documentState?.scale]);\n\n const actualRotation = useMemo(() => {\n if (rotation !== undefined) return rotation;\n // Combine page intrinsic rotation with document rotation\n const pageRotation = page?.rotation ?? 0;\n const docRotation = documentState?.rotation ?? 0;\n return ((pageRotation + docRotation) % 4) as Rotation;\n }, [rotation, page?.rotation, documentState?.rotation]);\n\n return (\n <Fragment>\n <PendingRedactions\n documentId={documentId}\n pageIndex={pageIndex}\n scale={actualScale}\n rotation={actualRotation}\n selectionMenu={selectionMenu}\n />\n <MarqueeRedact documentId={documentId} pageIndex={pageIndex} scale={actualScale} />\n <SelectionRedact documentId={documentId} pageIndex={pageIndex} scale={actualScale} />\n </Fragment>\n );\n};\n","import { createPluginPackage } from '@embedpdf/core';\nimport { RedactionPluginPackage as BaseRedactionPackage } from '@embedpdf/plugin-redaction';\nimport { RedactRendererRegistration } from './components/redact-renderer-registration';\n\nexport * from './hooks';\nexport * from './components';\nexport * from '@embedpdf/plugin-redaction';\n\n// Automatically register redact renderers when plugin is loaded\nexport const RedactionPluginPackage = createPluginPackage(BaseRedactionPackage)\n .addUtility(RedactRendererRegistration)\n .build();\n"],"names":["RedactHighlight","annotation","isSelected","scale","onClick","style","isHovered","setIsHovered","useState","object","segmentRects","rect","strokeColor","color","opacity","textColor","fontColor","overlayColor","overlayText","overlayTextRepeat","fontSize","fontFamily","PdfStandardFont","Helvetica","textAlign","PdfTextAlignment","Center","renderOverlayText","Array","fill","join","jsx","onMouseEnter","onMouseLeave","position","inset","children","map","b","i","onPointerDown","left","origin","x","top","y","width","size","height","background","border","boxSizing","pointerEvents","cursor","display","alignItems","justifyContent","Left","Right","overflow","Math","min","standardFontCssProperties","textAlignmentToCss","whiteSpace","textOverflow","lineHeight","RedactArea","padding","redactRenderers","createRenderer","id","matches","a","type","PdfAnnotationSubtype","REDACT","_a","length","render","pageIndex","interactionDefaults","isDraggable","isResizable","isRotatable","useAppearanceStream","RedactRendererRegistration","useRegisterRenderers","useRedactionPlugin","usePlugin","RedactionPlugin","useRedactionCapability","useCapability","MarqueeRedact","documentId","scaleOverride","className","stroke","plugin","redactionPlugin","documentState","useDocumentState","setRect","getPreviewStrokeColor","useEffect","onRedactionMarqueeChange","data","Highlight","rects","props","Fragment","zIndex","SelectionRedact","setRects","boundingRect","setBoundingRect","onRedactionSelectionChange","formattedSelection","selection","find","s","mixBlendMode","PendingRedactions","bboxStroke","rotation","Rotation","Degree0","selectionMenu","provides","redaction","items","setItems","selectedId","setSelectedId","scoped","forDocument","currentState","getState","pending","filter","it","source","selected","page","off1","onPendingChange","off2","onSelectedChange","sel","select","useCallback","e","stopPropagation","selectPending","kind","r","outline","outlineOffset","markColor","CounterRotate","context","item","placement","suggestTop","RedactionPluginPackage","createPluginPackage","BaseRedactionPackage","addUtility","build","_b","document","pages","actualScale","useMemo","actualRotation","state","setState","initialDocumentState","scope","onStateChange","newState"],"mappings":"8VA0BO,SAASA,GAAgBC,WAC9BA,EAAAC,WACAA,EAAAC,MACAA,EAAAC,QACAA,EAAAC,MACAA,IAEA,MAAOC,EAAWC,GAAgBC,EAAAA,UAAS,IACrCC,OAAEA,GAAWR,EAEbS,EAAeD,EAAOC,cAAgB,GACtCC,EAAOF,EAAOE,KAGdC,EAAcH,EAAOG,aAAe,UAEpCC,EAAQJ,EAAOI,OAAS,UAExBC,EA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,EAAAA,qBACX,CAOA,OAJoBC,EAAMC,cAAeC,IACvCJ,EAASI,MAIV,CAACF,IAEG,CACLH,QACA/C,SAAUkD"}
|
package/dist/react/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../shared-react';
|
package/dist/react/index.js
DELETED
|
@@ -1,519 +0,0 @@
|
|
|
1
|
-
import { createPluginPackage } from "@embedpdf/core";
|
|
2
|
-
import { initialDocumentState, RedactionPlugin, RedactionPluginPackage as RedactionPluginPackage$1 } from "@embedpdf/plugin-redaction";
|
|
3
|
-
export * from "@embedpdf/plugin-redaction";
|
|
4
|
-
import { createRenderer, useRegisterRenderers } from "@embedpdf/plugin-annotation/react";
|
|
5
|
-
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { PdfStandardFont, PdfTextAlignment, textAlignmentToCss, standardFontCssProperties, PdfAnnotationSubtype, Rotation } from "@embedpdf/models";
|
|
7
|
-
import { useState, useMemo, useEffect, useCallback, Fragment as Fragment$1 } from "react";
|
|
8
|
-
import { useCapability, usePlugin, useDocumentState } from "@embedpdf/core/react";
|
|
9
|
-
import { CounterRotate } from "@embedpdf/utils/react";
|
|
10
|
-
function RedactHighlight({
|
|
11
|
-
annotation,
|
|
12
|
-
isSelected,
|
|
13
|
-
scale,
|
|
14
|
-
onClick,
|
|
15
|
-
style
|
|
16
|
-
}) {
|
|
17
|
-
const [isHovered, setIsHovered] = useState(false);
|
|
18
|
-
const { object } = annotation;
|
|
19
|
-
const segmentRects = object.segmentRects ?? [];
|
|
20
|
-
const rect = object.rect;
|
|
21
|
-
const strokeColor = object.strokeColor ?? "#FF0000";
|
|
22
|
-
const color = object.color ?? "#000000";
|
|
23
|
-
const opacity = object.opacity ?? 1;
|
|
24
|
-
const textColor = object.fontColor ?? object.overlayColor ?? "#FFFFFF";
|
|
25
|
-
const overlayText = object.overlayText;
|
|
26
|
-
const overlayTextRepeat = object.overlayTextRepeat ?? false;
|
|
27
|
-
const fontSize = object.fontSize ?? 12;
|
|
28
|
-
const fontFamily = object.fontFamily ?? PdfStandardFont.Helvetica;
|
|
29
|
-
const textAlign = object.textAlign ?? PdfTextAlignment.Center;
|
|
30
|
-
const renderOverlayText = () => {
|
|
31
|
-
if (!overlayText) return null;
|
|
32
|
-
if (!overlayTextRepeat) return overlayText;
|
|
33
|
-
const reps = 10;
|
|
34
|
-
return Array(reps).fill(overlayText).join(" ");
|
|
35
|
-
};
|
|
36
|
-
return /* @__PURE__ */ jsx(
|
|
37
|
-
"div",
|
|
38
|
-
{
|
|
39
|
-
onMouseEnter: () => setIsHovered(true),
|
|
40
|
-
onMouseLeave: () => setIsHovered(false),
|
|
41
|
-
style: { position: "absolute", inset: 0 },
|
|
42
|
-
children: segmentRects.map((b, i) => /* @__PURE__ */ jsx(
|
|
43
|
-
"div",
|
|
44
|
-
{
|
|
45
|
-
onPointerDown: onClick,
|
|
46
|
-
style: {
|
|
47
|
-
position: "absolute",
|
|
48
|
-
left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,
|
|
49
|
-
top: (rect ? b.origin.y - rect.origin.y : b.origin.y) * scale,
|
|
50
|
-
width: b.size.width * scale,
|
|
51
|
-
height: b.size.height * scale,
|
|
52
|
-
// Default: transparent background with strokeColor (C) border
|
|
53
|
-
// Hovered: color (IC) background fill, no border
|
|
54
|
-
// Selected: no border (container handles it)
|
|
55
|
-
background: isHovered ? color : "transparent",
|
|
56
|
-
border: !isHovered ? `2px solid ${strokeColor}` : "none",
|
|
57
|
-
opacity: isHovered ? opacity : 1,
|
|
58
|
-
boxSizing: "border-box",
|
|
59
|
-
pointerEvents: "auto",
|
|
60
|
-
cursor: "pointer",
|
|
61
|
-
display: "flex",
|
|
62
|
-
alignItems: "center",
|
|
63
|
-
justifyContent: textAlign === PdfTextAlignment.Left ? "flex-start" : textAlign === PdfTextAlignment.Right ? "flex-end" : "center",
|
|
64
|
-
overflow: "hidden",
|
|
65
|
-
...style
|
|
66
|
-
},
|
|
67
|
-
children: isHovered && overlayText && /* @__PURE__ */ jsx(
|
|
68
|
-
"span",
|
|
69
|
-
{
|
|
70
|
-
style: {
|
|
71
|
-
color: textColor,
|
|
72
|
-
fontSize: Math.min(fontSize * scale, b.size.height * scale * 0.8),
|
|
73
|
-
...standardFontCssProperties(fontFamily),
|
|
74
|
-
textAlign: textAlignmentToCss(textAlign),
|
|
75
|
-
whiteSpace: overlayTextRepeat ? "normal" : "nowrap",
|
|
76
|
-
overflow: "hidden",
|
|
77
|
-
textOverflow: "ellipsis",
|
|
78
|
-
lineHeight: 1
|
|
79
|
-
},
|
|
80
|
-
children: renderOverlayText()
|
|
81
|
-
}
|
|
82
|
-
)
|
|
83
|
-
},
|
|
84
|
-
i
|
|
85
|
-
))
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
function RedactArea({ annotation, isSelected, scale, onClick, style }) {
|
|
90
|
-
const [isHovered, setIsHovered] = useState(false);
|
|
91
|
-
const { object } = annotation;
|
|
92
|
-
const strokeColor = object.strokeColor ?? "#FF0000";
|
|
93
|
-
const color = object.color ?? "#000000";
|
|
94
|
-
const opacity = object.opacity ?? 1;
|
|
95
|
-
const textColor = object.fontColor ?? object.overlayColor ?? "#FFFFFF";
|
|
96
|
-
const overlayText = object.overlayText;
|
|
97
|
-
const overlayTextRepeat = object.overlayTextRepeat ?? false;
|
|
98
|
-
const fontSize = object.fontSize ?? 12;
|
|
99
|
-
const fontFamily = object.fontFamily ?? PdfStandardFont.Helvetica;
|
|
100
|
-
const textAlign = object.textAlign ?? PdfTextAlignment.Center;
|
|
101
|
-
const renderOverlayText = () => {
|
|
102
|
-
if (!overlayText) return null;
|
|
103
|
-
if (!overlayTextRepeat) return overlayText;
|
|
104
|
-
const reps = 10;
|
|
105
|
-
return Array(reps).fill(overlayText).join(" ");
|
|
106
|
-
};
|
|
107
|
-
return /* @__PURE__ */ jsx(
|
|
108
|
-
"div",
|
|
109
|
-
{
|
|
110
|
-
onPointerDown: !isSelected ? onClick : void 0,
|
|
111
|
-
onMouseEnter: () => setIsHovered(true),
|
|
112
|
-
onMouseLeave: () => setIsHovered(false),
|
|
113
|
-
style: {
|
|
114
|
-
position: "absolute",
|
|
115
|
-
inset: 0,
|
|
116
|
-
// Default: transparent background with strokeColor (C) border
|
|
117
|
-
// Hovered: color (IC) background fill, no border
|
|
118
|
-
// Selected: no border (container handles it)
|
|
119
|
-
background: isHovered ? color : "transparent",
|
|
120
|
-
border: !isHovered ? `2px solid ${strokeColor}` : "none",
|
|
121
|
-
opacity: isHovered ? opacity : 1,
|
|
122
|
-
boxSizing: "border-box",
|
|
123
|
-
pointerEvents: "auto",
|
|
124
|
-
cursor: isSelected ? "move" : "pointer",
|
|
125
|
-
display: "flex",
|
|
126
|
-
alignItems: "center",
|
|
127
|
-
justifyContent: textAlign === PdfTextAlignment.Left ? "flex-start" : textAlign === PdfTextAlignment.Right ? "flex-end" : "center",
|
|
128
|
-
overflow: "hidden",
|
|
129
|
-
...style
|
|
130
|
-
},
|
|
131
|
-
children: isHovered && overlayText && /* @__PURE__ */ jsx(
|
|
132
|
-
"span",
|
|
133
|
-
{
|
|
134
|
-
style: {
|
|
135
|
-
color: textColor,
|
|
136
|
-
fontSize: fontSize * scale,
|
|
137
|
-
...standardFontCssProperties(fontFamily),
|
|
138
|
-
textAlign: textAlignmentToCss(textAlign),
|
|
139
|
-
whiteSpace: overlayTextRepeat ? "normal" : "nowrap",
|
|
140
|
-
overflow: "hidden",
|
|
141
|
-
textOverflow: "ellipsis",
|
|
142
|
-
padding: "4px"
|
|
143
|
-
},
|
|
144
|
-
children: renderOverlayText()
|
|
145
|
-
}
|
|
146
|
-
)
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
const redactRenderers = [
|
|
151
|
-
createRenderer({
|
|
152
|
-
id: "redactHighlight",
|
|
153
|
-
matches: (a) => {
|
|
154
|
-
var _a;
|
|
155
|
-
return a.type === PdfAnnotationSubtype.REDACT && "segmentRects" in a && (((_a = a.segmentRects) == null ? void 0 : _a.length) ?? 0) > 0;
|
|
156
|
-
},
|
|
157
|
-
render: ({ annotation, isSelected, scale, pageIndex, onClick }) => /* @__PURE__ */ jsx(
|
|
158
|
-
RedactHighlight,
|
|
159
|
-
{
|
|
160
|
-
annotation,
|
|
161
|
-
isSelected,
|
|
162
|
-
scale,
|
|
163
|
-
pageIndex,
|
|
164
|
-
onClick
|
|
165
|
-
}
|
|
166
|
-
),
|
|
167
|
-
interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },
|
|
168
|
-
useAppearanceStream: false
|
|
169
|
-
}),
|
|
170
|
-
createRenderer({
|
|
171
|
-
id: "redactArea",
|
|
172
|
-
matches: (a) => {
|
|
173
|
-
var _a;
|
|
174
|
-
return a.type === PdfAnnotationSubtype.REDACT && (!("segmentRects" in a) || !(((_a = a.segmentRects) == null ? void 0 : _a.length) ?? 0));
|
|
175
|
-
},
|
|
176
|
-
render: ({ annotation, isSelected, scale, pageIndex, onClick }) => /* @__PURE__ */ jsx(
|
|
177
|
-
RedactArea,
|
|
178
|
-
{
|
|
179
|
-
annotation,
|
|
180
|
-
isSelected,
|
|
181
|
-
scale,
|
|
182
|
-
pageIndex,
|
|
183
|
-
onClick
|
|
184
|
-
}
|
|
185
|
-
),
|
|
186
|
-
interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },
|
|
187
|
-
useAppearanceStream: false
|
|
188
|
-
})
|
|
189
|
-
];
|
|
190
|
-
function RedactRendererRegistration() {
|
|
191
|
-
useRegisterRenderers(redactRenderers);
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
const useRedactionPlugin = () => usePlugin(RedactionPlugin.id);
|
|
195
|
-
const useRedactionCapability = () => useCapability(RedactionPlugin.id);
|
|
196
|
-
const useRedaction = (documentId) => {
|
|
197
|
-
const { provides } = useRedactionCapability();
|
|
198
|
-
const [state, setState] = useState(initialDocumentState);
|
|
199
|
-
const scope = useMemo(
|
|
200
|
-
() => provides ? provides.forDocument(documentId) : null,
|
|
201
|
-
[provides, documentId]
|
|
202
|
-
);
|
|
203
|
-
useEffect(() => {
|
|
204
|
-
if (!scope) {
|
|
205
|
-
setState(initialDocumentState);
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
try {
|
|
209
|
-
setState(scope.getState());
|
|
210
|
-
} catch (e) {
|
|
211
|
-
setState(initialDocumentState);
|
|
212
|
-
}
|
|
213
|
-
const unsubscribe = scope.onStateChange((newState) => {
|
|
214
|
-
setState(newState);
|
|
215
|
-
});
|
|
216
|
-
return unsubscribe;
|
|
217
|
-
}, [scope]);
|
|
218
|
-
return {
|
|
219
|
-
state,
|
|
220
|
-
provides: scope
|
|
221
|
-
};
|
|
222
|
-
};
|
|
223
|
-
const MarqueeRedact = ({
|
|
224
|
-
documentId,
|
|
225
|
-
pageIndex,
|
|
226
|
-
scale: scaleOverride,
|
|
227
|
-
className,
|
|
228
|
-
stroke,
|
|
229
|
-
fill = "transparent"
|
|
230
|
-
}) => {
|
|
231
|
-
const { plugin: redactionPlugin } = useRedactionPlugin();
|
|
232
|
-
const documentState = useDocumentState(documentId);
|
|
233
|
-
const [rect, setRect] = useState(null);
|
|
234
|
-
const scale = scaleOverride ?? (documentState == null ? void 0 : documentState.scale) ?? 1;
|
|
235
|
-
const strokeColor = stroke ?? (redactionPlugin == null ? void 0 : redactionPlugin.getPreviewStrokeColor()) ?? "red";
|
|
236
|
-
useEffect(() => {
|
|
237
|
-
if (!redactionPlugin || !documentId) return;
|
|
238
|
-
return redactionPlugin.onRedactionMarqueeChange(documentId, (data) => {
|
|
239
|
-
setRect(data.pageIndex === pageIndex ? data.rect : null);
|
|
240
|
-
});
|
|
241
|
-
}, [redactionPlugin, documentId, pageIndex]);
|
|
242
|
-
if (!rect) return null;
|
|
243
|
-
return /* @__PURE__ */ jsx(
|
|
244
|
-
"div",
|
|
245
|
-
{
|
|
246
|
-
style: {
|
|
247
|
-
position: "absolute",
|
|
248
|
-
pointerEvents: "none",
|
|
249
|
-
left: rect.origin.x * scale,
|
|
250
|
-
top: rect.origin.y * scale,
|
|
251
|
-
width: rect.size.width * scale,
|
|
252
|
-
height: rect.size.height * scale,
|
|
253
|
-
border: `1px solid ${strokeColor}`,
|
|
254
|
-
background: fill,
|
|
255
|
-
boxSizing: "border-box"
|
|
256
|
-
},
|
|
257
|
-
className
|
|
258
|
-
}
|
|
259
|
-
);
|
|
260
|
-
};
|
|
261
|
-
function Highlight({
|
|
262
|
-
color = "#FFFF00",
|
|
263
|
-
opacity = 1,
|
|
264
|
-
border = "1px solid red",
|
|
265
|
-
rects,
|
|
266
|
-
rect,
|
|
267
|
-
scale,
|
|
268
|
-
onClick,
|
|
269
|
-
style,
|
|
270
|
-
...props
|
|
271
|
-
}) {
|
|
272
|
-
return /* @__PURE__ */ jsx(Fragment, { children: rects.map((b, i) => /* @__PURE__ */ jsx(
|
|
273
|
-
"div",
|
|
274
|
-
{
|
|
275
|
-
onPointerDown: onClick,
|
|
276
|
-
style: {
|
|
277
|
-
position: "absolute",
|
|
278
|
-
border,
|
|
279
|
-
left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,
|
|
280
|
-
top: (rect ? b.origin.y - rect.origin.y : b.origin.y) * scale,
|
|
281
|
-
width: b.size.width * scale,
|
|
282
|
-
height: b.size.height * scale,
|
|
283
|
-
background: color,
|
|
284
|
-
opacity,
|
|
285
|
-
pointerEvents: onClick ? "auto" : "none",
|
|
286
|
-
cursor: onClick ? "pointer" : "default",
|
|
287
|
-
zIndex: onClick ? 1 : void 0,
|
|
288
|
-
...style
|
|
289
|
-
},
|
|
290
|
-
...props
|
|
291
|
-
},
|
|
292
|
-
i
|
|
293
|
-
)) });
|
|
294
|
-
}
|
|
295
|
-
function SelectionRedact({ documentId, pageIndex, scale }) {
|
|
296
|
-
const { plugin: redactionPlugin } = useRedactionPlugin();
|
|
297
|
-
const [rects, setRects] = useState([]);
|
|
298
|
-
const [boundingRect, setBoundingRect] = useState(null);
|
|
299
|
-
const strokeColor = (redactionPlugin == null ? void 0 : redactionPlugin.getPreviewStrokeColor()) ?? "red";
|
|
300
|
-
useEffect(() => {
|
|
301
|
-
if (!redactionPlugin) return;
|
|
302
|
-
return redactionPlugin.onRedactionSelectionChange(documentId, (formattedSelection) => {
|
|
303
|
-
const selection = formattedSelection.find((s) => s.pageIndex === pageIndex);
|
|
304
|
-
setRects((selection == null ? void 0 : selection.segmentRects) ?? []);
|
|
305
|
-
setBoundingRect((selection == null ? void 0 : selection.rect) ?? null);
|
|
306
|
-
});
|
|
307
|
-
}, [redactionPlugin, documentId, pageIndex]);
|
|
308
|
-
if (!boundingRect) return null;
|
|
309
|
-
return /* @__PURE__ */ jsx(
|
|
310
|
-
"div",
|
|
311
|
-
{
|
|
312
|
-
style: {
|
|
313
|
-
mixBlendMode: "normal",
|
|
314
|
-
pointerEvents: "none",
|
|
315
|
-
position: "absolute",
|
|
316
|
-
inset: 0
|
|
317
|
-
},
|
|
318
|
-
children: /* @__PURE__ */ jsx(
|
|
319
|
-
Highlight,
|
|
320
|
-
{
|
|
321
|
-
color: "transparent",
|
|
322
|
-
opacity: 1,
|
|
323
|
-
rects,
|
|
324
|
-
scale,
|
|
325
|
-
border: `1px solid ${strokeColor}`
|
|
326
|
-
}
|
|
327
|
-
)
|
|
328
|
-
}
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
function PendingRedactions({
|
|
332
|
-
documentId,
|
|
333
|
-
pageIndex,
|
|
334
|
-
scale,
|
|
335
|
-
bboxStroke = "rgba(0,0,0,0.8)",
|
|
336
|
-
rotation = Rotation.Degree0,
|
|
337
|
-
selectionMenu
|
|
338
|
-
}) {
|
|
339
|
-
const { provides: redaction } = useRedactionCapability();
|
|
340
|
-
const [items, setItems] = useState([]);
|
|
341
|
-
const [selectedId, setSelectedId] = useState(null);
|
|
342
|
-
useEffect(() => {
|
|
343
|
-
if (!redaction) return;
|
|
344
|
-
const scoped = redaction.forDocument(documentId);
|
|
345
|
-
const currentState = scoped.getState();
|
|
346
|
-
setItems((currentState.pending[pageIndex] ?? []).filter((it) => it.source === "legacy"));
|
|
347
|
-
setSelectedId(
|
|
348
|
-
currentState.selected && currentState.selected.page === pageIndex ? currentState.selected.id : null
|
|
349
|
-
);
|
|
350
|
-
const off1 = scoped.onPendingChange((map) => {
|
|
351
|
-
setItems((map[pageIndex] ?? []).filter((it) => it.source === "legacy"));
|
|
352
|
-
});
|
|
353
|
-
const off2 = scoped.onSelectedChange((sel) => {
|
|
354
|
-
setSelectedId(sel && sel.page === pageIndex ? sel.id : null);
|
|
355
|
-
});
|
|
356
|
-
return () => {
|
|
357
|
-
off1 == null ? void 0 : off1();
|
|
358
|
-
off2 == null ? void 0 : off2();
|
|
359
|
-
};
|
|
360
|
-
}, [redaction, documentId, pageIndex]);
|
|
361
|
-
const select = useCallback(
|
|
362
|
-
(e, id) => {
|
|
363
|
-
e.stopPropagation();
|
|
364
|
-
if (!redaction) return;
|
|
365
|
-
redaction.forDocument(documentId).selectPending(pageIndex, id);
|
|
366
|
-
},
|
|
367
|
-
[redaction, documentId, pageIndex]
|
|
368
|
-
);
|
|
369
|
-
if (!items.length) return null;
|
|
370
|
-
return /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, pointerEvents: "none" }, children: items.map((it) => {
|
|
371
|
-
if (it.kind === "area") {
|
|
372
|
-
const r = it.rect;
|
|
373
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
374
|
-
/* @__PURE__ */ jsx(
|
|
375
|
-
"div",
|
|
376
|
-
{
|
|
377
|
-
style: {
|
|
378
|
-
position: "absolute",
|
|
379
|
-
left: r.origin.x * scale,
|
|
380
|
-
top: r.origin.y * scale,
|
|
381
|
-
width: r.size.width * scale,
|
|
382
|
-
height: r.size.height * scale,
|
|
383
|
-
background: "transparent",
|
|
384
|
-
outline: selectedId === it.id ? `1px solid ${bboxStroke}` : "none",
|
|
385
|
-
outlineOffset: "2px",
|
|
386
|
-
border: `1px solid ${it.markColor}`,
|
|
387
|
-
pointerEvents: "auto",
|
|
388
|
-
cursor: "pointer"
|
|
389
|
-
},
|
|
390
|
-
onPointerDown: (e) => select(e, it.id)
|
|
391
|
-
}
|
|
392
|
-
),
|
|
393
|
-
selectionMenu && /* @__PURE__ */ jsx(
|
|
394
|
-
CounterRotate,
|
|
395
|
-
{
|
|
396
|
-
rect: {
|
|
397
|
-
origin: { x: r.origin.x * scale, y: r.origin.y * scale },
|
|
398
|
-
size: { width: r.size.width * scale, height: r.size.height * scale }
|
|
399
|
-
},
|
|
400
|
-
rotation,
|
|
401
|
-
children: (props) => selectionMenu({
|
|
402
|
-
...props,
|
|
403
|
-
context: {
|
|
404
|
-
type: "redaction",
|
|
405
|
-
item: it,
|
|
406
|
-
pageIndex
|
|
407
|
-
},
|
|
408
|
-
selected: selectedId === it.id,
|
|
409
|
-
placement: {
|
|
410
|
-
suggestTop: false
|
|
411
|
-
}
|
|
412
|
-
})
|
|
413
|
-
}
|
|
414
|
-
)
|
|
415
|
-
] }, it.id);
|
|
416
|
-
}
|
|
417
|
-
const b = it.rect;
|
|
418
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
419
|
-
/* @__PURE__ */ jsx(
|
|
420
|
-
"div",
|
|
421
|
-
{
|
|
422
|
-
style: {
|
|
423
|
-
position: "absolute",
|
|
424
|
-
left: b.origin.x * scale,
|
|
425
|
-
top: b.origin.y * scale,
|
|
426
|
-
width: b.size.width * scale,
|
|
427
|
-
height: b.size.height * scale,
|
|
428
|
-
background: "transparent",
|
|
429
|
-
outline: selectedId === it.id ? `1px solid ${bboxStroke}` : "none",
|
|
430
|
-
outlineOffset: "2px",
|
|
431
|
-
pointerEvents: "auto",
|
|
432
|
-
cursor: selectedId === it.id ? "pointer" : "default"
|
|
433
|
-
},
|
|
434
|
-
children: /* @__PURE__ */ jsx(
|
|
435
|
-
Highlight,
|
|
436
|
-
{
|
|
437
|
-
rect: b,
|
|
438
|
-
rects: it.rects,
|
|
439
|
-
color: "transparent",
|
|
440
|
-
border: `1px solid ${it.markColor}`,
|
|
441
|
-
scale,
|
|
442
|
-
onClick: (e) => select(e, it.id)
|
|
443
|
-
}
|
|
444
|
-
)
|
|
445
|
-
}
|
|
446
|
-
),
|
|
447
|
-
selectionMenu && /* @__PURE__ */ jsx(
|
|
448
|
-
CounterRotate,
|
|
449
|
-
{
|
|
450
|
-
rect: {
|
|
451
|
-
origin: { x: b.origin.x * scale, y: b.origin.y * scale },
|
|
452
|
-
size: { width: b.size.width * scale, height: b.size.height * scale }
|
|
453
|
-
},
|
|
454
|
-
rotation,
|
|
455
|
-
children: (props) => selectionMenu({
|
|
456
|
-
...props,
|
|
457
|
-
context: {
|
|
458
|
-
type: "redaction",
|
|
459
|
-
item: it,
|
|
460
|
-
pageIndex
|
|
461
|
-
},
|
|
462
|
-
selected: selectedId === it.id,
|
|
463
|
-
placement: {
|
|
464
|
-
suggestTop: false
|
|
465
|
-
}
|
|
466
|
-
})
|
|
467
|
-
}
|
|
468
|
-
)
|
|
469
|
-
] }, it.id);
|
|
470
|
-
}) });
|
|
471
|
-
}
|
|
472
|
-
const RedactionLayer = ({
|
|
473
|
-
documentId,
|
|
474
|
-
pageIndex,
|
|
475
|
-
scale,
|
|
476
|
-
rotation,
|
|
477
|
-
selectionMenu
|
|
478
|
-
}) => {
|
|
479
|
-
var _a, _b;
|
|
480
|
-
const documentState = useDocumentState(documentId);
|
|
481
|
-
const page = (_b = (_a = documentState == null ? void 0 : documentState.document) == null ? void 0 : _a.pages) == null ? void 0 : _b[pageIndex];
|
|
482
|
-
const actualScale = useMemo(() => {
|
|
483
|
-
if (scale !== void 0) return scale;
|
|
484
|
-
return (documentState == null ? void 0 : documentState.scale) ?? 1;
|
|
485
|
-
}, [scale, documentState == null ? void 0 : documentState.scale]);
|
|
486
|
-
const actualRotation = useMemo(() => {
|
|
487
|
-
if (rotation !== void 0) return rotation;
|
|
488
|
-
const pageRotation = (page == null ? void 0 : page.rotation) ?? 0;
|
|
489
|
-
const docRotation = (documentState == null ? void 0 : documentState.rotation) ?? 0;
|
|
490
|
-
return (pageRotation + docRotation) % 4;
|
|
491
|
-
}, [rotation, page == null ? void 0 : page.rotation, documentState == null ? void 0 : documentState.rotation]);
|
|
492
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
493
|
-
/* @__PURE__ */ jsx(
|
|
494
|
-
PendingRedactions,
|
|
495
|
-
{
|
|
496
|
-
documentId,
|
|
497
|
-
pageIndex,
|
|
498
|
-
scale: actualScale,
|
|
499
|
-
rotation: actualRotation,
|
|
500
|
-
selectionMenu
|
|
501
|
-
}
|
|
502
|
-
),
|
|
503
|
-
/* @__PURE__ */ jsx(MarqueeRedact, { documentId, pageIndex, scale: actualScale }),
|
|
504
|
-
/* @__PURE__ */ jsx(SelectionRedact, { documentId, pageIndex, scale: actualScale })
|
|
505
|
-
] });
|
|
506
|
-
};
|
|
507
|
-
const RedactionPluginPackage = createPluginPackage(RedactionPluginPackage$1).addUtility(RedactRendererRegistration).build();
|
|
508
|
-
export {
|
|
509
|
-
RedactArea,
|
|
510
|
-
RedactHighlight,
|
|
511
|
-
RedactRendererRegistration,
|
|
512
|
-
RedactionLayer,
|
|
513
|
-
RedactionPluginPackage,
|
|
514
|
-
redactRenderers,
|
|
515
|
-
useRedaction,
|
|
516
|
-
useRedactionCapability,
|
|
517
|
-
useRedactionPlugin
|
|
518
|
-
};
|
|
519
|
-
//# sourceMappingURL=index.js.map
|