reactjs-tiptap-editor 1.0.25 → 1.0.26

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 (289) hide show
  1. package/lib/{ActionMenuButton-8cTG45Ft.js → ActionMenuButton-B4KDkZ0z.js} +1 -1
  2. package/lib/{ActionMenuButton-CXeFhner.cjs → ActionMenuButton-C3Cfeza9.cjs} +1 -1
  3. package/lib/Attachment.cjs +1 -1
  4. package/lib/Attachment.js +25 -25
  5. package/lib/Blockquote.cjs +5 -5
  6. package/lib/Blockquote.js +1490 -53
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +3 -3
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +2 -2
  11. package/lib/Callout.cjs +1 -1
  12. package/lib/Callout.js +222 -8
  13. package/lib/Clear.cjs +1 -1
  14. package/lib/Clear.js +2 -2
  15. package/lib/Code.cjs +1 -1
  16. package/lib/Code.js +56 -39
  17. package/lib/CodeBlock.cjs +1 -1
  18. package/lib/CodeBlock.js +8 -4
  19. package/lib/CodeView.cjs +1 -1
  20. package/lib/CodeView.js +2 -2
  21. package/lib/Color.cjs +1 -1
  22. package/lib/Color.js +3 -3
  23. package/lib/Column.cjs +1 -1
  24. package/lib/Column.js +2 -2
  25. package/lib/{Drawer-TJY4NuHx.cjs → Drawer-D7E9kTca.cjs} +1 -1
  26. package/lib/{Drawer-C-EO1uoK.js → Drawer-DA0FLHs9.js} +20 -20
  27. package/lib/Drawer.cjs +1 -1
  28. package/lib/Drawer.js +4 -4
  29. package/lib/Emoji.cjs +1 -1
  30. package/lib/Emoji.js +1644 -148
  31. package/lib/Excalidraw.cjs +1 -1
  32. package/lib/Excalidraw.js +10 -10
  33. package/lib/ExportPdf.cjs +1 -1
  34. package/lib/ExportPdf.js +2 -2
  35. package/lib/ExportWord.cjs +1 -1
  36. package/lib/ExportWord.js +2 -2
  37. package/lib/FontFamily.cjs +1 -1
  38. package/lib/FontFamily.js +5 -5
  39. package/lib/FontSize.cjs +1 -1
  40. package/lib/FontSize.js +5 -5
  41. package/lib/FormatPainter.cjs +1 -0
  42. package/lib/FormatPainter.js +133 -0
  43. package/lib/Heading.cjs +1 -1
  44. package/lib/Heading.js +10 -6
  45. package/lib/Highlight.cjs +1 -1
  46. package/lib/Highlight.js +3 -3
  47. package/lib/History.cjs +7 -1
  48. package/lib/History.js +519 -478
  49. package/lib/HorizontalRule.cjs +1 -1
  50. package/lib/HorizontalRule.js +2 -2
  51. package/lib/{Iframe-CGb6-2LD.js → Iframe-DZ3r3QzK.js} +7 -7
  52. package/lib/{Iframe-5zx43DL4.cjs → Iframe-OMVd0xa_.cjs} +1 -1
  53. package/lib/Iframe.cjs +1 -1
  54. package/lib/Iframe.js +3 -3
  55. package/lib/Image.cjs +1 -1
  56. package/lib/Image.js +6 -6
  57. package/lib/ImageGif.cjs +1 -1
  58. package/lib/ImageGif.js +35 -35
  59. package/lib/ImportWord.cjs +1 -1
  60. package/lib/ImportWord.js +15 -15
  61. package/lib/{Indent-DuwV8s1t.cjs → Indent-QgCoonRk.cjs} +1 -1
  62. package/lib/{Indent-CdMYsDNS.js → Indent-kI4G-clX.js} +2 -2
  63. package/lib/Indent.cjs +1 -1
  64. package/lib/Indent.js +2 -2
  65. package/lib/Italic.cjs +1 -1
  66. package/lib/Italic.js +2 -2
  67. package/lib/{Katex-CCP_ZQz2.js → Katex-BPbXjcZQ.js} +6 -7
  68. package/lib/Katex-CUofhjB5.cjs +4 -0
  69. package/lib/Katex.cjs +1 -1
  70. package/lib/Katex.js +3 -3
  71. package/lib/LineHeight.cjs +1 -1
  72. package/lib/LineHeight.js +4 -4
  73. package/lib/Link.cjs +1 -1
  74. package/lib/Link.js +2 -2
  75. package/lib/{LinkEditBlock-B1m-TVMu.js → LinkEditBlock-BYWwH2_x.js} +59 -32
  76. package/lib/{LinkEditBlock-DQ8-iufJ.cjs → LinkEditBlock-Z7RRurvx.cjs} +2 -2
  77. package/lib/MarkdownPaste.cjs +1 -1
  78. package/lib/MarkdownPaste.js +1 -1
  79. package/lib/Mention.cjs +1 -1
  80. package/lib/Mention.js +9 -5
  81. package/lib/Mermaid.cjs +2 -2
  82. package/lib/Mermaid.js +61 -62
  83. package/lib/MoreMark.cjs +1 -1
  84. package/lib/MoreMark.js +5 -5
  85. package/lib/OrderedList.cjs +1 -1
  86. package/lib/OrderedList.js +2 -2
  87. package/lib/SearchAndReplace.cjs +1 -1
  88. package/lib/SearchAndReplace.js +14 -14
  89. package/lib/SlashCommand.cjs +1 -1
  90. package/lib/SlashCommand.js +7 -7
  91. package/lib/{SlashCommandNodeView-Dt6n1SP9.js → SlashCommandNodeView-C0l3Fb_3.js} +10 -10
  92. package/lib/{SlashCommandNodeView-DNixmQGa.cjs → SlashCommandNodeView-DPPmYEjC.cjs} +1 -1
  93. package/lib/Strike.cjs +1 -1
  94. package/lib/Strike.js +2 -2
  95. package/lib/{Table-C5JxBXef.cjs → Table-D5G3rfwb.cjs} +5 -5
  96. package/lib/{Table-DdEgaUwa.js → Table-DwseaFSD.js} +115 -97
  97. package/lib/Table.cjs +1 -1
  98. package/lib/Table.js +1 -1
  99. package/lib/TaskList.cjs +1 -1
  100. package/lib/TaskList.js +2 -2
  101. package/lib/TextAlign.cjs +1 -1
  102. package/lib/TextAlign.js +11 -11
  103. package/lib/TextDirection.cjs +1 -1
  104. package/lib/TextDirection.js +3 -3
  105. package/lib/TextUnderline.cjs +1 -1
  106. package/lib/TextUnderline.js +2 -2
  107. package/lib/{Twitter-Dnz9qyW0.js → Twitter-DP26Lkn8.js} +195 -195
  108. package/lib/Twitter-q4ZGZL0i.cjs +1 -0
  109. package/lib/Twitter.cjs +1 -1
  110. package/lib/Twitter.js +3 -3
  111. package/lib/Video.cjs +1 -1
  112. package/lib/Video.js +5 -5
  113. package/lib/bubble.cjs +6 -6
  114. package/lib/bubble.js +2783 -2137
  115. package/lib/{clsx-D6gYQn3o.cjs → clsx-DRbkQ4T7.cjs} +1 -1
  116. package/lib/{clsx-0OU6n9va.js → clsx-_bq4MQQ7.js} +14 -4
  117. package/lib/components/Bubble/RichTextBubbleCallout.d.ts +1 -1
  118. package/lib/components/Bubble/RichTextBubbleCodeBlock.d.ts +1 -1
  119. package/lib/components/Bubble/RichTextBubbleColumns.d.ts +1 -1
  120. package/lib/components/Bubble/RichTextBubbleDrawer.d.ts +1 -1
  121. package/lib/components/Bubble/RichTextBubbleExcalidraw.d.ts +1 -1
  122. package/lib/components/Bubble/RichTextBubbleIframe.d.ts +1 -1
  123. package/lib/components/Bubble/RichTextBubbleKatex.d.ts +2 -1
  124. package/lib/components/Bubble/RichTextBubbleLink.d.ts +1 -1
  125. package/lib/components/Bubble/RichTextBubbleMedia.d.ts +3 -3
  126. package/lib/components/Bubble/RichTextBubbleMenuDragHandle.d.ts +2 -1
  127. package/lib/components/Bubble/RichTextBubbleMermaid.d.ts +1 -1
  128. package/lib/components/Bubble/RichTextBubbleTable.d.ts +1 -1
  129. package/lib/components/Bubble/RichTextBubbleText.d.ts +1 -1
  130. package/lib/components/Bubble/RichTextBubbleTwitter.d.ts +1 -1
  131. package/lib/components/ColorPicker.d.ts +1 -1
  132. package/lib/components/ReactBus.d.ts +1 -1
  133. package/lib/components/RichTextProvider.d.ts +1 -1
  134. package/lib/components/SlashDialogTrigger/RenderDialogUploadImage.d.ts +1 -1
  135. package/lib/components/SlashDialogTrigger/RenderDialogUploadVideo.d.ts +1 -1
  136. package/lib/components/SlashDialogTrigger/SlashDialogTrigger.d.ts +2 -1
  137. package/lib/components/icons/Activity.d.ts +2 -1
  138. package/lib/components/icons/Animas.d.ts +2 -1
  139. package/lib/components/icons/AspectRatio.d.ts +1 -1
  140. package/lib/components/icons/Blockquote.d.ts +1 -1
  141. package/lib/components/icons/CodeView.d.ts +1 -1
  142. package/lib/components/icons/ColumnAddLeft.d.ts +1 -1
  143. package/lib/components/icons/ColumnAddRight.d.ts +1 -1
  144. package/lib/components/icons/DeleteColumn.d.ts +1 -1
  145. package/lib/components/icons/DeleteRow.d.ts +1 -1
  146. package/lib/components/icons/Direction.d.ts +1 -1
  147. package/lib/components/icons/Excalidraw.d.ts +1 -1
  148. package/lib/components/icons/ExportPdf.d.ts +1 -1
  149. package/lib/components/icons/ExportWord.d.ts +2 -1
  150. package/lib/components/icons/FileWordOutline.d.ts +1 -1
  151. package/lib/components/icons/Flag.d.ts +2 -1
  152. package/lib/components/icons/Food.d.ts +2 -1
  153. package/lib/components/icons/GIfIcon.d.ts +1 -1
  154. package/lib/components/icons/Html.d.ts +1 -1
  155. package/lib/components/icons/Icon.d.ts +1 -1
  156. package/lib/components/icons/IconColorFill.d.ts +1 -1
  157. package/lib/components/icons/IconHighlightFill.d.ts +1 -1
  158. package/lib/components/icons/ImportWord.d.ts +2 -1
  159. package/lib/components/icons/LeftToRight.d.ts +1 -1
  160. package/lib/components/icons/LineHeight.d.ts +1 -1
  161. package/lib/components/icons/MenuDown.d.ts +1 -1
  162. package/lib/components/icons/Mermaid.d.ts +1 -1
  163. package/lib/components/icons/NoFill.d.ts +1 -1
  164. package/lib/components/icons/Object.d.ts +2 -1
  165. package/lib/components/icons/RightToLeft.d.ts +1 -1
  166. package/lib/components/icons/SizeL.d.ts +1 -1
  167. package/lib/components/icons/SizeM.d.ts +1 -1
  168. package/lib/components/icons/SizeS.d.ts +1 -1
  169. package/lib/components/icons/Symbol.d.ts +2 -1
  170. package/lib/components/icons/Travel.d.ts +2 -1
  171. package/lib/components/icons/Twitter.d.ts +1 -1
  172. package/lib/components/ui/dialog.d.ts +2 -2
  173. package/lib/components/ui/dropdown-menu.d.ts +1 -1
  174. package/lib/components/ui/emoji-picker.d.ts +4 -4
  175. package/lib/components/ui/toaster.d.ts +1 -1
  176. package/lib/{dropdown-menu-ROihzXsP.js → dropdown-menu-BKSX4gvT.js} +1 -1
  177. package/lib/{dropdown-menu-yQ-sQ1k4.cjs → dropdown-menu-CURWpB9o.cjs} +1 -1
  178. package/lib/extensions/Attachment/components/NodeViewAttachment/FileIcon.d.ts +1 -1
  179. package/lib/extensions/Attachment/components/NodeViewAttachment/NodeViewAttachment.d.ts +1 -1
  180. package/lib/extensions/Attachment/components/RichTextAttachment.d.ts +1 -1
  181. package/lib/extensions/Blockquote/components/RichTextBlockquote.d.ts +1 -1
  182. package/lib/extensions/Bold/components/RichTextBold.d.ts +1 -1
  183. package/lib/extensions/BulletList/components/RichTextBulletList.d.ts +1 -1
  184. package/lib/extensions/Callout/components/NodeViewCallout/NodeViewCallout.d.ts +1 -1
  185. package/lib/extensions/Callout/components/RichTextCallout.d.ts +1 -1
  186. package/lib/extensions/Clear/components/RichTextClear.d.ts +1 -1
  187. package/lib/extensions/Code/components/RichTextCode.d.ts +1 -1
  188. package/lib/extensions/CodeBlock/components/RichTextCodeBlock.d.ts +2 -1
  189. package/lib/extensions/CodeView/components/RichTextCodeView.d.ts +1 -1
  190. package/lib/extensions/Color/components/RichTextColor.d.ts +1 -1
  191. package/lib/extensions/Column/components/RichTextColumn.d.ts +1 -1
  192. package/lib/extensions/Drawer/components/ControlDrawer/ControlDrawer.d.ts +2 -1
  193. package/lib/extensions/Drawer/components/ControlDrawer/icon.d.ts +27 -27
  194. package/lib/extensions/Drawer/components/EditDrawerBlock.d.ts +1 -1
  195. package/lib/extensions/Drawer/components/NodeViewDrawer/NodeViewDrawer.d.ts +2 -1
  196. package/lib/extensions/Drawer/components/RichTextDrawer.d.ts +1 -1
  197. package/lib/extensions/Emoji/components/RichTextEmoji.d.ts +2 -1
  198. package/lib/extensions/Excalidraw/components/NodeViewExcalidraw/NodeViewExcalidraw.d.ts +2 -1
  199. package/lib/extensions/Excalidraw/components/RichTextExcalidraw.d.ts +1 -1
  200. package/lib/extensions/ExportPdf/components/RichTextExportPdf.d.ts +1 -1
  201. package/lib/extensions/ExportWord/components/RichTextExportWord.d.ts +1 -1
  202. package/lib/extensions/FontFamily/components/RichTextFontFamily.d.ts +1 -1
  203. package/lib/extensions/FontSize/components/RichTextFontSize.d.ts +1 -1
  204. package/lib/extensions/FormatPainter/FormatPainter.d.ts +17 -0
  205. package/lib/extensions/FormatPainter/components/RichTextFormatPainter.d.ts +1 -0
  206. package/lib/extensions/FormatPainter/index.d.ts +1 -0
  207. package/lib/extensions/Heading/components/RichTextHeading.d.ts +1 -1
  208. package/lib/extensions/Highlight/components/RichTextHighlight.d.ts +2 -1
  209. package/lib/extensions/History/components/RichTextHistory.d.ts +3 -2
  210. package/lib/extensions/HorizontalRule/components/RichTextHorizontalRule.d.ts +1 -1
  211. package/lib/extensions/Iframe/components/IframeNodeView.d.ts +1 -1
  212. package/lib/extensions/Iframe/components/RichTextIframe.d.ts +1 -1
  213. package/lib/extensions/Image/components/ImageCropper.d.ts +2 -1
  214. package/lib/extensions/Image/components/ImageView.d.ts +2 -1
  215. package/lib/extensions/Image/components/RichTextImage.d.ts +1 -1
  216. package/lib/extensions/ImageGif/components/ImageGifView.d.ts +2 -1
  217. package/lib/extensions/ImageGif/components/RichTextImageGif.d.ts +2 -1
  218. package/lib/extensions/ImportWord/components/RichTextImportWord.d.ts +1 -1
  219. package/lib/extensions/Indent/components/RichTextIndent.d.ts +1 -1
  220. package/lib/extensions/Italic/components/RichTextItalic.d.ts +1 -1
  221. package/lib/extensions/Katex/components/KatexWrapper.d.ts +1 -1
  222. package/lib/extensions/Katex/components/RichTextKatex.d.ts +1 -1
  223. package/lib/extensions/LineHeight/components/RichTextLightHeight.d.ts +1 -1
  224. package/lib/extensions/Link/components/LinkEditBlock.d.ts +1 -1
  225. package/lib/extensions/Link/components/LinkViewBlock.d.ts +2 -1
  226. package/lib/extensions/Link/components/RichTextLink.d.ts +1 -1
  227. package/lib/extensions/Mermaid/components/NodeViewMermaid/NodeViewMermaid.d.ts +2 -1
  228. package/lib/extensions/Mermaid/components/RichTextMermaid.d.ts +1 -1
  229. package/lib/extensions/MoreMark/components/RichTextMoreMark.d.ts +1 -1
  230. package/lib/extensions/OrderedList/components/RichTextOrderedList.d.ts +1 -1
  231. package/lib/extensions/SearchAndReplace/components/RichTextSearchAndReplace.d.ts +1 -1
  232. package/lib/extensions/SlashCommand/components/SlashCommandList.d.ts +1 -1
  233. package/lib/extensions/Strike/components/RichTextStrike.d.ts +1 -1
  234. package/lib/extensions/Table/components/CreateTablePopover.d.ts +2 -1
  235. package/lib/extensions/Table/components/RichTextTable.d.ts +2 -1
  236. package/lib/extensions/TaskList/components/RichTextTaskList.d.ts +1 -1
  237. package/lib/extensions/TextAlign/components/RichTextAlign.d.ts +1 -1
  238. package/lib/extensions/TextDirection/components/RichTextTextDirection.d.ts +1 -1
  239. package/lib/extensions/TextUnderline/components/RichTextUnderline.d.ts +1 -1
  240. package/lib/extensions/Twitter/components/FormEditLinkTwitter.d.ts +1 -1
  241. package/lib/extensions/Twitter/components/NodeViewTweet.d.ts +1 -1
  242. package/lib/extensions/Twitter/components/RichTextTwitter.d.ts +1 -1
  243. package/lib/extensions/Video/components/RichTextVideo.d.ts +1 -1
  244. package/lib/index-BGfIcDCQ.cjs +26 -0
  245. package/lib/index-BaR0Brts.js +1115 -0
  246. package/lib/index-BgNKVyMW.cjs +2 -0
  247. package/lib/index-BpLw6ebr.cjs +1 -0
  248. package/lib/{index-X6WZUM9O.js → index-C52cuQ_Y.js} +1503 -1352
  249. package/lib/index-CDw4Eszh.cjs +12 -0
  250. package/lib/{index-CUvjYuRp.cjs → index-CHVV5iY-.cjs} +1 -1
  251. package/lib/{index-zw-Kd38i.js → index-CJMI7Fjf.js} +1 -1
  252. package/lib/{index-D-Ouz0vF.js → index-DQy9iBzV.js} +1 -1
  253. package/lib/index-Dbm_Mans.js +1756 -0
  254. package/lib/{index-oj858lQO.js → index-DtyAGMbq.js} +208 -208
  255. package/lib/{index-BblvcbTH.js → index-Dx-Dh7KS.js} +1464 -1348
  256. package/lib/{index-BAb_UADw.cjs → index-SEMQrdk2.cjs} +1 -1
  257. package/lib/index-aujjnfSJ.cjs +1 -0
  258. package/lib/index.cjs +1 -1
  259. package/lib/index.js +12 -12
  260. package/lib/{jsx-runtime-CT7Pcg-t.js → jsx-runtime-DE8oVoME.js} +3 -1
  261. package/lib/locale-bundle.cjs +1 -1
  262. package/lib/locale-bundle.js +1 -1
  263. package/lib/locales/index.d.ts +1 -1
  264. package/lib/{popover-BfWFqCIs.js → popover-BB-ZDnqk.js} +1 -1
  265. package/lib/{popover-BPzkMuyi.cjs → popover-CrywEkBR.cjs} +1 -1
  266. package/lib/{renderNodeView-D--fDFov.cjs → renderNodeView-5h3-p80E.cjs} +1 -1
  267. package/lib/{renderNodeView-CfWJK4rG.js → renderNodeView-DoKZ4GYy.js} +2 -2
  268. package/lib/{separator-DpaS43Gt.cjs → separator-BGO9AZp4.cjs} +1 -1
  269. package/lib/{separator-CBPrZizK.js → separator-DuuOJRQd.js} +21 -21
  270. package/lib/store/EditorEditableReactive.d.ts +1 -1
  271. package/lib/store/ThemeColorReactive.d.ts +1 -1
  272. package/lib/style.css +1 -1
  273. package/lib/types.d.ts +2 -2
  274. package/lib/{updatePosition-DGPtRfWN.cjs → updatePosition-B1oRJE1x.cjs} +1 -1
  275. package/lib/{updatePosition-BwzAsiY0.js → updatePosition-CFTYKYNJ.js} +2 -2
  276. package/package.json +79 -66
  277. package/lib/Callout-DWOMZPiP.cjs +0 -1
  278. package/lib/Callout-ZlPQrMEt.js +0 -340
  279. package/lib/Katex-D9FP7EUE.cjs +0 -4
  280. package/lib/Twitter--tfifMt1.cjs +0 -1
  281. package/lib/index-BF3EVCB1.cjs +0 -2
  282. package/lib/index-Bcj8cyOO.cjs +0 -24
  283. package/lib/index-CGjT-a9h.js +0 -1377
  284. package/lib/index-CPTpXLfX.cjs +0 -11
  285. package/lib/index-CWw4s87s.cjs +0 -1
  286. package/lib/index-Cal5SPfB.js +0 -779
  287. package/lib/index-Gi752TMk.cjs +0 -1
  288. package/lib/textarea-Bl64keav.js +0 -20
  289. package/lib/textarea-wvARZKyA.cjs +0 -1
