@anaralabs/lector 3.5.11 → 3.5.12
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.js +11 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1136,8 +1136,10 @@ var consolidateHighlightRects = (rects) => {
|
|
|
1136
1136
|
return Math.abs(topDiff) < 2 ? a.left - b.left : topDiff;
|
|
1137
1137
|
});
|
|
1138
1138
|
let current = sorted[0];
|
|
1139
|
+
if (!current) return rects;
|
|
1139
1140
|
for (let i = 1; i < sorted.length; i++) {
|
|
1140
1141
|
const next = sorted[i];
|
|
1142
|
+
if (!next) continue;
|
|
1141
1143
|
const samePageAndLine = current.pageNumber === next.pageNumber && Math.abs(current.top - next.top) < Math.max(current.height, next.height) * 0.5;
|
|
1142
1144
|
const horizontallyConnected = samePageAndLine && // Adjacent (touching or very close)
|
|
1143
1145
|
(Math.abs(current.left + current.width - next.left) <= MERGE_THRESHOLD || Math.abs(next.left + next.width - current.left) <= MERGE_THRESHOLD || // Overlapping
|
|
@@ -1160,7 +1162,9 @@ var consolidateHighlightRects = (rects) => {
|
|
|
1160
1162
|
current = next;
|
|
1161
1163
|
}
|
|
1162
1164
|
}
|
|
1163
|
-
|
|
1165
|
+
if (current) {
|
|
1166
|
+
consolidated.push(current);
|
|
1167
|
+
}
|
|
1164
1168
|
return consolidated;
|
|
1165
1169
|
};
|
|
1166
1170
|
var consolidateRects = (rects) => {
|
|
@@ -1336,13 +1340,14 @@ var useSelectionDimensions = () => {
|
|
|
1336
1340
|
});
|
|
1337
1341
|
textLayerMapHighlight.forEach((rects) => {
|
|
1338
1342
|
if (rects.length > 0) {
|
|
1339
|
-
|
|
1340
|
-
|
|
1343
|
+
if (rects.length === 1) {
|
|
1344
|
+
highlightRects.push(...rects);
|
|
1345
|
+
} else {
|
|
1346
|
+
const consolidated = consolidateHighlightRects(rects);
|
|
1347
|
+
highlightRects.push(...consolidated);
|
|
1348
|
+
}
|
|
1341
1349
|
}
|
|
1342
1350
|
});
|
|
1343
|
-
const finalHighlights = consolidateHighlightRects(highlightRects);
|
|
1344
|
-
highlightRects.length = 0;
|
|
1345
|
-
highlightRects.push(...finalHighlights);
|
|
1346
1351
|
textLayerMapUnderline.forEach((rects) => {
|
|
1347
1352
|
if (rects.length > 0) {
|
|
1348
1353
|
const lineGroups = groupRectsByLine(rects);
|