|
@@ -451,11 +451,11 @@ class ComPDFKitViewer {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- delAnnotations(annotation) {
|
|
|
+ async delAnnotations(annotation) {
|
|
|
const annotations = Array.isArray(annotation) ? annotation : [annotation]
|
|
|
- annotations.forEach(item => {
|
|
|
- this.handleAnnotationChange({ type: 'delete', annotation: item })
|
|
|
- })
|
|
|
+ for (const item of annotations) {
|
|
|
+ await this.handleAnnotationChange({ type: 'delete', annotation: item })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
addEvent(eventName, fn) {
|
|
@@ -1702,11 +1702,10 @@ class ComPDFKitViewer {
|
|
|
currentAnnotation = this.handleInk(currentAnnotation)
|
|
|
}
|
|
|
annotateHandles.push(currentAnnotation)
|
|
|
- if (annotation[i].type === 'redaction' || annotation[i].type === 'remove') this.redactionList.push(annotation[i])
|
|
|
- console.log(annotation, this.redactionList)
|
|
|
+ if (annotation[i].type === 'redact') this.redactionList.push(annotation[i])
|
|
|
}
|
|
|
} else {
|
|
|
- const annotations = this.annotations[annotation.pageIndex]
|
|
|
+ let annotations = this.annotations[annotation.pageIndex]
|
|
|
if (!annotations) return
|
|
|
const index = findIndex(annotation.name, annotations)
|
|
|
if (this.webviewerServer) {
|
|
@@ -1780,7 +1779,6 @@ class ComPDFKitViewer {
|
|
|
await this.#postAnnotations(annotateHandles)
|
|
|
}
|
|
|
|
|
|
- console.log(this.redactionList)
|
|
|
this.eventBus.dispatch('showRedactionApplyBar', this.redactionList.length ? true : false)
|
|
|
|
|
|
this.isAnnotationModified = true
|
|
@@ -2872,12 +2870,6 @@ class ComPDFKitViewer {
|
|
|
await this.updateTextPtr();
|
|
|
}
|
|
|
|
|
|
- if (oldMode === 'security' && this.toolMode !== 'security') {
|
|
|
- console.log('delete: ', this.redactionList)
|
|
|
- this.delAnnotations(this.redactionList)
|
|
|
- this.pdfViewer.refresh()
|
|
|
- }
|
|
|
-
|
|
|
for (let page in this.annotations) {
|
|
|
for (let i = 0; i < this.annotations[page].length; i++) {
|
|
|
const annot = this.annotations[page][i]
|
|
@@ -4302,11 +4294,30 @@ class ComPDFKitViewer {
|
|
|
this.isContentEditModyfied = value
|
|
|
}
|
|
|
|
|
|
- applyRedactions(redaction) {
|
|
|
- console.log('apply: ', this.redactionList)
|
|
|
- const redactions = Array.isArray(redaction) ? redaction : [redaction]
|
|
|
- // redactions.length > 0 && this.addAnnotations(redactions)
|
|
|
- this.redactionList = []
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ console.log(redactionList)
|
|
|
+ redactionList.forEach(async item => {
|
|
|
+ if (item.erasure) {
|
|
|
+ await this.messageHandler.sendWithPromise('ErasureRedactionFromRect', { pagePtr: item.pagePtr, rect: item.rect })
|
|
|
+ } else {
|
|
|
+ await this.messageHandler.sendWithPromise('ApplyRedaction', { annotPtr: item.annotPtr })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ await this.delAnnotations(redactionList)
|
|
|
+ } else {
|
|
|
+ await this.delAnnotations(this.redactionList)
|
|
|
+ this.redactionList.length = 0
|
|
|
+ }
|
|
|
+ this.pdfViewer.refresh()
|
|
|
}
|
|
|
}
|
|
|
|