@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.cjs CHANGED
@@ -1,12 +1,13 @@
1
- const require_event_bus = require('../event-bus-BJn1dJM1.cjs');
2
- const require_extension = require('../extension-CF0s-pGh.cjs');
3
- const require_root = require('../root-D6lslKju.cjs');
1
+ const require_event_bus = require('../event-bus-D-uahiao.cjs');
2
+ const require_global_content = require('../global-content-D3TNgSN6.cjs');
3
+ const require_extension = require('../extension-DHsEsAaO.cjs');
4
+ const require_root = require('../root-CEAehvsX.cjs');
4
5
  let _tiptap_react = require("@tiptap/react");
5
6
  let react = require("react");
6
7
  react = require_event_bus.__toESM(react);
7
8
  let react_jsx_runtime = require("react/jsx-runtime");
8
- let _tiptap_core = require("@tiptap/core");
9
9
  let _tiptap_pm_state = require("@tiptap/pm/state");
10
+ let _radix_ui_react_slot = require("@radix-ui/react-slot");
10
11
 
11
12
  //#region src/ui/icons/align-center-vertical.tsx
12
13
  function AlignCenterVerticalIcon({ size, width, height, ...props }) {
@@ -125,6 +126,86 @@ function BoxIcon({ size, width, height, ...props }) {
125
126
  });
126
127
  }
127
128
 
129
+ //#endregion
130
+ //#region src/ui/icons/corner-bottom-left.tsx
131
+ function CornerBottomLeftIcon({ size, width, height, ...props }) {
132
+ return /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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
+
128
209
  //#endregion
129
210
  //#region src/ui/icons/image.tsx
130
211
  function ImageIcon({ size, width, height, ...props }) {
@@ -233,6 +314,182 @@ function MousePointerClickIcon({ size, width, height, ...props }) {
233
314
  });
234
315
  }
235
316
 
317
+ //#endregion
318
+ //#region src/ui/icons/panel-bottom.tsx
319
+ function PanelBottomIcon({ size, width, height, ...props }) {
320
+ return /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("rect", {
333
+ width: "18",
334
+ height: "18",
335
+ x: "3",
336
+ y: "3",
337
+ rx: "2"
338
+ }), /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("rect", {
358
+ width: "18",
359
+ height: "18",
360
+ x: "3",
361
+ y: "3",
362
+ rx: "2"
363
+ }), /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("rect", {
383
+ width: "18",
384
+ height: "18",
385
+ x: "3",
386
+ y: "3",
387
+ rx: "2"
388
+ }), /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("rect", {
408
+ width: "18",
409
+ height: "18",
410
+ x: "3",
411
+ y: "3",
412
+ rx: "2"
413
+ }), /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("path", { d: "M5 12h14" }), /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("path", { d: "M5 3a2 2 0 0 0-2 2" }),
478
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M19 3a2 2 0 0 1 2 2" }),
479
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M21 19a2 2 0 0 1-2 2" }),
480
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M5 21a2 2 0 0 1-2-2" }),
481
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M9 3h1" }),
482
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M9 21h1" }),
483
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M14 3h1" }),
484
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M14 21h1" }),
485
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M3 9v1" }),
486
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M21 9v1" }),
487
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M3 14v1" }),
488
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M21 14v1" })
489
+ ]
490
+ });
491
+ }
492
+
236
493
  //#endregion
237
494
  //#region src/ui/icons/square-round-corner.tsx
238
495
  function SquareRoundCornerIcon({ size, width, height, ...props }) {
@@ -315,6 +572,25 @@ function TypeIcon({ size, width, height, ...props }) {
315
572
  });
316
573
  }
317
574
 
575
+ //#endregion
576
+ //#region src/ui/icons/x.tsx
577
+ function XIcon({ size, width, height, ...props }) {
578
+ return /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("path", { d: "M18 6 6 18" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m6 6 12 12" })]
591
+ });
592
+ }
593
+
318
594
  //#endregion
319
595
  //#region src/ui/bubble-menu/separator.tsx
