reactjs-tiptap-editor 0.3.31 → 0.4.0

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 +39 -43
  6. package/lib/Attachment.d.ts +39 -43
  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 +39 -43
  14. package/lib/Blockquote.d.ts +39 -43
  15. package/lib/Blockquote.js +33 -17
  16. package/lib/Bold.cjs +1 -1
  17. package/lib/Bold.d.cts +39 -43
  18. package/lib/Bold.d.ts +39 -43
  19. package/lib/Bold.js +23 -16
  20. package/lib/BulletList.cjs +1 -1
  21. package/lib/BulletList.d.cts +40 -44
  22. package/lib/BulletList.d.ts +40 -44
  23. package/lib/BulletList.js +11 -57
  24. package/lib/Clear.cjs +1 -1
  25. package/lib/Clear.d.cts +39 -43
  26. package/lib/Clear.d.ts +39 -43
  27. package/lib/Clear.js +4 -2
  28. package/lib/Code.cjs +1 -1
  29. package/lib/Code.d.cts +39 -43
  30. package/lib/Code.d.ts +39 -43
  31. package/lib/Code.js +29 -25
  32. package/lib/CodeBlock.cjs +2 -2
  33. package/lib/CodeBlock.d.cts +39 -43
  34. package/lib/CodeBlock.d.ts +39 -43
  35. package/lib/CodeBlock.js +3 -3
  36. package/lib/CodeView.cjs +1 -1
  37. package/lib/CodeView.d.cts +39 -43
  38. package/lib/CodeView.d.ts +39 -43
  39. package/lib/CodeView.js +3 -2
  40. package/lib/Color.cjs +1 -1
  41. package/lib/Color.d.cts +40 -44
  42. package/lib/Color.d.ts +40 -44
  43. package/lib/Color.js +42 -74
  44. package/lib/Document.cjs +1 -1
  45. package/lib/Document.d.cts +39 -43
  46. package/lib/Document.d.ts +39 -43
  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 +39 -43
  52. package/lib/Drawer.d.ts +39 -43
  53. package/lib/Drawer.js +4 -4
  54. package/lib/Emoji.cjs +1 -1
  55. package/lib/Emoji.d.cts +42 -44
  56. package/lib/Emoji.d.ts +42 -44
  57. package/lib/Emoji.js +19793 -182
  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 +39 -43
  62. package/lib/Excalidraw.d.ts +39 -43
  63. package/lib/Excalidraw.js +3 -3
  64. package/lib/ExportPdf.cjs +1 -1
  65. package/lib/ExportPdf.d.cts +39 -43
  66. package/lib/ExportPdf.d.ts +39 -43
  67. package/lib/ExportPdf.js +4 -2
  68. package/lib/ExportWord.cjs +1 -1
  69. package/lib/ExportWord.d.cts +39 -43
  70. package/lib/ExportWord.d.ts +39 -43
  71. package/lib/ExportWord.js +22 -51
  72. package/lib/FontFamily.cjs +1 -1
  73. package/lib/FontFamily.d.cts +40 -44
  74. package/lib/FontFamily.d.ts +40 -44
  75. package/lib/FontFamily.js +44 -73
  76. package/lib/FontSize.cjs +1 -1
  77. package/lib/FontSize.d.cts +39 -43
  78. package/lib/FontSize.d.ts +39 -43
  79. package/lib/FontSize.js +7 -5
  80. package/lib/FormatPainter.cjs +1 -1
  81. package/lib/FormatPainter.d.cts +39 -43
  82. package/lib/FormatPainter.d.ts +39 -43
  83. package/lib/FormatPainter.js +4 -2
  84. package/lib/Heading.cjs +1 -1
  85. package/lib/Heading.d.cts +39 -43
  86. package/lib/Heading.d.ts +39 -43
  87. package/lib/Heading.js +71 -60
  88. package/lib/Highlight.cjs +1 -1
  89. package/lib/Highlight.d.cts +39 -43
  90. package/lib/Highlight.d.ts +39 -43
  91. package/lib/Highlight.js +5 -4
  92. package/lib/History.cjs +1 -1
  93. package/lib/History.d.cts +41 -45
  94. package/lib/History.d.ts +41 -45
  95. package/lib/History.js +39 -403
  96. package/lib/HorizontalRule.cjs +1 -1
  97. package/lib/HorizontalRule.d.cts +39 -43
  98. package/lib/HorizontalRule.d.ts +39 -43
  99. package/lib/HorizontalRule.js +16 -65
  100. package/lib/Iframe.cjs +1 -1
  101. package/lib/Iframe.d.cts +39 -43
  102. package/lib/Iframe.d.ts +39 -43
  103. package/lib/Iframe.js +4 -4
  104. package/lib/Image.cjs +1 -1
  105. package/lib/Image.d.cts +39 -43
  106. package/lib/Image.d.ts +39 -43
  107. package/lib/Image.js +3 -3
  108. package/lib/ImageGif.cjs +1 -1
  109. package/lib/ImageGif.d.cts +39 -43
  110. package/lib/ImageGif.d.ts +39 -43
  111. package/lib/ImageGif.js +5 -5
  112. package/lib/ImportWord.cjs +72 -72
  113. package/lib/ImportWord.d.cts +39 -43
  114. package/lib/ImportWord.d.ts +39 -43
  115. package/lib/ImportWord.js +5652 -5615
  116. package/lib/Indent.cjs +1 -1
  117. package/lib/Indent.d.cts +39 -43
  118. package/lib/Indent.d.ts +39 -43
  119. package/lib/Indent.js +4 -2
  120. package/lib/Italic.cjs +1 -1
  121. package/lib/Italic.d.cts +39 -43
  122. package/lib/Italic.d.ts +39 -43
  123. package/lib/Italic.js +20 -14
  124. package/lib/Katex.cjs +1 -1
  125. package/lib/Katex.d.cts +39 -43
  126. package/lib/Katex.d.ts +39 -43
  127. package/lib/Katex.js +12 -12
  128. package/lib/LineHeight.cjs +1 -1
  129. package/lib/LineHeight.d.cts +39 -43
  130. package/lib/LineHeight.d.ts +39 -43
  131. package/lib/LineHeight.js +5 -3
  132. package/lib/Link.cjs +1 -1
  133. package/lib/Link.d.cts +39 -43
  134. package/lib/Link.d.ts +39 -43
  135. package/lib/Link.js +4 -4
  136. package/lib/ListItem.cjs +1 -1
  137. package/lib/ListItem.d.cts +44 -44
  138. package/lib/ListItem.d.ts +44 -44
  139. package/lib/ListItem.js +4 -30
  140. package/lib/Mention.cjs +1 -1
  141. package/lib/Mention.d.cts +39 -43
  142. package/lib/Mention.d.ts +39 -43
  143. package/lib/Mention.js +161 -132
  144. package/lib/Mermaid.cjs +2 -2
  145. package/lib/Mermaid.d.cts +39 -43
  146. package/lib/Mermaid.d.ts +39 -43
  147. package/lib/Mermaid.js +50 -48
  148. package/lib/MoreMark.cjs +1 -1
  149. package/lib/MoreMark.d.cts +39 -43
  150. package/lib/MoreMark.d.ts +39 -43
  151. package/lib/MoreMark.js +5 -3
  152. package/lib/MultiColumn.cjs +1 -1
  153. package/lib/MultiColumn.d.cts +39 -43
  154. package/lib/MultiColumn.d.ts +39 -43
  155. package/lib/MultiColumn.js +2 -2
  156. package/lib/OrderedList.cjs +1 -1
  157. package/lib/OrderedList.d.cts +40 -44
  158. package/lib/OrderedList.d.ts +40 -44
  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 +52 -126
  164. package/lib/SearchAndReplace.d.ts +52 -126
  165. package/lib/SearchAndReplace.js +204 -192
  166. package/lib/Selection.cjs +1 -1
  167. package/lib/Selection.d.cts +39 -43
  168. package/lib/Selection.d.ts +39 -43
  169. package/lib/Selection.js +1 -1
  170. package/lib/SlashCommand.cjs +1 -1
  171. package/lib/SlashCommand.d.cts +39 -43
  172. package/lib/SlashCommand.d.ts +39 -43
  173. package/lib/SlashCommand.js +177 -222
  174. package/lib/Strike.cjs +1 -1
  175. package/lib/Strike.d.cts +39 -43
  176. package/lib/Strike.d.ts +39 -43
  177. package/lib/Strike.js +20 -14
  178. package/lib/SubAndSuperScript.cjs +1 -1
  179. package/lib/SubAndSuperScript.d.cts +39 -43
  180. package/lib/SubAndSuperScript.d.ts +39 -43
  181. package/lib/SubAndSuperScript.js +5 -3
  182. package/lib/Table.cjs +8 -10
  183. package/lib/Table.d.cts +42 -46
  184. package/lib/Table.d.ts +42 -46
  185. package/lib/Table.js +382 -2022
  186. package/lib/TableOfContent.cjs +1 -1
  187. package/lib/TableOfContent.d.cts +39 -43
  188. package/lib/TableOfContent.d.ts +39 -43
  189. package/lib/TableOfContent.js +5 -5
  190. package/lib/TaskList.cjs +1 -1
  191. package/lib/TaskList.d.cts +41 -45
  192. package/lib/TaskList.d.ts +41 -45
  193. package/lib/TaskList.js +12 -154
  194. package/lib/TextAlign.cjs +1 -1
  195. package/lib/TextAlign.d.cts +39 -43
  196. package/lib/TextAlign.d.ts +39 -43
  197. package/lib/TextAlign.js +11 -9
  198. package/lib/TextBubble.cjs +1 -1
  199. package/lib/TextBubble.d.cts +39 -43
  200. package/lib/TextBubble.d.ts +39 -43
  201. package/lib/TextBubble.js +5 -3
  202. package/lib/TextDirection.cjs +1 -1
  203. package/lib/TextDirection.d.cts +39 -43
  204. package/lib/TextDirection.d.ts +39 -43
  205. package/lib/TextDirection.js +2 -3
  206. package/lib/TextUnderline.cjs +1 -1
  207. package/lib/TextUnderline.d.cts +39 -43
  208. package/lib/TextUnderline.d.ts +39 -43
  209. package/lib/TextUnderline.js +40 -12
  210. package/lib/TrailingNode.cjs +1 -1
  211. package/lib/TrailingNode.d.cts +39 -43
  212. package/lib/TrailingNode.d.ts +39 -43
  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 +39 -43
  218. package/lib/Twitter.d.ts +39 -43
  219. package/lib/Twitter.js +3 -3
  220. package/lib/Video.cjs +1 -1
  221. package/lib/Video.d.cts +39 -43
  222. package/lib/Video.d.ts +39 -43
  223. package/lib/Video.js +3 -3
  224. package/lib/bubble-extra.cjs +2 -2
  225. package/lib/bubble-extra.d.cts +39 -43
  226. package/lib/bubble-extra.d.ts +39 -43
  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 +40 -243
  250. package/lib/index.d.ts +40 -243
  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 +39 -43
  256. package/lib/locale-bundle.d.ts +39 -43
  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
