@embedpdf/plugin-redaction 2.15.0 → 3.0.0-next.1

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