@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.36
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 +175 -162
- package/dist/accordionComponent/index.umd.js +7 -7
- package/dist/aiChat/index.cjs.js +64 -64
- package/dist/aiChat/index.es.js +5785 -5757
- package/dist/aiChat/index.js +64 -64
- package/dist/aiChat/index.umd.js +63 -63
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +204 -191
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +183 -170
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +134 -121
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +165 -152
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +5 -5
- package/dist/canvasGridMode/index.es.js +245 -232
- package/dist/canvasGridMode/index.umd.js +4 -4
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +155 -142
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +9 -9
- package/dist/dataSourceEjs/index.es.js +257 -244
- package/dist/dataSourceEjs/index.umd.js +9 -9
- package/dist/dataSourceHandlebars/index.cjs.js +8 -8
- package/dist/dataSourceHandlebars/index.es.js +216 -203
- package/dist/dataSourceHandlebars/index.umd.js +7 -7
- package/dist/dialogComponent/index.cjs.js +14 -14
- package/dist/dialogComponent/index.es.js +141 -128
- package/dist/dialogComponent/index.umd.js +14 -14
- package/dist/flexComponent/index.cjs.js +13 -13
- package/dist/flexComponent/index.es.js +484 -471
- package/dist/flexComponent/index.umd.js +13 -13
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +173 -160
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +160 -147
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +196 -183
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +25 -25
- package/dist/index.es.js +121 -108
- package/dist/index.umd.js +18 -18
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +157 -144
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +245 -232
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +106 -93
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +157 -144
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +181 -168
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +7 -7
- package/dist/prosemirror/index.es.js +385 -372
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +200 -187
- 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 +118 -105
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +4 -4
- package/dist/shapeDividerComponent/index.es.js +129 -116
- package/dist/shapeDividerComponent/index.umd.js +4 -4
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +203 -190
- package/dist/swiperComponent/index.umd.js +7 -7
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +257 -244
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +121 -108
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
function
|
|
2
|
-
let
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
|
|
1
|
+
function J(e, i, t) {
|
|
2
|
+
let o, n, l, d, r;
|
|
3
|
+
const c = i;
|
|
4
|
+
function f() {
|
|
5
|
+
const a = Date.now() - d;
|
|
6
|
+
a < c && a >= 0 ? o = setTimeout(f, c - a) : (o = null, r = e.apply(l, n), l = n = null);
|
|
7
7
|
}
|
|
8
|
-
const
|
|
9
|
-
return
|
|
8
|
+
const p = function() {
|
|
9
|
+
return l = this, n = arguments, d = Date.now(), o || (o = setTimeout(f, c)), r;
|
|
10
10
|
};
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
},
|
|
11
|
+
return p.clear = function() {
|
|
12
|
+
o && (clearTimeout(o), o = null);
|
|
13
|
+
}, p.flush = function() {
|
|
14
|
+
o && (r = e.apply(l, n), l = n = null, clearTimeout(o), o = null);
|
|
15
|
+
}, p;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
L,
|
|
17
|
+
const k = "app.grapesjs.com", z = "app-stage.grapesjs.com", Q = "app2.grapesjs.com", C = "app-stage2.grapesjs.com", B = [
|
|
19
18
|
k,
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
Q,
|
|
20
|
+
z,
|
|
21
|
+
C,
|
|
22
22
|
"localhost",
|
|
23
23
|
"127.0.0.1",
|
|
24
24
|
".local-credentialless.webcontainer.io",
|
|
@@ -27,88 +27,101 @@ const L = "app.grapesjs.com", F = "app-stage.grapesjs.com", k = "app2.grapesjs.c
|
|
|
27
27
|
// For stackblitz.com demos
|
|
28
28
|
"-sandpack.codesandbox.io"
|
|
29
29
|
// For Sandpack demos
|
|
30
|
-
],
|
|
30
|
+
], ee = "license:check:end", te = () => typeof window < "u", se = ({
|
|
31
31
|
isDev: e,
|
|
32
32
|
isStage: i,
|
|
33
33
|
isPlatform: t
|
|
34
|
-
}) => `${e ? "" : `https://${i ?
|
|
34
|
+
}) => `${e ? "" : `https://${i ? z : k}`}/${t ? "platform-api" : "api"}`, oe = () => {
|
|
35
35
|
const e = te() && window.location.hostname;
|
|
36
|
-
return !!e && (
|
|
36
|
+
return !!e && (B.includes(e) || B.some((i) => e.endsWith(i)));
|
|
37
37
|
};
|
|
38
|
-
async function
|
|
38
|
+
async function ne({
|
|
39
39
|
path: e,
|
|
40
40
|
baseApiUrl: i,
|
|
41
41
|
method: t = "GET",
|
|
42
|
-
headers:
|
|
43
|
-
params:
|
|
44
|
-
body:
|
|
42
|
+
headers: o = {},
|
|
43
|
+
params: n,
|
|
44
|
+
body: l
|
|
45
45
|
}) {
|
|
46
|
-
const
|
|
46
|
+
const r = `${i || se({ isDev: !1, isStage: !1 })}${e}`, c = {
|
|
47
47
|
method: t,
|
|
48
48
|
headers: {
|
|
49
49
|
"Content-Type": "application/json",
|
|
50
|
-
...
|
|
50
|
+
...o
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
-
throw new Error(`HTTP error! status: ${
|
|
57
|
-
return
|
|
53
|
+
l && (c.body = JSON.stringify(l));
|
|
54
|
+
const f = n ? new URLSearchParams(n).toString() : "", p = f ? `?${f}` : "", a = await fetch(`${r}${p}`, c);
|
|
55
|
+
if (!a.ok)
|
|
56
|
+
throw new Error(`HTTP error! status: ${a.status}`);
|
|
57
|
+
return a.json();
|
|
58
58
|
}
|
|
59
|
-
var
|
|
60
|
-
const
|
|
61
|
-
[
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
59
|
+
var y = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(y || {}), H = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.dialogExportCode = "studio:dialogExportCode", e.dialogImportCode = "studio:dialogImportCode", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.clearPage = "studio:clearPage", e.projectFiles = "studio:projectFiles", e.validateCode = "studio:validateCode", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.layoutComponentAdd = "studio:layoutComponentAdd", e.layoutComponentGet = "studio:layoutComponentGet", e.layoutComponentRemove = "studio:layoutComponentRemove", e.layoutComponentRender = "studio:layoutComponentRender", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.settings = "studio:settings", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(H || {});
|
|
60
|
+
const F = {
|
|
61
|
+
[y.free]: 0,
|
|
62
|
+
[y.startup]: 10,
|
|
63
|
+
[y.business]: 20,
|
|
64
|
+
[y.enterprise]: 30
|
|
65
65
|
};
|
|
66
66
|
function ae(e) {
|
|
67
67
|
const i = e;
|
|
68
|
-
return i.init = (t) => (
|
|
68
|
+
return i.init = (t) => (o) => e(o, t), i;
|
|
69
69
|
}
|
|
70
70
|
const ie = (e) => /* @__PURE__ */ ae(e);
|
|
71
71
|
async function re({
|
|
72
72
|
editor: e,
|
|
73
73
|
plan: i,
|
|
74
74
|
pluginName: t,
|
|
75
|
-
licenseKey:
|
|
76
|
-
onLicenseCheckResponse:
|
|
77
|
-
cleanup:
|
|
75
|
+
licenseKey: o,
|
|
76
|
+
onLicenseCheckResponse: n,
|
|
77
|
+
cleanup: l
|
|
78
78
|
}) {
|
|
79
|
-
let
|
|
80
|
-
const
|
|
81
|
-
console.warn("Cleanup plugin:", t, "Reason:",
|
|
82
|
-
}, f = (
|
|
83
|
-
var
|
|
84
|
-
const { error:
|
|
85
|
-
if (!(
|
|
86
|
-
|
|
87
|
-
else if (
|
|
88
|
-
const
|
|
89
|
-
|
|
79
|
+
let d = "", r;
|
|
80
|
+
const c = (a) => {
|
|
81
|
+
console.warn("Cleanup plugin:", t, "Reason:", a), l();
|
|
82
|
+
}, f = (a = {}) => {
|
|
83
|
+
var T;
|
|
84
|
+
const { error: v, sdkLicense: R } = a, b = (T = a.plan) == null ? void 0 : T.category;
|
|
85
|
+
if (!(R || a.license) || v)
|
|
86
|
+
c(v || "Invalid license");
|
|
87
|
+
else if (b) {
|
|
88
|
+
const D = F[i], M = F[b];
|
|
89
|
+
D > M && c({ pluginRequiredPlan: i, licensePlan: b });
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
e.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
92
|
+
e.Commands.has(H.settings) && (r = e.runCommand(H.settings), d = (r == null ? void 0 : r.baseUrl) || "");
|
|
93
|
+
const p = (a) => {
|
|
94
|
+
n == null || n(a), a && f(a);
|
|
95
|
+
};
|
|
96
|
+
if (!r) {
|
|
97
|
+
e.onReady(async () => {
|
|
98
|
+
if (!oe())
|
|
99
|
+
if (o) {
|
|
100
|
+
const a = await ce({ licenseKey: o, pluginName: t, baseApiUrl: d });
|
|
101
|
+
p(a);
|
|
102
|
+
} else
|
|
103
|
+
c("The `licenseKey` option not provided");
|
|
104
|
+
});
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (r.licensePlan || r.licenseError) {
|
|
108
|
+
const a = le(r);
|
|
109
|
+
p(a);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
e.on(ee, (a) => p(a));
|
|
106
113
|
}
|
|
114
|
+
const le = (e) => ({
|
|
115
|
+
sdkLicense: e.license,
|
|
116
|
+
license: e.license,
|
|
117
|
+
error: e.licenseError,
|
|
118
|
+
plan: e.licensePlan
|
|
119
|
+
});
|
|
107
120
|
async function ce(e) {
|
|
108
|
-
const { licenseKey: i, pluginName: t, baseApiUrl:
|
|
121
|
+
const { licenseKey: i, pluginName: t, baseApiUrl: o } = e;
|
|
109
122
|
try {
|
|
110
|
-
return (await
|
|
111
|
-
baseApiUrl:
|
|
123
|
+
return (await ne({
|
|
124
|
+
baseApiUrl: o,
|
|
112
125
|
path: `/sdk/${i || "na"}`,
|
|
113
126
|
method: "POST",
|
|
114
127
|
params: {
|
|
@@ -116,28 +129,28 @@ async function ce(e) {
|
|
|
116
129
|
pn: t
|
|
117
130
|
}
|
|
118
131
|
})).result || {};
|
|
119
|
-
} catch (
|
|
120
|
-
return console.error("Error during SDK license check:",
|
|
132
|
+
} catch (n) {
|
|
133
|
+
return console.error("Error during SDK license check:", n), !1;
|
|
121
134
|
}
|
|
122
135
|
}
|
|
123
|
-
const
|
|
124
|
-
const { rule: t, ruleView:
|
|
125
|
-
if (
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
const
|
|
136
|
+
const N = "data-gs-plg-", _ = "canvasFullSize", ue = y.startup, ge = (e, i) => {
|
|
137
|
+
const { rule: t, ruleView: o } = i, { style: n } = t.attributes;
|
|
138
|
+
if (n && n[e]) {
|
|
139
|
+
const l = n[e], d = /([0-9.]+)(vh|dvh|lvh|svh)/g, r = d.test(l), c = o.frameView.model;
|
|
140
|
+
if (r && c.hasAutoHeight()) {
|
|
141
|
+
const f = l.replace(d, (a, v) => `${window.innerHeight * (parseFloat(v) / 100)}px`), p = t.toCSS({
|
|
129
142
|
style: {
|
|
130
|
-
...
|
|
131
|
-
[e]:
|
|
143
|
+
...n,
|
|
144
|
+
[e]: f
|
|
132
145
|
}
|
|
133
146
|
});
|
|
134
|
-
i.css =
|
|
147
|
+
i.css = p;
|
|
135
148
|
}
|
|
136
149
|
}
|
|
137
150
|
}, pe = (e) => {
|
|
138
|
-
["height", "min-height", "max-height"].forEach((i) =>
|
|
139
|
-
},
|
|
140
|
-
const { Canvas: t, Commands:
|
|
151
|
+
["height", "min-height", "max-height"].forEach((i) => ge(i, e));
|
|
152
|
+
}, de = function(e, i = {}) {
|
|
153
|
+
const { Canvas: t, Commands: o, Devices: n, Css: l } = e, d = {
|
|
141
154
|
deviceMaxWidth: 1200,
|
|
142
155
|
deviceMinHeigth: 500,
|
|
143
156
|
canvasOffsetY: 30,
|
|
@@ -147,91 +160,91 @@ const W = "data-gs-plg-", z = "canvasFullSize", le = v.startup, ue = (e, i) => {
|
|
|
147
160
|
frameTransition: 0.3,
|
|
148
161
|
...i
|
|
149
162
|
}, {
|
|
150
|
-
canvasOffsetY:
|
|
151
|
-
canvasOffsetX:
|
|
152
|
-
canvasTransition:
|
|
153
|
-
deviceMaxWidth:
|
|
154
|
-
deviceMinHeigth:
|
|
155
|
-
deviceFixedHeight:
|
|
156
|
-
frameBorderRadius:
|
|
157
|
-
frameTransition:
|
|
158
|
-
} =
|
|
159
|
-
let
|
|
160
|
-
|
|
161
|
-
!
|
|
163
|
+
canvasOffsetY: r,
|
|
164
|
+
canvasOffsetX: c,
|
|
165
|
+
canvasTransition: f,
|
|
166
|
+
deviceMaxWidth: p,
|
|
167
|
+
deviceMinHeigth: a,
|
|
168
|
+
deviceFixedHeight: v,
|
|
169
|
+
frameBorderRadius: R,
|
|
170
|
+
frameTransition: b
|
|
171
|
+
} = d, w = `${a}px`, T = t.events, D = "core:preview", M = `${o.events.stopCommand}${D}`, L = t.getConfig(), I = `${_}:disable`, W = n.getAll().map((s) => ({ ...s.attributes })), K = f * 1e3, m = { x: c, y: r };
|
|
172
|
+
let P = {}, G, A;
|
|
173
|
+
L.scrollableCanvas = !v, n.getAll().map((s) => {
|
|
174
|
+
!s.get("width") && s.set("width", `${p}px`), !s.get("height") && s.set("height", v ? "100vh" : "auto"), !s.get("minHeight") && s.set("minHeight", w);
|
|
162
175
|
});
|
|
163
|
-
const
|
|
164
|
-
const u = `${
|
|
165
|
-
if (
|
|
166
|
-
return
|
|
167
|
-
const h =
|
|
176
|
+
const O = (s) => {
|
|
177
|
+
const u = `${N}canvas-full-size`, g = document.querySelector(`style[${u}]`);
|
|
178
|
+
if (s && g)
|
|
179
|
+
return g.remove();
|
|
180
|
+
const h = g || document.createElement("style"), x = t.getZoomMultiplier();
|
|
168
181
|
h.setAttribute(u, "true"), h.innerHTML = `
|
|
169
|
-
.gjs-frame-wrapper { transition: width ${
|
|
170
|
-
.gjs-frame-wrapper__bottom { height: ${
|
|
171
|
-
.gjs-frame { border-radius: ${
|
|
172
|
-
`, !
|
|
182
|
+
.gjs-frame-wrapper { transition: width ${b}s !important; }
|
|
183
|
+
.gjs-frame-wrapper__bottom { height: ${r * x}px }
|
|
184
|
+
.gjs-frame { border-radius: ${R}px }
|
|
185
|
+
`, !g && document.body.appendChild(h);
|
|
173
186
|
};
|
|
174
|
-
e.on(
|
|
175
|
-
if (!
|
|
176
|
-
const { window: u } =
|
|
177
|
-
|
|
187
|
+
e.on(T.frameLoadHead, (s) => {
|
|
188
|
+
if (!L.scrollableCanvas) return;
|
|
189
|
+
const { window: u } = s, g = u.document, h = g.head, x = `${N}canvas-full-size-wrappers`, $ = h.querySelector(`style[${x}]`) || g.createElement("style");
|
|
190
|
+
$.setAttribute(x, "true"), $.innerHTML = `
|
|
178
191
|
body { height: auto !important; }
|
|
179
|
-
[data-gjs-type="wrapper"] { min-height: ${
|
|
180
|
-
[data-gjs-type="mjml"] { min-height: ${
|
|
181
|
-
[data-gjs-type="mj-body"] { min-height: ${
|
|
182
|
-
`, !h.contains(
|
|
192
|
+
[data-gjs-type="wrapper"] { min-height: ${w} !important; }
|
|
193
|
+
[data-gjs-type="mjml"] { min-height: ${w} !important; }
|
|
194
|
+
[data-gjs-type="mj-body"] { min-height: ${w} !important; }
|
|
195
|
+
`, !h.contains($) && h.appendChild($);
|
|
183
196
|
});
|
|
184
|
-
const j = () =>
|
|
197
|
+
const j = () => G.style.display = "none", Z = () => G.style.display = "", q = () => {
|
|
185
198
|
var h;
|
|
186
|
-
if (!
|
|
187
|
-
const
|
|
188
|
-
(h =
|
|
189
|
-
},
|
|
199
|
+
if (!v) return;
|
|
200
|
+
const s = t.getZoomMultiplier(), g = t.getRect().height * s - r * 2;
|
|
201
|
+
(h = n.getSelected()) == null || h.set("height", `${Math.max(g, a)}px`), t.fitViewport({ zoom: t.getZoom(), gap: m });
|
|
202
|
+
}, E = J(() => {
|
|
190
203
|
t.fitViewport({
|
|
191
|
-
zoom: (
|
|
204
|
+
zoom: (s) => s > 100 ? 100 : s,
|
|
192
205
|
ignoreHeight: !0,
|
|
193
|
-
gap:
|
|
194
|
-
}),
|
|
195
|
-
var u,
|
|
196
|
-
const { em:
|
|
197
|
-
|
|
198
|
-
},
|
|
199
|
-
}, 100),
|
|
200
|
-
|
|
206
|
+
gap: m
|
|
207
|
+
}), q(), O(), setTimeout(() => {
|
|
208
|
+
var u, g;
|
|
209
|
+
const { em: s } = e;
|
|
210
|
+
s.destroyed || ((g = (u = e.getSelected()) == null ? void 0 : u.getEl()) == null || g.scrollIntoView({ block: "nearest" }), e.refresh({ tools: !0 }), Z(), o.isActive(D) ? s.stopDefault() : s.runDefault());
|
|
211
|
+
}, K);
|
|
212
|
+
}, 100), X = (s = {}) => {
|
|
213
|
+
s.options && s.options.from !== "fitViewport" && t.fitViewport({
|
|
201
214
|
zoom: t.getZoom(),
|
|
202
215
|
ignoreHeight: !0,
|
|
203
|
-
gap:
|
|
216
|
+
gap: m
|
|
204
217
|
});
|
|
205
|
-
},
|
|
206
|
-
j(),
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
},
|
|
212
|
-
[
|
|
213
|
-
[
|
|
214
|
-
[
|
|
215
|
-
[e.events.destroy,
|
|
216
|
-
[
|
|
218
|
+
}, Y = () => {
|
|
219
|
+
j(), E();
|
|
220
|
+
}, S = () => {
|
|
221
|
+
P.overflowX = "hidden", P.overflowY = "auto";
|
|
222
|
+
}, U = () => {
|
|
223
|
+
A == null || A.disconnect(), E.clear();
|
|
224
|
+
}, V = [
|
|
225
|
+
[n.events.select, Y],
|
|
226
|
+
[T.zoom, X],
|
|
227
|
+
[M, S],
|
|
228
|
+
[e.events.destroy, U],
|
|
229
|
+
[l.events.mountBefore, pe]
|
|
217
230
|
];
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}),
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
j(),
|
|
224
|
-
}),
|
|
231
|
+
o.add(I, () => {
|
|
232
|
+
n.devices.reset(W), L.scrollableCanvas = !1, t.getModel().updateDevice(), t.setZoom(100), t.setCoords(0, 0), P.overflowY = "hidden", O(!0), V.forEach(([s, u]) => e.off(s, u)), U(), o.run("studio:canvasReload");
|
|
233
|
+
}), V.forEach(([s, u]) => e.on(s, u)), e.onReady(() => {
|
|
234
|
+
const s = t.getElement(), u = t.getFramesEl(), g = t.getCanvasView();
|
|
235
|
+
G = t.getSpotsEl(), P = s.style, P.overflowX = "hidden", u.style.transition = `transform ${f}s`, document.removeEventListener("keypress", g.onKeyPress), O(), A = new ResizeObserver(() => {
|
|
236
|
+
j(), E();
|
|
237
|
+
}), A.observe(s.parentElement), E();
|
|
225
238
|
}), re({
|
|
226
239
|
editor: e,
|
|
227
|
-
licenseKey:
|
|
228
|
-
plan:
|
|
229
|
-
pluginName:
|
|
240
|
+
licenseKey: d.licenseKey,
|
|
241
|
+
plan: ue,
|
|
242
|
+
pluginName: _,
|
|
230
243
|
cleanup: () => {
|
|
231
|
-
e.runCommand(
|
|
244
|
+
e.runCommand(I);
|
|
232
245
|
}
|
|
233
246
|
});
|
|
234
|
-
},
|
|
247
|
+
}, fe = ie(de);
|
|
235
248
|
export {
|
|
236
|
-
|
|
249
|
+
fe as default
|
|
237
250
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(y
|
|
2
|
-
.gjs-frame-wrapper { transition: width ${
|
|
3
|
-
.gjs-frame-wrapper__bottom { height: ${r
|
|
4
|
-
.gjs-frame { border-radius: ${
|
|
5
|
-
`,!
|
|
1
|
+
(function(w,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(w=typeof globalThis<"u"?globalThis:w||self,w.StudioSdkPlugins_canvasFullSize=y())})(this,function(){"use strict";function w(e,i,t){let o,n,l,d,r;const c=i;function f(){const a=Date.now()-d;a<c&&a>=0?o=setTimeout(f,c-a):(o=null,r=e.apply(l,n),l=n=null)}const p=function(){return l=this,n=arguments,d=Date.now(),o||(o=setTimeout(f,c)),r};return p.clear=function(){o&&(clearTimeout(o),o=null)},p.flush=function(){o&&(r=e.apply(l,n),l=n=null,clearTimeout(o),o=null)},p}const y="app.grapesjs.com",_="app-stage.grapesjs.com",N=[y,"app2.grapesjs.com",_,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],S="license:check:end",K=()=>typeof window<"u",Z=({isDev:e,isStage:i,isPlatform:t})=>`${e?"":`https://${i?_:y}`}/${t?"platform-api":"api"}`,q=()=>{const e=K()&&window.location.hostname;return!!e&&(N.includes(e)||N.some(i=>e.endsWith(i)))};async function X({path:e,baseApiUrl:i,method:t="GET",headers:o={},params:n,body:l}){const r=`${i||Z({isDev:!1,isStage:!1})}${e}`,c={method:t,headers:{"Content-Type":"application/json",...o}};l&&(c.body=JSON.stringify(l));const f=n?new URLSearchParams(n).toString():"",p=f?`?${f}`:"",a=await fetch(`${r}${p}`,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),L=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(L||{});const U={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function Y(e){const i=e;return i.init=t=>o=>e(o,t),i}const J=e=>Y(e);async function Q({editor:e,plan:i,pluginName:t,licenseKey:o,onLicenseCheckResponse:n,cleanup:l}){let d="",r;const c=a=>{console.warn("Cleanup plugin:",t,"Reason:",a),l()},f=(a={})=>{var A;const{error:v,sdkLicense:x}=a,T=(A=a.plan)==null?void 0:A.category;if(!(x||a.license)||v)c(v||"Invalid license");else if(T){const E=U[i],G=U[T];E>G&&c({pluginRequiredPlan:i,licensePlan:T})}};e.Commands.has(L.settings)&&(r=e.runCommand(L.settings),d=(r==null?void 0:r.baseUrl)||"");const p=a=>{n==null||n(a),a&&f(a)};if(!r){e.onReady(async()=>{if(!q())if(o){const a=await ee({licenseKey:o,pluginName:t,baseApiUrl:d});p(a)}else c("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const a=C(r);p(a);return}e.on(S,a=>p(a))}const C=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function ee(e){const{licenseKey:i,pluginName:t,baseApiUrl:o}=e;try{return(await X({baseApiUrl:o,path:`/sdk/${i||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const V="data-gs-plg-",B="canvasFullSize",te=b.startup,se=(e,i)=>{const{rule:t,ruleView:o}=i,{style:n}=t.attributes;if(n&&n[e]){const l=n[e],d=/([0-9.]+)(vh|dvh|lvh|svh)/g,r=d.test(l),c=o.frameView.model;if(r&&c.hasAutoHeight()){const f=l.replace(d,(a,v)=>`${window.innerHeight*(parseFloat(v)/100)}px`),p=t.toCSS({style:{...n,[e]:f}});i.css=p}}},oe=e=>{["height","min-height","max-height"].forEach(i=>se(i,e))};return J(function(e,i={}){const{Canvas:t,Commands:o,Devices:n,Css:l}=e,d={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...i},{canvasOffsetY:r,canvasOffsetX:c,canvasTransition:f,deviceMaxWidth:p,deviceMinHeigth:a,deviceFixedHeight:v,frameBorderRadius:x,frameTransition:T}=d,P=`${a}px`,A=t.events,E="core:preview",G=`${o.events.stopCommand}${E}`,O=t.getConfig(),F=`${B}:disable`,ne=n.getAll().map(s=>({...s.attributes})),ae=f*1e3,I={x:c,y:r};let D={},H,R;O.scrollableCanvas=!v,n.getAll().map(s=>{!s.get("width")&&s.set("width",`${p}px`),!s.get("height")&&s.set("height",v?"100vh":"auto"),!s.get("minHeight")&&s.set("minHeight",P)});const j=s=>{const u=`${V}canvas-full-size`,g=document.querySelector(`style[${u}]`);if(s&&g)return g.remove();const h=g||document.createElement("style"),$=t.getZoomMultiplier();h.setAttribute(u,"true"),h.innerHTML=`
|
|
2
|
+
.gjs-frame-wrapper { transition: width ${T}s !important; }
|
|
3
|
+
.gjs-frame-wrapper__bottom { height: ${r*$}px }
|
|
4
|
+
.gjs-frame { border-radius: ${x}px }
|
|
5
|
+
`,!g&&document.body.appendChild(h)};e.on(A.frameLoadHead,s=>{if(!O.scrollableCanvas)return;const{window:u}=s,g=u.document,h=g.head,$=`${V}canvas-full-size-wrappers`,m=h.querySelector(`style[${$}]`)||g.createElement("style");m.setAttribute($,"true"),m.innerHTML=`
|
|
6
6
|
body { height: auto !important; }
|
|
7
|
-
[data-gjs-type="wrapper"] { min-height: ${
|
|
8
|
-
[data-gjs-type="mjml"] { min-height: ${
|
|
9
|
-
[data-gjs-type="mj-body"] { min-height: ${
|
|
10
|
-
`,!h.contains(
|
|
7
|
+
[data-gjs-type="wrapper"] { min-height: ${P} !important; }
|
|
8
|
+
[data-gjs-type="mjml"] { min-height: ${P} !important; }
|
|
9
|
+
[data-gjs-type="mj-body"] { min-height: ${P} !important; }
|
|
10
|
+
`,!h.contains(m)&&h.appendChild(m)});const k=()=>H.style.display="none",ie=()=>H.style.display="",re=()=>{var h;if(!v)return;const s=t.getZoomMultiplier(),g=t.getRect().height*s-r*2;(h=n.getSelected())==null||h.set("height",`${Math.max(g,a)}px`),t.fitViewport({zoom:t.getZoom(),gap:I})},M=w(()=>{t.fitViewport({zoom:s=>s>100?100:s,ignoreHeight:!0,gap:I}),re(),j(),setTimeout(()=>{var u,g;const{em:s}=e;s.destroyed||((g=(u=e.getSelected())==null?void 0:u.getEl())==null||g.scrollIntoView({block:"nearest"}),e.refresh({tools:!0}),ie(),o.isActive(E)?s.stopDefault():s.runDefault())},ae)},100),le=(s={})=>{s.options&&s.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:I})},ce=()=>{k(),M()},ue=()=>{D.overflowX="hidden",D.overflowY="auto"},z=()=>{R==null||R.disconnect(),M.clear()},W=[[n.events.select,ce],[A.zoom,le],[G,ue],[e.events.destroy,z],[l.events.mountBefore,oe]];o.add(F,()=>{n.devices.reset(ne),O.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),D.overflowY="hidden",j(!0),W.forEach(([s,u])=>e.off(s,u)),z(),o.run("studio:canvasReload")}),W.forEach(([s,u])=>e.on(s,u)),e.onReady(()=>{const s=t.getElement(),u=t.getFramesEl(),g=t.getCanvasView();H=t.getSpotsEl(),D=s.style,D.overflowX="hidden",u.style.transition=`transform ${f}s`,document.removeEventListener("keypress",g.onKeyPress),j(),R=new ResizeObserver(()=>{k(),M()}),R.observe(s.parentElement),M()}),Q({editor:e,licenseKey:d.licenseKey,plan:te,pluginName:B,cleanup:()=>{e.runCommand(F)}})})});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
.${
|
|
1
|
+
"use strict";const Y="app.grapesjs.com",H="app-stage.grapesjs.com",rt="app2.grapesjs.com",st="app-stage2.grapesjs.com",j=[Y,rt,H,st,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],at="license:check:end",it=()=>typeof window<"u",lt=({isDev:t,isStage:e,isPlatform:r})=>`${t?"":`https://${e?H:Y}`}/${r?"platform-api":"api"}`,ct=()=>{const t=it()&&window.location.hostname;return!!t&&(j.includes(t)||j.some(e=>t.endsWith(e)))};function X(t){return typeof t=="function"}async function pt({path:t,baseApiUrl:e,method:r="GET",headers:n={},params:o,body:i}){const a=`${e||lt({isDev:!1,isStage:!1})}${t}`,p={method:r,headers:{"Content-Type":"application/json",...n}};i&&(p.body=JSON.stringify(i));const d=o?new URLSearchParams(o).toString():"",c=d?`?${d}`:"",l=await fetch(`${a}${c}`,p);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var G=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(G||{}),_=(t=>(t.toastAdd="studio:toastAdd",t.toastRemove="studio:toastRemove",t.dialogOpen="studio:dialogOpen",t.dialogClose="studio:dialogClose",t.dialogExportCode="studio:dialogExportCode",t.dialogImportCode="studio:dialogImportCode",t.sidebarLeftSet="studio:sidebarLeft:set",t.sidebarLeftGet="studio:sidebarLeft:get",t.sidebarLeftToggle="studio:sidebarLeft:toggle",t.sidebarRightSet="studio:sidebarRight:set",t.sidebarRightGet="studio:sidebarRight:get",t.sidebarRightToggle="studio:sidebarRight:toggle",t.sidebarTopSet="studio:sidebarTop:set",t.sidebarTopGet="studio:sidebarTop:get",t.sidebarTopToggle="studio:sidebarTop:toggle",t.sidebarBottomSet="studio:sidebarBottom:set",t.sidebarBottomGet="studio:sidebarBottom:get",t.sidebarBottomToggle="studio:sidebarBottom:toggle",t.symbolAdd="studio:symbolAdd",t.symbolDetach="studio:symbolDetach",t.symbolOverride="studio:symbolOverride",t.symbolPropagateStyles="studio:propagateStyles",t.getPagesConfig="studio:getPagesConfig",t.setPagesConfig="studio:setPagesConfig",t.getPageSettings="studio:getPageSettings",t.setPageSettings="studio:setPageSettings",t.clearPage="studio:clearPage",t.projectFiles="studio:projectFiles",t.validateCode="studio:validateCode",t.canvasReload="studio:canvasReload",t.getBlocksPanel="studio:getBlocksPanel",t.setBlocksPanel="studio:setBlocksPanel",t.getStateContextMenu="studio:getStateContextMenu",t.setStateContextMenu="studio:setStateContextMenu",t.contextMenuComponent="studio:contextMenuComponent",t.layoutAdd="studio:layoutAdd",t.layoutRemove="studio:layoutRemove",t.layoutToggle="studio:layoutToggle",t.layoutUpdate="studio:layoutUpdate",t.layoutGet="studio:layoutGet",t.layoutConfigGet="studio:layoutConfigGet",t.layoutConfigSet="studio:layoutConfigSet",t.layoutComponentAdd="studio:layoutComponentAdd",t.layoutComponentGet="studio:layoutComponentGet",t.layoutComponentRemove="studio:layoutComponentRemove",t.layoutComponentRender="studio:layoutComponentRender",t.getStateTheme="studio:getStateTheme",t.setStateTheme="studio:setStateTheme",t.settings="studio:settings",t.assetProviderGet="studio:assetProviderGet",t.assetProviderAdd="studio:assetProviderAdd",t.assetProviderRemove="studio:assetProviderRemove",t.fontGet="studio:fontGet",t.fontAdd="studio:fontAdd",t.fontRemove="studio:fontRemove",t.fontManagerOpen="studio:fontManagerOpen",t.menuFontLoad="studio:menuFontLoad",t.toggleStateDataSource="studio:toggleStateDataSource",t.getStateDataSource="studio:getStateDataSource",t.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",t.dataSourceSetImporter="studio:dataSourceSetImporter",t.dataSourceSetExporter="studio:dataSourceSetExporter",t.setDragAbsolute="studio:setDragAbsolute",t))(_||{});const W={[G.free]:0,[G.startup]:10,[G.business]:20,[G.enterprise]:30};function dt(t){const e=t;return e.init=r=>n=>t(n,r),e}const gt=t=>dt(t);async function ut({editor:t,plan:e,pluginName:r,licenseKey:n,onLicenseCheckResponse:o,cleanup:i}){let s="",a;const p=l=>{console.warn("Cleanup plugin:",r,"Reason:",l),i()},d=(l={})=>{var w;const{error:g,sdkLicense:u}=l,h=(w=l.plan)==null?void 0:w.category;if(!(u||l.license)||g)p(g||"Invalid license");else if(h){const v=W[e],R=W[h];v>R&&p({pluginRequiredPlan:e,licensePlan:h})}};t.Commands.has(_.settings)&&(a=t.runCommand(_.settings),s=(a==null?void 0:a.baseUrl)||"");const c=l=>{o==null||o(l),l&&d(l)};if(!a){t.onReady(async()=>{if(!ct())if(n){const l=await mt({licenseKey:n,pluginName:r,baseApiUrl:s});c(l)}else p("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const l=ft(a);c(l);return}t.on(at,l=>c(l))}const ft=t=>({sdkLicense:t.license,license:t.license,error:t.licenseError,plan:t.licensePlan});async function mt(t){const{licenseKey:e,pluginName:r,baseApiUrl:n}=t;try{return(await pt({baseApiUrl:n,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const N="canvasGridMode",yt=G.startup,F="component-grid-mode",D="grid-mode",M="gjs-drag-grid-spot",K=`${M}__grid-item`,J=`${M}__grid-target`,Q=`${M}__snapped`,ht=`${M}__container`,wt=()=>{const t="data-gjs-drag-grid-style",e=document,r="var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight))",n="var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue))",o=e.querySelector(`style[${t}]`)||e.createElement("style");o.setAttribute(t,"true"),o.innerHTML=`
|
|
2
|
+
.${K} {
|
|
3
3
|
outline: 2px solid ${n};
|
|
4
4
|
background: ${r};
|
|
5
5
|
outline-offset: -2px;
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
height: 100%;
|
|
9
9
|
opacity: 0.1;
|
|
10
10
|
}
|
|
11
|
-
.${
|
|
11
|
+
.${Q} {
|
|
12
12
|
width: 100%;
|
|
13
13
|
height: 100%;
|
|
14
14
|
outline: 2px solid ${n};
|
|
15
15
|
outline-offset: -2px;
|
|
16
16
|
position: absolute;
|
|
17
17
|
}
|
|
18
|
-
.${
|
|
18
|
+
.${J} {
|
|
19
19
|
position: absolute;
|
|
20
20
|
z-index: -1;
|
|
21
21
|
background: ${r};
|
|
@@ -23,4 +23,4 @@
|
|
|
23
23
|
outline-offset: -1px;
|
|
24
24
|
opacity: 0.35;
|
|
25
25
|
}
|
|
26
|
-
`,e.head.appendChild(o)};function Q(t){const{editor:e,type:r}=t,n=Ct(e,t.component),o=L(e,n.component);if(!vt(e,n,o,r))return{target:n,container:o,startScroll:et(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:A,component:o.component})}}function Z(t){const{editor:e,shadowTargetEl:r,shadowSnappedEl:n,shadowContainerEl:o,spotEl:i,target:s,container:l}=t,{Canvas:d}=e,c=e.config.stylePrefix;i==null||i.appendChild(o),o==null||o.appendChild(r),o==null||o.appendChild(n),wt(o,l),St(r,s,l),bt(n,s),$t(o,l.el),s.el.style.opacity="0";const p=d.getSpots().filter(a=>a.type!==A);e.em.stopDefault({preserveSelected:!0}),d.removeSpots(p),d.startAutoscroll(),d.getBody().classList.add(`${c}is__grabbing`)}function V(t){const{editor:e,shadowSnappedEl:r,shadowContainerEl:n,target:o,cancelled:i}=t,{Canvas:s}=e,l=e.config.stylePrefix,{component:d}=o;if(!i){const c=window.getComputedStyle(r);d.addStyle({"grid-area":c.gridArea,width:"",height:""})}o.el.style.opacity="",n.contains(r)&&(n==null||n.removeChild(r)),e.getModel().runDefault({preserveSelected:1}),s.stopAutoscroll(),s.getBody().classList.remove(`${l}is__grabbing`),s.removeSpots({type:A}),e.select(d)}function wt(t,{rows:e,columns:r}){const n=[];for(let o=0;o<r.length;o++){n[o]=[];for(let i=0;i<e.length;i++){const s=document.createElement("div");s.className=X,s.style.gridArea=`${i+1} / ${o+1}`,n[o][i]=s,t.appendChild(s)}}return n}function St(t,e,r){return t.className=k,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}function bt(t,e){const r=ot(e.el,e.computedStyles);return t.className=J,t.style.gridArea=`${r.row.start} / ${r.column.start} / ${r.row.end} / ${r.column.end}`,t}function $t(t,e){const r=window.getComputedStyle(e);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}function tt(t,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...t.getSelectedAll()].pop();return e}function Ct(t,e){const r=tt(t,e),n=r.getEl(),o=window.getComputedStyle(n);return{component:r,el:n,offset:t.Canvas.offset(n),margin:{top:parseFloat(o.marginTop),right:parseFloat(o.marginRight),bottom:parseFloat(o.marginBottom),left:parseFloat(o.marginLeft)},computedStyles:o}}function L(t,e){const r=e.parent(),n=r.getEl(),o=window.getComputedStyle(n);return{component:r,el:n,offset:t.Canvas.offset(n),computedStyles:o,padding:{top:parseFloat(o.paddingTop),right:parseFloat(o.paddingRight),bottom:parseFloat(o.paddingBottom),left:parseFloat(o.paddingLeft)},columns:o.gridTemplateColumns.split(" ").map(s=>parseFloat(s)),rows:o.gridTemplateRows.split(" ").map(s=>parseFloat(s)),gap:{column:parseInt(o.columnGap),row:parseInt(o.rowGap)}}}function E(t,e,r,n,o=1){let i=0;for(let s=e;s<=t.length;s++){if(i+(t[s-1]+n)*o>r)return s;i+=n+t[s-1]}return t.length+1}function et(t){const{scrollY:e,scrollX:r}=t.Canvas.getWindow();return{scroll:{top:e,left:r}}}function vt(t,e,r,n){const o=i=>t.em.logWarning(i);return n==="draggable"&&e.component.get(n)===!1?(o(`[${N}] The element is not ${n}`),!0):r.computedStyles.display!=="grid"?(o(`[${N}] The container does not have style display:grid`),!0):!1}function _(t,e,r={}){const n=tt(t,e),o=n==null?void 0:n.parent(),i=o==null?void 0:o.getEl();if(!o||!i)return!1;const{enableGrid:s}=r,l=window.getComputedStyle(i).display==="grid";return K(s)?s({component:n,parent:o,isParentGrid:l}):l}const B=t=>t.split(" ").map(e=>parseFloat(e));function ot(t,e){const r=t.ownerDocument.defaultView,n=e||r.getComputedStyle(t),o=n.gridArea.split("/").some(S=>isNaN(parseInt(S.trim()))),i={isComputed:o,raw:n.gridArea};if(!o)return{...i,row:{start:parseInt(n.gridRowStart),end:parseInt(n.gridRowEnd)},column:{start:parseInt(n.gridColumnStart),end:parseInt(n.gridColumnEnd)}};const s=t.parentElement,l=r.getComputedStyle(s),d=parseFloat(l.columnGap)||0,c=parseFloat(l.rowGap)||0,p=B(l.gridTemplateColumns),a=B(l.gridTemplateRows),u=parseFloat(l.paddingLeft)||0,m=parseFloat(l.paddingTop)||0,h=s.getBoundingClientRect(),f=t.getBoundingClientRect(),w=(S,$,x,C,M)=>{let P=1,T=C+M;for(let R=0;R<$.length;R++){const I=$[R],O=T+I;if(S>=T&&S<O)return P;T=O+x,P++}return-1},b=w(f.left,p,d,h.left,u),v=w(f.right-1,p,d,h.left,u)+1,y=w(f.top,a,c,h.top,m),g=w(f.bottom-1,a,c,h.top,m)+1;return{...i,row:{start:y,end:g},column:{start:b,end:v}}}function Et(t){t.Commands.add(F,{stop(){},run(e,r,n={}){const o=Q({editor:e,component:n.target,type:"draggable"});if(!o){this.stopCommand();return}const{spot:i,target:s,shadowContainerEl:l,shadowSnappedEl:d,shadowTargetEl:c,startScroll:p}=o;let{container:a}=o,u;new e.Utils.Dragger({doc:s.el.ownerDocument,onStart:()=>{u=setTimeout(()=>{Z({editor:e,shadowTargetEl:c,shadowSnappedEl:d,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:s,container:a}),a=L(e,s.component)},10)},onEnd:(h,f,{cancelled:w})=>{clearTimeout(u),V({editor:e,shadowSnappedEl:d,shadowContainerEl:l,target:s,cancelled:w}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:h,y:f})=>{const{scroll:w}=et(e),{columns:b,rows:v,gap:y,offset:g,padding:S}=a,{offset:$,margin:x}=s,C=$.top-g.top-S.top-x.top+f-p.top+w.top,M=$.left-g.left-S.left-x.left+h-p.left+w.left,P=Math.min(E(b,1,M,y.column,.5),b.length),T=Math.min(E(v,1,C,y.row,.5),v.length),R=Math.min(E(b,P,$.width,y.column)+1,b.length+1),I=Math.min(E(v,T,$.height,y.row)+1,v.length+1);d.style.gridArea=`${T} / ${P} / ${I} / ${R}`,c.style.top=`${C+S.top}px`,c.style.left=`${M+S.left}px`}}).start(n.event)}})}function xt(t,e){const r=Q({editor:t,component:e.component,type:"resizable"});if(!r)return;const{onMove:n,onEnd:o}=e.options||{},{spot:i,target:s,shadowContainerEl:l,shadowSnappedEl:d,shadowTargetEl:c}=r;let{container:p}=r,a="",u;return{onStart:m=>{a=m.target.dataset.gjsHandler||"",u=setTimeout(()=>{Z({editor:t,shadowTargetEl:c,shadowSnappedEl:d,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:s,container:p}),p=L(t,s.component)},10),t.trigger("component:resize",{...s,type:"start"})},onEnd:(m,h)=>{const{startDim:f,rectDim:w}=h.resizer,b=JSON.stringify(f)===JSON.stringify(w);clearTimeout(u),V({editor:t,shadowSnappedEl:d,shadowContainerEl:l,target:s,cancelled:b}),o==null||o(m,h)},onMove:(m,h)=>{const f=ot(d),w=s.margin.left,b=s.margin.top,v=s.margin.bottom,y=s.margin.right,{w:g,t:S,l:$,h:x}=h.resizer.rectDim,C={t:S-b,l:$-w,h:x+b+v,w:g+w+y};a.endsWith("l")&&(f.column.start=E(p.columns,1,C.l-p.offset.left-p.padding.left,p.gap.column,.5)),a.startsWith("t")&&(f.row.start=E(p.rows,1,C.t-p.offset.top-p.padding.top,p.gap.row,.5)),a.endsWith("r")&&(f.column.end=Math.max(E(p.columns,f.column.start,C.w,p.gap.column,.5),f.column.start+1)),a.startsWith("b")&&(f.row.end=Math.max(E(p.rows,f.row.start,C.h,p.gap.row,.5),f.row.start+1)),d.style.gridArea=`${f.row.start} / ${f.column.start} / ${f.row.end} / ${f.column.end}`,c.style.width=`${C.w}px`,c.style.height=`${C.h}px`,c.style.left=`${C.l-p.offset.left}px`,c.style.top=`${C.t-p.offset.top}px`,n==null||n(m,h)}}}const U=["px","%","em","rem","vw","vh"],Tt=(t,e)=>{const r=t.Styles.getSectors().find(n=>!!n.getProperty(e));return{sector:r,property:r?r.getProperty(e):void 0}},Gt=(t,e)=>Tt(t,e),Pt=(t,{x:e,y:r,mergable:n}={})=>{const o={property:`${t}-x`,type:"integer",units:U,...e},i={property:`${t}-y`,type:"integer",units:U,...r};return{property:t,type:"composite",properties:[o,i],...n&&{fromStyle(s,{name:l,separator:d,property:c}){const[p,a]=c.getProperties(),[u,m]=(s[l]||"").split(d);return{[p.getId()]:s[p.getName()]||u||"",[a.getId()]:s[a.getName()]||m||u||""}},toStyle(s,{name:l,property:d}){const[c,p]=d.getProperties(),a=s[c.getId()],u=s[p.getId()];return{[l]:a===u?a:`${a} ${u}`}}}}},z={display:["grid"]};function Rt(t=""){const e=/^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i,r=/^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i,n=t.match(e);if(!n)return null;const o=parseInt(n[1],10),i=n[2];let s=i,l=i;const d=i.match(r);return d&&(s=d[1],l=d[2]),{total:o,min:s===l?"":s,max:l}}function At(t={}){let e="",r="",n="",o="";const i=f=>f.split("/").map(w=>w.trim()).filter(Boolean),s=t["grid-area"]||"",l=t["grid-column"]||"",d=t["grid-row"]||"",c=i(s),p=i(l),a=i(d),u=c.length,m=p.length,h=a.length;return u===4?(n=c[0],e=c[1],o=c[2],r=c[3]):u===3?(n=c[0],e=c[1],o=c[2]):u===2?(n=c[0],e=c[1]):u===1&&(n=c[0]),m===2?(e=p[0],r=p[1]):m===1&&(e=p[0]),h===2?(n=a[0],o=a[1]):h===1&&(n=a[0]),{columnStart:e,columnEnd:r,rowStart:n,rowEnd:o}}function q(t){const{property:e,label:r}=t,n="1",o="1fr";return{property:e,label:r,type:"composite",requires:z,generic:!0,properties:[{name:" ",property:`${e}-repeat`,type:"number",full:!0,min:1,default:"1"},{label:"Min size",property:`${e}-min`,type:"number",min:0,units:["px","%"],default:"0"},{label:"Max size",property:`${e}-max`,type:"number",min:1,units:["fr","px","%"],default:"1"}],fromStyle(i,s){const{name:l,property:d}=s,[c,p,a]=d.getProperties(),u=i[l],m=Rt(u),h=(m==null?void 0:m.max)??o;return{[c.id]:(m==null?void 0:m.total)??n,[p.id]:(m==null?void 0:m.min)??"",[a.id]:h===o?"":h}},toStyle(i,{name:s,property:l}){const[d,c,p]=l.getProperties(),a=i[d.id],u=i[c.id],m=i[p.id]||o,h=u&&m?`minmax(${u}, ${m})`:m;return{[s]:`repeat(${a||n}, ${h})`}}}}function Dt(t,e){if(!e.styleableGrid)return;const{property:r,...n}=Gt(t,"display");if(!r)return;const o=r.getOption("grid"),i=n.sector;o||r.addOption({id:"grid",label:"Grid"}),i.addProperty(q({label:"Columns",property:"grid-template-columns"}),{}),i.addProperty(q({label:"Rows",property:"grid-template-rows"}),{}),i.addProperty({id:"grid-gap",requires:z,...Pt("gap",{x:{id:"grid-row-gap",label:"Row",property:"row-gap",min:0,default:"0"},y:{id:"grid-column-gap",label:"Column",property:"column-gap",min:0,default:"0"},mergable:!0})},{}),i.addProperty({type:"composite",property:"grid-area",label:"Grid area",requiresParent:z,generic:!0,properties:[{label:"Row start",property:"grid-row-start",type:"integer",default:"auto"},{label:"Row end",property:"grid-row-end",type:"integer",default:"auto"},{label:"Column start",property:"grid-column-start",type:"integer",default:"auto"},{label:"Column end",property:"grid-column-end",type:"integer",default:"auto"}],fromStyle(s){const l=At(s);return{"grid-column-start":s["grid-column-start"]||l.columnStart,"grid-column-end":s["grid-column-end"]||l.columnEnd,"grid-row-start":s["grid-row-start"]||l.rowStart,"grid-row-end":s["grid-row-end"]||l.rowEnd}},toStyle(s,{name:l}){const d=s["grid-row-start"]||"auto",c=s["grid-row-end"]||"auto",p=s["grid-column-start"]||"auto",a=s["grid-column-end"]||"auto";return{[l]:`${d} / ${p} / ${c} / ${a}`}}},{})}const Mt=function(t,e={}){const r={itemResizable:!0,...e},{Canvas:n,Commands:o,Components:i}=t,{itemResizable:s}=r,l=n.events,d=o.events,c=i.events,p=`${d.runBeforeCommand}tlb-move`,a=`${d.runBeforeCommand}resize`;let u;Et(t);const m=({options:y})=>{_(t,y.target,r)&&(t.runCommand(F,{...y}),y.abort=!0)},h=y=>{const{options:g}=y;_(t,g.component,r)&&(g.options=Object.assign(g.options||{},xt(t,g)))},f=()=>{const y=n.getSpots({type:A}).pop();if(!y)return;let g=y.attributes.spotEl;g||(g=document.createElement("div"),g.className=D,y.set({spotEl:g})),Object.entries(y.getStyle()).forEach(([S,$])=>g.style.setProperty(S,$)),u==null||u.appendChild(g)},w=({spot:y})=>{const g=y.attributes.spotEl;y.type!==A||!g||u==null||u.removeChild(g)};if(s){const y=g=>{const S=K(s)?s({component:g}):s;return typeof S=="boolean"?S:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...S}};t.on(c.resizeInit,g=>{const{component:S}=g;if(_(t,S,r)){const $=y(S);g.resizable=$}})}const b=[[p,m],[a,h],[l.spot,f],[l.spotRemove,w]];b.forEach(([y,g])=>{t.on(y,g)}),t.onReady(()=>{u=n.getSpotsEl(),ht(),Dt(t,r)});const v=()=>{delete t.Commands.commands[F],b.forEach(([y,g])=>{t.off(y,g)})};mt({editor:t,licenseKey:r.licenseKey,plan:ft,pluginName:N,cleanup:v})},It=ut(Mt);module.exports=It;
|
|
26
|
+
`,e.head.appendChild(o)};function Z(t){const{editor:e,type:r}=t,n=Rt(e,t.component),o=O(e,n.component);if(!Tt(e,n,o,r))return{target:n,container:o,startScroll:ot(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:D,component:o.component})}}function V(t){const{editor:e,shadowTargetEl:r,shadowSnappedEl:n,shadowContainerEl:o,spotEl:i,target:s,container:a}=t,{Canvas:p}=e,d=e.config.stylePrefix;i==null||i.appendChild(o),o==null||o.appendChild(r),o==null||o.appendChild(n),bt(o,a),vt(r,s,a),$t(n,s),St(o,a.el),s.el.style.opacity="0";const c=p.getSpots().filter(l=>l.type!==D);e.em.stopDefault({preserveSelected:!0}),p.removeSpots(c),p.startAutoscroll(),p.getBody().classList.add(`${d}is__grabbing`)}function tt(t){const{editor:e,shadowSnappedEl:r,shadowContainerEl:n,target:o,cancelled:i}=t,{Canvas:s}=e,a=e.config.stylePrefix,{component:p}=o;if(!i){const d=window.getComputedStyle(r);p.addStyle({"grid-area":d.gridArea,width:"",height:""})}o.el.style.opacity="",n.contains(r)&&(n==null||n.removeChild(r)),e.getModel().runDefault({preserveSelected:1}),s.stopAutoscroll(),s.getBody().classList.remove(`${a}is__grabbing`),s.removeSpots({type:D}),e.select(p)}function bt(t,{rows:e,columns:r}){const n=[];for(let o=0;o<r.length;o++){n[o]=[];for(let i=0;i<e.length;i++){const s=document.createElement("div");s.className=K,s.style.gridArea=`${i+1} / ${o+1}`,n[o][i]=s,t.appendChild(s)}}return n}function vt(t,e,r){return t.className=J,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}function $t(t,e){const r=nt(e.el,e.computedStyles);return t.className=Q,t.style.gridArea=`${r.row.start} / ${r.column.start} / ${r.row.end} / ${r.column.end}`,t}function St(t,e){const r=window.getComputedStyle(e);t.className=ht,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}function et(t,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...t.getSelectedAll()].pop();return e}function Rt(t,e){const r=et(t,e),n=r.getEl(),o=window.getComputedStyle(n);return{component:r,el:n,offset:t.Canvas.offset(n),margin:{top:parseFloat(o.marginTop),right:parseFloat(o.marginRight),bottom:parseFloat(o.marginBottom),left:parseFloat(o.marginLeft)},computedStyles:o}}function O(t,e){const r=e.parent(),n=r.getEl(),o=window.getComputedStyle(n);return{component:r,el:n,offset:t.Canvas.offset(n),computedStyles:o,padding:{top:parseFloat(o.paddingTop),right:parseFloat(o.paddingRight),bottom:parseFloat(o.paddingBottom),left:parseFloat(o.paddingLeft)},columns:o.gridTemplateColumns.split(" ").map(s=>parseFloat(s)),rows:o.gridTemplateRows.split(" ").map(s=>parseFloat(s)),gap:{column:parseInt(o.columnGap),row:parseInt(o.rowGap)}}}function T(t,e,r,n,o=1){let i=0;for(let s=e;s<=t.length;s++){if(i+(t[s-1]+n)*o>r)return s;i+=n+t[s-1]}return t.length+1}function ot(t){const{scrollY:e,scrollX:r}=t.Canvas.getWindow();return{scroll:{top:e,left:r}}}function Tt(t,e,r,n){const o=i=>t.em.logWarning(i);return n==="draggable"&&e.component.get(n)===!1?(o(`[${N}] The element is not ${n}`),!0):r.computedStyles.display!=="grid"?(o(`[${N}] The container does not have style display:grid`),!0):!1}function L(t,e,r={}){const n=et(t,e),o=n==null?void 0:n.parent(),i=o==null?void 0:o.getEl();if(!o||!i)return!1;const{enableGrid:s}=r,a=window.getComputedStyle(i).display==="grid";return X(s)?s({component:n,parent:o,isParentGrid:a}):a}const U=t=>t.split(" ").map(e=>parseFloat(e));function nt(t,e){const r=t.ownerDocument.defaultView,n=e||r.getComputedStyle(t),o=n.gridArea.split("/").some(b=>isNaN(parseInt(b.trim()))),i={isComputed:o,raw:n.gridArea};if(!o)return{...i,row:{start:parseInt(n.gridRowStart),end:parseInt(n.gridRowEnd)},column:{start:parseInt(n.gridColumnStart),end:parseInt(n.gridColumnEnd)}};const s=t.parentElement,a=r.getComputedStyle(s),p=parseFloat(a.columnGap)||0,d=parseFloat(a.rowGap)||0,c=U(a.gridTemplateColumns),l=U(a.gridTemplateRows),g=parseFloat(a.paddingLeft)||0,u=parseFloat(a.paddingTop)||0,h=s.getBoundingClientRect(),m=t.getBoundingClientRect(),w=(b,$,x,S,C)=>{let E=1,P=S+C;for(let A=0;A<$.length;A++){const I=$[A],z=P+I;if(b>=P&&b<z)return E;P=z+x,E++}return-1},v=w(m.left,c,p,h.left,g),R=w(m.right-1,c,p,h.left,g)+1,y=w(m.top,l,d,h.top,u),f=w(m.bottom-1,l,d,h.top,u)+1;return{...i,row:{start:y,end:f},column:{start:v,end:R}}}function xt(t){t.Commands.add(F,{stop(){},run(e,r,n={}){const o=Z({editor:e,component:n.target,type:"draggable"});if(!o){this.stopCommand();return}const{spot:i,target:s,shadowContainerEl:a,shadowSnappedEl:p,shadowTargetEl:d,startScroll:c}=o;let{container:l}=o,g;new e.Utils.Dragger({doc:s.el.ownerDocument,onStart:()=>{g=setTimeout(()=>{V({editor:e,shadowTargetEl:d,shadowSnappedEl:p,shadowContainerEl:a,spotEl:i.attributes.spotEl,target:s,container:l}),l=O(e,s.component)},10)},onEnd:(h,m,{cancelled:w})=>{clearTimeout(g),tt({editor:e,shadowSnappedEl:p,shadowContainerEl:a,target:s,cancelled:w}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:h,y:m})=>{const{scroll:w}=ot(e),{columns:v,rows:R,gap:y,offset:f,padding:b}=l,{offset:$,margin:x}=s,S=$.top-f.top-b.top-x.top+m-c.top+w.top,C=$.left-f.left-b.left-x.left+h-c.left+w.left,E=Math.min(T(v,1,C,y.column,.5),v.length),P=Math.min(T(R,1,S,y.row,.5),R.length),A=Math.min(T(v,E,$.width,y.column)+1,v.length+1),I=Math.min(T(R,P,$.height,y.row)+1,R.length+1);p.style.gridArea=`${P} / ${E} / ${I} / ${A}`,d.style.top=`${S+b.top}px`,d.style.left=`${C+b.left}px`}}).start(n.event)}})}function Pt(t,e){const r=Z({editor:t,component:e.component,type:"resizable"});if(!r)return;const{onMove:n,onEnd:o}=e.options||{},{spot:i,target:s,shadowContainerEl:a,shadowSnappedEl:p,shadowTargetEl:d}=r;let{container:c}=r,l="",g;return{onStart:u=>{l=u.target.dataset.gjsHandler||"",g=setTimeout(()=>{V({editor:t,shadowTargetEl:d,shadowSnappedEl:p,shadowContainerEl:a,spotEl:i.attributes.spotEl,target:s,container:c}),c=O(t,s.component)},10),t.trigger("component:resize",{...s,type:"start"})},onEnd:(u,h)=>{const{startDim:m,rectDim:w}=h.resizer,v=JSON.stringify(m)===JSON.stringify(w);clearTimeout(g),tt({editor:t,shadowSnappedEl:p,shadowContainerEl:a,target:s,cancelled:v}),o==null||o(u,h)},onMove:(u,h)=>{const m=nt(p),w=s.margin.left,v=s.margin.top,R=s.margin.bottom,y=s.margin.right,{w:f,t:b,l:$,h:x}=h.resizer.rectDim,S={t:b-v,l:$-w,h:x+v+R,w:f+w+y};l.endsWith("l")&&(m.column.start=T(c.columns,1,S.l-c.offset.left-c.padding.left,c.gap.column,.5)),l.startsWith("t")&&(m.row.start=T(c.rows,1,S.t-c.offset.top-c.padding.top,c.gap.row,.5)),l.endsWith("r")&&(m.column.end=Math.max(T(c.columns,m.column.start,S.w,c.gap.column,.5),m.column.start+1)),l.startsWith("b")&&(m.row.end=Math.max(T(c.rows,m.row.start,S.h,c.gap.row,.5),m.row.start+1)),p.style.gridArea=`${m.row.start} / ${m.column.start} / ${m.row.end} / ${m.column.end}`,d.style.width=`${S.w}px`,d.style.height=`${S.h}px`,d.style.left=`${S.l-c.offset.left}px`,d.style.top=`${S.t-c.offset.top}px`,n==null||n(u,h)}}}const k=["px","%","em","rem","vw","vh"],Gt=(t,e)=>{const r=t.Styles.getSectors().find(n=>!!n.getProperty(e));return{sector:r,property:r?r.getProperty(e):void 0}},Et=(t,e)=>Gt(t,e),At=(t,{x:e,y:r,mergable:n}={})=>{const o={property:`${t}-x`,type:"integer",units:k,...e},i={property:`${t}-y`,type:"integer",units:k,...r};return{property:t,type:"composite",properties:[o,i],...n&&{fromStyle(s,{name:a,separator:p,property:d}){const[c,l]=d.getProperties(),[g,u]=(s[a]||"").split(p);return{[c.getId()]:s[c.getName()]||g||"",[l.getId()]:s[l.getName()]||u||g||""}},toStyle(s,{name:a,property:p}){const[d,c]=p.getProperties(),l=s[d.getId()],g=s[c.getId()];return{[a]:l===g?l:`${l} ${g}`}}}}},B={display:["grid"]};function Dt(t=""){const e=/^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i,r=/^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i,n=t.match(e);if(!n)return null;const o=parseInt(n[1],10),i=n[2];let s=i,a=i;const p=i.match(r);return p&&(s=p[1],a=p[2]),{total:o,min:s===a?"":s,max:a}}function Mt(t={}){let e="",r="",n="",o="";const i=m=>m.split("/").map(w=>w.trim()).filter(Boolean),s=t["grid-area"]||"",a=t["grid-column"]||"",p=t["grid-row"]||"",d=i(s),c=i(a),l=i(p),g=d.length,u=c.length,h=l.length;return g===4?(n=d[0],e=d[1],o=d[2],r=d[3]):g===3?(n=d[0],e=d[1],o=d[2]):g===2?(n=d[0],e=d[1]):g===1&&(n=d[0]),u===2?(e=c[0],r=c[1]):u===1&&(e=c[0]),h===2?(n=l[0],o=l[1]):h===1&&(n=l[0]),{columnStart:e,columnEnd:r,rowStart:n,rowEnd:o}}function q(t){const{property:e,label:r}=t,n="1",o="1fr";return{property:e,label:r,type:"composite",requires:B,generic:!0,properties:[{name:" ",property:`${e}-repeat`,type:"number",full:!0,min:1,default:"1"},{label:"Min size",property:`${e}-min`,type:"number",min:0,units:["px","%"],default:"0"},{label:"Max size",property:`${e}-max`,type:"number",min:1,units:["fr","px","%"],default:"1"}],fromStyle(i,s){const{name:a,property:p}=s,[d,c,l]=p.getProperties(),g=i[a],u=Dt(g),h=(u==null?void 0:u.max)??o;return{[d.id]:(u==null?void 0:u.total)??n,[c.id]:(u==null?void 0:u.min)??"",[l.id]:h===o?"":h}},toStyle(i,{name:s,property:a}){const[p,d,c]=a.getProperties(),l=i[p.id],g=i[d.id],u=i[c.id]||o,h=g&&u?`minmax(${g}, ${u})`:u;return{[s]:`repeat(${l||n}, ${h})`}}}}function Ct(t,e){if(!e.styleableGrid)return;const{property:r,...n}=Et(t,"display");if(!r)return;const o=r.getOption("grid"),i=n.sector;o||r.addOption({id:"grid",label:"Grid"}),i.addProperty(q({label:"Columns",property:"grid-template-columns"}),{}),i.addProperty(q({label:"Rows",property:"grid-template-rows"}),{}),i.addProperty({id:"grid-gap",requires:B,...At("gap",{x:{id:"grid-row-gap",label:"Row",property:"row-gap",min:0,default:"0"},y:{id:"grid-column-gap",label:"Column",property:"column-gap",min:0,default:"0"},mergable:!0})},{}),i.addProperty({type:"composite",property:"grid-area",label:"Grid area",requiresParent:B,generic:!0,properties:[{label:"Row start",property:"grid-row-start",type:"integer",default:"auto"},{label:"Row end",property:"grid-row-end",type:"integer",default:"auto"},{label:"Column start",property:"grid-column-start",type:"integer",default:"auto"},{label:"Column end",property:"grid-column-end",type:"integer",default:"auto"}],fromStyle(s){const a=Mt(s);return{"grid-column-start":s["grid-column-start"]||a.columnStart,"grid-column-end":s["grid-column-end"]||a.columnEnd,"grid-row-start":s["grid-row-start"]||a.rowStart,"grid-row-end":s["grid-row-end"]||a.rowEnd}},toStyle(s,{name:a}){const p=s["grid-row-start"]||"auto",d=s["grid-row-end"]||"auto",c=s["grid-column-start"]||"auto",l=s["grid-column-end"]||"auto";return{[a]:`${p} / ${c} / ${d} / ${l}`}}},{})}const It=function(t,e={}){const r={itemResizable:!0,...e},{Canvas:n,Commands:o,Components:i}=t,{itemResizable:s}=r,a=n.events,p=o.events,d=i.events,c=`${p.runBeforeCommand}tlb-move`,l=`${p.runBeforeCommand}resize`;let g;xt(t);const u=({options:y})=>{L(t,y.target,r)&&(t.runCommand(F,{...y}),y.abort=!0)},h=y=>{const{options:f}=y;L(t,f.component,r)&&(f.options=Object.assign(f.options||{},Pt(t,f)))},m=()=>{const y=n.getSpots({type:D}).pop();if(!y)return;let f=y.attributes.spotEl;f||(f=document.createElement("div"),f.className=M,y.set({spotEl:f})),Object.entries(y.getStyle()).forEach(([b,$])=>f.style.setProperty(b,$)),g==null||g.appendChild(f)},w=({spot:y})=>{const f=y.attributes.spotEl;y.type!==D||!f||g==null||g.removeChild(f)};if(s){const y=f=>{const b=X(s)?s({component:f}):s;return typeof b=="boolean"?b:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...b}};t.on(d.resizeInit,f=>{const{component:b}=f;if(L(t,b,r)){const $=y(b);f.resizable=$}})}const v=[[c,u],[l,h],[a.spot,m],[a.spotRemove,w]];v.forEach(([y,f])=>{t.on(y,f)}),t.onReady(()=>{g=n.getSpotsEl(),wt(),Ct(t,r)});const R=()=>{delete t.Commands.commands[F],v.forEach(([y,f])=>{t.off(y,f)})};ut({editor:t,licenseKey:r.licenseKey,plan:yt,pluginName:N,cleanup:R})},Lt=gt(It);module.exports=Lt;
|