@useinsider/guido 3.27.0-beta.ee85b86 → 3.27.1-beta.842075e
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 +5 -10
- package/dist/components/Guido.vue.js +7 -7
- package/dist/components/Guido.vue2.js +83 -86
- package/dist/composables/useHtmlCompiler.js +8 -9
- package/dist/composables/useModuleRepair.js +32 -63
- package/dist/composables/useRecommendation.js +8 -16
- package/dist/composables/useStripo.js +43 -44
- package/dist/config/compiler/htmlCompilerRules.js +6 -16
- package/dist/config/compiler/recommendationCompilerRules.js +29 -41
- package/dist/config/migrator/unsubscribeMigrator.js +112 -100
- package/dist/enums/recommendation.js +4 -5
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +58 -40
- package/dist/extensions/Blocks/Unsubscribe/block.js +104 -96
- package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +4 -3
- package/dist/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.js +5 -0
- package/dist/guido.css +1 -1
- package/dist/package.json.js +4 -4
- package/dist/src/@types/generic.d.ts +0 -7
- package/dist/src/composables/useModuleRepair.d.ts +0 -6
- package/dist/src/composables/useRecommendation.d.ts +0 -4
- package/dist/src/enums/recommendation.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Unsubscribe/utils/constants.d.ts +1 -0
- package/dist/src/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.d.ts +1 -0
- package/dist/src/utils/dynamicContentConverter.d.ts +18 -20
- package/dist/src/utils/genericUtil.d.ts +8 -4
- package/dist/static/stripo-runtime-manifest.json.js +2 -2
- package/dist/utils/dynamicContentConverter.js +27 -41
- package/dist/utils/genericUtil.js +39 -39
- package/package.json +2 -2
- package/dist/components/organisms/dynamic-content/AmbiguousDynamicContentModal.vue.js +0 -24
- package/dist/components/organisms/dynamic-content/AmbiguousDynamicContentModal.vue2.js +0 -59
- package/dist/composables/useAmbiguousDynamicContent.js +0 -72
- package/dist/enums/dynamic-content.js +0 -4
- package/dist/src/components/organisms/dynamic-content/AmbiguousDynamicContentModal.vue.d.ts +0 -2
- package/dist/src/composables/useAmbiguousDynamicContent.d.ts +0 -7
- package/dist/src/enums/dynamic-content.d.ts +0 -3
- package/dist/src/stores/module-dynamic-content.d.ts +0 -30
- package/dist/src/utils/dynamicContentPendingMarker.d.ts +0 -2
- package/dist/stores/module-dynamic-content.js +0 -20
- package/dist/utils/dynamicContentPendingMarker.js +0 -6
|
@@ -9,4 +9,5 @@ export declare const DATA_ATTRIBUTES: {
|
|
|
9
9
|
readonly BLOCK_ID: "data-unsubscribe-block-id";
|
|
10
10
|
};
|
|
11
11
|
export declare const UNSUBSCRIBE_BLOCK_SELECTOR = ".unsubscribe-block-v2";
|
|
12
|
+
export declare const UNSUBSCRIBE_MERGE_TAG_REGEX: RegExp;
|
|
12
13
|
export declare const UNSUBSCRIBE_LINK_SELECTOR = "a[data-unsubscribe-link=\"true\"], a.unsubscribe-link";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const swapMergeTagInHref: (href: string, mergeTag: string) => string;
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type DynamicContentLookup = Map<string, DynamicContentCandidate[]>;
|
|
3
|
-
export interface AmbiguousDynamicContent {
|
|
4
|
-
/** The label as the author wrote it (first occurrence). */
|
|
5
|
-
label: string;
|
|
6
|
-
/** Every exact token name that resolved to this label, so a choice never touches a valid token. */
|
|
7
|
-
spellings: string[];
|
|
8
|
-
candidates: DynamicContentCandidate[];
|
|
9
|
-
}
|
|
1
|
+
import type { DynamicContent } from '@@/Types/generic';
|
|
10
2
|
export interface DynamicContentConversionResult {
|
|
11
3
|
html: string;
|
|
12
4
|
/** Distinct tokens that matched neither a known value nor a known label (reported to the user). */
|
|
13
5
|
unresolved: string[];
|
|
14
|
-
/** Labels shared by several attributes; left untouched for the user to choose. */
|
|
15
|
-
ambiguous: AmbiguousDynamicContent[];
|
|
16
6
|
}
|
|
17
7
|
/**
|
|
18
|
-
* Builds a label
|
|
19
|
-
* normalized (trimmed, lowercased).
|
|
8
|
+
* Builds a label→item lookup from one or more dynamic-content lists, keyed by
|
|
9
|
+
* normalized label (trimmed, lowercased). When lists overlap, a later list wins
|
|
10
|
+
* for a shared key.
|
|
20
11
|
*/
|
|
21
|
-
export declare const buildDynamicContentLookup: (
|
|
12
|
+
export declare const buildDynamicContentLookup: (...lists: DynamicContent[][]) => Map<string, DynamicContent>;
|
|
22
13
|
/**
|
|
23
|
-
*
|
|
24
|
-
* →
|
|
14
|
+
* Repairs dynamic-content tokens in a dropped module's HTML, using `lookup`
|
|
15
|
+
* (label→item) built from the account's full dynamic-content list. Returns the
|
|
16
|
+
* rewritten HTML plus the tokens it could not resolve.
|
|
17
|
+
*
|
|
18
|
+
* A token is rewritten to its canonical `{{value}}` form when its name matches a
|
|
19
|
+
* display label (`{{ Phone Number }}` → `{{phone_number}}`). Left untouched: an
|
|
20
|
+
* exact canonical value (already correct — this also stops a valid token being
|
|
21
|
+
* rewritten just because it coincides with an unrelated label), Liquid nested
|
|
22
|
+
* tokens (dotted, e.g. `coupon.code`), recommendation-block variables
|
|
23
|
+
* (`123_0_attr`), allowed system tokens, and `data-*` product tags. The account
|
|
24
|
+
* list is exhaustive, so any remaining token matching neither a value nor a label
|
|
25
|
+
* is reported in `unresolved`; the text itself is always left in place.
|
|
25
26
|
*/
|
|
26
|
-
export declare const convertModuleDynamicContent: (html: string, lookup:
|
|
27
|
-
/** Rewrites every token whose exact name the user resolved (`spelling → value`), keeping tails. */
|
|
28
|
-
export declare const applyDynamicContentChoices: (html: string, choices: Map<string, string>) => string;
|
|
29
|
-
export {};
|
|
27
|
+
export declare const convertModuleDynamicContent: (html: string, lookup: Map<string, DynamicContent>, liquidSyntax: boolean) => DynamicContentConversionResult;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import type { DynamicContent,
|
|
1
|
+
import type { DynamicContent, DynamicContentList, MergeTag } from '@@/Types/generic';
|
|
2
2
|
export declare const mergeTagToDynamicContent: (mergeTag: MergeTag) => DynamicContent;
|
|
3
3
|
export declare const dynamicContentToMergeTags: (dynamicContentList: DynamicContent[], liquidSyntax?: boolean) => MergeTag[];
|
|
4
4
|
/**
|
|
5
|
-
* Flattens the
|
|
6
|
-
*
|
|
5
|
+
* Flattens the partner-keyed dynamic-content tree into a deduped flat list of the
|
|
6
|
+
* ACTIVE partner's leaf attributes. A single editor session targets one partner,
|
|
7
|
+
* so only the FIRST partner entry is used (the sole entry for a single-partner
|
|
8
|
+
* host like email-fe; merging all partners would risk cross-partner label
|
|
9
|
+
* collisions). A node carrying `children`/`select_items` is a category grouping:
|
|
10
|
+
* recursed into but never collected itself — only real leaf attributes
|
|
11
|
+
* (`text`/`tag_text` + `value`) become `{ text, value }` pairs.
|
|
7
12
|
*/
|
|
8
|
-
export declare const flattenDynamicContentCandidates: (list: DynamicContentList | undefined | null) => DynamicContentCandidate[];
|
|
9
13
|
export declare const flattenDynamicContentList: (list: DynamicContentList | undefined | null) => DynamicContent[];
|
|
10
14
|
/**
|
|
11
15
|
* Builds the editor merge-tag entries from the template's preselected list plus
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const s = "2.
|
|
1
|
+
const s = "2.86.1", n = ["UIEditor.js", "zone.js", "styles-BWH3PMR4.css", "polyfills-FF3RLU5F.js", "main-QEKXZ3YR.js", "chunk-5T7CEBI5.js", "chunk-62K3AMOD.js", "chunk-66LFOY5U.js", "chunk-AMCKJHBC.js", "chunk-BOERNIOQ.js", "chunk-BVZUBVXH.js", "chunk-I2DLD5I4.js", "chunk-IEC5XOV2.js", "chunk-ILRQX7FO.js", "chunk-LBYVYY25.js", "chunk-LC3XAPU2.js", "chunk-OZSNTS6D.js", "chunk-PBUSX63H.js", "chunk-PYISBD2D.js", "assets/css/uiEditor.css", "assets/i18n/en.json", "assets/icons/ui-editor-icons.sprite.svg", "assets/icons/ui-editor-icons.map.json", "assets/imageeditor/scripts.min.js", "assets/imageeditor/assets/icons/merged.svg"], c = {
|
|
2
2
|
version: s,
|
|
3
3
|
files: n
|
|
4
4
|
};
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
c as default,
|
|
7
7
|
n as files,
|
|
8
8
|
s as version
|
|
9
9
|
};
|
|
@@ -1,45 +1,31 @@
|
|
|
1
|
-
import { DATA_ATTRIBUTE_REGEX as
|
|
2
|
-
import { dynamicContentToMergeTags as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, _ = (e, n) => e.pipeIndex !== -1 ? `{{${e.namePart.replace(e.name, () => n)}${e.inner.slice(e.pipeIndex)}}}` : D([{ text: e.name, value: n }])[0].value, w = (e) => {
|
|
10
|
-
const n = /* @__PURE__ */ new Map();
|
|
11
|
-
return e.forEach((t) => {
|
|
12
|
-
new Set([t.text, t.tagText].map(d)).forEach((s) => {
|
|
13
|
-
if (!s)
|
|
14
|
-
return;
|
|
15
|
-
let a = n.get(s);
|
|
16
|
-
a || (a = [], n.set(s, a)), a.some((o) => o.value === t.value) || a.push(t);
|
|
1
|
+
import { DATA_ATTRIBUTE_REGEX as A, DYNAMIC_CONTENT_TAG_REGEX as m, ALLOWED_DYNAMIC_SYSTEM_TOKENS as D } from "../enums/html-validator.js";
|
|
2
|
+
import { dynamicContentToMergeTags as T } from "./genericUtil.js";
|
|
3
|
+
const p = "guidoDataMask", M = "EndDataMask", f = /guidoDataMask(\d+)EndDataMask/g, h = /^\d+_\d+_.+$/, E = (o) => o.trim().toLowerCase(), I = (...o) => {
|
|
4
|
+
const r = /* @__PURE__ */ new Map();
|
|
5
|
+
return o.forEach((i) => {
|
|
6
|
+
i.forEach((s) => {
|
|
7
|
+
const a = E(s.text);
|
|
8
|
+
a && r.set(a, s);
|
|
17
9
|
});
|
|
18
|
-
}),
|
|
19
|
-
},
|
|
20
|
-
const s = /* @__PURE__ */ new Set(), a =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const p = a.get(m) ?? { label: r, spellings: [], candidates: u };
|
|
33
|
-
return p.spellings.includes(r) || p.spellings.push(r), a.set(m, p), l;
|
|
10
|
+
}), r;
|
|
11
|
+
}, w = (o, r, i) => {
|
|
12
|
+
const s = /* @__PURE__ */ new Set(), a = new Set([...r.values()].map((e) => e.value)), u = [];
|
|
13
|
+
return { html: o.replace(A, (e) => (u.push(e), `${p}${u.length - 1}${M}`)).replace(m, (e) => {
|
|
14
|
+
const n = e.slice(2, -2), c = n.indexOf("|"), l = c === -1 ? n : n.slice(0, c), t = l.trim();
|
|
15
|
+
if (t === "" || D.includes(t) || t.includes(".") || h.test(t) || a.has(t))
|
|
16
|
+
return e;
|
|
17
|
+
const d = r.get(E(t));
|
|
18
|
+
if (d) {
|
|
19
|
+
if (c !== -1) {
|
|
20
|
+
const _ = n.slice(c);
|
|
21
|
+
return `{{${l.replace(t, () => d.value)}${_}}}`;
|
|
22
|
+
}
|
|
23
|
+
return T([d], i)[0].value;
|
|
34
24
|
}
|
|
35
|
-
return s.add(
|
|
36
|
-
}),
|
|
37
|
-
}
|
|
38
|
-
const s = n.get(t.name);
|
|
39
|
-
return s ? _(t, s) : t.tag;
|
|
40
|
-
});
|
|
25
|
+
return s.add(t), e;
|
|
26
|
+
}).replace(f, (e, n) => u[Number(n)]), unresolved: [...s] };
|
|
27
|
+
};
|
|
41
28
|
export {
|
|
42
|
-
I as
|
|
43
|
-
w as
|
|
44
|
-
x as convertModuleDynamicContent
|
|
29
|
+
I as buildDynamicContentLookup,
|
|
30
|
+
w as convertModuleDynamicContent
|
|
45
31
|
};
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { formatToLiquidFilter as
|
|
2
|
-
const
|
|
1
|
+
import { formatToLiquidFilter as b, quoteArgument as y, liquidFilterToFormat as h } from "./liquidDynamicContent.js";
|
|
2
|
+
const g = (t) => {
|
|
3
3
|
if (!t.includes("="))
|
|
4
4
|
return null;
|
|
5
5
|
const [r, e] = t.split("=");
|
|
6
6
|
return { key: r.trim(), value: e.trim() };
|
|
7
|
-
},
|
|
8
|
-
if (!t.startsWith(
|
|
7
|
+
}, c = "default:", f = (t) => {
|
|
8
|
+
if (!t.startsWith(c))
|
|
9
9
|
return t;
|
|
10
|
-
const r = t.slice(
|
|
10
|
+
const r = t.slice(c.length).trim(), e = (l) => r.length >= 2 && r.startsWith(l) && r.endsWith(l);
|
|
11
11
|
return e('"') || e("'") ? r.slice(1, -1) : r;
|
|
12
|
-
},
|
|
13
|
-
const e = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((a) => a.trim()), [
|
|
12
|
+
}, k = (t) => {
|
|
13
|
+
const e = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((a) => a.trim()), [l] = e, s = {
|
|
14
14
|
text: t.label,
|
|
15
|
-
value:
|
|
15
|
+
value: l || ""
|
|
16
16
|
};
|
|
17
17
|
if (e.length >= 2) {
|
|
18
|
-
const [, a,
|
|
19
|
-
if (a.startsWith(
|
|
20
|
-
s.fallback =
|
|
18
|
+
const [, a, n] = e;
|
|
19
|
+
if (a.startsWith(c))
|
|
20
|
+
s.fallback = f(a);
|
|
21
21
|
else {
|
|
22
|
-
const
|
|
23
|
-
|
|
22
|
+
const o = h(a) ?? g(a);
|
|
23
|
+
o ? s.format = o : n || (s.fallback = a), n && (s.fallback = f(n));
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
return s;
|
|
27
|
-
}, h = (t) => {
|
|
28
|
-
const e = !Number.isNaN(Number(t)) && t.trim() !== "" ? t : m(t);
|
|
29
|
-
return e === null ? null : `${u} ${e}`;
|
|
30
27
|
}, p = (t) => {
|
|
31
|
-
const
|
|
28
|
+
const e = !Number.isNaN(Number(t)) && t.trim() !== "" ? t : y(t);
|
|
29
|
+
return e === null ? null : `${c} ${e}`;
|
|
30
|
+
}, v = (t) => {
|
|
31
|
+
const r = t.format ? b(t.format) : null, e = t.fallback ? p(t.fallback) : null, l = [t.value, r, e].filter(Boolean);
|
|
32
32
|
return {
|
|
33
33
|
label: [t.text, r, e && t.fallback].filter(Boolean).join(" | "),
|
|
34
|
-
value: `{{ ${
|
|
34
|
+
value: `{{ ${l.join(" | ")} }}`
|
|
35
35
|
};
|
|
36
|
-
},
|
|
36
|
+
}, i = (t, r = !1) => t.map((e) => r ? v(e) : e.format ? {
|
|
37
37
|
label: `${e.text} | ${e.format.key}=${e.format.value}`,
|
|
38
38
|
value: `{{${e.value}|${e.format.key}=${e.format.value}}}`
|
|
39
39
|
} : {
|
|
40
40
|
label: e.fallback ? `${e.text} | ${e.fallback}` : e.text,
|
|
41
41
|
value: e.fallback ? `{{${e.value}|${e.fallback}}}` : `{{${e.value}}}`
|
|
42
|
-
}),
|
|
43
|
-
const r = [], e = /* @__PURE__ */ new Set(),
|
|
44
|
-
Array.isArray(a) && a.forEach((
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
|
|
42
|
+
}), $ = (t) => {
|
|
43
|
+
const r = [], e = /* @__PURE__ */ new Set(), l = (a) => {
|
|
44
|
+
Array.isArray(a) && a.forEach((n) => {
|
|
45
|
+
const o = [...n.children ?? [], ...n.select_items ?? []];
|
|
46
|
+
if (o.length > 0) {
|
|
47
|
+
l(o);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
const u = n.text || n.tag_text;
|
|
51
|
+
u && n.value && !e.has(n.value) && (e.add(n.value), r.push({ text: u, value: n.value }));
|
|
51
52
|
});
|
|
52
53
|
}, [s] = Object.values(t ?? {});
|
|
53
|
-
return
|
|
54
|
-
},
|
|
55
|
-
const
|
|
54
|
+
return l(s), r;
|
|
55
|
+
}, d = (t, r, e = !1) => {
|
|
56
|
+
const l = new Set(t.map((a) => a.value)), s = r.filter((a) => l.has(a.value) ? !1 : (l.add(a.value), !0));
|
|
56
57
|
return [
|
|
57
|
-
...
|
|
58
|
-
...
|
|
58
|
+
...i(t, e),
|
|
59
|
+
...i(s, e)
|
|
59
60
|
];
|
|
60
61
|
}, F = () => {
|
|
61
62
|
var t;
|
|
62
63
|
return ((t = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : t.getAttribute("content")) ?? "";
|
|
63
|
-
},
|
|
64
|
+
}, T = (t) => typeof t == "string" ? t : typeof t == "number" ? String(t) : "", x = (t) => {
|
|
64
65
|
if (t === null || typeof t != "object" || Array.isArray(t))
|
|
65
66
|
return !1;
|
|
66
67
|
const r = Object.getPrototypeOf(t);
|
|
67
68
|
return r === Object.prototype || r === null;
|
|
68
69
|
};
|
|
69
70
|
export {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
x as flattenDynamicContentList,
|
|
71
|
+
T as asText,
|
|
72
|
+
d as buildMergeTagEntries,
|
|
73
|
+
i as dynamicContentToMergeTags,
|
|
74
|
+
$ as flattenDynamicContentList,
|
|
75
75
|
F as getCsrfToken,
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
x as isPlainObject,
|
|
77
|
+
k as mergeTagToDynamicContent
|
|
78
78
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.27.
|
|
3
|
+
"version": "3.27.1-beta.842075e",
|
|
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",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
},
|
|
137
137
|
"guido": {
|
|
138
138
|
"stripo": {
|
|
139
|
-
"version": "2.
|
|
139
|
+
"version": "2.86.1"
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import i from "./AmbiguousDynamicContentModal.vue2.js";
|
|
2
|
-
/* empty css */
|
|
3
|
-
import l from "../../../_virtual/_plugin-vue2_normalizer.js";
|
|
4
|
-
var c = function() {
|
|
5
|
-
var n = this, a = n._self._c, t = n._self._setupProxy;
|
|
6
|
-
return t.current ? a(t.WpModal, { attrs: { id: "guido__ambiguous-dynamic-content-modal", size: "medium", "close-on-outside-click": !1, "footer-button-options": t.footerButtonOptions, title: t.trans("email-editor.ambiguous-dynamic-content-title") }, on: { close: t.cancel, "primary-action": t.apply } }, [a("div", { staticClass: "ambiguous-dynamic-content-modal__content" }, [a("p", { staticClass: "mb-3" }, [n._v(" " + n._s(t.trans("email-editor.ambiguous-dynamic-content-message")) + " ")]), n._l(t.rows, function(e, s) {
|
|
7
|
-
return a(t.InSelect, { key: e.label, staticClass: "mb-2", attrs: { id: `guido__ambiguous-dynamic-content-select-${s}`, "search-status": "", "button-status": !1, "label-text": `{{ ${e.label} }}`, options: e.options, "placeholder-text": t.trans("email-editor.ambiguous-dynamic-content-placeholder"), state: e.isInvalid ? "error" : "default", "state-message": t.trans("email-editor.ambiguous-dynamic-content-validation"), value: e.selected }, on: { close: function(o) {
|
|
8
|
-
return t.touch(e.label);
|
|
9
|
-
}, select: function(o) {
|
|
10
|
-
return t.select(e.label, o);
|
|
11
|
-
} } });
|
|
12
|
-
})], 2)]) : n._e();
|
|
13
|
-
}, r = [], u = /* @__PURE__ */ l(
|
|
14
|
-
i,
|
|
15
|
-
c,
|
|
16
|
-
r,
|
|
17
|
-
!1,
|
|
18
|
-
null,
|
|
19
|
-
"2643213c"
|
|
20
|
-
);
|
|
21
|
-
const f = u.exports;
|
|
22
|
-
export {
|
|
23
|
-
f as default
|
|
24
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { defineComponent as h, ref as y, computed as u, watch as _ } from "vue";
|
|
2
|
-
import x from "../../wrappers/WpModal.vue.js";
|
|
3
|
-
import { useAmbiguousDynamicContent as S } from "../../../composables/useAmbiguousDynamicContent.js";
|
|
4
|
-
import { useTranslations as T } from "../../../composables/useTranslations.js";
|
|
5
|
-
import { useEditorStore as C } from "../../../stores/editor.js";
|
|
6
|
-
import { useModuleDynamicContentStore as B } from "../../../stores/module-dynamic-content.js";
|
|
7
|
-
import { InSelect as D } from "@useinsider/design-system-vue";
|
|
8
|
-
const G = /* @__PURE__ */ h({
|
|
9
|
-
__name: "AmbiguousDynamicContentModal",
|
|
10
|
-
setup(I) {
|
|
11
|
-
const s = T(), i = C(), c = B(), { resolve: r, dismiss: p } = S(), o = y({}), l = y([]), t = u(() => i.isStripoInitialized ? c.current : null);
|
|
12
|
-
_(() => {
|
|
13
|
-
var e;
|
|
14
|
-
return (e = t.value) == null ? void 0 : e.id;
|
|
15
|
-
}, () => {
|
|
16
|
-
o.value = {}, l.value = [];
|
|
17
|
-
});
|
|
18
|
-
const m = (e) => ({
|
|
19
|
-
text: [...e.path, e.tagText].join(" › "),
|
|
20
|
-
value: e.value
|
|
21
|
-
}), v = u(() => {
|
|
22
|
-
var e;
|
|
23
|
-
return (((e = t.value) == null ? void 0 : e.items) ?? []).map((a) => {
|
|
24
|
-
const d = a.candidates.map(m), f = d.filter((g) => g.value === o.value[a.label]);
|
|
25
|
-
return {
|
|
26
|
-
label: a.label,
|
|
27
|
-
options: d,
|
|
28
|
-
selected: f,
|
|
29
|
-
isInvalid: f.length === 0 && l.value.includes(a.label)
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
}), n = u(() => v.value.every((e) => e.selected.length > 0)), b = u(() => ({
|
|
33
|
-
cancelOrBackButton: {
|
|
34
|
-
type: "secondary",
|
|
35
|
-
labelText: s("action-builder.cancel"),
|
|
36
|
-
styling: "ghost"
|
|
37
|
-
},
|
|
38
|
-
primaryButton: {
|
|
39
|
-
type: "primary",
|
|
40
|
-
labelText: s("email-editor.ambiguous-dynamic-content-apply"),
|
|
41
|
-
disabledStatus: !n.value,
|
|
42
|
-
isTooltip: !n.value,
|
|
43
|
-
tooltipText: n.value ? "" : s("email-editor.ambiguous-dynamic-content-apply-tooltip")
|
|
44
|
-
}
|
|
45
|
-
}));
|
|
46
|
-
return { __sfc: !0, trans: s, editorStore: i, store: c, resolve: r, dismiss: p, selections: o, touched: l, current: t, toOption: m, rows: v, isComplete: n, footerButtonOptions: b, select: (e, { value: a }) => {
|
|
47
|
-
o.value = { ...o.value, [e]: a };
|
|
48
|
-
}, touch: (e) => {
|
|
49
|
-
l.value.includes(e) || (l.value = [...l.value, e]);
|
|
50
|
-
}, apply: () => {
|
|
51
|
-
t.value && n.value && r(t.value, o.value);
|
|
52
|
-
}, cancel: () => {
|
|
53
|
-
t.value && p(t.value.id);
|
|
54
|
-
}, WpModal: x, InSelect: D };
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
export {
|
|
58
|
-
G as default
|
|
59
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { useModuleRepair as A, UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY as D, registerUsedAttributes as C } from "./useModuleRepair.js";
|
|
2
|
-
import { useToaster as v } from "./useToaster.js";
|
|
3
|
-
import { useTranslations as R } from "./useTranslations.js";
|
|
4
|
-
import { ModuleDynamicContentAttribute as b } from "../enums/dynamic-content.js";
|
|
5
|
-
import { ToasterTypeOptions as h } from "../enums/toaster.js";
|
|
6
|
-
import { useModuleDynamicContentStore as O } from "../stores/module-dynamic-content.js";
|
|
7
|
-
import { applyDynamicContentChoices as H } from "../utils/dynamicContentConverter.js";
|
|
8
|
-
import { stripPendingMarker as _ } from "../utils/dynamicContentPendingMarker.js";
|
|
9
|
-
import { getEditorApi as w, EDITOR_NOT_READY_MESSAGE as N } from "../utils/stripoEditorApi.js";
|
|
10
|
-
import { ModificationDescription as u } from "../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
11
|
-
const c = b.Pending, M = () => {
|
|
12
|
-
const { editorCopilotApi: t } = w();
|
|
13
|
-
if (!t)
|
|
14
|
-
throw new Error(N);
|
|
15
|
-
return { api: t, root: t.getDocumentRootHtmlNode() };
|
|
16
|
-
}, E = (t) => {
|
|
17
|
-
const { api: p, root: a } = M(), m = a.querySelector(`[${c}="${t}"]`);
|
|
18
|
-
return { api: p, node: m };
|
|
19
|
-
}, G = () => {
|
|
20
|
-
const t = O(), { convertDynamicContent: p } = A(), { showToaster: a, handleError: m } = v(), f = R();
|
|
21
|
-
return { resolve: ({ id: o, items: r }, i) => {
|
|
22
|
-
try {
|
|
23
|
-
const { api: e, node: n } = E(o);
|
|
24
|
-
if (n) {
|
|
25
|
-
const s = /* @__PURE__ */ new Map();
|
|
26
|
-
r.forEach((l) => {
|
|
27
|
-
const g = i[l.label];
|
|
28
|
-
g && l.spellings.forEach((T) => s.set(T, g));
|
|
29
|
-
});
|
|
30
|
-
const d = _(H(n.getOuterHTML(), s)), y = e.getTemplateModifier();
|
|
31
|
-
y.modifyHtml(n).replaceWith(d), y.apply(new u("Resolved dynamic content")), C(d, r.flatMap((l) => l.candidates)), a({
|
|
32
|
-
type: h.Success,
|
|
33
|
-
message: f("email-editor.ambiguous-dynamic-content-success")
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
t.remove(o);
|
|
37
|
-
} catch (e) {
|
|
38
|
-
m(e, "Failed to apply the dynamic content choice");
|
|
39
|
-
}
|
|
40
|
-
}, dismiss: (o) => {
|
|
41
|
-
try {
|
|
42
|
-
const { api: r, node: i } = E(o);
|
|
43
|
-
if (i) {
|
|
44
|
-
const e = r.getTemplateModifier();
|
|
45
|
-
e.modifyHtml(i).removeAttribute(c), e.apply(new u("Cleared pending dynamic content").asHidden()), a({
|
|
46
|
-
type: h.Warning,
|
|
47
|
-
message: f(D)
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
} catch (r) {
|
|
51
|
-
m(r, "Failed to dismiss the dynamic content choice");
|
|
52
|
-
} finally {
|
|
53
|
-
t.remove(o);
|
|
54
|
-
}
|
|
55
|
-
}, restorePending: () => {
|
|
56
|
-
try {
|
|
57
|
-
const { api: o, root: r } = M(), i = [];
|
|
58
|
-
if (r.querySelectorAll(`[${c}]`).forEach((e) => {
|
|
59
|
-
const n = e.getAttribute(c), { ambiguous: s } = p(e.getOuterHTML());
|
|
60
|
-
!n || s.length === 0 ? i.push(e) : t.queue.some((d) => d.id === n) || t.enqueue({ id: n, items: s });
|
|
61
|
-
}), i.length > 0) {
|
|
62
|
-
const e = o.getTemplateModifier();
|
|
63
|
-
i.forEach((n) => e.modifyHtml(n).removeAttribute(c)), e.apply(new u("Cleared pending dynamic content").asHidden());
|
|
64
|
-
}
|
|
65
|
-
} catch (o) {
|
|
66
|
-
console.error("Failed to restore pending dynamic content:", o);
|
|
67
|
-
}
|
|
68
|
-
} };
|
|
69
|
-
};
|
|
70
|
-
export {
|
|
71
|
-
G as useAmbiguousDynamicContent
|
|
72
|
-
};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
|
2
|
-
export default _default;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type PendingModuleDynamicContent } from '@@/Stores/module-dynamic-content';
|
|
2
|
-
/** Resolves or dismisses the labels a dropped module left pending (see `useModuleRepair`). */
|
|
3
|
-
export declare const useAmbiguousDynamicContent: () => {
|
|
4
|
-
resolve: ({ id, items }: PendingModuleDynamicContent, selections: Record<string, string>) => void;
|
|
5
|
-
dismiss: (id: string) => void;
|
|
6
|
-
restorePending: () => void;
|
|
7
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { AmbiguousDynamicContent } from '@@/Utils/dynamicContentConverter';
|
|
2
|
-
export interface PendingModuleDynamicContent {
|
|
3
|
-
/** Value of the module root's pending marker attribute. */
|
|
4
|
-
id: string;
|
|
5
|
-
items: AmbiguousDynamicContent[];
|
|
6
|
-
}
|
|
7
|
-
interface ModuleDynamicContentState {
|
|
8
|
-
queue: PendingModuleDynamicContent[];
|
|
9
|
-
}
|
|
10
|
-
export declare const useModuleDynamicContentStore: import("pinia").StoreDefinition<"guidoModuleDynamicContent", ModuleDynamicContentState, {
|
|
11
|
-
current: (state: {
|
|
12
|
-
queue: {
|
|
13
|
-
id: string;
|
|
14
|
-
items: {
|
|
15
|
-
label: string;
|
|
16
|
-
spellings: string[];
|
|
17
|
-
candidates: {
|
|
18
|
-
value: string;
|
|
19
|
-
text: string;
|
|
20
|
-
tagText: string;
|
|
21
|
-
path: string[];
|
|
22
|
-
}[];
|
|
23
|
-
}[];
|
|
24
|
-
}[];
|
|
25
|
-
} & import("pinia").PiniaCustomStateProperties<ModuleDynamicContentState>) => PendingModuleDynamicContent | null;
|
|
26
|
-
}, {
|
|
27
|
-
enqueue(entry: PendingModuleDynamicContent): void;
|
|
28
|
-
remove(id: string): void;
|
|
29
|
-
}>;
|
|
30
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { defineStore as u } from "pinia";
|
|
2
|
-
const i = u("guidoModuleDynamicContent", {
|
|
3
|
-
state: () => ({
|
|
4
|
-
queue: []
|
|
5
|
-
}),
|
|
6
|
-
getters: {
|
|
7
|
-
current: (e) => e.queue[0] ?? null
|
|
8
|
-
},
|
|
9
|
-
actions: {
|
|
10
|
-
enqueue(e) {
|
|
11
|
-
this.queue = [...this.queue, e];
|
|
12
|
-
},
|
|
13
|
-
remove(e) {
|
|
14
|
-
this.queue = this.queue.filter((t) => t.id !== e);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
export {
|
|
19
|
-
i as useModuleDynamicContentStore
|
|
20
|
-
};
|