@embedpdf/plugin-redaction 2.14.4 → 3.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
package/dist/vue/index.js DELETED
@@ -1,638 +0,0 @@
1
- import { createPluginPackage } from "@embedpdf/core";
2
- import { RedactionPlugin, initialDocumentState, RedactionPluginPackage as RedactionPluginPackage$1 } from "@embedpdf/plugin-redaction";
3
- export * from "@embedpdf/plugin-redaction";
4
- import { defineComponent, openBlock, createElementBlock, Fragment, renderList, mergeProps, unref, ref, watch, toValue, computed, normalizeClass, normalizeStyle, createCommentVNode, createVNode, useSlots, createElementVNode, createBlock, withCtx, resolveDynamicComponent, renderSlot, normalizeProps, guardReactiveProps, toDisplayString } from "vue";
5
- import { useCapability, usePlugin, useDocumentState } from "@embedpdf/core/vue";
6
- import { Rotation, PdfStandardFont, PdfTextAlignment, textAlignmentToCss, standardFontCssProperties, PdfAnnotationSubtype } from "@embedpdf/models";
7
- import { CounterRotate } from "@embedpdf/utils/vue";
8
- import { createRenderer, useRegisterRenderers } from "@embedpdf/plugin-annotation/vue";
9
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
10
- __name: "highlight",
11
- props: {
12
- color: { default: "#FFFF00" },
13
- opacity: { default: 1 },
14
- border: { default: "1px solid red" },
15
- rects: {},
16
- rect: {},
17
- scale: {},
18
- onClick: {}
19
- },
20
- setup(__props) {
21
- const props = __props;
22
- const boundingRect = props.rect;
23
- return (_ctx, _cache) => {
24
- return openBlock(true), createElementBlock(Fragment, null, renderList(__props.rects, (rect, i) => {
25
- return openBlock(), createElementBlock("div", mergeProps({
26
- key: i,
27
- onPointerdown: _cache[0] || (_cache[0] = //@ts-ignore
28
- (...args) => __props.onClick && __props.onClick(...args)),
29
- style: {
30
- position: "absolute",
31
- border: __props.border,
32
- left: `${(unref(boundingRect) ? rect.origin.x - unref(boundingRect).origin.x : rect.origin.x) * __props.scale}px`,
33
- top: `${(unref(boundingRect) ? rect.origin.y - unref(boundingRect).origin.y : rect.origin.y) * __props.scale}px`,
34
- width: `${rect.size.width * __props.scale}px`,
35
- height: `${rect.size.height * __props.scale}px`,
36
- background: __props.color,
37
- opacity: __props.opacity,
38
- pointerEvents: __props.onClick ? "auto" : "none",
39
- cursor: __props.onClick ? "pointer" : "default",
40
- zIndex: __props.onClick ? 1 : void 0
41
- }
42
- }, { ref_for: true }, _ctx.$attrs), null, 16);
43
- }), 128);
44
- };
45
- }
46
- });
47
- const useRedactionPlugin = () => usePlugin(RedactionPlugin.id);
48
- const useRedactionCapability = () => useCapability(RedactionPlugin.id);
49
- const useRedaction = (documentId) => {
50
- const { provides } = useRedactionCapability();
51
- const state = ref(initialDocumentState);
52
- watch(
53
- [provides, () => toValue(documentId)],
54
- ([providesValue, docId], _, onCleanup) => {
55
- if (!providesValue) {
56
- state.value = initialDocumentState;
57
- return;
58
- }
59
- const scope = providesValue.forDocument(docId);
60
- try {
61
- state.value = scope.getState();
62
- } catch (e) {
63
- state.value = initialDocumentState;
64
- }
65
- const unsubscribe = scope.onStateChange((newState) => {
66
- state.value = newState;
67
- });
68
- onCleanup(unsubscribe);
69
- },
70
- { immediate: true }
71
- );
72
- const scopedProvides = computed(() => {
73
- var _a;
74
- const docId = toValue(documentId);
75
- return ((_a = provides.value) == null ? void 0 : _a.forDocument(docId)) ?? null;
76
- });
77
- return {
78
- state,
79
- provides: scopedProvides
80
- };
81
- };
82
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
83
- __name: "marquee-redact",
84
- props: {
85
- documentId: {},
86
- pageIndex: {},
87
- scale: {},
88
- className: {},
89
- stroke: { default: "red" },
90
- fill: { default: "transparent" }
91
- },
92
- setup(__props) {
93
- const props = __props;
94
- const { plugin: redactionPlugin } = useRedactionPlugin();
95
- const documentState = useDocumentState(() => props.documentId);
96
- const rect = ref(null);
97
- const actualScale = computed(() => {
98
- var _a;
99
- if (props.scale !== void 0) return props.scale;
100
- return ((_a = documentState.value) == null ? void 0 : _a.scale) ?? 1;
101
- });
102
- const strokeColor = computed(
103
- () => {
104
- var _a;
105
- return props.stroke ?? ((_a = redactionPlugin.value) == null ? void 0 : _a.getPreviewStrokeColor()) ?? "red";
106
- }
107
- );
108
- watch(
109
- [redactionPlugin, () => props.documentId, () => props.pageIndex],
110
- ([plugin, docId, pageIdx], _, onCleanup) => {
111
- if (!plugin || !docId) return;
112
- const unsubscribe = plugin.onRedactionMarqueeChange(docId, (data) => {
113
- rect.value = data.pageIndex === pageIdx ? data.rect : null;
114
- });
115
- onCleanup(unsubscribe);
116
- },
117
- { immediate: true }
118
- );
119
- return (_ctx, _cache) => {
120
- return rect.value ? (openBlock(), createElementBlock("div", {
121
- key: 0,
122
- style: normalizeStyle({
123
- position: "absolute",
124
- pointerEvents: "none",
125
- left: `${rect.value.origin.x * actualScale.value}px`,
126
- top: `${rect.value.origin.y * actualScale.value}px`,
127
- width: `${rect.value.size.width * actualScale.value}px`,
128
- height: `${rect.value.size.height * actualScale.value}px`,
129
- border: `1px solid ${strokeColor.value}`,
130
- background: __props.fill,
131
- boxSizing: "border-box"
132
- }),
133
- class: normalizeClass(__props.className)
134
- }, null, 6)) : createCommentVNode("", true);
135
- };
136
- }
137
- });
138
- const _hoisted_1$1 = {
139
- key: 0,
140
- style: {
141
- mixBlendMode: "normal",
142
- pointerEvents: "none",
143
- position: "absolute",
144
- inset: 0
145
- }
146
- };
147
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
148
- __name: "selection-redact",
149
- props: {
150
- documentId: {},
151
- pageIndex: {},
152
- scale: {}
153
- },
154
- setup(__props) {
155
- const props = __props;
156
- const { plugin: redactionPlugin } = useRedactionPlugin();
157
- const rects = ref([]);
158
- const boundingRect = ref(null);
159
- const strokeColor = computed(() => {
160
- var _a;
161
- return ((_a = redactionPlugin.value) == null ? void 0 : _a.getPreviewStrokeColor()) ?? "red";
162
- });
163
- watch(
164
- [redactionPlugin, () => props.documentId, () => props.pageIndex],
165
- ([plugin, docId, pageIdx], _, onCleanup) => {
166
- if (!plugin) {
167
- rects.value = [];
168
- boundingRect.value = null;
169
- return;
170
- }
171
- const unsubscribe = plugin.onRedactionSelectionChange(docId, (formattedSelection) => {
172
- const selection = formattedSelection.find((s) => s.pageIndex === pageIdx);
173
- rects.value = (selection == null ? void 0 : selection.segmentRects) ?? [];
174
- boundingRect.value = (selection == null ? void 0 : selection.rect) ?? null;
175
- });
176
- onCleanup(unsubscribe);
177
- },
178
- { immediate: true }
179
- );
180
- return (_ctx, _cache) => {
181
- return boundingRect.value ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
182
- createVNode(_sfc_main$7, {
183
- color: "transparent",
184
- opacity: 1,
185
- rects: rects.value,
186
- scale: __props.scale,
187
- border: `1px solid ${strokeColor.value}`
188
- }, null, 8, ["rects", "scale", "border"])
189
- ])) : createCommentVNode("", true);
190
- };
191
- }
192
- });
193
- const _hoisted_1 = {
194
- key: 0,
195
- style: { position: "absolute", inset: 0, pointerEvents: "none" }
196
- };
197
- const _hoisted_2 = ["onPointerdown"];
198
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
199
- __name: "pending-redactions",
200
- props: {
201
- documentId: {},
202
- pageIndex: {},
203
- scale: {},
204
- rotation: { default: Rotation.Degree0 },
205
- bboxStroke: { default: "rgba(0,0,0,0.8)" },
206
- selectionMenu: {}
207
- },
208
- setup(__props) {
209
- const props = __props;
210
- const slots = useSlots();
211
- const { provides: redaction } = useRedactionCapability();
212
- const items = ref([]);
213
- const selectedId = ref(null);
214
- watch(
215
- [redaction, () => props.documentId, () => props.pageIndex],
216
- ([redactionValue, docId, pageIdx], _, onCleanup) => {
217
- if (!redactionValue) {
218
- items.value = [];
219
- selectedId.value = null;
220
- return;
221
- }
222
- const scoped = redactionValue.forDocument(docId);
223
- const currentState = scoped.getState();
224
- items.value = (currentState.pending[pageIdx] ?? []).filter((it) => it.source === "legacy");
225
- selectedId.value = currentState.selected && currentState.selected.page === pageIdx ? currentState.selected.id : null;
226
- const off1 = scoped.onPendingChange((map) => {
227
- items.value = (map[pageIdx] ?? []).filter((it) => it.source === "legacy");
228
- });
229
- const off2 = scoped.onSelectedChange((sel) => {
230
- selectedId.value = sel && sel.page === pageIdx ? sel.id : null;
231
- });
232
- onCleanup(() => {
233
- off1 == null ? void 0 : off1();
234
- off2 == null ? void 0 : off2();
235
- });
236
- },
237
- { immediate: true }
238
- );
239
- const select = (e, id) => {
240
- e.stopPropagation();
241
- const redactionValue = redaction.value;
242
- if (!redactionValue) return;
243
- redactionValue.forDocument(props.documentId).selectPending(props.pageIndex, id);
244
- };
245
- const shouldShowMenu = (itemId) => {
246
- const isSelected = selectedId.value === itemId;
247
- return isSelected && (!!props.selectionMenu || !!slots["selection-menu"]);
248
- };
249
- const buildContext = (item) => ({
250
- type: "redaction",
251
- item,
252
- pageIndex: props.pageIndex
253
- });
254
- const menuPlacement = {
255
- suggestTop: false,
256
- spaceAbove: 0,
257
- spaceBelow: 0
258
- };
259
- const renderSelectionMenu = (item, rect, menuWrapperProps) => {
260
- if (!props.selectionMenu) return null;
261
- return props.selectionMenu({
262
- rect,
263
- menuWrapperProps,
264
- selected: selectedId.value === item.id,
265
- placement: menuPlacement,
266
- context: buildContext(item)
267
- });
268
- };
269
- return (_ctx, _cache) => {
270
- return items.value.length ? (openBlock(), createElementBlock("div", _hoisted_1, [
271
- (openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item) => {
272
- return openBlock(), createElementBlock(Fragment, {
273
- key: item.id
274
- }, [
275
- item.kind === "area" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
276
- createElementVNode("div", {
277
- style: normalizeStyle({
278
- position: "absolute",
279
- left: `${item.rect.origin.x * __props.scale}px`,
280
- top: `${item.rect.origin.y * __props.scale}px`,
281
- width: `${item.rect.size.width * __props.scale}px`,
282
- height: `${item.rect.size.height * __props.scale}px`,
283
- background: "transparent",
284
- outline: selectedId.value === item.id ? `1px solid ${__props.bboxStroke}` : "none",
285
- outlineOffset: "2px",
286
- border: `1px solid red`,
287
- pointerEvents: "auto",
288
- cursor: "pointer"
289
- }),
290
- onPointerdown: (e) => select(e, item.id)
291
- }, null, 44, _hoisted_2),
292
- shouldShowMenu(item.id) ? (openBlock(), createBlock(unref(CounterRotate), {
293
- key: 0,
294
- rect: {
295
- origin: { x: item.rect.origin.x * __props.scale, y: item.rect.origin.y * __props.scale },
296
- size: { width: item.rect.size.width * __props.scale, height: item.rect.size.height * __props.scale }
297
- },
298
- rotation: __props.rotation
299
- }, {
300
- default: withCtx(({ rect, menuWrapperProps }) => [
301
- __props.selectionMenu ? (openBlock(), createBlock(resolveDynamicComponent(renderSelectionMenu(item, rect, menuWrapperProps)), { key: 0 })) : renderSlot(_ctx.$slots, "selection-menu", {
302
- key: 1,
303
- context: buildContext(item),
304
- selected: selectedId.value === item.id,
305
- rect,
306
- placement: menuPlacement,
307
- menuWrapperProps
308
- })
309
- ]),
310
- _: 2
311
- }, 1032, ["rect", "rotation"])) : createCommentVNode("", true)
312
- ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
313
- createElementVNode("div", {
314
- style: normalizeStyle({
315
- position: "absolute",
316
- left: `${item.rect.origin.x * __props.scale}px`,
317
- top: `${item.rect.origin.y * __props.scale}px`,
318
- width: `${item.rect.size.width * __props.scale}px`,
319
- height: `${item.rect.size.height * __props.scale}px`,
320
- background: "transparent",
321
- outline: selectedId.value === item.id ? `1px solid ${__props.bboxStroke}` : "none",
322
- outlineOffset: "2px",
323
- pointerEvents: "auto",
324
- cursor: selectedId.value === item.id ? "pointer" : "default"
325
- })
326
- }, [
327
- createVNode(_sfc_main$7, {
328
- rect: item.rect,
329
- rects: item.rects,
330
- color: "transparent",
331
- border: "1px solid red",
332
- scale: __props.scale,
333
- "on-click": (e) => select(e, item.id)
334
- }, null, 8, ["rect", "rects", "scale", "on-click"])
335
- ], 4),
336
- shouldShowMenu(item.id) ? (openBlock(), createBlock(unref(CounterRotate), {
337
- key: 0,
338
- rect: {
339
- origin: {
340
- x: item.rect.origin.x * __props.scale,
341
- y: item.rect.origin.y * __props.scale
342
- },
343
- size: {
344
- width: item.rect.size.width * __props.scale,
345
- height: item.rect.size.height * __props.scale
346
- }
347
- },
348
- rotation: __props.rotation
349
- }, {
350
- default: withCtx(({ rect, menuWrapperProps }) => [
351
- __props.selectionMenu ? (openBlock(), createBlock(resolveDynamicComponent(renderSelectionMenu(item, rect, menuWrapperProps)), { key: 0 })) : renderSlot(_ctx.$slots, "selection-menu", {
352
- key: 1,
353
- context: buildContext(item),
354
- selected: selectedId.value === item.id,
355
- rect,
356
- placement: menuPlacement,
357
- menuWrapperProps
358
- })
359
- ]),
360
- _: 2
361
- }, 1032, ["rect", "rotation"])) : createCommentVNode("", true)
362
- ], 64))
363
- ], 64);
364
- }), 128))
365
- ])) : createCommentVNode("", true);
366
- };
367
- }
368
- });
369
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
370
- __name: "redaction-layer",
371
- props: {
372
- documentId: {},
373
- pageIndex: {},
374
- scale: {},
375
- rotation: {},
376
- bboxStroke: { default: "rgba(0,0,0,0.8)" },
377
- selectionMenu: {}
378
- },
379
- setup(__props) {
380
- const props = __props;
381
- const documentState = useDocumentState(() => props.documentId);
382
- const page = computed(() => {
383
- var _a, _b, _c;
384
- return (_c = (_b = (_a = documentState.value) == null ? void 0 : _a.document) == null ? void 0 : _b.pages) == null ? void 0 : _c[props.pageIndex];
385
- });
386
- const actualScale = computed(() => {
387
- var _a;
388
- if (props.scale !== void 0) return props.scale;
389
- return ((_a = documentState.value) == null ? void 0 : _a.scale) ?? 1;
390
- });
391
- const actualRotation = computed(() => {
392
- var _a, _b;
393
- if (props.rotation !== void 0) return props.rotation;
394
- const pageRotation = ((_a = page.value) == null ? void 0 : _a.rotation) ?? 0;
395
- const docRotation = ((_b = documentState.value) == null ? void 0 : _b.rotation) ?? 0;
396
- return (pageRotation + docRotation) % 4;
397
- });
398
- return (_ctx, _cache) => {
399
- return openBlock(), createElementBlock(Fragment, null, [
400
- createVNode(_sfc_main$4, {
401
- "document-id": __props.documentId,
402
- "page-index": __props.pageIndex,
403
- scale: actualScale.value,
404
- rotation: actualRotation.value,
405
- "bbox-stroke": __props.bboxStroke,
406
- "selection-menu": __props.selectionMenu
407
- }, {
408
- "selection-menu": withCtx((slotProps) => [
409
- renderSlot(_ctx.$slots, "selection-menu", normalizeProps(guardReactiveProps(slotProps)))
410
- ]),
411
- _: 3
412
- }, 8, ["document-id", "page-index", "scale", "rotation", "bbox-stroke", "selection-menu"]),
413
- createVNode(_sfc_main$6, {
414
- "document-id": __props.documentId,
415
- "page-index": __props.pageIndex,
416
- scale: actualScale.value
417
- }, null, 8, ["document-id", "page-index", "scale"]),
418
- createVNode(_sfc_main$5, {
419
- "document-id": __props.documentId,
420
- "page-index": __props.pageIndex,
421
- scale: actualScale.value
422
- }, null, 8, ["document-id", "page-index", "scale"])
423
- ], 64);
424
- };
425
- }
426
- });
427
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
428
- __name: "redact-highlight",
429
- props: {
430
- annotation: {},
431
- currentObject: {},
432
- isSelected: { type: Boolean },
433
- isEditing: { type: Boolean },
434
- scale: {},
435
- pageIndex: {},
436
- documentId: {},
437
- onClick: { type: Function },
438
- appearanceActive: { type: Boolean }
439
- },
440
- setup(__props) {
441
- const props = __props;
442
- const isHovered = ref(false);
443
- const segmentRects = computed(() => props.annotation.object.segmentRects ?? []);
444
- const rect = computed(() => props.annotation.object.rect);
445
- const strokeColor = computed(() => props.annotation.object.strokeColor ?? "#FF0000");
446
- const color = computed(() => props.annotation.object.color ?? "#000000");
447
- const opacity = computed(() => props.annotation.object.opacity ?? 1);
448
- const textColor = computed(
449
- () => props.annotation.object.fontColor ?? props.annotation.object.overlayColor ?? "#FFFFFF"
450
- );
451
- const overlayText = computed(() => props.annotation.object.overlayText);
452
- const overlayTextRepeat = computed(() => props.annotation.object.overlayTextRepeat ?? false);
453
- const fontSize = computed(() => props.annotation.object.fontSize ?? 12);
454
- const fontFamily = computed(() => props.annotation.object.fontFamily ?? PdfStandardFont.Helvetica);
455
- const textAlign = computed(() => props.annotation.object.textAlign ?? PdfTextAlignment.Center);
456
- const renderedOverlayText = computed(() => {
457
- if (!overlayText.value) return "";
458
- if (!overlayTextRepeat.value) return overlayText.value;
459
- const reps = 10;
460
- return Array(reps).fill(overlayText.value).join(" ");
461
- });
462
- const getSegmentStyle = (b) => ({
463
- position: "absolute",
464
- left: `${(rect.value ? b.origin.x - rect.value.origin.x : b.origin.x) * props.scale}px`,
465
- top: `${(rect.value ? b.origin.y - rect.value.origin.y : b.origin.y) * props.scale}px`,
466
- width: `${b.size.width * props.scale}px`,
467
- height: `${b.size.height * props.scale}px`,
468
- // Default: transparent background with strokeColor (C) border
469
- // Hovered: color (IC) background fill, no border
470
- background: isHovered.value ? color.value : "transparent",
471
- border: !isHovered.value ? `2px solid ${strokeColor.value}` : "none",
472
- opacity: isHovered.value ? opacity.value : 1,
473
- boxSizing: "border-box",
474
- pointerEvents: "auto",
475
- cursor: "pointer",
476
- display: "flex",
477
- alignItems: "center",
478
- justifyContent: textAlign.value === PdfTextAlignment.Left ? "flex-start" : textAlign.value === PdfTextAlignment.Right ? "flex-end" : "center",
479
- overflow: "hidden"
480
- });
481
- const getTextStyle = (b) => ({
482
- color: textColor.value,
483
- fontSize: `${Math.min(fontSize.value * props.scale, b.size.height * props.scale * 0.8)}px`,
484
- ...standardFontCssProperties(fontFamily.value),
485
- textAlign: textAlignmentToCss(textAlign.value),
486
- whiteSpace: overlayTextRepeat.value ? "normal" : "nowrap",
487
- overflow: "hidden",
488
- textOverflow: "ellipsis",
489
- lineHeight: 1
490
- });
491
- return (_ctx, _cache) => {
492
- return openBlock(), createElementBlock("div", {
493
- onMouseenter: _cache[1] || (_cache[1] = ($event) => isHovered.value = true),
494
- onMouseleave: _cache[2] || (_cache[2] = ($event) => isHovered.value = false),
495
- style: { position: "absolute", inset: 0 }
496
- }, [
497
- (openBlock(true), createElementBlock(Fragment, null, renderList(segmentRects.value, (b, i) => {
498
- return openBlock(), createElementBlock("div", {
499
- key: i,
500
- onPointerdown: _cache[0] || (_cache[0] = //@ts-ignore
501
- (...args) => __props.onClick && __props.onClick(...args)),
502
- style: normalizeStyle(getSegmentStyle(b))
503
- }, [
504
- isHovered.value && overlayText.value ? (openBlock(), createElementBlock("span", {
505
- key: 0,
506
- style: normalizeStyle(getTextStyle(b))
507
- }, toDisplayString(renderedOverlayText.value), 5)) : createCommentVNode("", true)
508
- ], 36);
509
- }), 128))
510
- ], 32);
511
- };
512
- }
513
- });
514
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
515
- __name: "redact-area",
516
- props: {
517
- annotation: {},
518
- currentObject: {},
519
- isSelected: { type: Boolean },
520
- isEditing: { type: Boolean },
521
- scale: {},
522
- pageIndex: {},
523
- documentId: {},
524
- onClick: { type: Function },
525
- appearanceActive: { type: Boolean }
526
- },
527
- setup(__props) {
528
- const props = __props;
529
- const isHovered = ref(false);
530
- const strokeColor = computed(() => props.annotation.object.strokeColor ?? "#FF0000");
531
- const color = computed(() => props.annotation.object.color ?? "#000000");
532
- const opacity = computed(() => props.annotation.object.opacity ?? 1);
533
- const textColor = computed(
534
- () => props.annotation.object.fontColor ?? props.annotation.object.overlayColor ?? "#FFFFFF"
535
- );
536
- const overlayText = computed(() => props.annotation.object.overlayText);
537
- const overlayTextRepeat = computed(() => props.annotation.object.overlayTextRepeat ?? false);
538
- const fontSize = computed(() => props.annotation.object.fontSize ?? 12);
539
- const fontFamily = computed(() => props.annotation.object.fontFamily ?? PdfStandardFont.Helvetica);
540
- const textAlign = computed(() => props.annotation.object.textAlign ?? PdfTextAlignment.Center);
541
- const renderedOverlayText = computed(() => {
542
- if (!overlayText.value) return "";
543
- if (!overlayTextRepeat.value) return overlayText.value;
544
- const reps = 10;
545
- return Array(reps).fill(overlayText.value).join(" ");
546
- });
547
- const containerStyle = computed(() => ({
548
- position: "absolute",
549
- inset: 0,
550
- // Default: transparent background with strokeColor (C) border
551
- // Hovered: color (IC) background fill, no border
552
- background: isHovered.value ? color.value : "transparent",
553
- border: !isHovered.value ? `2px solid ${strokeColor.value}` : "none",
554
- opacity: isHovered.value ? opacity.value : 1,
555
- boxSizing: "border-box",
556
- pointerEvents: "auto",
557
- cursor: props.isSelected ? "move" : "pointer",
558
- display: "flex",
559
- alignItems: "center",
560
- justifyContent: textAlign.value === PdfTextAlignment.Left ? "flex-start" : textAlign.value === PdfTextAlignment.Right ? "flex-end" : "center",
561
- overflow: "hidden"
562
- }));
563
- const textStyle = computed(() => ({
564
- color: textColor.value,
565
- fontSize: `${fontSize.value * props.scale}px`,
566
- ...standardFontCssProperties(fontFamily.value),
567
- textAlign: textAlignmentToCss(textAlign.value),
568
- whiteSpace: overlayTextRepeat.value ? "normal" : "nowrap",
569
- overflow: "hidden",
570
- textOverflow: "ellipsis",
571
- padding: "4px"
572
- }));
573
- return (_ctx, _cache) => {
574
- return openBlock(), createElementBlock("div", {
575
- onPointerdown: _cache[0] || (_cache[0] = (e) => {
576
- var _a;
577
- if (!__props.isSelected) (_a = __props.onClick) == null ? void 0 : _a.call(__props, e);
578
- }),
579
- onMouseenter: _cache[1] || (_cache[1] = ($event) => isHovered.value = true),
580
- onMouseleave: _cache[2] || (_cache[2] = ($event) => isHovered.value = false),
581
- style: normalizeStyle(containerStyle.value)
582
- }, [
583
- isHovered.value && overlayText.value ? (openBlock(), createElementBlock("span", {
584
- key: 0,
585
- style: normalizeStyle(textStyle.value)
586
- }, toDisplayString(renderedOverlayText.value), 5)) : createCommentVNode("", true)
587
- ], 36);
588
- };
589
- }
590
- });
591
- const redactRenderers = [
592
- createRenderer({
593
- id: "redactHighlight",
594
- matches: (a) => {
595
- var _a;
596
- return a.type === PdfAnnotationSubtype.REDACT && "segmentRects" in a && (((_a = a.segmentRects) == null ? void 0 : _a.length) ?? 0) > 0;
597
- },
598
- component: _sfc_main$2,
599
- interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },
600
- useAppearanceStream: false
601
- }),
602
- createRenderer({
603
- id: "redactArea",
604
- matches: (a) => {
605
- var _a;
606
- return a.type === PdfAnnotationSubtype.REDACT && (!("segmentRects" in a) || !(((_a = a.segmentRects) == null ? void 0 : _a.length) ?? 0));
607
- },
608
- component: _sfc_main$1,
609
- interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },
610
- useAppearanceStream: false
611
- })
612
- ];
613
- const _sfc_main = /* @__PURE__ */ defineComponent({
614
- __name: "redact-renderer-registration",
615
- setup(__props) {
616
- useRegisterRenderers(redactRenderers);
617
- return (_ctx, _cache) => {
618
- return renderSlot(_ctx.$slots, "default");
619
- };
620
- }
621
- });
622
- const RedactionPluginPackage = createPluginPackage(RedactionPluginPackage$1).addUtility(_sfc_main).build();
623
- export {
624
- _sfc_main$7 as Highlight,
625
- _sfc_main$6 as MarqueeRedact,
626
- _sfc_main$4 as PendingRedactions,
627
- _sfc_main$1 as RedactArea,
628
- _sfc_main$2 as RedactHighlight,
629
- _sfc_main as RedactRendererRegistration,
630
- _sfc_main$3 as RedactionLayer,
631
- RedactionPluginPackage,
632
- _sfc_main$5 as SelectionRedact,
633
- redactRenderers,
634
- useRedaction,
635
- useRedactionCapability,
636
- useRedactionPlugin
637
- };
638
- //# sourceMappingURL=index.js.map