@useinsider/guido 1.0.3-beta.a6893cb → 1.0.3-beta.a6a2da8
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/@types/generic.d.ts +9 -0
- package/dist/components/Guido.vue.d.ts +2 -2
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +74 -69
- package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue.d.ts +2 -0
- package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue.js +18 -0
- package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue2.js +16 -0
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.d.ts +2 -0
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +24 -0
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +64 -0
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.d.ts +2 -0
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.js +18 -0
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue2.js +107 -0
- package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.d.ts +2 -0
- package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.js +18 -0
- package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue2.js +12 -0
- package/dist/components/wrappers/WpDrawer.vue.d.ts +6 -4
- package/dist/components/wrappers/WpDrawer.vue.js +6 -4
- package/dist/composables/useStripo.js +40 -32
- package/dist/config/compiler/unsubscribeCompilerRules.js +42 -29
- package/dist/config/migrator/couponBlockMigrator.d.ts +1 -0
- package/dist/config/migrator/couponBlockMigrator.js +67 -0
- package/dist/config/migrator/index.d.ts +1 -1
- package/dist/config/migrator/index.js +7 -5
- package/dist/config/migrator/unsubscribeMigrator.d.ts +1 -0
- package/dist/config/migrator/unsubscribeMigrator.js +124 -0
- package/dist/enums/defaults.js +6 -3
- package/dist/enums/unsubscribe.d.ts +19 -0
- package/dist/enums/unsubscribe.js +39 -6
- package/dist/extensions/Blocks/Checkbox/block.d.ts +1 -0
- package/dist/extensions/Blocks/Checkbox/block.js +15 -24
- package/dist/extensions/Blocks/Checkbox/control.js +24 -38
- package/dist/extensions/Blocks/Checkbox/extension.js +5 -16
- package/dist/extensions/Blocks/Checkbox/iconsRegistry.d.ts +4 -0
- package/dist/extensions/Blocks/Checkbox/iconsRegistry.js +18 -0
- package/dist/extensions/Blocks/Checkbox/settingsPanel.js +12 -25
- package/dist/extensions/Blocks/Checkbox/template.js +5 -16
- package/dist/extensions/Blocks/CouponBlock/block.d.ts +12 -0
- package/dist/extensions/Blocks/CouponBlock/block.js +33 -0
- package/dist/extensions/Blocks/CouponBlock/extension.d.ts +2 -0
- package/dist/extensions/Blocks/CouponBlock/extension.js +8 -0
- package/dist/extensions/Blocks/CouponBlock/iconsRegistry.d.ts +4 -0
- package/dist/extensions/Blocks/CouponBlock/iconsRegistry.js +33 -0
- package/dist/extensions/Blocks/CouponBlock/settingsPanel.d.ts +4 -0
- package/dist/extensions/Blocks/CouponBlock/settingsPanel.js +24 -0
- package/dist/extensions/Blocks/CouponBlock/template.d.ts +3 -0
- package/dist/extensions/Blocks/CouponBlock/template.js +18 -0
- package/dist/extensions/Blocks/RadioButton/block.d.ts +1 -0
- package/dist/extensions/Blocks/RadioButton/block.js +13 -22
- package/dist/extensions/Blocks/RadioButton/control.js +32 -46
- package/dist/extensions/Blocks/RadioButton/extension.js +4 -15
- package/dist/extensions/Blocks/RadioButton/iconsRegistry.d.ts +4 -0
- package/dist/extensions/Blocks/RadioButton/iconsRegistry.js +14 -0
- package/dist/extensions/Blocks/RadioButton/settingsPanel.js +13 -26
- package/dist/extensions/Blocks/RadioButton/template.js +7 -18
- package/dist/extensions/Blocks/Unsubscribe/block.d.ts +32 -0
- package/dist/extensions/Blocks/Unsubscribe/block.js +131 -0
- package/dist/extensions/Blocks/Unsubscribe/control.d.ts +29 -0
- package/dist/extensions/Blocks/Unsubscribe/control.js +167 -0
- package/dist/extensions/Blocks/Unsubscribe/elements/preview.d.ts +11 -0
- package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +42 -0
- package/dist/extensions/Blocks/Unsubscribe/extension.d.ts +2 -0
- package/dist/extensions/Blocks/Unsubscribe/extension.js +21 -0
- package/dist/extensions/Blocks/Unsubscribe/iconsRegistry.d.ts +4 -0
- package/dist/extensions/Blocks/Unsubscribe/iconsRegistry.js +21 -0
- package/dist/extensions/Blocks/Unsubscribe/settingsPanel.d.ts +4 -0
- package/dist/extensions/Blocks/Unsubscribe/settingsPanel.js +35 -0
- package/dist/extensions/Blocks/Unsubscribe/styles.css.js +42 -0
- package/dist/extensions/Blocks/Unsubscribe/tagRegistry.d.ts +4 -0
- package/dist/extensions/Blocks/Unsubscribe/tagRegistry.js +10 -0
- package/dist/extensions/Blocks/Unsubscribe/template.d.ts +12 -0
- package/dist/extensions/Blocks/Unsubscribe/template.js +22 -0
- package/dist/extensions/Blocks/Unsubscribe/utils/constants.d.ts +9 -0
- package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +11 -0
- package/dist/extensions/Blocks/Unsubscribe/utils/utils.d.ts +7 -0
- package/dist/extensions/Blocks/Unsubscribe/utils/utils.js +6 -0
- package/dist/extensions/Blocks/_Boilerplate/block.d.ts +1 -0
- package/dist/extensions/Blocks/_Boilerplate/iconsRegistry.d.ts +4 -0
- package/dist/extensions/DynamicContent/dynamic-content.js +31 -45
- package/dist/extensions/DynamicContent/extension.js +6 -18
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +648 -0
- package/dist/services/unsubscribeApi.d.ts +4 -0
- package/dist/services/unsubscribeApi.js +16 -0
- package/dist/stores/config.d.ts +96 -0
- package/dist/stores/config.js +17 -0
- package/dist/stores/unsubscribe.d.ts +253 -5
- package/dist/stores/unsubscribe.js +126 -6
- package/dist/utils/templatePreparation.js +17 -16
- package/package.json +2 -2
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/Extension.js +0 -75
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/ExtensionBuilder.js +0 -77
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/blocks/Block.js +0 -123
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/AiAssistantValueType.js +0 -7
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockCompositionType.js +0 -7
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockName.js +0 -12
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockType.js +0 -7
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BuiltInControlTypes.js +0 -119
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/ContextActionType.js +0 -7
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/EditorStatePropertyType.js +0 -7
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/PanelPosition.js +0 -7
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/Popover.js +0 -12
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/PreviewDeviceMode.js +0 -7
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/SettingsTab.js +0 -7
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementType.js +0 -7
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementsAttributes.js +0 -24
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/Control.js +0 -24
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/SettingsPanelRegistry.js +0 -11
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/SettingsPanelTab.js +0 -33
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/modifications/ModificationDescription.js +0 -22
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/ui-elements/UIElement.js +0 -40
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/ui-elements/UIElementTagRegistry.js +0 -5
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { useActionsApi as f } from "./useActionsApi.js";
|
|
2
|
-
import { useCustomInterfaceAppearance as
|
|
3
|
-
import { useStripoEventHandler as
|
|
2
|
+
import { useCustomInterfaceAppearance as E } from "./useCustomInterfaceAppearance.js";
|
|
3
|
+
import { useStripoEventHandler as S } 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/
|
|
8
|
-
import b from "../extensions/
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
import w from "../extensions/Blocks/CouponBlock/extension.js";
|
|
8
|
+
import b from "../extensions/Blocks/RadioButton/extension.js";
|
|
9
|
+
import _ from "../extensions/Blocks/Unsubscribe/extension.js";
|
|
10
|
+
import k from "../extensions/DynamicContent/extension.js";
|
|
11
|
+
import { useStripoApi as B } from "../services/stripoApi.js";
|
|
12
|
+
import V from "../static/styles/customEditorStyle.css.js";
|
|
13
|
+
import { useEditorStore as F } from "../stores/editor.js";
|
|
14
|
+
import { dynamicContentToMergeTags as x } from "../utils/genericUtil.js";
|
|
15
|
+
const N = (s) => {
|
|
16
|
+
const { handleError: d } = C(), { getToken: c, getCustomFonts: u } = B(), { handleEvent: l } = S(), m = (r, i = []) => {
|
|
17
|
+
const t = F(), { html: e, css: a, forceRecreate: g } = r;
|
|
16
18
|
window.UIEditor.initEditor(
|
|
17
19
|
document.querySelector("#guido-editor"),
|
|
18
20
|
{
|
|
@@ -29,7 +31,7 @@ const q = (s) => {
|
|
|
29
31
|
customAppearanceMergetags: !0,
|
|
30
32
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
31
33
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
32
|
-
customViewStyles:
|
|
34
|
+
customViewStyles: V,
|
|
33
35
|
conditionsEnabled: !0,
|
|
34
36
|
customConditionsEnabled: !0,
|
|
35
37
|
conditionCategories: y,
|
|
@@ -43,49 +45,55 @@ const q = (s) => {
|
|
|
43
45
|
},
|
|
44
46
|
mergeTags: [
|
|
45
47
|
{
|
|
46
|
-
entries:
|
|
48
|
+
entries: x(s.preselectedDynamicContentList)
|
|
47
49
|
}
|
|
48
50
|
],
|
|
49
|
-
async onTokenRefreshRequest(
|
|
51
|
+
async onTokenRefreshRequest(o) {
|
|
50
52
|
try {
|
|
51
53
|
const n = await c();
|
|
52
|
-
|
|
54
|
+
o(n);
|
|
53
55
|
} catch (n) {
|
|
54
56
|
d(n, "Failed to refresh token");
|
|
55
57
|
}
|
|
56
58
|
},
|
|
57
59
|
onTemplateLoaded() {
|
|
58
60
|
try {
|
|
59
|
-
const { importCss:
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
const { importCss: o } = E(), { activateCustomViewStyles: n } = f();
|
|
62
|
+
o(), n(), s.onReady(), t.isStripoInitialized = !0, t.loadingStatus = !1, setTimeout(() => {
|
|
63
|
+
t.hasChanges = !1;
|
|
62
64
|
}, 1e3);
|
|
63
|
-
} catch (
|
|
64
|
-
d(
|
|
65
|
+
} catch (o) {
|
|
66
|
+
d(o, "Failed to load custom interface appearance");
|
|
65
67
|
}
|
|
66
68
|
},
|
|
67
|
-
onCodeEditorVisibilityChanged(
|
|
68
|
-
|
|
69
|
+
onCodeEditorVisibilityChanged(o) {
|
|
70
|
+
t.isCodeEditorOpen = o;
|
|
69
71
|
},
|
|
70
|
-
onEditorVisualModeChanged(
|
|
71
|
-
|
|
72
|
+
onEditorVisualModeChanged(o) {
|
|
73
|
+
t.editorVisualMode = o.toLowerCase();
|
|
72
74
|
},
|
|
73
|
-
onVersionHistoryVisibilityChanged(
|
|
74
|
-
|
|
75
|
+
onVersionHistoryVisibilityChanged(o) {
|
|
76
|
+
t.isVersionHistoryOpen = o;
|
|
75
77
|
},
|
|
76
78
|
onDataChanged() {
|
|
77
|
-
|
|
79
|
+
t.hasChanges = !0;
|
|
78
80
|
},
|
|
79
81
|
onEvent: l,
|
|
80
|
-
ignoreClickOutsideSelectors: [
|
|
82
|
+
ignoreClickOutsideSelectors: [
|
|
83
|
+
"#guido-dynamic-content-modal",
|
|
84
|
+
".in-on-board-wrapper",
|
|
85
|
+
".in-drawer__container"
|
|
86
|
+
],
|
|
81
87
|
extensions: [
|
|
82
|
-
|
|
88
|
+
k,
|
|
83
89
|
h,
|
|
90
|
+
b,
|
|
91
|
+
_,
|
|
84
92
|
w
|
|
85
93
|
]
|
|
86
94
|
}
|
|
87
95
|
);
|
|
88
|
-
}, p = (r) => new Promise((i,
|
|
96
|
+
}, p = (r) => new Promise((i, t) => {
|
|
89
97
|
if (document.getElementById("UiEditorScript")) {
|
|
90
98
|
r(), i();
|
|
91
99
|
return;
|
|
@@ -95,7 +103,7 @@ const q = (s) => {
|
|
|
95
103
|
r(), i();
|
|
96
104
|
}, e.onerror = () => {
|
|
97
105
|
const a = new Error("Failed to load Stripo UIEditor script");
|
|
98
|
-
|
|
106
|
+
t(a);
|
|
99
107
|
}, document.body.appendChild(e);
|
|
100
108
|
});
|
|
101
109
|
return { initPlugin: async (r) => {
|
|
@@ -106,5 +114,5 @@ const q = (s) => {
|
|
|
106
114
|
} };
|
|
107
115
|
};
|
|
108
116
|
export {
|
|
109
|
-
|
|
117
|
+
N as useStripo
|
|
110
118
|
};
|
|
@@ -1,23 +1,36 @@
|
|
|
1
|
-
import { usePartner as
|
|
2
|
-
import { LINK_REGEXES as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { usePartner as U } from "../../composables/usePartner.js";
|
|
2
|
+
import { LINK_REGEXES as l, LINK_TYPES as b, URLS as f } from "../../enums/unsubscribe.js";
|
|
3
|
+
import { parsePageList as B } from "../../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
4
|
+
import { useConfigStore as N } from "../../stores/config.js";
|
|
5
|
+
import { useUnsubscribeStore as I } from "../../stores/unsubscribe.js";
|
|
6
|
+
const T = [
|
|
5
7
|
{
|
|
6
8
|
id: "add-unsubscribe-link-values",
|
|
7
9
|
description: "Adding unsubscribe link values",
|
|
8
10
|
type: "custom",
|
|
9
|
-
processor: (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
processor: (t) => {
|
|
12
|
+
const { getPartnerName: i } = U(), a = N(), n = I(), u = a.getVariationId;
|
|
13
|
+
if (!u)
|
|
14
|
+
return t;
|
|
15
|
+
let o = t;
|
|
16
|
+
const e = `/${i()}/email/${u}?user={{iid}}`;
|
|
17
|
+
return new DOMParser().parseFromString(o, "text/html").querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-list]").forEach((p) => {
|
|
18
|
+
var g;
|
|
19
|
+
const d = p.getAttribute("data-unsubscribe-page-list");
|
|
20
|
+
if (!d)
|
|
21
|
+
return;
|
|
22
|
+
const S = B(d), m = ((g = n.templates) == null ? void 0 : g.filter(
|
|
23
|
+
(c) => S.includes(c.id)
|
|
24
|
+
)) ?? [], R = m.some((c) => c.type === b.UNSUBSCRIBE_LINK_TYPE), _ = m.some((c) => c.type === b.PREFERENCES_LINK_TYPE), E = p.outerHTML;
|
|
25
|
+
let s = E;
|
|
26
|
+
R && (s = s.replace(
|
|
27
|
+
l.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
|
|
28
|
+
f.UNSUBSCRIBE_URL + e
|
|
29
|
+
)), _ && (s = s.replace(
|
|
30
|
+
l.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
|
|
31
|
+
f.PREFERENCES_URL + e
|
|
32
|
+
)), s = s.replace(l.UNSUBSCRIBE_LINK_REGEX, ""), o = o.replace(E, s);
|
|
33
|
+
}), o;
|
|
21
34
|
},
|
|
22
35
|
priority: 60
|
|
23
36
|
},
|
|
@@ -25,7 +38,7 @@ const S = [
|
|
|
25
38
|
id: "remove-data-ogsb-button-styles",
|
|
26
39
|
description: "Removing styles like [data-ogsb] .es-button.es-button-123 { background: red; }",
|
|
27
40
|
type: "regex",
|
|
28
|
-
pattern:
|
|
41
|
+
pattern: l.DATA_OGSB_BUTTON_CSS_REGEX,
|
|
29
42
|
replacement: "",
|
|
30
43
|
flags: "g",
|
|
31
44
|
priority: 61
|
|
@@ -34,25 +47,25 @@ const S = [
|
|
|
34
47
|
id: "format-comment-braces",
|
|
35
48
|
description: "Adding spaces around comment braces for proper formatting",
|
|
36
49
|
type: "custom",
|
|
37
|
-
processor: (
|
|
50
|
+
processor: (t) => t.replace(/{#/g, "{ #").replace(/#}/g, "# }"),
|
|
38
51
|
priority: 62
|
|
39
52
|
},
|
|
40
53
|
{
|
|
41
54
|
id: "add-universal-link-flags",
|
|
42
55
|
description: "Adding universal link flags",
|
|
43
56
|
type: "custom",
|
|
44
|
-
processor: (
|
|
45
|
-
let i =
|
|
46
|
-
const
|
|
47
|
-
return
|
|
48
|
-
if (
|
|
57
|
+
processor: (t) => {
|
|
58
|
+
let i = t;
|
|
59
|
+
const a = i.match(/<a[^>]+>(.*?)<\/a>/gm);
|
|
60
|
+
return a && a.forEach((n) => {
|
|
61
|
+
if (n.includes("insEmail=1"))
|
|
49
62
|
return;
|
|
50
|
-
if (
|
|
51
|
-
const o =
|
|
52
|
-
const
|
|
53
|
-
return
|
|
63
|
+
if (n.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
|
|
64
|
+
const o = n.replace(/href=(["'`”])(.*?)\1/gm, (e) => {
|
|
65
|
+
const r = e.slice(6, e.length - 1).trim();
|
|
66
|
+
return e.includes("?") || e.includes("#") ? r.slice(-1) === "&" ? e.replace(r, `${r}insEmail=1`) : e.replace(r, `${r}&insEmail=1`) : e.replace(r, `${r}?insEmail=1`);
|
|
54
67
|
});
|
|
55
|
-
i = i.replace(
|
|
68
|
+
i = i.replace(n, o);
|
|
56
69
|
}
|
|
57
70
|
}), i;
|
|
58
71
|
},
|
|
@@ -60,5 +73,5 @@ const S = [
|
|
|
60
73
|
}
|
|
61
74
|
];
|
|
62
75
|
export {
|
|
63
|
-
|
|
76
|
+
T as unsubscribeCompilerRules
|
|
64
77
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function migrateCouponBlock(html: string): string;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var m = (o, t, e) => t in o ? k(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var x = (o, t, e) => m(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import h from "../../extensions/Blocks/CouponBlock/template.js";
|
|
5
|
+
class y {
|
|
6
|
+
constructor() {
|
|
7
|
+
x(this, "parser");
|
|
8
|
+
this.parser = new DOMParser();
|
|
9
|
+
}
|
|
10
|
+
migrate(t) {
|
|
11
|
+
try {
|
|
12
|
+
const e = this.parser.parseFromString(t, "text/html"), n = e.querySelectorAll("td.coupon-block.ins-coupon-code:not([esd-extension-block-id])");
|
|
13
|
+
return n.length === 0 ? t : (n.forEach((s) => {
|
|
14
|
+
const i = this.extractText(s), c = this.extractAttributes(s), l = h.replace("{@COUPON_CODE}", i).replace(
|
|
15
|
+
'class="coupon-block coupon-block-v2 ins-coupon-code esd-block-text esd-extension-block"',
|
|
16
|
+
c.class
|
|
17
|
+
).replace(
|
|
18
|
+
'esd-extension-block-id="coupon-block"',
|
|
19
|
+
`esd-extension-block-id="coupon-block"${c.block}`
|
|
20
|
+
).replace(
|
|
21
|
+
'<p class="ins-title"',
|
|
22
|
+
`<p class="ins-title"${c.text}`
|
|
23
|
+
);
|
|
24
|
+
s.outerHTML = l;
|
|
25
|
+
}), e.documentElement.outerHTML);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return console.error("CouponBlockMigrator failed:", e), t;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
extractText(t) {
|
|
31
|
+
var g;
|
|
32
|
+
const e = t.querySelector(".ins-title");
|
|
33
|
+
if (!e)
|
|
34
|
+
return "{@COUPON_CODE}";
|
|
35
|
+
const n = ((g = e.textContent) == null ? void 0 : g.trim()) || "{@COUPON_CODE}", s = e.getAttribute("style") || "", i = /font-weight\s*:\s*bold/i.test(s), c = /font-style\s*:\s*italic/i.test(s), l = /text-decoration[^;]*underline/i.test(s), u = /text-decoration[^;]*line-through/i.test(s), a = /vertical-align\s*:\s*sub/i.test(s), p = /vertical-align\s*:\s*super/i.test(s);
|
|
36
|
+
return [
|
|
37
|
+
[i, "strong"],
|
|
38
|
+
[c, "em"],
|
|
39
|
+
[l, "u"],
|
|
40
|
+
[u, "s"],
|
|
41
|
+
[a, "sub"],
|
|
42
|
+
[p, "sup"]
|
|
43
|
+
].reduce((b, [f, d]) => f ? `<${d}>${b}</${d}>` : b, n);
|
|
44
|
+
}
|
|
45
|
+
extractAttributes(t) {
|
|
46
|
+
const e = t.querySelector(".ins-title"), n = t.className.split(" ").filter((r) => r.startsWith("es-")), s = t.getAttribute("align"), i = t.getAttribute("bgcolor"), c = t.getAttribute("style"), l = e == null ? void 0 : e.getAttribute("style");
|
|
47
|
+
let u = 'class="coupon-block coupon-block-v2 ins-coupon-code esd-block-text esd-extension-block';
|
|
48
|
+
n.length && (u += ` ${n.join(" ")}`), u += '"';
|
|
49
|
+
let a = "";
|
|
50
|
+
if (s && (a += ` align="${s}"`), i && (a += ` bgcolor="${i}"`), c) {
|
|
51
|
+
const r = c.replace(/background-color[^;]+;?/gi, "").replace(/;+/g, ";").trim();
|
|
52
|
+
r && (a += ` style="${r.replace(/"/g, "'")}"`);
|
|
53
|
+
}
|
|
54
|
+
let p = "";
|
|
55
|
+
if (l) {
|
|
56
|
+
const r = l.replace(/"/g, '"').replace(/font-weight\s*:\s*[^;]+;?/gi, "").replace(/font-style\s*:\s*[^;]+;?/gi, "").replace(/text-decoration\s*:\s*[^;]+;?/gi, "").replace(/vertical-align\s*:\s*[^;]+;?/gi, "").replace(/;+/g, ";").replace(/^;|;$/g, "").trim().replace(/"/g, "'");
|
|
57
|
+
r && (p = ` style="${r}"`);
|
|
58
|
+
}
|
|
59
|
+
return { class: u, block: a, text: p };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function C(o) {
|
|
63
|
+
return new y().migrate(o);
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
C as migrateCouponBlock
|
|
67
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const migrate: (html: string) => string
|
|
1
|
+
export declare const migrate: (html: string) => Promise<string>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { migrateCheckbox as o } from "./checkboxMigrator.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { migrateCouponBlock as m } from "./couponBlockMigrator.js";
|
|
3
|
+
import { migrateRadioButton as i } from "./radioButtonMigrator.js";
|
|
4
|
+
import { migrateUnsubscribe as e } from "./unsubscribeMigrator.js";
|
|
5
|
+
const c = async (t) => {
|
|
6
|
+
let r = t;
|
|
7
|
+
return r = o(r), r = i(r), r = await e(r), r = m(r), r;
|
|
6
8
|
};
|
|
7
9
|
export {
|
|
8
|
-
|
|
10
|
+
c as migrate
|
|
9
11
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function migrateUnsubscribe(html: string): Promise<string>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var x = (l, e, t) => e in l ? h(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
|
|
3
|
+
var S = (l, e, t) => x(l, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { MERGE_TAGS as k, PAGE_TYPES as p } from "../../enums/unsubscribe.js";
|
|
5
|
+
import { DATA_ATTRIBUTES as A } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
6
|
+
import { useUnsubscribeStore as T } from "../../stores/unsubscribe.js";
|
|
7
|
+
class C {
|
|
8
|
+
constructor() {
|
|
9
|
+
S(this, "parser");
|
|
10
|
+
this.parser = new DOMParser();
|
|
11
|
+
}
|
|
12
|
+
async migrate(e) {
|
|
13
|
+
try {
|
|
14
|
+
const t = this.parser.parseFromString(e, "text/html"), i = t.querySelectorAll("td.unsubscribe-block");
|
|
15
|
+
if (!i.length)
|
|
16
|
+
return e;
|
|
17
|
+
const o = T();
|
|
18
|
+
return await o.fetchTemplates(), i.forEach((r) => {
|
|
19
|
+
const c = r.getAttribute("id"), g = this.extractPaddingClass(r), u = r.getAttribute("bgcolor") || "", n = this.extractUnsubscribeContent(r), s = this.getCollectionTypeFromMergeTag(n.linkHref), b = o.getSelectedUnsubscribePagesByCollection(s);
|
|
20
|
+
console.debug("[UnsubscribeMigrator]", {
|
|
21
|
+
mergeTag: n.linkHref,
|
|
22
|
+
collectionType: s,
|
|
23
|
+
pageIds: b,
|
|
24
|
+
paddingClass: g,
|
|
25
|
+
bgColor: u
|
|
26
|
+
});
|
|
27
|
+
const f = this.buildUnsubscribeBlock(
|
|
28
|
+
n,
|
|
29
|
+
s,
|
|
30
|
+
b,
|
|
31
|
+
g,
|
|
32
|
+
u
|
|
33
|
+
), a = this.parser.parseFromString(
|
|
34
|
+
`<table id="tempDoc"><tbody><tr>${f}</tr></tbody></table>`,
|
|
35
|
+
"text/html"
|
|
36
|
+
).querySelector(".unsubscribe-block-v2");
|
|
37
|
+
a && r.parentNode && (a.setAttribute("id", c || ""), r.parentNode.replaceChild(a, r));
|
|
38
|
+
}), t.documentElement.outerHTML;
|
|
39
|
+
} catch (t) {
|
|
40
|
+
return console.error("UnsubscribeMigrator failed:", t), e;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
extractPaddingClass(e) {
|
|
44
|
+
const i = (e.getAttribute("class") || "").match(/\bes-p\d+\b/);
|
|
45
|
+
return i ? i[0] : "";
|
|
46
|
+
}
|
|
47
|
+
extractUnsubscribeContent(e) {
|
|
48
|
+
var m;
|
|
49
|
+
const t = e.querySelector("p");
|
|
50
|
+
if (!t)
|
|
51
|
+
return {
|
|
52
|
+
textBefore: "You can ",
|
|
53
|
+
linkText: "unsubscribe",
|
|
54
|
+
linkHref: "{{ins-unsubscribe-link}}",
|
|
55
|
+
linkStyle: "",
|
|
56
|
+
textAfter: " from our emails, if you need to.",
|
|
57
|
+
isBold: !1,
|
|
58
|
+
isItalic: !1,
|
|
59
|
+
align: "center",
|
|
60
|
+
paragraphStyle: ""
|
|
61
|
+
};
|
|
62
|
+
const i = e.getAttribute("align") || t.getAttribute("align") || "center", o = t.getAttribute("style") || "", r = t.querySelector("a.unsubscribe-link") || t.querySelector('a[href*="unsubscribe"]');
|
|
63
|
+
if (!r)
|
|
64
|
+
return {
|
|
65
|
+
textBefore: "You can ",
|
|
66
|
+
linkText: "unsubscribe",
|
|
67
|
+
linkHref: "{{ins-unsubscribe-link}}",
|
|
68
|
+
linkStyle: "",
|
|
69
|
+
textAfter: " from our emails, if you need to.",
|
|
70
|
+
isBold: !1,
|
|
71
|
+
isItalic: !1,
|
|
72
|
+
align: i,
|
|
73
|
+
paragraphStyle: o
|
|
74
|
+
};
|
|
75
|
+
const c = ((m = r.textContent) == null ? void 0 : m.trim()) || "unsubscribe", g = r.getAttribute("href") || "{{ins-unsubscribe-link}}", u = r.getAttribute("style") || "", n = t.textContent || "", s = n.indexOf(c), b = s >= 0 ? n.substring(0, s).trim() : "You can ", f = s >= 0 ? n.substring(s + c.length).trim() : " from our emails, if you need to.", d = !!t.querySelector("b, strong"), a = !!t.querySelector("i, em");
|
|
76
|
+
return {
|
|
77
|
+
textBefore: b,
|
|
78
|
+
linkText: c,
|
|
79
|
+
linkHref: this.normalizeUnsubscribeHref(g),
|
|
80
|
+
linkStyle: u,
|
|
81
|
+
textAfter: f,
|
|
82
|
+
isBold: d,
|
|
83
|
+
isItalic: a,
|
|
84
|
+
align: i,
|
|
85
|
+
paragraphStyle: o
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
buildUnsubscribeBlock(e, t, i, o, r) {
|
|
89
|
+
const c = e.linkStyle ? ` style="${e.linkStyle}"` : "", u = `<a ${`href="${e.linkHref}" class="unsubscribe-link" target="_blank" data-unsubscribe-link="true"`}${c}>${e.linkText}</a>`, n = [];
|
|
90
|
+
e.textBefore && n.push(e.textBefore), n.push(u), e.textAfter && n.push(e.textAfter);
|
|
91
|
+
let s = n.join(" ");
|
|
92
|
+
e.isBold && e.isItalic ? s = `<strong path="1,0"><em path="1,0,0">${s}</em></strong>` : e.isBold ? s = `<strong path="1,0">${s}</strong>` : e.isItalic && (s = `<em path="1,0">${s}</em>`);
|
|
93
|
+
const b = e.align ? ` align="${e.align}"` : "", f = r ? ` bgcolor="${r}"` : "", d = e.paragraphStyle ? ` style="${e.paragraphStyle}"` : "", a = i.length > 0 ? ` ${A.PAGE_LIST}="${i.join(",")}"` : "", m = ` ${A.PAGE_TYPE}="${t}"`, y = "esd-block-text unsubscribe-block-v2 esd-block-unsubscribe esd-unsubscribe-block esd-extension-block";
|
|
94
|
+
return `
|
|
95
|
+
<td
|
|
96
|
+
data-migration="true"
|
|
97
|
+
esd-extension-block-id="unsubscribe-block"
|
|
98
|
+
class="${o ? `${y} ${o}` : y}"
|
|
99
|
+
${b}${f}${m}${a}
|
|
100
|
+
>
|
|
101
|
+
<p path="1"${d}>
|
|
102
|
+
${s}
|
|
103
|
+
</p>
|
|
104
|
+
</td>
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
getCollectionTypeFromMergeTag(e) {
|
|
108
|
+
return e === k[p.SUBSCRIPTION_PREFERENCE_CENTER] ? p.SUBSCRIPTION_PREFERENCE_CENTER : e === k[p.GLOBAL_UNSUBSCRIBE] ? p.GLOBAL_UNSUBSCRIBE : p.GLOBAL_UNSUBSCRIBE;
|
|
109
|
+
}
|
|
110
|
+
normalizeUnsubscribeHref(e) {
|
|
111
|
+
if (Object.values(k).includes(e))
|
|
112
|
+
return e;
|
|
113
|
+
const i = e.match(/{{ins-(?:global-)?(?:preferences-)?unsubscribe-link}}/);
|
|
114
|
+
return i ? i[0] : e.includes("unsubscribe") || e.includes("unsub") ? (console.warn(
|
|
115
|
+
`[UnsubscribeMigrator] Unrecognized unsubscribe href format: "${e}". Defaulting to {{ins-unsubscribe-link}}`
|
|
116
|
+
), "{{ins-unsubscribe-link}}") : e;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function M(l) {
|
|
120
|
+
return new C().migrate(l);
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
M as migrateUnsubscribe
|
|
124
|
+
};
|
package/dist/enums/defaults.js
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
57
|
-
|
|
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
|
-
|
|
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
|
-
},
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
|
|
2
2
|
export declare const CHECKBOX_BLOCK_ID = "checkbox-block";
|
|
3
3
|
export declare class CheckboxBlock extends Block {
|
|
4
|
+
constructor();
|
|
4
5
|
getId(): string;
|
|
5
6
|
getIcon(): string;
|
|
6
7
|
getBlockCompositionType(): BlockCompositionType;
|
|
@@ -1,39 +1,30 @@
|
|
|
1
|
-
import { Block as t } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/EditorStatePropertyType.js";
|
|
9
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PanelPosition.js";
|
|
10
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/Popover.js";
|
|
11
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PreviewDeviceMode.js";
|
|
12
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/SettingsTab.js";
|
|
13
|
-
import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementType.js";
|
|
14
|
-
import { getDefaultTemplate as r } from "./template.js";
|
|
15
|
-
const e = "checkbox-block";
|
|
16
|
-
class x extends t {
|
|
1
|
+
import { Block as e, BlockCompositionType as t } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { getDefaultTemplate as o } from "./template.js";
|
|
3
|
+
const r = "checkbox-block";
|
|
4
|
+
class p extends e {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
}
|
|
17
8
|
getId() {
|
|
18
|
-
return
|
|
9
|
+
return r;
|
|
19
10
|
}
|
|
20
11
|
getIcon() {
|
|
21
|
-
return "
|
|
12
|
+
return "checkbox-icon";
|
|
22
13
|
}
|
|
23
14
|
getBlockCompositionType() {
|
|
24
|
-
return
|
|
15
|
+
return t.CONTAINER;
|
|
25
16
|
}
|
|
26
17
|
getName() {
|
|
27
|
-
return this.api.translate("Checkbox
|
|
18
|
+
return this.api.translate("Checkbox Block");
|
|
28
19
|
}
|
|
29
20
|
getDescription() {
|
|
30
|
-
return this.api.translate("Checkbox
|
|
21
|
+
return this.api.translate("Checkbox Block Description");
|
|
31
22
|
}
|
|
32
23
|
getTemplate() {
|
|
33
|
-
return
|
|
24
|
+
return o();
|
|
34
25
|
}
|
|
35
26
|
}
|
|
36
27
|
export {
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
r as CHECKBOX_BLOCK_ID,
|
|
29
|
+
p as CheckboxBlock
|
|
39
30
|
};
|