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.
@@ -973,9 +973,9 @@ async function convertParagraph(node, mediaUrl, customBlockConverter) {
973
973
  );
974
974
  const children = childParts.join("");
975
975
  if (!children.trim()) {
976
- return '<p style="margin: 0 0 16px 0; min-height: 1em;">&nbsp;</p>';
976
+ return '<p class="mobile-margin-bottom-16" style="margin: 0 0 16px 0; min-height: 1em;">&nbsp;</p>';
977
977
  }
978
- return `<p style="margin: 0 0 16px 0; text-align: ${align};">${children}</p>`;
978
+ 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
979
  }
980
980
  async function convertHeading(node, mediaUrl, customBlockConverter) {
981
981
  const tag = node.tag || "h1";
@@ -989,8 +989,14 @@ async function convertHeading(node, mediaUrl, customBlockConverter) {
989
989
  h2: "font-size: 24px; font-weight: 600; margin: 0 0 16px 0; line-height: 1.3;",
990
990
  h3: "font-size: 20px; font-weight: 600; margin: 0 0 12px 0; line-height: 1.4;"
991
991
  };
992
+ const mobileClasses = {
993
+ h1: "mobile-font-size-24",
994
+ h2: "mobile-font-size-20",
995
+ h3: "mobile-font-size-16"
996
+ };
992
997
  const style = `${styles[tag] || styles.h3} text-align: ${align};`;
993
- return `<${tag} style="${style}">${children}</${tag}>`;
998
+ const mobileClass = mobileClasses[tag] || mobileClasses.h3;
999
+ return `<${tag} class="${mobileClass}" style="${style}">${children}</${tag}>`;
994
1000
  }
995
1001
  async function convertList(node, mediaUrl, customBlockConverter) {
996
1002
  const tag = node.listType === "number" ? "ol" : "ul";
@@ -998,8 +1004,8 @@ async function convertList(node, mediaUrl, customBlockConverter) {
998
1004
  (node.children || []).map((child) => convertNode(child, mediaUrl, customBlockConverter))
999
1005
  );
1000
1006
  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}>`;
1007
+ 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;";
1008
+ return `<${tag} class="mobile-margin-bottom-16" style="${style}">${children}</${tag}>`;
1003
1009
  }
1004
1010
  async function convertListItem(node, mediaUrl, customBlockConverter) {
1005
1011
  const childParts = await Promise.all(
@@ -1056,16 +1062,16 @@ function convertUpload(node, mediaUrl) {
1056
1062
  }
1057
1063
  const alt = node.fields?.altText || upload.alt || "";
1058
1064
  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;" />`;
1065
+ 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
1066
  if (caption) {
1061
1067
  return `
1062
- <div style="margin: 0 0 16px 0; text-align: center;">
1068
+ <div style="margin: 0 0 16px 0; text-align: center;" class="mobile-margin-bottom-16">
1063
1069
  ${imgHtml}
1064
- <p style="margin: 8px 0 0 0; font-size: 14px; color: #6b7280; font-style: italic;">${escapeHtml(caption)}</p>
1070
+ <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
1071
  </div>
1066
1072
  `;
1067
1073
  }
1068
- return `<div style="margin: 0 0 16px 0; text-align: center;">${imgHtml}</div>`;
1074
+ return `<div style="margin: 0 0 16px 0; text-align: center;" class="mobile-margin-bottom-16">${imgHtml}</div>`;
1069
1075
  }
