react-tailwind-email-editor 0.0.6 → 0.0.7
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 +1 -1
- package/dist/index.d.cts +6 -57
- package/dist/index.d.ts +6 -57
- package/dist/index.js +435 -147
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +417 -132
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React10 = require('react');
|
|
4
4
|
var core = require('@craftjs/core');
|
|
5
5
|
var AccordionPrimitive = require('@radix-ui/react-accordion');
|
|
6
6
|
var lucideReact = require('lucide-react');
|
|
@@ -10,8 +10,11 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
10
10
|
var reactSlot = require('@radix-ui/react-slot');
|
|
11
11
|
var classVarianceAuthority = require('class-variance-authority');
|
|
12
12
|
var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
|
|
13
|
+
var TabsPrimitive = require('@radix-ui/react-tabs');
|
|
13
14
|
var DialogPrimitive = require('@radix-ui/react-dialog');
|
|
14
15
|
var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
|
|
16
|
+
var PopoverPrimitive = require('@radix-ui/react-popover');
|
|
17
|
+
var LabelPrimitive = require('@radix-ui/react-label');
|
|
15
18
|
|
|
16
19
|
function _interopNamespace(e) {
|
|
17
20
|
if (e && e.__esModule) return e;
|
|
@@ -31,18 +34,21 @@ function _interopNamespace(e) {
|
|
|
31
34
|
return Object.freeze(n);
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
var
|
|
37
|
+
var React10__namespace = /*#__PURE__*/_interopNamespace(React10);
|
|
35
38
|
var AccordionPrimitive__namespace = /*#__PURE__*/_interopNamespace(AccordionPrimitive);
|
|
36
39
|
var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
|
|
40
|
+
var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
|
|
37
41
|
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
|
|
38
42
|
var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
|
|
43
|
+
var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
|
|
44
|
+
var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
|
|
39
45
|
|
|
40
46
|
// src/components/editor/EmailEditor.tsx
|
|
41
47
|
function cn(...inputs) {
|
|
42
48
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
43
49
|
}
|
|
44
50
|
var Accordion = AccordionPrimitive__namespace.Root;
|
|
45
|
-
var AccordionItem =
|
|
51
|
+
var AccordionItem = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
46
52
|
AccordionPrimitive__namespace.Item,
|
|
47
53
|
{
|
|
48
54
|
ref,
|
|
@@ -51,7 +57,7 @@ var AccordionItem = React9__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
51
57
|
}
|
|
52
58
|
));
|
|
53
59
|
AccordionItem.displayName = "AccordionItem";
|
|
54
|
-
var AccordionTrigger =
|
|
60
|
+
var AccordionTrigger = React10__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Header, { className: "flex", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
55
61
|
AccordionPrimitive__namespace.Trigger,
|
|
56
62
|
{
|
|
57
63
|
ref,
|
|
@@ -67,7 +73,7 @@ var AccordionTrigger = React9__namespace.forwardRef(({ className, children, ...p
|
|
|
67
73
|
}
|
|
68
74
|
) }));
|
|
69
75
|
AccordionTrigger.displayName = AccordionPrimitive__namespace.Trigger.displayName;
|
|
70
|
-
var AccordionContent =
|
|
76
|
+
var AccordionContent = React10__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
71
77
|
AccordionPrimitive__namespace.Content,
|
|
72
78
|
{
|
|
73
79
|
ref,
|
|
@@ -82,25 +88,28 @@ var defaultTheme = {
|
|
|
82
88
|
paperMinHeight: 800,
|
|
83
89
|
paperBackground: "#ffffff"
|
|
84
90
|
};
|
|
85
|
-
var EditorContext =
|
|
91
|
+
var EditorContext = React10.createContext({
|
|
86
92
|
components: {},
|
|
87
93
|
theme: defaultTheme,
|
|
88
94
|
slots: {},
|
|
89
95
|
templates: [],
|
|
90
96
|
callbacks: {},
|
|
91
97
|
htmlRenderers: {},
|
|
92
|
-
title: "
|
|
98
|
+
title: "",
|
|
93
99
|
showToolbar: true,
|
|
94
100
|
showToolbox: true,
|
|
95
101
|
showSettingsPanel: true
|
|
96
102
|
});
|
|
97
|
-
var useEditorConfig = () =>
|
|
98
|
-
var EditorProvider = ({
|
|
99
|
-
|
|
103
|
+
var useEditorConfig = () => React10.useContext(EditorContext);
|
|
104
|
+
var EditorProvider = ({
|
|
105
|
+
children,
|
|
106
|
+
value
|
|
107
|
+
}) => {
|
|
108
|
+
const mergedTheme = React10.useMemo(
|
|
100
109
|
() => ({ ...defaultTheme, ...value.theme }),
|
|
101
110
|
[value.theme]
|
|
102
111
|
);
|
|
103
|
-
const ctx =
|
|
112
|
+
const ctx = React10.useMemo(
|
|
104
113
|
() => ({ ...value, theme: mergedTheme }),
|
|
105
114
|
[value, mergedTheme]
|
|
106
115
|
);
|
|
@@ -129,7 +138,7 @@ var ToolboxItem = ({ name, config }) => {
|
|
|
129
138
|
};
|
|
130
139
|
var Toolbox = () => {
|
|
131
140
|
const { components } = useEditorConfig();
|
|
132
|
-
const grouped =
|
|
141
|
+
const grouped = React10__namespace.default.useMemo(() => {
|
|
133
142
|
const map = {};
|
|
134
143
|
for (const [name, config] of Object.entries(components)) {
|
|
135
144
|
const cat = config.category || "Other";
|
|
@@ -139,7 +148,7 @@ var Toolbox = () => {
|
|
|
139
148
|
return map;
|
|
140
149
|
}, [components]);
|
|
141
150
|
const categoryKeys = Object.keys(grouped);
|
|
142
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-
|
|
151
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-5", children: /* @__PURE__ */ jsxRuntime.jsx(Accordion, { type: "multiple", defaultValue: categoryKeys, children: categoryKeys.map((category, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
143
152
|
AccordionItem,
|
|
144
153
|
{
|
|
145
154
|
value: category,
|
|
@@ -186,7 +195,7 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
186
195
|
}
|
|
187
196
|
}
|
|
188
197
|
);
|
|
189
|
-
var Button =
|
|
198
|
+
var Button = React10__namespace.forwardRef(
|
|
190
199
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
191
200
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
192
201
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -200,7 +209,7 @@ var Button = React9__namespace.forwardRef(
|
|
|
200
209
|
}
|
|
201
210
|
);
|
|
202
211
|
Button.displayName = "Button";
|
|
203
|
-
var ScrollArea =
|
|
212
|
+
var ScrollArea = React10__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
204
213
|
ScrollAreaPrimitive__namespace.Root,
|
|
205
214
|
{
|
|
206
215
|
ref,
|
|
@@ -214,7 +223,7 @@ var ScrollArea = React9__namespace.forwardRef(({ className, children, ...props }
|
|
|
214
223
|
}
|
|
215
224
|
));
|
|
216
225
|
ScrollArea.displayName = ScrollAreaPrimitive__namespace.Root.displayName;
|
|
217
|
-
var ScrollBar =
|
|
226
|
+
var ScrollBar = React10__namespace.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
218
227
|
ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
|
|
219
228
|
{
|
|
220
229
|
ref,
|
|
@@ -292,7 +301,7 @@ var SettingsPanel = () => {
|
|
|
292
301
|
}
|
|
293
302
|
};
|
|
294
303
|
if (slots.settingsPanel && selected) {
|
|
295
|
-
return
|
|
304
|
+
return React10__namespace.default.createElement(slots.settingsPanel, {
|
|
296
305
|
selectedId: selected.id,
|
|
297
306
|
selectedName: selected.displayName || selected.name,
|
|
298
307
|
//@ts-ignore
|
|
@@ -305,7 +314,7 @@ var SettingsPanel = () => {
|
|
|
305
314
|
}
|
|
306
315
|
if (!selected) {
|
|
307
316
|
if (slots.settingsEmptyState) {
|
|
308
|
-
return
|
|
317
|
+
return React10__namespace.default.createElement(slots.settingsEmptyState);
|
|
309
318
|
}
|
|
310
319
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-6 text-center", children: [
|
|
311
320
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-16 h-16 mx-auto mb-4 rounded-full bg-muted flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Layers, { className: "h-8 w-8 text-muted-foreground" }) }),
|
|
@@ -380,7 +389,7 @@ var SettingsPanel = () => {
|
|
|
380
389
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings2, { className: "h-4 w-4 text-muted-foreground" }),
|
|
381
390
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Properties" })
|
|
382
391
|
] }) }),
|
|
383
|
-
/* @__PURE__ */ jsxRuntime.jsx(AccordionContent, { className: "pb-4", children:
|
|
392
|
+
/* @__PURE__ */ jsxRuntime.jsx(AccordionContent, { className: "pb-4", children: React10__namespace.default.createElement(selected.settings) })
|
|
384
393
|
] }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center text-muted-foreground text-sm py-8", children: [
|
|
385
394
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Paintbrush, { className: "h-8 w-8 mx-auto mb-2 opacity-50" }),
|
|
386
395
|
/* @__PURE__ */ jsxRuntime.jsx("p", { children: "No editable properties" })
|
|
@@ -460,7 +469,7 @@ var RenderNode = ({ render }) => {
|
|
|
460
469
|
deletable: query.node(node.id).isDeletable(),
|
|
461
470
|
parent: node.data.parent
|
|
462
471
|
}));
|
|
463
|
-
|
|
472
|
+
React10.useEffect(() => {
|
|
464
473
|
if (dom) {
|
|
465
474
|
if (isActive || isHover) {
|
|
466
475
|
dom.classList.add("component-selected");
|
|
@@ -469,19 +478,19 @@ var RenderNode = ({ render }) => {
|
|
|
469
478
|
}
|
|
470
479
|
}
|
|
471
480
|
}, [dom, isActive, isHover]);
|
|
472
|
-
const getPos =
|
|
481
|
+
const getPos = React10.useCallback((dom2) => {
|
|
473
482
|
const { top, left, bottom } = dom2 ? dom2.getBoundingClientRect() : { top: 0, left: 0, bottom: 0 };
|
|
474
483
|
return {
|
|
475
484
|
top: `${top > 0 ? top : bottom}px`,
|
|
476
485
|
left: `${left}px`
|
|
477
486
|
};
|
|
478
487
|
}, []);
|
|
479
|
-
const scroll =
|
|
488
|
+
const scroll = React10.useCallback(() => {
|
|
480
489
|
const currentDOM = dom;
|
|
481
490
|
if (!currentDOM) return;
|
|
482
491
|
const { top, left } = getPos(currentDOM);
|
|
483
492
|
}, [dom, getPos]);
|
|
484
|
-
|
|
493
|
+
React10.useEffect(() => {
|
|
485
494
|
var _a;
|
|
486
495
|
(_a = document.querySelector(".craftjs-renderer")) == null ? void 0 : _a.addEventListener("scroll", scroll);
|
|
487
496
|
return () => {
|
|
@@ -4112,9 +4121,46 @@ ${childrenHtml}
|
|
|
4112
4121
|
};
|
|
4113
4122
|
return renderNode("ROOT");
|
|
4114
4123
|
};
|
|
4124
|
+
var Tabs = TabsPrimitive__namespace.Root;
|
|
4125
|
+
var TabsList = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4126
|
+
TabsPrimitive__namespace.List,
|
|
4127
|
+
{
|
|
4128
|
+
ref,
|
|
4129
|
+
className: cn(
|
|
4130
|
+
"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
|
|
4131
|
+
className
|
|
4132
|
+
),
|
|
4133
|
+
...props
|
|
4134
|
+
}
|
|
4135
|
+
));
|
|
4136
|
+
TabsList.displayName = TabsPrimitive__namespace.List.displayName;
|
|
4137
|
+
var TabsTrigger = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4138
|
+
TabsPrimitive__namespace.Trigger,
|
|
4139
|
+
{
|
|
4140
|
+
ref,
|
|
4141
|
+
className: cn(
|
|
4142
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
4143
|
+
className
|
|
4144
|
+
),
|
|
4145
|
+
...props
|
|
4146
|
+
}
|
|
4147
|
+
));
|
|
4148
|
+
TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
|
|
4149
|
+
var TabsContent = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4150
|
+
TabsPrimitive__namespace.Content,
|
|
4151
|
+
{
|
|
4152
|
+
ref,
|
|
4153
|
+
className: cn(
|
|
4154
|
+
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
4155
|
+
className
|
|
4156
|
+
),
|
|
4157
|
+
...props
|
|
4158
|
+
}
|
|
4159
|
+
));
|
|
4160
|
+
TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
|
|
4115
4161
|
var Dialog = DialogPrimitive__namespace.Root;
|
|
4116
4162
|
var DialogPortal = DialogPrimitive__namespace.Portal;
|
|
4117
|
-
var DialogOverlay =
|
|
4163
|
+
var DialogOverlay = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4118
4164
|
DialogPrimitive__namespace.Overlay,
|
|
4119
4165
|
{
|
|
4120
4166
|
ref,
|
|
@@ -4126,7 +4172,7 @@ var DialogOverlay = React9__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
4126
4172
|
}
|
|
4127
4173
|
));
|
|
4128
4174
|
DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
|
|
4129
|
-
var DialogContent =
|
|
4175
|
+
var DialogContent = React10__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
|
|
4130
4176
|
/* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
|
|
4131
4177
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4132
4178
|
DialogPrimitive__namespace.Content,
|
|
@@ -4162,7 +4208,7 @@ var DialogHeader = ({
|
|
|
4162
4208
|
}
|
|
4163
4209
|
);
|
|
4164
4210
|
DialogHeader.displayName = "DialogHeader";
|
|
4165
|
-
var DialogTitle =
|
|
4211
|
+
var DialogTitle = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4166
4212
|
DialogPrimitive__namespace.Title,
|
|
4167
4213
|
{
|
|
4168
4214
|
ref,
|
|
@@ -4174,7 +4220,7 @@ var DialogTitle = React9__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
4174
4220
|
}
|
|
4175
4221
|
));
|
|
4176
4222
|
DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
|
|
4177
|
-
var DialogDescription =
|
|
4223
|
+
var DialogDescription = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4178
4224
|
DialogPrimitive__namespace.Description,
|
|
4179
4225
|
{
|
|
4180
4226
|
ref,
|
|
@@ -4185,7 +4231,7 @@ var DialogDescription = React9__namespace.forwardRef(({ className, ...props }, r
|
|
|
4185
4231
|
DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
|
|
4186
4232
|
var DropdownMenu = DropdownMenuPrimitive__namespace.Root;
|
|
4187
4233
|
var DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
|
|
4188
|
-
var DropdownMenuSubTrigger =
|
|
4234
|
+
var DropdownMenuSubTrigger = React10__namespace.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4189
4235
|
DropdownMenuPrimitive__namespace.SubTrigger,
|
|
4190
4236
|
{
|
|
4191
4237
|
ref,
|
|
@@ -4202,7 +4248,7 @@ var DropdownMenuSubTrigger = React9__namespace.forwardRef(({ className, inset, c
|
|
|
4202
4248
|
}
|
|
4203
4249
|
));
|
|
4204
4250
|
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive__namespace.SubTrigger.displayName;
|
|
4205
|
-
var DropdownMenuSubContent =
|
|
4251
|
+
var DropdownMenuSubContent = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4206
4252
|
DropdownMenuPrimitive__namespace.SubContent,
|
|
4207
4253
|
{
|
|
4208
4254
|
ref,
|
|
@@ -4214,7 +4260,7 @@ var DropdownMenuSubContent = React9__namespace.forwardRef(({ className, ...props
|
|
|
4214
4260
|
}
|
|
4215
4261
|
));
|
|
4216
4262
|
DropdownMenuSubContent.displayName = DropdownMenuPrimitive__namespace.SubContent.displayName;
|
|
4217
|
-
var DropdownMenuContent =
|
|
4263
|
+
var DropdownMenuContent = React10__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4218
4264
|
DropdownMenuPrimitive__namespace.Content,
|
|
4219
4265
|
{
|
|
4220
4266
|
ref,
|
|
@@ -4227,7 +4273,7 @@ var DropdownMenuContent = React9__namespace.forwardRef(({ className, sideOffset
|
|
|
4227
4273
|
}
|
|
4228
4274
|
) }));
|
|
4229
4275
|
DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
|
|
4230
|
-
var DropdownMenuItem =
|
|
4276
|
+
var DropdownMenuItem = React10__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4231
4277
|
DropdownMenuPrimitive__namespace.Item,
|
|
4232
4278
|
{
|
|
4233
4279
|
ref,
|
|
@@ -4240,7 +4286,7 @@ var DropdownMenuItem = React9__namespace.forwardRef(({ className, inset, ...prop
|
|
|
4240
4286
|
}
|
|
4241
4287
|
));
|
|
4242
4288
|
DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
|
|
4243
|
-
var DropdownMenuCheckboxItem =
|
|
4289
|
+
var DropdownMenuCheckboxItem = React10__namespace.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4244
4290
|
DropdownMenuPrimitive__namespace.CheckboxItem,
|
|
4245
4291
|
{
|
|
4246
4292
|
ref,
|
|
@@ -4257,7 +4303,7 @@ var DropdownMenuCheckboxItem = React9__namespace.forwardRef(({ className, childr
|
|
|
4257
4303
|
}
|
|
4258
4304
|
));
|
|
4259
4305
|
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
|
|
4260
|
-
var DropdownMenuRadioItem =
|
|
4306
|
+
var DropdownMenuRadioItem = React10__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4261
4307
|
DropdownMenuPrimitive__namespace.RadioItem,
|
|
4262
4308
|
{
|
|
4263
4309
|
ref,
|
|
@@ -4273,7 +4319,7 @@ var DropdownMenuRadioItem = React9__namespace.forwardRef(({ className, children,
|
|
|
4273
4319
|
}
|
|
4274
4320
|
));
|
|
4275
4321
|
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
|
|
4276
|
-
var DropdownMenuLabel =
|
|
4322
|
+
var DropdownMenuLabel = React10__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4277
4323
|
DropdownMenuPrimitive__namespace.Label,
|
|
4278
4324
|
{
|
|
4279
4325
|
ref,
|
|
@@ -4286,7 +4332,7 @@ var DropdownMenuLabel = React9__namespace.forwardRef(({ className, inset, ...pro
|
|
|
4286
4332
|
}
|
|
4287
4333
|
));
|
|
4288
4334
|
DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
|
|
4289
|
-
var DropdownMenuSeparator =
|
|
4335
|
+
var DropdownMenuSeparator = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4290
4336
|
DropdownMenuPrimitive__namespace.Separator,
|
|
4291
4337
|
{
|
|
4292
4338
|
ref,
|
|
@@ -4295,20 +4341,145 @@ var DropdownMenuSeparator = React9__namespace.forwardRef(({ className, ...props
|
|
|
4295
4341
|
}
|
|
4296
4342
|
));
|
|
4297
4343
|
DropdownMenuSeparator.displayName = DropdownMenuPrimitive__namespace.Separator.displayName;
|
|
4298
|
-
var
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4344
|
+
var Popover = PopoverPrimitive__namespace.Root;
|
|
4345
|
+
var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
|
|
4346
|
+
var PopoverContent = React10__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4347
|
+
PopoverPrimitive__namespace.Content,
|
|
4348
|
+
{
|
|
4349
|
+
ref,
|
|
4350
|
+
align,
|
|
4351
|
+
sideOffset,
|
|
4352
|
+
className: cn(
|
|
4353
|
+
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
4354
|
+
className
|
|
4355
|
+
),
|
|
4356
|
+
...props
|
|
4357
|
+
}
|
|
4358
|
+
) }));
|
|
4359
|
+
PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
|
|
4360
|
+
var labelVariants = classVarianceAuthority.cva(
|
|
4361
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
4362
|
+
);
|
|
4363
|
+
var Label2 = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4364
|
+
LabelPrimitive__namespace.Root,
|
|
4365
|
+
{
|
|
4366
|
+
ref,
|
|
4367
|
+
className: cn(labelVariants(), className),
|
|
4368
|
+
...props
|
|
4369
|
+
}
|
|
4370
|
+
));
|
|
4371
|
+
Label2.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
4372
|
+
var COLOR_PRESETS = [
|
|
4373
|
+
{ name: "Blue", hsl: "222.2 47.4% 11.2%" },
|
|
4374
|
+
{ name: "Indigo", hsl: "243 75% 59%" },
|
|
4375
|
+
{ name: "Emerald", hsl: "160 84% 39%" },
|
|
4376
|
+
{ name: "Rose", hsl: "346 77% 50%" },
|
|
4377
|
+
{ name: "Amber", hsl: "32 95% 44%" },
|
|
4378
|
+
{ name: "Violet", hsl: "263 70% 50%" },
|
|
4379
|
+
{ name: "Cyan", hsl: "192 91% 36%" },
|
|
4380
|
+
{ name: "Slate", hsl: "215 20% 35%" }
|
|
4381
|
+
];
|
|
4382
|
+
var ColorCustomizer = ({ value, onColorChange }) => {
|
|
4383
|
+
const [customColor, setCustomColor] = React10.useState("#1e293b");
|
|
4384
|
+
const applyColor = (hsl) => {
|
|
4385
|
+
onColorChange(hsl);
|
|
4386
|
+
};
|
|
4387
|
+
const hexToHsl = (hex) => {
|
|
4388
|
+
const r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
4389
|
+
const g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
4390
|
+
const b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
4391
|
+
const max = Math.max(r, g, b);
|
|
4392
|
+
const min = Math.min(r, g, b);
|
|
4393
|
+
let h = 0;
|
|
4394
|
+
let s = 0;
|
|
4395
|
+
const l = (max + min) / 2;
|
|
4396
|
+
if (max !== min) {
|
|
4397
|
+
const d = max - min;
|
|
4398
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
4399
|
+
switch (max) {
|
|
4400
|
+
case r:
|
|
4401
|
+
h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
4402
|
+
break;
|
|
4403
|
+
case g:
|
|
4404
|
+
h = ((b - r) / d + 2) / 6;
|
|
4405
|
+
break;
|
|
4406
|
+
case b:
|
|
4407
|
+
h = ((r - g) / d + 4) / 6;
|
|
4408
|
+
break;
|
|
4409
|
+
}
|
|
4410
|
+
}
|
|
4411
|
+
return `${Math.round(h * 360)} ${Math.round(s * 100)}% ${Math.round(l * 100)}%`;
|
|
4412
|
+
};
|
|
4413
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { children: [
|
|
4414
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outline", size: "sm", className: "gap-2 h-8 text-xs", children: [
|
|
4415
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Paintbrush, { className: "h-3.5 w-3.5" }),
|
|
4416
|
+
"Primary"
|
|
4417
|
+
] }) }),
|
|
4418
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-64", align: "end", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
4419
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label2, { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Primary Color" }),
|
|
4420
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-4 gap-2", children: COLOR_PRESETS.map((preset) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4421
|
+
"button",
|
|
4422
|
+
{
|
|
4423
|
+
type: "button",
|
|
4424
|
+
onClick: () => applyColor(preset.hsl),
|
|
4425
|
+
className: "group flex flex-col items-center gap-1",
|
|
4426
|
+
title: preset.name,
|
|
4427
|
+
children: [
|
|
4428
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4429
|
+
"div",
|
|
4430
|
+
{
|
|
4431
|
+
className: "w-8 h-8 rounded-full border-2 transition-all shadow-sm",
|
|
4432
|
+
style: {
|
|
4433
|
+
backgroundColor: `hsl(${preset.hsl})`,
|
|
4434
|
+
borderColor: value === preset.hsl ? "hsl(var(--foreground))" : "transparent"
|
|
4435
|
+
}
|
|
4436
|
+
}
|
|
4437
|
+
),
|
|
4438
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: preset.name })
|
|
4439
|
+
]
|
|
4440
|
+
},
|
|
4441
|
+
preset.name
|
|
4442
|
+
)) }),
|
|
4443
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-2 border-t border-border", children: [
|
|
4444
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label2, { className: "text-xs text-muted-foreground mb-1.5 block", children: "Custom Color" }),
|
|
4445
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 items-center", children: [
|
|
4446
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4447
|
+
"input",
|
|
4448
|
+
{
|
|
4449
|
+
type: "color",
|
|
4450
|
+
value: customColor,
|
|
4451
|
+
onChange: (e) => {
|
|
4452
|
+
setCustomColor(e.target.value);
|
|
4453
|
+
applyColor(hexToHsl(e.target.value));
|
|
4454
|
+
},
|
|
4455
|
+
className: "w-10 h-8 rounded border border-border cursor-pointer bg-background"
|
|
4456
|
+
}
|
|
4457
|
+
),
|
|
4458
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground font-mono", children: customColor })
|
|
4459
|
+
] })
|
|
4460
|
+
] })
|
|
4461
|
+
] }) })
|
|
4462
|
+
] });
|
|
4463
|
+
};
|
|
4464
|
+
var TopBar = ({
|
|
4465
|
+
isDarkMode,
|
|
4466
|
+
onToggleDarkMode,
|
|
4467
|
+
primaryColor,
|
|
4468
|
+
onPrimaryColorChange
|
|
4469
|
+
}) => {
|
|
4470
|
+
const { actions, query, canUndo, canRedo } = core.useEditor((state, queryCtx) => ({
|
|
4471
|
+
canUndo: state.options.enabled && queryCtx.history.canUndo(),
|
|
4472
|
+
canRedo: state.options.enabled && queryCtx.history.canRedo()
|
|
4302
4473
|
}));
|
|
4303
4474
|
const { title, logo, templates, callbacks, slots, htmlRenderers } = useEditorConfig();
|
|
4304
|
-
const [showCode, setShowCode] =
|
|
4305
|
-
const [showPreview, setShowPreview] =
|
|
4306
|
-
const [copied, setCopied] =
|
|
4307
|
-
const [htmlCode, setHtmlCode] =
|
|
4308
|
-
const [previewDevice, setPreviewDevice] =
|
|
4475
|
+
const [showCode, setShowCode] = React10.useState(false);
|
|
4476
|
+
const [showPreview, setShowPreview] = React10.useState(false);
|
|
4477
|
+
const [copied, setCopied] = React10.useState(false);
|
|
4478
|
+
const [htmlCode, setHtmlCode] = React10.useState("");
|
|
4479
|
+
const [previewDevice, setPreviewDevice] = React10.useState(
|
|
4309
4480
|
"desktop"
|
|
4310
4481
|
);
|
|
4311
|
-
const getHtml =
|
|
4482
|
+
const getHtml = React10.useCallback(() => {
|
|
4312
4483
|
const json = query.serialize();
|
|
4313
4484
|
const nodes = JSON.parse(json);
|
|
4314
4485
|
return generateEmailHtml(nodes, htmlRenderers);
|
|
@@ -4368,7 +4539,7 @@ var TopBar = () => {
|
|
|
4368
4539
|
}
|
|
4369
4540
|
};
|
|
4370
4541
|
if (slots.toolbar) {
|
|
4371
|
-
return
|
|
4542
|
+
return React10__namespace.default.createElement(slots.toolbar, {
|
|
4372
4543
|
onExport: getHtml,
|
|
4373
4544
|
onPreview: getHtml,
|
|
4374
4545
|
onClear: handleClearCanvas,
|
|
@@ -4377,21 +4548,23 @@ var TopBar = () => {
|
|
|
4377
4548
|
});
|
|
4378
4549
|
}
|
|
4379
4550
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4380
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-
|
|
4381
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-
|
|
4382
|
-
/* @__PURE__ */ jsxRuntime.
|
|
4383
|
-
|
|
4384
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4385
|
-
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-sm font-bold leading-tight", children: title }),
|
|
4386
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[10px] text-muted-foreground", children: "Drag & Drop Builder" })
|
|
4387
|
-
] })
|
|
4388
|
-
] }),
|
|
4389
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-6 w-px bg-border" }),
|
|
4551
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-2.5 border-b border-border bg-background", children: [
|
|
4552
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
4553
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-sm font-semibold text-foreground", children: title }) }),
|
|
4554
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-5 w-px bg-border" }),
|
|
4390
4555
|
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
|
|
4391
|
-
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4556
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4557
|
+
Button,
|
|
4558
|
+
{
|
|
4559
|
+
variant: "outline",
|
|
4560
|
+
size: "sm",
|
|
4561
|
+
className: "gap-1.5 h-8 text-xs",
|
|
4562
|
+
children: [
|
|
4563
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.LayoutTemplate, { className: "h-3.5 w-3.5" }),
|
|
4564
|
+
"Templates"
|
|
4565
|
+
]
|
|
4566
|
+
}
|
|
4567
|
+
) }),
|
|
4395
4568
|
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuContent, { align: "start", className: "w-56", children: [
|
|
4396
4569
|
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { children: "Quick Start Templates" }),
|
|
4397
4570
|
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
|
|
@@ -4401,7 +4574,7 @@ var TopBar = () => {
|
|
|
4401
4574
|
className: "gap-2",
|
|
4402
4575
|
onClick: () => handleLoadTemplate(template),
|
|
4403
4576
|
children: [
|
|
4404
|
-
template.icon &&
|
|
4577
|
+
template.icon && React10__namespace.default.createElement(template.icon, {
|
|
4405
4578
|
className: "h-4 w-4 text-muted-foreground"
|
|
4406
4579
|
}),
|
|
4407
4580
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
@@ -4424,8 +4597,28 @@ var TopBar = () => {
|
|
|
4424
4597
|
] })
|
|
4425
4598
|
] })
|
|
4426
4599
|
] }),
|
|
4427
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-
|
|
4428
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4600
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
4601
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4602
|
+
Button,
|
|
4603
|
+
{
|
|
4604
|
+
variant: "outline",
|
|
4605
|
+
size: "sm",
|
|
4606
|
+
onClick: onToggleDarkMode,
|
|
4607
|
+
className: "gap-1.5 h-8 text-xs",
|
|
4608
|
+
children: [
|
|
4609
|
+
isDarkMode ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Sun, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Moon, { className: "h-3.5 w-3.5" }),
|
|
4610
|
+
isDarkMode ? "Light" : "Dark"
|
|
4611
|
+
]
|
|
4612
|
+
}
|
|
4613
|
+
),
|
|
4614
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4615
|
+
ColorCustomizer,
|
|
4616
|
+
{
|
|
4617
|
+
value: primaryColor,
|
|
4618
|
+
onColorChange: onPrimaryColorChange
|
|
4619
|
+
}
|
|
4620
|
+
),
|
|
4621
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-0.5 bg-muted rounded-md p-0.5", children: [
|
|
4429
4622
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4430
4623
|
Button,
|
|
4431
4624
|
{
|
|
@@ -4433,9 +4626,9 @@ var TopBar = () => {
|
|
|
4433
4626
|
size: "sm",
|
|
4434
4627
|
disabled: !canUndo,
|
|
4435
4628
|
onClick: () => actions.history.undo(),
|
|
4436
|
-
className: "h-
|
|
4629
|
+
className: "h-7 w-7 p-0",
|
|
4437
4630
|
title: "Undo",
|
|
4438
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { className: "h-
|
|
4631
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { className: "h-3.5 w-3.5" })
|
|
4439
4632
|
}
|
|
4440
4633
|
),
|
|
4441
4634
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4445,22 +4638,21 @@ var TopBar = () => {
|
|
|
4445
4638
|
size: "sm",
|
|
4446
4639
|
disabled: !canRedo,
|
|
4447
4640
|
onClick: () => actions.history.redo(),
|
|
4448
|
-
className: "h-
|
|
4641
|
+
className: "h-7 w-7 p-0",
|
|
4449
4642
|
title: "Redo",
|
|
4450
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { className: "h-
|
|
4643
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { className: "h-3.5 w-3.5" })
|
|
4451
4644
|
}
|
|
4452
4645
|
)
|
|
4453
4646
|
] }),
|
|
4454
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-px h-6 bg-border" }),
|
|
4455
4647
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4456
4648
|
Button,
|
|
4457
4649
|
{
|
|
4458
4650
|
variant: "outline",
|
|
4459
4651
|
size: "sm",
|
|
4460
4652
|
onClick: handlePreview,
|
|
4461
|
-
className: "gap-
|
|
4653
|
+
className: "gap-1.5 h-8 text-xs",
|
|
4462
4654
|
children: [
|
|
4463
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: "h-
|
|
4655
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: "h-3.5 w-3.5" }),
|
|
4464
4656
|
" Preview"
|
|
4465
4657
|
]
|
|
4466
4658
|
}
|
|
@@ -4468,13 +4660,12 @@ var TopBar = () => {
|
|
|
4468
4660
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4469
4661
|
Button,
|
|
4470
4662
|
{
|
|
4471
|
-
variant: "default",
|
|
4472
4663
|
size: "sm",
|
|
4473
4664
|
onClick: handleExport,
|
|
4474
|
-
className: "gap-
|
|
4665
|
+
className: "gap-1.5 h-8 text-xs",
|
|
4475
4666
|
children: [
|
|
4476
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Code, { className: "h-
|
|
4477
|
-
" Export
|
|
4667
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Code, { className: "h-3.5 w-3.5" }),
|
|
4668
|
+
" Export"
|
|
4478
4669
|
]
|
|
4479
4670
|
}
|
|
4480
4671
|
)
|
|
@@ -4485,7 +4676,7 @@ var TopBar = () => {
|
|
|
4485
4676
|
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Export HTML" }),
|
|
4486
4677
|
/* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { children: "Copy this HTML code to use in your email client or system." })
|
|
4487
4678
|
] }),
|
|
4488
|
-
slots.exportDialog ?
|
|
4679
|
+
slots.exportDialog ? React10__namespace.default.createElement(slots.exportDialog, {
|
|
4489
4680
|
html: htmlCode,
|
|
4490
4681
|
onClose: () => setShowCode(false)
|
|
4491
4682
|
}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -4504,53 +4695,98 @@ var TopBar = () => {
|
|
|
4504
4695
|
] }) }),
|
|
4505
4696
|
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: showPreview, onOpenChange: setShowPreview, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "max-w-5xl max-h-[90vh]", children: [
|
|
4506
4697
|
/* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
|
|
4507
|
-
/* @__PURE__ */ jsxRuntime.
|
|
4508
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Email Preview" }),
|
|
4509
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-1 bg-muted rounded-lg p-1" })
|
|
4510
|
-
] }),
|
|
4698
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Email Preview" }) }),
|
|
4511
4699
|
/* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { children: "Preview how your email will look in email clients." })
|
|
4512
4700
|
] }),
|
|
4513
|
-
slots.previewDialog ?
|
|
4701
|
+
slots.previewDialog ? React10__namespace.default.createElement(slots.previewDialog, {
|
|
4514
4702
|
html: htmlCode,
|
|
4515
4703
|
onClose: () => setShowPreview(false)
|
|
4516
4704
|
}) : /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "h-[600px]", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4517
4705
|
"div",
|
|
4518
4706
|
{
|
|
4519
4707
|
className: `mx-auto transition-all duration-300 ${previewDevice === "mobile" ? "max-w-[375px]" : "max-w-full"}`,
|
|
4520
|
-
children: /* @__PURE__ */ jsxRuntime.
|
|
4521
|
-
"
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4708
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border rounded-lg bg-muted/30 overflow-hidden", children: [
|
|
4709
|
+
previewDevice === "mobile" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-6 bg-muted flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-16 h-1 bg-muted-foreground/30 rounded-full" }) }),
|
|
4710
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4711
|
+
"iframe",
|
|
4712
|
+
{
|
|
4713
|
+
srcDoc: htmlCode,
|
|
4714
|
+
className: "w-full min-h-[500px] bg-white",
|
|
4715
|
+
title: "Email Preview",
|
|
4716
|
+
style: {
|
|
4717
|
+
height: previewDevice === "mobile" ? "667px" : "600px"
|
|
4718
|
+
}
|
|
4528
4719
|
}
|
|
4529
|
-
|
|
4530
|
-
|
|
4720
|
+
)
|
|
4721
|
+
] })
|
|
4531
4722
|
}
|
|
4532
4723
|
) })
|
|
4533
4724
|
] }) })
|
|
4534
4725
|
] });
|
|
4535
4726
|
};
|
|
4536
|
-
var
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
]
|
|
4727
|
+
var LeftSidebar = ({ setActiveTab, activeTab }) => {
|
|
4728
|
+
const { components, slots } = useEditorConfig();
|
|
4729
|
+
const { selectedNodeId } = core.useEditor((state) => ({
|
|
4730
|
+
//@ts-ignore
|
|
4731
|
+
selectedNodeId: state.events.selected[0]
|
|
4732
|
+
}));
|
|
4733
|
+
React10.useEffect(() => {
|
|
4734
|
+
if (selectedNodeId) {
|
|
4735
|
+
setActiveTab("properties");
|
|
4736
|
+
}
|
|
4737
|
+
}, [selectedNodeId]);
|
|
4738
|
+
const categories = React10.useMemo(() => {
|
|
4739
|
+
return Object.keys(components).reduce((acc, k) => {
|
|
4740
|
+
const cat = components[k].category || "Other";
|
|
4741
|
+
if (!acc.includes(cat)) acc.push(cat);
|
|
4742
|
+
return acc;
|
|
4743
|
+
}, []);
|
|
4744
|
+
}, [components]);
|
|
4745
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full flex flex-col bg-background border-r border-border", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4746
|
+
Tabs,
|
|
4747
|
+
{
|
|
4748
|
+
value: activeTab,
|
|
4749
|
+
onValueChange: (value) => setActiveTab(value),
|
|
4750
|
+
className: "flex-1 flex flex-col",
|
|
4751
|
+
children: [
|
|
4752
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 pt-2 border-b border-border", children: /* @__PURE__ */ jsxRuntime.jsxs(TabsList, { className: "w-full h-9 bg-muted/50", children: [
|
|
4753
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4754
|
+
TabsTrigger,
|
|
4755
|
+
{
|
|
4756
|
+
value: "components",
|
|
4757
|
+
className: "flex-1 gap-1.5 text-xs data-[state=active]:bg-background",
|
|
4758
|
+
children: [
|
|
4759
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Layers, { className: "h-3.5 w-3.5" }),
|
|
4760
|
+
"Components"
|
|
4761
|
+
]
|
|
4762
|
+
}
|
|
4763
|
+
),
|
|
4764
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4765
|
+
TabsTrigger,
|
|
4766
|
+
{
|
|
4767
|
+
value: "properties",
|
|
4768
|
+
className: "flex-1 gap-1.5 text-xs data-[state=active]:bg-background",
|
|
4769
|
+
children: [
|
|
4770
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "h-3.5 w-3.5" }),
|
|
4771
|
+
"Properties"
|
|
4772
|
+
]
|
|
4773
|
+
}
|
|
4774
|
+
)
|
|
4775
|
+
] }) }),
|
|
4776
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "components", className: "flex-1 mt-0 ", children: /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "h-full max-h-[180vh] ", children: slots.toolbox ? React10__namespace.default.createElement(slots.toolbox, { components, categories }) : /* @__PURE__ */ jsxRuntime.jsx(Toolbox, {}) }) }),
|
|
4777
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "properties", className: "flex-1 mt-0 ", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full", children: /* @__PURE__ */ jsxRuntime.jsx(SettingsPanel, {}) }) })
|
|
4778
|
+
]
|
|
4779
|
+
}
|
|
4780
|
+
) });
|
|
4781
|
+
};
|
|
4782
|
+
var defaultEmailContent = /* @__PURE__ */ jsxRuntime.jsx(core.Element, { is: Paper, canvas: true });
|
|
4783
|
+
var getReadablePrimaryForeground = (primaryHsl) => {
|
|
4784
|
+
var _a;
|
|
4785
|
+
const lightness = Number.parseFloat(
|
|
4786
|
+
((_a = primaryHsl.trim().split(/\s+/)[2]) == null ? void 0 : _a.replace("%", "")) || "50"
|
|
4787
|
+
);
|
|
4788
|
+
return lightness > 60 ? "222.2 47.4% 11.2%" : "210 40% 98%";
|
|
4789
|
+
};
|
|
4554
4790
|
var EmailEditor = ({
|
|
4555
4791
|
components: userComponents,
|
|
4556
4792
|
replaceBuiltins = false,
|
|
@@ -4565,20 +4801,69 @@ var EmailEditor = ({
|
|
|
4565
4801
|
htmlRenderers = {},
|
|
4566
4802
|
showToolbar = true,
|
|
4567
4803
|
showToolbox = true,
|
|
4568
|
-
|
|
4804
|
+
darkMode = true,
|
|
4569
4805
|
className,
|
|
4570
4806
|
style
|
|
4571
4807
|
}) => {
|
|
4572
|
-
|
|
4808
|
+
var _a, _b, _c, _d;
|
|
4809
|
+
const mergedComponents = React10.useMemo(() => {
|
|
4573
4810
|
if (replaceBuiltins) return userComponents || {};
|
|
4574
4811
|
return { ...DEFAULT_COMPONENTS, ...userComponents || {} };
|
|
4575
4812
|
}, [userComponents, replaceBuiltins]);
|
|
4576
|
-
const
|
|
4813
|
+
const [activeTab, setActiveTab] = React10.useState(
|
|
4814
|
+
"components"
|
|
4815
|
+
);
|
|
4816
|
+
const resolver = React10.useMemo(() => {
|
|
4577
4817
|
const res = buildResolver(mergedComponents);
|
|
4578
4818
|
res.Paper = Paper;
|
|
4579
4819
|
return res;
|
|
4580
4820
|
}, [mergedComponents]);
|
|
4581
4821
|
const renderNodeFn = slots.renderNode || RenderNode;
|
|
4822
|
+
const [isDarkMode, setIsDarkMode] = React10.useState(!darkMode);
|
|
4823
|
+
const [primaryColor, setPrimaryColor] = React10.useState(
|
|
4824
|
+
(_a = theme.colors) == null ? void 0 : _a.primary
|
|
4825
|
+
);
|
|
4826
|
+
React10.useEffect(() => {
|
|
4827
|
+
var _a2;
|
|
4828
|
+
setPrimaryColor((_a2 = theme.colors) == null ? void 0 : _a2.primary);
|
|
4829
|
+
}, [(_b = theme.colors) == null ? void 0 : _b.primary]);
|
|
4830
|
+
const primaryForeground = React10.useMemo(() => {
|
|
4831
|
+
var _a2;
|
|
4832
|
+
if ((_a2 = theme.colors) == null ? void 0 : _a2.primaryForeground) return theme.colors.primaryForeground;
|
|
4833
|
+
if (!primaryColor) return void 0;
|
|
4834
|
+
return getReadablePrimaryForeground(primaryColor);
|
|
4835
|
+
}, [primaryColor, (_c = theme.colors) == null ? void 0 : _c.primaryForeground]);
|
|
4836
|
+
const themeColorVars = React10.useMemo(() => {
|
|
4837
|
+
const colors = theme.colors || {};
|
|
4838
|
+
return {
|
|
4839
|
+
background: colors.background,
|
|
4840
|
+
foreground: colors.foreground,
|
|
4841
|
+
border: colors.border,
|
|
4842
|
+
muted: colors.muted,
|
|
4843
|
+
"muted-foreground": colors.mutedForeground,
|
|
4844
|
+
destructive: colors.destructive,
|
|
4845
|
+
"panel-background": colors.panelBackground,
|
|
4846
|
+
"canvas-background": colors.canvasBackground
|
|
4847
|
+
};
|
|
4848
|
+
}, [theme.colors]);
|
|
4849
|
+
const editorStyle = React10.useMemo(() => {
|
|
4850
|
+
const cssVars = { ...style || {} };
|
|
4851
|
+
Object.entries(themeColorVars).forEach(([token, value]) => {
|
|
4852
|
+
if (value) cssVars[`--${token}`] = value;
|
|
4853
|
+
});
|
|
4854
|
+
if (primaryColor) cssVars["--primary"] = primaryColor;
|
|
4855
|
+
if (primaryForeground) cssVars["--primary-foreground"] = primaryForeground;
|
|
4856
|
+
if (theme.borderRadius) cssVars["--radius"] = `${theme.borderRadius}px`;
|
|
4857
|
+
if (theme.fontFamily) cssVars.fontFamily = theme.fontFamily;
|
|
4858
|
+
return cssVars;
|
|
4859
|
+
}, [
|
|
4860
|
+
style,
|
|
4861
|
+
themeColorVars,
|
|
4862
|
+
primaryColor,
|
|
4863
|
+
primaryForeground,
|
|
4864
|
+
theme.borderRadius,
|
|
4865
|
+
theme.fontFamily
|
|
4866
|
+
]);
|
|
4582
4867
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4583
4868
|
EditorProvider,
|
|
4584
4869
|
{
|
|
@@ -4593,51 +4878,54 @@ var EmailEditor = ({
|
|
|
4593
4878
|
logo,
|
|
4594
4879
|
showToolbar,
|
|
4595
4880
|
showToolbox,
|
|
4596
|
-
showSettingsPanel
|
|
4881
|
+
showSettingsPanel: false
|
|
4597
4882
|
},
|
|
4598
4883
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4599
4884
|
"div",
|
|
4600
4885
|
{
|
|
4601
|
-
className: `h-screen flex flex-col bg-
|
|
4602
|
-
style,
|
|
4886
|
+
className: `h-screen flex flex-col ${isDarkMode ? "dark" : ""} bg-background text-foreground ${className || ""}`,
|
|
4887
|
+
style: editorStyle,
|
|
4603
4888
|
children: /* @__PURE__ */ jsxRuntime.jsxs(core.Editor, { resolver, onRender: renderNodeFn, children: [
|
|
4604
|
-
showToolbar && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4889
|
+
showToolbar && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4890
|
+
TopBar,
|
|
4891
|
+
{
|
|
4892
|
+
isDarkMode,
|
|
4893
|
+
onToggleDarkMode: () => setIsDarkMode((prev) => !prev),
|
|
4894
|
+
primaryColor,
|
|
4895
|
+
onPrimaryColorChange: (primaryHsl) => {
|
|
4896
|
+
var _a2;
|
|
4897
|
+
setPrimaryColor(primaryHsl);
|
|
4898
|
+
(_a2 = callbacks.onColorChange) == null ? void 0 : _a2.call(callbacks, primaryHsl);
|
|
4899
|
+
}
|
|
4900
|
+
}
|
|
4901
|
+
),
|
|
4902
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex", children: [
|
|
4903
|
+
showToolbox && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-auto max-w-96 flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4904
|
+
LeftSidebar,
|
|
4905
|
+
{
|
|
4906
|
+
setActiveTab,
|
|
4907
|
+
activeTab
|
|
4908
|
+
}
|
|
4909
|
+
) }),
|
|
4623
4910
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4624
4911
|
"div",
|
|
4625
4912
|
{
|
|
4626
|
-
className: "flex-1 overflow-auto
|
|
4627
|
-
style: {
|
|
4628
|
-
|
|
4913
|
+
className: "flex-1 overflow-auto craftjs-renderer",
|
|
4914
|
+
style: {
|
|
4915
|
+
backgroundColor: ((_d = theme.colors) == null ? void 0 : _d.canvasBackground) || "hsl(var(--muted))"
|
|
4916
|
+
},
|
|
4917
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4918
|
+
"div",
|
|
4919
|
+
{
|
|
4920
|
+
className: "p-8",
|
|
4921
|
+
onClick: () => {
|
|
4922
|
+
setActiveTab("properties");
|
|
4923
|
+
},
|
|
4924
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(core.Frame, { data: initialState, children: defaultEmailContent })
|
|
4925
|
+
}
|
|
4926
|
+
)
|
|
4629
4927
|
}
|
|
4630
|
-
)
|
|
4631
|
-
showSettingsPanel && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-80 border-l bg-background flex flex-col", children: [
|
|
4632
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4 border-b", children: [
|
|
4633
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4634
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "h-4 w-4 text-primary" }),
|
|
4635
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold text-sm", children: "Properties" })
|
|
4636
|
-
] }),
|
|
4637
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-1", children: "Edit selected component" })
|
|
4638
|
-
] }),
|
|
4639
|
-
/* @__PURE__ */ jsxRuntime.jsx(SettingsPanel, {})
|
|
4640
|
-
] })
|
|
4928
|
+
)
|
|
4641
4929
|
] })
|
|
4642
4930
|
] })
|
|
4643
4931
|
}
|