reactjs-tiptap-editor 1.0.22 → 1.0.24

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 (159) hide show
  1. package/lib/{ActionMenuButton-BBDqKvKg.cjs → ActionMenuButton-B8NhVw5m.cjs} +1 -1
  2. package/lib/{ActionMenuButton-B1067mIC.js → ActionMenuButton-HYlhmRvw.js} +1 -1
  3. package/lib/Attachment.cjs +1 -1
  4. package/lib/Attachment.js +4 -4
  5. package/lib/Blockquote.cjs +1 -1
  6. package/lib/Blockquote.js +2 -2
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +2 -2
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +2 -2
  11. package/lib/{Callout-lBlBlK_w.cjs → Callout-B-S2f0Qo.cjs} +1 -1
  12. package/lib/{Callout-V2mO6s2Y.js → Callout-CF7Y9yJ7.js} +4 -4
  13. package/lib/Callout.cjs +1 -1
  14. package/lib/Callout.js +4 -4
  15. package/lib/Clear.cjs +1 -1
  16. package/lib/Clear.js +2 -2
  17. package/lib/Code.cjs +1 -1
  18. package/lib/Code.js +6 -6
  19. package/lib/CodeBlock.cjs +1 -1
  20. package/lib/CodeBlock.js +27 -27
  21. package/lib/CodeView.cjs +1 -1
  22. package/lib/CodeView.js +2 -2
  23. package/lib/Color.cjs +1 -1
  24. package/lib/Color.js +3 -3
  25. package/lib/Column.cjs +1 -1
  26. package/lib/Column.js +7 -7
  27. package/lib/{Drawer-Cyv27orn.js → Drawer-CaXVhxo4.js} +21 -21
  28. package/lib/{Drawer-BeYo9jAG.cjs → Drawer-Was4hxYH.cjs} +1 -1
  29. package/lib/Drawer.cjs +1 -1
  30. package/lib/Drawer.js +4 -4
  31. package/lib/Emoji.cjs +1 -1
  32. package/lib/Emoji.js +4312 -1860
  33. package/lib/Excalidraw.cjs +1 -1
  34. package/lib/Excalidraw.js +3 -3
  35. package/lib/ExportPdf.cjs +1 -1
  36. package/lib/ExportPdf.js +2 -2
  37. package/lib/ExportWord.cjs +1 -1
  38. package/lib/ExportWord.js +2 -2
  39. package/lib/FontFamily.cjs +1 -1
  40. package/lib/FontFamily.js +5 -5
  41. package/lib/FontSize.cjs +1 -1
  42. package/lib/FontSize.js +9 -9
  43. package/lib/Heading.cjs +1 -1
  44. package/lib/Heading.js +5 -5
  45. package/lib/Highlight.cjs +1 -1
  46. package/lib/Highlight.js +69 -46
  47. package/lib/History.cjs +1 -1
  48. package/lib/History.js +556 -418
  49. package/lib/HorizontalRule.cjs +1 -1
  50. package/lib/HorizontalRule.js +2 -2
  51. package/lib/{Iframe-Bx-VDxSB.cjs → Iframe-BI0sq6pd.cjs} +1 -1
  52. package/lib/{Iframe-D9JVKzO0.js → Iframe-Bp986fj0.js} +3 -3
  53. package/lib/Iframe.cjs +1 -1
  54. package/lib/Iframe.js +3 -3
  55. package/lib/Image.cjs +1 -1
  56. package/lib/Image.js +3 -3
  57. package/lib/ImageGif.cjs +1 -1
  58. package/lib/ImageGif.js +47 -47
  59. package/lib/ImportWord.cjs +1 -1
  60. package/lib/ImportWord.js +3 -3
  61. package/lib/{Indent-B5tQ5Wfg.js → Indent-E6B8DkyN.js} +4 -4
  62. package/lib/{Indent-CCLO0KpG.cjs → Indent-FvM52kjA.cjs} +1 -1
  63. package/lib/Indent.cjs +1 -1
  64. package/lib/Indent.js +2 -2
  65. package/lib/Italic.cjs +1 -1
  66. package/lib/Italic.js +2 -2
  67. package/lib/{Katex-rtfVV2pl.cjs → Katex-DP6EjdKz.cjs} +1 -1
  68. package/lib/{Katex-w_c6vAMd.js → Katex-pzwyyiFJ.js} +5 -5
  69. package/lib/Katex.cjs +1 -1
  70. package/lib/Katex.js +3 -3
  71. package/lib/LineHeight.cjs +1 -1
  72. package/lib/LineHeight.js +4 -4
  73. package/lib/Link.cjs +1 -1
  74. package/lib/Link.js +2 -2
  75. package/lib/LinkEditBlock-Cmkmp2fW.cjs +5 -0
  76. package/lib/{LinkEditBlock-CTlU8YnO.js → LinkEditBlock-OjN4F2rM.js} +222 -224
  77. package/lib/MarkdownPaste.cjs +1 -1
  78. package/lib/MarkdownPaste.js +1 -1
  79. package/lib/Mention.cjs +1 -1
  80. package/lib/Mention.js +8 -8
  81. package/lib/Mermaid.cjs +1 -1
  82. package/lib/Mermaid.js +34 -34
  83. package/lib/MoreMark.cjs +1 -1
  84. package/lib/MoreMark.js +3 -3
  85. package/lib/OrderedList.cjs +1 -1
  86. package/lib/OrderedList.js +2 -2
  87. package/lib/SearchAndReplace.cjs +1 -1
  88. package/lib/SearchAndReplace.js +4 -4
  89. package/lib/SlashCommand.cjs +1 -1
  90. package/lib/SlashCommand.js +7 -7
  91. package/lib/{SlashCommandNodeView-CVKjpS6r.cjs → SlashCommandNodeView-DarAytvt.cjs} +1 -1
  92. package/lib/{SlashCommandNodeView-DNkpJuM3.js → SlashCommandNodeView-o323V8li.js} +2 -2
  93. package/lib/Strike.cjs +1 -1
  94. package/lib/Strike.js +2 -2
  95. package/lib/Table-CC9uNHPL.js +1984 -0
  96. package/lib/Table-Clnz-i4l.cjs +9 -0
  97. package/lib/Table.cjs +1 -1
  98. package/lib/Table.js +1 -1
  99. package/lib/TaskList.cjs +1 -1
  100. package/lib/TaskList.js +2 -2
  101. package/lib/TextAlign.cjs +1 -1
  102. package/lib/TextAlign.js +3 -3
  103. package/lib/TextDirection.cjs +1 -1
  104. package/lib/TextDirection.js +3 -3
  105. package/lib/TextUnderline.cjs +1 -1
  106. package/lib/TextUnderline.js +2 -2
  107. package/lib/{Twitter-BJjt8vv_.cjs → Twitter-0kmrijjL.cjs} +1 -1
  108. package/lib/{Twitter-CKm0M53B.js → Twitter-BVnXL8we.js} +5 -5
  109. package/lib/Twitter.cjs +1 -1
  110. package/lib/Twitter.js +3 -3
  111. package/lib/Video.cjs +1 -1
  112. package/lib/Video.js +3 -3
  113. package/lib/bubble.cjs +6 -6
  114. package/lib/bubble.js +1573 -1561
  115. package/lib/{clsx-Bg-2aTKh.js → clsx-0OU6n9va.js} +379 -353
  116. package/lib/clsx-D6gYQn3o.cjs +33 -0
  117. package/lib/{dropdown-menu-Dre693DD.cjs → dropdown-menu-BIGvxqiu.cjs} +1 -1
  118. package/lib/{dropdown-menu-AhMKS9PQ.js → dropdown-menu-BW2M6saA.js} +1 -1
  119. package/lib/index-BAb_UADw.cjs +1 -0
  120. package/lib/index-BF3EVCB1.cjs +2 -0
  121. package/lib/{index-D0EmqTpe.js → index-BblvcbTH.js} +1130 -1064
  122. package/lib/index-Bcj8cyOO.cjs +24 -0
  123. package/lib/{index-BfHAqkoX.js → index-BrsJsbds.js} +3 -3
  124. package/lib/index-CGjT-a9h.js +1377 -0
  125. package/lib/index-CPTpXLfX.cjs +11 -0
  126. package/lib/{index-C3dgmjIF.cjs → index-CUvjYuRp.cjs} +1 -1
  127. package/lib/{index-C4aGVY2E.cjs → index-CWw4s87s.cjs} +1 -1
  128. package/lib/{index-DXtVL0al.js → index-Cal5SPfB.js} +189 -134
  129. package/lib/{index-CjLxMm5d.js → index-D-Ouz0vF.js} +1 -1
  130. package/lib/{index-83hp1lZH.cjs → index-deubsx3z.cjs} +1 -1
  131. package/lib/{index-DtVRewGA.js → index-oj858lQO.js} +229 -31
  132. package/lib/{index-CbkpBnTX.js → index-zw-Kd38i.js} +47 -50
  133. package/lib/index.cjs +1 -1
  134. package/lib/index.js +2 -2
  135. package/lib/locale-bundle.cjs +1 -1
  136. package/lib/locale-bundle.js +7 -6
  137. package/lib/locales/index.d.ts +199 -1
  138. package/lib/locales/ja.d.ts +198 -0
  139. package/lib/{popover-B1ptDngu.js → popover-BIVHT1W9.js} +1 -1
  140. package/lib/{popover-D7w_FVSV.cjs → popover-DoSfJsFS.cjs} +1 -1
  141. package/lib/{renderNodeView-CbxCTni3.js → renderNodeView-CfWJK4rG.js} +2 -2
  142. package/lib/{renderNodeView-DFVrJy0l.cjs → renderNodeView-D--fDFov.cjs} +1 -1
  143. package/lib/{separator-C_7KkuoG.cjs → separator-SRbPfmGa.cjs} +1 -1
  144. package/lib/{separator-CDoF4Z4Z.js → separator-b-qOPJmp.js} +3 -3
  145. package/lib/{textarea-CNzZnjjW.js → textarea-CpxXPky_.js} +1 -1
  146. package/lib/{textarea-CEtXap1b.cjs → textarea-DbGw9oCU.cjs} +1 -1
  147. package/lib/updatePosition-BwzAsiY0.js +16 -0
  148. package/lib/{updatePosition-CQE1ct18.cjs → updatePosition-DGPtRfWN.cjs} +1 -1
  149. package/package.json +60 -60
  150. package/lib/LinkEditBlock-_41zgSyl.cjs +0 -5
  151. package/lib/Table-BFiU40iW.cjs +0 -9
  152. package/lib/Table-yZtD5Qo1.js +0 -1945
  153. package/lib/clsx-DSAWW32g.cjs +0 -33
  154. package/lib/index-C4WLt4NA.cjs +0 -24
  155. package/lib/index-DlxZt4_j.cjs +0 -1
  156. package/lib/index-P5_MyY0i.js +0 -1362
  157. package/lib/index-TcJ2UKnv.cjs +0 -1
  158. package/lib/index-fbGGohBT.cjs +0 -12
  159. package/lib/updatePosition-BGD41Hbg.js +0 -16
