payload-plugin-newsletter 0.18.0 → 0.19.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.
@@ -1024,9 +1024,9 @@ async function convertParagraph(node, mediaUrl, customBlockConverter) {
1024
1024
  );
1025
1025
  const children = childParts.join("");
1026
1026
  if (!children.trim()) {
1027
- return '<p style="margin: 0 0 16px 0; min-height: 1em;">&nbsp;</p>';
1027
+ return '<p class="mobile-margin-bottom-16" style="margin: 0 0 16px 0; min-height: 1em;">&nbsp;</p>';
1028
1028
  }
1029
- return `<p style="margin: 0 0 16px 0; text-align: ${align};">${children}</p>`;
1029
+ 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
1030
  }
1031
1031
  async function convertHeading(node, mediaUrl, customBlockConverter) {
1032
1032
  const tag = node.tag || "h1";
@@ -1040,8 +1040,14 @@ async function convertHeading(node, mediaUrl, customBlockConverter) {
1040
1040
  h2: "font-size: 24px; font-weight: 600; margin: 0 0 16px 0; line-height: 1.3;",
1041
1041
  h3: "font-size: 20px; font-weight: 600; margin: 0 0 12px 0; line-height: 1.4;"
1042
1042
  };
1043
+ const mobileClasses = {
1044
+ h1: "mobile-font-size-24",
1045
+ h2: "mobile-font-size-20",
1046
+ h3: "mobile-font-size-16"
1047
+ };
1043
1048
  const style = `${styles[tag] || styles.h3} text-align: ${align};`;
1044
- return `<${tag} style="${style}">${children}</${tag}>`;
1049
+ const mobileClass = mobileClasses[tag] || mobileClasses.h3;
1050
+ return `<${tag} class="${mobileClass}" style="${style}">${children}</${tag}>`;
1045
1051
  }
1046
1052
  async function convertList(node, mediaUrl, customBlockConverter) {
1047
1053
  const tag = node.listType === "number" ? "ol" : "ul";
@@ -1049,8 +1055,8 @@ async function convertList(node, mediaUrl, customBlockConverter) {
1049
1055
  (node.children || []).map((child) => convertNode(child, mediaUrl, customBlockConverter))
1050
1056
  );
1051
1057
  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}>`;
1058
+ 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;";
1059
+ return `<${tag} class="mobile-margin-bottom-16" style="${style}">${children}</${tag}>`;
1054
1060
  }
1055
1061
  async function convertListItem(node, mediaUrl, customBlockConverter) {
1056
1062
  const childParts = await Promise.all(
@@ -1107,16 +1113,16 @@ function convertUpload(node, mediaUrl) {
1107
1113
  }
1108
1114
  const alt = node.fields?.altText || upload.alt || "";
1109
1115
  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;" />`;
1116
+ 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
1117
  if (caption) {
1112
1118
  return `
1113
- <div style="margin: 0 0 16px 0; text-align: center;">
1119
+ <div style="margin: 0 0 16px 0; text-align: center;" class="mobile-margin-bottom-16">
1114
1120
  ${imgHtml}
1115
- <p style="margin: 8px 0 0 0; font-size: 14px; color: #6b7280; font-style: italic;">${escapeHtml(caption)}</p>
1121
+ <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
1122
  </div>
1117
1123
  `;
1118
1124
  }
1119
- return `<div style="margin: 0 0 16px 0; text-align: center;">${imgHtml}</div>`;
1125
+ return `<div style="margin: 0 0 16px 0; text-align: center;" class="mobile-margin-bottom-16">${imgHtml}</div>`;
1120
1126
  }
