@pallasoft/ps-utilities 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/constants/email-preview-config.d.ts +2 -1
- package/dist/common/constants/email-preview-config.js +2 -1
- package/dist/common/email-preview-service.d.ts +1 -0
- package/dist/common/email-preview-service.js +6 -2
- package/dist/models/email-preview-input.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ export declare const EmailPreviewConfig: {
|
|
|
4
4
|
readonly imageName: "email.png";
|
|
5
5
|
readonly imageContentType: "image/png";
|
|
6
6
|
readonly fallbackSubject: "Email";
|
|
7
|
+
readonly dateFormat: "D MMM YYYY, h:mm A";
|
|
7
8
|
readonly page: {
|
|
8
9
|
readonly width: 860;
|
|
9
10
|
readonly padding: 48;
|
|
@@ -13,7 +14,7 @@ export declare const EmailPreviewConfig: {
|
|
|
13
14
|
readonly bodySize: 15;
|
|
14
15
|
readonly lineHeight: 24;
|
|
15
16
|
readonly maxLines: 140;
|
|
16
|
-
readonly minHeight:
|
|
17
|
+
readonly minHeight: 320;
|
|
17
18
|
readonly charWidth: 7.4;
|
|
18
19
|
readonly subjectWidthRatio: 1.45;
|
|
19
20
|
readonly metaWidthRatio: 0.9;
|
|
@@ -7,6 +7,7 @@ exports.EmailPreviewConfig = {
|
|
|
7
7
|
imageName: 'email.png',
|
|
8
8
|
imageContentType: 'image/png',
|
|
9
9
|
fallbackSubject: 'Email',
|
|
10
|
+
dateFormat: 'D MMM YYYY, h:mm A',
|
|
10
11
|
page: {
|
|
11
12
|
width: 860,
|
|
12
13
|
padding: 48,
|
|
@@ -16,7 +17,7 @@ exports.EmailPreviewConfig = {
|
|
|
16
17
|
bodySize: 15,
|
|
17
18
|
lineHeight: 24,
|
|
18
19
|
maxLines: 140,
|
|
19
|
-
minHeight:
|
|
20
|
+
minHeight: 320,
|
|
20
21
|
charWidth: 7.4,
|
|
21
22
|
subjectWidthRatio: 1.45,
|
|
22
23
|
metaWidthRatio: 0.9,
|
|
@@ -2,6 +2,7 @@ import type { EmailPreviewInput } from '../models/email-preview-input';
|
|
|
2
2
|
export declare class EmailPreviewService {
|
|
3
3
|
static escape(value: string): string;
|
|
4
4
|
static hasContent(input: EmailPreviewInput): boolean;
|
|
5
|
+
static receivedOf(input: EmailPreviewInput): string;
|
|
5
6
|
static subjectOf(input: EmailPreviewInput): string;
|
|
6
7
|
static toText(input: EmailPreviewInput): string;
|
|
7
8
|
static toDocument(input: EmailPreviewInput): string;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EmailPreviewService = void 0;
|
|
4
4
|
var email_preview_config_1 = require("./constants/email-preview-config");
|
|
5
|
+
var date_service_1 = require("./date-service");
|
|
5
6
|
var EmailPreviewService = /** @class */ (function () {
|
|
6
7
|
function EmailPreviewService() {
|
|
7
8
|
}
|
|
@@ -17,6 +18,9 @@ var EmailPreviewService = /** @class */ (function () {
|
|
|
17
18
|
return ((input.html !== null && input.html.trim() !== '') ||
|
|
18
19
|
(input.text !== null && input.text.trim() !== ''));
|
|
19
20
|
};
|
|
21
|
+
EmailPreviewService.receivedOf = function (input) {
|
|
22
|
+
return date_service_1.DateService.formatDateInTimezone(input.receivedAt, input.timezone, email_preview_config_1.EmailPreviewConfig.dateFormat);
|
|
23
|
+
};
|
|
20
24
|
EmailPreviewService.subjectOf = function (input) {
|
|
21
25
|
return input.subject === null || input.subject.trim() === ''
|
|
22
26
|
? email_preview_config_1.EmailPreviewConfig.fallbackSubject
|
|
@@ -34,13 +38,13 @@ var EmailPreviewService = /** @class */ (function () {
|
|
|
34
38
|
var body = input.html !== null && input.html.trim() !== ''
|
|
35
39
|
? EmailPreviewService.body(input.html)
|
|
36
40
|
: "<pre style=\"white-space:pre-wrap;font-family:inherit;margin:0;\">".concat(EmailPreviewService.escape(input.text === null ? '' : input.text), "</pre>");
|
|
37
|
-
return "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<title>".concat(EmailPreviewService.escape(subject), "</title>\n\t</head>\n\t<body style=\"margin:0;padding:24px;background:#f5f7fa;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;color:#101828;\">\n\t\t<div style=\"max-width:760px;margin:0 auto;background:#ffffff;border:1px solid #e4e8ee;border-radius:12px;overflow:hidden;\">\n\t\t\t<div style=\"padding:16px 20px;border-bottom:1px solid #e4e8ee;background:#f9fafb;\">\n\t\t\t\t<div style=\"font-size:15px;font-weight:700;\">").concat(EmailPreviewService.escape(subject), "</div>\n\t\t\t\t<div style=\"margin-top:4px;font-size:12px;color:#667085;\">From ").concat(EmailPreviewService.escape(input.from), " \u00B7 ").concat(EmailPreviewService.escape(input
|
|
41
|
+
return "<!doctype html>\n<html lang=\"en\">\n\t<head>\n\t\t<meta charset=\"utf-8\" />\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t\t<title>".concat(EmailPreviewService.escape(subject), "</title>\n\t</head>\n\t<body style=\"margin:0;padding:24px;background:#f5f7fa;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;color:#101828;\">\n\t\t<div style=\"max-width:760px;margin:0 auto;background:#ffffff;border:1px solid #e4e8ee;border-radius:12px;overflow:hidden;\">\n\t\t\t<div style=\"padding:16px 20px;border-bottom:1px solid #e4e8ee;background:#f9fafb;\">\n\t\t\t\t<div style=\"font-size:15px;font-weight:700;\">").concat(EmailPreviewService.escape(subject), "</div>\n\t\t\t\t<div style=\"margin-top:4px;font-size:12px;color:#667085;\">From ").concat(EmailPreviewService.escape(input.from), " \u00B7 ").concat(EmailPreviewService.escape(EmailPreviewService.receivedOf(input)), "</div>\n\t\t\t</div>\n\t\t\t<div style=\"padding:20px;\">").concat(body, "</div>\n\t\t</div>\n\t</body>\n</html>");
|
|
38
42
|
};
|
|
39
43
|
EmailPreviewService.toImageMarkup = function (input) {
|
|
40
44
|
var page = email_preview_config_1.EmailPreviewConfig.page;
|
|
41
45
|
var width = page.width - page.padding * 2;
|
|
42
46
|
var subject = EmailPreviewService.clip(EmailPreviewService.subjectOf(input), Math.floor(width / (page.charWidth * page.subjectWidthRatio)));
|
|
43
|
-
var meta = EmailPreviewService.clip("From ".concat(input.from, " \u00B7 ").concat(input
|
|
47
|
+
var meta = EmailPreviewService.clip("From ".concat(input.from, " \u00B7 ").concat(EmailPreviewService.receivedOf(input)), Math.floor(width / (page.charWidth * page.metaWidthRatio)));
|
|
44
48
|
var lines = EmailPreviewService.wrap(EmailPreviewService.toText(input), Math.floor(width / page.charWidth)).slice(0, page.maxLines);
|
|
45
49
|
var metaBaseline = page.padding + page.subjectSize + 10 + page.metaSize;
|
|
46
50
|
var bodyTop = metaBaseline + page.headerGap;
|