@grapesjs/studio-sdk-plugins 1.0.27 → 1.0.28-rc.1

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 q = "app.grapesjs.com", K = "app-stage.grapesjs.com", U = [
1
+ const q = "app.grapesjs.com", H = "app-stage.grapesjs.com", B = [
2
2
  q,
3
- K,
3
+ H,
4
4
  "localhost",
5
5
  "127.0.0.1",
6
6
  ".local-credentialless.webcontainer.io",
@@ -9,14 +9,14 @@ const q = "app.grapesjs.com", K = "app-stage.grapesjs.com", U = [
9
9
  // For stackblitz.com demos
10
10
  "-sandpack.codesandbox.io"
11
11
  // For Sandpack demos
12
- ], st = "license:check:start", at = "license:check:end", it = () => typeof window < "u", lt = ({ isDev: t, isStage: e }) => `${t ? "" : `https://${e ? K : q}`}/api`, ct = () => {
13
- const t = it() && window.location.hostname;
14
- return !!t && (U.includes(t) || U.some((e) => t.endsWith(e)));
12
+ ], ot = "license:check:start", rt = "license:check:end", st = () => typeof window < "u", at = ({ isDev: t, isStage: e }) => `${t ? "" : `https://${e ? H : q}`}/api`, it = () => {
13
+ const t = st() && window.location.hostname;
14
+ return !!t && (B.includes(t) || B.some((e) => t.endsWith(e)));
15
15
  };