@@ -1,1945 +0,0 @@
1
- import { O as de, S as E, W as Ve, T as W, F as v, u as L, L as ke, s as Ke, X as Xe, N as J, m as Y, R as Ue, U as Ge, E as Ee, Y as qe } from "./index-D0EmqTpe.js";
2
- import { TextSelection as Je } from "@tiptap/pm/state";
3
- import { k as Ye, D as oe, a as ne } from "./index-CjLxMm5d.js";
4
- import { jsxs as ee, jsx as k, Fragment as Ze } from "react/jsx-runtime";
5
- import { h as Qe, u as et, d as tt, A as ot } from "./index-BfHAqkoX.js";
6
- import { useState as _ } from "react";
7
- import "./theme.js";
8
- import { T as O, k as F, m as j } from "./index-DtVRewGA.js";
9
- import { P as nt, a as lt, b as rt } from "./popover-B1ptDngu.js";
10
- let le, re;
11
- if (typeof WeakMap < "u") {
12
- let t = /* @__PURE__ */ new WeakMap();
13
- le = (e) => t.get(e), re = (e, o) => (t.set(e, o), o);
14
- } else {
15
- const t = [];
16
- let o = 0;
17
- le = (n) => {
18
- for (let l = 0; l < t.length; l += 2) if (t[l] == n) return t[l + 1];
19
- }, re = (n, l) => (o == 10 && (o = 0), t[o++] = n, t[o++] = l);
20
- }
21
- var C = class {
22
- constructor(t, e, o, n) {
23
- this.width = t, this.height = e, this.map = o, this.problems = n;
24
- }
25
- findCell(t) {
26
- for (let e = 0; e < this.map.length; e++) {
27
- const o = this.map[e];
28
- if (o != t) continue;
29
- const n = e % this.width, l = e / this.width | 0;
30
- let r = n + 1, s = l + 1;
31
- for (let i = 1; r < this.width && this.map[e + i] == o; i++) r++;
32
- for (let i = 1; s < this.height && this.map[e + this.width * i] == o; i++) s++;
33
- return {
34
- left: n,
35
- top: l,
36
- right: r,
37
- bottom: s
38
- };
39
- }
40
- throw new RangeError(`No cell with offset ${t} found`);
41
- }
42
- colCount(t) {
43
- for (let e = 0; e < this.map.length; e++) if (this.map[e] == t) return e % this.width;
44
- throw new RangeError(`No cell with offset ${t} found`);
45
- }
46
- nextCell(t, e, o) {
47
- const { left: n, right: l, top: r, bottom: s } = this.findCell(t);
48
- return e == "horiz" ? (o < 0 ? n == 0 : l == this.width) ? null : this.map[r * this.width + (o < 0 ? n - 1 : l)] : (o < 0 ? r == 0 : s == this.height) ? null : this.map[n + this.width * (o < 0 ? r - 1 : s)];
49
- }
50
- rectBetween(t, e) {
51
- const { left: o, right: n, top: l, bottom: r } = this.findCell(t), { left: s, right: i, top: c, bottom: a } = this.findCell(e);
52
- return {
53
- left: Math.min(o, s),
54
- top: Math.min(l, c),
55
- right: Math.max(n, i),
56
- bottom: Math.max(r, a)
57
- };
58
- }
59
- cellsInRect(t) {
60
- const e = [], o = {};
61
- for (let n = t.top; n < t.bottom; n++) for (let l = t.left; l < t.right; l++) {
62
- const r = n * this.width + l, s = this.map[r];
63
- o[s] || (o[s] = !0, !(l == t.left && l && this.map[r - 1] == s || n == t.top && n && this.map[r - this.width] == s) && e.push(s));
64
- }
65
- return e;
66
- }
67
- positionAt(t, e, o) {
68
- for (let n = 0, l = 0; ; n++) {
69
- const r = l + o.child(n).nodeSize;
70
- if (n == t) {
71
- let s = e + t * this.width;
72
- const i = (t + 1) * this.width;
73
- for (; s < i && this.map[s] < l; ) s++;
74
- return s == i ? r - 1 : this.map[s];
75
- }
76
- l = r;
77
- }
78
- }
79
- static get(t) {
80
- return le(t) || re(t, st(t));
81
- }
82
- };
83
- function st(t) {
84
- if (t.type.spec.tableRole != "table") throw new RangeError("Not a table node: " + t.type.name);
85
- const e = it(t), o = t.childCount, n = [];
86
- let l = 0, r = null;
87
- const s = [];
88
- for (let a = 0, d = e * o; a < d; a++) n[a] = 0;
89
- for (let a = 0, d = 0; a < o; a++) {
90
- const u = t.child(a);
91
- d++;
92
- for (let p = 0; ; p++) {
93
- for (; l < n.length && n[l] != 0; ) l++;
94
- if (p == u.childCount) break;
95
- const m = u.child(p), { colspan: g, rowspan: b, colwidth: S } = m.attrs;
96
- for (let A = 0; A < b; A++) {
97
- if (A + a >= o) {
98
- (r || (r = [])).push({
99
- type: "overlong_rowspan",
100
- pos: d,
101
- n: b - A
102
- });
103
- break;
104
- }
105
- const z = l + A * e;
106
- for (let T = 0; T < g; T++) {
107
- n[z + T] == 0 ? n[z + T] = d : (r || (r = [])).push({
108
- type: "collision",
109
- row: a,
110
- pos: d,
111
- n: g - T
112
- });
113
- const P = S && S[T];
114
- if (P) {
115
- const B = (z + T) % e * 2, Q = s[B];
116
- Q == null || Q != P && s[B + 1] == 1 ? (s[B] = P, s[B + 1] = 1) : Q == P && s[B + 1]++;
117
- }
118
- }
119
- }
120
- l += g, d += m.nodeSize;
121
- }
122
- const f = (a + 1) * e;
123
- let h = 0;
124
- for (; l < f; ) n[l++] == 0 && h++;
125
- h && (r || (r = [])).push({
126
- type: "missing",
127
- row: a,
128
- n: h
129
- }), d++;
130
- }
131
- (e === 0 || o === 0) && (r || (r = [])).push({ type: "zero_sized" });
132
- const i = new C(e, o, n, r);
133
- let c = !1;
134
- for (let a = 0; !c && a < s.length; a += 2) s[a] != null && s[a + 1] < o && (c = !0);
135
- return c && ct(i, s, t), i;
136
- }
137
- function it(t) {
138
- let e = -1, o = !1;
139
- for (let n = 0; n < t.childCount; n++) {
140
- const l = t.child(n);
141
- let r = 0;
142
- if (o) for (let s = 0; s < n; s++) {
143
- const i = t.child(s);
144
- for (let c = 0; c < i.childCount; c++) {
145
- const a = i.child(c);
146
- s + a.attrs.rowspan > n && (r += a.attrs.colspan);
147
- }
148
- }
149
- for (let s = 0; s < l.childCount; s++) {
150
- const i = l.child(s);
151
- r += i.attrs.colspan, i.attrs.rowspan > 1 && (o = !0);
152
- }
153
- e == -1 ? e = r : e != r && (e = Math.max(e, r));
154
- }
155
- return e;
156
- }
157
- function ct(t, e, o) {
158
- t.problems || (t.problems = []);
159
- const n = {};
160
- for (let l = 0; l < t.map.length; l++) {
161
- const r = t.map[l];
162
- if (n[r]) continue;
163
- n[r] = !0;
164
- const s = o.nodeAt(r);
165
- if (!s) throw new RangeError(`No cell with offset ${r} found`);
166
- let i = null;
167
- const c = s.attrs;
168
- for (let a = 0; a < c.colspan; a++) {
169
- const d = e[(l + a) % t.width * 2];
170
- d != null && (!c.colwidth || c.colwidth[a] != d) && ((i || (i = at(c)))[a] = d);
171
- }
172
- i && t.problems.unshift({
173
- type: "colwidth mismatch",
174
- pos: r,
175
- colwidth: i
176
- });
177
- }
178
- }
179
- function at(t) {
180
- if (t.colwidth) return t.colwidth.slice();
181
- const e = [];
182
- for (let o = 0; o < t.colspan; o++) e.push(0);
183
- return e;
184
- }
185
- function y(t) {
186
- let e = t.cached.tableNodeTypes;
187
- if (!e) {
188
- e = t.cached.tableNodeTypes = {};
189
- for (const o in t.nodes) {
190
- const n = t.nodes[o], l = n.spec.tableRole;
191
- l && (e[l] = n);
192
- }
193
- }
194
- return e;
195
- }
196
- const H = new de("selectingCells");
197
- function $(t) {
198
- for (let e = t.depth - 1; e > 0; e--) if (t.node(e).type.spec.tableRole == "row") return t.node(0).resolve(t.before(e + 1));
199
- return null;
200
- }
201
- function dt(t) {
202
- for (let e = t.depth; e > 0; e--) {
203
- const o = t.node(e).type.spec.tableRole;
204
- if (o === "cell" || o === "header_cell") return t.node(e);
205
- }
206
- return null;
207
- }
208
- function R(t) {
209
- const e = t.selection.$head;
210
- for (let o = e.depth; o > 0; o--) if (e.node(o).type.spec.tableRole == "row") return !0;
211
- return !1;
212
- }
213
- function Z(t) {
214
- const e = t.selection;
215
- if ("$anchorCell" in e && e.$anchorCell) return e.$anchorCell.pos > e.$headCell.pos ? e.$anchorCell : e.$headCell;
216
- if ("node" in e && e.node && e.node.type.spec.tableRole == "cell") return e.$anchor;
217
- const o = $(e.$head) || ut(e.$head);
218
- if (o) return o;
219
- throw new RangeError(`No cell found around position ${e.head}`);
220
- }
221
- function ut(t) {
222
- for (let e = t.nodeAfter, o = t.pos; e; e = e.firstChild, o++) {
223
- const n = e.type.spec.tableRole;
224
- if (n == "cell" || n == "header_cell") return t.doc.resolve(o);
225
- }
226
- for (let e = t.nodeBefore, o = t.pos; e; e = e.lastChild, o--) {
227
- const n = e.type.spec.tableRole;
228
- if (n == "cell" || n == "header_cell") return t.doc.resolve(o - e.nodeSize);
229
- }
230
- }
231
- function se(t) {
232
- return t.parent.type.spec.tableRole == "row" && !!t.nodeAfter;
233
- }
234
- function ft(t) {
235
- return t.node(0).resolve(t.pos + t.nodeAfter.nodeSize);
236
- }
237
- function ue(t, e) {
238
- return t.depth == e.depth && t.pos >= e.start(-1) && t.pos <= e.end(-1);
239
- }
240
- function ze(t, e, o) {
241
- const n = t.node(-1), l = C.get(n), r = t.start(-1), s = l.nextCell(t.pos - r, e, o);
242
- return s == null ? null : t.node(0).resolve(r + s);
243
- }
244
- function D(t, e, o = 1) {
245
- const n = {
246
- ...t,
247
- colspan: t.colspan - o
248
- };
249
- return n.colwidth && (n.colwidth = n.colwidth.slice(), n.colwidth.splice(e, o), n.colwidth.some((l) => l > 0) || (n.colwidth = null)), n;
250
- }
251
- function He(t, e, o = 1) {
252
- const n = {
253
- ...t,
254
- colspan: t.colspan + o
255
- };
256
- if (n.colwidth) {
257
- n.colwidth = n.colwidth.slice();
258
- for (let l = 0; l < o; l++) n.colwidth.splice(e, 0, 0);
259
- }
260
- return n;
261
- }
262
- function ht(t, e, o) {
263
- const n = y(e.type.schema).header_cell;
264
- for (let l = 0; l < t.height; l++) if (e.nodeAt(t.map[o + l * t.width]).type != n) return !1;
265
- return !0;
266
- }
267
- var w = class N extends E {
268
- constructor(e, o = e) {
269
- const n = e.node(-1), l = C.get(n), r = e.start(-1), s = l.rectBetween(e.pos - r, o.pos - r), i = e.node(0), c = l.cellsInRect(s).filter((d) => d != o.pos - r);
270
- c.unshift(o.pos - r);
271
- const a = c.map((d) => {
272
- const u = n.nodeAt(d);
273
- if (!u) throw new RangeError(`No cell with offset ${d} found`);
274
- const f = r + d + 1;
275
- return new Ve(i.resolve(f), i.resolve(f + u.content.size));
276
- });
277
- super(a[0].$from, a[0].$to, a), this.$anchorCell = e, this.$headCell = o;
278
- }
279
- map(e, o) {
280
- const n = e.resolve(o.map(this.$anchorCell.pos)), l = e.resolve(o.map(this.$headCell.pos));
281
- if (se(n) && se(l) && ue(n, l)) {
282
- const r = this.$anchorCell.node(-1) != n.node(-1);
283
- return r && this.isRowSelection() ? N.rowSelection(n, l) : r && this.isColSelection() ? N.colSelection(n, l) : new N(n, l);
284
- }
285
- return W.between(n, l);
286
- }
287
- content() {
288
- const e = this.$anchorCell.node(-1), o = C.get(e), n = this.$anchorCell.start(-1), l = o.rectBetween(this.$anchorCell.pos - n, this.$headCell.pos - n), r = {}, s = [];
289
- for (let c = l.top; c < l.bottom; c++) {
290
- const a = [];
291
- for (let d = c * o.width + l.left, u = l.left; u < l.right; u++, d++) {
292
- const f = o.map[d];
293
- if (r[f]) continue;
294
- r[f] = !0;
295
- const h = o.findCell(f);
296
- let p = e.nodeAt(f);
297
- if (!p) throw new RangeError(`No cell with offset ${f} found`);
298
- const m = l.left - h.left, g = h.right - l.right;
299
- if (m > 0 || g > 0) {
300
- let b = p.attrs;
301
- if (m > 0 && (b = D(b, 0, m)), g > 0 && (b = D(b, b.colspan - g, g)), h.left < l.left) {
302
- if (p = p.type.createAndFill(b), !p) throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`);
303
- } else p = p.type.create(b, p.content);
304
- }
305
- if (h.top < l.top || h.bottom > l.bottom) {
306
- const b = {
307
- ...p.attrs,
308
- rowspan: Math.min(h.bottom, l.bottom) - Math.max(h.top, l.top)
309
- };
310
- h.top < l.top ? p = p.type.createAndFill(b) : p = p.type.create(b, p.content);
311
- }
312
- a.push(p);
313
- }
314
- s.push(e.child(c).copy(v.from(a)));
315
- }
316
- const i = this.isColSelection() && this.isRowSelection() ? e : s;
317
- return new L(v.from(i), 1, 1);
318
- }
319
- replace(e, o = L.empty) {
320
- const n = e.steps.length, l = this.ranges;
321
- for (let s = 0; s < l.length; s++) {
322
- const { $from: i, $to: c } = l[s], a = e.mapping.slice(n);
323
- e.replace(a.map(i.pos), a.map(c.pos), s ? L.empty : o);
324
- }
325
- const r = E.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)), -1);
326
- r && e.setSelection(r);
327
- }
328
- replaceWith(e, o) {
329
- this.replace(e, new L(v.from(o), 0, 0));
330
- }
331
- forEachCell(e) {
332
- const o = this.$anchorCell.node(-1), n = C.get(o), l = this.$anchorCell.start(-1), r = n.cellsInRect(n.rectBetween(this.$anchorCell.pos - l, this.$headCell.pos - l));
333
- for (let s = 0; s < r.length; s++) e(o.nodeAt(r[s]), l + r[s]);
334
- }
335
- isColSelection() {
336
- const e = this.$anchorCell.index(-1), o = this.$headCell.index(-1);
337
- if (Math.min(e, o) > 0) return !1;
338
- const n = e + this.$anchorCell.nodeAfter.attrs.rowspan, l = o + this.$headCell.nodeAfter.attrs.rowspan;
339
- return Math.max(n, l) == this.$headCell.node(-1).childCount;
340
- }
341
- static colSelection(e, o = e) {
342
- const n = e.node(-1), l = C.get(n), r = e.start(-1), s = l.findCell(e.pos - r), i = l.findCell(o.pos - r), c = e.node(0);
343
- return s.top <= i.top ? (s.top > 0 && (e = c.resolve(r + l.map[s.left])), i.bottom < l.height && (o = c.resolve(r + l.map[l.width * (l.height - 1) + i.right - 1]))) : (i.top > 0 && (o = c.resolve(r + l.map[i.left])), s.bottom < l.height && (e = c.resolve(r + l.map[l.width * (l.height - 1) + s.right - 1]))), new N(e, o);
344
- }
345
- isRowSelection() {
346
- const e = this.$anchorCell.node(-1), o = C.get(e), n = this.$anchorCell.start(-1), l = o.colCount(this.$anchorCell.pos - n), r = o.colCount(this.$headCell.pos - n);
347
- if (Math.min(l, r) > 0) return !1;
348
- const s = l + this.$anchorCell.nodeAfter.attrs.colspan, i = r + this.$headCell.nodeAfter.attrs.colspan;
349
- return Math.max(s, i) == o.width;
350
- }
351
- eq(e) {
352
- return e instanceof N && e.$anchorCell.pos == this.$anchorCell.pos && e.$headCell.pos == this.$headCell.pos;
353
- }
354
- static rowSelection(e, o = e) {
355
- const n = e.node(-1), l = C.get(n), r = e.start(-1), s = l.findCell(e.pos - r), i = l.findCell(o.pos - r), c = e.node(0);
356
- return s.left <= i.left ? (s.left > 0 && (e = c.resolve(r + l.map[s.top * l.width])), i.right < l.width && (o = c.resolve(r + l.map[l.width * (i.top + 1) - 1]))) : (i.left > 0 && (o = c.resolve(r + l.map[i.top * l.width])), s.right < l.width && (e = c.resolve(r + l.map[l.width * (s.top + 1) - 1]))), new N(e, o);
357
- }
358
- toJSON() {
359
- return {
360
- type: "cell",
361
- anchor: this.$anchorCell.pos,
362
- head: this.$headCell.pos
363
- };
364
- }
365
- static fromJSON(e, o) {
366
- return new N(e.resolve(o.anchor), e.resolve(o.head));
367
- }
368
- static create(e, o, n = o) {
369
- return new N(e.resolve(o), e.resolve(n));
370
- }
371
- getBookmark() {
372
- return new pt(this.$anchorCell.pos, this.$headCell.pos);
373
- }
374
- };
375
- w.prototype.visible = !1;
376
- E.jsonID("cell", w);
377
- var pt = class Le {
378
- constructor(e, o) {
379
- this.anchor = e, this.head = o;
380
- }
381
- map(e) {
382
- return new Le(e.map(this.anchor), e.map(this.head));
383
- }
384
- resolve(e) {
385
- const o = e.resolve(this.anchor), n = e.resolve(this.head);
386
- return o.parent.type.spec.tableRole == "row" && n.parent.type.spec.tableRole == "row" && o.index() < o.parent.childCount && n.index() < n.parent.childCount && ue(o, n) ? new w(o, n) : E.near(n, 1);
387
- }
388
- };
389
- function mt(t) {
390
- if (!(t.selection instanceof w)) return null;
391
- const e = [];
392
- return t.selection.forEachCell((o, n) => {
393
- e.push(ne.node(n, n + o.nodeSize, { class: "selectedCell" }));
394
- }), oe.create(t.doc, e);
395
- }
396
- function gt({ $from: t, $to: e }) {
397
- if (t.pos == e.pos || t.pos < e.pos - 6) return !1;
398
- let o = t.pos, n = e.pos, l = t.depth;
399
- for (; l >= 0 && !(t.after(l + 1) < t.end(l)); l--, o++) ;
400
- for (let r = e.depth; r >= 0 && !(e.before(r + 1) > e.start(r)); r--, n--) ;
401
- return o == n && /row|table/.test(t.node(l).type.spec.tableRole);
402
- }
403
- function bt({ $from: t, $to: e }) {
404
- let o, n;
405
- for (let l = t.depth; l > 0; l--) {
406
- const r = t.node(l);
407
- if (r.type.spec.tableRole === "cell" || r.type.spec.tableRole === "header_cell") {
408
- o = r;
409
- break;
410
- }
411
- }
412
- for (let l = e.depth; l > 0; l--) {
413
- const r = e.node(l);
414
- if (r.type.spec.tableRole === "cell" || r.type.spec.tableRole === "header_cell") {
415
- n = r;
416
- break;
417
- }
418
- }
419
- return o !== n && e.parentOffset === 0;
420
- }
421
- function wt(t, e, o) {
422
- const n = (e || t).selection, l = (e || t).doc;
423
- let r, s;
424
- if (n instanceof Ke && (s = n.node.type.spec.tableRole)) {
425
- if (s == "cell" || s == "header_cell") r = w.create(l, n.from);
426
- else if (s == "row") {
427
- const i = l.resolve(n.from + 1);
428
- r = w.rowSelection(i, i);
429
- } else if (!o) {
430
- const i = C.get(n.node), c = n.from + 1, a = c + i.map[i.width * i.height - 1];
431
- r = w.create(l, c + 1, a);
432
- }
433
- } else n instanceof W && gt(n) ? r = W.create(l, n.from) : n instanceof W && bt(n) && (r = W.create(l, n.$from.start(), n.$from.end()));
434
- return r && (e || (e = t.tr)).setSelection(r), e;
435
- }
436
- const Ct = new de("fix-tables");
437
- function We(t, e, o, n) {
438
- const l = t.childCount, r = e.childCount;
439
- e: for (let s = 0, i = 0; s < r; s++) {
440
- const c = e.child(s);
441
- for (let a = i, d = Math.min(l, s + 3); a < d; a++) if (t.child(a) == c) {
442
- i = a + 1, o += c.nodeSize;
443
- continue e;
444
- }
445
- n(c, o), i < l && t.child(i).sameMarkup(c) ? We(t.child(i), c, o + 1, n) : c.nodesBetween(0, c.content.size, n, o + 1), o += c.nodeSize;
446
- }
447
- }
448
- function $e(t, e) {
449
- let o;
450
- const n = (l, r) => {
451
- l.type.spec.tableRole == "table" && (o = yt(t, l, r, o));
452
- };
453
- return e ? e.doc != t.doc && We(e.doc, t.doc, 0, n) : t.doc.descendants(n), o;
454
- }
455
- function yt(t, e, o, n) {
456
- const l = C.get(e);
457
- if (!l.problems) return n;
458
- n || (n = t.tr);
459
- const r = [];
460
- for (let c = 0; c < l.height; c++) r.push(0);
461
- for (let c = 0; c < l.problems.length; c++) {
462
- const a = l.problems[c];
463
- if (a.type == "collision") {
464
- const d = e.nodeAt(a.pos);
465
- if (!d) continue;
466
- const u = d.attrs;
467
- for (let f = 0; f < u.rowspan; f++) r[a.row + f] += a.n;
468
- n.setNodeMarkup(n.mapping.map(o + 1 + a.pos), null, D(u, u.colspan - a.n, a.n));
469
- } else if (a.type == "missing") r[a.row] += a.n;
470
- else if (a.type == "overlong_rowspan") {
471
- const d = e.nodeAt(a.pos);
472
- if (!d) continue;
473
- n.setNodeMarkup(n.mapping.map(o + 1 + a.pos), null, {
474
- ...d.attrs,
475
- rowspan: d.attrs.rowspan - a.n
476
- });
477
- } else if (a.type == "colwidth mismatch") {
478
- const d = e.nodeAt(a.pos);
479
- if (!d) continue;
480
- n.setNodeMarkup(n.mapping.map(o + 1 + a.pos), null, {
481
- ...d.attrs,
482
- colwidth: a.colwidth
483
- });
484
- } else if (a.type == "zero_sized") {
485
- const d = n.mapping.map(o);
486
- n.delete(d, d + e.nodeSize);
487
- }
488
- }
489
- let s, i;
490
- for (let c = 0; c < r.length; c++) r[c] && (s == null && (s = c), i = c);
491
- for (let c = 0, a = o + 1; c < l.height; c++) {
492
- const d = e.child(c), u = a + d.nodeSize, f = r[c];
493
- if (f > 0) {
494
- let h = "cell";
495
- d.firstChild && (h = d.firstChild.type.spec.tableRole);
496
- const p = [];
497
- for (let g = 0; g < f; g++) {
498
- const b = y(t.schema)[h].createAndFill();
499
- b && p.push(b);
500
- }
501
- const m = (c == 0 || s == c - 1) && i == c ? a + 1 : u - 1;
502
- n.insert(n.mapping.map(m), p);
503
- }
504
- a = u;
505
- }
506
- return n.setMeta(Ct, { fixTables: !0 });
507
- }
508
- function M(t) {
509
- const e = t.selection, o = Z(t), n = o.node(-1), l = o.start(-1), r = C.get(n);
510
- return {
511
- ...e instanceof w ? r.rectBetween(e.$anchorCell.pos - l, e.$headCell.pos - l) : r.findCell(o.pos - l),
512
- tableStart: l,
513
- map: r,
514
- table: n
515
- };
516
- }
517
- function De(t, { map: e, tableStart: o, table: n }, l) {
518
- let r = l > 0 ? -1 : 0;
519
- ht(e, n, l + r) && (r = l == 0 || l == e.width ? null : 0);
520
- for (let s = 0; s < e.height; s++) {
521
- const i = s * e.width + l;
522
- if (l > 0 && l < e.width && e.map[i - 1] == e.map[i]) {
523
- const c = e.map[i], a = n.nodeAt(c);
524
- t.setNodeMarkup(t.mapping.map(o + c), null, He(a.attrs, l - e.colCount(c))), s += a.attrs.rowspan - 1;
525
- } else {
526
- const c = r == null ? y(n.type.schema).cell : n.nodeAt(e.map[i + r]).type, a = e.positionAt(s, l, n);
527
- t.insert(t.mapping.map(o + a), c.createAndFill());
528
- }
529
- }
530
- return t;
531
- }
532
- function St(t, e) {
533
- if (!R(t)) return !1;
534
- if (e) {
535
- const o = M(t);
536
- e(De(t.tr, o, o.left));
537
- }
538
- return !0;
539
- }
540
- function xt(t, e) {
541
- if (!R(t)) return !1;
542
- if (e) {
543
- const o = M(t);
544
- e(De(t.tr, o, o.right));
545
- }
546
- return !0;
547
- }
548
- function At(t, { map: e, table: o, tableStart: n }, l) {
549
- const r = t.mapping.maps.length;
550
- for (let s = 0; s < e.height; ) {
551
- const i = s * e.width + l, c = e.map[i], a = o.nodeAt(c), d = a.attrs;
552
- if (l > 0 && e.map[i - 1] == c || l < e.width - 1 && e.map[i + 1] == c) t.setNodeMarkup(t.mapping.slice(r).map(n + c), null, D(d, l - e.colCount(c)));
553
- else {
554
- const u = t.mapping.slice(r).map(n + c);
555
- t.delete(u, u + a.nodeSize);
556
- }
557
- s += d.rowspan;
558
- }
559
- }
560
- function Tt(t, e) {
561
- if (!R(t)) return !1;
562
- if (e) {
563
- const o = M(t), n = t.tr;
564
- if (o.left == 0 && o.right == o.map.width) return !1;
565
- for (let l = o.right - 1; At(n, o, l), l != o.left; l--) {
566
- const r = o.tableStart ? n.doc.nodeAt(o.tableStart - 1) : n.doc;
567
- if (!r) throw new RangeError("No table found");
568
- o.table = r, o.map = C.get(r);
569
- }
570
- e(n);
571
- }
572
- return !0;
573
- }
574
- function Rt(t, e, o) {
575
- var n;
576
- const l = y(e.type.schema).header_cell;
577
- for (let r = 0; r < t.width; r++) if (((n = e.nodeAt(t.map[r + o * t.width])) === null || n === void 0 ? void 0 : n.type) != l) return !1;
578
- return !0;
579
- }
580
- function Be(t, { map: e, tableStart: o, table: n }, l) {
581
- let r = o;
582
- for (let a = 0; a < l; a++) r += n.child(a).nodeSize;
583
- const s = [];
584
- let i = l > 0 ? -1 : 0;
585
- Rt(e, n, l + i) && (i = l == 0 || l == e.height ? null : 0);
586
- for (let a = 0, d = e.width * l; a < e.width; a++, d++) if (l > 0 && l < e.height && e.map[d] == e.map[d - e.width]) {
587
- const u = e.map[d], f = n.nodeAt(u).attrs;
588
- t.setNodeMarkup(o + u, null, {
589
- ...f,
590
- rowspan: f.rowspan + 1
591
- }), a += f.colspan - 1;
592
- } else {
593
- var c;
594
- const u = i == null ? y(n.type.schema).cell : (c = n.nodeAt(e.map[d + i * e.width])) === null || c === void 0 ? void 0 : c.type, f = u == null ? void 0 : u.createAndFill();
595
- f && s.push(f);
596
- }
597
- return t.insert(r, y(n.type.schema).row.create(null, s)), t;
598
- }
599
- function vt(t, e) {
600
- if (!R(t)) return !1;
601
- if (e) {
602
- const o = M(t);
603
- e(Be(t.tr, o, o.top));
604
- }
605
- return !0;
606
- }
607
- function Mt(t, e) {
608
- if (!R(t)) return !1;
609
- if (e) {
610
- const o = M(t);
611
- e(Be(t.tr, o, o.bottom));
612
- }
613
- return !0;
614
- }
615
- function Nt(t, { map: e, table: o, tableStart: n }, l) {
616
- let r = 0;
617
- for (let a = 0; a < l; a++) r += o.child(a).nodeSize;
618
- const s = r + o.child(l).nodeSize, i = t.mapping.maps.length;
619
- t.delete(r + n, s + n);
620
- const c = /* @__PURE__ */ new Set();
621
- for (let a = 0, d = l * e.width; a < e.width; a++, d++) {
622
- const u = e.map[d];
623
- if (!c.has(u)) {
624
- if (c.add(u), l > 0 && u == e.map[d - e.width]) {
625
- const f = o.nodeAt(u).attrs;
626
- t.setNodeMarkup(t.mapping.slice(i).map(u + n), null, {
627
- ...f,
628
- rowspan: f.rowspan - 1
629
- }), a += f.colspan - 1;
630
- } else if (l < e.height && u == e.map[d + e.width]) {
631
- const f = o.nodeAt(u), h = f.attrs, p = f.type.create({
632
- ...h,
633
- rowspan: f.attrs.rowspan - 1
634
- }, f.content), m = e.positionAt(l + 1, a, o);
635
- t.insert(t.mapping.slice(i).map(n + m), p), a += h.colspan - 1;
636
- }
637
- }
638
- }
639
- }
640
- function kt(t, e) {
641
- if (!R(t)) return !1;
642
- if (e) {
643
- const o = M(t), n = t.tr;
644
- if (o.top == 0 && o.bottom == o.map.height) return !1;
645
- for (let l = o.bottom - 1; Nt(n, o, l), l != o.top; l--) {
646
- const r = o.tableStart ? n.doc.nodeAt(o.tableStart - 1) : n.doc;
647
- if (!r) throw new RangeError("No table found");
648
- o.table = r, o.map = C.get(o.table);
649
- }
650
- e(n);
651
- }
652
- return !0;
653
- }
654
- function fe(t) {
655
- const e = t.content;
656
- return e.childCount == 1 && e.child(0).isTextblock && e.child(0).childCount == 0;
657
- }
658
- function Et({ width: t, height: e, map: o }, n) {
659
- let l = n.top * t + n.left, r = l, s = (n.bottom - 1) * t + n.left, i = l + (n.right - n.left - 1);
660
- for (let c = n.top; c < n.bottom; c++) {
661
- if (n.left > 0 && o[r] == o[r - 1] || n.right < t && o[i] == o[i + 1]) return !0;
662
- r += t, i += t;
663
- }
664
- for (let c = n.left; c < n.right; c++) {
665
- if (n.top > 0 && o[l] == o[l - t] || n.bottom < e && o[s] == o[s + t]) return !0;
666
- l++, s++;
667
- }
668
- return !1;
669
- }
670
- function he(t, e) {
671
- const o = t.selection;
672
- if (!(o instanceof w) || o.$anchorCell.pos == o.$headCell.pos) return !1;
673
- const n = M(t), { map: l } = n;
674
- if (Et(l, n)) return !1;
675
- if (e) {
676
- const r = t.tr, s = {};
677
- let i = v.empty, c, a;
678
- for (let d = n.top; d < n.bottom; d++) for (let u = n.left; u < n.right; u++) {
679
- const f = l.map[d * l.width + u], h = n.table.nodeAt(f);
680
- if (!(s[f] || !h))
681
- if (s[f] = !0, c == null)
682
- c = f, a = h;
683
- else {
684
- fe(h) || (i = i.append(h.content));
685
- const p = r.mapping.map(f + n.tableStart);
686
- r.delete(p, p + h.nodeSize);
687
- }
688
- }
689
- if (c == null || a == null) return !0;
690
- if (r.setNodeMarkup(c + n.tableStart, null, {
691
- ...He(a.attrs, a.attrs.colspan, n.right - n.left - a.attrs.colspan),
692
- rowspan: n.bottom - n.top
693
- }), i.size > 0) {
694
- const d = c + 1 + a.content.size, u = fe(a) ? c + 1 : d;
695
- r.replaceWith(u + n.tableStart, d + n.tableStart, i);
696
- }
697
- r.setSelection(new w(r.doc.resolve(c + n.tableStart))), e(r);
698
- }
699
- return !0;
700
- }
701
- function pe(t, e) {
702
- const o = y(t.schema);
703
- return zt(({ node: n }) => o[n.type.spec.tableRole])(t, e);
704
- }
705
- function zt(t) {
706
- return (e, o) => {
707
- const n = e.selection;
708
- let l, r;
709
- if (n instanceof w) {
710
- if (n.$anchorCell.pos != n.$headCell.pos) return !1;
711
- l = n.$anchorCell.nodeAfter, r = n.$anchorCell.pos;
712
- } else {
713
- var s;
714
- if (l = dt(n.$from), !l) return !1;
715
- r = (s = $(n.$from)) === null || s === void 0 ? void 0 : s.pos;
716
- }
717
- if (l == null || r == null || l.attrs.colspan == 1 && l.attrs.rowspan == 1) return !1;
718
- if (o) {
719
- let i = l.attrs;
720
- const c = [], a = i.colwidth;
721
- i.rowspan > 1 && (i = {
722
- ...i,
723
- rowspan: 1
724
- }), i.colspan > 1 && (i = {
725
- ...i,
726
- colspan: 1
727
- });
728
- const d = M(e), u = e.tr;
729
- for (let h = 0; h < d.right - d.left; h++) c.push(a ? {
730
- ...i,
731
- colwidth: a && a[h] ? [a[h]] : null
732
- } : i);
733
- let f;
734
- for (let h = d.top; h < d.bottom; h++) {
735
- let p = d.map.positionAt(h, d.left, d.table);
736
- h == d.top && (p += l.nodeSize);
737
- for (let m = d.left, g = 0; m < d.right; m++, g++)
738
- m == d.left && h == d.top || u.insert(f = u.mapping.map(p + d.tableStart, 1), t({
739
- node: l,
740
- row: h,
741
- col: m
742
- }).createAndFill(c[g]));
743
- }
744
- u.setNodeMarkup(r, t({
745
- node: l,
746
- row: d.top,
747
- col: d.left
748
- }), c[0]), n instanceof w && u.setSelection(new w(u.doc.resolve(n.$anchorCell.pos), f ? u.doc.resolve(f) : void 0)), o(u);
749
- }
750
- return !0;
751
- };
752
- }
753
- function Ht(t, e) {
754
- return function(o, n) {
755
- if (!R(o)) return !1;
756
- const l = Z(o);
757
- if (l.nodeAfter.attrs[t] === e) return !1;
758
- if (n) {
759
- const r = o.tr;
760
- o.selection instanceof w ? o.selection.forEachCell((s, i) => {
761
- s.attrs[t] !== e && r.setNodeMarkup(i, null, {
762
- ...s.attrs,
763
- [t]: e
764
- });
765
- }) : r.setNodeMarkup(l.pos, null, {
766
- ...l.nodeAfter.attrs,
767
- [t]: e
768
- }), n(r);
769
- }
770
- return !0;
771
- };
772
- }
773
- function Lt(t) {
774
- return function(e, o) {
775
- if (!R(e)) return !1;
776
- if (o) {
777
- const n = y(e.schema), l = M(e), r = e.tr, s = l.map.cellsInRect(t == "column" ? {
778
- left: l.left,
779
- top: 0,
780
- right: l.right,
781
- bottom: l.map.height
782
- } : t == "row" ? {
783
- left: 0,
784
- top: l.top,
785
- right: l.map.width,
786
- bottom: l.bottom
787
- } : l), i = s.map((c) => l.table.nodeAt(c));
788
- for (let c = 0; c < s.length; c++) i[c].type == n.header_cell && r.setNodeMarkup(l.tableStart + s[c], n.cell, i[c].attrs);
789
- if (r.steps.length === 0) for (let c = 0; c < s.length; c++) r.setNodeMarkup(l.tableStart + s[c], n.header_cell, i[c].attrs);
790
- o(r);
791
- }
792
- return !0;
793
- };
794
- }
795
- function me(t, e, o) {
796
- const n = e.map.cellsInRect({
797
- left: 0,
798
- top: 0,
799
- right: t == "row" ? e.map.width : 1,
800
- bottom: t == "column" ? e.map.height : 1
801
- });
802
- for (let l = 0; l < n.length; l++) {
803
- const r = e.table.nodeAt(n[l]);
804
- if (r && r.type !== o.header_cell) return !1;
805
- }
806
- return !0;
807
- }
808
- function I(t, e) {
809
- return e = e || { useDeprecatedLogic: !1 }, e.useDeprecatedLogic ? Lt(t) : function(o, n) {
810
- if (!R(o)) return !1;
811
- if (n) {
812
- const l = y(o.schema), r = M(o), s = o.tr, i = me("row", r, l), c = me("column", r, l), a = (t === "column" ? i : t === "row" && c) ? 1 : 0, d = t == "column" ? {
813
- left: 0,
814
- top: a,
815
- right: 1,
816
- bottom: r.map.height
817
- } : t == "row" ? {
818
- left: a,
819
- top: 0,
820
- right: r.map.width,
821
- bottom: 1
822
- } : r, u = t == "column" ? c ? l.cell : l.header_cell : t == "row" ? i ? l.cell : l.header_cell : l.cell;
823
- r.map.cellsInRect(d).forEach((f) => {
824
- const h = f + r.tableStart, p = s.doc.nodeAt(h);
825
- p && s.setNodeMarkup(h, u, p.attrs);
826
- }), n(s);
827
- }
828
- return !0;
829
- };
830
- }
831
- I("row", { useDeprecatedLogic: !0 });
832
- I("column", { useDeprecatedLogic: !0 });
833
- const Wt = I("cell", { useDeprecatedLogic: !0 });
834
- function $t(t, e) {
835
- if (e < 0) {
836
- const o = t.nodeBefore;
837
- if (o) return t.pos - o.nodeSize;
838
- for (let n = t.index(-1) - 1, l = t.before(); n >= 0; n--) {
839
- const r = t.node(-1).child(n), s = r.lastChild;
840
- if (s) return l - 1 - s.nodeSize;
841
- l -= r.nodeSize;
842
- }
843
- } else {
844
- if (t.index() < t.parent.childCount - 1) return t.pos + t.nodeAfter.nodeSize;
845
- const o = t.node(-1);
846
- for (let n = t.indexAfter(-1), l = t.after(); n < o.childCount; n++) {
847
- const r = o.child(n);
848
- if (r.childCount) return l + 1;
849
- l += r.nodeSize;
850
- }
851
- }
852
- return null;
853
- }
854
- function ge(t) {
855
- return function(e, o) {
856
- if (!R(e)) return !1;
857
- const n = $t(Z(e), t);
858
- if (n == null) return !1;
859
- if (o) {
860
- const l = e.doc.resolve(n);
861
- o(e.tr.setSelection(W.between(l, ft(l))).scrollIntoView());
862
- }
863
- return !0;
864
- };
865
- }
866
- function Dt(t, e) {
867
- const o = t.selection.$anchor;
868
- for (let n = o.depth; n > 0; n--) if (o.node(n).type.spec.tableRole == "table")
869
- return e && e(t.tr.delete(o.before(n), o.after(n)).scrollIntoView()), !0;
870
- return !1;
871
- }
872
- function V(t, e) {
873
- const o = t.selection;
874
- if (!(o instanceof w)) return !1;
875
- if (e) {
876
- const n = t.tr, l = y(t.schema).cell.createAndFill().content;
877
- o.forEachCell((r, s) => {
878
- r.content.eq(l) || n.replace(n.mapping.map(s + 1), n.mapping.map(s + r.nodeSize - 1), new L(l, 0, 0));
879
- }), n.docChanged && e(n);
880
- }
881
- return !0;
882
- }
883
- function Bt(t) {
884
- if (t.size === 0) return null;
885
- let { content: e, openStart: o, openEnd: n } = t;
886
- for (; e.childCount == 1 && (o > 0 && n > 0 || e.child(0).type.spec.tableRole == "table"); )
887
- o--, n--, e = e.child(0).content;
888
- const l = e.child(0), r = l.type.spec.tableRole, s = l.type.schema, i = [];
889
- if (r == "row") for (let c = 0; c < e.childCount; c++) {
890
- let a = e.child(c).content;
891
- const d = c ? 0 : Math.max(0, o - 1), u = c < e.childCount - 1 ? 0 : Math.max(0, n - 1);
892
- (d || u) && (a = ie(y(s).row, new L(a, d, u)).content), i.push(a);
893
- }
894
- else if (r == "cell" || r == "header_cell") i.push(o || n ? ie(y(s).row, new L(e, o, n)).content : e);
895
- else return null;
896
- return It(s, i);
897
- }
898
- function It(t, e) {
899
- const o = [];
900
- for (let l = 0; l < e.length; l++) {
901
- const r = e[l];
902
- for (let s = r.childCount - 1; s >= 0; s--) {
903
- const { rowspan: i, colspan: c } = r.child(s).attrs;
904
- for (let a = l; a < l + i; a++) o[a] = (o[a] || 0) + c;
905
- }
906
- }
907
- let n = 0;
908
- for (let l = 0; l < o.length; l++) n = Math.max(n, o[l]);
909
- for (let l = 0; l < o.length; l++)
910
- if (l >= e.length && e.push(v.empty), o[l] < n) {
911
- const r = y(t).cell.createAndFill(), s = [];
912
- for (let i = o[l]; i < n; i++) s.push(r);
913
- e[l] = e[l].append(v.from(s));
914
- }
915
- return {
916
- height: e.length,
917
- width: n,
918
- rows: e
919
- };
920
- }
921
- function ie(t, e) {
922
- const o = t.createAndFill();
923
- return new Xe(o).replace(0, o.content.size, e).doc;
924
- }
925
- function Pt({ width: t, height: e, rows: o }, n, l) {
926
- if (t != n) {
927
- const r = [], s = [];
928
- for (let i = 0; i < o.length; i++) {
929
- const c = o[i], a = [];
930
- for (let d = r[i] || 0, u = 0; d < n; u++) {
931
- let f = c.child(u % c.childCount);
932
- d + f.attrs.colspan > n && (f = f.type.createChecked(D(f.attrs, f.attrs.colspan, d + f.attrs.colspan - n), f.content)), a.push(f), d += f.attrs.colspan;
933
- for (let h = 1; h < f.attrs.rowspan; h++) r[i + h] = (r[i + h] || 0) + f.attrs.colspan;
934
- }
935
- s.push(v.from(a));
936
- }
937
- o = s, t = n;
938
- }
939
- if (e != l) {
940
- const r = [];
941
- for (let s = 0, i = 0; s < l; s++, i++) {
942
- const c = [], a = o[i % e];
943
- for (let d = 0; d < a.childCount; d++) {
944
- let u = a.child(d);
945
- s + u.attrs.rowspan > l && (u = u.type.create({
946
- ...u.attrs,
947
- rowspan: Math.max(1, l - u.attrs.rowspan)
948
- }, u.content)), c.push(u);
949
- }
950
- r.push(v.from(c));
951
- }
952
- o = r, e = l;
953
- }
954
- return {
955
- width: t,
956
- height: e,
957
- rows: o
958
- };
959
- }
960
- function _t(t, e, o, n, l, r, s) {
961
- const i = t.doc.type.schema, c = y(i);
962
- let a, d;
963
- if (l > e.width) for (let u = 0, f = 0; u < e.height; u++) {
964
- const h = o.child(u);
965
- f += h.nodeSize;
966
- const p = [];
967
- let m;
968
- h.lastChild == null || h.lastChild.type == c.cell ? m = a || (a = c.cell.createAndFill()) : m = d || (d = c.header_cell.createAndFill());
969
- for (let g = e.width; g < l; g++) p.push(m);
970
- t.insert(t.mapping.slice(s).map(f - 1 + n), p);
971
- }
972
- if (r > e.height) {
973
- const u = [];
974
- for (let p = 0, m = (e.height - 1) * e.width; p < Math.max(e.width, l); p++) {
975
- const g = p >= e.width ? !1 : o.nodeAt(e.map[m + p]).type == c.header_cell;
976
- u.push(g ? d || (d = c.header_cell.createAndFill()) : a || (a = c.cell.createAndFill()));
977
- }
978
- const f = c.row.create(null, v.from(u)), h = [];
979
- for (let p = e.height; p < r; p++) h.push(f);
980
- t.insert(t.mapping.slice(s).map(n + o.nodeSize - 2), h);
981
- }
982
- return !!(a || d);
983
- }
984
- function be(t, e, o, n, l, r, s, i) {
985
- if (s == 0 || s == e.height) return !1;
986
- let c = !1;
987
- for (let a = l; a < r; a++) {
988
- const d = s * e.width + a, u = e.map[d];
989
- if (e.map[d - e.width] == u) {
990
- c = !0;
991
- const f = o.nodeAt(u), { top: h, left: p } = e.findCell(u);
992
- t.setNodeMarkup(t.mapping.slice(i).map(u + n), null, {
993
- ...f.attrs,
994
- rowspan: s - h
995
- }), t.insert(t.mapping.slice(i).map(e.positionAt(s, p, o)), f.type.createAndFill({
996
- ...f.attrs,
997
- rowspan: h + f.attrs.rowspan - s
998
- })), a += f.attrs.colspan - 1;
999
- }
1000
- }
1001
- return c;
1002
- }
1003
- function we(t, e, o, n, l, r, s, i) {
1004
- if (s == 0 || s == e.width) return !1;
1005
- let c = !1;
1006
- for (let a = l; a < r; a++) {
1007
- const d = a * e.width + s, u = e.map[d];
1008
- if (e.map[d - 1] == u) {
1009
- c = !0;
1010
- const f = o.nodeAt(u), h = e.colCount(u), p = t.mapping.slice(i).map(u + n);
1011
- t.setNodeMarkup(p, null, D(f.attrs, s - h, f.attrs.colspan - (s - h))), t.insert(p + f.nodeSize, f.type.createAndFill(D(f.attrs, 0, s - h))), a += f.attrs.rowspan - 1;
1012
- }
1013
- }
1014
- return c;
1015
- }
1016
- function Ce(t, e, o, n, l) {
1017
- let r = o ? t.doc.nodeAt(o - 1) : t.doc;
1018
- if (!r) throw new Error("No table found");
1019
- let s = C.get(r);
1020
- const { top: i, left: c } = n, a = c + l.width, d = i + l.height, u = t.tr;
1021
- let f = 0;
1022
- function h() {
1023
- if (r = o ? u.doc.nodeAt(o - 1) : u.doc, !r) throw new Error("No table found");
1024
- s = C.get(r), f = u.mapping.maps.length;
1025
- }
1026
- _t(u, s, r, o, a, d, f) && h(), be(u, s, r, o, c, a, i, f) && h(), be(u, s, r, o, c, a, d, f) && h(), we(u, s, r, o, i, d, c, f) && h(), we(u, s, r, o, i, d, a, f) && h();
1027
- for (let p = i; p < d; p++) {
1028
- const m = s.positionAt(p, c, r), g = s.positionAt(p, a, r);
1029
- u.replace(u.mapping.slice(f).map(m + o), u.mapping.slice(f).map(g + o), new L(l.rows[p - i], 0, 0));
1030
- }
1031
- h(), u.setSelection(new w(u.doc.resolve(o + s.positionAt(i, c, r)), u.doc.resolve(o + s.positionAt(d - 1, a - 1, r)))), e(u);
1032
- }
1033
- const Ot = Ye({
1034
- ArrowLeft: K("horiz", -1),
1035
- ArrowRight: K("horiz", 1),
1036
- ArrowUp: K("vert", -1),
1037
- ArrowDown: K("vert", 1),
1038
- "Shift-ArrowLeft": X("horiz", -1),
1039
- "Shift-ArrowRight": X("horiz", 1),
1040
- "Shift-ArrowUp": X("vert", -1),
1041
- "Shift-ArrowDown": X("vert", 1),
1042
- Backspace: V,
1043
- "Mod-Backspace": V,
1044
- Delete: V,
1045
- "Mod-Delete": V
1046
- });
1047
- function G(t, e, o) {
1048
- return o.eq(t.selection) ? !1 : (e && e(t.tr.setSelection(o).scrollIntoView()), !0);
1049
- }
1050
- function K(t, e) {
1051
- return (o, n, l) => {
1052
- if (!l) return !1;
1053
- const r = o.selection;
1054
- if (r instanceof w) return G(o, n, E.near(r.$headCell, e));
1055
- if (t != "horiz" && !r.empty) return !1;
1056
- const s = Ie(l, t, e);
1057
- if (s == null) return !1;
1058
- if (t == "horiz") return G(o, n, E.near(o.doc.resolve(r.head + e), e));
1059
- {
1060
- const i = o.doc.resolve(s), c = ze(i, t, e);
1061
- let a;
1062
- return c ? a = E.near(c, 1) : e < 0 ? a = E.near(o.doc.resolve(i.before(-1)), -1) : a = E.near(o.doc.resolve(i.after(-1)), 1), G(o, n, a);
1063
- }
1064
- };
1065
- }
1066
- function X(t, e) {
1067
- return (o, n, l) => {
1068
- if (!l) return !1;
1069
- const r = o.selection;
1070
- let s;
1071
- if (r instanceof w) s = r;
1072
- else {
1073
- const c = Ie(l, t, e);
1074
- if (c == null) return !1;
1075
- s = new w(o.doc.resolve(c));
1076
- }
1077
- const i = ze(s.$headCell, t, e);
1078
- return i ? G(o, n, new w(s.$anchorCell, i)) : !1;
1079
- };
1080
- }
1081
- function Ft(t, e) {
1082
- const o = t.state.doc, n = $(o.resolve(e));
1083
- return n ? (t.dispatch(t.state.tr.setSelection(new w(n))), !0) : !1;
1084
- }
1085
- function jt(t, e, o) {
1086
- if (!R(t.state)) return !1;
1087
- let n = Bt(o);
1088
- const l = t.state.selection;
1089
- if (l instanceof w) {
1090
- n || (n = {
1091
- width: 1,
1092
- height: 1,
1093
- rows: [v.from(ie(y(t.state.schema).cell, o))]
1094
- });
1095
- const r = l.$anchorCell.node(-1), s = l.$anchorCell.start(-1), i = C.get(r).rectBetween(l.$anchorCell.pos - s, l.$headCell.pos - s);
1096
- return n = Pt(n, i.right - i.left, i.bottom - i.top), Ce(t.state, t.dispatch, s, i, n), !0;
1097
- } else if (n) {
1098
- const r = Z(t.state), s = r.start(-1);
1099
- return Ce(t.state, t.dispatch, s, C.get(r.node(-1)).findCell(r.pos - s), n), !0;
1100
- } else return !1;
1101
- }
1102
- function Vt(t, e) {
1103
- var o;
1104
- if (e.button != 0 || e.ctrlKey || e.metaKey) return;
1105
- const n = ye(t, e.target);
1106
- let l;
1107
- if (e.shiftKey && t.state.selection instanceof w)
1108
- r(t.state.selection.$anchorCell, e), e.preventDefault();
1109
- else if (e.shiftKey && n && (l = $(t.state.selection.$anchor)) != null && ((o = te(t, e)) === null || o === void 0 ? void 0 : o.pos) != l.pos)
1110
- r(l, e), e.preventDefault();
1111
- else if (!n) return;
1112
- function r(c, a) {
1113
- let d = te(t, a);
1114
- const u = H.getState(t.state) == null;
1115
- if (!d || !ue(c, d)) if (u) d = c;
1116
- else return;
1117
- const f = new w(c, d);
1118
- if (u || !t.state.selection.eq(f)) {
1119
- const h = t.state.tr.setSelection(f);
1120
- u && h.setMeta(H, c.pos), t.dispatch(h);
1121
- }
1122
- }
1123
- function s() {
1124
- t.root.removeEventListener("mouseup", s), t.root.removeEventListener("dragstart", s), t.root.removeEventListener("mousemove", i), H.getState(t.state) != null && t.dispatch(t.state.tr.setMeta(H, -1));
1125
- }
1126
- function i(c) {
1127
- const a = c, d = H.getState(t.state);
1128
- let u;
1129
- if (d != null) u = t.state.doc.resolve(d);
1130
- else if (ye(t, a.target) != n && (u = te(t, e), !u))
1131
- return s();
1132
- u && r(u, a);
1133
- }
1134
- t.root.addEventListener("mouseup", s), t.root.addEventListener("dragstart", s), t.root.addEventListener("mousemove", i);
1135
- }
1136
- function Ie(t, e, o) {
1137
- if (!(t.state.selection instanceof W)) return null;
1138
- const { $head: n } = t.state.selection;
1139
- for (let l = n.depth - 1; l >= 0; l--) {
1140
- const r = n.node(l);
1141
- if ((o < 0 ? n.index(l) : n.indexAfter(l)) != (o < 0 ? 0 : r.childCount)) return null;
1142
- if (r.type.spec.tableRole == "cell" || r.type.spec.tableRole == "header_cell") {
1143
- const s = n.before(l), i = e == "vert" ? o > 0 ? "down" : "up" : o > 0 ? "right" : "left";
1144
- return t.endOfTextblock(i) ? s : null;
1145
- }
1146
- }
1147
- return null;
1148
- }
1149
- function ye(t, e) {
1150
- for (; e && e != t.dom; e = e.parentNode) if (e.nodeName == "TD" || e.nodeName == "TH") return e;
1151
- return null;
1152
- }
1153
- function te(t, e) {
1154
- const o = t.posAtCoords({
1155
- left: e.clientX,
1156
- top: e.clientY
1157
- });
1158
- if (!o) return null;
1159
- let { inside: n, pos: l } = o;
1160
- return n >= 0 && $(t.state.doc.resolve(n)) || $(t.state.doc.resolve(l));
1161
- }
1162
- var Kt = class {
1163
- constructor(e, o) {
1164
- this.node = e, this.defaultCellMinWidth = o, this.dom = document.createElement("div"), this.dom.className = "tableWrapper", this.table = this.dom.appendChild(document.createElement("table")), this.table.style.setProperty("--default-cell-min-width", `${o}px`), this.colgroup = this.table.appendChild(document.createElement("colgroup")), ce(e, this.colgroup, this.table, o), this.contentDOM = this.table.appendChild(document.createElement("tbody"));
1165
- }
1166
- update(e) {
1167
- return e.type != this.node.type ? !1 : (this.node = e, ce(e, this.colgroup, this.table, this.defaultCellMinWidth), !0);
1168
- }
1169
- ignoreMutation(e) {
1170
- return e.type == "attributes" && (e.target == this.table || this.colgroup.contains(e.target));
1171
- }
1172
- };
1173
- function ce(t, e, o, n, l, r) {
1174
- let s = 0, i = !0, c = e.firstChild;
1175
- const a = t.firstChild;
1176
- if (a) {
1177
- for (let u = 0, f = 0; u < a.childCount; u++) {
1178
- const { colspan: h, colwidth: p } = a.child(u).attrs;
1179
- for (let m = 0; m < h; m++, f++) {
1180
- const g = l == f ? r : p && p[m], b = g ? g + "px" : "";
1181
- if (s += g || n, g || (i = !1), c)
1182
- c.style.width != b && (c.style.width = b), c = c.nextSibling;
1183
- else {
1184
- const S = document.createElement("col");
1185
- S.style.width = b, e.appendChild(S);
1186
- }
1187
- }
1188
- }
1189
- for (; c; ) {
1190
- var d;
1191
- const u = c.nextSibling;
1192
- (d = c.parentNode) === null || d === void 0 || d.removeChild(c), c = u;
1193
- }
1194
- i ? (o.style.width = s + "px", o.style.minWidth = "") : (o.style.width = "", o.style.minWidth = s + "px");
1195
- }
1196
- }
1197
- const x = new de("tableColumnResizing");
1198
- function Xt({ handleWidth: t = 5, cellMinWidth: e = 25, defaultCellMinWidth: o = 100, View: n = Kt, lastColumnResizable: l = !0 } = {}) {
1199
- const r = new ke({
1200
- key: x,
1201
- state: {
1202
- init(s, i) {
1203
- var c;
1204
- const a = (c = r.spec) === null || c === void 0 || (c = c.props) === null || c === void 0 ? void 0 : c.nodeViews, d = y(i.schema).table.name;
1205
- return n && a && (a[d] = (u, f) => new n(u, o, f)), new Ut(-1, !1);
1206
- },
1207
- apply(s, i) {
1208
- return i.apply(s);
1209
- }
1210
- },
1211
- props: {
1212
- attributes: (s) => {
1213
- const i = x.getState(s);
1214
- return i && i.activeHandle > -1 ? { class: "resize-cursor" } : {};
1215
- },
1216
- handleDOMEvents: {
1217
- mousemove: (s, i) => {
1218
- Gt(s, i, t, l);
1219
- },
1220
- mouseleave: (s) => {
1221
- qt(s);
1222
- },
1223
- mousedown: (s, i) => {
1224
- Jt(s, i, e, o);
1225
- }
1226
- },
1227
- decorations: (s) => {
1228
- const i = x.getState(s);
1229
- if (i && i.activeHandle > -1) return to(s, i.activeHandle);
1230
- },
1231
- nodeViews: {}
1232
- }
1233
- });
1234
- return r;
1235
- }
1236
- var Ut = class q {
1237
- constructor(e, o) {
1238
- this.activeHandle = e, this.dragging = o;
1239
- }
1240
- apply(e) {
1241
- const o = this, n = e.getMeta(x);
1242
- if (n && n.setHandle != null) return new q(n.setHandle, !1);
1243
- if (n && n.setDragging !== void 0) return new q(o.activeHandle, n.setDragging);
1244
- if (o.activeHandle > -1 && e.docChanged) {
1245
- let l = e.mapping.map(o.activeHandle, -1);
1246
- return se(e.doc.resolve(l)) || (l = -1), new q(l, o.dragging);
1247
- }
1248
- return o;
1249
- }
1250
- };
1251
- function Gt(t, e, o, n) {
1252
- if (!t.editable) return;
1253
- const l = x.getState(t.state);
1254
- if (l && !l.dragging) {
1255
- const r = Zt(e.target);
1256
- let s = -1;
1257
- if (r) {
1258
- const { left: i, right: c } = r.getBoundingClientRect();
1259
- e.clientX - i <= o ? s = Se(t, e, "left", o) : c - e.clientX <= o && (s = Se(t, e, "right", o));
1260
- }
1261
- if (s != l.activeHandle) {
1262
- if (!n && s !== -1) {
1263
- const i = t.state.doc.resolve(s), c = i.node(-1), a = C.get(c), d = i.start(-1);
1264
- if (a.colCount(i.pos - d) + i.nodeAfter.attrs.colspan - 1 == a.width - 1) return;
1265
- }
1266
- Pe(t, s);
1267
- }
1268
- }
1269
- }
1270
- function qt(t) {
1271
- if (!t.editable) return;
1272
- const e = x.getState(t.state);
1273
- e && e.activeHandle > -1 && !e.dragging && Pe(t, -1);
1274
- }
1275
- function Jt(t, e, o, n) {
1276
- var l;
1277
- if (!t.editable) return !1;
1278
- const r = (l = t.dom.ownerDocument.defaultView) !== null && l !== void 0 ? l : window, s = x.getState(t.state);
1279
- if (!s || s.activeHandle == -1 || s.dragging) return !1;
1280
- const i = t.state.doc.nodeAt(s.activeHandle), c = Yt(t, s.activeHandle, i.attrs);
1281
- t.dispatch(t.state.tr.setMeta(x, { setDragging: {
1282
- startX: e.clientX,
1283
- startWidth: c
1284
- } }));
1285
- function a(u) {
1286
- r.removeEventListener("mouseup", a), r.removeEventListener("mousemove", d);
1287
- const f = x.getState(t.state);
1288
- f != null && f.dragging && (Qt(t, f.activeHandle, xe(f.dragging, u, o)), t.dispatch(t.state.tr.setMeta(x, { setDragging: null })));
1289
- }
1290
- function d(u) {
1291
- if (!u.which) return a(u);
1292
- const f = x.getState(t.state);
1293
- if (f && f.dragging) {
1294
- const h = xe(f.dragging, u, o);
1295
- Ae(t, f.activeHandle, h, n);
1296
- }
1297
- }
1298
- return Ae(t, s.activeHandle, c, n), r.addEventListener("mouseup", a), r.addEventListener("mousemove", d), e.preventDefault(), !0;
1299
- }
1300
- function Yt(t, e, { colspan: o, colwidth: n }) {
1301
- const l = n && n[n.length - 1];
1302
- if (l) return l;
1303
- const r = t.domAtPos(e);
1304
- let s = r.node.childNodes[r.offset].offsetWidth, i = o;
1305
- if (n)
1306
- for (let c = 0; c < o; c++) n[c] && (s -= n[c], i--);
1307
- return s / i;
1308
- }
1309
- function Zt(t) {
1310
- for (; t && t.nodeName != "TD" && t.nodeName != "TH"; ) t = t.classList && t.classList.contains("ProseMirror") ? null : t.parentNode;
1311
- return t;
1312
- }
1313
- function Se(t, e, o, n) {
1314
- const l = o == "right" ? -n : n, r = t.posAtCoords({
1315
- left: e.clientX + l,
1316
- top: e.clientY
1317
- });
1318
- if (!r) return -1;
1319
- const { pos: s } = r, i = $(t.state.doc.resolve(s));
1320
- if (!i) return -1;
1321
- if (o == "right") return i.pos;
1322
- const c = C.get(i.node(-1)), a = i.start(-1), d = c.map.indexOf(i.pos - a);
1323
- return d % c.width == 0 ? -1 : a + c.map[d - 1];
1324
- }
1325
- function xe(t, e, o) {
1326
- const n = e.clientX - t.startX;
1327
- return Math.max(o, t.startWidth + n);
1328
- }
1329
- function Pe(t, e) {
1330
- t.dispatch(t.state.tr.setMeta(x, { setHandle: e }));
1331
- }
1332
- function Qt(t, e, o) {
1333
- const n = t.state.doc.resolve(e), l = n.node(-1), r = C.get(l), s = n.start(-1), i = r.colCount(n.pos - s) + n.nodeAfter.attrs.colspan - 1, c = t.state.tr;
1334
- for (let a = 0; a < r.height; a++) {
1335
- const d = a * r.width + i;
1336
- if (a && r.map[d] == r.map[d - r.width]) continue;
1337
- const u = r.map[d], f = l.nodeAt(u).attrs, h = f.colspan == 1 ? 0 : i - r.colCount(u);
1338
- if (f.colwidth && f.colwidth[h] == o) continue;
1339
- const p = f.colwidth ? f.colwidth.slice() : eo(f.colspan);
1340
- p[h] = o, c.setNodeMarkup(s + u, null, {
1341
- ...f,
1342
- colwidth: p
1343
- });
1344
- }
1345
- c.docChanged && t.dispatch(c);
1346
- }
1347
- function Ae(t, e, o, n) {
1348
- const l = t.state.doc.resolve(e), r = l.node(-1), s = l.start(-1), i = C.get(r).colCount(l.pos - s) + l.nodeAfter.attrs.colspan - 1;
1349
- let c = t.domAtPos(l.start(-1)).node;
1350
- for (; c && c.nodeName != "TABLE"; ) c = c.parentNode;
1351
- c && ce(r, c.firstChild, c, n, i, o);
1352
- }
1353
- function eo(t) {
1354
- return Array(t).fill(0);
1355
- }
1356
- function to(t, e) {
1357
- const o = [], n = t.doc.resolve(e), l = n.node(-1);
1358
- if (!l) return oe.empty;
1359
- const r = C.get(l), s = n.start(-1), i = r.colCount(n.pos - s) + n.nodeAfter.attrs.colspan - 1;
1360
- for (let a = 0; a < r.height; a++) {
1361
- const d = i + a * r.width;
1362
- if ((i == r.width - 1 || r.map[d] != r.map[d + 1]) && (a == 0 || r.map[d] != r.map[d - r.width])) {
1363
- var c;
1364
- const u = r.map[d], f = s + u + l.nodeAt(u).nodeSize - 1, h = document.createElement("div");
1365
- h.className = "column-resize-handle", !((c = x.getState(t)) === null || c === void 0) && c.dragging && o.push(ne.node(s + u, s + u + l.nodeAt(u).nodeSize, { class: "column-resize-dragging" })), o.push(ne.widget(f, h));
1366
- }
1367
- }
1368
- return oe.create(t.doc, o);
1369
- }
1370
- function oo({ allowTableNodeSelection: t = !1 } = {}) {
1371
- return new ke({
1372
- key: H,
1373
- state: {
1374
- init() {
1375
- return null;
1376
- },
1377
- apply(e, o) {
1378
- const n = e.getMeta(H);
1379
- if (n != null) return n == -1 ? null : n;
1380
- if (o == null || !e.docChanged) return o;
1381
- const { deleted: l, pos: r } = e.mapping.mapResult(o);
1382
- return l ? null : r;
1383
- }
1384
- },
1385
- props: {
1386
- decorations: mt,
1387
- handleDOMEvents: { mousedown: Vt },
1388
- createSelectionBetween(e) {
1389
- return H.getState(e.state) != null ? e.state.selection : null;
1390
- },
1391
- handleTripleClick: Ft,
1392
- handleKeyDown: Ot,
1393
- handlePaste: jt
1394
- },
1395
- appendTransaction(e, o, n) {
1396
- return wt(n, $e(n, o), t);
1397
- }
1398
- });
1399
- }
1400
- var _e = J.create({
1401
- name: "tableCell",
1402
- addOptions() {
1403
- return {
1404
- HTMLAttributes: {}
1405
- };
1406
- },
1407
- content: "block+",
1408
- addAttributes() {
1409
- return {
1410
- colspan: {
1411
- default: 1
1412
- },
1413
- rowspan: {
1414
- default: 1
1415
- },
1416
- colwidth: {
1417
- default: null,
1418
- parseHTML: (t) => {
1419
- var e, o;
1420
- const n = t.getAttribute("colwidth"), l = n ? n.split(",").map((r) => parseInt(r, 10)) : null;
1421
- if (!l) {
1422
- const r = (e = t.closest("table")) == null ? void 0 : e.querySelectorAll("colgroup > col"), s = Array.from(((o = t.parentElement) == null ? void 0 : o.children) || []).indexOf(t);
1423
- if (s && s > -1 && r && r[s]) {
1424
- const i = r[s].getAttribute("width");
1425
- return i ? [parseInt(i, 10)] : null;
1426
- }
1427
- }
1428
- return l;
1429
- }
1430
- }
1431
- };
1432
- },
1433
- tableRole: "cell",
1434
- isolating: !0,
1435
- parseHTML() {
1436
- return [{ tag: "td" }];
1437
- },
1438
- renderHTML({ HTMLAttributes: t }) {
1439
- return ["td", Y(this.options.HTMLAttributes, t), 0];
1440
- }
1441
- }), Oe = J.create({
1442
- name: "tableHeader",
1443
- addOptions() {
1444
- return {
1445
- HTMLAttributes: {}
1446
- };
1447
- },
1448
- content: "block+",
1449
- addAttributes() {
1450
- return {
1451
- colspan: {
1452
- default: 1
1453
- },
1454
- rowspan: {
1455
- default: 1
1456
- },
1457
- colwidth: {
1458
- default: null,
1459
- parseHTML: (t) => {
1460
- const e = t.getAttribute("colwidth");
1461
- return e ? e.split(",").map((n) => parseInt(n, 10)) : null;
1462
- }
1463
- }
1464
- };
1465
- },
1466
- tableRole: "header_cell",
1467
- isolating: !0,
1468
- parseHTML() {
1469
- return [{ tag: "th" }];
1470
- },
1471
- renderHTML({ HTMLAttributes: t }) {
1472
- return ["th", Y(this.options.HTMLAttributes, t), 0];
1473
- }
1474
- }), Fe = J.create({
1475
- name: "tableRow",
1476
- addOptions() {
1477
- return {
1478
- HTMLAttributes: {}
1479
- };
1480
- },
1481
- content: "(tableCell | tableHeader)*",
1482
- tableRole: "row",
1483
- parseHTML() {
1484
- return [{ tag: "tr" }];
1485
- },
1486
- renderHTML({ HTMLAttributes: t }) {
1487
- return ["tr", Y(this.options.HTMLAttributes, t), 0];
1488
- }
1489
- });
1490
- function ae(t, e) {
1491
- return e ? ["width", `${Math.max(e, t)}px`] : ["min-width", `${t}px`];
1492
- }
1493
- function Te(t, e, o, n, l, r) {
1494
- var s;
1495
- let i = 0, c = !0, a = e.firstChild;
1496
- const d = t.firstChild;
1497
- if (d !== null)
1498
- for (let f = 0, h = 0; f < d.childCount; f += 1) {
1499
- const { colspan: p, colwidth: m } = d.child(f).attrs;
1500
- for (let g = 0; g < p; g += 1, h += 1) {
1501
- const b = l === h ? r : m && m[g], S = b ? `${b}px` : "";
1502
- if (i += b || n, b || (c = !1), a) {
1503
- if (a.style.width !== S) {
1504
- const [A, z] = ae(n, b);
1505
- a.style.setProperty(A, z);
1506
- }
1507
- a = a.nextSibling;
1508
- } else {
1509
- const A = document.createElement("col"), [z, T] = ae(n, b);
1510
- A.style.setProperty(z, T), e.appendChild(A);
1511
- }
1512
- }
1513
- }
1514
- for (; a; ) {
1515
- const f = a.nextSibling;
1516
- (s = a.parentNode) == null || s.removeChild(a), a = f;
1517
- }
1518
- const u = t.attrs.style && typeof t.attrs.style == "string" && /\bwidth\s*:/i.test(t.attrs.style);
1519
- c && !u ? (o.style.width = `${i}px`, o.style.minWidth = "") : (o.style.width = "", o.style.minWidth = `${i}px`);
1520
- }
1521
- var no = class {
1522
- constructor(t, e) {
1523
- this.node = t, this.cellMinWidth = e, this.dom = document.createElement("div"), this.dom.className = "tableWrapper", this.table = this.dom.appendChild(document.createElement("table")), t.attrs.style && (this.table.style.cssText = t.attrs.style), this.colgroup = this.table.appendChild(document.createElement("colgroup")), Te(t, this.colgroup, this.table, e), this.contentDOM = this.table.appendChild(document.createElement("tbody"));
1524
- }
1525
- update(t) {
1526
- return t.type !== this.node.type ? !1 : (this.node = t, Te(t, this.colgroup, this.table, this.cellMinWidth), !0);
1527
- }
1528
- ignoreMutation(t) {
1529
- const e = t.target, o = this.dom.contains(e), n = this.contentDOM.contains(e);
1530
- return !!(o && !n && (t.type === "attributes" || t.type === "childList" || t.type === "characterData"));
1531
- }
1532
- };
1533
- function lo(t, e, o, n) {
1534
- let l = 0, r = !0;
1535
- const s = [], i = t.firstChild;
1536
- if (!i)
1537
- return {};
1538
- for (let u = 0, f = 0; u < i.childCount; u += 1) {
1539
- const { colspan: h, colwidth: p } = i.child(u).attrs;
1540
- for (let m = 0; m < h; m += 1, f += 1) {
1541
- const g = o === f ? n : p && p[m];
1542
- l += g || e, g || (r = !1);
1543
- const [b, S] = ae(e, g);
1544
- s.push(["col", { style: `${b}: ${S}` }]);
1545
- }
1546
- }
1547
- const c = r ? `${l}px` : "", a = r ? "" : `${l}px`;
1548
- return { colgroup: ["colgroup", {}, ...s], tableWidth: c, tableMinWidth: a };
1549
- }
1550
- function Re(t, e) {
1551
- return t.createAndFill();
1552
- }
1553
- function ro(t) {
1554
- if (t.cached.tableNodeTypes)
1555
- return t.cached.tableNodeTypes;
1556
- const e = {};
1557
- return Object.keys(t.nodes).forEach((o) => {
1558
- const n = t.nodes[o];
1559
- n.spec.tableRole && (e[n.spec.tableRole] = n);
1560
- }), t.cached.tableNodeTypes = e, e;
1561
- }
1562
- function so(t, e, o, n, l) {
1563
- const r = ro(t), s = [], i = [];
1564
- for (let a = 0; a < o; a += 1) {
1565
- const d = Re(r.cell);
1566
- if (d && i.push(d), n) {
1567
- const u = Re(r.header_cell);
1568
- u && s.push(u);
1569
- }
1570
- }
1571
- const c = [];
1572
- for (let a = 0; a < e; a += 1)
1573
- c.push(r.row.createChecked(null, n && a === 0 ? s : i));
1574
- return r.table.createChecked(null, c);
1575
- }
1576
- function io(t) {
1577
- return t instanceof w;
1578
- }
1579
- var U = ({ editor: t }) => {
1580
- const { selection: e } = t.state;
1581
- if (!io(e))
1582
- return !1;
1583
- let o = 0;
1584
- const n = qe(e.ranges[0].$from, (r) => r.type.name === "table");
1585
- return n == null || n.node.descendants((r) => {
1586
- if (r.type.name === "table")
1587
- return !1;
1588
- ["tableCell", "tableHeader"].includes(r.type.name) && (o += 1);
1589
- }), o === e.ranges.length ? (t.commands.deleteTable(), !0) : !1;
1590
- }, co = "";
1591
- function ao(t) {
1592
- return (t || "").replace(/\s+/g, " ").trim();
1593
- }
1594
- function uo(t, e, o = {}) {
1595
- var n;
1596
- const l = (n = o.cellLineSeparator) != null ? n : co;
1597
- if (!t || !t.content || t.content.length === 0)
1598
- return "";
1599
- const r = [];
1600
- t.content.forEach((p) => {
1601
- const m = [];
1602
- p.content && p.content.forEach((g) => {
1603
- let b = "";
1604
- g.content && Array.isArray(g.content) && g.content.length > 1 ? b = g.content.map((T) => e.renderChildren(T)).join(l) : b = g.content ? e.renderChildren(g.content) : "";
1605
- const S = ao(b), A = g.type === "tableHeader";
1606
- m.push({ text: S, isHeader: A });
1607
- }), r.push(m);
1608
- });
1609
- const s = r.reduce((p, m) => Math.max(p, m.length), 0);
1610
- if (s === 0)
1611
- return "";
1612
- const i = new Array(s).fill(0);
1613
- r.forEach((p) => {
1614
- var m;
1615
- for (let g = 0; g < s; g += 1) {
1616
- const S = (((m = p[g]) == null ? void 0 : m.text) || "").length;
1617
- S > i[g] && (i[g] = S), i[g] < 3 && (i[g] = 3);
1618
- }
1619
- });
1620
- const c = (p, m) => p + " ".repeat(Math.max(0, m - p.length)), a = r[0], d = a.some((p) => p.isHeader);
1621
- let u = `
1622
- `;
1623
- const f = new Array(s).fill(0).map((p, m) => d && a[m] && a[m].text || "");
1624
- return u += `| ${f.map((p, m) => c(p, i[m])).join(" | ")} |
1625
- `, u += `| ${i.map((p) => "-".repeat(Math.max(3, p))).join(" | ")} |
1626
- `, (d ? r.slice(1) : r).forEach((p) => {
1627
- u += `| ${new Array(s).fill(0).map((m, g) => c(p[g] && p[g].text || "", i[g])).join(" | ")} |
1628
- `;
1629
- }), u;
1630
- }
1631
- var fo = uo, je = J.create({
1632
- name: "table",
1633
- // @ts-ignore
1634
- addOptions() {
1635
- return {
1636
- HTMLAttributes: {},
1637
- resizable: !1,
1638
- renderWrapper: !1,
1639
- handleWidth: 5,
1640
- cellMinWidth: 25,
1641
- // TODO: fix
1642
- View: no,
1643
- lastColumnResizable: !0,
1644
- allowTableNodeSelection: !1
1645
- };
1646
- },
1647
- content: "tableRow+",
1648
- tableRole: "table",
1649
- isolating: !0,
1650
- group: "block",
1651
- parseHTML() {
1652
- return [{ tag: "table" }];
1653
- },
1654
- renderHTML({ node: t, HTMLAttributes: e }) {
1655
- const { colgroup: o, tableWidth: n, tableMinWidth: l } = lo(t, this.options.cellMinWidth), r = e.style;
1656
- function s() {
1657
- return r || (n ? `width: ${n}` : `min-width: ${l}`);
1658
- }
1659
- const i = [
1660
- "table",
1661
- Y(this.options.HTMLAttributes, e, {
1662
- style: s()
1663
- }),
1664
- o,
1665
- ["tbody", 0]
1666
- ];
1667
- return this.options.renderWrapper ? ["div", { class: "tableWrapper" }, i] : i;
1668
- },
1669
- parseMarkdown: (t, e) => {
1670
- const o = [];
1671
- if (t.header) {
1672
- const n = [];
1673
- t.header.forEach((l) => {
1674
- n.push(e.createNode("tableHeader", {}, [{ type: "paragraph", content: e.parseInline(l.tokens) }]));
1675
- }), o.push(e.createNode("tableRow", {}, n));
1676
- }
1677
- return t.rows && t.rows.forEach((n) => {
1678
- const l = [];
1679
- n.forEach((r) => {
1680
- l.push(e.createNode("tableCell", {}, [{ type: "paragraph", content: e.parseInline(r.tokens) }]));
1681
- }), o.push(e.createNode("tableRow", {}, l));
1682
- }), e.createNode("table", void 0, o);
1683
- },
1684
- renderMarkdown: (t, e) => fo(t, e),
1685
- addCommands() {
1686
- return {
1687
- insertTable: ({ rows: t = 3, cols: e = 3, withHeaderRow: o = !0 } = {}) => ({ tr: n, dispatch: l, editor: r }) => {
1688
- const s = so(r.schema, t, e, o);
1689
- if (l) {
1690
- const i = n.selection.from + 1;
1691
- n.replaceSelectionWith(s).scrollIntoView().setSelection(Je.near(n.doc.resolve(i)));
1692
- }
1693
- return !0;
1694
- },
1695
- addColumnBefore: () => ({ state: t, dispatch: e }) => St(t, e),
1696
- addColumnAfter: () => ({ state: t, dispatch: e }) => xt(t, e),
1697
- deleteColumn: () => ({ state: t, dispatch: e }) => Tt(t, e),
1698
- addRowBefore: () => ({ state: t, dispatch: e }) => vt(t, e),
1699
- addRowAfter: () => ({ state: t, dispatch: e }) => Mt(t, e),
1700
- deleteRow: () => ({ state: t, dispatch: e }) => kt(t, e),
1701
- deleteTable: () => ({ state: t, dispatch: e }) => Dt(t, e),
1702
- mergeCells: () => ({ state: t, dispatch: e }) => he(t, e),
1703
- splitCell: () => ({ state: t, dispatch: e }) => pe(t, e),
1704
- toggleHeaderColumn: () => ({ state: t, dispatch: e }) => I("column")(t, e),
1705
- toggleHeaderRow: () => ({ state: t, dispatch: e }) => I("row")(t, e),
1706
- toggleHeaderCell: () => ({ state: t, dispatch: e }) => Wt(t, e),
1707
- mergeOrSplit: () => ({ state: t, dispatch: e }) => he(t, e) ? !0 : pe(t, e),
1708
- setCellAttribute: (t, e) => ({ state: o, dispatch: n }) => Ht(t, e)(o, n),
1709
- goToNextCell: () => ({ state: t, dispatch: e }) => ge(1)(t, e),
1710
- goToPreviousCell: () => ({ state: t, dispatch: e }) => ge(-1)(t, e),
1711
- fixTables: () => ({ state: t, dispatch: e }) => (e && $e(t), !0),
1712
- setCellSelection: (t) => ({ tr: e, dispatch: o }) => {
1713
- if (o) {
1714
- const n = w.create(e.doc, t.anchorCell, t.headCell);
1715
- e.setSelection(n);
1716
- }
1717
- return !0;
1718
- }
1719
- };
1720
- },
1721
- addKeyboardShortcuts() {
1722
- return {
1723
- Tab: () => this.editor.commands.goToNextCell() ? !0 : this.editor.can().addRowAfter() ? this.editor.chain().addRowAfter().goToNextCell().run() : !1,
1724
- "Shift-Tab": () => this.editor.commands.goToPreviousCell(),
1725
- Backspace: U,
1726
- "Mod-Backspace": U,
1727
- Delete: U,
1728
- "Mod-Delete": U
1729
- };
1730
- },
1731
- addProseMirrorPlugins() {
1732
- return [
1733
- ...this.options.resizable && this.editor.isEditable ? [
1734
- Xt({
1735
- handleWidth: this.options.handleWidth,
1736
- cellMinWidth: this.options.cellMinWidth,
1737
- defaultCellMinWidth: this.options.cellMinWidth,
1738
- View: this.options.View,
1739
- lastColumnResizable: this.options.lastColumnResizable
1740
- })
1741
- ] : [],
1742
- oo({
1743
- allowTableNodeSelection: this.options.allowTableNodeSelection
1744
- })
1745
- ];
1746
- },
1747
- extendNodeSchema(t) {
1748
- const e = {
1749
- name: t.name,
1750
- options: t.options,
1751
- storage: t.storage
1752
- };
1753
- return {
1754
- tableRole: Ue(Ge(t, "tableRole", e))
1755
- };
1756
- }
1757
- });
1758
- Ee.create({
1759
- name: "tableKit",
1760
- addExtensions() {
1761
- const t = [];
1762
- return this.options.table !== !1 && t.push(je.configure(this.options.table)), this.options.tableCell !== !1 && t.push(_e.configure(this.options.tableCell)), this.options.tableHeader !== !1 && t.push(Oe.configure(this.options.tableHeader)), this.options.tableRow !== !1 && t.push(Fe.configure(this.options.tableRow)), t;
1763
- }
1764
- });
1765
- function ho(t, e, o) {
1766
- if (!t.doc)
1767
- return t;
1768
- const n = t.doc.nodeAt(e);
1769
- if (!n || o === n.attrs.backgroundColor)
1770
- return t;
1771
- const l = {
1772
- ...n.attrs,
1773
- backgroundColor: o
1774
- };
1775
- return t.setNodeMarkup(e, n.type, l, n.marks);
1776
- }
1777
- function po(t, e, o) {
1778
- const { doc: n, selection: l } = t;
1779
- return !n || !l || !(l instanceof w) || l.forEachCell((r, s) => {
1780
- t = ho(t, s, o);
1781
- }), t;
1782
- }
1783
- function ve(t, e) {
1784
- return ({ tr: o, state: n, dispatch: l }) => {
1785
- const { selection: r } = n;
1786
- return o = o.setSelection(r), o = po(o, e, t), o.docChanged ? (l == null || l(o), !0) : !1;
1787
- };
1788
- }
1789
- const mo = Ee.create({
1790
- name: "tableCellBackground",
1791
- addOptions() {
1792
- return {
1793
- types: ["tableCell"],
1794
- HTMLAttributes: {}
1795
- };
1796
- },
1797
- addGlobalAttributes() {
1798
- return [
1799
- {
1800
- types: this.options.types,
1801
- attributes: {
1802
- backgroundColor: {
1803
- parseHTML: (t) => t.style.backgroundColor || "",
1804
- renderHTML: (t) => !t.backgroundColor || t.backgroundColor === "" ? {} : {
1805
- style: `background-color: ${t.backgroundColor}`
1806
- }
1807
- }
1808
- }
1809
- }
1810
- ];
1811
- },
1812
- addCommands() {
1813
- return {
1814
- setTableCellBackground: (t) => ve(t, this.options),
1815
- unsetTableCellBackground: () => ve("", this.options)
1816
- };
1817
- }
1818
- }), go = /(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i, bo = /CrOS/, wo = /android|ipad|playbook|silk/i;
1819
- function Me(t = {}) {
1820
- let e = t.ua || typeof navigator < "u" && navigator.userAgent;
1821
- return e && typeof e == "object" && e.headers && typeof e.headers["user-agent"] == "string" && (e = e.headers["user-agent"]), typeof e != "string" ? !1 : !!(go.test(e) && !bo.test(e) || t.tablet && wo.test(e) || t.tablet && t.featureDetect && navigator && navigator.maxTouchPoints > 1 && e.includes("Macintosh") && e.includes("Safari"));
1822
- }
1823
- const Ne = (t) => Array.from({ length: t }).map((e, o) => o + 1);
1824
- function Co(t) {
1825
- var f;
1826
- const [e, o] = _(!1), [n, l] = _(!0), [r, s] = _({
1827
- rows: Me() ? O : F,
1828
- cols: Me() ? O : F
1829
- }), [i, c] = _({
1830
- rows: j,
1831
- cols: j
1832
- });
1833
- function a(h, p) {
1834
- h === r.rows && s((m) => ({
1835
- ...m,
1836
- rows: Math.min(h + 1, O)
1837
- })), p === r.cols && s((m) => ({
1838
- ...m,
1839
- cols: Math.min(p + 1, O)
1840
- })), c({
1841
- rows: h,
1842
- cols: p
1843
- });
1844
- }
1845
- function d(h, p) {
1846
- t == null || t.createTable({ rows: h, cols: p, withHeaderRow: n }), u(), o(!1);
1847
- }
1848
- function u() {
1849
- l(!1), s({
1850
- rows: F,
1851
- cols: F
1852
- }), c({
1853
- rows: j,
1854
- cols: j
1855
- });
1856
- }
1857
- return /* @__PURE__ */ ee(nt, { modal: !0, onOpenChange: o, open: e, children: [
1858
- /* @__PURE__ */ k(lt, { asChild: !0, "data-state": t != null && t.dataState ? "on" : "off", children: t == null ? void 0 : t.children }),
1859
- /* @__PURE__ */ k(rt, { align: "start", className: "richtext-w-full !richtext-p-2", side: "bottom", children: /* @__PURE__ */ ee("div", { className: "table-grid-size-editor richtext-p-0", children: [
1860
- /* @__PURE__ */ k("div", { className: "richtext-flex richtext-flex-col richtext-flex-wrap richtext-justify-between richtext-gap-1", children: (f = Ne(r == null ? void 0 : r.rows)) == null ? void 0 : f.map((h) => {
1861
- var p;
1862
- return /* @__PURE__ */ k("div", { className: "richtext-flex richtext-gap-1", children: (p = Ne(r == null ? void 0 : r.cols)) == null ? void 0 : p.map((m) => /* @__PURE__ */ k(
1863
- "div",
1864
- {
1865
- onMouseDown: () => d(h, m),
1866
- onMouseOver: () => a(h, m),
1867
- className: `richtext-cursor-pointer richtext-border-border ${m <= i.cols && h <= i.rows && "tableCellActive !richtext-bg-foreground"}`,
1868
- children: /* @__PURE__ */ k("div", { className: "richtext-box-border richtext-size-4 richtext-rounded-[2px] !richtext-border richtext-border-solid !richtext-border-border richtext-p-1" })
1869
- },
1870
- `richtext-table-col-${m}`
1871
- )) }, `richtext-table-row-${h}`);
1872
- }) }),
1873
- /* @__PURE__ */ ee("div", { className: "richtext-mt-2 richtext-text-center richtext-text-sm richtext-text-foreground", children: [
1874
- i.rows,
1875
- "x",
1876
- i.cols
1877
- ] })
1878
- ] }) })
1879
- ] });
1880
- }
1881
- function zo() {
1882
- const t = Qe(), e = et(yo.name), {
1883
- icon: o = void 0,
1884
- tooltip: n = void 0,
1885
- action: l = void 0,
1886
- isActive: r = void 0,
1887
- color: s
1888
- } = (e == null ? void 0 : e.componentProps) ?? {}, { dataState: i, disabled: c } = tt(r);
1889
- if (!e)
1890
- return /* @__PURE__ */ k(Ze, {});
1891
- function a(d) {
1892
- t.chain().focus().insertTable({ ...d, withHeaderRow: !1 }).run();
1893
- }
1894
- return /* @__PURE__ */ k(Co, { createTable: a, dataState: i, children: /* @__PURE__ */ k(
1895
- ot,
1896
- {
1897
- action: l,
1898
- color: s,
1899
- dataState: i,
1900
- icon: o,
1901
- isActive: r,
1902
- tooltip: n,
1903
- disabled: c
1904
- }
1905
- ) });
1906
- }
1907
- const yo = /* @__PURE__ */ je.extend({
1908
- //@ts-expect-error
1909
- addOptions() {
1910
- var t;
1911
- return {
1912
- ...(t = this.parent) == null ? void 0 : t.call(this),
1913
- HTMLAttributes: {
1914
- style: `
1915
- border: 1px solid #000;
1916
- border-collapse: collapse;
1917
- width: 100%;
1918
- `
1919
- },
1920
- resizable: !0,
1921
- lastColumnResizable: !0,
1922
- allowTableNodeSelection: !1,
1923
- button: ({ editor: e, t: o }) => ({
1924
- componentProps: {
1925
- isActive: () => e.isActive("table"),
1926
- icon: "Table",
1927
- tooltip: o("editor.table.tooltip")
1928
- }
1929
- })
1930
- };
1931
- },
1932
- addExtensions() {
1933
- return [
1934
- Fe.configure(this.options.tableRow),
1935
- Oe.configure(this.options.tableHeader),
1936
- _e.configure(this.options.tableCell),
1937
- mo.configure(this.options.tableCellBackground)
1938
- ];
1939
- }
1940
- });
1941
- export {
1942
- w as C,
1943
- zo as R,
1944
- yo as T
1945
- };