@useinsider/guido 3.27.0-beta.8bef749 → 3.27.0-beta.9585b71

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,79 +1,97 @@
1
- import { EditorStatePropertyType as E, PreviewDeviceMode as I, ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { createImageMarginsControl as M, createImageSizeControl as C } from "../../../controlFactories.js";
1
+ import { EditorStatePropertyType as M, PreviewDeviceMode as I, ModificationDescription as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { createImageMarginsControl as C, createImageSizeControl as O } from "../../../controlFactories.js";
3
3
  import { RecommendationBlockId as c } from "../../constants/blockIds.js";
4
- import { RecommendationControlId as g } from "../../constants/controlIds.js";
5
- import { BLOCK_ROOT_SELECTOR as l } from "../../constants/selectors.js";
6
- import { hasGetStyle as a, hasGetAttribute as O } from "../../utils/tagName.js";
7
- const R = { width: "", height: "auto", "max-height": "" }, f = `${l} img.adapt-img`, x = `*${l.slice(1)}`, p = `@media only screen and (max-width: 600px) { ${f} { max-height: none !important; } }`;
8
- function _(t) {
4
+ import { RecommendationControlId as f } from "../../constants/controlIds.js";
5
+ import { BLOCK_ROOT_SELECTOR as l, MOBILE_CONTAINER_SELECTOR as R } from "../../constants/selectors.js";
6
+ import { hasGetStyle as a, hasGetAttribute as T } from "../../utils/tagName.js";
7
+ const _ = { width: "", height: "auto", "max-height": "" }, E = `${l} img.adapt-img`, b = `*${l.slice(1)}`, p = `@media only screen and (max-width: 600px) { ${E} { max-height: none !important; } }`;
8
+ function x(t) {
9
9
  return { width: "auto", height: "auto", "max-height": `${t}px` };
10
10
  }
11
11
  function A(t) {
12
- return t.querySelectorAll(x).some((e) => "getSelector" in e && e.getSelector() === f);
12
+ return t.querySelectorAll(b).some((e) => "getSelector" in e && e.getSelector() === E);
13
13
  }
14
- function T(t, e) {
15
- return a(t) && Object.entries(e).some(([o, n]) => (t.getStyle(o) ?? "") !== n);
14
+ function B(t, e) {
15
+ return a(t) && Object.entries(e).some(([o, i]) => (t.getStyle(o) ?? "") !== i);
16
16
  }
17
17
  function S(t) {
18
18
  const e = t.getDocumentRootCssNode();
19
19
  return e && !A(e) ? e : null;
20
20
  }
21
- function H(t, e) {
22
- const n = e.querySelectorAll("img").some((r) => a(r) && !!r.getStyle("max-height")) ? S(t) : null;
23
- if (!n)
21
+ function U(t, e) {
22
+ const i = e.querySelectorAll("img").some((r) => a(r) && !!r.getStyle("max-height")) ? S(t) : null;
23
+ if (!i)
24
24
  return;
25
- const i = t.getDocumentModifier();
26
- i.modifyCss(n).appendRule(p), i.apply(new h("Add the reco image mobile fit rule"));
25
+ const n = t.getDocumentModifier();
26
+ n.modifyCss(i).appendRule(p), n.apply(new g("Add the reco image mobile fit rule"));
27
27
  }
28
- const B = `[esd-extension-block-id="${c.IMAGE}"]`, L = /^\d+px$/;
28
+ const L = `[esd-extension-block-id="${c.IMAGE}"]`, v = /^\d+px$/;
29
29
  function y(t) {
30
- return O(t) && Number(t.getAttribute("height")) || 0;
30
+ return T(t) && Number(t.getAttribute("height")) || 0;
31
31
  }
32
- function b(t) {
32
+ function w(t) {
33
33
  const e = y(t), o = a(t) ? t.getStyle("max-height") ?? "" : "";
34
- return L.test(o) && e > 0 && o !== `${e}px`;
34
+ return v.test(o) && e > 0 && o !== `${e}px`;
35
35
  }
36
- function U(t, e) {
37
- const o = e.querySelectorAll(B).map((i) => i.querySelector("img")).filter(b);
36
+ function Z(t, e) {
37
+ const o = e.querySelectorAll(L).map((n) => n.querySelector("img")).filter(w);
38
38
  if (!o.length)
39
39
  return;
40
- const n = t.getDocumentModifier();
41
- o.forEach((i) => n.modifyHtml(i).setStyle("max-height", `${y(i)}px`)), n.apply(new h("Sync the reco image height bound").asHidden());
40
+ const i = t.getDocumentModifier();
41
+ o.forEach((n) => i.modifyHtml(n).setStyle("max-height", `${y(n)}px`)), i.apply(new g("Sync the reco image height bound").asHidden());
42
+ }
43
+ function h(t) {
44
+ try {
45
+ return !!t.closest(R);
46
+ } catch {
47
+ return null;
48
+ }
42
49
  }
43
- class D extends C(
44
- g.IMAGE_SIZE,
50
+ class D extends O(
51
+ f.IMAGE_SIZE,
45
52
  c.IMAGE,
46
53
  l
47
54
  ) {
55
+ // Stripo derives the mobile size from rendered targets, and the container hidden in mobile preview renders 0px.
56
+ getTargetNodes(e) {
57
+ const o = super.getTargetNodes(e);
58
+ if (!this.isMobilePreview())
59
+ return o;
60
+ const i = h(e);
61
+ return i === null ? [] : o.filter((n) => h(n) === i);
62
+ }
48
63
  getAdditionalModifications(e) {
49
- if (this.api.getEditorState()[E.previewDeviceMode] === I.MOBILE)
64
+ if (this.isMobilePreview())
50
65
  return;
51
- const o = this.getFitStyles(), n = this.getTargetNodes(e).map((s) => s.querySelector("img")).filter((s) => T(s, o)), i = o["max-height"] ? S(this.api) : null;
52
- if (!n.length && !i)
66
+ const o = this.getFitStyles(), i = this.getTargetNodes(e).map((s) => s.querySelector("img")).filter((s) => B(s, o)), n = o["max-height"] ? S(this.api) : null;
67
+ if (!i.length && !n)
53
68
  return;
54
69
  const r = this.api.getDocumentModifier();
55
- return i && r.modifyCss(i).appendRule(p), n.forEach((s) => {
56
- const m = r.modifyHtml(s);
57
- Object.entries(o).forEach(([u, d]) => {
58
- d ? m.setStyle(u, d) : m.removeStyle(u);
70
+ return n && r.modifyCss(n).appendRule(p), i.forEach((s) => {
71
+ const u = r.modifyHtml(s);
72
+ Object.entries(o).forEach(([d, m]) => {
73
+ m ? u.setStyle(d, m) : u.removeStyle(d);
59
74
  });
60
75
  }), r;
61
76
  }
77
+ isMobilePreview() {
78
+ return this.api.getEditorState()[M.previewDeviceMode] === I.MOBILE;
79
+ }
62
80
  getFitStyles() {
63
81
  const { size: e } = this.api.getValues();
64
- return (e == null ? void 0 : e.type) === "height" && e.value ? _(e.value) : R;
82
+ return (e == null ? void 0 : e.type) === "height" && e.value ? x(e.value) : _;
65
83
  }
66
84
  }
67
- const F = M(
68
- g.IMAGE_MARGINS,
85
+ const N = C(
86
+ f.IMAGE_MARGINS,
69
87
  c.IMAGE,
70
88
  l
71
- ), P = {
89
+ ), j = {
72
90
  size: D,
73
- margins: F
91
+ margins: N
74
92
  };
75
93
  export {
76
- P as ImageControls,
77
- H as ensureMobileFitRule,
78
- U as syncHeightBound
94
+ j as ImageControls,
95
+ U as ensureMobileFitRule,
96
+ Z as syncHeightBound
79
97
  };
@@ -1,9 +1,9 @@
1
- const o = "3.27.0-beta.8bef749", s = { stripo: { version: "2.83.1" } }, e = {
1
+ const o = "3.27.0-beta.9585b71", s = { stripo: { version: "2.83.1" } }, t = {
2
2
  version: o,
3
3
  guido: s
4
4
  };
5
5
  export {
6
- e as default,
6
+ t as default,
7
7
  s as guido,
8
8
  o as version
9
9
  };
@@ -25,7 +25,9 @@ declare const SizeControl_base: {
25
25
  };
26
26
  };
27
27
  declare class SizeControl extends SizeControl_base {
28
+ getTargetNodes(root: ImmutableHtmlNode): ImmutableHtmlNode[];
28
29
  getAdditionalModifications(root: ImmutableHtmlNode): TemplateModifier<HtmlNodeModifier, CssNodeModifier> | undefined;
30
+ private isMobilePreview;
29
31
  private getFitStyles;
30
32
  }
31
33
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.27.0-beta.8bef749",
3
+ "version": "3.27.0-beta.9585b71",
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",