@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 D = "app.grapesjs.com", $ = "app-stage.grapesjs.com", B = "app2.grapesjs.com", H = "app-stage2.grapesjs.com", O = [
2
- D,
1
+ const k = "app.grapesjs.com", D = "app-stage.grapesjs.com", B = "app2.grapesjs.com", H = "app-stage2.grapesjs.com", O = [
2
+ k,
3
3
  B,
4
- $,
4
+ D,
5
5
  H,
6
6
  "localhost",
7
7
  "127.0.0.1",
@@ -9,211 +9,237 @@ const D = "app.grapesjs.com", $ = "app-stage.grapesjs.com", B = "app2.grapesjs.c
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
- ], F = "license:check:start", W = "license:check:end", C = () => typeof window < "u", K = ({
15
- isDev: t,
16
- isStage: e,
14
+ ".claudemcpcontent.com",
15
+ // For Claude mcp app
16
+ ".web-sandbox.oaiusercontent.com"
17
+ // For OpenAI mcp app
18
+ ], F = "license:check:end", C = () => typeof window < "u", W = ({
19
+ isDev: e,
20
+ isStage: t,
17
21
  isPlatform: o
18
- }) => `${t ? "" : `https://${e ? $ : D}`}/${o ? "platform-api" : "api"}`, V = () => {
19
- const t = C() && window.location.hostname;
20
- return !!t && (O.includes(t) || O.some((e) => t.endsWith(e)));
22
+ }) => `${e ? "" : `https://${t ? D : k}`}/${o ? "platform-api" : "api"}`, m = () => {
23
+ if (!C()) 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
+ }, K = () => {
32
+ const e = m();
33
+ return !!e && (O.includes(e) || O.some((t) => e.endsWith(t)));
21
34
  };
