@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 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" src="./public/guido.png" alt="Guido logo">
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 l } from "./useConfig.js";
2
- import { useSaveStart as m, useSaveComplete as c } from "./useGuidoActions.js";
3
- import { useTemplatePreparation as d } from "../utils/templatePreparation.js";
4
- import { useHtmlValidator as p } from "./useHtmlValidator.js";
5
- const w = () => {
6
- const i = m(), s = c(), { validateHtml: o } = p(), { callbacks: a } = l();
7
- return { save: async (r = !1) => {
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
- i();
10
- const { prepareTemplateDetails: n } = d(), t = await n();
11
- if (await o(t.compiledHtml, t.dynamicContentList, !0) && !((e = a.value) != null && e.externalValidation && !await a.value.externalValidation(t)))
12
- return r || s(t), t;
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
- w as useSave
20
+ E as useSave
17
21
  };
@@ -1,26 +1,26 @@
1
- import { useActionsApi as _ } from "./useActionsApi.js";
2
- import { useBlocksConfig as B } from "./useBlocksConfig.js";
3
- import { useConfig as v } from "./useConfig.js";
4
- import { useCustomInterfaceAppearance as A } from "./useCustomInterfaceAppearance.js";
5
- import { useStripoEventHandler as F } from "./useStripoEventHandler.js";
6
- import { useToaster as D } from "./useToaster.js";
7
- import { displayConditions as I } from "../enums/displayConditions.js";
8
- import { useStripoApi as M } from "../services/stripoApi.js";
9
- import U from "../static/styles/customEditorStyle.css.js";
10
- import { useEditorStore as P } from "../stores/editor.js";
11
- import { dynamicContentToMergeTags as R } from "../utils/genericUtil.js";
12
- import H from "../package.json.js";
13
- const W = (c) => {
14
- const { features: l, template: y } = v(), { handleError: u } = D(), { getToken: C, getCustomFonts: S } = M(), { handleEvent: E } = F(), { getStripoBlocksConfig: h } = B(), w = async (i, n = []) => {
15
- var m, g, f;
16
- const o = P(), { html: r, css: p } = i, { baseBlocks: s, extensions: t } = await h(), a = ((m = l.value) == null ? void 0 : m.displayConditions) ?? !0, k = ((g = l.value) == null ? void 0 : g.modulesDisabled) ?? !1, T = ((f = y.value) == null ? void 0 : f.forceRecreate) ?? !1;
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: r,
22
- css: p,
23
- forceRecreate: T,
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: U,
34
- conditionsEnabled: a,
35
- customConditionsEnabled: a,
36
- conditionCategories: I,
33
+ customViewStyles: H,
34
+ conditionsEnabled: m,
35
+ customConditionsEnabled: m,
36
+ conditionCategories: P,
37
37
  enableXSSSecurity: !0,
38
- modulesDisabled: k,
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
- ...s ? { baseBlocks: s } : {},
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: R(c.preselectedDynamicContentList)
54
+ entries: O(c.preselectedDynamicContentList)
54
55
  }
55
56
  ],
56
- async onTokenRefreshRequest(e) {
57
+ async onTokenRefreshRequest(o) {
57
58
  try {
58
- const d = await C();
59
- e(d);
60
- } catch (d) {
61
- u(d, "Failed to refresh token");
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: e } = A(), { activateCustomViewStyles: d, updateTimerInClonedTemplate: V } = _();
67
- e(), d(), V(), c.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
68
- o.hasChanges = !1;
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 (e) {
71
- u(e, "Failed to load custom interface appearance");
71
+ } catch (o) {
72
+ u(o, "Failed to load custom interface appearance");
72
73
  }
73
74
  },
74
- onCodeEditorVisibilityChanged(e) {
75
- o.isCodeEditorOpen = e;
75
+ onCodeEditorVisibilityChanged(o) {
76
+ e.isCodeEditorOpen = o;
76
77
  },
77
- onEditorVisualModeChanged(e) {
78
- o.editorVisualMode = e.toLowerCase();
78
+ onEditorVisualModeChanged(o) {
79
+ e.editorVisualMode = o.toLowerCase();
79
80
  },
80
- onVersionHistoryVisibilityChanged(e) {
81
- o.isVersionHistoryOpen = e;
81
+ onVersionHistoryVisibilityChanged(o) {
82
+ e.isVersionHistoryOpen = o;
82
83
  },
83
84
  onDataChanged() {
84
- o.hasChanges = !0;
85
+ e.hasChanges = !0;
85
86
  },
86
- onEvent: E,
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: t
93
+ extensions: d
93
94
  }
94
95
  );
95
- }, b = (i) => new Promise((n, o) => {
96
- var a;
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 r = H.guido, s = `https://email-static.useinsider.com/guido/${(a = r == null ? void 0 : r.stripo) == null ? void 0 : a.version}/UIEditor.js`, t = document.createElement("script");
102
- t.id = "UiEditorScript", t.type = "module", t.src = s, t.onload = () => {
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
- o(new Error(`Failed to load Stripo UIEditor script from S3: ${s}`));
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 b(async () => {
110
- const n = await S();
111
- await w(i, n);
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
- W as useStripo
120
+ Z as useStripo
117
121
  };
@@ -1,20 +1,35 @@
1
- import { useOnboardingStore as i } from "../stores/onboarding.js";
2
- const c = () => {
3
- const e = {
4
- block_dropped: ({ blockName: t }) => {
5
- if (t === "BLOCK_TEXT") {
6
- const n = i(), o = !n.shouldShowOnboarding("textBlockOnboarding"), r = n.isActive("textBlockOnboarding");
7
- if (o || r)
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
- n.start("textBlockOnboarding");
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 (t, n) => {
14
- const o = e[t];
15
- o && await o(n);
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
- c as useStripoEventHandler
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
+ };