@grapesjs/studio-sdk-plugins 1.0.36 → 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 (91) hide show
  1. package/dist/accordionComponent/index.cjs.js +4 -4
  2. package/dist/accordionComponent/index.es.js +83 -70
  3. package/dist/accordionComponent/index.umd.js +4 -4
  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 +70 -70
  8. package/dist/aiChat/index.es.js +8627 -8161
  9. package/dist/aiChat/index.js +70 -70
  10. package/dist/aiChat/index.umd.js +70 -70
  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 +55 -42
  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 +67 -54
  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 +59 -46
  20. package/dist/canvasEmptyState/index.umd.js +1 -1
  21. package/dist/canvasFullSize/index.cjs.js +4 -4
  22. package/dist/canvasFullSize/index.es.js +59 -46
  23. package/dist/canvasFullSize/index.umd.js +4 -4
  24. package/dist/canvasGridMode/index.cjs.js +2 -2
  25. package/dist/canvasGridMode/index.es.js +70 -57
  26. package/dist/canvasGridMode/index.umd.js +4 -4
  27. package/dist/canvasScreenshot/index.cjs.js +1 -1
  28. package/dist/canvasScreenshot/index.es.js +37 -24
  29. package/dist/canvasScreenshot/index.umd.js +1 -1
  30. package/dist/dataSourceEjs/index.cjs.js +3 -3
  31. package/dist/dataSourceEjs/index.es.js +51 -38
  32. package/dist/dataSourceEjs/index.umd.js +3 -3
  33. package/dist/dataSourceHandlebars/index.cjs.js +2 -2
  34. package/dist/dataSourceHandlebars/index.es.js +50 -37
  35. package/dist/dataSourceHandlebars/index.umd.js +6 -6
  36. package/dist/dialogComponent/index.cjs.js +9 -9
  37. package/dist/dialogComponent/index.es.js +58 -45
  38. package/dist/dialogComponent/index.umd.js +3 -3
  39. package/dist/flexComponent/index.cjs.js +6 -6
  40. package/dist/flexComponent/index.es.js +82 -69
  41. package/dist/flexComponent/index.umd.js +6 -6
  42. package/dist/fsLightboxComponent/index.cjs.js +2 -2
  43. package/dist/fsLightboxComponent/index.es.js +70 -57
  44. package/dist/fsLightboxComponent/index.umd.js +2 -2
  45. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  46. package/dist/googleFontsAssetProvider/index.es.js +84 -71
  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 +82 -69
  50. package/dist/iconifyComponent/index.umd.js +2 -2
  51. package/dist/index.cjs.js +36 -36
  52. package/dist/index.es.js +843 -830
  53. package/dist/index.umd.js +36 -36
  54. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  55. package/dist/layoutSidebarButtons/index.es.js +81 -68
  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 +86 -73
  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 +70 -57
  62. package/dist/linkImageComponent/index.umd.js +2 -2
  63. package/dist/listPagesComponent/index.cjs.js +3 -3
  64. package/dist/listPagesComponent/index.es.js +49 -36
  65. package/dist/listPagesComponent/index.umd.js +3 -3
  66. package/dist/presetPrintable/index.cjs.js +3 -3
  67. package/dist/presetPrintable/index.es.js +130 -117
  68. package/dist/presetPrintable/index.umd.js +3 -3
  69. package/dist/prosemirror/index.cjs.js +1 -1
  70. package/dist/prosemirror/index.es.js +96 -83
  71. package/dist/prosemirror/index.umd.js +1 -1
  72. package/dist/rendererReact/index.cjs.js +1 -1
  73. package/dist/rendererReact/index.es.js +143 -131
  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 +74 -61
  78. package/dist/rteTinyMce/index.umd.js +2 -2
  79. package/dist/shapeDividerComponent/index.cjs.js +3 -3
  80. package/dist/shapeDividerComponent/index.es.js +33 -20
  81. package/dist/shapeDividerComponent/index.umd.js +3 -3
  82. package/dist/swiperComponent/index.cjs.js +5 -5
  83. package/dist/swiperComponent/index.es.js +105 -92
  84. package/dist/swiperComponent/index.umd.js +5 -5
  85. package/dist/tableComponent/index.cjs.js +1 -1
  86. package/dist/tableComponent/index.es.js +163 -150
  87. package/dist/tableComponent/index.umd.js +1 -1
  88. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  89. package/dist/youtubeAssetProvider/index.es.js +36 -23
  90. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  91. package/package.json +2 -2
@@ -1,17 +1,17 @@
1
1
  function ce(e, t, o) {
2
- let l, s, n, c, a;
2
+ let l, n, s, c, a;
3
3
  const r = t;
4
4
  function h() {
5
5
  const d = Date.now() - c;
6
- d < r && d >= 0 ? l = setTimeout(h, r - d) : (l = null, a = e.apply(n, s), n = s = null);
6
+ d < r && d >= 0 ? l = setTimeout(h, r - d) : (l = null, a = e.apply(s, n), s = n = null);
7
7
  }
8
8
  const v = function() {
9
- return n = this, s = arguments, c = Date.now(), l || (l = setTimeout(h, r)), a;
9
+ return s = this, n = arguments, c = Date.now(), l || (l = setTimeout(h, r)), a;
10
10
  };
11
11
  return v.clear = function() {
12
12
  l && (clearTimeout(l), l = null);
13
13
  }, v.flush = function() {
14
- l && (a = e.apply(n, s), n = s = null, clearTimeout(l), l = null);
14
+ l && (a = e.apply(s, n), s = n = null, clearTimeout(l), l = null);
15
15
  }, v;
16
16
  }
17
17
  const F = "app.grapesjs.com", U = "app-stage.grapesjs.com", ie = "app2.grapesjs.com", he = "app-stage2.grapesjs.com", S = [
@@ -25,26 +25,39 @@ const F = "app.grapesjs.com", U = "app-stage.grapesjs.com", ie = "app2.grapesjs.
25
25
  // For stackblitz.com demos
26
26
  ".local.webcontainer.io",
27
27
  // For stackblitz.com demos
28
- "-sandpack.codesandbox.io"
28
+ "-sandpack.codesandbox.io",
29
29
  // For Sandpack demos
30
+ ".claudemcpcontent.com",
31
+ // For Claude mcp app
32
+ ".web-sandbox.oaiusercontent.com"
33
+ // For OpenAI mcp app
30
34
  ], de = "license:check:end", ve = () => typeof window < "u", ue = ({
31
35
  isDev: e,
32
36
  isStage: t,
33
37
  isPlatform: o
34
38
  }) => `${e ? "" : `https://${t ? U : F}`}/${o ? "platform-api" : "api"}`, ge = () => {
35
- const e = ve() && window.location.hostname;
39
+ if (!ve()) return "";
40
+ const { hostname: e } = window.location;
41
+ if (e) return e;
42
+ try {
43
+ return window.parent.location.hostname || "";
44
+ } catch {
45
+ return "";
46
+ }
47
+ }, be = () => {
48
+ const e = ge();
36
49
  return !!e && (S.includes(e) || S.some((t) => e.endsWith(t)));
37
50
  };
38
51
  function $(e) {
39
52
  return typeof e == "function";
40
53
  }
