email-builder-utils 1.1.5 → 1.1.7

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.
@@ -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
- ADD_ORD_USER = "ADD_ORD_USER",
42
- LIST_ORD_USER = "LIST_ORD_USER",
43
- DELETE_ORD_USER = "DELETE_ORD_USER",
44
- UPDATE_ORD_USER = "UPDATE_ORD_USER"
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
@@ -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["ADD_ORD_USER"] = "ADD_ORD_USER";
54
- FEATURE_TYPE["LIST_ORD_USER"] = "LIST_ORD_USER";
55
- FEATURE_TYPE["DELETE_ORD_USER"] = "DELETE_ORD_USER";
56
- FEATURE_TYPE["UPDATE_ORD_USER"] = "UPDATE_ORD_USER";
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 = {}));
@@ -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); // Maintain aspect ratio
119
- // Extract border styles
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 ? Math.min(borderRadius / scaledWidth, 1) : 0;
125
- // Conditionally add stroke attributes
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,16 +144,32 @@ 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
- const imageStyle = { width, height, objectFit };
152
- const containerStyles = buildStyles(containerStyle, { perChanges: [], pxChanges: addPxToAttributes });
153
- const imageTagStyles = buildStyles(imageStyle, { perChanges: addPxOrPerToAttributes, pxChanges: addPxToAttributes });
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 outlookImage = await appendOutlookForImage(imageElement, cellWidthInPx, ((typeof width === "string" ? parseInt(width.replace("%", "")) : width) / 100) *
156
- (cellWidthInPx - style?.padding?.left - style?.padding?.right), imageUrl, style);
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
- console.log(imageContent);
159
- return navigateToUrl ? `<a href="${navigateToUrl}" target="_blank" style="display:block; text-decoration:none; cursor:pointer;">${imageContent}</a>` : imageContent;
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
175
  const { width, buttonColor, borderColor, borderRadius, borderWidth, height, buttonPadding, color, fontFamily, fontSize, fontWeight } = buttonStyle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "email-builder-utils",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [