@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/dist/canvas.d.cts
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Editor } from 'grapesjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Sections a host adds to the palette.
|
|
6
|
+
*
|
|
7
|
+
* A dropped block is ordinary MJML from then on, so it has to be MJML the agent's strict
|
|
8
|
+
* compile accepts and the editor writes back unchanged: one bad block in the palette would
|
|
9
|
+
* put an error into every email it is dropped in, and block every agent write to it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
type SectionBlock = {
|
|
13
|
+
/** Unique, and not the id of a built-in block. */
|
|
14
|
+
readonly id: string;
|
|
15
|
+
/** Plain text. */
|
|
16
|
+
readonly label: string;
|
|
17
|
+
/** Exactly one `<mj-section>`, without `sec-*`/`obj-*` ids: those are added on drop. */
|
|
18
|
+
readonly mjml: string;
|
|
19
|
+
/** SVG markup for the tile, rendered as is. The palette paints it with `fill`, as it does
|
|
20
|
+
* the built-in tiles, so draw with filled shapes. */
|
|
21
|
+
readonly media?: string;
|
|
22
|
+
};
|
|
23
|
+
/** Why a block cannot be offered; empty when it can. */
|
|
24
|
+
declare function blockProblems(mjml: string, editor?: Editor): string[];
|
|
2
25
|
|
|
3
26
|
type SaveStatus = "idle" | "saving" | "saved" | "error";
|
|
4
27
|
/** Snapshot of editor state pushed to the header (device, undo, save, zoom, width). */
|
|
@@ -45,7 +68,12 @@ type Props = {
|
|
|
45
68
|
commentsRefresh: number;
|
|
46
69
|
/** Reports the number of open comments (for the header indicator). */
|
|
47
70
|
onOpenCountChange: (n: number) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Sections offered after the built-in blocks, read once when the editor starts. One that
|
|
73
|
+
* `blockProblems` refuses is left out and reported in the console.
|
|
74
|
+
*/
|
|
75
|
+
blocks?: readonly SectionBlock[];
|
|
48
76
|
};
|
|
49
|
-
declare function EmailEditor({ docId, onReady, commentsRefresh, onOpenCountChange }: Props): React.JSX.Element;
|
|
77
|
+
declare function EmailEditor({ docId, onReady, commentsRefresh, onOpenCountChange, blocks, }: Props): React.JSX.Element;
|
|
50
78
|
|
|
51
|
-
export { type EditorApi, type EditorState, EmailEditor, type SaveStatus };
|
|
79
|
+
export { type EditorApi, type EditorState, EmailEditor, type SaveStatus, type SectionBlock, blockProblems };
|
package/dist/canvas.d.ts
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Editor } from 'grapesjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Sections a host adds to the palette.
|
|
6
|
+
*
|
|
7
|
+
* A dropped block is ordinary MJML from then on, so it has to be MJML the agent's strict
|
|
8
|
+
* compile accepts and the editor writes back unchanged: one bad block in the palette would
|
|
9
|
+
* put an error into every email it is dropped in, and block every agent write to it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
type SectionBlock = {
|
|
13
|
+
/** Unique, and not the id of a built-in block. */
|
|
14
|
+
readonly id: string;
|
|
15
|
+
/** Plain text. */
|
|
16
|
+
readonly label: string;
|
|
17
|
+
/** Exactly one `<mj-section>`, without `sec-*`/`obj-*` ids: those are added on drop. */
|
|
18
|
+
readonly mjml: string;
|
|
19
|
+
/** SVG markup for the tile, rendered as is. The palette paints it with `fill`, as it does
|
|
20
|
+
* the built-in tiles, so draw with filled shapes. */
|
|
21
|
+
readonly media?: string;
|
|
22
|
+
};
|
|
23
|
+
/** Why a block cannot be offered; empty when it can. */
|
|
24
|
+
declare function blockProblems(mjml: string, editor?: Editor): string[];
|
|
2
25
|
|
|
3
26
|
type SaveStatus = "idle" | "saving" | "saved" | "error";
|
|
4
27
|
/** Snapshot of editor state pushed to the header (device, undo, save, zoom, width). */
|
|
@@ -45,7 +68,12 @@ type Props = {
|
|
|
45
68
|
commentsRefresh: number;
|
|
46
69
|
/** Reports the number of open comments (for the header indicator). */
|
|
47
70
|
onOpenCountChange: (n: number) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Sections offered after the built-in blocks, read once when the editor starts. One that
|
|
73
|
+
* `blockProblems` refuses is left out and reported in the console.
|
|
74
|
+
*/
|
|
75
|
+
blocks?: readonly SectionBlock[];
|
|
48
76
|
};
|
|
49
|
-
declare function EmailEditor({ docId, onReady, commentsRefresh, onOpenCountChange }: Props): React.JSX.Element;
|
|
77
|
+
declare function EmailEditor({ docId, onReady, commentsRefresh, onOpenCountChange, blocks, }: Props): React.JSX.Element;
|
|
50
78
|
|
|
51
|
-
export { type EditorApi, type EditorState, EmailEditor, type SaveStatus };
|
|
79
|
+
export { type EditorApi, type EditorState, EmailEditor, type SaveStatus, type SectionBlock, blockProblems };
|