mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
[api-minor] Ensure that the AnnotationLayer
gets a default l10n-instance in GENERIC builds (PR 16552 follow-up)
*This is something that I completely overlooked during review of PR 16552, despite leaving a l10n-related comment.* The new l10n-handling of PopupAnnotations assume that the `AnnotationLayer` is always initialized with a l10n-instance, which might not actually be the case in third-party implementations where the default viewer isn't used. To work-around that we'll now bundle, and fallback on, the existing `NullL10n`-implementation in GENERIC builds of the PDF.js library. This will only result in a slight file-size increase for the *built* `pdf.js` file, again limited to GENERIC builds, since the `web/l10n_utils.js` file has no dependencies. Also, tweaks a couple of TESTING pre-processor checks to *only* include that code when running the reference tests.
This commit is contained in:
parent
a656d71959
commit
197e806c86
2 changed files with 22 additions and 10 deletions
|
@ -1943,14 +1943,10 @@ class PopupElement {
|
|||
// The modification date is shown in the popup instead of the creation
|
||||
// date if it is available and can be parsed correctly, which is
|
||||
// consistent with other viewers such as Adobe Acrobat.
|
||||
this.#dateTimePromise = parent.l10n.get(
|
||||
"annotation_date_string",
|
||||
{
|
||||
date: dateObject.toLocaleDateString(),
|
||||
time: dateObject.toLocaleTimeString(),
|
||||
},
|
||||
"{{date}}, {{time}}"
|
||||
);
|
||||
this.#dateTimePromise = parent.l10n.get("annotation_date_string", {
|
||||
date: dateObject.toLocaleDateString(),
|
||||
time: dateObject.toLocaleTimeString(),
|
||||
});
|
||||
}
|
||||
|
||||
this.trigger = elements.flatMap(e => e.getElementsToTriggerPopup());
|
||||
|
@ -1969,7 +1965,7 @@ class PopupElement {
|
|||
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
|
||||
// created and displayed during reference tests.
|
||||
this.#parent.popupShow.push(async () => {
|
||||
|
@ -2788,7 +2784,14 @@ class AnnotationLayer {
|
|||
this.viewport = viewport;
|
||||
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.
|
||||
Object.defineProperty(this, "showPopups", {
|
||||
value: async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue