@grapesjs/studio-sdk-plugins 1.0.25 → 1.0.26-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dataSourceEjs/EjsExporter.d.ts +2 -2
- package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +2 -2
- package/dist/flexComponent/index.cjs.js +1 -1
- package/dist/flexComponent/index.es.js +1 -1
- package/dist/flexComponent/index.umd.js +1 -1
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +4 -4
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +1 -1
- package/dist/iconifyComponent/index.es.js +1 -1
- package/dist/iconifyComponent/index.umd.js +1 -1
- package/dist/index.cjs.js +21 -21
- package/dist/index.es.js +219 -216
- package/dist/index.umd.js +2 -2
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +19 -19
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/types.d.ts +2 -1
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +101 -101
- package/dist/presetPrintable/index.umd.js +1 -1
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rendererReact/index.cjs.d.ts +3 -2
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.d.ts +3 -2
- package/dist/rendererReact/index.es.d.ts +3 -2
- package/dist/rendererReact/index.es.js +219 -153
- package/dist/rendererReact/index.js +1 -0
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rendererReact/rendererCanvas/RenderCanvasComponent.d.ts +4 -2
- package/dist/rendererReact/rendererCanvas/customRenderer.d.ts +2 -2
- package/dist/rendererReact/rendererCanvas/util.d.ts +27 -7
- package/dist/rendererReact/rendererProject/RenderComponent.d.ts +2 -0
- package/dist/rendererReact/rendererProject/RenderError.d.ts +2 -0
- package/dist/rendererReact/rendererProject/RenderPage.d.ts +2 -0
- package/dist/rendererReact/rendererProject/RenderProject.d.ts +3 -0
- package/dist/rendererReact/rendererProject/index.cjs.d.ts +1 -2
- package/dist/rendererReact/rendererProject/index.cjs.js +2 -10
- package/dist/rendererReact/rendererProject/index.d.ts +1 -2
- package/dist/rendererReact/rendererProject/index.es.d.ts +1 -2
- package/dist/rendererReact/rendererProject/index.es.js +206 -227
- package/dist/rendererReact/rendererProject/index.js +2 -10
- package/dist/rendererReact/rendererProject/index.umd.js +2 -10
- package/dist/rendererReact/rendererProject/parser/parser.d.ts +34 -53
- package/dist/rendererReact/rendererProject/types.d.ts +18 -4
- package/dist/rendererReact/rendererProject/util.d.ts +0 -11
- package/dist/rendererReact/shared/shared.d.ts +3 -0
- package/dist/rendererReact/shared/types.d.ts +150 -44
- package/dist/rendererReact/shared/util.d.ts +7 -1
- package/dist/rendererReact/types.d.ts +9 -12
- package/dist/rendererReact/typesSchema.d.ts +116 -49
- package/dist/rteTinyMce/index.cjs.js +1 -1
- package/dist/rteTinyMce/index.es.js +1 -1
- package/dist/rteTinyMce/index.umd.js +1 -1
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +15 -12
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +6 -6
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +14 -2
- package/dist/rendererReact/rendererProject/GrapesJSProject.d.ts +0 -3
- package/dist/rendererReact/rendererProject/RenderProjectComponent.d.ts +0 -12
|
@@ -1,91 +1,87 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createElement as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return
|
|
1
|
+
import { jsx as l, jsxs as C } from "react/jsx-runtime";
|
|
2
|
+
import { createElement as T, Fragment as v } from "react";
|
|
3
|
+
var m = /* @__PURE__ */ ((n) => (n.NoPagesFound = "noPagesFound", n.PageNotFound = "pageNotFound", n.NoFramesFound = "noFramesFound", n.MissingRootComponent = "missingRootComponent", n.ComponentNotFound = "componentNotFound", n))(m || {});
|
|
4
|
+
function k(n) {
|
|
5
|
+
const { config: t, errorType: e } = n, r = t == null ? void 0 : t.errorComponent;
|
|
6
|
+
return r ? /* @__PURE__ */ l(r, { ...n }) : /* @__PURE__ */ C("div", { children: [
|
|
7
|
+
"Error: ",
|
|
8
|
+
e
|
|
9
|
+
] });
|
|
7
10
|
}
|
|
8
|
-
|
|
9
|
-
noPagesFound: () => "No pages found in project",
|
|
10
|
-
pageNotFound: ({ pageId: s = "" }) => `Page not found: ${s}`,
|
|
11
|
-
noFramesFound: () => "No frames found in page",
|
|
12
|
-
missingRootComponent: () => "Missing root component",
|
|
13
|
-
componentNotFound: ({ componentId: s = "" }) => `Component not found: ${s}`
|
|
14
|
-
};
|
|
15
|
-
function R(s) {
|
|
11
|
+
function P(n) {
|
|
16
12
|
const t = {};
|
|
17
13
|
let e = !1;
|
|
18
|
-
for (const
|
|
19
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
20
|
-
const
|
|
21
|
-
if (typeof
|
|
22
|
-
const
|
|
23
|
-
t[
|
|
14
|
+
for (const r in n)
|
|
15
|
+
if (Object.prototype.hasOwnProperty.call(n, r)) {
|
|
16
|
+
const s = n[r];
|
|
17
|
+
if (typeof s == "string" || typeof s == "number") {
|
|
18
|
+
const o = r.includes("-") ? r.replace(/-([a-z])/g, (i) => i[1].toUpperCase()) : r;
|
|
19
|
+
t[o] = s, e = !0;
|
|
24
20
|
}
|
|
25
21
|
}
|
|
26
22
|
return e ? t : void 0;
|
|
27
23
|
}
|
|
28
|
-
function D(
|
|
24
|
+
function D(n) {
|
|
29
25
|
const t = {};
|
|
30
|
-
return
|
|
26
|
+
return n.split(";").forEach((e) => {
|
|
31
27
|
if (!e.trim()) return;
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
const
|
|
37
|
-
t[
|
|
28
|
+
const r = e.indexOf(":");
|
|
29
|
+
if (r > 0) {
|
|
30
|
+
const s = e.substring(0, r).trim(), o = e.substring(r + 1).trim();
|
|
31
|
+
if (s && o) {
|
|
32
|
+
const i = s.replace(/-([a-z])/g, (c) => c[1].toUpperCase());
|
|
33
|
+
t[i] = o;
|
|
38
34
|
}
|
|
39
35
|
}
|
|
40
36
|
}), Object.keys(t).length > 0 ? t : void 0;
|
|
41
37
|
}
|
|
42
|
-
function
|
|
43
|
-
if (
|
|
44
|
-
if (typeof
|
|
45
|
-
return
|
|
46
|
-
if (typeof
|
|
47
|
-
let t = D(
|
|
38
|
+
function W(n) {
|
|
39
|
+
if (n) {
|
|
40
|
+
if (typeof n == "object" && !Array.isArray(n))
|
|
41
|
+
return P(n);
|
|
42
|
+
if (typeof n == "string") {
|
|
43
|
+
let t = D(n);
|
|
48
44
|
if (!t)
|
|
49
45
|
try {
|
|
50
|
-
const e = JSON.parse(
|
|
51
|
-
typeof e == "object" && e !== null && !Array.isArray(e) && (t =
|
|
46
|
+
const e = JSON.parse(n);
|
|
47
|
+
typeof e == "object" && e !== null && !Array.isArray(e) && (t = P(e));
|
|
52
48
|
} catch (e) {
|
|
53
49
|
console.error("Failed to parse style string as JSON", e);
|
|
54
50
|
}
|
|
55
51
|
return t;
|
|
56
52
|
}
|
|
57
|
-
if (Array.isArray(
|
|
53
|
+
if (Array.isArray(n)) {
|
|
58
54
|
const t = {};
|
|
59
|
-
return
|
|
55
|
+
return n.forEach((e) => {
|
|
60
56
|
if (typeof e == "object" && e !== null) {
|
|
61
|
-
const
|
|
62
|
-
if (typeof
|
|
63
|
-
const
|
|
64
|
-
t[
|
|
57
|
+
const r = e.name || e.property, s = e.value;
|
|
58
|
+
if (typeof r == "string" && r && s !== void 0 && s !== "") {
|
|
59
|
+
const o = r.replace(/-([a-z])/g, (i) => i[1].toUpperCase());
|
|
60
|
+
t[o] = s;
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
63
|
}), Object.keys(t).length > 0 ? t : void 0;
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
66
|
}
|
|
71
|
-
function B(
|
|
72
|
-
return
|
|
67
|
+
function B(n) {
|
|
68
|
+
return j[n] ? j[n] : n.includes("-") ? n.replace(/-([a-z])/g, (t, e) => e.toUpperCase()) : n;
|
|
73
69
|
}
|
|
74
|
-
function
|
|
75
|
-
var
|
|
76
|
-
const t = {}
|
|
77
|
-
for (const [
|
|
78
|
-
if (
|
|
79
|
-
t.style =
|
|
80
|
-
else if (
|
|
81
|
-
t[
|
|
70
|
+
function I(n) {
|
|
71
|
+
var e;
|
|
72
|
+
const t = {};
|
|
73
|
+
for (const [r, s] of Object.entries(n))
|
|
74
|
+
if (r === "style")
|
|
75
|
+
t.style = W(s);
|
|
76
|
+
else if (r.startsWith("data-"))
|
|
77
|
+
t[r] = s;
|
|
82
78
|
else {
|
|
83
|
-
const
|
|
84
|
-
e ||
|
|
79
|
+
const o = B(r);
|
|
80
|
+
((e = n.xmlns) == null ? void 0 : e.includes("svg")) || n.viewBox !== void 0 || n.d !== void 0 || z.has(o) || o.startsWith("svg") ? t[o] = s : !M.has(o) && !o.startsWith("on") && !o.startsWith("aria-") && !o.startsWith("data-") ? t[r] = s : t[o] = s;
|
|
85
81
|
}
|
|
86
82
|
return t;
|
|
87
83
|
}
|
|
88
|
-
const
|
|
84
|
+
const M = /* @__PURE__ */ new Set([
|
|
89
85
|
"className",
|
|
90
86
|
"id",
|
|
91
87
|
"style",
|
|
@@ -126,7 +122,7 @@ const z = /* @__PURE__ */ new Set([
|
|
|
126
122
|
"aria-labelledby",
|
|
127
123
|
"aria-describedby",
|
|
128
124
|
"role"
|
|
129
|
-
]),
|
|
125
|
+
]), z = /* @__PURE__ */ new Set([
|
|
130
126
|
"x",
|
|
131
127
|
"y",
|
|
132
128
|
"d",
|
|
@@ -169,7 +165,7 @@ const z = /* @__PURE__ */ new Set([
|
|
|
169
165
|
"clipPath",
|
|
170
166
|
"overflow",
|
|
171
167
|
"pointerEvents"
|
|
172
|
-
]),
|
|
168
|
+
]), j = {
|
|
173
169
|
class: "className",
|
|
174
170
|
for: "htmlFor",
|
|
175
171
|
"http-equiv": "httpEquiv",
|
|
@@ -186,117 +182,106 @@ const z = /* @__PURE__ */ new Set([
|
|
|
186
182
|
"font-family": "fontFamily",
|
|
187
183
|
"font-size": "fontSize",
|
|
188
184
|
"text-anchor": "textAnchor"
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const {
|
|
185
|
+
};
|
|
186
|
+
function L(n, t, e) {
|
|
187
|
+
const { id: r, type: s } = n, o = r || void 0;
|
|
188
|
+
let i;
|
|
189
|
+
return r ? i = r : t ? i = `${t}-${e ?? 0}` : s === "head" ? i = "gjs-head" : t === "gjs-head" ? i = `${t}-${e ?? 0}` : i = `gjs-${s}`, { key: i, nodeId: o };
|
|
190
|
+
}
|
|
191
|
+
const R = function n(t) {
|
|
192
|
+
var w;
|
|
193
|
+
const { component: e, config: r, children: s, parentId: o, index: i } = t;
|
|
192
194
|
if (!e) return null;
|
|
193
|
-
const
|
|
194
|
-
if (c === "textnode") return
|
|
195
|
-
const
|
|
196
|
-
b && Object.keys(
|
|
197
|
-
const
|
|
198
|
-
typeof
|
|
195
|
+
const { type: c, content: a } = e;
|
|
196
|
+
if (c === "textnode") return a;
|
|
197
|
+
const u = (w = r == null ? void 0 : r.components) == null ? void 0 : w[c], d = (u == null ? void 0 : u.component) || e.tagName || "div", h = e.attributes, { key: g, nodeId: N } = L(e, o, i), b = !!(u != null && u.component), A = I(h);
|
|
198
|
+
b && Object.keys(A).forEach((y) => {
|
|
199
|
+
const p = A[y];
|
|
200
|
+
typeof p == "string" && !isNaN(Number(p)) && p.trim() !== "" && (A[y] = Number(p));
|
|
199
201
|
});
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
{
|
|
203
|
-
config: o,
|
|
204
|
-
component: m,
|
|
205
|
-
parentId: f,
|
|
206
|
-
index: g
|
|
207
|
-
},
|
|
208
|
-
`${m.getId()}-${g}`
|
|
209
|
-
)) : [p], a], P = {
|
|
210
|
-
...C,
|
|
211
|
-
...w ? { id: w } : {}
|
|
202
|
+
const { components: F } = e, x = [...F.length ? F.map((y, p) => /* @__PURE__ */ l(n, { config: r, component: y, parentId: g, index: p }, `${y.id}-${p}`)) : [a], s], $ = {
|
|
203
|
+
...A,
|
|
204
|
+
...N ? { id: N } : {}
|
|
212
205
|
};
|
|
213
|
-
return b ? /* @__PURE__ */
|
|
206
|
+
return b ? /* @__PURE__ */ l(d, { ...$, children: x }, g) : /* @__PURE__ */ T(d, { ...$, key: g }, e.isVoid ? null : x);
|
|
214
207
|
};
|
|
215
|
-
|
|
208
|
+
function U(n) {
|
|
209
|
+
var a;
|
|
210
|
+
const { config: t, root: e, css: r } = n, s = (t == null ? void 0 : t.rootComponent) || v, o = ((a = e.docEl) == null ? void 0 : a.tagName) || "html", i = (t == null ? void 0 : t.headAfter) || v, c = (t == null ? void 0 : t.bodyAfter) || v;
|
|
211
|
+
return /* @__PURE__ */ l(o, { children: /* @__PURE__ */ C(s, { children: [
|
|
212
|
+
/* @__PURE__ */ C(R, { component: e.head, config: t, children: [
|
|
213
|
+
/* @__PURE__ */ l("style", { children: `${r}` }),
|
|
214
|
+
/* @__PURE__ */ l(i, {})
|
|
215
|
+
] }),
|
|
216
|
+
/* @__PURE__ */ l(R, { component: e, config: t, children: /* @__PURE__ */ l(c, {}) })
|
|
217
|
+
] }) });
|
|
218
|
+
}
|
|
219
|
+
class S {
|
|
216
220
|
constructor(t) {
|
|
217
221
|
this.data = t;
|
|
218
222
|
}
|
|
219
|
-
|
|
223
|
+
get id() {
|
|
220
224
|
var t;
|
|
221
225
|
return (t = this.data.attributes) == null ? void 0 : t.id;
|
|
222
226
|
}
|
|
223
|
-
|
|
227
|
+
get type() {
|
|
224
228
|
return this.data.type || "default";
|
|
225
229
|
}
|
|
226
|
-
|
|
227
|
-
const t = this
|
|
230
|
+
get tagName() {
|
|
231
|
+
const { type: t } = this;
|
|
228
232
|
return t === "svg" ? "svg" : t === "image" ? "img" : t === "linkBox" || t === "link" ? "a" : t === "head" ? "head" : t === "wrapper" ? "body" : this.data.tagName || "";
|
|
229
233
|
}
|
|
230
|
-
isVoid() {
|
|
231
|
-
return this.
|
|
234
|
+
get isVoid() {
|
|
235
|
+
return this.tagName === "img" ? !0 : !!this.data.void;
|
|
232
236
|
}
|
|
233
|
-
|
|
234
|
-
const t = { ...this.data.attributes }, e = this
|
|
237
|
+
get attributes() {
|
|
238
|
+
const t = { ...this.data.attributes }, { classes: e } = this;
|
|
235
239
|
e.length && (t.class = e.join(" "));
|
|
236
|
-
function
|
|
237
|
-
return Object.prototype.hasOwnProperty.call(
|
|
240
|
+
function r(s, o) {
|
|
241
|
+
return Object.prototype.hasOwnProperty.call(s, o);
|
|
238
242
|
}
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
getStyle() {
|
|
242
|
-
return this.data.style || {};
|
|
243
|
+
return r(t, "id") || (t.id = this.id), t;
|
|
243
244
|
}
|
|
244
|
-
|
|
245
|
+
get content() {
|
|
245
246
|
return this.data.content || "";
|
|
246
247
|
}
|
|
247
|
-
|
|
248
|
-
return (this.data.components || []).map((t) => new
|
|
248
|
+
get components() {
|
|
249
|
+
return (this.data.components || []).map((t) => new S(t));
|
|
249
250
|
}
|
|
250
|
-
|
|
251
|
-
return
|
|
251
|
+
get head() {
|
|
252
|
+
return new S(this.data.head || { tagName: "head" });
|
|
252
253
|
}
|
|
253
|
-
|
|
254
|
+
get docEl() {
|
|
254
255
|
return this.data.docEl;
|
|
255
256
|
}
|
|
256
|
-
|
|
257
|
+
get classes() {
|
|
257
258
|
return (this.data.classes || []).map((e) => typeof e == "string" ? e : e.name);
|
|
258
259
|
}
|
|
259
|
-
hasClass(t) {
|
|
260
|
-
return this.getClasses().includes(t);
|
|
261
|
-
}
|
|
262
260
|
}
|
|
263
|
-
class
|
|
261
|
+
class _ {
|
|
264
262
|
constructor(t) {
|
|
265
263
|
this.data = t;
|
|
266
264
|
}
|
|
267
|
-
|
|
268
|
-
return this.data.component ? new
|
|
269
|
-
}
|
|
270
|
-
getWidth() {
|
|
271
|
-
return this.data.width || "";
|
|
272
|
-
}
|
|
273
|
-
getHeight() {
|
|
274
|
-
return this.data.height || "";
|
|
265
|
+
get component() {
|
|
266
|
+
return this.data.component ? new S(this.data.component) : null;
|
|
275
267
|
}
|
|
276
268
|
}
|
|
277
269
|
class V {
|
|
278
270
|
constructor(t) {
|
|
279
271
|
this.data = t;
|
|
280
272
|
}
|
|
281
|
-
|
|
273
|
+
get id() {
|
|
282
274
|
return this.data.id;
|
|
283
275
|
}
|
|
284
|
-
|
|
285
|
-
return this.data.
|
|
286
|
-
}
|
|
287
|
-
getFrames() {
|
|
288
|
-
return (this.data.frames || []).map((t) => new U(t));
|
|
276
|
+
get frames() {
|
|
277
|
+
return (this.data.frames || []).map((t) => new _(t));
|
|
289
278
|
}
|
|
290
279
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
getAll() {
|
|
296
|
-
return this.assets;
|
|
297
|
-
}
|
|
280
|
+
function E(n) {
|
|
281
|
+
const t = /(-?\d*\.?\d+)\w{0,}/.exec(n);
|
|
282
|
+
return t ? parseFloat(t[1]) : Number.MAX_VALUE;
|
|
298
283
|
}
|
|
299
|
-
class
|
|
284
|
+
class q {
|
|
300
285
|
constructor(t) {
|
|
301
286
|
this.rules = t;
|
|
302
287
|
}
|
|
@@ -306,50 +291,75 @@ class G {
|
|
|
306
291
|
getRulesByGroup(t) {
|
|
307
292
|
return this.rules.filter((e) => e.group === t);
|
|
308
293
|
}
|
|
309
|
-
|
|
310
|
-
|
|
294
|
+
getAtRule(t) {
|
|
295
|
+
const { atRuleType: e, mediaText: r } = t, s = e ? `@${e}` : r ? "@media" : "";
|
|
296
|
+
return s + (r && s ? ` ${r}` : "");
|
|
297
|
+
}
|
|
298
|
+
selectorsToString(t, e = {}) {
|
|
299
|
+
const r = [], { state: s, selectorsAdd: o, selectors: i = [] } = t, c = i.map((u) => this.getFromSelectorName(u)).join(""), a = s && !e.skipState ? `:${s}` : "";
|
|
300
|
+
return c && r.push(`${c}${a}`), o && !e.skipAdd && r.push(o), r.join(", ");
|
|
301
|
+
}
|
|
302
|
+
getFromSelectorName(t = "") {
|
|
303
|
+
return `${t.startsWith("#") ? "" : "."}${t}`;
|
|
304
|
+
}
|
|
305
|
+
styleToString(t = {}) {
|
|
306
|
+
const e = [], { style: r = {}, important: s } = t;
|
|
307
|
+
for (const o in r) {
|
|
308
|
+
const i = Array.isArray(s) ? s.indexOf(o) >= 0 : s;
|
|
309
|
+
if (o.substring(0, 2) === "__") continue;
|
|
310
|
+
const a = r[o];
|
|
311
|
+
(Array.isArray(a) ? a : [a]).forEach((f) => {
|
|
312
|
+
const d = `${f}${i ? " !important" : ""}`;
|
|
313
|
+
d && e.push(`${o}:${d};`);
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
return e.join("");
|
|
317
|
+
}
|
|
318
|
+
getDeclaration(t) {
|
|
319
|
+
const { singleAtRule: e } = t, r = this.selectorsToString(t), s = this.styleToString(t);
|
|
320
|
+
let o = "";
|
|
321
|
+
return (r || e) && s && (o = e ? s : `${r}{${s}}`), o;
|
|
322
|
+
}
|
|
323
|
+
buildFromRule(t) {
|
|
324
|
+
let e = "";
|
|
325
|
+
const r = this.selectorsToString(t), { selectorsAdd: s, singleAtRule: o } = t;
|
|
326
|
+
if (r || s || o) {
|
|
327
|
+
const i = this.getDeclaration(t);
|
|
328
|
+
i && (e += i);
|
|
329
|
+
}
|
|
330
|
+
return e;
|
|
331
|
+
}
|
|
332
|
+
sortMediaObject(t = {}) {
|
|
333
|
+
const e = [];
|
|
334
|
+
for (const r in t) {
|
|
335
|
+
const s = t[r];
|
|
336
|
+
e.push({ key: r, value: s });
|
|
337
|
+
}
|
|
338
|
+
return e.sort((r, s) => {
|
|
339
|
+
const o = [r.key, s.key].every((a) => a.indexOf("min-width") !== -1), i = o ? r.key : s.key, c = o ? s.key : r.key;
|
|
340
|
+
return E(i) - E(c);
|
|
341
|
+
});
|
|
311
342
|
}
|
|
312
343
|
getCssAsString() {
|
|
313
344
|
if (!this.rules || !this.rules.length) return "";
|
|
314
|
-
const t =
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
return
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
const n = r.atRuleType && r.mediaText ? `@${r.atRuleType} ${r.mediaText}` : r.mediaText ? `@media ${r.mediaText}` : null;
|
|
332
|
-
n ? (o[n] || (o[n] = []), o[n].push(r)) : e.push(r);
|
|
333
|
-
});
|
|
334
|
-
let a = e.map((r) => t(r)).join(`
|
|
345
|
+
const { rules: t } = this, e = {}, r = [];
|
|
346
|
+
return t.forEach((s) => {
|
|
347
|
+
const o = this.getAtRule(s);
|
|
348
|
+
if (o) {
|
|
349
|
+
const i = e[o];
|
|
350
|
+
i ? i.push(s) : e[o] = [s];
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
r.push(this.buildFromRule(s));
|
|
354
|
+
}), this.sortMediaObject(e).forEach((s) => {
|
|
355
|
+
let o = "";
|
|
356
|
+
const i = s.key;
|
|
357
|
+
s.value.forEach((a) => {
|
|
358
|
+
const u = this.buildFromRule(a);
|
|
359
|
+
a.singleAtRule ? r.push(`${i}{${u}}`) : o += u;
|
|
360
|
+
}), o && r.push(`${i}{${o}}`);
|
|
361
|
+
}), r.join(`
|
|
335
362
|
`);
|
|
336
|
-
return Object.keys(o).forEach((r) => {
|
|
337
|
-
const n = o[r].map((c) => t(c)).join(`
|
|
338
|
-
`);
|
|
339
|
-
n && (a += `
|
|
340
|
-
|
|
341
|
-
${r} {
|
|
342
|
-
${n}
|
|
343
|
-
}`);
|
|
344
|
-
}), a;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
class H {
|
|
348
|
-
constructor(t) {
|
|
349
|
-
this.symbols = t;
|
|
350
|
-
}
|
|
351
|
-
getAll() {
|
|
352
|
-
return this.symbols;
|
|
353
363
|
}
|
|
354
364
|
}
|
|
355
365
|
class J {
|
|
@@ -368,79 +378,48 @@ class K {
|
|
|
368
378
|
return this.pages;
|
|
369
379
|
}
|
|
370
380
|
}
|
|
371
|
-
class
|
|
381
|
+
class G {
|
|
372
382
|
constructor(t) {
|
|
373
|
-
this.
|
|
374
|
-
}
|
|
375
|
-
getAssetManager() {
|
|
376
|
-
return this.assetManager;
|
|
377
|
-
}
|
|
378
|
-
getCssComposer() {
|
|
379
|
-
return this.cssComposer;
|
|
380
|
-
}
|
|
381
|
-
getPages() {
|
|
382
|
-
return this.pages;
|
|
383
|
-
}
|
|
384
|
-
getSymbols() {
|
|
385
|
-
return this.symbols;
|
|
386
|
-
}
|
|
387
|
-
getDataSources() {
|
|
388
|
-
return this.dataSources;
|
|
383
|
+
this.Css = new q(t.styles || []), this.Pages = new K(t.pages || []), this.DataSources = new J(t.dataSources || []);
|
|
389
384
|
}
|
|
390
385
|
}
|
|
391
|
-
function
|
|
392
|
-
if (
|
|
393
|
-
for (const e of
|
|
394
|
-
const
|
|
395
|
-
if (
|
|
386
|
+
function O(n, t) {
|
|
387
|
+
if (n.id === t) return n;
|
|
388
|
+
for (const e of n.components) {
|
|
389
|
+
const r = O(e, t);
|
|
390
|
+
if (r) return r;
|
|
396
391
|
}
|
|
397
392
|
return null;
|
|
398
393
|
}
|
|
399
|
-
|
|
394
|
+
const Y = function(n) {
|
|
400
395
|
var d;
|
|
401
|
-
const {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
const
|
|
415
|
-
var i;
|
|
416
|
-
const a = new _(s), r = a.getCssComposer().getCssAsString(), n = a.getPages().getAll(), c = { ...O, ...t.errors };
|
|
417
|
-
if (!n.length)
|
|
418
|
-
return y(c.noPagesFound, { projectJson: s });
|
|
419
|
-
const p = e ? n.find((h) => h.getName() === e) : n[0];
|
|
420
|
-
if (!p)
|
|
421
|
-
return y(c.pageNotFound, { pageId: e });
|
|
422
|
-
const l = p.getFrames();
|
|
423
|
-
if (!l.length)
|
|
424
|
-
return y(c.noFramesFound, { page: p });
|
|
425
|
-
const d = (i = l[0]) == null ? void 0 : i.getComponent();
|
|
426
|
-
if (!d)
|
|
427
|
-
return y(c.missingRootComponent, { frame: l[0] });
|
|
428
|
-
if (o) {
|
|
429
|
-
const h = j(d, o);
|
|
396
|
+
const { projectData: t, config: e = {}, pageId: r, componentId: s } = n, o = new G(t), i = o.Css.getCssAsString(), c = o.Pages.getAll();
|
|
397
|
+
if (!c.length)
|
|
398
|
+
return /* @__PURE__ */ l(k, { ...n, errorType: m.NoPagesFound });
|
|
399
|
+
const a = r ? c.find((h) => h.id === r) : c[0];
|
|
400
|
+
if (!a)
|
|
401
|
+
return /* @__PURE__ */ l(k, { ...n, errorType: m.PageNotFound });
|
|
402
|
+
const { frames: u } = a;
|
|
403
|
+
if (!u.length)
|
|
404
|
+
return /* @__PURE__ */ l(k, { ...n, errorType: m.NoFramesFound });
|
|
405
|
+
const f = (d = u[0]) == null ? void 0 : d.component;
|
|
406
|
+
if (!f)
|
|
407
|
+
return /* @__PURE__ */ l(k, { ...n, errorType: m.MissingRootComponent });
|
|
408
|
+
if (s) {
|
|
409
|
+
const h = O(f, s);
|
|
430
410
|
if (!h)
|
|
431
|
-
return
|
|
411
|
+
return /* @__PURE__ */ l(k, { ...n, errorType: m.ComponentNotFound });
|
|
432
412
|
if (h) {
|
|
433
|
-
const
|
|
434
|
-
return /* @__PURE__ */
|
|
435
|
-
/* @__PURE__ */
|
|
436
|
-
/* @__PURE__ */
|
|
413
|
+
const g = e.rootComponent || v;
|
|
414
|
+
return /* @__PURE__ */ C(g, { children: [
|
|
415
|
+
/* @__PURE__ */ l("style", { children: `${i}` }),
|
|
416
|
+
/* @__PURE__ */ l(R, { component: h, config: e })
|
|
437
417
|
] });
|
|
438
418
|
}
|
|
439
419
|
return null;
|
|
440
420
|
}
|
|
441
|
-
return /* @__PURE__ */
|
|
421
|
+
return /* @__PURE__ */ l(U, { config: e, root: f, css: i });
|
|
442
422
|
};
|
|
443
423
|
export {
|
|
444
|
-
|
|
445
|
-
A as RenderProjectComponent
|
|
424
|
+
Y as RenderProject
|
|
446
425
|
};
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`);return d
|
|
3
|
-
${d}
|
|
4
|
-
}`:""},e=[],o={};this.rules.forEach(r=>{if(!r||!r.selectors||!r.style)return;const n=r.atRuleType&&r.mediaText?`@${r.atRuleType} ${r.mediaText}`:r.mediaText?`@media ${r.mediaText}`:null;n?(o[n]||(o[n]=[]),o[n].push(r)):e.push(r)});let a=e.map(r=>t(r)).join(`
|
|
5
|
-
`);return Object.keys(o).forEach(r=>{const n=o[r].map(l=>t(l)).join(`
|
|
6
|
-
`);n&&(a+=`
|
|
7
|
-
|
|
8
|
-
${r} {
|
|
9
|
-
${n}
|
|
10
|
-
}`)}),a}}class U{constructor(t){this.symbols=t}getAll(){return this.symbols}}class G{constructor(t){this.list=t}getAll(){return this.list}}class J{constructor(t){this.pages=t.map(e=>new z(e))}getAll(){return this.pages}}class V{constructor(t){this.assetManager=new L(t.assets||[]),this.cssComposer=new q(t.styles||[]),this.pages=new J(t.pages||[]),this.symbols=new U(t.symbols||[]),this.dataSources=new G(t.dataSources||[])}getAssetManager(){return this.assetManager}getCssComposer(){return this.cssComposer}getPages(){return this.pages}getSymbols(){return this.symbols}getDataSources(){return this.dataSources}}function F(s,t){if(s.getId()===t)return s;for(const e of s.getComponents()){const o=F(e,t);if(o)return o}return null}function H(s){var d;const{config:t,root:e,css:o}=s,a=t.wrapper||S.Fragment,r=e.getHead(),n=(d=e.getDocEl)==null?void 0:d.call(e),l=e.getAttributes().doctype||"<!DOCTYPE html>",p=(n==null?void 0:n.tagName)||"html",{skipDocType:u}=t;return c.jsxs(c.Fragment,{children:[u!==void 0&&!u&&l,c.jsxs(p,{children:[c.jsx(x,{component:r,config:t,children:c.jsx("style",{children:`${o}`})}),c.jsx(a,{children:c.jsx(x,{component:e,config:t})})]})]})}function y(s,t){const e=s?typeof s=="function"?s(t):s:"An error occurred";return c.jsx(c.Fragment,{children:c.jsx("html",{children:c.jsx("body",{children:e})})})}const K=({projectJson:s,config:t={},pageId:e,componentId:o})=>{var i;const a=new V(s),r=a.getCssComposer().getCssAsString(),n=a.getPages().getAll(),l={...$,...t.errors};if(!n.length)return y(l.noPagesFound,{projectJson:s});const p=e?n.find(h=>h.getName()===e):n[0];if(!p)return y(l.pageNotFound,{pageId:e});const u=p.getFrames();if(!u.length)return y(l.noFramesFound,{page:p});const d=(i=u[0])==null?void 0:i.getComponent();if(!d)return y(l.missingRootComponent,{frame:u[0]});if(o){const h=F(d,o);if(!h)return y(l.componentNotFound,{componentId:o});if(h){const f=t.wrapper||S.Fragment;return c.jsxs(c.Fragment,{children:[c.jsx("style",{children:`${r}`}),c.jsx(f,{children:c.jsx(x,{component:h,config:t})})]})}return null}return c.jsx(H,{config:t,root:d,css:r})};exports.GrapesJSProject=K;exports.RenderProjectComponent=x;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),k=require("react");var m=(r=>(r.NoPagesFound="noPagesFound",r.PageNotFound="pageNotFound",r.NoFramesFound="noFramesFound",r.MissingRootComponent="missingRootComponent",r.ComponentNotFound="componentNotFound",r))(m||{});function x(r){const{config:t,errorType:e}=r,s=t==null?void 0:t.errorComponent;return s?a.jsx(s,{...r}):a.jsxs("div",{children:["Error: ",e]})}function P(r){const t={};let e=!1;for(const s in r)if(Object.prototype.hasOwnProperty.call(r,s)){const n=r[s];if(typeof n=="string"||typeof n=="number"){const o=s.includes("-")?s.replace(/-([a-z])/g,i=>i[1].toUpperCase()):s;t[o]=n,e=!0}}return e?t:void 0}function O(r){const t={};return r.split(";").forEach(e=>{if(!e.trim())return;const s=e.indexOf(":");if(s>0){const n=e.substring(0,s).trim(),o=e.substring(s+1).trim();if(n&&o){const i=n.replace(/-([a-z])/g,l=>l[1].toUpperCase());t[i]=o}}}),Object.keys(t).length>0?t:void 0}function T(r){if(r){if(typeof r=="object"&&!Array.isArray(r))return P(r);if(typeof r=="string"){let t=O(r);if(!t)try{const e=JSON.parse(r);typeof e=="object"&&e!==null&&!Array.isArray(e)&&(t=P(e))}catch(e){console.error("Failed to parse style string as JSON",e)}return t}if(Array.isArray(r)){const t={};return r.forEach(e=>{if(typeof e=="object"&&e!==null){const s=e.name||e.property,n=e.value;if(typeof s=="string"&&s&&n!==void 0&&n!==""){const o=s.replace(/-([a-z])/g,i=>i[1].toUpperCase());t[o]=n}}}),Object.keys(t).length>0?t:void 0}}}function D(r){return $[r]?$[r]:r.includes("-")?r.replace(/-([a-z])/g,(t,e)=>e.toUpperCase()):r}function W(r){var e;const t={};for(const[s,n]of Object.entries(r))if(s==="style")t.style=T(n);else if(s.startsWith("data-"))t[s]=n;else{const o=D(s);((e=r.xmlns)==null?void 0:e.includes("svg"))||r.viewBox!==void 0||r.d!==void 0||M.has(o)||o.startsWith("svg")?t[o]=n:!B.has(o)&&!o.startsWith("on")&&!o.startsWith("aria-")&&!o.startsWith("data-")?t[s]=n:t[o]=n}return t}const B=new Set(["className","id","style","href","src","alt","title","target","rel","type","name","value","placeholder","onClick","onChange","onSubmit","onBlur","onFocus","disabled","readOnly","checked","selected","multiple","width","height","maxLength","min","max","step","rows","cols","autoComplete","autoFocus","required","spellCheck","tabIndex","aria-label","aria-labelledby","aria-describedby","role"]),M=new Set(["x","y","d","cx","cy","r","rx","ry","x1","x2","y1","y2","points","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeOpacity","fillOpacity","fillRule","clipRule","transform","viewBox","preserveAspectRatio","pathLength","vectorEffect","dominantBaseline","alignmentBaseline","textAnchor","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","baselineShift","opacity","mask","clipPath","overflow","pointerEvents"]),$={class:"className",for:"htmlFor","http-equiv":"httpEquiv","accept-charset":"acceptCharset","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","fill-rule":"fillRule","clip-rule":"clipRule","stroke-miterlimit":"strokeMiterlimit","stroke-dasharray":"strokeDasharray","stroke-opacity":"strokeOpacity","fill-opacity":"fillOpacity","font-family":"fontFamily","font-size":"fontSize","text-anchor":"textAnchor"};function I(r,t,e){const{id:s,type:n}=r,o=s||void 0;let i;return s?i=s:t?i=`${t}-${e??0}`:n==="head"?i="gjs-head":t==="gjs-head"?i=`${t}-${e??0}`:i=`gjs-${n}`,{key:i,nodeId:o}}const v=function r(t){var N;const{component:e,config:s,children:n,parentId:o,index:i}=t;if(!e)return null;const{type:l,content:c}=e;if(l==="textnode")return c;const u=(N=s==null?void 0:s.components)==null?void 0:N[l],d=(u==null?void 0:u.component)||e.tagName||"div",h=e.attributes,{key:g,nodeId:j}=I(e,o,i),C=!!(u!=null&&u.component),A=W(h);C&&Object.keys(A).forEach(y=>{const p=A[y];typeof p=="string"&&!isNaN(Number(p))&&p.trim()!==""&&(A[y]=Number(p))});const{components:R}=e,b=[...R.length?R.map((y,p)=>a.jsx(r,{config:s,component:y,parentId:g,index:p},`${y.id}-${p}`)):[c],n],F={...A,...j?{id:j}:{}};return C?a.jsx(d,{...F,children:b},g):k.createElement(d,{...F,key:g},e.isVoid?null:b)};function z(r){var c;const{config:t,root:e,css:s}=r,n=(t==null?void 0:t.rootComponent)||k.Fragment,o=((c=e.docEl)==null?void 0:c.tagName)||"html",i=(t==null?void 0:t.headAfter)||k.Fragment,l=(t==null?void 0:t.bodyAfter)||k.Fragment;return a.jsx(o,{children:a.jsxs(n,{children:[a.jsxs(v,{component:e.head,config:t,children:[a.jsx("style",{children:`${s}`}),a.jsx(i,{})]}),a.jsx(v,{component:e,config:t,children:a.jsx(l,{})})]})})}class S{constructor(t){this.data=t}get id(){var t;return(t=this.data.attributes)==null?void 0:t.id}get type(){return this.data.type||"default"}get tagName(){const{type:t}=this;return t==="svg"?"svg":t==="image"?"img":t==="linkBox"||t==="link"?"a":t==="head"?"head":t==="wrapper"?"body":this.data.tagName||""}get isVoid(){return this.tagName==="img"?!0:!!this.data.void}get attributes(){const t={...this.data.attributes},{classes:e}=this;e.length&&(t.class=e.join(" "));function s(n,o){return Object.prototype.hasOwnProperty.call(n,o)}return s(t,"id")||(t.id=this.id),t}get content(){return this.data.content||""}get components(){return(this.data.components||[]).map(t=>new S(t))}get head(){return new S(this.data.head||{tagName:"head"})}get docEl(){return this.data.docEl}get classes(){return(this.data.classes||[]).map(e=>typeof e=="string"?e:e.name)}}class L{constructor(t){this.data=t}get component(){return this.data.component?new S(this.data.component):null}}class U{constructor(t){this.data=t}get id(){return this.data.id}get frames(){return(this.data.frames||[]).map(t=>new L(t))}}function w(r){const t=/(-?\d*\.?\d+)\w{0,}/.exec(r);return t?parseFloat(t[1]):Number.MAX_VALUE}class _{constructor(t){this.rules=t}getAll(){return this.rules}getRulesByGroup(t){return this.rules.filter(e=>e.group===t)}getAtRule(t){const{atRuleType:e,mediaText:s}=t,n=e?`@${e}`:s?"@media":"";return n+(s&&n?` ${s}`:"")}selectorsToString(t,e={}){const s=[],{state:n,selectorsAdd:o,selectors:i=[]}=t,l=i.map(u=>this.getFromSelectorName(u)).join(""),c=n&&!e.skipState?`:${n}`:"";return l&&s.push(`${l}${c}`),o&&!e.skipAdd&&s.push(o),s.join(", ")}getFromSelectorName(t=""){return`${t.startsWith("#")?"":"."}${t}`}styleToString(t={}){const e=[],{style:s={},important:n}=t;for(const o in s){const i=Array.isArray(n)?n.indexOf(o)>=0:n;if(o.substring(0,2)==="__")continue;const c=s[o];(Array.isArray(c)?c:[c]).forEach(f=>{const d=`${f}${i?" !important":""}`;d&&e.push(`${o}:${d};`)})}return e.join("")}getDeclaration(t){const{singleAtRule:e}=t,s=this.selectorsToString(t),n=this.styleToString(t);let o="";return(s||e)&&n&&(o=e?n:`${s}{${n}}`),o}buildFromRule(t){let e="";const s=this.selectorsToString(t),{selectorsAdd:n,singleAtRule:o}=t;if(s||n||o){const i=this.getDeclaration(t);i&&(e+=i)}return e}sortMediaObject(t={}){const e=[];for(const s in t){const n=t[s];e.push({key:s,value:n})}return e.sort((s,n)=>{const o=[s.key,n.key].every(c=>c.indexOf("min-width")!==-1),i=o?s.key:n.key,l=o?n.key:s.key;return w(i)-w(l)})}getCssAsString(){if(!this.rules||!this.rules.length)return"";const{rules:t}=this,e={},s=[];return t.forEach(n=>{const o=this.getAtRule(n);if(o){const i=e[o];i?i.push(n):e[o]=[n];return}s.push(this.buildFromRule(n))}),this.sortMediaObject(e).forEach(n=>{let o="";const i=n.key;n.value.forEach(c=>{const u=this.buildFromRule(c);c.singleAtRule?s.push(`${i}{${u}}`):o+=u}),o&&s.push(`${i}{${o}}`)}),s.join(`
|
|
2
|
+
`)}}class q{constructor(t){this.list=t}getAll(){return this.list}}class V{constructor(t){this.pages=t.map(e=>new U(e))}getAll(){return this.pages}}class J{constructor(t){this.Css=new _(t.styles||[]),this.Pages=new V(t.pages||[]),this.DataSources=new q(t.dataSources||[])}}function E(r,t){if(r.id===t)return r;for(const e of r.components){const s=E(e,t);if(s)return s}return null}const K=function(r){var d;const{projectData:t,config:e={},pageId:s,componentId:n}=r,o=new J(t),i=o.Css.getCssAsString(),l=o.Pages.getAll();if(!l.length)return a.jsx(x,{...r,errorType:m.NoPagesFound});const c=s?l.find(h=>h.id===s):l[0];if(!c)return a.jsx(x,{...r,errorType:m.PageNotFound});const{frames:u}=c;if(!u.length)return a.jsx(x,{...r,errorType:m.NoFramesFound});const f=(d=u[0])==null?void 0:d.component;if(!f)return a.jsx(x,{...r,errorType:m.MissingRootComponent});if(n){const h=E(f,n);if(!h)return a.jsx(x,{...r,errorType:m.ComponentNotFound});if(h){const g=e.rootComponent||k.Fragment;return a.jsxs(g,{children:[a.jsx("style",{children:`${i}`}),a.jsx(v,{component:h,config:e})]})}return null}return a.jsx(z,{config:e,root:f,css:i})};exports.RenderProject=K;
|