@useinsider/guido 3.21.2-beta.1cc8327 → 3.21.2-beta.45bb425
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 +21 -22
- package/dist/composables/useFullStoryBridge.js +9 -10
- package/dist/composables/useSave.js +75 -68
- package/dist/composables/validators/useHtmlDocumentCountValidator.js +22 -0
- package/dist/config/migrator/index.js +10 -11
- package/dist/services/templateLibraryApi.js +36 -31
- package/dist/src/composables/validators/useHtmlDocumentCountValidator.d.ts +3 -0
- package/dist/src/utils/templatePreparation.d.ts +2 -1
- package/dist/utils/templatePreparation.js +30 -30
- package/package.json +1 -1
- package/dist/config/migrator/fullStoryScriptMigrator.js +0 -5
- package/dist/src/config/migrator/fullStoryScriptMigrator.d.ts +0 -1
- package/dist/src/utils/fullStoryScripts.d.ts +0 -6
- package/dist/utils/fullStoryScripts.js +0 -8
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { filterAmpErrors as
|
|
2
|
-
import {
|
|
3
|
-
import { getEditorApi as r } from "../utils/stripoEditorApi.js";
|
|
1
|
+
import { filterAmpErrors as y } from "../utils/ampErrorFilter.js";
|
|
2
|
+
import { getEditorApi as s } from "../utils/stripoEditorApi.js";
|
|
4
3
|
import { useToaster as D } from "./useToaster.js";
|
|
5
|
-
const
|
|
4
|
+
const h = 1e4, T = 3e4, r = (n, l, A) => new Promise((C, p) => {
|
|
6
5
|
const f = setTimeout(
|
|
7
6
|
() => p(new Error(`${n} did not report completion within ${l}ms`)),
|
|
8
7
|
l
|
|
@@ -14,8 +13,8 @@ const H = 1e4, T = 3e4, m = (n, l, A) => new Promise((C, p) => {
|
|
|
14
13
|
} catch (t) {
|
|
15
14
|
d(t);
|
|
16
15
|
}
|
|
17
|
-
}),
|
|
18
|
-
const { handleError: n } = D(), l = (t = {}) =>
|
|
16
|
+
}), P = () => {
|
|
17
|
+
const { handleError: n } = D(), l = (t = {}) => r(
|
|
19
18
|
"compileEmail",
|
|
20
19
|
T,
|
|
21
20
|
(e, i) => {
|
|
@@ -39,38 +38,38 @@ const H = 1e4, T = 3e4, m = (n, l, A) => new Promise((C, p) => {
|
|
|
39
38
|
resetDataSavedFlag: !1,
|
|
40
39
|
disableLineHeightsReplace: !0
|
|
41
40
|
}, ...t }, u = {
|
|
42
|
-
callback: (
|
|
43
|
-
|
|
41
|
+
callback: (m, g, w, S, v) => {
|
|
42
|
+
m ? i(m) : e({
|
|
44
43
|
html: g,
|
|
45
44
|
ampHtml: w,
|
|
46
|
-
ampErrors:
|
|
47
|
-
displayConditions:
|
|
45
|
+
ampErrors: y(S ?? []),
|
|
46
|
+
displayConditions: v
|
|
48
47
|
});
|
|
49
48
|
},
|
|
50
49
|
...o
|
|
51
50
|
};
|
|
52
|
-
|
|
51
|
+
s().actionsApi.compileEmail(u);
|
|
53
52
|
}
|
|
54
53
|
);
|
|
55
54
|
return {
|
|
56
55
|
getCompiledEmail: l,
|
|
57
|
-
getTemplateData: () =>
|
|
56
|
+
getTemplateData: () => r(
|
|
58
57
|
"getTemplateData",
|
|
59
58
|
T,
|
|
60
59
|
(t) => {
|
|
61
|
-
const e = ({ html: i, css: a, width: o, height: E, utmParams: u, syncModulesIds:
|
|
62
|
-
html:
|
|
60
|
+
const e = ({ html: i, css: a, width: o, height: E, utmParams: u, syncModulesIds: m }) => t({
|
|
61
|
+
html: i,
|
|
63
62
|
css: a,
|
|
64
63
|
width: o,
|
|
65
64
|
height: E,
|
|
66
65
|
utmParams: u,
|
|
67
|
-
syncModulesIds:
|
|
66
|
+
syncModulesIds: m
|
|
68
67
|
});
|
|
69
|
-
|
|
68
|
+
s().actionsApi.getTemplateData(e);
|
|
70
69
|
}
|
|
71
70
|
),
|
|
72
71
|
activateCustomViewStyles: (t = !0) => {
|
|
73
|
-
|
|
72
|
+
s().actionsApi.activateCustomViewStyles(t);
|
|
74
73
|
},
|
|
75
74
|
getPreviewData: async (t) => {
|
|
76
75
|
try {
|
|
@@ -110,16 +109,16 @@ const H = 1e4, T = 3e4, m = (n, l, A) => new Promise((C, p) => {
|
|
|
110
109
|
}
|
|
111
110
|
}),
|
|
112
111
|
updateHtmlAndCss: (t, e) => {
|
|
113
|
-
const { actionsApi: i } =
|
|
114
|
-
return
|
|
112
|
+
const { actionsApi: i } = s();
|
|
113
|
+
return r("updateHtmlAndCss", h, (a) => {
|
|
115
114
|
i.updateHtmlAndCss(t, e, () => a());
|
|
116
115
|
});
|
|
117
116
|
},
|
|
118
|
-
editorSave: () =>
|
|
117
|
+
editorSave: () => r(
|
|
119
118
|
"save",
|
|
120
119
|
T,
|
|
121
120
|
(t) => {
|
|
122
|
-
|
|
121
|
+
s().actionsApi.save((e) => {
|
|
123
122
|
if (e) {
|
|
124
123
|
n(e, "Failed to save template"), t(!1);
|
|
125
124
|
return;
|
|
@@ -131,5 +130,5 @@ const H = 1e4, T = 3e4, m = (n, l, A) => new Promise((C, p) => {
|
|
|
131
130
|
};
|
|
132
131
|
};
|
|
133
132
|
export {
|
|
134
|
-
|
|
133
|
+
P as useActionsApi
|
|
135
134
|
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (typeof n._fs_org != "string" || !n._fs_org)
|
|
1
|
+
const c = "https://email-static.useinsider.com/guido/guido-fs.js", u = () => ({ injectFullStory: () => {
|
|
2
|
+
var n;
|
|
3
|
+
const s = window;
|
|
4
|
+
if (typeof s._fs_org != "string" || !s._fs_org)
|
|
6
5
|
return;
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
6
|
+
const r = document.querySelector("ui-editor"), o = (n = r == null ? void 0 : r.shadowRoot) == null ? void 0 : n.querySelector("iframe"), e = o == null ? void 0 : o.contentDocument;
|
|
7
|
+
if (!e || e.querySelector('script[data-fullstory-bridge="true"]'))
|
|
9
8
|
return;
|
|
10
|
-
const t =
|
|
11
|
-
t.src =
|
|
9
|
+
const t = e.createElement("script");
|
|
10
|
+
t.src = c, t.async = !0, t.crossOrigin = "anonymous", t.dataset.fullstoryBridge = "true", e.head.appendChild(t);
|
|
12
11
|
} });
|
|
13
12
|
export {
|
|
14
|
-
|
|
13
|
+
u as useFullStoryBridge
|
|
15
14
|
};
|
|
@@ -1,84 +1,91 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useEditorLock as
|
|
4
|
-
import { useSaveStart as
|
|
5
|
-
import { useSaveValidation as
|
|
6
|
-
import { useSaveValidationRollout as
|
|
7
|
-
import { useSyncModuleExtractor as
|
|
8
|
-
import { ToasterTypeOptions as
|
|
9
|
-
import { useStripoApi as
|
|
10
|
-
import { useConfigStore as
|
|
11
|
-
import { useDynamicContentStore as
|
|
12
|
-
import { useSaveValidationStore as
|
|
13
|
-
import { useTemplatePreparation as
|
|
14
|
-
import { useAllowlist as
|
|
15
|
-
import { useHtmlValidator as
|
|
16
|
-
import { useToaster as
|
|
17
|
-
import { useCouponBlockValidator as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { useActionsApi as q } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as O } from "./useConfig.js";
|
|
3
|
+
import { useEditorLock as D } from "./useEditorLock.js";
|
|
4
|
+
import { useSaveStart as F, useSaveComplete as j } from "./useGuidoActions.js";
|
|
5
|
+
import { useSaveValidation as z } from "./useSaveValidation.js";
|
|
6
|
+
import { useSaveValidationRollout as G } from "./useSaveValidationRollout.js";
|
|
7
|
+
import { useSyncModuleExtractor as I } from "./useSyncModuleExtractor.js";
|
|
8
|
+
import { ToasterTypeOptions as J } from "../enums/toaster.js";
|
|
9
|
+
import { useStripoApi as K } from "../services/stripoApi.js";
|
|
10
|
+
import { useConfigStore as N } from "../stores/config.js";
|
|
11
|
+
import { useDynamicContentStore as Q } from "../stores/dynamic-content.js";
|
|
12
|
+
import { useSaveValidationStore as X } from "../stores/save-validation.js";
|
|
13
|
+
import { useTemplatePreparation as Y, getHtmlReferencedUnsubscribePages as Z } from "../utils/templatePreparation.js";
|
|
14
|
+
import { useAllowlist as _ } from "./useAllowlist.js";
|
|
15
|
+
import { useHtmlValidator as $ } from "./useHtmlValidator.js";
|
|
16
|
+
import { useToaster as tt } from "./useToaster.js";
|
|
17
|
+
import { useCouponBlockValidator as et } from "./validators/useCouponBlockValidator.js";
|
|
18
|
+
import { useHtmlDocumentCountValidator as ot } from "./validators/useHtmlDocumentCountValidator.js";
|
|
19
|
+
import { useLiquidValidator as it } from "./validators/useLiquidValidator.js";
|
|
20
|
+
import { useSyncModuleBlockValidator as st } from "./validators/useSyncModuleBlockValidator.js";
|
|
21
|
+
import { useUnsubscribeBlockValidator as at } from "./validators/useUnsubscribeBlockValidator.js";
|
|
22
|
+
const Pt = () => {
|
|
23
|
+
const n = F(), w = j(), { validateHtml: y } = $(), { validateLiquidSyntax: E } = it(), { validateCouponBlockTags: b } = et(), { validateUnsubscribeBlockUniqueness: g, validateUnsubscribeBlockHasTemplate: H } = at(), { validateSyncModuleBlocks: l } = st(), { validateSingleHtmlDocument: c } = ot(), { callbacks: r, isFeatureEnabled: v } = O(), { extractSyncModuleData: V } = I(), { setSyncModuleUnsubscriptionPages: x } = K(), { editorSave: C, getTemplateData: u } = q(), { showToaster: k } = tt(), { getBlockedDomains: h, resolveToast: B } = _(), { prepareTemplateDetails: p } = Y(), { collectSaveValidationErrors: T } = z(), { isEnabled: P } = G(), L = X(), U = Q(), S = N(), { runExclusive: m } = D(), d = async (t, e, i) => {
|
|
24
|
+
if (!v("allowlistEnabled"))
|
|
24
25
|
return !1;
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
26
|
+
const o = await h(t, e);
|
|
27
|
+
if (!o.length)
|
|
27
28
|
return !1;
|
|
28
|
-
if (!
|
|
29
|
-
const s = await
|
|
30
|
-
s != null && s.message &&
|
|
31
|
-
type:
|
|
29
|
+
if (!i) {
|
|
30
|
+
const s = await B(o);
|
|
31
|
+
s != null && s.message && k({
|
|
32
|
+
type: J.Warning,
|
|
32
33
|
message: s.message,
|
|
33
34
|
actionButton: s.actionButton
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
return !0;
|
|
37
|
-
},
|
|
38
|
-
if (!await
|
|
38
|
+
}, A = async (t) => !b(t.compiledHtml) || !g(t.compiledHtml) || !H(t.compiledHtml) ? !1 : v("liquidSyntax") ? E(t.compiledHtml) : y(t.compiledHtml, t.dynamicContentList, !0), f = async (t, e) => {
|
|
39
|
+
if (!await C())
|
|
39
40
|
return;
|
|
40
|
-
const { unsubscribePayload:
|
|
41
|
-
if (await
|
|
42
|
-
const
|
|
43
|
-
|
|
41
|
+
const { unsubscribePayload: o, stripoModules: s } = V(t.rawHtml);
|
|
42
|
+
if (await x(o), t.modules = s, !e.suppress) {
|
|
43
|
+
const a = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
|
|
44
|
+
w({ ...t, ...a, silent: e.silent });
|
|
44
45
|
}
|
|
45
46
|
return t;
|
|
46
|
-
},
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
}, M = async (t, e) => {
|
|
48
|
+
var s;
|
|
49
|
+
n();
|
|
50
|
+
const i = await u();
|
|
51
|
+
if (!c(i.html, e))
|
|
52
|
+
return;
|
|
53
|
+
const o = await p(i);
|
|
54
|
+
if (l(o.rawHtml, e)) {
|
|
55
|
+
if (P.value && !e) {
|
|
56
|
+
const a = await T(
|
|
53
57
|
o.compiledHtml,
|
|
54
58
|
o.dynamicContentList
|
|
55
59
|
);
|
|
56
|
-
if (
|
|
57
|
-
|
|
60
|
+
if (a.length) {
|
|
61
|
+
L.open(a, "save");
|
|
58
62
|
return;
|
|
59
63
|
}
|
|
60
|
-
} else if (!await
|
|
64
|
+
} else if (!await A(o))
|
|
61
65
|
return;
|
|
62
|
-
if (!((
|
|
63
|
-
return
|
|
66
|
+
if (!((s = r.value) != null && s.externalValidation && !await r.value.externalValidation(o)) && !await d(o.compiledHtml, o.css, e))
|
|
67
|
+
return f(o, { silent: e, suppress: t });
|
|
64
68
|
}
|
|
65
|
-
},
|
|
66
|
-
var
|
|
67
|
-
if (!
|
|
69
|
+
}, W = async () => {
|
|
70
|
+
var i;
|
|
71
|
+
if (!S.allowSaveWithErrors)
|
|
72
|
+
return;
|
|
73
|
+
n();
|
|
74
|
+
const t = await u();
|
|
75
|
+
if (!c(t.html, !1))
|
|
68
76
|
return;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!f.allowSaveWithErrors)
|
|
77
|
+
const e = await p(t);
|
|
78
|
+
if (l(e.rawHtml, !1) && !((i = r.value) != null && i.externalValidation && !await r.value.externalValidation(e)) && !await d(e.compiledHtml, e.css, !1))
|
|
79
|
+
return f(e, { silent: !1, blankCompiled: !0 });
|
|
80
|
+
}, R = async () => {
|
|
81
|
+
if (!S.allowSaveWithErrors)
|
|
75
82
|
return;
|
|
76
|
-
|
|
77
|
-
const { html: t, css: e } = await
|
|
78
|
-
if (!
|
|
83
|
+
n();
|
|
84
|
+
const { html: t, css: e } = await u();
|
|
85
|
+
if (!c(t, !0) || !l(t, !0) || await d(t, e, !0))
|
|
79
86
|
return;
|
|
80
|
-
const
|
|
81
|
-
dynamicContentList:
|
|
87
|
+
const i = Z(t), o = {
|
|
88
|
+
dynamicContentList: U.getSelectedDynamicContentList,
|
|
82
89
|
compiledHtml: "",
|
|
83
90
|
rawHtml: t,
|
|
84
91
|
css: e,
|
|
@@ -88,16 +95,16 @@ const Bt = () => {
|
|
|
88
95
|
// No campaignUrls: hosts overwrite their stored map with any object, and raw HTML can't rebuild it.
|
|
89
96
|
recommendation: { configs: {} },
|
|
90
97
|
unsubscribe: {
|
|
91
|
-
status:
|
|
92
|
-
config:
|
|
98
|
+
status: i.length > 0,
|
|
99
|
+
config: i
|
|
93
100
|
}
|
|
94
101
|
};
|
|
95
|
-
return
|
|
102
|
+
return f(o, { silent: !0 });
|
|
96
103
|
};
|
|
97
|
-
return { save: (t = !1, e = !1) =>
|
|
98
|
-
() =>
|
|
99
|
-
), saveWithErrors: () =>
|
|
104
|
+
return { save: (t = !1, e = !1) => m(
|
|
105
|
+
() => M(t, e)
|
|
106
|
+
), saveWithErrors: () => m(W), saveRawOnly: () => m(R) };
|
|
100
107
|
};
|
|
101
108
|
export {
|
|
102
|
-
|
|
109
|
+
Pt as useSave
|
|
103
110
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useToaster as i } from "../useToaster.js";
|
|
2
|
+
import { useTranslations as m } from "../useTranslations.js";
|
|
3
|
+
import { ToasterTypeOptions as c } from "../../enums/toaster.js";
|
|
4
|
+
const u = "newsletter.multiple-html-designs-detected", r = `(?:[^>"']|"[^"]*"|'[^']*')*`, a = "style|script|noscript|xmp|iframe|noembed|noframes|textarea|title", T = /<html(?=[\s>/])/gi, A = new RegExp(
|
|
5
|
+
`<!--[\\s\\S]*?-->|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>|<(${a})(?=[\\s/>])${r}>[\\s\\S]*?</\\1\\s*>|<([a-zA-Z][\\w:-]*)${r}>`,
|
|
6
|
+
"gi"
|
|
7
|
+
), p = (e) => Array.from(e.matchAll(A)).filter(([, , t]) => (t == null ? void 0 : t.toLowerCase()) === "html").length, g = () => {
|
|
8
|
+
const { showToaster: e } = i(), t = m();
|
|
9
|
+
return { validateSingleHtmlDocument: (o, l = !1) => {
|
|
10
|
+
var n;
|
|
11
|
+
if ((((n = o.match(T)) == null ? void 0 : n.length) ?? 0) < 2)
|
|
12
|
+
return !0;
|
|
13
|
+
const s = p(o);
|
|
14
|
+
return s <= 1 ? !0 : (console.debug("guido:save:blocked", { reason: "multiple-html-documents", htmlRootCount: s }), l || e({
|
|
15
|
+
type: c.Warning,
|
|
16
|
+
message: t(u)
|
|
17
|
+
}), !1);
|
|
18
|
+
} };
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
g as useHtmlDocumentCountValidator
|
|
22
|
+
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { migrateCheckbox as i } from "./checkboxMigrator.js";
|
|
2
2
|
import { migrateCouponBlock as e } from "./couponBlockMigrator.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { migrateRecommendation as p } from "./recommendationMigrator.js";
|
|
3
|
+
import { migrateItemsBlock as a } from "./itemsBlockMigrator.js";
|
|
4
|
+
import { migrateProductNameLink as n } from "./productNameLinkMigrator.js";
|
|
5
|
+
import { migrateRadioButton as c } from "./radioButtonMigrator.js";
|
|
6
|
+
import { migrateRecommendation as g } from "./recommendationMigrator.js";
|
|
8
7
|
import { migrateRecommendationPartnerScope as f } from "./recommendationPartnerMigrator.js";
|
|
9
|
-
import { migrateRecommendationTitle as
|
|
10
|
-
import { migrateSocialIcons as
|
|
11
|
-
import { migrateUnsubscribe as
|
|
12
|
-
const h = async (
|
|
13
|
-
let m =
|
|
14
|
-
return m = i(m), m =
|
|
8
|
+
import { migrateRecommendationTitle as p } from "./recommendationTitleMigrator.js";
|
|
9
|
+
import { migrateSocialIcons as d } from "./socialIconMigrator.js";
|
|
10
|
+
import { migrateUnsubscribe as l } from "./unsubscribeMigrator.js";
|
|
11
|
+
const h = async (r, t = {}, o) => {
|
|
12
|
+
let m = r;
|
|
13
|
+
return m = i(m), m = c(m), m = await l(m), m = e(m), m = g(m, t), o && (m = f(m, o)), m = p(m), m = a(m), m = n(m), m = d(m), m;
|
|
15
14
|
};
|
|
16
15
|
export {
|
|
17
16
|
h as migrate
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { useActionsApi as h } from "../composables/useActionsApi.js";
|
|
2
|
+
import { useConfig as S } from "../composables/useConfig.js";
|
|
3
|
+
import { useHttp as v } from "../composables/useHttp.js";
|
|
4
|
+
import { useToaster as x } from "../composables/useToaster.js";
|
|
5
|
+
import { useTranslations as A } from "../composables/useTranslations.js";
|
|
6
|
+
import { useHtmlDocumentCountValidator as E } from "../composables/validators/useHtmlDocumentCountValidator.js";
|
|
7
|
+
import { useLiquidValidator as N } from "../composables/validators/useLiquidValidator.js";
|
|
8
|
+
import { EditorType as H } from "../enums/defaults.js";
|
|
9
|
+
import { ToasterTypeOptions as P } from "../enums/toaster.js";
|
|
10
|
+
import { useRecommendationExtensionStore as D } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
11
|
+
import { useSaveAsTemplateStore as L } from "../stores/save-as-template.js";
|
|
10
12
|
import { base64EncodeWithSpecialChars as r } from "../utils/base64.js";
|
|
11
|
-
import { isPlainObject as
|
|
12
|
-
import { useTemplatePreparation as
|
|
13
|
-
const
|
|
14
|
-
const { get: n, post: m } =
|
|
13
|
+
import { isPlainObject as q } from "../utils/genericUtil.js";
|
|
14
|
+
import { useTemplatePreparation as F } from "../utils/templatePreparation.js";
|
|
15
|
+
const Z = () => {
|
|
16
|
+
const { get: n, post: m } = v(), { handleError: s, showToaster: l } = x(), { config: c, isFeatureEnabled: p } = S(), { validateLiquidSyntax: T } = N(), { validateSingleHtmlDocument: w } = E(), { getTemplateData: b } = h(), u = A();
|
|
15
17
|
return {
|
|
16
18
|
getCategories: async () => {
|
|
17
19
|
try {
|
|
18
20
|
const { data: e = [] } = await n("/newsletter/template-library/get-template-categories");
|
|
19
21
|
return e;
|
|
20
22
|
} catch (e) {
|
|
21
|
-
return
|
|
23
|
+
return s(e, "Failed to fetch template categories"), [];
|
|
22
24
|
}
|
|
23
25
|
},
|
|
24
26
|
checkTemplateNameAvailability: async (e) => {
|
|
@@ -35,27 +37,30 @@ const B = () => {
|
|
|
35
37
|
);
|
|
36
38
|
return t.toString();
|
|
37
39
|
} catch (t) {
|
|
38
|
-
return
|
|
40
|
+
return s(t, "Failed to create category"), "";
|
|
39
41
|
}
|
|
40
42
|
},
|
|
41
43
|
createTemplate: async () => {
|
|
42
44
|
var e, t, d, y;
|
|
43
45
|
try {
|
|
44
|
-
const { prepareTemplateDetails: i } =
|
|
45
|
-
if (
|
|
46
|
+
const { prepareTemplateDetails: i } = F(), o = L(), g = await b();
|
|
47
|
+
if (!w(g.html))
|
|
46
48
|
return !1;
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
const a = await i(g);
|
|
50
|
+
if (p("liquidSyntax") && !await T(a.compiledHtml))
|
|
51
|
+
return !1;
|
|
52
|
+
const C = {
|
|
53
|
+
name: o.getTemplateName,
|
|
54
|
+
categories: o.getSelectedCategoryIds,
|
|
50
55
|
productId: ((t = (e = c.value) == null ? void 0 : e.partner) == null ? void 0 : t.productType) || 0,
|
|
51
|
-
editorType:
|
|
56
|
+
editorType: H,
|
|
52
57
|
messageType: ((y = (d = c.value) == null ? void 0 : d.partner) == null ? void 0 : y.messageType) || 0,
|
|
53
58
|
content: r(a.compiledHtml),
|
|
54
59
|
css: r(a.css),
|
|
55
60
|
unsubscriptionPreferencePageStatus: !1,
|
|
56
61
|
unsubscriptionPreferencePages: [],
|
|
57
62
|
recommendationCampaignUrls: r(
|
|
58
|
-
|
|
63
|
+
D().recommendationCampaignUrls
|
|
59
64
|
),
|
|
60
65
|
recommendationConfigs: r({}),
|
|
61
66
|
isGuido: !0,
|
|
@@ -67,31 +72,31 @@ const B = () => {
|
|
|
67
72
|
css: a.css,
|
|
68
73
|
dynamicContentList: a.dynamicContentList
|
|
69
74
|
})
|
|
70
|
-
}, { data:
|
|
75
|
+
}, { data: f } = await m(
|
|
71
76
|
"/newsletter/template-library/create-template",
|
|
72
|
-
|
|
77
|
+
C
|
|
73
78
|
);
|
|
74
|
-
if (!
|
|
79
|
+
if (!q(f))
|
|
75
80
|
throw new Error("Unexpected create-template response");
|
|
76
|
-
return
|
|
81
|
+
return f.type === "alert" ? (l({
|
|
77
82
|
message: u(
|
|
78
83
|
"newsletter.template-library-save-alert",
|
|
79
|
-
{ templateName:
|
|
84
|
+
{ templateName: o.getTemplateName }
|
|
80
85
|
),
|
|
81
|
-
type:
|
|
86
|
+
type: P.Error
|
|
82
87
|
}), !1) : (l({
|
|
83
88
|
message: u(
|
|
84
89
|
"newsletter.template-library-save-success",
|
|
85
|
-
{ templateName:
|
|
90
|
+
{ templateName: o.getTemplateName }
|
|
86
91
|
),
|
|
87
92
|
type: "success"
|
|
88
93
|
}), !0);
|
|
89
94
|
} catch (i) {
|
|
90
|
-
return
|
|
95
|
+
return s(i, "Failed to create template"), !1;
|
|
91
96
|
}
|
|
92
97
|
}
|
|
93
98
|
};
|
|
94
99
|
};
|
|
95
100
|
export {
|
|
96
|
-
|
|
101
|
+
Z as useTemplateLibraryApi
|
|
97
102
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TemplateData } from '@@/Types/actions-api';
|
|
1
2
|
import type { SavedTemplateDetails } from '@@/Types/stripo';
|
|
2
3
|
/**
|
|
3
4
|
* Collects every unsubscribe page id referenced by the unsubscribe blocks
|
|
@@ -44,7 +45,7 @@ export declare function getHtmlReferencedUnsubscribePages(html: string): number[
|
|
|
44
45
|
*/
|
|
45
46
|
declare function hydrateRecommendationStoreFromRawHtml(rawHtml: string): Promise<void>;
|
|
46
47
|
export declare const useTemplatePreparation: () => {
|
|
47
|
-
prepareTemplateDetails: () => Promise<Omit<SavedTemplateDetails, "metadata">>;
|
|
48
|
+
prepareTemplateDetails: (prefetched?: TemplateData) => Promise<Omit<SavedTemplateDetails, "metadata">>;
|
|
48
49
|
hydrateRecommendationStore: typeof hydrateRecommendationStoreFromRawHtml;
|
|
49
50
|
};
|
|
50
51
|
export {};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useHtmlCompiler as
|
|
1
|
+
import { useActionsApi as E } from "../composables/useActionsApi.js";
|
|
2
|
+
import { useConfig as F } from "../composables/useConfig.js";
|
|
3
|
+
import { useHtmlCompiler as I } from "../composables/useHtmlCompiler.js";
|
|
4
4
|
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
-
import { toBlockUrlConfig as
|
|
5
|
+
import { toBlockUrlConfig as R } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
|
|
6
6
|
import { DATA_ATTRIBUTES as g } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
7
|
-
import { parsePageList as
|
|
8
|
-
import { useDynamicContentStore as
|
|
9
|
-
import { useEditorStore as
|
|
10
|
-
import { useUnsubscribeStore as
|
|
11
|
-
import { isPlainObject as
|
|
12
|
-
import { assignTrackingIds as
|
|
13
|
-
function
|
|
7
|
+
import { parsePageList as U } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
8
|
+
import { useDynamicContentStore as L } from "../stores/dynamic-content.js";
|
|
9
|
+
import { useEditorStore as N } from "../stores/editor.js";
|
|
10
|
+
import { useUnsubscribeStore as v } from "../stores/unsubscribe.js";
|
|
11
|
+
import { isPlainObject as z } from "./genericUtil.js";
|
|
12
|
+
import { assignTrackingIds as M } from "./linkTrackingIds.js";
|
|
13
|
+
function O(n) {
|
|
14
14
|
const r = new DOMParser().parseFromString(n, "text/html").querySelectorAll(`[${g.PAGE_LIST}]`), e = [];
|
|
15
15
|
return r.forEach((i) => {
|
|
16
16
|
const t = i.getAttribute(g.PAGE_LIST);
|
|
17
|
-
t && e.push(...
|
|
17
|
+
t && e.push(...U(t));
|
|
18
18
|
}), [...new Set(e)];
|
|
19
19
|
}
|
|
20
20
|
async function S(n) {
|
|
@@ -35,7 +35,7 @@ async function S(n) {
|
|
|
35
35
|
} catch {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
z(a) && r.seedBlockUrlConfig(t, R(a));
|
|
39
39
|
});
|
|
40
40
|
try {
|
|
41
41
|
await r.fetchRecommendationCreateData();
|
|
@@ -46,40 +46,40 @@ async function S(n) {
|
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
const n =
|
|
49
|
+
const Z = () => {
|
|
50
|
+
const n = L(), c = N(), o = v(), { getCompiledEmail: r, getTemplateData: e, updateHtmlAndCss: i } = E(), { compileHtml: t, compileAmpHtml: m } = I(), { isFeatureEnabled: a } = F();
|
|
51
51
|
return {
|
|
52
|
-
prepareTemplateDetails: async () => {
|
|
53
|
-
let { html: s, css: u, syncModulesIds:
|
|
52
|
+
prepareTemplateDetails: async (h) => {
|
|
53
|
+
let { html: s, css: u, syncModulesIds: y = [] } = h ?? await e();
|
|
54
54
|
if (a("linkTrackingIds"))
|
|
55
55
|
try {
|
|
56
|
-
const { html: d, changed:
|
|
57
|
-
c.trackIdSessionFloor =
|
|
56
|
+
const { html: d, changed: x, nextSeq: D } = M(s, c.trackIdSessionFloor);
|
|
57
|
+
c.trackIdSessionFloor = D, x && (s = d, await i(d, u));
|
|
58
58
|
} catch (d) {
|
|
59
59
|
console.error("Tracking-id step failed, saving anyway:", d);
|
|
60
60
|
}
|
|
61
|
-
const { html:
|
|
61
|
+
const { html: T, ampHtml: p = "", ampErrors: A = [] } = await r({
|
|
62
62
|
minimize: !0,
|
|
63
63
|
resetDataSavedFlag: !1
|
|
64
64
|
});
|
|
65
65
|
o.selectedUnsubscribePages.length && await o.fetchTemplates(), await S(s);
|
|
66
|
-
const { compiledHtml:
|
|
66
|
+
const { compiledHtml: w, stats: l, appliedRules: C } = t(T), H = p && m(p).compiledHtml, k = n.getSelectedDynamicContentList, P = b(), f = O(s);
|
|
67
67
|
return console.debug("HTML Compilation Stats:", {
|
|
68
68
|
originalSize: l.originalSize,
|
|
69
69
|
compiledSize: l.compiledSize,
|
|
70
70
|
reduction: `${l.reductionPercentage.toFixed(2)}%`,
|
|
71
|
-
appliedRules:
|
|
71
|
+
appliedRules: C,
|
|
72
72
|
executionTime: `${l.executionTime.toFixed(2)}ms`
|
|
73
73
|
}), {
|
|
74
|
-
dynamicContentList:
|
|
75
|
-
compiledHtml:
|
|
74
|
+
dynamicContentList: k,
|
|
75
|
+
compiledHtml: w,
|
|
76
76
|
rawHtml: s,
|
|
77
77
|
css: u,
|
|
78
|
-
ampHtml:
|
|
79
|
-
ampErrors:
|
|
80
|
-
modules:
|
|
78
|
+
ampHtml: H,
|
|
79
|
+
ampErrors: A,
|
|
80
|
+
modules: y.map(Number),
|
|
81
81
|
recommendation: {
|
|
82
|
-
campaignUrls:
|
|
82
|
+
campaignUrls: P.recommendationCampaignUrls,
|
|
83
83
|
configs: {}
|
|
84
84
|
},
|
|
85
85
|
unsubscribe: {
|
|
@@ -94,6 +94,6 @@ const Y = () => {
|
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
96
|
export {
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
O as getHtmlReferencedUnsubscribePages,
|
|
98
|
+
Z as useTemplatePreparation
|
|
99
99
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.21.2-beta.
|
|
3
|
+
"version": "3.21.2-beta.45bb425",
|
|
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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const migrateFullStoryScripts: (html: string) => string;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const FULLSTORY_BRIDGE_SCRIPT_URL = "https://email-static.useinsider.com/guido/guido-fs.js";
|
|
2
|
-
/**
|
|
3
|
-
* Removes FullStory `<script>` elements that the panel / bridge leave in the editor iframe head,
|
|
4
|
-
* which Stripo then serializes into the stored source. Other scripts are left untouched.
|
|
5
|
-
*/
|
|
6
|
-
export declare function stripFullStoryScripts(html: string): string;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const o = "https://email-static.useinsider.com/guido/guido-fs.js", E = new RegExp("<script\\b([^>]*?)(?<!\\/)>([\\s\\S]*?)<\\/script\\s*>", "gi"), _ = /<script\b([^>]*?)\/>/gi, e = /\bsrc\s*=\s*["']?(?:https?:)?\/\/(?:[\w-]+\.)*fullstory\.com[/"'\s>]/i, R = /\bdata-fullstory-bridge\b/i, S = /\b_fs_(?:script|namespace)\b/, i = (s, t = "") => e.test(`${s} `) || R.test(s) || s.includes(o) || S.test(t);
|
|
2
|
-
function n(s) {
|
|
3
|
-
return !s || !/fullstory|_fs_|guido-fs\.js/i.test(s) ? s : s.replace(E, (t, c, r) => i(c, r) ? "" : t).replace(_, (t, c) => i(c) ? "" : t);
|
|
4
|
-
}
|
|
5
|
-
export {
|
|
6
|
-
o as FULLSTORY_BRIDGE_SCRIPT_URL,
|
|
7
|
-
n as stripFullStoryScripts
|
|
8
|
-
};
|