react-email-studio 3.4.0 → 3.8.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/CHANGELOG.md +70 -2
- package/README.md +12 -0
- package/TUTORIAL.md +56 -2
- package/USER_README.md +17 -0
- package/dist/index.cjs +1560 -491
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +84 -33
- package/dist/index.d.ts +84 -33
- package/dist/index.js +1566 -494
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -131,11 +131,14 @@ type EmailDocumentSettings = {
|
|
|
131
131
|
color?: string;
|
|
132
132
|
responsive?: boolean;
|
|
133
133
|
rtl?: boolean;
|
|
134
|
-
/**
|
|
134
|
+
/** Content card inner padding (editor `settings.padding`). */
|
|
135
|
+
contentPadding?: number;
|
|
136
|
+
/** Content card corner radius (editor `settings.borderRadius`). */
|
|
137
|
+
contentBorderRadius?: number;
|
|
138
|
+
/** Studio snapshot for round-trip with the visual editor (settings + editor chrome). */
|
|
135
139
|
_reactEmailStudio?: {
|
|
136
140
|
contentPadding?: number;
|
|
137
141
|
contentBorderRadius?: number;
|
|
138
|
-
/** Full `ReactEmailEditor` settings object (merged on load after canonical fields). */
|
|
139
142
|
editorSettings?: Record<string, unknown>;
|
|
140
143
|
};
|
|
141
144
|
};
|
|
@@ -144,19 +147,37 @@ type RowLayout = {
|
|
|
144
147
|
gap?: number;
|
|
145
148
|
stackOnMobile?: boolean;
|
|
146
149
|
align?: "left" | "center" | "right";
|
|
150
|
+
/** Editor layout preset key (e.g. `layout2`, `custom`) — optional on `email_document` rows. */
|
|
151
|
+
preset?: string;
|
|
152
|
+
/** Column width ratios; length should match `columns`. */
|
|
153
|
+
ratios?: number[];
|
|
147
154
|
};
|
|
155
|
+
/** Row shell on `email_document` (editor field names). */
|
|
156
|
+
type RowProps = {
|
|
157
|
+
bgColor?: string;
|
|
158
|
+
bgImage?: string;
|
|
159
|
+
bgRepeat?: string;
|
|
160
|
+
bgSize?: string;
|
|
161
|
+
bgPosition?: string;
|
|
162
|
+
bgGradient?: {
|
|
163
|
+
angle?: number;
|
|
164
|
+
colors?: [string, string, string];
|
|
165
|
+
stops?: [number, number, number];
|
|
166
|
+
} | null;
|
|
167
|
+
padding?: Padding;
|
|
168
|
+
borderRadius?: number;
|
|
169
|
+
borderWidth?: number;
|
|
170
|
+
borderColor?: string;
|
|
171
|
+
textAlign?: "left" | "center" | "right" | "justify";
|
|
172
|
+
};
|
|
173
|
+
/** Legacy row shell (`backgroundColor`, …) — import only. */
|
|
148
174
|
type RowStyles = {
|
|
149
175
|
backgroundColor?: string;
|
|
150
176
|
backgroundImage?: string;
|
|
151
177
|
backgroundRepeat?: string;
|
|
152
178
|
backgroundSize?: string;
|
|
153
179
|
backgroundPosition?: string;
|
|
154
|
-
|
|
155
|
-
backgroundGradient?: {
|
|
156
|
-
angle?: number;
|
|
157
|
-
colors?: [string, string, string];
|
|
158
|
-
stops?: [number, number, number];
|
|
159
|
-
};
|
|
180
|
+
backgroundGradient?: RowProps["bgGradient"];
|
|
160
181
|
padding?: Padding;
|
|
161
182
|
borderRadius?: number;
|
|
162
183
|
borderWidth?: number;
|
|
@@ -174,6 +195,18 @@ type ColumnBorderRadius = number | {
|
|
|
174
195
|
br?: number;
|
|
175
196
|
bl?: number;
|
|
176
197
|
};
|
|
198
|
+
/** Column shell on `email_document` (editor field names). */
|
|
199
|
+
type ColumnProps = {
|
|
200
|
+
padding?: Padding;
|
|
201
|
+
bgColor?: string;
|
|
202
|
+
bgImage?: string;
|
|
203
|
+
bgRepeat?: string;
|
|
204
|
+
bgSize?: string;
|
|
205
|
+
bgPosition?: string;
|
|
206
|
+
bgGradient?: RowProps["bgGradient"];
|
|
207
|
+
borderRadius?: ColumnBorderRadius;
|
|
208
|
+
};
|
|
209
|
+
/** Legacy column shell — import only. */
|
|
177
210
|
type ColumnStyles = {
|
|
178
211
|
padding?: Padding;
|
|
179
212
|
backgroundColor?: string;
|
|
@@ -181,28 +214,27 @@ type ColumnStyles = {
|
|
|
181
214
|
backgroundRepeat?: string;
|
|
182
215
|
backgroundSize?: string;
|
|
183
216
|
backgroundPosition?: string;
|
|
184
|
-
|
|
185
|
-
backgroundGradient?: {
|
|
186
|
-
angle?: number;
|
|
187
|
-
colors?: [string, string, string];
|
|
188
|
-
stops?: [number, number, number];
|
|
189
|
-
};
|
|
190
|
-
/** Uniform px or per-corner (matches block border radius in the editor). */
|
|
217
|
+
backgroundGradient?: RowProps["bgGradient"];
|
|
191
218
|
borderRadius?: ColumnBorderRadius;
|
|
192
219
|
};
|
|
193
220
|
type BlockBase = {
|
|
194
221
|
id?: string;
|
|
195
222
|
type: string;
|
|
196
|
-
|
|
223
|
+
/** Payload: object for most blocks; plain HTML string for `type: "html"`. */
|
|
224
|
+
content?: Record<string, unknown> | string;
|
|
225
|
+
/** Full editor block props (export + preferred import). */
|
|
226
|
+
props?: Record<string, unknown>;
|
|
227
|
+
/** Legacy block styling — import only when `props` is absent. */
|
|
197
228
|
styles?: Record<string, unknown>;
|
|
198
229
|
behavior?: Record<string, unknown>;
|
|
199
230
|
responsive?: Record<string, unknown>;
|
|
200
|
-
/** Full editor block props for lossless export/import (react-email-studio). */
|
|
201
|
-
props?: Record<string, unknown>;
|
|
202
231
|
};
|
|
203
232
|
type EmailDocumentColumn = {
|
|
204
233
|
id?: string;
|
|
205
234
|
layout?: ColumnLayout;
|
|
235
|
+
/** Column surface (padding, backgrounds, radius). */
|
|
236
|
+
props?: ColumnProps;
|
|
237
|
+
/** Legacy column shell — import only. */
|
|
206
238
|
styles?: ColumnStyles;
|
|
207
239
|
blocks?: BlockBase[];
|
|
208
240
|
};
|
|
@@ -210,9 +242,12 @@ type EmailDocumentRow = {
|
|
|
210
242
|
id?: string;
|
|
211
243
|
type?: "row";
|
|
212
244
|
layout?: RowLayout;
|
|
245
|
+
/** Row shell (padding, backgrounds). */
|
|
246
|
+
props?: RowProps;
|
|
247
|
+
/** Legacy row shell — import only. */
|
|
213
248
|
styles?: RowStyles;
|
|
214
249
|
columns?: EmailDocumentColumn[];
|
|
215
|
-
/**
|
|
250
|
+
/** Editor row snapshot (`preset`, `ratios`, column props, …) for round-trip. */
|
|
216
251
|
_reactEmailStudio?: {
|
|
217
252
|
row?: Record<string, unknown>;
|
|
218
253
|
};
|
|
@@ -220,11 +255,18 @@ type EmailDocumentRow = {
|
|
|
220
255
|
type EmailDocument = {
|
|
221
256
|
type: "email_document";
|
|
222
257
|
settings?: EmailDocumentSettings;
|
|
258
|
+
/** Flat root blocks (optional interchange; `rows` is the primary LMS/export shape). */
|
|
259
|
+
blocks?: BlockBase[];
|
|
260
|
+
/** Layout rows with `columns[].blocks[]` (primary import/export shape). */
|
|
223
261
|
rows?: EmailDocumentRow[];
|
|
224
262
|
globalStyles?: Record<string, unknown>;
|
|
225
263
|
responsive?: Record<string, unknown>;
|
|
226
264
|
};
|
|
227
265
|
|
|
266
|
+
/** Coerce fragment / array input into `email_document` before normalize. */
|
|
267
|
+
declare function coerceEmailDocumentInput(input: unknown): unknown;
|
|
268
|
+
/** Normalize input and return `email_document` in LMS/export shape (`rows[]` + `_reactEmailStudio`). */
|
|
269
|
+
declare function canonicalizeEmailDocument(input: unknown): EmailDocument | null;
|
|
228
270
|
/** Re-export for consumers typing `jsonToHtml` options. */
|
|
229
271
|
type JsonToHtmlOptions = EmailHtmlOptions;
|
|
230
272
|
/**
|
|
@@ -233,6 +275,23 @@ type JsonToHtmlOptions = EmailHtmlOptions;
|
|
|
233
275
|
*/
|
|
234
276
|
declare function jsonToHtml(designInput: unknown, opts?: JsonToHtmlOptions): string;
|
|
235
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Pull usable HTML from a full document (`<!DOCTYPE` / `<html>`) or a fragment string.
|
|
280
|
+
*/
|
|
281
|
+
declare function extractHtmlForDesign(html: string): string;
|
|
282
|
+
/**
|
|
283
|
+
* Wrap HTML (fragment or full email/page document) in a minimal `email_document`
|
|
284
|
+
* with one row, one column, and a single **html** block — suitable for `loadJson`.
|
|
285
|
+
*
|
|
286
|
+
* @returns `null` when there is no non-empty HTML after extraction/normalization.
|
|
287
|
+
*/
|
|
288
|
+
declare function htmlToEmailDesignTemplate(html: string): EmailDocument | null;
|
|
289
|
+
/**
|
|
290
|
+
* HTML fragment or full document → `email_document` JSON string (for `loadJson` / storage).
|
|
291
|
+
* Returns `""` when there is no non-empty HTML after extraction.
|
|
292
|
+
*/
|
|
293
|
+
declare function htmlToJson(html: string, pretty?: boolean): string;
|
|
294
|
+
|
|
236
295
|
/** Theme color tokens (subset used by the editor chrome). */
|
|
237
296
|
type ThemeColors = (typeof THEMES)["light"];
|
|
238
297
|
/** Known `options` keys for {@link ReactEmailEditor} — callers may pass extra keys; these are what the editor reads. */
|
|
@@ -263,8 +322,11 @@ type ReactEmailEditorOptions = EmailHtmlOptions & {
|
|
|
263
322
|
paletteGroupLabels?: Partial<Record<BlockPaletteGroupKey, string>>;
|
|
264
323
|
};
|
|
265
324
|
};
|
|
325
|
+
type LoadJsonOptions = {
|
|
326
|
+
mode?: "replace" | "append";
|
|
327
|
+
};
|
|
266
328
|
interface ReactEmailEditorRef {
|
|
267
|
-
loadJson(input: string | Record<string, unknown
|
|
329
|
+
loadJson(input: string | Record<string, unknown>, options?: LoadJsonOptions): void;
|
|
268
330
|
/** Calls `cb` with the design as a JSON string (new `email_document` schema). */
|
|
269
331
|
exportJson(cb: (json: string) => void, pretty?: boolean): void;
|
|
270
332
|
}
|
|
@@ -286,20 +348,9 @@ type ReactEmailEditorProps = {
|
|
|
286
348
|
};
|
|
287
349
|
declare const ReactEmailEditor: react.ForwardRefExoticComponent<ReactEmailEditorProps & react.RefAttributes<ReactEmailEditorRef>> & {
|
|
288
350
|
jsonToHtml: typeof jsonToHtml;
|
|
351
|
+
htmlToJson: typeof htmlToJson;
|
|
289
352
|
};
|
|
290
353
|
|
|
291
|
-
/**
|
|
292
|
-
* Pull usable HTML from a full document (`<!DOCTYPE` / `<html>`) or a fragment string.
|
|
293
|
-
*/
|
|
294
|
-
declare function extractHtmlForDesign(html: string): string;
|
|
295
|
-
/**
|
|
296
|
-
* Wrap HTML (fragment or full email/page document) in a minimal `email_document`
|
|
297
|
-
* with one row, one column, and a single **html** block — suitable for `loadJson`.
|
|
298
|
-
*
|
|
299
|
-
* @returns `null` when there is no non-empty HTML after extraction/normalization.
|
|
300
|
-
*/
|
|
301
|
-
declare function htmlToEmailDesignTemplate(html: string): EmailDocument | null;
|
|
302
|
-
|
|
303
354
|
declare function utf8ToBase64(raw: string): string;
|
|
304
355
|
declare function base64ToUtf8(b64: string): string;
|
|
305
356
|
|
|
@@ -427,4 +478,4 @@ declare const DEVICES: ({
|
|
|
427
478
|
})[];
|
|
428
479
|
declare function PreviewModal({ html, contentWidth, rowCount, blockCount, editorZoom, locale, initialDevice, initialMobileVariant, onClose, C, title, secondaryActionLabel, onSecondaryAction, }: EmailPreviewModalProps): react_jsx_runtime.JSX.Element;
|
|
429
480
|
|
|
430
|
-
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, extractHtmlForDesign, htmlToEmailDesignTemplate, jsonToHtml, utf8ToBase64 };
|
|
481
|
+
export { type BlockBase, type ColumnProps, type ColumnStyles, type EmailDocument, type EmailDocumentColumn, type EmailDocumentRow, type EmailDocumentSettings, type EmailHtmlOptions, PreviewModal as EmailPreviewModal, type EmailPreviewModalProps, type JsonToHtmlOptions, type LoadJsonOptions, type MobilePreviewVariant, ReactEmailEditor, type ReactEmailEditorOptions, type ReactEmailEditorProps, type ReactEmailEditorRef, type RowProps, type RowStyles, base64ToUtf8, canonicalizeEmailDocument, coerceEmailDocumentInput, DEVICES as emailPreviewDevices, extractHtmlForDesign, htmlToEmailDesignTemplate, htmlToJson, jsonToHtml, utf8ToBase64 };
|
package/dist/index.d.ts
CHANGED
|
@@ -131,11 +131,14 @@ type EmailDocumentSettings = {
|
|
|
131
131
|
color?: string;
|
|
132
132
|
responsive?: boolean;
|
|
133
133
|
rtl?: boolean;
|
|
134
|
-
/**
|
|
134
|
+
/** Content card inner padding (editor `settings.padding`). */
|
|
135
|
+
contentPadding?: number;
|
|
136
|
+
/** Content card corner radius (editor `settings.borderRadius`). */
|
|
137
|
+
contentBorderRadius?: number;
|
|
138
|
+
/** Studio snapshot for round-trip with the visual editor (settings + editor chrome). */
|
|
135
139
|
_reactEmailStudio?: {
|
|
136
140
|
contentPadding?: number;
|
|
137
141
|
contentBorderRadius?: number;
|
|
138
|
-
/** Full `ReactEmailEditor` settings object (merged on load after canonical fields). */
|
|
139
142
|
editorSettings?: Record<string, unknown>;
|
|
140
143
|
};
|
|
141
144
|
};
|
|
@@ -144,19 +147,37 @@ type RowLayout = {
|
|
|
144
147
|
gap?: number;
|
|
145
148
|
stackOnMobile?: boolean;
|
|
146
149
|
align?: "left" | "center" | "right";
|
|
150
|
+
/** Editor layout preset key (e.g. `layout2`, `custom`) — optional on `email_document` rows. */
|
|
151
|
+
preset?: string;
|
|
152
|
+
/** Column width ratios; length should match `columns`. */
|
|
153
|
+
ratios?: number[];
|
|
147
154
|
};
|
|
155
|
+
/** Row shell on `email_document` (editor field names). */
|
|
156
|
+
type RowProps = {
|
|
157
|
+
bgColor?: string;
|
|
158
|
+
bgImage?: string;
|
|
159
|
+
bgRepeat?: string;
|
|
160
|
+
bgSize?: string;
|
|
161
|
+
bgPosition?: string;
|
|
162
|
+
bgGradient?: {
|
|
163
|
+
angle?: number;
|
|
164
|
+
colors?: [string, string, string];
|
|
165
|
+
stops?: [number, number, number];
|
|
166
|
+
} | null;
|
|
167
|
+
padding?: Padding;
|
|
168
|
+
borderRadius?: number;
|
|
169
|
+
borderWidth?: number;
|
|
170
|
+
borderColor?: string;
|
|
171
|
+
textAlign?: "left" | "center" | "right" | "justify";
|
|
172
|
+
};
|
|
173
|
+
/** Legacy row shell (`backgroundColor`, …) — import only. */
|
|
148
174
|
type RowStyles = {
|
|
149
175
|
backgroundColor?: string;
|
|
150
176
|
backgroundImage?: string;
|
|
151
177
|
backgroundRepeat?: string;
|
|
152
178
|
backgroundSize?: string;
|
|
153
179
|
backgroundPosition?: string;
|
|
154
|
-
|
|
155
|
-
backgroundGradient?: {
|
|
156
|
-
angle?: number;
|
|
157
|
-
colors?: [string, string, string];
|
|
158
|
-
stops?: [number, number, number];
|
|
159
|
-
};
|
|
180
|
+
backgroundGradient?: RowProps["bgGradient"];
|
|
160
181
|
padding?: Padding;
|
|
161
182
|
borderRadius?: number;
|
|
162
183
|
borderWidth?: number;
|
|
@@ -174,6 +195,18 @@ type ColumnBorderRadius = number | {
|
|
|
174
195
|
br?: number;
|
|
175
196
|
bl?: number;
|
|
176
197
|
};
|
|
198
|
+
/** Column shell on `email_document` (editor field names). */
|
|
199
|
+
type ColumnProps = {
|
|
200
|
+
padding?: Padding;
|
|
201
|
+
bgColor?: string;
|
|
202
|
+
bgImage?: string;
|
|
203
|
+
bgRepeat?: string;
|
|
204
|
+
bgSize?: string;
|
|
205
|
+
bgPosition?: string;
|
|
206
|
+
bgGradient?: RowProps["bgGradient"];
|
|
207
|
+
borderRadius?: ColumnBorderRadius;
|
|
208
|
+
};
|
|
209
|
+
/** Legacy column shell — import only. */
|
|
177
210
|
type ColumnStyles = {
|
|
178
211
|
padding?: Padding;
|
|
179
212
|
backgroundColor?: string;
|
|
@@ -181,28 +214,27 @@ type ColumnStyles = {
|
|
|
181
214
|
backgroundRepeat?: string;
|
|
182
215
|
backgroundSize?: string;
|
|
183
216
|
backgroundPosition?: string;
|
|
184
|
-
|
|
185
|
-
backgroundGradient?: {
|
|
186
|
-
angle?: number;
|
|
187
|
-
colors?: [string, string, string];
|
|
188
|
-
stops?: [number, number, number];
|
|
189
|
-
};
|
|
190
|
-
/** Uniform px or per-corner (matches block border radius in the editor). */
|
|
217
|
+
backgroundGradient?: RowProps["bgGradient"];
|
|
191
218
|
borderRadius?: ColumnBorderRadius;
|
|
192
219
|
};
|
|
193
220
|
type BlockBase = {
|
|
194
221
|
id?: string;
|
|
195
222
|
type: string;
|
|
196
|
-
|
|
223
|
+
/** Payload: object for most blocks; plain HTML string for `type: "html"`. */
|
|
224
|
+
content?: Record<string, unknown> | string;
|
|
225
|
+
/** Full editor block props (export + preferred import). */
|
|
226
|
+
props?: Record<string, unknown>;
|
|
227
|
+
/** Legacy block styling — import only when `props` is absent. */
|
|
197
228
|
styles?: Record<string, unknown>;
|
|
198
229
|
behavior?: Record<string, unknown>;
|
|
199
230
|
responsive?: Record<string, unknown>;
|
|
200
|
-
/** Full editor block props for lossless export/import (react-email-studio). */
|
|
201
|
-
props?: Record<string, unknown>;
|
|
202
231
|
};
|
|
203
232
|
type EmailDocumentColumn = {
|
|
204
233
|
id?: string;
|
|
205
234
|
layout?: ColumnLayout;
|
|
235
|
+
/** Column surface (padding, backgrounds, radius). */
|
|
236
|
+
props?: ColumnProps;
|
|
237
|
+
/** Legacy column shell — import only. */
|
|
206
238
|
styles?: ColumnStyles;
|
|
207
239
|
blocks?: BlockBase[];
|
|
208
240
|
};
|
|
@@ -210,9 +242,12 @@ type EmailDocumentRow = {
|
|
|
210
242
|
id?: string;
|
|
211
243
|
type?: "row";
|
|
212
244
|
layout?: RowLayout;
|
|
245
|
+
/** Row shell (padding, backgrounds). */
|
|
246
|
+
props?: RowProps;
|
|
247
|
+
/** Legacy row shell — import only. */
|
|
213
248
|
styles?: RowStyles;
|
|
214
249
|
columns?: EmailDocumentColumn[];
|
|
215
|
-
/**
|
|
250
|
+
/** Editor row snapshot (`preset`, `ratios`, column props, …) for round-trip. */
|
|
216
251
|
_reactEmailStudio?: {
|
|
217
252
|
row?: Record<string, unknown>;
|
|
218
253
|
};
|
|
@@ -220,11 +255,18 @@ type EmailDocumentRow = {
|
|
|
220
255
|
type EmailDocument = {
|
|
221
256
|
type: "email_document";
|
|
222
257
|
settings?: EmailDocumentSettings;
|
|
258
|
+
/** Flat root blocks (optional interchange; `rows` is the primary LMS/export shape). */
|
|
259
|
+
blocks?: BlockBase[];
|
|
260
|
+
/** Layout rows with `columns[].blocks[]` (primary import/export shape). */
|
|
223
261
|
rows?: EmailDocumentRow[];
|
|
224
262
|
globalStyles?: Record<string, unknown>;
|
|
225
263
|
responsive?: Record<string, unknown>;
|
|
226
264
|
};
|
|
227
265
|
|
|
266
|
+
/** Coerce fragment / array input into `email_document` before normalize. */
|
|
267
|
+
declare function coerceEmailDocumentInput(input: unknown): unknown;
|
|
268
|
+
/** Normalize input and return `email_document` in LMS/export shape (`rows[]` + `_reactEmailStudio`). */
|
|
269
|
+
declare function canonicalizeEmailDocument(input: unknown): EmailDocument | null;
|
|
228
270
|
/** Re-export for consumers typing `jsonToHtml` options. */
|
|
229
271
|
type JsonToHtmlOptions = EmailHtmlOptions;
|
|
230
272
|
/**
|
|
@@ -233,6 +275,23 @@ type JsonToHtmlOptions = EmailHtmlOptions;
|
|
|
233
275
|
*/
|
|
234
276
|
declare function jsonToHtml(designInput: unknown, opts?: JsonToHtmlOptions): string;
|
|
235
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Pull usable HTML from a full document (`<!DOCTYPE` / `<html>`) or a fragment string.
|
|
280
|
+
*/
|
|
281
|
+
declare function extractHtmlForDesign(html: string): string;
|
|
282
|
+
/**
|
|
283
|
+
* Wrap HTML (fragment or full email/page document) in a minimal `email_document`
|
|
284
|
+
* with one row, one column, and a single **html** block — suitable for `loadJson`.
|
|
285
|
+
*
|
|
286
|
+
* @returns `null` when there is no non-empty HTML after extraction/normalization.
|
|
287
|
+
*/
|
|
288
|
+
declare function htmlToEmailDesignTemplate(html: string): EmailDocument | null;
|
|
289
|
+
/**
|
|
290
|
+
* HTML fragment or full document → `email_document` JSON string (for `loadJson` / storage).
|
|
291
|
+
* Returns `""` when there is no non-empty HTML after extraction.
|
|
292
|
+
*/
|
|
293
|
+
declare function htmlToJson(html: string, pretty?: boolean): string;
|
|
294
|
+
|
|
236
295
|
/** Theme color tokens (subset used by the editor chrome). */
|
|
237
296
|
type ThemeColors = (typeof THEMES)["light"];
|
|
238
297
|
/** Known `options` keys for {@link ReactEmailEditor} — callers may pass extra keys; these are what the editor reads. */
|
|
@@ -263,8 +322,11 @@ type ReactEmailEditorOptions = EmailHtmlOptions & {
|
|
|
263
322
|
paletteGroupLabels?: Partial<Record<BlockPaletteGroupKey, string>>;
|
|
264
323
|
};
|
|
265
324
|
};
|
|
325
|
+
type LoadJsonOptions = {
|
|
326
|
+
mode?: "replace" | "append";
|
|
327
|
+
};
|
|
266
328
|
interface ReactEmailEditorRef {
|
|
267
|
-
loadJson(input: string | Record<string, unknown
|
|
329
|
+
loadJson(input: string | Record<string, unknown>, options?: LoadJsonOptions): void;
|
|
268
330
|
/** Calls `cb` with the design as a JSON string (new `email_document` schema). */
|
|
269
331
|
exportJson(cb: (json: string) => void, pretty?: boolean): void;
|
|
270
332
|
}
|
|
@@ -286,20 +348,9 @@ type ReactEmailEditorProps = {
|
|
|
286
348
|
};
|
|
287
349
|
declare const ReactEmailEditor: react.ForwardRefExoticComponent<ReactEmailEditorProps & react.RefAttributes<ReactEmailEditorRef>> & {
|
|
288
350
|
jsonToHtml: typeof jsonToHtml;
|
|
351
|
+
htmlToJson: typeof htmlToJson;
|
|
289
352
|
};
|
|
290
353
|
|
|
291
|
-
/**
|
|
292
|
-
* Pull usable HTML from a full document (`<!DOCTYPE` / `<html>`) or a fragment string.
|
|
293
|
-
*/
|
|
294
|
-
declare function extractHtmlForDesign(html: string): string;
|
|
295
|
-
/**
|
|
296
|
-
* Wrap HTML (fragment or full email/page document) in a minimal `email_document`
|
|
297
|
-
* with one row, one column, and a single **html** block — suitable for `loadJson`.
|
|
298
|
-
*
|
|
299
|
-
* @returns `null` when there is no non-empty HTML after extraction/normalization.
|
|
300
|
-
*/
|
|
301
|
-
declare function htmlToEmailDesignTemplate(html: string): EmailDocument | null;
|
|
302
|
-
|
|
303
354
|
declare function utf8ToBase64(raw: string): string;
|
|
304
355
|
declare function base64ToUtf8(b64: string): string;
|
|
305
356
|
|
|
@@ -427,4 +478,4 @@ declare const DEVICES: ({
|
|
|
427
478
|
})[];
|
|
428
479
|
declare function PreviewModal({ html, contentWidth, rowCount, blockCount, editorZoom, locale, initialDevice, initialMobileVariant, onClose, C, title, secondaryActionLabel, onSecondaryAction, }: EmailPreviewModalProps): react_jsx_runtime.JSX.Element;
|
|
429
480
|
|
|
430
|
-
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, extractHtmlForDesign, htmlToEmailDesignTemplate, jsonToHtml, utf8ToBase64 };
|
|
481
|
+
export { type BlockBase, type ColumnProps, type ColumnStyles, type EmailDocument, type EmailDocumentColumn, type EmailDocumentRow, type EmailDocumentSettings, type EmailHtmlOptions, PreviewModal as EmailPreviewModal, type EmailPreviewModalProps, type JsonToHtmlOptions, type LoadJsonOptions, type MobilePreviewVariant, ReactEmailEditor, type ReactEmailEditorOptions, type ReactEmailEditorProps, type ReactEmailEditorRef, type RowProps, type RowStyles, base64ToUtf8, canonicalizeEmailDocument, coerceEmailDocumentInput, DEVICES as emailPreviewDevices, extractHtmlForDesign, htmlToEmailDesignTemplate, htmlToJson, jsonToHtml, utf8ToBase64 };
|