@useinsider/guido 3.7.1-beta.cb7d58e → 3.7.2-beta.0ef1511

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.
@@ -1,31 +1,32 @@
1
1
  import { useActionsApi as x } from "./useActionsApi.js";
2
2
  import { useConfig as y } from "./useConfig.js";
3
- import { useSaveStart as w, useSaveComplete as C } from "./useGuidoActions.js";
4
- import { useSyncModuleExtractor as E } from "./useSyncModuleExtractor.js";
5
- import { useStripoApi as H } from "../services/stripoApi.js";
6
- import { useTemplatePreparation as b } from "../utils/templatePreparation.js";
7
- import { useHtmlValidator as q } from "./useHtmlValidator.js";
3
+ import { useSaveStart as w, useSaveComplete as H } from "./useGuidoActions.js";
4
+ import { useSyncModuleExtractor as q } from "./useSyncModuleExtractor.js";
5
+ import { useStripoApi as C } from "../services/stripoApi.js";
6
+ import { useTemplatePreparation as E } from "../utils/templatePreparation.js";
7
+ import { useHtmlValidator as k } from "./useHtmlValidator.js";
8
8
  import { useCouponBlockValidator as L } from "./validators/useCouponBlockValidator.js";
9
9
  import { useLiquidValidator as P } from "./validators/useLiquidValidator.js";
