@mjml-agent-editor/editor 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/LICENSE +21 -0
- package/README.md +93 -0
- package/dist/canvas.cjs +1099 -0
- package/dist/canvas.cjs.map +1 -0
- package/dist/canvas.d.cts +49 -0
- package/dist/canvas.d.ts +49 -0
- package/dist/canvas.js +629 -0
- package/dist/canvas.js.map +1 -0
- package/dist/chunk-LSF33PSW.js +1649 -0
- package/dist/chunk-LSF33PSW.js.map +1 -0
- package/dist/chunk-V6RR4VRD.js +340 -0
- package/dist/chunk-V6RR4VRD.js.map +1 -0
- package/dist/index.cjs +1935 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +71 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/ui.cjs +384 -0
- package/dist/ui.cjs.map +1 -0
- package/dist/ui.d.cts +47 -0
- package/dist/ui.d.ts +47 -0
- package/dist/ui.js +42 -0
- package/dist/ui.js.map +1 -0
- package/package.json +92 -0
- package/src/components/editor/editor-theme.css +411 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Krzysztof Marmol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Editor package
|
|
2
|
+
|
|
3
|
+
The React MJML editor: GrapesJS canvas, agent chat panel, and comments pinned to elements
|
|
4
|
+
on the canvas.
|
|
5
|
+
|
|
6
|
+
## Entry points
|
|
7
|
+
|
|
8
|
+
| Import | Contains | Notes |
|
|
9
|
+
| -------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------ |
|
|
10
|
+
| `@mjml-agent-editor/editor` | stores, `EditorHeader`, `ChatPanel`, `CanvasComments`, types | Safe to import anywhere |
|
|
11
|
+
| `@mjml-agent-editor/editor/ui` | the shadcn primitives and `cn` | Light; no canvas |
|
|
12
|
+
| `@mjml-agent-editor/editor/canvas` | `EmailEditor` | **Browser only** — GrapesJS touches `window` at import |
|
|
13
|
+
| `@mjml-agent-editor/editor/styles.css` | editor chrome stylesheet | Import from your Tailwind entry |
|
|
14
|
+
|
|
15
|
+
The split is not cosmetic. With a single barrel, a layout file importing a tooltip provider
|
|
16
|
+
pulls `EmailEditor` — and therefore GrapesJS — into the server bundle, and the Next.js build
|
|
17
|
+
dies with `window is not defined` while prerendering an unrelated page. Load the canvas
|
|
18
|
+
through a client-only dynamic import:
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
const EmailEditor = dynamic(
|
|
22
|
+
() => import("@mjml-agent-editor/editor/canvas").then((m) => m.EmailEditor),
|
|
23
|
+
{ ssr: false },
|
|
24
|
+
);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Theming
|
|
28
|
+
|
|
29
|
+
Every colour is a CSS custom property. Restyle the editor by redefining tokens; do not fork
|
|
30
|
+
the stylesheet:
|
|
31
|
+
|
|
32
|
+
```css
|
|
33
|
+
:root {
|
|
34
|
+
--mjml-editor-panel: #14261f;
|
|
35
|
+
--mjml-editor-accent: #f59e0b;
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
That covers the GrapesJS chrome _and_ the React components around it — the header, chat
|
|
40
|
+
panel and comment pins are classed against Tailwind names (`bg-panel`, `text-brand`) that
|
|
41
|
+
`styles.css` defines as aliases of the same tokens. Verified by overriding eleven tokens in
|
|
42
|
+
a running editor: the whole surface repainted, no component touched.
|
|
43
|
+
|
|
44
|
+
The full token list, with what each one is for, is the `:root` block at the top of
|
|
45
|
+
`src/components/editor/editor-theme.css`.
|
|
46
|
+
|
|
47
|
+
The canvas iframe is the one place this cannot reach — it has its own document, so the
|
|
48
|
+
agent's edit-pulse rules are injected by script. That injection reads
|
|
49
|
+
`--mjml-editor-accent` from the host document rather than carrying its own colour.
|
|
50
|
+
|
|
51
|
+
## Stylesheet wiring
|
|
52
|
+
|
|
53
|
+
The components are Tailwind-classed, and Tailwind only emits classes it can see. Point it at
|
|
54
|
+
the package from your CSS entry, or the editor renders unstyled with nothing in the build
|
|
55
|
+
warning about it:
|
|
56
|
+
|
|
57
|
+
```css
|
|
58
|
+
@import "grapesjs/dist/css/grapes.min.css";
|
|
59
|
+
@import "@mjml-agent-editor/editor/styles.css";
|
|
60
|
+
@source "../../node_modules/@mjml-agent-editor/editor/dist";
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Routing
|
|
64
|
+
|
|
65
|
+
The package has no router dependency. `EditorHeader` takes a `homeLink` node, so a Next.js
|
|
66
|
+
host passes `<Link href="/">` and anything else passes an anchor.
|
|
67
|
+
|
|
68
|
+
## Data access
|
|
69
|
+
|
|
70
|
+
Nothing here talks to a database. The host passes a `DocumentStore` and a `CommentStore`
|
|
71
|
+
(the same shapes the agent uses, from `@mjml-agent-editor/core`) and the components read
|
|
72
|
+
them through context:
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import { EditorStoreProvider } from "@mjml-agent-editor/editor";
|
|
76
|
+
|
|
77
|
+
<EditorStoreProvider stores={{ documents, comments }}>
|
|
78
|
+
<EditorWorkspace docId={id} />
|
|
79
|
+
</EditorStoreProvider>;
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
In the spike every component imported `@/lib/documents`, which imported a Supabase client.
|
|
83
|
+
Adopting the editor meant adopting Supabase, and no component could be rendered without a
|
|
84
|
+
database behind it. `apps/example/lib/stores.ts` shows the Supabase wiring; anything
|
|
85
|
+
satisfying the two interfaces works, including an in-memory object.
|
|
86
|
+
|
|
87
|
+
Forgetting the provider throws with an explanation rather than failing on a null read.
|
|
88
|
+
|
|
89
|
+
## A note on field names
|
|
90
|
+
|
|
91
|
+
The ports are camelCase (`sectionId`, `objectId`, `projectData`); Postgres columns are
|
|
92
|
+
snake_case. The mapping belongs in the adapter — see
|
|
93
|
+
`packages/store-supabase/src/index.ts` — and never leaks into the components.
|