@react-email/editor 0.0.0-experimental.43 → 0.0.0-experimental.45

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