@prosekit/extensions 0.11.3 → 0.11.5

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 (383) hide show
  1. package/dist/commit/style.css +2 -0
  2. package/dist/commit/style.css.map +1 -0
  3. package/dist/commit/style.js +1 -0
  4. package/dist/{drop-indicator-B8P652g2.js → drop-indicator-D1eHOhSi.js} +6 -5
  5. package/dist/drop-indicator-D1eHOhSi.js.map +1 -0
  6. package/dist/enter-rule-RdhEA900.js +2 -1
  7. package/dist/enter-rule-RdhEA900.js.map +1 -0
  8. package/dist/gap-cursor/style.css +2 -0
  9. package/dist/gap-cursor/style.css.map +1 -0
  10. package/dist/gap-cursor/style.js +1 -0
  11. package/dist/{input-rule-Gji4N7Oe.js → input-rule-B17tpW4m.js} +3 -3
  12. package/dist/input-rule-B17tpW4m.js.map +1 -0
  13. package/dist/list/style.css +2 -0
  14. package/dist/list/style.css.map +1 -0
  15. package/dist/list/style.js +1 -0
  16. package/dist/loro/style.css +2 -0
  17. package/dist/loro/style.css.map +1 -0
  18. package/dist/loro/style.js +1 -0
  19. package/dist/{mark-rule-D7zaa32n.js → mark-rule-BCqIZMDu.js} +3 -3
  20. package/dist/mark-rule-BCqIZMDu.js.map +1 -0
  21. package/dist/{paste-rule-Cca3n5TA.js → paste-rule-DIEJKIje.js} +5 -15
  22. package/dist/paste-rule-DIEJKIje.js.map +1 -0
  23. package/dist/placeholder/style.css +2 -0
  24. package/dist/placeholder/style.css.map +1 -0
  25. package/dist/placeholder/style.js +1 -0
  26. package/dist/prosekit-extensions-autocomplete.d.ts +2 -1
  27. package/dist/prosekit-extensions-autocomplete.d.ts.map +1 -0
  28. package/dist/prosekit-extensions-autocomplete.js +2 -9
  29. package/dist/prosekit-extensions-autocomplete.js.map +1 -0
  30. package/dist/prosekit-extensions-blockquote.d.ts +2 -1
  31. package/dist/prosekit-extensions-blockquote.d.ts.map +1 -0
  32. package/dist/prosekit-extensions-blockquote.js +4 -4
  33. package/dist/prosekit-extensions-blockquote.js.map +1 -0
  34. package/dist/prosekit-extensions-bold.d.ts +2 -1
  35. package/dist/prosekit-extensions-bold.d.ts.map +1 -0
  36. package/dist/prosekit-extensions-bold.js +3 -2
  37. package/dist/prosekit-extensions-bold.js.map +1 -0
  38. package/dist/prosekit-extensions-code-block.d.ts +2 -1
  39. package/dist/prosekit-extensions-code-block.d.ts.map +1 -0
  40. package/dist/prosekit-extensions-code-block.js +5 -6
  41. package/dist/prosekit-extensions-code-block.js.map +1 -0
  42. package/dist/prosekit-extensions-code.d.ts +2 -1
  43. package/dist/prosekit-extensions-code.d.ts.map +1 -0
  44. package/dist/prosekit-extensions-code.js +3 -2
  45. package/dist/prosekit-extensions-code.js.map +1 -0
  46. package/dist/prosekit-extensions-commit.d.ts +2 -1
  47. package/dist/prosekit-extensions-commit.d.ts.map +1 -0
  48. package/dist/prosekit-extensions-commit.js +11 -13
  49. package/dist/prosekit-extensions-commit.js.map +1 -0
  50. package/dist/prosekit-extensions-doc.d.ts +2 -1
  51. package/dist/prosekit-extensions-doc.d.ts.map +1 -0
  52. package/dist/prosekit-extensions-doc.js +2 -1
  53. package/dist/prosekit-extensions-doc.js.map +1 -0
  54. package/dist/prosekit-extensions-drop-cursor.d.ts +2 -1
  55. package/dist/prosekit-extensions-drop-cursor.d.ts.map +1 -0
  56. package/dist/prosekit-extensions-drop-cursor.js +2 -1
  57. package/dist/prosekit-extensions-drop-cursor.js.map +1 -0
  58. package/dist/prosekit-extensions-drop-indicator.d.ts +2 -1
  59. package/dist/prosekit-extensions-drop-indicator.d.ts.map +1 -0
  60. package/dist/prosekit-extensions-drop-indicator.js +1 -1
  61. package/dist/prosekit-extensions-enter-rule.d.ts +2 -1
  62. package/dist/prosekit-extensions-enter-rule.d.ts.map +1 -0
  63. package/dist/prosekit-extensions-file.d.ts +2 -1
  64. package/dist/prosekit-extensions-file.d.ts.map +1 -0
  65. package/dist/prosekit-extensions-file.js +4 -16
  66. package/dist/prosekit-extensions-file.js.map +1 -0
  67. package/dist/prosekit-extensions-gap-cursor.d.ts +2 -2
  68. package/dist/prosekit-extensions-gap-cursor.d.ts.map +1 -0
  69. package/dist/prosekit-extensions-gap-cursor.js +2 -1
  70. package/dist/prosekit-extensions-gap-cursor.js.map +1 -0
  71. package/dist/prosekit-extensions-hard-break.d.ts +2 -1
  72. package/dist/prosekit-extensions-hard-break.d.ts.map +1 -0
  73. package/dist/prosekit-extensions-hard-break.js +2 -1
  74. package/dist/prosekit-extensions-hard-break.js.map +1 -0
  75. package/dist/prosekit-extensions-heading.d.ts +2 -1
  76. package/dist/prosekit-extensions-heading.d.ts.map +1 -0
  77. package/dist/prosekit-extensions-heading.js +5 -6
  78. package/dist/prosekit-extensions-heading.js.map +1 -0
  79. package/dist/prosekit-extensions-horizontal-rule.d.ts +2 -1
  80. package/dist/prosekit-extensions-horizontal-rule.d.ts.map +1 -0
  81. package/dist/prosekit-extensions-horizontal-rule.js +5 -6
  82. package/dist/prosekit-extensions-horizontal-rule.js.map +1 -0
  83. package/dist/prosekit-extensions-image.d.ts +2 -1
  84. package/dist/prosekit-extensions-image.d.ts.map +1 -0
  85. package/dist/prosekit-extensions-image.js +3 -3
  86. package/dist/prosekit-extensions-image.js.map +1 -0
  87. package/dist/prosekit-extensions-input-rule.d.ts +2 -1
  88. package/dist/prosekit-extensions-input-rule.d.ts.map +1 -0
  89. package/dist/prosekit-extensions-input-rule.js +1 -1
  90. package/dist/prosekit-extensions-italic.d.ts +2 -1
  91. package/dist/prosekit-extensions-italic.d.ts.map +1 -0
  92. package/dist/prosekit-extensions-italic.js +3 -2
  93. package/dist/prosekit-extensions-italic.js.map +1 -0
  94. package/dist/prosekit-extensions-link.d.ts +2 -1
  95. package/dist/prosekit-extensions-link.d.ts.map +1 -0
  96. package/dist/prosekit-extensions-link.js +6 -5
  97. package/dist/prosekit-extensions-link.js.map +1 -0
  98. package/dist/prosekit-extensions-list.d.ts +22 -21
  99. package/dist/prosekit-extensions-list.d.ts.map +1 -0
  100. package/dist/prosekit-extensions-list.js +6 -7
  101. package/dist/prosekit-extensions-list.js.map +1 -0
  102. package/dist/prosekit-extensions-loro.d.ts +14 -13
  103. package/dist/prosekit-extensions-loro.d.ts.map +1 -0
  104. package/dist/prosekit-extensions-loro.js +2 -1
  105. package/dist/prosekit-extensions-loro.js.map +1 -0
  106. package/dist/prosekit-extensions-mark-rule.d.ts +2 -1
  107. package/dist/prosekit-extensions-mark-rule.d.ts.map +1 -0
  108. package/dist/prosekit-extensions-mark-rule.js +1 -1
  109. package/dist/prosekit-extensions-mention.d.ts +2 -1
  110. package/dist/prosekit-extensions-mention.d.ts.map +1 -0
  111. package/dist/prosekit-extensions-mention.js +2 -1
  112. package/dist/prosekit-extensions-mention.js.map +1 -0
  113. package/dist/prosekit-extensions-mod-click-prevention.d.ts +2 -1
  114. package/dist/prosekit-extensions-mod-click-prevention.d.ts.map +1 -0
  115. package/dist/prosekit-extensions-mod-click-prevention.js +2 -1
  116. package/dist/prosekit-extensions-mod-click-prevention.js.map +1 -0
  117. package/dist/prosekit-extensions-paragraph.d.ts +2 -1
  118. package/dist/prosekit-extensions-paragraph.d.ts.map +1 -0
  119. package/dist/prosekit-extensions-paragraph.js +2 -1
  120. package/dist/prosekit-extensions-paragraph.js.map +1 -0
  121. package/dist/prosekit-extensions-paste-rule.d.ts +2 -1
  122. package/dist/prosekit-extensions-paste-rule.d.ts.map +1 -0
  123. package/dist/prosekit-extensions-paste-rule.js +1 -1
  124. package/dist/prosekit-extensions-placeholder.d.ts +2 -1
  125. package/dist/prosekit-extensions-placeholder.d.ts.map +1 -0
  126. package/dist/prosekit-extensions-placeholder.js +5 -4
  127. package/dist/prosekit-extensions-placeholder.js.map +1 -0
  128. package/dist/prosekit-extensions-readonly.d.ts +2 -1
  129. package/dist/prosekit-extensions-readonly.d.ts.map +1 -0
  130. package/dist/prosekit-extensions-readonly.js +2 -1
  131. package/dist/prosekit-extensions-readonly.js.map +1 -0
  132. package/dist/prosekit-extensions-search.d.ts +2 -1
  133. package/dist/prosekit-extensions-search.d.ts.map +1 -0
  134. package/dist/prosekit-extensions-search.js +3 -3
  135. package/dist/prosekit-extensions-search.js.map +1 -0
  136. package/dist/prosekit-extensions-strike.d.ts +2 -1
  137. package/dist/prosekit-extensions-strike.d.ts.map +1 -0
  138. package/dist/prosekit-extensions-strike.js +3 -2
  139. package/dist/prosekit-extensions-strike.js.map +1 -0
  140. package/dist/prosekit-extensions-table.d.ts +56 -114
  141. package/dist/prosekit-extensions-table.d.ts.map +1 -0
  142. package/dist/prosekit-extensions-table.js +3 -2
  143. package/dist/prosekit-extensions-text-align.d.ts +2 -1
  144. package/dist/prosekit-extensions-text-align.d.ts.map +1 -0
  145. package/dist/prosekit-extensions-text-align.js +2 -1
  146. package/dist/prosekit-extensions-text-align.js.map +1 -0
  147. package/dist/prosekit-extensions-text.d.ts +2 -1
  148. package/dist/prosekit-extensions-text.d.ts.map +1 -0
  149. package/dist/prosekit-extensions-text.js +2 -1
  150. package/dist/prosekit-extensions-text.js.map +1 -0
  151. package/dist/prosekit-extensions-underline.d.ts +2 -1
  152. package/dist/prosekit-extensions-underline.d.ts.map +1 -0
  153. package/dist/prosekit-extensions-underline.js +2 -1
  154. package/dist/prosekit-extensions-underline.js.map +1 -0
  155. package/dist/prosekit-extensions-virtual-selection.d.ts +2 -1
  156. package/dist/prosekit-extensions-virtual-selection.d.ts.map +1 -0
  157. package/dist/prosekit-extensions-virtual-selection.js +3 -3
  158. package/dist/prosekit-extensions-virtual-selection.js.map +1 -0
  159. package/dist/prosekit-extensions-yjs.d.ts +2 -1
  160. package/dist/prosekit-extensions-yjs.d.ts.map +1 -0
  161. package/dist/prosekit-extensions-yjs.js +2 -1
  162. package/dist/prosekit-extensions-yjs.js.map +1 -0
  163. package/dist/prosekit-extensions.d.ts +1 -1
  164. package/dist/prosekit-extensions.js +1 -0
  165. package/dist/search/style.css +2 -0
  166. package/dist/search/style.css.map +1 -0
  167. package/dist/search/style.js +1 -0
  168. package/dist/shiki-highlighter-chunk-DSPM0T27.d.ts +2 -1
  169. package/dist/shiki-highlighter-chunk-DSPM0T27.d.ts.map +1 -0
  170. package/dist/shiki-highlighter-chunk.js +3 -5
  171. package/dist/shiki-highlighter-chunk.js.map +1 -0
  172. package/dist/table/style.css +2 -0
  173. package/dist/table/style.css.map +1 -0
  174. package/dist/table/style.js +1 -0
  175. package/dist/table-Bi7WsMI3.js +297 -0
  176. package/dist/table-Bi7WsMI3.js.map +1 -0
  177. package/dist/virtual-selection/style.css +2 -0
  178. package/dist/virtual-selection/style.css.map +1 -0
  179. package/dist/virtual-selection/style.js +1 -0
  180. package/dist/yjs/style.css +2 -0
  181. package/dist/yjs/style.css.map +1 -0
  182. package/dist/yjs/style.js +1 -0
  183. package/package.json +10 -9
  184. package/src/autocomplete/autocomplete-helpers.ts +74 -0
  185. package/src/autocomplete/autocomplete-plugin.ts +186 -0
  186. package/src/autocomplete/autocomplete-rule.ts +117 -0
  187. package/src/autocomplete/autocomplete.spec.ts +132 -0
  188. package/src/autocomplete/autocomplete.ts +29 -0
  189. package/src/autocomplete/index.ts +9 -0
  190. package/src/blockquote/blockquote-commands.ts +32 -0
  191. package/src/blockquote/blockquote-input-rule.ts +14 -0
  192. package/src/blockquote/blockquote-keymap.spec.ts +45 -0
  193. package/src/blockquote/blockquote-keymap.ts +31 -0
  194. package/src/blockquote/blockquote-spec.ts +24 -0
  195. package/src/blockquote/blockquote.ts +34 -0
  196. package/src/blockquote/index.ts +14 -0
  197. package/src/bold/bold-commands.ts +23 -0
  198. package/src/bold/bold-input-rule.spec.ts +51 -0
  199. package/src/bold/bold-input-rule.ts +18 -0
  200. package/src/bold/bold-keymap.ts +14 -0
  201. package/src/bold/bold-spec.ts +53 -0
  202. package/src/bold/bold.ts +32 -0
  203. package/src/bold/index.ts +14 -0
  204. package/src/code/code-commands.ts +23 -0
  205. package/src/code/code-input-rule.ts +18 -0
  206. package/src/code/code-keymap.ts +14 -0
  207. package/src/code/code-spec.ts +28 -0
  208. package/src/code/code.ts +32 -0
  209. package/src/code/index.ts +14 -0
  210. package/src/code-block/code-block-commands.ts +44 -0
  211. package/src/code-block/code-block-highlight.ts +40 -0
  212. package/src/code-block/code-block-input-rule.ts +36 -0
  213. package/src/code-block/code-block-keymap.ts +61 -0
  214. package/src/code-block/code-block-shiki.ts +58 -0
  215. package/src/code-block/code-block-spec.spec.ts +164 -0
  216. package/src/code-block/code-block-spec.ts +71 -0
  217. package/src/code-block/code-block-types.ts +8 -0
  218. package/src/code-block/code-block.ts +46 -0
  219. package/src/code-block/index.ts +32 -0
  220. package/src/code-block/shiki-bundle.ts +8 -0
  221. package/src/code-block/shiki-highlighter-chunk.ts +84 -0
  222. package/src/code-block/shiki-highlighter.ts +22 -0
  223. package/src/code-block/shiki-parser.ts +36 -0
  224. package/src/commit/index.ts +330 -0
  225. package/src/commit/style.css +7 -0
  226. package/src/doc/index.ts +21 -0
  227. package/src/drop-cursor/drop-cursor.ts +46 -0
  228. package/src/drop-cursor/index.ts +5 -0
  229. package/src/drop-indicator/drop-indicator-facet.ts +84 -0
  230. package/src/drop-indicator/drop-indicator-plugin.ts +147 -0
  231. package/src/drop-indicator/drop-indicator.ts +37 -0
  232. package/src/drop-indicator/drop-target.ts +168 -0
  233. package/src/drop-indicator/index.ts +14 -0
  234. package/src/drop-indicator/types.ts +90 -0
  235. package/src/enter-rule/index.ts +241 -0
  236. package/src/file/file-drop-handler.ts +75 -0
  237. package/src/file/file-paste-handler.spec.ts +95 -0
  238. package/src/file/file-paste-handler.ts +59 -0
  239. package/src/file/file-upload.ts +119 -0
  240. package/src/file/helpers.ts +39 -0
  241. package/src/file/index.ts +16 -0
  242. package/src/gap-cursor/gap-cursor.ts +28 -0
  243. package/src/gap-cursor/index.ts +4 -0
  244. package/src/gap-cursor/style.css +25 -0
  245. package/src/hard-break/hard-break-commands.ts +31 -0
  246. package/src/hard-break/hard-break-keymap.spec.ts +45 -0
  247. package/src/hard-break/hard-break-keymap.ts +16 -0
  248. package/src/hard-break/hard-break-spec.ts +31 -0
  249. package/src/hard-break/hard-break.ts +32 -0
  250. package/src/hard-break/index.ts +13 -0
  251. package/src/heading/heading-commands.ts +37 -0
  252. package/src/heading/heading-input-rule.ts +22 -0
  253. package/src/heading/heading-keymap.spec.ts +53 -0
  254. package/src/heading/heading-keymap.ts +40 -0
  255. package/src/heading/heading-spec.ts +39 -0
  256. package/src/heading/heading-types.ts +3 -0
  257. package/src/heading/heading.ts +34 -0
  258. package/src/heading/index.ts +15 -0
  259. package/src/horizontal-rule/horizontal-rule-commands.spec.ts +61 -0
  260. package/src/horizontal-rule/horizontal-rule-commands.ts +37 -0
  261. package/src/horizontal-rule/horizontal-rule-input-rule.spec.ts +61 -0
  262. package/src/horizontal-rule/horizontal-rule-input-rule.ts +26 -0
  263. package/src/horizontal-rule/horizontal-rule-spec.ts +21 -0
  264. package/src/horizontal-rule/horizontal-rule.ts +29 -0
  265. package/src/horizontal-rule/index.ts +14 -0
  266. package/src/image/image-commands.ts +27 -0
  267. package/src/image/image-spec.ts +72 -0
  268. package/src/image/image.ts +25 -0
  269. package/src/image/index.ts +13 -0
  270. package/src/index.ts +1 -0
  271. package/src/input-rule/index.ts +237 -0
  272. package/src/italic/index.ts +14 -0
  273. package/src/italic/italic-commands.spec.ts +75 -0
  274. package/src/italic/italic-commands.ts +23 -0
  275. package/src/italic/italic-input-rule.spec.ts +25 -0
  276. package/src/italic/italic-input-rule.ts +18 -0
  277. package/src/italic/italic-keymap.ts +14 -0
  278. package/src/italic/italic-spec.ts +35 -0
  279. package/src/italic/italic.ts +34 -0
  280. package/src/link/index.spec.ts +88 -0
  281. package/src/link/index.ts +156 -0
  282. package/src/link/link-paste-rule.spec.ts +194 -0
  283. package/src/link/link-paste-rule.ts +22 -0
  284. package/src/link/link-regex.spec.ts +82 -0
  285. package/src/link/link-regex.ts +79 -0
  286. package/src/link/link-types.ts +8 -0
  287. package/src/list/index.ts +25 -0
  288. package/src/list/list-commands.ts +61 -0
  289. package/src/list/list-drop-indicator.ts +37 -0
  290. package/src/list/list-input-rules.ts +14 -0
  291. package/src/list/list-keymap.spec.ts +39 -0
  292. package/src/list/list-keymap.ts +48 -0
  293. package/src/list/list-plugins.ts +35 -0
  294. package/src/list/list-serializer.ts +38 -0
  295. package/src/list/list-spec.ts +60 -0
  296. package/src/list/list-types.spec.ts +10 -0
  297. package/src/list/list-types.ts +23 -0
  298. package/src/list/list.spec.ts +134 -0
  299. package/src/list/list.ts +38 -0
  300. package/src/list/style.css +128 -0
  301. package/src/loro/index.ts +17 -0
  302. package/src/loro/loro-commands.ts +27 -0
  303. package/src/loro/loro-cursor-plugin.ts +28 -0
  304. package/src/loro/loro-keymap.ts +23 -0
  305. package/src/loro/loro-sync-plugin.ts +14 -0
  306. package/src/loro/loro-undo-plugin.ts +12 -0
  307. package/src/loro/loro.ts +75 -0
  308. package/src/loro/style.css +33 -0
  309. package/src/mark-rule/apply.ts +129 -0
  310. package/src/mark-rule/index.ts +2 -0
  311. package/src/mark-rule/mark-rule.spec.ts +123 -0
  312. package/src/mark-rule/mark-rule.ts +48 -0
  313. package/src/mark-rule/range.ts +107 -0
  314. package/src/mark-rule/types.ts +30 -0
  315. package/src/mention/index.ts +90 -0
  316. package/src/mod-click-prevention/index.ts +35 -0
  317. package/src/paragraph/index.ts +7 -0
  318. package/src/paragraph/paragraph-commands.ts +29 -0
  319. package/src/paragraph/paragraph-keymap.ts +15 -0
  320. package/src/paragraph/paragraph-spec.ts +31 -0
  321. package/src/paragraph/paragraph.ts +37 -0
  322. package/src/paste-rule/index.ts +10 -0
  323. package/src/paste-rule/mark-paste-rule.spec.ts +112 -0
  324. package/src/paste-rule/mark-paste-rule.ts +194 -0
  325. package/src/paste-rule/paste-rule-plugin.ts +53 -0
  326. package/src/paste-rule/paste-rule.spec.ts +96 -0
  327. package/src/paste-rule/paste-rule.ts +60 -0
  328. package/src/paste-rule/split-text-by-regex.spec.ts +97 -0
  329. package/src/paste-rule/split-text-by-regex.ts +44 -0
  330. package/src/placeholder/index.ts +113 -0
  331. package/src/placeholder/style.css +7 -0
  332. package/src/readonly/index.ts +22 -0
  333. package/src/search/index.ts +140 -0
  334. package/src/search/style.css +13 -0
  335. package/src/strike/index.ts +101 -0
  336. package/src/table/index.ts +53 -0
  337. package/src/table/style.css +42 -0
  338. package/src/table/table-commands/delete-cell-selection.spec.ts +41 -0
  339. package/src/table/table-commands/delete-cell-selection.ts +1 -0
  340. package/src/table/table-commands/exit-table.spec.ts +45 -0
  341. package/src/table/table-commands/exit-table.ts +49 -0
  342. package/src/table/table-commands/insert-table.spec.ts +39 -0
  343. package/src/table/table-commands/insert-table.ts +80 -0
  344. package/src/table/table-commands/move-table-column.spec.ts +618 -0
  345. package/src/table/table-commands/move-table-column.ts +4 -0
  346. package/src/table/table-commands/move-table-row.spec.ts +380 -0
  347. package/src/table/table-commands/move-table-row.ts +4 -0
  348. package/src/table/table-commands/select-table-cell.spec.ts +34 -0
  349. package/src/table/table-commands/select-table-cell.ts +35 -0
  350. package/src/table/table-commands/select-table-column.spec.ts +33 -0
  351. package/src/table/table-commands/select-table-column.ts +39 -0
  352. package/src/table/table-commands/select-table-row.spec.ts +32 -0
  353. package/src/table/table-commands/select-table-row.ts +39 -0
  354. package/src/table/table-commands/select-table.spec.ts +36 -0
  355. package/src/table/table-commands/select-table.ts +50 -0
  356. package/src/table/table-commands.ts +110 -0
  357. package/src/table/table-drop-indicator.ts +40 -0
  358. package/src/table/table-plugins.ts +15 -0
  359. package/src/table/table-spec.spec.ts +113 -0
  360. package/src/table/table-spec.ts +109 -0
  361. package/src/table/table-utils.ts +16 -0
  362. package/src/table/table.ts +49 -0
  363. package/src/table/test-utils.ts +28 -0
  364. package/src/testing/clipboard.ts +58 -0
  365. package/src/testing/format-html.ts +5 -0
  366. package/src/testing/index.ts +161 -0
  367. package/src/testing/keyboard.ts +36 -0
  368. package/src/testing/markdown.ts +23 -0
  369. package/src/text/index.ts +24 -0
  370. package/src/text-align/index.ts +133 -0
  371. package/src/types/assert-type-equal.ts +8 -0
  372. package/src/underline/index.ts +83 -0
  373. package/src/virtual-selection/index.ts +100 -0
  374. package/src/virtual-selection/style.css +5 -0
  375. package/src/yjs/index.ts +22 -0
  376. package/src/yjs/style.css +31 -0
  377. package/src/yjs/yjs-commands.ts +27 -0
  378. package/src/yjs/yjs-cursor-plugin.ts +25 -0
  379. package/src/yjs/yjs-keymap.ts +23 -0
  380. package/src/yjs/yjs-sync-plugin.ts +23 -0
  381. package/src/yjs/yjs-undo-plugin.ts +87 -0
  382. package/src/yjs/yjs.ts +84 -0
  383. package/dist/table-C_qAMj5-.js +0 -734
@@ -0,0 +1,618 @@
1
+ import type { Command } from '@prosekit/pm/state'
2
+ import { CellSelection } from 'prosemirror-tables'
3
+ import {
4
+ describe,
5
+ expect,
6
+ it,
7
+ } from 'vitest'
8
+
9
+ import { setupTest } from '../../testing'
10
+
11
+ import { moveTableColumn } from './move-table-column'
12
+
13
+ function setup() {
14
+ const { editor, n } = setupTest()
15
+
16
+ const setCellSelection = (from: number, to: number) => {
17
+ const command: Command = (state, dispatch) => {
18
+ const selection = CellSelection.create(state.doc, from, to)
19
+ dispatch?.(state.tr.setSelection(selection))
20
+ return true
21
+ }
22
+ editor.exec(command)
23
+ }
24
+
25
+ return { editor, n, setCellSelection }
26
+ }
27
+
28
+ describe('moveTableColumn', () => {
29
+ describe('on a simple table', () => {
30
+ it('should move column right-to-left', () => {
31
+ const { editor, n: { doc, table, tr, td } } = setup()
32
+ const docNode = doc(
33
+ table(
34
+ tr(td('1'), td(), td()),
35
+ tr(td('2'), td(), td()),
36
+ tr(td('3'), td(), td()),
37
+ ),
38
+ )
39
+
40
+ editor.set(docNode)
41
+ editor.exec(moveTableColumn({ from: 2, to: 0 }))
42
+
43
+ const expected = doc(
44
+ table(
45
+ tr(td(), td('1'), td()),
46
+ tr(td(), td('2'), td()),
47
+ tr(td(), td('3'), td()),
48
+ ),
49
+ )
50
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
51
+ })
52
+
53
+ it('should move column left-to-right', () => {
54
+ const { editor, n: { doc, table, tr, td } } = setup()
55
+ const docNode = doc(
56
+ table(
57
+ tr(td('1'), td(), td()),
58
+ tr(td('2'), td('x'), td()),
59
+ tr(td('3'), td(), td()),
60
+ ),
61
+ )
62
+
63
+ editor.set(docNode)
64
+ editor.exec(moveTableColumn({ from: 1, to: 2 }))
65
+
66
+ const expected = doc(
67
+ table(
68
+ tr(td('1'), td(), td()),
69
+ tr(td('2'), td(), td('x')),
70
+ tr(td('3'), td(), td()),
71
+ ),
72
+ )
73
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
74
+ })
75
+
76
+ it('should select column after moving with select option', () => {
77
+ const { editor, n: { doc, table, tr, td } } = setup()
78
+ const docNode = doc(
79
+ table(
80
+ tr(td('1'), td(), td()),
81
+ tr(td('2'), td(), td()),
82
+ tr(td('3'), td(), td()),
83
+ ),
84
+ )
85
+
86
+ editor.set(docNode)
87
+ editor.exec(moveTableColumn({ from: 2, to: 0, select: true }))
88
+
89
+ // Check that a cell selection was created
90
+ expect(editor.state.selection).toBeInstanceOf(CellSelection)
91
+ const selection = editor.state.selection as CellSelection
92
+ expect(selection.$anchorCell.pos).toBeDefined()
93
+ expect(selection.$headCell.pos).toBeDefined()
94
+ })
95
+ })
96
+
97
+ describe('on a table with merged cells', () => {
98
+ it('should move columns merged at first line', () => {
99
+ const { editor, n: { doc, table, tr, td } } = setup()
100
+ const docNode = doc(
101
+ table(
102
+ tr(td('1'), td('merged cell', { colspan: 2 })),
103
+ tr(td('2'), td(), td()),
104
+ tr(td('3'), td(), td()),
105
+ ),
106
+ )
107
+
108
+ editor.set(docNode)
109
+ editor.exec(moveTableColumn({ from: 1, to: 0 }))
110
+
111
+ const expected = doc(
112
+ table(
113
+ tr(td('merged cell', { colspan: 2 }), td('1')),
114
+ tr(td(), td(), td('2')),
115
+ tr(td(), td(), td('3')),
116
+ ),
117
+ )
118
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
119
+ })
120
+
121
+ it('should move columns merged at middle line', () => {
122
+ const { editor, n: { doc, table, tr, td } } = setup()
123
+ const docNode = doc(
124
+ table(
125
+ tr(td('1'), td(), td()),
126
+ tr(td('2'), td('merged cell', { colspan: 2 })),
127
+ tr(td('3'), td(), td()),
128
+ ),
129
+ )
130
+
131
+ editor.set(docNode)
132
+ editor.exec(moveTableColumn({ from: 1, to: 0 }))
133
+
134
+ const expected = doc(
135
+ table(
136
+ tr(td(), td(), td('1')),
137
+ tr(td('merged cell', { colspan: 2 }), td('2')),
138
+ tr(td(), td(), td('3')),
139
+ ),
140
+ )
141
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
142
+ })
143
+
144
+ it('should move columns merged at last line', () => {
145
+ const { editor, n: { doc, table, tr, td } } = setup()
146
+ const docNode = doc(
147
+ table(
148
+ tr(td('1'), td(), td()),
149
+ tr(td('2'), td(), td()),
150
+ tr(td('3'), td('merged cell', { colspan: 2 })),
151
+ ),
152
+ )
153
+
154
+ editor.set(docNode)
155
+ editor.exec(moveTableColumn({ from: 1, to: 0 }))
156
+
157
+ const expected = doc(
158
+ table(
159
+ tr(td(), td(), td('1')),
160
+ tr(td(), td(), td('2')),
161
+ tr(td('merged cell', { colspan: 2 }), td('3')),
162
+ ),
163
+ )
164
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
165
+ })
166
+
167
+ it('should move and keep table headers', () => {
168
+ const { editor, n: { doc, table, tr, td, th } } = setup()
169
+ const docNode = doc(
170
+ table(
171
+ tr(th('merged cell', { colspan: 2 }), th()),
172
+ tr(td(), td(), td()),
173
+ tr(td(), td(), td()),
174
+ ),
175
+ )
176
+
177
+ editor.set(docNode)
178
+ editor.exec(moveTableColumn({ from: 0, to: 2 }))
179
+
180
+ const expected = doc(
181
+ table(
182
+ tr(th(), th('merged cell', { colspan: 2 })),
183
+ tr(td(), td(), td()),
184
+ tr(td(), td(), td()),
185
+ ),
186
+ )
187
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
188
+ })
189
+
190
+ it('should move and keep columns headers', () => {
191
+ const { editor, n: { doc, table, tr, td, th } } = setup()
192
+ const docNode = doc(
193
+ table(
194
+ tr(th(), th(), th()),
195
+ tr(th('b1'), td(), td('b2')),
196
+ tr(th(), td(), td()),
197
+ ),
198
+ )
199
+
200
+ editor.set(docNode)
201
+ editor.exec(moveTableColumn({ from: 2, to: 0 }))
202
+
203
+ const expected = doc(
204
+ table(
205
+ tr(th(), th(), th()),
206
+ tr(th('b2'), td('b1'), td()),
207
+ tr(th(), td(), td()),
208
+ ),
209
+ )
210
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
211
+ })
212
+ })
213
+
214
+ describe('on a table with merged rows', () => {
215
+ it('should move columns', () => {
216
+ const { editor, n: { doc, table, tr, td } } = setup()
217
+ const docNode = doc(
218
+ table(
219
+ tr(td('merged-row', { rowspan: 2 }), td('a0'), td('a1')),
220
+ tr(td('b1'), td('b2')),
221
+ tr(td('c1'), td('c2'), td('c3')),
222
+ ),
223
+ )
224
+
225
+ editor.set(docNode)
226
+ editor.exec(moveTableColumn({ from: 1, to: 2 }))
227
+
228
+ const expected = doc(
229
+ table(
230
+ tr(td('merged-row', { rowspan: 2 }), td('a1'), td('a0')),
231
+ tr(td('b2'), td('b1')),
232
+ tr(td('c1'), td('c3'), td('c2')),
233
+ ),
234
+ )
235
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
236
+ })
237
+
238
+ it('should move columns for multi rows merged', () => {
239
+ const { editor, n: { doc, table, tr, td } } = setup()
240
+ const docNode = doc(
241
+ table(
242
+ tr(td('a1', { rowspan: 2 }), td('a2'), td('a3')),
243
+ tr(td('b1'), td('b2', { rowspan: 2 })),
244
+ tr(td('c1'), td('c2')),
245
+ ),
246
+ )
247
+
248
+ editor.set(docNode)
249
+ editor.exec(moveTableColumn({ from: 1, to: 2 }))
250
+
251
+ const expected = doc(
252
+ table(
253
+ tr(td('a1', { rowspan: 2 }), td('a3'), td('a2')),
254
+ tr(td('b2', { rowspan: 2 }), td('b1')),
255
+ tr(td('c1'), td('c2')),
256
+ ),
257
+ )
258
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
259
+ })
260
+
261
+ it('should move columns between two merged rows', () => {
262
+ const { editor, n: { doc, table, tr, td } } = setup()
263
+ const docNode = doc(
264
+ table(
265
+ tr(td('a1', { rowspan: 2 }), td('a2'), td('a3')),
266
+ tr(td('b1'), td('b2', { rowspan: 2 })),
267
+ tr(td('c1'), td('c2')),
268
+ ),
269
+ )
270
+
271
+ editor.set(docNode)
272
+ editor.exec(moveTableColumn({ from: 0, to: 2 }))
273
+
274
+ const expected = doc(
275
+ table(
276
+ tr(td('a2'), td('a3'), td('a1', { rowspan: 2 })),
277
+ tr(td('b1'), td('b2', { rowspan: 2 })),
278
+ tr(td('c2'), td('c1')),
279
+ ),
280
+ )
281
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
282
+ })
283
+
284
+ it('should move column between column with merged row and regular columns', () => {
285
+ const { editor, n: { doc, table, tr, td } } = setup()
286
+ const docNode = doc(
287
+ table(
288
+ tr(td('a1'), td('a2'), td('a3')),
289
+ tr(td('b1'), td('b2', { rowspan: 2 }), td('b3')),
290
+ tr(td('c1'), td('c2')),
291
+ ),
292
+ )
293
+
294
+ editor.set(docNode)
295
+ editor.exec(moveTableColumn({ from: 2, to: 1 }))
296
+
297
+ const expected = doc(
298
+ table(
299
+ tr(td('a1'), td('a3'), td('a2')),
300
+ tr(td('b1'), td('b3'), td('b2', { rowspan: 2 })),
301
+ tr(td('c1'), td('c2')),
302
+ ),
303
+ )
304
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
305
+ })
306
+ })
307
+
308
+ describe('on a complex table with merged cells and rows', () => {
309
+ it('keep the merged content columns order', () => {
310
+ const { editor, n: { doc, table, tr, td } } = setup()
311
+ const docNode = doc(
312
+ table(
313
+ tr(td(), td('a1'), td('a2')),
314
+ tr(td(), td('b1', { colspan: 2 })),
315
+ tr(td(), td('c1'), td('c2')),
316
+ ),
317
+ )
318
+
319
+ editor.set(docNode)
320
+ editor.exec(moveTableColumn({ from: 1, to: 0 }))
321
+
322
+ const expected = doc(
323
+ table(
324
+ tr(td('a1'), td('a2'), td()),
325
+ tr(td('b1', { colspan: 2 }), td()),
326
+ tr(td('c1'), td('c2'), td()),
327
+ ),
328
+ )
329
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
330
+ })
331
+
332
+ describe('when the first line all columns are merged', () => {
333
+ it('should not move columns', () => {
334
+ const { editor, n: { doc, table, tr, td } } = setup()
335
+ const docNode = doc(
336
+ table(
337
+ tr(td('a1', { colspan: 3 })),
338
+ tr(td('b1'), td(), td()),
339
+ tr(td('c1'), td(), td()),
340
+ ),
341
+ )
342
+
343
+ editor.set(docNode)
344
+ editor.exec(moveTableColumn({ from: 1, to: 0 }))
345
+
346
+ const expected = doc(
347
+ table(
348
+ tr(td('a1', { colspan: 3 })),
349
+ tr(td('b1'), td(), td()),
350
+ tr(td('c1'), td(), td()),
351
+ ),
352
+ )
353
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
354
+ })
355
+ })
356
+ })
357
+
358
+ describe('on a simple table with col header', () => {
359
+ it('should move column 0 -> 2', () => {
360
+ const { editor, n: { doc, table, tr, td, th } } = setup()
361
+ const docNode = doc(
362
+ table(
363
+ tr(th('1'), td(), td()),
364
+ tr(th('2'), td(), td()),
365
+ tr(th('3'), td(), td()),
366
+ ),
367
+ )
368
+
369
+ editor.set(docNode)
370
+ editor.exec(moveTableColumn({ from: 0, to: 2 }))
371
+
372
+ const expected = doc(
373
+ table(
374
+ tr(th(), td(), td('1')),
375
+ tr(th(), td(), td('2')),
376
+ tr(th(), td(), td('3')),
377
+ ),
378
+ )
379
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
380
+ })
381
+
382
+ it('should move column 2 -> 0', () => {
383
+ const { editor, n: { doc, table, tr, td, th } } = setup()
384
+ const docNode = doc(
385
+ table(
386
+ tr(th('1'), td(), td()),
387
+ tr(th('2'), td(), td()),
388
+ tr(th('3'), td(), td()),
389
+ ),
390
+ )
391
+
392
+ editor.set(docNode)
393
+ editor.exec(moveTableColumn({ from: 2, to: 0 }))
394
+
395
+ const expected = doc(
396
+ table(
397
+ tr(th(), td('1'), td()),
398
+ tr(th(), td('2'), td()),
399
+ tr(th(), td('3'), td()),
400
+ ),
401
+ )
402
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
403
+ })
404
+
405
+ it('should move column 1 -> 2', () => {
406
+ const { editor, n: { doc, table, tr, td, th } } = setup()
407
+ const docNode = doc(
408
+ table(
409
+ tr(th('1'), td(), td()),
410
+ tr(th('2'), td('x'), td()),
411
+ tr(th('3'), td(), td()),
412
+ ),
413
+ )
414
+
415
+ editor.set(docNode)
416
+ editor.exec(moveTableColumn({ from: 1, to: 2 }))
417
+
418
+ const expected = doc(
419
+ table(
420
+ tr(th('1'), td(), td()),
421
+ tr(th('2'), td(), td('x')),
422
+ tr(th('3'), td(), td()),
423
+ ),
424
+ )
425
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
426
+ })
427
+ })
428
+
429
+ describe('on a simple table with row header', () => {
430
+ it('should move column 0 -> 2', () => {
431
+ const { editor, n: { doc, table, tr, td, th } } = setup()
432
+ const docNode = doc(
433
+ table(
434
+ tr(th('1'), th(), th()),
435
+ tr(td('2'), td(), td()),
436
+ tr(td('3'), td(), td()),
437
+ ),
438
+ )
439
+
440
+ editor.set(docNode)
441
+ editor.exec(moveTableColumn({ from: 0, to: 2 }))
442
+
443
+ const expected = doc(
444
+ table(
445
+ tr(th(), th(), th('1')),
446
+ tr(td(), td(), td('2')),
447
+ tr(td(), td(), td('3')),
448
+ ),
449
+ )
450
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
451
+ })
452
+
453
+ it('should move column 2 -> 0', () => {
454
+ const { editor, n: { doc, table, tr, td, th } } = setup()
455
+ const docNode = doc(
456
+ table(
457
+ tr(th('1'), th(), th()),
458
+ tr(td('2'), td(), td()),
459
+ tr(td('3'), td(), td()),
460
+ ),
461
+ )
462
+
463
+ editor.set(docNode)
464
+ editor.exec(moveTableColumn({ from: 2, to: 0 }))
465
+
466
+ const expected = doc(
467
+ table(
468
+ tr(th(), th('1'), th()),
469
+ tr(td(), td('2'), td()),
470
+ tr(td(), td('3'), td()),
471
+ ),
472
+ )
473
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
474
+ })
475
+
476
+ it('should move column 1 -> 2', () => {
477
+ const { editor, n: { doc, table, tr, td, th } } = setup()
478
+ const docNode = doc(
479
+ table(
480
+ tr(th('1'), th(), th()),
481
+ tr(td('2'), td('x'), td()),
482
+ tr(td('3'), td(), td()),
483
+ ),
484
+ )
485
+
486
+ editor.set(docNode)
487
+ editor.exec(moveTableColumn({ from: 1, to: 2 }))
488
+
489
+ const expected = doc(
490
+ table(
491
+ tr(th('1'), th(), th()),
492
+ tr(td('2'), td(), td('x')),
493
+ tr(td('3'), td(), td()),
494
+ ),
495
+ )
496
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
497
+ })
498
+ })
499
+
500
+ describe('on a simple table with col & row header', () => {
501
+ it('should move column 0 -> 2', () => {
502
+ const { editor, n: { doc, table, tr, td, th } } = setup()
503
+ const docNode = doc(
504
+ table(
505
+ tr(th('1'), th(), th()),
506
+ tr(th('2'), td(), td()),
507
+ tr(th('3'), td(), td()),
508
+ ),
509
+ )
510
+
511
+ editor.set(docNode)
512
+ editor.exec(moveTableColumn({ from: 0, to: 2 }))
513
+
514
+ const expected = doc(
515
+ table(
516
+ tr(th(), th(), th('1')),
517
+ tr(th(), td(), td('2')),
518
+ tr(th(), td(), td('3')),
519
+ ),
520
+ )
521
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
522
+ })
523
+
524
+ it('should move column 2 -> 0', () => {
525
+ const { editor, n: { doc, table, tr, td, th } } = setup()
526
+ const docNode = doc(
527
+ table(
528
+ tr(th('1'), th(), th()),
529
+ tr(th('2'), td(), td()),
530
+ tr(th('3'), td(), td()),
531
+ ),
532
+ )
533
+
534
+ editor.set(docNode)
535
+ editor.exec(moveTableColumn({ from: 2, to: 0 }))
536
+
537
+ const expected = doc(
538
+ table(
539
+ tr(th(), th('1'), th()),
540
+ tr(th(), td('2'), td()),
541
+ tr(th(), td('3'), td()),
542
+ ),
543
+ )
544
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
545
+ })
546
+
547
+ it('should move column 1 -> 2', () => {
548
+ const { editor, n: { doc, table, tr, td, th } } = setup()
549
+ const docNode = doc(
550
+ table(
551
+ tr(th('1'), th(), th()),
552
+ tr(th('2'), td('x'), td()),
553
+ tr(th('3'), td(), td()),
554
+ ),
555
+ )
556
+
557
+ editor.set(docNode)
558
+ editor.exec(moveTableColumn({ from: 1, to: 2 }))
559
+
560
+ const expected = doc(
561
+ table(
562
+ tr(th('1'), th(), th()),
563
+ tr(th('2'), td(), td('x')),
564
+ tr(th('3'), td(), td()),
565
+ ),
566
+ )
567
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
568
+ })
569
+ })
570
+
571
+ describe('table with headers and varying cell types', () => {
572
+ it('should move column 2 to 0', () => {
573
+ const { editor, n: { doc, table, tr, td, th } } = setup()
574
+ const docNode = doc(
575
+ table(
576
+ tr(th('a1'), th('a2'), th('a3'), th('a4'), th('a5')),
577
+ tr(td('b1', { colspan: 2 }), td('b2'), td('b3'), td('b4')),
578
+ tr(td('c1'), td('c2'), td('c3'), td('c4', { colspan: 2 })),
579
+ ),
580
+ )
581
+
582
+ editor.set(docNode)
583
+ editor.exec(moveTableColumn({ from: 2, to: 0 }))
584
+
585
+ const expected = doc(
586
+ table(
587
+ tr(th('a3'), th('a1'), th('a2'), th('a4'), th('a5')),
588
+ tr(td('b2'), td('b1', { colspan: 2 }), td('b3'), td('b4')),
589
+ tr(td('c3'), td('c1'), td('c2'), td('c4', { colspan: 2 })),
590
+ ),
591
+ )
592
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
593
+ })
594
+
595
+ it('should move column 0 to 2', () => {
596
+ const { editor, n: { doc, table, tr, td, th } } = setup()
597
+ const docNode = doc(
598
+ table(
599
+ tr(th('a1'), th('a2'), th('a3'), th('a4'), th('a5')),
600
+ tr(td('b1', { colspan: 2 }), td('b2'), td('b3'), td('b4')),
601
+ tr(td('c1'), td('c2'), td('c3'), td('c4', { colspan: 2 })),
602
+ ),
603
+ )
604
+
605
+ editor.set(docNode)
606
+ editor.exec(moveTableColumn({ from: 0, to: 2 }))
607
+
608
+ const expected = doc(
609
+ table(
610
+ tr(th('a3'), th('a1'), th('a2'), th('a4'), th('a5')),
611
+ tr(td('b2'), td('b1', { colspan: 2 }), td('b3'), td('b4')),
612
+ tr(td('c3'), td('c1'), td('c2'), td('c4', { colspan: 2 })),
613
+ ),
614
+ )
615
+ expect(editor.state.doc.toJSON()).toEqual(expected.toJSON())
616
+ })
617
+ })
618
+ })
@@ -0,0 +1,4 @@
1
+ export {
2
+ moveTableColumn,
3
+ type MoveTableColumnOptions,
4
+ } from 'prosemirror-tables'