Merge pull request #13113 from Snuffleupagus/scripting-PresentationMode-events

Ignore some *scripting* events which don't make sense in PresentationMode
This commit is contained in:
Tim van der Meij 2021-03-19 22:52:15 +01:00 committed by GitHub
commit e7e0ecf9c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {
@ -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 }));
@ -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");