wzl 11 mesiacov pred
rodič
commit
dbd90215d3

+ 1 - 3
packages/core/src/form/signature_fields.js

@@ -50,8 +50,6 @@ export default class SignatureFields extends Base {
     this.eventBus._on('setProperty', this.setProperty.bind(this))
     this.eventBus._on('deleteSignature', this.onDelete)
 
-    // console.log(this.layer.annotationStore.signatures)
-
     for (let key in this.annotation) {
       if (key === 'background-color') {
         let newName = 'backgroundColor'
@@ -587,7 +585,7 @@ export default class SignatureFields extends Base {
   handleDelete (data) {
     const event = data instanceof Event ? data : null
     if (!this.annotationContainer) return
-    if (!event && data.name !== this.annotation.name) return
+    if (event || (!event && data.signaturePtr !== this.annotation.digitalSignaturePtr)) return
     if (this.layer.tool && event) {
       event.stopPropagation()
     }

+ 9 - 2
packages/core/src/index.js

@@ -1624,7 +1624,7 @@ class ComPDFKitViewer {
           annotateHandles
         }),
       }
-       return await fetch(this.optionUrl.webviewBaseUrl + this.optionUrl.editUrl, options)
+      return await fetch(this.optionUrl.webviewBaseUrl + this.optionUrl.editUrl, options)
         .then((res) => {
           return res.json()
         })
@@ -3592,15 +3592,22 @@ class ComPDFKitViewer {
   }
 
   deleteSignature(signature) {
+    this.messageHandler.sendWithPromise('RemoveSignature', {
+      doc: this.doc,
+      signaturePtr: signature.signaturePtr
+    })
+
     this.eventBus.dispatch('deleteSignature', signature)
+
+    annotationStore.signatures.splice(signature.index, 1)
   }
 
   async getSignatures() {
     const { signatures, signaturePtrList } = await this.messageHandler.sendWithPromise('GetSignatures', {
       doc: this.doc
     })
-    this.eventBus.dispatch('getSignatures', signatures)
     annotationStore.signatures = signatures
+    this.eventBus.dispatch('getSignatures', annotationStore.signatures)
     return signaturePtrList
   }
 }

+ 2 - 2
packages/core/src/worker/compdfkit_worker.js

@@ -1465,9 +1465,9 @@ class CPDFWorker {
     })
 
     messageHandler.on('RemoveSignature', (data) => {
-      const { doc, signPrt } = data
+      const { doc, signaturePtr } = data
 
-      return Module._RemoveSignature(doc, signPrt)
+     return Module._RemoveSignature(doc, signaturePtr, true)
     })
   }
 }

+ 0 - 1
packages/webview/src/components/AnnotationContainer/AnnotationContent.vue

@@ -47,7 +47,6 @@
   const markup = ['highlight', 'underline', 'squiggly', 'strikeout']
 
   const setAnnotationList = ({ annotations }) => {
-    console.log(annotations)
     useDocument.initAnnotations(annotations)
     const instance = getCurrentInstance();
     instance?.proxy?.$forceUpdate();

+ 5 - 5
packages/webview/src/components/SignatureContainer/SignatureContainer.vue

@@ -2,7 +2,7 @@
   <div class="signature-container">
     <div class="signature-title">{{ $t('leftPanel.signatureList') }}</div>
     <div v-if="signatures.length" class="signatures">
-      <template v-for="signature in signatures">
+      <template v-for="(signature, index) in signatures" :key="index">
         <div class="signature" :class="{ 'focus': selectedSignature && selectedSignature.name === signature.name }" @click="goToPage(signature.pageIndex)">
           <SignatureValid v-if="signature.state === 'valid'" />
           <SignatureInvalid v-else-if="signature.state === 'invalid'" />
@@ -20,7 +20,7 @@
             @clickoutside="onOutsidePopover"
           >
             <template #trigger>
-              <Button class="more" @click.stop="selectSign(signature)">
+              <Button class="more" @click.stop="selectSign(signature, index)">
                 <MoreB />
               </Button>
             </template>
@@ -55,7 +55,6 @@ const selectedSignature = computed(() => useDocument.getSelectedSignature)
 const showPopover = ref(false)
 
 const setSignaturesList = (signatures) => {
-  console.log(signatures)
   useDocument.initSignatures(signatures)
   const instance = getCurrentInstance()
   instance?.proxy?.$forceUpdate()
@@ -79,9 +78,10 @@ const openDialog = (name) => {
   useViewer.openElement(name)
 }
 
-const selectSign = (data) => {
+const selectSign = (signature, index) => {
   showPopover.value = true
-  useDocument.setSelectedSignature(data)
+  signature.index = index
+  useDocument.setSelectedSignature(signature)
 }
 </script>
 

+ 1 - 0
packages/webview/src/stores/modules/document.js

@@ -436,6 +436,7 @@ export const useDocumentStore = defineStore({
       }
     },
     setSelectedSignature (data) {
+      this.selectedSignature = null
       this.selectedSignature = data
     },
     initSignatures (signatures) {