|
@@ -21,6 +21,7 @@ import MessageHandler from "./message_handler"
|
|
|
import JSZip from 'jszip'
|
|
|
import Outline from './Outline'
|
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
+import { ContentEditManager } from "./editor/content_edit_manager.js";
|
|
|
|
|
|
GlobalWorkerOptions.workerSrc = './lib/pdf.worker.min.js'
|
|
|
const CMAP_URL = './cmaps/'
|
|
@@ -86,8 +87,8 @@ class ComPDFKitViewer {
|
|
|
|
|
|
this.initWorker()
|
|
|
this.annotator = 'Guest'
|
|
|
- this.undoList = []
|
|
|
- this.redoList = []
|
|
|
+ this.isAnnotationModified = false
|
|
|
+ this.isContentEditModyfied = false
|
|
|
}
|
|
|
|
|
|
get pagesCount() {
|
|
@@ -114,6 +115,10 @@ class ComPDFKitViewer {
|
|
|
return this.pdfViewer.currentScale;
|
|
|
}
|
|
|
|
|
|
+ get isDocumentModified() {
|
|
|
+ return this.isAnnotationModified || this.isContentEditModyfied;
|
|
|
+ }
|
|
|
+
|
|
|
getPageWidth(pageNumber) {
|
|
|
return this.pagesPtr[pageNumber - 1].width
|
|
|
}
|
|
@@ -480,6 +485,8 @@ class ComPDFKitViewer {
|
|
|
annotationStore.selectedName = null
|
|
|
this.fontFileInited = false
|
|
|
this.saveAction = options.saveAction || null
|
|
|
+ this.isAnnotationModified = false
|
|
|
+ this.isContentEditModyfied = false
|
|
|
const parameters = {
|
|
|
cMapUrl: CMAP_URL,
|
|
|
cMapPacked: true,
|
|
@@ -1514,7 +1521,7 @@ class ComPDFKitViewer {
|
|
|
eventBus._on("resize", this.webViewerResize.bind(this));
|
|
|
eventBus._on("pagerendered", this.webViewerPageRendered.bind(this));
|
|
|
eventBus._on("updateviewarea", this.webViewerUpdateViewarea.bind(this));
|
|
|
- eventBus._on("pagechanging", this.webViewerPageChanging.bind(this));
|
|
|
+ eventBus._on("onPageNumberUpdated", this.webViewerPageChanging.bind(this));
|
|
|
eventBus._on("rotationchanging", this.webViewerRotationChanging.bind(this));
|
|
|
eventBus._on("sidebarviewchanged", this.webViewerSidebarViewChanged.bind(this));
|
|
|
eventBus._on("presentationmodechanged", this.webViewerPresentationModeChanged.bind(this));
|
|
@@ -1546,6 +1553,7 @@ class ComPDFKitViewer {
|
|
|
eventBus._on("handleField", this.handleField.bind(this));
|
|
|
eventBus._on("pageNumberChanged", this.pageNumberChanged.bind(this));
|
|
|
eventBus._on("updateSignatureAp", this.updateSignatureAp.bind(this));
|
|
|
+ eventBus._on("isContentEditModyfied", this.setContentEditModyfied.bind(this));
|
|
|
}
|
|
|
|
|
|
bindWindowEvents() {
|
|
@@ -1767,6 +1775,8 @@ class ComPDFKitViewer {
|
|
|
this.#convertAnnotationsForBackend(annotateHandles)
|
|
|
await this.#postAnnotations(annotateHandles)
|
|
|
}
|
|
|
+
|
|
|
+ this.isAnnotationModified = true
|
|
|
return true
|
|
|
}
|
|
|
|
|
@@ -2312,8 +2322,7 @@ class ComPDFKitViewer {
|
|
|
enablePrintAutoRotate: true,
|
|
|
eventBus: this.eventBus,
|
|
|
$t: this.$t,
|
|
|
- doc: this.doc,
|
|
|
- messageHandler: this.messageHandler
|
|
|
+ doc: this.doc
|
|
|
});
|
|
|
|
|
|
pdfRenderingQueue.setViewer(this.pdfViewer);
|
|
@@ -2364,6 +2373,8 @@ class ComPDFKitViewer {
|
|
|
});
|
|
|
this.pdfSidebar.onToggled = this.forceRendering.bind(this);
|
|
|
}
|
|
|
+
|
|
|
+ this.contentEditManager = new ContentEditManager(this);
|
|
|
}
|
|
|
|
|
|
setInitialView(
|
|
@@ -2475,6 +2486,12 @@ class ComPDFKitViewer {
|
|
|
top
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ scrollToPercent(percent) {
|
|
|
+ const scrollTotalHeight = this.scrollContainer.scrollHeight - this.scrollContainer.clientHeight;
|
|
|
+ const top = scrollTotalHeight * percent / 100;
|
|
|
+ this.scrollTo({ top });
|
|
|
+ }
|
|
|
|
|
|
webViewerAnnotationsCountChanged(evt) {
|
|
|
this.annotationsNumChangedCallback(evt.annotationsCount);
|
|
@@ -2601,6 +2618,7 @@ class ComPDFKitViewer {
|
|
|
this.pdfThumbnailViewer.scrollThumbnailIntoView(pageNumber);
|
|
|
}
|
|
|
this.pageChangedCallback(this.page)
|
|
|
+ return pageNumber
|
|
|
}
|
|
|
|
|
|
webViewerSidebarViewChanged({ view }) {
|
|
@@ -4071,6 +4089,8 @@ class ComPDFKitViewer {
|
|
|
this.#convertAnnotationsForBackend(annotateHandles)
|
|
|
this.#postAnnotations(annotateHandles)
|
|
|
}
|
|
|
+
|
|
|
+ this.isAnnotationModified = true
|
|
|
}
|
|
|
|
|
|
async #postAnnotations(annotateHandles) {
|
|
@@ -4212,6 +4232,18 @@ class ComPDFKitViewer {
|
|
|
const { operation, pageNumber } = data
|
|
|
this.pdfViewer._pages[pageNumber - 1].contentContainer.handleResetOperate(operation)
|
|
|
}
|
|
|
+
|
|
|
+ getContentEditManager() {
|
|
|
+ return this.contentEditManager
|
|
|
+ }
|
|
|
+
|
|
|
+ getContentEditHistoryManager() {
|
|
|
+ return this.pdfViewer.contentEditHistoryManager
|
|
|
+ }
|
|
|
+
|
|
|
+ setContentEditModyfied(value) {
|
|
|
+ this.isContentEditModyfied = value
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
class PDFWorker {
|