@useinsider/guido 3.19.0-beta.8efe483 → 3.19.0-beta.ab4fcb3
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/config/schemas.js +104 -91
- package/dist/components/Guido.vue.js +3 -3
- package/dist/components/Guido.vue2.js +77 -73
- package/dist/components/organisms/header/EditorActions.vue.js +4 -4
- package/dist/components/organisms/header/EditorActions.vue2.js +23 -25
- package/dist/composables/useActionsApi.js +52 -47
- package/dist/composables/useCodeEditorApi.js +23 -9
- package/dist/composables/useTranslations.js +3 -2
- package/dist/composables/useVersionHistoryApi.js +33 -24
- package/dist/config/migrator/index.js +14 -13
- package/dist/config/migrator/recommendationPartnerMigrator.js +50 -0
- package/dist/extensions/Blocks/Recommendation/block.js +15 -14
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +45 -38
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +1 -0
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
- package/dist/src/stores/config.d.ts +20 -0
- package/dist/src/utils/stripoEditorApi.d.ts +4 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
- package/dist/stores/unsubscribe.js +3 -3
- package/dist/utils/stripoEditorApi.js +11 -0
- package/package.json +3 -2
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useCortexBlueprintBridge as
|
|
3
|
-
import { useEditorLock as
|
|
4
|
-
import { provideGuidoActions as
|
|
5
|
-
import { useGuidoStateBridge as
|
|
6
|
-
import { usePartner as
|
|
7
|
-
import { useStripo as
|
|
8
|
-
import { useTimerClone as
|
|
9
|
-
import { migrate as
|
|
10
|
-
import { ModuleFolderDefaults as
|
|
11
|
-
import { RIBBON_SELECTOR as
|
|
1
|
+
import { defineComponent as ae, defineAsyncComponent as m, ref as x, computed as u, watch as W, onMounted as se, onUnmounted as ie } from "vue";
|
|
2
|
+
import { useCortexBlueprintBridge as ce } from "../composables/useCortexBlueprintBridge.js";
|
|
3
|
+
import { useEditorLock as de } from "../composables/useEditorLock.js";
|
|
4
|
+
import { provideGuidoActions as me } from "../composables/useGuidoActions.js";
|
|
5
|
+
import { useGuidoStateBridge as le } from "../composables/useGuidoStateBridge.js";
|
|
6
|
+
import { usePartner as ue } from "../composables/usePartner.js";
|
|
7
|
+
import { useStripo as pe } from "../composables/useStripo.js";
|
|
8
|
+
import { useTimerClone as fe } from "../composables/useTimerClone.js";
|
|
9
|
+
import { migrate as G } from "../config/migrator/index.js";
|
|
10
|
+
import { ModuleFolderDefaults as H } from "../enums/defaults.js";
|
|
11
|
+
import { RIBBON_SELECTOR as ye } from "../enums/onboarding.js";
|
|
12
12
|
import { useRecommendationExtensionStore as h } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
13
|
-
import
|
|
14
|
-
import
|
|
13
|
+
import ge from "./organisms/AutoSaveController.vue.js";
|
|
14
|
+
import Se from "./organisms/base/Toaster.vue.js";
|
|
15
15
|
import ve from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import { useStripoApi as
|
|
21
|
-
import { useConfigStore as
|
|
22
|
-
import { useDynamicContentStore as
|
|
23
|
-
import { useEditorStore as
|
|
24
|
-
import { usePreviewStore as
|
|
25
|
-
import { useTemplateStore as
|
|
26
|
-
import { useUnsubscribeStore as
|
|
27
|
-
import { readTrackFloor as
|
|
28
|
-
const
|
|
16
|
+
import be from "./organisms/header/HeaderWrapper.vue.js";
|
|
17
|
+
import he from "./organisms/LoadingWrapper.vue.js";
|
|
18
|
+
import Ee from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
|
|
19
|
+
import we from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
|
|
20
|
+
import { useStripoApi as Ce } from "../services/stripoApi.js";
|
|
21
|
+
import { useConfigStore as De } from "../stores/config.js";
|
|
22
|
+
import { useDynamicContentStore as ke } from "../stores/dynamic-content.js";
|
|
23
|
+
import { useEditorStore as $ } from "../stores/editor.js";
|
|
24
|
+
import { usePreviewStore as Fe } from "../stores/preview.js";
|
|
25
|
+
import { useTemplateStore as Re } from "../stores/template.js";
|
|
26
|
+
import { useUnsubscribeStore as Te } from "../stores/unsubscribe.js";
|
|
27
|
+
import { readTrackFloor as z } from "../utils/linkTrackingIds.js";
|
|
28
|
+
const ot = /* @__PURE__ */ ae({
|
|
29
29
|
__name: "Guido",
|
|
30
30
|
props: {
|
|
31
31
|
config: null,
|
|
32
32
|
ready: { type: Boolean, default: !0 }
|
|
33
33
|
},
|
|
34
34
|
emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
|
|
35
|
-
setup(
|
|
36
|
-
const
|
|
35
|
+
setup(q, { expose: K, emit: r }) {
|
|
36
|
+
const s = q, V = m(
|
|
37
37
|
() => import("./organisms/email-preview/PreviewContainer.vue.js")
|
|
38
|
-
), V = m(
|
|
39
|
-
() => import("./organisms/onboarding/OnboardingWrapper.vue.js")
|
|
40
38
|
), j = m(
|
|
41
|
-
() => import("./organisms/
|
|
39
|
+
() => import("./organisms/onboarding/OnboardingWrapper.vue.js")
|
|
42
40
|
), J = m(
|
|
43
|
-
() => import("./organisms/extensions/recommendation/
|
|
41
|
+
() => import("./organisms/extensions/recommendation/AssignStrategyDrawer.vue.js")
|
|
44
42
|
), Q = m(
|
|
43
|
+
() => import("./organisms/extensions/recommendation/RemoveStrategyModal.vue.js")
|
|
44
|
+
), X = m(
|
|
45
45
|
() => import("./organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js")
|
|
46
|
-
), E =
|
|
47
|
-
|
|
48
|
-
const c =
|
|
46
|
+
), E = x(), p = x(), f = ke(), w = Te(), o = De();
|
|
47
|
+
s.ready && o.init(s.config);
|
|
48
|
+
const c = $(), Y = Fe(), l = u(() => c.hasChanges), { isTestPartner: Z } = ue(), C = () => {
|
|
49
49
|
var t;
|
|
50
50
|
return (t = E.value) == null ? void 0 : t.handleSave(!0);
|
|
51
51
|
}, D = (t) => {
|
|
52
52
|
c.loadingStatus = t;
|
|
53
53
|
};
|
|
54
|
-
|
|
54
|
+
ce(), le();
|
|
55
55
|
const y = () => {
|
|
56
56
|
var t, e;
|
|
57
57
|
return {
|
|
@@ -59,18 +59,18 @@ const tt = /* @__PURE__ */ re({
|
|
|
59
59
|
userId: o.userId,
|
|
60
60
|
username: o.username,
|
|
61
61
|
partnerName: o.partnerName,
|
|
62
|
-
savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) ||
|
|
63
|
-
defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) ||
|
|
62
|
+
savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || H.SAVED_MODULES,
|
|
63
|
+
defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || H.DEFAULT_MODULES
|
|
64
64
|
};
|
|
65
|
-
}, { initPlugin: k, preloadRuntime:
|
|
65
|
+
}, { initPlugin: k, preloadRuntime: F } = pe(), { runExclusive: R, beginMount: T, isCurrentMount: M } = de();
|
|
66
66
|
let g = 0;
|
|
67
|
-
const { getDefaultTemplate: I } =
|
|
67
|
+
const { getDefaultTemplate: I } = Ce(), { cloneTimersOnSave: L, hasTimerBlocks: U } = fe(), ee = u(() => {
|
|
68
68
|
var t;
|
|
69
69
|
return !((t = o.ui) != null && t.showHeader);
|
|
70
|
-
}),
|
|
70
|
+
}), te = u(() => o.isFeatureEnabled("reusableRecommendationStrategy")), oe = u(
|
|
71
71
|
() => !!h().recommendationConfigs.strategyId
|
|
72
72
|
);
|
|
73
|
-
|
|
73
|
+
me({
|
|
74
74
|
onBack: () => {
|
|
75
75
|
console.debug("guido:back"), r("back");
|
|
76
76
|
},
|
|
@@ -85,80 +85,84 @@ const tt = /* @__PURE__ */ re({
|
|
|
85
85
|
console.debug("guido:test-email:click"), r("test-email:click");
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
-
const
|
|
88
|
+
const B = (t) => {
|
|
89
89
|
console.debug("dynamic-content:close", t), f.setSelectedDynamicContent(t), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: t }));
|
|
90
|
-
},
|
|
90
|
+
}, N = () => {
|
|
91
91
|
console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
|
|
92
92
|
};
|
|
93
|
-
|
|
93
|
+
W(() => l.value, () => {
|
|
94
94
|
r("on-change", l.value);
|
|
95
95
|
});
|
|
96
|
-
const
|
|
97
|
-
const e = t, { attribute:
|
|
98
|
-
console.debug("dynamic-content:open", e.detail), r("dynamic-content:open",
|
|
96
|
+
const S = (t) => {
|
|
97
|
+
const e = t, { attribute: a, position: d } = e.detail;
|
|
98
|
+
console.debug("dynamic-content:open", e.detail), r("dynamic-content:open", a, d);
|
|
99
99
|
};
|
|
100
100
|
let i = null;
|
|
101
|
-
const
|
|
101
|
+
const v = () => {
|
|
102
102
|
var e;
|
|
103
|
-
const t = document.querySelector(
|
|
103
|
+
const t = document.querySelector(ye);
|
|
104
104
|
(e = p.value) == null || e.style.setProperty("--ribbon-offset", `${(t == null ? void 0 : t.offsetHeight) ?? 0}px`);
|
|
105
105
|
}, b = async () => {
|
|
106
106
|
var t;
|
|
107
107
|
try {
|
|
108
|
-
o.initialized || o.init(
|
|
109
|
-
const e = o.template,
|
|
108
|
+
o.initialized || o.init(s.config), c.templateId = o.templateId;
|
|
109
|
+
const e = o.template, a = (e == null ? void 0 : e.html) || "", d = (e == null ? void 0 : e.css) || "", A = (e == null ? void 0 : e.preselectedDynamicContent) || [];
|
|
110
110
|
w.selectedUnsubscribePages = (e == null ? void 0 : e.selectedUnsubscribePages) || [];
|
|
111
|
-
const
|
|
111
|
+
const P = ((t = e == null ? void 0 : e.migration) == null ? void 0 : t.recommendationConfigs) ?? {}, _ = o.isFeatureEnabled("linkTrackingIds"), O = {
|
|
112
|
+
partnerName: o.partnerName,
|
|
113
|
+
campaignUrls: e == null ? void 0 : e.recommendationCampaignUrls,
|
|
114
|
+
rrsEnabled: o.isFeatureEnabled("reusableRecommendationStrategy")
|
|
115
|
+
};
|
|
112
116
|
let n = {
|
|
113
|
-
html:
|
|
117
|
+
html: a && await G(a, P, O),
|
|
114
118
|
css: d
|
|
115
119
|
};
|
|
116
|
-
n.html || (n = await I(), n.html = await
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
preselectedDynamicContentList:
|
|
120
|
+
n.html || (n = await I(), n.html = await G(n.html, P, O));
|
|
121
|
+
const ne = _ ? z(n.html, (e == null ? void 0 : e.trackIdCounter) || 0) : 0;
|
|
122
|
+
U(n.html) && (n.html = await L(n.html)), _ && (c.trackIdSessionFloor = Math.max(ne, z(n.html)));
|
|
123
|
+
const re = {
|
|
124
|
+
preselectedDynamicContentList: A,
|
|
121
125
|
onReady: () => {
|
|
122
126
|
console.debug("guido:ready"), r("ready");
|
|
123
127
|
}
|
|
124
128
|
};
|
|
125
|
-
g =
|
|
129
|
+
g = T(), await k(n, y(), re), f.selectedDynamicContentList = A;
|
|
126
130
|
} catch (e) {
|
|
127
131
|
console.error("Failed to initialize Stripo editor:", e);
|
|
128
132
|
}
|
|
129
133
|
};
|
|
130
134
|
return se(async () => {
|
|
131
135
|
var e;
|
|
132
|
-
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), h().$reset(),
|
|
136
|
+
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), h().$reset(), $().$reset(), Re().$reset(), v();
|
|
133
137
|
const t = (e = p.value) == null ? void 0 : e.parentElement;
|
|
134
|
-
if (t && (i = new ResizeObserver(
|
|
138
|
+
if (t && (i = new ResizeObserver(v), i.observe(t)), F(), s.ready)
|
|
135
139
|
await b();
|
|
136
140
|
else {
|
|
137
|
-
const
|
|
138
|
-
d && (
|
|
141
|
+
const a = W(() => s.ready, (d) => {
|
|
142
|
+
d && (a(), b());
|
|
139
143
|
});
|
|
140
144
|
}
|
|
141
|
-
document.addEventListener("dynamic-content:open",
|
|
142
|
-
}),
|
|
143
|
-
i == null || i.disconnect(), document.removeEventListener("dynamic-content:open",
|
|
144
|
-
if (
|
|
145
|
+
document.addEventListener("dynamic-content:open", S);
|
|
146
|
+
}), ie(() => {
|
|
147
|
+
i == null || i.disconnect(), document.removeEventListener("dynamic-content:open", S), h().disposeStrategyPageReturn(), R(async () => {
|
|
148
|
+
if (M(g))
|
|
145
149
|
try {
|
|
146
150
|
window.UIEditor.removeEditor();
|
|
147
151
|
} catch {
|
|
148
152
|
console.debug("Failed to remove Stripo editor: No editor found");
|
|
149
153
|
}
|
|
150
154
|
}), o.reset();
|
|
151
|
-
}),
|
|
155
|
+
}), K({
|
|
152
156
|
dynamicContent: {
|
|
153
|
-
insert:
|
|
154
|
-
close:
|
|
157
|
+
insert: B,
|
|
158
|
+
close: N
|
|
155
159
|
},
|
|
156
160
|
hasChanges: l,
|
|
157
161
|
saveSilent: C,
|
|
158
162
|
setLoading: D
|
|
159
|
-
}), { __sfc: !0, PreviewContainer:
|
|
163
|
+
}), { __sfc: !0, PreviewContainer: V, OnboardingWrapper: j, AssignStrategyDrawer: J, RemoveStrategyModal: Q, LegacyStrategyUpdatedModal: X, headerWrapperRef: E, wrapperRef: p, dynamicContentStore: f, unsubscribeStore: w, props: s, configStore: o, editorStore: c, previewStore: Y, hasChanges: l, isTestPartner: Z, saveSilent: C, setLoading: D, emit: r, buildMetadata: y, initPlugin: k, preloadRuntime: F, runExclusive: R, beginMount: T, isCurrentMount: M, mountGeneration: g, getDefaultTemplate: I, cloneTimersOnSave: L, hasTimerBlocks: U, noHeader: ee, isRrsEnabled: te, hasAssignedStrategy: oe, insertDynamicContent: B, closeDynamicContent: N, handleDynamicContentOpen: S, ribbonObserver: i, updateRibbonOffset: v, startEditor: b, AutoSaveController: ge, Toaster: Se, FilterSelectionDrawer: ve, HeaderWrapper: be, LoadingWrapper: he, SaveAsTemplateDrawer: Ee, UnsubscribeWrapper: we };
|
|
160
164
|
}
|
|
161
165
|
});
|
|
162
166
|
export {
|
|
163
|
-
|
|
167
|
+
ot as default
|
|
164
168
|
};
|
|
@@ -9,15 +9,15 @@ var u = function() {
|
|
|
9
9
|
} } }), e(t.MigrationConfirmModal, { ref: "migrationModalRef", on: { confirm: function(r) {
|
|
10
10
|
return t.executeSave(!1);
|
|
11
11
|
} } })], 1);
|
|
12
|
-
},
|
|
12
|
+
}, c = [], p = /* @__PURE__ */ d(
|
|
13
13
|
l,
|
|
14
14
|
u,
|
|
15
|
-
|
|
15
|
+
c,
|
|
16
16
|
!1,
|
|
17
17
|
null,
|
|
18
|
-
"
|
|
18
|
+
"c61cc8ea"
|
|
19
19
|
);
|
|
20
|
-
const v =
|
|
20
|
+
const v = p.exports;
|
|
21
21
|
export {
|
|
22
22
|
v as default
|
|
23
23
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as q, ref as
|
|
1
|
+
import { defineComponent as q, ref as n, computed as x } from "vue";
|
|
2
2
|
import { useActionsApi as b } from "../../../composables/useActionsApi.js";
|
|
3
3
|
import { useConfig as k } from "../../../composables/useConfig.js";
|
|
4
4
|
import { useExport as B } from "../../../composables/useExport.js";
|
|
@@ -17,48 +17,46 @@ import { storeToRefs as Q } from "pinia";
|
|
|
17
17
|
import U from "./MigrationConfirmModal.vue.js";
|
|
18
18
|
const ft = /* @__PURE__ */ q({
|
|
19
19
|
__name: "EditorActions",
|
|
20
|
-
setup(W, { expose:
|
|
21
|
-
const { config:
|
|
20
|
+
setup(W, { expose: w }) {
|
|
21
|
+
const { config: l, isFeatureEnabled: m } = k(), { exportHtml: c } = B(), { save: p } = R(), { openVersionHistory: u, closeVersionHistory: f } = P(), { getCompiledEmail: d } = b(), { compileHtml: v } = L(), { validateLiquidSyntax: y } = j(), { handleError: r } = z(), e = G(), g = J(), { hasMigrations: S } = Q(g), s = I(), i = n(!1), a = n(!1), H = n(), h = D(), _ = () => {
|
|
22
22
|
if (e.isVersionHistoryOpen) {
|
|
23
|
-
|
|
23
|
+
f();
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
u();
|
|
27
27
|
}, C = async () => {
|
|
28
|
-
i.value = !0, await
|
|
28
|
+
i.value = !0, await c(), i.value = !1;
|
|
29
29
|
}, A = () => {
|
|
30
30
|
e.isSaveAsTemplateDrawerOpen = !0;
|
|
31
|
-
}, M =
|
|
31
|
+
}, M = x(() => e.isVersionHistoryOpen ? s("newsletter.close-version-history") : s("newsletter.version-history")), O = x(
|
|
32
32
|
() => {
|
|
33
33
|
var t, o;
|
|
34
|
-
return ((o = (t =
|
|
34
|
+
return ((o = (t = l.value) == null ? void 0 : t.features) == null ? void 0 : o.versionHistory) && !e.isPreviewModeOpen;
|
|
35
35
|
}
|
|
36
|
-
),
|
|
36
|
+
), V = async (t) => {
|
|
37
37
|
a.value = !0, t || (e.loadingStatus = !0);
|
|
38
38
|
let o;
|
|
39
39
|
try {
|
|
40
|
-
o = await
|
|
41
|
-
} catch (
|
|
42
|
-
|
|
43
|
-
throw n;
|
|
44
|
-
r(n, "Failed to save template");
|
|
40
|
+
o = await p(t);
|
|
41
|
+
} catch (T) {
|
|
42
|
+
r(T, "Failed to save template");
|
|
45
43
|
} finally {
|
|
46
44
|
a.value = !1, !t && !o && (e.loadingStatus = !1);
|
|
47
45
|
}
|
|
48
46
|
return o;
|
|
49
|
-
},
|
|
47
|
+
}, E = (t) => {
|
|
50
48
|
var o;
|
|
51
|
-
if (!t &&
|
|
52
|
-
(o =
|
|
49
|
+
if (!t && S.value) {
|
|
50
|
+
(o = H.value) == null || o.open();
|
|
53
51
|
return;
|
|
54
52
|
}
|
|
55
|
-
return
|
|
53
|
+
return V(t);
|
|
56
54
|
}, F = async () => {
|
|
57
|
-
if (
|
|
55
|
+
if (m("liquidSyntax")) {
|
|
58
56
|
e.loadingStatus = !0;
|
|
59
57
|
try {
|
|
60
|
-
const { html: t } = await
|
|
61
|
-
if (!await
|
|
58
|
+
const { html: t } = await d({ minimize: !0, resetDataSavedFlag: !1 }), { compiledHtml: o } = v(t);
|
|
59
|
+
if (!await y(o))
|
|
62
60
|
return;
|
|
63
61
|
} catch (t) {
|
|
64
62
|
r(t, "Failed to prepare test email");
|
|
@@ -67,11 +65,11 @@ const ft = /* @__PURE__ */ q({
|
|
|
67
65
|
e.loadingStatus = !1;
|
|
68
66
|
}
|
|
69
67
|
}
|
|
70
|
-
|
|
68
|
+
h();
|
|
71
69
|
};
|
|
72
|
-
return
|
|
73
|
-
handleSave:
|
|
74
|
-
}), { __sfc: !0, config:
|
|
70
|
+
return w({
|
|
71
|
+
handleSave: E
|
|
72
|
+
}), { __sfc: !0, config: l, isFeatureEnabled: m, exportHtml: c, save: p, openVersionHistory: u, closeVersionHistory: f, getCompiledEmail: d, compileHtml: v, validateLiquidSyntax: y, handleError: r, editorStore: e, templateStore: g, hasMigrations: S, trans: s, isExporting: i, isSaving: a, migrationModalRef: H, testEmailClick: h, handleVersionHistory: _, handleExport: C, handleSaveAs: A, versionHistoryTooltipText: M, isVersionHistoryButtonVisible: O, executeSave: V, handleSave: E, handleTestEmail: F, getTooltipOptions: K, InButtonV2: N, MigrationConfirmModal: U };
|
|
75
73
|
}
|
|
76
74
|
});
|
|
77
75
|
export {
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import { filterAmpErrors as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { filterAmpErrors as y } from "../utils/ampErrorFilter.js";
|
|
2
|
+
import { getEditorApi as s } from "../utils/stripoEditorApi.js";
|
|
3
|
+
import { useToaster as D } from "./useToaster.js";
|
|
4
|
+
const h = 1e4, T = 3e4, r = (n, l, A) => new Promise((C, p) => {
|
|
5
|
+
const f = setTimeout(
|
|
6
|
+
() => p(new Error(`${n} did not report completion within ${l}ms`)),
|
|
6
7
|
l
|
|
7
|
-
),
|
|
8
|
-
clearTimeout(
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
), c = (t) => (e) => {
|
|
9
|
+
clearTimeout(f), t(e);
|
|
10
|
+
}, d = c(p);
|
|
11
|
+
try {
|
|
12
|
+
A(c(C), d);
|
|
13
|
+
} catch (t) {
|
|
14
|
+
d(t);
|
|
15
|
+
}
|
|
16
|
+
}), P = () => {
|
|
17
|
+
const { handleError: n } = D(), l = (t = {}) => r(
|
|
13
18
|
"compileEmail",
|
|
14
|
-
|
|
15
|
-
(e,
|
|
19
|
+
T,
|
|
20
|
+
(e, i) => {
|
|
16
21
|
const o = { ...{
|
|
17
22
|
minimize: !0,
|
|
18
23
|
utmEntity: {
|
|
@@ -32,53 +37,53 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
|
|
|
32
37
|
forceAmp: !1,
|
|
33
38
|
resetDataSavedFlag: !1,
|
|
34
39
|
disableLineHeightsReplace: !0
|
|
35
|
-
}, ...t },
|
|
36
|
-
callback: (
|
|
37
|
-
|
|
38
|
-
html:
|
|
39
|
-
ampHtml:
|
|
40
|
-
ampErrors:
|
|
41
|
-
displayConditions:
|
|
40
|
+
}, ...t }, u = {
|
|
41
|
+
callback: (m, g, w, S, v) => {
|
|
42
|
+
m ? i(m) : e({
|
|
43
|
+
html: g,
|
|
44
|
+
ampHtml: w,
|
|
45
|
+
ampErrors: y(S ?? []),
|
|
46
|
+
displayConditions: v
|
|
42
47
|
});
|
|
43
48
|
},
|
|
44
49
|
...o
|
|
45
50
|
};
|
|
46
|
-
|
|
51
|
+
s().actionsApi.compileEmail(u);
|
|
47
52
|
}
|
|
48
53
|
);
|
|
49
54
|
return {
|
|
50
55
|
getCompiledEmail: l,
|
|
51
|
-
getTemplateData: () =>
|
|
56
|
+
getTemplateData: () => r(
|
|
52
57
|
"getTemplateData",
|
|
53
|
-
|
|
58
|
+
T,
|
|
54
59
|
(t) => {
|
|
55
|
-
const e = ({ html:
|
|
56
|
-
html:
|
|
57
|
-
css:
|
|
60
|
+
const e = ({ html: i, css: a, width: o, height: E, utmParams: u, syncModulesIds: m }) => t({
|
|
61
|
+
html: i,
|
|
62
|
+
css: a,
|
|
58
63
|
width: o,
|
|
59
64
|
height: E,
|
|
60
|
-
utmParams:
|
|
61
|
-
syncModulesIds:
|
|
65
|
+
utmParams: u,
|
|
66
|
+
syncModulesIds: m
|
|
62
67
|
});
|
|
63
|
-
|
|
68
|
+
s().actionsApi.getTemplateData(e);
|
|
64
69
|
}
|
|
65
70
|
),
|
|
66
71
|
activateCustomViewStyles: (t = !0) => {
|
|
67
|
-
|
|
72
|
+
s().actionsApi.activateCustomViewStyles(t);
|
|
68
73
|
},
|
|
69
74
|
getPreviewData: async (t) => {
|
|
70
75
|
try {
|
|
71
76
|
const {
|
|
72
77
|
html: e,
|
|
73
|
-
displayConditions:
|
|
74
|
-
ampHtml:
|
|
78
|
+
displayConditions: i,
|
|
79
|
+
ampHtml: a = "",
|
|
75
80
|
ampErrors: o = []
|
|
76
81
|
} = await l({ minimize: !1, resetDataSavedFlag: !1, ...t });
|
|
77
82
|
return {
|
|
78
83
|
html: e,
|
|
79
|
-
ampHtml:
|
|
84
|
+
ampHtml: a,
|
|
80
85
|
ampErrors: o,
|
|
81
|
-
displayConditions:
|
|
86
|
+
displayConditions: i
|
|
82
87
|
};
|
|
83
88
|
} catch (e) {
|
|
84
89
|
return n(e, "Error loading preview"), {
|
|
@@ -90,30 +95,30 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
|
|
|
90
95
|
}
|
|
91
96
|
},
|
|
92
97
|
updateTimerInClonedTemplate: () => new Promise((t) => {
|
|
93
|
-
var e,
|
|
94
|
-
if (typeof ((
|
|
98
|
+
var e, i;
|
|
99
|
+
if (typeof ((i = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : i.updateTimerInClonedTemplate) != "function") {
|
|
95
100
|
t(null);
|
|
96
101
|
return;
|
|
97
102
|
}
|
|
98
103
|
try {
|
|
99
|
-
window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((
|
|
100
|
-
|
|
104
|
+
window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((a, o) => {
|
|
105
|
+
a ? (n(a, "Failed to update timer in cloned template"), t(null)) : t(o || null);
|
|
101
106
|
});
|
|
102
|
-
} catch (
|
|
103
|
-
n(
|
|
107
|
+
} catch (a) {
|
|
108
|
+
n(a, "Failed to call updateTimerInClonedTemplate"), t(null);
|
|
104
109
|
}
|
|
105
110
|
}),
|
|
106
111
|
updateHtmlAndCss: (t, e) => {
|
|
107
|
-
const { actionsApi:
|
|
108
|
-
return
|
|
109
|
-
|
|
112
|
+
const { actionsApi: i } = s();
|
|
113
|
+
return r("updateHtmlAndCss", h, (a) => {
|
|
114
|
+
i.updateHtmlAndCss(t, e, () => a());
|
|
110
115
|
});
|
|
111
116
|
},
|
|
112
|
-
editorSave: () =>
|
|
117
|
+
editorSave: () => r(
|
|
113
118
|
"save",
|
|
114
|
-
|
|
119
|
+
T,
|
|
115
120
|
(t) => {
|
|
116
|
-
|
|
121
|
+
s().actionsApi.save((e) => {
|
|
117
122
|
if (e) {
|
|
118
123
|
n(e, "Failed to save template"), t(!1);
|
|
119
124
|
return;
|
|
@@ -125,5 +130,5 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
|
|
|
125
130
|
};
|
|
126
131
|
};
|
|
127
132
|
export {
|
|
128
|
-
|
|
133
|
+
P as useActionsApi
|
|
129
134
|
};
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { ToasterTypeOptions as d } from "../enums/toaster.js";
|
|
2
|
+
import { findEditorApi as s, EDITOR_NOT_READY_MESSAGE as p } from "../utils/stripoEditorApi.js";
|
|
3
|
+
import { useToaster as E } from "./useToaster.js";
|
|
4
|
+
const T = () => {
|
|
5
|
+
const { showToaster: i } = E(), t = (o) => {
|
|
6
|
+
var r;
|
|
7
|
+
const e = (r = s()) == null ? void 0 : r.codeEditorApi;
|
|
8
|
+
if (!e) {
|
|
9
|
+
i({ type: d.Error, message: p });
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
o(e);
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
openCodeEditor: () => {
|
|
16
|
+
t((o) => o.openCodeEditor());
|
|
17
|
+
},
|
|
18
|
+
closeCodeEditor: () => {
|
|
19
|
+
t((o) => o.closeCodeEditor());
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
9
23
|
export {
|
|
10
|
-
|
|
24
|
+
T as useCodeEditorApi
|
|
11
25
|
};
|
|
@@ -6,9 +6,10 @@ import { useConfig } from "./useConfig.js";
|
|
|
6
6
|
const useTranslations = () => {
|
|
7
7
|
var o, e;
|
|
8
8
|
const { config } = useConfig(), translationsPath = ((e = (o = config.value) == null ? void 0 : o.editor) == null ? void 0 : e.translationsPath) || DEFAULT_EDITOR.translationsPath, translations = ref(eval(translationsPath)), trans = (t, n) => {
|
|
9
|
-
|
|
9
|
+
var s;
|
|
10
|
+
const r = (s = translations.value) == null ? void 0 : s[t];
|
|
10
11
|
return r ? n ? Object.entries(n).reduce(
|
|
11
|
-
(
|
|
12
|
+
(i, [a, l]) => i.replace(new RegExp(`{${a}}`, "g"), String(l)),
|
|
12
13
|
r
|
|
13
14
|
) : r : (console.warn(`Translation key not found: ${t}`), t);
|
|
14
15
|
};
|