@dooherceg/tiptap-controlled-editor-with-table 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/README.md +63 -0
  2. package/dist/Combination-CO0ZtURs.js +1333 -0
  3. package/dist/assets/badge.css +1 -0
  4. package/dist/assets/button.css +1 -0
  5. package/dist/assets/card.css +1 -0
  6. package/dist/assets/color-highlight-button.css +1 -0
  7. package/dist/assets/dropdown-menu.css +1 -0
  8. package/dist/assets/image-upload-node.css +1 -0
  9. package/dist/assets/input.css +1 -0
  10. package/dist/assets/popover.css +1 -0
  11. package/dist/assets/separator.css +1 -0
  12. package/dist/assets/simple-editor.css +1 -0
  13. package/dist/assets/toolbar.css +1 -0
  14. package/dist/assets/tooltip.css +1 -0
  15. package/dist/components/tiptap-icons/add-table-column-after-icon.d.ts +1 -0
  16. package/dist/components/tiptap-icons/add-table-column-after-icon.js +26 -0
  17. package/dist/components/tiptap-icons/add-table-column-before-icon.d.ts +1 -0
  18. package/dist/components/tiptap-icons/add-table-column-before-icon.js +26 -0
  19. package/dist/components/tiptap-icons/add-table-row-after-icon.d.ts +1 -0
  20. package/dist/components/tiptap-icons/add-table-row-after-icon.js +26 -0
  21. package/dist/components/tiptap-icons/add-table-row-before-icon.d.ts +1 -0
  22. package/dist/components/tiptap-icons/add-table-row-before-icon.js +26 -0
  23. package/dist/components/tiptap-icons/align-center-icon.d.ts +3 -0
  24. package/dist/components/tiptap-icons/align-center-icon.js +47 -0
  25. package/dist/components/tiptap-icons/align-justify-icon.d.ts +3 -0
  26. package/dist/components/tiptap-icons/align-justify-icon.js +47 -0
  27. package/dist/components/tiptap-icons/align-left-icon.d.ts +1 -0
  28. package/dist/components/tiptap-icons/align-left-icon.js +49 -0
  29. package/dist/components/tiptap-icons/align-right-icon.d.ts +1 -0
  30. package/dist/components/tiptap-icons/align-right-icon.js +49 -0
  31. package/dist/components/tiptap-icons/arrow-left-icon.d.ts +1 -0
  32. package/dist/components/tiptap-icons/arrow-left-icon.js +27 -0
  33. package/dist/components/tiptap-icons/ban-icon.d.ts +1 -0
  34. package/dist/components/tiptap-icons/ban-icon.js +29 -0
  35. package/dist/components/tiptap-icons/blockquote-icon.d.ts +1 -0
  36. package/dist/components/tiptap-icons/blockquote-icon.js +58 -0
  37. package/dist/components/tiptap-icons/bold-icon.d.ts +1 -0
  38. package/dist/components/tiptap-icons/bold-icon.js +29 -0
  39. package/dist/components/tiptap-icons/chevron-down-icon.d.ts +3 -0
  40. package/dist/components/tiptap-icons/chevron-down-icon.js +27 -0
  41. package/dist/components/tiptap-icons/close-icon.d.ts +1 -0
  42. package/dist/components/tiptap-icons/close-icon.js +27 -0
  43. package/dist/components/tiptap-icons/code-block-icon.d.ts +1 -0
  44. package/dist/components/tiptap-icons/code-block-icon.js +49 -0
  45. package/dist/components/tiptap-icons/code2-icon.d.ts +1 -0
  46. package/dist/components/tiptap-icons/code2-icon.js +43 -0
  47. package/dist/components/tiptap-icons/corner-down-left-icon.d.ts +1 -0
  48. package/dist/components/tiptap-icons/corner-down-left-icon.js +29 -0
  49. package/dist/components/tiptap-icons/delete-table-column-icon.d.ts +1 -0
  50. package/dist/components/tiptap-icons/delete-table-column-icon.js +26 -0
  51. package/dist/components/tiptap-icons/delete-table-row-icon.d.ts +1 -0
  52. package/dist/components/tiptap-icons/delete-table-row-icon.js +33 -0
  53. package/dist/components/tiptap-icons/external-link-icon.d.ts +1 -0
  54. package/dist/components/tiptap-icons/external-link-icon.js +36 -0
  55. package/dist/components/tiptap-icons/heading-five-icon.d.ts +1 -0
  56. package/dist/components/tiptap-icons/heading-five-icon.js +36 -0
  57. package/dist/components/tiptap-icons/heading-four-icon.d.ts +1 -0
  58. package/dist/components/tiptap-icons/heading-four-icon.js +36 -0
  59. package/dist/components/tiptap-icons/heading-icon.d.ts +1 -0
  60. package/dist/components/tiptap-icons/heading-icon.js +27 -0
  61. package/dist/components/tiptap-icons/heading-one-icon.d.ts +1 -0
  62. package/dist/components/tiptap-icons/heading-one-icon.js +36 -0
  63. package/dist/components/tiptap-icons/heading-six-icon.d.ts +1 -0
  64. package/dist/components/tiptap-icons/heading-six-icon.js +38 -0
  65. package/dist/components/tiptap-icons/heading-three-icon.d.ts +1 -0
  66. package/dist/components/tiptap-icons/heading-three-icon.js +47 -0
  67. package/dist/components/tiptap-icons/heading-two-icon.d.ts +1 -0
  68. package/dist/components/tiptap-icons/heading-two-icon.js +36 -0
  69. package/dist/components/tiptap-icons/highlighter-icon.d.ts +1 -0
  70. package/dist/components/tiptap-icons/highlighter-icon.js +29 -0
  71. package/dist/components/tiptap-icons/image-plus-icon.d.ts +1 -0
  72. package/dist/components/tiptap-icons/image-plus-icon.js +29 -0
  73. package/dist/components/tiptap-icons/italic-icon.d.ts +1 -0
  74. package/dist/components/tiptap-icons/italic-icon.js +27 -0
  75. package/dist/components/tiptap-icons/link-icon.d.ts +1 -0
  76. package/dist/components/tiptap-icons/link-icon.js +36 -0
  77. package/dist/components/tiptap-icons/list-icon.d.ts +1 -0
  78. package/dist/components/tiptap-icons/list-icon.js +76 -0
  79. package/dist/components/tiptap-icons/list-ordered-icon.d.ts +1 -0
  80. package/dist/components/tiptap-icons/list-ordered-icon.js +76 -0
  81. package/dist/components/tiptap-icons/list-todo-icon.d.ts +1 -0
  82. package/dist/components/tiptap-icons/list-todo-icon.js +67 -0
  83. package/dist/components/tiptap-icons/merge-table-cells-icon.d.ts +1 -0
  84. package/dist/components/tiptap-icons/merge-table-cells-icon.js +26 -0
  85. package/dist/components/tiptap-icons/moon-star-icon.d.ts +1 -0
  86. package/dist/components/tiptap-icons/moon-star-icon.js +38 -0
  87. package/dist/components/tiptap-icons/redo2-icon.d.ts +1 -0
  88. package/dist/components/tiptap-icons/redo2-icon.js +29 -0
  89. package/dist/components/tiptap-icons/remove-table-icon.d.ts +1 -0
  90. package/dist/components/tiptap-icons/remove-table-icon.js +26 -0
  91. package/dist/components/tiptap-icons/split-table-cells-icon copy.d.ts +1 -0
  92. package/dist/components/tiptap-icons/split-table-cells-icon copy.js +30 -0
  93. package/dist/components/tiptap-icons/strike-icon.d.ts +1 -0
  94. package/dist/components/tiptap-icons/strike-icon.js +36 -0
  95. package/dist/components/tiptap-icons/subscript-icon.d.ts +1 -0
  96. package/dist/components/tiptap-icons/subscript-icon.js +49 -0
  97. package/dist/components/tiptap-icons/sun-icon.d.ts +1 -0
  98. package/dist/components/tiptap-icons/sun-icon.js +87 -0
  99. package/dist/components/tiptap-icons/superscript-icon.d.ts +1 -0
  100. package/dist/components/tiptap-icons/superscript-icon.js +49 -0
  101. package/dist/components/tiptap-icons/table-icon.d.ts +3 -0
  102. package/dist/components/tiptap-icons/table-icon.js +24 -0
  103. package/dist/components/tiptap-icons/trash-icon.d.ts +1 -0
  104. package/dist/components/tiptap-icons/trash-icon.js +29 -0
  105. package/dist/components/tiptap-icons/underline-icon.d.ts +1 -0
  106. package/dist/components/tiptap-icons/underline-icon.js +29 -0
  107. package/dist/components/tiptap-icons/undo2-icon.d.ts +1 -0
  108. package/dist/components/tiptap-icons/undo2-icon.js +29 -0
  109. package/dist/components/tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.d.ts +2 -0
  110. package/dist/components/tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.js +67 -0
  111. package/dist/components/tiptap-node/image-upload-node/image-upload-node-extension.d.ts +58 -0
  112. package/dist/components/tiptap-node/image-upload-node/image-upload-node-extension.js +77 -0
  113. package/dist/components/tiptap-node/image-upload-node/image-upload-node.d.ts +68 -0
  114. package/dist/components/tiptap-node/image-upload-node/image-upload-node.js +329 -0
  115. package/dist/components/tiptap-node/image-upload-node/index.d.ts +1 -0
  116. package/dist/components/tiptap-node/image-upload-node/index.js +4 -0
  117. package/dist/components/tiptap-templates/simple/simple-editor.d.ts +8 -0
  118. package/dist/components/tiptap-templates/simple/simple-editor.js +1956 -0
  119. package/dist/components/tiptap-templates/simple/theme-toggle.d.ts +1 -0
  120. package/dist/components/tiptap-templates/simple/theme-toggle.js +28 -0
  121. package/dist/components/tiptap-ui/blockquote-button/blockquote-button.d.ts +22 -0
  122. package/dist/components/tiptap-ui/blockquote-button/blockquote-button.js +71 -0
  123. package/dist/components/tiptap-ui/blockquote-button/index.d.ts +2 -0
  124. package/dist/components/tiptap-ui/blockquote-button/index.js +11 -0
  125. package/dist/components/tiptap-ui/blockquote-button/use-blockquote.d.ts +80 -0
  126. package/dist/components/tiptap-ui/blockquote-button/use-blockquote.js +82 -0
  127. package/dist/components/tiptap-ui/code-block-button/code-block-button.d.ts +22 -0
  128. package/dist/components/tiptap-ui/code-block-button/code-block-button.js +71 -0
  129. package/dist/components/tiptap-ui/code-block-button/index.d.ts +2 -0
  130. package/dist/components/tiptap-ui/code-block-button/index.js +11 -0
  131. package/dist/components/tiptap-ui/code-block-button/use-code-block.d.ts +87 -0
  132. package/dist/components/tiptap-ui/code-block-button/use-code-block.js +83 -0
  133. package/dist/components/tiptap-ui/color-highlight-button/color-highlight-button.d.ts +45 -0
  134. package/dist/components/tiptap-ui/color-highlight-button/color-highlight-button.js +89 -0
  135. package/dist/components/tiptap-ui/color-highlight-button/index.d.ts +2 -0
  136. package/dist/components/tiptap-ui/color-highlight-button/index.js +14 -0
  137. package/dist/components/tiptap-ui/color-highlight-button/use-color-highlight.d.ts +82 -0
  138. package/dist/components/tiptap-ui/color-highlight-button/use-color-highlight.js +176 -0
  139. package/dist/components/tiptap-ui/color-highlight-popover/color-highlight-popover.d.ts +25 -0
  140. package/dist/components/tiptap-ui/color-highlight-popover/color-highlight-popover.js +136 -0
  141. package/dist/components/tiptap-ui/color-highlight-popover/index.d.ts +1 -0
  142. package/dist/components/tiptap-ui/color-highlight-popover/index.js +6 -0
  143. package/dist/components/tiptap-ui/heading-button/heading-button.d.ts +23 -0
  144. package/dist/components/tiptap-ui/heading-button/heading-button.js +74 -0
  145. package/dist/components/tiptap-ui/heading-button/index.d.ts +2 -0
  146. package/dist/components/tiptap-ui/heading-button/index.js +13 -0
  147. package/dist/components/tiptap-ui/heading-button/use-heading.d.ts +108 -0
  148. package/dist/components/tiptap-ui/heading-button/use-heading.js +112 -0
  149. package/dist/components/tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.d.ts +20 -0
  150. package/dist/components/tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.js +67 -0
  151. package/dist/components/tiptap-ui/heading-dropdown-menu/index.d.ts +2 -0
  152. package/dist/components/tiptap-ui/heading-dropdown-menu/index.js +7 -0
  153. package/dist/components/tiptap-ui/heading-dropdown-menu/use-heading-dropdown-menu.d.ts +73 -0
  154. package/dist/components/tiptap-ui/heading-dropdown-menu/use-heading-dropdown-menu.js +38 -0
  155. package/dist/components/tiptap-ui/image-upload-button/image-upload-button.d.ts +29 -0
  156. package/dist/components/tiptap-ui/image-upload-button/image-upload-button.js +72 -0
  157. package/dist/components/tiptap-ui/image-upload-button/index.d.ts +2 -0
  158. package/dist/components/tiptap-ui/image-upload-button/index.js +12 -0
  159. package/dist/components/tiptap-ui/image-upload-button/use-image-upload.d.ts +84 -0
  160. package/dist/components/tiptap-ui/image-upload-button/use-image-upload.js +76 -0
  161. package/dist/components/tiptap-ui/insert-table-button/insert-table-button.d.ts +4 -0
  162. package/dist/components/tiptap-ui/insert-table-button/insert-table-button.js +41 -0
  163. package/dist/components/tiptap-ui/link-popover/index.d.ts +2 -0
  164. package/dist/components/tiptap-ui/link-popover/index.js +13 -0
  165. package/dist/components/tiptap-ui/link-popover/link-popover.d.ts +57 -0
  166. package/dist/components/tiptap-ui/link-popover/link-popover.js +193 -0
  167. package/dist/components/tiptap-ui/link-popover/use-link-popover.d.ts +117 -0
  168. package/dist/components/tiptap-ui/link-popover/use-link-popover.js +103 -0
  169. package/dist/components/tiptap-ui/list-button/index.d.ts +2 -0
  170. package/dist/components/tiptap-ui/list-button/index.js +14 -0
  171. package/dist/components/tiptap-ui/list-button/list-button.d.ts +23 -0
  172. package/dist/components/tiptap-ui/list-button/list-button.js +74 -0
  173. package/dist/components/tiptap-ui/list-button/use-list.d.ts +97 -0
  174. package/dist/components/tiptap-ui/list-button/use-list.js +149 -0
  175. package/dist/components/tiptap-ui/list-dropdown-menu/index.d.ts +1 -0
  176. package/dist/components/tiptap-ui/list-dropdown-menu/index.js +4 -0
  177. package/dist/components/tiptap-ui/list-dropdown-menu/list-dropdown-menu.d.ts +29 -0
  178. package/dist/components/tiptap-ui/list-dropdown-menu/list-dropdown-menu.js +63 -0
  179. package/dist/components/tiptap-ui/list-dropdown-menu/use-list-dropdown-menu.d.ts +90 -0
  180. package/dist/components/tiptap-ui/list-dropdown-menu/use-list-dropdown-menu.js +84 -0
  181. package/dist/components/tiptap-ui/mark-button/index.d.ts +2 -0
  182. package/dist/components/tiptap-ui/mark-button/index.js +14 -0
  183. package/dist/components/tiptap-ui/mark-button/mark-button.d.ts +23 -0
  184. package/dist/components/tiptap-ui/mark-button/mark-button.js +74 -0
  185. package/dist/components/tiptap-ui/mark-button/use-mark.d.ts +104 -0
  186. package/dist/components/tiptap-ui/mark-button/use-mark.js +84 -0
  187. package/dist/components/tiptap-ui/table-actions-toolbar/add-column-after-button.d.ts +4 -0
  188. package/dist/components/tiptap-ui/table-actions-toolbar/add-column-after-button.js +7 -0
  189. package/dist/components/tiptap-ui/table-actions-toolbar/add-column-before-button.d.ts +4 -0
  190. package/dist/components/tiptap-ui/table-actions-toolbar/add-column-before-button.js +7 -0
  191. package/dist/components/tiptap-ui/table-actions-toolbar/add-row-after-button.d.ts +4 -0
  192. package/dist/components/tiptap-ui/table-actions-toolbar/add-row-after-button.js +7 -0
  193. package/dist/components/tiptap-ui/table-actions-toolbar/add-row-before-button.d.ts +4 -0
  194. package/dist/components/tiptap-ui/table-actions-toolbar/add-row-before-button.js +7 -0
  195. package/dist/components/tiptap-ui/table-actions-toolbar/delete-column-button.d.ts +4 -0
  196. package/dist/components/tiptap-ui/table-actions-toolbar/delete-column-button.js +7 -0
  197. package/dist/components/tiptap-ui/table-actions-toolbar/delete-row-button.d.ts +4 -0
  198. package/dist/components/tiptap-ui/table-actions-toolbar/delete-row-button.js +7 -0
  199. package/dist/components/tiptap-ui/table-actions-toolbar/get-table-node-and-pos.d.ts +6 -0
  200. package/dist/components/tiptap-ui/table-actions-toolbar/get-table-node-and-pos.js +15 -0
  201. package/dist/components/tiptap-ui/table-actions-toolbar/merge-cells-button.d.ts +4 -0
  202. package/dist/components/tiptap-ui/table-actions-toolbar/merge-cells-button.js +7 -0
  203. package/dist/components/tiptap-ui/table-actions-toolbar/remove-table-button.d.ts +4 -0
  204. package/dist/components/tiptap-ui/table-actions-toolbar/remove-table-button.js +7 -0
  205. package/dist/components/tiptap-ui/table-actions-toolbar/split-table-cells-button.d.ts +4 -0
  206. package/dist/components/tiptap-ui/table-actions-toolbar/split-table-cells-button.js +7 -0
  207. package/dist/components/tiptap-ui/table-actions-toolbar/table-actions-toolbar.d.ts +2 -0
  208. package/dist/components/tiptap-ui/table-actions-toolbar/table-actions-toolbar.js +75 -0
  209. package/dist/components/tiptap-ui/text-align-button/index.d.ts +2 -0
  210. package/dist/components/tiptap-ui/text-align-button/index.js +15 -0
  211. package/dist/components/tiptap-ui/text-align-button/text-align-button.d.ts +30 -0
  212. package/dist/components/tiptap-ui/text-align-button/text-align-button.js +81 -0
  213. package/dist/components/tiptap-ui/text-align-button/use-text-align.d.ts +101 -0
  214. package/dist/components/tiptap-ui/text-align-button/use-text-align.js +84 -0
  215. package/dist/components/tiptap-ui/undo-redo-button/index.d.ts +2 -0
  216. package/dist/components/tiptap-ui/undo-redo-button/index.js +13 -0
  217. package/dist/components/tiptap-ui/undo-redo-button/undo-redo-button.d.ts +23 -0
  218. package/dist/components/tiptap-ui/undo-redo-button/undo-redo-button.js +70 -0
  219. package/dist/components/tiptap-ui/undo-redo-button/use-undo-redo.d.ts +90 -0
  220. package/dist/components/tiptap-ui/undo-redo-button/use-undo-redo.js +67 -0
  221. package/dist/components/tiptap-ui-primitive/badge/badge.d.ts +8 -0
  222. package/dist/components/tiptap-ui-primitive/badge/badge.js +30 -0
  223. package/dist/components/tiptap-ui-primitive/badge/index.d.ts +1 -0
  224. package/dist/components/tiptap-ui-primitive/badge/index.js +4 -0
  225. package/dist/components/tiptap-ui-primitive/button/button.d.ts +14 -0
  226. package/dist/components/tiptap-ui-primitive/button/button.js +69 -0
  227. package/dist/components/tiptap-ui-primitive/button/index.d.ts +1 -0
  228. package/dist/components/tiptap-ui-primitive/button/index.js +6 -0
  229. package/dist/components/tiptap-ui-primitive/card/card.d.ts +9 -0
  230. package/dist/components/tiptap-ui-primitive/card/card.js +62 -0
  231. package/dist/components/tiptap-ui-primitive/card/index.d.ts +1 -0
  232. package/dist/components/tiptap-ui-primitive/card/index.js +9 -0
  233. package/dist/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.d.ts +16 -0
  234. package/dist/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.js +1028 -0
  235. package/dist/components/tiptap-ui-primitive/dropdown-menu/index.d.ts +1 -0
  236. package/dist/components/tiptap-ui-primitive/dropdown-menu/index.js +13 -0
  237. package/dist/components/tiptap-ui-primitive/input/index.d.ts +1 -0
  238. package/dist/components/tiptap-ui-primitive/input/index.js +5 -0
  239. package/dist/components/tiptap-ui-primitive/input/input.d.ts +3 -0
  240. package/dist/components/tiptap-ui-primitive/input/input.js +16 -0
  241. package/dist/components/tiptap-ui-primitive/popover/index.d.ts +1 -0
  242. package/dist/components/tiptap-ui-primitive/popover/index.js +6 -0
  243. package/dist/components/tiptap-ui-primitive/popover/popover.d.ts +5 -0
  244. package/dist/components/tiptap-ui-primitive/popover/popover.js +244 -0
  245. package/dist/components/tiptap-ui-primitive/separator/index.d.ts +1 -0
  246. package/dist/components/tiptap-ui-primitive/separator/index.js +4 -0
  247. package/dist/components/tiptap-ui-primitive/separator/separator.d.ts +6 -0
  248. package/dist/components/tiptap-ui-primitive/separator/separator.js +22 -0
  249. package/dist/components/tiptap-ui-primitive/spacer/index.d.ts +1 -0
  250. package/dist/components/tiptap-ui-primitive/spacer/index.js +4 -0
  251. package/dist/components/tiptap-ui-primitive/spacer/spacer.d.ts +6 -0
  252. package/dist/components/tiptap-ui-primitive/spacer/spacer.js +20 -0
  253. package/dist/components/tiptap-ui-primitive/toolbar/index.d.ts +1 -0
  254. package/dist/components/tiptap-ui-primitive/toolbar/index.js +6 -0
  255. package/dist/components/tiptap-ui-primitive/toolbar/toolbar.d.ts +8 -0
  256. package/dist/components/tiptap-ui-primitive/toolbar/toolbar.js +83 -0
  257. package/dist/components/tiptap-ui-primitive/tooltip/index.d.ts +1 -0
  258. package/dist/components/tiptap-ui-primitive/tooltip/index.js +6 -0
  259. package/dist/components/tiptap-ui-primitive/tooltip/tooltip.d.ts +28 -0
  260. package/dist/components/tiptap-ui-primitive/tooltip/tooltip.js +1374 -0
  261. package/dist/floating-ui.react-dom-DgOuULHo.js +1334 -0
  262. package/dist/hooks/use-composed-ref.d.ts +3 -0
  263. package/dist/hooks/use-composed-ref.js +16 -0
  264. package/dist/hooks/use-cursor-visibility.d.ts +20 -0
  265. package/dist/hooks/use-cursor-visibility.js +31 -0
  266. package/dist/hooks/use-element-rect.d.ts +35 -0
  267. package/dist/hooks/use-element-rect.js +79 -0
  268. package/dist/hooks/use-menu-navigation.d.ts +52 -0
  269. package/dist/hooks/use-menu-navigation.js +68 -0
  270. package/dist/hooks/use-mobile.d.ts +1 -0
  271. package/dist/hooks/use-mobile.js +13 -0
  272. package/dist/hooks/use-scrolling.d.ts +8 -0
  273. package/dist/hooks/use-scrolling.js +17 -0
  274. package/dist/hooks/use-throttled-callback.d.ts +18 -0
  275. package/dist/hooks/use-throttled-callback.js +116 -0
  276. package/dist/hooks/use-tiptap-editor.d.ts +17 -0
  277. package/dist/hooks/use-tiptap-editor.js +25 -0
  278. package/dist/hooks/use-unmount.d.ts +7 -0
  279. package/dist/hooks/use-unmount.js +14 -0
  280. package/dist/hooks/use-window-size.d.ts +35 -0
  281. package/dist/hooks/use-window-size.js +33 -0
  282. package/dist/index-Bqw9S4qP.js +238 -0
  283. package/dist/lib/tiptap-utils.d.ts +160 -0
  284. package/dist/lib/tiptap-utils.js +229 -0
  285. package/dist/main.d.ts +1 -0
  286. package/dist/main.js +4 -0
  287. package/package.json +67 -0