16
- function J(t) {
16
+ function Y(t) {
17
17
  return typeof t == "function";
18
18
  }
19
- async function pt({
19
+ async function lt({
20
20
  path: t,
21
21
  baseApiUrl: e,
22
22
  method: r = "GET",
@@ -24,7 +24,7 @@ async function pt({
24
24
  params: n,
25
25
  body: i
26
26
  }) {
27
- const l = `${e || lt({ isDev: !1, isStage: !1 })}${t}`, c = {
27
+ const l = `${e || at({ isDev: !1, isStage: !1 })}${t}`, c = {
28
28
  method: r,
29
29
  headers: {
30
30
  "Content-Type": "application/json",
@@ -37,19 +37,19 @@ async function pt({
37
37
  throw new Error(`HTTP error! status: ${d.status}`);
38
38
  return d.json();
39
39
  }
40
- var M = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(M || {});
41
- const j = {
42
- [M.free]: 0,
43
- [M.startup]: 10,
44
- [M.business]: 20,
45
- [M.enterprise]: 30
40
+ var R = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(R || {});
41
+ const O = {
42
+ [R.free]: 0,
43
+ [R.startup]: 10,
44
+ [R.business]: 20,
45
+ [R.enterprise]: 30
46
46
  };
47
- function dt(t) {
47
+ function ct(t) {
48
48
  const e = t;
49
49
  return e.init = (r) => (o) => t(o, r), e;
50
50
  }
51
- const ut = (t) => /* @__PURE__ */ dt(t);
52
- async function gt({
51
+ const pt = (t) => /* @__PURE__ */ ct(t);
52
+ async function dt({
53
53
  editor: t,
54
54
  plan: e,
55
55
  pluginName: r,
@@ -57,37 +57,37 @@ async function gt({
57
57
  cleanup: n
58
58
  }) {
59
59
  let i = "", s = !1;
60
- const l = ct(), c = (a) => {
60
+ const l = it(), c = (a) => {
61
61
  console.warn("Cleanup plugin:", r, "Reason:", a), n();
62
62
  }, p = (a = {}) => {
63
- var S;
64
- const { error: d, sdkLicense: u } = a, g = (S = a.plan) == null ? void 0 : S.category;
63
+ var g;
64
+ const { error: d, sdkLicense: u } = a, m = (g = a.plan) == null ? void 0 : g.category;
65
65
  if (!(u || a.license) || d)
66
66
  c(d || "Invalid license");
67
- else if (g) {
68
- const f = j[e], b = j[g];
69
- f > b && c({ pluginRequiredPlan: e, licensePlan: g });
67
+ else if (m) {
68
+ const w = O[e], b = O[m];
69
+ w > b && c({ pluginRequiredPlan: e, licensePlan: m });
70
70
  }
71
71
  };
72
- t.on(st, (a) => {
72
+ t.on(ot, (a) => {
73
73
  i = a == null ? void 0 : a.baseApiUrl, s = !0;
74
- }), t.on(at, (a) => {
74
+ }), t.on(rt, (a) => {
75
75
  p(a);
76
76
  }), setTimeout(async () => {
77
77
  if (!s) {
78
78
  if (l) return;
79
79
  if (o) {
80
- const a = await mt({ licenseKey: o, pluginName: r, baseApiUrl: i });
80
+ const a = await ut({ licenseKey: o, pluginName: r, baseApiUrl: i });
81
81
  a && p(a);
82
82
  } else
83
83
  c("The `licenseKey` option not provided");
84
84
  }
85
85
  }, 2e3);
86
86
  }
87
- async function mt(t) {
87
+ async function ut(t) {
88
88
  const { licenseKey: e, pluginName: r, baseApiUrl: o } = t;
89
89
  try {
90
- return (await pt({
90
+ return (await lt({
91
91
  baseApiUrl: o,
92
92
  path: `/sdk/${e || "na"}`,
93
93
  method: "POST",
@@ -100,10 +100,10 @@ async function mt(t) {
100
100
  return console.error("Error during SDK license check:", n), !1;
101
101
  }
102
102
  }
103
- const W = "canvasGridMode", ft = M.startup, F = "component-grid-mode", _ = "grid-mode", L = "gjs-drag-grid-spot", Q = `${L}__grid-item`, Z = `${L}__grid-target`, V = `${L}__snapped`, yt = `${L}__container`, ht = () => {
103
+ const L = "canvasGridMode", mt = R.startup, N = "component-grid-mode", A = "grid-mode", D = "gjs-drag-grid-spot", K = `${D}__grid-item`, X = `${D}__grid-target`, J = `${D}__snapped`, gt = `${D}__container`, ft = () => {
104
104
  const t = "data-gjs-drag-grid-style", e = document, r = "var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight))", o = "var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue))", n = e.querySelector(`style[${t}]`) || e.createElement("style");
105
105
  n.setAttribute(t, "true"), n.innerHTML = `
106
- .${Q} {
106
+ .${K} {
107
107
  outline: 2px solid ${o};
108
108
  background: ${r};
109
109
  outline-offset: -2px;
@@ -112,14 +112,14 @@ const W = "canvasGridMode", ft = M.startup, F = "component-grid-mode", _ = "grid
112
112
  height: 100%;
113
113
  opacity: 0.1;
114
114
  }
115
- .${V} {
115
+ .${J} {
116
116
  width: 100%;
117
117
  height: 100%;
118
118
  outline: 2px solid ${o};
119
119
  outline-offset: -2px;
120
120
  position: absolute;
121
121
  }
122
- .${Z} {
122
+ .${X} {
123
123
  position: absolute;
124
124
  z-index: -1;
125
125
  background: ${r};
@@ -129,29 +129,29 @@ const W = "canvasGridMode", ft = M.startup, F = "component-grid-mode", _ = "grid
129
129
  }
130
130
  `, e.head.appendChild(n);
131
131
  };
132
- function tt(t) {
133
- const { editor: e, type: r } = t, o = $t(e, t.component), n = B(e, o.component);
134
- if (!vt(e, o, n, r))
132
+ function Q(t) {
133
+ const { editor: e, type: r } = t, o = bt(e, t.component), n = z(e, o.component);
134
+ if (!Ct(e, o, n, r))
135
135
  return {
136
136
  target: o,
137
137
  container: n,
138
- startScroll: O(e).scroll,
138
+ startScroll: et(e).scroll,
139
139
  shadowContainerEl: document.createElement("div"),
140
140
  shadowSnappedEl: document.createElement("div"),
141
141
  shadowTargetEl: document.createElement("div"),
142
142
  spot: e.Canvas.addSpot({
143
- type: _,
143
+ type: A,
144
144
  component: n.component
145
145
  })
146
146
  };
147
147
  }
148
- function et(t) {
148
+ function Z(t) {
149
149
  const { editor: e, shadowTargetEl: r, shadowSnappedEl: o, shadowContainerEl: n, spotEl: i, target: s, container: l } = t, { Canvas: c } = e, p = e.config.stylePrefix;
150
- i == null || i.appendChild(n), n == null || n.appendChild(r), n == null || n.appendChild(o), wt(n, l), St(r, s, l), bt(o, s), Ct(n, l.el), s.el.style.opacity = "0";
151
- const a = c.getSpots().filter((d) => d.type !== _);
150
+ i == null || i.appendChild(n), n == null || n.appendChild(r), n == null || n.appendChild(o), yt(n, l), ht(r, s, l), wt(o, s), St(n, l.el), s.el.style.opacity = "0";
151
+ const a = c.getSpots().filter((d) => d.type !== A);
152
152
  e.em.stopDefault({ preserveSelected: !0 }), c.removeSpots(a), c.startAutoscroll(), c.getBody().classList.add(`${p}is__grabbing`);
153
153
  }
154
- function nt(t) {
154
+ function V(t) {
155
155
  const { editor: e, shadowSnappedEl: r, shadowContainerEl: o, target: n, cancelled: i } = t, { Canvas: s } = e, l = e.config.stylePrefix, { component: c } = n;
156
156
  if (!i) {
157
157
  const p = window.getComputedStyle(r);
@@ -161,9 +161,9 @@ function nt(t) {
161
161
  height: ""
162
162
  });
163
163
  }
164
- n.el.style.opacity = "", o.contains(r) && (o == null || o.removeChild(r)), e.getModel().runDefault({ preserveSelected: 1 }), s.stopAutoscroll(), s.getBody().classList.remove(`${l}is__grabbing`), s.removeSpots({ type: _ }), e.select(c);
164
+ n.el.style.opacity = "", o.contains(r) && (o == null || o.removeChild(r)), e.getModel().runDefault({ preserveSelected: 1 }), s.stopAutoscroll(), s.getBody().classList.remove(`${l}is__grabbing`), s.removeSpots({ type: A }), e.select(c);
165
165
  }
166
- function wt(t, {
166
+ function yt(t, {
167
167
  rows: e,
168
168
  columns: r
169
169
  }) {
@@ -172,31 +172,31 @@ function wt(t, {
172
172
  o[n] = [];
173
173
  for (let i = 0; i < e.length; i++) {
174
174
  const s = document.createElement("div");
175
- s.className = Q, s.style.gridArea = `${i + 1} / ${n + 1}`, o[n][i] = s, t.appendChild(s);
175
+ s.className = K, s.style.gridArea = `${i + 1} / ${n + 1}`, o[n][i] = s, t.appendChild(s);
176
176
  }
177
177
  }
178
178
  return o;
179
179
  }
180
- function St(t, e, r) {
181
- return t.className = Z, t.style.top = `${e.offset.top - r.offset.top}px`, t.style.left = `${e.offset.left - r.offset.left}px`, t.style.width = `${e.offset.width + e.margin.left + e.margin.right}px`, t.style.height = `${e.offset.height + e.margin.top + e.margin.bottom}px`, t;
180
+ function ht(t, e, r) {
181
+ return t.className = X, t.style.top = `${e.offset.top - r.offset.top}px`, t.style.left = `${e.offset.left - r.offset.left}px`, t.style.width = `${e.offset.width + e.margin.left + e.margin.right}px`, t.style.height = `${e.offset.height + e.margin.top + e.margin.bottom}px`, t;
182
182
  }
183
- function bt(t, e) {
184
- const r = rt(e.el, e.computedStyles);
185
- return t.className = V, t.style.gridArea = `${r.row.start} / ${r.column.start} / ${r.row.end} / ${r.column.end}`, t;
183
+ function wt(t, e) {
184
+ const r = nt(e.el, e.computedStyles);
185
+ return t.className = J, t.style.gridArea = `${r.row.start} / ${r.column.start} / ${r.row.end} / ${r.column.end}`, t;
186
186
  }
187
- function Ct(t, e) {
187
+ function St(t, e) {
188
188
  const r = window.getComputedStyle(e);
189
- t.className = yt, t.style.position = "relative", t.style.display = r.display, t.style.gap = r.gap, t.style.padding = r.padding, t.style.border = r.border, t.style.gridTemplateColumns = r.gridTemplateColumns, t.style.gridTemplateRows = r.gridTemplateRows;
189
+ t.className = gt, t.style.position = "relative", t.style.display = r.display, t.style.gap = r.gap, t.style.padding = r.padding, t.style.border = r.border, t.style.gridTemplateColumns = r.gridTemplateColumns, t.style.gridTemplateRows = r.gridTemplateRows;
190
190
  }
191
- function ot(t, e) {
191
+ function tt(t, e) {
192
192
  if (e) {
193
193
  if (Array.isArray(e))
194
194
  return [...e].pop();
195
195
  } else return [...t.getSelectedAll()].pop();
196
196
  return e;
197
197
  }
198
- function $t(t, e) {
199
- const r = ot(t, e), o = r.getEl(), n = window.getComputedStyle(o);
198
+ function bt(t, e) {
199
+ const r = tt(t, e), o = r.getEl(), n = window.getComputedStyle(o);
200
200
  return {
201
201
  component: r,
202
202
  el: o,
@@ -210,7 +210,7 @@ function $t(t, e) {
210
210
  computedStyles: n
211
211
  };
212
212
  }
213
- function B(t, e) {
213
+ function z(t, e) {
214
214
  const r = e.parent(), o = r.getEl(), n = window.getComputedStyle(o);
215
215
  return {
216
216
  component: r,
@@ -231,7 +231,7 @@ function B(t, e) {
231
231
  }
232
232
  };
233
233
  }
234
- function P(t, e, r, o, n = 1) {
234
+ function E(t, e, r, o, n = 1) {
235
235
  let i = 0;
236
236
  for (let s = e; s <= t.length; s++) {
237
237
  if (i + (t[s - 1] + o) * n > r)
@@ -240,7 +240,7 @@ function P(t, e, r, o, n = 1) {
240
240
  }
241
241
  return t.length + 1;
242
242
  }
243
- function O(t) {
243
+ function et(t) {
244
244
  const { scrollY: e, scrollX: r } = t.Canvas.getWindow();
245
245
  return {
246
246
  scroll: {
@@ -249,20 +249,20 @@ function O(t) {
249
249
  }
250
250
  };
251
251
  }
252
- function vt(t, e, r, o) {
252
+ function Ct(t, e, r, o) {
253
253
  const n = (i) => t.em.logWarning(i);
254
- return o === "draggable" && e.component.get(o) === !1 ? (n(`[${W}] The element is not ${o}`), !0) : r.computedStyles.display !== "grid" ? (n(`[${W}] The container does not have style display:grid`), !0) : !1;
254
+ return o === "draggable" && e.component.get(o) === !1 ? (n(`[${L}] The element is not ${o}`), !0) : r.computedStyles.display !== "grid" ? (n(`[${L}] The container does not have style display:grid`), !0) : !1;
255
255
  }
256
- function N(t, e, r = {}) {
257
- const o = ot(t, e), n = o == null ? void 0 : o.parent(), i = n == null ? void 0 : n.getEl();
256
+ function _(t, e, r = {}) {
257
+ const o = tt(t, e), n = o == null ? void 0 : o.parent(), i = n == null ? void 0 : n.getEl();
258
258
  if (!n || !i)
259
259
  return !1;
260
260
  const { enableGrid: s } = r, l = window.getComputedStyle(i).display === "grid";
261
- return J(s) ? s({ component: o, parent: n, isParentGrid: l }) : l;
261
+ return Y(s) ? s({ component: o, parent: n, isParentGrid: l }) : l;
262
262
  }
263
- const Y = (t) => t.split(" ").map((e) => parseFloat(e));
264
- function rt(t, e) {
265
- const r = t.ownerDocument.defaultView, o = e || r.getComputedStyle(t), n = o.gridArea.split("/").some((w) => isNaN(parseInt(w.trim()))), i = {
263
+ const k = (t) => t.split(" ").map((e) => parseFloat(e));
264
+ function nt(t, e) {
265
+ const r = t.ownerDocument.defaultView, o = e || r.getComputedStyle(t), n = o.gridArea.split("/").some((S) => isNaN(parseInt(S.trim()))), i = {
266
266
  isComputed: n,
267
267
  raw: o.gridArea
268
268
  };
@@ -278,21 +278,21 @@ function rt(t, e) {
278
278
  end: parseInt(o.gridColumnEnd)
279
279
  }
280
280
  };
281
- const s = t.parentElement, l = r.getComputedStyle(s), c = parseFloat(l.columnGap) || 0, p = parseFloat(l.rowGap) || 0, a = Y(l.gridTemplateColumns), d = Y(l.gridTemplateRows), u = parseFloat(l.paddingLeft) || 0, g = parseFloat(l.paddingTop) || 0, h = s.getBoundingClientRect(), S = t.getBoundingClientRect(), f = (w, C, T, R, A) => {
282
- let x = 1, E = R + A;
283
- for (let G = 0; G < C.length; G++) {
284
- const D = C[G], I = E + D;
285
- if (w >= E && w < I)
286
- return x;
287
- E = I + T, x++;
281
+ const s = t.parentElement, l = r.getComputedStyle(s), c = parseFloat(l.columnGap) || 0, p = parseFloat(l.rowGap) || 0, a = k(l.gridTemplateColumns), d = k(l.gridTemplateRows), u = parseFloat(l.paddingLeft) || 0, m = parseFloat(l.paddingTop) || 0, h = s.getBoundingClientRect(), g = t.getBoundingClientRect(), w = (S, C, x, $, M) => {
282
+ let G = 1, T = $ + M;
283
+ for (let P = 0; P < C.length; P++) {
284
+ const I = C[P], W = T + I;
285
+ if (S >= T && S < W)
286
+ return G;
287
+ T = W + x, G++;
288
288
  }
289
289
  return -1;
290
- }, b = f(S.left, a, c, h.left, u), v = f(S.right - 1, a, c, h.left, u) + 1, m = f(S.top, d, p, h.top, g), y = f(S.bottom - 1, d, p, h.top, g) + 1;
290
+ }, b = w(g.left, a, c, h.left, u), v = w(g.right - 1, a, c, h.left, u) + 1, y = w(g.top, d, p, h.top, m), f = w(g.bottom - 1, d, p, h.top, m) + 1;
291
291
  return {
292
292
  ...i,
293
293
  row: {
294
- start: m,
295
- end: y
294
+ start: y,
295
+ end: f
296
296
  },
297
297
  column: {
298
298
  start: b,
@@ -300,12 +300,12 @@ function rt(t, e) {
300
300
  }
301
301
  };
302
302
  }
303
- function Et(t) {
304
- t.Commands.add(F, {
303
+ function $t(t) {
304
+ t.Commands.add(N, {
305
305
  stop() {
306
306
  },
307
307
  run(e, r, o = {}) {
308
- const n = tt({ editor: e, component: o.target, type: "draggable" });
308
+ const n = Q({ editor: e, component: o.target, type: "draggable" });
309
309
  if (!n) {
310
310
  this.stopCommand();
311
311
  return;
@@ -316,7 +316,7 @@ function Et(t) {
316
316
  doc: s.el.ownerDocument,
317
317
  onStart: () => {
318
318
  u = setTimeout(() => {
319
- et({
319
+ Z({
320
320
  editor: e,
321
321
  shadowTargetEl: p,
322
322
  shadowSnappedEl: c,
@@ -324,39 +324,39 @@ function Et(t) {
324
324
  spotEl: i.attributes.spotEl,
325
325
  target: s,
326
326
  container: d
327
- }), d = B(e, s.component);
327
+ }), d = z(e, s.component);
328
328
  }, 10);
329
329
  },
330
- onEnd: (h, S, { cancelled: f }) => {
331
- clearTimeout(u), nt({
330
+ onEnd: (h, g, { cancelled: w }) => {
331
+ clearTimeout(u), V({
332
332
  editor: e,
333
333
  shadowSnappedEl: c,
334
334
  shadowContainerEl: l,
335
335
  target: s,
336
- cancelled: f
336
+ cancelled: w
337
337
  }), this.stopCommand(), e.em.set("_cmpDrag", 1);
338
338
  },
339
- setPosition: ({ x: h, y: S }) => {
340
- const { scroll: f } = O(e), { columns: b, rows: v, gap: m, offset: y, padding: w } = d, { offset: C, margin: T } = s, R = C.top - y.top - w.top - T.top + S - a.top + f.top, A = C.left - y.left - w.left - T.left + h - a.left + f.left, x = Math.min(P(b, 1, A, m.column, 0.5), b.length), E = Math.min(P(v, 1, R, m.row, 0.5), v.length), G = Math.min(
341
- P(b, x, C.width, m.column) + 1,
339
+ setPosition: ({ x: h, y: g }) => {
340
+ const { scroll: w } = et(e), { columns: b, rows: v, gap: y, offset: f, padding: S } = d, { offset: C, margin: x } = s, $ = C.top - f.top - S.top - x.top + g - a.top + w.top, M = C.left - f.left - S.left - x.left + h - a.left + w.left, G = Math.min(E(b, 1, M, y.column, 0.5), b.length), T = Math.min(E(v, 1, $, y.row, 0.5), v.length), P = Math.min(
341
+ E(b, G, C.width, y.column) + 1,
342
342
  b.length + 1
343
- ), D = Math.min(P(v, E, C.height, m.row) + 1, v.length + 1);
344
- c.style.gridArea = `${E} / ${x} / ${D} / ${G}`, p.style.top = `${R + w.top}px`, p.style.left = `${A + w.left}px`;
343
+ ), I = Math.min(E(v, T, C.height, y.row) + 1, v.length + 1);
344
+ c.style.gridArea = `${T} / ${G} / ${I} / ${P}`, p.style.top = `${$ + S.top}px`, p.style.left = `${M + S.left}px`;
345
345
  }
346
346
  }).start(o.event);
347
347
  }
348
348
  });
349
349
  }
350
- function xt(t, e) {
351
- const r = tt({ editor: t, component: e.target, type: "resizable" });
350
+ function vt(t, e) {
351
+ const r = Q({ editor: t, component: e.component, type: "resizable" });
352
352
  if (!r)
353
353
  return;
354
354
  const { onMove: o, onEnd: n } = e.options || {}, { spot: i, target: s, shadowContainerEl: l, shadowSnappedEl: c, shadowTargetEl: p } = r;
355
355
  let { container: a } = r, d = "", u;
356
356
  return {
357
- onStart: (g) => {
358
- d = g.target.dataset.gjsHandler || "", u = setTimeout(() => {
359
- et({
357
+ onStart: (m) => {
358
+ d = m.target.dataset.gjsHandler || "", u = setTimeout(() => {
359
+ Z({
360
360
  editor: t,
361
361
  shadowTargetEl: p,
362
362
  shadowSnappedEl: c,
@@ -364,64 +364,58 @@ function xt(t, e) {
364
364
  spotEl: i.attributes.spotEl,
365
365
  target: s,
366
366
  container: a
367
- }), a = B(t, s.component);
367
+ }), a = z(t, s.component);
368
368
  }, 10), t.trigger("component:resize", { ...s, type: "start" });
369
369
  },
370
- onEnd: (g, h) => {
371
- const { startDim: S, rectDim: f } = h.resizer, b = JSON.stringify(S) === JSON.stringify(f);
372
- clearTimeout(u), nt({ editor: t, shadowSnappedEl: c, shadowContainerEl: l, target: s, cancelled: b }), n == null || n(g, h);
370
+ onEnd: (m, h) => {
371
+ const { startDim: g, rectDim: w } = h.resizer, b = JSON.stringify(g) === JSON.stringify(w);
372
+ clearTimeout(u), V({ editor: t, shadowSnappedEl: c, shadowContainerEl: l, target: s, cancelled: b }), n == null || n(m, h);
373
373
  },
374
- onMove: (g) => {
375
- var k;
376
- const h = g;
377
- if (((k = h.target) == null ? void 0 : k.nodeName) === "I")
378
- return;
379
- const { scroll: S } = O(t), f = rt(c);
380
- let b = 0, v = 0, m = 0, y = 0;
381
- const w = s.margin.left, C = s.margin.top, T = s.margin.bottom, R = s.margin.right, { width: A, top: x, left: E, height: G } = s.offset, D = h.clientX, I = h.clientY, $ = {
382
- t: x - C,
383
- l: E - w,
384
- h: G + C + T,
385
- w: A + w + R
374
+ onMove: (m, h) => {
375
+ const g = nt(c), w = s.margin.left, b = s.margin.top, v = s.margin.bottom, y = s.margin.right, { w: f, t: S, l: C, h: x } = h.resizer.rectDim, $ = {
376
+ t: S - b,
377
+ l: C - w,
378
+ h: x + b + v,
379
+ w: f + w + y
386
380
  };
387
- d.startsWith("t") ? ($.t = I - C, $.h = x + G + C + T - I) : d.startsWith("b") && ($.h = I - x + C + T), d.endsWith("l") ? ($.l = D - w, $.w = E + A + w + R - D) : d.endsWith("r") && ($.w = D - E + w + R), d.endsWith("l") && (m = S.left, f.column.start = P(
381
+ d.endsWith("l") && (g.column.start = E(
388
382
  a.columns,
389
383
  1,
390
- $.l - a.offset.left - m - a.padding.left,
384
+ $.l - a.offset.left - a.padding.left,
391
385
  a.gap.column,
392
386
  0.5
393
- )), d.startsWith("t") && (b = S.top, f.row.start = P(
387
+ )), d.startsWith("t") && (g.row.start = E(
394
388
  a.rows,
395
389
  1,
396
- $.t - a.offset.top + b - a.padding.top,
390
+ $.t - a.offset.top - a.padding.top,
397
391
  a.gap.row,
398
392
  0.5
399
- )), d.endsWith("r") && (y = S.left, f.column.end = Math.max(
400
- P(a.columns, f.column.start, $.w - y, a.gap.column, 0.5),
401
- f.column.start + 1
402
- )), d.startsWith("b") && (v = S.top, f.row.end = Math.max(
403
- P(a.rows, f.row.start, $.h + v, a.gap.row, 0.5),
404
- f.row.start + 1
405
- )), c.style.gridArea = `${f.row.start} / ${f.column.start} / ${f.row.end} / ${f.column.end}`, p.style.width = `${$.w + y + m}px`, p.style.height = `${$.h + v - b}px`, p.style.left = `${$.l - a.offset.left - m}px`, p.style.top = `${$.t - a.offset.top + b}px`, o == null || o(g);
393
+ )), d.endsWith("r") && (g.column.end = Math.max(
394
+ E(a.columns, g.column.start, $.w, a.gap.column, 0.5),
395
+ g.column.start + 1
396
+ )), d.startsWith("b") && (g.row.end = Math.max(
397
+ E(a.rows, g.row.start, $.h, a.gap.row, 0.5),
398
+ g.row.start + 1
399
+ )), c.style.gridArea = `${g.row.start} / ${g.column.start} / ${g.row.end} / ${g.column.end}`, p.style.width = `${$.w}px`, p.style.height = `${$.h}px`, p.style.left = `${$.l - a.offset.left}px`, p.style.top = `${$.t - a.offset.top}px`, o == null || o(m, h);
406
400
  }
407
401
  };
408
402
  }
409
- const H = ["px", "%", "em", "rem", "vw", "vh"], Tt = (t, e) => {
403
+ const U = ["px", "%", "em", "rem", "vw", "vh"], Et = (t, e) => {
410
404
  const r = t.Styles.getSectors().find((o) => !!o.getProperty(e));
411
405
  return {
412
406
  sector: r,
413
407
  property: r ? r.getProperty(e) : void 0
414
408
  };
415
- }, Rt = (t, e) => Tt(t, e), Gt = (t, { x: e, y: r, mergable: o } = {}) => {
409
+ }, xt = (t, e) => Et(t, e), Tt = (t, { x: e, y: r, mergable: o } = {}) => {
416
410
  const n = {
417
411
  property: `${t}-x`,
418
412
  type: "integer",
419
- units: H,
413
+ units: U,
420
414
  ...e
421
415
  }, i = {
422
416
  property: `${t}-y`,
423
417
  type: "integer",
424
- units: H,
418
+ units: U,
425
419
  ...r
426
420
  };
427
421
  return {
@@ -430,10 +424,10 @@ const H = ["px", "%", "em", "rem", "vw", "vh"], Tt = (t, e) => {
430
424
  properties: [n, i],
431
425
  ...o && {
432
426
  fromStyle(s, { name: l, separator: c, property: p }) {
433
- const [a, d] = p.getProperties(), [u, g] = (s[l] || "").split(c);
427
+ const [a, d] = p.getProperties(), [u, m] = (s[l] || "").split(c);
434
428
  return {
435
429
  [a.getId()]: s[a.getName()] || u || "",
436
- [d.getId()]: s[d.getName()] || g || u || ""
430
+ [d.getId()]: s[d.getName()] || m || u || ""
437
431
  };
438
432
  },
439
433
  toStyle(s, { name: l, property: c }) {
@@ -444,8 +438,8 @@ const H = ["px", "%", "em", "rem", "vw", "vh"], Tt = (t, e) => {
444
438
  }
445
439
  }
446
440
  };
447
- }, z = { display: ["grid"] };
448
- function Pt(t = "") {
441
+ }, F = { display: ["grid"] };
442
+ function Rt(t = "") {
449
443
  const e = /^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i, r = /^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i, o = t.match(e);
450
444
  if (!o)
451
445
  return null;
@@ -458,23 +452,23 @@ function Pt(t = "") {
458
452
  max: l
459
453
  };
460
454
  }
461
- function At(t = {}) {
455
+ function Gt(t = {}) {
462
456
  let e = "", r = "", o = "", n = "";
463
- const i = (S) => S.split("/").map((f) => f.trim()).filter(Boolean), s = t["grid-area"] || "", l = t["grid-column"] || "", c = t["grid-row"] || "", p = i(s), a = i(l), d = i(c), u = p.length, g = a.length, h = d.length;
464
- return u === 4 ? (o = p[0], e = p[1], n = p[2], r = p[3]) : u === 3 ? (o = p[0], e = p[1], n = p[2]) : u === 2 ? (o = p[0], e = p[1]) : u === 1 && (o = p[0]), g === 2 ? (e = a[0], r = a[1]) : g === 1 && (e = a[0]), h === 2 ? (o = d[0], n = d[1]) : h === 1 && (o = d[0]), {
457
+ const i = (g) => g.split("/").map((w) => w.trim()).filter(Boolean), s = t["grid-area"] || "", l = t["grid-column"] || "", c = t["grid-row"] || "", p = i(s), a = i(l), d = i(c), u = p.length, m = a.length, h = d.length;
458
+ return u === 4 ? (o = p[0], e = p[1], n = p[2], r = p[3]) : u === 3 ? (o = p[0], e = p[1], n = p[2]) : u === 2 ? (o = p[0], e = p[1]) : u === 1 && (o = p[0]), m === 2 ? (e = a[0], r = a[1]) : m === 1 && (e = a[0]), h === 2 ? (o = d[0], n = d[1]) : h === 1 && (o = d[0]), {
465
459
  columnStart: e,
466
460
  columnEnd: r,
467
461
  rowStart: o,
468
462
  rowEnd: n
469
463
  };
470
464
  }
471
- function X(t) {
465
+ function j(t) {
472
466
  const { property: e, label: r } = t, o = "1", n = "1fr";
473
467
  return {
474
468
  property: e,
475
469
  label: r,
476
470
  type: "composite",
477
- requires: z,
471
+ requires: F,
478
472
  generic: !0,
479
473
  properties: [
480
474
  {
@@ -503,34 +497,34 @@ function X(t) {
503
497
  }
504
498
  ],
505
499
  fromStyle(i, s) {
506
- const { name: l, property: c } = s, [p, a, d] = c.getProperties(), u = i[l], g = Pt(u), h = (g == null ? void 0 : g.max) ?? n;
500
+ const { name: l, property: c } = s, [p, a, d] = c.getProperties(), u = i[l], m = Rt(u), h = (m == null ? void 0 : m.max) ?? n;
507
501
  return {
508
- [p.id]: (g == null ? void 0 : g.total) ?? o,
509
- [a.id]: (g == null ? void 0 : g.min) ?? "",
502
+ [p.id]: (m == null ? void 0 : m.total) ?? o,
503
+ [a.id]: (m == null ? void 0 : m.min) ?? "",
510
504
  [d.id]: h === n ? "" : h
511
505
  };
512
506
  },
513
507
  toStyle(i, { name: s, property: l }) {
514
- const [c, p, a] = l.getProperties(), d = i[c.id], u = i[p.id], g = i[a.id] || n, h = u && g ? `minmax(${u}, ${g})` : g;
508
+ const [c, p, a] = l.getProperties(), d = i[c.id], u = i[p.id], m = i[a.id] || n, h = u && m ? `minmax(${u}, ${m})` : m;
515
509
  return {
516
510
  [s]: `repeat(${d || o}, ${h})`
517
511
  };
518
512
  }
519
513
  };
520
514
  }
521
- function Dt(t, e) {
515
+ function Pt(t, e) {
522
516
  if (!e.styleableGrid) return;
523
- const { property: r, ...o } = Rt(t, "display");
517
+ const { property: r, ...o } = xt(t, "display");
524
518
  if (!r) return;
525
519
  const n = r.getOption("grid"), i = o.sector;
526
520
  n || r.addOption({ id: "grid", label: "Grid" }), i.addProperty(
527
- X({
521
+ j({
528
522
  label: "Columns",
529
523
  property: "grid-template-columns"
530
524
  }),
531
525
  {}
532
526
  ), i.addProperty(
533
- X({
527
+ j({
534
528
  label: "Rows",
535
529
  property: "grid-template-rows"
536
530
  }),
@@ -538,8 +532,8 @@ function Dt(t, e) {
538
532
  ), i.addProperty(
539
533
  {
540
534
  id: "grid-gap",
541
- requires: z,
542
- ...Gt("gap", {
535
+ requires: F,
536
+ ...Tt("gap", {
543
537
  x: { id: "grid-row-gap", label: "Row", property: "row-gap", min: 0, default: "0" },
544
538
  y: { id: "grid-column-gap", label: "Column", property: "column-gap", min: 0, default: "0" },
545
539
  mergable: !0
@@ -551,7 +545,7 @@ function Dt(t, e) {
551
545
  type: "composite",
552
546
  property: "grid-area",
553
547
  label: "Grid area",
554
- requiresParent: z,
548
+ requiresParent: F,
555
549
  // detached: true,
556
550
  generic: !0,
557
551
  properties: [
@@ -581,7 +575,7 @@ function Dt(t, e) {
581
575
  }
582
576
  ],
583
577
  fromStyle(s) {
584
- const l = At(s);
578
+ const l = Gt(s);
585
579
  return {
586
580
  "grid-column-start": s["grid-column-start"] || l.columnStart,
587
581
  "grid-column-end": s["grid-column-end"] || l.columnEnd,
@@ -599,32 +593,33 @@ function Dt(t, e) {
599
593
  {}
600
594
  );
601
595
  }
602
- const It = function(t, e = {}) {
596
+ const At = function(t, e = {}) {
603
597
  const r = {
604
598
  itemResizable: !0,
605
599
  ...e
606
600
  }, { Canvas: o, Commands: n, Components: i } = t, { itemResizable: s } = r, l = o.events, c = n.events, p = i.events, a = `${c.runBeforeCommand}tlb-move`, d = `${c.runBeforeCommand}resize`;
607
601
  let u;
608
- Et(t);
609
- const g = ({ options: m }) => {
610
- N(t, m.target, r) && (t.runCommand(F, { ...m }), m.abort = !0);
611
- }, h = ({ options: m }) => {
612
- N(t, m.target, r) && Object.assign(m.options, xt(t, m));
613
- }, S = () => {
614
- const m = o.getSpots({
615
- type: _
602
+ $t(t);
603
+ const m = ({ options: y }) => {
604
+ _(t, y.target, r) && (t.runCommand(N, { ...y }), y.abort = !0);
605
+ }, h = (y) => {
606
+ const { options: f } = y;
607
+ _(t, f.component, r) && (f.options = Object.assign(f.options || {}, vt(t, f)));
608
+ }, g = () => {
609
+ const y = o.getSpots({
610
+ type: A
616
611
  }).pop();
617
- if (!m) return;
618
- let y = m.attributes.spotEl;
619
- y || (y = document.createElement("div"), y.className = L, m.set({ spotEl: y })), Object.entries(m.getStyle()).forEach(([w, C]) => y.style.setProperty(w, C)), u == null || u.appendChild(y);
620
- }, f = ({ spot: m }) => {
621
- const y = m.attributes.spotEl;
622
- m.type !== _ || !y || u == null || u.removeChild(y);
612
+ if (!y) return;
613
+ let f = y.attributes.spotEl;
614
+ f || (f = document.createElement("div"), f.className = D, y.set({ spotEl: f })), Object.entries(y.getStyle()).forEach(([S, C]) => f.style.setProperty(S, C)), u == null || u.appendChild(f);
615
+ }, w = ({ spot: y }) => {
616
+ const f = y.attributes.spotEl;
617
+ y.type !== A || !f || u == null || u.removeChild(f);
623
618
  };
624
619
  if (s) {
625
- const m = (y) => {
626
- const w = J(s) ? s({ component: y }) : s;
627
- return typeof w == "boolean" ? w : {
620
+ const y = (f) => {
621
+ const S = Y(s) ? s({ component: f }) : s;
622
+ return typeof S == "boolean" ? S : {
628
623
  tl: !1,
629
624
  tc: !1,
630
625
  tr: !1,
@@ -633,41 +628,41 @@ const It = function(t, e = {}) {
633
628
  bl: !1,
634
629
  bc: !1,
635
630
  br: !1,
636
- ...w
631
+ ...S
637
632
  };
638
633
  };
639
- t.on(p.resizeInit, (y) => {
640
- const { component: w } = y;
641
- if (N(t, w, r)) {
642
- const C = m(w);
643
- y.resizable = C;
634
+ t.on(p.resizeInit, (f) => {
635
+ const { component: S } = f;
636
+ if (_(t, S, r)) {
637
+ const C = y(S);
638
+ f.resizable = C;
644
639
  }
645
640
  });
646
641
  }
647
642
  const b = [
648
- [a, g],
643
+ [a, m],
649
644
  [d, h],
650
- [l.spot, S],
651
- [l.spotRemove, f]
645
+ [l.spot, g],
646
+ [l.spotRemove, w]
652
647
  ];
653
- b.forEach(([m, y]) => {
654
- t.on(m, y);
648
+ b.forEach(([y, f]) => {
649
+ t.on(y, f);
655
650
  }), t.onReady(() => {
656
- u = o.getSpotsEl(), ht(), Dt(t, r);
651
+ u = o.getSpotsEl(), ft(), Pt(t, r);
657
652
  });
658
653
  const v = () => {
659
- delete t.Commands.commands[F], b.forEach(([m, y]) => {
660
- t.off(m, y);
654
+ delete t.Commands.commands[N], b.forEach(([y, f]) => {
655
+ t.off(y, f);
661
656
  });
662
657
  };
663
- gt({
658
+ dt({
664
659
  editor: t,
665
660
  licenseKey: r.licenseKey,
666
- plan: ft,
667
- pluginName: W,
661
+ plan: mt,
662
+ pluginName: L,
668
663
  cleanup: v
669
664
  });
670
- }, Mt = ut(It);
665
+ }, Dt = pt(At);
671
666
  export {
672
- Mt as default
667
+ Dt as default
673
668
  };