@@ -127,9 +127,8 @@ declare module '@tiptap/core' {
127
127
 
128
128
  declare module '@tiptap/core' {
129
129
  interface Commands<ReturnType> {
130
- drawer: {
131
- setDrawer: (options: any, replace?: any) => ReturnType;
132
- setAlignImageDrawer: (align: 'left' | 'center' | 'right') => ReturnType;
130
+ excalidraw: {
131
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
133
132
  };
134
133
  }
135
134
  }
@@ -137,11 +136,9 @@ declare module '@tiptap/core' {
137
136
 
138
137
  declare module '@tiptap/core' {
139
138
  interface Commands<ReturnType> {
140
- emoji: {
141
- setEmoji: (emoji: {
142
- name: string;
143
- emoji: string;
144
- }) => ReturnType;
139
+ drawer: {
140
+ setDrawer: (options: any, replace?: any) => ReturnType;
141
+ setAlignImageDrawer: (align: 'left' | 'center' | 'right') => ReturnType;
145
142
  };
146
143
  }
147
144
  }
@@ -149,8 +146,8 @@ declare module '@tiptap/core' {
149
146
 
150
147
  declare module '@tiptap/core' {
151
148
  interface Commands<ReturnType> {
152
- excalidraw: {
153
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
149
+ exportPdf: {
150
+ exportToPdf: () => ReturnType;
154
151
  };
155
152
  }
156
153
  }
@@ -158,8 +155,8 @@ declare module '@tiptap/core' {
158
155
 
159
156
  declare module '@tiptap/core' {
160
157
  interface Commands<ReturnType> {
161
- exportPdf: {
162
- exportToPdf: () => ReturnType;
158
+ exportWord: {
159
+ exportToWord: () => ReturnType;
163
160
  };
164
161
  }
165
162
  }
@@ -167,8 +164,8 @@ declare module '@tiptap/core' {
167
164
 
168
165
  declare module '@tiptap/core' {
169
166
  interface Commands<ReturnType> {
170
- exportWord: {
171
- exportToWord: () => ReturnType;
167
+ painter: {
168
+ setPainter: (marks: Mark[]) => ReturnType;
172
169
  };
173
170
  }
174
171
  }
@@ -192,15 +189,6 @@ declare module '@tiptap/core' {
192
189
  }
193
190
 
194
191
 
195
- declare module '@tiptap/core' {
196
- interface Commands<ReturnType> {
197
- painter: {
198
- setPainter: (marks: Mark[]) => ReturnType;
199
- };
200
- }
201
- }
202
-
203
-
204
192
  declare module '@tiptap/core' {
205
193
  interface Commands<ReturnType> {
206
194
  iframe: {
@@ -256,6 +244,15 @@ declare module '@tiptap/core' {
256
244
  }
257
245
 
258
246
 
247
+ declare module '@tiptap/core' {
248
+ interface Commands<ReturnType> {
249
+ katex: {
250
+ setKatex: (arg?: IKatexAttrs) => ReturnType;
251
+ };
252
+ }
253
+ }
254
+
255
+
259
256
  declare module '@tiptap/core' {
260
257
  interface Commands<ReturnType> {
261
258
  indent: {
@@ -274,8 +271,9 @@ declare module '@tiptap/core' {
274
271
 
275
272
  declare module '@tiptap/core' {
276
273
  interface Commands<ReturnType> {
277
- katex: {
278
- setKatex: (arg?: IKatexAttrs) => ReturnType;
274
+ lineHeight: {
275
+ setLineHeight: (lineHeight: string) => ReturnType;
276
+ unsetLineHeight: () => ReturnType;
279
277
  };
280
278
  }
281
279
  }
@@ -283,9 +281,13 @@ declare module '@tiptap/core' {
283
281
 
284
282
  declare module '@tiptap/core' {
285
283
  interface Commands<ReturnType> {
286
- lineHeight: {
287
- setLineHeight: (lineHeight: string) => ReturnType;
288
- unsetLineHeight: () => ReturnType;
284
+ columns: {
285
+ insertColumns: (attrs?: {
286
+ cols: number;
287
+ }) => ReturnType;
288
+ addColBefore: () => ReturnType;
289
+ addColAfter: () => ReturnType;
290
+ deleteCol: () => ReturnType;
289
291
  };
290
292
  }
291
293
  }
@@ -303,13 +305,9 @@ declare module '@tiptap/core' {
303
305
 
304
306
  declare module '@tiptap/core' {
305
307
  interface Commands<ReturnType> {
306
- columns: {
307
- insertColumns: (attrs?: {
308
- cols: number;
309
- }) => ReturnType;
310
- addColBefore: () => ReturnType;
311
- addColAfter: () => ReturnType;
312
- deleteCol: () => ReturnType;
308
+ tableOfContents: {
309
+ setTableOfContents: () => ReturnType;
310
+ removeTableOfContents: () => ReturnType;
313
311
  };
314
312
  }
315
313
  }
@@ -320,22 +318,20 @@ declare module '@tiptap/core' {
320
318
  search: {
321
319
  setSearchTerm: (searchTerm: string) => ReturnType;
322
320
  setReplaceTerm: (replaceTerm: string) => ReturnType;
321
+ setCaseSensitive: (caseSensitive: boolean) => ReturnType;
322
+ resetIndex: () => ReturnType;
323
+ nextSearchResult: () => ReturnType;
324
+ previousSearchResult: () => ReturnType;
323
325
  replace: () => ReturnType;
324
326
  replaceAll: () => ReturnType;
325
- goToPrevSearchResult: () => void;
326
- goToNextSearchResult: () => void;
327
- setCaseSensitive: (caseSensitive: boolean) => ReturnType;
328
327
  };
329
328
  }
330
329
  }
331
330
 
332
331
 
333
332
  declare module '@tiptap/core' {
334
- interface Commands<ReturnType> {
335
- tableOfContents: {
336
- setTableOfContents: () => ReturnType;
337
- removeTableOfContents: () => ReturnType;
338
- };
333
+ interface Storage {
334
+ searchAndReplace: SearchAndReplaceStorage;
339
335
  }
340
336
  }
341
337
 
@@ -1,8 +1,10 @@
1
- import { E as a } from "./index-DI9T3iLd.js";
2
- import { S as b, a as l } from "./index-LUL9mqY4.js";
3
- import { A as r } from "./RichTextEditor-KP2Rgcqe.js";
1
+ import { E as a } from "./index-kbO3iWqL.js";
2
+ import { S as b, a as l } from "./index-D_L6n8O8.js";
3
+ import { A as r } from "./RichTextEditor-DGcKEUGr.js";
4
4
  const g = /* @__PURE__ */ a.create({
5
5
  name: "subAndSuperScript",
6
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7
+ //@ts-expect-error
6
8
  addOptions() {
7
9
  var s;
8
10
  return {
package/lib/Table.cjs CHANGED
@@ -1,11 +1,9 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("./index-ByRfqzMr.cjs"),R=require("react/jsx-runtime"),O=require("./RichTextEditor-DWlLqTl9.cjs"),X=require("react"),T=require("./index-D_A0TBRA.cjs");var q,U;if(typeof WeakMap<"u"){let t=new WeakMap;q=e=>t.get(e),U=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;q=o=>{for(let l=0;l<t.length;l+=2)if(t[l]==o)return t[l+1]},U=(o,l)=>(n==10&&(n=0),t[n++]=o,t[n++]=l)}var S=class{constructor(t,e,n,o){this.width=t,this.height=e,this.map=n,this.problems=o}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const o=e%this.width,l=e/this.width|0;let r=o+1,s=l+1;for(let i=1;r<this.width&&this.map[e+i]==n;i++)r++;for(let i=1;s<this.height&&this.map[e+this.width*i]==n;i++)s++;return{left:o,top:l,right:r,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:o,right:l,top:r,bottom:s}=this.findCell(t);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)]}rectBetween(t,e){const{left:n,right:o,top:l,bottom:r}=this.findCell(t),{left:s,right:i,top:c,bottom:a}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(l,c),right:Math.max(o,i),bottom:Math.max(r,a)}}cellsInRect(t){const e=[],n={};for(let o=t.top;o<t.bottom;o++)for(let l=t.left;l<t.right;l++){const r=o*this.width+l,s=this.map[r];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))}return e}positionAt(t,e,n){for(let o=0,l=0;;o++){const r=l+n.child(o).nodeSize;if(o==t){let s=e+t*this.width;const i=(t+1)*this.width;for(;s<i&&this.map[s]<l;)s++;return s==i?r-1:this.map[s]}l=r}}static get(t){return q(t)||U(t,Ne(t))}};function Ne(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=ke(t),n=t.childCount,o=[];let l=0,r=null;const s=[];for(let a=0,u=e*n;a<u;a++)o[a]=0;for(let a=0,u=0;a<n;a++){const d=t.child(a);u++;for(let p=0;;p++){for(;l<o.length&&o[l]!=0;)l++;if(p==d.childCount)break;const g=d.child(p),{colspan:b,rowspan:C,colwidth:x}=g.attrs;for(let E=0;E<C;E++){if(E+a>=n){(r||(r=[])).push({type:"overlong_rowspan",pos:u,n:C-E});break}const D=l+E*e;for(let z=0;z<b;z++){o[D+z]==0?o[D+z]=u:(r||(r=[])).push({type:"collision",row:a,pos:u,n:b-z});const I=x&&x[z];if(I){const H=(D+z)%e*2,K=s[H];K==null||K!=I&&s[H+1]==1?(s[H]=I,s[H+1]=1):K==I&&s[H+1]++}}}l+=b,u+=g.nodeSize}const f=(a+1)*e;let h=0;for(;l<f;)o[l++]==0&&h++;h&&(r||(r=[])).push({type:"missing",row:a,n:h}),u++}(e===0||n===0)&&(r||(r=[])).push({type:"zero_sized"});const i=new S(e,n,o,r);let c=!1;for(let a=0;!c&&a<s.length;a+=2)s[a]!=null&&s[a+1]<n&&(c=!0);return c&&ze(i,s,t),i}function ke(t){let e=-1,n=!1;for(let o=0;o<t.childCount;o++){const l=t.child(o);let r=0;if(n)for(let s=0;s<o;s++){const i=t.child(s);for(let c=0;c<i.childCount;c++){const a=i.child(c);s+a.attrs.rowspan>o&&(r+=a.attrs.colspan)}}for(let s=0;s<l.childCount;s++){const i=l.child(s);r+=i.attrs.colspan,i.attrs.rowspan>1&&(n=!0)}e==-1?e=r:e!=r&&(e=Math.max(e,r))}return e}function ze(t,e,n){t.problems||(t.problems=[]);const o={};for(let l=0;l<t.map.length;l++){const r=t.map[l];if(o[r])continue;o[r]=!0;const s=n.nodeAt(r);if(!s)throw new RangeError(`No cell with offset ${r} found`);let i=null;const c=s.attrs;for(let a=0;a<c.colspan;a++){const u=(l+a)%t.width,d=e[u*2];d!=null&&(!c.colwidth||c.colwidth[a]!=d)&&((i||(i=Le(c)))[a]=d)}i&&t.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:i})}}function Le(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function y(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const o=t.nodes[n],l=o.spec.tableRole;l&&(e[l]=o)}}return e}var k=new m.PluginKey("selectingCells");function _(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function _e(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function M(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function V(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=_(e.$head)||De(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function De(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function J(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function He(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function te(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Ce(t,e,n){const o=t.node(-1),l=S.get(o),r=t.start(-1),s=l.nextCell(t.pos-r,e,n);return s==null?null:t.node(0).resolve(r+s)}function L(t,e,n=1){const o={...t,colspan:t.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,n),o.colwidth.some(l=>l>0)||(o.colwidth=null)),o}function Se(t,e,n=1){const o={...t,colspan:t.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let l=0;l<n;l++)o.colwidth.splice(e,0,0)}return o}function Be(t,e,n){const o=y(e.type.schema).header_cell;for(let l=0;l<t.height;l++)if(e.nodeAt(t.map[n+l*t.width]).type!=o)return!1;return!0}var w=class N extends m.Selection{constructor(e,n=e){const o=e.node(-1),l=S.get(o),r=e.start(-1),s=l.rectBetween(e.pos-r,n.pos-r),i=e.node(0),c=l.cellsInRect(s).filter(u=>u!=n.pos-r);c.unshift(n.pos-r);const a=c.map(u=>{const d=o.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);const f=r+u+1;return new m.SelectionRange(i.resolve(f),i.resolve(f+d.content.size))});super(a[0].$from,a[0].$to,a),this.$anchorCell=e,this.$headCell=n}map(e,n){const o=e.resolve(n.map(this.$anchorCell.pos)),l=e.resolve(n.map(this.$headCell.pos));if(J(o)&&J(l)&&te(o,l)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?N.rowSelection(o,l):r&&this.isColSelection()?N.colSelection(o,l):new N(o,l)}return m.TextSelection.between(o,l)}content(){const e=this.$anchorCell.node(-1),n=S.get(e),o=this.$anchorCell.start(-1),l=n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),r={},s=[];for(let c=l.top;c<l.bottom;c++){const a=[];for(let u=c*n.width+l.left,d=l.left;d<l.right;d++,u++){const f=n.map[u];if(r[f])continue;r[f]=!0;const h=n.findCell(f);let p=e.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const g=l.left-h.left,b=h.right-l.right;if(g>0||b>0){let C=p.attrs;if(g>0&&(C=L(C,0,g)),b>0&&(C=L(C,C.colspan-b,b)),h.left<l.left){if(p=p.type.createAndFill(C),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(C)}`)}else p=p.type.create(C,p.content)}if(h.top<l.top||h.bottom>l.bottom){const C={...p.attrs,rowspan:Math.min(h.bottom,l.bottom)-Math.max(h.top,l.top)};h.top<l.top?p=p.type.createAndFill(C):p=p.type.create(C,p.content)}a.push(p)}s.push(e.child(c).copy(m.Fragment.from(a)))}const i=this.isColSelection()&&this.isRowSelection()?e:s;return new m.Slice(m.Fragment.from(i),1,1)}replace(e,n=m.Slice.empty){const o=e.steps.length,l=this.ranges;for(let s=0;s<l.length;s++){const{$from:i,$to:c}=l[s],a=e.mapping.slice(o);e.replace(a.map(i.pos),a.map(c.pos),s?m.Slice.empty:n)}const r=m.Selection.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,n){this.replace(e,new m.Slice(m.Fragment.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),o=S.get(n),l=this.$anchorCell.start(-1),r=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-l,this.$headCell.pos-l));for(let s=0;s<r.length;s++)e(n.nodeAt(r[s]),l+r[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const o=e+this.$anchorCell.nodeAfter.attrs.rowspan,l=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,l)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const o=e.node(-1),l=S.get(o),r=e.start(-1),s=l.findCell(e.pos-r),i=l.findCell(n.pos-r),c=e.node(0);return s.top<=i.top?(s.top>0&&(e=c.resolve(r+l.map[s.left])),i.bottom<l.height&&(n=c.resolve(r+l.map[l.width*(l.height-1)+i.right-1]))):(i.top>0&&(n=c.resolve(r+l.map[i.left])),s.bottom<l.height&&(e=c.resolve(r+l.map[l.width*(l.height-1)+s.right-1]))),new N(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=S.get(e),o=this.$anchorCell.start(-1),l=n.colCount(this.$anchorCell.pos-o),r=n.colCount(this.$headCell.pos-o);if(Math.min(l,r)>0)return!1;const s=l+this.$anchorCell.nodeAfter.attrs.colspan,i=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,i)==n.width}eq(e){return e instanceof N&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const o=e.node(-1),l=S.get(o),r=e.start(-1),s=l.findCell(e.pos-r),i=l.findCell(n.pos-r),c=e.node(0);return s.left<=i.left?(s.left>0&&(e=c.resolve(r+l.map[s.top*l.width])),i.right<l.width&&(n=c.resolve(r+l.map[l.width*(i.top+1)-1]))):(i.left>0&&(n=c.resolve(r+l.map[i.top*l.width])),s.right<l.width&&(e=c.resolve(r+l.map[l.width*(s.top+1)-1]))),new N(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new N(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){return new N(e.resolve(n),e.resolve(o))}getBookmark(){return new Ie(this.$anchorCell.pos,this.$headCell.pos)}};w.prototype.visible=!1;m.Selection.jsonID("cell",w);var Ie=class ye{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ye(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),o=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&te(n,o)?new w(n,o):m.Selection.near(o,1)}};function $e(t){if(!(t.selection instanceof w))return null;const e=[];return t.selection.forEachCell((n,o)=>{e.push(m.Decoration.node(o,o+n.nodeSize,{class:"selectedCell"}))}),m.DecorationSet.create(t.doc,e)}function We({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,o=e.pos,l=t.depth;for(;l>=0&&!(t.after(l+1)<t.end(l));l--,n++);for(let r=e.depth;r>=0&&!(e.before(r+1)>e.start(r));r--,o--);return n==o&&/row|table/.test(t.node(l).type.spec.tableRole)}function Pe({$from:t,$to:e}){let n,o;for(let l=t.depth;l>0;l--){const r=t.node(l);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){n=r;break}}for(let l=e.depth;l>0;l--){const r=e.node(l);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){o=r;break}}return n!==o&&e.parentOffset===0}function Fe(t,e,n){const o=(e||t).selection,l=(e||t).doc;let r,s;if(o instanceof m.NodeSelection&&(s=o.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")r=w.create(l,o.from);else if(s=="row"){const i=l.resolve(o.from+1);r=w.rowSelection(i,i)}else if(!n){const i=S.get(o.node),c=o.from+1,a=c+i.map[i.width*i.height-1];r=w.create(l,c+1,a)}}else o instanceof m.TextSelection&&We(o)?r=m.TextSelection.create(l,o.from):o instanceof m.TextSelection&&Pe(o)&&(r=m.TextSelection.create(l,o.$from.start(),o.$from.end()));return r&&(e||(e=t.tr)).setSelection(r),e}var Oe=new m.PluginKey("fix-tables");function Ae(t,e,n,o){const l=t.childCount,r=e.childCount;e:for(let s=0,i=0;s<r;s++){const c=e.child(s);for(let a=i,u=Math.min(l,s+3);a<u;a++)if(t.child(a)==c){i=a+1,n+=c.nodeSize;continue e}o(c,n),i<l&&t.child(i).sameMarkup(c)?Ae(t.child(i),c,n+1,o):c.nodesBetween(0,c.content.size,o,n+1),n+=c.nodeSize}}function xe(t,e){let n;const o=(l,r)=>{l.type.spec.tableRole=="table"&&(n=je(t,l,r,n))};return e?e.doc!=t.doc&&Ae(e.doc,t.doc,0,o):t.doc.descendants(o),n}function je(t,e,n,o){const l=S.get(e);if(!l.problems)return o;o||(o=t.tr);const r=[];for(let c=0;c<l.height;c++)r.push(0);for(let c=0;c<l.problems.length;c++){const a=l.problems[c];if(a.type=="collision"){const u=e.nodeAt(a.pos);if(!u)continue;const d=u.attrs;for(let f=0;f<d.rowspan;f++)r[a.row+f]+=a.n;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,L(d,d.colspan-a.n,a.n))}else if(a.type=="missing")r[a.row]+=a.n;else if(a.type=="overlong_rowspan"){const u=e.nodeAt(a.pos);if(!u)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-a.n})}else if(a.type=="colwidth mismatch"){const u=e.nodeAt(a.pos);if(!u)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...u.attrs,colwidth:a.colwidth})}else if(a.type=="zero_sized"){const u=o.mapping.map(n);o.delete(u,u+e.nodeSize)}}let s,i;for(let c=0;c<r.length;c++)r[c]&&(s==null&&(s=c),i=c);for(let c=0,a=n+1;c<l.height;c++){const u=e.child(c),d=a+u.nodeSize,f=r[c];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let b=0;b<f;b++){const C=y(t.schema)[h].createAndFill();C&&p.push(C)}const g=(c==0||s==c-1)&&i==c?a+1:d-1;o.insert(o.mapping.map(g),p)}a=d}return o.setMeta(Oe,{fixTables:!0})}function v(t){const e=t.selection,n=V(t),o=n.node(-1),l=n.start(-1),r=S.get(o);return{...e instanceof w?r.rectBetween(e.$anchorCell.pos-l,e.$headCell.pos-l):r.findCell(n.pos-l),tableStart:l,map:r,table:o}}function Te(t,{map:e,tableStart:n,table:o},l){let r=l>0?-1:0;Be(e,o,l+r)&&(r=l==0||l==e.width?null:0);for(let s=0;s<e.height;s++){const i=s*e.width+l;if(l>0&&l<e.width&&e.map[i-1]==e.map[i]){const c=e.map[i],a=o.nodeAt(c);t.setNodeMarkup(t.mapping.map(n+c),null,Se(a.attrs,l-e.colCount(c))),s+=a.attrs.rowspan-1}else{const c=r==null?y(o.type.schema).cell:o.nodeAt(e.map[i+r]).type,a=e.positionAt(s,l,o);t.insert(t.mapping.map(n+a),c.createAndFill())}}return t}function Ge(t,e){if(!M(t))return!1;if(e){const n=v(t);e(Te(t.tr,n,n.left))}return!0}function Ve(t,e){if(!M(t))return!1;if(e){const n=v(t);e(Te(t.tr,n,n.right))}return!0}function Ke(t,{map:e,table:n,tableStart:o},l){const r=t.mapping.maps.length;for(let s=0;s<e.height;){const i=s*e.width+l,c=e.map[i],a=n.nodeAt(c),u=a.attrs;if(l>0&&e.map[i-1]==c||l<e.width-1&&e.map[i+1]==c)t.setNodeMarkup(t.mapping.slice(r).map(o+c),null,L(u,l-e.colCount(c)));else{const d=t.mapping.slice(r).map(o+c);t.delete(d,d+a.nodeSize)}s+=u.rowspan}}function Xe(t,e){if(!M(t))return!1;if(e){const n=v(t),o=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let l=n.right-1;Ke(o,n,l),l!=n.left;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw RangeError("No table found");n.table=r,n.map=S.get(r)}e(o)}return!0}function Ze(t,e,n){var o;const l=y(e.type.schema).header_cell;for(let r=0;r<t.width;r++)if(((o=e.nodeAt(t.map[r+n*t.width]))==null?void 0:o.type)!=l)return!1;return!0}function Re(t,{map:e,tableStart:n,table:o},l){var r;let s=n;for(let a=0;a<l;a++)s+=o.child(a).nodeSize;const i=[];let c=l>0?-1:0;Ze(e,o,l+c)&&(c=l==0||l==e.height?null:0);for(let a=0,u=e.width*l;a<e.width;a++,u++)if(l>0&&l<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],f=o.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...f,rowspan:f.rowspan+1}),a+=f.colspan-1}else{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();f&&i.push(f)}return t.insert(s,y(o.type.schema).row.create(null,i)),t}function qe(t,e){if(!M(t))return!1;if(e){const n=v(t);e(Re(t.tr,n,n.top))}return!0}function Ue(t,e){if(!M(t))return!1;if(e){const n=v(t);e(Re(t.tr,n,n.bottom))}return!0}function Je(t,{map:e,table:n,tableStart:o},l){let r=0;for(let a=0;a<l;a++)r+=n.child(a).nodeSize;const s=r+n.child(l).nodeSize,i=t.mapping.maps.length;t.delete(r+o,s+o);const c=new Set;for(let a=0,u=l*e.width;a<e.width;a++,u++){const d=e.map[u];if(!c.has(d)){if(c.add(d),l>0&&d==e.map[u-e.width]){const f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(i).map(d+o),null,{...f,rowspan:f.rowspan-1}),a+=f.colspan-1}else if(l<e.height&&d==e.map[u+e.width]){const f=n.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),g=e.positionAt(l+1,a,n);t.insert(t.mapping.slice(i).map(o+g),p),a+=h.colspan-1}}}}function Ye(t,e){if(!M(t))return!1;if(e){const n=v(t),o=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let l=n.bottom-1;Je(o,n,l),l!=n.top;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw RangeError("No table found");n.table=r,n.map=S.get(n.table)}e(o)}return!0}function ne(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Qe({width:t,height:e,map:n},o){let l=o.top*t+o.left,r=l,s=(o.bottom-1)*t+o.left,i=l+(o.right-o.left-1);for(let c=o.top;c<o.bottom;c++){if(o.left>0&&n[r]==n[r-1]||o.right<t&&n[i]==n[i+1])return!0;r+=t,i+=t}for(let c=o.left;c<o.right;c++){if(o.top>0&&n[l]==n[l-t]||o.bottom<e&&n[s]==n[s+t])return!0;l++,s++}return!1}function oe(t,e){const n=t.selection;if(!(n instanceof w)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=v(t),{map:l}=o;if(Qe(l,o))return!1;if(e){const r=t.tr,s={};let i=m.Fragment.empty,c,a;for(let u=o.top;u<o.bottom;u++)for(let d=o.left;d<o.right;d++){const f=l.map[u*l.width+d],h=o.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,c==null)c=f,a=h;else{ne(h)||(i=i.append(h.content));const p=r.mapping.map(f+o.tableStart);r.delete(p,p+h.nodeSize)}}if(c==null||a==null)return!0;if(r.setNodeMarkup(c+o.tableStart,null,{...Se(a.attrs,a.attrs.colspan,o.right-o.left-a.attrs.colspan),rowspan:o.bottom-o.top}),i.size){const u=c+1+a.content.size,d=ne(a)?c+1:u;r.replaceWith(d+o.tableStart,u+o.tableStart,i)}r.setSelection(new w(r.doc.resolve(c+o.tableStart))),e(r)}return!0}function le(t,e){const n=y(t.schema);return et(({node:o})=>n[o.type.spec.tableRole])(t,e)}function et(t){return(e,n)=>{var o;const l=e.selection;let r,s;if(l instanceof w){if(l.$anchorCell.pos!=l.$headCell.pos)return!1;r=l.$anchorCell.nodeAfter,s=l.$anchorCell.pos}else{if(r=_e(l.$from),!r)return!1;s=(o=_(l.$from))==null?void 0:o.pos}if(r==null||s==null||r.attrs.colspan==1&&r.attrs.rowspan==1)return!1;if(n){let i=r.attrs;const c=[],a=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const u=v(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)c.push(a?{...i,colwidth:a&&a[h]?[a[h]]:null}:i);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=r.nodeSize);for(let g=u.left,b=0;g<u.right;g++,b++)g==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),t({node:r,row:h,col:g}).createAndFill(c[b]))}d.setNodeMarkup(s,t({node:r,row:u.top,col:u.left}),c[0]),l instanceof w&&d.setSelection(new w(d.doc.resolve(l.$anchorCell.pos),f?d.doc.resolve(f):void 0)),n(d)}return!0}}function tt(t,e){return function(n,o){if(!M(n))return!1;const l=V(n);if(l.nodeAfter.attrs[t]===e)return!1;if(o){const r=n.tr;n.selection instanceof w?n.selection.forEachCell((s,i)=>{s.attrs[t]!==e&&r.setNodeMarkup(i,null,{...s.attrs,[t]:e})}):r.setNodeMarkup(l.pos,null,{...l.nodeAfter.attrs,[t]:e}),o(r)}return!0}}function nt(t){return function(e,n){if(!M(e))return!1;if(n){const o=y(e.schema),l=v(e),r=e.tr,s=l.map.cellsInRect(t=="column"?{left:l.left,top:0,right:l.right,bottom:l.map.height}:t=="row"?{left:0,top:l.top,right:l.map.width,bottom:l.bottom}:l),i=s.map(c=>l.table.nodeAt(c));for(let c=0;c<s.length;c++)i[c].type==o.header_cell&&r.setNodeMarkup(l.tableStart+s[c],o.cell,i[c].attrs);if(r.steps.length==0)for(let c=0;c<s.length;c++)r.setNodeMarkup(l.tableStart+s[c],o.header_cell,i[c].attrs);n(r)}return!0}}function re(t,e,n){const o=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let l=0;l<o.length;l++){const r=e.table.nodeAt(o[l]);if(r&&r.type!==n.header_cell)return!1}return!0}function B(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?nt(t):function(n,o){if(!M(n))return!1;if(o){const l=y(n.schema),r=v(n),s=n.tr,i=re("row",r,l),c=re("column",r,l),u=(t==="column"?i:t==="row"?c:!1)?1:0,d=t=="column"?{left:0,top:u,right:1,bottom:r.map.height}:t=="row"?{left:u,top:0,right:r.map.width,bottom:1}:r,f=t=="column"?c?l.cell:l.header_cell:t=="row"?i?l.cell:l.header_cell:l.cell;r.map.cellsInRect(d).forEach(h=>{const p=h+r.tableStart,g=s.doc.nodeAt(p);g&&s.setNodeMarkup(p,f,g.attrs)}),o(s)}return!0}}B("row",{useDeprecatedLogic:!0});B("column",{useDeprecatedLogic:!0});var ot=B("cell",{useDeprecatedLogic:!0});function lt(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let o=t.index(-1)-1,l=t.before();o>=0;o--){const r=t.node(-1).child(o),s=r.lastChild;if(s)return l-1-s.nodeSize;l-=r.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let o=t.indexAfter(-1),l=t.after();o<n.childCount;o++){const r=n.child(o);if(r.childCount)return l+1;l+=r.nodeSize}}return null}function se(t){return function(e,n){if(!M(e))return!1;const o=lt(V(e),t);if(o==null)return!1;if(n){const l=e.doc.resolve(o);n(e.tr.setSelection(m.TextSelection.between(l,He(l))).scrollIntoView())}return!0}}function rt(t,e){const n=t.selection.$anchor;for(let o=n.depth;o>0;o--)if(n.node(o).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}function $(t,e){const n=t.selection;if(!(n instanceof w))return!1;if(e){const o=t.tr,l=y(t.schema).cell.createAndFill().content;n.forEachCell((r,s)=>{r.content.eq(l)||o.replace(o.mapping.map(s+1),o.mapping.map(s+r.nodeSize-1),new m.Slice(l,0,0))}),o.docChanged&&e(o)}return!0}function st(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:o}=t;for(;e.childCount==1&&(n>0&&o>0||e.child(0).type.spec.tableRole=="table");)n--,o--,e=e.child(0).content;const l=e.child(0),r=l.type.spec.tableRole,s=l.type.schema,i=[];if(r=="row")for(let c=0;c<e.childCount;c++){let a=e.child(c).content;const u=c?0:Math.max(0,n-1),d=c<e.childCount-1?0:Math.max(0,o-1);(u||d)&&(a=Y(y(s).row,new m.Slice(a,u,d)).content),i.push(a)}else if(r=="cell"||r=="header_cell")i.push(n||o?Y(y(s).row,new m.Slice(e,n,o)).content:e);else return null;return it(s,i)}function it(t,e){const n=[];for(let l=0;l<e.length;l++){const r=e[l];for(let s=r.childCount-1;s>=0;s--){const{rowspan:i,colspan:c}=r.child(s).attrs;for(let a=l;a<l+i;a++)n[a]=(n[a]||0)+c}}let o=0;for(let l=0;l<n.length;l++)o=Math.max(o,n[l]);for(let l=0;l<n.length;l++)if(l>=e.length&&e.push(m.Fragment.empty),n[l]<o){const r=y(t).cell.createAndFill(),s=[];for(let i=n[l];i<o;i++)s.push(r);e[l]=e[l].append(m.Fragment.from(s))}return{height:e.length,width:o,rows:e}}function Y(t,e){const n=t.createAndFill();return new m.Transform(n).replace(0,n.content.size,e).doc}function ct({width:t,height:e,rows:n},o,l){if(t!=o){const r=[],s=[];for(let i=0;i<n.length;i++){const c=n[i],a=[];for(let u=r[i]||0,d=0;u<o;d++){let f=c.child(d%c.childCount);u+f.attrs.colspan>o&&(f=f.type.createChecked(L(f.attrs,f.attrs.colspan,u+f.attrs.colspan-o),f.content)),a.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)r[i+h]=(r[i+h]||0)+f.attrs.colspan}s.push(m.Fragment.from(a))}n=s,t=o}if(e!=l){const r=[];for(let s=0,i=0;s<l;s++,i++){const c=[],a=n[i%e];for(let u=0;u<a.childCount;u++){let d=a.child(u);s+d.attrs.rowspan>l&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,l-d.attrs.rowspan)},d.content)),c.push(d)}r.push(m.Fragment.from(c))}n=r,e=l}return{width:t,height:e,rows:n}}function at(t,e,n,o,l,r,s){const i=t.doc.type.schema,c=y(i);let a,u;if(l>e.width)for(let d=0,f=0;d<e.height;d++){const h=n.child(d);f+=h.nodeSize;const p=[];let g;h.lastChild==null||h.lastChild.type==c.cell?g=a||(a=c.cell.createAndFill()):g=u||(u=c.header_cell.createAndFill());for(let b=e.width;b<l;b++)p.push(g);t.insert(t.mapping.slice(s).map(f-1+o),p)}if(r>e.height){const d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,l);p++){const b=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==c.header_cell;d.push(b?u||(u=c.header_cell.createAndFill()):a||(a=c.cell.createAndFill()))}const f=c.row.create(null,m.Fragment.from(d)),h=[];for(let p=e.height;p<r;p++)h.push(f);t.insert(t.mapping.slice(s).map(o+n.nodeSize-2),h)}return!!(a||u)}function ie(t,e,n,o,l,r,s,i){if(s==0||s==e.height)return!1;let c=!1;for(let a=l;a<r;a++){const u=s*e.width+a,d=e.map[u];if(e.map[u-e.width]==d){c=!0;const f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(i).map(d+o),null,{...f.attrs,rowspan:s-h}),t.insert(t.mapping.slice(i).map(e.positionAt(s,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-s})),a+=f.attrs.colspan-1}}return c}function ce(t,e,n,o,l,r,s,i){if(s==0||s==e.width)return!1;let c=!1;for(let a=l;a<r;a++){const u=a*e.width+s,d=e.map[u];if(e.map[u-1]==d){c=!0;const f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(i).map(d+o);t.setNodeMarkup(p,null,L(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(L(f.attrs,0,s-h))),a+=f.attrs.rowspan-1}}return c}function ae(t,e,n,o,l){let r=n?t.doc.nodeAt(n-1):t.doc;if(!r)throw new Error("No table found");let s=S.get(r);const{top:i,left:c}=o,a=c+l.width,u=i+l.height,d=t.tr;let f=0;function h(){if(r=n?d.doc.nodeAt(n-1):d.doc,!r)throw new Error("No table found");s=S.get(r),f=d.mapping.maps.length}at(d,s,r,n,a,u,f)&&h(),ie(d,s,r,n,c,a,i,f)&&h(),ie(d,s,r,n,c,a,u,f)&&h(),ce(d,s,r,n,i,u,c,f)&&h(),ce(d,s,r,n,i,u,a,f)&&h();for(let p=i;p<u;p++){const g=s.positionAt(p,c,r),b=s.positionAt(p,a,r);d.replace(d.mapping.slice(f).map(g+n),d.mapping.slice(f).map(b+n),new m.Slice(l.rows[p-i],0,0))}h(),d.setSelection(new w(d.doc.resolve(n+s.positionAt(i,c,r)),d.doc.resolve(n+s.positionAt(u-1,a-1,r)))),e(d)}var dt=m.keydownHandler({ArrowLeft:W("horiz",-1),ArrowRight:W("horiz",1),ArrowUp:W("vert",-1),ArrowDown:W("vert",1),"Shift-ArrowLeft":P("horiz",-1),"Shift-ArrowRight":P("horiz",1),"Shift-ArrowUp":P("vert",-1),"Shift-ArrowDown":P("vert",1),Backspace:$,"Mod-Backspace":$,Delete:$,"Mod-Delete":$});function j(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function W(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;if(r instanceof w)return j(n,o,m.Selection.near(r.$headCell,e));if(t!="horiz"&&!r.empty)return!1;const s=Me(l,t,e);if(s==null)return!1;if(t=="horiz")return j(n,o,m.Selection.near(n.doc.resolve(r.head+e),e));{const i=n.doc.resolve(s),c=Ce(i,t,e);let a;return c?a=m.Selection.near(c,1):e<0?a=m.Selection.near(n.doc.resolve(i.before(-1)),-1):a=m.Selection.near(n.doc.resolve(i.after(-1)),1),j(n,o,a)}}}function P(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;let s;if(r instanceof w)s=r;else{const c=Me(l,t,e);if(c==null)return!1;s=new w(n.doc.resolve(c))}const i=Ce(s.$headCell,t,e);return i?j(n,o,new w(s.$anchorCell,i)):!1}}function ut(t,e){const n=t.state.doc,o=_(n.resolve(e));return o?(t.dispatch(t.state.tr.setSelection(new w(o))),!0):!1}function ft(t,e,n){if(!M(t.state))return!1;let o=st(n);const l=t.state.selection;if(l instanceof w){o||(o={width:1,height:1,rows:[m.Fragment.from(Y(y(t.state.schema).cell,n))]});const r=l.$anchorCell.node(-1),s=l.$anchorCell.start(-1),i=S.get(r).rectBetween(l.$anchorCell.pos-s,l.$headCell.pos-s);return o=ct(o,i.right-i.left,i.bottom-i.top),ae(t.state,t.dispatch,s,i,o),!0}else if(o){const r=V(t.state),s=r.start(-1);return ae(t.state,t.dispatch,s,S.get(r.node(-1)).findCell(r.pos-s),o),!0}else return!1}function ht(t,e){var n;if(e.ctrlKey||e.metaKey)return;const o=de(t,e.target);let l;if(e.shiftKey&&t.state.selection instanceof w)r(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(l=_(t.state.selection.$anchor))!=null&&((n=Z(t,e))==null?void 0:n.pos)!=l.pos)r(l,e),e.preventDefault();else if(!o)return;function r(c,a){let u=Z(t,a);const d=k.getState(t.state)==null;if(!u||!te(c,u))if(d)u=c;else return;const f=new w(c,u);if(d||!t.state.selection.eq(f)){const h=t.state.tr.setSelection(f);d&&h.setMeta(k,c.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",i),k.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(k,-1))}function i(c){const a=c,u=k.getState(t.state);let d;if(u!=null)d=t.state.doc.resolve(u);else if(de(t,a.target)!=o&&(d=Z(t,e),!d))return s();d&&r(d,a)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",i)}function Me(t,e,n){if(!(t.state.selection instanceof m.TextSelection))return null;const{$head:o}=t.state.selection;for(let l=o.depth-1;l>=0;l--){const r=o.node(l);if((n<0?o.index(l):o.indexAfter(l))!=(n<0?0:r.childCount))return null;if(r.type.spec.tableRole=="cell"||r.type.spec.tableRole=="header_cell"){const i=o.before(l),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?i:null}}return null}function de(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Z(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?_(t.state.doc.resolve(n.pos)):null}var pt=class{constructor(e,n){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("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Q(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Q(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Q(t,e,n,o,l,r){var s;let i=0,c=!0,a=e.firstChild;const u=t.firstChild;if(u){for(let d=0,f=0;d<u.childCount;d++){const{colspan:h,colwidth:p}=u.child(d).attrs;for(let g=0;g<h;g++,f++){const b=l==f?r:p&&p[g],C=b?b+"px":"";if(i+=b||o,b||(c=!1),a)a.style.width!=C&&(a.style.width=C),a=a.nextSibling;else{const x=document.createElement("col");x.style.width=C,e.appendChild(x)}}}for(;a;){const d=a.nextSibling;(s=a.parentNode)==null||s.removeChild(a),a=d}c?(n.style.width=i+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=i+"px")}}var A=new m.PluginKey("tableColumnResizing");function mt({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:o=pt,lastColumnResizable:l=!0}={}){const r=new m.Plugin({key:A,state:{init(s,i){var c,a;const u=(a=(c=r.spec)==null?void 0:c.props)==null?void 0:a.nodeViews,d=y(i.schema).table.name;return o&&u&&(u[d]=(f,h)=>new o(f,n,h)),new gt(-1,!1)},apply(s,i){return i.apply(s)}},props:{attributes:s=>{const i=A.getState(s);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,i)=>{bt(s,i,t,l)},mouseleave:s=>{wt(s)},mousedown:(s,i)=>{Ct(s,i,e,n)}},decorations:s=>{const i=A.getState(s);if(i&&i.activeHandle>-1)return Tt(s,i.activeHandle)},nodeViews:{}}});return r}var gt=class G{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,o=e.getMeta(A);if(o&&o.setHandle!=null)return new G(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new G(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&e.docChanged){let l=e.mapping.map(n.activeHandle,-1);return J(e.doc.resolve(l))||(l=-1),new G(l,n.dragging)}return n}};function bt(t,e,n,o){if(!t.editable)return;const l=A.getState(t.state);if(l&&!l.dragging){const r=yt(e.target);let s=-1;if(r){const{left:i,right:c}=r.getBoundingClientRect();e.clientX-i<=n?s=ue(t,e,"left",n):c-e.clientX<=n&&(s=ue(t,e,"right",n))}if(s!=l.activeHandle){if(!o&&s!==-1){const i=t.state.doc.resolve(s),c=i.node(-1),a=S.get(c),u=i.start(-1);if(a.colCount(i.pos-u)+i.nodeAfter.attrs.colspan-1==a.width-1)return}ve(t,s)}}}function wt(t){if(!t.editable)return;const e=A.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&ve(t,-1)}function Ct(t,e,n,o){var l;if(!t.editable)return!1;const r=(l=t.dom.ownerDocument.defaultView)!=null?l:window,s=A.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const i=t.state.doc.nodeAt(s.activeHandle),c=St(t,s.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(A,{setDragging:{startX:e.clientX,startWidth:c}}));function a(d){r.removeEventListener("mouseup",a),r.removeEventListener("mousemove",u);const f=A.getState(t.state);f!=null&&f.dragging&&(At(t,f.activeHandle,fe(f.dragging,d,n)),t.dispatch(t.state.tr.setMeta(A,{setDragging:null})))}function u(d){if(!d.which)return a(d);const f=A.getState(t.state);if(f&&f.dragging){const h=fe(f.dragging,d,n);he(t,f.activeHandle,h,o)}}return he(t,s.activeHandle,c,o),r.addEventListener("mouseup",a),r.addEventListener("mousemove",u),e.preventDefault(),!0}function St(t,e,{colspan:n,colwidth:o}){const l=o&&o[o.length-1];if(l)return l;const r=t.domAtPos(e);let i=r.node.childNodes[r.offset].offsetWidth,c=n;if(o)for(let a=0;a<n;a++)o[a]&&(i-=o[a],c--);return i/c}function yt(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function ue(t,e,n,o){const l=n=="right"?-o:o,r=t.posAtCoords({left:e.clientX+l,top:e.clientY});if(!r)return-1;const{pos:s}=r,i=_(t.state.doc.resolve(s));if(!i)return-1;if(n=="right")return i.pos;const c=S.get(i.node(-1)),a=i.start(-1),u=c.map.indexOf(i.pos-a);return u%c.width==0?-1:a+c.map[u-1]}function fe(t,e,n){const o=e.clientX-t.startX;return Math.max(n,t.startWidth+o)}function ve(t,e){t.dispatch(t.state.tr.setMeta(A,{setHandle:e}))}function At(t,e,n){const o=t.state.doc.resolve(e),l=o.node(-1),r=S.get(l),s=o.start(-1),i=r.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,c=t.state.tr;for(let a=0;a<r.height;a++){const u=a*r.width+i;if(a&&r.map[u]==r.map[u-r.width])continue;const d=r.map[u],f=l.nodeAt(d).attrs,h=f.colspan==1?0:i-r.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;const p=f.colwidth?f.colwidth.slice():xt(f.colspan);p[h]=n,c.setNodeMarkup(s+d,null,{...f,colwidth:p})}c.docChanged&&t.dispatch(c)}function he(t,e,n,o){const l=t.state.doc.resolve(e),r=l.node(-1),s=l.start(-1),i=S.get(r).colCount(l.pos-s)+l.nodeAfter.attrs.colspan-1;let c=t.domAtPos(l.start(-1)).node;for(;c&&c.nodeName!="TABLE";)c=c.parentNode;c&&Q(r,c.firstChild,c,o,i,n)}function xt(t){return Array(t).fill(0)}function Tt(t,e){var n;const o=[],l=t.doc.resolve(e),r=l.node(-1);if(!r)return m.DecorationSet.empty;const s=S.get(r),i=l.start(-1),c=s.colCount(l.pos-i)+l.nodeAfter.attrs.colspan-1;for(let a=0;a<s.height;a++){const u=c+a*s.width;if((c==s.width-1||s.map[u]!=s.map[u+1])&&(a==0||s.map[u]!=s.map[u-s.width])){const d=s.map[u],f=i+d+r.nodeAt(d).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(n=A.getState(t))!=null&&n.dragging&&o.push(m.Decoration.node(i+d,i+d+r.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),o.push(m.Decoration.widget(f,h))}}return m.DecorationSet.create(t.doc,o)}function Rt({allowTableNodeSelection:t=!1}={}){return new m.Plugin({key:k,state:{init(){return null},apply(e,n){const o=e.getMeta(k);if(o!=null)return o==-1?null:o;if(n==null||!e.docChanged)return n;const{deleted:l,pos:r}=e.mapping.mapResult(n);return l?null:r}},props:{decorations:$e,handleDOMEvents:{mousedown:ht},createSelectionBetween(e){return k.getState(e.state)!=null?e.state.selection:null},handleTripleClick:ut,handleKeyDown:dt,handlePaste:ft},appendTransaction(e,n,o){return Fe(o,xe(o,n),t)}})}function ee(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function pe(t,e,n,o,l,r){var s;let i=0,c=!0,a=e.firstChild;const u=t.firstChild;if(u!==null)for(let d=0,f=0;d<u.childCount;d+=1){const{colspan:h,colwidth:p}=u.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const b=l===f?r:p&&p[g],C=b?`${b}px`:"";if(i+=b||o,b||(c=!1),a){if(a.style.width!==C){const[x,E]=ee(o,b);a.style.setProperty(x,E)}a=a.nextSibling}else{const x=document.createElement("col"),[E,D]=ee(o,b);x.style.setProperty(E,D),e.appendChild(x)}}}for(;a;){const d=a.nextSibling;(s=a.parentNode)===null||s===void 0||s.removeChild(a),a=d}c?(n.style.width=`${i}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${i}px`)}class Mt{constructor(e,n){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")),pe(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,pe(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function vt(t,e,n,o){let l=0,r=!0;const s=[],i=t.firstChild;if(!i)return{};for(let d=0,f=0;d<i.childCount;d+=1){const{colspan:h,colwidth:p}=i.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const b=n===f?o:p&&p[g];l+=b||e,b||(r=!1);const[C,x]=ee(e,b);s.push(["col",{style:`${C}: ${x}`}])}}const c=r?`${l}px`:"",a=r?"":`${l}px`;return{colgroup:["colgroup",{},...s],tableWidth:c,tableMinWidth:a}}function me(t,e){return t.createAndFill()}function Et(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const o=t.nodes[n];o.spec.tableRole&&(e[o.spec.tableRole]=o)}),t.cached.tableNodeTypes=e,e}function Nt(t,e,n,o,l){const r=Et(t),s=[],i=[];for(let a=0;a<n;a+=1){const u=me(r.cell);if(u&&i.push(u),o){const d=me(r.header_cell);d&&s.push(d)}}const c=[];for(let a=0;a<e;a+=1)c.push(r.row.createChecked(null,o&&a===0?s:i));return r.table.createChecked(null,c)}function kt(t){return t instanceof w}const F=({editor:t})=>{const{selection:e}=t.state;if(!kt(e))return!1;let n=0;const o=m.findParentNodeClosestToPos(e.ranges[0].$from,r=>r.type.name==="table");return o==null||o.node.descendants(r=>{if(r.type.name==="table")return!1;["tableCell","tableHeader"].includes(r.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},zt=m.Node.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Mt,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:o,tableMinWidth:l}=vt(t,this.options.cellMinWidth);return["table",m.mergeAttributes(this.options.HTMLAttributes,e,{style:o?`width: ${o}`:`min-width: ${l}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:o,dispatch:l,editor:r})=>{const s=Nt(r.schema,t,e,n);if(l){const i=o.selection.from+1;o.replaceSelectionWith(s).scrollIntoView().setSelection(m.TextSelection.near(o.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Ge(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Ve(t,e),deleteColumn:()=>({state:t,dispatch:e})=>Xe(t,e),addRowBefore:()=>({state:t,dispatch:e})=>qe(t,e),addRowAfter:()=>({state:t,dispatch:e})=>Ue(t,e),deleteRow:()=>({state:t,dispatch:e})=>Ye(t,e),deleteTable:()=>({state:t,dispatch:e})=>rt(t,e),mergeCells:()=>({state:t,dispatch:e})=>oe(t,e),splitCell:()=>({state:t,dispatch:e})=>le(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>B("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>B("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>ot(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>oe(t,e)?!0:le(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:o})=>tt(t,e)(n,o),goToNextCell:()=>({state:t,dispatch:e})=>se(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>se(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&xe(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const o=w.create(e.doc,t.anchorCell,t.headCell);e.setSelection(o)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:F,"Mod-Backspace":F,Delete:F,"Mod-Delete":F}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[mt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Rt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:m.callOrReturn(m.getExtensionField(t,"tableRole",e))}}}),Lt=m.Node.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",m.mergeAttributes(this.options.HTMLAttributes,t),0]}}),_t=/(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,Dt=/CrOS/,Ht=/android|ipad|playbook|silk/i;function ge(t={}){let e=t.ua||typeof navigator<"u"&&navigator.userAgent;return e&&typeof e=="object"&&e.headers&&typeof e.headers["user-agent"]=="string"&&(e=e.headers["user-agent"]),typeof e!="string"?!1:!!(_t.test(e)&&!Dt.test(e)||t.tablet&&Ht.test(e)||t.tablet&&t.featureDetect&&navigator&&navigator.maxTouchPoints>1&&e.includes("Macintosh")&&e.includes("Safari"))}const be=t=>Array.from({length:t}).map((e,n)=>n+1);function Bt(t){var u;const[e,n]=X.useState(!0),[o,l]=X.useState({rows:ge()?T.TABLE_MAX_GRID_SIZE:T.TABLE_INIT_GRID_SIZE,cols:ge()?T.TABLE_MAX_GRID_SIZE:T.TABLE_INIT_GRID_SIZE}),[r,s]=X.useState({rows:T.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:T.TABLE_DEFAULT_SELECTED_GRID_SIZE});function i(d,f){d===o.rows&&l(h=>({...h,rows:Math.min(d+1,T.TABLE_MAX_GRID_SIZE)})),f===o.cols&&l(h=>({...h,cols:Math.min(f+1,T.TABLE_MAX_GRID_SIZE)})),s({rows:d,cols:f})}function c(d,f){t==null||t.createTable({rows:d,cols:f,withHeaderRow:e}),a()}function a(){n(!1),l({rows:T.TABLE_INIT_GRID_SIZE,cols:T.TABLE_INIT_GRID_SIZE}),s({rows:T.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:T.TABLE_DEFAULT_SELECTED_GRID_SIZE})}return R.jsxs(O.Popover,{modal:!0,children:[R.jsx(O.PopoverTrigger,{asChild:!0,children:t==null?void 0:t.children}),R.jsx(O.PopoverContent,{align:"start",className:"richtext-w-full !richtext-p-2",side:"bottom",children:R.jsxs("div",{className:"table-grid-size-editor richtext-p-0",children:[R.jsx("div",{className:"richtext-flex richtext-flex-col richtext-flex-wrap richtext-justify-between richtext-gap-1",children:(u=be(o==null?void 0:o.rows))==null?void 0:u.map(d=>{var f;return R.jsx("div",{className:"richtext-flex richtext-gap-1",children:(f=be(o==null?void 0:o.cols))==null?void 0:f.map(h=>R.jsx("div",{onMouseDown:()=>c(d,h),onMouseOver:()=>i(d,h),className:`richtext-cursor-pointer richtext-border-border ${h<=r.cols&&d<=r.rows&&"tableCellActive !richtext-bg-foreground"}`,children:R.jsx("div",{className:"richtext-box-border richtext-size-4 richtext-rounded-[2px] !richtext-border richtext-border-solid !richtext-border-border richtext-p-1"})},`c-${h}`))},`r-${d}`)})}),R.jsxs("div",{className:"richtext-mt-2 richtext-text-center richtext-text-sm richtext-text-zinc-600",children:[r.rows," ","x",r.cols]})]})})]})}function It(t){function e(n){t.disabled||t.editor.chain().focus().insertTable({...n,withHeaderRow:!1}).run()}return R.jsx(Bt,{createTable:e,children:R.jsx(O.ActionButton,{icon:t==null?void 0:t.icon,tooltip:t==null?void 0:t.tooltip,tooltipOptions:t==null?void 0:t.tooltipOptions,disabled:t==null?void 0:t.disabled,color:t==null?void 0:t.color,action:t==null?void 0:t.action,isActive:t==null?void 0:t.isActive})})}function $t(t,e,n){if(!t.doc)return t;const o=t.doc.nodeAt(e);if(!o||n===o.attrs.backgroundColor)return t;const l={...o.attrs,backgroundColor:n};return t.setNodeMarkup(e,o.type,l,o.marks)}function Wt(t,e,n){const{doc:o,selection:l}=t;return!o||!l||!(l instanceof w)||l.forEachCell((r,s)=>{t=$t(t,s,n)}),t}function we(t,e){return({tr:n,state:o,dispatch:l})=>{const{selection:r}=o;return n=n.setSelection(r),n=Wt(n,e,t),n.docChanged?(l==null||l(n),!0):!1}}const Pt=m.Extension.create({name:"tableCellBackground",addOptions(){return{types:["tableCell"],HTMLAttributes:{}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{parseHTML:t=>t.style.backgroundColor||"",renderHTML:t=>!t.backgroundColor||t.backgroundColor===""?{}:{style:`background-color: ${t.backgroundColor}`}}}}]},addCommands(){return{setTableCellBackground:t=>we(t,this.options),unsetTableCellBackground:()=>we("",this.options)}}}),Ft=m.Node.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",m.mergeAttributes(this.options.HTMLAttributes,t),0]}}),Ot=Ft.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),HTMLAttributes:{style:"border-bottom: 1px solid #000;"}}}}),jt=m.Node.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",m.mergeAttributes(this.options.HTMLAttributes,t),0]}}),Gt=jt.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),HTMLAttributes:{style:`
2
- border-right: 1px solid #000;
3
- padding: 8px 12px;
4
- &:last-child {
5
- border-right: none;
6
- }
7
- `}}}}),Ee=zt.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),HTMLAttributes:{style:`
8
- border: 1px solid #000;
9
- border-collapse: collapse;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("./index-DF2Lp4HZ.cjs"),c=require("./RichTextEditor-CxvwGvQG.cjs"),w=require("react/jsx-runtime"),_=require("react"),x=require("./index-6D1J-A-o.cjs");var N=g.Node3.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{var t,l;const r=e.getAttribute("colwidth"),o=r?r.split(",").map(n=>parseInt(n,10)):null;if(!o){const n=(t=e.closest("table"))==null?void 0:t.querySelectorAll("colgroup > col"),i=Array.from(((l=e.parentElement)==null?void 0:l.children)||[]).indexOf(e);if(i&&i>-1&&n&&n[i]){const a=n[i].getAttribute("width");return a?[parseInt(a,10)]:null}}return o}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",g.mergeAttributes(this.options.HTMLAttributes,e),0]}}),D=g.Node3.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:e}){return["th",g.mergeAttributes(this.options.HTMLAttributes,e),0]}}),W=g.Node3.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",g.mergeAttributes(this.options.HTMLAttributes,e),0]}});function R(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function v(e,t,l,r,o,n){var i;let a=0,C=!0,d=t.firstChild;const m=e.firstChild;if(m!==null)for(let f=0,p=0;f<m.childCount;f+=1){const{colspan:h,colwidth:b}=m.child(f).attrs;for(let s=0;s<h;s+=1,p+=1){const T=o===p?n:b&&b[s],y=T?`${T}px`:"";if(a+=T||r,T||(C=!1),d){if(d.style.width!==y){const[A,E]=R(r,T);d.style.setProperty(A,E)}d=d.nextSibling}else{const A=document.createElement("col"),[E,S]=R(r,T);A.style.setProperty(E,S),t.appendChild(A)}}}for(;d;){const f=d.nextSibling;(i=d.parentNode)==null||i.removeChild(d),d=f}const u=e.attrs.style&&typeof e.attrs.style=="string"&&/\bwidth\s*:/i.test(e.attrs.style);C&&!u?(l.style.width=`${a}px`,l.style.minWidth=""):(l.style.width="",l.style.minWidth=`${a}px`)}var $=class{constructor(e,t){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")),v(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,v(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){const t=e.target,l=this.dom.contains(t),r=this.contentDOM.contains(t);return!!(l&&!r&&(e.type==="attributes"||e.type==="childList"||e.type==="characterData"))}};function O(e,t,l,r){let o=0,n=!0;const i=[],a=e.firstChild;if(!a)return{};for(let u=0,f=0;u<a.childCount;u+=1){const{colspan:p,colwidth:h}=a.child(u).attrs;for(let b=0;b<p;b+=1,f+=1){const s=l===f?r:h&&h[b];o+=s||t,s||(n=!1);const[T,y]=R(t,s);i.push(["col",{style:`${T}: ${y}`}])}}const C=n?`${o}px`:"",d=n?"":`${o}px`;return{colgroup:["colgroup",{},...i],tableWidth:C,tableMinWidth:d}}function L(e,t){return e.createAndFill()}function z(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(l=>{const r=e.nodes[l];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function G(e,t,l,r,o){const n=z(e),i=[],a=[];for(let d=0;d<l;d+=1){const m=L(n.cell);if(m&&a.push(m),r){const u=L(n.header_cell);u&&i.push(u)}}const C=[];for(let d=0;d<t;d+=1)C.push(n.row.createChecked(null,r&&d===0?i:a));return n.table.createChecked(null,C)}function P(e){return e instanceof c.CellSelection}var M=({editor:e})=>{const{selection:t}=e.state;if(!P(t))return!1;let l=0;const r=g.findParentNodeClosestToPos(t.ranges[0].$from,n=>n.type.name==="table");return r==null||r.node.descendants(n=>{if(n.type.name==="table")return!1;["tableCell","tableHeader"].includes(n.type.name)&&(l+=1)}),l===t.ranges.length?(e.commands.deleteTable(),!0):!1},Z="";function F(e){return(e||"").replace(/\s+/g," ").trim()}function V(e,t,l={}){var r;const o=(r=l.cellLineSeparator)!=null?r:Z;if(!e||!e.content||e.content.length===0)return"";const n=[];e.content.forEach(h=>{const b=[];h.content&&h.content.forEach(s=>{let T="";s.content&&Array.isArray(s.content)&&s.content.length>1?T=s.content.map(S=>t.renderChildren(S)).join(o):T=s.content?t.renderChildren(s.content):"";const y=F(T),A=s.type==="tableHeader";b.push({text:y,isHeader:A})}),n.push(b)});const i=n.reduce((h,b)=>Math.max(h,b.length),0);if(i===0)return"";const a=new Array(i).fill(0);n.forEach(h=>{var b;for(let s=0;s<i;s+=1){const y=(((b=h[s])==null?void 0:b.text)||"").length;y>a[s]&&(a[s]=y),a[s]<3&&(a[s]=3)}});const C=(h,b)=>h+" ".repeat(Math.max(0,b-h.length)),d=n[0],m=d.some(h=>h.isHeader);let u=`
2
+ `;const f=new Array(i).fill(0).map((h,b)=>m&&d[b]&&d[b].text||"");return u+=`| ${f.map((h,b)=>C(h,a[b])).join(" | ")} |
3
+ `,u+=`| ${a.map(h=>"-".repeat(Math.max(3,h))).join(" | ")} |
4
+ `,(m?n.slice(1):n).forEach(h=>{u+=`| ${new Array(i).fill(0).map((b,s)=>C(h[s]&&h[s].text||"",a[s])).join(" | ")} |
5
+ `}),u}var q=V,B=g.Node3.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:$,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){const{colgroup:l,tableWidth:r,tableMinWidth:o}=O(e,this.options.cellMinWidth),n=t.style;function i(){return n||(r?`width: ${r}`:`min-width: ${o}`)}const a=["table",g.mergeAttributes(this.options.HTMLAttributes,t,{style:i()}),l,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},a]:a},parseMarkdown:(e,t)=>{const l=[];if(e.header){const r=[];e.header.forEach(o=>{r.push(t.createNode("tableHeader",{},[{type:"paragraph",content:t.parseInline(o.tokens)}]))}),l.push(t.createNode("tableRow",{},r))}return e.rows&&e.rows.forEach(r=>{const o=[];r.forEach(n=>{o.push(t.createNode("tableCell",{},[{type:"paragraph",content:t.parseInline(n.tokens)}]))}),l.push(t.createNode("tableRow",{},o))}),t.createNode("table",void 0,l)},renderMarkdown:(e,t)=>q(e,t),addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:l=!0}={})=>({tr:r,dispatch:o,editor:n})=>{const i=G(n.schema,e,t,l);if(o){const a=r.selection.from+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(g.TextSelection.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>c.addColumnBefore(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>c.addColumnAfter(e,t),deleteColumn:()=>({state:e,dispatch:t})=>c.deleteColumn(e,t),addRowBefore:()=>({state:e,dispatch:t})=>c.addRowBefore(e,t),addRowAfter:()=>({state:e,dispatch:t})=>c.addRowAfter(e,t),deleteRow:()=>({state:e,dispatch:t})=>c.deleteRow(e,t),deleteTable:()=>({state:e,dispatch:t})=>c.deleteTable(e,t),mergeCells:()=>({state:e,dispatch:t})=>c.mergeCells(e,t),splitCell:()=>({state:e,dispatch:t})=>c.splitCell(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>c.toggleHeader("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>c.toggleHeader("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>c.toggleHeaderCell(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>c.mergeCells(e,t)?!0:c.splitCell(e,t),setCellAttribute:(e,t)=>({state:l,dispatch:r})=>c.setCellAttr(e,t)(l,r),goToNextCell:()=>({state:e,dispatch:t})=>c.goToNextCell(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>c.goToNextCell(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&c.fixTables(e),!0),setCellSelection:e=>({tr:t,dispatch:l})=>{if(l){const r=c.CellSelection.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:M,"Mod-Backspace":M,Delete:M,"Mod-Delete":M}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[c.columnResizing({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],c.tableEditing({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:g.callOrReturn(g.getExtensionField(e,"tableRole",t))}}});g.Extension.create({name:"tableKit",addExtensions(){const e=[];return this.options.table!==!1&&e.push(B.configure(this.options.table)),this.options.tableCell!==!1&&e.push(N.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(D.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(W.configure(this.options.tableRow)),e}});const U=/(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,K=/CrOS/,X=/android|ipad|playbook|silk/i;function I(e={}){let t=e.ua||typeof navigator<"u"&&navigator.userAgent;return t&&typeof t=="object"&&t.headers&&typeof t.headers["user-agent"]=="string"&&(t=t.headers["user-agent"]),typeof t!="string"?!1:!!(U.test(t)&&!K.test(t)||e.tablet&&X.test(t)||e.tablet&&e.featureDetect&&navigator&&navigator.maxTouchPoints>1&&t.includes("Macintosh")&&t.includes("Safari"))}const H=e=>Array.from({length:e}).map((t,l)=>l+1);function J(e){var m;const[t,l]=_.useState(!0),[r,o]=_.useState({rows:I()?x.TABLE_MAX_GRID_SIZE:x.TABLE_INIT_GRID_SIZE,cols:I()?x.TABLE_MAX_GRID_SIZE:x.TABLE_INIT_GRID_SIZE}),[n,i]=_.useState({rows:x.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:x.TABLE_DEFAULT_SELECTED_GRID_SIZE});function a(u,f){u===r.rows&&o(p=>({...p,rows:Math.min(u+1,x.TABLE_MAX_GRID_SIZE)})),f===r.cols&&o(p=>({...p,cols:Math.min(f+1,x.TABLE_MAX_GRID_SIZE)})),i({rows:u,cols:f})}function C(u,f){e==null||e.createTable({rows:u,cols:f,withHeaderRow:t}),d()}function d(){l(!1),o({rows:x.TABLE_INIT_GRID_SIZE,cols:x.TABLE_INIT_GRID_SIZE}),i({rows:x.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:x.TABLE_DEFAULT_SELECTED_GRID_SIZE})}return w.jsxs(c.Popover,{modal:!0,children:[w.jsx(c.PopoverTrigger,{asChild:!0,children:e==null?void 0:e.children}),w.jsx(c.PopoverContent,{align:"start",className:"richtext-w-full !richtext-p-2",side:"bottom",children:w.jsxs("div",{className:"table-grid-size-editor richtext-p-0",children:[w.jsx("div",{className:"richtext-flex richtext-flex-col richtext-flex-wrap richtext-justify-between richtext-gap-1",children:(m=H(r==null?void 0:r.rows))==null?void 0:m.map(u=>{var f;return w.jsx("div",{className:"richtext-flex richtext-gap-1",children:(f=H(r==null?void 0:r.cols))==null?void 0:f.map(p=>w.jsx("div",{onMouseDown:()=>C(u,p),onMouseOver:()=>a(u,p),className:`richtext-cursor-pointer richtext-border-border ${p<=n.cols&&u<=n.rows&&"tableCellActive !richtext-bg-foreground"}`,children:w.jsx("div",{className:"richtext-box-border richtext-size-4 richtext-rounded-[2px] !richtext-border richtext-border-solid !richtext-border-border richtext-p-1"})},`c-${p}`))},`r-${u}`)})}),w.jsxs("div",{className:"richtext-mt-2 richtext-text-center richtext-text-sm richtext-text-zinc-600",children:[n.rows," ","x",n.cols]})]})})]})}function Q(e){function t(l){e.disabled||e.editor.chain().focus().insertTable({...l,withHeaderRow:!1}).run()}return w.jsx(J,{createTable:t,children:w.jsx(c.ActionButton,{icon:e==null?void 0:e.icon,tooltip:e==null?void 0:e.tooltip,tooltipOptions:e==null?void 0:e.tooltipOptions,disabled:e==null?void 0:e.disabled,color:e==null?void 0:e.color,action:e==null?void 0:e.action,isActive:e==null?void 0:e.isActive})})}function Y(e,t,l){if(!e.doc)return e;const r=e.doc.nodeAt(t);if(!r||l===r.attrs.backgroundColor)return e;const o={...r.attrs,backgroundColor:l};return e.setNodeMarkup(t,r.type,o,r.marks)}function ee(e,t,l){const{doc:r,selection:o}=e;return!r||!o||!(o instanceof c.CellSelection)||o.forEachCell((n,i)=>{e=Y(e,i,l)}),e}function k(e,t){return({tr:l,state:r,dispatch:o})=>{const{selection:n}=r;return l=l.setSelection(n),l=ee(l,t,e),l.docChanged?(o==null||o(l),!0):!1}}const te=g.Extension.create({name:"tableCellBackground",addOptions(){return{types:["tableCell"],HTMLAttributes:{}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{parseHTML:e=>e.style.backgroundColor||"",renderHTML:e=>!e.backgroundColor||e.backgroundColor===""?{}:{style:`background-color: ${e.backgroundColor}`}}}}]},addCommands(){return{setTableCellBackground:e=>k(e,this.options),unsetTableCellBackground:()=>k("",this.options)}}}),j=B.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{style:`
6
+ border: 1px solid #000;
7
+ border-collapse: collapse;
10
8
  width: 100%;
11
- `},resizable:!0,lastColumnResizable:!0,allowTableNodeSelection:!1,button:({editor:e,t:n})=>({component:It,componentProps:{disabled:e.isActive("table")||!1,icon:"Table",tooltip:n("editor.table.tooltip"),editor:e}})}},addExtensions(){return[Ot.configure(this.options.tableRow),Lt.configure(this.options.tableHeader),Gt.configure(this.options.tableCell),Pt.configure(this.options.tableCellBackground)]}});exports.Table=Ee;exports.default=Ee;
9
+ `},resizable:!0,lastColumnResizable:!0,allowTableNodeSelection:!1,button:({editor:t,t:l})=>({component:Q,componentProps:{disabled:t.isActive("table")||!1,icon:"Table",tooltip:l("editor.table.tooltip"),editor:t}})}},addExtensions(){return[W.configure(this.options.tableRow),D.configure(this.options.tableHeader),N.configure(this.options.tableCell),te.configure(this.options.tableCellBackground)]}});exports.Table=j;exports.default=j;
package/lib/Table.d.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Editor } from '@tiptap/react';
2
2
  import { Extension } from '@tiptap/core';
3
3
  import { Node as Node_2 } from '@tiptap/core';
4
- import { TableCellOptions } from '@tiptap/extension-table-cell';
5
- import { TableHeaderOptions } from '@tiptap/extension-table-header';
6
- import { TableRowOptions } from '@tiptap/extension-table-row';
4
+ import { TableCellOptions } from '@tiptap/extension-table';
5
+ import { TableHeaderOptions } from '@tiptap/extension-table';
6
+ import { TableRowOptions } from '@tiptap/extension-table';
7
7
 
8
8
  /**
9
9
  * Represents the ButtonView function.
@@ -135,9 +135,8 @@ declare module '@tiptap/core' {
135
135
 
136
136
  declare module '@tiptap/core' {
137
137
  interface Commands<ReturnType> {
138
- drawer: {
139
- setDrawer: (options: any, replace?: any) => ReturnType;
140
- setAlignImageDrawer: (align: 'left' | 'center' | 'right') => ReturnType;
138
+ excalidraw: {
139
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
141
140
  };
142
141
  }
143
142
  }
@@ -145,11 +144,9 @@ declare module '@tiptap/core' {
145
144
 
146
145
  declare module '@tiptap/core' {
147
146
  interface Commands<ReturnType> {
148
- emoji: {
149
- setEmoji: (emoji: {
150
- name: string;
151
- emoji: string;
152
- }) => ReturnType;
147
+ drawer: {
148
+ setDrawer: (options: any, replace?: any) => ReturnType;
149
+ setAlignImageDrawer: (align: 'left' | 'center' | 'right') => ReturnType;
153
150
  };
154
151
  }
155
152
  }
@@ -157,8 +154,8 @@ declare module '@tiptap/core' {
157
154
 
158
155
  declare module '@tiptap/core' {
159
156
  interface Commands<ReturnType> {
160
- excalidraw: {
161
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
157
+ exportPdf: {
158
+ exportToPdf: () => ReturnType;
162
159
  };
163
160
  }
164
161
  }
@@ -166,8 +163,8 @@ declare module '@tiptap/core' {
166
163
 
167
164
  declare module '@tiptap/core' {
168
165
  interface Commands<ReturnType> {
169
- exportPdf: {
170
- exportToPdf: () => ReturnType;
166
+ exportWord: {
167
+ exportToWord: () => ReturnType;
171
168
  };
172
169
  }
173
170
  }
@@ -175,8 +172,8 @@ declare module '@tiptap/core' {
175
172
 
176
173
  declare module '@tiptap/core' {
177
174
  interface Commands<ReturnType> {
178
- exportWord: {
179
- exportToWord: () => ReturnType;
175
+ painter: {
176
+ setPainter: (marks: Mark[]) => ReturnType;
180
177
  };
181
178
  }
182
179
  }
@@ -200,15 +197,6 @@ declare module '@tiptap/core' {
200
197
  }
201
198
 
202
199
 
203
- declare module '@tiptap/core' {
204
- interface Commands<ReturnType> {
205
- painter: {
206
- setPainter: (marks: Mark[]) => ReturnType;
207
- };
208
- }
209
- }
210
-
211
-
212
200
  declare module '@tiptap/core' {
213
201
  interface Commands<ReturnType> {
214
202
  iframe: {
@@ -264,6 +252,15 @@ declare module '@tiptap/core' {
264
252
  }
265
253
 
266
254
 
255
+ declare module '@tiptap/core' {
256
+ interface Commands<ReturnType> {
257
+ katex: {
258
+ setKatex: (arg?: IKatexAttrs) => ReturnType;
259
+ };
260
+ }
261
+ }
262
+
263
+
267
264
  declare module '@tiptap/core' {
268
265
  interface Commands<ReturnType> {
269
266
  indent: {
@@ -282,8 +279,9 @@ declare module '@tiptap/core' {
282
279
 
283
280
  declare module '@tiptap/core' {
284
281
  interface Commands<ReturnType> {
285
- katex: {
286
- setKatex: (arg?: IKatexAttrs) => ReturnType;
282
+ lineHeight: {
283
+ setLineHeight: (lineHeight: string) => ReturnType;
284
+ unsetLineHeight: () => ReturnType;
287
285
  };
288
286
  }
289
287
  }
@@ -291,9 +289,13 @@ declare module '@tiptap/core' {
291
289
 
292
290
  declare module '@tiptap/core' {
293
291
  interface Commands<ReturnType> {
294
- lineHeight: {
295
- setLineHeight: (lineHeight: string) => ReturnType;
296
- unsetLineHeight: () => ReturnType;
292
+ columns: {
293
+ insertColumns: (attrs?: {
294
+ cols: number;
295
+ }) => ReturnType;
296
+ addColBefore: () => ReturnType;
297
+ addColAfter: () => ReturnType;
298
+ deleteCol: () => ReturnType;
297
299
  };
298
300
  }
299
301
  }
@@ -311,13 +313,9 @@ declare module '@tiptap/core' {
311
313
 
312
314
  declare module '@tiptap/core' {
313
315
  interface Commands<ReturnType> {
314
- columns: {
315
- insertColumns: (attrs?: {
316
- cols: number;
317
- }) => ReturnType;
318
- addColBefore: () => ReturnType;
319
- addColAfter: () => ReturnType;
320
- deleteCol: () => ReturnType;
316
+ tableOfContents: {
317
+ setTableOfContents: () => ReturnType;
318
+ removeTableOfContents: () => ReturnType;
321
319
  };
322
320
  }
323
321
  }
@@ -328,22 +326,20 @@ declare module '@tiptap/core' {
328
326
  search: {
329
327
  setSearchTerm: (searchTerm: string) => ReturnType;
330
328
  setReplaceTerm: (replaceTerm: string) => ReturnType;
329
+ setCaseSensitive: (caseSensitive: boolean) => ReturnType;
330
+ resetIndex: () => ReturnType;
331
+ nextSearchResult: () => ReturnType;
332
+ previousSearchResult: () => ReturnType;
331
333
  replace: () => ReturnType;
332
334
  replaceAll: () => ReturnType;
333
- goToPrevSearchResult: () => void;
334
- goToNextSearchResult: () => void;
335
- setCaseSensitive: (caseSensitive: boolean) => ReturnType;
336
335
  };
337
336
  }
338
337
  }
339
338
 
340
339
 
341
340
  declare module '@tiptap/core' {
342
- interface Commands<ReturnType> {
343
- tableOfContents: {
344
- setTableOfContents: () => ReturnType;
345
- removeTableOfContents: () => ReturnType;
346
- };
341
+ interface Storage {
342
+ searchAndReplace: SearchAndReplaceStorage;
347
343
  }
348
344
  }
349
345