320
596
  function BubbleMenuSeparator({ className }) {
@@ -364,7 +640,177 @@ const BubbleMenu = {
364
640
  };
365
641
 
366
642
  //#endregion
367
- //#region src/ui/inspector/provider.tsx
643
+ //#region src/ui/editor-focus-scope.tsx
644
+ const FocusScopeContext = react.createContext(null);
645
+ function useEditorFocusScope() {
646
+ const context = react.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 } = (0, _tiptap_react.useCurrentEditor)();
652
+ const scopeRefs = react.useRef(/* @__PURE__ */ new Set());
653
+ const handleFocusIn = react.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.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(_tiptap_pm_state.TextSelection.create(transaction.doc, 0));
666
+ editor.view.dispatch(transaction);
667
+ }
668
+ }, [editor]);
669
+ const registerScope = react.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.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.useEffect(() => {
682
+ const defaultFocusPlugin = editor?.state.plugins.find((plugin) => plugin.spec.key === _tiptap_react.extensions.focusEventsPluginKey);
683
+ if (editor && defaultFocusPlugin) {
684
+ editor.unregisterPlugin(_tiptap_react.extensions.focusEventsPluginKey);
685
+ const pluginKey = new _tiptap_pm_state.PluginKey("inspectorReactEmailFocusEvents");
686
+ editor.registerPlugin(new _tiptap_pm_state.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_slot.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: require_root.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: require_root.LinkIcon,
745
+ label: "Link"
746
+ },
747
+ codeBlock: {
748
+ icon: require_root.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: require_root.TextQuoteIcon,
765
+ label: "Blockquote"
766
+ },
767
+ bulletList: {
768
+ icon: require_root.ListIcon,
769
+ label: "Bullet List"
770
+ },
771
+ orderedList: {
772
+ icon: require_root.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
368
814
  const IGNORED_NODES = ["doc", "text"];
369
815
  function getHierarchyAtPosition(editor, pos) {
370
816
  if (!editor) return [];
@@ -435,8 +881,11 @@ function useInspector() {
435
881
  if (!context) throw new Error("useInspector can only be called from inside the InspectorContext. This probably means you forgot the <Inspector.Provider>");
436
882
  return context;
437
883
  }
438
- function InspectorProvider({ children }) {
884
+ const InspectorRoot = react.forwardRef(function InspectorRoot$1({ children, asChild, ...restProps }, forwardedRef) {
439
885
  const { editor } = (0, _tiptap_react.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
+ }
440
889
  const target = (0, _tiptap_react.useEditorState)({
441
890
  editor,
442
891
  selector(context) {
@@ -478,75 +927,35 @@ function InspectorProvider({ children }) {
478
927
  if (target === "text") return [...getNodeHierarchy(editor)].reverse();
479
928
  return [];
480
929
  }, [editor, target]);
481
- const editorDomFocused = react.useRef(false);
482
- const inspectorFocused = react.useRef(false);
483
- react.useEffect(() => {
484
- const defaultFocusPlugin = editor?.state.plugins.find((plugin) => plugin.spec.key === _tiptap_core.extensions.focusEventsPluginKey);
485
- if (editor && defaultFocusPlugin) {
486
- editor?.unregisterPlugin(_tiptap_core.extensions.focusEventsPluginKey);
487
- const pluginKey = new _tiptap_pm_state.PluginKey("inspectorReactEmailFocusEvents");
488
- editor.registerPlugin(new _tiptap_pm_state.Plugin({
489
- key: pluginKey,
490
- props: { handleDOMEvents: {
491
- focus: (view, event) => {
492
- editorDomFocused.current = true;
493
- editor.isFocused = true;
494
- const transaction = editor.state.tr.setMeta("focus", { event }).setMeta("addToHistory", false);
495
- view.dispatch(transaction);
496
- return false;
497
- },
498
- blur: (view, event) => {
499
- editorDomFocused.current = false;
500
- if (!inspectorFocused.current) {
501
- editor.isFocused = false;
502
- const transaction = editor.state.tr.setMeta("blur", { event }).setMeta("addToHistory", false);
503
- view.dispatch(transaction);
504
- }
505
- return false;
506
- }
507
- } }
508
- }));
509
- return () => {
510
- editor?.unregisterPlugin(pluginKey);
511
- editor?.registerPlugin(defaultFocusPlugin);
512
- };
513
- }
514
- }, [editor]);
930
+ const Component = asChild ? _radix_ui_react_slot.Slot : "aside";
515
931
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InspectorContext.Provider, {
516
932
  value: {
517
933
  target,
518
- pathFromRoot,
519
- focus: (event) => {
520
- inspectorFocused.current = true;
521
- if (editor) {
522
- editor.isFocused = true;
523
- const transaction = editor.state.tr.setMeta("focus", { event }).setMeta("addToHistory", false);
524
- editor.view.dispatch(transaction);
525
- }
526
- },
527
- blur: (event) => {
528
- inspectorFocused.current = false;
529
- if (!editorDomFocused.current && editor) {
530
- editor.isFocused = false;
531
- const transaction = editor.state.tr.setMeta("blur", { event }).setMeta("addToHistory", false);
532
- editor.view.dispatch(transaction);
533
- }
534
- }
934
+ pathFromRoot
535
935
  },
536
- children
936
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditorFocusScopeProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditorFocusScope, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
937
+ ref: forwardedRef,
938
+ ...restProps,
939
+ tabIndex: -1,
940
+ children
941
+ }) }) })
537
942
  });
538
- }
943
+ });
539
944
 
540
945
  //#endregion
541
946
  //#region src/ui/inspector/breadcrumb.tsx
542
947
  function InspectorBreadcrumb({ children }) {
543
948
  const { editor } = (0, _tiptap_react.useCurrentEditor)();
544
949
  const { pathFromRoot } = useInspector();
545
- return children(react.default.useMemo(() => {
950
+ const segments = react.default.useMemo(() => {
546
951
  return [{
547
952
  node: null,
548
953
  focus() {
549
- 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();
550
959
  }
551
960
  }, ...pathFromRoot.map((focusedNode) => ({
552
961
  node: focusedNode,
@@ -555,38 +964,485 @@ function InspectorBreadcrumb({ children }) {
555
964
  editor?.commands.focus();
556
965
  }
557
966
  }))];
558
- }, [pathFromRoot]));
967
+ }, [editor, pathFromRoot]);
968
+ if (children) return children(segments);
969
+ return /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("nav", {
994
+ "data-re-inspector-breadcrumb": "",
995
+ children: /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)("li", {
1001
+ "data-re-inspector-breadcrumb-item": "",
1002
+ children: [
1003
+ i !== 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1004
+ "data-re-inspector-breadcrumb-separator": "",
1005
+ children: "/"
1006
+ }),
1007
+ i === 1 && hasEllipsis && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1008
+ "data-re-inspector-breadcrumb-ellipsis": "",
1009
+ children: "…"
1010
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1011
+ "data-re-inspector-breadcrumb-separator": "",
1012
+ children: "/"
1013
+ })] }),
1014
+ /* @__PURE__ */ (0, react_jsx_runtime.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
+ });
559
1026
  }
