@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.37

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.
Files changed (92) hide show
  1. package/dist/accordionComponent/index.cjs.js +7 -7
  2. package/dist/accordionComponent/index.es.js +185 -159
  3. package/dist/accordionComponent/index.umd.js +7 -7
  4. package/dist/aiChat/clientToolsProcessors.d.ts +1 -2
  5. package/dist/aiChat/components/utils.d.ts +1 -0
  6. package/dist/aiChat/components/utilsTw.d.ts +11 -0
  7. package/dist/aiChat/index.cjs.js +75 -75
  8. package/dist/aiChat/index.es.js +9122 -8628
  9. package/dist/aiChat/index.js +75 -75
  10. package/dist/aiChat/index.umd.js +75 -75
  11. package/dist/aiChat/projectGeneration.d.ts +17 -0
  12. package/dist/animationComponent/index.cjs.js +3 -3
  13. package/dist/animationComponent/index.es.js +221 -195
  14. package/dist/animationComponent/index.umd.js +3 -3
  15. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  16. package/dist/canvasAbsoluteMode/index.es.js +199 -173
  17. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  18. package/dist/canvasEmptyState/index.cjs.js +1 -1
  19. package/dist/canvasEmptyState/index.es.js +149 -123
  20. package/dist/canvasEmptyState/index.umd.js +1 -1
  21. package/dist/canvasFullSize/index.cjs.js +9 -9
  22. package/dist/canvasFullSize/index.es.js +186 -160
  23. package/dist/canvasFullSize/index.umd.js +9 -9
  24. package/dist/canvasGridMode/index.cjs.js +5 -5
  25. package/dist/canvasGridMode/index.es.js +263 -237
  26. package/dist/canvasGridMode/index.umd.js +2 -2
  27. package/dist/canvasScreenshot/index.cjs.js +1 -1
  28. package/dist/canvasScreenshot/index.es.js +168 -142
  29. package/dist/canvasScreenshot/index.umd.js +1 -1
  30. package/dist/dataSourceEjs/index.cjs.js +9 -9
  31. package/dist/dataSourceEjs/index.es.js +271 -245
  32. package/dist/dataSourceEjs/index.umd.js +9 -9
  33. package/dist/dataSourceHandlebars/index.cjs.js +8 -8
  34. package/dist/dataSourceHandlebars/index.es.js +232 -206
  35. package/dist/dataSourceHandlebars/index.umd.js +8 -8
  36. package/dist/dialogComponent/index.cjs.js +14 -14
  37. package/dist/dialogComponent/index.es.js +157 -131
  38. package/dist/dialogComponent/index.umd.js +14 -14
  39. package/dist/flexComponent/index.cjs.js +13 -13
  40. package/dist/flexComponent/index.es.js +497 -471
  41. package/dist/flexComponent/index.umd.js +13 -13
  42. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  43. package/dist/fsLightboxComponent/index.es.js +189 -163
  44. package/dist/fsLightboxComponent/index.umd.js +3 -3
  45. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  46. package/dist/googleFontsAssetProvider/index.es.js +175 -149
  47. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  48. package/dist/iconifyComponent/index.cjs.js +2 -2
  49. package/dist/iconifyComponent/index.es.js +207 -181
  50. package/dist/iconifyComponent/index.umd.js +2 -2
  51. package/dist/index.cjs.js +36 -36
  52. package/dist/index.es.js +917 -891
  53. package/dist/index.umd.js +36 -36
  54. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  55. package/dist/layoutSidebarButtons/index.es.js +192 -166
  56. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  57. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  58. package/dist/lightGalleryComponent/index.es.js +265 -239
  59. package/dist/lightGalleryComponent/index.umd.js +1 -1
  60. package/dist/linkImageComponent/index.cjs.js +2 -2
  61. package/dist/linkImageComponent/index.es.js +121 -95
  62. package/dist/linkImageComponent/index.umd.js +2 -2
  63. package/dist/listPagesComponent/index.cjs.js +5 -5
  64. package/dist/listPagesComponent/index.es.js +171 -145
  65. package/dist/listPagesComponent/index.umd.js +5 -5
  66. package/dist/presetPrintable/index.cjs.js +3 -3
  67. package/dist/presetPrintable/index.es.js +227 -201
  68. package/dist/presetPrintable/index.umd.js +3 -3
  69. package/dist/prosemirror/index.cjs.js +7 -7
  70. package/dist/prosemirror/index.es.js +457 -431
  71. package/dist/prosemirror/index.umd.js +8 -8
  72. package/dist/rendererReact/index.cjs.js +1 -1
  73. package/dist/rendererReact/index.es.js +248 -223
  74. package/dist/rendererReact/index.js +1 -1
  75. package/dist/rendererReact/index.umd.js +1 -1
  76. package/dist/rteTinyMce/index.cjs.js +2 -2
  77. package/dist/rteTinyMce/index.es.js +150 -124
  78. package/dist/rteTinyMce/index.umd.js +2 -2
  79. package/dist/shapeDividerComponent/index.cjs.js +4 -4
  80. package/dist/shapeDividerComponent/index.es.js +143 -117
  81. package/dist/shapeDividerComponent/index.umd.js +4 -4
  82. package/dist/swiperComponent/index.cjs.js +9 -9
  83. package/dist/swiperComponent/index.es.js +218 -192
  84. package/dist/swiperComponent/index.umd.js +7 -7
  85. package/dist/tableComponent/index.cjs.js +1 -1
  86. package/dist/tableComponent/index.es.js +275 -249
  87. package/dist/tableComponent/index.umd.js +1 -1
  88. package/dist/types.d.ts +1 -1
  89. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  90. package/dist/youtubeAssetProvider/index.es.js +134 -108
  91. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  92. package/package.json +2 -2
@@ -1,206 +1,232 @@
1
1
  import { jsx as y } from "react/jsx-runtime";
2
- import { useState as R, useEffect as I, createElement as B, Fragment as T } from "react";
3
- import { createRoot as L } from "react-dom/client";
4
- const U = "app.grapesjs.com", W = "app-stage.grapesjs.com", K = "app2.grapesjs.com", F = "app-stage2.grapesjs.com", P = [
5
- U,
2
+ import { useState as O, useEffect as U, createElement as F, Fragment as D } from "react";
3
+ import { createRoot as W } from "react-dom/client";
4
+ const C = "app.grapesjs.com", _ = "app-stage.grapesjs.com", $ = "app2.grapesjs.com", K = "app-stage2.grapesjs.com", N = [
5
+ C,
6
+ $,
7
+ _,
6
8
  K,
7
- W,
8
- F,
9
9
  "localhost",
10
10
  "127.0.0.1",
11
11
  ".local-credentialless.webcontainer.io",
12
12
  // For stackblitz.com demos
13
13
  ".local.webcontainer.io",
14
14
  // For stackblitz.com demos
15
- "-sandpack.codesandbox.io"
15
+ "-sandpack.codesandbox.io",
16
16
  // For Sandpack demos
17
- ], M = "license:check:start", V = "license:check:end", z = () => typeof window < "u", G = ({
17
+ ".claudemcpcontent.com",
18
+ // For Claude mcp app
19
+ ".web-sandbox.oaiusercontent.com"
20
+ // For OpenAI mcp app
21
+ ], S = "license:check:end", V = () => typeof window < "u", z = ({
18
22
  isDev: e,
19
23
  isStage: t,
20
- isPlatform: n
21
- }) => `${e ? "" : `https://${t ? W : U}`}/${n ? "platform-api" : "api"}`, J = () => {
22
- const e = z() && window.location.hostname;
23
- return !!e && (P.includes(e) || P.some((t) => e.endsWith(t)));
24
- }, q = (e) => e.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (t, n) => (n ? "-" : "") + t.toLowerCase()), x = (e) => typeof e == "string";
25
- function H(e) {
24
+ isPlatform: o
25
+ }) => `${e ? "" : `https://${t ? _ : C}`}/${o ? "platform-api" : "api"}`, J = () => {
26
+ if (!V()) return "";
27
+ const { hostname: e } = window.location;
28
+ if (e) return e;
29
+ try {
30
+ return window.parent.location.hostname || "";
31
+ } catch {
32
+ return "";
33
+ }
34
+ }, q = () => {
35
+ const e = J();
36
+ return !!e && (N.includes(e) || N.some((t) => e.endsWith(t)));
37
+ }, H = (e) => e.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (t, o) => (o ? "-" : "") + t.toLowerCase()), L = (e) => typeof e == "string";
38
+ function Z(e) {
26
39
  return typeof e == "function";
27
40
  }
