payload-plugin-newsletter 0.18.0 → 0.20.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/CHANGELOG.md +103 -0
- package/PREVIEW_CUSTOMIZATION_TASK.md +201 -0
- package/README.md +97 -0
- package/dist/collections.cjs +177 -20
- package/dist/collections.cjs.map +1 -1
- package/dist/collections.js +177 -20
- package/dist/collections.js.map +1 -1
- package/dist/components.cjs +314 -143
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +2 -0
- package/dist/components.d.ts +2 -0
- package/dist/components.js +251 -80
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +201 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +198 -20
- package/dist/index.js.map +1 -1
- package/dist/types.d.cts +23 -0
- package/dist/types.d.ts +23 -0
- package/dist/utils.cjs +172 -18
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +5 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +172 -18
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/components.js
CHANGED
|
@@ -920,6 +920,12 @@ async function convertToEmailSafeHtml(editorState, options) {
|
|
|
920
920
|
const rawHtml = await lexicalToEmailHtml(editorState, options?.mediaUrl, options?.customBlockConverter);
|
|
921
921
|
const sanitizedHtml = DOMPurify.sanitize(rawHtml, EMAIL_SAFE_CONFIG);
|
|
922
922
|
if (options?.wrapInTemplate) {
|
|
923
|
+
if (options.customWrapper) {
|
|
924
|
+
return await Promise.resolve(options.customWrapper(sanitizedHtml, {
|
|
925
|
+
preheader: options.preheader,
|
|
926
|
+
subject: options.subject
|
|
927
|
+
}));
|
|
928
|
+
}
|
|
923
929
|
return wrapInEmailTemplate(sanitizedHtml, options.preheader);
|
|
924
930
|
}
|
|
925
931
|
return sanitizedHtml;
|
|
@@ -973,9 +979,9 @@ async function convertParagraph(node, mediaUrl, customBlockConverter) {
|
|
|
973
979
|
);
|
|
974
980
|
const children = childParts.join("");
|
|
975
981
|
if (!children.trim()) {
|
|
976
|
-
return '<p style="margin: 0 0 16px 0; min-height: 1em;"> </p>';
|
|
982
|
+
return '<p class="mobile-margin-bottom-16" style="margin: 0 0 16px 0; min-height: 1em;"> </p>';
|
|
977
983
|
}
|
|
978
|
-
return `<p style="margin: 0 0 16px 0; text-align: ${align};">${children}</p>`;
|
|
984
|
+
return `<p class="mobile-margin-bottom-16" style="margin: 0 0 16px 0; text-align: ${align}; font-size: 16px; line-height: 1.5;">${children}</p>`;
|
|
979
985
|
}
|
|
980
986
|
async function convertHeading(node, mediaUrl, customBlockConverter) {
|
|
981
987
|
const tag = node.tag || "h1";
|
|
@@ -989,8 +995,14 @@ async function convertHeading(node, mediaUrl, customBlockConverter) {
|
|
|
989
995
|
h2: "font-size: 24px; font-weight: 600; margin: 0 0 16px 0; line-height: 1.3;",
|
|
990
996
|
h3: "font-size: 20px; font-weight: 600; margin: 0 0 12px 0; line-height: 1.4;"
|
|
991
997
|
};
|
|
998
|
+
const mobileClasses = {
|
|
999
|
+
h1: "mobile-font-size-24",
|
|
1000
|
+
h2: "mobile-font-size-20",
|
|
1001
|
+
h3: "mobile-font-size-16"
|
|
1002
|
+
};
|
|
992
1003
|
const style = `${styles[tag] || styles.h3} text-align: ${align};`;
|
|
993
|
-
|
|
1004
|
+
const mobileClass = mobileClasses[tag] || mobileClasses.h3;
|
|
1005
|
+
return `<${tag} class="${mobileClass}" style="${style}">${children}</${tag}>`;
|
|
994
1006
|
}
|
|
995
1007
|
async function convertList(node, mediaUrl, customBlockConverter) {
|
|
996
1008
|
const tag = node.listType === "number" ? "ol" : "ul";
|
|
@@ -998,8 +1010,8 @@ async function convertList(node, mediaUrl, customBlockConverter) {
|
|
|
998
1010
|
(node.children || []).map((child) => convertNode(child, mediaUrl, customBlockConverter))
|
|
999
1011
|
);
|
|
1000
1012
|
const children = childParts.join("");
|
|
1001
|
-
const style = tag === "ul" ? "margin: 0 0 16px 0; padding-left: 24px; list-style-type: disc;" : "margin: 0 0 16px 0; padding-left: 24px; list-style-type: decimal;";
|
|
1002
|
-
return `<${tag} style="${style}">${children}</${tag}>`;
|
|
1013
|
+
const style = tag === "ul" ? "margin: 0 0 16px 0; padding-left: 24px; list-style-type: disc; font-size: 16px; line-height: 1.5;" : "margin: 0 0 16px 0; padding-left: 24px; list-style-type: decimal; font-size: 16px; line-height: 1.5;";
|
|
1014
|
+
return `<${tag} class="mobile-margin-bottom-16" style="${style}">${children}</${tag}>`;
|
|
1003
1015
|
}
|
|
1004
1016
|
async function convertListItem(node, mediaUrl, customBlockConverter) {
|
|
1005
1017
|
const childParts = await Promise.all(
|
|
@@ -1056,16 +1068,16 @@ function convertUpload(node, mediaUrl) {
|
|
|
1056
1068
|
}
|
|
1057
1069
|
const alt = node.fields?.altText || upload.alt || "";
|
|
1058
1070
|
const caption = node.fields?.caption || "";
|
|
1059
|
-
const imgHtml = `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" style="max-width: 100%; height: auto; display: block; margin: 0 auto;" />`;
|
|
1071
|
+
const imgHtml = `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" class="mobile-width-100" style="max-width: 100%; height: auto; display: block; margin: 0 auto; border-radius: 6px;" />`;
|
|
1060
1072
|
if (caption) {
|
|
1061
1073
|
return `
|
|
1062
|
-
<div style="margin: 0 0 16px 0; text-align: center;">
|
|
1074
|
+
<div style="margin: 0 0 16px 0; text-align: center;" class="mobile-margin-bottom-16">
|
|
1063
1075
|
${imgHtml}
|
|
1064
|
-
<p style="margin: 8px 0 0 0; font-size: 14px; color: #6b7280; font-style: italic;">${escapeHtml(caption)}</p>
|
|
1076
|
+
<p style="margin: 8px 0 0 0; font-size: 14px; color: #6b7280; font-style: italic; text-align: center;" class="mobile-font-size-14">${escapeHtml(caption)}</p>
|
|
1065
1077
|
</div>
|
|
1066
1078
|
`;
|
|
1067
1079
|
}
|
|
1068
|
-
return `<div style="margin: 0 0 16px 0; text-align: center;">${imgHtml}</div>`;
|
|
1080
|
+
return `<div style="margin: 0 0 16px 0; text-align: center;" class="mobile-margin-bottom-16">${imgHtml}</div>`;
|
|
1069
1081
|
}
|
|
1070
1082
|
async function convertBlock(node, mediaUrl, customBlockConverter) {
|
|
1071
1083
|
const blockType = node.fields?.blockName || node.blockName;
|
|
@@ -1138,11 +1150,14 @@ function escapeHtml(text) {
|
|
|
1138
1150
|
}
|
|
1139
1151
|
function wrapInEmailTemplate(content, preheader) {
|
|
1140
1152
|
return `<!DOCTYPE html>
|
|
1141
|
-
<html lang="en">
|
|
1153
|
+
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
|
|
1142
1154
|
<head>
|
|
1143
1155
|
<meta charset="UTF-8">
|
|
1144
1156
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1145
|
-
<
|
|
1157
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
1158
|
+
<meta name="x-apple-disable-message-reformatting">
|
|
1159
|
+
<title>Newsletter</title>
|
|
1160
|
+
|
|
1146
1161
|
<!--[if mso]>
|
|
1147
1162
|
<noscript>
|
|
1148
1163
|
<xml>
|
|
@@ -1152,16 +1167,155 @@ function wrapInEmailTemplate(content, preheader) {
|
|
|
1152
1167
|
</xml>
|
|
1153
1168
|
</noscript>
|
|
1154
1169
|
<![endif]-->
|
|
1170
|
+
|
|
1171
|
+
<style>
|
|
1172
|
+
/* Reset and base styles */
|
|
1173
|
+
* {
|
|
1174
|
+
-webkit-text-size-adjust: 100%;
|
|
1175
|
+
-ms-text-size-adjust: 100%;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
body {
|
|
1179
|
+
margin: 0 !important;
|
|
1180
|
+
padding: 0 !important;
|
|
1181
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
|
|
1182
|
+
font-size: 16px;
|
|
1183
|
+
line-height: 1.5;
|
|
1184
|
+
color: #1A1A1A;
|
|
1185
|
+
background-color: #f8f9fa;
|
|
1186
|
+
-webkit-font-smoothing: antialiased;
|
|
1187
|
+
-moz-osx-font-smoothing: grayscale;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
table {
|
|
1191
|
+
border-spacing: 0 !important;
|
|
1192
|
+
border-collapse: collapse !important;
|
|
1193
|
+
table-layout: fixed !important;
|
|
1194
|
+
margin: 0 auto !important;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
table table table {
|
|
1198
|
+
table-layout: auto;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
img {
|
|
1202
|
+
-ms-interpolation-mode: bicubic;
|
|
1203
|
+
max-width: 100%;
|
|
1204
|
+
height: auto;
|
|
1205
|
+
border: 0;
|
|
1206
|
+
outline: none;
|
|
1207
|
+
text-decoration: none;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
/* Responsive styles */
|
|
1211
|
+
@media only screen and (max-width: 640px) {
|
|
1212
|
+
.mobile-hide {
|
|
1213
|
+
display: none !important;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
.mobile-center {
|
|
1217
|
+
text-align: center !important;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
.mobile-width-100 {
|
|
1221
|
+
width: 100% !important;
|
|
1222
|
+
max-width: 100% !important;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
.mobile-padding {
|
|
1226
|
+
padding: 20px !important;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
.mobile-padding-sm {
|
|
1230
|
+
padding: 16px !important;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
.mobile-font-size-14 {
|
|
1234
|
+
font-size: 14px !important;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
.mobile-font-size-16 {
|
|
1238
|
+
font-size: 16px !important;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
.mobile-font-size-20 {
|
|
1242
|
+
font-size: 20px !important;
|
|
1243
|
+
line-height: 1.3 !important;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
.mobile-font-size-24 {
|
|
1247
|
+
font-size: 24px !important;
|
|
1248
|
+
line-height: 1.2 !important;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
/* Stack sections on mobile */
|
|
1252
|
+
.mobile-stack {
|
|
1253
|
+
display: block !important;
|
|
1254
|
+
width: 100% !important;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/* Mobile-specific spacing */
|
|
1258
|
+
.mobile-margin-bottom-16 {
|
|
1259
|
+
margin-bottom: 16px !important;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
.mobile-margin-bottom-20 {
|
|
1263
|
+
margin-bottom: 20px !important;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/* Dark mode support */
|
|
1268
|
+
@media (prefers-color-scheme: dark) {
|
|
1269
|
+
.dark-mode-bg {
|
|
1270
|
+
background-color: #1a1a1a !important;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
.dark-mode-text {
|
|
1274
|
+
color: #ffffff !important;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
.dark-mode-border {
|
|
1278
|
+
border-color: #333333 !important;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
/* Outlook-specific fixes */
|
|
1283
|
+
<!--[if mso]>
|
|
1284
|
+
<style>
|
|
1285
|
+
table {
|
|
1286
|
+
border-collapse: collapse;
|
|
1287
|
+
border-spacing: 0;
|
|
1288
|
+
border: none;
|
|
1289
|
+
margin: 0;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
div, p {
|
|
1293
|
+
margin: 0;
|
|
1294
|
+
}
|
|
1295
|
+
</style>
|
|
1296
|
+
<![endif]-->
|
|
1297
|
+
</style>
|
|
1155
1298
|
</head>
|
|
1156
|
-
<body style="margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; font-size: 16px; line-height: 1.5; color: #
|
|
1157
|
-
${preheader ?
|
|
1158
|
-
|
|
1299
|
+
<body style="margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; font-size: 16px; line-height: 1.5; color: #1A1A1A; background-color: #f8f9fa;">
|
|
1300
|
+
${preheader ? `
|
|
1301
|
+
<!-- Preheader text -->
|
|
1302
|
+
<div style="display: none; max-height: 0; overflow: hidden; font-size: 1px; line-height: 1px; color: transparent;">
|
|
1303
|
+
${escapeHtml(preheader)}
|
|
1304
|
+
</div>
|
|
1305
|
+
` : ""}
|
|
1306
|
+
|
|
1307
|
+
<!-- Main container -->
|
|
1308
|
+
<table role="presentation" cellpadding="0" cellspacing="0" width="100%" style="margin: 0; padding: 0; background-color: #f8f9fa;">
|
|
1159
1309
|
<tr>
|
|
1160
|
-
<td align="center" style="padding: 20px
|
|
1161
|
-
|
|
1310
|
+
<td align="center" style="padding: 20px 10px;">
|
|
1311
|
+
<!-- Email wrapper -->
|
|
1312
|
+
<table role="presentation" cellpadding="0" cellspacing="0" width="600" class="mobile-width-100" style="margin: 0 auto; max-width: 600px;">
|
|
1162
1313
|
<tr>
|
|
1163
|
-
<td style="padding:
|
|
1164
|
-
|
|
1314
|
+
<td class="mobile-padding" style="padding: 0;">
|
|
1315
|
+
<!-- Content area with light background -->
|
|
1316
|
+
<div style="background-color: #ffffff; padding: 40px 30px; border-radius: 8px;" class="mobile-padding">
|
|
1317
|
+
${content}
|
|
1318
|
+
</div>
|
|
1165
1319
|
</td>
|
|
1166
1320
|
</tr>
|
|
1167
1321
|
</table>
|
|
@@ -1267,8 +1421,16 @@ function validateEmailHtml(html) {
|
|
|
1267
1421
|
};
|
|
1268
1422
|
}
|
|
1269
1423
|
|
|
1424
|
+
// src/contexts/PluginConfigContext.tsx
|
|
1425
|
+
import { createContext, useContext } from "react";
|
|
1426
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1427
|
+
var PluginConfigContext = createContext(null);
|
|
1428
|
+
var usePluginConfigOptional = () => {
|
|
1429
|
+
return useContext(PluginConfigContext);
|
|
1430
|
+
};
|
|
1431
|
+
|
|
1270
1432
|
// src/components/Broadcasts/EmailPreview.tsx
|
|
1271
|
-
import { jsx as
|
|
1433
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1272
1434
|
var SAMPLE_DATA = {
|
|
1273
1435
|
"subscriber.name": "John Doe",
|
|
1274
1436
|
"subscriber.firstName": "John",
|
|
@@ -1284,8 +1446,11 @@ var EmailPreview = ({
|
|
|
1284
1446
|
subject,
|
|
1285
1447
|
preheader,
|
|
1286
1448
|
mode = "desktop",
|
|
1287
|
-
onValidation
|
|
1449
|
+
onValidation,
|
|
1450
|
+
pluginConfig: propPluginConfig
|
|
1288
1451
|
}) => {
|
|
1452
|
+
const contextPluginConfig = usePluginConfigOptional();
|
|
1453
|
+
const pluginConfig = propPluginConfig || contextPluginConfig;
|
|
1289
1454
|
const [html, setHtml] = useState5("");
|
|
1290
1455
|
const [loading, setLoading] = useState5(false);
|
|
1291
1456
|
const [validationResult, setValidationResult] = useState5(null);
|
|
@@ -1298,9 +1463,13 @@ var EmailPreview = ({
|
|
|
1298
1463
|
}
|
|
1299
1464
|
setLoading(true);
|
|
1300
1465
|
try {
|
|
1466
|
+
const emailPreviewConfig = pluginConfig?.customizations?.broadcasts?.emailPreview;
|
|
1301
1467
|
const emailHtml = await convertToEmailSafeHtml(content, {
|
|
1302
|
-
wrapInTemplate: true,
|
|
1303
|
-
preheader
|
|
1468
|
+
wrapInTemplate: emailPreviewConfig?.wrapInTemplate ?? true,
|
|
1469
|
+
preheader,
|
|
1470
|
+
subject,
|
|
1471
|
+
customWrapper: emailPreviewConfig?.customWrapper,
|
|
1472
|
+
customBlockConverter: pluginConfig?.customizations?.broadcasts?.customBlockConverter
|
|
1304
1473
|
});
|
|
1305
1474
|
const personalizedHtml = replacePersonalizationTags(emailHtml, SAMPLE_DATA);
|
|
1306
1475
|
const previewHtml = addEmailHeader(personalizedHtml, {
|
|
@@ -1320,7 +1489,7 @@ var EmailPreview = ({
|
|
|
1320
1489
|
}
|
|
1321
1490
|
};
|
|
1322
1491
|
convertContent();
|
|
1323
|
-
}, [content, subject, preheader, onValidation]);
|
|
1492
|
+
}, [content, subject, preheader, onValidation, pluginConfig]);
|
|
1324
1493
|
useEffect4(() => {
|
|
1325
1494
|
if (iframeRef.current && html) {
|
|
1326
1495
|
const doc = iframeRef.current.contentDocument;
|
|
@@ -1340,7 +1509,7 @@ var EmailPreview = ({
|
|
|
1340
1509
|
validationResult.errors.length,
|
|
1341
1510
|
")"
|
|
1342
1511
|
] }),
|
|
1343
|
-
/* @__PURE__ */
|
|
1512
|
+
/* @__PURE__ */ jsx5("ul", { style: { margin: 0, paddingLeft: "20px", fontSize: "13px", color: "#dc2626" }, children: validationResult.errors.map((error, index) => /* @__PURE__ */ jsx5("li", { children: error }, index)) })
|
|
1344
1513
|
] }),
|
|
1345
1514
|
validationResult.warnings.length > 0 && /* @__PURE__ */ jsxs4("div", { children: [
|
|
1346
1515
|
/* @__PURE__ */ jsxs4("h4", { style: { color: "#d97706", margin: "0 0 8px 0", fontSize: "14px" }, children: [
|
|
@@ -1348,10 +1517,10 @@ var EmailPreview = ({
|
|
|
1348
1517
|
validationResult.warnings.length,
|
|
1349
1518
|
")"
|
|
1350
1519
|
] }),
|
|
1351
|
-
/* @__PURE__ */
|
|
1520
|
+
/* @__PURE__ */ jsx5("ul", { style: { margin: 0, paddingLeft: "20px", fontSize: "13px", color: "#d97706" }, children: validationResult.warnings.map((warning, index) => /* @__PURE__ */ jsx5("li", { children: warning }, index)) })
|
|
1352
1521
|
] })
|
|
1353
1522
|
] }),
|
|
1354
|
-
/* @__PURE__ */
|
|
1523
|
+
/* @__PURE__ */ jsx5("div", { style: {
|
|
1355
1524
|
flex: 1,
|
|
1356
1525
|
display: "flex",
|
|
1357
1526
|
alignItems: "center",
|
|
@@ -1359,14 +1528,14 @@ var EmailPreview = ({
|
|
|
1359
1528
|
backgroundColor: "#f3f4f6",
|
|
1360
1529
|
padding: "20px",
|
|
1361
1530
|
overflow: "auto"
|
|
1362
|
-
}, children: loading ? /* @__PURE__ */
|
|
1531
|
+
}, children: loading ? /* @__PURE__ */ jsx5("div", { style: { textAlign: "center", color: "#6b7280" }, children: /* @__PURE__ */ jsx5("p", { children: "Loading preview..." }) }) : html ? /* @__PURE__ */ jsx5("div", { style: {
|
|
1363
1532
|
backgroundColor: "white",
|
|
1364
1533
|
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
|
|
1365
1534
|
borderRadius: "8px",
|
|
1366
1535
|
overflow: "hidden",
|
|
1367
1536
|
transform: `scale(${viewport.scale})`,
|
|
1368
1537
|
transformOrigin: "top center"
|
|
1369
|
-
}, children: /* @__PURE__ */
|
|
1538
|
+
}, children: /* @__PURE__ */ jsx5(
|
|
1370
1539
|
"iframe",
|
|
1371
1540
|
{
|
|
1372
1541
|
ref: iframeRef,
|
|
@@ -1379,7 +1548,7 @@ var EmailPreview = ({
|
|
|
1379
1548
|
},
|
|
1380
1549
|
sandbox: "allow-same-origin"
|
|
1381
1550
|
}
|
|
1382
|
-
) }) : /* @__PURE__ */
|
|
1551
|
+
) }) : /* @__PURE__ */ jsx5("div", { style: { textAlign: "center", color: "#6b7280" }, children: /* @__PURE__ */ jsx5("p", { children: "Start typing to see the email preview" }) }) }),
|
|
1383
1552
|
validationResult && /* @__PURE__ */ jsxs4("div", { style: {
|
|
1384
1553
|
padding: "12px 16px",
|
|
1385
1554
|
borderTop: "1px solid #e5e7eb",
|
|
@@ -1427,11 +1596,12 @@ function escapeHtml2(text) {
|
|
|
1427
1596
|
// src/components/Broadcasts/EmailPreviewField.tsx
|
|
1428
1597
|
import { useState as useState6 } from "react";
|
|
1429
1598
|
import { useFormFields } from "@payloadcms/ui";
|
|
1430
|
-
import { jsx as
|
|
1599
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1431
1600
|
var EmailPreviewField = () => {
|
|
1432
1601
|
const [previewMode, setPreviewMode] = useState6("desktop");
|
|
1433
1602
|
const [isValid, setIsValid] = useState6(true);
|
|
1434
1603
|
const [validationSummary, setValidationSummary] = useState6("");
|
|
1604
|
+
const pluginConfig = usePluginConfigOptional();
|
|
1435
1605
|
const fields = useFormFields(([fields2]) => ({
|
|
1436
1606
|
content: fields2["contentSection.content"],
|
|
1437
1607
|
subject: fields2["subject"],
|
|
@@ -1488,9 +1658,9 @@ var EmailPreviewField = () => {
|
|
|
1488
1658
|
backgroundColor: "#f9fafb"
|
|
1489
1659
|
}, children: [
|
|
1490
1660
|
/* @__PURE__ */ jsxs5("div", { style: { display: "flex", alignItems: "center", gap: "16px" }, children: [
|
|
1491
|
-
/* @__PURE__ */
|
|
1661
|
+
/* @__PURE__ */ jsx6("h3", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Email Preview" }),
|
|
1492
1662
|
/* @__PURE__ */ jsxs5("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
1493
|
-
/* @__PURE__ */
|
|
1663
|
+
/* @__PURE__ */ jsx6(
|
|
1494
1664
|
"button",
|
|
1495
1665
|
{
|
|
1496
1666
|
type: "button",
|
|
@@ -1507,7 +1677,7 @@ var EmailPreviewField = () => {
|
|
|
1507
1677
|
children: "Desktop"
|
|
1508
1678
|
}
|
|
1509
1679
|
),
|
|
1510
|
-
/* @__PURE__ */
|
|
1680
|
+
/* @__PURE__ */ jsx6(
|
|
1511
1681
|
"button",
|
|
1512
1682
|
{
|
|
1513
1683
|
type: "button",
|
|
@@ -1525,7 +1695,7 @@ var EmailPreviewField = () => {
|
|
|
1525
1695
|
}
|
|
1526
1696
|
)
|
|
1527
1697
|
] }),
|
|
1528
|
-
validationSummary && /* @__PURE__ */
|
|
1698
|
+
validationSummary && /* @__PURE__ */ jsx6("div", { style: {
|
|
1529
1699
|
padding: "6px 12px",
|
|
1530
1700
|
backgroundColor: isValid ? "#fef3c7" : "#fee2e2",
|
|
1531
1701
|
color: isValid ? "#92400e" : "#991b1b",
|
|
@@ -1533,7 +1703,7 @@ var EmailPreviewField = () => {
|
|
|
1533
1703
|
fontSize: "13px"
|
|
1534
1704
|
}, children: validationSummary })
|
|
1535
1705
|
] }),
|
|
1536
|
-
/* @__PURE__ */
|
|
1706
|
+
/* @__PURE__ */ jsx6(
|
|
1537
1707
|
"button",
|
|
1538
1708
|
{
|
|
1539
1709
|
type: "button",
|
|
@@ -1551,14 +1721,15 @@ var EmailPreviewField = () => {
|
|
|
1551
1721
|
}
|
|
1552
1722
|
)
|
|
1553
1723
|
] }),
|
|
1554
|
-
/* @__PURE__ */
|
|
1724
|
+
/* @__PURE__ */ jsx6("div", { style: { height: "600px" }, children: /* @__PURE__ */ jsx6(
|
|
1555
1725
|
EmailPreview,
|
|
1556
1726
|
{
|
|
1557
1727
|
content: fields.content?.value || null,
|
|
1558
1728
|
subject: fields.subject?.value || "Email Subject",
|
|
1559
1729
|
preheader: fields.preheader?.value,
|
|
1560
1730
|
mode: previewMode,
|
|
1561
|
-
onValidation: handleValidation
|
|
1731
|
+
onValidation: handleValidation,
|
|
1732
|
+
pluginConfig: pluginConfig || void 0
|
|
1562
1733
|
}
|
|
1563
1734
|
) })
|
|
1564
1735
|
] });
|
|
@@ -1567,7 +1738,7 @@ var EmailPreviewField = () => {
|
|
|
1567
1738
|
// src/components/Broadcasts/BroadcastEditor.tsx
|
|
1568
1739
|
import { useState as useState7, useCallback as useCallback2 } from "react";
|
|
1569
1740
|
import { useField, useFormFields as useFormFields2 } from "@payloadcms/ui";
|
|
1570
|
-
import { jsx as
|
|
1741
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1571
1742
|
var BroadcastEditor = (props) => {
|
|
1572
1743
|
const { value } = useField({ path: props.path });
|
|
1573
1744
|
const [showPreview, setShowPreview] = useState7(true);
|
|
@@ -1623,7 +1794,7 @@ var BroadcastEditor = (props) => {
|
|
|
1623
1794
|
backgroundColor: "#f9fafb"
|
|
1624
1795
|
}, children: [
|
|
1625
1796
|
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", alignItems: "center", gap: "16px" }, children: [
|
|
1626
|
-
/* @__PURE__ */
|
|
1797
|
+
/* @__PURE__ */ jsx7(
|
|
1627
1798
|
"button",
|
|
1628
1799
|
{
|
|
1629
1800
|
type: "button",
|
|
@@ -1641,7 +1812,7 @@ var BroadcastEditor = (props) => {
|
|
|
1641
1812
|
}
|
|
1642
1813
|
),
|
|
1643
1814
|
showPreview && /* @__PURE__ */ jsxs6("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
1644
|
-
/* @__PURE__ */
|
|
1815
|
+
/* @__PURE__ */ jsx7(
|
|
1645
1816
|
"button",
|
|
1646
1817
|
{
|
|
1647
1818
|
type: "button",
|
|
@@ -1658,7 +1829,7 @@ var BroadcastEditor = (props) => {
|
|
|
1658
1829
|
children: "Desktop"
|
|
1659
1830
|
}
|
|
1660
1831
|
),
|
|
1661
|
-
/* @__PURE__ */
|
|
1832
|
+
/* @__PURE__ */ jsx7(
|
|
1662
1833
|
"button",
|
|
1663
1834
|
{
|
|
1664
1835
|
type: "button",
|
|
@@ -1676,7 +1847,7 @@ var BroadcastEditor = (props) => {
|
|
|
1676
1847
|
}
|
|
1677
1848
|
)
|
|
1678
1849
|
] }),
|
|
1679
|
-
showPreview && validationSummary && /* @__PURE__ */
|
|
1850
|
+
showPreview && validationSummary && /* @__PURE__ */ jsx7("div", { style: {
|
|
1680
1851
|
padding: "6px 12px",
|
|
1681
1852
|
backgroundColor: isValid ? "#fef3c7" : "#fee2e2",
|
|
1682
1853
|
color: isValid ? "#92400e" : "#991b1b",
|
|
@@ -1684,7 +1855,7 @@ var BroadcastEditor = (props) => {
|
|
|
1684
1855
|
fontSize: "13px"
|
|
1685
1856
|
}, children: validationSummary })
|
|
1686
1857
|
] }),
|
|
1687
|
-
showPreview && /* @__PURE__ */
|
|
1858
|
+
showPreview && /* @__PURE__ */ jsx7(
|
|
1688
1859
|
"button",
|
|
1689
1860
|
{
|
|
1690
1861
|
type: "button",
|
|
@@ -1703,12 +1874,12 @@ var BroadcastEditor = (props) => {
|
|
|
1703
1874
|
)
|
|
1704
1875
|
] }),
|
|
1705
1876
|
/* @__PURE__ */ jsxs6("div", { style: { flex: 1, display: "flex", overflow: "hidden" }, children: [
|
|
1706
|
-
/* @__PURE__ */
|
|
1877
|
+
/* @__PURE__ */ jsx7("div", { style: {
|
|
1707
1878
|
flex: showPreview ? "0 0 50%" : "1",
|
|
1708
1879
|
overflow: "auto",
|
|
1709
1880
|
borderRight: showPreview ? "1px solid #e5e7eb" : "none"
|
|
1710
|
-
}, children: /* @__PURE__ */
|
|
1711
|
-
showPreview && /* @__PURE__ */
|
|
1881
|
+
}, children: /* @__PURE__ */ jsx7("div", { style: { padding: "16px" }, children: /* @__PURE__ */ jsx7("div", { className: "rich-text-lexical" }) }) }),
|
|
1882
|
+
showPreview && /* @__PURE__ */ jsx7("div", { style: { flex: "0 0 50%", overflow: "hidden" }, children: /* @__PURE__ */ jsx7(
|
|
1712
1883
|
EmailPreview,
|
|
1713
1884
|
{
|
|
1714
1885
|
content: value,
|
|
@@ -1727,7 +1898,7 @@ import { useState as useState8, useCallback as useCallback3 } from "react";
|
|
|
1727
1898
|
import { useFormFields as useFormFields3 } from "@payloadcms/ui";
|
|
1728
1899
|
|
|
1729
1900
|
// src/components/Broadcasts/PreviewControls.tsx
|
|
1730
|
-
import { jsx as
|
|
1901
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1731
1902
|
var PreviewControls = ({
|
|
1732
1903
|
onUpdate,
|
|
1733
1904
|
device,
|
|
@@ -1770,7 +1941,7 @@ var PreviewControls = ({
|
|
|
1770
1941
|
fontSize: "14px"
|
|
1771
1942
|
});
|
|
1772
1943
|
return /* @__PURE__ */ jsxs7("div", { style: controlsStyle, children: [
|
|
1773
|
-
/* @__PURE__ */
|
|
1944
|
+
/* @__PURE__ */ jsx8(
|
|
1774
1945
|
"button",
|
|
1775
1946
|
{
|
|
1776
1947
|
style: updateButtonStyle,
|
|
@@ -1788,9 +1959,9 @@ var PreviewControls = ({
|
|
|
1788
1959
|
"aria-label": "Desktop view",
|
|
1789
1960
|
children: [
|
|
1790
1961
|
/* @__PURE__ */ jsxs7("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1791
|
-
/* @__PURE__ */
|
|
1792
|
-
/* @__PURE__ */
|
|
1793
|
-
/* @__PURE__ */
|
|
1962
|
+
/* @__PURE__ */ jsx8("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2", ry: "2" }),
|
|
1963
|
+
/* @__PURE__ */ jsx8("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
|
|
1964
|
+
/* @__PURE__ */ jsx8("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
|
|
1794
1965
|
] }),
|
|
1795
1966
|
"Desktop"
|
|
1796
1967
|
]
|
|
@@ -1804,8 +1975,8 @@ var PreviewControls = ({
|
|
|
1804
1975
|
"aria-label": "Mobile view",
|
|
1805
1976
|
children: [
|
|
1806
1977
|
/* @__PURE__ */ jsxs7("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1807
|
-
/* @__PURE__ */
|
|
1808
|
-
/* @__PURE__ */
|
|
1978
|
+
/* @__PURE__ */ jsx8("rect", { x: "5", y: "2", width: "14", height: "20", rx: "2", ry: "2" }),
|
|
1979
|
+
/* @__PURE__ */ jsx8("line", { x1: "12", y1: "18", x2: "12", y2: "18" })
|
|
1809
1980
|
] }),
|
|
1810
1981
|
"Mobile"
|
|
1811
1982
|
]
|
|
@@ -1816,7 +1987,7 @@ var PreviewControls = ({
|
|
|
1816
1987
|
};
|
|
1817
1988
|
|
|
1818
1989
|
// src/components/Broadcasts/BroadcastInlinePreview.tsx
|
|
1819
|
-
import { Fragment as Fragment2, jsx as
|
|
1990
|
+
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1820
1991
|
var BroadcastInlinePreview = () => {
|
|
1821
1992
|
const [device, setDevice] = useState8("desktop");
|
|
1822
1993
|
const [isLoading, setIsLoading] = useState8(false);
|
|
@@ -1905,8 +2076,8 @@ var BroadcastInlinePreview = () => {
|
|
|
1905
2076
|
};
|
|
1906
2077
|
return /* @__PURE__ */ jsxs8("div", { style: containerStyle, children: [
|
|
1907
2078
|
/* @__PURE__ */ jsxs8("div", { style: headerStyle, children: [
|
|
1908
|
-
/* @__PURE__ */
|
|
1909
|
-
/* @__PURE__ */
|
|
2079
|
+
/* @__PURE__ */ jsx9("h3", { style: titleStyle, children: "Email Preview" }),
|
|
2080
|
+
/* @__PURE__ */ jsx9(
|
|
1910
2081
|
"button",
|
|
1911
2082
|
{
|
|
1912
2083
|
onClick: () => showPreview ? setShowPreview(false) : updatePreview(),
|
|
@@ -1916,9 +2087,9 @@ var BroadcastInlinePreview = () => {
|
|
|
1916
2087
|
}
|
|
1917
2088
|
)
|
|
1918
2089
|
] }),
|
|
1919
|
-
showPreview && /* @__PURE__ */
|
|
1920
|
-
/* @__PURE__ */
|
|
1921
|
-
/* @__PURE__ */
|
|
2090
|
+
showPreview && /* @__PURE__ */ jsx9("div", { style: previewContainerStyle, children: error ? /* @__PURE__ */ jsxs8("div", { style: errorStyle, children: [
|
|
2091
|
+
/* @__PURE__ */ jsx9("p", { style: { color: "#ef4444", margin: "0 0 1rem" }, children: error.message }),
|
|
2092
|
+
/* @__PURE__ */ jsx9(
|
|
1922
2093
|
"button",
|
|
1923
2094
|
{
|
|
1924
2095
|
onClick: updatePreview,
|
|
@@ -1934,7 +2105,7 @@ var BroadcastInlinePreview = () => {
|
|
|
1934
2105
|
}
|
|
1935
2106
|
)
|
|
1936
2107
|
] }) : previewHtml ? /* @__PURE__ */ jsxs8(Fragment2, { children: [
|
|
1937
|
-
/* @__PURE__ */
|
|
2108
|
+
/* @__PURE__ */ jsx9(
|
|
1938
2109
|
PreviewControls,
|
|
1939
2110
|
{
|
|
1940
2111
|
onUpdate: updatePreview,
|
|
@@ -1943,7 +2114,7 @@ var BroadcastInlinePreview = () => {
|
|
|
1943
2114
|
isLoading
|
|
1944
2115
|
}
|
|
1945
2116
|
),
|
|
1946
|
-
/* @__PURE__ */
|
|
2117
|
+
/* @__PURE__ */ jsx9(
|
|
1947
2118
|
"div",
|
|
1948
2119
|
{
|
|
1949
2120
|
style: {
|
|
@@ -1953,7 +2124,7 @@ var BroadcastInlinePreview = () => {
|
|
|
1953
2124
|
justifyContent: "center",
|
|
1954
2125
|
overflow: "auto"
|
|
1955
2126
|
},
|
|
1956
|
-
children: /* @__PURE__ */
|
|
2127
|
+
children: /* @__PURE__ */ jsx9(
|
|
1957
2128
|
"div",
|
|
1958
2129
|
{
|
|
1959
2130
|
style: {
|
|
@@ -1964,7 +2135,7 @@ var BroadcastInlinePreview = () => {
|
|
|
1964
2135
|
borderRadius: "8px",
|
|
1965
2136
|
overflow: "hidden"
|
|
1966
2137
|
},
|
|
1967
|
-
children: /* @__PURE__ */
|
|
2138
|
+
children: /* @__PURE__ */ jsx9(
|
|
1968
2139
|
"iframe",
|
|
1969
2140
|
{
|
|
1970
2141
|
srcDoc: previewHtml,
|
|
@@ -1986,9 +2157,9 @@ var BroadcastInlinePreview = () => {
|
|
|
1986
2157
|
};
|
|
1987
2158
|
|
|
1988
2159
|
// src/components/Broadcasts/BroadcastPreviewField.tsx
|
|
1989
|
-
import { jsx as
|
|
2160
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1990
2161
|
var BroadcastPreviewField = () => {
|
|
1991
|
-
return /* @__PURE__ */
|
|
2162
|
+
return /* @__PURE__ */ jsx10("div", { style: {
|
|
1992
2163
|
padding: "1rem",
|
|
1993
2164
|
background: "#f9fafb",
|
|
1994
2165
|
borderRadius: "4px",
|
|
@@ -2000,7 +2171,7 @@ var BroadcastPreviewField = () => {
|
|
|
2000
2171
|
// src/components/Broadcasts/EmailRenderer.tsx
|
|
2001
2172
|
import { useEffect as useEffect5, useState as useState9, useCallback as useCallback4, useRef as useRef2 } from "react";
|
|
2002
2173
|
import { render } from "@react-email/render";
|
|
2003
|
-
import { jsx as
|
|
2174
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2004
2175
|
var EmailRenderer = ({
|
|
2005
2176
|
template,
|
|
2006
2177
|
data,
|
|
@@ -2013,7 +2184,7 @@ var EmailRenderer = ({
|
|
|
2013
2184
|
const renderEmail = useCallback4(async () => {
|
|
2014
2185
|
try {
|
|
2015
2186
|
const TemplateComponent = template;
|
|
2016
|
-
const element = /* @__PURE__ */
|
|
2187
|
+
const element = /* @__PURE__ */ jsx11(TemplateComponent, { ...data });
|
|
2017
2188
|
const html = await render(element, {
|
|
2018
2189
|
pretty: true
|
|
2019
2190
|
});
|
|
@@ -2068,8 +2239,8 @@ var EmailRenderer = ({
|
|
|
2068
2239
|
};
|
|
2069
2240
|
if (error) {
|
|
2070
2241
|
return /* @__PURE__ */ jsxs9("div", { style: errorStyle, children: [
|
|
2071
|
-
/* @__PURE__ */
|
|
2072
|
-
/* @__PURE__ */
|
|
2242
|
+
/* @__PURE__ */ jsx11("h3", { style: { color: "#ef4444", margin: "0 0 1rem" }, children: "Template Render Error" }),
|
|
2243
|
+
/* @__PURE__ */ jsx11("pre", { style: {
|
|
2073
2244
|
background: "#f9fafb",
|
|
2074
2245
|
padding: "1rem",
|
|
2075
2246
|
borderRadius: "4px",
|
|
@@ -2080,7 +2251,7 @@ var EmailRenderer = ({
|
|
|
2080
2251
|
}, children: error.message })
|
|
2081
2252
|
] });
|
|
2082
2253
|
}
|
|
2083
|
-
return /* @__PURE__ */
|
|
2254
|
+
return /* @__PURE__ */ jsx11("div", { style: containerStyle, children: /* @__PURE__ */ jsx11(
|
|
2084
2255
|
"iframe",
|
|
2085
2256
|
{
|
|
2086
2257
|
ref: iframeRef,
|
|
@@ -2092,7 +2263,7 @@ var EmailRenderer = ({
|
|
|
2092
2263
|
};
|
|
2093
2264
|
|
|
2094
2265
|
// src/components/Broadcasts/StatusBadge.tsx
|
|
2095
|
-
import { jsx as
|
|
2266
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
2096
2267
|
var statusConfig = {
|
|
2097
2268
|
["draft" /* DRAFT */]: {
|
|
2098
2269
|
label: "Draft",
|
|
@@ -2140,7 +2311,7 @@ var statusConfig = {
|
|
|
2140
2311
|
var StatusBadge = ({ cellData }) => {
|
|
2141
2312
|
const status = cellData;
|
|
2142
2313
|
const config = statusConfig[status] || statusConfig["draft" /* DRAFT */];
|
|
2143
|
-
return /* @__PURE__ */
|
|
2314
|
+
return /* @__PURE__ */ jsx12(
|
|
2144
2315
|
"span",
|
|
2145
2316
|
{
|
|
2146
2317
|
style: {
|
|
@@ -2175,21 +2346,21 @@ import {
|
|
|
2175
2346
|
Section,
|
|
2176
2347
|
Text
|
|
2177
2348
|
} from "@react-email/components";
|
|
2178
|
-
import { jsx as
|
|
2349
|
+
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2179
2350
|
var DefaultBroadcastTemplate = ({
|
|
2180
2351
|
subject,
|
|
2181
2352
|
preheader,
|
|
2182
2353
|
content
|
|
2183
2354
|
}) => {
|
|
2184
2355
|
return /* @__PURE__ */ jsxs10(Html, { children: [
|
|
2185
|
-
/* @__PURE__ */
|
|
2186
|
-
/* @__PURE__ */
|
|
2187
|
-
/* @__PURE__ */
|
|
2188
|
-
/* @__PURE__ */
|
|
2189
|
-
/* @__PURE__ */
|
|
2356
|
+
/* @__PURE__ */ jsx13(Head, {}),
|
|
2357
|
+
/* @__PURE__ */ jsx13(Preview, { children: preheader || subject }),
|
|
2358
|
+
/* @__PURE__ */ jsx13(Body, { style: main, children: /* @__PURE__ */ jsxs10(Container, { style: container, children: [
|
|
2359
|
+
/* @__PURE__ */ jsx13(Section, { style: contentSection, children: /* @__PURE__ */ jsx13("div", { dangerouslySetInnerHTML: { __html: content } }) }),
|
|
2360
|
+
/* @__PURE__ */ jsx13(Hr, { style: divider }),
|
|
2190
2361
|
/* @__PURE__ */ jsxs10(Section, { style: footer, children: [
|
|
2191
|
-
/* @__PURE__ */
|
|
2192
|
-
/* @__PURE__ */
|
|
2362
|
+
/* @__PURE__ */ jsx13(Text, { style: footerText, children: "You're receiving this email because you subscribed to our newsletter." }),
|
|
2363
|
+
/* @__PURE__ */ jsx13(Text, { style: footerText, children: /* @__PURE__ */ jsx13(Link, { href: "{{unsubscribe_url}}", style: footerLink, children: "Unsubscribe" }) })
|
|
2193
2364
|
] })
|
|
2194
2365
|
] }) })
|
|
2195
2366
|
] });
|