560
1027
 
561
1028
  //#endregion
562
- //#region src/ui/inspector/document.tsx
563
- function ensureAllProperties(currentStyles, themeDefaults) {
564
- return currentStyles.map((group) => {
565
- const defaultGroup = themeDefaults.find((g) => group.id ? g.id === group.id : g.title === group.title);
566
- if (!defaultGroup || defaultGroup.inputs.length === 0) return group;
567
- const existingProps = new Set(group.inputs.map((i) => `${i.classReference}:${i.prop}`));
568
- const missingInputs = defaultGroup.inputs.filter((defaultInput) => !existingProps.has(`${defaultInput.classReference}:${defaultInput.prop}`)).map((defaultInput) => {
569
- const propDef = require_extension.SUPPORTED_CSS_PROPERTIES[defaultInput.prop];
570
- if (propDef && propDef.type === "number") return {
571
- ...defaultInput,
572
- value: "",
573
- placeholder: String(propDef.defaultValue)
574
- };
575
- return { ...defaultInput };
576
- });
577
- if (missingInputs.length === 0) return group;
578
- return {
579
- ...group,
580
- 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.useRef(0);
1032
+ const startValueRef = react.useRef(0);
1033
+ const isDraggingRef = react.useRef(false);
1034
+ react.useEffect(() => {
1035
+ return () => {
1036
+ document.body.style.removeProperty("cursor");
1037
+ document.body.style.removeProperty("user-select");
581
1038
  };
582
- });
1039
+ }, []);
1040
+ const onPointerDown = react.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.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.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
+ } };
583
1072
  }
