-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support file save triggered from the Firefox integrated version. #12248
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, modulo a couple of small suggestions.
web/app.js
Outdated
@@ -874,7 +874,7 @@ const PDFViewerApplication = { | |||
); | |||
}, | |||
|
|||
download() { | |||
download(isFallback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change this to the following, to clearly mark the parameter as optional:
download(isFallback) { | |
download(isFallback = false) { |
web/download_manager.js
Outdated
* from the fallback bar. The version of PDF.js integrated with Firefox uses | ||
* this to to determine whether to show the "save as" or "open with" dialog. | ||
*/ | ||
download(blob, url, filename, isFallback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change this to the following, to clearly mark the parameter as optional:
download(blob, url, filename, isFallback) { | |
download(blob, url, filename, isFallback = false) { |
web/firefoxcom.js
Outdated
@@ -115,7 +115,7 @@ class DownloadManager { | |||
); | |||
} | |||
|
|||
download(blob, url, filename) { | |||
download(blob, url, filename, isFallback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change this to the following, to clearly mark the parameter as optional:
download(blob, url, filename, isFallback) { | |
download(blob, url, filename, isFallback = false) { |
web/app.js
Outdated
@@ -988,7 +988,7 @@ const PDFViewerApplication = { | |||
if (!download) { | |||
return; | |||
} | |||
PDFViewerApplication.download(); | |||
PDFViewerApplication.download(true /* isFallback */); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: In the code-base, this is usually formatted the following way.
PDFViewerApplication.download(true /* isFallback */); | |
PDFViewerApplication.download(/* isFallback = */ true); |
src/display/api.js
Outdated
@@ -2540,7 +2540,7 @@ class WorkerTransport { | |||
numPages: this._numPages, | |||
annotationStorage: | |||
(annotationStorage && annotationStorage.getAll()) || null, | |||
filename: this._fullReader.filename, | |||
filename: this._fullReader ? this._fullReader.filename : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
This is still a bit WIP, will update in a bit here once we decide how things should work in the bugzilla bug. |
53db555
to
6b69478
Compare
@@ -2334,16 +2335,22 @@ function webViewerPresentationMode() { | |||
function webViewerPrint() { | |||
window.print(); | |||
} | |||
function webViewerDownload() { | |||
function webViewerDownloadOrSave(sourceEventType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that this handles either calling save or download. I think the PDFViewerApplication method should do that, but let's fix that in a follow up.
@@ -1722,6 +1722,7 @@ const PDFViewerApplication = { | |||
eventBus._on("presentationmode", webViewerPresentationMode); | |||
eventBus._on("print", webViewerPrint); | |||
eventBus._on("download", webViewerDownload); | |||
eventBus._on("save", webViewerSave); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires a corresponding eventBus._off(...)
line in PDFViewerApplication.unbindEvents
below.
6b69478
to
1a5c49b
Compare
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.
1a5c49b
to
8023175
Compare
Related to https://bugzilla.mozilla.org/show_bug.cgi?id=1659753
This allows Firefox trigger a "download" 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 set an
isFallback
flag on downloads triggered from thefallback bar so Firefox can keep launching the "open with" dialog instead
of the "save as" dialog.