email-builder-utils 1.1.15 → 1.1.20
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,
|
|
1
|
+
{"version":3,"file":"convertJsonToHtml.d.ts","sourceRoot":"","sources":["../../src/utils/convertJsonToHtml.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,GAAU,UAAU,GAAG,oBAgFpD,CAAC"}
|
|
@@ -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;
|
|
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"}
|
package/dist/utils/jsonToHTML.js
CHANGED
|
@@ -111,15 +111,40 @@ function convertSpacerBlockToHtml(blockData) {
|
|
|
111
111
|
});
|
|
112
112
|
return appendOutlookSupport(``, styles);
|
|
113
113
|
}
|
|
114
|
+
// function convertTextBlock(blockData: IBlockData) {
|
|
115
|
+
// const { style, props } = blockData.data;
|
|
116
|
+
// const styles = buildStyles(style, {
|
|
117
|
+
// perChanges: [],
|
|
118
|
+
// pxChanges: allPxAttributes,
|
|
119
|
+
// });
|
|
120
|
+
// const text = props.text || "";
|
|
121
|
+
// const navigateToUrl = props.navigateToUrl || "";
|
|
122
|
+
// const textContent = appendOutlookSupport(
|
|
123
|
+
// text.replaceAll(/\n/g, "<br>"),
|
|
124
|
+
// styles
|
|
125
|
+
// );
|
|
126
|
+
// return navigateToUrl
|
|
127
|
+
// ? `<a href="${navigateToUrl}" rel="noreferrer noopener" style="color:inherit; text-decoration:none; cursor:pointer;">${textContent}</a>`
|
|
128
|
+
// : textContent;
|
|
129
|
+
// }
|
|
114
130
|
function convertTextBlock(blockData) {
|
|
115
131
|
const { style, props } = blockData.data;
|
|
116
|
-
const
|
|
132
|
+
const { width, backgroundColor, padding, borderRadius, borderStyle, borderColor, borderWidth, textContainerBackgroundColor, textContainerPadding, ...rest } = style;
|
|
133
|
+
const textBoxStyle = { width, backgroundColor, padding, borderRadius, borderStyle, borderColor, borderWidth };
|
|
134
|
+
const convertedTextStyle = buildStyles(textBoxStyle, {
|
|
135
|
+
perChanges: [],
|
|
136
|
+
pxChanges: allPxAttributes,
|
|
137
|
+
});
|
|
138
|
+
const styles = buildStyles({ padding: textContainerPadding, backgroundColor: textContainerBackgroundColor, ...rest }, {
|
|
117
139
|
perChanges: [],
|
|
118
140
|
pxChanges: allPxAttributes,
|
|
119
141
|
});
|
|
120
|
-
const
|
|
142
|
+
const sanitizedText = (props.text ?? "")
|
|
143
|
+
.replaceAll(/<p>/g, "<div>")
|
|
144
|
+
.replaceAll(/<\/p>/g, "</div>");
|
|
121
145
|
const navigateToUrl = props.navigateToUrl || "";
|
|
122
|
-
const
|
|
146
|
+
const convertedTextBox = `<div style="display: inline-block; max-width: 100%; box-sizing: border-box; ${convertedTextStyle}">${sanitizedText.replaceAll(/\n/g, "<br>")}</div>`;
|
|
147
|
+
const textContent = appendOutlookSupport(convertedTextBox, styles);
|
|
123
148
|
return navigateToUrl
|
|
124
149
|
? `<a href="${navigateToUrl}" rel="noreferrer noopener" style="color:inherit; text-decoration:none; cursor:pointer;">${textContent}</a>`
|
|
125
150
|
: textContent;
|
|
@@ -237,7 +262,7 @@ function convertButtonBlock(blockData) {
|
|
|
237
262
|
perChanges: [],
|
|
238
263
|
pxChanges: allPxAttributes,
|
|
239
264
|
});
|
|
240
|
-
const convertedStyles = buildStyles(rest, {
|
|
265
|
+
const convertedStyles = buildStyles({ maxWidth: "100%", boxSizing: "border-box", ...rest }, {
|
|
241
266
|
perChanges: [],
|
|
242
267
|
pxChanges: allPxAttributes,
|
|
243
268
|
});
|
|
@@ -247,7 +272,7 @@ function convertButtonBlock(blockData) {
|
|
|
247
272
|
}
|
|
248
273
|
async function convertGridBlock(blockData, rootData, cellWidthInPx) {
|
|
249
274
|
const { style = {}, childrenIds = [], props } = blockData.data;
|
|
250
|
-
const { columns = 1, cellWidths = [] } = props;
|
|
275
|
+
const { columns = 1, cellWidths = [], responsive = true } = props;
|
|
251
276
|
const { columnGap = 0, ...restStyle } = style;
|
|
252
277
|
const tableStyles = buildStyles(restStyle, {
|
|
253
278
|
perChanges: [],
|
|
@@ -271,20 +296,18 @@ async function convertGridBlock(blockData, rootData, cellWidthInPx) {
|
|
|
271
296
|
const child = rootData[childId];
|
|
272
297
|
const { style: cellStyle = {} } = child.data || {};
|
|
273
298
|
const verticalAlign = cellStyle.verticalAlign || "top";
|
|
274
|
-
const childHtml = child
|
|
275
|
-
? await convertGridCellBlock(child, rootData, widthPercent, cellWidthInPx)
|
|
276
|
-
: "";
|
|
299
|
+
const { html: childHtml, styles } = await convertGridCellBlock(child, rootData, widthPercent, cellWidthInPx);
|
|
277
300
|
html += `
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
301
|
+
<td
|
|
302
|
+
width="${widthPercent}%"
|
|
303
|
+
${responsive ? 'class="stack-column"' : ""}
|
|
304
|
+
style="vertical-align:${verticalAlign}; padding:0; word-break:break-word; ${styles}"
|
|
305
|
+
>
|
|
306
|
+
${childHtml}
|
|
307
|
+
</td>`;
|
|
285
308
|
}
|
|
286
309
|
else {
|
|
287
|
-
html += `<td width="${widthPercent}%" class="stack-column" style="padding:0;"></td>`;
|
|
310
|
+
html += `<td width="${widthPercent}%" ${responsive ? 'class="stack-column"' : ""} style="padding:0;"></td>`;
|
|
288
311
|
}
|
|
289
312
|
}
|
|
290
313
|
html += "</tr>";
|
|
@@ -306,20 +329,8 @@ async function convertGridCellBlock(blockData, rootData, cellWidthPercent, paren
|
|
|
306
329
|
innerHtmlParts.push(await convertToHtml(child, rootData, cellWidthPx));
|
|
307
330
|
}
|
|
308
331
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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>`;
|
|
332
|
+
return {
|
|
333
|
+
html: innerHtmlParts.join(""),
|
|
334
|
+
styles,
|
|
335
|
+
};
|
|
325
336
|
}
|