584
- function applyStyleChange(styles, themeName, { classReference, prop, newValue }) {
585
- let found = false;
586
- const updatedStyles = styles.map((styleGroup) => {
587
- if (styleGroup.inputs.find((input) => input.classReference === classReference && input.prop === prop)) {
588
- found = true;
589
- return {
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.useState(() => toDisplayString(value));
1082
+ const isFocusedRef = react.useRef(false);
1083
+ const cancelledRef = react.useRef(false);
1084
+ react.useEffect(() => {
1085
+ if (!isFocusedRef.current) setDisplayValue(toDisplayString(value));
1086
+ }, [value]);
1087
+ const commit = react.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.useCallback((e) => {
1114
+ setDisplayValue(e.target.value);
1115
+ }, []),
1116
+ onBlur: react.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.useCallback((e) => {
1125
+ isFocusedRef.current = true;
1126
+ e.target.select();
1127
+ }, []),
1128
+ onKeyDown: react.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__ */ (0, react_jsx_runtime.jsxs)("span", {
1177
+ "data-re-inspector-color-control": "",
1178
+ className,
1179
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1180
+ type: "color",
1181
+ "data-re-inspector-color-trigger": "",
1182
+ value: normalizeHex(value),
1183
+ onChange: (e) => onChange(e.target.value)
1184
+ }), /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("select", {
1219
+ "data-re-inspector-select": "",
1220
+ ...rest,
1221
+ children
1222
+ });
1223
+ }
1224
+ function SelectItem(props) {
1225
+ return /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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.forwardRef(function TextField$1({ className, ...rest }, ref) {
1245
+ return /* @__PURE__ */ (0, react_jsx_runtime.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.forwardRef(function Textarea$1({ className, ...rest }, ref) {
1256
+ return /* @__PURE__ */ (0, react_jsx_runtime.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.createContext(null);
1268
+ function Root$1({ value, onValueChange, children, className }) {
1269
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToggleGroupContext.Provider, {
1270
+ value: {
1271
+ value,
1272
+ onValueChange
1273
+ },
1274
+ children: /* @__PURE__ */ (0, react_jsx_runtime.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.useContext(ToggleGroupContext);
1284
+ const isActive = ctx?.value === value;
1285
+ return /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("span", {
1303
+ "data-re-inspector-tooltip": "",
1304
+ ...rest,
1305
+ children
1306
+ });
1307
+ }
1308
+ function TooltipTrigger({ children, ...rest }) {
1309
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1310
+ "data-re-inspector-tooltip-trigger": "",
1311
+ ...rest,
1312
+ children
1313
+ });
1314
+ }
1315
+ function TooltipContent({ children, ...rest }) {
1316
+ return /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)("span", {
1342
+ "data-re-inspector-number": "",
1343
+ children: [
1344
+ icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1345
+ className: "pointer-events-none",
1346
+ "aria-hidden": true,
1347
+ children: icon
1348
+ }),
1349
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextField, {
1350
+ value: displayValue,
1351
+ placeholder,
1352
+ type: "text",
1353
+ inputMode: "numeric",
1354
+ "data-type": "number",
1355
+ ...handlers
1356
+ }),
1357
+ hasUnitSelect ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Root$2, {
1358
+ value: unit,
1359
+ onChange: (e) => onUnitChange(e.target.value),
1360
+ children: unitOptions.map((opt) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Item$1, {
1361
+ value: opt,
1362
+ children: opt
1363
+ }, opt))
1364
+ }) : unit && /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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.useState(initialCollapsed);
1387
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1388
+ "data-re-inspector-section": "",
1389
+ ...title ? { "data-has-title": "" } : {},
1390
+ children: [title && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1391
+ "data-re-inspector-section-header": "",
1392
+ children: [
1393
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1394
+ type: "button",
1395
+ "data-re-inspector-section-toggle": "",
1396
+ onClick: () => setCollapsed((c) => !c),
1397
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text, { children: title })
1398
+ }),
1399
+ collapsed && onAdd && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Trigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
1400
+ onClick: onAdd,
1401
+ "aria-label": `Add ${title}`,
1402
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PlusIcon, { size: 16 })
1403
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Content, { children: `Add ${title}` })] }),
1404
+ !collapsed && onRemove && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Trigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
1405
+ onClick: onRemove,
1406
+ "aria-label": `Remove ${title}`,
1407
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MinusIcon, { size: 16 })
1408
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Content, { children: `Remove ${title}` })] })
1409
+ ]
1410
+ }), !collapsed && children && /* @__PURE__ */ (0, react_jsx_runtime.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 = require_extension.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)) {
1444
+ found = true;
1445
+ return {
590
1446
  ...styleGroup,
591
1447
  inputs: styleGroup.inputs.map((input) => {
592
1448
  if (input.classReference === classReference && input.prop === prop) return {
@@ -652,28 +1508,1474 @@ function InspectorDocument({ children }) {
652
1508
  function findStyleValue(classReference, prop) {
653
1509
  for (const group of groups) {
654
1510
  const input = group.inputs.find((i) => i.classReference === classReference && i.prop === prop);
655
- if (input) return input.value;
1511
+ if (input && input.value !== void 0) return input.value;
656
1512
  }
657
1513
  for (const group of themeDefaults) {
658
1514
  const input = group.inputs.find((i) => i.classReference === classReference && i.prop === prop);
659
- if (input) return input.value;
1515
+ if (input && input.value !== void 0) return input.value;
660
1516
  }
661
1517
  return require_extension.SUPPORTED_CSS_PROPERTIES[prop]?.defaultValue ?? "";
662
1518
  }
663
- if (target === "doc") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: children({
1519
+ if (target !== "doc") return null;
1520
+ const context = {
664
1521
  styles: groups,
665
1522
  setGlobalStyle,
666
1523
  batchSetGlobalStyle,
667
1524
  findStyleValue
1525
+ };
1526
+ if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: children(context) });
1527
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InspectorDocumentDefaults, { context });
1528
+ }
1529
+ function InspectorDocumentDefaults({ context }) {
1530
+ const { findStyleValue, setGlobalStyle } = context;
1531
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Section, {
1532
+ title: "Background",
1533
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Color" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorInput, {
1534
+ value: String(findStyleValue("body", "backgroundColor") ?? ""),
1535
+ onChange: (v) => setGlobalStyle("body", "backgroundColor", v)
1536
+ })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Padding" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NumberInput, {
1537
+ value: findStyleValue("body", "padding") ?? "",
1538
+ onChange: (v) => setGlobalStyle("body", "padding", v),
1539
+ unit: "px"
1540
+ })] })]
1541
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Section, {
1542
+ title: "Container",
1543
+ children: [
1544
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Color" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorInput, {
1545
+ value: String(findStyleValue("container", "backgroundColor") ?? ""),
1546
+ onChange: (v) => setGlobalStyle("container", "backgroundColor", v)
1547
+ })] }),
1548
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Width" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NumberInput, {
1549
+ value: findStyleValue("container", "width") ?? "",
1550
+ onChange: (v) => setGlobalStyle("container", "width", v),
1551
+ unit: "px"
1552
+ })] }),
1553
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Padding" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NumberInput, {
1554
+ value: findStyleValue("container", "padding") ?? "",
1555
+ onChange: (v) => setGlobalStyle("container", "padding", v),
1556
+ unit: "px"
1557
+ })] }),
1558
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Rounded" }), /* @__PURE__ */ (0, react_jsx_runtime.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 = require_extension.useEmailTheming(editor);
1580
+ const globalColors = react.useMemo(() => {
1581
+ const colors = /* @__PURE__ */ new Set();
1582
+ const cssJs = require_extension.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 = (0, _tiptap_react.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.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
+ require_event_bus.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__ */ (0, react_jsx_runtime.jsx)(Section, {
1790
+ title: "Attributes",
1791
+ initialCollapsed,
1792
+ children: nodeAttrs.map(({ name, config, value }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: config.label }), config.type === "select" && config.options ? /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)(Item$1, {
1800
+ value: val,
1801
+ children: label
1802
+ }, val))
1803
+ }) : config.type === "number" ? /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)(Textarea, {
1809
+ value: String(value ?? config.defaultValue),
1810
+ onChange: (e) => setAttr(name, e.target.value)
1811
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)(Section, {
1838
+ title: "Background",
1839
+ initialCollapsed,
1840
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Color" }), /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)(PanelTopIcon, { size: 14 })
1853
+ },
1854
+ {
1855
+ side: "Right",
1856
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PanelRightIcon, { size: 14 })
1857
+ },
1858
+ {
1859
+ side: "Bottom",
1860
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PanelBottomIcon, { size: 14 })
1861
+ },
1862
+ {
1863
+ side: "Left",
1864
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.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 = require_extension.SUPPORTED_CSS_PROPERTIES.borderStyle.options;
1881
+ function BorderPicker({ styleObject, onChange }) {
1882
+ const [expanded, setExpanded] = react.useState(() => !allSidesEqual(styleObject));
1883
+ const handleModeChange = (mode) => {
1884
+ if (mode === "uniform" && expanded) {
1885
+ const width = getSideValue(styleObject, "Top", "Width") ?? String(require_extension.SUPPORTED_CSS_PROPERTIES.borderWidth.defaultValue);
1886
+ const color = getSideValue(styleObject, "Top", "Color") ?? String(require_extension.SUPPORTED_CSS_PROPERTIES.borderColor.defaultValue);
1887
+ const style = getSideValue(styleObject, "Top", "Style") ?? String(require_extension.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(require_extension.SUPPORTED_CSS_PROPERTIES.borderWidth.defaultValue);
1898
+ const color = styleObject.borderColor ?? String(require_extension.SUPPORTED_CSS_PROPERTIES.borderColor.defaultValue);
1899
+ const style = styleObject.borderStyle ?? String(require_extension.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__ */ (0, react_jsx_runtime.jsxs)(Root$1, {
1908
+ value: expanded ? "individual" : "uniform",
1909
+ onValueChange: handleModeChange,
1910
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Trigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Item, {
1911
+ value: "uniform",
1912
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SquareIcon, { size: 16 })
1913
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Content, { children: "Uniform" })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Trigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Item, {
1914
+ value: "individual",
1915
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SquareDashedIcon, { size: 16 })
1916
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Content, { children: "Per side" })] })]
1917
+ });
1918
+ if (expanded) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1919
+ className: "flex flex-col gap-2",
1920
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Border" }), modeToggle] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1921
+ className: "flex flex-col gap-1.5",
1922
+ children: SIDES.map(({ side, icon }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1923
+ className: "flex items-center gap-1",
1924
+ children: [
1925
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BorderWidthInput, {
1926
+ icon,
1927
+ value: getSideValue(styleObject, side, "Width"),
1928
+ onChange: (v) => onChange(`border${side}Width`, v)
1929
+ }),
1930
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Root$2, {
1931
+ value: String(getSideValue(styleObject, side, "Style") ?? require_extension.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__ */ (0, react_jsx_runtime.jsx)(Item$1, {
1934
+ value: val,
1935
+ children: label
1936
+ }, val))
1937
+ }),
1938
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorInput, {
1939
+ value: String(getSideValue(styleObject, side, "Color") ?? require_extension.SUPPORTED_CSS_PROPERTIES.borderColor.defaultValue),
1940
+ onChange: (v) => onChange(`border${side}Color`, v)
1941
+ }),
1942
+ /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)(XIcon, { size: 14 })
1952
+ })
1953
+ ]
1954
+ }, side))
1955
+ })]
1956
+ });
1957
+ const uniformColor = String(styleObject.borderColor ?? require_extension.SUPPORTED_CSS_PROPERTIES.borderColor.defaultValue);
1958
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1959
+ className: "flex flex-col gap-3",
1960
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Border" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1961
+ className: "flex items-center gap-1",
1962
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BorderWidthInput, {
1963
+ value: styleObject.borderWidth ?? "",
1964
+ onChange: (v) => onChange("borderWidth", v)
1965
+ }), modeToggle]
1966
+ })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {}), /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)("span", {
1985
+ "data-re-inspector-number": "",
1986
+ children: [
1987
+ icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1988
+ className: "pointer-events-none",
1989
+ "aria-hidden": true,
1990
+ children: icon
1991
+ }),
1992
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextField, {
1993
+ type: "text",
1994
+ inputMode: "numeric",
1995
+ "data-type": "number",
1996
+ value: displayValue,
1997
+ placeholder: String(require_extension.SUPPORTED_CSS_PROPERTIES.borderWidth.defaultValue),
1998
+ ...handlers
1999
+ }),
2000
+ /* @__PURE__ */ (0, react_jsx_runtime.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.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__ */ (0, react_jsx_runtime.jsxs)(Root$1, {
2022
+ value: expanded ? "individual" : "uniform",
2023
+ onValueChange: handleModeChange,
2024
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Trigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Item, {
2025
+ value: "uniform",
2026
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SquareIcon, { size: 16 })
2027
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Content, { children: "Uniform" })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Trigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Item, {
2028
+ value: "individual",
2029
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SquareDashedIcon, { size: 16 })
2030
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Content, { children: "Per corner" })] })]
2031
+ });
2032
+ if (expanded) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2033
+ className: "flex flex-col gap-2",
2034
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Rounded" }), modeToggle] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2035
+ className: "flex flex-col items-center gap-1.5",
2036
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2037
+ className: "flex items-center gap-1.5",
2038
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RadiusInput, {
2039
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)(RadiusInput, {
2048
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)("div", {
2058
+ className: "flex items-center gap-1.5",
2059
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RadiusInput, {
2060
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)(RadiusInput, {
2069
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Rounded" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2082
+ className: "flex items-center gap-1",
2083
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)("span", {
2104
+ "data-re-inspector-number": "",
2105
+ children: [
2106
+ icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2107
+ className: "pointer-events-none",
2108
+ "aria-hidden": true,
2109
+ children: icon
2110
+ }),
2111
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextField, {
2112
+ type: "text",
2113
+ inputMode: "numeric",
2114
+ "data-type": "number",
2115
+ value: displayValue,
2116
+ ...handlers
2117
+ }),
2118
+ /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)(Section, {
2173
+ title: "Border",
2174
+ initialCollapsed,
2175
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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.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__ */ (0, react_jsx_runtime.jsxs)(Root$1, {
2226
+ value: expanded ? "individual" : "uniform",
2227
+ onValueChange: handleModeChange,
2228
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Trigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Item, {
2229
+ value: "uniform",
2230
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SquareIcon, { size: 16 })
2231
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Content, { children: "Uniform" })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Trigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Item, {
2232
+ value: "individual",
2233
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SquareDashedIcon, { size: 16 })
2234
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Content, { children: "Per side" })] })]
2235
+ });
2236
+ if (expanded) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2237
+ className: "flex flex-col gap-2",
2238
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Padding" }), modeToggle] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2239
+ className: "flex flex-col items-center gap-1.5",
2240
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2241
+ className: "flex items-center gap-1",
2242
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PaddingInput, {
2243
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PanelTopIcon, { size: 14 }),
2244
+ value: value.paddingTop,
2245
+ onChange: (v) => handleChange("paddingTop", v),
2246
+ unit
2247
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PaddingInput, {
2248
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PanelRightIcon, { size: 14 }),
2249
+ value: value.paddingRight,
2250
+ onChange: (v) => handleChange("paddingRight", v),
2251
+ unit
2252
+ })]
2253
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2254
+ className: "flex items-center gap-1",
2255
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PaddingInput, {
2256
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PanelBottomIcon, { size: 14 }),
2257
+ value: value.paddingBottom,
2258
+ onChange: (v) => handleChange("paddingBottom", v),
2259
+ unit
2260
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PaddingInput, {
2261
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PanelLeftIcon, { size: 14 }),
2262
+ value: value.paddingLeft,
2263
+ onChange: (v) => handleChange("paddingLeft", v),
2264
+ unit
2265
+ })]
2266
+ })]
2267
+ })]
2268
+ });
2269
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Padding" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2270
+ className: "flex items-center gap-1",
2271
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)("span", {
2292
+ "data-re-inspector-number": "",
2293
+ children: [
2294
+ icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2295
+ className: "pointer-events-none",
2296
+ "aria-hidden": true,
2297
+ children: icon
2298
+ }),
2299
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextField, {
2300
+ type: "text",
2301
+ inputMode: "numeric",
2302
+ "data-type": "number",
2303
+ value: displayValue,
2304
+ ...handlers
2305
+ }),
2306
+ /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)(Section, {
2319
+ title: "Padding",
2320
+ initialCollapsed,
2321
+ children: /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)(Section, {
2354
+ title: "Size",
2355
+ initialCollapsed,
2356
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Width" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NumberInput, {
2357
+ value: width,
2358
+ onChange: setWidth,
2359
+ unit: "px",
2360
+ placeholder: "auto",
2361
+ min: 0
2362
+ })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Height" }), /* @__PURE__ */ (0, react_jsx_runtime.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: require_root.BoldIcon,
2388
+ label: "Bold"
2389
+ },
2390
+ {
2391
+ value: "italic",
2392
+ icon: require_root.ItalicIcon,
2393
+ label: "Italic"
2394
+ },
2395
+ {
2396
+ value: "underline",
2397
+ icon: require_root.UnderlineIcon,
2398
+ label: "Underline"
2399
+ },
2400
+ {
2401
+ value: "line-through",
2402
+ icon: require_root.StrikethroughIcon,
2403
+ label: "Strikethrough"
2404
+ },
2405
+ {
2406
+ value: "code",
2407
+ icon: require_root.CodeIcon,
2408
+ label: "Code"
2409
+ },
2410
+ {
2411
+ value: "uppercase",
2412
+ icon: require_root.CaseUpperIcon,
2413
+ label: "Uppercase"
2414
+ }
2415
+ ];
2416
+ const ALIGNMENT_ITEMS = [
2417
+ {
2418
+ value: "left",
2419
+ alternativeIcon: require_root.AlignLeftIcon,
2420
+ icon: AlignStartVerticalIcon
2421
+ },
2422
+ {
2423
+ value: "center",
2424
+ alternativeIcon: require_root.AlignCenterIcon,
2425
+ icon: AlignCenterVerticalIcon
2426
+ },
2427
+ {
2428
+ value: "right",
2429
+ alternativeIcon: require_root.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__ */ (0, react_jsx_runtime.jsxs)(Section, {
2441
+ title: "Typography",
2442
+ initialCollapsed,
2443
+ children: [
2444
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Color" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorInput, {
2445
+ value: color,
2446
+ onChange: (v) => setStyle("color", v)
2447
+ })] }),
2448
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Size" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NumberInput, {
2449
+ value: fontSize,
2450
+ onChange: (v) => setStyle("fontSize", v),
2451
+ unit: "px",
2452
+ min: 1
2453
+ })] }),
2454
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Line height" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NumberInput, {
2455
+ value: lineHeight,
2456
+ onChange: (v) => setStyle("lineHeight", v),
2457
+ unit: "%"
2458
+ })] }),
2459
+ marks && toggleMark && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Format" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2460
+ className: "flex items-center gap-0.5",
2461
+ children: FORMAT_ITEMS.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Trigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconButton, {
2462
+ onClick: () => toggleMark(item.value),
2463
+ "aria-pressed": marks[item.value] ?? false,
2464
+ "aria-label": item.label,
2465
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(item.icon, { size: 16 })
2466
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Content, { children: item.label })] }, item.value))
2467
+ })] }),
2468
+ alignment && setAlignment && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Align" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Root$1, {
2469
+ value: alignment,
2470
+ onValueChange: setAlignment,
2471
+ children: ALIGNMENT_ITEMS.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Trigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Item, {
2472
+ value: item.value,
2473
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(item.icon, { size: 16 })
2474
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.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 = require_extension.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 = require_global_content.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 = require_extension.SUPPORTED_CSS_PROPERTIES[prop]?.unit;
2591
+ currentStyle[prop] = unit && typeof value === "number" ? `${value}${unit}` : String(value);
2592
+ }
2593
+ require_global_content.ensureBorderStyleFallback(currentStyle);
2594
+ const newStyle = require_global_content.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 } = (0, _tiptap_react.useCurrentEditor)();
2608
+ const theming = require_extension.useEmailTheming(editor);
2609
+ const { target } = useInspector();
2610
+ const documentColors = useDocumentColors(editor);
2611
+ const [localAttr, setLocalAttr] = react.useState(null);
2612
+ const focusedNode = typeof target === "object" && target !== null ? target : null;
2613
+ react.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 = require_global_content.inlineCssToJs(attrs.style || "");
2619
+ const css = require_extension.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__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: children(context) });
2662
+ return /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: getDefaultLayout(context.nodeType).sections.map((section) => {
2761
+ switch (section.type) {
2762
+ case "attributes": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AttributesSection, {
2763
+ ...context,
2764
+ initialCollapsed: section.initialCollapsed
2765
+ }, section.type);
2766
+ case "size": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SizeSection, {
2767
+ ...context,
2768
+ initialCollapsed: section.initialCollapsed
2769
+ }, section.type);
2770
+ case "typography": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypographySection, {
2771
+ ...context,
2772
+ initialCollapsed: section.initialCollapsed
2773
+ }, section.type);
2774
+ case "padding": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PaddingSection, {
2775
+ ...context,
2776
+ initialCollapsed: section.initialCollapsed
2777
+ }, section.type);
2778
+ case "background": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BackgroundSection, {
2779
+ ...context,
2780
+ initialCollapsed: section.initialCollapsed
2781
+ }, section.type);
2782
+ case "border": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BorderSection, {
2783
+ ...context,
2784
+ initialCollapsed: section.initialCollapsed
2785
+ }, section.type);
2786
+ default: return null;
2787
+ }
668
2788
  }) });
