email-builder-utils 1.1.5 → 1.1.9
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/types/Generics.d.ts +4 -4
- package/dist/types/Generics.js +4 -4
- package/dist/utils/jsonToHTML.js +54 -33
- package/package.json +1 -1
package/dist/types/Generics.d.ts
CHANGED
|
@@ -38,9 +38,9 @@ export declare enum FEATURE_TYPE {
|
|
|
38
38
|
GET_ORG = "GET_ORG",
|
|
39
39
|
DELETE_ORG = "DELETE_ORG",
|
|
40
40
|
UPDATE_ORG = "UPDATE_ORG",
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
ADD_ORG_USER = "ADD_ORG_USER",
|
|
42
|
+
LIST_ORG_USER = "LIST_ORG_USER",
|
|
43
|
+
DELETE_ORG_USER = "DELETE_ORG_USER",
|
|
44
|
+
UPDATE_ORG_USER = "UPDATE_ORG_USER"
|
|
45
45
|
}
|
|
46
46
|
//# sourceMappingURL=Generics.d.ts.map
|
package/dist/types/Generics.js
CHANGED
|
@@ -50,8 +50,8 @@ var FEATURE_TYPE;
|
|
|
50
50
|
FEATURE_TYPE["DELETE_ORG"] = "DELETE_ORG";
|
|
51
51
|
FEATURE_TYPE["UPDATE_ORG"] = "UPDATE_ORG";
|
|
52
52
|
// Manage Org Users
|
|
53
|
-
FEATURE_TYPE["
|
|
54
|
-
FEATURE_TYPE["
|
|
55
|
-
FEATURE_TYPE["
|
|
56
|
-
FEATURE_TYPE["
|
|
53
|
+
FEATURE_TYPE["ADD_ORG_USER"] = "ADD_ORG_USER";
|
|
54
|
+
FEATURE_TYPE["LIST_ORG_USER"] = "LIST_ORG_USER";
|
|
55
|
+
FEATURE_TYPE["DELETE_ORG_USER"] = "DELETE_ORG_USER";
|
|
56
|
+
FEATURE_TYPE["UPDATE_ORG_USER"] = "UPDATE_ORG_USER";
|
|
57
57
|
})(FEATURE_TYPE || (exports.FEATURE_TYPE = FEATURE_TYPE = {}));
|
package/dist/utils/jsonToHTML.js
CHANGED
|
@@ -41,10 +41,10 @@ function buildStyles(style, { pxChanges, perChanges }) {
|
|
|
41
41
|
}
|
|
42
42
|
const cssKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
43
43
|
if (pxChanges.includes(key)) {
|
|
44
|
-
stylesObj[cssKey] = `${value}px
|
|
44
|
+
stylesObj[cssKey] = typeof value === "number" ? `${value}px` : value;
|
|
45
45
|
}
|
|
46
46
|
else if (perChanges.includes(key)) {
|
|
47
|
-
stylesObj[cssKey] = `${value}
|
|
47
|
+
stylesObj[cssKey] = typeof value === "number" ? `${value}%` : value;
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
50
|
stylesObj[cssKey] = value;
|
|
@@ -111,18 +111,16 @@ async function appendOutlookForImage(content, outerContainerWidth, innerContaine
|
|
|
111
111
|
const image = await jimp_1.Jimp.read(imageUrl);
|
|
112
112
|
const originalWidth = image.bitmap.width;
|
|
113
113
|
const originalHeight = image.bitmap.height;
|
|
114
|
-
// Calculate width scaling factor based on outer and inner widths
|
|
115
114
|
const widthScalingFactor = Math.min(outerContainerWidth / originalWidth, innerContainerWidth / originalWidth);
|
|
116
|
-
// Scale height proportionally
|
|
117
115
|
const scaledWidth = Math.round(originalWidth * widthScalingFactor);
|
|
118
|
-
const scaledHeight = Math.round(originalHeight * widthScalingFactor);
|
|
119
|
-
|
|
120
|
-
const borderWidth = style?.borderWidth || 0;
|
|
116
|
+
const scaledHeight = Math.round(originalHeight * widthScalingFactor);
|
|
117
|
+
const borderWidth = parseInt(style?.borderWidth) || 0;
|
|
121
118
|
const borderColor = style?.borderColor || "transparent";
|
|
122
|
-
const borderRadius = style?.borderRadius || 0;
|
|
119
|
+
const borderRadius = parseInt(style?.borderRadius) || 0;
|
|
123
120
|
const useRoundRect = borderRadius > 0;
|
|
124
|
-
const arcsize = useRoundRect
|
|
125
|
-
|
|
121
|
+
const arcsize = useRoundRect
|
|
122
|
+
? Math.min(borderRadius / scaledHeight, 1).toFixed(2)
|
|
123
|
+
: "";
|
|
126
124
|
const borderAttributes = borderWidth > 0
|
|
127
125
|
? `strokeweight="${borderWidth}px" strokecolor="${borderColor}"`
|
|
128
126
|
: `stroked="false"`;
|
|
@@ -131,8 +129,7 @@ async function appendOutlookForImage(content, outerContainerWidth, innerContaine
|
|
|
131
129
|
style="width:${scaledWidth}px;height:${scaledHeight}px;"
|
|
132
130
|
${borderAttributes}
|
|
133
131
|
${useRoundRect ? `arcsize="${arcsize}"` : ""}
|
|
134
|
-
fill="true"
|
|
135
|
-
fillcolor="none">
|
|
132
|
+
fill="true" fillcolor="none">
|
|
136
133
|
<v:fill src="${imageUrl}" type="frame" />
|
|
137
134
|
<v:textbox inset="0,0,0,0"><div style="display:none;">.</div></v:textbox>
|
|
138
135
|
</v:${useRoundRect ? "roundrect" : "rect"}>
|
|
@@ -147,32 +144,56 @@ async function appendOutlookForImage(content, outerContainerWidth, innerContaine
|
|
|
147
144
|
async function convertImageBlock(blockData, cellWidthInPx) {
|
|
148
145
|
const { style, props } = blockData.data;
|
|
149
146
|
const { altText, imageUrl, navigateToUrl } = props;
|
|
150
|
-
const { width, height, objectFit, ...containerStyle } = style;
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
147
|
+
const { width, height, objectFit, borderRadius, borderWidth, borderColor, borderStyle, ...containerStyle } = style;
|
|
148
|
+
// Ensure border styles are applied only to the container, not the image
|
|
149
|
+
const imageStyle = {
|
|
150
|
+
width,
|
|
151
|
+
height,
|
|
152
|
+
objectFit,
|
|
153
|
+
borderStyle,
|
|
154
|
+
borderRadius: borderRadius,
|
|
155
|
+
borderColor
|
|
156
|
+
};
|
|
157
|
+
// Add border styles to container for fallback clients
|
|
158
|
+
const containerStyles = buildStyles({
|
|
159
|
+
...containerStyle,
|
|
160
|
+
}, { perChanges: [], pxChanges: addPxToAttributes });
|
|
161
|
+
const imageTagStyles = buildStyles(imageStyle, {
|
|
162
|
+
perChanges: addPxOrPerToAttributes,
|
|
163
|
+
pxChanges: addPxToAttributes,
|
|
164
|
+
});
|
|
154
165
|
const imageElement = `<img src="${imageUrl}" alt="${altText}" style="${imageTagStyles}" />`;
|
|
155
|
-
const
|
|
156
|
-
(cellWidthInPx - style?.padding?.left - style?.padding?.right
|
|
166
|
+
const innerContainerWidth = ((typeof width === "string" ? parseInt(width.replace("%", "")) : width) / 100) *
|
|
167
|
+
(cellWidthInPx - (style?.padding?.left || 0) - (style?.padding?.right || 0));
|
|
168
|
+
const outlookImage = await appendOutlookForImage(imageElement, cellWidthInPx, innerContainerWidth, imageUrl, style);
|
|
157
169
|
const imageContent = appendOutlookSupport(outlookImage, containerStyles);
|
|
158
|
-
|
|
159
|
-
|
|
170
|
+
return navigateToUrl
|
|
171
|
+
? `<a href="${navigateToUrl}" target="_blank" style="display:block; text-decoration:none; cursor:pointer;">${imageContent}</a>`
|
|
172
|
+
: imageContent;
|
|
160
173
|
}
|
|
161
174
|
function appendOutlookForButton(content, buttonStyle, navigateToUrl, text) {
|
|
162
|
-
const { width
|
|
175
|
+
const { width = 200, height = 44, borderRadius = 0, borderColor = "transparent", borderWidth = 0, buttonColor = "none", buttonPadding = { top: 0, bottom: 0, left: 0, right: 0 }, color = "#000000", fontFamily = "Arial, sans-serif", fontSize = 16, fontWeight = 400, } = buttonStyle;
|
|
176
|
+
const borderAttributes = borderWidth > 0
|
|
177
|
+
? `strokeweight="${borderWidth}px" strokecolor="${borderColor}"`
|
|
178
|
+
: `stroked="false"`;
|
|
163
179
|
return `
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
180
|
+
<!--[if mso]>
|
|
181
|
+
<v:${borderRadius ? "roundrect" : "rect"} xmlns:v="urn:schemas-microsoft-com:vml" href="${navigateToUrl}"
|
|
182
|
+
style="height:${height}px;v-text-anchor:middle;width:${width}px;"
|
|
183
|
+
arcsize="${borderRadius / height}" ${borderAttributes}
|
|
184
|
+
fillcolor="${buttonColor}">
|
|
185
|
+
<w:anchorlock/>
|
|
186
|
+
<v:textbox inset="${buttonPadding.top}px,${buttonPadding.left}px,${buttonPadding.bottom}px,${buttonPadding.right}px">
|
|
187
|
+
<center style="font-family:${fontFamily};font-size:${fontSize}px;font-weight:${fontWeight};color:${color};">
|
|
188
|
+
${text}
|
|
189
|
+
</center>
|
|
190
|
+
</v:textbox>
|
|
191
|
+
</v:${borderRadius ? "roundrect" : "rect"}>
|
|
192
|
+
<![endif]-->
|
|
193
|
+
<!--[if !mso]><!-->
|
|
194
|
+
${content}
|
|
195
|
+
<!--<![endif]-->
|
|
196
|
+
`;
|
|
176
197
|
}
|
|
177
198
|
function convertButtonBlock(blockData) {
|
|
178
199
|
const { style, props } = blockData.data;
|