@savvycal/mjml-editor 0.0.1 → 0.0.2

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.
Files changed (173) hide show
  1. package/README.md +176 -0
  2. package/dist/components/editor/BlockIcon.d.ts +7 -0
  3. package/dist/components/editor/BlockIcon.d.ts.map +1 -0
  4. package/dist/components/editor/BlockInspector.d.ts +6 -0
  5. package/dist/components/editor/BlockInspector.d.ts.map +1 -0
  6. package/dist/components/editor/BlockInspector.js +380 -0
  7. package/dist/components/editor/EditorCanvas.d.ts +11 -0
  8. package/dist/components/editor/EditorCanvas.d.ts.map +1 -0
  9. package/dist/components/editor/EditorCanvas.js +116 -0
  10. package/dist/components/editor/FontEditor.d.ts +2 -0
  11. package/dist/components/editor/FontEditor.d.ts.map +1 -0
  12. package/dist/components/editor/FontEditor.js +227 -0
  13. package/dist/components/editor/GlobalStylesPanel.d.ts +7 -0
  14. package/dist/components/editor/GlobalStylesPanel.d.ts.map +1 -0
  15. package/dist/components/editor/GlobalStylesPanel.js +310 -0
  16. package/dist/components/editor/InteractivePreview.d.ts +8 -0
  17. package/dist/components/editor/InteractivePreview.d.ts.map +1 -0
  18. package/dist/components/editor/InteractivePreview.js +120 -0
  19. package/dist/components/editor/LiquidAutocomplete.d.ts +10 -0
  20. package/dist/components/editor/LiquidAutocomplete.d.ts.map +1 -0
  21. package/dist/components/editor/LiquidAutocomplete.js +70 -0
  22. package/dist/components/editor/LiquidInput.d.ts +12 -0
  23. package/dist/components/editor/LiquidInput.d.ts.map +1 -0
  24. package/dist/components/editor/LiquidInput.js +185 -0
  25. package/dist/components/editor/MjmlEditor.d.ts +11 -0
  26. package/dist/components/editor/MjmlEditor.d.ts.map +1 -0
  27. package/dist/components/editor/MjmlEditor.js +111 -0
  28. package/dist/components/editor/OutlineTree.d.ts +7 -0
  29. package/dist/components/editor/OutlineTree.d.ts.map +1 -0
  30. package/dist/components/editor/OutlineTree.js +282 -0
  31. package/dist/components/editor/SourceEditor.d.ts +2 -0
  32. package/dist/components/editor/SourceEditor.d.ts.map +1 -0
  33. package/dist/components/editor/SourceEditor.js +70 -0
  34. package/dist/components/editor/SourcePreview.d.ts +7 -0
  35. package/dist/components/editor/SourcePreview.d.ts.map +1 -0
  36. package/dist/components/editor/SourcePreview.js +55 -0
  37. package/dist/components/editor/TiptapEditor.d.ts +12 -0
  38. package/dist/components/editor/TiptapEditor.d.ts.map +1 -0
  39. package/dist/components/editor/TiptapEditor.js +330 -0
  40. package/dist/components/editor/VisualEditor.d.ts +7 -0
  41. package/dist/components/editor/VisualEditor.d.ts.map +1 -0
  42. package/dist/components/editor/VisualEditor.js +51 -0
  43. package/dist/components/editor/visual-blocks/VisualBlock.d.ts +7 -0
  44. package/dist/components/editor/visual-blocks/VisualBlock.d.ts.map +1 -0
  45. package/dist/components/editor/visual-blocks/VisualBlock.js +34 -0
  46. package/dist/components/editor/visual-blocks/VisualButton.d.ts +7 -0
  47. package/dist/components/editor/visual-blocks/VisualButton.d.ts.map +1 -0
  48. package/dist/components/editor/visual-blocks/VisualButton.js +111 -0
  49. package/dist/components/editor/visual-blocks/VisualColumn.d.ts +8 -0
  50. package/dist/components/editor/visual-blocks/VisualColumn.d.ts.map +1 -0
  51. package/dist/components/editor/visual-blocks/VisualColumn.js +44 -0
  52. package/dist/components/editor/visual-blocks/VisualDivider.d.ts +7 -0
  53. package/dist/components/editor/visual-blocks/VisualDivider.d.ts.map +1 -0
  54. package/dist/components/editor/visual-blocks/VisualDivider.js +41 -0
  55. package/dist/components/editor/visual-blocks/VisualImage.d.ts +7 -0
  56. package/dist/components/editor/visual-blocks/VisualImage.d.ts.map +1 -0
  57. package/dist/components/editor/visual-blocks/VisualImage.js +48 -0
  58. package/dist/components/editor/visual-blocks/VisualRaw.d.ts +7 -0
  59. package/dist/components/editor/visual-blocks/VisualRaw.d.ts.map +1 -0
  60. package/dist/components/editor/visual-blocks/VisualRaw.js +32 -0
  61. package/dist/components/editor/visual-blocks/VisualSection.d.ts +7 -0
  62. package/dist/components/editor/visual-blocks/VisualSection.d.ts.map +1 -0
  63. package/dist/components/editor/visual-blocks/VisualSection.js +131 -0
  64. package/dist/components/editor/visual-blocks/VisualSocial.d.ts +7 -0
  65. package/dist/components/editor/visual-blocks/VisualSocial.d.ts.map +1 -0
  66. package/dist/components/editor/visual-blocks/VisualSocial.js +62 -0
  67. package/dist/components/editor/visual-blocks/VisualSpacer.d.ts +7 -0
  68. package/dist/components/editor/visual-blocks/VisualSpacer.d.ts.map +1 -0
  69. package/dist/components/editor/visual-blocks/VisualSpacer.js +30 -0
  70. package/dist/components/editor/visual-blocks/VisualText.d.ts +7 -0
  71. package/dist/components/editor/visual-blocks/VisualText.d.ts.map +1 -0
  72. package/dist/components/editor/visual-blocks/VisualText.js +103 -0
  73. package/dist/components/editor/visual-blocks/helpers.d.ts +13 -0
  74. package/dist/components/editor/visual-blocks/helpers.d.ts.map +1 -0
  75. package/dist/components/editor/visual-blocks/helpers.js +44 -0
  76. package/dist/components/editor/visual-blocks/useResolvedAttributes.d.ts +7 -0
  77. package/dist/components/editor/visual-blocks/useResolvedAttributes.d.ts.map +1 -0
  78. package/dist/components/editor/visual-blocks/useResolvedAttributes.js +12 -0
  79. package/dist/components/ui/badge.d.ts +10 -0
  80. package/dist/components/ui/badge.d.ts.map +1 -0
  81. package/dist/components/ui/badge.js +26 -0
  82. package/dist/components/ui/button.d.ts +11 -0
  83. package/dist/components/ui/button.d.ts.map +1 -0
  84. package/dist/components/ui/button.js +54 -0
  85. package/dist/components/ui/card.d.ts +10 -0
  86. package/dist/components/ui/card.d.ts.map +1 -0
  87. package/dist/components/ui/collapsible.d.ts +6 -0
  88. package/dist/components/ui/collapsible.d.ts.map +1 -0
  89. package/dist/components/ui/collapsible.js +7 -0
  90. package/dist/components/ui/floating-panel.d.ts +12 -0
  91. package/dist/components/ui/floating-panel.d.ts.map +1 -0
  92. package/dist/components/ui/floating-panel.js +54 -0
  93. package/dist/components/ui/input.d.ts +4 -0
  94. package/dist/components/ui/input.d.ts.map +1 -0
  95. package/dist/components/ui/input.js +26 -0
  96. package/dist/components/ui/label.d.ts +5 -0
  97. package/dist/components/ui/label.d.ts.map +1 -0
  98. package/dist/components/ui/label.js +23 -0
  99. package/dist/components/ui/popover.d.ts +8 -0
  100. package/dist/components/ui/popover.d.ts.map +1 -0
  101. package/dist/components/ui/popover.js +39 -0
  102. package/dist/components/ui/resizable-split-pane.d.ts +10 -0
  103. package/dist/components/ui/resizable-split-pane.d.ts.map +1 -0
  104. package/dist/components/ui/resizable-split-pane.js +65 -0
  105. package/dist/components/ui/scroll-area.d.ts +10 -0
  106. package/dist/components/ui/scroll-area.d.ts.map +1 -0
  107. package/dist/components/ui/scroll-area.js +69 -0
  108. package/dist/components/ui/select.d.ts +16 -0
  109. package/dist/components/ui/select.d.ts.map +1 -0
  110. package/dist/components/ui/select.js +145 -0
  111. package/dist/components/ui/separator.d.ts +5 -0
  112. package/dist/components/ui/separator.d.ts.map +1 -0
  113. package/dist/components/ui/tabs.d.ts +8 -0
  114. package/dist/components/ui/tabs.d.ts.map +1 -0
  115. package/dist/components/ui/tabs.js +68 -0
  116. package/dist/components/ui/theme-toggle.d.ts +2 -0
  117. package/dist/components/ui/theme-toggle.d.ts.map +1 -0
  118. package/dist/components/ui/theme-toggle.js +58 -0
  119. package/dist/context/EditorContext.d.ts +40 -0
  120. package/dist/context/EditorContext.d.ts.map +1 -0
  121. package/dist/context/EditorContext.js +576 -0
  122. package/dist/context/LiquidSchemaContext.d.ts +10 -0
  123. package/dist/context/LiquidSchemaContext.d.ts.map +1 -0
  124. package/dist/context/LiquidSchemaContext.js +16 -0
  125. package/dist/context/ThemeContext.d.ts +18 -0
  126. package/dist/context/ThemeContext.d.ts.map +1 -0
  127. package/dist/context/ThemeContext.js +53 -0
  128. package/dist/extensions/LiquidHighlight.d.ts +3 -0
  129. package/dist/extensions/LiquidHighlight.d.ts.map +1 -0
  130. package/dist/extensions/LiquidHighlight.js +58 -0
  131. package/dist/extensions/LiquidSuggestion.d.ts +18 -0
  132. package/dist/extensions/LiquidSuggestion.d.ts.map +1 -0
  133. package/dist/extensions/LiquidSuggestion.js +119 -0
  134. package/dist/hooks/useFontLoader.d.ts +6 -0
  135. package/dist/hooks/useFontLoader.d.ts.map +1 -0
  136. package/dist/hooks/useFontLoader.js +21 -0
  137. package/dist/hooks/useStyleLoader.d.ts +11 -0
  138. package/dist/hooks/useStyleLoader.d.ts.map +1 -0
  139. package/dist/hooks/useStyleLoader.js +26 -0
  140. package/dist/index.d.ts +6 -150
  141. package/dist/index.d.ts.map +1 -0
  142. package/dist/index.js +7 -57452
  143. package/dist/lib/html-utils.d.ts +23 -0
  144. package/dist/lib/html-utils.d.ts.map +1 -0
  145. package/dist/lib/html-utils.js +25 -0
  146. package/dist/lib/mjml/attributes.d.ts +100 -0
  147. package/dist/lib/mjml/attributes.d.ts.map +1 -0
  148. package/dist/lib/mjml/attributes.js +105 -0
  149. package/dist/lib/mjml/parser.d.ts +67 -0
  150. package/dist/lib/mjml/parser.d.ts.map +1 -0
  151. package/dist/lib/mjml/parser.js +184 -0
  152. package/dist/lib/mjml/parser.test.d.ts +2 -0
  153. package/dist/lib/mjml/parser.test.d.ts.map +1 -0
  154. package/dist/lib/mjml/renderer.d.ts +23 -0
  155. package/dist/lib/mjml/renderer.d.ts.map +1 -0
  156. package/dist/lib/mjml/renderer.js +72 -0
  157. package/dist/lib/mjml/schema.d.ts +21 -0
  158. package/dist/lib/mjml/schema.d.ts.map +1 -0
  159. package/dist/lib/mjml/schema.js +1307 -0
  160. package/dist/lib/mjml/scopeCSS.d.ts +21 -0
  161. package/dist/lib/mjml/scopeCSS.d.ts.map +1 -0
  162. package/dist/lib/mjml/scopeCSS.js +67 -0
  163. package/dist/lib/utils.d.ts +3 -0
  164. package/dist/lib/utils.d.ts.map +1 -0
  165. package/dist/lib/utils.js +8 -0
  166. package/dist/styles.d.ts +1 -0
  167. package/dist/styles.d.ts.map +1 -0
  168. package/dist/styles.js +1 -0
  169. package/dist/types/liquid.d.ts +28 -0
  170. package/dist/types/liquid.d.ts.map +1 -0
  171. package/dist/types/mjml.d.ts +101 -0
  172. package/dist/types/mjml.d.ts.map +1 -0
  173. package/package.json +12 -9
