@blade-hq/agent-react 2612.0.0-beta.4 → 2612.0.0-beta.6

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 (1147) hide show
  1. package/README.md +18 -0
  2. package/dist/chat/ChatPanel.d.ts +1 -3
  3. package/dist/chat/LightComposer.d.ts +1 -1
  4. package/dist/chat/ai-elements/reasoning.d.ts +4 -4
  5. package/dist/chat/customization.d.ts +1 -5
  6. package/dist/chat/lib/citations.d.ts +6 -2
  7. package/dist/chat/runtime/actions.d.ts +2 -0
  8. package/dist/chat/runtime/composer-channels.d.ts +4 -0
  9. package/dist/chat/runtime/input-cache-reset.d.ts +1 -1
  10. package/dist/chat/runtime/input-history-storage.d.ts +2 -0
  11. package/dist/{chunk-WCMGQJLE.js → chunk-IRBOKMF5.js} +2 -2
  12. package/dist/{chunk-FQQJP2GJ.js → chunk-UKQFSXGC.js} +168 -40
  13. package/dist/chunk-UKQFSXGC.js.map +1 -0
  14. package/dist/{chunk-5J54S5BK.js → chunk-XJLFFRQP.js} +401 -182
  15. package/dist/chunk-XJLFFRQP.js.map +1 -0
  16. package/dist/components/ChatInput.d.ts +3 -1
  17. package/dist/components/TopicAssetSubmitDialog.d.ts +14 -0
  18. package/dist/components/plugin-connector.d.ts +1 -0
  19. package/dist/embed/entry.d.ts +2 -0
  20. package/dist/index.d.ts +2 -0
  21. package/dist/index.js +8 -4
  22. package/dist/internal.d.ts +2 -0
  23. package/dist/internal.js +7 -3
  24. package/dist/internal.js.map +1 -1
  25. package/dist/lib/agent-computer-command.d.ts +1 -3
  26. package/dist/rich-input/ChatInput.d.ts +1 -1
  27. package/dist/rich-input/FileCompletionMenu.d.ts +4 -2
  28. package/dist/rich-input/SkillStatusBar.d.ts +2 -4
  29. package/dist/rich-input/extensions/plugin-mention.d.ts +15 -0
  30. package/dist/rich-input/extensions/skill-mention.d.ts +0 -1
  31. package/dist/rich-input/extensions/topic-asset-mention.d.ts +13 -0
  32. package/dist/rich-input/index.d.ts +6 -0
  33. package/dist/rich-input/lib/composer-content.d.ts +10 -1
  34. package/dist/rich-input/lib/input-history-document.d.ts +3 -0
  35. package/dist/rich-input/lib/plugin-suggestions.d.ts +7 -0
  36. package/dist/rich-input/lib/reference-candidates.d.ts +30 -0
  37. package/dist/rich-input/lib/topic-asset-suggestions.d.ts +6 -0
  38. package/dist/rich-input/use-input-history.d.ts +8 -8
  39. package/dist/rich-input/use-reference-candidates.d.ts +8 -0
  40. package/dist/rich-input.js +6404 -6008
  41. package/dist/rich-input.js.map +1 -1
  42. package/dist/style.full.css +1 -1
  43. package/node_modules/@floating-ui/core/LICENSE +20 -0
  44. package/node_modules/@floating-ui/core/README.md +4 -0
  45. package/node_modules/@floating-ui/core/dist/floating-ui.core.browser.min.mjs +1 -0
  46. package/node_modules/@floating-ui/core/dist/floating-ui.core.browser.mjs +1184 -0
  47. package/node_modules/@floating-ui/core/dist/floating-ui.core.d.mts +531 -0
  48. package/node_modules/@floating-ui/core/dist/floating-ui.core.d.ts +531 -0
  49. package/node_modules/@floating-ui/core/dist/floating-ui.core.esm.js +1058 -0
  50. package/node_modules/@floating-ui/core/dist/floating-ui.core.mjs +1058 -0
  51. package/node_modules/@floating-ui/core/dist/floating-ui.core.umd.js +1203 -0
  52. package/node_modules/@floating-ui/core/dist/floating-ui.core.umd.min.js +1 -0
  53. package/node_modules/@floating-ui/core/package.json +63 -0
  54. package/node_modules/@floating-ui/dom/LICENSE +20 -0
  55. package/node_modules/@floating-ui/dom/README.md +4 -0
  56. package/node_modules/@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs +1 -0
  57. package/node_modules/@floating-ui/dom/dist/floating-ui.dom.browser.mjs +956 -0
  58. package/node_modules/@floating-ui/dom/dist/floating-ui.dom.d.mts +358 -0
  59. package/node_modules/@floating-ui/dom/dist/floating-ui.dom.d.ts +358 -0
  60. package/node_modules/@floating-ui/dom/dist/floating-ui.dom.esm.js +781 -0
  61. package/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs +781 -0
  62. package/node_modules/@floating-ui/dom/dist/floating-ui.dom.umd.js +975 -0
  63. package/node_modules/@floating-ui/dom/dist/floating-ui.dom.umd.min.js +1 -0
  64. package/node_modules/@floating-ui/dom/package.json +71 -0
  65. package/node_modules/@floating-ui/utils/LICENSE +20 -0
  66. package/node_modules/@floating-ui/utils/README.md +4 -0
  67. package/node_modules/@floating-ui/utils/dist/floating-ui.utils.d.mts +103 -0
  68. package/node_modules/@floating-ui/utils/dist/floating-ui.utils.d.ts +103 -0
  69. package/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.d.mts +47 -0
  70. package/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.d.ts +47 -0
  71. package/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.esm.js +165 -0
  72. package/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs +165 -0
  73. package/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.umd.js +192 -0
  74. package/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.umd.min.js +1 -0
  75. package/node_modules/@floating-ui/utils/dist/floating-ui.utils.esm.js +136 -0
  76. package/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs +136 -0
  77. package/node_modules/@floating-ui/utils/dist/floating-ui.utils.umd.js +167 -0
  78. package/node_modules/@floating-ui/utils/dist/floating-ui.utils.umd.min.js +1 -0
  79. package/node_modules/@floating-ui/utils/dom/floating-ui.utils.dom.d.ts +47 -0
  80. package/node_modules/@floating-ui/utils/dom/floating-ui.utils.dom.esm.js +165 -0
  81. package/node_modules/@floating-ui/utils/dom/floating-ui.utils.dom.umd.js +192 -0
  82. package/node_modules/@floating-ui/utils/dom/package.json +6 -0
  83. package/node_modules/@floating-ui/utils/package.json +70 -0
  84. package/node_modules/@radix-ui/primitive/LICENSE +21 -0
  85. package/node_modules/@radix-ui/primitive/README.md +3 -0
  86. package/node_modules/@radix-ui/primitive/dist/index.d.mts +20 -0
  87. package/node_modules/@radix-ui/primitive/dist/index.d.ts +20 -0
  88. package/node_modules/@radix-ui/primitive/dist/index.js +76 -0
  89. package/node_modules/@radix-ui/primitive/dist/index.js.map +7 -0
  90. package/node_modules/@radix-ui/primitive/dist/index.mjs +53 -0
  91. package/node_modules/@radix-ui/primitive/dist/index.mjs.map +7 -0
  92. package/node_modules/@radix-ui/primitive/package.json +47 -0
  93. package/node_modules/@radix-ui/react-collapsible/LICENSE +21 -0
  94. package/node_modules/@radix-ui/react-collapsible/README.md +3 -0
  95. package/node_modules/@radix-ui/react-collapsible/dist/index.d.mts +33 -0
  96. package/node_modules/@radix-ui/react-collapsible/dist/index.d.ts +33 -0
  97. package/node_modules/@radix-ui/react-collapsible/dist/index.js +187 -0
  98. package/node_modules/@radix-ui/react-collapsible/dist/index.js.map +7 -0
  99. package/node_modules/@radix-ui/react-collapsible/dist/index.mjs +155 -0
  100. package/node_modules/@radix-ui/react-collapsible/dist/index.mjs.map +7 -0
  101. package/node_modules/@radix-ui/react-collapsible/package.json +75 -0
  102. package/node_modules/@radix-ui/react-compose-refs/README.md +13 -0
  103. package/node_modules/@radix-ui/react-compose-refs/dist/index.d.mts +15 -0
  104. package/node_modules/@radix-ui/react-compose-refs/dist/index.d.ts +15 -0
  105. package/node_modules/@radix-ui/react-compose-refs/dist/index.js +74 -0
  106. package/node_modules/@radix-ui/react-compose-refs/dist/index.js.map +7 -0
  107. package/node_modules/@radix-ui/react-compose-refs/dist/index.mjs +41 -0
  108. package/node_modules/@radix-ui/react-compose-refs/dist/index.mjs.map +7 -0
  109. package/node_modules/@radix-ui/react-compose-refs/package.json +75 -0
  110. package/node_modules/@radix-ui/react-context/README.md +13 -0
  111. package/node_modules/@radix-ui/react-context/dist/index.d.mts +21 -0
  112. package/node_modules/@radix-ui/react-context/dist/index.d.ts +21 -0
  113. package/node_modules/@radix-ui/react-context/dist/index.js +114 -0
  114. package/node_modules/@radix-ui/react-context/dist/index.js.map +7 -0
  115. package/node_modules/@radix-ui/react-context/dist/index.mjs +81 -0
  116. package/node_modules/@radix-ui/react-context/dist/index.mjs.map +7 -0
  117. package/node_modules/@radix-ui/react-context/package.json +75 -0
  118. package/node_modules/@radix-ui/react-id/README.md +13 -0
  119. package/node_modules/@radix-ui/react-id/dist/index.d.mts +3 -0
  120. package/node_modules/@radix-ui/react-id/dist/index.d.ts +3 -0
  121. package/node_modules/@radix-ui/react-id/dist/index.js +49 -0
  122. package/node_modules/@radix-ui/react-id/dist/index.js.map +7 -0
  123. package/node_modules/@radix-ui/react-id/dist/index.mjs +16 -0
  124. package/node_modules/@radix-ui/react-id/dist/index.mjs.map +7 -0
  125. package/node_modules/@radix-ui/react-id/package.json +78 -0
  126. package/node_modules/@radix-ui/react-presence/LICENSE +21 -0
  127. package/node_modules/@radix-ui/react-presence/README.md +3 -0
  128. package/node_modules/@radix-ui/react-presence/dist/index.d.mts +12 -0
  129. package/node_modules/@radix-ui/react-presence/dist/index.d.ts +12 -0
  130. package/node_modules/@radix-ui/react-presence/dist/index.js +171 -0
  131. package/node_modules/@radix-ui/react-presence/dist/index.js.map +7 -0
  132. package/node_modules/@radix-ui/react-presence/dist/index.mjs +139 -0
  133. package/node_modules/@radix-ui/react-presence/dist/index.mjs.map +7 -0
  134. package/node_modules/@radix-ui/react-presence/package.json +69 -0
  135. package/node_modules/@radix-ui/react-primitive/LICENSE +21 -0
  136. package/node_modules/@radix-ui/react-primitive/README.md +3 -0
  137. package/node_modules/@radix-ui/react-primitive/dist/index.d.mts +52 -0
  138. package/node_modules/@radix-ui/react-primitive/dist/index.d.ts +52 -0
  139. package/node_modules/@radix-ui/react-primitive/dist/index.js +80 -0
  140. package/node_modules/@radix-ui/react-primitive/dist/index.js.map +7 -0
  141. package/node_modules/@radix-ui/react-primitive/dist/index.mjs +47 -0
  142. package/node_modules/@radix-ui/react-primitive/dist/index.mjs.map +7 -0
  143. package/node_modules/@radix-ui/react-primitive/package.json +68 -0
  144. package/node_modules/@radix-ui/react-slot/LICENSE +21 -0
  145. package/node_modules/@radix-ui/react-slot/README.md +3 -0
  146. package/node_modules/@radix-ui/react-slot/dist/index.d.mts +17 -0
  147. package/node_modules/@radix-ui/react-slot/dist/index.d.ts +17 -0
  148. package/node_modules/@radix-ui/react-slot/dist/index.js +138 -0
  149. package/node_modules/@radix-ui/react-slot/dist/index.js.map +7 -0
  150. package/node_modules/@radix-ui/react-slot/dist/index.mjs +105 -0
  151. package/node_modules/@radix-ui/react-slot/dist/index.mjs.map +7 -0
  152. package/node_modules/@radix-ui/react-slot/package.json +63 -0
  153. package/node_modules/@radix-ui/react-use-controllable-state/LICENSE +21 -0
  154. package/node_modules/@radix-ui/react-use-controllable-state/README.md +3 -0
  155. package/node_modules/@radix-ui/react-use-controllable-state/dist/index.d.mts +40 -0
  156. package/node_modules/@radix-ui/react-use-controllable-state/dist/index.d.ts +40 -0
  157. package/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +169 -0
  158. package/node_modules/@radix-ui/react-use-controllable-state/dist/index.js.map +7 -0
  159. package/node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs +136 -0
  160. package/node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs.map +7 -0
  161. package/node_modules/@radix-ui/react-use-controllable-state/package.json +64 -0
  162. package/node_modules/@radix-ui/react-use-effect-event/LICENSE +21 -0
  163. package/node_modules/@radix-ui/react-use-effect-event/README.md +5 -0
  164. package/node_modules/@radix-ui/react-use-effect-event/dist/index.d.mts +8 -0
  165. package/node_modules/@radix-ui/react-use-effect-event/dist/index.d.ts +8 -0
  166. package/node_modules/@radix-ui/react-use-effect-event/dist/index.js +60 -0
  167. package/node_modules/@radix-ui/react-use-effect-event/dist/index.js.map +7 -0
  168. package/node_modules/@radix-ui/react-use-effect-event/dist/index.mjs +27 -0
  169. package/node_modules/@radix-ui/react-use-effect-event/dist/index.mjs.map +7 -0
  170. package/node_modules/@radix-ui/react-use-effect-event/package.json +65 -0
  171. package/node_modules/@radix-ui/react-use-effect-event/src/index.ts +1 -0
  172. package/node_modules/@radix-ui/react-use-effect-event/src/use-effect-event.tsx +36 -0
  173. package/node_modules/@radix-ui/react-use-layout-effect/README.md +13 -0
  174. package/node_modules/@radix-ui/react-use-layout-effect/dist/index.d.mts +12 -0
  175. package/node_modules/@radix-ui/react-use-layout-effect/dist/index.d.ts +12 -0
  176. package/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +41 -0
  177. package/node_modules/@radix-ui/react-use-layout-effect/dist/index.js.map +7 -0
  178. package/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs +8 -0
  179. package/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs.map +7 -0
  180. package/node_modules/@radix-ui/react-use-layout-effect/package.json +75 -0
  181. package/node_modules/@remirror/core-constants/LICENSE +21 -0
  182. package/node_modules/@remirror/core-constants/dist/_tsup-dts-rollup.d.cts +612 -0
  183. package/node_modules/@remirror/core-constants/dist/_tsup-dts-rollup.d.ts +612 -0
  184. package/node_modules/@remirror/core-constants/dist/remirror-core-constants.cjs +314 -0
  185. package/node_modules/@remirror/core-constants/dist/remirror-core-constants.d.cts +20 -0
  186. package/node_modules/@remirror/core-constants/dist/remirror-core-constants.d.ts +20 -0
  187. package/node_modules/@remirror/core-constants/dist/remirror-core-constants.js +269 -0
  188. package/node_modules/@remirror/core-constants/dist-types/core-constants.d.ts +431 -0
  189. package/node_modules/@remirror/core-constants/dist-types/error-constants.d.ts +119 -0
  190. package/node_modules/@remirror/core-constants/dist-types/index.d.ts +2 -0
  191. package/node_modules/@remirror/core-constants/dist-types/tsconfig.tsbuildinfo +1 -0
  192. package/node_modules/@remirror/core-constants/package.json +45 -0
  193. package/node_modules/@remirror/core-constants/readme.md +17 -0
  194. package/node_modules/@tiptap/core/LICENSE.md +21 -0
  195. package/node_modules/@tiptap/core/README.md +18 -0
  196. package/node_modules/@tiptap/core/dist/index.cjs +7126 -0
  197. package/node_modules/@tiptap/core/dist/index.cjs.map +1 -0
  198. package/node_modules/@tiptap/core/dist/index.d.cts +4954 -0
  199. package/node_modules/@tiptap/core/dist/index.d.ts +4954 -0
  200. package/node_modules/@tiptap/core/dist/index.js +6992 -0
  201. package/node_modules/@tiptap/core/dist/index.js.map +1 -0
  202. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.cjs +56 -0
  203. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.cjs.map +1 -0
  204. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.d.cts +23 -0
  205. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.d.ts +23 -0
  206. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +26 -0
  207. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js.map +1 -0
  208. package/node_modules/@tiptap/core/jsx-dev-runtime/index.cjs +1 -0
  209. package/node_modules/@tiptap/core/jsx-dev-runtime/index.d.cts +1 -0
  210. package/node_modules/@tiptap/core/jsx-dev-runtime/index.d.ts +1 -0
  211. package/node_modules/@tiptap/core/jsx-dev-runtime/index.js +1 -0
  212. package/node_modules/@tiptap/core/jsx-runtime/index.cjs +1 -0
  213. package/node_modules/@tiptap/core/jsx-runtime/index.d.cts +1 -0
  214. package/node_modules/@tiptap/core/jsx-runtime/index.d.ts +1 -0
  215. package/node_modules/@tiptap/core/jsx-runtime/index.js +1 -0
  216. package/node_modules/@tiptap/core/package.json +70 -0
  217. package/node_modules/@tiptap/core/src/CommandManager.ts +138 -0
  218. package/node_modules/@tiptap/core/src/Editor.ts +806 -0
  219. package/node_modules/@tiptap/core/src/EventEmitter.ts +58 -0
  220. package/node_modules/@tiptap/core/src/Extendable.ts +602 -0
  221. package/node_modules/@tiptap/core/src/Extension.ts +55 -0
  222. package/node_modules/@tiptap/core/src/ExtensionManager.ts +440 -0
  223. package/node_modules/@tiptap/core/src/InputRule.ts +290 -0
  224. package/node_modules/@tiptap/core/src/Mark.ts +211 -0
  225. package/node_modules/@tiptap/core/src/MarkView.ts +122 -0
  226. package/node_modules/@tiptap/core/src/Node.ts +377 -0
  227. package/node_modules/@tiptap/core/src/NodePos.ts +257 -0
  228. package/node_modules/@tiptap/core/src/NodeView.ts +339 -0
  229. package/node_modules/@tiptap/core/src/PasteRule.ts +373 -0
  230. package/node_modules/@tiptap/core/src/Tracker.ts +36 -0
  231. package/node_modules/@tiptap/core/src/__tests__/transformPastedHTML.test.ts +575 -0
  232. package/node_modules/@tiptap/core/src/commands/blur.ts +29 -0
  233. package/node_modules/@tiptap/core/src/commands/clearContent.ts +25 -0
  234. package/node_modules/@tiptap/core/src/commands/clearNodes.ts +57 -0
  235. package/node_modules/@tiptap/core/src/commands/command.ts +22 -0
  236. package/node_modules/@tiptap/core/src/commands/createParagraphNear.ts +21 -0
  237. package/node_modules/@tiptap/core/src/commands/cut.ts +36 -0
  238. package/node_modules/@tiptap/core/src/commands/deleteCurrentNode.ts +44 -0
  239. package/node_modules/@tiptap/core/src/commands/deleteNode.ts +41 -0
  240. package/node_modules/@tiptap/core/src/commands/deleteRange.ts +26 -0
  241. package/node_modules/@tiptap/core/src/commands/deleteSelection.ts +21 -0
  242. package/node_modules/@tiptap/core/src/commands/enter.ts +19 -0
  243. package/node_modules/@tiptap/core/src/commands/exitCode.ts +21 -0
  244. package/node_modules/@tiptap/core/src/commands/extendMarkRange.ts +51 -0
  245. package/node_modules/@tiptap/core/src/commands/first.ts +26 -0
  246. package/node_modules/@tiptap/core/src/commands/focus.ts +108 -0
  247. package/node_modules/@tiptap/core/src/commands/forEach.ts +24 -0
  248. package/node_modules/@tiptap/core/src/commands/index.ts +57 -0
  249. package/node_modules/@tiptap/core/src/commands/insertContent.ts +46 -0
  250. package/node_modules/@tiptap/core/src/commands/insertContentAt.ts +212 -0
  251. package/node_modules/@tiptap/core/src/commands/join.ts +69 -0
  252. package/node_modules/@tiptap/core/src/commands/joinItemBackward.ts +37 -0
  253. package/node_modules/@tiptap/core/src/commands/joinItemForward.ts +37 -0
  254. package/node_modules/@tiptap/core/src/commands/joinTextblockBackward.ts +20 -0
  255. package/node_modules/@tiptap/core/src/commands/joinTextblockForward.ts +20 -0
  256. package/node_modules/@tiptap/core/src/commands/keyboardShortcut.ts +100 -0
  257. package/node_modules/@tiptap/core/src/commands/lift.ts +34 -0
  258. package/node_modules/@tiptap/core/src/commands/liftEmptyBlock.ts +21 -0
  259. package/node_modules/@tiptap/core/src/commands/liftListItem.ts +26 -0
  260. package/node_modules/@tiptap/core/src/commands/newlineInCode.ts +21 -0
  261. package/node_modules/@tiptap/core/src/commands/resetAttributes.ts +73 -0
  262. package/node_modules/@tiptap/core/src/commands/scrollIntoView.ts +23 -0
  263. package/node_modules/@tiptap/core/src/commands/selectAll.ts +27 -0
  264. package/node_modules/@tiptap/core/src/commands/selectNodeBackward.ts +21 -0
  265. package/node_modules/@tiptap/core/src/commands/selectNodeForward.ts +21 -0
  266. package/node_modules/@tiptap/core/src/commands/selectParentNode.ts +21 -0
  267. package/node_modules/@tiptap/core/src/commands/selectTextblockEnd.ts +23 -0
  268. package/node_modules/@tiptap/core/src/commands/selectTextblockStart.ts +23 -0
  269. package/node_modules/@tiptap/core/src/commands/setContent.ts +76 -0
  270. package/node_modules/@tiptap/core/src/commands/setMark.ts +118 -0
  271. package/node_modules/@tiptap/core/src/commands/setMeta.ts +25 -0
  272. package/node_modules/@tiptap/core/src/commands/setNode.ts +57 -0
  273. package/node_modules/@tiptap/core/src/commands/setNodeSelection.ts +31 -0
  274. package/node_modules/@tiptap/core/src/commands/setTextDirection.ts +51 -0
  275. package/node_modules/@tiptap/core/src/commands/setTextSelection.ts +35 -0
  276. package/node_modules/@tiptap/core/src/commands/sinkListItem.ts +26 -0
  277. package/node_modules/@tiptap/core/src/commands/splitBlock.ts +115 -0
  278. package/node_modules/@tiptap/core/src/commands/splitListItem.ts +149 -0
  279. package/node_modules/@tiptap/core/src/commands/toggleList.ts +159 -0
  280. package/node_modules/@tiptap/core/src/commands/toggleMark.ts +51 -0
  281. package/node_modules/@tiptap/core/src/commands/toggleNode.ts +47 -0
  282. package/node_modules/@tiptap/core/src/commands/toggleWrap.ts +32 -0
  283. package/node_modules/@tiptap/core/src/commands/undoInputRule.ts +49 -0
  284. package/node_modules/@tiptap/core/src/commands/unsetAllMarks.ts +32 -0
  285. package/node_modules/@tiptap/core/src/commands/unsetMark.ts +65 -0
  286. package/node_modules/@tiptap/core/src/commands/unsetTextDirection.ts +51 -0
  287. package/node_modules/@tiptap/core/src/commands/updateAttributes.ts +150 -0
  288. package/node_modules/@tiptap/core/src/commands/wrapIn.ts +27 -0
  289. package/node_modules/@tiptap/core/src/commands/wrapInList.ts +27 -0
  290. package/node_modules/@tiptap/core/src/extensions/clipboardTextSerializer.ts +44 -0
  291. package/node_modules/@tiptap/core/src/extensions/commands.ts +14 -0
  292. package/node_modules/@tiptap/core/src/extensions/delete.ts +89 -0
  293. package/node_modules/@tiptap/core/src/extensions/drop.ts +26 -0
  294. package/node_modules/@tiptap/core/src/extensions/editable.ts +18 -0
  295. package/node_modules/@tiptap/core/src/extensions/focusEvents.ts +41 -0
  296. package/node_modules/@tiptap/core/src/extensions/index.ts +10 -0
  297. package/node_modules/@tiptap/core/src/extensions/keymap.ts +160 -0
  298. package/node_modules/@tiptap/core/src/extensions/paste.ts +25 -0
  299. package/node_modules/@tiptap/core/src/extensions/tabindex.ts +18 -0
  300. package/node_modules/@tiptap/core/src/extensions/textDirection.ts +86 -0
  301. package/node_modules/@tiptap/core/src/helpers/MappablePosition.ts +66 -0
  302. package/node_modules/@tiptap/core/src/helpers/combineTransactionSteps.ts +21 -0
  303. package/node_modules/@tiptap/core/src/helpers/createChainableState.ts +39 -0
  304. package/node_modules/@tiptap/core/src/helpers/createDocument.ts +24 -0
  305. package/node_modules/@tiptap/core/src/helpers/createNodeFromContent.ts +119 -0
  306. package/node_modules/@tiptap/core/src/helpers/defaultBlockAt.ts +18 -0
  307. package/node_modules/@tiptap/core/src/helpers/findChildren.ts +24 -0
  308. package/node_modules/@tiptap/core/src/helpers/findChildrenInRange.ts +36 -0
  309. package/node_modules/@tiptap/core/src/helpers/findParentNode.ts +18 -0
  310. package/node_modules/@tiptap/core/src/helpers/findParentNodeClosestToPos.ts +37 -0
  311. package/node_modules/@tiptap/core/src/helpers/flattenExtensions.ts +30 -0
  312. package/node_modules/@tiptap/core/src/helpers/generateHTML.ts +18 -0
  313. package/node_modules/@tiptap/core/src/helpers/generateJSON.ts +18 -0
  314. package/node_modules/@tiptap/core/src/helpers/generateText.ts +34 -0
  315. package/node_modules/@tiptap/core/src/helpers/getAttributes.ts +29 -0
  316. package/node_modules/@tiptap/core/src/helpers/getAttributesFromExtensions.ts +122 -0
  317. package/node_modules/@tiptap/core/src/helpers/getChangedRanges.ts +85 -0
  318. package/node_modules/@tiptap/core/src/helpers/getDebugJSON.ts +54 -0
  319. package/node_modules/@tiptap/core/src/helpers/getExtensionField.ts +32 -0
  320. package/node_modules/@tiptap/core/src/helpers/getHTMLFromFragment.ts +13 -0
  321. package/node_modules/@tiptap/core/src/helpers/getMarkAttributes.ts +30 -0
  322. package/node_modules/@tiptap/core/src/helpers/getMarkRange.ts +90 -0
  323. package/node_modules/@tiptap/core/src/helpers/getMarkType.ts +13 -0
  324. package/node_modules/@tiptap/core/src/helpers/getMarksBetween.ts +44 -0
  325. package/node_modules/@tiptap/core/src/helpers/getNodeAtPosition.ts +29 -0
  326. package/node_modules/@tiptap/core/src/helpers/getNodeAttributes.ts +22 -0
  327. package/node_modules/@tiptap/core/src/helpers/getNodeType.ts +13 -0
  328. package/node_modules/@tiptap/core/src/helpers/getRenderedAttributes.ts +23 -0
  329. package/node_modules/@tiptap/core/src/helpers/getSchema.ts +12 -0
  330. package/node_modules/@tiptap/core/src/helpers/getSchemaByResolvedExtensions.ts +183 -0
  331. package/node_modules/@tiptap/core/src/helpers/getSchemaTypeByName.ts +11 -0
  332. package/node_modules/@tiptap/core/src/helpers/getSchemaTypeNameByName.ts +19 -0
  333. package/node_modules/@tiptap/core/src/helpers/getSplittedAttributes.ts +28 -0
  334. package/node_modules/@tiptap/core/src/helpers/getText.ts +28 -0
  335. package/node_modules/@tiptap/core/src/helpers/getTextBetween.ts +52 -0
  336. package/node_modules/@tiptap/core/src/helpers/getTextContentFromNodes.ts +29 -0
  337. package/node_modules/@tiptap/core/src/helpers/getTextSerializersFromSchema.ts +16 -0
  338. package/node_modules/@tiptap/core/src/helpers/index.ts +55 -0
  339. package/node_modules/@tiptap/core/src/helpers/injectExtensionAttributesToParseRule.ts +47 -0
  340. package/node_modules/@tiptap/core/src/helpers/isActive.ts +23 -0
  341. package/node_modules/@tiptap/core/src/helpers/isAtEndOfNode.ts +29 -0
  342. package/node_modules/@tiptap/core/src/helpers/isAtStartOfNode.ts +11 -0
  343. package/node_modules/@tiptap/core/src/helpers/isExtensionRulesEnabled.ts +13 -0
  344. package/node_modules/@tiptap/core/src/helpers/isList.ts +27 -0
  345. package/node_modules/@tiptap/core/src/helpers/isMarkActive.ts +94 -0
  346. package/node_modules/@tiptap/core/src/helpers/isNodeActive.ts +51 -0
  347. package/node_modules/@tiptap/core/src/helpers/isNodeEmpty.ts +62 -0
  348. package/node_modules/@tiptap/core/src/helpers/isNodeSelection.ts +5 -0
  349. package/node_modules/@tiptap/core/src/helpers/isTextSelection.ts +5 -0
  350. package/node_modules/@tiptap/core/src/helpers/posToDOMRect.ts +35 -0
  351. package/node_modules/@tiptap/core/src/helpers/resolveExtensions.ts +25 -0
  352. package/node_modules/@tiptap/core/src/helpers/resolveFocusPosition.ts +31 -0
  353. package/node_modules/@tiptap/core/src/helpers/rewriteUnknownContent.ts +149 -0
  354. package/node_modules/@tiptap/core/src/helpers/selectionToInsertionEnd.ts +29 -0
  355. package/node_modules/@tiptap/core/src/helpers/sortExtensions.ts +26 -0
  356. package/node_modules/@tiptap/core/src/helpers/splitExtensions.ts +16 -0
  357. package/node_modules/@tiptap/core/src/index.ts +28 -0
  358. package/node_modules/@tiptap/core/src/inputRules/index.ts +5 -0
  359. package/node_modules/@tiptap/core/src/inputRules/markInputRule.ts +68 -0
  360. package/node_modules/@tiptap/core/src/inputRules/nodeInputRule.ts +73 -0
  361. package/node_modules/@tiptap/core/src/inputRules/textInputRule.ts +35 -0
  362. package/node_modules/@tiptap/core/src/inputRules/textblockTypeInputRule.ts +35 -0
  363. package/node_modules/@tiptap/core/src/inputRules/wrappingInputRule.ts +82 -0
  364. package/node_modules/@tiptap/core/src/jsx-runtime.ts +65 -0
  365. package/node_modules/@tiptap/core/src/lib/ResizableNodeView.ts +1060 -0
  366. package/node_modules/@tiptap/core/src/lib/index.ts +1 -0
  367. package/node_modules/@tiptap/core/src/pasteRules/index.ts +3 -0
  368. package/node_modules/@tiptap/core/src/pasteRules/markPasteRule.ts +71 -0
  369. package/node_modules/@tiptap/core/src/pasteRules/nodePasteRule.ts +44 -0
  370. package/node_modules/@tiptap/core/src/pasteRules/textPasteRule.ts +34 -0
  371. package/node_modules/@tiptap/core/src/style.ts +71 -0
  372. package/node_modules/@tiptap/core/src/types.ts +1058 -0
  373. package/node_modules/@tiptap/core/src/utilities/callOrReturn.ts +21 -0
  374. package/node_modules/@tiptap/core/src/utilities/canInsertNode.ts +30 -0
  375. package/node_modules/@tiptap/core/src/utilities/createStyleTag.ts +21 -0
  376. package/node_modules/@tiptap/core/src/utilities/deleteProps.ts +16 -0
  377. package/node_modules/@tiptap/core/src/utilities/elementFromString.ts +27 -0
  378. package/node_modules/@tiptap/core/src/utilities/escapeForRegEx.ts +4 -0
  379. package/node_modules/@tiptap/core/src/utilities/findDuplicates.ts +8 -0
  380. package/node_modules/@tiptap/core/src/utilities/fromString.ts +19 -0
  381. package/node_modules/@tiptap/core/src/utilities/index.ts +26 -0
  382. package/node_modules/@tiptap/core/src/utilities/isAndroid.ts +3 -0
  383. package/node_modules/@tiptap/core/src/utilities/isEmptyObject.ts +3 -0
  384. package/node_modules/@tiptap/core/src/utilities/isFirefox.ts +11 -0
  385. package/node_modules/@tiptap/core/src/utilities/isFunction.ts +4 -0
  386. package/node_modules/@tiptap/core/src/utilities/isMacOS.ts +3 -0
  387. package/node_modules/@tiptap/core/src/utilities/isNumber.ts +3 -0
  388. package/node_modules/@tiptap/core/src/utilities/isPlainObject.ts +13 -0
  389. package/node_modules/@tiptap/core/src/utilities/isRegExp.ts +3 -0
  390. package/node_modules/@tiptap/core/src/utilities/isSafari.ts +11 -0
  391. package/node_modules/@tiptap/core/src/utilities/isString.ts +3 -0
  392. package/node_modules/@tiptap/core/src/utilities/isiOS.ts +7 -0
  393. package/node_modules/@tiptap/core/src/utilities/markdown/attributeUtils.ts +130 -0
  394. package/node_modules/@tiptap/core/src/utilities/markdown/createAtomBlockMarkdownSpec.ts +141 -0
  395. package/node_modules/@tiptap/core/src/utilities/markdown/createBlockMarkdownSpec.ts +225 -0
  396. package/node_modules/@tiptap/core/src/utilities/markdown/createInlineMarkdownSpec.ts +282 -0
  397. package/node_modules/@tiptap/core/src/utilities/markdown/index.ts +13 -0
  398. package/node_modules/@tiptap/core/src/utilities/markdown/parseIndentedBlocks.ts +194 -0
  399. package/node_modules/@tiptap/core/src/utilities/markdown/renderNestedMarkdownContent.ts +96 -0
  400. package/node_modules/@tiptap/core/src/utilities/mergeAttributes.ts +109 -0
  401. package/node_modules/@tiptap/core/src/utilities/mergeDeep.ts +17 -0
  402. package/node_modules/@tiptap/core/src/utilities/minMax.ts +3 -0
  403. package/node_modules/@tiptap/core/src/utilities/objectIncludes.ts +30 -0
  404. package/node_modules/@tiptap/core/src/utilities/removeDuplicates.ts +13 -0
  405. package/node_modules/@tiptap/extension-bubble-menu/LICENSE.md +21 -0
  406. package/node_modules/@tiptap/extension-bubble-menu/README.md +18 -0
  407. package/node_modules/@tiptap/extension-bubble-menu/dist/index.cjs +462 -0
  408. package/node_modules/@tiptap/extension-bubble-menu/dist/index.cjs.map +1 -0
  409. package/node_modules/@tiptap/extension-bubble-menu/dist/index.d.cts +169 -0
  410. package/node_modules/@tiptap/extension-bubble-menu/dist/index.d.ts +169 -0
  411. package/node_modules/@tiptap/extension-bubble-menu/dist/index.js +443 -0
  412. package/node_modules/@tiptap/extension-bubble-menu/dist/index.js.map +1 -0
  413. package/node_modules/@tiptap/extension-bubble-menu/package.json +54 -0
  414. package/node_modules/@tiptap/extension-bubble-menu/src/bubble-menu-plugin.ts +650 -0
  415. package/node_modules/@tiptap/extension-bubble-menu/src/bubble-menu.ts +50 -0
  416. package/node_modules/@tiptap/extension-bubble-menu/src/index.ts +6 -0
  417. package/node_modules/@tiptap/extension-floating-menu/LICENSE.md +21 -0
  418. package/node_modules/@tiptap/extension-floating-menu/README.md +18 -0
  419. package/node_modules/@tiptap/extension-floating-menu/dist/index.cjs +380 -0
  420. package/node_modules/@tiptap/extension-floating-menu/dist/index.cjs.map +1 -0
  421. package/node_modules/@tiptap/extension-floating-menu/dist/index.d.cts +179 -0
  422. package/node_modules/@tiptap/extension-floating-menu/dist/index.d.ts +179 -0
  423. package/node_modules/@tiptap/extension-floating-menu/dist/index.js +361 -0
  424. package/node_modules/@tiptap/extension-floating-menu/dist/index.js.map +1 -0
  425. package/node_modules/@tiptap/extension-floating-menu/package.json +53 -0
  426. package/node_modules/@tiptap/extension-floating-menu/src/floating-menu-plugin.ts +525 -0
  427. package/node_modules/@tiptap/extension-floating-menu/src/floating-menu.ts +77 -0
  428. package/node_modules/@tiptap/extension-floating-menu/src/index.ts +6 -0
  429. package/node_modules/@tiptap/extension-mention/LICENSE.md +21 -0
  430. package/node_modules/@tiptap/extension-mention/README.md +18 -0
  431. package/node_modules/@tiptap/extension-mention/dist/index.cjs +277 -0
  432. package/node_modules/@tiptap/extension-mention/dist/index.cjs.map +1 -0
  433. package/node_modules/@tiptap/extension-mention/dist/index.d.cts +93 -0
  434. package/node_modules/@tiptap/extension-mention/dist/index.d.ts +93 -0
  435. package/node_modules/@tiptap/extension-mention/dist/index.js +250 -0
  436. package/node_modules/@tiptap/extension-mention/dist/index.js.map +1 -0
  437. package/node_modules/@tiptap/extension-mention/package.json +52 -0
  438. package/node_modules/@tiptap/extension-mention/src/index.ts +5 -0
  439. package/node_modules/@tiptap/extension-mention/src/mention.ts +357 -0
  440. package/node_modules/@tiptap/extension-mention/src/utils/get-default-suggestion-attributes.ts +89 -0
  441. package/node_modules/@tiptap/pm/LICENSE.md +21 -0
  442. package/node_modules/@tiptap/pm/README.md +22 -0
  443. package/node_modules/@tiptap/pm/changeset/index.ts +1 -0
  444. package/node_modules/@tiptap/pm/collab/index.ts +1 -0
  445. package/node_modules/@tiptap/pm/commands/index.ts +1 -0
  446. package/node_modules/@tiptap/pm/dist/changeset/index.cjs +2 -0
  447. package/node_modules/@tiptap/pm/dist/changeset/index.d.cts +18 -0
  448. package/node_modules/@tiptap/pm/dist/changeset/index.d.ts +18 -0
  449. package/node_modules/@tiptap/pm/dist/changeset/index.js +2 -0
  450. package/node_modules/@tiptap/pm/dist/collab/index.cjs +2 -0
  451. package/node_modules/@tiptap/pm/dist/collab/index.d.cts +1 -0
  452. package/node_modules/@tiptap/pm/dist/collab/index.d.ts +1 -0
  453. package/node_modules/@tiptap/pm/dist/collab/index.js +2 -0
  454. package/node_modules/@tiptap/pm/dist/commands/index.cjs +2 -0
  455. package/node_modules/@tiptap/pm/dist/commands/index.d.cts +1 -0
  456. package/node_modules/@tiptap/pm/dist/commands/index.d.ts +1 -0
  457. package/node_modules/@tiptap/pm/dist/commands/index.js +2 -0
  458. package/node_modules/@tiptap/pm/dist/dropcursor/index.cjs +2 -0
  459. package/node_modules/@tiptap/pm/dist/dropcursor/index.d.cts +1 -0
  460. package/node_modules/@tiptap/pm/dist/dropcursor/index.d.ts +1 -0
  461. package/node_modules/@tiptap/pm/dist/dropcursor/index.js +2 -0
  462. package/node_modules/@tiptap/pm/dist/gapcursor/index.cjs +2 -0
  463. package/node_modules/@tiptap/pm/dist/gapcursor/index.d.cts +1 -0
  464. package/node_modules/@tiptap/pm/dist/gapcursor/index.d.ts +1 -0
  465. package/node_modules/@tiptap/pm/dist/gapcursor/index.js +2 -0
  466. package/node_modules/@tiptap/pm/dist/history/index.cjs +2 -0
  467. package/node_modules/@tiptap/pm/dist/history/index.d.cts +1 -0
  468. package/node_modules/@tiptap/pm/dist/history/index.d.ts +1 -0
  469. package/node_modules/@tiptap/pm/dist/history/index.js +2 -0
  470. package/node_modules/@tiptap/pm/dist/inputrules/index.cjs +2 -0
  471. package/node_modules/@tiptap/pm/dist/inputrules/index.d.cts +1 -0
  472. package/node_modules/@tiptap/pm/dist/inputrules/index.d.ts +1 -0
  473. package/node_modules/@tiptap/pm/dist/inputrules/index.js +2 -0
  474. package/node_modules/@tiptap/pm/dist/keymap/index.cjs +2 -0
  475. package/node_modules/@tiptap/pm/dist/keymap/index.d.cts +1 -0
  476. package/node_modules/@tiptap/pm/dist/keymap/index.d.ts +1 -0
  477. package/node_modules/@tiptap/pm/dist/keymap/index.js +2 -0
  478. package/node_modules/@tiptap/pm/dist/markdown/index.cjs +2 -0
  479. package/node_modules/@tiptap/pm/dist/markdown/index.d.cts +1 -0
  480. package/node_modules/@tiptap/pm/dist/markdown/index.d.ts +1 -0
  481. package/node_modules/@tiptap/pm/dist/markdown/index.js +2 -0
  482. package/node_modules/@tiptap/pm/dist/menu/index.cjs +2 -0
  483. package/node_modules/@tiptap/pm/dist/menu/index.d.cts +1 -0
  484. package/node_modules/@tiptap/pm/dist/menu/index.d.ts +1 -0
  485. package/node_modules/@tiptap/pm/dist/menu/index.js +2 -0
  486. package/node_modules/@tiptap/pm/dist/model/index.cjs +2 -0
  487. package/node_modules/@tiptap/pm/dist/model/index.d.cts +1 -0
  488. package/node_modules/@tiptap/pm/dist/model/index.d.ts +1 -0
  489. package/node_modules/@tiptap/pm/dist/model/index.js +2 -0
  490. package/node_modules/@tiptap/pm/dist/schema-basic/index.cjs +2 -0
  491. package/node_modules/@tiptap/pm/dist/schema-basic/index.d.cts +1 -0
  492. package/node_modules/@tiptap/pm/dist/schema-basic/index.d.ts +1 -0
  493. package/node_modules/@tiptap/pm/dist/schema-basic/index.js +2 -0
  494. package/node_modules/@tiptap/pm/dist/schema-list/index.cjs +2 -0
  495. package/node_modules/@tiptap/pm/dist/schema-list/index.d.cts +1 -0
  496. package/node_modules/@tiptap/pm/dist/schema-list/index.d.ts +1 -0
  497. package/node_modules/@tiptap/pm/dist/schema-list/index.js +2 -0
  498. package/node_modules/@tiptap/pm/dist/state/index.cjs +2 -0
  499. package/node_modules/@tiptap/pm/dist/state/index.d.cts +1 -0
  500. package/node_modules/@tiptap/pm/dist/state/index.d.ts +1 -0
  501. package/node_modules/@tiptap/pm/dist/state/index.js +2 -0
  502. package/node_modules/@tiptap/pm/dist/tables/index.cjs +2 -0
  503. package/node_modules/@tiptap/pm/dist/tables/index.d.cts +1 -0
  504. package/node_modules/@tiptap/pm/dist/tables/index.d.ts +1 -0
  505. package/node_modules/@tiptap/pm/dist/tables/index.js +2 -0
  506. package/node_modules/@tiptap/pm/dist/trailing-node/index.cjs +2 -0
  507. package/node_modules/@tiptap/pm/dist/trailing-node/index.d.cts +1 -0
  508. package/node_modules/@tiptap/pm/dist/trailing-node/index.d.ts +1 -0
  509. package/node_modules/@tiptap/pm/dist/trailing-node/index.js +2 -0
  510. package/node_modules/@tiptap/pm/dist/transform/index.cjs +2 -0
  511. package/node_modules/@tiptap/pm/dist/transform/index.d.cts +1 -0
  512. package/node_modules/@tiptap/pm/dist/transform/index.d.ts +1 -0
  513. package/node_modules/@tiptap/pm/dist/transform/index.js +2 -0
  514. package/node_modules/@tiptap/pm/dist/view/index.cjs +2 -0
  515. package/node_modules/@tiptap/pm/dist/view/index.d.cts +1 -0
  516. package/node_modules/@tiptap/pm/dist/view/index.d.ts +1 -0
  517. package/node_modules/@tiptap/pm/dist/view/index.js +2 -0
  518. package/node_modules/@tiptap/pm/dropcursor/index.ts +1 -0
  519. package/node_modules/@tiptap/pm/gapcursor/index.ts +1 -0
  520. package/node_modules/@tiptap/pm/history/index.ts +1 -0
  521. package/node_modules/@tiptap/pm/inputrules/index.ts +1 -0
  522. package/node_modules/@tiptap/pm/keymap/index.ts +1 -0
  523. package/node_modules/@tiptap/pm/markdown/index.ts +1 -0
  524. package/node_modules/@tiptap/pm/menu/index.ts +1 -0
  525. package/node_modules/@tiptap/pm/model/index.ts +1 -0
  526. package/node_modules/@tiptap/pm/package.json +211 -0
  527. package/node_modules/@tiptap/pm/schema-basic/index.ts +1 -0
  528. package/node_modules/@tiptap/pm/schema-list/index.ts +1 -0
  529. package/node_modules/@tiptap/pm/state/index.ts +1 -0
  530. package/node_modules/@tiptap/pm/tables/index.ts +1 -0
  531. package/node_modules/@tiptap/pm/trailing-node/index.ts +1 -0
  532. package/node_modules/@tiptap/pm/transform/index.ts +1 -0
  533. package/node_modules/@tiptap/pm/view/index.ts +1 -0
  534. package/node_modules/@tiptap/react/LICENSE.md +21 -0
  535. package/node_modules/@tiptap/react/README.md +18 -0
  536. package/node_modules/@tiptap/react/dist/index.cjs +1195 -0
  537. package/node_modules/@tiptap/react/dist/index.cjs.map +1 -0
  538. package/node_modules/@tiptap/react/dist/index.d.cts +534 -0
  539. package/node_modules/@tiptap/react/dist/index.d.ts +534 -0
  540. package/node_modules/@tiptap/react/dist/index.js +1131 -0
  541. package/node_modules/@tiptap/react/dist/index.js.map +1 -0
  542. package/node_modules/@tiptap/react/dist/menus/index.cjs +499 -0
  543. package/node_modules/@tiptap/react/dist/menus/index.cjs.map +1 -0
  544. package/node_modules/@tiptap/react/dist/menus/index.d.cts +19 -0
  545. package/node_modules/@tiptap/react/dist/menus/index.d.ts +19 -0
  546. package/node_modules/@tiptap/react/dist/menus/index.js +461 -0
  547. package/node_modules/@tiptap/react/dist/menus/index.js.map +1 -0
  548. package/node_modules/@tiptap/react/package.json +76 -0
  549. package/node_modules/@tiptap/react/src/Context.tsx +60 -0
  550. package/node_modules/@tiptap/react/src/Editor.ts +13 -0
  551. package/node_modules/@tiptap/react/src/EditorContent.tsx +229 -0
  552. package/node_modules/@tiptap/react/src/NodeViewContent.tsx +30 -0
  553. package/node_modules/@tiptap/react/src/NodeViewWrapper.tsx +27 -0
  554. package/node_modules/@tiptap/react/src/ReactMarkViewRenderer.tsx +106 -0
  555. package/node_modules/@tiptap/react/src/ReactNodeViewRenderer.tsx +387 -0
  556. package/node_modules/@tiptap/react/src/ReactRenderer.tsx +282 -0
  557. package/node_modules/@tiptap/react/src/Tiptap.tsx +224 -0
  558. package/node_modules/@tiptap/react/src/index.ts +13 -0
  559. package/node_modules/@tiptap/react/src/menus/BubbleMenu.spec.ts +174 -0
  560. package/node_modules/@tiptap/react/src/menus/BubbleMenu.tsx +153 -0
  561. package/node_modules/@tiptap/react/src/menus/FloatingMenu.spec.ts +164 -0
  562. package/node_modules/@tiptap/react/src/menus/FloatingMenu.tsx +137 -0
  563. package/node_modules/@tiptap/react/src/menus/getAutoPluginKey.ts +5 -0
  564. package/node_modules/@tiptap/react/src/menus/index.ts +2 -0
  565. package/node_modules/@tiptap/react/src/menus/useMenuElementProps.ts +354 -0
  566. package/node_modules/@tiptap/react/src/types.ts +6 -0
  567. package/node_modules/@tiptap/react/src/useEditor.ts +382 -0
  568. package/node_modules/@tiptap/react/src/useEditorState.ts +173 -0
  569. package/node_modules/@tiptap/react/src/useReactNodeView.ts +28 -0
  570. package/node_modules/@tiptap/suggestion/LICENSE.md +21 -0
  571. package/node_modules/@tiptap/suggestion/README.md +18 -0
  572. package/node_modules/@tiptap/suggestion/dist/index.cjs +369 -0
  573. package/node_modules/@tiptap/suggestion/dist/index.cjs.map +1 -0
  574. package/node_modules/@tiptap/suggestion/dist/index.d.cts +213 -0
  575. package/node_modules/@tiptap/suggestion/dist/index.d.ts +213 -0
  576. package/node_modules/@tiptap/suggestion/dist/index.js +339 -0
  577. package/node_modules/@tiptap/suggestion/dist/index.js.map +1 -0
  578. package/node_modules/@tiptap/suggestion/package.json +50 -0
  579. package/node_modules/@tiptap/suggestion/src/__tests__/suggestion.test.ts +127 -0
  580. package/node_modules/@tiptap/suggestion/src/findSuggestionMatch.ts +79 -0
  581. package/node_modules/@tiptap/suggestion/src/index.ts +8 -0
  582. package/node_modules/@tiptap/suggestion/src/suggestion.ts +585 -0
  583. package/node_modules/@types/linkify-it/LICENSE +21 -0
  584. package/node_modules/@types/linkify-it/README.md +15 -0
  585. package/node_modules/@types/linkify-it/build/index.cjs.d.ts +178 -0
  586. package/node_modules/@types/linkify-it/index.d.mts +174 -0
  587. package/node_modules/@types/linkify-it/index.d.ts +3 -0
  588. package/node_modules/@types/linkify-it/package.json +50 -0
  589. package/node_modules/@types/markdown-it/LICENSE +21 -0
  590. package/node_modules/@types/markdown-it/README.md +15 -0
  591. package/node_modules/@types/markdown-it/dist/index.cjs.d.ts +1236 -0
  592. package/node_modules/@types/markdown-it/dist/markdown-it.d.ts +5 -0
  593. package/node_modules/@types/markdown-it/dist/markdown-it.min.d.ts +5 -0
  594. package/node_modules/@types/markdown-it/index.d.mts +1 -0
  595. package/node_modules/@types/markdown-it/index.d.ts +3 -0
  596. package/node_modules/@types/markdown-it/lib/common/html_blocks.d.mts +7 -0
  597. package/node_modules/@types/markdown-it/lib/common/html_re.d.mts +2 -0
  598. package/node_modules/@types/markdown-it/lib/common/utils.d.mts +62 -0
  599. package/node_modules/@types/markdown-it/lib/helpers/index.d.mts +5 -0
  600. package/node_modules/@types/markdown-it/lib/helpers/parse_link_destination.d.mts +7 -0
  601. package/node_modules/@types/markdown-it/lib/helpers/parse_link_label.d.mts +3 -0
  602. package/node_modules/@types/markdown-it/lib/helpers/parse_link_title.d.mts +29 -0
  603. package/node_modules/@types/markdown-it/lib/index.d.mts +404 -0
  604. package/node_modules/@types/markdown-it/lib/parser_block.d.mts +25 -0
  605. package/node_modules/@types/markdown-it/lib/parser_core.d.mts +18 -0
  606. package/node_modules/@types/markdown-it/lib/parser_inline.d.mts +38 -0
  607. package/node_modules/@types/markdown-it/lib/renderer.d.mts +96 -0
  608. package/node_modules/@types/markdown-it/lib/ruler.d.mts +158 -0
  609. package/node_modules/@types/markdown-it/lib/rules_block/state_block.d.mts +124 -0
  610. package/node_modules/@types/markdown-it/lib/rules_core/state_core.d.mts +18 -0
  611. package/node_modules/@types/markdown-it/lib/rules_inline/state_inline.d.mts +73 -0
  612. package/node_modules/@types/markdown-it/lib/token.d.mts +108 -0
  613. package/node_modules/@types/markdown-it/package.json +54 -0
  614. package/node_modules/@types/mdurl/LICENSE +21 -0
  615. package/node_modules/@types/mdurl/README.md +15 -0
  616. package/node_modules/@types/mdurl/build/index.cjs.d.ts +52 -0
  617. package/node_modules/@types/mdurl/index.d.mts +6 -0
  618. package/node_modules/@types/mdurl/index.d.ts +3 -0
  619. package/node_modules/@types/mdurl/lib/decode.d.mts +10 -0
  620. package/node_modules/@types/mdurl/lib/encode.d.mts +15 -0
  621. package/node_modules/@types/mdurl/lib/format.d.mts +3 -0
  622. package/node_modules/@types/mdurl/lib/parse.d.mts +18 -0
  623. package/node_modules/@types/mdurl/package.json +36 -0
  624. package/node_modules/@types/use-sync-external-store/LICENSE +21 -0
  625. package/node_modules/@types/use-sync-external-store/README.md +15 -0
  626. package/node_modules/@types/use-sync-external-store/index.d.ts +5 -0
  627. package/node_modules/@types/use-sync-external-store/package.json +30 -0
  628. package/node_modules/@types/use-sync-external-store/shim/index.d.ts +1 -0
  629. package/node_modules/@types/use-sync-external-store/shim/with-selector.d.ts +1 -0
  630. package/node_modules/@types/use-sync-external-store/with-selector.d.ts +7 -0
  631. package/node_modules/argparse/LICENSE +254 -0
  632. package/node_modules/argparse/README.md +84 -0
  633. package/node_modules/argparse/argparse.js +3707 -0
  634. package/node_modules/argparse/lib/sub.js +67 -0
  635. package/node_modules/argparse/lib/textwrap.js +440 -0
  636. package/node_modules/argparse/package.json +31 -0
  637. package/node_modules/crelt/LICENSE +19 -0
  638. package/node_modules/crelt/README.md +23 -0
  639. package/node_modules/crelt/dist/index.cjs +31 -0
  640. package/node_modules/crelt/dist/index.d.cts +4 -0
  641. package/node_modules/crelt/index.d.ts +4 -0
  642. package/node_modules/crelt/index.js +28 -0
  643. package/node_modules/crelt/package.json +35 -0
  644. package/node_modules/crelt/rollup.config.js +13 -0
  645. package/node_modules/entities/LICENSE +11 -0
  646. package/node_modules/entities/lib/decode.d.ts +211 -0
  647. package/node_modules/entities/lib/decode.d.ts.map +1 -0
  648. package/node_modules/entities/lib/decode.js +536 -0
  649. package/node_modules/entities/lib/decode.js.map +1 -0
  650. package/node_modules/entities/lib/decode_codepoint.d.ts +19 -0
  651. package/node_modules/entities/lib/decode_codepoint.d.ts.map +1 -0
  652. package/node_modules/entities/lib/decode_codepoint.js +76 -0
  653. package/node_modules/entities/lib/decode_codepoint.js.map +1 -0
  654. package/node_modules/entities/lib/encode.d.ts +22 -0
  655. package/node_modules/entities/lib/encode.d.ts.map +1 -0
  656. package/node_modules/entities/lib/encode.js +77 -0
  657. package/node_modules/entities/lib/encode.js.map +1 -0
  658. package/node_modules/entities/lib/escape.d.ts +43 -0
  659. package/node_modules/entities/lib/escape.d.ts.map +1 -0
  660. package/node_modules/entities/lib/escape.js +122 -0
  661. package/node_modules/entities/lib/escape.js.map +1 -0
  662. package/node_modules/entities/lib/esm/decode.d.ts +211 -0
  663. package/node_modules/entities/lib/esm/decode.d.ts.map +1 -0
  664. package/node_modules/entities/lib/esm/decode.js +496 -0
  665. package/node_modules/entities/lib/esm/decode.js.map +1 -0
  666. package/node_modules/entities/lib/esm/decode_codepoint.d.ts +19 -0
  667. package/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +1 -0
  668. package/node_modules/entities/lib/esm/decode_codepoint.js +71 -0
  669. package/node_modules/entities/lib/esm/decode_codepoint.js.map +1 -0
  670. package/node_modules/entities/lib/esm/encode.d.ts +22 -0
  671. package/node_modules/entities/lib/esm/encode.d.ts.map +1 -0
  672. package/node_modules/entities/lib/esm/encode.js +69 -0
  673. package/node_modules/entities/lib/esm/encode.js.map +1 -0
  674. package/node_modules/entities/lib/esm/escape.d.ts +43 -0
  675. package/node_modules/entities/lib/esm/escape.d.ts.map +1 -0
  676. package/node_modules/entities/lib/esm/escape.js +116 -0
  677. package/node_modules/entities/lib/esm/escape.js.map +1 -0
  678. package/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +3 -0
  679. package/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +1 -0
  680. package/node_modules/entities/lib/esm/generated/decode-data-html.js +7 -0
  681. package/node_modules/entities/lib/esm/generated/decode-data-html.js.map +1 -0
  682. package/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +3 -0
  683. package/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +1 -0
  684. package/node_modules/entities/lib/esm/generated/decode-data-xml.js +7 -0
  685. package/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +1 -0
  686. package/node_modules/entities/lib/esm/generated/encode-html.d.ts +8 -0
  687. package/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +1 -0
  688. package/node_modules/entities/lib/esm/generated/encode-html.js +10 -0
  689. package/node_modules/entities/lib/esm/generated/encode-html.js.map +1 -0
  690. package/node_modules/entities/lib/esm/index.d.ts +96 -0
  691. package/node_modules/entities/lib/esm/index.d.ts.map +1 -0
  692. package/node_modules/entities/lib/esm/index.js +99 -0
  693. package/node_modules/entities/lib/esm/index.js.map +1 -0
  694. package/node_modules/entities/lib/esm/package.json +1 -0
  695. package/node_modules/entities/lib/generated/decode-data-html.d.ts +3 -0
  696. package/node_modules/entities/lib/generated/decode-data-html.d.ts.map +1 -0
  697. package/node_modules/entities/lib/generated/decode-data-html.js +9 -0
  698. package/node_modules/entities/lib/generated/decode-data-html.js.map +1 -0
  699. package/node_modules/entities/lib/generated/decode-data-xml.d.ts +3 -0
  700. package/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +1 -0
  701. package/node_modules/entities/lib/generated/decode-data-xml.js +9 -0
  702. package/node_modules/entities/lib/generated/decode-data-xml.js.map +1 -0
  703. package/node_modules/entities/lib/generated/encode-html.d.ts +8 -0
  704. package/node_modules/entities/lib/generated/encode-html.d.ts.map +1 -0
  705. package/node_modules/entities/lib/generated/encode-html.js +12 -0
  706. package/node_modules/entities/lib/generated/encode-html.js.map +1 -0
  707. package/node_modules/entities/lib/index.d.ts +96 -0
  708. package/node_modules/entities/lib/index.d.ts.map +1 -0
  709. package/node_modules/entities/lib/index.js +126 -0
  710. package/node_modules/entities/lib/index.js.map +1 -0
  711. package/node_modules/entities/package.json +90 -0
  712. package/node_modules/entities/readme.md +122 -0
  713. package/node_modules/escape-string-regexp/index.d.ts +18 -0
  714. package/node_modules/escape-string-regexp/index.js +13 -0
  715. package/node_modules/escape-string-regexp/license +9 -0
  716. package/node_modules/escape-string-regexp/package.json +38 -0
  717. package/node_modules/escape-string-regexp/readme.md +34 -0
  718. package/node_modules/fast-equals/LICENSE +21 -0
  719. package/node_modules/fast-equals/README.md +477 -0
  720. package/node_modules/fast-equals/dist/cjs/comparator.d.cts +60 -0
  721. package/node_modules/fast-equals/dist/cjs/equals.d.cts +62 -0
  722. package/node_modules/fast-equals/dist/cjs/index.cjs +653 -0
  723. package/node_modules/fast-equals/dist/cjs/index.cjs.map +1 -0
  724. package/node_modules/fast-equals/dist/cjs/index.d.cts +66 -0
  725. package/node_modules/fast-equals/dist/cjs/internalTypes.d.cts +178 -0
  726. package/node_modules/fast-equals/dist/cjs/utils.d.cts +33 -0
  727. package/node_modules/fast-equals/dist/es/comparator.d.mts +60 -0
  728. package/node_modules/fast-equals/dist/es/equals.d.mts +62 -0
  729. package/node_modules/fast-equals/dist/es/index.d.mts +66 -0
  730. package/node_modules/fast-equals/dist/es/index.mjs +642 -0
  731. package/node_modules/fast-equals/dist/es/index.mjs.map +1 -0
  732. package/node_modules/fast-equals/dist/es/internalTypes.d.mts +178 -0
  733. package/node_modules/fast-equals/dist/es/utils.d.mts +33 -0
  734. package/node_modules/fast-equals/dist/umd/comparator.d.ts +26 -0
  735. package/node_modules/fast-equals/dist/umd/equals.d.ts +62 -0
  736. package/node_modules/fast-equals/dist/umd/index.d.ts +47 -0
  737. package/node_modules/fast-equals/dist/umd/index.js +659 -0
  738. package/node_modules/fast-equals/dist/umd/index.js.map +1 -0
  739. package/node_modules/fast-equals/dist/umd/internalTypes.d.ts +159 -0
  740. package/node_modules/fast-equals/dist/umd/utils.d.ts +28 -0
  741. package/node_modules/fast-equals/index.d.ts +260 -0
  742. package/node_modules/fast-equals/package.json +113 -0
  743. package/node_modules/linkify-it/LICENSE +22 -0
  744. package/node_modules/linkify-it/README.md +196 -0
  745. package/node_modules/linkify-it/build/index.cjs.js +832 -0
  746. package/node_modules/linkify-it/index.mjs +642 -0
  747. package/node_modules/linkify-it/lib/re.mjs +189 -0
  748. package/node_modules/linkify-it/package.json +58 -0
  749. package/node_modules/markdown-it/LICENSE +22 -0
  750. package/node_modules/markdown-it/README.md +324 -0
  751. package/node_modules/markdown-it/bin/markdown-it.mjs +107 -0
  752. package/node_modules/markdown-it/dist/index.cjs.js +5547 -0
  753. package/node_modules/markdown-it/dist/markdown-it.js +6969 -0
  754. package/node_modules/markdown-it/dist/markdown-it.min.js +2 -0
  755. package/node_modules/markdown-it/index.mjs +1 -0
  756. package/node_modules/markdown-it/lib/common/html_blocks.mjs +67 -0
  757. package/node_modules/markdown-it/lib/common/html_re.mjs +25 -0
  758. package/node_modules/markdown-it/lib/common/utils.mjs +304 -0
  759. package/node_modules/markdown-it/lib/helpers/index.mjs +11 -0
  760. package/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs +77 -0
  761. package/node_modules/markdown-it/lib/helpers/parse_link_label.mjs +49 -0
  762. package/node_modules/markdown-it/lib/helpers/parse_link_title.mjs +66 -0
  763. package/node_modules/markdown-it/lib/index.mjs +565 -0
  764. package/node_modules/markdown-it/lib/parser_block.mjs +134 -0
  765. package/node_modules/markdown-it/lib/parser_core.mjs +62 -0
  766. package/node_modules/markdown-it/lib/parser_inline.mjs +197 -0
  767. package/node_modules/markdown-it/lib/presets/commonmark.mjs +88 -0
  768. package/node_modules/markdown-it/lib/presets/default.mjs +47 -0
  769. package/node_modules/markdown-it/lib/presets/zero.mjs +70 -0
  770. package/node_modules/markdown-it/lib/renderer.mjs +322 -0
  771. package/node_modules/markdown-it/lib/ruler.mjs +340 -0
  772. package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +209 -0
  773. package/node_modules/markdown-it/lib/rules_block/code.mjs +30 -0
  774. package/node_modules/markdown-it/lib/rules_block/fence.mjs +94 -0
  775. package/node_modules/markdown-it/lib/rules_block/heading.mjs +51 -0
  776. package/node_modules/markdown-it/lib/rules_block/hr.mjs +40 -0
  777. package/node_modules/markdown-it/lib/rules_block/html_block.mjs +69 -0
  778. package/node_modules/markdown-it/lib/rules_block/lheading.mjs +82 -0
  779. package/node_modules/markdown-it/lib/rules_block/list.mjs +331 -0
  780. package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +46 -0
  781. package/node_modules/markdown-it/lib/rules_block/reference.mjs +212 -0
  782. package/node_modules/markdown-it/lib/rules_block/state_block.mjs +220 -0
  783. package/node_modules/markdown-it/lib/rules_block/table.mjs +228 -0
  784. package/node_modules/markdown-it/lib/rules_core/block.mjs +13 -0
  785. package/node_modules/markdown-it/lib/rules_core/inline.mjs +11 -0
  786. package/node_modules/markdown-it/lib/rules_core/linkify.mjs +134 -0
  787. package/node_modules/markdown-it/lib/rules_core/normalize.mjs +17 -0
  788. package/node_modules/markdown-it/lib/rules_core/replacements.mjs +101 -0
  789. package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +193 -0
  790. package/node_modules/markdown-it/lib/rules_core/state_core.mjs +17 -0
  791. package/node_modules/markdown-it/lib/rules_core/text_join.mjs +43 -0
  792. package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +72 -0
  793. package/node_modules/markdown-it/lib/rules_inline/backticks.mjs +60 -0
  794. package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +124 -0
  795. package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +123 -0
  796. package/node_modules/markdown-it/lib/rules_inline/entity.mjs +51 -0
  797. package/node_modules/markdown-it/lib/rules_inline/escape.mjs +69 -0
  798. package/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs +38 -0
  799. package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +50 -0
  800. package/node_modules/markdown-it/lib/rules_inline/image.mjs +138 -0
  801. package/node_modules/markdown-it/lib/rules_inline/link.mjs +139 -0
  802. package/node_modules/markdown-it/lib/rules_inline/linkify.mjs +63 -0
  803. package/node_modules/markdown-it/lib/rules_inline/newline.mjs +42 -0
  804. package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +123 -0
  805. package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +127 -0
  806. package/node_modules/markdown-it/lib/rules_inline/text.mjs +86 -0
  807. package/node_modules/markdown-it/lib/token.mjs +191 -0
  808. package/node_modules/markdown-it/package.json +92 -0
  809. package/node_modules/mdurl/LICENSE +45 -0
  810. package/node_modules/mdurl/README.md +102 -0
  811. package/node_modules/mdurl/build/index.cjs.js +534 -0
  812. package/node_modules/mdurl/index.mjs +11 -0
  813. package/node_modules/mdurl/lib/decode.mjs +112 -0
  814. package/node_modules/mdurl/lib/encode.mjs +89 -0
  815. package/node_modules/mdurl/lib/format.mjs +21 -0
  816. package/node_modules/mdurl/lib/parse.mjs +308 -0
  817. package/node_modules/mdurl/package.json +37 -0
  818. package/node_modules/orderedmap/LICENSE +19 -0
  819. package/node_modules/orderedmap/README.md +69 -0
  820. package/node_modules/orderedmap/dist/index.cjs +139 -0
  821. package/node_modules/orderedmap/dist/index.d.cts +33 -0
  822. package/node_modules/orderedmap/dist/index.d.ts +33 -0
  823. package/node_modules/orderedmap/dist/index.js +137 -0
  824. package/node_modules/orderedmap/package.json +39 -0
  825. package/node_modules/prosemirror-changeset/CHANGELOG.md +147 -0
  826. package/node_modules/prosemirror-changeset/LICENSE +19 -0
  827. package/node_modules/prosemirror-changeset/README.md +175 -0
  828. package/node_modules/prosemirror-changeset/dist/index.cjs +585 -0
  829. package/node_modules/prosemirror-changeset/dist/index.d.cts +186 -0
  830. package/node_modules/prosemirror-changeset/dist/index.d.ts +186 -0
  831. package/node_modules/prosemirror-changeset/dist/index.js +715 -0
  832. package/node_modules/prosemirror-changeset/package.json +40 -0
  833. package/node_modules/prosemirror-changeset/src/README.md +32 -0
  834. package/node_modules/prosemirror-changeset/src/change.ts +189 -0
  835. package/node_modules/prosemirror-changeset/src/changeset.ts +212 -0
  836. package/node_modules/prosemirror-changeset/src/diff.ts +151 -0
  837. package/node_modules/prosemirror-changeset/src/simplify.ts +132 -0
  838. package/node_modules/prosemirror-changeset/test/test-changed-range.ts +48 -0
  839. package/node_modules/prosemirror-changeset/test/test-changes.ts +211 -0
  840. package/node_modules/prosemirror-changeset/test/test-diff.ts +69 -0
  841. package/node_modules/prosemirror-changeset/test/test-merge.ts +56 -0
  842. package/node_modules/prosemirror-changeset/test/test-simplify.ts +71 -0
  843. package/node_modules/prosemirror-collab/.tern-project +8 -0
  844. package/node_modules/prosemirror-collab/CHANGELOG.md +77 -0
  845. package/node_modules/prosemirror-collab/CONTRIBUTING.md +104 -0
  846. package/node_modules/prosemirror-collab/LICENSE +19 -0
  847. package/node_modules/prosemirror-collab/README.md +28 -0
  848. package/node_modules/prosemirror-collab/dist/index.cjs +155 -0
  849. package/node_modules/prosemirror-collab/dist/index.d.cts +60 -0
  850. package/node_modules/prosemirror-collab/dist/index.d.ts +60 -0
  851. package/node_modules/prosemirror-collab/dist/index.js +156 -0
  852. package/node_modules/prosemirror-collab/package.json +40 -0
  853. package/node_modules/prosemirror-collab/src/README.md +11 -0
  854. package/node_modules/prosemirror-collab/src/collab.ts +184 -0
  855. package/node_modules/prosemirror-commands/.tern-project +8 -0
  856. package/node_modules/prosemirror-commands/CHANGELOG.md +322 -0
  857. package/node_modules/prosemirror-commands/CONTRIBUTING.md +104 -0
  858. package/node_modules/prosemirror-commands/LICENSE +19 -0
  859. package/node_modules/prosemirror-commands/README.md +28 -0
  860. package/node_modules/prosemirror-commands/dist/index.cjs +687 -0
  861. package/node_modules/prosemirror-commands/dist/index.d.cts +215 -0
  862. package/node_modules/prosemirror-commands/dist/index.d.ts +215 -0
  863. package/node_modules/prosemirror-commands/dist/index.js +850 -0
  864. package/node_modules/prosemirror-commands/package.json +39 -0
  865. package/node_modules/prosemirror-commands/src/README.md +40 -0
  866. package/node_modules/prosemirror-commands/src/commands.ts +783 -0
  867. package/node_modules/prosemirror-dropcursor/CHANGELOG.md +137 -0
  868. package/node_modules/prosemirror-dropcursor/CONTRIBUTING.md +100 -0
  869. package/node_modules/prosemirror-dropcursor/LICENSE +19 -0
  870. package/node_modules/prosemirror-dropcursor/README.md +50 -0
  871. package/node_modules/prosemirror-dropcursor/dist/index.cjs +185 -0
  872. package/node_modules/prosemirror-dropcursor/dist/index.d.cts +38 -0
  873. package/node_modules/prosemirror-dropcursor/dist/index.d.ts +38 -0
  874. package/node_modules/prosemirror-dropcursor/dist/index.js +146 -0
  875. package/node_modules/prosemirror-dropcursor/package.json +38 -0
  876. package/node_modules/prosemirror-dropcursor/src/dropcursor.ts +170 -0
  877. package/node_modules/prosemirror-gapcursor/CHANGELOG.md +122 -0
  878. package/node_modules/prosemirror-gapcursor/CONTRIBUTING.md +104 -0
  879. package/node_modules/prosemirror-gapcursor/LICENSE +19 -0
  880. package/node_modules/prosemirror-gapcursor/README.md +31 -0
  881. package/node_modules/prosemirror-gapcursor/dist/index.cjs +239 -0
  882. package/node_modules/prosemirror-gapcursor/dist/index.d.cts +31 -0
  883. package/node_modules/prosemirror-gapcursor/dist/index.d.ts +31 -0
  884. package/node_modules/prosemirror-gapcursor/dist/index.js +239 -0
  885. package/node_modules/prosemirror-gapcursor/package.json +43 -0
  886. package/node_modules/prosemirror-gapcursor/src/README.md +21 -0
  887. package/node_modules/prosemirror-gapcursor/src/gapcursor.ts +141 -0
  888. package/node_modules/prosemirror-gapcursor/src/index.ts +91 -0
  889. package/node_modules/prosemirror-gapcursor/style/gapcursor.css +25 -0
  890. package/node_modules/prosemirror-history/.tern-project +8 -0
  891. package/node_modules/prosemirror-history/CHANGELOG.md +170 -0
  892. package/node_modules/prosemirror-history/CONTRIBUTING.md +104 -0
  893. package/node_modules/prosemirror-history/LICENSE +19 -0
  894. package/node_modules/prosemirror-history/README.md +27 -0
  895. package/node_modules/prosemirror-history/dist/index.cjs +382 -0
  896. package/node_modules/prosemirror-history/dist/index.d.cts +64 -0
  897. package/node_modules/prosemirror-history/dist/index.d.ts +64 -0
  898. package/node_modules/prosemirror-history/dist/index.js +453 -0
  899. package/node_modules/prosemirror-history/package.json +40 -0
  900. package/node_modules/prosemirror-history/src/README.md +23 -0
  901. package/node_modules/prosemirror-history/src/history.ts +465 -0
  902. package/node_modules/prosemirror-inputrules/.tern-project +8 -0
  903. package/node_modules/prosemirror-inputrules/CHANGELOG.md +127 -0
  904. package/node_modules/prosemirror-inputrules/CONTRIBUTING.md +104 -0
  905. package/node_modules/prosemirror-inputrules/LICENSE +19 -0
  906. package/node_modules/prosemirror-inputrules/README.md +29 -0
  907. package/node_modules/prosemirror-inputrules/dist/index.cjs +194 -0
  908. package/node_modules/prosemirror-inputrules/dist/index.d.cts +131 -0
  909. package/node_modules/prosemirror-inputrules/dist/index.d.ts +131 -0
  910. package/node_modules/prosemirror-inputrules/dist/index.js +239 -0
  911. package/node_modules/prosemirror-inputrules/package.json +36 -0
  912. package/node_modules/prosemirror-inputrules/src/README.md +23 -0
  913. package/node_modules/prosemirror-inputrules/src/index.ts +4 -0
  914. package/node_modules/prosemirror-inputrules/src/inputrules.ts +167 -0
  915. package/node_modules/prosemirror-inputrules/src/rulebuilders.ts +59 -0
  916. package/node_modules/prosemirror-inputrules/src/rules.ts +17 -0
  917. package/node_modules/prosemirror-keymap/.tern-project +8 -0
  918. package/node_modules/prosemirror-keymap/CHANGELOG.md +104 -0
  919. package/node_modules/prosemirror-keymap/CONTRIBUTING.md +104 -0
  920. package/node_modules/prosemirror-keymap/LICENSE +19 -0
  921. package/node_modules/prosemirror-keymap/README.md +27 -0
  922. package/node_modules/prosemirror-keymap/dist/index.cjs +65 -0
  923. package/node_modules/prosemirror-keymap/dist/index.d.cts +47 -0
  924. package/node_modules/prosemirror-keymap/dist/index.d.ts +47 -0
  925. package/node_modules/prosemirror-keymap/dist/index.js +128 -0
  926. package/node_modules/prosemirror-keymap/package.json +38 -0
  927. package/node_modules/prosemirror-keymap/src/README.md +5 -0
  928. package/node_modules/prosemirror-keymap/src/keymap.ts +105 -0
  929. package/node_modules/prosemirror-markdown/.tern-project +8 -0
  930. package/node_modules/prosemirror-markdown/CHANGELOG.md +311 -0
  931. package/node_modules/prosemirror-markdown/CONTRIBUTING.md +100 -0
  932. package/node_modules/prosemirror-markdown/LICENSE +19 -0
  933. package/node_modules/prosemirror-markdown/README.md +276 -0
  934. package/node_modules/prosemirror-markdown/dist/index.cjs +966 -0
  935. package/node_modules/prosemirror-markdown/dist/index.d.cts +335 -0
  936. package/node_modules/prosemirror-markdown/dist/index.d.ts +335 -0
  937. package/node_modules/prosemirror-markdown/dist/index.js +878 -0
  938. package/node_modules/prosemirror-markdown/package.json +40 -0
  939. package/node_modules/prosemirror-markdown/src/README.md +42 -0
  940. package/node_modules/prosemirror-markdown/src/from_markdown.ts +272 -0
  941. package/node_modules/prosemirror-markdown/src/index.ts +5 -0
  942. package/node_modules/prosemirror-markdown/src/schema.ts +156 -0
  943. package/node_modules/prosemirror-markdown/src/to_markdown.ts +483 -0
  944. package/node_modules/prosemirror-menu/.tern-project +8 -0
  945. package/node_modules/prosemirror-menu/CHANGELOG.md +107 -0
  946. package/node_modules/prosemirror-menu/CONTRIBUTING.md +100 -0
  947. package/node_modules/prosemirror-menu/LICENSE +19 -0
  948. package/node_modules/prosemirror-menu/README.md +235 -0
  949. package/node_modules/prosemirror-menu/dist/index.cjs +798 -0
  950. package/node_modules/prosemirror-menu/dist/index.d.cts +281 -0
  951. package/node_modules/prosemirror-menu/dist/index.d.ts +281 -0
  952. package/node_modules/prosemirror-menu/dist/index.js +795 -0
  953. package/node_modules/prosemirror-menu/package.json +42 -0
  954. package/node_modules/prosemirror-menu/src/README.md +60 -0
  955. package/node_modules/prosemirror-menu/src/icons.ts +53 -0
  956. package/node_modules/prosemirror-menu/src/index.ts +4 -0
  957. package/node_modules/prosemirror-menu/src/menu.ts +628 -0
  958. package/node_modules/prosemirror-menu/src/menubar.ts +210 -0
  959. package/node_modules/prosemirror-menu/style/menu.css +169 -0
  960. package/node_modules/prosemirror-model/.tern-project +8 -0
  961. package/node_modules/prosemirror-model/CHANGELOG.md +730 -0
  962. package/node_modules/prosemirror-model/CONTRIBUTING.md +104 -0
  963. package/node_modules/prosemirror-model/LICENSE +19 -0
  964. package/node_modules/prosemirror-model/README.md +29 -0
  965. package/node_modules/prosemirror-model/dist/index.cjs +2898 -0
  966. package/node_modules/prosemirror-model/dist/index.d.cts +1679 -0
  967. package/node_modules/prosemirror-model/dist/index.d.ts +1679 -0
  968. package/node_modules/prosemirror-model/dist/index.js +3464 -0
  969. package/node_modules/prosemirror-model/package.json +38 -0
  970. package/node_modules/prosemirror-model/src/README.md +62 -0
  971. package/node_modules/prosemirror-model/src/comparedeep.ts +15 -0
  972. package/node_modules/prosemirror-model/src/content.ts +413 -0
  973. package/node_modules/prosemirror-model/src/diff.ts +52 -0
  974. package/node_modules/prosemirror-model/src/dom.ts +1 -0
  975. package/node_modules/prosemirror-model/src/fragment.ts +268 -0
  976. package/node_modules/prosemirror-model/src/from_dom.ts +848 -0
  977. package/node_modules/prosemirror-model/src/index.ts +11 -0
  978. package/node_modules/prosemirror-model/src/mark.ts +111 -0
  979. package/node_modules/prosemirror-model/src/node.ts +402 -0
  980. package/node_modules/prosemirror-model/src/replace.ts +225 -0
  981. package/node_modules/prosemirror-model/src/resolvedpos.ts +289 -0
  982. package/node_modules/prosemirror-model/src/schema.ts +705 -0
  983. package/node_modules/prosemirror-model/src/to_dom.ts +238 -0
  984. package/node_modules/prosemirror-schema-basic/.tern-project +8 -0
  985. package/node_modules/prosemirror-schema-basic/CHANGELOG.md +81 -0
  986. package/node_modules/prosemirror-schema-basic/CONTRIBUTING.md +100 -0
  987. package/node_modules/prosemirror-schema-basic/LICENSE +19 -0
  988. package/node_modules/prosemirror-schema-basic/README.md +28 -0
  989. package/node_modules/prosemirror-schema-basic/dist/index.cjs +246 -0
  990. package/node_modules/prosemirror-schema-basic/dist/index.d.cts +87 -0
  991. package/node_modules/prosemirror-schema-basic/dist/index.d.ts +87 -0
  992. package/node_modules/prosemirror-schema-basic/dist/index.js +183 -0
  993. package/node_modules/prosemirror-schema-basic/package.json +37 -0
  994. package/node_modules/prosemirror-schema-basic/src/README.md +8 -0
  995. package/node_modules/prosemirror-schema-basic/src/schema-basic.ts +166 -0
  996. package/node_modules/prosemirror-schema-list/.tern-project +8 -0
  997. package/node_modules/prosemirror-schema-list/CHANGELOG.md +140 -0
  998. package/node_modules/prosemirror-schema-list/CONTRIBUTING.md +100 -0
  999. package/node_modules/prosemirror-schema-list/LICENSE +19 -0
  1000. package/node_modules/prosemirror-schema-list/README.md +28 -0
  1001. package/node_modules/prosemirror-schema-list/dist/index.cjs +253 -0
  1002. package/node_modules/prosemirror-schema-list/dist/index.d.cts +71 -0
  1003. package/node_modules/prosemirror-schema-list/dist/index.d.ts +71 -0
  1004. package/node_modules/prosemirror-schema-list/dist/index.js +289 -0
  1005. package/node_modules/prosemirror-schema-list/package.json +40 -0
  1006. package/node_modules/prosemirror-schema-list/src/README.md +29 -0
  1007. package/node_modules/prosemirror-schema-list/src/schema-list.ts +267 -0
  1008. package/node_modules/prosemirror-state/.tern-project +8 -0
  1009. package/node_modules/prosemirror-state/CHANGELOG.md +296 -0
  1010. package/node_modules/prosemirror-state/CONTRIBUTING.md +104 -0
  1011. package/node_modules/prosemirror-state/LICENSE +19 -0
  1012. package/node_modules/prosemirror-state/README.md +28 -0
  1013. package/node_modules/prosemirror-state/dist/index.cjs +884 -0
  1014. package/node_modules/prosemirror-state/dist/index.d.cts +709 -0
  1015. package/node_modules/prosemirror-state/dist/index.d.ts +709 -0
  1016. package/node_modules/prosemirror-state/dist/index.js +1002 -0
  1017. package/node_modules/prosemirror-state/package.json +39 -0
  1018. package/node_modules/prosemirror-state/src/README.md +42 -0
  1019. package/node_modules/prosemirror-state/src/index.ts +7 -0
  1020. package/node_modules/prosemirror-state/src/plugin.ts +142 -0
  1021. package/node_modules/prosemirror-state/src/selection.ts +462 -0
  1022. package/node_modules/prosemirror-state/src/state.ts +266 -0
  1023. package/node_modules/prosemirror-state/src/transaction.ts +215 -0
  1024. package/node_modules/prosemirror-tables/LICENSE +19 -0
  1025. package/node_modules/prosemirror-tables/README.md +254 -0
  1026. package/node_modules/prosemirror-tables/dist/index.cjs +2683 -0
  1027. package/node_modules/prosemirror-tables/dist/index.d.cts +751 -0
  1028. package/node_modules/prosemirror-tables/dist/index.d.cts.map +1 -0
  1029. package/node_modules/prosemirror-tables/dist/index.d.ts +751 -0
  1030. package/node_modules/prosemirror-tables/dist/index.d.ts.map +1 -0
  1031. package/node_modules/prosemirror-tables/dist/index.js +2626 -0
  1032. package/node_modules/prosemirror-tables/dist/index.js.map +1 -0
  1033. package/node_modules/prosemirror-tables/package.json +80 -0
  1034. package/node_modules/prosemirror-tables/style/tables.css +48 -0
  1035. package/node_modules/prosemirror-trailing-node/LICENSE +21 -0
  1036. package/node_modules/prosemirror-trailing-node/dist/_tsup-dts-rollup.d.cts +41 -0
  1037. package/node_modules/prosemirror-trailing-node/dist/_tsup-dts-rollup.d.ts +41 -0
  1038. package/node_modules/prosemirror-trailing-node/dist/prosemirror-trailing-node.cjs +70 -0
  1039. package/node_modules/prosemirror-trailing-node/dist/prosemirror-trailing-node.d.cts +2 -0
  1040. package/node_modules/prosemirror-trailing-node/dist/prosemirror-trailing-node.d.ts +2 -0
  1041. package/node_modules/prosemirror-trailing-node/dist/prosemirror-trailing-node.js +43 -0
  1042. package/node_modules/prosemirror-trailing-node/dist-types/index.d.ts +2 -0
  1043. package/node_modules/prosemirror-trailing-node/dist-types/trailing-node-plugin.d.ts +33 -0
  1044. package/node_modules/prosemirror-trailing-node/dist-types/tsconfig.tsbuildinfo +1 -0
  1045. package/node_modules/prosemirror-trailing-node/package.json +57 -0
  1046. package/node_modules/prosemirror-trailing-node/readme.md +55 -0
  1047. package/node_modules/prosemirror-transform/.tern-project +8 -0
  1048. package/node_modules/prosemirror-transform/CHANGELOG.md +502 -0
  1049. package/node_modules/prosemirror-transform/CONTRIBUTING.md +104 -0
  1050. package/node_modules/prosemirror-transform/LICENSE +19 -0
  1051. package/node_modules/prosemirror-transform/README.md +29 -0
  1052. package/node_modules/prosemirror-transform/dist/index.cjs +1888 -0
  1053. package/node_modules/prosemirror-transform/dist/index.d.cts +847 -0
  1054. package/node_modules/prosemirror-transform/dist/index.d.ts +847 -0
  1055. package/node_modules/prosemirror-transform/dist/index.js +2181 -0
  1056. package/node_modules/prosemirror-transform/package.json +37 -0
  1057. package/node_modules/prosemirror-transform/src/README.md +59 -0
  1058. package/node_modules/prosemirror-transform/src/attr_step.ts +98 -0
  1059. package/node_modules/prosemirror-transform/src/index.ts +11 -0
  1060. package/node_modules/prosemirror-transform/src/map.ts +284 -0
  1061. package/node_modules/prosemirror-transform/src/mark.ts +106 -0
  1062. package/node_modules/prosemirror-transform/src/mark_step.ts +224 -0
  1063. package/node_modules/prosemirror-transform/src/replace.ts +460 -0
  1064. package/node_modules/prosemirror-transform/src/replace_step.ts +178 -0
  1065. package/node_modules/prosemirror-transform/src/step.ts +97 -0
  1066. package/node_modules/prosemirror-transform/src/structure.ts +349 -0
  1067. package/node_modules/prosemirror-transform/src/transform.ts +271 -0
  1068. package/node_modules/prosemirror-view/.tern-project +8 -0
  1069. package/node_modules/prosemirror-view/CHANGELOG.md +2447 -0
  1070. package/node_modules/prosemirror-view/CONTRIBUTING.md +104 -0
  1071. package/node_modules/prosemirror-view/LICENSE +19 -0
  1072. package/node_modules/prosemirror-view/README.md +28 -0
  1073. package/node_modules/prosemirror-view/dist/index.cjs +5381 -0
  1074. package/node_modules/prosemirror-view/dist/index.d.cts +904 -0
  1075. package/node_modules/prosemirror-view/dist/index.d.ts +904 -0
  1076. package/node_modules/prosemirror-view/dist/index.js +5900 -0
  1077. package/node_modules/prosemirror-view/package.json +43 -0
  1078. package/node_modules/prosemirror-view/src/README.md +38 -0
  1079. package/node_modules/prosemirror-view/src/browser.ts +24 -0
  1080. package/node_modules/prosemirror-view/src/capturekeys.ts +345 -0
  1081. package/node_modules/prosemirror-view/src/clipboard.ts +263 -0
  1082. package/node_modules/prosemirror-view/src/decoration.ts +793 -0
  1083. package/node_modules/prosemirror-view/src/dom.ts +159 -0
  1084. package/node_modules/prosemirror-view/src/domchange.ts +383 -0
  1085. package/node_modules/prosemirror-view/src/domcoords.ts +515 -0
  1086. package/node_modules/prosemirror-view/src/domobserver.ts +392 -0
  1087. package/node_modules/prosemirror-view/src/index.ts +825 -0
  1088. package/node_modules/prosemirror-view/src/input.ts +830 -0
  1089. package/node_modules/prosemirror-view/src/selection.ts +216 -0
  1090. package/node_modules/prosemirror-view/src/viewdesc.ts +1590 -0
  1091. package/node_modules/prosemirror-view/style/prosemirror.css +54 -0
  1092. package/node_modules/punycode.js/LICENSE-MIT.txt +20 -0
  1093. package/node_modules/punycode.js/README.md +148 -0
  1094. package/node_modules/punycode.js/package.json +58 -0
  1095. package/node_modules/punycode.js/punycode.es6.js +444 -0
  1096. package/node_modules/punycode.js/punycode.js +443 -0
  1097. package/node_modules/rope-sequence/LICENSE +19 -0
  1098. package/node_modules/rope-sequence/README.md +63 -0
  1099. package/node_modules/rope-sequence/dist/index.cjs +209 -0
  1100. package/node_modules/rope-sequence/dist/index.d.cts +11 -0
  1101. package/node_modules/rope-sequence/dist/index.d.ts +11 -0
  1102. package/node_modules/rope-sequence/dist/index.js +207 -0
  1103. package/node_modules/rope-sequence/index.js +190 -0
  1104. package/node_modules/rope-sequence/package.json +34 -0
  1105. package/node_modules/rope-sequence/test.js +78 -0
  1106. package/node_modules/uc.micro/LICENSE.txt +20 -0
  1107. package/node_modules/uc.micro/README.md +14 -0
  1108. package/node_modules/uc.micro/build/index.cjs.js +20 -0
  1109. package/node_modules/uc.micro/categories/Cc/regex.mjs +1 -0
  1110. package/node_modules/uc.micro/categories/Cf/regex.mjs +1 -0
  1111. package/node_modules/uc.micro/categories/P/regex.mjs +1 -0
  1112. package/node_modules/uc.micro/categories/S/regex.mjs +1 -0
  1113. package/node_modules/uc.micro/categories/Z/regex.mjs +1 -0
  1114. package/node_modules/uc.micro/index.mjs +8 -0
  1115. package/node_modules/uc.micro/package.json +37 -0
  1116. package/node_modules/uc.micro/properties/Any/regex.mjs +1 -0
  1117. package/node_modules/use-sync-external-store/LICENSE +21 -0
  1118. package/node_modules/use-sync-external-store/README.md +5 -0
  1119. package/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +97 -0
  1120. package/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +85 -0
  1121. package/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +95 -0
  1122. package/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.native.development.js +88 -0
  1123. package/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.native.production.js +59 -0
  1124. package/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +66 -0
  1125. package/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +96 -0
  1126. package/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js +84 -0
  1127. package/node_modules/use-sync-external-store/cjs/use-sync-external-store.development.js +27 -0
  1128. package/node_modules/use-sync-external-store/cjs/use-sync-external-store.production.js +13 -0
  1129. package/node_modules/use-sync-external-store/index.js +7 -0
  1130. package/node_modules/use-sync-external-store/package.json +43 -0
  1131. package/node_modules/use-sync-external-store/shim/index.js +7 -0
  1132. package/node_modules/use-sync-external-store/shim/index.native.js +7 -0
  1133. package/node_modules/use-sync-external-store/shim/with-selector.js +7 -0
  1134. package/node_modules/use-sync-external-store/with-selector.js +7 -0
  1135. package/node_modules/w3c-keyname/.tern-port +1 -0
  1136. package/node_modules/w3c-keyname/LICENSE +19 -0
  1137. package/node_modules/w3c-keyname/README.md +18 -0
  1138. package/node_modules/w3c-keyname/index.cjs +127 -0
  1139. package/node_modules/w3c-keyname/index.d.cts +5 -0
  1140. package/node_modules/w3c-keyname/index.d.ts +5 -0
  1141. package/node_modules/w3c-keyname/index.js +119 -0
  1142. package/node_modules/w3c-keyname/package.json +37 -0
  1143. package/package.json +120 -3
  1144. package/public-api.md +23 -1
  1145. package/dist/chunk-5J54S5BK.js.map +0 -1
  1146. package/dist/chunk-FQQJP2GJ.js.map +0 -1
  1147. /package/dist/{chunk-WCMGQJLE.js.map → chunk-IRBOKMF5.js.map} +0 -0
@@ -0,0 +1,2683 @@
1
+ let prosemirror_state = require("prosemirror-state");
2
+ let prosemirror_model = require("prosemirror-model");
3
+ let prosemirror_view = require("prosemirror-view");
4
+ let prosemirror_keymap = require("prosemirror-keymap");
5
+ let prosemirror_transform = require("prosemirror-transform");
6
+
7
+ //#region src/tablemap.ts
8
+ let readFromCache;
9
+ let addToCache;
10
+ if (typeof WeakMap != "undefined") {
11
+ let cache = /* @__PURE__ */ new WeakMap();
12
+ readFromCache = (key) => cache.get(key);
13
+ addToCache = (key, value) => {
14
+ cache.set(key, value);
15
+ return value;
16
+ };
17
+ } else {
18
+ const cache = [];
19
+ const cacheSize = 10;
20
+ let cachePos = 0;
21
+ readFromCache = (key) => {
22
+ for (let i = 0; i < cache.length; i += 2) if (cache[i] == key) return cache[i + 1];
23
+ };
24
+ addToCache = (key, value) => {
25
+ if (cachePos == cacheSize) cachePos = 0;
26
+ cache[cachePos++] = key;
27
+ return cache[cachePos++] = value;
28
+ };
29
+ }
30
+ /**
31
+ * A table map describes the structure of a given table. To avoid
32
+ * recomputing them all the time, they are cached per table node. To
33
+ * be able to do that, positions saved in the map are relative to the
34
+ * start of the table, rather than the start of the document.
35
+ *
36
+ * @public
37
+ */
38
+ var TableMap = class {
39
+ constructor(width, height, map, problems) {
40
+ this.width = width;
41
+ this.height = height;
42
+ this.map = map;
43
+ this.problems = problems;
44
+ }
45
+ findCell(pos) {
46
+ for (let i = 0; i < this.map.length; i++) {
47
+ const curPos = this.map[i];
48
+ if (curPos != pos) continue;
49
+ const left = i % this.width;
50
+ const top = i / this.width | 0;
51
+ let right = left + 1;
52
+ let bottom = top + 1;
53
+ for (let j = 1; right < this.width && this.map[i + j] == curPos; j++) right++;
54
+ for (let j = 1; bottom < this.height && this.map[i + this.width * j] == curPos; j++) bottom++;
55
+ return {
56
+ left,
57
+ top,
58
+ right,
59
+ bottom
60
+ };
61
+ }
62
+ throw new RangeError(`No cell with offset ${pos} found`);
63
+ }
64
+ colCount(pos) {
65
+ for (let i = 0; i < this.map.length; i++) if (this.map[i] == pos) return i % this.width;
66
+ throw new RangeError(`No cell with offset ${pos} found`);
67
+ }
68
+ nextCell(pos, axis, dir) {
69
+ const { left, right, top, bottom } = this.findCell(pos);
70
+ if (axis == "horiz") {
71
+ if (dir < 0 ? left == 0 : right == this.width) return null;
72
+ return this.map[top * this.width + (dir < 0 ? left - 1 : right)];
73
+ } else {
74
+ if (dir < 0 ? top == 0 : bottom == this.height) return null;
75
+ return this.map[left + this.width * (dir < 0 ? top - 1 : bottom)];
76
+ }
77
+ }
78
+ rectBetween(a, b) {
79
+ const { left: leftA, right: rightA, top: topA, bottom: bottomA } = this.findCell(a);
80
+ const { left: leftB, right: rightB, top: topB, bottom: bottomB } = this.findCell(b);
81
+ return {
82
+ left: Math.min(leftA, leftB),
83
+ top: Math.min(topA, topB),
84
+ right: Math.max(rightA, rightB),
85
+ bottom: Math.max(bottomA, bottomB)
86
+ };
87
+ }
88
+ cellsInRect(rect) {
89
+ const result = [];
90
+ const seen = {};
91
+ for (let row = rect.top; row < rect.bottom; row++) for (let col = rect.left; col < rect.right; col++) {
92
+ const index = row * this.width + col;
93
+ const pos = this.map[index];
94
+ if (seen[pos]) continue;
95
+ seen[pos] = true;
96
+ if (col == rect.left && col && this.map[index - 1] == pos || row == rect.top && row && this.map[index - this.width] == pos) continue;
97
+ result.push(pos);
98
+ }
99
+ return result;
100
+ }
101
+ positionAt(row, col, table) {
102
+ for (let i = 0, rowStart = 0;; i++) {
103
+ const rowEnd = rowStart + table.child(i).nodeSize;
104
+ if (i == row) {
105
+ let index = col + row * this.width;
106
+ const rowEndIndex = (row + 1) * this.width;
107
+ while (index < rowEndIndex && this.map[index] < rowStart) index++;
108
+ return index == rowEndIndex ? rowEnd - 1 : this.map[index];
109
+ }
110
+ rowStart = rowEnd;
111
+ }
112
+ }
113
+ static get(table) {
114
+ return readFromCache(table) || addToCache(table, computeMap(table));
115
+ }
116
+ };
117
+ function computeMap(table) {
118
+ if (table.type.spec.tableRole != "table") throw new RangeError("Not a table node: " + table.type.name);
119
+ const width = findWidth(table), height = table.childCount;
120
+ const map = [];
121
+ let mapPos = 0;
122
+ let problems = null;
123
+ const colWidths = [];
124
+ for (let i = 0, e = width * height; i < e; i++) map[i] = 0;
125
+ for (let row = 0, pos = 0; row < height; row++) {
126
+ const rowNode = table.child(row);
127
+ pos++;
128
+ for (let i = 0;; i++) {
129
+ while (mapPos < map.length && map[mapPos] != 0) mapPos++;
130
+ if (i == rowNode.childCount) break;
131
+ const cellNode = rowNode.child(i);
132
+ const { colspan, rowspan, colwidth } = cellNode.attrs;
133
+ for (let h = 0; h < rowspan; h++) {
134
+ if (h + row >= height) {
135
+ (problems || (problems = [])).push({
136
+ type: "overlong_rowspan",
137
+ pos,
138
+ n: rowspan - h
139
+ });
140
+ break;
141
+ }
142
+ const start = mapPos + h * width;
143
+ for (let w = 0; w < colspan; w++) {
144
+ if (map[start + w] == 0) map[start + w] = pos;
145
+ else (problems || (problems = [])).push({
146
+ type: "collision",
147
+ row,
148
+ pos,
149
+ n: colspan - w
150
+ });
151
+ const colW = colwidth && colwidth[w];
152
+ if (colW) {
153
+ const widthIndex = (start + w) % width * 2, prev = colWidths[widthIndex];
154
+ if (prev == null || prev != colW && colWidths[widthIndex + 1] == 1) {
155
+ colWidths[widthIndex] = colW;
156
+ colWidths[widthIndex + 1] = 1;
157
+ } else if (prev == colW) colWidths[widthIndex + 1]++;
158
+ }
159
+ }
160
+ }
161
+ mapPos += colspan;
162
+ pos += cellNode.nodeSize;
163
+ }
164
+ const expectedPos = (row + 1) * width;
165
+ let missing = 0;
166
+ while (mapPos < expectedPos) if (map[mapPos++] == 0) missing++;
167
+ if (missing) (problems || (problems = [])).push({
168
+ type: "missing",
169
+ row,
170
+ n: missing
171
+ });
172
+ pos++;
173
+ }
174
+ if (width === 0 || height === 0) (problems || (problems = [])).push({ type: "zero_sized" });
175
+ const tableMap = new TableMap(width, height, map, problems);
176
+ let badWidths = false;
177
+ for (let i = 0; !badWidths && i < colWidths.length; i += 2) if (colWidths[i] != null && colWidths[i + 1] < height) badWidths = true;
178
+ if (badWidths) findBadColWidths(tableMap, colWidths, table);
179
+ return tableMap;
180
+ }
181
+ function findWidth(table) {
182
+ let width = -1;
183
+ let hasRowSpan = false;
184
+ for (let row = 0; row < table.childCount; row++) {
185
+ const rowNode = table.child(row);
186
+ let rowWidth = 0;
187
+ if (hasRowSpan) for (let j = 0; j < row; j++) {
188
+ const prevRow = table.child(j);
189
+ for (let i = 0; i < prevRow.childCount; i++) {
190
+ const cell = prevRow.child(i);
191
+ if (j + cell.attrs.rowspan > row) rowWidth += cell.attrs.colspan;
192
+ }
193
+ }
194
+ for (let i = 0; i < rowNode.childCount; i++) {
195
+ const cell = rowNode.child(i);
196
+ rowWidth += cell.attrs.colspan;
197
+ if (cell.attrs.rowspan > 1) hasRowSpan = true;
198
+ }
199
+ if (width == -1) width = rowWidth;
200
+ else if (width != rowWidth) width = Math.max(width, rowWidth);
201
+ }
202
+ return width;
203
+ }
204
+ function findBadColWidths(map, colWidths, table) {
205
+ if (!map.problems) map.problems = [];
206
+ const seen = {};
207
+ for (let i = 0; i < map.map.length; i++) {
208
+ const pos = map.map[i];
209
+ if (seen[pos]) continue;
210
+ seen[pos] = true;
211
+ const node = table.nodeAt(pos);
212
+ if (!node) throw new RangeError(`No cell with offset ${pos} found`);
213
+ let updated = null;
214
+ const attrs = node.attrs;
215
+ for (let j = 0; j < attrs.colspan; j++) {
216
+ const colWidth = colWidths[(i + j) % map.width * 2];
217
+ if (colWidth != null && (!attrs.colwidth || attrs.colwidth[j] != colWidth)) (updated || (updated = freshColWidth(attrs)))[j] = colWidth;
218
+ }
219
+ if (updated) map.problems.unshift({
220
+ type: "colwidth mismatch",
221
+ pos,
222
+ colwidth: updated
223
+ });
224
+ }
225
+ }
226
+ function freshColWidth(attrs) {
227
+ if (attrs.colwidth) return attrs.colwidth.slice();
228
+ const result = [];
229
+ for (let i = 0; i < attrs.colspan; i++) result.push(0);
230
+ return result;
231
+ }
232
+
233
+ //#endregion
234
+ //#region src/schema.ts
235
+ function getCellAttrs(dom, extraAttrs) {
236
+ if (typeof dom === "string") return {};
237
+ const widthAttr = dom.getAttribute("data-colwidth");
238
+ const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr) ? widthAttr.split(",").map((s) => Number(s)) : null;
239
+ const colspan = Number(dom.getAttribute("colspan") || 1);
240
+ const result = {
241
+ colspan,
242
+ rowspan: Number(dom.getAttribute("rowspan") || 1),
243
+ colwidth: widths && widths.length == colspan ? widths : null
244
+ };
245
+ for (const prop in extraAttrs) {
246
+ const getter = extraAttrs[prop].getFromDOM;
247
+ const value = getter && getter(dom);
248
+ if (value != null) result[prop] = value;
249
+ }
250
+ return result;
251
+ }
252
+ function setCellAttrs(node, extraAttrs) {
253
+ const attrs = {};
254
+ if (node.attrs.colspan != 1) attrs.colspan = node.attrs.colspan;
255
+ if (node.attrs.rowspan != 1) attrs.rowspan = node.attrs.rowspan;
256
+ if (node.attrs.colwidth) attrs["data-colwidth"] = node.attrs.colwidth.join(",");
257
+ for (const prop in extraAttrs) {
258
+ const setter = extraAttrs[prop].setDOMAttr;
259
+ if (setter) setter(node.attrs[prop], attrs);
260
+ }
261
+ return attrs;
262
+ }
263
+ function validateColwidth(value) {
264
+ if (value === null) return;
265
+ if (!Array.isArray(value)) throw new TypeError("colwidth must be null or an array");
266
+ for (const item of value) if (typeof item !== "number") throw new TypeError("colwidth must be null or an array of numbers");
267
+ }
268
+ /**
269
+ * This function creates a set of [node
270
+ * specs](http://prosemirror.net/docs/ref/#model.SchemaSpec.nodes) for
271
+ * `table`, `table_row`, and `table_cell` nodes types as used by this
272
+ * module. The result can then be added to the set of nodes when
273
+ * creating a schema.
274
+ *
275
+ * @public
276
+ */
277
+ function tableNodes(options) {
278
+ const extraAttrs = options.cellAttributes || {};
279
+ const cellAttrs = {
280
+ colspan: {
281
+ default: 1,
282
+ validate: "number"
283
+ },
284
+ rowspan: {
285
+ default: 1,
286
+ validate: "number"
287
+ },
288
+ colwidth: {
289
+ default: null,
290
+ validate: validateColwidth
291
+ }
292
+ };
293
+ for (const prop in extraAttrs) cellAttrs[prop] = {
294
+ default: extraAttrs[prop].default,
295
+ validate: extraAttrs[prop].validate
296
+ };
297
+ return {
298
+ table: {
299
+ content: "table_row+",
300
+ tableRole: "table",
301
+ isolating: true,
302
+ group: options.tableGroup,
303
+ parseDOM: [{ tag: "table" }],
304
+ toDOM() {
305
+ return ["table", ["tbody", 0]];
306
+ }
307
+ },
308
+ table_row: {
309
+ content: "(table_cell | table_header)*",
310
+ tableRole: "row",
311
+ parseDOM: [{ tag: "tr" }],
312
+ toDOM() {
313
+ return ["tr", 0];
314
+ }
315
+ },
316
+ table_cell: {
317
+ content: options.cellContent,
318
+ attrs: cellAttrs,
319
+ tableRole: "cell",
320
+ isolating: true,
321
+ parseDOM: [{
322
+ tag: "td",
323
+ getAttrs: (dom) => getCellAttrs(dom, extraAttrs)
324
+ }],
325
+ toDOM(node) {
326
+ return [
327
+ "td",
328
+ setCellAttrs(node, extraAttrs),
329
+ 0
330
+ ];
331
+ }
332
+ },
333
+ table_header: {
334
+ content: options.cellContent,
335
+ attrs: cellAttrs,
336
+ tableRole: "header_cell",
337
+ isolating: true,
338
+ parseDOM: [{
339
+ tag: "th",
340
+ getAttrs: (dom) => getCellAttrs(dom, extraAttrs)
341
+ }],
342
+ toDOM(node) {
343
+ return [
344
+ "th",
345
+ setCellAttrs(node, extraAttrs),
346
+ 0
347
+ ];
348
+ }
349
+ }
350
+ };
351
+ }
352
+ /**
353
+ * @public
354
+ */
355
+ function tableNodeTypes(schema) {
356
+ let result = schema.cached.tableNodeTypes;
357
+ if (!result) {
358
+ result = schema.cached.tableNodeTypes = {};
359
+ for (const name in schema.nodes) {
360
+ const type = schema.nodes[name], role = type.spec.tableRole;
361
+ if (role) result[role] = type;
362
+ }
363
+ }
364
+ return result;
365
+ }
366
+
367
+ //#endregion
368
+ //#region src/util.ts
369
+ /**
370
+ * @public
371
+ */
372
+ const tableEditingKey = new prosemirror_state.PluginKey("selectingCells");
373
+ /**
374
+ * @public
375
+ */
376
+ function cellAround($pos) {
377
+ for (let d = $pos.depth - 1; d > 0; d--) if ($pos.node(d).type.spec.tableRole == "row") return $pos.node(0).resolve($pos.before(d + 1));
378
+ return null;
379
+ }
380
+ function cellWrapping($pos) {
381
+ for (let d = $pos.depth; d > 0; d--) {
382
+ const role = $pos.node(d).type.spec.tableRole;
383
+ if (role === "cell" || role === "header_cell") return $pos.node(d);
384
+ }
385
+ return null;
386
+ }
387
+ /**
388
+ * @public
389
+ */
390
+ function isInTable(state) {
391
+ const $head = state.selection.$head;
392
+ for (let d = $head.depth; d > 0; d--) if ($head.node(d).type.spec.tableRole == "row") return true;
393
+ return false;
394
+ }
395
+ /**
396
+ * @internal
397
+ */
398
+ function selectionCell(state) {
399
+ const sel = state.selection;
400
+ if ("$anchorCell" in sel && sel.$anchorCell) return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
401
+ else if ("node" in sel && sel.node && sel.node.type.spec.tableRole == "cell") return sel.$anchor;
402
+ const $cell = cellAround(sel.$head) || cellNear(sel.$head);
403
+ if ($cell) return $cell;
404
+ throw new RangeError(`No cell found around position ${sel.head}`);
405
+ }
406
+ /**
407
+ * @public
408
+ */
409
+ function cellNear($pos) {
410
+ for (let after = $pos.nodeAfter, pos = $pos.pos; after; after = after.firstChild, pos++) {
411
+ const role = after.type.spec.tableRole;
412
+ if (role == "cell" || role == "header_cell") return $pos.doc.resolve(pos);
413
+ }
414
+ for (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {
415
+ const role = before.type.spec.tableRole;
416
+ if (role == "cell" || role == "header_cell") return $pos.doc.resolve(pos - before.nodeSize);
417
+ }
418
+ }
419
+ /**
420
+ * @public
421
+ */
422
+ function pointsAtCell($pos) {
423
+ return $pos.parent.type.spec.tableRole == "row" && !!$pos.nodeAfter;
424
+ }
425
+ /**
426
+ * @public
427
+ */
428
+ function moveCellForward($pos) {
429
+ return $pos.node(0).resolve($pos.pos + $pos.nodeAfter.nodeSize);
430
+ }
431
+ /**
432
+ * @internal
433
+ */
434
+ function inSameTable($cellA, $cellB) {
435
+ return $cellA.depth == $cellB.depth && $cellA.pos >= $cellB.start(-1) && $cellA.pos <= $cellB.end(-1);
436
+ }
437
+ /**
438
+ * @public
439
+ */
440
+ function findCell($pos) {
441
+ return TableMap.get($pos.node(-1)).findCell($pos.pos - $pos.start(-1));
442
+ }
443
+ /**
444
+ * @public
445
+ */
446
+ function colCount($pos) {
447
+ return TableMap.get($pos.node(-1)).colCount($pos.pos - $pos.start(-1));
448
+ }
449
+ /**
450
+ * @public
451
+ */
452
+ function nextCell($pos, axis, dir) {
453
+ const table = $pos.node(-1);
454
+ const map = TableMap.get(table);
455
+ const tableStart = $pos.start(-1);
456
+ const moved = map.nextCell($pos.pos - tableStart, axis, dir);
457
+ return moved == null ? null : $pos.node(0).resolve(tableStart + moved);
458
+ }
459
+ /**
460
+ * @public
461
+ */
462
+ function removeColSpan(attrs, pos, n = 1) {
463
+ const result = {
464
+ ...attrs,
465
+ colspan: attrs.colspan - n
466
+ };
467
+ if (result.colwidth) {
468
+ result.colwidth = result.colwidth.slice();
469
+ result.colwidth.splice(pos, n);
470
+ if (!result.colwidth.some((w) => w > 0)) result.colwidth = null;
471
+ }
472
+ return result;
473
+ }
474
+ /**
475
+ * @public
476
+ */
477
+ function addColSpan(attrs, pos, n = 1) {
478
+ const result = {
479
+ ...attrs,
480
+ colspan: attrs.colspan + n
481
+ };
482
+ if (result.colwidth) {
483
+ result.colwidth = result.colwidth.slice();
484
+ for (let i = 0; i < n; i++) result.colwidth.splice(pos, 0, 0);
485
+ }
486
+ return result;
487
+ }
488
+ /**
489
+ * @public
490
+ */
491
+ function columnIsHeader(map, table, col) {
492
+ const headerCell = tableNodeTypes(table.type.schema).header_cell;
493
+ for (let row = 0; row < map.height; row++) if (table.nodeAt(map.map[col + row * map.width]).type != headerCell) return false;
494
+ return true;
495
+ }
496
+
497
+ //#endregion
498
+ //#region src/cellselection.ts
499
+ /**
500
+ * A [`Selection`](http://prosemirror.net/docs/ref/#state.Selection)
501
+ * subclass that represents a cell selection spanning part of a table.
502
+ * With the plugin enabled, these will be created when the user
503
+ * selects across cells, and will be drawn by giving selected cells a
504
+ * `selectedCell` CSS class.
505
+ *
506
+ * @public
507
+ */
508
+ var CellSelection = class CellSelection extends prosemirror_state.Selection {
509
+ constructor($anchorCell, $headCell = $anchorCell) {
510
+ const table = $anchorCell.node(-1);
511
+ const map = TableMap.get(table);
512
+ const tableStart = $anchorCell.start(-1);
513
+ const rect = map.rectBetween($anchorCell.pos - tableStart, $headCell.pos - tableStart);
514
+ const doc = $anchorCell.node(0);
515
+ const cells = map.cellsInRect(rect).filter((p) => p != $headCell.pos - tableStart);
516
+ cells.unshift($headCell.pos - tableStart);
517
+ const ranges = cells.map((pos) => {
518
+ const cell = table.nodeAt(pos);
519
+ if (!cell) throw new RangeError(`No cell with offset ${pos} found`);
520
+ const from = tableStart + pos + 1;
521
+ return new prosemirror_state.SelectionRange(doc.resolve(from), doc.resolve(from + cell.content.size));
522
+ });
523
+ super(ranges[0].$from, ranges[0].$to, ranges);
524
+ this.$anchorCell = $anchorCell;
525
+ this.$headCell = $headCell;
526
+ }
527
+ map(doc, mapping) {
528
+ const $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));
529
+ const $headCell = doc.resolve(mapping.map(this.$headCell.pos));
530
+ if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {
531
+ const tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);
532
+ if (tableChanged && this.isRowSelection()) return CellSelection.rowSelection($anchorCell, $headCell);
533
+ else if (tableChanged && this.isColSelection()) return CellSelection.colSelection($anchorCell, $headCell);
534
+ else return new CellSelection($anchorCell, $headCell);
535
+ }
536
+ return prosemirror_state.TextSelection.between($anchorCell, $headCell);
537
+ }
538
+ content() {
539
+ const table = this.$anchorCell.node(-1);
540
+ const map = TableMap.get(table);
541
+ const tableStart = this.$anchorCell.start(-1);
542
+ const rect = map.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart);
543
+ const seen = {};
544
+ const rows = [];
545
+ for (let row = rect.top; row < rect.bottom; row++) {
546
+ const rowContent = [];
547
+ for (let index = row * map.width + rect.left, col = rect.left; col < rect.right; col++, index++) {
548
+ const pos = map.map[index];
549
+ if (seen[pos]) continue;
550
+ seen[pos] = true;
551
+ const cellRect = map.findCell(pos);
552
+ let cell = table.nodeAt(pos);
553
+ if (!cell) throw new RangeError(`No cell with offset ${pos} found`);
554
+ const extraLeft = rect.left - cellRect.left;
555
+ const extraRight = cellRect.right - rect.right;
556
+ if (extraLeft > 0 || extraRight > 0) {
557
+ let attrs = cell.attrs;
558
+ if (extraLeft > 0) attrs = removeColSpan(attrs, 0, extraLeft);
559
+ if (extraRight > 0) attrs = removeColSpan(attrs, attrs.colspan - extraRight, extraRight);
560
+ if (cellRect.left < rect.left) {
561
+ cell = cell.type.createAndFill(attrs);
562
+ if (!cell) throw new RangeError(`Could not create cell with attrs ${JSON.stringify(attrs)}`);
563
+ } else cell = cell.type.create(attrs, cell.content);
564
+ }
565
+ if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {
566
+ const attrs = {
567
+ ...cell.attrs,
568
+ rowspan: Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top)
569
+ };
570
+ if (cellRect.top < rect.top) cell = cell.type.createAndFill(attrs);
571
+ else cell = cell.type.create(attrs, cell.content);
572
+ }
573
+ rowContent.push(cell);
574
+ }
575
+ rows.push(table.child(row).copy(prosemirror_model.Fragment.from(rowContent)));
576
+ }
577
+ const fragment = this.isColSelection() && this.isRowSelection() ? table : rows;
578
+ return new prosemirror_model.Slice(prosemirror_model.Fragment.from(fragment), 1, 1);
579
+ }
580
+ replace(tr, content = prosemirror_model.Slice.empty) {
581
+ const mapFrom = tr.steps.length, ranges = this.ranges;
582
+ for (let i = 0; i < ranges.length; i++) {
583
+ const { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);
584
+ tr.replace(mapping.map($from.pos), mapping.map($to.pos), i ? prosemirror_model.Slice.empty : content);
585
+ }
586
+ const sel = prosemirror_state.Selection.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);
587
+ if (sel) tr.setSelection(sel);
588
+ }
589
+ replaceWith(tr, node) {
590
+ this.replace(tr, new prosemirror_model.Slice(prosemirror_model.Fragment.from(node), 0, 0));
591
+ }
592
+ forEachCell(f) {
593
+ const table = this.$anchorCell.node(-1);
594
+ const map = TableMap.get(table);
595
+ const tableStart = this.$anchorCell.start(-1);
596
+ const cells = map.cellsInRect(map.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart));
597
+ for (let i = 0; i < cells.length; i++) f(table.nodeAt(cells[i]), tableStart + cells[i]);
598
+ }
599
+ isColSelection() {
600
+ const anchorTop = this.$anchorCell.index(-1);
601
+ const headTop = this.$headCell.index(-1);
602
+ if (Math.min(anchorTop, headTop) > 0) return false;
603
+ const anchorBottom = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;
604
+ const headBottom = headTop + this.$headCell.nodeAfter.attrs.rowspan;
605
+ return Math.max(anchorBottom, headBottom) == this.$headCell.node(-1).childCount;
606
+ }
607
+ static colSelection($anchorCell, $headCell = $anchorCell) {
608
+ const table = $anchorCell.node(-1);
609
+ const map = TableMap.get(table);
610
+ const tableStart = $anchorCell.start(-1);
611
+ const anchorRect = map.findCell($anchorCell.pos - tableStart);
612
+ const headRect = map.findCell($headCell.pos - tableStart);
613
+ const doc = $anchorCell.node(0);
614
+ if (anchorRect.top <= headRect.top) {
615
+ if (anchorRect.top > 0) $anchorCell = doc.resolve(tableStart + map.map[anchorRect.left]);
616
+ if (headRect.bottom < map.height) $headCell = doc.resolve(tableStart + map.map[map.width * (map.height - 1) + headRect.right - 1]);
617
+ } else {
618
+ if (headRect.top > 0) $headCell = doc.resolve(tableStart + map.map[headRect.left]);
619
+ if (anchorRect.bottom < map.height) $anchorCell = doc.resolve(tableStart + map.map[map.width * (map.height - 1) + anchorRect.right - 1]);
620
+ }
621
+ return new CellSelection($anchorCell, $headCell);
622
+ }
623
+ isRowSelection() {
624
+ const table = this.$anchorCell.node(-1);
625
+ const map = TableMap.get(table);
626
+ const tableStart = this.$anchorCell.start(-1);
627
+ const anchorLeft = map.colCount(this.$anchorCell.pos - tableStart);
628
+ const headLeft = map.colCount(this.$headCell.pos - tableStart);
629
+ if (Math.min(anchorLeft, headLeft) > 0) return false;
630
+ const anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;
631
+ const headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;
632
+ return Math.max(anchorRight, headRight) == map.width;
633
+ }
634
+ eq(other) {
635
+ return other instanceof CellSelection && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;
636
+ }
637
+ static rowSelection($anchorCell, $headCell = $anchorCell) {
638
+ const table = $anchorCell.node(-1);
639
+ const map = TableMap.get(table);
640
+ const tableStart = $anchorCell.start(-1);
641
+ const anchorRect = map.findCell($anchorCell.pos - tableStart);
642
+ const headRect = map.findCell($headCell.pos - tableStart);
643
+ const doc = $anchorCell.node(0);
644
+ if (anchorRect.left <= headRect.left) {
645
+ if (anchorRect.left > 0) $anchorCell = doc.resolve(tableStart + map.map[anchorRect.top * map.width]);
646
+ if (headRect.right < map.width) $headCell = doc.resolve(tableStart + map.map[map.width * (headRect.top + 1) - 1]);
647
+ } else {
648
+ if (headRect.left > 0) $headCell = doc.resolve(tableStart + map.map[headRect.top * map.width]);
649
+ if (anchorRect.right < map.width) $anchorCell = doc.resolve(tableStart + map.map[map.width * (anchorRect.top + 1) - 1]);
650
+ }
651
+ return new CellSelection($anchorCell, $headCell);
652
+ }
653
+ toJSON() {
654
+ return {
655
+ type: "cell",
656
+ anchor: this.$anchorCell.pos,
657
+ head: this.$headCell.pos
658
+ };
659
+ }
660
+ static fromJSON(doc, json) {
661
+ return new CellSelection(doc.resolve(json.anchor), doc.resolve(json.head));
662
+ }
663
+ static create(doc, anchorCell, headCell = anchorCell) {
664
+ return new CellSelection(doc.resolve(anchorCell), doc.resolve(headCell));
665
+ }
666
+ getBookmark() {
667
+ return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
668
+ }
669
+ };
670
+ CellSelection.prototype.visible = false;
671
+ prosemirror_state.Selection.jsonID("cell", CellSelection);
672
+ /**
673
+ * @public
674
+ */
675
+ var CellBookmark = class CellBookmark {
676
+ constructor(anchor, head) {
677
+ this.anchor = anchor;
678
+ this.head = head;
679
+ }
680
+ map(mapping) {
681
+ return new CellBookmark(mapping.map(this.anchor), mapping.map(this.head));
682
+ }
683
+ resolve(doc) {
684
+ const $anchorCell = doc.resolve(this.anchor), $headCell = doc.resolve(this.head);
685
+ if ($anchorCell.parent.type.spec.tableRole == "row" && $headCell.parent.type.spec.tableRole == "row" && $anchorCell.index() < $anchorCell.parent.childCount && $headCell.index() < $headCell.parent.childCount && inSameTable($anchorCell, $headCell)) return new CellSelection($anchorCell, $headCell);
686
+ else return prosemirror_state.Selection.near($headCell, 1);
687
+ }
688
+ };
689
+ function drawCellSelection(state) {
690
+ if (!(state.selection instanceof CellSelection)) return null;
691
+ const cells = [];
692
+ state.selection.forEachCell((node, pos) => {
693
+ cells.push(prosemirror_view.Decoration.node(pos, pos + node.nodeSize, { class: "selectedCell" }));
694
+ });
695
+ return prosemirror_view.DecorationSet.create(state.doc, cells);
696
+ }
697
+ function isCellBoundarySelection({ $from, $to }) {
698
+ if ($from.pos == $to.pos || $from.pos < $to.pos - 6) return false;
699
+ let afterFrom = $from.pos;
700
+ let beforeTo = $to.pos;
701
+ let depth = $from.depth;
702
+ for (; depth >= 0; depth--, afterFrom++) if ($from.after(depth + 1) < $from.end(depth)) break;
703
+ for (let d = $to.depth; d >= 0; d--, beforeTo--) if ($to.before(d + 1) > $to.start(d)) break;
704
+ return afterFrom == beforeTo && /row|table/.test($from.node(depth).type.spec.tableRole);
705
+ }
706
+ function isTextSelectionAcrossCells({ $from, $to }) {
707
+ let fromCellBoundaryNode;
708
+ let toCellBoundaryNode;
709
+ for (let i = $from.depth; i > 0; i--) {
710
+ const node = $from.node(i);
711
+ if (node.type.spec.tableRole === "cell" || node.type.spec.tableRole === "header_cell") {
712
+ fromCellBoundaryNode = node;
713
+ break;
714
+ }
715
+ }
716
+ for (let i = $to.depth; i > 0; i--) {
717
+ const node = $to.node(i);
718
+ if (node.type.spec.tableRole === "cell" || node.type.spec.tableRole === "header_cell") {
719
+ toCellBoundaryNode = node;
720
+ break;
721
+ }
722
+ }
723
+ return fromCellBoundaryNode !== toCellBoundaryNode && $to.parentOffset === 0;
724
+ }
725
+ function normalizeSelection(state, tr, allowTableNodeSelection) {
726
+ const sel = (tr || state).selection;
727
+ const doc = (tr || state).doc;
728
+ let normalize;
729
+ let role;
730
+ if (sel instanceof prosemirror_state.NodeSelection && (role = sel.node.type.spec.tableRole)) {
731
+ if (role == "cell" || role == "header_cell") normalize = CellSelection.create(doc, sel.from);
732
+ else if (role == "row") {
733
+ const $cell = doc.resolve(sel.from + 1);
734
+ normalize = CellSelection.rowSelection($cell, $cell);
735
+ } else if (!allowTableNodeSelection) {
736
+ const map = TableMap.get(sel.node);
737
+ const start = sel.from + 1;
738
+ const lastCell = start + map.map[map.width * map.height - 1];
739
+ normalize = CellSelection.create(doc, start + 1, lastCell);
740
+ }
741
+ } else if (sel instanceof prosemirror_state.TextSelection && isCellBoundarySelection(sel)) normalize = prosemirror_state.TextSelection.create(doc, sel.from);
742
+ else if (sel instanceof prosemirror_state.TextSelection && isTextSelectionAcrossCells(sel)) normalize = prosemirror_state.TextSelection.create(doc, sel.$from.start(), sel.$from.end());
743
+ if (normalize) (tr || (tr = state.tr)).setSelection(normalize);
744
+ return tr;
745
+ }
746
+
747
+ //#endregion
748
+ //#region src/fixtables.ts
749
+ /**
750
+ * @public
751
+ */
752
+ const fixTablesKey = new prosemirror_state.PluginKey("fix-tables");
753
+ /**
754
+ * Helper for iterating through the nodes in a document that changed
755
+ * compared to the given previous document. Useful for avoiding
756
+ * duplicate work on each transaction.
757
+ *
758
+ * @public
759
+ */
760
+ function changedDescendants(old, cur, offset, f) {
761
+ const oldSize = old.childCount, curSize = cur.childCount;
762
+ outer: for (let i = 0, j = 0; i < curSize; i++) {
763
+ const child = cur.child(i);
764
+ for (let scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) if (old.child(scan) == child) {
765
+ j = scan + 1;
766
+ offset += child.nodeSize;
767
+ continue outer;
768
+ }
769
+ f(child, offset);
770
+ if (j < oldSize && old.child(j).sameMarkup(child)) changedDescendants(old.child(j), child, offset + 1, f);
771
+ else child.nodesBetween(0, child.content.size, f, offset + 1);
772
+ offset += child.nodeSize;
773
+ }
774
+ }
775
+ /**
776
+ * Inspect all tables in the given state's document and return a
777
+ * transaction that fixes them, if necessary. If `oldState` was
778
+ * provided, that is assumed to hold a previous, known-good state,
779
+ * which will be used to avoid re-scanning unchanged parts of the
780
+ * document.
781
+ *
782
+ * @public
783
+ */
784
+ function fixTables(state, oldState) {
785
+ let tr;
786
+ const check = (node, pos) => {
787
+ if (node.type.spec.tableRole == "table") tr = fixTable(state, node, pos, tr);
788
+ };
789
+ if (!oldState) state.doc.descendants(check);
790
+ else if (oldState.doc != state.doc) changedDescendants(oldState.doc, state.doc, 0, check);
791
+ return tr;
792
+ }
793
+ function fixTable(state, table, tablePos, tr) {
794
+ const map = TableMap.get(table);
795
+ if (!map.problems) return tr;
796
+ if (!tr) tr = state.tr;
797
+ const mustAdd = [];
798
+ for (let i = 0; i < map.height; i++) mustAdd.push(0);
799
+ for (let i = 0; i < map.problems.length; i++) {
800
+ const prob = map.problems[i];
801
+ if (prob.type == "collision") {
802
+ const cell = table.nodeAt(prob.pos);
803
+ if (!cell) continue;
804
+ const attrs = cell.attrs;
805
+ for (let j = 0; j < attrs.rowspan; j++) mustAdd[prob.row + j] += prob.n;
806
+ tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, removeColSpan(attrs, attrs.colspan - prob.n, prob.n));
807
+ } else if (prob.type == "missing") mustAdd[prob.row] += prob.n;
808
+ else if (prob.type == "overlong_rowspan") {
809
+ const cell = table.nodeAt(prob.pos);
810
+ if (!cell) continue;
811
+ tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {
812
+ ...cell.attrs,
813
+ rowspan: cell.attrs.rowspan - prob.n
814
+ });
815
+ } else if (prob.type == "colwidth mismatch") {
816
+ const cell = table.nodeAt(prob.pos);
817
+ if (!cell) continue;
818
+ tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {
819
+ ...cell.attrs,
820
+ colwidth: prob.colwidth
821
+ });
822
+ } else if (prob.type == "zero_sized") {
823
+ const pos = tr.mapping.map(tablePos);
824
+ tr.delete(pos, pos + table.nodeSize);
825
+ }
826
+ }
827
+ let first, last;
828
+ for (let i = 0; i < mustAdd.length; i++) if (mustAdd[i]) {
829
+ if (first == null) first = i;
830
+ last = i;
831
+ }
832
+ for (let i = 0, pos = tablePos + 1; i < map.height; i++) {
833
+ const row = table.child(i);
834
+ const end = pos + row.nodeSize;
835
+ const add = mustAdd[i];
836
+ if (add > 0) {
837
+ let role = "cell";
838
+ if (row.firstChild) role = row.firstChild.type.spec.tableRole;
839
+ const nodes = [];
840
+ for (let j = 0; j < add; j++) {
841
+ const node = tableNodeTypes(state.schema)[role].createAndFill();
842
+ if (node) nodes.push(node);
843
+ }
844
+ const side = (i == 0 || first == i - 1) && last == i ? pos + 1 : end - 1;
845
+ tr.insert(tr.mapping.map(side), nodes);
846
+ }
847
+ pos = end;
848
+ }
849
+ return tr.setMeta(fixTablesKey, { fixTables: true });
850
+ }
851
+
852
+ //#endregion
853
+ //#region src/utils/convert.ts
854
+ /**
855
+ * This function will transform the table node into a matrix of rows and columns
856
+ * respecting merged cells, for example this table:
857
+ *
858
+ * ```
859
+ * ┌──────┬──────┬─────────────┐
860
+ * │ A1 │ B1 │ C1 │
861
+ * ├──────┼──────┴──────┬──────┤
862
+ * │ A2 │ B2 │ │
863
+ * ├──────┼─────────────┤ D1 │
864
+ * │ A3 │ B3 │ C3 │ │
865
+ * └──────┴──────┴──────┴──────┘
866
+ * ```
867
+ *
868
+ * will be converted to the below:
869
+ *
870
+ * ```javascript
871
+ * [
872
+ * [A1, B1, C1, null],
873
+ * [A2, B2, null, D1],
874
+ * [A3, B3, C3, null],
875
+ * ]
876
+ * ```
877
+ * @internal
878
+ */
879
+ function convertTableNodeToArrayOfRows(tableNode) {
880
+ const map = TableMap.get(tableNode);
881
+ const rows = [];
882
+ const rowCount = map.height;
883
+ const colCount$1 = map.width;
884
+ for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
885
+ const row = [];
886
+ for (let colIndex = 0; colIndex < colCount$1; colIndex++) {
887
+ const cellIndex = rowIndex * colCount$1 + colIndex;
888
+ const cellPos = map.map[cellIndex];
889
+ if (rowIndex > 0) {
890
+ const topCellIndex = cellIndex - colCount$1;
891
+ if (cellPos === map.map[topCellIndex]) {
892
+ row.push(null);
893
+ continue;
894
+ }
895
+ }
896
+ if (colIndex > 0) {
897
+ const leftCellIndex = cellIndex - 1;
898
+ if (cellPos === map.map[leftCellIndex]) {
899
+ row.push(null);
900
+ continue;
901
+ }
902
+ }
903
+ row.push(tableNode.nodeAt(cellPos));
904
+ }
905
+ rows.push(row);
906
+ }
907
+ return rows;
908
+ }
909
+ /**
910
+ * Convert an array of rows to a table node.
911
+ *
912
+ * @internal
913
+ */
914
+ function convertArrayOfRowsToTableNode(tableNode, arrayOfNodes) {
915
+ const newRows = [];
916
+ const map = TableMap.get(tableNode);
917
+ const rowCount = map.height;
918
+ const colCount$1 = map.width;
919
+ for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
920
+ const oldRow = tableNode.child(rowIndex);
921
+ const newCells = [];
922
+ for (let colIndex = 0; colIndex < colCount$1; colIndex++) {
923
+ const cell = arrayOfNodes[rowIndex][colIndex];
924
+ if (!cell) continue;
925
+ const cellPos = map.map[rowIndex * map.width + colIndex];
926
+ const oldCell = tableNode.nodeAt(cellPos);
927
+ if (!oldCell) continue;
928
+ const newCell = oldCell.type.createChecked(cell.attrs, cell.content, cell.marks);
929
+ newCells.push(newCell);
930
+ }
931
+ const newRow = oldRow.type.createChecked(oldRow.attrs, newCells, oldRow.marks);
932
+ newRows.push(newRow);
933
+ }
934
+ return tableNode.type.createChecked(tableNode.attrs, newRows, tableNode.marks);
935
+ }
936
+
937
+ //#endregion
938
+ //#region src/utils/move-row-in-array-of-rows.ts
939
+ /**
940
+ * Move a row in an array of rows.
941
+ *
942
+ * @internal
943
+ */
944
+ function moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, directionOverride) {
945
+ const direction = indexesOrigin[0] > indexesTarget[0] ? -1 : 1;
946
+ const rowsExtracted = rows.splice(indexesOrigin[0], indexesOrigin.length);
947
+ const positionOffset = rowsExtracted.length % 2 === 0 ? 1 : 0;
948
+ let target;
949
+ if (directionOverride === -1 && direction === 1) target = indexesTarget[0] - 1;
950
+ else if (directionOverride === 1 && direction === -1) target = indexesTarget[indexesTarget.length - 1] - positionOffset + 1;
951
+ else target = direction === -1 ? indexesTarget[0] : indexesTarget[indexesTarget.length - 1] - positionOffset;
952
+ rows.splice(target, 0, ...rowsExtracted);
953
+ return rows;
954
+ }
955
+
956
+ //#endregion
957
+ //#region src/utils/query.ts
958
+ /**
959
+ * Checks if the given object is a `CellSelection` instance.
960
+ *
961
+ * @internal
962
+ */
963
+ function isCellSelection(value) {
964
+ return value instanceof CellSelection;
965
+ }
966
+ /**
967
+ * Find the closest table node for a given position.
968
+ *
969
+ * @public
970
+ */
971
+ function findTable($pos) {
972
+ return findParentNode((node) => node.type.spec.tableRole === "table", $pos);
973
+ }
974
+ /**
975
+ * Try to find the anchor and head cell in the same table by using the given
976
+ * anchor and head as hit points, or fallback to the selection's anchor and
977
+ * head.
978
+ *
979
+ * @public
980
+ */
981
+ function findCellRange(selection, anchorHit, headHit) {
982
+ var _ref, _ref2;
983
+ if (anchorHit == null && headHit == null && isCellSelection(selection)) return [selection.$anchorCell, selection.$headCell];
984
+ const anchor = (_ref = anchorHit !== null && anchorHit !== void 0 ? anchorHit : headHit) !== null && _ref !== void 0 ? _ref : selection.anchor;
985
+ const head = (_ref2 = headHit !== null && headHit !== void 0 ? headHit : anchorHit) !== null && _ref2 !== void 0 ? _ref2 : selection.head;
986
+ const doc = selection.$head.doc;
987
+ const $anchorCell = findCellPos(doc, anchor);
988
+ const $headCell = findCellPos(doc, head);
989
+ if ($anchorCell && $headCell && inSameTable($anchorCell, $headCell)) return [$anchorCell, $headCell];
990
+ return null;
991
+ }
992
+ /**
993
+ * Try to find a resolved pos of a cell by using the given pos as a hit point.
994
+ *
995
+ * @public
996
+ */
997
+ function findCellPos(doc, pos) {
998
+ const $pos = doc.resolve(pos);
999
+ return cellAround($pos) || cellNear($pos);
1000
+ }
1001
+ /**
1002
+ * Find the closest parent node that satisfies the predicate.
1003
+ *
1004
+ * @internal
1005
+ */
1006
+ function findParentNode(predicate, $pos) {
1007
+ for (let depth = $pos.depth; depth >= 0; depth -= 1) {
1008
+ const node = $pos.node(depth);
1009
+ if (predicate(node)) return {
1010
+ node,
1011
+ pos: depth === 0 ? 0 : $pos.before(depth),
1012
+ start: $pos.start(depth),
1013
+ depth
1014
+ };
1015
+ }
1016
+ return null;
1017
+ }
1018
+
1019
+ //#endregion
1020
+ //#region src/utils/get-cells.ts
1021
+ /**
1022
+ * Returns an array of cells in a column at the specified column index.
1023
+ *
1024
+ * @internal
1025
+ */
1026
+ function getCellsInColumn(columnIndex, selection) {
1027
+ const table = findTable(selection.$from);
1028
+ if (!table) return;
1029
+ const map = TableMap.get(table.node);
1030
+ if (columnIndex < 0 || columnIndex > map.width - 1) return;
1031
+ return map.cellsInRect({
1032
+ left: columnIndex,
1033
+ right: columnIndex + 1,
1034
+ top: 0,
1035
+ bottom: map.height
1036
+ }).map((nodePos) => {
1037
+ const node = table.node.nodeAt(nodePos);
1038
+ const pos = nodePos + table.start;
1039
+ return {
1040
+ pos,
1041
+ start: pos + 1,
1042
+ node,
1043
+ depth: table.depth + 2
1044
+ };
1045
+ });
1046
+ }
1047
+ /**
1048
+ * Returns an array of cells in a row at the specified row index.
1049
+ *
1050
+ * @internal
1051
+ */
1052
+ function getCellsInRow(rowIndex, selection) {
1053
+ const table = findTable(selection.$from);
1054
+ if (!table) return;
1055
+ const map = TableMap.get(table.node);
1056
+ if (rowIndex < 0 || rowIndex > map.height - 1) return;
1057
+ return map.cellsInRect({
1058
+ left: 0,
1059
+ right: map.width,
1060
+ top: rowIndex,
1061
+ bottom: rowIndex + 1
1062
+ }).map((nodePos) => {
1063
+ const node = table.node.nodeAt(nodePos);
1064
+ const pos = nodePos + table.start;
1065
+ return {
1066
+ pos,
1067
+ start: pos + 1,
1068
+ node,
1069
+ depth: table.depth + 2
1070
+ };
1071
+ });
1072
+ }
1073
+
1074
+ //#endregion
1075
+ //#region src/utils/selection-range.ts
1076
+ /**
1077
+ * Returns a range of rectangular selection spanning all merged cells around a
1078
+ * column at index `columnIndex`.
1079
+ *
1080
+ * Original implementation from Atlassian (Apache License 2.0)
1081
+ *
1082
+ * https://bitbucket.org/atlassian/atlassian-frontend-mirror/src/5f91cb871e8248bc3bae5ddc30bb9fd9200fadbb/editor/editor-tables/src/utils/get-selection-range-in-column.ts#editor/editor-tables/src/utils/get-selection-range-in-column.ts
1083
+ *
1084
+ * @internal
1085
+ */
1086
+ function getSelectionRangeInColumn(tr, startColIndex, endColIndex = startColIndex) {
1087
+ let startIndex = startColIndex;
1088
+ let endIndex = endColIndex;
1089
+ for (let i = startColIndex; i >= 0; i--) {
1090
+ const cells = getCellsInColumn(i, tr.selection);
1091
+ if (cells) cells.forEach((cell) => {
1092
+ const maybeEndIndex = cell.node.attrs.colspan + i - 1;
1093
+ if (maybeEndIndex >= startIndex) startIndex = i;
1094
+ if (maybeEndIndex > endIndex) endIndex = maybeEndIndex;
1095
+ });
1096
+ }
1097
+ for (let i = startColIndex; i <= endIndex; i++) {
1098
+ const cells = getCellsInColumn(i, tr.selection);
1099
+ if (cells) cells.forEach((cell) => {
1100
+ const maybeEndIndex = cell.node.attrs.colspan + i - 1;
1101
+ if (cell.node.attrs.colspan > 1 && maybeEndIndex > endIndex) endIndex = maybeEndIndex;
1102
+ });
1103
+ }
1104
+ const indexes = [];
1105
+ for (let i = startIndex; i <= endIndex; i++) {
1106
+ const maybeCells = getCellsInColumn(i, tr.selection);
1107
+ if (maybeCells && maybeCells.length > 0) indexes.push(i);
1108
+ }
1109
+ startIndex = indexes[0];
1110
+ endIndex = indexes[indexes.length - 1];
1111
+ const firstSelectedColumnCells = getCellsInColumn(startIndex, tr.selection);
1112
+ const firstRowCells = getCellsInRow(0, tr.selection);
1113
+ if (!firstSelectedColumnCells || !firstRowCells) return;
1114
+ const $anchor = tr.doc.resolve(firstSelectedColumnCells[firstSelectedColumnCells.length - 1].pos);
1115
+ let headCell;
1116
+ for (let i = endIndex; i >= startIndex; i--) {
1117
+ const columnCells = getCellsInColumn(i, tr.selection);
1118
+ if (columnCells && columnCells.length > 0) {
1119
+ for (let j = firstRowCells.length - 1; j >= 0; j--) if (firstRowCells[j].pos === columnCells[0].pos) {
1120
+ headCell = columnCells[0];
1121
+ break;
1122
+ }
1123
+ if (headCell) break;
1124
+ }
1125
+ }
1126
+ if (!headCell) return;
1127
+ return {
1128
+ $anchor,
1129
+ $head: tr.doc.resolve(headCell.pos),
1130
+ indexes
1131
+ };
1132
+ }
1133
+ /**
1134
+ * Returns a range of rectangular selection spanning all merged cells around a
1135
+ * row at index `rowIndex`.
1136
+ *
1137
+ * Original implementation from Atlassian (Apache License 2.0)
1138
+ *
1139
+ * https://bitbucket.org/atlassian/atlassian-frontend-mirror/src/5f91cb871e8248bc3bae5ddc30bb9fd9200fadbb/editor/editor-tables/src/utils/get-selection-range-in-row.ts#editor/editor-tables/src/utils/get-selection-range-in-row.ts
1140
+ *
1141
+ * @internal
1142
+ */
1143
+ function getSelectionRangeInRow(tr, startRowIndex, endRowIndex = startRowIndex) {
1144
+ let startIndex = startRowIndex;
1145
+ let endIndex = endRowIndex;
1146
+ for (let i = startRowIndex; i >= 0; i--) {
1147
+ const cells = getCellsInRow(i, tr.selection);
1148
+ if (cells) cells.forEach((cell) => {
1149
+ const maybeEndIndex = cell.node.attrs.rowspan + i - 1;
1150
+ if (maybeEndIndex >= startIndex) startIndex = i;
1151
+ if (maybeEndIndex > endIndex) endIndex = maybeEndIndex;
1152
+ });
1153
+ }
1154
+ for (let i = startRowIndex; i <= endIndex; i++) {
1155
+ const cells = getCellsInRow(i, tr.selection);
1156
+ if (cells) cells.forEach((cell) => {
1157
+ const maybeEndIndex = cell.node.attrs.rowspan + i - 1;
1158
+ if (cell.node.attrs.rowspan > 1 && maybeEndIndex > endIndex) endIndex = maybeEndIndex;
1159
+ });
1160
+ }
1161
+ const indexes = [];
1162
+ for (let i = startIndex; i <= endIndex; i++) {
1163
+ const maybeCells = getCellsInRow(i, tr.selection);
1164
+ if (maybeCells && maybeCells.length > 0) indexes.push(i);
1165
+ }
1166
+ startIndex = indexes[0];
1167
+ endIndex = indexes[indexes.length - 1];
1168
+ const firstSelectedRowCells = getCellsInRow(startIndex, tr.selection);
1169
+ const firstColumnCells = getCellsInColumn(0, tr.selection);
1170
+ if (!firstSelectedRowCells || !firstColumnCells) return;
1171
+ const $anchor = tr.doc.resolve(firstSelectedRowCells[firstSelectedRowCells.length - 1].pos);
1172
+ let headCell;
1173
+ for (let i = endIndex; i >= startIndex; i--) {
1174
+ const rowCells = getCellsInRow(i, tr.selection);
1175
+ if (rowCells && rowCells.length > 0) {
1176
+ for (let j = firstColumnCells.length - 1; j >= 0; j--) if (firstColumnCells[j].pos === rowCells[0].pos) {
1177
+ headCell = rowCells[0];
1178
+ break;
1179
+ }
1180
+ if (headCell) break;
1181
+ }
1182
+ }
1183
+ if (!headCell) return;
1184
+ return {
1185
+ $anchor,
1186
+ $head: tr.doc.resolve(headCell.pos),
1187
+ indexes
1188
+ };
1189
+ }
1190
+
1191
+ //#endregion
1192
+ //#region src/utils/transpose.ts
1193
+ /**
1194
+ * Transposes a 2D array by flipping columns to rows.
1195
+ *
1196
+ * Transposition is a familiar algebra concept where the matrix is flipped
1197
+ * along its diagonal. For more details, see:
1198
+ * https://en.wikipedia.org/wiki/Transpose
1199
+ *
1200
+ * @example
1201
+ * ```javascript
1202
+ * const arr = [
1203
+ * ['a1', 'a2', 'a3'],
1204
+ * ['b1', 'b2', 'b3'],
1205
+ * ['c1', 'c2', 'c3'],
1206
+ * ['d1', 'd2', 'd3'],
1207
+ * ];
1208
+ *
1209
+ * const result = transpose(arr);
1210
+ * result === [
1211
+ * ['a1', 'b1', 'c1', 'd1'],
1212
+ * ['a2', 'b2', 'c2', 'd2'],
1213
+ * ['a3', 'b3', 'c3', 'd3'],
1214
+ * ]
1215
+ * ```
1216
+ */
1217
+ function transpose(array) {
1218
+ return array[0].map((_, i) => {
1219
+ return array.map((column) => column[i]);
1220
+ });
1221
+ }
1222
+
1223
+ //#endregion
1224
+ //#region src/utils/move-column.ts
1225
+ /**
1226
+ * Move a column from index `origin` to index `target`.
1227
+ *
1228
+ * @internal
1229
+ */
1230
+ function moveColumn(moveColParams) {
1231
+ var _getSelectionRangeInC, _getSelectionRangeInC2;
1232
+ const { tr, originIndex, targetIndex, select, pos } = moveColParams;
1233
+ const table = findTable(tr.doc.resolve(pos));
1234
+ if (!table) return false;
1235
+ const indexesOriginColumn = (_getSelectionRangeInC = getSelectionRangeInColumn(tr, originIndex)) === null || _getSelectionRangeInC === void 0 ? void 0 : _getSelectionRangeInC.indexes;
1236
+ const indexesTargetColumn = (_getSelectionRangeInC2 = getSelectionRangeInColumn(tr, targetIndex)) === null || _getSelectionRangeInC2 === void 0 ? void 0 : _getSelectionRangeInC2.indexes;
1237
+ if (!indexesOriginColumn || !indexesTargetColumn) return false;
1238
+ if (indexesOriginColumn.includes(targetIndex)) return false;
1239
+ const newTable = moveTableColumn$1(table.node, indexesOriginColumn, indexesTargetColumn, 0);
1240
+ tr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);
1241
+ if (!select) return true;
1242
+ const map = TableMap.get(newTable);
1243
+ const start = table.start;
1244
+ const index = targetIndex;
1245
+ const lastCell = map.positionAt(map.height - 1, index, newTable);
1246
+ const $lastCell = tr.doc.resolve(start + lastCell);
1247
+ const firstCell = map.positionAt(0, index, newTable);
1248
+ const $firstCell = tr.doc.resolve(start + firstCell);
1249
+ tr.setSelection(CellSelection.colSelection($lastCell, $firstCell));
1250
+ return true;
1251
+ }
1252
+ function moveTableColumn$1(table, indexesOrigin, indexesTarget, direction) {
1253
+ let rows = transpose(convertTableNodeToArrayOfRows(table));
1254
+ rows = moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, direction);
1255
+ rows = transpose(rows);
1256
+ return convertArrayOfRowsToTableNode(table, rows);
1257
+ }
1258
+
1259
+ //#endregion
1260
+ //#region src/utils/move-row.ts
1261
+ /**
1262
+ * Move a row from index `origin` to index `target`.
1263
+ *
1264
+ * @internal
1265
+ */
1266
+ function moveRow(moveRowParams) {
1267
+ var _getSelectionRangeInR, _getSelectionRangeInR2;
1268
+ const { tr, originIndex, targetIndex, select, pos } = moveRowParams;
1269
+ const table = findTable(tr.doc.resolve(pos));
1270
+ if (!table) return false;
1271
+ const indexesOriginRow = (_getSelectionRangeInR = getSelectionRangeInRow(tr, originIndex)) === null || _getSelectionRangeInR === void 0 ? void 0 : _getSelectionRangeInR.indexes;
1272
+ const indexesTargetRow = (_getSelectionRangeInR2 = getSelectionRangeInRow(tr, targetIndex)) === null || _getSelectionRangeInR2 === void 0 ? void 0 : _getSelectionRangeInR2.indexes;
1273
+ if (!indexesOriginRow || !indexesTargetRow) return false;
1274
+ if (indexesOriginRow.includes(targetIndex)) return false;
1275
+ const newTable = moveTableRow$1(table.node, indexesOriginRow, indexesTargetRow, 0);
1276
+ tr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);
1277
+ if (!select) return true;
1278
+ const map = TableMap.get(newTable);
1279
+ const start = table.start;
1280
+ const index = targetIndex;
1281
+ const lastCell = map.positionAt(index, map.width - 1, newTable);
1282
+ const $lastCell = tr.doc.resolve(start + lastCell);
1283
+ const firstCell = map.positionAt(index, 0, newTable);
1284
+ const $firstCell = tr.doc.resolve(start + firstCell);
1285
+ tr.setSelection(CellSelection.rowSelection($lastCell, $firstCell));
1286
+ return true;
1287
+ }
1288
+ function moveTableRow$1(table, indexesOrigin, indexesTarget, direction) {
1289
+ let rows = convertTableNodeToArrayOfRows(table);
1290
+ rows = moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, direction);
1291
+ return convertArrayOfRowsToTableNode(table, rows);
1292
+ }
1293
+
1294
+ //#endregion
1295
+ //#region src/commands.ts
1296
+ /**
1297
+ * Helper to get the selected rectangle in a table, if any. Adds table
1298
+ * map, table node, and table start offset to the object for
1299
+ * convenience.
1300
+ *
1301
+ * @public
1302
+ */
1303
+ function selectedRect(state) {
1304
+ const sel = state.selection;
1305
+ const $pos = selectionCell(state);
1306
+ const table = $pos.node(-1);
1307
+ const tableStart = $pos.start(-1);
1308
+ const map = TableMap.get(table);
1309
+ return {
1310
+ ...sel instanceof CellSelection ? map.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart) : map.findCell($pos.pos - tableStart),
1311
+ tableStart,
1312
+ map,
1313
+ table
1314
+ };
1315
+ }
1316
+ /**
1317
+ * Add a column at the given position in a table.
1318
+ *
1319
+ * @public
1320
+ */
1321
+ function addColumn(tr, { map, tableStart, table }, col) {
1322
+ let refColumn = col > 0 ? -1 : 0;
1323
+ if (columnIsHeader(map, table, col + refColumn)) refColumn = col == 0 || col == map.width ? null : 0;
1324
+ for (let row = 0; row < map.height; row++) {
1325
+ const index = row * map.width + col;
1326
+ if (col > 0 && col < map.width && map.map[index - 1] == map.map[index]) {
1327
+ const pos = map.map[index];
1328
+ const cell = table.nodeAt(pos);
1329
+ tr.setNodeMarkup(tr.mapping.map(tableStart + pos), null, addColSpan(cell.attrs, col - map.colCount(pos)));
1330
+ row += cell.attrs.rowspan - 1;
1331
+ } else {
1332
+ const type = refColumn == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + refColumn]).type;
1333
+ const pos = map.positionAt(row, col, table);
1334
+ tr.insert(tr.mapping.map(tableStart + pos), type.createAndFill());
1335
+ }
1336
+ }
1337
+ return tr;
1338
+ }
1339
+ /**
1340
+ * Command to add a column before the column with the selection.
1341
+ *
1342
+ * @public
1343
+ */
1344
+ function addColumnBefore(state, dispatch) {
1345
+ if (!isInTable(state)) return false;
1346
+ if (dispatch) {
1347
+ const rect = selectedRect(state);
1348
+ dispatch(addColumn(state.tr, rect, rect.left));
1349
+ }
1350
+ return true;
1351
+ }
1352
+ /**
1353
+ * Command to add a column after the column with the selection.
1354
+ *
1355
+ * @public
1356
+ */
1357
+ function addColumnAfter(state, dispatch) {
1358
+ if (!isInTable(state)) return false;
1359
+ if (dispatch) {
1360
+ const rect = selectedRect(state);
1361
+ dispatch(addColumn(state.tr, rect, rect.right));
1362
+ }
1363
+ return true;
1364
+ }
1365
+ /**
1366
+ * @public
1367
+ */
1368
+ function removeColumn(tr, { map, table, tableStart }, col) {
1369
+ const mapStart = tr.mapping.maps.length;
1370
+ for (let row = 0; row < map.height;) {
1371
+ const index = row * map.width + col;
1372
+ const pos = map.map[index];
1373
+ const cell = table.nodeAt(pos);
1374
+ const attrs = cell.attrs;
1375
+ if (col > 0 && map.map[index - 1] == pos || col < map.width - 1 && map.map[index + 1] == pos) tr.setNodeMarkup(tr.mapping.slice(mapStart).map(tableStart + pos), null, removeColSpan(attrs, col - map.colCount(pos)));
1376
+ else {
1377
+ const start = tr.mapping.slice(mapStart).map(tableStart + pos);
1378
+ tr.delete(start, start + cell.nodeSize);
1379
+ }
1380
+ row += attrs.rowspan;
1381
+ }
1382
+ }
1383
+ /**
1384
+ * Command function that removes the selected columns from a table.
1385
+ *
1386
+ * @public
1387
+ */
1388
+ function deleteColumn(state, dispatch) {
1389
+ if (!isInTable(state)) return false;
1390
+ if (dispatch) {
1391
+ const rect = selectedRect(state);
1392
+ const tr = state.tr;
1393
+ if (rect.left == 0 && rect.right == rect.map.width) return false;
1394
+ for (let i = rect.right - 1;; i--) {
1395
+ removeColumn(tr, rect, i);
1396
+ if (i == rect.left) break;
1397
+ const table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
1398
+ if (!table) throw new RangeError("No table found");
1399
+ rect.table = table;
1400
+ rect.map = TableMap.get(table);
1401
+ }
1402
+ dispatch(tr);
1403
+ }
1404
+ return true;
1405
+ }
1406
+ /**
1407
+ * @public
1408
+ */
1409
+ function rowIsHeader(map, table, row) {
1410
+ var _table$nodeAt;
1411
+ const headerCell = tableNodeTypes(table.type.schema).header_cell;
1412
+ for (let col = 0; col < map.width; col++) if (((_table$nodeAt = table.nodeAt(map.map[col + row * map.width])) === null || _table$nodeAt === void 0 ? void 0 : _table$nodeAt.type) != headerCell) return false;
1413
+ return true;
1414
+ }
1415
+ /**
1416
+ * @public
1417
+ */
1418
+ function addRow(tr, { map, tableStart, table }, row) {
1419
+ let rowPos = tableStart;
1420
+ for (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize;
1421
+ const cells = [];
1422
+ let refRow = row > 0 ? -1 : 0;
1423
+ if (rowIsHeader(map, table, row + refRow)) refRow = row == 0 || row == map.height ? null : 0;
1424
+ for (let col = 0, index = map.width * row; col < map.width; col++, index++) if (row > 0 && row < map.height && map.map[index] == map.map[index - map.width]) {
1425
+ const pos = map.map[index];
1426
+ const attrs = table.nodeAt(pos).attrs;
1427
+ tr.setNodeMarkup(tableStart + pos, null, {
1428
+ ...attrs,
1429
+ rowspan: attrs.rowspan + 1
1430
+ });
1431
+ col += attrs.colspan - 1;
1432
+ } else {
1433
+ var _table$nodeAt2;
1434
+ const type = refRow == null ? tableNodeTypes(table.type.schema).cell : (_table$nodeAt2 = table.nodeAt(map.map[index + refRow * map.width])) === null || _table$nodeAt2 === void 0 ? void 0 : _table$nodeAt2.type;
1435
+ const node = type === null || type === void 0 ? void 0 : type.createAndFill();
1436
+ if (node) cells.push(node);
1437
+ }
1438
+ tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));
1439
+ return tr;
1440
+ }
1441
+ /**
1442
+ * Add a table row before the selection.
1443
+ *
1444
+ * @public
1445
+ */
1446
+ function addRowBefore(state, dispatch) {
1447
+ if (!isInTable(state)) return false;
1448
+ if (dispatch) {
1449
+ const rect = selectedRect(state);
1450
+ dispatch(addRow(state.tr, rect, rect.top));
1451
+ }
1452
+ return true;
1453
+ }
1454
+ /**
1455
+ * Add a table row after the selection.
1456
+ *
1457
+ * @public
1458
+ */
1459
+ function addRowAfter(state, dispatch) {
1460
+ if (!isInTable(state)) return false;
1461
+ if (dispatch) {
1462
+ const rect = selectedRect(state);
1463
+ dispatch(addRow(state.tr, rect, rect.bottom));
1464
+ }
1465
+ return true;
1466
+ }
1467
+ /**
1468
+ * @public
1469
+ */
1470
+ function removeRow(tr, { map, table, tableStart }, row) {
1471
+ let rowPos = 0;
1472
+ for (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize;
1473
+ const nextRow = rowPos + table.child(row).nodeSize;
1474
+ const mapFrom = tr.mapping.maps.length;
1475
+ tr.delete(rowPos + tableStart, nextRow + tableStart);
1476
+ const seen = /* @__PURE__ */ new Set();
1477
+ for (let col = 0, index = row * map.width; col < map.width; col++, index++) {
1478
+ const pos = map.map[index];
1479
+ if (seen.has(pos)) continue;
1480
+ seen.add(pos);
1481
+ if (row > 0 && pos == map.map[index - map.width]) {
1482
+ const attrs = table.nodeAt(pos).attrs;
1483
+ tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, {
1484
+ ...attrs,
1485
+ rowspan: attrs.rowspan - 1
1486
+ });
1487
+ col += attrs.colspan - 1;
1488
+ } else if (row < map.height && pos == map.map[index + map.width]) {
1489
+ const cell = table.nodeAt(pos);
1490
+ const attrs = cell.attrs;
1491
+ const copy = cell.type.create({
1492
+ ...attrs,
1493
+ rowspan: cell.attrs.rowspan - 1
1494
+ }, cell.content);
1495
+ const newPos = map.positionAt(row + 1, col, table);
1496
+ tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy);
1497
+ col += attrs.colspan - 1;
1498
+ }
1499
+ }
1500
+ }
1501
+ /**
1502
+ * Remove the selected rows from a table.
1503
+ *
1504
+ * @public
1505
+ */
1506
+ function deleteRow(state, dispatch) {
1507
+ if (!isInTable(state)) return false;
1508
+ if (dispatch) {
1509
+ const rect = selectedRect(state), tr = state.tr;
1510
+ if (rect.top == 0 && rect.bottom == rect.map.height) return false;
1511
+ for (let i = rect.bottom - 1;; i--) {
1512
+ removeRow(tr, rect, i);
1513
+ if (i == rect.top) break;
1514
+ const table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
1515
+ if (!table) throw new RangeError("No table found");
1516
+ rect.table = table;
1517
+ rect.map = TableMap.get(rect.table);
1518
+ }
1519
+ dispatch(tr);
1520
+ }
1521
+ return true;
1522
+ }
1523
+ function isEmpty(cell) {
1524
+ const c = cell.content;
1525
+ return c.childCount == 1 && c.child(0).isTextblock && c.child(0).childCount == 0;
1526
+ }
1527
+ function cellsOverlapRectangle({ width, height, map }, rect) {
1528
+ let indexTop = rect.top * width + rect.left, indexLeft = indexTop;
1529
+ let indexBottom = (rect.bottom - 1) * width + rect.left, indexRight = indexTop + (rect.right - rect.left - 1);
1530
+ for (let i = rect.top; i < rect.bottom; i++) {
1531
+ if (rect.left > 0 && map[indexLeft] == map[indexLeft - 1] || rect.right < width && map[indexRight] == map[indexRight + 1]) return true;
1532
+ indexLeft += width;
1533
+ indexRight += width;
1534
+ }
1535
+ for (let i = rect.left; i < rect.right; i++) {
1536
+ if (rect.top > 0 && map[indexTop] == map[indexTop - width] || rect.bottom < height && map[indexBottom] == map[indexBottom + width]) return true;
1537
+ indexTop++;
1538
+ indexBottom++;
1539
+ }
1540
+ return false;
1541
+ }
1542
+ /**
1543
+ * Merge the selected cells into a single cell. Only available when
1544
+ * the selected cells' outline forms a rectangle.
1545
+ *
1546
+ * @public
1547
+ */
1548
+ function mergeCells(state, dispatch) {
1549
+ const sel = state.selection;
1550
+ if (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos) return false;
1551
+ const rect = selectedRect(state), { map } = rect;
1552
+ if (cellsOverlapRectangle(map, rect)) return false;
1553
+ if (dispatch) {
1554
+ const tr = state.tr;
1555
+ const seen = {};
1556
+ let content = prosemirror_model.Fragment.empty;
1557
+ let mergedPos;
1558
+ let mergedCell;
1559
+ for (let row = rect.top; row < rect.bottom; row++) for (let col = rect.left; col < rect.right; col++) {
1560
+ const cellPos = map.map[row * map.width + col];
1561
+ const cell = rect.table.nodeAt(cellPos);
1562
+ if (seen[cellPos] || !cell) continue;
1563
+ seen[cellPos] = true;
1564
+ if (mergedPos == null) {
1565
+ mergedPos = cellPos;
1566
+ mergedCell = cell;
1567
+ } else {
1568
+ if (!isEmpty(cell)) content = content.append(cell.content);
1569
+ const mapped = tr.mapping.map(cellPos + rect.tableStart);
1570
+ tr.delete(mapped, mapped + cell.nodeSize);
1571
+ }
1572
+ }
1573
+ if (mergedPos == null || mergedCell == null) return true;
1574
+ tr.setNodeMarkup(mergedPos + rect.tableStart, null, {
1575
+ ...addColSpan(mergedCell.attrs, mergedCell.attrs.colspan, rect.right - rect.left - mergedCell.attrs.colspan),
1576
+ rowspan: rect.bottom - rect.top
1577
+ });
1578
+ if (content.size > 0) {
1579
+ const end = mergedPos + 1 + mergedCell.content.size;
1580
+ const start = isEmpty(mergedCell) ? mergedPos + 1 : end;
1581
+ tr.replaceWith(start + rect.tableStart, end + rect.tableStart, content);
1582
+ }
1583
+ tr.setSelection(new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart)));
1584
+ dispatch(tr);
1585
+ }
1586
+ return true;
1587
+ }
1588
+ /**
1589
+ * Split a selected cell, whose rowpan or colspan is greater than one,
1590
+ * into smaller cells. Use the first cell type for the new cells.
1591
+ *
1592
+ * @public
1593
+ */
1594
+ function splitCell(state, dispatch) {
1595
+ const nodeTypes = tableNodeTypes(state.schema);
1596
+ return splitCellWithType(({ node }) => {
1597
+ return nodeTypes[node.type.spec.tableRole];
1598
+ })(state, dispatch);
1599
+ }
1600
+ /**
1601
+ * Split a selected cell, whose rowpan or colspan is greater than one,
1602
+ * into smaller cells with the cell type (th, td) returned by getType function.
1603
+ *
1604
+ * @public
1605
+ */
1606
+ function splitCellWithType(getCellType) {
1607
+ return (state, dispatch) => {
1608
+ const sel = state.selection;
1609
+ let cellNode;
1610
+ let cellPos;
1611
+ if (!(sel instanceof CellSelection)) {
1612
+ var _cellAround;
1613
+ cellNode = cellWrapping(sel.$from);
1614
+ if (!cellNode) return false;
1615
+ cellPos = (_cellAround = cellAround(sel.$from)) === null || _cellAround === void 0 ? void 0 : _cellAround.pos;
1616
+ } else {
1617
+ if (sel.$anchorCell.pos != sel.$headCell.pos) return false;
1618
+ cellNode = sel.$anchorCell.nodeAfter;
1619
+ cellPos = sel.$anchorCell.pos;
1620
+ }
1621
+ if (cellNode == null || cellPos == null) return false;
1622
+ if (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) return false;
1623
+ if (dispatch) {
1624
+ let baseAttrs = cellNode.attrs;
1625
+ const attrs = [];
1626
+ const colwidth = baseAttrs.colwidth;
1627
+ if (baseAttrs.rowspan > 1) baseAttrs = {
1628
+ ...baseAttrs,
1629
+ rowspan: 1
1630
+ };
1631
+ if (baseAttrs.colspan > 1) baseAttrs = {
1632
+ ...baseAttrs,
1633
+ colspan: 1
1634
+ };
1635
+ const rect = selectedRect(state), tr = state.tr;
1636
+ for (let i = 0; i < rect.right - rect.left; i++) attrs.push(colwidth ? {
1637
+ ...baseAttrs,
1638
+ colwidth: colwidth && colwidth[i] ? [colwidth[i]] : null
1639
+ } : baseAttrs);
1640
+ let lastCell;
1641
+ for (let row = rect.top; row < rect.bottom; row++) {
1642
+ let pos = rect.map.positionAt(row, rect.left, rect.table);
1643
+ if (row == rect.top) pos += cellNode.nodeSize;
1644
+ for (let col = rect.left, i = 0; col < rect.right; col++, i++) {
1645
+ if (col == rect.left && row == rect.top) continue;
1646
+ tr.insert(lastCell = tr.mapping.map(pos + rect.tableStart, 1), getCellType({
1647
+ node: cellNode,
1648
+ row,
1649
+ col
1650
+ }).createAndFill(attrs[i]));
1651
+ }
1652
+ }
1653
+ tr.setNodeMarkup(cellPos, getCellType({
1654
+ node: cellNode,
1655
+ row: rect.top,
1656
+ col: rect.left
1657
+ }), attrs[0]);
1658
+ if (sel instanceof CellSelection) tr.setSelection(new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), lastCell ? tr.doc.resolve(lastCell) : void 0));
1659
+ dispatch(tr);
1660
+ }
1661
+ return true;
1662
+ };
1663
+ }
1664
+ /**
1665
+ * Returns a command that sets the given attribute to the given value,
1666
+ * and is only available when the currently selected cell doesn't
1667
+ * already have that attribute set to that value.
1668
+ *
1669
+ * @public
1670
+ */
1671
+ function setCellAttr(name, value) {
1672
+ return function(state, dispatch) {
1673
+ if (!isInTable(state)) return false;
1674
+ const $cell = selectionCell(state);
1675
+ if ($cell.nodeAfter.attrs[name] === value) return false;
1676
+ if (dispatch) {
1677
+ const tr = state.tr;
1678
+ if (state.selection instanceof CellSelection) state.selection.forEachCell((node, pos) => {
1679
+ if (node.attrs[name] !== value) tr.setNodeMarkup(pos, null, {
1680
+ ...node.attrs,
1681
+ [name]: value
1682
+ });
1683
+ });
1684
+ else tr.setNodeMarkup($cell.pos, null, {
1685
+ ...$cell.nodeAfter.attrs,
1686
+ [name]: value
1687
+ });
1688
+ dispatch(tr);
1689
+ }
1690
+ return true;
1691
+ };
1692
+ }
1693
+ function deprecated_toggleHeader(type) {
1694
+ return function(state, dispatch) {
1695
+ if (!isInTable(state)) return false;
1696
+ if (dispatch) {
1697
+ const types = tableNodeTypes(state.schema);
1698
+ const rect = selectedRect(state), tr = state.tr;
1699
+ const cells = rect.map.cellsInRect(type == "column" ? {
1700
+ left: rect.left,
1701
+ top: 0,
1702
+ right: rect.right,
1703
+ bottom: rect.map.height
1704
+ } : type == "row" ? {
1705
+ left: 0,
1706
+ top: rect.top,
1707
+ right: rect.map.width,
1708
+ bottom: rect.bottom
1709
+ } : rect);
1710
+ const nodes = cells.map((pos) => rect.table.nodeAt(pos));
1711
+ for (let i = 0; i < cells.length; i++) if (nodes[i].type == types.header_cell) tr.setNodeMarkup(rect.tableStart + cells[i], types.cell, nodes[i].attrs);
1712
+ if (tr.steps.length === 0) for (let i = 0; i < cells.length; i++) tr.setNodeMarkup(rect.tableStart + cells[i], types.header_cell, nodes[i].attrs);
1713
+ dispatch(tr);
1714
+ }
1715
+ return true;
1716
+ };
1717
+ }
1718
+ function isHeaderEnabledByType(type, rect, types) {
1719
+ const cellPositions = rect.map.cellsInRect({
1720
+ left: 0,
1721
+ top: 0,
1722
+ right: type == "row" ? rect.map.width : 1,
1723
+ bottom: type == "column" ? rect.map.height : 1
1724
+ });
1725
+ for (let i = 0; i < cellPositions.length; i++) {
1726
+ const cell = rect.table.nodeAt(cellPositions[i]);
1727
+ if (cell && cell.type !== types.header_cell) return false;
1728
+ }
1729
+ return true;
1730
+ }
1731
+ /**
1732
+ * Toggles between row/column header and normal cells (Only applies to first row/column).
1733
+ * For deprecated behavior pass `useDeprecatedLogic` in options with true.
1734
+ *
1735
+ * @public
1736
+ */
1737
+ function toggleHeader(type, options) {
1738
+ options = options || { useDeprecatedLogic: false };
1739
+ if (options.useDeprecatedLogic) return deprecated_toggleHeader(type);
1740
+ return function(state, dispatch) {
1741
+ if (!isInTable(state)) return false;
1742
+ if (dispatch) {
1743
+ const types = tableNodeTypes(state.schema);
1744
+ const rect = selectedRect(state), tr = state.tr;
1745
+ const isHeaderRowEnabled = isHeaderEnabledByType("row", rect, types);
1746
+ const isHeaderColumnEnabled = isHeaderEnabledByType("column", rect, types);
1747
+ const selectionStartsAt = (type === "column" ? isHeaderRowEnabled : type === "row" ? isHeaderColumnEnabled : false) ? 1 : 0;
1748
+ const cellsRect = type == "column" ? {
1749
+ left: 0,
1750
+ top: selectionStartsAt,
1751
+ right: 1,
1752
+ bottom: rect.map.height
1753
+ } : type == "row" ? {
1754
+ left: selectionStartsAt,
1755
+ top: 0,
1756
+ right: rect.map.width,
1757
+ bottom: 1
1758
+ } : rect;
1759
+ const newType = type == "column" ? isHeaderColumnEnabled ? types.cell : types.header_cell : type == "row" ? isHeaderRowEnabled ? types.cell : types.header_cell : types.cell;
1760
+ rect.map.cellsInRect(cellsRect).forEach((relativeCellPos) => {
1761
+ const cellPos = relativeCellPos + rect.tableStart;
1762
+ const cell = tr.doc.nodeAt(cellPos);
1763
+ if (cell) tr.setNodeMarkup(cellPos, newType, cell.attrs);
1764
+ });
1765
+ dispatch(tr);
1766
+ }
1767
+ return true;
1768
+ };
1769
+ }
1770
+ /**
1771
+ * Toggles whether the selected row contains header cells.
1772
+ *
1773
+ * @public
1774
+ */
1775
+ const toggleHeaderRow = toggleHeader("row", { useDeprecatedLogic: true });
1776
+ /**
1777
+ * Toggles whether the selected column contains header cells.
1778
+ *
1779
+ * @public
1780
+ */
1781
+ const toggleHeaderColumn = toggleHeader("column", { useDeprecatedLogic: true });
1782
+ /**
1783
+ * Toggles whether the selected cells are header cells.
1784
+ *
1785
+ * @public
1786
+ */
1787
+ const toggleHeaderCell = toggleHeader("cell", { useDeprecatedLogic: true });
1788
+ function findNextCell($cell, dir) {
1789
+ if (dir < 0) {
1790
+ const before = $cell.nodeBefore;
1791
+ if (before) return $cell.pos - before.nodeSize;
1792
+ for (let row = $cell.index(-1) - 1, rowEnd = $cell.before(); row >= 0; row--) {
1793
+ const rowNode = $cell.node(-1).child(row);
1794
+ const lastChild = rowNode.lastChild;
1795
+ if (lastChild) return rowEnd - 1 - lastChild.nodeSize;
1796
+ rowEnd -= rowNode.nodeSize;
1797
+ }
1798
+ } else {
1799
+ if ($cell.index() < $cell.parent.childCount - 1) return $cell.pos + $cell.nodeAfter.nodeSize;
1800
+ const table = $cell.node(-1);
1801
+ for (let row = $cell.indexAfter(-1), rowStart = $cell.after(); row < table.childCount; row++) {
1802
+ const rowNode = table.child(row);
1803
+ if (rowNode.childCount) return rowStart + 1;
1804
+ rowStart += rowNode.nodeSize;
1805
+ }
1806
+ }
1807
+ return null;
1808
+ }
1809
+ /**
1810
+ * Returns a command for selecting the next (direction=1) or previous
1811
+ * (direction=-1) cell in a table.
1812
+ *
1813
+ * @public
1814
+ */
1815
+ function goToNextCell(direction) {
1816
+ return function(state, dispatch) {
1817
+ if (!isInTable(state)) return false;
1818
+ const cell = findNextCell(selectionCell(state), direction);
1819
+ if (cell == null) return false;
1820
+ if (dispatch) {
1821
+ const $cell = state.doc.resolve(cell);
1822
+ dispatch(state.tr.setSelection(prosemirror_state.TextSelection.between($cell, moveCellForward($cell))).scrollIntoView());
1823
+ }
1824
+ return true;
1825
+ };
1826
+ }
1827
+ /**
1828
+ * Deletes the table around the selection, if any.
1829
+ *
1830
+ * @public
1831
+ */
1832
+ function deleteTable(state, dispatch) {
1833
+ const $pos = state.selection.$anchor;
1834
+ for (let d = $pos.depth; d > 0; d--) if ($pos.node(d).type.spec.tableRole == "table") {
1835
+ if (dispatch) dispatch(state.tr.delete($pos.before(d), $pos.after(d)).scrollIntoView());
1836
+ return true;
1837
+ }
1838
+ return false;
1839
+ }
1840
+ /**
1841
+ * Deletes the content of the selected cells, if they are not empty.
1842
+ *
1843
+ * @public
1844
+ */
1845
+ function deleteCellSelection(state, dispatch) {
1846
+ const sel = state.selection;
1847
+ if (!(sel instanceof CellSelection)) return false;
1848
+ if (dispatch) {
1849
+ const tr = state.tr;
1850
+ const baseContent = tableNodeTypes(state.schema).cell.createAndFill().content;
1851
+ sel.forEachCell((cell, pos) => {
1852
+ if (!cell.content.eq(baseContent)) tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1), new prosemirror_model.Slice(baseContent, 0, 0));
1853
+ });
1854
+ if (tr.docChanged) dispatch(tr);
1855
+ }
1856
+ return true;
1857
+ }
1858
+ /**
1859
+ * Move a table row from index `from` to index `to`.
1860
+ *
1861
+ * @public
1862
+ */
1863
+ function moveTableRow(options) {
1864
+ return (state, dispatch) => {
1865
+ const { from: originIndex, to: targetIndex, select = true, pos = state.selection.from } = options;
1866
+ const tr = state.tr;
1867
+ if (moveRow({
1868
+ tr,
1869
+ originIndex,
1870
+ targetIndex,
1871
+ select,
1872
+ pos
1873
+ })) {
1874
+ dispatch === null || dispatch === void 0 || dispatch(tr);
1875
+ return true;
1876
+ }
1877
+ return false;
1878
+ };
1879
+ }
1880
+ /**
1881
+ * Move a table column from index `from` to index `to`.
1882
+ *
1883
+ * @public
1884
+ */
1885
+ function moveTableColumn(options) {
1886
+ return (state, dispatch) => {
1887
+ const { from: originIndex, to: targetIndex, select = true, pos = state.selection.from } = options;
1888
+ const tr = state.tr;
1889
+ if (moveColumn({
1890
+ tr,
1891
+ originIndex,
1892
+ targetIndex,
1893
+ select,
1894
+ pos
1895
+ })) {
1896
+ dispatch === null || dispatch === void 0 || dispatch(tr);
1897
+ return true;
1898
+ }
1899
+ return false;
1900
+ };
1901
+ }
1902
+
1903
+ //#endregion
1904
+ //#region src/copypaste.ts
1905
+ /**
1906
+ * Get a rectangular area of cells from a slice, or null if the outer
1907
+ * nodes of the slice aren't table cells or rows.
1908
+ *
1909
+ * @internal
1910
+ */
1911
+ function pastedCells(slice) {
1912
+ if (slice.size === 0) return null;
1913
+ let { content, openStart, openEnd } = slice;
1914
+ while (content.childCount == 1 && (openStart > 0 && openEnd > 0 || content.child(0).type.spec.tableRole == "table")) {
1915
+ openStart--;
1916
+ openEnd--;
1917
+ content = content.child(0).content;
1918
+ }
1919
+ const first = content.child(0);
1920
+ const role = first.type.spec.tableRole;
1921
+ const schema = first.type.schema, rows = [];
1922
+ if (role == "row") for (let i = 0; i < content.childCount; i++) {
1923
+ let cells = content.child(i).content;
1924
+ const left = i ? 0 : Math.max(0, openStart - 1);
1925
+ const right = i < content.childCount - 1 ? 0 : Math.max(0, openEnd - 1);
1926
+ if (left || right) cells = fitSlice(tableNodeTypes(schema).row, new prosemirror_model.Slice(cells, left, right)).content;
1927
+ rows.push(cells);
1928
+ }
1929
+ else if (role == "cell" || role == "header_cell") rows.push(openStart || openEnd ? fitSlice(tableNodeTypes(schema).row, new prosemirror_model.Slice(content, openStart, openEnd)).content : content);
1930
+ else return null;
1931
+ return ensureRectangular(schema, rows);
1932
+ }
1933
+ function ensureRectangular(schema, rows) {
1934
+ const widths = [];
1935
+ for (let i = 0; i < rows.length; i++) {
1936
+ const row = rows[i];
1937
+ for (let j = row.childCount - 1; j >= 0; j--) {
1938
+ const { rowspan, colspan } = row.child(j).attrs;
1939
+ for (let r = i; r < i + rowspan; r++) widths[r] = (widths[r] || 0) + colspan;
1940
+ }
1941
+ }
1942
+ let width = 0;
1943
+ for (let r = 0; r < widths.length; r++) width = Math.max(width, widths[r]);
1944
+ for (let r = 0; r < widths.length; r++) {
1945
+ if (r >= rows.length) rows.push(prosemirror_model.Fragment.empty);
1946
+ if (widths[r] < width) {
1947
+ const empty = tableNodeTypes(schema).cell.createAndFill();
1948
+ const cells = [];
1949
+ for (let i = widths[r]; i < width; i++) cells.push(empty);
1950
+ rows[r] = rows[r].append(prosemirror_model.Fragment.from(cells));
1951
+ }
1952
+ }
1953
+ return {
1954
+ height: rows.length,
1955
+ width,
1956
+ rows
1957
+ };
1958
+ }
1959
+ function fitSlice(nodeType, slice) {
1960
+ const node = nodeType.createAndFill();
1961
+ return new prosemirror_transform.Transform(node).replace(0, node.content.size, slice).doc;
1962
+ }
1963
+ /**
1964
+ * Clip or extend (repeat) the given set of cells to cover the given
1965
+ * width and height. Will clip rowspan/colspan cells at the edges when
1966
+ * they stick out.
1967
+ *
1968
+ * @internal
1969
+ */
1970
+ function clipCells({ width, height, rows }, newWidth, newHeight) {
1971
+ if (width != newWidth) {
1972
+ const added = [];
1973
+ const newRows = [];
1974
+ for (let row = 0; row < rows.length; row++) {
1975
+ const frag = rows[row], cells = [];
1976
+ for (let col = added[row] || 0, i = 0; col < newWidth; i++) {
1977
+ let cell = frag.child(i % frag.childCount);
1978
+ if (col + cell.attrs.colspan > newWidth) cell = cell.type.createChecked(removeColSpan(cell.attrs, cell.attrs.colspan, col + cell.attrs.colspan - newWidth), cell.content);
1979
+ cells.push(cell);
1980
+ col += cell.attrs.colspan;
1981
+ for (let j = 1; j < cell.attrs.rowspan; j++) added[row + j] = (added[row + j] || 0) + cell.attrs.colspan;
1982
+ }
1983
+ newRows.push(prosemirror_model.Fragment.from(cells));
1984
+ }
1985
+ rows = newRows;
1986
+ width = newWidth;
1987
+ }
1988
+ if (height != newHeight) {
1989
+ const newRows = [];
1990
+ for (let row = 0, i = 0; row < newHeight; row++, i++) {
1991
+ const cells = [], source = rows[i % height];
1992
+ for (let j = 0; j < source.childCount; j++) {
1993
+ let cell = source.child(j);
1994
+ if (row + cell.attrs.rowspan > newHeight) cell = cell.type.create({
1995
+ ...cell.attrs,
1996
+ rowspan: Math.max(1, newHeight - cell.attrs.rowspan)
1997
+ }, cell.content);
1998
+ cells.push(cell);
1999
+ }
2000
+ newRows.push(prosemirror_model.Fragment.from(cells));
2001
+ }
2002
+ rows = newRows;
2003
+ height = newHeight;
2004
+ }
2005
+ return {
2006
+ width,
2007
+ height,
2008
+ rows
2009
+ };
2010
+ }
2011
+ function growTable(tr, map, table, start, width, height, mapFrom) {
2012
+ const schema = tr.doc.type.schema;
2013
+ const types = tableNodeTypes(schema);
2014
+ let empty;
2015
+ let emptyHead;
2016
+ if (width > map.width) for (let row = 0, rowEnd = 0; row < map.height; row++) {
2017
+ const rowNode = table.child(row);
2018
+ rowEnd += rowNode.nodeSize;
2019
+ const cells = [];
2020
+ let add;
2021
+ if (rowNode.lastChild == null || rowNode.lastChild.type == types.cell) add = empty || (empty = types.cell.createAndFill());
2022
+ else add = emptyHead || (emptyHead = types.header_cell.createAndFill());
2023
+ for (let i = map.width; i < width; i++) cells.push(add);
2024
+ tr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start), cells);
2025
+ }
2026
+ if (height > map.height) {
2027
+ const cells = [];
2028
+ for (let i = 0, start$1 = (map.height - 1) * map.width; i < Math.max(map.width, width); i++) {
2029
+ const header = i >= map.width ? false : table.nodeAt(map.map[start$1 + i]).type == types.header_cell;
2030
+ cells.push(header ? emptyHead || (emptyHead = types.header_cell.createAndFill()) : empty || (empty = types.cell.createAndFill()));
2031
+ }
2032
+ const emptyRow = types.row.create(null, prosemirror_model.Fragment.from(cells)), rows = [];
2033
+ for (let i = map.height; i < height; i++) rows.push(emptyRow);
2034
+ tr.insert(tr.mapping.slice(mapFrom).map(start + table.nodeSize - 2), rows);
2035
+ }
2036
+ return !!(empty || emptyHead);
2037
+ }
2038
+ function isolateHorizontal(tr, map, table, start, left, right, top, mapFrom) {
2039
+ if (top == 0 || top == map.height) return false;
2040
+ let found = false;
2041
+ for (let col = left; col < right; col++) {
2042
+ const index = top * map.width + col, pos = map.map[index];
2043
+ if (map.map[index - map.width] == pos) {
2044
+ found = true;
2045
+ const cell = table.nodeAt(pos);
2046
+ const { top: cellTop, left: cellLeft } = map.findCell(pos);
2047
+ tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + start), null, {
2048
+ ...cell.attrs,
2049
+ rowspan: top - cellTop
2050
+ });
2051
+ tr.insert(tr.mapping.slice(mapFrom).map(map.positionAt(top, cellLeft, table)), cell.type.createAndFill({
2052
+ ...cell.attrs,
2053
+ rowspan: cellTop + cell.attrs.rowspan - top
2054
+ }));
2055
+ col += cell.attrs.colspan - 1;
2056
+ }
2057
+ }
2058
+ return found;
2059
+ }
2060
+ function isolateVertical(tr, map, table, start, top, bottom, left, mapFrom) {
2061
+ if (left == 0 || left == map.width) return false;
2062
+ let found = false;
2063
+ for (let row = top; row < bottom; row++) {
2064
+ const index = row * map.width + left, pos = map.map[index];
2065
+ if (map.map[index - 1] == pos) {
2066
+ found = true;
2067
+ const cell = table.nodeAt(pos);
2068
+ const cellLeft = map.colCount(pos);
2069
+ const updatePos = tr.mapping.slice(mapFrom).map(pos + start);
2070
+ tr.setNodeMarkup(updatePos, null, removeColSpan(cell.attrs, left - cellLeft, cell.attrs.colspan - (left - cellLeft)));
2071
+ tr.insert(updatePos + cell.nodeSize, cell.type.createAndFill(removeColSpan(cell.attrs, 0, left - cellLeft)));
2072
+ row += cell.attrs.rowspan - 1;
2073
+ }
2074
+ }
2075
+ return found;
2076
+ }
2077
+ /**
2078
+ * Insert the given set of cells (as returned by `pastedCells`) into a
2079
+ * table, at the position pointed at by rect.
2080
+ *
2081
+ * @internal
2082
+ */
2083
+ function insertCells(state, dispatch, tableStart, rect, cells) {
2084
+ let table = tableStart ? state.doc.nodeAt(tableStart - 1) : state.doc;
2085
+ if (!table) throw new Error("No table found");
2086
+ let map = TableMap.get(table);
2087
+ const { top, left } = rect;
2088
+ const right = left + cells.width, bottom = top + cells.height;
2089
+ const tr = state.tr;
2090
+ let mapFrom = 0;
2091
+ function recomp() {
2092
+ table = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;
2093
+ if (!table) throw new Error("No table found");
2094
+ map = TableMap.get(table);
2095
+ mapFrom = tr.mapping.maps.length;
2096
+ }
2097
+ if (growTable(tr, map, table, tableStart, right, bottom, mapFrom)) recomp();
2098
+ if (isolateHorizontal(tr, map, table, tableStart, left, right, top, mapFrom)) recomp();
2099
+ if (isolateHorizontal(tr, map, table, tableStart, left, right, bottom, mapFrom)) recomp();
2100
+ if (isolateVertical(tr, map, table, tableStart, top, bottom, left, mapFrom)) recomp();
2101
+ if (isolateVertical(tr, map, table, tableStart, top, bottom, right, mapFrom)) recomp();
2102
+ for (let row = top; row < bottom; row++) {
2103
+ const from = map.positionAt(row, left, table), to = map.positionAt(row, right, table);
2104
+ tr.replace(tr.mapping.slice(mapFrom).map(from + tableStart), tr.mapping.slice(mapFrom).map(to + tableStart), new prosemirror_model.Slice(cells.rows[row - top], 0, 0));
2105
+ }
2106
+ recomp();
2107
+ tr.setSelection(new CellSelection(tr.doc.resolve(tableStart + map.positionAt(top, left, table)), tr.doc.resolve(tableStart + map.positionAt(bottom - 1, right - 1, table))));
2108
+ dispatch(tr);
2109
+ }
2110
+
2111
+ //#endregion
2112
+ //#region src/input.ts
2113
+ const handleKeyDown = (0, prosemirror_keymap.keydownHandler)({
2114
+ ArrowLeft: arrow("horiz", -1),
2115
+ ArrowRight: arrow("horiz", 1),
2116
+ ArrowUp: arrow("vert", -1),
2117
+ ArrowDown: arrow("vert", 1),
2118
+ "Shift-ArrowLeft": shiftArrow("horiz", -1),
2119
+ "Shift-ArrowRight": shiftArrow("horiz", 1),
2120
+ "Shift-ArrowUp": shiftArrow("vert", -1),
2121
+ "Shift-ArrowDown": shiftArrow("vert", 1),
2122
+ Backspace: deleteCellSelection,
2123
+ "Mod-Backspace": deleteCellSelection,
2124
+ Delete: deleteCellSelection,
2125
+ "Mod-Delete": deleteCellSelection
2126
+ });
2127
+ function maybeSetSelection(state, dispatch, selection) {
2128
+ if (selection.eq(state.selection)) return false;
2129
+ if (dispatch) dispatch(state.tr.setSelection(selection).scrollIntoView());
2130
+ return true;
2131
+ }
2132
+ /**
2133
+ * @internal
2134
+ */
2135
+ function arrow(axis, dir) {
2136
+ return (state, dispatch, view) => {
2137
+ if (!view) return false;
2138
+ const sel = state.selection;
2139
+ if (sel instanceof CellSelection) return maybeSetSelection(state, dispatch, prosemirror_state.Selection.near(sel.$headCell, dir));
2140
+ if (axis != "horiz" && !sel.empty) return false;
2141
+ const end = atEndOfCell(view, axis, dir);
2142
+ if (end == null) return false;
2143
+ if (axis == "horiz") return maybeSetSelection(state, dispatch, prosemirror_state.Selection.near(state.doc.resolve(sel.head + dir), dir));
2144
+ else {
2145
+ const $cell = state.doc.resolve(end);
2146
+ const $next = nextCell($cell, axis, dir);
2147
+ let newSel;
2148
+ if ($next) newSel = prosemirror_state.Selection.near($next, 1);
2149
+ else if (dir < 0) newSel = prosemirror_state.Selection.near(state.doc.resolve($cell.before(-1)), -1);
2150
+ else newSel = prosemirror_state.Selection.near(state.doc.resolve($cell.after(-1)), 1);
2151
+ return maybeSetSelection(state, dispatch, newSel);
2152
+ }
2153
+ };
2154
+ }
2155
+ function shiftArrow(axis, dir) {
2156
+ return (state, dispatch, view) => {
2157
+ if (!view) return false;
2158
+ const sel = state.selection;
2159
+ let cellSel;
2160
+ if (sel instanceof CellSelection) cellSel = sel;
2161
+ else {
2162
+ const end = atEndOfCell(view, axis, dir);
2163
+ if (end == null) return false;
2164
+ cellSel = new CellSelection(state.doc.resolve(end));
2165
+ }
2166
+ const $head = nextCell(cellSel.$headCell, axis, dir);
2167
+ if (!$head) return false;
2168
+ return maybeSetSelection(state, dispatch, new CellSelection(cellSel.$anchorCell, $head));
2169
+ };
2170
+ }
2171
+ function handleTripleClick(view, pos) {
2172
+ const doc = view.state.doc, $cell = cellAround(doc.resolve(pos));
2173
+ if (!$cell) return false;
2174
+ view.dispatch(view.state.tr.setSelection(new CellSelection($cell)));
2175
+ return true;
2176
+ }
2177
+ /**
2178
+ * @public
2179
+ */
2180
+ function handlePaste(view, _, slice) {
2181
+ if (!isInTable(view.state)) return false;
2182
+ let cells = pastedCells(slice);
2183
+ const sel = view.state.selection;
2184
+ if (sel instanceof CellSelection) {
2185
+ if (!cells) cells = {
2186
+ width: 1,
2187
+ height: 1,
2188
+ rows: [prosemirror_model.Fragment.from(fitSlice(tableNodeTypes(view.state.schema).cell, slice))]
2189
+ };
2190
+ const table = sel.$anchorCell.node(-1);
2191
+ const start = sel.$anchorCell.start(-1);
2192
+ const rect = TableMap.get(table).rectBetween(sel.$anchorCell.pos - start, sel.$headCell.pos - start);
2193
+ cells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);
2194
+ insertCells(view.state, view.dispatch, start, rect, cells);
2195
+ return true;
2196
+ } else if (cells) {
2197
+ const $cell = selectionCell(view.state);
2198
+ const start = $cell.start(-1);
2199
+ insertCells(view.state, view.dispatch, start, TableMap.get($cell.node(-1)).findCell($cell.pos - start), cells);
2200
+ return true;
2201
+ } else return false;
2202
+ }
2203
+ function handleMouseDown$1(view, startEvent) {
2204
+ var _cellUnderMouse;
2205
+ if (startEvent.button != 0) return;
2206
+ if (startEvent.ctrlKey || startEvent.metaKey) return;
2207
+ const startDOMCell = domInCell(view, startEvent.target);
2208
+ let $anchor;
2209
+ if (startEvent.shiftKey && view.state.selection instanceof CellSelection) {
2210
+ setCellSelection(view.state.selection.$anchorCell, startEvent);
2211
+ startEvent.preventDefault();
2212
+ } else if (startEvent.shiftKey && startDOMCell && ($anchor = cellAround(view.state.selection.$anchor)) != null && ((_cellUnderMouse = cellUnderMouse(view, startEvent)) === null || _cellUnderMouse === void 0 ? void 0 : _cellUnderMouse.pos) != $anchor.pos) {
2213
+ setCellSelection($anchor, startEvent);
2214
+ startEvent.preventDefault();
2215
+ } else if (!startDOMCell) return;
2216
+ function setCellSelection($anchor$1, event) {
2217
+ let $head = cellUnderMouse(view, event);
2218
+ const starting = tableEditingKey.getState(view.state) == null;
2219
+ if (!$head || !inSameTable($anchor$1, $head)) if (starting) $head = $anchor$1;
2220
+ else return;
2221
+ const selection = new CellSelection($anchor$1, $head);
2222
+ if (starting || !view.state.selection.eq(selection)) {
2223
+ const tr = view.state.tr.setSelection(selection);
2224
+ if (starting) tr.setMeta(tableEditingKey, $anchor$1.pos);
2225
+ view.dispatch(tr);
2226
+ }
2227
+ }
2228
+ function stop() {
2229
+ view.root.removeEventListener("mouseup", stop);
2230
+ view.root.removeEventListener("dragstart", stop);
2231
+ view.root.removeEventListener("mousemove", move);
2232
+ if (tableEditingKey.getState(view.state) != null) view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));
2233
+ }
2234
+ function move(_event) {
2235
+ const event = _event;
2236
+ const anchor = tableEditingKey.getState(view.state);
2237
+ let $anchor$1;
2238
+ if (anchor != null) $anchor$1 = view.state.doc.resolve(anchor);
2239
+ else if (domInCell(view, event.target) != startDOMCell) {
2240
+ $anchor$1 = cellUnderMouse(view, startEvent);
2241
+ if (!$anchor$1) return stop();
2242
+ }
2243
+ if ($anchor$1) setCellSelection($anchor$1, event);
2244
+ }
2245
+ view.root.addEventListener("mouseup", stop);
2246
+ view.root.addEventListener("dragstart", stop);
2247
+ view.root.addEventListener("mousemove", move);
2248
+ }
2249
+ function atEndOfCell(view, axis, dir) {
2250
+ if (!(view.state.selection instanceof prosemirror_state.TextSelection)) return null;
2251
+ const { $head } = view.state.selection;
2252
+ for (let d = $head.depth - 1; d >= 0; d--) {
2253
+ const parent = $head.node(d);
2254
+ if ((dir < 0 ? $head.index(d) : $head.indexAfter(d)) != (dir < 0 ? 0 : parent.childCount)) return null;
2255
+ if (parent.type.spec.tableRole == "cell" || parent.type.spec.tableRole == "header_cell") {
2256
+ const cellPos = $head.before(d);
2257
+ const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
2258
+ return view.endOfTextblock(dirStr) ? cellPos : null;
2259
+ }
2260
+ }
2261
+ return null;
2262
+ }
2263
+ function domInCell(view, dom) {
2264
+ for (; dom && dom != view.dom; dom = dom.parentNode) if (dom.nodeName == "TD" || dom.nodeName == "TH") return dom;
2265
+ return null;
2266
+ }
2267
+ function cellUnderMouse(view, event) {
2268
+ const mousePos = view.posAtCoords({
2269
+ left: event.clientX,
2270
+ top: event.clientY
2271
+ });
2272
+ if (!mousePos) return null;
2273
+ let { inside, pos } = mousePos;
2274
+ return inside >= 0 && cellAround(view.state.doc.resolve(inside)) || cellAround(view.state.doc.resolve(pos));
2275
+ }
2276
+
2277
+ //#endregion
2278
+ //#region src/tableview.ts
2279
+ /**
2280
+ * @public
2281
+ */
2282
+ var TableView = class {
2283
+ constructor(node, defaultCellMinWidth) {
2284
+ this.node = node;
2285
+ this.defaultCellMinWidth = defaultCellMinWidth;
2286
+ this.dom = document.createElement("div");
2287
+ this.dom.className = "tableWrapper";
2288
+ this.table = this.dom.appendChild(document.createElement("table"));
2289
+ this.table.style.setProperty("--default-cell-min-width", `${defaultCellMinWidth}px`);
2290
+ this.colgroup = this.table.appendChild(document.createElement("colgroup"));
2291
+ updateColumnsOnResize(node, this.colgroup, this.table, defaultCellMinWidth);
2292
+ this.contentDOM = this.table.appendChild(document.createElement("tbody"));
2293
+ }
2294
+ update(node) {
2295
+ if (node.type != this.node.type) return false;
2296
+ this.node = node;
2297
+ updateColumnsOnResize(node, this.colgroup, this.table, this.defaultCellMinWidth);
2298
+ return true;
2299
+ }
2300
+ ignoreMutation(record) {
2301
+ return record.type == "attributes" && (record.target == this.table || this.colgroup.contains(record.target));
2302
+ }
2303
+ };
2304
+ /**
2305
+ * @public
2306
+ */
2307
+ function updateColumnsOnResize(node, colgroup, table, defaultCellMinWidth, overrideCol, overrideValue) {
2308
+ let totalWidth = 0;
2309
+ let fixedWidth = true;
2310
+ let nextDOM = colgroup.firstChild;
2311
+ const row = node.firstChild;
2312
+ if (!row) return;
2313
+ for (let i = 0, col = 0; i < row.childCount; i++) {
2314
+ const { colspan, colwidth } = row.child(i).attrs;
2315
+ for (let j = 0; j < colspan; j++, col++) {
2316
+ const hasWidth = overrideCol == col ? overrideValue : colwidth && colwidth[j];
2317
+ const cssWidth = hasWidth ? hasWidth + "px" : "";
2318
+ totalWidth += hasWidth || defaultCellMinWidth;
2319
+ if (!hasWidth) fixedWidth = false;
2320
+ if (!nextDOM) {
2321
+ const col$1 = document.createElement("col");
2322
+ col$1.style.width = cssWidth;
2323
+ colgroup.appendChild(col$1);
2324
+ } else {
2325
+ if (nextDOM.style.width != cssWidth) nextDOM.style.width = cssWidth;
2326
+ nextDOM = nextDOM.nextSibling;
2327
+ }
2328
+ }
2329
+ }
2330
+ while (nextDOM) {
2331
+ var _nextDOM$parentNode;
2332
+ const after = nextDOM.nextSibling;
2333
+ (_nextDOM$parentNode = nextDOM.parentNode) === null || _nextDOM$parentNode === void 0 || _nextDOM$parentNode.removeChild(nextDOM);
2334
+ nextDOM = after;
2335
+ }
2336
+ if (fixedWidth) {
2337
+ table.style.width = totalWidth + "px";
2338
+ table.style.minWidth = "";
2339
+ } else {
2340
+ table.style.width = "";
2341
+ table.style.minWidth = totalWidth + "px";
2342
+ }
2343
+ }
2344
+
2345
+ //#endregion
2346
+ //#region src/columnresizing.ts
2347
+ /**
2348
+ * @public
2349
+ */
2350
+ const columnResizingPluginKey = new prosemirror_state.PluginKey("tableColumnResizing");
2351
+ /**
2352
+ * @public
2353
+ */
2354
+ function columnResizing({ handleWidth = 5, cellMinWidth = 25, defaultCellMinWidth = 100, View = TableView, lastColumnResizable = true } = {}) {
2355
+ const plugin = new prosemirror_state.Plugin({
2356
+ key: columnResizingPluginKey,
2357
+ state: {
2358
+ init(_, state) {
2359
+ var _plugin$spec;
2360
+ const nodeViews = (_plugin$spec = plugin.spec) === null || _plugin$spec === void 0 || (_plugin$spec = _plugin$spec.props) === null || _plugin$spec === void 0 ? void 0 : _plugin$spec.nodeViews;
2361
+ const tableName = tableNodeTypes(state.schema).table.name;
2362
+ if (View && nodeViews) nodeViews[tableName] = (node, view) => {
2363
+ return new View(node, defaultCellMinWidth, view);
2364
+ };
2365
+ return new ResizeState(-1, false);
2366
+ },
2367
+ apply(tr, prev) {
2368
+ return prev.apply(tr);
2369
+ }
2370
+ },
2371
+ props: {
2372
+ attributes: (state) => {
2373
+ const pluginState = columnResizingPluginKey.getState(state);
2374
+ return pluginState && pluginState.activeHandle > -1 ? { class: "resize-cursor" } : {};
2375
+ },
2376
+ handleDOMEvents: {
2377
+ mousemove: (view, event) => {
2378
+ handleMouseMove(view, event, handleWidth, lastColumnResizable);
2379
+ },
2380
+ mouseleave: (view) => {
2381
+ handleMouseLeave(view);
2382
+ },
2383
+ mousedown: (view, event) => {
2384
+ handleMouseDown(view, event, cellMinWidth, defaultCellMinWidth);
2385
+ }
2386
+ },
2387
+ decorations: (state) => {
2388
+ const pluginState = columnResizingPluginKey.getState(state);
2389
+ if (pluginState && pluginState.activeHandle > -1) return handleDecorations(state, pluginState.activeHandle);
2390
+ },
2391
+ nodeViews: {}
2392
+ }
2393
+ });
2394
+ return plugin;
2395
+ }
2396
+ /**
2397
+ * @public
2398
+ */
2399
+ var ResizeState = class ResizeState {
2400
+ constructor(activeHandle, dragging) {
2401
+ this.activeHandle = activeHandle;
2402
+ this.dragging = dragging;
2403
+ }
2404
+ apply(tr) {
2405
+ const state = this;
2406
+ const action = tr.getMeta(columnResizingPluginKey);
2407
+ if (action && action.setHandle != null) return new ResizeState(action.setHandle, false);
2408
+ if (action && action.setDragging !== void 0) return new ResizeState(state.activeHandle, action.setDragging);
2409
+ if (state.activeHandle > -1 && tr.docChanged) {
2410
+ let handle = tr.mapping.map(state.activeHandle, -1);
2411
+ if (!pointsAtCell(tr.doc.resolve(handle))) handle = -1;
2412
+ return new ResizeState(handle, state.dragging);
2413
+ }
2414
+ return state;
2415
+ }
2416
+ };
2417
+ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
2418
+ if (!view.editable) return;
2419
+ const pluginState = columnResizingPluginKey.getState(view.state);
2420
+ if (!pluginState) return;
2421
+ if (!pluginState.dragging) {
2422
+ const target = domCellAround(event.target);
2423
+ let cell = -1;
2424
+ if (target) {
2425
+ const { left, right } = target.getBoundingClientRect();
2426
+ if (event.clientX - left <= handleWidth) cell = edgeCell(view, event, "left", handleWidth);
2427
+ else if (right - event.clientX <= handleWidth) cell = edgeCell(view, event, "right", handleWidth);
2428
+ }
2429
+ if (cell != pluginState.activeHandle) {
2430
+ if (!lastColumnResizable && cell !== -1) {
2431
+ const $cell = view.state.doc.resolve(cell);
2432
+ const table = $cell.node(-1);
2433
+ const map = TableMap.get(table);
2434
+ const tableStart = $cell.start(-1);
2435
+ if (map.colCount($cell.pos - tableStart) + $cell.nodeAfter.attrs.colspan - 1 == map.width - 1) return;
2436
+ }
2437
+ updateHandle(view, cell);
2438
+ }
2439
+ }
2440
+ }
2441
+ function handleMouseLeave(view) {
2442
+ if (!view.editable) return;
2443
+ const pluginState = columnResizingPluginKey.getState(view.state);
2444
+ if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) updateHandle(view, -1);
2445
+ }
2446
+ function handleMouseDown(view, event, cellMinWidth, defaultCellMinWidth) {
2447
+ var _view$dom$ownerDocume;
2448
+ if (!view.editable) return false;
2449
+ const win = (_view$dom$ownerDocume = view.dom.ownerDocument.defaultView) !== null && _view$dom$ownerDocume !== void 0 ? _view$dom$ownerDocume : window;
2450
+ const pluginState = columnResizingPluginKey.getState(view.state);
2451
+ if (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging) return false;
2452
+ const cell = view.state.doc.nodeAt(pluginState.activeHandle);
2453
+ const width = currentColWidth(view, pluginState.activeHandle, cell.attrs);
2454
+ view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: {
2455
+ startX: event.clientX,
2456
+ startWidth: width
2457
+ } }));
2458
+ function finish(event$1) {
2459
+ win.removeEventListener("mouseup", finish);
2460
+ win.removeEventListener("mousemove", move);
2461
+ const pluginState$1 = columnResizingPluginKey.getState(view.state);
2462
+ if (pluginState$1 === null || pluginState$1 === void 0 ? void 0 : pluginState$1.dragging) {
2463
+ updateColumnWidth(view, pluginState$1.activeHandle, draggedWidth(pluginState$1.dragging, event$1, cellMinWidth));
2464
+ view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null }));
2465
+ }
2466
+ }
2467
+ function move(event$1) {
2468
+ if (!event$1.which) return finish(event$1);
2469
+ const pluginState$1 = columnResizingPluginKey.getState(view.state);
2470
+ if (!pluginState$1) return;
2471
+ if (pluginState$1.dragging) {
2472
+ const dragged = draggedWidth(pluginState$1.dragging, event$1, cellMinWidth);
2473
+ displayColumnWidth(view, pluginState$1.activeHandle, dragged, defaultCellMinWidth);
2474
+ }
2475
+ }
2476
+ displayColumnWidth(view, pluginState.activeHandle, width, defaultCellMinWidth);
2477
+ win.addEventListener("mouseup", finish);
2478
+ win.addEventListener("mousemove", move);
2479
+ event.preventDefault();
2480
+ return true;
2481
+ }
2482
+ function currentColWidth(view, cellPos, { colspan, colwidth }) {
2483
+ const width = colwidth && colwidth[colwidth.length - 1];
2484
+ if (width) return width;
2485
+ const dom = view.domAtPos(cellPos);
2486
+ let domWidth = dom.node.childNodes[dom.offset].offsetWidth, parts = colspan;
2487
+ if (colwidth) {
2488
+ for (let i = 0; i < colspan; i++) if (colwidth[i]) {
2489
+ domWidth -= colwidth[i];
2490
+ parts--;
2491
+ }
2492
+ }
2493
+ return domWidth / parts;
2494
+ }
2495
+ function domCellAround(target) {
2496
+ while (target && target.nodeName != "TD" && target.nodeName != "TH") target = target.classList && target.classList.contains("ProseMirror") ? null : target.parentNode;
2497
+ return target;
2498
+ }
2499
+ function edgeCell(view, event, side, handleWidth) {
2500
+ const offset = side == "right" ? -handleWidth : handleWidth;
2501
+ const found = view.posAtCoords({
2502
+ left: event.clientX + offset,
2503
+ top: event.clientY
2504
+ });
2505
+ if (!found) return -1;
2506
+ const { pos } = found;
2507
+ const $cell = cellAround(view.state.doc.resolve(pos));
2508
+ if (!$cell) return -1;
2509
+ if (side == "right") return $cell.pos;
2510
+ const map = TableMap.get($cell.node(-1)), start = $cell.start(-1);
2511
+ const index = map.map.indexOf($cell.pos - start);
2512
+ return index % map.width == 0 ? -1 : start + map.map[index - 1];
2513
+ }
2514
+ function draggedWidth(dragging, event, resizeMinWidth) {
2515
+ const offset = event.clientX - dragging.startX;
2516
+ return Math.max(resizeMinWidth, dragging.startWidth + offset);
2517
+ }
2518
+ function updateHandle(view, value) {
2519
+ view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value }));
2520
+ }
2521
+ function updateColumnWidth(view, cell, width) {
2522
+ const $cell = view.state.doc.resolve(cell);
2523
+ const table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);
2524
+ const col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
2525
+ const tr = view.state.tr;
2526
+ for (let row = 0; row < map.height; row++) {
2527
+ const mapIndex = row * map.width + col;
2528
+ if (row && map.map[mapIndex] == map.map[mapIndex - map.width]) continue;
2529
+ const pos = map.map[mapIndex];
2530
+ const attrs = table.nodeAt(pos).attrs;
2531
+ const index = attrs.colspan == 1 ? 0 : col - map.colCount(pos);
2532
+ if (attrs.colwidth && attrs.colwidth[index] == width) continue;
2533
+ const colwidth = attrs.colwidth ? attrs.colwidth.slice() : zeroes(attrs.colspan);
2534
+ colwidth[index] = width;
2535
+ tr.setNodeMarkup(start + pos, null, {
2536
+ ...attrs,
2537
+ colwidth
2538
+ });
2539
+ }
2540
+ if (tr.docChanged) view.dispatch(tr);
2541
+ }
2542
+ function displayColumnWidth(view, cell, width, defaultCellMinWidth) {
2543
+ const $cell = view.state.doc.resolve(cell);
2544
+ const table = $cell.node(-1), start = $cell.start(-1);
2545
+ const col = TableMap.get(table).colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
2546
+ let dom = view.domAtPos($cell.start(-1)).node;
2547
+ while (dom && dom.nodeName != "TABLE") dom = dom.parentNode;
2548
+ if (!dom) return;
2549
+ updateColumnsOnResize(table, dom.firstChild, dom, defaultCellMinWidth, col, width);
2550
+ }
2551
+ function zeroes(n) {
2552
+ return Array(n).fill(0);
2553
+ }
2554
+ function handleDecorations(state, cell) {
2555
+ const decorations = [];
2556
+ const $cell = state.doc.resolve(cell);
2557
+ const table = $cell.node(-1);
2558
+ if (!table) return prosemirror_view.DecorationSet.empty;
2559
+ const map = TableMap.get(table);
2560
+ const start = $cell.start(-1);
2561
+ const col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
2562
+ for (let row = 0; row < map.height; row++) {
2563
+ const index = col + row * map.width;
2564
+ if ((col == map.width - 1 || map.map[index] != map.map[index + 1]) && (row == 0 || map.map[index] != map.map[index - map.width])) {
2565
+ var _columnResizingPlugin;
2566
+ const cellPos = map.map[index];
2567
+ const pos = start + cellPos + table.nodeAt(cellPos).nodeSize - 1;
2568
+ const dom = document.createElement("div");
2569
+ dom.className = "column-resize-handle";
2570
+ if ((_columnResizingPlugin = columnResizingPluginKey.getState(state)) === null || _columnResizingPlugin === void 0 ? void 0 : _columnResizingPlugin.dragging) decorations.push(prosemirror_view.Decoration.node(start + cellPos, start + cellPos + table.nodeAt(cellPos).nodeSize, { class: "column-resize-dragging" }));
2571
+ decorations.push(prosemirror_view.Decoration.widget(pos, dom));
2572
+ }
2573
+ }
2574
+ return prosemirror_view.DecorationSet.create(state.doc, decorations);
2575
+ }
2576
+
2577
+ //#endregion
2578
+ //#region src/index.ts
2579
+ /**
2580
+ * Creates a [plugin](http://prosemirror.net/docs/ref/#state.Plugin)
2581
+ * that, when added to an editor, enables cell-selection, handles
2582
+ * cell-based copy/paste, and makes sure tables stay well-formed (each
2583
+ * row has the same width, and cells don't overlap).
2584
+ *
2585
+ * You should probably put this plugin near the end of your array of
2586
+ * plugins, since it handles mouse and arrow key events in tables
2587
+ * rather broadly, and other plugins, like the gap cursor or the
2588
+ * column-width dragging plugin, might want to get a turn first to
2589
+ * perform more specific behavior.
2590
+ *
2591
+ * @public
2592
+ */
2593
+ function tableEditing({ allowTableNodeSelection = false } = {}) {
2594
+ return new prosemirror_state.Plugin({
2595
+ key: tableEditingKey,
2596
+ state: {
2597
+ init() {
2598
+ return null;
2599
+ },
2600
+ apply(tr, cur) {
2601
+ const set = tr.getMeta(tableEditingKey);
2602
+ if (set != null) return set == -1 ? null : set;
2603
+ if (cur == null || !tr.docChanged) return cur;
2604
+ const { deleted, pos } = tr.mapping.mapResult(cur);
2605
+ return deleted ? null : pos;
2606
+ }
2607
+ },
2608
+ props: {
2609
+ decorations: drawCellSelection,
2610
+ handleDOMEvents: { mousedown: handleMouseDown$1 },
2611
+ createSelectionBetween(view) {
2612
+ return tableEditingKey.getState(view.state) != null ? view.state.selection : null;
2613
+ },
2614
+ handleTripleClick,
2615
+ handleKeyDown,
2616
+ handlePaste
2617
+ },
2618
+ appendTransaction(_, oldState, state) {
2619
+ return normalizeSelection(state, fixTables(state, oldState), allowTableNodeSelection);
2620
+ }
2621
+ });
2622
+ }
2623
+
2624
+ //#endregion
2625
+ exports.CellBookmark = CellBookmark;
2626
+ exports.CellSelection = CellSelection;
2627
+ exports.ResizeState = ResizeState;
2628
+ exports.TableMap = TableMap;
2629
+ exports.TableView = TableView;
2630
+ exports.__clipCells = clipCells;
2631
+ exports.__insertCells = insertCells;
2632
+ exports.__pastedCells = pastedCells;
2633
+ exports.addColSpan = addColSpan;
2634
+ exports.addColumn = addColumn;
2635
+ exports.addColumnAfter = addColumnAfter;
2636
+ exports.addColumnBefore = addColumnBefore;
2637
+ exports.addRow = addRow;
2638
+ exports.addRowAfter = addRowAfter;
2639
+ exports.addRowBefore = addRowBefore;
2640
+ exports.cellAround = cellAround;
2641
+ exports.cellNear = cellNear;
2642
+ exports.colCount = colCount;
2643
+ exports.columnIsHeader = columnIsHeader;
2644
+ exports.columnResizing = columnResizing;
2645
+ exports.columnResizingPluginKey = columnResizingPluginKey;
2646
+ exports.deleteCellSelection = deleteCellSelection;
2647
+ exports.deleteColumn = deleteColumn;
2648
+ exports.deleteRow = deleteRow;
2649
+ exports.deleteTable = deleteTable;
2650
+ exports.findCell = findCell;
2651
+ exports.findCellPos = findCellPos;
2652
+ exports.findCellRange = findCellRange;
2653
+ exports.findTable = findTable;
2654
+ exports.fixTables = fixTables;
2655
+ exports.fixTablesKey = fixTablesKey;
2656
+ exports.goToNextCell = goToNextCell;
2657
+ exports.handlePaste = handlePaste;
2658
+ exports.inSameTable = inSameTable;
2659
+ exports.isInTable = isInTable;
2660
+ exports.mergeCells = mergeCells;
2661
+ exports.moveCellForward = moveCellForward;
2662
+ exports.moveTableColumn = moveTableColumn;
2663
+ exports.moveTableRow = moveTableRow;
2664
+ exports.nextCell = nextCell;
2665
+ exports.pointsAtCell = pointsAtCell;
2666
+ exports.removeColSpan = removeColSpan;
2667
+ exports.removeColumn = removeColumn;
2668
+ exports.removeRow = removeRow;
2669
+ exports.rowIsHeader = rowIsHeader;
2670
+ exports.selectedRect = selectedRect;
2671
+ exports.selectionCell = selectionCell;
2672
+ exports.setCellAttr = setCellAttr;
2673
+ exports.splitCell = splitCell;
2674
+ exports.splitCellWithType = splitCellWithType;
2675
+ exports.tableEditing = tableEditing;
2676
+ exports.tableEditingKey = tableEditingKey;
2677
+ exports.tableNodeTypes = tableNodeTypes;
2678
+ exports.tableNodes = tableNodes;
2679
+ exports.toggleHeader = toggleHeader;
2680
+ exports.toggleHeaderCell = toggleHeaderCell;
2681
+ exports.toggleHeaderColumn = toggleHeaderColumn;
2682
+ exports.toggleHeaderRow = toggleHeaderRow;
2683
+ exports.updateColumnsOnResize = updateColumnsOnResize;