Skip to content

Commit 200ad02

Browse files
committed
Updated basic example
1 parent 8ce309b commit 200ad02

File tree

1 file changed

+34
-45
lines changed

1 file changed

+34
-45
lines changed

example/basic/index.tsx

Lines changed: 34 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ const displayConditions = [
2525
label: "Children",
2626
description: "All children customers",
2727
key: "ischild",
28-
},
29-
{
30-
label: "Custom",
31-
description: "All custom customers",
32-
before: "{{#custom}}",
33-
after: "{{/custom}}",
3428
}
3529
]
3630

@@ -57,7 +51,7 @@ const BasicExample = () => {
5751
// const { design, html } = data;
5852
console.log("exportHtml", data);
5953
console.log("Output HTML has been logged in your developer console.");
60-
});
54+
}, {minify: true});
6155
};
6256

6357
const togglePreview = () => {
@@ -90,45 +84,33 @@ const BasicExample = () => {
9084

9185
const setMergeTags = () => {
9286
const mailui = mailUiEditorRef.current?.editor;
93-
mailui?.setMergeTags([
94-
{
87+
mailui?.setMergeTags({
88+
first_name: {
9589
label: "First name",
9690
value: "{{ first_name }}",
9791
},
98-
{
92+
last_name: {
9993
label: "Last name",
10094
value: "{{ last_name }}",
10195
},
102-
{
96+
shopping: {
10397
label: "Shipping address-",
104-
margeTags: [
105-
{
98+
margeTags: {
99+
'shipping_address.city': {
106100
label: "City 1",
107101
value: "{{ shipping_address.city }}",
108102
},
109-
{
103+
'shipping_address.state': {
110104
label: "State 1",
111105
value: "{{ shipping_address.state }}",
112106
},
113-
{
107+
'shipping_address.country': {
114108
label: "Country 1",
115109
value: "{{ shipping_address.country }}",
116110
},
117-
{
118-
label: "City 2",
119-
value: "{{ shipping_address.city }}",
120-
},
121-
{
122-
label: "State 2",
123-
value: "{{ shipping_address.state }}",
124-
},
125-
{
126-
label: "Country 2",
127-
value: "{{ shipping_address.country }}",
128-
},
129-
],
111+
}
130112
},
131-
]);
113+
});
132114
};
133115

134116
const loadTemplate = () => {
@@ -146,7 +128,7 @@ const BasicExample = () => {
146128
const loadConvertDesign = () => {
147129
const mailui = mailUiEditorRef.current?.editor;
148130
mailui?.loadDesign(unlayerTemplate);
149-
console.log("dfsdf__");
131+
console.log("Convert Design");
150132
};
151133

152134
const loadListener = () => {
@@ -200,11 +182,16 @@ const BasicExample = () => {
200182
console.log("image:onUpload", params);
201183

202184
setTimeout(() => {
203-
done("https://api.slingacademy.com/public/sample-photos/9.jpeg");
185+
done({
186+
id: 111,
187+
src: "https://api.slingacademy.com/public/sample-photos/9.jpeg",
188+
fileName: '',
189+
alt: ''
190+
});
204191
}, 3000);
205192
});
206193

207-
mailui.registerCallback("image:removed", function (image: object, done: Function) {
194+
mailui.registerCallback("image:onRemove", function (image: object, done: Function) {
208195
// image will include id, userId and projectId
209196
console.log(image);
210197

@@ -234,9 +221,9 @@ const BasicExample = () => {
234221
});
235222

236223
/**
237-
* Library
224+
* Block
238225
*/
239-
mailui.registerProvider("library:collections", async (params: {}, done: Function) => {
226+
mailui.registerProvider("block:collections", async (params: {}, done: Function) => {
240227
console.log("params", params);
241228

242229
/**
@@ -245,7 +232,7 @@ const BasicExample = () => {
245232
const collections: any[] = []
246233
done(collections);
247234
});
248-
mailui.registerProvider("library:collectionData", async (params: {}, done: Function) => {
235+
mailui.registerProvider("block:collectionData", async (params: {}, done: Function) => {
249236
console.log("params", params);
250237

251238
/**
@@ -256,20 +243,20 @@ const BasicExample = () => {
256243
done(collectionData);
257244
}, 4000)
258245
});
259-
mailui.registerProvider("library:saved", async (params: object, done: Function) => {
260-
console.log("library:onSave", params);
246+
mailui.registerProvider("block:saved", async (params: object, done: Function) => {
247+
console.log("block:onSave", params);
261248
setTimeout(() => {
262-
done({name: 'saved library', id: 111});
249+
done({name: 'saved block', id: 111});
263250
}, 3000);
264251
});
265-
mailui.registerCallback("library:removed", async (params: object, done: Function) => {
266-
console.log("library:onSave", params);
252+
mailui.registerCallback("block:removed", async (params: object, done: Function) => {
253+
console.log("block:onSave", params);
267254
setTimeout(() => {
268255
done();
269256
}, 3000);
270257
});
271-
mailui.registerCallback("library:saveAuthAlert", async (params: object, done: Function) => {
272-
console.log("library:saveAuthAlert", params);
258+
mailui.registerCallback("block:saveAuthAlert", async (params: object, done: Function) => {
259+
console.log("block:saveAuthAlert", params);
273260
done(true);
274261
});
275262
// mailui.registerCallback("displayCondition", async (params: object, done: Function) => {
@@ -303,7 +290,9 @@ const BasicExample = () => {
303290
return acc;
304291
}, {});
305292

306-
done(data)
293+
done({
294+
dataMap: data
295+
})
307296
});
308297

309298
mailui?.setDisplayConditions(displayConditions)
@@ -441,11 +430,11 @@ const BasicExample = () => {
441430
safeSearch: true,
442431
// defaultSearchTerm: "people",
443432
},
444-
stockLibrary: {
433+
stockBlocks: {
445434
enabled: true,
446435
safeFilter: true,
447436
},
448-
saveToLibrary: {
437+
saveToBlock: {
449438
enabled: true,
450439
authAlert: true,
451440
},

0 commit comments

Comments
 (0)