@groovymedia/easy-email-core 4.12.2-2
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/lib/blocks/advanced/blocks/index.d.ts +15 -0
- package/lib/blocks/advanced/generateAdvancedBlock.d.ts +60 -0
- package/lib/blocks/advanced/generateAdvancedContentBlock.d.ts +6 -0
- package/lib/blocks/advanced/generateAdvancedLayoutBlock.d.ts +7 -0
- package/lib/blocks/advanced/index.d.ts +19 -0
- package/lib/blocks/index.d.ts +2 -0
- package/lib/blocks/standard/Accordion/index.d.ts +17 -0
- package/lib/blocks/standard/AccordionElement/index.d.ts +16 -0
- package/lib/blocks/standard/AccordionText/index.d.ts +12 -0
- package/lib/blocks/standard/AccordionTitle/index.d.ts +9 -0
- package/lib/blocks/standard/Button/index.d.ts +30 -0
- package/lib/blocks/standard/Carousel/index.d.ts +26 -0
- package/lib/blocks/standard/Column/index.d.ts +13 -0
- package/lib/blocks/standard/Divider/index.d.ts +11 -0
- package/lib/blocks/standard/Group/index.d.ts +8 -0
- package/lib/blocks/standard/Hero/index.d.ts +15 -0
- package/lib/blocks/standard/Image/index.d.ts +18 -0
- package/lib/blocks/standard/Navbar/index.d.ts +27 -0
- package/lib/blocks/standard/Page/index.d.ts +29 -0
- package/lib/blocks/standard/Raw/index.d.ts +5 -0
- package/lib/blocks/standard/Section/index.d.ts +19 -0
- package/lib/blocks/standard/Social/index.d.ts +47 -0
- package/lib/blocks/standard/Spacer/index.d.ts +7 -0
- package/lib/blocks/standard/Table/index.d.ts +5 -0
- package/lib/blocks/standard/Template/index.d.ts +5 -0
- package/lib/blocks/standard/Text/index.d.ts +20 -0
- package/lib/blocks/standard/Wrapper/index.d.ts +12 -0
- package/lib/blocks/standard/index.d.ts +45 -0
- package/lib/components/Accordion.d.ts +7 -0
- package/lib/components/AccordionElement.d.ts +7 -0
- package/lib/components/AccordionText.d.ts +7 -0
- package/lib/components/AccordionTitle.d.ts +7 -0
- package/lib/components/BasicBlock.d.ts +7 -0
- package/lib/components/BlockRenderer.d.ts +4 -0
- package/lib/components/Button.d.ts +7 -0
- package/lib/components/Carousel.d.ts +7 -0
- package/lib/components/Column.d.ts +7 -0
- package/lib/components/Divider.d.ts +7 -0
- package/lib/components/Group.d.ts +7 -0
- package/lib/components/Hero.d.ts +7 -0
- package/lib/components/Image.d.ts +7 -0
- package/lib/components/MjmlBlock.d.ts +10 -0
- package/lib/components/Navbar.d.ts +7 -0
- package/lib/components/Page.d.ts +7 -0
- package/lib/components/Raw.d.ts +7 -0
- package/lib/components/Section.d.ts +7 -0
- package/lib/components/Social.d.ts +7 -0
- package/lib/components/Spacer.d.ts +7 -0
- package/lib/components/Table.d.ts +7 -0
- package/lib/components/Template.d.ts +8 -0
- package/lib/components/Text.d.ts +7 -0
- package/lib/components/Wrapper.d.ts +7 -0
- package/lib/components/index.d.ts +23 -0
- package/lib/constants.d.ts +42 -0
- package/lib/index.cjs.js +111 -0
- package/lib/index.cjs.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.es.js +5997 -0
- package/lib/index.es.js.map +1 -0
- package/lib/typings/index.d.ts +41 -0
- package/lib/utils/BlockManager.d.ts +16 -0
- package/lib/utils/I18nManager.d.ts +7 -0
- package/lib/utils/ImageManager.d.ts +13 -0
- package/lib/utils/JsonToMjml.d.ts +12 -0
- package/lib/utils/TemplateEngineManager.d.ts +18 -0
- package/lib/utils/ancestorOf.d.ts +1 -0
- package/lib/utils/block.d.ts +34 -0
- package/lib/utils/classnames.d.ts +1 -0
- package/lib/utils/createBlock.d.ts +2 -0
- package/lib/utils/createBlockDataByType.d.ts +2 -0
- package/lib/utils/createCustomBlock.d.ts +2 -0
- package/lib/utils/generaMjmlMetaData.d.ts +2 -0
- package/lib/utils/getAdapterAttributesString.d.ts +2 -0
- package/lib/utils/getImg.d.ts +15 -0
- package/lib/utils/getPlaceholder.d.ts +2 -0
- package/lib/utils/getPreviewClassName.d.ts +1 -0
- package/lib/utils/index.d.ts +16 -0
- package/lib/utils/isAdvancedBlock.d.ts +1 -0
- package/lib/utils/isProductionMode.d.ts +24 -0
- package/lib/utils/isValidBlockData.d.ts +2 -0
- package/lib/utils/mergeBlock.d.ts +2 -0
- package/lib/utils/parseReactBlockToBlockData.d.ts +2 -0
- package/package.json +91 -0
- package/readme.md +581 -0
package/readme.md
ADDED
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
# Easy-email-core
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
This is the core easy-email library, composed by the following parts
|
|
6
|
+
|
|
7
|
+
- utils
|
|
8
|
+
- JsonToMjml
|
|
9
|
+
- BlockManager
|
|
10
|
+
- createCustomBlock
|
|
11
|
+
- parseReactBlockToBlockData
|
|
12
|
+
- ImageManager (add or overwrite image)
|
|
13
|
+
|
|
14
|
+
- blocks
|
|
15
|
+
|
|
16
|
+
- json definition of basic block
|
|
17
|
+
|
|
18
|
+
- components
|
|
19
|
+
- React component for basic blocks
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
$ npm install --save easy-email-core
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
or
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
$ yarn add easy-email-core
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## transform json to mjml
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { JsonToMjml } from 'easy-email-core';
|
|
37
|
+
|
|
38
|
+
const xml = JsonToMjml({
|
|
39
|
+
data: json,
|
|
40
|
+
context: null,
|
|
41
|
+
mode: 'production',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
console.log(xml);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
// output
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<mjml>
|
|
51
|
+
<mj-head>
|
|
52
|
+
<mj-html-attributes>
|
|
53
|
+
<mj-html-attribute
|
|
54
|
+
class="easy-email"
|
|
55
|
+
multiple-attributes="false"
|
|
56
|
+
attribute-name="text-color"
|
|
57
|
+
text-color="#000000"
|
|
58
|
+
></mj-html-attribute>
|
|
59
|
+
<mj-html-attribute
|
|
60
|
+
class="easy-email"
|
|
61
|
+
multiple-attributes="false"
|
|
62
|
+
attribute-name="font-family"
|
|
63
|
+
font-family="lucida Grande,Verdana,Microsoft YaHei"
|
|
64
|
+
></mj-html-attribute>
|
|
65
|
+
<mj-html-attribute
|
|
66
|
+
class="easy-email"
|
|
67
|
+
multiple-attributes="false"
|
|
68
|
+
attribute-name="font-size"
|
|
69
|
+
font-size="14px"
|
|
70
|
+
></mj-html-attribute>
|
|
71
|
+
<mj-html-attribute
|
|
72
|
+
class="easy-email"
|
|
73
|
+
multiple-attributes="false"
|
|
74
|
+
attribute-name="line-height"
|
|
75
|
+
line-height="1.7"
|
|
76
|
+
></mj-html-attribute>
|
|
77
|
+
<mj-html-attribute
|
|
78
|
+
class="easy-email"
|
|
79
|
+
multiple-attributes="false"
|
|
80
|
+
attribute-name="responsive"
|
|
81
|
+
responsive="true"
|
|
82
|
+
></mj-html-attribute>
|
|
83
|
+
</mj-html-attributes>
|
|
84
|
+
|
|
85
|
+
<mj-breakpoint width="480px" />
|
|
86
|
+
<mj-attributes>
|
|
87
|
+
<mj-all font-family="lucida Grande,Verdana,Microsoft YaHei" />
|
|
88
|
+
<mj-text font-size="14px" />
|
|
89
|
+
<mj-text color="#000000" />
|
|
90
|
+
<mj-text line-height="1.7" />
|
|
91
|
+
</mj-attributes>
|
|
92
|
+
</mj-head>
|
|
93
|
+
<mj-body
|
|
94
|
+
background-color="#efeeea"
|
|
95
|
+
width="600px"
|
|
96
|
+
css-class="mjml-body"
|
|
97
|
+
>
|
|
98
|
+
<mj-hero
|
|
99
|
+
padding="100px 0px 100px 0px"
|
|
100
|
+
border="none"
|
|
101
|
+
direction="ltr"
|
|
102
|
+
text-align="center"
|
|
103
|
+
background-color="#2a3448"
|
|
104
|
+
background-position="center center"
|
|
105
|
+
mode="fluid-height"
|
|
106
|
+
vertical-align="top"
|
|
107
|
+
background-url="https://cloud.githubusercontent.com/assets/1830348/15354890/1442159a-1cf0-11e6-92b1-b861dadf1750.jpg"
|
|
108
|
+
background-width="600px"
|
|
109
|
+
background-height="469px"
|
|
110
|
+
>
|
|
111
|
+
<mj-text
|
|
112
|
+
padding="20px 20px 20px 20px"
|
|
113
|
+
align="center"
|
|
114
|
+
color="#ffffff"
|
|
115
|
+
font-size="45px"
|
|
116
|
+
line-height="45px"
|
|
117
|
+
font-family="Helvetica"
|
|
118
|
+
font-weight="900"
|
|
119
|
+
>
|
|
120
|
+
GO TO SPACE
|
|
121
|
+
</mj-text>
|
|
122
|
+
|
|
123
|
+
<mj-button
|
|
124
|
+
align="center"
|
|
125
|
+
background-color="#414141"
|
|
126
|
+
color="#ffffff"
|
|
127
|
+
font-weight="normal"
|
|
128
|
+
border-radius="3px"
|
|
129
|
+
padding="10px 25px 10px 25px"
|
|
130
|
+
inner-padding="10px 25px 10px 25px"
|
|
131
|
+
line-height="120%"
|
|
132
|
+
target="_blank"
|
|
133
|
+
vertical-align="middle"
|
|
134
|
+
border="none"
|
|
135
|
+
text-align="center"
|
|
136
|
+
href="https://mjml.io/"
|
|
137
|
+
>
|
|
138
|
+
ORDER YOUR TICKET NOW
|
|
139
|
+
</mj-button>
|
|
140
|
+
</mj-hero>
|
|
141
|
+
</mj-body>
|
|
142
|
+
</mjml>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## parseReactBlockToBlockData
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
import { JsonToMjml, components, parseReactBlockToBlockData } from 'easy-email-core';
|
|
149
|
+
|
|
150
|
+
const { Page, Section, Column, Text, Button } = components;
|
|
151
|
+
|
|
152
|
+
const blockData = parseReactBlockToBlockData(
|
|
153
|
+
<Page>
|
|
154
|
+
<Section>
|
|
155
|
+
<Column>
|
|
156
|
+
<Text
|
|
157
|
+
padding='20px'
|
|
158
|
+
color='#ffffff'
|
|
159
|
+
font-family='Helvetica'
|
|
160
|
+
align='center'
|
|
161
|
+
font-size='45px'
|
|
162
|
+
line-height='45px'
|
|
163
|
+
font-weight='900'
|
|
164
|
+
>
|
|
165
|
+
GO TO SPACE
|
|
166
|
+
</Text>
|
|
167
|
+
<Button
|
|
168
|
+
href='https://mjml.io/'
|
|
169
|
+
align='center'
|
|
170
|
+
>
|
|
171
|
+
ORDER YOUR TICKET NOW
|
|
172
|
+
</Button>
|
|
173
|
+
</Column>
|
|
174
|
+
</Section>
|
|
175
|
+
</Page>,
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
console.log(blockData);
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
// output
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"type": "page",
|
|
186
|
+
"data": {
|
|
187
|
+
"value": {
|
|
188
|
+
"breakpoint": "480px",
|
|
189
|
+
"headAttributes": "",
|
|
190
|
+
"font-size": "14px",
|
|
191
|
+
"line-height": "1.7",
|
|
192
|
+
"headStyles": [],
|
|
193
|
+
"fonts": [],
|
|
194
|
+
"responsive": true,
|
|
195
|
+
"font-family": "lucida Grande,Verdana,Microsoft YaHei",
|
|
196
|
+
"text-color": "#000000"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"attributes": {
|
|
200
|
+
"background-color": "#efeeea",
|
|
201
|
+
"width": "600px"
|
|
202
|
+
},
|
|
203
|
+
"children": [
|
|
204
|
+
{
|
|
205
|
+
"type": "section",
|
|
206
|
+
"data": {
|
|
207
|
+
"value": {
|
|
208
|
+
"noWrap": false
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"attributes": {
|
|
212
|
+
"padding": "20px 0px 20px 0px",
|
|
213
|
+
"border": "none",
|
|
214
|
+
"direction": "ltr",
|
|
215
|
+
"text-align": "center",
|
|
216
|
+
"background-repeat": "repeat",
|
|
217
|
+
"background-size": "auto",
|
|
218
|
+
"background-position": "top center"
|
|
219
|
+
},
|
|
220
|
+
"children": [
|
|
221
|
+
{
|
|
222
|
+
"type": "column",
|
|
223
|
+
"data": {
|
|
224
|
+
"value": {}
|
|
225
|
+
},
|
|
226
|
+
"attributes": {
|
|
227
|
+
"padding": "0px 0px 0px 0px",
|
|
228
|
+
"border": "none",
|
|
229
|
+
"vertical-align": "top"
|
|
230
|
+
},
|
|
231
|
+
"children": [
|
|
232
|
+
{
|
|
233
|
+
"type": "text",
|
|
234
|
+
"data": {
|
|
235
|
+
"value": {
|
|
236
|
+
"content": "GO TO SPACE"
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
"attributes": {
|
|
240
|
+
"padding": "20px",
|
|
241
|
+
"align": "center",
|
|
242
|
+
"color": "#ffffff",
|
|
243
|
+
"font-family": "Helvetica",
|
|
244
|
+
"font-size": "45px",
|
|
245
|
+
"line-height": "45px",
|
|
246
|
+
"font-weight": "900"
|
|
247
|
+
},
|
|
248
|
+
"children": []
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"type": "button",
|
|
252
|
+
"data": {
|
|
253
|
+
"value": {
|
|
254
|
+
"content": "ORDER YOUR TICKET NOW"
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
"attributes": {
|
|
258
|
+
"align": "center",
|
|
259
|
+
"background-color": "#414141",
|
|
260
|
+
"color": "#ffffff",
|
|
261
|
+
"font-weight": "normal",
|
|
262
|
+
"border-radius": "3px",
|
|
263
|
+
"padding": "10px 25px 10px 25px",
|
|
264
|
+
"inner-padding": "10px 25px 10px 25px",
|
|
265
|
+
"line-height": "120%",
|
|
266
|
+
"target": "_blank",
|
|
267
|
+
"vertical-align": "middle",
|
|
268
|
+
"border": "none",
|
|
269
|
+
"text-align": "center",
|
|
270
|
+
"href": "https://mjml.io/"
|
|
271
|
+
},
|
|
272
|
+
"children": []
|
|
273
|
+
}
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
```tsx
|
|
283
|
+
// Then transform to mjml
|
|
284
|
+
console.log(
|
|
285
|
+
JsonToMjml({
|
|
286
|
+
data: blockData,
|
|
287
|
+
mode: 'production',
|
|
288
|
+
}),
|
|
289
|
+
);
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
// output
|
|
293
|
+
|
|
294
|
+
```html
|
|
295
|
+
<mjml>
|
|
296
|
+
<mj-head>
|
|
297
|
+
<mj-html-attributes>
|
|
298
|
+
<mj-html-attribute
|
|
299
|
+
class="easy-email"
|
|
300
|
+
multiple-attributes="false"
|
|
301
|
+
attribute-name="text-color"
|
|
302
|
+
text-color="#000000"
|
|
303
|
+
></mj-html-attribute>
|
|
304
|
+
<mj-html-attribute
|
|
305
|
+
class="easy-email"
|
|
306
|
+
multiple-attributes="false"
|
|
307
|
+
attribute-name="font-family"
|
|
308
|
+
font-family="lucida Grande,Verdana,Microsoft YaHei"
|
|
309
|
+
></mj-html-attribute>
|
|
310
|
+
<mj-html-attribute
|
|
311
|
+
class="easy-email"
|
|
312
|
+
multiple-attributes="false"
|
|
313
|
+
attribute-name="font-size"
|
|
314
|
+
font-size="14px"
|
|
315
|
+
></mj-html-attribute>
|
|
316
|
+
<mj-html-attribute
|
|
317
|
+
class="easy-email"
|
|
318
|
+
multiple-attributes="false"
|
|
319
|
+
attribute-name="line-height"
|
|
320
|
+
line-height="1.7"
|
|
321
|
+
></mj-html-attribute>
|
|
322
|
+
<mj-html-attribute
|
|
323
|
+
class="easy-email"
|
|
324
|
+
multiple-attributes="false"
|
|
325
|
+
attribute-name="responsive"
|
|
326
|
+
responsive="true"
|
|
327
|
+
></mj-html-attribute>
|
|
328
|
+
</mj-html-attributes>
|
|
329
|
+
|
|
330
|
+
<mj-breakpoint width="480px" />
|
|
331
|
+
<mj-attributes>
|
|
332
|
+
<mj-all font-family="lucida Grande,Verdana,Microsoft YaHei" />
|
|
333
|
+
<mj-text font-size="14px" />
|
|
334
|
+
<mj-text color="#000000" />
|
|
335
|
+
<mj-text line-height="1.7" />
|
|
336
|
+
</mj-attributes>
|
|
337
|
+
</mj-head>
|
|
338
|
+
<mj-body
|
|
339
|
+
background-color="#efeeea"
|
|
340
|
+
width="600px"
|
|
341
|
+
css-class="mjml-body"
|
|
342
|
+
>
|
|
343
|
+
<mj-section
|
|
344
|
+
padding="20px 0px 20px 0px"
|
|
345
|
+
border="none"
|
|
346
|
+
direction="ltr"
|
|
347
|
+
text-align="center"
|
|
348
|
+
background-repeat="repeat"
|
|
349
|
+
background-size="auto"
|
|
350
|
+
background-position="top center"
|
|
351
|
+
>
|
|
352
|
+
<mj-column
|
|
353
|
+
padding="0px 0px 0px 0px"
|
|
354
|
+
border="none"
|
|
355
|
+
vertical-align="top"
|
|
356
|
+
>
|
|
357
|
+
<mj-text
|
|
358
|
+
padding="20px"
|
|
359
|
+
align="center"
|
|
360
|
+
color="#ffffff"
|
|
361
|
+
font-family="Helvetica"
|
|
362
|
+
font-size="45px"
|
|
363
|
+
line-height="45px"
|
|
364
|
+
font-weight="900"
|
|
365
|
+
>
|
|
366
|
+
GO TO SPACE
|
|
367
|
+
</mj-text>
|
|
368
|
+
|
|
369
|
+
<mj-button
|
|
370
|
+
align="center"
|
|
371
|
+
background-color="#414141"
|
|
372
|
+
color="#ffffff"
|
|
373
|
+
font-weight="normal"
|
|
374
|
+
border-radius="3px"
|
|
375
|
+
padding="10px 25px 10px 25px"
|
|
376
|
+
inner-padding="10px 25px 10px 25px"
|
|
377
|
+
line-height="120%"
|
|
378
|
+
target="_blank"
|
|
379
|
+
vertical-align="middle"
|
|
380
|
+
border="none"
|
|
381
|
+
text-align="center"
|
|
382
|
+
href="https://mjml.io/"
|
|
383
|
+
>
|
|
384
|
+
ORDER YOUR TICKET NOW
|
|
385
|
+
</mj-button>
|
|
386
|
+
</mj-column>
|
|
387
|
+
</mj-section>
|
|
388
|
+
</mj-body>
|
|
389
|
+
</mjml>
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
## Customize your block
|
|
393
|
+
|
|
394
|
+
```tsx
|
|
395
|
+
import { merge } from 'lodash';
|
|
396
|
+
import {
|
|
397
|
+
createCustomBlock,
|
|
398
|
+
IBlockData,
|
|
399
|
+
components,
|
|
400
|
+
BasicType,
|
|
401
|
+
JsonToMjml,
|
|
402
|
+
BasicType,
|
|
403
|
+
BlockManager,
|
|
404
|
+
} from 'easy-email-core';
|
|
405
|
+
const { Section, Column, Image, Button } = components;
|
|
406
|
+
|
|
407
|
+
type IMyFirstBlock = IBlockData<
|
|
408
|
+
{
|
|
409
|
+
'background-color': string;
|
|
410
|
+
'text-color': string;
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
buttonText: string;
|
|
414
|
+
imageUrl: string;
|
|
415
|
+
}
|
|
416
|
+
>;
|
|
417
|
+
|
|
418
|
+
const myFirstBlock = createCustomBlock({
|
|
419
|
+
name: 'My first block',
|
|
420
|
+
type: 'MY_FIRST_BLOCK',
|
|
421
|
+
create(payload) {
|
|
422
|
+
const defaultData: IMyFirstBlock = {
|
|
423
|
+
type: 'MY_FIRST_BLOCK',
|
|
424
|
+
data: {
|
|
425
|
+
value: {
|
|
426
|
+
buttonText: 'Got it',
|
|
427
|
+
imageUrl:
|
|
428
|
+
'http://res.cloudinary.com/dwkp0e1yo/image/upload/v1665841616/pn7npfspxaqfzxiensue.png',
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
attributes: {
|
|
432
|
+
'background-color': '#4A90E2',
|
|
433
|
+
'text-color': '#ffffff',
|
|
434
|
+
},
|
|
435
|
+
children: [],
|
|
436
|
+
};
|
|
437
|
+
return merge(defaultData, payload);
|
|
438
|
+
},
|
|
439
|
+
validParentType: [BasicType.PAGE, BasicType.WRAPPER],
|
|
440
|
+
render(
|
|
441
|
+
data: IMyFirstBlock,
|
|
442
|
+
idx: string | null,
|
|
443
|
+
mode: 'testing' | 'production',
|
|
444
|
+
context?: IPage,
|
|
445
|
+
dataSource?: { [key: string]: any },
|
|
446
|
+
) {
|
|
447
|
+
const { imageUrl, buttonText } = data.data.value;
|
|
448
|
+
const attributes = data.attributes;
|
|
449
|
+
|
|
450
|
+
const instance = (
|
|
451
|
+
<Section padding='20px'>
|
|
452
|
+
<Column>
|
|
453
|
+
<Image
|
|
454
|
+
padding='0px 0px 0px 0px'
|
|
455
|
+
width='100px'
|
|
456
|
+
src={imageUrl}
|
|
457
|
+
/>
|
|
458
|
+
<Button
|
|
459
|
+
background-color={attributes['background-color']}
|
|
460
|
+
color={attributes['text-color']}
|
|
461
|
+
href='#'
|
|
462
|
+
>
|
|
463
|
+
{buttonText}
|
|
464
|
+
</Button>
|
|
465
|
+
</Column>
|
|
466
|
+
</Section>
|
|
467
|
+
);
|
|
468
|
+
return instance;
|
|
469
|
+
},
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
BlockManager.registerBlocks({ myFirstBlock });
|
|
473
|
+
|
|
474
|
+
const pageBlock = BlockManager.getBlockByType(BasicType.PAGE);
|
|
475
|
+
|
|
476
|
+
console.log(
|
|
477
|
+
JsonToMjml({
|
|
478
|
+
data: pageBlock.create({
|
|
479
|
+
children: [myFirstBlock.create()],
|
|
480
|
+
}),
|
|
481
|
+
mode: 'production',
|
|
482
|
+
}),
|
|
483
|
+
);
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
// output
|
|
487
|
+
|
|
488
|
+
```html
|
|
489
|
+
<mjml>
|
|
490
|
+
<mj-head>
|
|
491
|
+
<mj-html-attributes>
|
|
492
|
+
<mj-html-attribute
|
|
493
|
+
class="easy-email"
|
|
494
|
+
multiple-attributes="false"
|
|
495
|
+
attribute-name="text-color"
|
|
496
|
+
text-color="#000000"
|
|
497
|
+
></mj-html-attribute>
|
|
498
|
+
<mj-html-attribute
|
|
499
|
+
class="easy-email"
|
|
500
|
+
multiple-attributes="false"
|
|
501
|
+
attribute-name="font-family"
|
|
502
|
+
font-family="lucida Grande,Verdana,Microsoft YaHei"
|
|
503
|
+
></mj-html-attribute>
|
|
504
|
+
<mj-html-attribute
|
|
505
|
+
class="easy-email"
|
|
506
|
+
multiple-attributes="false"
|
|
507
|
+
attribute-name="font-size"
|
|
508
|
+
font-size="14px"
|
|
509
|
+
></mj-html-attribute>
|
|
510
|
+
<mj-html-attribute
|
|
511
|
+
class="easy-email"
|
|
512
|
+
multiple-attributes="false"
|
|
513
|
+
attribute-name="line-height"
|
|
514
|
+
line-height="1.7"
|
|
515
|
+
></mj-html-attribute>
|
|
516
|
+
<mj-html-attribute
|
|
517
|
+
class="easy-email"
|
|
518
|
+
multiple-attributes="false"
|
|
519
|
+
attribute-name="responsive"
|
|
520
|
+
responsive="true"
|
|
521
|
+
></mj-html-attribute>
|
|
522
|
+
</mj-html-attributes>
|
|
523
|
+
|
|
524
|
+
<mj-breakpoint width="480px" />
|
|
525
|
+
<mj-attributes>
|
|
526
|
+
<mj-all font-family="lucida Grande,Verdana,Microsoft YaHei" />
|
|
527
|
+
<mj-text font-size="14px" />
|
|
528
|
+
<mj-text color="#000000" />
|
|
529
|
+
<mj-text line-height="1.7" />
|
|
530
|
+
</mj-attributes>
|
|
531
|
+
</mj-head>
|
|
532
|
+
<mj-body
|
|
533
|
+
background-color="#efeeea"
|
|
534
|
+
width="600px"
|
|
535
|
+
css-class="mjml-body"
|
|
536
|
+
>
|
|
537
|
+
<mj-section
|
|
538
|
+
padding="20px"
|
|
539
|
+
background-repeat="repeat"
|
|
540
|
+
background-size="auto"
|
|
541
|
+
background-position="top center"
|
|
542
|
+
border="none"
|
|
543
|
+
direction="ltr"
|
|
544
|
+
text-align="center"
|
|
545
|
+
>
|
|
546
|
+
<mj-column
|
|
547
|
+
padding="0px 0px 0px 0px"
|
|
548
|
+
border="none"
|
|
549
|
+
vertical-align="top"
|
|
550
|
+
>
|
|
551
|
+
<mj-image
|
|
552
|
+
align="center"
|
|
553
|
+
height="auto"
|
|
554
|
+
padding="0px 0px 0px 0px"
|
|
555
|
+
src="http://res.cloudinary.com/dwkp0e1yo/image/upload/v1665841616/pn7npfspxaqfzxiensue.png"
|
|
556
|
+
width="100px"
|
|
557
|
+
>
|
|
558
|
+
</mj-image>
|
|
559
|
+
|
|
560
|
+
<mj-button
|
|
561
|
+
align="center"
|
|
562
|
+
background-color="#4A90E2"
|
|
563
|
+
color="#ffffff"
|
|
564
|
+
font-weight="normal"
|
|
565
|
+
border-radius="3px"
|
|
566
|
+
padding="10px 25px 10px 25px"
|
|
567
|
+
inner-padding="10px 25px 10px 25px"
|
|
568
|
+
line-height="120%"
|
|
569
|
+
target="_blank"
|
|
570
|
+
vertical-align="middle"
|
|
571
|
+
border="none"
|
|
572
|
+
text-align="center"
|
|
573
|
+
href="#"
|
|
574
|
+
>
|
|
575
|
+
Got it
|
|
576
|
+
</mj-button>
|
|
577
|
+
</mj-column>
|
|
578
|
+
</mj-section>
|
|
579
|
+
</mj-body>
|
|
580
|
+
</mjml>
|
|
581
|
+
```
|