Explorar el Código

fix: FreeText 修复跨页移动背景色bug

liutian hace 2 semanas
padre
commit
5b3859d5d2
Se han modificado 1 ficheros con 6 adiciones y 10 borrados
  1. 6 10
      packages/core/src/annotation/freetext.js

+ 6 - 10
packages/core/src/annotation/freetext.js

@@ -83,10 +83,6 @@ export default class Shape extends Base {
       annotation.color = '#000000'
     }
 
-    if (!annotation.bgColor) {
-      annotation.bgColor = 'transparent'
-    }
-
     if (!annotation.fontSize) {
       annotation.fontSize = 16
     }
@@ -119,7 +115,7 @@ export default class Shape extends Base {
       lineHeight: '1.2em',
       padding: '2px 4px',
       overflow: 'auto',
-      backgroundColor: annotation.bgColor,
+      backgroundColor: annotation.bgColor ? annotation.bgColor : 'transparent',
       '-webkit-user-select': 'text'
     })
 
@@ -137,7 +133,7 @@ export default class Shape extends Base {
       lineHeight: '1.2em',
       padding: '2px 4px',
       overflow: 'hidden',
-      backgroundColor: annotation.bgColor
+      backgroundColor: annotation.bgColor ? annotation.bgColor : 'transparent',
     })
     if (annotation.contents) {
       freetextElement.innerHTML = annotation.contents
@@ -788,10 +784,10 @@ export default class Shape extends Base {
             return
           }
           if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
-        left = pageX - (startState.clickX - leftTop.x)
-        top = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        right = pageX - (startState.clickX - rightBottom.x)
-        bottom = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+            left = pageX - (startState.clickX - leftTop.x)
+            top = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            right = pageX - (startState.clickX - rightBottom.x)
+            bottom = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
           } else if ((minPage + 1) === maxPage) {
             left = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
             top = pageY - (startState.clickY - leftTop.y)