From 37b61f22281e3bd7e94bd2f7660d0b411cc29640 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 1 Jul 2022 16:09:10 +0200 Subject: [PATCH] [editor] Disable editing while PresentationMode is active --- web/base_viewer.js | 4 +++- web/pdf_presentation_mode.js | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/web/base_viewer.js b/web/base_viewer.js index d73ad1263a923..1ba11a1fa9969 100644 --- a/web/base_viewer.js +++ b/web/base_viewer.js @@ -2156,7 +2156,9 @@ class BaseViewer { * @type {number} */ get annotationEditorMode() { - return this.#annotationEditorMode; + return this.#annotationEditorUIManager + ? this.#annotationEditorMode + : AnnotationEditorType.DISABLE; } /** diff --git a/web/pdf_presentation_mode.js b/web/pdf_presentation_mode.js index 7da3719cb0f18..d1dc0782120a6 100644 --- a/web/pdf_presentation_mode.js +++ b/web/pdf_presentation_mode.js @@ -19,6 +19,7 @@ import { ScrollMode, SpreadMode, } from "./ui_utils.js"; +import { AnnotationEditorType } from "pdfjs-lib"; const DELAY_BEFORE_HIDING_CONTROLS = 3000; // in ms const ACTIVE_SELECTOR = "pdfPresentationMode"; @@ -79,6 +80,7 @@ class PDFPresentationMode { scaleValue: pdfViewer.currentScaleValue, scrollMode: pdfViewer.scrollMode, spreadMode: null, + annotationEditorMode: null, }; if ( @@ -91,6 +93,9 @@ class PDFPresentationMode { ); this.#args.spreadMode = pdfViewer.spreadMode; } + if (pdfViewer.annotationEditorMode !== AnnotationEditorType.DISABLE) { + this.#args.annotationEditorMode = pdfViewer.annotationEditorMode; + } try { await promise; @@ -167,6 +172,10 @@ class PDFPresentationMode { } this.pdfViewer.currentPageNumber = this.#args.pageNumber; this.pdfViewer.currentScaleValue = "page-fit"; + + if (this.#args.annotationEditorMode !== null) { + this.pdfViewer.annotationEditorMode = AnnotationEditorType.NONE; + } }, 0); this.#addWindowListeners(); @@ -195,6 +204,10 @@ class PDFPresentationMode { } this.pdfViewer.currentScaleValue = this.#args.scaleValue; this.pdfViewer.currentPageNumber = pageNumber; + + if (this.#args.annotationEditorMode !== null) { + this.pdfViewer.annotationEditorMode = this.#args.annotationEditorMode; + } this.#args = null; }, 0);