Merge pull request #17592 from Snuffleupagus/viewer-generate-fileInput

[GENERIC viewer] Generate the `fileInput` DOM-element dynamically
This commit is contained in:
Tim van der Meij 2024-01-28 18:11:21 +01:00 committed by GitHub
commit 2e2127cbb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 6 additions and 20 deletions

View File

@ -602,8 +602,12 @@ const PDFViewerApplication = {
}
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
const fileInput = appConfig.openFileInput;
const fileInput = (this._openFileInput = document.createElement("input"));
fileInput.id = "fileInput";
fileInput.hidden = true;
fileInput.type = "file";
fileInput.value = null;
document.body.append(fileInput);
fileInput.addEventListener("change", function (evt) {
const { files } = evt.target;
@ -2383,8 +2387,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
// eslint-disable-next-line no-var
var webViewerOpenFile = function (evt) {
const fileInput = PDFViewerApplication.appConfig.openFileInput;
fileInput.click();
PDFViewerApplication._openFileInput?.click();
};
}

View File

@ -123,10 +123,5 @@ See https://github.com/adobe-type-tools/cmap-resources
</div> <!-- outerContainer -->
<div id="printContainer"></div>
<!--#if !MOZCENTRAL-->
<input type="file" id="fileInput" class="hidden">
<!--#endif-->
</body>
</html>

View File

@ -57,10 +57,6 @@ function getViewerConfiguration() {
cancelButton: document.getElementById("passwordCancel"),
},
printContainer: document.getElementById("printContainer"),
openFileInput:
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")
? document.getElementById("fileInput")
: null,
};
}

View File

@ -565,9 +565,5 @@ See https://github.com/adobe-type-tools/cmap-resources
</div> <!-- outerContainer -->
<div id="printContainer"></div>
<!--#if GENERIC-->
<input type="file" id="fileInput" class="hidden">
<!--#endif-->
</body>
</html>

View File

@ -177,10 +177,6 @@ function getViewerConfiguration() {
),
},
printContainer: document.getElementById("printContainer"),
openFileInput:
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")
? document.getElementById("fileInput")
: null,
debuggerScriptPath: "./debugger.mjs",
};
}