@embedpdf/plugin-redaction 2.0.0 → 2.0.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-redaction.svelte.ts","../../src/svelte/components/highlight.svelte","../../src/svelte/components/marquee-redact.svelte","../../src/svelte/components/pending-redactions.svelte","../../src/svelte/components/selection-redact.svelte","../../src/svelte/components/redaction-layer.svelte"],"sourcesContent":["import {\n RedactionPlugin,\n initialDocumentState,\n RedactionDocumentState,\n RedactionScope,\n} from '@embedpdf/plugin-redaction';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useRedactionPlugin = () => usePlugin<RedactionPlugin>(RedactionPlugin.id);\nexport const useRedactionCapability = () => useCapability<RedactionPlugin>(RedactionPlugin.id);\n\n// Define the return type explicitly to maintain type safety\ninterface UseRedactionReturn {\n provides: RedactionScope | null;\n state: RedactionDocumentState;\n}\n\n/**\n * Hook for redaction state for a specific document\n * @param getDocumentId Document ID getter function\n */\nexport const useRedaction = (getDocumentId: () => string | null): UseRedactionReturn => {\n const capability = useRedactionCapability();\n\n let state = $state<RedactionDocumentState>(initialDocumentState);\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n // Scoped capability for current docId\n const scopedProvides = $derived(\n capability.provides && documentId ? capability.provides.forDocument(documentId) : null,\n );\n\n $effect(() => {\n const provides = capability.provides;\n const docId = documentId;\n\n if (!provides || !docId) {\n state = initialDocumentState;\n return;\n }\n\n const scope = provides.forDocument(docId);\n\n // Get initial state\n try {\n state = scope.getState();\n } catch (e) {\n // Handle case where state might not be ready\n state = initialDocumentState;\n }\n\n // Subscribe to state changes for THIS docId\n return scope.onStateChange((newState) => {\n state = newState;\n });\n });\n\n return {\n get provides() {\n return scopedProvides;\n },\n get state() {\n return state;\n },\n };\n};\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n\n interface HighlightProps {\n color?: string;\n opacity?: number;\n border?: string;\n rects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent | TouchEvent) => void;\n style?: string;\n }\n\n let {\n color = '#FFFF00',\n opacity = 1,\n border = '1px solid red',\n rects,\n rect,\n scale,\n onClick,\n style = '',\n }: HighlightProps = $props();\n\n // Rename rect to boundingRect for clarity\n const boundingRect = rect;\n</script>\n\n{#each rects as b, i (i)}\n <div\n onpointerdown={onClick}\n ontouchstart={onClick}\n style:position=\"absolute\"\n style:border\n style:left={`${(boundingRect ? b.origin.x - boundingRect.origin.x : b.origin.x) * scale}px`}\n style:top={`${(boundingRect ? b.origin.y - boundingRect.origin.y : b.origin.y) * scale}px`}\n style:width={`${b.size.width * scale}px`}\n style:height={`${b.size.height * scale}px`}\n style:background={color}\n style:opacity\n style:pointer-events={onClick ? 'auto' : 'none'}\n style:cursor={onClick ? 'pointer' : 'default'}\n style:z-index={onClick ? '1' : undefined}\n {style}\n ></div>\n{/each}\n","<script lang=\"ts\">\n import { useDocumentState } from '@embedpdf/core/svelte';\n import type { Rect } from '@embedpdf/models';\n import { useRedactionPlugin } from '../hooks/use-redaction.svelte';\n\n interface 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\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n className = '',\n stroke = 'red',\n fill = 'transparent',\n }: MarqueeRedactProps = $props();\n\n const redactionPlugin = useRedactionPlugin();\n const documentState = useDocumentState(() => documentId);\n let rect = $state<Rect | null>(null);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n $effect(() => {\n if (!redactionPlugin.plugin || !documentId) {\n rect = null;\n return;\n }\n\n return redactionPlugin.plugin.registerMarqueeOnPage({\n documentId,\n pageIndex,\n scale: actualScale,\n callback: {\n onPreview: (newRect) => {\n rect = newRect;\n },\n },\n });\n });\n</script>\n\n{#if rect}\n <div\n class={className}\n style:position=\"absolute\"\n style:pointer-events=\"none\"\n style:left={`${rect.origin.x * actualScale}px`}\n style:top={`${rect.origin.y * actualScale}px`}\n style:width={`${rect.size.width * actualScale}px`}\n style:height={`${rect.size.height * actualScale}px`}\n style:border={`1px solid ${stroke}`}\n style:background={fill}\n style:box-sizing=\"border-box\"\n ></div>\n{/if}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import type { Rect } from '@embedpdf/models';\n import { Rotation } from '@embedpdf/models';\n import { CounterRotate } from '@embedpdf/utils/svelte';\n import type { MenuWrapperProps, SelectionMenuPlacement } from '@embedpdf/utils/svelte';\n import type { RedactionItem } from '@embedpdf/plugin-redaction';\n import { useRedactionCapability } from '../hooks/use-redaction.svelte';\n import Highlight from './highlight.svelte';\n import type {\n RedactionSelectionContext,\n RedactionSelectionMenuRenderFn,\n RedactionSelectionMenuProps,\n } from '../types';\n\n interface Props {\n documentId: string;\n pageIndex: number;\n scale: number;\n rotation?: Rotation;\n bboxStroke?: string;\n selectionMenu?: RedactionSelectionMenuRenderFn;\n selectionMenuSnippet?: Snippet<[RedactionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale,\n rotation = Rotation.Degree0,\n bboxStroke = 'rgba(0,0,0,0.8)',\n selectionMenu,\n selectionMenuSnippet,\n }: Props = $props();\n\n const redactionCapability = useRedactionCapability();\n\n let items = $state<RedactionItem[]>([]);\n let selectedId = $state<string | null>(null);\n\n $effect(() => {\n const redactionValue = redactionCapability.provides;\n if (!redactionValue) {\n items = [];\n selectedId = null;\n return;\n }\n\n const scoped = redactionValue.forDocument(documentId);\n const currentState = scoped.getState();\n items = currentState.pending[pageIndex] ?? [];\n selectedId = currentState.selected?.page === pageIndex ? currentState.selected.id : null;\n\n const off1 = scoped.onPendingChange((map) => {\n items = map[pageIndex] ?? [];\n });\n\n const off2 = scoped.onSelectedChange((sel) => {\n selectedId = sel?.page === pageIndex ? sel.id : null;\n });\n\n return () => {\n off1?.();\n off2?.();\n };\n });\n\n function select(e: MouseEvent | TouchEvent, id: string) {\n e.stopPropagation();\n if (!redactionCapability.provides) return;\n redactionCapability.provides.forDocument(documentId).selectPending(pageIndex, id);\n }\n\n function shouldShowMenu(itemId: string): boolean {\n const isSelected = selectedId === itemId;\n return isSelected && (!!selectionMenu || !!selectionMenuSnippet);\n }\n\n function buildContext(item: RedactionItem): RedactionSelectionContext {\n return { type: 'redaction', item, pageIndex };\n }\n\n const menuPlacement: SelectionMenuPlacement = {\n suggestTop: false,\n spaceAbove: 0,\n spaceBelow: 0,\n };\n\n function buildMenuProps(\n item: RedactionItem,\n rect: Rect,\n menuWrapperProps: MenuWrapperProps,\n ): RedactionSelectionMenuProps {\n return {\n context: buildContext(item),\n selected: selectedId === item.id,\n rect,\n placement: menuPlacement,\n menuWrapperProps,\n };\n }\n</script>\n\n{#if items.length}\n <div style=\"position: absolute; inset: 0; pointer-events: none;\">\n {#each items as item (item.id)}\n {#if item.kind === 'area'}\n <div\n style=\"\n position: absolute;\n left: {item.rect.origin.x * scale}px;\n top: {item.rect.origin.y * scale}px;\n width: {item.rect.size.width * scale}px;\n height: {item.rect.size.height * scale}px;\n background: transparent;\n outline: {selectedId === item.id ? `1px solid ${bboxStroke}` : 'none'};\n outline-offset: 2px;\n border: 1px solid red;\n pointer-events: auto;\n cursor: pointer;\n \"\n onpointerdown={(e) => select(e, item.id)}\n ontouchstart={(e) => select(e, item.id)}\n ></div>\n\n {#if shouldShowMenu(item.id)}\n <CounterRotate\n rect={{\n origin: { x: item.rect.origin.x * scale, y: item.rect.origin.y * scale },\n size: { width: item.rect.size.width * scale, height: item.rect.size.height * scale },\n }}\n {rotation}\n >\n {#snippet children({ rect, menuWrapperProps })}\n {@const menuProps = buildMenuProps(item, rect, menuWrapperProps)}\n {#if selectionMenu}\n {@const result = selectionMenu(menuProps)}\n {#if result}\n <result.component {...result.props} />\n {/if}\n {:else if selectionMenuSnippet}\n {@render selectionMenuSnippet(menuProps)}\n {/if}\n {/snippet}\n </CounterRotate>\n {/if}\n {:else}\n <div\n style=\"\n position: absolute;\n left: {item.rect.origin.x * scale}px;\n top: {item.rect.origin.y * scale}px;\n width: {item.rect.size.width * scale}px;\n height: {item.rect.size.height * scale}px;\n background: transparent;\n outline: {selectedId === item.id ? `1px solid ${bboxStroke}` : 'none'};\n outline-offset: 2px;\n pointer-events: auto;\n cursor: {selectedId === item.id ? 'pointer' : 'default'};\n \"\n >\n <Highlight\n rect={item.rect}\n rects={item.rects}\n color=\"transparent\"\n border=\"1px solid red\"\n {scale}\n onClick={(e) => select(e, item.id)}\n />\n </div>\n\n {#if shouldShowMenu(item.id)}\n <CounterRotate\n rect={{\n origin: { x: item.rect.origin.x * scale, y: item.rect.origin.y * scale },\n size: { width: item.rect.size.width * scale, height: item.rect.size.height * scale },\n }}\n {rotation}\n >\n {#snippet children({ rect, menuWrapperProps })}\n {@const menuProps = buildMenuProps(item, rect, menuWrapperProps)}\n {#if selectionMenu}\n {@const result = selectionMenu(menuProps)}\n {#if result}\n <result.component {...result.props} />\n {/if}\n {:else if selectionMenuSnippet}\n {@render selectionMenuSnippet(menuProps)}\n {/if}\n {/snippet}\n </CounterRotate>\n {/if}\n {/if}\n {/each}\n </div>\n{/if}\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n import { useRedactionPlugin } from '../hooks/use-redaction.svelte';\n import Highlight from './highlight.svelte';\n\n interface SelectionRedactProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n }\n\n let { documentId, pageIndex, scale }: SelectionRedactProps = $props();\n\n const redactionPlugin = useRedactionPlugin();\n let rects = $state<Rect[]>([]);\n let boundingRect = $state<Rect | null>(null);\n\n $effect(() => {\n if (!redactionPlugin.plugin) {\n rects = [];\n boundingRect = null;\n return;\n }\n\n return redactionPlugin.plugin.onRedactionSelectionChange(documentId, (formattedSelection) => {\n const selection = formattedSelection.find((s) => s.pageIndex === pageIndex);\n rects = selection?.segmentRects ?? [];\n boundingRect = selection?.rect ?? null;\n });\n });\n</script>\n\n{#if boundingRect}\n <div\n style:mix-blend-mode=\"normal\"\n style:pointer-events=\"none\"\n style:position=\"absolute\"\n style:inset=\"0\"\n >\n <Highlight color=\"transparent\" opacity={1} {rects} {scale} border=\"1px solid red\" />\n </div>\n{/if}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import { Rotation } from '@embedpdf/models';\n import PendingRedactions from './pending-redactions.svelte';\n import MarqueeRedact from './marquee-redact.svelte';\n import SelectionRedact from './selection-redact.svelte';\n import type { RedactionSelectionMenuRenderFn, RedactionSelectionMenuProps } from '../types';\n\n interface 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 /** Render function for selection menu (schema-driven approach) */\n selectionMenu?: RedactionSelectionMenuRenderFn;\n /** Snippet for custom selection menu (slot-based approach) */\n selectionMenuSnippet?: Snippet<[RedactionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale,\n rotation,\n selectionMenu,\n selectionMenuSnippet,\n }: RedactionLayerProps = $props();\n\n const documentState = useDocumentState(() => documentId);\n\n const actualScale = $derived(scale !== undefined ? scale : (documentState.current?.scale ?? 1));\n\n const actualRotation = $derived(\n rotation !== undefined ? rotation : (documentState.current?.rotation ?? Rotation.Degree0),\n );\n</script>\n\n<PendingRedactions\n {documentId}\n {pageIndex}\n scale={actualScale}\n rotation={actualRotation}\n {selectionMenu}\n {selectionMenuSnippet}\n/>\n<MarqueeRedact {documentId} {pageIndex} scale={actualScale} />\n<SelectionRedact {documentId} {pageIndex} scale={actualScale} />\n"],"names":["useRedactionPlugin","usePlugin","RedactionPlugin","id","useRedactionCapability","useCapability","color","opacity","border","style","boundingRect","$$props","rect","b","origin","x","scale","y","size","width","height","onClick","cursor","className","stroke","fill","redactionPlugin","documentState","useDocumentState","documentId","actualScale","$","derived","_a","current","user_effect","plugin","registerMarqueeOnPage","pageIndex","callback","onPreview","newRect","set","left","get","top","consequent","rotation","prop","Rotation","Degree0","bboxStroke","redactionCapability","items","state","proxy","selectedId","select","e","stopPropagation","provides","forDocument","selectPending","shouldShowMenu","itemId","selectionMenu","selectionMenuSnippet","buildContext","item","type","redactionValue","scoped","currentState","getState","pending","selected","page","off1","onPendingChange","map","off2","onSelectedChange","sel","menuPlacement","suggestTop","spaceAbove","spaceBelow","buildMenuProps","menuWrapperProps","context","placement","each","div","div_1","__pointerdown","__touchstart","menuProps","result","result_component","$$anchor","spread_props","props","consequent_3","rects","result_component_1","consequent_5","consequent_8","kind","consequent_4","$$render","alternate_2","length","consequent_9","onRedactionSelectionChange","formattedSelection","selection","find","s","segmentRects","actualRotation","getDocumentId","capability","initialDocumentState","scopedProvides","docId","scope","onStateChange","newState"],"mappings":"ilBAQaA,EAAA,IAA2BC,YAA2BC,EAAAA,gBAAgBC,IACtEC,EAAA,IAA+BC,gBAA+BH,EAAAA,gBAAgBC,qDCMvF,IAAAG,qBAAQ,WACRC,uBAAU,GACVC,sBAAS,iBAKTC,qBAAQ,UAIJC,EAAYC,EAAAC,6EAGJC,4PAMIH,QAAeG,GAAEC,OAAOC,EAAIL,EAAaI,OAAOC,QAAIF,GAAEC,OAAOC,GAACJ,EAAAK,gBAC/DN,QAAeG,GAAEC,OAAOG,EAAIP,EAAaI,OAAOG,QAAIJ,GAAEC,OAAOG,GAACN,EAAAK,uBAC7DH,GAAEK,KAAKC,MAAKR,EAAAK,wBACXH,GAAEK,KAAKE,OAAMT,EAAAK,sBACZV,gBAEc,iBAAAK,EAAAU,QAAA,OAAS,OACjBC,OAAAX,EAAAU,QAAA,UAAY,UACX,UAAAV,EAAAU,QAAA,SAAM,kCAhBnC,wGCJI,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B,MAAAC,EAAarH,IAEf,IAAAkD,kBAAuCoE,EAAAA,uBAGrC,MAAA7F,YAAsB2F,GAGtBG,EAAA5F,EAAAC,QAAA,IACJyF,EAAW7D,gBAAY/B,GAAa4F,EAAW7D,SAASC,kBAAYhC,IAAc,aAGpFE,EAAAI,uBACQyB,EAAW6D,EAAW7D,SACtBgE,QAAQ/F,OAET+B,IAAagE,cAChB7F,EAAAW,IAAAY,EAAQoE,EAAAA,sBAAA,GAIJ,MAAAG,EAAQjE,EAASC,YAAY+D,aAIjCtE,EAAQuE,EAAMpD,YAAA,EAChB,OAASf,GAEP3B,EAAAW,IAAAY,EAAQoE,EAAAA,sBAAA,EACV,CAGO,OAAAG,EAAMC,cAAeC,IAC1BhG,EAAAW,IAAAY,EAAQyE,GAAA,QAKN,YAAAnE,gBACK+D,EACT,EACI,SAAArE,gBACKA,EACT"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-redaction.svelte.ts","../../src/svelte/components/highlight.svelte","../../src/svelte/components/marquee-redact.svelte","../../src/svelte/components/pending-redactions.svelte","../../src/svelte/components/selection-redact.svelte","../../src/svelte/components/redaction-layer.svelte"],"sourcesContent":["import {\n RedactionPlugin,\n initialDocumentState,\n RedactionDocumentState,\n RedactionScope,\n} from '@embedpdf/plugin-redaction';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useRedactionPlugin = () => usePlugin<RedactionPlugin>(RedactionPlugin.id);\nexport const useRedactionCapability = () => useCapability<RedactionPlugin>(RedactionPlugin.id);\n\n// Define the return type explicitly to maintain type safety\ninterface UseRedactionReturn {\n provides: RedactionScope | null;\n state: RedactionDocumentState;\n}\n\n/**\n * Hook for redaction state for a specific document\n * @param getDocumentId Document ID getter function\n */\nexport const useRedaction = (getDocumentId: () => string | null): UseRedactionReturn => {\n const capability = useRedactionCapability();\n\n let state = $state<RedactionDocumentState>(initialDocumentState);\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n // Scoped capability for current docId\n const scopedProvides = $derived(\n capability.provides && documentId ? capability.provides.forDocument(documentId) : null,\n );\n\n $effect(() => {\n const provides = capability.provides;\n const docId = documentId;\n\n if (!provides || !docId) {\n state = initialDocumentState;\n return;\n }\n\n const scope = provides.forDocument(docId);\n\n // Get initial state\n try {\n state = scope.getState();\n } catch (e) {\n // Handle case where state might not be ready\n state = initialDocumentState;\n }\n\n // Subscribe to state changes for THIS docId\n return scope.onStateChange((newState) => {\n state = newState;\n });\n });\n\n return {\n get provides() {\n return scopedProvides;\n },\n get state() {\n return state;\n },\n };\n};\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n\n interface HighlightProps {\n color?: string;\n opacity?: number;\n border?: string;\n rects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent | TouchEvent) => void;\n style?: string;\n }\n\n let {\n color = '#FFFF00',\n opacity = 1,\n border = '1px solid red',\n rects,\n rect,\n scale,\n onClick,\n style = '',\n }: HighlightProps = $props();\n\n // Rename rect to boundingRect for clarity\n const boundingRect = rect;\n</script>\n\n{#each rects as b, i (i)}\n <div\n onpointerdown={onClick}\n ontouchstart={onClick}\n style:position=\"absolute\"\n style:border\n style:left={`${(boundingRect ? b.origin.x - boundingRect.origin.x : b.origin.x) * scale}px`}\n style:top={`${(boundingRect ? b.origin.y - boundingRect.origin.y : b.origin.y) * scale}px`}\n style:width={`${b.size.width * scale}px`}\n style:height={`${b.size.height * scale}px`}\n style:background={color}\n style:opacity\n style:pointer-events={onClick ? 'auto' : 'none'}\n style:cursor={onClick ? 'pointer' : 'default'}\n style:z-index={onClick ? '1' : undefined}\n {style}\n ></div>\n{/each}\n","<script lang=\"ts\">\n import { useDocumentState } from '@embedpdf/core/svelte';\n import type { Rect } from '@embedpdf/models';\n import { useRedactionPlugin } from '../hooks/use-redaction.svelte';\n\n interface 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\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n className = '',\n stroke = 'red',\n fill = 'transparent',\n }: MarqueeRedactProps = $props();\n\n const redactionPlugin = useRedactionPlugin();\n const documentState = useDocumentState(() => documentId);\n let rect = $state<Rect | null>(null);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n $effect(() => {\n if (!redactionPlugin.plugin || !documentId) {\n rect = null;\n return;\n }\n\n return redactionPlugin.plugin.registerMarqueeOnPage({\n documentId,\n pageIndex,\n scale: actualScale,\n callback: {\n onPreview: (newRect) => {\n rect = newRect;\n },\n },\n });\n });\n</script>\n\n{#if rect}\n <div\n class={className}\n style:position=\"absolute\"\n style:pointer-events=\"none\"\n style:left={`${rect.origin.x * actualScale}px`}\n style:top={`${rect.origin.y * actualScale}px`}\n style:width={`${rect.size.width * actualScale}px`}\n style:height={`${rect.size.height * actualScale}px`}\n style:border={`1px solid ${stroke}`}\n style:background={fill}\n style:box-sizing=\"border-box\"\n ></div>\n{/if}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import type { Rect } from '@embedpdf/models';\n import { Rotation } from '@embedpdf/models';\n import { CounterRotate } from '@embedpdf/utils/svelte';\n import type { MenuWrapperProps, SelectionMenuPlacement } from '@embedpdf/utils/svelte';\n import type { RedactionItem } from '@embedpdf/plugin-redaction';\n import { useRedactionCapability } from '../hooks/use-redaction.svelte';\n import Highlight from './highlight.svelte';\n import type {\n RedactionSelectionContext,\n RedactionSelectionMenuRenderFn,\n RedactionSelectionMenuProps,\n } from '../types';\n\n interface Props {\n documentId: string;\n pageIndex: number;\n scale: number;\n rotation?: Rotation;\n bboxStroke?: string;\n selectionMenu?: RedactionSelectionMenuRenderFn;\n selectionMenuSnippet?: Snippet<[RedactionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale,\n rotation = Rotation.Degree0,\n bboxStroke = 'rgba(0,0,0,0.8)',\n selectionMenu,\n selectionMenuSnippet,\n }: Props = $props();\n\n const redactionCapability = useRedactionCapability();\n\n let items = $state<RedactionItem[]>([]);\n let selectedId = $state<string | null>(null);\n\n $effect(() => {\n const redactionValue = redactionCapability.provides;\n if (!redactionValue) {\n items = [];\n selectedId = null;\n return;\n }\n\n const scoped = redactionValue.forDocument(documentId);\n const currentState = scoped.getState();\n items = currentState.pending[pageIndex] ?? [];\n selectedId = currentState.selected?.page === pageIndex ? currentState.selected.id : null;\n\n const off1 = scoped.onPendingChange((map) => {\n items = map[pageIndex] ?? [];\n });\n\n const off2 = scoped.onSelectedChange((sel) => {\n selectedId = sel?.page === pageIndex ? sel.id : null;\n });\n\n return () => {\n off1?.();\n off2?.();\n };\n });\n\n function select(e: MouseEvent | TouchEvent, id: string) {\n e.stopPropagation();\n if (!redactionCapability.provides) return;\n redactionCapability.provides.forDocument(documentId).selectPending(pageIndex, id);\n }\n\n function shouldShowMenu(itemId: string): boolean {\n const isSelected = selectedId === itemId;\n return isSelected && (!!selectionMenu || !!selectionMenuSnippet);\n }\n\n function buildContext(item: RedactionItem): RedactionSelectionContext {\n return { type: 'redaction', item, pageIndex };\n }\n\n const menuPlacement: SelectionMenuPlacement = {\n suggestTop: false,\n spaceAbove: 0,\n spaceBelow: 0,\n };\n\n function buildMenuProps(\n item: RedactionItem,\n rect: Rect,\n menuWrapperProps: MenuWrapperProps,\n ): RedactionSelectionMenuProps {\n return {\n context: buildContext(item),\n selected: selectedId === item.id,\n rect,\n placement: menuPlacement,\n menuWrapperProps,\n };\n }\n</script>\n\n{#if items.length}\n <div style=\"position: absolute; inset: 0; pointer-events: none;\">\n {#each items as item (item.id)}\n {#if item.kind === 'area'}\n <div\n style=\"\n position: absolute;\n left: {item.rect.origin.x * scale}px;\n top: {item.rect.origin.y * scale}px;\n width: {item.rect.size.width * scale}px;\n height: {item.rect.size.height * scale}px;\n background: transparent;\n outline: {selectedId === item.id ? `1px solid ${bboxStroke}` : 'none'};\n outline-offset: 2px;\n border: 1px solid red;\n pointer-events: auto;\n cursor: pointer;\n \"\n onpointerdown={(e) => select(e, item.id)}\n ontouchstart={(e) => select(e, item.id)}\n ></div>\n\n {#if shouldShowMenu(item.id)}\n <CounterRotate\n rect={{\n origin: { x: item.rect.origin.x * scale, y: item.rect.origin.y * scale },\n size: { width: item.rect.size.width * scale, height: item.rect.size.height * scale },\n }}\n {rotation}\n >\n {#snippet children({ rect, menuWrapperProps })}\n {@const menuProps = buildMenuProps(item, rect, menuWrapperProps)}\n {#if selectionMenu}\n {@const result = selectionMenu(menuProps)}\n {#if result}\n <result.component {...result.props} />\n {/if}\n {:else if selectionMenuSnippet}\n {@render selectionMenuSnippet(menuProps)}\n {/if}\n {/snippet}\n </CounterRotate>\n {/if}\n {:else}\n <div\n style=\"\n position: absolute;\n left: {item.rect.origin.x * scale}px;\n top: {item.rect.origin.y * scale}px;\n width: {item.rect.size.width * scale}px;\n height: {item.rect.size.height * scale}px;\n background: transparent;\n outline: {selectedId === item.id ? `1px solid ${bboxStroke}` : 'none'};\n outline-offset: 2px;\n pointer-events: auto;\n cursor: {selectedId === item.id ? 'pointer' : 'default'};\n \"\n >\n <Highlight\n rect={item.rect}\n rects={item.rects}\n color=\"transparent\"\n border=\"1px solid red\"\n {scale}\n onClick={(e) => select(e, item.id)}\n />\n </div>\n\n {#if shouldShowMenu(item.id)}\n <CounterRotate\n rect={{\n origin: { x: item.rect.origin.x * scale, y: item.rect.origin.y * scale },\n size: { width: item.rect.size.width * scale, height: item.rect.size.height * scale },\n }}\n {rotation}\n >\n {#snippet children({ rect, menuWrapperProps })}\n {@const menuProps = buildMenuProps(item, rect, menuWrapperProps)}\n {#if selectionMenu}\n {@const result = selectionMenu(menuProps)}\n {#if result}\n <result.component {...result.props} />\n {/if}\n {:else if selectionMenuSnippet}\n {@render selectionMenuSnippet(menuProps)}\n {/if}\n {/snippet}\n </CounterRotate>\n {/if}\n {/if}\n {/each}\n </div>\n{/if}\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n import { useRedactionPlugin } from '../hooks/use-redaction.svelte';\n import Highlight from './highlight.svelte';\n\n interface SelectionRedactProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n }\n\n let { documentId, pageIndex, scale }: SelectionRedactProps = $props();\n\n const redactionPlugin = useRedactionPlugin();\n let rects = $state<Rect[]>([]);\n let boundingRect = $state<Rect | null>(null);\n\n $effect(() => {\n if (!redactionPlugin.plugin) {\n rects = [];\n boundingRect = null;\n return;\n }\n\n return redactionPlugin.plugin.onRedactionSelectionChange(documentId, (formattedSelection) => {\n const selection = formattedSelection.find((s) => s.pageIndex === pageIndex);\n rects = selection?.segmentRects ?? [];\n boundingRect = selection?.rect ?? null;\n });\n });\n</script>\n\n{#if boundingRect}\n <div\n style:mix-blend-mode=\"normal\"\n style:pointer-events=\"none\"\n style:position=\"absolute\"\n style:inset=\"0\"\n >\n <Highlight color=\"transparent\" opacity={1} {rects} {scale} border=\"1px solid red\" />\n </div>\n{/if}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import { Rotation } from '@embedpdf/models';\n import PendingRedactions from './pending-redactions.svelte';\n import MarqueeRedact from './marquee-redact.svelte';\n import SelectionRedact from './selection-redact.svelte';\n import type { RedactionSelectionMenuRenderFn, RedactionSelectionMenuProps } from '../types';\n\n interface 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 /** Render function for selection menu (schema-driven approach) */\n selectionMenu?: RedactionSelectionMenuRenderFn;\n /** Snippet for custom selection menu (slot-based approach) */\n selectionMenuSnippet?: Snippet<[RedactionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale,\n rotation,\n selectionMenu,\n selectionMenuSnippet,\n }: RedactionLayerProps = $props();\n\n const documentState = useDocumentState(() => documentId);\n\n const actualScale = $derived(scale !== undefined ? scale : (documentState.current?.scale ?? 1));\n\n const actualRotation = $derived(\n rotation !== undefined ? rotation : (documentState.current?.rotation ?? Rotation.Degree0),\n );\n</script>\n\n<PendingRedactions\n {documentId}\n {pageIndex}\n scale={actualScale}\n rotation={actualRotation}\n {selectionMenu}\n {selectionMenuSnippet}\n/>\n<MarqueeRedact {documentId} {pageIndex} scale={actualScale} />\n<SelectionRedact {documentId} {pageIndex} scale={actualScale} />\n"],"names":["useRedactionPlugin","usePlugin","RedactionPlugin","id","useRedactionCapability","useCapability","color","opacity","border","style","boundingRect","$$props","rect","b","div","root_1","__pointerdown","$$args","__touchstart","$","template_effect","styles","set_style","origin","x","scale","y","size","width","height","onClick","cursor","className","stroke","fill","redactionPlugin","documentState","useDocumentState","documentId","state","actualScale","derived","_a","current","user_effect","plugin","registerMarqueeOnPage","pageIndex","callback","onPreview","newRect","set","set_class","left","get","top","consequent","rotation","prop","Rotation","Degree0","bboxStroke","redactionCapability","items","proxy","selectedId","select","e","stopPropagation","provides","forDocument","selectPending","shouldShowMenu","itemId","selectionMenu","selectionMenuSnippet","buildContext","item","type","redactionValue","scoped","currentState","getState","pending","selected","page","off1","onPendingChange","map","off2","onSelectedChange","sel","menuPlacement","suggestTop","spaceAbove","spaceBelow","buildMenuProps","menuWrapperProps","context","placement","$$anchor","div_1","first_child","fragment_2","children","$$arg0","menuProps","result","result_component","spread_props","props","CounterRotate","consequent_3","div_2","fragment_9","Highlight","rects","result_component_1","consequent_5","consequent_8","kind","consequent_4","$$render","alternate_2","length","consequent_9","onRedactionSelectionChange","formattedSelection","selection","find","s","segmentRects","actualRotation","PendingRedactions","node","MarqueeRedact","node_1","SelectionRedact","getDocumentId","capability","initialDocumentState","scopedProvides","docId","scope","onStateChange","newState"],"mappings":"ilBAQaA,EAAA,IAA2BC,YAA2BC,EAAAA,gBAAgBC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C,uCAIpFyE,EAAgBC,EAAA,oGAGR9F,gCACG4F,iIAIXG,EAAaC,EAAA,oGAAiChG,MAC9CiG,iBAAe,oGAAiCjG,2BAXjD,iDLnB6BkG,IACrB,MAAAC,EAAavI,QAEfmC,EAAQpB,EAAAoB,cAA+BqG,EAAAA,uBAGrC,MAAAtG,YAAsBoG,GAGtBG,EAAA1H,EAAAsB,QAAA,IACJkG,EAAWtE,gBAAY/B,GAAaqG,EAAWtE,SAASC,kBAAYhC,IAAc,aAGpFnB,EAAAyB,uBACQyB,EAAWsE,EAAWtE,SACtByE,QAAQxG,OAET+B,IAAayE,cAChB3H,EAAAgC,IAAAZ,EAAQqG,EAAAA,sBAAA,GAIJ,MAAAG,EAAQ1E,EAASC,YAAYwE,aAIjCvG,EAAQwG,EAAM7D,YAAA,EAChB,OAASf,GAEPhD,EAAAgC,IAAAZ,EAAQqG,EAAAA,sBAAA,EACV,CAGO,OAAAG,EAAMC,cAAeC,IAC1B9H,EAAAgC,IAAAZ,EAAQ0G,GAAA,QAKN,YAAA5E,gBACKwE,EACT,EACI,SAAAtG,gBACKA,EACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-redaction.svelte.ts","../../src/svelte/components/highlight.svelte","../../src/svelte/components/marquee-redact.svelte","../../src/svelte/components/pending-redactions.svelte","../../src/svelte/components/selection-redact.svelte","../../src/svelte/components/redaction-layer.svelte"],"sourcesContent":["import {\n RedactionPlugin,\n initialDocumentState,\n RedactionDocumentState,\n RedactionScope,\n} from '@embedpdf/plugin-redaction';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useRedactionPlugin = () => usePlugin<RedactionPlugin>(RedactionPlugin.id);\nexport const useRedactionCapability = () => useCapability<RedactionPlugin>(RedactionPlugin.id);\n\n// Define the return type explicitly to maintain type safety\ninterface UseRedactionReturn {\n provides: RedactionScope | null;\n state: RedactionDocumentState;\n}\n\n/**\n * Hook for redaction state for a specific document\n * @param getDocumentId Document ID getter function\n */\nexport const useRedaction = (getDocumentId: () => string | null): UseRedactionReturn => {\n const capability = useRedactionCapability();\n\n let state = $state<RedactionDocumentState>(initialDocumentState);\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n // Scoped capability for current docId\n const scopedProvides = $derived(\n capability.provides && documentId ? capability.provides.forDocument(documentId) : null,\n );\n\n $effect(() => {\n const provides = capability.provides;\n const docId = documentId;\n\n if (!provides || !docId) {\n state = initialDocumentState;\n return;\n }\n\n const scope = provides.forDocument(docId);\n\n // Get initial state\n try {\n state = scope.getState();\n } catch (e) {\n // Handle case where state might not be ready\n state = initialDocumentState;\n }\n\n // Subscribe to state changes for THIS docId\n return scope.onStateChange((newState) => {\n state = newState;\n });\n });\n\n return {\n get provides() {\n return scopedProvides;\n },\n get state() {\n return state;\n },\n };\n};\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n\n interface HighlightProps {\n color?: string;\n opacity?: number;\n border?: string;\n rects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent | TouchEvent) => void;\n style?: string;\n }\n\n let {\n color = '#FFFF00',\n opacity = 1,\n border = '1px solid red',\n rects,\n rect,\n scale,\n onClick,\n style = '',\n }: HighlightProps = $props();\n\n // Rename rect to boundingRect for clarity\n const boundingRect = rect;\n</script>\n\n{#each rects as b, i (i)}\n <div\n onpointerdown={onClick}\n ontouchstart={onClick}\n style:position=\"absolute\"\n style:border\n style:left={`${(boundingRect ? b.origin.x - boundingRect.origin.x : b.origin.x) * scale}px`}\n style:top={`${(boundingRect ? b.origin.y - boundingRect.origin.y : b.origin.y) * scale}px`}\n style:width={`${b.size.width * scale}px`}\n style:height={`${b.size.height * scale}px`}\n style:background={color}\n style:opacity\n style:pointer-events={onClick ? 'auto' : 'none'}\n style:cursor={onClick ? 'pointer' : 'default'}\n style:z-index={onClick ? '1' : undefined}\n {style}\n ></div>\n{/each}\n","<script lang=\"ts\">\n import { useDocumentState } from '@embedpdf/core/svelte';\n import type { Rect } from '@embedpdf/models';\n import { useRedactionPlugin } from '../hooks/use-redaction.svelte';\n\n interface 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\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n className = '',\n stroke = 'red',\n fill = 'transparent',\n }: MarqueeRedactProps = $props();\n\n const redactionPlugin = useRedactionPlugin();\n const documentState = useDocumentState(() => documentId);\n let rect = $state<Rect | null>(null);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n $effect(() => {\n if (!redactionPlugin.plugin || !documentId) {\n rect = null;\n return;\n }\n\n return redactionPlugin.plugin.registerMarqueeOnPage({\n documentId,\n pageIndex,\n scale: actualScale,\n callback: {\n onPreview: (newRect) => {\n rect = newRect;\n },\n },\n });\n });\n</script>\n\n{#if rect}\n <div\n class={className}\n style:position=\"absolute\"\n style:pointer-events=\"none\"\n style:left={`${rect.origin.x * actualScale}px`}\n style:top={`${rect.origin.y * actualScale}px`}\n style:width={`${rect.size.width * actualScale}px`}\n style:height={`${rect.size.height * actualScale}px`}\n style:border={`1px solid ${stroke}`}\n style:background={fill}\n style:box-sizing=\"border-box\"\n ></div>\n{/if}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import type { Rect } from '@embedpdf/models';\n import { Rotation } from '@embedpdf/models';\n import { CounterRotate } from '@embedpdf/utils/svelte';\n import type { MenuWrapperProps, SelectionMenuPlacement } from '@embedpdf/utils/svelte';\n import type { RedactionItem } from '@embedpdf/plugin-redaction';\n import { useRedactionCapability } from '../hooks/use-redaction.svelte';\n import Highlight from './highlight.svelte';\n import type {\n RedactionSelectionContext,\n RedactionSelectionMenuRenderFn,\n RedactionSelectionMenuProps,\n } from '../types';\n\n interface Props {\n documentId: string;\n pageIndex: number;\n scale: number;\n rotation?: Rotation;\n bboxStroke?: string;\n selectionMenu?: RedactionSelectionMenuRenderFn;\n selectionMenuSnippet?: Snippet<[RedactionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale,\n rotation = Rotation.Degree0,\n bboxStroke = 'rgba(0,0,0,0.8)',\n selectionMenu,\n selectionMenuSnippet,\n }: Props = $props();\n\n const redactionCapability = useRedactionCapability();\n\n let items = $state<RedactionItem[]>([]);\n let selectedId = $state<string | null>(null);\n\n $effect(() => {\n const redactionValue = redactionCapability.provides;\n if (!redactionValue) {\n items = [];\n selectedId = null;\n return;\n }\n\n const scoped = redactionValue.forDocument(documentId);\n const currentState = scoped.getState();\n items = currentState.pending[pageIndex] ?? [];\n selectedId = currentState.selected?.page === pageIndex ? currentState.selected.id : null;\n\n const off1 = scoped.onPendingChange((map) => {\n items = map[pageIndex] ?? [];\n });\n\n const off2 = scoped.onSelectedChange((sel) => {\n selectedId = sel?.page === pageIndex ? sel.id : null;\n });\n\n return () => {\n off1?.();\n off2?.();\n };\n });\n\n function select(e: MouseEvent | TouchEvent, id: string) {\n e.stopPropagation();\n if (!redactionCapability.provides) return;\n redactionCapability.provides.forDocument(documentId).selectPending(pageIndex, id);\n }\n\n function shouldShowMenu(itemId: string): boolean {\n const isSelected = selectedId === itemId;\n return isSelected && (!!selectionMenu || !!selectionMenuSnippet);\n }\n\n function buildContext(item: RedactionItem): RedactionSelectionContext {\n return { type: 'redaction', item, pageIndex };\n }\n\n const menuPlacement: SelectionMenuPlacement = {\n suggestTop: false,\n spaceAbove: 0,\n spaceBelow: 0,\n };\n\n function buildMenuProps(\n item: RedactionItem,\n rect: Rect,\n menuWrapperProps: MenuWrapperProps,\n ): RedactionSelectionMenuProps {\n return {\n context: buildContext(item),\n selected: selectedId === item.id,\n rect,\n placement: menuPlacement,\n menuWrapperProps,\n };\n }\n</script>\n\n{#if items.length}\n <div style=\"position: absolute; inset: 0; pointer-events: none;\">\n {#each items as item (item.id)}\n {#if item.kind === 'area'}\n <div\n style=\"\n position: absolute;\n left: {item.rect.origin.x * scale}px;\n top: {item.rect.origin.y * scale}px;\n width: {item.rect.size.width * scale}px;\n height: {item.rect.size.height * scale}px;\n background: transparent;\n outline: {selectedId === item.id ? `1px solid ${bboxStroke}` : 'none'};\n outline-offset: 2px;\n border: 1px solid red;\n pointer-events: auto;\n cursor: pointer;\n \"\n onpointerdown={(e) => select(e, item.id)}\n ontouchstart={(e) => select(e, item.id)}\n ></div>\n\n {#if shouldShowMenu(item.id)}\n <CounterRotate\n rect={{\n origin: { x: item.rect.origin.x * scale, y: item.rect.origin.y * scale },\n size: { width: item.rect.size.width * scale, height: item.rect.size.height * scale },\n }}\n {rotation}\n >\n {#snippet children({ rect, menuWrapperProps })}\n {@const menuProps = buildMenuProps(item, rect, menuWrapperProps)}\n {#if selectionMenu}\n {@const result = selectionMenu(menuProps)}\n {#if result}\n <result.component {...result.props} />\n {/if}\n {:else if selectionMenuSnippet}\n {@render selectionMenuSnippet(menuProps)}\n {/if}\n {/snippet}\n </CounterRotate>\n {/if}\n {:else}\n <div\n style=\"\n position: absolute;\n left: {item.rect.origin.x * scale}px;\n top: {item.rect.origin.y * scale}px;\n width: {item.rect.size.width * scale}px;\n height: {item.rect.size.height * scale}px;\n background: transparent;\n outline: {selectedId === item.id ? `1px solid ${bboxStroke}` : 'none'};\n outline-offset: 2px;\n pointer-events: auto;\n cursor: {selectedId === item.id ? 'pointer' : 'default'};\n \"\n >\n <Highlight\n rect={item.rect}\n rects={item.rects}\n color=\"transparent\"\n border=\"1px solid red\"\n {scale}\n onClick={(e) => select(e, item.id)}\n />\n </div>\n\n {#if shouldShowMenu(item.id)}\n <CounterRotate\n rect={{\n origin: { x: item.rect.origin.x * scale, y: item.rect.origin.y * scale },\n size: { width: item.rect.size.width * scale, height: item.rect.size.height * scale },\n }}\n {rotation}\n >\n {#snippet children({ rect, menuWrapperProps })}\n {@const menuProps = buildMenuProps(item, rect, menuWrapperProps)}\n {#if selectionMenu}\n {@const result = selectionMenu(menuProps)}\n {#if result}\n <result.component {...result.props} />\n {/if}\n {:else if selectionMenuSnippet}\n {@render selectionMenuSnippet(menuProps)}\n {/if}\n {/snippet}\n </CounterRotate>\n {/if}\n {/if}\n {/each}\n </div>\n{/if}\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n import { useRedactionPlugin } from '../hooks/use-redaction.svelte';\n import Highlight from './highlight.svelte';\n\n interface SelectionRedactProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n }\n\n let { documentId, pageIndex, scale }: SelectionRedactProps = $props();\n\n const redactionPlugin = useRedactionPlugin();\n let rects = $state<Rect[]>([]);\n let boundingRect = $state<Rect | null>(null);\n\n $effect(() => {\n if (!redactionPlugin.plugin) {\n rects = [];\n boundingRect = null;\n return;\n }\n\n return redactionPlugin.plugin.onRedactionSelectionChange(documentId, (formattedSelection) => {\n const selection = formattedSelection.find((s) => s.pageIndex === pageIndex);\n rects = selection?.segmentRects ?? [];\n boundingRect = selection?.rect ?? null;\n });\n });\n</script>\n\n{#if boundingRect}\n <div\n style:mix-blend-mode=\"normal\"\n style:pointer-events=\"none\"\n style:position=\"absolute\"\n style:inset=\"0\"\n >\n <Highlight color=\"transparent\" opacity={1} {rects} {scale} border=\"1px solid red\" />\n </div>\n{/if}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import { Rotation } from '@embedpdf/models';\n import PendingRedactions from './pending-redactions.svelte';\n import MarqueeRedact from './marquee-redact.svelte';\n import SelectionRedact from './selection-redact.svelte';\n import type { RedactionSelectionMenuRenderFn, RedactionSelectionMenuProps } from '../types';\n\n interface 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 /** Render function for selection menu (schema-driven approach) */\n selectionMenu?: RedactionSelectionMenuRenderFn;\n /** Snippet for custom selection menu (slot-based approach) */\n selectionMenuSnippet?: Snippet<[RedactionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale,\n rotation,\n selectionMenu,\n selectionMenuSnippet,\n }: RedactionLayerProps = $props();\n\n const documentState = useDocumentState(() => documentId);\n\n const actualScale = $derived(scale !== undefined ? scale : (documentState.current?.scale ?? 1));\n\n const actualRotation = $derived(\n rotation !== undefined ? rotation : (documentState.current?.rotation ?? Rotation.Degree0),\n );\n</script>\n\n<PendingRedactions\n {documentId}\n {pageIndex}\n scale={actualScale}\n rotation={actualRotation}\n {selectionMenu}\n {selectionMenuSnippet}\n/>\n<MarqueeRedact {documentId} {pageIndex} scale={actualScale} />\n<SelectionRedact {documentId} {pageIndex} scale={actualScale} />\n"],"names":["$$anchor"],"mappings":";;;;;;;AAQa,MAAA,qBAAA,MAA2B,UAA2B,gBAAgB,EAAE;AACxE,MAAA,yBAAA,MAA+B,cAA+B,gBAAgB,EAAE;MAYhF,eAAA,CAAgB,kBAA2D;AAChF,QAAA,aAAa,uBAAA;AAEf,MAAA,wBAAuC,oBAAoB,CAAA;AAGzD,QAAA,uBAAsB,aAAA;AAGtB,QAAA,iBAAA,EAAA,QAAA,MACJ,WAAW,kBAAY,UAAA,IAAa,WAAW,SAAS,kBAAY,UAAU,CAAA,IAAI,IAAA;AAGpF,IAAA,kBAAc;UACN,WAAW,WAAW;AACtB,UAAA,cAAQ,UAAA;SAET,YAAA,CAAa,OAAO;AACvB,QAAA,IAAA,OAAQ,sBAAA,IAAA;;IAEV;AAEM,UAAA,QAAQ,SAAS,YAAY,KAAK;QAGpC;YACF,OAAQ,MAAM,SAAA,GAAA,IAAA;AAAA,IAChB,SAAS,GAAG;AAEV,QAAA,IAAA,OAAQ,sBAAA,IAAA;AAAA,IACV;AAGO,WAAA,MAAM,cAAA,CAAe,aAAa;AACvC,QAAA,IAAA,OAAQ,UAAA,I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mC,IAAI;AAE3C,IAAA,YAAO,MAAO;SACP,gBAAgB,QAAQ;YAC3B,OAAK,CAAA,GAAA,IAAA;AACL,QAAA,IAAA,cAAe,IAAI;;IAErB;AAEO,WAAA,gBAAgB,OAAO,2BAA0B,QAAA,YAAA,CAAc,uBAAuB;YACrF,YAAY,mBAAmB,MAAM,MAAM,EAAE,cAAS,QAAA,SAAA;YAC5D,QAAQ,uCAAW,iBAAY,CAAA,GAAA,IAAA;AAC/B,QAAA,IAAA,eAAe,uCAAW,SAAQ,MAAI,IAAA;AAAA,IACxC,CAAC;AAAA,EACH,CAAC;;;;;;;;;;;;;;;iBAUyC;AAAA;;;;;;;;;;;;gBAPvC,YAAY,EAAA,UAAA,UAAA;AAAA;;;;AAFjB;;4CC9BA;;AAiCQ,QAAA,gBAAgB,iBAAgB,MAAA,QAAA,UAAA;QAEhC,cAAW,EAAA,QAAA,MAAA;;AAAA,mBAAA,UAAsB,SAAS,QAAA,UAAY,mBAAc,YAAd,mBAAuB,UAAS;AAAA,GAAC;AAEvF,QAAA;;gCACS,8BAAwB,mBAAc,YAAd,mBAAuB,aAAY,SAAS;AAAA,GAAO;;;;;;;;;;;mBAOnF,WAAW;AAAA;;mBACR,cAAc;AAAA;;;;;;;;;;;;;;;;;mBAIqB,WAAW;AAAA;;;;;;;;;;;mBACT,WAAW;AAAA;;;;AAX5D;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-redaction.svelte.ts","../../src/svelte/components/highlight.svelte","../../src/svelte/components/marquee-redact.svelte","../../src/svelte/components/pending-redactions.svelte","../../src/svelte/components/selection-redact.svelte","../../src/svelte/components/redaction-layer.svelte"],"sourcesContent":["import {\n RedactionPlugin,\n initialDocumentState,\n RedactionDocumentState,\n RedactionScope,\n} from '@embedpdf/plugin-redaction';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useRedactionPlugin = () => usePlugin<RedactionPlugin>(RedactionPlugin.id);\nexport const useRedactionCapability = () => useCapability<RedactionPlugin>(RedactionPlugin.id);\n\n// Define the return type explicitly to maintain type safety\ninterface UseRedactionReturn {\n provides: RedactionScope | null;\n state: RedactionDocumentState;\n}\n\n/**\n * Hook for redaction state for a specific document\n * @param getDocumentId Document ID getter function\n */\nexport const useRedaction = (getDocumentId: () => string | null): UseRedactionReturn => {\n const capability = useRedactionCapability();\n\n let state = $state<RedactionDocumentState>(initialDocumentState);\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n // Scoped capability for current docId\n const scopedProvides = $derived(\n capability.provides && documentId ? capability.provides.forDocument(documentId) : null,\n );\n\n $effect(() => {\n const provides = capability.provides;\n const docId = documentId;\n\n if (!provides || !docId) {\n state = initialDocumentState;\n return;\n }\n\n const scope = provides.forDocument(docId);\n\n // Get initial state\n try {\n state = scope.getState();\n } catch (e) {\n // Handle case where state might not be ready\n state = initialDocumentState;\n }\n\n // Subscribe to state changes for THIS docId\n return scope.onStateChange((newState) => {\n state = newState;\n });\n });\n\n return {\n get provides() {\n return scopedProvides;\n },\n get state() {\n return state;\n },\n };\n};\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n\n interface HighlightProps {\n color?: string;\n opacity?: number;\n border?: string;\n rects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent | TouchEvent) => void;\n style?: string;\n }\n\n let {\n color = '#FFFF00',\n opacity = 1,\n border = '1px solid red',\n rects,\n rect,\n scale,\n onClick,\n style = '',\n }: HighlightProps = $props();\n\n // Rename rect to boundingRect for clarity\n const boundingRect = rect;\n</script>\n\n{#each rects as b, i (i)}\n <div\n onpointerdown={onClick}\n ontouchstart={onClick}\n style:position=\"absolute\"\n style:border\n style:left={`${(boundingRect ? b.origin.x - boundingRect.origin.x : b.origin.x) * scale}px`}\n style:top={`${(boundingRect ? b.origin.y - boundingRect.origin.y : b.origin.y) * scale}px`}\n style:width={`${b.size.width * scale}px`}\n style:height={`${b.size.height * scale}px`}\n style:background={color}\n style:opacity\n style:pointer-events={onClick ? 'auto' : 'none'}\n style:cursor={onClick ? 'pointer' : 'default'}\n style:z-index={onClick ? '1' : undefined}\n {style}\n ></div>\n{/each}\n","<script lang=\"ts\">\n import { useDocumentState } from '@embedpdf/core/svelte';\n import type { Rect } from '@embedpdf/models';\n import { useRedactionPlugin } from '../hooks/use-redaction.svelte';\n\n interface 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\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n className = '',\n stroke = 'red',\n fill = 'transparent',\n }: MarqueeRedactProps = $props();\n\n const redactionPlugin = useRedactionPlugin();\n const documentState = useDocumentState(() => documentId);\n let rect = $state<Rect | null>(null);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n $effect(() => {\n if (!redactionPlugin.plugin || !documentId) {\n rect = null;\n return;\n }\n\n return redactionPlugin.plugin.registerMarqueeOnPage({\n documentId,\n pageIndex,\n scale: actualScale,\n callback: {\n onPreview: (newRect) => {\n rect = newRect;\n },\n },\n });\n });\n</script>\n\n{#if rect}\n <div\n class={className}\n style:position=\"absolute\"\n style:pointer-events=\"none\"\n style:left={`${rect.origin.x * actualScale}px`}\n style:top={`${rect.origin.y * actualScale}px`}\n style:width={`${rect.size.width * actualScale}px`}\n style:height={`${rect.size.height * actualScale}px`}\n style:border={`1px solid ${stroke}`}\n style:background={fill}\n style:box-sizing=\"border-box\"\n ></div>\n{/if}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import type { Rect } from '@embedpdf/models';\n import { Rotation } from '@embedpdf/models';\n import { CounterRotate } from '@embedpdf/utils/svelte';\n import type { MenuWrapperProps, SelectionMenuPlacement } from '@embedpdf/utils/svelte';\n import type { RedactionItem } from '@embedpdf/plugin-redaction';\n import { useRedactionCapability } from '../hooks/use-redaction.svelte';\n import Highlight from './highlight.svelte';\n import type {\n RedactionSelectionContext,\n RedactionSelectionMenuRenderFn,\n RedactionSelectionMenuProps,\n } from '../types';\n\n interface Props {\n documentId: string;\n pageIndex: number;\n scale: number;\n rotation?: Rotation;\n bboxStroke?: string;\n selectionMenu?: RedactionSelectionMenuRenderFn;\n selectionMenuSnippet?: Snippet<[RedactionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale,\n rotation = Rotation.Degree0,\n bboxStroke = 'rgba(0,0,0,0.8)',\n selectionMenu,\n selectionMenuSnippet,\n }: Props = $props();\n\n const redactionCapability = useRedactionCapability();\n\n let items = $state<RedactionItem[]>([]);\n let selectedId = $state<string | null>(null);\n\n $effect(() => {\n const redactionValue = redactionCapability.provides;\n if (!redactionValue) {\n items = [];\n selectedId = null;\n return;\n }\n\n const scoped = redactionValue.forDocument(documentId);\n const currentState = scoped.getState();\n items = currentState.pending[pageIndex] ?? [];\n selectedId = currentState.selected?.page === pageIndex ? currentState.selected.id : null;\n\n const off1 = scoped.onPendingChange((map) => {\n items = map[pageIndex] ?? [];\n });\n\n const off2 = scoped.onSelectedChange((sel) => {\n selectedId = sel?.page === pageIndex ? sel.id : null;\n });\n\n return () => {\n off1?.();\n off2?.();\n };\n });\n\n function select(e: MouseEvent | TouchEvent, id: string) {\n e.stopPropagation();\n if (!redactionCapability.provides) return;\n redactionCapability.provides.forDocument(documentId).selectPending(pageIndex, id);\n }\n\n function shouldShowMenu(itemId: string): boolean {\n const isSelected = selectedId === itemId;\n return isSelected && (!!selectionMenu || !!selectionMenuSnippet);\n }\n\n function buildContext(item: RedactionItem): RedactionSelectionContext {\n return { type: 'redaction', item, pageIndex };\n }\n\n const menuPlacement: SelectionMenuPlacement = {\n suggestTop: false,\n spaceAbove: 0,\n spaceBelow: 0,\n };\n\n function buildMenuProps(\n item: RedactionItem,\n rect: Rect,\n menuWrapperProps: MenuWrapperProps,\n ): RedactionSelectionMenuProps {\n return {\n context: buildContext(item),\n selected: selectedId === item.id,\n rect,\n placement: menuPlacement,\n menuWrapperProps,\n };\n }\n</script>\n\n{#if items.length}\n <div style=\"position: absolute; inset: 0; pointer-events: none;\">\n {#each items as item (item.id)}\n {#if item.kind === 'area'}\n <div\n style=\"\n position: absolute;\n left: {item.rect.origin.x * scale}px;\n top: {item.rect.origin.y * scale}px;\n width: {item.rect.size.width * scale}px;\n height: {item.rect.size.height * scale}px;\n background: transparent;\n outline: {selectedId === item.id ? `1px solid ${bboxStroke}` : 'none'};\n outline-offset: 2px;\n border: 1px solid red;\n pointer-events: auto;\n cursor: pointer;\n \"\n onpointerdown={(e) => select(e, item.id)}\n ontouchstart={(e) => select(e, item.id)}\n ></div>\n\n {#if shouldShowMenu(item.id)}\n <CounterRotate\n rect={{\n origin: { x: item.rect.origin.x * scale, y: item.rect.origin.y * scale },\n size: { width: item.rect.size.width * scale, height: item.rect.size.height * scale },\n }}\n {rotation}\n >\n {#snippet children({ rect, menuWrapperProps })}\n {@const menuProps = buildMenuProps(item, rect, menuWrapperProps)}\n {#if selectionMenu}\n {@const result = selectionMenu(menuProps)}\n {#if result}\n <result.component {...result.props} />\n {/if}\n {:else if selectionMenuSnippet}\n {@render selectionMenuSnippet(menuProps)}\n {/if}\n {/snippet}\n </CounterRotate>\n {/if}\n {:else}\n <div\n style=\"\n position: absolute;\n left: {item.rect.origin.x * scale}px;\n top: {item.rect.origin.y * scale}px;\n width: {item.rect.size.width * scale}px;\n height: {item.rect.size.height * scale}px;\n background: transparent;\n outline: {selectedId === item.id ? `1px solid ${bboxStroke}` : 'none'};\n outline-offset: 2px;\n pointer-events: auto;\n cursor: {selectedId === item.id ? 'pointer' : 'default'};\n \"\n >\n <Highlight\n rect={item.rect}\n rects={item.rects}\n color=\"transparent\"\n border=\"1px solid red\"\n {scale}\n onClick={(e) => select(e, item.id)}\n />\n </div>\n\n {#if shouldShowMenu(item.id)}\n <CounterRotate\n rect={{\n origin: { x: item.rect.origin.x * scale, y: item.rect.origin.y * scale },\n size: { width: item.rect.size.width * scale, height: item.rect.size.height * scale },\n }}\n {rotation}\n >\n {#snippet children({ rect, menuWrapperProps })}\n {@const menuProps = buildMenuProps(item, rect, menuWrapperProps)}\n {#if selectionMenu}\n {@const result = selectionMenu(menuProps)}\n {#if result}\n <result.component {...result.props} />\n {/if}\n {:else if selectionMenuSnippet}\n {@render selectionMenuSnippet(menuProps)}\n {/if}\n {/snippet}\n </CounterRotate>\n {/if}\n {/if}\n {/each}\n </div>\n{/if}\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n import { useRedactionPlugin } from '../hooks/use-redaction.svelte';\n import Highlight from './highlight.svelte';\n\n interface SelectionRedactProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n }\n\n let { documentId, pageIndex, scale }: SelectionRedactProps = $props();\n\n const redactionPlugin = useRedactionPlugin();\n let rects = $state<Rect[]>([]);\n let boundingRect = $state<Rect | null>(null);\n\n $effect(() => {\n if (!redactionPlugin.plugin) {\n rects = [];\n boundingRect = null;\n return;\n }\n\n return redactionPlugin.plugin.onRedactionSelectionChange(documentId, (formattedSelection) => {\n const selection = formattedSelection.find((s) => s.pageIndex === pageIndex);\n rects = selection?.segmentRects ?? [];\n boundingRect = selection?.rect ?? null;\n });\n });\n</script>\n\n{#if boundingRect}\n <div\n style:mix-blend-mode=\"normal\"\n style:pointer-events=\"none\"\n style:position=\"absolute\"\n style:inset=\"0\"\n >\n <Highlight color=\"transparent\" opacity={1} {rects} {scale} border=\"1px solid red\" />\n </div>\n{/if}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import { Rotation } from '@embedpdf/models';\n import PendingRedactions from './pending-redactions.svelte';\n import MarqueeRedact from './marquee-redact.svelte';\n import SelectionRedact from './selection-redact.svelte';\n import type { RedactionSelectionMenuRenderFn, RedactionSelectionMenuProps } from '../types';\n\n interface 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 /** Render function for selection menu (schema-driven approach) */\n selectionMenu?: RedactionSelectionMenuRenderFn;\n /** Snippet for custom selection menu (slot-based approach) */\n selectionMenuSnippet?: Snippet<[RedactionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale,\n rotation,\n selectionMenu,\n selectionMenuSnippet,\n }: RedactionLayerProps = $props();\n\n const documentState = useDocumentState(() => documentId);\n\n const actualScale = $derived(scale !== undefined ? scale : (documentState.current?.scale ?? 1));\n\n const actualRotation = $derived(\n rotation !== undefined ? rotation : (documentState.current?.rotation ?? Rotation.Degree0),\n );\n</script>\n\n<PendingRedactions\n {documentId}\n {pageIndex}\n scale={actualScale}\n rotation={actualRotation}\n {selectionMenu}\n {selectionMenuSnippet}\n/>\n<MarqueeRedact {documentId} {pageIndex} scale={actualScale} />\n<SelectionRedact {documentId} {pageIndex} scale={actualScale} />\n"],"names":["root_1","$$anchor","PendingRedactions","MarqueeRedact","SelectionRedact"],"mappings":";;;;;;;AAQa,MAAA,qBAAA,MAA2B,UAA2B,gBAAgB,EAAE;AACxE,MAAA,yBAAA,MAA+B,cAA+B,gBAAgB,EAAE;MAYhF,eAAA,CAAgB,kBAA2D;AAChF,QAAA,aAAa,uBAAA;MAEf,QAAQ,EAAA,cAA+B,oBAAoB,CAAA;AAGzD,QAAA,uBAAsB,aAAA;AAGtB,QAAA,iBAAA,EAAA,QAAA,MACJ,WAAW,kBAAY,UAAA,IAAa,WAAW,SAAS,kBAAY,UAAU,CAAA,IAAI,IAAA;AAGpF,IAAA,kBAAc;UACN,WAAW,WAAW;AACtB,UAAA,cAAQ,UAAA;SAET,YAAA,CAAa,OAAO;AACvB,QAAA,IAAA,OAAQ,sBAAA,IAAA;;IAEV;AAEM,UAAA,QAAQ,SAAS,YAAY,KAAK;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AC;;;;;UAIA,MAAE,OAAA;kBAAF,KAAE,IAAA,CAAA,GAAA;AAAA;;;;;2BAAF,GAAE;AAMA,gBAAS,QAAA;AAAA;iBAA8B;AAAA;uBAAI,KAAK;AAAA;;;;;;cANlD,GAAE;0BAAF,GAAE;AAAA;;gBADA,YAAY,EAAA,UAAA,UAAA;AAAA;;;;AAFjB;;4CC9BA;;AAiCQ,QAAA,gBAAgB,iBAAgB,MAAA,QAAA,UAAA;QAEhC,cAAW,EAAA,QAAA,MAAA;;AAAA,mBAAA,UAAsB,SAAS,QAAA,UAAY,mBAAc,YAAd,mBAAuB,UAAS;AAAA,GAAC;AAEvF,QAAA;;gCACS,8BAAwB,mBAAc,YAAd,mBAAuB,aAAY,SAAS;AAAA,GAAO;;;AAI3FC,qBAAgB,MAAA;AAAA;;;;;;;mBAGR,WAAW;AAAA;;mBACR,cAAc;AAAA;;;;;;;;;AAIzBC,iBAAa,QAAA;AAAA;;;;;;;mBAAiC,WAAW;AAAA;;;AACzDC,mBAAe,QAAA;AAAA;;;;;;;mBAAiC,WAAW;AAAA;;;;AAX5D;"}
@@ -1,5 +1,6 @@
1
1
  import { Rotation } from '@embedpdf/models';
