mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
open PDF in new window using built-in browser viewer
This commit is contained in:
parent
303e70bb58
commit
24ec89c220
@ -109,8 +109,10 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
|
|||||||
let blob: Blob = null;
|
let blob: Blob = null;
|
||||||
let type: string = null;
|
let type: string = null;
|
||||||
const fileNameLower = fileName.toLowerCase();
|
const fileNameLower = fileName.toLowerCase();
|
||||||
|
let doDownload = true;
|
||||||
if (fileNameLower.endsWith('.pdf')) {
|
if (fileNameLower.endsWith('.pdf')) {
|
||||||
type = 'application/pdf';
|
type = 'application/pdf';
|
||||||
|
doDownload = false;
|
||||||
} else if (fileNameLower.endsWith('.xlsx')) {
|
} else if (fileNameLower.endsWith('.xlsx')) {
|
||||||
type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
||||||
} else if (fileNameLower.endsWith('.docx')) {
|
} else if (fileNameLower.endsWith('.docx')) {
|
||||||
@ -141,10 +143,13 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
|
|||||||
navigator.msSaveBlob(blob, fileName);
|
navigator.msSaveBlob(blob, fileName);
|
||||||
} else {
|
} else {
|
||||||
const a = win.document.createElement('a');
|
const a = win.document.createElement('a');
|
||||||
|
if (doDownload) {
|
||||||
|
a.download = fileName;
|
||||||
|
} else {
|
||||||
|
a.target = '_blank';
|
||||||
|
}
|
||||||
a.href = win.URL.createObjectURL(blob);
|
a.href = win.URL.createObjectURL(blob);
|
||||||
a.download = fileName;
|
|
||||||
a.style.position = 'fixed';
|
a.style.position = 'fixed';
|
||||||
a.target = '_blank';
|
|
||||||
win.document.body.appendChild(a);
|
win.document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
win.document.body.removeChild(a);
|
win.document.body.removeChild(a);
|
||||||
|
Loading…
Reference in New Issue
Block a user