email-builder-utils 1.1.15 → 1.1.19

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.
@@ -1 +1 @@
1
- {"version":3,"file":"convertJsonToHtml.d.ts","sourceRoot":"","sources":["../../src/utils/convertJsonToHtml.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,GAAU,UAAU,GAAG,oBA+EpD,CAAC"}
1
+ {"version":3,"file":"convertJsonToHtml.d.ts","sourceRoot":"","sources":["../../src/utils/convertJsonToHtml.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,GAAU,UAAU,GAAG,oBAgFpD,CAAC"}
@@ -40,6 +40,7 @@ const convertJsonToHtml = async (jsonData) => {
40
40
  <center>
41
41
  <table
42
42
  class="responsive-table"
43
+ bgcolor="${canvasColor}"
43
44
  style="
44
45
  font-family: ${fontFamily};
45
46
  margin: 0 auto;
@@ -7,6 +7,7 @@ interface BlockJsonProps {
7
7
  text: string;
8
8
  altText: string;
9
9
  imageUrl: string;
10
+ responsive?: boolean;
10
11
  }
11
12
  interface IBlockData {
12
13
  type: BlockType;
@@ -1 +1 @@
1
- {"version":3,"file":"jsonToHTML.d.ts","sourceRoot":"","sources":["../../src/utils/jsonToHTML.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AASrC,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,UAAU;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE;QACJ,KAAK,EAAE,cAAc,CAAC;QACtB,KAAK,EAAE,GAAG,CAAC;QACX,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;KAC7B,CAAC;CACH;AAYD,eAAO,MAAM,gBAAgB,kDAAkD,CAAC;AA2DhF,wBAAsB,aAAa,CACjC,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,GAAG,EACb,aAAa,EAAE,MAAM,mBAkBtB"}
1
+ {"version":3,"file":"jsonToHTML.d.ts","sourceRoot":"","sources":["../../src/utils/jsonToHTML.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AASrC,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,UAAU;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE;QACJ,KAAK,EAAE,cAAc,CAAC;QACtB,KAAK,EAAE,GAAG,CAAC;QACX,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;KAC7B,CAAC;CACH;AAYD,eAAO,MAAM,gBAAgB,kDAAkD,CAAC;AA2DhF,wBAAsB,aAAa,CACjC,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,GAAG,EACb,aAAa,EAAE,MAAM,mBAkBtB"}
@@ -247,7 +247,7 @@ function convertButtonBlock(blockData) {
247
247
  }
248
248
  async function convertGridBlock(blockData, rootData, cellWidthInPx) {
249
249
  const { style = {}, childrenIds = [], props } = blockData.data;
250
- const { columns = 1, cellWidths = [] } = props;
250
+ const { columns = 1, cellWidths = [], responsive = true } = props;
251
251
  const { columnGap = 0, ...restStyle } = style;
252
252
  const tableStyles = buildStyles(restStyle, {
253
253
  perChanges: [],
@@ -271,20 +271,18 @@ async function convertGridBlock(blockData, rootData, cellWidthInPx) {
271
271
  const child = rootData[childId];
272
272
  const { style: cellStyle = {} } = child.data || {};
273
273
  const verticalAlign = cellStyle.verticalAlign || "top";
274
- const childHtml = child
275
- ? await convertGridCellBlock(child, rootData, widthPercent, cellWidthInPx)
276
- : "";
274
+ const { html: childHtml, styles } = await convertGridCellBlock(child, rootData, widthPercent, cellWidthInPx);
277
275
  html += `
278
- <td
279
- width="${widthPercent}%"
280
- class="stack-column"
281
- style="vertical-align:${verticalAlign}; padding:0; word-break:break-word;"
282
- >
283
- ${childHtml}
284
- </td>`;
276
+ <td
277
+ width="${widthPercent}%"
278
+ ${responsive ? 'class="stack-column"' : ""}
279
+ style="vertical-align:${verticalAlign}; padding:0; word-break:break-word; ${styles}"
280
+ >
281
+ ${childHtml}
282
+ </td>`;
285
283
  }
286
284
  else {
287
- html += `<td width="${widthPercent}%" class="stack-column" style="padding:0;"></td>`;
285
+ html += `<td width="${widthPercent}%" ${responsive ? 'class="stack-column"' : ""} style="padding:0;"></td>`;
288
286
  }
289
287
  }
290
288
  html += "</tr>";
@@ -306,20 +304,8 @@ async function convertGridCellBlock(blockData, rootData, cellWidthPercent, paren
306
304
  innerHtmlParts.push(await convertToHtml(child, rootData, cellWidthPx));
307
305
  }
308
306
  }
309
- const innerContent = innerHtmlParts.join("");
310
- return `
311
- <table
312
- role="presentation"
313
- border="0"
314
- cellpadding="0"
315
- cellspacing="0"
316
- width="100%"
317
- style="border-collapse:collapse;table-layout:fixed;${styles}"
318
- >
319
- <tr>
320
- <td style="padding:0;">
321
- ${innerContent}
322
- </td>
323
- </tr>
324
- </table>`;
307
+ return {
308
+ html: innerHtmlParts.join(""),
309
+ styles,
310
+ };
325
311
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "email-builder-utils",
3
- "version": "1.1.15",
3
+ "version": "1.1.19",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [