@useinsider/guido 1.0.3-beta.e83334e → 1.0.3-beta.ea69f4a
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 +0 -3
- package/dist/composables/useActionsApi.js +32 -23
- package/dist/composables/useStripo.js +48 -46
- package/dist/composables/useTimerClone.js +67 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +25 -25
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +62 -66
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -3
- package/dist/extensions/Blocks/Items/store/items-block.js +1 -1
- package/dist/extensions/Blocks/Items/template.js +58 -64
- package/dist/extensions/Blocks/Unsubscribe/block.js +30 -34
- package/dist/src/composables/useActionsApi.d.ts +1 -0
- package/dist/src/composables/useTimerClone.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/enums/settingsEnums.d.ts +0 -1
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -600,9 +600,6 @@ Create a `.env` file with the following variables: (You can get env variables fr
|
|
|
600
600
|
VITE_STRIPO_PLUGIN_ID=your_plugin_id
|
|
601
601
|
VITE_STRIPO_SECRET_KEY=your_secret_key
|
|
602
602
|
VITE_STRIPO_ROLE=your_role
|
|
603
|
-
|
|
604
|
-
# Playwright Test Configuration (Optional - for local debugging only)
|
|
605
|
-
HEADED=false # Set to 'true' to run tests with visible browser
|
|
606
603
|
```
|
|
607
604
|
|
|
608
605
|
### Project Structure
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useToaster as
|
|
1
|
+
import { useToaster as w } from "./useToaster.js";
|
|
2
2
|
const A = () => {
|
|
3
|
-
const { handleError: l } =
|
|
3
|
+
const { handleError: l } = w(), s = (e = {}) => new Promise((t, a) => {
|
|
4
4
|
const i = { ...{
|
|
5
5
|
minimize: !0,
|
|
6
6
|
utmEntity: {
|
|
@@ -20,13 +20,13 @@ const A = () => {
|
|
|
20
20
|
forceAmp: !1,
|
|
21
21
|
resetDataSavedFlag: !1,
|
|
22
22
|
disableLineHeightsReplace: !0
|
|
23
|
-
}, ...
|
|
24
|
-
callback: (
|
|
25
|
-
|
|
26
|
-
html:
|
|
27
|
-
ampHtml:
|
|
28
|
-
ampErrors:
|
|
29
|
-
displayConditions:
|
|
23
|
+
}, ...e }, m = {
|
|
24
|
+
callback: (n, p, c, d, u) => {
|
|
25
|
+
n ? a(n) : t({
|
|
26
|
+
html: p,
|
|
27
|
+
ampHtml: c,
|
|
28
|
+
ampErrors: d,
|
|
29
|
+
displayConditions: u
|
|
30
30
|
});
|
|
31
31
|
},
|
|
32
32
|
...i
|
|
@@ -34,44 +34,53 @@ const A = () => {
|
|
|
34
34
|
window.StripoEditorApi.actionsApi.compileEmail(m);
|
|
35
35
|
});
|
|
36
36
|
return {
|
|
37
|
-
getCompiledEmail:
|
|
38
|
-
getTemplateData: () => new Promise((
|
|
39
|
-
const
|
|
37
|
+
getCompiledEmail: s,
|
|
38
|
+
getTemplateData: () => new Promise((e) => {
|
|
39
|
+
const t = ({ html: a, css: o, width: i, height: r, utmParams: m, syncModulesIds: n }) => e({
|
|
40
40
|
html: a,
|
|
41
41
|
css: o,
|
|
42
42
|
width: i,
|
|
43
43
|
height: r,
|
|
44
44
|
utmParams: m,
|
|
45
|
-
syncModulesIds:
|
|
45
|
+
syncModulesIds: n
|
|
46
46
|
});
|
|
47
|
-
window.StripoEditorApi.actionsApi.getTemplateData(
|
|
47
|
+
window.StripoEditorApi.actionsApi.getTemplateData(t);
|
|
48
48
|
}),
|
|
49
|
-
activateCustomViewStyles: (
|
|
50
|
-
window.StripoEditorApi.actionsApi.activateCustomViewStyles(
|
|
49
|
+
activateCustomViewStyles: (e = !0) => {
|
|
50
|
+
window.StripoEditorApi.actionsApi.activateCustomViewStyles(e);
|
|
51
51
|
},
|
|
52
|
-
getPreviewData: async (
|
|
52
|
+
getPreviewData: async (e) => {
|
|
53
53
|
try {
|
|
54
54
|
const {
|
|
55
|
-
html:
|
|
55
|
+
html: t,
|
|
56
56
|
displayConditions: a,
|
|
57
57
|
ampHtml: o = "",
|
|
58
58
|
ampErrors: i = []
|
|
59
|
-
} = await
|
|
59
|
+
} = await s({ minimize: !1, resetDataSavedFlag: !1, ...e });
|
|
60
60
|
return {
|
|
61
|
-
html:
|
|
61
|
+
html: t,
|
|
62
62
|
ampHtml: o,
|
|
63
63
|
ampErrors: i,
|
|
64
64
|
displayConditions: a
|
|
65
65
|
};
|
|
66
|
-
} catch (
|
|
67
|
-
return l(
|
|
66
|
+
} catch (t) {
|
|
67
|
+
return l(t, "Error loading preview"), {
|
|
68
68
|
html: "",
|
|
69
69
|
ampHtml: "",
|
|
70
70
|
ampErrors: [],
|
|
71
71
|
displayConditions: []
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
}
|
|
74
|
+
},
|
|
75
|
+
updateTimerInClonedTemplate: () => new Promise((e) => {
|
|
76
|
+
try {
|
|
77
|
+
window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((t, a) => {
|
|
78
|
+
t ? (l(t, "Failed to update timer in cloned template"), e(null)) : e(a || null);
|
|
79
|
+
});
|
|
80
|
+
} catch (t) {
|
|
81
|
+
l(t, "Failed to call updateTimerInClonedTemplate"), e(null);
|
|
82
|
+
}
|
|
83
|
+
})
|
|
75
84
|
};
|
|
76
85
|
};
|
|
77
86
|
export {
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useBlocksConfig as
|
|
3
|
-
import { useConfig as
|
|
4
|
-
import { useCustomInterfaceAppearance as
|
|
5
|
-
import { useStripoEventHandler as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { useActionsApi as V } from "./useActionsApi.js";
|
|
2
|
+
import { useBlocksConfig as _ } from "./useBlocksConfig.js";
|
|
3
|
+
import { useConfig as A } from "./useConfig.js";
|
|
4
|
+
import { useCustomInterfaceAppearance as B } from "./useCustomInterfaceAppearance.js";
|
|
5
|
+
import { useStripoEventHandler as v } from "./useStripoEventHandler.js";
|
|
6
|
+
import { useTimerClone as F } from "./useTimerClone.js";
|
|
7
|
+
import { useToaster as I } from "./useToaster.js";
|
|
8
|
+
import { displayConditions as M } from "../enums/displayConditions.js";
|
|
9
|
+
import { useStripoApi as U } from "../services/stripoApi.js";
|
|
10
|
+
import D from "../static/styles/customEditorStyle.css.js";
|
|
11
|
+
import { useEditorStore as P } from "../stores/editor.js";
|
|
12
|
+
import { dynamicContentToMergeTags as H } from "../utils/genericUtil.js";
|
|
13
|
+
import O from "../package.json.js";
|
|
14
|
+
const Y = (c) => {
|
|
15
|
+
const { config: u } = A(), { handleError: p } = I(), { getToken: m, getCustomFonts: C } = U(), { handleEvent: S } = v(), { getStripoBlocksConfig: E } = _(), w = async (i, r = []) => {
|
|
16
|
+
var g, y;
|
|
17
|
+
const e = P(), { html: s, css: f, forceRecreate: a } = i, { baseBlocks: t, extensions: d } = await E();
|
|
17
18
|
window.UIEditor.initEditor(
|
|
18
19
|
document.querySelector("#guido-editor"),
|
|
19
20
|
{
|
|
20
21
|
metadata: c,
|
|
21
|
-
html:
|
|
22
|
-
css:
|
|
22
|
+
html: s,
|
|
23
|
+
css: f,
|
|
23
24
|
forceRecreate: a,
|
|
24
25
|
locale: "en",
|
|
25
26
|
undoButtonSelector: "#guido__undo-button",
|
|
@@ -30,10 +31,10 @@ const J = (c) => {
|
|
|
30
31
|
customAppearanceMergetags: !0,
|
|
31
32
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
32
33
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
33
|
-
customViewStyles:
|
|
34
|
-
conditionsEnabled: ((
|
|
35
|
-
customConditionsEnabled: ((
|
|
36
|
-
conditionCategories:
|
|
34
|
+
customViewStyles: D,
|
|
35
|
+
conditionsEnabled: ((g = u.features) == null ? void 0 : g.displayConditions) ?? !0,
|
|
36
|
+
customConditionsEnabled: ((y = u.features) == null ? void 0 : y.displayConditions) ?? !0,
|
|
37
|
+
conditionCategories: M,
|
|
37
38
|
enableXSSSecurity: !0,
|
|
38
39
|
messageSettingsEnabled: !0,
|
|
39
40
|
displayGmailAnnotations: !0,
|
|
@@ -41,7 +42,7 @@ const J = (c) => {
|
|
|
41
42
|
displayTitle: !1,
|
|
42
43
|
displayUTM: !1,
|
|
43
44
|
selectElementAfterDrop: !0,
|
|
44
|
-
...
|
|
45
|
+
...t ? { baseBlocks: t } : {},
|
|
45
46
|
editorFonts: {
|
|
46
47
|
showDefaultStandardFonts: !0,
|
|
47
48
|
showDefaultNotStandardFonts: !0,
|
|
@@ -49,38 +50,39 @@ const J = (c) => {
|
|
|
49
50
|
},
|
|
50
51
|
mergeTags: [
|
|
51
52
|
{
|
|
52
|
-
entries:
|
|
53
|
+
entries: H(c.preselectedDynamicContentList)
|
|
53
54
|
}
|
|
54
55
|
],
|
|
55
56
|
async onTokenRefreshRequest(o) {
|
|
56
57
|
try {
|
|
57
|
-
const
|
|
58
|
-
o(
|
|
59
|
-
} catch (
|
|
60
|
-
|
|
58
|
+
const n = await m();
|
|
59
|
+
o(n);
|
|
60
|
+
} catch (n) {
|
|
61
|
+
p(n, "Failed to refresh token");
|
|
61
62
|
}
|
|
62
63
|
},
|
|
63
64
|
onTemplateLoaded() {
|
|
65
|
+
var o, n;
|
|
64
66
|
try {
|
|
65
|
-
const { importCss:
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
const { importCss: l } = B(), { activateCustomViewStyles: T, updateTimerInClonedTemplate: b } = V(), { updateTimersOnLoad: k } = F();
|
|
68
|
+
l(), T(), typeof ((n = (o = window.StripoEditorApi) == null ? void 0 : o.actionsApi) == null ? void 0 : n.updateTimerInClonedTemplate) == "function" ? b() : k(m), c.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
|
|
69
|
+
e.hasChanges = !1;
|
|
68
70
|
}, 1e3);
|
|
69
|
-
} catch (
|
|
70
|
-
l
|
|
71
|
+
} catch (l) {
|
|
72
|
+
p(l, "Failed to load custom interface appearance");
|
|
71
73
|
}
|
|
72
74
|
},
|
|
73
75
|
onCodeEditorVisibilityChanged(o) {
|
|
74
|
-
|
|
76
|
+
e.isCodeEditorOpen = o;
|
|
75
77
|
},
|
|
76
78
|
onEditorVisualModeChanged(o) {
|
|
77
|
-
|
|
79
|
+
e.editorVisualMode = o.toLowerCase();
|
|
78
80
|
},
|
|
79
81
|
onVersionHistoryVisibilityChanged(o) {
|
|
80
|
-
|
|
82
|
+
e.isVersionHistoryOpen = o;
|
|
81
83
|
},
|
|
82
84
|
onDataChanged() {
|
|
83
|
-
|
|
85
|
+
e.hasChanges = !0;
|
|
84
86
|
},
|
|
85
87
|
onEvent: S,
|
|
86
88
|
ignoreClickOutsideSelectors: [
|
|
@@ -91,26 +93,26 @@ const J = (c) => {
|
|
|
91
93
|
extensions: d
|
|
92
94
|
}
|
|
93
95
|
);
|
|
94
|
-
}, h = (i) => new Promise((r,
|
|
96
|
+
}, h = (i) => new Promise((r, e) => {
|
|
95
97
|
var d;
|
|
96
98
|
if (document.getElementById("UiEditorScript")) {
|
|
97
99
|
i(), r();
|
|
98
100
|
return;
|
|
99
101
|
}
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
+
const s = O.guido, a = `https://email-static.useinsider.com/guido/${(d = s == null ? void 0 : s.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
|
|
103
|
+
t.id = "UiEditorScript", t.type = "module", t.src = a, t.onload = () => {
|
|
102
104
|
i(), r();
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
}, document.body.appendChild(
|
|
105
|
+
}, t.onerror = () => {
|
|
106
|
+
e(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
|
|
107
|
+
}, document.body.appendChild(t);
|
|
106
108
|
});
|
|
107
109
|
return { initPlugin: async (i) => {
|
|
108
110
|
await h(async () => {
|
|
109
|
-
const r = await
|
|
110
|
-
await
|
|
111
|
+
const r = await C();
|
|
112
|
+
await w(i, r);
|
|
111
113
|
});
|
|
112
114
|
} };
|
|
113
115
|
};
|
|
114
116
|
export {
|
|
115
|
-
|
|
117
|
+
Y as useStripo
|
|
116
118
|
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useToaster as I } from "./useToaster.js";
|
|
2
|
+
const M = () => {
|
|
3
|
+
const { handleError: d } = I(), a = (n) => /esd-timer-id="(\d+)"/.test(n), c = async (n, s) => {
|
|
4
|
+
try {
|
|
5
|
+
console.debug("[TIMER CLONE] Calling Stripo API to clone timers...");
|
|
6
|
+
const e = await fetch("https://plugins.stripo.email/api/v1/timers/clone", {
|
|
7
|
+
method: "POST",
|
|
8
|
+
headers: {
|
|
9
|
+
"ES-PLUGIN-AUTH": `Bearer ${s}`,
|
|
10
|
+
"Content-Type": "application/json"
|
|
11
|
+
},
|
|
12
|
+
body: JSON.stringify({ html: n })
|
|
13
|
+
});
|
|
14
|
+
if (console.debug("[TIMER CLONE] API response status:", e.status), !e.ok) {
|
|
15
|
+
const r = await e.text();
|
|
16
|
+
throw console.debug("[TIMER CLONE] API error:", r), new Error(`Stripo API error: ${e.status} ${e.statusText}`);
|
|
17
|
+
}
|
|
18
|
+
const t = await e.json();
|
|
19
|
+
return console.debug("[TIMER CLONE] Timers cloned successfully. Map:", t.timersMap), console.debug("[TIMER CLONE] Old HTML length:", n.length), console.debug("[TIMER CLONE] New HTML length:", t.html.length), t.html;
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return console.debug("[TIMER CLONE] Error:", e), d(e, "Failed to clone timer IDs"), null;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
hasTimerBlocks: a,
|
|
26
|
+
cloneTimersInHtml: c,
|
|
27
|
+
updateTimersOnLoad: async (n) => {
|
|
28
|
+
var s, e, t, r, l, u;
|
|
29
|
+
try {
|
|
30
|
+
console.debug("[TIMER CLONE] Starting timer update on template load...");
|
|
31
|
+
const o = (e = (s = window.UIEditor) == null ? void 0 : s.getHtml) == null ? void 0 : e.call(s);
|
|
32
|
+
if (!o) {
|
|
33
|
+
console.debug("[TIMER CLONE] No HTML found, skipping timer update");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const E = a(o);
|
|
37
|
+
if (console.debug("[TIMER CLONE] Has timer blocks?", E), !E)
|
|
38
|
+
return;
|
|
39
|
+
const T = o.match(/esd-timer-id="(\d+)"/g);
|
|
40
|
+
console.debug("[TIMER CLONE] Current timer IDs:", T), console.debug("[TIMER CLONE] Getting auth token...");
|
|
41
|
+
const p = await n();
|
|
42
|
+
if (!p) {
|
|
43
|
+
console.debug("[TIMER CLONE] No auth token available, skipping timer update");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const i = await c(o, p);
|
|
47
|
+
if (!i) {
|
|
48
|
+
console.debug("[TIMER CLONE] API returned no updated HTML");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (i === o) {
|
|
52
|
+
console.debug("[TIMER CLONE] HTML unchanged, no update needed");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const m = i.match(/esd-timer-id="(\d+)"/g);
|
|
56
|
+
console.debug("[TIMER CLONE] New timer IDs:", m);
|
|
57
|
+
const g = ((r = (t = window.UIEditor) == null ? void 0 : t.getCss) == null ? void 0 : r.call(t)) || "";
|
|
58
|
+
console.debug("[TIMER CLONE] Updating editor with new HTML..."), (u = (l = window.StripoEditorApi) == null ? void 0 : l.actionsApi) != null && u.updateHtmlAndCss ? (window.StripoEditorApi.actionsApi.updateHtmlAndCss(i, g), console.debug("[TIMER CLONE] ✅ Editor updated successfully!")) : console.debug("[TIMER CLONE] updateHtmlAndCss method not available");
|
|
59
|
+
} catch (o) {
|
|
60
|
+
console.debug("[TIMER CLONE] Error updating timers:", o), d(o, "Failed to update timer blocks");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
M as useTimerClone
|
|
67
|
+
};
|
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
var d = Object.defineProperty;
|
|
2
2
|
var h = (i, t, e) => t in i ? d(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
-
var
|
|
4
|
-
import { ModificationDescription as
|
|
3
|
+
var s = (i, t, e) => h(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { ModificationDescription as n, UIElementType as a, UEAttr as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
5
|
import { CommonControl as c } from "../../../common-control.js";
|
|
6
|
-
import { ItemsBlockControlId as
|
|
6
|
+
import { ItemsBlockControlId as l } from "../../enums/controlEnums.js";
|
|
7
7
|
import { SETTINGS_ENUMS as I } from "../../enums/settingsEnums.js";
|
|
8
8
|
import { useItemsBlockStore as N } from "../../store/items-block.js";
|
|
9
|
-
import { syncNameTrimmingFromAttributes as
|
|
10
|
-
import { updateConfigBlockAttributes as
|
|
11
|
-
const
|
|
9
|
+
import { syncNameTrimmingFromAttributes as y } from "../../utils/syncAttributesFromConfigBlock.js";
|
|
10
|
+
import { updateConfigBlockAttributes as M } from "../../utils/updateAttributes.js";
|
|
11
|
+
const f = l.NAME_TRIMMING, r = {
|
|
12
12
|
TRIMMING: "trimming"
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class R extends c {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
17
|
-
|
|
17
|
+
s(this, "store", N());
|
|
18
18
|
}
|
|
19
19
|
getId() {
|
|
20
|
-
return
|
|
20
|
+
return f;
|
|
21
21
|
}
|
|
22
22
|
getTemplate() {
|
|
23
23
|
return `
|
|
24
|
-
<div class="${
|
|
24
|
+
<div class="${l.NAME_TRIMMING}">
|
|
25
25
|
${this._getTextTrimming()}
|
|
26
26
|
</div>
|
|
27
27
|
`;
|
|
28
28
|
}
|
|
29
29
|
onRender() {
|
|
30
|
-
this.api.updateValues({ [
|
|
30
|
+
this.api.updateValues({ [r.TRIMMING]: this.store.nameTrimming }), this.api.onValueChanged(r.TRIMMING, (e) => {
|
|
31
31
|
this._onTrimmingChange(e);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
onTemplateNodeUpdated(e) {
|
|
35
35
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
|
|
36
|
-
() =>
|
|
36
|
+
() => y(this.currentNode),
|
|
37
37
|
() => {
|
|
38
|
-
this.api.updateValues({ [
|
|
38
|
+
this.api.updateValues({ [r.TRIMMING]: this.store.nameTrimming });
|
|
39
39
|
}
|
|
40
|
-
);
|
|
40
|
+
), this.store.nameTrimming && this._applyTrimmingStyles();
|
|
41
41
|
}
|
|
42
42
|
_onTrimmingChange(e) {
|
|
43
|
-
this.store.setNameTrimming(e),
|
|
43
|
+
this.store.setNameTrimming(e), M(this.currentNode, this.api), this.api.updateValues({ [r.TRIMMING]: e }), this._applyTrimmingStyles(e);
|
|
44
44
|
}
|
|
45
45
|
_applyTrimmingStyles(e) {
|
|
46
|
-
var
|
|
47
|
-
const
|
|
48
|
-
if (!
|
|
46
|
+
var m;
|
|
47
|
+
const o = (m = this.currentNode) == null ? void 0 : m.querySelector("p > a");
|
|
48
|
+
if (!o)
|
|
49
49
|
return;
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
const p = e !== void 0 ? e : this.store.nameTrimming, T = this.store.orientation === I.ORIENTATION.VERTICAL;
|
|
51
|
+
p ? this.api.getDocumentModifier().modifyHtml(o).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", T ? "130px" : "550px").apply(new n("Text Trimming Enabled")) : this.api.getDocumentModifier().modifyHtml(o).removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow").removeStyle("max-width").apply(new n("Text Trimming Disabled"));
|
|
52
52
|
}
|
|
53
53
|
_getTextTrimming() {
|
|
54
54
|
return `
|
|
55
55
|
<div class="container">
|
|
56
56
|
<div class="display-flex align-items-center justify-content-between">
|
|
57
|
-
<${
|
|
57
|
+
<${a.LABEL}
|
|
58
58
|
${g.LABEL.text}="${this.api.translate("Text Trimming")}"
|
|
59
59
|
>
|
|
60
|
-
</${
|
|
61
|
-
${this._GuToggle(
|
|
60
|
+
</${a.LABEL}>
|
|
61
|
+
${this._GuToggle(r.TRIMMING)}
|
|
62
62
|
</div>
|
|
63
63
|
</div>
|
|
64
64
|
`;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
export {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
f as CONTROL_BLOCK_ID,
|
|
69
|
+
R as NameTrimmingControl
|
|
70
70
|
};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { UEAttr as
|
|
5
|
-
import { CommonControl as
|
|
6
|
-
import { ItemsBlockId as
|
|
7
|
-
import { productPairs as
|
|
8
|
-
import { ItemTypeOptions as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { useItemsBlockStore as
|
|
12
|
-
import { getDefaultTemplate as
|
|
13
|
-
import { syncCurrencySymbolFromAttributes as
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var M = (T, u, e) => u in T ? P(T, u, { enumerable: !0, configurable: !0, writable: !0, value: e }) : T[u] = e;
|
|
3
|
+
var C = (T, u, e) => M(T, typeof u != "symbol" ? u + "" : u, e);
|
|
4
|
+
import { UEAttr as b, ModificationDescription as d } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as D } from "../../common-control.js";
|
|
6
|
+
import { ItemsBlockId as m } from "../enums/controlEnums.js";
|
|
7
|
+
import { productPairs as p, templateFirstLine as A } from "../enums/productEnums.js";
|
|
8
|
+
import { ItemTypeOptions as R, OrientationOptions as L, ItemInCartOptions as N, SETTINGS_ENUMS as S } from "../enums/settingsEnums.js";
|
|
9
|
+
import x from "../layouts/horizontal.html.js";
|
|
10
|
+
import H from "../layouts/vertical.html.js";
|
|
11
|
+
import { useItemsBlockStore as U } from "../store/items-block.js";
|
|
12
|
+
import { getDefaultTemplate as F } from "../template.js";
|
|
13
|
+
import { syncCurrencySymbolFromAttributes as $, syncCurrencyLocationFromAttributes as k, syncFormattedPriceFromAttributes as q } from "../utils/syncAttributesFromConfigBlock.js";
|
|
14
14
|
import { updateConfigBlockAttributes as f } from "../utils/updateAttributes.js";
|
|
15
|
-
const
|
|
15
|
+
const w = "ui-elements-items-block", o = {
|
|
16
16
|
ITEMS_TYPE: "itemsType",
|
|
17
17
|
ORIENTATION: "orientation",
|
|
18
18
|
ITEM_IDS: "itemIds"
|
|
19
19
|
};
|
|
20
|
-
class
|
|
20
|
+
class Z extends D {
|
|
21
21
|
constructor() {
|
|
22
22
|
super(...arguments);
|
|
23
|
-
|
|
23
|
+
C(this, "store", U());
|
|
24
24
|
}
|
|
25
25
|
getId() {
|
|
26
|
-
return
|
|
26
|
+
return w;
|
|
27
27
|
}
|
|
28
28
|
getTemplate() {
|
|
29
29
|
return `
|
|
@@ -44,7 +44,7 @@ class te extends x {
|
|
|
44
44
|
onTemplateNodeUpdated(e) {
|
|
45
45
|
super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(
|
|
46
46
|
() => {
|
|
47
|
-
|
|
47
|
+
$(this.currentNode), k(this.currentNode), q(this.currentNode);
|
|
48
48
|
},
|
|
49
49
|
() => {
|
|
50
50
|
this.api.updateValues({
|
|
@@ -67,7 +67,7 @@ class te extends x {
|
|
|
67
67
|
name: o.ITEMS_TYPE,
|
|
68
68
|
className: "es-100",
|
|
69
69
|
placeholder: "Select Item Type",
|
|
70
|
-
options:
|
|
70
|
+
options: R
|
|
71
71
|
})
|
|
72
72
|
])}
|
|
73
73
|
`;
|
|
@@ -97,9 +97,7 @@ class te extends x {
|
|
|
97
97
|
`;
|
|
98
98
|
}
|
|
99
99
|
_onOrientationChange(e) {
|
|
100
|
-
console.debug("Orientation changed to: ", e), this.store.setOrientation(e), this.api.updateValues({ [o.ORIENTATION]: e }), f(this.currentNode, this.api), this._reOrderTemplate(),
|
|
101
|
-
this._recalculateTrimming();
|
|
102
|
-
}, 50);
|
|
100
|
+
console.debug("Orientation changed to: ", e), this.store.setOrientation(e), this.api.updateValues({ [o.ORIENTATION]: e }), f(this.currentNode, this.api), this._reOrderTemplate(), this._recalculateTrimming();
|
|
103
101
|
}
|
|
104
102
|
_onItemsTypeChange(e) {
|
|
105
103
|
const i = S.ITEMS_TYPE[e], t = N[e], r = t == null ? void 0 : t[0];
|
|
@@ -111,8 +109,8 @@ class te extends x {
|
|
|
111
109
|
_initializeSelectItems() {
|
|
112
110
|
this.api.setUIEAttribute(
|
|
113
111
|
o.ITEMS_TYPE,
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
b.SELECTPICKER.items,
|
|
113
|
+
R
|
|
116
114
|
);
|
|
117
115
|
const { itemsType: e, itemIds: i } = this.store;
|
|
118
116
|
this.api.updateValues({
|
|
@@ -121,7 +119,7 @@ class te extends x {
|
|
|
121
119
|
const t = N[e];
|
|
122
120
|
this.api.setUIEAttribute(
|
|
123
121
|
o.ITEM_IDS,
|
|
124
|
-
|
|
122
|
+
b.SELECTPICKER.items,
|
|
125
123
|
t
|
|
126
124
|
), this.api.updateValues({
|
|
127
125
|
[o.ITEM_IDS]: i
|
|
@@ -148,7 +146,7 @@ class te extends x {
|
|
|
148
146
|
currencyLocation: n,
|
|
149
147
|
formattedPrice: s
|
|
150
148
|
} = this.store;
|
|
151
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(
|
|
149
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(F({
|
|
152
150
|
orientation: e,
|
|
153
151
|
itemsType: i,
|
|
154
152
|
itemId: t,
|
|
@@ -160,22 +158,22 @@ class te extends x {
|
|
|
160
158
|
_getTemplateData() {
|
|
161
159
|
const { itemsType: e, itemIds: i, formattedPrice: t } = this.store, r = N[e].findIndex((s) => s.value === i), n = r > -1 ? r : 0;
|
|
162
160
|
return {
|
|
163
|
-
imageSrc:
|
|
164
|
-
name:
|
|
165
|
-
price: t ?
|
|
166
|
-
originalPrice: t ?
|
|
167
|
-
quantity:
|
|
168
|
-
button:
|
|
161
|
+
imageSrc: p.PAIRS_FOR_EXTENSION.imageSrc[e].DEFAULT[n],
|
|
162
|
+
name: p.PAIRS_FOR_EXTENSION.name[e].DEFAULT[n],
|
|
163
|
+
price: t ? p.PAIRS_FOR_EXTENSION.price[e].DEFAULT_PRICE_FORMATTED : p.PAIRS_FOR_EXTENSION.price[e].DEFAULT_PRICE,
|
|
164
|
+
originalPrice: t ? p.PAIRS_FOR_EXTENSION.originalPrice[e].DEFAULT_PRICE_FORMATTED : p.PAIRS_FOR_EXTENSION.originalPrice[e].DEFAULT_PRICE,
|
|
165
|
+
quantity: p.PAIRS_FOR_EXTENSION.quantity[e].DEFAULT,
|
|
166
|
+
button: p.PAIRS_FOR_EXTENSION.button[e].DEFAULT_LABEL
|
|
169
167
|
};
|
|
170
168
|
}
|
|
171
169
|
_updateImageSrc(e) {
|
|
172
170
|
var t;
|
|
173
|
-
const i = (t = this.currentNode) == null ? void 0 : t.querySelector(`[esd-extension-block-id="${
|
|
171
|
+
const i = (t = this.currentNode) == null ? void 0 : t.querySelector(`[esd-extension-block-id="${m.IMAGE}"] img`);
|
|
174
172
|
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute("src", e).apply(new d("Updated image src"));
|
|
175
173
|
}
|
|
176
174
|
_updateName(e) {
|
|
177
175
|
var n;
|
|
178
|
-
const i = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${
|
|
176
|
+
const i = (n = this.currentNode) == null ? void 0 : n.querySelector(`[esd-extension-block-id="${m.NAME}"]`);
|
|
179
177
|
if (!i)
|
|
180
178
|
return;
|
|
181
179
|
const t = i.getInnerText().trim();
|
|
@@ -183,20 +181,20 @@ class te extends x {
|
|
|
183
181
|
r = r.replace(t, e), this.api.getDocumentModifier().modifyHtml(i).setInnerHtml(r).apply(new d("Updated name"));
|
|
184
182
|
}
|
|
185
183
|
_updatePrice(e) {
|
|
186
|
-
var
|
|
187
|
-
const i = (
|
|
184
|
+
var E;
|
|
185
|
+
const i = (E = this.currentNode) == null ? void 0 : E.querySelector(`[esd-extension-block-id="${m.PRICE}"]`);
|
|
188
186
|
if (!i)
|
|
189
187
|
return;
|
|
190
188
|
const t = this._getParagraphFromBlock(i);
|
|
191
189
|
if (!t)
|
|
192
190
|
return;
|
|
193
|
-
const r = t.getInnerHTML() || "", n = t.getInnerText() || "", { currencySymbol: s, currencyLocation: a } = this.store,
|
|
191
|
+
const r = t.getInnerHTML() || "", n = t.getInnerText() || "", { currencySymbol: s, currencyLocation: a } = this.store, l = (s == null ? void 0 : s.trim()) || "", c = this._removeCurrencySymbol(n, l), h = this._replacePriceNumber(c, e), I = this._buildPriceContent(h, l, a), _ = r.replace(n, I);
|
|
194
192
|
this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(_).apply(new d("Updated price"));
|
|
195
193
|
}
|
|
196
194
|
_updateOriginalPrice(e) {
|
|
197
195
|
var y;
|
|
198
196
|
const i = (y = this.currentNode) == null ? void 0 : y.querySelector(
|
|
199
|
-
`[esd-extension-block-id="${
|
|
197
|
+
`[esd-extension-block-id="${m.ORIGINAL_PRICE}"]`
|
|
200
198
|
);
|
|
201
199
|
if (!i)
|
|
202
200
|
return;
|
|
@@ -206,12 +204,12 @@ class te extends x {
|
|
|
206
204
|
const r = t.querySelector("s");
|
|
207
205
|
if (!r)
|
|
208
206
|
return;
|
|
209
|
-
const n = r.getInnerHTML() || "", s = r.getInnerText() || "", { currencySymbol: a, currencyLocation:
|
|
210
|
-
this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(
|
|
207
|
+
const n = r.getInnerHTML() || "", s = r.getInnerText() || "", { currencySymbol: a, currencyLocation: l } = this.store, c = (a == null ? void 0 : a.trim()) || "", h = this._removeCurrencySymbol(s, c), I = this._replacePriceNumber(h, e), _ = this._buildPriceContent(I, c, l), g = `<s>${n.replace(s, _)}</s>`;
|
|
208
|
+
this.api.getDocumentModifier().modifyHtml(t).setInnerHtml(g).apply(new d("Updated original price"));
|
|
211
209
|
}
|
|
212
210
|
_updateQuantity(e) {
|
|
213
211
|
var a;
|
|
214
|
-
const i = this.store.itemsType !== S.ITEMS_TYPE.BROWSED_ITEMS, t = (a = this.currentNode) == null ? void 0 : a.querySelector(`[esd-extension-block-id="${
|
|
212
|
+
const i = this.store.itemsType !== S.ITEMS_TYPE.BROWSED_ITEMS, t = (a = this.currentNode) == null ? void 0 : a.querySelector(`[esd-extension-block-id="${m.QUANTITY}"]`);
|
|
215
213
|
if (!t)
|
|
216
214
|
return;
|
|
217
215
|
const r = t.getStyle("display") === "none", n = t.getInnerText().trim();
|
|
@@ -223,17 +221,15 @@ class te extends x {
|
|
|
223
221
|
* @description Reorders the template structure based on current orientation and visibility settings.
|
|
224
222
|
*/
|
|
225
223
|
_reOrderTemplate() {
|
|
226
|
-
var I, _,
|
|
227
|
-
const e = (
|
|
228
|
-
`[esd-extension-block-id="${
|
|
229
|
-
), n = (
|
|
224
|
+
var h, I, _, E, g, y, O;
|
|
225
|
+
const e = (h = this.currentNode) == null ? void 0 : h.querySelector(`[esd-extension-block-id="${m.IMAGE}"]`), i = (I = this.currentNode) == null ? void 0 : I.querySelector(`[esd-extension-block-id="${m.NAME}"]`), t = (_ = this.currentNode) == null ? void 0 : _.querySelector(`[esd-extension-block-id="${m.PRICE}"]`), r = (E = this.currentNode) == null ? void 0 : E.querySelector(
|
|
226
|
+
`[esd-extension-block-id="${m.ORIGINAL_PRICE}"]`
|
|
227
|
+
), n = (g = this.currentNode) == null ? void 0 : g.querySelector(`[esd-extension-block-id="${m.QUANTITY}"]`), s = (y = this.currentNode) == null ? void 0 : y.querySelector(`[esd-extension-block-id="${m.BUTTON}"]`), a = (O = this.currentNode) == null ? void 0 : O.querySelector("esd-config-block");
|
|
230
228
|
if (!e || !i || !t || !r || !n || !s || !a)
|
|
231
229
|
return;
|
|
232
|
-
const { orientation:
|
|
233
|
-
let
|
|
234
|
-
|
|
235
|
-
u = u.replace("{-{-TEMPLATE_FIRST_LINE-}-}", m ? R : "").replace("{-{-PRODUCT_IMAGE-}-}", e.getOuterHTML()).replace("{-{-PRODUCT_NAME-}-}", i.getOuterHTML()).replace("{-{-PRODUCT_PRICE-}-}", t.getOuterHTML()).replace("{-{-PRODUCT_ORIGINAL_PRICE-}-}", r.getOuterHTML()).replace("{-{-PRODUCT_QUANTITY-}-}", n.getOuterHTML()).replace("{-{-PRODUCT_BUTTON-}-}", s.getOuterHTML()).replace("{-{-CONFIG_BLOCK-}-}", a.getOuterHTML()), u = u.trim().replace(R, "").slice(0, -5), this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(u).apply(new d("Reordered template"));
|
|
236
|
-
}, 50);
|
|
230
|
+
const { orientation: l } = this.store;
|
|
231
|
+
let c = l === S.ORIENTATION.VERTICAL ? H : x;
|
|
232
|
+
c = c.replace("{-{-TEMPLATE_FIRST_LINE-}-}", A).replace("{-{-PRODUCT_IMAGE-}-}", e.getOuterHTML()).replace("{-{-PRODUCT_NAME-}-}", i.getOuterHTML()).replace("{-{-PRODUCT_PRICE-}-}", t.getOuterHTML()).replace("{-{-PRODUCT_ORIGINAL_PRICE-}-}", r.getOuterHTML()).replace("{-{-PRODUCT_QUANTITY-}-}", n.getOuterHTML()).replace("{-{-PRODUCT_BUTTON-}-}", s.getOuterHTML()).replace("{-{-CONFIG_BLOCK-}-}", a.getOuterHTML()), c = c.trim().replace(A, "").slice(0, -5), this.api.getDocumentModifier().modifyHtml(this.currentNode).setInnerHtml(c).apply(new d("Reordered template"));
|
|
237
233
|
}
|
|
238
234
|
_updateDataTypeAttributes(e) {
|
|
239
235
|
if (!this.currentNode)
|
|
@@ -247,21 +243,21 @@ class te extends x {
|
|
|
247
243
|
_updateDataNumberAttributes(e) {
|
|
248
244
|
if (!this.currentNode)
|
|
249
245
|
return;
|
|
250
|
-
const { itemsType: i } = this.store, t = N[i].findIndex((
|
|
246
|
+
const { itemsType: i } = this.store, t = N[i].findIndex((l) => l.value === e);
|
|
251
247
|
let r = "1";
|
|
252
248
|
if (t >= 0)
|
|
253
249
|
r = String(t + 1);
|
|
254
250
|
else if (e) {
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
const [,
|
|
258
|
-
r =
|
|
251
|
+
const l = e.match(/\((\d+)\)/);
|
|
252
|
+
if (l) {
|
|
253
|
+
const [, c] = l;
|
|
254
|
+
r = c;
|
|
259
255
|
}
|
|
260
256
|
}
|
|
261
257
|
const n = this.currentNode.closest(".ins-product-td"), s = this.api.getDocumentModifier();
|
|
262
|
-
n && s.modifyHtml(n).setAttribute("data-number", r), this.currentNode.querySelectorAll("[data-number]").forEach((
|
|
263
|
-
const
|
|
264
|
-
s.modifyHtml(
|
|
258
|
+
n && s.modifyHtml(n).setAttribute("data-number", r), this.currentNode.querySelectorAll("[data-number]").forEach((l) => {
|
|
259
|
+
const c = l;
|
|
260
|
+
s.modifyHtml(c).setAttribute("data-number", r);
|
|
265
261
|
}), s.apply(new d("Updated data-number attribute"));
|
|
266
262
|
}
|
|
267
263
|
_reFillTemplate() {
|
|
@@ -269,17 +265,17 @@ class te extends x {
|
|
|
269
265
|
this._updateImageSrc(e.imageSrc), this._updateName(e.name), this._updatePrice(e.price), this._updateOriginalPrice(e.originalPrice), this._updateQuantity(e.quantity);
|
|
270
266
|
}
|
|
271
267
|
_recalculateTrimming() {
|
|
272
|
-
var
|
|
273
|
-
if (!this.currentNode)
|
|
268
|
+
var r;
|
|
269
|
+
if (!this.store.nameTrimming || !this.currentNode)
|
|
274
270
|
return;
|
|
275
|
-
const e = (
|
|
271
|
+
const e = (r = this.currentNode) == null ? void 0 : r.querySelector(`[esd-extension-block-id="${m.NAME}"]`);
|
|
276
272
|
if (!e)
|
|
277
273
|
return;
|
|
278
|
-
const i = e.querySelector("p
|
|
274
|
+
const i = e.querySelector("p");
|
|
279
275
|
if (!i)
|
|
280
276
|
return;
|
|
281
|
-
const t = this.store.orientation === S.ORIENTATION.VERTICAL
|
|
282
|
-
this.api.getDocumentModifier().modifyHtml(i).setStyle("
|
|
277
|
+
const t = this.store.orientation === S.ORIENTATION.VERTICAL;
|
|
278
|
+
this.api.getDocumentModifier().modifyHtml(i).setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis").setStyle("max-width", t ? "130px" : "100%").apply(new d("Recalculated trimming after orientation change"));
|
|
283
279
|
}
|
|
284
280
|
_getParagraphFromBlock(e) {
|
|
285
281
|
return e.querySelector("p");
|
|
@@ -311,6 +307,6 @@ class te extends x {
|
|
|
311
307
|
}
|
|
312
308
|
}
|
|
313
309
|
export {
|
|
314
|
-
|
|
315
|
-
|
|
310
|
+
w as CONTROL_BLOCK_ID,
|
|
311
|
+
Z as ItemsBlockControl
|
|
316
312
|
};
|
|
@@ -19,7 +19,7 @@ const e = {
|
|
|
19
19
|
itemsType: e.ITEMS_TYPE.CART_ITEMS,
|
|
20
20
|
cartItemsSelectControlValue: "{{Abandoned Cart Item (1) Url}}",
|
|
21
21
|
cardOrientationControlValue: e.ORIENTATION.HORIZONTAL,
|
|
22
|
-
productNameTrimmingControlValue: "
|
|
22
|
+
productNameTrimmingControlValue: "0",
|
|
23
23
|
productPriceHideDiscountControlValue: "0",
|
|
24
24
|
productPriceFormattedControlValue: "1",
|
|
25
25
|
productPriceCurrencySymbolControlValue: "USD",
|
|
@@ -34,8 +34,7 @@ const e = {
|
|
|
34
34
|
productQuantityVisible: "1",
|
|
35
35
|
productPriceVisible: "1",
|
|
36
36
|
productOriginalPriceVisible: "1",
|
|
37
|
-
productButtonVisible: "1"
|
|
38
|
-
productImageWidth: "70"
|
|
37
|
+
productButtonVisible: "1"
|
|
39
38
|
}, o = {
|
|
40
39
|
[e.ITEMS_TYPE.CART_ITEMS]: [
|
|
41
40
|
{ text: "Abandoned Cart Item (1)", value: "{{Abandoned Cart Item (1) Url}}" },
|
|
@@ -8,7 +8,7 @@ const n = (t) => t.replace(/Url\}/, "Image}"), o = (t) => t.replace(/Image\}/, "
|
|
|
8
8
|
imageLink: n(t),
|
|
9
9
|
buttonLink: o(t),
|
|
10
10
|
orientation: e.cardOrientationControlValue,
|
|
11
|
-
nameTrimming: !
|
|
11
|
+
nameTrimming: !1,
|
|
12
12
|
hideDiscount: !1,
|
|
13
13
|
currencySymbol: "USD",
|
|
14
14
|
currencyLocation: "0",
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { BlockType as l, BlockAttr as _ } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
-
import { ItemsBlockId as
|
|
2
|
+
import { ItemsBlockId as d } from "./enums/controlEnums.js";
|
|
3
3
|
import { productPairs as i, templateFirstLine as N } from "./enums/productEnums.js";
|
|
4
|
-
import { ItemInCartOptions as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
let [
|
|
8
|
-
const
|
|
4
|
+
import { ItemInCartOptions as P, SETTINGS_ENUMS as O } from "./enums/settingsEnums.js";
|
|
5
|
+
import f from "./layouts/horizontal.html.js";
|
|
6
|
+
import B from "./layouts/vertical.html.js";
|
|
7
|
+
let [R] = i.PAIRS_FOR_EXTENSION.imageSrc.CART_ITEMS.DEFAULT, [C] = i.PAIRS_FOR_EXTENSION.name.CART_ITEMS.DEFAULT, [I] = i.PAIRS_FOR_EXTENSION.price.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [$] = i.PAIRS_FOR_EXTENSION.originalPrice.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [u] = i.PAIRS_FOR_EXTENSION.quantity.CART_ITEMS.DEFAULT;
|
|
8
|
+
const g = (a, t) => `
|
|
9
9
|
<${l.BLOCK_IMAGE}
|
|
10
|
-
${_.BLOCK_IMAGE.src}="${
|
|
11
|
-
${_.BLOCK_IMAGE.alt}="
|
|
10
|
+
${_.BLOCK_IMAGE.src}="${R}"
|
|
11
|
+
${_.BLOCK_IMAGE.alt}="Product Image"
|
|
12
12
|
${_.BLOCK_IMAGE.href}="#!"
|
|
13
|
-
${_.BLOCK_IMAGE.width}
|
|
14
|
-
esd-extension-block-id="${
|
|
13
|
+
${_.BLOCK_IMAGE.width}="70"
|
|
14
|
+
esd-extension-block-id="${d.IMAGE}"
|
|
15
15
|
data-slot-1
|
|
16
16
|
product-attr="imageSrc"
|
|
17
17
|
data-type="${a}"
|
|
@@ -23,7 +23,7 @@ const h = (a, t) => `
|
|
|
23
23
|
align="center"
|
|
24
24
|
class="es-p10"
|
|
25
25
|
data-type="${a}"
|
|
26
|
-
esd-extension-block-id="${
|
|
26
|
+
esd-extension-block-id="${d.NAME}"
|
|
27
27
|
>
|
|
28
28
|
<p contenteditable="false">
|
|
29
29
|
<a
|
|
@@ -35,30 +35,24 @@ const h = (a, t) => `
|
|
|
35
35
|
line-height: inherit;
|
|
36
36
|
font-family: inherit;
|
|
37
37
|
color: inherit;
|
|
38
|
-
display: block;
|
|
39
|
-
word-wrap:break-word;
|
|
40
|
-
white-space: nowrap;
|
|
41
|
-
width: 520px;
|
|
42
|
-
overflow: hidden;
|
|
43
|
-
text-overflow: ellipsis;
|
|
44
38
|
"
|
|
45
39
|
product-attr="name"
|
|
46
40
|
data-slot-2
|
|
47
41
|
width="100%">
|
|
48
|
-
${
|
|
42
|
+
${C}
|
|
49
43
|
</a>
|
|
50
44
|
</p>
|
|
51
45
|
</${l.BLOCK_TEXT}>
|
|
52
|
-
`, S = (a, t,
|
|
53
|
-
let
|
|
46
|
+
`, S = (a, t, n, e, c) => {
|
|
47
|
+
let o = I;
|
|
54
48
|
if (e && e.trim()) {
|
|
55
|
-
const
|
|
56
|
-
|
|
49
|
+
const T = ` ${e.trim()} `;
|
|
50
|
+
o = (c || "0") === "1" ? `${I}${T}` : `${T}${I}`;
|
|
57
51
|
}
|
|
58
|
-
const r = c === "1" ? "after" : "before",
|
|
52
|
+
const r = c === "1" ? "after" : "before", E = `data-formated="${n ? "true" : "false"}"`, s = `data-curency="${r}"`;
|
|
59
53
|
return `
|
|
60
54
|
<${l.BLOCK_TEXT}
|
|
61
|
-
esd-extension-block-id="${
|
|
55
|
+
esd-extension-block-id="${d.PRICE}"
|
|
62
56
|
class="items-block-price"
|
|
63
57
|
width="100%"
|
|
64
58
|
align="center"
|
|
@@ -69,25 +63,25 @@ const h = (a, t) => `
|
|
|
69
63
|
data-slot-4
|
|
70
64
|
data-type="${a}"
|
|
71
65
|
data-number="${t}"
|
|
72
|
-
${
|
|
66
|
+
${E}
|
|
73
67
|
${s}
|
|
74
68
|
${e ? `data-currency_symbol="${e}"` : ""}
|
|
75
69
|
>
|
|
76
|
-
${
|
|
70
|
+
${o}
|
|
77
71
|
</p>
|
|
78
72
|
</${l.BLOCK_TEXT}>
|
|
79
73
|
`;
|
|
80
|
-
}, L = (a, t,
|
|
81
|
-
let
|
|
74
|
+
}, L = (a, t, n, e, c) => {
|
|
75
|
+
let o = $;
|
|
82
76
|
if (e && e.trim()) {
|
|
83
|
-
const
|
|
84
|
-
|
|
77
|
+
const T = ` ${e.trim()} `;
|
|
78
|
+
o = (c || "0") === "1" ? `${$}${T}` : `${T}${$}`;
|
|
85
79
|
}
|
|
86
|
-
const r = c === "1" ? "after" : "before",
|
|
80
|
+
const r = c === "1" ? "after" : "before", E = `data-formated="${n ? "true" : "false"}"`, s = `data-curency="${r}"`;
|
|
87
81
|
return `
|
|
88
82
|
<${l.BLOCK_TEXT}
|
|
89
83
|
class="items-block-price"
|
|
90
|
-
esd-extension-block-id="${
|
|
84
|
+
esd-extension-block-id="${d.ORIGINAL_PRICE}"
|
|
91
85
|
width="100%"
|
|
92
86
|
align="center"
|
|
93
87
|
>
|
|
@@ -98,11 +92,11 @@ const h = (a, t) => `
|
|
|
98
92
|
style="color: #cc0000"
|
|
99
93
|
data-type="${a}"
|
|
100
94
|
data-number="${t}"
|
|
101
|
-
${
|
|
95
|
+
${E}
|
|
102
96
|
${s}
|
|
103
97
|
${e ? `data-currency_symbol="${e}"` : ""}
|
|
104
98
|
>
|
|
105
|
-
<s>${
|
|
99
|
+
<s>${o}</s>
|
|
106
100
|
</p>
|
|
107
101
|
</${l.BLOCK_TEXT}>
|
|
108
102
|
`;
|
|
@@ -111,7 +105,7 @@ const h = (a, t) => `
|
|
|
111
105
|
width="100%"
|
|
112
106
|
align="center"
|
|
113
107
|
class="es-p10"
|
|
114
|
-
esd-extension-block-id="${
|
|
108
|
+
esd-extension-block-id="${d.QUANTITY}"
|
|
115
109
|
>
|
|
116
110
|
<p
|
|
117
111
|
product-attr="quantity"
|
|
@@ -121,75 +115,75 @@ const h = (a, t) => `
|
|
|
121
115
|
${u}
|
|
122
116
|
</p>
|
|
123
117
|
</${l.BLOCK_TEXT}>
|
|
124
|
-
`,
|
|
118
|
+
`, h = (a, t) => `
|
|
125
119
|
<${l.BLOCK_BUTTON}
|
|
126
120
|
width="100%"
|
|
127
121
|
class="ins-button"
|
|
128
122
|
name="buy-button"
|
|
129
123
|
caption="Buy"
|
|
130
124
|
align="center"
|
|
131
|
-
esd-extension-block-id="${
|
|
125
|
+
esd-extension-block-id="${d.BUTTON}"
|
|
132
126
|
product-attr="button"
|
|
133
127
|
data-slot-6
|
|
134
128
|
data-type="${a}"
|
|
135
129
|
data-number="${t}"
|
|
136
130
|
>Buy
|
|
137
131
|
</${l.BLOCK_BUTTON}>
|
|
138
|
-
`,
|
|
132
|
+
`, U = () => `
|
|
139
133
|
<esd-config-block style="display: none;"></esd-config-block>
|
|
140
|
-
`,
|
|
141
|
-
const
|
|
134
|
+
`, p = (a, t, n, e, c, o, r, E) => {
|
|
135
|
+
const A = `${`data-type="${t}" data-number="${n}"`} data-orientation="${e}"`;
|
|
142
136
|
return a.replace(
|
|
143
137
|
/<td([^>]*class="[^"]*ins-product-td[^"]*"[^>]*)>/,
|
|
144
|
-
`<td$1 ${
|
|
145
|
-
).replace("{-{-TEMPLATE_FIRST_LINE-}-}", N).replace("{-{-PRODUCT_IMAGE-}-}",
|
|
138
|
+
`<td$1 ${A}>`
|
|
139
|
+
).replace("{-{-TEMPLATE_FIRST_LINE-}-}", N).replace("{-{-PRODUCT_IMAGE-}-}", g(t, n)).replace("{-{-PRODUCT_NAME-}-}", F(t)).replace(
|
|
146
140
|
"{-{-PRODUCT_PRICE-}-}",
|
|
147
|
-
S(t,
|
|
141
|
+
S(t, n, c, o, r)
|
|
148
142
|
).replace(
|
|
149
143
|
"{-{-PRODUCT_ORIGINAL_PRICE-}-}",
|
|
150
144
|
L(
|
|
151
145
|
t,
|
|
152
|
-
o,
|
|
153
|
-
c,
|
|
154
146
|
n,
|
|
147
|
+
c,
|
|
148
|
+
o,
|
|
155
149
|
r
|
|
156
150
|
)
|
|
157
|
-
).replace("{-{-PRODUCT_QUANTITY-}-}", b()).replace("{-{-PRODUCT_BUTTON-}-}",
|
|
151
|
+
).replace("{-{-PRODUCT_QUANTITY-}-}", b()).replace("{-{-PRODUCT_BUTTON-}-}", h(t, n)).replace("{-{-CONFIG_BLOCK-}-}", U());
|
|
158
152
|
};
|
|
159
|
-
function
|
|
153
|
+
function x({
|
|
160
154
|
orientation: a,
|
|
161
155
|
itemsType: t = O.ITEMS_TYPE.CART_ITEMS,
|
|
162
|
-
itemId:
|
|
156
|
+
itemId: n,
|
|
163
157
|
currencySymbol: e,
|
|
164
158
|
currencyLocation: c,
|
|
165
|
-
formattedPrice:
|
|
159
|
+
formattedPrice: o = !0
|
|
166
160
|
}) {
|
|
167
|
-
const r =
|
|
168
|
-
let
|
|
161
|
+
const r = P[t].findIndex((s) => s.value === n);
|
|
162
|
+
let E = "1";
|
|
169
163
|
if (r >= 0)
|
|
170
|
-
|
|
171
|
-
else if (
|
|
172
|
-
const s =
|
|
173
|
-
s && s[1] && ([,
|
|
164
|
+
E = String(r + 1);
|
|
165
|
+
else if (n) {
|
|
166
|
+
const s = n.match(/\((\d+)\)/);
|
|
167
|
+
s && s[1] && ([, E] = s);
|
|
174
168
|
}
|
|
175
|
-
return
|
|
176
|
-
|
|
169
|
+
return R = i.PAIRS_FOR_EXTENSION.imageSrc[t].DEFAULT[r >= 0 ? r : 0], C = i.PAIRS_FOR_EXTENSION.name[t].DEFAULT[r >= 0 ? r : 0], I = o ? i.PAIRS_FOR_EXTENSION.price[t].DEFAULT_PRICE_FORMATTED : i.PAIRS_FOR_EXTENSION.price[t].DEFAULT_PRICE, $ = o ? i.PAIRS_FOR_EXTENSION.originalPrice[t].DEFAULT_PRICE_FORMATTED : i.PAIRS_FOR_EXTENSION.originalPrice[t].DEFAULT_PRICE, u = i.PAIRS_FOR_EXTENSION.quantity[t].DEFAULT, a === O.ORIENTATION.VERTICAL ? p(
|
|
170
|
+
B,
|
|
177
171
|
t,
|
|
178
|
-
|
|
172
|
+
E,
|
|
179
173
|
a,
|
|
180
|
-
|
|
174
|
+
o,
|
|
181
175
|
e,
|
|
182
176
|
c
|
|
183
|
-
) :
|
|
184
|
-
|
|
177
|
+
) : p(
|
|
178
|
+
f,
|
|
185
179
|
t,
|
|
186
|
-
|
|
180
|
+
E,
|
|
187
181
|
a,
|
|
188
|
-
|
|
182
|
+
o,
|
|
189
183
|
e,
|
|
190
184
|
c
|
|
191
185
|
);
|
|
192
186
|
}
|
|
193
187
|
export {
|
|
194
|
-
|
|
188
|
+
x as getDefaultTemplate
|
|
195
189
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (n, i, e) =>
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var S = (n, i, e) => i in n ? _(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
|
|
3
|
+
var u = (n, i, e) => S(n, typeof i != "symbol" ? i + "" : i, e);
|
|
4
4
|
import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
|
|
5
5
|
import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
|
|
6
|
-
import { Block as
|
|
7
|
-
import { getDefaultTemplate as
|
|
6
|
+
import { Block as d, BlockCompositionType as L, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
|
+
import { getDefaultTemplate as h } from "./template.js";
|
|
8
8
|
import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
|
|
9
|
-
import { parsePageList as
|
|
10
|
-
const
|
|
9
|
+
import { parsePageList as m } from "./utils/utils.js";
|
|
10
|
+
const v = "unsubscribe-block", g = 'a[data-unsubscribe-link="true"]', T = ".unsubscribe-block-v2", f = "{{ins-unsubscribe-link}}", B = {
|
|
11
11
|
[E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
12
12
|
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class D extends d {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
u(this, "selectEventListener", null);
|
|
@@ -19,13 +19,13 @@ class R extends h {
|
|
|
19
19
|
u(this, "currentNode");
|
|
20
20
|
}
|
|
21
21
|
getId() {
|
|
22
|
-
return
|
|
22
|
+
return v;
|
|
23
23
|
}
|
|
24
24
|
getIcon() {
|
|
25
25
|
return "unsubscribe-icon";
|
|
26
26
|
}
|
|
27
27
|
getBlockCompositionType() {
|
|
28
|
-
return
|
|
28
|
+
return L.BLOCK;
|
|
29
29
|
}
|
|
30
30
|
getName() {
|
|
31
31
|
return this.api.translate("Unsubscribe Block");
|
|
@@ -34,10 +34,13 @@ class R extends h {
|
|
|
34
34
|
return this.api.translate("Unsubscribe Block Description");
|
|
35
35
|
}
|
|
36
36
|
getTemplate() {
|
|
37
|
-
return
|
|
37
|
+
return h();
|
|
38
|
+
}
|
|
39
|
+
onCreated(e) {
|
|
40
|
+
"getOuterHTML" in e && !e.getOuterHTML() || "getAttribute" in e && e.getAttribute("data-migration") || (this.currentNode = e, this._resetStoreState(), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
|
|
38
41
|
}
|
|
39
42
|
onSelect(e) {
|
|
40
|
-
this.currentNode = e,
|
|
43
|
+
this.currentNode = e, this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener();
|
|
41
44
|
}
|
|
42
45
|
onDelete(e) {
|
|
43
46
|
this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
|
|
@@ -63,13 +66,7 @@ class R extends h {
|
|
|
63
66
|
this.cancelEventListener && (document.removeEventListener(a.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
|
|
64
67
|
}
|
|
65
68
|
_handleCancel() {
|
|
66
|
-
|
|
67
|
-
if (!this.currentNode)
|
|
68
|
-
return;
|
|
69
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).delete().apply(new b("Removed unsubscribe block due to cancel"));
|
|
70
|
-
} catch (e) {
|
|
71
|
-
console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
|
|
72
|
-
}
|
|
69
|
+
this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).delete().apply(new b("Removed unsubscribe block due to cancel"));
|
|
73
70
|
}
|
|
74
71
|
_removeEventListeners() {
|
|
75
72
|
this._removeSelectEventListener(), this._removeCancelEventListener();
|
|
@@ -77,27 +74,26 @@ class R extends h {
|
|
|
77
74
|
_updateBlock(e, s) {
|
|
78
75
|
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
79
76
|
return;
|
|
80
|
-
const t = this.currentNode.querySelector(
|
|
77
|
+
const t = this.currentNode.querySelector(g);
|
|
81
78
|
if (!t)
|
|
82
79
|
return;
|
|
83
80
|
const r = this._getMergeTag(e);
|
|
84
81
|
this.api.getDocumentModifier().modifyHtml(t).setAttribute("href", r).apply(new b(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, s).apply(new b("Updated unsubscribe block metadata"));
|
|
85
82
|
}
|
|
86
83
|
_getMergeTag(e) {
|
|
87
|
-
return
|
|
84
|
+
return B[e] ?? f;
|
|
88
85
|
}
|
|
89
86
|
_openDrawer() {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
87
|
+
try {
|
|
88
|
+
const e = c();
|
|
89
|
+
e.typeSelectionDrawerStatus = !0;
|
|
90
|
+
} catch (e) {
|
|
91
|
+
console.error("[UnsubscribeBlock] Failed to open drawer:", e);
|
|
92
|
+
}
|
|
97
93
|
}
|
|
98
94
|
_checkExistingBlocks() {
|
|
99
95
|
const e = c();
|
|
100
|
-
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(
|
|
96
|
+
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(T).forEach((t) => {
|
|
101
97
|
if ("getAttribute" in t) {
|
|
102
98
|
const r = t.getAttribute(o.PAGE_TYPE);
|
|
103
99
|
if (r) {
|
|
@@ -113,8 +109,8 @@ class R extends h {
|
|
|
113
109
|
const s = e.getAttribute(o.PAGE_TYPE), t = e.getAttribute(o.PAGE_LIST);
|
|
114
110
|
if (!s || !t)
|
|
115
111
|
return;
|
|
116
|
-
const r = c(), l = Number(s),
|
|
117
|
-
r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(
|
|
112
|
+
const r = c(), l = Number(s), p = m(t);
|
|
113
|
+
r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(p);
|
|
118
114
|
}
|
|
119
115
|
_resetStoreState() {
|
|
120
116
|
c().$reset();
|
|
@@ -125,11 +121,11 @@ class R extends h {
|
|
|
125
121
|
const s = e.getAttribute(o.PAGE_LIST);
|
|
126
122
|
if (!s)
|
|
127
123
|
return;
|
|
128
|
-
const t = c(), r =
|
|
124
|
+
const t = c(), r = m(s);
|
|
129
125
|
t.removeUnsubscribePages(r);
|
|
130
126
|
}
|
|
131
127
|
}
|
|
132
128
|
export {
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
v as UNSUBSCRIBE_BLOCK_ID,
|
|
130
|
+
D as UnsubscribeBlock
|
|
135
131
|
};
|
|
@@ -5,4 +5,5 @@ export declare const useActionsApi: () => {
|
|
|
5
5
|
getTemplateData: () => Promise<TemplateData>;
|
|
6
6
|
activateCustomViewStyles: (isActive?: boolean) => void;
|
|
7
7
|
getPreviewData: (options?: CompileEmailOptions) => Promise<CompiledEmailResult>;
|
|
8
|
+
updateTimerInClonedTemplate: () => Promise<string | null>;
|
|
8
9
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
2
2
|
import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
|
|
3
3
|
export declare const UNSUBSCRIBE_BLOCK_ID = "unsubscribe-block";
|
|
4
4
|
export declare class UnsubscribeBlock extends Block {
|
|
@@ -12,8 +12,9 @@ export declare class UnsubscribeBlock extends Block {
|
|
|
12
12
|
getName(): string;
|
|
13
13
|
getDescription(): string;
|
|
14
14
|
getTemplate(): string;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
onCreated(node: ImmutableHtmlNode): void;
|
|
16
|
+
onSelect(node: ImmutableHtmlNode): undefined;
|
|
17
|
+
onDelete(node: ImmutableHtmlNode): undefined;
|
|
17
18
|
onDestroy(): void;
|
|
18
19
|
private _setupSelectEventListener;
|
|
19
20
|
private _removeSelectEventListener;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "1.0.3-beta.
|
|
3
|
+
"version": "1.0.3-beta.ea69f4a",
|
|
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",
|