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