@useinsider/guido 3.17.0-beta.58179dc → 3.17.0-beta.db80c84

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.
@@ -17,13 +17,13 @@ import { buildMergeTagEntries as W, flattenDynamicContentList as Y } from "../ut
17
17
  import Z from "../package.json.js";
18
18
  let n = null;
19
19
  const Ce = () => {
20
- const { features: c, template: u, isFeatureEnabled: m } = q(), { handleError: p, showToaster: k } = G(), { getToken: M, getCustomFonts: T, getSyncModulesStatus: v } = K(), { handleEvent: B } = z(), { handleModuleAdd: F } = j(), { getStripoBlocksConfig: A } = O(), { getStripoNotifications: V } = $(), f = () => n || (n = new Promise((i, s) => {
21
- var l;
20
+ const { features: c, template: u, isFeatureEnabled: m } = q(), { handleError: p, showToaster: k } = G(), { getToken: B, getCustomFonts: M, getSyncModulesStatus: T } = K(), { handleEvent: v } = z(), { handleModuleAdd: F } = j(), { getStripoBlocksConfig: A } = O(), { getStripoNotifications: V } = $(), f = () => n || (n = new Promise((i, s) => {
21
+ var d;
22
22
  if (document.getElementById("UiEditorScript")) {
23
23
  i();
24
24
  return;
25
25
  }
26
- const o = Z.guido, r = `https://email-static.useinsider.com/guido/${(l = o == null ? void 0 : o.stripo) == null ? void 0 : l.version}/UIEditor.js`, e = document.createElement("script");
26
+ const o = Z.guido, r = `https://email-static.useinsider.com/guido/${(d = o == null ? void 0 : o.stripo) == null ? void 0 : d.version}/UIEditor.js`, e = document.createElement("script");
27
27
  e.id = "UiEditorScript", e.type = "module", e.src = r, e.onload = () => i(), e.onerror = () => {
28
28
  e.remove(), s(new Error(`Failed to load Stripo UIEditor script from S3: ${r}`));
29
29
  }, document.body.appendChild(e);
@@ -31,12 +31,12 @@ const Ce = () => {
31
31
  n = null;
32
32
  }), n), _ = async (i, s, o, a = [], r = !1) => {
33
33
  var y, E, h, C;
34
- const e = b(), { html: l, css: D } = i, { baseBlocks: g, extensions: R } = await A(), S = ((y = c.value) == null ? void 0 : y.displayConditions) ?? !0, P = ((E = c.value) == null ? void 0 : E.modulesDisabled) ?? !1, U = ((h = u.value) == null ? void 0 : h.forceRecreate) ?? !1;
34
+ const e = b(), { html: d, css: D } = i, { baseBlocks: g, extensions: R } = await A(), S = ((y = c.value) == null ? void 0 : y.displayConditions) ?? !0, P = ((E = c.value) == null ? void 0 : E.modulesDisabled) ?? !1, U = !!d || (((h = u.value) == null ? void 0 : h.forceRecreate) ?? !1);
35
35
  await window.UIEditor.initEditor(
36
36
  document.querySelector("#guido-editor"),
37
37
  {
38
38
  metadata: s,
39
- html: l,
39
+ html: d,
40
40
  css: D,
41
41
  forceRecreate: U,
42
42
  locale: "en",
@@ -80,16 +80,16 @@ const Ce = () => {
80
80
  ],
81
81
  async onTokenRefreshRequest(t) {
82
82
  try {
83
- const d = await M();
84
- t(d);
85
- } catch (d) {
86
- p(d, "Failed to refresh token");
83
+ const l = await B();
84
+ t(l);
85
+ } catch (l) {
86
+ p(l, "Failed to refresh token");
87
87
  }
88
88
  },
89
89
  onTemplateLoaded() {
90
90
  try {
91
- const { importCss: t } = H(), { activateCustomViewStyles: d, updateTimerInClonedTemplate: I } = L(), { injectFullStory: x } = N();
92
- t(), d(), x(), I(), o.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
91
+ const { importCss: t } = H(), { activateCustomViewStyles: l, updateTimerInClonedTemplate: I } = L(), { injectFullStory: x } = N();
92
+ t(), l(), x(), I(), o.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
93
93
  e.hasChanges = !1;
94
94
  }, 1e3);
95
95
  } catch (t) {
@@ -108,7 +108,7 @@ const Ce = () => {
108
108
  onDataChanged() {
109
109
  e.hasChanges = !0;
110
110
  },
111
- onEvent: B,
111
+ onEvent: v,
112
112
  onModuleAdd: F,
113
113
  notifications: V(),
114
114
  ignoreClickOutsideSelectors: [
@@ -126,8 +126,8 @@ const Ce = () => {
126
126
  try {
127
127
  await f();
128
128
  const [r, e] = await Promise.all([
129
- T(),
130
- v()
129
+ M(),
130
+ T()
131
131
  ]);
132
132
  a.syncModulesEnabled = e, await _(i, s, o, r, e);
133
133
  } catch {
@@ -1,21 +1,18 @@
1
- var A = Object.defineProperty;
2
- var C = (a, c, t) => c in a ? A(a, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[c] = t;
3
- var h = (a, c, t) => C(a, typeof c != "symbol" ? c + "" : c, t);
4
- import { BlockId as y } from "../../../enums/block.js";
5
- import { getMigrationBannerHtml as R } from "../../../utils/migrationBannerHtml.js";
6
- import { Block as B, BlockCompositionType as E, ModificationDescription as g } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
- import { RecommendationBlockId as T } from "./constants/blockIds.js";
8
- import { CSS_CLASS_SKIP_COMPILE as D, SELECTOR_TITLE_CELL as b, CSS_CLASS_TITLE_CELL as S, CSS_CLASS_ATTRIBUTE_ROW as L, ATTR_DATA_ATTRIBUTE_TYPE as M, ATTR_RECOMMENDATION_TITLE as O, ATTR_DATA_VISIBILITY as N } from "./constants/selectors.js";
9
- import { regenerateMobileProductRows as w } from "./controls/main/utils.js";
10
- import { ensureMobileCssRulesExist as p, setMobileLayoutOptOut as f, hasMobileLayoutOptOut as H } from "./controls/mobileLayout/cssRules.js";
1
+ var B = Object.defineProperty;
2
+ var D = (a, c, t) => c in a ? B(a, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[c] = t;
3
+ var h = (a, c, t) => D(a, typeof c != "symbol" ? c + "" : c, t);
4
+ import { BlockId as R } from "../../../enums/block.js";
5
+ import { getMigrationBannerHtml as y } from "../../../utils/migrationBannerHtml.js";
6
+ import { Block as b, BlockCompositionType as A, ModificationDescription as g } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
+ import { regenerateMobileProductRows as C } from "./controls/main/utils.js";
8
+ import { ensureMobileCssRulesExist as p, setMobileLayoutOptOut as f, hasMobileLayoutOptOut as E } from "./controls/mobileLayout/cssRules.js";
11
9
  import { RecommendationConfigService as s } from "./services/configService.js";
12
10
  import { useRecommendationExtensionStore as d } from "./store/recommendation.js";
13
- import { getDefaultTemplate as x } from "./templates/grid/template.js";
14
- import { useRecommendationBlockWarning as $ } from "./useRecommendationBlockWarning.js";
15
- import { findLegacyTitle as P } from "./utils/legacyTitle.js";
16
- const _ = y.Recommendation, m = "recommendation-block-v2", u = "recommendation-id", I = "hide-price";
11
+ import { getDefaultTemplate as S } from "./templates/grid/template.js";
12
+ import { useRecommendationBlockWarning as M } from "./useRecommendationBlockWarning.js";
13
+ const _ = R.Recommendation, m = "recommendation-block-v2", u = "recommendation-id", I = "hide-price";
17
14
  let k = !1;
18
- class X extends B {
15
+ class P extends b {
19
16
  constructor() {
20
17
  super();
21
18
  /**
@@ -31,7 +28,7 @@ class X extends B {
31
28
  return "recommendation-icon";
32
29
  }
33
30
  getBlockCompositionType() {
34
- return E.CONTAINER;
31
+ return A.CONTAINER;
35
32
  }
36
33
  getName() {
37
34
  return this.api.translate("Recommendation Block");
@@ -42,7 +39,7 @@ class X extends B {
42
39
  );
43
40
  }
44
41
  getSettingsPanelTitleHtml() {
45
- return R(
42
+ return y(
46
43
  _,
47
44
  this.api.translate("Recommendation Block"),
48
45
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
@@ -66,7 +63,7 @@ class X extends B {
66
63
  */
67
64
  getTemplate() {
68
65
  const t = this._generateNextId();
69
- return this._pendingBlockId = t, x(t);
66
+ return this._pendingBlockId = t, S(t);
70
67
  }
71
68
  /**
72
69
  * Called when a new block is dropped into the template
@@ -97,7 +94,7 @@ class X extends B {
97
94
  if (r.setCurrentBlock(i), this._stampHidePrice(t, n.priceHideIfSameAsDiscounted), o) {
98
95
  p(this.api);
99
96
  const l = this._getBlockElement(t);
100
- l && (f(this.api, l, !0), w({
97
+ l && (f(this.api, l, !0), C({
101
98
  currentNode: t,
102
99
  documentModifier: this.api.getDocumentModifier()
103
100
  }));
@@ -122,44 +119,18 @@ class X extends B {
122
119
  "Assign recommendation ID to legacy block"
123
120
  );
124
121
  }
125
- this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t), this._healLegacyTitle(t);
122
+ this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
126
123
  try {
127
124
  k || (p(this.api), k = !0);
128
125
  const e = s.getConfig(t), i = this._getBlockElement(t);
129
126
  if (i) {
130
127
  const n = !e.mobileLayoutEnabled;
131
- H(i) !== n && f(this.api, i, n);
128
+ E(i) !== n && f(this.api, i, n);
132
129
  }
133
130
  } catch {
134
131
  }
135
132
  }
136
133
  }
137
- /**
138
- * Adopts the plain text cell a pre-SD-147795 block used as its title.
139
- *
140
- * `recommendationTitleMigrator` tags that cell before the document is handed
141
- * to Stripo, but Stripo serves a template it already holds in its own storage
142
- * (`forceRecreate: false`) and drops the HTML we pass, so for an already-saved
143
- * campaign the tagging only ever lands here. Without it the title is an
144
- * ordinary text block: Card Composition reads the toggle as off while the
145
- * title is on screen, switching it on prepends a second title, and the cell
146
- * keeps the generic delete/duplicate node actions the CSS hides by class.
147
- *
148
- * Partner-managed blocks are left alone, the same exclusion the migrator makes.
149
- * @param node - The block node that may still carry an untagged title
150
- */
151
- _healLegacyTitle(t) {
152
- const e = this._getBlockElement(t);
153
- if (!e || !("querySelector" in e) || !("hasClass" in e) || e.hasClass(D) || e.querySelector(b))
154
- return;
155
- const i = P(e);
156
- if (!i)
157
- return;
158
- const n = this.api.getDocumentModifier();
159
- n.modifyHtml(i.cell).setClass(S).setAttribute("esd-extension-block-id", T.TITLE), i.rows.forEach((o) => {
160
- n.modifyHtml(o).setClass(L).setAttribute(M, O).setAttribute(N, "1");
161
- }), n.apply(new g("Adopt legacy recommendation title"));
162
- }
163
134
  /**
164
135
  * Called when a block is deleted from the template
165
136
  *
@@ -184,7 +155,7 @@ class X extends B {
184
155
  */
185
156
  _warnIfMultipleBlocks() {
186
157
  try {
187
- $().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
158
+ M().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
188
159
  } catch {
189
160
  }
190
161
  }
@@ -362,5 +333,5 @@ class X extends B {
362
333
  }
363
334
  export {
364
335
  _ as BLOCK_ID,
365
- X as RecommendationBlock
336
+ P as RecommendationBlock
366
337
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Only reaches a template Stripo has no stored copy of an already-saved campaign
3
- * opens from Stripo storage and is tagged by `RecommendationBlock._healLegacyTitle`.
2
+ * Runs before the document reaches the editor, so a legacy title is already a
3
+ * composition item on the first render no post-load adoption pass.
4
4
  */
5
5
  export declare function migrateRecommendationTitle(html: string): string;
@@ -48,21 +48,6 @@ export declare class RecommendationBlock extends Block {
48
48
  * @param node - The block node that may need migration
49
49
  */
50
50
  onDocumentChanged(node: ImmutableHtmlNode): void;
51
- /**
52
- * Adopts the plain text cell a pre-SD-147795 block used as its title.
53
- *
54
- * `recommendationTitleMigrator` tags that cell before the document is handed
55
- * to Stripo, but Stripo serves a template it already holds in its own storage
56
- * (`forceRecreate: false`) and drops the HTML we pass, so for an already-saved
57
- * campaign the tagging only ever lands here. Without it the title is an
58
- * ordinary text block: Card Composition reads the toggle as off while the
59
- * title is on screen, switching it on prepends a second title, and the cell
60
- * keeps the generic delete/duplicate node actions the CSS hides by class.
61
- *
62
- * Partner-managed blocks are left alone, the same exclusion the migrator makes.
63
- * @param node - The block node that may still carry an untagged title
64
- */
65
- private _healLegacyTitle;
66
51
  /**
67
52
  * Called when a block is deleted from the template
68
53
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.17.0-beta.58179dc",
3
+ "version": "3.17.0-beta.db80c84",
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,20 +0,0 @@
1
- import { CONTAINER_SELECTOR as s, CSS_CLASS_SPACER as c } from "../constants/selectors.js";
2
- import { getMainContainerTbody as a } from "../controls/main/utils.js";
3
- const l = "td.esd-block-text";
4
- function C(n) {
5
- return "getInnerText" in n && n.getInnerText().trim().length > 0;
6
- }
7
- function T(n) {
8
- return "children" in n && n.children().some((e) => "hasClass" in e && e.hasClass(c));
9
- }
10
- function h(n) {
11
- const e = a(n), i = e && "children" in e ? e.children() : [], [t, o] = i, r = t == null ? void 0 : t.querySelector(l);
12
- if (!(!r || r.closest(s) || !C(r)))
13
- return {
14
- cell: r,
15
- rows: o && T(o) ? [t, o] : [t]
16
- };
17
- }
18
- export {
19
- h as findLegacyTitle
20
- };
@@ -1,20 +0,0 @@
1
- import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
2
- export interface LegacyTitle {
3
- /** The untagged title cell. */
4
- cell: ImmutableHtmlNode;
5
- /** Its wrapper row, plus the spacer row below it when there is one. */
6
- rows: ImmutableHtmlNode[];
7
- }
8
- /**
9
- * Finds the untagged title a pre-SD-147795 block still carries: a non-empty
10
- * `esd-block-text` cell that sits outside the product containers and wraps the
11
- * container's first row.
12
- *
13
- * This is `recommendationTitleMigrator`'s rule applied to the live document.
14
- * The migrator alone cannot reach a saved campaign: Stripo serves a template it
15
- * already holds in its own storage (`forceRecreate: false`) and drops the HTML
16
- * the pre-load migration hands it, so the tagging has to be applied here too.
17
- * @param block - The `.recommendation-block-v2` node
18
- * @returns The legacy title, or `undefined` when the block has none
19
- */
20
- export declare function findLegacyTitle(block: ImmutableHtmlNode): LegacyTitle | undefined;