@embedpdf/plugin-redaction 1.4.1 → 2.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.
Files changed (63) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +573 -207
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +48 -13
  6. package/dist/lib/index.d.ts +1 -1
  7. package/dist/lib/redaction-plugin.d.ts +22 -8
  8. package/dist/lib/reducer.d.ts +4 -2
  9. package/dist/lib/selectors.d.ts +5 -3
  10. package/dist/lib/types.d.ts +68 -20
  11. package/dist/preact/index.cjs +1 -1
  12. package/dist/preact/index.cjs.map +1 -1
  13. package/dist/preact/index.js +86 -37
  14. package/dist/preact/index.js.map +1 -1
  15. package/dist/react/index.cjs +1 -1
  16. package/dist/react/index.cjs.map +1 -1
  17. package/dist/react/index.js +86 -37
  18. package/dist/react/index.js.map +1 -1
  19. package/dist/shared/components/marquee-redact.d.ts +4 -2
  20. package/dist/shared/components/pending-redactions.d.ts +4 -3
  21. package/dist/shared/components/redaction-layer.d.ts +11 -5
  22. package/dist/shared/components/selection-redact.d.ts +2 -1
  23. package/dist/shared/components/types.d.ts +6 -7
  24. package/dist/shared/hooks/use-redaction.d.ts +4 -4
  25. package/dist/shared-preact/components/marquee-redact.d.ts +4 -2
  26. package/dist/shared-preact/components/pending-redactions.d.ts +4 -3
  27. package/dist/shared-preact/components/redaction-layer.d.ts +11 -5
  28. package/dist/shared-preact/components/selection-redact.d.ts +2 -1
  29. package/dist/shared-preact/components/types.d.ts +6 -7
  30. package/dist/shared-preact/hooks/use-redaction.d.ts +4 -4
  31. package/dist/shared-react/components/marquee-redact.d.ts +4 -2
  32. package/dist/shared-react/components/pending-redactions.d.ts +4 -3
  33. package/dist/shared-react/components/redaction-layer.d.ts +11 -5
  34. package/dist/shared-react/components/selection-redact.d.ts +2 -1
  35. package/dist/shared-react/components/types.d.ts +6 -7
  36. package/dist/shared-react/hooks/use-redaction.d.ts +4 -4
  37. package/dist/svelte/components/highlight.svelte.d.ts +14 -0
  38. package/dist/svelte/components/index.d.ts +5 -0
  39. package/dist/svelte/components/marquee-redact.svelte.d.ts +16 -0
  40. package/dist/svelte/components/pending-redactions.svelte.d.ts +15 -0
  41. package/dist/svelte/components/redaction-layer.svelte.d.ts +20 -0
  42. package/dist/svelte/components/selection-redact.svelte.d.ts +8 -0
  43. package/dist/svelte/hooks/index.d.ts +1 -0
  44. package/dist/svelte/hooks/use-redaction.svelte.d.ts +21 -0
  45. package/dist/svelte/index.cjs +2 -0
  46. package/dist/svelte/index.cjs.map +1 -0
  47. package/dist/svelte/index.d.ts +4 -0
  48. package/dist/svelte/index.js +554 -0
  49. package/dist/svelte/index.js.map +1 -0
  50. package/dist/svelte/types.d.ts +10 -0
  51. package/dist/vue/components/highlight.vue.d.ts +2 -1
  52. package/dist/vue/components/marquee-redact.vue.d.ts +5 -2
  53. package/dist/vue/components/pending-redactions.vue.d.ts +18 -13
  54. package/dist/vue/components/redaction-layer.vue.d.ts +13 -4
  55. package/dist/vue/components/selection-redact.vue.d.ts +3 -1
  56. package/dist/vue/components/types.d.ts +9 -0
  57. package/dist/vue/hooks/use-redaction.d.ts +9 -102
  58. package/dist/vue/index.cjs +1 -1
  59. package/dist/vue/index.cjs.map +1 -1
  60. package/dist/vue/index.d.ts +1 -0
  61. package/dist/vue/index.js +219 -125
  62. package/dist/vue/index.js.map +1 -1
  63. package/package.json +18 -10
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/lib/types.ts","../src/lib/actions.ts","../src/lib/handlers/marquee-redact.handler.ts","../src/lib/redaction-plugin.ts","../src/lib/manifest.ts","../src/lib/reducer.ts","../src/lib/selectors.ts","../src/lib/index.ts"],"sourcesContent":["import { BasePluginConfig, EventHook } from '@embedpdf/core';\nimport { PdfErrorReason, Rect, Task } from '@embedpdf/models';\n\n// Redaction mode enum\nexport enum RedactionMode {\n MarqueeRedact = 'marqueeRedact',\n RedactSelection = 'redactSelection',\n}\n\nexport interface SelectedRedaction {\n page: number;\n id: string | null;\n}\n\nexport interface RedactionState {\n isRedacting: boolean;\n activeType: RedactionMode | null;\n pending: Record<number, RedactionItem[]>;\n pendingCount: number;\n selected: SelectedRedaction | null;\n}\n\nexport type RedactionItem =\n | {\n id: string;\n kind: 'text';\n page: number;\n rect: Rect;\n rects: Rect[];\n }\n | {\n id: string;\n kind: 'area';\n page: number;\n rect: Rect;\n };\n\nexport interface MarqueeRedactCallback {\n onPreview?: (rect: Rect | null) => void;\n onCommit?: (rect: Rect) => void;\n}\n\nexport interface RegisterMarqueeOnPageOptions {\n pageIndex: number;\n scale: number;\n callback: MarqueeRedactCallback;\n}\n\nexport interface RedactionPluginConfig extends BasePluginConfig {\n drawBlackBoxes: boolean;\n}\n\n// Add event types similar to annotation plugin\nexport type RedactionEvent =\n | {\n type: 'add';\n items: RedactionItem[];\n }\n | {\n type: 'remove';\n page: number;\n id: string;\n }\n | {\n type: 'clear';\n }\n | {\n type: 'commit';\n success: boolean;\n error?: PdfErrorReason;\n };\n\nexport interface RedactionCapability {\n queueCurrentSelectionAsPending: () => Task<boolean, PdfErrorReason>;\n\n enableMarqueeRedact: () => void;\n toggleMarqueeRedact: () => void;\n isMarqueeRedactActive: () => boolean;\n\n enableRedactSelection: () => void;\n toggleRedactSelection: () => void;\n isRedactSelectionActive: () => boolean;\n\n onPendingChange: EventHook<Record<number, RedactionItem[]>>;\n addPending: (items: RedactionItem[]) => void;\n removePending: (page: number, id: string) => void;\n clearPending: () => void;\n commitAllPending: () => Task<boolean, PdfErrorReason>;\n commitPending: (page: number, id: string) => Task<boolean, PdfErrorReason>;\n\n endRedaction: () => void;\n startRedaction: () => void;\n\n selectPending: (page: number, id: string) => void;\n deselectPending: () => void;\n\n // Event hook for redaction events\n onSelectedChange: EventHook<SelectedRedaction | null>;\n onRedactionEvent: EventHook<RedactionEvent>;\n onStateChange: EventHook<RedactionState>;\n}\n","import { Action } from '@embedpdf/core';\nimport { RedactionItem, RedactionMode } from './types';\n\nexport const START_REDACTION = 'START_REDACTION';\nexport const END_REDACTION = 'END_REDACTION';\nexport const SET_ACTIVE_TYPE = 'SET_ACTIVE_TYPE';\n\nexport const ADD_PENDING = 'ADD_PENDING';\nexport const REMOVE_PENDING = 'REMOVE_PENDING';\nexport const CLEAR_PENDING = 'CLEAR_PENDING';\n\nexport const SELECT_PENDING = 'SELECT_PENDING';\nexport const DESELECT_PENDING = 'DESELECT_PENDING';\n\nexport interface StartRedactionAction extends Action {\n type: typeof START_REDACTION;\n payload: RedactionMode;\n}\nexport interface EndRedactionAction extends Action {\n type: typeof END_REDACTION;\n}\nexport interface SetActiveTypeAction extends Action {\n type: typeof SET_ACTIVE_TYPE;\n payload: RedactionMode | null;\n}\n\nexport interface AddPendingAction extends Action {\n type: typeof ADD_PENDING;\n payload: RedactionItem[];\n}\nexport interface RemovePendingAction extends Action {\n type: typeof REMOVE_PENDING;\n payload: { page: number; id: string };\n}\nexport interface ClearPendingAction extends Action {\n type: typeof CLEAR_PENDING;\n}\n\nexport interface SelectPendingAction extends Action {\n type: typeof SELECT_PENDING;\n payload: { page: number; id: string };\n}\nexport interface DeselectPendingAction extends Action {\n type: typeof DESELECT_PENDING;\n}\n\nexport type RedactionAction =\n | StartRedactionAction\n | EndRedactionAction\n | SetActiveTypeAction\n | AddPendingAction\n | RemovePendingAction\n | ClearPendingAction\n | SelectPendingAction\n | DeselectPendingAction;\n\nexport const addPending = (items: RedactionItem[]): AddPendingAction => ({\n type: ADD_PENDING,\n payload: items,\n});\nexport const removePending = (page: number, id: string): RemovePendingAction => ({\n type: REMOVE_PENDING,\n payload: { page, id },\n});\nexport const clearPending = (): ClearPendingAction => ({ type: CLEAR_PENDING });\n\nexport const startRedaction = (mode: RedactionMode): StartRedactionAction => ({\n type: START_REDACTION,\n payload: mode,\n});\nexport const endRedaction = (): EndRedactionAction => ({ type: END_REDACTION });\nexport const setActiveType = (mode: RedactionMode | null): SetActiveTypeAction => ({\n type: SET_ACTIVE_TYPE,\n payload: mode,\n});\n\nexport const selectPending = (page: number, id: string): SelectPendingAction => ({\n type: SELECT_PENDING,\n payload: { page, id },\n});\nexport const deselectPending = (): DeselectPendingAction => ({ type: DESELECT_PENDING });\n","import { Position, Rect, Size } from '@embedpdf/models';\nimport { clamp } from '@embedpdf/core';\nimport {\n EmbedPdfPointerEvent,\n PointerEventHandlersWithLifecycle,\n} from '@embedpdf/plugin-interaction-manager';\n\nexport function createMarqueeHandler(opts: {\n pageSize: Size;\n scale: number;\n minDragPx?: number;\n onPreview?: (rect: Rect | null) => void;\n onCommit?: (rect: Rect) => void;\n}): PointerEventHandlersWithLifecycle<EmbedPdfPointerEvent> {\n const { pageSize, scale, minDragPx = 5, onPreview, onCommit } = opts;\n\n let start: Position | null = null;\n let last: Rect | null = null;\n\n return {\n onPointerDown: (pos, evt) => {\n start = pos;\n last = { origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } };\n onPreview?.(last);\n evt.setPointerCapture?.();\n },\n onPointerMove: (pos) => {\n if (!start) return;\n const x = clamp(pos.x, 0, pageSize.width);\n const y = clamp(pos.y, 0, pageSize.height);\n last = {\n origin: { x: Math.min(start.x, x), y: Math.min(start.y, y) },\n size: { width: Math.abs(x - start.x), height: Math.abs(y - start.y) },\n };\n onPreview?.(last);\n },\n onPointerUp: (_pos, evt) => {\n if (last) {\n const dragPx = Math.max(last.size.width, last.size.height) * scale;\n if (dragPx > minDragPx) onCommit?.(last);\n }\n start = null;\n last = null;\n onPreview?.(null);\n evt.releasePointerCapture?.();\n },\n onPointerCancel: (_pos, evt) => {\n start = null;\n last = null;\n onPreview?.(null);\n evt.releasePointerCapture?.();\n },\n };\n}\n","import {\n RedactionPluginConfig,\n RedactionCapability,\n RedactionState,\n RegisterMarqueeOnPageOptions,\n RedactionItem,\n SelectedRedaction,\n RedactionMode,\n RedactionEvent,\n} from './types';\nimport {\n BasePlugin,\n createBehaviorEmitter,\n PluginRegistry,\n refreshPages,\n Unsubscribe,\n} from '@embedpdf/core';\nimport {\n PdfErrorCode,\n PdfErrorReason,\n PdfTask,\n PdfTaskHelper,\n Rect,\n Task,\n uuidV4,\n} from '@embedpdf/models';\nimport {\n FormattedSelection,\n SelectionCapability,\n SelectionPlugin,\n} from '@embedpdf/plugin-selection';\nimport {\n InteractionManagerCapability,\n InteractionManagerPlugin,\n} from '@embedpdf/plugin-interaction-manager';\nimport {\n addPending,\n clearPending,\n deselectPending,\n endRedaction,\n removePending,\n selectPending,\n startRedaction,\n} from './actions';\nimport { createMarqueeHandler } from './handlers';\n\nexport class RedactionPlugin extends BasePlugin<\n RedactionPluginConfig,\n RedactionCapability,\n RedactionState\n> {\n static readonly id = 'redaction' as const;\n private config: RedactionPluginConfig;\n\n private selectionCapability: SelectionCapability | undefined;\n private interactionManagerCapability: InteractionManagerCapability | undefined;\n\n private readonly redactionSelection$ = createBehaviorEmitter<FormattedSelection[]>();\n private readonly pending$ = createBehaviorEmitter<Record<number, RedactionItem[]>>();\n private readonly selected$ = createBehaviorEmitter<SelectedRedaction | null>();\n private readonly state$ = createBehaviorEmitter<RedactionState>();\n private readonly events$ = createBehaviorEmitter<RedactionEvent>();\n\n private readonly unsubscribeSelectionChange: Unsubscribe | undefined;\n private readonly unsubscribeEndSelection: Unsubscribe | undefined;\n private readonly unsubscribeModeChange: Unsubscribe | undefined;\n\n constructor(id: string, registry: PluginRegistry, config: RedactionPluginConfig) {\n super(id, registry);\n this.config = config;\n\n this.selectionCapability = this.registry.getPlugin<SelectionPlugin>('selection')?.provides();\n this.interactionManagerCapability = this.registry\n .getPlugin<InteractionManagerPlugin>('interaction-manager')\n ?.provides();\n\n if (this.interactionManagerCapability) {\n this.interactionManagerCapability.registerMode({\n id: RedactionMode.MarqueeRedact,\n scope: 'page',\n exclusive: true,\n cursor: 'crosshair',\n });\n }\n\n if (this.interactionManagerCapability && this.selectionCapability) {\n this.interactionManagerCapability.registerMode({\n id: RedactionMode.RedactSelection,\n scope: 'page',\n exclusive: false,\n });\n this.selectionCapability.enableForMode(RedactionMode.RedactSelection);\n }\n\n this.unsubscribeModeChange = this.interactionManagerCapability?.onModeChange((state) => {\n if (state.activeMode === RedactionMode.RedactSelection) {\n this.dispatch(startRedaction(RedactionMode.RedactSelection));\n } else if (state.activeMode === RedactionMode.MarqueeRedact) {\n this.dispatch(startRedaction(RedactionMode.MarqueeRedact));\n } else {\n this.dispatch(endRedaction());\n }\n });\n\n this.unsubscribeSelectionChange = this.selectionCapability?.onSelectionChange(() => {\n if (!this.selectionCapability) return;\n if (!this.state.isRedacting) return;\n const formattedSelection = this.selectionCapability.getFormattedSelection();\n this.redactionSelection$.emit(formattedSelection);\n });\n\n this.unsubscribeEndSelection = this.selectionCapability?.onEndSelection(() => {\n if (!this.selectionCapability) return;\n if (!this.state.isRedacting) return;\n\n const formattedSelection = this.selectionCapability.getFormattedSelection();\n\n const items: RedactionItem[] = formattedSelection.map((s) => ({\n id: uuidV4(),\n kind: 'text',\n page: s.pageIndex,\n rect: s.rect,\n rects: s.segmentRects,\n }));\n\n this.dispatch(addPending(items));\n this.redactionSelection$.emit([]);\n this.selectionCapability.clear();\n this.pending$.emit(this.state.pending);\n if (items.length) {\n this.selectPending(items[items.length - 1].page, items[items.length - 1].id);\n }\n });\n }\n\n async initialize(_config: RedactionPluginConfig): Promise<void> {}\n\n protected buildCapability(): RedactionCapability {\n return {\n queueCurrentSelectionAsPending: () => this.queueCurrentSelectionAsPending(),\n\n enableMarqueeRedact: () => this.enableMarqueeRedact(),\n toggleMarqueeRedact: () => this.toggleMarqueeRedact(),\n isMarqueeRedactActive: () =>\n this.interactionManagerCapability?.getActiveMode() === RedactionMode.MarqueeRedact,\n\n enableRedactSelection: () => this.enableRedactSelection(),\n toggleRedactSelection: () => this.toggleRedactSelection(),\n isRedactSelectionActive: () =>\n this.interactionManagerCapability?.getActiveMode() === RedactionMode.RedactSelection,\n\n addPending: (items) => {\n this.dispatch(addPending(items));\n this.pending$.emit(this.state.pending);\n this.events$.emit({ type: 'add', items });\n },\n removePending: (page, id) => {\n this.dispatch(removePending(page, id));\n this.pending$.emit(this.state.pending);\n this.events$.emit({ type: 'remove', page, id });\n },\n clearPending: () => {\n this.dispatch(clearPending());\n this.pending$.emit(this.state.pending);\n this.events$.emit({ type: 'clear' });\n },\n commitAllPending: () => this.commitAllPending(),\n commitPending: (page, id) => this.commitPendingOne(page, id),\n\n endRedaction: () => this.endRedaction(),\n startRedaction: () => this.startRedaction(),\n\n selectPending: (page, id) => this.selectPending(page, id),\n deselectPending: () => this.deselectPending(),\n\n onSelectedChange: this.selected$.on,\n onRedactionEvent: this.events$.on,\n onStateChange: this.state$.on,\n onPendingChange: this.pending$.on,\n };\n }\n\n public onRedactionSelectionChange(\n callback: (formattedSelection: FormattedSelection[]) => void,\n ): Unsubscribe {\n return this.redactionSelection$.on(callback);\n }\n\n private selectPending(page: number, id: string) {\n this.dispatch(selectPending(page, id));\n this.selectionCapability?.clear();\n this.selected$.emit(this.state.selected);\n }\n private deselectPending() {\n this.dispatch(deselectPending());\n this.selected$.emit(this.state.selected);\n }\n\n private enableRedactSelection() {\n this.interactionManagerCapability?.activate(RedactionMode.RedactSelection);\n }\n private toggleRedactSelection() {\n if (this.interactionManagerCapability?.getActiveMode() === RedactionMode.RedactSelection)\n this.interactionManagerCapability?.activateDefaultMode();\n else this.interactionManagerCapability?.activate(RedactionMode.RedactSelection);\n }\n\n private enableMarqueeRedact() {\n this.interactionManagerCapability?.activate(RedactionMode.MarqueeRedact);\n }\n private toggleMarqueeRedact() {\n if (this.interactionManagerCapability?.getActiveMode() === RedactionMode.MarqueeRedact)\n this.interactionManagerCapability?.activateDefaultMode();\n else this.interactionManagerCapability?.activate(RedactionMode.MarqueeRedact);\n }\n\n private startRedaction() {\n this.interactionManagerCapability?.activate(RedactionMode.RedactSelection);\n }\n private endRedaction() {\n this.interactionManagerCapability?.activateDefaultMode();\n }\n\n public registerMarqueeOnPage(opts: RegisterMarqueeOnPageOptions) {\n if (!this.interactionManagerCapability) {\n this.logger.warn(\n 'RedactionPlugin',\n 'MissingDependency',\n 'Interaction manager plugin not loaded, marquee redaction disabled',\n );\n return () => {};\n }\n\n const document = this.coreState.core.document;\n if (!document) {\n this.logger.warn('RedactionPlugin', 'DocumentNotFound', 'Document not found');\n return () => {};\n }\n\n const page = document.pages[opts.pageIndex];\n if (!page) {\n this.logger.warn('RedactionPlugin', 'PageNotFound', `Page ${opts.pageIndex} not found`);\n return () => {};\n }\n\n const handlers = createMarqueeHandler({\n pageSize: page.size,\n scale: opts.scale,\n onPreview: opts.callback.onPreview,\n onCommit: (r) => {\n const item: RedactionItem = {\n id: uuidV4(),\n kind: 'area',\n page: opts.pageIndex,\n rect: r,\n };\n this.dispatch(addPending([item]));\n this.pending$.emit(this.state.pending);\n opts.callback.onCommit?.(r);\n this.enableRedactSelection();\n this.selectPending(opts.pageIndex, item.id);\n },\n });\n\n const off = this.interactionManagerCapability.registerAlways({\n handlers: {\n onPointerDown: (_, evt) => {\n if (evt.target === evt.currentTarget) {\n this.deselectPending();\n }\n },\n },\n scope: {\n type: 'page',\n pageIndex: opts.pageIndex,\n },\n });\n\n const off2 = this.interactionManagerCapability.registerHandlers({\n modeId: RedactionMode.MarqueeRedact,\n handlers,\n pageIndex: opts.pageIndex,\n });\n\n return () => {\n off();\n off2();\n };\n }\n\n private queueCurrentSelectionAsPending(): Task<boolean, PdfErrorReason> {\n if (!this.selectionCapability)\n return PdfTaskHelper.reject({\n code: PdfErrorCode.NotFound,\n message: '[RedactionPlugin] selection plugin required',\n });\n\n const doc = this.coreState.core.document;\n if (!doc)\n return PdfTaskHelper.reject({ code: PdfErrorCode.NotFound, message: 'Document not found' });\n\n const formatted = this.selectionCapability.getFormattedSelection();\n if (!formatted.length) return PdfTaskHelper.resolve(true);\n\n const id = uuidV4();\n\n const items: RedactionItem[] = formatted.map((s) => ({\n id,\n kind: 'text',\n page: s.pageIndex,\n rect: s.rect,\n rects: s.segmentRects,\n }));\n\n this.enableRedactSelection();\n this.dispatch(addPending(items));\n this.pending$.emit(this.state.pending);\n // optional: auto-select the last one added\n const last = items[items.length - 1];\n this.selectPending(last.page, last.id);\n\n // clear live UI selection\n this.redactionSelection$.emit([]);\n this.selectionCapability?.clear();\n\n return PdfTaskHelper.resolve(true);\n }\n\n private commitPendingOne(page: number, id: string): Task<boolean, PdfErrorReason> {\n const doc = this.coreState.core.document;\n if (!doc)\n return PdfTaskHelper.reject({ code: PdfErrorCode.NotFound, message: 'Document not found' });\n\n const item = (this.state.pending[page] ?? []).find((it) => it.id === id);\n if (!item) return PdfTaskHelper.resolve(true);\n\n const rects: Rect[] = item.kind === 'text' ? item.rects : [item.rect];\n const pdfPage = doc.pages[page];\n if (!pdfPage)\n return PdfTaskHelper.reject({ code: PdfErrorCode.NotFound, message: 'Page not found' });\n\n const task = new Task<boolean, PdfErrorReason>();\n this.engine\n .redactTextInRects(doc, pdfPage, rects, {\n drawBlackBoxes: this.config.drawBlackBoxes,\n })\n .wait(\n () => {\n this.dispatch(removePending(page, id));\n this.pending$.emit(this.state.pending);\n this.dispatchCoreAction(refreshPages([page]));\n this.events$.emit({ type: 'commit', success: true });\n task.resolve(true);\n },\n (error) => {\n this.events$.emit({ type: 'commit', success: false, error: error.reason });\n task.reject({ code: PdfErrorCode.Unknown, message: 'Failed to commit redactions' });\n },\n );\n\n return task;\n }\n\n private commitAllPending(): Task<boolean, PdfErrorReason> {\n const doc = this.coreState.core.document;\n if (!doc)\n return PdfTaskHelper.reject({ code: PdfErrorCode.NotFound, message: 'Document not found' });\n\n // group rects per page\n const perPage = new Map<number, Rect[]>();\n for (const [page, items] of Object.entries(this.state.pending)) {\n const p = Number(page);\n const list = perPage.get(p) ?? [];\n for (const it of items) {\n if (it.kind === 'text') list.push(...it.rects);\n else list.push(it.rect);\n }\n perPage.set(p, list);\n }\n\n const pagesToRefresh = Array.from(perPage.entries())\n .filter(([_, rects]) => rects.length > 0)\n .map(([pageIndex]) => pageIndex);\n\n const tasks: PdfTask<boolean>[] = [];\n for (const [pageIndex, rects] of perPage) {\n const page = doc.pages[pageIndex];\n if (!page) continue;\n if (!rects.length) continue;\n tasks.push(\n this.engine.redactTextInRects(doc, page, rects, {\n drawBlackBoxes: this.config.drawBlackBoxes,\n }),\n );\n }\n\n const task = new Task<boolean, PdfErrorReason>();\n Task.all(tasks).wait(\n () => {\n this.dispatch(clearPending());\n this.dispatchCoreAction(refreshPages(pagesToRefresh));\n this.pending$.emit(this.state.pending);\n this.events$.emit({ type: 'commit', success: true });\n task.resolve(true);\n },\n (error) => {\n this.events$.emit({ type: 'commit', success: false, error: error.reason });\n task.reject({ code: PdfErrorCode.Unknown, message: 'Failed to commit redactions' });\n },\n );\n\n return task;\n }\n\n override onStoreUpdated(_: RedactionState, newState: RedactionState): void {\n // keep external listeners in sync\n this.pending$.emit(newState.pending);\n this.selected$.emit(newState.selected);\n this.state$.emit(newState);\n }\n\n async destroy(): Promise<void> {\n this.redactionSelection$.clear();\n this.pending$.clear();\n this.state$.clear();\n this.events$.clear();\n\n this.unsubscribeSelectionChange?.();\n this.unsubscribeEndSelection?.();\n this.unsubscribeModeChange?.();\n\n await super.destroy();\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { RedactionPluginConfig } from './types';\n\nexport const REDACTION_PLUGIN_ID = 'redaction';\n\nexport const manifest: PluginManifest<RedactionPluginConfig> = {\n id: REDACTION_PLUGIN_ID,\n name: 'Redaction Plugin',\n version: '1.0.0',\n provides: ['redaction'],\n requires: [],\n optional: ['interaction-manager', 'selection'],\n defaultConfig: {\n enabled: true,\n drawBlackBoxes: true,\n },\n};\n","import { RedactionItem, RedactionState } from './types';\nimport {\n RedactionAction,\n ADD_PENDING,\n CLEAR_PENDING,\n END_REDACTION,\n REMOVE_PENDING,\n START_REDACTION,\n SET_ACTIVE_TYPE,\n SELECT_PENDING,\n DESELECT_PENDING,\n} from './actions';\n\n// Helper function to calculate total pending count\nconst calculatePendingCount = (pending: Record<number, RedactionItem[]>): number => {\n return Object.values(pending).reduce((total, items) => total + items.length, 0);\n};\n\nexport const initialState: RedactionState = {\n isRedacting: false,\n activeType: null,\n pending: {},\n pendingCount: 0,\n selected: null,\n};\n\nexport const redactionReducer = (state = initialState, action: RedactionAction): RedactionState => {\n switch (action.type) {\n case ADD_PENDING: {\n const next = { ...state.pending };\n for (const item of action.payload) {\n next[item.page] = (next[item.page] ?? []).concat(item);\n }\n return { ...state, pending: next, pendingCount: calculatePendingCount(next) };\n }\n\n case REMOVE_PENDING: {\n const { page, id } = action.payload;\n const list = state.pending[page] ?? [];\n const filtered = list.filter((it) => it.id !== id);\n const next = { ...state.pending, [page]: filtered };\n\n // if the removed one was selected → clear selection\n const stillSelected =\n state.selected && !(state.selected.page === page && state.selected.id === id);\n\n return {\n ...state,\n pending: next,\n pendingCount: calculatePendingCount(next),\n selected: stillSelected ? state.selected : null,\n };\n }\n\n case CLEAR_PENDING:\n return { ...state, pending: {}, pendingCount: 0, selected: null };\n\n case SELECT_PENDING:\n return { ...state, selected: { page: action.payload.page, id: action.payload.id } };\n\n case DESELECT_PENDING:\n return { ...state, selected: null };\n\n case START_REDACTION:\n return { ...state, isRedacting: true, activeType: action.payload };\n case END_REDACTION:\n return {\n ...state,\n pending: {},\n pendingCount: 0,\n selected: null,\n isRedacting: false,\n activeType: null,\n };\n case SET_ACTIVE_TYPE:\n return { ...state, activeType: action.payload };\n default:\n return state;\n }\n};\n","import { RedactionState } from './types';\n\nexport const getPendingRedactionsCount = (s: RedactionState) =>\n Object.values(s.pending).reduce((sum, list) => sum + (list?.length ?? 0), 0);\n\nexport const hasPendingRedactions = (s: RedactionState) =>\n Object.values(s.pending).some((list) => (list?.length ?? 0) > 0);\n","import { PluginPackage } from '@embedpdf/core';\nimport { RedactionPluginConfig, RedactionState } from './types';\nimport { RedactionPlugin } from './redaction-plugin';\nimport { manifest, REDACTION_PLUGIN_ID } from './manifest';\nimport { RedactionAction } from './actions';\nimport { initialState, redactionReducer } from './reducer';\n\nexport const RedactionPluginPackage: PluginPackage<\n RedactionPlugin,\n RedactionPluginConfig,\n RedactionState,\n RedactionAction\n> = {\n manifest,\n create: (registry, config) => new RedactionPlugin(REDACTION_PLUGIN_ID, registry, config),\n reducer: redactionReducer,\n initialState: initialState,\n};\n\nexport * from './redaction-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './selectors';\nexport { initialState } from './reducer';\n"],"names":["RedactionMode"],"mappings":";;AAIY,IAAA,kCAAAA,mBAAL;AACLA,iBAAA,eAAgB,IAAA;AAChBA,iBAAA,iBAAkB,IAAA;AAFRA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;ACDL,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AAExB,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,gBAAgB;AAEtB,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AA4CnB,MAAA,aAAa,CAAC,WAA8C;AAAA,EACvE,MAAM;AAAA,EACN,SAAS;AACX;AACa,MAAA,gBAAgB,CAAC,MAAc,QAAqC;AAAA,EAC/E,MAAM;AAAA,EACN,SAAS,EAAE,MAAM,GAAG;AACtB;AACO,MAAM,eAAe,OAA2B,EAAE,MAAM;AAElD,MAAA,iBAAiB,CAAC,UAA+C;AAAA,EAC5E,MAAM;AAAA,EACN,SAAS;AACX;AACO,MAAM,eAAe,OAA2B,EAAE,MAAM;AAMlD,MAAA,gBAAgB,CAAC,MAAc,QAAqC;AAAA,EAC/E,MAAM;AAAA,EACN,SAAS,EAAE,MAAM,GAAG;AACtB;AACO,MAAM,kBAAkB,OAA8B,EAAE,MAAM;ACzE9D,SAAS,qBAAqB,MAMuB;AAC1D,QAAM,EAAE,UAAU,OAAO,YAAY,GAAG,WAAW,aAAa;AAEhE,MAAI,QAAyB;AAC7B,MAAI,OAAoB;AAEjB,SAAA;AAAA,IACL,eAAe,CAAC,KAAK,QA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AK,SAAS,QAAO,6BAAM,WAAU,IAAI,CAAC;AAEtE,MAAM,uBAAuB,CAAC,MACnC,OAAO,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,WAAU,6BAAM,WAAU,KAAK,CAAC;ACC1D,MAAM,yBAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,UAAU,WAAW,IAAI,gBAAgB,qBAAqB,UAAU,MAAM;AAAA,EACvF,SAAS;AAAA,EACT;AACF;"}
1
+ {"version":3,"file":"index.js","sources":["../src/lib/types.ts","../src/lib/actions.ts","../src/lib/handlers/marquee-redact.handler.ts","../src/lib/reducer.ts","../src/lib/redaction-plugin.ts","../src/lib/manifest.ts","../src/lib/selectors.ts","../src/lib/index.ts"],"sourcesContent":["import { BasePluginConfig, EventHook } from '@embedpdf/core';\nimport { PdfErrorReason, Rect, Task } from '@embedpdf/models';\n\n// Redaction mode enum\nexport enum RedactionMode {\n MarqueeRedact = 'marqueeRedact',\n RedactSelection = 'redactSelection',\n}\n\nexport interface SelectedRedaction {\n page: number;\n id: string;\n}\n\n// Per-document redaction state\nexport interface RedactionDocumentState {\n isRedacting: boolean;\n activeType: RedactionMode | null;\n pending: Record<number, RedactionItem[]>;\n pendingCount: number;\n selected: SelectedRedaction | null;\n}\n\n// Plugin state\nexport interface RedactionState {\n documents: Record<string, RedactionDocumentState>;\n activeDocumentId: string | null;\n}\n\nexport type RedactionItem =\n | {\n id: string;\n kind: 'text';\n page: number;\n rect: Rect;\n rects: Rect[];\n }\n | {\n id: string;\n kind: 'area';\n page: number;\n rect: Rect;\n };\n\nexport interface MarqueeRedactCallback {\n onPreview?: (rect: Rect | null) => void;\n onCommit?: (rect: Rect) => void;\n}\n\nexport interface RegisterMarqueeOnPageOptions {\n documentId: string;\n pageIndex: number;\n scale: number;\n callback: MarqueeRedactCallback;\n}\n\nexport interface RedactionPluginConfig extends BasePluginConfig {\n drawBlackBoxes: boolean;\n}\n\n// Events include documentId\nexport type RedactionEvent =\n | {\n type: 'add';\n documentId: string;\n items: RedactionItem[];\n }\n | {\n type: 'remove';\n documentId: string;\n page: number;\n id: string;\n }\n | {\n type: 'clear';\n documentId: string;\n }\n | {\n type: 'commit';\n documentId: string;\n success: boolean;\n error?: PdfErrorReason;\n };\n\nexport interface PendingChangeEvent {\n documentId: string;\n pending: Record<number, RedactionItem[]>;\n}\n\nexport interface SelectedChangeEvent {\n documentId: string;\n selected: SelectedRedaction | null;\n}\n\nexport interface StateChangeEvent {\n documentId: string;\n state: RedactionDocumentState;\n}\n\n// Scoped redaction capability\nexport interface RedactionScope {\n queueCurrentSelectionAsPending(): Task<boolean, PdfErrorReason>;\n\n enableMarqueeRedact(): void;\n toggleMarqueeRedact(): void;\n isMarqueeRedactActive(): boolean;\n\n enableRedactSelection(): void;\n toggleRedactSelection(): void;\n isRedactSelectionActive(): boolean;\n\n addPending(items: RedactionItem[]): void;\n removePending(page: number, id: string): void;\n clearPending(): void;\n commitAllPending(): Task<boolean, PdfErrorReason>;\n commitPending(page: number, id: string): Task<boolean, PdfErrorReason>;\n\n endRedaction(): void;\n startRedaction(): void;\n\n selectPending(page: number, id: string): void;\n getSelectedPending(): SelectedRedaction | null;\n deselectPending(): void;\n\n getState(): RedactionDocumentState;\n\n onPendingChange: EventHook<Record<number, RedactionItem[]>>;\n onSelectedChange: EventHook<SelectedRedaction | null>;\n onRedactionEvent: EventHook<RedactionEvent>;\n onStateChange: EventHook<RedactionDocumentState>;\n}\n\nexport interface RedactionCapability {\n // Active document operations\n queueCurrentSelectionAsPending(): Task<boolean, PdfErrorReason>;\n\n enableMarqueeRedact(): void;\n toggleMarqueeRedact(): void;\n isMarqueeRedactActive(): boolean;\n\n enableRedactSelection(): void;\n toggleRedactSelection(): void;\n isRedactSelectionActive(): boolean;\n\n addPending(items: RedactionItem[]): void;\n removePending(page: number, id: string): void;\n clearPending(): void;\n commitAllPending(): Task<boolean, PdfErrorReason>;\n commitPending(page: number, id: string): Task<boolean, PdfErrorReason>;\n\n endRedaction(): void;\n startRedaction(): void;\n\n selectPending(page: number, id: string): void;\n getSelectedPending(): SelectedRedaction | null;\n deselectPending(): void;\n\n getState(): RedactionDocumentState;\n\n // Document-scoped operations\n forDocument(documentId: string): RedactionScope;\n\n // Events (include documentId)\n onPendingChange: EventHook<PendingChangeEvent>;\n onSelectedChange: EventHook<SelectedChangeEvent>;\n onRedactionEvent: EventHook<RedactionEvent>;\n onStateChange: EventHook<StateChangeEvent>;\n}\n","import { Action } from '@embedpdf/core';\nimport { RedactionItem, RedactionMode, RedactionDocumentState } from './types';\n\n// Document lifecycle\nexport const INIT_REDACTION_STATE = 'REDACTION/INIT_STATE';\nexport const CLEANUP_REDACTION_STATE = 'REDACTION/CLEANUP_STATE';\nexport const SET_ACTIVE_DOCUMENT = 'REDACTION/SET_ACTIVE_DOCUMENT';\n\n// Per-document redaction operations\nexport const START_REDACTION = 'START_REDACTION';\nexport const END_REDACTION = 'END_REDACTION';\nexport const SET_ACTIVE_TYPE = 'SET_ACTIVE_TYPE';\n\nexport const ADD_PENDING = 'ADD_PENDING';\nexport const REMOVE_PENDING = 'REMOVE_PENDING';\nexport const CLEAR_PENDING = 'CLEAR_PENDING';\n\nexport const SELECT_PENDING = 'SELECT_PENDING';\nexport const DESELECT_PENDING = 'DESELECT_PENDING';\n\n// Document lifecycle actions\nexport interface InitRedactionStateAction extends Action {\n type: typeof INIT_REDACTION_STATE;\n payload: {\n documentId: string;\n state: RedactionDocumentState;\n };\n}\n\nexport interface CleanupRedactionStateAction extends Action {\n type: typeof CLEANUP_REDACTION_STATE;\n payload: string; // documentId\n}\n\nexport interface SetActiveDocumentAction extends Action {\n type: typeof SET_ACTIVE_DOCUMENT;\n payload: string | null; // documentId\n}\n\n// Per-document operation actions\nexport interface StartRedactionAction extends Action {\n type: typeof START_REDACTION;\n payload: {\n documentId: string;\n mode: RedactionMode;\n };\n}\n\nexport interface EndRedactionAction extends Action {\n type: typeof END_REDACTION;\n payload: string; // documentId\n}\n\nexport interface SetActiveTypeAction extends Action {\n type: typeof SET_ACTIVE_TYPE;\n payload: {\n documentId: string;\n mode: RedactionMode | null;\n };\n}\n\nexport interface AddPendingAction extends Action {\n type: typeof ADD_PENDING;\n payload: {\n documentId: string;\n items: RedactionItem[];\n };\n}\n\nexport interface RemovePendingAction extends Action {\n type: typeof REMOVE_PENDING;\n payload: {\n documentId: string;\n page: number;\n id: string;\n };\n}\n\nexport interface ClearPendingAction extends Action {\n type: typeof CLEAR_PENDING;\n payload: string; // documentId\n}\n\nexport interface SelectPendingAction extends Action {\n type: typeof SELECT_PENDING;\n payload: {\n documentId: string;\n page: number;\n id: string;\n };\n}\n\nexport interface DeselectPendingAction extends Action {\n type: typeof DESELECT_PENDING;\n payload: string; // documentId\n}\n\nexport type RedactionAction =\n | InitRedactionStateAction\n | CleanupRedactionStateAction\n | SetActiveDocumentAction\n | StartRedactionAction\n | EndRedactionAction\n | SetActiveTypeAction\n | AddPendingAction\n | RemovePendingAction\n | ClearPendingAction\n | SelectPendingAction\n | DeselectPendingAction;\n\n// Action Creators\n\nexport function initRedactionState(\n documentId: string,\n state: RedactionDocumentState,\n): InitRedactionStateAction {\n return { type: INIT_REDACTION_STATE, payload: { documentId, state } };\n}\n\nexport function cleanupRedactionState(documentId: string): CleanupRedactionStateAction {\n return { type: CLEANUP_REDACTION_STATE, payload: documentId };\n}\n\nexport function setActiveDocument(documentId: string | null): SetActiveDocumentAction {\n return { type: SET_ACTIVE_DOCUMENT, payload: documentId };\n}\n\nexport const addPending = (documentId: string, items: RedactionItem[]): AddPendingAction => ({\n type: ADD_PENDING,\n payload: { documentId, items },\n});\n\nexport const removePending = (\n documentId: string,\n page: number,\n id: string,\n): RemovePendingAction => ({\n type: REMOVE_PENDING,\n payload: { documentId, page, id },\n});\n\nexport const clearPending = (documentId: string): ClearPendingAction => ({\n type: CLEAR_PENDING,\n payload: documentId,\n});\n\nexport const startRedaction = (documentId: string, mode: RedactionMode): StartRedactionAction => ({\n type: START_REDACTION,\n payload: { documentId, mode },\n});\n\nexport const endRedaction = (documentId: string): EndRedactionAction => ({\n type: END_REDACTION,\n payload: documentId,\n});\n\nexport const setActiveType = (\n documentId: string,\n mode: RedactionMode | null,\n): SetActiveTypeAction => ({\n type: SET_ACTIVE_TYPE,\n payload: { documentId, mode },\n});\n\nexport const selectPending = (\n documentId: string,\n page: number,\n id: string,\n): SelectPendingAction => ({\n type: SELECT_PENDING,\n payload: { documentId, page, id },\n});\n\nexport const deselectPending = (documentId: string): DeselectPendingAction => ({\n type: DESELECT_PENDING,\n payload: documentId,\n});\n","import { Position, Rect, Size } from '@embedpdf/models';\nimport { clamp } from '@embedpdf/core';\nimport {\n EmbedPdfPointerEvent,\n PointerEventHandlersWithLifecycle,\n} from '@embedpdf/plugin-interaction-manager';\n\nexport function createMarqueeHandler(opts: {\n pageSize: Size;\n scale: number;\n minDragPx?: number;\n onPreview?: (rect: Rect | null) => void;\n onCommit?: (rect: Rect) => void;\n}): PointerEventHandlersWithLifecycle<EmbedPdfPointerEvent> {\n const { pageSize, scale, minDragPx = 5, onPreview, onCommit } = opts;\n\n let start: Position | null = null;\n let last: Rect | null = null;\n\n return {\n onPointerDown: (pos, evt) => {\n start = pos;\n last = { origin: { x: pos.x, y: pos.y }, size: { width: 0, height: 0 } };\n onPreview?.(last);\n evt.setPointerCapture?.();\n },\n onPointerMove: (pos) => {\n if (!start) return;\n const x = clamp(pos.x, 0, pageSize.width);\n const y = clamp(pos.y, 0, pageSize.height);\n last = {\n origin: { x: Math.min(start.x, x), y: Math.min(start.y, y) },\n size: { width: Math.abs(x - start.x), height: Math.abs(y - start.y) },\n };\n onPreview?.(last);\n },\n onPointerUp: (_pos, evt) => {\n if (last) {\n const dragPx = Math.max(last.size.width, last.size.height) * scale;\n if (dragPx > minDragPx) onCommit?.(last);\n }\n start = null;\n last = null;\n onPreview?.(null);\n evt.releasePointerCapture?.();\n },\n onPointerCancel: (_pos, evt) => {\n start = null;\n last = null;\n onPreview?.(null);\n evt.releasePointerCapture?.();\n },\n };\n}\n","import { Reducer } from '@embedpdf/core';\nimport { RedactionItem, RedactionState, RedactionDocumentState } from './types';\nimport {\n RedactionAction,\n INIT_REDACTION_STATE,\n CLEANUP_REDACTION_STATE,\n SET_ACTIVE_DOCUMENT,\n ADD_PENDING,\n CLEAR_PENDING,\n END_REDACTION,\n REMOVE_PENDING,\n START_REDACTION,\n SET_ACTIVE_TYPE,\n SELECT_PENDING,\n DESELECT_PENDING,\n} from './actions';\n\n// Helper function to calculate total pending count\nconst calculatePendingCount = (pending: Record<number, RedactionItem[]>): number => {\n return Object.values(pending).reduce((total, items) => total + items.length, 0);\n};\n\nexport const initialDocumentState: RedactionDocumentState = {\n isRedacting: false,\n activeType: null,\n pending: {},\n pendingCount: 0,\n selected: null,\n};\n\nexport const initialState: RedactionState = {\n documents: {},\n activeDocumentId: null,\n};\n\nexport const redactionReducer: Reducer<RedactionState, RedactionAction> = (\n state = initialState,\n action,\n) => {\n switch (action.type) {\n case INIT_REDACTION_STATE: {\n const { documentId, state: docState } = action.payload;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: docState,\n },\n // Set as active if no active document\n activeDocumentId: state.activeDocumentId ?? documentId,\n };\n }\n\n case CLEANUP_REDACTION_STATE: {\n const documentId = action.payload;\n const { [documentId]: removed, ...remainingDocs } = state.documents;\n return {\n ...state,\n documents: remainingDocs,\n activeDocumentId: state.activeDocumentId === documentId ? null : state.activeDocumentId,\n };\n }\n\n case SET_ACTIVE_DOCUMENT: {\n return {\n ...state,\n activeDocumentId: action.payload,\n };\n }\n\n case ADD_PENDING: {\n const { documentId, items } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n\n const next = { ...docState.pending };\n for (const item of items) {\n next[item.page] = (next[item.page] ?? []).concat(item);\n }\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n pending: next,\n pendingCount: calculatePendingCount(next),\n },\n },\n };\n }\n\n case REMOVE_PENDING: {\n const { documentId, page, id } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n\n const list = docState.pending[page] ?? [];\n const filtered = list.filter((it) => it.id !== id);\n const next = { ...docState.pending, [page]: filtered };\n\n // if the removed one was selected → clear selection\n const stillSelected =\n docState.selected && !(docState.selected.page === page && docState.selected.id === id);\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n pending: next,\n pendingCount: calculatePendingCount(next),\n selected: stillSelected ? docState.selected : null,\n },\n },\n };\n }\n\n case CLEAR_PENDING: {\n const documentId = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n pending: {},\n pendingCount: 0,\n selected: null,\n },\n },\n };\n }\n\n case SELECT_PENDING: {\n const { documentId, page, id } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n selected: { page, id },\n },\n },\n };\n }\n\n case DESELECT_PENDING: {\n const documentId = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n selected: null,\n },\n },\n };\n }\n\n case START_REDACTION: {\n const { documentId, mode } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n isRedacting: true,\n activeType: mode,\n },\n },\n };\n }\n\n case END_REDACTION: {\n const documentId = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n pending: {},\n pendingCount: 0,\n selected: null,\n isRedacting: false,\n activeType: null,\n },\n },\n };\n }\n\n case SET_ACTIVE_TYPE: {\n const { documentId, mode } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n activeType: mode,\n },\n },\n };\n }\n\n default:\n return state;\n }\n};\n","import {\n RedactionPluginConfig,\n RedactionCapability,\n RedactionState,\n RegisterMarqueeOnPageOptions,\n RedactionItem,\n SelectedRedaction,\n RedactionMode,\n RedactionEvent,\n RedactionScope,\n StateChangeEvent,\n PendingChangeEvent,\n SelectedChangeEvent,\n RedactionDocumentState,\n} from './types';\nimport {\n BasePlugin,\n createBehaviorEmitter,\n PluginRegistry,\n refreshPages,\n Listener,\n} from '@embedpdf/core';\nimport {\n PdfErrorCode,\n PdfErrorReason,\n PdfTask,\n PdfTaskHelper,\n Rect,\n Task,\n uuidV4,\n} from '@embedpdf/models';\nimport {\n FormattedSelection,\n SelectionCapability,\n SelectionPlugin,\n} from '@embedpdf/plugin-selection';\nimport {\n InteractionManagerCapability,\n InteractionManagerPlugin,\n} from '@embedpdf/plugin-interaction-manager';\nimport {\n addPending,\n clearPending,\n deselectPending,\n endRedaction,\n removePending,\n selectPending,\n startRedaction,\n initRedactionState,\n cleanupRedactionState,\n RedactionAction,\n} from './actions';\nimport { createMarqueeHandler } from './handlers';\nimport { initialDocumentState } from './reducer';\n\nexport class RedactionPlugin extends BasePlugin<\n RedactionPluginConfig,\n RedactionCapability,\n RedactionState,\n RedactionAction\n> {\n static readonly id = 'redaction' as const;\n\n private config: RedactionPluginConfig;\n private selectionCapability: SelectionCapability | undefined;\n private interactionManagerCapability: InteractionManagerCapability | undefined;\n\n // Per-document emitters\n private readonly redactionSelection$ = new Map<\n string,\n ReturnType<typeof createBehaviorEmitter<FormattedSelection[]>>\n >();\n\n // Global emitters with documentId\n private readonly pending$ = createBehaviorEmitter<PendingChangeEvent>();\n private readonly selected$ = createBehaviorEmitter<SelectedChangeEvent>();\n private readonly state$ = createBehaviorEmitter<StateChangeEvent>();\n private readonly events$ = createBehaviorEmitter<RedactionEvent>();\n\n // Per-document unsubscribe functions\n private readonly documentUnsubscribers = new Map<string, Array<() => void>>();\n\n constructor(id: string, registry: PluginRegistry, config: RedactionPluginConfig) {\n super(id, registry);\n this.config = config;\n\n this.selectionCapability = this.registry.getPlugin<SelectionPlugin>('selection')?.provides();\n this.interactionManagerCapability = this.registry\n .getPlugin<InteractionManagerPlugin>('interaction-manager')\n ?.provides();\n\n if (this.interactionManagerCapability) {\n this.interactionManagerCapability.registerMode({\n id: RedactionMode.MarqueeRedact,\n scope: 'page',\n exclusive: true,\n cursor: 'crosshair',\n });\n this.interactionManagerCapability.registerMode({\n id: RedactionMode.RedactSelection,\n scope: 'page',\n exclusive: false,\n });\n }\n\n // Listen to mode changes per document\n this.interactionManagerCapability?.onModeChange((modeState) => {\n const documentId = modeState.documentId;\n\n if (modeState.activeMode === RedactionMode.RedactSelection) {\n this.dispatch(startRedaction(documentId, RedactionMode.RedactSelection));\n } else if (modeState.activeMode === RedactionMode.MarqueeRedact) {\n this.dispatch(startRedaction(documentId, RedactionMode.MarqueeRedact));\n } else {\n const docState = this.getDocumentState(documentId);\n if (docState?.isRedacting) {\n this.dispatch(endRedaction(documentId));\n }\n }\n });\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Lifecycle Hooks (from BasePlugin)\n // ─────────────────────────────────────────────────────────\n\n protected override onDocumentLoadingStarted(documentId: string): void {\n // Initialize state for this document\n this.dispatch(\n initRedactionState(documentId, {\n ...initialDocumentState,\n }),\n );\n\n // Create per-document emitter\n this.redactionSelection$.set(documentId, createBehaviorEmitter<FormattedSelection[]>());\n // Setup selection listeners for this document\n const unsubscribers: Array<() => void> = [];\n\n if (this.selectionCapability) {\n const selectionScope = this.selectionCapability.forDocument(documentId);\n\n // Listen to selection changes\n const unsubSelection = selectionScope.onSelectionChange(() => {\n const docState = this.getDocumentState(documentId);\n if (!docState?.isRedacting) return;\n\n const formattedSelection = selectionScope.getFormattedSelection();\n const emitter = this.redactionSelection$.get(documentId);\n emitter?.emit(formattedSelection);\n });\n\n // Listen to end selection\n const unsubEndSelection = selectionScope.onEndSelection(() => {\n const docState = this.getDocumentState(documentId);\n if (!docState?.isRedacting) return;\n\n const formattedSelection = selectionScope.getFormattedSelection();\n\n const items: RedactionItem[] = formattedSelection.map((s) => ({\n id: uuidV4(),\n kind: 'text',\n page: s.pageIndex,\n rect: s.rect,\n rects: s.segmentRects,\n }));\n\n this.dispatch(addPending(documentId, items));\n const emitter = this.redactionSelection$.get(documentId);\n emitter?.emit([]);\n selectionScope.clear();\n\n this.emitPendingChange(documentId);\n\n if (items.length) {\n this.selectPending(items[items.length - 1].page, items[items.length - 1].id, documentId);\n }\n });\n\n unsubscribers.push(unsubSelection, unsubEndSelection);\n }\n\n this.documentUnsubscribers.set(documentId, unsubscribers);\n\n this.logger.debug(\n 'RedactionPlugin',\n 'DocumentOpened',\n `Initialized redaction state for document: ${documentId}`,\n );\n }\n\n protected override onDocumentLoaded(documentId: string): void {\n this.selectionCapability?.enableForMode(RedactionMode.RedactSelection, documentId);\n }\n\n protected override onDocumentClosed(documentId: string): void {\n // Cleanup state\n this.dispatch(cleanupRedactionState(documentId));\n\n // Cleanup emitters\n const emitter = this.redactionSelection$.get(documentId);\n emitter?.clear();\n this.redactionSelection$.delete(documentId);\n\n // Cleanup unsubscribers\n const unsubscribers = this.documentUnsubscribers.get(documentId);\n if (unsubscribers) {\n unsubscribers.forEach((unsub) => unsub());\n this.documentUnsubscribers.delete(documentId);\n }\n\n this.logger.debug(\n 'RedactionPlugin',\n 'DocumentClosed',\n `Cleaned up redaction state for document: ${documentId}`,\n );\n }\n\n // ─────────────────────────────────────────────────────────\n // Capability\n // ─────────────────────────────────────────────────────────\n\n async initialize(_config: RedactionPluginConfig): Promise<void> {\n this.logger.info('RedactionPlugin', 'Initialize', 'Redaction plugin initialized');\n }\n\n protected buildCapability(): RedactionCapability {\n return {\n // Active document operations\n queueCurrentSelectionAsPending: () => this.queueCurrentSelectionAsPending(),\n\n enableMarqueeRedact: () => this.enableMarqueeRedact(),\n toggleMarqueeRedact: () => this.toggleMarqueeRedact(),\n isMarqueeRedactActive: () => this.isMarqueeRedactActive(),\n\n enableRedactSelection: () => this.enableRedactSelection(),\n toggleRedactSelection: () => this.toggleRedactSelection(),\n isRedactSelectionActive: () => this.isRedactSelectionActive(),\n\n addPending: (items) => this.addPendingItems(items),\n removePending: (page, id) => this.removePendingItem(page, id),\n clearPending: () => this.clearPendingItems(),\n commitAllPending: () => this.commitAllPending(),\n commitPending: (page, id) => this.commitPendingOne(page, id),\n\n endRedaction: () => this.endRedactionMode(),\n startRedaction: () => this.startRedactionMode(),\n\n selectPending: (page, id) => this.selectPending(page, id),\n getSelectedPending: () => this.getSelectedPending(),\n deselectPending: () => this.deselectPending(),\n\n getState: () => this.getDocumentStateOrThrow(),\n\n // Document-scoped operations\n forDocument: (documentId: string) => this.createRedactionScope(documentId),\n\n // Events\n onPendingChange: this.pending$.on,\n onSelectedChange: this.selected$.on,\n onRedactionEvent: this.events$.on,\n onStateChange: this.state$.on,\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Scoping\n // ─────────────────────────────────────────────────────────\n\n private createRedactionScope(documentId: string): RedactionScope {\n return {\n queueCurrentSelectionAsPending: () => this.queueCurrentSelectionAsPending(documentId),\n\n enableMarqueeRedact: () => this.enableMarqueeRedact(documentId),\n toggleMarqueeRedact: () => this.toggleMarqueeRedact(documentId),\n isMarqueeRedactActive: () => this.isMarqueeRedactActive(documentId),\n\n enableRedactSelection: () => this.enableRedactSelection(documentId),\n toggleRedactSelection: () => this.toggleRedactSelection(documentId),\n isRedactSelectionActive: () => this.isRedactSelectionActive(documentId),\n\n addPending: (items) => this.addPendingItems(items, documentId),\n removePending: (page, id) => this.removePendingItem(page, id, documentId),\n clearPending: () => this.clearPendingItems(documentId),\n commitAllPending: () => this.commitAllPending(documentId),\n commitPending: (page, id) => this.commitPendingOne(page, id, documentId),\n\n endRedaction: () => this.endRedactionMode(documentId),\n startRedaction: () => this.startRedactionMode(documentId),\n\n selectPending: (page, id) => this.selectPending(page, id, documentId),\n getSelectedPending: () => this.getSelectedPending(documentId),\n deselectPending: () => this.deselectPending(documentId),\n\n getState: () => this.getDocumentStateOrThrow(documentId),\n\n onPendingChange: (listener: Listener<Record<number, RedactionItem[]>>) =>\n this.pending$.on((event) => {\n if (event.documentId === documentId) listener(event.pending);\n }),\n onSelectedChange: (listener: Listener<SelectedRedaction | null>) =>\n this.selected$.on((event) => {\n if (event.documentId === documentId) listener(event.selected);\n }),\n onRedactionEvent: (listener: Listener<RedactionEvent>) =>\n this.events$.on((event) => {\n if (event.documentId === documentId) listener(event);\n }),\n onStateChange: (listener: Listener<RedactionDocumentState>) =>\n this.state$.on((event) => {\n if (event.documentId === documentId) listener(event.state);\n }),\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // State Helpers\n // ─────────────────────────────────────────────────────────\n\n private getDocumentState(documentId?: string): RedactionDocumentState | null {\n const id = documentId ?? this.getActiveDocumentId();\n return this.state.documents[id] ?? null;\n }\n\n private getDocumentStateOrThrow(documentId?: string): RedactionDocumentState {\n const state = this.getDocumentState(documentId);\n if (!state) {\n throw new Error(`Redaction state not found for document: ${documentId ?? 'active'}`);\n }\n return state;\n }\n\n // ─────────────────────────────────────────────────────────\n // Core Operations\n // ─────────────────────────────────────────────────────────\n\n private addPendingItems(items: RedactionItem[], documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n this.dispatch(addPending(id, items));\n this.emitPendingChange(id);\n this.events$.emit({ type: 'add', documentId: id, items });\n }\n\n private removePendingItem(page: number, itemId: string, documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n this.dispatch(removePending(id, page, itemId));\n this.emitPendingChange(id);\n this.events$.emit({ type: 'remove', documentId: id, page, id: itemId });\n }\n\n private clearPendingItems(documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n this.dispatch(clearPending(id));\n this.emitPendingChange(id);\n this.events$.emit({ type: 'clear', documentId: id });\n }\n\n private selectPending(page: number, itemId: string, documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n this.dispatch(selectPending(id, page, itemId));\n this.selectionCapability?.forDocument(id).clear();\n this.emitSelectedChange(id);\n }\n\n private getSelectedPending(documentId?: string): SelectedRedaction | null {\n const id = documentId ?? this.getActiveDocumentId();\n return this.getDocumentState(id)?.selected ?? null;\n }\n\n private deselectPending(documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n this.dispatch(deselectPending(id));\n this.emitSelectedChange(id);\n }\n\n private enableRedactSelection(documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n this.interactionManagerCapability?.forDocument(id).activate(RedactionMode.RedactSelection);\n }\n\n private toggleRedactSelection(documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n const scope = this.interactionManagerCapability?.forDocument(id);\n if (scope?.getActiveMode() === RedactionMode.RedactSelection) {\n scope.activateDefaultMode();\n } else {\n scope?.activate(RedactionMode.RedactSelection);\n }\n }\n\n private isRedactSelectionActive(documentId?: string): boolean {\n const id = documentId ?? this.getActiveDocumentId();\n return (\n this.interactionManagerCapability?.forDocument(id).getActiveMode() ===\n RedactionMode.RedactSelection\n );\n }\n\n private enableMarqueeRedact(documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n this.interactionManagerCapability?.forDocument(id).activate(RedactionMode.MarqueeRedact);\n }\n\n private toggleMarqueeRedact(documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n const scope = this.interactionManagerCapability?.forDocument(id);\n if (scope?.getActiveMode() === RedactionMode.MarqueeRedact) {\n scope.activateDefaultMode();\n } else {\n scope?.activate(RedactionMode.MarqueeRedact);\n }\n }\n\n private isMarqueeRedactActive(documentId?: string): boolean {\n const id = documentId ?? this.getActiveDocumentId();\n return (\n this.interactionManagerCapability?.forDocument(id).getActiveMode() ===\n RedactionMode.MarqueeRedact\n );\n }\n\n private startRedactionMode(documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n this.interactionManagerCapability?.forDocument(id).activate(RedactionMode.RedactSelection);\n }\n\n private endRedactionMode(documentId?: string) {\n const id = documentId ?? this.getActiveDocumentId();\n this.interactionManagerCapability?.forDocument(id).activateDefaultMode();\n }\n\n // ─────────────────────────────────────────────────────────\n // Public Methods\n // ─────────────────────────────────────────────────────────\n\n public onRedactionSelectionChange(\n documentId: string,\n callback: (formattedSelection: FormattedSelection[]) => void,\n ) {\n const emitter = this.redactionSelection$.get(documentId);\n return emitter?.on(callback) ?? (() => {});\n }\n\n public registerMarqueeOnPage(opts: RegisterMarqueeOnPageOptions) {\n if (!this.interactionManagerCapability) {\n this.logger.warn(\n 'RedactionPlugin',\n 'MissingDependency',\n 'Interaction manager plugin not loaded, marquee redaction disabled',\n );\n return () => {};\n }\n\n const coreDoc = this.coreState.core.documents[opts.documentId];\n if (!coreDoc?.document) {\n this.logger.warn('RedactionPlugin', 'DocumentNotFound', 'Document not found');\n return () => {};\n }\n\n const page = coreDoc.document.pages[opts.pageIndex];\n if (!page) {\n this.logger.warn('RedactionPlugin', 'PageNotFound', `Page ${opts.pageIndex} not found`);\n return () => {};\n }\n\n const handlers = createMarqueeHandler({\n pageSize: page.size,\n scale: opts.scale,\n onPreview: opts.callback.onPreview,\n onCommit: (r) => {\n const item: RedactionItem = {\n id: uuidV4(),\n kind: 'area',\n page: opts.pageIndex,\n rect: r,\n };\n this.dispatch(addPending(opts.documentId, [item]));\n this.emitPendingChange(opts.documentId);\n opts.callback.onCommit?.(r);\n this.enableRedactSelection(opts.documentId);\n this.selectPending(opts.pageIndex, item.id, opts.documentId);\n },\n });\n\n const off = this.interactionManagerCapability.registerAlways({\n handlers: {\n onPointerDown: (_, evt) => {\n if (evt.target === evt.currentTarget) {\n this.deselectPending(opts.documentId);\n }\n },\n },\n scope: {\n type: 'page',\n documentId: opts.documentId,\n pageIndex: opts.pageIndex,\n },\n });\n\n const off2 = this.interactionManagerCapability.registerHandlers({\n documentId: opts.documentId,\n modeId: RedactionMode.MarqueeRedact,\n handlers,\n pageIndex: opts.pageIndex,\n });\n\n return () => {\n off();\n off2();\n };\n }\n\n private queueCurrentSelectionAsPending(documentId?: string): Task<boolean, PdfErrorReason> {\n const id = documentId ?? this.getActiveDocumentId();\n\n if (!this.selectionCapability)\n return PdfTaskHelper.reject({\n code: PdfErrorCode.NotFound,\n message: '[RedactionPlugin] selection plugin required',\n });\n\n const coreDoc = this.coreState.core.documents[id];\n if (!coreDoc?.document)\n return PdfTaskHelper.reject({ code: PdfErrorCode.NotFound, message: 'Document not found' });\n\n const selectionScope = this.selectionCapability.forDocument(id);\n const formatted = selectionScope.getFormattedSelection();\n if (!formatted.length) return PdfTaskHelper.resolve(true);\n\n const uniqueId = uuidV4();\n\n const items: RedactionItem[] = formatted.map((s) => ({\n id: uniqueId,\n kind: 'text',\n page: s.pageIndex,\n rect: s.rect,\n rects: s.segmentRects,\n }));\n\n this.enableRedactSelection(id);\n this.dispatch(addPending(id, items));\n this.emitPendingChange(id);\n\n // Auto-select the last one added\n const last = items[items.length - 1];\n this.selectPending(last.page, last.id, id);\n\n // Clear live UI selection\n const emitter = this.redactionSelection$.get(id);\n emitter?.emit([]);\n selectionScope.clear();\n\n return PdfTaskHelper.resolve(true);\n }\n\n private commitPendingOne(\n page: number,\n id: string,\n documentId?: string,\n ): Task<boolean, PdfErrorReason> {\n const docId = documentId ?? this.getActiveDocumentId();\n const coreDoc = this.coreState.core.documents[docId];\n\n if (!coreDoc?.document)\n return PdfTaskHelper.reject({ code: PdfErrorCode.NotFound, message: 'Document not found' });\n\n const docState = this.getDocumentState(docId);\n if (!docState) {\n return PdfTaskHelper.reject({\n code: PdfErrorCode.NotFound,\n message: 'Document state not found',\n });\n }\n\n const item = (docState.pending[page] ?? []).find((it) => it.id === id);\n if (!item) return PdfTaskHelper.resolve(true);\n\n const rects: Rect[] = item.kind === 'text' ? item.rects : [item.rect];\n const pdfPage = coreDoc.document.pages[page];\n if (!pdfPage)\n return PdfTaskHelper.reject({ code: PdfErrorCode.NotFound, message: 'Page not found' });\n\n const task = new Task<boolean, PdfErrorReason>();\n this.engine\n .redactTextInRects(coreDoc.document, pdfPage, rects, {\n drawBlackBoxes: this.config.drawBlackBoxes,\n })\n .wait(\n () => {\n this.dispatch(removePending(docId, page, id));\n this.emitPendingChange(docId);\n this.dispatchCoreAction(refreshPages(docId, [page]));\n this.events$.emit({ type: 'commit', documentId: docId, success: true });\n task.resolve(true);\n },\n (error) => {\n this.events$.emit({\n type: 'commit',\n documentId: docId,\n success: false,\n error: error.reason,\n });\n task.reject({ code: PdfErrorCode.Unknown, message: 'Failed to commit redactions' });\n },\n );\n\n return task;\n }\n\n private commitAllPending(documentId?: string): Task<boolean, PdfErrorReason> {\n const docId = documentId ?? this.getActiveDocumentId();\n const coreDoc = this.coreState.core.documents[docId];\n\n if (!coreDoc?.document)\n return PdfTaskHelper.reject({ code: PdfErrorCode.NotFound, message: 'Document not found' });\n\n const docState = this.getDocumentState(docId);\n if (!docState) {\n return PdfTaskHelper.reject({\n code: PdfErrorCode.NotFound,\n message: 'Document state not found',\n });\n }\n\n // Group rects per page\n const perPage = new Map<number, Rect[]>();\n for (const [page, items] of Object.entries(docState.pending)) {\n const p = Number(page);\n const list = perPage.get(p) ?? [];\n for (const it of items) {\n if (it.kind === 'text') list.push(...it.rects);\n else list.push(it.rect);\n }\n perPage.set(p, list);\n }\n\n const pagesToRefresh = Array.from(perPage.entries())\n .filter(([_, rects]) => rects.length > 0)\n .map(([pageIndex]) => pageIndex);\n\n const tasks: PdfTask<boolean>[] = [];\n for (const [pageIndex, rects] of perPage) {\n const page = coreDoc.document.pages[pageIndex];\n if (!page) continue;\n if (!rects.length) continue;\n tasks.push(\n this.engine.redactTextInRects(coreDoc.document, page, rects, {\n drawBlackBoxes: this.config.drawBlackBoxes,\n }),\n );\n }\n\n const task = new Task<boolean, PdfErrorReason>();\n Task.all(tasks).wait(\n () => {\n this.dispatch(clearPending(docId));\n this.dispatchCoreAction(refreshPages(docId, pagesToRefresh));\n this.emitPendingChange(docId);\n this.events$.emit({ type: 'commit', documentId: docId, success: true });\n task.resolve(true);\n },\n (error) => {\n this.events$.emit({\n type: 'commit',\n documentId: docId,\n success: false,\n error: error.reason,\n });\n task.reject({ code: PdfErrorCode.Unknown, message: 'Failed to commit redactions' });\n },\n );\n\n return task;\n }\n\n // ─────────────────────────────────────────────────────────\n // Event Emission Helpers\n // ─────────────────────────────────────────────────────────\n\n private emitPendingChange(documentId: string) {\n const docState = this.getDocumentState(documentId);\n if (docState) {\n this.pending$.emit({ documentId, pending: docState.pending });\n }\n }\n\n private emitSelectedChange(documentId: string) {\n const docState = this.getDocumentState(documentId);\n if (docState) {\n this.selected$.emit({ documentId, selected: docState.selected });\n }\n }\n\n private emitStateChange(documentId: string) {\n const docState = this.getDocumentState(documentId);\n if (docState) {\n this.state$.emit({ documentId, state: docState });\n }\n }\n\n // ─────────────────────────────────────────────────────────\n // Store Update Handlers\n // ─────────────────────────────────────────────────────────\n\n override onStoreUpdated(_: RedactionState, newState: RedactionState): void {\n // Emit state changes for each changed document\n for (const documentId in newState.documents) {\n const docState = newState.documents[documentId];\n if (docState) {\n this.emitPendingChange(documentId);\n this.emitSelectedChange(documentId);\n this.emitStateChange(documentId);\n }\n }\n }\n\n // ─────────────────────────────────────────────────────────\n // Lifecycle\n // ─────────────────────────────────────────────────────────\n\n async destroy(): Promise<void> {\n this.pending$.clear();\n this.selected$.clear();\n this.state$.clear();\n this.events$.clear();\n\n // Cleanup all per-document emitters\n this.redactionSelection$.forEach((emitter) => emitter.clear());\n this.redactionSelection$.clear();\n\n // Cleanup all unsubscribers\n this.documentUnsubscribers.forEach((unsubscribers) => {\n unsubscribers.forEach((unsub) => unsub());\n });\n this.documentUnsubscribers.clear();\n\n await super.destroy();\n }\n}\n","import { PluginManifest } from '@embedpdf/core';\nimport { RedactionPluginConfig } from './types';\n\nexport const REDACTION_PLUGIN_ID = 'redaction';\n\nexport const manifest: PluginManifest<RedactionPluginConfig> = {\n id: REDACTION_PLUGIN_ID,\n name: 'Redaction Plugin',\n version: '1.0.0',\n provides: ['redaction'],\n requires: [],\n optional: ['interaction-manager', 'selection'],\n defaultConfig: {\n enabled: true,\n drawBlackBoxes: true,\n },\n};\n","import { RedactionState, RedactionDocumentState } from './types';\n\nexport const getPendingRedactionsCount = (s: RedactionDocumentState) => s.pendingCount;\n\nexport const hasPendingRedactions = (s: RedactionDocumentState) => s.pendingCount > 0;\n\nexport const getDocumentPendingCount = (state: RedactionState, documentId: string): number => {\n return state.documents[documentId]?.pendingCount ?? 0;\n};\n\nexport const getTotalPendingCount = (state: RedactionState): number => {\n return Object.values(state.documents).reduce((sum, doc) => sum + doc.pendingCount, 0);\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { RedactionPluginConfig, RedactionState } from './types';\nimport { RedactionPlugin } from './redaction-plugin';\nimport { manifest, REDACTION_PLUGIN_ID } from './manifest';\nimport { RedactionAction } from './actions';\nimport { initialState, redactionReducer } from './reducer';\n\nexport const RedactionPluginPackage: PluginPackage<\n RedactionPlugin,\n RedactionPluginConfig,\n RedactionState,\n RedactionAction\n> = {\n manifest,\n create: (registry, config) => new RedactionPlugin(REDACTION_PLUGIN_ID, registry, config),\n reducer: redactionReducer,\n initialState: initialState,\n};\n\nexport * from './redaction-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './selectors';\nexport { initialState, initialDocumentState } from './reducer';\n"],"names":["RedactionMode"],"mappings":";;AAIO,IAAK,kCAAAA,mBAAL;AACLA,iBAAA,eAAA,IAAgB;AAChBA,iBAAA,iBAAA,IAAkB;AAFR,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;ACAL,MAAM,uBAAuB;AAC7B,MAAM,0BAA0B;AAChC,MAAM,sBAAsB;AAG5B,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AAExB,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,gBAAgB;AAEtB,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AA8FzB,SAAS,mBACd,YACA,OAC0B;AAC1B,SAAO,EAAE,MAAM,sBAAsB,SAAS,EAAE,YAAY,QAAM;AACpE;AAEO,SAAS,sBAAsB,YAAiD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K,QAAQ,MAAA;AAGb,SAAK,oBAAoB,QAAQ,CAAC,YAAY,QAAQ,OAAO;AAC7D,SAAK,oBAAoB,MAAA;AAGzB,SAAK,sBAAsB,QAAQ,CAAC,kBAAkB;AACpD,oBAAc,QAAQ,CAAC,UAAU,MAAA,CAAO;AAAA,IAC1C,CAAC;AACD,SAAK,sBAAsB,MAAA;AAE3B,UAAM,MAAM,QAAA;AAAA,EACd;AACF;AArqBE,iBAAgB,KAAK;AANhB,IAAM,kBAAN;ACpDA,MAAM,sBAAsB;AAE5B,MAAM,WAAkD;AAAA,EAC7D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,WAAW;AAAA,EACtB,UAAU,CAAA;AAAA,EACV,UAAU,CAAC,uBAAuB,WAAW;AAAA,EAC7C,eAAe;AAAA,IACb,SAAS;AAAA,IACT,gBAAgB;AAAA,EAAA;AAEpB;ACdO,MAAM,4BAA4B,CAAC,MAA8B,EAAE;AAEnE,MAAM,uBAAuB,CAAC,MAA8B,EAAE,eAAe;AAE7E,MAAM,0BAA0B,CAAC,OAAuB,eAA+B;;AAC5F,WAAO,WAAM,UAAU,UAAU,MAA1B,mBAA6B,iBAAgB;AACtD;AAEO,MAAM,uBAAuB,CAAC,UAAkC;AACrE,SAAO,OAAO,OAAO,MAAM,SAAS,EAAE,OAAO,CAAC,KAAK,QAAQ,MAAM,IAAI,cAAc,CAAC;AACtF;ACLO,MAAM,yBAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,UAAU,WAAW,IAAI,gBAAgB,qBAAqB,UAAU,MAAM;AAAA,EACvF,SAAS;AAAA,EACT;AACF;"}
@@ -1,5 +1,8 @@
1
1
  import { Action } from '@embedpdf/core';
2
- import { RedactionItem, RedactionMode } from './types';
2
+ import { RedactionItem, RedactionMode, RedactionDocumentState } from './types';
3
+ export declare const INIT_REDACTION_STATE = "REDACTION/INIT_STATE";
4
+ export declare const CLEANUP_REDACTION_STATE = "REDACTION/CLEANUP_STATE";
5
+ export declare const SET_ACTIVE_DOCUMENT = "REDACTION/SET_ACTIVE_DOCUMENT";
3
6
  export declare const START_REDACTION = "START_REDACTION";
4
7
  export declare const END_REDACTION = "END_REDACTION";
5
8
  export declare const SET_ACTIVE_TYPE = "SET_ACTIVE_TYPE";
@@ -8,47 +11,79 @@ export declare const REMOVE_PENDING = "REMOVE_PENDING";
8
11
  export declare const CLEAR_PENDING = "CLEAR_PENDING";
9
12
  export declare const SELECT_PENDING = "SELECT_PENDING";
10
13
  export declare const DESELECT_PENDING = "DESELECT_PENDING";
14
+ export interface InitRedactionStateAction extends Action {
15
+ type: typeof INIT_REDACTION_STATE;
16
+ payload: {
17
+ documentId: string;
18
+ state: RedactionDocumentState;
19
+ };
20
+ }
21
+ export interface CleanupRedactionStateAction extends Action {
22
+ type: typeof CLEANUP_REDACTION_STATE;
23
+ payload: string;
24
+ }
25
+ export interface SetActiveDocumentAction extends Action {
26
+ type: typeof SET_ACTIVE_DOCUMENT;
27
+ payload: string | null;
28
+ }
11
29
  export interface StartRedactionAction extends Action {
12
30
  type: typeof START_REDACTION;
13
- payload: RedactionMode;
31
+ payload: {
32
+ documentId: string;
33
+ mode: RedactionMode;
34
+ };
14
35
  }
