@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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +573 -207
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +48 -13
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/redaction-plugin.d.ts +22 -8
- package/dist/lib/reducer.d.ts +4 -2
- package/dist/lib/selectors.d.ts +5 -3
- package/dist/lib/types.d.ts +68 -20
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +86 -37
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +86 -37
- package/dist/react/index.js.map +1 -1
- package/dist/shared/components/marquee-redact.d.ts +4 -2
- package/dist/shared/components/pending-redactions.d.ts +4 -3
- package/dist/shared/components/redaction-layer.d.ts +11 -5
- package/dist/shared/components/selection-redact.d.ts +2 -1
- package/dist/shared/components/types.d.ts +6 -7
- package/dist/shared/hooks/use-redaction.d.ts +4 -4
- package/dist/shared-preact/components/marquee-redact.d.ts +4 -2
- package/dist/shared-preact/components/pending-redactions.d.ts +4 -3
- package/dist/shared-preact/components/redaction-layer.d.ts +11 -5
- package/dist/shared-preact/components/selection-redact.d.ts +2 -1
- package/dist/shared-preact/components/types.d.ts +6 -7
- package/dist/shared-preact/hooks/use-redaction.d.ts +4 -4
- package/dist/shared-react/components/marquee-redact.d.ts +4 -2
- package/dist/shared-react/components/pending-redactions.d.ts +4 -3
- package/dist/shared-react/components/redaction-layer.d.ts +11 -5
- package/dist/shared-react/components/selection-redact.d.ts +2 -1
- package/dist/shared-react/components/types.d.ts +6 -7
- package/dist/shared-react/hooks/use-redaction.d.ts +4 -4
- package/dist/svelte/components/highlight.svelte.d.ts +14 -0
- package/dist/svelte/components/index.d.ts +5 -0
- package/dist/svelte/components/marquee-redact.svelte.d.ts +16 -0
- package/dist/svelte/components/pending-redactions.svelte.d.ts +15 -0
- package/dist/svelte/components/redaction-layer.svelte.d.ts +20 -0
- package/dist/svelte/components/selection-redact.svelte.d.ts +8 -0
- package/dist/svelte/hooks/index.d.ts +1 -0
- package/dist/svelte/hooks/use-redaction.svelte.d.ts +21 -0
- package/dist/svelte/index.cjs +2 -0
- package/dist/svelte/index.cjs.map +1 -0
- package/dist/svelte/index.d.ts +4 -0
- package/dist/svelte/index.js +554 -0
- package/dist/svelte/index.js.map +1 -0
- package/dist/svelte/types.d.ts +10 -0
- package/dist/vue/components/highlight.vue.d.ts +2 -1
- package/dist/vue/components/marquee-redact.vue.d.ts +5 -2
- package/dist/vue/components/pending-redactions.vue.d.ts +18 -13
- package/dist/vue/components/redaction-layer.vue.d.ts +13 -4
- package/dist/vue/components/selection-redact.vue.d.ts +3 -1
- package/dist/vue/components/types.d.ts +9 -0
- package/dist/vue/hooks/use-redaction.d.ts +9 -102
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/index.js +219 -125
- package/dist/vue/index.js.map +1 -1
- package/package.json +18 -10
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import * as $ from "svelte/internal/client";
|
|
2
|
+
import { RedactionPlugin, initialDocumentState } from "@embedpdf/plugin-redaction";
|
|
3
|
+
export * from "@embedpdf/plugin-redaction";
|
|
4
|
+
import { usePlugin, useCapability, useDocumentState } from "@embedpdf/core/svelte";
|
|
5
|
+
import "svelte/internal/disclose-version";
|
|
6
|
+
import { Rotation } from "@embedpdf/models";
|
|
7
|
+
import { CounterRotate } from "@embedpdf/utils/svelte";
|
|
8
|
+
const useRedactionPlugin = () => usePlugin(RedactionPlugin.id);
|
|
9
|
+
const useRedactionCapability = () => useCapability(RedactionPlugin.id);
|
|
10
|
+
const useRedaction = (getDocumentId) => {
|
|
11
|
+
const capability = useRedactionCapability();
|
|
12
|
+
let state = $.state($.proxy(initialDocumentState));
|
|
13
|
+
const documentId = $.derived(getDocumentId);
|
|
14
|
+
const scopedProvides = $.derived(() => capability.provides && $.get(documentId) ? capability.provides.forDocument($.get(documentId)) : null);
|
|
15
|
+
$.user_effect(() => {
|
|
16
|
+
const provides = capability.provides;
|
|
17
|
+
const docId = $.get(documentId);
|
|
18
|
+
if (!provides || !docId) {
|
|
19
|
+
$.set(state, initialDocumentState, true);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const scope = provides.forDocument(docId);
|
|
23
|
+
try {
|
|
24
|
+
$.set(state, scope.getState(), true);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
$.set(state, initialDocumentState, true);
|
|
27
|
+
}
|
|
28
|
+
return scope.onStateChange((newState) => {
|
|
29
|
+
$.set(state, newState, true);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
get provides() {
|
|
34
|
+
return $.get(scopedProvides);
|
|
35
|
+
},
|
|
36
|
+
get state() {
|
|
37
|
+
return $.get(state);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
var root_1$3 = $.from_html(`<div></div>`);
|
|
42
|
+
function Highlight($$anchor, $$props) {
|
|
43
|
+
let color = $.prop($$props, "color", 3, "#FFFF00"), opacity = $.prop($$props, "opacity", 3, 1), border = $.prop($$props, "border", 3, "1px solid red"), style = $.prop($$props, "style", 3, "");
|
|
44
|
+
const boundingRect = $$props.rect;
|
|
45
|
+
var fragment = $.comment();
|
|
46
|
+
var node = $.first_child(fragment);
|
|
47
|
+
$.each(node, 17, () => $$props.rects, $.index, ($$anchor2, b) => {
|
|
48
|
+
var div = root_1$3();
|
|
49
|
+
div.__pointerdown = function(...$$args) {
|
|
50
|
+
var _a;
|
|
51
|
+
(_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
|
|
52
|
+
};
|
|
53
|
+
div.__touchstart = function(...$$args) {
|
|
54
|
+
var _a;
|
|
55
|
+
(_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
|
|
56
|
+
};
|
|
57
|
+
let styles;
|
|
58
|
+
$.template_effect(() => styles = $.set_style(div, style(), styles, {
|
|
59
|
+
position: "absolute",
|
|
60
|
+
border: border(),
|
|
61
|
+
left: `${(boundingRect ? $.get(b).origin.x - boundingRect.origin.x : $.get(b).origin.x) * $$props.scale}px`,
|
|
62
|
+
top: `${(boundingRect ? $.get(b).origin.y - boundingRect.origin.y : $.get(b).origin.y) * $$props.scale}px`,
|
|
63
|
+
width: `${$.get(b).size.width * $$props.scale}px`,
|
|
64
|
+
height: `${$.get(b).size.height * $$props.scale}px`,
|
|
65
|
+
background: color(),
|
|
66
|
+
opacity: opacity(),
|
|
67
|
+
"pointer-events": $$props.onClick ? "auto" : "none",
|
|
68
|
+
cursor: $$props.onClick ? "pointer" : "default",
|
|
69
|
+
"z-index": $$props.onClick ? "1" : void 0
|
|
70
|
+
}));
|
|
71
|
+
$.append($$anchor2, div);
|
|
72
|
+
});
|
|
73
|
+
$.append($$anchor, fragment);
|
|
74
|
+
}
|
|
75
|
+
$.delegate(["pointerdown", "touchstart"]);
|
|
76
|
+
var root_1$2 = $.from_html(`<div></div>`);
|
|
77
|
+
function Marquee_redact($$anchor, $$props) {
|
|
78
|
+
$.push($$props, true);
|
|
79
|
+
let className = $.prop($$props, "className", 3, ""), stroke = $.prop($$props, "stroke", 3, "red"), fill = $.prop($$props, "fill", 3, "transparent");
|
|
80
|
+
const redactionPlugin = useRedactionPlugin();
|
|
81
|
+
const documentState = useDocumentState(() => $$props.documentId);
|
|
82
|
+
let rect = $.state(null);
|
|
83
|
+
const actualScale = $.derived(() => {
|
|
84
|
+
var _a;
|
|
85
|
+
return $$props.scale !== void 0 ? $$props.scale : ((_a = documentState.current) == null ? void 0 : _a.scale) ?? 1;
|
|
86
|
+
});
|
|
87
|
+
$.user_effect(() => {
|
|
88
|
+
if (!redactionPlugin.plugin || !$$props.documentId) {
|
|
89
|
+
$.set(rect, null);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
return redactionPlugin.plugin.registerMarqueeOnPage({
|
|
93
|
+
documentId: $$props.documentId,
|
|
94
|
+
pageIndex: $$props.pageIndex,
|
|
95
|
+
scale: $.get(actualScale),
|
|
96
|
+
callback: {
|
|
97
|
+
onPreview: (newRect) => {
|
|
98
|
+
$.set(rect, newRect, true);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
var fragment = $.comment();
|
|
104
|
+
var node = $.first_child(fragment);
|
|
105
|
+
{
|
|
106
|
+
var consequent = ($$anchor2) => {
|
|
107
|
+
var div = root_1$2();
|
|
108
|
+
let styles;
|
|
109
|
+
$.template_effect(() => {
|
|
110
|
+
$.set_class(div, 1, $.clsx(className()));
|
|
111
|
+
styles = $.set_style(div, "", styles, {
|
|
112
|
+
position: "absolute",
|
|
113
|
+
"pointer-events": "none",
|
|
114
|
+
left: `${$.get(rect).origin.x * $.get(actualScale)}px`,
|
|
115
|
+
top: `${$.get(rect).origin.y * $.get(actualScale)}px`,
|
|
116
|
+
width: `${$.get(rect).size.width * $.get(actualScale)}px`,
|
|
117
|
+
height: `${$.get(rect).size.height * $.get(actualScale)}px`,
|
|
118
|
+
border: `1px solid ${stroke()}`,
|
|
119
|
+
background: fill(),
|
|
120
|
+
"box-sizing": "border-box"
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
$.append($$anchor2, div);
|
|
124
|
+
};
|
|
125
|
+
$.if(node, ($$render) => {
|
|
126
|
+
if ($.get(rect)) $$render(consequent);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
$.append($$anchor, fragment);
|
|
130
|
+
$.pop();
|
|
131
|
+
}
|
|
132
|
+
var root_3 = $.from_html(`<div></div> <!>`, 1);
|
|
133
|
+
var root_10 = $.from_html(`<div><!></div> <!>`, 1);
|
|
134
|
+
var root_1$1 = $.from_html(`<div style="position: absolute; inset: 0; pointer-events: none;"></div>`);
|
|
135
|
+
function Pending_redactions($$anchor, $$props) {
|
|
136
|
+
$.push($$props, true);
|
|
137
|
+
let rotation = $.prop($$props, "rotation", 19, () => Rotation.Degree0), bboxStroke = $.prop($$props, "bboxStroke", 3, "rgba(0,0,0,0.8)");
|
|
138
|
+
const redactionCapability = useRedactionCapability();
|
|
139
|
+
let items = $.state($.proxy([]));
|
|
140
|
+
let selectedId = $.state(null);
|
|
141
|
+
$.user_effect(() => {
|
|
142
|
+
var _a;
|
|
143
|
+
const redactionValue = redactionCapability.provides;
|
|
144
|
+
if (!redactionValue) {
|
|
145
|
+
$.set(items, [], true);
|
|
146
|
+
$.set(selectedId, null);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const scoped = redactionValue.forDocument($$props.documentId);
|
|
150
|
+
const currentState = scoped.getState();
|
|
151
|
+
$.set(items, currentState.pending[$$props.pageIndex] ?? [], true);
|
|
152
|
+
$.set(selectedId, ((_a = currentState.selected) == null ? void 0 : _a.page) === $$props.pageIndex ? currentState.selected.id : null, true);
|
|
153
|
+
const off1 = scoped.onPendingChange((map) => {
|
|
154
|
+
$.set(items, map[$$props.pageIndex] ?? [], true);
|
|
155
|
+
});
|
|
156
|
+
const off2 = scoped.onSelectedChange((sel) => {
|
|
157
|
+
$.set(selectedId, (sel == null ? void 0 : sel.page) === $$props.pageIndex ? sel.id : null, true);
|
|
158
|
+
});
|
|
159
|
+
return () => {
|
|
160
|
+
off1 == null ? void 0 : off1();
|
|
161
|
+
off2 == null ? void 0 : off2();
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
function select(e, id) {
|
|
165
|
+
e.stopPropagation();
|
|
166
|
+
if (!redactionCapability.provides) return;
|
|
167
|
+
redactionCapability.provides.forDocument($$props.documentId).selectPending($$props.pageIndex, id);
|
|
168
|
+
}
|
|
169
|
+
function shouldShowMenu(itemId) {
|
|
170
|
+
const isSelected = $.get(selectedId) === itemId;
|
|
171
|
+
return isSelected && (!!$$props.selectionMenu || !!$$props.selectionMenuSnippet);
|
|
172
|
+
}
|
|
173
|
+
function buildContext(item) {
|
|
174
|
+
return { type: "redaction", item, pageIndex: $$props.pageIndex };
|
|
175
|
+
}
|
|
176
|
+
const menuPlacement = { suggestTop: false, spaceAbove: 0, spaceBelow: 0 };
|
|
177
|
+
function buildMenuProps(item, rect, menuWrapperProps) {
|
|
178
|
+
return {
|
|
179
|
+
context: buildContext(item),
|
|
180
|
+
selected: $.get(selectedId) === item.id,
|
|
181
|
+
rect,
|
|
182
|
+
placement: menuPlacement,
|
|
183
|
+
menuWrapperProps
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
var fragment = $.comment();
|
|
187
|
+
var node = $.first_child(fragment);
|
|
188
|
+
{
|
|
189
|
+
var consequent_9 = ($$anchor2) => {
|
|
190
|
+
var div = root_1$1();
|
|
191
|
+
$.each(div, 21, () => $.get(items), (item) => item.id, ($$anchor3, item) => {
|
|
192
|
+
var fragment_1 = $.comment();
|
|
193
|
+
var node_1 = $.first_child(fragment_1);
|
|
194
|
+
{
|
|
195
|
+
var consequent_4 = ($$anchor4) => {
|
|
196
|
+
var fragment_2 = root_3();
|
|
197
|
+
var div_1 = $.first_child(fragment_2);
|
|
198
|
+
div_1.__pointerdown = (e) => select(e, $.get(item).id);
|
|
199
|
+
div_1.__touchstart = (e) => select(e, $.get(item).id);
|
|
200
|
+
var node_2 = $.sibling(div_1, 2);
|
|
201
|
+
{
|
|
202
|
+
var consequent_3 = ($$anchor5) => {
|
|
203
|
+
{
|
|
204
|
+
const children = ($$anchor6, $$arg0) => {
|
|
205
|
+
let rect = () => $$arg0 == null ? void 0 : $$arg0().rect;
|
|
206
|
+
let menuWrapperProps = () => $$arg0 == null ? void 0 : $$arg0().menuWrapperProps;
|
|
207
|
+
const menuProps = $.derived(() => buildMenuProps($.get(item), rect(), menuWrapperProps()));
|
|
208
|
+
var fragment_4 = $.comment();
|
|
209
|
+
var node_3 = $.first_child(fragment_4);
|
|
210
|
+
{
|
|
211
|
+
var consequent_1 = ($$anchor7) => {
|
|
212
|
+
const result = $.derived(() => $$props.selectionMenu($.get(menuProps)));
|
|
213
|
+
var fragment_5 = $.comment();
|
|
214
|
+
var node_4 = $.first_child(fragment_5);
|
|
215
|
+
{
|
|
216
|
+
var consequent = ($$anchor8) => {
|
|
217
|
+
var fragment_6 = $.comment();
|
|
218
|
+
var node_5 = $.first_child(fragment_6);
|
|
219
|
+
$.component(node_5, () => $.get(result).component, ($$anchor9, result_component) => {
|
|
220
|
+
result_component($$anchor9, $.spread_props(() => $.get(result).props));
|
|
221
|
+
});
|
|
222
|
+
$.append($$anchor8, fragment_6);
|
|
223
|
+
};
|
|
224
|
+
$.if(node_4, ($$render) => {
|
|
225
|
+
if ($.get(result)) $$render(consequent);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
$.append($$anchor7, fragment_5);
|
|
229
|
+
};
|
|
230
|
+
var alternate = ($$anchor7) => {
|
|
231
|
+
var fragment_7 = $.comment();
|
|
232
|
+
var node_6 = $.first_child(fragment_7);
|
|
233
|
+
{
|
|
234
|
+
var consequent_2 = ($$anchor8) => {
|
|
235
|
+
var fragment_8 = $.comment();
|
|
236
|
+
var node_7 = $.first_child(fragment_8);
|
|
237
|
+
$.snippet(node_7, () => $$props.selectionMenuSnippet, () => $.get(menuProps));
|
|
238
|
+
$.append($$anchor8, fragment_8);
|
|
239
|
+
};
|
|
240
|
+
$.if(
|
|
241
|
+
node_6,
|
|
242
|
+
($$render) => {
|
|
243
|
+
if ($$props.selectionMenuSnippet) $$render(consequent_2);
|
|
244
|
+
},
|
|
245
|
+
true
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
$.append($$anchor7, fragment_7);
|
|
249
|
+
};
|
|
250
|
+
$.if(node_3, ($$render) => {
|
|
251
|
+
if ($$props.selectionMenu) $$render(consequent_1);
|
|
252
|
+
else $$render(alternate, false);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
$.append($$anchor6, fragment_4);
|
|
256
|
+
};
|
|
257
|
+
let $0 = $.derived(() => ({
|
|
258
|
+
origin: {
|
|
259
|
+
x: $.get(item).rect.origin.x * $$props.scale,
|
|
260
|
+
y: $.get(item).rect.origin.y * $$props.scale
|
|
261
|
+
},
|
|
262
|
+
size: {
|
|
263
|
+
width: $.get(item).rect.size.width * $$props.scale,
|
|
264
|
+
height: $.get(item).rect.size.height * $$props.scale
|
|
265
|
+
}
|
|
266
|
+
}));
|
|
267
|
+
CounterRotate($$anchor5, {
|
|
268
|
+
get rect() {
|
|
269
|
+
return $.get($0);
|
|
270
|
+
},
|
|
271
|
+
get rotation() {
|
|
272
|
+
return rotation();
|
|
273
|
+
},
|
|
274
|
+
children,
|
|
275
|
+
$$slots: { default: true }
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
$.if(node_2, ($$render) => {
|
|
280
|
+
if (shouldShowMenu($.get(item).id)) $$render(consequent_3);
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
$.template_effect(() => $.set_style(div_1, `
|
|
284
|
+
position: absolute;
|
|
285
|
+
left: ${$.get(item).rect.origin.x * $$props.scale}px;
|
|
286
|
+
top: ${$.get(item).rect.origin.y * $$props.scale}px;
|
|
287
|
+
width: ${$.get(item).rect.size.width * $$props.scale}px;
|
|
288
|
+
height: ${$.get(item).rect.size.height * $$props.scale}px;
|
|
289
|
+
background: transparent;
|
|
290
|
+
outline: ${$.get(selectedId) === $.get(item).id ? `1px solid ${bboxStroke()}` : "none"};
|
|
291
|
+
outline-offset: 2px;
|
|
292
|
+
border: 1px solid red;
|
|
293
|
+
pointer-events: auto;
|
|
294
|
+
cursor: pointer;
|
|
295
|
+
`));
|
|
296
|
+
$.append($$anchor4, fragment_2);
|
|
297
|
+
};
|
|
298
|
+
var alternate_2 = ($$anchor4) => {
|
|
299
|
+
var fragment_9 = root_10();
|
|
300
|
+
var div_2 = $.first_child(fragment_9);
|
|
301
|
+
var node_8 = $.child(div_2);
|
|
302
|
+
Highlight(node_8, {
|
|
303
|
+
get rect() {
|
|
304
|
+
return $.get(item).rect;
|
|
305
|
+
},
|
|
306
|
+
get rects() {
|
|
307
|
+
return $.get(item).rects;
|
|
308
|
+
},
|
|
309
|
+
color: "transparent",
|
|
310
|
+
border: "1px solid red",
|
|
311
|
+
get scale() {
|
|
312
|
+
return $$props.scale;
|
|
313
|
+
},
|
|
314
|
+
onClick: (e) => select(e, $.get(item).id)
|
|
315
|
+
});
|
|
316
|
+
$.reset(div_2);
|
|
317
|
+
var node_9 = $.sibling(div_2, 2);
|
|
318
|
+
{
|
|
319
|
+
var consequent_8 = ($$anchor5) => {
|
|
320
|
+
{
|
|
321
|
+
const children = ($$anchor6, $$arg0) => {
|
|
322
|
+
let rect = () => $$arg0 == null ? void 0 : $$arg0().rect;
|
|
323
|
+
let menuWrapperProps = () => $$arg0 == null ? void 0 : $$arg0().menuWrapperProps;
|
|
324
|
+
const menuProps = $.derived(() => buildMenuProps($.get(item), rect(), menuWrapperProps()));
|
|
325
|
+
var fragment_11 = $.comment();
|
|
326
|
+
var node_10 = $.first_child(fragment_11);
|
|
327
|
+
{
|
|
328
|
+
var consequent_6 = ($$anchor7) => {
|
|
329
|
+
const result = $.derived(() => $$props.selectionMenu($.get(menuProps)));
|
|
330
|
+
var fragment_12 = $.comment();
|
|
331
|
+
var node_11 = $.first_child(fragment_12);
|
|
332
|
+
{
|
|
333
|
+
var consequent_5 = ($$anchor8) => {
|
|
334
|
+
var fragment_13 = $.comment();
|
|
335
|
+
var node_12 = $.first_child(fragment_13);
|
|
336
|
+
$.component(node_12, () => $.get(result).component, ($$anchor9, result_component_1) => {
|
|
337
|
+
result_component_1($$anchor9, $.spread_props(() => $.get(result).props));
|
|
338
|
+
});
|
|
339
|
+
$.append($$anchor8, fragment_13);
|
|
340
|
+
};
|
|
341
|
+
$.if(node_11, ($$render) => {
|
|
342
|
+
if ($.get(result)) $$render(consequent_5);
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
$.append($$anchor7, fragment_12);
|
|
346
|
+
};
|
|
347
|
+
var alternate_1 = ($$anchor7) => {
|
|
348
|
+
var fragment_14 = $.comment();
|
|
349
|
+
var node_13 = $.first_child(fragment_14);
|
|
350
|
+
{
|
|
351
|
+
var consequent_7 = ($$anchor8) => {
|
|
352
|
+
var fragment_15 = $.comment();
|
|
353
|
+
var node_14 = $.first_child(fragment_15);
|
|
354
|
+
$.snippet(node_14, () => $$props.selectionMenuSnippet, () => $.get(menuProps));
|
|
355
|
+
$.append($$anchor8, fragment_15);
|
|
356
|
+
};
|
|
357
|
+
$.if(
|
|
358
|
+
node_13,
|
|
359
|
+
($$render) => {
|
|
360
|
+
if ($$props.selectionMenuSnippet) $$render(consequent_7);
|
|
361
|
+
},
|
|
362
|
+
true
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
$.append($$anchor7, fragment_14);
|
|
366
|
+
};
|
|
367
|
+
$.if(node_10, ($$render) => {
|
|
368
|
+
if ($$props.selectionMenu) $$render(consequent_6);
|
|
369
|
+
else $$render(alternate_1, false);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
$.append($$anchor6, fragment_11);
|
|
373
|
+
};
|
|
374
|
+
let $0 = $.derived(() => ({
|
|
375
|
+
origin: {
|
|
376
|
+
x: $.get(item).rect.origin.x * $$props.scale,
|
|
377
|
+
y: $.get(item).rect.origin.y * $$props.scale
|
|
378
|
+
},
|
|
379
|
+
size: {
|
|
380
|
+
width: $.get(item).rect.size.width * $$props.scale,
|
|
381
|
+
height: $.get(item).rect.size.height * $$props.scale
|
|
382
|
+
}
|
|
383
|
+
}));
|
|
384
|
+
CounterRotate($$anchor5, {
|
|
385
|
+
get rect() {
|
|
386
|
+
return $.get($0);
|
|
387
|
+
},
|
|
388
|
+
get rotation() {
|
|
389
|
+
return rotation();
|
|
390
|
+
},
|
|
391
|
+
children,
|
|
392
|
+
$$slots: { default: true }
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
$.if(node_9, ($$render) => {
|
|
397
|
+
if (shouldShowMenu($.get(item).id)) $$render(consequent_8);
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
$.template_effect(() => $.set_style(div_2, `
|
|
401
|
+
position: absolute;
|
|
402
|
+
left: ${$.get(item).rect.origin.x * $$props.scale}px;
|
|
403
|
+
top: ${$.get(item).rect.origin.y * $$props.scale}px;
|
|
404
|
+
width: ${$.get(item).rect.size.width * $$props.scale}px;
|
|
405
|
+
height: ${$.get(item).rect.size.height * $$props.scale}px;
|
|
406
|
+
background: transparent;
|
|
407
|
+
outline: ${$.get(selectedId) === $.get(item).id ? `1px solid ${bboxStroke()}` : "none"};
|
|
408
|
+
outline-offset: 2px;
|
|
409
|
+
pointer-events: auto;
|
|
410
|
+
cursor: ${$.get(selectedId) === $.get(item).id ? "pointer" : "default"};
|
|
411
|
+
`));
|
|
412
|
+
$.append($$anchor4, fragment_9);
|
|
413
|
+
};
|
|
414
|
+
$.if(node_1, ($$render) => {
|
|
415
|
+
if ($.get(item).kind === "area") $$render(consequent_4);
|
|
416
|
+
else $$render(alternate_2, false);
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
$.append($$anchor3, fragment_1);
|
|
420
|
+
});
|
|
421
|
+
$.reset(div);
|
|
422
|
+
$.append($$anchor2, div);
|
|
423
|
+
};
|
|
424
|
+
$.if(node, ($$render) => {
|
|
425
|
+
if ($.get(items).length) $$render(consequent_9);
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
$.append($$anchor, fragment);
|
|
429
|
+
$.pop();
|
|
430
|
+
}
|
|
431
|
+
$.delegate(["pointerdown", "touchstart"]);
|
|
432
|
+
var root_1 = $.from_html(`<div><!></div>`);
|
|
433
|
+
function Selection_redact($$anchor, $$props) {
|
|
434
|
+
$.push($$props, true);
|
|
435
|
+
const redactionPlugin = useRedactionPlugin();
|
|
436
|
+
let rects = $.state($.proxy([]));
|
|
437
|
+
let boundingRect = $.state(null);
|
|
438
|
+
$.user_effect(() => {
|
|
439
|
+
if (!redactionPlugin.plugin) {
|
|
440
|
+
$.set(rects, [], true);
|
|
441
|
+
$.set(boundingRect, null);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
return redactionPlugin.plugin.onRedactionSelectionChange($$props.documentId, (formattedSelection) => {
|
|
445
|
+
const selection = formattedSelection.find((s) => s.pageIndex === $$props.pageIndex);
|
|
446
|
+
$.set(rects, (selection == null ? void 0 : selection.segmentRects) ?? [], true);
|
|
447
|
+
$.set(boundingRect, (selection == null ? void 0 : selection.rect) ?? null, true);
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
var fragment = $.comment();
|
|
451
|
+
var node = $.first_child(fragment);
|
|
452
|
+
{
|
|
453
|
+
var consequent = ($$anchor2) => {
|
|
454
|
+
var div = root_1();
|
|
455
|
+
$.set_style(div, "", {}, {
|
|
456
|
+
"mix-blend-mode": "normal",
|
|
457
|
+
"pointer-events": "none",
|
|
458
|
+
position: "absolute",
|
|
459
|
+
inset: "0"
|
|
460
|
+
});
|
|
461
|
+
var node_1 = $.child(div);
|
|
462
|
+
Highlight(node_1, {
|
|
463
|
+
color: "transparent",
|
|
464
|
+
opacity: 1,
|
|
465
|
+
get rects() {
|
|
466
|
+
return $.get(rects);
|
|
467
|
+
},
|
|
468
|
+
get scale() {
|
|
469
|
+
return $$props.scale;
|
|
470
|
+
},
|
|
471
|
+
border: "1px solid red"
|
|
472
|
+
});
|
|
473
|
+
$.reset(div);
|
|
474
|
+
$.append($$anchor2, div);
|
|
475
|
+
};
|
|
476
|
+
$.if(node, ($$render) => {
|
|
477
|
+
if ($.get(boundingRect)) $$render(consequent);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
$.append($$anchor, fragment);
|
|
481
|
+
$.pop();
|
|
482
|
+
}
|
|
483
|
+
var root = $.from_html(`<!> <!> <!>`, 1);
|
|
484
|
+
function Redaction_layer($$anchor, $$props) {
|
|
485
|
+
$.push($$props, true);
|
|
486
|
+
const documentState = useDocumentState(() => $$props.documentId);
|
|
487
|
+
const actualScale = $.derived(() => {
|
|
488
|
+
var _a;
|
|
489
|
+
return $$props.scale !== void 0 ? $$props.scale : ((_a = documentState.current) == null ? void 0 : _a.scale) ?? 1;
|
|
490
|
+
});
|
|
491
|
+
const actualRotation = $.derived(() => {
|
|
492
|
+
var _a;
|
|
493
|
+
return $$props.rotation !== void 0 ? $$props.rotation : ((_a = documentState.current) == null ? void 0 : _a.rotation) ?? Rotation.Degree0;
|
|
494
|
+
});
|
|
495
|
+
var fragment = root();
|
|
496
|
+
var node = $.first_child(fragment);
|
|
497
|
+
Pending_redactions(node, {
|
|
498
|
+
get documentId() {
|
|
499
|
+
return $$props.documentId;
|
|
500
|
+
},
|
|
501
|
+
get pageIndex() {
|
|
502
|
+
return $$props.pageIndex;
|
|
503
|
+
},
|
|
504
|
+
get scale() {
|
|
505
|
+
return $.get(actualScale);
|
|
506
|
+
},
|
|
507
|
+
get rotation() {
|
|
508
|
+
return $.get(actualRotation);
|
|
509
|
+
},
|
|
510
|
+
get selectionMenu() {
|
|
511
|
+
return $$props.selectionMenu;
|
|
512
|
+
},
|
|
513
|
+
get selectionMenuSnippet() {
|
|
514
|
+
return $$props.selectionMenuSnippet;
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
var node_1 = $.sibling(node, 2);
|
|
518
|
+
Marquee_redact(node_1, {
|
|
519
|
+
get documentId() {
|
|
520
|
+
return $$props.documentId;
|
|
521
|
+
},
|
|
522
|
+
get pageIndex() {
|
|
523
|
+
return $$props.pageIndex;
|
|
524
|
+
},
|
|
525
|
+
get scale() {
|
|
526
|
+
return $.get(actualScale);
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
var node_2 = $.sibling(node_1, 2);
|
|
530
|
+
Selection_redact(node_2, {
|
|
531
|
+
get documentId() {
|
|
532
|
+
return $$props.documentId;
|
|
533
|
+
},
|
|
534
|
+
get pageIndex() {
|
|
535
|
+
return $$props.pageIndex;
|
|
536
|
+
},
|
|
537
|
+
get scale() {
|
|
538
|
+
return $.get(actualScale);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
$.append($$anchor, fragment);
|
|
542
|
+
$.pop();
|
|
543
|
+
}
|
|
544
|
+
export {
|
|
545
|
+
Highlight,
|
|
546
|
+
Marquee_redact as MarqueeRedact,
|
|
547
|
+
Pending_redactions as PendingRedactions,
|
|
548
|
+
Redaction_layer as RedactionLayer,
|
|
549
|
+
Selection_redact as SelectionRedact,
|
|
550
|
+
useRedaction,
|
|
551
|
+
useRedactionCapability,
|
|
552
|
+
useRedactionPlugin
|
|
553
|
+
};
|
|
554
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-redaction.svelte.ts","../../src/svelte/components/highlight.svelte","../../src/svelte/components/marquee-redact.svelte","../../src/svelte/components/pending-redactions.svelte","../../src/svelte/components/selection-redact.svelte","../../src/svelte/components/redaction-layer.svelte"],"sourcesContent":["import {\n RedactionPlugin,\n initialDocumentState,\n RedactionDocumentState,\n RedactionScope,\n} from '@embedpdf/plugin-redaction';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useRedactionPlugin = () => usePlugin<RedactionPlugin>(RedactionPlugin.id);\nexport const useRedactionCapability = () => useCapability<RedactionPlugin>(RedactionPlugin.id);\n\n// Define the return type explicitly to maintain type safety\ninterface UseRedactionReturn {\n provides: RedactionScope | null;\n state: RedactionDocumentState;\n}\n\n/**\n * Hook for redaction state for a specific document\n * @param getDocumentId Document ID getter function\n */\nexport const useRedaction = (getDocumentId: () => string | null): UseRedactionReturn => {\n const capability = useRedactionCapability();\n\n let state = $state<RedactionDocumentState>(initialDocumentState);\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n // Scoped capability for current docId\n const scopedProvides = $derived(\n capability.provides && documentId ? capability.provides.forDocument(documentId) : null,\n );\n\n $effect(() => {\n const provides = capability.provides;\n const docId = documentId;\n\n if (!provides || !docId) {\n state = initialDocumentState;\n return;\n }\n\n const scope = provides.forDocument(docId);\n\n // Get initial state\n try {\n state = scope.getState();\n } catch (e) {\n // Handle case where state might not be ready\n state = initialDocumentState;\n }\n\n // Subscribe to state changes for THIS docId\n return scope.onStateChange((newState) => {\n state = newState;\n });\n });\n\n return {\n get provides() {\n return scopedProvides;\n },\n get state() {\n return state;\n },\n };\n};\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n\n interface HighlightProps {\n color?: string;\n opacity?: number;\n border?: string;\n rects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent | TouchEvent) => void;\n style?: string;\n }\n\n let {\n color = '#FFFF00',\n opacity = 1,\n border = '1px solid red',\n rects,\n rect,\n scale,\n onClick,\n style = '',\n }: HighlightProps = $props();\n\n // Rename rect to boundingRect for clarity\n const boundingRect = rect;\n</script>\n\n{#each rects as b, i (i)}\n <div\n onpointerdown={onClick}\n ontouchstart={onClick}\n style:position=\"absolute\"\n style:border\n style:left={`${(boundingRect ? b.origin.x - boundingRect.origin.x : b.origin.x) * scale}px`}\n style:top={`${(boundingRect ? b.origin.y - boundingRect.origin.y : b.origin.y) * scale}px`}\n style:width={`${b.size.width * scale}px`}\n style:height={`${b.size.height * scale}px`}\n style:background={color}\n style:opacity\n style:pointer-events={onClick ? 'auto' : 'none'}\n style:cursor={onClick ? 'pointer' : 'default'}\n style:z-index={onClick ? '1' : undefined}\n {style}\n ></div>\n{/each}\n","<script lang=\"ts\">\n import { useDocumentState } from '@embedpdf/core/svelte';\n import type { Rect } from '@embedpdf/models';\n import { useRedactionPlugin } from '../hooks/use-redaction.svelte';\n\n interface MarqueeRedactProps {\n /** The ID of the document */\n documentId: string;\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale?: number;\n /** Optional CSS class applied to the marquee rectangle */\n className?: string;\n /** Stroke / fill colours (defaults below) */\n stroke?: string;\n fill?: string;\n }\n\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n className = '',\n stroke = 'red',\n fill = 'transparent',\n }: MarqueeRedactProps = $props();\n\n const redactionPlugin = useRedactionPlugin();\n const documentState = useDocumentState(() => documentId);\n let rect = $state<Rect | null>(null);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n $effect(() => {\n if (!redactionPlugin.plugin || !documentId) {\n rect = null;\n return;\n }\n\n return redactionPlugin.plugin.registerMarqueeOnPage({\n documentId,\n pageIndex,\n scale: actualScale,\n callback: {\n onPreview: (newRect) => {\n rect = newRect;\n },\n },\n });\n });\n</script>\n\n{#if rect}\n <div\n class={className}\n style:position=\"absolute\"\n style:pointer-events=\"none\"\n style:left={`${rect.origin.x * actualScale}px`}\n style:top={`${rect.origin.y * actualScale}px`}\n style:width={`${rect.size.width * actualScale}px`}\n style:height={`${rect.size.height * actualScale}px`}\n style:border={`1px solid ${stroke}`}\n style:background={fill}\n style:box-sizing=\"border-box\"\n ></div>\n{/if}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import type { Rect } from '@embedpdf/models';\n import { Rotation } from '@embedpdf/models';\n import { CounterRotate } from '@embedpdf/utils/svelte';\n import type { MenuWrapperProps, SelectionMenuPlacement } from '@embedpdf/utils/svelte';\n import type { RedactionItem } from '@embedpdf/plugin-redaction';\n import { useRedactionCapability } from '../hooks/use-redaction.svelte';\n import Highlight from './highlight.svelte';\n import type {\n RedactionSelectionContext,\n RedactionSelectionMenuRenderFn,\n RedactionSelectionMenuProps,\n } from '../types';\n\n interface Props {\n documentId: string;\n pageIndex: number;\n scale: number;\n rotation?: Rotation;\n bboxStroke?: string;\n selectionMenu?: RedactionSelectionMenuRenderFn;\n selectionMenuSnippet?: Snippet<[RedactionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale,\n rotation = Rotation.Degree0,\n bboxStroke = 'rgba(0,0,0,0.8)',\n selectionMenu,\n selectionMenuSnippet,\n }: Props = $props();\n\n const redactionCapability = useRedactionCapability();\n\n let items = $state<RedactionItem[]>([]);\n let selectedId = $state<string | null>(null);\n\n $effect(() => {\n const redactionValue = redactionCapability.provides;\n if (!redactionValue) {\n items = [];\n selectedId = null;\n return;\n }\n\n const scoped = redactionValue.forDocument(documentId);\n const currentState = scoped.getState();\n items = currentState.pending[pageIndex] ?? [];\n selectedId = currentState.selected?.page === pageIndex ? currentState.selected.id : null;\n\n const off1 = scoped.onPendingChange((map) => {\n items = map[pageIndex] ?? [];\n });\n\n const off2 = scoped.onSelectedChange((sel) => {\n selectedId = sel?.page === pageIndex ? sel.id : null;\n });\n\n return () => {\n off1?.();\n off2?.();\n };\n });\n\n function select(e: MouseEvent | TouchEvent, id: string) {\n e.stopPropagation();\n if (!redactionCapability.provides) return;\n redactionCapability.provides.forDocument(documentId).selectPending(pageIndex, id);\n }\n\n function shouldShowMenu(itemId: string): boolean {\n const isSelected = selectedId === itemId;\n return isSelected && (!!selectionMenu || !!selectionMenuSnippet);\n }\n\n function buildContext(item: RedactionItem): RedactionSelectionContext {\n return { type: 'redaction', item, pageIndex };\n }\n\n const menuPlacement: SelectionMenuPlacement = {\n suggestTop: false,\n spaceAbove: 0,\n spaceBelow: 0,\n };\n\n function buildMenuProps(\n item: RedactionItem,\n rect: Rect,\n menuWrapperProps: MenuWrapperProps,\n ): RedactionSelectionMenuProps {\n return {\n context: buildContext(item),\n selected: selectedId === item.id,\n rect,\n placement: menuPlacement,\n menuWrapperProps,\n };\n }\n</script>\n\n{#if items.length}\n <div style=\"position: absolute; inset: 0; pointer-events: none;\">\n {#each items as item (item.id)}\n {#if item.kind === 'area'}\n <div\n style=\"\n position: absolute;\n left: {item.rect.origin.x * scale}px;\n top: {item.rect.origin.y * scale}px;\n width: {item.rect.size.width * scale}px;\n height: {item.rect.size.height * scale}px;\n background: transparent;\n outline: {selectedId === item.id ? `1px solid ${bboxStroke}` : 'none'};\n outline-offset: 2px;\n border: 1px solid red;\n pointer-events: auto;\n cursor: pointer;\n \"\n onpointerdown={(e) => select(e, item.id)}\n ontouchstart={(e) => select(e, item.id)}\n ></div>\n\n {#if shouldShowMenu(item.id)}\n <CounterRotate\n rect={{\n origin: { x: item.rect.origin.x * scale, y: item.rect.origin.y * scale },\n size: { width: item.rect.size.width * scale, height: item.rect.size.height * scale },\n }}\n {rotation}\n >\n {#snippet children({ rect, menuWrapperProps })}\n {@const menuProps = buildMenuProps(item, rect, menuWrapperProps)}\n {#if selectionMenu}\n {@const result = selectionMenu(menuProps)}\n {#if result}\n <result.component {...result.props} />\n {/if}\n {:else if selectionMenuSnippet}\n {@render selectionMenuSnippet(menuProps)}\n {/if}\n {/snippet}\n </CounterRotate>\n {/if}\n {:else}\n <div\n style=\"\n position: absolute;\n left: {item.rect.origin.x * scale}px;\n top: {item.rect.origin.y * scale}px;\n width: {item.rect.size.width * scale}px;\n height: {item.rect.size.height * scale}px;\n background: transparent;\n outline: {selectedId === item.id ? `1px solid ${bboxStroke}` : 'none'};\n outline-offset: 2px;\n pointer-events: auto;\n cursor: {selectedId === item.id ? 'pointer' : 'default'};\n \"\n >\n <Highlight\n rect={item.rect}\n rects={item.rects}\n color=\"transparent\"\n border=\"1px solid red\"\n {scale}\n onClick={(e) => select(e, item.id)}\n />\n </div>\n\n {#if shouldShowMenu(item.id)}\n <CounterRotate\n rect={{\n origin: { x: item.rect.origin.x * scale, y: item.rect.origin.y * scale },\n size: { width: item.rect.size.width * scale, height: item.rect.size.height * scale },\n }}\n {rotation}\n >\n {#snippet children({ rect, menuWrapperProps })}\n {@const menuProps = buildMenuProps(item, rect, menuWrapperProps)}\n {#if selectionMenu}\n {@const result = selectionMenu(menuProps)}\n {#if result}\n <result.component {...result.props} />\n {/if}\n {:else if selectionMenuSnippet}\n {@render selectionMenuSnippet(menuProps)}\n {/if}\n {/snippet}\n </CounterRotate>\n {/if}\n {/if}\n {/each}\n </div>\n{/if}\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n import { useRedactionPlugin } from '../hooks/use-redaction.svelte';\n import Highlight from './highlight.svelte';\n\n interface SelectionRedactProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n }\n\n let { documentId, pageIndex, scale }: SelectionRedactProps = $props();\n\n const redactionPlugin = useRedactionPlugin();\n let rects = $state<Rect[]>([]);\n let boundingRect = $state<Rect | null>(null);\n\n $effect(() => {\n if (!redactionPlugin.plugin) {\n rects = [];\n boundingRect = null;\n return;\n }\n\n return redactionPlugin.plugin.onRedactionSelectionChange(documentId, (formattedSelection) => {\n const selection = formattedSelection.find((s) => s.pageIndex === pageIndex);\n rects = selection?.segmentRects ?? [];\n boundingRect = selection?.rect ?? null;\n });\n });\n</script>\n\n{#if boundingRect}\n <div\n style:mix-blend-mode=\"normal\"\n style:pointer-events=\"none\"\n style:position=\"absolute\"\n style:inset=\"0\"\n >\n <Highlight color=\"transparent\" opacity={1} {rects} {scale} border=\"1px solid red\" />\n </div>\n{/if}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import { Rotation } from '@embedpdf/models';\n import PendingRedactions from './pending-redactions.svelte';\n import MarqueeRedact from './marquee-redact.svelte';\n import SelectionRedact from './selection-redact.svelte';\n import type { RedactionSelectionMenuRenderFn, RedactionSelectionMenuProps } from '../types';\n\n interface RedactionLayerProps {\n /** The ID of the document this layer belongs to */\n documentId: string;\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Current render scale for this page */\n scale?: number;\n /** Page rotation (for counter-rotating menus, etc.) */\n rotation?: Rotation;\n /** Render function for selection menu (schema-driven approach) */\n selectionMenu?: RedactionSelectionMenuRenderFn;\n /** Snippet for custom selection menu (slot-based approach) */\n selectionMenuSnippet?: Snippet<[RedactionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale,\n rotation,\n selectionMenu,\n selectionMenuSnippet,\n }: RedactionLayerProps = $props();\n\n const documentState = useDocumentState(() => documentId);\n\n const actualScale = $derived(scale !== undefined ? scale : (documentState.current?.scale ?? 1));\n\n const actualRotation = $derived(\n rotation !== undefined ? rotation : (documentState.current?.rotation ?? Rotation.Degree0),\n );\n</script>\n\n<PendingRedactions\n {documentId}\n {pageIndex}\n scale={actualScale}\n rotation={actualRotation}\n {selectionMenu}\n {selectionMenuSnippet}\n/>\n<MarqueeRedact {documentId} {pageIndex} scale={actualScale} />\n<SelectionRedact {documentId} {pageIndex} scale={actualScale} />\n"],"names":["$$anchor"],"mappings":";;;;;;;AAQa,MAAA,qBAAA,MAA2B,UAA2B,gBAAgB,EAAE;AACxE,MAAA,yBAAA,MAA+B,cAA+B,gBAAgB,EAAE;MAYhF,eAAA,CAAgB,kBAA2D;AAChF,QAAA,aAAa,uBAAA;AAEf,MAAA,wBAAuC,oBAAoB,CAAA;AAGzD,QAAA,uBAAsB,aAAA;AAGtB,QAAA,iBAAA,EAAA,QAAA,MACJ,WAAW,kBAAY,UAAA,IAAa,WAAW,SAAS,kBAAY,UAAU,CAAA,IAAI,IAAA;AAGpF,IAAA,kBAAc;UACN,WAAW,WAAW;AACtB,UAAA,cAAQ,UAAA;SAET,YAAA,CAAa,OAAO;AACvB,QAAA,IAAA,OAAQ,sBAAA,IAAA;;IAEV;AAEM,UAAA,QAAQ,SAAS,YAAY,KAAK;QAGpC;YACF,OAAQ,MAAM,SAAA,GAAA,IAAA;AAAA,IAChB,SAAS,GAAG;AAEV,QAAA,IAAA,OAAQ,sBAAA,IAAA;AAAA,IACV;AAGO,WAAA,MAAM,cAAA,CAAe,aAAa;AACvC,QAAA,IAAA,OAAQ,UAAA,IAAA;AAAA,IACV,CAAC;AAAA,EACH,CAAC;;IAGK,IAAA,WAAW;mBACN,cAAA;AAAA,IACT;AAAA,IACI,IAAA,QAAQ;mBACH,KAAA;AAAA,IACT;AAAA;AAEJ;;sCCnEA;AAeI,MAAA,oCAAQ,SAAS,GACjB,wC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ACrF,YAAY,mBAAmB,MAAM,MAAM,EAAE,cAAS,QAAA,SAAA;YAC5D,QAAQ,uCAAW,iBAAY,CAAA,GAAA,IAAA;AAC/B,QAAA,IAAA,eAAe,uCAAW,SAAQ,MAAI,IAAA;AAAA,IACxC,CAAC;AAAA,EACH,CAAC;;;;;;;;;;;;;;;iBAUyC;AAAA;;;;;;;;;;;;gBAPvC,YAAY,EAAA,UAAA,UAAA;AAAA;;;;AAFjB;;4CC9BA;;AAiCQ,QAAA,gBAAgB,iBAAgB,MAAA,QAAA,UAAA;QAEhC,cAAW,EAAA,QAAA,MAAA;;AAAA,mBAAA,UAAsB,SAAS,QAAA,UAAY,mBAAc,YAAd,mBAAuB,UAAS;AAAA,GAAC;AAEvF,QAAA;;gCACS,8BAAwB,mBAAc,YAAd,mBAAuB,aAAY,SAAS;AAAA,GAAO;;;;;;;;;;;mBAOnF,WAAW;AAAA;;mBACR,cAAc;AAAA;;;;;;;;;;;;;;;;;mBAIqB,WAAW;AAAA;;;;;;;;;;;mBACT,WAAW;AAAA;;;;AAX5D;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SelectionMenuPropsBase, SelectionMenuRenderFn, SelectionMenuRenderResult } from '@embedpdf/utils/svelte';
|
|
2
|
+
import { RedactionItem } from '../lib/index.ts';
|
|
3
|
+
export interface RedactionSelectionContext {
|
|
4
|
+
type: 'redaction';
|
|
5
|
+
item: RedactionItem;
|
|
6
|
+
pageIndex: number;
|
|
7
|
+
}
|
|
8
|
+
export type RedactionSelectionMenuProps = SelectionMenuPropsBase<RedactionSelectionContext>;
|
|
9
|
+
export type RedactionSelectionMenuRenderFn = SelectionMenuRenderFn<RedactionSelectionContext>;
|
|
10
|
+
export type { SelectionMenuRenderResult };
|
|
@@ -8,9 +8,10 @@ interface HighlightProps {
|
|
|
8
8
|
scale: number;
|
|
9
9
|
onClick?: (e: PointerEvent | TouchEvent) => void;
|
|
10
10
|
}
|
|
11
|
-
declare const
|
|
11
|
+
declare const __VLS_export: import('vue').DefineComponent<HighlightProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<HighlightProps> & Readonly<{}>, {
|
|
12
12
|
color: string;
|
|
13
13
|
opacity: number;
|
|
14
14
|
border: string;
|
|
15
15
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
16
17
|
export default _default;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
interface MarqueeRedactProps {
|
|
2
|
+
/** The ID of the document */
|
|
3
|
+
documentId: string;
|
|
2
4
|
/** Index of the page this layer lives on */
|
|
3
5
|
pageIndex: number;
|
|
4
6
|
/** Scale of the page */
|
|
5
|
-
scale
|
|
7
|
+
scale?: number;
|
|
6
8
|
/** Optional CSS class applied to the marquee rectangle */
|
|
7
9
|
className?: string;
|
|
8
10
|
/** Stroke / fill colours (defaults below) */
|
|
9
11
|
stroke?: string;
|
|
10
12
|
fill?: string;
|
|
11
13
|
}
|
|
12
|
-
declare const
|
|
14
|
+
declare const __VLS_export: import('vue').DefineComponent<MarqueeRedactProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<MarqueeRedactProps> & Readonly<{}>, {
|
|
13
15
|
fill: string;
|
|
14
16
|
stroke: string;
|
|
15
17
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
16
19
|
export default _default;
|