@grapesjs/studio-sdk-plugins 1.0.30 → 1.0.31
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.
- package/dist/flexComponent/index.cjs.js +6 -6
- package/dist/flexComponent/index.es.js +133 -136
- package/dist/flexComponent/index.umd.js +6 -6
- package/dist/flexComponent/utils.d.ts +2 -3
- package/dist/index.cjs.js +47 -47
- package/dist/index.es.js +1935 -1938
- package/dist/index.umd.js +48 -48
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const pe = "app.grapesjs.com", de = "app-stage.grapesjs.com", Se = "app2.grapesjs.com", ye = "app-stage2.grapesjs.com", se = [
|
|
2
|
+
pe,
|
|
3
|
+
Se,
|
|
2
4
|
de,
|
|
3
5
|
ye,
|
|
4
|
-
ue,
|
|
5
|
-
be,
|
|
6
6
|
"localhost",
|
|
7
7
|
"127.0.0.1",
|
|
8
8
|
".local-credentialless.webcontainer.io",
|
|
@@ -11,11 +11,11 @@ const de = "app.grapesjs.com", ue = "app-stage.grapesjs.com", ye = "app2.grapesj
|
|
|
11
11
|
// For stackblitz.com demos
|
|
12
12
|
"-sandpack.codesandbox.io"
|
|
13
13
|
// For Sandpack demos
|
|
14
|
-
],
|
|
15
|
-
const n =
|
|
16
|
-
return !!n && (
|
|
14
|
+
], be = "license:check:start", Ce = "license:check:end", Pe = () => typeof window < "u", ze = ({ isDev: n, isStage: e }) => `${n ? "" : `https://${e ? de : pe}`}/api`, xe = () => {
|
|
15
|
+
const n = Pe() && window.location.hostname;
|
|
16
|
+
return !!n && (se.includes(n) || se.some((e) => n.endsWith(e)));
|
|
17
17
|
};
|
|
18
|
-
function
|
|
18
|
+
function we(n) {
|
|
19
19
|
return typeof n == "function";
|
|
20
20
|
}
|
|
21
21
|
async function Ie({
|
|
@@ -26,7 +26,7 @@ async function Ie({
|
|
|
26
26
|
params: i,
|
|
27
27
|
body: a
|
|
28
28
|
}) {
|
|
29
|
-
const l = `${e ||
|
|
29
|
+
const l = `${e || ze({ isDev: !1, isStage: !1 })}${n}`, c = {
|
|
30
30
|
method: t,
|
|
31
31
|
headers: {
|
|
32
32
|
"Content-Type": "application/json",
|
|
@@ -39,18 +39,18 @@ async function Ie({
|
|
|
39
39
|
throw new Error(`HTTP error! status: ${u.status}`);
|
|
40
40
|
return u.json();
|
|
41
41
|
}
|
|
42
|
-
var $ = /* @__PURE__ */ ((n) => (n.free = "free", n.startup = "startup", n.business = "business", n.enterprise = "enterprise", n))($ || {}),
|
|
43
|
-
const
|
|
42
|
+
var $ = /* @__PURE__ */ ((n) => (n.free = "free", n.startup = "startup", n.business = "business", n.enterprise = "enterprise", n))($ || {}), ue = /* @__PURE__ */ ((n) => (n.web = "web", n.email = "email", n.document = "document", n.react = "react", n))(ue || {});
|
|
43
|
+
const ie = {
|
|
44
44
|
[$.free]: 0,
|
|
45
45
|
[$.startup]: 10,
|
|
46
46
|
[$.business]: 20,
|
|
47
47
|
[$.enterprise]: 30
|
|
48
48
|
};
|
|
49
|
-
function
|
|
49
|
+
function ve(n) {
|
|
50
50
|
const e = n;
|
|
51
51
|
return e.init = (t) => (s) => n(s, t), e;
|
|
52
52
|
}
|
|
53
|
-
const
|
|
53
|
+
const Re = (n) => /* @__PURE__ */ ve(n);
|
|
54
54
|
async function Ge({
|
|
55
55
|
editor: n,
|
|
56
56
|
plan: e,
|
|
@@ -59,34 +59,34 @@ async function Ge({
|
|
|
59
59
|
cleanup: i
|
|
60
60
|
}) {
|
|
61
61
|
let a = "", o = !1;
|
|
62
|
-
const l =
|
|
62
|
+
const l = xe(), c = (p) => {
|
|
63
63
|
console.warn("Cleanup plugin:", t, "Reason:", p), i();
|
|
64
64
|
}, g = (p = {}) => {
|
|
65
65
|
var y;
|
|
66
|
-
const { error: u, sdkLicense: f } = p,
|
|
66
|
+
const { error: u, sdkLicense: f } = p, I = (y = p.plan) == null ? void 0 : y.category;
|
|
67
67
|
if (!(f || p.license) || u)
|
|
68
68
|
c(u || "Invalid license");
|
|
69
|
-
else if (
|
|
70
|
-
const
|
|
71
|
-
|
|
69
|
+
else if (I) {
|
|
70
|
+
const v = ie[e], R = ie[I];
|
|
71
|
+
v > R && c({ pluginRequiredPlan: e, licensePlan: I });
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
-
n.on(
|
|
74
|
+
n.on(be, (p) => {
|
|
75
75
|
a = p == null ? void 0 : p.baseApiUrl, o = !0;
|
|
76
|
-
}), n.on(
|
|
76
|
+
}), n.on(Ce, (p) => {
|
|
77
77
|
g(p);
|
|
78
78
|
}), setTimeout(async () => {
|
|
79
79
|
if (!o) {
|
|
80
80
|
if (l) return;
|
|
81
81
|
if (s) {
|
|
82
|
-
const p = await
|
|
82
|
+
const p = await Ee({ licenseKey: s, pluginName: t, baseApiUrl: a });
|
|
83
83
|
p && g(p);
|
|
84
84
|
} else
|
|
85
85
|
c("The `licenseKey` option not provided");
|
|
86
86
|
}
|
|
87
87
|
}, 2e3);
|
|
88
88
|
}
|
|
89
|
-
async function
|
|
89
|
+
async function Ee(n) {
|
|
90
90
|
const { licenseKey: e, pluginName: t, baseApiUrl: s } = n;
|
|
91
91
|
try {
|
|
92
92
|
return (await Ie({
|
|
@@ -102,16 +102,16 @@ async function Te(n) {
|
|
|
102
102
|
return console.error("Error during SDK license check:", i), !1;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
const
|
|
105
|
+
const he = (n) => (e) => {
|
|
106
106
|
var t;
|
|
107
|
-
return ((t = e.getAttribute) == null ? void 0 : t.call(e,
|
|
108
|
-
},
|
|
107
|
+
return ((t = e.getAttribute) == null ? void 0 : t.call(e, te)) === n;
|
|
108
|
+
}, Te = (...n) => (e) => n.some((t) => e.is(t)), Le = (...n) => (e, t) => n.some((s) => t.is(s)), ge = "gjs-plg-", te = "data-type-role", N = class N {
|
|
109
109
|
constructor(e) {
|
|
110
110
|
this.config = e;
|
|
111
111
|
}
|
|
112
112
|
getSize(e) {
|
|
113
113
|
var t;
|
|
114
|
-
return (t = this.config) != null && t.getSize ? this.config.getSize(e) :
|
|
114
|
+
return (t = this.config) != null && t.getSize ? this.config.getSize(e) : ne(e.componentColumn, N.CSS_FLEX_BASIS);
|
|
115
115
|
}
|
|
116
116
|
setSize(e) {
|
|
117
117
|
var t;
|
|
@@ -124,7 +124,7 @@ const ge = (n) => (e) => {
|
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
N.CSS_FLEX_BASIS = "flex-basis";
|
|
127
|
-
let
|
|
127
|
+
let W = N;
|
|
128
128
|
const j = class j {
|
|
129
129
|
constructor(e) {
|
|
130
130
|
this.config = e;
|
|
@@ -134,7 +134,7 @@ const j = class j {
|
|
|
134
134
|
}
|
|
135
135
|
getGap(e) {
|
|
136
136
|
var t;
|
|
137
|
-
return (t = this.config) != null && t.getGap ? this.config.getGap(e) :
|
|
137
|
+
return (t = this.config) != null && t.getGap ? this.config.getGap(e) : ne(e.componentRow, j.CSS_GAP);
|
|
138
138
|
}
|
|
139
139
|
setGap(e) {
|
|
140
140
|
var t;
|
|
@@ -147,8 +147,8 @@ const j = class j {
|
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
149
|
j.CSS_GAP = "gap";
|
|
150
|
-
let
|
|
151
|
-
const
|
|
150
|
+
let K = j;
|
|
151
|
+
const X = class X {
|
|
152
152
|
constructor(e) {
|
|
153
153
|
this.config = e;
|
|
154
154
|
}
|
|
@@ -161,12 +161,12 @@ const Y = class Y {
|
|
|
161
161
|
isLayoutVertical(e) {
|
|
162
162
|
var s;
|
|
163
163
|
if ((s = this.config) != null && s.isParentVertical) return this.config.isParentVertical(e);
|
|
164
|
-
const t =
|
|
164
|
+
const t = ne(e.componentRow, X.CSS_FLEX_DIRECTION, !0);
|
|
165
165
|
return t === "column" || t === "column-reverse";
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
|
-
|
|
169
|
-
let
|
|
168
|
+
X.CSS_FLEX_DIRECTION = "flex-direction";
|
|
169
|
+
let J = X;
|
|
170
170
|
const _ = class _ {
|
|
171
171
|
constructor(e) {
|
|
172
172
|
this.config = e;
|
|
@@ -195,8 +195,8 @@ const _ = class _ {
|
|
|
195
195
|
}
|
|
196
196
|
};
|
|
197
197
|
_.MJML_COLUMN_TYPE = "mj-column";
|
|
198
|
-
let
|
|
199
|
-
const
|
|
198
|
+
let q = _;
|
|
199
|
+
const Y = class Y {
|
|
200
200
|
constructor(e) {
|
|
201
201
|
this.config = e;
|
|
202
202
|
}
|
|
@@ -207,7 +207,7 @@ const U = class U {
|
|
|
207
207
|
var s;
|
|
208
208
|
if ((s = this.config) != null && s.getGap) return this.config.getGap(e);
|
|
209
209
|
const { componentRow: t } = e;
|
|
210
|
-
if (t.is(
|
|
210
|
+
if (t.is(Y.MJML_SECTION_TYPE)) {
|
|
211
211
|
const i = t.getAttributes();
|
|
212
212
|
if (i && i.padding)
|
|
213
213
|
return parseInt(i.padding, 10) || 0;
|
|
@@ -219,9 +219,9 @@ const U = class U {
|
|
|
219
219
|
(s = (t = this.config) == null ? void 0 : t.setGap) == null || s.call(t, e);
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
|
-
|
|
223
|
-
let
|
|
224
|
-
class
|
|
222
|
+
Y.MJML_SECTION_TYPE = "mj-section";
|
|
223
|
+
let Z = Y;
|
|
224
|
+
class $e {
|
|
225
225
|
constructor(e) {
|
|
226
226
|
this.config = e;
|
|
227
227
|
}
|
|
@@ -252,46 +252,43 @@ class A {
|
|
|
252
252
|
getHandlers(e) {
|
|
253
253
|
const t = `${e.projectType}-${e.disableGapHandler ? "nogap" : "gap"}`;
|
|
254
254
|
return this.handlerCache.has(t) || (H(e) ? this.handlerCache.set(t, {
|
|
255
|
-
sizeHandler: new
|
|
256
|
-
gapHandler: new
|
|
257
|
-
parentSizeHandler: new
|
|
255
|
+
sizeHandler: new q(e),
|
|
256
|
+
gapHandler: new Z(e),
|
|
257
|
+
parentSizeHandler: new $e(e)
|
|
258
258
|
}) : this.handlerCache.set(t, {
|
|
259
|
-
sizeHandler: new
|
|
260
|
-
gapHandler: new
|
|
261
|
-
parentSizeHandler: new
|
|
259
|
+
sizeHandler: new W(e),
|
|
260
|
+
gapHandler: new K(e),
|
|
261
|
+
parentSizeHandler: new J(e)
|
|
262
262
|
})), this.handlerCache.get(t);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
function
|
|
265
|
+
function E(n) {
|
|
266
266
|
return A.getInstance().getHandlers(n);
|
|
267
267
|
}
|
|
268
|
-
const
|
|
268
|
+
const ae = (n) => {
|
|
269
269
|
n.style.display = "none";
|
|
270
|
-
},
|
|
270
|
+
}, oe = (n) => {
|
|
271
271
|
n.style.display = "block";
|
|
272
|
-
}, M = (n) => +parseFloat(`${n}`).toFixed(2), H = (n) => n.projectType ===
|
|
273
|
-
const t = n.Canvas.getFramesEl();
|
|
274
|
-
t && (t.style.pointerEvents = e ? "none" : "");
|
|
275
|
-
}, He = (n) => n ? ["top", "bottom"] : ["left", "right"], Me = (n) => {
|
|
272
|
+
}, M = (n) => +parseFloat(`${n}`).toFixed(2), H = (n) => n.projectType === ue.email, Ae = (n) => n ? ["top", "bottom"] : ["left", "right"], He = (n) => {
|
|
276
273
|
const e = n.parent();
|
|
277
274
|
return e ? e.components().models.indexOf(n) === 0 : !1;
|
|
278
|
-
},
|
|
275
|
+
}, Me = (n) => {
|
|
279
276
|
const e = n.parent();
|
|
280
277
|
if (!e) return !1;
|
|
281
278
|
const t = e.components().models;
|
|
282
279
|
return t.indexOf(n) === t.length - 1;
|
|
283
|
-
},
|
|
280
|
+
}, Ve = (n) => {
|
|
284
281
|
const e = n.parent();
|
|
285
282
|
if (!e) return !1;
|
|
286
283
|
const t = e.components().models;
|
|
287
284
|
return t.length > 1 && n.index() === t.length - 1;
|
|
288
|
-
},
|
|
285
|
+
}, Ne = (n, e, t, s) => {
|
|
289
286
|
const a = n + (t ? e === "top" ? -1 : e === "bottom" ? 1 : 0 : e === "left" ? -1 : e === "right" ? 1 : 0);
|
|
290
287
|
return a >= 0 && a < s ? a : -1;
|
|
291
|
-
},
|
|
288
|
+
}, k = (n) => n === "top" || n === "bottom", je = (n, e) => !!(He(n) && (e === "left" || e === "top") || Me(n) && (e === "right" || e === "bottom")), _e = (n) => {
|
|
292
289
|
const e = n.parent();
|
|
293
290
|
return e ? e.components().models.length > 1 : !1;
|
|
294
|
-
},
|
|
291
|
+
}, re = (n, e) => n === "right" || n === "bottom" ? e > 0 : e < 0, ne = (n, e, t = !1) => {
|
|
295
292
|
const s = !t, i = n.getEl();
|
|
296
293
|
if (!i)
|
|
297
294
|
return s ? 0 : "";
|
|
@@ -301,29 +298,29 @@ const oe = (n) => {
|
|
|
301
298
|
return typeof o == "string" ? (l = parseFloat(o.replace(/[^-\d.]/g, "")), isNaN(l) && (l = 0)) : l = Number(o) || 0, l;
|
|
302
299
|
}
|
|
303
300
|
return o;
|
|
304
|
-
},
|
|
305
|
-
const s =
|
|
301
|
+
}, ce = (n, e, t) => {
|
|
302
|
+
const s = Q({ componentRow: n, isVertical: e }, t), i = n.components().models;
|
|
306
303
|
return s * (i.length - 1);
|
|
307
|
-
}, D = (n, e) =>
|
|
304
|
+
}, D = (n, e) => E(e).parentSizeHandler.isLayoutVertical({ componentRow: n }), B = (n, e) => E(e).sizeHandler.getSize(n), Q = (n, e) => {
|
|
308
305
|
if (e != null && e.disableGapHandler) return 0;
|
|
309
|
-
const { gapHandler: t, parentSizeHandler: s } =
|
|
306
|
+
const { gapHandler: t, parentSizeHandler: s } = E(e);
|
|
310
307
|
if (!t.isGapSupported()) return 0;
|
|
311
308
|
const i = t.getGap(n), a = s.getParentSize(n);
|
|
312
309
|
return i / 100 * a;
|
|
313
|
-
},
|
|
314
|
-
|
|
315
|
-
},
|
|
316
|
-
const t =
|
|
310
|
+
}, ee = (n, e) => E(e).parentSizeHandler.getParentSize(n), V = (n, e) => {
|
|
311
|
+
E(e).sizeHandler.setSize(n);
|
|
312
|
+
}, fe = (n, e) => {
|
|
313
|
+
const t = B(n, e);
|
|
317
314
|
V({ ...n, sizeValue: `${t}%`, partial: !1 }, e);
|
|
318
|
-
},
|
|
315
|
+
}, me = (n, e) => {
|
|
319
316
|
if (e != null && e.disableGapHandler) return;
|
|
320
|
-
const { gapHandler: t } =
|
|
317
|
+
const { gapHandler: t } = E(e);
|
|
321
318
|
t.isGapSupported() && t.setGap(n);
|
|
322
|
-
},
|
|
319
|
+
}, De = (n, e) => {
|
|
323
320
|
const t = n.getStyle().gap;
|
|
324
321
|
if (!t) return;
|
|
325
322
|
const s = n.components().models, i = { componentRow: n, isVertical: D(n, e) };
|
|
326
|
-
s.map((a) =>
|
|
323
|
+
s.map((a) => fe({ ...i, componentColumn: a }, e)), me({ ...i, gapValue: String(t), partial: !1 }, e);
|
|
327
324
|
};
|
|
328
325
|
function Be(n, e) {
|
|
329
326
|
const { Blocks: t } = n, { typeColumn: s, typeRow: i, blocks: a } = e;
|
|
@@ -356,16 +353,16 @@ function Be(n, e) {
|
|
|
356
353
|
c("3 Columns 25/25/50", [25, 25, 50]),
|
|
357
354
|
c("4 Columns", [25, 25, 25, 25]),
|
|
358
355
|
c("5 Columns", [20, 20, 20, 20, 20])
|
|
359
|
-
], p =
|
|
356
|
+
], p = we(a) ? a({ blocks: g }) : g;
|
|
360
357
|
return p.forEach((u) => t.add(u.id, u)), () => {
|
|
361
358
|
p.forEach((u) => t.remove(u.id));
|
|
362
359
|
};
|
|
363
360
|
}
|
|
364
|
-
const
|
|
365
|
-
const { Components: t } = n, { typeRow: s, typeColumn: i, extendTypeColumn: a } = e, o = `${
|
|
361
|
+
const Fe = (n, e) => {
|
|
362
|
+
const { Components: t } = n, { typeRow: s, typeColumn: i, extendTypeColumn: a } = e, o = `${ge}${i}`, c = !!i && !!t.getType(i) && !a;
|
|
366
363
|
if (!(!i || c || H(e)))
|
|
367
364
|
return t.addType(i, {
|
|
368
|
-
isComponent:
|
|
365
|
+
isComponent: he(i),
|
|
369
366
|
model: {
|
|
370
367
|
defaults: {
|
|
371
368
|
name: "Column",
|
|
@@ -373,8 +370,8 @@ const ke = (n, e) => {
|
|
|
373
370
|
emptyState: !0,
|
|
374
371
|
classes: o,
|
|
375
372
|
icon: '<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',
|
|
376
|
-
draggable:
|
|
377
|
-
attributes: { [
|
|
373
|
+
draggable: Le(s),
|
|
374
|
+
attributes: { [te]: i },
|
|
378
375
|
styles: `
|
|
379
376
|
.${o} {
|
|
380
377
|
flex-grow: 1;
|
|
@@ -385,19 +382,19 @@ const ke = (n, e) => {
|
|
|
385
382
|
}), () => {
|
|
386
383
|
t.removeType(i);
|
|
387
384
|
};
|
|
388
|
-
},
|
|
389
|
-
const { Components: t } = n, { typeRow: s, typeColumn: i, extendTypeRow: a } = e, o = `${
|
|
385
|
+
}, ke = (n, e) => {
|
|
386
|
+
const { Components: t } = n, { typeRow: s, typeColumn: i, extendTypeRow: a } = e, o = `${ge}${s}`, c = !!s && !!t.getType(s) && !a;
|
|
390
387
|
if (!(!s || c || H(e)))
|
|
391
388
|
return t.addType(s, {
|
|
392
|
-
isComponent:
|
|
389
|
+
isComponent: he(s),
|
|
393
390
|
model: {
|
|
394
391
|
defaults: {
|
|
395
392
|
name: "Row",
|
|
396
393
|
classes: o,
|
|
397
394
|
icon: '<svg viewBox="0 0 24 24"><path d="M4 4.8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3A1.8 1.8 0 0 0 20 4.7zm0 8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',
|
|
398
395
|
emptyState: { styleIn: "width: 100%" },
|
|
399
|
-
attributes: { [
|
|
400
|
-
droppable:
|
|
396
|
+
attributes: { [te]: s },
|
|
397
|
+
droppable: Te(i),
|
|
401
398
|
traits: [
|
|
402
399
|
// {
|
|
403
400
|
// type: 'number',
|
|
@@ -455,8 +452,8 @@ const ke = (n, e) => {
|
|
|
455
452
|
}), () => {
|
|
456
453
|
t.removeType(s);
|
|
457
454
|
};
|
|
458
|
-
},
|
|
459
|
-
class
|
|
455
|
+
}, Oe = "flexComponent", Xe = $.startup;
|
|
456
|
+
class Ye {
|
|
460
457
|
constructor() {
|
|
461
458
|
this.resizableChildTypes = /* @__PURE__ */ new Set(), this.gapAdjustableParentTypes = /* @__PURE__ */ new Set(), this.typeRelationships = /* @__PURE__ */ new Map();
|
|
462
459
|
}
|
|
@@ -480,7 +477,7 @@ class Ue {
|
|
|
480
477
|
return this.typeRelationships.has(s) ? this.typeRelationships.get(s).has(i) : !1;
|
|
481
478
|
}
|
|
482
479
|
}
|
|
483
|
-
class
|
|
480
|
+
class Ue {
|
|
484
481
|
constructor(e, t, s) {
|
|
485
482
|
this.editor = e, this.registry = t, this.opts = s, this.resizeState = /* @__PURE__ */ new WeakMap();
|
|
486
483
|
}
|
|
@@ -496,12 +493,12 @@ class We {
|
|
|
496
493
|
const o = e.parent();
|
|
497
494
|
if (!o || !this.registry.isValidRelationship(o, e)) return;
|
|
498
495
|
a.snapEnabled = o.get("snap") ?? i.snapEnabled, a.snapDivisions = o.get("snap-divisions") ?? i.snapDivisions ?? 12;
|
|
499
|
-
const l = o.components().models, c = l.findIndex((f) => f.cid === e.cid), g = D(o, i), p =
|
|
496
|
+
const l = o.components().models, c = l.findIndex((f) => f.cid === e.cid), g = D(o, i), p = Ne(c, t, g, l.length);
|
|
500
497
|
p !== -1 && (a.adjacentIdx = p);
|
|
501
498
|
const u = { componentColumn: e, componentRow: o, isVertical: g };
|
|
502
|
-
if (a.startPercent =
|
|
499
|
+
if (a.startPercent = B(u, i), typeof a.adjacentIdx < "u") {
|
|
503
500
|
const f = l[a.adjacentIdx];
|
|
504
|
-
a.neighborStartPercent =
|
|
501
|
+
a.neighborStartPercent = B({ ...u, componentColumn: f }, i);
|
|
505
502
|
}
|
|
506
503
|
}
|
|
507
504
|
updateResizeByDelta(e, t, s) {
|
|
@@ -510,25 +507,25 @@ class We {
|
|
|
510
507
|
}
|
|
511
508
|
finishResize(e) {
|
|
512
509
|
const t = e.parent(), s = t == null ? void 0 : t.components().models, i = { componentRow: t, isVertical: !!t && D(t, this.opts) };
|
|
513
|
-
s == null || s.forEach((a) =>
|
|
510
|
+
s == null || s.forEach((a) => fe({ ...i, componentColumn: a }, this.opts)), this.clearState(e);
|
|
514
511
|
}
|
|
515
512
|
updateContinuesResize(e, t, s) {
|
|
516
513
|
const i = this.getState(e), a = e.parent(), { opts: o } = this;
|
|
517
514
|
if (!a) return;
|
|
518
|
-
const l = o.minItemPercent ?? 0, c =
|
|
515
|
+
const l = o.minItemPercent ?? 0, c = k(t), g = ee({ componentRow: a, isVertical: c }, o), p = ce(a, c, this.opts), f = 100 - p / g * 100, I = s / (g - p) * f, { startPercent: P = 0, neighborStartPercent: y = 0 } = i, v = { componentRow: a, isVertical: c, componentColumn: e, partial: !0 }, R = re(t, s) ? P + Math.abs(I) : P - Math.abs(I);
|
|
519
516
|
if (typeof i.adjacentIdx < "u") {
|
|
520
517
|
const z = a.components().models[i.adjacentIdx], x = P + y, b = x - l, r = Math.min(b, Math.max(l, R)), d = x - r;
|
|
521
|
-
V({ ...
|
|
522
|
-
{ ...
|
|
518
|
+
V({ ...v, sizeValue: `${M(r)}%` }, o), V(
|
|
519
|
+
{ ...v, componentColumn: z, sizeValue: `${M(d)}%` },
|
|
523
520
|
o
|
|
524
521
|
);
|
|
525
522
|
} else {
|
|
526
523
|
const z = Math.max(l, Math.min(f, R));
|
|
527
|
-
V({ ...
|
|
524
|
+
V({ ...v, sizeValue: `${M(z)}%` }, o);
|
|
528
525
|
}
|
|
529
526
|
}
|
|
530
527
|
updateSnapResize(e, t, s) {
|
|
531
|
-
const i = this.getState(e), a = e.parent(), o =
|
|
528
|
+
const i = this.getState(e), a = e.parent(), o = k(t), l = ee({ componentRow: a, isVertical: o }, this.opts), c = ce(a, o, this.opts), g = l - c, p = s / g * 100, u = re(t, s), { startPercent: f = 0, snapDivisions: I = 12 } = i, P = u ? f + Math.abs(p) : f - Math.abs(p), y = 100 / I, v = Math.floor(P / y) * y, R = Math.ceil(P / y) * y, z = Math.abs(R - P), x = Math.abs(P - v), b = y * 0.2, C = z < x ? R : v;
|
|
532
529
|
if (C > 0 && C < 100 && (z < b || x < b) && i.lastSnappedPercent !== C) {
|
|
533
530
|
i.lastSnappedPercent = C;
|
|
534
531
|
let m = Math.abs(C - f) / 100 * g;
|
|
@@ -536,31 +533,31 @@ class We {
|
|
|
536
533
|
} else z >= b && x >= b && (i.lastSnappedPercent = void 0);
|
|
537
534
|
}
|
|
538
535
|
}
|
|
539
|
-
class
|
|
536
|
+
class We {
|
|
540
537
|
constructor(e, t, s) {
|
|
541
538
|
this.editor = e, this.registry = t, this.opts = s;
|
|
542
539
|
}
|
|
543
540
|
updateGapByDelta(e, t, s, i) {
|
|
544
541
|
if (!this.registry.isGapAdjustableParent(e)) return;
|
|
545
|
-
const { opts: a } = this, o = Math.max(0, s + t), l =
|
|
546
|
-
(b, C) => b +
|
|
542
|
+
const { opts: a } = this, o = Math.max(0, s + t), l = ee({ componentRow: e, isVertical: i }, a), c = o / l * 100, g = e.components().models, p = g.length - 1, u = { componentRow: e, isVertical: i }, f = g.reduce(
|
|
543
|
+
(b, C) => b + B({ ...u, componentColumn: C }, a),
|
|
547
544
|
0
|
|
548
545
|
), P = 100 - c * p, y = a.minItemPercent || 5;
|
|
549
546
|
if (P < y * g.length)
|
|
550
547
|
return;
|
|
551
548
|
const R = 100 - p * c, z = f - R, x = { componentRow: e, isVertical: i, partial: !0 };
|
|
552
549
|
g.map((b) => {
|
|
553
|
-
const C =
|
|
550
|
+
const C = B({ ...u, componentColumn: b }, a), r = C - C / f * z;
|
|
554
551
|
V({ ...x, componentColumn: b, sizeValue: `${M(r)}%` }, a);
|
|
555
|
-
}),
|
|
552
|
+
}), me({ ...x, gapValue: `${M(c)}%` }, a);
|
|
556
553
|
}
|
|
557
554
|
finishGapAdjust(e) {
|
|
558
|
-
|
|
555
|
+
De(e, this.opts);
|
|
559
556
|
}
|
|
560
557
|
}
|
|
561
|
-
class
|
|
558
|
+
class Ke {
|
|
562
559
|
constructor(e, t, s) {
|
|
563
|
-
this.editor = e, this.registry = t, this.opts = s, this.resizeHandler = new
|
|
560
|
+
this.editor = e, this.registry = t, this.opts = s, this.resizeHandler = new Ue(e, t, s), this.gapHandler = new We(e, t, s);
|
|
564
561
|
}
|
|
565
562
|
startResize(e, t, s) {
|
|
566
563
|
this.resizeHandler.startResize(e, t, s);
|
|
@@ -585,20 +582,20 @@ class Je {
|
|
|
585
582
|
return this.registry.isGapAdjustableParent(e);
|
|
586
583
|
}
|
|
587
584
|
}
|
|
588
|
-
const
|
|
589
|
-
function
|
|
585
|
+
const O = "gs-flex-spots", le = `${O}__handle-size`, Je = `${O}__handle-gap`;
|
|
586
|
+
function qe(n, e) {
|
|
590
587
|
const { Canvas: t } = n, s = "flex-resize-spot";
|
|
591
588
|
let i, a, o, l, c = null, g = null;
|
|
592
|
-
const p = new
|
|
589
|
+
const p = new Ye(), u = new Ke(n, p, e), f = () => {
|
|
593
590
|
var r;
|
|
594
|
-
i = document.createElement("div"), i.className =
|
|
591
|
+
i = document.createElement("div"), i.className = O, i.style.display = "none", a = document.createElement("div"), a.className = `${O}__handles`, a.style.position = "absolute", a.style.pointerEvents = "none", a.style.zIndex = "21", o = {
|
|
595
592
|
left: document.createElement("div"),
|
|
596
593
|
right: document.createElement("div"),
|
|
597
594
|
top: document.createElement("div"),
|
|
598
595
|
bottom: document.createElement("div")
|
|
599
596
|
}, Object.entries(o).forEach(([d, m]) => {
|
|
600
|
-
const S = d, h =
|
|
601
|
-
m.className = `${
|
|
597
|
+
const S = d, h = k(S);
|
|
598
|
+
m.className = `${le} ${le}-${S} gjs-resizer-h gjs-cv-unscale`, m.style.cssText = `
|
|
602
599
|
pointer-events: all;
|
|
603
600
|
position: absolute;
|
|
604
601
|
z-index: 1;
|
|
@@ -608,8 +605,8 @@ function Ze(n, e) {
|
|
|
608
605
|
${S === "right" ? "right: 0px;" : ""}
|
|
609
606
|
${S === "top" ? "top: 0px;" : ""}
|
|
610
607
|
${S === "bottom" ? "bottom: 0px;" : ""}
|
|
611
|
-
`, m.addEventListener("pointerdown",
|
|
612
|
-
}), !e.disableGapHandler && !H(e) && (l = document.createElement("div"), l.className =
|
|
608
|
+
`, m.addEventListener("pointerdown", I(S)), a.appendChild(m);
|
|
609
|
+
}), !e.disableGapHandler && !H(e) && (l = document.createElement("div"), l.className = Je, l.style.cssText = `
|
|
613
610
|
position: absolute;
|
|
614
611
|
background-color: var(--gs-theme-cl-cmp-bg1, #3b97e3);
|
|
615
612
|
border-width: 2px;
|
|
@@ -620,48 +617,48 @@ function Ze(n, e) {
|
|
|
620
617
|
max-width: 3rem;
|
|
621
618
|
max-height: 3rem;
|
|
622
619
|
`, l.addEventListener("pointerdown", P()), a.appendChild(l)), i.append(a), (r = t.getSpotsEl()) == null || r.appendChild(i);
|
|
623
|
-
},
|
|
620
|
+
}, I = (r) => (d) => {
|
|
624
621
|
if (!c) return;
|
|
625
|
-
|
|
622
|
+
d.stopPropagation(), d.preventDefault(), u.startResize(c, r, d);
|
|
626
623
|
const m = d.clientX, S = d.clientY;
|
|
627
624
|
d.target.setPointerCapture(d.pointerId);
|
|
628
625
|
const h = (T) => {
|
|
629
|
-
const
|
|
630
|
-
u.updateResizeByDelta(c, r,
|
|
626
|
+
const G = n.Canvas.getZoomMultiplier(), L = (T.clientX - m) * G, F = (T.clientY - S) * G, U = k(r) ? F : L;
|
|
627
|
+
u.updateResizeByDelta(c, r, U);
|
|
631
628
|
}, w = () => {
|
|
632
|
-
|
|
629
|
+
u.finishResize(c), d.target.releasePointerCapture(d.pointerId), document.removeEventListener("pointermove", h), document.removeEventListener("pointerup", w);
|
|
633
630
|
};
|
|
634
631
|
document.addEventListener("pointermove", h), document.addEventListener("pointerup", w);
|
|
635
632
|
}, P = () => (r) => {
|
|
636
633
|
if (!g) return;
|
|
637
634
|
const d = g;
|
|
638
|
-
|
|
639
|
-
const m = D(d, e), S =
|
|
635
|
+
r.stopPropagation(), r.preventDefault();
|
|
636
|
+
const m = D(d, e), S = Q({ componentRow: d, isVertical: m }, e), h = r.clientX, w = r.clientY;
|
|
640
637
|
r.target.setPointerCapture(r.pointerId);
|
|
641
638
|
const T = (L) => {
|
|
642
|
-
const
|
|
643
|
-
u.updateGapByDelta(d,
|
|
644
|
-
},
|
|
645
|
-
|
|
639
|
+
const F = n.Canvas.getZoomMultiplier(), U = m ? (L.clientY - w) * F : (L.clientX - h) * F;
|
|
640
|
+
u.updateGapByDelta(d, U, S, m);
|
|
641
|
+
}, G = () => {
|
|
642
|
+
u.finishGapAdjust(d), r.target.releasePointerCapture(r.pointerId), document.removeEventListener("pointermove", T), document.removeEventListener("pointerup", G);
|
|
646
643
|
};
|
|
647
|
-
document.addEventListener("pointermove", T), document.addEventListener("pointerup",
|
|
644
|
+
document.addEventListener("pointermove", T), document.addEventListener("pointerup", G);
|
|
648
645
|
}, y = (r) => {
|
|
649
646
|
const d = r.component;
|
|
650
647
|
if (!d || !i || (c = d, g = d.parent(), !g)) return;
|
|
651
648
|
const m = g;
|
|
652
|
-
|
|
649
|
+
oe(i);
|
|
653
650
|
const S = r.getStyle();
|
|
654
651
|
a && Object.assign(a.style, S);
|
|
655
|
-
const h = D(m, e), w =
|
|
656
|
-
if (Object.values(o).forEach(
|
|
657
|
-
if (
|
|
658
|
-
const L = o[
|
|
659
|
-
|
|
660
|
-
}),
|
|
661
|
-
const
|
|
662
|
-
|
|
652
|
+
const h = D(m, e), w = Ae(h);
|
|
653
|
+
if (Object.values(o).forEach(ae), w.forEach((G) => {
|
|
654
|
+
if (je(d, G)) return;
|
|
655
|
+
const L = o[G];
|
|
656
|
+
oe(L);
|
|
657
|
+
}), E(e).gapHandler.isGapSupported() && l && _e(d)) {
|
|
658
|
+
const G = Q({ componentRow: m, isVertical: h }, e);
|
|
659
|
+
v(G, h, Ve(d));
|
|
663
660
|
}
|
|
664
|
-
},
|
|
661
|
+
}, v = (r, d, m = !1) => {
|
|
665
662
|
const S = e.gapHandleSize, h = l.style;
|
|
666
663
|
if (d) {
|
|
667
664
|
h.height = `${S}px`;
|
|
@@ -673,7 +670,7 @@ function Ze(n, e) {
|
|
|
673
670
|
m ? (h.left = `-${(r + w) / 2}px`, h.right = "") : (h.right = `-${(r + w) / 2}px`, h.left = ""), h.height = "50%", h.top = "50%", h.transform = "translateY(-50%)", h.cursor = "col-resize";
|
|
674
671
|
}
|
|
675
672
|
}, R = () => {
|
|
676
|
-
i && (
|
|
673
|
+
i && (ae(i), c = null, g = null);
|
|
677
674
|
}, z = () => {
|
|
678
675
|
t.removeSpots({ type: s });
|
|
679
676
|
const r = n.getSelected(), d = r == null ? void 0 : r.parent();
|
|
@@ -692,7 +689,7 @@ function Ze(n, e) {
|
|
|
692
689
|
n.off(t.events.spot, x), n.off(C, z);
|
|
693
690
|
};
|
|
694
691
|
}
|
|
695
|
-
const
|
|
692
|
+
const Ze = function(n, e = {}) {
|
|
696
693
|
const t = {
|
|
697
694
|
typeRow: "flex-row",
|
|
698
695
|
typeColumn: "flex-column",
|
|
@@ -700,17 +697,17 @@ const Qe = function(n, e = {}) {
|
|
|
700
697
|
snapDivisions: 12,
|
|
701
698
|
minItemPercent: 5,
|
|
702
699
|
...e
|
|
703
|
-
}, s = [
|
|
700
|
+
}, s = [ke(n, t), Fe(n, t)], i = qe(n, t), a = Be(n, t);
|
|
704
701
|
Ge({
|
|
705
702
|
editor: n,
|
|
706
703
|
licenseKey: t.licenseKey,
|
|
707
|
-
plan:
|
|
708
|
-
pluginName:
|
|
704
|
+
plan: Xe,
|
|
705
|
+
pluginName: Oe,
|
|
709
706
|
cleanup: () => {
|
|
710
707
|
s.forEach((o) => o == null ? void 0 : o()), i(), a == null || a();
|
|
711
708
|
}
|
|
712
709
|
});
|
|
713
|
-
},
|
|
710
|
+
}, Qe = Re(Ze);
|
|
714
711
|
export {
|
|
715
|
-
|
|
712
|
+
Qe as default
|
|
716
713
|
};
|