Merge pull request #16572 from Snuffleupagus/annotationLayer-NullL10n
[api-minor] Ensure that the `AnnotationLayer` gets a default l10n-instance in GENERIC builds (PR 16552 follow-up)
This commit is contained in:
commit
7588418b09
@ -1943,14 +1943,10 @@ class PopupElement {
|
|||||||
// The modification date is shown in the popup instead of the creation
|
// The modification date is shown in the popup instead of the creation
|
||||||
// date if it is available and can be parsed correctly, which is
|
// date if it is available and can be parsed correctly, which is
|
||||||
// consistent with other viewers such as Adobe Acrobat.
|
// consistent with other viewers such as Adobe Acrobat.
|
||||||
this.#dateTimePromise = parent.l10n.get(
|
this.#dateTimePromise = parent.l10n.get("annotation_date_string", {
|
||||||
"annotation_date_string",
|
date: dateObject.toLocaleDateString(),
|
||||||
{
|
time: dateObject.toLocaleTimeString(),
|
||||||
date: dateObject.toLocaleDateString(),
|
});
|
||||||
time: dateObject.toLocaleTimeString(),
|
|
||||||
},
|
|
||||||
"{{date}}, {{time}}"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.trigger = elements.flatMap(e => e.getElementsToTriggerPopup());
|
this.trigger = elements.flatMap(e => e.getElementsToTriggerPopup());
|
||||||
@ -1969,7 +1965,7 @@ class PopupElement {
|
|||||||
this.#toggle();
|
this.#toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
|
||||||
// Since the popup is lazily created, we need to ensure that it'll be
|
// Since the popup is lazily created, we need to ensure that it'll be
|
||||||
// created and displayed during reference tests.
|
// created and displayed during reference tests.
|
||||||
this.#parent.popupShow.push(async () => {
|
this.#parent.popupShow.push(async () => {
|
||||||
@ -2788,7 +2784,14 @@ class AnnotationLayer {
|
|||||||
this.viewport = viewport;
|
this.viewport = viewport;
|
||||||
this.zIndex = 0;
|
this.zIndex = 0;
|
||||||
|
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
if (
|
||||||
|
typeof PDFJSDev !== "undefined" &&
|
||||||
|
PDFJSDev.test("GENERIC && !TESTING")
|
||||||
|
) {
|
||||||
|
const { NullL10n } = require("pdfjs-web/l10n_utils.js");
|
||||||
|
this.l10n ||= NullL10n;
|
||||||
|
}
|
||||||
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
|
||||||
// For testing purposes.
|
// For testing purposes.
|
||||||
Object.defineProperty(this, "showPopups", {
|
Object.defineProperty(this, "showPopups", {
|
||||||
value: async () => {
|
value: async () => {
|
||||||
@ -2820,7 +2823,7 @@ class AnnotationLayer {
|
|||||||
* @param {AnnotationLayerParameters} params
|
* @param {AnnotationLayerParameters} params
|
||||||
* @memberof AnnotationLayer
|
* @memberof AnnotationLayer
|
||||||
*/
|
*/
|
||||||
render(params) {
|
async render(params) {
|
||||||
const { annotations } = params;
|
const { annotations } = params;
|
||||||
const layer = this.div;
|
const layer = this.div;
|
||||||
setLayerDimensions(layer, this.viewport);
|
setLayerDimensions(layer, this.viewport);
|
||||||
@ -2894,6 +2897,8 @@ class AnnotationLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.#setAnnotationCanvasMap();
|
this.#setAnnotationCanvasMap();
|
||||||
|
|
||||||
|
await this.l10n.translate(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -235,9 +235,8 @@ class Rasterize {
|
|||||||
l10n,
|
l10n,
|
||||||
viewport: annotationViewport,
|
viewport: annotationViewport,
|
||||||
});
|
});
|
||||||
annotationLayer.render(parameters);
|
await annotationLayer.render(parameters);
|
||||||
await annotationLayer.showPopups();
|
await annotationLayer.showPopups();
|
||||||
await l10n.translate(div);
|
|
||||||
|
|
||||||
// Inline SVG images from text annotations.
|
// Inline SVG images from text annotations.
|
||||||
await inlineImages(div);
|
await inlineImages(div);
|
||||||
|
@ -134,7 +134,7 @@ class AnnotationLayerBuilder {
|
|||||||
viewport: viewport.clone({ dontFlip: true }),
|
viewport: viewport.clone({ dontFlip: true }),
|
||||||
});
|
});
|
||||||
|
|
||||||
this.annotationLayer.render({
|
await this.annotationLayer.render({
|
||||||
annotations,
|
annotations,
|
||||||
imageResourcesPath: this.imageResourcesPath,
|
imageResourcesPath: this.imageResourcesPath,
|
||||||
renderForms: this.renderForms,
|
renderForms: this.renderForms,
|
||||||
@ -145,7 +145,6 @@ class AnnotationLayerBuilder {
|
|||||||
hasJSActions,
|
hasJSActions,
|
||||||
fieldObjects,
|
fieldObjects,
|
||||||
});
|
});
|
||||||
this.l10n.translate(div);
|
|
||||||
|
|
||||||
// Ensure that interactive form elements in the annotationLayer are
|
// Ensure that interactive form elements in the annotationLayer are
|
||||||
// disabled while PresentationMode is active (see issue 12232).
|
// disabled while PresentationMode is active (see issue 12232).
|
||||||
|
@ -13,6 +13,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PLEASE NOTE: This file is currently imported in both the `web/` and
|
||||||
|
* `src/display/` folders, hence be EXTREMELY careful about
|
||||||
|
* introducing any dependencies here since that can lead to an
|
||||||
|
* unexpected/unnecessary size increase of the *built* files.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A subset of the l10n strings in the `l10n/en-US/viewer.properties` file.
|
* A subset of the l10n strings in the `l10n/en-US/viewer.properties` file.
|
||||||
*/
|
*/
|
||||||
@ -63,6 +70,8 @@ const DEFAULT_L10N_STRINGS = {
|
|||||||
unexpected_response_error: "Unexpected server response.",
|
unexpected_response_error: "Unexpected server response.",
|
||||||
rendering_error: "An error occurred while rendering the page.",
|
rendering_error: "An error occurred while rendering the page.",
|
||||||
|
|
||||||
|
annotation_date_string: "{{date}}, {{time}}",
|
||||||
|
|
||||||
printing_not_supported:
|
printing_not_supported:
|
||||||
"Warning: Printing is not fully supported by this browser.",
|
"Warning: Printing is not fully supported by this browser.",
|
||||||
printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
|
printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user