react-email-studio 2.0.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.
@@ -0,0 +1,407 @@
1
+ import * as react from 'react';
2
+ import { CSSProperties, ReactNode } from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ declare const THEMES: {
6
+ /** White chrome, dark type */
7
+ light: {
8
+ bg: string;
9
+ sidebar: string;
10
+ canvas: string;
11
+ surface: string;
12
+ border: string;
13
+ accent: string;
14
+ accent2: string;
15
+ text: string;
16
+ muted: string;
17
+ danger: string;
18
+ success: string;
19
+ warn: string;
20
+ inputBg: string;
21
+ toolbarBg: string;
22
+ };
23
+ /** Dark chrome, light type */
24
+ dark: {
25
+ bg: string;
26
+ sidebar: string;
27
+ canvas: string;
28
+ surface: string;
29
+ border: string;
30
+ accent: string;
31
+ accent2: string;
32
+ text: string;
33
+ muted: string;
34
+ danger: string;
35
+ success: string;
36
+ warn: string;
37
+ inputBg: string;
38
+ toolbarBg: string;
39
+ };
40
+ /** @deprecated aliases — same palette family */
41
+ modern_light: {
42
+ bg: string;
43
+ sidebar: string;
44
+ canvas: string;
45
+ surface: string;
46
+ border: string;
47
+ accent: string;
48
+ accent2: string;
49
+ text: string;
50
+ muted: string;
51
+ danger: string;
52
+ success: string;
53
+ warn: string;
54
+ inputBg: string;
55
+ toolbarBg: string;
56
+ };
57
+ modern_dark: {
58
+ bg: string;
59
+ sidebar: string;
60
+ canvas: string;
61
+ surface: string;
62
+ border: string;
63
+ accent: string;
64
+ accent2: string;
65
+ text: string;
66
+ muted: string;
67
+ danger: string;
68
+ success: string;
69
+ warn: string;
70
+ inputBg: string;
71
+ toolbarBg: string;
72
+ };
73
+ };
74
+ /** Sidebar palette groups: order = top to bottom. Each block uses `paletteGroup` + `paletteOrder` (ascending within group). */
75
+ declare const BLOCK_PALETTE_GROUPS: readonly [{
76
+ readonly key: "text";
77
+ readonly labelKey: "blockPaletteGroupText";
78
+ }, {
79
+ readonly key: "structure";
80
+ readonly labelKey: "blockPaletteGroupStructure";
81
+ }, {
82
+ readonly key: "media";
83
+ readonly labelKey: "blockPaletteGroupMedia";
84
+ }, {
85
+ readonly key: "actions";
86
+ readonly labelKey: "blockPaletteGroupActions";
87
+ }, {
88
+ readonly key: "widgets";
89
+ readonly labelKey: "blockPaletteGroupWidgets";
90
+ }];
91
+ type BlockPaletteGroupKey = (typeof BLOCK_PALETTE_GROUPS)[number]["key"];
92
+
93
+ /** Options passed to {@link designToHtml} and {@link jsonToHtml} (from `emailDesignJson`). */
94
+ type EmailHtmlOptions = {
95
+ /** Injected as a `<style>` block in the document `<head>`. */
96
+ customCSS?: string;
97
+ };
98
+
99
+ /** Theme color tokens (subset used by the editor chrome). */
100
+ type ThemeColors = (typeof THEMES)["light"];
101
+ /** Known `options` keys for {@link ReactEmailEditor} — callers may pass extra keys; these are what the editor reads. */
102
+ type ReactEmailEditorOptions = EmailHtmlOptions & {
103
+ appearance?: {
104
+ theme?: string;
105
+ /** Shallow merge over the active theme (e.g. accent border). */
106
+ colors?: Partial<ThemeColors>;
107
+ /** Extra named palettes; keys appear in Settings → Color scheme. */
108
+ customThemes?: Record<string, ThemeColors>;
109
+ };
110
+ locale?: string;
111
+ mergeTags?: {
112
+ name: string;
113
+ value: string;
114
+ }[];
115
+ features?: {
116
+ autoSave?: {
117
+ enabled?: boolean;
118
+ interval?: number;
119
+ };
120
+ };
121
+ tools?: Record<string, {
122
+ enabled?: boolean;
123
+ }>;
124
+ /** Optional labels for block-library sections (row layouts + content blocks). */
125
+ blockLibrary?: {
126
+ groupHeadings?: {
127
+ blocks?: string;
128
+ };
129
+ /** Override default palette group titles (keys: text, structure, media, actions, widgets). */
130
+ paletteGroupLabels?: Partial<Record<BlockPaletteGroupKey, string>>;
131
+ };
132
+ };
133
+ interface ReactEmailEditorRef {
134
+ loadJson(input: string | Record<string, unknown>): void;
135
+ /** Calls `cb` with the design as a JSON string (new `email_document` schema). */
136
+ exportJson(cb: (json: string) => void, pretty?: boolean): void;
137
+ }
138
+ type ReactEmailEditorProps = {
139
+ minHeight?: string;
140
+ editorId?: string;
141
+ options?: ReactEmailEditorOptions;
142
+ style?: CSSProperties;
143
+ onLoad?: (api: ReactEmailEditorRef) => void;
144
+ onReady?: (api: ReactEmailEditorRef) => void;
145
+ onUpload?: (file: File) => Promise<string>;
146
+ templates?: {
147
+ name: string;
148
+ design: unknown;
149
+ thumbnail?: string;
150
+ }[];
151
+ hideTemplates?: boolean;
152
+ children?: ReactNode;
153
+ };
154
+ declare const ReactEmailEditor: react.ForwardRefExoticComponent<ReactEmailEditorProps & react.RefAttributes<ReactEmailEditorRef>>;
155
+
156
+ type Padding = {
157
+ top?: number;
158
+ right?: number;
159
+ bottom?: number;
160
+ left?: number;
161
+ };
162
+ type EmailDocumentSettings = {
163
+ width?: number;
164
+ backgroundColor?: string;
165
+ backgroundImage?: string;
166
+ backgroundRepeat?: string;
167
+ backgroundSize?: string;
168
+ backgroundPosition?: string;
169
+ /** 3-stop linear gradient (editor-specific extension). */
170
+ backgroundGradient?: {
171
+ angle?: number;
172
+ colors?: [string, string, string];
173
+ stops?: [number, number, number];
174
+ };
175
+ contentBackgroundColor?: string;
176
+ contentBackgroundImage?: string;
177
+ contentBackgroundRepeat?: string;
178
+ contentBackgroundSize?: string;
179
+ contentBackgroundPosition?: string;
180
+ /** 3-stop linear gradient (editor-specific extension). */
181
+ contentBackgroundGradient?: {
182
+ angle?: number;
183
+ colors?: [string, string, string];
184
+ stops?: [number, number, number];
185
+ };
186
+ fontFamily?: string;
187
+ lineHeightBase?: number;
188
+ color?: string;
189
+ responsive?: boolean;
190
+ rtl?: boolean;
191
+ };
192
+ type RowLayout = {
193
+ columns?: number;
194
+ gap?: number;
195
+ stackOnMobile?: boolean;
196
+ align?: "left" | "center" | "right";
197
+ };
198
+ type RowStyles = {
199
+ backgroundColor?: string;
200
+ backgroundImage?: string;
201
+ backgroundRepeat?: string;
202
+ backgroundSize?: string;
203
+ backgroundPosition?: string;
204
+ /** 3-stop linear gradient (editor-specific extension). */
205
+ backgroundGradient?: {
206
+ angle?: number;
207
+ colors?: [string, string, string];
208
+ stops?: [number, number, number];
209
+ };
210
+ padding?: Padding;
211
+ borderRadius?: number;
212
+ borderWidth?: number;
213
+ borderColor?: string;
214
+ textAlign?: "left" | "center" | "right" | "justify";
215
+ };
216
+ type ColumnLayout = {
217
+ width?: string;
218
+ verticalAlign?: "top" | "middle" | "bottom";
219
+ mobileWidth?: string;
220
+ };
221
+ type ColumnBorderRadius = number | {
222
+ tl?: number;
223
+ tr?: number;
224
+ br?: number;
225
+ bl?: number;
226
+ };
227
+ type ColumnStyles = {
228
+ padding?: Padding;
229
+ backgroundColor?: string;
230
+ backgroundImage?: string;
231
+ backgroundRepeat?: string;
232
+ backgroundSize?: string;
233
+ backgroundPosition?: string;
234
+ /** 3-stop linear gradient (editor-specific extension). */
235
+ backgroundGradient?: {
236
+ angle?: number;
237
+ colors?: [string, string, string];
238
+ stops?: [number, number, number];
239
+ };
240
+ /** Uniform px or per-corner (matches block border radius in the editor). */
241
+ borderRadius?: ColumnBorderRadius;
242
+ };
243
+ type BlockBase = {
244
+ id?: string;
245
+ type: string;
246
+ content?: Record<string, unknown>;
247
+ styles?: Record<string, unknown>;
248
+ behavior?: Record<string, unknown>;
249
+ responsive?: Record<string, unknown>;
250
+ };
251
+ type EmailDocumentColumn = {
252
+ id?: string;
253
+ layout?: ColumnLayout;
254
+ styles?: ColumnStyles;
255
+ blocks?: BlockBase[];
256
+ };
257
+ type EmailDocumentRow = {
258
+ id?: string;
259
+ type?: "row";
260
+ layout?: RowLayout;
261
+ styles?: RowStyles;
262
+ columns?: EmailDocumentColumn[];
263
+ };
264
+ type EmailDocument = {
265
+ type: "email_document";
266
+ settings?: EmailDocumentSettings;
267
+ rows?: EmailDocumentRow[];
268
+ globalStyles?: Record<string, unknown>;
269
+ responsive?: Record<string, unknown>;
270
+ };
271
+
272
+ /** Re-export for consumers typing `jsonToHtml` options. */
273
+ type JsonToHtmlOptions = EmailHtmlOptions;
274
+ /**
275
+ * Design object or JSON string → full HTML email document (preview / send).
276
+ * Strings are parsed with `JSON.parse` then normalized; invalid JSON returns `""`.
277
+ */
278
+ declare function jsonToHtml(designInput: unknown, opts?: JsonToHtmlOptions): string;
279
+
280
+ declare function utf8ToBase64(raw: string): string;
281
+ declare function base64ToUtf8(b64: string): string;
282
+
283
+ type MobilePreviewVariant = "iphone" | "android";
284
+ type EmailPreviewModalProps = {
285
+ html: string;
286
+ contentWidth?: number;
287
+ rowCount?: number;
288
+ blockCount?: number;
289
+ editorZoom?: number;
290
+ locale?: string;
291
+ initialDevice?: string;
292
+ /** Phone shell in mobile / split view: iPhone vs Android frame + viewport width. */
293
+ initialMobileVariant?: MobilePreviewVariant;
294
+ onClose: () => void;
295
+ C: Record<string, string>;
296
+ /** Shown as the header line (e.g. email subject). */
297
+ title?: string;
298
+ secondaryActionLabel?: string;
299
+ onSecondaryAction?: () => void;
300
+ };
301
+ declare const DEVICES: ({
302
+ key: string;
303
+ label: string;
304
+ maxW: number;
305
+ screenW: null;
306
+ screenH: null;
307
+ frame: null;
308
+ chrome?: undefined;
309
+ } | {
310
+ key: string;
311
+ label: string;
312
+ maxW: number;
313
+ screenW: number;
314
+ screenH: number;
315
+ chrome: {
316
+ body: {
317
+ width: number;
318
+ borderRadius: number;
319
+ background: string;
320
+ padding: string;
321
+ boxShadow: string;
322
+ };
323
+ topBar: {
324
+ height: number;
325
+ display: string;
326
+ alignItems: string;
327
+ justifyContent: string;
328
+ marginBottom: number;
329
+ paddingTop?: undefined;
330
+ };
331
+ topBarInner: {
332
+ width: number;
333
+ height: number;
334
+ borderRadius: number;
335
+ background: string;
336
+ };
337
+ bottomBar: {
338
+ height: number;
339
+ display: string;
340
+ alignItems: string;
341
+ justifyContent: string;
342
+ marginTop: number;
343
+ };
344
+ homeIndicator: {
345
+ width: number;
346
+ height: number;
347
+ borderRadius: number;
348
+ background: string;
349
+ };
350
+ screen: {
351
+ borderRadius: number;
352
+ overflow: string;
353
+ border: string;
354
+ };
355
+ notch?: undefined;
356
+ sideButtons?: undefined;
357
+ };
358
+ frame?: undefined;
359
+ } | {
360
+ key: string;
361
+ label: string;
362
+ maxW: number;
363
+ screenW: number;
364
+ screenH: number;
365
+ chrome: {
366
+ body: {
367
+ width: number;
368
+ borderRadius: number;
369
+ background: string;
370
+ padding: string;
371
+ boxShadow: string;
372
+ };
373
+ notch: boolean;
374
+ sideButtons: boolean;
375
+ topBar: {
376
+ height: number;
377
+ display: string;
378
+ alignItems: string;
379
+ justifyContent: string;
380
+ paddingTop: number;
381
+ marginBottom: number;
382
+ };
383
+ topBarInner: null;
384
+ bottomBar: {
385
+ height: number;
386
+ display: string;
387
+ alignItems: string;
388
+ justifyContent: string;
389
+ marginTop: number;
390
+ };
391
+ homeIndicator: {
392
+ width: number;
393
+ height: number;
394
+ borderRadius: number;
395
+ background: string;
396
+ };
397
+ screen: {
398
+ borderRadius: number;
399
+ overflow: string;
400
+ border: string;
401
+ };
402
+ };
403
+ frame?: undefined;
404
+ })[];
405
+ declare function PreviewModal({ html, contentWidth, rowCount, blockCount, editorZoom, locale, initialDevice, initialMobileVariant, onClose, C, title, secondaryActionLabel, onSecondaryAction, }: EmailPreviewModalProps): react_jsx_runtime.JSX.Element;
406
+
407
+ export { type BlockBase, type EmailDocument, type EmailDocumentColumn, type EmailDocumentRow, type EmailDocumentSettings, type EmailHtmlOptions, PreviewModal as EmailPreviewModal, type EmailPreviewModalProps, type JsonToHtmlOptions, type MobilePreviewVariant, ReactEmailEditor, type ReactEmailEditorOptions, type ReactEmailEditorProps, type ReactEmailEditorRef, base64ToUtf8, DEVICES as emailPreviewDevices, jsonToHtml, utf8ToBase64 };