From d7d21f0d6e29ac292b8678aae7c1b60bc04f26a1 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 7 Dec 2022 10:21:57 +0100 Subject: [PATCH] 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, });