@grapesjs/studio-sdk-plugins 1.0.33-rc.1 → 1.0.33
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/accordionComponent/index.cjs.js +7 -7
- package/dist/accordionComponent/index.es.js +161 -156
- package/dist/accordionComponent/index.umd.js +9 -9
- package/dist/aiChat/chatManager.d.ts +15 -0
- package/dist/aiChat/clientTools.d.ts +3 -3
- package/dist/aiChat/clientToolsProcessors.d.ts +14 -1
- package/dist/aiChat/components/AiChatEmptyState.d.ts +4 -6
- package/dist/aiChat/components/AiChatError.d.ts +2 -1
- package/dist/aiChat/components/AiChatHeader.d.ts +2 -1
- package/dist/aiChat/components/AiChatInput/AssetsSection.d.ts +7 -0
- package/dist/aiChat/components/AiChatInput/AttachButton.d.ts +10 -0
- package/dist/aiChat/components/AiChatInput/ContextSection.d.ts +5 -0
- package/dist/aiChat/components/AiChatInput/DictateButton.d.ts +7 -0
- package/dist/aiChat/components/AiChatInput/TextAreaWithAutoResize.d.ts +6 -0
- package/dist/aiChat/components/AiChatInput/constants.d.ts +6 -0
- package/dist/aiChat/components/AiChatInput/hooks/useSpeechToText.d.ts +15 -0
- package/dist/aiChat/components/AiChatInput/index.d.ts +37 -0
- package/dist/aiChat/components/AiChatLoadingState.d.ts +2 -1
- package/dist/aiChat/components/AiChatMessage.d.ts +21 -9
- package/dist/aiChat/components/AiChatMessages.d.ts +5 -7
- package/dist/aiChat/components/AiChatMessagesStatus.d.ts +5 -0
- package/dist/aiChat/components/AiChatPanel.d.ts +2 -3
- package/dist/aiChat/components/AiChatProvider.d.ts +14 -0
- package/dist/aiChat/components/MemoizedMarkdown.d.ts +9 -0
- package/dist/aiChat/components/index.d.ts +24 -25
- package/dist/aiChat/components/utils.d.ts +12 -4
- package/dist/aiChat/index.cjs.d.ts +5 -0
- package/dist/aiChat/index.cjs.js +453 -0
- package/dist/aiChat/index.d.ts +4 -3
- package/dist/aiChat/index.es.d.ts +5 -0
- package/dist/aiChat/index.es.js +30930 -0
- package/dist/aiChat/index.js +453 -0
- package/dist/aiChat/index.umd.js +453 -0
- package/dist/aiChat/locales/en.d.ts +64 -0
- package/dist/aiChat/server/index.cjs.d.ts +4 -0
- package/dist/aiChat/server/index.cjs.js +309 -0
- package/dist/aiChat/server/index.d.ts +0 -50
- package/dist/aiChat/server/index.es.d.ts +4 -0
- package/dist/aiChat/server/index.es.js +876 -0
- package/dist/aiChat/server/index.js +309 -0
- package/dist/aiChat/server/index.umd.js +309 -0
- package/dist/aiChat/server/stream.d.ts +0 -6
- package/dist/aiChat/server/tools.d.ts +157 -51
- package/dist/aiChat/server/types.d.ts +108 -64
- package/dist/aiChat/types.d.ts +148 -108
- package/dist/aiChat/typesSchema.d.ts +238 -25
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +174 -169
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +161 -156
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +113 -108
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +137 -132
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +4 -4
- package/dist/canvasGridMode/index.es.js +168 -163
- package/dist/canvasGridMode/index.umd.js +8 -8
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +132 -127
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +5 -5
- package/dist/dataSourceEjs/index.es.js +151 -146
- package/dist/dataSourceEjs/index.umd.js +5 -5
- package/dist/dataSourceHandlebars/index.cjs.js +4 -4
- package/dist/dataSourceHandlebars/index.es.js +91 -86
- package/dist/dataSourceHandlebars/index.umd.js +5 -5
- package/dist/dialogComponent/index.cjs.js +16 -16
- package/dist/dialogComponent/index.es.js +117 -112
- package/dist/dialogComponent/index.umd.js +16 -16
- package/dist/flexComponent/index.cjs.js +11 -11
- package/dist/flexComponent/index.es.js +416 -411
- package/dist/flexComponent/index.umd.js +11 -11
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +152 -147
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +127 -122
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +170 -165
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +27 -22
- package/dist/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +156 -151
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +197 -192
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +86 -81
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +121 -116
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +4 -4
- package/dist/presetPrintable/index.es.js +180 -175
- package/dist/presetPrintable/index.umd.js +4 -4
- package/dist/prosemirror/index.cjs.js +6 -6
- package/dist/prosemirror/index.es.js +128 -123
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +127 -122
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +160 -155
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +25 -25
- package/dist/shapeDividerComponent/index.es.js +127 -122
- package/dist/shapeDividerComponent/index.umd.js +25 -25
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +197 -192
- package/dist/swiperComponent/index.umd.js +9 -9
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +227 -222
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +12 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +124 -119
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +5 -2
- package/dist/aiChat/components/AiChatInput.d.ts +0 -17
- package/dist/aiChat/server/stream-utils.d.ts +0 -16
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const pt = "app.grapesjs.com", dt = "app-stage.grapesjs.com", St = "app2.grapesjs.com", yt = "app-stage2.grapesjs.com", st = [
|
|
2
|
+
pt,
|
|
3
|
+
St,
|
|
4
|
+
dt,
|
|
5
|
+
yt,
|
|
6
6
|
"localhost",
|
|
7
7
|
"127.0.0.1",
|
|
8
8
|
".local-credentialless.webcontainer.io",
|
|
@@ -11,114 +11,119 @@ const pe = "app.grapesjs.com", de = "app-stage.grapesjs.com", Se = "app2.grapesj
|
|
|
11
11
|
// For stackblitz.com demos
|
|
12
12
|
"-sandpack.codesandbox.io"
|
|
13
13
|
// For Sandpack demos
|
|
14
|
-
],
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
], bt = "license:check:start", Pt = "license:check:end", zt = () => typeof window < "u", Ct = ({
|
|
15
|
+
isDev: n,
|
|
16
|
+
isStage: t,
|
|
17
|
+
isPlatform: e
|
|
18
|
+
}) => `${n ? "" : `https://${t ? dt : pt}`}/${e ? "platform-api" : "api"}`, xt = () => {
|
|
19
|
+
const n = zt() && window.location.hostname;
|
|
20
|
+
return !!n && (st.includes(n) || st.some((t) => n.endsWith(t)));
|
|
17
21
|
};
|
|
18
|
-
function
|
|
22
|
+
function wt(n) {
|
|
19
23
|
return typeof n == "function";
|
|
20
24
|
}
|
|
21
|
-
async function
|
|
25
|
+
async function It({
|
|
22
26
|
path: n,
|
|
23
|
-
baseApiUrl:
|
|
24
|
-
method:
|
|
27
|
+
baseApiUrl: t,
|
|
28
|
+
method: e = "GET",
|
|
25
29
|
headers: s = {},
|
|
26
30
|
params: i,
|
|
27
31
|
body: a
|
|
28
32
|
}) {
|
|
29
|
-
const
|
|
30
|
-
method:
|
|
33
|
+
const c = `${t || Ct({ isDev: !1, isStage: !1 })}${n}`, p = {
|
|
34
|
+
method: e,
|
|
31
35
|
headers: {
|
|
32
36
|
"Content-Type": "application/json",
|
|
33
37
|
...s
|
|
34
38
|
}
|
|
35
39
|
};
|
|
36
|
-
a && (
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
39
|
-
throw new Error(`HTTP error! status: ${
|
|
40
|
-
return
|
|
40
|
+
a && (p.body = JSON.stringify(a));
|
|
41
|
+
const u = i ? new URLSearchParams(i).toString() : "", f = u ? `?${u}` : "", r = await fetch(`${c}${f}`, p);
|
|
42
|
+
if (!r.ok)
|
|
43
|
+
throw new Error(`HTTP error! status: ${r.status}`);
|
|
44
|
+
return r.json();
|
|
41
45
|
}
|
|
42
|
-
var
|
|
43
|
-
const
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
46
|
+
var A = /* @__PURE__ */ ((n) => (n.free = "free", n.startup = "startup", n.business = "business", n.enterprise = "enterprise", n))(A || {}), ut = /* @__PURE__ */ ((n) => (n.web = "web", n.email = "email", n.document = "document", n.react = "react", n))(ut || {});
|
|
47
|
+
const it = {
|
|
48
|
+
[A.free]: 0,
|
|
49
|
+
[A.startup]: 10,
|
|
50
|
+
[A.business]: 20,
|
|
51
|
+
[A.enterprise]: 30
|
|
48
52
|
};
|
|
49
|
-
function
|
|
50
|
-
const
|
|
51
|
-
return
|
|
53
|
+
function vt(n) {
|
|
54
|
+
const t = n;
|
|
55
|
+
return t.init = (e) => (s) => n(s, e), t;
|
|
52
56
|
}
|
|
53
|
-
const
|
|
54
|
-
async function
|
|
57
|
+
const Gt = (n) => /* @__PURE__ */ vt(n);
|
|
58
|
+
async function Et({
|
|
55
59
|
editor: n,
|
|
56
|
-
plan:
|
|
57
|
-
pluginName:
|
|
60
|
+
plan: t,
|
|
61
|
+
pluginName: e,
|
|
58
62
|
licenseKey: s,
|
|
59
|
-
|
|
63
|
+
onLicenseCheckResponse: i,
|
|
64
|
+
cleanup: a
|
|
60
65
|
}) {
|
|
61
|
-
let
|
|
62
|
-
const
|
|
63
|
-
console.warn("Cleanup plugin:",
|
|
64
|
-
},
|
|
65
|
-
var
|
|
66
|
-
const { error:
|
|
67
|
-
if (!(
|
|
68
|
-
|
|
69
|
-
else if (
|
|
70
|
-
const v =
|
|
71
|
-
v >
|
|
66
|
+
let o = "", c = !1;
|
|
67
|
+
const p = xt(), u = (r) => {
|
|
68
|
+
console.warn("Cleanup plugin:", e, "Reason:", r), a();
|
|
69
|
+
}, f = (r = {}) => {
|
|
70
|
+
var x;
|
|
71
|
+
const { error: g, sdkLicense: E } = r, S = (x = r.plan) == null ? void 0 : x.category;
|
|
72
|
+
if (!(E || r.license) || g)
|
|
73
|
+
u(g || "Invalid license");
|
|
74
|
+
else if (S) {
|
|
75
|
+
const v = it[t], b = it[S];
|
|
76
|
+
v > b && u({ pluginRequiredPlan: t, licensePlan: S });
|
|
72
77
|
}
|
|
73
78
|
};
|
|
74
|
-
n.on(
|
|
75
|
-
|
|
76
|
-
}), n.on(
|
|
77
|
-
|
|
79
|
+
n.on(bt, (r) => {
|
|
80
|
+
o = r == null ? void 0 : r.baseApiUrl, c = !0;
|
|
81
|
+
}), n.on(Pt, (r) => {
|
|
82
|
+
i == null || i(r), f(r);
|
|
78
83
|
}), setTimeout(async () => {
|
|
79
|
-
if (!
|
|
80
|
-
if (
|
|
84
|
+
if (!c) {
|
|
85
|
+
if (p) return;
|
|
81
86
|
if (s) {
|
|
82
|
-
const
|
|
83
|
-
|
|
87
|
+
const r = await Rt({ licenseKey: s, pluginName: e, baseApiUrl: o });
|
|
88
|
+
i == null || i(r), r && f(r);
|
|
84
89
|
} else
|
|
85
|
-
|
|
90
|
+
u("The `licenseKey` option not provided");
|
|
86
91
|
}
|
|
87
92
|
}, 2e3);
|
|
88
93
|
}
|
|
89
|
-
async function
|
|
90
|
-
const { licenseKey:
|
|
94
|
+
async function Rt(n) {
|
|
95
|
+
const { licenseKey: t, pluginName: e, baseApiUrl: s } = n;
|
|
91
96
|
try {
|
|
92
|
-
return (await
|
|
97
|
+
return (await It({
|
|
93
98
|
baseApiUrl: s,
|
|
94
|
-
path: `/sdk/${
|
|
99
|
+
path: `/sdk/${t || "na"}`,
|
|
95
100
|
method: "POST",
|
|
96
101
|
params: {
|
|
97
102
|
d: window.location.hostname,
|
|
98
|
-
pn:
|
|
103
|
+
pn: e
|
|
99
104
|
}
|
|
100
105
|
})).result || {};
|
|
101
106
|
} catch (i) {
|
|
102
107
|
return console.error("Error during SDK license check:", i), !1;
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
|
-
const
|
|
106
|
-
var
|
|
107
|
-
return ((
|
|
108
|
-
},
|
|
109
|
-
constructor(
|
|
110
|
-
this.config =
|
|
111
|
-
}
|
|
112
|
-
getSize(
|
|
113
|
-
var
|
|
114
|
-
return (
|
|
115
|
-
}
|
|
116
|
-
setSize(
|
|
117
|
-
var
|
|
118
|
-
if ((
|
|
119
|
-
this.config.setSize(
|
|
110
|
+
const ht = (n) => (t) => {
|
|
111
|
+
var e;
|
|
112
|
+
return ((e = t.getAttribute) == null ? void 0 : e.call(t, et)) === n;
|
|
113
|
+
}, Tt = (...n) => (t) => n.some((e) => t.is(e)), $t = (...n) => (t, e) => n.some((s) => e.is(s)), gt = "gjs-plg-", et = "data-type-role", N = class N {
|
|
114
|
+
constructor(t) {
|
|
115
|
+
this.config = t;
|
|
116
|
+
}
|
|
117
|
+
getSize(t) {
|
|
118
|
+
var e;
|
|
119
|
+
return (e = this.config) != null && e.getSize ? this.config.getSize(t) : nt(t.componentColumn, N.CSS_FLEX_BASIS);
|
|
120
|
+
}
|
|
121
|
+
setSize(t) {
|
|
122
|
+
var e;
|
|
123
|
+
if ((e = this.config) != null && e.setSize)
|
|
124
|
+
this.config.setSize(t);
|
|
120
125
|
else {
|
|
121
|
-
const { componentColumn: s, sizeValue: i, partial: a } =
|
|
126
|
+
const { componentColumn: s, sizeValue: i, partial: a } = t;
|
|
122
127
|
s.addStyle({ [N.CSS_FLEX_BASIS]: i }, { partial: a });
|
|
123
128
|
}
|
|
124
129
|
}
|
|
@@ -126,243 +131,243 @@ const he = (n) => (e) => {
|
|
|
126
131
|
N.CSS_FLEX_BASIS = "flex-basis";
|
|
127
132
|
let W = N;
|
|
128
133
|
const j = class j {
|
|
129
|
-
constructor(
|
|
130
|
-
this.config =
|
|
134
|
+
constructor(t) {
|
|
135
|
+
this.config = t;
|
|
131
136
|
}
|
|
132
137
|
isGapSupported() {
|
|
133
138
|
return !0;
|
|
134
139
|
}
|
|
135
|
-
getGap(
|
|
136
|
-
var
|
|
137
|
-
return (
|
|
140
|
+
getGap(t) {
|
|
141
|
+
var e;
|
|
142
|
+
return (e = this.config) != null && e.getGap ? this.config.getGap(t) : nt(t.componentRow, j.CSS_GAP);
|
|
138
143
|
}
|
|
139
|
-
setGap(
|
|
140
|
-
var
|
|
141
|
-
if ((
|
|
142
|
-
this.config.setGap(
|
|
144
|
+
setGap(t) {
|
|
145
|
+
var e;
|
|
146
|
+
if ((e = this.config) != null && e.setGap)
|
|
147
|
+
this.config.setGap(t);
|
|
143
148
|
else {
|
|
144
|
-
const { componentRow: s, gapValue: i, partial: a } =
|
|
149
|
+
const { componentRow: s, gapValue: i, partial: a } = t;
|
|
145
150
|
s.addStyle({ [j.CSS_GAP]: i }, { partial: a });
|
|
146
151
|
}
|
|
147
152
|
}
|
|
148
153
|
};
|
|
149
154
|
j.CSS_GAP = "gap";
|
|
150
155
|
let K = j;
|
|
151
|
-
const
|
|
152
|
-
constructor(
|
|
153
|
-
this.config =
|
|
156
|
+
const Y = class Y {
|
|
157
|
+
constructor(t) {
|
|
158
|
+
this.config = t;
|
|
154
159
|
}
|
|
155
|
-
getParentSize(
|
|
160
|
+
getParentSize(t) {
|
|
156
161
|
var a;
|
|
157
|
-
if ((a = this.config) != null && a.getParentSize) return this.config.getParentSize(
|
|
158
|
-
const { componentRow:
|
|
162
|
+
if ((a = this.config) != null && a.getParentSize) return this.config.getParentSize(t);
|
|
163
|
+
const { componentRow: e, isVertical: s } = t, i = e.getEl();
|
|
159
164
|
return i ? s ? i.clientHeight : i.clientWidth : 0;
|
|
160
165
|
}
|
|
161
|
-
isLayoutVertical(
|
|
166
|
+
isLayoutVertical(t) {
|
|
162
167
|
var s;
|
|
163
|
-
if ((s = this.config) != null && s.isParentVertical) return this.config.isParentVertical(
|
|
164
|
-
const
|
|
165
|
-
return
|
|
168
|
+
if ((s = this.config) != null && s.isParentVertical) return this.config.isParentVertical(t);
|
|
169
|
+
const e = nt(t.componentRow, Y.CSS_FLEX_DIRECTION, !0);
|
|
170
|
+
return e === "column" || e === "column-reverse";
|
|
166
171
|
}
|
|
167
172
|
};
|
|
168
|
-
|
|
169
|
-
let J =
|
|
173
|
+
Y.CSS_FLEX_DIRECTION = "flex-direction";
|
|
174
|
+
let J = Y;
|
|
170
175
|
const _ = class _ {
|
|
171
|
-
constructor(
|
|
172
|
-
this.config =
|
|
176
|
+
constructor(t) {
|
|
177
|
+
this.config = t;
|
|
173
178
|
}
|
|
174
|
-
getSize(
|
|
179
|
+
getSize(t) {
|
|
175
180
|
var s;
|
|
176
|
-
if ((s = this.config) != null && s.getSize) return this.config.getSize(
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
const a =
|
|
181
|
+
if ((s = this.config) != null && s.getSize) return this.config.getSize(t);
|
|
182
|
+
const e = t.componentColumn;
|
|
183
|
+
if (e.is(_.MJML_COLUMN_TYPE)) {
|
|
184
|
+
const a = e.getAttributes().width;
|
|
180
185
|
if (a && (a.includes("%") || !isNaN(parseFloat(a))))
|
|
181
186
|
return parseFloat(a);
|
|
182
|
-
const o =
|
|
187
|
+
const o = e.parent();
|
|
183
188
|
return 100 / (o ? o.components().length : 1);
|
|
184
189
|
}
|
|
185
190
|
return 0;
|
|
186
191
|
}
|
|
187
|
-
setSize(
|
|
188
|
-
var
|
|
189
|
-
if ((
|
|
190
|
-
this.config.setSize(
|
|
192
|
+
setSize(t) {
|
|
193
|
+
var e;
|
|
194
|
+
if ((e = this.config) != null && e.setSize)
|
|
195
|
+
this.config.setSize(t);
|
|
191
196
|
else {
|
|
192
|
-
const { componentColumn: s, sizeValue: i, partial: a } =
|
|
197
|
+
const { componentColumn: s, sizeValue: i, partial: a } = t;
|
|
193
198
|
s.is(_.MJML_COLUMN_TYPE) && s.addAttributes({ width: `${parseFloat(i)}%` }, { partial: a });
|
|
194
199
|
}
|
|
195
200
|
}
|
|
196
201
|
};
|
|
197
202
|
_.MJML_COLUMN_TYPE = "mj-column";
|
|
198
203
|
let q = _;
|
|
199
|
-
const
|
|
200
|
-
constructor(
|
|
201
|
-
this.config =
|
|
204
|
+
const U = class U {
|
|
205
|
+
constructor(t) {
|
|
206
|
+
this.config = t;
|
|
202
207
|
}
|
|
203
208
|
isGapSupported() {
|
|
204
209
|
return !1;
|
|
205
210
|
}
|
|
206
|
-
getGap(
|
|
211
|
+
getGap(t) {
|
|
207
212
|
var s;
|
|
208
|
-
if ((s = this.config) != null && s.getGap) return this.config.getGap(
|
|
209
|
-
const { componentRow:
|
|
210
|
-
if (
|
|
211
|
-
const i =
|
|
213
|
+
if ((s = this.config) != null && s.getGap) return this.config.getGap(t);
|
|
214
|
+
const { componentRow: e } = t;
|
|
215
|
+
if (e.is(U.MJML_SECTION_TYPE)) {
|
|
216
|
+
const i = e.getAttributes();
|
|
212
217
|
if (i && i.padding)
|
|
213
218
|
return parseInt(i.padding, 10) || 0;
|
|
214
219
|
}
|
|
215
220
|
return 0;
|
|
216
221
|
}
|
|
217
|
-
setGap(
|
|
218
|
-
var
|
|
219
|
-
(s = (
|
|
222
|
+
setGap(t) {
|
|
223
|
+
var e, s;
|
|
224
|
+
(s = (e = this.config) == null ? void 0 : e.setGap) == null || s.call(e, t);
|
|
220
225
|
}
|
|
221
226
|
};
|
|
222
|
-
|
|
223
|
-
let Z =
|
|
224
|
-
class
|
|
225
|
-
constructor(
|
|
226
|
-
this.config =
|
|
227
|
+
U.MJML_SECTION_TYPE = "mj-section";
|
|
228
|
+
let Z = U;
|
|
229
|
+
class At {
|
|
230
|
+
constructor(t) {
|
|
231
|
+
this.config = t;
|
|
227
232
|
}
|
|
228
|
-
getParentSize(
|
|
233
|
+
getParentSize(t) {
|
|
229
234
|
var o;
|
|
230
|
-
if ((o = this.config) != null && o.getParentSize) return this.config.getParentSize(
|
|
231
|
-
const { componentRow:
|
|
235
|
+
if ((o = this.config) != null && o.getParentSize) return this.config.getParentSize(t);
|
|
236
|
+
const { componentRow: e, isVertical: s } = t, i = e.getEl();
|
|
232
237
|
if (!i) return 0;
|
|
233
238
|
let a = i;
|
|
234
239
|
if (i.tagName !== "TABLE") {
|
|
235
|
-
const
|
|
236
|
-
|
|
240
|
+
const c = i.querySelectorAll("table");
|
|
241
|
+
c.length && (a = c[0]);
|
|
237
242
|
}
|
|
238
243
|
return s ? a.clientHeight : a.clientWidth;
|
|
239
244
|
}
|
|
240
|
-
isLayoutVertical(
|
|
241
|
-
var
|
|
242
|
-
return (
|
|
245
|
+
isLayoutVertical(t) {
|
|
246
|
+
var e;
|
|
247
|
+
return (e = this.config) != null && e.isParentVertical ? this.config.isParentVertical(t) : !1;
|
|
243
248
|
}
|
|
244
249
|
}
|
|
245
|
-
class
|
|
250
|
+
class H {
|
|
246
251
|
constructor() {
|
|
247
252
|
this.handlerCache = /* @__PURE__ */ new Map();
|
|
248
253
|
}
|
|
249
254
|
static getInstance() {
|
|
250
|
-
return
|
|
251
|
-
}
|
|
252
|
-
getHandlers(
|
|
253
|
-
const
|
|
254
|
-
return this.handlerCache.has(
|
|
255
|
-
sizeHandler: new q(
|
|
256
|
-
gapHandler: new Z(
|
|
257
|
-
parentSizeHandler: new
|
|
258
|
-
}) : this.handlerCache.set(
|
|
259
|
-
sizeHandler: new W(
|
|
260
|
-
gapHandler: new K(
|
|
261
|
-
parentSizeHandler: new J(
|
|
262
|
-
})), this.handlerCache.get(
|
|
255
|
+
return H.instance || (H.instance = new H()), H.instance;
|
|
256
|
+
}
|
|
257
|
+
getHandlers(t) {
|
|
258
|
+
const e = `${t.projectType}-${t.disableGapHandler ? "nogap" : "gap"}`;
|
|
259
|
+
return this.handlerCache.has(e) || (M(t) ? this.handlerCache.set(e, {
|
|
260
|
+
sizeHandler: new q(t),
|
|
261
|
+
gapHandler: new Z(t),
|
|
262
|
+
parentSizeHandler: new At(t)
|
|
263
|
+
}) : this.handlerCache.set(e, {
|
|
264
|
+
sizeHandler: new W(t),
|
|
265
|
+
gapHandler: new K(t),
|
|
266
|
+
parentSizeHandler: new J(t)
|
|
267
|
+
})), this.handlerCache.get(e);
|
|
263
268
|
}
|
|
264
269
|
}
|
|
265
|
-
function
|
|
266
|
-
return
|
|
270
|
+
function R(n) {
|
|
271
|
+
return H.getInstance().getHandlers(n);
|
|
267
272
|
}
|
|
268
|
-
const
|
|
273
|
+
const at = (n) => {
|
|
269
274
|
n.style.display = "none";
|
|
270
|
-
},
|
|
275
|
+
}, ot = (n) => {
|
|
271
276
|
n.style.display = "block";
|
|
272
|
-
},
|
|
273
|
-
const
|
|
274
|
-
return
|
|
275
|
-
},
|
|
276
|
-
const
|
|
277
|
-
if (!
|
|
278
|
-
const
|
|
279
|
-
return
|
|
280
|
-
},
|
|
281
|
-
const
|
|
282
|
-
if (!
|
|
283
|
-
const
|
|
284
|
-
return
|
|
285
|
-
},
|
|
286
|
-
const a = n + (
|
|
277
|
+
}, L = (n) => +parseFloat(`${n}`).toFixed(2), M = (n) => n.projectType === ut.email, Ht = (n) => n ? ["top", "bottom"] : ["left", "right"], Mt = (n) => {
|
|
278
|
+
const t = n.parent();
|
|
279
|
+
return t ? t.components().models.indexOf(n) === 0 : !1;
|
|
280
|
+
}, Lt = (n) => {
|
|
281
|
+
const t = n.parent();
|
|
282
|
+
if (!t) return !1;
|
|
283
|
+
const e = t.components().models;
|
|
284
|
+
return e.indexOf(n) === e.length - 1;
|
|
285
|
+
}, Vt = (n) => {
|
|
286
|
+
const t = n.parent();
|
|
287
|
+
if (!t) return !1;
|
|
288
|
+
const e = t.components().models;
|
|
289
|
+
return e.length > 1 && n.index() === e.length - 1;
|
|
290
|
+
}, Nt = (n, t, e, s) => {
|
|
291
|
+
const a = n + (e ? t === "top" ? -1 : t === "bottom" ? 1 : 0 : t === "left" ? -1 : t === "right" ? 1 : 0);
|
|
287
292
|
return a >= 0 && a < s ? a : -1;
|
|
288
|
-
},
|
|
289
|
-
const
|
|
290
|
-
return
|
|
291
|
-
},
|
|
292
|
-
const s = !
|
|
293
|
+
}, O = (n) => n === "top" || n === "bottom", jt = (n, t) => !!(Mt(n) && (t === "left" || t === "top") || Lt(n) && (t === "right" || t === "bottom")), _t = (n) => {
|
|
294
|
+
const t = n.parent();
|
|
295
|
+
return t ? t.components().models.length > 1 : !1;
|
|
296
|
+
}, rt = (n, t) => n === "right" || n === "bottom" ? t > 0 : t < 0, nt = (n, t, e = !1) => {
|
|
297
|
+
const s = !e, i = n.getEl();
|
|
293
298
|
if (!i)
|
|
294
299
|
return s ? 0 : "";
|
|
295
|
-
const o = window.getComputedStyle(i)[
|
|
300
|
+
const o = window.getComputedStyle(i)[t] || "";
|
|
296
301
|
if (s) {
|
|
297
|
-
let
|
|
298
|
-
return typeof o == "string" ? (
|
|
302
|
+
let c;
|
|
303
|
+
return typeof o == "string" ? (c = parseFloat(o.replace(/[^-\d.]/g, "")), isNaN(c) && (c = 0)) : c = Number(o) || 0, c;
|
|
299
304
|
}
|
|
300
305
|
return o;
|
|
301
|
-
},
|
|
302
|
-
const s = Q({ componentRow: n, isVertical:
|
|
306
|
+
}, lt = (n, t, e) => {
|
|
307
|
+
const s = Q({ componentRow: n, isVertical: t }, e), i = n.components().models;
|
|
303
308
|
return s * (i.length - 1);
|
|
304
|
-
}, D = (n,
|
|
305
|
-
if (
|
|
306
|
-
const { gapHandler:
|
|
307
|
-
if (!
|
|
308
|
-
const i =
|
|
309
|
+
}, D = (n, t) => R(t).parentSizeHandler.isLayoutVertical({ componentRow: n }), B = (n, t) => R(t).sizeHandler.getSize(n), Q = (n, t) => {
|
|
310
|
+
if (t != null && t.disableGapHandler) return 0;
|
|
311
|
+
const { gapHandler: e, parentSizeHandler: s } = R(t);
|
|
312
|
+
if (!e.isGapSupported()) return 0;
|
|
313
|
+
const i = e.getGap(n), a = s.getParentSize(n);
|
|
309
314
|
return i / 100 * a;
|
|
310
|
-
},
|
|
311
|
-
|
|
312
|
-
},
|
|
313
|
-
const
|
|
314
|
-
V({ ...n, sizeValue: `${
|
|
315
|
-
},
|
|
316
|
-
if (
|
|
317
|
-
const { gapHandler:
|
|
318
|
-
|
|
319
|
-
},
|
|
320
|
-
const
|
|
321
|
-
if (!
|
|
322
|
-
const s = n.components().models, i = { componentRow: n, isVertical: D(n,
|
|
323
|
-
s.map((a) =>
|
|
315
|
+
}, tt = (n, t) => R(t).parentSizeHandler.getParentSize(n), V = (n, t) => {
|
|
316
|
+
R(t).sizeHandler.setSize(n);
|
|
317
|
+
}, ft = (n, t) => {
|
|
318
|
+
const e = B(n, t);
|
|
319
|
+
V({ ...n, sizeValue: `${e}%`, partial: !1 }, t);
|
|
320
|
+
}, mt = (n, t) => {
|
|
321
|
+
if (t != null && t.disableGapHandler) return;
|
|
322
|
+
const { gapHandler: e } = R(t);
|
|
323
|
+
e.isGapSupported() && e.setGap(n);
|
|
324
|
+
}, Dt = (n, t) => {
|
|
325
|
+
const e = n.getStyle().gap;
|
|
326
|
+
if (!e) return;
|
|
327
|
+
const s = n.components().models, i = { componentRow: n, isVertical: D(n, t) };
|
|
328
|
+
s.map((a) => ft({ ...i, componentColumn: a }, t)), mt({ ...i, gapValue: String(e), partial: !1 }, t);
|
|
324
329
|
};
|
|
325
|
-
function
|
|
326
|
-
const { Blocks:
|
|
327
|
-
if (a === !1 ||
|
|
328
|
-
const o = (
|
|
330
|
+
function Bt(n, t) {
|
|
331
|
+
const { Blocks: e } = n, { typeColumn: s, typeRow: i, blocks: a } = t;
|
|
332
|
+
if (a === !1 || M(t)) return;
|
|
333
|
+
const o = (r) => ({
|
|
329
334
|
type: i,
|
|
330
|
-
components:
|
|
335
|
+
components: r.map((g) => ({
|
|
331
336
|
type: s,
|
|
332
|
-
style: { "flex-basis": `${
|
|
337
|
+
style: { "flex-basis": `${g}%` }
|
|
333
338
|
}))
|
|
334
|
-
}),
|
|
335
|
-
${
|
|
336
|
-
</div>`,
|
|
337
|
-
id: `flex-row-${
|
|
338
|
-
label:
|
|
339
|
+
}), c = (r) => `<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
|
|
340
|
+
${r.map((g) => `<div style="flex-basis: ${g}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
|
|
341
|
+
</div>`, p = (r, g) => ({
|
|
342
|
+
id: `flex-row-${g.join("-")}`,
|
|
343
|
+
label: r,
|
|
339
344
|
category: "Layout",
|
|
340
345
|
select: !0,
|
|
341
346
|
full: !0,
|
|
342
347
|
attributes: { class: "gs-block-item__flex gs-utl-w-full" },
|
|
343
|
-
media:
|
|
344
|
-
content: o(
|
|
345
|
-
}),
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
],
|
|
357
|
-
return
|
|
358
|
-
|
|
348
|
+
media: c(g),
|
|
349
|
+
content: o(g)
|
|
350
|
+
}), u = [
|
|
351
|
+
p("1 Column", [100]),
|
|
352
|
+
p("2 Columns 50/50", [50, 50]),
|
|
353
|
+
p("2 Columns 25/75", [25, 75]),
|
|
354
|
+
p("2 Columns 75/25", [75, 25]),
|
|
355
|
+
p("3 Columns", [33.33, 33.33, 33.33]),
|
|
356
|
+
p("3 Columns 50/25/25", [50, 25, 25]),
|
|
357
|
+
p("3 Columns 25/50/25", [25, 50, 25]),
|
|
358
|
+
p("3 Columns 25/25/50", [25, 25, 50]),
|
|
359
|
+
p("4 Columns", [25, 25, 25, 25]),
|
|
360
|
+
p("5 Columns", [20, 20, 20, 20, 20])
|
|
361
|
+
], f = wt(a) ? a({ blocks: u }) : u;
|
|
362
|
+
return f.forEach((r) => e.add(r.id, r)), () => {
|
|
363
|
+
f.forEach((r) => e.remove(r.id));
|
|
359
364
|
};
|
|
360
365
|
}
|
|
361
|
-
const
|
|
362
|
-
const { Components:
|
|
363
|
-
if (!(!i ||
|
|
364
|
-
return
|
|
365
|
-
isComponent:
|
|
366
|
+
const Ft = (n, t) => {
|
|
367
|
+
const { Components: e } = n, { typeRow: s, typeColumn: i, extendTypeColumn: a } = t, o = `${gt}${i}`, p = !!i && !!e.getType(i) && !a;
|
|
368
|
+
if (!(!i || p || M(t)))
|
|
369
|
+
return e.addType(i, {
|
|
370
|
+
isComponent: ht(i),
|
|
366
371
|
model: {
|
|
367
372
|
defaults: {
|
|
368
373
|
name: "Column",
|
|
@@ -370,8 +375,8 @@ const Fe = (n, e) => {
|
|
|
370
375
|
emptyState: !0,
|
|
371
376
|
classes: o,
|
|
372
377
|
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>',
|
|
373
|
-
draggable:
|
|
374
|
-
attributes: { [
|
|
378
|
+
draggable: $t(s),
|
|
379
|
+
attributes: { [et]: i },
|
|
375
380
|
styles: `
|
|
376
381
|
.${o} {
|
|
377
382
|
flex-grow: 1;
|
|
@@ -380,21 +385,21 @@ const Fe = (n, e) => {
|
|
|
380
385
|
}
|
|
381
386
|
}
|
|
382
387
|
}), () => {
|
|
383
|
-
|
|
388
|
+
e.removeType(i);
|
|
384
389
|
};
|
|
385
|
-
},
|
|
386
|
-
const { Components:
|
|
387
|
-
if (!(!s ||
|
|
388
|
-
return
|
|
389
|
-
isComponent:
|
|
390
|
+
}, Ot = (n, t) => {
|
|
391
|
+
const { Components: e } = n, { typeRow: s, typeColumn: i, extendTypeRow: a } = t, o = `${gt}${s}`, p = !!s && !!e.getType(s) && !a;
|
|
392
|
+
if (!(!s || p || M(t)))
|
|
393
|
+
return e.addType(s, {
|
|
394
|
+
isComponent: ht(s),
|
|
390
395
|
model: {
|
|
391
396
|
defaults: {
|
|
392
397
|
name: "Row",
|
|
393
398
|
classes: o,
|
|
394
399
|
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>',
|
|
395
400
|
emptyState: { styleIn: "width: 100%" },
|
|
396
|
-
attributes: { [
|
|
397
|
-
droppable:
|
|
401
|
+
attributes: { [et]: s },
|
|
402
|
+
droppable: Tt(i),
|
|
398
403
|
traits: [
|
|
399
404
|
// {
|
|
400
405
|
// type: 'number',
|
|
@@ -418,7 +423,7 @@ const Fe = (n, e) => {
|
|
|
418
423
|
type: "checkbox",
|
|
419
424
|
name: "snap",
|
|
420
425
|
label: "Enable Snap",
|
|
421
|
-
default:
|
|
426
|
+
default: t.snapEnabled,
|
|
422
427
|
changeProp: !0
|
|
423
428
|
},
|
|
424
429
|
{
|
|
@@ -428,7 +433,7 @@ const Fe = (n, e) => {
|
|
|
428
433
|
min: 1,
|
|
429
434
|
max: 12,
|
|
430
435
|
step: 1,
|
|
431
|
-
default:
|
|
436
|
+
default: t.snapDivisions,
|
|
432
437
|
changeProp: !0
|
|
433
438
|
}
|
|
434
439
|
],
|
|
@@ -450,163 +455,163 @@ const Fe = (n, e) => {
|
|
|
450
455
|
}
|
|
451
456
|
}
|
|
452
457
|
}), () => {
|
|
453
|
-
|
|
458
|
+
e.removeType(s);
|
|
454
459
|
};
|
|
455
|
-
},
|
|
456
|
-
class
|
|
460
|
+
}, Xt = "flexComponent", Yt = A.startup;
|
|
461
|
+
class Ut {
|
|
457
462
|
constructor() {
|
|
458
463
|
this.resizableChildTypes = /* @__PURE__ */ new Set(), this.gapAdjustableParentTypes = /* @__PURE__ */ new Set(), this.typeRelationships = /* @__PURE__ */ new Map();
|
|
459
464
|
}
|
|
460
|
-
registerResizableChild(
|
|
461
|
-
this.resizableChildTypes.add(
|
|
465
|
+
registerResizableChild(t) {
|
|
466
|
+
this.resizableChildTypes.add(t);
|
|
462
467
|
}
|
|
463
|
-
registerGapAdjustableParent(
|
|
464
|
-
this.gapAdjustableParentTypes.add(
|
|
468
|
+
registerGapAdjustableParent(t) {
|
|
469
|
+
this.gapAdjustableParentTypes.add(t);
|
|
465
470
|
}
|
|
466
|
-
registerTypeRelationship(
|
|
467
|
-
this.typeRelationships.has(
|
|
471
|
+
registerTypeRelationship(t, e) {
|
|
472
|
+
this.typeRelationships.has(t) || this.typeRelationships.set(t, /* @__PURE__ */ new Set()), this.typeRelationships.get(t).add(e), this.registerResizableChild(e), this.registerGapAdjustableParent(t);
|
|
468
473
|
}
|
|
469
|
-
isResizableChild(
|
|
470
|
-
return this.resizableChildTypes.has(
|
|
474
|
+
isResizableChild(t) {
|
|
475
|
+
return this.resizableChildTypes.has(t.get("type"));
|
|
471
476
|
}
|
|
472
|
-
isGapAdjustableParent(
|
|
473
|
-
return this.gapAdjustableParentTypes.has(
|
|
477
|
+
isGapAdjustableParent(t) {
|
|
478
|
+
return this.gapAdjustableParentTypes.has(t.get("type"));
|
|
474
479
|
}
|
|
475
|
-
isValidRelationship(
|
|
476
|
-
const s =
|
|
480
|
+
isValidRelationship(t, e) {
|
|
481
|
+
const s = t.get("type"), i = e.get("type");
|
|
477
482
|
return this.typeRelationships.has(s) ? this.typeRelationships.get(s).has(i) : !1;
|
|
478
483
|
}
|
|
479
484
|
}
|
|
480
|
-
class
|
|
481
|
-
constructor(
|
|
482
|
-
this.editor =
|
|
485
|
+
class kt {
|
|
486
|
+
constructor(t, e, s) {
|
|
487
|
+
this.editor = t, this.registry = e, this.opts = s, this.resizeState = /* @__PURE__ */ new WeakMap();
|
|
483
488
|
}
|
|
484
|
-
getState(
|
|
485
|
-
return this.resizeState.has(
|
|
489
|
+
getState(t) {
|
|
490
|
+
return this.resizeState.has(t) || this.resizeState.set(t, {}), this.resizeState.get(t);
|
|
486
491
|
}
|
|
487
|
-
clearState(
|
|
488
|
-
return this.resizeState.delete(
|
|
492
|
+
clearState(t) {
|
|
493
|
+
return this.resizeState.delete(t);
|
|
489
494
|
}
|
|
490
|
-
startResize(
|
|
491
|
-
const { opts: i } = this, a = this.getState(
|
|
492
|
-
a.direction =
|
|
493
|
-
const o =
|
|
494
|
-
if (!o || !this.registry.isValidRelationship(o,
|
|
495
|
+
startResize(t, e, s) {
|
|
496
|
+
const { opts: i } = this, a = this.getState(t);
|
|
497
|
+
a.direction = e, a.startX = s.clientX, a.startY = s.clientY, a.resizing = !0, a.lastSnappedPercent = void 0;
|
|
498
|
+
const o = t.parent();
|
|
499
|
+
if (!o || !this.registry.isValidRelationship(o, t)) return;
|
|
495
500
|
a.snapEnabled = o.get("snap") ?? i.snapEnabled, a.snapDivisions = o.get("snap-divisions") ?? i.snapDivisions ?? 12;
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
const
|
|
499
|
-
if (a.startPercent = B(
|
|
500
|
-
const
|
|
501
|
-
a.neighborStartPercent = B({ ...
|
|
501
|
+
const c = o.components().models, p = c.findIndex((g) => g.cid === t.cid), u = D(o, i), f = Nt(p, e, u, c.length);
|
|
502
|
+
f !== -1 && (a.adjacentIdx = f);
|
|
503
|
+
const r = { componentColumn: t, componentRow: o, isVertical: u };
|
|
504
|
+
if (a.startPercent = B(r, i), typeof a.adjacentIdx < "u") {
|
|
505
|
+
const g = c[a.adjacentIdx];
|
|
506
|
+
a.neighborStartPercent = B({ ...r, componentColumn: g }, i);
|
|
502
507
|
}
|
|
503
508
|
}
|
|
504
|
-
updateResizeByDelta(
|
|
505
|
-
const i = this.getState(
|
|
506
|
-
!i.resizing || !a || (i.snapEnabled ? this.updateSnapResize(
|
|
509
|
+
updateResizeByDelta(t, e, s) {
|
|
510
|
+
const i = this.getState(t), a = t.parent();
|
|
511
|
+
!i.resizing || !a || (i.snapEnabled ? this.updateSnapResize(t, e, s) : this.updateContinuesResize(t, e, s));
|
|
507
512
|
}
|
|
508
|
-
finishResize(
|
|
509
|
-
const
|
|
510
|
-
s == null || s.forEach((a) =>
|
|
513
|
+
finishResize(t) {
|
|
514
|
+
const e = t.parent(), s = e == null ? void 0 : e.components().models, i = { componentRow: e, isVertical: !!e && D(e, this.opts) };
|
|
515
|
+
s == null || s.forEach((a) => ft({ ...i, componentColumn: a }, this.opts)), this.clearState(t);
|
|
511
516
|
}
|
|
512
|
-
updateContinuesResize(
|
|
513
|
-
const i = this.getState(
|
|
517
|
+
updateContinuesResize(t, e, s) {
|
|
518
|
+
const i = this.getState(t), a = t.parent(), { opts: o } = this;
|
|
514
519
|
if (!a) return;
|
|
515
|
-
const
|
|
520
|
+
const c = o.minItemPercent ?? 0, p = O(e), u = tt({ componentRow: a, isVertical: p }, o), f = lt(a, p, this.opts), g = 100 - f / u * 100, E = s / (u - f) * g, { startPercent: S = 0, neighborStartPercent: C = 0 } = i, x = { componentRow: a, isVertical: p, componentColumn: t, partial: !0 }, v = rt(e, s) ? S + Math.abs(E) : S - Math.abs(E);
|
|
516
521
|
if (typeof i.adjacentIdx < "u") {
|
|
517
|
-
const
|
|
518
|
-
V({ ...
|
|
519
|
-
{ ...
|
|
522
|
+
const b = a.components().models[i.adjacentIdx], w = S + C, P = w - c, l = Math.min(P, Math.max(c, v)), d = w - l;
|
|
523
|
+
V({ ...x, sizeValue: `${L(l)}%` }, o), V(
|
|
524
|
+
{ ...x, componentColumn: b, sizeValue: `${L(d)}%` },
|
|
520
525
|
o
|
|
521
526
|
);
|
|
522
527
|
} else {
|
|
523
|
-
const
|
|
524
|
-
V({ ...
|
|
528
|
+
const b = Math.max(c, Math.min(g, v));
|
|
529
|
+
V({ ...x, sizeValue: `${L(b)}%` }, o);
|
|
525
530
|
}
|
|
526
531
|
}
|
|
527
|
-
updateSnapResize(
|
|
528
|
-
const i = this.getState(
|
|
529
|
-
if (
|
|
530
|
-
i.lastSnappedPercent =
|
|
531
|
-
let m = Math.abs(
|
|
532
|
-
(
|
|
533
|
-
} else
|
|
532
|
+
updateSnapResize(t, e, s) {
|
|
533
|
+
const i = this.getState(t), a = t.parent(), o = O(e), c = tt({ componentRow: a, isVertical: o }, this.opts), p = lt(a, o, this.opts), u = c - p, f = s / u * 100, r = rt(e, s), { startPercent: g = 0, snapDivisions: E = 12 } = i, S = r ? g + Math.abs(f) : g - Math.abs(f), C = 100 / E, x = Math.floor(S / C) * C, v = Math.ceil(S / C) * C, b = Math.abs(v - S), w = Math.abs(S - x), P = C * 0.2, z = b < w ? v : x;
|
|
534
|
+
if (z > 0 && z < 100 && (b < P || w < P) && i.lastSnappedPercent !== z) {
|
|
535
|
+
i.lastSnappedPercent = z;
|
|
536
|
+
let m = Math.abs(z - g) / 100 * u;
|
|
537
|
+
(r && (e === "left" || e === "top") || !r && (e === "right" || e === "bottom")) && (m = -m), this.updateContinuesResize(t, e, m);
|
|
538
|
+
} else b >= P && w >= P && (i.lastSnappedPercent = void 0);
|
|
534
539
|
}
|
|
535
540
|
}
|
|
536
|
-
class
|
|
537
|
-
constructor(
|
|
538
|
-
this.editor =
|
|
539
|
-
}
|
|
540
|
-
updateGapByDelta(
|
|
541
|
-
if (!this.registry.isGapAdjustableParent(
|
|
542
|
-
const { opts: a } = this, o = Math.max(0, s +
|
|
543
|
-
(
|
|
541
|
+
class Wt {
|
|
542
|
+
constructor(t, e, s) {
|
|
543
|
+
this.editor = t, this.registry = e, this.opts = s;
|
|
544
|
+
}
|
|
545
|
+
updateGapByDelta(t, e, s, i) {
|
|
546
|
+
if (!this.registry.isGapAdjustableParent(t)) return;
|
|
547
|
+
const { opts: a } = this, o = Math.max(0, s + e), c = tt({ componentRow: t, isVertical: i }, a), p = o / c * 100, u = t.components().models, f = u.length - 1, r = { componentRow: t, isVertical: i }, g = u.reduce(
|
|
548
|
+
(P, z) => P + B({ ...r, componentColumn: z }, a),
|
|
544
549
|
0
|
|
545
|
-
),
|
|
546
|
-
if (
|
|
550
|
+
), S = 100 - p * f, C = a.minItemPercent || 5;
|
|
551
|
+
if (S < C * u.length)
|
|
547
552
|
return;
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
const
|
|
551
|
-
V({ ...
|
|
552
|
-
}),
|
|
553
|
+
const v = 100 - f * p, b = g - v, w = { componentRow: t, isVertical: i, partial: !0 };
|
|
554
|
+
u.map((P) => {
|
|
555
|
+
const z = B({ ...r, componentColumn: P }, a), l = z - z / g * b;
|
|
556
|
+
V({ ...w, componentColumn: P, sizeValue: `${L(l)}%` }, a);
|
|
557
|
+
}), mt({ ...w, gapValue: `${L(p)}%` }, a);
|
|
553
558
|
}
|
|
554
|
-
finishGapAdjust(
|
|
555
|
-
|
|
559
|
+
finishGapAdjust(t) {
|
|
560
|
+
Dt(t, this.opts);
|
|
556
561
|
}
|
|
557
562
|
}
|
|
558
|
-
class
|
|
559
|
-
constructor(
|
|
560
|
-
this.editor =
|
|
563
|
+
class Kt {
|
|
564
|
+
constructor(t, e, s) {
|
|
565
|
+
this.editor = t, this.registry = e, this.opts = s, this.resizeHandler = new kt(t, e, s), this.gapHandler = new Wt(t, e, s);
|
|
561
566
|
}
|
|
562
|
-
startResize(
|
|
563
|
-
this.resizeHandler.startResize(
|
|
567
|
+
startResize(t, e, s) {
|
|
568
|
+
this.resizeHandler.startResize(t, e, s);
|
|
564
569
|
}
|
|
565
|
-
updateResizeByDelta(
|
|
566
|
-
this.resizeHandler.updateResizeByDelta(
|
|
570
|
+
updateResizeByDelta(t, e, s) {
|
|
571
|
+
this.resizeHandler.updateResizeByDelta(t, e, s);
|
|
567
572
|
}
|
|
568
|
-
finishResize(
|
|
569
|
-
this.resizeHandler.finishResize(
|
|
573
|
+
finishResize(t) {
|
|
574
|
+
this.resizeHandler.finishResize(t);
|
|
570
575
|
}
|
|
571
|
-
updateGapByDelta(
|
|
572
|
-
this.gapHandler.updateGapByDelta(
|
|
576
|
+
updateGapByDelta(t, e, s, i) {
|
|
577
|
+
this.gapHandler.updateGapByDelta(t, e, s, i);
|
|
573
578
|
}
|
|
574
|
-
finishGapAdjust(
|
|
575
|
-
this.gapHandler.finishGapAdjust(
|
|
579
|
+
finishGapAdjust(t) {
|
|
580
|
+
this.gapHandler.finishGapAdjust(t);
|
|
576
581
|
}
|
|
577
|
-
canResize(
|
|
578
|
-
const
|
|
579
|
-
return
|
|
582
|
+
canResize(t) {
|
|
583
|
+
const e = t.parent();
|
|
584
|
+
return e ? this.registry.isValidRelationship(e, t) : !1;
|
|
580
585
|
}
|
|
581
|
-
canAdjustGap(
|
|
582
|
-
return this.registry.isGapAdjustableParent(
|
|
586
|
+
canAdjustGap(t) {
|
|
587
|
+
return this.registry.isGapAdjustableParent(t);
|
|
583
588
|
}
|
|
584
589
|
}
|
|
585
|
-
const
|
|
586
|
-
function
|
|
587
|
-
const { Canvas:
|
|
588
|
-
let i, a, o,
|
|
589
|
-
const
|
|
590
|
-
var
|
|
591
|
-
i = document.createElement("div"), i.className =
|
|
590
|
+
const X = "gs-flex-spots", ct = `${X}__handle-size`, Jt = `${X}__handle-gap`;
|
|
591
|
+
function qt(n, t) {
|
|
592
|
+
const { Canvas: e } = n, s = "flex-resize-spot";
|
|
593
|
+
let i, a, o, c, p = null, u = null;
|
|
594
|
+
const f = new Ut(), r = new Kt(n, f, t), g = () => {
|
|
595
|
+
var l;
|
|
596
|
+
i = document.createElement("div"), i.className = X, i.style.display = "none", a = document.createElement("div"), a.className = `${X}__handles`, a.style.position = "absolute", a.style.pointerEvents = "none", a.style.zIndex = "21", o = {
|
|
592
597
|
left: document.createElement("div"),
|
|
593
598
|
right: document.createElement("div"),
|
|
594
599
|
top: document.createElement("div"),
|
|
595
600
|
bottom: document.createElement("div")
|
|
596
601
|
}, Object.entries(o).forEach(([d, m]) => {
|
|
597
|
-
const
|
|
598
|
-
m.className = `${
|
|
602
|
+
const y = d, h = O(y);
|
|
603
|
+
m.className = `${ct} ${ct}-${y} gjs-resizer-h gjs-cv-unscale`, m.style.cssText = `
|
|
599
604
|
pointer-events: all;
|
|
600
605
|
position: absolute;
|
|
601
606
|
z-index: 1;
|
|
602
607
|
cursor: ${h ? "ns-resize" : "ew-resize"};
|
|
603
608
|
${h ? "left: 50%;" : "top: 50%;"}
|
|
604
|
-
${
|
|
605
|
-
${
|
|
606
|
-
${
|
|
607
|
-
${
|
|
608
|
-
`, m.addEventListener("pointerdown",
|
|
609
|
-
}), !
|
|
609
|
+
${y === "left" ? "left: 0px;" : ""}
|
|
610
|
+
${y === "right" ? "right: 0px;" : ""}
|
|
611
|
+
${y === "top" ? "top: 0px;" : ""}
|
|
612
|
+
${y === "bottom" ? "bottom: 0px;" : ""}
|
|
613
|
+
`, m.addEventListener("pointerdown", E(y)), a.appendChild(m);
|
|
614
|
+
}), !t.disableGapHandler && !M(t) && (c = document.createElement("div"), c.className = Jt, c.style.cssText = `
|
|
610
615
|
position: absolute;
|
|
611
616
|
background-color: var(--gs-theme-cl-cmp-bg1, #3b97e3);
|
|
612
617
|
border-width: 2px;
|
|
@@ -616,98 +621,98 @@ function qe(n, e) {
|
|
|
616
621
|
pointer-events: all;
|
|
617
622
|
max-width: 3rem;
|
|
618
623
|
max-height: 3rem;
|
|
619
|
-
`,
|
|
620
|
-
},
|
|
621
|
-
if (!
|
|
622
|
-
d.stopPropagation(), d.preventDefault(),
|
|
623
|
-
const m = d.clientX,
|
|
624
|
+
`, c.addEventListener("pointerdown", S()), a.appendChild(c)), i.append(a), (l = e.getSpotsEl()) == null || l.appendChild(i);
|
|
625
|
+
}, E = (l) => (d) => {
|
|
626
|
+
if (!p) return;
|
|
627
|
+
d.stopPropagation(), d.preventDefault(), r.startResize(p, l, d);
|
|
628
|
+
const m = d.clientX, y = d.clientY;
|
|
624
629
|
d.target.setPointerCapture(d.pointerId);
|
|
625
630
|
const h = (T) => {
|
|
626
|
-
const G = n.Canvas.getZoomMultiplier(),
|
|
627
|
-
|
|
628
|
-
},
|
|
629
|
-
|
|
631
|
+
const G = n.Canvas.getZoomMultiplier(), $ = (T.clientX - m) * G, F = (T.clientY - y) * G, k = O(l) ? F : $;
|
|
632
|
+
r.updateResizeByDelta(p, l, k);
|
|
633
|
+
}, I = () => {
|
|
634
|
+
r.finishResize(p), d.target.releasePointerCapture(d.pointerId), document.removeEventListener("pointermove", h), document.removeEventListener("pointerup", I);
|
|
630
635
|
};
|
|
631
|
-
document.addEventListener("pointermove", h), document.addEventListener("pointerup",
|
|
632
|
-
},
|
|
633
|
-
if (!
|
|
634
|
-
const d =
|
|
635
|
-
|
|
636
|
-
const m = D(d,
|
|
637
|
-
|
|
638
|
-
const T = (
|
|
639
|
-
const F = n.Canvas.getZoomMultiplier(),
|
|
640
|
-
|
|
636
|
+
document.addEventListener("pointermove", h), document.addEventListener("pointerup", I);
|
|
637
|
+
}, S = () => (l) => {
|
|
638
|
+
if (!u) return;
|
|
639
|
+
const d = u;
|
|
640
|
+
l.stopPropagation(), l.preventDefault();
|
|
641
|
+
const m = D(d, t), y = Q({ componentRow: d, isVertical: m }, t), h = l.clientX, I = l.clientY;
|
|
642
|
+
l.target.setPointerCapture(l.pointerId);
|
|
643
|
+
const T = ($) => {
|
|
644
|
+
const F = n.Canvas.getZoomMultiplier(), k = m ? ($.clientY - I) * F : ($.clientX - h) * F;
|
|
645
|
+
r.updateGapByDelta(d, k, y, m);
|
|
641
646
|
}, G = () => {
|
|
642
|
-
|
|
647
|
+
r.finishGapAdjust(d), l.target.releasePointerCapture(l.pointerId), document.removeEventListener("pointermove", T), document.removeEventListener("pointerup", G);
|
|
643
648
|
};
|
|
644
649
|
document.addEventListener("pointermove", T), document.addEventListener("pointerup", G);
|
|
645
|
-
},
|
|
646
|
-
const d =
|
|
647
|
-
if (!d || !i || (
|
|
648
|
-
const m =
|
|
649
|
-
|
|
650
|
-
const
|
|
651
|
-
a && Object.assign(a.style,
|
|
652
|
-
const h = D(m,
|
|
653
|
-
if (Object.values(o).forEach(
|
|
654
|
-
if (
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
}),
|
|
658
|
-
const G = Q({ componentRow: m, isVertical: h },
|
|
659
|
-
|
|
650
|
+
}, C = (l) => {
|
|
651
|
+
const d = l.component;
|
|
652
|
+
if (!d || !i || (p = d, u = d.parent(), !u)) return;
|
|
653
|
+
const m = u;
|
|
654
|
+
ot(i);
|
|
655
|
+
const y = l.getStyle();
|
|
656
|
+
a && Object.assign(a.style, y);
|
|
657
|
+
const h = D(m, t), I = Ht(h);
|
|
658
|
+
if (Object.values(o).forEach(at), I.forEach((G) => {
|
|
659
|
+
if (jt(d, G)) return;
|
|
660
|
+
const $ = o[G];
|
|
661
|
+
ot($);
|
|
662
|
+
}), R(t).gapHandler.isGapSupported() && c && _t(d)) {
|
|
663
|
+
const G = Q({ componentRow: m, isVertical: h }, t);
|
|
664
|
+
x(G, h, Vt(d));
|
|
660
665
|
}
|
|
661
|
-
},
|
|
662
|
-
const
|
|
666
|
+
}, x = (l, d, m = !1) => {
|
|
667
|
+
const y = t.gapHandleSize, h = c.style;
|
|
663
668
|
if (d) {
|
|
664
|
-
h.height = `${
|
|
665
|
-
const
|
|
666
|
-
m ? (h.top = `-${(
|
|
669
|
+
h.height = `${y}px`;
|
|
670
|
+
const I = c.offsetHeight;
|
|
671
|
+
m ? (h.top = `-${(l + I) / 2}px`, h.bottom = "") : (h.bottom = `-${(l + I) / 2}px`, h.top = ""), h.width = "50%", h.left = "50%", h.transform = "translateX(-50%)", h.cursor = "row-resize";
|
|
667
672
|
} else {
|
|
668
|
-
h.width = `${
|
|
669
|
-
const
|
|
670
|
-
m ? (h.left = `-${(
|
|
673
|
+
h.width = `${y}px`;
|
|
674
|
+
const I = c.offsetWidth;
|
|
675
|
+
m ? (h.left = `-${(l + I) / 2}px`, h.right = "") : (h.right = `-${(l + I) / 2}px`, h.left = ""), h.height = "50%", h.top = "50%", h.transform = "translateY(-50%)", h.cursor = "col-resize";
|
|
671
676
|
}
|
|
672
|
-
},
|
|
673
|
-
i && (
|
|
674
|
-
},
|
|
675
|
-
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
},
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
},
|
|
682
|
-
|
|
677
|
+
}, v = () => {
|
|
678
|
+
i && (at(i), p = null, u = null);
|
|
679
|
+
}, b = () => {
|
|
680
|
+
e.removeSpots({ type: s });
|
|
681
|
+
const l = n.getSelected(), d = l == null ? void 0 : l.parent();
|
|
682
|
+
l && d && f.isValidRelationship(d, l) ? e.addSpot({ type: s, component: l }) : v();
|
|
683
|
+
}, w = () => {
|
|
684
|
+
const l = e.getSpots().filter((d) => d.type === s)[0];
|
|
685
|
+
l && C(l);
|
|
686
|
+
}, P = (l, d) => {
|
|
687
|
+
f.registerTypeRelationship(l, d);
|
|
683
688
|
};
|
|
684
689
|
n.onReady(() => {
|
|
685
|
-
|
|
690
|
+
g(), M(t) ? P("mj-section", "mj-column") : P(t.typeRow, t.typeColumn);
|
|
686
691
|
});
|
|
687
|
-
const
|
|
688
|
-
return n.on(
|
|
689
|
-
n.off(
|
|
692
|
+
const z = "component:toggled";
|
|
693
|
+
return n.on(e.events.spot, w), n.on(z, b), () => {
|
|
694
|
+
n.off(e.events.spot, w), n.off(z, b);
|
|
690
695
|
};
|
|
691
696
|
}
|
|
692
|
-
const
|
|
693
|
-
const
|
|
697
|
+
const Zt = function(n, t = {}) {
|
|
698
|
+
const e = {
|
|
694
699
|
typeRow: "flex-row",
|
|
695
700
|
typeColumn: "flex-column",
|
|
696
701
|
gapHandleSize: 3,
|
|
697
702
|
snapDivisions: 12,
|
|
698
703
|
minItemPercent: 5,
|
|
699
|
-
...
|
|
700
|
-
}, s = [
|
|
701
|
-
|
|
704
|
+
...t
|
|
705
|
+
}, s = [Ot(n, e), Ft(n, e)], i = qt(n, e), a = Bt(n, e);
|
|
706
|
+
Et({
|
|
702
707
|
editor: n,
|
|
703
|
-
licenseKey:
|
|
704
|
-
plan:
|
|
705
|
-
pluginName:
|
|
708
|
+
licenseKey: e.licenseKey,
|
|
709
|
+
plan: Yt,
|
|
710
|
+
pluginName: Xt,
|
|
706
711
|
cleanup: () => {
|
|
707
712
|
s.forEach((o) => o == null ? void 0 : o()), i(), a == null || a();
|
|
708
713
|
}
|
|
709
714
|
});
|
|
710
|
-
},
|
|
715
|
+
}, Qt = Gt(Zt);
|
|
711
716
|
export {
|
|
712
|
-
|
|
717
|
+
Qt as default
|
|
713
718
|
};
|