@useinsider/guido 2.1.0-beta.235b052 → 2.1.0-beta.25c1ef4
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/README.md +3 -1
- package/dist/composables/useSave.js +16 -12
- package/dist/composables/useStripo.js +58 -54
- package/dist/composables/useStripoEventHandler.js +27 -12
- package/dist/composables/useSyncModuleExtractor.js +33 -0
- package/dist/config/migrator/itemsBlockMigrator.js +127 -122
- package/dist/enums/unsubscribe.js +25 -21
- package/dist/services/stripoApi.js +56 -17
- package/dist/src/@types/events.d.ts +34 -2
- package/dist/src/composables/useSyncModuleExtractor.d.ts +4 -0
- package/dist/src/enums/unsubscribe.d.ts +3 -0
- package/dist/src/mock/api/settings.d.ts +2 -0
- package/dist/src/services/stripoApi.d.ts +5 -0
- package/dist/src/stores/editor.d.ts +23 -0
- package/dist/static/templates/empty/index.html.js +74 -0
- package/dist/static/templates/empty/style.css.js +779 -0
- package/dist/stores/editor.js +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://www.youtube.com/shorts/Y0RwBeMezL4" target="_blank" rel="noopener noreferrer">
|
|
3
|
-
<img width="180"
|
|
3
|
+
<img width="180"
|
|
4
|
+
src="https://web-image.useinsider.com/guido/defaultImageLibrary/iUH0liTK0d2YDsVB5LDN1770169173.jpg"
|
|
5
|
+
alt="Guido logo">
|
|
4
6
|
</a>
|
|
5
7
|
</p>
|
|
6
8
|
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useSaveStart as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { useConfig as u } from "./useConfig.js";
|
|
2
|
+
import { useSaveStart as d, useSaveComplete as p } from "./useGuidoActions.js";
|
|
3
|
+
import { useSyncModuleExtractor as f } from "./useSyncModuleExtractor.js";
|
|
4
|
+
import { useStripoApi as v } from "../services/stripoApi.js";
|
|
5
|
+
import { useTemplatePreparation as S } from "../utils/templatePreparation.js";
|
|
6
|
+
import { useHtmlValidator as x } from "./useHtmlValidator.js";
|
|
7
|
+
const E = () => {
|
|
8
|
+
const o = d(), s = p(), { validateHtml: i } = x(), { callbacks: a } = u(), { extractSyncModuleUnsubscribeData: r } = f(), { setSyncModuleUnsubscriptionPages: n } = v();
|
|
9
|
+
return { save: async (l = !1) => {
|
|
8
10
|
var e;
|
|
9
|
-
|
|
10
|
-
const { prepareTemplateDetails:
|
|
11
|
-
if (await
|
|
12
|
-
return
|
|
11
|
+
o();
|
|
12
|
+
const { prepareTemplateDetails: c } = S(), t = await c();
|
|
13
|
+
if (!await i(t.compiledHtml, t.dynamicContentList, !0) || (e = a.value) != null && e.externalValidation && !await a.value.externalValidation(t))
|
|
14
|
+
return;
|
|
15
|
+
const m = r(t.rawHtml);
|
|
16
|
+
return await n(m), l || s(t), t;
|
|
13
17
|
} };
|
|
14
18
|
};
|
|
15
19
|
export {
|
|
16
|
-
|
|
20
|
+
E as useSave
|
|
17
21
|
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useBlocksConfig as
|
|
3
|
-
import { useConfig as
|
|
4
|
-
import { useCustomInterfaceAppearance as
|
|
5
|
-
import { useStripoEventHandler as
|
|
6
|
-
import { useToaster as
|
|
7
|
-
import { displayConditions as
|
|
8
|
-
import { useStripoApi as
|
|
9
|
-
import
|
|
10
|
-
import { useEditorStore as
|
|
11
|
-
import { dynamicContentToMergeTags as
|
|
12
|
-
import
|
|
13
|
-
const
|
|
14
|
-
const { features: l, template:
|
|
15
|
-
var
|
|
16
|
-
const
|
|
1
|
+
import { useActionsApi as M } from "./useActionsApi.js";
|
|
2
|
+
import { useBlocksConfig as A } from "./useBlocksConfig.js";
|
|
3
|
+
import { useConfig as F } from "./useConfig.js";
|
|
4
|
+
import { useCustomInterfaceAppearance as D } from "./useCustomInterfaceAppearance.js";
|
|
5
|
+
import { useStripoEventHandler as I } from "./useStripoEventHandler.js";
|
|
6
|
+
import { useToaster as U } from "./useToaster.js";
|
|
7
|
+
import { displayConditions as P } from "../enums/displayConditions.js";
|
|
8
|
+
import { useStripoApi as R } from "../services/stripoApi.js";
|
|
9
|
+
import H from "../static/styles/customEditorStyle.css.js";
|
|
10
|
+
import { useEditorStore as S } from "../stores/editor.js";
|
|
11
|
+
import { dynamicContentToMergeTags as O } from "../utils/genericUtil.js";
|
|
12
|
+
import q from "../package.json.js";
|
|
13
|
+
const Z = (c) => {
|
|
14
|
+
const { features: l, template: C } = F(), { handleError: u } = U(), { getToken: E, getCustomFonts: h, getSyncModulesStatus: w } = R(), { handleEvent: b } = I(), { getStripoBlocksConfig: k } = A(), T = async (i, n = [], r = !1) => {
|
|
15
|
+
var g, f, y;
|
|
16
|
+
const e = S(), { html: p, css: a } = i, { baseBlocks: t, extensions: d } = await k(), m = ((g = l.value) == null ? void 0 : g.displayConditions) ?? !0, _ = ((f = l.value) == null ? void 0 : f.modulesDisabled) ?? !1, B = ((y = C.value) == null ? void 0 : y.forceRecreate) ?? !1;
|
|
17
17
|
window.UIEditor.initEditor(
|
|
18
18
|
document.querySelector("#guido-editor"),
|
|
19
19
|
{
|
|
20
20
|
metadata: c,
|
|
21
|
-
html:
|
|
22
|
-
css:
|
|
23
|
-
forceRecreate:
|
|
21
|
+
html: p,
|
|
22
|
+
css: a,
|
|
23
|
+
forceRecreate: B,
|
|
24
24
|
locale: "en",
|
|
25
25
|
undoButtonSelector: "#guido__undo-button",
|
|
26
26
|
redoButtonSelector: "#guido__redo-button",
|
|
@@ -30,19 +30,20 @@ const W = (c) => {
|
|
|
30
30
|
customAppearanceMergetags: !0,
|
|
31
31
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
32
32
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
33
|
-
customViewStyles:
|
|
34
|
-
conditionsEnabled:
|
|
35
|
-
customConditionsEnabled:
|
|
36
|
-
conditionCategories:
|
|
33
|
+
customViewStyles: H,
|
|
34
|
+
conditionsEnabled: m,
|
|
35
|
+
customConditionsEnabled: m,
|
|
36
|
+
conditionCategories: P,
|
|
37
37
|
enableXSSSecurity: !0,
|
|
38
|
-
modulesDisabled:
|
|
38
|
+
modulesDisabled: _,
|
|
39
|
+
syncModulesEnabled: r,
|
|
39
40
|
messageSettingsEnabled: !0,
|
|
40
41
|
displayGmailAnnotations: !0,
|
|
41
42
|
displayHiddenPreheader: !1,
|
|
42
43
|
displayTitle: !1,
|
|
43
44
|
displayUTM: !1,
|
|
44
45
|
selectElementAfterDrop: !0,
|
|
45
|
-
...
|
|
46
|
+
...t ? { baseBlocks: t } : {},
|
|
46
47
|
editorFonts: {
|
|
47
48
|
showDefaultStandardFonts: !0,
|
|
48
49
|
showDefaultNotStandardFonts: !0,
|
|
@@ -50,68 +51,71 @@ const W = (c) => {
|
|
|
50
51
|
},
|
|
51
52
|
mergeTags: [
|
|
52
53
|
{
|
|
53
|
-
entries:
|
|
54
|
+
entries: O(c.preselectedDynamicContentList)
|
|
54
55
|
}
|
|
55
56
|
],
|
|
56
|
-
async onTokenRefreshRequest(
|
|
57
|
+
async onTokenRefreshRequest(o) {
|
|
57
58
|
try {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
} catch (
|
|
61
|
-
u(
|
|
59
|
+
const s = await E();
|
|
60
|
+
o(s);
|
|
61
|
+
} catch (s) {
|
|
62
|
+
u(s, "Failed to refresh token");
|
|
62
63
|
}
|
|
63
64
|
},
|
|
64
65
|
onTemplateLoaded() {
|
|
65
66
|
try {
|
|
66
|
-
const { importCss:
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
const { importCss: o } = D(), { activateCustomViewStyles: s, updateTimerInClonedTemplate: v } = M();
|
|
68
|
+
o(), s(), v(), c.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
|
|
69
|
+
e.hasChanges = !1;
|
|
69
70
|
}, 1e3);
|
|
70
|
-
} catch (
|
|
71
|
-
u(
|
|
71
|
+
} catch (o) {
|
|
72
|
+
u(o, "Failed to load custom interface appearance");
|
|
72
73
|
}
|
|
73
74
|
},
|
|
74
|
-
onCodeEditorVisibilityChanged(
|
|
75
|
-
|
|
75
|
+
onCodeEditorVisibilityChanged(o) {
|
|
76
|
+
e.isCodeEditorOpen = o;
|
|
76
77
|
},
|
|
77
|
-
onEditorVisualModeChanged(
|
|
78
|
-
|
|
78
|
+
onEditorVisualModeChanged(o) {
|
|
79
|
+
e.editorVisualMode = o.toLowerCase();
|
|
79
80
|
},
|
|
80
|
-
onVersionHistoryVisibilityChanged(
|
|
81
|
-
|
|
81
|
+
onVersionHistoryVisibilityChanged(o) {
|
|
82
|
+
e.isVersionHistoryOpen = o;
|
|
82
83
|
},
|
|
83
84
|
onDataChanged() {
|
|
84
|
-
|
|
85
|
+
e.hasChanges = !0;
|
|
85
86
|
},
|
|
86
|
-
onEvent:
|
|
87
|
+
onEvent: b,
|
|
87
88
|
ignoreClickOutsideSelectors: [
|
|
88
89
|
"#guido-dynamic-content-modal",
|
|
89
90
|
".in-on-board-wrapper",
|
|
90
91
|
".in-drawer__container"
|
|
91
92
|
],
|
|
92
|
-
extensions:
|
|
93
|
+
extensions: d
|
|
93
94
|
}
|
|
94
95
|
);
|
|
95
|
-
},
|
|
96
|
-
var
|
|
96
|
+
}, V = (i) => new Promise((n, r) => {
|
|
97
|
+
var d;
|
|
97
98
|
if (document.getElementById("UiEditorScript")) {
|
|
98
99
|
i(), n();
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
101
|
-
const
|
|
102
|
-
t.id = "UiEditorScript", t.type = "module", t.src =
|
|
102
|
+
const e = q.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
|
|
103
|
+
t.id = "UiEditorScript", t.type = "module", t.src = a, t.onload = () => {
|
|
103
104
|
i(), n();
|
|
104
105
|
}, t.onerror = () => {
|
|
105
|
-
|
|
106
|
+
r(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
|
|
106
107
|
}, document.body.appendChild(t);
|
|
107
108
|
});
|
|
108
109
|
return { initPlugin: async (i) => {
|
|
109
|
-
await
|
|
110
|
-
const n = await
|
|
111
|
-
|
|
110
|
+
await V(async () => {
|
|
111
|
+
const n = S(), [r, e] = await Promise.all([
|
|
112
|
+
h(),
|
|
113
|
+
w()
|
|
114
|
+
]);
|
|
115
|
+
n.syncModulesEnabled = e, await T(i, r, e);
|
|
112
116
|
});
|
|
113
117
|
} };
|
|
114
118
|
};
|
|
115
119
|
export {
|
|
116
|
-
|
|
120
|
+
Z as useStripo
|
|
117
121
|
};
|
|
@@ -1,20 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { useStripoApi as i } from "../services/stripoApi.js";
|
|
2
|
+
import { useEditorStore as u } from "../stores/editor.js";
|
|
3
|
+
import { useOnboardingStore as l } from "../stores/onboarding.js";
|
|
4
|
+
import { useUnsubscribeStore as b } from "../stores/unsubscribe.js";
|
|
5
|
+
const v = () => {
|
|
6
|
+
const { updateSyncModule: d, getSyncModule: r } = i(), n = u(), s = b(), a = {
|
|
7
|
+
block_dropped: ({ blockName: e }) => {
|
|
8
|
+
if (e === "BLOCK_TEXT") {
|
|
9
|
+
const o = l(), t = !o.shouldShowOnboarding("textBlockOnboarding"), c = o.isActive("textBlockOnboarding");
|
|
10
|
+
if (t || c)
|
|
8
11
|
return;
|
|
9
|
-
|
|
12
|
+
o.start("textBlockOnboarding");
|
|
10
13
|
}
|
|
14
|
+
},
|
|
15
|
+
module_saved: async (e) => {
|
|
16
|
+
n.syncModulesEnabled && (console.debug("[module_saved] Saved module data:", e), await d(e));
|
|
17
|
+
},
|
|
18
|
+
module_dropped: async (e) => {
|
|
19
|
+
if (!n.syncModulesEnabled)
|
|
20
|
+
return;
|
|
21
|
+
const { moduleId: o } = e, t = await r(o);
|
|
22
|
+
console.debug("[module_dropped] Sync module data:", t), t.unsubscriptionPreferencePages.length && await s.fetchTemplates();
|
|
23
|
+
},
|
|
24
|
+
module_updated: async (e) => {
|
|
25
|
+
n.syncModulesEnabled && (console.debug("[module_updated] Updated module data:", e), await d(e));
|
|
11
26
|
}
|
|
12
27
|
};
|
|
13
|
-
return { handleEvent: async (
|
|
14
|
-
const
|
|
15
|
-
o && await o
|
|
28
|
+
return { handleEvent: async (e, o) => {
|
|
29
|
+
const t = a[e];
|
|
30
|
+
console.debug("Stripo Event: ", e, o), t && await t(o);
|
|
16
31
|
} };
|
|
17
32
|
};
|
|
18
33
|
export {
|
|
19
|
-
|
|
34
|
+
v as useStripoEventHandler
|
|
20
35
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { UNSUBSCRIBE_SYNC_MODULE_TYPES as S } from "../enums/unsubscribe.js";
|
|
2
|
+
import { DATA_ATTRIBUTES as a } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
3
|
+
import { useEditorStore as d } from "../stores/editor.js";
|
|
4
|
+
const T = ".esd-synchronizable-module", m = '[esd-extension-block-id="unsubscribe-block"]', A = "esd-custom-block-id", M = () => {
|
|
5
|
+
const l = d();
|
|
6
|
+
return { extractSyncModuleUnsubscribeData: (p) => {
|
|
7
|
+
if (!l.syncModulesEnabled)
|
|
8
|
+
return [];
|
|
9
|
+
const E = new DOMParser().parseFromString(p, "text/html").querySelectorAll(T), e = [];
|
|
10
|
+
return E.forEach((r) => {
|
|
11
|
+
const s = r.getAttribute(A);
|
|
12
|
+
if (!s)
|
|
13
|
+
return;
|
|
14
|
+
r.querySelectorAll(m).forEach((o) => {
|
|
15
|
+
const n = o.getAttribute(a.PAGE_LIST), c = o.getAttribute(a.PAGE_TYPE);
|
|
16
|
+
if (!n || !c)
|
|
17
|
+
return;
|
|
18
|
+
const b = parseInt(c), u = S[b];
|
|
19
|
+
if (!u)
|
|
20
|
+
return;
|
|
21
|
+
const i = n.split(",").map((t) => parseInt(t.trim())).filter((t) => !Number.isNaN(t));
|
|
22
|
+
i.length !== 0 && e.push({
|
|
23
|
+
stripoModuleId: s,
|
|
24
|
+
unsubscriptionPreferencePages: i,
|
|
25
|
+
type: u
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}), e;
|
|
29
|
+
} };
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
M as useSyncModuleExtractor
|
|
33
|
+
};
|