@@ -0,0 +1,282 @@
1
+ import { jsxs as s, jsx as e, Fragment as H } from "react/jsx-runtime";
2
+ import { useRef as j, useState as _, useEffect as L } from "react";
3
+ import { Tree as G } from "react-arborist";
4
+ import { PanelLeftClose as V, Plus as I, Palette as F, Mail as W, ChevronDown as Y, ChevronRight as y, GripVertical as q, Columns as P, Trash2 as J, MoveVertical as S, Minus as T, MousePointerClick as A, Image as D, Type as z } from "lucide-react";
5
+ import { useEditor as M } from "../../context/EditorContext.js";
6
+ import { Button as d } from "../ui/button.js";
7
+ import { Popover as K, PopoverTrigger as Q, PopoverContent as U } from "../ui/popover.js";
8
+ import { contentBlockTypes as X } from "../../lib/mjml/schema.js";
9
+ import { cn as m } from "../../lib/utils.js";
10
+ const C = "__global_styles__", Z = {
11
+ "mj-section": /* @__PURE__ */ e("div", { className: "w-4 h-4 border border-current rounded-sm" }),
12
+ "mj-column": /* @__PURE__ */ e(P, { className: "h-4 w-4" }),
13
+ "mj-text": /* @__PURE__ */ e(z, { className: "h-4 w-4" }),
14
+ "mj-image": /* @__PURE__ */ e(D, { className: "h-4 w-4" }),
15
+ "mj-button": /* @__PURE__ */ e(A, { className: "h-4 w-4" }),
16
+ "mj-divider": /* @__PURE__ */ e(T, { className: "h-4 w-4" }),
17
+ "mj-spacer": /* @__PURE__ */ e(S, { className: "h-4 w-4" })
18
+ }, $ = {
19
+ "mj-text": /* @__PURE__ */ e(z, { className: "h-4 w-4" }),
20
+ "mj-image": /* @__PURE__ */ e(D, { className: "h-4 w-4" }),
21
+ "mj-button": /* @__PURE__ */ e(A, { className: "h-4 w-4" }),
22
+ "mj-divider": /* @__PURE__ */ e(T, { className: "h-4 w-4" }),
23
+ "mj-spacer": /* @__PURE__ */ e(S, { className: "h-4 w-4" })
24
+ };
25
+ function ee(t) {
26
+ return {
27
+ "mj-section": "Section",
28
+ "mj-column": "Column",
29
+ "mj-text": "Text",
30
+ "mj-image": "Image",
31
+ "mj-button": "Button",
32
+ "mj-divider": "Divider",
33
+ "mj-spacer": "Spacer",
34
+ "mj-wrapper": "Wrapper",
35
+ "mj-group": "Group",
36
+ "mj-hero": "Hero",
37
+ "mj-navbar": "Navbar",
38
+ "mj-social": "Social",
39
+ "mj-raw": "Raw HTML"
40
+ }[t] || t.replace("mj-", "").replace(/-/g, " ");
41
+ }
42
+ function te(t) {
43
+ return [
44
+ "mj-section",
45
+ "mj-column",
46
+ "mj-wrapper",
47
+ "mj-group",
48
+ "mj-hero"
49
+ ].includes(t);
50
+ }
51
+ function k(t) {
52
+ return t === "mj-column";
53
+ }
54
+ function B(t) {
55
+ return t === "mj-section" || t === "mj-group";
56
+ }
57
+ function oe({ node: t, style: c, dragHandle: f }) {
58
+ const { state: x, selectBlock: u, deleteBlock: N, addBlock: p, addColumn: v } = M(), [w, a] = _(!1), o = t.data, b = x.selectedBlockId === o._id, r = t.children && t.children.length > 0, l = te(o.tagName), h = (n) => {
59
+ n.stopPropagation(), t.select(), u(o._id);
60
+ }, i = (n) => {
61
+ n.stopPropagation(), N(o._id);
62
+ }, g = (n) => {
63
+ n.stopPropagation(), t.toggle();
64
+ }, O = (n) => {
65
+ const E = o.children?.length || 0;
66
+ p(o._id, E, n), a(!1);
67
+ }, R = () => {
68
+ v(o._id), a(!1);
69
+ };
70
+ return /* @__PURE__ */ s(
71
+ "div",
72
+ {
73
+ style: c,
74
+ className: m(
75
+ "group flex items-center h-8 pr-2 cursor-pointer",
76
+ "hover:bg-accent/50 transition-colors",
77
+ b && "bg-accent",
78
+ t.state.isDragging && "opacity-50"
79
+ ),
80
+ onClick: h,
81
+ children: [
82
+ l ? /* @__PURE__ */ e(
83
+ "button",
84
+ {
85
+ className: m(
86
+ "flex items-center justify-center w-5 h-5",
87
+ "text-foreground-muted hover:text-foreground transition-colors"
88
+ ),
89
+ onClick: g,
90
+ children: r ? t.isOpen ? /* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(y, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(y, { className: "h-3.5 w-3.5 opacity-30" })
91
+ }
92
+ ) : /* @__PURE__ */ e("div", { className: "w-5" }),
93
+ /* @__PURE__ */ e("div", { className: "flex items-center justify-center w-5 h-5 text-foreground-muted", children: Z[o.tagName] || /* @__PURE__ */ e("div", { className: "w-3 h-3 bg-foreground-muted rounded-sm" }) }),
94
+ /* @__PURE__ */ e("span", { className: "flex-1 ml-2 text-sm truncate text-foreground", children: ee(o.tagName) }),
95
+ /* @__PURE__ */ s(
96
+ "div",
97
+ {
98
+ className: m(
99
+ "flex items-center gap-0.5",
100
+ "opacity-0 group-hover:opacity-100 transition-opacity"
101
+ ),
102
+ children: [
103
+ /* @__PURE__ */ e(
104
+ "div",
105
+ {
106
+ ref: f,
107
+ className: m(
108
+ "flex items-center justify-center w-6 h-6 cursor-grab rounded-md",
109
+ "text-foreground-muted hover:text-foreground hover:bg-accent/50"
110
+ ),
111
+ children: /* @__PURE__ */ e(q, { className: "h-3.5 w-3.5" })
112
+ }
113
+ ),
114
+ (k(o.tagName) || B(o.tagName)) && /* @__PURE__ */ s(K, { open: w, onOpenChange: a, children: [
115
+ /* @__PURE__ */ e(Q, { asChild: !0, children: /* @__PURE__ */ e(
116
+ d,
117
+ {
118
+ variant: "ghost",
119
+ size: "icon-sm",
120
+ className: "h-6 w-6 text-foreground-muted hover:text-foreground",
121
+ onClick: (n) => n.stopPropagation(),
122
+ children: /* @__PURE__ */ e(I, { className: "h-3.5 w-3.5" })
123
+ }
124
+ ) }),
125
+ /* @__PURE__ */ s(
126
+ U,
127
+ {
128
+ className: "w-48 p-1.5 shadow-framer-lg",
129
+ align: "start",
130
+ onClick: (n) => n.stopPropagation(),
131
+ children: [
132
+ B(o.tagName) && /* @__PURE__ */ s(
133
+ d,
134
+ {
135
+ variant: "ghost",
136
+ size: "sm",
137
+ className: "w-full justify-start gap-3 h-8 px-3 text-sm font-normal hover:bg-accent",
138
+ onClick: R,
139
+ children: [
140
+ /* @__PURE__ */ e(P, { className: "h-4 w-4 text-foreground-muted" }),
141
+ "Column"
142
+ ]
143
+ }
144
+ ),
145
+ k(o.tagName) && /* @__PURE__ */ e(H, { children: X.map((n) => /* @__PURE__ */ s(
146
+ d,
147
+ {
148
+ variant: "ghost",
149
+ size: "sm",
150
+ className: "w-full justify-start gap-3 h-8 px-3 text-sm font-normal hover:bg-accent",
151
+ onClick: () => O(n.type),
152
+ children: [
153
+ /* @__PURE__ */ e("span", { className: "text-foreground-muted", children: $[n.type] }),
154
+ n.label
155
+ ]
156
+ },
157
+ n.type
158
+ )) })
159
+ ]
160
+ }
161
+ )
162
+ ] }),
163
+ /* @__PURE__ */ e(
164
+ d,
165
+ {
166
+ variant: "ghost",
167
+ size: "icon-sm",
168
+ className: "h-6 w-6 text-foreground-muted hover:text-destructive",
169
+ onClick: i,
170
+ children: /* @__PURE__ */ e(J, { className: "h-3.5 w-3.5" })
171
+ }
172
+ )
173
+ ]
174
+ }
175
+ )
176
+ ]
177
+ }
178
+ );
179
+ }
180
+ function he({ onTogglePanel: t }) {
181
+ const { state: c, moveBlock: f, addSection: x, selectBlock: u } = M(), N = j(null), p = j(null), [v, w] = _(400);
182
+ L(() => {
183
+ const r = p.current;
184
+ if (!r) return;
185
+ const l = new ResizeObserver((h) => {
186
+ for (const i of h)
187
+ w(i.contentRect.height);
188
+ });
189
+ return l.observe(r), () => l.disconnect();
190
+ }, []);
191
+ const a = c.document.children?.find((r) => r.tagName === "mj-body"), o = a?.children || [], b = ({
192
+ dragIds: r,
193
+ parentId: l,
194
+ index: h
195
+ }) => {
196
+ const i = r[0], g = l || a?._id;
197
+ i && g && f(i, g, h);
198
+ };
199
+ return /* @__PURE__ */ s("div", { className: "flex flex-col h-full", children: [
200
+ /* @__PURE__ */ s("div", { className: "flex items-center justify-between h-11 px-3 border-b border-border bg-background", children: [
201
+ /* @__PURE__ */ e("span", { className: "text-sm font-semibold text-foreground", children: "Email Structure" }),
202
+ t && /* @__PURE__ */ e(
203
+ d,
204
+ {
205
+ variant: "ghost",
206
+ size: "icon-sm",
207
+ onClick: t,
208
+ className: "h-7 w-7 rounded-md text-foreground-muted hover:text-foreground hover:bg-accent",
209
+ title: "Collapse panel",
210
+ children: /* @__PURE__ */ e(V, { className: "h-4 w-4" })
211
+ }
212
+ )
213
+ ] }),
214
+ /* @__PURE__ */ e("div", { className: "px-3 py-2 border-b border-border", children: /* @__PURE__ */ s(
215
+ d,
216
+ {
217
+ variant: "outline",
218
+ size: "sm",
219
+ onClick: x,
220
+ className: "w-full h-8 gap-1.5 text-xs font-medium",
221
+ children: [
222
+ /* @__PURE__ */ e(I, { className: "h-3.5 w-3.5" }),
223
+ "Add Section"
224
+ ]
225
+ }
226
+ ) }),
227
+ /* @__PURE__ */ s("div", { className: "px-3 py-1 border-b border-border space-y-0.5", children: [
228
+ /* @__PURE__ */ s(
229
+ "button",
230
+ {
231
+ onClick: () => u(C),
232
+ className: m(
233
+ "flex items-center gap-2 w-full h-8 px-2 rounded-md text-sm",
234
+ "hover:bg-accent/50 transition-colors",
235
+ c.selectedBlockId === C && "bg-accent"
236
+ ),
237
+ children: [
238
+ /* @__PURE__ */ e(F, { className: "h-4 w-4 text-foreground-muted" }),
239
+ /* @__PURE__ */ e("span", { className: "text-foreground", children: "Global Styles" })
240
+ ]
241
+ }
242
+ ),
243
+ /* @__PURE__ */ s(
244
+ "button",
245
+ {
246
+ onClick: () => u(a?._id || null),
247
+ className: m(
248
+ "flex items-center gap-2 w-full h-8 px-2 rounded-md text-sm",
249
+ "hover:bg-accent/50 transition-colors",
250
+ c.selectedBlockId === a?._id && "bg-accent"
251
+ ),
252
+ children: [
253
+ /* @__PURE__ */ e(W, { className: "h-4 w-4 text-foreground-muted" }),
254
+ /* @__PURE__ */ e("span", { className: "text-foreground", children: "Body" })
255
+ ]
256
+ }
257
+ )
258
+ ] }),
259
+ /* @__PURE__ */ e("div", { ref: p, className: "flex-1 min-h-0", children: o.length > 0 ? /* @__PURE__ */ e(
260
+ G,
261
+ {
262
+ ref: N,
263
+ data: o,
264
+ idAccessor: (r) => r._id,
265
+ childrenAccessor: (r) => r.children || null,
266
+ openByDefault: !0,
267
+ width: "100%",
268
+ height: v,
269
+ indent: 16,
270
+ rowHeight: 32,
271
+ paddingTop: 8,
272
+ paddingBottom: 8,
273
+ onMove: b,
274
+ children: oe
275
+ }
276
+ ) : /* @__PURE__ */ e("div", { className: "flex-1 px-3 py-8 text-center text-sm text-muted-foreground", children: "No content yet" }) })
277
+ ] });
278
+ }
279
+ export {
280
+ C as GLOBAL_STYLES_ID,
281
+ he as OutlineTree
282
+ };
@@ -0,0 +1,2 @@
1
+ export declare function SourceEditor(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=SourceEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SourceEditor.d.ts","sourceRoot":"","sources":["../../../src/components/editor/SourceEditor.tsx"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,4CAkF3B"}
@@ -0,0 +1,70 @@
1
+ import { jsxs as s, jsx as r } from "react/jsx-runtime";
2
+ import { useState as n, useEffect as p } from "react";
3
+ import { AlertTriangle as h } from "lucide-react";
4
+ import { useEditor as g } from "../../context/EditorContext.js";
5
+ import { serializeMjml as x, parseMjml as b } from "../../lib/mjml/parser.js";
6
+ import { ResizableSplitPane as v } from "../ui/resizable-split-pane.js";
7
+ import { SourcePreview as N } from "./SourcePreview.js";
8
+ function E() {
9
+ const { state: m, setDocument: c } = g(), [a, i] = n(""), [o, t] = n(null), [d, l] = n(!1);
10
+ p(() => {
11
+ const e = x(m.document);
12
+ i(e), l(!1), t(null);
13
+ }, [m.document]);
14
+ const u = () => {
15
+ try {
16
+ const e = b(a);
17
+ if (e.tagName !== "mjml") {
18
+ t("Invalid MJML: Document must have an <mjml> root element");
19
+ return;
20
+ }
21
+ c(e), t(null), l(!1);
22
+ } catch (e) {
23
+ t(e instanceof Error ? e.message : "Failed to parse MJML");
24
+ }
25
+ }, f = (e) => {
26
+ i(e), l(!0), t(null);
27
+ };
28
+ return /* @__PURE__ */ s(
29
+ v,
30
+ {
31
+ defaultLeftWidth: 50,
32
+ minLeftWidth: 30,
33
+ maxLeftWidth: 70,
34
+ children: [
35
+ /* @__PURE__ */ s("div", { className: "flex flex-col h-full bg-background", children: [
36
+ /* @__PURE__ */ r("div", { className: "px-4 pt-4", children: /* @__PURE__ */ s("div", { className: "flex items-start gap-3 p-3 rounded-md bg-amber-50 border border-amber-200 text-amber-800", children: [
37
+ /* @__PURE__ */ r(h, { className: "h-4 w-4 mt-0.5 flex-shrink-0" }),
38
+ /* @__PURE__ */ r("p", { className: "text-sm", children: "You are editing the raw MJML source. Changes may affect the visual editor." })
39
+ ] }) }),
40
+ /* @__PURE__ */ r("div", { className: "flex-1 min-h-0 p-4", children: /* @__PURE__ */ r(
41
+ "textarea",
42
+ {
43
+ value: a,
44
+ onChange: (e) => f(e.target.value),
45
+ className: "w-full h-full p-4 font-mono text-sm bg-muted border border-border rounded-md resize-none focus:outline-none focus:ring-2 focus:ring-ring",
46
+ spellCheck: !1
47
+ }
48
+ ) }),
49
+ /* @__PURE__ */ s("div", { className: "px-4 pb-4 flex items-center gap-3", children: [
50
+ /* @__PURE__ */ r(
51
+ "button",
52
+ {
53
+ onClick: u,
54
+ disabled: !d,
55
+ className: "px-4 py-2 text-sm font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed",
56
+ children: "Apply"
57
+ }
58
+ ),
59
+ d && !o && /* @__PURE__ */ r("span", { className: "text-sm text-foreground-muted", children: "Unsaved changes" }),
60
+ o && /* @__PURE__ */ r("span", { className: "text-sm text-destructive", children: o })
61
+ ] })
62
+ ] }),
63
+ /* @__PURE__ */ r(N, { mjmlSource: a, debounceMs: 300 })
64
+ ]
65
+ }
66
+ );
67
+ }
68
+ export {
69
+ E as SourceEditor
70
+ };
@@ -0,0 +1,7 @@
1
+ interface SourcePreviewProps {
2
+ mjmlSource: string;
3
+ debounceMs?: number;
4
+ }
5
+ export declare function SourcePreview({ mjmlSource, debounceMs, }: SourcePreviewProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=SourcePreview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SourcePreview.d.ts","sourceRoot":"","sources":["../../../src/components/editor/SourcePreview.tsx"],"names":[],"mappings":"AAGA,UAAU,kBAAkB;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,UAAgB,GACjB,EAAE,kBAAkB,2CAkEpB"}
@@ -0,0 +1,55 @@
1
+ import { jsxs as r, jsx as n } from "react/jsx-runtime";
2
+ import { useRef as f, useState as u, useEffect as m, useMemo as b } from "react";
3
+ import { renderMjmlString as x } from "../../lib/mjml/renderer.js";
4
+ function v({
5
+ mjmlSource: s,
6
+ debounceMs: i = 300
7
+ }) {
8
+ const o = f(null), [l, c] = u(s);
9
+ m(() => {
10
+ const e = setTimeout(() => {
11
+ c(s);
12
+ }, i);
13
+ return () => clearTimeout(e);
14
+ }, [s, i]);
15
+ const { html: a, errors: t } = b(() => l.trim() ? x(l) : { html: "", errors: [] }, [l]);
16
+ return m(() => {
17
+ if (o.current) {
18
+ const e = o.current.contentDocument;
19
+ e && (e.open(), e.write(a), e.close());
20
+ }
21
+ }, [a]), /* @__PURE__ */ r("div", { className: "flex flex-col h-full", children: [
22
+ /* @__PURE__ */ r("div", { className: "h-11 px-4 flex items-center justify-between border-b border-border bg-background", children: [
23
+ /* @__PURE__ */ n("span", { className: "text-sm font-semibold text-foreground", children: "Preview" }),
24
+ t.length > 0 && /* @__PURE__ */ r("span", { className: "text-xs font-medium text-amber-600 bg-amber-50 px-2 py-0.5 rounded-md", children: [
25
+ t.length,
26
+ " warning",
27
+ t.length !== 1 ? "s" : ""
28
+ ] })
29
+ ] }),
30
+ /* @__PURE__ */ n("div", { className: "flex-1 overflow-auto bg-muted", children: /* @__PURE__ */ n(
31
+ "iframe",
32
+ {
33
+ ref: o,
34
+ title: "Source Preview",
35
+ className: "w-full h-full border-0 bg-white",
36
+ sandbox: "allow-same-origin"
37
+ }
38
+ ) }),
39
+ t.length > 0 && /* @__PURE__ */ r("div", { className: "max-h-28 overflow-auto border-t border-border bg-amber-50/50 p-3", children: [
40
+ /* @__PURE__ */ n("div", { className: "text-xs font-semibold text-amber-700 mb-2", children: "Warnings" }),
41
+ /* @__PURE__ */ n("div", { className: "space-y-1", children: t.map((e, d) => /* @__PURE__ */ r("div", { className: "text-xs text-amber-600", children: [
42
+ /* @__PURE__ */ r("span", { className: "font-mono", children: [
43
+ "Line ",
44
+ e.line,
45
+ ":"
46
+ ] }),
47
+ " ",
48
+ e.message
49
+ ] }, d)) })
50
+ ] })
51
+ ] });
52
+ }
53
+ export {
54
+ v as SourcePreview
55
+ };
@@ -0,0 +1,12 @@
1
+ interface TiptapEditorProps {
2
+ content: string;
3
+ onUpdate: (html: string) => void;
4
+ style?: React.CSSProperties;
5
+ className?: string;
6
+ }
7
+ export interface TiptapEditorRef {
8
+ focus: () => void;
9
+ }
10
+ export declare const TiptapEditor: import('react').ForwardRefExoticComponent<TiptapEditorProps & import('react').RefAttributes<TiptapEditorRef>>;
11
+ export {};
12
+ //# sourceMappingURL=TiptapEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TiptapEditor.d.ts","sourceRoot":"","sources":["../../../src/components/editor/TiptapEditor.tsx"],"names":[],"mappings":"AAyCA,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,+GAobxB,CAAC"}