2
- import { RedactionSelectionMenuRenderFn } from './types';
2
+ import { SelectionMenuPlacement } from '@embedpdf/utils/vue';
3
+ import { RedactionSelectionContext, RedactionSelectionMenuRenderFn } from './types';
3
4
  interface PendingRedactionsProps {
4
5
  documentId: string;
5
6
  pageIndex: number;
@@ -9,23 +10,49 @@ interface PendingRedactionsProps {
9
10
  /** Render function for selection menu (schema-driven approach) */
10
11
  selectionMenu?: RedactionSelectionMenuRenderFn;
11
12
  }
12
- declare var __VLS_12: {
13
- context: any;
13
+ declare var __VLS_13: {
14
+ context: RedactionSelectionContext;
14
15
  selected: boolean;
15
- rect: any;
16
- placement: any;
17
- menuWrapperProps: any;
18
- }, __VLS_29: {
19
- context: any;
16
+ rect: {
17
+ origin: {
18
+ x: number;
19
+ y: number;
20
+ };
21
+ size: {
22
+ width: number;
23
+ height: number;
24
+ };
25
+ };
26
+ placement: SelectionMenuPlacement;
27
+ menuWrapperProps: {
28
+ style: import('vue').CSSProperties;
29
+ onPointerdown: (e: PointerEvent) => void;
30
+ onTouchstart: (e: TouchEvent) => void;
31
+ };
32
+ }, __VLS_32: {
33
+ context: RedactionSelectionContext;
20
34
  selected: boolean;
21
- rect: any;
22
- placement: any;
23
- menuWrapperProps: any;
35
+ rect: {
36
+ origin: {
37
+ x: number;
38
+ y: number;
39
+ };
40
+ size: {
41
+ width: number;
42
+ height: number;
43
+ };
44
+ };
45
+ placement: SelectionMenuPlacement;
46
+ menuWrapperProps: {
47
+ style: import('vue').CSSProperties;
48
+ onPointerdown: (e: PointerEvent) => void;
49
+ onTouchstart: (e: TouchEvent) => void;
50
+ };
24
51
  };
25
52
  type __VLS_Slots = {} & {
26
- 'selection-menu'?: (props: typeof __VLS_12) => any;
53
+ 'selection-menu'?: (props: typeof __VLS_13) => any;
27
54
  } & {
28
- 'selection-menu'?: (props: typeof __VLS_29) => any;
55
+ 'selection-menu'?: (props: typeof __VLS_32) => any;
29
56
  };
30
57
  declare const __VLS_base: import('vue').DefineComponent<PendingRedactionsProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<PendingRedactionsProps> & Readonly<{}>, {
31
58
  rotation: Rotation;
@@ -14,9 +14,28 @@ interface RedactionLayerProps {
14
14
  /** Optional menu renderer for a selected redaction */
15
15
  selectionMenu?: RedactionSelectionMenuRenderFn;
16
16
  }
17
- declare var __VLS_6: any;
17
+ declare var __VLS_8: {
18
+ context: import('./types').RedactionSelectionContext;
19
+ selected: boolean;
20
+ rect: {
21
+ origin: {
22
+ x: number;
23
+ y: number;
24
+ };
25
+ size: {
26
+ width: number;
27
+ height: number;
28
+ };
29
+ };
30
+ placement: import('@embedpdf/utils/vue').SelectionMenuPlacement;
31
+ menuWrapperProps: {
32
+ style: import('vue').CSSProperties;
33
+ onPointerdown: (e: PointerEvent) => void;
34
+ onTouchstart: (e: TouchEvent) => void;
35
+ };
36
+ };
18
37
  type __VLS_Slots = {} & {
19
- 'selection-menu'?: (props: typeof __VLS_6) => any;
38
+ 'selection-menu'?: (props: typeof __VLS_8) => any;
20
39
  };
21
40
  declare const __VLS_base: import('vue').DefineComponent<RedactionLayerProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<RedactionLayerProps> & Readonly<{}>, {
22
41
  bboxStroke: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-redaction",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",
@@ -35,16 +35,16 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@embedpdf/models": "2.0.0",
39
- "@embedpdf/utils": "2.0.0"
38
+ "@embedpdf/models": "2.0.2",
39
+ "@embedpdf/utils": "2.0.2"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/react": "^18.2.0",
43
43
  "typescript": "^5.0.0",
44
44
  "@embedpdf/build": "1.1.0",
45
- "@embedpdf/core": "2.0.0",
46
- "@embedpdf/plugin-interaction-manager": "2.0.0",
47
- "@embedpdf/plugin-selection": "2.0.0"
45
+ "@embedpdf/core": "2.0.2",
46
+ "@embedpdf/plugin-selection": "2.0.2",
47
+ "@embedpdf/plugin-interaction-manager": "2.0.2"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "preact": "^10.26.4",
@@ -52,9 +52,9 @@
52
52
  "react-dom": ">=16.8.0",
53
53
  "vue": ">=3.2.0",
54
54
  "svelte": ">=5 <6",
55
- "@embedpdf/core": "2.0.0",
56
- "@embedpdf/plugin-interaction-manager": "2.0.0",
57
- "@embedpdf/plugin-selection": "2.0.0"
55
+ "@embedpdf/core": "2.0.2",
56
+ "@embedpdf/plugin-selection": "2.0.2",
57
+ "@embedpdf/plugin-interaction-manager": "2.0.2"
58
58
  },
59
59
  "files": [
60
60
  "dist",