reactjs-tiptap-editor 0.3.31 → 0.4.1

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