@progress/kendo-react-editor 9.4.0-develop.2 → 9.4.0-develop.21

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 (97) hide show
  1. package/Editor.js +1 -1
  2. package/Editor.mjs +0 -1
  3. package/NOTICE.txt +40 -51
  4. package/config/defaultStyles.js +1 -1
  5. package/config/defaultStyles.mjs +0 -1
  6. package/config/shortcuts.js +1 -1
  7. package/config/shortcuts.mjs +8 -9
  8. package/config/toolsSettings.js +1 -1
  9. package/config/toolsSettings.mjs +0 -1
  10. package/dialogs/FindReplace.js +1 -1
  11. package/dialogs/FindReplace.mjs +0 -1
  12. package/dialogs/index.js +1 -1
  13. package/dialogs/index.mjs +0 -1
  14. package/dialogs/insertImage.js +1 -1
  15. package/dialogs/insertImage.mjs +0 -1
  16. package/dialogs/insertLink.js +1 -1
  17. package/dialogs/insertLink.mjs +10 -11
  18. package/dialogs/viewHtml.js +1 -1
  19. package/dialogs/viewHtml.mjs +5 -6
  20. package/dist/cdn/js/kendo-react-editor.js +8 -1
  21. package/index.js +2 -1
  22. package/index.mjs +7 -7
  23. package/messages/index.js +1 -1
  24. package/messages/index.mjs +0 -1
  25. package/package-metadata.js +1 -1
  26. package/package-metadata.mjs +2 -3
  27. package/package.json +13 -13
  28. package/tools/align.js +1 -1
  29. package/tools/align.mjs +4 -5
  30. package/tools/applyColor.js +1 -1
  31. package/tools/applyColor.mjs +5 -6
  32. package/tools/cleanFormatting.js +1 -1
  33. package/tools/cleanFormatting.mjs +8 -9
  34. package/tools/findReplace.js +1 -1
  35. package/tools/findReplace.mjs +9 -10
  36. package/tools/fontStyle.js +1 -1
  37. package/tools/fontStyle.mjs +6 -7
  38. package/tools/formatBlock.js +1 -1
  39. package/tools/formatBlock.mjs +10 -11
  40. package/tools/history.js +1 -1
  41. package/tools/history.mjs +2 -3
  42. package/tools/indent.js +1 -1
  43. package/tools/indent.mjs +0 -1
  44. package/tools/index.js +1 -1
  45. package/tools/index.mjs +0 -1
  46. package/tools/inlineFormat.js +1 -1
  47. package/tools/inlineFormat.mjs +4 -5
  48. package/tools/insertImage.js +1 -1
  49. package/tools/insertImage.mjs +4 -5
  50. package/tools/insertLink.js +1 -1
  51. package/tools/insertLink.mjs +13 -14
  52. package/tools/insertTable/popup.js +1 -1
  53. package/tools/insertTable/popup.mjs +4 -5
  54. package/tools/insertTable/popupGrid.js +1 -1
  55. package/tools/insertTable/popupGrid.mjs +0 -1
  56. package/tools/insertTable/tool.js +1 -1
  57. package/tools/insertTable/tool.mjs +0 -1
  58. package/tools/lists-styled.js +1 -1
  59. package/tools/lists-styled.mjs +0 -1
  60. package/tools/lists.js +1 -1
  61. package/tools/lists.mjs +13 -14
  62. package/tools/outdent.js +1 -1
  63. package/tools/outdent.mjs +0 -1
  64. package/tools/pdf.js +1 -1
  65. package/tools/pdf.mjs +4 -5
  66. package/tools/print.js +1 -1
  67. package/tools/print.mjs +4 -5
  68. package/tools/proseMirrorTool.js +1 -1
  69. package/tools/proseMirrorTool.mjs +8 -9
  70. package/tools/selectAll.js +1 -1
  71. package/tools/selectAll.mjs +5 -6
  72. package/tools/table-wizard/cellPropsUtils.js +1 -1
  73. package/tools/table-wizard/cellPropsUtils.mjs +34 -35
  74. package/tools/table-wizard/tableCellProperties.js +1 -1
  75. package/tools/table-wizard/tableCellProperties.mjs +0 -1
  76. package/tools/table-wizard/tableProperties.js +1 -1
  77. package/tools/table-wizard/tableProperties.mjs +44 -45
  78. package/tools/table-wizard/tablePropsUtils.js +1 -1
  79. package/tools/table-wizard/tablePropsUtils.mjs +99 -100
  80. package/tools/table-wizard/utils.js +1 -1
  81. package/tools/table-wizard/utils.mjs +17 -18
  82. package/tools/tableEdit.js +1 -1
  83. package/tools/tableEdit.mjs +2 -3
  84. package/tools/unlink.js +1 -1
  85. package/tools/unlink.mjs +8 -9
  86. package/tools/utils.js +1 -1
  87. package/tools/utils.mjs +0 -1
  88. package/tools/viewHtml.js +1 -1
  89. package/tools/viewHtml.mjs +11 -12
  90. package/utils/browser-detection.js +1 -1
  91. package/utils/browser-detection.mjs +0 -1
  92. package/utils/controlled-value.js +1 -1
  93. package/utils/controlled-value.mjs +2 -3
  94. package/utils/index.js +1 -1
  95. package/utils/index.mjs +0 -1
  96. package/utils/props-key.js +1 -1
  97. package/utils/props-key.mjs +3 -4
@@ -5,7 +5,6 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use client";
9
8
  import * as e from "react";
10
9
  import { Button as A } from "@progress/kendo-react-buttons";
11
10
  import { NumericTextBox as s, ColorPicker as se, Checkbox as Ne, TextBox as L } from "@progress/kendo-react-inputs";
@@ -18,20 +17,20 @@ import { valueRenderWithIcon as k, itemRenderWithIcon as v } from "./tableCellPr
18
17
  import { useLocalization as ge } from "@progress/kendo-react-intl";
19
18
  import { keys as t, messages as l } from "../../messages/index.mjs";
20
19
  import { applyTableData as ze, tablePositionStyles as He, tableDefaultData as We, initialTableData as Ue } from "./tablePropsUtils.mjs";
21
- const _e = (o) => {
22
- const { view: n, ...r } = o, P = ge(), [N, b] = e.useState(!1), g = !!(n && Te(n.state.selection.$from, (i) => i.type.spec.tableRole === "table")), p = e.useCallback(() => {
20
+ const _e = (n) => {
21
+ const { view: o, ...r } = n, P = ge(), [N, b] = e.useState(!1), g = !!(o && Te(o.state.selection.$from, (i) => i.type.spec.tableRole === "table")), p = e.useCallback(() => {
23
22
  b(!0);
24
23
  }, []), m = e.useCallback(() => {
25
- b(!1), n == null || n.focus();
26
- }, [n]), f = e.useCallback(
24
+ b(!1), o == null || o.focus();
25
+ }, [o]), f = e.useCallback(
27
26
  (i) => {
28
- if (n && i) {
29
- const u = ze(n.state, i);
30
- u && n.dispatch(u);
27
+ if (o && i) {
28
+ const u = ze(o.state, i);
29
+ u && o.dispatch(u);
31
30
  }
32
31
  m();
33
32
  },
34
- [n, m]
33
+ [o, m]
35
34
  );
36
35
  return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
37
36
  A,
@@ -45,7 +44,7 @@ const _e = (o) => {
45
44
  ...De,
46
45
  ...r
47
46
  }
48
- ), N && /* @__PURE__ */ e.createElement(Fe, { onClose: m, onSave: f, view: n }));
47
+ ), N && /* @__PURE__ */ e.createElement(Fe, { onClose: m, onSave: f, view: o }));
49
48
  }, E = [
50
49
  {
51
50
  textKey: t.tablePropertiesAlignLeft,
@@ -100,7 +99,7 @@ const _e = (o) => {
100
99
  icon: "table-position-right",
101
100
  svgIcon: Re
102
101
  }
103
- ].map((o) => ({ ...o, style: He[o.value] })), fe = [
102
+ ].map((n) => ({ ...n, style: He[n.value] })), fe = [
104
103
  {
105
104
  textKey: t.tablePropertiesTop,
106
105
  text: l[t.tablePropertiesTop],
@@ -127,14 +126,14 @@ const _e = (o) => {
127
126
  text: l[t.tablePropertiesUsingIdAttributes],
128
127
  value: "id"
129
128
  }
130
- ], Fe = (o) => {
131
- const n = e.useMemo(() => {
132
- const a = o.view && o.view.state;
129
+ ], Fe = (n) => {
130
+ const o = e.useMemo(() => {
131
+ const a = n.view && n.view.state;
133
132
  return a ? We(a) : Ue;
134
- }, [o.view]), r = ge(), [P, N] = e.useState(0), b = e.useCallback((a) => {
133
+ }, [n.view]), r = ge(), [P, N] = e.useState(0), b = e.useCallback((a) => {
135
134
  N(a.selected);
136
135
  }, []), g = e.useRef(null), p = e.useRef(null), m = e.useRef(null), f = e.useRef(null), i = e.useRef(null), u = e.useRef(null), S = e.useRef(null), I = e.useRef(null), B = e.useRef(null), K = e.useRef(null), x = e.useRef(null), h = e.useRef(null), V = e.useRef(null), T = e.useRef(null), D = e.useRef(null), z = e.useRef(null), H = e.useRef(null), W = e.useRef(null), U = e.useRef(null), F = e.useRef(null), C = e.useRef(null), w = e.useRef(null), y = e.useRef(null), pe = e.useCallback(() => {
137
- var R, M, G, $, j, q, J, O, Q, X, Y, Z, _, ee, te, ae, le, re, ne, oe;
136
+ var R, M, G, $, j, q, J, O, Q, X, Y, Z, _, ee, te, ae, le, re, oe, ne;
138
137
  const a = {
139
138
  rows: ((R = g.current) == null ? void 0 : R.value) || 0,
140
139
  columns: ((M = p.current) == null ? void 0 : M.value) || 0,
@@ -157,24 +156,24 @@ const _e = (o) => {
157
156
  headerRows: ((ae = U.current) == null ? void 0 : ae.value) || 0,
158
157
  headerColumns: ((le = F.current) == null ? void 0 : le.value) || 0,
159
158
  captionAlignment: (re = C.current) != null && re.value ? C.current.value.value : null,
160
- captionPosition: (ne = w.current) != null && ne.value ? w.current.value.value : null,
161
- associateHeaders: (oe = y.current) != null && oe.value ? y.current.value.value : "none"
159
+ captionPosition: (oe = w.current) != null && oe.value ? w.current.value.value : null,
160
+ associateHeaders: (ne = y.current) != null && ne.value ? y.current.value.value : "none"
162
161
  };
163
- o.onSave.call(void 0, a);
164
- }, [o.onSave]), ke = /* @__PURE__ */ e.createElement("div", { className: "k-form k-form-md" }, /* @__PURE__ */ e.createElement("fieldset", { className: "k-form-fieldset" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-layout k-d-grid k-grid-cols-4 k-gap-x-4" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
162
+ n.onSave.call(void 0, a);
163
+ }, [n.onSave]), ke = /* @__PURE__ */ e.createElement("div", { className: "k-form k-form-md" }, /* @__PURE__ */ e.createElement("fieldset", { className: "k-form-fieldset" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-layout k-d-grid k-grid-cols-4 k-gap-x-4" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
165
164
  t.tablePropertiesRows,
166
165
  l[t.tablePropertiesRows]
167
- )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: g, defaultValue: n.rows, min: 1 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
166
+ )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: g, defaultValue: o.rows, min: 1 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
168
167
  t.tablePropertiesColumns,
169
168
  l[t.tablePropertiesColumns]
170
- )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: p, defaultValue: n.columns, min: 1 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
169
+ )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: p, defaultValue: o.columns, min: 1 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
171
170
  t.tablePropertiesWidth,
172
171
  l[t.tablePropertiesWidth]
173
172
  )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
174
173
  s,
175
174
  {
176
175
  ref: m,
177
- defaultValue: n.width,
176
+ defaultValue: o.width,
178
177
  min: 0,
179
178
  placeholder: r.toLanguageString(t.sizeAuto, l[t.sizeAuto])
180
179
  }
@@ -182,7 +181,7 @@ const _e = (o) => {
182
181
  ie,
183
182
  {
184
183
  ref: I,
185
- defaultValue: n.widthUnit,
184
+ defaultValue: o.widthUnit,
186
185
  data: me,
187
186
  popupSettings: c
188
187
  }
@@ -193,7 +192,7 @@ const _e = (o) => {
193
192
  s,
194
193
  {
195
194
  ref: f,
196
- defaultValue: n.height,
195
+ defaultValue: o.height,
197
196
  min: 0,
198
197
  placeholder: r.toLanguageString(t.sizeAuto, l[t.sizeAuto])
199
198
  }
@@ -201,7 +200,7 @@ const _e = (o) => {
201
200
  ie,
202
201
  {
203
202
  ref: B,
204
- defaultValue: n.heightUnit,
203
+ defaultValue: o.heightUnit,
205
204
  data: me.filter((a) => a !== "%"),
206
205
  popupSettings: c
207
206
  }
@@ -212,7 +211,7 @@ const _e = (o) => {
212
211
  d,
213
212
  {
214
213
  ref: K,
215
- defaultValue: de.find((a) => a.value === n.position),
214
+ defaultValue: de.find((a) => a.value === o.position),
216
215
  popupSettings: c,
217
216
  data: de.map((a) => ({
218
217
  ...a,
@@ -230,7 +229,7 @@ const _e = (o) => {
230
229
  d,
231
230
  {
232
231
  ref: x,
233
- defaultValue: E.find((a) => a.value === n.textAlign),
232
+ defaultValue: E.find((a) => a.value === o.textAlign),
234
233
  data: E.map((a) => ({ ...a, text: r.toLanguageString(a.textKey, a.text) })),
235
234
  textField: "text",
236
235
  dataItemKey: "value",
@@ -245,7 +244,7 @@ const _e = (o) => {
245
244
  s,
246
245
  {
247
246
  ref: i,
248
- defaultValue: n.cellSpacing,
247
+ defaultValue: o.cellSpacing,
249
248
  placeholder: r.toLanguageString(t.sizeAuto, l[t.sizeAuto]),
250
249
  min: 0
251
250
  }
@@ -256,27 +255,27 @@ const _e = (o) => {
256
255
  s,
257
256
  {
258
257
  ref: u,
259
- defaultValue: n.cellPadding,
258
+ defaultValue: o.cellPadding,
260
259
  placeholder: r.toLanguageString(t.sizeAuto, l[t.sizeAuto]),
261
260
  min: 0
262
261
  }
263
262
  ))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-full" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
264
263
  t.tablePropertiesTableBackground,
265
264
  l[t.tablePropertiesTableBackground]
266
- )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(se, { ref: V, defaultValue: n.backgroundColor }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
265
+ )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(se, { ref: V, defaultValue: o.backgroundColor }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
267
266
  t.tablePropertiesBorderWidth,
268
267
  l[t.tablePropertiesBorderWidth]
269
- )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: S, defaultValue: n.borderWidth, min: 0 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
268
+ )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: S, defaultValue: o.borderWidth, min: 0 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
270
269
  t.tablePropertiesBorderColor,
271
270
  l[t.tablePropertiesBorderColor]
272
- )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(se, { ref: T, defaultValue: n.borderColor }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
271
+ )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(se, { ref: T, defaultValue: o.borderColor }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
273
272
  t.tablePropertiesBorderStyle,
274
273
  l[t.tablePropertiesBorderStyle]
275
274
  )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
276
275
  d,
277
276
  {
278
277
  ref: h,
279
- defaultValue: ue.find((a) => a.value === n.borderStyle),
278
+ defaultValue: ue.find((a) => a.value === o.borderStyle),
280
279
  popupSettings: c,
281
280
  data: ue.map((a) => ({
282
281
  ...a,
@@ -294,18 +293,18 @@ const _e = (o) => {
294
293
  t.tablePropertiesCollapseBorders,
295
294
  l[t.tablePropertiesCollapseBorders]
296
295
  ),
297
- defaultChecked: n.collapseBorders
296
+ defaultChecked: o.collapseBorders
298
297
  }
299
- )))))), ve = /* @__PURE__ */ e.createElement("div", { className: "k-form k-form-md" }, /* @__PURE__ */ e.createElement("fieldset", { className: "k-form-fieldset" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-layout k-d-grid" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-field" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesId, l[t.tablePropertiesId])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(L, { ref: z, defaultValue: n.id }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
298
+ )))))), ve = /* @__PURE__ */ e.createElement("div", { className: "k-form k-form-md" }, /* @__PURE__ */ e.createElement("fieldset", { className: "k-form-fieldset" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-layout k-d-grid" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-field" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(t.tablePropertiesId, l[t.tablePropertiesId])), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(L, { ref: z, defaultValue: o.id }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
300
299
  t.tablePropertiesCssClass,
301
300
  l[t.tablePropertiesCssClass]
302
- )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(L, { ref: H, defaultValue: n.className }))), /* @__PURE__ */ e.createElement("fieldset", { className: "k-form-fieldset" }, /* @__PURE__ */ e.createElement("legend", { className: "k-form-legend" }, r.toLanguageString(
301
+ )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(L, { ref: H, defaultValue: o.className }))), /* @__PURE__ */ e.createElement("fieldset", { className: "k-form-fieldset" }, /* @__PURE__ */ e.createElement("legend", { className: "k-form-legend" }, r.toLanguageString(
303
302
  t.tablePropertiesAccessibility,
304
303
  l[t.tablePropertiesAccessibility]
305
304
  )), /* @__PURE__ */ e.createElement("div", { className: "k-d-grid k-grid-cols-4 k-gap-x-4" }, /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-full" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
306
305
  t.tablePropertiesCaption,
307
306
  l[t.tablePropertiesCaption]
308
- )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(L, { ref: W, defaultValue: n.caption }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
307
+ )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(L, { ref: W, defaultValue: o.caption }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
309
308
  t.tablePropertiesCaptionPosition,
310
309
  l[t.tablePropertiesCaptionPosition]
311
310
  )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
@@ -313,7 +312,7 @@ const _e = (o) => {
313
312
  {
314
313
  ref: w,
315
314
  defaultValue: fe.find(
316
- (a) => a.value === n.captionPosition
315
+ (a) => a.value === o.captionPosition
317
316
  ),
318
317
  data: fe.map((a) => ({
319
318
  ...a,
@@ -332,7 +331,7 @@ const _e = (o) => {
332
331
  d,
333
332
  {
334
333
  ref: C,
335
- defaultValue: E.find((a) => a.value === n.captionAlignment),
334
+ defaultValue: E.find((a) => a.value === o.captionAlignment),
336
335
  data: E.map((a) => ({
337
336
  ...a,
338
337
  text: r.toLanguageString(a.textKey, a.text)
@@ -346,10 +345,10 @@ const _e = (o) => {
346
345
  ))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
347
346
  t.tablePropertiesHeaderRows,
348
347
  l[t.tablePropertiesHeaderRows]
349
- )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: U, defaultValue: n.headerRows, min: 0 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
348
+ )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: U, defaultValue: o.headerRows, min: 0 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-1" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
350
349
  t.tablePropertiesHeaderCols,
351
350
  l[t.tablePropertiesHeaderCols]
352
- )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: F, defaultValue: n.headerColumns, min: 0 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
351
+ )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(s, { ref: F, defaultValue: o.headerColumns, min: 0 }))), /* @__PURE__ */ e.createElement("div", { className: "k-form-field k-col-span-2" }, /* @__PURE__ */ e.createElement("label", { className: "k-label k-form-label" }, r.toLanguageString(
353
352
  t.tablePropertiesAssociateHeaders,
354
353
  l[t.tablePropertiesAssociateHeaders]
355
354
  )), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
@@ -357,7 +356,7 @@ const _e = (o) => {
357
356
  {
358
357
  ref: y,
359
358
  defaultValue: be.find(
360
- (a) => a.value === n.associateHeaders
359
+ (a) => a.value === o.associateHeaders
361
360
  ),
362
361
  data: be.map((a) => ({
363
362
  ...a,
@@ -387,14 +386,14 @@ const _e = (o) => {
387
386
  ve
388
387
  )), Pe = [
389
388
  /* @__PURE__ */ e.createElement(A, { themeColor: "primary", key: "save", onClick: pe }, r.toLanguageString(t.tablePropertiesSave, l[t.tablePropertiesSave])),
390
- /* @__PURE__ */ e.createElement(A, { onClick: o.onClose, key: "cancel" }, r.toLanguageString(t.tablePropertiesCancel, l[t.tablePropertiesCancel]))
389
+ /* @__PURE__ */ e.createElement(A, { onClick: n.onClose, key: "cancel" }, r.toLanguageString(t.tablePropertiesCancel, l[t.tablePropertiesCancel]))
391
390
  ];
392
391
  return /* @__PURE__ */ e.createElement(
393
392
  Se,
394
393
  {
395
394
  className: "k-editor-window k-editor-table-wizard-window",
396
395
  title: r.toLanguageString(t.tableProperties, l[t.tableProperties]),
397
- onClose: o.onClose,
396
+ onClose: n.onClose,
398
397
  key: "dialog",
399
398
  style: { userSelect: "none" },
400
399
  width: 480,
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@progress/kendo-editor-common"),k=require("../tableEdit.js"),d=require("./utils.js"),N=require("../utils.js"),E={rows:0,columns:0,width:null,widthUnit:"",height:null,heightUnit:"",position:null,textAlign:"",cellPadding:null,cellSpacing:null,backgroundColor:void 0,borderWidth:null,borderColor:void 0,borderStyle:null,collapseBorders:!1,id:"",className:"",caption:"",captionAlignment:null,captionPosition:null,headerRows:0,headerColumns:0,associateHeaders:"none"},A={left:{"margin-left":"","margin-right":"auto"},center:{"margin-left":"auto","margin-right":"auto"},right:{"margin-left":"auto","margin-right":""},"":{}},M=o=>{const t=[];for(let s=0;s<o.height;s++){const l=s*o.width,e=l+o.width;t.push(o.map.slice(l,e))}return t},$=(o,t)=>{let s=0,l=0;const e=M(t);e.forEach(n=>{let i=!0;n.forEach(r=>{const c=o.nodeAt(r);c&&c.type.name!=="table_header"&&(i=!1)}),i&&s++});for(let n=0;n<t.width;n++){let i=!0;for(let r=0;r<t.height;r++){const c=e[r]&&e[r][n],u=typeof c=="number"&&o.nodeAt(c);u&&u.type.name!=="table_header"&&(i=!1)}i&&l++}return{rows:s,columns:l}},v=o=>{const t=new Set;return o.content.forEach(s=>{s.content.forEach(l=>{t.add(d.parseStyle(l.attrs.style).padding||"")})}),t.size===1?Array.from(t)[0]:""},j=o=>{let t=!0,s=!0;return o.content.forEach(l=>{l.content.forEach(e=>{const n=e.type.name==="table_header",i=e.type.name==="table_cell";n&&!e.attrs.scope&&(t=!1),(n&&!e.attrs.id||i&&!e.attrs.headers)&&(s=!1)})}),t?"scope":s?"id":"none"},F=o=>{var a,h,m;const t=d.selectedCells(o),s=o.selection.$from,l=t.length?N.parentNode(s,f=>f.type.spec.tableRole==="table"):null;if(!l)return E;const e=N.parentNode(s,f=>f.type.name==="table_wrapper");let n="",i={},r={};e&&(r=d.parseStyle(e.node.attrs.style),e.node.content.forEach(f=>{if(f.type.name==="table_caption_external"){const S=w.pmDocToFragment(f);n=w.fragmentToHtml(S),n=n==="<img>"?"":n,i=d.parseStyle(f.attrs.style)}}));const c=d.parseStyle(((a=l.node.attrs)==null?void 0:a.style)||""),u=w.TableMap.get(l.node),p=r["margin-left"]==="auto"&&r["margin-right"]==="auto"?"center":r["margin-right"]==="auto"?"left":r["margin-left"]==="auto"?"right":null,y=$(l.node,u),g=v(l.node);return{...E,columns:u.width,rows:u.height,...d.nodeSize(l.node,"width"),...e&&/%/.test(r.width||"")?d.nodeSize(e.node,"width"):{},...d.nodeSize(l.node,"height"),textAlign:c["text-align"]||"",position:p||null,cellPadding:g?parseFloat(g):null,cellSpacing:c["border-spacing"]?parseFloat(c["border-spacing"]):null,backgroundColor:c["background-color"],borderWidth:c["border-width"]?parseFloat(c["border-width"]):null,borderColor:c["border-color"],borderStyle:c["border-style"]||null,collapseBorders:c["border-collapse"]==="collapse",caption:n||void 0,captionAlignment:i["text-align"]||"",captionPosition:i["caption-side"]||null,headerRows:y.rows,headerColumns:y.columns,associateHeaders:y.rows||y.columns?j(l.node):"none",id:((h=l.node.attrs)==null?void 0:h.id)||"",className:((m=l.node.attrs)==null?void 0:m.class)||""}},x=o=>{const s=o.lastChild.lastChild;return{node:s,pos:o.content.size-s.nodeSize}},_=(o,t,s,l,e)=>{const n=x(s),i=t+n.pos;if(!o.doc.nodeAt(i))return o;const c=o.doc.resolve(i),u=new w.CellSelection(c,c),p=o.tr.setSelection(u);let y=o.apply(p);for(let g=0;g<l;g++)e(y,a=>{y=y.apply(a)});return y},R=(o,t,s,l)=>{let e=o;for(let n=0;n<s;n++){const i=e.doc.nodeAt(t);if(i){const r=x(i),c=t+r.pos,u=e.doc.resolve(c),p=new w.CellSelection(u,u),y=e.tr.setSelection(p);e=e.apply(y),l(e,g=>{e=e.apply(g)})}}return e},O=(o,t,s,l)=>{let e=o,n=e.doc.nodeAt(t);if(!n)return e;let i=w.TableMap.get(n);return i.width===l&&i.height===s||(l>i.width?e=_(e,t,n,l-i.width,w.addColumnAfter):l<i.width&&(e=R(e,t,i.width-l,k.deleteColumnCmd)),n=e.doc.nodeAt(t),!n)||(i=w.TableMap.get(n),s>i.height?e=_(e,t,n,s-i.height,w.addRowAfter):s<i.height&&(e=R(e,t,i.height-s,k.deleteRowCmd))),e},q=(o,t,s)=>{const l=o.doc.nodeAt(s);if(!l)return o;let e={...l.attrs};const n=t.width!==null&&(t.widthUnit!=="%"||!t.caption&&!t.position);e=d.setNodeStyle(e,"width",n?t.width+t.widthUnit:""),e=d.setNodeStyle(e,"height",t.height!==null?t.height+t.heightUnit:""),e=d.setNodeStyle(e,"text-align",t.textAlign||""),e=d.setNodeStyle(e,"background-color",t.backgroundColor||""),e=d.setNodeStyle(e,"border-width",t.borderWidth?t.borderWidth+"px":""),e=d.setNodeStyle(e,"border-style",t.borderStyle||""),e=d.setNodeStyle(e,"border-color",t.borderColor||""),e=d.setNodeStyle(e,"border-spacing",t.cellSpacing!==null?t.cellSpacing+"px":""),t.cellSpacing!==null?e=d.setNodeStyle(e,"border-collapse","unset"):e=d.setNodeStyle(e,"border-collapse",t.collapseBorders?"collapse":"");const i=A[t.position||""]||{};Object.keys(i).forEach(c=>{e=d.setNodeStyle(e,c,i[c])}),e.id=t.id||null,e.class=t.className||null;const r=o.tr.setNodeMarkup(s,null,e);return o=o.apply(r),o},z=(o,t,s,l,e)=>{if(t.type.name!==l.name||Object.keys(e).length>0){const n=o.tr.setNodeMarkup(s,l,{...t.attrs,...e});return o.apply(n)}return o},B=(o,t)=>{/^cell-[0-9]+-[0-9]+$/.test(o.attrs.id||"")&&(t.id=null)},P=(o,t,s)=>{const l=o.doc.nodeAt(s),e=l&&w.TableMap.get(l);if(!l||!e)return o;const n=M(e);let i=o;const{table_header:r,table_cell:c}=o.schema.nodes,u=String(new Date().getTime()),p=[],y=(a,h)=>{const m=`cell-${a}${h}-${u}`;return p[a]||p.push([]),p[a][h]||p[a].push([]),p[a][h]=m,m},g=(a,h,m,f)=>{const S=[];if(f)for(let b=0;b<a;b++)p[b]&&p[b][h]&&S.push(p[b][h]);if(m)for(let b=0;b<h;b++)p[a]&&p[a][b]&&S.push(p[a][b]);return S.join(" ")};return n.forEach((a,h)=>{a.forEach((m,f)=>{const S=l.nodeAt(m);if(S){const b=f<t.headerColumns,T=h<t.headerRows,C={...S.attrs};B(S,C),C.headers=null,C.scope=null,T||b?(t.associateHeaders==="scope"&&(C.scope=T?"col":"row"),t.associateHeaders==="id"&&(C.id=y(h,f),(f>0||h>0)&&(C.headers=g(h,f,b,T)||null)),i=z(i,S,s+m+1,r,C)):(t.associateHeaders==="id"&&(C.headers=g(h,f,t.headerColumns>0,t.headerRows>0)||null),i=z(i,S,s+m+1,c,C))}})}),i},G=(o,t,s,l)=>{let e={...t.attrs};return e=d.setNodeStyle(e,"margin-left",""),e=d.setNodeStyle(e,"margin-right",""),Object.keys(l||{}).forEach(n=>{e=d.setNodeStyle(e,n,(l||{})[n]||"")}),o.apply(o.tr.setNodeMarkup(s,null,e))},D=(o,t)=>w.parseContent("<p>"+o+"</p>",t).content.firstChild.content,H=(o,t)=>{if(!o.caption)return;let s={caption:"",style:"display: table-caption"};o.captionAlignment&&(s=d.setNodeStyle(s,"text-align",o.captionAlignment)),o.captionPosition&&(s=d.setNodeStyle(s,"caption-side",o.captionPosition));const l=D(o.caption,t);return l&&t.nodes.table_caption_external.createAndFill(s,l)||void 0},U=o=>o.firstChild&&o.firstChild.type.name==="table_caption_external",J=(o,t,s,l)=>{let e=o,n;const i=s+2,r=s+1,c=e.schema;if(U(t))if(n=t.firstChild,l.caption){const u=D(l.caption,c);if(e=e.apply(e.tr.replaceWith(i,i+n.content.size,u)),n=e.doc.nodeAt(r),n){let p={...n.attrs};p=d.setNodeStyle(p,"text-align",l.captionAlignment||""),p=d.setNodeStyle(p,"caption-side",l.captionPosition||""),e=e.apply(e.tr.setNodeAttribute(r,"style",p.style))}}else e=e.apply(e.tr.deleteRange(i,i+n.content.size));else n=H(l,c),n&&(e=e.apply(e.tr.replaceWith(r,r,n)));return e},K=(o,t,s,l,e)=>{let n={state:o,pos:s};if(!l&&(t.position||t.caption)){let r={table:"",style:"display: table"};const c=[],u=t.position,p=u&&A[u];p&&Object.keys(p).forEach(h=>{r=d.setNodeStyle(r,h,p[h]||"")}),typeof t.width=="number"&&t.widthUnit==="%"&&(r=d.setNodeStyle(r,"width",t.width+t.widthUnit));const y=H(t,o.schema);y&&c.push(y);const g=o.doc.nodeAt(s);c.push(g);const a=o.schema.nodes.table_wrapper.createAndFill(r,c);if(a){const h=o.tr.replaceWith(s,s+g.content.size,a);o=o.apply(h),n={state:o,pos:s}}}else l&&(t.position||t.caption||!t.caption&&U(l.node))?(o=G(o,l.node,e,t.position&&A[t.position]),o=J(o,l.node,e,t),n={state:o,pos:e}):l&&!(t.position||t.caption)?n={state:o,node:l.node,pos:o.selection.$from.start(l.depth)-1}:n={state:o,pos:s};const i=l&&n.state.doc.nodeAt(e);if(i){let r;typeof t.width=="number"&&t.widthUnit==="%"?r=d.setNodeStyle(i.attrs,"width",t.width+t.widthUnit):t.widthUnit!=="%"&&/%/.test(d.parseStyle(i.attrs.style||"").width||"")&&(r=d.setNodeStyle(i.attrs,"width","")),r&&(n.state=n.state.apply(n.state.tr.setNodeMarkup(e,null,r)))}return n},L=(o,t)=>{const s=o.selection.$from,l=N.parentNode(s,f=>f.type.spec.tableRole==="table");if(!l)return;const e=s.start(l.depth)-1;let n=O(o,e,t.rows,t.columns);if(!n)return;const i=n.tr;d.tableCells(n).forEach(f=>{let S={...f.node.attrs};S=d.setNodeStyle(S,"padding",typeof t.cellPadding=="number"?t.cellPadding+"px":""),i.setNodeMarkup(f.pos,null,S)}),n=n.apply(i),n=q(n,t,e),n=P(n,t,e);const r=N.parentNode(s,f=>f.type.name==="table_wrapper"),c=s.start((r==null?void 0:r.depth)||0)-1,u=K(n,t,e,r,c);n=u.state;const p=u.pos,y=n.doc.nodeAt(u.pos);if(!y)return;const g=p+(r||l).node.content.size,a=o.tr.replaceWith(p,g,y),h=w.Selection.atEnd(y),m=w.TextSelection.create(a.doc,p+h.to+1);return a.setSelection(m),a};exports.applyTableData=L;exports.initialTableData=E;exports.tableDefaultData=F;exports.tablePositionStyles=A;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@progress/kendo-editor-common"),k=require("../tableEdit.js"),d=require("./utils.js"),N=require("../utils.js"),E={rows:0,columns:0,width:null,widthUnit:"",height:null,heightUnit:"",position:null,textAlign:"",cellPadding:null,cellSpacing:null,backgroundColor:void 0,borderWidth:null,borderColor:void 0,borderStyle:null,collapseBorders:!1,id:"",className:"",caption:"",captionAlignment:null,captionPosition:null,headerRows:0,headerColumns:0,associateHeaders:"none"},A={left:{"margin-left":"","margin-right":"auto"},center:{"margin-left":"auto","margin-right":"auto"},right:{"margin-left":"auto","margin-right":""},"":{}},M=o=>{const t=[];for(let s=0;s<o.height;s++){const l=s*o.width,e=l+o.width;t.push(o.map.slice(l,e))}return t},$=(o,t)=>{let s=0,l=0;const e=M(t);e.forEach(n=>{let i=!0;n.forEach(r=>{const c=o.nodeAt(r);c&&c.type.name!=="table_header"&&(i=!1)}),i&&s++});for(let n=0;n<t.width;n++){let i=!0;for(let r=0;r<t.height;r++){const c=e[r]&&e[r][n],u=typeof c=="number"&&o.nodeAt(c);u&&u.type.name!=="table_header"&&(i=!1)}i&&l++}return{rows:s,columns:l}},v=o=>{const t=new Set;return o.content.forEach(s=>{s.content.forEach(l=>{t.add(d.parseStyle(l.attrs.style).padding||"")})}),t.size===1?Array.from(t)[0]:""},j=o=>{let t=!0,s=!0;return o.content.forEach(l=>{l.content.forEach(e=>{const n=e.type.name==="table_header",i=e.type.name==="table_cell";n&&!e.attrs.scope&&(t=!1),(n&&!e.attrs.id||i&&!e.attrs.headers)&&(s=!1)})}),t?"scope":s?"id":"none"},F=o=>{var a,h,m;const t=d.selectedCells(o),s=o.selection.$from,l=t.length?N.parentNode(s,f=>f.type.spec.tableRole==="table"):null;if(!l)return E;const e=N.parentNode(s,f=>f.type.name==="table_wrapper");let n="",i={},r={};e&&(r=d.parseStyle(e.node.attrs.style),e.node.content.forEach(f=>{if(f.type.name==="table_caption_external"){const S=w.pmDocToFragment(f);n=w.fragmentToHtml(S),n=n==="<img>"?"":n,i=d.parseStyle(f.attrs.style)}}));const c=d.parseStyle(((a=l.node.attrs)==null?void 0:a.style)||""),u=w.TableMap.get(l.node),p=r["margin-left"]==="auto"&&r["margin-right"]==="auto"?"center":r["margin-right"]==="auto"?"left":r["margin-left"]==="auto"?"right":null,y=$(l.node,u),g=v(l.node);return{...E,columns:u.width,rows:u.height,...d.nodeSize(l.node,"width"),...e&&/%/.test(r.width||"")?d.nodeSize(e.node,"width"):{},...d.nodeSize(l.node,"height"),textAlign:c["text-align"]||"",position:p||null,cellPadding:g?parseFloat(g):null,cellSpacing:c["border-spacing"]?parseFloat(c["border-spacing"]):null,backgroundColor:c["background-color"],borderWidth:c["border-width"]?parseFloat(c["border-width"]):null,borderColor:c["border-color"],borderStyle:c["border-style"]||null,collapseBorders:c["border-collapse"]==="collapse",caption:n||void 0,captionAlignment:i["text-align"]||"",captionPosition:i["caption-side"]||null,headerRows:y.rows,headerColumns:y.columns,associateHeaders:y.rows||y.columns?j(l.node):"none",id:((h=l.node.attrs)==null?void 0:h.id)||"",className:((m=l.node.attrs)==null?void 0:m.class)||""}},x=o=>{const s=o.lastChild.lastChild;return{node:s,pos:o.content.size-s.nodeSize}},_=(o,t,s,l,e)=>{const n=x(s),i=t+n.pos;if(!o.doc.nodeAt(i))return o;const c=o.doc.resolve(i),u=new w.CellSelection(c,c),p=o.tr.setSelection(u);let y=o.apply(p);for(let g=0;g<l;g++)e(y,a=>{y=y.apply(a)});return y},R=(o,t,s,l)=>{let e=o;for(let n=0;n<s;n++){const i=e.doc.nodeAt(t);if(i){const r=x(i),c=t+r.pos,u=e.doc.resolve(c),p=new w.CellSelection(u,u),y=e.tr.setSelection(p);e=e.apply(y),l(e,g=>{e=e.apply(g)})}}return e},O=(o,t,s,l)=>{let e=o,n=e.doc.nodeAt(t);if(!n)return e;let i=w.TableMap.get(n);return i.width===l&&i.height===s||(l>i.width?e=_(e,t,n,l-i.width,w.addColumnAfter):l<i.width&&(e=R(e,t,i.width-l,k.deleteColumnCmd)),n=e.doc.nodeAt(t),!n)||(i=w.TableMap.get(n),s>i.height?e=_(e,t,n,s-i.height,w.addRowAfter):s<i.height&&(e=R(e,t,i.height-s,k.deleteRowCmd))),e},q=(o,t,s)=>{const l=o.doc.nodeAt(s);if(!l)return o;let e={...l.attrs};const n=t.width!==null&&(t.widthUnit!=="%"||!t.caption&&!t.position);e=d.setNodeStyle(e,"width",n?t.width+t.widthUnit:""),e=d.setNodeStyle(e,"height",t.height!==null?t.height+t.heightUnit:""),e=d.setNodeStyle(e,"text-align",t.textAlign||""),e=d.setNodeStyle(e,"background-color",t.backgroundColor||""),e=d.setNodeStyle(e,"border-width",t.borderWidth?t.borderWidth+"px":""),e=d.setNodeStyle(e,"border-style",t.borderStyle||""),e=d.setNodeStyle(e,"border-color",t.borderColor||""),e=d.setNodeStyle(e,"border-spacing",t.cellSpacing!==null?t.cellSpacing+"px":""),t.cellSpacing!==null?e=d.setNodeStyle(e,"border-collapse","unset"):e=d.setNodeStyle(e,"border-collapse",t.collapseBorders?"collapse":"");const i=A[t.position||""]||{};Object.keys(i).forEach(c=>{e=d.setNodeStyle(e,c,i[c])}),e.id=t.id||null,e.class=t.className||null;const r=o.tr.setNodeMarkup(s,null,e);return o=o.apply(r),o},z=(o,t,s,l,e)=>{if(t.type.name!==l.name||Object.keys(e).length>0){const n=o.tr.setNodeMarkup(s,l,{...t.attrs,...e});return o.apply(n)}return o},B=(o,t)=>{/^cell-[0-9]+-[0-9]+$/.test(o.attrs.id||"")&&(t.id=null)},P=(o,t,s)=>{const l=o.doc.nodeAt(s),e=l&&w.TableMap.get(l);if(!l||!e)return o;const n=M(e);let i=o;const{table_header:r,table_cell:c}=o.schema.nodes,u=String(new Date().getTime()),p=[],y=(a,h)=>{const m=`cell-${a}${h}-${u}`;return p[a]||p.push([]),p[a][h]||p[a].push([]),p[a][h]=m,m},g=(a,h,m,f)=>{const S=[];if(f)for(let b=0;b<a;b++)p[b]&&p[b][h]&&S.push(p[b][h]);if(m)for(let b=0;b<h;b++)p[a]&&p[a][b]&&S.push(p[a][b]);return S.join(" ")};return n.forEach((a,h)=>{a.forEach((m,f)=>{const S=l.nodeAt(m);if(S){const b=f<t.headerColumns,T=h<t.headerRows,C={...S.attrs};B(S,C),C.headers=null,C.scope=null,T||b?(t.associateHeaders==="scope"&&(C.scope=T?"col":"row"),t.associateHeaders==="id"&&(C.id=y(h,f),(f>0||h>0)&&(C.headers=g(h,f,b,T)||null)),i=z(i,S,s+m+1,r,C)):(t.associateHeaders==="id"&&(C.headers=g(h,f,t.headerColumns>0,t.headerRows>0)||null),i=z(i,S,s+m+1,c,C))}})}),i},G=(o,t,s,l)=>{let e={...t.attrs};return e=d.setNodeStyle(e,"margin-left",""),e=d.setNodeStyle(e,"margin-right",""),Object.keys(l||{}).forEach(n=>{e=d.setNodeStyle(e,n,(l||{})[n]||"")}),o.apply(o.tr.setNodeMarkup(s,null,e))},D=(o,t)=>w.parseContent("<p>"+o+"</p>",t).content.firstChild.content,H=(o,t)=>{if(!o.caption)return;let s={caption:"",style:"display: table-caption"};o.captionAlignment&&(s=d.setNodeStyle(s,"text-align",o.captionAlignment)),o.captionPosition&&(s=d.setNodeStyle(s,"caption-side",o.captionPosition));const l=D(o.caption,t);return l&&t.nodes.table_caption_external.createAndFill(s,l)||void 0},U=o=>o.firstChild&&o.firstChild.type.name==="table_caption_external",J=(o,t,s,l)=>{let e=o,n;const i=s+2,r=s+1,c=e.schema;if(U(t))if(n=t.firstChild,l.caption){const u=D(l.caption,c);if(e=e.apply(e.tr.replaceWith(i,i+n.content.size,u)),n=e.doc.nodeAt(r),n){let p={...n.attrs};p=d.setNodeStyle(p,"text-align",l.captionAlignment||""),p=d.setNodeStyle(p,"caption-side",l.captionPosition||""),e=e.apply(e.tr.setNodeAttribute(r,"style",p.style))}}else e=e.apply(e.tr.deleteRange(i,i+n.content.size));else n=H(l,c),n&&(e=e.apply(e.tr.replaceWith(r,r,n)));return e},K=(o,t,s,l,e)=>{let n={state:o,pos:s};if(!l&&(t.position||t.caption)){let r={table:"",style:"display: table"};const c=[],u=t.position,p=u&&A[u];p&&Object.keys(p).forEach(h=>{r=d.setNodeStyle(r,h,p[h]||"")}),typeof t.width=="number"&&t.widthUnit==="%"&&(r=d.setNodeStyle(r,"width",t.width+t.widthUnit));const y=H(t,o.schema);y&&c.push(y);const g=o.doc.nodeAt(s);c.push(g);const a=o.schema.nodes.table_wrapper.createAndFill(r,c);if(a){const h=o.tr.replaceWith(s,s+g.content.size,a);o=o.apply(h),n={state:o,pos:s}}}else l&&(t.position||t.caption||!t.caption&&U(l.node))?(o=G(o,l.node,e,t.position&&A[t.position]),o=J(o,l.node,e,t),n={state:o,pos:e}):l&&!(t.position||t.caption)?n={state:o,node:l.node,pos:o.selection.$from.start(l.depth)-1}:n={state:o,pos:s};const i=l&&n.state.doc.nodeAt(e);if(i){let r;typeof t.width=="number"&&t.widthUnit==="%"?r=d.setNodeStyle(i.attrs,"width",t.width+t.widthUnit):t.widthUnit!=="%"&&/%/.test(d.parseStyle(i.attrs.style||"").width||"")&&(r=d.setNodeStyle(i.attrs,"width","")),r&&(n.state=n.state.apply(n.state.tr.setNodeMarkup(e,null,r)))}return n},L=(o,t)=>{const s=o.selection.$from,l=N.parentNode(s,f=>f.type.spec.tableRole==="table");if(!l)return;const e=s.start(l.depth)-1;let n=O(o,e,t.rows,t.columns);if(!n)return;const i=n.tr;d.tableCells(n).forEach(f=>{let S={...f.node.attrs};S=d.setNodeStyle(S,"padding",typeof t.cellPadding=="number"?t.cellPadding+"px":""),i.setNodeMarkup(f.pos,null,S)}),n=n.apply(i),n=q(n,t,e),n=P(n,t,e);const r=N.parentNode(s,f=>f.type.name==="table_wrapper"),c=s.start((r==null?void 0:r.depth)||0)-1,u=K(n,t,e,r,c);n=u.state;const p=u.pos,y=n.doc.nodeAt(u.pos);if(!y)return;const g=p+(r||l).node.content.size,a=o.tr.replaceWith(p,g,y),h=w.Selection.atEnd(y),m=w.TextSelection.create(a.doc,p+h.to+1);return a.setSelection(m),a};exports.applyTableData=L;exports.initialTableData=E;exports.tableDefaultData=F;exports.tablePositionStyles=A;