Skip to content

Commit

Permalink
Use embed for PDFs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfbacon committed Nov 13, 2023
1 parent d1e9302 commit 6693f14
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions webmail/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ const dom = {
ul: (...l: ElemArg[]) => _domKids(document.createElement('ul'), l),
li: (...l: ElemArg[]) => _domKids(document.createElement('li'), l),
iframe: (...l: ElemArg[]) => _domKids(document.createElement('iframe'), l),
embed: (...l: ElemArg[]) => _domKids(document.createElement('embed'), l),
b: (...l: ElemArg[]) => _domKids(document.createElement('b'), l),
img: (...l: ElemArg[]) => _domKids(document.createElement('img'), l),
style: (...l: ElemArg[]) => _domKids(document.createElement('style'), l),
Expand Down
1 change: 1 addition & 0 deletions webmail/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ const [dom, style, attr, prop] = (function () {
ul: (...l) => _domKids(document.createElement('ul'), l),
li: (...l) => _domKids(document.createElement('li'), l),
iframe: (...l) => _domKids(document.createElement('iframe'), l),
embed: (...l) => _domKids(document.createElement('embed'), l),
b: (...l) => _domKids(document.createElement('b'), l),
img: (...l) => _domKids(document.createElement('img'), l),
style: (...l) => _domKids(document.createElement('style'), l),
Expand Down
3 changes: 2 additions & 1 deletion webmail/webmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ const [dom, style, attr, prop] = (function () {
ul: (...l) => _domKids(document.createElement('ul'), l),
li: (...l) => _domKids(document.createElement('li'), l),
iframe: (...l) => _domKids(document.createElement('iframe'), l),
embed: (...l) => _domKids(document.createElement('embed'), l),
b: (...l) => _domKids(document.createElement('b'), l),
img: (...l) => _domKids(document.createElement('img'), l),
style: (...l) => _domKids(document.createElement('style'), l),
Expand Down Expand Up @@ -2973,7 +2974,7 @@ const newMsgView = (miv, msglistView, listMailboxes, possibleLabels, messageLoad
}, style({ backgroundColor: 'white', borderRadius: '.25em', boxShadow: '0 0 20px rgba(0, 0, 0, 0.1)', border: '1px solid #ddd' }), a.Filename || '(unnamed)', ' - ', formatSize(a.Part.DecodedSize), ' - ', dom.a('Download', attr.download(''), attr.href('msg/' + m.ID + '/download/' + pathStr), function click(e) { e.stopPropagation(); }))), isImage(a) ?
dom.div(style({ flexGrow: 1, display: 'flex', alignItems: 'center', justifyContent: 'center', maxHeight: 'calc(100% - 50px)', margin: '0 5em' }), dom.img(attr.src('msg/' + m.ID + '/view/' + pathStr), style({ backgroundColor: 'white', maxWidth: '100%', maxHeight: '100%', boxShadow: '0 0 20px rgba(0, 0, 0, 0.1)', margin: '0 30px' }))) : (isText(a) ?
dom.iframe(attr.title('Attachment shown as text.'), style({ flexGrow: 1, boxShadow: '0 0 20px rgba(0, 0, 0, 0.1)', backgroundColor: 'white', margin: '0 5em' }), attr.src('msg/' + m.ID + '/viewtext/' + pathStr)) : (isPDF(a) ?
dom.iframe(style({ flexGrow: 1, boxShadow: '0 0 20px rgba(0, 0, 0, 0.1)', backgroundColor: 'white', margin: '0 5em' }), attr.title('Attachment as PDF.'), attr.src('msg/' + m.ID + '/view/' + pathStr)) :
dom.embed(style({ flexGrow: 1, boxShadow: '0 0 20px rgba(0, 0, 0, 0.1)', backgroundColor: 'white', margin: '0 5em' }), attr.title('Attachment as PDF.'), attr.src('msg/' + m.ID + '/view/' + pathStr)) :
content = dom.div(function click(e) {
e.stopPropagation();
}, style({ minWidth: '30em', padding: '2ex', boxShadow: '0 0 20px rgba(0, 0, 0, 0.1)', backgroundColor: 'white', margin: '0 5em', textAlign: 'center' }), dom.div(style({ marginBottom: '2ex' }), 'Attachment could be a binary file.'), dom.clickbutton('View as text', function click() {
Expand Down
2 changes: 1 addition & 1 deletion webmail/webmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2563,7 +2563,7 @@ const newMsgView = (miv: MsgitemView, msglistView: MsglistView, listMailboxes: l
attr.src('msg/'+m.ID+'/viewtext/'+pathStr)
) : (
isPDF(a) ?
dom.iframe(
dom.embed(
style({flexGrow: 1, boxShadow: '0 0 20px rgba(0, 0, 0, 0.1)', backgroundColor: 'white', margin: '0 5em'}),
attr.title('Attachment as PDF.'),
attr.src('msg/'+m.ID+'/view/'+pathStr)
Expand Down

0 comments on commit 6693f14

Please sign in to comment.