Skip to content

Ignore some *scripting* events which don't make sense in PresentationMode #13113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions web/pdf_scripting_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ class PDFScriptingManager {
* @private
*/
async _updateFromSandbox(detail) {
// Ignore some events, see below, that don't make sense in PresentationMode.
const isInPresentationMode =
this._pdfViewer.isInPresentationMode ||
this._pdfViewer.isChangingPresentationMode;

const { id, command, value } = detail;
if (!id) {
switch (command) {
Expand All @@ -284,12 +289,21 @@ class PDFScriptingManager {
console.log(value);
break;
case "zoom":
if (isInPresentationMode) {
return;
}
this._pdfViewer.currentScaleValue = value;
break;
}
return;
}

if (isInPresentationMode) {
if (detail.focus) {
return;
}
}

const element = document.getElementById(id);
if (element) {
element.dispatchEvent(new CustomEvent("updatefromsandbox", { detail }));
Expand Down Expand Up @@ -382,11 +396,9 @@ class PDFScriptingManager {
* @private
*/
async _getDocProperties() {
// The default viewer use-case.
if (this._docPropertiesLookup) {
return this._docPropertiesLookup(this._pdfDocument);
}
// Fallback, to support the viewer components use-case.
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("COMPONENTS")) {
const { docPropertiesLookup } = require("./generic_scripting.js");

Expand Down