@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.
@@ -1,84 +1,85 @@
1
- import { useActionsApi as R } from "./useActionsApi.js";
2
- import { useConfig as q } from "./useConfig.js";
3
- import { useEditorLock as O } from "./useEditorLock.js";
4
- import { useSaveStart as D, useSaveComplete as F } from "./useGuidoActions.js";
5
- import { useSaveValidation as j } from "./useSaveValidation.js";
6
- import { useSaveValidationRollout as z } from "./useSaveValidationRollout.js";
7
- import { useSyncModuleExtractor as G } from "./useSyncModuleExtractor.js";
8
- import { ToasterTypeOptions as I } from "../enums/toaster.js";
9
- import { useStripoApi as J } from "../services/stripoApi.js";
10
- import { useConfigStore as K } from "../stores/config.js";
11
- import { useDynamicContentStore as N } from "../stores/dynamic-content.js";
12
- import { useSaveValidationStore as Q } from "../stores/save-validation.js";
13
- import { useTemplatePreparation as X, getHtmlReferencedUnsubscribePages as Y } from "../utils/templatePreparation.js";
14
- import { useAllowlist as Z } from "./useAllowlist.js";
15
- import { useHtmlValidator as _ } from "./useHtmlValidator.js";
16
- import { useToaster as $ } from "./useToaster.js";
17
- import { useCouponBlockValidator as tt } from "./validators/useCouponBlockValidator.js";
18
- import { useLiquidValidator as et } from "./validators/useLiquidValidator.js";
19
- import { useSyncModuleBlockValidator as ot } from "./validators/useSyncModuleBlockValidator.js";
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 Bt = () => {
22
- const a = D(), p = F(), { validateHtml: v } = _(), { validateLiquidSyntax: S } = et(), { validateCouponBlockTags: y } = tt(), { validateUnsubscribeBlockUniqueness: w, validateUnsubscribeBlockHasTemplate: E } = st(), { validateSyncModuleBlocks: n } = ot(), { callbacks: r, isFeatureEnabled: d } = q(), { extractSyncModuleData: b } = G(), { setSyncModuleUnsubscriptionPages: g } = J(), { editorSave: H, getTemplateData: V } = R(), { showToaster: x } = $(), { getBlockedDomains: k, resolveToast: C } = Z(), { prepareTemplateDetails: m } = X(), { collectSaveValidationErrors: B } = j(), { isEnabled: h } = z(), T = Q(), P = N(), f = K(), { runExclusive: l } = O(), c = async (t, e, o) => {
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 i = await k(t, e);
26
- if (!i.length)
26
+ const r = await k(t, e);
27
+ if (!r.length)
27
28
  return !1;
28
29
  if (!o) {
29
- const s = await C(i);
30
- s != null && s.message && x({
31
- type: I.Warning,
32
- message: s.message,
33
- actionButton: s.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
- }, L = async (t) => !y(t.compiledHtml) || !w(t.compiledHtml) || !E(t.compiledHtml) ? !1 : d("liquidSyntax") ? S(t.compiledHtml) : v(t.compiledHtml, t.dynamicContentList, !0), u = async (t, e) => {
38
- if (!await H())
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: i, stripoModules: s } = b(t.rawHtml);
41
- if (await g(i), t.modules = s, !e.suppress) {
42
- const W = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
43
- p({ ...t, ...W, silent: e.silent });
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
- }, U = async (t, e) => {
47
- var i;
47
+ }, A = async (t, e) => {
48
+ var r;
48
49
  a();
49
- const o = await m();
50
- if (n(o.rawHtml, e)) {
51
- if (h.value && !e) {
52
- const s = await B(
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 (s.length) {
57
- T.open(s, "save");
57
+ if (i.length) {
58
+ P.open(i, "save");
58
59
  return;
59
60
  }
60
- } else if (!await L(o))
61
+ } else if (!await U(o))
61
62
  return;
62
- if (!((i = r.value) != null && i.externalValidation && !await r.value.externalValidation(o)) && !await c(o.compiledHtml, o.css, e))
63
- return u(o, { silent: e, suppress: t });
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
- }, A = async () => {
66
+ }, M = async () => {
66
67
  var e;
67
- if (!f.allowSaveWithErrors)
68
+ if (!v.allowSaveWithErrors)
68
69
  return;
69
70
  a();
70
- const t = await m();
71
- if (n(t.rawHtml, !1) && !((e = r.value) != null && e.externalValidation && !await r.value.externalValidation(t)) && !await c(t.compiledHtml, t.css, !1))
72
- return u(t, { silent: !1, blankCompiled: !0 });
73
- }, M = async () => {
74
- if (!f.allowSaveWithErrors)
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 V();
78
- if (!n(t, !0) || await c(t, e, !0))
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 = Y(t), i = {
81
- dynamicContentList: P.getSelectedDynamicContentList,
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 u(i, { silent: !0 });
96
+ return m(r, { silent: !0 });
96
97
  };
97
- return { save: (t = !1, e = !1) => l(
98
- () => U(t, e)
99
- ), saveWithErrors: () => l(A), saveRawOnly: () => l(M) };
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
- Bt as useSave
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") || i.hasAttribute("height"))
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 I, createImageSizeControl as d } from "../../../controlFactories.js";
2
- import { RecommendationBlockId as n } from "../../constants/blockIds.js";
3
- import { RecommendationControlId as m } from "../../constants/controlIds.js";
4
- import { BLOCK_ROOT_SELECTOR as a } from "../../constants/selectors.js";
5
- import { hasGetStyle as f } from "../../utils/tagName.js";
6
- const s = ["width", "height"];
7
- function g(t) {
8
- return f(t) && s.some((e) => !!t.getStyle(e));
9
- }
10
- class S extends d(
11
- m.IMAGE_SIZE,
12
- n.IMAGE,
13
- a
14
- ) {
15
- getAdditionalModifications(e) {
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
- A as ImageControls
18
+ C as ImageControls
36
19
  };
@@ -0,0 +1,3 @@
1
+ export declare const useHtmlDocumentCountValidator: () => {
2
+ validateSingleHtmlDocument: (rawHtml: string, silent?: boolean) => boolean;
3
+ };
@@ -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: typeof SizeControl;
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.ab76470",
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",