@arbidocs/react 0.4.64 → 0.4.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/annotations/index.cjs +241 -61
- package/dist/annotations/index.cjs.map +1 -1
- package/dist/annotations/index.d.cts +72 -5
- package/dist/annotations/index.d.ts +72 -5
- package/dist/annotations/index.js +236 -62
- package/dist/annotations/index.js.map +1 -1
- package/dist/artifacts/index.cjs +17 -17
- package/dist/artifacts/index.js +3 -3
- package/dist/{chunk-F5WHYJRB.js → chunk-IS23MR2A.js} +3 -3
- package/dist/{chunk-F5WHYJRB.js.map → chunk-IS23MR2A.js.map} +1 -1
- package/dist/{chunk-VH5ITITV.cjs → chunk-NCUBNIO4.cjs} +3 -3
- package/dist/{chunk-VH5ITITV.cjs.map → chunk-NCUBNIO4.cjs.map} +1 -1
- package/dist/{chunk-SX7FCSON.js → chunk-OTNB2IZL.js} +3 -3
- package/dist/{chunk-SX7FCSON.js.map → chunk-OTNB2IZL.js.map} +1 -1
- package/dist/{chunk-6YKVIERB.cjs → chunk-RM5DPY5G.cjs} +3 -3
- package/dist/{chunk-6YKVIERB.cjs.map → chunk-RM5DPY5G.cjs.map} +1 -1
- package/dist/index.cjs +302 -302
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -9
- package/dist/ui/index.cjs +137 -137
- package/dist/ui/index.js +2 -2
- package/package.json +3 -3
|
@@ -135,6 +135,12 @@ function pendingRedactions(layer) {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
// src/annotations/store.ts
|
|
138
|
+
var AnnotationStoreOfflineError = class extends Error {
|
|
139
|
+
constructor(message = "You are offline") {
|
|
140
|
+
super(message);
|
|
141
|
+
this.name = "AnnotationStoreOfflineError";
|
|
142
|
+
}
|
|
143
|
+
};
|
|
138
144
|
function createMemoryStore(now = () => (/* @__PURE__ */ new Date()).toISOString()) {
|
|
139
145
|
const layers = /* @__PURE__ */ new Map();
|
|
140
146
|
return {
|
|
@@ -172,6 +178,56 @@ function safeLocalStorage() {
|
|
|
172
178
|
}
|
|
173
179
|
}
|
|
174
180
|
|
|
181
|
+
// src/annotations/merge.ts
|
|
182
|
+
var time = (iso) => {
|
|
183
|
+
const t = Date.parse(iso);
|
|
184
|
+
return Number.isNaN(t) ? 0 : t;
|
|
185
|
+
};
|
|
186
|
+
function mergeReplies(a, b) {
|
|
187
|
+
const byId = /* @__PURE__ */ new Map();
|
|
188
|
+
for (const r of [...a, ...b]) if (!byId.has(r.id)) byId.set(r.id, r);
|
|
189
|
+
return [...byId.values()].sort((x, y) => time(x.createdAt) - time(y.createdAt));
|
|
190
|
+
}
|
|
191
|
+
function newer(mine, theirs) {
|
|
192
|
+
const winner = time(theirs.updatedAt) > time(mine.updatedAt) ? theirs : mine;
|
|
193
|
+
if (mine.kind === "comment" && theirs.kind === "comment" && winner.kind === "comment") {
|
|
194
|
+
const replies = mergeReplies(mine.replies, theirs.replies);
|
|
195
|
+
if (replies.length !== winner.replies.length) return { ...winner, replies };
|
|
196
|
+
}
|
|
197
|
+
return winner;
|
|
198
|
+
}
|
|
199
|
+
function mergeLayers({ base, mine, theirs, deleted }) {
|
|
200
|
+
const baseById = new Map((base?.annotations ?? []).map((a) => [a.id, a]));
|
|
201
|
+
const theirsById = new Map(theirs.annotations.map((a) => [a.id, a]));
|
|
202
|
+
const mineIds = new Set(mine.annotations.map((a) => a.id));
|
|
203
|
+
const out = [];
|
|
204
|
+
for (const m of mine.annotations) {
|
|
205
|
+
if (deleted?.has(m.id)) continue;
|
|
206
|
+
const t = theirsById.get(m.id);
|
|
207
|
+
if (t) {
|
|
208
|
+
out.push(newer(m, t));
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
const b = baseById.get(m.id);
|
|
212
|
+
if (b && time(m.updatedAt) <= time(b.updatedAt)) continue;
|
|
213
|
+
out.push(m);
|
|
214
|
+
}
|
|
215
|
+
for (const t of theirs.annotations) {
|
|
216
|
+
if (mineIds.has(t.id) || deleted?.has(t.id)) continue;
|
|
217
|
+
if (baseById.has(t.id)) continue;
|
|
218
|
+
out.push(t);
|
|
219
|
+
}
|
|
220
|
+
const updatedAt = time(theirs.updatedAt) > time(mine.updatedAt) ? theirs.updatedAt : mine.updatedAt;
|
|
221
|
+
return { ...mine, annotations: out, updatedAt };
|
|
222
|
+
}
|
|
223
|
+
function sameMarks(a, b) {
|
|
224
|
+
if (a.annotations.length !== b.annotations.length) return false;
|
|
225
|
+
const byId = new Map(a.annotations.map((m) => [m.id, m.updatedAt]));
|
|
226
|
+
return b.annotations.every(
|
|
227
|
+
(m) => byId.get(m.id) === m.updatedAt && (m.kind !== "comment" || a.annotations.find((x) => x.id === m.id).replies.length === m.replies.length)
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
175
231
|
// src/annotations/redaction-log.ts
|
|
176
232
|
var REDACTION_LOG_COLUMNS = ["page", "reason", "status", "approved_by", "time"];
|
|
177
233
|
var STATUS = {
|
|
@@ -292,14 +348,37 @@ var REDACTION_REASONS = [
|
|
|
292
348
|
"Commercial",
|
|
293
349
|
"Irrelevant"
|
|
294
350
|
];
|
|
351
|
+
function layerStatusText(controller) {
|
|
352
|
+
if (controller.status === "error") return "Could not be loaded";
|
|
353
|
+
if (controller.readOnly) return "View only";
|
|
354
|
+
if (controller.offline) {
|
|
355
|
+
return controller.dirty ? "Offline \u2014 will save when back online" : "Offline";
|
|
356
|
+
}
|
|
357
|
+
if (controller.error) return "Not saved \u2014 retrying";
|
|
358
|
+
if (controller.saving) return "Saving\u2026";
|
|
359
|
+
if (controller.dirty) return "Unsaved changes";
|
|
360
|
+
return "Saved";
|
|
361
|
+
}
|
|
295
362
|
var AUTOSAVE_MS = 600;
|
|
363
|
+
var RETRY_MS = 1e4;
|
|
296
364
|
var defaultNow = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
297
365
|
var defaultId = () => globalThis.crypto.randomUUID();
|
|
366
|
+
function rebaseHistory(history, sent, remote) {
|
|
367
|
+
const onto = (layer) => layer === sent ? remote : mergeLayers({ base: sent, mine: layer, theirs: remote });
|
|
368
|
+
return {
|
|
369
|
+
present: onto(history.present),
|
|
370
|
+
past: history.past.map(onto),
|
|
371
|
+
future: history.future.map(onto)
|
|
372
|
+
};
|
|
373
|
+
}
|
|
298
374
|
function useAnnotationLayer({
|
|
299
375
|
documentId,
|
|
300
376
|
store,
|
|
301
377
|
author,
|
|
302
378
|
autosaveMs = AUTOSAVE_MS,
|
|
379
|
+
readOnly: readOnlyProp = false,
|
|
380
|
+
online = true,
|
|
381
|
+
pullMs = 0,
|
|
303
382
|
now = defaultNow,
|
|
304
383
|
makeId = defaultId
|
|
305
384
|
}) {
|
|
@@ -310,12 +389,17 @@ function useAnnotationLayer({
|
|
|
310
389
|
const [status, setStatus] = react.useState("loading");
|
|
311
390
|
const [error, setError] = react.useState(null);
|
|
312
391
|
const [saving, setSaving] = react.useState(false);
|
|
392
|
+
const [offlineFailure, setOfflineFailure] = react.useState(false);
|
|
393
|
+
const [storeReadOnly, setStoreReadOnly] = react.useState(false);
|
|
313
394
|
const [tool, setToolState] = react.useState("select");
|
|
314
395
|
const [settings, setSettingsState] = react.useState(DEFAULT_SETTINGS);
|
|
315
396
|
const [selectedId, setSelectedId] = react.useState(null);
|
|
397
|
+
const readOnly = readOnlyProp || storeReadOnly;
|
|
316
398
|
const historyRef = react.useRef(history);
|
|
317
399
|
const savedRef = react.useRef(null);
|
|
318
400
|
const timerRef = react.useRef(void 0);
|
|
401
|
+
const retryRef = react.useRef(void 0);
|
|
402
|
+
const savingRef = react.useRef(false);
|
|
319
403
|
const docRef = react.useRef(documentId);
|
|
320
404
|
const storeRef = react.useRef(store);
|
|
321
405
|
storeRef.current = store;
|
|
@@ -323,10 +407,24 @@ function useAnnotationLayer({
|
|
|
323
407
|
nowRef.current = now;
|
|
324
408
|
const idRef = react.useRef(makeId);
|
|
325
409
|
idRef.current = makeId;
|
|
410
|
+
const readOnlyRef = react.useRef(readOnly);
|
|
411
|
+
readOnlyRef.current = readOnly;
|
|
412
|
+
const onlineRef = react.useRef(online);
|
|
413
|
+
onlineRef.current = online;
|
|
414
|
+
const autosaveMsRef = react.useRef(autosaveMs);
|
|
415
|
+
autosaveMsRef.current = autosaveMs;
|
|
326
416
|
const commit = react.useCallback((next) => {
|
|
327
417
|
historyRef.current = next;
|
|
328
418
|
setHistory(next);
|
|
329
419
|
}, []);
|
|
420
|
+
const adoptRemote = react.useCallback(
|
|
421
|
+
(sent, remote) => {
|
|
422
|
+
commit(rebaseHistory(historyRef.current, sent, remote));
|
|
423
|
+
savedRef.current = remote;
|
|
424
|
+
setSavedLayer(remote);
|
|
425
|
+
},
|
|
426
|
+
[commit]
|
|
427
|
+
);
|
|
330
428
|
react.useEffect(() => {
|
|
331
429
|
docRef.current = documentId;
|
|
332
430
|
let cancelled = false;
|
|
@@ -334,12 +432,14 @@ function useAnnotationLayer({
|
|
|
334
432
|
setError(null);
|
|
335
433
|
setSelectedId(null);
|
|
336
434
|
setSavedLayer(null);
|
|
435
|
+
setStoreReadOnly(false);
|
|
337
436
|
savedRef.current = null;
|
|
338
437
|
commit(createHistory(chunkSSOPIPEX_cjs.emptyLayer(documentId, nowRef.current())));
|
|
339
438
|
storeRef.current.load(documentId).then((layer) => {
|
|
340
439
|
if (cancelled) return;
|
|
341
440
|
savedRef.current = layer;
|
|
342
441
|
setSavedLayer(layer);
|
|
442
|
+
setStoreReadOnly(storeRef.current.canEdit?.(documentId) === false);
|
|
343
443
|
commit(createHistory(layer));
|
|
344
444
|
setStatus("ready");
|
|
345
445
|
}).catch((e) => {
|
|
@@ -350,37 +450,88 @@ function useAnnotationLayer({
|
|
|
350
450
|
return () => {
|
|
351
451
|
cancelled = true;
|
|
352
452
|
clearTimeout(timerRef.current);
|
|
453
|
+
clearTimeout(retryRef.current);
|
|
353
454
|
const layer = historyRef.current.present;
|
|
354
|
-
if (savedRef.current !== null && layer !== savedRef.current && layer.documentId === documentId) {
|
|
455
|
+
if (savedRef.current !== null && layer !== savedRef.current && layer.documentId === documentId && !readOnlyRef.current) {
|
|
355
456
|
storeRef.current.save(layer).catch((e) => console.error("Annotations could not be saved", e));
|
|
356
457
|
}
|
|
357
458
|
};
|
|
358
459
|
}, [documentId, commit]);
|
|
359
460
|
const save = react.useCallback(async () => {
|
|
360
461
|
clearTimeout(timerRef.current);
|
|
462
|
+
clearTimeout(retryRef.current);
|
|
361
463
|
const layer = historyRef.current.present;
|
|
362
|
-
if (layer === savedRef.current) return;
|
|
464
|
+
if (layer === savedRef.current || savedRef.current === null) return;
|
|
465
|
+
if (readOnlyRef.current || savingRef.current) return;
|
|
466
|
+
if (!onlineRef.current) return;
|
|
467
|
+
savingRef.current = true;
|
|
363
468
|
setSaving(true);
|
|
469
|
+
let failed = false;
|
|
364
470
|
try {
|
|
365
|
-
await storeRef.current.save(layer);
|
|
471
|
+
const stored = await storeRef.current.save(layer);
|
|
366
472
|
if (layer.documentId === docRef.current) {
|
|
367
|
-
savedRef.current = layer;
|
|
368
|
-
setSavedLayer(layer);
|
|
369
473
|
setError(null);
|
|
474
|
+
setOfflineFailure(false);
|
|
475
|
+
if (stored && stored !== layer) {
|
|
476
|
+
adoptRemote(layer, stored);
|
|
477
|
+
} else {
|
|
478
|
+
savedRef.current = layer;
|
|
479
|
+
setSavedLayer(layer);
|
|
480
|
+
}
|
|
370
481
|
}
|
|
371
482
|
} catch (e) {
|
|
372
|
-
|
|
483
|
+
failed = true;
|
|
484
|
+
if (e instanceof AnnotationStoreOfflineError) {
|
|
485
|
+
setOfflineFailure(true);
|
|
486
|
+
} else {
|
|
487
|
+
setError(e instanceof Error ? e.message : "The annotations could not be saved");
|
|
488
|
+
}
|
|
489
|
+
retryRef.current = setTimeout(() => void saveRef.current(), RETRY_MS);
|
|
373
490
|
} finally {
|
|
491
|
+
savingRef.current = false;
|
|
374
492
|
setSaving(false);
|
|
493
|
+
if (!failed && historyRef.current.present !== savedRef.current) {
|
|
494
|
+
timerRef.current = setTimeout(() => void saveRef.current(), autosaveMsRef.current);
|
|
495
|
+
}
|
|
375
496
|
}
|
|
376
|
-
}, []);
|
|
497
|
+
}, [adoptRemote]);
|
|
498
|
+
const saveRef = react.useRef(save);
|
|
499
|
+
saveRef.current = save;
|
|
377
500
|
const present = history.present;
|
|
378
501
|
const dirty = status === "ready" && present !== savedLayer;
|
|
379
502
|
react.useEffect(() => {
|
|
380
|
-
if (!dirty) return;
|
|
503
|
+
if (!dirty || !online || readOnly) return;
|
|
381
504
|
timerRef.current = setTimeout(() => void save(), autosaveMs);
|
|
382
505
|
return () => clearTimeout(timerRef.current);
|
|
383
|
-
}, [dirty, present, autosaveMs, save]);
|
|
506
|
+
}, [dirty, present, autosaveMs, save, online, readOnly]);
|
|
507
|
+
react.useEffect(() => {
|
|
508
|
+
if (online) setOfflineFailure(false);
|
|
509
|
+
if (online && savedRef.current !== null && historyRef.current.present !== savedRef.current) {
|
|
510
|
+
void save();
|
|
511
|
+
}
|
|
512
|
+
}, [online, save]);
|
|
513
|
+
const pull = react.useCallback(async () => {
|
|
514
|
+
const s = storeRef.current;
|
|
515
|
+
const base = savedRef.current;
|
|
516
|
+
if (!s.pull || !base || savingRef.current || !onlineRef.current) return;
|
|
517
|
+
if (historyRef.current.present !== base) return;
|
|
518
|
+
try {
|
|
519
|
+
const remote = await s.pull(docRef.current);
|
|
520
|
+
if (!remote || remote.documentId !== docRef.current || savedRef.current !== base) return;
|
|
521
|
+
adoptRemote(base, remote);
|
|
522
|
+
} catch {
|
|
523
|
+
}
|
|
524
|
+
}, [adoptRemote]);
|
|
525
|
+
react.useEffect(() => {
|
|
526
|
+
if (!pullMs || status !== "ready") return;
|
|
527
|
+
const timer = setInterval(() => void pull(), pullMs);
|
|
528
|
+
const onFocus = () => void pull();
|
|
529
|
+
window.addEventListener("focus", onFocus);
|
|
530
|
+
return () => {
|
|
531
|
+
clearInterval(timer);
|
|
532
|
+
window.removeEventListener("focus", onFocus);
|
|
533
|
+
};
|
|
534
|
+
}, [pullMs, status, pull]);
|
|
384
535
|
react.useEffect(() => {
|
|
385
536
|
const flush = () => void save();
|
|
386
537
|
const onVisibility = () => {
|
|
@@ -395,6 +546,7 @@ function useAnnotationLayer({
|
|
|
395
546
|
}, [save]);
|
|
396
547
|
const dispatch = react.useCallback(
|
|
397
548
|
(action) => {
|
|
549
|
+
if (readOnlyRef.current) return false;
|
|
398
550
|
try {
|
|
399
551
|
commit(applyAction(historyRef.current, action));
|
|
400
552
|
setError(null);
|
|
@@ -413,6 +565,7 @@ function useAnnotationLayer({
|
|
|
413
565
|
},
|
|
414
566
|
[author]
|
|
415
567
|
);
|
|
568
|
+
const offline = !online || offlineFailure;
|
|
416
569
|
const controller = react.useMemo(() => {
|
|
417
570
|
const exists = (id) => id !== null && present.annotations.some((a) => a.id === id) ? id : null;
|
|
418
571
|
return {
|
|
@@ -421,9 +574,12 @@ function useAnnotationLayer({
|
|
|
421
574
|
error,
|
|
422
575
|
saving,
|
|
423
576
|
dirty,
|
|
577
|
+
offline,
|
|
578
|
+
readOnly,
|
|
424
579
|
author,
|
|
425
|
-
tool,
|
|
580
|
+
tool: readOnly ? "select" : tool,
|
|
426
581
|
setTool: (next) => {
|
|
582
|
+
if (readOnly && next !== "select") return;
|
|
427
583
|
setToolState(next);
|
|
428
584
|
if (next !== "select") setSelectedId(null);
|
|
429
585
|
},
|
|
@@ -458,10 +614,14 @@ function useAnnotationLayer({
|
|
|
458
614
|
});
|
|
459
615
|
},
|
|
460
616
|
resolve: (id, resolved) => void dispatch({ type: "resolve", id, resolved, now: nowRef.current() }),
|
|
461
|
-
undo: () =>
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
617
|
+
undo: () => {
|
|
618
|
+
if (!readOnly) commit(undo(historyRef.current));
|
|
619
|
+
},
|
|
620
|
+
redo: () => {
|
|
621
|
+
if (!readOnly) commit(redo(historyRef.current));
|
|
622
|
+
},
|
|
623
|
+
canUndo: !readOnly && canUndo(history),
|
|
624
|
+
canRedo: !readOnly && canRedo(history),
|
|
465
625
|
flush: save
|
|
466
626
|
};
|
|
467
627
|
}, [
|
|
@@ -471,6 +631,8 @@ function useAnnotationLayer({
|
|
|
471
631
|
error,
|
|
472
632
|
saving,
|
|
473
633
|
dirty,
|
|
634
|
+
offline,
|
|
635
|
+
readOnly,
|
|
474
636
|
author,
|
|
475
637
|
tool,
|
|
476
638
|
settings,
|
|
@@ -731,7 +893,8 @@ function AnnotationPageOverlay({
|
|
|
731
893
|
const [openComment, setOpenComment] = react.useState(null);
|
|
732
894
|
const marks = controller.layer.annotations.filter((a) => a.page === pageNumber);
|
|
733
895
|
const hasText = useHasTextLayer(rootRef);
|
|
734
|
-
const
|
|
896
|
+
const readOnly = controller.readOnly;
|
|
897
|
+
const drawing = !readOnly && (DRAW_TOOLS.includes(tool) || TEXT_TOOLS.includes(tool) && !hasText);
|
|
735
898
|
react.useEffect(() => {
|
|
736
899
|
if (openComment && selectedId !== openComment) setOpenComment(null);
|
|
737
900
|
}, [selectedId, openComment]);
|
|
@@ -828,7 +991,7 @@ function AnnotationPageOverlay({
|
|
|
828
991
|
};
|
|
829
992
|
const beginDrag = (e, a, mode) => {
|
|
830
993
|
const origin = singleRect(a);
|
|
831
|
-
if (!origin || e.button !== 0) return;
|
|
994
|
+
if (!origin || e.button !== 0 || readOnly) return;
|
|
832
995
|
e.stopPropagation();
|
|
833
996
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
834
997
|
setDrag({
|
|
@@ -859,7 +1022,7 @@ function AnnotationPageOverlay({
|
|
|
859
1022
|
if (drag.moved) controller.update(a.id, patchForRect(a, drag.rect));
|
|
860
1023
|
setDrag(null);
|
|
861
1024
|
};
|
|
862
|
-
const interactive = (a) => tool === "select" || tool === "comment" && a.kind === "comment";
|
|
1025
|
+
const interactive = (a) => readOnly ? a.kind === "comment" : tool === "select" || tool === "comment" && a.kind === "comment";
|
|
863
1026
|
const selected = marks.find((a) => a.id === selectedId);
|
|
864
1027
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
865
1028
|
"div",
|
|
@@ -907,7 +1070,7 @@ function AnnotationPageOverlay({
|
|
|
907
1070
|
},
|
|
908
1071
|
a.id
|
|
909
1072
|
)),
|
|
910
|
-
selected && tool === "select" && singleRect(selected) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1073
|
+
selected && tool === "select" && !readOnly && singleRect(selected) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
911
1074
|
Handles,
|
|
912
1075
|
{
|
|
913
1076
|
rect: drag?.id === selected.id ? drag.rect : singleRect(selected),
|
|
@@ -916,7 +1079,7 @@ function AnnotationPageOverlay({
|
|
|
916
1079
|
onPointerUp: () => endDrag(selected)
|
|
917
1080
|
}
|
|
918
1081
|
),
|
|
919
|
-
selected && tool === "select" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1082
|
+
selected && tool === "select" && !readOnly && /* @__PURE__ */ jsxRuntime.jsx(
|
|
920
1083
|
ActionBar,
|
|
921
1084
|
{
|
|
922
1085
|
annotation: selected,
|
|
@@ -1233,14 +1396,15 @@ function CommentPopover({
|
|
|
1233
1396
|
}) {
|
|
1234
1397
|
const [body, setBody] = react.useState(a.body);
|
|
1235
1398
|
const [reply, setReply] = react.useState("");
|
|
1236
|
-
const
|
|
1399
|
+
const readOnly = controller.readOnly;
|
|
1400
|
+
const mine = a.author === controller.author && !readOnly;
|
|
1237
1401
|
react.useEffect(() => setBody(a.body), [a.body]);
|
|
1238
1402
|
const commitBody = () => {
|
|
1239
1403
|
if (mine && body !== a.body) controller.update(a.id, { body });
|
|
1240
1404
|
};
|
|
1241
1405
|
const close = () => {
|
|
1242
1406
|
commitBody();
|
|
1243
|
-
if (body.trim() === "" && a.replies.length === 0) controller.remove(a.id);
|
|
1407
|
+
if (!readOnly && body.trim() === "" && a.replies.length === 0) controller.remove(a.id);
|
|
1244
1408
|
onClose();
|
|
1245
1409
|
};
|
|
1246
1410
|
const sendReply = () => {
|
|
@@ -1311,7 +1475,7 @@ function CommentPopover({
|
|
|
1311
1475
|
] }, r.id))
|
|
1312
1476
|
}
|
|
1313
1477
|
),
|
|
1314
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex gap-1", children: [
|
|
1478
|
+
!readOnly && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex gap-1", children: [
|
|
1315
1479
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1316
1480
|
"input",
|
|
1317
1481
|
{
|
|
@@ -1340,7 +1504,7 @@ function CommentPopover({
|
|
|
1340
1504
|
}
|
|
1341
1505
|
)
|
|
1342
1506
|
] }),
|
|
1343
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex items-center justify-between", children: [
|
|
1507
|
+
readOnly ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 text-xs text-muted-foreground", "data-testid": "annotation-comment-status", children: a.resolved ? "Resolved" : "Open" }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex items-center justify-between", children: [
|
|
1344
1508
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1345
1509
|
"button",
|
|
1346
1510
|
{
|
|
@@ -1427,14 +1591,20 @@ function Swatches({
|
|
|
1427
1591
|
c
|
|
1428
1592
|
)) });
|
|
1429
1593
|
}
|
|
1430
|
-
function AnnotationToolbar({
|
|
1594
|
+
function AnnotationToolbar({
|
|
1595
|
+
controller,
|
|
1596
|
+
onFreeze,
|
|
1597
|
+
actions,
|
|
1598
|
+
className
|
|
1599
|
+
}) {
|
|
1431
1600
|
useTextSelectionMarks(controller);
|
|
1432
1601
|
useAnnotationShortcuts(controller);
|
|
1433
1602
|
const { tool, settings } = controller;
|
|
1434
1603
|
const pending = pendingRedactions(controller.layer);
|
|
1435
1604
|
const redactionCount = controller.layer.annotations.filter((a) => a.kind === "redaction").length;
|
|
1436
1605
|
const colored = tool === "highlight" || tool === "box" || tool === "stamp";
|
|
1437
|
-
const status = controller
|
|
1606
|
+
const status = layerStatusText(controller);
|
|
1607
|
+
const editable = !controller.readOnly;
|
|
1438
1608
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1439
1609
|
"div",
|
|
1440
1610
|
{
|
|
@@ -1446,7 +1616,7 @@ function AnnotationToolbar({ controller, onFreeze, className }) {
|
|
|
1446
1616
|
className
|
|
1447
1617
|
),
|
|
1448
1618
|
children: [
|
|
1449
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1", role: "group", "aria-label": "Tool", children: TOOLS.map(({ tool: t, label, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1619
|
+
editable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1", role: "group", "aria-label": "Tool", children: TOOLS.map(({ tool: t, label, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1450
1620
|
chunkGXQO3IJC_cjs.Button,
|
|
1451
1621
|
{
|
|
1452
1622
|
type: "button",
|
|
@@ -1461,7 +1631,7 @@ function AnnotationToolbar({ controller, onFreeze, className }) {
|
|
|
1461
1631
|
},
|
|
1462
1632
|
t
|
|
1463
1633
|
)) }),
|
|
1464
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", role: "group", "aria-label": "History", children: [
|
|
1634
|
+
editable && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", role: "group", "aria-label": "History", children: [
|
|
1465
1635
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1466
1636
|
chunkGXQO3IJC_cjs.Button,
|
|
1467
1637
|
{
|
|
@@ -1491,7 +1661,7 @@ function AnnotationToolbar({ controller, onFreeze, className }) {
|
|
|
1491
1661
|
}
|
|
1492
1662
|
)
|
|
1493
1663
|
] }),
|
|
1494
|
-
colored && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1664
|
+
editable && colored && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1495
1665
|
Swatches,
|
|
1496
1666
|
{
|
|
1497
1667
|
label: "Colour",
|
|
@@ -1500,7 +1670,7 @@ function AnnotationToolbar({ controller, onFreeze, className }) {
|
|
|
1500
1670
|
onChange: (c) => controller.setSettings({ colors: { ...settings.colors, [tool]: c } })
|
|
1501
1671
|
}
|
|
1502
1672
|
),
|
|
1503
|
-
tool === "stamp" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1673
|
+
editable && tool === "stamp" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1504
1674
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1505
1675
|
"input",
|
|
1506
1676
|
{
|
|
@@ -1515,7 +1685,7 @@ function AnnotationToolbar({ controller, onFreeze, className }) {
|
|
|
1515
1685
|
),
|
|
1516
1686
|
/* @__PURE__ */ jsxRuntime.jsx("datalist", { id: "annotation-stamp-presets", children: STAMP_PRESETS.map((s) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: s }, s)) })
|
|
1517
1687
|
] }),
|
|
1518
|
-
(tool === "redact-text" || tool === "redact-area") && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1688
|
+
editable && (tool === "redact-text" || tool === "redact-area") && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1519
1689
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1520
1690
|
"input",
|
|
1521
1691
|
{
|
|
@@ -1535,36 +1705,38 @@ function AnnotationToolbar({ controller, onFreeze, className }) {
|
|
|
1535
1705
|
pending.length,
|
|
1536
1706
|
" pending"
|
|
1537
1707
|
] }),
|
|
1538
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1708
|
+
editable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1709
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1710
|
+
chunkGXQO3IJC_cjs.Button,
|
|
1711
|
+
{
|
|
1712
|
+
type: "button",
|
|
1713
|
+
size: "sm",
|
|
1714
|
+
variant: "outline",
|
|
1715
|
+
disabled: pending.length === 0,
|
|
1716
|
+
"data-testid": "annotation-approve-all",
|
|
1717
|
+
onClick: () => controller.setRedactionStatus(
|
|
1718
|
+
pending.map((a) => a.id),
|
|
1719
|
+
"approved"
|
|
1720
|
+
),
|
|
1721
|
+
children: "Approve all"
|
|
1722
|
+
}
|
|
1723
|
+
),
|
|
1724
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1725
|
+
chunkGXQO3IJC_cjs.Button,
|
|
1726
|
+
{
|
|
1727
|
+
type: "button",
|
|
1728
|
+
size: "sm",
|
|
1729
|
+
variant: "outline",
|
|
1730
|
+
disabled: pending.length === 0,
|
|
1731
|
+
"data-testid": "annotation-reject-all",
|
|
1732
|
+
onClick: () => controller.setRedactionStatus(
|
|
1733
|
+
pending.map((a) => a.id),
|
|
1734
|
+
"rejected"
|
|
1735
|
+
),
|
|
1736
|
+
children: "Reject all"
|
|
1737
|
+
}
|
|
1738
|
+
)
|
|
1739
|
+
] })
|
|
1568
1740
|
] }),
|
|
1569
1741
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex items-center gap-3 text-xs text-muted-foreground", children: [
|
|
1570
1742
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1572,11 +1744,13 @@ function AnnotationToolbar({ controller, onFreeze, className }) {
|
|
|
1572
1744
|
{
|
|
1573
1745
|
"data-testid": "annotation-status",
|
|
1574
1746
|
role: "status",
|
|
1575
|
-
|
|
1747
|
+
"data-state": controller.readOnly ? "readonly" : controller.offline ? "offline" : controller.error ? "error" : controller.saving ? "saving" : controller.dirty ? "dirty" : "saved",
|
|
1748
|
+
className: chunkS6A6FSG7_cjs.cn(controller.error && !controller.offline && "text-destructive"),
|
|
1576
1749
|
title: controller.error ?? void 0,
|
|
1577
1750
|
children: status
|
|
1578
1751
|
}
|
|
1579
1752
|
),
|
|
1753
|
+
actions,
|
|
1580
1754
|
onFreeze && /* @__PURE__ */ jsxRuntime.jsxs(chunkGXQO3IJC_cjs.Button, { type: "button", size: "sm", "data-testid": "annotation-freeze", onClick: onFreeze, children: [
|
|
1581
1755
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Snowflake, { size: 14 }),
|
|
1582
1756
|
"Freeze copy"
|
|
@@ -2128,7 +2302,9 @@ Object.defineProperty(exports, "parseLayer", {
|
|
|
2128
2302
|
enumerable: true,
|
|
2129
2303
|
get: function () { return chunkSSOPIPEX_cjs.parseLayer; }
|
|
2130
2304
|
});
|
|
2305
|
+
exports.AUTOSAVE_MS = AUTOSAVE_MS;
|
|
2131
2306
|
exports.AnnotationPageOverlay = AnnotationPageOverlay;
|
|
2307
|
+
exports.AnnotationStoreOfflineError = AnnotationStoreOfflineError;
|
|
2132
2308
|
exports.AnnotationToolbar = AnnotationToolbar;
|
|
2133
2309
|
exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
|
|
2134
2310
|
exports.FreezeDialog = FreezeDialog;
|
|
@@ -2137,6 +2313,7 @@ exports.MARK_COLORS = MARK_COLORS;
|
|
|
2137
2313
|
exports.ProductionDialog = ProductionDialog;
|
|
2138
2314
|
exports.REDACTION_LOG_COLUMNS = REDACTION_LOG_COLUMNS;
|
|
2139
2315
|
exports.REDACTION_REASONS = REDACTION_REASONS;
|
|
2316
|
+
exports.RETRY_MS = RETRY_MS;
|
|
2140
2317
|
exports.STAMP_PRESETS = STAMP_PRESETS;
|
|
2141
2318
|
exports.annotationsOnPage = annotationsOnPage;
|
|
2142
2319
|
exports.applyAction = applyAction;
|
|
@@ -2150,6 +2327,8 @@ exports.dragRect = dragRect;
|
|
|
2150
2327
|
exports.dragToNorm = dragToNorm;
|
|
2151
2328
|
exports.intersects = intersects;
|
|
2152
2329
|
exports.isTooSmall = isTooSmall;
|
|
2330
|
+
exports.layerStatusText = layerStatusText;
|
|
2331
|
+
exports.mergeLayers = mergeLayers;
|
|
2153
2332
|
exports.mergeLineRects = mergeLineRects;
|
|
2154
2333
|
exports.moveItem = moveItem;
|
|
2155
2334
|
exports.patchForRect = patchForRect;
|
|
@@ -2160,6 +2339,7 @@ exports.redactionLogCsv = redactionLogCsv;
|
|
|
2160
2339
|
exports.redactionLogRows = redactionLogRows;
|
|
2161
2340
|
exports.redo = redo;
|
|
2162
2341
|
exports.reduceLayer = reduceLayer;
|
|
2342
|
+
exports.sameMarks = sameMarks;
|
|
2163
2343
|
exports.selectionToPageMarks = selectionToPageMarks;
|
|
2164
2344
|
exports.singleRect = singleRect;
|
|
2165
2345
|
exports.toNorm = toNorm;
|