@grapesjs/studio-sdk-plugins 1.0.22 → 1.0.23

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,6 +1,6 @@
1
- const U = "app.grapesjs.com", G = "app-stage.grapesjs.com", x = [
2
- U,
3
- G,
1
+ const N = "app.grapesjs.com", W = "app-stage.grapesjs.com", G = [
2
+ N,
3
+ W,
4
4
  "localhost",
5
5
  "127.0.0.1",
6
6
  ".local-credentialless.webcontainer.io",
@@ -9,21 +9,21 @@ const U = "app.grapesjs.com", G = "app-stage.grapesjs.com", x = [
9
9
  // For stackblitz.com demos
10
10
  "-sandpack.codesandbox.io"
11
11
  // For Sandpack demos
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;
12
+ ], V = "license:check:start", Y = "license:check:end", J = () => typeof window < "u", M = (e, n = {}) => {
13
+ const t = Q(e) ? { id: e, src: e } : e;
14
14
  return new Promise((s, a) => {
15
- var p, g;
16
- const o = document.querySelector(`script[src="${t.src}"]`), { id: i } = t;
15
+ var l, p;
16
+ const o = document.querySelector(`script[src="${t.src}"]`), { id: r } = t;
17
17
  if (o)
18
- return (p = n.onScript) == null || p.call(n, o), s(i);
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);
18
+ return (l = n.onScript) == null || l.call(n, o), s(r);
19
+ const i = document.createElement("script");
20
+ i.src = t.src, i.onload = () => s(r), i.onerror = () => a(r), document.head.appendChild(i), (p = n.onScript) == null || p.call(n, i);
21
21
  });
22
- }, C = ({ isDev: e, isStage: n }) => `${e ? "" : `https://${n ? G : U}`}/api`, q = () => {
23
- const e = K() && window.location.hostname;
24
- return !!e && (x.includes(e) || x.some((n) => e.endsWith(n)));
25
- }, V = (e) => typeof e == "string";
26
- async function Y({
22
+ }, X = ({ isDev: e, isStage: n }) => `${e ? "" : `https://${n ? W : N}`}/api`, Z = () => {
23
+ const e = J() && window.location.hostname;
24
+ return !!e && (G.includes(e) || G.some((n) => e.endsWith(n)));
25
+ }, Q = (e) => typeof e == "string";
26
+ async function ee({
27
27
  path: e,
28
28
  baseApiUrl: n,
29
29
  method: t = "GET",
@@ -31,70 +31,70 @@ async function Y({
31
31
  params: a,
32
32
  body: o
33
33
  }) {
34
- const r = `${n || C({ isDev: !1, isStage: !1 })}${e}`, p = {
34
+ const i = `${n || X({ isDev: !1, isStage: !1 })}${e}`, l = {
35
35
  method: t,
36
36
  headers: {
37
37
  "Content-Type": "application/json",
38
38
  ...s
39
39
  }
40
40
  };
41
- o && (p.body = JSON.stringify(o));
42
- const g = a ? new URLSearchParams(a).toString() : "", c = g ? `?${g}` : "", u = await fetch(`${r}${c}`, p);
43
- if (!u.ok)
44
- throw new Error(`HTTP error! status: ${u.status}`);
45
- return u.json();
41
+ o && (l.body = JSON.stringify(o));
42
+ const p = a ? new URLSearchParams(a).toString() : "", d = p ? `?${p}` : "", g = await fetch(`${i}${d}`, l);
43
+ if (!g.ok)
44
+ throw new Error(`HTTP error! status: ${g.status}`);
45
+ return g.json();
46
46
  }
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
- const H = {
49
- [E.free]: 0,
50
- [E.startup]: 10,
51
- [E.business]: 20,
52
- [E.enterprise]: 30
47
+ var B = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(B || {}), z = /* @__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))(z || {});
48
+ const O = {
49
+ [B.free]: 0,
50
+ [B.startup]: 10,
51
+ [B.business]: 20,
52
+ [B.enterprise]: 30
53
53
  };
54
- function J(e) {
54
+ function te(e) {
55
55
  const n = e;
56
56
  return n.init = (t) => (s) => e(s, t), n;
57
57
  }
58
- const X = (e) => /* @__PURE__ */ J(e);
59
- async function Z({
58
+ const se = (e) => /* @__PURE__ */ te(e);
59
+ async function ne({
60
60
  editor: e,
61
61
  plan: n,
62
62
  pluginName: t,
63
63
  licenseKey: s,
64
64
  cleanup: a
65
65
  }) {
66
- let o = "", i = !1;
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
- p(u || "Invalid license");
66
+ let o = "", r = !1;
67
+ const i = Z(), l = (d) => {
68
+ console.warn("Cleanup plugin:", t, "Reason:", d), a();
69
+ }, p = (d = {}) => {
70
+ var w;
71
+ const { error: g, sdkLicense: u } = d, f = (w = d.plan) == null ? void 0 : w.category;
72
+ if (!(u || d.license) || g)
73
+ l(g || "Invalid license");
74
74
  else if (f) {
75
- const v = H[n], A = H[f];
76
- v > A && p({ pluginRequiredPlan: n, licensePlan: f });
75
+ const c = O[n], h = O[f];
76
+ c > h && l({ pluginRequiredPlan: n, licensePlan: f });
77
77
  }
78
78
  };
79
- e.on(N, (c) => {
80
- o = c == null ? void 0 : c.baseApiUrl, i = !0;
81
- }), e.on(z, (c) => {
82
- g(c);
79
+ e.on(V, (d) => {
80
+ o = d == null ? void 0 : d.baseApiUrl, r = !0;
81
+ }), e.on(Y, (d) => {
82
+ p(d);
83
83
  }), setTimeout(async () => {
84
- if (!i) {
85
- if (r) return;
84
+ if (!r) {
85
+ if (i) return;
86
86
  if (s) {
87
- const c = await Q({ licenseKey: s, pluginName: t, baseApiUrl: o });
88
- c && g(c);
87
+ const d = await oe({ licenseKey: s, pluginName: t, baseApiUrl: o });
88
+ d && p(d);
89
89
  } else
90
- p("The `licenseKey` option not provided");
90
+ l("The `licenseKey` option not provided");
91
91
  }
92
92
  }, 2e3);
93
93
  }
94
- async function Q(e) {
94
+ async function oe(e) {
95
95
  const { licenseKey: n, pluginName: t, baseApiUrl: s } = e;
96
96
  try {
97
- return (await Y({
97
+ return (await ee({
98
98
  baseApiUrl: s,
99
99
  path: `/sdk/${n || "na"}`,
100
100
  method: "POST",
@@ -107,31 +107,32 @@ async function Q(e) {
107
107
  return console.error("Error during SDK license check:", a), !1;
108
108
  }
109
109
  }
110
- const ee = (e) => (n) => {
110
+ const ae = (e) => (n) => {
111
111
  var 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) => {
112
+ return ((t = n.getAttribute) == null ? void 0 : t.call(n, q)) === e;
113
+ }, re = (...e) => (n, t) => e.some((s) => t.is(s)), K = (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
- }, 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
- function g() {
121
- const u = Date.now() - i;
122
- u < p && u >= 0 ? s = setTimeout(g, p - u) : (s = null, r = e.apply(o, a), o = a = null);
116
+ }, ie = "gjs-plg-", C = "data-gs-plg-", q = "data-type-role";
117
+ function I(e, n, t) {
118
+ let s, a, o, r, i;
119
+ const l = n === void 0 ? 100 : n;
120
+ function p() {
121
+ const g = Date.now() - r;
122
+ g < l && g >= 0 ? s = setTimeout(p, l - g) : (s = null, i = e.apply(o, a), o = a = null);
123
123
  }
124
- const c = function() {
125
- return o = this, a = arguments, i = Date.now(), s || (s = setTimeout(g, p)), r;
124
+ const d = function() {
125
+ return o = this, a = arguments, r = Date.now(), s || (s = setTimeout(p, l)), i;
126
126
  };
127
- return c.clear = function() {
127
+ return d.clear = function() {
128
128
  s && (clearTimeout(s), s = null);
129
- }, c.flush = function() {
130
- s && (r = e.apply(o, a), o = a = null, clearTimeout(s), s = null);
131
- }, c;
129
+ }, d.flush = function() {
130
+ s && (i = e.apply(o, a), o = a = null, clearTimeout(s), s = null);
131
+ }, d;
132
132
  }
133
- const P = "page-break";
134
- function L(e, n) {
133
+ const A = "page-break";
134
+ var m = /* @__PURE__ */ ((e) => (e.A5 = "a5", e.A5Portrait = "a5-portrait", e.A4 = "a4", e.A3 = "a3", e.B5 = "b5", e.B4 = "b4", e.letter = "letter", e.legal = "legal", e.ledger = "ledger", e))(m || {});
135
+ function D(e, n) {
135
136
  const s = {
136
137
  mm: 3.7795275590551185,
137
138
  // 1mm ≈ 3.78px
@@ -146,45 +147,46 @@ function L(e, n) {
146
147
  };
147
148
  return s[n] ? e * s[n] : null;
148
149
  }
149
- const ne = (e, n) => {
150
- const { name: t, id: s, width: a, height: o, unit: i } = e, { fixedHeight: r } = n, p = `${a}${i}`, g = `${o}${i}`;
150
+ const ce = (e, n) => {
151
+ const { name: t, id: s, width: a, height: o, unit: r } = e, { fixedHeight: i } = n, l = `${a}${r}`, p = `${o}${r}`;
151
152
  return {
152
153
  id: s || t.toLowerCase().replace(/\s/g, "-"),
153
- name: `${t} (${p} x ${g})`,
154
+ name: `${t} (${l} x ${p})`,
154
155
  sizeH: o,
155
156
  sizeW: a,
156
- sizeUnit: i,
157
+ sizeUnit: r,
157
158
  widthMedia: "",
158
- width: p,
159
- minHeight: r ? "0" : `${L(o, i)}px`,
160
- height: r ? g : void 0
159
+ width: l,
160
+ minHeight: i ? "0" : `${D(o, r)}px`,
161
+ height: i ? p : void 0
161
162
  };
162
- }, $ = "page-breaks", R = "gjs-page-breaks-spot", S = (e) => e.type === $;
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(), r = i == null ? void 0 : i.getEl(), p = [];
165
- if (!i || !r)
166
- return p;
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
- let d = 0;
169
- for (; d < g; ) {
170
- const f = u.find((m) => m.top > d && m.top < d + o);
171
- f ? (d = f.top + f.height, p.push(f.top)) : (d += o, d < g && p.push(d));
163
+ }, H = "page-breaks", $ = "gjs-page-breaks-spot", j = (e) => e.type === H;
164
+ function le(e) {
165
+ const { Devices: n } = e, { height: t, minHeight: s } = n.getSelected().attributes, o = parseFloat(`${t && t !== "auto" ? t : s}`), r = e.getWrapper(), i = r == null ? void 0 : r.getEl(), l = [];
166
+ if (!r || !i)
167
+ return l;
168
+ const p = i.getBoundingClientRect().height, g = r.findType(A).map((f) => f.getEl()).filter(Boolean).map((f) => ({ top: f.offsetTop, height: f.offsetHeight }));
169
+ let u = 0;
170
+ for (; u < p; ) {
171
+ const f = g.find((y) => y.top > u && y.top < u + o);
172
+ f ? (u = f.top + f.height, l.push(f.top)) : (u += o, u < p && l.push(u));
172
173
  }
173
- return p;
174
+ return l;
174
175
  }
175
- function ae(e, n) {
176
+ function pe(e, n) {
176
177
  const { Canvas: t } = e, s = t.events, a = e.events;
177
178
  let o;
178
- const i = () => {
179
- F(
180
- `${I}preset-printable-spots`,
181
- `.${R} {
179
+ const r = () => {
180
+ K(
181
+ `${C}preset-printable-spots`,
182
+ `.${$} {
182
183
  position: absolute;
183
184
  left: 0;
184
185
  width: 100%;
185
186
  border-top: 1px dashed var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue));
187
+ color: var(--gs-theme-cl-prm-txt, var(--gjs-font-color));
186
188
  }
187
- .${R}::after {
189
+ .${$}::after {
188
190
  background-color: var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight));
189
191
  content: attr(data-page-number);
190
192
  display: block;
@@ -198,83 +200,87 @@ function ae(e, n) {
198
200
  `,
199
201
  { target: window.document.head }
200
202
  );
201
- }, r = () => {
203
+ }, i = () => {
202
204
  if (n.enablePageBreaksSpot === !1) return;
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);
205
+ const c = { id: H, type: H, component: e.getWrapper() };
206
+ return t.getSpots(c).pop() || t.addSpot(c);
207
+ }, l = ({ spot: c }) => {
208
+ const { spotEl: h } = c.attributes;
209
+ !j(c) || !h || !o || o.removeChild(h);
210
+ }, p = ({ spot: c }) => {
211
+ if (!j(c) || !o) return;
212
+ let { spotEl: h } = c.attributes;
213
+ h || (h = document.createElement("div"), h.className = `${$}__items`, c.set({ spotEl: h })), o.appendChild(h);
214
+ }, d = ({ spot: c }) => {
215
+ const { spotEl: h, pageBreaks: x = [] } = c.attributes;
216
+ !j(c) || !h || !o || (Object.entries(c.getStyle()).forEach(([k, R]) => h.style.setProperty(k, R)), h.innerHTML = "", x.forEach((k, R) => {
217
+ const T = document.createElement("div");
218
+ T.setAttribute("data-page-number", `${R + 2}`), T.className = $, T.style.top = `${k}px`, h.appendChild(T);
217
219
  }));
218
- }, u = _(() => {
220
+ }, g = I(() => {
219
221
  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 = [
225
- ["component:input", u],
226
- [a.update, u],
227
- [s.spotAdd, g],
228
- [s.spotUpdate, c],
229
- [s.spotRemove, p],
222
+ const c = i();
223
+ c && c.set({ pageBreaks: le(e), up: (c.attributes.up || 0) + 1 });
224
+ }, 150), u = I(g, 200), f = () => {
225
+ o = t.getSpotsEl(), i();
226
+ }, y = () => {
227
+ const c = i();
228
+ c && c.set({ up: (c.attributes.up || 0) + 1 });
229
+ }, w = [
230
+ ["component:input", g],
231
+ ["frame:scroll", y],
232
+ [a.update, g],
233
+ [s.spotAdd, p],
234
+ [s.spotUpdate, d],
235
+ [s.spotRemove, l],
230
236
  [s.frameLoadBody, f]
231
237
  ];
232
- return m.forEach(([l, v]) => e.on(l, v)), e.onReady(() => {
233
- i(), new ResizeObserver(d).observe(t.getElement().parentElement);
238
+ return w.forEach(([c, h]) => e.on(c, h)), e.onReady(() => {
239
+ r(), new ResizeObserver(y).observe(t.getElement().parentElement);
234
240
  }), () => {
235
- m.forEach(([l, v]) => e.off(l, v)), u.clear(), d.clear();
241
+ w.forEach(([c, h]) => e.off(c, h)), g.clear(), u.clear();
236
242
  };
237
243
  }
238
- var D = /* @__PURE__ */ ((e) => (e.print = "presetPrintable:print", e))(D || {});
239
- const M = (e) => new Promise((n) => {
244
+ var _ = /* @__PURE__ */ ((e) => (e.print = "presetPrintable:print", e))(_ || {});
245
+ const F = (e) => new Promise((n) => {
240
246
  const t = document.createElement("iframe");
241
247
  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);
242
248
  });
243
- function ie(e, n) {
249
+ function de(e, n) {
244
250
  const { Commands: t, Pages: s } = e;
245
251
  return t.add(
246
- D.print,
247
- async (a, o, i = {}) => {
248
- const r = {
249
- page: i.allPages ? void 0 : s.getSelected(),
252
+ _.print,
253
+ async (a, o, r = {}) => {
254
+ const i = {
255
+ page: r.allPages ? void 0 : s.getSelected(),
250
256
  styles: "inline",
251
257
  optionsHtml: {
252
258
  // Avoid DataSource exporter
253
259
  exporter: null
254
260
  }
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 = [];
256
- if (i.separatePrints)
257
- for (const d of g)
258
- u.push(await M(d));
261
+ }, p = (await t.run(z.projectFiles, i)).filter((u) => u.filename.endsWith(".html")), d = p.map((u) => u.content).join('<div style="break-before: page;"></div>'), g = [];
262
+ if (r.separatePrints)
263
+ for (const u of p)
264
+ g.push(await F(u));
259
265
  else
260
- u.push(await M({ content: c, filename: "", mimeType: "" }));
261
- for (const d of u) {
262
- const f = d.contentWindow;
266
+ g.push(await F({ content: d, filename: "", mimeType: "" }));
267
+ for (const u of g) {
268
+ const f = u.contentWindow;
263
269
  f.focus(), f.print();
264
270
  }
265
- setTimeout(() => u.forEach((d) => d.remove()), 1e3);
271
+ setTimeout(() => g.forEach((u) => u.remove()), 1e3);
266
272
  }
267
273
  ), t.add("presetPrintable:exp", async (a) => {
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");
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() });
274
+ await M("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"), await M("https://cdn.jsdelivr.net/npm/jspdf@3.0.0/dist/jspdf.umd.min.js");
275
+ const { Devices: o, Canvas: r } = a, { sizeW: i, sizeH: l, sizeUnit: p } = o.getSelected().attributes, d = r.getFrameEl().contentDocument, g = "px", u = [D(i, p), D(l, p)], f = new window.jspdf.jsPDF({ unit: g, format: u }), y = d.body;
276
+ f.html(y, { callback: (w) => w.save() });
271
277
  }), () => {
272
- delete e.Commands.commands[D.print];
278
+ delete e.Commands.commands[_.print];
273
279
  };
274
280
  }
275
- function re(e, n) {
276
- const { blockPageBreak: t = {} } = n, { Components: s, Blocks: a } = e, o = "Page Break", i = `${se}${P}`;
277
- return s.addType(P, {
281
+ function ge(e, n) {
282
+ const { blockPageBreak: t = {} } = n, { Components: s, Blocks: a } = e, o = "Page Break", r = `${ie}${A}`;
283
+ return s.addType(A, {
278
284
  block: t && {
279
285
  label: o,
280
286
  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>',
@@ -282,59 +288,60 @@ function re(e, n) {
282
288
  select: !0,
283
289
  ...t
284
290
  },
285
- isComponent: ee(P),
291
+ isComponent: ae(A),
286
292
  model: {
287
293
  defaults: {
288
294
  name: o,
289
- classes: i,
290
- attributes: { [W]: P },
295
+ classes: r,
296
+ attributes: { [q]: A },
291
297
  emptyState: !0,
292
298
  stylable: !1,
293
299
  droppable: !1,
294
- draggable: te("wrapper"),
295
- styles: `.${i} { break-before: page; }`,
300
+ draggable: re("wrapper"),
301
+ styles: `.${r} { break-before: page; }`,
296
302
  traits: []
297
303
  }
298
304
  }
299
305
  }), () => {
300
- s.removeType(P), a.remove(P);
306
+ s.removeType(A), a.remove(A);
301
307
  };
302
308
  }
303
- const ce = "presetPrintable", le = function(e, n = {}) {
309
+ const ue = "presetPrintable", he = B.free, fe = function(e, n = {}) {
310
+ var U;
304
311
  const t = {
305
- selectedDevice: "a4",
312
+ selectedDevice: m.A4,
306
313
  ...n
307
- }, { Canvas: s, Devices: a } = e, o = s.events, i = e.events, r = t.selectedDevice || a.getConfig().default, g = [
308
- { name: "A5", width: 148, height: 210, unit: "mm" },
309
- { name: "A5 Portrait", width: 210, height: 148, unit: "mm" },
310
- { name: "A4", width: 210, height: 297, unit: "mm" },
311
- { name: "A3", width: 297, height: 420, unit: "mm" },
312
- { name: "B5", width: 176, height: 250, unit: "mm" },
313
- { name: "B4", width: 250, height: 353, unit: "mm" },
314
- { name: "Letter", width: 8.5, height: 11, unit: "in" },
315
- { name: "Legal", width: 8.5, height: 14, unit: "in" },
316
- { name: "Ledger", width: 11, height: 17, unit: "in" }
317
- ].map((b) => ne(b, t));
314
+ }, { Canvas: s, Devices: a, Blocks: o } = e, r = s.events, i = e.events, l = t.selectedDevice || a.getConfig().default, p = [
315
+ { id: m.A5, name: "A5", width: 148, height: 210, unit: "mm" },
316
+ { id: m.A5Portrait, name: "A5 Portrait", width: 210, height: 148, unit: "mm" },
317
+ { id: m.A4, name: "A4", width: 210, height: 297, unit: "mm" },
318
+ { id: m.A3, name: "A3", width: 297, height: 420, unit: "mm" },
319
+ { id: m.B5, name: "B5", width: 176, height: 250, unit: "mm" },
320
+ { id: m.B4, name: "B4", width: 250, height: 353, unit: "mm" },
321
+ { id: m.letter, name: "Letter", width: 8.5, height: 11, unit: "in" },
322
+ { id: m.legal, name: "Legal", width: 8.5, height: 14, unit: "in" },
323
+ { id: m.ledger, name: "Ledger", width: 11, height: 17, unit: "in" }
324
+ ], g = (((U = t.devices) == null ? void 0 : U.call(t, { items: p })) || p).map((v) => ce(v, t));
318
325
  a.devices.reset(g);
319
- const c = r && a.get(r) || a.getAll().at(0);
320
- a.select(c);
321
- const u = () => {
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(
326
+ const u = l && a.get(l) || a.getAll().at(0);
327
+ a.select(u), ["map", "video"].forEach((v) => o.remove(v));
328
+ const y = () => {
329
+ const v = "page-rule", { rules: b } = e.Css, { width: E, height: P, minHeight: L } = a.getSelected().attributes, S = P && P !== "auto" ? P : L;
330
+ (b.where({ id: v }).pop() || b.add(
324
331
  {
325
- id: b,
332
+ id: v,
326
333
  selectors: [],
327
334
  selectorsAdd: "@page"
328
335
  },
329
336
  { at: 0 }
330
337
  )).setStyle({
331
- size: `${w} ${B}`,
338
+ size: `${E} ${S}`,
332
339
  margin: "0"
333
340
  });
334
- }, d = (b) => {
335
- const h = b.document, { minHeight: w } = a.getSelected().attributes, k = `
336
- ${!!parseFloat(`${w}`) ? `
337
- [data-gjs-type="wrapper"] { min-height: ${w}; }
341
+ }, w = (v) => {
342
+ const b = v.document, { minHeight: E } = a.getSelected().attributes, L = `
343
+ ${!!parseFloat(`${E}`) ? `
344
+ [data-gjs-type="wrapper"] { min-height: ${E}; }
338
345
  ` : `
339
346
  body {
340
347
  overflow: hidden;
@@ -346,48 +353,48 @@ const ce = "presetPrintable", le = function(e, n = {}) {
346
353
  }
347
354
  `}
348
355
  `;
349
- F(`${I}preset-printable`, k, { doc: h, target: h.head }), u();
356
+ K(`${C}preset-printable`, L, { doc: b, target: b.head }), y();
350
357
  };
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) => {
356
- const B = k.target;
357
- B.scrollTop > 0 && B.scrollTo(0, 0);
358
+ e.on(r.frameLoadBody, (v) => {
359
+ const b = v.window;
360
+ if (w(b), t.fixedHeight) {
361
+ const P = v.model.getComponent().getEl();
362
+ P == null || P.addEventListener("scroll", (L) => {
363
+ const S = L.target;
364
+ S.scrollTop > 0 && S.scrollTo(0, 0);
358
365
  });
359
366
  }
360
367
  }), e.on(a.events.select, () => {
361
- var h;
362
- const b = (h = s.getFrameEl().contentDocument) == null ? void 0 : h.defaultView;
363
- b && d(b);
368
+ var b;
369
+ const v = (b = s.getFrameEl().contentDocument) == null ? void 0 : b.defaultView;
370
+ v && w(v);
364
371
  });
365
- const f = () => {
366
- const h = e.Css.getRules().filter((w) => w.selectorsToString() === "body").pop();
367
- h == null || h.addStyle({
372
+ const c = () => {
373
+ const b = e.Css.getRules().filter((E) => E.selectorsToString() === "body").pop();
374
+ b == null || b.addStyle({
368
375
  "margin-top": "",
369
376
  "margin-right": "",
370
377
  "margin-bottom": "",
371
378
  "margin-left": "",
372
379
  margin: "0"
373
380
  });
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);
381
+ }, h = [[i.projectLoad, c]];
382
+ h.forEach(([v, b]) => e.on(v, b));
383
+ const x = pe(e, t), k = de(e), R = ge(e, t);
377
384
  e.onReady(() => {
378
385
  e.UndoManager.clear();
379
386
  });
380
387
  const T = () => {
381
- m.forEach(([b, h]) => e.off(b, h)), l(), v(), A();
388
+ h.forEach(([v, b]) => e.off(v, b)), x(), k(), R();
382
389
  };
383
- e.on(i.destroy, T), Z({
390
+ e.on(i.destroy, T), ne({
384
391
  editor: e,
385
392
  licenseKey: t.licenseKey,
386
- plan: E.startup,
387
- pluginName: ce,
393
+ plan: he,
394
+ pluginName: ue,
388
395
  cleanup: T
389
396
  });
390
- }, ge = X(le);
397
+ }, be = se(fe);
391
398
  export {
392
- ge as default
399
+ be as default
393
400
  };