@mjml-agent-editor/editor 0.2.0 → 0.4.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/README.md +34 -2
- package/dist/canvas.cjs +597 -226
- package/dist/canvas.cjs.map +1 -1
- package/dist/canvas.d.cts +30 -2
- package/dist/canvas.d.ts +30 -2
- package/dist/canvas.js +589 -222
- package/dist/canvas.js.map +1 -1
- package/dist/{chunk-FTEJNUJL.js → chunk-PXFZVLNQ.js} +5 -2
- package/dist/chunk-PXFZVLNQ.js.map +1 -0
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/editor/editor-theme.css +4 -0
- package/dist/chunk-FTEJNUJL.js.map +0 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ on the canvas.
|
|
|
9
9
|
| -------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------ |
|
|
10
10
|
| `@mjml-agent-editor/editor` | stores, `EditorHeader`, `ChatPanel`, `CanvasComments`, types | Safe to import anywhere |
|
|
11
11
|
| `@mjml-agent-editor/editor/ui` | the shadcn primitives and `cn` | Light; no canvas |
|
|
12
|
-
| `@mjml-agent-editor/editor/canvas` | `EmailEditor`
|
|
12
|
+
| `@mjml-agent-editor/editor/canvas` | `EmailEditor`, `blockProblems` | **Browser only** — GrapesJS touches `window` at import |
|
|
13
13
|
| `@mjml-agent-editor/editor/styles.css` | editor chrome stylesheet | Import from your Tailwind entry |
|
|
14
14
|
|
|
15
15
|
The split is not cosmetic. With a single barrel, a layout file importing a tooltip provider
|
|
@@ -116,11 +116,43 @@ const images: ImageLibrary = {
|
|
|
116
116
|
|
|
117
117
|
`quota` (`{ used, limit }`) is shown in the picker and stops uploads when reached. Leave
|
|
118
118
|
`remove` out for a read-only gallery — a host that caps uploads but cannot reclaim the
|
|
119
|
-
storage would otherwise be handing out a way round its own cap.
|
|
119
|
+
storage would otherwise be handing out a way round its own cap. Leave `upload` out, and set
|
|
120
|
+
`allowUrl: false`, for a gallery of your own images and nothing else.
|
|
120
121
|
|
|
121
122
|
Without a library the picker takes URLs only. The editor never inlines a file as base64:
|
|
122
123
|
most mail clients block `data:` images, and every agent turn would pay for the bytes.
|
|
123
124
|
|
|
125
|
+
## Your own sections
|
|
126
|
+
|
|
127
|
+
`EmailEditor` takes `blocks`: sections of your own, listed in the palette after the built-in
|
|
128
|
+
blocks, under `blockCategorySections`. Each is one `<mj-section>` of MJML; once dropped it is
|
|
129
|
+
ordinary MJML that the agent edits like any other section, and it gets its `sec-*` id then.
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
const BLOCKS = [{ id: "footer", label: "Footer", mjml: FOOTER_MJML }] satisfies SectionBlock[];
|
|
133
|
+
|
|
134
|
+
<EmailEditor docId={docId} blocks={BLOCKS} /* … */ />;
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The agent compiles the whole email strictly on every write, so a section the editor cannot
|
|
138
|
+
keep would block it in every email it is dropped in. `blockProblems(mjml)` says why a block
|
|
139
|
+
cannot be offered — it is not strict MJML, not exactly one section, carries a `sec-*`/`obj-*`
|
|
140
|
+
id, a link whose scheme is not http, https, mailto, tel or sms, or a `data:` image, holds markup
|
|
141
|
+
the editor drops, or uses a tag a section here cannot hold (`mj-table`, `mj-hero`, accordion
|
|
142
|
+
and carousel, which the editor cannot edit; `mj-wrapper` and `mj-raw`). The editor leaves such
|
|
143
|
+
a block out and logs why; call it in a test of your catalog to find out before your users do.
|
|
144
|
+
It needs a DOM, so run that test under jsdom. Labels are plain text. `blocks` is read once,
|
|
145
|
+
when the editor starts.
|
|
146
|
+
|
|
147
|
+
Every tile, built-in or yours, also works from the keyboard: Tab to it, and Enter or Space
|
|
148
|
+
adds it after the selected element or section (an element with nothing selected gets a
|
|
149
|
+
section of its own), selects it and announces it.
|
|
150
|
+
|
|
151
|
+
What an email loads from elsewhere: no built-in block carries a sample picture, but social
|
|
152
|
+
icons without a `src` of their own come from `www.mailjet.com`, and text without a
|
|
153
|
+
`font-family` gets MJML's default, Ubuntu from `fonts.googleapis.com`. Both reach every
|
|
154
|
+
reader's mail client, so name them wherever you list who receives your users' data.
|
|
155
|
+
|
|
124
156
|
## Copy
|
|
125
157
|
|
|
126
158
|
Every word the editor renders comes from a dictionary with English defaults, so a host
|