41
- async function be({
54
+ async function pe({
42
55
  path: e,
43
56
  baseApiUrl: t,
44
57
  method: o = "GET",
45
58
  headers: l = {},
46
- params: s,
47
- body: n
59
+ params: n,
60
+ body: s
48
61
  }) {
49
62
  const a = `${t || ue({ isDev: !1, isStage: !1 })}${e}`, r = {
50
63
  method: o,
@@ -53,8 +66,8 @@ async function be({
53
66
  ...l
54
67
  }
55
68
  };
56
- n && (r.body = JSON.stringify(n));
57
- const h = s ? new URLSearchParams(s).toString() : "", v = h ? `?${h}` : "", d = await fetch(`${a}${v}`, r);
69
+ s && (r.body = JSON.stringify(s));
70
+ const h = n ? new URLSearchParams(n).toString() : "", v = h ? `?${h}` : "", d = await fetch(`${a}${v}`, r);
58
71
  if (!d.ok)
59
72
  throw new Error(`HTTP error! status: ${d.status}`);
60
73
  return d.json();
@@ -66,22 +79,22 @@ const E = {
66
79
  [C.business]: 20,
67
80
  [C.enterprise]: 30
68
81
  };
69
- function pe(e) {
82
+ function fe(e) {
70
83
  const t = e;
71
84
  return t.init = (o) => (l) => e(l, o), t;
72
85
  }
73
- const fe = (e) => /* @__PURE__ */ pe(e);
74
- async function me({
86
+ const me = (e) => /* @__PURE__ */ fe(e);
87
+ async function we({
75
88
  editor: e,
76
89
  plan: t,
77
90
  pluginName: o,
78
91
  licenseKey: l,
79
- onLicenseCheckResponse: s,
80
- cleanup: n
92
+ onLicenseCheckResponse: n,
93
+ cleanup: s
81
94
  }) {
82
95
  let c = "", a;
83
96
  const r = (d) => {
84
- console.warn("Cleanup plugin:", o, "Reason:", d), n();
97
+ console.warn("Cleanup plugin:", o, "Reason:", d), s();
85
98
  }, h = (d = {}) => {
86
99
  var y;
87
100
  const { error: p, sdkLicense: V } = d, m = (y = d.plan) == null ? void 0 : y.category;
@@ -94,13 +107,13 @@ async function me({
94
107
  };
95
108
  e.Commands.has(x.settings) && (a = e.runCommand(x.settings), c = (a == null ? void 0 : a.baseUrl) || "");
96
109
  const v = (d) => {
97
- s == null || s(d), d && h(d);
110
+ n == null || n(d), d && h(d);
98
111
  };
99
112
  if (!a) {
100
113
  e.onReady(async () => {
101
- if (!ge())
114
+ if (!be())
102
115
  if (l) {
103
- const d = await ye({ licenseKey: l, pluginName: o, baseApiUrl: c });
116
+ const d = await Ce({ licenseKey: l, pluginName: o, baseApiUrl: c });
104
117
  v(d);
105
118
  } else
106
119
  r("The `licenseKey` option not provided");
@@ -108,22 +121,22 @@ async function me({
108
121
  return;
109
122
  }
110
123
  if (a.licensePlan || a.licenseError) {
111
- const d = we(a);
124
+ const d = ye(a);
112
125
  v(d);
113
126
  return;
114
127
  }
115
128
  e.on(de, (d) => v(d));
116
129
  }
117
- const we = (e) => ({
130
+ const ye = (e) => ({
118
131
  sdkLicense: e.license,
119
132
  license: e.license,
120
133
  error: e.licenseError,
121
134
  plan: e.licensePlan
122
135
  });
123
- async function ye(e) {
136
+ async function Ce(e) {
124
137
  const { licenseKey: t, pluginName: o, baseApiUrl: l } = e;
125
138
  try {
126
- return (await be({
139
+ return (await pe({
127
140
  baseApiUrl: l,
128
141
  path: `/sdk/${t || "na"}`,
129
142
  method: "POST",
@@ -132,11 +145,11 @@ async function ye(e) {
132
145
  pn: o
133
146
  }
134
147
  })).result || {};
135
- } catch (s) {
136
- return console.error("Error during SDK license check:", s), !1;
148
+ } catch (n) {
149
+ return console.error("Error during SDK license check:", n), !1;
137
150
  }
138
151
  }
139
- const Ce = "tableComponent", He = C.startup;
152
+ const He = "tableComponent", Re = C.startup;
140
153
  var i = /* @__PURE__ */ ((e) => (e.table = "table", e.tableSettings = "tableSettings", e.tableDelete = "tableDelete", e.tableHead = "tableHead", e.tableFoot = "tableFoot", e.tableCellItems = "tableCellItems", e.tableCellProperties = "tableCellProperties", e.tableCellMerge = "tableCellMerge", e.tableCellSplit = "tableCellSplit", e.tableRowItems = "tableRowItems", e.tableRowInsertBefore = "tableRowInsertBefore", e.tableRowInsertAfter = "tableRowInsertAfter", e.tableRowDelete = "tableRowDelete", e.tableRowProperties = "tableRowProperties", e.tableRowCut = "tableRowCut", e.tableRowCopy = "tableRowCopy", e.tableRowPasteBefore = "tableRowPasteBefore", e.tableRowPasteAfter = "tableRowPasteAfter", e.tableColumn = "tableColumn", e.tableColumnItems = "tableColumnItems", e.tableColumnInsertBefore = "tableColumnInsertBefore", e.tableColumnInsertAfter = "tableColumnInsertAfter", e.tableColumnDelete = "tableColumnDelete", e.tableColumnCut = "tableColumnCut", e.tableColumnCopy = "tableColumnCopy", e.tableColumnPasteBefore = "tableColumnPasteBefore", e.tableColumnPasteAfter = "tableColumnPasteAfter", e))(i || {});
141
154
  const u = {
142
155
  table: '<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',
@@ -166,8 +179,8 @@ const u = {
166
179
  tableColumnCopy: '<svg viewBox="0 0 24 24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',
167
180
  tableColumnPasteBefore: '<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v2H4V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm-2 7v12H4V8h6zM8.5 9.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',
168
181
  tableColumnPasteAfter: '<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm8 7v12h-6V8h6zm-1.5 1.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>'
169
- }, f = "table", W = "thead", _ = "tfoot", M = "tbody", b = "row", g = "cell", D = "clipboardTable", Re = [f, W, _, M, b, g], B = (e) => e.em.get(D) || [], Pe = (e) => e.every((t) => t.is(g)), T = (e, t) => {
170
- const { editor: o, event: l, opts: s } = e, n = l.currentTarget || l.target, { x: c, y: a, width: r, height: h } = n.getBoundingClientRect(), v = {
182
+ }, f = "table", W = "thead", _ = "tfoot", M = "tbody", b = "row", g = "cell", D = "clipboardTable", Pe = [f, W, _, M, b, g], B = (e) => e.em.get(D) || [], Ve = (e) => e.every((t) => t.is(g)), T = (e, t) => {
183
+ const { editor: o, event: l, opts: n } = e, s = l.currentTarget || l.target, { x: c, y: a, width: r, height: h } = s.getBoundingClientRect(), v = {
171
184
  style: { width: 240, height: 300 },
172
185
  placer: { type: "popover", closeOnClickAway: !0, x: c, y: a, w: r, h },
173
186
  layout: {
@@ -188,27 +201,27 @@ const u = {
188
201
  },
189
202
  ...t
190
203
  };
191
- $(s.openSettings) ? s.openSettings({ ...e, layoutProps: v }) : o.runCommand(x.layoutToggle, v);
192
- }, Ve = (e, {
204
+ $(n.openSettings) ? n.openSettings({ ...e, layoutProps: v }) : o.runCommand(x.layoutToggle, v);
205
+ }, ze = (e, {
193
206
  rows: t = 1,
194
207
  cells: o = 5,
195
208
  text: l
196
209
  } = {}) => ({
197
210
  type: e,
198
- components: Array.from(Array(t).keys()).map((s) => ({
211
+ components: Array.from(Array(t).keys()).map((n) => ({
199
212
  type: b,
200
- components: Array.from(Array(o).keys()).map((n) => ({
213
+ components: Array.from(Array(o).keys()).map((s) => ({
201
214
  type: g,
202
- components: l ? { type: "text", content: $(l) ? l({ y: s, x: n }) : l } : void 0
215
+ components: l ? { type: "text", content: $(l) ? l({ y: n, x: s }) : l } : void 0
203
216
  }))
204
217
  }))
205
218
  }), j = "Table settings", K = (e) => {
206
219
  const { component: t } = e;
207
220
  return t.is(f) ? t : t.closestType(f);
208
- }, ze = (e) => {
221
+ }, Ae = (e) => {
209
222
  var t;
210
223
  (t = K(e)) == null || t.remove(e.opts);
211
- }, Ae = (e) => {
224
+ }, xe = (e) => {
212
225
  const t = K(e);
213
226
  t && (e.editor.select(t), T(e, {
214
227
  id: "tableSettings",
@@ -223,7 +236,7 @@ const u = {
223
236
  id: i.tableSettings,
224
237
  label: j,
225
238
  icon: u[i.tableSettings],
226
- onClick: ({ event: o }) => Ae({
239
+ onClick: ({ event: o }) => xe({
227
240
  ...e,
228
241
  // @ts-expect-error workaround for the build
229
242
  event: o
@@ -233,41 +246,41 @@ const u = {
233
246
  id: i.tableDelete,
234
247
  label: "Delete table",
235
248
  icon: u[i.tableDelete],
236
- onClick: () => ze(e)
249
+ onClick: () => Ae(e)
237
250
  }
238
251
  ]
239
252
  }], X = ({ editor: e }) => {
240
253
  const t = B(e);
241
- return t.length && Pe(t);
254
+ return t.length && Ve(t);
242
255
  }, G = ({ component: e, editor: t, after: o }) => {
243
256
  if (!e.is(g)) return;
244
- const l = e.closestType(f), s = e.closestType(b), n = e.index() + (o ? 1 : 0);
245
- l == null || l.findType(b).forEach((a) => a.append({ type: g }, { at: n }));
246
- const c = s == null ? void 0 : s.components().at(n);
257
+ const l = e.closestType(f), n = e.closestType(b), s = e.index() + (o ? 1 : 0);
258
+ l == null || l.findType(b).forEach((a) => a.append({ type: g }, { at: s }));
259
+ const c = n == null ? void 0 : n.components().at(s);
247
260
  c && t.select(c);
248
261
  }, Y = ({ component: e, opts: t }) => {
249
262
  if (!e.is(g)) return;
250
263
  const o = e.closestType(f), l = e.index();
251
- o == null || o.findType(b).forEach((s) => {
252
- var n;
253
- return (n = s.components().at(l)) == null ? void 0 : n.remove(t);
264
+ o == null || o.findType(b).forEach((n) => {
265
+ var s;
266
+ return (s = n.components().at(l)) == null ? void 0 : s.remove(t);
254
267
  });
255
268
  }, J = ({ component: e, editor: t }) => {
256
269
  if (!e.is(g)) return;
257
- const o = e.closestType(f), l = e.index(), s = (o == null ? void 0 : o.findType(b).map((n) => n.components().at(l))) || [];
258
- s.length && t.em.set(D, s);
270
+ const o = e.closestType(f), l = e.index(), n = (o == null ? void 0 : o.findType(b).map((s) => s.components().at(l))) || [];
271
+ n.length && t.em.set(D, n);
259
272
  }, N = (e) => {
260
273
  const { component: t, editor: o, after: l } = e;
261
274
  if (!t.is(g) || !X(e)) return;
262
- const s = B(o), n = t.closestType(f), c = t.index() + (l ? 1 : 0);
263
- n == null || n.findType(b).forEach((a, r) => {
264
- const h = s[r], v = (h == null ? void 0 : h.clone()) || { type: g };
275
+ const n = B(o), s = t.closestType(f), c = t.index() + (l ? 1 : 0);
276
+ s == null || s.findType(b).forEach((a, r) => {
277
+ const h = n[r], v = (h == null ? void 0 : h.clone()) || { type: g };
265
278
  a.append(v, { at: c });
266
279
  });
267
- }, xe = (e) => {
280
+ }, Be = (e) => {
268
281
  const { component: t } = e;
269
282
  t.is(g) && (J(e), Y({ ...e, opts: { temporary: !0 } }));
270
- }, Be = (e) => {
283
+ }, Ie = (e) => {
271
284
  const t = X(e);
272
285
  return [{
273
286
  id: i.tableColumnItems,
@@ -296,7 +309,7 @@ const u = {
296
309
  id: i.tableColumnCut,
297
310
  label: "Cut column",
298
311
  icon: u[i.tableColumnCut],
299
- onClick: () => xe(e)
312
+ onClick: () => Be(e)
300
313
  },
301
314
  {
302
315
  id: i.tableColumnCopy,
@@ -320,16 +333,16 @@ const u = {
320
333
  }
321
334
  ]
322
335
  }];
323
- }, Q = "Row settings", Ie = (e) => e.every((t) => t.is(b)), P = (e) => {
336
+ }, Q = "Row settings", Me = (e) => e.every((t) => t.is(b)), P = (e) => {
324
337
  const { component: t } = e, o = t.is(g), l = t.is(b);
325
338
  if (!(!o && !l))
326
339
  return l ? t : t.closestType(b);
327
340
  }, Z = (e) => {
328
- const { component: t, editor: o, after: l } = e, s = P(e);
329
- if (!s) return;
330
- const n = s.index() + (l ? 1 : 0), c = s.components().length, a = Array.from(Array(c).keys()).map(() => ({ type: g })), r = s.parent();
341
+ const { component: t, editor: o, after: l } = e, n = P(e);
342
+ if (!n) return;
343
+ const s = n.index() + (l ? 1 : 0), c = n.components().length, a = Array.from(Array(c).keys()).map(() => ({ type: g })), r = n.parent();
331
344
  if (r) {
332
- const h = r.append({ type: b, components: a }, { at: n })[0];
345
+ const h = r.append({ type: b, components: a }, { at: s })[0];
333
346
  if (t.is(g) && h) {
334
347
  const v = t.index(), d = h.components().at(v);
335
348
  d && o.select(d);
@@ -345,14 +358,14 @@ const u = {
345
358
  var a;
346
359
  const { editor: t, after: o } = e, l = P(e);
347
360
  if (!l || !le(e)) return;
348
- const n = B(t)[0], c = l.index() + (o ? 1 : 0);
349
- n && ((a = l.parent()) == null || a.append(n.clone(), { at: c }));
350
- }, Me = (e) => {
361
+ const s = B(t)[0], c = l.index() + (o ? 1 : 0);
362
+ s && ((a = l.parent()) == null || a.append(s.clone(), { at: c }));
363
+ }, ke = (e) => {
351
364
  P(e) && (te(e), ee({ ...e, opts: { temporary: !0 } }));
352
365
  }, le = ({ editor: e }) => {
353
366
  const t = B(e);
354
- return t.length && Ie(t);
355
- }, ke = (e) => {
367
+ return t.length && Me(t);
368
+ }, De = (e) => {
356
369
  const t = P(e);
357
370
  t && (e.editor.select(t), T(e, {
358
371
  id: "tableRowSettings",
@@ -387,7 +400,7 @@ const u = {
387
400
  id: i.tableRowProperties,
388
401
  label: Q,
389
402
  icon: u[i.tableRowProperties],
390
- onClick: ({ event: l }) => ke({
403
+ onClick: ({ event: l }) => De({
391
404
  ...e,
392
405
  // @ts-expect-error workaround for the build
393
406
  event: l
@@ -397,7 +410,7 @@ const u = {
397
410
  id: i.tableRowCut,
398
411
  label: "Cut row",
399
412
  icon: u[i.tableRowCut],
400
- onClick: () => Me(e)
413
+ onClick: () => ke(e)
401
414
  },
402
415
  {
403
416
  id: i.tableRowCopy,
@@ -425,20 +438,20 @@ const u = {
425
438
  const t = e.attributes.attributes || {}, o = parseInt(`${t.rowspan || 1}`, 10), l = parseInt(`${t.colspan || 1}`, 10);
426
439
  return { rowspan: o, colspan: l };
427
440
  };
428
- function se(e) {
441
+ function ne(e) {
429
442
  const t = [];
430
443
  return e.components().forEach((o, l) => {
431
- o.components().each((s, n) => {
432
- const { rowspan: c, colspan: a } = L(s);
444
+ o.components().each((n, s) => {
445
+ const { rowspan: c, colspan: a } = L(n);
433
446
  if (t[l])
434
- for (; t[l][n]; )
435
- n++;
447
+ for (; t[l][s]; )
448
+ s++;
436
449
  for (let r = l; r < l + c; r++) {
437
450
  t[r] || (t[r] = []);
438
- for (let h = n; h < n + a; h++)
451
+ for (let h = s; h < s + a; h++)
439
452
  t[r][h] = {
440
- real: r === l && h === n,
441
- cell: s,
453
+ real: r === l && h === s,
454
+ cell: n,
442
455
  rowspan: c,
443
456
  colspan: a
444
457
  };
@@ -451,15 +464,15 @@ function H(e, t, o) {
451
464
  return (l = e[o]) == null ? void 0 : l[t];
452
465
  }
453
466
  const k = (e) => e.closestType(b);
454
- function De(e, { x: t, y: o, rows: l, cols: s }) {
467
+ function Te(e, { x: t, y: o, rows: l, cols: n }) {
455
468
  var a;
456
- let n = k(e[o][t].cell), c;
469
+ let s = k(e[o][t].cell), c;
457
470
  for (let r = 1; r <= l; r++)
458
- if (n = (a = n == null ? void 0 : n.parent()) == null ? void 0 : a.components().at(n.index() + 1), n) {
471
+ if (s = (a = s == null ? void 0 : s.parent()) == null ? void 0 : a.components().at(s.index() + 1), s) {
459
472
  for (c = t; c >= 0; c--) {
460
473
  const { cell: h } = e[o + r][c], v = k(h);
461
- if (v === n) {
462
- for (let d = 1; d <= s; d++) {
474
+ if (v === s) {
475
+ for (let d = 1; d <= n; d++) {
463
476
  const p = h.index();
464
477
  v.append({ type: g }, { at: p + 1 });
465
478
  }
@@ -467,30 +480,30 @@ function De(e, { x: t, y: o, rows: l, cols: s }) {
467
480
  }
468
481
  }
469
482
  if (c === -1) {
470
- const v = n.components().at(0).index();
471
- for (let d = 1; d <= s; d++)
472
- n.append({ type: g }, { at: v });
483
+ const v = s.components().at(0).index();
484
+ for (let d = 1; d <= n; d++)
485
+ s.append({ type: g }, { at: v });
473
486
  }
474
487
  }
475
488
  }
476
- function ne(e) {
489
+ function se(e) {
477
490
  for (let t = 0; t < e.length; t++)
478
491
  for (let o = 0; o < e[t].length; o++) {
479
- const s = e[t][o].cell;
480
- if (s.em.selected.hasComponent(s)) {
481
- const { rowspan: n, colspan: c } = L(s);
482
- if (c > 1 || n > 1) {
483
- s.addAttributes({ colspan: 1, rowspan: 1 });
492
+ const n = e[t][o].cell;
493
+ if (n.em.selected.hasComponent(n)) {
494
+ const { rowspan: s, colspan: c } = L(n);
495
+ if (c > 1 || s > 1) {
496
+ n.addAttributes({ colspan: 1, rowspan: 1 });
484
497
  for (let a = 0; a < c - 1; a++) {
485
- const r = s.index();
486
- k(s).append({ type: g }, { at: r + 1 });
498
+ const r = n.index();
499
+ k(n).append({ type: g }, { at: r + 1 });
487
500
  }
488
- De(e, { x: o, y: t, rows: n - 1, cols: c });
501
+ Te(e, { x: o, y: t, rows: s - 1, cols: c });
489
502
  }
490
503
  }
491
504
  }
492
505
  }
493
- function Te(e) {
506
+ function Le(e) {
494
507
  const t = [];
495
508
  e.components().forEach((o) => {
496
509
  o.components().length || t.push(o);
@@ -498,84 +511,84 @@ function Te(e) {
498
511
  }
499
512
  const I = (e, t = {}) => {
500
513
  var c;
501
- const o = se(e), { em: l } = e;
502
- let s, n;
514
+ const o = ne(e), { em: l } = e;
515
+ let n, s;
503
516
  for (let a = 0; a < o.length; a++)
504
517
  for (let r = 0; r < o[a].length; r++) {
505
518
  const h = o[a][r];
506
519
  if ((c = t.selected) != null && c.includes(h.cell) || l.selected.hasComponent(h.cell)) {
507
520
  const v = { x: r, y: a };
508
- s || (s = v), n = v;
521
+ n || (n = v), s = v;
509
522
  }
510
523
  }
511
524
  return {
512
525
  grid: o,
513
- startPos: s,
514
- endPos: n
526
+ startPos: n,
527
+ endPos: s
515
528
  };
516
529
  };
517
- function Le(e, t = {}) {
518
- const o = I(e), { startPos: l, endPos: s } = o;
519
- let { grid: n } = o;
530
+ function Se(e, t = {}) {
531
+ const o = I(e), { startPos: l, endPos: n } = o;
532
+ let { grid: s } = o;
520
533
  const { em: c } = e;
521
- if (!l || !s)
534
+ if (!l || !n)
522
535
  return;
523
- const a = l.x, r = l.y, h = s.x, v = s.y, d = H(n, a, r), p = H(n, h, v);
536
+ const a = l.x, r = l.y, h = n.x, v = n.y, d = H(s, a, r), p = H(s, h, v);
524
537
  if (d && p) {
525
- ne(n), n = se(e);
526
- const V = [], m = H(n, a, r).cell;
538
+ se(s), s = ne(e);
539
+ const V = [], m = H(s, a, r).cell;
527
540
  m.addAttributes({
528
541
  colspan: h - a + 1,
529
542
  rowspan: v - r + 1
530
543
  });
531
544
  for (let w = r; w <= v; w++)
532
545
  for (let y = a; y <= h; y++) {
533
- const z = H(n, y, w);
546
+ const z = H(s, y, w);
534
547
  if (!z) continue;
535
548
  const { cell: A } = z;
536
549
  A !== m && V.push(A);
537
550
  }
538
551
  V.forEach((w) => {
539
552
  t.mergeContent && m.append(w.components().models), w.remove();
540
- }), c.setSelected(m), Te(e);
553
+ }), c.setSelected(m), Le(e);
541
554
  }
542
555
  }
543
- const ae = "Cell settings", Se = "Merge cells", Ee = "Split cell", Ge = (e) => e.closestType(b), R = (e) => {
556
+ const ae = "Cell settings", Ee = "Merge cells", Ge = "Split cell", Ne = (e) => e.closestType(b), R = (e) => {
544
557
  var t;
545
- return (t = Ge(e)) == null ? void 0 : t.parent();
546
- }, Ne = (e) => {
558
+ return (t = Ne(e)) == null ? void 0 : t.parent();
559
+ }, Ze = (e) => {
547
560
  const t = e.editor.getSelectedAll(), o = R(t[0]), l = t[0];
548
561
  if (!o || !(l != null && l.is(g)) || t.length > 1)
549
562
  return !1;
550
- const { rowspan: s, colspan: n } = L(l);
551
- return !(n < 2 && s < 2);
552
- }, Ze = (e) => {
553
- const o = e.editor.getSelectedAll()[0], l = R(o), { grid: s } = I(l);
554
- ne(s);
563
+ const { rowspan: n, colspan: s } = L(l);
564
+ return !(s < 2 && n < 2);
565
+ }, Oe = (e) => {
566
+ const o = e.editor.getSelectedAll()[0], l = R(o), { grid: n } = I(l);
567
+ se(n);
555
568
  }, re = (e) => {
556
569
  const t = e.editor.getSelectedAll(), o = R(t[0]);
557
570
  if (!o || t.length < 2 || t.some((a) => !a.is(g) || R(a) !== o))
558
571
  return !1;
559
- const { grid: l, startPos: s, endPos: n } = I(o), { em: c } = o;
560
- if (!s || !n) return !1;
561
- for (let a = s.y; a <= n.y; a++)
562
- for (let r = s.x; r <= n.x; r++) {
572
+ const { grid: l, startPos: n, endPos: s } = I(o), { em: c } = o;
573
+ if (!n || !s) return !1;
574
+ for (let a = n.y; a <= s.y; a++)
575
+ for (let r = n.x; r <= s.x; r++) {
563
576
  const h = H(l, r, a);
564
577
  if (!h || !c.selected.hasComponent(h.cell))
565
578
  return !1;
566
579
  }
567
580
  return !0;
568
- }, Oe = (e) => {
581
+ }, Fe = (e) => {
569
582
  const { editor: t } = e;
570
583
  if (!re(e)) return;
571
584
  const o = t.getSelectedAll(), l = R(o[0]);
572
- Le(l, { mergeContent: !0 });
573
- }, Fe = (e) => {
585
+ Se(l, { mergeContent: !0 });
586
+ }, Ue = (e) => {
574
587
  T(e, {
575
588
  id: "tableCellSettings",
576
589
  header: { label: ae }
577
590
  });
578
- }, Ue = (e) => [{
591
+ }, $e = (e) => [{
579
592
  id: i.tableCellItems,
580
593
  icon: u[i.tableCellProperties],
581
594
  label: "Cell",
@@ -584,7 +597,7 @@ const ae = "Cell settings", Se = "Merge cells", Ee = "Split cell", Ge = (e) => e
584
597
  id: i.tableCellProperties,
585
598
  label: ae,
586
599
  icon: u[i.tableCellProperties],
587
- onClick: ({ event: o }) => Fe({
600
+ onClick: ({ event: o }) => Ue({
588
601
  ...e,
589
602
  // @ts-expect-error workaround for the build
590
603
  event: o
@@ -592,39 +605,39 @@ const ae = "Cell settings", Se = "Merge cells", Ee = "Split cell", Ge = (e) => e
592
605
  },
593
606
  {
594
607
  id: i.tableCellMerge,
595
- label: Se,
608
+ label: Ee,
596
609
  icon: u[i.tableCellMerge],
597
- onClick: () => Oe(e),
610
+ onClick: () => Fe(e),
598
611
  disabled: !re(e)
599
612
  },
600
613
  {
601
614
  id: i.tableCellSplit,
602
- label: Ee,
615
+ label: Ge,
603
616
  icon: u[i.tableCellSplit],
604
- onClick: () => Ze(e),
605
- disabled: !Ne(e)
617
+ onClick: () => Oe(e),
618
+ disabled: !Ze(e)
606
619
  }
607
620
  ]
608
- }, ...Be(e), ...oe(e)], $e = (e) => {
621
+ }, ...Ie(e), ...oe(e)], We = (e) => {
609
622
  const t = e[0] && R(e[0]);
610
623
  if (!t) return;
611
- const { grid: o, startPos: l, endPos: s } = I(t, { selected: e });
612
- if (!l || !s) return;
613
- const n = [];
614
- for (let c = l.y; c <= s.y; c++)
615
- for (let a = l.x; a <= s.x; a++) {
624
+ const { grid: o, startPos: l, endPos: n } = I(t, { selected: e });
625
+ if (!l || !n) return;
626
+ const s = [];
627
+ for (let c = l.y; c <= n.y; c++)
628
+ for (let a = l.x; a <= n.x; a++) {
616
629
  const r = H(o, a, c);
617
- r && n.push(r.cell);
630
+ r && s.push(r.cell);
618
631
  }
619
- n.length && t.em.setSelected(n, {
632
+ s.length && t.em.setSelected(s, {
620
633
  // @ts-expect-error custom option
621
634
  fromCell: !0
622
635
  });
623
- }, We = function(e, t = {}) {
636
+ }, _e = function(e, t = {}) {
624
637
  const o = {
625
638
  block: {},
626
639
  ...t
627
- }, { Components: l } = e, s = {
640
+ }, { Components: l } = e, n = {
628
641
  copyable: !1,
629
642
  emptyState: !0,
630
643
  highlightable: !1,
@@ -705,7 +718,7 @@ const ae = "Cell settings", Se = "Merge cells", Ee = "Split cell", Ge = (e) => e
705
718
  }
706
719
  }
707
720
  ],
708
- components: Ve(M, { rows: 5 }),
721
+ components: ze(M, { rows: 5 }),
709
722
  contextMenu: ({ items: c, editor: a, component: r }) => [
710
723
  ...q({ editor: a, component: r, opts: o }),
711
724
  ...c
@@ -716,21 +729,21 @@ const ae = "Cell settings", Se = "Merge cells", Ee = "Split cell", Ge = (e) => e
716
729
  model: {
717
730
  defaults: {
718
731
  icon: u.tableHead,
719
- ...s
732
+ ...n
720
733
  }
721
734
  }
722
735
  }), l.addType(_, {
723
736
  model: {
724
737
  defaults: {
725
738
  icon: u.tableFoot,
726
- ...s
739
+ ...n
727
740
  }
728
741
  }
729
742
  }), l.addType(M, {
730
743
  model: {
731
744
  defaults: {
732
745
  icon: u.tableRowProperties,
733
- ...s
746
+ ...n
734
747
  }
735
748
  }
736
749
  }), l.addType(b, {
@@ -793,29 +806,29 @@ const ae = "Cell settings", Se = "Merge cells", Ee = "Split cell", Ge = (e) => e
793
806
  }
794
807
  ],
795
808
  contextMenu: ({ items: c, editor: a, component: r }) => [
796
- ...Ue({ editor: a, component: r, opts: o }),
809
+ ...$e({ editor: a, component: r, opts: o }),
797
810
  ...c
798
811
  ]
799
812
  }
800
813
  }
801
814
  });
802
- const n = ce((c, a) => {
815
+ const s = ce((c, a) => {
803
816
  var d;
804
817
  const r = e.getSelectedAll(), h = !!((d = a == null ? void 0 : a.event) != null && d.shiftKey);
805
818
  if (r.length < 2 || !h || a.fromCell) return;
806
819
  const v = r.map((p) => p.is(g) ? p : p.closestType(g)).filter(Boolean);
807
- v.length === r.length && $e(v);
820
+ v.length === r.length && We(v);
808
821
  }, 0);
809
- e.on("component:select", n), me({
822
+ e.on("component:select", s), we({
810
823
  editor: e,
811
- plan: He,
812
- pluginName: Ce,
824
+ plan: Re,
825
+ pluginName: He,
813
826
  licenseKey: o.licenseKey,
814
827
  cleanup: () => {
815
- e.off("component:select", n), e.Blocks.remove(f), Re.forEach((c) => l.removeType(c));
828
+ e.off("component:select", s), e.Blocks.remove(f), Pe.forEach((c) => l.removeType(c));
816
829
  }
817
830
  });
818
- }, _e = fe(We);
831
+ }, je = me(_e);
819
832
  export {
820
- _e as default
833
+ je as default
821
834
  };