Pārlūkot izejas kodu

fix: 应用密文后刷新注释

wzl 1 mēnesi atpakaļ
vecāks
revīzija
3b1b0ab096

+ 4 - 4
packages/core/src/annotation/stamp.js

@@ -399,9 +399,9 @@ export default class Stamp extends Base {
       this.layer.selectedElementName = null
     }
 
-    this.outerLine.removeEventListener('mousedown', this.onMousedown)
-    this.outerLine.removeEventListener('touchstart', this.onMousedown)
-    this.outerLineContainer.remove()
+    this.outerLine?.removeEventListener('mousedown', this.onMousedown)
+    this.outerLine?.removeEventListener('touchstart', this.onMousedown)
+    this.outerLineContainer?.remove()
   }
 
   handleMouseDown (event) {
@@ -568,7 +568,7 @@ export default class Stamp extends Base {
       event.stopPropagation()
     }
     this.handleOutside()
-    this.annotationContainer.remove()
+    this.annotationContainer?.remove()
 
     this.annotation.isDelete = true
     const annotationData = {

+ 28 - 8
packages/core/src/index.js

@@ -2925,6 +2925,14 @@ class ComPDFKitViewer {
     });
 
     this.pdfViewer.refresh()
+
+    return new Promise((resolve) => {
+      const eventHandler = () => {
+        this.eventBus._off('pagerendered', eventHandler)
+        resolve()
+      }
+      this.eventBus._on('pagerendered', eventHandler)
+    })
   }
 
   setPropertyPanel(props) {
@@ -4306,25 +4314,37 @@ class ComPDFKitViewer {
         const redactions = Array.isArray(redaction) ? redaction : [redaction]
         redactionList = redactions
       }
-      redactionList.forEach(async item => {
+      for (const item of redactionList) {
         if (item.erasure) {
           if (item.rects && item.rects.length) {
-            item.rects.forEach(async rect => {
+            for (const rect of item.rects) {
               await this.messageHandler.sendWithPromise('ErasureRedactionFromRect', { pagePtr: item.pagePtr, rect })
-            })
+            }
           } else {
             await this.messageHandler.sendWithPromise('ErasureRedactionFromRect', { pagePtr: item.pagePtr, rect: item.rect })
           }
         } else {
           await this.messageHandler.sendWithPromise('ApplyRedaction', { annotPtr: item.annotPtr })
         }
+      }
+      
+      await this.updateTextPtr()
+      this.emptyAnnotations()
+      this.pdfViewer.refresh()
+      this.reRenderAnnotations()
+
+      return new Promise((resolve) => {
+        const eventHandler = () => {
+          this.eventBus._off('annotationChanged', eventHandler)
+          resolve()
+        }
+        this.eventBus._on('annotationChanged', eventHandler)
       })
-      await this.delAnnotations(redactionList)
-    } else {
-      await this.delAnnotations(this.redactionList)
-      this.redactionList.length = 0
     }
-    await this.updateTextPtr()
+
+    await this.delAnnotations(this.redactionList)
+    this.redactionList.length = 0
+    this.pdfViewer.refresh()
   }
 }
 

+ 0 - 1
packages/core/src/worker/compdfkit_worker.js

@@ -3265,7 +3265,6 @@ function setAnnotRGBColor(data) {
   const color = convertColorToCppFormat(rawColor)
 
   const isSetColorSuccess = Module._SetAnnotRGBColor(annotPtr, color.R, color.G, color.B)
-  Module._SetAnnotFilledRGBColor(annotPtr, color.R, color.G, color.B)
   return !!isSetColorSuccess
 }
 

+ 2 - 1
packages/webview/src/components/DocumentContainer/DocumentContainer.vue

@@ -866,7 +866,8 @@ window.instances.UI.loadDocument = async (file, {
 }
 
 .redact .annotationContainer > div:not(.redact),
-.redact .annotationContainer > div:not(.redact).annotation > div {
+.redact .annotationContainer > div:not(.redact).annotation > div,
+.redact .annotationContainer > div:not(.redact).annotation > img {
   cursor: inherit;
   pointer-events: none;
 }

+ 11 - 3
packages/webview/src/components/SecurityToolbar/RedactionConfirmDialog.vue

@@ -17,6 +17,9 @@
       </template>
     </Dialog>
   </div>
+  <div class="mask" :class="{ active: loading }">
+    <div v-show="loading" class="loading"><Loading /></div>
+  </div>
 </template>
 
 <script setup>
@@ -31,16 +34,21 @@ const useDocument = useDocumentStore()
 const dialogType = computed(() => useViewer.getRedactionConfirmDialog)
 const show = computed(() => dialogType.value >= 0)
 
+const loading = ref(false)
+
 const closeDialog = () => {
   useViewer.setRedactionConfirmDialog(-1)
 }
 
-const confirm = () => {
-  core.applyRedactions(dialogType.value === 1 ? 'all' : null)
+const confirm = async () => {
+  const flag = dialogType.value === 1 ? 'all' : null
+  loading.value = true
+  closeDialog()
+  await core.applyRedactions(flag)
   useDocument.setToolState('')
   useViewer.setActiveToolMode('view')
-  closeDialog()
   useViewer.closeElement('leftPanel')
+  loading.value = false
 }
 </script>