email-builder-utils 1.0.12 → 1.0.13
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":"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;AASD,eAAO,MAAM,gBAAgB,kDAAkD,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;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;AASD,eAAO,MAAM,gBAAgB,kDAAkD,CAAC;AAyDhF,wBAAsB,aAAa,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,mBAiB9F"}
|
package/dist/utils/jsonToHTML.js
CHANGED
|
@@ -34,6 +34,9 @@ function buildStyles(style, { pxChanges, perChanges }) {
|
|
|
34
34
|
}
|
|
35
35
|
const stylesObj = {};
|
|
36
36
|
Object.entries(style).forEach(([key, value]) => {
|
|
37
|
+
if (key === "customCss") {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
37
40
|
const appendPx = pxChanges.includes(key);
|
|
38
41
|
const appendPer = perChanges.includes(key);
|
|
39
42
|
if (value === undefined || value === null || value === "")
|
|
@@ -54,7 +57,7 @@ function buildStyles(style, { pxChanges, perChanges }) {
|
|
|
54
57
|
}
|
|
55
58
|
return;
|
|
56
59
|
});
|
|
57
|
-
return jsonToPlainString(cleanJson(stylesObj)).trim();
|
|
60
|
+
return `${jsonToPlainString(cleanJson(stylesObj))}${style.customCss || ""}`.trim();
|
|
58
61
|
}
|
|
59
62
|
async function convertToHtml(blockData, rootData, cellWidthInPx) {
|
|
60
63
|
switch (blockData.type) {
|
|
@@ -109,7 +112,7 @@ async function appendOutlookForImage(content, outerContainerWidth, innerContaine
|
|
|
109
112
|
const scaledHeight = Math.round(originalHeight * widthScalingFactor); // Maintain aspect ratio
|
|
110
113
|
// VML for Outlook
|
|
111
114
|
const outlookImage = `<!--[if mso]>
|
|
112
|
-
<v:rect xmlns:v="urn:schemas-microsoft-com:vml"
|
|
115
|
+
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" style="width:${scaledWidth}px;height:${scaledHeight}px;">
|
|
113
116
|
<v:fill src="${imageUrl}" type="frame" />
|
|
114
117
|
</v:rect>
|
|
115
118
|
<![endif]-->`;
|
|
@@ -151,8 +154,10 @@ function appendOutlookForButton(content, buttonStyle, navigateToUrl, text) {
|
|
|
151
154
|
function convertButtonBlock(blockData) {
|
|
152
155
|
const { style, props } = blockData.data;
|
|
153
156
|
const { text, navigateToUrl } = props;
|
|
154
|
-
const { fontFamily, fontSize, fontWeight, borderColor, borderRadius, borderWidth, borderStyle, buttonPadding, textColor, buttonColor, ...rest } = style;
|
|
157
|
+
const { fontFamily, fontSize, fontWeight, borderColor, borderRadius, borderWidth, borderStyle, buttonPadding, textColor, buttonColor, width, height, ...rest } = style;
|
|
155
158
|
const buttonStyle = {
|
|
159
|
+
width,
|
|
160
|
+
height,
|
|
156
161
|
fontFamily,
|
|
157
162
|
fontSize,
|
|
158
163
|
fontWeight,
|