15
36
  export interface EndRedactionAction extends Action {
16
37
  type: typeof END_REDACTION;
38
+ payload: string;
17
39
  }
18
40
  export interface SetActiveTypeAction extends Action {
19
41
  type: typeof SET_ACTIVE_TYPE;
20
- payload: RedactionMode | null;
42
+ payload: {
43
+ documentId: string;
44
+ mode: RedactionMode | null;
45
+ };
21
46
  }
22
47
  export interface AddPendingAction extends Action {
23
48
  type: typeof ADD_PENDING;
24
- payload: RedactionItem[];
49
+ payload: {
50
+ documentId: string;
51
+ items: RedactionItem[];
52
+ };
25
53
  }
26
54
  export interface RemovePendingAction extends Action {
27
55
  type: typeof REMOVE_PENDING;
28
56
  payload: {
57
+ documentId: string;
29
58
  page: number;
30
59
  id: string;
31
60
  };
32
61
  }
33
62
  export interface ClearPendingAction extends Action {
34
63
  type: typeof CLEAR_PENDING;
64
+ payload: string;
35
65
  }
36
66
  export interface SelectPendingAction extends Action {
37
67
  type: typeof SELECT_PENDING;
38
68
  payload: {
69
+ documentId: string;
39
70
  page: number;
40
71
  id: string;
41
72
  };
42
73
  }