669
2789
  }
670
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__ */ (0, react_jsx_runtime.jsxs)(Section, {
2796
+ title: "Link",
2797
+ initialCollapsed,
2798
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "URL" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextField, {
2799
+ type: "text",
2800
+ value: linkHref,
2801
+ readOnly: true
2802
+ })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PropRow, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, { children: "Color" }), /* @__PURE__ */ (0, react_jsx_runtime.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 (0, _tiptap_react.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 require_global_content.inlineCssToJs(linkStyle).color || themeLinkColor || fallback;
2836
+ }
2837
+ function updateLinkColor(editor, linkStyle, color) {
2838
+ const styleObj = require_global_content.inlineCssToJs(linkStyle);
2839
+ styleObj.color = color;
2840
+ const newStyle = require_global_content.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 = require_global_content.expandShorthandProperties(require_global_content.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
+ require_global_content.ensureBorderStyleFallback(expanded);
2887
+ const newStyle = require_global_content.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 } = (0, _tiptap_react.useCurrentEditor)();
2906
+ const theming = require_extension.useEmailTheming(editor);
2907
+ const { target } = useInspector();
2908
+ const documentColors = useDocumentColors(editor);
2909
+ const linkMark = useLinkMark(editor);
2910
+ const activeMarks = (0, _tiptap_react.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 = (0, _tiptap_react.useEditorState)({
2920
+ editor,
2921
+ selector: ({ editor: ed }) => getParentBlockInfo(ed)
2922
+ });
2923
+ if (!editor || !theming || target !== "text") return null;
2924
+ const css = require_extension.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 = require_global_content.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__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: children(context) });
2958
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InspectorTextDefaults, { context });
2959
+ }
2960
+ function InspectorTextDefaults({ context }) {
2961
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypographySection, { ...context }), context.isLinkActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LinkSection, { ...context })] });
2962
+ }
2963
+
671
2964
  //#endregion
