From 9d8325d5a805c1d8ef032778f15909edcc65b4bf Mon Sep 17 00:00:00 2001
From: the-djmaze <>
Date: Sun, 13 Feb 2022 20:01:21 +0100
Subject: [PATCH] Improved "View in separate window" with theme colors
---
dev/Html/PreviewMessage.html | 38 +++++++++++-------------------------
dev/Model/Message.js | 25 +++++++++++-------------
2 files changed, 22 insertions(+), 41 deletions(-)
diff --git a/dev/Html/PreviewMessage.html b/dev/Html/PreviewMessage.html
index 7632cf6fe..a9bbb736c 100644
--- a/dev/Html/PreviewMessage.html
+++ b/dev/Html/PreviewMessage.html
@@ -1,31 +1,24 @@
-
- {{subject}}
+
-
-
- {{subject}}
-
- {{fromCreds}}
- {{toLabel}}: {{toCreds}}
- {{ccLabel}}: {{ccCreds}}
-
- {{html}}
-
+
diff --git a/dev/Model/Message.js b/dev/Model/Message.js
index 8b2e65b0a..21fe4efe0 100644
--- a/dev/Model/Message.js
+++ b/dev/Model/Message.js
@@ -491,21 +491,18 @@ export class MessageModel extends AbstractModel {
ccLine = this.ccToLine(false),
m = 0 < timeStampInUTC ? new Date(timeStampInUTC * 1000) : null,
win = open(''),
- doc = win.document;
- doc.write(PreviewHTML
- .replace(/{{subject}}/g, encodeHtml(this.subject()))
- .replace('{{date}}', encodeHtml(m ? m.format('LLL') : ''))
- .replace('{{fromCreds}}', encodeHtml(this.fromToLine(false)))
- .replace('{{toCreds}}', encodeHtml(this.toToLine(false)))
- .replace('{{toLabel}}', encodeHtml(i18n('GLOBAL/TO')))
- .replace('{{ccHide}}', ccLine ? '' : 'hidden=""')
- .replace('{{ccCreds}}', encodeHtml(ccLine))
- .replace('{{ccLabel}}', encodeHtml(i18n('GLOBAL/CC')))
- .replace('{{bodyClass}}', this.isHtml() ? 'html' : 'plain')
- .replace('{{html}}', this.bodyAsHTML())
+ sdoc = win.document;
+ let subject = encodeHtml(this.subject()),
+ mode = this.isHtml() ? 'div' : 'pre',
+ cc = ccLine ? `${encodeHtml(i18n('GLOBAL/CC'))}: ${encodeHtml(ccLine)}
` : '',
+ style = getComputedStyle(doc.querySelector('.messageView')),
+ prop = property => style.getPropertyValue(property);
+ sdoc.write(PreviewHTML
+ .replace('', ''+subject)
+ // eslint-disable-next-line max-len
+ .replace('', `${subject}
${encodeHtml(this.fromToLine(false))}
${encodeHtml(i18n('GLOBAL/TO'))}: ${encodeHtml(this.toToLine(false))}
${cc}<${mode}>${this.bodyAsHTML()}${mode}>`)
);
-
- doc.close();
+ sdoc.close();
if (print) {
setTimeout(() => win.print(), 100);