@prosekit/extensions 0.11.4 → 0.11.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 (384) 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-E7nCfdnR.js +58 -0
  5. package/dist/drop-indicator-E7nCfdnR.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/file-DVUhe5KJ.js +134 -0
  9. package/dist/file-DVUhe5KJ.js.map +1 -0
  10. package/dist/gap-cursor/style.css +2 -0
  11. package/dist/gap-cursor/style.css.map +1 -0
  12. package/dist/gap-cursor/style.js +1 -0
  13. package/dist/index-DY6lIIYV.d.ts +134 -0
  14. package/dist/index-DY6lIIYV.d.ts.map +1 -0
  15. package/dist/{input-rule-Gji4N7Oe.js → input-rule-B17tpW4m.js} +3 -3
  16. package/dist/input-rule-B17tpW4m.js.map +1 -0
  17. package/dist/list/style.css +2 -0
  18. package/dist/list/style.css.map +1 -0
  19. package/dist/list/style.js +1 -0
  20. package/dist/loro/style.css +2 -0
  21. package/dist/loro/style.css.map +1 -0
  22. package/dist/loro/style.js +1 -0
  23. package/dist/{mark-rule-D7zaa32n.js → mark-rule-CGmswjQ_.js} +3 -3
  24. package/dist/mark-rule-CGmswjQ_.js.map +1 -0
  25. package/dist/{paste-rule-Cca3n5TA.js → paste-rule-BIztzELg.js} +5 -15
  26. package/dist/paste-rule-BIztzELg.js.map +1 -0
  27. package/dist/placeholder/style.css +2 -0
  28. package/dist/placeholder/style.css.map +1 -0
  29. package/dist/placeholder/style.js +1 -0
  30. package/dist/prosekit-extensions-autocomplete.d.ts +2 -1
  31. package/dist/prosekit-extensions-autocomplete.d.ts.map +1 -0
  32. package/dist/prosekit-extensions-autocomplete.js +2 -9
  33. package/dist/prosekit-extensions-autocomplete.js.map +1 -0
  34. package/dist/prosekit-extensions-blockquote.d.ts +2 -1
  35. package/dist/prosekit-extensions-blockquote.d.ts.map +1 -0
  36. package/dist/prosekit-extensions-blockquote.js +4 -4
  37. package/dist/prosekit-extensions-blockquote.js.map +1 -0
  38. package/dist/prosekit-extensions-bold.d.ts +2 -1
  39. package/dist/prosekit-extensions-bold.d.ts.map +1 -0
  40. package/dist/prosekit-extensions-bold.js +3 -2
  41. package/dist/prosekit-extensions-bold.js.map +1 -0
  42. package/dist/prosekit-extensions-code-block.d.ts +3 -2
  43. package/dist/prosekit-extensions-code-block.d.ts.map +1 -0
  44. package/dist/prosekit-extensions-code-block.js +5 -6
  45. package/dist/prosekit-extensions-code-block.js.map +1 -0
  46. package/dist/prosekit-extensions-code.d.ts +2 -1
  47. package/dist/prosekit-extensions-code.d.ts.map +1 -0
  48. package/dist/prosekit-extensions-code.js +3 -2
  49. package/dist/prosekit-extensions-code.js.map +1 -0
  50. package/dist/prosekit-extensions-commit.d.ts +2 -1
  51. package/dist/prosekit-extensions-commit.d.ts.map +1 -0
  52. package/dist/prosekit-extensions-commit.js +11 -13
  53. package/dist/prosekit-extensions-commit.js.map +1 -0
  54. package/dist/prosekit-extensions-doc.d.ts +2 -1
  55. package/dist/prosekit-extensions-doc.d.ts.map +1 -0
  56. package/dist/prosekit-extensions-doc.js +2 -1
  57. package/dist/prosekit-extensions-doc.js.map +1 -0
  58. package/dist/prosekit-extensions-drop-cursor.d.ts +2 -1
  59. package/dist/prosekit-extensions-drop-cursor.d.ts.map +1 -0
  60. package/dist/prosekit-extensions-drop-cursor.js +2 -1
  61. package/dist/prosekit-extensions-drop-cursor.js.map +1 -0
  62. package/dist/prosekit-extensions-drop-indicator.d.ts +5 -107
  63. package/dist/prosekit-extensions-drop-indicator.d.ts.map +1 -0
  64. package/dist/prosekit-extensions-drop-indicator.js +1 -1
  65. package/dist/prosekit-extensions-enter-rule.d.ts +2 -1
  66. package/dist/prosekit-extensions-enter-rule.d.ts.map +1 -0
  67. package/dist/prosekit-extensions-file.d.ts +2 -125
  68. package/dist/prosekit-extensions-file.js +1 -139
  69. package/dist/prosekit-extensions-gap-cursor.d.ts +2 -2
  70. package/dist/prosekit-extensions-gap-cursor.d.ts.map +1 -0
  71. package/dist/prosekit-extensions-gap-cursor.js +2 -1
  72. package/dist/prosekit-extensions-gap-cursor.js.map +1 -0
  73. package/dist/prosekit-extensions-hard-break.d.ts +2 -5
  74. package/dist/prosekit-extensions-hard-break.d.ts.map +1 -0
  75. package/dist/prosekit-extensions-hard-break.js +2 -1
  76. package/dist/prosekit-extensions-hard-break.js.map +1 -0
  77. package/dist/prosekit-extensions-heading.d.ts +2 -1
  78. package/dist/prosekit-extensions-heading.d.ts.map +1 -0
  79. package/dist/prosekit-extensions-heading.js +5 -6
  80. package/dist/prosekit-extensions-heading.js.map +1 -0
  81. package/dist/prosekit-extensions-horizontal-rule.d.ts +2 -1
  82. package/dist/prosekit-extensions-horizontal-rule.d.ts.map +1 -0
  83. package/dist/prosekit-extensions-horizontal-rule.js +5 -6
  84. package/dist/prosekit-extensions-horizontal-rule.js.map +1 -0
  85. package/dist/prosekit-extensions-image.d.ts +80 -3
  86. package/dist/prosekit-extensions-image.d.ts.map +1 -0
  87. package/dist/prosekit-extensions-image.js +90 -10
  88. package/dist/prosekit-extensions-image.js.map +1 -0
  89. package/dist/prosekit-extensions-input-rule.d.ts +2 -1
  90. package/dist/prosekit-extensions-input-rule.d.ts.map +1 -0
  91. package/dist/prosekit-extensions-input-rule.js +1 -1
  92. package/dist/prosekit-extensions-italic.d.ts +2 -1
  93. package/dist/prosekit-extensions-italic.d.ts.map +1 -0
  94. package/dist/prosekit-extensions-italic.js +3 -2
  95. package/dist/prosekit-extensions-italic.js.map +1 -0
  96. package/dist/prosekit-extensions-link.d.ts +2 -1
  97. package/dist/prosekit-extensions-link.d.ts.map +1 -0
  98. package/dist/prosekit-extensions-link.js +6 -5
  99. package/dist/prosekit-extensions-link.js.map +1 -0
  100. package/dist/prosekit-extensions-list.d.ts +22 -21
  101. package/dist/prosekit-extensions-list.d.ts.map +1 -0
  102. package/dist/prosekit-extensions-list.js +7 -8
  103. package/dist/prosekit-extensions-list.js.map +1 -0
  104. package/dist/prosekit-extensions-loro.d.ts +14 -13
  105. package/dist/prosekit-extensions-loro.d.ts.map +1 -0
  106. package/dist/prosekit-extensions-loro.js +2 -1
  107. package/dist/prosekit-extensions-loro.js.map +1 -0
  108. package/dist/prosekit-extensions-mark-rule.d.ts +2 -1
  109. package/dist/prosekit-extensions-mark-rule.d.ts.map +1 -0
  110. package/dist/prosekit-extensions-mark-rule.js +1 -1
  111. package/dist/prosekit-extensions-mention.d.ts +2 -1
  112. package/dist/prosekit-extensions-mention.d.ts.map +1 -0
  113. package/dist/prosekit-extensions-mention.js +2 -1
  114. package/dist/prosekit-extensions-mention.js.map +1 -0
  115. package/dist/prosekit-extensions-mod-click-prevention.d.ts +2 -1
  116. package/dist/prosekit-extensions-mod-click-prevention.d.ts.map +1 -0
  117. package/dist/prosekit-extensions-mod-click-prevention.js +2 -1
  118. package/dist/prosekit-extensions-mod-click-prevention.js.map +1 -0
  119. package/dist/prosekit-extensions-paragraph.d.ts +2 -5
  120. package/dist/prosekit-extensions-paragraph.d.ts.map +1 -0
  121. package/dist/prosekit-extensions-paragraph.js +2 -1
  122. package/dist/prosekit-extensions-paragraph.js.map +1 -0
  123. package/dist/prosekit-extensions-paste-rule.d.ts +2 -1
  124. package/dist/prosekit-extensions-paste-rule.d.ts.map +1 -0
  125. package/dist/prosekit-extensions-paste-rule.js +1 -1
  126. package/dist/prosekit-extensions-placeholder.d.ts +2 -1
  127. package/dist/prosekit-extensions-placeholder.d.ts.map +1 -0
  128. package/dist/prosekit-extensions-placeholder.js +5 -5
  129. package/dist/prosekit-extensions-placeholder.js.map +1 -0
  130. package/dist/prosekit-extensions-readonly.d.ts +2 -1
  131. package/dist/prosekit-extensions-readonly.d.ts.map +1 -0
  132. package/dist/prosekit-extensions-readonly.js +2 -1
  133. package/dist/prosekit-extensions-readonly.js.map +1 -0
  134. package/dist/prosekit-extensions-search.d.ts +2 -1
  135. package/dist/prosekit-extensions-search.d.ts.map +1 -0
  136. package/dist/prosekit-extensions-search.js +3 -3
  137. package/dist/prosekit-extensions-search.js.map +1 -0
  138. package/dist/prosekit-extensions-strike.d.ts +2 -1
  139. package/dist/prosekit-extensions-strike.d.ts.map +1 -0
  140. package/dist/prosekit-extensions-strike.js +3 -2
  141. package/dist/prosekit-extensions-strike.js.map +1 -0
  142. package/dist/prosekit-extensions-table.d.ts +47 -114
  143. package/dist/prosekit-extensions-table.d.ts.map +1 -0
  144. package/dist/prosekit-extensions-table.js +2 -2
  145. package/dist/prosekit-extensions-text-align.d.ts +2 -1
  146. package/dist/prosekit-extensions-text-align.d.ts.map +1 -0
  147. package/dist/prosekit-extensions-text-align.js +2 -1
  148. package/dist/prosekit-extensions-text-align.js.map +1 -0
  149. package/dist/prosekit-extensions-text.d.ts +2 -1
  150. package/dist/prosekit-extensions-text.d.ts.map +1 -0
  151. package/dist/prosekit-extensions-text.js +2 -1
  152. package/dist/prosekit-extensions-text.js.map +1 -0
  153. package/dist/prosekit-extensions-underline.d.ts +2 -1
  154. package/dist/prosekit-extensions-underline.d.ts.map +1 -0
  155. package/dist/prosekit-extensions-underline.js +2 -1
  156. package/dist/prosekit-extensions-underline.js.map +1 -0
  157. package/dist/prosekit-extensions-virtual-selection.d.ts +2 -1
  158. package/dist/prosekit-extensions-virtual-selection.d.ts.map +1 -0
  159. package/dist/prosekit-extensions-virtual-selection.js +3 -3
  160. package/dist/prosekit-extensions-virtual-selection.js.map +1 -0
  161. package/dist/prosekit-extensions-yjs.d.ts +2 -1
  162. package/dist/prosekit-extensions-yjs.d.ts.map +1 -0
  163. package/dist/prosekit-extensions-yjs.js +2 -1
  164. package/dist/prosekit-extensions-yjs.js.map +1 -0
  165. package/dist/prosekit-extensions.js +1 -0
  166. package/dist/search/style.css +2 -0
  167. package/dist/search/style.css.map +1 -0
  168. package/dist/search/style.js +1 -0
  169. package/dist/{shiki-highlighter-chunk-DSPM0T27.d.ts → shiki-highlighter-chunk-Cwu1Jr9o.d.ts} +2 -1
  170. package/dist/shiki-highlighter-chunk-Cwu1Jr9o.d.ts.map +1 -0
  171. package/dist/shiki-highlighter-chunk.d.ts +1 -1
  172. package/dist/shiki-highlighter-chunk.js +3 -5
  173. package/dist/shiki-highlighter-chunk.js.map +1 -0
  174. package/dist/table/style.css +2 -0
  175. package/dist/table/style.css.map +1 -0
  176. package/dist/table/style.js +1 -0
  177. package/dist/table-BNwuK7xg.js +297 -0
  178. package/dist/table-BNwuK7xg.js.map +1 -0
  179. package/dist/virtual-selection/style.css +2 -0
  180. package/dist/virtual-selection/style.css.map +1 -0
  181. package/dist/virtual-selection/style.js +1 -0
  182. package/dist/yjs/style.css +2 -0
  183. package/dist/yjs/style.css.map +1 -0
  184. package/dist/yjs/style.js +1 -0
  185. package/package.json +12 -10
  186. package/src/autocomplete/autocomplete-helpers.ts +74 -0
  187. package/src/autocomplete/autocomplete-plugin.ts +186 -0
  188. package/src/autocomplete/autocomplete-rule.ts +117 -0
  189. package/src/autocomplete/autocomplete.spec.ts +132 -0
  190. package/src/autocomplete/autocomplete.ts +29 -0
  191. package/src/autocomplete/index.ts +9 -0
  192. package/src/blockquote/blockquote-commands.ts +32 -0
  193. package/src/blockquote/blockquote-input-rule.ts +14 -0
  194. package/src/blockquote/blockquote-keymap.spec.ts +45 -0
  195. package/src/blockquote/blockquote-keymap.ts +31 -0
  196. package/src/blockquote/blockquote-spec.ts +24 -0
  197. package/src/blockquote/blockquote.ts +34 -0
  198. package/src/blockquote/index.ts +14 -0
  199. package/src/bold/bold-commands.ts +23 -0
  200. package/src/bold/bold-input-rule.spec.ts +51 -0
  201. package/src/bold/bold-input-rule.ts +18 -0
  202. package/src/bold/bold-keymap.ts +14 -0
  203. package/src/bold/bold-spec.ts +53 -0
  204. package/src/bold/bold.ts +32 -0
  205. package/src/bold/index.ts +14 -0
  206. package/src/code/code-commands.ts +23 -0
  207. package/src/code/code-input-rule.ts +18 -0
  208. package/src/code/code-keymap.ts +14 -0
  209. package/src/code/code-spec.ts +28 -0
  210. package/src/code/code.ts +32 -0
  211. package/src/code/index.ts +14 -0
  212. package/src/code-block/code-block-commands.ts +44 -0
  213. package/src/code-block/code-block-highlight.ts +40 -0
  214. package/src/code-block/code-block-input-rule.ts +36 -0
  215. package/src/code-block/code-block-keymap.ts +61 -0
  216. package/src/code-block/code-block-shiki.ts +58 -0
  217. package/src/code-block/code-block-spec.spec.ts +164 -0
  218. package/src/code-block/code-block-spec.ts +71 -0
  219. package/src/code-block/code-block-types.ts +8 -0
  220. package/src/code-block/code-block.ts +46 -0
  221. package/src/code-block/index.ts +32 -0
  222. package/src/code-block/shiki-bundle.ts +8 -0
  223. package/src/code-block/shiki-highlighter-chunk.ts +84 -0
  224. package/src/code-block/shiki-highlighter.ts +22 -0
  225. package/src/code-block/shiki-parser.ts +36 -0
  226. package/src/commit/index.ts +330 -0
  227. package/src/commit/style.css +7 -0
  228. package/src/doc/index.ts +21 -0
  229. package/src/drop-cursor/drop-cursor.ts +46 -0
  230. package/src/drop-cursor/index.ts +5 -0
  231. package/src/drop-indicator/drop-indicator-facet.ts +62 -0
  232. package/src/drop-indicator/drop-indicator.ts +35 -0
  233. package/src/drop-indicator/index.ts +14 -0
  234. package/src/enter-rule/index.ts +241 -0
  235. package/src/file/file-drop-handler.ts +75 -0
  236. package/src/file/file-paste-handler.spec.ts +95 -0
  237. package/src/file/file-paste-handler.ts +59 -0
  238. package/src/file/file-upload.ts +140 -0
  239. package/src/file/helpers.ts +39 -0
  240. package/src/file/index.ts +16 -0
  241. package/src/gap-cursor/gap-cursor.ts +28 -0
  242. package/src/gap-cursor/index.ts +4 -0
  243. package/src/gap-cursor/style.css +25 -0
  244. package/src/hard-break/hard-break-commands.ts +31 -0
  245. package/src/hard-break/hard-break-keymap.spec.ts +45 -0
  246. package/src/hard-break/hard-break-keymap.ts +16 -0
  247. package/src/hard-break/hard-break-spec.ts +31 -0
  248. package/src/hard-break/hard-break.ts +32 -0
  249. package/src/hard-break/index.ts +13 -0
  250. package/src/heading/heading-commands.ts +37 -0
  251. package/src/heading/heading-input-rule.ts +22 -0
  252. package/src/heading/heading-keymap.spec.ts +53 -0
  253. package/src/heading/heading-keymap.ts +40 -0
  254. package/src/heading/heading-spec.ts +39 -0
  255. package/src/heading/heading-types.ts +3 -0
  256. package/src/heading/heading.ts +34 -0
  257. package/src/heading/index.ts +15 -0
  258. package/src/horizontal-rule/horizontal-rule-commands.spec.ts +61 -0
  259. package/src/horizontal-rule/horizontal-rule-commands.ts +37 -0
  260. package/src/horizontal-rule/horizontal-rule-input-rule.spec.ts +61 -0
  261. package/src/horizontal-rule/horizontal-rule-input-rule.ts +26 -0
  262. package/src/horizontal-rule/horizontal-rule-spec.ts +21 -0
  263. package/src/horizontal-rule/horizontal-rule.ts +29 -0
  264. package/src/horizontal-rule/index.ts +14 -0
  265. package/src/image/image-commands.ts +36 -0
  266. package/src/image/image-spec.ts +72 -0
  267. package/src/image/image-upload-handler.ts +156 -0
  268. package/src/image/image.ts +25 -0
  269. package/src/image/index.ts +22 -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/drop-indicator-dB9rZn8e.js +0 -267
  384. package/dist/table-CPI9ZxbK.js +0 -760
