@koi-br/ocr-web-sdk 1.0.53 → 1.0.55
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-BniO2aM1.mjs → index-7NzuKZi7.mjs} +6645 -6639
- package/dist/{index-CAoaF0us.js → index-DzCRrBSn.js} +78 -78
- package/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +2 -2
- package/dist/style.css +1 -1
- package/dist/{tiff.min-Djly3w3y.js → tiff.min-BMh2flpF.js} +1 -1
- package/dist/{tiff.min-DqwrYsQT.mjs → tiff.min-CpubOvNg.mjs} +1 -1
- package/package.json +1 -1
- package/preview/ImagePreview.vue +45 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getAugmentedNamespace, a as getDefaultExportFromCjs } from "./index-
|
|
1
|
+
import { g as getAugmentedNamespace, a as getDefaultExportFromCjs } from "./index-7NzuKZi7.mjs";
|
|
2
2
|
function _mergeNamespaces(U, W) {
|
|
3
3
|
for (var Z = 0; Z < W.length; Z++) {
|
|
4
4
|
const s0 = W[Z];
|
package/package.json
CHANGED
package/preview/ImagePreview.vue
CHANGED
|
@@ -236,8 +236,7 @@
|
|
|
236
236
|
:auto-size="{ minRows: 1, maxRows: 3}"
|
|
237
237
|
placeholder="请输入批注内容..."
|
|
238
238
|
class="annotation-textarea"
|
|
239
|
-
@keydown.
|
|
240
|
-
@keydown.meta.enter="saveAnnotation"
|
|
239
|
+
@keydown.enter="handleAnnotationKeydown"
|
|
241
240
|
@focus="cancelHideAnnotationButton"
|
|
242
241
|
@blur="cancelHideAnnotationButton"
|
|
243
242
|
@click.stop
|
|
@@ -2125,6 +2124,21 @@ const handleAnnotationPopupLeave = (e: MouseEvent) => {
|
|
|
2125
2124
|
}, 200);
|
|
2126
2125
|
};
|
|
2127
2126
|
|
|
2127
|
+
/**
|
|
2128
|
+
* 处理批注输入框的键盘事件
|
|
2129
|
+
* 回车键提交,Shift+回车键换行
|
|
2130
|
+
*/
|
|
2131
|
+
const handleAnnotationKeydown = (e: KeyboardEvent) => {
|
|
2132
|
+
// 如果按下了 Shift 键,允许默认行为(换行)
|
|
2133
|
+
if (e.shiftKey) {
|
|
2134
|
+
return; // 允许默认行为,即换行
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
// 如果没有按下 Shift 键,阻止默认行为并提交
|
|
2138
|
+
e.preventDefault();
|
|
2139
|
+
saveAnnotation();
|
|
2140
|
+
};
|
|
2141
|
+
|
|
2128
2142
|
/**
|
|
2129
2143
|
* 保存批注
|
|
2130
2144
|
*/
|
|
@@ -2335,6 +2349,29 @@ const isElementVisible = (
|
|
|
2335
2349
|
);
|
|
2336
2350
|
};
|
|
2337
2351
|
|
|
2352
|
+
/**
|
|
2353
|
+
* 检查元素是否在视口的中间区域(中间60%的区域)
|
|
2354
|
+
* 如果元素在底部或顶部边缘,返回 false,需要滚动到中间
|
|
2355
|
+
*/
|
|
2356
|
+
const isElementInCenterArea = (
|
|
2357
|
+
element: HTMLElement,
|
|
2358
|
+
container: HTMLElement
|
|
2359
|
+
): boolean => {
|
|
2360
|
+
const elementRect = element.getBoundingClientRect();
|
|
2361
|
+
const containerRect = container.getBoundingClientRect();
|
|
2362
|
+
|
|
2363
|
+
// 计算容器的中间区域(上下各留20%的边距)
|
|
2364
|
+
const containerHeight = containerRect.height;
|
|
2365
|
+
const centerAreaTop = containerRect.top + containerHeight * 0.2;
|
|
2366
|
+
const centerAreaBottom = containerRect.bottom - containerHeight * 0.2;
|
|
2367
|
+
|
|
2368
|
+
// 计算元素的中心点
|
|
2369
|
+
const elementCenterY = (elementRect.top + elementRect.bottom) / 2;
|
|
2370
|
+
|
|
2371
|
+
// 检查元素的中心点是否在中间区域内
|
|
2372
|
+
return elementCenterY >= centerAreaTop && elementCenterY <= centerAreaBottom;
|
|
2373
|
+
};
|
|
2374
|
+
|
|
2338
2375
|
/**
|
|
2339
2376
|
* 高亮指定位置
|
|
2340
2377
|
* @param pageNum 页码
|
|
@@ -2506,10 +2543,14 @@ const highlightPosition = (
|
|
|
2506
2543
|
elementRef.addEventListener("animationend", handleAnimationEnd);
|
|
2507
2544
|
});
|
|
2508
2545
|
|
|
2509
|
-
//
|
|
2546
|
+
// 只有在需要滚动时才滚动
|
|
2547
|
+
// 如果元素不在视口内,或者不在中间区域(比如在底部),都需要滚动到中间
|
|
2510
2548
|
if (shouldScroll && containerRef.value) {
|
|
2511
2549
|
const isVisible = isElementVisible(elementRef, containerRef.value);
|
|
2512
|
-
|
|
2550
|
+
const isInCenter = isElementInCenterArea(elementRef, containerRef.value);
|
|
2551
|
+
|
|
2552
|
+
// 如果元素不可见,或者不在中间区域,都需要滚动到中间
|
|
2553
|
+
if (!isVisible || !isInCenter) {
|
|
2513
2554
|
// 标记这是定位滚动,不应该被同步滚动干扰
|
|
2514
2555
|
containerRef.value.dataset.pageScrolling = "true";
|
|
2515
2556
|
elementRef.scrollIntoView({ behavior: "smooth", block: "center" });
|