Skip to content

Commit

Permalink
[api-minor] Re-factor the PDFScriptingManager class to use private …
Browse files Browse the repository at this point in the history
…fields/methods

 - Change (most) fields/methods into private ones, since that's now supported.
 - Tweak the constructor-parameters, and simplify the sandbox initialization w.r.t. the viewer components.
 - Remove some unused function/method parameters.
 - Slightly simplify the "updatefromsandbox"-handler by using local variables and inverting some conditions.
  • Loading branch information
Snuffleupagus committed Jun 20, 2023
1 parent ef240b6 commit 45ab503
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 180 deletions.
4 changes: 2 additions & 2 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,8 @@ const PDFViewerApplication = {
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC || CHROME")
? AppOptions.get("sandboxBundleSrc")
: null,
scriptingFactory: externalServices,
docPropertiesLookup: this._scriptingDocProperties.bind(this),
externalServices,
docProperties: this._scriptingDocProperties.bind(this),
});
this.pdfScriptingManager = pdfScriptingManager;

Expand Down
4 changes: 2 additions & 2 deletions web/generic_scripting.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import { getPdfFilenameFromUrl, loadScript } from "pdfjs-lib";

async function docPropertiesLookup(pdfDocument) {
async function docProperties(pdfDocument) {
const url = "",
baseUrl = url.split("#")[0];
// eslint-disable-next-line prefer-const
Expand Down Expand Up @@ -65,4 +65,4 @@ class GenericScripting {
}
}

export { docPropertiesLookup, GenericScripting };
export { docProperties, GenericScripting };
Loading

0 comments on commit 45ab503

Please sign in to comment.