mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
[api-minor] Fix the AnnotationStorage
usage properly in the viewer/tests (PR 12107 and 12143 follow-up)
*The [api-minor] label probably ought to have been added to the original PR, given the changes to the `createAnnotationLayerBuilder` signature (if nothing else).* This patch fixes the following things: - Let the `AnnotationLayer.render` method create an `AnnotationStorage`-instance if none was provided, thus making the parameter *properly* optional. This not only fixes the reference tests, it also prevents issues when the viewer components are used. - Stop exporting `AnnotationStorage` in the official API, i.e. the `src/pdf.js` file, since it's no longer necessary given the change above. Generally speaking, unless absolutely necessary we probably shouldn't export unused things in the API. - Fix a number of JSDocs `typedef`s, in `src/display/` and `web/` code, to actually account for the new `annotationStorage` parameter. - Update `web/interfaces.js` to account for the changes in `createAnnotationLayerBuilder`. - Initialize the storage, in `AnnotationStorage`, using `Object.create(null)` rather than `{}` (which is the PDF.js default).
This commit is contained in:
parent
c5663f2f6b
commit
346afd1e1c
6 changed files with 11 additions and 8 deletions
|
@ -21,6 +21,7 @@ import { SimpleLinkService } from "./pdf_link_service.js";
|
|||
* @typedef {Object} AnnotationLayerBuilderOptions
|
||||
* @property {HTMLDivElement} pageDiv
|
||||
* @property {PDFPage} pdfPage
|
||||
* @property {AnnotationStorage} [annotationStorage]
|
||||
* @property {string} [imageResourcesPath] - Path for image resources, mainly
|
||||
* for annotation icons. Include trailing slash.
|
||||
* @property {boolean} renderInteractiveForms
|
||||
|
@ -38,7 +39,7 @@ class AnnotationLayerBuilder {
|
|||
pdfPage,
|
||||
linkService,
|
||||
downloadManager,
|
||||
annotationStorage,
|
||||
annotationStorage = null,
|
||||
imageResourcesPath = "",
|
||||
renderInteractiveForms = false,
|
||||
l10n = NullL10n,
|
||||
|
@ -118,6 +119,7 @@ class DefaultAnnotationLayerFactory {
|
|||
/**
|
||||
* @param {HTMLDivElement} pageDiv
|
||||
* @param {PDFPage} pdfPage
|
||||
* @param {AnnotationStorage} [annotationStorage]
|
||||
* @param {string} [imageResourcesPath] - Path for image resources, mainly
|
||||
* for annotation icons. Include trailing slash.
|
||||
* @param {boolean} renderInteractiveForms
|
||||
|
@ -127,7 +129,7 @@ class DefaultAnnotationLayerFactory {
|
|||
createAnnotationLayerBuilder(
|
||||
pageDiv,
|
||||
pdfPage,
|
||||
annotationStorage,
|
||||
annotationStorage = null,
|
||||
imageResourcesPath = "",
|
||||
renderInteractiveForms = false,
|
||||
l10n = NullL10n
|
||||
|
|
|
@ -165,6 +165,7 @@ class IPDFAnnotationLayerFactory {
|
|||
/**
|
||||
* @param {HTMLDivElement} pageDiv
|
||||
* @param {PDFPage} pdfPage
|
||||
* @param {AnnotationStorage} [annotationStorage]
|
||||
* @param {string} [imageResourcesPath] - Path for image resources, mainly
|
||||
* for annotation icons. Include trailing slash.
|
||||
* @param {boolean} renderInteractiveForms
|
||||
|
@ -174,6 +175,7 @@ class IPDFAnnotationLayerFactory {
|
|||
createAnnotationLayerBuilder(
|
||||
pageDiv,
|
||||
pdfPage,
|
||||
annotationStorage = null,
|
||||
imageResourcesPath = "",
|
||||
renderInteractiveForms = false,
|
||||
l10n = undefined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue