email-builder-utils 1.1.46 → 1.1.48

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.
Files changed (39) hide show
  1. package/dist/utils/blocks/button.d.ts +29 -0
  2. package/dist/utils/blocks/button.d.ts.map +1 -0
  3. package/dist/utils/blocks/button.js +130 -0
  4. package/dist/utils/blocks/dividers.d.ts +4 -0
  5. package/dist/utils/blocks/dividers.d.ts.map +1 -0
  6. package/dist/utils/blocks/dividers.js +72 -0
  7. package/dist/utils/blocks/grid.d.ts +6 -0
  8. package/dist/utils/blocks/grid.d.ts.map +1 -0
  9. package/dist/utils/blocks/grid.js +248 -0
  10. package/dist/utils/blocks/image.d.ts +8 -0
  11. package/dist/utils/blocks/image.d.ts.map +1 -0
  12. package/dist/utils/blocks/image.js +58 -0
  13. package/dist/utils/blocks/shape.d.ts +2 -0
  14. package/dist/utils/blocks/shape.d.ts.map +1 -0
  15. package/dist/utils/blocks/shape.js +256 -0
  16. package/dist/utils/blocks/text.d.ts +2 -0
  17. package/dist/utils/blocks/text.d.ts.map +1 -0
  18. package/dist/utils/blocks/text.js +106 -0
  19. package/dist/utils/blocks/video.d.ts +2 -0
  20. package/dist/utils/blocks/video.d.ts.map +1 -0
  21. package/dist/utils/blocks/video.js +151 -0
  22. package/dist/utils/buildStyles.d.ts +10 -0
  23. package/dist/utils/buildStyles.d.ts.map +1 -0
  24. package/dist/utils/buildStyles.js +101 -0
  25. package/dist/utils/common.d.ts +1 -0
  26. package/dist/utils/common.d.ts.map +1 -1
  27. package/dist/utils/common.js +10 -0
  28. package/dist/utils/convertJsonToHtml.d.ts.map +1 -1
  29. package/dist/utils/convertJsonToHtml.js +135 -74
  30. package/dist/utils/gradientUtils.d.ts +8 -0
  31. package/dist/utils/gradientUtils.d.ts.map +1 -0
  32. package/dist/utils/gradientUtils.js +68 -0
  33. package/dist/utils/jsonToHTML.d.ts +2 -29
  34. package/dist/utils/jsonToHTML.d.ts.map +1 -1
  35. package/dist/utils/jsonToHTML.js +18 -1560
  36. package/dist/utils/outlookSupport.d.ts +4 -207
  37. package/dist/utils/outlookSupport.d.ts.map +1 -1
  38. package/dist/utils/outlookSupport.js +86 -453
  39. package/package.json +1 -1
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractVimeoId = exports.extractYouTubeId = void 0;
4
4
  exports.getVisibilityClass = getVisibilityClass;
5
+ exports.encodeBlockPropsAttr = encodeBlockPropsAttr;
5
6
  const extractYouTubeId = (url) => {
6
7
  try {
7
8
  const u = new URL(url);
@@ -43,3 +44,12 @@ function getVisibilityClass(props) {
43
44
  .filter(Boolean)
44
45
  .join(" ");
45
46
  }
47
+ function encodeBlockPropsAttr(props) {
48
+ // HTML attribute-safe JSON string.
49
+ // Keep it minimal and deterministic: the importer reads it back via getAttribute + JSON.parse.
50
+ return JSON.stringify(props)
51
+ .replace(/&/g, "&")
52
+ .replace(/"/g, """)
53
+ .replace(/</g, "&lt;")
54
+ .replace(/>/g, "&gt;");
55
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"convertJsonToHtml.d.ts","sourceRoot":"","sources":["../../src/utils/convertJsonToHtml.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,GAAU,UAAU,GAAG,oBAwHpD,CAAC"}
1
+ {"version":3,"file":"convertJsonToHtml.d.ts","sourceRoot":"","sources":["../../src/utils/convertJsonToHtml.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,GAAU,UAAU,GAAG,oBAqLpD,CAAC"}
@@ -20,6 +20,7 @@ const convertJsonToHtml = async (jsonData) => {
20
20
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
21
21
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
22
22
  <meta name="x-apple-disable-message-reformatting" />
23
+ <meta name="format-detection" content="telephone=no,address=no,email=no,date=no,url=no" />
23
24
  <!--[if gte mso 9]><xml>
24
25
  <o:OfficeDocumentSettings>
25
26
  <o:AllowPNG/>
@@ -27,83 +28,143 @@ const convertJsonToHtml = async (jsonData) => {
27
28
  </o:OfficeDocumentSettings>
28
29
  </xml><![endif]-->
29
30
  <style>
30
- .responsive-table {
31
- width: 100%;
32
- max-width: 600px;
31
+ html, body {
32
+ margin: 0 !important;
33
+ padding: 0 !important;
34
+ width: 100% !important;
35
+ -ms-text-size-adjust: 100%;
36
+ -webkit-text-size-adjust: 100%;
37
+ }
38
+
39
+ body, table, td, p, a {
40
+ font-family: ${(0, fontFallback_1.withFontFallback)(fontFamily)};
41
+ }
42
+
43
+ table, td {
44
+ mso-table-lspace: 0pt;
45
+ mso-table-rspace: 0pt;
46
+ border-collapse: collapse !important;
47
+ }
48
+
49
+ img {
50
+ -ms-interpolation-mode: bicubic;
51
+ border: 0;
52
+ outline: none;
53
+ text-decoration: none;
54
+ display: block;
55
+ height: auto;
56
+ line-height: 100%;
57
+ }
58
+
59
+ a {
60
+ text-decoration: none;
61
+ color: inherit;
62
+ }
63
+
64
+ .email-container {
65
+ width: 100%;
66
+ max-width: 600px;
67
+ margin: 0 auto;
68
+ }
69
+
70
+ .stack-column,
71
+ .stack-column-cell {
72
+ vertical-align: top;
73
+ }
74
+
75
+ .hide-mobile {
76
+ display: block !important;
77
+ max-height: none !important;
78
+ overflow: visible !important;
79
+ }
80
+
81
+ .hide-desktop {
82
+ display: none !important;
83
+ max-height: 0 !important;
84
+ overflow: hidden !important;
85
+ mso-hide: all !important;
86
+ }
87
+
88
+ @media only screen and (max-width: 600px) {
89
+ .email-container {
90
+ width: 100% !important;
33
91
  }
34
- @media only screen and (max-width: 600px) {
35
- .responsive-table {
36
- width: 100% !important;
37
- }
38
- .stack-column,
39
- .stack-column td {
40
- display: block !important;
41
- width: 100% !important;
42
- max-width: 100% !important;
43
- }
92
+
93
+ .stack-column,
94
+ .stack-column-cell {
95
+ display: block !important;
96
+ width: 100% !important;
97
+ max-width: 100% !important;
44
98
  }
99
+
45
100
  .hide-mobile {
46
- display: block !important;
47
- }
48
-
49
- .hide-desktop {
50
- display: block !important;
51
- mso-hide: all !important; /* Hide in Outlook (treated as desktop) */
52
- }
53
-
54
- @media only screen and (max-width: 600px) {
55
- .hide-mobile {
56
- display: none !important;
57
- max-height: 0 !important;
58
- overflow: hidden !important;
59
- mso-hide: all !important;
60
- }
61
- }
62
-
63
- @media only screen and (min-width: 601px) {
64
- .hide-desktop {
65
- display: none !important;
66
- max-height: 0 !important;
67
- overflow: hidden !important;
68
- mso-hide: all !important;
69
- }
70
- }
71
-
72
- </style>
73
- </head>
74
- <body style="margin:0; padding:0; background-color:${canvasColor};">
75
- <center style="width:100%; background-color:${canvasColor};">
76
- <table
77
- class="responsive-table"
78
- role="presentation"
79
- bgcolor="${canvasColor}"
80
- cellpadding="0"
81
- cellspacing="0"
82
- border="0"
83
- width="600"
84
- align="center"
85
- style="
86
- font-family: ${(0, fontFallback_1.withFontFallback)(fontFamily)};
87
- margin: 0 auto;
88
- table-layout:fixed;
89
- width:600px;
90
- max-width:600px;
91
- background-color: ${canvasColor};
92
- ${textColor ? `color: ${textColor};` : ''}
93
- ${borderWidth ? `border: ${borderWidth}px ${borderStyle || 'solid'} ${borderColor || 'transparent'};` : ''}
94
- ${borderRadius ? `border-radius: ${borderRadius}px;` : ''}"
95
- >
96
- <tbody>
97
- <tr>
98
- <td style="padding: ${top}px ${right}px ${bottom}px ${left}px;">
99
- ${blocksHtml.join("")}
100
- </td>
101
- </tr>
102
- </tbody>
103
- </table>
104
- </center>
105
- </body>
106
- </html>`;
101
+ display: none !important;
102
+ max-height: 0 !important;
103
+ overflow: hidden !important;
104
+ mso-hide: all !important;
105
+ }
106
+
107
+ .hide-desktop {
108
+ display: block !important;
109
+ max-height: none !important;
110
+ overflow: visible !important;
111
+ }
112
+ }
113
+ </style>
114
+ </head>
115
+ <body style="margin:0; padding:0; background-color:${canvasColor || '#ffffff'};">
116
+ <center style="width:100%; background-color:${canvasColor || '#ffffff'};">
117
+
118
+ <table role="presentation" width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="${canvasColor || '#ffffff'}">
119
+ <tr>
120
+ <td align="center">
121
+
122
+ <!--[if mso]>
123
+ <table role="presentation" border="0" cellspacing="0" cellpadding="0" width="600">
124
+ <tr>
125
+ <td>
126
+ <![endif]-->
127
+
128
+ <table
129
+ role="presentation"
130
+ class="email-container"
131
+ bgcolor="${canvasColor || '#ffffff'}"
132
+ cellpadding="0"
133
+ cellspacing="0"
134
+ border="0"
135
+ width="100%"
136
+ style="
137
+ font-family: ${(0, fontFallback_1.withFontFallback)(fontFamily)};
138
+ table-layout: fixed;
139
+ width: 100%;
140
+ max-width: 600px;
141
+ background-color: ${canvasColor || '#ffffff'};
142
+ ${textColor ? `color: ${textColor};` : ''}
143
+ ${borderWidth ? `border: ${borderWidth}px ${borderStyle || 'solid'} ${borderColor || 'transparent'};` : ''}
144
+ ${borderRadius ? `border-radius: ${borderRadius}px;` : ''}"
145
+ >
146
+ <tbody>
147
+ <tr>
148
+ <td style="padding: ${top}px ${right}px ${bottom}px ${left}px;">
149
+ ${blocksHtml.join("")}
150
+ </td>
151
+ </tr>
152
+ </tbody>
153
+ </table>
154
+
155
+ <!--[if mso]>
156
+ </td>
157
+ </tr>
158
+ </table>
159
+ <![endif]-->
160
+
161
+ </td>
162
+ </tr>
163
+ </table>
164
+
165
+ </center>
166
+ </body>
167
+ </html>`;
107
168
  return rawHtml;
108
169
  };
109
170
  exports.convertJsonToHtml = convertJsonToHtml;
@@ -0,0 +1,8 @@
1
+ export declare function extractCssFallbackColor(customCss?: string): string;
2
+ export declare function parseGradient(gradient?: string): {
3
+ angle: number;
4
+ colors: string[];
5
+ fallback: string;
6
+ } | null;
7
+ export declare function cssAngleToVml(angle: number): number;
8
+ //# sourceMappingURL=gradientUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gradientUtils.d.ts","sourceRoot":"","sources":["../../src/utils/gradientUtils.ts"],"names":[],"mappings":"AAsBA,wBAAgB,uBAAuB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAKlE;AAED,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM;;;;SAyB9C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,UAE1C"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractCssFallbackColor = extractCssFallbackColor;
4
+ exports.parseGradient = parseGradient;
5
+ exports.cssAngleToVml = cssAngleToVml;
6
+ const GRADIENT_KEYWORDS = new Set([
7
+ 'linear', 'radial', 'conic', 'gradient',
8
+ 'to', 'at', 'top', 'bottom', 'left', 'right', 'center',
9
+ 'closest', 'farthest', 'corner', 'side', 'circle', 'ellipse',
10
+ 'deg', 'turn', 'rad', 'grad', 'from', 'in',
11
+ 'url',
12
+ ]);
13
+ function firstGradientColor(gradient) {
14
+ const tokenRe = /#[0-9a-fA-F]{3,8}|rgba?\([^)]+\)|([a-zA-Z-]+)/g;
15
+ let m;
16
+ while ((m = tokenRe.exec(gradient)) !== null) {
17
+ const namedWord = m[1];
18
+ if (namedWord) {
19
+ if (!GRADIENT_KEYWORDS.has(namedWord.toLowerCase()))
20
+ return namedWord;
21
+ }
22
+ else {
23
+ return m[0];
24
+ }
25
+ }
26
+ return '';
27
+ }
28
+ function extractCssFallbackColor(customCss) {
29
+ if (!customCss)
30
+ return '';
31
+ const gradientMatch = customCss.match(/(?:linear|radial|conic)-gradient\(([^)]+(?:\([^)]*\)[^)]*)*)\)/);
32
+ if (!gradientMatch)
33
+ return '';
34
+ return firstGradientColor(gradientMatch[1]);
35
+ }
36
+ function parseGradient(gradient) {
37
+ if (!gradient)
38
+ return null;
39
+ const lower = gradient.toLowerCase();
40
+ const degMatch = gradient.match(/(\d+(?:\.\d+)?)deg/);
41
+ let angle = 180;
42
+ if (degMatch) {
43
+ angle = parseFloat(degMatch[1]);
44
+ }
45
+ else if (lower.includes('to right'))
46
+ angle = 90;
47
+ else if (lower.includes('to left'))
48
+ angle = 270;
49
+ else if (lower.includes('to top'))
50
+ angle = 0;
51
+ const colors = [];
52
+ const tokenRe = /#[0-9a-fA-F]{3,8}|rgba?\([^)]+\)|([a-zA-Z-]+)/g;
53
+ let m;
54
+ while ((m = tokenRe.exec(gradient)) !== null) {
55
+ const namedWord = m[1];
56
+ if (namedWord) {
57
+ if (!GRADIENT_KEYWORDS.has(namedWord.toLowerCase()))
58
+ colors.push(namedWord);
59
+ }
60
+ else {
61
+ colors.push(m[0]);
62
+ }
63
+ }
64
+ return { angle, colors, fallback: colors[0] || '#ffffff' };
65
+ }
66
+ function cssAngleToVml(angle) {
67
+ return (angle + 90) % 360;
68
+ }
@@ -1,30 +1,3 @@
1
- import { BlockType } from "../types";
2
- interface BlockJsonProps {
3
- columns: number;
4
- rows: number;
5
- cellWidths: Array<number>;
6
- navigateToUrl: string;
7
- text: string;
8
- altText: string;
9
- imageUrl: string;
10
- responsive?: boolean;
11
- videoUrl?: string;
12
- youtubeVideoUrl?: string;
13
- thumbnailUrl?: string;
14
- shape?: string;
15
- hideOnDesktop?: boolean;
16
- hideOnMobile?: boolean;
17
- }
18
- interface IBlockData {
19
- type: BlockType;
20
- data: {
21
- props: BlockJsonProps;
22
- style: any;
23
- childrenIds?: Array<string>;
24
- };
25
- }
26
- export declare const tableCommonStyle = "border-collapse:collapse; table-layout:fixed";
27
- export declare function convertToHtml(blockData: IBlockData, rootData: any, cellWidthInPx: number): Promise<string>;
28
- export declare function convertVideoBlock(blockData: any, cellWidthInPx: number): Promise<string>;
29
- export {};
1
+ export { tableCommonStyle } from "./buildStyles";
2
+ export declare function convertToHtml(blockData: any, rootData: any, cellWidthInPx: number): Promise<string>;
30
3
  //# sourceMappingURL=jsonToHTML.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsonToHTML.d.ts","sourceRoot":"","sources":["../../src/utils/jsonToHTML.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAA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