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