@seliseblocks/mailcraft 0.1.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.
- package/DOCS.md +557 -0
- package/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/mailcraft-editor.bundle.js +519 -0
- package/dist/mailcraft-editor.bundle.js.map +7 -0
- package/examples/templates/activate-your-account.html +54 -0
- package/examples/templates/back-in-stock.html +63 -0
- package/examples/templates/cart-left-behind.html +74 -0
- package/examples/templates/community-giveaway.html +81 -0
- package/examples/templates/frontend-futures-invite.html +69 -0
- package/examples/templates/give-25-get-25.html +69 -0
- package/examples/templates/invoice-paid.html +77 -0
- package/examples/templates/meet-nova-launch.html +69 -0
- package/examples/templates/mega-weekend-sale.html +57 -0
- package/examples/templates/order-confirmed.html +80 -0
- package/examples/templates/rate-your-headphones.html +71 -0
- package/examples/templates/reset-your-password.html +54 -0
- package/examples/templates/thankyou-promo-code.html +68 -0
- package/examples/templates/the-sunday-brief.html +47 -0
- package/examples/templates/welcome-to-your-workspace.html +62 -0
- package/examples/templates/your-order-shipped.html +74 -0
- package/examples/templates/your-password-was-changed.html +58 -0
- package/examples/templates/your-signin-code.html +58 -0
- package/examples/vanilla.html +1574 -0
- package/package.json +66 -0
- package/src/core/accent.js +194 -0
- package/src/core/assets.js +15 -0
- package/src/core/binder.js +119 -0
- package/src/core/blocks.js +256 -0
- package/src/core/css-cascade.js +117 -0
- package/src/core/editor-core.js +1492 -0
- package/src/core/export.js +58 -0
- package/src/core/footer.js +73 -0
- package/src/core/i18n/ar.js +177 -0
- package/src/core/i18n/bg.js +152 -0
- package/src/core/i18n/bn.js +176 -0
- package/src/core/i18n/ca.js +152 -0
- package/src/core/i18n/cs.js +152 -0
- package/src/core/i18n/da.js +152 -0
- package/src/core/i18n/de-CH.js +152 -0
- package/src/core/i18n/de.js +152 -0
- package/src/core/i18n/dz.js +179 -0
- package/src/core/i18n/el.js +152 -0
- package/src/core/i18n/en.js +269 -0
- package/src/core/i18n/es.js +152 -0
- package/src/core/i18n/et.js +152 -0
- package/src/core/i18n/fi.js +152 -0
- package/src/core/i18n/fr.js +152 -0
- package/src/core/i18n/hr.js +152 -0
- package/src/core/i18n/hu.js +152 -0
- package/src/core/i18n/index.js +83 -0
- package/src/core/i18n/it.js +152 -0
- package/src/core/i18n/lt.js +152 -0
- package/src/core/i18n/lv.js +152 -0
- package/src/core/i18n/nb.js +152 -0
- package/src/core/i18n/nl.js +152 -0
- package/src/core/i18n/pl.js +152 -0
- package/src/core/i18n/pt.js +152 -0
- package/src/core/i18n/ro.js +152 -0
- package/src/core/i18n/ru.js +152 -0
- package/src/core/i18n/sk.js +152 -0
- package/src/core/i18n/sl.js +152 -0
- package/src/core/i18n/sv.js +152 -0
- package/src/core/i18n/tables.js +50 -0
- package/src/core/i18n/tr.js +152 -0
- package/src/core/i18n/uk.js +152 -0
- package/src/core/icons.js +235 -0
- package/src/core/ids.js +1 -0
- package/src/core/import-html.js +959 -0
- package/src/core/layout-style.js +115 -0
- package/src/core/parse.js +10 -0
- package/src/core/placeholder.js +15 -0
- package/src/core/sanitize.js +141 -0
- package/src/core/storage-limits.js +184 -0
- package/src/core/storage.js +85 -0
- package/src/core/theme.js +1 -0
- package/src/core/toolbar.js +67 -0
- package/src/core/variables.js +11 -0
- package/src/create-editor.js +109 -0
- package/src/index.js +9 -0
- package/src/mailcraft-editor.js +1862 -0
- package/src/render/block-body.js +295 -0
- package/src/render/canvas.js +284 -0
- package/src/render/fields.js +609 -0
- package/src/render/focus-preserve.js +158 -0
- package/src/render/rte.js +212 -0
- package/src/render/screenshot.js +132 -0
- package/src/render/story.js +415 -0
- package/src/render/style.js +452 -0
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# MailCraft
|
|
2
|
+
|
|
3
|
+
Drag-and-drop email editor as a Web Component. No dependencies, no framework, no build step.
|
|
4
|
+
|
|
5
|
+
**[Live demo](https://mailcraft.seliseblocks.com/examples/vanilla.html)** · **[Documentation](https://mailcraft.seliseblocks.com/DOCS.html)**
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @seliseblocks/mailcraft
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Use
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import '@seliseblocks/mailcraft'; // registers <mailcraft-editor>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<mailcraft-editor id="editor"></mailcraft-editor>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or mount it into a container from code, without writing the tag:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { createEditor } from '@seliseblocks/mailcraft';
|
|
25
|
+
|
|
26
|
+
const editor = createEditor('#mail', { html, toolbar: false });
|
|
27
|
+
editor.exportHtml();
|
|
28
|
+
editor.destroy();
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
That is a working editor. It speaks HTML in both directions — there is no document format to store or migrate:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
editor.loadTemplate({ name: 'Welcome', html }); // give it HTML
|
|
35
|
+
const html = editor.exportHtml(); // get send-ready HTML back
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Exported HTML is valid input to `loadTemplate`, so saving the export *is* saving the user's work.
|
|
39
|
+
|
|
40
|
+
## Configure
|
|
41
|
+
|
|
42
|
+
| | |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `variables="first_name,company"` | merge tags, exported as `{{first_name}}` |
|
|
45
|
+
| `locale="de"` | 31 languages, RTL automatic |
|
|
46
|
+
| `theme="light" \| "dark"` | host owns light/dark; hides the built-in toggle |
|
|
47
|
+
| `ui-font="inherit"` | match your app's font |
|
|
48
|
+
| `accent="#e11d48"` | your brand color, everywhere the editor is accented; also `var(--brand)` or `inherit` |
|
|
49
|
+
| `toolbar="none"` | hide the editor's own top bar |
|
|
50
|
+
| `footer="none"` | drop the "Powered by SELISE Blocks © 2026" strip, or pass your own line |
|
|
51
|
+
| `toolbar="undo,redo,export"` | …or keep only these parts |
|
|
52
|
+
| `.storageProvider` + `.storageLimits` | image uploads to your backend |
|
|
53
|
+
| `.aiProvider` | `async (prompt) => text`, powers the AI draft panel |
|
|
54
|
+
| `.messages` | override any UI string |
|
|
55
|
+
|
|
56
|
+
Every attribute is also a property. Full reference and integration recipes: **[DOCS.md](DOCS.md)**.
|
|
57
|
+
|
|
58
|
+
## For AI agents
|
|
59
|
+
|
|
60
|
+
Everything an assistant needs to wire this up correctly:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
PACKAGE @seliseblocks/mailcraft — Web Component, zero runtime deps
|
|
64
|
+
IMPORT import '@seliseblocks/mailcraft' (side effect: registers the element)
|
|
65
|
+
Safe to import under SSR; the element itself renders in a browser only.
|
|
66
|
+
ELEMENT <mailcraft-editor id="editor"></mailcraft-editor>
|
|
67
|
+
MOUNT createEditor(target, options) -> handle (no tag needed)
|
|
68
|
+
target = CSS selector or Element; throws if it matches nothing
|
|
69
|
+
options = html, name, variables, locale, dir, theme, uiFont, accent, toolbar,
|
|
70
|
+
footer, storageProvider, storageLimits, aiProvider, iconProvider,
|
|
71
|
+
messages, height, replace, onChange(doc), onExport(html)
|
|
72
|
+
name = template name for `html`; read only alongside it
|
|
73
|
+
handle = the METHODS below + .element + .destroy()
|
|
74
|
+
The container supplies the height; the editor fills it.
|
|
75
|
+
|
|
76
|
+
DATA HTML in, HTML out. There is no JSON document format in the public API.
|
|
77
|
+
editor.loadTemplate({ name, html }) apply HTML (undoable, deep-copied)
|
|
78
|
+
editor.importHtml(html) apply HTML (same importer)
|
|
79
|
+
editor.exportHtml() -> string send-ready email HTML
|
|
80
|
+
Persist by storing exportHtml() and passing it back to loadTemplate().
|
|
81
|
+
Unclassifiable markup survives as a raw-HTML block. Nothing is dropped.
|
|
82
|
+
|
|
83
|
+
EVENTS 'change' detail = internal doc (do not persist this)
|
|
84
|
+
'export' detail = HTML string
|
|
85
|
+
|
|
86
|
+
ATTRS variables="a,b,c" | locale="de" | theme="dark" | dir="rtl"
|
|
87
|
+
ui-font="inherit" | accent="#e11d48" | accent="var(--brand)"
|
|
88
|
+
toolbar="none" | toolbar="undo,redo,export" | footer="none"
|
|
89
|
+
PROPS .variables .toolbar .footer .uiFont .accent .messages .aiProvider .iconProvider
|
|
90
|
+
.storageProvider .storageLimits
|
|
91
|
+
METHODS exportHtml() importHtml(html) loadTemplate(tpl) undo() redo()
|
|
92
|
+
screenshotPng() previewScreenshot() downloadScreenshot() copyScreenshot()
|
|
93
|
+
|
|
94
|
+
KEYS Bound on window, so they survive toolbar="none":
|
|
95
|
+
Esc (leave field / deselect + close), Ctrl/Cmd+Z, Shift+Ctrl/Cmd+Z,
|
|
96
|
+
Ctrl/Cmd+E (export dialog), Ctrl/Cmd+K (link, while editing),
|
|
97
|
+
Ctrl/Cmd+D (duplicate), Backspace|Delete (delete selection).
|
|
98
|
+
|
|
99
|
+
UPLOADS Limits and a provider are both required, or every upload is refused.
|
|
100
|
+
editor.storageLimits = { accept:['image/jpeg','image/png','image/gif'],
|
|
101
|
+
maxBytes: 2*1024*1024 }
|
|
102
|
+
editor.storageProvider = { list(q), upload(file, o), folders?(), remove?(a),
|
|
103
|
+
limits? }
|
|
104
|
+
provider.limits is merged per key under .storageLimits, and satisfies
|
|
105
|
+
the requirement on its own. .storageProvider = null restores the demo library.
|
|
106
|
+
The editor never makes a network request itself.
|
|
107
|
+
|
|
108
|
+
TOOLBAR Parts: logo status device undo redo theme ai code preview export
|
|
109
|
+
Attribute = allow-list (keep these). Property = { part: false } (drop these).
|
|
110
|
+
none|hidden|off|false = no bar at all; all = the default.
|
|
111
|
+
Hidden undo/redo/export stay reachable — methods, plus Ctrl/Cmd+Z, +E.
|
|
112
|
+
preview, code and ai are bar-only: hiding them removes the panel.
|
|
113
|
+
|
|
114
|
+
DO NOT Do not use getContent()/setContent() — internal, shape may change.
|
|
115
|
+
Do not expect a campaign/title option — there is none; <title> is "Email".
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Develop
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
npm install && node build.js && npm test
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`examples/vanilla.html` is a complete host page — open it directly, no server needed. It ships in the npm package too, so it is there after an install; the [hosted copy](https://mailcraft.seliseblocks.com/examples/vanilla.html) is the same file.
|
|
125
|
+
|
|
126
|
+
MIT
|