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.cjs
CHANGED
|
@@ -900,7 +900,7 @@ function useNewsletterAuth(_options = {}) {
|
|
|
900
900
|
}
|
|
901
901
|
|
|
902
902
|
// src/components/Broadcasts/EmailPreview.tsx
|
|
903
|
-
var
|
|
903
|
+
var import_react6 = require("react");
|
|
904
904
|
|
|
905
905
|
// src/utils/emailSafeHtml.ts
|
|
906
906
|
var import_isomorphic_dompurify = __toESM(require("isomorphic-dompurify"), 1);
|
|
@@ -971,6 +971,12 @@ async function convertToEmailSafeHtml(editorState, options) {
|
|
|
971
971
|
const rawHtml = await lexicalToEmailHtml(editorState, options?.mediaUrl, options?.customBlockConverter);
|
|
972
972
|
const sanitizedHtml = import_isomorphic_dompurify.default.sanitize(rawHtml, EMAIL_SAFE_CONFIG);
|
|
973
973
|
if (options?.wrapInTemplate) {
|
|
974
|
+
if (options.customWrapper) {
|
|
975
|
+
return await Promise.resolve(options.customWrapper(sanitizedHtml, {
|
|
976
|
+
preheader: options.preheader,
|
|
977
|
+
subject: options.subject
|
|
978
|
+
}));
|
|
979
|
+
}
|
|
974
980
|
return wrapInEmailTemplate(sanitizedHtml, options.preheader);
|
|
975
981
|
}
|
|
976
982
|
return sanitizedHtml;
|
|
@@ -1024,9 +1030,9 @@ async function convertParagraph(node, mediaUrl, customBlockConverter) {
|
|
|
1024
1030
|
);
|
|
1025
1031
|
const children = childParts.join("");
|
|
1026
1032
|
if (!children.trim()) {
|
|
1027
|
-
return '<p style="margin: 0 0 16px 0; min-height: 1em;"> </p>';
|
|
1033
|
+
return '<p class="mobile-margin-bottom-16" style="margin: 0 0 16px 0; min-height: 1em;"> </p>';
|
|
1028
1034
|
}
|
|
1029
|
-
return `<p style="margin: 0 0 16px 0; text-align: ${align};">${children}</p>`;
|
|
1035
|
+
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>`;
|
|
1030
1036
|
}
|
|
1031
1037
|
async function convertHeading(node, mediaUrl, customBlockConverter) {
|
|
1032
1038
|
const tag = node.tag || "h1";
|
|
@@ -1040,8 +1046,14 @@ async function convertHeading(node, mediaUrl, customBlockConverter) {
|
|
|
1040
1046
|
h2: "font-size: 24px; font-weight: 600; margin: 0 0 16px 0; line-height: 1.3;",
|
|
1041
1047
|
h3: "font-size: 20px; font-weight: 600; margin: 0 0 12px 0; line-height: 1.4;"
|
|
1042
1048
|
};
|
|
1049
|
+
const mobileClasses = {
|
|
1050
|
+
h1: "mobile-font-size-24",
|
|
1051
|
+
h2: "mobile-font-size-20",
|
|
1052
|
+
h3: "mobile-font-size-16"
|
|
1053
|
+
};
|
|
1043
1054
|
const style = `${styles[tag] || styles.h3} text-align: ${align};`;
|
|
1044
|
-
|
|
1055
|
+
const mobileClass = mobileClasses[tag] || mobileClasses.h3;
|
|
1056
|
+
return `<${tag} class="${mobileClass}" style="${style}">${children}</${tag}>`;
|
|
1045
1057
|
}
|
|
1046
1058
|
async function convertList(node, mediaUrl, customBlockConverter) {
|
|
1047
1059
|
const tag = node.listType === "number" ? "ol" : "ul";
|
|
@@ -1049,8 +1061,8 @@ async function convertList(node, mediaUrl, customBlockConverter) {
|
|
|
1049
1061
|
(node.children || []).map((child) => convertNode(child, mediaUrl, customBlockConverter))
|
|
1050
1062
|
);
|
|
1051
1063
|
const children = childParts.join("");
|
|
1052
|
-
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;";
|
|
1053
|
-
return `<${tag} style="${style}">${children}</${tag}>`;
|
|
1064
|
+
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;";
|
|
1065
|
+
return `<${tag} class="mobile-margin-bottom-16" style="${style}">${children}</${tag}>`;
|
|
1054
1066
|
}
|
|
1055
1067
|
async function convertListItem(node, mediaUrl, customBlockConverter) {
|
|
1056
1068
|
const childParts = await Promise.all(
|
|
@@ -1107,16 +1119,16 @@ function convertUpload(node, mediaUrl) {
|
|
|
1107
1119
|
}
|
|
1108
1120
|
const alt = node.fields?.altText || upload.alt || "";
|
|
1109
1121
|
const caption = node.fields?.caption || "";
|
|
1110
|
-
const imgHtml = `<img src="${escapeHtml(src)}" alt="${escapeHtml(alt)}" style="max-width: 100%; height: auto; display: block; margin: 0 auto;" />`;
|
|
1122
|
+
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;" />`;
|
|
1111
1123
|
if (caption) {
|
|
1112
1124
|
return `
|
|
1113
|
-
<div style="margin: 0 0 16px 0; text-align: center;">
|
|
1125
|
+
<div style="margin: 0 0 16px 0; text-align: center;" class="mobile-margin-bottom-16">
|
|
1114
1126
|
${imgHtml}
|
|
1115
|
-
<p style="margin: 8px 0 0 0; font-size: 14px; color: #6b7280; font-style: italic;">${escapeHtml(caption)}</p>
|
|
1127
|
+
<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>
|
|
1116
1128
|
</div>
|
|
1117
1129
|
`;
|
|
1118
1130
|
}
|
|
1119
|
-
return `<div style="margin: 0 0 16px 0; text-align: center;">${imgHtml}</div>`;
|
|
1131
|
+
return `<div style="margin: 0 0 16px 0; text-align: center;" class="mobile-margin-bottom-16">${imgHtml}</div>`;
|
|
1120
1132
|
}
|
|
1121
1133
|
async function convertBlock(node, mediaUrl, customBlockConverter) {
|
|
1122
1134
|
const blockType = node.fields?.blockName || node.blockName;
|
|
@@ -1189,11 +1201,14 @@ function escapeHtml(text) {
|
|
|
1189
1201
|
}
|
|
1190
1202
|
function wrapInEmailTemplate(content, preheader) {
|
|
1191
1203
|
return `<!DOCTYPE html>
|
|
1192
|
-
<html lang="en">
|
|
1204
|
+
<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">
|
|
1193
1205
|
<head>
|
|
1194
1206
|
<meta charset="UTF-8">
|
|
1195
1207
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1196
|
-
<
|
|
1208
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
1209
|
+
<meta name="x-apple-disable-message-reformatting">
|
|
1210
|
+
<title>Newsletter</title>
|
|
1211
|
+
|
|
1197
1212
|
<!--[if mso]>
|
|
1198
1213
|
<noscript>
|
|
1199
1214
|
<xml>
|
|
@@ -1203,16 +1218,155 @@ function wrapInEmailTemplate(content, preheader) {
|
|
|
1203
1218
|
</xml>
|
|
1204
1219
|
</noscript>
|
|
1205
1220
|
<![endif]-->
|
|
1221
|
+
|
|
1222
|
+
<style>
|
|
1223
|
+
/* Reset and base styles */
|
|
1224
|
+
* {
|
|
1225
|
+
-webkit-text-size-adjust: 100%;
|
|
1226
|
+
-ms-text-size-adjust: 100%;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
body {
|
|
1230
|
+
margin: 0 !important;
|
|
1231
|
+
padding: 0 !important;
|
|
1232
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
|
|
1233
|
+
font-size: 16px;
|
|
1234
|
+
line-height: 1.5;
|
|
1235
|
+
color: #1A1A1A;
|
|
1236
|
+
background-color: #f8f9fa;
|
|
1237
|
+
-webkit-font-smoothing: antialiased;
|
|
1238
|
+
-moz-osx-font-smoothing: grayscale;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
table {
|
|
1242
|
+
border-spacing: 0 !important;
|
|
1243
|
+
border-collapse: collapse !important;
|
|
1244
|
+
table-layout: fixed !important;
|
|
1245
|
+
margin: 0 auto !important;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
table table table {
|
|
1249
|
+
table-layout: auto;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
img {
|
|
1253
|
+
-ms-interpolation-mode: bicubic;
|
|
1254
|
+
max-width: 100%;
|
|
1255
|
+
height: auto;
|
|
1256
|
+
border: 0;
|
|
1257
|
+
outline: none;
|
|
1258
|
+
text-decoration: none;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
/* Responsive styles */
|
|
1262
|
+
@media only screen and (max-width: 640px) {
|
|
1263
|
+
.mobile-hide {
|
|
1264
|
+
display: none !important;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
.mobile-center {
|
|
1268
|
+
text-align: center !important;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
.mobile-width-100 {
|
|
1272
|
+
width: 100% !important;
|
|
1273
|
+
max-width: 100% !important;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
.mobile-padding {
|
|
1277
|
+
padding: 20px !important;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
.mobile-padding-sm {
|
|
1281
|
+
padding: 16px !important;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
.mobile-font-size-14 {
|
|
1285
|
+
font-size: 14px !important;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
.mobile-font-size-16 {
|
|
1289
|
+
font-size: 16px !important;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
.mobile-font-size-20 {
|
|
1293
|
+
font-size: 20px !important;
|
|
1294
|
+
line-height: 1.3 !important;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
.mobile-font-size-24 {
|
|
1298
|
+
font-size: 24px !important;
|
|
1299
|
+
line-height: 1.2 !important;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
/* Stack sections on mobile */
|
|
1303
|
+
.mobile-stack {
|
|
1304
|
+
display: block !important;
|
|
1305
|
+
width: 100% !important;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
/* Mobile-specific spacing */
|
|
1309
|
+
.mobile-margin-bottom-16 {
|
|
1310
|
+
margin-bottom: 16px !important;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
.mobile-margin-bottom-20 {
|
|
1314
|
+
margin-bottom: 20px !important;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
/* Dark mode support */
|
|
1319
|
+
@media (prefers-color-scheme: dark) {
|
|
1320
|
+
.dark-mode-bg {
|
|
1321
|
+
background-color: #1a1a1a !important;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
.dark-mode-text {
|
|
1325
|
+
color: #ffffff !important;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
.dark-mode-border {
|
|
1329
|
+
border-color: #333333 !important;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
/* Outlook-specific fixes */
|
|
1334
|
+
<!--[if mso]>
|
|
1335
|
+
<style>
|
|
1336
|
+
table {
|
|
1337
|
+
border-collapse: collapse;
|
|
1338
|
+
border-spacing: 0;
|
|
1339
|
+
border: none;
|
|
1340
|
+
margin: 0;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
div, p {
|
|
1344
|
+
margin: 0;
|
|
1345
|
+
}
|
|
1346
|
+
</style>
|
|
1347
|
+
<![endif]-->
|
|
1348
|
+
</style>
|
|
1206
1349
|
</head>
|
|
1207
|
-
<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: #
|
|
1208
|
-
${preheader ?
|
|
1209
|
-
|
|
1350
|
+
<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;">
|
|
1351
|
+
${preheader ? `
|
|
1352
|
+
<!-- Preheader text -->
|
|
1353
|
+
<div style="display: none; max-height: 0; overflow: hidden; font-size: 1px; line-height: 1px; color: transparent;">
|
|
1354
|
+
${escapeHtml(preheader)}
|
|
1355
|
+
</div>
|
|
1356
|
+
` : ""}
|
|
1357
|
+
|
|
1358
|
+
<!-- Main container -->
|
|
1359
|
+
<table role="presentation" cellpadding="0" cellspacing="0" width="100%" style="margin: 0; padding: 0; background-color: #f8f9fa;">
|
|
1210
1360
|
<tr>
|
|
1211
|
-
<td align="center" style="padding: 20px
|
|
1212
|
-
|
|
1361
|
+
<td align="center" style="padding: 20px 10px;">
|
|
1362
|
+
<!-- Email wrapper -->
|
|
1363
|
+
<table role="presentation" cellpadding="0" cellspacing="0" width="600" class="mobile-width-100" style="margin: 0 auto; max-width: 600px;">
|
|
1213
1364
|
<tr>
|
|
1214
|
-
<td style="padding:
|
|
1215
|
-
|
|
1365
|
+
<td class="mobile-padding" style="padding: 0;">
|
|
1366
|
+
<!-- Content area with light background -->
|
|
1367
|
+
<div style="background-color: #ffffff; padding: 40px 30px; border-radius: 8px;" class="mobile-padding">
|
|
1368
|
+
${content}
|
|
1369
|
+
</div>
|
|
1216
1370
|
</td>
|
|
1217
1371
|
</tr>
|
|
1218
1372
|
</table>
|
|
@@ -1318,8 +1472,16 @@ function validateEmailHtml(html) {
|
|
|
1318
1472
|
};
|
|
1319
1473
|
}
|
|
1320
1474
|
|
|
1321
|
-
// src/
|
|
1475
|
+
// src/contexts/PluginConfigContext.tsx
|
|
1476
|
+
var import_react5 = require("react");
|
|
1322
1477
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1478
|
+
var PluginConfigContext = (0, import_react5.createContext)(null);
|
|
1479
|
+
var usePluginConfigOptional = () => {
|
|
1480
|
+
return (0, import_react5.useContext)(PluginConfigContext);
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1483
|
+
// src/components/Broadcasts/EmailPreview.tsx
|
|
1484
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1323
1485
|
var SAMPLE_DATA = {
|
|
1324
1486
|
"subscriber.name": "John Doe",
|
|
1325
1487
|
"subscriber.firstName": "John",
|
|
@@ -1335,13 +1497,16 @@ var EmailPreview = ({
|
|
|
1335
1497
|
subject,
|
|
1336
1498
|
preheader,
|
|
1337
1499
|
mode = "desktop",
|
|
1338
|
-
onValidation
|
|
1500
|
+
onValidation,
|
|
1501
|
+
pluginConfig: propPluginConfig
|
|
1339
1502
|
}) => {
|
|
1340
|
-
const
|
|
1341
|
-
const
|
|
1342
|
-
const [
|
|
1343
|
-
const
|
|
1344
|
-
(0,
|
|
1503
|
+
const contextPluginConfig = usePluginConfigOptional();
|
|
1504
|
+
const pluginConfig = propPluginConfig || contextPluginConfig;
|
|
1505
|
+
const [html, setHtml] = (0, import_react6.useState)("");
|
|
1506
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
1507
|
+
const [validationResult, setValidationResult] = (0, import_react6.useState)(null);
|
|
1508
|
+
const iframeRef = (0, import_react6.useRef)(null);
|
|
1509
|
+
(0, import_react6.useEffect)(() => {
|
|
1345
1510
|
const convertContent = async () => {
|
|
1346
1511
|
if (!content) {
|
|
1347
1512
|
setHtml("");
|
|
@@ -1349,9 +1514,13 @@ var EmailPreview = ({
|
|
|
1349
1514
|
}
|
|
1350
1515
|
setLoading(true);
|
|
1351
1516
|
try {
|
|
1517
|
+
const emailPreviewConfig = pluginConfig?.customizations?.broadcasts?.emailPreview;
|
|
1352
1518
|
const emailHtml = await convertToEmailSafeHtml(content, {
|
|
1353
|
-
wrapInTemplate: true,
|
|
1354
|
-
preheader
|
|
1519
|
+
wrapInTemplate: emailPreviewConfig?.wrapInTemplate ?? true,
|
|
1520
|
+
preheader,
|
|
1521
|
+
subject,
|
|
1522
|
+
customWrapper: emailPreviewConfig?.customWrapper,
|
|
1523
|
+
customBlockConverter: pluginConfig?.customizations?.broadcasts?.customBlockConverter
|
|
1355
1524
|
});
|
|
1356
1525
|
const personalizedHtml = replacePersonalizationTags(emailHtml, SAMPLE_DATA);
|
|
1357
1526
|
const previewHtml = addEmailHeader(personalizedHtml, {
|
|
@@ -1371,8 +1540,8 @@ var EmailPreview = ({
|
|
|
1371
1540
|
}
|
|
1372
1541
|
};
|
|
1373
1542
|
convertContent();
|
|
1374
|
-
}, [content, subject, preheader, onValidation]);
|
|
1375
|
-
(0,
|
|
1543
|
+
}, [content, subject, preheader, onValidation, pluginConfig]);
|
|
1544
|
+
(0, import_react6.useEffect)(() => {
|
|
1376
1545
|
if (iframeRef.current && html) {
|
|
1377
1546
|
const doc = iframeRef.current.contentDocument;
|
|
1378
1547
|
if (doc) {
|
|
@@ -1383,26 +1552,26 @@ var EmailPreview = ({
|
|
|
1383
1552
|
}
|
|
1384
1553
|
}, [html]);
|
|
1385
1554
|
const viewport = VIEWPORT_SIZES[mode];
|
|
1386
|
-
return /* @__PURE__ */ (0,
|
|
1387
|
-
validationResult && (validationResult.errors.length > 0 || validationResult.warnings.length > 0) && /* @__PURE__ */ (0,
|
|
1388
|
-
validationResult.errors.length > 0 && /* @__PURE__ */ (0,
|
|
1389
|
-
/* @__PURE__ */ (0,
|
|
1555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { height: "100%", display: "flex", flexDirection: "column" }, children: [
|
|
1556
|
+
validationResult && (validationResult.errors.length > 0 || validationResult.warnings.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { padding: "16px", borderBottom: "1px solid #e5e7eb" }, children: [
|
|
1557
|
+
validationResult.errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { marginBottom: "12px" }, children: [
|
|
1558
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("h4", { style: { color: "#dc2626", margin: "0 0 8px 0", fontSize: "14px" }, children: [
|
|
1390
1559
|
"Errors (",
|
|
1391
1560
|
validationResult.errors.length,
|
|
1392
1561
|
")"
|
|
1393
1562
|
] }),
|
|
1394
|
-
/* @__PURE__ */ (0,
|
|
1563
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { style: { margin: 0, paddingLeft: "20px", fontSize: "13px", color: "#dc2626" }, children: validationResult.errors.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: error }, index)) })
|
|
1395
1564
|
] }),
|
|
1396
|
-
validationResult.warnings.length > 0 && /* @__PURE__ */ (0,
|
|
1397
|
-
/* @__PURE__ */ (0,
|
|
1565
|
+
validationResult.warnings.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
1566
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("h4", { style: { color: "#d97706", margin: "0 0 8px 0", fontSize: "14px" }, children: [
|
|
1398
1567
|
"Warnings (",
|
|
1399
1568
|
validationResult.warnings.length,
|
|
1400
1569
|
")"
|
|
1401
1570
|
] }),
|
|
1402
|
-
/* @__PURE__ */ (0,
|
|
1571
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { style: { margin: 0, paddingLeft: "20px", fontSize: "13px", color: "#d97706" }, children: validationResult.warnings.map((warning, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: warning }, index)) })
|
|
1403
1572
|
] })
|
|
1404
1573
|
] }),
|
|
1405
|
-
/* @__PURE__ */ (0,
|
|
1574
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
1406
1575
|
flex: 1,
|
|
1407
1576
|
display: "flex",
|
|
1408
1577
|
alignItems: "center",
|
|
@@ -1410,14 +1579,14 @@ var EmailPreview = ({
|
|
|
1410
1579
|
backgroundColor: "#f3f4f6",
|
|
1411
1580
|
padding: "20px",
|
|
1412
1581
|
overflow: "auto"
|
|
1413
|
-
}, children: loading ? /* @__PURE__ */ (0,
|
|
1582
|
+
}, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { textAlign: "center", color: "#6b7280" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: "Loading preview..." }) }) : html ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
1414
1583
|
backgroundColor: "white",
|
|
1415
1584
|
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
|
|
1416
1585
|
borderRadius: "8px",
|
|
1417
1586
|
overflow: "hidden",
|
|
1418
1587
|
transform: `scale(${viewport.scale})`,
|
|
1419
1588
|
transformOrigin: "top center"
|
|
1420
|
-
}, children: /* @__PURE__ */ (0,
|
|
1589
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1421
1590
|
"iframe",
|
|
1422
1591
|
{
|
|
1423
1592
|
ref: iframeRef,
|
|
@@ -1430,8 +1599,8 @@ var EmailPreview = ({
|
|
|
1430
1599
|
},
|
|
1431
1600
|
sandbox: "allow-same-origin"
|
|
1432
1601
|
}
|
|
1433
|
-
) }) : /* @__PURE__ */ (0,
|
|
1434
|
-
validationResult && /* @__PURE__ */ (0,
|
|
1602
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { textAlign: "center", color: "#6b7280" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: "Start typing to see the email preview" }) }) }),
|
|
1603
|
+
validationResult && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
|
|
1435
1604
|
padding: "12px 16px",
|
|
1436
1605
|
borderTop: "1px solid #e5e7eb",
|
|
1437
1606
|
fontSize: "13px",
|
|
@@ -1439,20 +1608,20 @@ var EmailPreview = ({
|
|
|
1439
1608
|
display: "flex",
|
|
1440
1609
|
gap: "24px"
|
|
1441
1610
|
}, children: [
|
|
1442
|
-
/* @__PURE__ */ (0,
|
|
1611
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
1443
1612
|
"Size: ",
|
|
1444
1613
|
Math.round(validationResult.stats.sizeInBytes / 1024),
|
|
1445
1614
|
"KB"
|
|
1446
1615
|
] }),
|
|
1447
|
-
/* @__PURE__ */ (0,
|
|
1616
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
1448
1617
|
"Links: ",
|
|
1449
1618
|
validationResult.stats.linkCount
|
|
1450
1619
|
] }),
|
|
1451
|
-
/* @__PURE__ */ (0,
|
|
1620
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
1452
1621
|
"Images: ",
|
|
1453
1622
|
validationResult.stats.imageCount
|
|
1454
1623
|
] }),
|
|
1455
|
-
/* @__PURE__ */ (0,
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
1456
1625
|
"Viewport: ",
|
|
1457
1626
|
mode === "desktop" ? "600px" : "320px"
|
|
1458
1627
|
] })
|
|
@@ -1476,13 +1645,14 @@ function escapeHtml2(text) {
|
|
|
1476
1645
|
}
|
|
1477
1646
|
|
|
1478
1647
|
// src/components/Broadcasts/EmailPreviewField.tsx
|
|
1479
|
-
var
|
|
1648
|
+
var import_react7 = require("react");
|
|
1480
1649
|
var import_ui = require("@payloadcms/ui");
|
|
1481
|
-
var
|
|
1650
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1482
1651
|
var EmailPreviewField = () => {
|
|
1483
|
-
const [previewMode, setPreviewMode] = (0,
|
|
1484
|
-
const [isValid, setIsValid] = (0,
|
|
1485
|
-
const [validationSummary, setValidationSummary] = (0,
|
|
1652
|
+
const [previewMode, setPreviewMode] = (0, import_react7.useState)("desktop");
|
|
1653
|
+
const [isValid, setIsValid] = (0, import_react7.useState)(true);
|
|
1654
|
+
const [validationSummary, setValidationSummary] = (0, import_react7.useState)("");
|
|
1655
|
+
const pluginConfig = usePluginConfigOptional();
|
|
1486
1656
|
const fields = (0, import_ui.useFormFields)(([fields2]) => ({
|
|
1487
1657
|
content: fields2["contentSection.content"],
|
|
1488
1658
|
subject: fields2["subject"],
|
|
@@ -1524,13 +1694,13 @@ var EmailPreviewField = () => {
|
|
|
1524
1694
|
alert(error instanceof Error ? error.message : "Failed to send test email");
|
|
1525
1695
|
}
|
|
1526
1696
|
};
|
|
1527
|
-
return /* @__PURE__ */ (0,
|
|
1697
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
|
|
1528
1698
|
marginTop: "24px",
|
|
1529
1699
|
border: "1px solid #e5e7eb",
|
|
1530
1700
|
borderRadius: "8px",
|
|
1531
1701
|
overflow: "hidden"
|
|
1532
1702
|
}, children: [
|
|
1533
|
-
/* @__PURE__ */ (0,
|
|
1703
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
|
|
1534
1704
|
display: "flex",
|
|
1535
1705
|
alignItems: "center",
|
|
1536
1706
|
justifyContent: "space-between",
|
|
@@ -1538,10 +1708,10 @@ var EmailPreviewField = () => {
|
|
|
1538
1708
|
borderBottom: "1px solid #e5e7eb",
|
|
1539
1709
|
backgroundColor: "#f9fafb"
|
|
1540
1710
|
}, children: [
|
|
1541
|
-
/* @__PURE__ */ (0,
|
|
1542
|
-
/* @__PURE__ */ (0,
|
|
1543
|
-
/* @__PURE__ */ (0,
|
|
1544
|
-
/* @__PURE__ */ (0,
|
|
1711
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "16px" }, children: [
|
|
1712
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Email Preview" }),
|
|
1713
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
1714
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1545
1715
|
"button",
|
|
1546
1716
|
{
|
|
1547
1717
|
type: "button",
|
|
@@ -1558,7 +1728,7 @@ var EmailPreviewField = () => {
|
|
|
1558
1728
|
children: "Desktop"
|
|
1559
1729
|
}
|
|
1560
1730
|
),
|
|
1561
|
-
/* @__PURE__ */ (0,
|
|
1731
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1562
1732
|
"button",
|
|
1563
1733
|
{
|
|
1564
1734
|
type: "button",
|
|
@@ -1576,7 +1746,7 @@ var EmailPreviewField = () => {
|
|
|
1576
1746
|
}
|
|
1577
1747
|
)
|
|
1578
1748
|
] }),
|
|
1579
|
-
validationSummary && /* @__PURE__ */ (0,
|
|
1749
|
+
validationSummary && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
|
|
1580
1750
|
padding: "6px 12px",
|
|
1581
1751
|
backgroundColor: isValid ? "#fef3c7" : "#fee2e2",
|
|
1582
1752
|
color: isValid ? "#92400e" : "#991b1b",
|
|
@@ -1584,7 +1754,7 @@ var EmailPreviewField = () => {
|
|
|
1584
1754
|
fontSize: "13px"
|
|
1585
1755
|
}, children: validationSummary })
|
|
1586
1756
|
] }),
|
|
1587
|
-
/* @__PURE__ */ (0,
|
|
1757
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1588
1758
|
"button",
|
|
1589
1759
|
{
|
|
1590
1760
|
type: "button",
|
|
@@ -1602,34 +1772,35 @@ var EmailPreviewField = () => {
|
|
|
1602
1772
|
}
|
|
1603
1773
|
)
|
|
1604
1774
|
] }),
|
|
1605
|
-
/* @__PURE__ */ (0,
|
|
1775
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { height: "600px" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1606
1776
|
EmailPreview,
|
|
1607
1777
|
{
|
|
1608
1778
|
content: fields.content?.value || null,
|
|
1609
1779
|
subject: fields.subject?.value || "Email Subject",
|
|
1610
1780
|
preheader: fields.preheader?.value,
|
|
1611
1781
|
mode: previewMode,
|
|
1612
|
-
onValidation: handleValidation
|
|
1782
|
+
onValidation: handleValidation,
|
|
1783
|
+
pluginConfig: pluginConfig || void 0
|
|
1613
1784
|
}
|
|
1614
1785
|
) })
|
|
1615
1786
|
] });
|
|
1616
1787
|
};
|
|
1617
1788
|
|
|
1618
1789
|
// src/components/Broadcasts/BroadcastEditor.tsx
|
|
1619
|
-
var
|
|
1790
|
+
var import_react8 = require("react");
|
|
1620
1791
|
var import_ui2 = require("@payloadcms/ui");
|
|
1621
|
-
var
|
|
1792
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1622
1793
|
var BroadcastEditor = (props) => {
|
|
1623
1794
|
const { value } = (0, import_ui2.useField)({ path: props.path });
|
|
1624
|
-
const [showPreview, setShowPreview] = (0,
|
|
1625
|
-
const [previewMode, setPreviewMode] = (0,
|
|
1626
|
-
const [isValid, setIsValid] = (0,
|
|
1627
|
-
const [validationSummary, setValidationSummary] = (0,
|
|
1795
|
+
const [showPreview, setShowPreview] = (0, import_react8.useState)(true);
|
|
1796
|
+
const [previewMode, setPreviewMode] = (0, import_react8.useState)("desktop");
|
|
1797
|
+
const [isValid, setIsValid] = (0, import_react8.useState)(true);
|
|
1798
|
+
const [validationSummary, setValidationSummary] = (0, import_react8.useState)("");
|
|
1628
1799
|
const fields = (0, import_ui2.useFormFields)(([fields2]) => ({
|
|
1629
1800
|
subject: fields2["subject"],
|
|
1630
1801
|
preheader: fields2["contentSection.preheader"]
|
|
1631
1802
|
}));
|
|
1632
|
-
const handleValidation = (0,
|
|
1803
|
+
const handleValidation = (0, import_react8.useCallback)((result) => {
|
|
1633
1804
|
setIsValid(result.valid);
|
|
1634
1805
|
const errorCount = result.errors.length;
|
|
1635
1806
|
const warningCount = result.warnings.length;
|
|
@@ -1664,8 +1835,8 @@ var BroadcastEditor = (props) => {
|
|
|
1664
1835
|
alert(error instanceof Error ? error.message : "Failed to send test email");
|
|
1665
1836
|
}
|
|
1666
1837
|
};
|
|
1667
|
-
return /* @__PURE__ */ (0,
|
|
1668
|
-
/* @__PURE__ */ (0,
|
|
1838
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { height: "600px", display: "flex", flexDirection: "column" }, children: [
|
|
1839
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: {
|
|
1669
1840
|
display: "flex",
|
|
1670
1841
|
alignItems: "center",
|
|
1671
1842
|
justifyContent: "space-between",
|
|
@@ -1673,8 +1844,8 @@ var BroadcastEditor = (props) => {
|
|
|
1673
1844
|
borderBottom: "1px solid #e5e7eb",
|
|
1674
1845
|
backgroundColor: "#f9fafb"
|
|
1675
1846
|
}, children: [
|
|
1676
|
-
/* @__PURE__ */ (0,
|
|
1677
|
-
/* @__PURE__ */ (0,
|
|
1847
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "16px" }, children: [
|
|
1848
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1678
1849
|
"button",
|
|
1679
1850
|
{
|
|
1680
1851
|
type: "button",
|
|
@@ -1691,8 +1862,8 @@ var BroadcastEditor = (props) => {
|
|
|
1691
1862
|
children: showPreview ? "Hide Preview" : "Show Preview"
|
|
1692
1863
|
}
|
|
1693
1864
|
),
|
|
1694
|
-
showPreview && /* @__PURE__ */ (0,
|
|
1695
|
-
/* @__PURE__ */ (0,
|
|
1865
|
+
showPreview && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
1866
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1696
1867
|
"button",
|
|
1697
1868
|
{
|
|
1698
1869
|
type: "button",
|
|
@@ -1709,7 +1880,7 @@ var BroadcastEditor = (props) => {
|
|
|
1709
1880
|
children: "Desktop"
|
|
1710
1881
|
}
|
|
1711
1882
|
),
|
|
1712
|
-
/* @__PURE__ */ (0,
|
|
1883
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1713
1884
|
"button",
|
|
1714
1885
|
{
|
|
1715
1886
|
type: "button",
|
|
@@ -1727,7 +1898,7 @@ var BroadcastEditor = (props) => {
|
|
|
1727
1898
|
}
|
|
1728
1899
|
)
|
|
1729
1900
|
] }),
|
|
1730
|
-
showPreview && validationSummary && /* @__PURE__ */ (0,
|
|
1901
|
+
showPreview && validationSummary && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
|
|
1731
1902
|
padding: "6px 12px",
|
|
1732
1903
|
backgroundColor: isValid ? "#fef3c7" : "#fee2e2",
|
|
1733
1904
|
color: isValid ? "#92400e" : "#991b1b",
|
|
@@ -1735,7 +1906,7 @@ var BroadcastEditor = (props) => {
|
|
|
1735
1906
|
fontSize: "13px"
|
|
1736
1907
|
}, children: validationSummary })
|
|
1737
1908
|
] }),
|
|
1738
|
-
showPreview && /* @__PURE__ */ (0,
|
|
1909
|
+
showPreview && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1739
1910
|
"button",
|
|
1740
1911
|
{
|
|
1741
1912
|
type: "button",
|
|
@@ -1753,13 +1924,13 @@ var BroadcastEditor = (props) => {
|
|
|
1753
1924
|
}
|
|
1754
1925
|
)
|
|
1755
1926
|
] }),
|
|
1756
|
-
/* @__PURE__ */ (0,
|
|
1757
|
-
/* @__PURE__ */ (0,
|
|
1927
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { flex: 1, display: "flex", overflow: "hidden" }, children: [
|
|
1928
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
|
|
1758
1929
|
flex: showPreview ? "0 0 50%" : "1",
|
|
1759
1930
|
overflow: "auto",
|
|
1760
1931
|
borderRight: showPreview ? "1px solid #e5e7eb" : "none"
|
|
1761
|
-
}, children: /* @__PURE__ */ (0,
|
|
1762
|
-
showPreview && /* @__PURE__ */ (0,
|
|
1932
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { padding: "16px" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rich-text-lexical" }) }) }),
|
|
1933
|
+
showPreview && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { flex: "0 0 50%", overflow: "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1763
1934
|
EmailPreview,
|
|
1764
1935
|
{
|
|
1765
1936
|
content: value,
|
|
@@ -1774,11 +1945,11 @@ var BroadcastEditor = (props) => {
|
|
|
1774
1945
|
};
|
|
1775
1946
|
|
|
1776
1947
|
// src/components/Broadcasts/BroadcastInlinePreview.tsx
|
|
1777
|
-
var
|
|
1948
|
+
var import_react9 = require("react");
|
|
1778
1949
|
var import_ui3 = require("@payloadcms/ui");
|
|
1779
1950
|
|
|
1780
1951
|
// src/components/Broadcasts/PreviewControls.tsx
|
|
1781
|
-
var
|
|
1952
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1782
1953
|
var PreviewControls = ({
|
|
1783
1954
|
onUpdate,
|
|
1784
1955
|
device,
|
|
@@ -1820,8 +1991,8 @@ var PreviewControls = ({
|
|
|
1820
1991
|
cursor: "pointer",
|
|
1821
1992
|
fontSize: "14px"
|
|
1822
1993
|
});
|
|
1823
|
-
return /* @__PURE__ */ (0,
|
|
1824
|
-
/* @__PURE__ */ (0,
|
|
1994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: controlsStyle, children: [
|
|
1995
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1825
1996
|
"button",
|
|
1826
1997
|
{
|
|
1827
1998
|
style: updateButtonStyle,
|
|
@@ -1830,33 +2001,33 @@ var PreviewControls = ({
|
|
|
1830
2001
|
children: isLoading ? "Updating..." : "Update Preview"
|
|
1831
2002
|
}
|
|
1832
2003
|
),
|
|
1833
|
-
/* @__PURE__ */ (0,
|
|
1834
|
-
/* @__PURE__ */ (0,
|
|
2004
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: deviceSelectorStyle, children: [
|
|
2005
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1835
2006
|
"button",
|
|
1836
2007
|
{
|
|
1837
2008
|
style: deviceButtonStyle(device === "desktop"),
|
|
1838
2009
|
onClick: () => onDeviceChange("desktop"),
|
|
1839
2010
|
"aria-label": "Desktop view",
|
|
1840
2011
|
children: [
|
|
1841
|
-
/* @__PURE__ */ (0,
|
|
1842
|
-
/* @__PURE__ */ (0,
|
|
1843
|
-
/* @__PURE__ */ (0,
|
|
1844
|
-
/* @__PURE__ */ (0,
|
|
2012
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
2013
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2", ry: "2" }),
|
|
2014
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
|
|
2015
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
|
|
1845
2016
|
] }),
|
|
1846
2017
|
"Desktop"
|
|
1847
2018
|
]
|
|
1848
2019
|
}
|
|
1849
2020
|
),
|
|
1850
|
-
/* @__PURE__ */ (0,
|
|
2021
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1851
2022
|
"button",
|
|
1852
2023
|
{
|
|
1853
2024
|
style: deviceButtonStyle(device === "mobile"),
|
|
1854
2025
|
onClick: () => onDeviceChange("mobile"),
|
|
1855
2026
|
"aria-label": "Mobile view",
|
|
1856
2027
|
children: [
|
|
1857
|
-
/* @__PURE__ */ (0,
|
|
1858
|
-
/* @__PURE__ */ (0,
|
|
1859
|
-
/* @__PURE__ */ (0,
|
|
2028
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
2029
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("rect", { x: "5", y: "2", width: "14", height: "20", rx: "2", ry: "2" }),
|
|
2030
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("line", { x1: "12", y1: "18", x2: "12", y2: "18" })
|
|
1860
2031
|
] }),
|
|
1861
2032
|
"Mobile"
|
|
1862
2033
|
]
|
|
@@ -1867,19 +2038,19 @@ var PreviewControls = ({
|
|
|
1867
2038
|
};
|
|
1868
2039
|
|
|
1869
2040
|
// src/components/Broadcasts/BroadcastInlinePreview.tsx
|
|
1870
|
-
var
|
|
2041
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1871
2042
|
var BroadcastInlinePreview = () => {
|
|
1872
|
-
const [device, setDevice] = (0,
|
|
1873
|
-
const [isLoading, setIsLoading] = (0,
|
|
1874
|
-
const [showPreview, setShowPreview] = (0,
|
|
1875
|
-
const [previewHtml, setPreviewHtml] = (0,
|
|
1876
|
-
const [error, setError] = (0,
|
|
2043
|
+
const [device, setDevice] = (0, import_react9.useState)("desktop");
|
|
2044
|
+
const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
|
|
2045
|
+
const [showPreview, setShowPreview] = (0, import_react9.useState)(false);
|
|
2046
|
+
const [previewHtml, setPreviewHtml] = (0, import_react9.useState)(null);
|
|
2047
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
1877
2048
|
const fields = (0, import_ui3.useFormFields)(([fields2]) => ({
|
|
1878
2049
|
subject: fields2["subject"]?.value,
|
|
1879
2050
|
preheader: fields2["contentSection.preheader"]?.value,
|
|
1880
2051
|
content: fields2["contentSection.content"]?.value
|
|
1881
2052
|
}));
|
|
1882
|
-
const updatePreview = (0,
|
|
2053
|
+
const updatePreview = (0, import_react9.useCallback)(async () => {
|
|
1883
2054
|
if (!fields.content) {
|
|
1884
2055
|
setError(new Error("Please add some content before previewing"));
|
|
1885
2056
|
return;
|
|
@@ -1954,10 +2125,10 @@ var BroadcastInlinePreview = () => {
|
|
|
1954
2125
|
fontSize: "14px",
|
|
1955
2126
|
fontWeight: 500
|
|
1956
2127
|
};
|
|
1957
|
-
return /* @__PURE__ */ (0,
|
|
1958
|
-
/* @__PURE__ */ (0,
|
|
1959
|
-
/* @__PURE__ */ (0,
|
|
1960
|
-
/* @__PURE__ */ (0,
|
|
2128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: containerStyle, children: [
|
|
2129
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: headerStyle, children: [
|
|
2130
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { style: titleStyle, children: "Email Preview" }),
|
|
2131
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1961
2132
|
"button",
|
|
1962
2133
|
{
|
|
1963
2134
|
onClick: () => showPreview ? setShowPreview(false) : updatePreview(),
|
|
@@ -1967,9 +2138,9 @@ var BroadcastInlinePreview = () => {
|
|
|
1967
2138
|
}
|
|
1968
2139
|
)
|
|
1969
2140
|
] }),
|
|
1970
|
-
showPreview && /* @__PURE__ */ (0,
|
|
1971
|
-
/* @__PURE__ */ (0,
|
|
1972
|
-
/* @__PURE__ */ (0,
|
|
2141
|
+
showPreview && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: previewContainerStyle, children: error ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: errorStyle, children: [
|
|
2142
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { style: { color: "#ef4444", margin: "0 0 1rem" }, children: error.message }),
|
|
2143
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1973
2144
|
"button",
|
|
1974
2145
|
{
|
|
1975
2146
|
onClick: updatePreview,
|
|
@@ -1984,8 +2155,8 @@ var BroadcastInlinePreview = () => {
|
|
|
1984
2155
|
children: "Retry"
|
|
1985
2156
|
}
|
|
1986
2157
|
)
|
|
1987
|
-
] }) : previewHtml ? /* @__PURE__ */ (0,
|
|
1988
|
-
/* @__PURE__ */ (0,
|
|
2158
|
+
] }) : previewHtml ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
2159
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1989
2160
|
PreviewControls,
|
|
1990
2161
|
{
|
|
1991
2162
|
onUpdate: updatePreview,
|
|
@@ -1994,7 +2165,7 @@ var BroadcastInlinePreview = () => {
|
|
|
1994
2165
|
isLoading
|
|
1995
2166
|
}
|
|
1996
2167
|
),
|
|
1997
|
-
/* @__PURE__ */ (0,
|
|
2168
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1998
2169
|
"div",
|
|
1999
2170
|
{
|
|
2000
2171
|
style: {
|
|
@@ -2004,7 +2175,7 @@ var BroadcastInlinePreview = () => {
|
|
|
2004
2175
|
justifyContent: "center",
|
|
2005
2176
|
overflow: "auto"
|
|
2006
2177
|
},
|
|
2007
|
-
children: /* @__PURE__ */ (0,
|
|
2178
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2008
2179
|
"div",
|
|
2009
2180
|
{
|
|
2010
2181
|
style: {
|
|
@@ -2015,7 +2186,7 @@ var BroadcastInlinePreview = () => {
|
|
|
2015
2186
|
borderRadius: "8px",
|
|
2016
2187
|
overflow: "hidden"
|
|
2017
2188
|
},
|
|
2018
|
-
children: /* @__PURE__ */ (0,
|
|
2189
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2019
2190
|
"iframe",
|
|
2020
2191
|
{
|
|
2021
2192
|
srcDoc: previewHtml,
|
|
@@ -2037,9 +2208,9 @@ var BroadcastInlinePreview = () => {
|
|
|
2037
2208
|
};
|
|
2038
2209
|
|
|
2039
2210
|
// src/components/Broadcasts/BroadcastPreviewField.tsx
|
|
2040
|
-
var
|
|
2211
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2041
2212
|
var BroadcastPreviewField = () => {
|
|
2042
|
-
return /* @__PURE__ */ (0,
|
|
2213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: {
|
|
2043
2214
|
padding: "1rem",
|
|
2044
2215
|
background: "#f9fafb",
|
|
2045
2216
|
borderRadius: "4px",
|
|
@@ -2049,22 +2220,22 @@ var BroadcastPreviewField = () => {
|
|
|
2049
2220
|
};
|
|
2050
2221
|
|
|
2051
2222
|
// src/components/Broadcasts/EmailRenderer.tsx
|
|
2052
|
-
var
|
|
2223
|
+
var import_react10 = require("react");
|
|
2053
2224
|
var import_render = require("@react-email/render");
|
|
2054
|
-
var
|
|
2225
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2055
2226
|
var EmailRenderer = ({
|
|
2056
2227
|
template,
|
|
2057
2228
|
data,
|
|
2058
2229
|
device = "desktop",
|
|
2059
2230
|
onRender
|
|
2060
2231
|
}) => {
|
|
2061
|
-
const [renderedHtml, setRenderedHtml] = (0,
|
|
2062
|
-
const [error, setError] = (0,
|
|
2063
|
-
const iframeRef = (0,
|
|
2064
|
-
const renderEmail = (0,
|
|
2232
|
+
const [renderedHtml, setRenderedHtml] = (0, import_react10.useState)("");
|
|
2233
|
+
const [error, setError] = (0, import_react10.useState)(null);
|
|
2234
|
+
const iframeRef = (0, import_react10.useRef)(null);
|
|
2235
|
+
const renderEmail = (0, import_react10.useCallback)(async () => {
|
|
2065
2236
|
try {
|
|
2066
2237
|
const TemplateComponent = template;
|
|
2067
|
-
const element = /* @__PURE__ */ (0,
|
|
2238
|
+
const element = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TemplateComponent, { ...data });
|
|
2068
2239
|
const html = await (0, import_render.render)(element, {
|
|
2069
2240
|
pretty: true
|
|
2070
2241
|
});
|
|
@@ -2076,10 +2247,10 @@ var EmailRenderer = ({
|
|
|
2076
2247
|
console.error("Failed to render email template:", err);
|
|
2077
2248
|
}
|
|
2078
2249
|
}, [template, data, onRender]);
|
|
2079
|
-
(0,
|
|
2250
|
+
(0, import_react10.useEffect)(() => {
|
|
2080
2251
|
renderEmail();
|
|
2081
2252
|
}, [renderEmail]);
|
|
2082
|
-
(0,
|
|
2253
|
+
(0, import_react10.useEffect)(() => {
|
|
2083
2254
|
if (iframeRef.current && renderedHtml) {
|
|
2084
2255
|
const iframe = iframeRef.current;
|
|
2085
2256
|
const doc = iframe.contentDocument || iframe.contentWindow?.document;
|
|
@@ -2118,9 +2289,9 @@ var EmailRenderer = ({
|
|
|
2118
2289
|
maxWidth: "500px"
|
|
2119
2290
|
};
|
|
2120
2291
|
if (error) {
|
|
2121
|
-
return /* @__PURE__ */ (0,
|
|
2122
|
-
/* @__PURE__ */ (0,
|
|
2123
|
-
/* @__PURE__ */ (0,
|
|
2292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: errorStyle, children: [
|
|
2293
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { style: { color: "#ef4444", margin: "0 0 1rem" }, children: "Template Render Error" }),
|
|
2294
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("pre", { style: {
|
|
2124
2295
|
background: "#f9fafb",
|
|
2125
2296
|
padding: "1rem",
|
|
2126
2297
|
borderRadius: "4px",
|
|
@@ -2131,7 +2302,7 @@ var EmailRenderer = ({
|
|
|
2131
2302
|
}, children: error.message })
|
|
2132
2303
|
] });
|
|
2133
2304
|
}
|
|
2134
|
-
return /* @__PURE__ */ (0,
|
|
2305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: containerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2135
2306
|
"iframe",
|
|
2136
2307
|
{
|
|
2137
2308
|
ref: iframeRef,
|
|
@@ -2143,7 +2314,7 @@ var EmailRenderer = ({
|
|
|
2143
2314
|
};
|
|
2144
2315
|
|
|
2145
2316
|
// src/components/Broadcasts/StatusBadge.tsx
|
|
2146
|
-
var
|
|
2317
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2147
2318
|
var statusConfig = {
|
|
2148
2319
|
["draft" /* DRAFT */]: {
|
|
2149
2320
|
label: "Draft",
|
|
@@ -2191,7 +2362,7 @@ var statusConfig = {
|
|
|
2191
2362
|
var StatusBadge = ({ cellData }) => {
|
|
2192
2363
|
const status = cellData;
|
|
2193
2364
|
const config = statusConfig[status] || statusConfig["draft" /* DRAFT */];
|
|
2194
|
-
return /* @__PURE__ */ (0,
|
|
2365
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2195
2366
|
"span",
|
|
2196
2367
|
{
|
|
2197
2368
|
style: {
|
|
@@ -2216,21 +2387,21 @@ var EmptyField = () => {
|
|
|
2216
2387
|
|
|
2217
2388
|
// src/email-templates/DefaultBroadcastTemplate.tsx
|
|
2218
2389
|
var import_components2 = require("@react-email/components");
|
|
2219
|
-
var
|
|
2390
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2220
2391
|
var DefaultBroadcastTemplate = ({
|
|
2221
2392
|
subject,
|
|
2222
2393
|
preheader,
|
|
2223
2394
|
content
|
|
2224
2395
|
}) => {
|
|
2225
|
-
return /* @__PURE__ */ (0,
|
|
2226
|
-
/* @__PURE__ */ (0,
|
|
2227
|
-
/* @__PURE__ */ (0,
|
|
2228
|
-
/* @__PURE__ */ (0,
|
|
2229
|
-
/* @__PURE__ */ (0,
|
|
2230
|
-
/* @__PURE__ */ (0,
|
|
2231
|
-
/* @__PURE__ */ (0,
|
|
2232
|
-
/* @__PURE__ */ (0,
|
|
2233
|
-
/* @__PURE__ */ (0,
|
|
2396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_components2.Html, { children: [
|
|
2397
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Head, {}),
|
|
2398
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Preview, { children: preheader || subject }),
|
|
2399
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Body, { style: main, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_components2.Container, { style: container, children: [
|
|
2400
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Section, { style: contentSection, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { dangerouslySetInnerHTML: { __html: content } }) }),
|
|
2401
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Hr, { style: divider }),
|
|
2402
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_components2.Section, { style: footer, children: [
|
|
2403
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Text, { style: footerText, children: "You're receiving this email because you subscribed to our newsletter." }),
|
|
2404
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Text, { style: footerText, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Link, { href: "{{unsubscribe_url}}", style: footerLink, children: "Unsubscribe" }) })
|
|
2234
2405
|
] })
|
|
2235
2406
|
] }) })
|
|
2236
2407
|
] });
|