@@ -0,0 +1,128 @@
1
+ :root {
2
+ --prosekit-list-bullet-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='2.5' fill='currentColor'/%3E%3C/svg%3E");
3
+ --prosekit-list-toggle-open-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpolygon points='8,10 12,14 16,10' fill='currentColor'/%3E%3C/svg%3E");
4
+ --prosekit-list-toggle-closed-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpolygon points='10,8 14,12 10,16' fill='currentColor'/%3E%3C/svg%3E");
5
+ }
6
+
7
+ .prosemirror-flat-list {
8
+ & {
9
+ position: relative;
10
+ margin: 0;
11
+ padding: 0;
12
+ list-style: none;
13
+ }
14
+
15
+ & > .list-marker {
16
+ position: absolute;
17
+ left: 0;
18
+ width: 1.5em;
19
+ width: 1lh;
20
+ height: 1.5em;
21
+ height: 1lh;
22
+ text-align: center;
23
+ }
24
+
25
+ & > .list-content {
26
+ margin-left: 1.5em;
27
+ margin-left: 1lh;
28
+ }
29
+
30
+ &[data-list-kind="bullet"] > .list-marker,
31
+ &[data-list-kind="toggle"] > .list-marker {
32
+ background-color: currentColor;
33
+ mask-position: center;
34
+ mask-repeat: no-repeat;
35
+ mask-size: contain;
36
+ }
37
+
38
+ &[data-list-kind="bullet"] {
39
+ & > .list-marker {
40
+ mask-image: var(--prosekit-list-bullet-icon);
41
+ }
42
+ }
43
+
44
+ &[data-list-kind="toggle"] {
45
+ & > .list-marker {
46
+ mask-image: var(--prosekit-list-toggle-open-icon);
47
+ }
48
+
49
+ &[data-list-collapsable][data-list-collapsed] > .list-marker {
50
+ mask-image: var(--prosekit-list-toggle-closed-icon);
51
+ }
52
+ }
53
+
54
+ &[data-list-kind="ordered"] {
55
+ /*
56
+ Ensure that the counters in children don't escape, so that the sub lists
57
+ won't affect the counter of the parent list.
58
+
59
+ See also https://github.com/ocavue/prosemirror-flat-list/issues/23
60
+ */
61
+ & > * {
62
+ contain: style;
63
+ }
64
+
65
+ &::before {
66
+ position: absolute;
67
+ right: calc(100% - 1.5em);
68
+ right: calc(100% - 1lh);
69
+ content: counter(prosemirror-flat-list-counter, decimal) ". ";
70
+ font-variant-numeric: tabular-nums;
71
+ }
72
+ counter-increment: prosemirror-flat-list-counter;
73
+
74
+ /*
75
+ Reset the counter for the first list node in the sequence.
76
+ */
77
+ &:first-child,
78
+ :not(&) + & {
79
+ counter-reset: prosemirror-flat-list-counter;
80
+
81
+ /*
82
+ If the first list node has a custom order number, set the counter to that value.
83
+ */
84
+ &[data-list-order] {
85
+ @supports (counter-set: prosemirror-flat-list-counter 1) {
86
+ counter-set: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
87
+ }
88
+
89
+ /*
90
+ Safari older than version 17.2 doesn't support `counter-set`
91
+ */
92
+ @supports not (counter-set: prosemirror-flat-list-counter 1) {
93
+ counter-increment: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
94
+ }
95
+ }
96
+ }
97
+ }
98
+
99
+ &[data-list-kind="task"] {
100
+ & > .list-marker {
101
+ &,
102
+ & * {
103
+ /* Make sure that the checkbox is at the center */
104
+ display: flex;
105
+ align-items: center;
106
+ justify-content: center;
107
+ margin: 0;
108
+ padding: 0;
109
+ cursor: pointer;
110
+ }
111
+ }
112
+ }
113
+
114
+ &[data-list-kind="toggle"] {
115
+ &[data-list-collapsable] > .list-marker {
116
+ cursor: pointer;
117
+ }
118
+ &:not([data-list-collapsable]) > .list-marker {
119
+ opacity: 40%;
120
+ pointer-events: none;
121
+ }
122
+
123
+ /* If collapsed, hide the second and futher children */
124
+ &[data-list-collapsable][data-list-collapsed] > .list-content > *:nth-child(n+2) {
125
+ display: none;
126
+ }
127
+ }
128
+ }
@@ -0,0 +1,17 @@
1
+ export type {
2
+ LoroSyncPluginProps,
3
+ LoroUndoPluginProps,
4
+ } from 'loro-prosemirror'
5
+ export {
6
+ defineLoro,
7
+ type LoroExtension,
8
+ type LoroOptions,
9
+ } from './loro'
10
+ export { defineLoroCommands } from './loro-commands'
11
+ export {
12
+ defineLoroCursorPlugin,
13
+ type LoroCursorOptions,
14
+ } from './loro-cursor-plugin'
15
+ export { defineLoroKeymap } from './loro-keymap'
16
+ export { defineLoroSyncPlugin } from './loro-sync-plugin'
17
+ export { defineLoroUndoPlugin } from './loro-undo-plugin'
@@ -0,0 +1,27 @@
1
+ import {
2
+ defineCommands,
3
+ type Extension,
4
+ } from '@prosekit/core'
5
+ import {
6
+ redo,
7
+ undo,
8
+ } from 'loro-prosemirror'
9
+
10
+ const commands = {
11
+ undo: () => undo,
12
+ redo: () => redo,
13
+ } as const
14
+
15
+ /**
16
+ * @internal
17
+ */
18
+ export type LoroCommandsExtension = Extension<{
19
+ Commands: {
20
+ undo: []
21
+ redo: []
22
+ }
23
+ }>
24
+
25
+ export function defineLoroCommands(): LoroCommandsExtension {
26
+ return defineCommands(commands)
27
+ }
@@ -0,0 +1,28 @@
1
+ import {
2
+ definePlugin,
3
+ type PlainExtension,
4
+ } from '@prosekit/core'
5
+ import type {
6
+ EditorState,
7
+ Selection,
8
+ } from '@prosekit/pm/state'
9
+ import type { DecorationAttrs } from '@prosekit/pm/view'
10
+ import type { PeerID } from 'loro-crdt'
11
+ import {
12
+ LoroCursorPlugin,
13
+ type CursorAwareness,
14
+ } from 'loro-prosemirror'
15
+
16
+ export interface LoroCursorOptions {
17
+ awareness: CursorAwareness
18
+ getSelection?: (state: EditorState) => Selection
19
+ createCursor?: (user: PeerID) => Element
20
+ createSelection?: (user: PeerID) => DecorationAttrs
21
+ }
22
+
23
+ export function defineLoroCursorPlugin(
24
+ options: LoroCursorOptions,
25
+ ): PlainExtension {
26
+ const { awareness, ...rest } = options
27
+ return definePlugin(LoroCursorPlugin(awareness, rest))
28
+ }
@@ -0,0 +1,23 @@
1
+ import {
2
+ defineKeymap,
3
+ isApple,
4
+ type Keymap,
5
+ type PlainExtension,
6
+ } from '@prosekit/core'
7
+ import {
8
+ redo,
9
+ undo,
10
+ } from 'loro-prosemirror'
11
+
12
+ const keymap: Keymap = {
13
+ 'Mod-z': undo,
14
+ 'Shift-Mod-z': redo,
15
+ }
16
+
17
+ if (!isApple) {
18
+ keymap['Mod-y'] = redo
19
+ }
20
+
21
+ export function defineLoroKeymap(): PlainExtension {
22
+ return defineKeymap(keymap)
23
+ }
@@ -0,0 +1,14 @@
1
+ import {
2
+ definePlugin,
3
+ type PlainExtension,
4
+ } from '@prosekit/core'
5
+ import {
6
+ LoroSyncPlugin,
7
+ type LoroSyncPluginProps,
8
+ } from 'loro-prosemirror'
9
+
10
+ export function defineLoroSyncPlugin(
11
+ options: LoroSyncPluginProps,
12
+ ): PlainExtension {
13
+ return definePlugin(LoroSyncPlugin(options))
14
+ }
@@ -0,0 +1,12 @@
1
+ import {
2
+ definePlugin,
3
+ type PlainExtension,
4
+ } from '@prosekit/core'
5
+ import {
6
+ LoroUndoPlugin,
7
+ type LoroUndoPluginProps,
8
+ } from 'loro-prosemirror'
9
+
10
+ export function defineLoroUndoPlugin(options: LoroUndoPluginProps): PlainExtension {
11
+ return definePlugin(LoroUndoPlugin(options))
12
+ }
@@ -0,0 +1,75 @@
1
+ import {
2
+ Priority,
3
+ union,
4
+ withPriority,
5
+ type PlainExtension,
6
+ type Union,
7
+ } from '@prosekit/core'
8
+ import type {
9
+ CursorAwareness,
10
+ LoroDocType,
11
+ LoroSyncPluginProps,
12
+ LoroUndoPluginProps,
13
+ } from 'loro-prosemirror'
14
+
15
+ import {
16
+ defineLoroCommands,
17
+ type LoroCommandsExtension,
18
+ } from './loro-commands'
19
+ import {
20
+ defineLoroCursorPlugin,
21
+ type LoroCursorOptions,
22
+ } from './loro-cursor-plugin'
23
+ import { defineLoroKeymap } from './loro-keymap'
24
+ import { defineLoroSyncPlugin } from './loro-sync-plugin'
25
+ import { defineLoroUndoPlugin } from './loro-undo-plugin'
26
+
27
+ export interface LoroOptions {
28
+ /**
29
+ * The Loro instance handles the state of shared data.
30
+ */
31
+ doc: LoroDocType
32
+
33
+ /**
34
+ * The Awareness instance.
35
+ */
36
+ awareness: CursorAwareness
37
+
38
+ /**
39
+ * Extra options for `LoroSyncPlugin`.
40
+ */
41
+ sync?: Omit<LoroSyncPluginProps, 'doc'>
42
+
43
+ /**
44
+ * Extra options for the `LoroUndoPlugin`.
45
+ */
46
+ undo?: Omit<LoroUndoPluginProps, 'doc'>
47
+
48
+ /**
49
+ * Extra options for `LoroCursorPlugin`.
50
+ */
51
+ cursor?: Omit<LoroCursorOptions, 'awareness'>
52
+ }
53
+
54
+ /**
55
+ * @internal
56
+ */
57
+ export type LoroExtension = Union<[LoroCommandsExtension, PlainExtension]>
58
+
59
+ /**
60
+ * @public
61
+ */
62
+ export function defineLoro(options: LoroOptions): LoroExtension {
63
+ const { doc, awareness, sync, undo, cursor } = options
64
+
65
+ return withPriority(
66
+ union([
67
+ defineLoroKeymap(),
68
+ defineLoroCommands(),
69
+ defineLoroCursorPlugin({ ...cursor, awareness }),
70
+ defineLoroUndoPlugin({ ...undo, doc }),
71
+ defineLoroSyncPlugin({ ...sync, doc }),
72
+ ]),
73
+ Priority.high,
74
+ )
75
+ }
@@ -0,0 +1,33 @@
1
+ .ProseMirror-loro-cursor:first-child {
2
+ margin-top: 16px;
3
+ }
4
+
5
+ /* This gives the remote user caret. The colors are automatically overwritten */
6
+ .ProseMirror-loro-cursor {
7
+ position: relative;
8
+ margin-right: -1px;
9
+ margin-left: -1px;
10
+ border-right: 1px solid black;
11
+ border-left: 1px solid black;
12
+ border-color: orange;
13
+ word-break: normal;
14
+ pointer-events: none;
15
+ }
16
+
17
+ /* This renders the username above the caret */
18
+ .ProseMirror-loro-cursor > div {
19
+ position: absolute;
20
+ top: -1.05em;
21
+ left: -1px;
22
+ padding-right: 2px;
23
+ padding-left: 2px;
24
+ background-color: rgb(250, 129, 0);
25
+ color: white;
26
+ font-style: normal;
27
+ font-weight: normal;
28
+ font-size: 13px;
29
+ line-height: normal;
30
+ font-family: serif;
31
+ white-space: nowrap;
32
+ user-select: none;
33
+ }
@@ -0,0 +1,129 @@
1
+ import {
2
+ getMarkType,
3
+ maybeRun,
4
+ OBJECT_REPLACEMENT_CHARACTER,
5
+ } from '@prosekit/core'
6
+ import type {
7
+ Mark,
8
+ ProseMirrorNode,
9
+ } from '@prosekit/pm/model'
10
+ import type {
11
+ EditorState,
12
+ Transaction,
13
+ } from '@prosekit/pm/state'
14
+
15
+ import { getCheckRanges } from './range'
16
+ import type { MarkRuleOptions } from './types'
17
+
18
+ type MarkRange = [from: number, to: number, mark: Mark]
19
+
20
+ function getExpectedMarkings(
21
+ rules: MarkRuleOptions[],
22
+ doc: ProseMirrorNode,
23
+ from: number,
24
+ to: number,
25
+ ): MarkRange[] {
26
+ const text = doc.textBetween(from, to, null, OBJECT_REPLACEMENT_CHARACTER)
27
+ const ranges: MarkRange[] = []
28
+
29
+ for (const rule of rules) {
30
+ rule.regex.lastIndex = 0
31
+ const matches = text.matchAll(rule.regex)
32
+ const markType = getMarkType(doc.type.schema, rule.type)
33
+
34
+ for (const match of matches) {
35
+ const index = match.index
36
+ if (index == null) continue
37
+ const attrs = maybeRun(rule.attrs, match)
38
+ const mark = markType.create(attrs)
39
+ ranges.push([from + index, from + index + match[0].length, mark])
40
+ }
41
+ }
42
+
43
+ // Sort by start position. If start positions are equal, the longer match
44
+ // should be prioritized.
45
+ ranges.sort((a, b) => a[0] - b[0] || b[1] - a[1])
46
+
47
+ // Remove overlapped marks.
48
+ const result: MarkRange[] = []
49
+ let freeIndex = 0
50
+
51
+ for (const range of ranges) {
52
+ if (range[0] >= freeIndex) {
53
+ result.push(range)
54
+ freeIndex = range[1]
55
+ }
56
+ }
57
+
58
+ return result
59
+ }
60
+
61
+ function getReceivedMarkings(
62
+ rules: MarkRuleOptions[],
63
+ doc: ProseMirrorNode,
64
+ from: number,
65
+ to: number,
66
+ ): MarkRange[] {
67
+ const result: MarkRange[] = []
68
+ const schema = doc.type.schema
69
+ const markTypes = rules.map((rule) => getMarkType(schema, rule.type))
70
+
71
+ doc.nodesBetween(from, to, (node, pos) => {
72
+ if (!node.isInline) {
73
+ return
74
+ }
75
+
76
+ for (const markType of markTypes) {
77
+ const mark = node.marks.find((mark) => mark.type === markType)
78
+ if (mark) {
79
+ result.push([pos, pos + node.nodeSize, mark])
80
+ }
81
+ }
82
+ })
83
+ return result
84
+ }
85
+
86
+ function markRangeEquals(a: MarkRange, b: MarkRange): boolean {
87
+ return a[0] === b[0] && a[1] === b[1] && a[2].eq(b[2])
88
+ }
89
+
90
+ function markRangeDiffs(a: MarkRange[], b: MarkRange[]): MarkRange[] {
91
+ return a.filter((x) => !b.some((y) => markRangeEquals(x, y)))
92
+ }
93
+
94
+ export function applyMarkRules(
95
+ rules: MarkRuleOptions[],
96
+ transactions: readonly Transaction[],
97
+ oldState: EditorState,
98
+ newState: EditorState,
99
+ ): Transaction | null {
100
+ if (transactions.length === 0 || transactions.every((tr) => !tr.docChanged)) {
101
+ return null
102
+ }
103
+
104
+ const ranges = getCheckRanges(transactions, oldState, newState)
105
+
106
+ const toRemove: MarkRange[] = []
107
+ const toCreate: MarkRange[] = []
108
+
109
+ for (const [from, to] of ranges) {
110
+ const expected = getExpectedMarkings(rules, newState.doc, from, to)
111
+ const received = getReceivedMarkings(rules, newState.doc, from, to)
112
+
113
+ toRemove.push(...markRangeDiffs(received, expected))
114
+ toCreate.push(...markRangeDiffs(expected, received))
115
+ }
116
+
117
+ if (toCreate.length === 0 && toRemove.length === 0) {
118
+ return null
119
+ }
120
+
121
+ const tr = newState.tr
122
+ for (const [from, to, mark] of toRemove) {
123
+ tr.removeMark(from, to, mark)
124
+ }
125
+ for (const [from, to, mark] of toCreate) {
126
+ tr.addMark(from, to, mark)
127
+ }
128
+ return tr
129
+ }
@@ -0,0 +1,2 @@
1
+ export { defineMarkRule } from './mark-rule'
2
+ export type { MarkRuleOptions } from './types'
@@ -0,0 +1,123 @@
1
+ import {
2
+ createEditor,
3
+ defineBaseCommands,
4
+ defineMarkSpec,
5
+ elementFromNode,
6
+ union,
7
+ type Editor,
8
+ } from '@prosekit/core'
9
+ import type { ProseMirrorNode } from '@prosekit/pm/model'
10
+ import {
11
+ describe,
12
+ expect,
13
+ it,
14
+ } from 'vitest'
15
+
16
+ import { defineDoc } from '../doc'
17
+ import { defineParagraph } from '../paragraph'
18
+ import { defineText } from '../text'
19
+
20
+ import { defineMarkRule } from './index'
21
+
22
+ describe('defineMarkRule', () => {
23
+ const editor = createEditor({
24
+ extension: union(
25
+ defineDoc(),
26
+ defineText(),
27
+ defineParagraph(),
28
+ defineBaseCommands(),
29
+ defineMarkSpec({
30
+ name: 'tag' as const,
31
+ toDOM: () => {
32
+ return ['mark-tag', 0]
33
+ },
34
+ }),
35
+ defineMarkRule({
36
+ regex: /#\d+/g,
37
+ type: 'tag',
38
+ }),
39
+ defineMarkSpec({
40
+ name: 'link' as const,
41
+ toDOM: () => {
42
+ return ['mark-link', 0]
43
+ },
44
+ }),
45
+ defineMarkRule({
46
+ regex: /example\.com(#\d+)?/g,
47
+ type: 'link',
48
+ }),
49
+ defineMarkSpec({
50
+ name: 'email' as const,
51
+ toDOM: () => {
52
+ return ['mark-email', 0]
53
+ },
54
+ }),
55
+ defineMarkRule({
56
+ regex: /[a-z]+@example\.com/g,
57
+ type: 'email',
58
+ }),
59
+ ),
60
+ })
61
+
62
+ const triggerMarkRule = (doc: ProseMirrorNode): string => {
63
+ setDoc(editor, doc)
64
+ editor.commands.insertText({ from: 1, text: ' ' })
65
+ return elementFromNode(editor.state.doc).innerHTML
66
+ }
67
+
68
+ const n = { ...editor.nodes, p: editor.nodes.paragraph }
69
+
70
+ it('can match tag', () => {
71
+ const doc = n.doc(n.p('#12345'))
72
+ const html = triggerMarkRule(doc)
73
+
74
+ expect(html).toMatchInlineSnapshot(`"<p> <mark-tag>#12345</mark-tag></p>"`)
75
+ })
76
+
77
+ it('can match link', () => {
78
+ const doc = n.doc(n.p('example.com'))
79
+ const html = triggerMarkRule(doc)
80
+
81
+ expect(html).toMatchInlineSnapshot(
82
+ `"<p> <mark-link>example.com</mark-link></p>"`,
83
+ )
84
+ })
85
+
86
+ it('can match link with anchor', () => {
87
+ const doc = n.doc(n.p('example.com#12345'))
88
+ const html = triggerMarkRule(doc)
89
+
90
+ expect(html).toMatchInlineSnapshot(
91
+ `"<p> <mark-link>example.com#12345</mark-link></p>"`,
92
+ )
93
+ })
94
+
95
+ it('can match email', () => {
96
+ const doc = n.doc(n.p('hello@example.com'))
97
+ const html = triggerMarkRule(doc)
98
+
99
+ expect(html).toMatchInlineSnapshot(
100
+ `"<p> <mark-email>hello@example.com</mark-email></p>"`,
101
+ )
102
+ })
103
+
104
+ it('can match email and tag', () => {
105
+ const doc = n.doc(n.p('hello@example.com#12345'))
106
+ const html = triggerMarkRule(doc)
107
+
108
+ expect(html).toMatchInlineSnapshot(
109
+ `"<p> <mark-email>hello@example.com</mark-email><mark-tag>#12345</mark-tag></p>"`,
110
+ )
111
+ })
112
+ })
113
+
114
+ function setDoc(editor: Editor, doc: ProseMirrorNode) {
115
+ if (!editor.mounted) {
116
+ const div = document.createElement('div')
117
+ editor.mount(div)
118
+ }
119
+
120
+ const tr = editor.state.tr
121
+ tr.replaceWith(0, tr.doc.content.size, doc.content)
122
+ editor.view.dispatch(tr)
123
+ }
@@ -0,0 +1,48 @@
1
+ import {
2
+ defineFacet,
3
+ defineFacetPayload,
4
+ pluginFacet,
5
+ type PlainExtension,
6
+ type PluginPayload,
7
+ } from '@prosekit/core'
8
+ import {
9
+ PluginKey,
10
+ ProseMirrorPlugin,
11
+ type EditorState,
12
+ type Transaction,
13
+ } from '@prosekit/pm/state'
14
+
15
+ import { applyMarkRules } from './apply'
16
+ import type { MarkRuleOptions } from './types'
17
+
18
+ /**
19
+ * A mark rule is something that can automatically apply marks to text if it
20
+ * matches a certain pattern, and remove them if it doesn't match anymore.
21
+ */
22
+ export function defineMarkRule(options: MarkRuleOptions): PlainExtension {
23
+ return defineFacetPayload(markRuleFacet, [options]) as PlainExtension
24
+ }
25
+
26
+ const markRuleFacet = defineFacet<MarkRuleOptions, PluginPayload>({
27
+ reduce: () => {
28
+ let rules: MarkRuleOptions[] = []
29
+
30
+ const plugin = new ProseMirrorPlugin({
31
+ key: new PluginKey('prosekit-mark-rule'),
32
+ appendTransaction: (
33
+ transactions: readonly Transaction[],
34
+ oldState: EditorState,
35
+ newState: EditorState,
36
+ ) => {
37
+ return applyMarkRules(rules, transactions, oldState, newState)
38
+ },
39
+ })
40
+
41
+ return function reducer(input) {
42
+ rules = input
43
+ return plugin
44
+ }
45
+ },
46
+
47
+ parent: pluginFacet,
48
+ })