email-builder-utils 1.1.19 → 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.
- package/dist/utils/jsonToHTML.js +29 -4
- package/package.json +1 -1
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
|
});
|