mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Move the loadPDFBug
function into PDFViewerApplication._parseHashParams
Given that this is a debug-only function we don't need to define it "globally" in the `web/app.js` file.
This commit is contained in:
parent
ba8c620e4b
commit
5fbc5ba16a
1 changed files with 15 additions and 13 deletions
28
web/app.js
28
web/app.js
|
@ -265,6 +265,18 @@ const PDFViewerApplication = {
|
|||
const { mainContainer, viewerContainer } = this.appConfig,
|
||||
params = parseQueryString(hash);
|
||||
|
||||
const loadPDFBug = async () => {
|
||||
if (this._PDFBug) {
|
||||
return;
|
||||
}
|
||||
const { PDFBug } =
|
||||
typeof PDFJSDev === "undefined"
|
||||
? await import(AppOptions.get("debuggerSrc")) // eslint-disable-line no-unsanitized/method
|
||||
: await __non_webpack_import__(AppOptions.get("debuggerSrc"));
|
||||
|
||||
this._PDFBug = PDFBug;
|
||||
};
|
||||
|
||||
if (params.get("disableworker") === "true") {
|
||||
try {
|
||||
GlobalWorkerOptions.workerSrc ||= AppOptions.get("workerSrc");
|
||||
|
@ -312,7 +324,7 @@ const PDFViewerApplication = {
|
|||
case "hover":
|
||||
viewerContainer.classList.add(`textLayer-${params.get("textlayer")}`);
|
||||
try {
|
||||
await loadPDFBug(this);
|
||||
await loadPDFBug();
|
||||
this._PDFBug.loadCSS();
|
||||
} catch (ex) {
|
||||
console.error(`_parseHashParams: "${ex.message}".`);
|
||||
|
@ -321,12 +333,11 @@ const PDFViewerApplication = {
|
|||
}
|
||||
}
|
||||
if (params.has("pdfbug")) {
|
||||
AppOptions.set("pdfBug", true);
|
||||
AppOptions.set("fontExtraProperties", true);
|
||||
AppOptions.setAll({ pdfBug: true, fontExtraProperties: true });
|
||||
|
||||
const enabled = params.get("pdfbug").split(",");
|
||||
try {
|
||||
await loadPDFBug(this);
|
||||
await loadPDFBug();
|
||||
this._PDFBug.init(mainContainer, enabled);
|
||||
} catch (ex) {
|
||||
console.error(`_parseHashParams: "${ex.message}".`);
|
||||
|
@ -2170,15 +2181,6 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
|||
};
|
||||
}
|
||||
|
||||
async function loadPDFBug(self) {
|
||||
const { PDFBug } =
|
||||
typeof PDFJSDev === "undefined"
|
||||
? await import(AppOptions.get("debuggerSrc")) // eslint-disable-line no-unsanitized/method
|
||||
: await __non_webpack_import__(AppOptions.get("debuggerSrc"));
|
||||
|
||||
self._PDFBug = PDFBug;
|
||||
}
|
||||
|
||||
function webViewerPageRender({ pageNumber }) {
|
||||
// If the page is (the most) visible when it starts rendering,
|
||||
// ensure that the page number input loading indicator is displayed.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue