@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,156 @@
1
+ import {
2
+ addMark,
3
+ defineCommands,
4
+ defineMarkSpec,
5
+ expandMark,
6
+ removeMark,
7
+ toggleMark,
8
+ union,
9
+ type Extension,
10
+ type PlainExtension,
11
+ type Union,
12
+ } from '@prosekit/core'
13
+ import { InputRule } from '@prosekit/pm/inputrules'
14
+
15
+ import { defineEnterRule } from '../enter-rule'
16
+ import { defineInputRule } from '../input-rule'
17
+ import { defineMarkRule } from '../mark-rule'
18
+
19
+ import { defineLinkPasteRule } from './link-paste-rule'
20
+ import {
21
+ LINK_ENTER_RE,
22
+ LINK_INPUT_RE,
23
+ LINK_MARK_RE,
24
+ } from './link-regex'
25
+ import type { LinkAttrs } from './link-types'
26
+
27
+ export { defineLinkPasteRule }
28
+ export type { LinkAttrs }
29
+
30
+ /**
31
+ * @internal
32
+ */
33
+ export type LinkSpecExtension = Extension<{
34
+ Marks: {
35
+ link: LinkAttrs
36
+ }
37
+ }>
38
+
39
+ /**
40
+ * @internal
41
+ */
42
+ export function defineLinkSpec(): LinkSpecExtension {
43
+ return defineMarkSpec<'link', LinkAttrs>({
44
+ name: 'link',
45
+ inclusive: false,
46
+ attrs: {
47
+ href: { validate: 'string' },
48
+ target: { default: null, validate: 'string|null' },
49
+ rel: { default: null, validate: 'string|null' },
50
+ },
51
+ parseDOM: [
52
+ {
53
+ tag: 'a[href]',
54
+ getAttrs: (dom: HTMLElement) => {
55
+ return {
56
+ href: dom.getAttribute('href') || '',
57
+ target: dom.getAttribute('target') || null,
58
+ rel: dom.getAttribute('rel') || null,
59
+ }
60
+ },
61
+ },
62
+ ],
63
+ toDOM(node) {
64
+ const { href, target, rel } = node.attrs as LinkAttrs
65
+ return ['a', { href, target, rel }, 0]
66
+ },
67
+ })
68
+ }
69
+
70
+ /**
71
+ * @internal
72
+ */
73
+ export type LinkCommandsExtension = Extension<{
74
+ Commands: {
75
+ addLink: [attrs: LinkAttrs]
76
+ removeLink: []
77
+ toggleLink: [attrs: LinkAttrs]
78
+ expandLink: []
79
+ }
80
+ }>
81
+
82
+ export function defineLinkCommands(): LinkCommandsExtension {
83
+ return defineCommands({
84
+ addLink: (attrs: LinkAttrs) => addMark({ type: 'link', attrs }),
85
+ removeLink: () => removeMark({ type: 'link' }),
86
+ toggleLink: (attrs: LinkAttrs) => toggleMark({ type: 'link', attrs }),
87
+ expandLink: () => expandMark({ type: 'link' }),
88
+ })
89
+ }
90
+
91
+ /**
92
+ * Apply link marks after pressing Space.
93
+ *
94
+ * @internal
95
+ */
96
+ export function defineLinkInputRule(): PlainExtension {
97
+ return defineInputRule(
98
+ new InputRule(LINK_INPUT_RE, (state, match, from) => {
99
+ const href = match[1]
100
+ if (!href) return null
101
+
102
+ const mark = state.schema.marks.link.create({ href })
103
+ return state.tr.addMark(from, from + href.length, mark).insertText(' ')
104
+ }),
105
+ )
106
+ }
107
+
108
+ /**
109
+ * Apply link marks after typing Enter.
110
+ *
111
+ * @internal
112
+ */
113
+ export function defineLinkEnterRule(): PlainExtension {
114
+ return defineEnterRule({
115
+ regex: LINK_ENTER_RE,
116
+ handler: ({ state, from, match }) => {
117
+ const href = match[1]
118
+ if (!href) return null
119
+
120
+ const mark = state.schema.marks.link.create({ href })
121
+ const tr = state.tr.addMark(from, from + href.length, mark)
122
+ return tr.docChanged ? tr : null
123
+ },
124
+ })
125
+ }
126
+
127
+ /**
128
+ * Apply and remove link marks to the text during typing.
129
+ *
130
+ * @internal
131
+ */
132
+ export function defineLinkMarkRule(): PlainExtension {
133
+ return defineMarkRule({
134
+ regex: LINK_MARK_RE,
135
+ type: 'link',
136
+ attrs: (match) => ({ href: match[1] }),
137
+ })
138
+ }
139
+
140
+ /**
141
+ * @internal
142
+ */
143
+ export type LinkExtension = Union<[LinkSpecExtension, LinkCommandsExtension]>
144
+
145
+ /**
146
+ * @public
147
+ */
148
+ export function defineLink(): LinkExtension {
149
+ return union(
150
+ defineLinkSpec(),
151
+ defineLinkCommands(),
152
+ defineLinkInputRule(),
153
+ defineLinkEnterRule(),
154
+ defineLinkPasteRule(),
155
+ )
156
+ }
@@ -0,0 +1,194 @@
1
+ import {
2
+ describe,
3
+ expect,
4
+ it,
5
+ } from 'vitest'
6
+
7
+ import { setupTest } from '../testing'
8
+ import {
9
+ pasteHTML,
10
+ pasteText,
11
+ } from '../testing/clipboard'
12
+
13
+ describe('defineLinkPasteRule', () => {
14
+ const { editor, n, m } = setupTest()
15
+
16
+ it('should convert URLs to links when pasting plain text', () => {
17
+ const doc = n.doc(n.p('<a>'))
18
+ editor.set(doc)
19
+
20
+ pasteHTML(editor.view, '<p>Visit https://example.com for more info</p>')
21
+
22
+ expect(editor.view.state.doc.toJSON()).toEqual(
23
+ n.doc(n.p(
24
+ 'Visit ',
25
+ m.link({ href: 'https://example.com' }, 'https://example.com'),
26
+ ' for more info',
27
+ )).toJSON(),
28
+ )
29
+ })
30
+
31
+ it('should handle multiple URLs in pasted text', () => {
32
+ const doc = n.doc(n.p('<a>'))
33
+ editor.set(doc)
34
+
35
+ pasteHTML(editor.view, '<p>Check https://google.com and https://github.com</p>')
36
+
37
+ expect(editor.view.state.doc.toJSON()).toEqual(
38
+ n.doc(n.p(
39
+ 'Check ',
40
+ m.link({ href: 'https://google.com' }, 'https://google.com'),
41
+ ' and ',
42
+ m.link({ href: 'https://github.com' }, 'https://github.com'),
43
+ )).toJSON(),
44
+ )
45
+ })
46
+
47
+ it('should handle URLs without protocol', () => {
48
+ const doc = n.doc(n.p('<a>'))
49
+ editor.set(doc)
50
+
51
+ pasteHTML(editor.view, '<p>Visit example.com for details</p>')
52
+
53
+ expect(editor.view.state.doc.toJSON()).toEqual(
54
+ n.doc(n.p(
55
+ 'Visit ',
56
+ m.link({ href: 'example.com' }, 'example.com'),
57
+ ' for details',
58
+ )).toJSON(),
59
+ )
60
+ })
61
+
62
+ it('should not modify text without URLs', () => {
63
+ const doc = n.doc(n.p('<a>'))
64
+ editor.set(doc)
65
+
66
+ pasteText(editor.view, 'This is just plain text without any links')
67
+
68
+ expect(editor.view.state.doc.toJSON()).toEqual(
69
+ n.doc(n.p('This is just plain text without any links')).toJSON(),
70
+ )
71
+ })
72
+
73
+ it('should preserve existing marks when adding links', () => {
74
+ const doc = n.doc(n.p('<a>'))
75
+ editor.set(doc)
76
+
77
+ pasteHTML(editor.view, '<p>Visit <strong>https://example.com</strong> for info</p>')
78
+
79
+ expect(editor.view.state.doc.toJSON()).toEqual(
80
+ n.doc(n.p(
81
+ 'Visit ',
82
+ m.bold(m.link({ href: 'https://example.com' }, 'https://example.com')),
83
+ ' for info',
84
+ )).toJSON(),
85
+ )
86
+ })
87
+
88
+ it('should not convert URLs inside existing links', () => {
89
+ const doc = n.doc(n.p('<a>'))
90
+ editor.set(doc)
91
+
92
+ pasteHTML(editor.view, '<p><a href="https://google.com">Visit https://example.com for more</a></p>')
93
+
94
+ expect(editor.view.state.doc.toJSON()).toEqual(
95
+ n.doc(n.p(
96
+ m.link({ href: 'https://google.com' }, 'Visit https://example.com for more'),
97
+ )).toJSON(),
98
+ )
99
+ })
100
+
101
+ it('should not convert URLs inside code blocks', () => {
102
+ const doc = n.doc(n.codeBlock('<a>'))
103
+ editor.set(doc)
104
+
105
+ pasteText(editor.view, 'https://example.com')
106
+
107
+ expect(editor.view.state.doc.toJSON()).toEqual(
108
+ n.doc(n.codeBlock('https://example.com')).toJSON(),
109
+ )
110
+ })
111
+
112
+ it('should not convert URLs inside code marks', () => {
113
+ const doc = n.doc(n.p('<a>'))
114
+ editor.set(doc)
115
+
116
+ pasteHTML(editor.view, '<p><code>https://example.com</code></p>')
117
+
118
+ expect(editor.view.state.doc.toJSON()).toEqual(
119
+ n.doc(n.p(m.code('https://example.com'))).toJSON(),
120
+ )
121
+ })
122
+
123
+ it('should handle URLs with paths and query parameters', () => {
124
+ const doc = n.doc(n.p('<a>'))
125
+ editor.set(doc)
126
+
127
+ pasteHTML(editor.view, '<p>Visit https://example.com/path?param=value#section</p>')
128
+
129
+ expect(editor.view.state.doc.toJSON()).toEqual(
130
+ n.doc(n.p(
131
+ 'Visit ',
132
+ m.link({ href: 'https://example.com/path?param=value#section' }, 'https://example.com/path?param=value#section'),
133
+ )).toJSON(),
134
+ )
135
+ })
136
+
137
+ it('should handle URLs at the beginning of text', () => {
138
+ const doc = n.doc(n.p('<a>'))
139
+ editor.set(doc)
140
+
141
+ pasteHTML(editor.view, '<p>https://example.com is a great site</p>')
142
+
143
+ expect(editor.view.state.doc.toJSON()).toEqual(
144
+ n.doc(n.p(
145
+ m.link({ href: 'https://example.com' }, 'https://example.com'),
146
+ ' is a great site',
147
+ )).toJSON(),
148
+ )
149
+ })
150
+
151
+ it('should handle URLs at the end of text', () => {
152
+ const doc = n.doc(n.p('<a>'))
153
+ editor.set(doc)
154
+
155
+ pasteHTML(editor.view, '<p>Check out https://example.com</p>')
156
+
157
+ expect(editor.view.state.doc.toJSON()).toEqual(
158
+ n.doc(n.p(
159
+ 'Check out ',
160
+ m.link({ href: 'https://example.com' }, 'https://example.com'),
161
+ )).toJSON(),
162
+ )
163
+ })
164
+
165
+ it('should handle URLs with punctuation after them', () => {
166
+ const doc = n.doc(n.p('<a>'))
167
+ editor.set(doc)
168
+
169
+ pasteHTML(editor.view, '<p>Visit https://example.com, it is great!</p>')
170
+
171
+ expect(editor.view.state.doc.toJSON()).toEqual(
172
+ n.doc(n.p(
173
+ 'Visit ',
174
+ m.link({ href: 'https://example.com' }, 'https://example.com'),
175
+ ', it is great!',
176
+ )).toJSON(),
177
+ )
178
+ })
179
+
180
+ it('should handle URLs inside nested block structures', () => {
181
+ const doc = n.doc(n.p('<a>'))
182
+ editor.set(doc)
183
+
184
+ pasteHTML(editor.view, '<blockquote><p>Quote: Visit https://example.com for more info</p></blockquote>')
185
+
186
+ expect(editor.view.state.doc.toJSON()).toEqual(
187
+ n.doc(n.blockquote(n.p(
188
+ 'Quote: Visit ',
189
+ m.link({ href: 'https://example.com' }, 'https://example.com'),
190
+ ' for more info',
191
+ ))).toJSON(),
192
+ )
193
+ })
194
+ })
@@ -0,0 +1,22 @@
1
+ import type { PlainExtension } from '@prosekit/core'
2
+
3
+ import { defineMarkPasteRule } from '../paste-rule'
4
+
5
+ import { LINK_MARK_RE } from './link-regex'
6
+ import type { LinkAttrs } from './link-types'
7
+
8
+ /**
9
+ * @internal
10
+ */
11
+ export function defineLinkPasteRule(): PlainExtension {
12
+ return defineMarkPasteRule({
13
+ type: 'link',
14
+ regex: LINK_MARK_RE,
15
+ getAttrs: (match: RegExpExecArray): LinkAttrs | false => {
16
+ if (match[1]) {
17
+ return { href: match[1] } satisfies LinkAttrs
18
+ }
19
+ return false
20
+ },
21
+ })
22
+ }
@@ -0,0 +1,82 @@
1
+ import {
2
+ describe,
3
+ expect,
4
+ it,
5
+ } from 'vitest'
6
+
7
+ import { LINK_MARK_RE } from './link-regex'
8
+
9
+ describe('LINK_MARK_RE', () => {
10
+ const cases = [
11
+ ['Not a link', null],
12
+
13
+ ['example.com', 'example.com'],
14
+ ['https://example.com', 'https://example.com'],
15
+ ['Foo https://example.com Bar', 'https://example.com'],
16
+ ['https://example.com/', 'https://example.com/'],
17
+ ['https://example.com/?query=1', 'https://example.com/?query=1'],
18
+ ['https://example.com/#fragment', 'https://example.com/#fragment'],
19
+ [
20
+ 'https://example.com/path?query=1#fragment',
21
+ 'https://example.com/path?query=1#fragment',
22
+ ],
23
+ [
24
+ 'https://example.com/path?query=1#fragment',
25
+ 'https://example.com/path?query=1#fragment',
26
+ ],
27
+ [
28
+ 'Foo https://example.com/path?query=1#fragment Bar',
29
+ 'https://example.com/path?query=1#fragment',
30
+ ],
31
+
32
+ // Ignore the period at the end
33
+ ['https://example.com.', 'https://example.com'],
34
+ ['https://example.com.uk', 'https://example.com.uk'],
35
+
36
+ // .goog is a TLD
37
+ ['Foo www.goog', 'www.goog'],
38
+ // .googl is not a TLD
39
+ ['Foo www.googl', null],
40
+ // .google is a TLD
41
+ ['Foo www.google', 'www.google'],
42
+
43
+ // Don't match ? when there is nothing after it
44
+ ['www.example.com?', 'www.example.com'],
45
+ ['www.example.com/?', 'www.example.com/'],
46
+ ['www.example.com/?=', 'www.example.com/?='],
47
+
48
+ // Don't match . when there is nothing after it
49
+ ['www.example.com.', 'www.example.com'],
50
+ ['www.example.com/.', 'www.example.com/'],
51
+ ['www.example.com/subpath.', 'www.example.com/subpath'],
52
+ ['www.example.com/subpath/.', 'www.example.com/subpath/'],
53
+ ['www.example.com/.gitignore', 'www.example.com/.gitignore'],
54
+
55
+ // with ( and )
56
+ [
57
+ 'https://en.wikipedia.org/wiki/Specials_(Unicode_block)',
58
+ 'https://en.wikipedia.org/wiki/Specials_(Unicode_block)',
59
+ ],
60
+
61
+ // with '
62
+ [
63
+ `https://en.wikipedia.org/wiki/The_Power_of_the_Powerless#Havel's_greengrocer`,
64
+ `https://en.wikipedia.org/wiki/The_Power_of_the_Powerless#Havel's_greengrocer`,
65
+ ],
66
+
67
+ // Trailing punctuation
68
+ [`www.example.com?a!`, `www.example.com?a`],
69
+ [`www.example.com?a! `, `www.example.com?a`],
70
+ [`www.example.com?a!!`, `www.example.com?a`],
71
+ [`www.example.com?a!b`, `www.example.com?a!b`],
72
+ [`www.example.com?a!b `, `www.example.com?a!b`],
73
+ [`www.example.com?a!b! `, `www.example.com?a!b`],
74
+ [`www.example.com?a!b!! `, `www.example.com?a!b`],
75
+ ] as const
76
+
77
+ it.each(cases)('should handle %s', (str, expected) => {
78
+ LINK_MARK_RE.lastIndex = 0
79
+ const received = LINK_MARK_RE.exec(str)?.[0] ?? null
80
+ expect(received).toEqual(expected)
81
+ })
82
+ })
@@ -0,0 +1,79 @@
1
+ /* eslint-disable unicorn/prefer-string-raw -- Don't use String.raw here for better bundler minification */
2
+
3
+ // All valid alpha TLDs.
4
+ // Data source: https://data.iana.org/TLD/tlds-alpha-by-domain.txt
5
+ const TLD_RE_PATTERN =
6
+ 'a(?:a(?:a|rp)|b(?:arth|b(?:ott|vie)?|c|le|ogado|udhabi)|c(?:ademy|c(?:enture|ountants?)|o|tor)?|d(?:s|ult)?|e(?:g|ro|tna)?|f(?:l|rica)?|g(?:akhan|ency)?|i(?:g|r(?:bus|force|tel))?|kdn|l(?:faromeo|i(?:baba|pay)|l(?:finanz|state|y)|s(?:ace|tom))?|m(?:azon|e(?:rican(?:express|family)|x)|fam|ica|sterdam)?|n(?:alytics|droid|quan|z)|ol?|p(?:artments|p(?:le)?)|q(?:uarelle)?|r(?:a(?:b|mco)|chi|my|pa|te?)?|s(?:da|ia|sociates)?|t(?:hleta|torney)?|u(?:ction|di(?:ble|o)?|spost|t(?:hor|os?))?|vianca|ws?|xa?|z(?:ure)?)|b(?:a(?:by|idu|n(?:a(?:mex|narepublic)|d|k)|r(?:c(?:elona|lay(?:card|s))|efoot|gains)?|s(?:eball|ketball)|uhaus|yern)?|b(?:c|t|va)?|c[gn]|d|e(?:a(?:ts|uty)|er|ntley|rlin|st(?:buy)?|t)?|f|g|h(?:arti)?|i(?:ble|d|ke|ngo?|o|z)?|j|l(?:ack(?:friday)?|o(?:ckbuster|g|omberg)|ue)|m[sw]?|n(?:pparibas)?|o(?:ats|ehringer|fa|m|nd|o(?:k(?:ing)?)?|s(?:ch|t(?:ik|on))|t|utique|x)?|r(?:adesco|idgestone|o(?:adway|ker|ther)|ussels)?|s|t|u(?:ild(?:ers)?|siness|y|zz)|v|w|y|zh?)|c(?:a(?:b|fe|l(?:l|vinklein)?|m(?:era|p)?|non|p(?:etown|ital(?:one)?)|r(?:avan|ds|e(?:ers?)?|s)?|s(?:a|e|h|ino)|t(?:ering|holic)?)?|b(?:a|n|re|s)|c|d|e(?:nter|o|rn)|f[ad]?|g|h(?:a(?:n(?:el|nel)|rity|se|t)|eap|intai|r(?:istmas|ome)|urch)?|i(?:priani|rcle|sco|t(?:adel|ic?|y(?:eats)?))?|k|l(?:aims|eaning|i(?:ck|ni(?:c|que))|o(?:thing|ud)|ub(?:med)?)?|m|n|o(?:ach|des|ffee|l(?:lege|ogne)|m(?:cast|m(?:bank|unity)|p(?:a(?:ny|re)|uter)|sec)?|n(?:dos|s(?:truction|ulting)|t(?:act|ractors))|o(?:king(?:channel)?|l|p)|rsica|u(?:ntry|pons?|rses))?|pa|r(?:edit(?:card|union)?|icket|own|s|uises?)?|u(?:isinella)?|v|w|x|y(?:mru|ou)?|z)|d(?:a(?:bur|d|nce|t(?:a|e|ing|sun)|y)|clk|ds|e(?:al(?:er|s)?|gree|l(?:ivery|l|oitte|ta)|mocrat|nt(?:al|ist)|si(?:gn)?|v)?|hl|i(?:amonds|et|gital|rect(?:ory)?|s(?:co(?:unt|ver)|h)|y)|j|k|m|np|o(?:c(?:s|tor)|g|mains|t|wnload)?|rive|tv|u(?:bai|nlop|pont|rban)|v(?:ag|r)|z)|e(?:a(?:rth|t)|co?|d(?:eka|u(?:cation)?)|e|g|m(?:ail|erck)|n(?:ergy|gineer(?:ing)?|terprises)|pson|quipment|r(?:icsson|ni)?|s(?:q|tate)?|t(?:isalat)?|u(?:rovision|s)?|vents|x(?:change|p(?:ert|osed|ress)|traspace))|f(?:a(?:ge|i(?:l|rwinds|th)|mily|ns?|rm(?:ers)?|s(?:hion|t))|e(?:dex|edback|rr(?:ari|ero))|i(?:at|d(?:elity|o)|lm|na(?:l|nc(?:e|ial))|r(?:e(?:stone)?|mdale)|sh(?:ing)?|t(?:ness)?)?|j|k|l(?:i(?:ckr|ghts|r)|o(?:rist|wers)|y)|m|o(?:o(?:d(?:network)?|tball)?|r(?:d|ex|sale|um)|undation|x)?|r(?:e(?:e|senius)|l|o(?:gans|nt(?:door|ier)))?|tr|u(?:jitsu|nd?|rniture|tbol)|yi)|g(?:a(?:l(?:l(?:ery|o|up))?|mes?|p|rden|y)?|b(?:iz)?|dn?|e(?:a|nt(?:ing)?|orge)?|f|g(?:ee)?|h|i(?:fts?|v(?:es|ing))?|l(?:ass|e|ob(?:al|o))?|m(?:ail|bh|o|x)?|n|o(?:daddy|l(?:d(?:point)?|f)|o(?:dyear|g(?:le)?)?|p|t|v)|p|q|r(?:a(?:inger|phics|tis)|een|ipe|o(?:cery|up))?|s|t|u(?:ardian|cci|ge|i(?:de|tars)|ru)?|w|y)|h(?:a(?:ir|mburg|ngout|us)|bo|dfc(?:bank)?|e(?:alth(?:care)?|l(?:p|sinki)|r(?:e|mes))|gtv|i(?:phop|samitsu|tachi|v)|kt?|m|n|o(?:ckey|l(?:dings|iday)|me(?:depot|goods|s(?:ense)?)|nda|rse|s(?:pital|t(?:ing)?)|t(?:el(?:es|s)|mail)?|use|w)|r|sbc|t|u(?:ghes)?|y(?:att|undai))|i(?:bm|c(?:bc|e|u)|d|e(?:ee)?|fm|kano|l|m(?:amat|db|mo(?:bilien)?)?|n(?:c|dustries|f(?:initi|o)|g|k|s(?:titute|ur(?:ance|e))|t(?:ernational|uit)?|vestments)?|o|piranga|q|r(?:ish)?|s(?:maili|t(?:anbul)?)?|t(?:au|v)?)|j(?:a(?:guar|va)|cb|e(?:ep|tzt|welry)?|io|ll|mp?|nj|o(?:b(?:s|urg)|t|y)?|p(?:morgan|rs)?|u(?:egos|niper))|k(?:aufen|ddi|e(?:rry(?:hotels|logistics|properties))?|fh|g|h|i(?:a|ds|m|nd(?:er|le)|tchen|wi)?|m|n|o(?:eln|matsu|sher)|p(?:mg|n)?|r(?:d|ed)?|uokgroup|w|y(?:oto)?|z)|l(?:a(?:caixa|m(?:borghini|er)|n(?:c(?:aster|ia)|d(?:rover)?|xess)|salle|t(?:ino|robe)?|w(?:yer)?)?|b|c|ds|e(?:ase|clerc|frak|g(?:al|o)|xus)|gbt|i(?:dl|fe(?:insurance|style)?|ghting|ke|lly|m(?:ited|o)|n(?:coln|de|k)|psy|v(?:e|ing))?|k|l[cp]|o(?:ans?|c(?:ker|us)|l|ndon|tt[eo]|ve)|pl(?:financial)?|r|s|t(?:da?)?|u(?:ndbeck|x(?:e|ury))?|v|y)|m(?:a(?:cys|drid|i(?:f|son)|keup|n(?:agement|go)?|p|r(?:ket(?:ing|s)?|riott|shalls)|serati|ttel)?|ba|c(?:kinsey)?|d|e(?:d(?:ia)?|et|lbourne|m(?:e|orial)|nu?|rckmsd)?|g|h|i(?:ami|crosoft|l|n[it]|t(?:subishi)?)|k|l[bs]?|ma?|n|o(?:bi(?:le)?|da|e|i|m|n(?:ash|ey|ster)|r(?:mon|tgage)|scow|to(?:rcycles)?|v(?:ie)?)?|p|q|r|sd?|t[nr]?|u(?:s(?:eum|ic)|tual)?|v|w|x|y|z)|n(?:a(?:b|goya|me|tura|vy)?|ba|c|e(?:c|t(?:bank|flix|work)?|ustar|ws?|x(?:t(?:direct)?|us))?|fl?|go?|hk|i(?:co|k(?:e|on)|nja|ssa[ny])?|l|o(?:kia|rt(?:hwesternmutual|on)|w(?:ruz|tv)?)?|p|r[aw]?|tt|u|yc|z)|o(?:b(?:i|server)|ffice|kinawa|l(?:ayan(?:group)?|dnavy|lo)|m(?:ega)?|n(?:e|g|l(?:ine)?)|oo|pen|r(?:a(?:cle|nge)|g(?:anic)?|igins)|saka|t(?:suka|t)|vh)|p(?:a(?:ge|nasonic|r(?:is|s|t(?:ners|s|y))|ssagens|y)?|ccw|et?|f(?:izer)?|g|h(?:armacy|d|ilips|o(?:ne|to(?:graphy|s)?)|ysio)?|i(?:c(?:s|t(?:et|ures))|d|n[gk]?|oneer|zza)|k|l(?:a(?:ce|y(?:station)?)|u(?:mbing|s))?|m|nc?|o(?:hl|ker|litie|rn|st)|r(?:a(?:merica|xi)|ess|ime|o(?:d(?:uctions)?|f|gressive|mo|pert(?:ies|y)|tection)?|u(?:dential)?)?|s|t|ub|wc?|y)|q(?:a|pon|ue(?:bec|st))|r(?:a(?:cing|dio)|e(?:a(?:d|l(?:estate|t(?:or|y)))|cipes|d(?:stone|umbrella)?|hab|i(?:sen?|t)|liance|n(?:t(?:als)?)?|p(?:air|ort|ublican)|st(?:aurant)?|views?|xroth)?|i(?:c(?:h(?:ardli)?|oh)|l|o|p)|o(?:c(?:her|ks)|deo|gers|om)?|s(?:vp)?|u(?:gby|hr|n)?|we?|yukyu)|s(?:a(?:arland|fe(?:ty)?|kura|l(?:e|on)|ms(?:club|ung)|n(?:dvik(?:coromant)?|ofi)|p|rl|s|ve|xo)?|b[is]?|c(?:a|b|h(?:aeffler|midt|o(?:larships|ol)|ule|warz)|ience|ot)?|d|e(?:a(?:rch|t)|cur(?:e|ity)|ek|lect|ner|rvices|ven|w|xy?)?|fr|g|h(?:a(?:ngrila|rp|w)|ell|i(?:a|ksha)|o(?:es|p(?:ping)?|uji|w(?:time)?))?|i(?:lk|n(?:a|gles)|te)?|j|k(?:in?|y(?:pe)?)?|l(?:ing)?|m(?:art|ile)?|n(?:cf)?|o(?:c(?:cer|ial)|ft(?:bank|ware)|hu|l(?:ar|utions)|n[gy]|y)?|p(?:a(?:ce)?|o(?:rt|t))|rl?|s|t(?:a(?:da|ples|r|te(?:bank|farm))|c(?:group)?|o(?:ckholm|r(?:age|e))|ream|ud(?:io|y)|yle)?|u(?:cks|pp(?:l(?:ies|y)|ort)|r(?:f|gery)|zuki)?|v|w(?:atch|iss)|x|y(?:dney|stems)?|z)|t(?:a(?:b|ipei|lk|obao|rget|t(?:a(?:motors|r)|too)|xi?)|ci?|dk?|e(?:am|ch(?:nology)?|l|masek|nnis|va)|f|g|h(?:d|eat(?:er|re))?|i(?:aa|ckets|enda|ffany|ps|r(?:es|ol))|j(?:maxx|x)?|k(?:maxx)?|l|m(?:all)?|n|o(?:day|kyo|ols|p|ray|shiba|tal|urs|wn|y(?:ota|s))?|r(?:a(?:d(?:e|ing)|ining|vel(?:channel|ers(?:insurance)?)?)|ust|v)?|t|u(?:be|i|nes|shu)|vs?|w|z)|u(?:a|b(?:ank|s)|g|k|n(?:i(?:com|versity)|o)|ol|ps|s|y|z)|v(?:a(?:cations|n(?:a|guard))?|c|e(?:gas|ntures|r(?:isign|sicherung)|t)?|g|i(?:ajes|deo|g|king|llas|n|p|rgin|s(?:a|ion)|v[ao])?|laanderen|n|o(?:dka|l(?:kswagen|vo)|t(?:e|ing|o)|yage)|u(?:elos)?)|w(?:a(?:l(?:es|mart|ter)|ng(?:gou)?|tch(?:es)?)|e(?:ather(?:channel)?|b(?:cam|er|site)|d(?:ding)?|i(?:bo|r))|f|hoswho|i(?:en|ki|lliamhill|n(?:dows|e|ners)?)|me|o(?:lterskluwer|odside|r(?:ks?|ld)|w)|s|t[cf])|x(?:box|erox|finity|i(?:huan|n)|xx|yz)|y(?:a(?:chts|hoo|maxun|ndex)|e|o(?:dobashi|ga|kohama|u(?:tube)?)|t|un)|z(?:a(?:ppos|ra)?|ero|ip|m|one|uerich|w)'
7
+
8
+ // Some common punctuations that can be used to stop a link
9
+ const PUNCTUATION_CHAR_PATTERN = '\\.\\,\\;\\!\\?'
10
+
11
+ const STOP_CHAR_PATTERN = '[' + PUNCTUATION_CHAR_PATTERN + ']'
12
+
13
+ const END_CHAR_PATTERN = '[^' + '\\s' + PUNCTUATION_CHAR_PATTERN + ']'
14
+
15
+ // dprint-ignore
16
+ const LINK_RE_BASE_PATTERN = (
17
+ // start of the link group
18
+ '(' +
19
+ '(?:' +
20
+ // protocol identifier (optional)
21
+ // short syntax // is allowed
22
+ '(?:(?:https?:)?\\/\\/)?' +
23
+
24
+ // host & domain names.
25
+ '(?:' +
26
+ '(?:' +
27
+ '[a-z0-9\\u00a1-\\uffff]' +
28
+ '[a-z0-9\\u00a1-\\uffff_-]{0,62}' +
29
+ ')?' +
30
+ '[a-z0-9\\u00a1-\\uffff]\\.' +
31
+ ')+' +
32
+
33
+ // TLD identifier name, must not end with dot
34
+ '(?:' +
35
+ TLD_RE_PATTERN +
36
+ ')' +
37
+ ')' +
38
+
39
+ // port number (optional)
40
+ '(?::\\d{2,5})?' +
41
+
42
+ // sub path (optional)
43
+ '(?:/' +
44
+ '(?:' +
45
+ '\\S*' +
46
+ END_CHAR_PATTERN +
47
+ ')?' +
48
+ ')?' +
49
+
50
+ // query string (optional)
51
+ '(?:\\?' +
52
+ '(?:' +
53
+ '\\S*' +
54
+ END_CHAR_PATTERN +
55
+ ')' +
56
+ ')?' +
57
+
58
+ // fragment (optional)
59
+ '(?:\\#' +
60
+ '(?:' +
61
+ '\\S*' +
62
+ END_CHAR_PATTERN +
63
+ ')?' +
64
+ ')?' +
65
+
66
+ // end of the link group
67
+ ')'
68
+ )
69
+
70
+ // dprint-ignore
71
+ const LINK_ENTER_PATTERN = LINK_RE_BASE_PATTERN + STOP_CHAR_PATTERN + '?' + '$'
72
+ // dprint-ignore
73
+ const LINK_INPUT_PATTERN = LINK_RE_BASE_PATTERN + STOP_CHAR_PATTERN + '?' + '\\s$'
74
+ // dprint-ignore
75
+ const LINK_MARK_PATTERN = LINK_RE_BASE_PATTERN + '(?=' + STOP_CHAR_PATTERN + '|\\s|$)'
76
+
77
+ export const LINK_ENTER_RE: RegExp = new RegExp(LINK_ENTER_PATTERN, 'gi')
78
+ export const LINK_INPUT_RE: RegExp = new RegExp(LINK_INPUT_PATTERN, 'gi')
79
+ export const LINK_MARK_RE: RegExp = new RegExp(LINK_MARK_PATTERN, 'gi')
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @public
3
+ */
4
+ export interface LinkAttrs {
5
+ href: string
6
+ target?: string | null
7
+ rel?: string | null
8
+ }
@@ -0,0 +1,25 @@
1
+ export { ListDOMSerializer } from 'prosemirror-flat-list'
2
+ export type {
3
+ DedentListOptions,
4
+ IndentListOptions,
5
+ ToggleCollapsedOptions,
6
+ UnwrapListOptions,
7
+ WrapInListGetAttrs,
8
+ } from 'prosemirror-flat-list'
9
+ export {
10
+ defineList,
11
+ type ListExtension,
12
+ } from './list'
13
+ export {
14
+ defineListCommands,
15
+ type ListCommandsExtension,
16
+ } from './list-commands'
17
+ export { defineListInputRules } from './list-input-rules'
18
+ export { defineListKeymap } from './list-keymap'
19
+ export { defineListPlugins } from './list-plugins'
20
+ export { defineListSerializer } from './list-serializer'
21
+ export {
22
+ defineListSpec,
23
+ type ListSpecExtension,
24
+ } from './list-spec'
25
+ export type { ListAttrs } from './list-types'
@@ -0,0 +1,61 @@
1
+ import {
2
+ defineCommands,
3
+ insertNode,
4
+ type Extension,
5
+ } from '@prosekit/core'
6
+ import type { Command } from '@prosekit/pm/state'
7
+ import {
8
+ createDedentListCommand as dedentList,
9
+ createIndentListCommand as indentList,
10
+ createMoveListCommand as moveList,
11
+ createSplitListCommand as splitList,
12
+ createToggleCollapsedCommand as toggleCollapsed,
13
+ createToggleListCommand as toggleList,
14
+ createUnwrapListCommand as unwrapList,
15
+ createWrapInListCommand as wrapInList,
16
+ type DedentListOptions,
17
+ type IndentListOptions,
18
+ type ListAttributes,
19
+ type ToggleCollapsedOptions,
20
+ type UnwrapListOptions,
21
+ } from 'prosemirror-flat-list'
22
+
23
+ function insertList(attrs?: ListAttributes): Command {
24
+ return insertNode({ type: 'list', attrs })
25
+ }
26
+
27
+ /**
28
+ * @internal
29
+ */
30
+ export type ListCommandsExtension = Extension<{
31
+ Commands: {
32
+ dedentList: [options?: DedentListOptions]
33
+ indentList: [options?: IndentListOptions]
34
+ moveList: [direction: 'up' | 'down']
35
+ splitList: []
36
+ toggleCollapsed: [options?: ToggleCollapsedOptions]
37
+ unwrapList: [options?: UnwrapListOptions]
38
+ toggleList: [attrs?: ListAttributes]
39
+ wrapInList: [attrs?: ListAttributes]
40
+ insertList: [attrs?: ListAttributes]
41
+ }
42
+ }>
43
+
44
+ /**
45
+ * Defines list commands.
46
+ *
47
+ * @internal
48
+ */
49
+ export function defineListCommands(): ListCommandsExtension {
50
+ return defineCommands({
51
+ dedentList,
52
+ indentList,
53
+ moveList,
54
+ splitList,
55
+ toggleCollapsed,
56
+ unwrapList,
57
+ toggleList,
58
+ wrapInList,
59
+ insertList,
60
+ })
61
+ }
@@ -0,0 +1,37 @@
1
+ import type { PlainExtension } from '@prosekit/core'
2
+
3
+ import type { DragEventHandler } from '../drop-indicator'
4
+ import { defineDropIndicator } from '../drop-indicator'
5
+
6
+ /**
7
+ * Configures drop indicator to avoid unexpected drop point.
8
+ *
9
+ * We don't want to drag a list node and drop it as the first
10
+ * child of another list node.
11
+ *
12
+ * @internal
13
+ */
14
+ export function defineListDropIndicator(): PlainExtension {
15
+ return defineDropIndicator({
16
+ onDrag,
17
+ })
18
+ }
19
+
20
+ const onDrag: DragEventHandler = ({ view, pos }): boolean => {
21
+ const slice = view.dragging?.slice
22
+ if (
23
+ slice
24
+ && slice.openStart === 0
25
+ && slice.openEnd === 0
26
+ && slice.content.childCount === 1
27
+ ) {
28
+ const node = slice.content.child(0)
29
+ if (node.type.name === 'list') {
30
+ const $pos = view.state.doc.resolve(pos)
31
+ if ($pos.parent.type.name === 'list' && $pos.index() === 0) {
32
+ return false
33
+ }
34
+ }
35
+ }
36
+ return true
37
+ }
@@ -0,0 +1,14 @@
1
+ import {
2
+ union,
3
+ type Extension,
4
+ } from '@prosekit/core'
5
+ import { listInputRules } from 'prosemirror-flat-list'
6
+
7
+ import { defineInputRule } from '../input-rule'
8
+
9
+ /**
10
+ * @internal
11
+ */
12
+ export function defineListInputRules(): Extension {
13
+ return union(listInputRules.map(defineInputRule))
14
+ }