@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,7 +1,7 @@
1
- const se = "app.grapesjs.com", re = "app-stage.grapesjs.com", ue = "app2.grapesjs.com", he = "app-stage2.grapesjs.com", Y = [
2
- se,
3
- ue,
1
+ const re = "app.grapesjs.com", ce = "app-stage.grapesjs.com", ge = "app2.grapesjs.com", he = "app-stage2.grapesjs.com", ee = [
4
2
  re,
3
+ ge,
4
+ ce,
5
5
  he,
6
6
  "localhost",
7
7
  "127.0.0.1",
@@ -9,153 +9,179 @@ const se = "app.grapesjs.com", re = "app-stage.grapesjs.com", ue = "app2.grapesj
9
9
  // For stackblitz.com demos
10
10
  ".local.webcontainer.io",
11
11
  // For stackblitz.com demos
12
- "-sandpack.codesandbox.io"
12
+ "-sandpack.codesandbox.io",
13
13
  // For Sandpack demos
14
- ], ge = "license:check:start", be = "license:check:end", me = () => typeof window < "u", de = ({
14
+ ".claudemcpcontent.com",
15
+ // For Claude mcp app
16
+ ".web-sandbox.oaiusercontent.com"
17
+ // For OpenAI mcp app
18
+ ], be = "license:check:end", de = () => typeof window < "u", ye = ({
15
19
  isDev: e,
16
- isStage: n,
20
+ isStage: l,
17
21
  isPlatform: t
18
- }) => `${e ? "" : `https://${n ? re : se}`}/${t ? "platform-api" : "api"}`, ye = () => {
19
- const e = me() && window.location.hostname;
20
- return !!e && (Y.includes(e) || Y.some((n) => e.endsWith(n)));
22
+ }) => `${e ? "" : `https://${l ? ce : re}`}/${t ? "platform-api" : "api"}`, me = () => {
23
+ if (!de()) return "";
24
+ const { hostname: e } = window.location;
25
+ if (e) return e;
26
+ try {
27
+ return window.parent.location.hostname || "";
28
+ } catch {
29
+ return "";
30
+ }
31
+ }, ve = () => {
32
+ const e = me();
33
+ return !!e && (ee.includes(e) || ee.some((l) => e.endsWith(l)));
21
34
  };
22
- async function ve({
35
+ async function fe({
23
36
  path: e,
24
- baseApiUrl: n,
37
+ baseApiUrl: l,
25
38
  method: t = "GET",
26
- headers: l = {},
27
- params: o,
28
- body: u
39
+ headers: o = {},
40
+ params: n,
41
+ body: g
29
42
  }) {
30
- const p = `${n || de({ isDev: !1, isStage: !1 })}${e}`, h = {
43
+ const i = `${l || ye({ isDev: !1, isStage: !1 })}${e}`, u = {
31
44
  method: t,
32
45
  headers: {
33
46
  "Content-Type": "application/json",
34
- ...l
47
+ ...o
35
48
  }
36
49
  };
37
- u && (h.body = JSON.stringify(u));
38
- const c = o ? new URLSearchParams(o).toString() : "", b = c ? `?${c}` : "", s = await fetch(`${p}${b}`, h);
39
- if (!s.ok)
40
- throw new Error(`HTTP error! status: ${s.status}`);
41
- return s.json();
50
+ g && (u.body = JSON.stringify(g));
51
+ const p = n ? new URLSearchParams(n).toString() : "", b = p ? `?${p}` : "", r = await fetch(`${i}${b}`, u);
52
+ if (!r.ok)
53
+ throw new Error(`HTTP error! status: ${r.status}`);
54
+ return r.json();
42
55
  }
43
- var G = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(G || {});
44
- const ee = {
45
- [G.free]: 0,
46
- [G.startup]: 10,
47
- [G.business]: 20,
48
- [G.enterprise]: 30
56
+ var E = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(E || {}), Z = /* @__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))(Z || {});
57
+ const te = {
58
+ [E.free]: 0,
59
+ [E.startup]: 10,
60
+ [E.business]: 20,
61
+ [E.enterprise]: 30
49
62
  };
50
- function fe(e) {
51
- const n = e;
52
- return n.init = (t) => (l) => e(l, t), n;
63
+ function Te(e) {
64
+ const l = e;
65
+ return l.init = (t) => (o) => e(o, t), l;
53
66
  }
54
- const Te = (e) => /* @__PURE__ */ fe(e);
55
- async function we({
67
+ const we = (e) => /* @__PURE__ */ Te(e);
68
+ async function xe({
56
69
  editor: e,
57
- plan: n,
70
+ plan: l,
58
71
  pluginName: t,
59
- licenseKey: l,
60
- onLicenseCheckResponse: o,
61
- cleanup: u
72
+ licenseKey: o,
73
+ onLicenseCheckResponse: n,
74
+ cleanup: g
62
75
  }) {
63
- let r = "", p = !1;
64
- const h = ye(), c = (s) => {
65
- console.warn("Cleanup plugin:", t, "Reason:", s), u();
66
- }, b = (s = {}) => {
67
- var k;
68
- const { error: P, sdkLicense: V } = s, T = (k = s.plan) == null ? void 0 : k.category;
69
- if (!(V || s.license) || P)
70
- c(P || "Invalid license");
76
+ let c = "", i;
77
+ const u = (r) => {
78
+ console.warn("Cleanup plugin:", t, "Reason:", r), g();
79
+ }, p = (r = {}) => {
80
+ var G;
81
+ const { error: I, sdkLicense: O } = r, T = (G = r.plan) == null ? void 0 : G.category;
82
+ if (!(O || r.license) || I)
83
+ u(I || "Invalid license");
71
84
  else if (T) {
72
- const O = ee[n], $ = ee[T];
73
- O > $ && c({ pluginRequiredPlan: n, licensePlan: T });
85
+ const M = te[l], _ = te[T];
86
+ M > _ && u({ pluginRequiredPlan: l, licensePlan: T });
74
87
  }
75
88
  };
76
- e.on(ge, (s) => {
77
- r = s == null ? void 0 : s.baseApiUrl, p = !0;
78
- }), e.on(be, (s) => {
79
- o == null || o(s), b(s);
80
- }), setTimeout(async () => {
81
- if (!p) {
82
- if (h) return;
83
- if (l) {
84
- const s = await Se({ licenseKey: l, pluginName: t, baseApiUrl: r });
85
- o == null || o(s), s && b(s);
86
- } else
87
- c("The `licenseKey` option not provided");
88
- }
89
- }, 2e3);
89
+ e.Commands.has(Z.settings) && (i = e.runCommand(Z.settings), c = (i == null ? void 0 : i.baseUrl) || "");
90
+ const b = (r) => {
91
+ n == null || n(r), r && p(r);
92
+ };
93
+ if (!i) {
94
+ e.onReady(async () => {
95
+ if (!ve())
96
+ if (o) {
97
+ const r = await Ae({ licenseKey: o, pluginName: t, baseApiUrl: c });
98
+ b(r);
99
+ } else
100
+ u("The `licenseKey` option not provided");
101
+ });
102
+ return;
103
+ }
104
+ if (i.licensePlan || i.licenseError) {
105
+ const r = Pe(i);
106
+ b(r);
107
+ return;
108
+ }
109
+ e.on(be, (r) => b(r));
90
110
  }
91
- async function Se(e) {
92
- const { licenseKey: n, pluginName: t, baseApiUrl: l } = e;
111
+ const Pe = (e) => ({
112
+ sdkLicense: e.license,
113
+ license: e.license,
114
+ error: e.licenseError,
115
+ plan: e.licensePlan
116
+ });
117
+ async function Ae(e) {
118
+ const { licenseKey: l, pluginName: t, baseApiUrl: o } = e;
93
119
  try {
94
- return (await ve({
95
- baseApiUrl: l,
96
- path: `/sdk/${n || "na"}`,
120
+ return (await fe({
121
+ baseApiUrl: o,
122
+ path: `/sdk/${l || "na"}`,
97
123
  method: "POST",
98
124
  params: {
99
125
  d: window.location.hostname,
100
126
  pn: t
101
127
  }
102
128
  })).result || {};
103
- } catch (o) {
104
- return console.error("Error during SDK license check:", o), !1;
129
+ } catch (n) {
130
+ return console.error("Error during SDK license check:", n), !1;
105
131
  }
106
132
  }
107
- const B = (e, n) => {
133
+ const z = (e, l) => {
108
134
  var t;
109
- return !!((t = e == null ? void 0 : e.hasAttribute) != null && t.call(e, n));
110
- }, xe = "lightGalleryComponent", Ie = G.startup;
111
- var E = /* @__PURE__ */ ((e) => (e.image = "image", e.video = "video", e.external = "external", e))(E || {});
112
- const I = "lightGallery", te = `${I}-item`, U = "data-lightgallery", ae = `${U}-item`, j = "toggle", A = {
135
+ return !!((t = e == null ? void 0 : e.hasAttribute) != null && t.call(e, l));
136
+ }, Le = "lightGalleryComponent", Ie = E.startup;
137
+ var S = /* @__PURE__ */ ((e) => (e.image = "image", e.video = "video", e.external = "external", e))(S || {});
138
+ const A = "lightGallery", ae = `${A}-item`, j = "data-lightgallery", oe = `${j}-item`, N = "toggle", L = {
113
139
  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>',
114
140
  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>',
115
141
  gallery: '<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>',
116
142
  galleryItem: '<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',
117
143
  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>',
118
144
  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>'
119
- }, W = { propKeys: [], props: {}, traits: [] }, _ = (e, n = {}) => {
120
- var o;
121
- const t = {}, l = [];
122
- for (const u in e) {
123
- const { value: r, ...p } = e[u];
124
- l.push({ id: u, name: u, changeProp: !0, category: n.category, ...p }), t[u] = r;
125
- const { subTraits: h = {} } = p;
126
- for (const c in p.subTraits)
127
- (o = h[c]) == null || o.forEach((b) => {
128
- const s = b.id || b.name;
129
- t[s] = b.value;
145
+ }, F = { propKeys: [], props: {}, traits: [] }, V = (e, l = {}) => {
146
+ var n;
147
+ const t = {}, o = [];
148
+ for (const g in e) {
149
+ const { value: c, ...i } = e[g];
150
+ o.push({ id: g, name: g, changeProp: !0, category: l.category, ...i }), t[g] = c;
151
+ const { subTraits: u = {} } = i;
152
+ for (const p in i.subTraits)
153
+ (n = u[p]) == null || n.forEach((b) => {
154
+ const r = b.id || b.name;
155
+ t[r] = b.value;
130
156
  });
131
157
  }
132
158
  return {
133
159
  propKeys: Object.keys(t),
134
160
  props: t,
135
- traits: l
161
+ traits: o
136
162
  };
137
- }, F = (e, n) => {
138
- const t = e.getTrait(n), l = t.get("category"), o = t.get("subTraits") || {}, r = (Object.values(o).flat() || []).map((c) => c.id || c.name);
139
- e.removeTrait(r);
140
- const p = o[t.getValue()], h = e.getTraitIndex(n) + 1;
141
- p && e.addTrait(
142
- p.map((c) => ({ category: l, ...c })),
143
- { at: h }
163
+ }, q = (e, l) => {
164
+ const t = e.getTrait(l), o = t.get("category"), n = t.get("subTraits") || {}, c = (Object.values(n).flat() || []).map((p) => p.id || p.name);
165
+ e.removeTrait(c);
166
+ const i = n[t.getValue()], u = e.getTraitIndex(l) + 1;
167
+ i && e.addTrait(
168
+ i.map((p) => ({ category: o, ...p })),
169
+ { at: u }
144
170
  );
145
- }, Z = (e, n) => {
146
- n.forEach((t) => {
147
- const l = e.getTrait(t);
148
- if (!l || !l.get("subTraits")) return;
149
- const o = l.changeProp ? `change:${t}` : `change:attributes:${t}`;
150
- e.on(o, () => F(e, t)), F(e, t);
171
+ }, W = (e, l) => {
172
+ l.forEach((t) => {
173
+ const o = e.getTrait(t);
174
+ if (!o || !o.get("subTraits")) return;
175
+ const n = o.changeProp ? `change:${t}` : `change:attributes:${t}`;
176
+ e.on(n, () => q(e, t)), q(e, t);
151
177
  });
152
- }, Ae = (e, n, t) => {
153
- const o = e.getTrait(n).get("subTraits") || {}, r = (Object.values(o).flat() || []).map((h) => {
154
- const c = h.name || h.id;
155
- return h.changeProp ? `change:${c}` : `change:attributes:${c}`;
156
- }), p = Array.from(new Set(r));
157
- p.length && e.on(p.join(" "), t);
158
- }, Pe = {
178
+ }, Ge = (e, l, t) => {
179
+ const n = e.getTrait(l).get("subTraits") || {}, c = (Object.values(n).flat() || []).map((u) => {
180
+ const p = u.name || u.id;
181
+ return u.changeProp ? `change:${p}` : `change:attributes:${p}`;
182
+ }), i = Array.from(new Set(c));
183
+ i.length && e.on(i.join(" "), t);
184
+ }, ke = {
159
185
  // startAnimationDuration: {
160
186
  // type: 'number',
161
187
  // label: 'Start duration',
@@ -164,12 +190,12 @@ const I = "lightGallery", te = `${I}-item`, U = "data-lightgallery", ae = `${U}-
164
190
  // step: 50,
165
191
  // min: 0
166
192
  // },
167
- [j]: {
193
+ [N]: {
168
194
  type: "button",
169
195
  label: "Toggle Gallery",
170
- command: (e, n) => {
171
- var t, l;
172
- return (l = (t = n.target) == null ? void 0 : t.getView()) == null ? void 0 : l.toggleGallery();
196
+ command: (e, l) => {
197
+ var t, o;
198
+ return (o = (t = l.target) == null ? void 0 : t.getView()) == null ? void 0 : o.toggleGallery();
173
199
  }
174
200
  },
175
201
  speed: {
@@ -269,7 +295,7 @@ const I = "lightGallery", te = `${I}-item`, U = "data-lightgallery", ae = `${U}-
269
295
  visible: ({ component: e }) => !!e.getTrait("closable").getValue(),
270
296
  value: !0
271
297
  }
272
- }, ke = {
298
+ }, Se = {
273
299
  thumbnail: {
274
300
  category: { id: "thumbnail-options", label: "Thumbnail Options" },
275
301
  type: "checkbox",
@@ -371,7 +397,7 @@ const I = "lightGallery", te = `${I}-item`, U = "data-lightgallery", ae = `${U}-
371
397
  ]
372
398
  }
373
399
  }
374
- }, Le = {
400
+ }, Ee = {
375
401
  autoplay: {
376
402
  category: { id: "autoplay-options", label: "Autoplay options" },
377
403
  type: "checkbox",
@@ -425,7 +451,7 @@ const I = "lightGallery", te = `${I}-item`, U = "data-lightgallery", ae = `${U}-
425
451
  ]
426
452
  }
427
453
  }
428
- }, Ee = {
454
+ }, Oe = {
429
455
  zoom: {
430
456
  category: { id: "zoom-options", label: "Zoom options" },
431
457
  type: "checkbox",
@@ -477,7 +503,7 @@ const I = "lightGallery", te = `${I}-item`, U = "data-lightgallery", ae = `${U}-
477
503
  ]
478
504
  }
479
505
  }
480
- }, f = "sourceType", K = "data-iframe", q = {
506
+ }, f = "sourceType", U = "data-iframe", J = {
481
507
  name: "href",
482
508
  type: "file",
483
509
  label: "Image Source"
@@ -485,7 +511,7 @@ const I = "lightGallery", te = `${I}-item`, U = "data-lightgallery", ae = `${U}-
485
511
  name: "data-src",
486
512
  label: "Video Source",
487
513
  placeholder: "https://www.youtube.com/watch?v=..."
488
- }, J = {
514
+ }, C = {
489
515
  name: "data-poster",
490
516
  label: "Video Poster",
491
517
  type: "file"
@@ -493,21 +519,21 @@ const I = "lightGallery", te = `${I}-item`, U = "data-lightgallery", ae = `${U}-
493
519
  name: "data-src",
494
520
  label: "External Source",
495
521
  placeholder: "https://some-external-source.com/...."
496
- }, ce = {
522
+ }, pe = {
497
523
  label: "Caption",
498
524
  name: "data-sub-html",
499
525
  placeholder: "My caption",
500
526
  changeProp: !1
501
- }, Ge = {
502
- [j]: {
527
+ }, Me = {
528
+ [N]: {
503
529
  type: "button",
504
530
  label: "Toggle Gallery",
505
- command: (e, n) => {
506
- var o, u;
507
- const t = n.target, l = (o = t == null ? void 0 : t.closestType(I)) == null ? void 0 : o.getView();
508
- if (l && t) {
509
- const r = ((u = l.getLightGallery()) == null ? void 0 : u.items) || [], p = Array.from(r).indexOf(t.getEl());
510
- p >= 0 && l.toggleGallery(p);
531
+ command: (e, l) => {
532
+ var n, g;
533
+ const t = l.target, o = (n = t == null ? void 0 : t.closestType(A)) == null ? void 0 : n.getView();
534
+ if (o && t) {
535
+ const c = ((g = o.getLightGallery()) == null ? void 0 : g.items) || [], i = Array.from(c).indexOf(t.getEl());
536
+ i >= 0 && o.toggleGallery(i);
511
537
  }
512
538
  }
513
539
  },
@@ -517,107 +543,107 @@ const I = "lightGallery", te = `${I}-item`, U = "data-lightgallery", ae = `${U}-
517
543
  labelToTitle: !0,
518
544
  value: "image",
519
545
  subTraits: {
520
- image: [q],
521
- video: [H, J],
546
+ image: [J],
547
+ video: [H, C],
522
548
  external: [le]
523
549
  },
524
550
  options: [
525
- { id: "image", label: q.label || "", icon: A.image },
526
- { id: "video", label: H.label || "", icon: A.video },
527
- { id: "external", label: le.label || "", icon: A.external }
551
+ { id: "image", label: J.label || "", icon: L.image },
552
+ { id: "video", label: H.label || "", icon: L.video },
553
+ { id: "external", label: le.label || "", icon: L.external }
528
554
  ]
529
555
  },
530
- subHtml: ce
556
+ subHtml: pe
531
557
  // This unfortuntaly breaks other thumbnails
532
558
  // customThumb: traitCustomThumb
533
- }, ne = "lgThumbnail", Ve = "lgVideo", oe = "lgAutoplay", ie = "lgZoom", L = "https://cdn.jsdelivr.net/npm/lightgallery@2.8.2", Oe = function(e, n = {}) {
534
- const { Blocks: t, Components: l } = e, o = "LightGallery", u = "LightGallery Item", r = {
535
- toolbarIconOpen: A.eye,
559
+ }, se = "lgThumbnail", De = "lgVideo", ne = "lgAutoplay", ie = "lgZoom", k = "https://cdn.jsdelivr.net/npm/lightgallery@2.8.2", Ve = function(e, l = {}) {
560
+ const { Blocks: t, Components: o } = e, n = "LightGallery", g = "LightGallery Item", c = {
561
+ toolbarIconOpen: L.eye,
536
562
  block: {},
537
563
  lgLicenseKey: "92DE1DB8-7986-4F02-B908-514F97678D28",
538
564
  defaultSrc: "https://placehold.co/200/777/white.png?text=Image",
539
- plugins: [ne, Ve, oe, ie],
565
+ plugins: [se, De, ne, ie],
540
566
  cdnScript: [
541
- `${L}/lightgallery.min.js`,
542
- `${L}/plugins/thumbnail/lg-thumbnail.min.js`,
543
- `${L}/plugins/video/lg-video.min.js`,
544
- `${L}/plugins/autoplay/lg-autoplay.min.js`,
545
- `${L}/plugins/zoom/lg-zoom.min.js`
567
+ `${k}/lightgallery.min.js`,
568
+ `${k}/plugins/thumbnail/lg-thumbnail.min.js`,
569
+ `${k}/plugins/video/lg-video.min.js`,
570
+ `${k}/plugins/autoplay/lg-autoplay.min.js`,
571
+ `${k}/plugins/zoom/lg-zoom.min.js`
546
572
  ],
547
- cdnStyle: `${L}/css/lightgallery-bundle.min.css`,
548
- ...n
549
- }, { block: p, toolbarIconOpen: h, defaultSrc: c } = r, b = function(a) {
550
- const i = this, g = window, { plugins: d, cdnScript: w, cdnStyle: C, inline: R, lgLicenseKey: pe, ...y } = a || {}, S = (m) => isNaN(m) ? void 0 : parseInt(m, 10), Q = () => {
551
- var D;
552
- const m = {
553
- ...y,
554
- licenseKey: pe,
555
- speed: S(y.speed),
556
- startAnimationDuration: S(y.startAnimationDuration),
557
- thumbMargin: S(y.thumbMargin),
558
- thumbWidth: S(y.thumbWidth),
559
- slideShowInterval: S(y.slideShowInterval),
560
- scale: S(y.scale),
561
- enableZoomAfter: S(y.enableZoomAfter),
562
- plugins: (d || []).map((N) => g[N])
573
+ cdnStyle: `${k}/css/lightgallery-bundle.min.css`,
574
+ ...l
575
+ }, { block: i, toolbarIconOpen: u, defaultSrc: p } = c, b = function(a) {
576
+ const s = this, h = window, { plugins: y, cdnScript: w, cdnStyle: D, inline: Q, lgLicenseKey: ue, ...m } = a || {}, x = (d) => isNaN(d) ? void 0 : parseInt(d, 10), X = () => {
577
+ var B;
578
+ const d = {
579
+ ...m,
580
+ licenseKey: ue,
581
+ speed: x(m.speed),
582
+ startAnimationDuration: x(m.startAnimationDuration),
583
+ thumbMargin: x(m.thumbMargin),
584
+ thumbWidth: x(m.thumbWidth),
585
+ slideShowInterval: x(m.slideShowInterval),
586
+ scale: x(m.scale),
587
+ enableZoomAfter: x(m.enableZoomAfter),
588
+ plugins: (y || []).map(($) => h[$])
563
589
  };
564
- R && (m.container = i, m.closable = !1);
565
- const z = (D = g.lightGallery) == null ? void 0 : D.call(g, i, m);
566
- R && z.openGallery();
590
+ Q && (d.container = s, d.closable = !1);
591
+ const K = (B = h.lightGallery) == null ? void 0 : B.call(h, s, d);
592
+ Q && K.openGallery();
567
593
  };
568
- if (g.lightGallery)
569
- Q();
594
+ if (h.lightGallery)
595
+ X();
570
596
  else {
571
- const { head: m } = document, z = Array.isArray(w) ? [...w] : [w], D = Array.isArray(C) ? [...C] : [C], N = (x) => {
572
- if (x.length) {
597
+ const { head: d } = document, K = Array.isArray(w) ? [...w] : [w], B = Array.isArray(D) ? [...D] : [D], $ = (P) => {
598
+ if (P.length) {
573
599
  const v = document.createElement("link");
574
- v.href = x.shift(), v.rel = "stylesheet", m.appendChild(v), N(x);
600
+ v.href = P.shift(), v.rel = "stylesheet", d.appendChild(v), $(P);
575
601
  }
576
- }, X = (x) => {
577
- if (x.length) {
602
+ }, Y = (P) => {
603
+ if (P.length) {
578
604
  const v = document.createElement("script");
579
- v.src = x.shift(), v.onerror = v.onload = X.bind(null, x), m.appendChild(v);
605
+ v.src = P.shift(), v.onerror = v.onload = Y.bind(null, P), d.appendChild(v);
580
606
  } else
581
- Q();
607
+ X();
582
608
  };
583
- N(D), X(z);
609
+ $(B), Y(K);
584
610
  }
585
- }, s = (a) => {
586
- const i = a.getTrait(j);
587
- if (!h || !i) return;
588
- const { toolbar: g } = a, d = {
589
- id: j,
590
- label: h,
591
- command: () => setTimeout(() => i.runCommand(), 100)
611
+ }, r = (a) => {
612
+ const s = a.getTrait(N);
613
+ if (!u || !s) return;
614
+ const { toolbar: h } = a, y = {
615
+ id: N,
616
+ label: u,
617
+ command: () => setTimeout(() => s.runCommand(), 100)
592
618
  };
593
- !g.find((C) => C.id === d.id) && (g == null || g.unshift(d));
619
+ !h.find((D) => D.id === y.id) && (h == null || h.unshift(y));
594
620
  };
595
- let P = [];
596
- const V = r.plugins || [], T = _(Pe), M = V.includes(ne) ? _(ke) : W, k = V.includes(oe) ? _(Le) : W, O = V.includes(ie) ? _(Ee) : W;
597
- l.addType(I, {
598
- block: p && {
599
- label: o,
600
- media: A.gallery,
621
+ let I = [];
622
+ const O = c.plugins || [], T = V(ke), R = O.includes(se) ? V(Se) : F, G = O.includes(ne) ? V(Ee) : F, M = O.includes(ie) ? V(Oe) : F;
623
+ o.addType(A, {
624
+ block: i && {
625
+ label: n,
626
+ media: L.gallery,
601
627
  category: "Extra",
602
628
  select: !0,
603
- ...r.block
629
+ ...c.block
604
630
  },
605
- isComponent: (a) => B(a, U),
631
+ isComponent: (a) => z(a, j),
606
632
  extendFn: ["init", "initToolbar"],
607
633
  model: {
608
634
  defaults: {
609
- name: o,
610
- icon: A.gallery,
611
- draggable: (a, i) => !i.is(I),
612
- attributes: { [U]: !0 },
613
- components: { type: te },
635
+ name: n,
636
+ icon: L.gallery,
637
+ draggable: (a, s) => !s.is(A),
638
+ attributes: { [j]: !0 },
639
+ components: { type: ae },
614
640
  script: b,
615
641
  selector: "",
616
642
  exThumbImage: "",
617
- cdnScript: r.cdnScript,
618
- cdnStyle: r.cdnStyle,
619
- plugins: r.plugins,
620
- lgLicenseKey: r.lgLicenseKey,
643
+ cdnScript: c.cdnScript,
644
+ cdnStyle: c.cdnStyle,
645
+ plugins: c.plugins,
646
+ lgLicenseKey: c.lgLicenseKey,
621
647
  "script-props": [
622
648
  "lgLicenseKey",
623
649
  "cdnScript",
@@ -626,21 +652,21 @@ const I = "lightGallery", te = `${I}-item`, U = "data-lightgallery", ae = `${U}-
626
652
  "selector",
627
653
  "exThumbImage",
628
654
  ...T.propKeys,
629
- ...M.propKeys,
630
- ...k.propKeys,
631
- ...O.propKeys
655
+ ...R.propKeys,
656
+ ...G.propKeys,
657
+ ...M.propKeys
632
658
  ],
633
659
  ...T.props,
660
+ ...R.props,
661
+ ...G.props,
634
662
  ...M.props,
635
- ...k.props,
636
- ...O.props,
637
- traits: [...T.traits, ...M.traits, ...k.traits, ...O.traits]
663
+ traits: [...T.traits, ...R.traits, ...G.traits, ...M.traits]
638
664
  },
639
665
  init() {
640
- Z(this, ["thumbnail"]), Z(this, ["autoplay"]), Z(this, ["zoom"]);
666
+ W(this, ["thumbnail"]), W(this, ["autoplay"]), W(this, ["zoom"]);
641
667
  },
642
668
  initToolbar() {
643
- s(this);
669
+ r(this);
644
670
  }
645
671
  },
646
672
  extendFnView: ["init"],
@@ -652,7 +678,7 @@ const I = "lightGallery", te = `${I}-item`, U = "data-lightgallery", ae = `${U}-
652
678
  lgAfterClose: "onLgClose"
653
679
  }),
654
680
  init() {
655
- this.listenTo(this.model, l.events.scriptUnmount, this.destroyLightGallery);
681
+ this.listenTo(this.model, o.events.scriptUnmount, this.destroyLightGallery);
656
682
  },
657
683
  getLightGallery() {
658
684
  return this.el.__lg;
@@ -666,84 +692,84 @@ const I = "lightGallery", te = `${I}-item`, U = "data-lightgallery", ae = `${U}-
666
692
  a.lgOpened = !0;
667
693
  },
668
694
  isInlineGallery() {
669
- var i;
695
+ var s;
670
696
  const a = this.getLightGallery();
671
- return ((i = a == null ? void 0 : a.settings) == null ? void 0 : i.container) === this.el;
697
+ return ((s = a == null ? void 0 : a.settings) == null ? void 0 : s.container) === this.el;
672
698
  },
673
699
  onLgInit(a) {
674
700
  this.el.__lg = a.detail.instance, !this.isInlineGallery() && this.disableLgInCanvas();
675
701
  },
676
702
  onLgOpen() {
677
- const { em: a } = this, { Canvas: i } = a, g = this.getLightGallery();
678
- P = i.getSpots(), setTimeout(() => i.removeSpots()), g.__lgOpened = !0;
703
+ const { em: a } = this, { Canvas: s } = a, h = this.getLightGallery();
704
+ I = s.getSpots(), setTimeout(() => s.removeSpots()), h.__lgOpened = !0;
679
705
  },
680
706
  onLgClose() {
681
707
  const a = this.getLightGallery();
682
- P.forEach((i) => this.em.Canvas.addSpot(i.attributes)), P = [], a.__lgOpened = !1, setTimeout(() => this.disableLgInCanvas());
708
+ I.forEach((s) => this.em.Canvas.addSpot(s.attributes)), I = [], a.__lgOpened = !1, setTimeout(() => this.disableLgInCanvas());
683
709
  },
684
710
  toggleGallery(a) {
685
- const i = this.getLightGallery();
686
- if (i.__lgOpened) return i.closeGallery(!0);
687
- i.lgOpened = !1, i.openGallery(a);
711
+ const s = this.getLightGallery();
712
+ if (s.__lgOpened) return s.closeGallery(!0);
713
+ s.lgOpened = !1, s.openGallery(a);
688
714
  }
689
715
  }
690
716
  });
691
- const $ = _(Ge);
692
- l.addType(te, {
693
- isComponent: (a) => B(a, ae) || a.tagName === "A" && B(a.parentElement, U),
717
+ const _ = V(Me);
718
+ o.addType(ae, {
719
+ isComponent: (a) => z(a, oe) || a.tagName === "A" && z(a.parentElement, j),
694
720
  extendFn: ["init", "initToolbar"],
695
721
  model: {
696
722
  defaults: {
697
723
  tagName: "a",
698
- name: u,
699
- icon: A.galleryItem,
700
- attributes: { [ae]: !0, href: c },
701
- components: { type: "image", attributes: { alt: "Image", src: c } },
702
- ...$.props,
703
- traits: [...$.traits]
724
+ name: g,
725
+ icon: L.galleryItem,
726
+ attributes: { [oe]: !0, href: p },
727
+ components: { type: "image", attributes: { alt: "Image", src: p } },
728
+ ..._.props,
729
+ traits: [..._.traits]
704
730
  },
705
731
  init() {
706
- const a = [f].map((i) => `change:${i}`).join(" ");
707
- this.initSourceType(), this.on(a, this.updateTraits), this.updateTraits({ init: !0 }), this.initScriptUpdate(), Ae(this, f, this.triggerGalleryUpdate);
732
+ const a = [f].map((s) => `change:${s}`).join(" ");
733
+ this.initSourceType(), this.on(a, this.updateTraits), this.updateTraits({ init: !0 }), this.initScriptUpdate(), Ge(this, f, this.triggerGalleryUpdate);
708
734
  },
709
735
  initToolbar() {
710
- s(this);
736
+ r(this);
711
737
  },
712
738
  initScriptUpdate() {
713
- const a = [ce.name].map((i) => `change:attributes:${i}`).join(" ");
739
+ const a = [pe.name].map((s) => `change:attributes:${s}`).join(" ");
714
740
  this.on(a, this.triggerGalleryUpdate);
715
741
  },
716
742
  triggerGalleryUpdate(...a) {
717
- var i;
718
- (i = this.closestType(I)) == null || i.__scriptPropsChange(...a);
743
+ var s;
744
+ (s = this.closestType(A)) == null || s.__scriptPropsChange(...a);
719
745
  },
720
746
  updateTraits(a = {}) {
721
- const { changed: i } = this, { init: g } = a;
722
- if (i[f] || g) {
723
- F(this, f);
724
- const d = this.getTrait(f).getValue();
725
- if (d === E.image) {
726
- this.removeAttributes([H.name, J.name, K]);
727
- const w = this.getTrait(q.name);
728
- w.setValue(w.getValue() || c);
729
- } else d === E.video ? this.removeAttributes([K]) : d === E.external && this.addAttributes({ [K]: !0 });
747
+ const { changed: s } = this, { init: h } = a;
748
+ if (s[f] || h) {
749
+ q(this, f);
750
+ const y = this.getTrait(f).getValue();
751
+ if (y === S.image) {
752
+ this.removeAttributes([H.name, C.name, U]);
753
+ const w = this.getTrait(J.name);
754
+ w.setValue(w.getValue() || p);
755
+ } else y === S.video ? this.removeAttributes([U]) : y === S.external && this.addAttributes({ [U]: !0 });
730
756
  }
731
757
  },
732
758
  initSourceType() {
733
759
  const a = this.getAttributes({ noClass: !0, noStyle: !0 });
734
- a[K] ? this.set(f, E.external) : (a[H.name] || a[J.name]) && this.set(f, E.video);
760
+ a[U] ? this.set(f, S.external) : (a[H.name] || a[C.name]) && this.set(f, S.video);
735
761
  }
736
762
  }
737
- }), we({
763
+ }), xe({
738
764
  editor: e,
739
765
  plan: Ie,
740
- licenseKey: r.licenseKey,
741
- pluginName: xe,
766
+ licenseKey: c.licenseKey,
767
+ pluginName: Le,
742
768
  cleanup: () => {
743
- t.remove(I), l.removeType(I);
769
+ t.remove(A), o.removeType(A);
744
770
  }
745
771
  });
746
- }, Ce = Te(Oe);
772
+ }, Re = we(Ve);
747
773
  export {
748
- Ce as default
774
+ Re as default
749
775
  };