@maildeno/editor 0.1.4 → 0.4.3
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/CHANGELOG.md +304 -0
- package/README.md +397 -381
- package/dist/{RowPreviewLegacyComponent-yjHSkZLz.js → RowPreviewLegacyComponent-BFvLnPiK.js} +1 -1
- package/dist/{RowPreviewRow-D-wmhbhZ.js → RowPreviewRow-D-6koDUR.js} +2 -2
- package/dist/adapters/errors.d.ts +59 -0
- package/dist/adapters/index.d.ts +31 -0
- package/dist/adapters/types.d.ts +68 -0
- package/dist/brand.d.ts +15 -0
- package/dist/components/DesktopOnlyNotice.vue.d.ts +20 -0
- package/dist/components/features/emailBuilder/EmailEditor.vue.d.ts +182 -0
- package/dist/components/features/emailBuilder/assistant/AssistantPanel.vue.d.ts +37 -0
- package/dist/components/features/emailBuilder/blocks/AnchorBlock.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/blocks/ButtonBlock.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/blocks/DividerBlock.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/blocks/HeadingBlock.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/blocks/ImageBlock.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/blocks/ListBlock.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/blocks/MenuBlock.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/blocks/ParagraphBlock.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/blocks/SocialsBlock.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/blocks/SpacerBlock.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/blocks/VideoBlock.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/canvas/Canvas.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/canvas/CanvasColumn.vue.d.ts +49 -0
- package/dist/components/features/emailBuilder/canvas/CanvasComponent.vue.d.ts +56 -0
- package/dist/components/features/emailBuilder/canvas/CanvasElement.vue.d.ts +21 -0
- package/dist/components/features/emailBuilder/canvas/CanvasRow.vue.d.ts +49 -0
- package/dist/components/features/emailBuilder/canvas/CanvasRowSpacer.vue.d.ts +40 -0
- package/dist/components/features/emailBuilder/health/HealthIndicator.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/layout/Header.vue.d.ts +54 -0
- package/dist/components/features/emailBuilder/layout/SendEmail.vue.d.ts +21 -0
- package/dist/components/features/emailBuilder/layout/SidebarLeft.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/layout/SidebarRight.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/panels/AnchorPanel.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/panels/ButtonPanel.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/panels/DividerPanel.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/panels/HeadingPanel.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/panels/ImagePanel.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/panels/ListPanel.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/panels/MenuPanel.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/panels/ParagraphPanel.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/panels/RowColumnPanel.vue.d.ts +13 -0
- package/dist/components/features/emailBuilder/panels/RowPanel.vue.d.ts +13 -0
- package/dist/components/features/emailBuilder/panels/RowSpacerPanel.vue.d.ts +13 -0
- package/dist/components/features/emailBuilder/panels/SocialsPanel.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/panels/SpacerPanel.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/panels/VideoPanel.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/panels/shared/DeviceTabs.vue.d.ts +19 -0
- package/dist/components/features/emailBuilder/panels/shared/LinkFieldMergeTags.vue.d.ts +31 -0
- package/dist/components/features/emailBuilder/panels/shared/OverrideBadge.vue.d.ts +9 -0
- package/dist/components/features/emailBuilder/panels/shared/PreviewBadge.vue.d.ts +11 -0
- package/dist/components/features/emailBuilder/panels/shared/TextFieldMergeTags.vue.d.ts +25 -0
- package/dist/components/features/emailBuilder/panels/ui/BoxStylingSection.vue.d.ts +7 -0
- package/dist/components/features/emailBuilder/panels/ui/PropertyAlignment.vue.d.ts +30 -0
- package/dist/components/features/emailBuilder/panels/ui/PropertyColor.vue.d.ts +75 -0
- package/dist/components/features/emailBuilder/panels/ui/PropertyGradientColor.vue.d.ts +27 -0
- package/dist/components/features/emailBuilder/panels/ui/PropertyNumberSlider.vue.d.ts +74 -0
- package/dist/components/features/emailBuilder/panels/ui/PropertySection.vue.d.ts +17 -0
- package/dist/components/features/emailBuilder/panels/ui/PropertySelect.vue.d.ts +74 -0
- package/dist/components/features/emailBuilder/panels/ui/PropertyTextStyle.vue.d.ts +52 -0
- package/dist/components/features/emailBuilder/panels/ui/PropertyTextStylePanel.vue.d.ts +72 -0
- package/dist/components/features/emailBuilder/panels/ui/PropertyToggle.vue.d.ts +45 -0
- package/dist/components/features/emailBuilder/panels/ui/PropertyVisibility.vue.d.ts +32 -0
- package/dist/components/features/emailBuilder/panels/ui/SpacingControl.vue.d.ts +19 -0
- package/dist/components/features/emailBuilder/panels/ui/color-picker/AlphaSlider.vue.d.ts +28 -0
- package/dist/components/features/emailBuilder/panels/ui/color-picker/ColorPickerPanel.vue.d.ts +31 -0
- package/dist/components/features/emailBuilder/panels/ui/color-picker/HueSlider.vue.d.ts +19 -0
- package/dist/components/features/emailBuilder/panels/ui/color-picker/RecentColors.vue.d.ts +20 -0
- package/dist/components/features/emailBuilder/panels/ui/color-picker/SVPanel.vue.d.ts +39 -0
- package/dist/components/features/emailBuilder/panels/ui/visibility-rule/Rule.vue.d.ts +28 -0
- package/dist/components/features/emailBuilder/preview/PreviewScreen.vue.d.ts +7 -0
- package/dist/components/features/emailBuilder/preview/ui/PreviewCanvas.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/preview/ui/PreviewCapabilityBadges.vue.d.ts +12 -0
- package/dist/components/features/emailBuilder/preview/ui/PreviewClientCard.vue.d.ts +20 -0
- package/dist/components/features/emailBuilder/preview/ui/PreviewClientList.vue.d.ts +21 -0
- package/dist/components/features/emailBuilder/preview/ui/PreviewClientPicker.vue.d.ts +16 -0
- package/dist/components/features/emailBuilder/preview/ui/PreviewComponent.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/preview/ui/PreviewDetailView.vue.d.ts +41 -0
- package/dist/components/features/emailBuilder/preview/ui/PreviewRendered.vue.d.ts +8 -0
- package/dist/components/features/emailBuilder/product/RowPreview.vue.d.ts +8 -0
- package/dist/components/features/emailBuilder/product/RowPreviewChildren.vue.d.ts +14 -0
- package/dist/components/features/emailBuilder/product/RowPreviewLegacyComponent.vue.d.ts +14 -0
- package/dist/components/features/emailBuilder/product/RowPreviewRow.vue.d.ts +9 -0
- package/dist/components/features/emailBuilder/product/SavedRowsPanel.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/product/SavedTemplatesPanel.vue.d.ts +13 -0
- package/dist/components/features/emailBuilder/product/VersionHistoryPanel.vue.d.ts +14 -0
- package/dist/components/features/emailBuilder/sidebar/SidebarBlockButton.vue.d.ts +35 -0
- package/dist/components/features/emailBuilder/tabs/GeneralTab.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/tabs/LayoutTab.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/tabs/content/ContentTab.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/tabs/content/LayersPanel.vue.d.ts +7 -0
- package/dist/components/features/emailBuilder/tabs/general/MergeTagsTab.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/tabs/general/StylesTab.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/tabs/general/VisibilityTab.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/tabs/general/VisibilityWrapESPTab.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/tabs/general/merge-tags/LinkTagTab.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/tabs/general/merge-tags/MergeTagTab.vue.d.ts +3 -0
- package/dist/components/features/emailBuilder/ui/LinkInputDialog.vue.d.ts +17 -0
- package/dist/components/features/emailBuilder/ui/canvas/CanvasRowDropZone.vue.d.ts +12 -0
- package/dist/components/features/emailBuilder/ui/canvas/DropZone.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/ui/canvas/Loader.vue.d.ts +19 -0
- package/dist/components/features/emailBuilder/ui/layers-panel/ComponentIcon.vue.d.ts +7 -0
- package/dist/components/features/emailBuilder/ui/layers-panel/LayerColumnChildren.vue.d.ts +42 -0
- package/dist/components/features/emailBuilder/ui/layers-panel/LayerDropLine.vue.d.ts +8 -0
- package/dist/components/features/emailBuilder/ui/renderers/AnchorRenderer.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/ui/renderers/DividerRenderer.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/ui/renderers/HeadingRenderer.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/ui/renderers/ImageRenderer.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/ui/renderers/ListRenderer.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/ui/renderers/MenuRenderer.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/ui/renderers/ParagraphRenderer.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/ui/renderers/SocialsRenderer.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/ui/renderers/SpacerRenderer.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/ui/renderers/VideoRenderer.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/ui/rich-text-editor/RichTextEditor.vue.d.ts +12 -0
- package/dist/components/features/emailBuilder/ui/rich-text-editor/pickers/MergeTagPicker.vue.d.ts +18 -0
- package/dist/components/features/emailBuilder/ui/rich-text-editor/pickers/RichTextColorPicker.vue.d.ts +15 -0
- package/dist/components/features/emailBuilder/ui/visibility/SupportBadge.vue.d.ts +10 -0
- package/dist/components/features/emailBuilder/ui/visibility/VisibilityPopover.vue.d.ts +45 -0
- package/dist/components/ui/ConfirmDialog.vue.d.ts +3 -0
- package/dist/components/ui/Icon.vue.d.ts +33 -0
- package/dist/components/ui/InfoDialog.vue.d.ts +12 -0
- package/dist/components/ui/Loading.vue.d.ts +6 -0
- package/dist/components/ui/ShadowSafeToast.vue.d.ts +3 -0
- package/dist/components/ui/primitives/Button.vue.d.ts +23 -0
- package/dist/components/ui/primitives/DatePicker.vue.d.ts +16 -0
- package/dist/components/ui/primitives/Dialog.vue.d.ts +34 -0
- package/dist/components/ui/primitives/InputText.vue.d.ts +29 -0
- package/dist/components/ui/primitives/Message.vue.d.ts +20 -0
- package/dist/components/ui/primitives/Select.vue.d.ts +22 -0
- package/dist/composables/emailBuilder/components/useSystemRows.d.ts +22 -0
- package/dist/composables/emailBuilder/core/ui/useLayerHoverScroll.d.ts +10 -10
- package/dist/composables/emailBuilder/core/useEmailBuilder.d.ts +18 -0
- package/dist/composables/emailBuilder/export/logic/espLogicWrapper.d.ts +4 -4
- package/dist/composables/emailBuilder/export/targets/templateSnapshot.d.ts +24 -0
- package/dist/composables/emailBuilder/persistence/useEmailBuilderPersistence.d.ts +1 -1
- package/dist/composables/system/useColorScheme.d.ts +16 -0
- package/dist/editor.css +2074 -1688
- package/dist/{element-CWjNN0lY.js → element-95RHug4F.js} +3275 -1986
- package/dist/element-scoped-styles.css +2074 -1688
- package/dist/element.d.ts +1 -1
- package/dist/element.js +1 -1
- package/dist/{html-DGrfikay.js → html-D6UnSE1C.js} +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3325 -1984
- package/dist/init.d.ts +95 -2
- package/dist/init.js +29 -3
- package/dist/theme.d.ts +68 -17
- package/dist/types/assistant.d.ts +56 -0
- package/dist/{vue.runtime.esm-bundler-CfYyFhW6.js → vue.runtime.esm-bundler-BaHqghYy.js} +3 -3
- package/package.json +6 -3
- package/dist/composables/emailBuilder/transform/pipeline/optimizeAI.d.ts +0 -125
package/README.md
CHANGED
|
@@ -1,381 +1,397 @@
|
|
|
1
|
-
# @maildeno/editor
|
|
2
|
-
|
|
3
|
-
A drag-and-drop email template editor.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @maildeno/editor
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
One package, no peer dependencies, no CSS import. The editor injects its own
|
|
12
|
-
styling when it mounts.
|
|
13
|
-
|
|
14
|
-
## Minimal usage Vue
|
|
15
|
-
|
|
16
|
-
```vue
|
|
17
|
-
<script setup lang="ts">
|
|
18
|
-
import { EmailEditor } from "@maildeno/editor";
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<template>
|
|
22
|
-
<EmailEditor />
|
|
23
|
-
</template>
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Props and events
|
|
27
|
-
|
|
28
|
-
| Prop | Type |
|
|
29
|
-
| --- | --- |
|
|
30
|
-
| `templateId` | `string` |
|
|
31
|
-
| `storageAdapter` | `EditorStorageAdapter` |
|
|
32
|
-
| `theme` | `{ primaryColor?, surfaceColor? }` |
|
|
33
|
-
| `capabilities` | `{ export?: Array<"html"\|"mjml"\|"react"\|"json"> }` |
|
|
34
|
-
| `onSendTestEmail` | `(payload) => Promise<void>` |
|
|
35
|
-
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
editor
|
|
47
|
-
editor.value.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
- **
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
async
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
async
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
//
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
1
|
+
# @maildeno/editor
|
|
2
|
+
|
|
3
|
+
A drag-and-drop email template editor.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @maildeno/editor
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
One package, no peer dependencies, no CSS import. The editor injects its own
|
|
12
|
+
styling when it mounts.
|
|
13
|
+
|
|
14
|
+
## Minimal usage Vue
|
|
15
|
+
|
|
16
|
+
```vue
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import { EmailEditor } from "@maildeno/editor";
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<EmailEditor />
|
|
23
|
+
</template>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Props and events
|
|
27
|
+
|
|
28
|
+
| Prop | Type |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| `templateId` | `string` |
|
|
31
|
+
| `storageAdapter` | `EditorStorageAdapter` |
|
|
32
|
+
| `theme` | `{ primaryColor?, surfaceColor? }` |
|
|
33
|
+
| `capabilities` | `{ export?: Array<"html"\|"mjml"\|"react"\|"json"> }` |
|
|
34
|
+
| `onSendTestEmail` | `(payload) => Promise<void>` |
|
|
35
|
+
| `brandName` | `string` |
|
|
36
|
+
| `versions` | `boolean` |
|
|
37
|
+
| `assistant` | `AssistantMount` |
|
|
38
|
+
|
|
39
|
+
| Event | Payload |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| `@save` | `{ templateId: string \| null }` |
|
|
42
|
+
|
|
43
|
+
Reading content out uses a template ref:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
const editor = ref();
|
|
47
|
+
editor.value.getHtml("prune");
|
|
48
|
+
editor.value.getMjml();
|
|
49
|
+
editor.value.getReactEmail();
|
|
50
|
+
editor.value.getJson();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Minimal usage React
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { useEffect, useRef } from "react";
|
|
57
|
+
import { init, type EditorHandle } from "@maildeno/editor/init";
|
|
58
|
+
|
|
59
|
+
export default function Editor() {
|
|
60
|
+
const container = useRef<HTMLDivElement>(null);
|
|
61
|
+
const handle = useRef<EditorHandle | null>(null);
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
let cancelled = false;
|
|
65
|
+
|
|
66
|
+
init({ container: container.current! }).then((h) => {
|
|
67
|
+
// React 18 StrictMode mounts effects twice in development. Without
|
|
68
|
+
// this guard the first instance is orphaned and never destroyed.
|
|
69
|
+
if (cancelled) return h.destroy();
|
|
70
|
+
handle.current = h;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return () => {
|
|
74
|
+
cancelled = true;
|
|
75
|
+
handle.current?.destroy();
|
|
76
|
+
};
|
|
77
|
+
}, []);
|
|
78
|
+
|
|
79
|
+
return <div ref={container} />;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## `EditorHandle`
|
|
84
|
+
|
|
85
|
+
`init()` resolves to this once the editor has mounted:
|
|
86
|
+
|
|
87
|
+
| Member | Description |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| `element` | The underlying `<maildeno-editor>` DOM node. |
|
|
90
|
+
| `on(event, fn)` / `off(event, fn)` | Subscribe to editor events. Currently `"save"`. |
|
|
91
|
+
| `setTheme(theme)` | Re-theme live, any time after mount. |
|
|
92
|
+
| `getHtml(mode?)` | Current template as an HTML email string, or `null` if empty. |
|
|
93
|
+
| `getMjml(mode?)` | Current template as MJML. |
|
|
94
|
+
| `getReactEmail(mode?)` | Current template as React Email `.tsx` source. |
|
|
95
|
+
| `getJson()` | Current template as a plain object. |
|
|
96
|
+
| `setJson(data, opts?)` | Replace the canvas. Accepts what `getJson()` returns, so `setJson(getJson())` round-trips. `opts.history` is `"undoable"` (default) or `"reset"`. |
|
|
97
|
+
| `getSelection()` | `{ id, type }` for the selected block, or `null`. `type` is the block type (`"paragraph"`, `"image"`…). |
|
|
98
|
+
| `setSelection(id)` | Select by id, or clear with `null`. Returns `false` if no block has that id. |
|
|
99
|
+
| `onChange(cb)` | Runs `cb` after each committed change. Returns an unsubscribe function. |
|
|
100
|
+
| `destroy()` | Unmount and clean up. Always call this on unmount. |
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
### Getting content out
|
|
104
|
+
|
|
105
|
+
Four getters, available on the handle (`init()`) or a template ref (Vue component):
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
getHtml(mode?) // production-ready HTML email
|
|
109
|
+
getMjml(mode?) // MJML source
|
|
110
|
+
getReactEmail(mode?) // React Email .tsx source
|
|
111
|
+
getJson() // the template as a plain object
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`mode` is `"prune"` (default) or `"wrap"`, and only matters if you use ESP conditional visibility:
|
|
115
|
+
|
|
116
|
+
- **`"prune"`** evaluates conditions against the current preview context and outputs only the branches that match. Use it for a concrete send.
|
|
117
|
+
- **`"wrap"`** keeps every branch, wrapped in your ESP's conditional syntax. Use it when handing the HTML to an ESP that will do the evaluation itself.
|
|
118
|
+
|
|
119
|
+
They all return `null` when the canvas is empty, so check before using:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
const html = handle.getHtml();
|
|
123
|
+
if (!html) return; // nothing built yet
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`getJson()` returns the portable template format — `template_id`, `template_name`, `canvas`, `rows`, `schema_version`. Store it and pass it back via your adapter's `loadTemplate` to restore exactly.
|
|
127
|
+
|
|
128
|
+
## Feature reference
|
|
129
|
+
|
|
130
|
+
Everything below is identical across frameworks. Only the mounting differs.
|
|
131
|
+
|
|
132
|
+
### The editor at a glance
|
|
133
|
+
|
|
134
|
+
- **Drag-and-drop block editor** — paragraph, heading, image, video, list, button, anchor, divider, spacer, menu, socials, plus custom blocks you register.
|
|
135
|
+
- **Four export formats** — HTML, MJML, React Email (`.tsx`), JSON.
|
|
136
|
+
- **ESP-aware conditional logic** — visibility rules compile to the right syntax for Klaviyo, Mailchimp, Braze, SFMC, HubSpot, Iterable, Handlebars and more.
|
|
137
|
+
- **Merge tags** with an in-editor picker.
|
|
138
|
+
- **Saved templates and saved rows** — reusable snippets and full documents.
|
|
139
|
+
- **Desktop/mobile styling** — per-block mobile overrides.
|
|
140
|
+
- **Undo/redo**, autosave draft recovery, and a preview with client-specific rendering checks.
|
|
141
|
+
- **Zero backend required** — defaults to `localStorage`; bring an adapter to use your own.
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
### Storage adapter
|
|
145
|
+
|
|
146
|
+
The editor never talks to your backend directly. Implement this and it uses your storage for everything:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
import type { EditorStorageAdapter } from "@maildeno/editor";
|
|
150
|
+
|
|
151
|
+
const adapter: EditorStorageAdapter = {
|
|
152
|
+
// ── Templates ──────────────────────────────────────────────
|
|
153
|
+
async loadTemplate(templateId) {
|
|
154
|
+
if (!templateId) return null; // null = start blank
|
|
155
|
+
const res = await fetch(`/api/templates/${templateId}`);
|
|
156
|
+
if (!res.ok) return null;
|
|
157
|
+
const t = await res.json();
|
|
158
|
+
return { rows: t.rows, canvasStyles: t.canvasStyles, name: t.name };
|
|
159
|
+
},
|
|
160
|
+
async saveTemplate(snapshot, templateId) {
|
|
161
|
+
const res = await fetch(`/api/templates/${templateId ?? ""}`, {
|
|
162
|
+
method: templateId ? "PUT" : "POST",
|
|
163
|
+
body: JSON.stringify(snapshot),
|
|
164
|
+
});
|
|
165
|
+
return { templateId: (await res.json()).id }; // editor stamps this for later saves
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
// ── Optional: powers the "Saved templates" panel ───────────
|
|
169
|
+
// Return summaries, not full documents — listing shouldn't fetch every
|
|
170
|
+
// template's rows. Omit both and the panel says listing isn't supported.
|
|
171
|
+
async listTemplates() {
|
|
172
|
+
return fetch("/api/templates").then((r) => r.json());
|
|
173
|
+
// -> [{ templateId, name, updatedAt }]
|
|
174
|
+
},
|
|
175
|
+
async deleteTemplate(id) {
|
|
176
|
+
await fetch(`/api/templates/${id}`, { method: "DELETE" });
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
// ── Saved rows (reusable snippets) ─────────────────────────
|
|
180
|
+
// Optional second, read-only row library — an org's shared blocks.
|
|
181
|
+
// Shown in a "Shared" tab beside the user's own rows, and only when
|
|
182
|
+
// this returns something, so omitting it changes nothing. There is no
|
|
183
|
+
// save/rename/delete counterpart: curating a shared library is an admin
|
|
184
|
+
// concern the editor has no user model to express.
|
|
185
|
+
async listSystemSavedRows() {
|
|
186
|
+
return api.get("/org/saved-rows");
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
async listSavedRows() {
|
|
190
|
+
return fetch("/api/saved-rows").then((r) => r.json());
|
|
191
|
+
},
|
|
192
|
+
async saveSavedRow(row, name) {
|
|
193
|
+
return fetch("/api/saved-rows", {
|
|
194
|
+
method: "POST", body: JSON.stringify({ row, name }),
|
|
195
|
+
}).then((r) => r.json());
|
|
196
|
+
},
|
|
197
|
+
async deleteSavedRow(id) {
|
|
198
|
+
await fetch(`/api/saved-rows/${id}`, { method: "DELETE" });
|
|
199
|
+
},
|
|
200
|
+
async renameSavedRow(id, name) {
|
|
201
|
+
await fetch(`/api/saved-rows/${id}`, {
|
|
202
|
+
method: "PATCH", body: JSON.stringify({ name }),
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
// Synchronous — it runs during a drag, so it can't await. Read from
|
|
206
|
+
// whatever you already have client-side (e.g. your last listSavedRows result).
|
|
207
|
+
cloneSavedRowForCanvas(id) {
|
|
208
|
+
return structuredClone(rowCache.get(id) ?? null);
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
// ── Images ─────────────────────────────────────────────────
|
|
212
|
+
// Called when a user drops or picks an image. Return a public URL.
|
|
213
|
+
async uploadImage(file) {
|
|
214
|
+
const form = new FormData();
|
|
215
|
+
form.append("file", file);
|
|
216
|
+
const { url } = await fetch("/api/upload", { method: "POST", body: form })
|
|
217
|
+
.then((r) => r.json());
|
|
218
|
+
return url;
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Without an adapter, everything persists to `localStorage` — fine for demos, but images are stored as base64 data URIs, which will hit the ~5 MB quota quickly on image-heavy templates.
|
|
224
|
+
|
|
225
|
+
### Partial adapters
|
|
226
|
+
|
|
227
|
+
Every method is optional. Anything you leave out falls back to the built-in
|
|
228
|
+
localStorage adapter, so you can override only the parts you need:
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
// Upload images to your own storage; keep everything else local.
|
|
232
|
+
init({
|
|
233
|
+
storageAdapter: {
|
|
234
|
+
async uploadImage(file) {
|
|
235
|
+
const form = new FormData();
|
|
236
|
+
form.append("file", file);
|
|
237
|
+
const { url } = await fetch("/api/upload", { method: "POST", body: form })
|
|
238
|
+
.then((r) => r.json());
|
|
239
|
+
return url;
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
The fallback is per-method, not per-area. If you implement `saveTemplate`
|
|
246
|
+
against your own backend but leave `listTemplates` out, the saved-templates
|
|
247
|
+
panel will list localStorage templates rather than yours — the editor warns
|
|
248
|
+
about that specific mismatch in development. Implement `listTemplates` and
|
|
249
|
+
`deleteTemplate` alongside `loadTemplate`/`saveTemplate` to keep them
|
|
250
|
+
consistent.
|
|
251
|
+
|
|
252
|
+
### Sending email
|
|
253
|
+
|
|
254
|
+
The editor hands you `{ to, subject, html }` and stops there. Your ESP key must never reach the browser, so the send happens on your server:
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
// client
|
|
258
|
+
onSendTestEmail: async ({ to, subject, html }) => {
|
|
259
|
+
await fetch("/api/send-test", {
|
|
260
|
+
method: "POST",
|
|
261
|
+
body: JSON.stringify({ to, subject, html }),
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
// server — Resend shown; Postmark/SendGrid are the same shape
|
|
268
|
+
import { Resend } from "resend";
|
|
269
|
+
const resend = new Resend(process.env.RESEND_API_KEY);
|
|
270
|
+
|
|
271
|
+
export async function POST(req) {
|
|
272
|
+
const { to, subject, html } = await req.json();
|
|
273
|
+
await resend.emails.send({ from: "you@yourdomain.com", to, subject, html });
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
This is the **test-send** button only — one recipient, manual click. For a real campaign, pull the HTML yourself (`getHtml()`) and drive your own send to a list.
|
|
278
|
+
|
|
279
|
+
### Theming
|
|
280
|
+
|
|
281
|
+
One hex re-themes the whole editor coherently:
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
setTheme({ primary: "#6366f1" });
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Every surface reads from semantic tokens, so you can override just the parts
|
|
288
|
+
you care about without redefining the rest:
|
|
289
|
+
|
|
290
|
+
```ts
|
|
291
|
+
setTheme({
|
|
292
|
+
// Core — everything else derives from these
|
|
293
|
+
primary: "#e11d48",
|
|
294
|
+
background: "#f8fafc",
|
|
295
|
+
surface: "#ffffff",
|
|
296
|
+
text: "#111827",
|
|
297
|
+
border: "#e5e7eb",
|
|
298
|
+
|
|
299
|
+
// Individual surfaces
|
|
300
|
+
headerBg: "#111827",
|
|
301
|
+
headerText: "#f9fafb",
|
|
302
|
+
sidebarBg: "#ffffff",
|
|
303
|
+
canvasBg: "#f1f5f9",
|
|
304
|
+
inputBg: "#ffffff",
|
|
305
|
+
inputText: "#111827",
|
|
306
|
+
overlayBg: "#ffffff", // dialogs, toasts, dropdowns, date picker
|
|
307
|
+
toolbarBg: "#ffffff", // floating + rich-text toolbars
|
|
308
|
+
|
|
309
|
+
// The Save / Update button
|
|
310
|
+
buttonPrimaryBg: "#e11d48",
|
|
311
|
+
buttonPrimaryText: "#ffffff",
|
|
312
|
+
buttonPrimaryHoverBg: "#be123c",
|
|
313
|
+
|
|
314
|
+
// Dark mode — has its own complete defaults, so override only what differs
|
|
315
|
+
dark: {
|
|
316
|
+
primary: "#fb7185",
|
|
317
|
+
headerBg: "#0b0f19",
|
|
318
|
+
buttonPrimaryText: "#1e1b4b",
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Dark mode activates when the editor element carries the `dark` class:
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
handle.element.classList.toggle("dark");
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**Anything you leave out keeps its default**, so a partial theme is always
|
|
330
|
+
coherent rather than half-applied. Two things worth knowing:
|
|
331
|
+
|
|
332
|
+
- Set `onPrimary` (or `buttonPrimaryText`) when using a light brand colour, or
|
|
333
|
+
the primary button's label will be low-contrast against it.
|
|
334
|
+
- Severity tints for toasts and messages (`successBg`, `dangerFg`, …) have
|
|
335
|
+
separate dark defaults, so they don't leave pale panels sitting on a dark
|
|
336
|
+
surface.
|
|
337
|
+
|
|
338
|
+
Multiple editors on one page theme independently.
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
### Extension points
|
|
342
|
+
|
|
343
|
+
All three are additive — no need to fork or edit built-ins.
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
import { registerBlock, registerESPSyntax, registerMergeTags } from "@maildeno/editor";
|
|
347
|
+
|
|
348
|
+
// A custom block type
|
|
349
|
+
registerBlock({
|
|
350
|
+
name: "product-card",
|
|
351
|
+
label: "Product Card",
|
|
352
|
+
icon: "<svg …>",
|
|
353
|
+
schema: { /* default props */ },
|
|
354
|
+
renderCanvas: ProductCardCanvas, // Vue component shown in the editor
|
|
355
|
+
renderSettings: ProductCardPanel, // Vue component for the right panel
|
|
356
|
+
renderEmail: {
|
|
357
|
+
html: (props, ctx) => `<table>…</table>`,
|
|
358
|
+
mjml: (props, ctx) => `<mj-section>…</mj-section>`,
|
|
359
|
+
reactEmail: (props, ctx) => `<Section>…</Section>`,
|
|
360
|
+
},
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// Conditional syntax for an ESP that isn't built in
|
|
364
|
+
registerESPSyntax("my-esp", {
|
|
365
|
+
wrapOpenTag: (expr) => `{% if ${expr} %}`,
|
|
366
|
+
wrapCloseTag: () => `{% endif %}`,
|
|
367
|
+
wrapMergeTag: (key, fallback) =>
|
|
368
|
+
fallback ? `{{ ${key} | default: "${fallback}" }}` : `{{ ${key} }}`,
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
// Extra merge tags in the picker
|
|
372
|
+
registerMergeTags([
|
|
373
|
+
{ key: "customer.first_name" },
|
|
374
|
+
{ key: "order.total" },
|
|
375
|
+
]);
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
Call these **before** the editor mounts.
|
|
379
|
+
|
|
380
|
+
### Persisting which template is open
|
|
381
|
+
|
|
382
|
+
The editor doesn't own that decision. Listen for `save` and store the id however you track it:
|
|
383
|
+
|
|
384
|
+
```ts
|
|
385
|
+
handle.on("save", ({ templateId }) => {
|
|
386
|
+
router.replace(`/editor/${templateId}`); // or your DB, or app state
|
|
387
|
+
});
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
Pass it back as `templateId` next time to reopen.
|
|
391
|
+
|
|
392
|
+
### Practical notes
|
|
393
|
+
|
|
394
|
+
- **The container needs a real height.** The editor fills its parent; `height: 100vh` or a sized flex child both work.
|
|
395
|
+
- **`transform`, `filter`, `perspective` or `will-change` on any ancestor** breaks `position: fixed` inside it — floating toolbars and pickers will land in the wrong place. Avoid them above the mount point.
|
|
396
|
+
- **Desktop only.** The editor shows a notice on small screens rather than attempting a mobile drag-and-drop UI.
|
|
397
|
+
- **Autosave** keeps a local draft, so a refresh mid-edit recovers. "New template" clears it deliberately.
|