1070
1076
  async function convertBlock(node, mediaUrl, customBlockConverter) {
1071
1077
  const blockType = node.fields?.blockName || node.blockName;
@@ -1138,11 +1144,14 @@ function escapeHtml(text) {
1138
1144
  }
1139
1145
  function wrapInEmailTemplate(content, preheader) {
1140
1146
  return `<!DOCTYPE html>
1141
- <html lang="en">
1147
+ <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
1148
  <head>
1143
1149
  <meta charset="UTF-8">
1144
1150
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
1145
- <title>Email</title>
1151
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
1152
+ <meta name="x-apple-disable-message-reformatting">
1153
+ <title>Newsletter</title>
1154
+
1146
1155
  <!--[if mso]>
1147
1156
  <noscript>
1148
1157
  <xml>
@@ -1152,16 +1161,155 @@ function wrapInEmailTemplate(content, preheader) {
1152
1161
  </xml>
1153
1162
  </noscript>
1154
1163
  <![endif]-->
1164
+
1165
+ <style>
1166
+ /* Reset and base styles */
1167
+ * {
1168
+ -webkit-text-size-adjust: 100%;
1169
+ -ms-text-size-adjust: 100%;
1170
+ }
1171
+
1172
+ body {
1173
+ margin: 0 !important;
1174
+ padding: 0 !important;
1175
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
1176
+ font-size: 16px;
1177
+ line-height: 1.5;
1178
+ color: #1A1A1A;
1179
+ background-color: #f8f9fa;
1180
+ -webkit-font-smoothing: antialiased;
1181
+ -moz-osx-font-smoothing: grayscale;
1182
+ }
1183
+
1184
+ table {
1185
+ border-spacing: 0 !important;
1186
+ border-collapse: collapse !important;
1187
+ table-layout: fixed !important;
1188
+ margin: 0 auto !important;
1189
+ }
1190
+
1191
+ table table table {
1192
+ table-layout: auto;
1193
+ }
1194
+
1195
+ img {
1196
+ -ms-interpolation-mode: bicubic;
1197
+ max-width: 100%;
1198
+ height: auto;
1199
+ border: 0;
1200
+ outline: none;
1201
+ text-decoration: none;
1202
+ }
1203
+
1204
+ /* Responsive styles */
1205
+ @media only screen and (max-width: 640px) {
1206
+ .mobile-hide {
1207
+ display: none !important;
1208
+ }
1209
+
1210
+ .mobile-center {
1211
+ text-align: center !important;
1212
+ }
1213
+
1214
+ .mobile-width-100 {
1215
+ width: 100% !important;
1216
+ max-width: 100% !important;
1217
+ }
1218
+
1219
+ .mobile-padding {
1220
+ padding: 20px !important;
1221
+ }
1222
+
1223
+ .mobile-padding-sm {
1224
+ padding: 16px !important;
1225
+ }
1226
+
1227
+ .mobile-font-size-14 {
1228
+ font-size: 14px !important;
1229
+ }
1230
+
1231
+ .mobile-font-size-16 {
1232
+ font-size: 16px !important;
1233
+ }
1234
+
1235
+ .mobile-font-size-20 {
1236
+ font-size: 20px !important;
1237
+ line-height: 1.3 !important;
1238
+ }
1239
+
1240
+ .mobile-font-size-24 {
1241
+ font-size: 24px !important;
1242
+ line-height: 1.2 !important;
1243
+ }
1244
+
1245
+ /* Stack sections on mobile */
1246
+ .mobile-stack {
1247
+ display: block !important;
1248
+ width: 100% !important;
1249
+ }
1250
+
1251
+ /* Mobile-specific spacing */
1252
+ .mobile-margin-bottom-16 {
1253
+ margin-bottom: 16px !important;
1254
+ }
1255
+
1256
+ .mobile-margin-bottom-20 {
1257
+ margin-bottom: 20px !important;
1258
+ }
1259
+ }
1260
+
1261
+ /* Dark mode support */
1262
+ @media (prefers-color-scheme: dark) {
1263
+ .dark-mode-bg {
1264
+ background-color: #1a1a1a !important;
1265
+ }
1266
+
1267
+ .dark-mode-text {
1268
+ color: #ffffff !important;
1269
+ }
1270
+
1271
+ .dark-mode-border {
1272
+ border-color: #333333 !important;
1273
+ }
1274
+ }
1275
+
1276
+ /* Outlook-specific fixes */
1277
+ <!--[if mso]>
1278
+ <style>
1279
+ table {
1280
+ border-collapse: collapse;
1281
+ border-spacing: 0;
1282
+ border: none;
1283
+ margin: 0;
1284
+ }
1285
+
1286
+ div, p {
1287
+ margin: 0;
1288
+ }
1289
+ </style>
1290
+ <![endif]-->
1291
+ </style>
1155
1292
  </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: #333333; background-color: #f3f4f6;">
1157
- ${preheader ? `<div style="display: none; max-height: 0; overflow: hidden;">${escapeHtml(preheader)}</div>` : ""}
1158
- <table role="presentation" cellpadding="0" cellspacing="0" width="100%" style="margin: 0; padding: 0;">
1293
+ <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;">
1294
+ ${preheader ? `
1295
+ <!-- Preheader text -->
1296
+ <div style="display: none; max-height: 0; overflow: hidden; font-size: 1px; line-height: 1px; color: transparent;">
1297
+ ${escapeHtml(preheader)}
1298
+ </div>
1299
+ ` : ""}
1300
+
1301
+ <!-- Main container -->
1302
+ <table role="presentation" cellpadding="0" cellspacing="0" width="100%" style="margin: 0; padding: 0; background-color: #f8f9fa;">
1159
1303
  <tr>
1160
- <td align="center" style="padding: 20px 0;">
1161
- <table role="presentation" cellpadding="0" cellspacing="0" width="600" style="margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden;">
1304
+ <td align="center" style="padding: 20px 10px;">
1305
+ <!-- Email wrapper -->
1306
+ <table role="presentation" cellpadding="0" cellspacing="0" width="600" class="mobile-width-100" style="margin: 0 auto; max-width: 600px;">
1162
1307
  <tr>
1163
- <td style="padding: 40px 30px;">
1164
- ${content}
1308
+ <td class="mobile-padding" style="padding: 0;">
1309
+ <!-- Content area with light background -->
1310
+ <div style="background-color: #ffffff; padding: 40px 30px; border-radius: 8px;" class="mobile-padding">
1311
+ ${content}
1312
+ </div>
1165
1313
  </td>
1166
1314
  </tr>
1167
1315
  </table>