@react-email/editor 0.0.0-canary.49

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 (80) hide show
  1. package/dist/columns-D1gzbJr5.cjs +404 -0
  2. package/dist/columns-TFI4L-IC.mjs +277 -0
  3. package/dist/columns-TFI4L-IC.mjs.map +1 -0
  4. package/dist/core/index.cjs +9 -0
  5. package/dist/core/index.d.cts +2 -0
  6. package/dist/core/index.d.mts +2 -0
  7. package/dist/core/index.mjs +4 -0
  8. package/dist/core-Dp3tVCOZ.mjs +156 -0
  9. package/dist/core-Dp3tVCOZ.mjs.map +1 -0
  10. package/dist/core-NV1Aun-R.cjs +173 -0
  11. package/dist/event-bus-BxVEXi1L.mjs +88 -0
  12. package/dist/event-bus-BxVEXi1L.mjs.map +1 -0
  13. package/dist/event-bus-WI0H5tIM.cjs +105 -0
  14. package/dist/extension-CfIsm0_p.cjs +1504 -0
  15. package/dist/extension-n2yYIR7e.mjs +1403 -0
  16. package/dist/extension-n2yYIR7e.mjs.map +1 -0
  17. package/dist/extensions/index.cjs +51 -0
  18. package/dist/extensions/index.d.cts +401 -0
  19. package/dist/extensions/index.d.cts.map +1 -0
  20. package/dist/extensions/index.d.mts +401 -0
  21. package/dist/extensions/index.d.mts.map +1 -0
  22. package/dist/extensions/index.mjs +5 -0
  23. package/dist/extensions-BsDsFFkk.mjs +1785 -0
  24. package/dist/extensions-BsDsFFkk.mjs.map +1 -0
  25. package/dist/extensions-D9BbHnEV.cjs +2029 -0
  26. package/dist/global-content-CaNsyaPw.mjs +78 -0
  27. package/dist/global-content-CaNsyaPw.mjs.map +1 -0
  28. package/dist/global-content-CxV8qpMp.cjs +89 -0
  29. package/dist/index-BMsf5s28.d.mts +194 -0
  30. package/dist/index-BMsf5s28.d.mts.map +1 -0
  31. package/dist/index-DNriNUPU.d.cts +194 -0
  32. package/dist/index-DNriNUPU.d.cts.map +1 -0
  33. package/dist/index.cjs +199 -0
  34. package/dist/index.css +1171 -0
  35. package/dist/index.css.map +1 -0
  36. package/dist/index.d.cts +43 -0
  37. package/dist/index.d.cts.map +1 -0
  38. package/dist/index.d.mts +43 -0
  39. package/dist/index.d.mts.map +1 -0
  40. package/dist/index.mjs +199 -0
  41. package/dist/index.mjs.map +1 -0
  42. package/dist/plugins/index.cjs +19 -0
  43. package/dist/plugins/index.d.cts +73 -0
  44. package/dist/plugins/index.d.cts.map +1 -0
  45. package/dist/plugins/index.d.mts +73 -0
  46. package/dist/plugins/index.d.mts.map +1 -0
  47. package/dist/plugins/index.mjs +3 -0
  48. package/dist/root-BWiLr5WO.mjs +2363 -0
  49. package/dist/root-BWiLr5WO.mjs.map +1 -0
  50. package/dist/root-Bm_YBU0n.cjs +2873 -0
  51. package/dist/set-text-alignment-BDkB4Vfh.mjs +19 -0
  52. package/dist/set-text-alignment-BDkB4Vfh.mjs.map +1 -0
  53. package/dist/set-text-alignment-BlyZq1GA.cjs +24 -0
  54. package/dist/styles-BBXVfEv-.mjs +223 -0
  55. package/dist/styles-BBXVfEv-.mjs.map +1 -0
  56. package/dist/styles-D5jB7Yx-.cjs +252 -0
  57. package/dist/types-B-hiUAR9.d.cts +47 -0
  58. package/dist/types-B-hiUAR9.d.cts.map +1 -0
  59. package/dist/types-J7sLqbPy.d.mts +47 -0
  60. package/dist/types-J7sLqbPy.d.mts.map +1 -0
  61. package/dist/ui/bubble-menu/bubble-menu.css +285 -0
  62. package/dist/ui/index.cjs +3052 -0
  63. package/dist/ui/index.d.cts +1220 -0
  64. package/dist/ui/index.d.cts.map +1 -0
  65. package/dist/ui/index.d.mts +1220 -0
  66. package/dist/ui/index.d.mts.map +1 -0
  67. package/dist/ui/index.mjs +2942 -0
  68. package/dist/ui/index.mjs.map +1 -0
  69. package/dist/ui/inspector/inspector.css +338 -0
  70. package/dist/ui/slash-command/slash-command.css +44 -0
  71. package/dist/ui/themes/default.css +1169 -0
  72. package/dist/utils/index.cjs +3 -0
  73. package/dist/utils/index.d.cts +7 -0
  74. package/dist/utils/index.d.cts.map +1 -0
  75. package/dist/utils/index.d.mts +7 -0
  76. package/dist/utils/index.d.mts.map +1 -0
  77. package/dist/utils/index.mjs +3 -0
  78. package/license.md +7 -0
  79. package/package.json +159 -0
  80. package/readme.md +69 -0
