mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Support file save triggered from the Firefox integrated version.
Related to https://bugzilla.mozilla.org/show_bug.cgi?id=1659753 This allows Firefox trigger a "save" event from ctrl/cmd+s or the "Save Page As" context menu, which in turn lets pdf.js generate a new PDF if there is form data to save. I also now use `sourceEventType` on downloads so Firefox can determine if it should launch the "open with" dialog or "save as" dialog.
This commit is contained in:
parent
10f61b8c96
commit
8023175103
4 changed files with 38 additions and 12 deletions
|
@ -115,7 +115,7 @@ class DownloadManager {
|
|||
);
|
||||
}
|
||||
|
||||
download(blob, url, filename) {
|
||||
download(blob, url, filename, sourceEventType = "download") {
|
||||
const blobUrl = URL.createObjectURL(blob);
|
||||
const onResponse = err => {
|
||||
if (err && this.onerror) {
|
||||
|
@ -130,6 +130,7 @@ class DownloadManager {
|
|||
blobUrl,
|
||||
originalUrl: url,
|
||||
filename,
|
||||
sourceEventType,
|
||||
},
|
||||
onResponse
|
||||
);
|
||||
|
@ -231,6 +232,17 @@ class MozL10n {
|
|||
}
|
||||
})();
|
||||
|
||||
(function listenSaveEvent() {
|
||||
const handleEvent = function ({ type, detail }) {
|
||||
if (!PDFViewerApplication.initialized) {
|
||||
return;
|
||||
}
|
||||
PDFViewerApplication.eventBus.dispatch(type, { source: window });
|
||||
};
|
||||
|
||||
window.addEventListener("save", handleEvent);
|
||||
})();
|
||||
|
||||
class FirefoxComDataRangeTransport extends PDFDataRangeTransport {
|
||||
requestDataRange(begin, end) {
|
||||
FirefoxCom.request("requestDataRange", { begin, end });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue