@useinsider/guido 3.7.0-beta.fc2a9d1 → 3.7.1-beta.05a2232

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 (30) hide show
  1. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +2 -2
  2. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +24 -22
  3. package/dist/composables/useHtmlValidator.js +79 -73
  4. package/dist/composables/useSave.js +17 -16
  5. package/dist/composables/validators/useUnsubscribeBlockValidator.js +32 -0
  6. package/dist/enums/html-validator.js +13 -5
  7. package/dist/enums/toaster.js +1 -1
  8. package/dist/extensions/Blocks/Recommendation/block.js +35 -16
  9. package/dist/extensions/Blocks/Recommendation/useRecommendationBlockWarning.js +16 -0
  10. package/dist/extensions/Blocks/Recommendation/utils/recommendationBlockCount.js +9 -0
  11. package/dist/extensions/Blocks/Unsubscribe/block.js +123 -73
  12. package/dist/extensions/Blocks/Unsubscribe/control.js +33 -26
  13. package/dist/extensions/Blocks/Unsubscribe/template.js +4 -4
  14. package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +4 -3
  15. package/dist/guido.css +1 -1
  16. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +3 -0
  17. package/dist/src/composables/validators/useUnsubscribeBlockValidator.test.d.ts +1 -0
  18. package/dist/src/enums/html-validator.d.ts +4 -0
  19. package/dist/src/enums/toaster.d.ts +2 -1
  20. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +13 -0
  21. package/dist/src/extensions/Blocks/Recommendation/block.test.d.ts +1 -0
  22. package/dist/src/extensions/Blocks/Recommendation/useRecommendationBlockWarning.d.ts +12 -0
  23. package/dist/src/extensions/Blocks/Recommendation/utils/recommendationBlockCount.d.ts +28 -0
  24. package/dist/src/extensions/Blocks/Recommendation/utils/recommendationBlockCount.test.d.ts +1 -0
  25. package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +9 -0
  26. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  27. package/dist/src/extensions/Blocks/Unsubscribe/utils/constants.d.ts +1 -0
  28. package/dist/static/styles/components/base-input.css.js +5 -0
  29. package/dist/stores/autosave.js +6 -6
  30. package/package.json +1 -1
@@ -1,39 +1,41 @@
1
- var g = Object.defineProperty;
2
- var k = (c, n, e) => n in c ? g(c, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[n] = e;
3
- var l = (c, n, e) => k(c, typeof n != "symbol" ? n + "" : n, e);
4
- import { useToaster as B } from "../../../composables/useToaster.js";
5
- import { ToasterTypeOptions as S } from "../../../enums/toaster.js";
6
- import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
7
- import { useUnsubscribeStore as a } from "../../../stores/unsubscribe.js";
8
- import { Block as L, BlockCompositionType as f, ContextActionType as h, ModificationDescription as b, BlockType as v } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
9
- import { getDefaultTemplate as A } from "./template.js";
10
- import { DATA_ATTRIBUTES as i, UNSUBSCRIBE_EVENTS as d } from "./utils/constants.js";
11
- import { parsePageList as p } from "./utils/utils.js";
12
- const y = "unsubscribe-block", m = 'a[data-unsubscribe-link="true"]', _ = ".unsubscribe-block-v2", I = "{{ins-unsubscribe-link}}", T = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", C = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", N = {
13
- [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
14
- [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
15
- };
16
- class F extends L {
1
+ var S = Object.defineProperty;
2
+ var L = (c, o, e) => o in c ? S(c, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[o] = e;
3
+ var a = (c, o, e) => L(c, typeof o != "symbol" ? o + "" : o, e);
4
+ import { useToaster as f } from "../../../composables/useToaster.js";
5
+ import { ToasterTypeOptions as A } from "../../../enums/toaster.js";
6
+ import { PAGE_TYPES as h } from "../../../enums/unsubscribe.js";
7
+ import { useUnsubscribeStore as u } from "../../../stores/unsubscribe.js";
8
+ import { Block as y, BlockCompositionType as T, ContextActionType as k, ModificationDescription as d, BlockType as I } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
9
+ import { getDefaultTemplate as v } from "./template.js";
10
+ import { UNSUBSCRIBE_BLOCK_SELECTOR as m, DATA_ATTRIBUTES as n, UNSUBSCRIBE_EVENTS as b } from "./utils/constants.js";
11
+ import { parsePageList as B } from "./utils/utils.js";
12
+ const C = "unsubscribe-block", E = 'a[data-unsubscribe-link="true"]', N = "{{ins-unsubscribe-link}}", U = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", R = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", D = {
13
+ [h.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
14
+ [h.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
15
+ }, w = 3;
16
+ class H extends y {
17
17
  constructor() {
18
18
  super();
19
- l(this, "selectEventListener", null);
20
- l(this, "cancelEventListener", null);
21
- l(this, "currentNode");
19
+ a(this, "selectEventListener", null);
20
+ a(this, "cancelEventListener", null);
21
+ a(this, "currentNode");
22
22
  // Per-block "did this instance have a link last time we saw it?" tracking.
23
23
  // Keyed by the stable `data-unsubscribe-block-id` we assign, because
24
24
  // ImmutableHtmlNode instances are recreated on every document mutation and
25
25
  // can't be used as Map keys directly. A singleton boolean here would be
26
26
  // polluted across blocks since Stripo fires onDocumentChanged per-instance.
27
- l(this, "linkStateByBlockId", /* @__PURE__ */ new Map());
27
+ a(this, "linkStateByBlockId", /* @__PURE__ */ new Map());
28
+ // Per-block prepend retry counter for the leading text guard (SD-143097).
29
+ a(this, "guardAttemptsByBlockId", /* @__PURE__ */ new Map());
28
30
  }
29
31
  getId() {
30
- return y;
32
+ return C;
31
33
  }
32
34
  getIcon() {
33
35
  return "unsubscribe-icon";
34
36
  }
35
37
  getBlockCompositionType() {
36
- return f.BLOCK;
38
+ return T.BLOCK;
37
39
  }
38
40
  getName() {
39
41
  return this.api.translate("Unsubscribe Block");
@@ -42,36 +44,84 @@ class F extends L {
42
44
  return this.api.translate("Unsubscribe Block Description");
43
45
  }
44
46
  getTemplate() {
45
- return A();
47
+ return v();
46
48
  }
47
49
  getContextActionsIds() {
48
- return [h.MOVE, h.REMOVE];
50
+ return [k.MOVE, k.REMOVE];
49
51
  }
50
52
  onSelect(e) {
51
53
  this.currentNode = e;
52
54
  const t = this._getOrAssignBlockId(e);
53
55
  t && this.linkStateByBlockId.set(t, this._hasUnsubscribeLink(e)), !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
54
56
  }
57
+ onCreated(e) {
58
+ this._ensureLeadingTextGuard(e);
59
+ }
60
+ onDocumentInit() {
61
+ try {
62
+ const e = this.api.getDocumentRoot();
63
+ e && "querySelectorAll" in e && e.querySelectorAll(m).forEach((t) => {
64
+ this._ensureLeadingTextGuard(t);
65
+ });
66
+ } catch {
67
+ }
68
+ }
55
69
  onDocumentChanged(e) {
70
+ this._ensureLeadingTextGuard(e);
56
71
  const t = this._getOrAssignBlockId(e);
57
72
  if (!t)
58
73
  return;
59
- const r = this._hasUnsubscribeLink(e);
60
- this.linkStateByBlockId.get(t) === !0 && !r && this._warnLinkRemoved(), this.linkStateByBlockId.set(t, r);
74
+ const s = this._hasUnsubscribeLink(e);
75
+ this.linkStateByBlockId.get(t) === !0 && !s && this._warnLinkRemoved(), this.linkStateByBlockId.set(t, s);
61
76
  }
62
77
  onDelete(e) {
63
78
  this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
64
79
  const t = this._readBlockId(e);
65
- t && this.linkStateByBlockId.delete(t);
80
+ t && (this.linkStateByBlockId.delete(t), this.guardAttemptsByBlockId.delete(t));
66
81
  }
67
82
  onDestroy() {
68
- this._removeEventListeners(), this.currentNode = void 0, this.linkStateByBlockId.clear();
83
+ this._removeEventListeners(), this.currentNode = void 0, this.linkStateByBlockId.clear(), this.guardAttemptsByBlockId.clear();
84
+ }
85
+ /**
86
+ * Guarantees a plain-text node before the link's wrapper inside the <p>.
87
+ * Without it the only caret position left of the link is inside the anchor,
88
+ * so anything typed there becomes part of the link (SD-143097).
89
+ */
90
+ _ensureLeadingTextGuard(e) {
91
+ if (!("querySelector" in e))
92
+ return;
93
+ const t = e.querySelector(E);
94
+ if (!t)
95
+ return;
96
+ let s = t, r = s.parent();
97
+ for (; r && "getTagName" in r && r.getTagName().toLowerCase() !== "p"; )
98
+ s = r, r = r.parent();
99
+ if (!r || !("getTagName" in r) || r.getTagName().toLowerCase() !== "p")
100
+ return;
101
+ const i = s.previousSibling();
102
+ if (!!(i && i.getType() === "text" && i.getTextContent())) {
103
+ const p = this._readBlockId(e);
104
+ p && this.guardAttemptsByBlockId.delete(p);
105
+ return;
106
+ }
107
+ const g = this._getOrAssignBlockId(e);
108
+ if (!g)
109
+ return;
110
+ const _ = this.guardAttemptsByBlockId.get(g) ?? 0;
111
+ if (!(_ >= w)) {
112
+ this.guardAttemptsByBlockId.set(g, _ + 1);
113
+ try {
114
+ this.api.getDocumentModifier().modifyHtml(r).prepend("&nbsp;").apply(new d("Ensure unsubscribe link text guard"));
115
+ } catch (p) {
116
+ console.warn("[UnsubscribeBlock] Failed to ensure link text guard:", p);
117
+ }
118
+ }
69
119
  }
70
120
  _hasUnsubscribeLink(e) {
71
- return "querySelector" in e ? !!e.querySelector(m) : !1;
121
+ return "querySelector" in e ? !!e.querySelector(E) : !1;
72
122
  }
73
123
  _readBlockId(e) {
74
- return "getAttribute" in e ? e.getAttribute(i.BLOCK_ID) : null;
124
+ return "getAttribute" in e ? e.getAttribute(n.BLOCK_ID) : null;
75
125
  }
76
126
  /**
77
127
  * Returns the block's stable id, assigning one via the document modifier if
@@ -85,13 +135,13 @@ class F extends L {
85
135
  return t;
86
136
  if (!("getAttribute" in e))
87
137
  return null;
88
- const r = this._generateNextBlockId();
138
+ const s = this._generateNextBlockId();
89
139
  try {
90
- this.api.getDocumentModifier().modifyHtml(e).setAttribute(i.BLOCK_ID, r).apply(new b(`Assign unsubscribe block id ${r}`));
91
- } catch (s) {
92
- return console.warn("[UnsubscribeBlock] Failed to assign block id:", s), null;
140
+ this.api.getDocumentModifier().modifyHtml(e).setAttribute(n.BLOCK_ID, s).apply(new d(`Assign unsubscribe block id ${s}`));
141
+ } catch (r) {
142
+ return console.warn("[UnsubscribeBlock] Failed to assign block id:", r), null;
93
143
  }
94
- return r;
144
+ return s;
95
145
  }
96
146
  /**
97
147
  * Generates a unique id by scanning the document for the highest existing
@@ -102,10 +152,10 @@ class F extends L {
102
152
  let e = 0;
103
153
  try {
104
154
  const t = this.api.getDocumentRoot();
105
- t && "querySelectorAll" in t && t.querySelectorAll(_).forEach((s) => {
106
- if ("getAttribute" in s) {
107
- const o = s.getAttribute(i.BLOCK_ID), u = o ? parseInt(o) : 0;
108
- u > e && (e = u);
155
+ t && "querySelectorAll" in t && t.querySelectorAll(m).forEach((r) => {
156
+ if ("getAttribute" in r) {
157
+ const i = r.getAttribute(n.BLOCK_ID), l = i ? parseInt(i) : 0;
158
+ l > e && (e = l);
109
159
  }
110
160
  });
111
161
  } catch {
@@ -114,14 +164,14 @@ class F extends L {
114
164
  }
115
165
  _warnLinkRemoved() {
116
166
  try {
117
- const { showToaster: e } = B();
167
+ const { showToaster: e } = f();
118
168
  e({
119
- type: S.Warning,
120
- message: this.api.translate(C),
169
+ type: A.Warning,
170
+ message: this.api.translate(R),
121
171
  actionButton: {
122
172
  text: this.api.translate("Visit Academy"),
123
173
  onClick: () => {
124
- window.open(T, "_blank", "noopener,noreferrer");
174
+ window.open(U, "_blank", "noopener,noreferrer");
125
175
  }
126
176
  }
127
177
  });
@@ -131,26 +181,26 @@ class F extends L {
131
181
  }
132
182
  _setupSelectEventListener() {
133
183
  this._removeSelectEventListener(), this.selectEventListener = (e) => {
134
- const t = e, { collectionType: r, selectedPages: s } = t.detail;
135
- this._updateBlock(r, s.join(","));
136
- }, document.addEventListener(d.SELECT, this.selectEventListener);
184
+ const t = e, { collectionType: s, selectedPages: r } = t.detail;
185
+ this._updateBlock(s, r.join(","));
186
+ }, document.addEventListener(b.SELECT, this.selectEventListener);
137
187
  }
138
188
  _removeSelectEventListener() {
139
- this.selectEventListener && (document.removeEventListener(d.SELECT, this.selectEventListener), this.selectEventListener = null);
189
+ this.selectEventListener && (document.removeEventListener(b.SELECT, this.selectEventListener), this.selectEventListener = null);
140
190
  }
141
191
  _setupCancelEventListener() {
142
192
  this._removeCancelEventListener(), this.cancelEventListener = () => {
143
193
  this._handleCancel();
144
- }, document.addEventListener(d.CANCEL, this.cancelEventListener);
194
+ }, document.addEventListener(b.CANCEL, this.cancelEventListener);
145
195
  }
146
196
  _removeCancelEventListener() {
147
- this.cancelEventListener && (document.removeEventListener(d.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
197
+ this.cancelEventListener && (document.removeEventListener(b.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
148
198
  }
149
199
  _handleCancel() {
150
200
  try {
151
201
  if (!this.currentNode)
152
202
  return;
153
- this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${v.EMPTY_CONTAINER}/>`).apply(new b("Removed unsubscribe block due to cancel"));
203
+ this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${I.EMPTY_CONTAINER}/>`).apply(new d("Removed unsubscribe block due to cancel"));
154
204
  } catch (e) {
155
205
  console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
156
206
  }
@@ -161,32 +211,32 @@ class F extends L {
161
211
  _updateBlock(e, t) {
162
212
  if (!this.currentNode || !("querySelector" in this.currentNode))
163
213
  return;
164
- const r = this.currentNode.querySelector(m);
165
- if (!r)
214
+ const s = this.currentNode.querySelector(E);
215
+ if (!s)
166
216
  return;
167
- const s = this._getMergeTag(e);
168
- this.api.getDocumentModifier().modifyHtml(r).setAttribute("href", s).apply(new b(`Updated unsubscribe link to ${s}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(i.PAGE_TYPE, e.toString()).setAttribute(i.PAGE_LIST, t).apply(new b("Updated unsubscribe block metadata"));
217
+ const r = this._getMergeTag(e);
218
+ this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", r).apply(new d(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(n.PAGE_TYPE, e.toString()).setAttribute(n.PAGE_LIST, t).apply(new d("Updated unsubscribe block metadata"));
169
219
  }
170
220
  _getMergeTag(e) {
171
- return N[e] ?? I;
221
+ return D[e] ?? N;
172
222
  }
173
223
  _openDrawer() {
174
224
  if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
175
225
  try {
176
- const e = a();
226
+ const e = u();
177
227
  e.typeSelectionDrawerStatus = !0;
178
228
  } catch (e) {
179
229
  console.error("[UnsubscribeBlock] Failed to open drawer:", e);
180
230
  }
181
231
  }
182
232
  _checkExistingBlocks() {
183
- const e = a();
184
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(_).forEach((r) => {
185
- if ("getAttribute" in r) {
186
- const s = r.getAttribute(i.PAGE_TYPE);
187
- if (s) {
188
- const o = Number(s);
189
- o === E.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : o === E.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
233
+ const e = u();
234
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(m).forEach((s) => {
235
+ if ("getAttribute" in s) {
236
+ const r = s.getAttribute(n.PAGE_TYPE);
237
+ if (r) {
238
+ const i = Number(r);
239
+ i === h.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : i === h.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
190
240
  }
191
241
  }
192
242
  });
@@ -194,26 +244,26 @@ class F extends L {
194
244
  async _loadBlockState(e) {
195
245
  if (!("getAttribute" in e))
196
246
  return;
197
- const t = e.getAttribute(i.PAGE_TYPE), r = e.getAttribute(i.PAGE_LIST);
198
- if (!t || !r)
247
+ const t = e.getAttribute(n.PAGE_TYPE), s = e.getAttribute(n.PAGE_LIST);
248
+ if (!t || !s)
199
249
  return;
200
- const s = a(), o = Number(t), u = p(r);
201
- await s.fetchTemplates(), s.setCollectionWithoutAutoSelection(o), s.loadSelectedTemplates(u);
250
+ const r = u(), i = Number(t), l = B(s);
251
+ await r.fetchTemplates(), r.setCollectionWithoutAutoSelection(i), r.loadSelectedTemplates(l);
202
252
  }
203
253
  _resetStoreState() {
204
- a().$reset();
254
+ u().$reset();
205
255
  }
206
256
  _removeBlockTemplatesFromStore(e) {
207
257
  if (!("getAttribute" in e))
208
258
  return;
209
- const t = e.getAttribute(i.PAGE_LIST);
259
+ const t = e.getAttribute(n.PAGE_LIST);
210
260
  if (!t)
211
261
  return;
212
- const r = a(), s = p(t);
213
- r.removeUnsubscribePages(s);
262
+ const s = u(), r = B(t);
263
+ s.removeUnsubscribePages(r);
214
264
  }
215
265
  }
216
266
  export {
217
- y as UNSUBSCRIBE_BLOCK_ID,
218
- F as UnsubscribeBlock
267
+ C as UNSUBSCRIBE_BLOCK_ID,
268
+ H as UnsubscribeBlock
219
269
  };
@@ -1,28 +1,28 @@
1
- var d = Object.defineProperty;
2
- var h = (a, s, e) => s in a ? d(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
- var u = (a, s, e) => h(a, typeof s != "symbol" ? s + "" : s, e);
1
+ var T = Object.defineProperty;
2
+ var p = (o, s, e) => s in o ? T(o, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[s] = e;
3
+ var c = (o, s, e) => p(o, typeof s != "symbol" ? s + "" : s, e);
4
4
  import { useUnsubscribeStore as l } from "../../../stores/unsubscribe.js";
5
- import { Control as T, UEAttr as i, UIElementType as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
- import { DATA_ATTRIBUTES as p } from "./utils/constants.js";
7
- import { parsePageList as _ } from "./utils/utils.js";
8
- const v = "ui-elements-unsubscribe", r = {
5
+ import { Control as _, UEAttr as i, UIElementType as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { DATA_ATTRIBUTES as d } from "./utils/constants.js";
7
+ import { parsePageList as h } from "./utils/utils.js";
8
+ const g = "ui-elements-unsubscribe", r = {
9
9
  SELECT_BUTTON: "selectTemplateButton",
10
10
  PREV_BUTTON: "prevButton",
11
11
  NEXT_BUTTON: "nextButton",
12
12
  COUNTER_TEXT: "counterText",
13
13
  PREVIEW_IMAGE: "previewImage"
14
14
  };
15
- class B extends T {
15
+ class B extends _ {
16
16
  constructor() {
17
17
  super(...arguments);
18
- u(this, "currentPreviewIndex", 0);
19
- u(this, "currentNode");
20
- u(this, "currentPages");
21
- u(this, "valueChangeHandlers", []);
22
- u(this, "lastParsedAttribute");
18
+ c(this, "currentPreviewIndex", 0);
19
+ c(this, "currentNode");
20
+ c(this, "currentPages");
21
+ c(this, "valueChangeHandlers", []);
22
+ c(this, "lastParsedAttribute");
23
23
  }
24
24
  getId() {
25
- return v;
25
+ return g;
26
26
  }
27
27
  getTemplate() {
28
28
  return `
@@ -34,8 +34,8 @@ class B extends T {
34
34
  }
35
35
  onTemplateNodeUpdated(e) {
36
36
  if (this.currentNode = e, "getAttribute" in this.currentNode) {
37
- const t = this.currentNode.getAttribute(p.PAGE_LIST);
38
- t && (t !== this.lastParsedAttribute && (this.currentPages = _(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updateCounter(), this._loadAndUpdatePreview());
37
+ const t = this.currentNode.getAttribute(d.PAGE_LIST);
38
+ t && (t !== this.lastParsedAttribute && (this.currentPages = h(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updateCounter(), this._loadAndUpdatePreview());
39
39
  }
40
40
  }
41
41
  onRender() {
@@ -62,11 +62,18 @@ class B extends T {
62
62
  _onButtonClick() {
63
63
  try {
64
64
  const e = l();
65
- e.activeType = e.getSelectedCollection[this.currentPreviewIndex], e.pageSelectionUpdateStatus = !0, e.pageSelectionDrawerStatus = !0;
65
+ this._reseedSelectionFromBlock(), e.activeType = e.getSelectedCollection[this.currentPreviewIndex], e.pageSelectionUpdateStatus = !0, e.pageSelectionDrawerStatus = !0;
66
66
  } catch (e) {
67
67
  console.error("[UnsubscribeControl] Failed to open drawer:", e);
68
68
  }
69
69
  }
70
+ _reseedSelectionFromBlock() {
71
+ const e = l();
72
+ if (e.$reset(), !this.currentNode || !("getAttribute" in this.currentNode))
73
+ return;
74
+ const t = this.currentNode.getAttribute(d.PAGE_TYPE), a = this.currentNode.getAttribute(d.PAGE_LIST);
75
+ !t || !a || (e.setCollectionWithoutAutoSelection(Number(t)), e.loadSelectedTemplates(h(a)));
76
+ }
70
77
  _onPrevClick() {
71
78
  this.currentPreviewIndex > 0 && (this.currentPreviewIndex--, this._updatePreview(), this._updateCounter());
72
79
  }
@@ -80,21 +87,21 @@ class B extends T {
80
87
  var e;
81
88
  if ((e = this.currentPages) != null && e.length)
82
89
  try {
83
- const t = this.currentPages[this.currentPreviewIndex], o = l().getThumbnailByTemplateId(t);
84
- if (!o) {
90
+ const t = this.currentPages[this.currentPreviewIndex], u = l().getThumbnailByTemplateId(t);
91
+ if (!u) {
85
92
  console.warn("[UnsubscribeControl] No thumbnail found for page:", t);
86
93
  return;
87
94
  }
88
95
  this.api.updateValues({
89
- [r.PREVIEW_IMAGE]: o
96
+ [r.PREVIEW_IMAGE]: u
90
97
  });
91
98
  } catch (t) {
92
99
  console.error("[UnsubscribeControl] Failed to update preview:", t);
93
100
  }
94
101
  }
95
102
  _updateCounter() {
96
- const e = this.currentPreviewIndex + 1, t = this.totalTemplates, c = this.currentPreviewIndex === 0, o = this.currentPreviewIndex >= t - 1;
97
- this.api.setUIEAttribute(r.PREV_BUTTON, i.BUTTON.disabled, c), this.api.setUIEAttribute(r.NEXT_BUTTON, i.BUTTON.disabled, o), this.api.setUIEAttribute(
103
+ const e = this.currentPreviewIndex + 1, t = this.totalTemplates, a = this.currentPreviewIndex === 0, u = this.currentPreviewIndex >= t - 1;
104
+ this.api.setUIEAttribute(r.PREV_BUTTON, i.BUTTON.disabled, a), this.api.setUIEAttribute(r.NEXT_BUTTON, i.BUTTON.disabled, u), this.api.setUIEAttribute(
98
105
  r.COUNTER_TEXT,
99
106
  i.LABEL.text,
100
107
  `${this.api.translate("Showing")} ${e} ${this.api.translate("of")} ${t}`
@@ -135,14 +142,14 @@ class B extends T {
135
142
  </${n.LABEL}>
136
143
  `;
137
144
  }
138
- _getIconButton(e, t, c) {
139
- const o = c ? `${i.BUTTON.disabled}="true"` : "";
145
+ _getIconButton(e, t, a) {
146
+ const u = a ? `${i.BUTTON.disabled}="true"` : "";
140
147
  return `
141
148
  <${n.BUTTON}
142
149
  id="${e}"
143
150
  class="flat-inline flat-white"
144
151
  ${i.BUTTON.name}="${e}"
145
- ${o}
152
+ ${u}
146
153
  >
147
154
  <${n.ICON}
148
155
  src="${t}"
@@ -165,6 +172,6 @@ class B extends T {
165
172
  }
166
173
  }
167
174
  export {
168
- v as UNSUBSCRIBE_CONTROL_ID,
175
+ g as UNSUBSCRIBE_CONTROL_ID,
169
176
  B as UnsubscribeControl
170
177
  };
@@ -1,21 +1,21 @@
1
1
  import { BlockType as s } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- const e = "unsubscribe", n = "{{ins-unsubscribe-link}}", t = `
2
+ const e = "unsubscribe", n = "{{ins-unsubscribe-link}}", b = `
3
3
  <${s.BLOCK_TEXT}
4
4
  class="unsubscribe-block-v2 esd-block-unsubscribe es-p0"
5
5
  align="center"
6
6
  data-unsubscribe-page-type=""
7
7
  data-unsubscribe-page-list=""
8
8
  >
9
- <p>&nbsp;<strong><a
9
+ <p>&nbsp;<a
10
10
  href="${n}"
11
11
  class="unsubscribe-link"
12
12
  target="_blank"
13
13
  data-unsubscribe-link="true"
14
- >${e}</a></strong></p>
14
+ >${e}</a></p>
15
15
  </${s.BLOCK_TEXT}>
16
16
  `;
17
17
  function u() {
18
- return t;
18
+ return b;
19
19
  }
20
20
  export {
21
21
  u as getDefaultTemplate
@@ -1,12 +1,13 @@
1
1
  const s = {
2
2
  SELECT: "unsubscribe:select",
3
3
  CANCEL: "unsubscribe:cancel"
4
- }, e = {
4
+ }, b = {
5
5
  PAGE_TYPE: "data-unsubscribe-page-type",
6
6
  PAGE_LIST: "data-unsubscribe-page-list",
7
7
  BLOCK_ID: "data-unsubscribe-block-id"
8
- };
8
+ }, c = ".unsubscribe-block-v2";
9
9
  export {
10
- e as DATA_ATTRIBUTES,
10
+ b as DATA_ATTRIBUTES,
11
+ c as UNSUBSCRIBE_BLOCK_SELECTOR,
11
12
  s as UNSUBSCRIBE_EVENTS
12
13
  };
package/dist/guido.css CHANGED
@@ -1 +1 @@
1
- .gap-16[data-v-5553d071],.gap-16[data-v-0e1b0c54]{gap:16px}[data-v-73199fa4] .in-button-v2__wrapper{line-height:0}[data-v-22226124] .in-segments-wrapper__button_selected,[data-v-22226124] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb;color:#0010ac;border-color:#0010ac}[data-v-2cb418af] .in-progress-wrapper__progress p span:last-child{display:none!important}[data-v-2cb418af] .in-progress-description-status{display:none!important}.view-options-wrapper[data-v-195ab6d4]{position:relative;display:inline-block}.new-tag[data-v-195ab6d4]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-195ab6d4] .guido__view-option-selection-desktop svg,[data-v-195ab6d4] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-195ab6d4] .in-segments-wrapper__button_selected,[data-v-195ab6d4] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-195ab6d4] .in-tooltip-wrapper__icon{cursor:pointer}.editor-toolbar[data-v-173c3a40]{gap:4px}.version-history-item[data-v-ee4b9c3f]{flex-basis:200px}.version-history[data-v-64c52560]{gap:8px}.version-history__toolbar[data-v-64c52560]{gap:4px}.view-options-wrapper[data-v-d405ca59]{position:relative;display:inline-block}.new-tag[data-v-d405ca59]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-d405ca59] .guido__verion-history-view-option-selection-desktop svg,[data-v-d405ca59] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-d405ca59] .in-segments-wrapper__button_selected,[data-v-d405ca59] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-d405ca59] .in-tooltip-wrapper__icon{cursor:pointer}.auto-save-toggle[data-v-2c964af4]{position:relative}.auto-save-toggle__info-box[data-v-2c964af4]{position:absolute;top:100%;left:0;z-index:10;width:280px}.editor-actions[data-v-82128f7d]{gap:4px}.header-wrapper[data-v-5c02dcc7]{min-width:1000px}.guido-loading__wrapper[data-v-07c4b2d8]{height:100%;top:75px!important;bottom:0!important}.guido-editor__wrapper[data-v-50dac6de]{--ribbon-offset: 0px;position:relative;width:100%;height:calc(100vh - 128px - var(--ribbon-offset))}.guido-editor__container[data-v-50dac6de]{width:100%;height:calc(100vh - 128px - var(--ribbon-offset))}.guido-editor__no-header[data-v-50dac6de]{height:calc(100vh - 75px - var(--ribbon-offset))}[data-v-293f1c47] .in-breadcrumb-wrapper__links{cursor:pointer}.templates-wrapper[data-v-df672485]{gap:16px;grid-template-columns:repeat(3,1fr)}.templates-wrapper .template-wrapper[data-v-df672485]{cursor:pointer}.templates-wrapper .template-wrapper .template-container[data-v-df672485]{height:274px;padding:2px;transition:none}.templates-wrapper .template-wrapper .template-container.selected[data-v-df672485]{padding:1px}.templates-wrapper .template-wrapper .template-container .thumbnail[data-v-df672485]{object-fit:cover;transform:scale(1)}[data-v-43c617a7] .guido__verion-history-view-option-selection-desktop svg,[data-v-43c617a7] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-43c617a7] .in-segments-wrapper__button_selected,[data-v-43c617a7] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}.error-list[data-v-c3fd5d4b]{gap:16px}.desktop-browser-header[data-v-d86c5af5]{height:79px;min-height:79px}.desktop-browser-header__left[data-v-d86c5af5]{-webkit-user-drag:none;height:79px;width:378px}.desktop-browser-header__center[data-v-d86c5af5]{height:79px;background-repeat:repeat-x;background-size:auto 100%;background-position:left top}.desktop-browser-header__right[data-v-d86c5af5]{-webkit-user-drag:none;height:79px;width:112px}.desktop-preview[data-v-988f8da6]{min-width:602px;height:70vh;min-height:583px;border-radius:10px}.desktop-preview iframe[data-v-988f8da6]{min-height:504px}.iframe-wrapper[data-v-e0424e99]{width:258px}.iframe-scaled[data-v-e0424e99]{width:320px;height:124.0310077519%;transform:scale(.80625);transform-origin:top left}.cropped-text[data-v-eb3d05d7]{width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mobile-preview-wrapper__phone[data-v-3f472f96]{width:282px}.mobile-preview-wrapper__phone img[data-v-3f472f96]{object-fit:cover;border-radius:44px}.mobile-preview-wrapper__content[data-v-3f472f96]{width:258px;height:450px;left:12px}[data-v-7419ae06] .vueperslides__bullets,[data-v-796d193b] .vueperslides__bullets{pointer-events:none!important}[data-v-796d193b] .vueperslides__parallax-wrapper{height:110px!important}[data-v-cadfc82d] .vueperslides__bullets{pointer-events:none!important}[data-v-cadfc82d] .vueperslides__parallax-wrapper{height:110px!important}
1
+ .gap-16[data-v-5553d071],.gap-16[data-v-0e1b0c54]{gap:16px}[data-v-73199fa4] .in-button-v2__wrapper{line-height:0}[data-v-22226124] .in-segments-wrapper__button_selected,[data-v-22226124] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb;color:#0010ac;border-color:#0010ac}[data-v-2cb418af] .in-progress-wrapper__progress p span:last-child{display:none!important}[data-v-2cb418af] .in-progress-description-status{display:none!important}.view-options-wrapper[data-v-195ab6d4]{position:relative;display:inline-block}.new-tag[data-v-195ab6d4]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-195ab6d4] .guido__view-option-selection-desktop svg,[data-v-195ab6d4] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-195ab6d4] .in-segments-wrapper__button_selected,[data-v-195ab6d4] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-195ab6d4] .in-tooltip-wrapper__icon{cursor:pointer}.editor-toolbar[data-v-173c3a40]{gap:4px}.version-history-item[data-v-ee4b9c3f]{flex-basis:200px}.version-history[data-v-64c52560]{gap:8px}.version-history__toolbar[data-v-64c52560]{gap:4px}.view-options-wrapper[data-v-d405ca59]{position:relative;display:inline-block}.new-tag[data-v-d405ca59]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-d405ca59] .guido__verion-history-view-option-selection-desktop svg,[data-v-d405ca59] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-d405ca59] .in-segments-wrapper__button_selected,[data-v-d405ca59] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-d405ca59] .in-tooltip-wrapper__icon{cursor:pointer}.auto-save-toggle[data-v-2c964af4]{position:relative}.auto-save-toggle__info-box[data-v-2c964af4]{position:absolute;top:100%;left:0;z-index:10;width:280px}.editor-actions[data-v-82128f7d]{gap:4px}.header-wrapper[data-v-5c02dcc7]{min-width:1000px}.guido-loading__wrapper[data-v-07c4b2d8]{height:100%;top:75px!important;bottom:0!important}.guido-editor__wrapper[data-v-50dac6de]{--ribbon-offset: 0px;position:relative;width:100%;height:calc(100vh - 128px - var(--ribbon-offset))}.guido-editor__container[data-v-50dac6de]{width:100%;height:calc(100vh - 128px - var(--ribbon-offset))}.guido-editor__no-header[data-v-50dac6de]{height:calc(100vh - 75px - var(--ribbon-offset))}[data-v-293f1c47] .in-breadcrumb-wrapper__links{cursor:pointer}.templates-wrapper[data-v-f6a8cb4c]{gap:16px;grid-template-columns:repeat(3,1fr)}.templates-wrapper .template-wrapper[data-v-f6a8cb4c]{cursor:pointer}.templates-wrapper .template-wrapper .template-container[data-v-f6a8cb4c]{height:274px;padding:2px;transition:none}.templates-wrapper .template-wrapper .template-container.selected[data-v-f6a8cb4c]{padding:1px}.templates-wrapper .template-wrapper .template-container .thumbnail[data-v-f6a8cb4c]{object-fit:cover;transform:scale(1)}[data-v-43c617a7] .guido__verion-history-view-option-selection-desktop svg,[data-v-43c617a7] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-43c617a7] .in-segments-wrapper__button_selected,[data-v-43c617a7] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}.error-list[data-v-c3fd5d4b]{gap:16px}.desktop-browser-header[data-v-d86c5af5]{height:79px;min-height:79px}.desktop-browser-header__left[data-v-d86c5af5]{-webkit-user-drag:none;height:79px;width:378px}.desktop-browser-header__center[data-v-d86c5af5]{height:79px;background-repeat:repeat-x;background-size:auto 100%;background-position:left top}.desktop-browser-header__right[data-v-d86c5af5]{-webkit-user-drag:none;height:79px;width:112px}.desktop-preview[data-v-988f8da6]{min-width:602px;height:70vh;min-height:583px;border-radius:10px}.desktop-preview iframe[data-v-988f8da6]{min-height:504px}.iframe-wrapper[data-v-e0424e99]{width:258px}.iframe-scaled[data-v-e0424e99]{width:320px;height:124.0310077519%;transform:scale(.80625);transform-origin:top left}.cropped-text[data-v-eb3d05d7]{width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mobile-preview-wrapper__phone[data-v-3f472f96]{width:282px}.mobile-preview-wrapper__phone img[data-v-3f472f96]{object-fit:cover;border-radius:44px}.mobile-preview-wrapper__content[data-v-3f472f96]{width:258px;height:450px;left:12px}[data-v-7419ae06] .vueperslides__bullets,[data-v-796d193b] .vueperslides__bullets{pointer-events:none!important}[data-v-796d193b] .vueperslides__parallax-wrapper{height:110px!important}[data-v-cadfc82d] .vueperslides__bullets{pointer-events:none!important}[data-v-cadfc82d] .vueperslides__parallax-wrapper{height:110px!important}
@@ -0,0 +1,3 @@
1
+ export declare const useUnsubscribeBlockValidator: () => {
2
+ validateUnsubscribeBlockUniqueness: (html: string) => boolean;
3
+ };
@@ -4,3 +4,7 @@ export declare const CampaignCouldNotBeSavedKey = "newsletter.campaign-could-not
4
4
  export declare const DISPLAY_CONDITIONS_REGEX: RegExp;
5
5
  export declare const DISPLAY_CONDITIONS_EXCEPTIONS_REGEX: RegExp;
6
6
  export declare const REMOVE_CONDITIONS_REGEX: RegExp;
7
+ export declare const DYNAMIC_CONTENT_TAG_REGEX: RegExp;
8
+ export declare const DATA_ATTRIBUTE_REGEX: RegExp;
9
+ export declare const VALID_DYNAMIC_VARIABLE_REGEX: RegExp;
10
+ export declare const ALLOWED_DYNAMIC_SYSTEM_TOKENS: string[];
@@ -1,5 +1,6 @@
1
1
  export declare enum ToasterTypeOptions {
2
2
  Success = "success",
3
3
  Warning = "warning",
4
- Alert = "alert"
4
+ Alert = "alert",
5
+ Dark = "dark"
5
6
  }
@@ -55,6 +55,19 @@ export declare class RecommendationBlock extends Block {
55
55
  * @param node - The block node being deleted
56
56
  */
57
57
  onDelete(node: ImmutableHtmlNode): void;
58
+ /**
59
+ * Warns (dark advisory toaster) when the design holds more than one live
60
+ * recommendation block. Triggered from the user-add paths only (fresh drop
61
+ * and duplicate) — never from document-load/migration, so opening a template
62
+ * that already has multiple blocks does not fire it. `onCreated` also runs
63
+ * for a reco block that arrives inside a saved structure (SD-143028), so this
64
+ * covers that case too — no separate `module_dropped` handling is needed.
65
+ *
66
+ * Counting lives in `useRecommendationBlockWarning`, whose DOM-based logic
67
+ * ignores the empty shells deletions leave behind (SD-143028). Wrapped in
68
+ * try/catch because the document root may be unavailable during initial load.
69
+ */
70
+ private _warnIfMultipleBlocks;
58
71
  /**
59
72
  * Generates the next unique recommendation ID by scanning all existing blocks
60
73
  * in the document and finding the maximum existing ID + 1.
@@ -0,0 +1,12 @@
1
+ import type { QueryableRoot } from './utils/recommendationBlockCount';
2
+ /**
3
+ * Advisory shown when a design ends up with more than one recommendation block,
4
+ * since multiple blocks can slow campaign delivery. Driven from the block
5
+ * lifecycle (`onCreated` for direct drop / duplicate, counting the editor's
6
+ * document root). `onCreated` also fires for a reco block that arrives inside a
7
+ * saved structure (SD-143028), so that case is covered without a separate
8
+ * `module_dropped` re-check.
9
+ */
10
+ export declare const useRecommendationBlockWarning: () => {
11
+ warnIfMultipleBlocks: (root: QueryableRoot) => void;
12
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Counts *live* recommendation blocks in a document.
3
+ *
4
+ * Deleting a recommendation block strips its inner content but leaves an empty
5
+ * `.recommendation-block-v2` container shell behind — present in every document
6
+ * representation the editor exposes (`getDocumentRoot`, `getDocumentRootHtmlNode`
7
+ * and even `getTemplateData`). A raw class count therefore over-reports after a
8
+ * delete→add cycle (SD-143028). The product row (`.recommendation-product-row`)
9
+ * is present on every live block from drop time (the default template ships
10
+ * product rows, both grid and list layouts) and is removed from a deleted
11
+ * block's leftover shell, so filtering by it cleanly separates live blocks from
12
+ * ghosts without reading any store.
13
+ */
14
+ export declare const RECOMMENDATION_BLOCK_SELECTOR = ".recommendation-block-v2";
15
+ export declare const RECOMMENDATION_PRODUCT_ROW_SELECTOR = ".recommendation-product-row";
16
+ interface QueryableNode {
17
+ querySelector(selector: string): unknown;
18
+ }
19
+ export interface QueryableRoot {
20
+ querySelectorAll(selector: string): Iterable<QueryableNode>;
21
+ }
22
+ /**
23
+ * Counts the live recommendation blocks reachable from `root`. Works on the
24
+ * editor's `ImmutableHtmlNode` document root (the `onCreated` drop / duplicate
25
+ * paths) and on any DOM-like root exposing `querySelectorAll`.
26
+ */
27
+ export declare function countLiveRecommendationBlocks(root: QueryableRoot): number;
28
+ export {};
@@ -6,6 +6,7 @@ export declare class UnsubscribeBlock extends Block {
6
6
  private cancelEventListener;
7
7
  private currentNode?;
8
8
  private linkStateByBlockId;
9
+ private guardAttemptsByBlockId;
9
10
  constructor();
10
11
  getId(): string;
11
12
  getIcon(): string;
@@ -15,9 +16,17 @@ export declare class UnsubscribeBlock extends Block {
15
16
  getTemplate(): string;
16
17
  getContextActionsIds(): string[];
17
18
  onSelect(node: ImmutableHtmlElementNode): void;
19
+ onCreated(node: ImmutableHtmlNode): void;
20
+ onDocumentInit(): void;
18
21
  onDocumentChanged(node: ImmutableHtmlNode): void;
19
22
  onDelete(node: ImmutableHtmlElementNode): void;
20
23
  onDestroy(): void;
24
+ /**
25
+ * Guarantees a plain-text node before the link's wrapper inside the <p>.
26
+ * Without it the only caret position left of the link is inside the anchor,
27
+ * so anything typed there becomes part of the link (SD-143097).
28
+ */
29
+ private _ensureLeadingTextGuard;
21
30
  private _hasUnsubscribeLink;
22
31
  private _readBlockId;
23
32
  /**