@thanhpv102/easy-email-core 4.19.0

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 (85) hide show
  1. package/lib/blocks/advanced/blocks/index.d.ts +16 -0
  2. package/lib/blocks/advanced/generateAdvancedBlock.d.ts +60 -0
  3. package/lib/blocks/advanced/generateAdvancedContentBlock.d.ts +6 -0
  4. package/lib/blocks/advanced/generateAdvancedLayoutBlock.d.ts +7 -0
  5. package/lib/blocks/advanced/generateAdvancedTableBlock.d.ts +21 -0
  6. package/lib/blocks/advanced/index.d.ts +22 -0
  7. package/lib/blocks/index.d.ts +2 -0
  8. package/lib/blocks/standard/Accordion/index.d.ts +17 -0
  9. package/lib/blocks/standard/AccordionElement/index.d.ts +16 -0
  10. package/lib/blocks/standard/AccordionText/index.d.ts +12 -0
  11. package/lib/blocks/standard/AccordionTitle/index.d.ts +9 -0
  12. package/lib/blocks/standard/Button/index.d.ts +30 -0
  13. package/lib/blocks/standard/Carousel/index.d.ts +26 -0
  14. package/lib/blocks/standard/Column/index.d.ts +13 -0
  15. package/lib/blocks/standard/Divider/index.d.ts +11 -0
  16. package/lib/blocks/standard/Group/index.d.ts +8 -0
  17. package/lib/blocks/standard/Hero/index.d.ts +15 -0
  18. package/lib/blocks/standard/Image/index.d.ts +18 -0
  19. package/lib/blocks/standard/Navbar/index.d.ts +27 -0
  20. package/lib/blocks/standard/Page/index.d.ts +29 -0
  21. package/lib/blocks/standard/Raw/index.d.ts +5 -0
  22. package/lib/blocks/standard/Section/index.d.ts +19 -0
  23. package/lib/blocks/standard/Social/index.d.ts +47 -0
  24. package/lib/blocks/standard/Spacer/index.d.ts +7 -0
  25. package/lib/blocks/standard/Table/index.d.ts +5 -0
  26. package/lib/blocks/standard/Template/index.d.ts +5 -0
  27. package/lib/blocks/standard/Text/index.d.ts +20 -0
  28. package/lib/blocks/standard/Wrapper/index.d.ts +12 -0
  29. package/lib/blocks/standard/index.d.ts +45 -0
  30. package/lib/components/Accordion.d.ts +8 -0
  31. package/lib/components/AccordionElement.d.ts +8 -0
  32. package/lib/components/AccordionText.d.ts +8 -0
  33. package/lib/components/AccordionTitle.d.ts +8 -0
  34. package/lib/components/BasicBlock.d.ts +7 -0
  35. package/lib/components/BlockRenderer.d.ts +5 -0
  36. package/lib/components/Button.d.ts +8 -0
  37. package/lib/components/Carousel.d.ts +8 -0
  38. package/lib/components/Column.d.ts +8 -0
  39. package/lib/components/Divider.d.ts +8 -0
  40. package/lib/components/Group.d.ts +8 -0
  41. package/lib/components/Hero.d.ts +8 -0
  42. package/lib/components/Image.d.ts +8 -0
  43. package/lib/components/MjmlBlock.d.ts +10 -0
  44. package/lib/components/Navbar.d.ts +8 -0
  45. package/lib/components/Page.d.ts +8 -0
  46. package/lib/components/Raw.d.ts +8 -0
  47. package/lib/components/Section.d.ts +8 -0
  48. package/lib/components/Social.d.ts +8 -0
  49. package/lib/components/Spacer.d.ts +8 -0
  50. package/lib/components/Table.d.ts +8 -0
  51. package/lib/components/Template.d.ts +8 -0
  52. package/lib/components/Text.d.ts +8 -0
  53. package/lib/components/Wrapper.d.ts +8 -0
  54. package/lib/components/index.d.ts +23 -0
  55. package/lib/constants.d.ts +43 -0
  56. package/lib/index.cjs.js +113 -0
  57. package/lib/index.cjs.js.map +1 -0
  58. package/lib/index.d.ts +5 -0
  59. package/lib/index.es.js +3685 -0
  60. package/lib/index.es.js.map +1 -0
  61. package/lib/typings/index.d.ts +41 -0
  62. package/lib/utils/BlockManager.d.ts +16 -0
  63. package/lib/utils/I18nManager.d.ts +7 -0
  64. package/lib/utils/ImageManager.d.ts +13 -0
  65. package/lib/utils/JsonToMjml.d.ts +12 -0
  66. package/lib/utils/TemplateEngineManager.d.ts +18 -0
  67. package/lib/utils/ancestorOf.d.ts +1 -0
  68. package/lib/utils/block.d.ts +34 -0
  69. package/lib/utils/classnames.d.ts +1 -0
  70. package/lib/utils/createBlock.d.ts +2 -0
  71. package/lib/utils/createBlockDataByType.d.ts +2 -0
  72. package/lib/utils/createCustomBlock.d.ts +2 -0
  73. package/lib/utils/generaMjmlMetaData.d.ts +2 -0
  74. package/lib/utils/getAdapterAttributesString.d.ts +2 -0
  75. package/lib/utils/getImg.d.ts +15 -0
  76. package/lib/utils/getPlaceholder.d.ts +2 -0
  77. package/lib/utils/getPreviewClassName.d.ts +1 -0
  78. package/lib/utils/index.d.ts +16 -0
  79. package/lib/utils/isAdvancedBlock.d.ts +1 -0
  80. package/lib/utils/isProductionMode.d.ts +24 -0
  81. package/lib/utils/isValidBlockData.d.ts +2 -0
  82. package/lib/utils/mergeBlock.d.ts +2 -0
  83. package/lib/utils/parseReactBlockToBlockData.d.ts +2 -0
  84. package/package.json +85 -0
  85. package/readme.md +426 -0
