From 5969df140b8640a8f55d16701dc16cc071cf6ef7 Mon Sep 17 00:00:00 2001 From: James Yu Date: Thu, 12 Dec 2024 11:21:33 +0800 Subject: [PATCH] Close #4484 Disable open, print, save handlers of pdf viewer --- dev/editviewer.py | 4 +++- viewer/viewer.mjs | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dev/editviewer.py b/dev/editviewer.py index 1e521518a..ca00fb47e 100644 --- a/dev/editviewer.py +++ b/dev/editviewer.py @@ -44,7 +44,9 @@ .replace('''setRotation(this.initialRotation);''', '''// setRotation(this.initialRotation);''') \ .replace('''this.pdfLinkService.setHash(this.initialBookmark);''', '''// this.pdfLinkService.setHash(this.initialBookmark);''') \ .replace('''hPadding = vPadding = 0;''', '''if (this._scrollMode === ScrollMode.HORIZONTAL || this._spreadMode === SpreadMode.NONE) { hPadding = vPadding = 0; } else { hPadding = 10; vPadding = 0; }''') \ - # .replace('''parent.document.dispatchEvent(event);''', '''parent.document.dispatchEvent(event); \n document.dispatchEvent(event);''') + .replace('''eventBus._on("openfile"''', '''// eventBus._on("openfile"''') \ + .replace('''eventBus._on("print"''', '''// eventBus._on("print"''') \ + .replace('''eventBus._on("download"''', '''// eventBus._on("download"''') fout.write(line) os.system(f'git diff --no-index {args.web}/viewer.html {args.viewer}/viewer.html > {args.viewer}/../dev/viewer/viewer.html.diff') diff --git a/viewer/viewer.mjs b/viewer/viewer.mjs index da9717dc3..6611e3569 100644 --- a/viewer/viewer.mjs +++ b/viewer/viewer.mjs @@ -14251,8 +14251,8 @@ const PDFViewerApplication = { eventBus._on("presentationmodechanged", evt => pdfViewer.presentationModeState = evt.state, opts); eventBus._on("presentationmode", this.requestPresentationMode.bind(this), opts); eventBus._on("switchannotationeditormode", evt => pdfViewer.annotationEditorMode = evt, opts); - eventBus._on("print", this.triggerPrinting.bind(this), opts); - eventBus._on("download", this.downloadOrSave.bind(this), opts); + // eventBus._on("print", this.triggerPrinting.bind(this), opts); + // eventBus._on("download", this.downloadOrSave.bind(this), opts); eventBus._on("firstpage", () => this.page = 1, opts); eventBus._on("lastpage", () => this.page = this.pagesCount, opts); eventBus._on("nextpage", () => pdfViewer.nextPage(), opts); @@ -14275,7 +14275,7 @@ const PDFViewerApplication = { eventBus._on("updatefindmatchescount", onUpdateFindMatchesCount.bind(this), opts); eventBus._on("updatefindcontrolstate", onUpdateFindControlState.bind(this), opts); eventBus._on("fileinputchange", onFileInputChange.bind(this), opts); - eventBus._on("openfile", onOpenFile.bind(this), opts); + // eventBus._on("openfile", onOpenFile.bind(this), opts); }, bindWindowEvents() { if (this._windowAbortController) {