@@ -1,23 +1,23 @@
1
- import { E as Q } from "./index-BblvcbTH.js";
1
+ import { E as Q } from "./index-Dx-Dh7KS.js";
2
2
  import { Plugin as X, PluginKey as Y } from "@tiptap/pm/state";
3
3
  import { DecorationSet as $, Decoration as Z } from "@tiptap/pm/view";
4
4
  import { jsx as u, Fragment as _, jsxs as T } from "react/jsx-runtime";
5
5
  import { useState as b, useEffect as k } from "react";
6
- import { h as ee, u as te, e as se, A as re, L as B, j as V, B as N, I as q, C as ne } from "./index-X6WZUM9O.js";
6
+ import { h as ee, u as te, e as se, A as re, L as B, k as V, B as N, I as q, C as ne } from "./index-C52cuQ_Y.js";
7
7
  import "./theme.js";
8
- import { u as ce } from "./index-oj858lQO.js";
9
- import { P as ae, a as le, b as oe } from "./popover-BfWFqCIs.js";
8
+ import { P as ce, a as ae, b as le } from "./popover-BB-ZDnqk.js";
9
+ import { u as oe } from "./index-DtyAGMbq.js";
10
10
  function Ce() {
11
- const { t } = ce(), e = ee(), s = te(xe.name), {
11
+ const { t } = oe(), e = ee(), s = te(xe.name), {
12
12
  icon: n = void 0,
13
13
  tooltip: i = void 0,
14
14
  shortcutKeys: l = void 0,
15
15
  tooltipOptions: c = {},
16
16
  action: h = void 0,
17
17
  isActive: m = void 0
18
- } = (s == null ? void 0 : s.componentProps) ?? {}, { disabled: o } = se(m), [f, d] = b(!1), [x, A] = b(""), [S, w] = b(""), [I, M] = b(!1), [W, j] = b(""), y = () => {
18
+ } = (s == null ? void 0 : s.componentProps) ?? {}, { disabled: o } = se(m), [f, d] = b(!1), [x, A] = b(""), [S, w] = b(""), [I, M] = b(!1), [W, D] = b(""), y = () => {
19
19
  var r, a, g, p;
20
- j(
20
+ D(
21
21
  `${((a = (r = e == null ? void 0 : e.storage) == null ? void 0 : r.searchAndReplace) == null ? void 0 : a.resultIndex) + 1}/${(p = (g = e == null ? void 0 : e.storage) == null ? void 0 : g.searchAndReplace) == null ? void 0 : p.results.length}`
22
22
  );
23
23
  };
@@ -39,7 +39,7 @@ function Ce() {
39
39
  p instanceof HTMLElement && p.scrollIntoView({ behavior: "smooth", block: "center" }), y();
40
40
  };
41
41
  k(() => {
42
- x.trim() || D(), x.trim() && L(!0);
42
+ x.trim() || j(), x.trim() && L(!0);
43
43
  }, [x]), k(() => {
44
44
  S.trim() && L();
45
45
  }, [S]), k(() => {
@@ -54,15 +54,15 @@ function Ce() {
54
54
  }, G = () => {
55
55
  var r, a;
56
56
  (a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.previousSearchResult) == null || a.call(r), E();
57
- }, D = () => {
57
+ }, j = () => {
58
58
  var r, a;
59
59
  A(""), w(""), (a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.resetIndex) == null || a.call(r), y();
60
60
  }, J = () => {
61
61
  var r, a;
62
- (a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.replaceAll) == null || a.call(r), j("0/0");
62
+ (a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.replaceAll) == null || a.call(r), D("0/0");
63
63
  };
64
- return s ? /* @__PURE__ */ T(ae, { onOpenChange: d, open: f, children: [
65
- /* @__PURE__ */ u(le, { asChild: !0, disabled: o, children: /* @__PURE__ */ u(
64
+ return s ? /* @__PURE__ */ T(ce, { onOpenChange: d, open: f, children: [
65
+ /* @__PURE__ */ u(ae, { asChild: !0, disabled: o, children: /* @__PURE__ */ u(
66
66
  re,
67
67
  {
68
68
  action: H,
@@ -73,7 +73,7 @@ function Ce() {
73
73
  tooltipOptions: c
74
74
  }
75
75
  ) }),
76
- /* @__PURE__ */ T(oe, { align: "start", className: "richtext-w-full", hideWhenDetached: !0, side: "bottom", children: [
76
+ /* @__PURE__ */ T(le, { align: "start", className: "richtext-w-full", hideWhenDetached: !0, side: "bottom", children: [
77
77
  /* @__PURE__ */ T("div", { className: "richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between", children: [
78
78
  /* @__PURE__ */ u(B, { children: t("editor.search.dialog.text") }),
79
79
  /* @__PURE__ */ u("span", { className: "richtext-font-semibold", children: W })
@@ -93,7 +93,7 @@ function Ce() {
93
93
  ),
94
94
  /* @__PURE__ */ u(N, { className: "richtext-flex-1", onClick: G, children: /* @__PURE__ */ u(q, { name: "ChevronUp" }) }),
95
95
  /* @__PURE__ */ u(N, { className: "richtext-flex-1", onClick: z, children: /* @__PURE__ */ u(q, { name: "ChevronDown" }) }),
96
- /* @__PURE__ */ u(N, { className: "richtext-flex-1", onClick: D, children: "Clear" })
96
+ /* @__PURE__ */ u(N, { className: "richtext-flex-1", onClick: j, children: "Clear" })
97
97
  ] }),
98
98
  /* @__PURE__ */ u(B, { className: "richtext-mb-[6px]", children: t("editor.replace.dialog.text") }),
99
99
  /* @__PURE__ */ u("div", { className: "richtext-mb-[5px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5", children: /* @__PURE__ */ u("div", { className: "richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center", children: /* @__PURE__ */ u(
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-Bcj8cyOO.cjs"),u=require("@tiptap/pm/state"),d=require("./clsx-D6gYQn3o.cjs"),l=require("./index-BF3EVCB1.cjs"),r=require("./SlashCommandNodeView-DNixmQGa.cjs"),o=require("./updatePosition-DGPtRfWN.cjs"),a=require("react/jsx-runtime"),m=require("react"),c=require("./index-CWw4s87s.cjs");function C({commandList:e}){const[,t]=r.useSignalCommandList(),{t:n}=c.useLocale();return m.useEffect(()=>{if(!(e!=null&&e.length)){const i=r.renderCommandListDefault({t:n});t(i);return}t(e)},[n,e]),a.jsx(a.Fragment,{})}const f=s.Extension.create({name:"richtextSlashCommand",priority:200,addProseMirrorPlugins(){return[l.Suggestion({pluginKey:new u.PluginKey("richtextSlashCommandPlugin"),editor:this.editor,char:"/",command:({editor:e,range:t,props:n})=>{const{view:i}=e;n.action({editor:e,range:t}),i.focus()},render:()=>{let e;return{onStart:t=>{t.clientRect&&(e=new d.ReactRenderer(r.SlashCommandNodeView,{props:t,editor:t.editor}),e.element.style.position="absolute",document.body.appendChild(e.element),o.updatePosition(t.editor,e.element))},onUpdate(t){e.updateProps(t),t.clientRect&&o.updatePosition(t.editor,e.element)},onKeyDown(t){var n;return t.event.key==="Escape"?(e.destroy(),e.element.remove(),!0):(n=e.ref)==null?void 0:n.onKeyDown(t)},onExit(){e&&(e.destroy(),e.element.remove())}}}})]}});exports.renderCommandListDefault=r.renderCommandListDefault;exports.useFilterCommandList=r.useFilterCommandList;exports.SlashCommand=f;exports.SlashCommandList=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-BGfIcDCQ.cjs"),u=require("@tiptap/pm/state"),d=require("./clsx-DRbkQ4T7.cjs"),l=require("./index-BgNKVyMW.cjs"),r=require("./SlashCommandNodeView-DPPmYEjC.cjs"),o=require("./updatePosition-B1oRJE1x.cjs"),a=require("react/jsx-runtime"),m=require("react"),c=require("./index-BpLw6ebr.cjs");function C({commandList:e}){const[,t]=r.useSignalCommandList(),{t:n}=c.useLocale();return m.useEffect(()=>{if(!(e!=null&&e.length)){const i=r.renderCommandListDefault({t:n});t(i);return}t(e)},[n,e]),a.jsx(a.Fragment,{})}const f=s.Extension.create({name:"richtextSlashCommand",priority:200,addProseMirrorPlugins(){return[l.Suggestion({pluginKey:new u.PluginKey("richtextSlashCommandPlugin"),editor:this.editor,char:"/",command:({editor:e,range:t,props:n})=>{const{view:i}=e;n.action({editor:e,range:t}),i.focus()},render:()=>{let e;return{onStart:t=>{t.clientRect&&(e=new d.ReactRenderer(r.SlashCommandNodeView,{props:t,editor:t.editor}),e.element.style.position="absolute",document.body.appendChild(e.element),o.updatePosition(t.editor,e.element))},onUpdate(t){e.updateProps(t),t.clientRect&&o.updatePosition(t.editor,e.element)},onKeyDown(t){var n;return t.event.key==="Escape"?(e.destroy(),e.element.remove(),!0):(n=e.ref)==null?void 0:n.onKeyDown(t)},onExit(){e&&(e.destroy(),e.element.remove())}}}})]}});exports.renderCommandListDefault=r.renderCommandListDefault;exports.useFilterCommandList=r.useFilterCommandList;exports.SlashCommand=f;exports.SlashCommandList=C;
@@ -1,13 +1,13 @@
1
- import { E as i } from "./index-BblvcbTH.js";
1
+ import { E as i } from "./index-Dx-Dh7KS.js";
2
2
  import { PluginKey as a } from "@tiptap/pm/state";
3
- import { R as m } from "./clsx-0OU6n9va.js";
4
- import { S as s } from "./index-CGjT-a9h.js";
5
- import { u, r as l, S as d } from "./SlashCommandNodeView-Dt6n1SP9.js";
6
- import { a as F } from "./SlashCommandNodeView-Dt6n1SP9.js";
7
- import { u as o } from "./updatePosition-BwzAsiY0.js";
3
+ import { R as m } from "./clsx-_bq4MQQ7.js";
4
+ import { S as s } from "./index-Dbm_Mans.js";
5
+ import { u, r as l, S as d } from "./SlashCommandNodeView-C0l3Fb_3.js";
6
+ import { a as F } from "./SlashCommandNodeView-C0l3Fb_3.js";
7
+ import { u as o } from "./updatePosition-CFTYKYNJ.js";
8
8
  import { jsx as f, Fragment as c } from "react/jsx-runtime";
9
9
  import { useEffect as h } from "react";
10
- import { u as C } from "./index-oj858lQO.js";
10
+ import { u as C } from "./index-DtyAGMbq.js";
11
11
  function v({ commandList: e }) {
12
12
  const [, t] = u(), { t: r } = C();
13
13
  return h(() => {
@@ -1,9 +1,9 @@
1
1
  import { jsx as d, jsxs as b } from "react/jsx-runtime";
2
2
  import { forwardRef as y, useState as w, useRef as v, useImperativeHandle as S, useEffect as B, Fragment as D } from "react";
3
- import { E as N, z as L, L as T, I as V, c as z } from "./index-X6WZUM9O.js";
3
+ import { K as N, M as L, L as T, I as V, c as G } from "./index-C52cuQ_Y.js";
4
4
  import "./theme.js";
5
- import { H as A, u as G } from "./index-oj858lQO.js";
6
- import { y as $, V as q } from "./index-BG0kQamI.js";
5
+ import { H as A, u as $ } from "./index-DtyAGMbq.js";
6
+ import { y as z, V as q } from "./index-BG0kQamI.js";
7
7
  function X({ t: i }) {
8
8
  const a = [
9
9
  {
@@ -153,13 +153,13 @@ function P(i, a) {
153
153
  })
154
154
  })).filter((l) => l.commands.length > 0);
155
155
  }
156
- const U = $([]);
157
- function O() {
156
+ const U = z([]);
157
+ function M() {
158
158
  const [i, a] = q(U);
159
159
  return [i, a];
160
160
  }
161
- function F(i, a) {
162
- const [e] = O(), [t, l] = w(0), [s, m] = w(0), u = v(null), { t: p } = G(), r = P(e, i.query), f = v([]);
161
+ function O(i, a) {
162
+ const [e] = M(), [t, l] = w(0), [s, m] = w(0), u = v(null), { t: p } = $(), r = P(e, i.query), f = v([]);
163
163
  S(a, () => ({
164
164
  onKeyDown: h
165
165
  })), B(() => {
@@ -216,7 +216,7 @@ function F(i, a) {
216
216
  {
217
217
  onClick: () => R(n, x),
218
218
  ref: (E) => H(n, x, E),
219
- className: z(
219
+ className: G(
220
220
  "richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent",
221
221
  {
222
222
  "bg-item-active": s === n && t === x
@@ -240,10 +240,10 @@ function F(i, a) {
240
240
  }
241
241
  );
242
242
  }
243
- const Y = y(F);
243
+ const Y = y(O);
244
244
  export {
245
245
  Y as S,
246
246
  P as a,
247
247
  X as r,
248
- O as u
248
+ M as u
249
249
  };
@@ -1 +1 @@
1
- "use strict";const d=require("react/jsx-runtime"),m=require("react"),h=require("./index-Gi752TMk.cjs");require("./theme.cjs");const w=require("./index-CWw4s87s.cjs"),v=require("./index-NsYff_Ni.cjs");function S({t:i}){const s=[{name:"format",title:i("editor.slash.format"),commands:[]},{name:"insert",title:i("editor.slash.insert"),commands:[]}];return w.HEADINGS.forEach(e=>{s[0].commands.push({name:`heading${e}`,label:i(e==="Paragraph"?"editor.paragraph.tooltip":`editor.heading.h${e}.tooltip`),aliases:[`h${e}`,"bt",`bt${e}`],iconName:`Heading${e}`,isActive:t=>e==="Paragraph"?!1:t.isActive("heading",{level:e})||!1,action:({editor:t,range:l})=>{const a=w.HEADINGS.find(u=>t.isActive("heading",{level:u}));if(e==="Paragraph"){a!==void 0&&a!=="Paragraph"&&t.commands.toggleHeading({level:a}),t.chain().focus().deleteRange(l).run();return}if(e){t.chain().focus().deleteRange(l).setHeading({level:e}).run();return}t.chain().focus().deleteRange(l).run()}})}),s[0].commands.push({name:"bulletList",label:i("editor.bulletlist.tooltip"),aliases:["ul","yxlb"],iconName:"List",isActive:e=>e.isActive("bulletList"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}}),s[0].commands.push({name:"orderedlist",label:i("editor.orderedlist.tooltip"),aliases:["ol","yxlb"],iconName:"ListOrdered",isActive:e=>e.isActive("orderedList"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}}),s[0].commands.push({name:"taskList",label:i("editor.tasklist.tooltip"),iconName:"ListTodo",description:"Task list with todo items",aliases:["todo"],isActive:e=>e.isActive("taskList"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run()}}),s[0].commands.push({name:"blockquote",label:i("editor.blockquote.tooltip"),description:"插入引入格式",aliases:["yr"],iconName:"TextQuote",isActive:e=>e.isActive("blockquote"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setBlockquote().run()}}),s[0].commands.push({name:"codeBlock",label:i("editor.codeblock.tooltip"),iconName:"Code2",description:"Code block with syntax highlighting",shouldBeHidden:e=>e.isActive("columns"),isActive:e=>e.isActive("codeBlock"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setCodeBlock().run()}}),s[1].commands.push({name:"image",label:i("editor.image.tooltip"),iconName:"ImageUp",description:"Insert a image",aliases:["image","tp","tupian"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();const l=h.EVENTS.UPLOAD_IMAGE(e.id);h.emit(l,!0)}}),s[1].commands.push({name:"video",label:i("editor.video.tooltip"),iconName:"Video",description:"Insert a video",aliases:["video","sp","shipin"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();const l=h.EVENTS.UPLOAD_VIDEO(e.id);h.emit(l,!0)}}),s[1].commands.push({name:"table",label:i("editor.table.tooltip"),iconName:"Table",description:"Insert a table",aliases:["table","bg","biaoge","biao"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}}),s[1].commands.push({name:"horizontalRule",label:i("editor.horizontalrule.tooltip"),iconName:"Minus",description:"Insert a horizontal divider",aliases:["hr","fgx","fg"],action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setHorizontalRule().run()}}),s[1].commands.push({name:"columns",label:i("editor.columns.tooltip"),iconName:"Columns2",description:"Add two column content",action:({editor:e})=>{e.chain().focus().insertColumns({cols:2}).run()}}),s}function C(i,s){return i.map(l=>({...l,commands:l.commands.filter(a=>{const u=a.label.toLowerCase().trim(),x=s.toLowerCase().trim();if(a.aliases){const b=a.aliases.map(f=>f.toLowerCase().trim()),r=u.match(x),g=b.some(f=>f.match(x));return r||g}return u.match(x)})})).filter(l=>l.commands.length>0)}const y=v.y([]);function L(){const[i,s]=v.V(y);return[i,s]}function q(i,s){const[e]=L(),[t,l]=m.useState(0),[a,u]=m.useState(0),x=m.useRef(null),{t:b}=w.useLocale(),r=C(e,i.query),g=m.useRef([]);m.useImperativeHandle(s,()=>({onKeyDown:f})),m.useEffect(()=>{if(!x.current)return;const o=a*1e3+t,n=g.current[o];n&&n.scrollIntoView({behavior:"smooth",block:"nearest"})},[t,a]);function f({event:o}){return o.key==="ArrowUp"?(A(),!0):o.key==="ArrowDown"?(I(),!0):o.key==="Enter"?(R(),!0):!1}function A(){var c;if(r.length===0)return!1;let o=t-1,n=a;o<0&&(n=a-1,o=((c=r[n])==null?void 0:c.commands.length)-1||0),n<0&&(n=r.length-1,o=r[n].commands.length-1),l(o),u(n)}function I(){if(r.length===0)return!1;const o=r[a].commands;let n=t+1,c=a;o.length-1<n&&(n=0,c=a+1),r.length-1<c&&(c=0),l(n),u(c)}function R(){if(r.length===0||a===-1||t===-1)return!1;N(a,t)}function N(o,n){const c=r[o].commands[n];i==null||i.command(c)}function k(o,n){N(o,n)}function E(o,n,c){g.current[o*1e3+n]=c}return d.jsx("div",{className:"richtext-max-h-[min(80vh,24rem)] richtext-flex-wrap richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none","data-richtext-portal":!0,ref:x,children:r!=null&&r.length?d.jsx("div",{className:"richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5",children:r==null?void 0:r.map((o,n)=>d.jsxs(m.Fragment,{children:[d.jsx(h.Label,{className:"richtext-mx-[4px] richtext-mb-[4px] richtext-mt-[8px] !richtext-text-[0.65rem] richtext-uppercase",children:o.title}),o.commands.map((c,p)=>d.jsxs("button",{onClick:()=>k(n,p),ref:H=>E(n,p,H),className:h.cn("richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent",{"bg-item-active":a===n&&t===p}),children:[c.iconUrl&&d.jsx("img",{alt:"",className:"richtext-size-6",src:c.iconUrl}),c.iconName&&d.jsx(h.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:c.iconName}),c.label]},`command-${p}`))]},`slash-${o.title}`))}):d.jsx("div",{className:"richtext-p-3",children:d.jsx("span",{className:"richtext-text-xs richtext-text-foreground",children:b("editor.slash.empty")})})})}const D=m.forwardRef(q);exports.SlashCommandNodeView=D;exports.renderCommandListDefault=S;exports.useFilterCommandList=C;exports.useSignalCommandList=L;
1
+ "use strict";const d=require("react/jsx-runtime"),m=require("react"),h=require("./index-aujjnfSJ.cjs");require("./theme.cjs");const w=require("./index-BpLw6ebr.cjs"),v=require("./index-NsYff_Ni.cjs");function S({t:i}){const s=[{name:"format",title:i("editor.slash.format"),commands:[]},{name:"insert",title:i("editor.slash.insert"),commands:[]}];return w.HEADINGS.forEach(e=>{s[0].commands.push({name:`heading${e}`,label:i(e==="Paragraph"?"editor.paragraph.tooltip":`editor.heading.h${e}.tooltip`),aliases:[`h${e}`,"bt",`bt${e}`],iconName:`Heading${e}`,isActive:t=>e==="Paragraph"?!1:t.isActive("heading",{level:e})||!1,action:({editor:t,range:l})=>{const a=w.HEADINGS.find(u=>t.isActive("heading",{level:u}));if(e==="Paragraph"){a!==void 0&&a!=="Paragraph"&&t.commands.toggleHeading({level:a}),t.chain().focus().deleteRange(l).run();return}if(e){t.chain().focus().deleteRange(l).setHeading({level:e}).run();return}t.chain().focus().deleteRange(l).run()}})}),s[0].commands.push({name:"bulletList",label:i("editor.bulletlist.tooltip"),aliases:["ul","yxlb"],iconName:"List",isActive:e=>e.isActive("bulletList"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}}),s[0].commands.push({name:"orderedlist",label:i("editor.orderedlist.tooltip"),aliases:["ol","yxlb"],iconName:"ListOrdered",isActive:e=>e.isActive("orderedList"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}}),s[0].commands.push({name:"taskList",label:i("editor.tasklist.tooltip"),iconName:"ListTodo",description:"Task list with todo items",aliases:["todo"],isActive:e=>e.isActive("taskList"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run()}}),s[0].commands.push({name:"blockquote",label:i("editor.blockquote.tooltip"),description:"插入引入格式",aliases:["yr"],iconName:"TextQuote",isActive:e=>e.isActive("blockquote"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setBlockquote().run()}}),s[0].commands.push({name:"codeBlock",label:i("editor.codeblock.tooltip"),iconName:"Code2",description:"Code block with syntax highlighting",shouldBeHidden:e=>e.isActive("columns"),isActive:e=>e.isActive("codeBlock"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setCodeBlock().run()}}),s[1].commands.push({name:"image",label:i("editor.image.tooltip"),iconName:"ImageUp",description:"Insert a image",aliases:["image","tp","tupian"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();const l=h.EVENTS.UPLOAD_IMAGE(e.id);h.emit(l,!0)}}),s[1].commands.push({name:"video",label:i("editor.video.tooltip"),iconName:"Video",description:"Insert a video",aliases:["video","sp","shipin"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();const l=h.EVENTS.UPLOAD_VIDEO(e.id);h.emit(l,!0)}}),s[1].commands.push({name:"table",label:i("editor.table.tooltip"),iconName:"Table",description:"Insert a table",aliases:["table","bg","biaoge","biao"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}}),s[1].commands.push({name:"horizontalRule",label:i("editor.horizontalrule.tooltip"),iconName:"Minus",description:"Insert a horizontal divider",aliases:["hr","fgx","fg"],action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setHorizontalRule().run()}}),s[1].commands.push({name:"columns",label:i("editor.columns.tooltip"),iconName:"Columns2",description:"Add two column content",action:({editor:e})=>{e.chain().focus().insertColumns({cols:2}).run()}}),s}function C(i,s){return i.map(l=>({...l,commands:l.commands.filter(a=>{const u=a.label.toLowerCase().trim(),x=s.toLowerCase().trim();if(a.aliases){const b=a.aliases.map(f=>f.toLowerCase().trim()),r=u.match(x),g=b.some(f=>f.match(x));return r||g}return u.match(x)})})).filter(l=>l.commands.length>0)}const y=v.y([]);function L(){const[i,s]=v.V(y);return[i,s]}function q(i,s){const[e]=L(),[t,l]=m.useState(0),[a,u]=m.useState(0),x=m.useRef(null),{t:b}=w.useLocale(),r=C(e,i.query),g=m.useRef([]);m.useImperativeHandle(s,()=>({onKeyDown:f})),m.useEffect(()=>{if(!x.current)return;const o=a*1e3+t,n=g.current[o];n&&n.scrollIntoView({behavior:"smooth",block:"nearest"})},[t,a]);function f({event:o}){return o.key==="ArrowUp"?(A(),!0):o.key==="ArrowDown"?(I(),!0):o.key==="Enter"?(R(),!0):!1}function A(){var c;if(r.length===0)return!1;let o=t-1,n=a;o<0&&(n=a-1,o=((c=r[n])==null?void 0:c.commands.length)-1||0),n<0&&(n=r.length-1,o=r[n].commands.length-1),l(o),u(n)}function I(){if(r.length===0)return!1;const o=r[a].commands;let n=t+1,c=a;o.length-1<n&&(n=0,c=a+1),r.length-1<c&&(c=0),l(n),u(c)}function R(){if(r.length===0||a===-1||t===-1)return!1;N(a,t)}function N(o,n){const c=r[o].commands[n];i==null||i.command(c)}function k(o,n){N(o,n)}function E(o,n,c){g.current[o*1e3+n]=c}return d.jsx("div",{className:"richtext-max-h-[min(80vh,24rem)] richtext-flex-wrap richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none","data-richtext-portal":!0,ref:x,children:r!=null&&r.length?d.jsx("div",{className:"richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5",children:r==null?void 0:r.map((o,n)=>d.jsxs(m.Fragment,{children:[d.jsx(h.Label,{className:"richtext-mx-[4px] richtext-mb-[4px] richtext-mt-[8px] !richtext-text-[0.65rem] richtext-uppercase",children:o.title}),o.commands.map((c,p)=>d.jsxs("button",{onClick:()=>k(n,p),ref:H=>E(n,p,H),className:h.cn("richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm richtext-text-foreground !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent",{"bg-item-active":a===n&&t===p}),children:[c.iconUrl&&d.jsx("img",{alt:"",className:"richtext-size-6",src:c.iconUrl}),c.iconName&&d.jsx(h.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:c.iconName}),c.label]},`command-${p}`))]},`slash-${o.title}`))}):d.jsx("div",{className:"richtext-p-3",children:d.jsx("span",{className:"richtext-text-xs richtext-text-foreground",children:b("editor.slash.empty")})})})}const D=m.forwardRef(q);exports.SlashCommandNodeView=D;exports.renderCommandListDefault=S;exports.useFilterCommandList=C;exports.useSignalCommandList=L;
package/lib/Strike.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-Bcj8cyOO.cjs"),s=require("react/jsx-runtime"),o=require("./index-Gi752TMk.cjs");require("react");require("./theme.cjs");var m=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,h=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,S=r.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",r.mergeAttributes(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[r.markInputRule({find:m,type:this.type})]},addPasteRules(){return[r.markPasteRule({find:h,type:this.type})]}});function f(){const t=o.useButtonProps(d.name),{icon:e=void 0,tooltip:i=void 0,shortcutKeys:n=void 0,tooltipOptions:c={},action:a=void 0,isActive:l=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:k,disabled:u,update:p}=o.useToggleActive(l),g=()=>{u||a&&(a(),p())};return t?s.jsx(o.ActionButton,{action:g,dataState:k,disabled:u,icon:e,shortcutKeys:n,tooltip:i,tooltipOptions:c}):s.jsx(s.Fragment,{})}const d=S.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:e,t:i,extension:n})=>({componentProps:{action:()=>e.commands.toggleStrike(),isActive:()=>e.isActive("strike")||!1,disabled:!1,icon:"Strikethrough",shortcutKeys:n.options.shortcutKeys??["shift","mod","S"],tooltip:i("editor.strike.tooltip")}})}}});exports.RichTextStrike=f;exports.Strike=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-BGfIcDCQ.cjs"),s=require("react/jsx-runtime"),o=require("./index-aujjnfSJ.cjs");require("react");require("./theme.cjs");var m=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,h=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,S=r.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",r.mergeAttributes(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[r.markInputRule({find:m,type:this.type})]},addPasteRules(){return[r.markPasteRule({find:h,type:this.type})]}});function f(){const t=o.useButtonProps(d.name),{icon:e=void 0,tooltip:i=void 0,shortcutKeys:n=void 0,tooltipOptions:c={},action:a=void 0,isActive:l=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:k,disabled:u,update:p}=o.useToggleActive(l),g=()=>{u||a&&(a(),p())};return t?s.jsx(o.ActionButton,{action:g,dataState:k,disabled:u,icon:e,shortcutKeys:n,tooltip:i,tooltipOptions:c}):s.jsx(s.Fragment,{})}const d=S.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:e,t:i,extension:n})=>({componentProps:{action:()=>e.commands.toggleStrike(),isActive:()=>e.isActive("strike")||!1,disabled:!1,icon:"Strikethrough",shortcutKeys:n.options.shortcutKeys??["shift","mod","S"],tooltip:i("editor.strike.tooltip")}})}}});exports.RichTextStrike=f;exports.Strike=d;
package/lib/Strike.js CHANGED
@@ -1,6 +1,6 @@
1
- import { M as m, h as k, j as l, m as g } from "./index-BblvcbTH.js";
1
+ import { M as m, h as k, j as l, m as g } from "./index-Dx-Dh7KS.js";
2
2
  import { jsx as n, Fragment as h } from "react/jsx-runtime";
3
- import { u as f, d as M, A as S } from "./index-X6WZUM9O.js";
3
+ import { u as f, d as M, A as S } from "./index-C52cuQ_Y.js";
4
4
  import "react";
5
5
  import "./theme.js";
6
6
  var v = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, A = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, y = m.create({
@@ -1,8 +1,8 @@
1
- "use strict";const w=require("./index-Bcj8cyOO.cjs"),Be=require("@tiptap/pm/state"),_=require("./index-CUvjYuRp.cjs"),T=require("react/jsx-runtime"),W=require("./index-Gi752TMk.cjs"),F=require("react");require("./theme.cjs");const v=require("./index-CWw4s87s.cjs"),U=require("./popover-BPzkMuyi.cjs");let Y,Q;if(typeof WeakMap<"u"){let t=new WeakMap;Y=e=>t.get(e),Q=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Y=o=>{for(let l=0;l<t.length;l+=2)if(t[l]==o)return t[l+1]},Q=(o,l)=>(n==10&&(n=0),t[n++]=o,t[n++]=l)}var y=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 Y(t)||Q(t,$e(t))}};function $e(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=We(t),n=t.childCount,o=[];let l=0,r=null;const s=[];for(let a=0,d=e*n;a<d;a++)o[a]=0;for(let a=0,d=0;a<n;a++){const u=t.child(a);d++;for(let p=0;;p++){for(;l<o.length&&o[l]!=0;)l++;if(p==u.childCount)break;const m=u.child(p),{colspan:b,rowspan:g,colwidth:S}=m.attrs;for(let x=0;x<g;x++){if(x+a>=n){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:g-x});break}const L=l+x*e;for(let M=0;M<b;M++){o[L+M]==0?o[L+M]=d:(r||(r=[])).push({type:"collision",row:a,pos:d,n:b-M});const B=S&&S[M];if(B){const H=(L+M)%e*2,Z=s[H];Z==null||Z!=B&&s[H+1]==1?(s[H]=B,s[H+1]=1):Z==B&&s[H+1]++}}}l+=b,d+=m.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}),d++}(e===0||n===0)&&(r||(r=[])).push({type:"zero_sized"});const i=new y(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&&Fe(i,s,t),i}function We(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 Fe(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 d=e[(l+a)%t.width*2];d!=null&&(!c.colwidth||c.colwidth[a]!=d)&&((i||(i=Pe(c)))[a]=d)}i&&t.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:i})}}function Pe(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function A(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}const z=new w.PluginKey("selectingCells");function D(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 je(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 E(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 X(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=D(e.$head)||Oe(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Oe(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 ee(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Ve(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function le(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Ae(t,e,n){const o=t.node(-1),l=y.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 I(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 xe(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 Ge(t,e,n){const o=A(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 C=class k extends w.Selection{constructor(e,n=e){const o=e.node(-1),l=y.get(o),r=e.start(-1),s=l.rectBetween(e.pos-r,n.pos-r),i=e.node(0),c=l.cellsInRect(s).filter(d=>d!=n.pos-r);c.unshift(n.pos-r);const a=c.map(d=>{const u=o.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const f=r+d+1;return new w.SelectionRange(i.resolve(f),i.resolve(f+u.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(ee(o)&&ee(l)&&le(o,l)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?k.rowSelection(o,l):r&&this.isColSelection()?k.colSelection(o,l):new k(o,l)}return w.TextSelection.between(o,l)}content(){const e=this.$anchorCell.node(-1),n=y.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 d=c*n.width+l.left,u=l.left;u<l.right;u++,d++){const f=n.map[d];if(r[f])continue;r[f]=!0;const h=n.findCell(f);let p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const m=l.left-h.left,b=h.right-l.right;if(m>0||b>0){let g=p.attrs;if(m>0&&(g=I(g,0,m)),b>0&&(g=I(g,g.colspan-b,b)),h.left<l.left){if(p=p.type.createAndFill(g),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(g)}`)}else p=p.type.create(g,p.content)}if(h.top<l.top||h.bottom>l.bottom){const g={...p.attrs,rowspan:Math.min(h.bottom,l.bottom)-Math.max(h.top,l.top)};h.top<l.top?p=p.type.createAndFill(g):p=p.type.create(g,p.content)}a.push(p)}s.push(e.child(c).copy(w.Fragment.from(a)))}const i=this.isColSelection()&&this.isRowSelection()?e:s;return new w.Slice(w.Fragment.from(i),1,1)}replace(e,n=w.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?w.Slice.empty:n)}const r=w.Selection.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,n){this.replace(e,new w.Slice(w.Fragment.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),o=y.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=y.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 k(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=y.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 k&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const o=e.node(-1),l=y.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 k(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new k(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){return new k(e.resolve(n),e.resolve(o))}getBookmark(){return new Ke(this.$anchorCell.pos,this.$headCell.pos)}};C.prototype.visible=!1;w.Selection.jsonID("cell",C);var Ke=class Te{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Te(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&&le(n,o)?new C(n,o):w.Selection.near(o,1)}};function qe(t){if(!(t.selection instanceof C))return null;const e=[];return t.selection.forEachCell((n,o)=>{e.push(_.Decoration.node(o,o+n.nodeSize,{class:"selectedCell"}))}),_.DecorationSet.create(t.doc,e)}function Xe({$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 Ze({$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 Ue(t,e,n){const o=(e||t).selection,l=(e||t).doc;let r,s;if(o instanceof w.NodeSelection&&(s=o.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")r=C.create(l,o.from);else if(s=="row"){const i=l.resolve(o.from+1);r=C.rowSelection(i,i)}else if(!n){const i=y.get(o.node),c=o.from+1,a=c+i.map[i.width*i.height-1];r=C.create(l,c+1,a)}}else o instanceof w.TextSelection&&Xe(o)?r=w.TextSelection.create(l,o.from):o instanceof w.TextSelection&&Ze(o)&&(r=w.TextSelection.create(l,o.$from.start(),o.$from.end()));return r&&(e||(e=t.tr)).setSelection(r),e}const Je=new w.PluginKey("fix-tables");function Re(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,d=Math.min(l,s+3);a<d;a++)if(t.child(a)==c){i=a+1,n+=c.nodeSize;continue e}o(c,n),i<l&&t.child(i).sameMarkup(c)?Re(t.child(i),c,n+1,o):c.nodesBetween(0,c.content.size,o,n+1),n+=c.nodeSize}}function ve(t,e){let n;const o=(l,r)=>{l.type.spec.tableRole=="table"&&(n=Ye(t,l,r,n))};return e?e.doc!=t.doc&&Re(e.doc,t.doc,0,o):t.doc.descendants(o),n}function Ye(t,e,n,o){const l=y.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 d=e.nodeAt(a.pos);if(!d)continue;const u=d.attrs;for(let f=0;f<u.rowspan;f++)r[a.row+f]+=a.n;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,I(u,u.colspan-a.n,a.n))}else if(a.type=="missing")r[a.row]+=a.n;else if(a.type=="overlong_rowspan"){const d=e.nodeAt(a.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-a.n})}else if(a.type=="colwidth mismatch"){const d=e.nodeAt(a.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...d.attrs,colwidth:a.colwidth})}else if(a.type=="zero_sized"){const d=o.mapping.map(n);o.delete(d,d+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 d=e.child(c),u=a+d.nodeSize,f=r[c];if(f>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const p=[];for(let b=0;b<f;b++){const g=A(t.schema)[h].createAndFill();g&&p.push(g)}const m=(c==0||s==c-1)&&i==c?a+1:u-1;o.insert(o.mapping.map(m),p)}a=u}return o.setMeta(Je,{fixTables:!0})}function N(t){const e=t.selection,n=X(t),o=n.node(-1),l=n.start(-1),r=y.get(o);return{...e instanceof C?r.rectBetween(e.$anchorCell.pos-l,e.$headCell.pos-l):r.findCell(n.pos-l),tableStart:l,map:r,table:o}}function Me(t,{map:e,tableStart:n,table:o},l){let r=l>0?-1:0;Ge(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,xe(a.attrs,l-e.colCount(c))),s+=a.attrs.rowspan-1}else{const c=r==null?A(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 Qe(t,e){if(!E(t))return!1;if(e){const n=N(t);e(Me(t.tr,n,n.left))}return!0}function et(t,e){if(!E(t))return!1;if(e){const n=N(t);e(Me(t.tr,n,n.right))}return!0}function tt(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),d=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,I(d,l-e.colCount(c)));else{const u=t.mapping.slice(r).map(o+c);t.delete(u,u+a.nodeSize)}s+=d.rowspan}}function nt(t,e){if(!E(t))return!1;if(e){const n=N(t),o=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let l=n.right-1;tt(o,n,l),l!=n.left;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw new RangeError("No table found");n.table=r,n.map=y.get(r)}e(o)}return!0}function ot(t,e,n){var o;const l=A(e.type.schema).header_cell;for(let r=0;r<t.width;r++)if(((o=e.nodeAt(t.map[r+n*t.width]))===null||o===void 0?void 0:o.type)!=l)return!1;return!0}function Ee(t,{map:e,tableStart:n,table:o},l){let r=n;for(let a=0;a<l;a++)r+=o.child(a).nodeSize;const s=[];let i=l>0?-1:0;ot(e,o,l+i)&&(i=l==0||l==e.height?null:0);for(let a=0,d=e.width*l;a<e.width;a++,d++)if(l>0&&l<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],f=o.nodeAt(u).attrs;t.setNodeMarkup(n+u,null,{...f,rowspan:f.rowspan+1}),a+=f.colspan-1}else{var c;const u=i==null?A(o.type.schema).cell:(c=o.nodeAt(e.map[d+i*e.width]))===null||c===void 0?void 0:c.type,f=u==null?void 0:u.createAndFill();f&&s.push(f)}return t.insert(r,A(o.type.schema).row.create(null,s)),t}function lt(t,e){if(!E(t))return!1;if(e){const n=N(t);e(Ee(t.tr,n,n.top))}return!0}function rt(t,e){if(!E(t))return!1;if(e){const n=N(t);e(Ee(t.tr,n,n.bottom))}return!0}function st(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,d=l*e.width;a<e.width;a++,d++){const u=e.map[d];if(!c.has(u)){if(c.add(u),l>0&&u==e.map[d-e.width]){const f=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(i).map(u+o),null,{...f,rowspan:f.rowspan-1}),a+=f.colspan-1}else if(l<e.height&&u==e.map[d+e.width]){const f=n.nodeAt(u),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(l+1,a,n);t.insert(t.mapping.slice(i).map(o+m),p),a+=h.colspan-1}}}}function it(t,e){if(!E(t))return!1;if(e){const n=N(t),o=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let l=n.bottom-1;st(o,n,l),l!=n.top;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw new RangeError("No table found");n.table=r,n.map=y.get(n.table)}e(o)}return!0}function re(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function ct({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 se(t,e){const n=t.selection;if(!(n instanceof C)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=N(t),{map:l}=o;if(ct(l,o))return!1;if(e){const r=t.tr,s={};let i=w.Fragment.empty,c,a;for(let d=o.top;d<o.bottom;d++)for(let u=o.left;u<o.right;u++){const f=l.map[d*l.width+u],h=o.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,c==null)c=f,a=h;else{re(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,{...xe(a.attrs,a.attrs.colspan,o.right-o.left-a.attrs.colspan),rowspan:o.bottom-o.top}),i.size>0){const d=c+1+a.content.size,u=re(a)?c+1:d;r.replaceWith(u+o.tableStart,d+o.tableStart,i)}r.setSelection(new C(r.doc.resolve(c+o.tableStart))),e(r)}return!0}function ie(t,e){const n=A(t.schema);return at(({node:o})=>n[o.type.spec.tableRole])(t,e)}function at(t){return(e,n)=>{const o=e.selection;let l,r;if(o instanceof C){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;l=o.$anchorCell.nodeAfter,r=o.$anchorCell.pos}else{var s;if(l=je(o.$from),!l)return!1;r=(s=D(o.$from))===null||s===void 0?void 0:s.pos}if(l==null||r==null||l.attrs.colspan==1&&l.attrs.rowspan==1)return!1;if(n){let i=l.attrs;const c=[],a=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const d=N(e),u=e.tr;for(let h=0;h<d.right-d.left;h++)c.push(a?{...i,colwidth:a&&a[h]?[a[h]]:null}:i);let f;for(let h=d.top;h<d.bottom;h++){let p=d.map.positionAt(h,d.left,d.table);h==d.top&&(p+=l.nodeSize);for(let m=d.left,b=0;m<d.right;m++,b++)m==d.left&&h==d.top||u.insert(f=u.mapping.map(p+d.tableStart,1),t({node:l,row:h,col:m}).createAndFill(c[b]))}u.setNodeMarkup(r,t({node:l,row:d.top,col:d.left}),c[0]),o instanceof C&&u.setSelection(new C(u.doc.resolve(o.$anchorCell.pos),f?u.doc.resolve(f):void 0)),n(u)}return!0}}function dt(t,e){return function(n,o){if(!E(n))return!1;const l=X(n);if(l.nodeAfter.attrs[t]===e)return!1;if(o){const r=n.tr;n.selection instanceof C?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 ut(t){return function(e,n){if(!E(e))return!1;if(n){const o=A(e.schema),l=N(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 ce(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 $(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?ut(t):function(n,o){if(!E(n))return!1;if(o){const l=A(n.schema),r=N(n),s=n.tr,i=ce("row",r,l),c=ce("column",r,l),a=(t==="column"?i:t==="row"&&c)?1:0,d=t=="column"?{left:0,top:a,right:1,bottom:r.map.height}:t=="row"?{left:a,top:0,right:r.map.width,bottom:1}:r,u=t=="column"?c?l.cell:l.header_cell:t=="row"?i?l.cell:l.header_cell:l.cell;r.map.cellsInRect(d).forEach(f=>{const h=f+r.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,u,p.attrs)}),o(s)}return!0}}$("row",{useDeprecatedLogic:!0});$("column",{useDeprecatedLogic:!0});const ft=$("cell",{useDeprecatedLogic:!0});function ht(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 ae(t){return function(e,n){if(!E(e))return!1;const o=ht(X(e),t);if(o==null)return!1;if(n){const l=e.doc.resolve(o);n(e.tr.setSelection(w.TextSelection.between(l,Ve(l))).scrollIntoView())}return!0}}function pt(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 P(t,e){const n=t.selection;if(!(n instanceof C))return!1;if(e){const o=t.tr,l=A(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 w.Slice(l,0,0))}),o.docChanged&&e(o)}return!0}function mt(t){if(t.size===0)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 d=c?0:Math.max(0,n-1),u=c<e.childCount-1?0:Math.max(0,o-1);(d||u)&&(a=te(A(s).row,new w.Slice(a,d,u)).content),i.push(a)}else if(r=="cell"||r=="header_cell")i.push(n||o?te(A(s).row,new w.Slice(e,n,o)).content:e);else return null;return gt(s,i)}function gt(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(w.Fragment.empty),n[l]<o){const r=A(t).cell.createAndFill(),s=[];for(let i=n[l];i<o;i++)s.push(r);e[l]=e[l].append(w.Fragment.from(s))}return{height:e.length,width:o,rows:e}}function te(t,e){const n=t.createAndFill();return new w.Transform(n).replace(0,n.content.size,e).doc}function bt({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 d=r[i]||0,u=0;d<o;u++){let f=c.child(u%c.childCount);d+f.attrs.colspan>o&&(f=f.type.createChecked(I(f.attrs,f.attrs.colspan,d+f.attrs.colspan-o),f.content)),a.push(f),d+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)r[i+h]=(r[i+h]||0)+f.attrs.colspan}s.push(w.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 d=0;d<a.childCount;d++){let u=a.child(d);s+u.attrs.rowspan>l&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,l-u.attrs.rowspan)},u.content)),c.push(u)}r.push(w.Fragment.from(c))}n=r,e=l}return{width:t,height:e,rows:n}}function wt(t,e,n,o,l,r,s){const i=t.doc.type.schema,c=A(i);let a,d;if(l>e.width)for(let u=0,f=0;u<e.height;u++){const h=n.child(u);f+=h.nodeSize;const p=[];let m;h.lastChild==null||h.lastChild.type==c.cell?m=a||(a=c.cell.createAndFill()):m=d||(d=c.header_cell.createAndFill());for(let b=e.width;b<l;b++)p.push(m);t.insert(t.mapping.slice(s).map(f-1+o),p)}if(r>e.height){const u=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,l);p++){const b=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==c.header_cell;u.push(b?d||(d=c.header_cell.createAndFill()):a||(a=c.cell.createAndFill()))}const f=c.row.create(null,w.Fragment.from(u)),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||d)}function de(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 d=s*e.width+a,u=e.map[d];if(e.map[d-e.width]==u){c=!0;const f=n.nodeAt(u),{top:h,left:p}=e.findCell(u);t.setNodeMarkup(t.mapping.slice(i).map(u+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 ue(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 d=a*e.width+s,u=e.map[d];if(e.map[d-1]==u){c=!0;const f=n.nodeAt(u),h=e.colCount(u),p=t.mapping.slice(i).map(u+o);t.setNodeMarkup(p,null,I(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(I(f.attrs,0,s-h))),a+=f.attrs.rowspan-1}}return c}function fe(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=y.get(r);const{top:i,left:c}=o,a=c+l.width,d=i+l.height,u=t.tr;let f=0;function h(){if(r=n?u.doc.nodeAt(n-1):u.doc,!r)throw new Error("No table found");s=y.get(r),f=u.mapping.maps.length}wt(u,s,r,n,a,d,f)&&h(),de(u,s,r,n,c,a,i,f)&&h(),de(u,s,r,n,c,a,d,f)&&h(),ue(u,s,r,n,i,d,c,f)&&h(),ue(u,s,r,n,i,d,a,f)&&h();for(let p=i;p<d;p++){const m=s.positionAt(p,c,r),b=s.positionAt(p,a,r);u.replace(u.mapping.slice(f).map(m+n),u.mapping.slice(f).map(b+n),new w.Slice(l.rows[p-i],0,0))}h(),u.setSelection(new C(u.doc.resolve(n+s.positionAt(i,c,r)),u.doc.resolve(n+s.positionAt(d-1,a-1,r)))),e(u)}const Ct=_.keydownHandler({ArrowLeft:j("horiz",-1),ArrowRight:j("horiz",1),ArrowUp:j("vert",-1),ArrowDown:j("vert",1),"Shift-ArrowLeft":O("horiz",-1),"Shift-ArrowRight":O("horiz",1),"Shift-ArrowUp":O("vert",-1),"Shift-ArrowDown":O("vert",1),Backspace:P,"Mod-Backspace":P,Delete:P,"Mod-Delete":P});function G(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function j(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;if(r instanceof C)return G(n,o,w.Selection.near(r.$headCell,e));if(t!="horiz"&&!r.empty)return!1;const s=Ne(l,t,e);if(s==null)return!1;if(t=="horiz")return G(n,o,w.Selection.near(n.doc.resolve(r.head+e),e));{const i=n.doc.resolve(s),c=Ae(i,t,e);let a;return c?a=w.Selection.near(c,1):e<0?a=w.Selection.near(n.doc.resolve(i.before(-1)),-1):a=w.Selection.near(n.doc.resolve(i.after(-1)),1),G(n,o,a)}}}function O(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;let s;if(r instanceof C)s=r;else{const c=Ne(l,t,e);if(c==null)return!1;s=new C(n.doc.resolve(c))}const i=Ae(s.$headCell,t,e);return i?G(n,o,new C(s.$anchorCell,i)):!1}}function yt(t,e){const n=t.state.doc,o=D(n.resolve(e));return o?(t.dispatch(t.state.tr.setSelection(new C(o))),!0):!1}function St(t,e,n){if(!E(t.state))return!1;let o=mt(n);const l=t.state.selection;if(l instanceof C){o||(o={width:1,height:1,rows:[w.Fragment.from(te(A(t.state.schema).cell,n))]});const r=l.$anchorCell.node(-1),s=l.$anchorCell.start(-1),i=y.get(r).rectBetween(l.$anchorCell.pos-s,l.$headCell.pos-s);return o=bt(o,i.right-i.left,i.bottom-i.top),fe(t.state,t.dispatch,s,i,o),!0}else if(o){const r=X(t.state),s=r.start(-1);return fe(t.state,t.dispatch,s,y.get(r.node(-1)).findCell(r.pos-s),o),!0}else return!1}function At(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const o=he(t,e.target);let l;if(e.shiftKey&&t.state.selection instanceof C)r(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(l=D(t.state.selection.$anchor))!=null&&((n=J(t,e))===null||n===void 0?void 0:n.pos)!=l.pos)r(l,e),e.preventDefault();else if(!o)return;function r(c,a){let d=J(t,a);const u=z.getState(t.state)==null;if(!d||!le(c,d))if(u)d=c;else return;const f=new C(c,d);if(u||!t.state.selection.eq(f)){const h=t.state.tr.setSelection(f);u&&h.setMeta(z,c.pos),t.dispatch(h)}}function s(){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))}function i(c){const a=c,d=z.getState(t.state);let u;if(d!=null)u=t.state.doc.resolve(d);else if(he(t,a.target)!=o&&(u=J(t,e),!u))return s();u&&r(u,a)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",i)}function Ne(t,e,n){if(!(t.state.selection instanceof w.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 s=o.before(l),i=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(i)?s:null}}return null}function he(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function J(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:o,pos:l}=n;return o>=0&&D(t.state.doc.resolve(o))||D(t.state.doc.resolve(l))}var xt=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")),ne(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,ne(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ne(t,e,n,o,l,r){let s=0,i=!0,c=e.firstChild;const a=t.firstChild;if(a){for(let u=0,f=0;u<a.childCount;u++){const{colspan:h,colwidth:p}=a.child(u).attrs;for(let m=0;m<h;m++,f++){const b=l==f?r:p&&p[m],g=b?b+"px":"";if(s+=b||o,b||(i=!1),c)c.style.width!=g&&(c.style.width=g),c=c.nextSibling;else{const S=document.createElement("col");S.style.width=g,e.appendChild(S)}}}for(;c;){var d;const u=c.nextSibling;(d=c.parentNode)===null||d===void 0||d.removeChild(c),c=u}i?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const R=new w.PluginKey("tableColumnResizing");function Tt({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:o=xt,lastColumnResizable:l=!0}={}){const r=new w.Plugin({key:R,state:{init(s,i){var c;const a=(c=r.spec)===null||c===void 0||(c=c.props)===null||c===void 0?void 0:c.nodeViews,d=A(i.schema).table.name;return o&&a&&(a[d]=(u,f)=>new o(u,n,f)),new Rt(-1,!1)},apply(s,i){return i.apply(s)}},props:{attributes:s=>{const i=R.getState(s);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,i)=>{vt(s,i,t,l)},mouseleave:s=>{Mt(s)},mousedown:(s,i)=>{Et(s,i,e,n)}},decorations:s=>{const i=R.getState(s);if(i&&i.activeHandle>-1)return Ht(s,i.activeHandle)},nodeViews:{}}});return r}var Rt=class K{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,o=e.getMeta(R);if(o&&o.setHandle!=null)return new K(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new K(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&e.docChanged){let l=e.mapping.map(n.activeHandle,-1);return ee(e.doc.resolve(l))||(l=-1),new K(l,n.dragging)}return n}};function vt(t,e,n,o){if(!t.editable)return;const l=R.getState(t.state);if(l&&!l.dragging){const r=Lt(e.target);let s=-1;if(r){const{left:i,right:c}=r.getBoundingClientRect();e.clientX-i<=n?s=pe(t,e,"left",n):c-e.clientX<=n&&(s=pe(t,e,"right",n))}if(s!=l.activeHandle){if(!o&&s!==-1){const i=t.state.doc.resolve(s),c=i.node(-1),a=y.get(c),d=i.start(-1);if(a.colCount(i.pos-d)+i.nodeAfter.attrs.colspan-1==a.width-1)return}Le(t,s)}}}function Mt(t){if(!t.editable)return;const e=R.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Le(t,-1)}function Et(t,e,n,o){var l;if(!t.editable)return!1;const r=(l=t.dom.ownerDocument.defaultView)!==null&&l!==void 0?l:window,s=R.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const i=t.state.doc.nodeAt(s.activeHandle),c=Nt(t,s.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(R,{setDragging:{startX:e.clientX,startWidth:c}}));function a(u){r.removeEventListener("mouseup",a),r.removeEventListener("mousemove",d);const f=R.getState(t.state);f!=null&&f.dragging&&(kt(t,f.activeHandle,me(f.dragging,u,n)),t.dispatch(t.state.tr.setMeta(R,{setDragging:null})))}function d(u){if(!u.which)return a(u);const f=R.getState(t.state);if(f&&f.dragging){const h=me(f.dragging,u,n);ge(t,f.activeHandle,h,o)}}return ge(t,s.activeHandle,c,o),r.addEventListener("mouseup",a),r.addEventListener("mousemove",d),e.preventDefault(),!0}function Nt(t,e,{colspan:n,colwidth:o}){const l=o&&o[o.length-1];if(l)return l;const r=t.domAtPos(e);let s=r.node.childNodes[r.offset].offsetWidth,i=n;if(o)for(let c=0;c<n;c++)o[c]&&(s-=o[c],i--);return s/i}function Lt(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function pe(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=D(t.state.doc.resolve(s));if(!i)return-1;if(n=="right")return i.pos;const c=y.get(i.node(-1)),a=i.start(-1),d=c.map.indexOf(i.pos-a);return d%c.width==0?-1:a+c.map[d-1]}function me(t,e,n){const o=e.clientX-t.startX;return Math.max(n,t.startWidth+o)}function Le(t,e){t.dispatch(t.state.tr.setMeta(R,{setHandle:e}))}function kt(t,e,n){const o=t.state.doc.resolve(e),l=o.node(-1),r=y.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 d=a*r.width+i;if(a&&r.map[d]==r.map[d-r.width])continue;const u=r.map[d],f=l.nodeAt(u).attrs,h=f.colspan==1?0:i-r.colCount(u);if(f.colwidth&&f.colwidth[h]==n)continue;const p=f.colwidth?f.colwidth.slice():zt(f.colspan);p[h]=n,c.setNodeMarkup(s+u,null,{...f,colwidth:p})}c.docChanged&&t.dispatch(c)}function ge(t,e,n,o){const l=t.state.doc.resolve(e),r=l.node(-1),s=l.start(-1),i=y.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&&ne(r,c.firstChild,c,o,i,n)}function zt(t){return Array(t).fill(0)}function Ht(t,e){const n=[],o=t.doc.resolve(e),l=o.node(-1);if(!l)return _.DecorationSet.empty;const r=y.get(l),s=o.start(-1),i=r.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;for(let a=0;a<r.height;a++){const d=i+a*r.width;if((i==r.width-1||r.map[d]!=r.map[d+1])&&(a==0||r.map[d]!=r.map[d-r.width])){var c;const u=r.map[d],f=s+u+l.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((c=R.getState(t))===null||c===void 0)&&c.dragging&&n.push(_.Decoration.node(s+u,s+u+l.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),n.push(_.Decoration.widget(f,h))}}return _.DecorationSet.create(t.doc,n)}function _t({allowTableNodeSelection:t=!1}={}){return new w.Plugin({key:z,state:{init(){return null},apply(e,n){const o=e.getMeta(z);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:qe,handleDOMEvents:{mousedown:At},createSelectionBetween(e){return z.getState(e.state)!=null?e.state.selection:null},handleTripleClick:yt,handleKeyDown:Ct,handlePaste:St},appendTransaction(e,n,o){return Ue(o,ve(o,n),t)}})}function q(t){return t==="left"||t==="right"||t==="center"?t:null}function Dt(t){const e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return q(e||n)}function It(t){return q(t==null?void 0:t.align)}function ke(){return{default:null,parseHTML:t=>Dt(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}var ze=w.Node3.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const o=t.getAttribute("colwidth"),l=o?o.split(",").map(r=>parseInt(r,10)):null;if(!l){const r=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),s=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(s&&s>-1&&r&&r[s]){const i=r[s].getAttribute("width");return i?[parseInt(i,10)]:null}}return l}},align:ke()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",w.mergeAttributes(this.options.HTMLAttributes,t),0]}}),He=w.Node3.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}},align:ke()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",w.mergeAttributes(this.options.HTMLAttributes,t),0]}}),_e=w.Node3.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",w.mergeAttributes(this.options.HTMLAttributes,t),0]}});function oe(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function be(t,e,n,o,l,r){var s;let i=0,c=!0,a=e.firstChild;const d=t.firstChild;if(d!==null)for(let f=0,h=0;f<d.childCount;f+=1){const{colspan:p,colwidth:m}=d.child(f).attrs;for(let b=0;b<p;b+=1,h+=1){const g=l===h?r:m&&m[b],S=g?`${g}px`:"";if(i+=g||o,g||(c=!1),a){if(a.style.width!==S){const[x,L]=oe(o,g);a.style.setProperty(x,L)}a=a.nextSibling}else{const x=document.createElement("col"),[L,M]=oe(o,g);x.style.setProperty(L,M),e.appendChild(x)}}}for(;a;){const f=a.nextSibling;(s=a.parentNode)==null||s.removeChild(a),a=f}const u=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);c&&!u?(n.style.width=`${i}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${i}px`)}var Bt=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),be(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,be(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),o=this.contentDOM.contains(e);return!!(n&&!o&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function $t(t,e,n,o){let l=0,r=!0;const s=[],i=t.firstChild;if(!i)return{};for(let u=0,f=0;u<i.childCount;u+=1){const{colspan:h,colwidth:p}=i.child(u).attrs;for(let m=0;m<h;m+=1,f+=1){const b=n===f?o:p&&p[m];l+=b||e,b||(r=!1);const[g,S]=oe(e,b);s.push(["col",{style:`${g}: ${S}`}])}}const c=r?`${l}px`:"",a=r?"":`${l}px`;return{colgroup:["colgroup",{},...s],tableWidth:c,tableMinWidth:a}}function we(t,e){return t.createAndFill()}function Wt(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 Ft(t,e,n,o,l){const r=Wt(t),s=[],i=[];for(let a=0;a<n;a+=1){const d=we(r.cell);if(d&&i.push(d),o){const u=we(r.header_cell);u&&s.push(u)}}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 Pt(t){return t instanceof C}var V=({editor:t})=>{const{selection:e}=t.state;if(!Pt(e))return!1;let n=0;const o=w.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},jt="";function Ot(t){return(t||"").replace(/\s+/g," ").trim()}function Vt(t,e,n={}){var o;const l=(o=n.cellLineSeparator)!=null?o:jt;if(!t||!t.content||t.content.length===0)return"";const r=[];t.content.forEach(m=>{const b=[];m.content&&m.content.forEach(g=>{let S="";g.content&&Array.isArray(g.content)&&g.content.length>1?S=g.content.map(H=>e.renderChildren(H)).join(l):S=g.content?e.renderChildren(g.content):"";const x=Ot(S),L=g.type==="tableHeader",M=It(g.attrs);b.push({text:x,isHeader:L,align:M})}),r.push(b)});const s=r.reduce((m,b)=>Math.max(m,b.length),0);if(s===0)return"";const i=new Array(s).fill(0);r.forEach(m=>{var b;for(let g=0;g<s;g+=1){const x=(((b=m[g])==null?void 0:b.text)||"").length;x>i[g]&&(i[g]=x),i[g]<3&&(i[g]=3)}});const c=(m,b)=>m+" ".repeat(Math.max(0,b-m.length)),a=r[0],d=a.some(m=>m.isHeader),u=new Array(s).fill(null);r.forEach(m=>{var b;for(let g=0;g<s;g+=1)!u[g]&&((b=m[g])!=null&&b.align)&&(u[g]=m[g].align)});let f=`
2
- `;const h=new Array(s).fill(0).map((m,b)=>d&&a[b]&&a[b].text||"");return f+=`| ${h.map((m,b)=>c(m,i[b])).join(" | ")} |
3
- `,f+=`| ${i.map((m,b)=>{const g=Math.max(3,m),S=u[b];return S==="left"?`:${"-".repeat(g)}`:S==="right"?`${"-".repeat(g)}:`:S==="center"?`:${"-".repeat(g)}:`:"-".repeat(g)}).join(" | ")} |
4
- `,(d?r.slice(1):r).forEach(m=>{f+=`| ${new Array(s).fill(0).map((b,g)=>c(m[g]&&m[g].text||"",i[g])).join(" | ")} |
5
- `}),f}var Gt=Vt,De=w.Node3.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Bt,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}=$t(t,this.options.cellMinWidth),r=e.style;function s(){return r||(o?`width: ${o}`:`min-width: ${l}`)}const i=["table",w.mergeAttributes(this.options.HTMLAttributes,e,{style:s()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},parseMarkdown:(t,e)=>{const n=[],o=Array.isArray(t.align)?t.align:[];if(t.header){const l=[];t.header.forEach((r,s)=>{var i;const c=q((i=o[s])!=null?i:r.align),a=c?{align:c}:{};l.push(e.createNode("tableHeader",a,[{type:"paragraph",content:e.parseInline(r.tokens)}]))}),n.push(e.createNode("tableRow",{},l))}return t.rows&&t.rows.forEach(l=>{const r=[];l.forEach((s,i)=>{var c;const a=q((c=o[i])!=null?c:s.align),d=a?{align:a}:{};r.push(e.createNode("tableCell",d,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>Gt(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:o,dispatch:l,editor:r})=>{const s=Ft(r.schema,t,e,n);if(l){const i=o.selection.from+1;o.replaceSelectionWith(s).scrollIntoView().setSelection(Be.TextSelection.near(o.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Qe(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>et(t,e),deleteColumn:()=>({state:t,dispatch:e})=>nt(t,e),addRowBefore:()=>({state:t,dispatch:e})=>lt(t,e),addRowAfter:()=>({state:t,dispatch:e})=>rt(t,e),deleteRow:()=>({state:t,dispatch:e})=>it(t,e),deleteTable:()=>({state:t,dispatch:e})=>pt(t,e),mergeCells:()=>({state:t,dispatch:e})=>se(t,e),splitCell:()=>({state:t,dispatch:e})=>ie(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>$("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>$("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>ft(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>se(t,e)?!0:ie(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:o})=>dt(t,e)(n,o),goToNextCell:()=>({state:t,dispatch:e})=>ae(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>ae(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&ve(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const o=C.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:V,"Mod-Backspace":V,Delete:V,"Mod-Delete":V}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Tt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],_t({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:n,view:o})=>new e(n,this.options.cellMinWidth,o)},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:w.callOrReturn(w.getExtensionField(t,"tableRole",e))}}});w.Extension.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(De.configure(this.options.table)),this.options.tableCell!==!1&&t.push(ze.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(He.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(_e.configure(this.options.tableRow)),t}});function Kt(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 qt(t,e,n){const{doc:o,selection:l}=t;return!o||!l||!(l instanceof C)||l.forEachCell((r,s)=>{t=Kt(t,s,n)}),t}function Ce(t,e){return({tr:n,state:o,dispatch:l})=>{const{selection:r}=o;return n=n.setSelection(r),n=qt(n,e,t),n.docChanged?(l==null||l(n),!0):!1}}const Xt=w.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=>Ce(t,this.options),unsetTableCellBackground:()=>Ce("",this.options)}}}),Zt=/(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,Ut=/CrOS/,Jt=/android|ipad|playbook|silk/i;function ye(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:!!(Zt.test(e)&&!Ut.test(e)||t.tablet&&Jt.test(e)||t.tablet&&t.featureDetect&&navigator&&navigator.maxTouchPoints>1&&e.includes("Macintosh")&&e.includes("Safari"))}const Se=t=>Array.from({length:t}).map((e,n)=>n+1);function Yt(t){var f;const[e,n]=F.useState(!1),[o,l]=F.useState(!0),[r,s]=F.useState({rows:ye()?v.TABLE_MAX_GRID_SIZE:v.TABLE_INIT_GRID_SIZE,cols:ye()?v.TABLE_MAX_GRID_SIZE:v.TABLE_INIT_GRID_SIZE}),[i,c]=F.useState({rows:v.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:v.TABLE_DEFAULT_SELECTED_GRID_SIZE});function a(h,p){h===r.rows&&s(m=>({...m,rows:Math.min(h+1,v.TABLE_MAX_GRID_SIZE)})),p===r.cols&&s(m=>({...m,cols:Math.min(p+1,v.TABLE_MAX_GRID_SIZE)})),c({rows:h,cols:p})}function d(h,p){t==null||t.createTable({rows:h,cols:p,withHeaderRow:o}),u(),n(!1)}function u(){l(!1),s({rows:v.TABLE_INIT_GRID_SIZE,cols:v.TABLE_INIT_GRID_SIZE}),c({rows:v.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:v.TABLE_DEFAULT_SELECTED_GRID_SIZE})}return T.jsxs(U.Popover,{modal:!0,onOpenChange:n,open:e,children:[T.jsx(U.PopoverTrigger,{asChild:!0,"data-state":t!=null&&t.dataState?"on":"off",children:t==null?void 0:t.children}),T.jsx(U.PopoverContent,{align:"start",className:"richtext-w-full !richtext-p-2",side:"bottom",children:T.jsxs("div",{className:"table-grid-size-editor richtext-p-0",children:[T.jsx("div",{className:"richtext-flex richtext-flex-col richtext-flex-wrap richtext-justify-between richtext-gap-1",children:(f=Se(r==null?void 0:r.rows))==null?void 0:f.map(h=>{var p;return T.jsx("div",{className:"richtext-flex richtext-gap-1",children:(p=Se(r==null?void 0:r.cols))==null?void 0:p.map(m=>T.jsx("div",{onMouseDown:()=>d(h,m),onMouseOver:()=>a(h,m),className:`richtext-cursor-pointer richtext-border-border ${m<=i.cols&&h<=i.rows&&"tableCellActive !richtext-bg-foreground"}`,children:T.jsx("div",{className:"richtext-box-border richtext-size-4 richtext-rounded-[2px] !richtext-border richtext-border-solid !richtext-border-border richtext-p-1"})},`richtext-table-col-${m}`))},`richtext-table-row-${h}`)})}),T.jsxs("div",{className:"richtext-mt-2 richtext-text-center richtext-text-sm richtext-text-foreground",children:[i.rows,"x",i.cols]})]})})]})}function Qt(){const t=W.useEditorInstance(),e=W.useButtonProps(Ie.name),{icon:n=void 0,tooltip:o=void 0,action:l=void 0,isActive:r=void 0,color:s}=(e==null?void 0:e.componentProps)??{},{dataState:i,disabled:c}=W.useToggleActive(r);if(!e)return T.jsx(T.Fragment,{});function a(d){t.chain().focus().insertTable({...d,withHeaderRow:!1}).run()}return T.jsx(Yt,{createTable:a,dataState:i,children:T.jsx(W.ActionButton,{action:l,color:s,dataState:i,icon:n,isActive:r,tooltip:o,disabled:c})})}const Ie=De.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),HTMLAttributes:{style:`
1
+ "use strict";const b=require("./index-BGfIcDCQ.cjs"),Be=require("@tiptap/pm/state"),_=require("./index-CHVV5iY-.cjs"),T=require("react/jsx-runtime"),W=require("./index-aujjnfSJ.cjs"),F=require("react");require("./theme.cjs");const U=require("./popover-CrywEkBR.cjs"),v=require("./index-BpLw6ebr.cjs");let Y,Q;if(typeof WeakMap<"u"){let t=new WeakMap;Y=e=>t.get(e),Q=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Y=o=>{for(let l=0;l<t.length;l+=2)if(t[l]==o)return t[l+1]},Q=(o,l)=>(n==10&&(n=0),t[n++]=o,t[n++]=l)}var y=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 Y(t)||Q(t,$e(t))}};function $e(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=We(t),n=t.childCount,o=[];let l=0,r=null;const s=[];for(let a=0,d=e*n;a<d;a++)o[a]=0;for(let a=0,d=0;a<n;a++){const u=t.child(a);d++;for(let p=0;;p++){for(;l<o.length&&o[l]!=0;)l++;if(p==u.childCount)break;const g=u.child(p),{colspan:w,rowspan:m,colwidth:S}=g.attrs;for(let x=0;x<m;x++){if(x+a>=n){(r||(r=[])).push({type:"overlong_rowspan",pos:d,n:m-x});break}const L=l+x*e;for(let M=0;M<w;M++){o[L+M]==0?o[L+M]=d:(r||(r=[])).push({type:"collision",row:a,pos:d,n:w-M});const B=S&&S[M];if(B){const H=(L+M)%e*2,Z=s[H];Z==null||Z!=B&&s[H+1]==1?(s[H]=B,s[H+1]=1):Z==B&&s[H+1]++}}}l+=w,d+=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}),d++}(e===0||n===0)&&(r||(r=[])).push({type:"zero_sized"});const i=new y(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&&Fe(i,s,t),i}function We(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 Fe(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 d=e[(l+a)%t.width*2];d!=null&&(!c.colwidth||c.colwidth[a]!=d)&&((i||(i=Pe(c)))[a]=d)}i&&t.problems.unshift({type:"colwidth mismatch",pos:r,colwidth:i})}}function Pe(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function A(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}const z=new b.PluginKey("selectingCells");function D(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 je(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 E(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 X(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=D(e.$head)||Oe(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Oe(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 ee(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Ve(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function le(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Ae(t,e,n){const o=t.node(-1),l=y.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 I(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 xe(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 Ge(t,e,n){const o=A(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 C=class k extends b.Selection{constructor(e,n=e){const o=e.node(-1),l=y.get(o),r=e.start(-1),s=l.rectBetween(e.pos-r,n.pos-r),i=e.node(0),c=l.cellsInRect(s).filter(d=>d!=n.pos-r);c.unshift(n.pos-r);const a=c.map(d=>{const u=o.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const f=r+d+1;return new b.SelectionRange(i.resolve(f),i.resolve(f+u.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(ee(o)&&ee(l)&&le(o,l)){const r=this.$anchorCell.node(-1)!=o.node(-1);return r&&this.isRowSelection()?k.rowSelection(o,l):r&&this.isColSelection()?k.colSelection(o,l):new k(o,l)}return b.TextSelection.between(o,l)}content(){const e=this.$anchorCell.node(-1),n=y.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 d=c*n.width+l.left,u=l.left;u<l.right;u++,d++){const f=n.map[d];if(r[f])continue;r[f]=!0;const h=n.findCell(f);let p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const g=l.left-h.left,w=h.right-l.right;if(g>0||w>0){let m=p.attrs;if(g>0&&(m=I(m,0,g)),w>0&&(m=I(m,m.colspan-w,w)),h.left<l.left){if(p=p.type.createAndFill(m),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(m)}`)}else p=p.type.create(m,p.content)}if(h.top<l.top||h.bottom>l.bottom){const m={...p.attrs,rowspan:Math.min(h.bottom,l.bottom)-Math.max(h.top,l.top)};h.top<l.top?p=p.type.createAndFill(m):p=p.type.create(m,p.content)}a.push(p)}s.push(e.child(c).copy(b.Fragment.from(a)))}const i=this.isColSelection()&&this.isRowSelection()?e:s;return new b.Slice(b.Fragment.from(i),1,1)}replace(e,n=b.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?b.Slice.empty:n)}const r=b.Selection.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,n){this.replace(e,new b.Slice(b.Fragment.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),o=y.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=y.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 k(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=y.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 k&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const o=e.node(-1),l=y.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 k(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new k(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){return new k(e.resolve(n),e.resolve(o))}getBookmark(){return new Ke(this.$anchorCell.pos,this.$headCell.pos)}};C.prototype.visible=!1;b.Selection.jsonID("cell",C);var Ke=class Te{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Te(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&&le(n,o)?new C(n,o):b.Selection.near(o,1)}};function qe(t){if(!(t.selection instanceof C))return null;const e=[];return t.selection.forEachCell((n,o)=>{e.push(_.Decoration.node(o,o+n.nodeSize,{class:"selectedCell"}))}),_.DecorationSet.create(t.doc,e)}function Xe({$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 Ze({$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 Ue(t,e,n){const o=(e||t).selection,l=(e||t).doc;let r,s;if(o instanceof b.NodeSelection&&(s=o.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")r=C.create(l,o.from);else if(s=="row"){const i=l.resolve(o.from+1);r=C.rowSelection(i,i)}else if(!n){const i=y.get(o.node),c=o.from+1,a=c+i.map[i.width*i.height-1];r=C.create(l,c+1,a)}}else o instanceof b.TextSelection&&Xe(o)?r=b.TextSelection.create(l,o.from):o instanceof b.TextSelection&&Ze(o)&&(r=b.TextSelection.create(l,o.$from.start(),o.$from.end()));return r&&(e||(e=t.tr)).setSelection(r),e}const Je=new b.PluginKey("fix-tables");function Re(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,d=Math.min(l,s+3);a<d;a++)if(t.child(a)==c){i=a+1,n+=c.nodeSize;continue e}o(c,n),i<l&&t.child(i).sameMarkup(c)?Re(t.child(i),c,n+1,o):c.nodesBetween(0,c.content.size,o,n+1),n+=c.nodeSize}}function ve(t,e){let n;const o=(l,r)=>{l.type.spec.tableRole=="table"&&(n=Ye(t,l,r,n))};return e?e.doc!=t.doc&&Re(e.doc,t.doc,0,o):t.doc.descendants(o),n}function Ye(t,e,n,o){const l=y.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 d=e.nodeAt(a.pos);if(!d)continue;const u=d.attrs;for(let f=0;f<u.rowspan;f++)r[a.row+f]+=a.n;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,I(u,u.colspan-a.n,a.n))}else if(a.type=="missing")r[a.row]+=a.n;else if(a.type=="overlong_rowspan"){const d=e.nodeAt(a.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-a.n})}else if(a.type=="colwidth mismatch"){const d=e.nodeAt(a.pos);if(!d)continue;o.setNodeMarkup(o.mapping.map(n+1+a.pos),null,{...d.attrs,colwidth:a.colwidth})}else if(a.type=="zero_sized"){const d=o.mapping.map(n);o.delete(d,d+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 d=e.child(c),u=a+d.nodeSize,f=r[c];if(f>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const p=[];for(let w=0;w<f;w++){const m=A(t.schema)[h].createAndFill();m&&p.push(m)}const g=(c==0||s==c-1)&&i==c?a+1:u-1;o.insert(o.mapping.map(g),p)}a=u}return o.setMeta(Je,{fixTables:!0})}function N(t){const e=t.selection,n=X(t),o=n.node(-1),l=n.start(-1),r=y.get(o);return{...e instanceof C?r.rectBetween(e.$anchorCell.pos-l,e.$headCell.pos-l):r.findCell(n.pos-l),tableStart:l,map:r,table:o}}function Me(t,{map:e,tableStart:n,table:o},l){let r=l>0?-1:0;Ge(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,xe(a.attrs,l-e.colCount(c))),s+=a.attrs.rowspan-1}else{const c=r==null?A(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 Qe(t,e){if(!E(t))return!1;if(e){const n=N(t);e(Me(t.tr,n,n.left))}return!0}function et(t,e){if(!E(t))return!1;if(e){const n=N(t);e(Me(t.tr,n,n.right))}return!0}function tt(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),d=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,I(d,l-e.colCount(c)));else{const u=t.mapping.slice(r).map(o+c);t.delete(u,u+a.nodeSize)}s+=d.rowspan}}function nt(t,e){if(!E(t))return!1;if(e){const n=N(t),o=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let l=n.right-1;tt(o,n,l),l!=n.left;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw new RangeError("No table found");n.table=r,n.map=y.get(r)}e(o)}return!0}function ot(t,e,n){var o;const l=A(e.type.schema).header_cell;for(let r=0;r<t.width;r++)if(((o=e.nodeAt(t.map[r+n*t.width]))===null||o===void 0?void 0:o.type)!=l)return!1;return!0}function Ee(t,{map:e,tableStart:n,table:o},l){let r=n;for(let a=0;a<l;a++)r+=o.child(a).nodeSize;const s=[];let i=l>0?-1:0;ot(e,o,l+i)&&(i=l==0||l==e.height?null:0);for(let a=0,d=e.width*l;a<e.width;a++,d++)if(l>0&&l<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],f=o.nodeAt(u).attrs;t.setNodeMarkup(n+u,null,{...f,rowspan:f.rowspan+1}),a+=f.colspan-1}else{var c;const u=i==null?A(o.type.schema).cell:(c=o.nodeAt(e.map[d+i*e.width]))===null||c===void 0?void 0:c.type,f=u==null?void 0:u.createAndFill();f&&s.push(f)}return t.insert(r,A(o.type.schema).row.create(null,s)),t}function lt(t,e){if(!E(t))return!1;if(e){const n=N(t);e(Ee(t.tr,n,n.top))}return!0}function rt(t,e){if(!E(t))return!1;if(e){const n=N(t);e(Ee(t.tr,n,n.bottom))}return!0}function st(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,d=l*e.width;a<e.width;a++,d++){const u=e.map[d];if(!c.has(u)){if(c.add(u),l>0&&u==e.map[d-e.width]){const f=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(i).map(u+o),null,{...f,rowspan:f.rowspan-1}),a+=f.colspan-1}else if(l<e.height&&u==e.map[d+e.width]){const f=n.nodeAt(u),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 it(t,e){if(!E(t))return!1;if(e){const n=N(t),o=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let l=n.bottom-1;st(o,n,l),l!=n.top;l--){const r=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!r)throw new RangeError("No table found");n.table=r,n.map=y.get(n.table)}e(o)}return!0}function re(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function ct({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 se(t,e){const n=t.selection;if(!(n instanceof C)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=N(t),{map:l}=o;if(ct(l,o))return!1;if(e){const r=t.tr,s={};let i=b.Fragment.empty,c,a;for(let d=o.top;d<o.bottom;d++)for(let u=o.left;u<o.right;u++){const f=l.map[d*l.width+u],h=o.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,c==null)c=f,a=h;else{re(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,{...xe(a.attrs,a.attrs.colspan,o.right-o.left-a.attrs.colspan),rowspan:o.bottom-o.top}),i.size>0){const d=c+1+a.content.size,u=re(a)?c+1:d;r.replaceWith(u+o.tableStart,d+o.tableStart,i)}r.setSelection(new C(r.doc.resolve(c+o.tableStart))),e(r)}return!0}function ie(t,e){const n=A(t.schema);return at(({node:o})=>n[o.type.spec.tableRole])(t,e)}function at(t){return(e,n)=>{const o=e.selection;let l,r;if(o instanceof C){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;l=o.$anchorCell.nodeAfter,r=o.$anchorCell.pos}else{var s;if(l=je(o.$from),!l)return!1;r=(s=D(o.$from))===null||s===void 0?void 0:s.pos}if(l==null||r==null||l.attrs.colspan==1&&l.attrs.rowspan==1)return!1;if(n){let i=l.attrs;const c=[],a=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const d=N(e),u=e.tr;for(let h=0;h<d.right-d.left;h++)c.push(a?{...i,colwidth:a&&a[h]?[a[h]]:null}:i);let f;for(let h=d.top;h<d.bottom;h++){let p=d.map.positionAt(h,d.left,d.table);h==d.top&&(p+=l.nodeSize);for(let g=d.left,w=0;g<d.right;g++,w++)g==d.left&&h==d.top||u.insert(f=u.mapping.map(p+d.tableStart,1),t({node:l,row:h,col:g}).createAndFill(c[w]))}u.setNodeMarkup(r,t({node:l,row:d.top,col:d.left}),c[0]),o instanceof C&&u.setSelection(new C(u.doc.resolve(o.$anchorCell.pos),f?u.doc.resolve(f):void 0)),n(u)}return!0}}function dt(t,e){return function(n,o){if(!E(n))return!1;const l=X(n);if(l.nodeAfter.attrs[t]===e)return!1;if(o){const r=n.tr;n.selection instanceof C?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 ut(t){return function(e,n){if(!E(e))return!1;if(n){const o=A(e.schema),l=N(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 ce(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 $(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?ut(t):function(n,o){if(!E(n))return!1;if(o){const l=A(n.schema),r=N(n),s=n.tr,i=ce("row",r,l),c=ce("column",r,l),a=(t==="column"?i:t==="row"&&c)?1:0,d=t=="column"?{left:0,top:a,right:1,bottom:r.map.height}:t=="row"?{left:a,top:0,right:r.map.width,bottom:1}:r,u=t=="column"?c?l.cell:l.header_cell:t=="row"?i?l.cell:l.header_cell:l.cell;r.map.cellsInRect(d).forEach(f=>{const h=f+r.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,u,p.attrs)}),o(s)}return!0}}$("row",{useDeprecatedLogic:!0});$("column",{useDeprecatedLogic:!0});const ft=$("cell",{useDeprecatedLogic:!0});function ht(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 ae(t){return function(e,n){if(!E(e))return!1;const o=ht(X(e),t);if(o==null)return!1;if(n){const l=e.doc.resolve(o);n(e.tr.setSelection(b.TextSelection.between(l,Ve(l))).scrollIntoView())}return!0}}function pt(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 P(t,e){const n=t.selection;if(!(n instanceof C))return!1;if(e){const o=t.tr,l=A(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 b.Slice(l,0,0))}),o.docChanged&&e(o)}return!0}function gt(t){if(t.size===0)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 d=c?0:Math.max(0,n-1),u=c<e.childCount-1?0:Math.max(0,o-1);(d||u)&&(a=te(A(s).row,new b.Slice(a,d,u)).content),i.push(a)}else if(r=="cell"||r=="header_cell")i.push(n||o?te(A(s).row,new b.Slice(e,n,o)).content:e);else return null;return mt(s,i)}function mt(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(b.Fragment.empty),n[l]<o){const r=A(t).cell.createAndFill(),s=[];for(let i=n[l];i<o;i++)s.push(r);e[l]=e[l].append(b.Fragment.from(s))}return{height:e.length,width:o,rows:e}}function te(t,e){const n=t.createAndFill();return new b.Transform(n).replace(0,n.content.size,e).doc}function bt({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 d=r[i]||0,u=0;d<o;u++){let f=c.child(u%c.childCount);d+f.attrs.colspan>o&&(f=f.type.createChecked(I(f.attrs,f.attrs.colspan,d+f.attrs.colspan-o),f.content)),a.push(f),d+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)r[i+h]=(r[i+h]||0)+f.attrs.colspan}s.push(b.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 d=0;d<a.childCount;d++){let u=a.child(d);s+u.attrs.rowspan>l&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,l-u.attrs.rowspan)},u.content)),c.push(u)}r.push(b.Fragment.from(c))}n=r,e=l}return{width:t,height:e,rows:n}}function wt(t,e,n,o,l,r,s){const i=t.doc.type.schema,c=A(i);let a,d;if(l>e.width)for(let u=0,f=0;u<e.height;u++){const h=n.child(u);f+=h.nodeSize;const p=[];let g;h.lastChild==null||h.lastChild.type==c.cell?g=a||(a=c.cell.createAndFill()):g=d||(d=c.header_cell.createAndFill());for(let w=e.width;w<l;w++)p.push(g);t.insert(t.mapping.slice(s).map(f-1+o),p)}if(r>e.height){const u=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,l);p++){const w=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==c.header_cell;u.push(w?d||(d=c.header_cell.createAndFill()):a||(a=c.cell.createAndFill()))}const f=c.row.create(null,b.Fragment.from(u)),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||d)}function de(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 d=s*e.width+a,u=e.map[d];if(e.map[d-e.width]==u){c=!0;const f=n.nodeAt(u),{top:h,left:p}=e.findCell(u);t.setNodeMarkup(t.mapping.slice(i).map(u+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 ue(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 d=a*e.width+s,u=e.map[d];if(e.map[d-1]==u){c=!0;const f=n.nodeAt(u),h=e.colCount(u),p=t.mapping.slice(i).map(u+o);t.setNodeMarkup(p,null,I(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(I(f.attrs,0,s-h))),a+=f.attrs.rowspan-1}}return c}function fe(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=y.get(r);const{top:i,left:c}=o,a=c+l.width,d=i+l.height,u=t.tr;let f=0;function h(){if(r=n?u.doc.nodeAt(n-1):u.doc,!r)throw new Error("No table found");s=y.get(r),f=u.mapping.maps.length}wt(u,s,r,n,a,d,f)&&h(),de(u,s,r,n,c,a,i,f)&&h(),de(u,s,r,n,c,a,d,f)&&h(),ue(u,s,r,n,i,d,c,f)&&h(),ue(u,s,r,n,i,d,a,f)&&h();for(let p=i;p<d;p++){const g=s.positionAt(p,c,r),w=s.positionAt(p,a,r);u.replace(u.mapping.slice(f).map(g+n),u.mapping.slice(f).map(w+n),new b.Slice(l.rows[p-i],0,0))}h(),u.setSelection(new C(u.doc.resolve(n+s.positionAt(i,c,r)),u.doc.resolve(n+s.positionAt(d-1,a-1,r)))),e(u)}const Ct=_.keydownHandler({ArrowLeft:j("horiz",-1),ArrowRight:j("horiz",1),ArrowUp:j("vert",-1),ArrowDown:j("vert",1),"Shift-ArrowLeft":O("horiz",-1),"Shift-ArrowRight":O("horiz",1),"Shift-ArrowUp":O("vert",-1),"Shift-ArrowDown":O("vert",1),Backspace:P,"Mod-Backspace":P,Delete:P,"Mod-Delete":P});function G(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function j(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;if(r instanceof C)return G(n,o,b.Selection.near(r.$headCell,e));if(t!="horiz"&&!r.empty)return!1;const s=Ne(l,t,e);if(s==null)return!1;if(t=="horiz")return G(n,o,b.Selection.near(n.doc.resolve(r.head+e),e));{const i=n.doc.resolve(s),c=Ae(i,t,e);let a;return c?a=b.Selection.near(c,1):e<0?a=b.Selection.near(n.doc.resolve(i.before(-1)),-1):a=b.Selection.near(n.doc.resolve(i.after(-1)),1),G(n,o,a)}}}function O(t,e){return(n,o,l)=>{if(!l)return!1;const r=n.selection;let s;if(r instanceof C)s=r;else{const c=Ne(l,t,e);if(c==null)return!1;s=new C(n.doc.resolve(c))}const i=Ae(s.$headCell,t,e);return i?G(n,o,new C(s.$anchorCell,i)):!1}}function yt(t,e){const n=t.state.doc,o=D(n.resolve(e));return o?(t.dispatch(t.state.tr.setSelection(new C(o))),!0):!1}function St(t,e,n){if(!E(t.state))return!1;let o=gt(n);const l=t.state.selection;if(l instanceof C){o||(o={width:1,height:1,rows:[b.Fragment.from(te(A(t.state.schema).cell,n))]});const r=l.$anchorCell.node(-1),s=l.$anchorCell.start(-1),i=y.get(r).rectBetween(l.$anchorCell.pos-s,l.$headCell.pos-s);return o=bt(o,i.right-i.left,i.bottom-i.top),fe(t.state,t.dispatch,s,i,o),!0}else if(o){const r=X(t.state),s=r.start(-1);return fe(t.state,t.dispatch,s,y.get(r.node(-1)).findCell(r.pos-s),o),!0}else return!1}function At(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const o=he(t,e.target);let l;if(e.shiftKey&&t.state.selection instanceof C)r(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(l=D(t.state.selection.$anchor))!=null&&((n=J(t,e))===null||n===void 0?void 0:n.pos)!=l.pos)r(l,e),e.preventDefault();else if(!o)return;function r(c,a){let d=J(t,a);const u=z.getState(t.state)==null;if(!d||!le(c,d))if(u)d=c;else return;const f=new C(c,d);if(u||!t.state.selection.eq(f)){const h=t.state.tr.setSelection(f);u&&h.setMeta(z,c.pos),t.dispatch(h)}}function s(){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))}function i(c){const a=c,d=z.getState(t.state);let u;if(d!=null)u=t.state.doc.resolve(d);else if(he(t,a.target)!=o&&(u=J(t,e),!u))return s();u&&r(u,a)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",i)}function Ne(t,e,n){if(!(t.state.selection instanceof b.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 s=o.before(l),i=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(i)?s:null}}return null}function he(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function J(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:o,pos:l}=n;return o>=0&&D(t.state.doc.resolve(o))||D(t.state.doc.resolve(l))}var xt=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")),ne(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,ne(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ne(t,e,n,o,l,r){let s=0,i=!0,c=e.firstChild;const a=t.firstChild;if(a){for(let u=0,f=0;u<a.childCount;u++){const{colspan:h,colwidth:p}=a.child(u).attrs;for(let g=0;g<h;g++,f++){const w=l==f?r:p&&p[g],m=w?w+"px":"";if(s+=w||o,w||(i=!1),c)c.style.width!=m&&(c.style.width=m),c=c.nextSibling;else{const S=document.createElement("col");S.style.width=m,e.appendChild(S)}}}for(;c;){var d;const u=c.nextSibling;(d=c.parentNode)===null||d===void 0||d.removeChild(c),c=u}i?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const R=new b.PluginKey("tableColumnResizing");function Tt({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:o=xt,lastColumnResizable:l=!0}={}){const r=new b.Plugin({key:R,state:{init(s,i){var c;const a=(c=r.spec)===null||c===void 0||(c=c.props)===null||c===void 0?void 0:c.nodeViews,d=A(i.schema).table.name;return o&&a&&(a[d]=(u,f)=>new o(u,n,f)),new Rt(-1,!1)},apply(s,i){return i.apply(s)}},props:{attributes:s=>{const i=R.getState(s);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,i)=>{vt(s,i,t,l)},mouseleave:s=>{Mt(s)},mousedown:(s,i)=>{Et(s,i,e,n)}},decorations:s=>{const i=R.getState(s);if(i&&i.activeHandle>-1)return Ht(s,i.activeHandle)},nodeViews:{}}});return r}var Rt=class K{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,o=e.getMeta(R);if(o&&o.setHandle!=null)return new K(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new K(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&e.docChanged){let l=e.mapping.map(n.activeHandle,-1);return ee(e.doc.resolve(l))||(l=-1),new K(l,n.dragging)}return n}};function vt(t,e,n,o){if(!t.editable)return;const l=R.getState(t.state);if(l&&!l.dragging){const r=Lt(e.target);let s=-1;if(r){const{left:i,right:c}=r.getBoundingClientRect();e.clientX-i<=n?s=pe(t,e,"left",n):c-e.clientX<=n&&(s=pe(t,e,"right",n))}if(s!=l.activeHandle){if(!o&&s!==-1){const i=t.state.doc.resolve(s),c=i.node(-1),a=y.get(c),d=i.start(-1);if(a.colCount(i.pos-d)+i.nodeAfter.attrs.colspan-1==a.width-1)return}Le(t,s)}}}function Mt(t){if(!t.editable)return;const e=R.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Le(t,-1)}function Et(t,e,n,o){var l;if(!t.editable)return!1;const r=(l=t.dom.ownerDocument.defaultView)!==null&&l!==void 0?l:window,s=R.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const i=t.state.doc.nodeAt(s.activeHandle),c=Nt(t,s.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(R,{setDragging:{startX:e.clientX,startWidth:c}}));function a(u){r.removeEventListener("mouseup",a),r.removeEventListener("mousemove",d);const f=R.getState(t.state);f!=null&&f.dragging&&(kt(t,f.activeHandle,ge(f.dragging,u,n)),t.dispatch(t.state.tr.setMeta(R,{setDragging:null})))}function d(u){if(!u.which)return a(u);const f=R.getState(t.state);if(f&&f.dragging){const h=ge(f.dragging,u,n);me(t,f.activeHandle,h,o)}}return me(t,s.activeHandle,c,o),r.addEventListener("mouseup",a),r.addEventListener("mousemove",d),e.preventDefault(),!0}function Nt(t,e,{colspan:n,colwidth:o}){const l=o&&o[o.length-1];if(l)return l;const r=t.domAtPos(e);let s=r.node.childNodes[r.offset].offsetWidth,i=n;if(o)for(let c=0;c<n;c++)o[c]&&(s-=o[c],i--);return s/i}function Lt(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function pe(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=D(t.state.doc.resolve(s));if(!i)return-1;if(n=="right")return i.pos;const c=y.get(i.node(-1)),a=i.start(-1),d=c.map.indexOf(i.pos-a);return d%c.width==0?-1:a+c.map[d-1]}function ge(t,e,n){const o=e.clientX-t.startX;return Math.max(n,t.startWidth+o)}function Le(t,e){t.dispatch(t.state.tr.setMeta(R,{setHandle:e}))}function kt(t,e,n){const o=t.state.doc.resolve(e),l=o.node(-1),r=y.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 d=a*r.width+i;if(a&&r.map[d]==r.map[d-r.width])continue;const u=r.map[d],f=l.nodeAt(u).attrs,h=f.colspan==1?0:i-r.colCount(u);if(f.colwidth&&f.colwidth[h]==n)continue;const p=f.colwidth?f.colwidth.slice():zt(f.colspan);p[h]=n,c.setNodeMarkup(s+u,null,{...f,colwidth:p})}c.docChanged&&t.dispatch(c)}function me(t,e,n,o){const l=t.state.doc.resolve(e),r=l.node(-1),s=l.start(-1),i=y.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&&ne(r,c.firstChild,c,o,i,n)}function zt(t){return Array(t).fill(0)}function Ht(t,e){const n=[],o=t.doc.resolve(e),l=o.node(-1);if(!l)return _.DecorationSet.empty;const r=y.get(l),s=o.start(-1),i=r.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;for(let a=0;a<r.height;a++){const d=i+a*r.width;if((i==r.width-1||r.map[d]!=r.map[d+1])&&(a==0||r.map[d]!=r.map[d-r.width])){var c;const u=r.map[d],f=s+u+l.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((c=R.getState(t))===null||c===void 0)&&c.dragging&&n.push(_.Decoration.node(s+u,s+u+l.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),n.push(_.Decoration.widget(f,h))}}return _.DecorationSet.create(t.doc,n)}function _t({allowTableNodeSelection:t=!1}={}){return new b.Plugin({key:z,state:{init(){return null},apply(e,n){const o=e.getMeta(z);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:qe,handleDOMEvents:{mousedown:At},createSelectionBetween(e){return z.getState(e.state)!=null?e.state.selection:null},handleTripleClick:yt,handleKeyDown:Ct,handlePaste:St},appendTransaction(e,n,o){return Ue(o,ve(o,n),t)}})}function q(t){return t==="left"||t==="right"||t==="center"?t:null}function Dt(t){const e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return q(e||n)}function It(t){return q(t==null?void 0:t.align)}function ke(){return{default:null,parseHTML:t=>Dt(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}var ze=b.Node3.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const o=t.getAttribute("colwidth"),l=o?o.split(",").map(r=>parseInt(r,10)):null;if(!l){const r=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),s=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(s&&s>-1&&r&&r[s]){const i=r[s].getAttribute("width");return i?[parseInt(i,10)]:null}}return l}},align:ke()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",b.mergeAttributes(this.options.HTMLAttributes,t),0]}}),He=b.Node3.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}},align:ke()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",b.mergeAttributes(this.options.HTMLAttributes,t),0]}}),_e=b.Node3.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",b.mergeAttributes(this.options.HTMLAttributes,t),0]}});function oe(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function be(t,e,n,o,l,r){var s;let i=0,c=!0,a=e.firstChild;const d=t.firstChild;if(d!==null)for(let f=0,h=0;f<d.childCount;f+=1){const{colspan:p,colwidth:g}=d.child(f).attrs;for(let w=0;w<p;w+=1,h+=1){const m=l===h?r:g&&g[w],S=m?`${m}px`:"";if(i+=m||o,m||(c=!1),a){if(a.style.width!==S){const[x,L]=oe(o,m);a.style.setProperty(x,L)}a=a.nextSibling}else{const x=document.createElement("col"),[L,M]=oe(o,m);x.style.setProperty(L,M),e.appendChild(x)}}}for(;a;){const f=a.nextSibling;(s=a.parentNode)==null||s.removeChild(a),a=f}const u=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);c&&!u?(n.style.width=`${i}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${i}px`)}var Bt=class{constructor(t,e,n,o={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(const[l,r]of Object.entries(o))r!=null&&(l==="style"?this.table.style.cssText=String(r):this.table.setAttribute(l,String(r)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),be(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,be(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),o=this.contentDOM.contains(e);return!!(n&&!o&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function $t(t,e,n,o){let l=0,r=!0;const s=[],i=t.firstChild;if(!i)return{};for(let u=0,f=0;u<i.childCount;u+=1){const{colspan:h,colwidth:p}=i.child(u).attrs;for(let g=0;g<h;g+=1,f+=1){const w=n===f?o:p&&p[g];l+=w||e,w||(r=!1);const[m,S]=oe(e,w);s.push(["col",{style:`${m}: ${S}`}])}}const c=r?`${l}px`:"",a=r?"":`${l}px`;return{colgroup:["colgroup",{},...s],tableWidth:c,tableMinWidth:a}}function we(t,e){return t.createAndFill()}function Wt(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 Ft(t,e,n,o,l){const r=Wt(t),s=[],i=[];for(let a=0;a<n;a+=1){const d=we(r.cell);if(d&&i.push(d),o){const u=we(r.header_cell);u&&s.push(u)}}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 Pt(t){return t instanceof C}var V=({editor:t})=>{const{selection:e}=t.state;if(!Pt(e))return!1;let n=0;const o=b.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},jt="";function Ot(t){return(t||"").replace(/\s+/g," ").trim()}function Vt(t,e,n={}){var o;const l=(o=n.cellLineSeparator)!=null?o:jt;if(!t||!t.content||t.content.length===0)return"";const r=[];t.content.forEach(g=>{const w=[];g.content&&g.content.forEach(m=>{let S="";m.content&&Array.isArray(m.content)&&m.content.length>1?S=m.content.map(H=>e.renderChildren(H)).join(l):S=m.content?e.renderChildren(m.content):"";const x=Ot(S),L=m.type==="tableHeader",M=It(m.attrs);w.push({text:x,isHeader:L,align:M})}),r.push(w)});const s=r.reduce((g,w)=>Math.max(g,w.length),0);if(s===0)return"";const i=Array.from({length:s}).fill(0);r.forEach(g=>{var w;for(let m=0;m<s;m+=1){const x=(((w=g[m])==null?void 0:w.text)||"").length;x>i[m]&&(i[m]=x),i[m]<3&&(i[m]=3)}});const c=(g,w)=>g+" ".repeat(Math.max(0,w-g.length)),a=r[0],d=a.some(g=>g.isHeader),u=Array.from({length:s}).fill(null);r.forEach(g=>{var w;for(let m=0;m<s;m+=1)!u[m]&&((w=g[m])!=null&&w.align)&&(u[m]=g[m].align)});let f=`
2
+ `;const h=Array.from({length:s}).map((g,w)=>d&&a[w]&&a[w].text||"");return f+=`| ${h.map((g,w)=>c(g,i[w])).join(" | ")} |
3
+ `,f+=`| ${i.map((g,w)=>{const m=Math.max(3,g),S=u[w];return S==="left"?`:${"-".repeat(m)}`:S==="right"?`${"-".repeat(m)}:`:S==="center"?`:${"-".repeat(m)}:`:"-".repeat(m)}).join(" | ")} |
4
+ `,(d?r.slice(1):r).forEach(g=>{f+=`| ${Array.from({length:s}).fill(0).map((w,m)=>c(g[m]&&g[m].text||"",i[m])).join(" | ")} |
5
+ `}),f}var Gt=Vt,De=b.Node3.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Bt,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}=$t(t,this.options.cellMinWidth),r=e.style;function s(){return r||(o?`width: ${o}`:`min-width: ${l}`)}const i=["table",b.mergeAttributes(this.options.HTMLAttributes,e,{style:s()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},parseMarkdown:(t,e)=>{const n=[],o=Array.isArray(t.align)?t.align:[];if(t.header){const l=[];t.header.forEach((r,s)=>{var i;const c=q((i=o[s])!=null?i:r.align),a=c?{align:c}:{};l.push(e.createNode("tableHeader",a,[{type:"paragraph",content:e.parseInline(r.tokens)}]))}),n.push(e.createNode("tableRow",{},l))}return t.rows&&t.rows.forEach(l=>{const r=[];l.forEach((s,i)=>{var c;const a=q((c=o[i])!=null?c:s.align),d=a?{align:a}:{};r.push(e.createNode("tableCell",d,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>Gt(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:o,dispatch:l,editor:r})=>{const s=Ft(r.schema,t,e,n);if(l){const i=o.selection.from+1;o.replaceSelectionWith(s).scrollIntoView().setSelection(Be.TextSelection.near(o.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Qe(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>et(t,e),deleteColumn:()=>({state:t,dispatch:e})=>nt(t,e),addRowBefore:()=>({state:t,dispatch:e})=>lt(t,e),addRowAfter:()=>({state:t,dispatch:e})=>rt(t,e),deleteRow:()=>({state:t,dispatch:e})=>it(t,e),deleteTable:()=>({state:t,dispatch:e})=>pt(t,e),mergeCells:()=>({state:t,dispatch:e})=>se(t,e),splitCell:()=>({state:t,dispatch:e})=>ie(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>$("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>$("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>ft(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>se(t,e)?!0:ie(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:o})=>dt(t,e)(n,o),goToNextCell:()=>({state:t,dispatch:e})=>ae(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>ae(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&ve(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const o=C.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:V,"Mod-Backspace":V,Delete:V,"Mod-Delete":V}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Tt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],_t({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:n,view:o,HTMLAttributes:l})=>{const r=b.mergeAttributes(this.options.HTMLAttributes,l);return new e(n,this.options.cellMinWidth,o,r)}},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:b.callOrReturn(b.getExtensionField(t,"tableRole",e))}}});b.Extension.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(De.configure(this.options.table)),this.options.tableCell!==!1&&t.push(ze.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(He.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(_e.configure(this.options.tableRow)),t}});function Kt(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 qt(t,e,n){const{doc:o,selection:l}=t;return!o||!l||!(l instanceof C)||l.forEachCell((r,s)=>{t=Kt(t,s,n)}),t}function Ce(t,e){return({tr:n,state:o,dispatch:l})=>{const{selection:r}=o;return n=n.setSelection(r),n=qt(n,e,t),n.docChanged?(l==null||l(n),!0):!1}}const Xt=b.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=>Ce(t,this.options),unsetTableCellBackground:()=>Ce("",this.options)}}}),Zt=/(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,Ut=/CrOS/,Jt=/android|ipad|playbook|silk/i;function ye(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:!!(Zt.test(e)&&!Ut.test(e)||t.tablet&&Jt.test(e)||t.tablet&&t.featureDetect&&navigator&&navigator.maxTouchPoints>1&&e.includes("Macintosh")&&e.includes("Safari"))}const Se=t=>Array.from({length:t}).map((e,n)=>n+1);function Yt(t){var f;const[e,n]=F.useState(!1),[o,l]=F.useState(!0),[r,s]=F.useState({rows:ye()?v.TABLE_MAX_GRID_SIZE:v.TABLE_INIT_GRID_SIZE,cols:ye()?v.TABLE_MAX_GRID_SIZE:v.TABLE_INIT_GRID_SIZE}),[i,c]=F.useState({rows:v.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:v.TABLE_DEFAULT_SELECTED_GRID_SIZE});function a(h,p){h===r.rows&&s(g=>({...g,rows:Math.min(h+1,v.TABLE_MAX_GRID_SIZE)})),p===r.cols&&s(g=>({...g,cols:Math.min(p+1,v.TABLE_MAX_GRID_SIZE)})),c({rows:h,cols:p})}function d(h,p){t==null||t.createTable({rows:h,cols:p,withHeaderRow:o}),u(),n(!1)}function u(){l(!1),s({rows:v.TABLE_INIT_GRID_SIZE,cols:v.TABLE_INIT_GRID_SIZE}),c({rows:v.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:v.TABLE_DEFAULT_SELECTED_GRID_SIZE})}return T.jsxs(U.Popover,{modal:!0,onOpenChange:n,open:e,children:[T.jsx(U.PopoverTrigger,{asChild:!0,"data-state":t!=null&&t.dataState?"on":"off",children:t==null?void 0:t.children}),T.jsx(U.PopoverContent,{align:"start",className:"richtext-w-full !richtext-p-2",side:"bottom",children:T.jsxs("div",{className:"table-grid-size-editor richtext-p-0",children:[T.jsx("div",{className:"richtext-flex richtext-flex-col richtext-flex-wrap richtext-justify-between richtext-gap-1",children:(f=Se(r==null?void 0:r.rows))==null?void 0:f.map(h=>{var p;return T.jsx("div",{className:"richtext-flex richtext-gap-1",children:(p=Se(r==null?void 0:r.cols))==null?void 0:p.map(g=>T.jsx("div",{onMouseDown:()=>d(h,g),onMouseOver:()=>a(h,g),className:`richtext-cursor-pointer richtext-border-border ${g<=i.cols&&h<=i.rows&&"tableCellActive !richtext-bg-foreground"}`,children:T.jsx("div",{className:"richtext-box-border richtext-size-4 richtext-rounded-[2px] !richtext-border richtext-border-solid !richtext-border-border richtext-p-1"})},`richtext-table-col-${g}`))},`richtext-table-row-${h}`)})}),T.jsxs("div",{className:"richtext-mt-2 richtext-text-center richtext-text-sm richtext-text-foreground",children:[i.rows,"x",i.cols]})]})})]})}function Qt(){const t=W.useEditorInstance(),e=W.useButtonProps(Ie.name),{icon:n=void 0,tooltip:o=void 0,action:l=void 0,isActive:r=void 0,color:s}=(e==null?void 0:e.componentProps)??{},{dataState:i,disabled:c}=W.useToggleActive(r);if(!e)return T.jsx(T.Fragment,{});function a(d){t.chain().focus().insertTable({...d,withHeaderRow:!1}).run()}return T.jsx(Yt,{createTable:a,dataState:i,children:T.jsx(W.ActionButton,{action:l,color:s,dataState:i,icon:n,isActive:r,tooltip:o,disabled:c})})}const Ie=De.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),HTMLAttributes:{style:`
6
6
  border: 1px solid #000;
7
7
  border-collapse: collapse;
8
8
  width: 100%;