@arbidocs/react 0.4.57 → 0.4.59
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 +17 -4
- package/dist/annotations/index.cjs.map +1 -1
- package/dist/annotations/index.js +17 -4
- package/dist/annotations/index.js.map +1 -1
- package/dist/artifacts/index.cjs +45 -60
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.d.cts +34 -19
- package/dist/artifacts/index.d.ts +34 -19
- package/dist/artifacts/index.js +33 -49
- package/dist/artifacts/index.js.map +1 -1
- package/dist/{chunk-R6V6YHPD.cjs → chunk-X75MAVGQ.cjs} +15 -3
- package/dist/chunk-X75MAVGQ.cjs.map +1 -0
- package/dist/{chunk-XKGTZ3H6.js → chunk-YYXX7KGR.js} +15 -4
- package/dist/chunk-YYXX7KGR.js.map +1 -0
- package/dist/index.cjs +104 -104
- package/dist/index.d.cts +20 -11
- package/dist/index.d.ts +20 -11
- package/dist/index.js +5 -5
- package/package.json +3 -3
- package/dist/chunk-R6V6YHPD.cjs.map +0 -1
- package/dist/chunk-XKGTZ3H6.js.map +0 -1
|
@@ -478,6 +478,19 @@ function clipRange(range, container) {
|
|
|
478
478
|
}
|
|
479
479
|
return clipped;
|
|
480
480
|
}
|
|
481
|
+
function textClientRects(range, container) {
|
|
482
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_TEXT);
|
|
483
|
+
const rects = [];
|
|
484
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
485
|
+
if (!node.textContent?.trim() || !range.intersectsNode(node)) continue;
|
|
486
|
+
const part = document.createRange();
|
|
487
|
+
part.selectNodeContents(node);
|
|
488
|
+
if (node === range.startContainer) part.setStart(node, range.startOffset);
|
|
489
|
+
if (node === range.endContainer) part.setEnd(node, range.endOffset);
|
|
490
|
+
rects.push(...Array.from(part.getClientRects()));
|
|
491
|
+
}
|
|
492
|
+
return rects;
|
|
493
|
+
}
|
|
481
494
|
function readSelection(selection, root = document) {
|
|
482
495
|
if (selection.rangeCount === 0 || selection.isCollapsed) return [];
|
|
483
496
|
const range = selection.getRangeAt(0);
|
|
@@ -491,7 +504,7 @@ function readSelection(selection, root = document) {
|
|
|
491
504
|
pages.push({
|
|
492
505
|
page,
|
|
493
506
|
box: toPixelRect(overlay.getBoundingClientRect()),
|
|
494
|
-
rects:
|
|
507
|
+
rects: textClientRects(clipped, container).map(toPixelRect),
|
|
495
508
|
text: clipped.toString()
|
|
496
509
|
});
|
|
497
510
|
});
|
|
@@ -501,9 +514,9 @@ function readSelection(selection, root = document) {
|
|
|
501
514
|
// src/annotations/useTextSelectionMarks.ts
|
|
502
515
|
var PAGE_SELECTOR = "[data-page-number]";
|
|
503
516
|
var TOUCH_SETTLE_MS = 700;
|
|
504
|
-
var MOUSE_SETTLE_MS =
|
|
505
|
-
var STABLE_CHECKS =
|
|
506
|
-
var MAX_SETTLE_ROUNDS =
|
|
517
|
+
var MOUSE_SETTLE_MS = 80;
|
|
518
|
+
var STABLE_CHECKS = 3;
|
|
519
|
+
var MAX_SETTLE_ROUNDS = 12;
|
|
507
520
|
function useTextSelectionMarks(controller) {
|
|
508
521
|
const latest = useRef(controller);
|
|
509
522
|
latest.current = controller;
|