@useinsider/guido 1.0.2-beta.ac0dc8b → 1.0.2-beta.ad1dcd9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/@types/generic.d.ts +8 -0
  2. package/dist/components/Guido.vue.d.ts +2 -2
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +68 -64
  5. package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue.d.ts +2 -0
  6. package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue.js +18 -0
  7. package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue2.js +16 -0
  8. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.d.ts +2 -0
  9. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +24 -0
  10. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +64 -0
  11. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.d.ts +2 -0
  12. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.js +18 -0
  13. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue2.js +108 -0
  14. package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.d.ts +2 -0
  15. package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.js +18 -0
  16. package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue2.js +12 -0
  17. package/dist/components/wrappers/WpDrawer.vue.d.ts +6 -4
  18. package/dist/components/wrappers/WpDrawer.vue.js +6 -4
  19. package/dist/composables/useHtmlValidator.js +52 -61
  20. package/dist/composables/useStripo.js +13 -13
  21. package/dist/config/compiler/unsubscribeCompilerRules.js +19 -19
  22. package/dist/config/migrator/index.d.ts +1 -1
  23. package/dist/config/migrator/index.js +6 -6
  24. package/dist/config/migrator/unsubscribeMigrator.d.ts +1 -0
  25. package/dist/config/migrator/unsubscribeMigrator.js +112 -0
  26. package/dist/enums/defaults.js +6 -3
  27. package/dist/enums/unsubscribe.d.ts +19 -0
  28. package/dist/enums/unsubscribe.js +39 -6
  29. package/dist/extensions/Blocks/Unsubscribe/block.d.ts +30 -0
  30. package/dist/extensions/Blocks/Unsubscribe/block.js +141 -0
  31. package/dist/extensions/Blocks/Unsubscribe/control.d.ts +29 -0
  32. package/dist/extensions/Blocks/Unsubscribe/control.js +180 -0
  33. package/dist/extensions/Blocks/Unsubscribe/elements/preview.d.ts +11 -0
  34. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +54 -0
  35. package/dist/extensions/Blocks/{RadioButton → Unsubscribe}/extension.js +6 -5
  36. package/dist/extensions/Blocks/{RadioButton → Unsubscribe}/settingsPanel.d.ts +1 -1
  37. package/dist/extensions/Blocks/{RadioButton → Unsubscribe}/settingsPanel.js +14 -21
  38. package/dist/extensions/Blocks/Unsubscribe/template.d.ts +3 -0
  39. package/dist/extensions/Blocks/{RadioButton/block.js → Unsubscribe/template.js} +15 -26
  40. package/dist/extensions/Blocks/Unsubscribe/utils/constants.d.ts +9 -0
  41. package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +11 -0
  42. package/dist/extensions/Blocks/Unsubscribe/utils/utils.d.ts +7 -0
  43. package/dist/extensions/Blocks/Unsubscribe/utils/utils.js +6 -0
  44. package/dist/guido.css +1 -1
  45. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementsAttributes.js +2 -1
  46. package/dist/services/unsubscribeApi.d.ts +4 -0
  47. package/dist/services/unsubscribeApi.js +16 -0
  48. package/dist/stores/unsubscribe.d.ts +183 -5
  49. package/dist/stores/unsubscribe.js +125 -6
  50. package/package.json +1 -1
  51. package/dist/config/migrator/radioButtonMigrator.d.ts +0 -1
  52. package/dist/config/migrator/radioButtonMigrator.js +0 -86
  53. package/dist/extensions/Blocks/RadioButton/block.d.ts +0 -10
  54. package/dist/extensions/Blocks/RadioButton/control.d.ts +0 -17
  55. package/dist/extensions/Blocks/RadioButton/control.js +0 -104
  56. package/dist/extensions/Blocks/RadioButton/template.d.ts +0 -6
  57. package/dist/extensions/Blocks/RadioButton/template.js +0 -160
  58. /package/dist/extensions/Blocks/{RadioButton → Unsubscribe}/extension.d.ts +0 -0
@@ -1,92 +1,92 @@
1
1
  import { useConfig as H } from "./useConfig.js";
2
2
  import { TemplateTypes as V } from "../enums/defaults.js";
3
- import { DISPLAY_CONDITIONS_REGEX as D, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as P, CampaignCouldNotBeSavedKey as R, CanNotMakeAnyChangesForRunningKey as _ } from "../enums/html-validator.js";
3
+ import { DISPLAY_CONDITIONS_REGEX as B, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as _, CampaignCouldNotBeSavedKey as D, CanNotMakeAnyChangesForRunningKey as P } from "../enums/html-validator.js";
4
4
  import { ToasterTypeOptions as l } from "../enums/toaster.js";
