@anaralabs/lector 3.5.10 → 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 +38 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -548,9 +548,8 @@ var AnnotationHighlightLayer = ({
|
|
|
548
548
|
top: rect.top,
|
|
549
549
|
left: rect.left,
|
|
550
550
|
width: rect.width,
|
|
551
|
-
height:
|
|
552
|
-
backgroundColor: annotation.borderColor
|
|
553
|
-
borderBottom: "1.5px"
|
|
551
|
+
height: 1.1,
|
|
552
|
+
backgroundColor: annotation.borderColor
|
|
554
553
|
},
|
|
555
554
|
"data-comment-id": annotation.id
|
|
556
555
|
},
|
|
@@ -1129,36 +1128,44 @@ var shouldMergeRects = (rect1, rect2) => {
|
|
|
1129
1128
|
};
|
|
1130
1129
|
var consolidateHighlightRects = (rects) => {
|
|
1131
1130
|
if (rects.length <= 1) return rects;
|
|
1131
|
+
const consolidated = [];
|
|
1132
1132
|
const sorted = [...rects].sort((a, b) => {
|
|
1133
|
+
const pageCompare = a.pageNumber - b.pageNumber;
|
|
1134
|
+
if (pageCompare !== 0) return pageCompare;
|
|
1133
1135
|
const topDiff = a.top - b.top;
|
|
1134
1136
|
return Math.abs(topDiff) < 2 ? a.left - b.left : topDiff;
|
|
1135
1137
|
});
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
+
let current = sorted[0];
|
|
1139
|
+
if (!current) return rects;
|
|
1138
1140
|
for (let i = 1; i < sorted.length; i++) {
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1141
|
-
const
|
|
1142
|
-
const
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1141
|
+
const next = sorted[i];
|
|
1142
|
+
if (!next) continue;
|
|
1143
|
+
const samePageAndLine = current.pageNumber === next.pageNumber && Math.abs(current.top - next.top) < Math.max(current.height, next.height) * 0.5;
|
|
1144
|
+
const horizontallyConnected = samePageAndLine && // Adjacent (touching or very close)
|
|
1145
|
+
(Math.abs(current.left + current.width - next.left) <= MERGE_THRESHOLD || Math.abs(next.left + next.width - current.left) <= MERGE_THRESHOLD || // Overlapping
|
|
1146
|
+
current.left < next.left + next.width && next.left < current.left + current.width || // Very close (small gap)
|
|
1147
|
+
Math.abs(current.left + current.width - next.left) <= current.height * 0.2);
|
|
1148
|
+
if (horizontallyConnected) {
|
|
1149
|
+
const newLeft = Math.min(current.left, next.left);
|
|
1150
|
+
const newRight = Math.max(current.left + current.width, next.left + next.width);
|
|
1151
|
+
const newTop = Math.min(current.top, next.top);
|
|
1152
|
+
const newBottom = Math.max(current.top + current.height, next.top + next.height);
|
|
1153
|
+
current = {
|
|
1154
|
+
left: newLeft,
|
|
1155
|
+
top: newTop,
|
|
1156
|
+
width: newRight - newLeft,
|
|
1157
|
+
height: newBottom - newTop,
|
|
1158
|
+
pageNumber: current.pageNumber
|
|
1159
|
+
};
|
|
1147
1160
|
} else {
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
} else {
|
|
1151
|
-
result.push(mergeRectGroup(currentGroup));
|
|
1152
|
-
}
|
|
1153
|
-
currentGroup = [currentRect];
|
|
1161
|
+
consolidated.push(current);
|
|
1162
|
+
current = next;
|
|
1154
1163
|
}
|
|
1155
1164
|
}
|
|
1156
|
-
if (
|
|
1157
|
-
|
|
1158
|
-
} else {
|
|
1159
|
-
result.push(mergeRectGroup(currentGroup));
|
|
1165
|
+
if (current) {
|
|
1166
|
+
consolidated.push(current);
|
|
1160
1167
|
}
|
|
1161
|
-
return
|
|
1168
|
+
return consolidated;
|
|
1162
1169
|
};
|
|
1163
1170
|
var consolidateRects = (rects) => {
|
|
1164
1171
|
if (rects.length <= 1) return rects;
|
|
@@ -1333,8 +1340,12 @@ var useSelectionDimensions = () => {
|
|
|
1333
1340
|
});
|
|
1334
1341
|
textLayerMapHighlight.forEach((rects) => {
|
|
1335
1342
|
if (rects.length > 0) {
|
|
1336
|
-
|
|
1337
|
-
|
|
1343
|
+
if (rects.length === 1) {
|
|
1344
|
+
highlightRects.push(...rects);
|
|
1345
|
+
} else {
|
|
1346
|
+
const consolidated = consolidateHighlightRects(rects);
|
|
1347
|
+
highlightRects.push(...consolidated);
|
|
1348
|
+
}
|
|
1338
1349
|
}
|
|
1339
1350
|
});
|
|
1340
1351
|
textLayerMapUnderline.forEach((rects) => {
|
|
@@ -1368,11 +1379,9 @@ var useSelectionDimensions = () => {
|
|
|
1368
1379
|
i++;
|
|
1369
1380
|
continue;
|
|
1370
1381
|
}
|
|
1371
|
-
const zoom = store.getState().zoom;
|
|
1372
1382
|
const lineRect = {
|
|
1373
1383
|
width: endRect.left + endRect.width - startRect.left,
|
|
1374
|
-
height:
|
|
1375
|
-
// Fixed 2px thickness
|
|
1384
|
+
height: 1.5,
|
|
1376
1385
|
top: startRect.top,
|
|
1377
1386
|
left: startRect.left,
|
|
1378
1387
|
pageNumber: startRect.pageNumber
|