672
2965
  //#region src/ui/inspector/index.tsx
673
2966
  const Inspector = {
674
- Provider: InspectorProvider,
2967
+ Root: InspectorRoot,
675
2968
  Breadcrumb: InspectorBreadcrumb,
676
- 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
677
2979
  };
678
2980
 
679
2981
  //#endregion
@@ -727,64 +3029,73 @@ exports.BubbleMenuUnderline = require_root.BubbleMenuUnderline;
727
3029
  exports.BubbleMenuUppercase = require_root.BubbleMenuUppercase;
728
3030
  exports.CODE = require_root.CODE;
729
3031
  exports.CaseUpperIcon = require_root.CaseUpperIcon;
730
- exports.Check = require_root.Check;
731
- exports.ChevronDown = require_root.ChevronDown;
732
- exports.Code = require_root.Code;
3032
+ exports.CheckIcon = require_root.CheckIcon;
3033
+ exports.ChevronDownIcon = require_root.ChevronDownIcon;
733
3034
  exports.CodeIcon = require_root.CodeIcon;
734
- exports.Columns2 = require_root.Columns2;
735
- exports.Columns3 = require_root.Columns3;
736
- exports.Columns4 = require_root.Columns4;
3035
+ exports.Columns2Icon = require_root.Columns2Icon;
3036
+ exports.Columns3Icon = require_root.Columns3Icon;
3037
+ exports.Columns4Icon = require_root.Columns4Icon;
737
3038
  exports.CommandList = require_root.CommandList;
