@react-email/editor 0.0.0-experimental.32 → 0.0.0-experimental.34
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-BrSAA0dn.d.mts.map +1 -1
- package/dist/plugins/index.cjs +333 -0
- package/dist/plugins/index.d.cts +107 -11
- package/dist/plugins/index.d.cts.map +1 -1
- package/dist/plugins/index.d.mts +107 -11
- package/dist/plugins/index.d.mts.map +1 -1
- package/dist/plugins/index.mjs +322 -1
- package/dist/plugins/index.mjs.map +1 -1
- package/dist/ui/index.d.cts +73 -73
- package/dist/ui/index.d.cts.map +1 -1
- package/dist/ui/index.d.mts +73 -73
- package/dist/ui/index.d.mts.map +1 -1
- package/package.json +1 -1
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { Editor, Extension, JSONContent } from "@tiptap/core";
|
|
2
2
|
import * as React$1 from "react";
|
|
3
3
|
|
|
4
|
-
//#region src/core/serializer/serializer-plugin.d.ts
|
|
5
|
-
interface SerializerPlugin {
|
|
6
|
-
getNodeStyles(node: JSONContent, depth: number, editor: Editor): React.CSSProperties;
|
|
7
|
-
BaseTemplate(props: {
|
|
8
|
-
previewText?: string;
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
editor: Editor;
|
|
11
|
-
}): React.ReactNode;
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
4
|
//#region src/plugins/email-theming/types.d.ts
|
|
15
5
|
type InputType = 'color' | 'number' | 'select' | 'text' | 'textarea';
|
|
16
6
|
type InputUnit = 'px' | '%';
|
|
@@ -19,6 +9,7 @@ type EditorTheme = 'basic' | 'minimal';
|
|
|
19
9
|
type PanelSectionId = 'body' | 'container' | 'typography' | 'h1' | 'h2' | 'h3' | 'link' | 'image' | 'button' | 'code-block' | 'inline-code';
|
|
20
10
|
type KnownThemeComponents = 'reset' | 'body' | 'container' | 'h1' | 'h2' | 'h3' | 'paragraph' | 'nestedList' | 'list' | 'listItem' | 'listParagraph' | 'blockquote' | 'codeBlock' | 'inlineCode' | 'codeTag' | 'link' | 'footer' | 'hr' | 'image' | 'button' | 'section';
|
|
21
11
|
type KnownCssProperties = 'align' | 'backgroundColor' | 'color' | 'fontSize' | 'fontWeight' | 'letterSpacing' | 'lineHeight' | 'textDecoration' | 'borderRadius' | 'borderTopLeftRadius' | 'borderTopRightRadius' | 'borderBottomLeftRadius' | 'borderBottomRightRadius' | 'borderWidth' | 'borderTopWidth' | 'borderRightWidth' | 'borderBottomWidth' | 'borderLeftWidth' | 'borderStyle' | 'borderTopStyle' | 'borderRightStyle' | 'borderBottomStyle' | 'borderLeftStyle' | 'borderColor' | 'borderTopColor' | 'borderRightColor' | 'borderBottomColor' | 'borderLeftColor' | 'padding' | 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'width' | 'height';
|
|
12
|
+
type ResetTheme = Record<KnownThemeComponents, React$1.CSSProperties>;
|
|
22
13
|
type CssJs = { [K in KnownThemeComponents]: React$1.CSSProperties & {
|
|
23
14
|
align?: 'center' | 'left' | 'right';
|
|
24
15
|
} };
|
|
@@ -53,6 +44,92 @@ interface PanelGroup {
|
|
|
53
44
|
inputs: Omit<PanelInputProperty, 'category'>[];
|
|
54
45
|
}
|
|
55
46
|
//#endregion
|
|
47
|
+
//#region src/plugins/email-theming/css-transforms.d.ts
|
|
48
|
+
declare function transformToCssJs(styleArray: PanelGroup[], baseFontSize: number): CssJs;
|
|
49
|
+
declare function mergeCssJs(original: CssJs, newCssJs: CssJs): {
|
|
50
|
+
blockquote: React$1.CSSProperties & {
|
|
51
|
+
align?: "center" | "left" | "right";
|
|
52
|
+
};
|
|
53
|
+
codeBlock: React$1.CSSProperties & {
|
|
54
|
+
align?: "center" | "left" | "right";
|
|
55
|
+
};
|
|
56
|
+
listItem: React$1.CSSProperties & {
|
|
57
|
+
align?: "center" | "left" | "right";
|
|
58
|
+
};
|
|
59
|
+
link: React$1.CSSProperties & {
|
|
60
|
+
align?: "center" | "left" | "right";
|
|
61
|
+
};
|
|
62
|
+
paragraph: React$1.CSSProperties & {
|
|
63
|
+
align?: "center" | "left" | "right";
|
|
64
|
+
};
|
|
65
|
+
image: React$1.CSSProperties & {
|
|
66
|
+
align?: "center" | "left" | "right";
|
|
67
|
+
};
|
|
68
|
+
button: React$1.CSSProperties & {
|
|
69
|
+
align?: "center" | "left" | "right";
|
|
70
|
+
};
|
|
71
|
+
footer: React$1.CSSProperties & {
|
|
72
|
+
align?: "center" | "left" | "right";
|
|
73
|
+
};
|
|
74
|
+
section: React$1.CSSProperties & {
|
|
75
|
+
align?: "center" | "left" | "right";
|
|
76
|
+
};
|
|
77
|
+
body: React$1.CSSProperties & {
|
|
78
|
+
align?: "center" | "left" | "right";
|
|
79
|
+
};
|
|
80
|
+
reset: React$1.CSSProperties & {
|
|
81
|
+
align?: "center" | "left" | "right";
|
|
82
|
+
};
|
|
83
|
+
container: React$1.CSSProperties & {
|
|
84
|
+
align?: "center" | "left" | "right";
|
|
85
|
+
};
|
|
86
|
+
h1: React$1.CSSProperties & {
|
|
87
|
+
align?: "center" | "left" | "right";
|
|
88
|
+
};
|
|
89
|
+
h2: React$1.CSSProperties & {
|
|
90
|
+
align?: "center" | "left" | "right";
|
|
91
|
+
};
|
|
92
|
+
h3: React$1.CSSProperties & {
|
|
93
|
+
align?: "center" | "left" | "right";
|
|
94
|
+
};
|
|
95
|
+
nestedList: React$1.CSSProperties & {
|
|
96
|
+
align?: "center" | "left" | "right";
|
|
97
|
+
};
|
|
98
|
+
list: React$1.CSSProperties & {
|
|
99
|
+
align?: "center" | "left" | "right";
|
|
100
|
+
};
|
|
101
|
+
listParagraph: React$1.CSSProperties & {
|
|
102
|
+
align?: "center" | "left" | "right";
|
|
103
|
+
};
|
|
104
|
+
inlineCode: React$1.CSSProperties & {
|
|
105
|
+
align?: "center" | "left" | "right";
|
|
106
|
+
};
|
|
107
|
+
codeTag: React$1.CSSProperties & {
|
|
108
|
+
align?: "center" | "left" | "right";
|
|
109
|
+
};
|
|
110
|
+
hr: React$1.CSSProperties & {
|
|
111
|
+
align?: "center" | "left" | "right";
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
declare function injectThemeCss(styles: CssJs, options?: {
|
|
115
|
+
styleId?: string;
|
|
116
|
+
scopeSelector?: string;
|
|
117
|
+
}): void;
|
|
118
|
+
declare function injectGlobalPlainCss(css?: string | null, options?: {
|
|
119
|
+
styleId?: string;
|
|
120
|
+
scopeSelector?: string;
|
|
121
|
+
}): void;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/core/serializer/serializer-plugin.d.ts
|
|
124
|
+
interface SerializerPlugin {
|
|
125
|
+
getNodeStyles(node: JSONContent, depth: number, editor: Editor): React.CSSProperties;
|
|
126
|
+
BaseTemplate(props: {
|
|
127
|
+
previewText?: string;
|
|
128
|
+
children: React.ReactNode;
|
|
129
|
+
editor: Editor;
|
|
130
|
+
}): React.ReactNode;
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
56
133
|
//#region src/plugins/email-theming/extension.d.ts
|
|
57
134
|
/**
|
|
58
135
|
* Maps a document node (type + attrs) to the theme component key used for style lookup.
|
|
@@ -76,5 +153,24 @@ declare const EmailTheming: Extension<{
|
|
|
76
153
|
serializerPlugin: SerializerPlugin;
|
|
77
154
|
}, any>;
|
|
78
155
|
//#endregion
|
|
79
|
-
|
|
156
|
+
//#region src/plugins/email-theming/themes.d.ts
|
|
157
|
+
/**
|
|
158
|
+
* Resolves the display title for a panel group.
|
|
159
|
+
* Uses the `id` lookup when available, falls back to the
|
|
160
|
+
* DB-persisted `title` for backwards compatibility.
|
|
161
|
+
*/
|
|
162
|
+
declare function getPanelTitle(group: PanelGroup): string;
|
|
163
|
+
declare const RESET_THEMES: Record<EditorTheme, ResetTheme>;
|
|
164
|
+
declare function resolveResetValue(value: string | number | undefined, targetUnit: 'px' | '%', bodyFontSizePx: number): number | undefined;
|
|
165
|
+
declare const EDITOR_THEMES: Record<EditorTheme, PanelGroup[]>;
|
|
166
|
+
declare function getThemeBodyFontSizePx(theme: EditorTheme): number;
|
|
167
|
+
/**
|
|
168
|
+
* Use to make the preview nicer once the theme might miss some
|
|
169
|
+
* important properties to make layout accurate
|
|
170
|
+
*/
|
|
171
|
+
declare const DEFAULT_INBOX_FONT_SIZE_PX = 14;
|
|
172
|
+
declare const INBOX_EMAIL_DEFAULTS: Partial<ResetTheme>;
|
|
173
|
+
declare const SUPPORTED_CSS_PROPERTIES: SupportedCssProperties;
|
|
174
|
+
//#endregion
|
|
175
|
+
export { CssJs, DEFAULT_INBOX_FONT_SIZE_PX, EDITOR_THEMES, EditorTheme, EmailTheming, INBOX_EMAIL_DEFAULTS, KnownCssProperties, KnownThemeComponents, PanelGroup, PanelInputProperty, PanelSectionId, RESET_THEMES, ResetTheme, SUPPORTED_CSS_PROPERTIES, SupportedCssProperties, getMergedCssJs, getPanelTitle, getResolvedNodeStyles, getThemeBodyFontSizePx, getThemeComponentKey, injectGlobalPlainCss, injectThemeCss, mergeCssJs, resolveResetValue, stylesToCss, transformToCssJs, useEmailTheming };
|
|
80
176
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/core/serializer/serializer-plugin.ts","../../src/plugins/email-theming/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/plugins/email-theming/types.ts","../../src/plugins/email-theming/css-transforms.ts","../../src/core/serializer/serializer-plugin.ts","../../src/plugins/email-theming/extension.tsx","../../src/plugins/email-theming/themes.ts"],"sourcesContent":[],"mappings":";;;;KAEK,SAAA;KACA,SAAA;KACA,OAAA,GAAU;AAFV,KAIO,WAAA,GAJE,OAAA,GAAA,SAAA;AACT,KAIO,cAAA,GAJE,MAAA,GAAA,WAAA,GAAA,YAAA,GAAA,IAAA,GAAA,IAAA,GAAA,IAAA,GAAA,MAAA,GAAA,OAAA,GAAA,QAAA,GAAA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AAA,SAAA;AAYd,cI0aC,aJ1amB,EI0aJ,MJ1aI,CI0aG,WJ1aH,EI0agB,UJ1ahB,EAAA,CAAA;AAuBpB,iBIwZI,sBAAA,CJxZc,KAAA,EIwZgB,WJxZhB,CAAA,EAAA,MAAA;AAqC9B;;;;AAA+B,cIqYlB,0BAAA,GJrYkB,EAAA;AAEnB,cIoYC,oBJnYL,EImY2B,OJnYJ,CImYY,UJnYN,CAAA;AAKzB,cI2YC,wBJ3YqB,EI2YK,sBJ3YL"}
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -73,6 +73,33 @@ function injectGlobalPlainCss(css, options = {}) {
|
|
|
73
73
|
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/plugins/email-theming/themes.ts
|
|
76
|
+
/**
|
|
77
|
+
* Single source of truth for panel section display titles.
|
|
78
|
+
* Titles are resolved from here at render time via `getPanelTitle`,
|
|
79
|
+
* so they never depend on what's persisted in the DB.
|
|
80
|
+
*/
|
|
81
|
+
const PANEL_SECTION_TITLES = {
|
|
82
|
+
body: "Background",
|
|
83
|
+
container: "Body",
|
|
84
|
+
typography: "Text",
|
|
85
|
+
h1: "Title",
|
|
86
|
+
h2: "Subtitle",
|
|
87
|
+
h3: "Heading",
|
|
88
|
+
link: "Link",
|
|
89
|
+
image: "Image",
|
|
90
|
+
button: "Button",
|
|
91
|
+
"code-block": "Code Block",
|
|
92
|
+
"inline-code": "Inline Code"
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Resolves the display title for a panel group.
|
|
96
|
+
* Uses the `id` lookup when available, falls back to the
|
|
97
|
+
* DB-persisted `title` for backwards compatibility.
|
|
98
|
+
*/
|
|
99
|
+
function getPanelTitle(group) {
|
|
100
|
+
if (group.id && group.id in PANEL_SECTION_TITLES) return PANEL_SECTION_TITLES[group.id];
|
|
101
|
+
return group.title;
|
|
102
|
+
}
|
|
76
103
|
const THEME_BASIC = [
|
|
77
104
|
{
|
|
78
105
|
id: "body",
|
|
@@ -447,10 +474,25 @@ const RESET_THEMES = {
|
|
|
447
474
|
basic: RESET_BASIC,
|
|
448
475
|
minimal: RESET_MINIMAL
|
|
449
476
|
};
|
|
477
|
+
function resolveResetValue(value, targetUnit, bodyFontSizePx) {
|
|
478
|
+
if (value === void 0) return;
|
|
479
|
+
const str = String(value);
|
|
480
|
+
const num = Number.parseFloat(str);
|
|
481
|
+
if (Number.isNaN(num)) return;
|
|
482
|
+
if (str.endsWith("em")) return targetUnit === "px" ? Math.floor(num * bodyFontSizePx) : num * 100;
|
|
483
|
+
return num;
|
|
484
|
+
}
|
|
450
485
|
const EDITOR_THEMES = {
|
|
451
486
|
minimal: THEME_MINIMAL,
|
|
452
487
|
basic: THEME_BASIC
|
|
453
488
|
};
|
|
489
|
+
function getThemeBodyFontSizePx(theme) {
|
|
490
|
+
for (const group of EDITOR_THEMES[theme]) {
|
|
491
|
+
if (group.classReference !== "body") continue;
|
|
492
|
+
for (const input of group.inputs) if (input.prop === "fontSize" && typeof input.value === "number") return input.value;
|
|
493
|
+
}
|
|
494
|
+
return 14;
|
|
495
|
+
}
|
|
454
496
|
/**
|
|
455
497
|
* Use to make the preview nicer once the theme might miss some
|
|
456
498
|
* important properties to make layout accurate
|
|
@@ -465,6 +507,285 @@ const INBOX_EMAIL_DEFAULTS = {
|
|
|
465
507
|
},
|
|
466
508
|
container: { width: 600 }
|
|
467
509
|
};
|
|
510
|
+
const SUPPORTED_CSS_PROPERTIES = {
|
|
511
|
+
align: {
|
|
512
|
+
label: "Align",
|
|
513
|
+
type: "select",
|
|
514
|
+
options: {
|
|
515
|
+
left: "Left",
|
|
516
|
+
center: "Center",
|
|
517
|
+
right: "Right"
|
|
518
|
+
},
|
|
519
|
+
defaultValue: "left",
|
|
520
|
+
category: "layout"
|
|
521
|
+
},
|
|
522
|
+
backgroundColor: {
|
|
523
|
+
label: "Background",
|
|
524
|
+
type: "color",
|
|
525
|
+
excludeNodes: ["image", "youtube"],
|
|
526
|
+
defaultValue: "#ffffff",
|
|
527
|
+
category: "appearance"
|
|
528
|
+
},
|
|
529
|
+
color: {
|
|
530
|
+
label: "Text color",
|
|
531
|
+
type: "color",
|
|
532
|
+
excludeNodes: ["image", "youtube"],
|
|
533
|
+
defaultValue: "#000000",
|
|
534
|
+
category: "typography"
|
|
535
|
+
},
|
|
536
|
+
fontSize: {
|
|
537
|
+
label: "Font size",
|
|
538
|
+
type: "number",
|
|
539
|
+
unit: "px",
|
|
540
|
+
excludeNodes: ["image", "youtube"],
|
|
541
|
+
defaultValue: 14,
|
|
542
|
+
category: "typography"
|
|
543
|
+
},
|
|
544
|
+
fontWeight: {
|
|
545
|
+
label: "Font weight",
|
|
546
|
+
type: "select",
|
|
547
|
+
options: {
|
|
548
|
+
300: "Light",
|
|
549
|
+
400: "Normal",
|
|
550
|
+
600: "Semi Bold",
|
|
551
|
+
700: "Bold",
|
|
552
|
+
800: "Extra Bold"
|
|
553
|
+
},
|
|
554
|
+
excludeNodes: ["image", "youtube"],
|
|
555
|
+
defaultValue: 400,
|
|
556
|
+
category: "typography"
|
|
557
|
+
},
|
|
558
|
+
letterSpacing: {
|
|
559
|
+
label: "Letter spacing",
|
|
560
|
+
type: "number",
|
|
561
|
+
unit: "px",
|
|
562
|
+
excludeNodes: ["image", "youtube"],
|
|
563
|
+
defaultValue: 0,
|
|
564
|
+
category: "typography"
|
|
565
|
+
},
|
|
566
|
+
lineHeight: {
|
|
567
|
+
label: "Line height",
|
|
568
|
+
type: "number",
|
|
569
|
+
unit: "%",
|
|
570
|
+
defaultValue: 155,
|
|
571
|
+
category: "typography"
|
|
572
|
+
},
|
|
573
|
+
textDecoration: {
|
|
574
|
+
label: "Text decoration",
|
|
575
|
+
type: "select",
|
|
576
|
+
options: {
|
|
577
|
+
none: "None",
|
|
578
|
+
underline: "Underline",
|
|
579
|
+
"line-through": "Line-through"
|
|
580
|
+
},
|
|
581
|
+
defaultValue: "none",
|
|
582
|
+
category: "typography"
|
|
583
|
+
},
|
|
584
|
+
borderRadius: {
|
|
585
|
+
label: "Border Radius",
|
|
586
|
+
type: "number",
|
|
587
|
+
unit: "px",
|
|
588
|
+
defaultValue: 8,
|
|
589
|
+
category: "appearance"
|
|
590
|
+
},
|
|
591
|
+
borderTopLeftRadius: {
|
|
592
|
+
label: "Border Radius (Top-Left)",
|
|
593
|
+
type: "number",
|
|
594
|
+
unit: "px",
|
|
595
|
+
defaultValue: 8,
|
|
596
|
+
category: "appearance"
|
|
597
|
+
},
|
|
598
|
+
borderTopRightRadius: {
|
|
599
|
+
label: "Border Radius (Top-Right)",
|
|
600
|
+
type: "number",
|
|
601
|
+
unit: "px",
|
|
602
|
+
defaultValue: 8,
|
|
603
|
+
category: "appearance"
|
|
604
|
+
},
|
|
605
|
+
borderBottomLeftRadius: {
|
|
606
|
+
label: "Border Radius (Bottom-Left)",
|
|
607
|
+
type: "number",
|
|
608
|
+
unit: "px",
|
|
609
|
+
defaultValue: 8,
|
|
610
|
+
category: "appearance"
|
|
611
|
+
},
|
|
612
|
+
borderBottomRightRadius: {
|
|
613
|
+
label: "Border Radius (Bottom-Right)",
|
|
614
|
+
type: "number",
|
|
615
|
+
unit: "px",
|
|
616
|
+
defaultValue: 8,
|
|
617
|
+
category: "appearance"
|
|
618
|
+
},
|
|
619
|
+
borderWidth: {
|
|
620
|
+
label: "Border Width",
|
|
621
|
+
type: "number",
|
|
622
|
+
unit: "px",
|
|
623
|
+
defaultValue: 1,
|
|
624
|
+
category: "appearance"
|
|
625
|
+
},
|
|
626
|
+
borderTopWidth: {
|
|
627
|
+
label: "Border Top Width",
|
|
628
|
+
type: "number",
|
|
629
|
+
unit: "px",
|
|
630
|
+
defaultValue: 1,
|
|
631
|
+
category: "appearance"
|
|
632
|
+
},
|
|
633
|
+
borderRightWidth: {
|
|
634
|
+
label: "Border Right Width",
|
|
635
|
+
type: "number",
|
|
636
|
+
unit: "px",
|
|
637
|
+
defaultValue: 1,
|
|
638
|
+
category: "appearance"
|
|
639
|
+
},
|
|
640
|
+
borderBottomWidth: {
|
|
641
|
+
label: "Border Bottom Width",
|
|
642
|
+
type: "number",
|
|
643
|
+
unit: "px",
|
|
644
|
+
defaultValue: 1,
|
|
645
|
+
category: "appearance"
|
|
646
|
+
},
|
|
647
|
+
borderLeftWidth: {
|
|
648
|
+
label: "Border Left Width",
|
|
649
|
+
type: "number",
|
|
650
|
+
unit: "px",
|
|
651
|
+
defaultValue: 1,
|
|
652
|
+
category: "appearance"
|
|
653
|
+
},
|
|
654
|
+
borderStyle: {
|
|
655
|
+
label: "Border Style",
|
|
656
|
+
type: "select",
|
|
657
|
+
options: {
|
|
658
|
+
solid: "Solid",
|
|
659
|
+
dashed: "Dashed",
|
|
660
|
+
dotted: "Dotted"
|
|
661
|
+
},
|
|
662
|
+
defaultValue: "solid",
|
|
663
|
+
category: "appearance"
|
|
664
|
+
},
|
|
665
|
+
borderTopStyle: {
|
|
666
|
+
label: "Border Top Style",
|
|
667
|
+
type: "select",
|
|
668
|
+
options: {
|
|
669
|
+
solid: "Solid",
|
|
670
|
+
dashed: "Dashed",
|
|
671
|
+
dotted: "Dotted"
|
|
672
|
+
},
|
|
673
|
+
defaultValue: "solid",
|
|
674
|
+
category: "appearance"
|
|
675
|
+
},
|
|
676
|
+
borderRightStyle: {
|
|
677
|
+
label: "Border Right Style",
|
|
678
|
+
type: "select",
|
|
679
|
+
options: {
|
|
680
|
+
solid: "Solid",
|
|
681
|
+
dashed: "Dashed",
|
|
682
|
+
dotted: "Dotted"
|
|
683
|
+
},
|
|
684
|
+
defaultValue: "solid",
|
|
685
|
+
category: "appearance"
|
|
686
|
+
},
|
|
687
|
+
borderBottomStyle: {
|
|
688
|
+
label: "Border Bottom Style",
|
|
689
|
+
type: "select",
|
|
690
|
+
options: {
|
|
691
|
+
solid: "Solid",
|
|
692
|
+
dashed: "Dashed",
|
|
693
|
+
dotted: "Dotted"
|
|
694
|
+
},
|
|
695
|
+
defaultValue: "solid",
|
|
696
|
+
category: "appearance"
|
|
697
|
+
},
|
|
698
|
+
borderLeftStyle: {
|
|
699
|
+
label: "Border Left Style",
|
|
700
|
+
type: "select",
|
|
701
|
+
options: {
|
|
702
|
+
solid: "Solid",
|
|
703
|
+
dashed: "Dashed",
|
|
704
|
+
dotted: "Dotted"
|
|
705
|
+
},
|
|
706
|
+
defaultValue: "solid",
|
|
707
|
+
category: "appearance"
|
|
708
|
+
},
|
|
709
|
+
borderColor: {
|
|
710
|
+
label: "Border Color",
|
|
711
|
+
type: "color",
|
|
712
|
+
defaultValue: "#000000",
|
|
713
|
+
category: "appearance"
|
|
714
|
+
},
|
|
715
|
+
borderTopColor: {
|
|
716
|
+
label: "Border Top Color",
|
|
717
|
+
type: "color",
|
|
718
|
+
defaultValue: "#000000",
|
|
719
|
+
category: "appearance"
|
|
720
|
+
},
|
|
721
|
+
borderRightColor: {
|
|
722
|
+
label: "Border Right Color",
|
|
723
|
+
type: "color",
|
|
724
|
+
defaultValue: "#000000",
|
|
725
|
+
category: "appearance"
|
|
726
|
+
},
|
|
727
|
+
borderBottomColor: {
|
|
728
|
+
label: "Border Bottom Color",
|
|
729
|
+
type: "color",
|
|
730
|
+
defaultValue: "#000000",
|
|
731
|
+
category: "appearance"
|
|
732
|
+
},
|
|
733
|
+
borderLeftColor: {
|
|
734
|
+
label: "Border Left Color",
|
|
735
|
+
type: "color",
|
|
736
|
+
defaultValue: "#000000",
|
|
737
|
+
category: "appearance"
|
|
738
|
+
},
|
|
739
|
+
padding: {
|
|
740
|
+
label: "Padding",
|
|
741
|
+
type: "number",
|
|
742
|
+
unit: "px",
|
|
743
|
+
defaultValue: 8,
|
|
744
|
+
category: "layout"
|
|
745
|
+
},
|
|
746
|
+
paddingTop: {
|
|
747
|
+
label: "Padding Top",
|
|
748
|
+
type: "number",
|
|
749
|
+
unit: "px",
|
|
750
|
+
defaultValue: 8,
|
|
751
|
+
category: "layout"
|
|
752
|
+
},
|
|
753
|
+
paddingLeft: {
|
|
754
|
+
label: "Padding Left",
|
|
755
|
+
type: "number",
|
|
756
|
+
unit: "px",
|
|
757
|
+
defaultValue: 8,
|
|
758
|
+
category: "layout"
|
|
759
|
+
},
|
|
760
|
+
paddingBottom: {
|
|
761
|
+
label: "Padding Bottom",
|
|
762
|
+
type: "number",
|
|
763
|
+
unit: "px",
|
|
764
|
+
defaultValue: 8,
|
|
765
|
+
category: "layout"
|
|
766
|
+
},
|
|
767
|
+
paddingRight: {
|
|
768
|
+
label: "Padding Right",
|
|
769
|
+
type: "number",
|
|
770
|
+
unit: "px",
|
|
771
|
+
defaultValue: 8,
|
|
772
|
+
category: "layout"
|
|
773
|
+
},
|
|
774
|
+
width: {
|
|
775
|
+
label: "Width",
|
|
776
|
+
type: "number",
|
|
777
|
+
unit: "px",
|
|
778
|
+
defaultValue: 600,
|
|
779
|
+
category: "layout"
|
|
780
|
+
},
|
|
781
|
+
height: {
|
|
782
|
+
label: "Height",
|
|
783
|
+
type: "number",
|
|
784
|
+
unit: "px",
|
|
785
|
+
defaultValue: 400,
|
|
786
|
+
category: "layout"
|
|
787
|
+
}
|
|
788
|
+
};
|
|
468
789
|
|
|
469
790
|
//#endregion
|
|
470
791
|
//#region src/plugins/email-theming/normalization.ts
|
|
@@ -773,5 +1094,5 @@ const EmailTheming = Extension.create({
|
|
|
773
1094
|
});
|
|
774
1095
|
|
|
775
1096
|
//#endregion
|
|
776
|
-
export { EmailTheming, getMergedCssJs, getResolvedNodeStyles, getThemeComponentKey, stylesToCss, useEmailTheming };
|
|
1097
|
+
export { DEFAULT_INBOX_FONT_SIZE_PX, EDITOR_THEMES, EmailTheming, INBOX_EMAIL_DEFAULTS, RESET_THEMES, SUPPORTED_CSS_PROPERTIES, getMergedCssJs, getPanelTitle, getResolvedNodeStyles, getThemeBodyFontSizePx, getThemeComponentKey, injectGlobalPlainCss, injectThemeCss, mergeCssJs, resolveResetValue, stylesToCss, transformToCssJs, useEmailTheming };
|
|
777
1098
|
//# sourceMappingURL=index.mjs.map
|