@useinsider/guido 3.21.0-beta.ab76470 → 3.21.0-beta.c9edf3a
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 +62 -61
- package/dist/composables/validators/useHtmlDocumentCountValidator.js +22 -0
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +16 -33
- package/dist/src/composables/validators/useHtmlDocumentCountValidator.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +16 -22
- package/package.json +1 -1
|
@@ -1,84 +1,85 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useEditorLock as
|
|
4
|
-
import { useSaveStart as
|
|
5
|
-
import { useSaveValidation as
|
|
6
|
-
import { useSaveValidationRollout as
|
|
7
|
-
import { useSyncModuleExtractor as
|
|
8
|
-
import { ToasterTypeOptions as
|
|
9
|
-
import { useStripoApi as
|
|
10
|
-
import { useConfigStore as
|
|
11
|
-
import { useDynamicContentStore as
|
|
12
|
-
import { useSaveValidationStore as
|
|
13
|
-
import { useTemplatePreparation as
|
|
14
|
-
import { useAllowlist as
|
|
15
|
-
import { useHtmlValidator as
|
|
16
|
-
import { useToaster as
|
|
17
|
-
import { useCouponBlockValidator as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
1
|
+
import { useActionsApi as q } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as O } from "./useConfig.js";
|
|
3
|
+
import { useEditorLock as D } from "./useEditorLock.js";
|
|
4
|
+
import { useSaveStart as F, useSaveComplete as j } from "./useGuidoActions.js";
|
|
5
|
+
import { useSaveValidation as z } from "./useSaveValidation.js";
|
|
6
|
+
import { useSaveValidationRollout as G } from "./useSaveValidationRollout.js";
|
|
7
|
+
import { useSyncModuleExtractor as I } from "./useSyncModuleExtractor.js";
|
|
8
|
+
import { ToasterTypeOptions as J } from "../enums/toaster.js";
|
|
9
|
+
import { useStripoApi as K } from "../services/stripoApi.js";
|
|
10
|
+
import { useConfigStore as N } from "../stores/config.js";
|
|
11
|
+
import { useDynamicContentStore as Q } from "../stores/dynamic-content.js";
|
|
12
|
+
import { useSaveValidationStore as X } from "../stores/save-validation.js";
|
|
13
|
+
import { useTemplatePreparation as Y, getHtmlReferencedUnsubscribePages as Z } from "../utils/templatePreparation.js";
|
|
14
|
+
import { useAllowlist as _ } from "./useAllowlist.js";
|
|
15
|
+
import { useHtmlValidator as $ } from "./useHtmlValidator.js";
|
|
16
|
+
import { useToaster as tt } from "./useToaster.js";
|
|
17
|
+
import { useCouponBlockValidator as et } from "./validators/useCouponBlockValidator.js";
|
|
18
|
+
import { useHtmlDocumentCountValidator as ot } from "./validators/useHtmlDocumentCountValidator.js";
|
|
19
|
+
import { useLiquidValidator as it } from "./validators/useLiquidValidator.js";
|
|
20
|
+
import { useSyncModuleBlockValidator as rt } from "./validators/useSyncModuleBlockValidator.js";
|
|
20
21
|
import { useUnsubscribeBlockValidator as st } from "./validators/useUnsubscribeBlockValidator.js";
|
|
21
|
-
const
|
|
22
|
-
const a =
|
|
22
|
+
const Pt = () => {
|
|
23
|
+
const a = F(), p = j(), { validateHtml: S } = $(), { validateLiquidSyntax: w } = it(), { validateCouponBlockTags: y } = et(), { validateUnsubscribeBlockUniqueness: H, validateUnsubscribeBlockHasTemplate: E } = st(), { validateSyncModuleBlocks: n } = rt(), { validateSingleHtmlDocument: l } = ot(), { callbacks: s, isFeatureEnabled: d } = O(), { extractSyncModuleData: b } = I(), { setSyncModuleUnsubscriptionPages: g } = K(), { editorSave: V, getTemplateData: x } = q(), { showToaster: C } = tt(), { getBlockedDomains: k, resolveToast: B } = _(), { prepareTemplateDetails: f } = Y(), { collectSaveValidationErrors: h } = z(), { isEnabled: T } = G(), P = X(), L = Q(), v = N(), { runExclusive: c } = D(), u = async (t, e, o) => {
|
|
23
24
|
if (!d("allowlistEnabled"))
|
|
24
25
|
return !1;
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
26
|
+
const r = await k(t, e);
|
|
27
|
+
if (!r.length)
|
|
27
28
|
return !1;
|
|
28
29
|
if (!o) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
type:
|
|
32
|
-
message:
|
|
33
|
-
actionButton:
|
|
30
|
+
const i = await B(r);
|
|
31
|
+
i != null && i.message && C({
|
|
32
|
+
type: J.Warning,
|
|
33
|
+
message: i.message,
|
|
34
|
+
actionButton: i.actionButton
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
return !0;
|
|
37
|
-
},
|
|
38
|
-
if (!await
|
|
38
|
+
}, U = async (t) => !y(t.compiledHtml) || !H(t.compiledHtml) || !E(t.compiledHtml) ? !1 : d("liquidSyntax") ? w(t.compiledHtml) : S(t.compiledHtml, t.dynamicContentList, !0), m = async (t, e) => {
|
|
39
|
+
if (!await V())
|
|
39
40
|
return;
|
|
40
|
-
const { unsubscribePayload:
|
|
41
|
-
if (await g(
|
|
42
|
-
const
|
|
43
|
-
p({ ...t, ...
|
|
41
|
+
const { unsubscribePayload: r, stripoModules: i } = b(t.rawHtml);
|
|
42
|
+
if (await g(r), t.modules = i, !e.suppress) {
|
|
43
|
+
const R = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
|
|
44
|
+
p({ ...t, ...R, silent: e.silent });
|
|
44
45
|
}
|
|
45
46
|
return t;
|
|
46
|
-
},
|
|
47
|
-
var
|
|
47
|
+
}, A = async (t, e) => {
|
|
48
|
+
var r;
|
|
48
49
|
a();
|
|
49
|
-
const o = await
|
|
50
|
-
if (n(o.rawHtml, e)) {
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
50
|
+
const o = await f();
|
|
51
|
+
if (l(o.rawHtml, e) && n(o.rawHtml, e)) {
|
|
52
|
+
if (T.value && !e) {
|
|
53
|
+
const i = await h(
|
|
53
54
|
o.compiledHtml,
|
|
54
55
|
o.dynamicContentList
|
|
55
56
|
);
|
|
56
|
-
if (
|
|
57
|
-
|
|
57
|
+
if (i.length) {
|
|
58
|
+
P.open(i, "save");
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
|
-
} else if (!await
|
|
61
|
+
} else if (!await U(o))
|
|
61
62
|
return;
|
|
62
|
-
if (!((
|
|
63
|
-
return
|
|
63
|
+
if (!((r = s.value) != null && r.externalValidation && !await s.value.externalValidation(o)) && !await u(o.compiledHtml, o.css, e))
|
|
64
|
+
return m(o, { silent: e, suppress: t });
|
|
64
65
|
}
|
|
65
|
-
},
|
|
66
|
+
}, M = async () => {
|
|
66
67
|
var e;
|
|
67
|
-
if (!
|
|
68
|
+
if (!v.allowSaveWithErrors)
|
|
68
69
|
return;
|
|
69
70
|
a();
|
|
70
|
-
const t = await
|
|
71
|
-
if (n(t.rawHtml, !1) && !((e =
|
|
72
|
-
return
|
|
73
|
-
},
|
|
74
|
-
if (!
|
|
71
|
+
const t = await f();
|
|
72
|
+
if (l(t.rawHtml, !1) && n(t.rawHtml, !1) && !((e = s.value) != null && e.externalValidation && !await s.value.externalValidation(t)) && !await u(t.compiledHtml, t.css, !1))
|
|
73
|
+
return m(t, { silent: !1, blankCompiled: !0 });
|
|
74
|
+
}, W = async () => {
|
|
75
|
+
if (!v.allowSaveWithErrors)
|
|
75
76
|
return;
|
|
76
77
|
a();
|
|
77
|
-
const { html: t, css: e } = await
|
|
78
|
-
if (!n(t, !0) || await
|
|
78
|
+
const { html: t, css: e } = await x();
|
|
79
|
+
if (!l(t, !0) || !n(t, !0) || await u(t, e, !0))
|
|
79
80
|
return;
|
|
80
|
-
const o =
|
|
81
|
-
dynamicContentList:
|
|
81
|
+
const o = Z(t), r = {
|
|
82
|
+
dynamicContentList: L.getSelectedDynamicContentList,
|
|
82
83
|
compiledHtml: "",
|
|
83
84
|
rawHtml: t,
|
|
84
85
|
css: e,
|
|
@@ -92,12 +93,12 @@ const Bt = () => {
|
|
|
92
93
|
config: o
|
|
93
94
|
}
|
|
94
95
|
};
|
|
95
|
-
return
|
|
96
|
+
return m(r, { silent: !0 });
|
|
96
97
|
};
|
|
97
|
-
return { save: (t = !1, e = !1) =>
|
|
98
|
-
() =>
|
|
99
|
-
), saveWithErrors: () =>
|
|
98
|
+
return { save: (t = !1, e = !1) => c(
|
|
99
|
+
() => A(t, e)
|
|
100
|
+
), saveWithErrors: () => c(M), saveRawOnly: () => c(W) };
|
|
100
101
|
};
|
|
101
102
|
export {
|
|
102
|
-
|
|
103
|
+
Pt as useSave
|
|
103
104
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ToasterTypeOptions as i } from "../../enums/toaster.js";
|
|
2
|
+
import { useToaster as c } from "../useToaster.js";
|
|
3
|
+
import { useTranslations as m } from "../useTranslations.js";
|
|
4
|
+
const u = "newsletter.multiple-html-designs-detected", r = `(?:[^>"']|"[^"]*"|'[^']*')*`, a = /<html(?=[\s>/])/gi, T = new RegExp(
|
|
5
|
+
`<!--[\\s\\S]*?-->|<(style|script)\\b${r}>[\\s\\S]*?</\\1\\s*>|<([a-zA-Z][\\w:-]*)${r}>`,
|
|
6
|
+
"gi"
|
|
7
|
+
), p = (e) => Array.from(e.matchAll(T)).filter(([, , t]) => (t == null ? void 0 : t.toLowerCase()) === "html").length, g = () => {
|
|
8
|
+
const { showToaster: e } = c(), t = m();
|
|
9
|
+
return { validateSingleHtmlDocument: (o, l = !1) => {
|
|
10
|
+
var n;
|
|
11
|
+
if ((((n = o.match(a)) == null ? void 0 : n.length) ?? 0) < 2)
|
|
12
|
+
return !0;
|
|
13
|
+
const s = p(o);
|
|
14
|
+
return s <= 1 ? !0 : (console.debug("guido:save:blocked", { reason: "multiple-html-documents", htmlRootCount: s }), l || e({
|
|
15
|
+
type: i.Warning,
|
|
16
|
+
message: t(u)
|
|
17
|
+
}), !1);
|
|
18
|
+
} };
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
g as useHtmlDocumentCountValidator
|
|
22
|
+
};
|
|
@@ -162,7 +162,7 @@ function G(t, r) {
|
|
|
162
162
|
function V(t) {
|
|
163
163
|
const r = t.getAttribute("style") || "", e = y(r, "width", 600), o = y(r, "padding", 0) * 2, c = Math.max(0, e - o);
|
|
164
164
|
c !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
|
|
165
|
-
if (i.hasAttribute("width")
|
|
165
|
+
if (i.hasAttribute("width"))
|
|
166
166
|
return;
|
|
167
167
|
const n = G(i, t);
|
|
168
168
|
if (!n)
|
|
@@ -1,36 +1,19 @@
|
|
|
1
|
-
import { createImageMarginsControl as
|
|
2
|
-
import { RecommendationBlockId as
|
|
3
|
-
import { RecommendationControlId as
|
|
4
|
-
import { BLOCK_ROOT_SELECTOR as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const r = this.getTargetNodes(e).map((o) => o.querySelector("img")).filter((o) => !!o && g(o));
|
|
17
|
-
if (!r.length)
|
|
18
|
-
return;
|
|
19
|
-
const i = this.api.getDocumentModifier();
|
|
20
|
-
return r.forEach((o) => {
|
|
21
|
-
const l = i.modifyHtml(o);
|
|
22
|
-
s.forEach((c) => l.removeStyle(c));
|
|
23
|
-
}), i;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const h = I(
|
|
27
|
-
m.IMAGE_MARGINS,
|
|
28
|
-
n.IMAGE,
|
|
29
|
-
a
|
|
30
|
-
), A = {
|
|
31
|
-
size: S,
|
|
32
|
-
margins: h
|
|
1
|
+
import { createImageMarginsControl as m, createImageSizeControl as n } from "../../../controlFactories.js";
|
|
2
|
+
import { RecommendationBlockId as o } from "../../constants/blockIds.js";
|
|
3
|
+
import { RecommendationControlId as r } from "../../constants/controlIds.js";
|
|
4
|
+
import { BLOCK_ROOT_SELECTOR as t } from "../../constants/selectors.js";
|
|
5
|
+
const e = n(
|
|
6
|
+
r.IMAGE_SIZE,
|
|
7
|
+
o.IMAGE,
|
|
8
|
+
t
|
|
9
|
+
), i = m(
|
|
10
|
+
r.IMAGE_MARGINS,
|
|
11
|
+
o.IMAGE,
|
|
12
|
+
t
|
|
13
|
+
), C = {
|
|
14
|
+
size: e,
|
|
15
|
+
margins: i
|
|
33
16
|
};
|
|
34
17
|
export {
|
|
35
|
-
|
|
18
|
+
C as ImageControls
|
|
36
19
|
};
|
|
@@ -3,41 +3,35 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Controls for styling the product image element in recommendation cards.
|
|
5
5
|
*/
|
|
6
|
-
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
7
|
-
declare const SizeControl_base: {
|
|
8
|
-
new (): {
|
|
9
|
-
getId(): string;
|
|
10
|
-
getTargetNodes(root: ImmutableHtmlNode): ImmutableHtmlNode[];
|
|
11
|
-
getParentControlId(): string;
|
|
12
|
-
api: import("@stripoinc/ui-editor-extensions").ControlApi;
|
|
13
|
-
getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
|
|
14
|
-
getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
|
|
15
|
-
getAdditionalModifications(_root: ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
|
|
16
|
-
isVisible(_node: ImmutableHtmlNode): boolean;
|
|
17
|
-
getElementLockCategory(): import("@stripoinc/ui-editor-extensions").ElementLockCategory | undefined;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
declare class SizeControl extends SizeControl_base {
|
|
21
|
-
getAdditionalModifications(root: ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
|
|
22
|
-
}
|
|
23
6
|
/**
|
|
24
7
|
* Grouped Image Controls
|
|
25
8
|
* Use this object for cleaner imports in extension.ts
|
|
26
9
|
*/
|
|
27
10
|
export declare const ImageControls: {
|
|
28
|
-
readonly size:
|
|
11
|
+
readonly size: {
|
|
12
|
+
new (): {
|
|
13
|
+
getId(): string;
|
|
14
|
+
getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
|
|
15
|
+
getParentControlId(): string;
|
|
16
|
+
api: import("@stripoinc/ui-editor-extensions").ControlApi;
|
|
17
|
+
getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
|
|
18
|
+
getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
|
|
19
|
+
getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
|
|
20
|
+
isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
|
|
21
|
+
getElementLockCategory(): import("@stripoinc/ui-editor-extensions").ElementLockCategory | undefined;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
29
24
|
readonly margins: {
|
|
30
25
|
new (): {
|
|
31
26
|
getId(): string;
|
|
32
|
-
getTargetNodes(root: ImmutableHtmlNode): ImmutableHtmlNode[];
|
|
27
|
+
getTargetNodes(root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode[];
|
|
33
28
|
getParentControlId(): string;
|
|
34
29
|
api: import("@stripoinc/ui-editor-extensions").ControlApi;
|
|
35
30
|
getLabels(): import("@stripoinc/ui-editor-extensions").ControlLabels | undefined;
|
|
36
31
|
getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
|
|
37
|
-
getAdditionalModifications(_root: ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
|
|
38
|
-
isVisible(_node: ImmutableHtmlNode): boolean;
|
|
32
|
+
getAdditionalModifications(_root: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
|
|
33
|
+
isVisible(_node: import("@stripoinc/ui-editor-extensions").ImmutableHtmlNode): boolean;
|
|
39
34
|
getElementLockCategory(): import("@stripoinc/ui-editor-extensions").ElementLockCategory | undefined;
|
|
40
35
|
};
|
|
41
36
|
};
|
|
42
37
|
};
|
|
43
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.21.0-beta.
|
|
3
|
+
"version": "3.21.0-beta.c9edf3a",
|
|
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",
|