|
@@ -685,9 +685,11 @@ class ComPDFKitViewer {
|
|
annotation.index = Number(rawAnnotation.index)
|
|
annotation.index = Number(rawAnnotation.index)
|
|
annotation.contents = rawAnnotation.content || ''
|
|
annotation.contents = rawAnnotation.content || ''
|
|
annotation.opacity = round(rawAnnotation.opacity, 2) || 1
|
|
annotation.opacity = round(rawAnnotation.opacity, 2) || 1
|
|
- rawAnnotation.replies && (annotation.replies = rawAnnotation.replies)
|
|
|
|
- rawAnnotation.markedAnnotState && (annotation.markedAnnotState = AnnotationStateString[rawAnnotation.markedAnnotState])
|
|
|
|
- rawAnnotation.reviewAnnotState && (annotation.reviewAnnotState = AnnotationStateString[rawAnnotation.reviewAnnotState])
|
|
|
|
|
|
+ rawAnnotation.mainName && (annotation.mainName = rawAnnotation.mainName)
|
|
|
|
+ rawAnnotation.replies && (annotation.replies = rawAnnotation.replies);
|
|
|
|
+ (rawAnnotation.markedAnnotState || rawAnnotation.markedAnnotState === 0) && (annotation.markedAnnotState = AnnotationStateString[rawAnnotation.markedAnnotState]);
|
|
|
|
+ (rawAnnotation.reviewAnnotState || rawAnnotation.reviewAnnotState === 0) && (annotation.reviewAnnotState = AnnotationStateString[rawAnnotation.reviewAnnotState])
|
|
|
|
+ annotation.name = rawAnnotation.name || uuidv4()
|
|
|
|
|
|
switch (rawAnnotation.type) {
|
|
switch (rawAnnotation.type) {
|
|
case 'freetext':
|
|
case 'freetext':
|
|
@@ -838,7 +840,7 @@ class ComPDFKitViewer {
|
|
|
|
|
|
if (annotation.replies?.length) {
|
|
if (annotation.replies?.length) {
|
|
for (const reply of annotation.replies) {
|
|
for (const reply of annotation.replies) {
|
|
- reply.name = uuidv4()
|
|
|
|
|
|
+ reply.name = reply.name || uuidv4()
|
|
reply.contents = reply.content
|
|
reply.contents = reply.content
|
|
delete reply.content
|
|
delete reply.content
|
|
reply.date = parseAdobePDFTimestamp(rawAnnotation.recentlyModifyDate || rawAnnotation.date || rawAnnotation.creationdate)
|
|
reply.date = parseAdobePDFTimestamp(rawAnnotation.recentlyModifyDate || rawAnnotation.date || rawAnnotation.creationdate)
|
|
@@ -2561,6 +2563,7 @@ class ComPDFKitViewer {
|
|
for (let page in this.annotations) {
|
|
for (let page in this.annotations) {
|
|
for (let i = 0; i < this.annotations[page].length; i++) {
|
|
for (let i = 0; i < this.annotations[page].length; i++) {
|
|
const annot = this.annotations[page][i]
|
|
const annot = this.annotations[page][i]
|
|
|
|
+ if (!annot) continue
|
|
const element = document.getElementById(annot['name'])
|
|
const element = document.getElementById(annot['name'])
|
|
|
|
|
|
if (element) {
|
|
if (element) {
|
|
@@ -3336,7 +3339,7 @@ class ComPDFKitViewer {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// 处理回复注释
|
|
// 处理回复注释
|
|
async handleReplyAnnotation(data) {
|
|
async handleReplyAnnotation(data) {
|
|
const { type, annotation, reply, reviewAnnotState, markedAnnotState } = data
|
|
const { type, annotation, reply, reviewAnnotState, markedAnnotState } = data
|
|
@@ -3365,9 +3368,10 @@ class ComPDFKitViewer {
|
|
if (reviewAnnotState) annot.reviewAnnotState = reviewAnnotState
|
|
if (reviewAnnotState) annot.reviewAnnotState = reviewAnnotState
|
|
if (markedAnnotState) annot.markedAnnotState = markedAnnotState
|
|
if (markedAnnotState) annot.markedAnnotState = markedAnnotState
|
|
} else {
|
|
} else {
|
|
- const index = findIndex(annot.name, this.annotations[annotation.pageIndex])
|
|
|
|
|
|
+ const annotations = this.annotations[annotation.pageIndex]
|
|
|
|
+ const index = findIndex(annot.name, annotations)
|
|
annot.index = index
|
|
annot.index = index
|
|
-
|
|
|
|
|
|
+
|
|
annotateHandles.push({
|
|
annotateHandles.push({
|
|
operate: 'add-annot',
|
|
operate: 'add-annot',
|
|
type: 'reply',
|
|
type: 'reply',
|
|
@@ -3379,6 +3383,8 @@ class ComPDFKitViewer {
|
|
})
|
|
})
|
|
if (!annot.replies) annot.replies = []
|
|
if (!annot.replies) annot.replies = []
|
|
annot.replies.push(reply)
|
|
annot.replies.push(reply)
|
|
|
|
+
|
|
|
|
+ annotations.push(reply)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (reviewAnnotState || markedAnnotState) { // 添加有状态回复(首次设置注释状态)
|
|
if (reviewAnnotState || markedAnnotState) { // 添加有状态回复(首次设置注释状态)
|
|
@@ -3391,9 +3397,11 @@ class ComPDFKitViewer {
|
|
if (markedAnnotState) annot.markedAnnotState = newState
|
|
if (markedAnnotState) annot.markedAnnotState = newState
|
|
else annot.reviewAnnotState = newState
|
|
else annot.reviewAnnotState = newState
|
|
} else {
|
|
} else {
|
|
|
|
+ const annotations = this.annotations[annotation.pageIndex]
|
|
|
|
+ const index = findIndex(annot.name, annotations)
|
|
const data = {
|
|
const data = {
|
|
operate: 'mod-annot',
|
|
operate: 'mod-annot',
|
|
- index: annot.index,
|
|
|
|
|
|
+ index,
|
|
pageIndex: annot.pageIndex,
|
|
pageIndex: annot.pageIndex,
|
|
targetPage: annot.pageIndex + 1
|
|
targetPage: annot.pageIndex + 1
|
|
}
|
|
}
|
|
@@ -3408,7 +3416,6 @@ class ComPDFKitViewer {
|
|
annotateHandles.push(data)
|
|
annotateHandles.push(data)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
} else if (type === 'delete') {
|
|
} else if (type === 'delete') {
|
|
if (!this.webviewerServer) {
|
|
if (!this.webviewerServer) {
|
|
await this.messageHandler.sendWithPromise('RemoveAnnot', {
|
|
await this.messageHandler.sendWithPromise('RemoveAnnot', {
|
|
@@ -3423,13 +3430,13 @@ class ComPDFKitViewer {
|
|
targetPage: reply.pageIndex + 1
|
|
targetPage: reply.pageIndex + 1
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- annot.replies = annot.replies.filter(item => item.name !== reply.name)
|
|
|
|
- annot.replies.forEach(item => {
|
|
|
|
- if (item.index > reply.index) {
|
|
|
|
- item.index--
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
|
|
|
|
+ annot.replies.splice(reply.index, 1)
|
|
|
|
+ annot.replies.map((item, index) => item.index = index)
|
|
|
|
+
|
|
|
|
+ const annotations = this.annotations[annotation.pageIndex]
|
|
|
|
+ const index = findIndex(reply.name, annotations)
|
|
|
|
+ annotations.splice(index, 1)
|
|
} else if (type === 'edit') {
|
|
} else if (type === 'edit') {
|
|
if (markedAnnotState || reviewAnnotState) { // 修改注释状态
|
|
if (markedAnnotState || reviewAnnotState) { // 修改注释状态
|
|
if (!this.webviewerServer) {
|
|
if (!this.webviewerServer) {
|
|
@@ -3444,16 +3451,24 @@ class ComPDFKitViewer {
|
|
annot.reviewAnnotState = newState
|
|
annot.reviewAnnotState = newState
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
|
|
+ const annotations = this.annotations[annotation.pageIndex]
|
|
|
|
+ const index = findIndex(annot.name, annotations)
|
|
|
|
+ const data = {
|
|
|
|
+ operate: 'mod-annot',
|
|
|
|
+ index,
|
|
|
|
+ pageIndex: annot.pageIndex,
|
|
|
|
+ targetPage: annot.pageIndex + 1
|
|
|
|
+ }
|
|
if (markedAnnotState) {
|
|
if (markedAnnotState) {
|
|
annot.markedAnnotState = markedAnnotState
|
|
annot.markedAnnotState = markedAnnotState
|
|
|
|
+ data.markedAnnotState = markedAnnotState
|
|
}
|
|
}
|
|
if (reviewAnnotState) {
|
|
if (reviewAnnotState) {
|
|
annot.reviewAnnotState = reviewAnnotState
|
|
annot.reviewAnnotState = reviewAnnotState
|
|
|
|
+ data.reviewAnnotState = reviewAnnotState
|
|
}
|
|
}
|
|
- let postData = JSON.parse(JSON.stringify(annot))
|
|
|
|
- annotateHandles.push(postData)
|
|
|
|
|
|
+ annotateHandles.push(data)
|
|
}
|
|
}
|
|
-
|
|
|
|
} else { // 修改回复内容
|
|
} else { // 修改回复内容
|
|
if (!this.webviewerServer) {
|
|
if (!this.webviewerServer) {
|
|
this.messageHandler.sendWithPromise('EditReplyAnnotation', {
|
|
this.messageHandler.sendWithPromise('EditReplyAnnotation', {
|
|
@@ -3474,15 +3489,10 @@ class ComPDFKitViewer {
|
|
targetPage: reply.pageIndex + 1,
|
|
targetPage: reply.pageIndex + 1,
|
|
content: reply.contents
|
|
content: reply.contents
|
|
})
|
|
})
|
|
- }
|
|
|
|
|
|
|
|
- // const res = await this.messageHandler.sendWithPromise('GetReplyAnnotation', {
|
|
|
|
- // pagePtr,
|
|
|
|
- // annotPtr
|
|
|
|
- // })
|
|
|
|
- // annot.replies = res.replies
|
|
|
|
- // annot.reviewAnnotState = res.reviewAnnotState
|
|
|
|
- // annot.markedAnnotState = res.markedAnnotState
|
|
|
|
|
|
+ const replayAnnotation = this.annotations[annotation.pageIndex].find(item => item.name === replyItem.name)
|
|
|
|
+ replayAnnotation.contents = reply.contents
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
this.eventBus.dispatch('annotationChanged', { annotations: this.annotations })
|
|
this.eventBus.dispatch('annotationChanged', { annotations: this.annotations })
|