@mjml-agent-editor/editor 0.2.0 → 0.3.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 +32 -1
- package/dist/canvas.cjs +445 -83
- 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 +437 -79
- package/dist/canvas.js.map +1 -1
- package/dist/{chunk-FTEJNUJL.js → chunk-K7KQC7LX.js} +5 -2
- package/dist/chunk-K7KQC7LX.js.map +1 -0
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- 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
|
|
@@ -121,6 +121,37 @@ storage would otherwise be handing out a way round its own cap.
|
|
|
121
121
|
Without a library the picker takes URLs only. The editor never inlines a file as base64:
|
|
122
122
|
most mail clients block `data:` images, and every agent turn would pay for the bytes.
|
|
123
123
|
|
|
124
|
+
## Your own sections
|
|
125
|
+
|
|
126
|
+
`EmailEditor` takes `blocks`: sections of your own, listed in the palette after the built-in
|
|
127
|
+
blocks, under `blockCategorySections`. Each is one `<mj-section>` of MJML; once dropped it is
|
|
128
|
+
ordinary MJML that the agent edits like any other section, and it gets its `sec-*` id then.
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
const BLOCKS = [{ id: "footer", label: "Footer", mjml: FOOTER_MJML }] satisfies SectionBlock[];
|
|
132
|
+
|
|
133
|
+
<EmailEditor docId={docId} blocks={BLOCKS} /* … */ />;
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The agent compiles the whole email strictly on every write, so a section the editor cannot
|
|
137
|
+
keep would block it in every email it is dropped in. `blockProblems(mjml)` says why a block
|
|
138
|
+
cannot be offered — it is not strict MJML, not exactly one section, carries a `sec-*`/`obj-*`
|
|
139
|
+
id, a link whose scheme is not http, https, mailto, tel or sms, or a `data:` image, holds markup
|
|
140
|
+
the editor drops, or uses a tag a section here cannot hold (`mj-table`, `mj-hero`, accordion
|
|
141
|
+
and carousel, which the editor cannot edit; `mj-wrapper` and `mj-raw`). The editor leaves such
|
|
142
|
+
a block out and logs why; call it in a test of your catalog to find out before your users do.
|
|
143
|
+
It needs a DOM, so run that test under jsdom. Labels are plain text. `blocks` is read once,
|
|
144
|
+
when the editor starts.
|
|
145
|
+
|
|
146
|
+
Every tile, built-in or yours, also works from the keyboard: Tab to it, and Enter or Space
|
|
147
|
+
adds it after the selected element or section (an element with nothing selected gets a
|
|
148
|
+
section of its own), selects it and announces it.
|
|
149
|
+
|
|
150
|
+
What an email loads from elsewhere: no built-in block carries a sample picture, but social
|
|
151
|
+
icons without a `src` of their own come from `www.mailjet.com`, and text without a
|
|
152
|
+
`font-family` gets MJML's default, Ubuntu from `fonts.googleapis.com`. Both reach every
|
|
153
|
+
reader's mail client, so name them wherever you list who receives your users' data.
|
|
154
|
+
|
|
124
155
|
## Copy
|
|
125
156
|
|
|
126
157
|
Every word the editor renders comes from a dictionary with English defaults, so a host
|