|
@@ -1184,6 +1184,8 @@ class ComPDFKitViewer {
|
|
}
|
|
}
|
|
|
|
|
|
async reRenderAnnotations() {
|
|
async reRenderAnnotations() {
|
|
|
|
+ const signaturePtrList = await this.getSignatures()
|
|
|
|
+
|
|
this.annotations = null
|
|
this.annotations = null
|
|
const annotations = []
|
|
const annotations = []
|
|
const pagesPtr = this.pagesPtr
|
|
const pagesPtr = this.pagesPtr
|
|
@@ -1206,7 +1208,8 @@ class ComPDFKitViewer {
|
|
doc: this.doc,
|
|
doc: this.doc,
|
|
annotPtr: annotation.annotPtr,
|
|
annotPtr: annotation.annotPtr,
|
|
pagePtr: annotation.pagePtr,
|
|
pagePtr: annotation.pagePtr,
|
|
- typeInt
|
|
|
|
|
|
+ typeInt,
|
|
|
|
+ signaturePtrList
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
attr = await this.messageHandler.sendWithPromise('GetAnnotation', {
|
|
attr = await this.messageHandler.sendWithPromise('GetAnnotation', {
|
|
@@ -1784,6 +1787,8 @@ class ComPDFKitViewer {
|
|
await this.#postAnnotations(annotateHandles)
|
|
await this.#postAnnotations(annotateHandles)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.eventBus.dispatch('redactAnnotationChanged', this.redactionList.length)
|
|
|
|
+
|
|
this.isAnnotationModified = true
|
|
this.isAnnotationModified = true
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
@@ -2926,7 +2931,7 @@ class ComPDFKitViewer {
|
|
|
|
|
|
this.pdfViewer.pagesPtr = this.pagesPtr
|
|
this.pdfViewer.pagesPtr = this.pagesPtr
|
|
this.pdfViewer._pages.forEach(page => {
|
|
this.pdfViewer._pages.forEach(page => {
|
|
- page.pagesPtr = this.pagesPtr
|
|
|
|
|
|
+ page.pagePtr = this.pagesPtr[page.pageIndex].pagePtr
|
|
});
|
|
});
|
|
|
|
|
|
this.pdfViewer.refresh()
|
|
this.pdfViewer.refresh()
|
|
@@ -4310,46 +4315,49 @@ class ComPDFKitViewer {
|
|
}
|
|
}
|
|
|
|
|
|
async applyRedactions(redaction) {
|
|
async applyRedactions(redaction) {
|
|
- if (redaction) {
|
|
|
|
- let redactionList
|
|
|
|
- if (redaction === 'all') {
|
|
|
|
- redactionList = [...this.redactionList]
|
|
|
|
- this.redactionList.length = 0
|
|
|
|
- } else {
|
|
|
|
- const redactions = Array.isArray(redaction) ? redaction : [redaction]
|
|
|
|
- redactionList = redactions
|
|
|
|
- }
|
|
|
|
- for (const item of redactionList) {
|
|
|
|
- if (item.erasure) {
|
|
|
|
- if (item.rects && item.rects.length) {
|
|
|
|
- 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()
|
|
|
|
|
|
+ if (!redaction) {
|
|
|
|
+ await this.delAnnotations(this.redactionList)
|
|
|
|
+ this.redactionList.length = 0
|
|
this.pdfViewer.refresh()
|
|
this.pdfViewer.refresh()
|
|
- this.reRenderAnnotations()
|
|
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
|
|
- return new Promise((resolve) => {
|
|
|
|
- const eventHandler = () => {
|
|
|
|
- this.eventBus._off('annotationChanged', eventHandler)
|
|
|
|
- resolve()
|
|
|
|
- }
|
|
|
|
- this.eventBus._on('annotationChanged', eventHandler)
|
|
|
|
- })
|
|
|
|
|
|
+ let redactionList
|
|
|
|
+ if (redaction === 'all') {
|
|
|
|
+ redactionList = [...this.redactionList]
|
|
|
|
+ await this.delAnnotations(this.redactionList)
|
|
|
|
+ this.redactionList.length = 0
|
|
|
|
+ } else {
|
|
|
|
+ const redactions = Array.isArray(redaction) ? redaction : [redaction]
|
|
|
|
+ redactionList = redactions
|
|
}
|
|
}
|
|
|
|
|
|
- await this.delAnnotations(this.redactionList)
|
|
|
|
- this.redactionList.length = 0
|
|
|
|
|
|
+ for (const item of redactionList.filter(item => !item.erasure)) {
|
|
|
|
+ await this.messageHandler.sendWithPromise('ApplyRedaction', { annotPtr: item.annotPtr })
|
|
|
|
+ }
|
|
|
|
+ for (const item of redactionList.filter(item => item.erasure)) {
|
|
|
|
+ if (item.rects && item.rects.length) {
|
|
|
|
+ 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 })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ await this.updateTextPtr()
|
|
|
|
+ this.emptyAnnotations()
|
|
this.pdfViewer.refresh()
|
|
this.pdfViewer.refresh()
|
|
|
|
+ this.reRenderAnnotations()
|
|
|
|
+
|
|
|
|
+ return new Promise((resolve) => {
|
|
|
|
+ const eventHandler = () => {
|
|
|
|
+ this.eventBus._off('annotationChanged', eventHandler)
|
|
|
|
+ this.pdfViewer.refresh()
|
|
|
|
+ resolve()
|
|
|
|
+ }
|
|
|
|
+ this.eventBus._on('annotationChanged', eventHandler)
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|