10
- const z = () => {
11
- const o = w(), s = C(), { validateHtml: r } = q(), { validateLiquidSyntax: n } = P(), { validateCouponBlockTags: l } = L(), { callbacks: a, isFeatureEnabled: d } = y(), { extractSyncModuleData: u } = E(), { setSyncModuleUnsubscriptionPages: c } = H(), { editorSave: m } = x();
12
- return { save: async (p = !1, f = !1) => {
13
- var i;
10
+ import { useUnsubscribeBlockValidator as B } from "./validators/useUnsubscribeBlockValidator.js";
11
+ const J = () => {
12
+ const o = w(), s = H(), { validateHtml: r } = k(), { validateLiquidSyntax: n } = P(), { validateCouponBlockTags: l } = L(), { validateUnsubscribeBlockUniqueness: d } = B(), { callbacks: i, isFeatureEnabled: u } = y(), { extractSyncModuleData: c } = q(), { setSyncModuleUnsubscriptionPages: m } = C(), { editorSave: p } = x();
13
+ return { save: async (f = !1, v = !1) => {
14
+ var a;
14
15
  o();
15
- const { prepareTemplateDetails: v } = b(), t = await v();
16
- if (!l(t.compiledHtml))
16
+ const { prepareTemplateDetails: S } = E(), t = await S();
17
+ if (!l(t.compiledHtml) || !d(t.compiledHtml))
17
18
  return;
18
- if (d("liquidSyntax")) {
19
+ if (u("liquidSyntax")) {
19
20
  if (!await n(t.compiledHtml))
20
21
  return;
21
22
  } else if (!await r(t.compiledHtml, t.dynamicContentList, !0))
22
23
  return;
23
- if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t) || !await m())
24
+ if ((a = i.value) != null && a.externalValidation && !await i.value.externalValidation(t) || !await p())
24
25
  return;
25
- const { unsubscribePayload: S, stripoModules: V } = u(t.rawHtml);
26
- return await c(S), t.modules = V, p || s({ ...t, silent: f }), t;
26
+ const { unsubscribePayload: V, stripoModules: b } = c(t.rawHtml);
27
+ return await m(V), t.modules = b, f || s({ ...t, silent: v }), t;
27
28
  } };
28
29
  };
29
30
  export {
30
- z as useSave
31
+ J as useSave
31
32
  };
@@ -0,0 +1,32 @@
1
+ import { ToasterTypeOptions as i } from "../../enums/toaster.js";
2
+ import { PAGE_TYPES as n } from "../../enums/unsubscribe.js";
3
+ import { UNSUBSCRIBE_BLOCK_SELECTOR as u, DATA_ATTRIBUTES as l } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
4
+ import { useToaster as T } from "../useToaster.js";
5
+ import { useTranslations as E } from "../useTranslations.js";
6
+ const m = [
7
+ {
8
+ pageType: n.GLOBAL_UNSUBSCRIBE,
9
+ messageKey: "unsubscription-preference.duplicate-global-unsub"
10
+ },
11
+ {
12
+ pageType: n.SUBSCRIPTION_PREFERENCE_CENTER,
13
+ messageKey: "unsubscription-preference.duplicate-pref-center"
14
+ }
15
+ ], g = "unsubscription-preference.duplicate-both", y = () => {
16
+ const { showToaster: o } = T(), a = E();
17
+ return { validateUnsubscribeBlockUniqueness: (c) => {
18
+ const p = new DOMParser().parseFromString(c, "text/html"), t = /* @__PURE__ */ new Map();
19
+ p.querySelectorAll(u).forEach((e) => {
20
+ const r = Number(e.getAttribute(l.PAGE_TYPE));
21
+ t.set(r, (t.get(r) ?? 0) + 1);
22
+ });
23
+ const s = m.filter((e) => (t.get(e.pageType) ?? 0) > 1).map((e) => e.messageKey);
24
+ return s.length ? (o({
25
+ type: i.Alert,
26
+ message: a(s.length > 1 ? g : s[0])
27
+ }), !1) : !0;
28
+ } };
29
+ };
30
+ export {
31
+ y as useUnsubscribeBlockValidator
32
+ };
@@ -7,9 +7,9 @@ import { PAGE_TYPES as h } from "../../../enums/unsubscribe.js";
7
7
  import { useUnsubscribeStore as u } from "../../../stores/unsubscribe.js";
8
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
9
  import { getDefaultTemplate as v } from "./template.js";
10
- import { DATA_ATTRIBUTES as n, UNSUBSCRIBE_EVENTS as p } from "./utils/constants.js";
10
+ import { UNSUBSCRIBE_BLOCK_SELECTOR as m, DATA_ATTRIBUTES as n, UNSUBSCRIBE_EVENTS as b } from "./utils/constants.js";
11
11
  import { parsePageList as B } from "./utils/utils.js";
12
- const C = "unsubscribe-block", m = 'a[data-unsubscribe-link="true"]', E = ".unsubscribe-block-v2", 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 = {
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
13
  [h.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
14
14
  [h.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
15
15
  }, w = 3;
@@ -60,7 +60,7 @@ class H extends y {
60
60
  onDocumentInit() {
61
61
  try {
62
62
  const e = this.api.getDocumentRoot();
63
- e && "querySelectorAll" in e && e.querySelectorAll(E).forEach((t) => {
63
+ e && "querySelectorAll" in e && e.querySelectorAll(m).forEach((t) => {
64
64
  this._ensureLeadingTextGuard(t);
65
65
  });
66
66
  } catch {
@@ -90,7 +90,7 @@ class H extends y {
90
90
  _ensureLeadingTextGuard(e) {
91
91
  if (!("querySelector" in e))
92
92
  return;
93
- const t = e.querySelector(m);
93
+ const t = e.querySelector(E);
94
94
  if (!t)
95
95
  return;
96
96
  let s = t, r = s.parent();
@@ -100,8 +100,8 @@ class H extends y {
100
100
  return;
101
101
  const i = s.previousSibling();
102
102
  if (!!(i && i.getType() === "text" && i.getTextContent())) {
103
- const b = this._readBlockId(e);
104
- b && this.guardAttemptsByBlockId.delete(b);
103
+ const p = this._readBlockId(e);
104
+ p && this.guardAttemptsByBlockId.delete(p);
105
105
  return;
106
106
  }
107
107
  const g = this._getOrAssignBlockId(e);
@@ -112,13 +112,13 @@ class H extends y {
112
112
  this.guardAttemptsByBlockId.set(g, _ + 1);
113
113
  try {
114
114
  this.api.getDocumentModifier().modifyHtml(r).prepend(" ").apply(new d("Ensure unsubscribe link text guard"));
115
- } catch (b) {
116
- console.warn("[UnsubscribeBlock] Failed to ensure link text guard:", b);
115
+ } catch (p) {
116
+ console.warn("[UnsubscribeBlock] Failed to ensure link text guard:", p);
117
117
  }
118
118
  }
119
119
  }
120
120
  _hasUnsubscribeLink(e) {
121
- return "querySelector" in e ? !!e.querySelector(m) : !1;
121
+ return "querySelector" in e ? !!e.querySelector(E) : !1;
122
122
  }
123
123
  _readBlockId(e) {
124
124
  return "getAttribute" in e ? e.getAttribute(n.BLOCK_ID) : null;
@@ -152,7 +152,7 @@ class H extends y {
152
152
  let e = 0;
153
153
  try {
154
154
  const t = this.api.getDocumentRoot();
155
- t && "querySelectorAll" in t && t.querySelectorAll(E).forEach((r) => {
155
+ t && "querySelectorAll" in t && t.querySelectorAll(m).forEach((r) => {
156
156
  if ("getAttribute" in r) {
157
157
  const i = r.getAttribute(n.BLOCK_ID), l = i ? parseInt(i) : 0;
158
158
  l > e && (e = l);
@@ -183,18 +183,18 @@ class H extends y {
183
183
  this._removeSelectEventListener(), this.selectEventListener = (e) => {
184
184
  const t = e, { collectionType: s, selectedPages: r } = t.detail;
185
185
  this._updateBlock(s, r.join(","));
186
- }, document.addEventListener(p.SELECT, this.selectEventListener);
186
+ }, document.addEventListener(b.SELECT, this.selectEventListener);
187
187
  }
188
188
  _removeSelectEventListener() {
189
- this.selectEventListener && (document.removeEventListener(p.SELECT, this.selectEventListener), this.selectEventListener = null);
189
+ this.selectEventListener && (document.removeEventListener(b.SELECT, this.selectEventListener), this.selectEventListener = null);
190
190
  }
191
191
  _setupCancelEventListener() {
192
192
  this._removeCancelEventListener(), this.cancelEventListener = () => {
193
193
  this._handleCancel();
194
- }, document.addEventListener(p.CANCEL, this.cancelEventListener);
194
+ }, document.addEventListener(b.CANCEL, this.cancelEventListener);
195
195
  }
196
196
  _removeCancelEventListener() {
197
- this.cancelEventListener && (document.removeEventListener(p.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
197
+ this.cancelEventListener && (document.removeEventListener(b.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
198
198
  }
199
199
  _handleCancel() {
200
200
  try {
@@ -211,7 +211,7 @@ class H extends y {
211
211
  _updateBlock(e, t) {
212
212
  if (!this.currentNode || !("querySelector" in this.currentNode))
213
213
  return;
214
- const s = this.currentNode.querySelector(m);
214
+ const s = this.currentNode.querySelector(E);
215
215
  if (!s)
216
216
  return;
217
217
  const r = this._getMergeTag(e);
@@ -231,7 +231,7 @@ class H extends y {
231
231
  }
232
232
  _checkExistingBlocks() {
233
233
  const e = u();
234
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(E).forEach((s) => {
234
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(m).forEach((s) => {
235
235
  if ("getAttribute" in s) {
236
236
  const r = s.getAttribute(n.PAGE_TYPE);
237
237
  if (r) {
@@ -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
  };
@@ -1,4 +1,4 @@
1
- const o = { stripo: { version: "2.66.0" } }, s = {
1
+ const o = { stripo: { version: "2.65.0" } }, s = {
2
2
  guido: o
3
3
  };
4
4
  export {
@@ -0,0 +1,3 @@
1
+ export declare const useUnsubscribeBlockValidator: () => {
2
+ validateUnsubscribeBlockUniqueness: (html: string) => boolean;
3
+ };
@@ -8,3 +8,4 @@ export declare const DATA_ATTRIBUTES: {
8
8
  readonly PAGE_LIST: "data-unsubscribe-page-list";
9
9
  readonly BLOCK_ID: "data-unsubscribe-block-id";
10
10
  };
11
+ export declare const UNSUBSCRIBE_BLOCK_SELECTOR = ".unsubscribe-block-v2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.7.1-beta.cb7d58e",
3
+ "version": "3.7.2-beta.0ef1511",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",
@@ -92,7 +92,7 @@
92
92
  },
93
93
  "guido": {
94
94
  "stripo": {
95
- "version": "2.66.0"
95
+ "version": "2.65.0"
96
96
  }
97
97
  }
98
98
  }