Browse Source

add: 注释选中新增事件

liutian 4 months ago
parent
commit
85263a9909

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

@@ -570,7 +570,18 @@ export default class Shape extends Base {
       }
     } else {
       if (this.layer.selectedElementName !== this.annotation.name) {
-        this.layer.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 12 - 1
packages/core/src/annotation/ink.js

@@ -102,7 +102,18 @@ export default class Ink extends Base {
       document.removeEventListener('keydown', this.onKeydown)
     } else {
       if (this.layer.selectedElementName !== this.annotation.name) {
-        this.layer.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 13 - 1
packages/core/src/annotation/line.js

@@ -352,7 +352,19 @@ export default class Line extends Base {
       document.removeEventListener('keydown', this.onKeydown)
     } else {
       if (this.layer.selectedElementName !== this.annotation.name) {
-        this.layer.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+        delete annotationData.arrow
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 12 - 1
packages/core/src/annotation/link.js

@@ -404,7 +404,18 @@ export default class Link extends Base {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.annotationStore.selectedElementName !== this.annotation.name) {
-        this.layer.annotationStore.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.annotationStore.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 2 - 1
packages/core/src/annotation/paint/shape.js

@@ -137,7 +137,6 @@ export default class PaintShape {
       let color = this.color
       const annotationData = {
         operate: "add-annot",
-        arrow:this.tool === 'arrow',
         type: this.tool === 'arrow' ? 'line' : this.tool,
         pageIndex: this.page,
         date: new Date(),
@@ -147,6 +146,8 @@ export default class PaintShape {
         rect
       }
 
+      this.tool === 'arrow' && (annotationData.arrow = true)
+
       if (annotationData.type == 'line') {
         const linePoints = [start.x, start.y, end.x, end.y]
         annotationData.linePoints = linePoints

+ 12 - 1
packages/core/src/annotation/redaction.js

@@ -274,7 +274,18 @@ export default class Redaction extends Base {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.annotationStore.selectedElementName !== this.annotation.name) {
-        this.layer.annotationStore.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.annotationStore.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 12 - 1
packages/core/src/annotation/shape.js

@@ -402,7 +402,18 @@ export default class Shape extends Base {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.selectedElementName !== this.annotation.name) {
-        this.layer.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 12 - 1
packages/core/src/annotation/stamp.js

@@ -370,7 +370,18 @@ export default class Stamp extends Base {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.selectedElementName !== this.annotation.name) {
-        this.layer.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 12 - 1
packages/core/src/annotation/text.js

@@ -332,7 +332,18 @@ export default class Text extends Base {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.selectedElementName !== this.annotation.name) {
-        this.layer.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 12 - 1
packages/core/src/form/check_box.js

@@ -481,7 +481,18 @@ export default class CheckBox extends Base {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.annotationStore.selectedElementName !== this.annotation.name) {
-        this.layer.annotationStore.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.annotationStore.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 12 - 1
packages/core/src/form/combo_box.js

@@ -491,7 +491,18 @@ export default class ComboBox extends Base {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.annotationStore.selectedElementName !== this.annotation.name) {
-        this.layer.annotationStore.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.annotationStore.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 12 - 1
packages/core/src/form/list_box.js

@@ -456,7 +456,18 @@ export default class ListBox extends Base {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.annotationStore.selectedElementName !== this.annotation.name) {
-        this.layer.annotationStore.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.annotationStore.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 12 - 1
packages/core/src/form/push_button.js

@@ -434,7 +434,18 @@ export default class PushButton extends Base {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.annotationStore.selectedElementName !== this.annotation.name) {
-        this.layer.annotationStore.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.annotationStore.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 12 - 1
packages/core/src/form/radio_button.js

@@ -482,7 +482,18 @@ export default class RadioButton extends Base {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.annotationStore.selectedElementName !== this.annotation.name) {
-        this.layer.annotationStore.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.annotationStore.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

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

@@ -364,7 +364,18 @@ export default class SignatureFields extends Base {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.annotationStore.selectedElementName !== this.annotation.name) {
-        this.layer.annotationStore.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.annotationStore.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 12 - 1
packages/core/src/form/text_field.js

@@ -415,7 +415,18 @@ export default class TextField extends Base {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.annotationStore.selectedElementName !== this.annotation.name) {
-        this.layer.annotationStore.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.annotationStore.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
       this.outerLine.addEventListener('mousedown', this.onMousedown)

+ 12 - 1
packages/core/src/markup/text_annotation.js

@@ -229,7 +229,18 @@ class TextAnnotation extends BaseAnnotation {
       this.outerLineContainer.remove()
     } else {
       if (this.layer.selectedElementName !== this.annotation.name) {
-        this.layer.selectedElementName = this.annotation.name
+        const annotation = this.annotation
+        this.layer.selectedElementName = annotation.name
+
+        const annotationData = {
+          ...annotation
+        }
+        delete annotationData.annotPtr
+        delete annotationData.pagePtr
+        delete annotationData.operate
+        delete annotationData.targetPage
+
+        this.eventBus.dispatch('annotationSelected', annotationData)
       }
       this.container.append(this.outerLineContainer)
     }