28
- async function Z({
41
+ async function Q({
29
42
  path: e,
30
43
  baseApiUrl: t,
31
- method: n = "GET",
44
+ method: o = "GET",
32
45
  headers: s = {},
33
- params: r,
34
- body: o
46
+ params: a,
47
+ body: n
35
48
  }) {
36
- const a = `${t || G({ isDev: !1, isStage: !1 })}${e}`, i = {
37
- method: n,
49
+ const r = `${t || z({ isDev: !1, isStage: !1 })}${e}`, c = {
50
+ method: o,
38
51
  headers: {
39
52
  "Content-Type": "application/json",
40
53
  ...s
41
54
  }
42
55
  };
43
- o && (i.body = JSON.stringify(o));
44
- const f = r ? new URLSearchParams(r).toString() : "", d = f ? `?${f}` : "", p = await fetch(`${a}${d}`, i);
56
+ n && (c.body = JSON.stringify(n));
57
+ const u = a ? new URLSearchParams(a).toString() : "", d = u ? `?${u}` : "", p = await fetch(`${r}${d}`, c);
45
58
  if (!p.ok)
46
59
  throw new Error(`HTTP error! status: ${p.status}`);
47
60
  return p.json();
48
61
  }
49
- var g = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(g || {});
50
- const O = {
51
- [g.free]: 0,
52
- [g.startup]: 10,
53
- [g.business]: 20,
54
- [g.enterprise]: 30
62
+ var v = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(v || {}), k = /* @__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))(k || {});
63
+ const B = {
64
+ [v.free]: 0,
65
+ [v.startup]: 10,
66
+ [v.business]: 20,
67
+ [v.enterprise]: 30
55
68
  };
56
- function Q(e) {
69
+ function X(e) {
57
70
  const t = e;
58
- return t.init = (n) => (s) => e(s, n), t;
71
+ return t.init = (o) => (s) => e(s, o), t;
59
72
  }
60
- const X = (e) => /* @__PURE__ */ Q(e);
61
- async function Y({
73
+ const Y = (e) => /* @__PURE__ */ X(e);
74
+ async function ee({
62
75
  editor: e,
63
76
  plan: t,
64
- pluginName: n,
77
+ pluginName: o,
65
78
  licenseKey: s,
66
- onLicenseCheckResponse: r,
67
- cleanup: o
79
+ onLicenseCheckResponse: a,
80
+ cleanup: n
68
81
  }) {
69
- let c = "", a = !1;
70
- const i = J(), f = (p) => {
71
- console.warn("Cleanup plugin:", n, "Reason:", p), o();
72
- }, d = (p = {}) => {
73
- var C;
74
- const { error: m, sdkLicense: u } = p, l = (C = p.plan) == null ? void 0 : C.category;
75
- if (!(u || p.license) || m)
76
- f(m || "Invalid license");
82
+ let i = "", r;
83
+ const c = (p) => {
84
+ console.warn("Cleanup plugin:", o, "Reason:", p), n();
85
+ }, u = (p = {}) => {
86
+ var w;
87
+ const { error: g, sdkLicense: f } = p, l = (w = p.plan) == null ? void 0 : w.category;
88
+ if (!(f || p.license) || g)
89
+ c(g || "Invalid license");
77
90
  else if (l) {
78
- const w = O[t], b = O[l];
79
- w > b && f({ pluginRequiredPlan: t, licensePlan: l });
91
+ const m = B[t], R = B[l];
92
+ m > R && c({ pluginRequiredPlan: t, licensePlan: l });
80
93
  }
81
94
  };
82
- e.on(M, (p) => {
83
- c = p == null ? void 0 : p.baseApiUrl, a = !0;
84
- }), e.on(V, (p) => {
85
- r == null || r(p), d(p);
86
- }), setTimeout(async () => {
87
- if (!a) {
88
- if (i) return;
89
- if (s) {
90
- const p = await ee({ licenseKey: s, pluginName: n, baseApiUrl: c });
91
- r == null || r(p), p && d(p);
92
- } else
93
- f("The `licenseKey` option not provided");
94
- }
95
- }, 2e3);
95
+ e.Commands.has(k.settings) && (r = e.runCommand(k.settings), i = (r == null ? void 0 : r.baseUrl) || "");
96
+ const d = (p) => {
97
+ a == null || a(p), p && u(p);
98
+ };
99
+ if (!r) {
100
+ e.onReady(async () => {
101
+ if (!q())
102
+ if (s) {
103
+ const p = await oe({ licenseKey: s, pluginName: o, baseApiUrl: i });
104
+ d(p);
105
+ } else
106
+ c("The `licenseKey` option not provided");
107
+ });
108
+ return;
109
+ }
110
+ if (r.licensePlan || r.licenseError) {
111
+ const p = te(r);
112
+ d(p);
113
+ return;
114
+ }
115
+ e.on(S, (p) => d(p));
96
116
  }
97
- async function ee(e) {
98
- const { licenseKey: t, pluginName: n, baseApiUrl: s } = e;
117
+ const te = (e) => ({
118
+ sdkLicense: e.license,
119
+ license: e.license,
120
+ error: e.licenseError,
121
+ plan: e.licensePlan
122
+ });
123
+ async function oe(e) {
124
+ const { licenseKey: t, pluginName: o, baseApiUrl: s } = e;
99
125
  try {
100
- return (await Z({
126
+ return (await Q({
101
127
  baseApiUrl: s,
102
128
  path: `/sdk/${t || "na"}`,
103
129
  method: "POST",
104
130
  params: {
105
131
  d: window.location.hostname,
106
- pn: n
132
+ pn: o
107
133
  }
108
134
  })).result || {};
109
- } catch (r) {
110
- return console.error("Error during SDK license check:", r), !1;
135
+ } catch (a) {
136
+ return console.error("Error during SDK license check:", a), !1;
111
137
  }
112
138
  }
113
- function te(e) {
139
+ function ne(e) {
114
140
  const t = {};
115
- for (const n in e)
116
- if (Object.prototype.hasOwnProperty.call(e, n)) {
117
- const s = q(n);
118
- t[s] = e[n];
141
+ for (const o in e)
142
+ if (Object.prototype.hasOwnProperty.call(e, o)) {
143
+ const s = H(o);
144
+ t[s] = e[o];
119
145
  }
120
146
  return t;
121
147
  }
122
- const ne = (e, t) => {
123
- const n = e.components || {};
124
- for (const s in n) {
125
- const r = n[s];
126
- if (r.component === t)
127
- return { cmpConfig: r, type: s };
148
+ const se = (e, t) => {
149
+ const o = e.components || {};
150
+ for (const s in o) {
151
+ const a = o[s];
152
+ if (a.component === t)
153
+ return { cmpConfig: a, type: s };
128
154
  }
129
155
  };
130
- function D(e) {
156
+ function G(e) {
131
157
  const t = {};
132
- let n = !1;
158
+ let o = !1;
133
159
  for (const s in e)
134
160
  if (Object.prototype.hasOwnProperty.call(e, s)) {
135
- const r = e[s];
136
- if (typeof r == "string" || typeof r == "number") {
137
- const o = s.includes("-") ? s.replace(/-([a-z])/g, (c) => c[1].toUpperCase()) : s;
138
- t[o] = r, n = !0;
161
+ const a = e[s];
162
+ if (typeof a == "string" || typeof a == "number") {
163
+ const n = s.includes("-") ? s.replace(/-([a-z])/g, (i) => i[1].toUpperCase()) : s;
164
+ t[n] = a, o = !0;
139
165
  }
140
166
  }
141
- return n ? t : void 0;
167
+ return o ? t : void 0;
142
168
  }
143
- function oe(e) {
169
+ function re(e) {
144
170
  const t = {};
145
- return e.split(";").forEach((n) => {
146
- if (!n.trim()) return;
147
- const s = n.indexOf(":");
171
+ return e.split(";").forEach((o) => {
172
+ if (!o.trim()) return;
173
+ const s = o.indexOf(":");
148
174
  if (s > 0) {
149
- const r = n.substring(0, s).trim(), o = n.substring(s + 1).trim();
150
- if (r && o) {
151
- const c = r.replace(/-([a-z])/g, (a) => a[1].toUpperCase());
152
- t[c] = o;
175
+ const a = o.substring(0, s).trim(), n = o.substring(s + 1).trim();
176
+ if (a && n) {
177
+ const i = a.replace(/-([a-z])/g, (r) => r[1].toUpperCase());
178
+ t[i] = n;
153
179
  }
154
180
  }
155
181
  }), Object.keys(t).length > 0 ? t : void 0;
156
182
  }
157
- function se(e) {
183
+ function ae(e) {
158
184
  if (e) {
159
185
  if (typeof e == "object" && !Array.isArray(e))
160
- return D(e);
186
+ return G(e);
161
187
  if (typeof e == "string") {
162
- let t = oe(e);
188
+ let t = re(e);
163
189
  if (!t)
164
190
  try {
165
- const n = JSON.parse(e);
166
- typeof n == "object" && n !== null && !Array.isArray(n) && (t = D(n));
167
- } catch (n) {
168
- console.error("Failed to parse style string as JSON", n);
191
+ const o = JSON.parse(e);
192
+ typeof o == "object" && o !== null && !Array.isArray(o) && (t = G(o));
193
+ } catch (o) {
194
+ console.error("Failed to parse style string as JSON", o);
169
195
  }
170
196
  return t;
171
197
  }
172
198
  if (Array.isArray(e)) {
173
199
  const t = {};
174
- return e.forEach((n) => {
175
- if (typeof n == "object" && n !== null) {
176
- const s = n.name || n.property, r = n.value;
177
- if (typeof s == "string" && s && r !== void 0 && r !== "") {
178
- const o = s.replace(/-([a-z])/g, (c) => c[1].toUpperCase());
179
- t[o] = r;
200
+ return e.forEach((o) => {
201
+ if (typeof o == "object" && o !== null) {
202
+ const s = o.name || o.property, a = o.value;
203
+ if (typeof s == "string" && s && a !== void 0 && a !== "") {
204
+ const n = s.replace(/-([a-z])/g, (i) => i[1].toUpperCase());
205
+ t[n] = a;
180
206
  }
181
207
  }
182
208
  }), Object.keys(t).length > 0 ? t : void 0;
183
209
  }
184
210
  }
185
211
  }
186
- function re(e) {
187
- return _[e] ? _[e] : e.includes("-") ? e.replace(/-([a-z])/g, (t, n) => n.toUpperCase()) : e;
212
+ function ie(e) {
213
+ return I[e] ? I[e] : e.includes("-") ? e.replace(/-([a-z])/g, (t, o) => o.toUpperCase()) : e;
188
214
  }
189
- function ae(e) {
190
- var n;
215
+ function ce(e) {
216
+ var o;
191
217
  const t = {};
192
- for (const [s, r] of Object.entries(e))
218
+ for (const [s, a] of Object.entries(e))
193
219
  if (s === "style")
194
- t.style = se(r);
220
+ t.style = ae(a);
195
221
  else if (s.startsWith("data-"))
196
- t[s] = r;
222
+ t[s] = a;
197
223
  else {
198
- const o = re(s);
199
- ((n = e.xmlns) == null ? void 0 : n.includes("svg")) || e.viewBox !== void 0 || e.d !== void 0 || ie.has(o) || o.startsWith("svg") ? t[o] = r : !ce.has(o) && !o.startsWith("on") && !o.startsWith("aria-") && !o.startsWith("data-") ? t[s] = r : t[o] = r;
224
+ const n = ie(s);
225
+ ((o = e.xmlns) == null ? void 0 : o.includes("svg")) || e.viewBox !== void 0 || e.d !== void 0 || pe.has(n) || n.startsWith("svg") ? t[n] = a : !le.has(n) && !n.startsWith("on") && !n.startsWith("aria-") && !n.startsWith("data-") ? t[s] = a : t[n] = a;
200
226
  }
201
227
  return t;
202
228
  }
203
- const ce = /* @__PURE__ */ new Set([
229
+ const le = /* @__PURE__ */ new Set([
204
230
  "className",
205
231
  "id",
206
232
  "style",
@@ -241,7 +267,7 @@ const ce = /* @__PURE__ */ new Set([
241
267
  "aria-labelledby",
242
268
  "aria-describedby",
243
269
  "role"
244
- ]), ie = /* @__PURE__ */ new Set([
270
+ ]), pe = /* @__PURE__ */ new Set([
245
271
  "x",
246
272
  "y",
247
273
  "d",
@@ -284,7 +310,7 @@ const ce = /* @__PURE__ */ new Set([
284
310
  "clipPath",
285
311
  "overflow",
286
312
  "pointerEvents"
287
- ]), _ = {
313
+ ]), I = {
288
314
  class: "className",
289
315
  for: "htmlFor",
290
316
  "http-equiv": "httpEquiv",
@@ -301,60 +327,60 @@ const ce = /* @__PURE__ */ new Set([
301
327
  "font-family": "fontFamily",
302
328
  "font-size": "fontSize",
303
329
  "text-anchor": "textAnchor"
304
- }, E = (e) => (e == null ? void 0 : e.$$typeof) && typeof e.props == "object";
305
- function le(e) {
330
+ }, T = (e) => (e == null ? void 0 : e.$$typeof) && typeof e.props == "object";
331
+ function ue(e) {
306
332
  return (t) => {
307
- const n = t.getContent();
308
- E(n) && t.set({
309
- content: A({ ...e, model: n }),
310
- reactContent: n
333
+ const o = t.getContent();
334
+ T(o) && t.set({
335
+ content: A({ ...e, model: o }),
336
+ reactContent: o
311
337
  });
312
338
  };
313
339
  }
314
- const pe = (e) => (t) => {
315
- const n = t.component;
316
- E(n) && (t.component = { components: A({ ...e, model: n }) });
340
+ const fe = (e) => (t) => {
341
+ const o = t.component;
342
+ T(o) && (t.component = { components: A({ ...e, model: o }) });
317
343
  };
318
344
  function A(e) {
319
- const { model: t, editor: n, config: s } = e;
320
- if (E(t)) {
321
- const r = t, o = {}, { type: c, props: a = {} } = r, { children: i, className: f, style: d, ...p } = a, m = (l) => ({ type: "textnode", content: l }), u = typeof c == "symbol";
322
- if (H(c)) {
323
- const l = ne(s, c);
324
- o.type = l == null ? void 0 : l.type;
325
- } else n.Components.getType(c) ? o.type = c : u || (o.tagName = c);
326
- if (f && (o.classes = f), d && (o.style = te(d)), Array.isArray(i) ? o.components = i.map((l) => x(l) ? m(l) : A({ ...e, model: l })).filter(Boolean) : x(i) && (o.components = m(i)), Object.keys(p).length) {
327
- const l = n.Parser.parserHtml.splitPropsFromAttr(p);
328
- o.attributes = l.attrs, Object.assign(o, l.props);
345
+ const { model: t, editor: o, config: s } = e;
346
+ if (T(t)) {
347
+ const a = t, n = {}, { type: i, props: r = {} } = a, { children: c, className: u, style: d, ...p } = r, g = (l) => ({ type: "textnode", content: l }), f = typeof i == "symbol";
348
+ if (Z(i)) {
349
+ const l = se(s, i);
350
+ n.type = l == null ? void 0 : l.type;
351
+ } else o.Components.getType(i) ? n.type = i : f || (n.tagName = i);
352
+ if (u && (n.classes = u), d && (n.style = ne(d)), Array.isArray(c) ? n.components = c.map((l) => L(l) ? g(l) : A({ ...e, model: l })).filter(Boolean) : L(c) && (n.components = g(c)), Object.keys(p).length) {
353
+ const l = o.Parser.parserHtml.splitPropsFromAttr(p);
354
+ n.attributes = l.attrs, Object.assign(n, l.props);
329
355
  }
330
- return o;
356
+ return n;
331
357
  }
332
358
  }
333
- function fe(e) {
334
- const { component: t } = e, [n, s] = R(0), [r, o] = R();
335
- return I(() => {
359
+ function de(e) {
360
+ const { component: t } = e, [o, s] = O(0), [a, n] = O();
361
+ return U(() => {
336
362
  if (!t) return () => {
337
363
  };
338
- const a = () => s((l) => l + 1), i = () => {
339
- [...t.views].forEach((v) => v.remove()), o(void 0);
340
- }, { em: f } = t, d = f.Components.events, m = [...["components", "attributes", "classes"].map((l) => `${d.update}:${l}`), "rerender"].join(" "), u = [d.removed, "rerender"].join(" ");
341
- return t.on(m, a), t.on(u, i), () => {
342
- t.off(m, a), t.off(u, i), i();
364
+ const r = () => s((l) => l + 1), c = () => {
365
+ [...t.views].forEach((b) => b.remove()), n(void 0);
366
+ }, { em: u } = t, d = u.Components.events, g = [...["components", "attributes", "classes"].map((l) => `${d.update}:${l}`), "rerender"].join(" "), f = [d.removed, "rerender"].join(" ");
367
+ return t.on(g, r), t.on(f, c), () => {
368
+ t.off(g, r), t.off(f, c), c();
343
369
  };
344
- }, [t]), { key: n, view: r, connectDom: (a) => {
345
- if (!a) return;
346
- const i = ue({ ...e, el: a });
347
- o(i);
370
+ }, [t]), { key: o, view: a, connectDom: (r) => {
371
+ if (!r) return;
372
+ const c = ge({ ...e, el: r });
373
+ n(c);
348
374
  } };
349
375
  }
350
- function ue(e) {
351
- var i;
352
- const { editor: t, component: n, el: s, frameView: r } = e, { em: o, Components: c } = t;
353
- let a = n.getView(r.model);
354
- if ((a == null ? void 0 : a.el) === s)
355
- return a;
356
- if (!a) {
357
- const { ComponentView: f } = c, d = n.attributes.type || "default", p = ((i = c.getType(d)) == null ? void 0 : i.view) || f, m = { ...c.config, frameView: r, em: o }, u = p.extend({
376
+ function ge(e) {
377
+ var c;
378
+ const { editor: t, component: o, el: s, frameView: a } = e, { em: n, Components: i } = t;
379
+ let r = o.getView(a.model);
380
+ if ((r == null ? void 0 : r.el) === s)
381
+ return r;
382
+ if (!r) {
383
+ const { ComponentView: u } = i, d = o.attributes.type || "default", p = ((c = i.getType(d)) == null ? void 0 : c.view) || u, g = { ...i.config, frameView: a, em: n }, f = p.extend({
358
384
  initComponents() {
359
385
  },
360
386
  _createElement() {
@@ -369,110 +395,109 @@ function ue(e) {
369
395
  return this._ensureElement(), this._setData(), this.renderAttributes(), (l = this.updateSrc) == null || l.call(this), this;
370
396
  }
371
397
  });
372
- a = new u({ el: s, config: m, model: n });
398
+ r = new f({ el: s, config: g, model: o });
373
399
  }
374
- return a.el = s, a.render(), a;
400
+ return r.el = s, r.render(), r;
375
401
  }
376
- function de(e, t) {
377
- const { Components: n } = e, s = (r) => {
378
- const { id: o, model: c } = r;
379
- n.addType(o, {
402
+ function ye(e, t) {
403
+ const { Components: o } = e, s = ({ id: a, model: n }) => {
404
+ n && o.addType(a, {
380
405
  model: {
381
- toJSON(...a) {
382
- const i = c.prototype.toJSON.apply(this, a);
383
- return i.tagName = this.tagName, i;
406
+ toJSON(...i) {
407
+ const r = n.prototype.toJSON.apply(this, i);
408
+ return r.tagName = this.tagName, r;
384
409
  }
385
410
  }
386
411
  });
387
412
  };
388
- n.getTypes().forEach(s), e.on("component:type:add", s), Object.entries(t.components || {}).forEach(([r, o]) => {
389
- var m, u;
390
- const { allowPropClassName: c, allowPropId: a, allowChildren: i } = o, f = !a && !c, d = () => ({
391
- disabled: f
413
+ o.getTypes().forEach(s), e.on("component:type:add", s), Object.entries(t.components || {}).forEach(([a, n]) => {
414
+ var g, f;
415
+ const { allowPropClassName: i, allowPropId: r, allowChildren: c } = n, u = !r && !i, d = () => ({
416
+ disabled: u
392
417
  }), p = () => ({
393
- disableClasses: !c,
394
- disableComponent: !a
418
+ disableClasses: !i,
419
+ disableComponent: !r
395
420
  });
396
- n.addType(r, {
397
- isComponent: (l) => (l == null ? void 0 : l.tagName) === r,
421
+ o.addType(a, {
422
+ isComponent: (l) => (l == null ? void 0 : l.tagName) === a,
398
423
  model: {
399
424
  defaults: {
400
- type: r,
401
- traits: ((m = o.props) == null ? void 0 : m.call(o)) || [],
402
- droppable: !!i,
403
- stylable: !f,
425
+ type: a,
426
+ traits: ((g = n.props) == null ? void 0 : g.call(n)) || [],
427
+ droppable: !!c,
428
+ stylable: !u,
404
429
  styleManager: d,
405
430
  selectorManager: p,
406
- ...((u = o.model) == null ? void 0 : u.defaults) || {}
431
+ ...((f = n.model) == null ? void 0 : f.defaults) || {}
407
432
  }
408
433
  }
409
434
  });
410
435
  });
411
436
  }
412
- function j(e) {
413
- var N;
414
- const { component: t, config: n, editor: s, frameView: r, onMount: o, tagName: c, children: a } = e, { key: i, view: f, connectDom: d } = fe(e);
415
- I(() => {
416
- if (!f && !o) return;
437
+ function M(e) {
438
+ var x;
439
+ const { component: t, config: o, editor: s, frameView: a, onMount: n, tagName: i, children: r } = e, { key: c, view: u, connectDom: d } = de(e);
440
+ U(() => {
441
+ if (!u && !n) return;
417
442
  const h = setTimeout(() => {
418
- f && (o == null || o(f), setTimeout(() => f.postRender()));
443
+ u && (n == null || n(u), setTimeout(() => u.postRender()));
419
444
  });
420
445
  return () => clearTimeout(h);
421
- }, [f]);
422
- const p = t.get("type") || "default", m = t.content, u = (N = n.components) == null ? void 0 : N[p], l = (u == null ? void 0 : u.component) || c || t.tagName || "div", v = t.components(), C = v.length ? v.map((h) => /* @__PURE__ */ y(j, { component: h, config: n, editor: s, frameView: r }, h.cid)) : [m || void 0], w = ae(t.getAttributes()), b = u == null ? void 0 : u.editorRender, S = [...C, a].filter((h) => h ?? !1), k = S.length ? S : null;
423
- if (b)
424
- return /* @__PURE__ */ y(b, { props: w, editor: s, component: t, connectDom: d, children: k });
425
- if (u != null && u.component)
426
- return /* @__PURE__ */ y("gjs-wrapper", { ref: d, style: u.wrapperStyle, children: /* @__PURE__ */ y(l, { ...w, children: k }) });
446
+ }, [u]);
447
+ const p = t.get("type") || "default", g = t.content, f = (x = o.components) == null ? void 0 : x[p], l = (f == null ? void 0 : f.component) || i || t.tagName || "div", b = t.components(), w = b.length ? b.map((h) => /* @__PURE__ */ y(M, { component: h, config: o, editor: s, frameView: a }, h.cid)) : [g || void 0], m = ce(t.getAttributes()), R = f == null ? void 0 : f.editorRender, E = [...w, r].filter((h) => h ?? !1), P = E.length ? E : null;
448
+ if (R)
449
+ return /* @__PURE__ */ y(R, { props: m, editor: s, component: t, connectDom: d, children: P });
450
+ if (f != null && f.component)
451
+ return /* @__PURE__ */ y("gjs-wrapper", { ref: d, style: f.wrapperStyle, children: /* @__PURE__ */ y(l, { ...m, children: P }) });
427
452
  if (t.isInstanceOf("textnode"))
428
- return m;
429
- const $ = t.isInstanceOf("text") ? i : void 0;
430
- return /* @__PURE__ */ B(l, { ...w, ref: d, key: $ }, t.get("void") ? null : k);
453
+ return g;
454
+ const j = t.isInstanceOf("text") ? c : void 0;
455
+ return /* @__PURE__ */ F(l, { ...m, ref: d, key: j }, t.get("void") ? null : P);
431
456
  }
432
- const me = (e) => {
433
- const { frame: t, window: n, onMount: s, editor: r } = e, o = r.Canvas.events, { root: c } = t;
457
+ const he = (e) => {
458
+ const { frame: t, window: o, onMount: s, editor: a } = e, n = a.Canvas.events, { root: i } = t;
434
459
  try {
435
- const a = L(n.document.body);
436
- a.render(/* @__PURE__ */ y(ye, { ...e, component: c, onMount: s }));
437
- const i = () => a.unmount();
438
- t.once(o.frameUnload, i), n.addEventListener("unload", i);
439
- } catch (a) {
440
- console.warn(a);
460
+ const r = W(o.document.body);
461
+ r.render(/* @__PURE__ */ y(ve, { ...e, component: i, onMount: s }));
462
+ const c = () => r.unmount();
463
+ t.once(n.frameUnload, c), o.addEventListener("unload", c);
464
+ } catch (r) {
465
+ console.warn(r);
441
466
  }
442
- return c.getView();
467
+ return i.getView();
443
468
  };
444
- function ye(e) {
445
- const { editor: t, component: n, window: s, frameView: r, config: o, onMount: c } = e, a = s.document, i = o.rootComponent || T, f = o.rootComponent ? { editorProps: { doc: a, editor: t, frameView: r } } : {}, d = (o == null ? void 0 : o.bodyAfter) || T;
446
- return /* @__PURE__ */ y(i, { ...f, children: /* @__PURE__ */ y(
447
- j,
469
+ function ve(e) {
470
+ const { editor: t, component: o, window: s, frameView: a, config: n, onMount: i } = e, r = s.document, c = n.rootComponent || D, u = n.rootComponent ? { editorProps: { doc: r, editor: t, frameView: a } } : {}, d = (n == null ? void 0 : n.bodyAfter) || D;
471
+ return /* @__PURE__ */ y(c, { ...u, children: /* @__PURE__ */ y(
472
+ M,
448
473
  {
449
474
  tagName: "div",
450
- component: n,
451
- config: o,
475
+ component: o,
476
+ config: n,
452
477
  editor: t,
453
- frameView: r,
454
- onMount: c,
455
- children: /* @__PURE__ */ y(d, { ...f })
478
+ frameView: a,
479
+ onMount: i,
480
+ children: /* @__PURE__ */ y(d, { ...u })
456
481
  }
457
482
  ) });
458
483
  }
459
- const he = "rendererReact", ge = g.startup, ve = function(e, t = {}) {
460
- const { Blocks: n, Pages: s } = e, r = n.events, o = s.events;
461
- e.Canvas.config.customRenderer = (a) => me({ ...a, config: t }), e.Components.config.processor = (a) => A({ model: a, editor: e, config: t }), de(e, t);
462
- const c = [
463
- [r.add, le({ editor: e, config: t })],
464
- [o.addBefore, pe({ editor: e, config: t })]
484
+ const be = "rendererReact", me = v.startup, we = function(e, t = {}) {
485
+ const { Blocks: o, Pages: s } = e, a = o.events, n = s.events;
486
+ e.Canvas.config.customRenderer = (r) => he({ ...r, config: t }), e.Components.config.processor = (r) => A({ model: r, editor: e, config: t }), ye(e, t);
487
+ const i = [
488
+ [a.add, ue({ editor: e, config: t })],
489
+ [n.addBefore, fe({ editor: e, config: t })]
465
490
  ];
466
- c.forEach(([a, i]) => e.on(a, i)), Y({
491
+ i.forEach(([r, c]) => e.on(r, c)), ee({
467
492
  editor: e,
468
493
  licenseKey: t.licenseKey,
469
- plan: ge,
470
- pluginName: he,
494
+ plan: me,
495
+ pluginName: be,
471
496
  cleanup: () => {
472
- e.Canvas.config.customRenderer = void 0, e.Components.config.processor = void 0, c.forEach(([a, i]) => e.off(a, i));
497
+ e.Canvas.config.customRenderer = void 0, e.Components.config.processor = void 0, i.forEach(([r, c]) => e.off(r, c));
473
498
  }
474
499
  });
475
- }, Ae = X(ve);
500
+ }, ke = Y(we);
476
501
  export {
477
- Ae as default
502
+ ke as default
478
503
  };