mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-01 03:27:43 +08:00
Clean message preview/print
This commit is contained in:
parent
c3a2da65df
commit
2bd9528098
3 changed files with 50 additions and 110 deletions
|
@ -80,14 +80,6 @@ function splitPlainText(text, len = 100) {
|
|||
return prefix + result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} m
|
||||
* @returns {any}
|
||||
*/
|
||||
export function deModule(m) {
|
||||
return (m && m.default ? m.default : m) || '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
|
|
|
@ -2,110 +2,61 @@
|
|||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="user-scalable=no" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="robots" content="noindex, nofollow, noodp" />
|
||||
<title>{{title}}</title>
|
||||
<title>{{subject}}</title>
|
||||
<style>
|
||||
html, body {
|
||||
background-color: #fff;
|
||||
color: #000;
|
||||
font-size: 13px;
|
||||
font-family: arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
a {color: blue; text-decoration: underline}
|
||||
a:visited {color: #609}
|
||||
a:active {color: red}
|
||||
blockquote {border-left: 2px solid black; margin: 0; padding: 0px 10px}
|
||||
header {
|
||||
background: #eee;
|
||||
border-bottom: 1px solid #ccc;
|
||||
padding: 0 15px;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
background: #fff;
|
||||
border: none;
|
||||
header h1 {
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
header * {
|
||||
font-size: 12px;
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
header time {
|
||||
float: right;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
border-left: 2px solid black;
|
||||
margin: 0;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
pre, .body-wrp.plain {
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
.body-wrp {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.body-wrp.html pre {
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
.body-wrp.plain {
|
||||
padding: 15px;
|
||||
white-space: pre-wrap;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
}
|
||||
|
||||
.body-wrp.plain pre {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
background: #fff;
|
||||
border: none;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
.body-wrp.plain blockquote {
|
||||
border-left: 2px solid blue;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.body-wrp.plain blockquote blockquote {
|
||||
border-left: 2px solid green;
|
||||
color: green;
|
||||
}
|
||||
|
||||
.body-wrp.plain blockquote blockquote blockquote {
|
||||
border-left: 2px solid red;
|
||||
color: red;
|
||||
}
|
||||
.rl-preview-subject {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
padding: 15px;
|
||||
}
|
||||
.rl-preview-creds-from, .rl-preview-creds-to, .rl-preview-creds-cc {
|
||||
font-size: 12px;
|
||||
padding: 5px 15px;
|
||||
}
|
||||
.rl-preview-date {
|
||||
float: right;
|
||||
font-size: 12px;
|
||||
padding: 10px 15px;
|
||||
}
|
||||
.rl-preview-section {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
.rl-preview-hide {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="rl-preview-section">
|
||||
<div class="rl-preview-subject">{{subject}}</div>
|
||||
</div>
|
||||
<div class="rl-preview-section">
|
||||
<div class="rl-preview-date">{{date}}</div>
|
||||
<div class="rl-preview-creds-from">{{fromCreds}}</div>
|
||||
<div class="rl-preview-creds-to">{{toLabel}}: {{toCreds}}</div>
|
||||
<div class="rl-preview-creds-cc {{ccClass}}">{{ccLabel}}: {{ccCreds}}</div>
|
||||
</div>
|
||||
<header>
|
||||
<h1>{{subject}}</h1>
|
||||
<time>{{date}}</time>
|
||||
<div>{{fromCreds}}</div>
|
||||
<div>{{toLabel}}: {{toCreds}}</div>
|
||||
<div {{ccHide}}>{{ccLabel}}: {{ccCreds}}</div>
|
||||
</header>
|
||||
<div class="body-wrp {{bodyClass}}">{{html}}</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -5,7 +5,6 @@ import { i18n } from 'Common/Translator';
|
|||
|
||||
import {
|
||||
pInt,
|
||||
deModule,
|
||||
encodeHtml,
|
||||
friendlySize
|
||||
} from 'Common/Utils';
|
||||
|
@ -518,21 +517,19 @@ class MessageModel extends AbstractModel {
|
|||
ccLine = this.ccToLine(false),
|
||||
m = 0 < timeStampInUTC ? new Date(timeStampInUTC * 1000) : null,
|
||||
win = open(''),
|
||||
doc = win.document;
|
||||
|
||||
doc.write(
|
||||
deModule(require('Html/PreviewMessage.html'))
|
||||
.replace('{{title}}', encodeHtml(this.subject()))
|
||||
.replace('{{subject}}', 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('MESSAGE/LABEL_TO')))
|
||||
.replace('{{ccClass}}', encodeHtml(ccLine ? '' : 'rl-preview-hide'))
|
||||
.replace('{{ccCreds}}', encodeHtml(ccLine))
|
||||
.replace('{{ccLabel}}', encodeHtml(i18n('MESSAGE/LABEL_CC')))
|
||||
.replace('{{bodyClass}}', this.isHtml() ? 'html' : 'plain')
|
||||
.replace('{{html}}', this.bodyAsHTML())
|
||||
doc = win.document,
|
||||
html = require('Html/PreviewMessage.html');
|
||||
doc.write((html.default)
|
||||
.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('MESSAGE/LABEL_TO')))
|
||||
.replace('{{ccHide}}', ccLine ? '' : 'hidden=""')
|
||||
.replace('{{ccCreds}}', encodeHtml(ccLine))
|
||||
.replace('{{ccLabel}}', encodeHtml(i18n('MESSAGE/LABEL_CC')))
|
||||
.replace('{{bodyClass}}', this.isHtml() ? 'html' : 'plain')
|
||||
.replace('{{html}}', this.bodyAsHTML())
|
||||
);
|
||||
|
||||
doc.close();
|
||||
|
|
Loading…
Reference in a new issue