43
74
  export interface DeselectPendingAction extends Action {
44
75
  type: typeof DESELECT_PENDING;
76
+ payload: string;
45
77
  }
46
- export type RedactionAction = StartRedactionAction | EndRedactionAction | SetActiveTypeAction | AddPendingAction | RemovePendingAction | ClearPendingAction | SelectPendingAction | DeselectPendingAction;
47
- export declare const addPending: (items: RedactionItem[]) => AddPendingAction;
48
- export declare const removePending: (page: number, id: string) => RemovePendingAction;
49
- export declare const clearPending: () => ClearPendingAction;
50
- export declare const startRedaction: (mode: RedactionMode) => StartRedactionAction;
51
- export declare const endRedaction: () => EndRedactionAction;
52
- export declare const setActiveType: (mode: RedactionMode | null) => SetActiveTypeAction;
53
- export declare const selectPending: (page: number, id: string) => SelectPendingAction;
54
- export declare const deselectPending: () => DeselectPendingAction;
78
+ export type RedactionAction = InitRedactionStateAction | CleanupRedactionStateAction | SetActiveDocumentAction | StartRedactionAction | EndRedactionAction | SetActiveTypeAction | AddPendingAction | RemovePendingAction | ClearPendingAction | SelectPendingAction | DeselectPendingAction;
79
+ export declare function initRedactionState(documentId: string, state: RedactionDocumentState): InitRedactionStateAction;
80
+ export declare function cleanupRedactionState(documentId: string): CleanupRedactionStateAction;
81
+ export declare function setActiveDocument(documentId: string | null): SetActiveDocumentAction;
82
+ export declare const addPending: (documentId: string, items: RedactionItem[]) => AddPendingAction;
83
+ export declare const removePending: (documentId: string, page: number, id: string) => RemovePendingAction;
84
+ export declare const clearPending: (documentId: string) => ClearPendingAction;
85
+ export declare const startRedaction: (documentId: string, mode: RedactionMode) => StartRedactionAction;
86
+ export declare const endRedaction: (documentId: string) => EndRedactionAction;
87
+ export declare const setActiveType: (documentId: string, mode: RedactionMode | null) => SetActiveTypeAction;
88
+ export declare const selectPending: (documentId: string, page: number, id: string) => SelectPendingAction;
89
+ export declare const deselectPending: (documentId: string) => DeselectPendingAction;
@@ -7,4 +7,4 @@ export * from './redaction-plugin';
7
7
  export * from './types';