package/readme.md ADDED
@@ -0,0 +1,426 @@
1
+ # Easy-email-core
2
+
3
+ ## Usage
4
+
5
+ ```sh
6
+ $ npm install --save easy-email-core
7
+ ```
8
+
9
+ or
10
+
11
+ ```sh
12
+ $ yarn add easy-email-core
13
+ ```
14
+
15
+ ## transform json to mjml
16
+
17
+ ```ts
18
+ import { JsonToMjml } from 'easy-email-core';
19
+
20
+ const xml = JsonToMjml({
21
+ data: json,
22
+ context: null,
23
+ mode: 'production',
24
+ });
25
+
26
+ console.log(xml);
27
+ ```
28
+
29
+ // output
30
+
31
+ ```html
32
+ <mjml>
33
+ <mj-head>
34
+ <mj-html-attributes>
35
+ <mj-html-attribute
36
+ class="easy-email"
37
+ multiple-attributes="false"
38
+ attribute-name="text-color"
39
+ text-color="#000000"
40
+ ></mj-html-attribute>
41
+ <mj-html-attribute
42
+ class="easy-email"
43
+ multiple-attributes="false"
44
+ attribute-name="font-family"
45
+ font-family="lucida Grande,Verdana,Microsoft YaHei"
46
+ ></mj-html-attribute>
47
+ <mj-html-attribute
48
+ class="easy-email"
49
+ multiple-attributes="false"
50
+ attribute-name="font-size"
51
+ font-size="14px"
52
+ ></mj-html-attribute>
53
+ <mj-html-attribute
54
+ class="easy-email"
55
+ multiple-attributes="false"
56
+ attribute-name="line-height"
57
+ line-height="1.7"
58
+ ></mj-html-attribute>
59
+ <mj-html-attribute
60
+ class="easy-email"
61
+ multiple-attributes="false"
62
+ attribute-name="responsive"
63
+ responsive="true"
64
+ ></mj-html-attribute>
65
+ </mj-html-attributes>
66
+
67
+ <mj-breakpoint width="480px" />
68
+ <mj-attributes>
69
+ <mj-all font-family="lucida Grande,Verdana,Microsoft YaHei" />
70
+ <mj-text font-size="14px" />
71
+ <mj-text color="#000000" />
72
+ <mj-text line-height="1.7" />
73
+ </mj-attributes>
74
+ </mj-head>
75
+ <mj-body
76
+ background-color="#efeeea"
77
+ width="600px"
78
+ css-class="mjml-body"
79
+ >
80
+ <mj-hero
81
+ padding="100px 0px 100px 0px"
82
+ border="none"
83
+ direction="ltr"
84
+ text-align="center"
85
+ background-color="#2a3448"
86
+ background-position="center center"
87
+ mode="fluid-height"
88
+ vertical-align="top"
89
+ background-url="https://cloud.githubusercontent.com/assets/1830348/15354890/1442159a-1cf0-11e6-92b1-b861dadf1750.jpg"
90
+ background-width="600px"
91
+ background-height="469px"
92
+ >
93
+ <mj-text
94
+ padding="20px 20px 20px 20px"
95
+ align="center"
96
+ color="#ffffff"
97
+ font-size="45px"
98
+ line-height="45px"
99
+ font-family="Helvetica"
100
+ font-weight="900"
101
+ >
102
+ GO TO SPACE
103
+ </mj-text>
104
+
105
+ <mj-button
106
+ align="center"
107
+ background-color="#414141"
108
+ color="#ffffff"
109
+ font-weight="normal"
110
+ border-radius="3px"
111
+ padding="10px 25px 10px 25px"
112
+ inner-padding="10px 25px 10px 25px"
113
+ line-height="120%"
114
+ target="_blank"
115
+ vertical-align="middle"
116
+ border="none"
117
+ text-align="center"
118
+ href="https://mjml.io/"
119
+ >
120
+ ORDER YOUR TICKET NOW
121
+ </mj-button>
122
+ </mj-hero>
123
+ </mj-body>
124
+ </mjml>
125
+ ```
126
+
127
+ ```tsx
128
+ // Then transform to mjml
129
+ console.log(
130
+ JsonToMjml({
131
+ data: blockData,
132
+ mode: 'production',
133
+ }),
134
+ );
135
+ ```
136
+
137
+ // output
138
+
139
+ ```html
140
+ <mjml>
141
+ <mj-head>
142
+ <mj-html-attributes>
143
+ <mj-html-attribute
144
+ class="easy-email"
145
+ multiple-attributes="false"
146
+ attribute-name="text-color"
147
+ text-color="#000000"
148
+ ></mj-html-attribute>
149
+ <mj-html-attribute
150
+ class="easy-email"
151
+ multiple-attributes="false"
152
+ attribute-name="font-family"
153
+ font-family="lucida Grande,Verdana,Microsoft YaHei"
154
+ ></mj-html-attribute>
155
+ <mj-html-attribute
156
+ class="easy-email"
157
+ multiple-attributes="false"
158
+ attribute-name="font-size"
159
+ font-size="14px"
160
+ ></mj-html-attribute>
161
+ <mj-html-attribute
162
+ class="easy-email"
163
+ multiple-attributes="false"
164
+ attribute-name="line-height"
165
+ line-height="1.7"
166
+ ></mj-html-attribute>
167
+ <mj-html-attribute
168
+ class="easy-email"
169
+ multiple-attributes="false"
170
+ attribute-name="responsive"
171
+ responsive="true"
172
+ ></mj-html-attribute>
173
+ </mj-html-attributes>
174
+
175
+ <mj-breakpoint width="480px" />
176
+ <mj-attributes>
177
+ <mj-all font-family="lucida Grande,Verdana,Microsoft YaHei" />
178
+ <mj-text font-size="14px" />
179
+ <mj-text color="#000000" />
180
+ <mj-text line-height="1.7" />
181
+ </mj-attributes>
182
+ </mj-head>
183
+ <mj-body
184
+ background-color="#efeeea"
185
+ width="600px"
186
+ css-class="mjml-body"
187
+ >
188
+ <mj-section
189
+ padding="20px 0px 20px 0px"
190
+ border="none"
191
+ direction="ltr"
192
+ text-align="center"
193
+ background-repeat="repeat"
194
+ background-size="auto"
195
+ background-position="top center"
196
+ >
197
+ <mj-column
198
+ padding="0px 0px 0px 0px"
199
+ border="none"
200
+ vertical-align="top"
201
+ >
202
+ <mj-text
203
+ padding="20px"
204
+ align="center"
205
+ color="#ffffff"
206
+ font-family="Helvetica"
207
+ font-size="45px"
208
+ line-height="45px"
209
+ font-weight="900"
210
+ >
211
+ GO TO SPACE
212
+ </mj-text>
213
+
214
+ <mj-button
215
+ align="center"
216
+ background-color="#414141"
217
+ color="#ffffff"
218
+ font-weight="normal"
219
+ border-radius="3px"
220
+ padding="10px 25px 10px 25px"
221
+ inner-padding="10px 25px 10px 25px"
222
+ line-height="120%"
223
+ target="_blank"
224
+ vertical-align="middle"
225
+ border="none"
226
+ text-align="center"
227
+ href="https://mjml.io/"
228
+ >
229
+ ORDER YOUR TICKET NOW
230
+ </mj-button>
231
+ </mj-column>
232
+ </mj-section>
233
+ </mj-body>
234
+ </mjml>
235
+ ```
236
+
237
+ ## Customize your block
238
+
239
+ ```tsx
240
+ import { merge } from 'lodash';
241
+ import {
242
+ createCustomBlock,
243
+ IBlockData,
244
+ components,
245
+ BasicType,
246
+ JsonToMjml,
247
+ BasicType,
248
+ BlockManager,
249
+ } from 'easy-email-core';
250
+ const { Section, Column, Image, Button } = components;
251
+
252
+ type IMyFirstBlock = IBlockData<
253
+ {
254
+ 'background-color': string;
255
+ 'text-color': string;
256
+ },
257
+ {
258
+ buttonText: string;
259
+ imageUrl: string;
260
+ }
261
+ >;
262
+
263
+ const myFirstBlock = createCustomBlock({
264
+ name: 'My first block',
265
+ type: 'MY_FIRST_BLOCK',
266
+ create(payload) {
267
+ const defaultData: IMyFirstBlock = {
268
+ type: 'MY_FIRST_BLOCK',
269
+ data: {
270
+ value: {
271
+ buttonText: 'Got it',
272
+ imageUrl:
273
+ 'http://res.cloudinary.com/dwkp0e1yo/image/upload/v1665841616/pn7npfspxaqfzxiensue.png',
274
+ },
275
+ },
276
+ attributes: {
277
+ 'background-color': '#4A90E2',
278
+ 'text-color': '#ffffff',
279
+ },
280
+ children: [],
281
+ };
282
+ return merge(defaultData, payload);
283
+ },
284
+ validParentType: [BasicType.PAGE, BasicType.WRAPPER],
285
+ render(
286
+ data: IMyFirstBlock,
287
+ idx: string | null,
288
+ mode: 'testing' | 'production',
289
+ context?: IPage,
290
+ dataSource?: { [key: string]: any },
291
+ ) {
292
+ const { imageUrl, buttonText } = data.data.value;
293
+ const attributes = data.attributes;
294
+
295
+ const instance = (
296
+ <Section padding='20px'>
297
+ <Column>
298
+ <Image
299
+ padding='0px 0px 0px 0px'
300
+ width='100px'
301
+ src={imageUrl}
302
+ />
303
+ <Button
304
+ background-color={attributes['background-color']}
305
+ color={attributes['text-color']}
306
+ href='#'
307
+ >
308
+ {buttonText}
309
+ </Button>
310
+ </Column>
311
+ </Section>
312
+ );
313
+ return instance;
314
+ },
315
+ });
316
+
317
+ BlockManager.registerBlocks({ myFirstBlock });
318
+
319
+ const pageBlock = BlockManager.getBlockByType(BasicType.PAGE);
320
+
321
+ console.log(
322
+ JsonToMjml({
323
+ data: pageBlock.create({
324
+ children: [myFirstBlock.create()],
325
+ }),
326
+ mode: 'production',
327
+ }),
328
+ );
329
+ ```
330
+
331
+ // output
332
+
333
+ ```html
334
+ <mjml>
335
+ <mj-head>
336
+ <mj-html-attributes>
337
+ <mj-html-attribute
338
+ class="easy-email"
339
+ multiple-attributes="false"
340
+ attribute-name="text-color"
341
+ text-color="#000000"
342
+ ></mj-html-attribute>
343
+ <mj-html-attribute
344
+ class="easy-email"
345
+ multiple-attributes="false"
346
+ attribute-name="font-family"
347
+ font-family="lucida Grande,Verdana,Microsoft YaHei"
348
+ ></mj-html-attribute>
349
+ <mj-html-attribute
350
+ class="easy-email"
351
+ multiple-attributes="false"
352
+ attribute-name="font-size"
353
+ font-size="14px"
354
+ ></mj-html-attribute>
355
+ <mj-html-attribute
356
+ class="easy-email"
357
+ multiple-attributes="false"
358
+ attribute-name="line-height"
359
+ line-height="1.7"
360
+ ></mj-html-attribute>
361
+ <mj-html-attribute
362
+ class="easy-email"
363
+ multiple-attributes="false"
364
+ attribute-name="responsive"
365
+ responsive="true"
366
+ ></mj-html-attribute>
367
+ </mj-html-attributes>
368
+
369
+ <mj-breakpoint width="480px" />
370
+ <mj-attributes>
371
+ <mj-all font-family="lucida Grande,Verdana,Microsoft YaHei" />
372
+ <mj-text font-size="14px" />
373
+ <mj-text color="#000000" />
374
+ <mj-text line-height="1.7" />
375
+ </mj-attributes>
376
+ </mj-head>
377
+ <mj-body
378
+ background-color="#efeeea"
379
+ width="600px"
380
+ css-class="mjml-body"
381
+ >
382
+ <mj-section
383
+ padding="20px"
384
+ background-repeat="repeat"
385
+ background-size="auto"
386
+ background-position="top center"
387
+ border="none"
388
+ direction="ltr"
389
+ text-align="center"
390
+ >
391
+ <mj-column
392
+ padding="0px 0px 0px 0px"
393
+ border="none"
394
+ vertical-align="top"
395
+ >
396
+ <mj-image
397
+ align="center"
398
+ height="auto"
399
+ padding="0px 0px 0px 0px"
400
+ src="http://res.cloudinary.com/dwkp0e1yo/image/upload/v1665841616/pn7npfspxaqfzxiensue.png"
401
+ width="100px"
402
+ >
403
+ </mj-image>
404
+
405
+ <mj-button
406
+ align="center"
407
+ background-color="#4A90E2"
408
+ color="#ffffff"
409
+ font-weight="normal"
410
+ border-radius="3px"
411
+ padding="10px 25px 10px 25px"
412
+ inner-padding="10px 25px 10px 25px"
413
+ line-height="120%"
414
+ target="_blank"
415
+ vertical-align="middle"
416
+ border="none"
417
+ text-align="center"
418
+ href="#"
419
+ >
420
+ Got it
421
+ </mj-button>
422
+ </mj-column>
423
+ </mj-section>
424
+ </mj-body>
425
+ </mjml>
426
+ ```