1121
1127
  async function convertBlock(node, mediaUrl, customBlockConverter) {
1122
1128
  const blockType = node.fields?.blockName || node.blockName;
@@ -1189,11 +1195,14 @@ function escapeHtml(text) {
1189
1195
  }
1190
1196
  function wrapInEmailTemplate(content, preheader) {
1191
1197
  return `<!DOCTYPE html>
1192
- <html lang="en">
1198
+ <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
1199
  <head>
1194
1200
  <meta charset="UTF-8">
1195
1201
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
1196
- <title>Email</title>
1202
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
1203
+ <meta name="x-apple-disable-message-reformatting">
1204
+ <title>Newsletter</title>
1205
+
1197
1206
  <!--[if mso]>
1198
1207
  <noscript>
1199
1208
  <xml>
@@ -1203,16 +1212,155 @@ function wrapInEmailTemplate(content, preheader) {
1203
1212
  </xml>
1204
1213
  </noscript>
1205
1214
  <![endif]-->
1215
+
1216
+ <style>
1217
+ /* Reset and base styles */
1218
+ * {
1219
+ -webkit-text-size-adjust: 100%;
1220
+ -ms-text-size-adjust: 100%;
1221
+ }
1222
+
1223
+ body {
1224
+ margin: 0 !important;
1225
+ padding: 0 !important;
1226
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
1227
+ font-size: 16px;
1228
+ line-height: 1.5;
1229
+ color: #1A1A1A;
1230
+ background-color: #f8f9fa;
1231
+ -webkit-font-smoothing: antialiased;
1232
+ -moz-osx-font-smoothing: grayscale;
1233
+ }
1234
+
1235
+ table {
1236
+ border-spacing: 0 !important;
1237
+ border-collapse: collapse !important;
1238
+ table-layout: fixed !important;
1239
+ margin: 0 auto !important;
1240
+ }
1241
+
1242
+ table table table {
1243
+ table-layout: auto;
1244
+ }
1245
+
1246
+ img {
1247
+ -ms-interpolation-mode: bicubic;
1248
+ max-width: 100%;
1249
+ height: auto;
1250
+ border: 0;
1251
+ outline: none;
1252
+ text-decoration: none;
1253
+ }
1254
+
1255
+ /* Responsive styles */
1256
+ @media only screen and (max-width: 640px) {
1257
+ .mobile-hide {
1258
+ display: none !important;
1259
+ }
1260
+
1261
+ .mobile-center {
1262
+ text-align: center !important;
1263
+ }
1264
+
1265
+ .mobile-width-100 {
1266
+ width: 100% !important;
1267
+ max-width: 100% !important;
1268
+ }
1269
+
1270
+ .mobile-padding {
1271
+ padding: 20px !important;
1272
+ }
1273
+
1274
+ .mobile-padding-sm {
1275
+ padding: 16px !important;
1276
+ }
1277
+
1278
+ .mobile-font-size-14 {
1279
+ font-size: 14px !important;
1280
+ }
1281
+
1282
+ .mobile-font-size-16 {
1283
+ font-size: 16px !important;
1284
+ }
1285
+
1286
+ .mobile-font-size-20 {
1287
+ font-size: 20px !important;
1288
+ line-height: 1.3 !important;
1289
+ }
1290
+
1291
+ .mobile-font-size-24 {
1292
+ font-size: 24px !important;
1293
+ line-height: 1.2 !important;
1294
+ }
1295
+
1296
+ /* Stack sections on mobile */
1297
+ .mobile-stack {
1298
+ display: block !important;
1299
+ width: 100% !important;
1300
+ }
1301
+
1302
+ /* Mobile-specific spacing */
1303
+ .mobile-margin-bottom-16 {
1304
+ margin-bottom: 16px !important;
1305
+ }
1306
+
1307
+ .mobile-margin-bottom-20 {
1308
+ margin-bottom: 20px !important;
1309
+ }
1310
+ }
1311
+
1312
+ /* Dark mode support */
1313
+ @media (prefers-color-scheme: dark) {
1314
+ .dark-mode-bg {
1315
+ background-color: #1a1a1a !important;
1316
+ }
1317
+
1318
+ .dark-mode-text {
1319
+ color: #ffffff !important;
1320
+ }
1321
+
1322
+ .dark-mode-border {
1323
+ border-color: #333333 !important;
1324
+ }
1325
+ }
1326
+
1327
+ /* Outlook-specific fixes */
1328
+ <!--[if mso]>
1329
+ <style>
1330
+ table {
1331
+ border-collapse: collapse;
1332
+ border-spacing: 0;
1333
+ border: none;
1334
+ margin: 0;
1335
+ }
1336
+
1337
+ div, p {
1338
+ margin: 0;
1339
+ }
1340
+ </style>
1341
+ <![endif]-->
1342
+ </style>
1206
1343
  </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: #333333; background-color: #f3f4f6;">
1208
- ${preheader ? `<div style="display: none; max-height: 0; overflow: hidden;">${escapeHtml(preheader)}</div>` : ""}
1209
- <table role="presentation" cellpadding="0" cellspacing="0" width="100%" style="margin: 0; padding: 0;">
1344
+ <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;">
1345
+ ${preheader ? `
1346
+ <!-- Preheader text -->
1347
+ <div style="display: none; max-height: 0; overflow: hidden; font-size: 1px; line-height: 1px; color: transparent;">
1348
+ ${escapeHtml(preheader)}
1349
+ </div>
1350
+ ` : ""}
1351
+
1352
+ <!-- Main container -->
1353
+ <table role="presentation" cellpadding="0" cellspacing="0" width="100%" style="margin: 0; padding: 0; background-color: #f8f9fa;">
1210
1354
  <tr>
1211
- <td align="center" style="padding: 20px 0;">
1212
- <table role="presentation" cellpadding="0" cellspacing="0" width="600" style="margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden;">
1355
+ <td align="center" style="padding: 20px 10px;">
1356
+ <!-- Email wrapper -->
1357
+ <table role="presentation" cellpadding="0" cellspacing="0" width="600" class="mobile-width-100" style="margin: 0 auto; max-width: 600px;">
1213
1358
  <tr>
1214
- <td style="padding: 40px 30px;">
1215
- ${content}
1359
+ <td class="mobile-padding" style="padding: 0;">
1360
+ <!-- Content area with light background -->
1361
+ <div style="background-color: #ffffff; padding: 40px 30px; border-radius: 8px;" class="mobile-padding">
1362
+ ${content}
1363
+ </div>
1216
1364
  </td>
1217
1365
  </tr>
1218
1366
  </table>