@savvycal/mjml-editor 0.0.1
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/dist/index.d.ts +150 -0
- package/dist/index.js +57454 -0
- package/dist/styles.css +1 -0
- package/package.json +79 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { JSX } from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
export declare type ContentBlockType = 'mj-text' | 'mj-image' | 'mj-button' | 'mj-divider' | 'mj-spacer';
|
|
5
|
+
|
|
6
|
+
export declare type EditorAction = {
|
|
7
|
+
type: 'SELECT_BLOCK';
|
|
8
|
+
payload: string | null;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'UPDATE_ATTRIBUTES';
|
|
11
|
+
payload: {
|
|
12
|
+
id: string;
|
|
13
|
+
attributes: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
} | {
|
|
16
|
+
type: 'UPDATE_CONTENT';
|
|
17
|
+
payload: {
|
|
18
|
+
id: string;
|
|
19
|
+
content: string;
|
|
20
|
+
};
|
|
21
|
+
} | {
|
|
22
|
+
type: 'ADD_BLOCK';
|
|
23
|
+
payload: {
|
|
24
|
+
parentId: string;
|
|
25
|
+
index: number;
|
|
26
|
+
block: MjmlNode;
|
|
27
|
+
};
|
|
28
|
+
} | {
|
|
29
|
+
type: 'DELETE_BLOCK';
|
|
30
|
+
payload: string;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'MOVE_BLOCK';
|
|
33
|
+
payload: {
|
|
34
|
+
id: string;
|
|
35
|
+
newParentId: string;
|
|
36
|
+
newIndex: number;
|
|
37
|
+
};
|
|
38
|
+
} | {
|
|
39
|
+
type: 'SET_DOCUMENT';
|
|
40
|
+
payload: MjmlNode;
|
|
41
|
+
} | {
|
|
42
|
+
type: 'UNDO';
|
|
43
|
+
} | {
|
|
44
|
+
type: 'REDO';
|
|
45
|
+
} | {
|
|
46
|
+
type: 'UPDATE_MJML_ATTRIBUTE';
|
|
47
|
+
payload: {
|
|
48
|
+
attributeType: 'all' | 'element' | 'class';
|
|
49
|
+
target: string | null;
|
|
50
|
+
attributes: Record<string, string>;
|
|
51
|
+
};
|
|
52
|
+
} | {
|
|
53
|
+
type: 'ADD_CLASS';
|
|
54
|
+
payload: string;
|
|
55
|
+
} | {
|
|
56
|
+
type: 'REMOVE_CLASS';
|
|
57
|
+
payload: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: 'RENAME_CLASS';
|
|
60
|
+
payload: {
|
|
61
|
+
oldName: string;
|
|
62
|
+
newName: string;
|
|
63
|
+
};
|
|
64
|
+
} | {
|
|
65
|
+
type: 'ADD_FONT';
|
|
66
|
+
payload: MjmlFont;
|
|
67
|
+
} | {
|
|
68
|
+
type: 'REMOVE_FONT';
|
|
69
|
+
payload: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'UPDATE_FONT';
|
|
72
|
+
payload: MjmlFont;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export declare interface EditorState {
|
|
76
|
+
document: MjmlNode;
|
|
77
|
+
selectedBlockId: string | null;
|
|
78
|
+
history: MjmlNode[];
|
|
79
|
+
historyIndex: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Complete Liquid schema passed to MjmlEditor
|
|
84
|
+
*/
|
|
85
|
+
export declare interface LiquidSchema {
|
|
86
|
+
/** Variables accessible via {{ variable_name }} syntax */
|
|
87
|
+
variables: LiquidSchemaItem[];
|
|
88
|
+
/** Tags accessible via {% tag_name %} syntax */
|
|
89
|
+
tags: LiquidSchemaItem[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Schema item for Liquid variables and tags
|
|
94
|
+
*/
|
|
95
|
+
export declare interface LiquidSchemaItem {
|
|
96
|
+
/** The name/path of the variable or tag (e.g., "user.name" or "if") */
|
|
97
|
+
name: string;
|
|
98
|
+
/** Optional description shown in the autocomplete popup */
|
|
99
|
+
description?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export declare function MjmlEditor({ value, onChange, className, defaultTheme, liquidSchema, }: MjmlEditorProps): JSX.Element;
|
|
103
|
+
|
|
104
|
+
declare interface MjmlEditorProps {
|
|
105
|
+
value: string;
|
|
106
|
+
onChange: (mjml: string) => void;
|
|
107
|
+
className?: string;
|
|
108
|
+
defaultTheme?: 'light' | 'dark' | 'system';
|
|
109
|
+
liquidSchema?: LiquidSchema;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare interface MjmlFont {
|
|
113
|
+
name: string;
|
|
114
|
+
href: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export declare interface MjmlNode {
|
|
118
|
+
tagName: string;
|
|
119
|
+
attributes: Record<string, string>;
|
|
120
|
+
children?: MjmlNode[];
|
|
121
|
+
content?: string;
|
|
122
|
+
_id?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export declare type MjmlTagName = 'mjml' | 'mj-head' | 'mj-body' | 'mj-wrapper' | 'mj-section' | 'mj-column' | 'mj-text' | 'mj-image' | 'mj-button' | 'mj-divider' | 'mj-spacer' | 'mj-title' | 'mj-preview' | 'mj-attributes' | 'mj-all' | 'mj-class' | 'mj-style' | 'mj-font';
|
|
126
|
+
|
|
127
|
+
declare type ResolvedTheme = 'light' | 'dark';
|
|
128
|
+
|
|
129
|
+
declare type Theme = 'light' | 'dark' | 'system';
|
|
130
|
+
|
|
131
|
+
declare interface ThemeContextValue {
|
|
132
|
+
theme: Theme;
|
|
133
|
+
resolvedTheme: ResolvedTheme;
|
|
134
|
+
setTheme: (theme: Theme) => void;
|
|
135
|
+
toggleTheme: () => void;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export declare function ThemeProvider({ children, defaultTheme, storageKey, }: ThemeProviderProps): JSX.Element;
|
|
139
|
+
|
|
140
|
+
declare interface ThemeProviderProps {
|
|
141
|
+
children: ReactNode;
|
|
142
|
+
defaultTheme?: Theme;
|
|
143
|
+
storageKey?: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export declare function ThemeToggle(): JSX.Element;
|
|
147
|
+
|
|
148
|
+
export declare function useTheme(): ThemeContextValue;
|
|
149
|
+
|
|
150
|
+
export { }
|