@lit-pigeon/editor 0.3.1 → 0.3.3

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.
package/dist/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { css as b, LitElement as g, html as l, nothing as te } from "lit";
2
2
  import { property as p, state as d, customElement as u } from "lit/decorators.js";
3
3
  import { t as s, c as Bt, r as po } from "./templates.js";
4
- import { P as Ur } from "./templates.js";
5
- import { getAllBlockDefinitions as co, getBlockDefinition as yt, updateBlock as ct, createBlock as Ye, insertBlock as ce, createColumn as Ie, insertRow as oe, createRow as Pe, cloneRowWithNewIds as jt, createBodySelection as Rt, deleteBlock as ho, deleteRow as Lt, duplicateBlock as go, duplicateRow as zt, generateId as Mt, EditorState as Ht, createHistoryPlugin as Ft, undo as uo, redo as bo, InMemoryTemplateStorage as vo, InMemoryRowLibraryStorage as fo, SYSTEM_LINK_TYPES as mo, createDocStep as dt, createDefaultDocument as _o, HISTORY_PLUGIN_NAME as Nt, canUndo as yo, canRedo as xo, createBlockSelection as ht, createRowSelection as Ut, createColumnSelection as $o, moveRow as wo, moveBlock as ko, updateRowAttributes as Co, addColumn as Io, removeColumn as Po, resizeColumns as To } from "@lit-pigeon/core";
4
+ import { P as Kr } from "./templates.js";
5
+ import { getAllBlockDefinitions as co, getBlockDefinition as yt, updateBlock as ct, createBlock as Ve, insertBlock as ce, createColumn as Ie, insertRow as oe, createRow as Te, cloneRowWithNewIds as jt, createBodySelection as Mt, deleteBlock as ho, deleteRow as Rt, duplicateBlock as go, duplicateRow as Lt, generateId as zt, EditorState as Ht, createHistoryPlugin as Ft, undo as uo, redo as bo, InMemoryTemplateStorage as vo, InMemoryRowLibraryStorage as fo, SYSTEM_LINK_TYPES as mo, createDocStep as dt, createDefaultDocument as _o, HISTORY_PLUGIN_NAME as Nt, canUndo as yo, canRedo as xo, createBlockSelection as ht, createRowSelection as Ut, createColumnSelection as $o, moveRow as wo, moveBlock as ko, updateRowAttributes as Co, addColumn as Io, removeColumn as To, resizeColumns as Po } from "@lit-pigeon/core";
6
6
  import { unsafeHTML as eo } from "lit/directives/unsafe-html.js";
7
- import { l as xt, r as So } from "./rich-text.js";
7
+ import { l as xt, r as So } from "./rich-text-bridge.js";
8
8
  import { styleMap as Oo } from "lit/directives/style-map.js";
9
+ import "./rich-text.js";
9
10
  const Kt = b`
10
11
  /* base palette */
11
12
  --pigeon-bg: #0f172a; /* slate-900 */
@@ -42,7 +43,7 @@ const Kt = b`
42
43
  0 2px 4px -2px rgb(0 0 0 / 0.4);
43
44
  --pigeon-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5),
44
45
  0 4px 6px -4px rgb(0 0 0 / 0.5);
45
- `, Do = b`
46
+ `, Eo = b`
46
47
  :host {
47
48
  /* base palette */
48
49
  --pigeon-bg: #ffffff;
@@ -112,12 +113,12 @@ const Kt = b`
112
113
  }
113
114
  }
114
115
  `;
115
- var Eo = Object.defineProperty, Ao = Object.getOwnPropertyDescriptor, xe = (e, t, o, r) => {
116
+ var Do = Object.defineProperty, Ao = Object.getOwnPropertyDescriptor, xe = (e, t, o, r) => {
116
117
  for (var i = r > 1 ? void 0 : r ? Ao(t, o) : t, n = e.length - 1, a; n >= 0; n--)
117
118
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
118
- return r && i && Eo(t, o, i), i;
119
+ return r && i && Do(t, o, i), i;
119
120
  };
120
- let K = class extends g {
121
+ let V = class extends g {
121
122
  constructor() {
122
123
  super(...arguments), this.canUndo = !1, this.canRedo = !1, this.device = "desktop", this.fullscreen = !1, this._exportMenuOpen = !1;
123
124
  }
@@ -318,7 +319,10 @@ let K = class extends g {
318
319
  }));
319
320
  }
320
321
  _toggleExportMenu() {
321
- this._exportMenuOpen = !this._exportMenuOpen;
322
+ this._exportMenuOpen = !this._exportMenuOpen, this._exportMenuOpen && this.dispatchEvent(new CustomEvent("toolbar-export", {
323
+ bubbles: !0,
324
+ composed: !0
325
+ }));
322
326
  }
323
327
  _onExportHtml() {
324
328
  this._exportMenuOpen = !1, this.dispatchEvent(new CustomEvent("pigeon:export-html", {
@@ -339,7 +343,7 @@ let K = class extends g {
339
343
  }));
340
344
  }
341
345
  };
342
- K.styles = b`
346
+ V.styles = b`
343
347
  :host {
344
348
  display: flex;
345
349
  align-items: center;
@@ -471,27 +475,27 @@ K.styles = b`
471
475
  `;
472
476
  xe([
473
477
  p({ type: Boolean, attribute: "can-undo" })
474
- ], K.prototype, "canUndo", 2);
478
+ ], V.prototype, "canUndo", 2);
475
479
  xe([
476
480
  p({ type: Boolean, attribute: "can-redo" })
477
- ], K.prototype, "canRedo", 2);
481
+ ], V.prototype, "canRedo", 2);
478
482
  xe([
479
483
  p({ type: String })
480
- ], K.prototype, "device", 2);
484
+ ], V.prototype, "device", 2);
481
485
  xe([
482
486
  p({ type: Boolean })
483
- ], K.prototype, "fullscreen", 2);
487
+ ], V.prototype, "fullscreen", 2);
484
488
  xe([
485
489
  d()
486
- ], K.prototype, "_exportMenuOpen", 2);
487
- K = xe([
490
+ ], V.prototype, "_exportMenuOpen", 2);
491
+ V = xe([
488
492
  u("pigeon-toolbar")
489
- ], K);
493
+ ], V);
490
494
  let $t = null;
491
495
  function Bo(e) {
492
496
  $t = e;
493
497
  }
