@semiont/react-ui 0.2.33-build.84 → 0.2.33-build.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +14 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/resource/AnnotateView.tsx +6 -28
- package/src/features/resource-viewer/__tests__/ResourceMutations.test.tsx +300 -0
- package/src/features/resource-viewer/__tests__/ResourceViewerPage.test.tsx +2 -0
- package/src/features/resource-viewer/components/ResourceViewerPage.tsx +11 -11
- package/src/styles/core/checkboxes.css +8 -0
package/dist/index.mjs
CHANGED
|
@@ -30417,21 +30417,9 @@ function ProposeEntitiesModal({
|
|
|
30417
30417
|
|
|
30418
30418
|
// src/components/resource/AnnotateView.tsx
|
|
30419
30419
|
import { useRef as useRef12, useEffect as useEffect18, useCallback as useCallback12, lazy, Suspense } from "react";
|
|
30420
|
-
import { getTextPositionSelector, getTextQuoteSelector, getTargetSelector, getMimeCategory, isPdfMimeType as isPdfMimeType2, resourceUri as toResourceUri } from "@semiont/api-client";
|
|
30421
|
-
import { findTextWithContext } from "@semiont/api-client";
|
|
30420
|
+
import { getTextPositionSelector, getTextQuoteSelector, getTargetSelector, getMimeCategory, isPdfMimeType as isPdfMimeType2, resourceUri as toResourceUri, extractContext, findTextWithContext } from "@semiont/api-client";
|
|
30422
30421
|
import { jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
30423
30422
|
var PdfAnnotationCanvas = lazy(() => import("./PdfAnnotationCanvas.client-FGV33CWN.mjs").then((mod) => ({ default: mod.PdfAnnotationCanvas })));
|
|
30424
|
-
function extractContext(content4, start2, end) {
|
|
30425
|
-
const CONTEXT_LENGTH = 32;
|
|
30426
|
-
const result = {};
|
|
30427
|
-
if (start2 > 0) {
|
|
30428
|
-
result.prefix = content4.substring(Math.max(0, start2 - CONTEXT_LENGTH), start2);
|
|
30429
|
-
}
|
|
30430
|
-
if (end < content4.length) {
|
|
30431
|
-
result.suffix = content4.substring(end, Math.min(content4.length, end + CONTEXT_LENGTH));
|
|
30432
|
-
}
|
|
30433
|
-
return result;
|
|
30434
|
-
}
|
|
30435
30423
|
function segmentTextWithAnnotations(content4, annotations) {
|
|
30436
30424
|
if (!content4) {
|
|
30437
30425
|
return [{ exact: "", start: 0, end: 0 }];
|
|
@@ -30441,12 +30429,14 @@ function segmentTextWithAnnotations(content4, annotations) {
|
|
|
30441
30429
|
const posSelector = getTextPositionSelector(targetSelector);
|
|
30442
30430
|
const quoteSelector = targetSelector ? getTextQuoteSelector(targetSelector) : null;
|
|
30443
30431
|
let position4;
|
|
30444
|
-
if (quoteSelector
|
|
30432
|
+
if (quoteSelector) {
|
|
30445
30433
|
position4 = findTextWithContext(
|
|
30446
30434
|
content4,
|
|
30447
30435
|
quoteSelector.exact,
|
|
30448
30436
|
quoteSelector.prefix,
|
|
30449
|
-
quoteSelector.suffix
|
|
30437
|
+
quoteSelector.suffix,
|
|
30438
|
+
posSelector?.start
|
|
30439
|
+
// Position hint for fuzzy matching
|
|
30450
30440
|
);
|
|
30451
30441
|
}
|
|
30452
30442
|
const start2 = position4?.start ?? posSelector?.start ?? 0;
|
|
@@ -57296,38 +57286,36 @@ function ResourceViewerPage({
|
|
|
57296
57286
|
console.error("[RealTime] Event stream error:", error);
|
|
57297
57287
|
}, [])
|
|
57298
57288
|
});
|
|
57289
|
+
const updateMutation = resources.update.useMutation();
|
|
57290
|
+
const generateCloneTokenMutation = resources.generateCloneToken.useMutation();
|
|
57299
57291
|
const handleResourceArchive = useCallback35(async () => {
|
|
57300
57292
|
try {
|
|
57301
|
-
await
|
|
57293
|
+
await updateMutation.mutateAsync({ rUri, data: { archived: true } });
|
|
57302
57294
|
await refetchDocument();
|
|
57303
|
-
showSuccess("Document archived");
|
|
57304
57295
|
} catch (err) {
|
|
57305
57296
|
console.error("Failed to archive document:", err);
|
|
57306
57297
|
showError("Failed to archive document");
|
|
57307
57298
|
}
|
|
57308
|
-
}, [
|
|
57299
|
+
}, [updateMutation, rUri, refetchDocument, showError]);
|
|
57309
57300
|
const handleResourceUnarchive = useCallback35(async () => {
|
|
57310
57301
|
try {
|
|
57311
|
-
await
|
|
57302
|
+
await updateMutation.mutateAsync({ rUri, data: { archived: false } });
|
|
57312
57303
|
await refetchDocument();
|
|
57313
|
-
showSuccess("Document unarchived");
|
|
57314
57304
|
} catch (err) {
|
|
57315
57305
|
console.error("Failed to unarchive document:", err);
|
|
57316
57306
|
showError("Failed to unarchive document");
|
|
57317
57307
|
}
|
|
57318
|
-
}, [
|
|
57308
|
+
}, [updateMutation, rUri, refetchDocument, showError]);
|
|
57319
57309
|
const handleResourceClone = useCallback35(async () => {
|
|
57320
57310
|
try {
|
|
57321
|
-
const result2 = await
|
|
57311
|
+
const result2 = await generateCloneTokenMutation.mutateAsync(rUri);
|
|
57322
57312
|
const token = result2.token;
|
|
57323
|
-
|
|
57324
|
-
await navigator.clipboard.writeText(cloneUrl);
|
|
57325
|
-
showSuccess("Clone link copied to clipboard");
|
|
57313
|
+
eventBus.emit("navigation:router-push", { path: `/know/compose?mode=clone&token=${token}`, reason: "clone" });
|
|
57326
57314
|
} catch (err) {
|
|
57327
57315
|
console.error("Failed to generate clone token:", err);
|
|
57328
57316
|
showError("Failed to generate clone link");
|
|
57329
57317
|
}
|
|
57330
|
-
}, [
|
|
57318
|
+
}, [generateCloneTokenMutation, rUri, showError]);
|
|
57331
57319
|
const handleAnnotationSparkle = useCallback35(({ annotationId }) => {
|
|
57332
57320
|
triggerSparkleAnimation(annotationId);
|
|
57333
57321
|
}, [triggerSparkleAnimation]);
|