Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/app/mailviewer/singlemailviewer.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,15 @@ describe('SingleMailViewerComponent', () => {
expect(component.mailObj.attachments[1].downloadURL.indexOf('blob:')).toBe(0);
}));

it('adds avatar sizing to printed messages', () => {
const printStyles = component.printableMessageStyles();

expect(printStyles).toContain('app-avatar-bar img');
expect(printStyles).toContain('width: 32px');
expect(printStyles).toContain('max-width: 32px');
expect(printStyles).toContain('max-height: 32px');
});

describe('mailto: link interceptor', () => {
let messageContentsElement: HTMLElement;
let mailtoLink: HTMLAnchorElement;
Expand Down
22 changes: 21 additions & 1 deletion src/app/mailviewer/singlemailviewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,26 @@ export class SingleMailViewerComponent implements OnInit, DoCheck, AfterViewInit
}
}

printableMessageStyles() {
return `
<style>
app-avatar-bar > div {
display: flex;
align-items: center;
}

app-avatar-bar img {
width: 32px;
height: 32px;
max-width: 32px;
max-height: 32px;
border-radius: 32px;
object-fit: cover;
}
</style>
`;
}

print() {
// Can't access print view inside iFrame, so we need to
// temporary hide buttons while the view is rendering
Expand All @@ -713,7 +733,7 @@ export class SingleMailViewerComponent implements OnInit, DoCheck, AfterViewInit
);
}
this.printFrame.nativeElement.onload = () => this.printFrame.nativeElement.contentWindow.print();
this.printFrame.nativeElement.src = URL.createObjectURL(new Blob([printablecontent],
this.printFrame.nativeElement.src = URL.createObjectURL(new Blob([this.printableMessageStyles(), printablecontent],
{ type: 'text/html' }
)
);
Expand Down