@semiont/react-ui 0.2.35-build.96 → 0.2.35-build.97
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.d.mts +83 -31
- package/dist/index.mjs +475 -512
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/resource/BrowseView.tsx +62 -51
- package/src/components/resource/ResourceViewer.tsx +6 -4
- package/src/components/resource/__tests__/BrowseView.test.tsx +8 -8
- package/src/features/resource-viewer/components/ResourceViewerPage.tsx +19 -17
package/dist/index.mjs
CHANGED
|
@@ -17353,402 +17353,154 @@ function saveSelectedShapeForSelectorType(selectorType, shape) {
|
|
|
17353
17353
|
}
|
|
17354
17354
|
}
|
|
17355
17355
|
|
|
17356
|
-
//
|
|
17357
|
-
|
|
17358
|
-
|
|
17359
|
-
|
|
17360
|
-
|
|
17361
|
-
|
|
17362
|
-
|
|
17363
|
-
* (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
|
|
17364
|
-
* ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
|
|
17365
|
-
* ((test?: Test) => Check)
|
|
17366
|
-
* )}
|
|
17367
|
-
*/
|
|
17368
|
-
/**
|
|
17369
|
-
* @param {Test} [test]
|
|
17370
|
-
* @returns {Check}
|
|
17371
|
-
*/
|
|
17372
|
-
(function(test) {
|
|
17373
|
-
if (test === null || test === void 0) {
|
|
17374
|
-
return ok;
|
|
17375
|
-
}
|
|
17376
|
-
if (typeof test === "function") {
|
|
17377
|
-
return castFactory(test);
|
|
17378
|
-
}
|
|
17379
|
-
if (typeof test === "object") {
|
|
17380
|
-
return Array.isArray(test) ? anyFactory(test) : (
|
|
17381
|
-
// Cast because `ReadonlyArray` goes into the above but `isArray`
|
|
17382
|
-
// narrows to `Array`.
|
|
17383
|
-
propertiesFactory(
|
|
17384
|
-
/** @type {Props} */
|
|
17385
|
-
test
|
|
17386
|
-
)
|
|
17387
|
-
);
|
|
17388
|
-
}
|
|
17389
|
-
if (typeof test === "string") {
|
|
17390
|
-
return typeFactory(test);
|
|
17391
|
-
}
|
|
17392
|
-
throw new Error("Expected function, string, or object as test");
|
|
17393
|
-
})
|
|
17394
|
-
);
|
|
17395
|
-
function anyFactory(tests) {
|
|
17396
|
-
const checks2 = [];
|
|
17397
|
-
let index2 = -1;
|
|
17398
|
-
while (++index2 < tests.length) {
|
|
17399
|
-
checks2[index2] = convert(tests[index2]);
|
|
17356
|
+
// src/lib/annotation-overlay.ts
|
|
17357
|
+
import { getTextPositionSelector, getTargetSelector, getExactText, getBodySource as getBodySource2 } from "@semiont/api-client";
|
|
17358
|
+
function buildSourceToRenderedMap(markdownSource, container) {
|
|
17359
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_TEXT);
|
|
17360
|
+
let renderedText = "";
|
|
17361
|
+
while (walker.nextNode()) {
|
|
17362
|
+
renderedText += walker.currentNode.textContent ?? "";
|
|
17400
17363
|
}
|
|
17401
|
-
|
|
17402
|
-
|
|
17403
|
-
|
|
17404
|
-
|
|
17405
|
-
|
|
17406
|
-
|
|
17407
|
-
|
|
17408
|
-
|
|
17409
|
-
}
|
|
17410
|
-
|
|
17411
|
-
const checkAsRecord = (
|
|
17412
|
-
/** @type {Record<string, unknown>} */
|
|
17413
|
-
check
|
|
17414
|
-
);
|
|
17415
|
-
return castFactory(all2);
|
|
17416
|
-
function all2(node2) {
|
|
17417
|
-
const nodeAsRecord = (
|
|
17418
|
-
/** @type {Record<string, unknown>} */
|
|
17419
|
-
/** @type {unknown} */
|
|
17420
|
-
node2
|
|
17421
|
-
);
|
|
17422
|
-
let key;
|
|
17423
|
-
for (key in check) {
|
|
17424
|
-
if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
|
|
17364
|
+
const map3 = /* @__PURE__ */ new Map();
|
|
17365
|
+
let renderedPos = 0;
|
|
17366
|
+
let sourcePos = 0;
|
|
17367
|
+
while (sourcePos < markdownSource.length && renderedPos < renderedText.length) {
|
|
17368
|
+
if (markdownSource[sourcePos] === renderedText[renderedPos]) {
|
|
17369
|
+
map3.set(sourcePos, renderedPos);
|
|
17370
|
+
renderedPos++;
|
|
17371
|
+
sourcePos++;
|
|
17372
|
+
} else {
|
|
17373
|
+
sourcePos++;
|
|
17425
17374
|
}
|
|
17426
|
-
return true;
|
|
17427
17375
|
}
|
|
17428
|
-
|
|
17429
|
-
|
|
17430
|
-
|
|
17431
|
-
function type(node2) {
|
|
17432
|
-
return node2 && node2.type === check;
|
|
17433
|
-
}
|
|
17434
|
-
}
|
|
17435
|
-
function castFactory(testFunction) {
|
|
17436
|
-
return check;
|
|
17437
|
-
function check(value, index2, parent) {
|
|
17438
|
-
return Boolean(
|
|
17439
|
-
looksLikeANode(value) && testFunction.call(
|
|
17440
|
-
this,
|
|
17441
|
-
value,
|
|
17442
|
-
typeof index2 === "number" ? index2 : void 0,
|
|
17443
|
-
parent || void 0
|
|
17444
|
-
)
|
|
17445
|
-
);
|
|
17376
|
+
while (sourcePos < markdownSource.length) {
|
|
17377
|
+
map3.set(sourcePos, renderedPos);
|
|
17378
|
+
sourcePos++;
|
|
17446
17379
|
}
|
|
17380
|
+
return map3;
|
|
17447
17381
|
}
|
|
17448
|
-
function
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
|
|
17453
|
-
|
|
17454
|
-
|
|
17455
|
-
|
|
17456
|
-
|
|
17457
|
-
|
|
17458
|
-
|
|
17459
|
-
|
|
17460
|
-
|
|
17461
|
-
|
|
17462
|
-
|
|
17463
|
-
|
|
17464
|
-
|
|
17465
|
-
|
|
17466
|
-
|
|
17467
|
-
|
|
17468
|
-
|
|
17469
|
-
|
|
17470
|
-
|
|
17471
|
-
|
|
17472
|
-
}
|
|
17473
|
-
const is2 = convert(check);
|
|
17474
|
-
const step = reverse ? -1 : 1;
|
|
17475
|
-
factory(tree, void 0, [])();
|
|
17476
|
-
function factory(node2, index2, parents) {
|
|
17477
|
-
const value = (
|
|
17478
|
-
/** @type {Record<string, unknown>} */
|
|
17479
|
-
node2 && typeof node2 === "object" ? node2 : {}
|
|
17480
|
-
);
|
|
17481
|
-
if (typeof value.type === "string") {
|
|
17482
|
-
const name3 = (
|
|
17483
|
-
// `hast`
|
|
17484
|
-
typeof value.tagName === "string" ? value.tagName : (
|
|
17485
|
-
// `xast`
|
|
17486
|
-
typeof value.name === "string" ? value.name : void 0
|
|
17487
|
-
)
|
|
17488
|
-
);
|
|
17489
|
-
Object.defineProperty(visit2, "name", {
|
|
17490
|
-
value: "node (" + color(node2.type + (name3 ? "<" + name3 + ">" : "")) + ")"
|
|
17491
|
-
});
|
|
17492
|
-
}
|
|
17493
|
-
return visit2;
|
|
17494
|
-
function visit2() {
|
|
17495
|
-
let result = empty;
|
|
17496
|
-
let subresult;
|
|
17497
|
-
let offset;
|
|
17498
|
-
let grandparents;
|
|
17499
|
-
if (!test || is2(node2, index2, parents[parents.length - 1] || void 0)) {
|
|
17500
|
-
result = toResult(visitor(node2, parents));
|
|
17501
|
-
if (result[0] === EXIT) {
|
|
17502
|
-
return result;
|
|
17503
|
-
}
|
|
17504
|
-
}
|
|
17505
|
-
if ("children" in node2 && node2.children) {
|
|
17506
|
-
const nodeAsParent = (
|
|
17507
|
-
/** @type {UnistParent} */
|
|
17508
|
-
node2
|
|
17509
|
-
);
|
|
17510
|
-
if (nodeAsParent.children && result[0] !== SKIP) {
|
|
17511
|
-
offset = (reverse ? nodeAsParent.children.length : -1) + step;
|
|
17512
|
-
grandparents = parents.concat(nodeAsParent);
|
|
17513
|
-
while (offset > -1 && offset < nodeAsParent.children.length) {
|
|
17514
|
-
const child = nodeAsParent.children[offset];
|
|
17515
|
-
subresult = factory(child, offset, grandparents)();
|
|
17516
|
-
if (subresult[0] === EXIT) {
|
|
17517
|
-
return subresult;
|
|
17518
|
-
}
|
|
17519
|
-
offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
|
|
17520
|
-
}
|
|
17521
|
-
}
|
|
17522
|
-
}
|
|
17523
|
-
return result;
|
|
17382
|
+
function buildTextNodeIndex(container) {
|
|
17383
|
+
const entries = [];
|
|
17384
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_TEXT);
|
|
17385
|
+
let offset = 0;
|
|
17386
|
+
while (walker.nextNode()) {
|
|
17387
|
+
const node2 = walker.currentNode;
|
|
17388
|
+
const length = node2.textContent?.length ?? 0;
|
|
17389
|
+
entries.push({ node: node2, start: offset, end: offset + length });
|
|
17390
|
+
offset += length;
|
|
17391
|
+
}
|
|
17392
|
+
return entries;
|
|
17393
|
+
}
|
|
17394
|
+
function findTextNode(entries, renderedOffset) {
|
|
17395
|
+
let lo = 0;
|
|
17396
|
+
let hi = entries.length - 1;
|
|
17397
|
+
while (lo <= hi) {
|
|
17398
|
+
const mid = lo + hi >>> 1;
|
|
17399
|
+
const entry = entries[mid];
|
|
17400
|
+
if (renderedOffset < entry.start) {
|
|
17401
|
+
hi = mid - 1;
|
|
17402
|
+
} else if (renderedOffset >= entry.end) {
|
|
17403
|
+
lo = mid + 1;
|
|
17404
|
+
} else {
|
|
17405
|
+
return { node: entry.node, localOffset: renderedOffset - entry.start };
|
|
17524
17406
|
}
|
|
17525
17407
|
}
|
|
17408
|
+
return null;
|
|
17526
17409
|
}
|
|
17527
|
-
function
|
|
17528
|
-
|
|
17529
|
-
|
|
17530
|
-
|
|
17531
|
-
|
|
17532
|
-
|
|
17533
|
-
|
|
17534
|
-
|
|
17535
|
-
|
|
17536
|
-
|
|
17537
|
-
|
|
17538
|
-
|
|
17539
|
-
|
|
17540
|
-
let test;
|
|
17541
|
-
let visitor;
|
|
17542
|
-
if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
|
|
17543
|
-
test = void 0;
|
|
17544
|
-
visitor = testOrVisitor;
|
|
17545
|
-
reverse = visitorOrReverse;
|
|
17546
|
-
} else {
|
|
17547
|
-
test = testOrVisitor;
|
|
17548
|
-
visitor = visitorOrReverse;
|
|
17549
|
-
reverse = maybeReverse;
|
|
17550
|
-
}
|
|
17551
|
-
visitParents(tree, test, overload, reverse);
|
|
17552
|
-
function overload(node2, parents) {
|
|
17553
|
-
const parent = parents[parents.length - 1];
|
|
17554
|
-
const index2 = parent ? parent.children.indexOf(node2) : void 0;
|
|
17555
|
-
return visitor(node2, index2, parent);
|
|
17556
|
-
}
|
|
17557
|
-
}
|
|
17558
|
-
|
|
17559
|
-
// src/lib/rehype-render-annotations.ts
|
|
17560
|
-
function buildAnnotationSpan(annotation, children) {
|
|
17561
|
-
let className;
|
|
17562
|
-
const annotationType = annotation.type;
|
|
17563
|
-
if (annotation.type === "highlight") {
|
|
17564
|
-
className = "annotation-highlight";
|
|
17565
|
-
} else if (annotation.type === "assessment") {
|
|
17566
|
-
className = "annotation-assessment";
|
|
17567
|
-
} else if (annotation.type === "comment") {
|
|
17568
|
-
className = "annotation-comment";
|
|
17569
|
-
} else if (annotation.type === "tag") {
|
|
17570
|
-
className = "annotation-tag";
|
|
17571
|
-
} else if (annotation.type === "reference") {
|
|
17572
|
-
className = "annotation-reference";
|
|
17573
|
-
} else {
|
|
17574
|
-
className = "annotation-reference";
|
|
17575
|
-
}
|
|
17576
|
-
return {
|
|
17577
|
-
type: "element",
|
|
17578
|
-
tagName: "span",
|
|
17579
|
-
properties: {
|
|
17580
|
-
className,
|
|
17581
|
-
"data-annotation-id": annotation.id,
|
|
17582
|
-
"data-annotation-type": annotationType
|
|
17583
|
-
},
|
|
17584
|
-
children
|
|
17585
|
-
};
|
|
17586
|
-
}
|
|
17587
|
-
function rehypeRenderAnnotations() {
|
|
17588
|
-
return (tree, file) => {
|
|
17589
|
-
const originalSource = String(file);
|
|
17590
|
-
visit(tree, "element", (element2) => {
|
|
17591
|
-
const annotationsJson = element2.properties?.["data-annotations"];
|
|
17592
|
-
if (!annotationsJson || typeof annotationsJson !== "string") {
|
|
17593
|
-
return;
|
|
17594
|
-
}
|
|
17595
|
-
const annotations = JSON.parse(annotationsJson);
|
|
17596
|
-
wrapCrossElementAnnotations(element2, annotations);
|
|
17597
|
-
applyWithinTextNodeAnnotations(element2, annotations, originalSource);
|
|
17598
|
-
delete element2.properties["data-annotations"];
|
|
17599
|
-
});
|
|
17600
|
-
};
|
|
17601
|
-
}
|
|
17602
|
-
function wrapCrossElementAnnotations(element2, annotations) {
|
|
17603
|
-
const spans = analyzeChildSpans(element2, annotations);
|
|
17604
|
-
if (spans.length === 0) return;
|
|
17605
|
-
const sortedSpans = spans.sort((a15, b8) => {
|
|
17606
|
-
const aLength = a15.endChildIndex - a15.startChildIndex;
|
|
17607
|
-
const bLength = b8.endChildIndex - b8.startChildIndex;
|
|
17608
|
-
return bLength - aLength;
|
|
17609
|
-
});
|
|
17610
|
-
for (const span of sortedSpans) {
|
|
17611
|
-
wrapChildRange(element2, span);
|
|
17410
|
+
function resolveAnnotationRanges(annotations, offsetMap, textNodeIndex) {
|
|
17411
|
+
const ranges = /* @__PURE__ */ new Map();
|
|
17412
|
+
for (const ann of annotations) {
|
|
17413
|
+
const renderedStart = offsetMap.get(ann.offset);
|
|
17414
|
+
const renderedEnd = offsetMap.get(ann.offset + ann.length - 1);
|
|
17415
|
+
if (renderedStart === void 0 || renderedEnd === void 0) continue;
|
|
17416
|
+
const startInfo = findTextNode(textNodeIndex, renderedStart);
|
|
17417
|
+
const endInfo = findTextNode(textNodeIndex, renderedEnd + 1);
|
|
17418
|
+
if (!startInfo || !endInfo) continue;
|
|
17419
|
+
const range = document.createRange();
|
|
17420
|
+
range.setStart(startInfo.node, startInfo.localOffset);
|
|
17421
|
+
range.setEnd(endInfo.node, endInfo.localOffset);
|
|
17422
|
+
ranges.set(ann.id, { range, annotation: ann });
|
|
17612
17423
|
}
|
|
17424
|
+
return ranges;
|
|
17613
17425
|
}
|
|
17614
|
-
function
|
|
17615
|
-
const
|
|
17616
|
-
|
|
17617
|
-
|
|
17618
|
-
|
|
17619
|
-
|
|
17620
|
-
|
|
17621
|
-
|
|
17622
|
-
|
|
17623
|
-
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
if (annStart < childEnd && annEnd > childStart) {
|
|
17627
|
-
if (startChildIndex === -1) {
|
|
17628
|
-
startChildIndex = i12;
|
|
17629
|
-
}
|
|
17630
|
-
endChildIndex = i12 + 1;
|
|
17426
|
+
function applyHighlights(ranges) {
|
|
17427
|
+
for (const [id2, { range, annotation }] of ranges) {
|
|
17428
|
+
const className = `annotation-${annotation.type}`;
|
|
17429
|
+
if (range.startContainer === range.endContainer) {
|
|
17430
|
+
const span = document.createElement("span");
|
|
17431
|
+
span.className = className;
|
|
17432
|
+
span.dataset.annotationId = id2;
|
|
17433
|
+
span.dataset.annotationType = annotation.type;
|
|
17434
|
+
try {
|
|
17435
|
+
range.surroundContents(span);
|
|
17436
|
+
} catch {
|
|
17437
|
+
wrapRangeTextNodes(range, id2, annotation);
|
|
17631
17438
|
}
|
|
17439
|
+
continue;
|
|
17632
17440
|
}
|
|
17633
|
-
|
|
17634
|
-
spans.push({ annotation: ann, startChildIndex, endChildIndex });
|
|
17635
|
-
}
|
|
17636
|
-
}
|
|
17637
|
-
return spans;
|
|
17638
|
-
}
|
|
17639
|
-
function getNodeOffsetRange(node2) {
|
|
17640
|
-
if (!node2) return null;
|
|
17641
|
-
if ("position" in node2 && node2.position?.start.offset !== void 0 && node2.position?.end.offset !== void 0) {
|
|
17642
|
-
return [node2.position.start.offset, node2.position.end.offset];
|
|
17441
|
+
wrapRangeTextNodes(range, id2, annotation);
|
|
17643
17442
|
}
|
|
17644
|
-
return null;
|
|
17645
17443
|
}
|
|
17646
|
-
function
|
|
17647
|
-
const
|
|
17648
|
-
const
|
|
17649
|
-
|
|
17650
|
-
|
|
17651
|
-
|
|
17652
|
-
|
|
17653
|
-
|
|
17654
|
-
|
|
17655
|
-
|
|
17656
|
-
|
|
17657
|
-
|
|
17658
|
-
|
|
17659
|
-
|
|
17660
|
-
const
|
|
17661
|
-
|
|
17662
|
-
|
|
17663
|
-
|
|
17664
|
-
|
|
17665
|
-
|
|
17666
|
-
|
|
17667
|
-
|
|
17668
|
-
|
|
17669
|
-
|
|
17670
|
-
|
|
17671
|
-
|
|
17672
|
-
|
|
17673
|
-
|
|
17674
|
-
|
|
17675
|
-
let lastPos = 0;
|
|
17676
|
-
for (const ann of applicable.sort((a15, b8) => a15.offset - b8.offset)) {
|
|
17677
|
-
let relStart = sourceToRendered.get(ann.offset);
|
|
17678
|
-
let relEnd = sourceToRendered.get(ann.offset + ann.length - 1);
|
|
17679
|
-
if (relStart === void 0 || relEnd === void 0) continue;
|
|
17680
|
-
relEnd = relEnd + 1;
|
|
17681
|
-
relStart = Math.max(0, Math.min(relStart, textContent.length));
|
|
17682
|
-
relEnd = Math.max(0, Math.min(relEnd, textContent.length));
|
|
17683
|
-
if (relStart >= relEnd || relStart < lastPos) continue;
|
|
17684
|
-
if (relStart > lastPos) {
|
|
17685
|
-
segments.push({ type: "text", value: textContent.substring(lastPos, relStart) });
|
|
17686
|
-
}
|
|
17687
|
-
const annotationSpan = buildAnnotationSpan(ann, [
|
|
17688
|
-
{ type: "text", value: textContent.substring(relStart, relEnd) }
|
|
17689
|
-
]);
|
|
17690
|
-
segments.push(annotationSpan);
|
|
17691
|
-
lastPos = relEnd;
|
|
17692
|
-
}
|
|
17693
|
-
if (lastPos < textContent.length) {
|
|
17694
|
-
segments.push({ type: "text", value: textContent.substring(lastPos) });
|
|
17695
|
-
}
|
|
17696
|
-
if (segments.length === 0) {
|
|
17697
|
-
return SKIP;
|
|
17698
|
-
} else if (segments.length === 1 && segments[0]) {
|
|
17699
|
-
parent.children[index2] = segments[0];
|
|
17700
|
-
} else {
|
|
17701
|
-
parent.children[index2] = {
|
|
17702
|
-
type: "element",
|
|
17703
|
-
tagName: "span",
|
|
17704
|
-
properties: {},
|
|
17705
|
-
children: segments
|
|
17706
|
-
};
|
|
17444
|
+
function wrapRangeTextNodes(range, id2, annotation) {
|
|
17445
|
+
const className = `annotation-${annotation.type}`;
|
|
17446
|
+
const walker = document.createTreeWalker(
|
|
17447
|
+
range.commonAncestorContainer,
|
|
17448
|
+
NodeFilter.SHOW_TEXT
|
|
17449
|
+
);
|
|
17450
|
+
const textNodes = [];
|
|
17451
|
+
while (walker.nextNode()) {
|
|
17452
|
+
const node2 = walker.currentNode;
|
|
17453
|
+
if (range.intersectsNode(node2)) {
|
|
17454
|
+
textNodes.push(node2);
|
|
17455
|
+
}
|
|
17456
|
+
}
|
|
17457
|
+
for (const textNode of textNodes) {
|
|
17458
|
+
const nodeRange = document.createRange();
|
|
17459
|
+
nodeRange.selectNodeContents(textNode);
|
|
17460
|
+
if (textNode === range.startContainer) {
|
|
17461
|
+
nodeRange.setStart(textNode, range.startOffset);
|
|
17462
|
+
}
|
|
17463
|
+
if (textNode === range.endContainer) {
|
|
17464
|
+
nodeRange.setEnd(textNode, range.endOffset);
|
|
17465
|
+
}
|
|
17466
|
+
const span = document.createElement("span");
|
|
17467
|
+
span.className = className;
|
|
17468
|
+
span.dataset.annotationId = id2;
|
|
17469
|
+
span.dataset.annotationType = annotation.type;
|
|
17470
|
+
try {
|
|
17471
|
+
nodeRange.surroundContents(span);
|
|
17472
|
+
} catch {
|
|
17707
17473
|
}
|
|
17708
|
-
|
|
17709
|
-
});
|
|
17474
|
+
}
|
|
17710
17475
|
}
|
|
17711
|
-
function
|
|
17712
|
-
const
|
|
17713
|
-
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
renderedPos++;
|
|
17719
|
-
sourcePos++;
|
|
17720
|
-
} else {
|
|
17721
|
-
sourcePos++;
|
|
17476
|
+
function clearHighlights(container) {
|
|
17477
|
+
const spans = container.querySelectorAll("[data-annotation-id]");
|
|
17478
|
+
for (const span of spans) {
|
|
17479
|
+
const parent = span.parentNode;
|
|
17480
|
+
if (!parent) continue;
|
|
17481
|
+
while (span.firstChild) {
|
|
17482
|
+
parent.insertBefore(span.firstChild, span);
|
|
17722
17483
|
}
|
|
17484
|
+
parent.removeChild(span);
|
|
17485
|
+
parent.normalize();
|
|
17723
17486
|
}
|
|
17724
|
-
while (sourcePos < sourceText.length) {
|
|
17725
|
-
map3.set(baseOffset + sourcePos, renderedPos);
|
|
17726
|
-
sourcePos++;
|
|
17727
|
-
}
|
|
17728
|
-
return map3;
|
|
17729
17487
|
}
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
17736
|
-
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17741
|
-
|
|
17742
|
-
|
|
17743
|
-
|
|
17744
|
-
|
|
17745
|
-
|
|
17746
|
-
if (!node2.data) node2.data = {};
|
|
17747
|
-
if (!node2.data.hProperties) node2.data.hProperties = {};
|
|
17748
|
-
node2.data.hProperties["data-annotations"] = JSON.stringify(overlapping);
|
|
17749
|
-
}
|
|
17750
|
-
});
|
|
17751
|
-
};
|
|
17488
|
+
function toOverlayAnnotations(annotations) {
|
|
17489
|
+
return annotations.map((ann) => {
|
|
17490
|
+
const targetSelector = getTargetSelector(ann.target);
|
|
17491
|
+
const posSelector = getTextPositionSelector(targetSelector);
|
|
17492
|
+
const start2 = posSelector?.start ?? 0;
|
|
17493
|
+
const end = posSelector?.end ?? 0;
|
|
17494
|
+
const type = Object.values(ANNOTATORS).find((a15) => a15.matchesAnnotation(ann))?.internalType || "highlight";
|
|
17495
|
+
return {
|
|
17496
|
+
id: ann.id,
|
|
17497
|
+
exact: getExactText(targetSelector),
|
|
17498
|
+
offset: start2,
|
|
17499
|
+
length: end - start2,
|
|
17500
|
+
type,
|
|
17501
|
+
source: getBodySource2(ann.body)
|
|
17502
|
+
};
|
|
17503
|
+
});
|
|
17752
17504
|
}
|
|
17753
17505
|
|
|
17754
17506
|
// src/lib/resource-utils.ts
|
|
@@ -26432,7 +26184,7 @@ function scrollAnnotationIntoView(annotationId, rootElement, options = {}) {
|
|
|
26432
26184
|
}
|
|
26433
26185
|
|
|
26434
26186
|
// src/components/CodeMirrorRenderer.tsx
|
|
26435
|
-
import { isHighlight as isHighlight2, isReference as isReference2, isResolvedReference as isResolvedReference2, isComment as isComment2, isAssessment, isTag as isTag3, getBodySource as
|
|
26187
|
+
import { isHighlight as isHighlight2, isReference as isReference2, isResolvedReference as isResolvedReference2, isComment as isComment2, isAssessment, isTag as isTag3, getBodySource as getBodySource3 } from "@semiont/api-client";
|
|
26436
26188
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
26437
26189
|
var updateAnnotationsEffect = StateEffect.define();
|
|
26438
26190
|
var updateWidgetsEffect = StateEffect.define();
|
|
@@ -26533,7 +26285,7 @@ function buildWidgetDecorations(_content, segments, generatingReferenceId, event
|
|
|
26533
26285
|
if (!segment.annotation) continue;
|
|
26534
26286
|
const annotation = segment.annotation;
|
|
26535
26287
|
if (isReference2(annotation)) {
|
|
26536
|
-
const bodySource =
|
|
26288
|
+
const bodySource = getBodySource3(annotation.body);
|
|
26537
26289
|
const targetName = bodySource ? getTargetDocumentName?.(bodySource) : void 0;
|
|
26538
26290
|
const isGenerating = generatingReferenceId ? annotation.id === generatingReferenceId : false;
|
|
26539
26291
|
const widget = new ReferenceResolutionWidget(
|
|
@@ -30370,7 +30122,7 @@ function ProposeEntitiesModal({
|
|
|
30370
30122
|
// src/components/resource/AnnotateView.tsx
|
|
30371
30123
|
import { useRef as useRef12, useEffect as useEffect18, useCallback as useCallback13, lazy, Suspense } from "react";
|
|
30372
30124
|
import { resourceUri as toResourceUri } from "@semiont/core";
|
|
30373
|
-
import { getTextPositionSelector, getTextQuoteSelector, getTargetSelector, getMimeCategory, isPdfMimeType as isPdfMimeType2, extractContext, findTextWithContext } from "@semiont/api-client";
|
|
30125
|
+
import { getTextPositionSelector as getTextPositionSelector2, getTextQuoteSelector, getTargetSelector as getTargetSelector2, getMimeCategory, isPdfMimeType as isPdfMimeType2, extractContext, findTextWithContext } from "@semiont/api-client";
|
|
30374
30126
|
import { jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
30375
30127
|
var PdfAnnotationCanvas = lazy(() => import("./PdfAnnotationCanvas.client-HNYRKFDS.mjs").then((mod) => ({ default: mod.PdfAnnotationCanvas })));
|
|
30376
30128
|
function segmentTextWithAnnotations(content4, annotations) {
|
|
@@ -30378,8 +30130,8 @@ function segmentTextWithAnnotations(content4, annotations) {
|
|
|
30378
30130
|
return [{ exact: "", start: 0, end: 0 }];
|
|
30379
30131
|
}
|
|
30380
30132
|
const normalizedAnnotations = annotations.map((ann) => {
|
|
30381
|
-
const targetSelector =
|
|
30382
|
-
const posSelector =
|
|
30133
|
+
const targetSelector = getTargetSelector2(ann.target);
|
|
30134
|
+
const posSelector = getTextPositionSelector2(targetSelector);
|
|
30383
30135
|
const quoteSelector = targetSelector ? getTextQuoteSelector(targetSelector) : null;
|
|
30384
30136
|
let position4;
|
|
30385
30137
|
if (quoteSelector) {
|
|
@@ -30681,7 +30433,7 @@ import { useRef as useRef13, useCallback as useCallback14, useEffect as useEffec
|
|
|
30681
30433
|
import { getAnnotationUriFromEvent } from "@semiont/core";
|
|
30682
30434
|
|
|
30683
30435
|
// src/components/resource/event-formatting.ts
|
|
30684
|
-
import { getExactText, getTargetSelector as
|
|
30436
|
+
import { getExactText as getExactText2, getTargetSelector as getTargetSelector3 } from "@semiont/api-client";
|
|
30685
30437
|
function formatEventType(type, t12, payload) {
|
|
30686
30438
|
switch (type) {
|
|
30687
30439
|
case "resource.created":
|
|
@@ -30792,8 +30544,8 @@ function getEventDisplayContent(event, annotations, allEvents) {
|
|
|
30792
30544
|
);
|
|
30793
30545
|
if (annotation?.target) {
|
|
30794
30546
|
try {
|
|
30795
|
-
const targetSelector =
|
|
30796
|
-
const exact =
|
|
30547
|
+
const targetSelector = getTargetSelector3(annotation.target);
|
|
30548
|
+
const exact = getExactText2(targetSelector);
|
|
30797
30549
|
if (exact) {
|
|
30798
30550
|
return { exact: truncateText(exact), isQuoted: true, isTag: false };
|
|
30799
30551
|
}
|
|
@@ -30810,7 +30562,7 @@ function getEventDisplayContent(event, annotations, allEvents) {
|
|
|
30810
30562
|
try {
|
|
30811
30563
|
const target = addedEvent.event.payload.annotation.target;
|
|
30812
30564
|
if (typeof target !== "string" && target.selector) {
|
|
30813
|
-
const exact =
|
|
30565
|
+
const exact = getExactText2(target.selector);
|
|
30814
30566
|
if (exact) {
|
|
30815
30567
|
return { exact: truncateText(exact), isQuoted: true, isTag: false };
|
|
30816
30568
|
}
|
|
@@ -30824,7 +30576,7 @@ function getEventDisplayContent(event, annotations, allEvents) {
|
|
|
30824
30576
|
try {
|
|
30825
30577
|
const target = eventData.payload.annotation.target;
|
|
30826
30578
|
if (typeof target !== "string" && target.selector) {
|
|
30827
|
-
const exact =
|
|
30579
|
+
const exact = getExactText2(target.selector);
|
|
30828
30580
|
if (exact) {
|
|
30829
30581
|
return { exact: truncateText(exact), isQuoted: true, isTag: false };
|
|
30830
30582
|
}
|
|
@@ -30844,8 +30596,8 @@ function getEventDisplayContent(event, annotations, allEvents) {
|
|
|
30844
30596
|
);
|
|
30845
30597
|
if (annotation?.target) {
|
|
30846
30598
|
try {
|
|
30847
|
-
const targetSelector =
|
|
30848
|
-
const exact =
|
|
30599
|
+
const targetSelector = getTargetSelector3(annotation.target);
|
|
30600
|
+
const exact = getExactText2(targetSelector);
|
|
30849
30601
|
if (exact) {
|
|
30850
30602
|
return { exact: truncateText(exact), isQuoted: true, isTag: false };
|
|
30851
30603
|
}
|
|
@@ -31098,10 +30850,10 @@ function AnnotationHistory({ rUri, hoveredAnnotationId, onEventHover, onEventCli
|
|
|
31098
30850
|
}
|
|
31099
30851
|
|
|
31100
30852
|
// src/components/resource/BrowseView.tsx
|
|
31101
|
-
import { useEffect as useEffect22, useRef as useRef15, useCallback as useCallback15, lazy as lazy2, Suspense as Suspense2 } from "react";
|
|
30853
|
+
import { useEffect as useEffect22, useRef as useRef15, useCallback as useCallback15, useMemo as useMemo4, memo, lazy as lazy2, Suspense as Suspense2 } from "react";
|
|
31102
30854
|
|
|
31103
30855
|
// ../../node_modules/devlop/lib/default.js
|
|
31104
|
-
function
|
|
30856
|
+
function ok() {
|
|
31105
30857
|
}
|
|
31106
30858
|
function unreachable() {
|
|
31107
30859
|
}
|
|
@@ -31128,9 +30880,9 @@ function name2(name3, options) {
|
|
|
31128
30880
|
// ../../node_modules/hast-util-whitespace/lib/index.js
|
|
31129
30881
|
var re2 = /[ \t\n\f\r]/g;
|
|
31130
30882
|
function whitespace(thing) {
|
|
31131
|
-
return typeof thing === "object" ? thing.type === "text" ?
|
|
30883
|
+
return typeof thing === "object" ? thing.type === "text" ? empty(thing.value) : false : empty(thing);
|
|
31132
30884
|
}
|
|
31133
|
-
function
|
|
30885
|
+
function empty(value) {
|
|
31134
30886
|
return value.replace(re2, "") === "";
|
|
31135
30887
|
}
|
|
31136
30888
|
|
|
@@ -32668,7 +32420,7 @@ function mdxExpression(state, node2) {
|
|
|
32668
32420
|
if (node2.data && node2.data.estree && state.evaluater) {
|
|
32669
32421
|
const program = node2.data.estree;
|
|
32670
32422
|
const expression = program.body[0];
|
|
32671
|
-
|
|
32423
|
+
ok(expression.type === "ExpressionStatement");
|
|
32672
32424
|
return (
|
|
32673
32425
|
/** @type {Child | undefined} */
|
|
32674
32426
|
state.evaluater.evaluateExpression(expression.expression)
|
|
@@ -32783,11 +32535,11 @@ function createJsxElementProps(state, node2) {
|
|
|
32783
32535
|
if (attribute.data && attribute.data.estree && state.evaluater) {
|
|
32784
32536
|
const program = attribute.data.estree;
|
|
32785
32537
|
const expression = program.body[0];
|
|
32786
|
-
|
|
32538
|
+
ok(expression.type === "ExpressionStatement");
|
|
32787
32539
|
const objectExpression = expression.expression;
|
|
32788
|
-
|
|
32540
|
+
ok(objectExpression.type === "ObjectExpression");
|
|
32789
32541
|
const property = objectExpression.properties[0];
|
|
32790
|
-
|
|
32542
|
+
ok(property.type === "SpreadElement");
|
|
32791
32543
|
Object.assign(
|
|
32792
32544
|
props,
|
|
32793
32545
|
state.evaluater.evaluateExpression(property.argument)
|
|
@@ -32802,7 +32554,7 @@ function createJsxElementProps(state, node2) {
|
|
|
32802
32554
|
if (attribute.value.data && attribute.value.data.estree && state.evaluater) {
|
|
32803
32555
|
const program = attribute.value.data.estree;
|
|
32804
32556
|
const expression = program.body[0];
|
|
32805
|
-
|
|
32557
|
+
ok(expression.type === "ExpressionStatement");
|
|
32806
32558
|
value = state.evaluater.evaluateExpression(expression.expression);
|
|
32807
32559
|
} else {
|
|
32808
32560
|
crashEstree(state, node2.position);
|
|
@@ -32896,7 +32648,7 @@ function findComponentFromName(state, name3, allowExpression) {
|
|
|
32896
32648
|
optional: false
|
|
32897
32649
|
} : prop;
|
|
32898
32650
|
}
|
|
32899
|
-
|
|
32651
|
+
ok(node2, "always a result");
|
|
32900
32652
|
result = node2;
|
|
32901
32653
|
} else {
|
|
32902
32654
|
result = name2(name3) && !/^[a-z]/.test(name3) ? { type: "Identifier", name: name3 } : { type: "Literal", value: name3 };
|
|
@@ -40799,6 +40551,209 @@ function footer(state) {
|
|
|
40799
40551
|
};
|
|
40800
40552
|
}
|
|
40801
40553
|
|
|
40554
|
+
// ../../node_modules/unist-util-is/lib/index.js
|
|
40555
|
+
var convert = (
|
|
40556
|
+
// Note: overloads in JSDoc can’t yet use different `@template`s.
|
|
40557
|
+
/**
|
|
40558
|
+
* @type {(
|
|
40559
|
+
* (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
|
|
40560
|
+
* (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
|
|
40561
|
+
* (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
|
|
40562
|
+
* ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
|
|
40563
|
+
* ((test?: Test) => Check)
|
|
40564
|
+
* )}
|
|
40565
|
+
*/
|
|
40566
|
+
/**
|
|
40567
|
+
* @param {Test} [test]
|
|
40568
|
+
* @returns {Check}
|
|
40569
|
+
*/
|
|
40570
|
+
(function(test) {
|
|
40571
|
+
if (test === null || test === void 0) {
|
|
40572
|
+
return ok2;
|
|
40573
|
+
}
|
|
40574
|
+
if (typeof test === "function") {
|
|
40575
|
+
return castFactory(test);
|
|
40576
|
+
}
|
|
40577
|
+
if (typeof test === "object") {
|
|
40578
|
+
return Array.isArray(test) ? anyFactory(test) : (
|
|
40579
|
+
// Cast because `ReadonlyArray` goes into the above but `isArray`
|
|
40580
|
+
// narrows to `Array`.
|
|
40581
|
+
propertiesFactory(
|
|
40582
|
+
/** @type {Props} */
|
|
40583
|
+
test
|
|
40584
|
+
)
|
|
40585
|
+
);
|
|
40586
|
+
}
|
|
40587
|
+
if (typeof test === "string") {
|
|
40588
|
+
return typeFactory(test);
|
|
40589
|
+
}
|
|
40590
|
+
throw new Error("Expected function, string, or object as test");
|
|
40591
|
+
})
|
|
40592
|
+
);
|
|
40593
|
+
function anyFactory(tests) {
|
|
40594
|
+
const checks2 = [];
|
|
40595
|
+
let index2 = -1;
|
|
40596
|
+
while (++index2 < tests.length) {
|
|
40597
|
+
checks2[index2] = convert(tests[index2]);
|
|
40598
|
+
}
|
|
40599
|
+
return castFactory(any);
|
|
40600
|
+
function any(...parameters) {
|
|
40601
|
+
let index3 = -1;
|
|
40602
|
+
while (++index3 < checks2.length) {
|
|
40603
|
+
if (checks2[index3].apply(this, parameters)) return true;
|
|
40604
|
+
}
|
|
40605
|
+
return false;
|
|
40606
|
+
}
|
|
40607
|
+
}
|
|
40608
|
+
function propertiesFactory(check) {
|
|
40609
|
+
const checkAsRecord = (
|
|
40610
|
+
/** @type {Record<string, unknown>} */
|
|
40611
|
+
check
|
|
40612
|
+
);
|
|
40613
|
+
return castFactory(all2);
|
|
40614
|
+
function all2(node2) {
|
|
40615
|
+
const nodeAsRecord = (
|
|
40616
|
+
/** @type {Record<string, unknown>} */
|
|
40617
|
+
/** @type {unknown} */
|
|
40618
|
+
node2
|
|
40619
|
+
);
|
|
40620
|
+
let key;
|
|
40621
|
+
for (key in check) {
|
|
40622
|
+
if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
|
|
40623
|
+
}
|
|
40624
|
+
return true;
|
|
40625
|
+
}
|
|
40626
|
+
}
|
|
40627
|
+
function typeFactory(check) {
|
|
40628
|
+
return castFactory(type);
|
|
40629
|
+
function type(node2) {
|
|
40630
|
+
return node2 && node2.type === check;
|
|
40631
|
+
}
|
|
40632
|
+
}
|
|
40633
|
+
function castFactory(testFunction) {
|
|
40634
|
+
return check;
|
|
40635
|
+
function check(value, index2, parent) {
|
|
40636
|
+
return Boolean(
|
|
40637
|
+
looksLikeANode(value) && testFunction.call(
|
|
40638
|
+
this,
|
|
40639
|
+
value,
|
|
40640
|
+
typeof index2 === "number" ? index2 : void 0,
|
|
40641
|
+
parent || void 0
|
|
40642
|
+
)
|
|
40643
|
+
);
|
|
40644
|
+
}
|
|
40645
|
+
}
|
|
40646
|
+
function ok2() {
|
|
40647
|
+
return true;
|
|
40648
|
+
}
|
|
40649
|
+
function looksLikeANode(value) {
|
|
40650
|
+
return value !== null && typeof value === "object" && "type" in value;
|
|
40651
|
+
}
|
|
40652
|
+
|
|
40653
|
+
// ../../node_modules/unist-util-visit-parents/lib/color.node.js
|
|
40654
|
+
function color(d8) {
|
|
40655
|
+
return "\x1B[33m" + d8 + "\x1B[39m";
|
|
40656
|
+
}
|
|
40657
|
+
|
|
40658
|
+
// ../../node_modules/unist-util-visit-parents/lib/index.js
|
|
40659
|
+
var empty2 = [];
|
|
40660
|
+
var CONTINUE = true;
|
|
40661
|
+
var EXIT = false;
|
|
40662
|
+
var SKIP = "skip";
|
|
40663
|
+
function visitParents(tree, test, visitor, reverse) {
|
|
40664
|
+
let check;
|
|
40665
|
+
if (typeof test === "function" && typeof visitor !== "function") {
|
|
40666
|
+
reverse = visitor;
|
|
40667
|
+
visitor = test;
|
|
40668
|
+
} else {
|
|
40669
|
+
check = test;
|
|
40670
|
+
}
|
|
40671
|
+
const is2 = convert(check);
|
|
40672
|
+
const step = reverse ? -1 : 1;
|
|
40673
|
+
factory(tree, void 0, [])();
|
|
40674
|
+
function factory(node2, index2, parents) {
|
|
40675
|
+
const value = (
|
|
40676
|
+
/** @type {Record<string, unknown>} */
|
|
40677
|
+
node2 && typeof node2 === "object" ? node2 : {}
|
|
40678
|
+
);
|
|
40679
|
+
if (typeof value.type === "string") {
|
|
40680
|
+
const name3 = (
|
|
40681
|
+
// `hast`
|
|
40682
|
+
typeof value.tagName === "string" ? value.tagName : (
|
|
40683
|
+
// `xast`
|
|
40684
|
+
typeof value.name === "string" ? value.name : void 0
|
|
40685
|
+
)
|
|
40686
|
+
);
|
|
40687
|
+
Object.defineProperty(visit2, "name", {
|
|
40688
|
+
value: "node (" + color(node2.type + (name3 ? "<" + name3 + ">" : "")) + ")"
|
|
40689
|
+
});
|
|
40690
|
+
}
|
|
40691
|
+
return visit2;
|
|
40692
|
+
function visit2() {
|
|
40693
|
+
let result = empty2;
|
|
40694
|
+
let subresult;
|
|
40695
|
+
let offset;
|
|
40696
|
+
let grandparents;
|
|
40697
|
+
if (!test || is2(node2, index2, parents[parents.length - 1] || void 0)) {
|
|
40698
|
+
result = toResult(visitor(node2, parents));
|
|
40699
|
+
if (result[0] === EXIT) {
|
|
40700
|
+
return result;
|
|
40701
|
+
}
|
|
40702
|
+
}
|
|
40703
|
+
if ("children" in node2 && node2.children) {
|
|
40704
|
+
const nodeAsParent = (
|
|
40705
|
+
/** @type {UnistParent} */
|
|
40706
|
+
node2
|
|
40707
|
+
);
|
|
40708
|
+
if (nodeAsParent.children && result[0] !== SKIP) {
|
|
40709
|
+
offset = (reverse ? nodeAsParent.children.length : -1) + step;
|
|
40710
|
+
grandparents = parents.concat(nodeAsParent);
|
|
40711
|
+
while (offset > -1 && offset < nodeAsParent.children.length) {
|
|
40712
|
+
const child = nodeAsParent.children[offset];
|
|
40713
|
+
subresult = factory(child, offset, grandparents)();
|
|
40714
|
+
if (subresult[0] === EXIT) {
|
|
40715
|
+
return subresult;
|
|
40716
|
+
}
|
|
40717
|
+
offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
|
|
40718
|
+
}
|
|
40719
|
+
}
|
|
40720
|
+
}
|
|
40721
|
+
return result;
|
|
40722
|
+
}
|
|
40723
|
+
}
|
|
40724
|
+
}
|
|
40725
|
+
function toResult(value) {
|
|
40726
|
+
if (Array.isArray(value)) {
|
|
40727
|
+
return value;
|
|
40728
|
+
}
|
|
40729
|
+
if (typeof value === "number") {
|
|
40730
|
+
return [CONTINUE, value];
|
|
40731
|
+
}
|
|
40732
|
+
return value === null || value === void 0 ? empty2 : [value];
|
|
40733
|
+
}
|
|
40734
|
+
|
|
40735
|
+
// ../../node_modules/unist-util-visit/lib/index.js
|
|
40736
|
+
function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
40737
|
+
let reverse;
|
|
40738
|
+
let test;
|
|
40739
|
+
let visitor;
|
|
40740
|
+
if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
|
|
40741
|
+
test = void 0;
|
|
40742
|
+
visitor = testOrVisitor;
|
|
40743
|
+
reverse = visitorOrReverse;
|
|
40744
|
+
} else {
|
|
40745
|
+
test = testOrVisitor;
|
|
40746
|
+
visitor = visitorOrReverse;
|
|
40747
|
+
reverse = maybeReverse;
|
|
40748
|
+
}
|
|
40749
|
+
visitParents(tree, test, overload, reverse);
|
|
40750
|
+
function overload(node2, parents) {
|
|
40751
|
+
const parent = parents[parents.length - 1];
|
|
40752
|
+
const index2 = parent ? parent.children.indexOf(node2) : void 0;
|
|
40753
|
+
return visitor(node2, index2, parent);
|
|
40754
|
+
}
|
|
40755
|
+
}
|
|
40756
|
+
|
|
40802
40757
|
// ../../node_modules/mdast-util-to-hast/lib/state.js
|
|
40803
40758
|
var own4 = {}.hasOwnProperty;
|
|
40804
40759
|
var emptyOptions3 = {};
|
|
@@ -40948,7 +40903,7 @@ function toHast(tree, options) {
|
|
|
40948
40903
|
const foot = footer(state);
|
|
40949
40904
|
const result = Array.isArray(node2) ? { type: "root", children: node2 } : node2 || { type: "root", children: [] };
|
|
40950
40905
|
if (foot) {
|
|
40951
|
-
|
|
40906
|
+
ok("children" in result);
|
|
40952
40907
|
result.children.push({ type: "text", value: "\n" }, foot);
|
|
40953
40908
|
}
|
|
40954
40909
|
return result;
|
|
@@ -41841,7 +41796,7 @@ var Processor = class _Processor extends CallableInstance {
|
|
|
41841
41796
|
} else if (resolve) {
|
|
41842
41797
|
resolve(file2);
|
|
41843
41798
|
} else {
|
|
41844
|
-
|
|
41799
|
+
ok(done, "`done` is defined if `resolve` is not");
|
|
41845
41800
|
done(void 0, file2);
|
|
41846
41801
|
}
|
|
41847
41802
|
}
|
|
@@ -41886,7 +41841,7 @@ var Processor = class _Processor extends CallableInstance {
|
|
|
41886
41841
|
assertCompiler("processSync", this.compiler || this.Compiler);
|
|
41887
41842
|
this.process(file, realDone);
|
|
41888
41843
|
assertDone("processSync", "process", complete);
|
|
41889
|
-
|
|
41844
|
+
ok(result, "we either bailed on an error or have a tree");
|
|
41890
41845
|
return result;
|
|
41891
41846
|
function realDone(error, file2) {
|
|
41892
41847
|
complete = true;
|
|
@@ -41942,7 +41897,7 @@ var Processor = class _Processor extends CallableInstance {
|
|
|
41942
41897
|
}
|
|
41943
41898
|
return done ? executor(void 0, done) : new Promise(executor);
|
|
41944
41899
|
function executor(resolve, reject) {
|
|
41945
|
-
|
|
41900
|
+
ok(
|
|
41946
41901
|
typeof file !== "function",
|
|
41947
41902
|
"`file` can\u2019t be a `done` anymore, we checked"
|
|
41948
41903
|
);
|
|
@@ -41958,7 +41913,7 @@ var Processor = class _Processor extends CallableInstance {
|
|
|
41958
41913
|
} else if (resolve) {
|
|
41959
41914
|
resolve(resultingTree);
|
|
41960
41915
|
} else {
|
|
41961
|
-
|
|
41916
|
+
ok(done, "`done` is defined if `resolve` is not");
|
|
41962
41917
|
done(void 0, resultingTree, file2);
|
|
41963
41918
|
}
|
|
41964
41919
|
}
|
|
@@ -41986,7 +41941,7 @@ var Processor = class _Processor extends CallableInstance {
|
|
|
41986
41941
|
let result;
|
|
41987
41942
|
this.run(tree, file, realDone);
|
|
41988
41943
|
assertDone("runSync", "run", complete);
|
|
41989
|
-
|
|
41944
|
+
ok(result, "we either bailed on an error or have a tree");
|
|
41990
41945
|
return result;
|
|
41991
41946
|
function realDone(error, tree2) {
|
|
41992
41947
|
bail(error);
|
|
@@ -42547,7 +42502,7 @@ function exitLiteralAutolinkHttp(token) {
|
|
|
42547
42502
|
function exitLiteralAutolinkWww(token) {
|
|
42548
42503
|
this.config.exit.data.call(this, token);
|
|
42549
42504
|
const node2 = this.stack[this.stack.length - 1];
|
|
42550
|
-
|
|
42505
|
+
ok(node2.type === "link");
|
|
42551
42506
|
node2.url = "http://" + this.sliceSerialize(token);
|
|
42552
42507
|
}
|
|
42553
42508
|
function exitLiteralAutolinkEmail(token) {
|
|
@@ -42658,7 +42613,7 @@ function enterFootnoteDefinition(token) {
|
|
|
42658
42613
|
function exitFootnoteCallString(token) {
|
|
42659
42614
|
const label = this.resume();
|
|
42660
42615
|
const node2 = this.stack[this.stack.length - 1];
|
|
42661
|
-
|
|
42616
|
+
ok(node2.type === "footnoteReference");
|
|
42662
42617
|
node2.identifier = normalizeIdentifier(
|
|
42663
42618
|
this.sliceSerialize(token)
|
|
42664
42619
|
).toLowerCase();
|
|
@@ -42670,7 +42625,7 @@ function exitFootnoteCall(token) {
|
|
|
42670
42625
|
function exitFootnoteDefinitionLabelString(token) {
|
|
42671
42626
|
const label = this.resume();
|
|
42672
42627
|
const node2 = this.stack[this.stack.length - 1];
|
|
42673
|
-
|
|
42628
|
+
ok(node2.type === "footnoteDefinition");
|
|
42674
42629
|
node2.identifier = normalizeIdentifier(
|
|
42675
42630
|
this.sliceSerialize(token)
|
|
42676
42631
|
).toLowerCase();
|
|
@@ -43877,7 +43832,7 @@ function gfmTableFromMarkdown() {
|
|
|
43877
43832
|
}
|
|
43878
43833
|
function enterTable(token) {
|
|
43879
43834
|
const align = token._align;
|
|
43880
|
-
|
|
43835
|
+
ok(align, "expected `_align` on table");
|
|
43881
43836
|
this.enter(
|
|
43882
43837
|
{
|
|
43883
43838
|
type: "table",
|
|
@@ -43909,7 +43864,7 @@ function exitCodeText(token) {
|
|
|
43909
43864
|
value = value.replace(/\\([\\|])/g, replace2);
|
|
43910
43865
|
}
|
|
43911
43866
|
const node2 = this.stack[this.stack.length - 1];
|
|
43912
|
-
|
|
43867
|
+
ok(node2.type === "inlineCode");
|
|
43913
43868
|
node2.value = value;
|
|
43914
43869
|
this.exit(token);
|
|
43915
43870
|
}
|
|
@@ -44028,14 +43983,14 @@ function gfmTaskListItemToMarkdown() {
|
|
|
44028
43983
|
}
|
|
44029
43984
|
function exitCheck(token) {
|
|
44030
43985
|
const node2 = this.stack[this.stack.length - 2];
|
|
44031
|
-
|
|
43986
|
+
ok(node2.type === "listItem");
|
|
44032
43987
|
node2.checked = token.type === "taskListCheckValueChecked";
|
|
44033
43988
|
}
|
|
44034
43989
|
function exitParagraphWithTaskListItem(token) {
|
|
44035
43990
|
const parent = this.stack[this.stack.length - 2];
|
|
44036
43991
|
if (parent && parent.type === "listItem" && typeof parent.checked === "boolean") {
|
|
44037
43992
|
const node2 = this.stack[this.stack.length - 1];
|
|
44038
|
-
|
|
43993
|
+
ok(node2.type === "paragraph");
|
|
44039
43994
|
const head = node2.children[0];
|
|
44040
43995
|
if (head && head.type === "text") {
|
|
44041
43996
|
const siblings = parent.children;
|
|
@@ -45412,7 +45367,7 @@ function remarkGfm(options) {
|
|
|
45412
45367
|
|
|
45413
45368
|
// src/components/resource/BrowseView.tsx
|
|
45414
45369
|
import { resourceUri as toResourceUri2 } from "@semiont/core";
|
|
45415
|
-
import {
|
|
45370
|
+
import { getMimeCategory as getMimeCategory2, isPdfMimeType as isPdfMimeType3 } from "@semiont/api-client";
|
|
45416
45371
|
|
|
45417
45372
|
// src/components/viewers/ImageViewer.tsx
|
|
45418
45373
|
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
@@ -45433,26 +45388,18 @@ function ImageViewer({ resourceUri: resourceUri2, alt = "Resource image" }) {
|
|
|
45433
45388
|
// src/components/resource/BrowseView.tsx
|
|
45434
45389
|
import { jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
45435
45390
|
var PdfAnnotationCanvas2 = lazy2(() => import("./PdfAnnotationCanvas.client-HNYRKFDS.mjs").then((mod) => ({ default: mod.PdfAnnotationCanvas })));
|
|
45436
|
-
function
|
|
45437
|
-
|
|
45438
|
-
|
|
45439
|
-
|
|
45440
|
-
|
|
45441
|
-
|
|
45442
|
-
|
|
45443
|
-
|
|
45444
|
-
|
|
45445
|
-
|
|
45446
|
-
|
|
45447
|
-
|
|
45448
|
-
length: end - start2,
|
|
45449
|
-
// remark plugin expects 'length', not 'end'
|
|
45450
|
-
type,
|
|
45451
|
-
source: getBodySource3(ann.body)
|
|
45452
|
-
};
|
|
45453
|
-
});
|
|
45454
|
-
}
|
|
45455
|
-
function BrowseView({
|
|
45391
|
+
var MemoizedMarkdown = memo(function MemoizedMarkdown2({
|
|
45392
|
+
content: content4
|
|
45393
|
+
}) {
|
|
45394
|
+
return /* @__PURE__ */ jsx27(
|
|
45395
|
+
Markdown,
|
|
45396
|
+
{
|
|
45397
|
+
remarkPlugins: [remarkGfm],
|
|
45398
|
+
children: content4
|
|
45399
|
+
}
|
|
45400
|
+
);
|
|
45401
|
+
});
|
|
45402
|
+
var BrowseView = memo(function BrowseView2({
|
|
45456
45403
|
content: content4,
|
|
45457
45404
|
mimeType,
|
|
45458
45405
|
resourceUri: resourceUri2,
|
|
@@ -45466,8 +45413,27 @@ function BrowseView({
|
|
|
45466
45413
|
const containerRef = useRef15(null);
|
|
45467
45414
|
const category = getMimeCategory2(mimeType);
|
|
45468
45415
|
const { highlights, references, assessments, comments, tags: tags3 } = annotations;
|
|
45469
|
-
const allAnnotations =
|
|
45470
|
-
|
|
45416
|
+
const allAnnotations = useMemo4(
|
|
45417
|
+
() => [...highlights, ...references, ...assessments, ...comments, ...tags3],
|
|
45418
|
+
[highlights, references, assessments, comments, tags3]
|
|
45419
|
+
);
|
|
45420
|
+
const overlayAnnotations = useMemo4(
|
|
45421
|
+
() => toOverlayAnnotations(allAnnotations),
|
|
45422
|
+
[allAnnotations]
|
|
45423
|
+
);
|
|
45424
|
+
const offsetMapRef = useRef15(null);
|
|
45425
|
+
useEffect22(() => {
|
|
45426
|
+
if (!containerRef.current) return;
|
|
45427
|
+
offsetMapRef.current = buildSourceToRenderedMap(content4, containerRef.current);
|
|
45428
|
+
}, [content4]);
|
|
45429
|
+
useEffect22(() => {
|
|
45430
|
+
if (!containerRef.current || !offsetMapRef.current || overlayAnnotations.length === 0) return;
|
|
45431
|
+
const container = containerRef.current;
|
|
45432
|
+
const textNodeIndex = buildTextNodeIndex(container);
|
|
45433
|
+
const ranges = resolveAnnotationRanges(overlayAnnotations, offsetMapRef.current, textNodeIndex);
|
|
45434
|
+
applyHighlights(ranges);
|
|
45435
|
+
return () => clearHighlights(container);
|
|
45436
|
+
}, [overlayAnnotations]);
|
|
45471
45437
|
useEffect22(() => {
|
|
45472
45438
|
if (!containerRef.current) return;
|
|
45473
45439
|
const container = containerRef.current;
|
|
@@ -45546,19 +45512,7 @@ function BrowseView({
|
|
|
45546
45512
|
annotators: ANNOTATORS
|
|
45547
45513
|
}
|
|
45548
45514
|
),
|
|
45549
|
-
/* @__PURE__ */ jsx27("div", { ref: containerRef, className: "semiont-browse-view__content", children: /* @__PURE__ */ jsx27(
|
|
45550
|
-
Markdown,
|
|
45551
|
-
{
|
|
45552
|
-
remarkPlugins: [
|
|
45553
|
-
remarkGfm,
|
|
45554
|
-
[remarkAnnotations, { annotations: preparedAnnotations }]
|
|
45555
|
-
],
|
|
45556
|
-
rehypePlugins: [
|
|
45557
|
-
rehypeRenderAnnotations
|
|
45558
|
-
],
|
|
45559
|
-
children: content4
|
|
45560
|
-
}
|
|
45561
|
-
) })
|
|
45515
|
+
/* @__PURE__ */ jsx27("div", { ref: containerRef, className: "semiont-browse-view__content", children: /* @__PURE__ */ jsx27(MemoizedMarkdown, { content: content4 }) })
|
|
45562
45516
|
] });
|
|
45563
45517
|
case "image":
|
|
45564
45518
|
if (isPdfMimeType3(mimeType)) {
|
|
@@ -45623,10 +45577,10 @@ function BrowseView({
|
|
|
45623
45577
|
)
|
|
45624
45578
|
] }) });
|
|
45625
45579
|
}
|
|
45626
|
-
}
|
|
45580
|
+
});
|
|
45627
45581
|
|
|
45628
45582
|
// src/components/resource/ResourceViewer.tsx
|
|
45629
|
-
import { useState as useState17, useEffect as useEffect23, useCallback as useCallback16, useRef as useRef16 } from "react";
|
|
45583
|
+
import { useState as useState17, useEffect as useEffect23, useCallback as useCallback16, useRef as useRef16, useMemo as useMemo5 } from "react";
|
|
45630
45584
|
import { resourceUri } from "@semiont/core";
|
|
45631
45585
|
import { getExactText as getExactText3, getTargetSelector as getTargetSelector4, isHighlight as isHighlight4, isAssessment as isAssessment3, isReference as isReference4, isComment as isComment4, isTag as isTag5, getBodySource as getBodySource4 } from "@semiont/api-client";
|
|
45632
45586
|
import { jsx as jsx28, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
@@ -45829,7 +45783,10 @@ function ResourceViewer({
|
|
|
45829
45783
|
// Annotation clicks
|
|
45830
45784
|
"attend:click": handleAnnotationClickEvent
|
|
45831
45785
|
});
|
|
45832
|
-
const annotationsCollection =
|
|
45786
|
+
const annotationsCollection = useMemo5(
|
|
45787
|
+
() => ({ highlights, references, assessments, comments, tags: tags3 }),
|
|
45788
|
+
[highlights, references, assessments, comments, tags3]
|
|
45789
|
+
);
|
|
45833
45790
|
const uiState = {
|
|
45834
45791
|
selectedMotivation,
|
|
45835
45792
|
selectedClick,
|
|
@@ -46019,7 +45976,7 @@ var AssessmentEntry = forwardRef(
|
|
|
46019
45976
|
);
|
|
46020
45977
|
|
|
46021
45978
|
// src/components/resource/panels/AssessmentPanel.tsx
|
|
46022
|
-
import { useState as useState19, useEffect as useEffect25, useRef as useRef17, useCallback as useCallback18, useMemo as
|
|
45979
|
+
import { useState as useState19, useEffect as useEffect25, useRef as useRef17, useCallback as useCallback18, useMemo as useMemo6 } from "react";
|
|
46023
45980
|
import { getTextPositionSelector as getTextPositionSelector3, getTargetSelector as getTargetSelector5 } from "@semiont/api-client";
|
|
46024
45981
|
|
|
46025
45982
|
// src/components/resource/panels/AssistSection.tsx
|
|
@@ -46269,7 +46226,7 @@ function AssessmentPanel({
|
|
|
46269
46226
|
const [focusedAnnotationId, setFocusedAnnotationId] = useState19(null);
|
|
46270
46227
|
const containerRef = useRef17(null);
|
|
46271
46228
|
const entryRefs = useRef17(/* @__PURE__ */ new Map());
|
|
46272
|
-
const sortedAnnotations =
|
|
46229
|
+
const sortedAnnotations = useMemo6(() => {
|
|
46273
46230
|
return [...annotations].sort((a15, b8) => {
|
|
46274
46231
|
const aSelector = getTextPositionSelector3(getTargetSelector5(a15.target));
|
|
46275
46232
|
const bSelector = getTextPositionSelector3(getTargetSelector5(b8.target));
|
|
@@ -46630,7 +46587,7 @@ var CommentEntry = forwardRef2(
|
|
|
46630
46587
|
);
|
|
46631
46588
|
|
|
46632
46589
|
// src/components/resource/panels/CommentsPanel.tsx
|
|
46633
|
-
import { useState as useState21, useEffect as useEffect27, useRef as useRef19, useCallback as useCallback19, useMemo as
|
|
46590
|
+
import { useState as useState21, useEffect as useEffect27, useRef as useRef19, useCallback as useCallback19, useMemo as useMemo7 } from "react";
|
|
46634
46591
|
import { getTextPositionSelector as getTextPositionSelector4, getTargetSelector as getTargetSelector6 } from "@semiont/api-client";
|
|
46635
46592
|
import { jsx as jsx35, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
46636
46593
|
function getSelectorDisplayText2(selector) {
|
|
@@ -46662,7 +46619,7 @@ function CommentsPanel({
|
|
|
46662
46619
|
const [focusedAnnotationId, setFocusedAnnotationId] = useState21(null);
|
|
46663
46620
|
const containerRef = useRef19(null);
|
|
46664
46621
|
const entryRefs = useRef19(/* @__PURE__ */ new Map());
|
|
46665
|
-
const sortedAnnotations =
|
|
46622
|
+
const sortedAnnotations = useMemo7(() => {
|
|
46666
46623
|
return [...annotations].sort((a15, b8) => {
|
|
46667
46624
|
const aSelector = getTextPositionSelector4(getTargetSelector6(a15.target));
|
|
46668
46625
|
const bSelector = getTextPositionSelector4(getTargetSelector6(b8.target));
|
|
@@ -46873,7 +46830,7 @@ var HighlightEntry = forwardRef3(
|
|
|
46873
46830
|
);
|
|
46874
46831
|
|
|
46875
46832
|
// src/components/resource/panels/HighlightPanel.tsx
|
|
46876
|
-
import { useEffect as useEffect28, useState as useState22, useRef as useRef20, useCallback as useCallback20, useMemo as
|
|
46833
|
+
import { useEffect as useEffect28, useState as useState22, useRef as useRef20, useCallback as useCallback20, useMemo as useMemo8 } from "react";
|
|
46877
46834
|
import { getTextPositionSelector as getTextPositionSelector5, getTargetSelector as getTargetSelector7 } from "@semiont/api-client";
|
|
46878
46835
|
import { jsx as jsx36, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
46879
46836
|
function HighlightPanel({
|
|
@@ -46891,7 +46848,7 @@ function HighlightPanel({
|
|
|
46891
46848
|
const [focusedAnnotationId, setFocusedAnnotationId] = useState22(null);
|
|
46892
46849
|
const containerRef = useRef20(null);
|
|
46893
46850
|
const entryRefs = useRef20(/* @__PURE__ */ new Map());
|
|
46894
|
-
const sortedAnnotations =
|
|
46851
|
+
const sortedAnnotations = useMemo8(() => {
|
|
46895
46852
|
return [...annotations].sort((a15, b8) => {
|
|
46896
46853
|
const aSelector = getTextPositionSelector5(getTargetSelector7(a15.target));
|
|
46897
46854
|
const bSelector = getTextPositionSelector5(getTargetSelector7(b8.target));
|
|
@@ -47217,7 +47174,7 @@ var ReferenceEntry = forwardRef4(
|
|
|
47217
47174
|
);
|
|
47218
47175
|
|
|
47219
47176
|
// src/components/resource/panels/ReferencesPanel.tsx
|
|
47220
|
-
import { useState as useState23, useRef as useRef22, useEffect as useEffect30, useCallback as useCallback21, useMemo as
|
|
47177
|
+
import { useState as useState23, useRef as useRef22, useEffect as useEffect30, useCallback as useCallback21, useMemo as useMemo9 } from "react";
|
|
47221
47178
|
import { getTextPositionSelector as getTextPositionSelector6, getTargetSelector as getTargetSelector9 } from "@semiont/api-client";
|
|
47222
47179
|
import { Fragment as Fragment8, jsx as jsx39, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
47223
47180
|
function getSelectorDisplayText3(selector) {
|
|
@@ -47267,7 +47224,7 @@ function ReferencesPanel({
|
|
|
47267
47224
|
localStorage.setItem("assist-section-expanded-reference", String(isAssistExpanded));
|
|
47268
47225
|
}, [isAssistExpanded]);
|
|
47269
47226
|
const entryRefs = useRef22(/* @__PURE__ */ new Map());
|
|
47270
|
-
const sortedAnnotations =
|
|
47227
|
+
const sortedAnnotations = useMemo9(() => {
|
|
47271
47228
|
return [...annotations].sort((a15, b8) => {
|
|
47272
47229
|
const aSelector = getTextPositionSelector6(getTargetSelector9(a15.target));
|
|
47273
47230
|
const bSelector = getTextPositionSelector6(getTargetSelector9(b8.target));
|
|
@@ -47775,7 +47732,7 @@ var TagEntry = forwardRef5(
|
|
|
47775
47732
|
);
|
|
47776
47733
|
|
|
47777
47734
|
// src/components/resource/panels/TaggingPanel.tsx
|
|
47778
|
-
import { useState as useState24, useEffect as useEffect31, useRef as useRef23, useCallback as useCallback22, useMemo as
|
|
47735
|
+
import { useState as useState24, useEffect as useEffect31, useRef as useRef23, useCallback as useCallback22, useMemo as useMemo10 } from "react";
|
|
47779
47736
|
import { getTextPositionSelector as getTextPositionSelector7, getTargetSelector as getTargetSelector10 } from "@semiont/api-client";
|
|
47780
47737
|
import { Fragment as Fragment10, jsx as jsx43, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
47781
47738
|
function getSelectorDisplayText4(selector) {
|
|
@@ -47824,7 +47781,7 @@ function TaggingPanel({
|
|
|
47824
47781
|
"attend:click": handleAnnotationClick
|
|
47825
47782
|
});
|
|
47826
47783
|
const entryRefs = useRef23(/* @__PURE__ */ new Map());
|
|
47827
|
-
const sortedAnnotations =
|
|
47784
|
+
const sortedAnnotations = useMemo10(() => {
|
|
47828
47785
|
return [...annotations].sort((a15, b8) => {
|
|
47829
47786
|
const aSelector = getTextPositionSelector7(getTargetSelector10(a15.target));
|
|
47830
47787
|
const bSelector = getTextPositionSelector7(getTargetSelector10(b8.target));
|
|
@@ -48593,16 +48550,16 @@ function SimpleNavigation({
|
|
|
48593
48550
|
import { useCallback as useCallback29, useState as useState31, useRef as useRef30, useEffect as useEffect39 } from "react";
|
|
48594
48551
|
|
|
48595
48552
|
// ../../node_modules/@dnd-kit/core/dist/core.esm.js
|
|
48596
|
-
import React20, { createContext as createContext7, useContext as useContext7, useEffect as useEffect36, useState as useState29, useCallback as useCallback26, useMemo as
|
|
48553
|
+
import React20, { createContext as createContext7, useContext as useContext7, useEffect as useEffect36, useState as useState29, useCallback as useCallback26, useMemo as useMemo12, useRef as useRef27, memo as memo2, useReducer, cloneElement, forwardRef as forwardRef6 } from "react";
|
|
48597
48554
|
import { createPortal, unstable_batchedUpdates } from "react-dom";
|
|
48598
48555
|
|
|
48599
48556
|
// ../../node_modules/@dnd-kit/utilities/dist/utilities.esm.js
|
|
48600
|
-
import { useMemo as
|
|
48557
|
+
import { useMemo as useMemo11, useLayoutEffect, useEffect as useEffect35, useRef as useRef26, useCallback as useCallback24 } from "react";
|
|
48601
48558
|
function useCombinedRefs() {
|
|
48602
48559
|
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
48603
48560
|
refs[_key] = arguments[_key];
|
|
48604
48561
|
}
|
|
48605
|
-
return
|
|
48562
|
+
return useMemo11(
|
|
48606
48563
|
() => (node2) => {
|
|
48607
48564
|
refs.forEach((ref) => ref(node2));
|
|
48608
48565
|
},
|
|
@@ -48705,7 +48662,7 @@ function useLatestValue(value, dependencies) {
|
|
|
48705
48662
|
}
|
|
48706
48663
|
function useLazyMemo(callback, dependencies) {
|
|
48707
48664
|
const valueRef = useRef26();
|
|
48708
|
-
return
|
|
48665
|
+
return useMemo11(
|
|
48709
48666
|
() => {
|
|
48710
48667
|
const newValue = callback(valueRef.current);
|
|
48711
48668
|
valueRef.current = newValue;
|
|
@@ -48739,7 +48696,7 @@ function usePrevious(value) {
|
|
|
48739
48696
|
}
|
|
48740
48697
|
var ids = {};
|
|
48741
48698
|
function useUniqueId(prefix, value) {
|
|
48742
|
-
return
|
|
48699
|
+
return useMemo11(() => {
|
|
48743
48700
|
if (value) {
|
|
48744
48701
|
return value;
|
|
48745
48702
|
}
|
|
@@ -49011,7 +48968,7 @@ function Accessibility(_ref) {
|
|
|
49011
48968
|
useEffect36(() => {
|
|
49012
48969
|
setMounted(true);
|
|
49013
48970
|
}, []);
|
|
49014
|
-
useDndMonitor(
|
|
48971
|
+
useDndMonitor(useMemo12(() => ({
|
|
49015
48972
|
onDragStart(_ref2) {
|
|
49016
48973
|
let {
|
|
49017
48974
|
active
|
|
@@ -49089,7 +49046,7 @@ var Action;
|
|
|
49089
49046
|
function noop() {
|
|
49090
49047
|
}
|
|
49091
49048
|
function useSensor(sensor, options) {
|
|
49092
|
-
return
|
|
49049
|
+
return useMemo12(
|
|
49093
49050
|
() => ({
|
|
49094
49051
|
sensor,
|
|
49095
49052
|
options: options != null ? options : {}
|
|
@@ -49102,7 +49059,7 @@ function useSensors() {
|
|
|
49102
49059
|
for (var _len = arguments.length, sensors = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
49103
49060
|
sensors[_key] = arguments[_key];
|
|
49104
49061
|
}
|
|
49105
|
-
return
|
|
49062
|
+
return useMemo12(
|
|
49106
49063
|
() => [...sensors].filter((sensor) => sensor != null),
|
|
49107
49064
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49108
49065
|
[...sensors]
|
|
@@ -50352,7 +50309,7 @@ function useAutoScroller(_ref) {
|
|
|
50352
50309
|
x: 0,
|
|
50353
50310
|
y: 0
|
|
50354
50311
|
});
|
|
50355
|
-
const rect =
|
|
50312
|
+
const rect = useMemo12(() => {
|
|
50356
50313
|
switch (activator) {
|
|
50357
50314
|
case AutoScrollActivator.Pointer:
|
|
50358
50315
|
return pointerCoordinates ? {
|
|
@@ -50375,7 +50332,7 @@ function useAutoScroller(_ref) {
|
|
|
50375
50332
|
const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
|
|
50376
50333
|
scrollContainer.scrollBy(scrollLeft, scrollTop);
|
|
50377
50334
|
}, []);
|
|
50378
|
-
const sortedScrollableAncestors =
|
|
50335
|
+
const sortedScrollableAncestors = useMemo12(() => order2 === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order2, scrollableAncestors]);
|
|
50379
50336
|
useEffect36(
|
|
50380
50337
|
() => {
|
|
50381
50338
|
if (!enabled || !scrollableAncestors.length || !rect) {
|
|
@@ -50489,7 +50446,7 @@ function useCachedNode(draggableNodes, id2) {
|
|
|
50489
50446
|
}, [node2, id2]);
|
|
50490
50447
|
}
|
|
50491
50448
|
function useCombineActivators(sensors, getSyntheticHandler) {
|
|
50492
|
-
return
|
|
50449
|
+
return useMemo12(() => sensors.reduce((accumulator, sensor) => {
|
|
50493
50450
|
const {
|
|
50494
50451
|
sensor: Sensor
|
|
50495
50452
|
} = sensor;
|
|
@@ -50637,7 +50594,7 @@ function useMutationObserver(_ref) {
|
|
|
50637
50594
|
disabled
|
|
50638
50595
|
} = _ref;
|
|
50639
50596
|
const handleMutations = useEvent(callback);
|
|
50640
|
-
const mutationObserver =
|
|
50597
|
+
const mutationObserver = useMemo12(() => {
|
|
50641
50598
|
if (disabled || typeof window === "undefined" || typeof window.MutationObserver === "undefined") {
|
|
50642
50599
|
return void 0;
|
|
50643
50600
|
}
|
|
@@ -50657,7 +50614,7 @@ function useResizeObserver(_ref) {
|
|
|
50657
50614
|
disabled
|
|
50658
50615
|
} = _ref;
|
|
50659
50616
|
const handleResize = useEvent(callback);
|
|
50660
|
-
const resizeObserver =
|
|
50617
|
+
const resizeObserver = useMemo12(
|
|
50661
50618
|
() => {
|
|
50662
50619
|
if (disabled || typeof window === "undefined" || typeof window.ResizeObserver === "undefined") {
|
|
50663
50620
|
return void 0;
|
|
@@ -50799,7 +50756,7 @@ function useScrollOffsets(elements) {
|
|
|
50799
50756
|
});
|
|
50800
50757
|
}
|
|
50801
50758
|
}, [handleScroll, elements]);
|
|
50802
|
-
return
|
|
50759
|
+
return useMemo12(() => {
|
|
50803
50760
|
if (elements.length) {
|
|
50804
50761
|
return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
|
|
50805
50762
|
}
|
|
@@ -50858,7 +50815,7 @@ function useSensorSetup(sensors) {
|
|
|
50858
50815
|
);
|
|
50859
50816
|
}
|
|
50860
50817
|
function useSyntheticListeners(listeners, id2) {
|
|
50861
|
-
return
|
|
50818
|
+
return useMemo12(() => {
|
|
50862
50819
|
return listeners.reduce((acc, _ref) => {
|
|
50863
50820
|
let {
|
|
50864
50821
|
eventName,
|
|
@@ -50872,7 +50829,7 @@ function useSyntheticListeners(listeners, id2) {
|
|
|
50872
50829
|
}, [listeners, id2]);
|
|
50873
50830
|
}
|
|
50874
50831
|
function useWindowRect(element2) {
|
|
50875
|
-
return
|
|
50832
|
+
return useMemo12(() => element2 ? getWindowClientRect(element2) : null, [element2]);
|
|
50876
50833
|
}
|
|
50877
50834
|
var defaultValue$2 = [];
|
|
50878
50835
|
function useRects(elements, measure) {
|
|
@@ -50944,7 +50901,7 @@ function useDragOverlayMeasuring(_ref) {
|
|
|
50944
50901
|
setRect(node2 ? measure(node2) : null);
|
|
50945
50902
|
}, [measure, resizeObserver]);
|
|
50946
50903
|
const [nodeRef, setRef] = useNodeRef(handleNodeChange);
|
|
50947
|
-
return
|
|
50904
|
+
return useMemo12(() => ({
|
|
50948
50905
|
nodeRef,
|
|
50949
50906
|
rect,
|
|
50950
50907
|
setRef
|
|
@@ -51221,7 +51178,7 @@ function applyModifiers(modifiers2, _ref) {
|
|
|
51221
51178
|
}, transform) : transform;
|
|
51222
51179
|
}
|
|
51223
51180
|
function useMeasuringConfiguration(config) {
|
|
51224
|
-
return
|
|
51181
|
+
return useMemo12(
|
|
51225
51182
|
() => ({
|
|
51226
51183
|
draggable: {
|
|
51227
51184
|
...defaultMeasuringConfiguration.draggable,
|
|
@@ -51299,7 +51256,7 @@ var Status;
|
|
|
51299
51256
|
Status2[Status2["Initializing"] = 1] = "Initializing";
|
|
51300
51257
|
Status2[Status2["Initialized"] = 2] = "Initialized";
|
|
51301
51258
|
})(Status || (Status = {}));
|
|
51302
|
-
var DndContext = /* @__PURE__ */
|
|
51259
|
+
var DndContext = /* @__PURE__ */ memo2(function DndContext2(_ref) {
|
|
51303
51260
|
var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
|
|
51304
51261
|
let {
|
|
51305
51262
|
id: id2,
|
|
@@ -51332,7 +51289,7 @@ var DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
|
|
|
51332
51289
|
initial: null,
|
|
51333
51290
|
translated: null
|
|
51334
51291
|
});
|
|
51335
|
-
const active =
|
|
51292
|
+
const active = useMemo12(() => {
|
|
51336
51293
|
var _node$data;
|
|
51337
51294
|
return activeId != null ? {
|
|
51338
51295
|
id: activeId,
|
|
@@ -51346,7 +51303,7 @@ var DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
|
|
|
51346
51303
|
const [activatorEvent, setActivatorEvent] = useState29(null);
|
|
51347
51304
|
const latestProps = useLatestValue(props, Object.values(props));
|
|
51348
51305
|
const draggableDescribedById = useUniqueId("DndDescribedBy", id2);
|
|
51349
|
-
const enabledDroppableContainers =
|
|
51306
|
+
const enabledDroppableContainers = useMemo12(() => droppableContainers.getEnabled(), [droppableContainers]);
|
|
51350
51307
|
const measuringConfiguration = useMeasuringConfiguration(measuring);
|
|
51351
51308
|
const {
|
|
51352
51309
|
droppableRects,
|
|
@@ -51358,7 +51315,7 @@ var DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
|
|
|
51358
51315
|
config: measuringConfiguration.droppable
|
|
51359
51316
|
});
|
|
51360
51317
|
const activeNode = useCachedNode(draggableNodes, activeId);
|
|
51361
|
-
const activationCoordinates =
|
|
51318
|
+
const activationCoordinates = useMemo12(() => activatorEvent ? getEventCoordinates(activatorEvent) : null, [activatorEvent]);
|
|
51362
51319
|
const autoScrollOptions = getAutoScrollerOptions();
|
|
51363
51320
|
const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure);
|
|
51364
51321
|
useLayoutShiftScrollCompensation({
|
|
@@ -51729,7 +51686,7 @@ var DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
|
|
|
51729
51686
|
scrollableAncestors,
|
|
51730
51687
|
scrollableAncestorRects
|
|
51731
51688
|
});
|
|
51732
|
-
const publicContext =
|
|
51689
|
+
const publicContext = useMemo12(() => {
|
|
51733
51690
|
const context = {
|
|
51734
51691
|
active,
|
|
51735
51692
|
activeNode,
|
|
@@ -51751,7 +51708,7 @@ var DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
|
|
|
51751
51708
|
};
|
|
51752
51709
|
return context;
|
|
51753
51710
|
}, [active, activeNode, activeNodeRect, activatorEvent, collisions, containerNodeRect, dragOverlay, draggableNodes, droppableContainers, droppableRects, over, measureDroppableContainers, scrollableAncestors, scrollableAncestorRects, measuringConfiguration, measuringScheduled, windowRect2]);
|
|
51754
|
-
const internalContext =
|
|
51711
|
+
const internalContext = useMemo12(() => {
|
|
51755
51712
|
const context = {
|
|
51756
51713
|
activatorEvent,
|
|
51757
51714
|
activators,
|
|
@@ -51846,7 +51803,7 @@ function useDraggable(_ref) {
|
|
|
51846
51803
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51847
51804
|
[draggableNodes, id2]
|
|
51848
51805
|
);
|
|
51849
|
-
const memoizedAttributes =
|
|
51806
|
+
const memoizedAttributes = useMemo12(() => ({
|
|
51850
51807
|
role,
|
|
51851
51808
|
tabIndex,
|
|
51852
51809
|
"aria-disabled": disabled,
|
|
@@ -51991,7 +51948,7 @@ function useDroppable(_ref) {
|
|
|
51991
51948
|
}
|
|
51992
51949
|
|
|
51993
51950
|
// ../../node_modules/@dnd-kit/sortable/dist/sortable.esm.js
|
|
51994
|
-
import React21, { useMemo as
|
|
51951
|
+
import React21, { useMemo as useMemo13, useRef as useRef28, useEffect as useEffect37, useState as useState30, useContext as useContext8 } from "react";
|
|
51995
51952
|
function arrayMove(array, from, to) {
|
|
51996
51953
|
const newArray = array.slice();
|
|
51997
51954
|
newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]);
|
|
@@ -52145,7 +52102,7 @@ function SortableContext(_ref) {
|
|
|
52145
52102
|
} = useDndContext();
|
|
52146
52103
|
const containerId = useUniqueId(ID_PREFIX2, id2);
|
|
52147
52104
|
const useDragOverlay = Boolean(dragOverlay.rect !== null);
|
|
52148
|
-
const items =
|
|
52105
|
+
const items = useMemo13(() => userDefinedItems.map((item) => typeof item === "object" && "id" in item ? item.id : item), [userDefinedItems]);
|
|
52149
52106
|
const isDragging = active != null;
|
|
52150
52107
|
const activeIndex = active ? items.indexOf(active.id) : -1;
|
|
52151
52108
|
const overIndex = over ? items.indexOf(over.id) : -1;
|
|
@@ -52161,7 +52118,7 @@ function SortableContext(_ref) {
|
|
|
52161
52118
|
useEffect37(() => {
|
|
52162
52119
|
previousItemsRef.current = items;
|
|
52163
52120
|
}, [items]);
|
|
52164
|
-
const contextValue =
|
|
52121
|
+
const contextValue = useMemo13(
|
|
52165
52122
|
() => ({
|
|
52166
52123
|
activeIndex,
|
|
52167
52124
|
containerId,
|
|
@@ -52288,7 +52245,7 @@ function useSortable(_ref) {
|
|
|
52288
52245
|
} = useContext8(Context2);
|
|
52289
52246
|
const disabled = normalizeLocalDisabled(localDisabled, globalDisabled);
|
|
52290
52247
|
const index2 = items.indexOf(id2);
|
|
52291
|
-
const data2 =
|
|
52248
|
+
const data2 = useMemo13(() => ({
|
|
52292
52249
|
sortable: {
|
|
52293
52250
|
containerId,
|
|
52294
52251
|
index: index2,
|
|
@@ -52296,7 +52253,7 @@ function useSortable(_ref) {
|
|
|
52296
52253
|
},
|
|
52297
52254
|
...customData
|
|
52298
52255
|
}), [containerId, customData, index2, items]);
|
|
52299
|
-
const itemsAfterCurrentSortable =
|
|
52256
|
+
const itemsAfterCurrentSortable = useMemo13(() => items.slice(items.indexOf(id2)), [items, id2]);
|
|
52300
52257
|
const {
|
|
52301
52258
|
rect,
|
|
52302
52259
|
node: node2,
|
|
@@ -56400,7 +56357,7 @@ function ResourceDiscoveryPage({
|
|
|
56400
56357
|
}
|
|
56401
56358
|
|
|
56402
56359
|
// src/features/resource-viewer/components/ResourceViewerPage.tsx
|
|
56403
|
-
import { useState as useState45, useEffect as useEffect49, useCallback as useCallback36, useMemo as
|
|
56360
|
+
import { useState as useState45, useEffect as useEffect49, useCallback as useCallback36, useMemo as useMemo14 } from "react";
|
|
56404
56361
|
import { useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
56405
56362
|
import { resourceAnnotationUri as resourceAnnotationUri3 } from "@semiont/core";
|
|
56406
56363
|
import { getLanguage, getPrimaryRepresentation, getPrimaryMediaType as getPrimaryMediaType2 } from "@semiont/api-client";
|
|
@@ -57035,7 +56992,7 @@ function ResourceViewerPage({
|
|
|
57035
56992
|
const entityTypesAPI = useEntityTypes();
|
|
57036
56993
|
const { content: content4, loading: contentLoading } = useResourceContent(rUri, resource);
|
|
57037
56994
|
const { data: annotationsData } = resources.annotations.useQuery(rUri);
|
|
57038
|
-
const annotations =
|
|
56995
|
+
const annotations = useMemo14(
|
|
57039
56996
|
() => annotationsData?.annotations || [],
|
|
57040
56997
|
[annotationsData?.annotations]
|
|
57041
56998
|
);
|
|
@@ -57165,8 +57122,8 @@ function ResourceViewerPage({
|
|
|
57165
57122
|
}, [updateMutation, rUri, refetchDocument, showError]);
|
|
57166
57123
|
const handleResourceClone = useCallback36(async () => {
|
|
57167
57124
|
try {
|
|
57168
|
-
const
|
|
57169
|
-
const token =
|
|
57125
|
+
const result = await generateCloneTokenMutation.mutateAsync(rUri);
|
|
57126
|
+
const token = result.token;
|
|
57170
57127
|
eventBus.get("navigation:router-push").next({ path: `/know/compose?mode=clone&token=${token}`, reason: "clone" });
|
|
57171
57128
|
} catch (err) {
|
|
57172
57129
|
console.error("Failed to generate clone token:", err);
|
|
@@ -57251,23 +57208,25 @@ function ResourceViewerPage({
|
|
|
57251
57208
|
}
|
|
57252
57209
|
return false;
|
|
57253
57210
|
});
|
|
57254
|
-
const
|
|
57255
|
-
|
|
57256
|
-
|
|
57257
|
-
|
|
57258
|
-
|
|
57259
|
-
|
|
57260
|
-
|
|
57261
|
-
|
|
57262
|
-
const
|
|
57263
|
-
|
|
57264
|
-
|
|
57265
|
-
|
|
57266
|
-
result[key]
|
|
57211
|
+
const groups = useMemo14(() => {
|
|
57212
|
+
const result = {
|
|
57213
|
+
highlights: [],
|
|
57214
|
+
references: [],
|
|
57215
|
+
assessments: [],
|
|
57216
|
+
comments: [],
|
|
57217
|
+
tags: []
|
|
57218
|
+
};
|
|
57219
|
+
for (const ann of annotations) {
|
|
57220
|
+
const annotator = Object.values(ANNOTATORS).find((a15) => a15.matchesAnnotation(ann));
|
|
57221
|
+
if (annotator) {
|
|
57222
|
+
const key = annotator.internalType + "s";
|
|
57223
|
+
if (result[key]) {
|
|
57224
|
+
result[key].push(ann);
|
|
57225
|
+
}
|
|
57267
57226
|
}
|
|
57268
57227
|
}
|
|
57269
|
-
|
|
57270
|
-
|
|
57228
|
+
return result;
|
|
57229
|
+
}, [annotations]);
|
|
57271
57230
|
const resourceWithContent = { ...resource, content: content4 };
|
|
57272
57231
|
const handleEventHover = useCallback36((annotationId) => {
|
|
57273
57232
|
if (annotationId) {
|
|
@@ -57539,7 +57498,11 @@ export {
|
|
|
57539
57498
|
UnifiedHeader,
|
|
57540
57499
|
UserMenuSkeleton,
|
|
57541
57500
|
WelcomePage,
|
|
57501
|
+
applyHighlights,
|
|
57502
|
+
buildSourceToRenderedMap,
|
|
57503
|
+
buildTextNodeIndex,
|
|
57542
57504
|
buttonStyles,
|
|
57505
|
+
clearHighlights,
|
|
57543
57506
|
createHoverHandlers,
|
|
57544
57507
|
cssVariables,
|
|
57545
57508
|
dispatch401Error,
|
|
@@ -57562,12 +57525,12 @@ export {
|
|
|
57562
57525
|
jsonLightHighlightStyle,
|
|
57563
57526
|
jsonLightTheme,
|
|
57564
57527
|
onAuthEvent,
|
|
57565
|
-
rehypeRenderAnnotations,
|
|
57566
|
-
remarkAnnotations,
|
|
57567
57528
|
resetEventBusForTesting,
|
|
57529
|
+
resolveAnnotationRanges,
|
|
57568
57530
|
sanitizeImageURL,
|
|
57569
57531
|
saveSelectedShapeForSelectorType,
|
|
57570
57532
|
supportsDetection,
|
|
57533
|
+
toOverlayAnnotations,
|
|
57571
57534
|
tokens,
|
|
57572
57535
|
useAdmin,
|
|
57573
57536
|
useAnnotationFlow,
|