@grapesjs/studio-sdk-plugins 1.0.33-rc.1 → 1.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/accordionComponent/index.cjs.js +7 -7
  2. package/dist/accordionComponent/index.es.js +161 -156
  3. package/dist/accordionComponent/index.umd.js +9 -9
  4. package/dist/aiChat/chatManager.d.ts +15 -0
  5. package/dist/aiChat/clientTools.d.ts +3 -3
  6. package/dist/aiChat/clientToolsProcessors.d.ts +14 -1
  7. package/dist/aiChat/components/AiChatEmptyState.d.ts +4 -6
  8. package/dist/aiChat/components/AiChatError.d.ts +2 -1
  9. package/dist/aiChat/components/AiChatHeader.d.ts +2 -1
  10. package/dist/aiChat/components/AiChatInput/AssetsSection.d.ts +7 -0
  11. package/dist/aiChat/components/AiChatInput/AttachButton.d.ts +10 -0
  12. package/dist/aiChat/components/AiChatInput/ContextSection.d.ts +5 -0
  13. package/dist/aiChat/components/AiChatInput/DictateButton.d.ts +7 -0
  14. package/dist/aiChat/components/AiChatInput/TextAreaWithAutoResize.d.ts +6 -0
  15. package/dist/aiChat/components/AiChatInput/constants.d.ts +6 -0
  16. package/dist/aiChat/components/AiChatInput/hooks/useSpeechToText.d.ts +15 -0
  17. package/dist/aiChat/components/AiChatInput/index.d.ts +37 -0
  18. package/dist/aiChat/components/AiChatLoadingState.d.ts +2 -1
  19. package/dist/aiChat/components/AiChatMessage.d.ts +21 -9
  20. package/dist/aiChat/components/AiChatMessages.d.ts +5 -7
  21. package/dist/aiChat/components/AiChatMessagesStatus.d.ts +5 -0
  22. package/dist/aiChat/components/AiChatPanel.d.ts +2 -3
  23. package/dist/aiChat/components/AiChatProvider.d.ts +14 -0
  24. package/dist/aiChat/components/MemoizedMarkdown.d.ts +9 -0
  25. package/dist/aiChat/components/index.d.ts +24 -25
  26. package/dist/aiChat/components/utils.d.ts +12 -4
  27. package/dist/aiChat/index.cjs.d.ts +5 -0
  28. package/dist/aiChat/index.cjs.js +453 -0
  29. package/dist/aiChat/index.d.ts +4 -3
  30. package/dist/aiChat/index.es.d.ts +5 -0
  31. package/dist/aiChat/index.es.js +30930 -0
  32. package/dist/aiChat/index.js +453 -0
  33. package/dist/aiChat/index.umd.js +453 -0
  34. package/dist/aiChat/locales/en.d.ts +64 -0
  35. package/dist/aiChat/server/index.cjs.d.ts +4 -0
  36. package/dist/aiChat/server/index.cjs.js +309 -0
  37. package/dist/aiChat/server/index.d.ts +0 -50
  38. package/dist/aiChat/server/index.es.d.ts +4 -0
  39. package/dist/aiChat/server/index.es.js +876 -0
  40. package/dist/aiChat/server/index.js +309 -0
  41. package/dist/aiChat/server/index.umd.js +309 -0
  42. package/dist/aiChat/server/stream.d.ts +0 -6
  43. package/dist/aiChat/server/tools.d.ts +157 -51
  44. package/dist/aiChat/server/types.d.ts +108 -64
  45. package/dist/aiChat/types.d.ts +148 -108
  46. package/dist/aiChat/typesSchema.d.ts +238 -25
  47. package/dist/animationComponent/index.cjs.js +3 -3
  48. package/dist/animationComponent/index.es.js +174 -169
  49. package/dist/animationComponent/index.umd.js +3 -3
  50. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  51. package/dist/canvasAbsoluteMode/index.es.js +161 -156
  52. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  53. package/dist/canvasEmptyState/index.cjs.js +1 -1
  54. package/dist/canvasEmptyState/index.es.js +113 -108
  55. package/dist/canvasEmptyState/index.umd.js +1 -1
  56. package/dist/canvasFullSize/index.cjs.js +9 -9
  57. package/dist/canvasFullSize/index.es.js +137 -132
  58. package/dist/canvasFullSize/index.umd.js +9 -9
  59. package/dist/canvasGridMode/index.cjs.js +4 -4
  60. package/dist/canvasGridMode/index.es.js +168 -163
  61. package/dist/canvasGridMode/index.umd.js +8 -8
  62. package/dist/canvasScreenshot/index.cjs.js +1 -1
  63. package/dist/canvasScreenshot/index.es.js +132 -127
  64. package/dist/canvasScreenshot/index.umd.js +1 -1
  65. package/dist/dataSourceEjs/index.cjs.js +5 -5
  66. package/dist/dataSourceEjs/index.es.js +151 -146
  67. package/dist/dataSourceEjs/index.umd.js +5 -5
  68. package/dist/dataSourceHandlebars/index.cjs.js +4 -4
  69. package/dist/dataSourceHandlebars/index.es.js +91 -86
  70. package/dist/dataSourceHandlebars/index.umd.js +5 -5
  71. package/dist/dialogComponent/index.cjs.js +16 -16
  72. package/dist/dialogComponent/index.es.js +117 -112
  73. package/dist/dialogComponent/index.umd.js +16 -16
  74. package/dist/flexComponent/index.cjs.js +11 -11
  75. package/dist/flexComponent/index.es.js +416 -411
  76. package/dist/flexComponent/index.umd.js +11 -11
  77. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  78. package/dist/fsLightboxComponent/index.es.js +152 -147
  79. package/dist/fsLightboxComponent/index.umd.js +3 -3
  80. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  81. package/dist/googleFontsAssetProvider/index.es.js +127 -122
  82. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  83. package/dist/iconifyComponent/index.cjs.js +2 -2
  84. package/dist/iconifyComponent/index.es.js +170 -165
  85. package/dist/iconifyComponent/index.umd.js +2 -2
  86. package/dist/index.cjs.js +1 -1
  87. package/dist/index.es.js +27 -22
  88. package/dist/index.umd.js +1 -1
  89. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  90. package/dist/layoutSidebarButtons/index.es.js +156 -151
  91. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  92. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  93. package/dist/lightGalleryComponent/index.es.js +197 -192
  94. package/dist/lightGalleryComponent/index.umd.js +1 -1
  95. package/dist/linkImageComponent/index.cjs.js +2 -2
  96. package/dist/linkImageComponent/index.es.js +86 -81
  97. package/dist/linkImageComponent/index.umd.js +2 -2
  98. package/dist/listPagesComponent/index.cjs.js +5 -5
  99. package/dist/listPagesComponent/index.es.js +121 -116
  100. package/dist/listPagesComponent/index.umd.js +5 -5
  101. package/dist/presetPrintable/index.cjs.js +4 -4
  102. package/dist/presetPrintable/index.es.js +180 -175
  103. package/dist/presetPrintable/index.umd.js +4 -4
  104. package/dist/prosemirror/index.cjs.js +6 -6
  105. package/dist/prosemirror/index.es.js +128 -123
  106. package/dist/prosemirror/index.umd.js +8 -8
  107. package/dist/rendererReact/index.cjs.js +1 -1
  108. package/dist/rendererReact/index.es.js +127 -122
  109. package/dist/rendererReact/index.js +1 -1
  110. package/dist/rendererReact/index.umd.js +1 -1
  111. package/dist/rteTinyMce/index.cjs.js +2 -2
  112. package/dist/rteTinyMce/index.es.js +160 -155
  113. package/dist/rteTinyMce/index.umd.js +2 -2
  114. package/dist/shapeDividerComponent/index.cjs.js +25 -25
  115. package/dist/shapeDividerComponent/index.es.js +127 -122
  116. package/dist/shapeDividerComponent/index.umd.js +25 -25
  117. package/dist/swiperComponent/index.cjs.js +9 -9
  118. package/dist/swiperComponent/index.es.js +197 -192
  119. package/dist/swiperComponent/index.umd.js +9 -9
  120. package/dist/tableComponent/index.cjs.js +1 -1
  121. package/dist/tableComponent/index.es.js +227 -222
  122. package/dist/tableComponent/index.umd.js +1 -1
  123. package/dist/types.d.ts +1 -1
  124. package/dist/utils.d.ts +12 -1
  125. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  126. package/dist/youtubeAssetProvider/index.es.js +124 -119
  127. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  128. package/package.json +5 -2
  129. package/dist/aiChat/components/AiChatInput.d.ts +0 -17
  130. package/dist/aiChat/server/stream-utils.d.ts +0 -16
@@ -1,8 +1,8 @@
1
- const D = "app.grapesjs.com", H = "app-stage.grapesjs.com", U = "app2.grapesjs.com", B = "app-stage2.grapesjs.com", M = [
2
- D,
3
- U,
4
- H,
1
+ const k = "app.grapesjs.com", U = "app-stage.grapesjs.com", B = "app2.grapesjs.com", C = "app-stage2.grapesjs.com", D = [
2
+ k,
5
3
  B,
4
+ U,
5
+ C,
6
6
  "localhost",
7
7
  "127.0.0.1",
8
8
  ".local-credentialless.webcontainer.io",
@@ -11,208 +11,213 @@ const D = "app.grapesjs.com", H = "app-stage.grapesjs.com", U = "app2.grapesjs.c
11
11
  // For stackblitz.com demos
12
12
  "-sandpack.codesandbox.io"
13
13
  // For Sandpack demos
14
- ], R = "license:check:start", W = "license:check:end", F = () => typeof window < "u", G = ({ isDev: t, isStage: a }) => `${t ? "" : `https://${a ? H : D}`}/api`, K = () => {
15
- const t = F() && window.location.hostname;
16
- return !!t && (M.includes(t) || M.some((a) => t.endsWith(a)));
14
+ ], W = "license:check:start", F = "license:check:end", G = () => typeof window < "u", K = ({
15
+ isDev: s,
16
+ isStage: c,
17
+ isPlatform: r
18
+ }) => `${s ? "" : `https://${c ? U : k}`}/${r ? "platform-api" : "api"}`, Z = () => {
19
+ const s = G() && window.location.hostname;
20
+ return !!s && (D.includes(s) || D.some((c) => s.endsWith(c)));
17
21
  };
18
- async function Z({
19
- path: t,
20
- baseApiUrl: a,
22
+ async function q({
23
+ path: s,
24
+ baseApiUrl: c,
21
25
  method: r = "GET",
22
- headers: c = {},
23
- params: p,
24
- body: h
26
+ headers: l = {},
27
+ params: a,
28
+ body: m
25
29
  }) {
26
- const w = `${a || G({ isDev: !1, isStage: !1 })}${t}`, d = {
30
+ const f = `${c || K({ isDev: !1, isStage: !1 })}${s}`, b = {
27
31
  method: r,
28
32
  headers: {
29
33
  "Content-Type": "application/json",
30
- ...c
34
+ ...l
31
35
  }
32
36
  };
33
- h && (d.body = JSON.stringify(h));
34
- const m = p ? new URLSearchParams(p).toString() : "", n = m ? `?${m}` : "", b = await fetch(`${w}${n}`, d);
35
- if (!b.ok)
36
- throw new Error(`HTTP error! status: ${b.status}`);
37
- return b.json();
37
+ m && (b.body = JSON.stringify(m));
38
+ const d = a ? new URLSearchParams(a).toString() : "", v = d ? `?${d}` : "", n = await fetch(`${f}${v}`, b);
39
+ if (!n.ok)
40
+ throw new Error(`HTTP error! status: ${n.status}`);
41
+ return n.json();
38
42
  }
39
- var x = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(x || {});
40
- const P = {
41
- [x.free]: 0,
42
- [x.startup]: 10,
43
- [x.business]: 20,
44
- [x.enterprise]: 30
43
+ var w = /* @__PURE__ */ ((s) => (s.free = "free", s.startup = "startup", s.business = "business", s.enterprise = "enterprise", s))(w || {});
44
+ const H = {
45
+ [w.free]: 0,
46
+ [w.startup]: 10,
47
+ [w.business]: 20,
48
+ [w.enterprise]: 30
45
49
  };
46
- function q(t) {
47
- const a = t;
48
- return a.init = (r) => (c) => t(c, r), a;
50
+ function z(s) {
51
+ const c = s;
52
+ return c.init = (r) => (l) => s(l, r), c;
49
53
  }
50
- const z = (t) => /* @__PURE__ */ q(t);
51
- async function J({
52
- editor: t,
53
- plan: a,
54
+ const J = (s) => /* @__PURE__ */ z(s);
55
+ async function R({
56
+ editor: s,
57
+ plan: c,
54
58
  pluginName: r,
55
- licenseKey: c,
56
- cleanup: p
59
+ licenseKey: l,
60
+ onLicenseCheckResponse: a,
61
+ cleanup: m
57
62
  }) {
58
- let h = "", g = !1;
59
- const w = K(), d = (n) => {
60
- console.warn("Cleanup plugin:", r, "Reason:", n), p();
61
- }, m = (n = {}) => {
63
+ let h = "", f = !1;
64
+ const b = Z(), d = (n) => {
65
+ console.warn("Cleanup plugin:", r, "Reason:", n), m();
66
+ }, v = (n = {}) => {
62
67
  var A;
63
- const { error: b, sdkLicense: l } = n, v = (A = n.plan) == null ? void 0 : A.category;
64
- if (!(l || n.license) || b)
65
- d(b || "Invalid license");
66
- else if (v) {
67
- const E = P[a], V = P[v];
68
- E > V && d({ pluginRequiredPlan: a, licensePlan: v });
68
+ const { error: p, sdkLicense: E } = n, y = (A = n.plan) == null ? void 0 : A.category;
69
+ if (!(E || n.license) || p)
70
+ d(p || "Invalid license");
71
+ else if (y) {
72
+ const j = H[c], t = H[y];
73
+ j > t && d({ pluginRequiredPlan: c, licensePlan: y });
69
74
  }
70
75
  };
71
- t.on(R, (n) => {
72
- h = n == null ? void 0 : n.baseApiUrl, g = !0;
73
- }), t.on(W, (n) => {
74
- m(n);
76
+ s.on(W, (n) => {
77
+ h = n == null ? void 0 : n.baseApiUrl, f = !0;
78
+ }), s.on(F, (n) => {
79
+ a == null || a(n), v(n);
75
80
  }), setTimeout(async () => {
76
- if (!g) {
77
- if (w) return;
78
- if (c) {
79
- const n = await X({ licenseKey: c, pluginName: r, baseApiUrl: h });
80
- n && m(n);
81
+ if (!f) {
82
+ if (b) return;
83
+ if (l) {
84
+ const n = await X({ licenseKey: l, pluginName: r, baseApiUrl: h });
85
+ a == null || a(n), n && v(n);
81
86
  } else
82
87
  d("The `licenseKey` option not provided");
83
88
  }
84
89
  }, 2e3);
85
90
  }
86
- async function X(t) {
87
- const { licenseKey: a, pluginName: r, baseApiUrl: c } = t;
91
+ async function X(s) {
92
+ const { licenseKey: c, pluginName: r, baseApiUrl: l } = s;
88
93
  try {
89
- return (await Z({
90
- baseApiUrl: c,
91
- path: `/sdk/${a || "na"}`,
94
+ return (await q({
95
+ baseApiUrl: l,
96
+ path: `/sdk/${c || "na"}`,
92
97
  method: "POST",
93
98
  params: {
94
99
  d: window.location.hostname,
95
100
  pn: r
96
101
  }
97
102
  })).result || {};
98
- } catch (p) {
99
- return console.error("Error during SDK license check:", p), !1;
103
+ } catch (a) {
104
+ return console.error("Error during SDK license check:", a), !1;
100
105
  }
101
106
  }
102
- const Y = "gjs-plg-", Q = "fsLightboxComponent", ee = x.startup, k = "data-fslightbox", C = "data-type", te = "fslightbox-open", T = "fslightbox", S = {
107
+ const Y = "gjs-plg-", Q = "fsLightboxComponent", tt = w.startup, $ = "data-fslightbox", N = "data-type", et = "fslightbox-open", L = "fslightbox", x = {
103
108
  image: '<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',
104
109
  video: '<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',
105
110
  imageLightbox: '<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',
106
111
  external: '<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',
107
112
  eye: '<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'
108
- }, se = function(t, a = {}) {
109
- const { Blocks: r, Components: c } = t, p = "Lightbox", h = `${Y}${T}`, g = {
110
- toolbarIconOpen: S.eye,
113
+ }, st = function(s, c = {}) {
114
+ const { Blocks: r, Components: l } = s, a = "Lightbox", m = `${Y}${L}`, h = {
115
+ toolbarIconOpen: x.eye,
111
116
  block: {},
112
117
  defaultSrc: "https://placehold.co/300/777/white.png?text=Image",
113
118
  cdnScript: "https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",
114
- ...a
115
- }, { block: w, toolbarIconOpen: d, defaultSrc: m } = g, n = function(s) {
116
- const e = this, i = "data-fslightbox", o = window, f = () => {
117
- var j;
119
+ ...c
120
+ }, { block: f, toolbarIconOpen: b, defaultSrc: d } = h, v = function(t) {
121
+ const e = this, i = "data-fslightbox", o = window, g = () => {
122
+ var M;
118
123
  const u = o.refreshFsLightbox;
119
124
  u == null || u();
120
- const $ = e.getAttribute(i);
121
- if ((j = o.fsLightboxInstances) == null || j[$], !o._isEditor) return;
122
- Array.from(document.querySelectorAll(`[${i}]`)).forEach((L) => {
123
- const y = L.onclick;
124
- L.onclick = function(I) {
125
+ const O = e.getAttribute(i);
126
+ if ((M = o.fsLightboxInstances) == null || M[O], !o._isEditor) return;
127
+ Array.from(document.querySelectorAll(`[${i}]`)).forEach((T) => {
128
+ const S = T.onclick;
129
+ T.onclick = function(I) {
125
130
  I.preventDefault();
126
- const O = L;
127
- !O.__skipLb && (y == null || y(I)), O.__skipLb = !0;
131
+ const P = T;
132
+ !P.__skipLb && (S == null || S(I)), P.__skipLb = !0;
128
133
  };
129
134
  });
130
135
  };
131
136
  if (o.refreshFsLightbox)
132
- f();
137
+ g();
133
138
  else {
134
139
  const u = document.createElement("script");
135
- u.src = s.cdnScript, u.onload = f, document.head.appendChild(u);
140
+ u.src = t.cdnScript, u.onload = g, document.head.appendChild(u);
136
141
  }
137
- }, b = (s) => ({
138
- id: `${T}-open-lb`,
139
- label: d,
142
+ }, n = (t) => ({
143
+ id: `${L}-open-lb`,
144
+ label: b,
140
145
  command: () => {
141
- const e = s.getView();
146
+ const e = t.getView();
142
147
  e == null || e.toggleLightbox();
143
148
  }
144
- }), l = "source-type", v = {
149
+ }), p = "source-type", E = {
145
150
  type: "radio",
146
- name: l,
151
+ name: p,
147
152
  label: "Source type",
148
153
  changeProp: !0,
149
154
  options: [
150
- { id: "image", label: "Image", icon: S.image },
151
- { id: "video", label: "Video", icon: S.video },
152
- { id: "el", label: "Custom Element", icon: S.external }
155
+ { id: "image", label: "Image", icon: x.image },
156
+ { id: "video", label: "Video", icon: x.video },
157
+ { id: "el", label: "Custom Element", icon: x.external }
153
158
  ],
154
159
  // @ts-expect-error Studio related prop
155
160
  labelToTitle: !0
156
- }, N = {
161
+ }, y = {
157
162
  id: "href-image",
158
163
  name: "href",
159
164
  type: "file",
160
165
  label: "Source Image"
161
- }, A = {
166
+ }, V = {
162
167
  id: "href-video",
163
168
  name: "href",
164
169
  label: "Source Video",
165
170
  placeholder: "https://www.youtube.com/watch?v=..."
166
- }, E = {
171
+ }, A = {
167
172
  id: "href-el",
168
173
  name: "href",
169
174
  label: "Source Element",
170
175
  placeholder: "#custom-element-id"
171
- }, V = {
172
- image: [N],
173
- video: [A],
174
- el: [E]
176
+ }, j = {
177
+ image: [y],
178
+ video: [V],
179
+ el: [A]
175
180
  };
176
- c.addType(T, {
177
- block: w && {
178
- label: p,
179
- media: S.imageLightbox,
181
+ l.addType(L, {
182
+ block: f && {
183
+ label: a,
184
+ media: x.imageLightbox,
180
185
  category: "Extra",
181
186
  select: !0,
182
- ...g.block
187
+ ...h.block
183
188
  },
184
- isComponent: (s) => {
189
+ isComponent: (t) => {
185
190
  var e;
186
- return (e = s.hasAttribute) == null ? void 0 : e.call(s, k);
191
+ return (e = t.hasAttribute) == null ? void 0 : e.call(t, $);
187
192
  },
188
193
  extendFn: ["initToolbar"],
189
194
  model: {
190
195
  defaults: {
191
196
  tagName: "a",
192
- name: p,
193
- icon: S.imageLightbox,
194
- classes: h,
195
- draggable: (s, e) => !e.is(T),
197
+ name: a,
198
+ icon: x.imageLightbox,
199
+ classes: m,
200
+ draggable: (t, e) => !e.is(L),
196
201
  attributes: {
197
- [k]: "lightbox",
198
- [C]: "image",
199
- href: m
202
+ [$]: "lightbox",
203
+ [N]: "image",
204
+ href: d
200
205
  },
201
- components: { type: "image", src: m },
202
- script: n,
203
- cdnScript: g.cdnScript,
206
+ components: { type: "image", src: d },
207
+ script: v,
208
+ cdnScript: h.cdnScript,
204
209
  "script-props": ["attributes", "cdnScript"],
205
- [l]: "image",
210
+ [p]: "image",
206
211
  traits: [
207
- v,
212
+ E,
208
213
  {
209
- name: k,
214
+ name: $,
210
215
  label: "Group name"
211
216
  },
212
217
  {
213
218
  type: "button",
214
219
  label: "Toggle Lightbox",
215
- command(s, e) {
220
+ command(t, e) {
216
221
  var o;
217
222
  const i = (o = e.target) == null ? void 0 : o.getView();
218
223
  i == null || i.toggleLightbox();
@@ -220,40 +225,40 @@ const Y = "gjs-plg-", Q = "fsLightboxComponent", ee = x.startup, k = "data-fslig
220
225
  }
221
226
  ],
222
227
  styles: `
223
- .${h} {
228
+ .${m} {
224
229
  display: inline-block;
225
230
  padding: 10px;
226
231
  }
227
232
  `
228
233
  },
229
234
  init() {
230
- const s = [l].map((e) => `change:${e}`).join(" ");
231
- this.on(s, this.updateTraits), this.on(`change:${l}`, this.onSourceTypeChange), this.on("change:attributes:href", this.adjustSourceType), this.updateTraits({ init: !0 }), this.adjustSourceType();
235
+ const t = [p].map((e) => `change:${e}`).join(" ");
236
+ this.on(t, this.updateTraits), this.on(`change:${p}`, this.onSourceTypeChange), this.on("change:attributes:href", this.adjustSourceType), this.updateTraits({ init: !0 }), this.adjustSourceType();
232
237
  },
233
- onSourceTypeChange(s, e, i) {
238
+ onSourceTypeChange(t, e, i) {
234
239
  if (i.adjust) return;
235
- const f = this.get(l) === "video" ? "video" : "image";
236
- this.addAttributes({ [C]: f, href: "" });
240
+ const g = this.get(p) === "video" ? "video" : "image";
241
+ this.addAttributes({ [N]: g, href: "" });
237
242
  },
238
243
  adjustSourceType() {
239
- const s = this.get(l), e = this.getAttributes().href || "", i = { adjust: !0 };
240
- if (s === "video") {
244
+ const t = this.get(p), e = this.getAttributes().href || "", i = { adjust: !0 };
245
+ if (t === "video") {
241
246
  const o = e.includes("youtube.com") ? "youtube" : "video";
242
- this.addAttributes({ [C]: o }, i);
243
- } else s !== "el" && e.startsWith("#") ? this.set(l, "el", i) : s === "image" && this.addAttributes({ [C]: "image" }, i);
247
+ this.addAttributes({ [N]: o }, i);
248
+ } else t !== "el" && e.startsWith("#") ? this.set(p, "el", i) : t === "image" && this.addAttributes({ [N]: "image" }, i);
244
249
  },
245
- updateTraits(s = {}) {
246
- const { changed: e } = this, { init: i } = s;
247
- if (e[v.name] || i) {
248
- this.removeTrait([N.name, A.name, E.name]);
249
- const o = this.get(l) || "image", f = this.getTraitIndex(l) + 1;
250
- this.addTrait(V[o], { at: f });
250
+ updateTraits(t = {}) {
251
+ const { changed: e } = this, { init: i } = t;
252
+ if (e[E.name] || i) {
253
+ this.removeTrait([y.name, V.name, A.name]);
254
+ const o = this.get(p) || "image", g = this.getTraitIndex(p) + 1;
255
+ this.addTrait(j[o], { at: g });
251
256
  }
252
257
  },
253
258
  initToolbar() {
254
- if (!d) return;
255
- const { toolbar: s } = this, e = b(this);
256
- !s.find((o) => o.id === e.id) && (s == null || s.unshift(e));
259
+ if (!b) return;
260
+ const { toolbar: t } = this, e = n(this);
261
+ !t.find((o) => o.id === e.id) && (t == null || t.unshift(e));
257
262
  }
258
263
  },
259
264
  view: {
@@ -261,31 +266,31 @@ const Y = "gjs-plg-", Q = "fsLightboxComponent", ee = x.startup, k = "data-fslig
261
266
  this.el.__skipLb = !0;
262
267
  },
263
268
  toggleLightbox() {
264
- var L;
265
- const { em: s, el: e, model: i } = this, { Canvas: o } = s, f = i.getAttributes()[k], { defaultView: u, documentElement: $ } = e.ownerDocument, _ = (L = u.fsLightboxInstances) == null ? void 0 : L[f];
266
- if ($.classList.contains(te))
269
+ var T;
270
+ const { em: t, el: e, model: i } = this, { Canvas: o } = t, g = i.getAttributes()[$], { defaultView: u, documentElement: O } = e.ownerDocument, _ = (T = u.fsLightboxInstances) == null ? void 0 : T[g];
271
+ if (O.classList.contains(et))
267
272
  _.close();
268
273
  else {
269
274
  e.__skipLb = !1;
270
- let y;
275
+ let S;
271
276
  _.props.onOpen = () => {
272
- y = o.getSpots(), setTimeout(() => o.removeSpots());
277
+ S = o.getSpots(), setTimeout(() => o.removeSpots());
273
278
  }, _.props.onClose = () => {
274
- y.forEach((I) => o.addSpot(I.attributes));
279
+ S.forEach((I) => o.addSpot(I.attributes));
275
280
  }, e.click();
276
281
  }
277
282
  }
278
283
  }
279
- }), J({
280
- editor: t,
281
- plan: ee,
282
- licenseKey: g.licenseKey,
284
+ }), R({
285
+ editor: s,
286
+ plan: tt,
287
+ licenseKey: h.licenseKey,
283
288
  pluginName: Q,
284
289
  cleanup: () => {
285
- r.remove(T), c.removeType(T);
290
+ r.remove(L), l.removeType(L);
286
291
  }
287
292
  });
288
- }, ne = z(se);
293
+ }, nt = J(st);
289
294
  export {
290
- ne as default
295
+ nt as default
291
296
  };
@@ -1,6 +1,6 @@
1
- (function(v,T){typeof exports=="object"&&typeof module<"u"?module.exports=T():typeof define=="function"&&define.amd?define(T):(v=typeof globalThis<"u"?globalThis:v||self,v.StudioSdkPlugins_fsLightboxComponent=T())})(this,function(){"use strict";const v="app.grapesjs.com",T="app-stage.grapesjs.com",V=[v,"app2.grapesjs.com",T,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],R="license:check:start",U="license:check:end",B=()=>typeof window<"u",W=({isDev:t,isStage:a})=>`${t?"":`https://${a?T:v}`}/api`,G=()=>{const t=B()&&window.location.hostname;return!!t&&(V.includes(t)||V.some(a=>t.endsWith(a)))};async function F({path:t,baseApiUrl:a,method:r="GET",headers:c={},params:p,body:h}){const _=`${a||W({isDev:!1,isStage:!1})}${t}`,d={method:r,headers:{"Content-Type":"application/json",...c}};h&&(d.body=JSON.stringify(h));const m=p?new URLSearchParams(p).toString():"",s=m?`?${m}`:"",b=await fetch(`${_}${s}`,d);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}var y=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(y||{});const $={[y.free]:0,[y.startup]:10,[y.business]:20,[y.enterprise]:30};function K(t){const a=t;return a.init=r=>c=>t(c,r),a}const Z=t=>K(t);async function q({editor:t,plan:a,pluginName:r,licenseKey:c,cleanup:p}){let h="",g=!1;const _=G(),d=s=>{console.warn("Cleanup plugin:",r,"Reason:",s),p()},m=(s={})=>{var E;const{error:b,sdkLicense:l}=s,x=(E=s.plan)==null?void 0:E.category;if(!(l||s.license)||b)d(b||"Invalid license");else if(x){const C=$[a],D=$[x];C>D&&d({pluginRequiredPlan:a,licensePlan:x})}};t.on(R,s=>{h=s==null?void 0:s.baseApiUrl,g=!0}),t.on(U,s=>{m(s)}),setTimeout(async()=>{if(!g){if(_)return;if(c){const s=await z({licenseKey:c,pluginName:r,baseApiUrl:h});s&&m(s)}else d("The `licenseKey` option not provided")}},2e3)}async function z(t){const{licenseKey:a,pluginName:r,baseApiUrl:c}=t;try{return(await F({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(p){return console.error("Error during SDK license check:",p),!1}}const J="gjs-plg-",X="fsLightboxComponent",Y=y.startup,I="data-fslightbox",k="data-type",Q="fslightbox-open",L="fslightbox",S={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',imageLightbox:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'};return Z(function(t,a={}){const{Blocks:r,Components:c}=t,p="Lightbox",h=`${J}${L}`,g={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...a},{block:_,toolbarIconOpen:d,defaultSrc:m}=g,s=function(n){const e=this,i="data-fslightbox",o=window,f=()=>{var P;const u=o.refreshFsLightbox;u==null||u();const M=e.getAttribute(i);if((P=o.fsLightboxInstances)==null||P[M],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(A=>{const w=A.onclick;A.onclick=function(O){O.preventDefault();const H=A;!H.__skipLb&&(w==null||w(O)),H.__skipLb=!0}})};if(o.refreshFsLightbox)f();else{const u=document.createElement("script");u.src=n.cdnScript,u.onload=f,document.head.appendChild(u)}},b=n=>({id:`${L}-open-lb`,label:d,command:()=>{const e=n.getView();e==null||e.toggleLightbox()}}),l="source-type",x={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},j={id:"href-image",name:"href",type:"file",label:"Source Image"},E={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},C={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},D={image:[j],video:[E],el:[C]};c.addType(L,{block:_&&{label:p,media:S.imageLightbox,category:"Extra",select:!0,...g.block},isComponent:n=>{var e;return(e=n.hasAttribute)==null?void 0:e.call(n,I)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:p,icon:S.imageLightbox,classes:h,draggable:(n,e)=>!e.is(L),attributes:{[I]:"lightbox",[k]:"image",href:m},components:{type:"image",src:m},script:s,cdnScript:g.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[x,{name:I,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(n,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
2
- .${h} {
1
+ (function(f,v){typeof exports=="object"&&typeof module<"u"?module.exports=v():typeof define=="function"&&define.amd?define(v):(f=typeof globalThis<"u"?globalThis:f||self,f.StudioSdkPlugins_fsLightboxComponent=v())})(this,function(){"use strict";const f="app.grapesjs.com",v="app-stage.grapesjs.com",k=[f,"app2.grapesjs.com",v,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],U="license:check:start",B="license:check:end",W=()=>typeof window<"u",G=({isDev:n,isStage:c,isPlatform:r})=>`${n?"":`https://${c?v:f}`}/${r?"platform-api":"api"}`,F=()=>{const n=W()&&window.location.hostname;return!!n&&(k.includes(n)||k.some(c=>n.endsWith(c)))};async function K({path:n,baseApiUrl:c,method:r="GET",headers:l={},params:a,body:m}){const x=`${c||G({isDev:!1,isStage:!1})}${n}`,b={method:r,headers:{"Content-Type":"application/json",...l}};m&&(b.body=JSON.stringify(m));const p=a?new URLSearchParams(a).toString():"",L=p?`?${p}`:"",s=await fetch(`${x}${L}`,b);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.json()}var T=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(T||{});const H={[T.free]:0,[T.startup]:10,[T.business]:20,[T.enterprise]:30};function Z(n){const c=n;return c.init=r=>l=>n(l,r),c}const q=n=>Z(n);async function R({editor:n,plan:c,pluginName:r,licenseKey:l,onLicenseCheckResponse:a,cleanup:m}){let h="",x=!1;const b=F(),p=s=>{console.warn("Cleanup plugin:",r,"Reason:",s),m()},L=(s={})=>{var E;const{error:d,sdkLicense:O}=s,A=(E=s.plan)==null?void 0:E.category;if(!(O||s.license)||d)p(d||"Invalid license");else if(A){const M=H[c],t=H[A];M>t&&p({pluginRequiredPlan:c,licensePlan:A})}};n.on(U,s=>{h=s==null?void 0:s.baseApiUrl,x=!0}),n.on(B,s=>{a==null||a(s),L(s)}),setTimeout(async()=>{if(!x){if(b)return;if(l){const s=await z({licenseKey:l,pluginName:r,baseApiUrl:h});a==null||a(s),s&&L(s)}else p("The `licenseKey` option not provided")}},2e3)}async function z(n){const{licenseKey:c,pluginName:r,baseApiUrl:l}=n;try{return(await K({baseApiUrl:l,path:`/sdk/${c||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const J="gjs-plg-",X="fsLightboxComponent",Y=T.startup,I="data-fslightbox",N="data-type",Q="fslightbox-open",y="fslightbox",S={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',imageLightbox:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'};return q(function(n,c={}){const{Blocks:r,Components:l}=n,a="Lightbox",m=`${J}${y}`,h={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...c},{block:x,toolbarIconOpen:b,defaultSrc:p}=h,L=function(t){const e=this,i="data-fslightbox",o=window,g=()=>{var V;const u=o.refreshFsLightbox;u==null||u();const P=e.getAttribute(i);if((V=o.fsLightboxInstances)==null||V[P],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(w=>{const _=w.onclick;w.onclick=function(j){j.preventDefault();const C=w;!C.__skipLb&&(_==null||_(j)),C.__skipLb=!0}})};if(o.refreshFsLightbox)g();else{const u=document.createElement("script");u.src=t.cdnScript,u.onload=g,document.head.appendChild(u)}},s=t=>({id:`${y}-open-lb`,label:b,command:()=>{const e=t.getView();e==null||e.toggleLightbox()}}),d="source-type",O={type:"radio",name:d,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},A={id:"href-image",name:"href",type:"file",label:"Source Image"},D={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},E={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},M={image:[A],video:[D],el:[E]};l.addType(y,{block:x&&{label:a,media:S.imageLightbox,category:"Extra",select:!0,...h.block},isComponent:t=>{var e;return(e=t.hasAttribute)==null?void 0:e.call(t,I)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:a,icon:S.imageLightbox,classes:m,draggable:(t,e)=>!e.is(y),attributes:{[I]:"lightbox",[N]:"image",href:p},components:{type:"image",src:p},script:L,cdnScript:h.cdnScript,"script-props":["attributes","cdnScript"],[d]:"image",traits:[O,{name:I,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(t,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
2
+ .${m} {
3
3
  display: inline-block;
4
4
  padding: 10px;
5
5
  }
6
- `},init(){const n=[l].map(e=>`change:${e}`).join(" ");this.on(n,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(n,e,i){if(i.adjust)return;const f=this.get(l)==="video"?"video":"image";this.addAttributes({[k]:f,href:""})},adjustSourceType(){const n=this.get(l),e=this.getAttributes().href||"",i={adjust:!0};if(n==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[k]:o},i)}else n!=="el"&&e.startsWith("#")?this.set(l,"el",i):n==="image"&&this.addAttributes({[k]:"image"},i)},updateTraits(n={}){const{changed:e}=this,{init:i}=n;if(e[x.name]||i){this.removeTrait([j.name,E.name,C.name]);const o=this.get(l)||"image",f=this.getTraitIndex(l)+1;this.addTrait(D[o],{at:f})}},initToolbar(){if(!d)return;const{toolbar:n}=this,e=b(this);!n.find(o=>o.id===e.id)&&(n==null||n.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var A;const{em:n,el:e,model:i}=this,{Canvas:o}=n,f=i.getAttributes()[I],{defaultView:u,documentElement:M}=e.ownerDocument,N=(A=u.fsLightboxInstances)==null?void 0:A[f];if(M.classList.contains(Q))N.close();else{e.__skipLb=!1;let w;N.props.onOpen=()=>{w=o.getSpots(),setTimeout(()=>o.removeSpots())},N.props.onClose=()=>{w.forEach(O=>o.addSpot(O.attributes))},e.click()}}}}),q({editor:t,plan:Y,licenseKey:g.licenseKey,pluginName:X,cleanup:()=>{r.remove(L),c.removeType(L)}})})});
6
+ `},init(){const t=[d].map(e=>`change:${e}`).join(" ");this.on(t,this.updateTraits),this.on(`change:${d}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(t,e,i){if(i.adjust)return;const g=this.get(d)==="video"?"video":"image";this.addAttributes({[N]:g,href:""})},adjustSourceType(){const t=this.get(d),e=this.getAttributes().href||"",i={adjust:!0};if(t==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[N]:o},i)}else t!=="el"&&e.startsWith("#")?this.set(d,"el",i):t==="image"&&this.addAttributes({[N]:"image"},i)},updateTraits(t={}){const{changed:e}=this,{init:i}=t;if(e[O.name]||i){this.removeTrait([A.name,D.name,E.name]);const o=this.get(d)||"image",g=this.getTraitIndex(d)+1;this.addTrait(M[o],{at:g})}},initToolbar(){if(!b)return;const{toolbar:t}=this,e=s(this);!t.find(o=>o.id===e.id)&&(t==null||t.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var w;const{em:t,el:e,model:i}=this,{Canvas:o}=t,g=i.getAttributes()[I],{defaultView:u,documentElement:P}=e.ownerDocument,$=(w=u.fsLightboxInstances)==null?void 0:w[g];if(P.classList.contains(Q))$.close();else{e.__skipLb=!1;let _;$.props.onOpen=()=>{_=o.getSpots(),setTimeout(()=>o.removeSpots())},$.props.onClose=()=>{_.forEach(j=>o.addSpot(j.attributes))},e.click()}}}}),R({editor:n,plan:Y,licenseKey:h.licenseKey,pluginName:X,cleanup:()=>{r.remove(y),l.removeType(y)}})})});
@@ -1 +1 @@
1
- "use strict";var d=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(d||{}),y=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",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.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))(y||{});const T="app.grapesjs.com",x="app-stage.grapesjs.com",I="app2.grapesjs.com",k="app-stage2.grapesjs.com",w=[T,I,x,k,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:start",E="license:check:end",M=()=>typeof window<"u",U=({isDev:e,isStage:t})=>`${e?"":`https://${t?x:T}`}/api`,j=()=>{const e=M()&&window.location.hostname;return!!e&&(w.includes(e)||w.some(t=>e.endsWith(t)))};async function N({path:e,baseApiUrl:t,method:s="GET",headers:o={},params:n,body:r}){const l=`${t||U({isDev:!1,isStage:!1})}${e}`,c={method:s,headers:{"Content-Type":"application/json",...o}};r&&(c.body=JSON.stringify(r));const u=n?new URLSearchParams(n).toString():"",a=u?`?${u}`:"",g=await fetch(`${l}${a}`,c);if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`);return g.json()}const L={[d.free]:0,[d.startup]:10,[d.business]:20,[d.enterprise]:30};function B(e){const t=e;return t.init=s=>o=>e(o,s),t}const W=e=>B(e);async function _({editor:e,plan:t,pluginName:s,licenseKey:o,cleanup:n}){let r="",i=!1;const l=j(),c=a=>{console.warn("Cleanup plugin:",s,"Reason:",a),n()},u=(a={})=>{var A;const{error:g,sdkLicense:f}=a,p=(A=a.plan)==null?void 0:A.category;if(!(f||a.license)||g)c(g||"Invalid license");else if(p){const G=L[t],O=L[p];G>O&&c({pluginRequiredPlan:t,licensePlan:p})}};e.on($,a=>{r=a==null?void 0:a.baseApiUrl,i=!0}),e.on(E,a=>{u(a)}),setTimeout(async()=>{if(!i){if(l)return;if(o){const a=await K({licenseKey:o,pluginName:s,baseApiUrl:r});a&&u(a)}else c("The `licenseKey` option not provided")}},2e3)}async function K(e){const{licenseKey:t,pluginName:s,baseApiUrl:o}=e;try{return(await N({baseApiUrl:o,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const b=e=>e.replaceAll('"',"").replaceAll("'",""),v=e=>e.includes(",")?e:/\s/.test(e)?`'${b(e)}'`:b(e),R=(e,t,s)=>({family:e,variant:t,...s}),D=(e,t)=>{e=v(e);const{menuVariant:s,variants:o}=t;return{family:e,familyLabel:b(e),menuVariant:s&&R(v(`menuFont-${b(e)}`),"regular",s),variants:Object.assign({},...Object.entries(o).map(([n,r])=>({[n]:R(e,n,r)})))}},F=(e,t)=>{var l;const s=D(e.family,e),o=s.menuVariant??((l=Object.values(s.variants))==null?void 0:l[0]);if(!o)return"Arial, Helvetica, sans-serif";const{source:n,descriptors:r}=o,i=b(o.family);if(!t){const c=new FontFace(i,`url("${n}")`,r),u=Array.from(document.fonts.values()).filter(a=>a.family===i);for(const a of u)document.fonts.delete(a);document.fonts.add(c),c.load().catch(()=>{})}return v(i)},V=e=>{const{family:t,menu:s,axes:o}=e,n=!!o,r=Object.assign({},...e.variants.map(i=>{var a,g;let l,c;if(n){const f=o.find(p=>p.tag==="wght");if(f){const{start:p,end:P}=f;l=`${p} ${P}`}}return l||(l=((a=i.match(/\d+/))==null?void 0:a[0])??"400"),c=((g=i.match(/[a-zA-Z]+/))==null?void 0:g[0])==="italic"?"italic":void 0,{[i]:{source:e.files[i],descriptors:{style:c,weight:l}}}}));return D(t,{menuVariant:{source:s},variants:r})},H=e=>({id:`${e.family}/${e.version}`,type:"font",src:e.menu,name:e.family,customData:{font:V(e),needsLoading:!0}}),z=e=>{const{font:t}=e.customData;return e.customData.needsLoading?(e.customData.needsLoading=!1,F(t)):F(t,!0)};let h;const q=e=>{const t=[];for(const s of Object.keys(e)){let o=e[s];o&&(Array.isArray(o)?t.push(...o.map(n=>[s,n.toString()])):(o=o.toString(),t.push([s,o])))}return new URLSearchParams(t)},S=e=>{const{apiKey:t,searchParams:s}=e,o=(n={})=>{const r="https://www.googleapis.com/webfonts/v1/webfonts",i=q(n);return`${r}?${i}`};return{id:"google-fonts",types:["font"],label:({editor:n})=>n.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var u;if(h)return h;const n={key:t,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},r=s==null?void 0:s(),i={...n,...r},c=await(await fetch(o(i))).json();return(u=c.items)!=null&&u.length?(h=c.items.map(H),h):[]},itemLayout:n=>{const r=h.find(l=>l.id===n.assetProps.id),i=z(r);return{type:"column",onClick:()=>n.onSelect(r),htmlAttrs:{title:r.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},J={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},Q="googleFontsAssetProvider",Z=d.startup,X=function(e,t){const{i18n:s={}}=t,o=S(t);e.runCommand(y.assetProviderAdd,{provider:o}),e.I18n.addMessages({en:J,...s}),_({editor:e,licenseKey:t.licenseKey,plan:Z,pluginName:Q,cleanup:()=>{e.runCommand(y.assetProviderRemove,{id:o.id})}})},Y=W(X);module.exports=Y;
1
+ "use strict";var p=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(p||{}),v=(t=>(t.toastAdd="studio:toastAdd",t.toastRemove="studio:toastRemove",t.dialogOpen="studio:dialogOpen",t.dialogClose="studio:dialogClose",t.dialogExportCode="studio:dialogExportCode",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.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))(v||{});const D="app.grapesjs.com",G="app-stage.grapesjs.com",I="app2.grapesjs.com",$="app-stage2.grapesjs.com",w=[D,I,G,$,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],E="license:check:start",M="license:check:end",U=()=>typeof window<"u",j=({isDev:t,isStage:e,isPlatform:s})=>`${t?"":`https://${e?G:D}`}/${s?"platform-api":"api"}`,N=()=>{const t=U()&&window.location.hostname;return!!t&&(w.includes(t)||w.some(e=>t.endsWith(e)))};async function B({path:t,baseApiUrl:e,method:s="GET",headers:n={},params:o,body:r}){const l=`${e||j({isDev:!1,isStage:!1})}${t}`,c={method:s,headers:{"Content-Type":"application/json",...n}};r&&(c.body=JSON.stringify(r));const u=o?new URLSearchParams(o).toString():"",g=u?`?${u}`:"",a=await fetch(`${l}${g}`,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a.json()}const F={[p.free]:0,[p.startup]:10,[p.business]:20,[p.enterprise]:30};function k(t){const e=t;return e.init=s=>n=>t(n,s),e}const W=t=>k(t);async function _({editor:t,plan:e,pluginName:s,licenseKey:n,onLicenseCheckResponse:o,cleanup:r}){let i="",l=!1;const c=N(),u=a=>{console.warn("Cleanup plugin:",s,"Reason:",a),r()},g=(a={})=>{var A;const{error:d,sdkLicense:f}=a,b=(A=a.plan)==null?void 0:A.category;if(!(f||a.license)||d)u(d||"Invalid license");else if(b){const O=F[e],R=F[b];O>R&&u({pluginRequiredPlan:e,licensePlan:b})}};t.on(E,a=>{i=a==null?void 0:a.baseApiUrl,l=!0}),t.on(M,a=>{o==null||o(a),g(a)}),setTimeout(async()=>{if(!l){if(c)return;if(n){const a=await K({licenseKey:n,pluginName:s,baseApiUrl:i});o==null||o(a),a&&g(a)}else u("The `licenseKey` option not provided")}},2e3)}async function K(t){const{licenseKey:e,pluginName:s,baseApiUrl:n}=t;try{return(await B({baseApiUrl:n,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const y=t=>t.replaceAll('"',"").replaceAll("'",""),P=t=>t.includes(",")?t:/\s/.test(t)?`'${y(t)}'`:y(t),T=(t,e,s)=>({family:t,variant:e,...s}),L=(t,e)=>{t=P(t);const{menuVariant:s,variants:n}=e;return{family:t,familyLabel:y(t),menuVariant:s&&T(P(`menuFont-${y(t)}`),"regular",s),variants:Object.assign({},...Object.entries(n).map(([o,r])=>({[o]:T(t,o,r)})))}},x=(t,e)=>{var l;const s=L(t.family,t),n=s.menuVariant??((l=Object.values(s.variants))==null?void 0:l[0]);if(!n)return"Arial, Helvetica, sans-serif";const{source:o,descriptors:r}=n,i=y(n.family);if(!e){const c=new FontFace(i,`url("${o}")`,r),u=Array.from(document.fonts.values()).filter(g=>g.family===i);for(const g of u)document.fonts.delete(g);document.fonts.add(c),c.load().catch(()=>{})}return P(i)},V=t=>{const{family:e,menu:s,axes:n}=t,o=!!n,r=Object.assign({},...t.variants.map(i=>{var g,a;let l,c;if(o){const d=n.find(f=>f.tag==="wght");if(d){const{start:f,end:b}=d;l=`${f} ${b}`}}return l||(l=((g=i.match(/\d+/))==null?void 0:g[0])??"400"),c=((a=i.match(/[a-zA-Z]+/))==null?void 0:a[0])==="italic"?"italic":void 0,{[i]:{source:t.files[i],descriptors:{style:c,weight:l}}}}));return L(e,{menuVariant:{source:s},variants:r})},H=t=>({id:`${t.family}/${t.version}`,type:"font",src:t.menu,name:t.family,customData:{font:V(t),needsLoading:!0}}),z=t=>{const{font:e}=t.customData;return t.customData.needsLoading?(t.customData.needsLoading=!1,x(e)):x(e,!0)};let h;const q=t=>{const e=[];for(const s of Object.keys(t)){let n=t[s];n&&(Array.isArray(n)?e.push(...n.map(o=>[s,o.toString()])):(n=n.toString(),e.push([s,n])))}return new URLSearchParams(e)},S=t=>{const{apiKey:e,searchParams:s}=t,n=(o={})=>{const r="https://www.googleapis.com/webfonts/v1/webfonts",i=q(o);return`${r}?${i}`};return{id:"google-fonts",types:["font"],label:({editor:o})=>o.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var u;if(h)return h;const o={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},r=s==null?void 0:s(),i={...o,...r},c=await(await fetch(n(i))).json();return(u=c.items)!=null&&u.length?(h=c.items.map(H),h):[]},itemLayout:o=>{const r=h.find(l=>l.id===o.assetProps.id),i=z(r);return{type:"column",onClick:()=>o.onSelect(r),htmlAttrs:{title:r.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},J={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},Q="googleFontsAssetProvider",Z=p.startup,X=function(t,e){const{i18n:s={}}=e,n=S(e);t.runCommand(v.assetProviderAdd,{provider:n}),t.I18n.addMessages({en:J,...s}),_({editor:t,licenseKey:e.licenseKey,plan:Z,pluginName:Q,cleanup:()=>{t.runCommand(v.assetProviderRemove,{id:n.id})}})},Y=W(X);module.exports=Y;