Ignore some *scripting* events which don't make sense in PresentationMode
A number of the currently supported *scripting* events only make sense in the "normal" viewer mode, and not when PresentationMode is active. For example: - Changing the zoom-level will outright break rendering in PresentationMode, since it relies on "page-fit" being used. - Focusing a particular (AcroForm) element won't work, and could break keyboard navigation, since forms should not be editable in PresentationMode (see issue 12232).
This commit is contained in:
		
							parent
							
								
									57e7557235
								
							
						
					
					
						commit
						1fa5ce7f48
					
				@ -261,6 +261,11 @@ class PDFScriptingManager {
 | 
				
			|||||||
   * @private
 | 
					   * @private
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  async _updateFromSandbox(detail) {
 | 
					  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;
 | 
					    const { id, command, value } = detail;
 | 
				
			||||||
    if (!id) {
 | 
					    if (!id) {
 | 
				
			||||||
      switch (command) {
 | 
					      switch (command) {
 | 
				
			||||||
@ -284,12 +289,21 @@ class PDFScriptingManager {
 | 
				
			|||||||
          console.log(value);
 | 
					          console.log(value);
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
        case "zoom":
 | 
					        case "zoom":
 | 
				
			||||||
 | 
					          if (isInPresentationMode) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
          this._pdfViewer.currentScaleValue = value;
 | 
					          this._pdfViewer.currentScaleValue = value;
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (isInPresentationMode) {
 | 
				
			||||||
 | 
					      if (detail.focus) {
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const element = document.getElementById(id);
 | 
					    const element = document.getElementById(id);
 | 
				
			||||||
    if (element) {
 | 
					    if (element) {
 | 
				
			||||||
      element.dispatchEvent(new CustomEvent("updatefromsandbox", { detail }));
 | 
					      element.dispatchEvent(new CustomEvent("updatefromsandbox", { detail }));
 | 
				
			||||||
@ -382,11 +396,9 @@ class PDFScriptingManager {
 | 
				
			|||||||
   * @private
 | 
					   * @private
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  async _getDocProperties() {
 | 
					  async _getDocProperties() {
 | 
				
			||||||
    // The default viewer use-case.
 | 
					 | 
				
			||||||
    if (this._docPropertiesLookup) {
 | 
					    if (this._docPropertiesLookup) {
 | 
				
			||||||
      return this._docPropertiesLookup(this._pdfDocument);
 | 
					      return this._docPropertiesLookup(this._pdfDocument);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // Fallback, to support the viewer components use-case.
 | 
					 | 
				
			||||||
    if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("COMPONENTS")) {
 | 
					    if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("COMPONENTS")) {
 | 
				
			||||||
      const { docPropertiesLookup } = require("./generic_scripting.js");
 | 
					      const { docPropertiesLookup } = require("./generic_scripting.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user