8
8
  export * from './manifest';
9
9
  export * from './selectors';
10
- export { initialState } from './reducer';
10
+ export { initialState, initialDocumentState } from './reducer';
@@ -1,7 +1,8 @@
1
1
  import { RedactionPluginConfig, RedactionCapability, RedactionState, RegisterMarqueeOnPageOptions } from './types';
2
- import { BasePlugin, PluginRegistry, Unsubscribe } from '@embedpdf/core';
2
+ import { BasePlugin, PluginRegistry } from '@embedpdf/core';
3
3
  import { FormattedSelection } from '@embedpdf/plugin-selection';
4
- export declare class RedactionPlugin extends BasePlugin<RedactionPluginConfig, RedactionCapability, RedactionState> {
4
+ import { RedactionAction } from './actions';
5
+ export declare class RedactionPlugin extends BasePlugin<RedactionPluginConfig, RedactionCapability, RedactionState, RedactionAction> {
5
6
  static readonly id: "redaction";
6
7
  private config;
7
8
  private selectionCapability;
@@ -11,25 +12,38 @@ export declare class RedactionPlugin extends BasePlugin<RedactionPluginConfig, R
11
12
  private readonly selected$;
12
13
  private readonly state$;
13
14
  private readonly events$;
14
- private readonly unsubscribeSelectionChange;
15
- private readonly unsubscribeEndSelection;
16
- private readonly unsubscribeModeChange;
15
+ private readonly documentUnsubscribers;
17
16
  constructor(id: string, registry: PluginRegistry, config: RedactionPluginConfig);
17
+ protected onDocumentLoadingStarted(documentId: string): void;
18
+ protected onDocumentLoaded(documentId: string): void;
19
+ protected onDocumentClosed(documentId: string): void;
18
20
  initialize(_config: RedactionPluginConfig): Promise<void>;
19
21
  protected buildCapability(): RedactionCapability;
20
- onRedactionSelectionChange(callback: (formattedSelection: FormattedSelection[]) => void): Unsubscribe;
22
+ private createRedactionScope;
23
+ private getDocumentState;
24
+ private getDocumentStateOrThrow;
25
+ private addPendingItems;
26
+ private removePendingItem;
27
+ private clearPendingItems;
21
28
  private selectPending;
29
+ private getSelectedPending;
22
30
  private deselectPending;
23
31
  private enableRedactSelection;
24
32
  private toggleRedactSelection;
33
+ private isRedactSelectionActive;
25
34
  private enableMarqueeRedact;
26
35
  private toggleMarqueeRedact;
27
- private startRedaction;
28
- private endRedaction;
36
+ private isMarqueeRedactActive;
37
+ private startRedactionMode;
38
+ private endRedactionMode;
39
+ onRedactionSelectionChange(documentId: string, callback: (formattedSelection: FormattedSelection[]) => void): import('@embedpdf/core').Unsubscribe;
29
40
  registerMarqueeOnPage(opts: RegisterMarqueeOnPageOptions): () => void;
30
41
  private queueCurrentSelectionAsPending;
31
42
  private commitPendingOne;
32
43
  private commitAllPending;
44
+ private emitPendingChange;
45
+ private emitSelectedChange;
46
+ private emitStateChange;
33
47
  onStoreUpdated(_: RedactionState, newState: RedactionState): void;
34
48
  destroy(): Promise<void>;
35
49
  }
@@ -1,4 +1,6 @@
1
- import { RedactionState } from './types';
1
+ import { Reducer } from '@embedpdf/core';
2
+ import { RedactionState, RedactionDocumentState } from './types';
2
3
  import { RedactionAction } from './actions';
4
+ export declare const initialDocumentState: RedactionDocumentState;
3
5
  export declare const initialState: RedactionState;
4
- export declare const redactionReducer: (state: RedactionState | undefined, action: RedactionAction) => RedactionState;
6
+ export declare const redactionReducer: Reducer<RedactionState, RedactionAction>;
@@ -1,3 +1,5 @@
1
- import { RedactionState } from './types';
2
- export declare const getPendingRedactionsCount: (s: RedactionState) => number;
3
- export declare const hasPendingRedactions: (s: RedactionState) => boolean;
1
+ import { RedactionState, RedactionDocumentState } from './types';
2
+ export declare const getPendingRedactionsCount: (s: RedactionDocumentState) => number;
3
+ export declare const hasPendingRedactions: (s: RedactionDocumentState) => boolean;
4
+ export declare const getDocumentPendingCount: (state: RedactionState, documentId: string) => number;
5
+ export declare const getTotalPendingCount: (state: RedactionState) => number;
@@ -6,15 +6,19 @@ export declare enum RedactionMode {
6
6
  }
7
7
  export interface SelectedRedaction {
8
8
  page: number;
9
- id: string | null;
9
+ id: string;
10
10
  }
11
- export interface RedactionState {
11
+ export interface RedactionDocumentState {
12
12
  isRedacting: boolean;
13
13
  activeType: RedactionMode | null;
14
14
  pending: Record<number, RedactionItem[]>;
15
15
  pendingCount: number;
16
16
  selected: SelectedRedaction | null;
17
17
  }
18
+ export interface RedactionState {
19
+ documents: Record<string, RedactionDocumentState>;
20
+ activeDocumentId: string | null;
21
+ }
18
22
  export type RedactionItem = {
19
23
  id: string;
20
24
  kind: 'text';
@@ -32,6 +36,7 @@ export interface MarqueeRedactCallback {
32
36
  onCommit?: (rect: Rect) => void;
33
37
  }
34
38
  export interface RegisterMarqueeOnPageOptions {
39
+ documentId: string;
35
40
  pageIndex: number;
36
41
  scale: number;
37
42
  callback: MarqueeRedactCallback;
@@ -41,37 +46,80 @@ export interface RedactionPluginConfig extends BasePluginConfig {
41
46
  }
42
47
  export type RedactionEvent = {
43
48
  type: 'add';
49
+ documentId: string;
44
50
  items: RedactionItem[];
45
51
  } | {
46
52
  type: 'remove';
53
+ documentId: string;
47
54
  page: number;
48
55
  id: string;
49
56
  } | {
50
57
  type: 'clear';
58
+ documentId: string;
51
59
  } | {
52
60
  type: 'commit';
61
+ documentId: string;
53
62
  success: boolean;
54
63
  error?: PdfErrorReason;
55
64
  };
56
- export interface RedactionCapability {
57
- queueCurrentSelectionAsPending: () => Task<boolean, PdfErrorReason>;
58
- enableMarqueeRedact: () => void;
59
- toggleMarqueeRedact: () => void;
60
- isMarqueeRedactActive: () => boolean;
61
- enableRedactSelection: () => void;
62
- toggleRedactSelection: () => void;
63
- isRedactSelectionActive: () => boolean;
65
+ export interface PendingChangeEvent {
66
+ documentId: string;
67
+ pending: Record<number, RedactionItem[]>;
68
+ }
69
+ export interface SelectedChangeEvent {
70
+ documentId: string;
71
+ selected: SelectedRedaction | null;
72
+ }
73
+ export interface StateChangeEvent {
74
+ documentId: string;
75
+ state: RedactionDocumentState;
76
+ }
77
+ export interface RedactionScope {
78
+ queueCurrentSelectionAsPending(): Task<boolean, PdfErrorReason>;
79
+ enableMarqueeRedact(): void;
80
+ toggleMarqueeRedact(): void;
81
+ isMarqueeRedactActive(): boolean;
82
+ enableRedactSelection(): void;
83
+ toggleRedactSelection(): void;
84
+ isRedactSelectionActive(): boolean;
85
+ addPending(items: RedactionItem[]): void;
86
+ removePending(page: number, id: string): void;
87
+ clearPending(): void;
88
+ commitAllPending(): Task<boolean, PdfErrorReason>;
89
+ commitPending(page: number, id: string): Task<boolean, PdfErrorReason>;
90
+ endRedaction(): void;
91
+ startRedaction(): void;
92
+ selectPending(page: number, id: string): void;
93
+ getSelectedPending(): SelectedRedaction | null;
94
+ deselectPending(): void;
95
+ getState(): RedactionDocumentState;
64
96
  onPendingChange: EventHook<Record<number, RedactionItem[]>>;
65
- addPending: (items: RedactionItem[]) => void;
66
- removePending: (page: number, id: string) => void;
67
- clearPending: () => void;
68
- commitAllPending: () => Task<boolean, PdfErrorReason>;
69
- commitPending: (page: number, id: string) => Task<boolean, PdfErrorReason>;
70
- endRedaction: () => void;
71
- startRedaction: () => void;
72
- selectPending: (page: number, id: string) => void;
73
- deselectPending: () => void;
74
97
  onSelectedChange: EventHook<SelectedRedaction | null>;
75
98
  onRedactionEvent: EventHook<RedactionEvent>;
76
- onStateChange: EventHook<RedactionState>;
99
+ onStateChange: EventHook<RedactionDocumentState>;
100
+ }
101
+ export interface RedactionCapability {
102
+ queueCurrentSelectionAsPending(): Task<boolean, PdfErrorReason>;
103
+ enableMarqueeRedact(): void;
104
+ toggleMarqueeRedact(): void;
105
+ isMarqueeRedactActive(): boolean;
106
+ enableRedactSelection(): void;
107
+ toggleRedactSelection(): void;
108
+ isRedactSelectionActive(): boolean;
109
+ addPending(items: RedactionItem[]): void;
110
+ removePending(page: number, id: string): void;
111
+ clearPending(): void;
112
+ commitAllPending(): Task<boolean, PdfErrorReason>;
113
+ commitPending(page: number, id: string): Task<boolean, PdfErrorReason>;
114
+ endRedaction(): void;
115
+ startRedaction(): void;
116
+ selectPending(page: number, id: string): void;
117
+ getSelectedPending(): SelectedRedaction | null;
118
+ deselectPending(): void;
119
+ getState(): RedactionDocumentState;
120
+ forDocument(documentId: string): RedactionScope;
121
+ onPendingChange: EventHook<PendingChangeEvent>;
122
+ onSelectedChange: EventHook<SelectedChangeEvent>;
123
+ onRedactionEvent: EventHook<RedactionEvent>;
124
+ onStateChange: EventHook<StateChangeEvent>;
77
125
  }
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/preact"),t=require("@embedpdf/plugin-redaction"),i=require("preact"),n=require("preact/hooks"),r=require("preact/jsx-runtime"),o=require("@embedpdf/utils/preact"),s=require("@embedpdf/models"),a=()=>e.usePlugin(t.RedactionPlugin.id),l=()=>e.useCapability(t.RedactionPlugin.id),d=({pageIndex:e,scale:t,className:i,stroke:o="red",fill:s="transparent"})=>{const{plugin:l}=a(),[d,c]=n.useState(null);return n.useEffect((()=>{if(l)return l.registerMarqueeOnPage({pageIndex:e,scale:t,callback:{onPreview:c}})}),[l,e]),d?r.jsx("div",{style:{position:"absolute",pointerEvents:"none",left:d.origin.x*t,top:d.origin.y*t,width:d.size.width*t,height:d.size.height*t,border:`1px solid ${o}`,background:s,boxSizing:"border-box"},className:i}):null};function c({color:e="#FFFF00",opacity:t=1,border:i="1px solid red",rects:n,rect:o,scale:s,onClick:a,style:l,...d}){return r.jsx(r.Fragment,{children:n.map(((n,c)=>r.jsx("div",{onPointerDown:a,onTouchStart:a,style:{position:"absolute",border:i,left:(o?n.origin.x-o.origin.x:n.origin.x)*s,top:(o?n.origin.y-o.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:e,opacity:t,pointerEvents:a?"auto":"none",cursor:a?"pointer":"default",zIndex:a?1:void 0,...l},...d},c)))})}function u({pageIndex:e,scale:t}){const{plugin:i}=a(),[o,s]=n.useState([]),[l,d]=n.useState(null);return n.useEffect((()=>{if(i)return i.onRedactionSelectionChange((t=>{const i=t.find((t=>t.pageIndex===e));s((null==i?void 0:i.segmentRects)??[]),d((null==i?void 0:i.rect)??null)}))}),[i,e]),l?r.jsx("div",{style:{mixBlendMode:"normal",pointerEvents:"none",position:"absolute",inset:0},children:r.jsx(c,{color:"transparent",opacity:1,rects:o,scale:t,border:"1px solid red"})}):null}function p({pageIndex:e,scale:t,bboxStroke:a="rgba(0,0,0,0.8)",rotation:d=s.Rotation.Degree0,selectionMenu:u}){const{provides:p}=l(),[g,x]=n.useState([]),[h,b]=n.useState(null);n.useEffect((()=>{if(!p)return;const t=p.onPendingChange((t=>x(t[e]??[]))),i=p.onSelectedChange((t=>{b(t&&t.page===e?t.id:null)}));return()=>{null==t||t(),null==i||i()}}),[p,e]);const f=n.useCallback(((t,i)=>{t.stopPropagation(),p&&p.selectPending(e,i)}),[p,e]);return g.length?r.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:g.map((n=>{if("area"===n.kind){const s=n.rect;return r.jsxs(i.Fragment,{children:[r.jsx("div",{style:{position:"absolute",left:s.origin.x*t,top:s.origin.y*t,width:s.size.width*t,height:s.size.height*t,background:"transparent",outline:h===n.id?`1px solid ${a}`:"none",outlineOffset:"2px",border:"1px solid red",pointerEvents:"auto",cursor:"pointer"},onPointerDown:e=>f(e,n.id),onTouchStart:e=>f(e,n.id)}),r.jsx(o.CounterRotate,{rect:{origin:{x:s.origin.x*t,y:s.origin.y*t},size:{width:s.size.width*t,height:s.size.height*t}},rotation:d,children:({rect:t,menuWrapperProps:i})=>u&&u({item:n,selected:h===n.id,pageIndex:e,menuWrapperProps:i,rect:t})})]},n.id)}const s=n.rect;return r.jsxs(i.Fragment,{children:[r.jsx("div",{style:{position:"absolute",left:s.origin.x*t,top:s.origin.y*t,width:s.size.width*t,height:s.size.height*t,background:"transparent",outline:h===n.id?`1px solid ${a}`:"none",outlineOffset:"2px",pointerEvents:"auto",cursor:h===n.id?"pointer":"default"},children:r.jsx(c,{rect:s,rects:n.rects,color:"transparent",border:"1px solid red",scale:t,onClick:e=>f(e,n.id)})}),r.jsx(o.CounterRotate,{rect:{origin:{x:s.origin.x*t,y:s.origin.y*t},size:{width:s.size.width*t,height:s.size.height*t}},rotation:d,children:({rect:t,menuWrapperProps:i})=>u&&u({item:n,selected:h===n.id,pageIndex:e,menuWrapperProps:i,rect:t})})]},n.id)}))}):null}exports.RedactionLayer=({pageIndex:e,scale:t,rotation:n=s.Rotation.Degree0,selectionMenu:o})=>r.jsxs(i.Fragment,{children:[r.jsx(p,{pageIndex:e,scale:t,rotation:n,selectionMenu:o}),r.jsx(d,{pageIndex:e,scale:t}),r.jsx(u,{pageIndex:e,scale:t})]}),exports.useRedaction=()=>{const{provides:e}=l(),[i,r]=n.useState(t.initialState);return n.useEffect((()=>null==e?void 0:e.onStateChange((e=>{r(e)}))),[e]),{state:i,provides:e}},exports.useRedactionCapability=l,exports.useRedactionPlugin=a,Object.keys(t).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})}));
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/preact"),t=require("@embedpdf/plugin-redaction"),n=require("preact"),i=require("preact/hooks"),o=require("preact/jsx-runtime"),r=require("@embedpdf/utils/preact"),s=require("@embedpdf/models"),d=()=>e.usePlugin(t.RedactionPlugin.id),l=()=>e.useCapability(t.RedactionPlugin.id),a=({documentId:t,pageIndex:n,scale:r,className:s,stroke:l="red",fill:a="transparent"})=>{const{plugin:c}=d(),u=e.useDocumentState(t),[p,g]=i.useState(null),x=i.useMemo(()=>void 0!==r?r:(null==u?void 0:u.scale)??1,[r,null==u?void 0:u.scale]);return i.useEffect(()=>{if(c&&t)return c.registerMarqueeOnPage({documentId:t,pageIndex:n,scale:x,callback:{onPreview:g}})},[c,t,n,x]),p?o.jsx("div",{style:{position:"absolute",pointerEvents:"none",left:p.origin.x*x,top:p.origin.y*x,width:p.size.width*x,height:p.size.height*x,border:`1px solid ${l}`,background:a,boxSizing:"border-box"},className:s}):null};function c({color:e="#FFFF00",opacity:t=1,border:n="1px solid red",rects:i,rect:r,scale:s,onClick:d,style:l,...a}){return o.jsx(o.Fragment,{children:i.map((i,c)=>o.jsx("div",{onPointerDown:d,onTouchStart:d,style:{position:"absolute",border:n,left:(r?i.origin.x-r.origin.x:i.origin.x)*s,top:(r?i.origin.y-r.origin.y:i.origin.y)*s,width:i.size.width*s,height:i.size.height*s,background:e,opacity:t,pointerEvents:d?"auto":"none",cursor:d?"pointer":"default",zIndex:d?1:void 0,...l},...a},c))})}function u({documentId:e,pageIndex:t,scale:n}){const{plugin:r}=d(),[s,l]=i.useState([]),[a,u]=i.useState(null);return i.useEffect(()=>{if(r)return r.onRedactionSelectionChange(e,e=>{const n=e.find(e=>e.pageIndex===t);l((null==n?void 0:n.segmentRects)??[]),u((null==n?void 0:n.rect)??null)})},[r,e,t]),a?o.jsx("div",{style:{mixBlendMode:"normal",pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(c,{color:"transparent",opacity:1,rects:s,scale:n,border:"1px solid red"})}):null}function p({documentId:e,pageIndex:t,scale:d,bboxStroke:a="rgba(0,0,0,0.8)",rotation:u=s.Rotation.Degree0,selectionMenu:p}){const{provides:g}=l(),[x,h]=i.useState([]),[m,f]=i.useState(null);i.useEffect(()=>{if(!g)return;const n=g.forDocument(e),i=n.getState();h(i.pending[t]??[]),f(i.selected&&i.selected.page===t?i.selected.id:null);const o=n.onPendingChange(e=>h(e[t]??[])),r=n.onSelectedChange(e=>{f(e&&e.page===t?e.id:null)});return()=>{null==o||o(),null==r||r()}},[g,e,t]);const b=i.useCallback((n,i)=>{n.stopPropagation(),g&&g.forDocument(e).selectPending(t,i)},[g,e,t]);return x.length?o.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:x.map(e=>{if("area"===e.kind){const i=e.rect;return o.jsxs(n.Fragment,{children:[o.jsx("div",{style:{position:"absolute",left:i.origin.x*d,top:i.origin.y*d,width:i.size.width*d,height:i.size.height*d,background:"transparent",outline:m===e.id?`1px solid ${a}`:"none",outlineOffset:"2px",border:"1px solid red",pointerEvents:"auto",cursor:"pointer"},onPointerDown:t=>b(t,e.id),onTouchStart:t=>b(t,e.id)}),p&&o.jsx(r.CounterRotate,{rect:{origin:{x:i.origin.x*d,y:i.origin.y*d},size:{width:i.size.width*d,height:i.size.height*d}},rotation:u,children:n=>p({...n,context:{type:"redaction",item:e,pageIndex:t},selected:m===e.id,placement:{suggestTop:!1}})})]},e.id)}const i=e.rect;return o.jsxs(n.Fragment,{children:[o.jsx("div",{style:{position:"absolute",left:i.origin.x*d,top:i.origin.y*d,width:i.size.width*d,height:i.size.height*d,background:"transparent",outline:m===e.id?`1px solid ${a}`:"none",outlineOffset:"2px",pointerEvents:"auto",cursor:m===e.id?"pointer":"default"},children:o.jsx(c,{rect:i,rects:e.rects,color:"transparent",border:"1px solid red",scale:d,onClick:t=>b(t,e.id)})}),p&&o.jsx(r.CounterRotate,{rect:{origin:{x:i.origin.x*d,y:i.origin.y*d},size:{width:i.size.width*d,height:i.size.height*d}},rotation:u,children:n=>p({...n,context:{type:"redaction",item:e,pageIndex:t},selected:m===e.id,placement:{suggestTop:!1}})})]},e.id)})}):null}exports.RedactionLayer=({documentId:t,pageIndex:r,scale:d,rotation:l,selectionMenu:c})=>{const g=e.useDocumentState(t),x=i.useMemo(()=>void 0!==d?d:(null==g?void 0:g.scale)??1,[d,null==g?void 0:g.scale]),h=i.useMemo(()=>void 0!==l?l:(null==g?void 0:g.rotation)??s.Rotation.Degree0,[l,null==g?void 0:g.rotation]);return o.jsxs(n.Fragment,{children:[o.jsx(p,{documentId:t,pageIndex:r,scale:x,rotation:h,selectionMenu:c}),o.jsx(a,{documentId:t,pageIndex:r,scale:x}),o.jsx(u,{documentId:t,pageIndex:r,scale:x})]})},exports.useRedaction=e=>{const{provides:n}=l(),[o,r]=i.useState(t.initialDocumentState),s=i.useMemo(()=>n?n.forDocument(e):null,[n,e]);return i.useEffect(()=>{if(!s)return void r(t.initialDocumentState);try{r(s.getState())}catch(e){r(t.initialDocumentState)}return s.onStateChange(e=>{r(e)})},[s]),{state:o,provides:s}},exports.useRedactionCapability=l,exports.useRedactionPlugin=d,Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
2
2
  //# sourceMappingURL=index.cjs.map