3039
+ exports.CornerBottomLeftIcon = CornerBottomLeftIcon;
3040
+ exports.CornerBottomRightIcon = CornerBottomRightIcon;
3041
+ exports.CornerTopLeftIcon = CornerTopLeftIcon;
3042
+ exports.CornerTopRightIcon = CornerTopRightIcon;
738
3043
  exports.DIVIDER = require_root.DIVIDER;
3044
+ exports.EditorFocusScope = EditorFocusScope;
3045
+ exports.EditorFocusScopeProvider = EditorFocusScopeProvider;
739
3046
  exports.ExternalLinkIcon = require_root.ExternalLinkIcon;
740
3047
  exports.FOUR_COLUMNS = require_root.FOUR_COLUMNS;
741
3048
  exports.H1 = require_root.H1;
742
3049
  exports.H2 = require_root.H2;
743
3050
  exports.H3 = require_root.H3;
744
- exports.Heading1 = require_root.Heading1;
745
- exports.Heading1Icon = require_root.Heading1;
746
- exports.Heading2 = require_root.Heading2;
747
- exports.Heading3 = require_root.Heading3;
3051
+ exports.Heading1Icon = require_root.Heading1Icon;
3052
+ exports.Heading2Icon = require_root.Heading2Icon;
3053
+ exports.Heading3Icon = require_root.Heading3Icon;
748
3054
  exports.ImageIcon = ImageIcon;
