@react-email/editor 0.0.0-experimental.8 → 1.0.0

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