ソースを参照

fix: 一轮测试修复

wzl 1 ヶ月 前
コミット
903ffa4699

+ 1 - 1
packages/core/src/annotation/freetext.js

@@ -362,7 +362,7 @@ export default class Shape extends Base {
     this.firstSelect = true
     if (this.show) {
       this.firstSelect = false
-      this.handleElementSelect()
+      !this.layer.addMode && this.handleElementSelect()
     }
   }
 

+ 2 - 0
packages/core/src/annotation/paint/freetext.js

@@ -133,6 +133,7 @@ export default class Freetext {
         annotation
       })
     }
+    this.layer.addMode = false
     freetextElement.removeEventListener('blur', this.onBlur)
     freetextElement.removeEventListener('paste', this.onPaste)
     freetextElement.remove()
@@ -151,6 +152,7 @@ export default class Freetext {
     if (freetextElement && event.target === freetextElement) return
 
     if (!freetextElement && !this.layer.selectedElementName) {
+      this.layer.addMode = true
       this.renderFreetext(event)
     }
   }

+ 1 - 2
packages/core/src/form/add_check_box.js

@@ -173,9 +173,8 @@ export default class AddCheckBox {
         const shapeEle = createElement('div', {
           'backgroundColor': '#DDE9FF',
           'borderColor': '#43474D',
-          'borderWidth': '3',
+          'borderWidth': '1px',
           'borderStyle': 'solid',
-
           'position': "absolute"
         })
         this.shapeEle = shapeEle

+ 1 - 1
packages/core/src/form/add_radio_button.js

@@ -173,7 +173,7 @@ export default class AddRadioButton {
         const shapeEle = createElement('div', {
           'backgroundColor': '#DDE9FF',
           'borderColor': '#43474D',
-          'borderWidth': '3',
+          'borderWidth': '1px',
           'borderStyle': 'solid',
           'borderRadius': '100%',
           'position': "absolute"

+ 2 - 2
packages/core/src/form/check_box.js

@@ -1001,8 +1001,8 @@ export default class CheckBox extends Base {
   async getImage(update) {
     const rect = this.initRect
     const imgRect = {
-      width: parseInt(rect.width * this.layer.ratio + 1),
-      height: parseInt(rect.height * this.layer.ratio + 1)
+      width: parseInt(rect.width * this.layer.ratio),
+      height: parseInt(rect.height * this.layer.ratio)
     }
 
     const imageArray = await this.messageHandler.sendWithPromise('GetRenderAnnot', {

+ 2 - 2
packages/core/src/form/text_field.js

@@ -1114,8 +1114,8 @@ export default class TextField extends Base {
   async getImage(update) {
     const rect = this.initRect
     const imgRect = {
-      width: parseInt(rect.width * this.layer.ratio + 1),
-      height: parseInt(rect.height * this.layer.ratio + 1)
+      width: parseInt(rect.width * this.layer.ratio),
+      height: parseInt(rect.height * this.layer.ratio)
     }
 
     const imageArray = await this.messageHandler.sendWithPromise('GetRenderAnnot', {

+ 76 - 54
packages/core/src/markup/text_annotation.js

@@ -33,11 +33,13 @@ class TextAnnotation extends BaseAnnotation {
     this.outerLineContainer = null
     this.ratio = window.devicePixelRatio || 1
     this.ctx = this.pageViewer.canvas.getContext('2d', { willReadFrequently: true })
+    this.baseImageData = this.pageViewer.baseImageData
     this.lineWidth = 2 * this.scale * this.ratio
 
     this.onHandleClick = this.handleClick.bind(this)
     this.onDelete = this.handleDelete.bind(this)
     this.onOpenReply = this.openReply.bind(this)
+    this.onUpdateMarkup = this.updateMarkup.bind(this)
 
     this.render()
   }
@@ -53,11 +55,12 @@ class TextAnnotation extends BaseAnnotation {
 
     const rect = this.calculate(start, end)
     this.rect = rect
-    this.baseImageData = this.ctx.getImageData(rect.left * this.ratio, rect.top * this.ratio, Math.round(rect.width * this.ratio), Math.round(rect.height * this.ratio + this.lineWidth + 2))
 
     const quadPoints = annotation.quadPoints
     if (!quadPoints) return
 
+    this.eventBus._on('markupUpdate', this.onUpdateMarkup)
+
     let positionArray = []
     for (let i = 0; (i + 3) < quadPoints.length; i+=4) {
       const x1 = parseInt(quadPoints[i].PointX * scale, 10),
@@ -77,13 +80,10 @@ class TextAnnotation extends BaseAnnotation {
         height
       })
     }
+    this.positionArray = positionArray
 
     this.ctx.globalCompositeOperation = 'multiply'
-    if (['highlight', 'underline', 'strikeout'].includes(annotation.type)) {
-      this.renderCanvansRect(positionArray)
-    } else if (annotation.type === 'squiggly') {
-      this.renderSquiggly(positionArray)
-    }
+    this.renderCanvansRect(positionArray)
     this.markupContainer.addEventListener('click', this.onHandleClick)
     
     this.outerLineContainer = document.createElement('div')
@@ -258,9 +258,14 @@ class TextAnnotation extends BaseAnnotation {
     this.handleOutside()
     this.markupContainer.remove()
 
+    this.eventBus._off('markupUpdate', this.onUpdateMarkup)
     this.ctx.clearRect(this.rect.left * this.ratio, this.rect.top * this.ratio, this.rect.width * this.ratio, this.rect.height * this.ratio)
-    this.ctx.putImageData(this.baseImageData, this.rect.left * this.ratio, this.rect.top * this.ratio)
-    this.baseImageData = null
+    this.ctx.putImageData(this.baseImageData, 0, 0, this.rect.left * this.ratio, this.rect.top * this.ratio, Math.round(this.rect.width * this.ratio + this.lineWidth + 2), Math.round(this.rect.height * this.ratio + this.lineWidth + 2))
+    this.eventBus.dispatch('markupUpdate', {
+      name: this.annotation.name,
+      pageIndex: this.page,
+      rect: this.rect
+    })
 
     this.annotation.isDelete = true
     const annotationData = {
@@ -288,10 +293,6 @@ class TextAnnotation extends BaseAnnotation {
   }
 
   renderCanvansRect (positionArray) {
-    const annotation = this.annotation
-    const { R, G, B } = convertColorToRGB(annotation.color)
-    this.ctx.fillStyle = `rgba(${R}, ${G}, ${B}, ${annotation.opacity || 1})`
-
     const markupContainer = document.createElement('div')
     markupContainer.className = 'markup'
 
@@ -306,58 +307,79 @@ class TextAnnotation extends BaseAnnotation {
         height: position.height + 'px'
       })
       markupContainer.append(container)
-
-      if (annotation.type === 'highlight') {
-        this.ctx.fillRect(position.left * this.ratio, position.top * this.ratio, position.width * this.ratio, position.height * this.ratio)
-      } else if (annotation.type === 'underline') {
-        this.ctx.fillRect(position.left * this.ratio, (position.top + position.height) * this.ratio, position.width * this.ratio, this.lineWidth)
-      } else if (annotation.type === 'strikeout') {
-        this.ctx.fillRect(position.left * this.ratio, (position.top + (position.height / 2)) * this.ratio, position.width * this.ratio, this.lineWidth)
-      }
     }
-    
+    this.drawCanvas(positionArray)
     this.container.append(markupContainer)
     this.markupContainer = markupContainer
   }
+  
+  openReply () {
+    this.eventBus.dispatch('openAnnotationReply', this.annotation)
+  }
 
-  renderSquiggly (positionArray) {
-    const annotation = this.annotation
-    const markupContainer = document.createElement('div')
-    markupContainer.className = 'markup'
+  updateMarkup (data) {
+    if (data.pageIndex !== this.page || data.name === this.annotation.name) return
 
-    const amplitude = 4 * this.scale  // 波动幅度
-    const wavelength = 42 * this.scale // 波长
-    const { R, G, B } = convertColorToRGB(annotation.color)
-    this.ctx.strokeStyle = `rgba(${R}, ${G}, ${B}, ${annotation.opacity || 1})`
-    this.ctx.lineWidth = this.lineWidth
+    const rect1 = this.rect
+    const rect2 = data.rect
 
-    for (let i = 0; i < positionArray.length; i++) {
-      const position = positionArray[i]
-      const container = document.createElement('div')
-      this.setCss(container, {
-        position: 'absolute',
-        overflow: 'hidden',
-        opacity: annotation.opacity || 1,
-        top: position.top + 'px',
-        left: position.left + 'px',
-        width: position.width + 'px',
-        height: position.height + 'px',
-      })
-      markupContainer.append(container)
+    if (rect1.left > rect2.left + rect2.width ||
+        rect1.left + rect1.width < rect2.left ||
+        rect1.top > rect2.top + rect2.height ||
+        rect1.top + rect1.height < rect2.top
+    ) return
 
-      this.ctx.beginPath()
-      for (let x = position.left * this.ratio; x <= (position.left + position.width) * this.ratio; x++) {
-        const y = (position.top + position.height) * this.ratio + amplitude * Math.sin((x / wavelength) * 2 * Math.PI)
-        this.ctx.lineTo(x, y)
+    this.ctx.clearRect(this.rect.left * this.ratio, this.rect.top * this.ratio, this.rect.width * this.ratio, this.rect.height * this.ratio)
+    this.ctx.putImageData(this.baseImageData, 0, 0, this.rect.left * this.ratio, this.rect.top * this.ratio, Math.round(this.rect.width * this.ratio + this.lineWidth + 2), Math.round(this.rect.height * this.ratio + this.lineWidth + 2))
+    this.drawCanvas(this.positionArray)
+  }
+
+  drawCanvas(positionArray) {
+    const annotation = this.annotation
+    if (['highlight', 'underline', 'strikeout'].includes(annotation.type)) {
+      const { R, G, B } = convertColorToRGB(annotation.color)
+      this.ctx.fillStyle = `rgba(${R}, ${G}, ${B}, ${annotation.opacity || 1})`
+
+      const markupContainer = document.createElement('div')
+      markupContainer.className = 'markup'
+
+      for (let i = 0; i < positionArray.length; i++) {
+        const position = positionArray[i]
+        const container = document.createElement('div')
+        this.setCss(container, {
+          position: 'absolute',
+          top: position.top + 'px',
+          left: position.left + 'px',
+          width: position.width + 'px',
+          height: position.height + 'px'
+        })
+        markupContainer.append(container)
+
+        if (annotation.type === 'highlight') {
+          this.ctx.fillRect(position.left * this.ratio, position.top * this.ratio, position.width * this.ratio, position.height * this.ratio)
+        } else if (annotation.type === 'underline') {
+          this.ctx.fillRect(position.left * this.ratio, (position.top + position.height) * this.ratio, position.width * this.ratio, this.lineWidth)
+        } else if (annotation.type === 'strikeout') {
+          this.ctx.fillRect(position.left * this.ratio, (position.top + (position.height / 2)) * this.ratio, position.width * this.ratio, this.lineWidth)
+        }
+      }
+    } else if (annotation.type === 'squiggly') {
+      const amplitude = 3 * this.scale  // 波动幅度
+      const wavelength = 20 * this.scale // 波长
+      const { R, G, B } = convertColorToRGB(annotation.color)
+      this.ctx.strokeStyle = `rgba(${R}, ${G}, ${B}, ${annotation.opacity || 1})`
+      this.ctx.lineWidth = this.lineWidth
+
+      for (let i = 0; i < positionArray.length; i++) {
+        const position = positionArray[i]
+        this.ctx.beginPath()
+        for (let x = position.left * this.ratio; x <= (position.left + position.width) * this.ratio; x++) {
+          const y = (position.top + position.height) * this.ratio + amplitude * Math.sin((x / wavelength) * 2 * Math.PI)
+          this.ctx.lineTo(x, y)
+        }
+        this.ctx.stroke()
       }
-      this.ctx.stroke()
     }
-    this.container.append(markupContainer)
-    this.markupContainer = markupContainer
-  }
-  
-  openReply () {
-    this.eventBus.dispatch('openAnnotationReply', this.annotation)
   }
 }
 

+ 2 - 0
packages/core/src/pdf_page_view.js

@@ -720,6 +720,7 @@ class PDFPageView {
         let imageData = ctx.createImageData(width, height);
         imageData.data.set(imageArray)
         ctx.putImageData(imageData, 0, 0)
+        this.baseImageData = imageData
 
         renderCapability.resolve()
       })
@@ -1429,6 +1430,7 @@ class PDFPageView {
         let imageData = ctx.createImageData(canvasWidth, canvasHeight);
         imageData.data.set(imageArray)
         ctx.putImageData(imageData, 0, 0)
+        this.baseImageData = imageData
 
         showCanvas();
         renderCapability.resolve();

+ 1 - 1
packages/webview/src/components/App/index.vue

@@ -246,7 +246,7 @@ const calculateDistance = (touches) => {
       color: #232A40;
       padding: 16px 16px 40px;
       background: #FFFFFF;
-      box-shadow: 0px 4px 32px rgba(129, 149, 200, 0.32);
+      box-shadow: 0px 4px 32px var(--c-doc-editor-popup-shadow);
       border-radius: 4px;
       .fail-logo svg {
         width: 60px;

+ 2 - 2
packages/webview/src/components/CompareDocumentContainer/CompareDocumentContainer.vue

@@ -145,7 +145,7 @@ const uploadFile = async (e, flag) => {
   if (!e.target.files[0]) return
 
   let url = URL.createObjectURL(e.target.files[0])
-  const pass = await core.checkPassword(url)
+  const pass = await core.checkPassword(url, true)
   if (pass === false) {
     e.target.value = ''
     return
@@ -188,7 +188,7 @@ const handleDrop = async (e, flag) => {
   if (files[0].type !== 'application/pdf') return
 
   let url = URL.createObjectURL(files[0])
-  const pass = await core.checkPassword(url)
+  const pass = await core.checkPassword(url, true)
   if (pass === false) {
     e.target.value = ''
     return

+ 1 - 1
packages/webview/src/components/Dialogs/LanguageDialog.vue

@@ -82,7 +82,7 @@
       max-width: 252px;
       padding: 20px 16px;
       background-color: var(--c-header-bg);
-      box-shadow: 0px 4px 32px 0px rgba(129, 149, 200, 0.32);
+      box-shadow: 0px 4px 32px 0px var(--c-doc-editor-popup-shadow);
       border-radius: 4px;
     }
     .header-container {

+ 1 - 1
packages/webview/src/components/Dialogs/SettingsDialog.vue

@@ -36,7 +36,7 @@
       <p class="title">{{ $t('header.settings.creationInfo') }}</p>
       <div class="version row">
         <span>{{ $t('header.settings.version') }}</span>
-        <span>2.5.0</span>
+        <span>2.5.1</span>
       </div>
 
       <template #footer>

+ 1 - 1
packages/webview/src/components/Dialogs/SignatureAppearanceDialog.vue

@@ -226,7 +226,7 @@ const getValue = (key) => {
       break
     case 'version':
       text.title = $t('signatures.appearanceDialog.ComPDFKitVersion')
-      text.value = '2.5.0'
+      text.value = '2.5.1'
       break
     case 'location':
       text.title = $t('signatures.appearanceDialog.location')

+ 1 - 1
packages/webview/src/components/ModalContainer/ModalContainer.vue

@@ -17,7 +17,7 @@
 <style lang="scss">
 .modal-container {
   background-color: var(--c-header-bg);
-  box-shadow: 0px 4px 32px 0px rgba(129, 149, 200, 0.32);
+  box-shadow: 0px 4px 32px 0px var(--c-doc-editor-popup-shadow);
   border-radius: 4px;
   .wrapper {
     position: relative;

+ 2 - 2
packages/webview/src/components/Signatures/DigitalSignCreatePanel.vue

@@ -58,8 +58,8 @@ const clear = () => {
   })
 }
 
-const save = () => {
-  const imageBase64 = core.handleSign({
+const save = async () => {
+  const imageBase64 = await core.handleSign({
     type: 1,
     flag: 'image',
   })