mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Move the opening of PDF file attachments into the DownloadManager
-implementations
Note how the `PDFAttachmentViewer` handles PDF file attachments specially, by opening them in a new window/tab, rather than forcing them to be downloaded. This is done to improve the overall UX, since browsers in general are able to handle PDF files internally. However, for file *annotations* we're currently not attempting to do the same thing and are instead just downloading them directly. In order to unify the behaviour, without having to duplicate a lot of code, the opening of PDF file attachments is thus moved into a new `DownloadManager.openOrDownloadData` method.
This commit is contained in:
parent
fafe039849
commit
df931ef685
5 changed files with 97 additions and 61 deletions
|
@ -1982,11 +1982,11 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
|||
* @memberof FileAttachmentAnnotationElement
|
||||
*/
|
||||
_download() {
|
||||
if (!this.downloadManager) {
|
||||
warn("Download cannot be started due to unavailable download manager");
|
||||
return;
|
||||
}
|
||||
this.downloadManager.downloadData(this.content, this.filename, "");
|
||||
this.downloadManager?.openOrDownloadData(
|
||||
this.container,
|
||||
this.content,
|
||||
this.filename
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue