@grapesjs/studio-sdk-plugins 1.0.21 → 1.0.22

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.
Files changed (66) hide show
  1. package/dist/animationComponent/components/Animation.d.ts +6 -0
  2. package/dist/animationComponent/components/AnimationGroup.d.ts +4 -0
  3. package/dist/animationComponent/index.cjs.d.ts +3 -0
  4. package/dist/animationComponent/index.cjs.js +507 -0
  5. package/dist/animationComponent/index.d.ts +3 -0
  6. package/dist/animationComponent/index.es.d.ts +3 -0
  7. package/dist/animationComponent/index.es.js +1111 -0
  8. package/dist/animationComponent/index.umd.js +507 -0
  9. package/dist/animationComponent/shared.d.ts +3 -0
  10. package/dist/animationComponent/types.d.ts +28 -0
  11. package/dist/animationComponent/typesSchema.d.ts +48 -0
  12. package/dist/animationComponent/utils.d.ts +19 -0
  13. package/dist/dataSourceEjs/EjsExporter.d.ts +13 -0
  14. package/dist/dataSourceEjs/EjsImporter.d.ts +29 -0
  15. package/dist/dataSourceEjs/index.cjs.d.ts +2 -2
  16. package/dist/dataSourceEjs/index.cjs.js +24 -3
  17. package/dist/dataSourceEjs/index.d.ts +2 -2
  18. package/dist/dataSourceEjs/index.es.d.ts +2 -2
  19. package/dist/dataSourceEjs/index.es.js +697 -114
  20. package/dist/dataSourceEjs/index.umd.js +24 -3
  21. package/dist/dataSourceEjs/shared.d.ts +3 -0
  22. package/dist/dataSourceEjs/types.d.ts +2 -2
  23. package/dist/dataSourceEjs/typesSchema.d.ts +3 -0
  24. package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +16 -0
  25. package/dist/dataSourceHandlebars/HandlebarsImporter.d.ts +20 -0
  26. package/dist/dataSourceHandlebars/helperImplementations.d.ts +1 -0
  27. package/dist/dataSourceHandlebars/index.cjs.js +20 -1
  28. package/dist/dataSourceHandlebars/index.es.js +401 -99
  29. package/dist/dataSourceHandlebars/index.umd.js +20 -1
  30. package/dist/dataSourceHandlebars/shared.d.ts +3 -0
  31. package/dist/dataSourceHandlebars/types.d.ts +2 -2
  32. package/dist/dataSourceHandlebars/typesSchema.d.ts +3 -0
  33. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  34. package/dist/googleFontsAssetProvider/index.es.js +29 -29
  35. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  36. package/dist/iconifyComponent/index.cjs.js +2 -2
  37. package/dist/iconifyComponent/index.es.js +64 -64
  38. package/dist/iconifyComponent/index.umd.js +2 -2
  39. package/dist/index.cjs.d.ts +1 -0
  40. package/dist/index.cjs.js +587 -51
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.es.d.ts +1 -0
  43. package/dist/index.es.js +4809 -3046
  44. package/dist/index.umd.js +584 -48
  45. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  46. package/dist/layoutSidebarButtons/index.es.js +59 -59
  47. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  48. package/dist/presetPrintable/index.cjs.js +3 -3
  49. package/dist/presetPrintable/index.es.js +136 -131
  50. package/dist/presetPrintable/index.umd.js +4 -4
  51. package/dist/prosemirror/index.cjs.js +1 -1
  52. package/dist/prosemirror/index.es.js +1 -1
  53. package/dist/prosemirror/index.umd.js +1 -1
  54. package/dist/rteTinyMce/index.cjs.js +2 -2
  55. package/dist/rteTinyMce/index.es.js +67 -67
  56. package/dist/rteTinyMce/index.umd.js +2 -2
  57. package/dist/tableComponent/index.cjs.js +1 -1
  58. package/dist/tableComponent/index.es.js +14 -14
  59. package/dist/tableComponent/index.umd.js +1 -1
  60. package/dist/utilsDataSources.d.ts +28 -0
  61. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  62. package/dist/youtubeAssetProvider/index.es.js +26 -26
  63. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  64. package/package.json +2 -1
  65. package/dist/dataSourceEjs/EjsStrategy.d.ts +0 -15
  66. package/dist/dataSourceHandlebars/HandlebarsStrategy.d.ts +0 -17
