@arbidocs/react 0.4.68 → 0.4.70
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/README.md +8 -0
- package/dist/annotations/index.cjs +186 -2450
- package/dist/annotations/index.cjs.map +1 -1
- package/dist/annotations/index.d.cts +3 -33
- package/dist/annotations/index.d.ts +3 -33
- package/dist/annotations/index.js +4 -2411
- package/dist/annotations/index.js.map +1 -1
- package/dist/artifacts/index.cjs +88 -112
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.js +12 -61
- package/dist/artifacts/index.js.map +1 -1
- package/dist/artifacts/redline-core.cjs +8 -7
- package/dist/artifacts/redline-core.js +2 -1
- package/dist/{chunk-PATLJSAO.cjs → chunk-3AADNIOK.cjs} +9 -52
- package/dist/chunk-3AADNIOK.cjs.map +1 -0
- package/dist/chunk-3QF5DNAP.js +2413 -0
- package/dist/chunk-3QF5DNAP.js.map +1 -0
- package/dist/chunk-5DCRIWCA.cjs +243 -0
- package/dist/chunk-5DCRIWCA.cjs.map +1 -0
- package/dist/{chunk-NA3FOYSF.cjs → chunk-5SZ2J2WT.cjs} +5 -177
- package/dist/chunk-5SZ2J2WT.cjs.map +1 -0
- package/dist/{chunk-43AKLNBC.js → chunk-74N436VK.js} +4 -40
- package/dist/chunk-74N436VK.js.map +1 -0
- package/dist/{chunk-Z3RRZ3KV.cjs → chunk-7CL7QHT6.cjs} +2 -240
- package/dist/chunk-7CL7QHT6.cjs.map +1 -0
- package/dist/{chunk-BWVIAATD.cjs → chunk-BTRIS3HY.cjs} +4 -4
- package/dist/{chunk-BWVIAATD.cjs.map → chunk-BTRIS3HY.cjs.map} +1 -1
- package/dist/chunk-G6FHNURH.js +234 -0
- package/dist/chunk-G6FHNURH.js.map +1 -0
- package/dist/chunk-HKUD2NZN.js +61 -0
- package/dist/chunk-HKUD2NZN.js.map +1 -0
- package/dist/chunk-QRCMKEE6.js +173 -0
- package/dist/chunk-QRCMKEE6.js.map +1 -0
- package/dist/{chunk-PFKLOVGQ.js → chunk-SYPUFZGA.js} +3 -233
- package/dist/chunk-SYPUFZGA.js.map +1 -0
- package/dist/chunk-T4IJHRRD.cjs +71 -0
- package/dist/chunk-T4IJHRRD.cjs.map +1 -0
- package/dist/chunk-ULU5LEWF.cjs +2460 -0
- package/dist/chunk-ULU5LEWF.cjs.map +1 -0
- package/dist/{chunk-TQ6FRVAH.js → chunk-V4CXOPLB.js} +3 -3
- package/dist/{chunk-TQ6FRVAH.js.map → chunk-V4CXOPLB.js.map} +1 -1
- package/dist/chunk-VOFNX4P6.cjs +50 -0
- package/dist/chunk-VOFNX4P6.cjs.map +1 -0
- package/dist/chunk-WUTL62MC.js +42 -0
- package/dist/chunk-WUTL62MC.js.map +1 -0
- package/dist/{chunk-JPGV7NMY.js → chunk-YXSXGTYQ.js} +4 -173
- package/dist/chunk-YXSXGTYQ.js.map +1 -0
- package/dist/chunk-Z3LLUO32.cjs +177 -0
- package/dist/chunk-Z3LLUO32.cjs.map +1 -0
- package/dist/document-tools/index.cjs +683 -0
- package/dist/document-tools/index.cjs.map +1 -0
- package/dist/document-tools/index.d.cts +392 -0
- package/dist/document-tools/index.d.ts +392 -0
- package/dist/document-tools/index.js +639 -0
- package/dist/document-tools/index.js.map +1 -0
- package/dist/index.cjs +320 -318
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/dist/store-CqkkD7Ho.d.cts +35 -0
- package/dist/store-D1nhbkgk.d.ts +35 -0
- package/dist/ui/index.cjs +138 -137
- package/dist/ui/index.js +3 -2
- package/package.json +11 -3
- package/dist/chunk-43AKLNBC.js.map +0 -1
- package/dist/chunk-JPGV7NMY.js.map +0 -1
- package/dist/chunk-NA3FOYSF.cjs.map +0 -1
- package/dist/chunk-PATLJSAO.cjs.map +0 -1
- package/dist/chunk-PFKLOVGQ.js.map +0 -1
- package/dist/chunk-Z3RRZ3KV.cjs.map +0 -1
|
@@ -1,2414 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { usePortalContainer, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '../chunk-47CCGUWR.js';
|
|
3
|
-
import { cn } from '../chunk-SN5YV6FF.js';
|
|
4
|
-
import { parseAnnotation, parseLayer, emptyLayer, clampRect, isEffectiveRedaction } from '../chunk-COWZGCL5.js';
|
|
1
|
+
export { AUTOSAVE_MS, AnnotationPageOverlay, AnnotationStoreOfflineError, AnnotationToolbar, DEFAULT_SETTINGS, FreezeDialog, HIGHLIGHT_COLORS, MARK_COLORS, ProductionDialog, REDACTION_LOG_COLUMNS, REDACTION_REASONS, RETRY_MS, STAMP_PRESETS, annotationsOnPage, applyAction, canRedo, canUndo, containsPoint, createHistory, createLocalStorageStore, createMemoryStore, dragRect, dragToNorm, intersects, isTooSmall, layerStatusText, mergeLayers, mergeLineRects, moveItem, patchForRect, pendingRedactions, qrCornerFor, readSelection, redactionLogCsv, redactionLogRows, redo, reduceLayer, sameMarks, selectionToPageMarks, singleRect, toNorm, toPixels, undo, useAnnotationLayer, useAnnotationShortcuts, useTextSelectionMarks } from '../chunk-3QF5DNAP.js';
|
|
5
2
|
export { AnnotationLayerError, LAYER_SCHEMA_VERSION, annotationRects, clampRect, emptyLayer, isEffectiveRedaction, parseAnnotation, parseLayer } from '../chunk-COWZGCL5.js';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
// src/annotations/state.ts
|
|
11
|
-
var HISTORY_LIMIT = 200;
|
|
12
|
-
function createHistory(layer) {
|
|
13
|
-
return { present: layer, past: [], future: [] };
|
|
14
|
-
}
|
|
15
|
-
function reduceLayer(layer, action) {
|
|
16
|
-
switch (action.type) {
|
|
17
|
-
case "replaceAll":
|
|
18
|
-
return action.layer;
|
|
19
|
-
case "add": {
|
|
20
|
-
const annotation = parseAnnotation(action.annotation);
|
|
21
|
-
if (layer.annotations.some((a) => a.id === annotation.id)) {
|
|
22
|
-
throw new Error(`annotation ${annotation.id} already exists`);
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
...layer,
|
|
26
|
-
annotations: [...layer.annotations, annotation],
|
|
27
|
-
updatedAt: annotation.updatedAt
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
case "addMany": {
|
|
31
|
-
let next = layer;
|
|
32
|
-
for (const annotation of action.annotations)
|
|
33
|
-
next = reduceLayer(next, { type: "add", annotation });
|
|
34
|
-
return next;
|
|
35
|
-
}
|
|
36
|
-
case "update": {
|
|
37
|
-
const found = layer.annotations.find((a) => a.id === action.id);
|
|
38
|
-
if (!found) return layer;
|
|
39
|
-
const next = parseAnnotation({
|
|
40
|
-
...found,
|
|
41
|
-
...action.patch,
|
|
42
|
-
id: found.id,
|
|
43
|
-
kind: found.kind,
|
|
44
|
-
page: found.page,
|
|
45
|
-
createdAt: found.createdAt,
|
|
46
|
-
updatedAt: action.now
|
|
47
|
-
});
|
|
48
|
-
return replace(layer, next, action.now);
|
|
49
|
-
}
|
|
50
|
-
case "remove": {
|
|
51
|
-
if (!layer.annotations.some((a) => a.id === action.id)) return layer;
|
|
52
|
-
return {
|
|
53
|
-
...layer,
|
|
54
|
-
annotations: layer.annotations.filter((a) => a.id !== action.id),
|
|
55
|
-
updatedAt: action.now
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
case "setRedactionStatus": {
|
|
59
|
-
const ids = new Set(action.ids);
|
|
60
|
-
let changed = false;
|
|
61
|
-
const annotations = layer.annotations.map((a) => {
|
|
62
|
-
if (a.kind !== "redaction" || !ids.has(a.id) || a.status === action.status) return a;
|
|
63
|
-
changed = true;
|
|
64
|
-
const next = { ...a, status: action.status, updatedAt: action.now };
|
|
65
|
-
delete next.reviewedBy;
|
|
66
|
-
delete next.reviewedAt;
|
|
67
|
-
if (action.status !== "pending" && action.by) {
|
|
68
|
-
next.reviewedBy = action.by;
|
|
69
|
-
next.reviewedAt = action.now;
|
|
70
|
-
}
|
|
71
|
-
return next;
|
|
72
|
-
});
|
|
73
|
-
return changed ? { ...layer, annotations, updatedAt: action.now } : layer;
|
|
74
|
-
}
|
|
75
|
-
case "reply": {
|
|
76
|
-
const found = layer.annotations.find((a) => a.id === action.id);
|
|
77
|
-
if (!found || found.kind !== "comment") return layer;
|
|
78
|
-
const next = parseAnnotation({
|
|
79
|
-
...found,
|
|
80
|
-
replies: [...found.replies, action.reply],
|
|
81
|
-
updatedAt: action.now
|
|
82
|
-
});
|
|
83
|
-
return replace(layer, next, action.now);
|
|
84
|
-
}
|
|
85
|
-
case "resolve": {
|
|
86
|
-
const found = layer.annotations.find((a) => a.id === action.id);
|
|
87
|
-
if (!found || found.kind !== "comment" || found.resolved === action.resolved) return layer;
|
|
88
|
-
return replace(
|
|
89
|
-
layer,
|
|
90
|
-
{ ...found, resolved: action.resolved, updatedAt: action.now },
|
|
91
|
-
action.now
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function replace(layer, next, now) {
|
|
97
|
-
return {
|
|
98
|
-
...layer,
|
|
99
|
-
annotations: layer.annotations.map((a) => a.id === next.id ? next : a),
|
|
100
|
-
updatedAt: now
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function applyAction(history, action) {
|
|
104
|
-
const present = reduceLayer(history.present, action);
|
|
105
|
-
if (present === history.present) return history;
|
|
106
|
-
const past = [...history.past, history.present];
|
|
107
|
-
return {
|
|
108
|
-
present,
|
|
109
|
-
past: past.length > HISTORY_LIMIT ? past.slice(past.length - HISTORY_LIMIT) : past,
|
|
110
|
-
future: []
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function undo(history) {
|
|
114
|
-
const previous = history.past[history.past.length - 1];
|
|
115
|
-
if (!previous) return history;
|
|
116
|
-
return {
|
|
117
|
-
present: previous,
|
|
118
|
-
past: history.past.slice(0, -1),
|
|
119
|
-
future: [history.present, ...history.future]
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function redo(history) {
|
|
123
|
-
const [next, ...rest] = history.future;
|
|
124
|
-
if (!next) return history;
|
|
125
|
-
return { present: next, past: [...history.past, history.present], future: rest };
|
|
126
|
-
}
|
|
127
|
-
var canUndo = (h) => h.past.length > 0;
|
|
128
|
-
var canRedo = (h) => h.future.length > 0;
|
|
129
|
-
function annotationsOnPage(layer, page) {
|
|
130
|
-
return layer.annotations.filter((a) => a.page === page);
|
|
131
|
-
}
|
|
132
|
-
function pendingRedactions(layer) {
|
|
133
|
-
return layer.annotations.filter((a) => a.kind === "redaction" && a.status === "pending");
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// src/annotations/store.ts
|
|
137
|
-
var AnnotationStoreOfflineError = class extends Error {
|
|
138
|
-
constructor(message = "You are offline") {
|
|
139
|
-
super(message);
|
|
140
|
-
this.name = "AnnotationStoreOfflineError";
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
function createMemoryStore(now = () => (/* @__PURE__ */ new Date()).toISOString()) {
|
|
144
|
-
const layers = /* @__PURE__ */ new Map();
|
|
145
|
-
return {
|
|
146
|
-
async load(documentId) {
|
|
147
|
-
const raw = layers.get(documentId);
|
|
148
|
-
return raw ? parseLayer(JSON.parse(raw)) : emptyLayer(documentId, now());
|
|
149
|
-
},
|
|
150
|
-
async save(layer) {
|
|
151
|
-
layers.set(layer.documentId, JSON.stringify(parseLayer(layer)));
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
var STORAGE_PREFIX = "arbi:annotations:";
|
|
156
|
-
function createLocalStorageStore(storage = safeLocalStorage(), now = () => (/* @__PURE__ */ new Date()).toISOString()) {
|
|
157
|
-
return {
|
|
158
|
-
async load(documentId) {
|
|
159
|
-
try {
|
|
160
|
-
const raw = storage?.getItem(STORAGE_PREFIX + documentId);
|
|
161
|
-
if (raw) return parseLayer(JSON.parse(raw));
|
|
162
|
-
} catch {
|
|
163
|
-
}
|
|
164
|
-
return emptyLayer(documentId, now());
|
|
165
|
-
},
|
|
166
|
-
async save(layer) {
|
|
167
|
-
if (!storage) throw new Error("storage is not available");
|
|
168
|
-
storage.setItem(STORAGE_PREFIX + layer.documentId, JSON.stringify(parseLayer(layer)));
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
function safeLocalStorage() {
|
|
173
|
-
try {
|
|
174
|
-
return typeof localStorage === "undefined" ? void 0 : localStorage;
|
|
175
|
-
} catch {
|
|
176
|
-
return void 0;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// src/annotations/merge.ts
|
|
181
|
-
var time = (iso) => {
|
|
182
|
-
const t = Date.parse(iso);
|
|
183
|
-
return Number.isNaN(t) ? 0 : t;
|
|
184
|
-
};
|
|
185
|
-
function mergeReplies(a, b) {
|
|
186
|
-
const byId = /* @__PURE__ */ new Map();
|
|
187
|
-
for (const r of [...a, ...b]) if (!byId.has(r.id)) byId.set(r.id, r);
|
|
188
|
-
return [...byId.values()].sort((x, y) => time(x.createdAt) - time(y.createdAt));
|
|
189
|
-
}
|
|
190
|
-
function newer(mine, theirs) {
|
|
191
|
-
const winner = time(theirs.updatedAt) > time(mine.updatedAt) ? theirs : mine;
|
|
192
|
-
if (mine.kind === "comment" && theirs.kind === "comment" && winner.kind === "comment") {
|
|
193
|
-
const replies = mergeReplies(mine.replies, theirs.replies);
|
|
194
|
-
if (replies.length !== winner.replies.length) return { ...winner, replies };
|
|
195
|
-
}
|
|
196
|
-
return winner;
|
|
197
|
-
}
|
|
198
|
-
function mergeLayers({ base, mine, theirs, deleted }) {
|
|
199
|
-
const baseById = new Map((base?.annotations ?? []).map((a) => [a.id, a]));
|
|
200
|
-
const theirsById = new Map(theirs.annotations.map((a) => [a.id, a]));
|
|
201
|
-
const mineIds = new Set(mine.annotations.map((a) => a.id));
|
|
202
|
-
const out = [];
|
|
203
|
-
for (const m of mine.annotations) {
|
|
204
|
-
if (deleted?.has(m.id)) continue;
|
|
205
|
-
const t = theirsById.get(m.id);
|
|
206
|
-
if (t) {
|
|
207
|
-
out.push(newer(m, t));
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
const b = baseById.get(m.id);
|
|
211
|
-
if (b && time(m.updatedAt) <= time(b.updatedAt)) continue;
|
|
212
|
-
out.push(m);
|
|
213
|
-
}
|
|
214
|
-
for (const t of theirs.annotations) {
|
|
215
|
-
if (mineIds.has(t.id) || deleted?.has(t.id)) continue;
|
|
216
|
-
if (baseById.has(t.id)) continue;
|
|
217
|
-
out.push(t);
|
|
218
|
-
}
|
|
219
|
-
const updatedAt = time(theirs.updatedAt) > time(mine.updatedAt) ? theirs.updatedAt : mine.updatedAt;
|
|
220
|
-
return { ...mine, annotations: out, updatedAt };
|
|
221
|
-
}
|
|
222
|
-
function sameMarks(a, b) {
|
|
223
|
-
if (a.annotations.length !== b.annotations.length) return false;
|
|
224
|
-
const byId = new Map(a.annotations.map((m) => [m.id, m.updatedAt]));
|
|
225
|
-
return b.annotations.every(
|
|
226
|
-
(m) => byId.get(m.id) === m.updatedAt && (m.kind !== "comment" || a.annotations.find((x) => x.id === m.id).replies.length === m.replies.length)
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// src/annotations/redaction-log.ts
|
|
231
|
-
var REDACTION_LOG_COLUMNS = ["page", "reason", "status", "approved_by", "time"];
|
|
232
|
-
var STATUS = {
|
|
233
|
-
approved: "redacted (approved)",
|
|
234
|
-
pending: "redacted (not reviewed)",
|
|
235
|
-
rejected: "not redacted (rejected)"
|
|
236
|
-
};
|
|
237
|
-
var top = (a) => Math.min(...a.rects.map((r) => r.y));
|
|
238
|
-
var left = (a) => Math.min(...a.rects.map((r) => r.x));
|
|
239
|
-
function redactionLogRows(layer) {
|
|
240
|
-
return layer.annotations.filter((a) => a.kind === "redaction").sort((a, b) => a.page - b.page || top(a) - top(b) || left(a) - left(b)).map((a) => ({
|
|
241
|
-
page: a.page,
|
|
242
|
-
reason: a.reason,
|
|
243
|
-
status: STATUS[a.status],
|
|
244
|
-
approvedBy: a.status === "approved" ? a.reviewedBy ?? "" : "",
|
|
245
|
-
time: a.reviewedAt ?? a.createdAt
|
|
246
|
-
}));
|
|
247
|
-
}
|
|
248
|
-
var cell = (value) => {
|
|
249
|
-
const text = String(value);
|
|
250
|
-
return `"${(/^[=+\-@]/.test(text) ? `'${text}` : text).replace(/"/g, '""')}"`;
|
|
251
|
-
};
|
|
252
|
-
function redactionLogCsv(layer) {
|
|
253
|
-
const rows = redactionLogRows(layer).map(
|
|
254
|
-
(r) => [r.page, r.reason, r.status, r.approvedBy, r.time].map(cell).join(",")
|
|
255
|
-
);
|
|
256
|
-
return [REDACTION_LOG_COLUMNS.join(","), ...rows].join("\r\n") + "\r\n";
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// src/annotations/geometry.ts
|
|
260
|
-
var MIN_MARK_FRACTION = 4e-3;
|
|
261
|
-
function toNorm(r, page) {
|
|
262
|
-
if (!(page.width > 0) || !(page.height > 0)) throw new RangeError("page size must be positive");
|
|
263
|
-
const x1 = Math.min(r.x, r.x + r.width);
|
|
264
|
-
const y1 = Math.min(r.y, r.y + r.height);
|
|
265
|
-
const x2 = Math.max(r.x, r.x + r.width);
|
|
266
|
-
const y2 = Math.max(r.y, r.y + r.height);
|
|
267
|
-
const cx1 = Math.min(Math.max(x1, 0), page.width);
|
|
268
|
-
const cy1 = Math.min(Math.max(y1, 0), page.height);
|
|
269
|
-
const cx2 = Math.min(Math.max(x2, 0), page.width);
|
|
270
|
-
const cy2 = Math.min(Math.max(y2, 0), page.height);
|
|
271
|
-
return clampRect({
|
|
272
|
-
x: cx1 / page.width,
|
|
273
|
-
y: cy1 / page.height,
|
|
274
|
-
w: (cx2 - cx1) / page.width,
|
|
275
|
-
h: (cy2 - cy1) / page.height
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
function toPixels(r, page) {
|
|
279
|
-
return {
|
|
280
|
-
x: r.x * page.width,
|
|
281
|
-
y: r.y * page.height,
|
|
282
|
-
width: r.w * page.width,
|
|
283
|
-
height: r.h * page.height
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
function dragToNorm(a, b, page) {
|
|
287
|
-
return toNorm({ x: a.x, y: a.y, width: b.x - a.x, height: b.y - a.y }, page);
|
|
288
|
-
}
|
|
289
|
-
function isTooSmall(r) {
|
|
290
|
-
return r.w < MIN_MARK_FRACTION || r.h < MIN_MARK_FRACTION;
|
|
291
|
-
}
|
|
292
|
-
function containsPoint(r, x, y) {
|
|
293
|
-
return x >= r.x && x <= r.x + r.w && y >= r.y && y <= r.y + r.h;
|
|
294
|
-
}
|
|
295
|
-
var EPS = 1e-9;
|
|
296
|
-
function intersects(a, b) {
|
|
297
|
-
return a.x + EPS < b.x + b.w && b.x + EPS < a.x + a.w && a.y + EPS < b.y + b.h && b.y + EPS < a.y + a.h;
|
|
298
|
-
}
|
|
299
|
-
function mergeLineRects(input, gap = 2) {
|
|
300
|
-
const rects = input.filter((r) => r.width > 0 && r.height > 0).map((r) => ({ ...r })).sort((a, b) => a.y - b.y || a.x - b.x);
|
|
301
|
-
const lines = [];
|
|
302
|
-
for (const r of rects) {
|
|
303
|
-
const mid = r.y + r.height / 2;
|
|
304
|
-
const line = lines.find((l) => {
|
|
305
|
-
const ref = l[0];
|
|
306
|
-
return mid >= ref.y && mid <= ref.y + ref.height;
|
|
307
|
-
});
|
|
308
|
-
if (line) line.push(r);
|
|
309
|
-
else lines.push([r]);
|
|
310
|
-
}
|
|
311
|
-
const out = [];
|
|
312
|
-
for (const line of lines) {
|
|
313
|
-
line.sort((a, b) => a.x - b.x);
|
|
314
|
-
let cur = { ...line[0] };
|
|
315
|
-
for (const r of line.slice(1)) {
|
|
316
|
-
if (r.x <= cur.x + cur.width + gap) {
|
|
317
|
-
const right = Math.max(cur.x + cur.width, r.x + r.width);
|
|
318
|
-
const top2 = Math.min(cur.y, r.y);
|
|
319
|
-
const bottom = Math.max(cur.y + cur.height, r.y + r.height);
|
|
320
|
-
cur = { x: cur.x, y: top2, width: right - cur.x, height: bottom - top2 };
|
|
321
|
-
} else {
|
|
322
|
-
out.push(cur);
|
|
323
|
-
cur = { ...r };
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
out.push(cur);
|
|
327
|
-
}
|
|
328
|
-
return out.sort((a, b) => a.y - b.y || a.x - b.x);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// src/annotations/controller.ts
|
|
332
|
-
var DRAW_TOOLS = ["box", "comment", "stamp", "redact-area"];
|
|
333
|
-
var TEXT_TOOLS = ["highlight", "redact-text"];
|
|
334
|
-
var DEFAULT_SETTINGS = {
|
|
335
|
-
colors: { highlight: "#ffe066", box: "#e03131", stamp: "#c92a2a" },
|
|
336
|
-
stampLabel: "CONFIDENTIAL",
|
|
337
|
-
redactionReason: "Privileged",
|
|
338
|
-
strokeWidth: 2
|
|
339
|
-
};
|
|
340
|
-
var HIGHLIGHT_COLORS = ["#ffe066", "#8ce99a", "#74c0fc", "#ffa8a8", "#eebefa"];
|
|
341
|
-
var MARK_COLORS = ["#e03131", "#1c7ed6", "#2f9e44", "#f08c00", "#000000"];
|
|
342
|
-
var STAMP_PRESETS = ["CONFIDENTIAL", "DRAFT", "APPROVED", "FILED", "PRIVILEGED", "COPY"];
|
|
343
|
-
var REDACTION_REASONS = [
|
|
344
|
-
"Privileged",
|
|
345
|
-
"Confidential",
|
|
346
|
-
"Personal data",
|
|
347
|
-
"Commercial",
|
|
348
|
-
"Irrelevant"
|
|
349
|
-
];
|
|
350
|
-
function layerStatusText(controller) {
|
|
351
|
-
if (controller.status === "error") return "Could not be loaded";
|
|
352
|
-
if (controller.readOnly) return "View only";
|
|
353
|
-
if (controller.offline) {
|
|
354
|
-
return controller.dirty ? "Offline \u2014 will save when back online" : "Offline";
|
|
355
|
-
}
|
|
356
|
-
if (controller.error) return "Not saved \u2014 retrying";
|
|
357
|
-
if (controller.saving) return "Saving\u2026";
|
|
358
|
-
if (controller.dirty) return "Unsaved changes";
|
|
359
|
-
return "Saved";
|
|
360
|
-
}
|
|
361
|
-
var AUTOSAVE_MS = 600;
|
|
362
|
-
var RETRY_MS = 1e4;
|
|
363
|
-
var defaultNow = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
364
|
-
var defaultId = () => globalThis.crypto.randomUUID();
|
|
365
|
-
function rebaseHistory(history, sent, remote) {
|
|
366
|
-
const onto = (layer) => layer === sent ? remote : mergeLayers({ base: sent, mine: layer, theirs: remote });
|
|
367
|
-
return {
|
|
368
|
-
present: onto(history.present),
|
|
369
|
-
past: history.past.map(onto),
|
|
370
|
-
future: history.future.map(onto)
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
function useAnnotationLayer({
|
|
374
|
-
documentId,
|
|
375
|
-
store,
|
|
376
|
-
author,
|
|
377
|
-
autosaveMs = AUTOSAVE_MS,
|
|
378
|
-
readOnly: readOnlyProp = false,
|
|
379
|
-
online = true,
|
|
380
|
-
pullMs = 0,
|
|
381
|
-
now = defaultNow,
|
|
382
|
-
makeId = defaultId
|
|
383
|
-
}) {
|
|
384
|
-
const [history, setHistory] = useState(
|
|
385
|
-
() => createHistory(emptyLayer(documentId, now()))
|
|
386
|
-
);
|
|
387
|
-
const [savedLayer, setSavedLayer] = useState(null);
|
|
388
|
-
const [status, setStatus] = useState("loading");
|
|
389
|
-
const [error, setError] = useState(null);
|
|
390
|
-
const [saving, setSaving] = useState(false);
|
|
391
|
-
const [offlineFailure, setOfflineFailure] = useState(false);
|
|
392
|
-
const [storeReadOnly, setStoreReadOnly] = useState(false);
|
|
393
|
-
const [tool, setToolState] = useState("select");
|
|
394
|
-
const [settings, setSettingsState] = useState(DEFAULT_SETTINGS);
|
|
395
|
-
const [selectedId, setSelectedId] = useState(null);
|
|
396
|
-
const readOnly = readOnlyProp || storeReadOnly;
|
|
397
|
-
const historyRef = useRef(history);
|
|
398
|
-
const savedRef = useRef(null);
|
|
399
|
-
const timerRef = useRef(void 0);
|
|
400
|
-
const retryRef = useRef(void 0);
|
|
401
|
-
const savingRef = useRef(false);
|
|
402
|
-
const docRef = useRef(documentId);
|
|
403
|
-
const storeRef = useRef(store);
|
|
404
|
-
storeRef.current = store;
|
|
405
|
-
const nowRef = useRef(now);
|
|
406
|
-
nowRef.current = now;
|
|
407
|
-
const idRef = useRef(makeId);
|
|
408
|
-
idRef.current = makeId;
|
|
409
|
-
const readOnlyRef = useRef(readOnly);
|
|
410
|
-
readOnlyRef.current = readOnly;
|
|
411
|
-
const onlineRef = useRef(online);
|
|
412
|
-
onlineRef.current = online;
|
|
413
|
-
const autosaveMsRef = useRef(autosaveMs);
|
|
414
|
-
autosaveMsRef.current = autosaveMs;
|
|
415
|
-
const commit = useCallback((next) => {
|
|
416
|
-
historyRef.current = next;
|
|
417
|
-
setHistory(next);
|
|
418
|
-
}, []);
|
|
419
|
-
const adoptRemote = useCallback(
|
|
420
|
-
(sent, remote) => {
|
|
421
|
-
commit(rebaseHistory(historyRef.current, sent, remote));
|
|
422
|
-
savedRef.current = remote;
|
|
423
|
-
setSavedLayer(remote);
|
|
424
|
-
},
|
|
425
|
-
[commit]
|
|
426
|
-
);
|
|
427
|
-
useEffect(() => {
|
|
428
|
-
docRef.current = documentId;
|
|
429
|
-
let cancelled = false;
|
|
430
|
-
setStatus("loading");
|
|
431
|
-
setError(null);
|
|
432
|
-
setSelectedId(null);
|
|
433
|
-
setSavedLayer(null);
|
|
434
|
-
setStoreReadOnly(false);
|
|
435
|
-
savedRef.current = null;
|
|
436
|
-
commit(createHistory(emptyLayer(documentId, nowRef.current())));
|
|
437
|
-
storeRef.current.load(documentId).then((layer) => {
|
|
438
|
-
if (cancelled) return;
|
|
439
|
-
savedRef.current = layer;
|
|
440
|
-
setSavedLayer(layer);
|
|
441
|
-
setStoreReadOnly(storeRef.current.canEdit?.(documentId) === false);
|
|
442
|
-
commit(createHistory(layer));
|
|
443
|
-
setStatus("ready");
|
|
444
|
-
}).catch((e) => {
|
|
445
|
-
if (cancelled) return;
|
|
446
|
-
setError(e instanceof Error ? e.message : "The annotations could not be loaded");
|
|
447
|
-
setStatus("error");
|
|
448
|
-
});
|
|
449
|
-
return () => {
|
|
450
|
-
cancelled = true;
|
|
451
|
-
clearTimeout(timerRef.current);
|
|
452
|
-
clearTimeout(retryRef.current);
|
|
453
|
-
const layer = historyRef.current.present;
|
|
454
|
-
if (savedRef.current !== null && layer !== savedRef.current && layer.documentId === documentId && !readOnlyRef.current) {
|
|
455
|
-
storeRef.current.save(layer).catch((e) => console.error("Annotations could not be saved", e));
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
}, [documentId, commit]);
|
|
459
|
-
const save = useCallback(async () => {
|
|
460
|
-
clearTimeout(timerRef.current);
|
|
461
|
-
clearTimeout(retryRef.current);
|
|
462
|
-
const layer = historyRef.current.present;
|
|
463
|
-
if (layer === savedRef.current || savedRef.current === null) return;
|
|
464
|
-
if (readOnlyRef.current || savingRef.current) return;
|
|
465
|
-
if (!onlineRef.current) return;
|
|
466
|
-
savingRef.current = true;
|
|
467
|
-
setSaving(true);
|
|
468
|
-
let failed = false;
|
|
469
|
-
try {
|
|
470
|
-
const stored = await storeRef.current.save(layer);
|
|
471
|
-
if (layer.documentId === docRef.current) {
|
|
472
|
-
setError(null);
|
|
473
|
-
setOfflineFailure(false);
|
|
474
|
-
if (stored && stored !== layer) {
|
|
475
|
-
adoptRemote(layer, stored);
|
|
476
|
-
} else {
|
|
477
|
-
savedRef.current = layer;
|
|
478
|
-
setSavedLayer(layer);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
} catch (e) {
|
|
482
|
-
failed = true;
|
|
483
|
-
if (e instanceof AnnotationStoreOfflineError) {
|
|
484
|
-
setOfflineFailure(true);
|
|
485
|
-
} else {
|
|
486
|
-
setError(e instanceof Error ? e.message : "The annotations could not be saved");
|
|
487
|
-
}
|
|
488
|
-
retryRef.current = setTimeout(() => void saveRef.current(), RETRY_MS);
|
|
489
|
-
} finally {
|
|
490
|
-
savingRef.current = false;
|
|
491
|
-
setSaving(false);
|
|
492
|
-
if (!failed && historyRef.current.present !== savedRef.current) {
|
|
493
|
-
timerRef.current = setTimeout(() => void saveRef.current(), autosaveMsRef.current);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}, [adoptRemote]);
|
|
497
|
-
const saveRef = useRef(save);
|
|
498
|
-
saveRef.current = save;
|
|
499
|
-
const present = history.present;
|
|
500
|
-
const dirty = status === "ready" && present !== savedLayer;
|
|
501
|
-
useEffect(() => {
|
|
502
|
-
if (!dirty || !online || readOnly) return;
|
|
503
|
-
timerRef.current = setTimeout(() => void save(), autosaveMs);
|
|
504
|
-
return () => clearTimeout(timerRef.current);
|
|
505
|
-
}, [dirty, present, autosaveMs, save, online, readOnly]);
|
|
506
|
-
useEffect(() => {
|
|
507
|
-
if (online) setOfflineFailure(false);
|
|
508
|
-
if (online && savedRef.current !== null && historyRef.current.present !== savedRef.current) {
|
|
509
|
-
void save();
|
|
510
|
-
}
|
|
511
|
-
}, [online, save]);
|
|
512
|
-
const pull = useCallback(async () => {
|
|
513
|
-
const s = storeRef.current;
|
|
514
|
-
const base = savedRef.current;
|
|
515
|
-
if (!s.pull || !base || savingRef.current || !onlineRef.current) return;
|
|
516
|
-
if (historyRef.current.present !== base) return;
|
|
517
|
-
try {
|
|
518
|
-
const remote = await s.pull(docRef.current);
|
|
519
|
-
if (!remote || remote.documentId !== docRef.current || savedRef.current !== base) return;
|
|
520
|
-
adoptRemote(base, remote);
|
|
521
|
-
} catch {
|
|
522
|
-
}
|
|
523
|
-
}, [adoptRemote]);
|
|
524
|
-
useEffect(() => {
|
|
525
|
-
if (!pullMs || status !== "ready") return;
|
|
526
|
-
const timer = setInterval(() => void pull(), pullMs);
|
|
527
|
-
const onFocus = () => void pull();
|
|
528
|
-
window.addEventListener("focus", onFocus);
|
|
529
|
-
return () => {
|
|
530
|
-
clearInterval(timer);
|
|
531
|
-
window.removeEventListener("focus", onFocus);
|
|
532
|
-
};
|
|
533
|
-
}, [pullMs, status, pull]);
|
|
534
|
-
useEffect(() => {
|
|
535
|
-
const flush = () => void save();
|
|
536
|
-
const onVisibility = () => {
|
|
537
|
-
if (document.visibilityState === "hidden") flush();
|
|
538
|
-
};
|
|
539
|
-
window.addEventListener("pagehide", flush);
|
|
540
|
-
document.addEventListener("visibilitychange", onVisibility);
|
|
541
|
-
return () => {
|
|
542
|
-
window.removeEventListener("pagehide", flush);
|
|
543
|
-
document.removeEventListener("visibilitychange", onVisibility);
|
|
544
|
-
};
|
|
545
|
-
}, [save]);
|
|
546
|
-
const dispatch = useCallback(
|
|
547
|
-
(action) => {
|
|
548
|
-
if (readOnlyRef.current) return false;
|
|
549
|
-
try {
|
|
550
|
-
commit(applyAction(historyRef.current, action));
|
|
551
|
-
setError(null);
|
|
552
|
-
return true;
|
|
553
|
-
} catch (e) {
|
|
554
|
-
setError(e instanceof Error ? e.message : "The change was rejected");
|
|
555
|
-
return false;
|
|
556
|
-
}
|
|
557
|
-
},
|
|
558
|
-
[commit]
|
|
559
|
-
);
|
|
560
|
-
const stamp = useCallback(
|
|
561
|
-
(mark) => {
|
|
562
|
-
const t = nowRef.current();
|
|
563
|
-
return { ...mark, id: idRef.current(), author, createdAt: t, updatedAt: t };
|
|
564
|
-
},
|
|
565
|
-
[author]
|
|
566
|
-
);
|
|
567
|
-
const offline = !online || offlineFailure;
|
|
568
|
-
const controller = useMemo(() => {
|
|
569
|
-
const exists = (id) => id !== null && present.annotations.some((a) => a.id === id) ? id : null;
|
|
570
|
-
return {
|
|
571
|
-
layer: present,
|
|
572
|
-
status,
|
|
573
|
-
error,
|
|
574
|
-
saving,
|
|
575
|
-
dirty,
|
|
576
|
-
offline,
|
|
577
|
-
readOnly,
|
|
578
|
-
author,
|
|
579
|
-
tool: readOnly ? "select" : tool,
|
|
580
|
-
setTool: (next) => {
|
|
581
|
-
if (readOnly && next !== "select") return;
|
|
582
|
-
setToolState(next);
|
|
583
|
-
if (next !== "select") setSelectedId(null);
|
|
584
|
-
},
|
|
585
|
-
settings,
|
|
586
|
-
setSettings: (patch) => setSettingsState((s) => ({ ...s, ...patch, colors: { ...s.colors, ...patch.colors } })),
|
|
587
|
-
selectedId: exists(selectedId),
|
|
588
|
-
select: setSelectedId,
|
|
589
|
-
add: (mark) => {
|
|
590
|
-
const annotation = stamp(mark);
|
|
591
|
-
return dispatch({ type: "add", annotation }) ? annotation.id : null;
|
|
592
|
-
},
|
|
593
|
-
addMany: (marks) => {
|
|
594
|
-
const annotations = marks.map(stamp);
|
|
595
|
-
return dispatch({ type: "addMany", annotations }) ? annotations.map((a) => a.id) : [];
|
|
596
|
-
},
|
|
597
|
-
update: (id, patch) => void dispatch({ type: "update", id, patch, now: nowRef.current() }),
|
|
598
|
-
remove: (id) => void dispatch({ type: "remove", id, now: nowRef.current() }),
|
|
599
|
-
setRedactionStatus: (ids, next) => void dispatch({
|
|
600
|
-
type: "setRedactionStatus",
|
|
601
|
-
ids,
|
|
602
|
-
status: next,
|
|
603
|
-
now: nowRef.current(),
|
|
604
|
-
by: author
|
|
605
|
-
}),
|
|
606
|
-
reply: (id, body) => {
|
|
607
|
-
const t = nowRef.current();
|
|
608
|
-
void dispatch({
|
|
609
|
-
type: "reply",
|
|
610
|
-
id,
|
|
611
|
-
reply: { id: idRef.current(), author, createdAt: t, body },
|
|
612
|
-
now: t
|
|
613
|
-
});
|
|
614
|
-
},
|
|
615
|
-
resolve: (id, resolved) => void dispatch({ type: "resolve", id, resolved, now: nowRef.current() }),
|
|
616
|
-
undo: () => {
|
|
617
|
-
if (!readOnly) commit(undo(historyRef.current));
|
|
618
|
-
},
|
|
619
|
-
redo: () => {
|
|
620
|
-
if (!readOnly) commit(redo(historyRef.current));
|
|
621
|
-
},
|
|
622
|
-
canUndo: !readOnly && canUndo(history),
|
|
623
|
-
canRedo: !readOnly && canRedo(history),
|
|
624
|
-
flush: save
|
|
625
|
-
};
|
|
626
|
-
}, [
|
|
627
|
-
present,
|
|
628
|
-
history,
|
|
629
|
-
status,
|
|
630
|
-
error,
|
|
631
|
-
saving,
|
|
632
|
-
dirty,
|
|
633
|
-
offline,
|
|
634
|
-
readOnly,
|
|
635
|
-
author,
|
|
636
|
-
tool,
|
|
637
|
-
settings,
|
|
638
|
-
selectedId,
|
|
639
|
-
stamp,
|
|
640
|
-
dispatch,
|
|
641
|
-
commit,
|
|
642
|
-
save
|
|
643
|
-
]);
|
|
644
|
-
return controller;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
// src/annotations/selection-marks.ts
|
|
648
|
-
var MIN_RECT_PX = 1;
|
|
649
|
-
function selectionToPageMarks(pages) {
|
|
650
|
-
const out = [];
|
|
651
|
-
for (const p of pages) {
|
|
652
|
-
if (!(p.box.width > 0) || !(p.box.height > 0)) continue;
|
|
653
|
-
const local = p.rects.filter((r) => r.width >= MIN_RECT_PX && r.height >= MIN_RECT_PX).map((r) => ({ x: r.x - p.box.x, y: r.y - p.box.y, width: r.width, height: r.height })).filter(
|
|
654
|
-
(r) => r.x + r.width > 0 && r.y + r.height > 0 && r.x < p.box.width && r.y < p.box.height
|
|
655
|
-
);
|
|
656
|
-
const lines = mergeLineRects(local);
|
|
657
|
-
if (lines.length === 0) continue;
|
|
658
|
-
out.push({
|
|
659
|
-
page: p.page,
|
|
660
|
-
rects: lines.map((r) => toNorm(r, { width: p.box.width, height: p.box.height })),
|
|
661
|
-
text: p.text.replace(/\s+/g, " ").trim()
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
return out;
|
|
665
|
-
}
|
|
666
|
-
var PAGE_ATTRIBUTE = "data-annotation-page";
|
|
667
|
-
var ownerDocument = (node) => node.ownerDocument ?? document;
|
|
668
|
-
var toPixelRect = (r) => ({
|
|
669
|
-
x: r.left,
|
|
670
|
-
y: r.top,
|
|
671
|
-
width: r.width,
|
|
672
|
-
height: r.height
|
|
673
|
-
});
|
|
674
|
-
function clipRange(range, container) {
|
|
675
|
-
if (!range.intersectsNode(container)) return null;
|
|
676
|
-
const bounds = ownerDocument(container).createRange();
|
|
677
|
-
bounds.selectNodeContents(container);
|
|
678
|
-
const clipped = range.cloneRange();
|
|
679
|
-
if (clipped.compareBoundaryPoints(Range.START_TO_START, bounds) < 0) {
|
|
680
|
-
clipped.setStart(bounds.startContainer, bounds.startOffset);
|
|
681
|
-
}
|
|
682
|
-
if (clipped.compareBoundaryPoints(Range.END_TO_END, bounds) > 0) {
|
|
683
|
-
clipped.setEnd(bounds.endContainer, bounds.endOffset);
|
|
684
|
-
}
|
|
685
|
-
return clipped;
|
|
686
|
-
}
|
|
687
|
-
function textClientRects(range, container) {
|
|
688
|
-
const doc = ownerDocument(container);
|
|
689
|
-
const walker = doc.createTreeWalker(container, NodeFilter.SHOW_TEXT);
|
|
690
|
-
const rects = [];
|
|
691
|
-
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
692
|
-
if (!node.textContent?.trim() || !range.intersectsNode(node)) continue;
|
|
693
|
-
const part = doc.createRange();
|
|
694
|
-
part.selectNodeContents(node);
|
|
695
|
-
if (node === range.startContainer) part.setStart(node, range.startOffset);
|
|
696
|
-
if (node === range.endContainer) part.setEnd(node, range.endOffset);
|
|
697
|
-
rects.push(...Array.from(part.getClientRects()));
|
|
698
|
-
}
|
|
699
|
-
return rects;
|
|
700
|
-
}
|
|
701
|
-
function firstTextAt(container, offset) {
|
|
702
|
-
if (container.nodeType === Node.TEXT_NODE) return { node: container, offset };
|
|
703
|
-
const child = container.childNodes[offset];
|
|
704
|
-
if (!child) return null;
|
|
705
|
-
if (child.nodeType === Node.TEXT_NODE) return { node: child, offset: 0 };
|
|
706
|
-
const first = ownerDocument(child).createTreeWalker(child, NodeFilter.SHOW_TEXT).nextNode();
|
|
707
|
-
return first ? { node: first, offset: 0 } : null;
|
|
708
|
-
}
|
|
709
|
-
function extendFocusToPointer(selection, point) {
|
|
710
|
-
if (selection.rangeCount === 0 || selection.isCollapsed) return;
|
|
711
|
-
const range = selection.getRangeAt(0);
|
|
712
|
-
if (selection.focusNode !== range.endContainer || selection.focusOffset !== range.endOffset)
|
|
713
|
-
return;
|
|
714
|
-
const start = firstTextAt(range.endContainer, range.endOffset);
|
|
715
|
-
if (!start) return;
|
|
716
|
-
const doc = ownerDocument(start.node);
|
|
717
|
-
const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_TEXT);
|
|
718
|
-
walker.currentNode = start.node;
|
|
719
|
-
const glyph = doc.createRange();
|
|
720
|
-
let end = null;
|
|
721
|
-
let node = start.node;
|
|
722
|
-
let offset = start.offset;
|
|
723
|
-
let passed = false;
|
|
724
|
-
while (node && !passed) {
|
|
725
|
-
const text = node.textContent ?? "";
|
|
726
|
-
for (let i = offset; i < text.length && !passed; i++) {
|
|
727
|
-
glyph.setStart(node, i);
|
|
728
|
-
glyph.setEnd(node, i + 1);
|
|
729
|
-
const r = glyph.getBoundingClientRect();
|
|
730
|
-
if (r.height === 0) continue;
|
|
731
|
-
const mid = r.top + r.height / 2;
|
|
732
|
-
if (mid > point.y + r.height / 2) passed = true;
|
|
733
|
-
else if (Math.abs(mid - point.y) > r.height / 2) continue;
|
|
734
|
-
else if (r.right > point.x + 0.5) passed = true;
|
|
735
|
-
else end = { node, offset: i + 1 };
|
|
736
|
-
}
|
|
737
|
-
node = walker.nextNode();
|
|
738
|
-
offset = 0;
|
|
739
|
-
}
|
|
740
|
-
if (end) selection.extend(end.node, end.offset);
|
|
741
|
-
}
|
|
742
|
-
function readSelection(selection, root = document) {
|
|
743
|
-
if (selection.rangeCount === 0 || selection.isCollapsed) return [];
|
|
744
|
-
const range = selection.getRangeAt(0);
|
|
745
|
-
const pages = [];
|
|
746
|
-
root.querySelectorAll(`[${PAGE_ATTRIBUTE}]`).forEach((overlay) => {
|
|
747
|
-
const page = Number(overlay.getAttribute(PAGE_ATTRIBUTE));
|
|
748
|
-
const container = overlay.parentElement;
|
|
749
|
-
if (!container || !Number.isInteger(page)) return;
|
|
750
|
-
const clipped = clipRange(range, container);
|
|
751
|
-
if (!clipped) return;
|
|
752
|
-
pages.push({
|
|
753
|
-
page,
|
|
754
|
-
box: toPixelRect(overlay.getBoundingClientRect()),
|
|
755
|
-
rects: textClientRects(clipped, container).map(toPixelRect),
|
|
756
|
-
text: clipped.toString()
|
|
757
|
-
});
|
|
758
|
-
});
|
|
759
|
-
return pages;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
// src/annotations/useTextSelectionMarks.ts
|
|
763
|
-
var PAGE_SELECTOR = "[data-page-number]";
|
|
764
|
-
var TOUCH_SETTLE_MS = 700;
|
|
765
|
-
var MOUSE_SETTLE_MS = 80;
|
|
766
|
-
var STABLE_CHECKS = 3;
|
|
767
|
-
var MAX_SETTLE_ROUNDS = 12;
|
|
768
|
-
function useTextSelectionMarks(controller) {
|
|
769
|
-
const latest = useRef(controller);
|
|
770
|
-
latest.current = controller;
|
|
771
|
-
const pagesDoc = usePortalContainer()?.ownerDocument ?? document;
|
|
772
|
-
useEffect(() => {
|
|
773
|
-
let startedOnPage = false;
|
|
774
|
-
let touchSelecting = false;
|
|
775
|
-
let settleTimer;
|
|
776
|
-
const settleTimers = /* @__PURE__ */ new Set();
|
|
777
|
-
const markSelection = () => {
|
|
778
|
-
const c = latest.current;
|
|
779
|
-
const selection = pagesDoc.getSelection();
|
|
780
|
-
if (!selection || !TEXT_TOOLS.includes(c.tool)) return false;
|
|
781
|
-
const pages = selectionToPageMarks(readSelection(selection, pagesDoc));
|
|
782
|
-
if (pages.length === 0) return false;
|
|
783
|
-
const marks = pages.map(
|
|
784
|
-
(p) => c.tool === "highlight" ? {
|
|
785
|
-
kind: "highlight",
|
|
786
|
-
page: p.page,
|
|
787
|
-
rects: p.rects,
|
|
788
|
-
color: c.settings.colors.highlight,
|
|
789
|
-
text: p.text
|
|
790
|
-
} : {
|
|
791
|
-
kind: "redaction",
|
|
792
|
-
page: p.page,
|
|
793
|
-
rects: p.rects,
|
|
794
|
-
reason: c.settings.redactionReason,
|
|
795
|
-
text: p.text,
|
|
796
|
-
status: "pending"
|
|
797
|
-
}
|
|
798
|
-
);
|
|
799
|
-
if (c.addMany(marks).length === 0) return false;
|
|
800
|
-
selection.removeAllRanges();
|
|
801
|
-
return true;
|
|
802
|
-
};
|
|
803
|
-
const onDown = (e) => {
|
|
804
|
-
startedOnPage = e.target instanceof Element && e.target.closest(PAGE_SELECTOR) !== null;
|
|
805
|
-
touchSelecting = startedOnPage && e.pointerType === "touch";
|
|
806
|
-
};
|
|
807
|
-
const onUp = (e) => {
|
|
808
|
-
if (!startedOnPage || !TEXT_TOOLS.includes(latest.current.tool)) return;
|
|
809
|
-
startedOnPage = false;
|
|
810
|
-
const selection = pagesDoc.getSelection();
|
|
811
|
-
if (selection && e.pointerType === "mouse") {
|
|
812
|
-
extendFocusToPointer(selection, { x: e.clientX, y: e.clientY });
|
|
813
|
-
}
|
|
814
|
-
let last = selection?.toString() ?? "";
|
|
815
|
-
let stable = 0;
|
|
816
|
-
let rounds = 0;
|
|
817
|
-
const check = () => {
|
|
818
|
-
const now = pagesDoc.getSelection()?.toString() ?? "";
|
|
819
|
-
if (now === last) stable++;
|
|
820
|
-
else {
|
|
821
|
-
last = now;
|
|
822
|
-
stable = 0;
|
|
823
|
-
}
|
|
824
|
-
if (stable >= STABLE_CHECKS || ++rounds >= MAX_SETTLE_ROUNDS) {
|
|
825
|
-
if (markSelection()) touchSelecting = false;
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
|
-
settleTimers.add(setTimeout(check, MOUSE_SETTLE_MS));
|
|
829
|
-
};
|
|
830
|
-
settleTimers.add(setTimeout(check, MOUSE_SETTLE_MS));
|
|
831
|
-
};
|
|
832
|
-
const onSelectionChange = () => {
|
|
833
|
-
if (!touchSelecting || !TEXT_TOOLS.includes(latest.current.tool)) return;
|
|
834
|
-
clearTimeout(settleTimer);
|
|
835
|
-
settleTimer = setTimeout(() => {
|
|
836
|
-
if (markSelection()) touchSelecting = false;
|
|
837
|
-
}, TOUCH_SETTLE_MS);
|
|
838
|
-
};
|
|
839
|
-
pagesDoc.addEventListener("pointerdown", onDown, true);
|
|
840
|
-
pagesDoc.addEventListener("pointerup", onUp, true);
|
|
841
|
-
pagesDoc.addEventListener("selectionchange", onSelectionChange);
|
|
842
|
-
return () => {
|
|
843
|
-
clearTimeout(settleTimer);
|
|
844
|
-
settleTimers.forEach(clearTimeout);
|
|
845
|
-
pagesDoc.removeEventListener("pointerdown", onDown, true);
|
|
846
|
-
pagesDoc.removeEventListener("pointerup", onUp, true);
|
|
847
|
-
pagesDoc.removeEventListener("selectionchange", onSelectionChange);
|
|
848
|
-
};
|
|
849
|
-
}, [pagesDoc]);
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
// src/annotations/overlay-geometry.ts
|
|
853
|
-
var MIN_MARK = 0.01;
|
|
854
|
-
function singleRect(a) {
|
|
855
|
-
if (a.kind === "box" || a.kind === "stamp" || a.kind === "comment") return a.rect;
|
|
856
|
-
if (a.kind === "redaction" && a.rects.length === 1) return a.rects[0];
|
|
857
|
-
return null;
|
|
858
|
-
}
|
|
859
|
-
var patchForRect = (a, rect) => a.kind === "redaction" ? { rects: [rect] } : { rect };
|
|
860
|
-
function dragRect(origin, mode, dx, dy) {
|
|
861
|
-
if (mode === "move") {
|
|
862
|
-
return {
|
|
863
|
-
...origin,
|
|
864
|
-
x: Math.min(Math.max(origin.x + dx, 0), 1 - origin.w),
|
|
865
|
-
y: Math.min(Math.max(origin.y + dy, 0), 1 - origin.h)
|
|
866
|
-
};
|
|
867
|
-
}
|
|
868
|
-
let left2 = origin.x;
|
|
869
|
-
let right = origin.x + origin.w;
|
|
870
|
-
let top2 = origin.y;
|
|
871
|
-
let bottom = origin.y + origin.h;
|
|
872
|
-
if (mode.includes("w")) left2 += dx;
|
|
873
|
-
else right += dx;
|
|
874
|
-
if (mode.includes("n")) top2 += dy;
|
|
875
|
-
else bottom += dy;
|
|
876
|
-
const x1 = Math.min(Math.max(Math.min(left2, right), 0), 1);
|
|
877
|
-
const x2 = Math.min(Math.max(Math.max(left2, right), 0), 1);
|
|
878
|
-
const y1 = Math.min(Math.max(Math.min(top2, bottom), 0), 1);
|
|
879
|
-
const y2 = Math.min(Math.max(Math.max(top2, bottom), 0), 1);
|
|
880
|
-
return clampRect({
|
|
881
|
-
x: x1,
|
|
882
|
-
y: y1,
|
|
883
|
-
w: Math.max(x2 - x1, MIN_MARK),
|
|
884
|
-
h: Math.max(y2 - y1, MIN_MARK)
|
|
885
|
-
});
|
|
886
|
-
}
|
|
887
|
-
var FALLBACK_PAGE_WIDTH_PT = 612;
|
|
888
|
-
var COMMENT_ICON_PX = 24;
|
|
889
|
-
var DEFAULT_STAMP = { w: 0.32, h: 0.06 };
|
|
890
|
-
var MOVE_THRESHOLD_PX = 3;
|
|
891
|
-
function useElementSize(ref) {
|
|
892
|
-
const [size, setSize] = useState({ width: 0, height: 0 });
|
|
893
|
-
useLayoutEffect(() => {
|
|
894
|
-
const el = ref.current;
|
|
895
|
-
if (!el) return;
|
|
896
|
-
const measure = () => {
|
|
897
|
-
const r = el.getBoundingClientRect();
|
|
898
|
-
setSize(
|
|
899
|
-
(prev) => prev.width === r.width && prev.height === r.height ? prev : { width: r.width, height: r.height }
|
|
900
|
-
);
|
|
901
|
-
};
|
|
902
|
-
measure();
|
|
903
|
-
const observer = new ResizeObserver(measure);
|
|
904
|
-
observer.observe(el);
|
|
905
|
-
return () => observer.disconnect();
|
|
906
|
-
}, [ref]);
|
|
907
|
-
return size;
|
|
908
|
-
}
|
|
909
|
-
function useHasTextLayer(ref) {
|
|
910
|
-
const [hasText, setHasText] = useState(false);
|
|
911
|
-
useLayoutEffect(() => {
|
|
912
|
-
const container = ref.current?.parentElement;
|
|
913
|
-
if (!container) return;
|
|
914
|
-
const check = () => setHasText(container.querySelector(".textLayer span") !== null);
|
|
915
|
-
check();
|
|
916
|
-
const observer = new MutationObserver(check);
|
|
917
|
-
observer.observe(container, { childList: true, subtree: true });
|
|
918
|
-
return () => observer.disconnect();
|
|
919
|
-
}, [ref]);
|
|
920
|
-
return hasText;
|
|
921
|
-
}
|
|
922
|
-
var pct = (n) => `${n * 100}%`;
|
|
923
|
-
var rectStyle = (r) => ({
|
|
924
|
-
left: pct(r.x),
|
|
925
|
-
top: pct(r.y),
|
|
926
|
-
width: pct(r.w),
|
|
927
|
-
height: pct(r.h)
|
|
928
|
-
});
|
|
929
|
-
function AnnotationPageOverlay({
|
|
930
|
-
controller,
|
|
931
|
-
pageNumber,
|
|
932
|
-
pageWidthPt
|
|
933
|
-
}) {
|
|
934
|
-
const rootRef = useRef(null);
|
|
935
|
-
const size = useElementSize(rootRef);
|
|
936
|
-
const pxPerPt = size.width / (pageWidthPt ?? FALLBACK_PAGE_WIDTH_PT);
|
|
937
|
-
const { tool, selectedId, settings } = controller;
|
|
938
|
-
const [draft, setDraft] = useState(null);
|
|
939
|
-
const [drag, setDrag] = useState(null);
|
|
940
|
-
const [openComment, setOpenComment] = useState(null);
|
|
941
|
-
const marks = controller.layer.annotations.filter((a) => a.page === pageNumber);
|
|
942
|
-
const hasText = useHasTextLayer(rootRef);
|
|
943
|
-
const readOnly = controller.readOnly;
|
|
944
|
-
const drawing = !readOnly && (DRAW_TOOLS.includes(tool) || TEXT_TOOLS.includes(tool) && !hasText);
|
|
945
|
-
useEffect(() => {
|
|
946
|
-
if (openComment && selectedId !== openComment) setOpenComment(null);
|
|
947
|
-
}, [selectedId, openComment]);
|
|
948
|
-
const local = useCallback((e) => {
|
|
949
|
-
const r = rootRef.current.getBoundingClientRect();
|
|
950
|
-
return { x: e.clientX - r.left, y: e.clientY - r.top };
|
|
951
|
-
}, []);
|
|
952
|
-
const pageSize = () => {
|
|
953
|
-
const r = rootRef.current.getBoundingClientRect();
|
|
954
|
-
return { width: r.width, height: r.height };
|
|
955
|
-
};
|
|
956
|
-
const finishDraft = useCallback(
|
|
957
|
-
(a, b) => {
|
|
958
|
-
const page = pageSize();
|
|
959
|
-
const rect = dragToNorm(a, b, page);
|
|
960
|
-
if (tool === "box") {
|
|
961
|
-
if (isTooSmall(rect)) return;
|
|
962
|
-
controller.add({
|
|
963
|
-
kind: "box",
|
|
964
|
-
page: pageNumber,
|
|
965
|
-
rect,
|
|
966
|
-
color: settings.colors.box,
|
|
967
|
-
strokeWidth: settings.strokeWidth
|
|
968
|
-
});
|
|
969
|
-
} else if (tool === "highlight") {
|
|
970
|
-
if (isTooSmall(rect)) return;
|
|
971
|
-
controller.add({
|
|
972
|
-
kind: "highlight",
|
|
973
|
-
page: pageNumber,
|
|
974
|
-
rects: [rect],
|
|
975
|
-
color: settings.colors.highlight
|
|
976
|
-
});
|
|
977
|
-
} else if (tool === "redact-area" || tool === "redact-text") {
|
|
978
|
-
if (isTooSmall(rect)) return;
|
|
979
|
-
controller.add({
|
|
980
|
-
kind: "redaction",
|
|
981
|
-
page: pageNumber,
|
|
982
|
-
rects: [rect],
|
|
983
|
-
reason: settings.redactionReason,
|
|
984
|
-
status: "pending"
|
|
985
|
-
});
|
|
986
|
-
} else if (tool === "stamp") {
|
|
987
|
-
const placed = isTooSmall(rect) ? clampRect({
|
|
988
|
-
x: a.x / page.width - DEFAULT_STAMP.w / 2,
|
|
989
|
-
y: a.y / page.height - DEFAULT_STAMP.h / 2,
|
|
990
|
-
...DEFAULT_STAMP
|
|
991
|
-
}) : rect;
|
|
992
|
-
controller.add({
|
|
993
|
-
kind: "stamp",
|
|
994
|
-
page: pageNumber,
|
|
995
|
-
rect: placed,
|
|
996
|
-
label: settings.stampLabel,
|
|
997
|
-
color: settings.colors.stamp
|
|
998
|
-
});
|
|
999
|
-
} else if (tool === "comment") {
|
|
1000
|
-
const anchor = clampRect({
|
|
1001
|
-
x: a.x / page.width,
|
|
1002
|
-
y: a.y / page.height,
|
|
1003
|
-
w: COMMENT_ICON_PX / page.width,
|
|
1004
|
-
h: COMMENT_ICON_PX / page.height
|
|
1005
|
-
});
|
|
1006
|
-
const id = controller.add({
|
|
1007
|
-
kind: "comment",
|
|
1008
|
-
page: pageNumber,
|
|
1009
|
-
rect: anchor,
|
|
1010
|
-
body: "",
|
|
1011
|
-
replies: [],
|
|
1012
|
-
resolved: false
|
|
1013
|
-
});
|
|
1014
|
-
if (id) {
|
|
1015
|
-
controller.setTool("select");
|
|
1016
|
-
controller.select(id);
|
|
1017
|
-
setOpenComment(id);
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
},
|
|
1021
|
-
[controller, tool, settings, pageNumber]
|
|
1022
|
-
);
|
|
1023
|
-
const onRootPointerDown = (e) => {
|
|
1024
|
-
if (!drawing || e.button !== 0 || e.target !== e.currentTarget) return;
|
|
1025
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1026
|
-
const p = local(e);
|
|
1027
|
-
setDraft({ a: p, b: p });
|
|
1028
|
-
};
|
|
1029
|
-
const onRootPointerMove = (e) => {
|
|
1030
|
-
if (draft) setDraft({ a: draft.a, b: local(e) });
|
|
1031
|
-
};
|
|
1032
|
-
const onRootPointerUp = (e) => {
|
|
1033
|
-
if (!draft) return;
|
|
1034
|
-
const b = local(e);
|
|
1035
|
-
const a = draft.a;
|
|
1036
|
-
setDraft(null);
|
|
1037
|
-
finishDraft(a, b);
|
|
1038
|
-
};
|
|
1039
|
-
const beginDrag = (e, a, mode) => {
|
|
1040
|
-
const origin = singleRect(a);
|
|
1041
|
-
if (!origin || e.button !== 0 || readOnly) return;
|
|
1042
|
-
e.stopPropagation();
|
|
1043
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1044
|
-
setDrag({
|
|
1045
|
-
id: a.id,
|
|
1046
|
-
mode,
|
|
1047
|
-
startX: e.clientX,
|
|
1048
|
-
startY: e.clientY,
|
|
1049
|
-
origin,
|
|
1050
|
-
rect: origin,
|
|
1051
|
-
moved: false
|
|
1052
|
-
});
|
|
1053
|
-
};
|
|
1054
|
-
const moveDrag = (e) => {
|
|
1055
|
-
if (!drag) return;
|
|
1056
|
-
const page = pageSize();
|
|
1057
|
-
const dxPx = e.clientX - drag.startX;
|
|
1058
|
-
const dyPx = e.clientY - drag.startY;
|
|
1059
|
-
const moved = drag.moved || Math.hypot(dxPx, dyPx) > MOVE_THRESHOLD_PX;
|
|
1060
|
-
if (!moved) return;
|
|
1061
|
-
setDrag({
|
|
1062
|
-
...drag,
|
|
1063
|
-
moved: true,
|
|
1064
|
-
rect: dragRect(drag.origin, drag.mode, dxPx / page.width, dyPx / page.height)
|
|
1065
|
-
});
|
|
1066
|
-
};
|
|
1067
|
-
const endDrag = (a) => {
|
|
1068
|
-
if (!drag) return;
|
|
1069
|
-
if (drag.moved) controller.update(a.id, patchForRect(a, drag.rect));
|
|
1070
|
-
setDrag(null);
|
|
1071
|
-
};
|
|
1072
|
-
const interactive = (a) => readOnly ? a.kind === "comment" : tool === "select" || tool === "comment" && a.kind === "comment";
|
|
1073
|
-
const selected = marks.find((a) => a.id === selectedId);
|
|
1074
|
-
return /* @__PURE__ */ jsxs(
|
|
1075
|
-
"div",
|
|
1076
|
-
{
|
|
1077
|
-
ref: rootRef,
|
|
1078
|
-
...{ [PAGE_ATTRIBUTE]: pageNumber },
|
|
1079
|
-
"data-testid": `annotation-overlay-${pageNumber}`,
|
|
1080
|
-
className: cn(
|
|
1081
|
-
"absolute inset-0 z-10 select-none overflow-hidden",
|
|
1082
|
-
drawing && "cursor-crosshair"
|
|
1083
|
-
),
|
|
1084
|
-
style: {
|
|
1085
|
-
pointerEvents: drawing ? "auto" : "none",
|
|
1086
|
-
touchAction: drawing ? "none" : void 0
|
|
1087
|
-
},
|
|
1088
|
-
onPointerDown: onRootPointerDown,
|
|
1089
|
-
onPointerMove: onRootPointerMove,
|
|
1090
|
-
onPointerUp: onRootPointerUp,
|
|
1091
|
-
onPointerCancel: () => setDraft(null),
|
|
1092
|
-
children: [
|
|
1093
|
-
marks.map((a) => /* @__PURE__ */ jsx(
|
|
1094
|
-
MarkView,
|
|
1095
|
-
{
|
|
1096
|
-
annotation: a,
|
|
1097
|
-
rectOverride: drag?.id === a.id ? drag.rect : void 0,
|
|
1098
|
-
pxPerPt,
|
|
1099
|
-
width: size.width,
|
|
1100
|
-
height: size.height,
|
|
1101
|
-
selected: a.id === selectedId,
|
|
1102
|
-
interactive: interactive(a),
|
|
1103
|
-
onPointerDown: (e) => {
|
|
1104
|
-
if (!interactive(a)) return;
|
|
1105
|
-
e.stopPropagation();
|
|
1106
|
-
controller.select(a.id);
|
|
1107
|
-
if (a.kind === "comment") setOpenComment(a.id);
|
|
1108
|
-
beginDrag(e, a, "move");
|
|
1109
|
-
},
|
|
1110
|
-
onPointerMove: moveDrag,
|
|
1111
|
-
onPointerUp: () => endDrag(a),
|
|
1112
|
-
onActivate: () => {
|
|
1113
|
-
controller.select(a.id);
|
|
1114
|
-
if (a.kind === "comment") setOpenComment(a.id);
|
|
1115
|
-
},
|
|
1116
|
-
onDelete: () => controller.remove(a.id)
|
|
1117
|
-
},
|
|
1118
|
-
a.id
|
|
1119
|
-
)),
|
|
1120
|
-
selected && tool === "select" && !readOnly && singleRect(selected) && /* @__PURE__ */ jsx(
|
|
1121
|
-
Handles,
|
|
1122
|
-
{
|
|
1123
|
-
rect: drag?.id === selected.id ? drag.rect : singleRect(selected),
|
|
1124
|
-
onPointerDown: (e, mode) => beginDrag(e, selected, mode),
|
|
1125
|
-
onPointerMove: moveDrag,
|
|
1126
|
-
onPointerUp: () => endDrag(selected)
|
|
1127
|
-
}
|
|
1128
|
-
),
|
|
1129
|
-
selected && tool === "select" && !readOnly && /* @__PURE__ */ jsx(
|
|
1130
|
-
ActionBar,
|
|
1131
|
-
{
|
|
1132
|
-
annotation: selected,
|
|
1133
|
-
controller,
|
|
1134
|
-
rect: drag?.id === selected.id ? drag.rect : firstRect(selected)
|
|
1135
|
-
}
|
|
1136
|
-
),
|
|
1137
|
-
draft && /* @__PURE__ */ jsx(Draft, { draft, tool }),
|
|
1138
|
-
openComment && selected?.kind === "comment" && selected.id === openComment && /* @__PURE__ */ jsx(
|
|
1139
|
-
CommentPopover,
|
|
1140
|
-
{
|
|
1141
|
-
annotation: selected,
|
|
1142
|
-
controller,
|
|
1143
|
-
pageHeight: size.height,
|
|
1144
|
-
onClose: () => {
|
|
1145
|
-
setOpenComment(null);
|
|
1146
|
-
controller.select(null);
|
|
1147
|
-
}
|
|
1148
|
-
},
|
|
1149
|
-
selected.id
|
|
1150
|
-
)
|
|
1151
|
-
]
|
|
1152
|
-
}
|
|
1153
|
-
);
|
|
1154
|
-
}
|
|
1155
|
-
var firstRect = (a) => a.kind === "highlight" || a.kind === "redaction" ? a.rects[0] : a.rect;
|
|
1156
|
-
function MarkView(props) {
|
|
1157
|
-
const { annotation: a, rectOverride, pxPerPt, width, height, selected, interactive } = props;
|
|
1158
|
-
const handlers = {
|
|
1159
|
-
onPointerDown: props.onPointerDown,
|
|
1160
|
-
onPointerMove: props.onPointerMove,
|
|
1161
|
-
onPointerUp: props.onPointerUp,
|
|
1162
|
-
onPointerCancel: props.onPointerUp,
|
|
1163
|
-
onKeyDown: (e) => {
|
|
1164
|
-
if (e.key === "Enter") props.onActivate();
|
|
1165
|
-
if (e.key === "Delete" || e.key === "Backspace") {
|
|
1166
|
-
e.preventDefault();
|
|
1167
|
-
props.onDelete();
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
};
|
|
1171
|
-
const base = (label) => ({
|
|
1172
|
-
"data-testid": `annotation-mark-${a.id}`,
|
|
1173
|
-
"data-kind": a.kind,
|
|
1174
|
-
"data-selected": selected ? "true" : void 0,
|
|
1175
|
-
role: "button",
|
|
1176
|
-
tabIndex: interactive ? 0 : -1,
|
|
1177
|
-
"aria-label": label,
|
|
1178
|
-
...handlers
|
|
1179
|
-
});
|
|
1180
|
-
const ring = selected ? "outline outline-2 outline-offset-2 outline-primary" : "";
|
|
1181
|
-
const events = interactive ? "auto" : "none";
|
|
1182
|
-
const dragsByTouch = selected && singleRect(a) !== null;
|
|
1183
|
-
const cursor = interactive ? singleRect(a) ? "move" : "pointer" : void 0;
|
|
1184
|
-
if (a.kind === "highlight") {
|
|
1185
|
-
return /* @__PURE__ */ jsx(Fragment, { children: a.rects.map((r, i) => /* @__PURE__ */ jsx(
|
|
1186
|
-
"div",
|
|
1187
|
-
{
|
|
1188
|
-
...i === 0 ? base(`Highlight: ${a.text ?? ""}`) : {},
|
|
1189
|
-
className: cn("absolute rounded-sm", i === 0 && ring),
|
|
1190
|
-
style: {
|
|
1191
|
-
...rectStyle(r),
|
|
1192
|
-
background: a.color,
|
|
1193
|
-
mixBlendMode: "multiply",
|
|
1194
|
-
opacity: 0.7,
|
|
1195
|
-
pointerEvents: events,
|
|
1196
|
-
touchAction: dragsByTouch ? "none" : void 0,
|
|
1197
|
-
cursor
|
|
1198
|
-
}
|
|
1199
|
-
},
|
|
1200
|
-
i
|
|
1201
|
-
)) });
|
|
1202
|
-
}
|
|
1203
|
-
if (a.kind === "box") {
|
|
1204
|
-
const r = rectOverride ?? a.rect;
|
|
1205
|
-
return /* @__PURE__ */ jsx(
|
|
1206
|
-
"div",
|
|
1207
|
-
{
|
|
1208
|
-
...base("Box"),
|
|
1209
|
-
className: cn("absolute", ring),
|
|
1210
|
-
style: {
|
|
1211
|
-
...rectStyle(r),
|
|
1212
|
-
border: `${a.strokeWidth * pxPerPt}px solid ${a.color}`,
|
|
1213
|
-
pointerEvents: events,
|
|
1214
|
-
touchAction: dragsByTouch ? "none" : void 0,
|
|
1215
|
-
cursor,
|
|
1216
|
-
boxSizing: "border-box"
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
);
|
|
1220
|
-
}
|
|
1221
|
-
if (a.kind === "stamp") {
|
|
1222
|
-
const r = rectOverride ?? a.rect;
|
|
1223
|
-
const fontPx = Math.max(
|
|
1224
|
-
6,
|
|
1225
|
-
Math.min(r.h * height * 0.6, r.w * width * 0.9 / Math.max(1, a.label.length * 0.7))
|
|
1226
|
-
);
|
|
1227
|
-
return /* @__PURE__ */ jsx(
|
|
1228
|
-
"div",
|
|
1229
|
-
{
|
|
1230
|
-
...base(`Stamp: ${a.label}`),
|
|
1231
|
-
className: cn("absolute flex items-center justify-center font-bold uppercase", ring),
|
|
1232
|
-
style: {
|
|
1233
|
-
...rectStyle(r),
|
|
1234
|
-
border: `${2 * pxPerPt}px solid ${a.color}`,
|
|
1235
|
-
color: a.color,
|
|
1236
|
-
fontSize: fontPx,
|
|
1237
|
-
lineHeight: 1,
|
|
1238
|
-
pointerEvents: events,
|
|
1239
|
-
touchAction: dragsByTouch ? "none" : void 0,
|
|
1240
|
-
cursor,
|
|
1241
|
-
boxSizing: "border-box",
|
|
1242
|
-
fontFamily: "Helvetica, Arial, sans-serif"
|
|
1243
|
-
},
|
|
1244
|
-
children: a.label
|
|
1245
|
-
}
|
|
1246
|
-
);
|
|
1247
|
-
}
|
|
1248
|
-
if (a.kind === "comment") {
|
|
1249
|
-
const r = rectOverride ?? a.rect;
|
|
1250
|
-
return /* @__PURE__ */ jsxs(
|
|
1251
|
-
"button",
|
|
1252
|
-
{
|
|
1253
|
-
type: "button",
|
|
1254
|
-
...base(`Comment: ${a.body || "empty"}`),
|
|
1255
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
1256
|
-
className: cn(
|
|
1257
|
-
"absolute flex items-center justify-center rounded-md border border-amber-700/60 bg-amber-300 text-amber-900 shadow-sm",
|
|
1258
|
-
a.resolved && "opacity-50",
|
|
1259
|
-
ring
|
|
1260
|
-
),
|
|
1261
|
-
style: {
|
|
1262
|
-
left: pct(r.x),
|
|
1263
|
-
top: pct(r.y),
|
|
1264
|
-
width: COMMENT_ICON_PX,
|
|
1265
|
-
height: COMMENT_ICON_PX,
|
|
1266
|
-
pointerEvents: events,
|
|
1267
|
-
touchAction: dragsByTouch ? "none" : void 0,
|
|
1268
|
-
cursor
|
|
1269
|
-
},
|
|
1270
|
-
children: [
|
|
1271
|
-
/* @__PURE__ */ jsx(MessageSquare, { size: 14 }),
|
|
1272
|
-
a.replies.length > 0 && /* @__PURE__ */ jsx("span", { className: "absolute -right-1 -top-1 rounded-full bg-amber-900 px-1 text-[9px] leading-3 text-white", children: a.replies.length })
|
|
1273
|
-
]
|
|
1274
|
-
}
|
|
1275
|
-
);
|
|
1276
|
-
}
|
|
1277
|
-
return /* @__PURE__ */ jsx(RedactionView, { ...props, annotation: a, ring, cursor, base });
|
|
1278
|
-
}
|
|
1279
|
-
function RedactionView({
|
|
1280
|
-
annotation: a,
|
|
1281
|
-
rectOverride,
|
|
1282
|
-
interactive,
|
|
1283
|
-
selected,
|
|
1284
|
-
ring,
|
|
1285
|
-
cursor,
|
|
1286
|
-
base
|
|
1287
|
-
}) {
|
|
1288
|
-
const events = interactive ? "auto" : "none";
|
|
1289
|
-
const dragsByTouch = selected && singleRect(a) !== null;
|
|
1290
|
-
const rects = rectOverride ? [rectOverride] : a.rects;
|
|
1291
|
-
const approved = a.status === "approved";
|
|
1292
|
-
const rejected = a.status === "rejected";
|
|
1293
|
-
const label = `Redaction (${a.status}): ${a.reason}`;
|
|
1294
|
-
return /* @__PURE__ */ jsx(Fragment, { children: rects.map((r, i) => /* @__PURE__ */ jsx(
|
|
1295
|
-
"div",
|
|
1296
|
-
{
|
|
1297
|
-
...i === 0 ? { ...base(label), title: label } : {},
|
|
1298
|
-
"data-status": i === 0 ? a.status : void 0,
|
|
1299
|
-
className: cn(
|
|
1300
|
-
"absolute flex items-center justify-center overflow-hidden text-[10px] leading-none",
|
|
1301
|
-
i === 0 && ring
|
|
1302
|
-
),
|
|
1303
|
-
style: {
|
|
1304
|
-
...rectStyle(r),
|
|
1305
|
-
pointerEvents: events,
|
|
1306
|
-
touchAction: dragsByTouch ? "none" : void 0,
|
|
1307
|
-
cursor,
|
|
1308
|
-
boxSizing: "border-box",
|
|
1309
|
-
...approved ? { background: "#000", color: "#fff" } : rejected ? { border: "1px dotted #868e96", opacity: 0.6 } : {
|
|
1310
|
-
background: "rgba(224,49,49,0.18)",
|
|
1311
|
-
border: "2px dashed #e03131",
|
|
1312
|
-
color: "#c92a2a"
|
|
1313
|
-
}
|
|
1314
|
-
},
|
|
1315
|
-
children: i === 0 && !rejected && /* @__PURE__ */ jsx("span", { className: "truncate px-1", children: a.reason })
|
|
1316
|
-
},
|
|
1317
|
-
i
|
|
1318
|
-
)) });
|
|
1319
|
-
}
|
|
1320
|
-
function Draft({ draft, tool }) {
|
|
1321
|
-
const x = Math.min(draft.a.x, draft.b.x);
|
|
1322
|
-
const y = Math.min(draft.a.y, draft.b.y);
|
|
1323
|
-
const w = Math.abs(draft.b.x - draft.a.x);
|
|
1324
|
-
const h = Math.abs(draft.b.y - draft.a.y);
|
|
1325
|
-
const redact = tool === "redact-area" || tool === "redact-text";
|
|
1326
|
-
return /* @__PURE__ */ jsx(
|
|
1327
|
-
"div",
|
|
1328
|
-
{
|
|
1329
|
-
"data-testid": "annotation-draft",
|
|
1330
|
-
className: "pointer-events-none absolute",
|
|
1331
|
-
style: {
|
|
1332
|
-
left: x,
|
|
1333
|
-
top: y,
|
|
1334
|
-
width: w,
|
|
1335
|
-
height: h,
|
|
1336
|
-
border: redact ? "2px dashed #e03131" : "2px solid #1c7ed6",
|
|
1337
|
-
background: redact ? "rgba(224,49,49,0.18)" : "rgba(28,126,214,0.08)"
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
);
|
|
1341
|
-
}
|
|
1342
|
-
var HANDLES = [
|
|
1343
|
-
{ mode: "nw", style: { left: 0, top: 0 }, cursor: "nwse-resize" },
|
|
1344
|
-
{ mode: "ne", style: { left: "100%", top: 0 }, cursor: "nesw-resize" },
|
|
1345
|
-
{ mode: "sw", style: { left: 0, top: "100%" }, cursor: "nesw-resize" },
|
|
1346
|
-
{ mode: "se", style: { left: "100%", top: "100%" }, cursor: "nwse-resize" }
|
|
1347
|
-
];
|
|
1348
|
-
function Handles({
|
|
1349
|
-
rect,
|
|
1350
|
-
onPointerDown,
|
|
1351
|
-
onPointerMove,
|
|
1352
|
-
onPointerUp
|
|
1353
|
-
}) {
|
|
1354
|
-
return /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute", style: rectStyle(rect), children: HANDLES.map((h) => (
|
|
1355
|
-
// The visible dot is small; the element a finger or pointer hits is a larger transparent
|
|
1356
|
-
// square around it (44px on touch screens, the usual minimum target).
|
|
1357
|
-
/* @__PURE__ */ jsx(
|
|
1358
|
-
"div",
|
|
1359
|
-
{
|
|
1360
|
-
"data-testid": `annotation-handle-${h.mode}`,
|
|
1361
|
-
className: "pointer-events-auto absolute flex h-6 w-6 -translate-x-1/2 -translate-y-1/2 items-center justify-center pointer-coarse:h-11 pointer-coarse:w-11",
|
|
1362
|
-
style: { ...h.style, cursor: h.cursor, touchAction: "none" },
|
|
1363
|
-
onPointerDown: (e) => onPointerDown(e, h.mode),
|
|
1364
|
-
onPointerMove,
|
|
1365
|
-
onPointerUp,
|
|
1366
|
-
onPointerCancel: onPointerUp,
|
|
1367
|
-
children: /* @__PURE__ */ jsx("span", { className: "pointer-events-none h-3 w-3 rounded-full border-2 border-primary bg-background" })
|
|
1368
|
-
},
|
|
1369
|
-
h.mode
|
|
1370
|
-
)
|
|
1371
|
-
)) });
|
|
1372
|
-
}
|
|
1373
|
-
var ACTION = "inline-flex h-7 w-7 items-center justify-center rounded text-foreground hover:bg-muted";
|
|
1374
|
-
function ActionBar({
|
|
1375
|
-
annotation: a,
|
|
1376
|
-
controller,
|
|
1377
|
-
rect
|
|
1378
|
-
}) {
|
|
1379
|
-
const above = rect.y > 0.05;
|
|
1380
|
-
return /* @__PURE__ */ jsxs(
|
|
1381
|
-
"div",
|
|
1382
|
-
{
|
|
1383
|
-
"data-testid": "annotation-actions",
|
|
1384
|
-
className: "pointer-events-auto absolute z-20 flex gap-0.5 rounded-md border border-border bg-background p-0.5 shadow-md",
|
|
1385
|
-
style: {
|
|
1386
|
-
left: pct(rect.x),
|
|
1387
|
-
top: above ? `calc(${pct(rect.y)} - 36px)` : `calc(${pct(rect.y + rect.h)} + 6px)`
|
|
1388
|
-
},
|
|
1389
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
1390
|
-
children: [
|
|
1391
|
-
a.kind === "redaction" && /* @__PURE__ */ jsx(
|
|
1392
|
-
"span",
|
|
1393
|
-
{
|
|
1394
|
-
className: "max-w-44 truncate self-center px-1.5 text-xs text-muted-foreground",
|
|
1395
|
-
title: a.reason,
|
|
1396
|
-
"data-testid": "annotation-action-reason",
|
|
1397
|
-
children: a.reason
|
|
1398
|
-
}
|
|
1399
|
-
),
|
|
1400
|
-
a.kind === "redaction" && a.status !== "approved" && /* @__PURE__ */ jsx(
|
|
1401
|
-
"button",
|
|
1402
|
-
{
|
|
1403
|
-
type: "button",
|
|
1404
|
-
className: ACTION,
|
|
1405
|
-
title: "Approve redaction",
|
|
1406
|
-
"aria-label": "Approve redaction",
|
|
1407
|
-
"data-testid": "annotation-action-approve",
|
|
1408
|
-
onClick: () => controller.setRedactionStatus([a.id], "approved"),
|
|
1409
|
-
children: /* @__PURE__ */ jsx(Check, { size: 15 })
|
|
1410
|
-
}
|
|
1411
|
-
),
|
|
1412
|
-
a.kind === "redaction" && a.status !== "rejected" && /* @__PURE__ */ jsx(
|
|
1413
|
-
"button",
|
|
1414
|
-
{
|
|
1415
|
-
type: "button",
|
|
1416
|
-
className: ACTION,
|
|
1417
|
-
title: "Reject redaction (leave visible)",
|
|
1418
|
-
"aria-label": "Reject redaction",
|
|
1419
|
-
"data-testid": "annotation-action-reject",
|
|
1420
|
-
onClick: () => controller.setRedactionStatus([a.id], "rejected"),
|
|
1421
|
-
children: /* @__PURE__ */ jsx(X, { size: 15 })
|
|
1422
|
-
}
|
|
1423
|
-
),
|
|
1424
|
-
a.kind === "redaction" && a.status !== "pending" && /* @__PURE__ */ jsx(
|
|
1425
|
-
"button",
|
|
1426
|
-
{
|
|
1427
|
-
type: "button",
|
|
1428
|
-
className: ACTION,
|
|
1429
|
-
title: "Back to pending",
|
|
1430
|
-
"aria-label": "Mark pending",
|
|
1431
|
-
"data-testid": "annotation-action-pending",
|
|
1432
|
-
onClick: () => controller.setRedactionStatus([a.id], "pending"),
|
|
1433
|
-
children: /* @__PURE__ */ jsx(RotateCcw, { size: 15 })
|
|
1434
|
-
}
|
|
1435
|
-
),
|
|
1436
|
-
/* @__PURE__ */ jsx(
|
|
1437
|
-
"button",
|
|
1438
|
-
{
|
|
1439
|
-
type: "button",
|
|
1440
|
-
className: ACTION,
|
|
1441
|
-
title: "Delete",
|
|
1442
|
-
"aria-label": "Delete annotation",
|
|
1443
|
-
"data-testid": "annotation-action-delete",
|
|
1444
|
-
onClick: () => controller.remove(a.id),
|
|
1445
|
-
children: /* @__PURE__ */ jsx(Trash2, { size: 15 })
|
|
1446
|
-
}
|
|
1447
|
-
)
|
|
1448
|
-
]
|
|
1449
|
-
}
|
|
1450
|
-
);
|
|
1451
|
-
}
|
|
1452
|
-
function CommentPopover({
|
|
1453
|
-
annotation: a,
|
|
1454
|
-
controller,
|
|
1455
|
-
pageHeight,
|
|
1456
|
-
onClose
|
|
1457
|
-
}) {
|
|
1458
|
-
const [body, setBody] = useState(a.body);
|
|
1459
|
-
const [reply, setReply] = useState("");
|
|
1460
|
-
const [lift, setLift] = useState(0);
|
|
1461
|
-
const popRef = useRef(null);
|
|
1462
|
-
const unsaved = useRef(null);
|
|
1463
|
-
const readOnly = controller.readOnly;
|
|
1464
|
-
const mine = a.author === controller.author && !readOnly;
|
|
1465
|
-
useEffect(() => setBody(a.body), [a.body]);
|
|
1466
|
-
useLayoutEffect(() => {
|
|
1467
|
-
const el = popRef.current;
|
|
1468
|
-
if (!el) return;
|
|
1469
|
-
const top2 = a.rect.y * pageHeight;
|
|
1470
|
-
const fit = () => setLift(Math.min(top2, Math.max(0, top2 + el.offsetHeight - pageHeight)));
|
|
1471
|
-
fit();
|
|
1472
|
-
const observer = new ResizeObserver(fit);
|
|
1473
|
-
observer.observe(el);
|
|
1474
|
-
return () => observer.disconnect();
|
|
1475
|
-
}, [a.rect.y, pageHeight]);
|
|
1476
|
-
const commitBody = () => {
|
|
1477
|
-
if (mine && body !== a.body) controller.update(a.id, { body });
|
|
1478
|
-
unsaved.current = null;
|
|
1479
|
-
};
|
|
1480
|
-
useEffect(
|
|
1481
|
-
() => () => {
|
|
1482
|
-
if (unsaved.current !== null) controller.update(a.id, { body: unsaved.current });
|
|
1483
|
-
unsaved.current = null;
|
|
1484
|
-
},
|
|
1485
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- runs once, when this comment's box unmounts
|
|
1486
|
-
[a.id]
|
|
1487
|
-
);
|
|
1488
|
-
const close = () => {
|
|
1489
|
-
commitBody();
|
|
1490
|
-
if (!readOnly && body.trim() === "" && a.replies.length === 0) controller.remove(a.id);
|
|
1491
|
-
onClose();
|
|
1492
|
-
};
|
|
1493
|
-
const sendReply = () => {
|
|
1494
|
-
const text = reply.trim();
|
|
1495
|
-
if (!text) return;
|
|
1496
|
-
commitBody();
|
|
1497
|
-
controller.reply(a.id, text);
|
|
1498
|
-
setReply("");
|
|
1499
|
-
};
|
|
1500
|
-
const onRight = a.rect.x > 0.6;
|
|
1501
|
-
return /* @__PURE__ */ jsxs(
|
|
1502
|
-
"div",
|
|
1503
|
-
{
|
|
1504
|
-
ref: popRef,
|
|
1505
|
-
"data-testid": "annotation-comment-popover",
|
|
1506
|
-
className: "pointer-events-auto absolute z-30 w-64 rounded-lg border border-border bg-background p-3 text-sm shadow-lg",
|
|
1507
|
-
style: {
|
|
1508
|
-
top: pct(a.rect.y),
|
|
1509
|
-
marginTop: -lift,
|
|
1510
|
-
...onRight ? { right: `calc(${pct(1 - a.rect.x)} + 8px)` } : { left: `calc(${pct(a.rect.x)} + ${COMMENT_ICON_PX + 8}px)` }
|
|
1511
|
-
},
|
|
1512
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
1513
|
-
children: [
|
|
1514
|
-
/* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between gap-2 text-xs text-muted-foreground", children: [
|
|
1515
|
-
/* @__PURE__ */ jsxs("span", { className: "truncate", children: [
|
|
1516
|
-
a.author,
|
|
1517
|
-
" \xB7 ",
|
|
1518
|
-
new Date(a.createdAt).toLocaleString()
|
|
1519
|
-
] }),
|
|
1520
|
-
/* @__PURE__ */ jsx(
|
|
1521
|
-
"button",
|
|
1522
|
-
{
|
|
1523
|
-
type: "button",
|
|
1524
|
-
"aria-label": "Close comment",
|
|
1525
|
-
"data-testid": "annotation-comment-close",
|
|
1526
|
-
className: ACTION,
|
|
1527
|
-
onClick: close,
|
|
1528
|
-
children: /* @__PURE__ */ jsx(X, { size: 14 })
|
|
1529
|
-
}
|
|
1530
|
-
)
|
|
1531
|
-
] }),
|
|
1532
|
-
/* @__PURE__ */ jsx(
|
|
1533
|
-
"textarea",
|
|
1534
|
-
{
|
|
1535
|
-
autoFocus: a.body === "",
|
|
1536
|
-
"data-testid": "annotation-comment-body",
|
|
1537
|
-
className: "field-sizing-content max-h-60 min-h-24 w-full resize-y rounded-md border border-input bg-background p-2 text-sm",
|
|
1538
|
-
placeholder: "Add a comment",
|
|
1539
|
-
value: body,
|
|
1540
|
-
readOnly: !mine,
|
|
1541
|
-
onChange: (e) => {
|
|
1542
|
-
setBody(e.target.value);
|
|
1543
|
-
unsaved.current = e.target.value;
|
|
1544
|
-
},
|
|
1545
|
-
onBlur: commitBody,
|
|
1546
|
-
onKeyDown: (e) => {
|
|
1547
|
-
if (e.key === "Escape") close();
|
|
1548
|
-
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
|
1549
|
-
commitBody();
|
|
1550
|
-
onClose();
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
),
|
|
1555
|
-
a.replies.length > 0 && /* @__PURE__ */ jsx(
|
|
1556
|
-
"ul",
|
|
1557
|
-
{
|
|
1558
|
-
className: "mt-2 max-h-40 space-y-2 overflow-y-auto",
|
|
1559
|
-
"data-testid": "annotation-comment-replies",
|
|
1560
|
-
children: a.replies.map((r) => /* @__PURE__ */ jsxs("li", { className: "rounded-md bg-muted p-2", children: [
|
|
1561
|
-
/* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground", children: r.author }),
|
|
1562
|
-
/* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap break-words", children: r.body })
|
|
1563
|
-
] }, r.id))
|
|
1564
|
-
}
|
|
1565
|
-
),
|
|
1566
|
-
!readOnly && /* @__PURE__ */ jsxs("div", { className: "mt-2 flex gap-1", children: [
|
|
1567
|
-
/* @__PURE__ */ jsx(
|
|
1568
|
-
"input",
|
|
1569
|
-
{
|
|
1570
|
-
"data-testid": "annotation-comment-reply",
|
|
1571
|
-
className: "h-8 min-w-0 flex-1 rounded-md border border-input bg-background px-2 text-sm",
|
|
1572
|
-
placeholder: "Reply",
|
|
1573
|
-
value: reply,
|
|
1574
|
-
onChange: (e) => setReply(e.target.value),
|
|
1575
|
-
onKeyDown: (e) => {
|
|
1576
|
-
if (e.key === "Enter") {
|
|
1577
|
-
e.preventDefault();
|
|
1578
|
-
sendReply();
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
),
|
|
1583
|
-
/* @__PURE__ */ jsx(
|
|
1584
|
-
"button",
|
|
1585
|
-
{
|
|
1586
|
-
type: "button",
|
|
1587
|
-
"aria-label": "Send reply",
|
|
1588
|
-
"data-testid": "annotation-comment-send",
|
|
1589
|
-
className: ACTION,
|
|
1590
|
-
onClick: sendReply,
|
|
1591
|
-
children: /* @__PURE__ */ jsx(Send, { size: 14 })
|
|
1592
|
-
}
|
|
1593
|
-
)
|
|
1594
|
-
] }),
|
|
1595
|
-
readOnly ? /* @__PURE__ */ jsx("div", { className: "mt-2 text-xs text-muted-foreground", "data-testid": "annotation-comment-status", children: a.resolved ? "Resolved" : "Open" }) : /* @__PURE__ */ jsxs("div", { className: "mt-2 flex items-center justify-between", children: [
|
|
1596
|
-
/* @__PURE__ */ jsx(
|
|
1597
|
-
"button",
|
|
1598
|
-
{
|
|
1599
|
-
type: "button",
|
|
1600
|
-
"data-testid": "annotation-comment-resolve",
|
|
1601
|
-
className: "text-xs text-primary hover:underline",
|
|
1602
|
-
onClick: () => controller.resolve(a.id, !a.resolved),
|
|
1603
|
-
children: a.resolved ? "Reopen" : "Resolve"
|
|
1604
|
-
}
|
|
1605
|
-
),
|
|
1606
|
-
/* @__PURE__ */ jsx(
|
|
1607
|
-
"button",
|
|
1608
|
-
{
|
|
1609
|
-
type: "button",
|
|
1610
|
-
"data-testid": "annotation-comment-delete",
|
|
1611
|
-
className: "text-xs text-destructive hover:underline",
|
|
1612
|
-
onClick: () => {
|
|
1613
|
-
controller.remove(a.id);
|
|
1614
|
-
onClose();
|
|
1615
|
-
},
|
|
1616
|
-
children: "Delete"
|
|
1617
|
-
}
|
|
1618
|
-
)
|
|
1619
|
-
] })
|
|
1620
|
-
]
|
|
1621
|
-
}
|
|
1622
|
-
);
|
|
1623
|
-
}
|
|
1624
|
-
var isEditable = (el) => el instanceof HTMLElement && (el.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName));
|
|
1625
|
-
function useAnnotationShortcuts(controller, enabled = true) {
|
|
1626
|
-
useEffect(() => {
|
|
1627
|
-
if (!enabled) return;
|
|
1628
|
-
const onKey = (e) => {
|
|
1629
|
-
if (isEditable(e.target)) return;
|
|
1630
|
-
const mod = e.metaKey || e.ctrlKey;
|
|
1631
|
-
if (mod && e.key.toLowerCase() === "z") {
|
|
1632
|
-
e.preventDefault();
|
|
1633
|
-
if (e.shiftKey) controller.redo();
|
|
1634
|
-
else controller.undo();
|
|
1635
|
-
} else if (mod && e.key.toLowerCase() === "y") {
|
|
1636
|
-
e.preventDefault();
|
|
1637
|
-
controller.redo();
|
|
1638
|
-
} else if ((e.key === "Delete" || e.key === "Backspace") && controller.selectedId) {
|
|
1639
|
-
e.preventDefault();
|
|
1640
|
-
controller.remove(controller.selectedId);
|
|
1641
|
-
} else if (e.key === "Escape") {
|
|
1642
|
-
controller.select(null);
|
|
1643
|
-
controller.setTool("select");
|
|
1644
|
-
}
|
|
1645
|
-
};
|
|
1646
|
-
document.addEventListener("keydown", onKey);
|
|
1647
|
-
return () => document.removeEventListener("keydown", onKey);
|
|
1648
|
-
}, [controller, enabled]);
|
|
1649
|
-
}
|
|
1650
|
-
var TOOLS = [
|
|
1651
|
-
{ tool: "select", label: "Select", icon: /* @__PURE__ */ jsx(MousePointer2, { size: 16 }) },
|
|
1652
|
-
{ tool: "highlight", label: "Highlight", icon: /* @__PURE__ */ jsx(Highlighter, { size: 16 }) },
|
|
1653
|
-
{ tool: "box", label: "Box", icon: /* @__PURE__ */ jsx(Square, { size: 16 }) },
|
|
1654
|
-
{ tool: "comment", label: "Comment", icon: /* @__PURE__ */ jsx(MessageSquare, { size: 16 }) },
|
|
1655
|
-
{ tool: "stamp", label: "Stamp", icon: /* @__PURE__ */ jsx(Stamp, { size: 16 }) },
|
|
1656
|
-
{ tool: "redact-text", label: "Redact text", icon: /* @__PURE__ */ jsx(ScanText, { size: 16 }) },
|
|
1657
|
-
{ tool: "redact-area", label: "Redact area", icon: /* @__PURE__ */ jsx(EyeOff, { size: 16 }) }
|
|
1658
|
-
];
|
|
1659
|
-
function Swatches({
|
|
1660
|
-
colors,
|
|
1661
|
-
value,
|
|
1662
|
-
onChange,
|
|
1663
|
-
label
|
|
1664
|
-
}) {
|
|
1665
|
-
return /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", role: "group", "aria-label": label, children: colors.map((c) => /* @__PURE__ */ jsx(
|
|
1666
|
-
"button",
|
|
1667
|
-
{
|
|
1668
|
-
type: "button",
|
|
1669
|
-
"aria-label": `${label} ${c}`,
|
|
1670
|
-
"aria-pressed": c === value,
|
|
1671
|
-
"data-testid": `annotation-color-${c.slice(1)}`,
|
|
1672
|
-
className: cn(
|
|
1673
|
-
"h-5 w-5 rounded-full border border-border",
|
|
1674
|
-
c === value && "ring-2 ring-primary ring-offset-1"
|
|
1675
|
-
),
|
|
1676
|
-
style: { background: c },
|
|
1677
|
-
onClick: () => onChange(c)
|
|
1678
|
-
},
|
|
1679
|
-
c
|
|
1680
|
-
)) });
|
|
1681
|
-
}
|
|
1682
|
-
function PresetField({
|
|
1683
|
-
label,
|
|
1684
|
-
testId,
|
|
1685
|
-
value,
|
|
1686
|
-
presets,
|
|
1687
|
-
maxLength,
|
|
1688
|
-
className,
|
|
1689
|
-
onChange
|
|
1690
|
-
}) {
|
|
1691
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
1692
|
-
/* @__PURE__ */ jsx(
|
|
1693
|
-
"input",
|
|
1694
|
-
{
|
|
1695
|
-
"aria-label": label,
|
|
1696
|
-
"data-testid": testId,
|
|
1697
|
-
className: cn("h-8 rounded-l-md border border-input bg-background px-2 text-sm", className),
|
|
1698
|
-
value,
|
|
1699
|
-
maxLength,
|
|
1700
|
-
onFocus: (e) => e.currentTarget.select(),
|
|
1701
|
-
onChange: (e) => onChange(e.target.value)
|
|
1702
|
-
}
|
|
1703
|
-
),
|
|
1704
|
-
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
1705
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
1706
|
-
"button",
|
|
1707
|
-
{
|
|
1708
|
-
type: "button",
|
|
1709
|
-
"aria-label": `Choose ${label.toLowerCase()}`,
|
|
1710
|
-
title: `Choose ${label.toLowerCase()}`,
|
|
1711
|
-
"data-testid": `${testId}-presets`,
|
|
1712
|
-
className: "flex h-8 items-center rounded-r-md border border-l-0 border-input bg-background px-1.5 text-muted-foreground hover:bg-accent",
|
|
1713
|
-
children: /* @__PURE__ */ jsx(ChevronDown, { size: 14 })
|
|
1714
|
-
}
|
|
1715
|
-
) }),
|
|
1716
|
-
/* @__PURE__ */ jsx(DropdownMenuContent, { align: "end", children: presets.map((p) => /* @__PURE__ */ jsx(DropdownMenuItem, { onSelect: () => onChange(p), children: p }, p)) })
|
|
1717
|
-
] })
|
|
1718
|
-
] });
|
|
1719
|
-
}
|
|
1720
|
-
function AnnotationToolbar({
|
|
1721
|
-
controller,
|
|
1722
|
-
onFreeze,
|
|
1723
|
-
actions,
|
|
1724
|
-
className
|
|
1725
|
-
}) {
|
|
1726
|
-
useTextSelectionMarks(controller);
|
|
1727
|
-
useAnnotationShortcuts(controller);
|
|
1728
|
-
const { tool, settings } = controller;
|
|
1729
|
-
const pending = pendingRedactions(controller.layer);
|
|
1730
|
-
const redactionCount = controller.layer.annotations.filter((a) => a.kind === "redaction").length;
|
|
1731
|
-
const colored = tool === "highlight" || tool === "box" || tool === "stamp";
|
|
1732
|
-
const redacting = tool === "redact-text" || tool === "redact-area";
|
|
1733
|
-
const status = layerStatusText(controller);
|
|
1734
|
-
const editable = !controller.readOnly;
|
|
1735
|
-
const redactionControls = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1736
|
-
editable && redacting && /* @__PURE__ */ jsx(
|
|
1737
|
-
PresetField,
|
|
1738
|
-
{
|
|
1739
|
-
label: "Redaction reason",
|
|
1740
|
-
testId: "annotation-redaction-reason",
|
|
1741
|
-
className: "w-44",
|
|
1742
|
-
value: settings.redactionReason,
|
|
1743
|
-
presets: REDACTION_REASONS,
|
|
1744
|
-
maxLength: 80,
|
|
1745
|
-
onChange: (redactionReason) => controller.setSettings({ redactionReason })
|
|
1746
|
-
}
|
|
1747
|
-
),
|
|
1748
|
-
redactionCount > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm", "data-testid": "annotation-review", children: [
|
|
1749
|
-
/* @__PURE__ */ jsxs("span", { className: "rounded-md bg-muted px-2 py-1", "data-testid": "annotation-pending-count", children: [
|
|
1750
|
-
pending.length,
|
|
1751
|
-
" pending"
|
|
1752
|
-
] }),
|
|
1753
|
-
editable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1754
|
-
/* @__PURE__ */ jsx(
|
|
1755
|
-
Button,
|
|
1756
|
-
{
|
|
1757
|
-
type: "button",
|
|
1758
|
-
size: "sm",
|
|
1759
|
-
variant: "outline",
|
|
1760
|
-
disabled: pending.length === 0,
|
|
1761
|
-
"data-testid": "annotation-approve-all",
|
|
1762
|
-
onClick: () => controller.setRedactionStatus(
|
|
1763
|
-
pending.map((a) => a.id),
|
|
1764
|
-
"approved"
|
|
1765
|
-
),
|
|
1766
|
-
children: "Approve all"
|
|
1767
|
-
}
|
|
1768
|
-
),
|
|
1769
|
-
/* @__PURE__ */ jsx(
|
|
1770
|
-
Button,
|
|
1771
|
-
{
|
|
1772
|
-
type: "button",
|
|
1773
|
-
size: "sm",
|
|
1774
|
-
variant: "outline",
|
|
1775
|
-
disabled: pending.length === 0,
|
|
1776
|
-
"data-testid": "annotation-reject-all",
|
|
1777
|
-
onClick: () => controller.setRedactionStatus(
|
|
1778
|
-
pending.map((a) => a.id),
|
|
1779
|
-
"rejected"
|
|
1780
|
-
),
|
|
1781
|
-
children: "Reject all"
|
|
1782
|
-
}
|
|
1783
|
-
)
|
|
1784
|
-
] })
|
|
1785
|
-
] })
|
|
1786
|
-
] });
|
|
1787
|
-
return /* @__PURE__ */ jsxs(
|
|
1788
|
-
"div",
|
|
1789
|
-
{
|
|
1790
|
-
role: "toolbar",
|
|
1791
|
-
"aria-label": "Annotation tools",
|
|
1792
|
-
"data-testid": "annotation-toolbar",
|
|
1793
|
-
className: cn(
|
|
1794
|
-
"flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border bg-background px-3 py-2",
|
|
1795
|
-
className
|
|
1796
|
-
),
|
|
1797
|
-
children: [
|
|
1798
|
-
editable && /* @__PURE__ */ jsxs(
|
|
1799
|
-
"div",
|
|
1800
|
-
{
|
|
1801
|
-
className: "flex items-center gap-1 border-r border-border pr-3",
|
|
1802
|
-
role: "group",
|
|
1803
|
-
"aria-label": "History",
|
|
1804
|
-
children: [
|
|
1805
|
-
/* @__PURE__ */ jsx(
|
|
1806
|
-
Button,
|
|
1807
|
-
{
|
|
1808
|
-
type: "button",
|
|
1809
|
-
size: "icon",
|
|
1810
|
-
variant: "ghost",
|
|
1811
|
-
title: "Undo",
|
|
1812
|
-
"aria-label": "Undo",
|
|
1813
|
-
"data-testid": "annotation-undo",
|
|
1814
|
-
disabled: !controller.canUndo,
|
|
1815
|
-
onClick: controller.undo,
|
|
1816
|
-
children: /* @__PURE__ */ jsx(Undo2, { size: 16 })
|
|
1817
|
-
}
|
|
1818
|
-
),
|
|
1819
|
-
/* @__PURE__ */ jsx(
|
|
1820
|
-
Button,
|
|
1821
|
-
{
|
|
1822
|
-
type: "button",
|
|
1823
|
-
size: "icon",
|
|
1824
|
-
variant: "ghost",
|
|
1825
|
-
title: "Redo",
|
|
1826
|
-
"aria-label": "Redo",
|
|
1827
|
-
"data-testid": "annotation-redo",
|
|
1828
|
-
disabled: !controller.canRedo,
|
|
1829
|
-
onClick: controller.redo,
|
|
1830
|
-
children: /* @__PURE__ */ jsx(Redo2, { size: 16 })
|
|
1831
|
-
}
|
|
1832
|
-
)
|
|
1833
|
-
]
|
|
1834
|
-
}
|
|
1835
|
-
),
|
|
1836
|
-
editable && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", role: "group", "aria-label": "Tool", children: TOOLS.map(({ tool: t, label, icon }) => /* @__PURE__ */ jsx(
|
|
1837
|
-
Button,
|
|
1838
|
-
{
|
|
1839
|
-
type: "button",
|
|
1840
|
-
size: "icon",
|
|
1841
|
-
variant: tool === t ? "default" : "ghost",
|
|
1842
|
-
title: label,
|
|
1843
|
-
"aria-label": label,
|
|
1844
|
-
"aria-pressed": tool === t,
|
|
1845
|
-
"data-testid": `annotation-tool-${t}`,
|
|
1846
|
-
onClick: () => controller.setTool(t),
|
|
1847
|
-
children: icon
|
|
1848
|
-
},
|
|
1849
|
-
t
|
|
1850
|
-
)) }),
|
|
1851
|
-
editable && colored && /* @__PURE__ */ jsx(
|
|
1852
|
-
Swatches,
|
|
1853
|
-
{
|
|
1854
|
-
label: "Colour",
|
|
1855
|
-
colors: tool === "highlight" ? HIGHLIGHT_COLORS : MARK_COLORS,
|
|
1856
|
-
value: settings.colors[tool],
|
|
1857
|
-
onChange: (c) => controller.setSettings({ colors: { ...settings.colors, [tool]: c } })
|
|
1858
|
-
}
|
|
1859
|
-
),
|
|
1860
|
-
editable && tool === "stamp" && /* @__PURE__ */ jsx(
|
|
1861
|
-
PresetField,
|
|
1862
|
-
{
|
|
1863
|
-
label: "Stamp text",
|
|
1864
|
-
testId: "annotation-stamp-label",
|
|
1865
|
-
className: "w-40",
|
|
1866
|
-
value: settings.stampLabel,
|
|
1867
|
-
presets: STAMP_PRESETS,
|
|
1868
|
-
maxLength: 40,
|
|
1869
|
-
onChange: (stampLabel) => controller.setSettings({ stampLabel })
|
|
1870
|
-
}
|
|
1871
|
-
),
|
|
1872
|
-
(redacting || redactionCount > 0) && /* @__PURE__ */ jsx(
|
|
1873
|
-
"div",
|
|
1874
|
-
{
|
|
1875
|
-
className: "flex w-full flex-wrap items-center gap-x-3 gap-y-2",
|
|
1876
|
-
"data-testid": "annotation-redaction-row",
|
|
1877
|
-
children: redactionControls
|
|
1878
|
-
}
|
|
1879
|
-
),
|
|
1880
|
-
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-end gap-3 text-xs text-muted-foreground", children: [
|
|
1881
|
-
/* @__PURE__ */ jsx(
|
|
1882
|
-
"span",
|
|
1883
|
-
{
|
|
1884
|
-
"data-testid": "annotation-status",
|
|
1885
|
-
role: "status",
|
|
1886
|
-
"data-state": controller.readOnly ? "readonly" : controller.offline ? "offline" : controller.error ? "error" : controller.saving ? "saving" : controller.dirty ? "dirty" : "saved",
|
|
1887
|
-
className: cn(controller.error && !controller.offline && "text-destructive"),
|
|
1888
|
-
title: controller.error ?? void 0,
|
|
1889
|
-
children: status
|
|
1890
|
-
}
|
|
1891
|
-
),
|
|
1892
|
-
actions,
|
|
1893
|
-
onFreeze && /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", "data-testid": "annotation-freeze", onClick: onFreeze, children: [
|
|
1894
|
-
/* @__PURE__ */ jsx(Snowflake, { size: 14 }),
|
|
1895
|
-
"Freeze copy"
|
|
1896
|
-
] })
|
|
1897
|
-
] })
|
|
1898
|
-
]
|
|
1899
|
-
}
|
|
1900
|
-
);
|
|
1901
|
-
}
|
|
1902
|
-
var KIND_LABELS = {
|
|
1903
|
-
highlight: "highlights",
|
|
1904
|
-
box: "boxes",
|
|
1905
|
-
comment: "comments",
|
|
1906
|
-
stamp: "stamps",
|
|
1907
|
-
redaction: "redactions"
|
|
1908
|
-
};
|
|
1909
|
-
function FreezeDialog({
|
|
1910
|
-
open,
|
|
1911
|
-
onOpenChange,
|
|
1912
|
-
controller,
|
|
1913
|
-
onConfirm,
|
|
1914
|
-
busy,
|
|
1915
|
-
progress,
|
|
1916
|
-
error
|
|
1917
|
-
}) {
|
|
1918
|
-
const [mode, setMode] = useState("vector");
|
|
1919
|
-
const [comments, setComments] = useState("omit");
|
|
1920
|
-
const [burnPending, setBurnPending] = useState(false);
|
|
1921
|
-
const [redactionLog, setRedactionLog] = useState(true);
|
|
1922
|
-
const marks = controller.layer.annotations;
|
|
1923
|
-
const redactions = marks.filter(isEffectiveRedaction);
|
|
1924
|
-
const pending = pendingRedactions(controller.layer);
|
|
1925
|
-
const hasRedactionMarks = marks.some((a) => a.kind === "redaction");
|
|
1926
|
-
const forced = redactions.length > 0;
|
|
1927
|
-
const effectiveMode = forced ? "image" : mode;
|
|
1928
|
-
const blocked = pending.length > 0 && !burnPending;
|
|
1929
|
-
const counts = Object.keys(KIND_LABELS).map(
|
|
1930
|
-
(k) => [
|
|
1931
|
-
k,
|
|
1932
|
-
marks.filter((a) => a.kind === k && (k !== "redaction" || isEffectiveRedaction(a))).length
|
|
1933
|
-
]
|
|
1934
|
-
).filter(([, n]) => n > 0);
|
|
1935
|
-
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (next) => !busy && onOpenChange(next), children: /* @__PURE__ */ jsxs(DialogContent, { "data-testid": "freeze-dialog", children: [
|
|
1936
|
-
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
1937
|
-
/* @__PURE__ */ jsx(DialogTitle, { children: "Freeze a copy" }),
|
|
1938
|
-
/* @__PURE__ */ jsx(DialogDescription, { children: "Saves a separate document with your annotations built in, next to the original. The original stays as it is." })
|
|
1939
|
-
] }),
|
|
1940
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", "data-testid": "freeze-summary", children: counts.length === 0 ? "No annotations yet." : counts.map(([k, n]) => `${n} ${KIND_LABELS[k]}`).join(", ") }),
|
|
1941
|
-
/* @__PURE__ */ jsxs("fieldset", { className: "space-y-2 text-sm", disabled: busy, children: [
|
|
1942
|
-
/* @__PURE__ */ jsx("legend", { className: "mb-1 font-medium", children: "Format" }),
|
|
1943
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-start gap-2", children: [
|
|
1944
|
-
/* @__PURE__ */ jsx(
|
|
1945
|
-
"input",
|
|
1946
|
-
{
|
|
1947
|
-
type: "radio",
|
|
1948
|
-
name: "freeze-mode",
|
|
1949
|
-
"data-testid": "freeze-mode-vector",
|
|
1950
|
-
checked: effectiveMode === "vector",
|
|
1951
|
-
disabled: forced,
|
|
1952
|
-
onChange: () => setMode("vector")
|
|
1953
|
-
}
|
|
1954
|
-
),
|
|
1955
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
1956
|
-
"Keep text",
|
|
1957
|
-
/* @__PURE__ */ jsx("span", { className: "block text-xs text-muted-foreground", children: "Searchable, smaller. Not available when there are redactions." })
|
|
1958
|
-
] })
|
|
1959
|
-
] }),
|
|
1960
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-start gap-2", children: [
|
|
1961
|
-
/* @__PURE__ */ jsx(
|
|
1962
|
-
"input",
|
|
1963
|
-
{
|
|
1964
|
-
type: "radio",
|
|
1965
|
-
name: "freeze-mode",
|
|
1966
|
-
"data-testid": "freeze-mode-image",
|
|
1967
|
-
checked: effectiveMode === "image",
|
|
1968
|
-
onChange: () => setMode("image")
|
|
1969
|
-
}
|
|
1970
|
-
),
|
|
1971
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
1972
|
-
"Image only",
|
|
1973
|
-
/* @__PURE__ */ jsx("span", { className: "block text-xs text-muted-foreground", children: "Every page becomes a picture. Nothing is left behind a redaction." })
|
|
1974
|
-
] })
|
|
1975
|
-
] }),
|
|
1976
|
-
forced && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", "data-testid": "freeze-forced-note", children: "Image only is required because this document has redactions." })
|
|
1977
|
-
] }),
|
|
1978
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
|
|
1979
|
-
"Comments",
|
|
1980
|
-
/* @__PURE__ */ jsxs(
|
|
1981
|
-
"select",
|
|
1982
|
-
{
|
|
1983
|
-
"data-testid": "freeze-comments",
|
|
1984
|
-
className: "h-8 rounded-md border border-input bg-background px-2",
|
|
1985
|
-
value: comments,
|
|
1986
|
-
disabled: busy,
|
|
1987
|
-
onChange: (e) => setComments(e.target.value),
|
|
1988
|
-
children: [
|
|
1989
|
-
/* @__PURE__ */ jsx("option", { value: "omit", children: "Leave out" }),
|
|
1990
|
-
/* @__PURE__ */ jsx("option", { value: "markers", children: "Numbered markers" }),
|
|
1991
|
-
/* @__PURE__ */ jsx("option", { value: "appendix", children: "Markers and a listing" })
|
|
1992
|
-
]
|
|
1993
|
-
}
|
|
1994
|
-
)
|
|
1995
|
-
] }),
|
|
1996
|
-
forced && comments !== "omit" && marks.some((a) => a.kind === "comment") && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", "data-testid": "freeze-comment-warning", children: "Comments are copied as written and may repeat text you have redacted." }),
|
|
1997
|
-
pending.length > 0 && /* @__PURE__ */ jsxs(
|
|
1998
|
-
"label",
|
|
1999
|
-
{
|
|
2000
|
-
className: "flex items-start gap-2 rounded-md border border-border p-2 text-sm",
|
|
2001
|
-
"data-testid": "freeze-pending",
|
|
2002
|
-
children: [
|
|
2003
|
-
/* @__PURE__ */ jsx(
|
|
2004
|
-
"input",
|
|
2005
|
-
{
|
|
2006
|
-
type: "checkbox",
|
|
2007
|
-
"data-testid": "freeze-burn-pending",
|
|
2008
|
-
checked: burnPending,
|
|
2009
|
-
disabled: busy,
|
|
2010
|
-
onChange: (e) => setBurnPending(e.target.checked)
|
|
2011
|
-
}
|
|
2012
|
-
),
|
|
2013
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
2014
|
-
pending.length,
|
|
2015
|
-
" redaction",
|
|
2016
|
-
pending.length === 1 ? " has" : "s have",
|
|
2017
|
-
" not been reviewed",
|
|
2018
|
-
/* @__PURE__ */ jsx("span", { className: "block text-xs text-muted-foreground", children: "Tick to redact them as well, or approve or reject them first." })
|
|
2019
|
-
] })
|
|
2020
|
-
]
|
|
2021
|
-
}
|
|
2022
|
-
),
|
|
2023
|
-
hasRedactionMarks && /* @__PURE__ */ jsxs("label", { className: "flex items-start gap-2 text-sm", children: [
|
|
2024
|
-
/* @__PURE__ */ jsx(
|
|
2025
|
-
"input",
|
|
2026
|
-
{
|
|
2027
|
-
type: "checkbox",
|
|
2028
|
-
"data-testid": "freeze-redaction-log",
|
|
2029
|
-
checked: redactionLog,
|
|
2030
|
-
disabled: busy,
|
|
2031
|
-
onChange: (e) => setRedactionLog(e.target.checked)
|
|
2032
|
-
}
|
|
2033
|
-
),
|
|
2034
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
2035
|
-
"Download a redaction log (CSV)",
|
|
2036
|
-
/* @__PURE__ */ jsx("span", { className: "block text-xs text-muted-foreground", children: "Page, reason, status, who approved it and when. Never the redacted text." })
|
|
2037
|
-
] })
|
|
2038
|
-
] }),
|
|
2039
|
-
busy && progress && /* @__PURE__ */ jsxs("p", { className: "text-sm", role: "status", "data-testid": "freeze-progress", children: [
|
|
2040
|
-
"Page ",
|
|
2041
|
-
progress.done,
|
|
2042
|
-
" of ",
|
|
2043
|
-
progress.total,
|
|
2044
|
-
"\u2026"
|
|
2045
|
-
] }),
|
|
2046
|
-
error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", role: "alert", "data-testid": "freeze-error", children: error }),
|
|
2047
|
-
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
2048
|
-
/* @__PURE__ */ jsx(
|
|
2049
|
-
Button,
|
|
2050
|
-
{
|
|
2051
|
-
type: "button",
|
|
2052
|
-
variant: "outline",
|
|
2053
|
-
disabled: busy,
|
|
2054
|
-
onClick: () => onOpenChange(false),
|
|
2055
|
-
children: "Cancel"
|
|
2056
|
-
}
|
|
2057
|
-
),
|
|
2058
|
-
/* @__PURE__ */ jsx(
|
|
2059
|
-
Button,
|
|
2060
|
-
{
|
|
2061
|
-
type: "button",
|
|
2062
|
-
"data-testid": "freeze-confirm",
|
|
2063
|
-
disabled: busy || blocked,
|
|
2064
|
-
onClick: () => onConfirm({
|
|
2065
|
-
mode: effectiveMode,
|
|
2066
|
-
comments,
|
|
2067
|
-
pendingRedactions: burnPending ? "burn" : "error",
|
|
2068
|
-
redactionLog: hasRedactionMarks && redactionLog
|
|
2069
|
-
}),
|
|
2070
|
-
children: busy ? "Freezing\u2026" : "Freeze"
|
|
2071
|
-
}
|
|
2072
|
-
)
|
|
2073
|
-
] })
|
|
2074
|
-
] }) });
|
|
2075
|
-
}
|
|
2076
|
-
var MAX_PREFIX = 24;
|
|
2077
|
-
function previewLabel(choices) {
|
|
2078
|
-
return `${choices.prefix}${String(choices.start).padStart(choices.digits, "0")}`;
|
|
2079
|
-
}
|
|
2080
|
-
function qrCornerFor(corner) {
|
|
2081
|
-
return corner.endsWith("left") ? "bottom-right" : "bottom-left";
|
|
2082
|
-
}
|
|
2083
|
-
function moveItem(items, from, to) {
|
|
2084
|
-
if (from === to || from < 0 || to < 0 || from >= items.length || to >= items.length)
|
|
2085
|
-
return [...items];
|
|
2086
|
-
const next = [...items];
|
|
2087
|
-
const [moved] = next.splice(from, 1);
|
|
2088
|
-
next.splice(to, 0, moved);
|
|
2089
|
-
return next;
|
|
2090
|
-
}
|
|
2091
|
-
function ProductionDialog({
|
|
2092
|
-
open,
|
|
2093
|
-
onOpenChange,
|
|
2094
|
-
documents,
|
|
2095
|
-
leftOut = [],
|
|
2096
|
-
onConfirm,
|
|
2097
|
-
busy,
|
|
2098
|
-
progress,
|
|
2099
|
-
error
|
|
2100
|
-
}) {
|
|
2101
|
-
const [layout, setLayout] = useState("merged");
|
|
2102
|
-
const [prefix, setPrefix] = useState("");
|
|
2103
|
-
const [start, setStart] = useState(1);
|
|
2104
|
-
const [digits, setDigits] = useState(6);
|
|
2105
|
-
const [corner, setCorner] = useState("bottom-right");
|
|
2106
|
-
const [qr, setQr] = useState(false);
|
|
2107
|
-
const [indexPage, setIndexPage] = useState(false);
|
|
2108
|
-
const [saveToWorkspace, setSaveToWorkspace] = useState(true);
|
|
2109
|
-
const documentKey = documents.map((d) => d.id).join("|");
|
|
2110
|
-
const [ordered, setOrdered] = useState(documents);
|
|
2111
|
-
useEffect(() => setOrdered(documents), [documentKey]);
|
|
2112
|
-
const listRef = useRef(null);
|
|
2113
|
-
const [dragFrom, setDragFrom] = useState(null);
|
|
2114
|
-
const focusAfterMove = useRef(null);
|
|
2115
|
-
useEffect(() => {
|
|
2116
|
-
const pending = focusAfterMove.current;
|
|
2117
|
-
focusAfterMove.current = null;
|
|
2118
|
-
if (!pending || !listRef.current) return;
|
|
2119
|
-
const button = (arrow) => listRef.current?.querySelector(
|
|
2120
|
-
`[data-testid="production-move-${arrow}-${pending.index}"]:not(:disabled)`
|
|
2121
|
-
);
|
|
2122
|
-
(button(pending.arrow) ?? button(pending.arrow === "up" ? "down" : "up"))?.focus();
|
|
2123
|
-
}, [ordered]);
|
|
2124
|
-
const move = (from, to, arrow) => {
|
|
2125
|
-
if (arrow) focusAfterMove.current = { index: to, arrow };
|
|
2126
|
-
setOrdered((items) => moveItem(items, from, to));
|
|
2127
|
-
};
|
|
2128
|
-
const onDrop = (to) => (e) => {
|
|
2129
|
-
e.preventDefault();
|
|
2130
|
-
if (dragFrom !== null) move(dragFrom, to);
|
|
2131
|
-
setDragFrom(null);
|
|
2132
|
-
};
|
|
2133
|
-
const valid = Number.isInteger(start) && start >= 0 && Number.isInteger(digits) && digits >= 1 && digits <= 12;
|
|
2134
|
-
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (next) => !busy && onOpenChange(next), children: /* @__PURE__ */ jsxs(DialogContent, { "data-testid": "production-dialog", className: "max-h-[90dvh] overflow-y-auto", children: [
|
|
2135
|
-
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
2136
|
-
/* @__PURE__ */ jsx(DialogTitle, { children: "Production set" }),
|
|
2137
|
-
/* @__PURE__ */ jsx(DialogDescription, { children: "Numbers every page with a Bates label, in the order shown. The originals are never changed; the result is downloaded and, if you choose, saved to the workspace." })
|
|
2138
|
-
] }),
|
|
2139
|
-
/* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", "data-testid": "production-summary", children: [
|
|
2140
|
-
documents.length,
|
|
2141
|
-
" document",
|
|
2142
|
-
documents.length === 1 ? "" : "s",
|
|
2143
|
-
", numbered in this order.",
|
|
2144
|
-
ordered.length > 1 ? " Drag a row or use its arrows to reorder." : ""
|
|
2145
|
-
] }),
|
|
2146
|
-
/* @__PURE__ */ jsx(
|
|
2147
|
-
"ol",
|
|
2148
|
-
{
|
|
2149
|
-
ref: listRef,
|
|
2150
|
-
className: "max-h-48 space-y-1 overflow-y-auto text-sm",
|
|
2151
|
-
"data-testid": "production-order",
|
|
2152
|
-
"aria-label": "Numbering order",
|
|
2153
|
-
children: ordered.map((doc, i) => /* @__PURE__ */ jsxs(
|
|
2154
|
-
"li",
|
|
2155
|
-
{
|
|
2156
|
-
draggable: !busy,
|
|
2157
|
-
onDragStart: () => setDragFrom(i),
|
|
2158
|
-
onDragOver: (e) => e.preventDefault(),
|
|
2159
|
-
onDrop: onDrop(i),
|
|
2160
|
-
onDragEnd: () => setDragFrom(null),
|
|
2161
|
-
className: `flex items-center gap-1 rounded-md border border-border px-2 py-1 ${dragFrom === i ? "opacity-50" : ""}`,
|
|
2162
|
-
"data-testid": `production-order-item-${i}`,
|
|
2163
|
-
"data-document-id": doc.id,
|
|
2164
|
-
children: [
|
|
2165
|
-
/* @__PURE__ */ jsx(
|
|
2166
|
-
GripVertical,
|
|
2167
|
-
{
|
|
2168
|
-
className: "size-4 shrink-0 cursor-grab text-muted-foreground",
|
|
2169
|
-
"aria-hidden": true
|
|
2170
|
-
}
|
|
2171
|
-
),
|
|
2172
|
-
/* @__PURE__ */ jsxs("span", { className: "w-6 shrink-0 text-right tabular-nums text-muted-foreground", children: [
|
|
2173
|
-
i + 1,
|
|
2174
|
-
"."
|
|
2175
|
-
] }),
|
|
2176
|
-
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", title: doc.name, children: doc.name }),
|
|
2177
|
-
/* @__PURE__ */ jsx(
|
|
2178
|
-
Button,
|
|
2179
|
-
{
|
|
2180
|
-
type: "button",
|
|
2181
|
-
variant: "ghost",
|
|
2182
|
-
size: "icon",
|
|
2183
|
-
className: "size-7 pointer-coarse:size-11",
|
|
2184
|
-
"aria-label": `Move ${doc.name} up`,
|
|
2185
|
-
"data-testid": `production-move-up-${i}`,
|
|
2186
|
-
disabled: busy || i === 0,
|
|
2187
|
-
onClick: () => move(i, i - 1, "up"),
|
|
2188
|
-
children: /* @__PURE__ */ jsx(ChevronUp, { className: "size-4" })
|
|
2189
|
-
}
|
|
2190
|
-
),
|
|
2191
|
-
/* @__PURE__ */ jsx(
|
|
2192
|
-
Button,
|
|
2193
|
-
{
|
|
2194
|
-
type: "button",
|
|
2195
|
-
variant: "ghost",
|
|
2196
|
-
size: "icon",
|
|
2197
|
-
className: "size-7 pointer-coarse:size-11",
|
|
2198
|
-
"aria-label": `Move ${doc.name} down`,
|
|
2199
|
-
"data-testid": `production-move-down-${i}`,
|
|
2200
|
-
disabled: busy || i === ordered.length - 1,
|
|
2201
|
-
onClick: () => move(i, i + 1, "down"),
|
|
2202
|
-
children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-4" })
|
|
2203
|
-
}
|
|
2204
|
-
)
|
|
2205
|
-
]
|
|
2206
|
-
},
|
|
2207
|
-
doc.id
|
|
2208
|
-
))
|
|
2209
|
-
}
|
|
2210
|
-
),
|
|
2211
|
-
leftOut.length > 0 && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", "data-testid": "production-left-out", children: [
|
|
2212
|
-
"Left out, with no PDF version to number: ",
|
|
2213
|
-
leftOut.join(", ")
|
|
2214
|
-
] }),
|
|
2215
|
-
/* @__PURE__ */ jsxs("fieldset", { className: "space-y-2 text-sm", disabled: busy, children: [
|
|
2216
|
-
/* @__PURE__ */ jsx("legend", { className: "mb-1 font-medium", children: "Files" }),
|
|
2217
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-start gap-2", children: [
|
|
2218
|
-
/* @__PURE__ */ jsx(
|
|
2219
|
-
"input",
|
|
2220
|
-
{
|
|
2221
|
-
type: "radio",
|
|
2222
|
-
name: "production-layout",
|
|
2223
|
-
"data-testid": "production-layout-merged",
|
|
2224
|
-
checked: layout === "merged",
|
|
2225
|
-
onChange: () => setLayout("merged")
|
|
2226
|
-
}
|
|
2227
|
-
),
|
|
2228
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
2229
|
-
"One merged file",
|
|
2230
|
-
/* @__PURE__ */ jsx("span", { className: "block text-xs text-muted-foreground", children: "All documents joined, numbered consecutively." })
|
|
2231
|
-
] })
|
|
2232
|
-
] }),
|
|
2233
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-start gap-2", children: [
|
|
2234
|
-
/* @__PURE__ */ jsx(
|
|
2235
|
-
"input",
|
|
2236
|
-
{
|
|
2237
|
-
type: "radio",
|
|
2238
|
-
name: "production-layout",
|
|
2239
|
-
"data-testid": "production-layout-per-document",
|
|
2240
|
-
checked: layout === "per-document",
|
|
2241
|
-
onChange: () => setLayout("per-document")
|
|
2242
|
-
}
|
|
2243
|
-
),
|
|
2244
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
2245
|
-
"One file per document",
|
|
2246
|
-
/* @__PURE__ */ jsx("span", { className: "block text-xs text-muted-foreground", children: "Numbering carries on from one file to the next." })
|
|
2247
|
-
] })
|
|
2248
|
-
] })
|
|
2249
|
-
] }),
|
|
2250
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-2 text-sm", children: [
|
|
2251
|
-
/* @__PURE__ */ jsxs("label", { className: "space-y-1", children: [
|
|
2252
|
-
"Prefix",
|
|
2253
|
-
/* @__PURE__ */ jsx(
|
|
2254
|
-
"input",
|
|
2255
|
-
{
|
|
2256
|
-
"data-testid": "production-prefix",
|
|
2257
|
-
className: "h-8 w-full rounded-md border border-input bg-background px-2",
|
|
2258
|
-
value: prefix,
|
|
2259
|
-
maxLength: MAX_PREFIX,
|
|
2260
|
-
disabled: busy,
|
|
2261
|
-
onChange: (e) => setPrefix(e.target.value)
|
|
2262
|
-
}
|
|
2263
|
-
)
|
|
2264
|
-
] }),
|
|
2265
|
-
/* @__PURE__ */ jsxs("label", { className: "space-y-1", children: [
|
|
2266
|
-
"Start at",
|
|
2267
|
-
/* @__PURE__ */ jsx(
|
|
2268
|
-
"input",
|
|
2269
|
-
{
|
|
2270
|
-
"data-testid": "production-start",
|
|
2271
|
-
type: "number",
|
|
2272
|
-
min: 0,
|
|
2273
|
-
className: "h-8 w-full rounded-md border border-input bg-background px-2",
|
|
2274
|
-
value: start,
|
|
2275
|
-
disabled: busy,
|
|
2276
|
-
onChange: (e) => setStart(e.target.valueAsNumber)
|
|
2277
|
-
}
|
|
2278
|
-
)
|
|
2279
|
-
] }),
|
|
2280
|
-
/* @__PURE__ */ jsxs("label", { className: "space-y-1", children: [
|
|
2281
|
-
"Digits",
|
|
2282
|
-
/* @__PURE__ */ jsx(
|
|
2283
|
-
"input",
|
|
2284
|
-
{
|
|
2285
|
-
"data-testid": "production-digits",
|
|
2286
|
-
type: "number",
|
|
2287
|
-
min: 1,
|
|
2288
|
-
max: 12,
|
|
2289
|
-
className: "h-8 w-full rounded-md border border-input bg-background px-2",
|
|
2290
|
-
value: digits,
|
|
2291
|
-
disabled: busy,
|
|
2292
|
-
onChange: (e) => setDigits(e.target.valueAsNumber)
|
|
2293
|
-
}
|
|
2294
|
-
)
|
|
2295
|
-
] })
|
|
2296
|
-
] }),
|
|
2297
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
|
|
2298
|
-
"Label position",
|
|
2299
|
-
/* @__PURE__ */ jsxs(
|
|
2300
|
-
"select",
|
|
2301
|
-
{
|
|
2302
|
-
"data-testid": "production-corner",
|
|
2303
|
-
className: "h-8 rounded-md border border-input bg-background px-2",
|
|
2304
|
-
value: corner,
|
|
2305
|
-
disabled: busy,
|
|
2306
|
-
onChange: (e) => setCorner(e.target.value),
|
|
2307
|
-
children: [
|
|
2308
|
-
/* @__PURE__ */ jsx("option", { value: "bottom-right", children: "Bottom right" }),
|
|
2309
|
-
/* @__PURE__ */ jsx("option", { value: "bottom-left", children: "Bottom left" }),
|
|
2310
|
-
/* @__PURE__ */ jsx("option", { value: "top-right", children: "Top right" }),
|
|
2311
|
-
/* @__PURE__ */ jsx("option", { value: "top-left", children: "Top left" })
|
|
2312
|
-
]
|
|
2313
|
-
}
|
|
2314
|
-
)
|
|
2315
|
-
] }),
|
|
2316
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-start gap-2 text-sm", children: [
|
|
2317
|
-
/* @__PURE__ */ jsx(
|
|
2318
|
-
"input",
|
|
2319
|
-
{
|
|
2320
|
-
type: "checkbox",
|
|
2321
|
-
"data-testid": "production-qr",
|
|
2322
|
-
checked: qr,
|
|
2323
|
-
disabled: busy,
|
|
2324
|
-
onChange: (e) => setQr(e.target.checked)
|
|
2325
|
-
}
|
|
2326
|
-
),
|
|
2327
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
2328
|
-
"QR code on every page",
|
|
2329
|
-
/* @__PURE__ */ jsx("span", { className: "block text-xs text-muted-foreground", children: "Opens the document in ARBI for anyone with access." })
|
|
2330
|
-
] })
|
|
2331
|
-
] }),
|
|
2332
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-start gap-2 text-sm", children: [
|
|
2333
|
-
/* @__PURE__ */ jsx(
|
|
2334
|
-
"input",
|
|
2335
|
-
{
|
|
2336
|
-
type: "checkbox",
|
|
2337
|
-
"data-testid": "production-index",
|
|
2338
|
-
checked: indexPage,
|
|
2339
|
-
disabled: busy,
|
|
2340
|
-
onChange: (e) => setIndexPage(e.target.checked)
|
|
2341
|
-
}
|
|
2342
|
-
),
|
|
2343
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
2344
|
-
"Index page at the start",
|
|
2345
|
-
/* @__PURE__ */ jsx("span", { className: "block text-xs text-muted-foreground", children: "Lists every document with its Bates range. The index itself is not numbered." })
|
|
2346
|
-
] })
|
|
2347
|
-
] }),
|
|
2348
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-start gap-2 text-sm", children: [
|
|
2349
|
-
/* @__PURE__ */ jsx(
|
|
2350
|
-
"input",
|
|
2351
|
-
{
|
|
2352
|
-
type: "checkbox",
|
|
2353
|
-
"data-testid": "production-save",
|
|
2354
|
-
checked: saveToWorkspace,
|
|
2355
|
-
disabled: busy,
|
|
2356
|
-
onChange: (e) => setSaveToWorkspace(e.target.checked)
|
|
2357
|
-
}
|
|
2358
|
-
),
|
|
2359
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
2360
|
-
"Save to workspace",
|
|
2361
|
-
/* @__PURE__ */ jsx("span", { className: "block text-xs text-muted-foreground", children: layout === "merged" ? "Adds the merged PDF to the Productions folder, so it can be shared or emailed." : "Adds each numbered file to a folder under Productions, so they can be shared or emailed." })
|
|
2362
|
-
] })
|
|
2363
|
-
] }),
|
|
2364
|
-
valid && /* @__PURE__ */ jsxs("p", { className: "text-sm", "data-testid": "production-preview", children: [
|
|
2365
|
-
"First label:",
|
|
2366
|
-
" ",
|
|
2367
|
-
/* @__PURE__ */ jsx("span", { className: "font-mono", children: previewLabel({ prefix, start, digits }) })
|
|
2368
|
-
] }),
|
|
2369
|
-
busy && progress && /* @__PURE__ */ jsxs("p", { className: "text-sm", role: "status", "data-testid": "production-progress", children: [
|
|
2370
|
-
"Document ",
|
|
2371
|
-
progress.done,
|
|
2372
|
-
" of ",
|
|
2373
|
-
progress.total,
|
|
2374
|
-
"\u2026"
|
|
2375
|
-
] }),
|
|
2376
|
-
error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", role: "alert", "data-testid": "production-error", children: error }),
|
|
2377
|
-
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
2378
|
-
/* @__PURE__ */ jsx(
|
|
2379
|
-
Button,
|
|
2380
|
-
{
|
|
2381
|
-
type: "button",
|
|
2382
|
-
variant: "outline",
|
|
2383
|
-
disabled: busy,
|
|
2384
|
-
onClick: () => onOpenChange(false),
|
|
2385
|
-
children: "Cancel"
|
|
2386
|
-
}
|
|
2387
|
-
),
|
|
2388
|
-
/* @__PURE__ */ jsx(
|
|
2389
|
-
Button,
|
|
2390
|
-
{
|
|
2391
|
-
type: "button",
|
|
2392
|
-
"data-testid": "production-confirm",
|
|
2393
|
-
disabled: busy || !valid || ordered.length === 0,
|
|
2394
|
-
onClick: () => onConfirm({
|
|
2395
|
-
layout,
|
|
2396
|
-
prefix,
|
|
2397
|
-
start,
|
|
2398
|
-
digits,
|
|
2399
|
-
corner,
|
|
2400
|
-
qr,
|
|
2401
|
-
indexPage,
|
|
2402
|
-
saveToWorkspace,
|
|
2403
|
-
order: ordered.map((d) => d.id)
|
|
2404
|
-
}),
|
|
2405
|
-
children: busy ? "Working\u2026" : "Create production"
|
|
2406
|
-
}
|
|
2407
|
-
)
|
|
2408
|
-
] })
|
|
2409
|
-
] }) });
|
|
2410
|
-
}
|
|
2411
|
-
|
|
2412
|
-
export { AUTOSAVE_MS, AnnotationPageOverlay, AnnotationStoreOfflineError, AnnotationToolbar, DEFAULT_SETTINGS, FreezeDialog, HIGHLIGHT_COLORS, MARK_COLORS, ProductionDialog, REDACTION_LOG_COLUMNS, REDACTION_REASONS, RETRY_MS, STAMP_PRESETS, annotationsOnPage, applyAction, canRedo, canUndo, containsPoint, createHistory, createLocalStorageStore, createMemoryStore, dragRect, dragToNorm, intersects, isTooSmall, layerStatusText, mergeLayers, mergeLineRects, moveItem, patchForRect, pendingRedactions, qrCornerFor, readSelection, redactionLogCsv, redactionLogRows, redo, reduceLayer, sameMarks, selectionToPageMarks, singleRect, toNorm, toPixels, undo, useAnnotationLayer, useAnnotationShortcuts, useTextSelectionMarks };
|
|
3
|
+
import '../chunk-WS6DF5X4.js';
|
|
4
|
+
import '../chunk-47CCGUWR.js';
|
|
5
|
+
import '../chunk-SN5YV6FF.js';
|
|
2413
6
|
//# sourceMappingURL=index.js.map
|
|
2414
7
|
//# sourceMappingURL=index.js.map
|