@koi-br/ocr-web-sdk 1.0.63 → 1.0.65

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koi-br/ocr-web-sdk",
3
- "version": "1.0.63",
3
+ "version": "1.0.65",
4
4
  "description": "一个支持多种Office文件格式预览的Vue3组件SDK,包括PDF、Word、Excel、图片、OFD、TIF等格式",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -233,6 +233,7 @@
233
233
  </span>
234
234
  </slot>
235
235
  <Textarea
236
+ ref="annotationTextareaRef"
236
237
  v-model="annotationInput"
237
238
  :auto-size="{ minRows: 1, maxRows: 3}"
238
239
  placeholder="请输入批注内容..."
@@ -632,6 +633,7 @@ const currentAnnotationBlock = ref<{
632
633
  } | null>(null); // 当前正在添加批注的文本块
633
634
  const currentEditingAnnotation = ref<AnnotationInfo | null>(null); // 当前正在编辑的批注信息(如果有)
634
635
  const annotationPopupRef = ref<HTMLElement>(); // 批注弹窗引用
636
+ const annotationTextareaRef = ref<any>(); // 批注输入框引用
635
637
 
636
638
  // 文本选择相关状态(保留用于兼容)
637
639
  const activeBlockDiv = ref<HTMLElement | null>(null);
@@ -2125,6 +2127,26 @@ const openAnnotationInput = (e?: Event) => {
2125
2127
  // 重新计算弹窗位置(输入框更大)
2126
2128
  nextTick(() => {
2127
2129
  adjustAnnotationPopupPosition();
2130
+
2131
+ // 🔑 自动聚焦到输入框
2132
+ if (annotationTextareaRef.value) {
2133
+ // Arco Design 的 Textarea 组件,需要通过 $el 或 textarea 属性访问原生元素
2134
+ const textareaElement = annotationTextareaRef.value.$el?.querySelector('textarea') ||
2135
+ annotationTextareaRef.value.textarea ||
2136
+ annotationTextareaRef.value.$el;
2137
+
2138
+ if (textareaElement && typeof textareaElement.focus === 'function') {
2139
+ // 使用 setTimeout 确保 DOM 完全渲染后再聚焦
2140
+ setTimeout(() => {
2141
+ textareaElement.focus();
2142
+ }, 0);
2143
+ } else if (annotationTextareaRef.value.focus) {
2144
+ // 如果组件本身有 focus 方法
2145
+ setTimeout(() => {
2146
+ annotationTextareaRef.value.focus();
2147
+ }, 0);
2148
+ }
2149
+ }
2128
2150
  });
2129
2151
  };
2130
2152
 
@@ -2729,27 +2751,6 @@ const highlightPosition = (
2729
2751
  }
2730
2752
  }
2731
2753
 
2732
- // 5秒后自动取消高亮
2733
- // 清除之前的定时器(防止多个定时器同时存在)
2734
- if (highlightTimer) {
2735
- clearTimeout(highlightTimer);
2736
- }
2737
-
2738
- highlightTimer = setTimeout(() => {
2739
- if (activeBlockDiv.value === elementRef && isHighlighted.value) {
2740
- // 移除动画类
2741
- elementRef.classList.remove("highlight-animated");
2742
- elementRef.style.backgroundColor = "transparent";
2743
- elementRef.style.boxShadow = "none";
2744
- elementRef.style.border = "none";
2745
- activeBlockDiv.value = null;
2746
- isHighlighted.value = false;
2747
- // 触发高亮清除事件,用于清除连接线
2748
- emit("highlight-clear");
2749
- }
2750
- highlightTimer = null;
2751
- }, 5000);
2752
-
2753
2754
  return true;
2754
2755
  } finally {
2755
2756
  // 🔑 关键:无论成功还是失败,都要立即清除高亮标志