email-builder-utils 1.1.49 → 1.1.52
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/blocks/button.d.ts +0 -27
- package/dist/utils/blocks/button.d.ts.map +1 -1
- package/dist/utils/blocks/button.js +89 -39
- package/dist/utils/blocks/dividers.js +30 -30
- package/dist/utils/blocks/grid.d.ts.map +1 -1
- package/dist/utils/blocks/grid.js +192 -106
- package/dist/utils/blocks/image.d.ts.map +1 -1
- package/dist/utils/blocks/image.js +42 -4
- package/dist/utils/blocks/shape.js +89 -89
- package/dist/utils/blocks/text.d.ts.map +1 -1
- package/dist/utils/blocks/text.js +80 -49
- package/dist/utils/blocks/video.js +56 -56
- package/dist/utils/buildStyles.d.ts.map +1 -1
- package/dist/utils/buildStyles.js +24 -6
- package/dist/utils/common.d.ts +1 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/common.js +14 -0
- package/dist/utils/convertJsonToHtml.d.ts.map +1 -1
- package/dist/utils/convertJsonToHtml.js +183 -153
- package/dist/utils/outlookSupport.d.ts.map +1 -1
- package/dist/utils/outlookSupport.js +81 -57
- package/package.json +34 -34
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
export declare function appendOutlookForButton(buttonData: {
|
|
2
|
-
style: any;
|
|
3
|
-
text: string;
|
|
4
|
-
navigateToUrl: string;
|
|
5
|
-
}): {
|
|
6
|
-
innerContent: string;
|
|
7
|
-
computed: {
|
|
8
|
-
fs: any;
|
|
9
|
-
fontWeight: any;
|
|
10
|
-
containerAlign: any;
|
|
11
|
-
padTop: any;
|
|
12
|
-
padRight: any;
|
|
13
|
-
padBottom: any;
|
|
14
|
-
padLeft: any;
|
|
15
|
-
explicitWidth: any;
|
|
16
|
-
vmlWidth: number;
|
|
17
|
-
safeColor: any;
|
|
18
|
-
bgColor: any;
|
|
19
|
-
safeFF: string;
|
|
20
|
-
finalHeight: any;
|
|
21
|
-
explicitHeight: any;
|
|
22
|
-
bw: any;
|
|
23
|
-
br: any;
|
|
24
|
-
bdColor: any;
|
|
25
|
-
bdStyle: any;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
1
|
export declare function convertButtonBlock(blockData: any): string;
|
|
29
2
|
//# sourceMappingURL=button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/utils/blocks/button.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/utils/blocks/button.ts"],"names":[],"mappings":"AA6IA,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,GAAG,UAuFhD"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.appendOutlookForButton = appendOutlookForButton;
|
|
4
3
|
exports.convertButtonBlock = convertButtonBlock;
|
|
5
4
|
const buildStyles_1 = require("../buildStyles");
|
|
6
5
|
const fontFallback_1 = require("../fontFallback");
|
|
@@ -26,36 +25,64 @@ function appendOutlookForButton(buttonData) {
|
|
|
26
25
|
const fontWeight = style.fontWeight || 400;
|
|
27
26
|
const containerAlign = style.alignment || style.textAlign || "left";
|
|
28
27
|
const explicitWidth = typeof style.width === "number" && style.width > 0 ? style.width : 0;
|
|
28
|
+
// VML requires explicit pixel width — estimate from text + padding when not set.
|
|
29
|
+
// Slightly conservative multiplier to reduce clipping risk in Outlook.
|
|
29
30
|
const estimatedTextWidth = Math.ceil((text || "").length * fs * 0.62);
|
|
30
31
|
const vmlWidthBase = explicitWidth || Math.max(120, estimatedTextWidth + padLeft + padRight + bw * 2);
|
|
32
|
+
// For pill buttons (large radius), ensure enough width so the curved ends don't encroach.
|
|
31
33
|
const minPillWidth = br > 0 ? Math.ceil(finalHeight * 2) : 0;
|
|
32
34
|
const vmlWidth = Math.max(vmlWidthBase, minPillWidth);
|
|
33
35
|
const borderCss = bw > 0 ? `border:${bw}px ${bdStyle} ${bdColor};` : "";
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<a
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
// Empty href triggers New Outlook's link sanitizer to strip surrounding styles.
|
|
37
|
+
const safeHref = navigateToUrl && navigateToUrl.trim() ? navigateToUrl : "#";
|
|
38
|
+
// ── Non-MSO fallback ──
|
|
39
|
+
// All visual box styling (bg, border, radius, width, height) lives on the <td>.
|
|
40
|
+
// New Outlook (and many web mail clients) strip these from <a> inline styles,
|
|
41
|
+
// treating anchors as inline text. The <td> is a block container and is preserved.
|
|
42
|
+
// The <a> fills the cell so the entire button is the click target — typography only.
|
|
43
|
+
// Down-level-hidden conditional comments hide this branch from classic Outlook
|
|
44
|
+
// (which renders the VML below), so both engines see exactly one button.
|
|
45
|
+
const tdWidthCss = explicitWidth ? `width:${explicitWidth}px;` : "";
|
|
46
|
+
const tdHeightCss = explicitHeight > 0 ? `height:${finalHeight}px;` : "";
|
|
47
|
+
const tdWidthAttr = explicitWidth ? ` width="${explicitWidth}"` : "";
|
|
48
|
+
const tdHeightAttr = explicitHeight > 0 ? ` height="${finalHeight}"` : "";
|
|
49
|
+
// <a> fills the cell. When height is explicit, line-height = inner height for vertical
|
|
50
|
+
// centering. When not, padding provides the vertical sizing (matches canvas behavior).
|
|
51
|
+
const anchorBoxStyles = explicitHeight > 0
|
|
52
|
+
? `display:block;line-height:${finalHeight - 2 * bw}px;padding:0 ${padRight}px;`
|
|
53
|
+
: `display:block;padding:${padTop}px ${padRight}px ${padBottom}px ${padLeft}px;line-height:${fs}px;`;
|
|
54
|
+
const tableAlignAttr = ` align="${containerAlign}"`;
|
|
55
|
+
const tableMargin = containerAlign === 'center' ? 'margin:0 auto;'
|
|
56
|
+
: containerAlign === 'right' ? 'margin-left:auto;margin-right:0;'
|
|
57
|
+
: '';
|
|
58
|
+
const nonMsoAnchor = `<!--[if !mso]><!-->
|
|
59
|
+
<table border="0" cellpadding="0" cellspacing="0" role="presentation"${tableAlignAttr} style="border-collapse:separate;${tableMargin}">
|
|
60
|
+
<tr>
|
|
61
|
+
<td bgcolor="${bgColor}" align="center" valign="middle"${tdWidthAttr}${tdHeightAttr} style="background-color:${bgColor};border-radius:${br}px;${borderCss}${tdWidthCss}${tdHeightCss}box-sizing:border-box;mso-padding-alt:0;text-align:center;">
|
|
62
|
+
<a href="${safeHref}" target="_blank" rel="noreferrer noopener"
|
|
63
|
+
style="${anchorBoxStyles}color:${safeColor};font-family:${safeFF};font-size:${fs}px;font-weight:${fontWeight};text-decoration:none;text-align:center;white-space:nowrap;-webkit-text-size-adjust:none;box-sizing:border-box;">${text}</a>
|
|
64
|
+
</td>
|
|
65
|
+
</tr>
|
|
66
|
+
</table>
|
|
42
67
|
<!--<![endif]-->`;
|
|
68
|
+
// ── MSO: VML bulletproof button (classic Outlook / Word engine) ──
|
|
69
|
+
// VML arcsize is a percentage of half the shorter side. Clamp to 50% (pill).
|
|
43
70
|
const arcSizePct = br > 0 ? Math.min(Math.round((br / (finalHeight / 2)) * 100), 50) : 0;
|
|
44
71
|
const strokeAttrs = bw > 0
|
|
45
72
|
? `stroke="true" strokecolor="${bdColor}" strokeweight="${bw}px"`
|
|
46
73
|
: `stroke="false"`;
|
|
47
|
-
const msoButton = `<!--[if mso]>
|
|
48
|
-
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word"
|
|
49
|
-
href="${
|
|
50
|
-
style="height:${finalHeight}px;v-text-anchor:middle;width:${vmlWidth}px;"
|
|
51
|
-
arcsize="${arcSizePct}%"
|
|
52
|
-
${strokeAttrs}
|
|
53
|
-
fillcolor="${bgColor}">
|
|
54
|
-
<w:anchorlock/>
|
|
55
|
-
<v:textbox inset="0,0,0,0">
|
|
56
|
-
<center style="color:${safeColor};font-family:${safeFF};font-size:${fs}px;font-weight:${fontWeight};mso-line-height-rule:exactly;line-height:${finalHeight}px;text-decoration:none;">${text}</center>
|
|
57
|
-
</v:textbox>
|
|
58
|
-
</v:roundrect>
|
|
74
|
+
const msoButton = `<!--[if mso]>
|
|
75
|
+
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word"
|
|
76
|
+
href="${safeHref}"
|
|
77
|
+
style="height:${finalHeight}px;v-text-anchor:middle;width:${vmlWidth}px;"
|
|
78
|
+
arcsize="${arcSizePct}%"
|
|
79
|
+
${strokeAttrs}
|
|
80
|
+
fillcolor="${bgColor}">
|
|
81
|
+
<w:anchorlock/>
|
|
82
|
+
<v:textbox inset="0,0,0,0">
|
|
83
|
+
<center style="color:${safeColor};font-family:${safeFF};font-size:${fs}px;font-weight:${fontWeight};mso-line-height-rule:exactly;line-height:${finalHeight}px;text-decoration:none;">${text}</center>
|
|
84
|
+
</v:textbox>
|
|
85
|
+
</v:roundrect>
|
|
59
86
|
<![endif]-->`;
|
|
60
87
|
const innerContent = containerAlign === "center"
|
|
61
88
|
? `<center>${msoButton}${nonMsoAnchor}</center>`
|
|
@@ -63,12 +90,24 @@ function appendOutlookForButton(buttonData) {
|
|
|
63
90
|
return {
|
|
64
91
|
innerContent,
|
|
65
92
|
computed: {
|
|
66
|
-
fs,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
93
|
+
fs,
|
|
94
|
+
fontWeight,
|
|
95
|
+
containerAlign,
|
|
96
|
+
padTop,
|
|
97
|
+
padRight,
|
|
98
|
+
padBottom,
|
|
99
|
+
padLeft,
|
|
100
|
+
explicitWidth,
|
|
101
|
+
vmlWidth,
|
|
102
|
+
safeColor,
|
|
103
|
+
bgColor,
|
|
104
|
+
safeFF,
|
|
105
|
+
finalHeight,
|
|
106
|
+
explicitHeight,
|
|
107
|
+
bw,
|
|
108
|
+
br,
|
|
109
|
+
bdColor,
|
|
110
|
+
bdStyle,
|
|
72
111
|
},
|
|
73
112
|
};
|
|
74
113
|
}
|
|
@@ -79,9 +118,20 @@ function convertButtonBlock(blockData) {
|
|
|
79
118
|
const visibilityClass = (0, common_1.getVisibilityClass)(props);
|
|
80
119
|
const { innerContent, computed } = appendOutlookForButton({
|
|
81
120
|
style: {
|
|
82
|
-
fontFamily,
|
|
83
|
-
|
|
84
|
-
|
|
121
|
+
fontFamily,
|
|
122
|
+
fontSize,
|
|
123
|
+
fontWeight,
|
|
124
|
+
textAlign,
|
|
125
|
+
borderColor,
|
|
126
|
+
borderRadius,
|
|
127
|
+
borderWidth,
|
|
128
|
+
borderStyle,
|
|
129
|
+
buttonPadding,
|
|
130
|
+
color,
|
|
131
|
+
buttonColor,
|
|
132
|
+
width,
|
|
133
|
+
height,
|
|
134
|
+
alignment,
|
|
85
135
|
},
|
|
86
136
|
text: text || "",
|
|
87
137
|
navigateToUrl: navigateToUrl || "",
|
|
@@ -117,14 +167,14 @@ function convertButtonBlock(blockData) {
|
|
|
117
167
|
hideOnDesktop: Boolean(props.hideOnDesktop),
|
|
118
168
|
hideOnMobile: Boolean(props.hideOnMobile),
|
|
119
169
|
});
|
|
120
|
-
return `
|
|
121
|
-
<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" class="${visibilityClass}" data-block-type="button" data-block-props="${buttonBlockProps}">
|
|
122
|
-
<tr>
|
|
123
|
-
<td align="${computed.containerAlign}"
|
|
124
|
-
style="padding:${padding?.top || 0}px ${padding?.right || 0}px ${padding?.bottom || 0}px ${padding?.left || 0}px;background-color:${containerBg || 'transparent'};">
|
|
125
|
-
${innerContent}
|
|
126
|
-
</td>
|
|
127
|
-
</tr>
|
|
128
|
-
</table>
|
|
170
|
+
return `
|
|
171
|
+
<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" class="${visibilityClass}" data-block-type="button" data-block-props="${buttonBlockProps}" style="border-collapse:collapse;table-layout:fixed;">
|
|
172
|
+
<tr>
|
|
173
|
+
<td align="${computed.containerAlign}"${(0, common_1.buildOutlookBgAttr)(containerBg)}
|
|
174
|
+
style="padding:${padding?.top || 0}px ${padding?.right || 0}px ${padding?.bottom || 0}px ${padding?.left || 0}px;background-color:${containerBg || 'transparent'};">
|
|
175
|
+
${innerContent}
|
|
176
|
+
</td>
|
|
177
|
+
</tr>
|
|
178
|
+
</table>
|
|
129
179
|
`;
|
|
130
180
|
}
|
|
@@ -21,23 +21,23 @@ function convertDividerBlockToHtml(blockData) {
|
|
|
21
21
|
hideOnMobile ? "hide-mobile" : "",
|
|
22
22
|
hideOnDesktop ? "hide-desktop" : "",
|
|
23
23
|
].filter(Boolean).join(" ");
|
|
24
|
-
const dividerContent = `
|
|
25
|
-
<table
|
|
26
|
-
align="${alignAttr}"
|
|
27
|
-
width="${dividerWidth}%"
|
|
28
|
-
cellpadding="0"
|
|
29
|
-
cellspacing="0"
|
|
30
|
-
style="margin:${alignMargin};"
|
|
31
|
-
>
|
|
32
|
-
<tr>
|
|
33
|
-
<td
|
|
34
|
-
height="${thickness}"
|
|
35
|
-
style="font-size:1px; line-height:1px; background:${dividerColor}; width:100%;"
|
|
36
|
-
>
|
|
37
|
-
|
|
38
|
-
</td>
|
|
39
|
-
</tr>
|
|
40
|
-
</table>
|
|
24
|
+
const dividerContent = `
|
|
25
|
+
<table
|
|
26
|
+
align="${alignAttr}"
|
|
27
|
+
width="${dividerWidth}%"
|
|
28
|
+
cellpadding="0"
|
|
29
|
+
cellspacing="0"
|
|
30
|
+
style="margin:${alignMargin};"
|
|
31
|
+
>
|
|
32
|
+
<tr>
|
|
33
|
+
<td
|
|
34
|
+
height="${thickness}"
|
|
35
|
+
style="font-size:1px; line-height:1px; background:${dividerColor}; width:100%;"
|
|
36
|
+
>
|
|
37
|
+
|
|
38
|
+
</td>
|
|
39
|
+
</tr>
|
|
40
|
+
</table>
|
|
41
41
|
`;
|
|
42
42
|
return (0, outlookSupport_1.appendOutlookSupport)(dividerContent, contentStyle, visibilityClass);
|
|
43
43
|
}
|
|
@@ -55,18 +55,18 @@ function convertVerticalDividerBlockToHtml(blockData) {
|
|
|
55
55
|
perChanges: [],
|
|
56
56
|
pxChanges: buildStyles_1.allPxAttributes,
|
|
57
57
|
});
|
|
58
|
-
return `
|
|
59
|
-
<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation"
|
|
60
|
-
style="${buildStyles_1.tableCommonStyle}; max-width:600px;" class="${visibilityClass}" data-block-type="vdivider">
|
|
61
|
-
<tr>
|
|
62
|
-
<td style="${outerStyles}; text-align:center; vertical-align:middle;">
|
|
63
|
-
<!--[if mso | IE]>
|
|
64
|
-
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fillcolor="${dividerColor}" style="width:${width}px;height:${height}px;" stroke="f"></v:rect>
|
|
65
|
-
<![endif]-->
|
|
66
|
-
<!--[if !mso]><!-->
|
|
67
|
-
<div style="display:inline-block;width:${width}px;height:${height}px;background:${dividerColor};line-height:0;font-size:0;"> </div>
|
|
68
|
-
<!--<![endif]-->
|
|
69
|
-
</td>
|
|
70
|
-
</tr>
|
|
58
|
+
return `
|
|
59
|
+
<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation"
|
|
60
|
+
style="${buildStyles_1.tableCommonStyle}; max-width:600px;" class="${visibilityClass}" data-block-type="vdivider">
|
|
61
|
+
<tr>
|
|
62
|
+
<td style="${outerStyles}; text-align:center; vertical-align:middle;">
|
|
63
|
+
<!--[if mso | IE]>
|
|
64
|
+
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fillcolor="${dividerColor}" style="width:${width}px;height:${height}px;" stroke="f"></v:rect>
|
|
65
|
+
<![endif]-->
|
|
66
|
+
<!--[if !mso]><!-->
|
|
67
|
+
<div style="display:inline-block;width:${width}px;height:${height}px;background:${dividerColor};line-height:0;font-size:0;"> </div>
|
|
68
|
+
<!--<![endif]-->
|
|
69
|
+
</td>
|
|
70
|
+
</tr>
|
|
71
71
|
</table>`;
|
|
72
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../src/utils/blocks/grid.ts"],"names":[],"mappings":"AAMA,wBAAsB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../src/utils/blocks/grid.ts"],"names":[],"mappings":"AAMA,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,GAAG,EACd,QAAQ,EAAE,GAAG,EACb,aAAa,EAAE,MAAM,mBA0TtB;AAED,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,GAAG,EACd,QAAQ,EAAE,GAAG,EACb,gBAAgB,EAAE,MAAM,EACxB,iBAAiB,EAAE,MAAM,EACzB,mBAAmB,UAAQ;;;GAwG5B"}
|