494
- function De() {
498
+ function Ee() {
495
499
  return $t;
496
500
  }
497
501
  function Xe() {
@@ -500,21 +504,21 @@ function Xe() {
500
504
  function wt(e, t) {
501
505
  e.dataTransfer && (e.dataTransfer.setData("application/json", JSON.stringify(t)), e.dataTransfer.effectAllowed = "move"), Bo(t);
502
506
  }
503
- function Hr(e) {
507
+ function Fr(e) {
504
508
  if (e.dataTransfer)
505
509
  try {
506
510
  const t = e.dataTransfer.getData("application/json");
507
511
  if (t) return JSON.parse(t);
508
512
  } catch {
509
513
  }
510
- return De();
514
+ return Ee();
511
515
  }
512
- var jo = Object.defineProperty, Ro = Object.getOwnPropertyDescriptor, $e = (e, t, o, r) => {
513
- for (var i = r > 1 ? void 0 : r ? Ro(t, o) : t, n = e.length - 1, a; n >= 0; n--)
516
+ var jo = Object.defineProperty, Mo = Object.getOwnPropertyDescriptor, $e = (e, t, o, r) => {
517
+ for (var i = r > 1 ? void 0 : r ? Mo(t, o) : t, n = e.length - 1, a; n >= 0; n--)
514
518
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
515
519
  return r && i && jo(t, o, i), i;
516
520
  };
517
- const Lo = {
521
+ const Ro = {
518
522
  text: "T",
519
523
  image: "[]",
520
524
  button: "[B]",
@@ -523,12 +527,12 @@ const Lo = {
523
527
  social: "@",
524
528
  html: "</>"
525
529
  };
526
- let W = class extends g {
530
+ let Y = class extends g {
527
531
  constructor() {
528
- super(...arguments), this.label = "", this.icon = "", this.dragType = "palette-block", this.blockType = "", this.columnCount = 1;
532
+ super(...arguments), this.label = "", this.icon = "", this.dragType = "palette-block", this.blockType = "", this.columnCount = 1, this._didDrag = !1;
529
533
  }
530
534
  render() {
531
- const e = Lo[this.icon] ?? this.icon ?? "?", t = this.dragType === "palette-row" ? "Add layout" : "Add block";
535
+ const e = Ro[this.icon] ?? this.icon ?? "?", t = this.dragType === "palette-row" ? "Add layout" : "Add block";
532
536
  return l`
533
537
  <div
534
538
  class="item"
@@ -536,7 +540,8 @@ let W = class extends g {
536
540
  role="button"
537
541
  tabindex="0"
538
542
  aria-label="${t}: ${this.label}"
539
- title="Drag onto the canvas, or press Enter to add"
543
+ title="Click to add, or drag onto the canvas"
544
+ @click=${this._onClick}
540
545
  @dragstart=${this._onDragStart}
541
546
  @dragend=${this._onDragEnd}
542
547
  @keydown=${this._onKeyDown}
@@ -546,8 +551,18 @@ let W = class extends g {
546
551
  </div>
547
552
  `;
548
553
  }
554
+ _onClick() {
555
+ this._didDrag || this._activate();
556
+ }
549
557
  _onKeyDown(e) {
550
- e.key !== "Enter" && e.key !== " " || (e.preventDefault(), this.dispatchEvent(
558
+ e.key !== "Enter" && e.key !== " " || (e.preventDefault(), this._activate());
559
+ }
560
+ /**
561
+ * Click/keyboard equivalent of dragging this item onto the canvas: ask the
562
+ * editor to append the block/layout to the document.
563
+ */
564
+ _activate() {
565
+ this.dispatchEvent(
551
566
  new CustomEvent("palette-item-activate", {
552
567
  detail: {
553
568
  type: this.dragType,
@@ -557,10 +572,10 @@ let W = class extends g {
557
572
  bubbles: !0,
558
573
  composed: !0
559
574
  })
560
- ));
575
+ );
561
576
  }
562
577
  _onDragStart(e) {
563
- wt(e, {
578
+ this._didDrag = !0, wt(e, {
564
579
  type: this.dragType,
565
580
  blockType: this.blockType || void 0,
566
581
  columnCount: this.columnCount
@@ -577,13 +592,15 @@ let W = class extends g {
577
592
  });
578
593
  }
579
594
  _onDragEnd() {
580
- this.dispatchEvent(new CustomEvent("palette-drag-end", {
595
+ setTimeout(() => {
596
+ this._didDrag = !1;
597
+ }, 0), this.dispatchEvent(new CustomEvent("palette-drag-end", {
581
598
  bubbles: !0,
582
599
  composed: !0
583
600
  }));
584
601
  }
585
602
  };
586
- W.styles = b`
603
+ Y.styles = b`
587
604
  :host {
588
605
  display: block;
589
606
  }
@@ -643,26 +660,26 @@ W.styles = b`
643
660
  `;
644
661
  $e([
645
662
  p({ type: String })
646
- ], W.prototype, "label", 2);
663
+ ], Y.prototype, "label", 2);
647
664
  $e([
648
665
  p({ type: String })
649
- ], W.prototype, "icon", 2);
666
+ ], Y.prototype, "icon", 2);
650
667
  $e([
651
668
  p({ type: String, attribute: "drag-type" })
652
- ], W.prototype, "dragType", 2);
669
+ ], Y.prototype, "dragType", 2);
653
670
  $e([
654
671
  p({ type: String, attribute: "block-type" })
655
- ], W.prototype, "blockType", 2);
672
+ ], Y.prototype, "blockType", 2);
656
673
  $e([
657
674
  p({ type: Number, attribute: "column-count" })
658
- ], W.prototype, "columnCount", 2);
659
- W = $e([
675
+ ], Y.prototype, "columnCount", 2);
676
+ Y = $e([
660
677
  u("pigeon-palette-item")
661
- ], W);
662
- var zo = Object.defineProperty, Mo = Object.getOwnPropertyDescriptor, kt = (e, t, o, r) => {
663
- for (var i = r > 1 ? void 0 : r ? Mo(t, o) : t, n = e.length - 1, a; n >= 0; n--)
678
+ ], Y);
679
+ var Lo = Object.defineProperty, zo = Object.getOwnPropertyDescriptor, kt = (e, t, o, r) => {
680
+ for (var i = r > 1 ? void 0 : r ? zo(t, o) : t, n = e.length - 1, a; n >= 0; n--)
664
681
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
665
- return r && i && zo(t, o, i), i;
682
+ return r && i && Lo(t, o, i), i;
666
683
  };
667
684
  const Ho = {
668
685
  text: "T",
@@ -675,7 +692,7 @@ const Ho = {
675
692
  hero: "H",
676
693
  navbar: "Nav"
677
694
  };
678
- let Ee = class extends g {
695
+ let De = class extends g {
679
696
  constructor() {
680
697
  super(...arguments), this.selection = null;
681
698
  }
@@ -734,7 +751,7 @@ let Ee = class extends g {
734
751
  }));
735
752
  }
736
753
  };
737
- Ee.styles = b`
754
+ De.styles = b`
738
755
  :host {
739
756
  display: block;
740
757
  font-family: var(--pigeon-font);
@@ -800,14 +817,14 @@ Ee.styles = b`
800
817
  `;
801
818
  kt([
802
819
  p({ type: Object })
803
- ], Ee.prototype, "doc", 2);
820
+ ], De.prototype, "doc", 2);
804
821
  kt([
805
822
  p({ type: Object })
806
- ], Ee.prototype, "selection", 2);
807
- Ee = kt([
823
+ ], De.prototype, "selection", 2);
824
+ De = kt([
808
825
  u("pigeon-layers")
809
- ], Ee);
810
- var Fo = Object.defineProperty, No = Object.getOwnPropertyDescriptor, M = (e, t, o, r) => {
826
+ ], De);
827
+ var Fo = Object.defineProperty, No = Object.getOwnPropertyDescriptor, H = (e, t, o, r) => {
811
828
  for (var i = r > 1 ? void 0 : r ? No(t, o) : t, n = e.length - 1, a; n >= 0; n--)
812
829
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
813
830
  return r && i && Fo(t, o, i), i;
@@ -826,7 +843,7 @@ const Wo = [
826
843
  { labelKey: "palette.layout.3-col", columns: 3, icon: "[|||]" },
827
844
  { labelKey: "palette.layout.4-col", columns: 4, icon: "[||||]" }
828
845
  ];
829
- let I = class extends g {
846
+ let T = class extends g {
830
847
  constructor() {
831
848
  super(...arguments), this.selection = null, this.brandKit = null, this.rowLibrary = null, this._blockDefs = [], this._activeTab = "content", this._brandTabLoaded = !1, this._savedTabLoaded = !1, this._handleBrandTabClick = async () => {
832
849
  this._activeTab = "brand", this._brandTabLoaded || (await Uo(), this._brandTabLoaded = !0);
@@ -936,7 +953,7 @@ let I = class extends g {
936
953
  return this._savedTabLoaded ? l`<pigeon-saved-tab .storage=${this.rowLibrary}></pigeon-saved-tab>` : l``;
937
954
  }
938
955
  };
939
- I.styles = b`
956
+ T.styles = b`
940
957
  :host {
941
958
  display: block;
942
959
  width: var(--pigeon-palette-width, 240px);
@@ -1015,34 +1032,34 @@ I.styles = b`
1015
1032
  gap: 6px;
1016
1033
  }
1017
1034
  `;
1018
- M([
1035
+ H([
1019
1036
  p({ type: Object })
1020
- ], I.prototype, "doc", 2);
1021
- M([
1037
+ ], T.prototype, "doc", 2);
1038
+ H([
1022
1039
  p({ type: Object })
1023
- ], I.prototype, "selection", 2);
1024
- M([
1040
+ ], T.prototype, "selection", 2);
1041
+ H([
1025
1042
  p({ attribute: !1 })
1026
- ], I.prototype, "brandKit", 2);
1027
- M([
1043
+ ], T.prototype, "brandKit", 2);
1044
+ H([
1028
1045
  p({ attribute: !1 })
1029
- ], I.prototype, "rowLibrary", 2);
1030
- M([
1046
+ ], T.prototype, "rowLibrary", 2);
1047
+ H([
1031
1048
  d()
1032
- ], I.prototype, "_blockDefs", 2);
1033
- M([
1049
+ ], T.prototype, "_blockDefs", 2);
1050
+ H([
1034
1051
  d()
1035
- ], I.prototype, "_activeTab", 2);
1036
- M([
1052
+ ], T.prototype, "_activeTab", 2);
1053
+ H([
1037
1054
  d()
1038
- ], I.prototype, "_brandTabLoaded", 2);
1039
- M([
1055
+ ], T.prototype, "_brandTabLoaded", 2);
1056
+ H([
1040
1057
  d()
1041
- ], I.prototype, "_savedTabLoaded", 2);
1042
- I = M([
1058
+ ], T.prototype, "_savedTabLoaded", 2);
1059
+ T = H([
1043
1060
  u("pigeon-palette")
1044
- ], I);
1045
- function Vo(e, t) {
1061
+ ], T);
1062
+ function qo(e, t) {
1046
1063
  if (t.length === 0) return 0;
1047
1064
  for (let o = 0; o < t.length; o++) {
1048
1065
  const r = t[o].getBoundingClientRect(), i = r.top + r.height / 2;
@@ -1051,7 +1068,7 @@ function Vo(e, t) {
1051
1068
  }
1052
1069
  return t.length;
1053
1070
  }
1054
- function Yo(e, t) {
1071
+ function Vo(e, t) {
1055
1072
  if (t.length === 0) return 0;
1056
1073
  for (let o = 0; o < t.length; o++) {
1057
1074
  const r = t[o].getBoundingClientRect(), i = r.top + r.height / 2;
@@ -1063,10 +1080,10 @@ function Yo(e, t) {
1063
1080
  function to(e, t) {
1064
1081
  return e < 0 || t === e || t === e + 1 ? null : t > e ? t - 1 : t;
1065
1082
  }
1066
- var qo = Object.defineProperty, Xo = Object.getOwnPropertyDescriptor, oo = (e, t, o, r) => {
1083
+ var Yo = Object.defineProperty, Xo = Object.getOwnPropertyDescriptor, oo = (e, t, o, r) => {
1067
1084
  for (var i = r > 1 ? void 0 : r ? Xo(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1068
1085
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
1069
- return r && i && qo(t, o, i), i;
1086
+ return r && i && Yo(t, o, i), i;
1070
1087
  };
1071
1088
  let Ge = class extends g {
1072
1089
  constructor() {
@@ -1169,7 +1186,7 @@ let de = class extends g {
1169
1186
  element: this._editorHost,
1170
1187
  initialHTML: this.block.values.content,
1171
1188
  onBlur: (o) => this._commit(o),
1172
- onEscape: () => this._exit()
1189
+ onEscape: (o) => this._commit(o)
1173
1190
  }));
1174
1191
  }
1175
1192
  _teardownEditor() {
@@ -1189,10 +1206,6 @@ let de = class extends g {
1189
1206
  composed: !0
1190
1207
  }));
1191
1208
  }
1192
- _exit() {
1193
- const e = this._editor ? this._editor.getHTML() : this.block.values.content;
1194
- this._commit(e);
1195
- }
1196
1209
  _handleClick(e) {
1197
1210
  e.stopPropagation(), !this.editing && this.dispatchEvent(new CustomEvent("block-select", {
1198
1211
  detail: { blockId: this.block.id },
@@ -1584,7 +1597,7 @@ It([
1584
1597
  Be = It([
1585
1598
  u("pigeon-divider-block")
1586
1599
  ], Be);
1587
- var ri = Object.defineProperty, ni = Object.getOwnPropertyDescriptor, Pt = (e, t, o, r) => {
1600
+ var ri = Object.defineProperty, ni = Object.getOwnPropertyDescriptor, Tt = (e, t, o, r) => {
1588
1601
  for (var i = r > 1 ? void 0 : r ? ni(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1589
1602
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
1590
1603
  return r && i && ri(t, o, i), i;
@@ -1656,16 +1669,16 @@ je.styles = b`
1656
1669
  opacity: 1;
1657
1670
  }
1658
1671
  `;
1659
- Pt([
1672
+ Tt([
1660
1673
  p({ type: Object })
1661
1674
  ], je.prototype, "block", 2);
1662
- Pt([
1675
+ Tt([
1663
1676
  p({ type: Boolean, reflect: !0 })
1664
1677
  ], je.prototype, "selected", 2);
1665
- je = Pt([
1678
+ je = Tt([
1666
1679
  u("pigeon-spacer-block")
1667
1680
  ], je);
1668
- var ai = Object.defineProperty, si = Object.getOwnPropertyDescriptor, Tt = (e, t, o, r) => {
1681
+ var ai = Object.defineProperty, si = Object.getOwnPropertyDescriptor, Pt = (e, t, o, r) => {
1669
1682
  for (var i = r > 1 ? void 0 : r ? si(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1670
1683
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
1671
1684
  return r && i && ai(t, o, i), i;
@@ -1687,7 +1700,7 @@ const li = {
1687
1700
  tiktok: "#000000",
1688
1701
  custom: "#6b7280"
1689
1702
  };
1690
- let Re = class extends g {
1703
+ let Me = class extends g {
1691
1704
  constructor() {
1692
1705
  super(...arguments), this.selected = !1;
1693
1706
  }
@@ -1734,7 +1747,7 @@ let Re = class extends g {
1734
1747
  }));
1735
1748
  }
1736
1749
  };
1737
- Re.styles = b`
1750
+ Me.styles = b`
1738
1751
  :host {
1739
1752
  display: block;
1740
1753
  cursor: pointer;
@@ -1782,21 +1795,21 @@ Re.styles = b`
1782
1795
  font-size: 13px;
1783
1796
  }
1784
1797
  `;
1785
- Tt([
1798
+ Pt([
1786
1799
  p({ type: Object })
1787
- ], Re.prototype, "block", 2);
1788
- Tt([
1800
+ ], Me.prototype, "block", 2);
1801
+ Pt([
1789
1802
  p({ type: Boolean, reflect: !0 })
1790
- ], Re.prototype, "selected", 2);
1791
- Re = Tt([
1803
+ ], Me.prototype, "selected", 2);
1804
+ Me = Pt([
1792
1805
  u("pigeon-social-block")
1793
- ], Re);
1806
+ ], Me);
1794
1807
  var ci = Object.defineProperty, di = Object.getOwnPropertyDescriptor, St = (e, t, o, r) => {
1795
1808
  for (var i = r > 1 ? void 0 : r ? di(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1796
1809
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
1797
1810
  return r && i && ci(t, o, i), i;
1798
1811
  };
1799
- let Le = class extends g {
1812
+ let Re = class extends g {
1800
1813
  constructor() {
1801
1814
  super(...arguments), this.selected = !1;
1802
1815
  }
@@ -1809,10 +1822,24 @@ let Le = class extends g {
1809
1822
  style="${t}"
1810
1823
  @click=${this._handleClick}
1811
1824
  >
1812
- ${e.content ? l`<div class="content" .innerHTML=${e.content}></div>` : l`<div class="empty-state">&lt;/&gt; Custom HTML</div>`}
1825
+ ${e.content ? l`<iframe
1826
+ class="content"
1827
+ title="Custom HTML"
1828
+ sandbox="allow-same-origin"
1829
+ .srcdoc=${`<style>body{margin:0;display:flow-root}</style>${e.content}`}
1830
+ @load=${this._fit}
1831
+ ></iframe>` : l`<div class="empty-state">&lt;/&gt; Custom HTML</div>`}
1813
1832
  </div>
1814
1833
  `;
1815
1834
  }
1835
+ /** No scripts run inside the sandbox, so the parent sizes the frame to its content. */
1836
+ _fit(e) {
1837
+ var o;
1838
+ const t = e.target;
1839
+ (o = this._resizer) == null || o.disconnect(), this._resizer = new ResizeObserver(() => {
1840
+ t.style.height = `${t.contentDocument.body.scrollHeight}px`;
1841
+ }), this._resizer.observe(t);
1842
+ }
1816
1843
  _handleClick(e) {
1817
1844
  e.stopPropagation(), this.dispatchEvent(new CustomEvent("block-select", {
1818
1845
  detail: { blockId: this.block.id },
@@ -1821,7 +1848,7 @@ let Le = class extends g {
1821
1848
  }));
1822
1849
  }
1823
1850
  };
1824
- Le.styles = b`
1851
+ Re.styles = b`
1825
1852
  :host {
1826
1853
  display: block;
1827
1854
  cursor: pointer;
@@ -1844,8 +1871,10 @@ Le.styles = b`
1844
1871
  }
1845
1872
 
1846
1873
  .content {
1847
- word-wrap: break-word;
1848
- overflow-wrap: break-word;
1874
+ display: block;
1875
+ width: 100%;
1876
+ border: 0;
1877
+ pointer-events: none;
1849
1878
  }
1850
1879
 
1851
1880
  .empty-state {
@@ -1863,13 +1892,13 @@ Le.styles = b`
1863
1892
  `;
1864
1893
  St([
1865
1894
  p({ type: Object })
1866
- ], Le.prototype, "block", 2);
1895
+ ], Re.prototype, "block", 2);
1867
1896
  St([
1868
1897
  p({ type: Boolean, reflect: !0 })
1869
- ], Le.prototype, "selected", 2);
1870
- Le = St([
1898
+ ], Re.prototype, "selected", 2);
1899
+ Re = St([
1871
1900
  u("pigeon-html-block")
1872
- ], Le);
1901
+ ], Re);
1873
1902
  var hi = Object.defineProperty, gi = Object.getOwnPropertyDescriptor, it = (e, t, o, r) => {
1874
1903
  for (var i = r > 1 ? void 0 : r ? gi(t, o) : t, n = e.length - 1, a; n >= 0; n--)
1875
1904
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
@@ -2037,7 +2066,7 @@ var ui = Object.defineProperty, bi = Object.getOwnPropertyDescriptor, Ot = (e, t
2037
2066
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
2038
2067
  return r && i && ui(t, o, i), i;
2039
2068
  };
2040
- let ze = class extends g {
2069
+ let Le = class extends g {
2041
2070
  constructor() {
2042
2071
  super(...arguments), this.selected = !1;
2043
2072
  }
@@ -2080,7 +2109,7 @@ let ze = class extends g {
2080
2109
  }));
2081
2110
  }
2082
2111
  };
2083
- ze.styles = b`
2112
+ Le.styles = b`
2084
2113
  :host {
2085
2114
  display: block;
2086
2115
  cursor: pointer;
@@ -2130,19 +2159,19 @@ ze.styles = b`
2130
2159
  `;
2131
2160
  Ot([
2132
2161
  p({ type: Object })
2133
- ], ze.prototype, "block", 2);
2162
+ ], Le.prototype, "block", 2);
2134
2163
  Ot([
2135
2164
  p({ type: Boolean, reflect: !0 })
2136
- ], ze.prototype, "selected", 2);
2137
- ze = Ot([
2165
+ ], Le.prototype, "selected", 2);
2166
+ Le = Ot([
2138
2167
  u("pigeon-navbar-block")
2139
- ], ze);
2140
- var vi = Object.defineProperty, fi = Object.getOwnPropertyDescriptor, X = (e, t, o, r) => {
2168
+ ], Le);
2169
+ var vi = Object.defineProperty, fi = Object.getOwnPropertyDescriptor, Z = (e, t, o, r) => {
2141
2170
  for (var i = r > 1 ? void 0 : r ? fi(t, o) : t, n = e.length - 1, a; n >= 0; n--)
2142
2171
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
2143
2172
  return r && i && vi(t, o, i), i;
2144
2173
  };
2145
- let O = class extends g {
2174
+ let A = class extends g {
2146
2175
  constructor() {
2147
2176
  super(...arguments), this.rowId = "", this.selection = null, this.editingBlockId = null, this._dropIndex = -1, this._isDragOver = !1, this._draggingBlockId = null;
2148
2177
  }
@@ -2251,7 +2280,7 @@ let O = class extends g {
2251
2280
  );
2252
2281
  }
2253
2282
  _onDragOver(e) {
2254
- const t = De();
2283
+ const t = Ee();
2255
2284
  if (!t || t.type !== "palette-block" && t.type !== "existing-block") return;
2256
2285
  e.preventDefault(), e.stopPropagation(), e.dataTransfer && (e.dataTransfer.dropEffect = t.type === "existing-block" ? "move" : "copy"), this._isDragOver = !0;
2257
2286
  const o = Array.from(
@@ -2259,14 +2288,14 @@ let O = class extends g {
2259
2288
  "pigeon-text-block, pigeon-image-block, pigeon-button-block, pigeon-divider-block, pigeon-spacer-block, pigeon-social-block, pigeon-html-block, pigeon-hero-block, pigeon-navbar-block, .custom-block"
2260
2289
  )
2261
2290
  );
2262
- this._dropIndex = Yo(e.clientY, o);
2291
+ this._dropIndex = Vo(e.clientY, o);
2263
2292
  }
2264
2293
  _onDragLeave(e) {
2265
2294
  const t = this.getBoundingClientRect();
2266
2295
  e.clientX >= t.left && e.clientX <= t.right && e.clientY >= t.top && e.clientY <= t.bottom || (this._isDragOver = !1, this._dropIndex = -1);
2267
2296
  }
2268
2297
  _onDrop(e) {
2269
- const t = De();
2298
+ const t = Ee();
2270
2299
  if (!t || t.type !== "palette-block" && t.type !== "existing-block") return;
2271
2300
  e.preventDefault(), e.stopPropagation();
2272
2301
  let o = this._dropIndex >= 0 ? this._dropIndex : this.column.blocks.length;
@@ -2308,7 +2337,7 @@ let O = class extends g {
2308
2337
  this._draggingBlockId = null, Xe();
2309
2338
  }
2310
2339
  };
2311
- O.styles = b`
2340
+ A.styles = b`
2312
2341
  :host {
2313
2342
  display: block;
2314
2343
  min-height: 40px;
@@ -2424,36 +2453,36 @@ O.styles = b`
2424
2453
  text-align: center;
2425
2454
  }
2426
2455
  `;
2427
- X([
2456
+ Z([
2428
2457
  p({ type: Object })
2429
- ], O.prototype, "column", 2);
2430
- X([
2458
+ ], A.prototype, "column", 2);
2459
+ Z([
2431
2460
  p({ type: String, attribute: "row-id" })
2432
- ], O.prototype, "rowId", 2);
2433
- X([
2461
+ ], A.prototype, "rowId", 2);
2462
+ Z([
2434
2463
  p({ type: Object })
2435
- ], O.prototype, "selection", 2);
2436
- X([
2464
+ ], A.prototype, "selection", 2);
2465
+ Z([
2437
2466
  p({ type: String, attribute: "editing-block-id" })
2438
- ], O.prototype, "editingBlockId", 2);
2439
- X([
2467
+ ], A.prototype, "editingBlockId", 2);
2468
+ Z([
2440
2469
  d()
2441
- ], O.prototype, "_dropIndex", 2);
2442
- X([
2470
+ ], A.prototype, "_dropIndex", 2);
2471
+ Z([
2443
2472
  d()
2444
- ], O.prototype, "_isDragOver", 2);
2445
- X([
2473
+ ], A.prototype, "_isDragOver", 2);
2474
+ Z([
2446
2475
  d()
2447
- ], O.prototype, "_draggingBlockId", 2);
2448
- O = X([
2476
+ ], A.prototype, "_draggingBlockId", 2);
2477
+ A = Z([
2449
2478
  u("pigeon-column")
2450
- ], O);
2451
- var mi = Object.defineProperty, _i = Object.getOwnPropertyDescriptor, G = (e, t, o, r) => {
2479
+ ], A);
2480
+ var mi = Object.defineProperty, _i = Object.getOwnPropertyDescriptor, Q = (e, t, o, r) => {
2452
2481
  for (var i = r > 1 ? void 0 : r ? _i(t, o) : t, n = e.length - 1, a; n >= 0; n--)
2453
2482
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
2454
2483
  return r && i && mi(t, o, i), i;
2455
2484
  };
2456
- let D = class extends g {
2485
+ let B = class extends g {
2457
2486
  constructor() {
2458
2487
  super(...arguments), this.index = 0, this.totalRows = 0, this.selection = null, this.editingBlockId = null, this.showActions = !1, this._dragging = !1;
2459
2488
  }
@@ -2613,7 +2642,7 @@ let D = class extends g {
2613
2642
  this._dragging = !1, Xe();
2614
2643
  }
2615
2644
  };
2616
- D.styles = b`
2645
+ B.styles = b`
2617
2646
  :host {
2618
2647
  display: block;
2619
2648
  position: relative;
@@ -2744,31 +2773,31 @@ D.styles = b`
2744
2773
  opacity: 1;
2745
2774
  }
2746
2775
  `;
2747
- G([
2776
+ Q([
2748
2777
  p({ type: Object })
2749
- ], D.prototype, "row", 2);
2750
- G([
2778
+ ], B.prototype, "row", 2);
2779
+ Q([
2751
2780
  p({ type: Number })
2752
- ], D.prototype, "index", 2);
2753
- G([
2781
+ ], B.prototype, "index", 2);
2782
+ Q([
2754
2783
  p({ type: Number, attribute: "total-rows" })
2755
- ], D.prototype, "totalRows", 2);
2756
- G([
2784
+ ], B.prototype, "totalRows", 2);
2785
+ Q([
2757
2786
  p({ type: Object })
2758
- ], D.prototype, "selection", 2);
2759
- G([
2787
+ ], B.prototype, "selection", 2);
2788
+ Q([
2760
2789
  p({ type: String, attribute: "editing-block-id" })
2761
- ], D.prototype, "editingBlockId", 2);
2762
- G([
2790
+ ], B.prototype, "editingBlockId", 2);
2791
+ Q([
2763
2792
  p({ type: Boolean, attribute: "show-actions", reflect: !0 })
2764
- ], D.prototype, "showActions", 2);
2765
- G([
2793
+ ], B.prototype, "showActions", 2);
2794
+ Q([
2766
2795
  d()
2767
- ], D.prototype, "_dragging", 2);
2768
- D = G([
2796
+ ], B.prototype, "_dragging", 2);
2797
+ B = Q([
2769
2798
  u("pigeon-row")
2770
- ], D);
2771
- var yi = Object.defineProperty, xi = Object.getOwnPropertyDescriptor, H = (e, t, o, r) => {
2799
+ ], B);
2800
+ var yi = Object.defineProperty, xi = Object.getOwnPropertyDescriptor, F = (e, t, o, r) => {
2772
2801
  for (var i = r > 1 ? void 0 : r ? xi(t, o) : t, n = e.length - 1, a; n >= 0; n--)
2773
2802
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
2774
2803
  return r && i && yi(t, o, i), i;
@@ -2872,12 +2901,12 @@ let P = class extends g {
2872
2901
  }));
2873
2902
  }
2874
2903
  _onDragOver(e) {
2875
- const t = De();
2904
+ const t = Ee();
2876
2905
  if (t && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = t.type === "existing-row" ? "move" : "copy"), this._isDragOver = !0, t.type === "palette-row" || t.type === "existing-row" || t.type === "library-row" || this.doc.body.rows.length === 0)) {
2877
2906
  const o = Array.from(
2878
2907
  this.renderRoot.querySelectorAll("pigeon-row")
2879
2908
  );
2880
- this._rowDropIndex = Vo(e.clientY, o);
2909
+ this._rowDropIndex = qo(e.clientY, o);
2881
2910
  }
2882
2911
  }
2883
2912
  _onDragLeave(e) {
@@ -2887,7 +2916,7 @@ let P = class extends g {
2887
2916
  }
2888
2917
  _onDrop(e) {
2889
2918
  e.preventDefault();
2890
- const t = De();
2919
+ const t = Ee();
2891
2920
  if (!t) {
2892
2921
  this._resetDragState();
2893
2922
  return;
@@ -3059,31 +3088,31 @@ P.styles = b`
3059
3088
  border-radius: var(--pigeon-radius, 6px);
3060
3089
  }
3061
3090
  `;
3062
- H([
3091
+ F([
3063
3092
  p({ type: Object })
3064
3093
  ], P.prototype, "doc", 2);
3065
- H([
3094
+ F([
3066
3095
  p({ type: Object })
3067
3096
  ], P.prototype, "selection", 2);
3068
- H([
3097
+ F([
3069
3098
  p({ type: String, attribute: "editing-block-id" })
3070
3099
  ], P.prototype, "editingBlockId", 2);
3071
- H([
3100
+ F([
3072
3101
  p({ type: Number, attribute: "preview-width" })
3073
3102
  ], P.prototype, "previewWidth", 2);
3074
- H([
3103
+ F([
3075
3104
  p({ type: String })
3076
3105
  ], P.prototype, "device", 2);
3077
- H([
3106
+ F([
3078
3107
  d()
3079
3108
  ], P.prototype, "_rowDropIndex", 2);
3080
- H([
3109
+ F([
3081
3110
  d()
3082
3111
  ], P.prototype, "_isDragOver", 2);
3083
- H([
3112
+ F([
3084
3113
  d()
3085
3114
  ], P.prototype, "_hoveredRowId", 2);
3086
- P = H([
3115
+ P = F([
3087
3116
  u("pigeon-canvas")
3088
3117
  ], P);
3089
3118
  /**
@@ -3091,22 +3120,22 @@ P = H([
3091
3120
  * Copyright 2017 Google LLC
3092
3121
  * SPDX-License-Identifier: BSD-3-Clause
3093
3122
  */
3094
- const Se = globalThis, Wt = (e) => e, Je = Se.trustedTypes, Vt = Je ? Je.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, io = "$lit$", U = `lit$${Math.random().toFixed(9).slice(2)}$`, ro = "?" + U, $i = `<${ro}>`, ne = document, Ze = () => ne.createComment(""), Me = (e) => e === null || typeof e != "object" && typeof e != "function", Dt = Array.isArray, wi = (e) => Dt(e) || typeof (e == null ? void 0 : e[Symbol.iterator]) == "function", bt = `[
3095
- \f\r]`, Te = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Yt = /-->/g, qt = />/g, ie = RegExp(`>|${bt}(?:([^\\s"'>=/]+)(${bt}*=${bt}*(?:[^
3123
+ const Se = globalThis, Wt = (e) => e, Je = Se.trustedTypes, qt = Je ? Je.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, io = "$lit$", q = `lit$${Math.random().toFixed(9).slice(2)}$`, ro = "?" + q, $i = `<${ro}>`, ne = document, Ze = () => ne.createComment(""), ze = (e) => e === null || typeof e != "object" && typeof e != "function", Et = Array.isArray, wi = (e) => Et(e) || typeof (e == null ? void 0 : e[Symbol.iterator]) == "function", bt = `[
3124
+ \f\r]`, Pe = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Vt = /-->/g, Yt = />/g, ie = RegExp(`>|${bt}(?:([^\\s"'>=/]+)(${bt}*=${bt}*(?:[^
3096
3125
  \f\r"'\`<>=]|("|')|))|$)`, "g"), Xt = /'/g, Gt = /"/g, no = /^(?:script|style|textarea|title)$/i, He = Symbol.for("lit-noChange"), y = Symbol.for("lit-nothing"), Jt = /* @__PURE__ */ new WeakMap(), re = ne.createTreeWalker(ne, 129);
3097
3126
  function ao(e, t) {
3098
- if (!Dt(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
3099
- return Vt !== void 0 ? Vt.createHTML(t) : t;
3127
+ if (!Et(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
3128
+ return qt !== void 0 ? qt.createHTML(t) : t;
3100
3129
  }
3101
3130
  const ki = (e, t) => {
3102
3131
  const o = e.length - 1, r = [];
3103
- let i, n = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", a = Te;
3132
+ let i, n = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", a = Pe;
3104
3133
  for (let h = 0; h < o; h++) {
3105
3134
  const c = e[h];
3106
3135
  let v, m, f = -1, R = 0;
3107
- for (; R < c.length && (a.lastIndex = R, m = a.exec(c), m !== null); ) R = a.lastIndex, a === Te ? m[1] === "!--" ? a = Yt : m[1] !== void 0 ? a = qt : m[2] !== void 0 ? (no.test(m[2]) && (i = RegExp("</" + m[2], "g")), a = ie) : m[3] !== void 0 && (a = ie) : a === ie ? m[0] === ">" ? (a = i ?? Te, f = -1) : m[1] === void 0 ? f = -2 : (f = a.lastIndex - m[2].length, v = m[1], a = m[3] === void 0 ? ie : m[3] === '"' ? Gt : Xt) : a === Gt || a === Xt ? a = ie : a === Yt || a === qt ? a = Te : (a = ie, i = void 0);
3108
- const N = a === ie && e[h + 1].startsWith("/>") ? " " : "";
3109
- n += a === Te ? c + $i : f >= 0 ? (r.push(v), c.slice(0, f) + io + c.slice(f) + U + N) : c + U + (f === -2 ? h : N);
3136
+ for (; R < c.length && (a.lastIndex = R, m = a.exec(c), m !== null); ) R = a.lastIndex, a === Pe ? m[1] === "!--" ? a = Vt : m[1] !== void 0 ? a = Yt : m[2] !== void 0 ? (no.test(m[2]) && (i = RegExp("</" + m[2], "g")), a = ie) : m[3] !== void 0 && (a = ie) : a === ie ? m[0] === ">" ? (a = i ?? Pe, f = -1) : m[1] === void 0 ? f = -2 : (f = a.lastIndex - m[2].length, v = m[1], a = m[3] === void 0 ? ie : m[3] === '"' ? Gt : Xt) : a === Gt || a === Xt ? a = ie : a === Vt || a === Yt ? a = Pe : (a = ie, i = void 0);
3137
+ const W = a === ie && e[h + 1].startsWith("/>") ? " " : "";
3138
+ n += a === Pe ? c + $i : f >= 0 ? (r.push(v), c.slice(0, f) + io + c.slice(f) + q + W) : c + q + (f === -2 ? h : W);
3110
3139
  }
3111
3140
  return [ao(e, n + (e[o] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), r];
3112
3141
  };
@@ -3123,21 +3152,21 @@ class Fe {
3123
3152
  for (; (i = re.nextNode()) !== null && c.length < h; ) {
3124
3153
  if (i.nodeType === 1) {
3125
3154
  if (i.hasAttributes()) for (const f of i.getAttributeNames()) if (f.endsWith(io)) {
3126
- const R = m[a++], N = i.getAttribute(f).split(U), Ve = /([.?@])?(.*)/.exec(R);
3127
- c.push({ type: 1, index: n, name: Ve[2], strings: N, ctor: Ve[1] === "." ? Ii : Ve[1] === "?" ? Pi : Ve[1] === "@" ? Ti : nt }), i.removeAttribute(f);
3128
- } else f.startsWith(U) && (c.push({ type: 6, index: n }), i.removeAttribute(f));
3155
+ const R = m[a++], W = i.getAttribute(f).split(q), qe = /([.?@])?(.*)/.exec(R);
3156
+ c.push({ type: 1, index: n, name: qe[2], strings: W, ctor: qe[1] === "." ? Ii : qe[1] === "?" ? Ti : qe[1] === "@" ? Pi : nt }), i.removeAttribute(f);
3157
+ } else f.startsWith(q) && (c.push({ type: 6, index: n }), i.removeAttribute(f));
3129
3158
  if (no.test(i.tagName)) {
3130
- const f = i.textContent.split(U), R = f.length - 1;
3159
+ const f = i.textContent.split(q), R = f.length - 1;
3131
3160
  if (R > 0) {
3132
3161
  i.textContent = Je ? Je.emptyScript : "";
3133
- for (let N = 0; N < R; N++) i.append(f[N], Ze()), re.nextNode(), c.push({ type: 2, index: ++n });
3162
+ for (let W = 0; W < R; W++) i.append(f[W], Ze()), re.nextNode(), c.push({ type: 2, index: ++n });
3134
3163
  i.append(f[R], Ze());
3135
3164
  }
3136
3165
  }
3137
3166
  } else if (i.nodeType === 8) if (i.data === ro) c.push({ type: 2, index: n });
3138
3167
  else {
3139
3168
  let f = -1;
3140
- for (; (f = i.data.indexOf(U, f + 1)) !== -1; ) c.push({ type: 7, index: n }), f += U.length - 1;
3169
+ for (; (f = i.data.indexOf(q, f + 1)) !== -1; ) c.push({ type: 7, index: n }), f += q.length - 1;
3141
3170
  }
3142
3171
  n++;
3143
3172
  }
@@ -3151,7 +3180,7 @@ function ue(e, t, o = e, r) {
3151
3180
  var a, h;
3152
3181
  if (t === He) return t;
3153
3182
  let i = r !== void 0 ? (a = o._$Co) == null ? void 0 : a[r] : o._$Cl;
3154
- const n = Me(t) ? void 0 : t._$litDirective$;
3183
+ const n = ze(t) ? void 0 : t._$litDirective$;
3155
3184
  return (i == null ? void 0 : i.constructor) !== n && ((h = i == null ? void 0 : i._$AO) == null || h.call(i, !1), n === void 0 ? i = void 0 : (i = new n(e), i._$AT(e, o, r)), r !== void 0 ? (o._$Co ?? (o._$Co = []))[r] = i : o._$Cl = i), i !== void 0 && (t = ue(e, i._$AS(e, t.values), i, r)), t;
3156
3185
  }
3157
3186
  class Ci {
@@ -3202,7 +3231,7 @@ class rt {
3202
3231
  return this._$AB;
3203
3232
  }
3204
3233
  _$AI(t, o = this) {
3205
- t = ue(this, t, o), Me(t) ? t === y || t == null || t === "" ? (this._$AH !== y && this._$AR(), this._$AH = y) : t !== this._$AH && t !== He && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : wi(t) ? this.k(t) : this._(t);
3234
+ t = ue(this, t, o), ze(t) ? t === y || t == null || t === "" ? (this._$AH !== y && this._$AR(), this._$AH = y) : t !== this._$AH && t !== He && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : wi(t) ? this.k(t) : this._(t);
3206
3235
  }
3207
3236
  O(t) {
3208
3237
  return this._$AA.parentNode.insertBefore(t, this._$AB);
@@ -3211,7 +3240,7 @@ class rt {
3211
3240
  this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
3212
3241
  }
3213
3242
  _(t) {
3214
- this._$AH !== y && Me(this._$AH) ? this._$AA.nextSibling.data = t : this.T(ne.createTextNode(t)), this._$AH = t;
3243
+ this._$AH !== y && ze(this._$AH) ? this._$AA.nextSibling.data = t : this.T(ne.createTextNode(t)), this._$AH = t;
3215
3244
  }
3216
3245
  $(t) {
3217
3246
  var n;
@@ -3227,7 +3256,7 @@ class rt {
3227
3256
  return o === void 0 && Jt.set(t.strings, o = new Fe(t)), o;
3228
3257
  }
3229
3258
  k(t) {
3230
- Dt(this._$AH) || (this._$AH = [], this._$AR());
3259
+ Et(this._$AH) || (this._$AH = [], this._$AR());
3231
3260
  const o = this._$AH;
3232
3261
  let r, i = 0;
3233
3262
  for (const n of t) i === o.length ? o.push(r = new rt(this.O(Ze()), this.O(Ze()), this, this.options)) : r = o[i], r._$AI(n), i++;
@@ -3258,11 +3287,11 @@ class nt {
3258
3287
  _$AI(t, o = this, r, i) {
3259
3288
  const n = this.strings;
3260
3289
  let a = !1;
3261
- if (n === void 0) t = ue(this, t, o, 0), a = !Me(t) || t !== this._$AH && t !== He, a && (this._$AH = t);
3290
+ if (n === void 0) t = ue(this, t, o, 0), a = !ze(t) || t !== this._$AH && t !== He, a && (this._$AH = t);
3262
3291
  else {
3263
3292
  const h = t;
3264
3293
  let c, v;
3265
- for (t = n[0], c = 0; c < n.length - 1; c++) v = ue(this, h[r + c], o, c), v === He && (v = this._$AH[c]), a || (a = !Me(v) || v !== this._$AH[c]), v === y ? t = y : t !== y && (t += (v ?? "") + n[c + 1]), this._$AH[c] = v;
3294
+ for (t = n[0], c = 0; c < n.length - 1; c++) v = ue(this, h[r + c], o, c), v === He && (v = this._$AH[c]), a || (a = !ze(v) || v !== this._$AH[c]), v === y ? t = y : t !== y && (t += (v ?? "") + n[c + 1]), this._$AH[c] = v;
3266
3295
  }
3267
3296
  a && !i && this.j(t);
3268
3297
  }
@@ -3278,7 +3307,7 @@ class Ii extends nt {
3278
3307
  this.element[this.name] = t === y ? void 0 : t;
3279
3308
  }
3280
3309
  }
3281
- class Pi extends nt {
3310
+ class Ti extends nt {
3282
3311
  constructor() {
3283
3312
  super(...arguments), this.type = 4;
3284
3313
  }
@@ -3286,7 +3315,7 @@ class Pi extends nt {
3286
3315
  this.element.toggleAttribute(this.name, !!t && t !== y);
3287
3316
  }
3288
3317
  }
3289
- class Ti extends nt {
3318
+ class Pi extends nt {
3290
3319
  constructor(t, o, r, i, n) {
3291
3320
  super(t, o, r, i, n), this.type = 5;
3292
3321
  }
@@ -3312,7 +3341,7 @@ class Si {
3312
3341
  }
3313
3342
  }
3314
3343
  const vt = Se.litHtmlPolyfillSupport;
3315
- vt == null || vt(Fe, rt), (Se.litHtmlVersions ?? (Se.litHtmlVersions = [])).push("3.3.2");
3344
+ vt == null || vt(Fe, rt), (Se.litHtmlVersions ?? (Se.litHtmlVersions = [])).push("3.3.3");
3316
3345
  /**
3317
3346
  * @license
3318
3347
  * Copyright 2020 Google LLC
@@ -3324,7 +3353,7 @@ const Oi = (e) => e.strings === void 0;
3324
3353
  * Copyright 2017 Google LLC
3325
3354
  * SPDX-License-Identifier: BSD-3-Clause
3326
3355
  */
3327
- const Di = { CHILD: 2 }, Ei = (e) => (...t) => ({ _$litDirective$: e, values: t });
3356
+ const Ei = { CHILD: 2 }, Di = (e) => (...t) => ({ _$litDirective$: e, values: t });
3328
3357
  class Ai {
3329
3358
  constructor(t) {
3330
3359
  }
@@ -3363,7 +3392,7 @@ const Oe = (e, t) => {
3363
3392
  let o = t._$AN;
3364
3393
  if (o === void 0) t._$AN = o = /* @__PURE__ */ new Set();
3365
3394
  else if (o.has(e)) break;
3366
- o.add(e), Ri(t);
3395
+ o.add(e), Mi(t);
3367
3396
  }
3368
3397
  };
3369
3398
  function Bi(e) {
@@ -3375,10 +3404,10 @@ function ji(e, t = !1, o = 0) {
3375
3404
  else r != null && (Oe(r, !1), Qe(r));
3376
3405
  else Oe(this, e);
3377
3406
  }
3378
- const Ri = (e) => {
3379
- e.type == Di.CHILD && (e._$AP ?? (e._$AP = ji), e._$AQ ?? (e._$AQ = Bi));
3407
+ const Mi = (e) => {
3408
+ e.type == Ei.CHILD && (e._$AP ?? (e._$AP = ji), e._$AQ ?? (e._$AQ = Bi));
3380
3409
  };
3381
- class Li extends Ai {
3410
+ class Ri extends Ai {
3382
3411
  constructor() {
3383
3412
  super(...arguments), this._$AN = void 0;
3384
3413
  }
@@ -3406,20 +3435,20 @@ class Li extends Ai {
3406
3435
  * Copyright 2020 Google LLC
3407
3436
  * SPDX-License-Identifier: BSD-3-Clause
3408
3437
  */
3409
- const be = () => new zi();
3410
- class zi {
3438
+ const be = () => new Li();
3439
+ class Li {
3411
3440
  }
3412
- const ft = /* @__PURE__ */ new WeakMap(), ve = Ei(class extends Li {
3441
+ const ft = /* @__PURE__ */ new WeakMap(), ve = Di(class extends Ri {
3413
3442
  render(e) {
3414
3443
  return y;
3415
3444
  }
3416
3445
  update(e, [t]) {
3417
3446
  var r;
3418
3447
  const o = t !== this.G;
3419
- return o && this.G !== void 0 && this.rt(void 0), (o || this.lt !== this.ct) && (this.G = t, this.ht = (r = e.options) == null ? void 0 : r.host, this.rt(this.ct = e.element)), y;
3448
+ return o && this.rt(void 0), (o || this.lt !== this.ct) && (this.G = t, this.ht = (r = e.options) == null ? void 0 : r.host, this.rt(this.ct = e.element)), y;
3420
3449
  }
3421
3450
  rt(e) {
3422
- if (this.isConnected || (e = void 0), typeof this.G == "function") {
3451
+ if (this.G !== void 0) if (this.isConnected || (e = void 0), typeof this.G == "function") {
3423
3452
  const t = this.ht ?? globalThis;
3424
3453
  let o = ft.get(t);
3425
3454
  o === void 0 && (o = /* @__PURE__ */ new WeakMap(), ft.set(t, o)), o.get(this.G) !== void 0 && this.G.call(this.ht, void 0), o.set(this.G, e), e !== void 0 && this.G.call(this.ht, e);
@@ -3435,7 +3464,7 @@ const ft = /* @__PURE__ */ new WeakMap(), ve = Ei(class extends Li {
3435
3464
  reconnected() {
3436
3465
  this.rt(this.ct);
3437
3466
  }
3438
- }), C = b`
3467
+ }), I = b`
3439
3468
  :host {
3440
3469
  display: block;
3441
3470
  }
@@ -3651,10 +3680,10 @@ const ft = /* @__PURE__ */ new WeakMap(), ve = Ei(class extends Li {
3651
3680
  box-shadow: var(--pigeon-ring-shadow);
3652
3681
  }
3653
3682
  `;
3654
- var Mi = Object.defineProperty, Hi = Object.getOwnPropertyDescriptor, Et = (e, t, o, r) => {
3683
+ var zi = Object.defineProperty, Hi = Object.getOwnPropertyDescriptor, Dt = (e, t, o, r) => {
3655
3684
  for (var i = r > 1 ? void 0 : r ? Hi(t, o) : t, n = e.length - 1, a; n >= 0; n--)
3656
3685
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
3657
- return r && i && Mi(t, o, i), i;
3686
+ return r && i && zi(t, o, i), i;
3658
3687
  };
3659
3688
  let Ne = class extends g {
3660
3689
  constructor() {
@@ -3777,13 +3806,13 @@ Ne.styles = b`
3777
3806
  height: 16px;
3778
3807
  }
3779
3808
  `;
3780
- Et([
3809
+ Dt([
3781
3810
  p({ type: String })
3782
3811
  ], Ne.prototype, "label", 2);
3783
- Et([
3812
+ Dt([
3784
3813
  p({ type: String })
3785
3814
  ], Ne.prototype, "value", 2);
3786
- Ne = Et([
3815
+ Ne = Dt([
3787
3816
  u("pigeon-alignment-picker")
3788
3817
  ], Ne);
3789
3818
  var Fi = Object.defineProperty, Ni = Object.getOwnPropertyDescriptor, At = (e, t, o, r) => {
@@ -4116,19 +4145,19 @@ le([
4116
4145
  L = le([
4117
4146
  u("pigeon-slider-input")
4118
4147
  ], L);
4119
- var Wi = Object.defineProperty, Vi = Object.getOwnPropertyDescriptor, we = (e, t, o, r) => {
4120
- for (var i = r > 1 ? void 0 : r ? Vi(t, o) : t, n = e.length - 1, a; n >= 0; n--)
4148
+ var Wi = Object.defineProperty, qi = Object.getOwnPropertyDescriptor, we = (e, t, o, r) => {
4149
+ for (var i = r > 1 ? void 0 : r ? qi(t, o) : t, n = e.length - 1, a; n >= 0; n--)
4121
4150
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
4122
4151
  return r && i && Wi(t, o, i), i;
4123
4152
  };
4124
- let V = class extends g {
4153
+ let X = class extends g {
4125
4154
  constructor() {
4126
4155
  super(...arguments), this.tags = [], this.open = !1, this.x = 0, this.y = 0, this._search = "";
4127
4156
  }
4128
4157
  render() {
4129
4158
  const e = this._getFilteredTags(), t = this._groupByCategory(e);
4130
4159
  return l`
4131
- <div class="picker" style="position: absolute; left: ${this.x}px; top: ${this.y}px;">
4160
+ <div class="picker" style="position: fixed; left: ${this.x}px; top: ${this.y}px;">
4132
4161
  <div class="search-box">
4133
4162
  <input
4134
4163
  type="text"
@@ -4177,7 +4206,7 @@ let V = class extends g {
4177
4206
  })), this.open = !1, this._search = "";
4178
4207
  }
4179
4208
  };
4180
- V.styles = b`
4209
+ X.styles = b`
4181
4210
  :host {
4182
4211
  display: none;
4183
4212
  }
@@ -4270,30 +4299,30 @@ V.styles = b`
4270
4299
  `;
4271
4300
  we([
4272
4301
  p({ type: Array })
4273
- ], V.prototype, "tags", 2);
4302
+ ], X.prototype, "tags", 2);
4274
4303
  we([
4275
4304
  p({ type: Boolean, reflect: !0 })
4276
- ], V.prototype, "open", 2);
4305
+ ], X.prototype, "open", 2);
4277
4306
  we([
4278
4307
  p({ type: Number })
4279
- ], V.prototype, "x", 2);
4308
+ ], X.prototype, "x", 2);
4280
4309
  we([
4281
4310
  p({ type: Number })
4282
- ], V.prototype, "y", 2);
4311
+ ], X.prototype, "y", 2);
4283
4312
  we([
4284
4313
  d()
4285
- ], V.prototype, "_search", 2);
4286
- V = we([
4314
+ ], X.prototype, "_search", 2);
4315
+ X = we([
4287
4316
  u("pigeon-merge-tag-picker")
4288
- ], V);
4289
- var Yi = Object.defineProperty, qi = Object.getOwnPropertyDescriptor, J = (e, t, o, r) => {
4290
- for (var i = r > 1 ? void 0 : r ? qi(t, o) : t, n = e.length - 1, a; n >= 0; n--)
4317
+ ], X);
4318
+ var Vi = Object.defineProperty, Yi = Object.getOwnPropertyDescriptor, N = (e, t, o, r) => {
4319
+ for (var i = r > 1 ? void 0 : r ? Yi(t, o) : t, n = e.length - 1, a; n >= 0; n--)
4291
4320
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
4292
- return r && i && Yi(t, o, i), i;
4321
+ return r && i && Vi(t, o, i), i;
4293
4322
  };
4294
- let E = class extends g {
4323
+ let S = class extends g {
4295
4324
  constructor() {
4296
- super(...arguments), this.rowId = "", this.columnId = "", this.mergeTags = [], this._pickerOpen = !1, this._pickerX = 0, this._pickerY = 0, this._textareaRef = be(), this._triggerRef = be();
4325
+ super(...arguments), this.rowId = "", this.columnId = "", this.mergeTags = [], this.requestMergeTags = !1, this._pickerOpen = !1, this._pickerX = 0, this._pickerY = 0, this._textareaRef = be(), this._triggerRef = be();
4297
4326
  }
4298
4327
  render() {
4299
4328
  if (!this.block) return l``;
@@ -4304,7 +4333,7 @@ let E = class extends g {
4304
4333
  <div class="field">
4305
4334
  <div class="label-row">
4306
4335
  <label>${s("panel.common.contentHtml")}</label>
4307
- ${t ? l`
4336
+ ${t || this.requestMergeTags ? l`
4308
4337
  <button class="tag-btn" ${ve(this._triggerRef)} @click=${this._togglePicker} title=${s("panel.common.insertMergeTag")}>
4309
4338
  ${s("panel.common.tagBtn")}
4310
4339
  </button>
@@ -4354,6 +4383,10 @@ let E = class extends g {
4354
4383
  `;
4355
4384
  }
4356
4385
  _togglePicker() {
4386
+ if (!this.mergeTags.length) {
4387
+ this.dispatchEvent(new CustomEvent("pigeon:merge-tag-request", { bubbles: !0, composed: !0 }));
4388
+ return;
4389
+ }
4357
4390
  const e = this._triggerRef.value;
4358
4391
  if (e) {
4359
4392
  if (!this._pickerOpen) {
@@ -4409,8 +4442,8 @@ let E = class extends g {
4409
4442
  this._emit({ padding: e.detail.value });
4410
4443
  }
4411
4444
  };
4412
- E.styles = [
4413
- C,
4445
+ S.styles = [
4446
+ I,
4414
4447
  b`
4415
4448
  /* Content textarea uses the monospace face so the HTML payload is
4416
4449
  readable to authors editing the raw markup. */
@@ -4454,30 +4487,33 @@ E.styles = [
4454
4487
  }
4455
4488
  `
4456
4489
  ];
4457
- J([
4490
+ N([
4458
4491
  p({ type: Object })
4459
- ], E.prototype, "block", 2);
4460
- J([
4492
+ ], S.prototype, "block", 2);
4493
+ N([
4461
4494
  p({ type: String })
4462
- ], E.prototype, "rowId", 2);
4463
- J([
4495
+ ], S.prototype, "rowId", 2);
4496
+ N([
4464
4497
  p({ type: String })
4465
- ], E.prototype, "columnId", 2);
4466
- J([
4498
+ ], S.prototype, "columnId", 2);
4499
+ N([
4467
4500
  p({ type: Array })
4468
- ], E.prototype, "mergeTags", 2);
4469
- J([
4501
+ ], S.prototype, "mergeTags", 2);
4502
+ N([
4503
+ p({ attribute: !1 })
4504
+ ], S.prototype, "requestMergeTags", 2);
4505
+ N([
4470
4506
  d()
4471
- ], E.prototype, "_pickerOpen", 2);
4472
- J([
4507
+ ], S.prototype, "_pickerOpen", 2);
4508
+ N([
4473
4509
  d()
4474
- ], E.prototype, "_pickerX", 2);
4475
- J([
4510
+ ], S.prototype, "_pickerX", 2);
4511
+ N([
4476
4512
  d()
4477
- ], E.prototype, "_pickerY", 2);
4478
- E = J([
4513
+ ], S.prototype, "_pickerY", 2);
4514
+ S = N([
4479
4515
  u("pigeon-text-panel")
4480
- ], E);
4516
+ ], S);
4481
4517
  var Xi = Object.defineProperty, Gi = Object.getOwnPropertyDescriptor, w = (e, t, o, r) => {
4482
4518
  for (var i = r > 1 ? void 0 : r ? Gi(t, o) : t, n = e.length - 1, a; n >= 0; n--)
4483
4519
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
@@ -4487,10 +4523,10 @@ let mt = null;
4487
4523
  function Ji() {
4488
4524
  return mt || (mt = import("./pigeon-stock-tab.js")), mt;
4489
4525
  }
4490
- const Zi = 250, qe = "__all__";
4526
+ const Zi = 250, Ye = "__all__";
4491
4527
  let x = class extends g {
4492
4528
  constructor() {
4493
- super(...arguments), this.config = {}, this.open = !1, this._tab = null, this._stockTabLoaded = !1, this._dragOver = !1, this._uploading = !1, this._progress = 0, this._error = "", this._urlInput = "", this._folder = qe, this._search = "", this._selectedTags = [], this._folders = [], this._assets = [], this._libraryLoading = !1, this._libraryError = "", this._searchTimer = null, this._libraryToken = 0, this._handleStockTabClick = async () => {
4529
+ super(...arguments), this.config = {}, this.open = !1, this._tab = null, this._stockTabLoaded = !1, this._dragOver = !1, this._uploading = !1, this._progress = 0, this._error = "", this._urlInput = "", this._folder = Ye, this._search = "", this._selectedTags = [], this._folders = [], this._assets = [], this._libraryLoading = !1, this._libraryError = "", this._searchTimer = null, this._libraryToken = 0, this._handleStockTabClick = async () => {
4494
4530
  this._tab = "stock", this._stockTabLoaded || (await Ji(), this._stockTabLoaded = !0);
4495
4531
  };
4496
4532
  }
@@ -4569,7 +4605,7 @@ let x = class extends g {
4569
4605
  .value=${this._folder}
4570
4606
  @change=${this._onFolderChange}
4571
4607
  >
4572
- <option value=${qe}>${s("asset.folder.all")}</option>
4608
+ <option value=${Ye}>${s("asset.folder.all")}</option>
4573
4609
  ${this._folders.map(
4574
4610
  (e) => l`<option value=${e} ?selected=${this._folder === e}>${e}</option>`
4575
4611
  )}
@@ -4593,7 +4629,7 @@ let x = class extends g {
4593
4629
  </div>` : te}
4594
4630
  ${this._libraryError ? l`<div class="error">${this._libraryError}</div>` : te}
4595
4631
  ${this._libraryLoading ? l`<div class="library-spinner">${s("asset.loading")}</div>` : this._assets.length === 0 ? l`<div class="empty-library">
4596
- ${this._search || this._selectedTags.length > 0 || this._folder !== qe ? s("asset.empty.filtered") : s("asset.empty.no-assets")}
4632
+ ${this._search || this._selectedTags.length > 0 || this._folder !== Ye ? s("asset.empty.filtered") : s("asset.empty.no-assets")}
4597
4633
  </div>` : l`<div class="asset-grid">
4598
4634
  ${this._assets.map((e) => this._renderAssetCard(e))}
4599
4635
  </div>`}
@@ -4671,7 +4707,7 @@ let x = class extends g {
4671
4707
  this._libraryLoading = !0, this._libraryError = "";
4672
4708
  try {
4673
4709
  const t = await this.storage.list({
4674
- folder: this._folder === qe ? void 0 : this._folder,
4710
+ folder: this._folder === Ye ? void 0 : this._folder,
4675
4711
  search: this._search.trim() || void 0,
4676
4712
  tags: this._selectedTags.length > 0 ? this._selectedTags : void 0
4677
4713
  });
@@ -5340,7 +5376,7 @@ let z = class extends g {
5340
5376
  }
5341
5377
  };
5342
5378
  z.styles = [
5343
- C,
5379
+ I,
5344
5380
  b`
5345
5381
  .upload-btn {
5346
5382
  margin-top: 6px;
@@ -5530,7 +5566,7 @@ var ir = Object.defineProperty, rr = Object.getOwnPropertyDescriptor, ke = (e, t
5530
5566
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
5531
5567
  return r && i && ir(t, o, i), i;
5532
5568
  };
5533
- let Y = class extends g {
5569
+ let G = class extends g {
5534
5570
  constructor() {
5535
5571
  super(...arguments), this.rowId = "", this.columnId = "", this.swatches = [], this.linkTypes = [];
5536
5572
  }
@@ -5692,25 +5728,25 @@ let Y = class extends g {
5692
5728
  this._emit({ innerPadding: e.detail.value });
5693
5729
  }
5694
5730
  };
5695
- Y.styles = C;
5731
+ G.styles = I;
5696
5732
  ke([
5697
5733
  p({ type: Object })
5698
- ], Y.prototype, "block", 2);
5734
+ ], G.prototype, "block", 2);
5699
5735
  ke([
5700
5736
  p({ type: String })
5701
- ], Y.prototype, "rowId", 2);
5737
+ ], G.prototype, "rowId", 2);
5702
5738
  ke([
5703
5739
  p({ type: String })
5704
- ], Y.prototype, "columnId", 2);
5740
+ ], G.prototype, "columnId", 2);
5705
5741
  ke([
5706
5742
  p({ attribute: !1 })
5707
- ], Y.prototype, "swatches", 2);
5743
+ ], G.prototype, "swatches", 2);
5708
5744
  ke([
5709
5745
  p({ attribute: !1 })
5710
- ], Y.prototype, "linkTypes", 2);
5711
- Y = ke([
5746
+ ], G.prototype, "linkTypes", 2);
5747
+ G = ke([
5712
5748
  u("pigeon-button-panel")
5713
- ], Y);
5749
+ ], G);
5714
5750
  var nr = Object.defineProperty, ar = Object.getOwnPropertyDescriptor, lo = (e, t, o, r) => {
5715
5751
  for (var i = r > 1 ? void 0 : r ? ar(t, o) : t, n = e.length - 1, a; n >= 0; n--)
5716
5752
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
@@ -5836,7 +5872,7 @@ let et = class extends g {
5836
5872
  }
5837
5873
  };
5838
5874
  et.styles = [
5839
- C,
5875
+ I,
5840
5876
  b`
5841
5877
  .hint {
5842
5878
  margin: 4px 0 0;
@@ -5992,14 +6028,14 @@ st([
5992
6028
  me = st([
5993
6029
  u("pigeon-font-picker")
5994
6030
  ], me);
5995
- var pr = Object.defineProperty, cr = Object.getOwnPropertyDescriptor, Z = (e, t, o, r) => {
6031
+ var pr = Object.defineProperty, cr = Object.getOwnPropertyDescriptor, U = (e, t, o, r) => {
5996
6032
  for (var i = r > 1 ? void 0 : r ? cr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
5997
6033
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
5998
6034
  return r && i && pr(t, o, i), i;
5999
6035
  };
6000
- let A = class extends g {
6036
+ let O = class extends g {
6001
6037
  constructor() {
6002
- super(...arguments), this.mergeTags = [], this.swatches = [], this.brandFonts = [], this._pickerOpen = !1, this._pickerX = 0, this._pickerY = 0, this._previewInputRef = be(), this._triggerRef = be();
6038
+ super(...arguments), this.mergeTags = [], this.requestMergeTags = !1, this.swatches = [], this.brandFonts = [], this._pickerOpen = !1, this._pickerX = 0, this._pickerY = 0, this._previewInputRef = be(), this._triggerRef = be();
6003
6039
  }
6004
6040
  render() {
6005
6041
  if (!this.doc) return l``;
@@ -6056,7 +6092,7 @@ let A = class extends g {
6056
6092
  <div class="field">
6057
6093
  <div class="label-row">
6058
6094
  <label>${s("panel.body.previewText")}</label>
6059
- ${this.mergeTags.length > 0 ? l`
6095
+ ${this.mergeTags.length > 0 || this.requestMergeTags ? l`
6060
6096
  <button class="tag-btn" ${ve(this._triggerRef)} @click=${this._togglePicker} title=${s("panel.common.insertMergeTag")}>
6061
6097
  ${s("panel.common.tagBtn")}
6062
6098
  </button>
@@ -6083,6 +6119,10 @@ let A = class extends g {
6083
6119
  `;
6084
6120
  }
6085
6121
  _togglePicker() {
6122
+ if (!this.mergeTags.length) {
6123
+ this.dispatchEvent(new CustomEvent("pigeon:merge-tag-request", { bubbles: !0, composed: !0 }));
6124
+ return;
6125
+ }
6086
6126
  const e = this._triggerRef.value;
6087
6127
  if (e) {
6088
6128
  if (!this._pickerOpen) {
@@ -6126,8 +6166,8 @@ let A = class extends g {
6126
6166
  this._emit({ metaField: "previewText", value: e.target.value });
6127
6167
  }
6128
6168
  };
6129
- A.styles = [
6130
- C,
6169
+ O.styles = [
6170
+ I,
6131
6171
  b`
6132
6172
  .alignment-buttons {
6133
6173
  display: flex;
@@ -6200,36 +6240,39 @@ A.styles = [
6200
6240
  }
6201
6241
  `
6202
6242
  ];
6203
- Z([
6243
+ U([
6204
6244
  p({ type: Object })
6205
- ], A.prototype, "doc", 2);
6206
- Z([
6245
+ ], O.prototype, "doc", 2);
6246
+ U([
6207
6247
  p({ type: Array })
6208
- ], A.prototype, "mergeTags", 2);
6209
- Z([
6248
+ ], O.prototype, "mergeTags", 2);
6249
+ U([
6210
6250
  p({ attribute: !1 })
6211
- ], A.prototype, "swatches", 2);
6212
- Z([
6251
+ ], O.prototype, "requestMergeTags", 2);
6252
+ U([
6213
6253
  p({ attribute: !1 })
6214
- ], A.prototype, "brandFonts", 2);
6215
- Z([
6254
+ ], O.prototype, "swatches", 2);
6255
+ U([
6256
+ p({ attribute: !1 })
6257
+ ], O.prototype, "brandFonts", 2);
6258
+ U([
6216
6259
  d()
6217
- ], A.prototype, "_pickerOpen", 2);
6218
- Z([
6260
+ ], O.prototype, "_pickerOpen", 2);
6261
+ U([
6219
6262
  d()
6220
- ], A.prototype, "_pickerX", 2);
6221
- Z([
6263
+ ], O.prototype, "_pickerX", 2);
6264
+ U([
6222
6265
  d()
6223
- ], A.prototype, "_pickerY", 2);
6224
- A = Z([
6266
+ ], O.prototype, "_pickerY", 2);
6267
+ O = U([
6225
6268
  u("pigeon-body-panel")
6226
- ], A);
6227
- var dr = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, Q = (e, t, o, r) => {
6269
+ ], O);
6270
+ var dr = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, ee = (e, t, o, r) => {
6228
6271
  for (var i = r > 1 ? void 0 : r ? hr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
6229
6272
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
6230
6273
  return r && i && dr(t, o, i), i;
6231
6274
  };
6232
- let B = class extends g {
6275
+ let j = class extends g {
6233
6276
  constructor() {
6234
6277
  super(...arguments), this.rowId = "", this.columnId = "", this.swatches = [], this._assetManagerOpen = !1;
6235
6278
  }
@@ -6382,31 +6425,31 @@ let B = class extends g {
6382
6425
  this._emit({ backgroundUrl: e.detail.url }), this._assetManagerOpen = !1;
6383
6426
  }
6384
6427
  };
6385
- B.styles = [C];
6386
- Q([
6428
+ j.styles = [I];
6429
+ ee([
6387
6430
  p({ type: Object })
6388
- ], B.prototype, "block", 2);
6389
- Q([
6431
+ ], j.prototype, "block", 2);
6432
+ ee([
6390
6433
  p({ type: String })
6391
- ], B.prototype, "rowId", 2);
6392
- Q([
6434
+ ], j.prototype, "rowId", 2);
6435
+ ee([
6393
6436
  p({ type: String })
6394
- ], B.prototype, "columnId", 2);
6395
- Q([
6437
+ ], j.prototype, "columnId", 2);
6438
+ ee([
6396
6439
  p({ type: Object })
6397
- ], B.prototype, "assetManagerConfig", 2);
6398
- Q([
6440
+ ], j.prototype, "assetManagerConfig", 2);
6441
+ ee([
6399
6442
  p({ attribute: !1 })
6400
- ], B.prototype, "assetStorage", 2);
6401
- Q([
6443
+ ], j.prototype, "assetStorage", 2);
6444
+ ee([
6402
6445
  p({ attribute: !1 })
6403
- ], B.prototype, "swatches", 2);
6404
- Q([
6446
+ ], j.prototype, "swatches", 2);
6447
+ ee([
6405
6448
  d()
6406
- ], B.prototype, "_assetManagerOpen", 2);
6407
- B = Q([
6449
+ ], j.prototype, "_assetManagerOpen", 2);
6450
+ j = ee([
6408
6451
  u("pigeon-hero-panel")
6409
- ], B);
6452
+ ], j);
6410
6453
  var gr = Object.defineProperty, ur = Object.getOwnPropertyDescriptor, Ke = (e, t, o, r) => {
6411
6454
  for (var i = r > 1 ? void 0 : r ? ur(t, o) : t, n = e.length - 1, a; n >= 0; n--)
6412
6455
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
@@ -6550,7 +6593,7 @@ let ae = class extends g {
6550
6593
  }
6551
6594
  };
6552
6595
  ae.styles = [
6553
- C,
6596
+ I,
6554
6597
  b`
6555
6598
  h4 {
6556
6599
  margin: 0 0 8px;
@@ -6710,7 +6753,7 @@ let se = class extends g {
6710
6753
  this._emit({ padding: e.detail.value });
6711
6754
  }
6712
6755
  };
6713
- se.styles = C;
6756
+ se.styles = I;
6714
6757
  We([
6715
6758
  p({ type: Object })
6716
6759
  ], se.prototype, "block", 2);
@@ -6768,7 +6811,7 @@ let _e = class extends g {
6768
6811
  this._emit({ height: e.detail.value });
6769
6812
  }
6770
6813
  };
6771
- _e.styles = C;
6814
+ _e.styles = I;
6772
6815
  lt([
6773
6816
  p({ type: Object })
6774
6817
  ], _e.prototype, "block", 2);
@@ -6940,7 +6983,7 @@ let ye = class extends g {
6940
6983
  }
6941
6984
  };
6942
6985
  ye.styles = [
6943
- C,
6986
+ I,
6944
6987
  b`
6945
6988
  h4 {
6946
6989
  margin: 0 0 8px;
@@ -7011,14 +7054,14 @@ pt([
7011
7054
  ye = pt([
7012
7055
  u("pigeon-social-panel")
7013
7056
  ], ye);
7014
- var $r = Object.defineProperty, wr = Object.getOwnPropertyDescriptor, ee = (e, t, o, r) => {
7057
+ var $r = Object.defineProperty, wr = Object.getOwnPropertyDescriptor, K = (e, t, o, r) => {
7015
7058
  for (var i = r > 1 ? void 0 : r ? wr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
7016
7059
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
7017
7060
  return r && i && $r(t, o, i), i;
7018
7061
  };
7019
- let j = class extends g {
7062
+ let E = class extends g {
7020
7063
  constructor() {
7021
- super(...arguments), this.rowId = "", this.columnId = "", this.mergeTags = [], this._pickerOpen = !1, this._pickerX = 0, this._pickerY = 0, this._textareaRef = be(), this._triggerRef = be();
7064
+ super(...arguments), this.rowId = "", this.columnId = "", this.mergeTags = [], this.requestMergeTags = !1, this._pickerOpen = !1, this._pickerX = 0, this._pickerY = 0, this._textareaRef = be(), this._triggerRef = be();
7022
7065
  }
7023
7066
  render() {
7024
7067
  if (!this.block) return l``;
@@ -7029,7 +7072,7 @@ let j = class extends g {
7029
7072
  <div class="field">
7030
7073
  <div class="label-row">
7031
7074
  <label>${s("panel.html.rawHtml")}</label>
7032
- ${t ? l`
7075
+ ${t || this.requestMergeTags ? l`
7033
7076
  <button class="tag-btn" ${ve(this._triggerRef)} @click=${this._togglePicker} title=${s("panel.common.insertMergeTag")}>
7034
7077
  ${s("panel.common.tagBtn")}
7035
7078
  </button>
@@ -7078,6 +7121,10 @@ let j = class extends g {
7078
7121
  this._emit({ padding: e.detail.value });
7079
7122
  }
7080
7123
  _togglePicker() {
7124
+ if (!this.mergeTags.length) {
7125
+ this.dispatchEvent(new CustomEvent("pigeon:merge-tag-request", { bubbles: !0, composed: !0 }));
7126
+ return;
7127
+ }
7081
7128
  const e = this._triggerRef.value;
7082
7129
  if (e) {
7083
7130
  if (!this._pickerOpen) {
@@ -7096,8 +7143,8 @@ let j = class extends g {
7096
7143
  t.setSelectionRange(h, h), t.focus(), this._emit({ content: a }), this._pickerOpen = !1;
7097
7144
  }
7098
7145
  };
7099
- j.styles = [
7100
- C,
7146
+ E.styles = [
7147
+ I,
7101
7148
  b`
7102
7149
  /* HTML payload is raw markup — show in monospace and taller than the
7103
7150
  default textarea so authors have room to work. */
@@ -7141,36 +7188,39 @@ j.styles = [
7141
7188
  }
7142
7189
  `
7143
7190
  ];
7144
- ee([
7191
+ K([
7145
7192
  p({ type: Object })
7146
- ], j.prototype, "block", 2);
7147
- ee([
7193
+ ], E.prototype, "block", 2);
7194
+ K([
7148
7195
  p({ type: String })
7149
- ], j.prototype, "rowId", 2);
7150
- ee([
7196
+ ], E.prototype, "rowId", 2);
7197
+ K([
7151
7198
  p({ type: String })
7152
- ], j.prototype, "columnId", 2);
7153
- ee([
7199
+ ], E.prototype, "columnId", 2);
7200
+ K([
7154
7201
  p({ type: Array })
7155
- ], j.prototype, "mergeTags", 2);
7156
- ee([
7202
+ ], E.prototype, "mergeTags", 2);
7203
+ K([
7204
+ p({ attribute: !1 })
7205
+ ], E.prototype, "requestMergeTags", 2);
7206
+ K([
7157
7207
  d()
7158
- ], j.prototype, "_pickerOpen", 2);
7159
- ee([
7208
+ ], E.prototype, "_pickerOpen", 2);
7209
+ K([
7160
7210
  d()
7161
- ], j.prototype, "_pickerX", 2);
7162
- ee([
7211
+ ], E.prototype, "_pickerX", 2);
7212
+ K([
7163
7213
  d()
7164
- ], j.prototype, "_pickerY", 2);
7165
- j = ee([
7214
+ ], E.prototype, "_pickerY", 2);
7215
+ E = K([
7166
7216
  u("pigeon-html-panel")
7167
- ], j);
7217
+ ], E);
7168
7218
  var kr = Object.defineProperty, Cr = Object.getOwnPropertyDescriptor, Ce = (e, t, o, r) => {
7169
7219
  for (var i = r > 1 ? void 0 : r ? Cr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
7170
7220
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
7171
7221
  return r && i && kr(t, o, i), i;
7172
7222
  };
7173
- let q = class extends g {
7223
+ let J = class extends g {
7174
7224
  constructor() {
7175
7225
  super(...arguments), this.rowId = "", this.columnId = "", this.label = "Block", this.schema = [];
7176
7226
  }
@@ -7280,33 +7330,33 @@ let q = class extends g {
7280
7330
  );
7281
7331
  }
7282
7332
  };
7283
- q.styles = C;
7333
+ J.styles = I;
7284
7334
  Ce([
7285
7335
  p({ type: Object })
7286
- ], q.prototype, "block", 2);
7336
+ ], J.prototype, "block", 2);
7287
7337
  Ce([
7288
7338
  p({ type: String })
7289
- ], q.prototype, "rowId", 2);
7339
+ ], J.prototype, "rowId", 2);
7290
7340
  Ce([
7291
7341
  p({ type: String })
7292
- ], q.prototype, "columnId", 2);
7342
+ ], J.prototype, "columnId", 2);
7293
7343
  Ce([
7294
7344
  p({ type: String })
7295
- ], q.prototype, "label", 2);
7345
+ ], J.prototype, "label", 2);
7296
7346
  Ce([
7297
7347
  p({ type: Array })
7298
- ], q.prototype, "schema", 2);
7299
- q = Ce([
7348
+ ], J.prototype, "schema", 2);
7349
+ J = Ce([
7300
7350
  u("pigeon-custom-panel")
7301
- ], q);
7302
- var Ir = Object.defineProperty, Pr = Object.getOwnPropertyDescriptor, F = (e, t, o, r) => {
7303
- for (var i = r > 1 ? void 0 : r ? Pr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
7351
+ ], J);
7352
+ var Ir = Object.defineProperty, Tr = Object.getOwnPropertyDescriptor, M = (e, t, o, r) => {
7353
+ for (var i = r > 1 ? void 0 : r ? Tr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
7304
7354
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
7305
7355
  return r && i && Ir(t, o, i), i;
7306
7356
  };
7307
- let T = class extends g {
7357
+ let C = class extends g {
7308
7358
  constructor() {
7309
- super(...arguments), this.selection = null, this.mergeTags = [], this.brandKit = null, this.fontConfig = [], this.linkTypes = [];
7359
+ super(...arguments), this.selection = null, this.mergeTags = [], this.requestMergeTags = !1, this.brandKit = null, this.fontConfig = [], this.linkTypes = [];
7310
7360
  }
7311
7361
  get _swatches() {
7312
7362
  var e;
@@ -7325,6 +7375,7 @@ let T = class extends g {
7325
7375
  <pigeon-body-panel
7326
7376
  .doc=${this.doc}
7327
7377
  .mergeTags=${this.mergeTags}
7378
+ .requestMergeTags=${this.requestMergeTags}
7328
7379
  .swatches=${this._swatches}
7329
7380
  .brandFonts=${this._brandFonts}
7330
7381
  ></pigeon-body-panel>
@@ -7415,7 +7466,7 @@ let T = class extends g {
7415
7466
  _renderBlockPanel(e, t, o) {
7416
7467
  switch (e.type) {
7417
7468
  case "text":
7418
- return l`<pigeon-text-panel .block=${e} .rowId=${t} .columnId=${o} .mergeTags=${this.mergeTags}></pigeon-text-panel>`;
7469
+ return l`<pigeon-text-panel .block=${e} .rowId=${t} .columnId=${o} .mergeTags=${this.mergeTags} .requestMergeTags=${this.requestMergeTags}></pigeon-text-panel>`;
7419
7470
  case "image":
7420
7471
  return l`<pigeon-image-panel
7421
7472
  .block=${e}
@@ -7444,7 +7495,7 @@ let T = class extends g {
7444
7495
  case "social":
7445
7496
  return l`<pigeon-social-panel .block=${e} .rowId=${t} .columnId=${o}></pigeon-social-panel>`;
7446
7497
  case "html":
7447
- return l`<pigeon-html-panel .block=${e} .rowId=${t} .columnId=${o} .mergeTags=${this.mergeTags}></pigeon-html-panel>`;
7498
+ return l`<pigeon-html-panel .block=${e} .rowId=${t} .columnId=${o} .mergeTags=${this.mergeTags} .requestMergeTags=${this.requestMergeTags}></pigeon-html-panel>`;
7448
7499
  default: {
7449
7500
  const r = e.type ?? "unknown", i = yt(r);
7450
7501
  return i != null && i.propertySchema && i.propertySchema.length > 0 ? l`<pigeon-custom-panel
@@ -7475,7 +7526,7 @@ let T = class extends g {
7475
7526
  return i.blocks.find((n) => n.id === o);
7476
7527
  }
7477
7528
  };
7478
- T.styles = b`
7529
+ C.styles = b`
7479
7530
  :host {
7480
7531
  display: block;
7481
7532
  width: var(--pigeon-properties-width, 300px);
@@ -7558,37 +7609,40 @@ T.styles = b`
7558
7609
  line-height: 1.5;
7559
7610
  }
7560
7611
  `;
7561
- F([
7612
+ M([
7562
7613
  p({ type: Object })
7563
- ], T.prototype, "doc", 2);
7564
- F([
7614
+ ], C.prototype, "doc", 2);
7615
+ M([
7565
7616
  p({ type: Object })
7566
- ], T.prototype, "selection", 2);
7567
- F([
7617
+ ], C.prototype, "selection", 2);
7618
+ M([
7568
7619
  p({ type: Array })
7569
- ], T.prototype, "mergeTags", 2);
7570
- F([
7620
+ ], C.prototype, "mergeTags", 2);
7621
+ M([
7571
7622
  p({ attribute: !1 })
7572
- ], T.prototype, "assetManagerConfig", 2);
7573
- F([
7623
+ ], C.prototype, "requestMergeTags", 2);
7624
+ M([
7574
7625
  p({ attribute: !1 })
7575
- ], T.prototype, "assetStorage", 2);
7576
- F([
7626
+ ], C.prototype, "assetManagerConfig", 2);
7627
+ M([
7577
7628
  p({ attribute: !1 })
7578
- ], T.prototype, "brandKit", 2);
7579
- F([
7629
+ ], C.prototype, "assetStorage", 2);
7630
+ M([
7580
7631
  p({ attribute: !1 })
7581
- ], T.prototype, "fontConfig", 2);
7582
- F([
7632
+ ], C.prototype, "brandKit", 2);
7633
+ M([
7583
7634
  p({ attribute: !1 })
7584
- ], T.prototype, "linkTypes", 2);
7585
- T = F([
7635
+ ], C.prototype, "fontConfig", 2);
7636
+ M([
7637
+ p({ attribute: !1 })
7638
+ ], C.prototype, "linkTypes", 2);
7639
+ C = M([
7586
7640
  u("pigeon-properties")
7587
- ], T);
7588
- var Tr = Object.defineProperty, Sr = Object.getOwnPropertyDescriptor, S = (e, t, o, r) => {
7641
+ ], C);
7642
+ var Pr = Object.defineProperty, Sr = Object.getOwnPropertyDescriptor, D = (e, t, o, r) => {
7589
7643
  for (var i = r > 1 ? void 0 : r ? Sr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
7590
7644
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
7591
- return r && i && Tr(t, o, i), i;
7645
+ return r && i && Pr(t, o, i), i;
7592
7646
  };
7593
7647
  let k = class extends g {
7594
7648
  constructor() {
@@ -7677,6 +7731,7 @@ let k = class extends g {
7677
7731
  return l`
7678
7732
  <iframe
7679
7733
  style="width: ${this._device === "mobile" ? "375px" : "100%"}; height: 100%;"
7734
+ sandbox="allow-popups allow-popups-to-escape-sandbox"
7680
7735
  srcdoc=${this._htmlContent}
7681
7736
  ></iframe>
7682
7737
  `;
@@ -7884,46 +7939,46 @@ k.styles = b`
7884
7939
  font-size: 14px;
7885
7940
  }
7886
7941
  `;
7887
- S([
7942
+ D([
7888
7943
  p({ type: Object })
7889
7944
  ], k.prototype, "renderer", 2);
7890
- S([
7945
+ D([
7891
7946
  p({ type: Object })
7892
7947
  ], k.prototype, "doc", 2);
7893
- S([
7948
+ D([
7894
7949
  p({ attribute: !1 })
7895
7950
  ], k.prototype, "documentToMjml", 2);
7896
- S([
7951
+ D([
7897
7952
  p({ attribute: !1 })
7898
7953
  ], k.prototype, "fonts", 2);
7899
- S([
7954
+ D([
7900
7955
  p({ type: Boolean, reflect: !0 })
7901
7956
  ], k.prototype, "open", 2);
7902
- S([
7957
+ D([
7903
7958
  d()
7904
7959
  ], k.prototype, "_viewMode", 2);
7905
- S([
7960
+ D([
7906
7961
  d()
7907
7962
  ], k.prototype, "_device", 2);
7908
- S([
7963
+ D([
7909
7964
  d()
7910
7965
  ], k.prototype, "_htmlContent", 2);
7911
- S([
7966
+ D([
7912
7967
  d()
7913
7968
  ], k.prototype, "_mjmlContent", 2);
7914
- S([
7969
+ D([
7915
7970
  d()
7916
7971
  ], k.prototype, "_loading", 2);
7917
- k = S([
7972
+ k = D([
7918
7973
  u("pigeon-preview")
7919
7974
  ], k);
7920
- var Or = Object.defineProperty, Dr = Object.getOwnPropertyDescriptor, $ = (e, t, o, r) => {
7921
- for (var i = r > 1 ? void 0 : r ? Dr(t, o) : t, n = e.length - 1, a; n >= 0; n--)
7975
+ var Or = Object.defineProperty, Er = Object.getOwnPropertyDescriptor, $ = (e, t, o, r) => {
7976
+ for (var i = r > 1 ? void 0 : r ? Er(t, o) : t, n = e.length - 1, a; n >= 0; n--)
7922
7977
  (a = e[n]) && (i = (r ? a(t, o, i) : a(i)) || i);
7923
7978
  return r && i && Or(t, o, i), i;
7924
7979
  };
7925
7980
  let _t = null;
7926
- function Er() {
7981
+ function Dr() {
7927
7982
  return _t || (_t = import("./templates.js").then((e) => e.p)), _t;
7928
7983
  }
7929
7984
  function Qt(e) {
@@ -7959,7 +8014,7 @@ let _ = class extends g {
7959
8014
  e.stopPropagation(), this._applyBodyAttribute("fontFamily", e.detail.family);
7960
8015
  }, this._handleBrandLogoInsert = (e) => {
7961
8016
  e.stopPropagation();
7962
- const { logo: t } = e.detail, o = Ye("image");
8017
+ const { logo: t } = e.detail, o = Ve("image");
7963
8018
  o.values.src = t.src, o.values.alt = t.name, t.width && (o.values.width = t.width);
7964
8019
  const r = this._state.selection;
7965
8020
  if (r != null && r.rowId && (r != null && r.columnId)) {
@@ -7972,7 +8027,7 @@ let _ = class extends g {
7972
8027
  ce(n.id, a.id, o, a.blocks.length)(this._state, this._dispatch);
7973
8028
  } else {
7974
8029
  const n = Ie([o]);
7975
- oe(Pe([n]), 0)(this._state, this._dispatch);
8030
+ oe(Te([n]), 0)(this._state, this._dispatch);
7976
8031
  }
7977
8032
  }, this._dispatch = (e) => {
7978
8033
  this._state = this._state.apply(e), this._syncHistoryFlags(), this.requestUpdate(), this._fireChange(), this._fireSelect();
@@ -8007,7 +8062,7 @@ let _ = class extends g {
8007
8062
  this._emitRowLibraryError(t, "delete");
8008
8063
  }
8009
8064
  }, this._handleKeyDown = (e) => {
8010
- if (!this._state || this._isInTextInput(e) || this._editingBlockId !== null) return;
8065
+ if (!this._state || !this._isForEditor(e) || this._isInTextInput(e) || this._editingBlockId !== null) return;
8011
8066
  const t = e.metaKey || e.ctrlKey, o = this._state.selection;
8012
8067
  if (t && !e.shiftKey && e.key.toLowerCase() === "z") {
8013
8068
  e.preventDefault(), this.undo();
@@ -8019,16 +8074,16 @@ let _ = class extends g {
8019
8074
  }
8020
8075
  if (e.key === "Escape") {
8021
8076
  const r = this._state.createTransaction();
8022
- r.setSelection(Rt()), this._dispatch(r);
8077
+ r.setSelection(Mt()), this._dispatch(r);
8023
8078
  return;
8024
8079
  }
8025
8080
  if (o) {
8026
8081
  if (e.key === "Delete" || e.key === "Backspace") {
8027
- o.type === "block" && o.rowId && o.columnId && o.blockId ? (e.preventDefault(), ho(o.rowId, o.columnId, o.blockId)(this._state, this._dispatch)) : o.type === "row" && o.rowId && (e.preventDefault(), Lt(o.rowId)(this._state, this._dispatch));
8082
+ o.type === "block" && o.rowId && o.columnId && o.blockId ? (e.preventDefault(), ho(o.rowId, o.columnId, o.blockId)(this._state, this._dispatch)) : o.type === "row" && o.rowId && (e.preventDefault(), Rt(o.rowId)(this._state, this._dispatch));
8028
8083
  return;
8029
8084
  }
8030
8085
  if (t && e.key.toLowerCase() === "d") {
8031
- o.type === "block" && o.rowId && o.columnId && o.blockId ? (e.preventDefault(), go(o.rowId, o.columnId, o.blockId)(this._state, this._dispatch)) : o.type === "row" && o.rowId && (e.preventDefault(), zt(o.rowId)(this._state, this._dispatch));
8086
+ o.type === "block" && o.rowId && o.columnId && o.blockId ? (e.preventDefault(), go(o.rowId, o.columnId, o.blockId)(this._state, this._dispatch)) : o.type === "row" && o.rowId && (e.preventDefault(), Lt(o.rowId)(this._state, this._dispatch));
8032
8087
  return;
8033
8088
  }
8034
8089
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
@@ -8048,13 +8103,13 @@ let _ = class extends g {
8048
8103
  if (o.type === "block" && o.rowId && o.columnId && o.blockId) {
8049
8104
  e.preventDefault();
8050
8105
  const r = structuredClone(this._clipboard);
8051
- r.id = Mt();
8106
+ r.id = zt();
8052
8107
  const i = this._findBlockIndex(o.rowId, o.columnId, o.blockId), n = i >= 0 ? i + 1 : void 0;
8053
8108
  ce(o.rowId, o.columnId, r, n)(this._state, this._dispatch);
8054
8109
  } else if (o.type === "column" && o.rowId && o.columnId) {
8055
8110
  e.preventDefault();
8056
8111
  const r = structuredClone(this._clipboard);
8057
- r.id = Mt(), ce(o.rowId, o.columnId, r)(this._state, this._dispatch);
8112
+ r.id = zt(), ce(o.rowId, o.columnId, r)(this._state, this._dispatch);
8058
8113
  }
8059
8114
  return;
8060
8115
  }
@@ -8065,7 +8120,7 @@ let _ = class extends g {
8065
8120
  /* Lifecycle */
8066
8121
  /* ------------------------------------------------------------------ */
8067
8122
  connectedCallback() {
8068
- super.connectedCallback(), Bt(this.config.locale, this.config.messages), this._initState(), this._applyDir(), this._resolveBrandKit(), this._applyTheme(), document.addEventListener("keydown", this._handleKeyDown), this.addEventListener("brand-kit-edit", this._handleBrandKitEdit), this.addEventListener("brand-color-apply", this._handleBrandColorApply), this.addEventListener("brand-font-apply", this._handleBrandFontApply), this.addEventListener("brand-logo-insert", this._handleBrandLogoInsert);
8123
+ super.connectedCallback(), Bt(this.config.locale, this.config.messages), this._state || this._initState(), this._applyDir(), this._resolveBrandKit(), this._applyTheme(), document.addEventListener("keydown", this._handleKeyDown), this.addEventListener("brand-kit-edit", this._handleBrandKitEdit), this.addEventListener("brand-color-apply", this._handleBrandColorApply), this.addEventListener("brand-font-apply", this._handleBrandFontApply), this.addEventListener("brand-logo-insert", this._handleBrandLogoInsert);
8069
8124
  }
8070
8125
  disconnectedCallback() {
8071
8126
  super.disconnectedCallback(), document.removeEventListener("keydown", this._handleKeyDown), this.removeEventListener("brand-kit-edit", this._handleBrandKitEdit), this.removeEventListener("brand-color-apply", this._handleBrandColorApply), this.removeEventListener("brand-font-apply", this._handleBrandFontApply), this.removeEventListener("brand-logo-insert", this._handleBrandLogoInsert);
@@ -8140,7 +8195,7 @@ let _ = class extends g {
8140
8195
  /* Render */
8141
8196
  /* ------------------------------------------------------------------ */
8142
8197
  render() {
8143
- var r;
8198
+ var r, i;
8144
8199
  if (!this._state) return l``;
8145
8200
  const e = this._state.doc, t = this._state.selection, o = this._device === "mobile" ? 375 : this._device === "tablet" ? 768 : 0;
8146
8201
  return l`
@@ -8156,6 +8211,7 @@ let _ = class extends g {
8156
8211
  @toolbar-device=${this._handleDevice}
8157
8212
  @toolbar-fullscreen=${this._handleFullscreen}
8158
8213
  @toolbar-templates=${this._handleTemplatesOpen}
8214
+ @toolbar-export=${this._handleExport}
8159
8215
  @pigeon:preview=${this._handlePreview}
8160
8216
  @pigeon:export-html=${this._handleExportHtml}
8161
8217
  @pigeon:export-mjml=${this._handleExportMjml}
@@ -8212,6 +8268,7 @@ let _ = class extends g {
8212
8268
  .doc=${e}
8213
8269
  .selection=${t}
8214
8270
  .mergeTags=${((r = this.config.mergeTags) == null ? void 0 : r.tags) ?? []}
8271
+ .requestMergeTags=${!!this.config.mergeTags && !((i = this.config.mergeTags.tags) != null && i.length)}
8215
8272
  .assetManagerConfig=${this.config.assetManager ?? {}}
8216
8273
  .assetStorage=${this.assetStorage ?? this.config.assetStorage}
8217
8274
  .brandKit=${this._activeBrandKit}
@@ -8232,9 +8289,9 @@ let _ = class extends g {
8232
8289
  .renderer=${this.renderer}
8233
8290
  .documentToMjml=${this.documentToMjml}
8234
8291
  .fonts=${this._renderFonts()}
8235
- @click=${(i) => {
8236
- var n;
8237
- (n = i.target.classList) != null && n.contains("overlay") && (this._previewOpen = !1);
8292
+ @click=${(n) => {
8293
+ var a;
8294
+ (a = n.target.classList) != null && a.contains("overlay") && (this._previewOpen = !1);
8238
8295
  }}
8239
8296
  ></pigeon-preview>
8240
8297
 
@@ -8312,7 +8369,7 @@ let _ = class extends g {
8312
8369
  o.addStep(n), this._dispatch(o);
8313
8370
  }
8314
8371
  async _handleTemplatesOpen() {
8315
- this._templatePickerLoaded || (await Er(), this._templatePickerLoaded = !0), this._templatePickerOpen = !0;
8372
+ this._templatePickerLoaded || (await Dr(), this._templatePickerLoaded = !0), this._templatePickerOpen = !0;
8316
8373
  }
8317
8374
  _handleTemplateLoad(e) {
8318
8375
  var o;
@@ -8386,23 +8443,32 @@ let _ = class extends g {
8386
8443
  composed: !0
8387
8444
  }));
8388
8445
  }
8389
- _handleExportHtml() {
8446
+ _handleExport() {
8447
+ this.dispatchEvent(new CustomEvent("pigeon:export", {
8448
+ bubbles: !0,
8449
+ composed: !0
8450
+ }));
8451
+ }
8452
+ async _handleExportHtml(e) {
8453
+ e.stopPropagation();
8454
+ const t = this._state.doc, o = await this.exportHtml();
8390
8455
  this.dispatchEvent(new CustomEvent("pigeon:export-html", {
8391
- detail: { document: this._state.doc },
8456
+ detail: { document: t, html: o },
8392
8457
  bubbles: !0,
8393
8458
  composed: !0
8394
8459
  }));
8395
8460
  }
8396
- _handleExportMjml() {
8397
- const e = this.documentToMjml ? this.documentToMjml(this._state.doc, { fonts: this._renderFonts() }) : null;
8461
+ _handleExportMjml(e) {
8462
+ e.stopPropagation();
8463
+ const t = this.documentToMjml ? this.documentToMjml(this._state.doc, { fonts: this._renderFonts() }) : null;
8398
8464
  this.dispatchEvent(new CustomEvent("pigeon:export-mjml", {
8399
- detail: { document: this._state.doc, mjml: e },
8465
+ detail: { document: this._state.doc, mjml: t },
8400
8466
  bubbles: !0,
8401
8467
  composed: !0
8402
8468
  }));
8403
8469
  }
8404
- _handleExportJson() {
8405
- this.dispatchEvent(new CustomEvent("pigeon:export-json", {
8470
+ _handleExportJson(e) {
8471
+ e.stopPropagation(), this.dispatchEvent(new CustomEvent("pigeon:export-json", {
8406
8472
  detail: { document: this._state.doc },
8407
8473
  bubbles: !0,
8408
8474
  composed: !0
@@ -8459,7 +8525,7 @@ let _ = class extends g {
8459
8525
  _handleBodySelect() {
8460
8526
  this._editingBlockId = null;
8461
8527
  const e = this._state.createTransaction();
8462
- e.setSelection(Rt()), this._dispatch(e);
8528
+ e.setSelection(Mt()), this._dispatch(e);
8463
8529
  }
8464
8530
  /* ------------------------------------------------------------------ */
8465
8531
  /* Row action handlers */
@@ -8468,10 +8534,10 @@ let _ = class extends g {
8468
8534
  wo(e.detail.rowId, e.detail.toIndex)(this._state, this._dispatch);
8469
8535
  }
8470
8536
  _handleRowDuplicate(e) {
8471
- zt(e.detail.rowId)(this._state, this._dispatch);
8537
+ Lt(e.detail.rowId)(this._state, this._dispatch);
8472
8538
  }
8473
8539
  _handleRowDelete(e) {
8474
- Lt(e.detail.rowId)(this._state, this._dispatch);
8540
+ Rt(e.detail.rowId)(this._state, this._dispatch);
8475
8541
  }
8476
8542
  async _refreshSavedTab() {
8477
8543
  var o;
@@ -8502,6 +8568,11 @@ let _ = class extends g {
8502
8568
  }
8503
8569
  return !1;
8504
8570
  }
8571
+ /** True when the key press is aimed at the editor, or at nothing else on the page. */
8572
+ _isForEditor(e) {
8573
+ const t = e.composedPath()[0];
8574
+ return t === document || t === document.body || t === document.documentElement ? !0 : e.composedPath().includes(this);
8575
+ }
8505
8576
  _flattenBlockLocations() {
8506
8577
  const e = [];
8507
8578
  for (const t of this._state.doc.body.rows)
@@ -8547,13 +8618,13 @@ let _ = class extends g {
8547
8618
  /* DnD handlers */
8548
8619
  /* ------------------------------------------------------------------ */
8549
8620
  _handleRowDrop(e) {
8550
- const { index: t, columnCount: o } = e.detail, r = Array.from({ length: o }, () => Ie()), i = Pe(r);
8621
+ const { index: t, columnCount: o } = e.detail, r = Array.from({ length: o }, () => Ie()), i = Te(r);
8551
8622
  oe(i, t)(this._state, this._dispatch);
8552
8623
  }
8553
8624
  _handleBlockDrop(e) {
8554
8625
  const { rowId: t, columnId: o, index: r, dragData: i } = e.detail;
8555
8626
  if (i.type === "palette-block" && i.blockType) {
8556
- const n = Ye(i.blockType);
8627
+ const n = Ve(i.blockType);
8557
8628
  ce(t, o, n, r)(this._state, this._dispatch);
8558
8629
  } else i.type === "existing-block" && i.blockId && i.rowId && i.columnId && ko(
8559
8630
  i.rowId,
@@ -8565,7 +8636,7 @@ let _ = class extends g {
8565
8636
  )(this._state, this._dispatch);
8566
8637
  }
8567
8638
  _handleBlockDropNewRow(e) {
8568
- const { blockType: t, rowIndex: o } = e.detail, r = Ye(t), i = Ie([r]), n = Pe([i]);
8639
+ const { blockType: t, rowIndex: o } = e.detail, r = Ve(t), i = Ie([r]), n = Te([i]);
8569
8640
  oe(n, o)(this._state, this._dispatch);
8570
8641
  }
8571
8642
  /**
@@ -8577,11 +8648,11 @@ let _ = class extends g {
8577
8648
  const { type: t, blockType: o, columnCount: r } = e.detail, i = this._state.doc.body.rows;
8578
8649
  if (t === "palette-row") {
8579
8650
  const a = Array.from({ length: r }, () => Ie());
8580
- oe(Pe(a), i.length)(this._state, this._dispatch);
8651
+ oe(Te(a), i.length)(this._state, this._dispatch);
8581
8652
  return;
8582
8653
  }
8583
8654
  if (!o) return;
8584
- const n = Ye(o);
8655
+ const n = Ve(o);
8585
8656
  if (i.length > 0) {
8586
8657
  const a = i[i.length - 1], h = a.columns[0];
8587
8658
  ce(a.id, h.id, n, h.blocks.length)(
@@ -8590,7 +8661,7 @@ let _ = class extends g {
8590
8661
  );
8591
8662
  } else {
8592
8663
  const a = Ie([n]);
8593
- oe(Pe([a]), 0)(this._state, this._dispatch);
8664
+ oe(Te([a]), 0)(this._state, this._dispatch);
8594
8665
  }
8595
8666
  }
8596
8667
  /* ------------------------------------------------------------------ */
@@ -8616,11 +8687,11 @@ let _ = class extends g {
8616
8687
  const v = this._state.doc.body.rows.find((m) => m.id === t);
8617
8688
  if (v && v.columns.length > 1) {
8618
8689
  const m = v.columns[v.columns.length - 1];
8619
- Po(t, m.id)(this._state, this._dispatch);
8690
+ To(t, m.id)(this._state, this._dispatch);
8620
8691
  }
8621
8692
  }
8622
8693
  const h = this._state.doc.body.rows.find((c) => c.id === t);
8623
- h && h.columns.length === o.length && To(t, o)(this._state, this._dispatch);
8694
+ h && h.columns.length === o.length && Po(t, o)(this._state, this._dispatch);
8624
8695
  }
8625
8696
  _handleBodyPropertyChange(e) {
8626
8697
  const { attribute: t, metaField: o, value: r } = e.detail, i = this._state.createTransaction();
@@ -8654,7 +8725,7 @@ let _ = class extends g {
8654
8725
  }
8655
8726
  };
8656
8727
  _.styles = [
8657
- Do,
8728
+ Eo,
8658
8729
  b`
8659
8730
  :host {
8660
8731
  display: flex;
@@ -8741,43 +8812,43 @@ _ = $([
8741
8812
  export {
8742
8813
  Ne as PigeonAlignmentPicker,
8743
8814
  x as PigeonAssetManager,
8744
- A as PigeonBodyPanel,
8815
+ O as PigeonBodyPanel,
8745
8816
  he as PigeonButtonBlock,
8746
- Y as PigeonButtonPanel,
8817
+ G as PigeonButtonPanel,
8747
8818
  P as PigeonCanvas,
8748
8819
  fe as PigeonColorPicker,
8749
- O as PigeonColumn,
8820
+ A as PigeonColumn,
8750
8821
  Be as PigeonDividerBlock,
8751
8822
  Ge as PigeonDropIndicator,
8752
8823
  _ as PigeonEditor,
8753
8824
  ge as PigeonHeroBlock,
8754
- B as PigeonHeroPanel,
8755
- Le as PigeonHtmlBlock,
8825
+ j as PigeonHeroPanel,
8826
+ Re as PigeonHtmlBlock,
8756
8827
  Ae as PigeonImageBlock,
8757
8828
  z as PigeonImagePanel,
8758
- Ee as PigeonLayers,
8759
- V as PigeonMergeTagPicker,
8760
- ze as PigeonNavBarBlock,
8829
+ De as PigeonLayers,
8830
+ X as PigeonMergeTagPicker,
8831
+ Le as PigeonNavBarBlock,
8761
8832
  ae as PigeonNavBarPanel,
8762
- I as PigeonPalette,
8763
- W as PigeonPaletteItem,
8833
+ T as PigeonPalette,
8834
+ Y as PigeonPaletteItem,
8764
8835
  k as PigeonPreview,
8765
- T as PigeonProperties,
8766
- D as PigeonRow,
8836
+ C as PigeonProperties,
8837
+ B as PigeonRow,
8767
8838
  et as PigeonRowPanel,
8768
8839
  L as PigeonSliderInput,
8769
- Re as PigeonSocialBlock,
8840
+ Me as PigeonSocialBlock,
8770
8841
  je as PigeonSpacerBlock,
8771
8842
  Ue as PigeonSpacingInput,
8772
- Ur as PigeonTemplatePicker,
8843
+ Kr as PigeonTemplatePicker,
8773
8844
  de as PigeonTextBlock,
8774
- E as PigeonTextPanel,
8775
- K as PigeonToolbar,
8776
- Yo as calculateBlockDropIndex,
8777
- Vo as calculateRowDropIndex,
8845
+ S as PigeonTextPanel,
8846
+ V as PigeonToolbar,
8847
+ Vo as calculateBlockDropIndex,
8848
+ qo as calculateRowDropIndex,
8778
8849
  Xe as clearDragData,
8779
- De as getDragData,
8780
- Hr as readDragTransfer,
8850
+ Ee as getDragData,
8851
+ Fr as readDragTransfer,
8781
8852
  Bo as setDragData,
8782
8853
  wt as writeDragTransfer
8783
8854
  };