|
@@ -45,18 +45,18 @@ export default class SignatureFields extends Base {
|
|
|
}
|
|
|
|
|
|
async render () {
|
|
|
+ const annotation = this.annotation
|
|
|
this.eventBus._on('setProperty', this.setProperty.bind(this))
|
|
|
this.eventBus._on('updateSignatureFieldAp', this.updateAp.bind(this))
|
|
|
|
|
|
- for (let key in this.annotation) {
|
|
|
+ for (let key in annotation) {
|
|
|
if (key === 'background-color') {
|
|
|
let newName = 'backgroundColor'
|
|
|
- this.annotation[newName] = this.annotation[key]
|
|
|
- delete this.annotation[key]
|
|
|
+ annotation[newName] = annotation[key]
|
|
|
+ delete annotation[key]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const annotation = this.annotation
|
|
|
|
|
|
const { start, end } = this.getActualRect(
|
|
|
this.viewport,
|
|
@@ -91,7 +91,7 @@ export default class SignatureFields extends Base {
|
|
|
)
|
|
|
this.shapeElement = shapeElement
|
|
|
|
|
|
- if (!this.annotation.isSigned) {
|
|
|
+ if (!annotation.isSigned) {
|
|
|
let tagElement = createElement(
|
|
|
'div',
|
|
|
{
|
|
@@ -115,14 +115,15 @@ export default class SignatureFields extends Base {
|
|
|
this.tagElement = tagElement
|
|
|
}
|
|
|
|
|
|
- const signature = this.layer.annotationStore.signatures.find(item => item.signaturePtr === this.annotation.signaturePtr)
|
|
|
+ const signature = this.layer.annotationStore.signatures.find(item => item.signaturePtr === annotation.signaturePtr)
|
|
|
if (signature) {
|
|
|
this.isDigital = signature.isDigital
|
|
|
}
|
|
|
- await this.getSignatureImage()
|
|
|
+ const imgBase64 = await this.getSignatureImage()
|
|
|
+ annotation.imageBase64 = imgBase64
|
|
|
|
|
|
this.annotationContainer.append(this.shapeElement)
|
|
|
- this.annotationContainer.append(this.tagElement)
|
|
|
+ !annotation.isSigned && this.annotationContainer.append(this.tagElement)
|
|
|
this.annotationContainer.addEventListener('mousedown', this.handleClick.bind(this))
|
|
|
this.container.append(this.annotationContainer)
|
|
|
|
|
@@ -447,7 +448,12 @@ export default class SignatureFields extends Base {
|
|
|
event.stopPropagation()
|
|
|
}
|
|
|
const operatorId = event.target.getAttribute('data-id')
|
|
|
-
|
|
|
+
|
|
|
+ const documentViewer = this.layer.documentViewer
|
|
|
+ const scrollElement = documentViewer.getScrollViewElement()
|
|
|
+ this.scrollTop = scrollElement.scrollTop
|
|
|
+ this.scrollLeft = scrollElement.scrollLeft
|
|
|
+
|
|
|
const { pageX, pageY } = getClickPoint(event)
|
|
|
this.startState = {
|
|
|
operator: operatorId,
|
|
@@ -467,7 +473,15 @@ export default class SignatureFields extends Base {
|
|
|
document.querySelector('.document-container').addEventListener('scroll', event => event.preventDefault())
|
|
|
}
|
|
|
this.moving = true
|
|
|
- const { pageX, pageY } = getClickPoint(event)
|
|
|
+ let { pageX, pageY } = getClickPoint(event)
|
|
|
+
|
|
|
+ const documentViewer = this.layer.documentViewer
|
|
|
+ const scrollElement = documentViewer.getScrollViewElement()
|
|
|
+ const scrollTop = scrollElement.scrollTop
|
|
|
+ const scrollLeft = scrollElement.scrollLeft
|
|
|
+ pageX = pageX + scrollLeft - this.scrollLeft
|
|
|
+ pageY = pageY + scrollTop - this.scrollTop
|
|
|
+
|
|
|
const start = this.start
|
|
|
const end = this.end
|
|
|
const startState = this.startState
|
|
@@ -629,6 +643,7 @@ export default class SignatureFields extends Base {
|
|
|
const annotationData = {
|
|
|
type: 'delete',
|
|
|
annotation: {
|
|
|
+ type: annotation.type,
|
|
|
operate: "del-annot",
|
|
|
name: this.annotation.name,
|
|
|
pageIndex: this.page
|
|
@@ -660,7 +675,9 @@ export default class SignatureFields extends Base {
|
|
|
document.removeEventListener('mouseup', this.onMouseup)
|
|
|
document.removeEventListener('touchmove', this.onMousemove)
|
|
|
document.removeEventListener('touchend', this.onMouseup)
|
|
|
-
|
|
|
+ this.scrollLeft = 0
|
|
|
+ this.scrollTop = 0
|
|
|
+
|
|
|
const annotation = this.annotation
|
|
|
const { start, end } = this.getInitialPoint()
|
|
|
|
|
@@ -677,6 +694,7 @@ export default class SignatureFields extends Base {
|
|
|
const annotationData = {
|
|
|
type: 'delete',
|
|
|
annotation: {
|
|
|
+ type: annotation.type,
|
|
|
operate: "del-annot",
|
|
|
name: annotation.name,
|
|
|
pageIndex: annotation.pageIndex,
|
|
@@ -704,6 +722,7 @@ export default class SignatureFields extends Base {
|
|
|
type: 'modify',
|
|
|
annotation: {
|
|
|
operate: "mod-form",
|
|
|
+ type: annotation.type,
|
|
|
name: annotation.name,
|
|
|
pageIndex: this.page,
|
|
|
pagePtr: annotation.pagePtr,
|
|
@@ -781,6 +800,7 @@ export default class SignatureFields extends Base {
|
|
|
if (updatePropsNum > 0) {
|
|
|
const annotationData = {
|
|
|
operate: "mod-form",
|
|
|
+ type: annotation.type,
|
|
|
name: annotation.name,
|
|
|
pageIndex: this.page,
|
|
|
pagePtr: annotation.pagePtr,
|
|
@@ -814,6 +834,7 @@ export default class SignatureFields extends Base {
|
|
|
if (updatePropsNum > 0) {
|
|
|
const annotationData = {
|
|
|
operate: "mod-form",
|
|
|
+ type: annotation.type,
|
|
|
name: annotation.name,
|
|
|
pageIndex: this.page,
|
|
|
pagePtr: annotation.pagePtr,
|
|
@@ -873,6 +894,8 @@ export default class SignatureFields extends Base {
|
|
|
|
|
|
this.annotationContainer.append(this.imgEle)
|
|
|
}
|
|
|
+
|
|
|
+ return imgSrc
|
|
|
}
|
|
|
|
|
|
async updateAp(annotPtr) {
|
|
@@ -880,6 +903,7 @@ export default class SignatureFields extends Base {
|
|
|
this.isDigital = false
|
|
|
this.annotation.isSigned = 1
|
|
|
this.tagElement.remove()
|
|
|
- await this.getSignatureImage()
|
|
|
+ const imgBase64 = await this.getSignatureImage()
|
|
|
+ this.annotation.imageBase64 = imgBase64
|
|
|
}
|
|
|
}
|