5
- import { useRecommendationStore as G } from "../stores/recommendation.js";
5
+ import { useRecommendationStore as R } from "../stores/recommendation.js";
6
6
  import { base64EncodeWithSpecialChars as $ } from "../utils/base64.js";
7
7
  import { useHttp as j } from "./useHttp.js";
8
- import { useToaster as q } from "./useToaster.js";
9
- import { useTranslations as M } from "./useTranslations.js";
10
- const se = () => {
8
+ import { useToaster as G } from "./useToaster.js";
9
+ import { useTranslations as X } from "./useTranslations.js";
10
+ const te = () => {
11
11
  var d;
12
- const { showToaster: c } = q(), { post: y } = j(), { config: h } = H(), a = M(), m = G(), u = ((d = h.partner) == null ? void 0 : d.messageType) === V.transactional, v = async (e) => {
12
+ const { showToaster: c } = G(), { post: y } = j(), { config: h } = H(), o = X(), m = R(), u = ((d = h.partner) == null ? void 0 : d.messageType) === V.transactional, C = async (e) => {
13
13
  const t = await y(
14
14
  "/newsletter/template-library/check-template-html-body",
15
15
  { html: $(e) }
16
- ), { status: n, message: r } = t.data;
16
+ ), { status: n, message: a } = t.data;
17
17
  return n || c({
18
18
  type: l.Alert,
19
- message: n === void 0 ? r : a("newsletter.invalid-url-link-for-toaster")
20
- }), a(R), r === a(_) && c({
19
+ message: n === void 0 ? a : o("newsletter.invalid-url-link-for-toaster")
20
+ }), o(D), a === o(P) && c({
21
21
  type: l.Alert,
22
- message: a("newsletter.already-in-progress")
22
+ message: o("newsletter.already-in-progress")
23
23
  }), n;
24
- }, C = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), w = (e) => ["if", "endif"].includes(e.toLowerCase()), S = (e, s) => {
24
+ }, v = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), w = (e) => ["if", "endif"].includes(e.toLowerCase()), S = (e, s) => {
25
25
  const t = e.match(/({%(.*?)%})/g);
26
26
  let n = !0;
27
- return t !== null && !u && t.forEach((r) => {
28
- const o = r.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
29
- if (o && o.length > 0) {
30
- const [i] = o;
31
- C(i) && !s.includes(i) && (c({
27
+ return t !== null && !u && t.forEach((a) => {
28
+ const i = a.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
29
+ if (i && i.length > 0) {
30
+ const [r] = i;
31
+ v(r) && !s.includes(r) && (c({
32
32
  type: l.Warning,
33
- message: a("custom-fields.invalid-custom-fields")
33
+ message: o("custom-fields.invalid-custom-fields")
34
34
  }), n = !1);
35
35
  }
36
36
  }), n;
37
37
  }, b = async (e, s, t) => {
38
- const n = t ? await v(e) : !0;
38
+ const n = t ? await C(e) : !0;
39
39
  return S(e, s) && n;
40
40
  }, E = (e) => e.length > 0 ? !0 : (c({
41
41
  type: l.Warning,
42
- message: a("newsletter.html-content-is-empty")
42
+ message: o("newsletter.html-content-is-empty")
43
43
  }), !1), A = (e) => {
44
44
  const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
45
45
  return s > t && c({
46
46
  type: l.Warning,
47
- message: a("custom-fields.missing-closing-braces")
47
+ message: o("custom-fields.missing-closing-braces")
48
48
  }), s < t && c({
49
49
  type: l.Warning,
50
- message: a("custom-fields.missing-opening-braces")
50
+ message: o("custom-fields.missing-opening-braces")
51
51
  }), s === t;
52
52
  }, x = (e) => {
53
53
  const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
54
54
  return s || c({
55
55
  type: l.Warning,
56
- message: a("custom-fields.invalid-custom-fields")
56
+ message: o("custom-fields.invalid-custom-fields")
57
57
  }), s;
58
- }, k = (e, s) => {
58
+ }, T = (e, s) => {
59
59
  const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
60
60
  if (t && !u) {
61
- const n = new Set(s.map((o) => o.toLowerCase())), r = [];
62
- if (t.forEach((o) => {
63
- const i = o.slice(2, -2).trim().toLowerCase();
64
- (!n.has(i) || i === "") && r.push(i);
65
- }), r.length > 0) {
66
- const o = `
61
+ const n = new Set(s.map((i) => i.toLowerCase())), a = [];
62
+ if (t.forEach((i) => {
63
+ const r = i.slice(2, -2).trim().toLowerCase();
64
+ (!n.has(r) || r === "") && a.push(r);
65
+ }), a.length > 0) {
66
+ const i = `
67
67
  <ul>
68
- ${r.map((i) => `<li>${i}</li>`).join("")}
68
+ ${a.map((r) => `<li>${r}</li>`).join("")}
69
69
  </ul>
70
70
  `;
71
71
  return c({
72
72
  type: l.Alert,
73
- message: a("custom-fields.invalid-custom-fields") + o
73
+ message: o("custom-fields.invalid-custom-fields") + i
74
74
  }), !1;
75
75
  }
76
76
  }
77
77
  return !0;
78
- }, T = (e) => {
78
+ }, k = (e) => {
79
79
  const s = e.match(/{%(.*?)%}/g), t = [];
80
80
  let n = !0;
81
- if (s && s.forEach((r) => {
82
- const o = r.match(D), i = r.match(P), B = (o == null ? void 0 : o.join("")) || "";
83
- (!o || r !== B) && !i && (c({
81
+ if (s && s.forEach((a) => {
82
+ const i = a.match(B), r = a.match(_), O = (i == null ? void 0 : i.join("")) || "";
83
+ (!i || a !== O) && !r && (c({
84
84
  type: l.Alert,
85
- message: a("newsletter.display-conditions-invalid-syntax")
86
- }), n = !1), o && o.forEach((f) => {
85
+ message: o("newsletter.display-conditions-invalid-syntax")
86
+ }), n = !1), i && i.forEach((f) => {
87
87
  f.trim() === "=" && (c({
88
88
  type: l.Alert,
89
- message: a("custom-conditions.wrong-equality-operators")
89
+ message: o("custom-conditions.wrong-equality-operators")
90
90
  }), n = !1);
91
91
  const g = f.match(/^[a-zA-Z]*$/g);
92
92
  g && g.forEach((p) => {
@@ -94,10 +94,10 @@ const se = () => {
94
94
  });
95
95
  });
96
96
  }), t.length) {
97
- const r = t.filter((i) => i === "if"), o = t.filter((i) => i === "endif");
98
- r.length !== o.length && (c({
97
+ const a = t.filter((r) => r === "if"), i = t.filter((r) => r === "endif");
98
+ a.length !== i.length && (c({
99
99
  type: l.Alert,
100
- message: a("custom-conditions.missing-if-endif-tag")
100
+ message: o("custom-conditions.missing-if-endif-tag")
101
101
  }), n = !1);
102
102
  }
103
103
  return n;
@@ -105,44 +105,35 @@ const se = () => {
105
105
  const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
106
106
  return n || c({
107
107
  type: l.Warning,
108
- message: a("custom-conditions.no-space-after-braces")
108
+ message: o("custom-conditions.no-space-after-braces")
109
109
  }), n;
110
110
  }, I = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (c({
111
111
  type: l.Warning,
112
- message: a("custom-conditions.no-braces-inside-if-tag")
112
+ message: o("custom-conditions.no-braces-inside-if-tag")
113
113
  }), !1) : !0, W = () => m.recommendationConfigs && Object.values(m.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (c({
114
114
  type: l.Alert,
115
- message: a("newsletter.fill-all-necessary-fields")
115
+ message: o("newsletter.fill-all-necessary-fields")
116
116
  }), !1) : !0, L = (e) => {
117
117
  const s = /src="[^"]*\.(svg|pst)"/gm;
118
118
  return e.match(s) === null ? !0 : (c({
119
119
  type: l.Alert,
120
- message: a("newsletter.invalid-image-type")
120
+ message: o("newsletter.invalid-image-type")
121
121
  }), !1);
122
122
  }, N = (e) => {
123
123
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
124
- return Array.from(n).find((o) => {
125
- var i;
126
- return !((i = o.id) != null && i.trim());
124
+ return Array.from(n).find((i) => {
125
+ var r;
126
+ return !((r = i.id) != null && r.trim());
127
127
  }) ? (c({
128
128
  type: l.Alert,
129
- message: a("unsubscribe-templates.select-checkbox-groups")
130
- }), !1) : !0;
131
- }, O = (e) => {
132
- const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
133
- return Array.from(n).find((o) => {
134
- var i;
135
- return !((i = o.id) != null && i.trim());
136
- }) ? (c({
137
- type: l.Alert,
138
- message: a("unsubscribe-templates.select-radio-button-groups")
129
+ message: o("unsubscribe-templates.select-checkbox-groups")
139
130
  }), !1) : !0;
140
131
  };
141
132
  return { validateHtml: async (e, s, t = !1) => {
142
- const n = s.map((o) => o.value);
143
- return await b(e, n, t) && E(e) && A(e) && x(e) && k(e, n) && T(e) && F(e) && I(e) && W() && L(e) && N(e) && O(e);
133
+ const n = s.map((i) => i.value);
134
+ return await b(e, n, t) && E(e) && A(e) && x(e) && T(e, n) && k(e) && F(e) && I(e) && W() && L(e) && N(e);
144
135
  } };
145
136
  };
146
137
  export {
147
- se as useHtmlValidator
138
+ te as useHtmlValidator
148
139
  };
@@ -4,14 +4,14 @@ import { useStripoEventHandler as E } from "./useStripoEventHandler.js";
4
4
  import { useToaster as C } from "./useToaster.js";
5
5
  import { displayConditions as y } from "../enums/displayConditions.js";
6
6
  import h from "../extensions/Blocks/Checkbox/extension.js";
7
- import w from "../extensions/Blocks/RadioButton/extension.js";
7
+ import w from "../extensions/Blocks/Unsubscribe/extension.js";
8
8
  import b from "../extensions/DynamicContent/extension.js";
9
- import { useStripoApi as k } from "../services/stripoApi.js";
10
- import B from "../static/styles/customEditorStyle.css.js";
9
+ import { useStripoApi as _ } from "../services/stripoApi.js";
10
+ import k from "../static/styles/customEditorStyle.css.js";
11
11
  import { useEditorStore as V } from "../stores/editor.js";
12
- import { dynamicContentToMergeTags as _ } from "../utils/genericUtil.js";
12
+ import { dynamicContentToMergeTags as B } from "../utils/genericUtil.js";
13
13
  const q = (s) => {
14
- const { handleError: d } = C(), { getToken: c, getCustomFonts: u } = k(), { handleEvent: l } = E(), m = (r, i = []) => {
14
+ const { handleError: d } = C(), { getToken: c, getCustomFonts: u } = _(), { handleEvent: l } = E(), m = (r, i = []) => {
15
15
  const o = V(), { html: e, css: a, forceRecreate: g } = r;
16
16
  window.UIEditor.initEditor(
17
17
  document.querySelector("#guido-editor"),
@@ -29,7 +29,7 @@ const q = (s) => {
29
29
  customAppearanceMergetags: !0,
30
30
  customAppearanceMergetagsBorderColor: "#f1f3fe",
31
31
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
32
- customViewStyles: B,
32
+ customViewStyles: k,
33
33
  conditionsEnabled: !0,
34
34
  customConditionsEnabled: !0,
35
35
  conditionCategories: y,
@@ -43,7 +43,7 @@ const q = (s) => {
43
43
  },
44
44
  mergeTags: [
45
45
  {
46
- entries: _(s.preselectedDynamicContentList)
46
+ entries: B(s.preselectedDynamicContentList)
47
47
  }
48
48
  ],
49
49
  async onTokenRefreshRequest(t) {
@@ -77,12 +77,12 @@ const q = (s) => {
77
77
  o.hasChanges = !0;
78
78
  },
79
79
  onEvent: l,
80
- ignoreClickOutsideSelectors: ["#guido-dynamic-content-modal", ".in-on-board-wrapper"],
81
- extensions: [
82
- b,
83
- h,
84
- w
85
- ]
80
+ ignoreClickOutsideSelectors: [
81
+ "#guido-dynamic-content-modal",
82
+ ".in-on-board-wrapper",
83
+ ".in-drawer__container"
84
+ ],
85
+ extensions: [b, h, w]
86
86
  }
87
87
  );
88
88
  }, p = (r) => new Promise((i, o) => {
@@ -1,23 +1,23 @@
1
1
  import { usePartner as m } from "../../composables/usePartner.js";
2
- import { LINK_REGEXES as c, LINK_TYPES as p, URLS as E } from "../../enums/unsubscribe.js";
2
+ import { LINK_REGEXES as l, LINK_TYPES as p, URLS as d } from "../../enums/unsubscribe.js";
3
3
  import { useUnsubscribeStore as b } from "../../stores/unsubscribe.js";
4
4
  const S = [
5
5
  {
6
6
  id: "add-unsubscribe-link-values",
7
7
  description: "Adding unsubscribe link values",
8
8
  type: "custom",
9
- processor: (n) => {
9
+ processor: (t) => {
10
10
  var a, u;
11
- const { getPartnerName: i } = m(), t = b();
12
- let e = n;
13
- const o = `/${i()}/email/0?user={{iid}}`, r = (a = t.selectedUnsubscribePages) == null ? void 0 : a.find((l) => l.type === p.UNSUBSCRIBE_LINK_TYPE), s = (u = t.selectedUnsubscribePages) == null ? void 0 : u.find((l) => l.type === p.PREFERENCES_LINK_TYPE);
11
+ const { getPartnerName: n } = m(), i = b();
12
+ let e = t;
13
+ const c = `/${n()}/email/0?user={{iid}}`, r = (a = i.templates) == null ? void 0 : a.find((o) => i.selectedUnsubscribePages.includes(o.id) && o.type === p.UNSUBSCRIBE_LINK_TYPE), s = (u = i.templates) == null ? void 0 : u.find((o) => i.selectedUnsubscribePages.includes(o.id) && o.type === p.PREFERENCES_LINK_TYPE);
14
14
  return r && (e = e.replace(
15
- c.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
16
- E.UNSUBSCRIBE_URL + o
15
+ l.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
16
+ d.UNSUBSCRIBE_URL + c
17
17
  )), s && (e = e.replace(
18
- c.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
19
- E.PREFERENCES_URL + o
20
- )), e.replace(c.UNSUBSCRIBE_LINK_REGEX, "");
18
+ l.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
19
+ d.PREFERENCES_URL + c
20
+ )), e.replace(l.UNSUBSCRIBE_LINK_REGEX, "");
21
21
  },
22
22
  priority: 60
23
23
  },
@@ -25,7 +25,7 @@ const S = [
25
25
  id: "remove-data-ogsb-button-styles",
26
26
  description: "Removing styles like [data-ogsb] .es-button.es-button-123 { background: red; }",
27
27
  type: "regex",
28
- pattern: c.DATA_OGSB_BUTTON_CSS_REGEX,
28
+ pattern: l.DATA_OGSB_BUTTON_CSS_REGEX,
29
29
  replacement: "",
30
30
  flags: "g",
31
31
  priority: 61
@@ -34,27 +34,27 @@ const S = [
34
34
  id: "format-comment-braces",
35
35
  description: "Adding spaces around comment braces for proper formatting",
36
36
  type: "custom",
37
- processor: (n) => n.replace(/{#/g, "{ #").replace(/#}/g, "# }"),
37
+ processor: (t) => t.replace(/{#/g, "{ #").replace(/#}/g, "# }"),
38
38
  priority: 62
39
39
  },
40
40
  {
41
41
  id: "add-universal-link-flags",
42
42
  description: "Adding universal link flags",
43
43
  type: "custom",
44
- processor: (n) => {
45
- let i = n;
46
- const t = i.match(/<a[^>]+>(.*?)<\/a>/gm);
47
- return t && t.forEach((e) => {
44
+ processor: (t) => {
45
+ let n = t;
46
+ const i = n.match(/<a[^>]+>(.*?)<\/a>/gm);
47
+ return i && i.forEach((e) => {
48
48
  if (e.includes("insEmail=1"))
49
49
  return;
50
50
  if (e.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
51
- const o = e.replace(/href=(["'`”])(.*?)\1/gm, (r) => {
51
+ const c = e.replace(/href=(["'`”])(.*?)\1/gm, (r) => {
52
52
  const s = r.slice(6, r.length - 1).trim();
53
53
  return r.includes("?") || r.includes("#") ? s.slice(-1) === "&" ? r.replace(s, `${s}insEmail=1`) : r.replace(s, `${s}&insEmail=1`) : r.replace(s, `${s}?insEmail=1`);
54
54
  });
55
- i = i.replace(e, o);
55
+ n = n.replace(e, c);
56
56
  }
57
- }), i;
57
+ }), n;
58
58
  },
59
59
  priority: 63
60
60
  }
@@ -1 +1 @@
1
- export declare const migrate: (html: string) => string;
1
+ export declare const migrate: (html: string) => Promise<string>;
@@ -1,9 +1,9 @@
1
- import { migrateCheckbox as o } from "./checkboxMigrator.js";
2
- import { migrateRadioButton as e } from "./radioButtonMigrator.js";
3
- const a = (r) => {
4
- let t = r;
5
- return t = o(r), t = e(r), t;
1
+ import { migrateCheckbox as e } from "./checkboxMigrator.js";
2
+ import { migrateUnsubscribe as m } from "./unsubscribeMigrator.js";
3
+ const o = async (t) => {
4
+ let r = t;
5
+ return r = e(r), r = await m(r), r;
6
6
  };
7
7
  export {
8
- a as migrate
8
+ o as migrate
9
9
  };
@@ -0,0 +1 @@
1
+ export declare function migrateUnsubscribe(html: string): Promise<string>;
@@ -0,0 +1,112 @@
1
+ var A = Object.defineProperty;
2
+ var T = (l, e, t) => e in l ? A(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
+ var d = (l, e, t) => T(l, typeof e != "symbol" ? e + "" : e, t);
4
+ import { MERGE_TAGS as p, PAGE_TYPES as g } from "../../enums/unsubscribe.js";
5
+ import { DATA_ATTRIBUTES as y } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
6
+ import { useUnsubscribeStore as x } from "../../stores/unsubscribe.js";
7
+ class h {
8
+ constructor() {
9
+ d(this, "parser");
10
+ this.parser = new DOMParser();
11
+ }
12
+ async migrate(e) {
13
+ try {
14
+ const t = this.parser.parseFromString(e, "text/html"), s = t.querySelectorAll("td.unsubscribe-block");
15
+ if (!s.length)
16
+ return e;
17
+ const u = x();
18
+ return await u.fetchTemplates(), s.forEach((i) => {
19
+ const a = i.getAttribute("id"), n = this.extractUnsubscribeContent(i), r = this.getCollectionTypeFromMergeTag(n.linkHref), o = u.getSelectedUnsubscribePagesByCollection(r);
20
+ console.debug("[UnsubscribeMigrator]", {
21
+ mergeTag: n.linkHref,
22
+ collectionType: r,
23
+ pageIds: o
24
+ });
25
+ const c = this.buildUnsubscribeBlock(n, r, o), b = this.parser.parseFromString(
26
+ `<table id="tempDoc"><tbody><tr>${c}</tr></tbody></table>`,
27
+ "text/html"
28
+ ).querySelector(".unsubscribe-block-v2");
29
+ b && i.parentNode && (b.setAttribute("id", a || ""), i.parentNode.replaceChild(b, i));
30
+ }), t.documentElement.outerHTML;
31
+ } catch (t) {
32
+ return console.error("UnsubscribeMigrator failed:", t), e;
33
+ }
34
+ }
35
+ extractUnsubscribeContent(e) {
36
+ var m;
37
+ const t = e.querySelector("p");
38
+ if (!t)
39
+ return {
40
+ textBefore: "You can ",
41
+ linkText: "unsubscribe",
42
+ linkHref: "{{ins-unsubscribe-link}}",
43
+ linkStyle: "",
44
+ textAfter: " from our emails, if you need to.",
45
+ isBold: !1,
46
+ isItalic: !1,
47
+ align: "center",
48
+ paragraphStyle: ""
49
+ };
50
+ const s = e.getAttribute("align") || t.getAttribute("align") || "center", u = t.getAttribute("style") || "", i = t.querySelector("a.unsubscribe-link") || t.querySelector('a[href*="unsubscribe"]');
51
+ if (!i)
52
+ return {
53
+ textBefore: "You can ",
54
+ linkText: "unsubscribe",
55
+ linkHref: "{{ins-unsubscribe-link}}",
56
+ linkStyle: "",
57
+ textAfter: " from our emails, if you need to.",
58
+ isBold: !1,
59
+ isItalic: !1,
60
+ align: s,
61
+ paragraphStyle: u
62
+ };
63
+ const a = ((m = i.textContent) == null ? void 0 : m.trim()) || "unsubscribe", n = i.getAttribute("href") || "{{ins-unsubscribe-link}}", r = i.getAttribute("style") || "", o = t.textContent || "", c = o.indexOf(a), f = c >= 0 ? o.substring(0, c).trim() : "You can ", b = c >= 0 ? o.substring(c + a.length).trim() : " from our emails, if you need to.", k = !!t.querySelector("b, strong"), S = !!t.querySelector("i, em");
64
+ return {
65
+ textBefore: f,
66
+ linkText: a,
67
+ linkHref: this.normalizeUnsubscribeHref(n),
68
+ linkStyle: r,
69
+ textAfter: b,
70
+ isBold: k,
71
+ isItalic: S,
72
+ align: s,
73
+ paragraphStyle: u
74
+ };
75
+ }
76
+ buildUnsubscribeBlock(e, t, s) {
77
+ const u = e.linkStyle ? ` style="${e.linkStyle}"` : "", a = `<a ${`href="${e.linkHref}" class="unsubscribe-link" target="_blank" data-unsubscribe-link="true"`}${u}>${e.linkText}</a>`, n = [];
78
+ e.textBefore && n.push(e.textBefore), n.push(a), e.textAfter && n.push(e.textAfter);
79
+ let r = n.join(" ");
80
+ e.isBold && e.isItalic ? r = `<strong path="1,0"><em path="1,0,0">${r}</em></strong>` : e.isBold ? r = `<strong path="1,0">${r}</strong>` : e.isItalic && (r = `<em path="1,0">${r}</em>`);
81
+ const o = e.align ? ` align="${e.align}"` : "", c = e.paragraphStyle ? ` style="${e.paragraphStyle}"` : "", f = s.length > 0 ? ` ${y.PAGE_LIST}="${s.join(",")}"` : "", b = ` ${y.PAGE_TYPE}="${t}"`;
82
+ return `
83
+ <td
84
+ data-migration="true"
85
+ esd-extension-block-id="unsubscribe-block"
86
+ class="esd-block-text unsubscribe-block-v2 esd-block-unsubscribe esd-unsubscribe-block esd-extension-block"
87
+ ${o}${b}${f}
88
+ >
89
+ <p path="1"${c}>
90
+ ${r}
91
+ </p>
92
+ </td>
93
+ `;
94
+ }
95
+ getCollectionTypeFromMergeTag(e) {
96
+ return e === p[g.SUBSCRIPTION_PREFERENCE_CENTER] ? g.SUBSCRIPTION_PREFERENCE_CENTER : e === p[g.GLOBAL_UNSUBSCRIBE] ? g.GLOBAL_UNSUBSCRIBE : g.GLOBAL_UNSUBSCRIBE;
97
+ }
98
+ normalizeUnsubscribeHref(e) {
99
+ if (Object.values(p).includes(e))
100
+ return e;
101
+ const s = e.match(/{{ins-(?:global-)?(?:preferences-)?unsubscribe-link}}/);
102
+ return s ? s[0] : e.includes("unsubscribe") || e.includes("unsub") ? (console.warn(
103
+ `[UnsubscribeMigrator] Unrecognized unsubscribe href format: "${e}". Defaulting to {{ins-unsubscribe-link}}`
104
+ ), "{{ins-unsubscribe-link}}") : e;
105
+ }
106
+ }
107
+ async function $(l) {
108
+ return new h().migrate(l);
109
+ }
110
+ export {
111
+ $ as migrateUnsubscribe
112
+ };
@@ -4,6 +4,9 @@ const a = {
4
4
  senderName: "",
5
5
  subject: ""
6
6
  },
7
+ extensions: {
8
+ unsubscribe: !0
9
+ },
7
10
  features: {
8
11
  dynamicContent: !0,
9
12
  saveAsTemplate: !0,
@@ -13,7 +16,7 @@ const a = {
13
16
  }, t = {
14
17
  promotional: 1,
15
18
  transactional: 2
16
- }, e = "email", o = "Guido User", n = t.promotional, i = 2, s = {
19
+ }, e = "email", o = "Guido User", n = t.promotional, s = 2, i = {
17
20
  email: 60,
18
21
  architect: 49
19
22
  }, u = [
@@ -53,8 +56,8 @@ export {
53
56
  n as DefaultMessageType,
54
57
  e as DefaultProductType,
55
58
  o as DefaultUsername,
56
- i as EditorType,
57
- s as ProductIds,
59
+ s as EditorType,
60
+ i as ProductIds,
58
61
  u as TEST_PARTNER_LIST,
59
62
  t as TemplateTypes
60
63
  };
@@ -13,3 +13,22 @@ export declare const URLS: {
13
13
  PREFERENCES_URL: string;
14
14
  };
15
15
  export declare const INSIDER_ID = "iid";
16
+ export declare const ACADEMY_LINK = "https://academy.useinsider.com/docs/global-unsubscribe-preference-center";
17
+ export declare const UNSUBSCRIBE_PAGES_LINK = "/email/unsubscribe-pages";
18
+ export declare const PAGE_TYPES: {
19
+ GLOBAL_UNSUBSCRIBE: number;
20
+ GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE: number;
21
+ SUBSCRIPTION_PREFERENCE_CENTER: number;
22
+ SUBSCRIPTION_PREFERENCE_CONFIRMATION: number;
23
+ RESUBSCRIBE: number;
24
+ };
25
+ export declare const TYPE_COLLECTIONS: {
26
+ [x: number]: number[];
27
+ };
28
+ export declare const TYPE_TRANSLATIONS: {
29
+ [x: number]: string;
30
+ };
31
+ export declare const MERGE_TAGS: {
32
+ [x: number]: string;
33
+ default: string;
34
+ };
@@ -1,17 +1,50 @@
1
- const E = {
1
+ import { useTranslations as e } from "../composables/useTranslations.js";
2
+ const s = e(), n = {
2
3
  UNSUBSCRIBE_LINK_TYPE: 1,
3
4
  PREFERENCES_LINK_TYPE: 3
4
- }, s = {
5
+ }, S = {
5
6
  UNSUBSCRIBE_LINK_REGEX: /{{ins-unsubscribe-link}}/g,
6
7
  DATA_OGSB_BUTTON_CSS_REGEX: "\\[data-ogsb\\]\\s*\\.es-button\\.es-button-[0-9]+\\s*\\{(?:[^\\}]*)\\}",
7
8
  GLOBAL_UNSUBSCRIBE_LINK_REGEX: /{{ins-global-unsubscribe-link}}/g,
8
9
  PREFERENCES_UNSUBSCRIBE_LINK_REGEX: /{{ins-preferences-unsubscribe-link}}/g
9
- }, _ = {
10
+ }, N = {
10
11
  UNSUBSCRIBE_URL: "https://mail.useinsider.com/user/v1/unsub",
11
12
  PREFERENCES_URL: "https://mail.useinsider.com/user/v1/prefs"
13
+ }, _ = "https://academy.useinsider.com/docs/global-unsubscribe-preference-center", I = "/email/unsubscribe-pages", E = {
14
+ GLOBAL_UNSUBSCRIBE: 1,
15
+ GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE: 2,
16
+ SUBSCRIPTION_PREFERENCE_CENTER: 3,
17
+ SUBSCRIPTION_PREFERENCE_CONFIRMATION: 4,
18
+ RESUBSCRIBE: 5
19
+ }, r = {
20
+ [E.GLOBAL_UNSUBSCRIBE]: [
21
+ E.GLOBAL_UNSUBSCRIBE,
22
+ E.GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE,
23
+ E.RESUBSCRIBE
24
+ ],
25
+ [E.SUBSCRIPTION_PREFERENCE_CENTER]: [
26
+ E.SUBSCRIPTION_PREFERENCE_CENTER,
27
+ E.SUBSCRIPTION_PREFERENCE_CONFIRMATION
28
+ ]
29
+ }, i = {
30
+ [E.GLOBAL_UNSUBSCRIBE]: s("unsubscription-preference.type-global-unsubscribe"),
31
+ [E.GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE]: s("unsubscription-preference.type-global-unsubscription-confirmation"),
32
+ [E.RESUBSCRIBE]: s("unsubscription-preference.type-resubscribe"),
33
+ [E.SUBSCRIPTION_PREFERENCE_CENTER]: s("unsubscription-preference.type-subscription-preferences-center"),
34
+ [E.SUBSCRIPTION_PREFERENCE_CONFIRMATION]: s("unsubscription-preference.type-subscription-preferences-confirmation")
35
+ }, B = {
36
+ default: "{{ins-unsubscribe-link}}",
37
+ [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
38
+ [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
12
39
  };
13
40
  export {
14
- s as LINK_REGEXES,
15
- E as LINK_TYPES,
16
- _ as URLS
41
+ _ as ACADEMY_LINK,
42
+ S as LINK_REGEXES,
43
+ n as LINK_TYPES,
44
+ B as MERGE_TAGS,
45
+ E as PAGE_TYPES,
46
+ r as TYPE_COLLECTIONS,
47
+ i as TYPE_TRANSLATIONS,
48
+ I as UNSUBSCRIBE_PAGES_LINK,
49
+ N as URLS
17
50
  };
@@ -0,0 +1,30 @@
1
+ import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
2
+ import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
3
+ export declare const UNSUBSCRIBE_BLOCK_ID = "unsubscribe-block";
4
+ export declare class UnsubscribeBlock extends Block {
5
+ private selectEventListener;
6
+ private cancelEventListener;
7
+ private currentNode?;
8
+ getId(): string;
9
+ getIcon(): string;
10
+ getBlockCompositionType(): BlockCompositionType;
11
+ getName(): string;
12
+ getDescription(): string;
13
+ getTemplate(): string;
14
+ onCreated(node: ImmutableHtmlNode): void;
15
+ onSelect(node: ImmutableHtmlNode): undefined;
16
+ onDelete(node: ImmutableHtmlNode): undefined;
17
+ private _setupSelectEventListener;
18
+ private _removeSelectEventListener;
19
+ private _setupCancelEventListener;
20
+ private _removeCancelEventListener;
21
+ private _handleCancel;
22
+ private _removeEventListeners;
23
+ private _updateBlock;
24
+ private _getMergeTag;
25
+ private _openDrawer;
26
+ private _checkExistingBlocks;
27
+ private _loadBlockState;
28
+ private _resetStoreState;
29
+ private _removeBlockTemplatesFromStore;
30
+ }