better-react-email-editor 0.1.3 → 0.1.6
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 +400 -394
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1256 -1052
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1724 -1634
- package/dist/types/components/BetterEmailEditor.d.ts +2 -0
- package/dist/types/components/BodyTab.d.ts +1 -1
- package/dist/types/components/Canvas.d.ts +3 -1
- package/dist/types/components/EmailHeader.d.ts +4 -0
- package/dist/types/components/fields.d.ts +9 -0
- package/dist/types/context.d.ts +7 -0
- package/dist/types/core/email-font.d.ts +5 -0
- package/dist/types/core/fonts.d.ts +13 -0
- package/dist/types/i18n/en.d.ts +10 -0
- package/dist/types/i18n/index.d.ts +20 -0
- package/dist/types/index.d.ts +3 -1
- package/package.json +1 -1
|
@@ -17,6 +17,8 @@ export interface BetterEmailEditorProps extends Omit<EditorRootProps, 'children'
|
|
|
17
17
|
showLayers?: boolean;
|
|
18
18
|
/** Show the right sidebar. Default: true. */
|
|
19
19
|
showSidebar?: boolean;
|
|
20
|
+
/** Show the subject and preview text fields above the email. Default: false. */
|
|
21
|
+
showEmailHeader?: boolean;
|
|
20
22
|
/** Replace any part with your own component. */
|
|
21
23
|
components?: BetterEmailEditorComponents;
|
|
22
24
|
/** Props (className, style…) forwarded to each part. */
|
|
@@ -5,5 +5,5 @@ export type DocumentContext = Parameters<NonNullable<InspectorDocumentProps['chi
|
|
|
5
5
|
export interface BodyTabProps extends StyleProps {
|
|
6
6
|
ctx: DocumentContext;
|
|
7
7
|
}
|
|
8
|
-
/** "Body" tab: email-wide settings (background, width, default colors, preview text). */
|
|
8
|
+
/** "Body" tab: email-wide settings (background, width, default font and colors, preview text). */
|
|
9
9
|
export declare function BodyTab({ ctx, className, style }: BodyTabProps): import("react").JSX.Element;
|
|
@@ -8,8 +8,10 @@ export interface CanvasProps extends StyleProps {
|
|
|
8
8
|
bubbleMenu?: boolean;
|
|
9
9
|
/** "/" command menu. `true` (default), `false`, or your own items. */
|
|
10
10
|
slashCommands?: boolean | SlashCommandItem[];
|
|
11
|
+
/** Subject and preview text fields above the email. Default: false. */
|
|
12
|
+
header?: boolean;
|
|
11
13
|
/** Extra content rendered inside the canvas scroll area. */
|
|
12
14
|
children?: ReactNode;
|
|
13
15
|
}
|
|
14
16
|
/** The editable email. Scrolls on its own: give it a height through its parent or `style`. */
|
|
15
|
-
export declare function Canvas({ overlay, bubbleMenu, slashCommands, className, style, children }: CanvasProps): import("react").JSX.Element;
|
|
17
|
+
export declare function Canvas({ overlay, bubbleMenu, slashCommands, header, className, style, children }: CanvasProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type StyleProps } from '../core/cx';
|
|
2
|
+
export type EmailHeaderProps = StyleProps;
|
|
3
|
+
/** Card with the subject line and the preview text, as an inbox shows them. */
|
|
4
|
+
export declare function EmailHeader({ className, style }: EmailHeaderProps): import("react").JSX.Element;
|
|
@@ -78,6 +78,15 @@ export interface SelectProps extends StyleProps {
|
|
|
78
78
|
options: Array<[string, string]>;
|
|
79
79
|
}
|
|
80
80
|
export declare function Select({ value, onChange, options, className, style }: SelectProps): import("react").JSX.Element;
|
|
81
|
+
export interface FontInputProps extends StyleProps {
|
|
82
|
+
/** A CSS `font-family` stack, or '' for none. */
|
|
83
|
+
value: string | undefined;
|
|
84
|
+
onChange: (value: string) => void;
|
|
85
|
+
/** Label of an extra first option that clears the font (''), e.g. "Default". */
|
|
86
|
+
emptyLabel?: string;
|
|
87
|
+
}
|
|
88
|
+
/** Font picker over the editor's `fonts`. Each option is drawn in its own font. */
|
|
89
|
+
export declare function FontInput({ value, onChange, emptyLabel, className, style }: FontInputProps): import("react").JSX.Element;
|
|
81
90
|
export interface SegmentedProps<T extends string> extends StyleProps {
|
|
82
91
|
value: T;
|
|
83
92
|
onChange: (value: T) => void;
|
package/dist/types/context.d.ts
CHANGED
|
@@ -2,10 +2,13 @@ import type { Editor, Extensions, JSONContent } from '@tiptap/core';
|
|
|
2
2
|
import { type EditorThemeInput } from '@react-email/editor/plugins';
|
|
3
3
|
import { type ReactNode } from 'react';
|
|
4
4
|
import { type StyleProps } from './core/cx';
|
|
5
|
+
import { type FontOption } from './core/fonts';
|
|
5
6
|
import { type DragSession, type HoverStore } from './core/stores';
|
|
6
7
|
import { type I18n, type Messages, type PartialMessages } from './i18n';
|
|
7
8
|
import type { NodeDefinition, PaletteGroup, PaletteItem, TemplateItem } from './registry/types';
|
|
8
9
|
export interface EmailSettings {
|
|
10
|
+
/** Subject line. Not part of the rendered HTML: send it with your email provider. */
|
|
11
|
+
subject?: string;
|
|
9
12
|
/** Inbox preview line (shown after the subject). */
|
|
10
13
|
previewText: string;
|
|
11
14
|
}
|
|
@@ -43,6 +46,8 @@ export interface EmailEditorContextValue extends I18n {
|
|
|
43
46
|
palette: PaletteItem[];
|
|
44
47
|
paletteGroups: PaletteGroup[];
|
|
45
48
|
templates: TemplateItem[];
|
|
49
|
+
/** Fonts offered by the font pickers. */
|
|
50
|
+
fonts: FontOption[];
|
|
46
51
|
starterDocument: (i18n: I18n) => JSONContent;
|
|
47
52
|
uploadImage: (file: File) => Promise<{
|
|
48
53
|
url: string;
|
|
@@ -82,6 +87,8 @@ export interface EditorRootProps extends StyleProps {
|
|
|
82
87
|
paletteGroups?: PaletteGroup[];
|
|
83
88
|
/** Prebuilt rows of the "Blocks" tab. */
|
|
84
89
|
templates?: TemplateItem[];
|
|
90
|
+
/** Fonts offered by the font pickers (Body tab and typography). Default: fonts installed with the main browsers. */
|
|
91
|
+
fonts?: FontOption[];
|
|
85
92
|
/** Content loaded by the top bar's "Template" button. */
|
|
86
93
|
starterDocument?: (i18n: I18n) => JSONContent;
|
|
87
94
|
/** Extra Tiptap extensions, read on mount. */
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
/** Font chosen for the whole email, or '' when it uses the theme's (system) font. */
|
|
3
|
+
export declare function getEmailFont(editor: Editor): string;
|
|
4
|
+
/** Sets the default font of the email. '' goes back to the theme's font. */
|
|
5
|
+
export declare function setEmailFont(editor: Editor, value: string): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** A font offered in the font pickers. `value` is a full CSS `font-family` stack. */
|
|
2
|
+
export interface FontOption {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Fonts installed on virtually every device and supported by every email
|
|
8
|
+
* client, each with fallbacks. Single quotes only: the stack ends up in a
|
|
9
|
+
* `style` attribute.
|
|
10
|
+
*/
|
|
11
|
+
export declare const defaultFonts: FontOption[];
|
|
12
|
+
/** The option whose first family matches `value` (quotes and fallbacks may differ). */
|
|
13
|
+
export declare function findFont(fonts: FontOption[], value: string | undefined): FontOption | undefined;
|
package/dist/types/i18n/en.d.ts
CHANGED
|
@@ -44,6 +44,12 @@ export declare const en: {
|
|
|
44
44
|
breadcrumb: string;
|
|
45
45
|
selectedText: string;
|
|
46
46
|
};
|
|
47
|
+
emailHeader: {
|
|
48
|
+
subject: string;
|
|
49
|
+
subjectPlaceholder: string;
|
|
50
|
+
previewText: string;
|
|
51
|
+
previewTextPlaceholder: string;
|
|
52
|
+
};
|
|
47
53
|
body: {
|
|
48
54
|
general: string;
|
|
49
55
|
previewText: string;
|
|
@@ -57,6 +63,8 @@ export declare const en: {
|
|
|
57
63
|
innerPadding: string;
|
|
58
64
|
radius: string;
|
|
59
65
|
defaultStyles: string;
|
|
66
|
+
font: string;
|
|
67
|
+
fontDefault: string;
|
|
60
68
|
text: string;
|
|
61
69
|
headings: string;
|
|
62
70
|
links: string;
|
|
@@ -65,6 +73,8 @@ export declare const en: {
|
|
|
65
73
|
};
|
|
66
74
|
inspector: {
|
|
67
75
|
typography: string;
|
|
76
|
+
font: string;
|
|
77
|
+
fontDefault: string;
|
|
68
78
|
color: string;
|
|
69
79
|
size: string;
|
|
70
80
|
weight: string;
|
|
@@ -48,6 +48,12 @@ export declare const locales: {
|
|
|
48
48
|
breadcrumb: string;
|
|
49
49
|
selectedText: string;
|
|
50
50
|
};
|
|
51
|
+
emailHeader: {
|
|
52
|
+
subject: string;
|
|
53
|
+
subjectPlaceholder: string;
|
|
54
|
+
previewText: string;
|
|
55
|
+
previewTextPlaceholder: string;
|
|
56
|
+
};
|
|
51
57
|
body: {
|
|
52
58
|
general: string;
|
|
53
59
|
previewText: string;
|
|
@@ -61,6 +67,8 @@ export declare const locales: {
|
|
|
61
67
|
innerPadding: string;
|
|
62
68
|
radius: string;
|
|
63
69
|
defaultStyles: string;
|
|
70
|
+
font: string;
|
|
71
|
+
fontDefault: string;
|
|
64
72
|
text: string;
|
|
65
73
|
headings: string;
|
|
66
74
|
links: string;
|
|
@@ -69,6 +77,8 @@ export declare const locales: {
|
|
|
69
77
|
};
|
|
70
78
|
inspector: {
|
|
71
79
|
typography: string;
|
|
80
|
+
font: string;
|
|
81
|
+
fontDefault: string;
|
|
72
82
|
color: string;
|
|
73
83
|
size: string;
|
|
74
84
|
weight: string;
|
|
@@ -291,6 +301,12 @@ export declare const locales: {
|
|
|
291
301
|
breadcrumb: string;
|
|
292
302
|
selectedText: string;
|
|
293
303
|
};
|
|
304
|
+
emailHeader: {
|
|
305
|
+
subject: string;
|
|
306
|
+
subjectPlaceholder: string;
|
|
307
|
+
previewText: string;
|
|
308
|
+
previewTextPlaceholder: string;
|
|
309
|
+
};
|
|
294
310
|
body: {
|
|
295
311
|
general: string;
|
|
296
312
|
previewText: string;
|
|
@@ -304,6 +320,8 @@ export declare const locales: {
|
|
|
304
320
|
innerPadding: string;
|
|
305
321
|
radius: string;
|
|
306
322
|
defaultStyles: string;
|
|
323
|
+
font: string;
|
|
324
|
+
fontDefault: string;
|
|
307
325
|
text: string;
|
|
308
326
|
headings: string;
|
|
309
327
|
links: string;
|
|
@@ -312,6 +330,8 @@ export declare const locales: {
|
|
|
312
330
|
};
|
|
313
331
|
inspector: {
|
|
314
332
|
typography: string;
|
|
333
|
+
font: string;
|
|
334
|
+
fontDefault: string;
|
|
315
335
|
color: string;
|
|
316
336
|
size: string;
|
|
317
337
|
weight: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { BetterEmailEditor, type BetterEmailEditorProps, type BetterEmailEditorC
|
|
|
2
2
|
export { EditorRoot, useEmailEditor, useOptionalEmailEditor, useI18n, useMessages, defaultTheme, readFileAsDataUrl, type EditorRootProps, type EmailEditorHandle, type EmailEditorContextValue, type EmailValue, type EmailSettings, type EmailExport, type Device, } from './context';
|
|
3
3
|
export { Canvas, type CanvasProps } from './components/Canvas';
|
|
4
4
|
export { CanvasOverlay } from './components/CanvasOverlay';
|
|
5
|
+
export { EmailHeader, type EmailHeaderProps } from './components/EmailHeader';
|
|
5
6
|
export { TopBar, LayersToggle, UndoRedo, DeviceToggle, TemplateButton, ImportButton, ExportJsonButton, PreviewButton, ExportHtmlButton, type TopBarProps, type PreviewButtonProps, } from './components/TopBar';
|
|
6
7
|
export { LayersPanel, type LayersPanelProps } from './components/LayersPanel';
|
|
7
8
|
export { Sidebar, type SidebarProps } from './components/Sidebar';
|
|
@@ -22,7 +23,7 @@ export { SocialLinksInspector } from './components/inspectors/SocialLinksInspect
|
|
|
22
23
|
export { ColumnsInspector } from './components/inspectors/ColumnsInspector';
|
|
23
24
|
export { SpacerInspector, HtmlInspector, DividerInspector, ContainerInspector } from './components/inspectors/SimpleInspectors';
|
|
24
25
|
export { TypographyGroup, SpacingGroup, BoxGroup, css, type TypographyGroupProps, type SpacingGroupProps, type BoxGroupProps, } from './components/inspectors/groups';
|
|
25
|
-
export { Group, Field, TextInput, TextArea, NumberInput, RangeInput, ColorInput, Select, Segmented, AlignInput, PaddingInput, toHex, DEFAULT_SWATCHES, type GroupProps, type FieldProps, type TextInputProps, type TextAreaProps, type NumberInputProps, type RangeInputProps, type ColorInputProps, type SelectProps, type SegmentedProps, type AlignInputProps, type PaddingInputProps, type Side, } from './components/fields';
|
|
26
|
+
export { Group, Field, TextInput, TextArea, NumberInput, RangeInput, FontInput, ColorInput, Select, Segmented, AlignInput, PaddingInput, toHex, DEFAULT_SWATCHES, type GroupProps, type FieldProps, type TextInputProps, type TextAreaProps, type NumberInputProps, type FontInputProps, type RangeInputProps, type ColorInputProps, type SelectProps, type SegmentedProps, type AlignInputProps, type PaddingInputProps, type Side, } from './components/fields';
|
|
26
27
|
export * as icons from './components/icons';
|
|
27
28
|
export { defaultNodes, textPreview, truncate } from './registry/default-nodes';
|
|
28
29
|
export { defaultPalette, defaultPaletteGroups, menuParagraph } from './registry/default-palette';
|
|
@@ -34,4 +35,5 @@ export * as content from './core/content';
|
|
|
34
35
|
export { BLOCK_CONTAINERS, COLUMN_PARENTS, appendBlocks, applyDrop, findDropTarget, selectedUnit, selectUnit, duplicateUnit, deleteUnit, parentUnit, unitAt, type BlockUnit, type DragPayload, type DropTarget, } from './core/dnd';
|
|
35
36
|
export { EmailButton } from './core/paste';
|
|
36
37
|
export { inlineStyleToObject } from './core/style-utils';
|
|
38
|
+
export { defaultFonts, findFont, type FontOption } from './core/fonts';
|
|
37
39
|
export { cx, type StyleProps } from './core/cx';
|
package/package.json
CHANGED