749
3055
  exports.Inspector = Inspector;
750
3056
  exports.ItalicIcon = require_root.ItalicIcon;
751
3057
  exports.LayoutIcon = LayoutIcon;
752
3058
  exports.LinkIcon = require_root.LinkIcon;
753
- exports.List = require_root.List;
754
- exports.ListIcon = require_root.List;
755
- exports.ListOrdered = require_root.ListOrdered;
756
- exports.ListOrderedIcon = require_root.ListOrdered;
3059
+ exports.ListIcon = require_root.ListIcon;
3060
+ exports.ListOrderedIcon = require_root.ListOrderedIcon;
757
3061
  exports.MinusIcon = MinusIcon;
758
- exports.MousePointer = require_root.MousePointer;
759
3062
  exports.MousePointerClickIcon = MousePointerClickIcon;
3063
+ exports.MousePointerIcon = require_root.MousePointerIcon;
760
3064
  exports.NUMBERED_LIST = require_root.NUMBERED_LIST;
761
3065
  exports.NodeSelectorContent = require_root.NodeSelectorContent;
762
3066
  exports.NodeSelectorRoot = require_root.NodeSelectorRoot;
763
3067
  exports.NodeSelectorTrigger = require_root.NodeSelectorTrigger;
3068
+ exports.PanelBottomIcon = PanelBottomIcon;
3069
+ exports.PanelLeftIcon = PanelLeftIcon;
3070
+ exports.PanelRightIcon = PanelRightIcon;
3071
+ exports.PanelTopIcon = PanelTopIcon;
764
3072
  exports.PencilIcon = require_root.PencilIcon;
3073
+ exports.PlusIcon = PlusIcon;
765
3074
  exports.QUOTE = require_root.QUOTE;
766
- exports.QuoteIcon = require_root.TextQuote;
767
- exports.Rows2 = require_root.Rows2;
3075
+ exports.Rows2Icon = require_root.Rows2Icon;
768
3076
  exports.SECTION = require_root.SECTION;
769
3077
  exports.SlashCommand = SlashCommand;
770
- exports.SplitSquareVertical = require_root.SplitSquareVertical;
771
- exports.SquareCode = require_root.SquareCode;
3078
+ exports.SplitSquareVerticalIcon = require_root.SplitSquareVerticalIcon;
3079
+ exports.SquareCodeIcon = require_root.SquareCodeIcon;
3080
+ exports.SquareDashedIcon = SquareDashedIcon;
3081
+ exports.SquareIcon = SquareIcon;
772
3082
  exports.SquareRoundCornerIcon = SquareRoundCornerIcon;
773
3083
  exports.StrikethroughIcon = require_root.StrikethroughIcon;
774
3084
  exports.TEXT = require_root.TEXT;
775
3085
  exports.THREE_COLUMNS = require_root.THREE_COLUMNS;
776
3086
  exports.TWO_COLUMNS = require_root.TWO_COLUMNS;
777
3087
  exports.TableIcon = TableIcon;
778
- exports.Text = require_root.Text;
779
3088
  exports.TextIcon = require_root.TextIcon;
780
- exports.TextQuote = require_root.TextQuote;
3089
+ exports.TextQuoteIcon = require_root.TextQuoteIcon;
781
3090
  exports.TypeIcon = TypeIcon;
782
3091
  exports.UnderlineIcon = require_root.UnderlineIcon;
783
3092
  exports.UnlinkIcon = require_root.UnlinkIcon;
3093
+ exports.XIcon = XIcon;
784
3094
  exports.bubbleMenuTriggers = require_root.bubbleMenuTriggers;
785
3095
  exports.defaultSlashCommands = require_root.defaultSlashCommands;
786
3096
  exports.filterAndRankItems = require_root.filterAndRankItems;
787
3097
  exports.isAtMaxColumnsDepth = require_root.isAtMaxColumnsDepth;
788
3098
  exports.isInsideNode = require_root.isInsideNode;
789
3099
  exports.scoreItem = require_root.scoreItem;
790
- exports.useBubbleMenuContext = require_root.useBubbleMenuContext;
3100
+ exports.useBubbleMenuContext = require_root.useBubbleMenuContext;
3101
+ exports.useEditorFocusScope = useEditorFocusScope;