Skip to content

Commit

Permalink
deps: upgrade pdf.js to 3.11.174
Browse files Browse the repository at this point in the history
  • Loading branch information
Priestch committed Nov 22, 2023
1 parent 78a679b commit ad81c6a
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/document-viewer/pdf.js
Submodule pdf.js updated 124 files
15 changes: 13 additions & 2 deletions packages/document-viewer/src/app_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,11 @@ function createHelper(PDFViewerApplication) {
// Only zoom the pages, not the entire viewer.
evt.preventDefault();
// NOTE: this check must be placed *after* preventDefault.
if (zoomDisabledTimeout || document.visibilityState === "hidden") {
if (
zoomDisabledTimeout ||
document.visibilityState === "hidden" ||
PDFViewerApplication.overlayManager.active
) {
return;
}
const previousScale = pdfViewer.currentScale;
Expand Down Expand Up @@ -560,7 +564,10 @@ function createHelper(PDFViewerApplication) {
return;
}
evt.preventDefault();
if (evt.touches.length !== 2) {
if (
evt.touches.length !== 2 ||
PDFViewerApplication.overlayManager.active
) {
PDFViewerApplication._touchInfo = null;
return;
}
Expand Down Expand Up @@ -1043,6 +1050,9 @@ function createHelper(PDFViewerApplication) {
function webViewerAnnotationEditorStatesChanged(data) {
PDFViewerApplication.externalServices.updateEditorStates(data);
}
function webViewerReportTelemetry({ details }) {
PDFViewerApplication.externalServices.reportTelemetry(details);
}

/* Abstract factory for the print service. */
return {
Expand Down Expand Up @@ -1104,6 +1114,7 @@ function createHelper(PDFViewerApplication) {
beforeUnload: beforeUnload,
webViewerAnnotationEditorStatesChanged:
webViewerAnnotationEditorStatesChanged,
webViewerReportTelemetry: webViewerReportTelemetry,
};
}
export { createHelper };
8 changes: 8 additions & 0 deletions packages/document-viewer/src/app_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ function getViewerConfiguration(el) {
linearized: el.querySelector("[data-dom-id='linearizedField']"),
},
},
altTextDialog: {
dialog: el.querySelector("[data-dom-id='altTextDialog']"),
optionDescription: el.querySelector("[data-dom-id='descriptionButton']"),
optionDecorative: el.querySelector("[data-dom-id='decorativeButton']"),
textarea: el.querySelector("[data-dom-id='descriptionTextarea']"),
cancelButton: el.querySelector("[data-dom-id='altTextCancel']"),
saveButton: el.querySelector("[data-dom-id='altTextSave']"),
},
annotationEditorParams: {
editorFreeTextFontSize: el.querySelector("[data-dom-id='editorFreeTextFontSize']"),
editorFreeTextColor: el.querySelector("[data-dom-id='editorFreeTextColor']"),
Expand Down
17 changes: 10 additions & 7 deletions packages/document-viewer/src/default_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
import { AppOptions, OptionKind } from "../pdf.js/web/app_options.js";
import { AutomationEventBus, EventBus } from "../pdf.js/web/event_utils.js";
import { LinkTarget, PDFLinkService } from "../pdf.js/web/pdf_link_service.js";
import { AltTextManager } from "web-alt_text_manager";
import { AnnotationEditorParams } from "web-annotation_editor_params";
import { OverlayManager } from "../pdf.js/web/overlay_manager.js";
import { PasswordPrompt } from "../pdf.js/web/password_prompt.js";
Expand Down Expand Up @@ -400,13 +401,17 @@ class ViewerApplication {
foreground: AppOptions.get("pageColorsForeground"),
}
: null;
const altTextManager = appConfig.altTextDialog
? new AltTextManager(appConfig.altTextDialog, container, this.overlayManager, eventBus)
: null;
const pdfViewer = new PDFViewer({
container,
viewer,
eventBus,
renderingQueue: pdfRenderingQueue,
linkService: pdfLinkService,
downloadManager,
altTextManager,
findController,
scriptingManager: AppOptions.get("enableScripting") && pdfScriptingManager,
l10n,
Expand Down Expand Up @@ -488,19 +493,14 @@ class ViewerApplication {
appConfig.toolbar,
eventBus,
l10n,
await this._nimbusDataPromise,
externalServices
await this._nimbusDataPromise
);
} else {
this.toolbar = new Toolbar(appConfig.toolbar, eventBus, l10n);
}
}
if (appConfig.secondaryToolbar) {
this.secondaryToolbar = new SecondaryToolbar(
appConfig.secondaryToolbar,
eventBus,
externalServices
);
this.secondaryToolbar = new SecondaryToolbar(appConfig.secondaryToolbar, eventBus);
}
if (this.supportsFullscreen && appConfig.secondaryToolbar?.presentationModeButton) {
this.pdfPresentationMode = new PDFPresentationMode({
Expand Down Expand Up @@ -1739,7 +1739,10 @@ class ViewerApplication {
eventBus._on("openfile", webViewerOpenFile);
}
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
// The `unbindEvents` method is unused in MOZCENTRAL builds,
// hence we don't need to unregister these event listeners.
eventBus._on("annotationeditorstateschanged", webViewerAnnotationEditorStatesChanged);
eventBus._on("reporttelemetry", webViewerReportTelemetry);
}
}
bindWindowEvents() {
Expand Down
105 changes: 105 additions & 0 deletions packages/document-viewer/src/viewer_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,111 @@ const template = `
</button>
</div>
</dialog>
<dialog
aria-labelledby="dialogLabel"
aria-describedby="dialogDescription"
data-dom-id="altTextDialog"
class="altTextDialog"
>
<div data-dom-id="altTextContainer" class="altTextContainer">
<div data-dom-id="overallDescription" class="overallDescription">
<span
data-l10n-id="editor_alt_text_dialog_label"
data-dom-id="dialogLabel"
class="title dialogLabel"
>Choose an option</span
><span
data-l10n-id="editor_alt_text_dialog_description"
data-dom-id="dialogDescription"
class="dialogDescription"
>
Alt text (alternative text) helps when people can’t see the image or
when it doesn’t load.
</span>
</div>
<div data-dom-id="addDescription" class="addDescription">
<div class="radio">
<div class="radioButton">
<label
><input
type="radio"
name="altTextOption"
tabindex="0"
aria-describedby="descriptionAreaLabel"
checked=""
data-dom-id="descriptionButton"
class="descriptionButton"
/><span
class="toolbarLabel"
data-l10n-id="editor_alt_text_add_description_label"
>Add a description</span
></label
><!--Removed!-->
</div>
<div class="radioLabel">
<span
data-l10n-id="editor_alt_text_add_description_description"
data-dom-id="descriptionAreaLabel"
class="descriptionAreaLabel"
>
Aim for 1-2 sentences that describe the subject, setting, or
actions.
</span>
</div>
</div>
<div class="descriptionArea">
<textarea
id="descriptionTextarea"
placeholder="For example, “A young man sits down at a table to eat a meal”"
aria-labelledby="descriptionAreaLabel"
data-l10n-id="editor_alt_text_textarea"
tabindex="0"
></textarea>
</div>
</div>
<div data-dom-id="markAsDecorative" class="markAsDecorative">
<div class="radio">
<div class="radioButton">
<label
><input
type="radio"
name="altTextOption"
aria-describedby="decorativeLabel"
data-dom-id="decorativeButton"
class="decorativeButton"
/><span
class="toolbarLabel"
data-l10n-id="editor_alt_text_mark_decorative_label"
>Mark as decorative</span
></label
><!--Removed!-->
</div>
<div class="radioLabel">
<span
data-l10n-id="editor_alt_text_mark_decorative_description"
data-dom-id="decorativeLabel"
class="decorativeLabel"
>
This is used for ornamental images, like borders or watermarks.
</span>
</div>
</div>
</div>
<div data-dom-id="buttons" class="buttons">
<button
tabindex="0"
data-dom-id="altTextCancel"
class="altTextCancel"
>
<span data-l10n-id="editor_alt_text_cancel_button"
>Cancel</span
></button
><button tabindex="0" data-dom-id="altTextSave" class="altTextSave">
<span data-l10n-id="editor_alt_text_save_button">Save</span>
</button>
</div>
</div>
</dialog>
<!--#if !MOZCENTRAL-->
<dialog
style="min-width: 200px"
Expand Down

0 comments on commit ad81c6a

Please sign in to comment.