@useinsider/guido 3.7.0-beta.509616e → 3.7.0-beta.77d2633
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/composables/useSave.js +17 -16
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +32 -0
- package/dist/enums/toaster.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +16 -35
- package/dist/extensions/Blocks/Unsubscribe/block.js +13 -13
- package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +4 -3
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +3 -0
- package/dist/src/enums/toaster.d.ts +1 -2
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -13
- package/dist/src/extensions/Blocks/Unsubscribe/utils/constants.d.ts +1 -0
- package/package.json +1 -1
- package/dist/extensions/Blocks/Recommendation/useRecommendationBlockWarning.js +0 -16
- package/dist/extensions/Blocks/Recommendation/utils/recommendationBlockCount.js +0 -9
- package/dist/src/extensions/Blocks/Recommendation/useRecommendationBlockWarning.d.ts +0 -12
- package/dist/src/extensions/Blocks/Recommendation/utils/recommendationBlockCount.d.ts +0 -28
- package/dist/src/extensions/Blocks/Recommendation/utils/recommendationBlockCount.test.d.ts +0 -1
- /package/dist/src/{extensions/Blocks/Recommendation/block.test.d.ts → composables/validators/useUnsubscribeBlockValidator.test.d.ts} +0 -0
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { useActionsApi as x } from "./useActionsApi.js";
|
|
2
2
|
import { useConfig as y } from "./useConfig.js";
|
|
3
|
-
import { useSaveStart as w, useSaveComplete as
|
|
4
|
-
import { useSyncModuleExtractor as
|
|
5
|
-
import { useStripoApi as
|
|
6
|
-
import { useTemplatePreparation as
|
|
7
|
-
import { useHtmlValidator as
|
|
3
|
+
import { useSaveStart as w, useSaveComplete as H } from "./useGuidoActions.js";
|
|
4
|
+
import { useSyncModuleExtractor as q } from "./useSyncModuleExtractor.js";
|
|
5
|
+
import { useStripoApi as C } from "../services/stripoApi.js";
|
|
6
|
+
import { useTemplatePreparation as E } from "../utils/templatePreparation.js";
|
|
7
|
+
import { useHtmlValidator as k } from "./useHtmlValidator.js";
|
|
8
8
|
import { useCouponBlockValidator as L } from "./validators/useCouponBlockValidator.js";
|
|
9
9
|
import { useLiquidValidator as P } from "./validators/useLiquidValidator.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
import { useUnsubscribeBlockValidator as B } from "./validators/useUnsubscribeBlockValidator.js";
|
|
11
|
+
const J = () => {
|
|
12
|
+
const o = w(), s = H(), { validateHtml: r } = k(), { validateLiquidSyntax: n } = P(), { validateCouponBlockTags: l } = L(), { validateUnsubscribeBlockUniqueness: d } = B(), { callbacks: i, isFeatureEnabled: u } = y(), { extractSyncModuleData: c } = q(), { setSyncModuleUnsubscriptionPages: m } = C(), { editorSave: p } = x();
|
|
13
|
+
return { save: async (f = !1, v = !1) => {
|
|
14
|
+
var a;
|
|
14
15
|
o();
|
|
15
|
-
const { prepareTemplateDetails:
|
|
16
|
-
if (!l(t.compiledHtml))
|
|
16
|
+
const { prepareTemplateDetails: S } = E(), t = await S();
|
|
17
|
+
if (!l(t.compiledHtml) || !d(t.compiledHtml))
|
|
17
18
|
return;
|
|
18
|
-
if (
|
|
19
|
+
if (u("liquidSyntax")) {
|
|
19
20
|
if (!await n(t.compiledHtml))
|
|
20
21
|
return;
|
|
21
22
|
} else if (!await r(t.compiledHtml, t.dynamicContentList, !0))
|
|
22
23
|
return;
|
|
23
|
-
if ((
|
|
24
|
+
if ((a = i.value) != null && a.externalValidation && !await i.value.externalValidation(t) || !await p())
|
|
24
25
|
return;
|
|
25
|
-
const { unsubscribePayload:
|
|
26
|
-
return await
|
|
26
|
+
const { unsubscribePayload: V, stripoModules: b } = c(t.rawHtml);
|
|
27
|
+
return await m(V), t.modules = b, f || s({ ...t, silent: v }), t;
|
|
27
28
|
} };
|
|
28
29
|
};
|
|
29
30
|
export {
|
|
30
|
-
|
|
31
|
+
J as useSave
|
|
31
32
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ToasterTypeOptions as i } from "../../enums/toaster.js";
|
|
2
|
+
import { PAGE_TYPES as n } from "../../enums/unsubscribe.js";
|
|
3
|
+
import { UNSUBSCRIBE_BLOCK_SELECTOR as u, DATA_ATTRIBUTES as l } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
4
|
+
import { useToaster as T } from "../useToaster.js";
|
|
5
|
+
import { useTranslations as E } from "../useTranslations.js";
|
|
6
|
+
const m = [
|
|
7
|
+
{
|
|
8
|
+
pageType: n.GLOBAL_UNSUBSCRIBE,
|
|
9
|
+
messageKey: "unsubscription-preference.duplicate-global-unsub"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
pageType: n.SUBSCRIPTION_PREFERENCE_CENTER,
|
|
13
|
+
messageKey: "unsubscription-preference.duplicate-pref-center"
|
|
14
|
+
}
|
|
15
|
+
], g = "unsubscription-preference.duplicate-both", y = () => {
|
|
16
|
+
const { showToaster: o } = T(), a = E();
|
|
17
|
+
return { validateUnsubscribeBlockUniqueness: (c) => {
|
|
18
|
+
const p = new DOMParser().parseFromString(c, "text/html"), t = /* @__PURE__ */ new Map();
|
|
19
|
+
p.querySelectorAll(u).forEach((e) => {
|
|
20
|
+
const r = Number(e.getAttribute(l.PAGE_TYPE));
|
|
21
|
+
t.set(r, (t.get(r) ?? 0) + 1);
|
|
22
|
+
});
|
|
23
|
+
const s = m.filter((e) => (t.get(e.pageType) ?? 0) > 1).map((e) => e.messageKey);
|
|
24
|
+
return s.length ? (o({
|
|
25
|
+
type: i.Alert,
|
|
26
|
+
message: a(s.length > 1 ? g : s[0])
|
|
27
|
+
}), !1) : !0;
|
|
28
|
+
} };
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
y as useUnsubscribeBlockValidator
|
|
32
|
+
};
|
package/dist/enums/toaster.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var c = /* @__PURE__ */ ((r) => (r.Success = "success", r.Warning = "warning", r.Alert = "alert", r
|
|
1
|
+
var c = /* @__PURE__ */ ((r) => (r.Success = "success", r.Warning = "warning", r.Alert = "alert", r))(c || {});
|
|
2
2
|
export {
|
|
3
3
|
c as ToasterTypeOptions
|
|
4
4
|
};
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var d = (a, r, t) =>
|
|
4
|
-
import { BlockId as
|
|
5
|
-
import { getMigrationBannerHtml as
|
|
6
|
-
import { Block as
|
|
2
|
+
var y = (a, r, t) => r in a ? k(a, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[r] = t;
|
|
3
|
+
var d = (a, r, t) => y(a, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { BlockId as B } from "../../../enums/block.js";
|
|
5
|
+
import { getMigrationBannerHtml as D } from "../../../utils/migrationBannerHtml.js";
|
|
6
|
+
import { Block as R, BlockCompositionType as C, ModificationDescription as h } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
7
|
import { regenerateMobileProductRows as b } from "./controls/main/utils.js";
|
|
8
8
|
import { ensureMobileCssRulesExist as p, setMobileLayoutOptOut as f, hasMobileLayoutOptOut as A } from "./controls/mobileLayout/cssRules.js";
|
|
9
9
|
import { RecommendationConfigService as c } from "./services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as g } from "./store/recommendation.js";
|
|
11
11
|
import { getDefaultTemplate as E } from "./templates/grid/template.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class H extends D {
|
|
12
|
+
const _ = B.Recommendation, m = "recommendation-block-v2", u = "recommendation-id";
|
|
13
|
+
let I = !1;
|
|
14
|
+
class q extends R {
|
|
16
15
|
constructor() {
|
|
17
16
|
super();
|
|
18
17
|
/**
|
|
@@ -22,7 +21,7 @@ class H extends D {
|
|
|
22
21
|
d(this, "_pendingBlockId", null);
|
|
23
22
|
}
|
|
24
23
|
getId() {
|
|
25
|
-
return
|
|
24
|
+
return _;
|
|
26
25
|
}
|
|
27
26
|
getIcon() {
|
|
28
27
|
return "recommendation-icon";
|
|
@@ -39,8 +38,8 @@ class H extends D {
|
|
|
39
38
|
);
|
|
40
39
|
}
|
|
41
40
|
getSettingsPanelTitleHtml() {
|
|
42
|
-
return
|
|
43
|
-
|
|
41
|
+
return D(
|
|
42
|
+
_,
|
|
44
43
|
this.api.translate("Recommendation Block"),
|
|
45
44
|
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.")
|
|
46
45
|
);
|
|
@@ -96,7 +95,7 @@ class H extends D {
|
|
|
96
95
|
documentModifier: this.api.getDocumentModifier()
|
|
97
96
|
}));
|
|
98
97
|
}
|
|
99
|
-
s.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 })
|
|
98
|
+
s.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
|
|
100
99
|
}
|
|
101
100
|
/**
|
|
102
101
|
* Called when the document changes or template is loaded
|
|
@@ -118,7 +117,7 @@ class H extends D {
|
|
|
118
117
|
}
|
|
119
118
|
this._healLingeringDuplicate(t), c.needsMigration(t) && this._migrateFromLegacy(t);
|
|
120
119
|
try {
|
|
121
|
-
|
|
120
|
+
I || (p(this.api), I = !0);
|
|
122
121
|
const e = c.getConfig(t), i = this._getBlockElement(t);
|
|
123
122
|
if (i) {
|
|
124
123
|
const n = !e.mobileLayoutEnabled;
|
|
@@ -138,24 +137,6 @@ class H extends D {
|
|
|
138
137
|
const e = this._getRecommendationId(t);
|
|
139
138
|
e && g().removeBlockState(e);
|
|
140
139
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Warns (dark advisory toaster) when the design holds more than one live
|
|
143
|
-
* recommendation block. Triggered from the user-add paths only (fresh drop
|
|
144
|
-
* and duplicate) — never from document-load/migration, so opening a template
|
|
145
|
-
* that already has multiple blocks does not fire it. `onCreated` also runs
|
|
146
|
-
* for a reco block that arrives inside a saved structure (SD-143028), so this
|
|
147
|
-
* covers that case too — no separate `module_dropped` handling is needed.
|
|
148
|
-
*
|
|
149
|
-
* Counting lives in `useRecommendationBlockWarning`, whose DOM-based logic
|
|
150
|
-
* ignores the empty shells deletions leave behind (SD-143028). Wrapped in
|
|
151
|
-
* try/catch because the document root may be unavailable during initial load.
|
|
152
|
-
*/
|
|
153
|
-
_warnIfMultipleBlocks() {
|
|
154
|
-
try {
|
|
155
|
-
M().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
|
|
156
|
-
} catch {
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
140
|
/**
|
|
160
141
|
* Generates the next unique recommendation ID by scanning all existing blocks
|
|
161
142
|
* in the document and finding the maximum existing ID + 1.
|
|
@@ -228,7 +209,7 @@ class H extends D {
|
|
|
228
209
|
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
229
210
|
_handleDuplicate(t, e) {
|
|
230
211
|
const i = this._reassignDuplicateId(t, e), n = g();
|
|
231
|
-
n.cloneBlockState(e, i), n.setCurrentBlock(i)
|
|
212
|
+
n.cloneBlockState(e, i), n.setCurrentBlock(i);
|
|
232
213
|
}
|
|
233
214
|
/**
|
|
234
215
|
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
@@ -310,6 +291,6 @@ class H extends D {
|
|
|
310
291
|
}
|
|
311
292
|
}
|
|
312
293
|
export {
|
|
313
|
-
|
|
314
|
-
|
|
294
|
+
_ as BLOCK_ID,
|
|
295
|
+
q as RecommendationBlock
|
|
315
296
|
};
|
|
@@ -5,11 +5,11 @@ import { useToaster as B } from "../../../composables/useToaster.js";
|
|
|
5
5
|
import { ToasterTypeOptions as S } from "../../../enums/toaster.js";
|
|
6
6
|
import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
|
|
7
7
|
import { useUnsubscribeStore as a } from "../../../stores/unsubscribe.js";
|
|
8
|
-
import { Block as L, BlockCompositionType as f, ContextActionType as h, ModificationDescription as b, BlockType as
|
|
9
|
-
import { getDefaultTemplate as
|
|
10
|
-
import { DATA_ATTRIBUTES as i, UNSUBSCRIBE_EVENTS as d } from "./utils/constants.js";
|
|
11
|
-
import { parsePageList as
|
|
12
|
-
const y = "unsubscribe-block",
|
|
8
|
+
import { Block as L, BlockCompositionType as f, ContextActionType as h, ModificationDescription as b, BlockType as A } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
9
|
+
import { getDefaultTemplate as v } from "./template.js";
|
|
10
|
+
import { DATA_ATTRIBUTES as i, UNSUBSCRIBE_BLOCK_SELECTOR as p, UNSUBSCRIBE_EVENTS as d } from "./utils/constants.js";
|
|
11
|
+
import { parsePageList as m } from "./utils/utils.js";
|
|
12
|
+
const y = "unsubscribe-block", _ = 'a[data-unsubscribe-link="true"]', I = "{{ins-unsubscribe-link}}", T = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", C = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", N = {
|
|
13
13
|
[E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
14
14
|
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
15
15
|
};
|
|
@@ -42,7 +42,7 @@ class F extends L {
|
|
|
42
42
|
return this.api.translate("Unsubscribe Block Description");
|
|
43
43
|
}
|
|
44
44
|
getTemplate() {
|
|
45
|
-
return
|
|
45
|
+
return v();
|
|
46
46
|
}
|
|
47
47
|
getContextActionsIds() {
|
|
48
48
|
return [h.MOVE, h.REMOVE];
|
|
@@ -68,7 +68,7 @@ class F extends L {
|
|
|
68
68
|
this._removeEventListeners(), this.currentNode = void 0, this.linkStateByBlockId.clear();
|
|
69
69
|
}
|
|
70
70
|
_hasUnsubscribeLink(e) {
|
|
71
|
-
return "querySelector" in e ? !!e.querySelector(
|
|
71
|
+
return "querySelector" in e ? !!e.querySelector(_) : !1;
|
|
72
72
|
}
|
|
73
73
|
_readBlockId(e) {
|
|
74
74
|
return "getAttribute" in e ? e.getAttribute(i.BLOCK_ID) : null;
|
|
@@ -102,7 +102,7 @@ class F extends L {
|
|
|
102
102
|
let e = 0;
|
|
103
103
|
try {
|
|
104
104
|
const t = this.api.getDocumentRoot();
|
|
105
|
-
t && "querySelectorAll" in t && t.querySelectorAll(
|
|
105
|
+
t && "querySelectorAll" in t && t.querySelectorAll(p).forEach((s) => {
|
|
106
106
|
if ("getAttribute" in s) {
|
|
107
107
|
const o = s.getAttribute(i.BLOCK_ID), u = o ? parseInt(o) : 0;
|
|
108
108
|
u > e && (e = u);
|
|
@@ -150,7 +150,7 @@ class F extends L {
|
|
|
150
150
|
try {
|
|
151
151
|
if (!this.currentNode)
|
|
152
152
|
return;
|
|
153
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${
|
|
153
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${A.EMPTY_CONTAINER}/>`).apply(new b("Removed unsubscribe block due to cancel"));
|
|
154
154
|
} catch (e) {
|
|
155
155
|
console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
|
|
156
156
|
}
|
|
@@ -161,7 +161,7 @@ class F extends L {
|
|
|
161
161
|
_updateBlock(e, t) {
|
|
162
162
|
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
163
163
|
return;
|
|
164
|
-
const r = this.currentNode.querySelector(
|
|
164
|
+
const r = this.currentNode.querySelector(_);
|
|
165
165
|
if (!r)
|
|
166
166
|
return;
|
|
167
167
|
const s = this._getMergeTag(e);
|
|
@@ -181,7 +181,7 @@ class F extends L {
|
|
|
181
181
|
}
|
|
182
182
|
_checkExistingBlocks() {
|
|
183
183
|
const e = a();
|
|
184
|
-
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(
|
|
184
|
+
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(p).forEach((r) => {
|
|
185
185
|
if ("getAttribute" in r) {
|
|
186
186
|
const s = r.getAttribute(i.PAGE_TYPE);
|
|
187
187
|
if (s) {
|
|
@@ -197,7 +197,7 @@ class F extends L {
|
|
|
197
197
|
const t = e.getAttribute(i.PAGE_TYPE), r = e.getAttribute(i.PAGE_LIST);
|
|
198
198
|
if (!t || !r)
|
|
199
199
|
return;
|
|
200
|
-
const s = a(), o = Number(t), u =
|
|
200
|
+
const s = a(), o = Number(t), u = m(r);
|
|
201
201
|
await s.fetchTemplates(), s.setCollectionWithoutAutoSelection(o), s.loadSelectedTemplates(u);
|
|
202
202
|
}
|
|
203
203
|
_resetStoreState() {
|
|
@@ -209,7 +209,7 @@ class F extends L {
|
|
|
209
209
|
const t = e.getAttribute(i.PAGE_LIST);
|
|
210
210
|
if (!t)
|
|
211
211
|
return;
|
|
212
|
-
const r = a(), s =
|
|
212
|
+
const r = a(), s = m(t);
|
|
213
213
|
r.removeUnsubscribePages(s);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
const s = {
|
|
2
2
|
SELECT: "unsubscribe:select",
|
|
3
3
|
CANCEL: "unsubscribe:cancel"
|
|
4
|
-
},
|
|
4
|
+
}, b = {
|
|
5
5
|
PAGE_TYPE: "data-unsubscribe-page-type",
|
|
6
6
|
PAGE_LIST: "data-unsubscribe-page-list",
|
|
7
7
|
BLOCK_ID: "data-unsubscribe-block-id"
|
|
8
|
-
};
|
|
8
|
+
}, c = ".unsubscribe-block-v2";
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
b as DATA_ATTRIBUTES,
|
|
11
|
+
c as UNSUBSCRIBE_BLOCK_SELECTOR,
|
|
11
12
|
s as UNSUBSCRIBE_EVENTS
|
|
12
13
|
};
|
|
@@ -55,19 +55,6 @@ export declare class RecommendationBlock extends Block {
|
|
|
55
55
|
* @param node - The block node being deleted
|
|
56
56
|
*/
|
|
57
57
|
onDelete(node: ImmutableHtmlNode): void;
|
|
58
|
-
/**
|
|
59
|
-
* Warns (dark advisory toaster) when the design holds more than one live
|
|
60
|
-
* recommendation block. Triggered from the user-add paths only (fresh drop
|
|
61
|
-
* and duplicate) — never from document-load/migration, so opening a template
|
|
62
|
-
* that already has multiple blocks does not fire it. `onCreated` also runs
|
|
63
|
-
* for a reco block that arrives inside a saved structure (SD-143028), so this
|
|
64
|
-
* covers that case too — no separate `module_dropped` handling is needed.
|
|
65
|
-
*
|
|
66
|
-
* Counting lives in `useRecommendationBlockWarning`, whose DOM-based logic
|
|
67
|
-
* ignores the empty shells deletions leave behind (SD-143028). Wrapped in
|
|
68
|
-
* try/catch because the document root may be unavailable during initial load.
|
|
69
|
-
*/
|
|
70
|
-
private _warnIfMultipleBlocks;
|
|
71
58
|
/**
|
|
72
59
|
* Generates the next unique recommendation ID by scanning all existing blocks
|
|
73
60
|
* in the document and finding the maximum existing ID + 1.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.7.0-beta.
|
|
3
|
+
"version": "3.7.0-beta.77d2633",
|
|
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,16 +0,0 @@
|
|
|
1
|
-
import { useToaster as r } from "../../../composables/useToaster.js";
|
|
2
|
-
import { useTranslations as s } from "../../../composables/useTranslations.js";
|
|
3
|
-
import { ToasterTypeOptions as n } from "../../../enums/toaster.js";
|
|
4
|
-
import { countLiveRecommendationBlocks as i } from "./utils/recommendationBlockCount.js";
|
|
5
|
-
const a = "newsletter.multiple-reco-blocks-warning", f = () => {
|
|
6
|
-
const { showToaster: o } = r(), t = s();
|
|
7
|
-
return { warnIfMultipleBlocks: (e) => {
|
|
8
|
-
i(e) > 1 && o({
|
|
9
|
-
type: n.Dark,
|
|
10
|
-
message: t(a)
|
|
11
|
-
});
|
|
12
|
-
} };
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
f as useRecommendationBlockWarning
|
|
16
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const r = ".recommendation-block-v2", t = ".recommendation-product-row";
|
|
2
|
-
function n(o) {
|
|
3
|
-
return Array.from(o.querySelectorAll(r)).filter((e) => e.querySelector(t)).length;
|
|
4
|
-
}
|
|
5
|
-
export {
|
|
6
|
-
r as RECOMMENDATION_BLOCK_SELECTOR,
|
|
7
|
-
t as RECOMMENDATION_PRODUCT_ROW_SELECTOR,
|
|
8
|
-
n as countLiveRecommendationBlocks
|
|
9
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { QueryableRoot } from './utils/recommendationBlockCount';
|
|
2
|
-
/**
|
|
3
|
-
* Advisory shown when a design ends up with more than one recommendation block,
|
|
4
|
-
* since multiple blocks can slow campaign delivery. Driven from the block
|
|
5
|
-
* lifecycle (`onCreated` for direct drop / duplicate, counting the editor's
|
|
6
|
-
* document root). `onCreated` also fires for a reco block that arrives inside a
|
|
7
|
-
* saved structure (SD-143028), so that case is covered without a separate
|
|
8
|
-
* `module_dropped` re-check.
|
|
9
|
-
*/
|
|
10
|
-
export declare const useRecommendationBlockWarning: () => {
|
|
11
|
-
warnIfMultipleBlocks: (root: QueryableRoot) => void;
|
|
12
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Counts *live* recommendation blocks in a document.
|
|
3
|
-
*
|
|
4
|
-
* Deleting a recommendation block strips its inner content but leaves an empty
|
|
5
|
-
* `.recommendation-block-v2` container shell behind — present in every document
|
|
6
|
-
* representation the editor exposes (`getDocumentRoot`, `getDocumentRootHtmlNode`
|
|
7
|
-
* and even `getTemplateData`). A raw class count therefore over-reports after a
|
|
8
|
-
* delete→add cycle (SD-143028). The product row (`.recommendation-product-row`)
|
|
9
|
-
* is present on every live block from drop time (the default template ships
|
|
10
|
-
* product rows, both grid and list layouts) and is removed from a deleted
|
|
11
|
-
* block's leftover shell, so filtering by it cleanly separates live blocks from
|
|
12
|
-
* ghosts without reading any store.
|
|
13
|
-
*/
|
|
14
|
-
export declare const RECOMMENDATION_BLOCK_SELECTOR = ".recommendation-block-v2";
|
|
15
|
-
export declare const RECOMMENDATION_PRODUCT_ROW_SELECTOR = ".recommendation-product-row";
|
|
16
|
-
interface QueryableNode {
|
|
17
|
-
querySelector(selector: string): unknown;
|
|
18
|
-
}
|
|
19
|
-
export interface QueryableRoot {
|
|
20
|
-
querySelectorAll(selector: string): Iterable<QueryableNode>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Counts the live recommendation blocks reachable from `root`. Works on the
|
|
24
|
-
* editor's `ImmutableHtmlNode` document root (the `onCreated` drop / duplicate
|
|
25
|
-
* paths) and on any DOM-like root exposing `querySelectorAll`.
|
|
26
|
-
*/
|
|
27
|
-
export declare function countLiveRecommendationBlocks(root: QueryableRoot): number;
|
|
28
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|