email-builder-utils 1.0.9 → 1.0.11
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.
|
@@ -6,7 +6,7 @@ const convertJsonToHtml = async (jsonData) => {
|
|
|
6
6
|
const rootData = jsonData?.root?.data;
|
|
7
7
|
const blocksHtml = [];
|
|
8
8
|
for (const childId of rootData?.childrenIds) {
|
|
9
|
-
blocksHtml.push(await (0, jsonToHTML_1.convertToHtml)(jsonData[childId], jsonData, 600));
|
|
9
|
+
blocksHtml.push(await (0, jsonToHTML_1.convertToHtml)(jsonData[childId], jsonData, 600 - (rootData.style?.padding?.left || 0) - (rootData.style?.padding?.right || 0)));
|
|
10
10
|
}
|
|
11
11
|
const rawHtml = `
|
|
12
12
|
<!DOCTYPE html>
|
package/dist/utils/jsonToHTML.js
CHANGED
|
@@ -100,7 +100,7 @@ async function appendOutlookForImage(content, outerContainerWidth, innerContaine
|
|
|
100
100
|
const originalWidth = image.bitmap.width;
|
|
101
101
|
const originalHeight = image.bitmap.height;
|
|
102
102
|
// Calculate width scaling factor based on outer and inner widths
|
|
103
|
-
const widthScalingFactor = Math.min(outerContainerWidth / originalWidth, innerContainerWidth / originalWidth
|
|
103
|
+
const widthScalingFactor = Math.min(outerContainerWidth / originalWidth, innerContainerWidth / originalWidth);
|
|
104
104
|
// Scale the height proportionally
|
|
105
105
|
const scaledWidth = Math.round(originalWidth * widthScalingFactor);
|
|
106
106
|
const scaledHeight = Math.round(originalHeight * widthScalingFactor); // Maintain aspect ratio
|
|
@@ -125,7 +125,7 @@ async function convertImageBlock(blockData, cellWidthInPx) {
|
|
|
125
125
|
const containerStyles = buildStyles(containerStyle, { perChanges: [], pxChanges: addPxToAttributes });
|
|
126
126
|
const imageTagStyles = buildStyles(imageStyle, { perChanges: addPxOrPerToAttributes, pxChanges: addPxToAttributes });
|
|
127
127
|
const imageElement = `<img src="${imageUrl}" alt="${altText}" style="${imageTagStyles}" />`;
|
|
128
|
-
const outlookImage = await appendOutlookForImage(imageElement, cellWidthInPx, parseInt(width.replace("%", "")) * cellWidthInPx, imageUrl);
|
|
128
|
+
const outlookImage = await appendOutlookForImage(imageElement, cellWidthInPx, ((typeof width === "string" ? parseInt(width.replace("%", "")) : width) / 100) * (cellWidthInPx - style?.padding?.left - style?.padding?.right), imageUrl);
|
|
129
129
|
const imageContent = appendOutlookSupport(outlookImage, containerStyles);
|
|
130
130
|
return navigateToUrl ? `<a href="${navigateToUrl}" target="_blank" style="display:block; text-decoration:none; cursor:pointer;">${imageContent}</a>` : imageContent;
|
|
131
131
|
}
|
|
@@ -201,7 +201,7 @@ async function convertGridCellBlock(blockData, rootData, cellWidth, parentCellWi
|
|
|
201
201
|
const cellItems = [];
|
|
202
202
|
if (childrenIds && childrenIds?.length > 0) {
|
|
203
203
|
for (const childId of childrenIds) {
|
|
204
|
-
cellItems.push(await convertToHtml(rootData[childId], rootData, parentCellWidth * (
|
|
204
|
+
cellItems.push(await convertToHtml(rootData[childId], rootData, parentCellWidth * (cellWidth || 0) / 100));
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
return `<td style="width:${cellWidth}% ; max-width:${cellWidth}%; ${styles}">${cellItems.join("")}</td>`;
|