@koi-br/ocr-web-sdk 1.0.30 → 1.0.31

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.
@@ -1,4 +1,4 @@
1
- import { g as getAugmentedNamespace, a as getDefaultExportFromCjs } from "./index-CPXnfqe3.mjs";
1
+ import { g as getAugmentedNamespace, a as getDefaultExportFromCjs } from "./index-IRUtAb6l.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koi-br/ocr-web-sdk",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "一个支持多种Office文件格式预览的Vue3组件SDK,包括PDF、Word、Excel、图片、OFD、TIF等格式",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -272,6 +272,15 @@ interface AnnotationInfo {
272
272
  createTime: number; // 创建时间戳
273
273
  }
274
274
 
275
+ /**
276
+ * 高亮样式配置
277
+ */
278
+ interface HighlightStyle {
279
+ backgroundColor?: string; // 背景色
280
+ border?: string; // 边框样式(如 "2px solid rgba(30, 144, 255, 0.8)")
281
+ boxShadow?: string; // 阴影样式
282
+ }
283
+
275
284
  const props = defineProps({
276
285
  // 支持单个URL(向后兼容)或URL数组
277
286
  url: {
@@ -1856,12 +1865,14 @@ const isElementVisible = (
1856
1865
  const highlightPosition = (
1857
1866
  pageNum: number,
1858
1867
  bbox: [number, number, number, number],
1859
- shouldScroll: boolean = true
1868
+ shouldScroll: boolean = true,
1869
+ highlightStyle?: HighlightStyle
1860
1870
  ): boolean => {
1861
1871
  // 清除之前的高亮
1862
1872
  if (activeBlockDiv.value) {
1863
1873
  activeBlockDiv.value.style.backgroundColor = "transparent";
1864
1874
  activeBlockDiv.value.style.boxShadow = "none";
1875
+ activeBlockDiv.value.style.border = "none";
1865
1876
  activeBlockDiv.value = null;
1866
1877
  }
1867
1878
  isHighlighted.value = false;
@@ -1916,7 +1927,7 @@ const highlightPosition = (
1916
1927
  // 等待页面切换完成后再高亮
1917
1928
  nextTick(() => {
1918
1929
  setTimeout(() => {
1919
- highlightPosition(pageNum, bbox, shouldScroll);
1930
+ highlightPosition(pageNum, bbox, shouldScroll, highlightStyle);
1920
1931
  }, 300);
1921
1932
  });
1922
1933
  return true;
@@ -1928,10 +1939,24 @@ const highlightPosition = (
1928
1939
  activeBlockDiv.value = elementRef;
1929
1940
  isHighlighted.value = true;
1930
1941
 
1931
- // 使用一致的高亮样式
1932
- elementRef.style.backgroundColor =
1933
- "var(--s-color-brand-primary-transparent-3, rgba(0, 102, 255, .15))";
1934
- elementRef.style.boxShadow = "0 0 0 2px rgba(30, 144, 255, 0.6)";
1942
+ // 使用传入的高亮样式,如果没有传入则使用默认样式
1943
+ if (highlightStyle) {
1944
+ if (highlightStyle.backgroundColor) {
1945
+ elementRef.style.backgroundColor = highlightStyle.backgroundColor;
1946
+ }
1947
+ if (highlightStyle.border) {
1948
+ elementRef.style.border = highlightStyle.border;
1949
+ }
1950
+ if (highlightStyle.boxShadow) {
1951
+ elementRef.style.boxShadow = highlightStyle.boxShadow;
1952
+ }
1953
+ } else {
1954
+ // 默认高亮样式
1955
+ elementRef.style.backgroundColor =
1956
+ "var(--s-color-brand-primary-transparent-3, rgba(0, 102, 255, .15))";
1957
+ elementRef.style.boxShadow = "0 0 0 2px rgba(30, 144, 255, 0.6)";
1958
+ elementRef.style.border = "none";
1959
+ }
1935
1960
 
1936
1961
  // 只有在需要滚动且元素不在视口内时才滚动
1937
1962
  if (shouldScroll && containerRef.value) {
@@ -1946,6 +1971,7 @@ const highlightPosition = (
1946
1971
  if (activeBlockDiv.value === elementRef && isHighlighted.value) {
1947
1972
  elementRef.style.backgroundColor = "transparent";
1948
1973
  elementRef.style.boxShadow = "none";
1974
+ elementRef.style.border = "none";
1949
1975
  activeBlockDiv.value = null;
1950
1976
  isHighlighted.value = false;
1951
1977
  }
@@ -1963,7 +1989,8 @@ const highlightPosition = (
1963
1989
  const jumpToPosition = (
1964
1990
  pageNum: number,
1965
1991
  bbox: [number, number, number, number],
1966
- emitEvent: boolean = true
1992
+ emitEvent: boolean = true,
1993
+ highlightStyle?: HighlightStyle
1967
1994
  ) => {
1968
1995
  // 如果页码不在有效范围内,直接返回
1969
1996
  if (pageNum < 1 || pageNum > totalPages.value) {
@@ -1978,7 +2005,7 @@ const jumpToPosition = (
1978
2005
  const retryDelay = 200;
1979
2006
 
1980
2007
  const tryHighlight = () => {
1981
- const success = highlightPosition(pageNum, bbox, true);
2008
+ const success = highlightPosition(pageNum, bbox, true, highlightStyle);
1982
2009
  if (success) {
1983
2010
  // 高亮成功,触发事件
1984
2011
  if (emitEvent) {
package/preview/index.vue CHANGED
@@ -483,14 +483,14 @@ defineExpose({
483
483
  getCurrentPreview: getCurrentPreviewRef,
484
484
  // PDF 预览的代理方法(方便使用)
485
485
  goToPage: (pageNum) => pdfPreviewRef.value?.goToPage(pageNum),
486
- jumpToPosition: (pageNum, bbox, emitEvent) => {
486
+ jumpToPosition: (pageNum, bbox, emitEvent, highlightStyle) => {
487
487
  // PDF 预览的定位方法
488
488
  if (fileType.value === 'pdf' && pdfPreviewRef.value) {
489
- return pdfPreviewRef.value.jumpToPosition(pageNum, bbox, emitEvent);
489
+ return pdfPreviewRef.value.jumpToPosition(pageNum, bbox, emitEvent, highlightStyle);
490
490
  }
491
- // 图片预览的定位方法(现在也支持 pageNum)
491
+ // 图片预览的定位方法(现在也支持 pageNum 和 highlightStyle
492
492
  if (fileType.value === 'image' && imagePreviewRef.value) {
493
- return imagePreviewRef.value.jumpToPosition(pageNum, bbox, emitEvent);
493
+ return imagePreviewRef.value.jumpToPosition(pageNum, bbox, emitEvent, highlightStyle);
494
494
  }
495
495
  },
496
496
  getCurrentPage: () => pdfPreviewRef.value?.getCurrentPage(),