@mjml-agent-editor/editor 0.1.17 → 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 +40 -5
- package/dist/canvas.cjs +3409 -624
- 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 +2946 -386
- package/dist/canvas.js.map +1 -1
- package/dist/{chunk-VJRKDFM4.js → chunk-K7KQC7LX.js} +201 -2
- package/dist/chunk-K7KQC7LX.js.map +1 -0
- package/dist/index.cjs +200 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -4
- package/dist/index.d.ts +69 -4
- package/dist/index.js +1 -1
- package/package.json +3 -2
- package/src/components/editor/editor-theme.css +55 -80
- package/dist/chunk-VJRKDFM4.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
|
|
@@ -138,10 +169,14 @@ building in another language overrides rather than forks:
|
|
|
138
169
|
>
|
|
139
170
|
```
|
|
140
171
|
|
|
141
|
-
Overrides are shallow-merged, so anything omitted stays English.
|
|
142
|
-
exception and
|
|
143
|
-
|
|
144
|
-
|
|
172
|
+
Overrides are shallow-merged, so anything omitted stays English. The maps keyed by an id
|
|
173
|
+
are the exception and merge key by key, so translating one entry keeps the others:
|
|
174
|
+
`toolLabels` (by agent tool), `blockLabels` (by block id, e.g. `mj-2-columns`),
|
|
175
|
+
`elementNames` (by MJML tag) and `inspectorLabels` (the Settings tab's field and option
|
|
176
|
+
names, and help as `<key>.help`). `DEFAULT_LABELS` and the `EditorLabels` type are exported
|
|
177
|
+
if you want to see the full list or build a complete translation; for `inspectorLabels` the
|
|
178
|
+
keys in `DEFAULT_LABELS.inspectorLabels` are the whole set. Font and brand names (Arial,
|
|
179
|
+
Facebook) are shown as they are and have no key.
|
|
145
180
|
|
|
146
181
|
New keys arrive with new features, including in 0.1.x releases. They always have English
|
|
147
182
|
defaults, so a host passing `Partial<EditorLabels>` picks them up untouched; a host that
|