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