@koi-br/ocr-web-sdk 1.0.46 → 1.0.48
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-DOjPkvyb.js → index-BPOvXxGT.js} +77 -77
- package/dist/{index-4BxqLxuQ.mjs → index-CUF5xedC.mjs} +6734 -6714
- package/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +2 -2
- package/dist/{tiff.min-BZeJgFo-.mjs → tiff.min-L8dsfe48.mjs} +1 -1
- package/dist/{tiff.min-DJDAfob-.js → tiff.min-VG_zD9-5.js} +1 -1
- package/package.json +1 -1
- package/preview/ImagePreview.vue +50 -14
- package/preview/index.vue +2 -1
package/package.json
CHANGED
package/preview/ImagePreview.vue
CHANGED
|
@@ -360,11 +360,6 @@ const props = defineProps({
|
|
|
360
360
|
type: Boolean,
|
|
361
361
|
default: true, // 默认不显示,保持向后兼容(isDownload 的默认值)
|
|
362
362
|
},
|
|
363
|
-
// 是否启用文本块的 hover 效果(高亮和显示批注按钮)
|
|
364
|
-
enableBlockHover: {
|
|
365
|
-
type: Boolean,
|
|
366
|
-
default: true,
|
|
367
|
-
},
|
|
368
363
|
});
|
|
369
364
|
|
|
370
365
|
const emit = defineEmits<{
|
|
@@ -381,6 +376,7 @@ const emit = defineEmits<{
|
|
|
381
376
|
"annotation-add": [annotation: AnnotationInfo]; // 添加批注事件
|
|
382
377
|
"annotation-update": [annotation: AnnotationInfo]; // 更新批注事件
|
|
383
378
|
"annotation-delete": [annotationId: string]; // 删除批注事件
|
|
379
|
+
"highlight-clear": []; // 高亮清除事件(用于清除连接线)
|
|
384
380
|
}>();
|
|
385
381
|
|
|
386
382
|
// 图片URL数组和当前页码
|
|
@@ -873,12 +869,18 @@ const switchToPage = (page: number) => {
|
|
|
873
869
|
showAnnotationPopup.value = false;
|
|
874
870
|
currentAnnotationBlock.value = null;
|
|
875
871
|
annotationInput.value = "";
|
|
872
|
+
const hadHighlight = isHighlighted.value && activeBlockDiv.value !== null;
|
|
876
873
|
activeBlockDiv.value = null;
|
|
877
874
|
isHighlighted.value = false;
|
|
878
875
|
|
|
879
876
|
// 更新页码
|
|
880
877
|
currentPage.value = page;
|
|
881
878
|
|
|
879
|
+
// 如果之前有高亮,触发高亮清除事件
|
|
880
|
+
if (hadHighlight) {
|
|
881
|
+
emit("highlight-clear");
|
|
882
|
+
}
|
|
883
|
+
|
|
882
884
|
// 触发页码变化事件
|
|
883
885
|
emit("page-change", page, totalPages.value);
|
|
884
886
|
|
|
@@ -922,9 +924,15 @@ const reset = () => {
|
|
|
922
924
|
showAnnotationPopup.value = false;
|
|
923
925
|
currentAnnotationBlock.value = null;
|
|
924
926
|
annotationInput.value = "";
|
|
927
|
+
const hadHighlight = isHighlighted.value && activeBlockDiv.value !== null;
|
|
925
928
|
activeBlockDiv.value = null;
|
|
926
929
|
isHighlighted.value = false;
|
|
927
930
|
|
|
931
|
+
// 如果之前有高亮,触发高亮清除事件
|
|
932
|
+
if (hadHighlight) {
|
|
933
|
+
emit("highlight-clear");
|
|
934
|
+
}
|
|
935
|
+
|
|
928
936
|
// 清除已渲染页面集合
|
|
929
937
|
renderedPages.value.clear();
|
|
930
938
|
};
|
|
@@ -1282,11 +1290,6 @@ const renderTextLayer = (pageNum?: number) => {
|
|
|
1282
1290
|
|
|
1283
1291
|
// Hover 和点击事件
|
|
1284
1292
|
blockDiv.addEventListener("mouseenter", (e) => {
|
|
1285
|
-
// 如果禁用了 hover 效果,不执行相关逻辑
|
|
1286
|
-
if (!props.enableBlockHover) {
|
|
1287
|
-
return;
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
1293
|
// 取消之前的隐藏定时器
|
|
1291
1294
|
if (hideTimer) {
|
|
1292
1295
|
clearTimeout(hideTimer);
|
|
@@ -1332,10 +1335,6 @@ const renderTextLayer = (pageNum?: number) => {
|
|
|
1332
1335
|
});
|
|
1333
1336
|
|
|
1334
1337
|
blockDiv.addEventListener("mouseleave", () => {
|
|
1335
|
-
// 如果禁用了 hover 效果,不执行隐藏逻辑
|
|
1336
|
-
if (!props.enableBlockHover) {
|
|
1337
|
-
return;
|
|
1338
|
-
}
|
|
1339
1338
|
// 延迟隐藏,给用户时间移动到批注按钮
|
|
1340
1339
|
hideAnnotationButton();
|
|
1341
1340
|
});
|
|
@@ -2158,6 +2157,7 @@ const highlightPosition = (
|
|
|
2158
2157
|
highlightStyle?: HighlightStyle
|
|
2159
2158
|
): boolean => {
|
|
2160
2159
|
// 清除之前的高亮
|
|
2160
|
+
const hadHighlight = activeBlockDiv.value !== null && isHighlighted.value;
|
|
2161
2161
|
if (activeBlockDiv.value) {
|
|
2162
2162
|
activeBlockDiv.value.style.backgroundColor = "transparent";
|
|
2163
2163
|
activeBlockDiv.value.style.boxShadow = "none";
|
|
@@ -2165,6 +2165,11 @@ const highlightPosition = (
|
|
|
2165
2165
|
activeBlockDiv.value = null;
|
|
2166
2166
|
}
|
|
2167
2167
|
isHighlighted.value = false;
|
|
2168
|
+
|
|
2169
|
+
// 如果之前有高亮,触发高亮清除事件
|
|
2170
|
+
if (hadHighlight) {
|
|
2171
|
+
emit("highlight-clear");
|
|
2172
|
+
}
|
|
2168
2173
|
|
|
2169
2174
|
// 如果页码不在有效范围内,返回 false
|
|
2170
2175
|
if (pageNum < 1 || pageNum > totalPages.value) {
|
|
@@ -2271,6 +2276,8 @@ const highlightPosition = (
|
|
|
2271
2276
|
elementRef.style.border = "none";
|
|
2272
2277
|
activeBlockDiv.value = null;
|
|
2273
2278
|
isHighlighted.value = false;
|
|
2279
|
+
// 触发高亮清除事件,用于清除连接线
|
|
2280
|
+
emit("highlight-clear");
|
|
2274
2281
|
}
|
|
2275
2282
|
}, 5000);
|
|
2276
2283
|
|
|
@@ -2585,6 +2592,34 @@ onBeforeUnmount(() => {
|
|
|
2585
2592
|
window.removeEventListener('resize', handleContainerResize);
|
|
2586
2593
|
});
|
|
2587
2594
|
|
|
2595
|
+
// 获取当前高亮位置信息(用于连接线功能)
|
|
2596
|
+
const getCurrentPosition = () => {
|
|
2597
|
+
if (!activeBlockDiv.value || !containerRef.value) {
|
|
2598
|
+
return null;
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
const bboxStr = activeBlockDiv.value.dataset.bbox;
|
|
2602
|
+
if (!bboxStr) {
|
|
2603
|
+
return null;
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
try {
|
|
2607
|
+
const bbox = JSON.parse(bboxStr) as [number, number, number, number];
|
|
2608
|
+
const pageStr = activeBlockDiv.value.dataset.page;
|
|
2609
|
+
const pageNum = pageStr ? parseInt(pageStr, 10) : currentPage.value;
|
|
2610
|
+
|
|
2611
|
+
return {
|
|
2612
|
+
pageNum,
|
|
2613
|
+
bbox,
|
|
2614
|
+
element: activeBlockDiv.value,
|
|
2615
|
+
container: containerRef.value,
|
|
2616
|
+
};
|
|
2617
|
+
} catch (error) {
|
|
2618
|
+
console.error("解析 bbox 失败:", error);
|
|
2619
|
+
return null;
|
|
2620
|
+
}
|
|
2621
|
+
};
|
|
2622
|
+
|
|
2588
2623
|
defineExpose({
|
|
2589
2624
|
reset,
|
|
2590
2625
|
jumpToPosition, // 暴露定位方法给父组件
|
|
@@ -2592,6 +2627,7 @@ defineExpose({
|
|
|
2592
2627
|
getCurrentPage: () => currentPage.value, // 获取当前页码
|
|
2593
2628
|
getTotalPages: () => totalPages.value, // 获取总页数
|
|
2594
2629
|
getContainer: () => containerRef.value, // 暴露容器引用,用于同步滚动
|
|
2630
|
+
getCurrentPosition, // 获取当前高亮位置信息(用于连接线功能)
|
|
2595
2631
|
});
|
|
2596
2632
|
</script>
|
|
2597
2633
|
|
package/preview/index.vue
CHANGED
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
@annotation-add="handleAnnotationAdd"
|
|
54
54
|
@annotation-update="handleAnnotationUpdate"
|
|
55
55
|
@annotation-delete="handleAnnotationDelete"
|
|
56
|
+
@highlight-clear="$emit('highlight-clear')"
|
|
56
57
|
>
|
|
57
58
|
<template #left-top>
|
|
58
59
|
<slot name="left-top"></slot>
|
|
@@ -141,7 +142,7 @@ import DocxPreview from './docxPreview.vue';
|
|
|
141
142
|
import XLSXPreview from './xlsxPreview.vue';
|
|
142
143
|
|
|
143
144
|
// 定义 emits
|
|
144
|
-
const emit = defineEmits(['load', 'annotation-add', 'annotation-update', 'annotation-delete']);
|
|
145
|
+
const emit = defineEmits(['load', 'annotation-add', 'annotation-update', 'annotation-delete', 'highlight-clear']);
|
|
145
146
|
|
|
146
147
|
// 定义 props
|
|
147
148
|
const props = defineProps({
|