@@ -1,6 +1,6 @@
1
- const M = "app.grapesjs.com", U = "app-stage.grapesjs.com", x = [
2
- M,
1
+ const U = "app.grapesjs.com", G = "app-stage.grapesjs.com", x = [
3
2
  U,
3
+ G,
4
4
  "localhost",
5
5
  "127.0.0.1",
6
6
  ".local-credentialless.webcontainer.io",
@@ -9,21 +9,21 @@ const M = "app.grapesjs.com", U = "app-stage.grapesjs.com", x = [
9
9
  // For stackblitz.com demos
10
10
  "-sandpack.codesandbox.io"
11
11
  // For Sandpack demos
12
- ], I = "license:check:start", N = "license:check:end", C = () => typeof window < "u", j = (e, n = {}) => {
13
- const t = q(e) ? { id: e, src: e } : e;
12
+ ], N = "license:check:start", z = "license:check:end", K = () => typeof window < "u", j = (e, n = {}) => {
13
+ const t = V(e) ? { id: e, src: e } : e;
14
14
  return new Promise((s, a) => {
15
15
  var p, g;
16
16
  const o = document.querySelector(`script[src="${t.src}"]`), { id: i } = t;
17
17
  if (o)
18
18
  return (p = n.onScript) == null || p.call(n, o), s(i);
19
- const c = document.createElement("script");
20
- c.src = t.src, c.onload = () => s(i), c.onerror = () => a(i), document.head.appendChild(c), (g = n.onScript) == null || g.call(n, c);
19
+ const r = document.createElement("script");
20
+ r.src = t.src, r.onload = () => s(i), r.onerror = () => a(i), document.head.appendChild(r), (g = n.onScript) == null || g.call(n, r);
21
21
  });
22
- }, K = ({ isDev: e, isStage: n }) => `${e ? "" : `https://${n ? U : M}`}/api`, z = () => {
23
- const e = C() && window.location.hostname;
22
+ }, C = ({ isDev: e, isStage: n }) => `${e ? "" : `https://${n ? G : U}`}/api`, q = () => {
23
+ const e = K() && window.location.hostname;
24
24
  return !!e && (x.includes(e) || x.some((n) => e.endsWith(n)));
25
- }, q = (e) => typeof e == "string";
26
- async function V({
25
+ }, V = (e) => typeof e == "string";
26
+ async function Y({
27
27
  path: e,
28
28
  baseApiUrl: n,
29
29
  method: t = "GET",
@@ -31,7 +31,7 @@ async function V({
31
31
  params: a,
32
32
  body: o
33
33
  }) {
34
- const c = `${n || K({ isDev: !1, isStage: !1 })}${e}`, p = {
34
+ const r = `${n || C({ isDev: !1, isStage: !1 })}${e}`, p = {
35
35
  method: t,
36
36
  headers: {
37
37
  "Content-Type": "application/json",
@@ -39,24 +39,24 @@ async function V({
39
39
  }
40
40
  };
41
41
  o && (p.body = JSON.stringify(o));
42
- const g = a ? new URLSearchParams(a).toString() : "", l = g ? `?${g}` : "", u = await fetch(`${c}${l}`, p);
42
+ const g = a ? new URLSearchParams(a).toString() : "", c = g ? `?${g}` : "", u = await fetch(`${r}${c}`, p);
43
43
  if (!u.ok)
44
44
  throw new Error(`HTTP error! status: ${u.status}`);
45
45
  return u.json();
46
46
  }
47
- var T = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(T || {}), G = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.projectFiles = "studio:projectFiles", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.setDragAbsolute = "studio:setDragAbsolute", e))(G || {});
47
+ var E = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(E || {}), O = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.projectFiles = "studio:projectFiles", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(O || {});
48
48
  const H = {
49
- [T.free]: 0,
50
- [T.startup]: 10,
51
- [T.business]: 20,
52
- [T.enterprise]: 30
49
+ [E.free]: 0,
50
+ [E.startup]: 10,
51
+ [E.business]: 20,
52
+ [E.enterprise]: 30
53
53
  };
54
- function Y(e) {
54
+ function J(e) {
55
55
  const n = e;
56
56
  return n.init = (t) => (s) => e(s, t), n;
57
57
  }
58
- const J = (e) => /* @__PURE__ */ Y(e);
59
- async function X({
58
+ const X = (e) => /* @__PURE__ */ J(e);
59
+ async function Z({
60
60
  editor: e,
61
61
  plan: n,
62
62
  pluginName: t,
@@ -64,37 +64,37 @@ async function X({
64
64
  cleanup: a
65
65
  }) {
66
66
  let o = "", i = !1;
67
- const c = z(), p = (l) => {
68
- console.warn("Cleanup plugin:", t, "Reason:", l), a();
69
- }, g = (l = {}) => {
70
- var h;
71
- const { error: u, sdkLicense: d } = l, f = (h = l.plan) == null ? void 0 : h.category;
72
- if (!(d || l.license) || u)
67
+ const r = q(), p = (c) => {
68
+ console.warn("Cleanup plugin:", t, "Reason:", c), a();
69
+ }, g = (c = {}) => {
70
+ var l;
71
+ const { error: u, sdkLicense: d } = c, f = (l = c.plan) == null ? void 0 : l.category;
72
+ if (!(d || c.license) || u)
73
73
  p(u || "Invalid license");
74
74
  else if (f) {
75
- const E = H[n], y = H[f];
76
- E > y && p({ pluginRequiredPlan: n, licensePlan: f });
75
+ const v = H[n], A = H[f];
76
+ v > A && p({ pluginRequiredPlan: n, licensePlan: f });
77
77
  }
78
78
  };
79
- e.on(I, (l) => {
80
- o = l == null ? void 0 : l.baseApiUrl, i = !0;
81
- }), e.on(N, (l) => {
82
- g(l);
79
+ e.on(N, (c) => {
80
+ o = c == null ? void 0 : c.baseApiUrl, i = !0;
81
+ }), e.on(z, (c) => {
82
+ g(c);
83
83
  }), setTimeout(async () => {
84
84
  if (!i) {
85
- if (c) return;
85
+ if (r) return;
86
86
  if (s) {
87
- const l = await Z({ licenseKey: s, pluginName: t, baseApiUrl: o });
88
- l && g(l);
87
+ const c = await Q({ licenseKey: s, pluginName: t, baseApiUrl: o });
88
+ c && g(c);
89
89
  } else
90
90
  p("The `licenseKey` option not provided");
91
91
  }
92
92
  }, 2e3);
93
93
  }
94
- async function Z(e) {
94
+ async function Q(e) {
95
95
  const { licenseKey: n, pluginName: t, baseApiUrl: s } = e;
96
96
  try {
97
- return (await V({
97
+ return (await Y({
98
98
  baseApiUrl: s,
99
99
  path: `/sdk/${n || "na"}`,
100
100
  method: "POST",
@@ -107,31 +107,31 @@ async function Z(e) {
107
107
  return console.error("Error during SDK license check:", a), !1;
108
108
  }
109
109
  }
110
- const Q = (e) => (n) => {
110
+ const ee = (e) => (n) => {
111
111
  var t;
112
- return ((t = n.getAttribute) == null ? void 0 : t.call(n, O)) === e;
113
- }, ee = (...e) => (n, t) => e.some((s) => t.is(s)), F = (e, n, t) => {
112
+ return ((t = n.getAttribute) == null ? void 0 : t.call(n, W)) === e;
113
+ }, te = (...e) => (n, t) => e.some((s) => t.is(s)), F = (e, n, t) => {
114
114
  const { doc: s = document } = t, a = t.target || s.head, o = a.querySelector(`style[${e}]`) || s.createElement("style");
115
115
  o.setAttribute(e, "true"), o.innerHTML = n, !a.contains(o) && a.appendChild(o);
116
- }, te = "gjs-plg-", W = "data-gs-plg-", O = "data-type-role";
117
- function se(e, n, t) {
118
- let s, a, o, i, c;
119
- const p = n;
116
+ }, se = "gjs-plg-", I = "data-gs-plg-", W = "data-type-role";
117
+ function _(e, n, t) {
118
+ let s, a, o, i, r;
119
+ const p = n === void 0 ? 100 : n;
120
120
  function g() {
121
121
  const u = Date.now() - i;
122
- u < p && u >= 0 ? s = setTimeout(g, p - u) : (s = null, c = e.apply(o, a), o = a = null);
122
+ u < p && u >= 0 ? s = setTimeout(g, p - u) : (s = null, r = e.apply(o, a), o = a = null);
123
123
  }
124
- const l = function() {
125
- return o = this, a = arguments, i = Date.now(), s || (s = setTimeout(g, p)), c;
124
+ const c = function() {
125
+ return o = this, a = arguments, i = Date.now(), s || (s = setTimeout(g, p)), r;
126
126
  };
127
- return l.clear = function() {
127
+ return c.clear = function() {
128
128
  s && (clearTimeout(s), s = null);
129
- }, l.flush = function() {
130
- s && (c = e.apply(o, a), o = a = null, clearTimeout(s), s = null);
131
- }, l;
129
+ }, c.flush = function() {
130
+ s && (r = e.apply(o, a), o = a = null, clearTimeout(s), s = null);
131
+ }, c;
132
132
  }
133
133
  const P = "page-break";
134
- function $(e, n) {
134
+ function L(e, n) {
135
135
  const s = {
136
136
  mm: 3.7795275590551185,
137
137
  // 1mm ≈ 3.78px
@@ -147,7 +147,7 @@ function $(e, n) {
147
147
  return s[n] ? e * s[n] : null;
148
148
  }
149
149
  const ne = (e, n) => {
150
- const { name: t, id: s, width: a, height: o, unit: i } = e, { fixedHeight: c } = n, p = `${a}${i}`, g = `${o}${i}`;
150
+ const { name: t, id: s, width: a, height: o, unit: i } = e, { fixedHeight: r } = n, p = `${a}${i}`, g = `${o}${i}`;
151
151
  return {
152
152
  id: s || t.toLowerCase().replace(/\s/g, "-"),
153
153
  name: `${t} (${p} x ${g})`,
@@ -156,18 +156,18 @@ const ne = (e, n) => {
156
156
  sizeUnit: i,
157
157
  widthMedia: "",
158
158
  width: p,
159
- minHeight: c ? "0" : `${$(o, i)}px`,
160
- height: c ? g : void 0
159
+ minHeight: r ? "0" : `${L(o, i)}px`,
160
+ height: r ? g : void 0
161
161
  };
162
- }, D = "page-breaks", R = "gjs-page-breaks-spot", L = (e) => e.type === D;
162
+ }, $ = "page-breaks", R = "gjs-page-breaks-spot", S = (e) => e.type === $;
163
163
  function oe(e) {
164
- const { Devices: n } = e, { height: t, minHeight: s } = n.getSelected().attributes, o = parseFloat(`${t && t !== "auto" ? t : s}`), i = e.getWrapper(), c = i == null ? void 0 : i.getEl(), p = [];
165
- if (!i || !c)
164
+ const { Devices: n } = e, { height: t, minHeight: s } = n.getSelected().attributes, o = parseFloat(`${t && t !== "auto" ? t : s}`), i = e.getWrapper(), r = i == null ? void 0 : i.getEl(), p = [];
165
+ if (!i || !r)
166
166
  return p;
167
- const g = c.getBoundingClientRect().height, u = i.findType(P).map((f) => f.getEl()).filter(Boolean).map((f) => ({ top: f.offsetTop, height: f.offsetHeight }));
167
+ const g = r.getBoundingClientRect().height, u = i.findType(P).map((f) => f.getEl()).filter(Boolean).map((f) => ({ top: f.offsetTop, height: f.offsetHeight }));
168
168
  let d = 0;
169
169
  for (; d < g; ) {
170
- const f = u.find((r) => r.top > d && r.top < d + o);
170
+ const f = u.find((m) => m.top > d && m.top < d + o);
171
171
  f ? (d = f.top + f.height, p.push(f.top)) : (d += o, d < g && p.push(d));
172
172
  }
173
173
  return p;
@@ -177,7 +177,7 @@ function ae(e, n) {
177
177
  let o;
178
178
  const i = () => {
179
179
  F(
180
- `${W}preset-printable-spots`,
180
+ `${I}preset-printable-spots`,
181
181
  `.${R} {
182
182
  position: absolute;
183
183
  left: 0;
@@ -198,61 +198,66 @@ function ae(e, n) {
198
198
  `,
199
199
  { target: window.document.head }
200
200
  );
201
- }, c = () => {
201
+ }, r = () => {
202
202
  if (n.enablePageBreaksSpot === !1) return;
203
- const r = { id: D, type: D, component: e.getWrapper() };
204
- return t.getSpots(r).pop() || t.addSpot(r);
205
- }, p = ({ spot: r }) => {
206
- const { spotEl: h } = r.attributes;
207
- !L(r) || !h || !o || o.removeChild(h);
208
- }, g = ({ spot: r }) => {
209
- if (!L(r) || !o) return;
210
- let { spotEl: h } = r.attributes;
211
- h || (h = document.createElement("div"), h.className = `${R}__items`, r.set({ spotEl: h })), o.appendChild(h);
212
- }, l = ({ spot: r }) => {
213
- const { spotEl: h, pageBreaks: E = [] } = r.attributes;
214
- !L(r) || !h || !o || (Object.entries(r.getStyle()).forEach(([y, A]) => h.style.setProperty(y, A)), h.innerHTML = "", E.forEach((y, A) => {
215
- const v = document.createElement("div");
216
- v.setAttribute("data-page-number", `${A + 2}`), v.className = R, v.style.top = `${y}px`, h.appendChild(v);
203
+ const l = { id: $, type: $, component: e.getWrapper() };
204
+ return t.getSpots(l).pop() || t.addSpot(l);
205
+ }, p = ({ spot: l }) => {
206
+ const { spotEl: v } = l.attributes;
207
+ !S(l) || !v || !o || o.removeChild(v);
208
+ }, g = ({ spot: l }) => {
209
+ if (!S(l) || !o) return;
210
+ let { spotEl: v } = l.attributes;
211
+ v || (v = document.createElement("div"), v.className = `${R}__items`, l.set({ spotEl: v })), o.appendChild(v);
212
+ }, c = ({ spot: l }) => {
213
+ const { spotEl: v, pageBreaks: A = [] } = l.attributes;
214
+ !S(l) || !v || !o || (Object.entries(l.getStyle()).forEach(([T, b]) => v.style.setProperty(T, b)), v.innerHTML = "", A.forEach((T, b) => {
215
+ const h = document.createElement("div");
216
+ h.setAttribute("data-page-number", `${b + 2}`), h.className = R, h.style.top = `${T}px`, v.appendChild(h);
217
217
  }));
218
- }, u = se(() => {
219
- const r = c();
220
- r && r.set({ pageBreaks: oe(e), up: (r.attributes.up || 0) + 1 });
221
- }, 150), d = () => {
222
- o = t.getSpotsEl(), c();
223
- }, f = [
218
+ }, u = _(() => {
219
+ if (e.em.destroyed) return;
220
+ const l = r();
221
+ l && l.set({ pageBreaks: oe(e), up: (l.attributes.up || 0) + 1 });
222
+ }, 150), d = _(u, 200), f = () => {
223
+ o = t.getSpotsEl(), r();
224
+ }, m = [
224
225
  ["component:input", u],
225
226
  [a.update, u],
226
227
  [s.spotAdd, g],
227
- [s.spotUpdate, l],
228
+ [s.spotUpdate, c],
228
229
  [s.spotRemove, p],
229
- [s.frameLoadBody, d]
230
+ [s.frameLoadBody, f]
230
231
  ];
231
- return f.forEach(([r, h]) => e.on(r, h)), e.onReady(() => {
232
- i();
232
+ return m.forEach(([l, v]) => e.on(l, v)), e.onReady(() => {
233
+ i(), new ResizeObserver(d).observe(t.getElement().parentElement);
233
234
  }), () => {
234
- f.forEach(([r, h]) => e.off(r, h)), u.clear();
235
+ m.forEach(([l, v]) => e.off(l, v)), u.clear(), d.clear();
235
236
  };
236
237
  }
237
- var S = /* @__PURE__ */ ((e) => (e.print = "presetPrintable:print", e))(S || {});
238
- const _ = (e) => new Promise((n) => {
238
+ var D = /* @__PURE__ */ ((e) => (e.print = "presetPrintable:print", e))(D || {});
239
+ const M = (e) => new Promise((n) => {
239
240
  const t = document.createElement("iframe");
240
241
  t.style.cssText = "position: absolute; width: 0; height: 0; border: 0; opacity: 0; pointer-events: none;", t.srcdoc = e.content, t.onload = () => n(t), document.body.appendChild(t);
241
242
  });
242
243
  function ie(e, n) {
243
244
  const { Commands: t, Pages: s } = e;
244
245
  return t.add(
245
- S.print,
246
+ D.print,
246
247
  async (a, o, i = {}) => {
247
- const c = {
248
+ const r = {
248
249
  page: i.allPages ? void 0 : s.getSelected(),
249
- styles: "inline"
250
- }, g = (await t.run(G.projectFiles, c)).filter((d) => d.filename.endsWith(".html")), l = g.map((d) => d.content).join('<div style="break-before: page;"></div>'), u = [];
250
+ styles: "inline",
251
+ optionsHtml: {
252
+ // Avoid DataSource exporter
253
+ exporter: null
254
+ }
255
+ }, g = (await t.run(O.projectFiles, r)).filter((d) => d.filename.endsWith(".html")), c = g.map((d) => d.content).join('<div style="break-before: page;"></div>'), u = [];
251
256
  if (i.separatePrints)
252
257
  for (const d of g)
253
- u.push(await _(d));
258
+ u.push(await M(d));
254
259
  else
255
- u.push(await _({ content: l, filename: "", mimeType: "" }));
260
+ u.push(await M({ content: c, filename: "", mimeType: "" }));
256
261
  for (const d of u) {
257
262
  const f = d.contentWindow;
258
263
  f.focus(), f.print();
@@ -261,14 +266,14 @@ function ie(e, n) {
261
266
  }
262
267
  ), t.add("presetPrintable:exp", async (a) => {
263
268
  await j("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"), await j("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");
264
- const { Devices: o, Canvas: i } = a, { sizeW: c, sizeH: p, sizeUnit: g } = o.getSelected().attributes, l = i.getFrameEl().contentDocument, u = "px", d = [$(c, g), $(p, g)], f = new window.jspdf.jsPDF({ unit: u, format: d }), r = l.body;
265
- f.html(r, { callback: (h) => h.save() });
269
+ const { Devices: o, Canvas: i } = a, { sizeW: r, sizeH: p, sizeUnit: g } = o.getSelected().attributes, c = i.getFrameEl().contentDocument, u = "px", d = [L(r, g), L(p, g)], f = new window.jspdf.jsPDF({ unit: u, format: d }), m = c.body;
270
+ f.html(m, { callback: (l) => l.save() });
266
271
  }), () => {
267
- delete e.Commands.commands[S.print];
272
+ delete e.Commands.commands[D.print];
268
273
  };
269
274
  }
270
275
  function re(e, n) {
271
- const { blockPageBreak: t = {} } = n, { Components: s, Blocks: a } = e, o = "Page Break", i = `${te}${P}`;
276
+ const { blockPageBreak: t = {} } = n, { Components: s, Blocks: a } = e, o = "Page Break", i = `${se}${P}`;
272
277
  return s.addType(P, {
273
278
  block: t && {
274
279
  label: o,
@@ -277,16 +282,16 @@ function re(e, n) {
277
282
  select: !0,
278
283
  ...t
279
284
  },
280
- isComponent: Q(P),
285
+ isComponent: ee(P),
281
286
  model: {
282
287
  defaults: {
283
288
  name: o,
284
289
  classes: i,
285
- attributes: { [O]: P },
290
+ attributes: { [W]: P },
286
291
  emptyState: !0,
287
292
  stylable: !1,
288
293
  droppable: !1,
289
- draggable: ee("wrapper"),
294
+ draggable: te("wrapper"),
290
295
  styles: `.${i} { break-before: page; }`,
291
296
  traits: []
292
297
  }
@@ -299,7 +304,7 @@ const ce = "presetPrintable", le = function(e, n = {}) {
299
304
  const t = {
300
305
  selectedDevice: "a4",
301
306
  ...n
302
- }, { Canvas: s, Devices: a } = e, o = s.events, i = e.events, c = t.selectedDevice || a.getConfig().default, g = [
307
+ }, { Canvas: s, Devices: a } = e, o = s.events, i = e.events, r = t.selectedDevice || a.getConfig().default, g = [
303
308
  { name: "A5", width: 148, height: 210, unit: "mm" },
304
309
  { name: "A5 Portrait", width: 210, height: 148, unit: "mm" },
305
310
  { name: "A4", width: 210, height: 297, unit: "mm" },
@@ -309,15 +314,15 @@ const ce = "presetPrintable", le = function(e, n = {}) {
309
314
  { name: "Letter", width: 8.5, height: 11, unit: "in" },
310
315
  { name: "Legal", width: 8.5, height: 14, unit: "in" },
311
316
  { name: "Ledger", width: 11, height: 17, unit: "in" }
312
- ].map((v) => ne(v, t));
317
+ ].map((b) => ne(b, t));
313
318
  a.devices.reset(g);
314
- const l = c && a.get(c) || a.getAll().at(0);
315
- a.select(l);
319
+ const c = r && a.get(r) || a.getAll().at(0);
320
+ a.select(c);
316
321
  const u = () => {
317
- const v = "page-rule", { rules: b } = e.Css, { width: w, height: m, minHeight: k } = a.getSelected().attributes, B = m && m !== "auto" ? m : k;
318
- (b.where({ id: v }).pop() || b.add(
322
+ const b = "page-rule", { rules: h } = e.Css, { width: w, height: y, minHeight: k } = a.getSelected().attributes, B = y && y !== "auto" ? y : k;
323
+ (h.where({ id: b }).pop() || h.add(
319
324
  {
320
- id: v,
325
+ id: b,
321
326
  selectors: [],
322
327
  selectorsAdd: "@page"
323
328
  },
@@ -326,8 +331,8 @@ const ce = "presetPrintable", le = function(e, n = {}) {
326
331
  size: `${w} ${B}`,
327
332
  margin: "0"
328
333
  });
329
- }, d = (v) => {
330
- const b = v.document, { minHeight: w } = a.getSelected().attributes, k = `
334
+ }, d = (b) => {
335
+ const h = b.document, { minHeight: w } = a.getSelected().attributes, k = `
331
336
  ${!!parseFloat(`${w}`) ? `
332
337
  [data-gjs-type="wrapper"] { min-height: ${w}; }
333
338
  ` : `
@@ -341,48 +346,48 @@ const ce = "presetPrintable", le = function(e, n = {}) {
341
346
  }
342
347
  `}
343
348
  `;
344
- F(`${W}preset-printable`, k, { doc: b, target: b.head }), u();
349
+ F(`${I}preset-printable`, k, { doc: h, target: h.head }), u();
345
350
  };
346
- e.on(o.frameLoadBody, (v) => {
347
- const b = v.window;
348
- if (d(b), t.fixedHeight) {
349
- const m = v.model.getComponent().getEl();
350
- m == null || m.addEventListener("scroll", (k) => {
351
+ e.on(o.frameLoadBody, (b) => {
352
+ const h = b.window;
353
+ if (d(h), t.fixedHeight) {
354
+ const y = b.model.getComponent().getEl();
355
+ y == null || y.addEventListener("scroll", (k) => {
351
356
  const B = k.target;
352
357
  B.scrollTop > 0 && B.scrollTo(0, 0);
353
358
  });
354
359
  }
355
360
  }), e.on(a.events.select, () => {
356
- var b;
357
- const v = (b = s.getFrameEl().contentDocument) == null ? void 0 : b.defaultView;
358
- v && d(v);
361
+ var h;
362
+ const b = (h = s.getFrameEl().contentDocument) == null ? void 0 : h.defaultView;
363
+ b && d(b);
359
364
  });
360
365
  const f = () => {
361
- const b = e.Css.getRules().filter((w) => w.selectorsToString() === "body").pop();
362
- b == null || b.addStyle({
366
+ const h = e.Css.getRules().filter((w) => w.selectorsToString() === "body").pop();
367
+ h == null || h.addStyle({
363
368
  "margin-top": "",
364
369
  "margin-right": "",
365
370
  "margin-bottom": "",
366
371
  "margin-left": "",
367
372
  margin: "0"
368
373
  });
369
- }, r = [[i.projectLoad, f]];
370
- r.forEach(([v, b]) => e.on(v, b));
371
- const h = ae(e, t), E = ie(e), y = re(e, t);
374
+ }, m = [[i.projectLoad, f]];
375
+ m.forEach(([b, h]) => e.on(b, h));
376
+ const l = ae(e, t), v = ie(e), A = re(e, t);
372
377
  e.onReady(() => {
373
378
  e.UndoManager.clear();
374
379
  });
375
- const A = () => {
376
- r.forEach(([v, b]) => e.off(v, b)), h(), E(), y();
380
+ const T = () => {
381
+ m.forEach(([b, h]) => e.off(b, h)), l(), v(), A();
377
382
  };
378
- X({
383
+ e.on(i.destroy, T), Z({
379
384
  editor: e,
380
385
  licenseKey: t.licenseKey,
381
- plan: T.startup,
386
+ plan: E.startup,
382
387
  pluginName: ce,
383
- cleanup: A
388
+ cleanup: T
384
389
  });
385
- }, ge = J(le);
390
+ }, ge = X(le);
386
391
  export {
387
392
  ge as default
388
393
  };
@@ -1,10 +1,10 @@
1
- (function(T,E){typeof exports=="object"&&typeof module<"u"?module.exports=E():typeof define=="function"&&define.amd?define(E):(T=typeof globalThis<"u"?globalThis:T||self,T.StudioSdkPlugins_presetPrintable=E())})(this,function(){"use strict";const T="app.grapesjs.com",E="app-stage.grapesjs.com",_=[T,E,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],I="license:check:start",N="license:check:end",C=()=>typeof window<"u",H=(e,n={})=>{const t=q(e)?{id:e,src:e}:e;return new Promise((s,a)=>{var p,g;const o=document.querySelector(`script[src="${t.src}"]`),{id:i}=t;if(o)return(p=n.onScript)==null||p.call(n,o),s(i);const c=document.createElement("script");c.src=t.src,c.onload=()=>s(i),c.onerror=()=>a(i),document.head.appendChild(c),(g=n.onScript)==null||g.call(n,c)})},K=({isDev:e,isStage:n})=>`${e?"":`https://${n?E:T}`}/api`,z=()=>{const e=C()&&window.location.hostname;return!!e&&(_.includes(e)||_.some(n=>e.endsWith(n)))},q=e=>typeof e=="string";async function V({path:e,baseApiUrl:n,method:t="GET",headers:s={},params:a,body:o}){const c=`${n||K({isDev:!1,isStage:!1})}${e}`,p={method:t,headers:{"Content-Type":"application/json",...s}};o&&(p.body=JSON.stringify(o));const g=a?new URLSearchParams(a).toString():"",l=g?`?${g}`:"",u=await fetch(`${c}${l}`,p);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var k=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(k||{}),M=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.setDragAbsolute="studio:setDragAbsolute",e))(M||{});const U={[k.free]:0,[k.startup]:10,[k.business]:20,[k.enterprise]:30};function Y(e){const n=e;return n.init=t=>s=>e(s,t),n}const J=e=>Y(e);async function X({editor:e,plan:n,pluginName:t,licenseKey:s,cleanup:a}){let o="",i=!1;const c=z(),p=l=>{console.warn("Cleanup plugin:",t,"Reason:",l),a()},g=(l={})=>{var h;const{error:u,sdkLicense:d}=l,f=(h=l.plan)==null?void 0:h.category;if(!(d||l.license)||u)p(u||"Invalid license");else if(f){const A=U[n],P=U[f];A>P&&p({pluginRequiredPlan:n,licensePlan:f})}};e.on(I,l=>{o=l==null?void 0:l.baseApiUrl,i=!0}),e.on(N,l=>{g(l)}),setTimeout(async()=>{if(!i){if(c)return;if(s){const l=await Z({licenseKey:s,pluginName:t,baseApiUrl:o});l&&g(l)}else p("The `licenseKey` option not provided")}},2e3)}async function Z(e){const{licenseKey:n,pluginName:t,baseApiUrl:s}=e;try{return(await V({baseApiUrl:s,path:`/sdk/${n||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const Q=e=>n=>{var t;return((t=n.getAttribute)==null?void 0:t.call(n,W))===e},ee=(...e)=>(n,t)=>e.some(s=>t.is(s)),G=(e,n,t)=>{const{doc:s=document}=t,a=t.target||s.head,o=a.querySelector(`style[${e}]`)||s.createElement("style");o.setAttribute(e,"true"),o.innerHTML=n,!a.contains(o)&&a.appendChild(o)},te="gjs-plg-",F="data-gs-plg-",W="data-type-role";function se(e,n,t){let s,a,o,i,c;const p=n;function g(){const u=Date.now()-i;u<p&&u>=0?s=setTimeout(g,p-u):(s=null,c=e.apply(o,a),o=a=null)}const l=function(){return o=this,a=arguments,i=Date.now(),s||(s=setTimeout(g,p)),c};return l.clear=function(){s&&(clearTimeout(s),s=null)},l.flush=function(){s&&(c=e.apply(o,a),o=a=null,clearTimeout(s),s=null)},l}const y="page-break";function D(e,n){const s={mm:3.7795275590551185,cm:37.79527559055118,in:96,pt:1.3333333333333333,pc:16};return s[n]?e*s[n]:null}const ne=(e,n)=>{const{name:t,id:s,width:a,height:o,unit:i}=e,{fixedHeight:c}=n,p=`${a}${i}`,g=`${o}${i}`;return{id:s||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${p} x ${g})`,sizeH:o,sizeW:a,sizeUnit:i,widthMedia:"",width:p,minHeight:c?"0":`${D(o,i)}px`,height:c?g:void 0}},S="page-breaks",L="gjs-page-breaks-spot",x=e=>e.type===S;function oe(e){const{Devices:n}=e,{height:t,minHeight:s}=n.getSelected().attributes,o=parseFloat(`${t&&t!=="auto"?t:s}`),i=e.getWrapper(),c=i==null?void 0:i.getEl(),p=[];if(!i||!c)return p;const g=c.getBoundingClientRect().height,u=i.findType(y).map(f=>f.getEl()).filter(Boolean).map(f=>({top:f.offsetTop,height:f.offsetHeight}));let d=0;for(;d<g;){const f=u.find(r=>r.top>d&&r.top<d+o);f?(d=f.top+f.height,p.push(f.top)):(d+=o,d<g&&p.push(d))}return p}function ae(e,n){const{Canvas:t}=e,s=t.events,a=e.events;let o;const i=()=>{G(`${F}preset-printable-spots`,`.${L} {
1
+ (function(T,E){typeof exports=="object"&&typeof module<"u"?module.exports=E():typeof define=="function"&&define.amd?define(E):(T=typeof globalThis<"u"?globalThis:T||self,T.StudioSdkPlugins_presetPrintable=E())})(this,function(){"use strict";const T="app.grapesjs.com",E="app-stage.grapesjs.com",H=[T,E,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],N="license:check:start",z="license:check:end",K=()=>typeof window<"u",_=(e,n={})=>{const t=V(e)?{id:e,src:e}:e;return new Promise((s,a)=>{var p,d;const o=document.querySelector(`script[src="${t.src}"]`),{id:i}=t;if(o)return(p=n.onScript)==null||p.call(n,o),s(i);const r=document.createElement("script");r.src=t.src,r.onload=()=>s(i),r.onerror=()=>a(i),document.head.appendChild(r),(d=n.onScript)==null||d.call(n,r)})},C=({isDev:e,isStage:n})=>`${e?"":`https://${n?E:T}`}/api`,q=()=>{const e=K()&&window.location.hostname;return!!e&&(H.includes(e)||H.some(n=>e.endsWith(n)))},V=e=>typeof e=="string";async function Y({path:e,baseApiUrl:n,method:t="GET",headers:s={},params:a,body:o}){const r=`${n||C({isDev:!1,isStage:!1})}${e}`,p={method:t,headers:{"Content-Type":"application/json",...s}};o&&(p.body=JSON.stringify(o));const d=a?new URLSearchParams(a).toString():"",c=d?`?${d}`:"",u=await fetch(`${r}${c}`,p);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var k=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(k||{}),M=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(M||{});const U={[k.free]:0,[k.startup]:10,[k.business]:20,[k.enterprise]:30};function J(e){const n=e;return n.init=t=>s=>e(s,t),n}const X=e=>J(e);async function Z({editor:e,plan:n,pluginName:t,licenseKey:s,cleanup:a}){let o="",i=!1;const r=q(),p=c=>{console.warn("Cleanup plugin:",t,"Reason:",c),a()},d=(c={})=>{var l;const{error:u,sdkLicense:g}=c,f=(l=c.plan)==null?void 0:l.category;if(!(g||c.license)||u)p(u||"Invalid license");else if(f){const b=U[n],B=U[f];b>B&&p({pluginRequiredPlan:n,licensePlan:f})}};e.on(N,c=>{o=c==null?void 0:c.baseApiUrl,i=!0}),e.on(z,c=>{d(c)}),setTimeout(async()=>{if(!i){if(r)return;if(s){const c=await Q({licenseKey:s,pluginName:t,baseApiUrl:o});c&&d(c)}else p("The `licenseKey` option not provided")}},2e3)}async function Q(e){const{licenseKey:n,pluginName:t,baseApiUrl:s}=e;try{return(await Y({baseApiUrl:s,path:`/sdk/${n||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const ee=e=>n=>{var t;return((t=n.getAttribute)==null?void 0:t.call(n,F))===e},te=(...e)=>(n,t)=>e.some(s=>t.is(s)),G=(e,n,t)=>{const{doc:s=document}=t,a=t.target||s.head,o=a.querySelector(`style[${e}]`)||s.createElement("style");o.setAttribute(e,"true"),o.innerHTML=n,!a.contains(o)&&a.appendChild(o)},se="gjs-plg-",O="data-gs-plg-",F="data-type-role";function I(e,n,t){let s,a,o,i,r;const p=n===void 0?100:n;function d(){const u=Date.now()-i;u<p&&u>=0?s=setTimeout(d,p-u):(s=null,r=e.apply(o,a),o=a=null)}const c=function(){return o=this,a=arguments,i=Date.now(),s||(s=setTimeout(d,p)),r};return c.clear=function(){s&&(clearTimeout(s),s=null)},c.flush=function(){s&&(r=e.apply(o,a),o=a=null,clearTimeout(s),s=null)},c}const P="page-break";function $(e,n){const s={mm:3.7795275590551185,cm:37.79527559055118,in:96,pt:1.3333333333333333,pc:16};return s[n]?e*s[n]:null}const ne=(e,n)=>{const{name:t,id:s,width:a,height:o,unit:i}=e,{fixedHeight:r}=n,p=`${a}${i}`,d=`${o}${i}`;return{id:s||t.toLowerCase().replace(/\s/g,"-"),name:`${t} (${p} x ${d})`,sizeH:o,sizeW:a,sizeUnit:i,widthMedia:"",width:p,minHeight:r?"0":`${$(o,i)}px`,height:r?d:void 0}},D="page-breaks",R="gjs-page-breaks-spot",x=e=>e.type===D;function oe(e){const{Devices:n}=e,{height:t,minHeight:s}=n.getSelected().attributes,o=parseFloat(`${t&&t!=="auto"?t:s}`),i=e.getWrapper(),r=i==null?void 0:i.getEl(),p=[];if(!i||!r)return p;const d=r.getBoundingClientRect().height,u=i.findType(P).map(f=>f.getEl()).filter(Boolean).map(f=>({top:f.offsetTop,height:f.offsetHeight}));let g=0;for(;g<d;){const f=u.find(m=>m.top>g&&m.top<g+o);f?(g=f.top+f.height,p.push(f.top)):(g+=o,g<d&&p.push(g))}return p}function ae(e,n){const{Canvas:t}=e,s=t.events,a=e.events;let o;const i=()=>{G(`${O}preset-printable-spots`,`.${R} {
2
2
  position: absolute;
3
3
  left: 0;
4
4
  width: 100%;
5
5
  border-top: 1px dashed var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue));
6
6
  }
7
- .${L}::after {
7
+ .${R}::after {
8
8
  background-color: var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight));
9
9
  content: attr(data-page-number);
10
10
  display: block;
@@ -15,7 +15,7 @@
15
15
  right: 0;
16
16
  transform: translate(100%, -50%);
17
17
  }
18
- `,{target:window.document.head})},c=()=>{if(n.enablePageBreaksSpot===!1)return;const r={id:S,type:S,component:e.getWrapper()};return t.getSpots(r).pop()||t.addSpot(r)},p=({spot:r})=>{const{spotEl:h}=r.attributes;!x(r)||!h||!o||o.removeChild(h)},g=({spot:r})=>{if(!x(r)||!o)return;let{spotEl:h}=r.attributes;h||(h=document.createElement("div"),h.className=`${L}__items`,r.set({spotEl:h})),o.appendChild(h)},l=({spot:r})=>{const{spotEl:h,pageBreaks:A=[]}=r.attributes;!x(r)||!h||!o||(Object.entries(r.getStyle()).forEach(([P,B])=>h.style.setProperty(P,B)),h.innerHTML="",A.forEach((P,B)=>{const b=document.createElement("div");b.setAttribute("data-page-number",`${B+2}`),b.className=L,b.style.top=`${P}px`,h.appendChild(b)}))},u=se(()=>{const r=c();r&&r.set({pageBreaks:oe(e),up:(r.attributes.up||0)+1})},150),d=()=>{o=t.getSpotsEl(),c()},f=[["component:input",u],[a.update,u],[s.spotAdd,g],[s.spotUpdate,l],[s.spotRemove,p],[s.frameLoadBody,d]];return f.forEach(([r,h])=>e.on(r,h)),e.onReady(()=>{i()}),()=>{f.forEach(([r,h])=>e.off(r,h)),u.clear()}}var j=(e=>(e.print="presetPrintable:print",e))(j||{});const O=e=>new Promise(n=>{const t=document.createElement("iframe");t.style.cssText="position: absolute; width: 0; height: 0; border: 0; opacity: 0; pointer-events: none;",t.srcdoc=e.content,t.onload=()=>n(t),document.body.appendChild(t)});function ie(e,n){const{Commands:t,Pages:s}=e;return t.add(j.print,async(a,o,i={})=>{const c={page:i.allPages?void 0:s.getSelected(),styles:"inline"},g=(await t.run(M.projectFiles,c)).filter(d=>d.filename.endsWith(".html")),l=g.map(d=>d.content).join('<div style="break-before: page;"></div>'),u=[];if(i.separatePrints)for(const d of g)u.push(await O(d));else u.push(await O({content:l,filename:"",mimeType:""}));for(const d of u){const f=d.contentWindow;f.focus(),f.print()}setTimeout(()=>u.forEach(d=>d.remove()),1e3)}),t.add("presetPrintable:exp",async a=>{await H("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"),await H("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");const{Devices:o,Canvas:i}=a,{sizeW:c,sizeH:p,sizeUnit:g}=o.getSelected().attributes,l=i.getFrameEl().contentDocument,u="px",d=[D(c,g),D(p,g)],f=new window.jspdf.jsPDF({unit:u,format:d}),r=l.body;f.html(r,{callback:h=>h.save()})}),()=>{delete e.Commands.commands[j.print]}}function re(e,n){const{blockPageBreak:t={}}=n,{Components:s,Blocks:a}=e,o="Page Break",i=`${te}${y}`;return s.addType(y,{block:t&&{label:o,media:'<svg viewBox="0 0 24 24"><path d="M18 20H6v-2H4v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2h-2v2M14 2H6a2 2 0 0 0-2 2v8h2V4h8v4h4v4h2V8l-6-6m-3 14H8v-2h3v2m5 0h-3v-2h3v2M3 14h3v2H3v-2m18 2h-3v-2h3v2Z"/></svg>',category:"Extra",select:!0,...t},isComponent:Q(y),model:{defaults:{name:o,classes:i,attributes:{[W]:y},emptyState:!0,stylable:!1,droppable:!1,draggable:ee("wrapper"),styles:`.${i} { break-before: page; }`,traits:[]}}}),()=>{s.removeType(y),a.remove(y)}}const ce="presetPrintable";return J(function(e,n={}){const t={selectedDevice:"a4",...n},{Canvas:s,Devices:a}=e,o=s.events,i=e.events,c=t.selectedDevice||a.getConfig().default,g=[{name:"A5",width:148,height:210,unit:"mm"},{name:"A5 Portrait",width:210,height:148,unit:"mm"},{name:"A4",width:210,height:297,unit:"mm"},{name:"A3",width:297,height:420,unit:"mm"},{name:"B5",width:176,height:250,unit:"mm"},{name:"B4",width:250,height:353,unit:"mm"},{name:"Letter",width:8.5,height:11,unit:"in"},{name:"Legal",width:8.5,height:14,unit:"in"},{name:"Ledger",width:11,height:17,unit:"in"}].map(b=>ne(b,t));a.devices.reset(g);const l=c&&a.get(c)||a.getAll().at(0);a.select(l);const u=()=>{const b="page-rule",{rules:v}=e.Css,{width:w,height:m,minHeight:R}=a.getSelected().attributes,$=m&&m!=="auto"?m:R;(v.where({id:b}).pop()||v.add({id:b,selectors:[],selectorsAdd:"@page"},{at:0})).setStyle({size:`${w} ${$}`,margin:"0"})},d=b=>{const v=b.document,{minHeight:w}=a.getSelected().attributes,R=`
18
+ `,{target:window.document.head})},r=()=>{if(n.enablePageBreaksSpot===!1)return;const l={id:D,type:D,component:e.getWrapper()};return t.getSpots(l).pop()||t.addSpot(l)},p=({spot:l})=>{const{spotEl:b}=l.attributes;!x(l)||!b||!o||o.removeChild(b)},d=({spot:l})=>{if(!x(l)||!o)return;let{spotEl:b}=l.attributes;b||(b=document.createElement("div"),b.className=`${R}__items`,l.set({spotEl:b})),o.appendChild(b)},c=({spot:l})=>{const{spotEl:b,pageBreaks:B=[]}=l.attributes;!x(l)||!b||!o||(Object.entries(l.getStyle()).forEach(([A,v])=>b.style.setProperty(A,v)),b.innerHTML="",B.forEach((A,v)=>{const h=document.createElement("div");h.setAttribute("data-page-number",`${v+2}`),h.className=R,h.style.top=`${A}px`,b.appendChild(h)}))},u=I(()=>{if(e.em.destroyed)return;const l=r();l&&l.set({pageBreaks:oe(e),up:(l.attributes.up||0)+1})},150),g=I(u,200),f=()=>{o=t.getSpotsEl(),r()},m=[["component:input",u],[a.update,u],[s.spotAdd,d],[s.spotUpdate,c],[s.spotRemove,p],[s.frameLoadBody,f]];return m.forEach(([l,b])=>e.on(l,b)),e.onReady(()=>{i(),new ResizeObserver(g).observe(t.getElement().parentElement)}),()=>{m.forEach(([l,b])=>e.off(l,b)),u.clear(),g.clear()}}var j=(e=>(e.print="presetPrintable:print",e))(j||{});const W=e=>new Promise(n=>{const t=document.createElement("iframe");t.style.cssText="position: absolute; width: 0; height: 0; border: 0; opacity: 0; pointer-events: none;",t.srcdoc=e.content,t.onload=()=>n(t),document.body.appendChild(t)});function ie(e,n){const{Commands:t,Pages:s}=e;return t.add(j.print,async(a,o,i={})=>{const r={page:i.allPages?void 0:s.getSelected(),styles:"inline",optionsHtml:{exporter:null}},d=(await t.run(M.projectFiles,r)).filter(g=>g.filename.endsWith(".html")),c=d.map(g=>g.content).join('<div style="break-before: page;"></div>'),u=[];if(i.separatePrints)for(const g of d)u.push(await W(g));else u.push(await W({content:c,filename:"",mimeType:""}));for(const g of u){const f=g.contentWindow;f.focus(),f.print()}setTimeout(()=>u.forEach(g=>g.remove()),1e3)}),t.add("presetPrintable:exp",async a=>{await _("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"),await _("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");const{Devices:o,Canvas:i}=a,{sizeW:r,sizeH:p,sizeUnit:d}=o.getSelected().attributes,c=i.getFrameEl().contentDocument,u="px",g=[$(r,d),$(p,d)],f=new window.jspdf.jsPDF({unit:u,format:g}),m=c.body;f.html(m,{callback:l=>l.save()})}),()=>{delete e.Commands.commands[j.print]}}function re(e,n){const{blockPageBreak:t={}}=n,{Components:s,Blocks:a}=e,o="Page Break",i=`${se}${P}`;return s.addType(P,{block:t&&{label:o,media:'<svg viewBox="0 0 24 24"><path d="M18 20H6v-2H4v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2h-2v2M14 2H6a2 2 0 0 0-2 2v8h2V4h8v4h4v4h2V8l-6-6m-3 14H8v-2h3v2m5 0h-3v-2h3v2M3 14h3v2H3v-2m18 2h-3v-2h3v2Z"/></svg>',category:"Extra",select:!0,...t},isComponent:ee(P),model:{defaults:{name:o,classes:i,attributes:{[F]:P},emptyState:!0,stylable:!1,droppable:!1,draggable:te("wrapper"),styles:`.${i} { break-before: page; }`,traits:[]}}}),()=>{s.removeType(P),a.remove(P)}}const ce="presetPrintable";return X(function(e,n={}){const t={selectedDevice:"a4",...n},{Canvas:s,Devices:a}=e,o=s.events,i=e.events,r=t.selectedDevice||a.getConfig().default,d=[{name:"A5",width:148,height:210,unit:"mm"},{name:"A5 Portrait",width:210,height:148,unit:"mm"},{name:"A4",width:210,height:297,unit:"mm"},{name:"A3",width:297,height:420,unit:"mm"},{name:"B5",width:176,height:250,unit:"mm"},{name:"B4",width:250,height:353,unit:"mm"},{name:"Letter",width:8.5,height:11,unit:"in"},{name:"Legal",width:8.5,height:14,unit:"in"},{name:"Ledger",width:11,height:17,unit:"in"}].map(v=>ne(v,t));a.devices.reset(d);const c=r&&a.get(r)||a.getAll().at(0);a.select(c);const u=()=>{const v="page-rule",{rules:h}=e.Css,{width:w,height:y,minHeight:S}=a.getSelected().attributes,L=y&&y!=="auto"?y:S;(h.where({id:v}).pop()||h.add({id:v,selectors:[],selectorsAdd:"@page"},{at:0})).setStyle({size:`${w} ${L}`,margin:"0"})},g=v=>{const h=v.document,{minHeight:w}=a.getSelected().attributes,S=`
19
19
  ${!!parseFloat(`${w}`)?`
20
20
  [data-gjs-type="wrapper"] { min-height: ${w}; }
21
21
  `:`
@@ -28,4 +28,4 @@
28
28
  height: 100dvh;
29
29
  }
30
30
  `}
31
- `;G(`${F}preset-printable`,R,{doc:v,target:v.head}),u()};e.on(o.frameLoadBody,b=>{const v=b.window;if(d(v),t.fixedHeight){const m=b.model.getComponent().getEl();m==null||m.addEventListener("scroll",R=>{const $=R.target;$.scrollTop>0&&$.scrollTo(0,0)})}}),e.on(a.events.select,()=>{var v;const b=(v=s.getFrameEl().contentDocument)==null?void 0:v.defaultView;b&&d(b)});const f=()=>{const v=e.Css.getRules().filter(w=>w.selectorsToString()==="body").pop();v==null||v.addStyle({"margin-top":"","margin-right":"","margin-bottom":"","margin-left":"",margin:"0"})},r=[[i.projectLoad,f]];r.forEach(([b,v])=>e.on(b,v));const h=ae(e,t),A=ie(e),P=re(e,t);e.onReady(()=>{e.UndoManager.clear()});const B=()=>{r.forEach(([b,v])=>e.off(b,v)),h(),A(),P()};X({editor:e,licenseKey:t.licenseKey,plan:k.startup,pluginName:ce,cleanup:B})})});
31
+ `;G(`${O}preset-printable`,S,{doc:h,target:h.head}),u()};e.on(o.frameLoadBody,v=>{const h=v.window;if(g(h),t.fixedHeight){const y=v.model.getComponent().getEl();y==null||y.addEventListener("scroll",S=>{const L=S.target;L.scrollTop>0&&L.scrollTo(0,0)})}}),e.on(a.events.select,()=>{var h;const v=(h=s.getFrameEl().contentDocument)==null?void 0:h.defaultView;v&&g(v)});const f=()=>{const h=e.Css.getRules().filter(w=>w.selectorsToString()==="body").pop();h==null||h.addStyle({"margin-top":"","margin-right":"","margin-bottom":"","margin-left":"",margin:"0"})},m=[[i.projectLoad,f]];m.forEach(([v,h])=>e.on(v,h));const l=ae(e,t),b=ie(e),B=re(e,t);e.onReady(()=>{e.UndoManager.clear()});const A=()=>{m.forEach(([v,h])=>e.off(v,h)),l(),b(),B()};e.on(i.destroy,A),Z({editor:e,licenseKey:t.licenseKey,plan:k.startup,pluginName:ce,cleanup:A})})});