@@ -0,0 +1,2942 @@
1
+ import { i as jsToInlineCss, n as expandShorthandProperties, r as inlineCssToJs, t as ensureBorderStyleFallback } from "../styles-BBXVfEv-.mjs";
2
+ import { l as loadPrismTheme } from "../columns-TFI4L-IC.mjs";
3
+ import { c as stylesToCss, d as EDITOR_THEMES, i as getThemeComponentKey, l as useEmailTheming, m as SUPPORTED_CSS_PROPERTIES, s as setGlobalStyles } from "../extension-n2yYIR7e.mjs";
4
+ import { $ as BubbleMenuAlignLeft, A as BubbleMenuImageDefault, At as AlignLeftIcon, B as NodeSelectorContent, C as BubbleMenuSeparator, Ct as Columns2Icon, D as BubbleMenuLinkOpenLink, Dt as CaseUpperIcon, E as BubbleMenuLinkToolbar, Et as CheckIcon, F as BubbleMenuUppercase, G as BubbleMenuItemGroup, H as NodeSelectorTrigger, I as BubbleMenuUnderline, J as BubbleMenuButtonToolbar, K as BubbleMenuCode, L as bubbleMenuTriggers, M as BubbleMenuImageEditLink, N as BubbleMenuButtonDefault, O as BubbleMenuLinkForm, Ot as BoldIcon, P as RootWithDefault, Q as BubbleMenuAlignRight, R as BubbleMenuStrike, S as BubbleMenu, St as Columns3Icon, T as BubbleMenuLinkUnlink, Tt as ChevronDownIcon, U as BubbleMenuLinkSelector, V as NodeSelectorRoot, W as BubbleMenuItalic, X as BubbleMenuButtonEditLink, Y as BubbleMenuButtonForm, Z as BubbleMenuBold, _ as TWO_COLUMNS, _t as Heading3Icon, a as BUTTON, at as TextQuoteIcon, b as isAtMaxColumnsDepth, bt as ExternalLinkIcon, c as FOUR_COLUMNS, ct as SquareCodeIcon, d as H3, dt as PencilIcon, et as BubbleMenuAlignCenter, f as NUMBERED_LIST, ft as MousePointerIcon, g as THREE_COLUMNS, gt as ItalicIcon, h as TEXT, ht as LinkIcon, i as BULLET_LIST, it as UnderlineIcon, j as BubbleMenuImageToolbar, jt as AlignCenterIcon, k as BubbleMenuLinkEditLink, kt as AlignRightIcon, l as H1, lt as SplitSquareVerticalIcon, m as SECTION, mt as ListIcon, n as filterAndRankItems, nt as useBubbleMenuContext, o as CODE, ot as TextIcon, p as QUOTE, pt as ListOrderedIcon, q as BubbleMenuButtonUnlink, r as scoreItem, rt as UnlinkIcon, s as DIVIDER, st as StrikethroughIcon, t as SlashCommandRoot, tt as BubbleMenuItem, u as H2, ut as Rows2Icon, v as defaultSlashCommands, vt as Heading2Icon, w as BubbleMenuLinkDefault, wt as CodeIcon, x as isInsideNode, xt as Columns4Icon, y as CommandList, yt as Heading1Icon, z as BubbleMenuNodeSelector } from "../root-BWiLr5WO.mjs";
5
+ import { extensions, useCurrentEditor, useEditorState } from "@tiptap/react";
6
+ import * as React$1 from "react";
7
+ import React from "react";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { NodeSelection, Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
10
+ import { Slot } from "@radix-ui/react-slot";
11
+
12
+ //#region src/ui/icons/align-center-vertical.tsx
13
+ function AlignCenterVerticalIcon({ size, width, height, ...props }) {
14
+ return /* @__PURE__ */ jsxs("svg", {
15
+ xmlns: "http://www.w3.org/2000/svg",
16
+ width: size ?? width ?? 24,
17
+ height: size ?? height ?? 24,
18
+ viewBox: "0 0 24 24",
19
+ fill: "none",
20
+ stroke: "currentColor",
21
+ strokeWidth: 2,
22
+ strokeLinecap: "round",
23
+ strokeLinejoin: "round",
24
+ "aria-hidden": "true",
25
+ ...props,
26
+ children: [
27
+ /* @__PURE__ */ jsx("path", { d: "M12 2v20" }),
28
+ /* @__PURE__ */ jsx("path", { d: "M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" }),
29
+ /* @__PURE__ */ jsx("path", { d: "M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" }),
30
+ /* @__PURE__ */ jsx("path", { d: "M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" }),
31
+ /* @__PURE__ */ jsx("path", { d: "M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" })
32
+ ]
33
+ });
34
+ }
35
+
36
+ //#endregion
37
+ //#region src/ui/icons/align-end-vertical.tsx
38
+ function AlignEndVerticalIcon({ size, width, height, ...props }) {
39
+ return /* @__PURE__ */ jsxs("svg", {
40
+ xmlns: "http://www.w3.org/2000/svg",
41
+ width: size ?? width ?? 24,
42
+ height: size ?? height ?? 24,
43
+ viewBox: "0 0 24 24",
44
+ fill: "none",
45
+ stroke: "currentColor",
46
+ strokeWidth: 2,
47
+ strokeLinecap: "round",
48
+ strokeLinejoin: "round",
49
+ "aria-hidden": "true",
50
+ ...props,
51
+ children: [
52
+ /* @__PURE__ */ jsx("rect", {
53
+ width: "9",
54
+ height: "6",
55
+ x: "9",
56
+ y: "14",
57
+ rx: "2"
58
+ }),
59
+ /* @__PURE__ */ jsx("rect", {
60
+ width: "16",
61
+ height: "6",
62
+ x: "2",
63
+ y: "4",
64
+ rx: "2"
65
+ }),
66
+ /* @__PURE__ */ jsx("path", { d: "M22 2v20" })
67
+ ]
68
+ });
69
+ }
70
+
71
+ //#endregion
72
+ //#region src/ui/icons/align-start-vertical.tsx
73
+ function AlignStartVerticalIcon({ size, width, height, ...props }) {
74
+ return /* @__PURE__ */ jsxs("svg", {
75
+ xmlns: "http://www.w3.org/2000/svg",
76
+ width: size ?? width ?? 24,
77
+ height: size ?? height ?? 24,
78
+ viewBox: "0 0 24 24",
79
+ fill: "none",
80
+ stroke: "currentColor",
81
+ strokeWidth: 2,
82
+ strokeLinecap: "round",
83
+ strokeLinejoin: "round",
84
+ "aria-hidden": "true",
85
+ ...props,
86
+ children: [
87
+ /* @__PURE__ */ jsx("rect", {
88
+ width: "9",
89
+ height: "6",
90
+ x: "6",
91
+ y: "14",
92
+ rx: "2"
93
+ }),
94
+ /* @__PURE__ */ jsx("rect", {
95
+ width: "16",
96
+ height: "6",
97
+ x: "6",
98
+ y: "4",
99
+ rx: "2"
100
+ }),
101
+ /* @__PURE__ */ jsx("path", { d: "M2 2v20" })
102
+ ]
103
+ });
104
+ }
105
+
106
+ //#endregion
107
+ //#region src/ui/icons/box.tsx
108
+ function BoxIcon({ size, width, height, ...props }) {
109
+ return /* @__PURE__ */ jsxs("svg", {
110
+ xmlns: "http://www.w3.org/2000/svg",
111
+ width: size ?? width ?? 24,
112
+ height: size ?? height ?? 24,
113
+ viewBox: "0 0 24 24",
114
+ fill: "none",
115
+ stroke: "currentColor",
116
+ strokeWidth: 2,
117
+ strokeLinecap: "round",
118
+ strokeLinejoin: "round",
119
+ "aria-hidden": "true",
120
+ ...props,
121
+ children: [
122
+ /* @__PURE__ */ jsx("path", { d: "M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z" }),
123
+ /* @__PURE__ */ jsx("path", { d: "m3.3 7 8.7 5 8.7-5" }),
124
+ /* @__PURE__ */ jsx("path", { d: "M12 22V12" })
125
+ ]
126
+ });
127
+ }
128
+
129
+ //#endregion
130
+ //#region src/ui/icons/corner-bottom-left.tsx
131
+ function CornerBottomLeftIcon({ size, width, height, ...props }) {
132
+ return /* @__PURE__ */ jsx("svg", {
133
+ xmlns: "http://www.w3.org/2000/svg",
134
+ width: size ?? width ?? 15,
135
+ height: size ?? height ?? 15,
136
+ viewBox: "0 0 15 15",
137
+ fill: "none",
138
+ "aria-hidden": "true",
139
+ ...props,
140
+ children: /* @__PURE__ */ jsx("path", {
141
+ d: "M9.87737 12H9.9H11.5C11.7761 12 12 11.7761 12 11.5C12 11.2239 11.7761 11 11.5 11H9.9C8.77164 11 7.95545 10.9996 7.31352 10.9472C6.67744 10.8952 6.25662 10.7946 5.91103 10.6185C5.25247 10.283 4.71703 9.74753 4.38148 9.08897C4.20539 8.74338 4.10481 8.32256 4.05284 7.68648C4.00039 7.04455 4 6.22836 4 5.1V3.5C4 3.22386 3.77614 3 3.5 3C3.22386 3 3 3.22386 3 3.5V5.1V5.12263C3 6.22359 3 7.08052 3.05616 7.76791C3.11318 8.46584 3.23058 9.0329 3.49047 9.54296C3.9219 10.3897 4.61031 11.0781 5.45704 11.5095C5.9671 11.7694 6.53416 11.8868 7.23209 11.9438C7.91948 12 8.77641 12 9.87737 12Z",
142
+ fill: "currentColor",
143
+ fillRule: "evenodd",
144
+ clipRule: "evenodd"
145
+ })
146
+ });
147
+ }
148
+
149
+ //#endregion
150
+ //#region src/ui/icons/corner-bottom-right.tsx
151
+ function CornerBottomRightIcon({ size, width, height, ...props }) {
152
+ return /* @__PURE__ */ jsx("svg", {
153
+ xmlns: "http://www.w3.org/2000/svg",
154
+ width: size ?? width ?? 15,
155
+ height: size ?? height ?? 15,
156
+ viewBox: "0 0 15 15",
157
+ fill: "none",
158
+ "aria-hidden": "true",
159
+ ...props,
160
+ children: /* @__PURE__ */ jsx("path", {
161
+ d: "M5.12263 12H5.1H3.5C3.22386 12 3 11.7761 3 11.5C3 11.2239 3.22386 11 3.5 11H5.1C6.22836 11 7.04455 10.9996 7.68648 10.9472C8.32256 10.8952 8.74338 10.7946 9.08897 10.6185C9.74753 10.283 10.283 9.74753 10.6185 9.08897C10.7946 8.74338 10.8952 8.32256 10.9472 7.68648C10.9996 7.04455 11 6.22836 11 5.1V3.5C11 3.22386 11.2239 3 11.5 3C11.7761 3 12 3.22386 12 3.5V5.1V5.12263C12 6.22359 12 7.08052 11.9438 7.76791C11.8868 8.46584 11.7694 9.0329 11.5095 9.54296C11.0781 10.3897 10.3897 11.0781 9.54296 11.5095C9.0329 11.7694 8.46584 11.8868 7.76791 11.9438C7.08052 12 6.22359 12 5.12263 12Z",
162
+ fill: "currentColor",
163
+ fillRule: "evenodd",
164
+ clipRule: "evenodd"
165
+ })
166
+ });
167
+ }
168
+
169
+ //#endregion
170
+ //#region src/ui/icons/corner-top-left.tsx
171
+ function CornerTopLeftIcon({ size, width, height, ...props }) {
172
+ return /* @__PURE__ */ jsx("svg", {
173
+ xmlns: "http://www.w3.org/2000/svg",
174
+ width: size ?? width ?? 15,
175
+ height: size ?? height ?? 15,
176
+ viewBox: "0 0 15 15",
177
+ fill: "none",
178
+ "aria-hidden": "true",
179
+ ...props,
180
+ children: /* @__PURE__ */ jsx("path", {
181
+ d: "M9.87737 3H9.9H11.5C11.7761 3 12 3.22386 12 3.5C12 3.77614 11.7761 4 11.5 4H9.9C8.77164 4 7.95545 4.00039 7.31352 4.05284C6.67744 4.10481 6.25662 4.20539 5.91103 4.38148C5.25247 4.71703 4.71703 5.25247 4.38148 5.91103C4.20539 6.25662 4.10481 6.67744 4.05284 7.31352C4.00039 7.95545 4 8.77164 4 9.9V11.5C4 11.7761 3.77614 12 3.5 12C3.22386 12 3 11.7761 3 11.5V9.9V9.87737C3 8.77641 3 7.91948 3.05616 7.23209C3.11318 6.53416 3.23058 5.9671 3.49047 5.45704C3.9219 4.61031 4.61031 3.9219 5.45704 3.49047C5.9671 3.23058 6.53416 3.11318 7.23209 3.05616C7.91948 3 8.77641 3 9.87737 3Z",
182
+ fill: "currentColor",
183
+ fillRule: "evenodd",
184
+ clipRule: "evenodd"
185
+ })
186
+ });
187
+ }
188
+
189
+ //#endregion
190
+ //#region src/ui/icons/corner-top-right.tsx
191
+ function CornerTopRightIcon({ size, width, height, ...props }) {
192
+ return /* @__PURE__ */ jsx("svg", {
193
+ xmlns: "http://www.w3.org/2000/svg",
194
+ width: size ?? width ?? 15,
195
+ height: size ?? height ?? 15,
196
+ viewBox: "0 0 15 15",
197
+ fill: "none",
198
+ "aria-hidden": "true",
199
+ ...props,
200
+ children: /* @__PURE__ */ jsx("path", {
201
+ d: "M5.12263 3H5.1H3.5C3.22386 3 3 3.22386 3 3.5C3 3.77614 3.22386 4 3.5 4H5.1C6.22836 4 7.04455 4.00039 7.68648 4.05284C8.32256 4.10481 8.74338 4.20539 9.08897 4.38148C9.74753 4.71703 10.283 5.25247 10.6185 5.91103C10.7946 6.25662 10.8952 6.67744 10.9472 7.31352C10.9996 7.95545 11 8.77164 11 9.9V11.5C11 11.7761 11.2239 12 11.5 12C11.7761 12 12 11.7761 12 11.5V9.9V9.87737C12 8.77641 12 7.91948 11.9438 7.23209C11.8868 6.53416 11.7694 5.9671 11.5095 5.45704C11.0781 4.61031 10.3897 3.9219 9.54296 3.49047C9.0329 3.23058 8.46584 3.11318 7.76791 3.05616C7.08052 3 6.22359 3 5.12263 3Z",
202
+ fill: "currentColor",
203
+ fillRule: "evenodd",
204
+ clipRule: "evenodd"
205
+ })
206
+ });
207
+ }
208
+
209
+ //#endregion
210
+ //#region src/ui/icons/image.tsx
211
+ function ImageIcon({ size, width, height, ...props }) {
212
+ return /* @__PURE__ */ jsxs("svg", {
213
+ xmlns: "http://www.w3.org/2000/svg",
214
+ width: size ?? width ?? 24,
215
+ height: size ?? height ?? 24,
216
+ viewBox: "0 0 24 24",
217
+ fill: "none",
218
+ stroke: "currentColor",
219
+ strokeWidth: 2,
220
+ strokeLinecap: "round",
221
+ strokeLinejoin: "round",
222
+ "aria-hidden": "true",
223
+ ...props,
224
+ children: [
225
+ /* @__PURE__ */ jsx("rect", {
226
+ width: "18",
227
+ height: "18",
228
+ x: "3",
229
+ y: "3",
230
+ rx: "2",
231
+ ry: "2"
232
+ }),
233
+ /* @__PURE__ */ jsx("circle", {
234
+ cx: "9",
235
+ cy: "9",
236
+ r: "2"
237
+ }),
238
+ /* @__PURE__ */ jsx("path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" })
239
+ ]
240
+ });
241
+ }
242
+
243
+ //#endregion
244
+ //#region src/ui/icons/layout.tsx
245
+ function LayoutIcon({ size, width, height, ...props }) {
246
+ return /* @__PURE__ */ jsxs("svg", {
247
+ xmlns: "http://www.w3.org/2000/svg",
248
+ width: size ?? width ?? 24,
249
+ height: size ?? height ?? 24,
250
+ viewBox: "0 0 24 24",
251
+ fill: "none",
252
+ stroke: "currentColor",
253
+ strokeWidth: 2,
254
+ strokeLinecap: "round",
255
+ strokeLinejoin: "round",
256
+ "aria-hidden": "true",
257
+ ...props,
258
+ children: [
259
+ /* @__PURE__ */ jsx("rect", {
260
+ width: "18",
261
+ height: "18",
262
+ x: "3",
263
+ y: "3",
264
+ rx: "2",
265
+ ry: "2"
266
+ }),
267
+ /* @__PURE__ */ jsx("path", { d: "M3 9h18" }),
268
+ /* @__PURE__ */ jsx("path", { d: "M9 21V9" })
269
+ ]
270
+ });
271
+ }
272
+
273
+ //#endregion
274
+ //#region src/ui/icons/minus.tsx
275
+ function MinusIcon({ size, width, height, ...props }) {
276
+ return /* @__PURE__ */ jsx("svg", {
277
+ xmlns: "http://www.w3.org/2000/svg",
278
+ width: size ?? width ?? 24,
279
+ height: size ?? height ?? 24,
280
+ viewBox: "0 0 24 24",
281
+ fill: "none",
282
+ stroke: "currentColor",
283
+ strokeWidth: 2,
284
+ strokeLinecap: "round",
285
+ strokeLinejoin: "round",
286
+ "aria-hidden": "true",
287
+ ...props,
288
+ children: /* @__PURE__ */ jsx("path", { d: "M5 12h14" })
289
+ });
290
+ }
291
+
292
+ //#endregion
293
+ //#region src/ui/icons/mouse-pointer-click.tsx
294
+ function MousePointerClickIcon({ size, width, height, ...props }) {
295
+ return /* @__PURE__ */ jsxs("svg", {
296
+ xmlns: "http://www.w3.org/2000/svg",
297
+ width: size ?? width ?? 24,
298
+ height: size ?? height ?? 24,
299
+ viewBox: "0 0 24 24",
300
+ fill: "none",
301
+ stroke: "currentColor",
302
+ strokeWidth: 2,
303
+ strokeLinecap: "round",
304
+ strokeLinejoin: "round",
305
+ "aria-hidden": "true",
306
+ ...props,
307
+ children: [
308
+ /* @__PURE__ */ jsx("path", { d: "M14 4.1 12 6" }),
309
+ /* @__PURE__ */ jsx("path", { d: "m5.1 8-2.9-.8" }),
310
+ /* @__PURE__ */ jsx("path", { d: "m6 12-1.9 2" }),
311
+ /* @__PURE__ */ jsx("path", { d: "M7.2 2.2 8 5.1" }),
312
+ /* @__PURE__ */ jsx("path", { d: "M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z" })
313
+ ]
314
+ });
315
+ }
316
+
317
+ //#endregion
318
+ //#region src/ui/icons/panel-bottom.tsx
319
+ function PanelBottomIcon({ size, width, height, ...props }) {
320
+ return /* @__PURE__ */ jsxs("svg", {
321
+ xmlns: "http://www.w3.org/2000/svg",
322
+ width: size ?? width ?? 24,
323
+ height: size ?? height ?? 24,
324
+ viewBox: "0 0 24 24",
325
+ fill: "none",
326
+ stroke: "currentColor",
327
+ strokeWidth: 2,
328
+ strokeLinecap: "round",
329
+ strokeLinejoin: "round",
330
+ "aria-hidden": "true",
331
+ ...props,
332
+ children: [/* @__PURE__ */ jsx("rect", {
333
+ width: "18",
334
+ height: "18",
335
+ x: "3",
336
+ y: "3",
337
+ rx: "2"
338
+ }), /* @__PURE__ */ jsx("path", { d: "M3 15h18" })]
339
+ });
340
+ }
341
+
342
+ //#endregion
343
+ //#region src/ui/icons/panel-left.tsx
344
+ function PanelLeftIcon({ size, width, height, ...props }) {
345
+ return /* @__PURE__ */ jsxs("svg", {
346
+ xmlns: "http://www.w3.org/2000/svg",
347
+ width: size ?? width ?? 24,
348
+ height: size ?? height ?? 24,
349
+ viewBox: "0 0 24 24",
350
+ fill: "none",
351
+ stroke: "currentColor",
352
+ strokeWidth: 2,
353
+ strokeLinecap: "round",
354
+ strokeLinejoin: "round",
355
+ "aria-hidden": "true",
356
+ ...props,
357
+ children: [/* @__PURE__ */ jsx("rect", {
358
+ width: "18",
359
+ height: "18",
360
+ x: "3",
361
+ y: "3",
362
+ rx: "2"
363
+ }), /* @__PURE__ */ jsx("path", { d: "M9 3v18" })]
364
+ });
365
+ }
366
+
367
+ //#endregion
368
+ //#region src/ui/icons/panel-right.tsx
369
+ function PanelRightIcon({ size, width, height, ...props }) {
370
+ return /* @__PURE__ */ jsxs("svg", {
371
+ xmlns: "http://www.w3.org/2000/svg",
372
+ width: size ?? width ?? 24,
373
+ height: size ?? height ?? 24,
374
+ viewBox: "0 0 24 24",
375
+ fill: "none",
376
+ stroke: "currentColor",
377
+ strokeWidth: 2,
378
+ strokeLinecap: "round",
379
+ strokeLinejoin: "round",
380
+ "aria-hidden": "true",
381
+ ...props,
382
+ children: [/* @__PURE__ */ jsx("rect", {
383
+ width: "18",
384
+ height: "18",
385
+ x: "3",
386
+ y: "3",
387
+ rx: "2"
388
+ }), /* @__PURE__ */ jsx("path", { d: "M15 3v18" })]
389
+ });
390
+ }
391
+
392
+ //#endregion
393
+ //#region src/ui/icons/panel-top.tsx
394
+ function PanelTopIcon({ size, width, height, ...props }) {
395
+ return /* @__PURE__ */ jsxs("svg", {
396
+ xmlns: "http://www.w3.org/2000/svg",
397
+ width: size ?? width ?? 24,
398
+ height: size ?? height ?? 24,
399
+ viewBox: "0 0 24 24",
400
+ fill: "none",
401
+ stroke: "currentColor",
402
+ strokeWidth: 2,
403
+ strokeLinecap: "round",
404
+ strokeLinejoin: "round",
405
+ "aria-hidden": "true",
406
+ ...props,
407
+ children: [/* @__PURE__ */ jsx("rect", {
408
+ width: "18",
409
+ height: "18",
410
+ x: "3",
411
+ y: "3",
412
+ rx: "2"
413
+ }), /* @__PURE__ */ jsx("path", { d: "M3 9h18" })]
414
+ });
415
+ }
416
+
417
+ //#endregion
418
+ //#region src/ui/icons/plus.tsx
419
+ function PlusIcon({ size, width, height, ...props }) {
420
+ return /* @__PURE__ */ jsxs("svg", {
421
+ xmlns: "http://www.w3.org/2000/svg",
422
+ width: size ?? width ?? 24,
423
+ height: size ?? height ?? 24,
424
+ viewBox: "0 0 24 24",
425
+ fill: "none",
426
+ stroke: "currentColor",
427
+ strokeWidth: 2,
428
+ strokeLinecap: "round",
429
+ strokeLinejoin: "round",
430
+ "aria-hidden": "true",
431
+ ...props,
432
+ children: [/* @__PURE__ */ jsx("path", { d: "M5 12h14" }), /* @__PURE__ */ jsx("path", { d: "M12 5v14" })]
433
+ });
434
+ }
435
+
436
+ //#endregion
437
+ //#region src/ui/icons/square.tsx
438
+ function SquareIcon({ size, width, height, ...props }) {
439
+ return /* @__PURE__ */ jsx("svg", {
440
+ xmlns: "http://www.w3.org/2000/svg",
441
+ width: size ?? width ?? 24,
442
+ height: size ?? height ?? 24,
443
+ viewBox: "0 0 24 24",
444
+ fill: "none",
445
+ stroke: "currentColor",
446
+ strokeWidth: 2,
447
+ strokeLinecap: "round",
448
+ strokeLinejoin: "round",
449
+ "aria-hidden": "true",
450
+ ...props,
451
+ children: /* @__PURE__ */ jsx("rect", {
452
+ width: "18",
453
+ height: "18",
454
+ x: "3",
455
+ y: "3",
456
+ rx: "2"
457
+ })
458
+ });
459
+ }
460
+
461
+ //#endregion
462
+ //#region src/ui/icons/square-dashed.tsx
463
+ function SquareDashedIcon({ size, width, height, ...props }) {
464
+ return /* @__PURE__ */ jsxs("svg", {
465
+ xmlns: "http://www.w3.org/2000/svg",
466
+ width: size ?? width ?? 24,
467
+ height: size ?? height ?? 24,
468
+ viewBox: "0 0 24 24",
469
+ fill: "none",
470
+ stroke: "currentColor",
471
+ strokeWidth: 2,
472
+ strokeLinecap: "round",
473
+ strokeLinejoin: "round",
474
+ "aria-hidden": "true",
475
+ ...props,
476
+ children: [
477
+ /* @__PURE__ */ jsx("path", { d: "M5 3a2 2 0 0 0-2 2" }),
478
+ /* @__PURE__ */ jsx("path", { d: "M19 3a2 2 0 0 1 2 2" }),
479
+ /* @__PURE__ */ jsx("path", { d: "M21 19a2 2 0 0 1-2 2" }),
480
+ /* @__PURE__ */ jsx("path", { d: "M5 21a2 2 0 0 1-2-2" }),
481
+ /* @__PURE__ */ jsx("path", { d: "M9 3h1" }),
482
+ /* @__PURE__ */ jsx("path", { d: "M9 21h1" }),
483
+ /* @__PURE__ */ jsx("path", { d: "M14 3h1" }),
484
+ /* @__PURE__ */ jsx("path", { d: "M14 21h1" }),
485
+ /* @__PURE__ */ jsx("path", { d: "M3 9v1" }),
486
+ /* @__PURE__ */ jsx("path", { d: "M21 9v1" }),
487
+ /* @__PURE__ */ jsx("path", { d: "M3 14v1" }),
488
+ /* @__PURE__ */ jsx("path", { d: "M21 14v1" })
489
+ ]
490
+ });
491
+ }
492
+
493
+ //#endregion
494
+ //#region src/ui/icons/square-round-corner.tsx
495
+ function SquareRoundCornerIcon({ size, width, height, ...props }) {
496
+ return /* @__PURE__ */ jsxs("svg", {
497
+ xmlns: "http://www.w3.org/2000/svg",
498
+ width: size ?? width ?? 24,
499
+ height: size ?? height ?? 24,
500
+ viewBox: "0 0 24 24",
501
+ fill: "none",
502
+ stroke: "currentColor",
503
+ strokeWidth: 2,
504
+ strokeLinecap: "round",
505
+ strokeLinejoin: "round",
506
+ "aria-hidden": "true",
507
+ ...props,
508
+ children: [/* @__PURE__ */ jsx("path", { d: "M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }), /* @__PURE__ */ jsx("path", { d: "M14 3a8 8 0 0 1 8 8" })]
509
+ });
510
+ }
511
+
512
+ //#endregion
513
+ //#region src/ui/icons/table.tsx
514
+ function TableIcon({ size, width, height, ...props }) {
515
+ return /* @__PURE__ */ jsxs("svg", {
516
+ xmlns: "http://www.w3.org/2000/svg",
517
+ width: size ?? width ?? 24,
518
+ height: size ?? height ?? 24,
519
+ viewBox: "0 0 24 24",
520
+ fill: "none",
521
+ stroke: "currentColor",
522
+ strokeWidth: 2,
523
+ strokeLinecap: "round",
524
+ strokeLinejoin: "round",
525
+ "aria-hidden": "true",
526
+ ...props,
527
+ children: [
528
+ /* @__PURE__ */ jsx("path", { d: "M12 3v18" }),
529
+ /* @__PURE__ */ jsx("rect", {
530
+ width: "18",
531
+ height: "18",
532
+ x: "3",
533
+ y: "3",
534
+ rx: "2"
535
+ }),
536
+ /* @__PURE__ */ jsx("path", { d: "M3 9h18" }),
537
+ /* @__PURE__ */ jsx("path", { d: "M3 15h18" })
538
+ ]
539
+ });
540
+ }
541
+
542
+ //#endregion
543
+ //#region src/ui/icons/type.tsx
544
+ function TypeIcon({ size, width, height, ...props }) {
545
+ return /* @__PURE__ */ jsxs("svg", {
546
+ xmlns: "http://www.w3.org/2000/svg",
547
+ width: size ?? width ?? 24,
548
+ height: size ?? height ?? 24,
549
+ viewBox: "0 0 24 24",
550
+ fill: "none",
551
+ stroke: "currentColor",
552
+ strokeWidth: 2,
553
+ strokeLinecap: "round",
554
+ strokeLinejoin: "round",
555
+ "aria-hidden": "true",
556
+ ...props,
557
+ children: [
558
+ /* @__PURE__ */ jsx("polyline", { points: "4 7 4 4 20 4 20 7" }),
559
+ /* @__PURE__ */ jsx("line", {
560
+ x1: "9",
561
+ x2: "15",
562
+ y1: "20",
563
+ y2: "20"
564
+ }),
565
+ /* @__PURE__ */ jsx("line", {
566
+ x1: "12",
567
+ x2: "12",
568
+ y1: "4",
569
+ y2: "20"
570
+ })
571
+ ]
572
+ });
573
+ }
574
+
575
+ //#endregion
576
+ //#region src/ui/icons/x.tsx
577
+ function XIcon({ size, width, height, ...props }) {
578
+ return /* @__PURE__ */ jsxs("svg", {
579
+ xmlns: "http://www.w3.org/2000/svg",
580
+ width: size ?? width ?? 24,
581
+ height: size ?? height ?? 24,
582
+ viewBox: "0 0 24 24",
583
+ fill: "none",
584
+ stroke: "currentColor",
585
+ strokeWidth: 2,
586
+ strokeLinecap: "round",
587
+ strokeLinejoin: "round",
588
+ "aria-hidden": "true",
589
+ ...props,
590
+ children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })]
591
+ });
592
+ }
593
+
594
+ //#endregion
595
+ //#region src/ui/editor-focus-scope.tsx
596
+ const FocusScopeContext = React$1.createContext(null);
597
+ function useEditorFocusScope() {
598
+ const context = React$1.useContext(FocusScopeContext);
599
+ if (!context) throw new Error("InspectorFocusScope must be used inside an InspectorFocusScopeProvider");
600
+ return context;
601
+ }
602
+ function EditorFocusScopeProvider({ children, clearSelectionOnBlur = true }) {
603
+ const { editor } = useCurrentEditor();
604
+ const scopeRefs = React$1.useRef(/* @__PURE__ */ new Set());
605
+ const handleFocusIn = React$1.useCallback((event) => {
606
+ if (editor) {
607
+ editor.isFocused = true;
608
+ const transaction = editor.state.tr.setMeta("focus", { event }).setMeta("addToHistory", false);
609
+ editor.view.dispatch(transaction);
610
+ }
611
+ }, [editor]);
612
+ const handleFocusOut = React$1.useCallback((event) => {
613
+ const nextFocus = event.relatedTarget;
614
+ if (![...scopeRefs.current].some((el) => nextFocus && el.contains(nextFocus)) && editor) {
615
+ editor.isFocused = false;
616
+ const transaction = editor.state.tr.setMeta("blur", { event }).setMeta("addToHistory", false);
617
+ if (clearSelectionOnBlur) transaction.setSelection(TextSelection.create(transaction.doc, 0));
618
+ editor.view.dispatch(transaction);
619
+ }
620
+ }, [editor]);
621
+ const registerScope = React$1.useCallback((el) => {
622
+ if (!el) return;
623
+ scopeRefs.current.add(el);
624
+ el.addEventListener("focusin", handleFocusIn);
625
+ el.addEventListener("focusout", handleFocusOut);
626
+ }, [handleFocusIn, handleFocusOut]);
627
+ const unregisterScope = React$1.useCallback((el) => {
628
+ if (!el) return;
629
+ scopeRefs.current.delete(el);
630
+ el.removeEventListener("focusin", handleFocusIn);
631
+ el.removeEventListener("focusout", handleFocusOut);
632
+ }, [handleFocusIn, handleFocusOut]);
633
+ React$1.useEffect(() => {
634
+ const defaultFocusPlugin = editor?.state.plugins.find((plugin) => plugin.spec.key === extensions.focusEventsPluginKey);
635
+ if (editor && defaultFocusPlugin) {
636
+ editor.unregisterPlugin(extensions.focusEventsPluginKey);
637
+ const pluginKey = new PluginKey("inspectorReactEmailFocusEvents");
638
+ editor.registerPlugin(new Plugin({
639
+ key: pluginKey,
640
+ view(view) {
641
+ registerScope(view.dom);
642
+ return { destroy() {
643
+ unregisterScope(view.dom);
644
+ } };
645
+ }
646
+ }));
647
+ return () => {
648
+ editor?.unregisterPlugin(pluginKey);
649
+ editor?.registerPlugin(defaultFocusPlugin);
650
+ };
651
+ }
652
+ }, [editor]);
653
+ return /* @__PURE__ */ jsx(FocusScopeContext.Provider, {
654
+ value: {
655
+ registerScope,
656
+ unregisterScope
657
+ },
658
+ children
659
+ });
660
+ }
661
+ function EditorFocusScope({ children }) {
662
+ const { registerScope, unregisterScope } = useEditorFocusScope();
663
+ return /* @__PURE__ */ jsx(Slot, {
664
+ ref: (element) => {
665
+ if (element) {
666
+ registerScope(element);
667
+ return () => {
668
+ unregisterScope(element);
669
+ };
670
+ }
671
+ },
672
+ children
673
+ });
674
+ }
675
+
676
+ //#endregion
677
+ //#region src/ui/inspector/config/node-meta.ts
678
+ const NODE_META = {
679
+ paragraph: {
680
+ icon: TypeIcon,
681
+ label: "Text"
682
+ },
683
+ heading: {
684
+ icon: Heading1Icon,
685
+ label: "Heading"
686
+ },
687
+ image: {
688
+ icon: ImageIcon,
689
+ label: "Image"
690
+ },
691
+ button: {
692
+ icon: MousePointerClickIcon,
693
+ label: "Button"
694
+ },
695
+ link: {
696
+ icon: LinkIcon,
697
+ label: "Link"
698
+ },
699
+ codeBlock: {
700
+ icon: CodeIcon,
701
+ label: "Code Block"
702
+ },
703
+ section: {
704
+ icon: LayoutIcon,
705
+ label: "Section"
706
+ },
707
+ div: {
708
+ icon: BoxIcon,
709
+ label: "Container"
710
+ },
711
+ footer: {
712
+ icon: BoxIcon,
713
+ label: "Footer"
714
+ },
715
+ blockquote: {
716
+ icon: TextQuoteIcon,
717
+ label: "Blockquote"
718
+ },
719
+ bulletList: {
720
+ icon: ListIcon,
721
+ label: "Bullet List"
722
+ },
723
+ orderedList: {
724
+ icon: ListIcon,
725
+ label: "Ordered List"
726
+ },
727
+ listItem: {
728
+ icon: MinusIcon,
729
+ label: "List Item"
730
+ },
731
+ table: {
732
+ icon: TableIcon,
733
+ label: "Table"
734
+ },
735
+ tableRow: {
736
+ icon: MinusIcon,
737
+ label: "Table Row"
738
+ },
739
+ tableCell: {
740
+ icon: BoxIcon,
741
+ label: "Table Cell"
742
+ },
743
+ tableHeader: {
744
+ icon: BoxIcon,
745
+ label: "Table Header"
746
+ },
747
+ horizontalRule: {
748
+ icon: MinusIcon,
749
+ label: "Divider"
750
+ },
751
+ global: {
752
+ icon: SquareRoundCornerIcon,
753
+ label: "Layout"
754
+ }
755
+ };
756
+ const DEFAULT_NODE_META = {
757
+ icon: BoxIcon,
758
+ label: "Element"
759
+ };
760
+ function getNodeMeta(nodeType) {
761
+ return NODE_META[nodeType] ?? DEFAULT_NODE_META;
762
+ }
763
+
764
+ //#endregion
765
+ //#region src/ui/inspector/root.tsx
766
+ const IGNORED_NODES = ["doc", "text"];
767
+ function getHierarchyAtPosition(editor, pos) {
768
+ if (!editor) return [];
769
+ const { doc } = editor.state;
770
+ const hierarchy = [];
771
+ const nodeAtPos = doc.nodeAt(pos);
772
+ if (nodeAtPos && !IGNORED_NODES.includes(nodeAtPos.type.name)) hierarchy.push({
773
+ nodeType: nodeAtPos.type.name,
774
+ nodeAttrs: { ...nodeAtPos.attrs },
775
+ nodePos: {
776
+ pos,
777
+ inside: pos
778
+ }
779
+ });
780
+ const resolvedPos = doc.resolve(pos);
781
+ for (let depth = resolvedPos.depth; depth > 0; depth--) {
782
+ const node = resolvedPos.node(depth);
783
+ const nodePos = resolvedPos.before(depth);
784
+ if (node && !IGNORED_NODES.includes(node.type.name)) {
785
+ if (!hierarchy.some((h) => h.nodePos.pos === nodePos)) hierarchy.push({
786
+ nodeType: node.type.name,
787
+ nodeAttrs: { ...node.attrs },
788
+ nodePos: {
789
+ pos: nodePos,
790
+ inside: nodePos
791
+ }
792
+ });
793
+ }
794
+ }
795
+ return hierarchy;
796
+ }
797
+ function getNodeHierarchy(editor) {
798
+ if (!editor) return [];
799
+ const { selection } = editor.state;
800
+ const hierarchy = [];
801
+ if (selection instanceof NodeSelection) {
802
+ const node = selection.node;
803
+ if (node && !IGNORED_NODES.includes(node.type.name)) hierarchy.push({
804
+ nodeType: node.type.name,
805
+ nodeAttrs: { ...node.attrs },
806
+ nodePos: {
807
+ pos: selection.from,
808
+ inside: selection.from
809
+ }
810
+ });
811
+ }
812
+ const { from } = selection;
813
+ const resolvedPos = editor.state.doc.resolve(from);
814
+ for (let depth = resolvedPos.depth; depth > 0; depth--) {
815
+ const node = resolvedPos.node(depth);
816
+ const pos = resolvedPos.before(depth);
817
+ if (node && !IGNORED_NODES.includes(node.type.name)) {
818
+ if (!hierarchy.some((h) => h.nodePos.pos === pos)) hierarchy.push({
819
+ nodeType: node.type.name,
820
+ nodeAttrs: { ...node.attrs },
821
+ nodePos: {
822
+ pos,
823
+ inside: pos
824
+ }
825
+ });
826
+ }
827
+ }
828
+ return hierarchy;
829
+ }
830
+ const InspectorContext = React$1.createContext(null);
831
+ function useInspector() {
832
+ const context = React$1.useContext(InspectorContext);
833
+ if (!context) throw new Error("useInspector can only be called from inside the InspectorContext. This probably means you forgot the <Inspector.Provider>");
834
+ return context;
835
+ }
836
+ const InspectorRoot = React$1.forwardRef(function InspectorRoot$1({ children, asChild, ...restProps }, forwardedRef) {
837
+ const { editor } = useCurrentEditor();
838
+ if (editor) {
839
+ if (!editor.extensionManager.extensions.some((extension) => extension.name === "theming")) throw new Error("Inspector.Provider requires the EmailTheming extension. Add EmailTheming (or EmailTheming.configure({ ... })) to your editor extensions.");
840
+ }
841
+ const target = useEditorState({
842
+ editor,
843
+ selector(context) {
844
+ if (!context.editor) return null;
845
+ if (!context.editor.isFocused) return "doc";
846
+ const { selection } = context.editor.state;
847
+ if (selection.content().size > 0 && selection instanceof TextSelection) {
848
+ const { $from } = selection;
849
+ for (let depth = $from.depth; depth > 0; depth--) if ($from.node(depth).type.name === "button") {
850
+ const pos = $from.before(depth);
851
+ const node = context.editor.state.doc.nodeAt(pos);
852
+ if (node) return {
853
+ nodeType: "button",
854
+ nodeAttrs: { ...node.attrs },
855
+ nodePos: {
856
+ pos,
857
+ inside: pos
858
+ }
859
+ };
860
+ break;
861
+ }
862
+ return "text";
863
+ }
864
+ const hierarchy = getNodeHierarchy(context.editor);
865
+ if (hierarchy.length > 0) {
866
+ const innermost = hierarchy[0];
867
+ const columnEntry = hierarchy.find((h) => h.nodeType === "columnsColumn");
868
+ return columnEntry && innermost.nodeType === "paragraph" ? columnEntry : innermost;
869
+ }
870
+ return "doc";
871
+ }
872
+ });
873
+ const pathFromRoot = React$1.useMemo(() => {
874
+ if (!editor) return [];
875
+ if (typeof target === "object" && target) {
876
+ const path = [...getHierarchyAtPosition(editor, target.nodePos.pos)].reverse();
877
+ return path.length > 0 ? path : [target];
878
+ }
879
+ if (target === "text") return [...getNodeHierarchy(editor)].reverse();
880
+ return [];
881
+ }, [editor, target]);
882
+ const Component = asChild ? Slot : "aside";
883
+ return /* @__PURE__ */ jsx(InspectorContext.Provider, {
884
+ value: {
885
+ target,
886
+ pathFromRoot
887
+ },
888
+ children: /* @__PURE__ */ jsx(EditorFocusScopeProvider, { children: /* @__PURE__ */ jsx(EditorFocusScope, { children: /* @__PURE__ */ jsx(Component, {
889
+ ref: forwardedRef,
890
+ ...restProps,
891
+ tabIndex: -1,
892
+ children
893
+ }) }) })
894
+ });
895
+ });
896
+
897
+ //#endregion
898
+ //#region src/ui/inspector/breadcrumb.tsx
899
+ function InspectorBreadcrumb({ children }) {
900
+ const { editor } = useCurrentEditor();
901
+ const { pathFromRoot } = useInspector();
902
+ const segments = React.useMemo(() => {
903
+ return [{
904
+ node: null,
905
+ focus() {
906
+ if (typeof document !== "undefined") {
907
+ const active = document.activeElement;
908
+ if (active instanceof HTMLElement) active.blur();
909
+ }
910
+ editor?.commands.blur();
911
+ }
912
+ }, ...pathFromRoot.map((focusedNode) => ({
913
+ node: focusedNode,
914
+ focus() {
915
+ editor?.commands.setNodeSelection(focusedNode.nodePos.pos);
916
+ editor?.commands.focus();
917
+ }
918
+ }))];
919
+ }, [editor, pathFromRoot]);
920
+ if (children) return children(segments);
921
+ return /* @__PURE__ */ jsx(BreadcrumbDefault, { segments });
922
+ }
923
+ const MAX_VISIBLE = 3;
924
+ function getVisibleSegments(segments) {
925
+ if (segments.length <= MAX_VISIBLE) return {
926
+ items: segments.map((s, i) => ({
927
+ segment: s,
928
+ index: i
929
+ })),
930
+ hasEllipsis: false
931
+ };
932
+ return {
933
+ items: [{
934
+ segment: segments[0],
935
+ index: 0
936
+ }, ...segments.slice(-2).map((s, i) => ({
937
+ segment: s,
938
+ index: segments.length - 2 + i
939
+ }))],
940
+ hasEllipsis: true
941
+ };
942
+ }
943
+ function BreadcrumbDefault({ segments }) {
944
+ const { items, hasEllipsis } = getVisibleSegments(segments);
945
+ return /* @__PURE__ */ jsx("nav", {
946
+ "data-re-inspector-breadcrumb": "",
947
+ children: /* @__PURE__ */ jsx("ol", {
948
+ "data-re-inspector-breadcrumb-list": "",
949
+ children: items.map(({ segment, index }, i) => {
950
+ const label = segment.node ? getNodeMeta(segment.node.nodeType).label : "Layout";
951
+ const isLast = index === segments.length - 1;
952
+ return /* @__PURE__ */ jsxs("li", {
953
+ "data-re-inspector-breadcrumb-item": "",
954
+ children: [
955
+ i !== 0 && /* @__PURE__ */ jsx("span", {
956
+ "data-re-inspector-breadcrumb-separator": "",
957
+ children: "/"
958
+ }),
959
+ i === 1 && hasEllipsis && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
960
+ "data-re-inspector-breadcrumb-ellipsis": "",
961
+ children: "…"
962
+ }), /* @__PURE__ */ jsx("span", {
963
+ "data-re-inspector-breadcrumb-separator": "",
964
+ children: "/"
965
+ })] }),
966
+ /* @__PURE__ */ jsx("button", {
967
+ type: "button",
968
+ "data-re-inspector-breadcrumb-button": "",
969
+ ...!isLast ? { "data-clickable": "" } : {},
970
+ onClick: () => segment.focus(),
971
+ children: label
972
+ })
973
+ ]
974
+ }, index);
975
+ })
976
+ })
977
+ });
978
+ }
979
+
980
+ //#endregion
981
+ //#region src/ui/inspector/hooks/use-drag-to-change.ts
982
+ function useDragToChange({ value, onCommit, min, step = 1 }) {
983
+ const startXRef = React$1.useRef(0);
984
+ const startValueRef = React$1.useRef(0);
985
+ const isDraggingRef = React$1.useRef(false);
986
+ React$1.useEffect(() => {
987
+ return () => {
988
+ document.body.style.removeProperty("cursor");
989
+ document.body.style.removeProperty("user-select");
990
+ };
991
+ }, []);
992
+ const onPointerDown = React$1.useCallback((e) => {
993
+ e.preventDefault();
994
+ isDraggingRef.current = true;
995
+ startXRef.current = e.clientX;
996
+ startValueRef.current = Number(value) || 0;
997
+ document.body.style.cursor = "ew-resize";
998
+ document.body.style.userSelect = "none";
999
+ e.currentTarget.setPointerCapture(e.pointerId);
1000
+ }, [value]);
1001
+ const onPointerMove = React$1.useCallback((e) => {
1002
+ if (!isDraggingRef.current) return;
1003
+ const dx = e.clientX - startXRef.current;
1004
+ const effectiveStep = e.shiftKey ? step * 10 : step;
1005
+ const delta = Math.round(dx / 2) * effectiveStep;
1006
+ onCommit(Math.max(min ?? Number.NEGATIVE_INFINITY, startValueRef.current + delta));
1007
+ }, [
1008
+ onCommit,
1009
+ min,
1010
+ step
1011
+ ]);
1012
+ const onPointerUp = React$1.useCallback(() => {
1013
+ isDraggingRef.current = false;
1014
+ document.body.style.removeProperty("cursor");
1015
+ document.body.style.removeProperty("user-select");
1016
+ }, []);
1017
+ return { dragProps: {
1018
+ onPointerDown,
1019
+ onPointerMove,
1020
+ onPointerUp,
1021
+ onPointerCancel: onPointerUp,
1022
+ style: { cursor: "ew-resize" }
1023
+ } };
1024
+ }
1025
+
1026
+ //#endregion
1027
+ //#region src/ui/inspector/hooks/use-numeric-input.ts
1028
+ function toDisplayString(v) {
1029
+ if (v === "" || v === void 0 || v === null || Number.isNaN(v)) return "";
1030
+ return String(v);
1031
+ }
1032
+ function useNumericInput({ value, onCommit, allowEmpty = true, min, fallbackValue }) {
1033
+ const [displayValue, setDisplayValue] = React$1.useState(() => toDisplayString(value));
1034
+ const isFocusedRef = React$1.useRef(false);
1035
+ const cancelledRef = React$1.useRef(false);
1036
+ React$1.useEffect(() => {
1037
+ if (!isFocusedRef.current) setDisplayValue(toDisplayString(value));
1038
+ }, [value]);
1039
+ const commit = React$1.useCallback((raw) => {
1040
+ const trimmed = raw.trim();
1041
+ if (trimmed === "") {
1042
+ if (allowEmpty) onCommit("");
1043
+ else {
1044
+ setDisplayValue("0");
1045
+ onCommit(0);
1046
+ }
1047
+ return;
1048
+ }
1049
+ const num = Number(trimmed);
1050
+ if (Number.isNaN(num)) {
1051
+ setDisplayValue(toDisplayString(value));
1052
+ return;
1053
+ }
1054
+ const clamped = Math.max(num, min ?? Number.NEGATIVE_INFINITY);
1055
+ setDisplayValue(String(clamped));
1056
+ onCommit(clamped);
1057
+ }, [
1058
+ value,
1059
+ onCommit,
1060
+ allowEmpty,
1061
+ min
1062
+ ]);
1063
+ return {
1064
+ displayValue,
1065
+ onChange: React$1.useCallback((e) => {
1066
+ setDisplayValue(e.target.value);
1067
+ }, []),
1068
+ onBlur: React$1.useCallback(() => {
1069
+ isFocusedRef.current = false;
1070
+ if (cancelledRef.current) {
1071
+ cancelledRef.current = false;
1072
+ return;
1073
+ }
1074
+ commit(displayValue);
1075
+ }, [commit, displayValue]),
1076
+ onFocus: React$1.useCallback((e) => {
1077
+ isFocusedRef.current = true;
1078
+ e.target.select();
1079
+ }, []),
1080
+ onKeyDown: React$1.useCallback((e) => {
1081
+ if (e.key === "Enter") {
1082
+ commit(displayValue);
1083
+ e.target.blur();
1084
+ }
1085
+ if (e.key === "Escape") {
1086
+ cancelledRef.current = true;
1087
+ setDisplayValue(toDisplayString(value));
1088
+ e.target.blur();
1089
+ }
1090
+ if (e.key === "ArrowUp" || e.key === "ArrowDown") {
1091
+ e.preventDefault();
1092
+ const step = e.shiftKey ? 10 : 1;
1093
+ const trimmed = displayValue.trim();
1094
+ const parsed = Number(trimmed);
1095
+ const current = trimmed === "" || Number.isNaN(parsed) ? fallbackValue ?? 0 : parsed;
1096
+ const next = Math.max(min ?? Number.NEGATIVE_INFINITY, e.key === "ArrowUp" ? current + step : current - step);
1097
+ setDisplayValue(String(next));
1098
+ onCommit(next);
1099
+ }
1100
+ }, [
1101
+ commit,
1102
+ displayValue,
1103
+ value,
1104
+ onCommit,
1105
+ min,
1106
+ fallbackValue
1107
+ ])
1108
+ };
1109
+ }
1110
+
1111
+ //#endregion
1112
+ //#region src/ui/inspector/utils/is-valid-hex-color.ts
1113
+ function isValidHexColor(value) {
1114
+ return /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(value);
1115
+ }
1116
+ function normalizeHex(value) {
1117
+ if (!value) return "#000000";
1118
+ const v = value.trim();
1119
+ const shortHex = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(v);
1120
+ if (shortHex) return `#${shortHex[1]}${shortHex[1]}${shortHex[2]}${shortHex[2]}${shortHex[3]}${shortHex[3]}`;
1121
+ if (/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(v)) return v;
1122
+ return "#000000";
1123
+ }
1124
+
1125
+ //#endregion
1126
+ //#region src/ui/inspector/primitives/color-input.tsx
1127
+ function ColorInput({ value, onChange, className }) {
1128
+ return /* @__PURE__ */ jsxs("span", {
1129
+ "data-re-inspector-color-control": "",
1130
+ className,
1131
+ children: [/* @__PURE__ */ jsx("input", {
1132
+ type: "color",
1133
+ "data-re-inspector-color-trigger": "",
1134
+ value: normalizeHex(value),
1135
+ onChange: (e) => onChange(e.target.value)
1136
+ }), /* @__PURE__ */ jsx("input", {
1137
+ type: "text",
1138
+ "data-re-inspector-color-hex": "",
1139
+ value,
1140
+ onChange: (e) => onChange(e.target.value)
1141
+ })]
1142
+ });
1143
+ }
1144
+
1145
+ //#endregion
1146
+ //#region src/ui/inspector/primitives/icon-button.tsx
1147
+ function IconButton({ className, children, ...rest }) {
1148
+ return /* @__PURE__ */ jsx("button", {
1149
+ type: "button",
1150
+ "data-re-inspector-icon-button": "",
1151
+ className,
1152
+ ...rest,
1153
+ children
1154
+ });
1155
+ }
1156
+
1157
+ //#endregion
1158
+ //#region src/ui/inspector/primitives/label.tsx
1159
+ function Label({ className, ...rest }) {
1160
+ return /* @__PURE__ */ jsx("label", {
1161
+ "data-re-inspector-label": "",
1162
+ className,
1163
+ ...rest
1164
+ });
1165
+ }
1166
+
1167
+ //#endregion
1168
+ //#region src/ui/inspector/primitives/select.tsx
1169
+ function SelectRoot({ children, ...rest }) {
1170
+ return /* @__PURE__ */ jsx("select", {
1171
+ "data-re-inspector-select": "",
1172
+ ...rest,
1173
+ children
1174
+ });
1175
+ }
1176
+ function SelectItem(props) {
1177
+ return /* @__PURE__ */ jsx("option", { ...props });
1178
+ }
1179
+ const Root$2 = SelectRoot;
1180
+ const Item$1 = SelectItem;
1181
+
1182
+ //#endregion
1183
+ //#region src/ui/inspector/primitives/text.tsx
1184
+ function Text({ size, color, className, ...rest }) {
1185
+ return /* @__PURE__ */ jsx("span", {
1186
+ "data-re-inspector-text": "",
1187
+ ...size ? { "data-size": size } : {},
1188
+ ...color ? { "data-color": color } : {},
1189
+ className,
1190
+ ...rest
1191
+ });
1192
+ }
1193
+
1194
+ //#endregion
1195
+ //#region src/ui/inspector/primitives/text-field.tsx
1196
+ const TextField = React$1.forwardRef(function TextField$1({ className, ...rest }, ref) {
1197
+ return /* @__PURE__ */ jsx("input", {
1198
+ ref,
1199
+ "data-re-inspector-input": "",
1200
+ className,
1201
+ ...rest
1202
+ });
1203
+ });
1204
+
1205
+ //#endregion
1206
+ //#region src/ui/inspector/primitives/textarea.tsx
1207
+ const Textarea = React$1.forwardRef(function Textarea$1({ className, ...rest }, ref) {
1208
+ return /* @__PURE__ */ jsx("textarea", {
1209
+ ref,
1210
+ "data-re-inspector-input": "",
1211
+ "data-type": "textarea",
1212
+ className,
1213
+ ...rest
1214
+ });
1215
+ });
1216
+
1217
+ //#endregion
1218
+ //#region src/ui/inspector/primitives/toggle-group.tsx
1219
+ const ToggleGroupContext = React$1.createContext(null);
1220
+ function Root$1({ value, onValueChange, children, className }) {
1221
+ return /* @__PURE__ */ jsx(ToggleGroupContext.Provider, {
1222
+ value: {
1223
+ value,
1224
+ onValueChange
1225
+ },
1226
+ children: /* @__PURE__ */ jsx("div", {
1227
+ "data-re-inspector-toggle-group": "",
1228
+ className,
1229
+ role: "group",
1230
+ children
1231
+ })
1232
+ });
1233
+ }
1234
+ function Item({ value, children, ...rest }) {
1235
+ const ctx = React$1.useContext(ToggleGroupContext);
1236
+ const isActive = ctx?.value === value;
1237
+ return /* @__PURE__ */ jsx("button", {
1238
+ type: "button",
1239
+ "data-re-inspector-toggle-item": "",
1240
+ ...isActive ? { "data-active": "" } : {},
1241
+ "aria-pressed": isActive,
1242
+ ...rest,
1243
+ onClick: (e) => {
1244
+ ctx?.onValueChange(value);
1245
+ rest.onClick?.(e);
1246
+ },
1247
+ children
1248
+ });
1249
+ }
1250
+
1251
+ //#endregion
1252
+ //#region src/ui/inspector/primitives/tooltip.tsx
1253
+ function TooltipRoot({ children, ...rest }) {
1254
+ return /* @__PURE__ */ jsx("span", {
1255
+ "data-re-inspector-tooltip": "",
1256
+ ...rest,
1257
+ children
1258
+ });
1259
+ }
1260
+ function TooltipTrigger({ children, ...rest }) {
1261
+ return /* @__PURE__ */ jsx("span", {
1262
+ "data-re-inspector-tooltip-trigger": "",
1263
+ ...rest,
1264
+ children
1265
+ });
1266
+ }
1267
+ function TooltipContent({ children, ...rest }) {
1268
+ return /* @__PURE__ */ jsx("span", {
1269
+ "data-re-inspector-tooltip-content": "",
1270
+ ...rest,
1271
+ children
1272
+ });
1273
+ }
1274
+ const Root = TooltipRoot;
1275
+ const Trigger = TooltipTrigger;
1276
+ const Content = TooltipContent;
1277
+
1278
+ //#endregion
1279
+ //#region src/ui/inspector/components/number-input.tsx
1280
+ function NumberInput({ icon, value, onChange, placeholder, unit, min, unitOptions, onUnitChange }) {
1281
+ const { displayValue, ...handlers } = useNumericInput({
1282
+ value,
1283
+ onCommit: onChange,
1284
+ min,
1285
+ fallbackValue: placeholder ? Number(placeholder) : void 0
1286
+ });
1287
+ const { dragProps } = useDragToChange({
1288
+ value,
1289
+ onCommit: onChange,
1290
+ min
1291
+ });
1292
+ const hasUnitSelect = unitOptions && unitOptions.length > 1 && onUnitChange;
1293
+ return /* @__PURE__ */ jsxs("span", {
1294
+ "data-re-inspector-number": "",
1295
+ children: [
1296
+ icon && /* @__PURE__ */ jsx("span", {
1297
+ className: "pointer-events-none",
1298
+ "aria-hidden": true,
1299
+ children: icon
1300
+ }),
1301
+ /* @__PURE__ */ jsx(TextField, {
1302
+ value: displayValue,
1303
+ placeholder,
1304
+ type: "text",
1305
+ inputMode: "numeric",
1306
+ "data-type": "number",
1307
+ ...handlers
1308
+ }),
1309
+ hasUnitSelect ? /* @__PURE__ */ jsx(Root$2, {
1310
+ value: unit,
1311
+ onChange: (e) => onUnitChange(e.target.value),
1312
+ children: unitOptions.map((opt) => /* @__PURE__ */ jsx(Item$1, {
1313
+ value: opt,
1314
+ children: opt
1315
+ }, opt))
1316
+ }) : unit && /* @__PURE__ */ jsx("span", {
1317
+ "data-re-inspector-unit": "",
1318
+ ...dragProps,
1319
+ children: unit
1320
+ })
1321
+ ]
1322
+ });
1323
+ }
1324
+
1325
+ //#endregion
1326
+ //#region src/ui/inspector/components/prop-row.tsx
1327
+ function PropRow({ children, className }) {
1328
+ return /* @__PURE__ */ jsx("div", {
1329
+ "data-re-inspector-prop-row": "",
1330
+ className,
1331
+ children
1332
+ });
1333
+ }
1334
+
1335
+ //#endregion
1336
+ //#region src/ui/inspector/components/section.tsx
1337
+ function Section({ title, children, initialCollapsed = false, onAdd, onRemove }) {
1338
+ const [collapsed, setCollapsed] = React$1.useState(initialCollapsed);
1339
+ return /* @__PURE__ */ jsxs("div", {
1340
+ "data-re-inspector-section": "",
1341
+ ...title ? { "data-has-title": "" } : {},
1342
+ children: [title && /* @__PURE__ */ jsxs("div", {
1343
+ "data-re-inspector-section-header": "",
1344
+ children: [
1345
+ /* @__PURE__ */ jsx("button", {
1346
+ type: "button",
1347
+ "data-re-inspector-section-toggle": "",
1348
+ onClick: () => setCollapsed((c) => !c),
1349
+ children: /* @__PURE__ */ jsx(Text, { children: title })
1350
+ }),
1351
+ collapsed && onAdd && /* @__PURE__ */ jsxs(Root, { children: [/* @__PURE__ */ jsx(Trigger, { children: /* @__PURE__ */ jsx(IconButton, {
1352
+ onClick: onAdd,
1353
+ "aria-label": `Add ${title}`,
1354
+ children: /* @__PURE__ */ jsx(PlusIcon, { size: 16 })
1355
+ }) }), /* @__PURE__ */ jsx(Content, { children: `Add ${title}` })] }),
1356
+ !collapsed && onRemove && /* @__PURE__ */ jsxs(Root, { children: [/* @__PURE__ */ jsx(Trigger, { children: /* @__PURE__ */ jsx(IconButton, {
1357
+ onClick: onRemove,
1358
+ "aria-label": `Remove ${title}`,
1359
+ children: /* @__PURE__ */ jsx(MinusIcon, { size: 16 })
1360
+ }) }), /* @__PURE__ */ jsx(Content, { children: `Remove ${title}` })] })
1361
+ ]
1362
+ }), !collapsed && children && /* @__PURE__ */ jsx("div", {
1363
+ "data-re-inspector-section-body": "",
1364
+ children
1365
+ })]
1366
+ });
1367
+ }
1368
+
1369
+ //#endregion
1370
+ //#region src/ui/inspector/document.tsx
1371
+ function ensureAllProperties(currentStyles, themeDefaults) {
1372
+ return currentStyles.map((group) => {
1373
+ const defaultGroup = themeDefaults.find((g) => group.id ? g.id === group.id : g.title === group.title);
1374
+ if (!defaultGroup || defaultGroup.inputs.length === 0) return group;
1375
+ const existingProps = new Set(group.inputs.map((i) => `${i.classReference}:${i.prop}`));
1376
+ const missingInputs = defaultGroup.inputs.filter((defaultInput) => !existingProps.has(`${defaultInput.classReference}:${defaultInput.prop}`)).map((defaultInput) => {
1377
+ const propDef = SUPPORTED_CSS_PROPERTIES[defaultInput.prop];
1378
+ if (propDef && propDef.type === "number") return {
1379
+ ...defaultInput,
1380
+ value: "",
1381
+ placeholder: String(propDef.defaultValue)
1382
+ };
1383
+ return { ...defaultInput };
1384
+ });
1385
+ if (missingInputs.length === 0) return group;
1386
+ return {
1387
+ ...group,
1388
+ inputs: [...group.inputs, ...missingInputs]
1389
+ };
1390
+ });
1391
+ }
1392
+ function applyStyleChange(styles, themeName, { classReference, prop, newValue }) {
1393
+ let found = false;
1394
+ const updatedStyles = styles.map((styleGroup) => {
1395
+ if (styleGroup.inputs.find((input) => input.classReference === classReference && input.prop === prop)) {
1396
+ found = true;
1397
+ return {
1398
+ ...styleGroup,
1399
+ inputs: styleGroup.inputs.map((input) => {
1400
+ if (input.classReference === classReference && input.prop === prop) return {
1401
+ ...input,
1402
+ value: newValue
1403
+ };
1404
+ return input;
1405
+ })
1406
+ };
1407
+ }
1408
+ return styleGroup;
1409
+ });
1410
+ if (found) return updatedStyles;
1411
+ const propDef = SUPPORTED_CSS_PROPERTIES[prop] ?? null;
1412
+ return updatedStyles.map((styleGroup) => {
1413
+ if (styleGroup.classReference !== classReference) return styleGroup;
1414
+ const defaultInput = EDITOR_THEMES[themeName].find((g) => styleGroup.id ? g.id === styleGroup.id : g.title === styleGroup.title)?.inputs.find((i) => i.prop === prop && i.classReference === classReference);
1415
+ if (defaultInput) return {
1416
+ ...styleGroup,
1417
+ inputs: [...styleGroup.inputs, {
1418
+ ...defaultInput,
1419
+ value: newValue
1420
+ }]
1421
+ };
1422
+ if (propDef) return {
1423
+ ...styleGroup,
1424
+ inputs: [...styleGroup.inputs, {
1425
+ label: propDef.label,
1426
+ type: propDef.type,
1427
+ value: newValue,
1428
+ prop,
1429
+ classReference,
1430
+ unit: propDef.unit,
1431
+ options: propDef.options
1432
+ }]
1433
+ };
1434
+ return styleGroup;
1435
+ });
1436
+ }
1437
+ function InspectorDocument({ children }) {
1438
+ const { editor } = useCurrentEditor();
1439
+ const theming = useEmailTheming(editor);
1440
+ const { target } = useInspector();
1441
+ if (!editor || !theming) return null;
1442
+ const themeDefaults = EDITOR_THEMES[theming.theme];
1443
+ const groups = ensureAllProperties(theming.styles, themeDefaults);
1444
+ function setGlobalStyle(classReference, property, value) {
1445
+ setGlobalStyles(editor, applyStyleChange(theming.styles, theming.theme, {
1446
+ classReference,
1447
+ prop: property,
1448
+ newValue: value
1449
+ }));
1450
+ }
1451
+ function batchSetGlobalStyle(changes) {
1452
+ let styles = theming.styles;
1453
+ for (const change of changes) styles = applyStyleChange(styles, theming.theme, {
1454
+ classReference: change.classReference,
1455
+ prop: change.property,
1456
+ newValue: change.value
1457
+ });
1458
+ setGlobalStyles(editor, styles);
1459
+ }
1460
+ function findStyleValue(classReference, prop) {
1461
+ for (const group of groups) {
1462
+ const input = group.inputs.find((i) => i.classReference === classReference && i.prop === prop);
1463
+ if (input && input.value !== void 0) return input.value;
1464
+ }
1465
+ for (const group of themeDefaults) {
1466
+ const input = group.inputs.find((i) => i.classReference === classReference && i.prop === prop);
1467
+ if (input && input.value !== void 0) return input.value;
1468
+ }
1469
+ return SUPPORTED_CSS_PROPERTIES[prop]?.defaultValue ?? "";
1470
+ }
1471
+ if (target !== "doc") return null;
1472
+ const context = {
1473
+ styles: groups,
1474
+ setGlobalStyle,
1475
+ batchSetGlobalStyle,
1476
+ findStyleValue
1477
+ };
1478
+ if (children) return /* @__PURE__ */ jsx(Fragment, { children: children(context) });
1479
+ return /* @__PURE__ */ jsx(InspectorDocumentDefaults, { context });
1480
+ }
1481
+ function InspectorDocumentDefaults({ context }) {
1482
+ const { findStyleValue, setGlobalStyle } = context;
1483
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Section, {
1484
+ title: "Background",
1485
+ children: [/* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Color" }), /* @__PURE__ */ jsx(ColorInput, {
1486
+ value: String(findStyleValue("body", "backgroundColor") ?? ""),
1487
+ onChange: (v) => setGlobalStyle("body", "backgroundColor", v)
1488
+ })] }), /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Padding" }), /* @__PURE__ */ jsx(NumberInput, {
1489
+ value: findStyleValue("body", "padding") ?? "",
1490
+ onChange: (v) => setGlobalStyle("body", "padding", v),
1491
+ unit: "px"
1492
+ })] })]
1493
+ }), /* @__PURE__ */ jsxs(Section, {
1494
+ title: "Container",
1495
+ children: [
1496
+ /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Color" }), /* @__PURE__ */ jsx(ColorInput, {
1497
+ value: String(findStyleValue("container", "backgroundColor") ?? ""),
1498
+ onChange: (v) => setGlobalStyle("container", "backgroundColor", v)
1499
+ })] }),
1500
+ /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Width" }), /* @__PURE__ */ jsx(NumberInput, {
1501
+ value: findStyleValue("container", "width") ?? "",
1502
+ onChange: (v) => setGlobalStyle("container", "width", v),
1503
+ unit: "px"
1504
+ })] }),
1505
+ /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Padding" }), /* @__PURE__ */ jsx(NumberInput, {
1506
+ value: findStyleValue("container", "padding") ?? "",
1507
+ onChange: (v) => setGlobalStyle("container", "padding", v),
1508
+ unit: "px"
1509
+ })] }),
1510
+ /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Rounded" }), /* @__PURE__ */ jsx(NumberInput, {
1511
+ value: findStyleValue("container", "borderRadius") ?? "",
1512
+ onChange: (v) => setGlobalStyle("container", "borderRadius", v),
1513
+ unit: "px"
1514
+ })] })
1515
+ ]
1516
+ })] });
1517
+ }
1518
+
1519
+ //#endregion
1520
+ //#region src/ui/inspector/hooks/use-document-colors.ts
1521
+ const COLOR_CSS_PROPERTIES = [
1522
+ "color",
1523
+ "backgroundColor",
1524
+ "borderColor",
1525
+ "borderTopColor",
1526
+ "borderRightColor",
1527
+ "borderBottomColor",
1528
+ "borderLeftColor"
1529
+ ];
1530
+ function useDocumentColors(editor) {
1531
+ const theming = useEmailTheming(editor);
1532
+ const globalColors = React$1.useMemo(() => {
1533
+ const colors = /* @__PURE__ */ new Set();
1534
+ const cssJs = stylesToCss(theming.styles, theming.theme);
1535
+ for (const componentStyles of Object.values(cssJs)) {
1536
+ if (!componentStyles || typeof componentStyles !== "object") continue;
1537
+ for (const prop of COLOR_CSS_PROPERTIES) {
1538
+ const value = componentStyles[prop];
1539
+ if (typeof value === "string") addColor(colors, value);
1540
+ }
1541
+ }
1542
+ return Array.from(colors);
1543
+ }, [theming]);
1544
+ const inlineColors = useEditorState({
1545
+ editor,
1546
+ selector: ({ editor: ed }) => {
1547
+ if (!ed) return [];
1548
+ const colors = /* @__PURE__ */ new Set();
1549
+ ed.state.doc.descendants((node) => {
1550
+ for (const mark of node.marks) if (mark.type.name === "textStyle" && mark.attrs.color) addColor(colors, mark.attrs.color);
1551
+ const style = node.attrs.style;
1552
+ if (style) extractColorsFromInlineStyle(colors, style);
1553
+ });
1554
+ return Array.from(colors);
1555
+ },
1556
+ equalityFn: (a, b) => {
1557
+ if (a === b) return true;
1558
+ if (!a || !b) return false;
1559
+ return arrayShallowEqual(a, b);
1560
+ }
1561
+ }) ?? [];
1562
+ return React$1.useMemo(() => {
1563
+ if (globalColors.length === 0) return inlineColors;
1564
+ if (inlineColors.length === 0) return globalColors;
1565
+ const merged = new Set([...globalColors, ...inlineColors]);
1566
+ return Array.from(merged);
1567
+ }, [globalColors, inlineColors]);
1568
+ }
1569
+ const COLOR_STYLE_PROPS = [
1570
+ "color",
1571
+ "background-color",
1572
+ "border-color",
1573
+ "border-top-color",
1574
+ "border-right-color",
1575
+ "border-bottom-color",
1576
+ "border-left-color"
1577
+ ];
1578
+ function extractColorsFromInlineStyle(colors, style) {
1579
+ for (const prop of COLOR_STYLE_PROPS) {
1580
+ const regex = new RegExp(`${prop}\\s*:\\s*([^;]+)`, "i");
1581
+ const match = style.match(regex);
1582
+ if (match) addColor(colors, match[1].trim());
1583
+ }
1584
+ }
1585
+ function addColor(colors, raw) {
1586
+ const value = raw.trim().toLowerCase();
1587
+ if (!value || value === "#000000" || value === "#ffffff") return;
1588
+ if (isValidHexColor(value)) {
1589
+ const normalized = expandToSix(value);
1590
+ colors.add(normalized);
1591
+ }
1592
+ }
1593
+ function expandToSix(hex) {
1594
+ const h = hex.slice(1);
1595
+ if (h.length === 3) return `#${h[0]}${h[0]}${h[1]}${h[1]}${h[2]}${h[2]}`;
1596
+ if (h.length === 4) return `#${h[0]}${h[0]}${h[1]}${h[1]}${h[2]}${h[2]}`;
1597
+ if (h.length === 8) return `#${h.slice(0, 6)}`;
1598
+ return hex;
1599
+ }
1600
+ function arrayShallowEqual(a, b) {
1601
+ if (a.length !== b.length) return false;
1602
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
1603
+ return true;
1604
+ }
1605
+
1606
+ //#endregion
1607
+ //#region src/ui/inspector/config/attribute-schema.ts
1608
+ const LOCAL_PROPS_SCHEMA = {
1609
+ class: {
1610
+ label: "Class",
1611
+ type: "text",
1612
+ defaultValue: ""
1613
+ },
1614
+ width: {
1615
+ label: "Width",
1616
+ type: "number",
1617
+ unit: "px",
1618
+ placeholder: "auto",
1619
+ defaultValue: 100
1620
+ },
1621
+ height: {
1622
+ label: "Height",
1623
+ type: "number",
1624
+ unit: "px",
1625
+ placeholder: "auto",
1626
+ defaultValue: 100
1627
+ },
1628
+ alt: {
1629
+ label: "Alt",
1630
+ type: "textarea",
1631
+ defaultValue: ""
1632
+ },
1633
+ align: {
1634
+ label: "Align",
1635
+ type: "select",
1636
+ defaultValue: "left",
1637
+ options: {
1638
+ left: "Left",
1639
+ center: "Center",
1640
+ right: "Right"
1641
+ }
1642
+ },
1643
+ alignment: {
1644
+ label: "Alignment",
1645
+ type: "select",
1646
+ defaultValue: "left",
1647
+ options: {
1648
+ left: "Left",
1649
+ center: "Center",
1650
+ right: "Right"
1651
+ }
1652
+ },
1653
+ level: {
1654
+ label: "Level",
1655
+ type: "number",
1656
+ defaultValue: 1
1657
+ },
1658
+ src: {
1659
+ label: "Source",
1660
+ type: "text",
1661
+ defaultValue: "",
1662
+ options: { enableVariables: true }
1663
+ },
1664
+ href: {
1665
+ label: "Link",
1666
+ type: "text",
1667
+ defaultValue: ""
1668
+ },
1669
+ title: {
1670
+ label: "Title",
1671
+ type: "text",
1672
+ defaultValue: ""
1673
+ },
1674
+ language: {
1675
+ label: "Language",
1676
+ type: "select",
1677
+ defaultValue: "javascript",
1678
+ options: {
1679
+ css: "CSS",
1680
+ go: "Go",
1681
+ html: "HTML",
1682
+ javascript: "JavaScript",
1683
+ jsx: "JSX",
1684
+ json: "JSON",
1685
+ markdown: "Markdown",
1686
+ php: "PHP",
1687
+ plaintext: "Plain text",
1688
+ python: "Python",
1689
+ ruby: "Ruby",
1690
+ shell: "Shell",
1691
+ sql: "SQL",
1692
+ svg: "svg",
1693
+ typescript: "TypeScript"
1694
+ }
1695
+ },
1696
+ theme: {
1697
+ label: "Theme",
1698
+ type: "select",
1699
+ defaultValue: "default",
1700
+ options: {
1701
+ default: "Default",
1702
+ atomDark: "Atom Dark",
1703
+ oneLight: "One Light",
1704
+ dracula: "Dracula",
1705
+ nord: "Nord",
1706
+ duotoneDark: "Duotone Dark",
1707
+ duotoneForest: "Duotone Forest",
1708
+ duotoneLight: "Duotone Light",
1709
+ duotoneSea: "Duotone Sea",
1710
+ duotoneSpace: "Duotone Space",
1711
+ vesper: "Vesper",
1712
+ vs: "VSCode Light",
1713
+ vscDarkPlus: "VSCode Dark"
1714
+ },
1715
+ customUpdate: ({ newValue }) => {
1716
+ loadPrismTheme(newValue);
1717
+ }
1718
+ }
1719
+ };
1720
+ const EXCLUDED_ATTRIBUTES = [
1721
+ "style",
1722
+ "class",
1723
+ "width",
1724
+ "height",
1725
+ "align",
1726
+ "alignment",
1727
+ "href",
1728
+ "id",
1729
+ "title",
1730
+ "lang",
1731
+ "dir",
1732
+ "data-id"
1733
+ ];
1734
+ const LIVEBLOCKS_INTERNAL_PROPS = ["ychange"];
1735
+
1736
+ //#endregion
1737
+ //#region src/ui/inspector/sections/attributes.tsx
1738
+ function AttributesSection({ nodeType, getAttr, setAttr, initialCollapsed = false }) {
1739
+ const nodeAttrs = getVisibleAttributes(nodeType, getAttr);
1740
+ if (nodeAttrs.length === 0) return null;
1741
+ return /* @__PURE__ */ jsx(Section, {
1742
+ title: "Attributes",
1743
+ initialCollapsed,
1744
+ children: nodeAttrs.map(({ name, config, value }) => /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: config.label }), config.type === "select" && config.options ? /* @__PURE__ */ jsx(Root$2, {
1745
+ value: String(value ?? config.defaultValue),
1746
+ onChange: (e) => {
1747
+ const newValue = e.target.value;
1748
+ setAttr(name, newValue);
1749
+ config.customUpdate?.({ newValue });
1750
+ },
1751
+ children: Object.entries(config.options).filter(([, v]) => typeof v === "string").map(([val, label]) => /* @__PURE__ */ jsx(Item$1, {
1752
+ value: val,
1753
+ children: label
1754
+ }, val))
1755
+ }) : config.type === "number" ? /* @__PURE__ */ jsx(NumberInput, {
1756
+ value: value ?? config.defaultValue,
1757
+ onChange: (v) => setAttr(name, v),
1758
+ unit: config.unit,
1759
+ min: 0
1760
+ }) : config.type === "textarea" ? /* @__PURE__ */ jsx(Textarea, {
1761
+ value: String(value ?? config.defaultValue),
1762
+ onChange: (e) => setAttr(name, e.target.value)
1763
+ }) : /* @__PURE__ */ jsx(TextField, {
1764
+ type: "text",
1765
+ value: String(value ?? config.defaultValue),
1766
+ onChange: (e) => setAttr(name, e.target.value)
1767
+ })] }, name))
1768
+ });
1769
+ }
1770
+ function getVisibleAttributes(_nodeType, getAttr) {
1771
+ const results = [];
1772
+ for (const [name, config] of Object.entries(LOCAL_PROPS_SCHEMA)) {
1773
+ if (EXCLUDED_ATTRIBUTES.includes(name)) continue;
1774
+ if (LIVEBLOCKS_INTERNAL_PROPS.includes(name)) continue;
1775
+ const value = getAttr(name);
1776
+ if (value !== void 0 && value !== null) results.push({
1777
+ name,
1778
+ config,
1779
+ value
1780
+ });
1781
+ }
1782
+ return results;
1783
+ }
1784
+
1785
+ //#endregion
1786
+ //#region src/ui/inspector/sections/background.tsx
1787
+ function BackgroundSection({ getStyle, setStyle, initialCollapsed = false }) {
1788
+ const value = String(getStyle("backgroundColor") ?? "");
1789
+ return /* @__PURE__ */ jsx(Section, {
1790
+ title: "Background",
1791
+ initialCollapsed,
1792
+ children: /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Color" }), /* @__PURE__ */ jsx(ColorInput, {
1793
+ value,
1794
+ onChange: (v) => setStyle("backgroundColor", v)
1795
+ })] })
1796
+ });
1797
+ }
1798
+
1799
+ //#endregion
1800
+ //#region src/ui/inspector/components/border-picker.tsx
1801
+ const SIDES = [
1802
+ {
1803
+ side: "Top",
1804
+ icon: /* @__PURE__ */ jsx(PanelTopIcon, { size: 14 })
1805
+ },
1806
+ {
1807
+ side: "Right",
1808
+ icon: /* @__PURE__ */ jsx(PanelRightIcon, { size: 14 })
1809
+ },
1810
+ {
1811
+ side: "Bottom",
1812
+ icon: /* @__PURE__ */ jsx(PanelBottomIcon, { size: 14 })
1813
+ },
1814
+ {
1815
+ side: "Left",
1816
+ icon: /* @__PURE__ */ jsx(PanelLeftIcon, { size: 14 })
1817
+ }
1818
+ ];
1819
+ function getSideValue(styleObject, side, prop) {
1820
+ const sideKey = `border${side}${prop}`;
1821
+ const shorthandKey = `border${prop}`;
1822
+ return styleObject[sideKey] ?? styleObject[shorthandKey];
1823
+ }
1824
+ function allSidesEqual(styleObject) {
1825
+ const topWidth = getSideValue(styleObject, "Top", "Width");
1826
+ const topColor = getSideValue(styleObject, "Top", "Color");
1827
+ const topStyle = getSideValue(styleObject, "Top", "Style");
1828
+ return SIDES.every(({ side }) => {
1829
+ return getSideValue(styleObject, side, "Width") === topWidth && getSideValue(styleObject, side, "Color") === topColor && getSideValue(styleObject, side, "Style") === topStyle;
1830
+ });
1831
+ }
1832
+ const BORDER_STYLE_OPTIONS = SUPPORTED_CSS_PROPERTIES.borderStyle.options;
1833
+ function BorderPicker({ styleObject, onChange }) {
1834
+ const [expanded, setExpanded] = React$1.useState(() => !allSidesEqual(styleObject));
1835
+ const handleModeChange = (mode) => {
1836
+ if (mode === "uniform" && expanded) {
1837
+ const width = getSideValue(styleObject, "Top", "Width") ?? String(SUPPORTED_CSS_PROPERTIES.borderWidth.defaultValue);
1838
+ const color = getSideValue(styleObject, "Top", "Color") ?? String(SUPPORTED_CSS_PROPERTIES.borderColor.defaultValue);
1839
+ const style = getSideValue(styleObject, "Top", "Style") ?? String(SUPPORTED_CSS_PROPERTIES.borderStyle.defaultValue);
1840
+ const changes = [
1841
+ ["borderWidth", width],
1842
+ ["borderColor", color],
1843
+ ["borderStyle", style]
1844
+ ];
1845
+ for (const { side } of SIDES) changes.push([`border${side}Width`, ""], [`border${side}Color`, ""], [`border${side}Style`, ""]);
1846
+ onChange(changes);
1847
+ setExpanded(false);
1848
+ } else if (mode === "individual" && !expanded) {
1849
+ const width = styleObject.borderWidth ?? String(SUPPORTED_CSS_PROPERTIES.borderWidth.defaultValue);
1850
+ const color = styleObject.borderColor ?? String(SUPPORTED_CSS_PROPERTIES.borderColor.defaultValue);
1851
+ const style = styleObject.borderStyle ?? String(SUPPORTED_CSS_PROPERTIES.borderStyle.defaultValue);
1852
+ const changes = [];
1853
+ for (const { side } of SIDES) changes.push([`border${side}Width`, styleObject[`border${side}Width`] ?? width], [`border${side}Color`, styleObject[`border${side}Color`] ?? color], [`border${side}Style`, styleObject[`border${side}Style`] ?? style]);
1854
+ changes.push(["borderWidth", ""], ["borderColor", ""], ["borderStyle", ""]);
1855
+ onChange(changes);
1856
+ setExpanded(true);
1857
+ }
1858
+ };
1859
+ const modeToggle = /* @__PURE__ */ jsxs(Root$1, {
1860
+ value: expanded ? "individual" : "uniform",
1861
+ onValueChange: handleModeChange,
1862
+ children: [/* @__PURE__ */ jsxs(Root, { children: [/* @__PURE__ */ jsx(Trigger, { children: /* @__PURE__ */ jsx(Item, {
1863
+ value: "uniform",
1864
+ children: /* @__PURE__ */ jsx(SquareIcon, { size: 16 })
1865
+ }) }), /* @__PURE__ */ jsx(Content, { children: "Uniform" })] }), /* @__PURE__ */ jsxs(Root, { children: [/* @__PURE__ */ jsx(Trigger, { children: /* @__PURE__ */ jsx(Item, {
1866
+ value: "individual",
1867
+ children: /* @__PURE__ */ jsx(SquareDashedIcon, { size: 16 })
1868
+ }) }), /* @__PURE__ */ jsx(Content, { children: "Per side" })] })]
1869
+ });
1870
+ if (expanded) return /* @__PURE__ */ jsxs("div", {
1871
+ className: "flex flex-col gap-2",
1872
+ children: [/* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Border" }), modeToggle] }), /* @__PURE__ */ jsx("div", {
1873
+ className: "flex flex-col gap-1.5",
1874
+ children: SIDES.map(({ side, icon }) => /* @__PURE__ */ jsxs("div", {
1875
+ className: "flex items-center gap-1",
1876
+ children: [
1877
+ /* @__PURE__ */ jsx(BorderWidthInput, {
1878
+ icon,
1879
+ value: getSideValue(styleObject, side, "Width"),
1880
+ onChange: (v) => onChange(`border${side}Width`, v)
1881
+ }),
1882
+ /* @__PURE__ */ jsx(Root$2, {
1883
+ value: String(getSideValue(styleObject, side, "Style") ?? SUPPORTED_CSS_PROPERTIES.borderStyle.defaultValue),
1884
+ onChange: (e) => onChange(`border${side}Style`, e.target.value),
1885
+ children: Object.entries(BORDER_STYLE_OPTIONS).map(([val, label]) => /* @__PURE__ */ jsx(Item$1, {
1886
+ value: val,
1887
+ children: label
1888
+ }, val))
1889
+ }),
1890
+ /* @__PURE__ */ jsx(ColorInput, {
1891
+ value: String(getSideValue(styleObject, side, "Color") ?? SUPPORTED_CSS_PROPERTIES.borderColor.defaultValue),
1892
+ onChange: (v) => onChange(`border${side}Color`, v)
1893
+ }),
1894
+ /* @__PURE__ */ jsx(IconButton, {
1895
+ onClick: () => {
1896
+ onChange([
1897
+ [`border${side}Width`, ""],
1898
+ [`border${side}Style`, ""],
1899
+ [`border${side}Color`, ""]
1900
+ ]);
1901
+ },
1902
+ "aria-label": `Clear ${side.toLowerCase()} border`,
1903
+ children: /* @__PURE__ */ jsx(XIcon, { size: 14 })
1904
+ })
1905
+ ]
1906
+ }, side))
1907
+ })]
1908
+ });
1909
+ const uniformColor = String(styleObject.borderColor ?? SUPPORTED_CSS_PROPERTIES.borderColor.defaultValue);
1910
+ return /* @__PURE__ */ jsxs("div", {
1911
+ className: "flex flex-col gap-3",
1912
+ children: [/* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Border" }), /* @__PURE__ */ jsxs("div", {
1913
+ className: "flex items-center gap-1",
1914
+ children: [/* @__PURE__ */ jsx(BorderWidthInput, {
1915
+ value: styleObject.borderWidth ?? "",
1916
+ onChange: (v) => onChange("borderWidth", v)
1917
+ }), modeToggle]
1918
+ })] }), /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, {}), /* @__PURE__ */ jsx(ColorInput, {
1919
+ value: uniformColor,
1920
+ onChange: (v) => onChange("borderColor", v)
1921
+ })] })]
1922
+ });
1923
+ }
1924
+ function BorderWidthInput({ icon, value, onChange }) {
1925
+ const { displayValue, ...handlers } = useNumericInput({
1926
+ value,
1927
+ onCommit: onChange,
1928
+ allowEmpty: true,
1929
+ min: 0
1930
+ });
1931
+ const { dragProps } = useDragToChange({
1932
+ value,
1933
+ onCommit: onChange,
1934
+ min: 0
1935
+ });
1936
+ return /* @__PURE__ */ jsxs("span", {
1937
+ "data-re-inspector-number": "",
1938
+ children: [
1939
+ icon && /* @__PURE__ */ jsx("span", {
1940
+ className: "pointer-events-none",
1941
+ "aria-hidden": true,
1942
+ children: icon
1943
+ }),
1944
+ /* @__PURE__ */ jsx(TextField, {
1945
+ type: "text",
1946
+ inputMode: "numeric",
1947
+ "data-type": "number",
1948
+ value: displayValue,
1949
+ placeholder: String(SUPPORTED_CSS_PROPERTIES.borderWidth.defaultValue),
1950
+ ...handlers
1951
+ }),
1952
+ /* @__PURE__ */ jsx("span", {
1953
+ "data-re-inspector-unit": "",
1954
+ ...dragProps,
1955
+ children: "px"
1956
+ })
1957
+ ]
1958
+ });
1959
+ }
1960
+
1961
+ //#endregion
1962
+ //#region src/ui/inspector/components/border-radius-picker.tsx
1963
+ function BorderRadiusPicker({ value, onChange, unit = "px" }) {
1964
+ const expandedValues = expandShorthand(value);
1965
+ const allEqual = Object.values(expandedValues).every((v) => v === expandedValues.borderTopLeftRadius);
1966
+ const [expanded, setExpanded] = React$1.useState(!allEqual);
1967
+ const handleModeChange = (mode) => {
1968
+ if (mode === "uniform" && expanded) {
1969
+ onChange(`${expandedValues.borderTopLeftRadius ?? expandedValues.borderTopRightRadius ?? expandedValues.borderBottomRightRadius ?? expandedValues.borderBottomLeftRadius ?? 0}${unit}`);
1970
+ setExpanded(false);
1971
+ } else if (mode === "individual" && !expanded) setExpanded(true);
1972
+ };
1973
+ const modeToggle = /* @__PURE__ */ jsxs(Root$1, {
1974
+ value: expanded ? "individual" : "uniform",
1975
+ onValueChange: handleModeChange,
1976
+ children: [/* @__PURE__ */ jsxs(Root, { children: [/* @__PURE__ */ jsx(Trigger, { children: /* @__PURE__ */ jsx(Item, {
1977
+ value: "uniform",
1978
+ children: /* @__PURE__ */ jsx(SquareIcon, { size: 16 })
1979
+ }) }), /* @__PURE__ */ jsx(Content, { children: "Uniform" })] }), /* @__PURE__ */ jsxs(Root, { children: [/* @__PURE__ */ jsx(Trigger, { children: /* @__PURE__ */ jsx(Item, {
1980
+ value: "individual",
1981
+ children: /* @__PURE__ */ jsx(SquareDashedIcon, { size: 16 })
1982
+ }) }), /* @__PURE__ */ jsx(Content, { children: "Per corner" })] })]
1983
+ });
1984
+ if (expanded) return /* @__PURE__ */ jsxs("div", {
1985
+ className: "flex flex-col gap-2",
1986
+ children: [/* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Rounded" }), modeToggle] }), /* @__PURE__ */ jsxs("div", {
1987
+ className: "flex flex-col items-center gap-1.5",
1988
+ children: [/* @__PURE__ */ jsxs("div", {
1989
+ className: "flex items-center gap-1.5",
1990
+ children: [/* @__PURE__ */ jsx(RadiusInput, {
1991
+ icon: /* @__PURE__ */ jsx(CornerTopLeftIcon, { size: 14 }),
1992
+ value: expandedValues.borderTopLeftRadius,
1993
+ onChange: (v) => onChange(collapseToShorthand({
1994
+ ...expandedValues,
1995
+ borderTopLeftRadius: v,
1996
+ unit
1997
+ })),
1998
+ unit
1999
+ }), /* @__PURE__ */ jsx(RadiusInput, {
2000
+ icon: /* @__PURE__ */ jsx(CornerTopRightIcon, { size: 14 }),
2001
+ value: expandedValues.borderTopRightRadius,
2002
+ onChange: (v) => onChange(collapseToShorthand({
2003
+ ...expandedValues,
2004
+ borderTopRightRadius: v,
2005
+ unit
2006
+ })),
2007
+ unit
2008
+ })]
2009
+ }), /* @__PURE__ */ jsxs("div", {
2010
+ className: "flex items-center gap-1.5",
2011
+ children: [/* @__PURE__ */ jsx(RadiusInput, {
2012
+ icon: /* @__PURE__ */ jsx(CornerBottomLeftIcon, { size: 14 }),
2013
+ value: expandedValues.borderBottomLeftRadius,
2014
+ onChange: (v) => onChange(collapseToShorthand({
2015
+ ...expandedValues,
2016
+ borderBottomLeftRadius: v,
2017
+ unit
2018
+ })),
2019
+ unit
2020
+ }), /* @__PURE__ */ jsx(RadiusInput, {
2021
+ icon: /* @__PURE__ */ jsx(CornerBottomRightIcon, { size: 14 }),
2022
+ value: expandedValues.borderBottomRightRadius,
2023
+ onChange: (v) => onChange(collapseToShorthand({
2024
+ ...expandedValues,
2025
+ borderBottomRightRadius: v,
2026
+ unit
2027
+ })),
2028
+ unit
2029
+ })]
2030
+ })]
2031
+ })]
2032
+ });
2033
+ return /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Rounded" }), /* @__PURE__ */ jsxs("div", {
2034
+ className: "flex items-center gap-1",
2035
+ children: [/* @__PURE__ */ jsx(RadiusInput, {
2036
+ value: expandedValues.borderTopLeftRadius,
2037
+ onChange: (v) => onChange(`${v}${unit}`),
2038
+ unit
2039
+ }), modeToggle]
2040
+ })] });
2041
+ }
2042
+ function RadiusInput({ icon, value, onChange, unit }) {
2043
+ const onCommit = (v) => onChange(v === "" ? 0 : v);
2044
+ const { displayValue, ...handlers } = useNumericInput({
2045
+ value,
2046
+ onCommit,
2047
+ allowEmpty: false,
2048
+ min: 0
2049
+ });
2050
+ const { dragProps } = useDragToChange({
2051
+ value,
2052
+ onCommit,
2053
+ min: 0
2054
+ });
2055
+ return /* @__PURE__ */ jsxs("span", {
2056
+ "data-re-inspector-number": "",
2057
+ children: [
2058
+ icon && /* @__PURE__ */ jsx("span", {
2059
+ className: "pointer-events-none",
2060
+ "aria-hidden": true,
2061
+ children: icon
2062
+ }),
2063
+ /* @__PURE__ */ jsx(TextField, {
2064
+ type: "text",
2065
+ inputMode: "numeric",
2066
+ "data-type": "number",
2067
+ value: displayValue,
2068
+ ...handlers
2069
+ }),
2070
+ /* @__PURE__ */ jsx("span", {
2071
+ "data-re-inspector-unit": "",
2072
+ ...dragProps,
2073
+ children: unit
2074
+ })
2075
+ ]
2076
+ });
2077
+ }
2078
+ function expandShorthand(value) {
2079
+ if (typeof value === "number") return {
2080
+ borderTopLeftRadius: value,
2081
+ borderTopRightRadius: value,
2082
+ borderBottomRightRadius: value,
2083
+ borderBottomLeftRadius: value
2084
+ };
2085
+ const [topLeft, topRight, bottomRight, bottomLeft] = value.split(" ").map((v) => Number.parseInt(v, 10));
2086
+ return {
2087
+ borderTopLeftRadius: topLeft,
2088
+ borderTopRightRadius: topRight ?? topLeft,
2089
+ borderBottomRightRadius: bottomRight ?? topLeft,
2090
+ borderBottomLeftRadius: bottomLeft ?? topRight ?? topLeft
2091
+ };
2092
+ }
2093
+ function collapseToShorthand(values) {
2094
+ const { borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadius, unit } = values;
2095
+ if (borderTopLeftRadius === borderTopRightRadius && borderTopLeftRadius === borderBottomRightRadius && borderTopLeftRadius === borderBottomLeftRadius) return `${borderTopLeftRadius}${unit}`;
2096
+ if (borderTopLeftRadius === borderBottomRightRadius && borderTopRightRadius === borderBottomLeftRadius) return `${borderTopLeftRadius}${unit} ${borderTopRightRadius}${unit}`;
2097
+ if (borderTopRightRadius === borderBottomLeftRadius) return `${borderTopLeftRadius}${unit} ${borderTopRightRadius}${unit} ${borderBottomRightRadius}${unit}`;
2098
+ return `${borderTopLeftRadius}${unit} ${borderTopRightRadius}${unit} ${borderBottomRightRadius}${unit} ${borderBottomLeftRadius}${unit}`;
2099
+ }
2100
+
2101
+ //#endregion
2102
+ //#region src/ui/inspector/sections/border.tsx
2103
+ const BORDER_PROPS = [
2104
+ "borderWidth",
2105
+ "borderColor",
2106
+ "borderStyle",
2107
+ "borderTopWidth",
2108
+ "borderTopColor",
2109
+ "borderTopStyle",
2110
+ "borderRightWidth",
2111
+ "borderRightColor",
2112
+ "borderRightStyle",
2113
+ "borderBottomWidth",
2114
+ "borderBottomColor",
2115
+ "borderBottomStyle",
2116
+ "borderLeftWidth",
2117
+ "borderLeftColor",
2118
+ "borderLeftStyle",
2119
+ "borderRadius"
2120
+ ];
2121
+ function BorderSection({ getStyle, setStyle, batchSetStyle, initialCollapsed = false }) {
2122
+ const styleObject = {};
2123
+ for (const prop of BORDER_PROPS) styleObject[prop] = getStyle(prop);
2124
+ return /* @__PURE__ */ jsxs(Section, {
2125
+ title: "Border",
2126
+ initialCollapsed,
2127
+ children: [/* @__PURE__ */ jsx(BorderPicker, {
2128
+ styleObject,
2129
+ onChange: (propOrChanges, value) => {
2130
+ if (Array.isArray(propOrChanges)) batchSetStyle(propOrChanges.map(([p, v]) => ({
2131
+ prop: p,
2132
+ value: v
2133
+ })));
2134
+ else setStyle(propOrChanges, value);
2135
+ }
2136
+ }), /* @__PURE__ */ jsx(BorderRadiusPicker, {
2137
+ value: getStyle("borderRadius") ?? 0,
2138
+ onChange: (v) => setStyle("borderRadius", v)
2139
+ })]
2140
+ });
2141
+ }
2142
+
2143
+ //#endregion
2144
+ //#region src/ui/inspector/components/padding-picker.tsx
2145
+ function PaddingPicker({ value, onChange, unit = "px" }) {
2146
+ const allEqual = value.paddingTop === value.paddingBottom && value.paddingTop === value.paddingLeft && value.paddingTop === value.paddingRight;
2147
+ const [expanded, setExpanded] = React$1.useState(!allEqual);
2148
+ const handleChange = (key, newValue) => {
2149
+ onChange({
2150
+ paddingTop: value.paddingTop ?? 0,
2151
+ paddingRight: value.paddingRight ?? 0,
2152
+ paddingBottom: value.paddingBottom ?? 0,
2153
+ paddingLeft: value.paddingLeft ?? 0,
2154
+ [key]: newValue
2155
+ });
2156
+ };
2157
+ const handleUniformChange = (newValue) => {
2158
+ onChange({
2159
+ paddingTop: newValue,
2160
+ paddingRight: newValue,
2161
+ paddingBottom: newValue,
2162
+ paddingLeft: newValue
2163
+ });
2164
+ };
2165
+ const handleModeChange = (mode) => {
2166
+ if (mode === "uniform" && expanded) {
2167
+ const uniform = value.paddingTop ?? 0;
2168
+ onChange({
2169
+ paddingTop: uniform,
2170
+ paddingRight: uniform,
2171
+ paddingBottom: uniform,
2172
+ paddingLeft: uniform
2173
+ });
2174
+ setExpanded(false);
2175
+ } else if (mode === "individual" && !expanded) setExpanded(true);
2176
+ };
2177
+ const modeToggle = /* @__PURE__ */ jsxs(Root$1, {
2178
+ value: expanded ? "individual" : "uniform",
2179
+ onValueChange: handleModeChange,
2180
+ children: [/* @__PURE__ */ jsxs(Root, { children: [/* @__PURE__ */ jsx(Trigger, { children: /* @__PURE__ */ jsx(Item, {
2181
+ value: "uniform",
2182
+ children: /* @__PURE__ */ jsx(SquareIcon, { size: 16 })
2183
+ }) }), /* @__PURE__ */ jsx(Content, { children: "Uniform" })] }), /* @__PURE__ */ jsxs(Root, { children: [/* @__PURE__ */ jsx(Trigger, { children: /* @__PURE__ */ jsx(Item, {
2184
+ value: "individual",
2185
+ children: /* @__PURE__ */ jsx(SquareDashedIcon, { size: 16 })
2186
+ }) }), /* @__PURE__ */ jsx(Content, { children: "Per side" })] })]
2187
+ });
2188
+ if (expanded) return /* @__PURE__ */ jsxs("div", {
2189
+ className: "flex flex-col gap-2",
2190
+ children: [/* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Padding" }), modeToggle] }), /* @__PURE__ */ jsxs("div", {
2191
+ className: "flex flex-col items-center gap-1.5",
2192
+ children: [/* @__PURE__ */ jsxs("div", {
2193
+ className: "flex items-center gap-1",
2194
+ children: [/* @__PURE__ */ jsx(PaddingInput, {
2195
+ icon: /* @__PURE__ */ jsx(PanelTopIcon, { size: 14 }),
2196
+ value: value.paddingTop,
2197
+ onChange: (v) => handleChange("paddingTop", v),
2198
+ unit
2199
+ }), /* @__PURE__ */ jsx(PaddingInput, {
2200
+ icon: /* @__PURE__ */ jsx(PanelRightIcon, { size: 14 }),
2201
+ value: value.paddingRight,
2202
+ onChange: (v) => handleChange("paddingRight", v),
2203
+ unit
2204
+ })]
2205
+ }), /* @__PURE__ */ jsxs("div", {
2206
+ className: "flex items-center gap-1",
2207
+ children: [/* @__PURE__ */ jsx(PaddingInput, {
2208
+ icon: /* @__PURE__ */ jsx(PanelBottomIcon, { size: 14 }),
2209
+ value: value.paddingBottom,
2210
+ onChange: (v) => handleChange("paddingBottom", v),
2211
+ unit
2212
+ }), /* @__PURE__ */ jsx(PaddingInput, {
2213
+ icon: /* @__PURE__ */ jsx(PanelLeftIcon, { size: 14 }),
2214
+ value: value.paddingLeft,
2215
+ onChange: (v) => handleChange("paddingLeft", v),
2216
+ unit
2217
+ })]
2218
+ })]
2219
+ })]
2220
+ });
2221
+ return /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Padding" }), /* @__PURE__ */ jsxs("div", {
2222
+ className: "flex items-center gap-1",
2223
+ children: [/* @__PURE__ */ jsx(PaddingInput, {
2224
+ value: value.paddingTop,
2225
+ onChange: handleUniformChange,
2226
+ unit
2227
+ }), modeToggle]
2228
+ })] });
2229
+ }
2230
+ function PaddingInput({ icon, value, onChange, unit }) {
2231
+ const onCommit = (v) => onChange(v === "" ? 0 : v);
2232
+ const { displayValue, ...handlers } = useNumericInput({
2233
+ value,
2234
+ onCommit,
2235
+ allowEmpty: false,
2236
+ min: 0
2237
+ });
2238
+ const { dragProps } = useDragToChange({
2239
+ value,
2240
+ onCommit,
2241
+ min: 0
2242
+ });
2243
+ return /* @__PURE__ */ jsxs("span", {
2244
+ "data-re-inspector-number": "",
2245
+ children: [
2246
+ icon && /* @__PURE__ */ jsx("span", {
2247
+ className: "pointer-events-none",
2248
+ "aria-hidden": true,
2249
+ children: icon
2250
+ }),
2251
+ /* @__PURE__ */ jsx(TextField, {
2252
+ type: "text",
2253
+ inputMode: "numeric",
2254
+ "data-type": "number",
2255
+ value: displayValue,
2256
+ ...handlers
2257
+ }),
2258
+ /* @__PURE__ */ jsx("span", {
2259
+ "data-re-inspector-unit": "",
2260
+ ...dragProps,
2261
+ children: unit
2262
+ })
2263
+ ]
2264
+ });
2265
+ }
2266
+
2267
+ //#endregion
2268
+ //#region src/ui/inspector/sections/padding.tsx
2269
+ function PaddingSection({ getStyle, batchSetStyle, initialCollapsed = false }) {
2270
+ return /* @__PURE__ */ jsx(Section, {
2271
+ title: "Padding",
2272
+ initialCollapsed,
2273
+ children: /* @__PURE__ */ jsx(PaddingPicker, {
2274
+ value: {
2275
+ paddingTop: Number(getStyle("paddingTop")) || 0,
2276
+ paddingRight: Number(getStyle("paddingRight")) || 0,
2277
+ paddingBottom: Number(getStyle("paddingBottom")) || 0,
2278
+ paddingLeft: Number(getStyle("paddingLeft")) || 0
2279
+ },
2280
+ onChange: (values) => {
2281
+ batchSetStyle(Object.entries(values).map(([prop, val]) => ({
2282
+ prop,
2283
+ value: val
2284
+ })));
2285
+ }
2286
+ })
2287
+ });
2288
+ }
2289
+
2290
+ //#endregion
2291
+ //#region src/ui/inspector/sections/size.tsx
2292
+ const SIZE_AS_ATTRIBUTES = ["image"];
2293
+ function SizeSection({ nodeType, getStyle, setStyle, getAttr, setAttr, initialCollapsed = false }) {
2294
+ const useAttrs = SIZE_AS_ATTRIBUTES.includes(nodeType);
2295
+ const width = useAttrs ? getAttr("width") ?? "" : getStyle("width") ?? "";
2296
+ const height = useAttrs ? getAttr("height") ?? "" : getStyle("height") ?? "";
2297
+ const setWidth = (v) => {
2298
+ if (useAttrs) setAttr("width", v === "" ? "" : v);
2299
+ else setStyle("width", v);
2300
+ };
2301
+ const setHeight = (v) => {
2302
+ if (useAttrs) setAttr("height", v === "" ? "" : v);
2303
+ else setStyle("height", v);
2304
+ };
2305
+ return /* @__PURE__ */ jsxs(Section, {
2306
+ title: "Size",
2307
+ initialCollapsed,
2308
+ children: [/* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Width" }), /* @__PURE__ */ jsx(NumberInput, {
2309
+ value: width,
2310
+ onChange: setWidth,
2311
+ unit: "px",
2312
+ placeholder: "auto",
2313
+ min: 0
2314
+ })] }), /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Height" }), /* @__PURE__ */ jsx(NumberInput, {
2315
+ value: height,
2316
+ onChange: setHeight,
2317
+ unit: "px",
2318
+ placeholder: "auto",
2319
+ min: 0
2320
+ })] })]
2321
+ });
2322
+ }
2323
+
2324
+ //#endregion
2325
+ //#region src/ui/inspector/config/text-config.tsx
2326
+ const CSS_UNIT_MAP = {
2327
+ fontSize: "px",
2328
+ borderWidth: "px",
2329
+ borderRadius: "px",
2330
+ paddingTop: "px",
2331
+ paddingRight: "px",
2332
+ paddingBottom: "px",
2333
+ paddingLeft: "px",
2334
+ lineHeight: "%"
2335
+ };
2336
+ const FORMAT_ITEMS = [
2337
+ {
2338
+ value: "bold",
2339
+ icon: BoldIcon,
2340
+ label: "Bold"
2341
+ },
2342
+ {
2343
+ value: "italic",
2344
+ icon: ItalicIcon,
2345
+ label: "Italic"
2346
+ },
2347
+ {
2348
+ value: "underline",
2349
+ icon: UnderlineIcon,
2350
+ label: "Underline"
2351
+ },
2352
+ {
2353
+ value: "line-through",
2354
+ icon: StrikethroughIcon,
2355
+ label: "Strikethrough"
2356
+ },
2357
+ {
2358
+ value: "code",
2359
+ icon: CodeIcon,
2360
+ label: "Code"
2361
+ },
2362
+ {
2363
+ value: "uppercase",
2364
+ icon: CaseUpperIcon,
2365
+ label: "Uppercase"
2366
+ }
2367
+ ];
2368
+ const ALIGNMENT_ITEMS = [
2369
+ {
2370
+ value: "left",
2371
+ alternativeIcon: AlignLeftIcon,
2372
+ icon: AlignStartVerticalIcon
2373
+ },
2374
+ {
2375
+ value: "center",
2376
+ alternativeIcon: AlignCenterIcon,
2377
+ icon: AlignCenterVerticalIcon
2378
+ },
2379
+ {
2380
+ value: "right",
2381
+ alternativeIcon: AlignRightIcon,
2382
+ icon: AlignEndVerticalIcon
2383
+ }
2384
+ ];
2385
+
2386
+ //#endregion
2387
+ //#region src/ui/inspector/sections/typography.tsx
2388
+ function TypographySection({ getStyle, setStyle, marks, toggleMark, alignment, setAlignment, initialCollapsed = false }) {
2389
+ const color = String(getStyle("color") ?? "");
2390
+ const fontSize = getStyle("fontSize") ?? "";
2391
+ const lineHeight = getStyle("lineHeight") ?? "";
2392
+ return /* @__PURE__ */ jsxs(Section, {
2393
+ title: "Typography",
2394
+ initialCollapsed,
2395
+ children: [
2396
+ /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Color" }), /* @__PURE__ */ jsx(ColorInput, {
2397
+ value: color,
2398
+ onChange: (v) => setStyle("color", v)
2399
+ })] }),
2400
+ /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Size" }), /* @__PURE__ */ jsx(NumberInput, {
2401
+ value: fontSize,
2402
+ onChange: (v) => setStyle("fontSize", v),
2403
+ unit: "px",
2404
+ min: 1
2405
+ })] }),
2406
+ /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Line height" }), /* @__PURE__ */ jsx(NumberInput, {
2407
+ value: lineHeight,
2408
+ onChange: (v) => setStyle("lineHeight", v),
2409
+ unit: "%"
2410
+ })] }),
2411
+ marks && toggleMark && /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Format" }), /* @__PURE__ */ jsx("div", {
2412
+ className: "flex items-center gap-0.5",
2413
+ children: FORMAT_ITEMS.map((item) => /* @__PURE__ */ jsxs(Root, { children: [/* @__PURE__ */ jsx(Trigger, { children: /* @__PURE__ */ jsx(IconButton, {
2414
+ onClick: () => toggleMark(item.value),
2415
+ "aria-pressed": marks[item.value] ?? false,
2416
+ "aria-label": item.label,
2417
+ children: /* @__PURE__ */ jsx(item.icon, { size: 16 })
2418
+ }) }), /* @__PURE__ */ jsx(Content, { children: item.label })] }, item.value))
2419
+ })] }),
2420
+ alignment && setAlignment && /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Align" }), /* @__PURE__ */ jsx(Root$1, {
2421
+ value: alignment,
2422
+ onValueChange: setAlignment,
2423
+ children: ALIGNMENT_ITEMS.map((item) => /* @__PURE__ */ jsxs(Root, { children: [/* @__PURE__ */ jsx(Trigger, { children: /* @__PURE__ */ jsx(Item, {
2424
+ value: item.value,
2425
+ children: /* @__PURE__ */ jsx(item.icon, { size: 16 })
2426
+ }) }), /* @__PURE__ */ jsx(Content, { children: item.value.charAt(0).toUpperCase() + item.value.slice(1) })] }, item.value))
2427
+ })] })
2428
+ ]
2429
+ });
2430
+ }
2431
+
2432
+ //#endregion
2433
+ //#region src/ui/inspector/utils/resolve-theme-defaults.ts
2434
+ function expandPaddingShorthand(value) {
2435
+ const [top, right = top, bottom = top, left = right] = String(value).trim().split(/\s+/);
2436
+ return {
2437
+ paddingTop: top,
2438
+ paddingRight: right,
2439
+ paddingBottom: bottom,
2440
+ paddingLeft: left
2441
+ };
2442
+ }
2443
+ function parseCssValue(value) {
2444
+ if (value === void 0 || value === null) return null;
2445
+ const match = String(value).trim().match(/^(-?\d*\.?\d+)(px|em|%|rem)?$/);
2446
+ if (match) return {
2447
+ numeric: Number.parseFloat(match[1]),
2448
+ unit: match[2] || ""
2449
+ };
2450
+ return null;
2451
+ }
2452
+ function convertToInspectorUnit(value, bodyFontSize, targetUnit) {
2453
+ const parsed = parseCssValue(value);
2454
+ if (!parsed) return "";
2455
+ if (parsed.unit === "em" || parsed.unit === "rem") return Math.round(parsed.numeric * bodyFontSize);
2456
+ if (parsed.unit === "%") return targetUnit === "%" ? parsed.numeric : parsed.numeric;
2457
+ if (parsed.unit === "px" || parsed.unit === "") return parsed.numeric;
2458
+ return "";
2459
+ }
2460
+ const BASE_FONT_SIZE_PX = 16;
2461
+ function resolveThemeDefaults(nodeType, attrs, themeStyles) {
2462
+ const componentKey = getThemeComponentKey(nodeType, 0, attrs);
2463
+ if (!componentKey) return {};
2464
+ const componentStyles = themeStyles[componentKey];
2465
+ if (!componentStyles) return {};
2466
+ const resolvedDefaults = {};
2467
+ if (componentStyles.color) resolvedDefaults.color = componentStyles.color;
2468
+ else if (themeStyles.body?.color) resolvedDefaults.color = themeStyles.body.color;
2469
+ if (componentStyles.fontWeight !== void 0) resolvedDefaults.fontWeight = componentStyles.fontWeight;
2470
+ if (componentStyles.textDecoration !== void 0) resolvedDefaults.textDecoration = componentStyles.textDecoration;
2471
+ if (componentStyles.backgroundColor !== void 0) resolvedDefaults.backgroundColor = componentStyles.backgroundColor;
2472
+ if (componentStyles.borderRadius !== void 0) {
2473
+ const converted = convertToInspectorUnit(componentStyles.borderRadius, BASE_FONT_SIZE_PX, "px");
2474
+ if (converted !== "") resolvedDefaults.borderRadius = converted;
2475
+ }
2476
+ if (componentStyles.borderWidth !== void 0) {
2477
+ const converted = convertToInspectorUnit(componentStyles.borderWidth, BASE_FONT_SIZE_PX, "px");
2478
+ if (converted !== "") resolvedDefaults.borderWidth = converted;
2479
+ }
2480
+ if (componentStyles.borderColor !== void 0) resolvedDefaults.borderColor = componentStyles.borderColor;
2481
+ if (componentStyles.borderStyle !== void 0) resolvedDefaults.borderStyle = componentStyles.borderStyle;
2482
+ const shorthandPadding = componentStyles.padding === void 0 ? {} : expandPaddingShorthand(componentStyles.padding);
2483
+ for (const prop of [
2484
+ "paddingTop",
2485
+ "paddingRight",
2486
+ "paddingBottom",
2487
+ "paddingLeft"
2488
+ ]) {
2489
+ const value = componentStyles[prop] ?? shorthandPadding[prop];
2490
+ if (value !== void 0) {
2491
+ const converted = convertToInspectorUnit(value, BASE_FONT_SIZE_PX, "px");
2492
+ if (converted !== "") resolvedDefaults[prop] = converted;
2493
+ }
2494
+ }
2495
+ return resolvedDefaults;
2496
+ }
2497
+
2498
+ //#endregion
2499
+ //#region src/ui/inspector/utils/get-node-at-pos.ts
2500
+ function getNodeAtExactPos(editor, nodePos) {
2501
+ const doc = editor.state.doc;
2502
+ const nodeAtPos = doc.nodeAt(nodePos.pos);
2503
+ if (nodeAtPos) return {
2504
+ node: nodeAtPos,
2505
+ pos: nodePos.pos
2506
+ };
2507
+ const resolved = doc.resolve(nodePos.pos);
2508
+ if (resolved.nodeAfter) return {
2509
+ node: resolved.nodeAfter,
2510
+ pos: nodePos.pos
2511
+ };
2512
+ if (resolved.parent && resolved.parent.type.name !== "doc") {
2513
+ const parentPos = resolved.before(resolved.depth);
2514
+ return {
2515
+ node: resolved.parent,
2516
+ pos: parentPos
2517
+ };
2518
+ }
2519
+ return null;
2520
+ }
2521
+
2522
+ //#endregion
2523
+ //#region src/ui/inspector/utils/style-updates.ts
2524
+ function customUpdateAttributes({ editor, nodePos, prop, newValue }, setLocalAttr) {
2525
+ const result = getNodeAtExactPos(editor, nodePos);
2526
+ if (!result?.node) return;
2527
+ const { node, pos } = result;
2528
+ const attributes = { ...node.attrs };
2529
+ attributes[prop] = newValue;
2530
+ setLocalAttr(attributes);
2531
+ const transaction = editor.state.tr.setNodeMarkup(pos, null, attributes);
2532
+ editor.view.dispatch(transaction);
2533
+ }
2534
+ function customUpdateStyles(params, setLocalAttr) {
2535
+ const result = getNodeAtExactPos(params.editor, params.nodePos);
2536
+ if (!result?.node) return;
2537
+ const { node, pos } = result;
2538
+ const currentStyle = inlineCssToJs(node.attrs.style);
2539
+ const changes = "changes" in params ? params.changes : [[params.prop, params.newValue]];
2540
+ for (const [prop, value] of changes) if (value === "" || value === void 0) delete currentStyle[prop];
2541
+ else {
2542
+ const unit = SUPPORTED_CSS_PROPERTIES[prop]?.unit;
2543
+ currentStyle[prop] = unit && typeof value === "number" ? `${value}${unit}` : String(value);
2544
+ }
2545
+ ensureBorderStyleFallback(currentStyle);
2546
+ const newStyle = jsToInlineCss(currentStyle);
2547
+ const attributes = {
2548
+ ...node.attrs,
2549
+ style: newStyle
2550
+ };
2551
+ setLocalAttr(attributes);
2552
+ const transaction = params.editor.state.tr.setNodeMarkup(pos, null, attributes);
2553
+ params.editor.view.dispatch(transaction);
2554
+ }
2555
+
2556
+ //#endregion
2557
+ //#region src/ui/inspector/node.tsx
2558
+ function InspectorNode({ children }) {
2559
+ const { editor } = useCurrentEditor();
2560
+ const theming = useEmailTheming(editor);
2561
+ const { target } = useInspector();
2562
+ const documentColors = useDocumentColors(editor);
2563
+ const [localAttr, setLocalAttr] = React$1.useState(null);
2564
+ const focusedNode = typeof target === "object" && target !== null ? target : null;
2565
+ React$1.useEffect(() => {
2566
+ if (focusedNode) setLocalAttr(focusedNode.nodeAttrs);
2567
+ }, [focusedNode]);
2568
+ if (!editor || !theming || !focusedNode) return null;
2569
+ const attrs = localAttr ?? focusedNode.nodeAttrs;
2570
+ const inlineStyles = inlineCssToJs(attrs.style || "");
2571
+ const css = stylesToCss(theming.styles, theming.theme);
2572
+ const themeDefaults = resolveThemeDefaults(focusedNode.nodeType, attrs, css);
2573
+ const mergedStyles = {
2574
+ ...themeDefaults,
2575
+ ...inlineStyles
2576
+ };
2577
+ const getStyle = (prop) => mergedStyles[prop];
2578
+ const setStyle = (prop, value) => {
2579
+ customUpdateStyles({
2580
+ editor,
2581
+ nodePos: focusedNode.nodePos,
2582
+ prop,
2583
+ newValue: value
2584
+ }, setLocalAttr);
2585
+ };
2586
+ const batchSetStyle = (changes) => {
2587
+ customUpdateStyles({
2588
+ editor,
2589
+ nodePos: focusedNode.nodePos,
2590
+ changes: changes.map((c) => [c.prop, c.value])
2591
+ }, setLocalAttr);
2592
+ };
2593
+ const getAttr = (name) => attrs[name];
2594
+ const setAttr = (name, value) => {
2595
+ customUpdateAttributes({
2596
+ editor,
2597
+ nodePos: focusedNode.nodePos,
2598
+ prop: name,
2599
+ newValue: value
2600
+ }, setLocalAttr);
2601
+ };
2602
+ const context = {
2603
+ nodeType: focusedNode.nodeType,
2604
+ nodePos: focusedNode.nodePos,
2605
+ getStyle,
2606
+ setStyle,
2607
+ batchSetStyle,
2608
+ getAttr,
2609
+ setAttr,
2610
+ themeDefaults,
2611
+ presetColors: documentColors
2612
+ };
2613
+ if (children) return /* @__PURE__ */ jsx(Fragment, { children: children(context) });
2614
+ return /* @__PURE__ */ jsx(InspectorNodeDefaults, { context });
2615
+ }
2616
+ function getDefaultLayout(nodeType) {
2617
+ switch (nodeType) {
2618
+ case "image": return { sections: [
2619
+ { type: "attributes" },
2620
+ { type: "size" },
2621
+ {
2622
+ type: "link",
2623
+ initialCollapsed: true
2624
+ },
2625
+ {
2626
+ type: "padding",
2627
+ initialCollapsed: true
2628
+ },
2629
+ {
2630
+ type: "border",
2631
+ initialCollapsed: true
2632
+ }
2633
+ ] };
2634
+ case "button": return { sections: [
2635
+ { type: "link" },
2636
+ { type: "typography" },
2637
+ {
2638
+ type: "size",
2639
+ initialCollapsed: true
2640
+ },
2641
+ {
2642
+ type: "padding",
2643
+ initialCollapsed: true
2644
+ },
2645
+ {
2646
+ type: "border",
2647
+ initialCollapsed: true
2648
+ },
2649
+ {
2650
+ type: "background",
2651
+ initialCollapsed: true
2652
+ }
2653
+ ] };
2654
+ case "section":
2655
+ case "div": return { sections: [
2656
+ { type: "background" },
2657
+ {
2658
+ type: "padding",
2659
+ initialCollapsed: true
2660
+ },
2661
+ {
2662
+ type: "border",
2663
+ initialCollapsed: true
2664
+ }
2665
+ ] };
2666
+ case "codeBlock": return { sections: [
2667
+ { type: "attributes" },
2668
+ {
2669
+ type: "padding",
2670
+ initialCollapsed: true
2671
+ },
2672
+ {
2673
+ type: "border",
2674
+ initialCollapsed: true
2675
+ }
2676
+ ] };
2677
+ case "footer": return { sections: [
2678
+ {
2679
+ type: "typography",
2680
+ initialCollapsed: true
2681
+ },
2682
+ {
2683
+ type: "padding",
2684
+ initialCollapsed: true
2685
+ },
2686
+ {
2687
+ type: "background",
2688
+ initialCollapsed: true
2689
+ }
2690
+ ] };
2691
+ default: return { sections: [
2692
+ {
2693
+ type: "typography",
2694
+ initialCollapsed: true
2695
+ },
2696
+ {
2697
+ type: "padding",
2698
+ initialCollapsed: true
2699
+ },
2700
+ {
2701
+ type: "background",
2702
+ initialCollapsed: true
2703
+ },
2704
+ {
2705
+ type: "border",
2706
+ initialCollapsed: true
2707
+ }
2708
+ ] };
2709
+ }
2710
+ }
2711
+ function InspectorNodeDefaults({ context }) {
2712
+ return /* @__PURE__ */ jsx(Fragment, { children: getDefaultLayout(context.nodeType).sections.map((section) => {
2713
+ switch (section.type) {
2714
+ case "attributes": return /* @__PURE__ */ jsx(AttributesSection, {
2715
+ ...context,
2716
+ initialCollapsed: section.initialCollapsed
2717
+ }, section.type);
2718
+ case "size": return /* @__PURE__ */ jsx(SizeSection, {
2719
+ ...context,
2720
+ initialCollapsed: section.initialCollapsed
2721
+ }, section.type);
2722
+ case "typography": return /* @__PURE__ */ jsx(TypographySection, {
2723
+ ...context,
2724
+ initialCollapsed: section.initialCollapsed
2725
+ }, section.type);
2726
+ case "padding": return /* @__PURE__ */ jsx(PaddingSection, {
2727
+ ...context,
2728
+ initialCollapsed: section.initialCollapsed
2729
+ }, section.type);
2730
+ case "background": return /* @__PURE__ */ jsx(BackgroundSection, {
2731
+ ...context,
2732
+ initialCollapsed: section.initialCollapsed
2733
+ }, section.type);
2734
+ case "border": return /* @__PURE__ */ jsx(BorderSection, {
2735
+ ...context,
2736
+ initialCollapsed: section.initialCollapsed
2737
+ }, section.type);
2738
+ default: return null;
2739
+ }
2740
+ }) });
2741
+ }
2742
+
2743
+ //#endregion
2744
+ //#region src/ui/inspector/sections/link.tsx
2745
+ function LinkSection({ linkHref, linkColor, setLinkColor, isLinkActive, initialCollapsed = false }) {
2746
+ if (!isLinkActive) return null;
2747
+ return /* @__PURE__ */ jsxs(Section, {
2748
+ title: "Link",
2749
+ initialCollapsed,
2750
+ children: [/* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "URL" }), /* @__PURE__ */ jsx(TextField, {
2751
+ type: "text",
2752
+ value: linkHref,
2753
+ readOnly: true
2754
+ })] }), /* @__PURE__ */ jsxs(PropRow, { children: [/* @__PURE__ */ jsx(Label, { children: "Color" }), /* @__PURE__ */ jsx(ColorInput, {
2755
+ value: linkColor,
2756
+ onChange: setLinkColor
2757
+ })] })]
2758
+ });
2759
+ }
2760
+
2761
+ //#endregion
2762
+ //#region src/ui/inspector/hooks/use-link-mark.ts
2763
+ function useLinkMark(editor) {
2764
+ return useEditorState({
2765
+ editor,
2766
+ selector: ({ editor: editor$1 }) => {
2767
+ if (!editor$1) return {
2768
+ href: "",
2769
+ style: "",
2770
+ isActive: false
2771
+ };
2772
+ const { from } = editor$1.state.selection;
2773
+ const mark = editor$1.state.doc.resolve(from).marks().find((m) => m.type.name === "link") ?? null;
2774
+ return {
2775
+ href: mark?.attrs?.href ?? "",
2776
+ style: mark?.attrs?.style ?? "",
2777
+ isActive: !!mark
2778
+ };
2779
+ }
2780
+ }) ?? {
2781
+ href: "",
2782
+ style: "",
2783
+ isActive: false
2784
+ };
2785
+ }
2786
+ function getLinkColor(linkStyle, themeLinkColor, fallback = "#000000") {
2787
+ return inlineCssToJs(linkStyle).color || themeLinkColor || fallback;
2788
+ }
2789
+ function updateLinkColor(editor, linkStyle, color) {
2790
+ const styleObj = inlineCssToJs(linkStyle);
2791
+ styleObj.color = color;
2792
+ const newStyle = jsToInlineCss(styleObj);
2793
+ const { from, to } = editor.state.selection;
2794
+ editor.chain().extendMarkRange("link").updateAttributes("link", { style: newStyle }).setTextSelection({
2795
+ from,
2796
+ to
2797
+ }).run();
2798
+ }
2799
+
2800
+ //#endregion
2801
+ //#region src/ui/inspector/utils/text-block-utils.ts
2802
+ function getParentBlockInfo(editor) {
2803
+ if (!editor) return {
2804
+ alignment: "left",
2805
+ pos: 0,
2806
+ nodeType: "paragraph",
2807
+ attrs: {}
2808
+ };
2809
+ const { from } = editor.state.selection;
2810
+ const resolvedPos = editor.state.doc.resolve(from);
2811
+ for (let depth = resolvedPos.depth; depth > 0; depth--) {
2812
+ const node = resolvedPos.node(depth);
2813
+ if (node.isBlock) return {
2814
+ alignment: node.attrs.align || node.attrs.alignment || "left",
2815
+ pos: resolvedPos.before(depth),
2816
+ nodeType: node.type.name,
2817
+ attrs: { ...node.attrs }
2818
+ };
2819
+ }
2820
+ return {
2821
+ alignment: "left",
2822
+ pos: 0,
2823
+ nodeType: "paragraph",
2824
+ attrs: {}
2825
+ };
2826
+ }
2827
+ function updateParentBlockStyle(editor, parentPos, styleKeyOrChanges, value) {
2828
+ if (!editor || parentPos < 0) return;
2829
+ const node = editor.state.doc.nodeAt(parentPos);
2830
+ if (!node) return;
2831
+ const expanded = expandShorthandProperties(inlineCssToJs(node.attrs.style || "", { removeUnit: false }));
2832
+ const changes = Array.isArray(styleKeyOrChanges) ? styleKeyOrChanges : [[styleKeyOrChanges, value]];
2833
+ for (const [styleKey, v] of changes) if (v === "" || v === void 0) delete expanded[styleKey];
2834
+ else {
2835
+ const unit = CSS_UNIT_MAP[styleKey];
2836
+ expanded[styleKey] = unit && typeof v === "number" ? `${v}${unit}` : v;
2837
+ }
2838
+ ensureBorderStyleFallback(expanded);
2839
+ const newStyle = jsToInlineCss(expanded);
2840
+ const tr = editor.state.tr.setNodeMarkup(parentPos, null, {
2841
+ ...node.attrs,
2842
+ style: newStyle
2843
+ });
2844
+ editor.view.dispatch(tr);
2845
+ }
2846
+
2847
+ //#endregion
2848
+ //#region src/ui/inspector/text.tsx
2849
+ const MARK_NAMES = [
2850
+ "bold",
2851
+ "italic",
2852
+ "underline",
2853
+ "strike",
2854
+ "code"
2855
+ ];
2856
+ function InspectorText({ children }) {
2857
+ const { editor } = useCurrentEditor();
2858
+ const theming = useEmailTheming(editor);
2859
+ const { target } = useInspector();
2860
+ const documentColors = useDocumentColors(editor);
2861
+ const linkMark = useLinkMark(editor);
2862
+ const activeMarks = useEditorState({
2863
+ editor,
2864
+ selector: ({ editor: ed }) => {
2865
+ if (!ed) return {};
2866
+ const result = {};
2867
+ for (const mark of MARK_NAMES) result[mark] = ed.isActive(mark);
2868
+ return result;
2869
+ }
2870
+ }) ?? {};
2871
+ const parentBlock = useEditorState({
2872
+ editor,
2873
+ selector: ({ editor: ed }) => getParentBlockInfo(ed)
2874
+ });
2875
+ if (!editor || !theming || target !== "text") return null;
2876
+ const css = stylesToCss(theming.styles, theming.theme);
2877
+ const parentAttrs = parentBlock?.attrs ?? {};
2878
+ const parentNodeType = parentBlock?.nodeType ?? "paragraph";
2879
+ const parentPos = parentBlock?.pos ?? 0;
2880
+ const themeDefaults = resolveThemeDefaults(parentNodeType, parentAttrs, css);
2881
+ const parentStyle = inlineCssToJs(String(parentAttrs.style || ""));
2882
+ const mergedStyles = {
2883
+ ...themeDefaults,
2884
+ ...parentStyle
2885
+ };
2886
+ const themeLinkColor = css.link?.color ? String(css.link.color) : void 0;
2887
+ const context = {
2888
+ marks: activeMarks,
2889
+ toggleMark: (mark) => {
2890
+ editor.chain().focus().toggleMark(mark).run();
2891
+ },
2892
+ alignment: parentBlock?.alignment ?? "left",
2893
+ setAlignment: (value) => {
2894
+ if (!parentBlock) return;
2895
+ editor.chain().focus().updateAttributes(parentNodeType, { alignment: value }).run();
2896
+ },
2897
+ linkHref: linkMark.href,
2898
+ linkColor: getLinkColor(linkMark.style, themeLinkColor),
2899
+ setLinkColor: (color) => {
2900
+ updateLinkColor(editor, linkMark.style, color);
2901
+ },
2902
+ isLinkActive: linkMark.isActive,
2903
+ getStyle: (prop) => mergedStyles[prop],
2904
+ setStyle: (prop, value) => {
2905
+ updateParentBlockStyle(editor, parentPos, prop, value);
2906
+ },
2907
+ presetColors: documentColors
2908
+ };
2909
+ if (children) return /* @__PURE__ */ jsx(Fragment, { children: children(context) });
2910
+ return /* @__PURE__ */ jsx(InspectorTextDefaults, { context });
2911
+ }
2912
+ function InspectorTextDefaults({ context }) {
2913
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(TypographySection, { ...context }), context.isLinkActive && /* @__PURE__ */ jsx(LinkSection, { ...context })] });
2914
+ }
2915
+
2916
+ //#endregion
2917
+ //#region src/ui/inspector/index.tsx
2918
+ const Inspector = {
2919
+ Root: InspectorRoot,
2920
+ Breadcrumb: InspectorBreadcrumb,
2921
+ Document: InspectorDocument,
2922
+ Node: InspectorNode,
2923
+ Text: InspectorText,
2924
+ Attributes: AttributesSection,
2925
+ Background: BackgroundSection,
2926
+ Border: BorderSection,
2927
+ Link: LinkSection,
2928
+ Padding: PaddingSection,
2929
+ Size: SizeSection,
2930
+ Typography: TypographySection
2931
+ };
2932
+
2933
+ //#endregion
2934
+ //#region src/ui/slash-command/index.ts
2935
+ const SlashCommand = {
2936
+ Root: SlashCommandRoot,
2937
+ CommandList
2938
+ };
2939
+
2940
+ //#endregion
2941
+ export { AlignCenterIcon, AlignCenterVerticalIcon, AlignEndVerticalIcon, AlignLeftIcon, AlignRightIcon, AlignStartVerticalIcon, BULLET_LIST, BUTTON, BoldIcon, BoxIcon, BubbleMenu, BubbleMenuAlignCenter, BubbleMenuAlignLeft, BubbleMenuAlignRight, BubbleMenuBold, BubbleMenuButtonDefault, BubbleMenuButtonEditLink, BubbleMenuButtonForm, BubbleMenuButtonToolbar, BubbleMenuButtonUnlink, BubbleMenuCode, BubbleMenuImageDefault, BubbleMenuImageEditLink, BubbleMenuImageToolbar, BubbleMenuItalic, BubbleMenuItem, BubbleMenuItemGroup, BubbleMenuLinkDefault, BubbleMenuLinkEditLink, BubbleMenuLinkForm, BubbleMenuLinkOpenLink, BubbleMenuLinkSelector, BubbleMenuLinkToolbar, BubbleMenuLinkUnlink, BubbleMenuNodeSelector, RootWithDefault as BubbleMenuRoot, BubbleMenuSeparator, BubbleMenuStrike, BubbleMenuUnderline, BubbleMenuUppercase, CODE, CaseUpperIcon, CheckIcon, ChevronDownIcon, CodeIcon, Columns2Icon, Columns3Icon, Columns4Icon, CommandList, CornerBottomLeftIcon, CornerBottomRightIcon, CornerTopLeftIcon, CornerTopRightIcon, DIVIDER, EditorFocusScope, EditorFocusScopeProvider, ExternalLinkIcon, FOUR_COLUMNS, H1, H2, H3, Heading1Icon, Heading2Icon, Heading3Icon, ImageIcon, Inspector, ItalicIcon, LayoutIcon, LinkIcon, ListIcon, ListOrderedIcon, MinusIcon, MousePointerClickIcon, MousePointerIcon, NUMBERED_LIST, NodeSelectorContent, NodeSelectorRoot, NodeSelectorTrigger, PanelBottomIcon, PanelLeftIcon, PanelRightIcon, PanelTopIcon, PencilIcon, PlusIcon, QUOTE, Rows2Icon, SECTION, SlashCommand, SplitSquareVerticalIcon, SquareCodeIcon, SquareDashedIcon, SquareIcon, SquareRoundCornerIcon, StrikethroughIcon, TEXT, THREE_COLUMNS, TWO_COLUMNS, TableIcon, TextIcon, TextQuoteIcon, TypeIcon, UnderlineIcon, UnlinkIcon, XIcon, bubbleMenuTriggers, defaultSlashCommands, filterAndRankItems, isAtMaxColumnsDepth, isInsideNode, scoreItem, useBubbleMenuContext, useEditorFocusScope };
2942
+ //# sourceMappingURL=index.mjs.map