@@ -0,0 +1,1956 @@
1
+ import { jsx as p, jsxs as w, Fragment as at } from "react/jsx-runtime";
2
+ import { useEditor as Ct, EditorContext as Lt, EditorContent as wt } from "@tiptap/react";
3
+ import { useState as vt, useRef as q, useEffect as D } from "react";
4
+ import { Mark as Q, markPasteRule as Mt, markInputRule as xt, mergeAttributes as k, Node as L, nodeInputRule as At, ResizableNodeView as It, wrappingInputRule as S, renderNestedMarkdownContent as lt, Extension as C, parseIndentedBlocks as F, isNodeActive as _, isAtStartOfNode as St, isAtEndOfNode as Ht, getNodeType as ut, getNodeAtPosition as Et, textInputRule as y, callOrReturn as dt, getExtensionField as ct, isNodeEmpty as $t, isNodeSelection as Nt, findParentNodeClosestToPos as Rt } from "@tiptap/core";
5
+ import { Plugin as H, PluginKey as E, TextSelection as Pt } from "prosemirror-state";
6
+ import { dropCursor as Bt } from "prosemirror-dropcursor";
7
+ import { DecorationSet as B, Decoration as K } from "prosemirror-view";
8
+ import { gapCursor as Ot } from "prosemirror-gapcursor";
9
+ import { history as Dt, redo as _t, undo as zt } from "prosemirror-history";
10
+ import { StarterKit as Wt } from "@tiptap/starter-kit";
11
+ import { HorizontalRule as jt } from "../../tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.js";
12
+ import { ImageUploadNode as Qt } from "../../tiptap-node/image-upload-node/image-upload-node-extension.js";
13
+ import { ArrowLeftIcon as Kt } from "../../tiptap-icons/arrow-left-icon.js";
14
+ import { HighlighterIcon as Vt } from "../../tiptap-icons/highlighter-icon.js";
15
+ import { LinkIcon as qt } from "../../tiptap-icons/link-icon.js";
16
+ import { useCursorVisibility as Ft } from "../../../hooks/use-cursor-visibility.js";
17
+ import { useIsMobile as Ut } from "../../../hooks/use-mobile.js";
18
+ import { useWindowSize as Gt } from "../../../hooks/use-window-size.js";
19
+ import { handleImageUpload as Xt, MAX_FILE_SIZE as Yt } from "../../../lib/tiptap-utils.js";
20
+ import { InsertTableButton as Zt } from "../../tiptap-ui/insert-table-button/insert-table-button.js";
21
+ import Jt from "../../tiptap-ui/table-actions-toolbar/table-actions-toolbar.js";
22
+ import { useTiptapEditor as te } from "../../../hooks/use-tiptap-editor.js";
23
+ import { columnResizing as ee, tableEditing as re, CellSelection as pt, fixTables as ne, goToNextCell as U, setCellAttr as se, mergeCells as G, splitCell as X, toggleHeaderCell as ie, toggleHeader as Y, deleteTable as oe, deleteRow as ae, addRowAfter as le, addRowBefore as ue, deleteColumn as de, addColumnAfter as ce, addColumnBefore as pe } from "prosemirror-tables";
24
+ import { Toolbar as he, ToolbarGroup as x, ToolbarSeparator as A } from "../../tiptap-ui-primitive/toolbar/toolbar.js";
25
+ import { UndoRedoButton as Z } from "../../tiptap-ui/undo-redo-button/undo-redo-button.js";
26
+ import { HeadingDropdownMenu as fe } from "../../tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.js";
27
+ import { ListDropdownMenu as me } from "../../tiptap-ui/list-dropdown-menu/list-dropdown-menu.js";
28
+ import { BlockquoteButton as ge } from "../../tiptap-ui/blockquote-button/blockquote-button.js";
29
+ import { CodeBlockButton as be } from "../../tiptap-ui/code-block-button/code-block-button.js";
30
+ import { MarkButton as M } from "../../tiptap-ui/mark-button/mark-button.js";
31
+ import { ColorHighlightPopover as ye, ColorHighlightPopoverButton as ke, ColorHighlightPopoverContent as Te } from "../../tiptap-ui/color-highlight-popover/color-highlight-popover.js";
32
+ import { LinkPopover as Ce, LinkButton as Le, LinkContent as we } from "../../tiptap-ui/link-popover/link-popover.js";
33
+ import { TextAlignButton as R } from "../../tiptap-ui/text-align-button/text-align-button.js";
34
+ import { Button as ve } from "../../tiptap-ui-primitive/button/button.js";
35
+ import '../../../assets/simple-editor.css';var Me = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, xe = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g, Ae = Q.create({
36
+ name: "highlight",
37
+ addOptions() {
38
+ return {
39
+ multicolor: !1,
40
+ HTMLAttributes: {}
41
+ };
42
+ },
43
+ addAttributes() {
44
+ return this.options.multicolor ? {
45
+ color: {
46
+ default: null,
47
+ parseHTML: (t) => t.getAttribute("data-color") || t.style.backgroundColor,
48
+ renderHTML: (t) => t.color ? {
49
+ "data-color": t.color,
50
+ style: `background-color: ${t.color}; color: inherit`
51
+ } : {}
52
+ }
53
+ } : {};
54
+ },
55
+ parseHTML() {
56
+ return [
57
+ {
58
+ tag: "mark"
59
+ }
60
+ ];
61
+ },
62
+ renderHTML({ HTMLAttributes: t }) {
63
+ return ["mark", k(this.options.HTMLAttributes, t), 0];
64
+ },
65
+ renderMarkdown: (t, e) => `==${e.renderChildren(t)}==`,
66
+ parseMarkdown: (t, e) => e.applyMark("highlight", e.parseInline(t.tokens || [])),
67
+ markdownTokenizer: {
68
+ name: "highlight",
69
+ level: "inline",
70
+ start: (t) => t.indexOf("=="),
71
+ tokenize(t, e, r) {
72
+ const s = /^(==)([^=]+)(==)/.exec(t);
73
+ if (s) {
74
+ const i = s[2].trim(), a = r.inlineTokens(i);
75
+ return {
76
+ type: "highlight",
77
+ raw: s[0],
78
+ text: i,
79
+ tokens: a
80
+ };
81
+ }
82
+ }
83
+ },
84
+ addCommands() {
85
+ return {
86
+ setHighlight: (t) => ({ commands: e }) => e.setMark(this.name, t),
87
+ toggleHighlight: (t) => ({ commands: e }) => e.toggleMark(this.name, t),
88
+ unsetHighlight: () => ({ commands: t }) => t.unsetMark(this.name)
89
+ };
90
+ },
91
+ addKeyboardShortcuts() {
92
+ return {
93
+ "Mod-Shift-h": () => this.editor.commands.toggleHighlight()
94
+ };
95
+ },
96
+ addInputRules() {
97
+ return [
98
+ xt({
99
+ find: Me,
100
+ type: this.type
101
+ })
102
+ ];
103
+ },
104
+ addPasteRules() {
105
+ return [
106
+ Mt({
107
+ find: xe,
108
+ type: this.type
109
+ })
110
+ ];
111
+ }
112
+ }), Ie = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/, Se = L.create({
113
+ name: "image",
114
+ addOptions() {
115
+ return {
116
+ inline: !1,
117
+ allowBase64: !1,
118
+ HTMLAttributes: {},
119
+ resize: !1
120
+ };
121
+ },
122
+ inline() {
123
+ return this.options.inline;
124
+ },
125
+ group() {
126
+ return this.options.inline ? "inline" : "block";
127
+ },
128
+ draggable: !0,
129
+ addAttributes() {
130
+ return {
131
+ src: {
132
+ default: null
133
+ },
134
+ alt: {
135
+ default: null
136
+ },
137
+ title: {
138
+ default: null
139
+ },
140
+ width: {
141
+ default: null
142
+ },
143
+ height: {
144
+ default: null
145
+ }
146
+ };
147
+ },
148
+ parseHTML() {
149
+ return [
150
+ {
151
+ tag: this.options.allowBase64 ? "img[src]" : 'img[src]:not([src^="data:"])'
152
+ }
153
+ ];
154
+ },
155
+ renderHTML({ HTMLAttributes: t }) {
156
+ return ["img", k(this.options.HTMLAttributes, t)];
157
+ },
158
+ parseMarkdown: (t, e) => e.createNode("image", {
159
+ src: t.href,
160
+ title: t.title,
161
+ alt: t.text
162
+ }),
163
+ renderMarkdown: (t) => {
164
+ var e, r, n, s, i, a;
165
+ const o = (r = (e = t.attrs) == null ? void 0 : e.src) != null ? r : "", c = (s = (n = t.attrs) == null ? void 0 : n.alt) != null ? s : "", l = (a = (i = t.attrs) == null ? void 0 : i.title) != null ? a : "";
166
+ return l ? `![${c}](${o} "${l}")` : `![${c}](${o})`;
167
+ },
168
+ addNodeView() {
169
+ if (!this.options.resize || !this.options.resize.enabled || typeof document > "u" || !this.editor.isEditable)
170
+ return null;
171
+ const { directions: t, minWidth: e, minHeight: r, alwaysPreserveAspectRatio: n } = this.options.resize;
172
+ return ({ node: s, getPos: i, HTMLAttributes: a }) => {
173
+ const o = document.createElement("img");
174
+ Object.entries(a).forEach(([d, u]) => {
175
+ if (u != null)
176
+ switch (d) {
177
+ case "width":
178
+ case "height":
179
+ break;
180
+ default:
181
+ o.setAttribute(d, u);
182
+ break;
183
+ }
184
+ }), o.src = a.src;
185
+ const c = new It({
186
+ element: o,
187
+ node: s,
188
+ getPos: i,
189
+ onResize: (d, u) => {
190
+ o.style.width = `${d}px`, o.style.height = `${u}px`;
191
+ },
192
+ onCommit: (d, u) => {
193
+ const h = i();
194
+ h !== void 0 && this.editor.chain().setNodeSelection(h).updateAttributes(this.name, {
195
+ width: d,
196
+ height: u
197
+ }).run();
198
+ },
199
+ onUpdate: (d, u, h) => d.type === s.type,
200
+ options: {
201
+ directions: t,
202
+ min: {
203
+ width: e,
204
+ height: r
205
+ },
206
+ preserveAspectRatio: n === !0
207
+ }
208
+ }), l = c.dom;
209
+ return l.style.visibility = "hidden", l.style.pointerEvents = "none", o.onload = () => {
210
+ l.style.visibility = "", l.style.pointerEvents = "";
211
+ }, c;
212
+ };
213
+ },
214
+ addCommands() {
215
+ return {
216
+ setImage: (t) => ({ commands: e }) => e.insertContent({
217
+ type: this.name,
218
+ attrs: t
219
+ })
220
+ };
221
+ },
222
+ addInputRules() {
223
+ return [
224
+ At({
225
+ find: Ie,
226
+ type: this.type,
227
+ getAttributes: (t) => {
228
+ const [, , e, r, n] = t;
229
+ return { src: r, alt: e, title: n };
230
+ }
231
+ })
232
+ ];
233
+ }
234
+ }), He = Object.defineProperty, Ee = (t, e) => {
235
+ for (var r in e)
236
+ He(t, r, { get: e[r], enumerable: !0 });
237
+ }, $e = "listItem", J = "textStyle", tt = /^\s*([-+*])\s$/, Ne = L.create({
238
+ name: "bulletList",
239
+ addOptions() {
240
+ return {
241
+ itemTypeName: "listItem",
242
+ HTMLAttributes: {},
243
+ keepMarks: !1,
244
+ keepAttributes: !1
245
+ };
246
+ },
247
+ group: "block list",
248
+ content() {
249
+ return `${this.options.itemTypeName}+`;
250
+ },
251
+ parseHTML() {
252
+ return [{ tag: "ul" }];
253
+ },
254
+ renderHTML({ HTMLAttributes: t }) {
255
+ return ["ul", k(this.options.HTMLAttributes, t), 0];
256
+ },
257
+ markdownTokenName: "list",
258
+ parseMarkdown: (t, e) => t.type !== "list" || t.ordered ? [] : {
259
+ type: "bulletList",
260
+ content: t.items ? e.parseChildren(t.items) : []
261
+ },
262
+ renderMarkdown: (t, e) => t.content ? e.renderChildren(t.content, `
263
+ `) : "",
264
+ markdownOptions: {
265
+ indentsContent: !0
266
+ },
267
+ addCommands() {
268
+ return {
269
+ toggleBulletList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes($e, this.editor.getAttributes(J)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
270
+ };
271
+ },
272
+ addKeyboardShortcuts() {
273
+ return {
274
+ "Mod-Shift-8": () => this.editor.commands.toggleBulletList()
275
+ };
276
+ },
277
+ addInputRules() {
278
+ let t = S({
279
+ find: tt,
280
+ type: this.type
281
+ });
282
+ return (this.options.keepMarks || this.options.keepAttributes) && (t = S({
283
+ find: tt,
284
+ type: this.type,
285
+ keepMarks: this.options.keepMarks,
286
+ keepAttributes: this.options.keepAttributes,
287
+ getAttributes: () => this.editor.getAttributes(J),
288
+ editor: this.editor
289
+ })), [t];
290
+ }
291
+ }), Re = L.create({
292
+ name: "listItem",
293
+ addOptions() {
294
+ return {
295
+ HTMLAttributes: {},
296
+ bulletListTypeName: "bulletList",
297
+ orderedListTypeName: "orderedList"
298
+ };
299
+ },
300
+ content: "paragraph block*",
301
+ defining: !0,
302
+ parseHTML() {
303
+ return [
304
+ {
305
+ tag: "li"
306
+ }
307
+ ];
308
+ },
309
+ renderHTML({ HTMLAttributes: t }) {
310
+ return ["li", k(this.options.HTMLAttributes, t), 0];
311
+ },
312
+ markdownTokenName: "list_item",
313
+ parseMarkdown: (t, e) => {
314
+ if (t.type !== "list_item")
315
+ return [];
316
+ let r = [];
317
+ if (t.tokens && t.tokens.length > 0)
318
+ if (t.tokens.some((s) => s.type === "paragraph"))
319
+ r = e.parseChildren(t.tokens);
320
+ else {
321
+ const s = t.tokens[0];
322
+ if (s && s.type === "text" && s.tokens && s.tokens.length > 0) {
323
+ if (r = [
324
+ {
325
+ type: "paragraph",
326
+ content: e.parseInline(s.tokens)
327
+ }
328
+ ], t.tokens.length > 1) {
329
+ const a = t.tokens.slice(1), o = e.parseChildren(a);
330
+ r.push(...o);
331
+ }
332
+ } else
333
+ r = e.parseChildren(t.tokens);
334
+ }
335
+ return r.length === 0 && (r = [
336
+ {
337
+ type: "paragraph",
338
+ content: []
339
+ }
340
+ ]), {
341
+ type: "listItem",
342
+ content: r
343
+ };
344
+ },
345
+ renderMarkdown: (t, e, r) => lt(
346
+ t,
347
+ e,
348
+ (n) => n.parentType === "bulletList" ? "- " : n.parentType === "orderedList" ? `${n.index + 1}. ` : "- ",
349
+ r
350
+ ),
351
+ addKeyboardShortcuts() {
352
+ return {
353
+ Enter: () => this.editor.commands.splitListItem(this.name),
354
+ Tab: () => this.editor.commands.sinkListItem(this.name),
355
+ "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
356
+ };
357
+ }
358
+ }), Pe = {};
359
+ Ee(Pe, {
360
+ findListItemPos: () => $,
361
+ getNextListDepth: () => V,
362
+ handleBackspace: () => z,
363
+ handleDelete: () => W,
364
+ hasListBefore: () => ht,
365
+ hasListItemAfter: () => Be,
366
+ hasListItemBefore: () => ft,
367
+ listItemHasSubList: () => mt,
368
+ nextListIsDeeper: () => gt,
369
+ nextListIsHigher: () => bt
370
+ });
371
+ var $ = (t, e) => {
372
+ const { $from: r } = e.selection, n = ut(t, e.schema);
373
+ let s = null, i = r.depth, a = r.pos, o = null;
374
+ for (; i > 0 && o === null; )
375
+ s = r.node(i), s.type === n ? o = i : (i -= 1, a -= 1);
376
+ return o === null ? null : { $pos: e.doc.resolve(a), depth: o };
377
+ }, V = (t, e) => {
378
+ const r = $(t, e);
379
+ if (!r)
380
+ return !1;
381
+ const [, n] = Et(e, t, r.$pos.pos + 4);
382
+ return n;
383
+ }, ht = (t, e, r) => {
384
+ const { $anchor: n } = t.selection, s = Math.max(0, n.pos - 2), i = t.doc.resolve(s).node();
385
+ return !(!i || !r.includes(i.type.name));
386
+ }, ft = (t, e) => {
387
+ var r;
388
+ const { $anchor: n } = e.selection, s = e.doc.resolve(n.pos - 2);
389
+ return !(s.index() === 0 || ((r = s.nodeBefore) == null ? void 0 : r.type.name) !== t);
390
+ }, mt = (t, e, r) => {
391
+ if (!r)
392
+ return !1;
393
+ const n = ut(t, e.schema);
394
+ let s = !1;
395
+ return r.descendants((i) => {
396
+ i.type === n && (s = !0);
397
+ }), s;
398
+ }, z = (t, e, r) => {
399
+ if (t.commands.undoInputRule())
400
+ return !0;
401
+ if (t.state.selection.from !== t.state.selection.to)
402
+ return !1;
403
+ if (!_(t.state, e) && ht(t.state, e, r)) {
404
+ const { $anchor: o } = t.state.selection, c = t.state.doc.resolve(o.before() - 1), l = [];
405
+ c.node().descendants((h, b) => {
406
+ h.type.name === e && l.push({ node: h, pos: b });
407
+ });
408
+ const d = l.at(-1);
409
+ if (!d)
410
+ return !1;
411
+ const u = t.state.doc.resolve(c.start() + d.pos + 1);
412
+ return t.chain().cut({ from: o.start() - 1, to: o.end() + 1 }, u.end()).joinForward().run();
413
+ }
414
+ if (!_(t.state, e) || !St(t.state))
415
+ return !1;
416
+ const n = $(e, t.state);
417
+ if (!n)
418
+ return !1;
419
+ const i = t.state.doc.resolve(n.$pos.pos - 2).node(n.depth), a = mt(e, t.state, i);
420
+ return ft(e, t.state) && !a ? t.commands.joinItemBackward() : t.chain().liftListItem(e).run();
421
+ }, gt = (t, e) => {
422
+ const r = V(t, e), n = $(t, e);
423
+ return !n || !r ? !1 : r > n.depth;
424
+ }, bt = (t, e) => {
425
+ const r = V(t, e), n = $(t, e);
426
+ return !n || !r ? !1 : r < n.depth;
427
+ }, W = (t, e) => {
428
+ if (!_(t.state, e) || !Ht(t.state, e))
429
+ return !1;
430
+ const { selection: r } = t.state, { $from: n, $to: s } = r;
431
+ return !r.empty && n.sameParent(s) ? !1 : gt(e, t.state) ? t.chain().focus(t.state.selection.from + 4).lift(e).joinBackward().run() : bt(e, t.state) ? t.chain().joinForward().joinBackward().run() : t.commands.joinItemForward();
432
+ }, Be = (t, e) => {
433
+ var r;
434
+ const { $anchor: n } = e.selection, s = e.doc.resolve(n.pos - n.parentOffset - 2);
435
+ return !(s.index() === s.parent.childCount - 1 || ((r = s.nodeAfter) == null ? void 0 : r.type.name) !== t);
436
+ }, Oe = C.create({
437
+ name: "listKeymap",
438
+ addOptions() {
439
+ return {
440
+ listTypes: [
441
+ {
442
+ itemName: "listItem",
443
+ wrapperNames: ["bulletList", "orderedList"]
444
+ },
445
+ {
446
+ itemName: "taskItem",
447
+ wrapperNames: ["taskList"]
448
+ }
449
+ ]
450
+ };
451
+ },
452
+ addKeyboardShortcuts() {
453
+ return {
454
+ Delete: ({ editor: t }) => {
455
+ let e = !1;
456
+ return this.options.listTypes.forEach(({ itemName: r }) => {
457
+ t.state.schema.nodes[r] !== void 0 && W(t, r) && (e = !0);
458
+ }), e;
459
+ },
460
+ "Mod-Delete": ({ editor: t }) => {
461
+ let e = !1;
462
+ return this.options.listTypes.forEach(({ itemName: r }) => {
463
+ t.state.schema.nodes[r] !== void 0 && W(t, r) && (e = !0);
464
+ }), e;
465
+ },
466
+ Backspace: ({ editor: t }) => {
467
+ let e = !1;
468
+ return this.options.listTypes.forEach(({ itemName: r, wrapperNames: n }) => {
469
+ t.state.schema.nodes[r] !== void 0 && z(t, r, n) && (e = !0);
470
+ }), e;
471
+ },
472
+ "Mod-Backspace": ({ editor: t }) => {
473
+ let e = !1;
474
+ return this.options.listTypes.forEach(({ itemName: r, wrapperNames: n }) => {
475
+ t.state.schema.nodes[r] !== void 0 && z(t, r, n) && (e = !0);
476
+ }), e;
477
+ }
478
+ };
479
+ }
480
+ }), et = /^(\s*)(\d+)\.\s+(.*)$/, De = /^\s/;
481
+ function _e(t) {
482
+ const e = [];
483
+ let r = 0, n = 0;
484
+ for (; r < t.length; ) {
485
+ const s = t[r], i = s.match(et);
486
+ if (!i)
487
+ break;
488
+ const [, a, o, c] = i, l = a.length;
489
+ let d = c, u = r + 1;
490
+ const h = [s];
491
+ for (; u < t.length; ) {
492
+ const b = t[u];
493
+ if (b.match(et))
494
+ break;
495
+ if (b.trim() === "")
496
+ h.push(b), d += `
497
+ `, u += 1;
498
+ else if (b.match(De))
499
+ h.push(b), d += `
500
+ ${b.slice(l + 2)}`, u += 1;
501
+ else
502
+ break;
503
+ }
504
+ e.push({
505
+ indent: l,
506
+ number: parseInt(o, 10),
507
+ content: d.trim(),
508
+ raw: h.join(`
509
+ `)
510
+ }), n = u, r = u;
511
+ }
512
+ return [e, n];
513
+ }
514
+ function yt(t, e, r) {
515
+ var n;
516
+ const s = [];
517
+ let i = 0;
518
+ for (; i < t.length; ) {
519
+ const a = t[i];
520
+ if (a.indent === e) {
521
+ const o = a.content.split(`
522
+ `), c = ((n = o[0]) == null ? void 0 : n.trim()) || "", l = [];
523
+ c && l.push({
524
+ type: "paragraph",
525
+ raw: c,
526
+ tokens: r.inlineTokens(c)
527
+ });
528
+ const d = o.slice(1).join(`
529
+ `).trim();
530
+ if (d) {
531
+ const b = r.blockTokens(d);
532
+ l.push(...b);
533
+ }
534
+ let u = i + 1;
535
+ const h = [];
536
+ for (; u < t.length && t[u].indent > e; )
537
+ h.push(t[u]), u += 1;
538
+ if (h.length > 0) {
539
+ const b = Math.min(...h.map((g) => g.indent)), f = yt(h, b, r);
540
+ l.push({
541
+ type: "list",
542
+ ordered: !0,
543
+ start: h[0].number,
544
+ items: f,
545
+ raw: h.map((g) => g.raw).join(`
546
+ `)
547
+ });
548
+ }
549
+ s.push({
550
+ type: "list_item",
551
+ raw: a.raw,
552
+ tokens: l
553
+ }), i = u;
554
+ } else
555
+ i += 1;
556
+ }
557
+ return s;
558
+ }
559
+ function ze(t, e) {
560
+ return t.map((r) => {
561
+ if (r.type !== "list_item")
562
+ return e.parseChildren([r])[0];
563
+ const n = [];
564
+ return r.tokens && r.tokens.length > 0 && r.tokens.forEach((s) => {
565
+ if (s.type === "paragraph" || s.type === "list" || s.type === "blockquote" || s.type === "code")
566
+ n.push(...e.parseChildren([s]));
567
+ else if (s.type === "text" && s.tokens) {
568
+ const i = e.parseChildren([s]);
569
+ n.push({
570
+ type: "paragraph",
571
+ content: i
572
+ });
573
+ } else {
574
+ const i = e.parseChildren([s]);
575
+ i.length > 0 && n.push(...i);
576
+ }
577
+ }), {
578
+ type: "listItem",
579
+ content: n
580
+ };
581
+ });
582
+ }
583
+ var We = "listItem", rt = "textStyle", nt = /^(\d+)\.\s$/, je = L.create({
584
+ name: "orderedList",
585
+ addOptions() {
586
+ return {
587
+ itemTypeName: "listItem",
588
+ HTMLAttributes: {},
589
+ keepMarks: !1,
590
+ keepAttributes: !1
591
+ };
592
+ },
593
+ group: "block list",
594
+ content() {
595
+ return `${this.options.itemTypeName}+`;
596
+ },
597
+ addAttributes() {
598
+ return {
599
+ start: {
600
+ default: 1,
601
+ parseHTML: (t) => t.hasAttribute("start") ? parseInt(t.getAttribute("start") || "", 10) : 1
602
+ },
603
+ type: {
604
+ default: null,
605
+ parseHTML: (t) => t.getAttribute("type")
606
+ }
607
+ };
608
+ },
609
+ parseHTML() {
610
+ return [
611
+ {
612
+ tag: "ol"
613
+ }
614
+ ];
615
+ },
616
+ renderHTML({ HTMLAttributes: t }) {
617
+ const { start: e, ...r } = t;
618
+ return e === 1 ? ["ol", k(this.options.HTMLAttributes, r), 0] : ["ol", k(this.options.HTMLAttributes, t), 0];
619
+ },
620
+ markdownTokenName: "list",
621
+ parseMarkdown: (t, e) => {
622
+ if (t.type !== "list" || !t.ordered)
623
+ return [];
624
+ const r = t.start || 1, n = t.items ? ze(t.items, e) : [];
625
+ return r !== 1 ? {
626
+ type: "orderedList",
627
+ attrs: { start: r },
628
+ content: n
629
+ } : {
630
+ type: "orderedList",
631
+ content: n
632
+ };
633
+ },
634
+ renderMarkdown: (t, e) => t.content ? e.renderChildren(t.content, `
635
+ `) : "",
636
+ markdownTokenizer: {
637
+ name: "orderedList",
638
+ level: "block",
639
+ start: (t) => {
640
+ const e = t.match(/^(\s*)(\d+)\.\s+/), r = e?.index;
641
+ return r !== void 0 ? r : -1;
642
+ },
643
+ tokenize: (t, e, r) => {
644
+ var n;
645
+ const s = t.split(`
646
+ `), [i, a] = _e(s);
647
+ if (i.length === 0)
648
+ return;
649
+ const o = yt(i, 0, r);
650
+ return o.length === 0 ? void 0 : {
651
+ type: "list",
652
+ ordered: !0,
653
+ start: ((n = i[0]) == null ? void 0 : n.number) || 1,
654
+ items: o,
655
+ raw: s.slice(0, a).join(`
656
+ `)
657
+ };
658
+ }
659
+ },
660
+ markdownOptions: {
661
+ indentsContent: !0
662
+ },
663
+ addCommands() {
664
+ return {
665
+ toggleOrderedList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(We, this.editor.getAttributes(rt)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
666
+ };
667
+ },
668
+ addKeyboardShortcuts() {
669
+ return {
670
+ "Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
671
+ };
672
+ },
673
+ addInputRules() {
674
+ let t = S({
675
+ find: nt,
676
+ type: this.type,
677
+ getAttributes: (e) => ({ start: +e[1] }),
678
+ joinPredicate: (e, r) => r.childCount + r.attrs.start === +e[1]
679
+ });
680
+ return (this.options.keepMarks || this.options.keepAttributes) && (t = S({
681
+ find: nt,
682
+ type: this.type,
683
+ keepMarks: this.options.keepMarks,
684
+ keepAttributes: this.options.keepAttributes,
685
+ getAttributes: (e) => ({ start: +e[1], ...this.editor.getAttributes(rt) }),
686
+ joinPredicate: (e, r) => r.childCount + r.attrs.start === +e[1],
687
+ editor: this.editor
688
+ })), [t];
689
+ }
690
+ }), Qe = /^\s*(\[([( |x])?\])\s$/, kt = L.create({
691
+ name: "taskItem",
692
+ addOptions() {
693
+ return {
694
+ nested: !1,
695
+ HTMLAttributes: {},
696
+ taskListTypeName: "taskList",
697
+ a11y: void 0
698
+ };
699
+ },
700
+ content() {
701
+ return this.options.nested ? "paragraph block*" : "paragraph+";
702
+ },
703
+ defining: !0,
704
+ addAttributes() {
705
+ return {
706
+ checked: {
707
+ default: !1,
708
+ keepOnSplit: !1,
709
+ parseHTML: (t) => {
710
+ const e = t.getAttribute("data-checked");
711
+ return e === "" || e === "true";
712
+ },
713
+ renderHTML: (t) => ({
714
+ "data-checked": t.checked
715
+ })
716
+ }
717
+ };
718
+ },
719
+ parseHTML() {
720
+ return [
721
+ {
722
+ tag: `li[data-type="${this.name}"]`,
723
+ priority: 51
724
+ }
725
+ ];
726
+ },
727
+ renderHTML({ node: t, HTMLAttributes: e }) {
728
+ return [
729
+ "li",
730
+ k(this.options.HTMLAttributes, e, {
731
+ "data-type": this.name
732
+ }),
733
+ [
734
+ "label",
735
+ [
736
+ "input",
737
+ {
738
+ type: "checkbox",
739
+ checked: t.attrs.checked ? "checked" : null
740
+ }
741
+ ],
742
+ ["span"]
743
+ ],
744
+ ["div", 0]
745
+ ];
746
+ },
747
+ parseMarkdown: (t, e) => {
748
+ const r = [];
749
+ if (t.tokens && t.tokens.length > 0 ? r.push(e.createNode("paragraph", {}, e.parseInline(t.tokens))) : t.text ? r.push(e.createNode("paragraph", {}, [e.createNode("text", { text: t.text })])) : r.push(e.createNode("paragraph", {}, [])), t.nestedTokens && t.nestedTokens.length > 0) {
750
+ const n = e.parseChildren(t.nestedTokens);
751
+ r.push(...n);
752
+ }
753
+ return e.createNode("taskItem", { checked: t.checked || !1 }, r);
754
+ },
755
+ renderMarkdown: (t, e) => {
756
+ var r;
757
+ const s = `- [${(r = t.attrs) != null && r.checked ? "x" : " "}] `;
758
+ return lt(t, e, s);
759
+ },
760
+ addKeyboardShortcuts() {
761
+ const t = {
762
+ Enter: () => this.editor.commands.splitListItem(this.name),
763
+ "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
764
+ };
765
+ return this.options.nested ? {
766
+ ...t,
767
+ Tab: () => this.editor.commands.sinkListItem(this.name)
768
+ } : t;
769
+ },
770
+ addNodeView() {
771
+ return ({ node: t, HTMLAttributes: e, getPos: r, editor: n }) => {
772
+ const s = document.createElement("li"), i = document.createElement("label"), a = document.createElement("span"), o = document.createElement("input"), c = document.createElement("div"), l = (d) => {
773
+ var u, h;
774
+ o.ariaLabel = ((h = (u = this.options.a11y) == null ? void 0 : u.checkboxLabel) == null ? void 0 : h.call(u, d, o.checked)) || `Task item checkbox for ${d.textContent || "empty task item"}`;
775
+ };
776
+ return l(t), i.contentEditable = "false", o.type = "checkbox", o.addEventListener("mousedown", (d) => d.preventDefault()), o.addEventListener("change", (d) => {
777
+ if (!n.isEditable && !this.options.onReadOnlyChecked) {
778
+ o.checked = !o.checked;
779
+ return;
780
+ }
781
+ const { checked: u } = d.target;
782
+ n.isEditable && typeof r == "function" && n.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: h }) => {
783
+ const b = r();
784
+ if (typeof b != "number")
785
+ return !1;
786
+ const f = h.doc.nodeAt(b);
787
+ return h.setNodeMarkup(b, void 0, {
788
+ ...f?.attrs,
789
+ checked: u
790
+ }), !0;
791
+ }).run(), !n.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t, u) || (o.checked = !o.checked));
792
+ }), Object.entries(this.options.HTMLAttributes).forEach(([d, u]) => {
793
+ s.setAttribute(d, u);
794
+ }), s.dataset.checked = t.attrs.checked, o.checked = t.attrs.checked, i.append(o, a), s.append(i, c), Object.entries(e).forEach(([d, u]) => {
795
+ s.setAttribute(d, u);
796
+ }), {
797
+ dom: s,
798
+ contentDOM: c,
799
+ update: (d) => d.type !== this.type ? !1 : (s.dataset.checked = d.attrs.checked, o.checked = d.attrs.checked, l(d), !0)
800
+ };
801
+ };
802
+ },
803
+ addInputRules() {
804
+ return [
805
+ S({
806
+ find: Qe,
807
+ type: this.type,
808
+ getAttributes: (t) => ({
809
+ checked: t[t.length - 1] === "x"
810
+ })
811
+ })
812
+ ];
813
+ }
814
+ }), Tt = L.create({
815
+ name: "taskList",
816
+ addOptions() {
817
+ return {
818
+ itemTypeName: "taskItem",
819
+ HTMLAttributes: {}
820
+ };
821
+ },
822
+ group: "block list",
823
+ content() {
824
+ return `${this.options.itemTypeName}+`;
825
+ },
826
+ parseHTML() {
827
+ return [
828
+ {
829
+ tag: `ul[data-type="${this.name}"]`,
830
+ priority: 51
831
+ }
832
+ ];
833
+ },
834
+ renderHTML({ HTMLAttributes: t }) {
835
+ return ["ul", k(this.options.HTMLAttributes, t, { "data-type": this.name }), 0];
836
+ },
837
+ parseMarkdown: (t, e) => e.createNode("taskList", {}, e.parseChildren(t.items || [])),
838
+ renderMarkdown: (t, e) => t.content ? e.renderChildren(t.content, `
839
+ `) : "",
840
+ markdownTokenizer: {
841
+ name: "taskList",
842
+ level: "block",
843
+ start(t) {
844
+ var e;
845
+ const r = (e = t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)) == null ? void 0 : e.index;
846
+ return r !== void 0 ? r : -1;
847
+ },
848
+ tokenize(t, e, r) {
849
+ const n = (i) => {
850
+ const a = F(
851
+ i,
852
+ {
853
+ itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
854
+ extractItemData: (o) => ({
855
+ indentLevel: o[1].length,
856
+ mainContent: o[4],
857
+ checked: o[3].toLowerCase() === "x"
858
+ }),
859
+ createToken: (o, c) => ({
860
+ type: "taskItem",
861
+ raw: "",
862
+ mainContent: o.mainContent,
863
+ indentLevel: o.indentLevel,
864
+ checked: o.checked,
865
+ text: o.mainContent,
866
+ tokens: r.inlineTokens(o.mainContent),
867
+ nestedTokens: c
868
+ }),
869
+ // Allow recursive nesting
870
+ customNestedParser: n
871
+ },
872
+ r
873
+ );
874
+ return a ? [
875
+ {
876
+ type: "taskList",
877
+ raw: a.raw,
878
+ items: a.items
879
+ }
880
+ ] : r.blockTokens(i);
881
+ }, s = F(
882
+ t,
883
+ {
884
+ itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
885
+ extractItemData: (i) => ({
886
+ indentLevel: i[1].length,
887
+ mainContent: i[4],
888
+ checked: i[3].toLowerCase() === "x"
889
+ }),
890
+ createToken: (i, a) => ({
891
+ type: "taskItem",
892
+ raw: "",
893
+ mainContent: i.mainContent,
894
+ indentLevel: i.indentLevel,
895
+ checked: i.checked,
896
+ text: i.mainContent,
897
+ tokens: r.inlineTokens(i.mainContent),
898
+ nestedTokens: a
899
+ }),
900
+ // Use the recursive parser for nested content
901
+ customNestedParser: n
902
+ },
903
+ r
904
+ );
905
+ if (s)
906
+ return {
907
+ type: "taskList",
908
+ raw: s.raw,
909
+ items: s.items
910
+ };
911
+ }
912
+ },
913
+ markdownOptions: {
914
+ indentsContent: !0
915
+ },
916
+ addCommands() {
917
+ return {
918
+ toggleTaskList: () => ({ commands: t }) => t.toggleList(this.name, this.options.itemTypeName)
919
+ };
920
+ },
921
+ addKeyboardShortcuts() {
922
+ return {
923
+ "Mod-Shift-9": () => this.editor.commands.toggleTaskList()
924
+ };
925
+ }
926
+ });
927
+ C.create({
928
+ name: "listKit",
929
+ addExtensions() {
930
+ const t = [];
931
+ return this.options.bulletList !== !1 && t.push(Ne.configure(this.options.bulletList)), this.options.listItem !== !1 && t.push(Re.configure(this.options.listItem)), this.options.listKeymap !== !1 && t.push(Oe.configure(this.options.listKeymap)), this.options.orderedList !== !1 && t.push(je.configure(this.options.orderedList)), this.options.taskItem !== !1 && t.push(kt.configure(this.options.taskItem)), this.options.taskList !== !1 && t.push(Tt.configure(this.options.taskList)), t;
932
+ }
933
+ });
934
+ var Ke = Q.create({
935
+ name: "subscript",
936
+ addOptions() {
937
+ return {
938
+ HTMLAttributes: {}
939
+ };
940
+ },
941
+ parseHTML() {
942
+ return [
943
+ {
944
+ tag: "sub"
945
+ },
946
+ {
947
+ style: "vertical-align",
948
+ getAttrs(t) {
949
+ return t !== "sub" ? !1 : null;
950
+ }
951
+ }
952
+ ];
953
+ },
954
+ renderHTML({ HTMLAttributes: t }) {
955
+ return ["sub", k(this.options.HTMLAttributes, t), 0];
956
+ },
957
+ addCommands() {
958
+ return {
959
+ setSubscript: () => ({ commands: t }) => t.setMark(this.name),
960
+ toggleSubscript: () => ({ commands: t }) => t.toggleMark(this.name),
961
+ unsetSubscript: () => ({ commands: t }) => t.unsetMark(this.name)
962
+ };
963
+ },
964
+ addKeyboardShortcuts() {
965
+ return {
966
+ "Mod-,": () => this.editor.commands.toggleSubscript()
967
+ };
968
+ }
969
+ }), Ve = Q.create({
970
+ name: "superscript",
971
+ addOptions() {
972
+ return {
973
+ HTMLAttributes: {}
974
+ };
975
+ },
976
+ parseHTML() {
977
+ return [
978
+ {
979
+ tag: "sup"
980
+ },
981
+ {
982
+ style: "vertical-align",
983
+ getAttrs(t) {
984
+ return t !== "super" ? !1 : null;
985
+ }
986
+ }
987
+ ];
988
+ },
989
+ renderHTML({ HTMLAttributes: t }) {
990
+ return ["sup", k(this.options.HTMLAttributes, t), 0];
991
+ },
992
+ addCommands() {
993
+ return {
994
+ setSuperscript: () => ({ commands: t }) => t.setMark(this.name),
995
+ toggleSuperscript: () => ({ commands: t }) => t.toggleMark(this.name),
996
+ unsetSuperscript: () => ({ commands: t }) => t.unsetMark(this.name)
997
+ };
998
+ },
999
+ addKeyboardShortcuts() {
1000
+ return {
1001
+ "Mod-.": () => this.editor.commands.toggleSuperscript()
1002
+ };
1003
+ }
1004
+ }), qe = C.create({
1005
+ name: "textAlign",
1006
+ addOptions() {
1007
+ return {
1008
+ types: [],
1009
+ alignments: ["left", "center", "right", "justify"],
1010
+ defaultAlignment: null
1011
+ };
1012
+ },
1013
+ addGlobalAttributes() {
1014
+ return [
1015
+ {
1016
+ types: this.options.types,
1017
+ attributes: {
1018
+ textAlign: {
1019
+ default: this.options.defaultAlignment,
1020
+ parseHTML: (t) => {
1021
+ const e = t.style.textAlign;
1022
+ return this.options.alignments.includes(e) ? e : this.options.defaultAlignment;
1023
+ },
1024
+ renderHTML: (t) => t.textAlign ? { style: `text-align: ${t.textAlign}` } : {}
1025
+ }
1026
+ }
1027
+ }
1028
+ ];
1029
+ },
1030
+ addCommands() {
1031
+ return {
1032
+ setTextAlign: (t) => ({ commands: e }) => this.options.alignments.includes(t) ? this.options.types.map((r) => e.updateAttributes(r, { textAlign: t })).every((r) => r) : !1,
1033
+ unsetTextAlign: () => ({ commands: t }) => this.options.types.map((e) => t.resetAttributes(e, "textAlign")).every((e) => e),
1034
+ toggleTextAlign: (t) => ({ editor: e, commands: r }) => this.options.alignments.includes(t) ? e.isActive({ textAlign: t }) ? r.unsetTextAlign() : r.setTextAlign(t) : !1
1035
+ };
1036
+ },
1037
+ addKeyboardShortcuts() {
1038
+ return {
1039
+ "Mod-Shift-l": () => this.editor.commands.setTextAlign("left"),
1040
+ "Mod-Shift-e": () => this.editor.commands.setTextAlign("center"),
1041
+ "Mod-Shift-r": () => this.editor.commands.setTextAlign("right"),
1042
+ "Mod-Shift-j": () => this.editor.commands.setTextAlign("justify")
1043
+ };
1044
+ }
1045
+ }), Fe = (t) => y({
1046
+ find: /--$/,
1047
+ replace: t ?? "—"
1048
+ }), Ue = (t) => y({
1049
+ find: /\.\.\.$/,
1050
+ replace: t ?? "…"
1051
+ }), Ge = (t) => y({
1052
+ find: /(?:^|[\s{[(<'"\u2018\u201C])(")$/,
1053
+ replace: t ?? "“"
1054
+ }), Xe = (t) => y({
1055
+ find: /"$/,
1056
+ replace: t ?? "”"
1057
+ }), Ye = (t) => y({
1058
+ find: /(?:^|[\s{[(<'"\u2018\u201C])(')$/,
1059
+ replace: t ?? "‘"
1060
+ }), Ze = (t) => y({
1061
+ find: /'$/,
1062
+ replace: t ?? "’"
1063
+ }), Je = (t) => y({
1064
+ find: /<-$/,
1065
+ replace: t ?? "←"
1066
+ }), tr = (t) => y({
1067
+ find: /->$/,
1068
+ replace: t ?? "→"
1069
+ }), er = (t) => y({
1070
+ find: /\(c\)$/,
1071
+ replace: t ?? "©"
1072
+ }), rr = (t) => y({
1073
+ find: /\(tm\)$/,
1074
+ replace: t ?? "™"
1075
+ }), nr = (t) => y({
1076
+ find: /\(sm\)$/,
1077
+ replace: t ?? "℠"
1078
+ }), sr = (t) => y({
1079
+ find: /\(r\)$/,
1080
+ replace: t ?? "®"
1081
+ }), ir = (t) => y({
1082
+ find: /(?:^|\s)(1\/2)\s$/,
1083
+ replace: t ?? "½"
1084
+ }), or = (t) => y({
1085
+ find: /\+\/-$/,
1086
+ replace: t ?? "±"
1087
+ }), ar = (t) => y({
1088
+ find: /!=$/,
1089
+ replace: t ?? "≠"
1090
+ }), lr = (t) => y({
1091
+ find: /<<$/,
1092
+ replace: t ?? "«"
1093
+ }), ur = (t) => y({
1094
+ find: />>$/,
1095
+ replace: t ?? "»"
1096
+ }), dr = (t) => y({
1097
+ find: /\d+\s?([*x])\s?\d+$/,
1098
+ replace: t ?? "×"
1099
+ }), cr = (t) => y({
1100
+ find: /\^2$/,
1101
+ replace: t ?? "²"
1102
+ }), pr = (t) => y({
1103
+ find: /\^3$/,
1104
+ replace: t ?? "³"
1105
+ }), hr = (t) => y({
1106
+ find: /(?:^|\s)(1\/4)\s$/,
1107
+ replace: t ?? "¼"
1108
+ }), fr = (t) => y({
1109
+ find: /(?:^|\s)(3\/4)\s$/,
1110
+ replace: t ?? "¾"
1111
+ }), mr = C.create({
1112
+ name: "typography",
1113
+ addOptions() {
1114
+ return {
1115
+ closeDoubleQuote: "”",
1116
+ closeSingleQuote: "’",
1117
+ copyright: "©",
1118
+ ellipsis: "…",
1119
+ emDash: "—",
1120
+ laquo: "«",
1121
+ leftArrow: "←",
1122
+ multiplication: "×",
1123
+ notEqual: "≠",
1124
+ oneHalf: "½",
1125
+ oneQuarter: "¼",
1126
+ openDoubleQuote: "“",
1127
+ openSingleQuote: "‘",
1128
+ plusMinus: "±",
1129
+ raquo: "»",
1130
+ registeredTrademark: "®",
1131
+ rightArrow: "→",
1132
+ servicemark: "℠",
1133
+ superscriptThree: "³",
1134
+ superscriptTwo: "²",
1135
+ threeQuarters: "¾",
1136
+ trademark: "™"
1137
+ };
1138
+ },
1139
+ addInputRules() {
1140
+ const t = [];
1141
+ return this.options.emDash !== !1 && t.push(Fe(this.options.emDash)), this.options.ellipsis !== !1 && t.push(Ue(this.options.ellipsis)), this.options.openDoubleQuote !== !1 && t.push(Ge(this.options.openDoubleQuote)), this.options.closeDoubleQuote !== !1 && t.push(Xe(this.options.closeDoubleQuote)), this.options.openSingleQuote !== !1 && t.push(Ye(this.options.openSingleQuote)), this.options.closeSingleQuote !== !1 && t.push(Ze(this.options.closeSingleQuote)), this.options.leftArrow !== !1 && t.push(Je(this.options.leftArrow)), this.options.rightArrow !== !1 && t.push(tr(this.options.rightArrow)), this.options.copyright !== !1 && t.push(er(this.options.copyright)), this.options.trademark !== !1 && t.push(rr(this.options.trademark)), this.options.servicemark !== !1 && t.push(nr(this.options.servicemark)), this.options.registeredTrademark !== !1 && t.push(sr(this.options.registeredTrademark)), this.options.oneHalf !== !1 && t.push(ir(this.options.oneHalf)), this.options.plusMinus !== !1 && t.push(or(this.options.plusMinus)), this.options.notEqual !== !1 && t.push(ar(this.options.notEqual)), this.options.laquo !== !1 && t.push(lr(this.options.laquo)), this.options.raquo !== !1 && t.push(ur(this.options.raquo)), this.options.multiplication !== !1 && t.push(dr(this.options.multiplication)), this.options.superscriptTwo !== !1 && t.push(cr(this.options.superscriptTwo)), this.options.superscriptThree !== !1 && t.push(pr(this.options.superscriptThree)), this.options.oneQuarter !== !1 && t.push(hr(this.options.oneQuarter)), this.options.threeQuarters !== !1 && t.push(fr(this.options.threeQuarters)), t;
1142
+ }
1143
+ });
1144
+ C.create({
1145
+ name: "characterCount",
1146
+ addOptions() {
1147
+ return {
1148
+ limit: null,
1149
+ mode: "textSize",
1150
+ textCounter: (t) => t.length,
1151
+ wordCounter: (t) => t.split(" ").filter((e) => e !== "").length
1152
+ };
1153
+ },
1154
+ addStorage() {
1155
+ return {
1156
+ characters: () => 0,
1157
+ words: () => 0
1158
+ };
1159
+ },
1160
+ onBeforeCreate() {
1161
+ this.storage.characters = (t) => {
1162
+ const e = t?.node || this.editor.state.doc;
1163
+ if ((t?.mode || this.options.mode) === "textSize") {
1164
+ const n = e.textBetween(0, e.content.size, void 0, " ");
1165
+ return this.options.textCounter(n);
1166
+ }
1167
+ return e.nodeSize;
1168
+ }, this.storage.words = (t) => {
1169
+ const e = t?.node || this.editor.state.doc, r = e.textBetween(0, e.content.size, " ", " ");
1170
+ return this.options.wordCounter(r);
1171
+ };
1172
+ },
1173
+ addProseMirrorPlugins() {
1174
+ let t = !1;
1175
+ return [
1176
+ new H({
1177
+ key: new E("characterCount"),
1178
+ appendTransaction: (e, r, n) => {
1179
+ if (t)
1180
+ return;
1181
+ const s = this.options.limit;
1182
+ if (s == null || s === 0) {
1183
+ t = !0;
1184
+ return;
1185
+ }
1186
+ const i = this.storage.characters({ node: n.doc });
1187
+ if (i > s) {
1188
+ const a = i - s, o = 0, c = a;
1189
+ console.warn(
1190
+ `[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`
1191
+ );
1192
+ const l = n.tr.deleteRange(o, c);
1193
+ return t = !0, l;
1194
+ }
1195
+ t = !0;
1196
+ },
1197
+ filterTransaction: (e, r) => {
1198
+ const n = this.options.limit;
1199
+ if (!e.docChanged || n === 0 || n === null || n === void 0)
1200
+ return !0;
1201
+ const s = this.storage.characters({ node: r.doc }), i = this.storage.characters({ node: e.doc });
1202
+ if (i <= n || s > n && i > n && i <= s)
1203
+ return !0;
1204
+ if (s > n && i > n && i > s || !e.getMeta("paste"))
1205
+ return !1;
1206
+ const o = e.selection.$head.pos, c = i - n, l = o - c, d = o;
1207
+ return e.deleteRange(l, d), !(this.storage.characters({ node: e.doc }) > n);
1208
+ }
1209
+ })
1210
+ ];
1211
+ }
1212
+ });
1213
+ C.create({
1214
+ name: "dropCursor",
1215
+ addOptions() {
1216
+ return {
1217
+ color: "currentColor",
1218
+ width: 1,
1219
+ class: void 0
1220
+ };
1221
+ },
1222
+ addProseMirrorPlugins() {
1223
+ return [Bt(this.options)];
1224
+ }
1225
+ });
1226
+ C.create({
1227
+ name: "focus",
1228
+ addOptions() {
1229
+ return {
1230
+ className: "has-focus",
1231
+ mode: "all"
1232
+ };
1233
+ },
1234
+ addProseMirrorPlugins() {
1235
+ return [
1236
+ new H({
1237
+ key: new E("focus"),
1238
+ props: {
1239
+ decorations: ({ doc: t, selection: e }) => {
1240
+ const { isEditable: r, isFocused: n } = this.editor, { anchor: s } = e, i = [];
1241
+ if (!r || !n)
1242
+ return B.create(t, []);
1243
+ let a = 0;
1244
+ this.options.mode === "deepest" && t.descendants((c, l) => {
1245
+ if (c.isText)
1246
+ return;
1247
+ if (!(s >= l && s <= l + c.nodeSize - 1))
1248
+ return !1;
1249
+ a += 1;
1250
+ });
1251
+ let o = 0;
1252
+ return t.descendants((c, l) => {
1253
+ if (c.isText || !(s >= l && s <= l + c.nodeSize - 1))
1254
+ return !1;
1255
+ if (o += 1, this.options.mode === "deepest" && a - o > 0 || this.options.mode === "shallowest" && o > 1)
1256
+ return this.options.mode === "deepest";
1257
+ i.push(
1258
+ K.node(l, l + c.nodeSize, {
1259
+ class: this.options.className
1260
+ })
1261
+ );
1262
+ }), B.create(t, i);
1263
+ }
1264
+ }
1265
+ })
1266
+ ];
1267
+ }
1268
+ });
1269
+ C.create({
1270
+ name: "gapCursor",
1271
+ addProseMirrorPlugins() {
1272
+ return [Ot()];
1273
+ },
1274
+ extendNodeSchema(t) {
1275
+ var e;
1276
+ const r = {
1277
+ name: t.name,
1278
+ options: t.options,
1279
+ storage: t.storage
1280
+ };
1281
+ return {
1282
+ allowGapCursor: (e = dt(ct(t, "allowGapCursor", r))) != null ? e : null
1283
+ };
1284
+ }
1285
+ });
1286
+ C.create({
1287
+ name: "placeholder",
1288
+ addOptions() {
1289
+ return {
1290
+ emptyEditorClass: "is-editor-empty",
1291
+ emptyNodeClass: "is-empty",
1292
+ placeholder: "Write something …",
1293
+ showOnlyWhenEditable: !0,
1294
+ showOnlyCurrent: !0,
1295
+ includeChildren: !1
1296
+ };
1297
+ },
1298
+ addProseMirrorPlugins() {
1299
+ return [
1300
+ new H({
1301
+ key: new E("placeholder"),
1302
+ props: {
1303
+ decorations: ({ doc: t, selection: e }) => {
1304
+ const r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: n } = e, s = [];
1305
+ if (!r)
1306
+ return null;
1307
+ const i = this.editor.isEmpty;
1308
+ return t.descendants((a, o) => {
1309
+ const c = n >= o && n <= o + a.nodeSize, l = !a.isLeaf && $t(a);
1310
+ if ((c || !this.options.showOnlyCurrent) && l) {
1311
+ const d = [this.options.emptyNodeClass];
1312
+ i && d.push(this.options.emptyEditorClass);
1313
+ const u = K.node(o, o + a.nodeSize, {
1314
+ class: d.join(" "),
1315
+ "data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
1316
+ editor: this.editor,
1317
+ node: a,
1318
+ pos: o,
1319
+ hasAnchor: c
1320
+ }) : this.options.placeholder
1321
+ });
1322
+ s.push(u);
1323
+ }
1324
+ return this.options.includeChildren;
1325
+ }), B.create(t, s);
1326
+ }
1327
+ }
1328
+ })
1329
+ ];
1330
+ }
1331
+ });
1332
+ var gr = C.create({
1333
+ name: "selection",
1334
+ addOptions() {
1335
+ return {
1336
+ className: "selection"
1337
+ };
1338
+ },
1339
+ addProseMirrorPlugins() {
1340
+ const { editor: t, options: e } = this;
1341
+ return [
1342
+ new H({
1343
+ key: new E("selection"),
1344
+ props: {
1345
+ decorations(r) {
1346
+ return r.selection.empty || t.isFocused || !t.isEditable || Nt(r.selection) || t.view.dragging ? null : B.create(r.doc, [
1347
+ K.inline(r.selection.from, r.selection.to, {
1348
+ class: e.className
1349
+ })
1350
+ ]);
1351
+ }
1352
+ }
1353
+ })
1354
+ ];
1355
+ }
1356
+ });
1357
+ function st({ types: t, node: e }) {
1358
+ return e && Array.isArray(t) && t.includes(e.type) || e?.type === t;
1359
+ }
1360
+ C.create({
1361
+ name: "trailingNode",
1362
+ addOptions() {
1363
+ return {
1364
+ node: void 0,
1365
+ notAfter: []
1366
+ };
1367
+ },
1368
+ addProseMirrorPlugins() {
1369
+ var t;
1370
+ const e = new E(this.name), r = ((t = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : t.name) || this.options.node || "paragraph", n = Object.entries(this.editor.schema.nodes).map(([, s]) => s).filter((s) => (this.options.notAfter || []).concat(r).includes(s.name));
1371
+ return [
1372
+ new H({
1373
+ key: e,
1374
+ appendTransaction: (s, i, a) => {
1375
+ const { doc: o, tr: c, schema: l } = a, d = e.getState(a), u = o.content.size, h = l.nodes[r];
1376
+ if (d)
1377
+ return c.insert(u, h.create());
1378
+ },
1379
+ state: {
1380
+ init: (s, i) => {
1381
+ const a = i.tr.doc.lastChild;
1382
+ return !st({ node: a, types: n });
1383
+ },
1384
+ apply: (s, i) => {
1385
+ if (!s.docChanged)
1386
+ return i;
1387
+ const a = s.doc.lastChild;
1388
+ return !st({ node: a, types: n });
1389
+ }
1390
+ }
1391
+ })
1392
+ ];
1393
+ }
1394
+ });
1395
+ C.create({
1396
+ name: "undoRedo",
1397
+ addOptions() {
1398
+ return {
1399
+ depth: 100,
1400
+ newGroupDelay: 500
1401
+ };
1402
+ },
1403
+ addCommands() {
1404
+ return {
1405
+ undo: () => ({ state: t, dispatch: e }) => zt(t, e),
1406
+ redo: () => ({ state: t, dispatch: e }) => _t(t, e)
1407
+ };
1408
+ },
1409
+ addProseMirrorPlugins() {
1410
+ return [Dt(this.options)];
1411
+ },
1412
+ addKeyboardShortcuts() {
1413
+ return {
1414
+ "Mod-z": () => this.editor.commands.undo(),
1415
+ "Shift-Mod-z": () => this.editor.commands.redo(),
1416
+ "Mod-y": () => this.editor.commands.redo(),
1417
+ // Russian keyboard layouts
1418
+ "Mod-я": () => this.editor.commands.undo(),
1419
+ "Shift-Mod-я": () => this.editor.commands.redo()
1420
+ };
1421
+ }
1422
+ });
1423
+ var br = L.create({
1424
+ name: "tableCell",
1425
+ addOptions() {
1426
+ return {
1427
+ HTMLAttributes: {}
1428
+ };
1429
+ },
1430
+ content: "block+",
1431
+ addAttributes() {
1432
+ return {
1433
+ colspan: {
1434
+ default: 1
1435
+ },
1436
+ rowspan: {
1437
+ default: 1
1438
+ },
1439
+ colwidth: {
1440
+ default: null,
1441
+ parseHTML: (t) => {
1442
+ var e, r;
1443
+ const n = t.getAttribute("colwidth"), s = n ? n.split(",").map((i) => parseInt(i, 10)) : null;
1444
+ if (!s) {
1445
+ const i = (e = t.closest("table")) == null ? void 0 : e.querySelectorAll("colgroup > col"), a = Array.from(((r = t.parentElement) == null ? void 0 : r.children) || []).indexOf(t);
1446
+ if (a && a > -1 && i && i[a]) {
1447
+ const o = i[a].getAttribute("width");
1448
+ return o ? [parseInt(o, 10)] : null;
1449
+ }
1450
+ }
1451
+ return s;
1452
+ }
1453
+ }
1454
+ };
1455
+ },
1456
+ tableRole: "cell",
1457
+ isolating: !0,
1458
+ parseHTML() {
1459
+ return [{ tag: "td" }];
1460
+ },
1461
+ renderHTML({ HTMLAttributes: t }) {
1462
+ return ["td", k(this.options.HTMLAttributes, t), 0];
1463
+ }
1464
+ }), yr = L.create({
1465
+ name: "tableHeader",
1466
+ addOptions() {
1467
+ return {
1468
+ HTMLAttributes: {}
1469
+ };
1470
+ },
1471
+ content: "block+",
1472
+ addAttributes() {
1473
+ return {
1474
+ colspan: {
1475
+ default: 1
1476
+ },
1477
+ rowspan: {
1478
+ default: 1
1479
+ },
1480
+ colwidth: {
1481
+ default: null,
1482
+ parseHTML: (t) => {
1483
+ const e = t.getAttribute("colwidth");
1484
+ return e ? e.split(",").map((n) => parseInt(n, 10)) : null;
1485
+ }
1486
+ }
1487
+ };
1488
+ },
1489
+ tableRole: "header_cell",
1490
+ isolating: !0,
1491
+ parseHTML() {
1492
+ return [{ tag: "th" }];
1493
+ },
1494
+ renderHTML({ HTMLAttributes: t }) {
1495
+ return ["th", k(this.options.HTMLAttributes, t), 0];
1496
+ }
1497
+ }), kr = L.create({
1498
+ name: "tableRow",
1499
+ addOptions() {
1500
+ return {
1501
+ HTMLAttributes: {}
1502
+ };
1503
+ },
1504
+ content: "(tableCell | tableHeader)*",
1505
+ tableRole: "row",
1506
+ parseHTML() {
1507
+ return [{ tag: "tr" }];
1508
+ },
1509
+ renderHTML({ HTMLAttributes: t }) {
1510
+ return ["tr", k(this.options.HTMLAttributes, t), 0];
1511
+ }
1512
+ });
1513
+ function j(t, e) {
1514
+ return e ? ["width", `${Math.max(e, t)}px`] : ["min-width", `${t}px`];
1515
+ }
1516
+ function it(t, e, r, n, s, i) {
1517
+ var a;
1518
+ let o = 0, c = !0, l = e.firstChild;
1519
+ const d = t.firstChild;
1520
+ if (d !== null)
1521
+ for (let h = 0, b = 0; h < d.childCount; h += 1) {
1522
+ const { colspan: f, colwidth: g } = d.child(h).attrs;
1523
+ for (let m = 0; m < f; m += 1, b += 1) {
1524
+ const T = s === b ? i : g && g[m], v = T ? `${T}px` : "";
1525
+ if (o += T || n, T || (c = !1), l) {
1526
+ if (l.style.width !== v) {
1527
+ const [I, N] = j(n, T);
1528
+ l.style.setProperty(I, N);
1529
+ }
1530
+ l = l.nextSibling;
1531
+ } else {
1532
+ const I = document.createElement("col"), [N, O] = j(n, T);
1533
+ I.style.setProperty(N, O), e.appendChild(I);
1534
+ }
1535
+ }
1536
+ }
1537
+ for (; l; ) {
1538
+ const h = l.nextSibling;
1539
+ (a = l.parentNode) == null || a.removeChild(l), l = h;
1540
+ }
1541
+ const u = t.attrs.style && typeof t.attrs.style == "string" && /\bwidth\s*:/i.test(t.attrs.style);
1542
+ c && !u ? (r.style.width = `${o}px`, r.style.minWidth = "") : (r.style.width = "", r.style.minWidth = `${o}px`);
1543
+ }
1544
+ var Tr = class {
1545
+ constructor(t, e) {
1546
+ 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")), it(t, this.colgroup, this.table, e), this.contentDOM = this.table.appendChild(document.createElement("tbody"));
1547
+ }
1548
+ update(t) {
1549
+ return t.type !== this.node.type ? !1 : (this.node = t, it(t, this.colgroup, this.table, this.cellMinWidth), !0);
1550
+ }
1551
+ ignoreMutation(t) {
1552
+ const e = t.target, r = this.dom.contains(e), n = this.contentDOM.contains(e);
1553
+ return !!(r && !n && (t.type === "attributes" || t.type === "childList" || t.type === "characterData"));
1554
+ }
1555
+ };
1556
+ function Cr(t, e, r, n) {
1557
+ let s = 0, i = !0;
1558
+ const a = [], o = t.firstChild;
1559
+ if (!o)
1560
+ return {};
1561
+ for (let u = 0, h = 0; u < o.childCount; u += 1) {
1562
+ const { colspan: b, colwidth: f } = o.child(u).attrs;
1563
+ for (let g = 0; g < b; g += 1, h += 1) {
1564
+ const m = r === h ? n : f && f[g];
1565
+ s += m || e, m || (i = !1);
1566
+ const [T, v] = j(e, m);
1567
+ a.push(["col", { style: `${T}: ${v}` }]);
1568
+ }
1569
+ }
1570
+ const c = i ? `${s}px` : "", l = i ? "" : `${s}px`;
1571
+ return { colgroup: ["colgroup", {}, ...a], tableWidth: c, tableMinWidth: l };
1572
+ }
1573
+ function ot(t, e) {
1574
+ return t.createAndFill();
1575
+ }
1576
+ function Lr(t) {
1577
+ if (t.cached.tableNodeTypes)
1578
+ return t.cached.tableNodeTypes;
1579
+ const e = {};
1580
+ return Object.keys(t.nodes).forEach((r) => {
1581
+ const n = t.nodes[r];
1582
+ n.spec.tableRole && (e[n.spec.tableRole] = n);
1583
+ }), t.cached.tableNodeTypes = e, e;
1584
+ }
1585
+ function wr(t, e, r, n, s) {
1586
+ const i = Lr(t), a = [], o = [];
1587
+ for (let l = 0; l < r; l += 1) {
1588
+ const d = ot(i.cell);
1589
+ if (d && o.push(d), n) {
1590
+ const u = ot(i.header_cell);
1591
+ u && a.push(u);
1592
+ }
1593
+ }
1594
+ const c = [];
1595
+ for (let l = 0; l < e; l += 1)
1596
+ c.push(i.row.createChecked(null, n && l === 0 ? a : o));
1597
+ return i.table.createChecked(null, c);
1598
+ }
1599
+ function vr(t) {
1600
+ return t instanceof pt;
1601
+ }
1602
+ var P = ({ editor: t }) => {
1603
+ const { selection: e } = t.state;
1604
+ if (!vr(e))
1605
+ return !1;
1606
+ let r = 0;
1607
+ const n = Rt(e.ranges[0].$from, (i) => i.type.name === "table");
1608
+ return n?.node.descendants((i) => {
1609
+ if (i.type.name === "table")
1610
+ return !1;
1611
+ ["tableCell", "tableHeader"].includes(i.type.name) && (r += 1);
1612
+ }), r === e.ranges.length ? (t.commands.deleteTable(), !0) : !1;
1613
+ }, Mr = "";
1614
+ function xr(t) {
1615
+ return (t || "").replace(/\s+/g, " ").trim();
1616
+ }
1617
+ function Ar(t, e, r = {}) {
1618
+ var n;
1619
+ const s = (n = r.cellLineSeparator) != null ? n : Mr;
1620
+ if (!t || !t.content || t.content.length === 0)
1621
+ return "";
1622
+ const i = [];
1623
+ t.content.forEach((f) => {
1624
+ const g = [];
1625
+ f.content && f.content.forEach((m) => {
1626
+ let T = "";
1627
+ m.content && Array.isArray(m.content) && m.content.length > 1 ? T = m.content.map((O) => e.renderChildren(O)).join(s) : T = m.content ? e.renderChildren(m.content) : "";
1628
+ const v = xr(T), I = m.type === "tableHeader";
1629
+ g.push({ text: v, isHeader: I });
1630
+ }), i.push(g);
1631
+ });
1632
+ const a = i.reduce((f, g) => Math.max(f, g.length), 0);
1633
+ if (a === 0)
1634
+ return "";
1635
+ const o = new Array(a).fill(0);
1636
+ i.forEach((f) => {
1637
+ var g;
1638
+ for (let m = 0; m < a; m += 1) {
1639
+ const v = (((g = f[m]) == null ? void 0 : g.text) || "").length;
1640
+ v > o[m] && (o[m] = v), o[m] < 3 && (o[m] = 3);
1641
+ }
1642
+ });
1643
+ const c = (f, g) => f + " ".repeat(Math.max(0, g - f.length)), l = i[0], d = l.some((f) => f.isHeader);
1644
+ let u = `
1645
+ `;
1646
+ const h = new Array(a).fill(0).map((f, g) => d && l[g] && l[g].text || "");
1647
+ return u += `| ${h.map((f, g) => c(f, o[g])).join(" | ")} |
1648
+ `, u += `| ${o.map((f) => "-".repeat(Math.max(3, f))).join(" | ")} |
1649
+ `, (d ? i.slice(1) : i).forEach((f) => {
1650
+ u += `| ${new Array(a).fill(0).map((g, m) => c(f[m] && f[m].text || "", o[m])).join(" | ")} |
1651
+ `;
1652
+ }), u;
1653
+ }
1654
+ var Ir = Ar, Sr = L.create({
1655
+ name: "table",
1656
+ // @ts-ignore
1657
+ addOptions() {
1658
+ return {
1659
+ HTMLAttributes: {},
1660
+ resizable: !1,
1661
+ renderWrapper: !1,
1662
+ handleWidth: 5,
1663
+ cellMinWidth: 25,
1664
+ // TODO: fix
1665
+ View: Tr,
1666
+ lastColumnResizable: !0,
1667
+ allowTableNodeSelection: !1
1668
+ };
1669
+ },
1670
+ content: "tableRow+",
1671
+ tableRole: "table",
1672
+ isolating: !0,
1673
+ group: "block",
1674
+ parseHTML() {
1675
+ return [{ tag: "table" }];
1676
+ },
1677
+ renderHTML({ node: t, HTMLAttributes: e }) {
1678
+ const { colgroup: r, tableWidth: n, tableMinWidth: s } = Cr(t, this.options.cellMinWidth), i = e.style;
1679
+ function a() {
1680
+ return i || (n ? `width: ${n}` : `min-width: ${s}`);
1681
+ }
1682
+ const o = [
1683
+ "table",
1684
+ k(this.options.HTMLAttributes, e, {
1685
+ style: a()
1686
+ }),
1687
+ r,
1688
+ ["tbody", 0]
1689
+ ];
1690
+ return this.options.renderWrapper ? ["div", { class: "tableWrapper" }, o] : o;
1691
+ },
1692
+ parseMarkdown: (t, e) => {
1693
+ const r = [];
1694
+ if (t.header) {
1695
+ const n = [];
1696
+ t.header.forEach((s) => {
1697
+ n.push(e.createNode("tableHeader", {}, [{ type: "paragraph", content: e.parseInline(s.tokens) }]));
1698
+ }), r.push(e.createNode("tableRow", {}, n));
1699
+ }
1700
+ return t.rows && t.rows.forEach((n) => {
1701
+ const s = [];
1702
+ n.forEach((i) => {
1703
+ s.push(e.createNode("tableCell", {}, [{ type: "paragraph", content: e.parseInline(i.tokens) }]));
1704
+ }), r.push(e.createNode("tableRow", {}, s));
1705
+ }), e.createNode("table", void 0, r);
1706
+ },
1707
+ renderMarkdown: (t, e) => Ir(t, e),
1708
+ addCommands() {
1709
+ return {
1710
+ insertTable: ({ rows: t = 3, cols: e = 3, withHeaderRow: r = !0 } = {}) => ({ tr: n, dispatch: s, editor: i }) => {
1711
+ const a = wr(i.schema, t, e, r);
1712
+ if (s) {
1713
+ const o = n.selection.from + 1;
1714
+ n.replaceSelectionWith(a).scrollIntoView().setSelection(Pt.near(n.doc.resolve(o)));
1715
+ }
1716
+ return !0;
1717
+ },
1718
+ addColumnBefore: () => ({ state: t, dispatch: e }) => pe(t, e),
1719
+ addColumnAfter: () => ({ state: t, dispatch: e }) => ce(t, e),
1720
+ deleteColumn: () => ({ state: t, dispatch: e }) => de(t, e),
1721
+ addRowBefore: () => ({ state: t, dispatch: e }) => ue(t, e),
1722
+ addRowAfter: () => ({ state: t, dispatch: e }) => le(t, e),
1723
+ deleteRow: () => ({ state: t, dispatch: e }) => ae(t, e),
1724
+ deleteTable: () => ({ state: t, dispatch: e }) => oe(t, e),
1725
+ mergeCells: () => ({ state: t, dispatch: e }) => G(t, e),
1726
+ splitCell: () => ({ state: t, dispatch: e }) => X(t, e),
1727
+ toggleHeaderColumn: () => ({ state: t, dispatch: e }) => Y("column")(t, e),
1728
+ toggleHeaderRow: () => ({ state: t, dispatch: e }) => Y("row")(t, e),
1729
+ toggleHeaderCell: () => ({ state: t, dispatch: e }) => ie(t, e),
1730
+ mergeOrSplit: () => ({ state: t, dispatch: e }) => G(t, e) ? !0 : X(t, e),
1731
+ setCellAttribute: (t, e) => ({ state: r, dispatch: n }) => se(t, e)(r, n),
1732
+ goToNextCell: () => ({ state: t, dispatch: e }) => U(1)(t, e),
1733
+ goToPreviousCell: () => ({ state: t, dispatch: e }) => U(-1)(t, e),
1734
+ fixTables: () => ({ state: t, dispatch: e }) => (e && ne(t), !0),
1735
+ setCellSelection: (t) => ({ tr: e, dispatch: r }) => {
1736
+ if (r) {
1737
+ const n = pt.create(e.doc, t.anchorCell, t.headCell);
1738
+ e.setSelection(n);
1739
+ }
1740
+ return !0;
1741
+ }
1742
+ };
1743
+ },
1744
+ addKeyboardShortcuts() {
1745
+ return {
1746
+ Tab: () => this.editor.commands.goToNextCell() ? !0 : this.editor.can().addRowAfter() ? this.editor.chain().addRowAfter().goToNextCell().run() : !1,
1747
+ "Shift-Tab": () => this.editor.commands.goToPreviousCell(),
1748
+ Backspace: P,
1749
+ "Mod-Backspace": P,
1750
+ Delete: P,
1751
+ "Mod-Delete": P
1752
+ };
1753
+ },
1754
+ addProseMirrorPlugins() {
1755
+ return [
1756
+ ...this.options.resizable && this.editor.isEditable ? [
1757
+ ee({
1758
+ handleWidth: this.options.handleWidth,
1759
+ cellMinWidth: this.options.cellMinWidth,
1760
+ defaultCellMinWidth: this.options.cellMinWidth,
1761
+ View: this.options.View,
1762
+ lastColumnResizable: this.options.lastColumnResizable
1763
+ })
1764
+ ] : [],
1765
+ re({
1766
+ allowTableNodeSelection: this.options.allowTableNodeSelection
1767
+ })
1768
+ ];
1769
+ },
1770
+ extendNodeSchema(t) {
1771
+ const e = {
1772
+ name: t.name,
1773
+ options: t.options,
1774
+ storage: t.storage
1775
+ };
1776
+ return {
1777
+ tableRole: dt(ct(t, "tableRole", e))
1778
+ };
1779
+ }
1780
+ }), Hr = C.create({
1781
+ name: "tableKit",
1782
+ addExtensions() {
1783
+ const t = [];
1784
+ return this.options.table !== !1 && t.push(Sr.configure(this.options.table)), this.options.tableCell !== !1 && t.push(br.configure(this.options.tableCell)), this.options.tableHeader !== !1 && t.push(yr.configure(this.options.tableHeader)), this.options.tableRow !== !1 && t.push(kr.configure(this.options.tableRow)), t;
1785
+ }
1786
+ });
1787
+ const Er = ({
1788
+ onHighlighterClick: t,
1789
+ onLinkClick: e,
1790
+ isMobile: r
1791
+ }) => {
1792
+ const { editor: n } = te();
1793
+ return /* @__PURE__ */ w(at, { children: [
1794
+ /* @__PURE__ */ w(x, { children: [
1795
+ /* @__PURE__ */ p(Z, { action: "undo" }),
1796
+ /* @__PURE__ */ p(Z, { action: "redo" })
1797
+ ] }),
1798
+ /* @__PURE__ */ p(A, {}),
1799
+ /* @__PURE__ */ w(x, { children: [
1800
+ /* @__PURE__ */ p(fe, { levels: [1, 2, 3, 4], portal: r }),
1801
+ /* @__PURE__ */ p(
1802
+ me,
1803
+ {
1804
+ types: ["bulletList", "orderedList", "taskList"],
1805
+ portal: r
1806
+ }
1807
+ ),
1808
+ /* @__PURE__ */ p(ge, {}),
1809
+ /* @__PURE__ */ p(be, {})
1810
+ ] }),
1811
+ /* @__PURE__ */ p(A, {}),
1812
+ /* @__PURE__ */ w(x, { children: [
1813
+ /* @__PURE__ */ p(M, { type: "bold" }),
1814
+ /* @__PURE__ */ p(M, { type: "italic" }),
1815
+ /* @__PURE__ */ p(M, { type: "strike" }),
1816
+ /* @__PURE__ */ p(M, { type: "code" }),
1817
+ /* @__PURE__ */ p(M, { type: "underline" }),
1818
+ r ? /* @__PURE__ */ p(ke, { onClick: t }) : /* @__PURE__ */ p(ye, {}),
1819
+ r ? /* @__PURE__ */ p(Le, { onClick: e }) : /* @__PURE__ */ p(Ce, {})
1820
+ ] }),
1821
+ /* @__PURE__ */ p(A, {}),
1822
+ /* @__PURE__ */ w(x, { children: [
1823
+ /* @__PURE__ */ p(M, { type: "superscript" }),
1824
+ /* @__PURE__ */ p(M, { type: "subscript" })
1825
+ ] }),
1826
+ /* @__PURE__ */ p(A, {}),
1827
+ /* @__PURE__ */ w(x, { children: [
1828
+ /* @__PURE__ */ p(R, { align: "left" }),
1829
+ /* @__PURE__ */ p(R, { align: "center" }),
1830
+ /* @__PURE__ */ p(R, { align: "right" }),
1831
+ /* @__PURE__ */ p(R, { align: "justify" })
1832
+ ] }),
1833
+ /* @__PURE__ */ p(A, {}),
1834
+ /* @__PURE__ */ p(x, { children: /* @__PURE__ */ p(Zt, { onClick: () => {
1835
+ n && n.chain().focus().insertTable({ rows: 3, cols: 3 }).run();
1836
+ } }) }),
1837
+ r && /* @__PURE__ */ p(A, {})
1838
+ ] });
1839
+ }, $r = ({
1840
+ type: t,
1841
+ onBack: e
1842
+ }) => /* @__PURE__ */ w(at, { children: [
1843
+ /* @__PURE__ */ p(x, { children: /* @__PURE__ */ w(ve, { "data-style": "ghost", onClick: e, children: [
1844
+ /* @__PURE__ */ p(Kt, { className: "tiptap-button-icon" }),
1845
+ t === "highlighter" ? /* @__PURE__ */ p(Vt, { className: "tiptap-button-icon" }) : /* @__PURE__ */ p(qt, { className: "tiptap-button-icon" })
1846
+ ] }) }),
1847
+ /* @__PURE__ */ p(A, {}),
1848
+ t === "highlighter" ? /* @__PURE__ */ p(Te, {}) : /* @__PURE__ */ p(we, {})
1849
+ ] });
1850
+ function fn({
1851
+ themeMode: t,
1852
+ content: e,
1853
+ onContentChange: r
1854
+ }) {
1855
+ const n = Ut(), { height: s } = Gt(), [i, a] = vt(
1856
+ "main"
1857
+ ), o = q(null), c = q(!1), l = Ct({
1858
+ immediatelyRender: !1,
1859
+ shouldRerenderOnTransaction: !1,
1860
+ editorProps: {
1861
+ attributes: {
1862
+ autocomplete: "off",
1863
+ autocorrect: "off",
1864
+ autocapitalize: "off",
1865
+ "aria-label": "Main content area, start typing to enter text.",
1866
+ class: "simple-editor"
1867
+ }
1868
+ },
1869
+ extensions: [
1870
+ Wt.configure({
1871
+ horizontalRule: !1,
1872
+ link: {
1873
+ openOnClick: !1,
1874
+ enableClickSelection: !0
1875
+ }
1876
+ }),
1877
+ jt,
1878
+ qe.configure({ types: ["heading", "paragraph"] }),
1879
+ Tt,
1880
+ kt.configure({ nested: !0 }),
1881
+ Ae.configure({ multicolor: !0 }),
1882
+ Se,
1883
+ mr,
1884
+ Ve,
1885
+ Ke,
1886
+ gr,
1887
+ Qt.configure({
1888
+ accept: "image/*",
1889
+ maxSize: Yt,
1890
+ limit: 3,
1891
+ upload: Xt,
1892
+ onError: (u) => console.error("Upload failed:", u)
1893
+ }),
1894
+ Hr.configure({
1895
+ table: {
1896
+ resizable: !0
1897
+ }
1898
+ })
1899
+ ],
1900
+ content: e,
1901
+ onUpdate: ({ editor: u }) => {
1902
+ if (!c.current && r) {
1903
+ const h = u.getHTML();
1904
+ r(h);
1905
+ }
1906
+ }
1907
+ }), d = Ft({
1908
+ editor: l,
1909
+ overlayHeight: o.current?.getBoundingClientRect().height ?? 0
1910
+ });
1911
+ return D(() => {
1912
+ !n && i !== "main" && a("main");
1913
+ }, [n, i]), D(() => {
1914
+ l && e !== void 0 && l.getHTML() !== e && (c.current = !0, l.commands.setContent(e, { emitUpdate: !1 }), c.current = !1);
1915
+ }, [e, l]), D(() => {
1916
+ document.documentElement.classList.toggle("dark", t === "dark");
1917
+ }, [t]), l ? /* @__PURE__ */ p("div", { className: "simple-editor-wrapper", children: /* @__PURE__ */ w(Lt.Provider, { value: { editor: l }, children: [
1918
+ /* @__PURE__ */ p(
1919
+ he,
1920
+ {
1921
+ ref: o,
1922
+ style: {
1923
+ ...n ? {
1924
+ bottom: `calc(100% - ${s - d.y}px)`
1925
+ } : {}
1926
+ },
1927
+ children: i === "main" ? /* @__PURE__ */ p(
1928
+ Er,
1929
+ {
1930
+ onHighlighterClick: () => a("highlighter"),
1931
+ onLinkClick: () => a("link"),
1932
+ isMobile: n
1933
+ }
1934
+ ) : /* @__PURE__ */ p(
1935
+ $r,
1936
+ {
1937
+ type: i === "highlighter" ? "highlighter" : "link",
1938
+ onBack: () => a("main")
1939
+ }
1940
+ )
1941
+ }
1942
+ ),
1943
+ /* @__PURE__ */ p(Jt, {}),
1944
+ /* @__PURE__ */ p(
1945
+ wt,
1946
+ {
1947
+ editor: l,
1948
+ role: "presentation",
1949
+ className: "simple-editor-content"
1950
+ }
1951
+ )
1952
+ ] }) }) : null;
1953
+ }
1954
+ export {
1955
+ fn as SimpleEditor
1956
+ };