@useinsider/guido 3.4.1-beta.c04b4e7 → 3.4.1-beta.ce8d9b0
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/composables/useActionsApi.js +5 -9
- package/dist/composables/useHtmlCompiler.js +40 -22
- package/dist/composables/useSave.js +14 -13
- package/dist/extensions/Blocks/Unsubscribe/block.js +53 -80
- package/dist/extensions/Blocks/Unsubscribe/template.js +8 -8
- package/dist/src/composables/useActionsApi.d.ts +1 -1
- package/dist/src/composables/useHtmlCompiler.d.ts +1 -0
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +1 -5
- package/dist/utils/templatePreparation.js +55 -63
- package/package.json +1 -1
|
@@ -21,9 +21,9 @@ const v = () => {
|
|
|
21
21
|
resetDataSavedFlag: !1,
|
|
22
22
|
disableLineHeightsReplace: !0
|
|
23
23
|
}, ...t }, s = {
|
|
24
|
-
callback: (l,
|
|
24
|
+
callback: (l, r, d, c, u) => {
|
|
25
25
|
l ? a(l) : e({
|
|
26
|
-
html:
|
|
26
|
+
html: r,
|
|
27
27
|
ampHtml: d,
|
|
28
28
|
ampErrors: c,
|
|
29
29
|
displayConditions: u
|
|
@@ -36,11 +36,11 @@ const v = () => {
|
|
|
36
36
|
return {
|
|
37
37
|
getCompiledEmail: m,
|
|
38
38
|
getTemplateData: () => new Promise((t) => {
|
|
39
|
-
const e = ({ html: a, css: i, width: o, height:
|
|
39
|
+
const e = ({ html: a, css: i, width: o, height: p, utmParams: s, syncModulesIds: l }) => t({
|
|
40
40
|
html: a,
|
|
41
41
|
css: i,
|
|
42
42
|
width: o,
|
|
43
|
-
height:
|
|
43
|
+
height: p,
|
|
44
44
|
utmParams: s,
|
|
45
45
|
syncModulesIds: l
|
|
46
46
|
});
|
|
@@ -91,11 +91,7 @@ const v = () => {
|
|
|
91
91
|
},
|
|
92
92
|
editorSave: () => new Promise((t) => {
|
|
93
93
|
window.StripoEditorApi.actionsApi.save((e) => {
|
|
94
|
-
|
|
95
|
-
n(e, "Failed to save template"), t(!1);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
t(!0);
|
|
94
|
+
e && n(e, "Failed to save template"), t();
|
|
99
95
|
});
|
|
100
96
|
})
|
|
101
97
|
};
|
|
@@ -1,30 +1,48 @@
|
|
|
1
|
-
import { defaultHtmlCompilerRules as
|
|
2
|
-
import { itemsCompilerRules as
|
|
3
|
-
import { liquidCompilerRules as
|
|
4
|
-
import { outlookCompilerRules as
|
|
5
|
-
import { recommendationCompilerRules as
|
|
6
|
-
import { socialCompilerRules as
|
|
7
|
-
import { unsubscribeCompilerRules as
|
|
8
|
-
import { createHtmlCompiler as
|
|
9
|
-
import { useConfig as
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { defaultHtmlCompilerRules as R } from "../config/compiler/htmlCompilerRules.js";
|
|
2
|
+
import { itemsCompilerRules as g } from "../config/compiler/itemsCompilerRules.js";
|
|
3
|
+
import { liquidCompilerRules as C } from "../config/compiler/liquidCompilerRules.js";
|
|
4
|
+
import { outlookCompilerRules as b } from "../config/compiler/outlookCompilerRules.js";
|
|
5
|
+
import { recommendationCompilerRules as v } from "../config/compiler/recommendationCompilerRules.js";
|
|
6
|
+
import { socialCompilerRules as H } from "../config/compiler/socialCompilerRules.js";
|
|
7
|
+
import { unsubscribeCompilerRules as x } from "../config/compiler/unsubscribeCompilerRules.js";
|
|
8
|
+
import { createHtmlCompiler as s } from "../utils/htmlCompiler.js";
|
|
9
|
+
import { useConfig as k } from "./useConfig.js";
|
|
10
|
+
const y = /* @__PURE__ */ new Set([
|
|
11
|
+
// URL/tag encoding fixes — keep merge-tag and placeholder integrity intact.
|
|
12
|
+
"fix-url-encoding-start",
|
|
13
|
+
"fix-url-encoding-end",
|
|
14
|
+
"fix-tags-start",
|
|
15
|
+
"fix-tags-end",
|
|
16
|
+
// Image domain corrections — plain string replacement.
|
|
17
|
+
"replace-old-image-domain",
|
|
18
|
+
"replace-old-v2-image-domain",
|
|
19
|
+
// Unsubscribe domain — the actual fix: injects the real unsubscribe href in
|
|
20
|
+
// place of the `{{ins-*-unsubscribe-link}}` placeholders, plus related
|
|
21
|
+
// unsubscribe-only cleanups. All pure regex/text, no AMP-forbidden output.
|
|
22
|
+
"add-unsubscribe-link-values",
|
|
23
|
+
"remove-data-ogsb-button-styles",
|
|
24
|
+
"format-comment-braces",
|
|
25
|
+
"add-universal-link-flags",
|
|
26
|
+
// Coupon placeholder replacement (only present when liquidSyntax is enabled).
|
|
27
|
+
"liquid-coupon-code"
|
|
28
|
+
]), M = () => {
|
|
29
|
+
var m, t, r;
|
|
30
|
+
const { compiler: e, isFeatureEnabled: a, partner: n } = k(), u = ((m = e.value) == null ? void 0 : m.customRules) || [], l = [
|
|
31
|
+
...!!((t = e.value) != null && t.ignoreDefaultRules) ? [] : R,
|
|
32
|
+
...v,
|
|
33
|
+
...x,
|
|
15
34
|
...g,
|
|
16
|
-
...f,
|
|
17
|
-
...C,
|
|
18
35
|
...b,
|
|
19
|
-
...
|
|
20
|
-
...
|
|
36
|
+
...H,
|
|
37
|
+
...a("liquidSyntax") ? C : [],
|
|
38
|
+
...u.map((o, f) => ({
|
|
21
39
|
...o,
|
|
22
|
-
priority: o.priority + 1e3 +
|
|
40
|
+
priority: o.priority + 1e3 + f
|
|
23
41
|
// Ensure additional rules run after default rules
|
|
24
42
|
}))
|
|
25
|
-
], p =
|
|
26
|
-
return { compileHtml: (o) => p.compile(o, void 0,
|
|
43
|
+
], p = s(l), c = l.filter((o) => y.has(o.id)), d = s(c), i = (r = n.value) == null ? void 0 : r.fallbackFont;
|
|
44
|
+
return { compileHtml: (o) => p.compile(o, void 0, i), compileAmpHtml: (o) => d.compile(o, void 0, i) };
|
|
27
45
|
};
|
|
28
46
|
export {
|
|
29
|
-
|
|
47
|
+
M as useHtmlCompiler
|
|
30
48
|
};
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { useActionsApi as x } from "./useActionsApi.js";
|
|
2
2
|
import { useConfig as y } from "./useConfig.js";
|
|
3
3
|
import { useSaveStart as w, useSaveComplete as C } from "./useGuidoActions.js";
|
|
4
|
-
import { useSyncModuleExtractor as
|
|
5
|
-
import { useStripoApi as
|
|
6
|
-
import { useTemplatePreparation as
|
|
7
|
-
import { useHtmlValidator as
|
|
8
|
-
import { useCouponBlockValidator as
|
|
9
|
-
import { useLiquidValidator as
|
|
10
|
-
const
|
|
11
|
-
const o = w(), s = C(), { validateHtml: r } =
|
|
4
|
+
import { useSyncModuleExtractor as H } from "./useSyncModuleExtractor.js";
|
|
5
|
+
import { useStripoApi as b } from "../services/stripoApi.js";
|
|
6
|
+
import { useTemplatePreparation as q } from "../utils/templatePreparation.js";
|
|
7
|
+
import { useHtmlValidator as L } from "./useHtmlValidator.js";
|
|
8
|
+
import { useCouponBlockValidator as P } from "./validators/useCouponBlockValidator.js";
|
|
9
|
+
import { useLiquidValidator as E } from "./validators/useLiquidValidator.js";
|
|
10
|
+
const j = () => {
|
|
11
|
+
const o = w(), s = C(), { validateHtml: r } = L(), { validateLiquidSyntax: l } = E(), { validateCouponBlockTags: n } = P(), { callbacks: a, isFeatureEnabled: d } = y(), { extractSyncModuleData: u } = H(), { setSyncModuleUnsubscriptionPages: c } = b(), { editorSave: m } = x();
|
|
12
12
|
return { save: async (p = !1, f = !1) => {
|
|
13
13
|
var i;
|
|
14
14
|
o();
|
|
15
|
-
const { prepareTemplateDetails: v } =
|
|
16
|
-
if (!
|
|
15
|
+
const { prepareTemplateDetails: v } = q(), t = await v();
|
|
16
|
+
if (!n(t.compiledHtml))
|
|
17
17
|
return;
|
|
18
18
|
if (d("liquidSyntax")) {
|
|
19
|
-
if (!await
|
|
19
|
+
if (!await l(t.compiledHtml))
|
|
20
20
|
return;
|
|
21
21
|
} else if (!await r(t.compiledHtml, t.dynamicContentList, !0))
|
|
22
22
|
return;
|
|
23
|
-
if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t)
|
|
23
|
+
if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t))
|
|
24
24
|
return;
|
|
25
|
+
await m();
|
|
25
26
|
const { unsubscribePayload: S, stripoModules: V } = u(t.rawHtml);
|
|
26
27
|
return await c(S), t.modules = V, p || s({ ...t, silent: f }), t;
|
|
27
28
|
} };
|
|
28
29
|
};
|
|
29
30
|
export {
|
|
30
|
-
|
|
31
|
+
j as useSave
|
|
31
32
|
};
|
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
var d = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
[b.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
14
|
-
[b.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
2
|
+
var h = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
|
|
3
|
+
var u = (n, i, e) => h(n, typeof i != "symbol" ? i + "" : i, e);
|
|
4
|
+
import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
|
|
5
|
+
import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
|
|
6
|
+
import { Block as _, BlockCompositionType as S, BlockType as L, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
|
+
import { getDefaultTemplate as v } from "./template.js";
|
|
8
|
+
import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
|
|
9
|
+
import { parsePageList as p } from "./utils/utils.js";
|
|
10
|
+
const g = "unsubscribe-block", T = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", C = {
|
|
11
|
+
[E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
12
|
+
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
15
13
|
};
|
|
16
|
-
class
|
|
14
|
+
class I extends _ {
|
|
17
15
|
constructor() {
|
|
18
16
|
super();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
c(this, "hadUnsubscribeLink", !1);
|
|
17
|
+
u(this, "selectEventListener", null);
|
|
18
|
+
u(this, "cancelEventListener", null);
|
|
19
|
+
u(this, "currentNode");
|
|
23
20
|
}
|
|
24
21
|
getId() {
|
|
25
|
-
return
|
|
22
|
+
return g;
|
|
26
23
|
}
|
|
27
24
|
getIcon() {
|
|
28
25
|
return "unsubscribe-icon";
|
|
29
26
|
}
|
|
30
27
|
getBlockCompositionType() {
|
|
31
|
-
return
|
|
28
|
+
return S.BLOCK;
|
|
32
29
|
}
|
|
33
30
|
getName() {
|
|
34
31
|
return this.api.translate("Unsubscribe Block");
|
|
@@ -37,63 +34,39 @@ class x extends g {
|
|
|
37
34
|
return this.api.translate("Unsubscribe Block Description");
|
|
38
35
|
}
|
|
39
36
|
getTemplate() {
|
|
40
|
-
return
|
|
37
|
+
return v();
|
|
41
38
|
}
|
|
42
39
|
onSelect(e) {
|
|
43
|
-
this.currentNode = e,
|
|
44
|
-
}
|
|
45
|
-
onDocumentChanged(e) {
|
|
46
|
-
const t = this._hasUnsubscribeLink(e);
|
|
47
|
-
this.hadUnsubscribeLink && !t && this._warnLinkRemoved(), this.hadUnsubscribeLink = t;
|
|
40
|
+
this.currentNode = e, !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
|
|
48
41
|
}
|
|
49
42
|
onDelete(e) {
|
|
50
|
-
this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState()
|
|
43
|
+
this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
|
|
51
44
|
}
|
|
52
45
|
onDestroy() {
|
|
53
|
-
this._removeEventListeners(), this.currentNode = void 0
|
|
54
|
-
}
|
|
55
|
-
_hasUnsubscribeLink(e) {
|
|
56
|
-
return "querySelector" in e ? !!e.querySelector(p) : !1;
|
|
57
|
-
}
|
|
58
|
-
_warnLinkRemoved() {
|
|
59
|
-
try {
|
|
60
|
-
const { showToaster: e } = L();
|
|
61
|
-
e({
|
|
62
|
-
type: S.Warning,
|
|
63
|
-
message: this.api.translate(A),
|
|
64
|
-
actionButton: {
|
|
65
|
-
text: this.api.translate("Visit Academy"),
|
|
66
|
-
onClick: () => {
|
|
67
|
-
window.open(C, "_blank", "noopener,noreferrer");
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
} catch (e) {
|
|
72
|
-
console.error("[UnsubscribeBlock] Failed to show warning toaster:", e);
|
|
73
|
-
}
|
|
46
|
+
this._removeEventListeners(), this.currentNode = void 0;
|
|
74
47
|
}
|
|
75
48
|
_setupSelectEventListener() {
|
|
76
49
|
this._removeSelectEventListener(), this.selectEventListener = (e) => {
|
|
77
|
-
const
|
|
78
|
-
this._updateBlock(
|
|
79
|
-
}, document.addEventListener(
|
|
50
|
+
const r = e, { collectionType: s, selectedPages: t } = r.detail;
|
|
51
|
+
this._updateBlock(s, t.join(","));
|
|
52
|
+
}, document.addEventListener(a.SELECT, this.selectEventListener);
|
|
80
53
|
}
|
|
81
54
|
_removeSelectEventListener() {
|
|
82
|
-
this.selectEventListener && (document.removeEventListener(
|
|
55
|
+
this.selectEventListener && (document.removeEventListener(a.SELECT, this.selectEventListener), this.selectEventListener = null);
|
|
83
56
|
}
|
|
84
57
|
_setupCancelEventListener() {
|
|
85
58
|
this._removeCancelEventListener(), this.cancelEventListener = () => {
|
|
86
59
|
this._handleCancel();
|
|
87
|
-
}, document.addEventListener(
|
|
60
|
+
}, document.addEventListener(a.CANCEL, this.cancelEventListener);
|
|
88
61
|
}
|
|
89
62
|
_removeCancelEventListener() {
|
|
90
|
-
this.cancelEventListener && (document.removeEventListener(
|
|
63
|
+
this.cancelEventListener && (document.removeEventListener(a.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
|
|
91
64
|
}
|
|
92
65
|
_handleCancel() {
|
|
93
66
|
try {
|
|
94
67
|
if (!this.currentNode)
|
|
95
68
|
return;
|
|
96
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${
|
|
69
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${L.EMPTY_CONTAINER}/>`).apply(new b("Removed unsubscribe block due to cancel"));
|
|
97
70
|
} catch (e) {
|
|
98
71
|
console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
|
|
99
72
|
}
|
|
@@ -101,35 +74,35 @@ class x extends g {
|
|
|
101
74
|
_removeEventListeners() {
|
|
102
75
|
this._removeSelectEventListener(), this._removeCancelEventListener();
|
|
103
76
|
}
|
|
104
|
-
_updateBlock(e,
|
|
77
|
+
_updateBlock(e, r) {
|
|
105
78
|
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
106
79
|
return;
|
|
107
|
-
const
|
|
108
|
-
if (!
|
|
80
|
+
const s = this.currentNode.querySelector(T);
|
|
81
|
+
if (!s)
|
|
109
82
|
return;
|
|
110
|
-
const
|
|
111
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
83
|
+
const t = this._getMergeTag(e);
|
|
84
|
+
this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", t).apply(new b(`Updated unsubscribe link to ${t}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, r).apply(new b("Updated unsubscribe block metadata"));
|
|
112
85
|
}
|
|
113
86
|
_getMergeTag(e) {
|
|
114
|
-
return
|
|
87
|
+
return C[e] ?? B;
|
|
115
88
|
}
|
|
116
89
|
_openDrawer() {
|
|
117
90
|
if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
|
|
118
91
|
try {
|
|
119
|
-
const e =
|
|
92
|
+
const e = c();
|
|
120
93
|
e.typeSelectionDrawerStatus = !0;
|
|
121
94
|
} catch (e) {
|
|
122
95
|
console.error("[UnsubscribeBlock] Failed to open drawer:", e);
|
|
123
96
|
}
|
|
124
97
|
}
|
|
125
98
|
_checkExistingBlocks() {
|
|
126
|
-
const e =
|
|
127
|
-
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(
|
|
128
|
-
if ("getAttribute" in
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
const l = Number(
|
|
132
|
-
l ===
|
|
99
|
+
const e = c();
|
|
100
|
+
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((s) => {
|
|
101
|
+
if ("getAttribute" in s) {
|
|
102
|
+
const t = s.getAttribute(o.PAGE_TYPE);
|
|
103
|
+
if (t) {
|
|
104
|
+
const l = Number(t);
|
|
105
|
+
l === E.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : l === E.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
|
|
133
106
|
}
|
|
134
107
|
}
|
|
135
108
|
});
|
|
@@ -137,26 +110,26 @@ class x extends g {
|
|
|
137
110
|
async _loadBlockState(e) {
|
|
138
111
|
if (!("getAttribute" in e))
|
|
139
112
|
return;
|
|
140
|
-
const
|
|
141
|
-
if (!
|
|
113
|
+
const r = e.getAttribute(o.PAGE_TYPE), s = e.getAttribute(o.PAGE_LIST);
|
|
114
|
+
if (!r || !s)
|
|
142
115
|
return;
|
|
143
|
-
const
|
|
144
|
-
await
|
|
116
|
+
const t = c(), l = Number(r), m = p(s);
|
|
117
|
+
await t.fetchTemplates(), t.setCollectionWithoutAutoSelection(l), t.loadSelectedTemplates(m);
|
|
145
118
|
}
|
|
146
119
|
_resetStoreState() {
|
|
147
|
-
|
|
120
|
+
c().$reset();
|
|
148
121
|
}
|
|
149
122
|
_removeBlockTemplatesFromStore(e) {
|
|
150
123
|
if (!("getAttribute" in e))
|
|
151
124
|
return;
|
|
152
|
-
const
|
|
153
|
-
if (!
|
|
125
|
+
const r = e.getAttribute(o.PAGE_LIST);
|
|
126
|
+
if (!r)
|
|
154
127
|
return;
|
|
155
|
-
const
|
|
156
|
-
|
|
128
|
+
const s = c(), t = p(r);
|
|
129
|
+
s.removeUnsubscribePages(t);
|
|
157
130
|
}
|
|
158
131
|
}
|
|
159
132
|
export {
|
|
160
|
-
|
|
161
|
-
|
|
133
|
+
g as UNSUBSCRIBE_BLOCK_ID,
|
|
134
|
+
I as UnsubscribeBlock
|
|
162
135
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { BlockType as
|
|
2
|
-
const
|
|
3
|
-
<${
|
|
1
|
+
import { BlockType as e } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
const s = "unsubscribe", n = "{{ins-unsubscribe-link}}", t = `
|
|
3
|
+
<${e.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
|
|
9
|
+
<p>You can <strong><a
|
|
10
10
|
href="${n}"
|
|
11
11
|
class="unsubscribe-link"
|
|
12
12
|
target="_blank"
|
|
13
13
|
data-unsubscribe-link="true"
|
|
14
|
-
>${
|
|
15
|
-
</${
|
|
14
|
+
>${s}</a></strong> from our emails, if you need to.</p>
|
|
15
|
+
</${e.BLOCK_TEXT}>
|
|
16
16
|
`;
|
|
17
|
-
function
|
|
17
|
+
function r() {
|
|
18
18
|
return t;
|
|
19
19
|
}
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
r as getDefaultTemplate
|
|
22
22
|
};
|
|
@@ -7,5 +7,5 @@ export declare const useActionsApi: () => {
|
|
|
7
7
|
getPreviewData: (options?: CompileEmailOptions) => Promise<CompiledEmailResult>;
|
|
8
8
|
updateTimerInClonedTemplate: () => Promise<string | null>;
|
|
9
9
|
updateHtmlAndCss: (html: string, css: string) => void;
|
|
10
|
-
editorSave: () => Promise<
|
|
10
|
+
editorSave: () => Promise<void>;
|
|
11
11
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { ImmutableHtmlElementNode
|
|
1
|
+
import type { ImmutableHtmlElementNode } from '@stripoinc/ui-editor-extensions';
|
|
2
2
|
import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
|
|
3
3
|
export declare const UNSUBSCRIBE_BLOCK_ID = "unsubscribe-block";
|
|
4
4
|
export declare class UnsubscribeBlock extends Block {
|
|
5
5
|
private selectEventListener;
|
|
6
6
|
private cancelEventListener;
|
|
7
7
|
private currentNode?;
|
|
8
|
-
private hadUnsubscribeLink;
|
|
9
8
|
constructor();
|
|
10
9
|
getId(): string;
|
|
11
10
|
getIcon(): string;
|
|
@@ -14,11 +13,8 @@ export declare class UnsubscribeBlock extends Block {
|
|
|
14
13
|
getDescription(): string;
|
|
15
14
|
getTemplate(): string;
|
|
16
15
|
onSelect(node: ImmutableHtmlElementNode): void;
|
|
17
|
-
onDocumentChanged(node: ImmutableHtmlNode): void;
|
|
18
16
|
onDelete(node: ImmutableHtmlElementNode): void;
|
|
19
17
|
onDestroy(): void;
|
|
20
|
-
private _hasUnsubscribeLink;
|
|
21
|
-
private _warnLinkRemoved;
|
|
22
18
|
private _setupSelectEventListener;
|
|
23
19
|
private _removeSelectEventListener;
|
|
24
20
|
private _setupCancelEventListener;
|
|
@@ -1,101 +1,93 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useHtmlCompiler as
|
|
3
|
-
import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as
|
|
1
|
+
import { useActionsApi as P } from "../composables/useActionsApi.js";
|
|
2
|
+
import { useHtmlCompiler as D } from "../composables/useHtmlCompiler.js";
|
|
3
|
+
import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as i } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
4
4
|
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
-
import { DATA_ATTRIBUTES as
|
|
6
|
-
import { parsePageList as
|
|
7
|
-
import { useDynamicContentStore as
|
|
8
|
-
import { useUnsubscribeStore as
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
return
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
}),
|
|
5
|
+
import { DATA_ATTRIBUTES as y } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
6
|
+
import { parsePageList as E } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
7
|
+
import { useDynamicContentStore as H } from "../stores/dynamic-content.js";
|
|
8
|
+
import { useUnsubscribeStore as U } from "../stores/unsubscribe.js";
|
|
9
|
+
function F(a, t) {
|
|
10
|
+
const c = new DOMParser().parseFromString(a, "text/html").querySelectorAll(`[${y.PAGE_LIST}]`), r = [];
|
|
11
|
+
return c.forEach((o) => {
|
|
12
|
+
const n = o.getAttribute(y.PAGE_LIST);
|
|
13
|
+
n && r.push(...E(n));
|
|
14
|
+
}), t.filter((o) => r.includes(o));
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
const m = new DOMParser().parseFromString(
|
|
16
|
+
function x(a) {
|
|
17
|
+
const m = new DOMParser().parseFromString(a, "text/html").querySelectorAll(".recommendation-block-v2");
|
|
18
18
|
if (m.length === 0)
|
|
19
19
|
return;
|
|
20
|
-
const
|
|
21
|
-
m.forEach((
|
|
22
|
-
var g, f, u,
|
|
23
|
-
const
|
|
24
|
-
if (!Number.isFinite(
|
|
20
|
+
const p = b();
|
|
21
|
+
m.forEach((c) => {
|
|
22
|
+
var l, g, f, u, s;
|
|
23
|
+
const r = c.getAttribute("recommendation-id"), o = r ? Number(r) : NaN;
|
|
24
|
+
if (!Number.isFinite(o))
|
|
25
25
|
return;
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
26
|
+
const n = c.getAttribute("esd-ext-config");
|
|
27
|
+
if (!n)
|
|
28
28
|
return;
|
|
29
29
|
let e;
|
|
30
30
|
try {
|
|
31
|
-
e = JSON.parse(
|
|
31
|
+
e = JSON.parse(n);
|
|
32
32
|
} catch {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
36
36
|
return;
|
|
37
|
-
const
|
|
38
|
-
strategy: e.strategy ??
|
|
39
|
-
language: e.language ??
|
|
40
|
-
size: e.size ??
|
|
37
|
+
const S = {
|
|
38
|
+
strategy: e.strategy ?? i.strategy,
|
|
39
|
+
language: e.language ?? i.language,
|
|
40
|
+
size: e.size ?? i.size,
|
|
41
41
|
// Spread the default arrays so each block gets a fresh reference
|
|
42
42
|
// instead of sharing the singleton in DEFAULT_NODE_CONFIG.
|
|
43
|
-
productIds: e.productIds ?? [...
|
|
44
|
-
filters: e.filters ?? [...
|
|
45
|
-
shuffleProducts: e.shuffleProducts ??
|
|
46
|
-
currencyCode: ((
|
|
47
|
-
currencyAlignment: ((
|
|
48
|
-
currencyDecimalCount: ((
|
|
49
|
-
currencyDecimalSeparator: ((
|
|
50
|
-
currencyThousandSeparator: ((
|
|
43
|
+
productIds: e.productIds ?? [...i.productIds],
|
|
44
|
+
filters: e.filters ?? [...i.filters],
|
|
45
|
+
shuffleProducts: e.shuffleProducts ?? i.shuffleProducts,
|
|
46
|
+
currencyCode: ((l = e.currency) == null ? void 0 : l.code) ?? d.code,
|
|
47
|
+
currencyAlignment: ((g = e.currency) == null ? void 0 : g.alignment) ?? d.alignment,
|
|
48
|
+
currencyDecimalCount: ((f = e.currency) == null ? void 0 : f.decimalCount) ?? d.decimalCount,
|
|
49
|
+
currencyDecimalSeparator: ((u = e.currency) == null ? void 0 : u.decimalSeparator) ?? d.decimalSeparator,
|
|
50
|
+
currencyThousandSeparator: ((s = e.currency) == null ? void 0 : s.thousandSeparator) ?? d.thousandSeparator
|
|
51
51
|
};
|
|
52
|
-
|
|
52
|
+
p.seedBlockUrlConfig(o, S);
|
|
53
53
|
});
|
|
54
|
-
try {
|
|
55
|
-
await l.fetchRecommendationCreateData();
|
|
56
|
-
} catch (t) {
|
|
57
|
-
console.warn(
|
|
58
|
-
"Recommendation reference data pre-load failed; validator will skip the availability check.",
|
|
59
|
-
t
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
54
|
}
|
|
63
|
-
const
|
|
64
|
-
const
|
|
55
|
+
const M = () => {
|
|
56
|
+
const a = H(), t = U(), { getCompiledEmail: m, getTemplateData: p } = P(), { compileHtml: c, compileAmpHtml: r } = D();
|
|
65
57
|
return {
|
|
66
58
|
prepareTemplateDetails: async () => {
|
|
67
|
-
const { html:
|
|
59
|
+
const { html: n, ampHtml: e = "", ampErrors: S = [] } = await m({
|
|
68
60
|
minimize: !0,
|
|
69
61
|
resetDataSavedFlag: !1
|
|
70
|
-
}), { html:
|
|
71
|
-
|
|
72
|
-
const { compiledHtml: u, stats:
|
|
62
|
+
}), { html: l, css: g, syncModulesIds: f = [] } = await p();
|
|
63
|
+
t.selectedUnsubscribePages.length && await t.fetchTemplates(), x(l);
|
|
64
|
+
const { compiledHtml: u, stats: s, appliedRules: A } = c(n), h = e && r(e).compiledHtml, C = a.getSelectedDynamicContentList, T = b();
|
|
73
65
|
return console.debug("HTML Compilation Stats:", {
|
|
74
|
-
originalSize:
|
|
75
|
-
compiledSize:
|
|
76
|
-
reduction: `${
|
|
77
|
-
appliedRules:
|
|
78
|
-
executionTime: `${
|
|
66
|
+
originalSize: s.originalSize,
|
|
67
|
+
compiledSize: s.compiledSize,
|
|
68
|
+
reduction: `${s.reductionPercentage.toFixed(2)}%`,
|
|
69
|
+
appliedRules: A,
|
|
70
|
+
executionTime: `${s.executionTime.toFixed(2)}ms`
|
|
79
71
|
}), {
|
|
80
|
-
dynamicContentList:
|
|
72
|
+
dynamicContentList: C,
|
|
81
73
|
compiledHtml: u,
|
|
82
|
-
rawHtml:
|
|
74
|
+
rawHtml: l,
|
|
83
75
|
css: g,
|
|
84
|
-
ampHtml:
|
|
85
|
-
ampErrors:
|
|
76
|
+
ampHtml: h,
|
|
77
|
+
ampErrors: S,
|
|
86
78
|
modules: f.map(Number),
|
|
87
79
|
recommendation: {
|
|
88
|
-
campaignUrls:
|
|
80
|
+
campaignUrls: T.recommendationCampaignUrls,
|
|
89
81
|
configs: {}
|
|
90
82
|
},
|
|
91
83
|
unsubscribe: {
|
|
92
|
-
status:
|
|
93
|
-
config:
|
|
84
|
+
status: t.unsubscribePagesStatus,
|
|
85
|
+
config: F(u, t.selectedUnsubscribePages)
|
|
94
86
|
}
|
|
95
87
|
};
|
|
96
88
|
}
|
|
97
89
|
};
|
|
98
90
|
};
|
|
99
91
|
export {
|
|
100
|
-
|
|
92
|
+
M as useTemplatePreparation
|
|
101
93
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.4.1-beta.
|
|
3
|
+
"version": "3.4.1-beta.ce8d9b0",
|
|
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",
|