From 6a5c1343f8b06780b5cbf5e8c792f305f66aac37 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 7 Dec 2022 10:12:43 +0100 Subject: [PATCH 1/2] Stop trying to disable searching in PresentationMode This change was made in PR 5552, however I cannot tell why we needed to disable searching in PresentationMode. Furthermore, with the changes in PR 13908 which effectively moved where this code is invoked, searching has now (accidentally) been working in PresentationMode in e.g. the Firefox PDF Viewer for well over a year. So, let's just enable searching unconditionally in PresentationMode to simplify the code. --- web/pdf_viewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index 142b5e0fe..44af2f098 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -1676,7 +1676,7 @@ class PDFViewer { return new TextHighlighter({ eventBus, pageIndex, - findController: this.isInPresentationMode ? null : this.findController, + findController: this.findController, }); } From d7d21f0d6e29ac292b8678aae7c1b60bc04f26a1 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 7 Dec 2022 10:21:57 +0100 Subject: [PATCH 2/2] Change `AnnotationEditorLayerBuilder.render` to not access "private" API functionality The `PDFPageProxy._pageIndex` property is a "private" one that shouldn't be accessed, since it could theoretically break tomorrow if we re-factor the relevant API code. Also, try to clean-up and improve consistency in a couple of JSDoc comments. --- web/annotation_editor_layer_builder.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/web/annotation_editor_layer_builder.js b/web/annotation_editor_layer_builder.js index 836f0ba53..e912ff60b 100644 --- a/web/annotation_editor_layer_builder.js +++ b/web/annotation_editor_layer_builder.js @@ -16,12 +16,9 @@ /** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */ // eslint-disable-next-line max-len /** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */ -/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */ // eslint-disable-next-line max-len /** @typedef {import("../src/display/editor/tools.js").AnnotationEditorUIManager} AnnotationEditorUIManager */ // eslint-disable-next-line max-len -/** @typedef {import("../annotation_storage.js").AnnotationStorage} AnnotationStorage */ -// eslint-disable-next-line max-len /** @typedef {import("./text_accessibility.js").TextAccessibilityManager} TextAccessibilityManager */ /** @typedef {import("./interfaces").IL10n} IL10n */ @@ -30,13 +27,11 @@ import { NullL10n } from "./l10n_utils.js"; /** * @typedef {Object} AnnotationEditorLayerBuilderOptions - * @property {number} mode - Editor mode + * @property {AnnotationEditorUIManager} [uiManager] * @property {HTMLDivElement} pageDiv * @property {PDFPageProxy} pdfPage - * @property {TextAccessibilityManager} accessibilityManager - * @property {AnnotationStorage} annotationStorage - * @property {IL10n} l10n - Localization service. - * @property {AnnotationEditorUIManager} uiManager + * @property {IL10n} l10n + * @property {TextAccessibilityManager} [accessibilityManager] */ class AnnotationEditorLayerBuilder { @@ -48,7 +43,6 @@ class AnnotationEditorLayerBuilder { constructor(options) { this.pageDiv = options.pageDiv; this.pdfPage = options.pdfPage; - this.annotationStorage = options.annotationStorage || null; this.accessibilityManager = options.accessibilityManager; this.l10n = options.l10n || NullL10n; this.annotationEditorLayer = null; @@ -86,9 +80,8 @@ class AnnotationEditorLayerBuilder { this.annotationEditorLayer = new AnnotationEditorLayer({ uiManager: this.#uiManager, div: this.div, - annotationStorage: this.annotationStorage, accessibilityManager: this.accessibilityManager, - pageIndex: this.pdfPage._pageIndex, + pageIndex: this.pdfPage.pageNumber - 1, l10n: this.l10n, viewport: clonedViewport, });