22
- async function Y({
23
- path: t,
24
- baseApiUrl: e,
35
+ async function V({
36
+ path: e,
37
+ baseApiUrl: t,
25
38
  method: o = "GET",
26
- headers: s = {},
27
- params: a,
28
- body: p
39
+ headers: r = {},
40
+ params: l,
41
+ body: g
29
42
  }) {
30
- const c = `${e || K({ isDev: !1, isStage: !1 })}${t}`, n = {
43
+ const s = `${t || W({ isDev: !1, isStage: !1 })}${e}`, n = {
31
44
  method: o,
32
45
  headers: {
33
46
  "Content-Type": "application/json",
34
- ...s
47
+ ...r
35
48
  }
36
49
  };
37
- p && (n.body = JSON.stringify(p));
38
- const r = a ? new URLSearchParams(a).toString() : "", g = r ? `?${r}` : "", i = await fetch(`${c}${g}`, n);
50
+ g && (n.body = JSON.stringify(g));
51
+ const c = l ? new URLSearchParams(l).toString() : "", p = c ? `?${c}` : "", i = await fetch(`${s}${p}`, n);
39
52
  if (!i.ok)
40
53
  throw new Error(`HTTP error! status: ${i.status}`);
41
54
  return i.json();
42
55
  }
43
- var v = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(v || {}), k = /* @__PURE__ */ ((t) => (t.Info = "info", t.Error = "error", t.Success = "success", t.Warning = "warning", t))(k || {}), w = /* @__PURE__ */ ((t) => (t.toastAdd = "studio:toastAdd", t.toastRemove = "studio:toastRemove", t.dialogOpen = "studio:dialogOpen", t.dialogClose = "studio:dialogClose", t.dialogExportCode = "studio:dialogExportCode", t.dialogImportCode = "studio:dialogImportCode", t.sidebarLeftSet = "studio:sidebarLeft:set", t.sidebarLeftGet = "studio:sidebarLeft:get", t.sidebarLeftToggle = "studio:sidebarLeft:toggle", t.sidebarRightSet = "studio:sidebarRight:set", t.sidebarRightGet = "studio:sidebarRight:get", t.sidebarRightToggle = "studio:sidebarRight:toggle", t.sidebarTopSet = "studio:sidebarTop:set", t.sidebarTopGet = "studio:sidebarTop:get", t.sidebarTopToggle = "studio:sidebarTop:toggle", t.sidebarBottomSet = "studio:sidebarBottom:set", t.sidebarBottomGet = "studio:sidebarBottom:get", t.sidebarBottomToggle = "studio:sidebarBottom:toggle", t.symbolAdd = "studio:symbolAdd", t.symbolDetach = "studio:symbolDetach", t.symbolOverride = "studio:symbolOverride", t.symbolPropagateStyles = "studio:propagateStyles", t.getPagesConfig = "studio:getPagesConfig", t.setPagesConfig = "studio:setPagesConfig", t.getPageSettings = "studio:getPageSettings", t.setPageSettings = "studio:setPageSettings", t.clearPage = "studio:clearPage", t.projectFiles = "studio:projectFiles", t.validateCode = "studio:validateCode", t.canvasReload = "studio:canvasReload", t.getBlocksPanel = "studio:getBlocksPanel", t.setBlocksPanel = "studio:setBlocksPanel", t.getStateContextMenu = "studio:getStateContextMenu", t.setStateContextMenu = "studio:setStateContextMenu", t.contextMenuComponent = "studio:contextMenuComponent", t.layoutAdd = "studio:layoutAdd", t.layoutRemove = "studio:layoutRemove", t.layoutToggle = "studio:layoutToggle", t.layoutUpdate = "studio:layoutUpdate", t.layoutGet = "studio:layoutGet", t.layoutConfigGet = "studio:layoutConfigGet", t.layoutConfigSet = "studio:layoutConfigSet", t.layoutComponentAdd = "studio:layoutComponentAdd", t.layoutComponentGet = "studio:layoutComponentGet", t.layoutComponentRemove = "studio:layoutComponentRemove", t.layoutComponentRender = "studio:layoutComponentRender", t.getStateTheme = "studio:getStateTheme", t.setStateTheme = "studio:setStateTheme", t.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))(w || {});
56
+ var w = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(w || {}), _ = /* @__PURE__ */ ((e) => (e.Info = "info", e.Error = "error", e.Success = "success", e.Warning = "warning", e))(_ || {}), y = /* @__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))(y || {});
44
57
  const x = {
45
- [v.free]: 0,
46
- [v.startup]: 10,
47
- [v.business]: 20,
48
- [v.enterprise]: 30
58
+ [w.free]: 0,
59
+ [w.startup]: 10,
60
+ [w.business]: 20,
61
+ [w.enterprise]: 30
49
62
  };
50
- function z(t) {
51
- const e = t;
52
- return e.init = (o) => (s) => t(s, o), e;
63
+ function Y(e) {
64
+ const t = e;
65
+ return t.init = (o) => (r) => e(r, o), t;
53
66
  }
54
- const q = (t) => /* @__PURE__ */ z(t);
55
- async function J({
56
- editor: t,
57
- plan: e,
67
+ const z = (e) => /* @__PURE__ */ Y(e);
68
+ async function q({
69
+ editor: e,
70
+ plan: t,
58
71
  pluginName: o,
59
- licenseKey: s,
60
- onLicenseCheckResponse: a,
61
- cleanup: p
72
+ licenseKey: r,
73
+ onLicenseCheckResponse: l,
74
+ cleanup: g
62
75
  }) {
63
- let l = "", c = !1;
64
- const n = V(), r = (i) => {
65
- console.warn("Cleanup plugin:", o, "Reason:", i), p();
66
- }, g = (i = {}) => {
67
- var h;
68
- const { error: y, sdkLicense: u } = i, d = (h = i.plan) == null ? void 0 : h.category;
69
- if (!(u || i.license) || y)
70
- r(y || "Invalid license");
76
+ let a = "", s;
77
+ const n = (i) => {
78
+ console.warn("Cleanup plugin:", o, "Reason:", i), g();
79
+ }, c = (i = {}) => {
80
+ var b;
81
+ const { error: h, sdkLicense: u } = i, d = (b = i.plan) == null ? void 0 : b.category;
82
+ if (!(u || i.license) || h)
83
+ n(h || "Invalid license");
71
84
  else if (d) {
72
- const f = x[e], b = x[d];
73
- f > b && r({ pluginRequiredPlan: e, licensePlan: d });
85
+ const f = x[t], v = x[d];
86
+ f > v && n({ pluginRequiredPlan: t, licensePlan: d });
74
87
  }
75
88
  };
76
- t.on(F, (i) => {
77
- l = i == null ? void 0 : i.baseApiUrl, c = !0;
78
- }), t.on(W, (i) => {
79
- a == null || a(i), g(i);
80
- }), setTimeout(async () => {
81
- if (!c) {
82
- if (n) return;
83
- if (s) {
84
- const i = await X({ licenseKey: s, pluginName: o, baseApiUrl: l });
85
- a == null || a(i), i && g(i);
86
- } else
87
- r("The `licenseKey` option not provided");
88
- }
89
- }, 2e3);
89
+ e.Commands.has(y.settings) && (s = e.runCommand(y.settings), a = (s == null ? void 0 : s.baseUrl) || "");
90
+ const p = (i) => {
91
+ l == null || l(i), i && c(i);
92
+ };
93
+ if (!s) {
94
+ e.onReady(async () => {
95
+ if (!K())
96
+ if (r) {
97
+ const i = await X({ licenseKey: r, pluginName: o, baseApiUrl: a });
98
+ p(i);
99
+ } else
100
+ n("The `licenseKey` option not provided");
101
+ });
102
+ return;
103
+ }
104
+ if (s.licensePlan || s.licenseError) {
105
+ const i = J(s);
106
+ p(i);
107
+ return;
108
+ }
109
+ e.on(F, (i) => p(i));
90
110
  }
91
- async function X(t) {
92
- const { licenseKey: e, pluginName: o, baseApiUrl: s } = t;
111
+ const J = (e) => ({
112
+ sdkLicense: e.license,
113
+ license: e.license,
114
+ error: e.licenseError,
115
+ plan: e.licensePlan
116
+ });
117
+ async function X(e) {
118
+ const { licenseKey: t, pluginName: o, baseApiUrl: r } = e;
93
119
  try {
94
- return (await Y({
95
- baseApiUrl: s,
96
- path: `/sdk/${e || "na"}`,
120
+ return (await V({
121
+ baseApiUrl: r,
122
+ path: `/sdk/${t || "na"}`,
97
123
  method: "POST",
98
124
  params: {
99
125
  d: window.location.hostname,
100
126
  pn: o
101
127
  }
102
128
  })).result || {};
103
- } catch (a) {
104
- return console.error("Error during SDK license check:", a), !1;
129
+ } catch (l) {
130
+ return console.error("Error during SDK license check:", l), !1;
105
131
  }
106
132
  }
107
- const Z = (t, e) => {
133
+ const Z = (e, t) => {
108
134
  var o;
109
- return !!((o = t == null ? void 0 : t.hasAttribute) != null && o.call(t, e));
110
- }, m = "iconifyComponent", Q = v.startup, S = { ratioDefault: !0, tc: !1, cl: !1, cr: !1, bc: !1 }, E = `<svg viewBox="0 0 24 24">
135
+ return !!((o = e == null ? void 0 : e.hasAttribute) != null && o.call(e, t));
136
+ }, Q = "iconifyComponent", S = w.startup, ee = { ratioDefault: !0, tc: !1, cl: !1, cr: !1, bc: !1 }, T = `<svg viewBox="0 0 24 24">
111
137
  <path d="M19 0H9C7.9 0 7 .9 7 2V18C7 19.1 7.9 20 9 20H19C20.1 20 21 19.1 21 18V2C21 .9 20.1 0 19 0M19 18H9V2H19V18M3 4V22C3 23.1 3.9 24 5 24H17V22H5V4H3M14 5L11 10L14 15L17 10L14 5Z" />
112
- </svg>`, G = "layout-icon-picker", tt = "icons-layout-", M = "icons-list-layout", N = "gs-iconify-picker", P = "__iconify_collection", et = "https://api.iconify.design", A = /* @__PURE__ */ new Map();
113
- let T;
114
- const ot = ({ collectionId: t }) => `https://cdn.jsdelivr.net/npm/@iconify-json/${t}@latest/icons.json`;
115
- async function R({ collectionId: t, editor: e }) {
138
+ </svg>`, $ = "layout-icon-picker", te = "icons-layout-", G = "icons-list-layout", M = "gs-iconify-picker", A = "__iconify_collection", oe = "https://api.iconify.design", E = /* @__PURE__ */ new Map();
139
+ let L;
140
+ const ne = ({ collectionId: e }) => `https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;
141
+ async function N({ collectionId: e, editor: t }) {
116
142
  try {
117
- if (A.has(t)) return A.get(t);
118
- const o = await fetch(ot({ collectionId: t }));
143
+ if (E.has(e)) return E.get(e);
144
+ const o = await fetch(ne({ collectionId: e }));
119
145
  if (!o.ok) throw new Error(`Failed to fetch collection: ${o.statusText}`);
120
- const s = await o.json();
121
- return A.set(t, s), s;
146
+ const r = await o.json();
147
+ return E.set(e, r), r;
122
148
  } catch (o) {
123
- console.error("Error fetching collection", o), e.runCommand(w.toastAdd, at());
149
+ console.error("Error fetching collection", o), t.runCommand(y.toastAdd, le());
124
150
  return;
125
151
  }
126
152
  }
127
- async function nt({ collectionIds: t, editor: e }) {
153
+ async function se({ collectionIds: e, editor: t }) {
128
154
  try {
129
- if (T) return T;
130
- const o = t ? `?prefixes=${t.join(",")}` : "", s = await fetch(`${et}/collections${o}`);
131
- if (!s.ok) throw new Error(`Failed to fetch collections: ${s.statusText}`);
132
- return T = await s.json(), T;
155
+ if (L) return L;
156
+ const o = e ? `?prefixes=${e.join(",")}` : "", r = await fetch(`${oe}/collections${o}`);
157
+ if (!r.ok) throw new Error(`Failed to fetch collections: ${r.statusText}`);
158
+ return L = await r.json(), L;
133
159
  } catch (o) {
134
- console.error("Error fetching collections", o), e.runCommand(w.toastAdd, j());
160
+ console.error("Error fetching collections", o), t.runCommand(y.toastAdd, j());
135
161
  return;
136
162
  }
137
163
  }
138
- function _() {
164
+ function R() {
139
165
  return {
140
166
  type: "button",
141
167
  label: "Open Icon Picker",
142
168
  name: "onActive",
143
169
  changeProp: !0,
144
- command(t) {
145
- var e;
146
- (e = t.getSelected()) == null || e.trigger("active");
170
+ command(e) {
171
+ var t;
172
+ (t = e.getSelected()) == null || t.trigger("active");
147
173
  }
148
174
  };
149
175
  }
150
- async function st({ collectionIds: t, editor: e, component: o }) {
151
- const s = await nt({ collectionIds: t, editor: e });
152
- if (!s) return;
153
- const a = ({ icon: n, collectionId: r, iconId: g }) => {
154
- o.components(n), o.set({ collectionId: r, iconId: g });
155
- }, p = Object.entries(s).map(([n, r]) => ({ id: n, ...r })).sort((n, r) => n.name.localeCompare(r.name)), l = o.get("collectionId") ?? p[0].id;
156
- e.runCommand(w.layoutToggle, {
157
- id: G,
176
+ async function re({ collectionIds: e, editor: t, component: o }) {
177
+ const r = await se({ collectionIds: e, editor: t });
178
+ if (!r) return;
179
+ const l = ({ icon: n, collectionId: c, iconId: p }) => {
180
+ o.components(n), o.set({ collectionId: c, iconId: p });
181
+ }, g = Object.entries(r).map(([n, c]) => ({ id: n, ...c })).sort((n, c) => n.name.localeCompare(c.name)), a = o.get("collectionId") ?? g[0].id;
182
+ t.runCommand(y.layoutToggle, {
183
+ id: $,
158
184
  placer: { type: "dialog", size: "l", title: "Select Icon" },
159
185
  header: !1,
160
186
  layout: {
161
187
  type: "column",
162
188
  style: { height: 500, gap: 10 },
163
189
  children: [
164
- rt({
165
- collectionsList: p,
166
- collectionId: l,
167
- editor: e,
168
- handleClick: a
190
+ ce({
191
+ collectionsList: g,
192
+ collectionId: a,
193
+ editor: t,
194
+ handleClick: l
169
195
  }),
170
- { id: M, type: "column", grow: !0 }
196
+ { id: G, type: "column", grow: !0 }
171
197
  ]
172
198
  }
173
199
  });
174
- const c = await R({ collectionId: l, editor: e });
175
- c && (U({ editor: e, collection: c }), L({
176
- editor: e,
177
- collection: c,
178
- handleClick: a,
179
- collectionId: l
200
+ const s = await N({ collectionId: a, editor: t });
201
+ s && (U({ editor: t, collection: s }), P({
202
+ editor: t,
203
+ collection: s,
204
+ handleClick: l,
205
+ collectionId: a
180
206
  }));
181
207
  }
182
- function U({ editor: t, collection: e }) {
183
- t.em.set(P, e);
208
+ function U({ editor: e, collection: t }) {
209
+ e.em.set(A, t);
184
210
  }
185
- function it(t) {
186
- return t.em.get(P);
211
+ function ie(e) {
212
+ return e.em.get(A);
187
213
  }
188
- function L(t) {
189
- const { editor: e } = t;
190
- e.runCommand(w.layoutUpdate, {
191
- id: tt,
192
- layout: ct(t),
214
+ function P(e) {
215
+ const { editor: t } = e;
216
+ t.runCommand(y.layoutUpdate, {
217
+ id: te,
218
+ layout: ae(e),
193
219
  header: !1,
194
220
  style: { height: "100%" },
195
- placer: { type: "static", layoutId: M }
221
+ placer: { type: "static", layoutId: G }
196
222
  });
197
223
  }
198
- function rt(t) {
199
- const { collectionsList: e, collectionId: o, editor: s, handleClick: a } = t, p = e.map(({ id: l, name: c, total: n }) => ({ id: l, label: `${c} (${n})` })).sort((l, c) => l.label.localeCompare(c.label));
224
+ function ce(e) {
225
+ const { collectionsList: t, collectionId: o, editor: r, handleClick: l } = e, g = t.map(({ id: a, name: s, total: n }) => ({ id: a, label: `${s} (${n})` })).sort((a, s) => a.label.localeCompare(s.label));
200
226
  return {
201
227
  type: "column",
202
228
  style: { gap: 10 },
203
- className: `${N}__header`,
229
+ className: `${M}__header`,
204
230
  children: [
205
231
  {
206
232
  type: "selectField",
207
233
  value: o,
208
- options: p,
234
+ options: g,
209
235
  emptyState: "Select an icon collection",
210
- onChange: async ({ setState: l, value: c }) => {
211
- const n = await R({ collectionId: c, editor: s });
212
- n && (l({ value: c }), U({ editor: s, collection: n }), L({
213
- editor: s,
236
+ onChange: async ({ setState: a, value: s }) => {
237
+ const n = await N({ collectionId: s, editor: r });
238
+ n && (a({ value: s }), U({ editor: r, collection: n }), P({
239
+ editor: r,
214
240
  collection: n,
215
- handleClick: a,
216
- collectionId: c
241
+ handleClick: l,
242
+ collectionId: s
217
243
  }));
218
244
  }
219
245
  },
@@ -222,54 +248,54 @@ function rt(t) {
222
248
  value: "",
223
249
  placeholder: "Search icons inside collection...",
224
250
  editorEvents: {
225
- [`change:${P}`]: ({ setState: l }) => l({ value: "" })
251
+ [`change:${A}`]: ({ setState: a }) => a({ value: "" })
226
252
  },
227
- onInput: ({ setState: l, value: c, editor: n }) => {
228
- const r = it(n);
229
- if (!r) return;
230
- const g = Object.fromEntries(
231
- Object.entries(r.icons).filter(([i]) => i.includes(c))
253
+ onInput: ({ setState: a, value: s, editor: n }) => {
254
+ const c = ie(n);
255
+ if (!c) return;
256
+ const p = Object.fromEntries(
257
+ Object.entries(c.icons).filter(([i]) => i.includes(s))
232
258
  );
233
- l({ value: c }), L({
259
+ a({ value: s }), P({
234
260
  editor: n,
235
- collection: r,
236
- handleClick: a,
261
+ collection: c,
262
+ handleClick: l,
237
263
  collectionId: o,
238
- collectionFiltered: { ...r, icons: g }
264
+ collectionFiltered: { ...c, icons: p }
239
265
  });
240
266
  }
241
267
  }
242
268
  ]
243
269
  };
244
270
  }
245
- function ct({
246
- collection: t,
247
- collectionFiltered: e,
271
+ function ae({
272
+ collection: e,
273
+ collectionFiltered: t,
248
274
  handleClick: o
249
275
  }) {
250
- const { height: s = 24, width: a = 24, icons: p, prefix: l } = e || t, c = Object.entries(p).map(([n, r]) => ({ name: n, ...r }), {});
276
+ const { height: r = 24, width: l = 24, icons: g, prefix: a } = t || e, s = Object.entries(g).map(([n, c]) => ({ name: n, ...c }), {});
251
277
  return {
252
278
  type: "column",
253
- className: `${N}__content`,
279
+ className: `${M}__content`,
254
280
  style: { height: "100%" },
255
281
  children: {
256
282
  type: "virtualList",
257
- items: c,
283
+ items: s,
258
284
  itemLayout: ({ item: n }) => ({
259
285
  type: "custom",
260
- render: (r) => {
261
- const { editor: g, addEl: i, removeEl: y } = r, u = document.createElementNS("http://www.w3.org/2000/svg", "svg");
286
+ render: (c) => {
287
+ const { editor: p, addEl: i, removeEl: h } = c, u = document.createElementNS("http://www.w3.org/2000/svg", "svg");
262
288
  u.setAttribute("xmlns", "http://www.w3.org/2000/svg"), u.innerHTML = n.body;
263
- const d = n.width || a, I = n.height || s;
289
+ const d = n.width || l, I = n.height || r;
264
290
  u.setAttribute("viewBox", `0 0 ${d} ${I}`), u.style.cssText = "width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";
265
- const h = [
291
+ const b = [
266
292
  [
267
293
  "click",
268
294
  () => {
269
295
  const f = u.cloneNode(!0);
270
296
  f.removeAttribute("style");
271
- const b = f.outerHTML;
272
- o({ icon: b, collectionId: l, iconId: n.name }), g == null || g.runCommand(w.layoutRemove, { id: G });
297
+ const v = f.outerHTML;
298
+ o({ icon: v, collectionId: a, iconId: n.name }), p == null || p.runCommand(y.layoutRemove, { id: $ });
273
299
  }
274
300
  ],
275
301
  [
@@ -285,8 +311,8 @@ function ct({
285
311
  }
286
312
  ]
287
313
  ];
288
- return h.forEach(([f, b]) => u.addEventListener(f, b)), i(u), () => {
289
- h.forEach(([f, b]) => u.removeEventListener(f, b)), y(u);
314
+ return b.forEach(([f, v]) => u.addEventListener(f, v)), i(u), () => {
315
+ b.forEach(([f, v]) => u.removeEventListener(f, v)), h(u);
290
316
  };
291
317
  }
292
318
  })
@@ -298,46 +324,46 @@ function j() {
298
324
  id: "toast-error-getCollections",
299
325
  header: "Error",
300
326
  content: "Error fetching collections",
301
- variant: k.Error
327
+ variant: _.Error
302
328
  };
303
329
  }
304
- function at() {
330
+ function le() {
305
331
  return {
306
332
  ...j(),
307
333
  id: "toast-error-getCollection",
308
334
  content: "Error fetching collection"
309
335
  };
310
336
  }
311
- const lt = function(t, e = {}) {
337
+ const ue = function(e, t = {}) {
312
338
  var u;
313
- const { Components: o, Blocks: s } = t, { collections: a, extendIconComponent: p = !0, licenseKey: l, block: c = {} } = e, n = "icon", r = "iconify", g = "Iconify", i = "data-type-iconify", y = {
339
+ const { Components: o, Blocks: r } = e, { collections: l, extendIconComponent: g = !0, licenseKey: a, block: s = {} } = t, n = "icon", c = "iconify", p = "Iconify", i = "data-type-iconify", h = {
314
340
  events: () => ({
315
341
  dblclick: "onActive"
316
342
  }),
317
343
  onActive() {
318
- st({ collectionIds: a, editor: t, component: this.model });
344
+ re({ collectionIds: l, editor: e, component: this.model });
319
345
  }
320
346
  };
321
- if (o.addType(r, {
322
- block: c && {
323
- label: g,
324
- media: E,
325
- content: { type: r },
347
+ if (o.addType(c, {
348
+ block: s && {
349
+ label: p,
350
+ media: T,
351
+ content: { type: c },
326
352
  category: "Extra",
327
353
  activate: !0,
328
- ...c
354
+ ...s
329
355
  },
330
356
  isComponent: (d) => Z(d, i),
331
357
  model: {
332
358
  defaults: {
333
- name: g,
334
- icon: E,
359
+ name: p,
360
+ icon: T,
335
361
  droppable: !1,
336
362
  attributes: { [i]: !0 },
337
- resizable: S,
338
- components: E,
363
+ resizable: ee,
364
+ components: T,
339
365
  style: { width: "50px", height: "50px" },
340
- traits: [_()]
366
+ traits: [R()]
341
367
  },
342
368
  init() {
343
369
  this.listenTo(this.components(), "change add", this.disableLayers), this.disableLayers();
@@ -346,28 +372,28 @@ const lt = function(t, e = {}) {
346
372
  this.components().forEach((d) => d.set({ layerable: !1, locked: !0 }));
347
373
  }
348
374
  },
349
- view: y
350
- }), p) {
351
- const d = (u = o.getType(n)) == null ? void 0 : u.model, [I, h, ...f] = d.getDefaults().traits;
375
+ view: h
376
+ }), g) {
377
+ const d = (u = o.getType(n)) == null ? void 0 : u.model, [I, b, ...f] = d.getDefaults().traits;
352
378
  o.addType(n, {
353
379
  model: {
354
380
  defaults: {
355
- traits: [I, h, _(), ...f]
381
+ traits: [I, b, R(), ...f]
356
382
  }
357
383
  },
358
- view: y
384
+ view: h
359
385
  });
360
386
  }
361
- J({
362
- editor: t,
363
- licenseKey: l,
364
- plan: Q,
365
- pluginName: m,
387
+ q({
388
+ editor: e,
389
+ licenseKey: a,
390
+ plan: S,
391
+ pluginName: Q,
366
392
  cleanup: () => {
367
- s.remove(r), o.removeType(r);
393
+ r.remove(c), o.removeType(c);
368
394
  }
369
395
  });
370
- }, ut = q(lt);
396
+ }, pe = z(ue);
371
397
  export {
372
- ut as default
398
+ pe as default
373
399
  };