@milkdown/crepe 7.4.0 → 7.5.0

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 (430) hide show
  1. package/lib/cjs/{_view-TbSIR42F.js → _view-N32ied53.js} +2 -2
  2. package/lib/cjs/{_view-TbSIR42F.js.map → _view-N32ied53.js.map} +1 -1
  3. package/lib/cjs/clsx-dASsG01A.js +6 -0
  4. package/lib/cjs/clsx-dASsG01A.js.map +1 -0
  5. package/lib/cjs/{composed-offset-position.browser.min-FwypoGc1.js → floating-ui.dom-2cjBpir5.js} +14 -18
  6. package/lib/cjs/floating-ui.dom-2cjBpir5.js.map +1 -0
  7. package/lib/cjs/helper-1aludV1Z.js +15 -0
  8. package/lib/cjs/helper-1aludV1Z.js.map +1 -0
  9. package/lib/cjs/{index-tbEq3xma.js → index--sa4NMpW.js} +15 -14
  10. package/lib/cjs/{index-tbEq3xma.js.map → index--sa4NMpW.js.map} +1 -1
  11. package/lib/cjs/{index-5PcT4iSf.js → index--tnUmqZ_.js} +18 -17
  12. package/lib/cjs/{index-5PcT4iSf.js.map → index--tnUmqZ_.js.map} +1 -1
  13. package/lib/cjs/{index-i0_v2uVp.js → index-1vHyMXH8.js} +15 -14
  14. package/lib/{esm/index-4QzlLVWs.js.map → cjs/index-1vHyMXH8.js.map} +1 -1
  15. package/lib/cjs/index-28q261C7.js +448 -0
  16. package/lib/cjs/index-28q261C7.js.map +1 -0
  17. package/lib/cjs/{index-mJ47ZWO2.js → index-55VIM-52.js} +18 -17
  18. package/lib/{esm/index-Grquo08f.js.map → cjs/index-55VIM-52.js.map} +1 -1
  19. package/lib/cjs/{index-lrFGGa_l.js → index-92bwto5V.js} +15 -14
  20. package/lib/cjs/{index-lrFGGa_l.js.map → index-92bwto5V.js.map} +1 -1
  21. package/lib/cjs/{index-2oxl5Zo4.js → index-Buu2tD9O.js} +45 -62
  22. package/lib/cjs/index-Buu2tD9O.js.map +1 -0
  23. package/lib/cjs/{index-OA_u95ey.js → index-E4Ist86Z.js} +15 -14
  24. package/lib/{esm/index-7BVeXLQZ.js.map → cjs/index-E4Ist86Z.js.map} +1 -1
  25. package/lib/cjs/{index-OIQn1x0L.js → index-FbNqlZU8.js} +14 -13
  26. package/lib/cjs/index-FbNqlZU8.js.map +1 -0
  27. package/lib/cjs/{index-SxWWV8XD.js → index-HH5lPgpj.js} +18 -17
  28. package/lib/cjs/{index-SxWWV8XD.js.map → index-HH5lPgpj.js.map} +1 -1
  29. package/lib/cjs/{index-vlxA_KJ8.js → index-J1-yHn7v.js} +15 -14
  30. package/lib/{esm/index-vwrMVELn.js.map → cjs/index-J1-yHn7v.js.map} +1 -1
  31. package/lib/cjs/{index-xqKfEyRA.js → index-J3XY9IPt.js} +12 -7
  32. package/lib/cjs/index-J3XY9IPt.js.map +1 -0
  33. package/lib/cjs/{index-llNS_EuP.js → index-Jztk6JlP.js} +58 -55
  34. package/lib/cjs/index-Jztk6JlP.js.map +1 -0
  35. package/lib/cjs/{index-O3vRXWIP.js → index-N6pPZY61.js} +22 -30
  36. package/lib/cjs/index-N6pPZY61.js.map +1 -0
  37. package/lib/cjs/{index-GKolgvC5.js → index-TUJs6KKL.js} +35 -68
  38. package/lib/cjs/index-TUJs6KKL.js.map +1 -0
  39. package/lib/cjs/{index-OtaMLv5l.js → index-Tjg8KyK7.js} +15 -14
  40. package/lib/cjs/{index-OtaMLv5l.js.map → index-Tjg8KyK7.js.map} +1 -1
  41. package/lib/cjs/{index-qRg5-QJH.js → index-VYwHTL3F.js} +16 -15
  42. package/lib/cjs/{index-qRg5-QJH.js.map → index-VYwHTL3F.js.map} +1 -1
  43. package/lib/cjs/index-_GOdKqUK.js +1147 -0
  44. package/lib/cjs/index-_GOdKqUK.js.map +1 -0
  45. package/lib/cjs/{index-PF7s7DOo.js → index-cKQcw-eu.js} +2 -2
  46. package/lib/cjs/{index-PF7s7DOo.js.map → index-cKQcw-eu.js.map} +1 -1
  47. package/lib/cjs/{index-fkT0ywfA.js → index-c_OzudR7.js} +15 -14
  48. package/lib/{esm/index-L7VXk-jT.js.map → cjs/index-c_OzudR7.js.map} +1 -1
  49. package/lib/cjs/{index-TEjdwq--.js → index-cb-5m0vG.js} +18 -17
  50. package/lib/cjs/index-cb-5m0vG.js.map +1 -0
  51. package/lib/cjs/index-cpC-j5Nt.js +176 -0
  52. package/lib/cjs/index-cpC-j5Nt.js.map +1 -0
  53. package/lib/cjs/index-crv_k6dv.js +1353 -0
  54. package/lib/cjs/index-crv_k6dv.js.map +1 -0
  55. package/lib/cjs/{index-78P4PeZ9.js → index-jlfsu92T.js} +16 -15
  56. package/lib/{esm/index-4oMdufW4.js.map → cjs/index-jlfsu92T.js.map} +1 -1
  57. package/lib/cjs/{index-de3dfsQr.js → index-jn036wuh.js} +17 -16
  58. package/lib/{esm/index-rwcSpYkt.js.map → cjs/index-jn036wuh.js.map} +1 -1
  59. package/lib/cjs/{index-JAqL0ybh.js → index-kqz-P6o6.js} +9 -9
  60. package/lib/cjs/index-kqz-P6o6.js.map +1 -0
  61. package/lib/cjs/{index-t_GA5F26.js → index-lBumFRUQ.js} +15 -14
  62. package/lib/cjs/{index-t_GA5F26.js.map → index-lBumFRUQ.js.map} +1 -1
  63. package/lib/cjs/{index-LdEYPSZc.js → index-lUNj3xuC.js} +15 -14
  64. package/lib/{esm/index-0khVa44f.js.map → cjs/index-lUNj3xuC.js.map} +1 -1
  65. package/lib/cjs/{index-ortUqbAp.js → index-mcxgNBq9.js} +15 -14
  66. package/lib/cjs/{index-ortUqbAp.js.map → index-mcxgNBq9.js.map} +1 -1
  67. package/lib/cjs/{index-GEIgbcVc.js → index-nTfDKYYi.js} +38 -37
  68. package/lib/{esm/index-NmjiRA0M.js.map → cjs/index-nTfDKYYi.js.map} +1 -1
  69. package/lib/cjs/{index-kNI3S3lF.js → index-tBw4NmwY.js} +11779 -404
  70. package/lib/cjs/index-tBw4NmwY.js.map +1 -0
  71. package/lib/cjs/{index-zBr61zy6.js → index-vfzLCXfi.js} +15 -14
  72. package/lib/cjs/{index-zBr61zy6.js.map → index-vfzLCXfi.js.map} +1 -1
  73. package/lib/cjs/{index-w9buMrFW.js → index-von4W2LG.js} +18 -17
  74. package/lib/cjs/{index-w9buMrFW.js.map → index-von4W2LG.js.map} +1 -1
  75. package/lib/cjs/index-z6pe2alg.js.map +1 -1
  76. package/lib/cjs/{index-wXLifZgm.js → index-zXSAHvAj.js} +2 -2
  77. package/lib/cjs/{index-wXLifZgm.js.map → index-zXSAHvAj.js.map} +1 -1
  78. package/lib/cjs/index.js +7 -6
  79. package/lib/cjs/index.js.map +1 -1
  80. package/lib/cjs/{schema-7d3meDfB.js → schema-RVrwDDcq.js} +4 -4
  81. package/lib/cjs/{schema-7d3meDfB.js.map → schema-RVrwDDcq.js.map} +1 -1
  82. package/lib/cjs/todoList-Ze4FLMlx.js +415 -0
  83. package/lib/cjs/todoList-Ze4FLMlx.js.map +1 -0
  84. package/lib/cjs/{tooltip-plugin-Mk9fRTxI.js → tooltip-plugin--lhebztC.js} +15 -24
  85. package/lib/cjs/tooltip-plugin--lhebztC.js.map +1 -0
  86. package/lib/esm/{_view-JjtfhQ8k.js → _view-IlZC8FA6.js} +2 -2
  87. package/lib/esm/{_view-JjtfhQ8k.js.map → _view-IlZC8FA6.js.map} +1 -1
  88. package/lib/esm/clsx-RxCLxYpD.js +4 -0
  89. package/lib/esm/clsx-RxCLxYpD.js.map +1 -0
  90. package/lib/esm/{composed-offset-position.browser.min-Tnm31e-m.js → floating-ui.dom-CAYjY8Gv.js} +15 -17
  91. package/lib/esm/floating-ui.dom-CAYjY8Gv.js.map +1 -0
  92. package/lib/esm/helper-wZAtC67x.js +13 -0
  93. package/lib/esm/helper-wZAtC67x.js.map +1 -0
  94. package/lib/esm/{index-Bg5GFp0g.js → index-0-j8Icms.js} +2 -2
  95. package/lib/esm/{index-Bg5GFp0g.js.map → index-0-j8Icms.js.map} +1 -1
  96. package/lib/esm/{index-4oMdufW4.js → index-1l-61HI-.js} +16 -15
  97. package/lib/{cjs/index-78P4PeZ9.js.map → esm/index-1l-61HI-.js.map} +1 -1
  98. package/lib/esm/{index-bVubJ6Rv.js → index-3HeWs5rX.js} +18 -17
  99. package/lib/esm/{index-bVubJ6Rv.js.map → index-3HeWs5rX.js.map} +1 -1
  100. package/lib/esm/{index-6P9Xk934.js → index-3bDzhU6z.js} +15 -14
  101. package/lib/esm/{index-6P9Xk934.js.map → index-3bDzhU6z.js.map} +1 -1
  102. package/lib/esm/{index-NmjiRA0M.js → index-6GrVnloh.js} +38 -37
  103. package/lib/{cjs/index-GEIgbcVc.js.map → esm/index-6GrVnloh.js.map} +1 -1
  104. package/lib/esm/index-8QJbxTYk.js +1145 -0
  105. package/lib/esm/index-8QJbxTYk.js.map +1 -0
  106. package/lib/esm/{index-218OjRxG.js → index-9w_hdnvb.js} +39 -56
  107. package/lib/esm/index-9w_hdnvb.js.map +1 -0
  108. package/lib/esm/index-A83StUe6.js +174 -0
  109. package/lib/esm/index-A83StUe6.js.map +1 -0
  110. package/lib/esm/{index-TNMG6UrN.js → index-AOoFzBaK.js} +9 -9
  111. package/lib/esm/index-AOoFzBaK.js.map +1 -0
  112. package/lib/esm/{index-L7VXk-jT.js → index-DS7Z4Ach.js} +15 -14
  113. package/lib/{cjs/index-fkT0ywfA.js.map → esm/index-DS7Z4Ach.js.map} +1 -1
  114. package/lib/esm/index-Jvxff1vU.js.map +1 -1
  115. package/lib/esm/{index-JkHHp3K-.js → index-LAdX6LsO.js} +11712 -352
  116. package/lib/esm/index-LAdX6LsO.js.map +1 -0
  117. package/lib/esm/{index-VyZguCIt.js → index-MB6wQe1U.js} +12 -7
  118. package/lib/esm/index-MB6wQe1U.js.map +1 -0
  119. package/lib/esm/{index-vwrMVELn.js → index-MxgqkRtj.js} +15 -14
  120. package/lib/{cjs/index-vlxA_KJ8.js.map → esm/index-MxgqkRtj.js.map} +1 -1
  121. package/lib/esm/{index-hQaRWeq1.js → index-NZ5-xr5_.js} +18 -17
  122. package/lib/esm/{index-hQaRWeq1.js.map → index-NZ5-xr5_.js.map} +1 -1
  123. package/lib/esm/{index-x-zW6gKj.js → index-OpUb5xP6.js} +2 -2
  124. package/lib/esm/{index-x-zW6gKj.js.map → index-OpUb5xP6.js.map} +1 -1
  125. package/lib/esm/{index-oMy83ynO.js → index-SDPCpsD5.js} +15 -14
  126. package/lib/esm/{index-oMy83ynO.js.map → index-SDPCpsD5.js.map} +1 -1
  127. package/lib/esm/{index-bsED907r.js → index-VP76m4nW.js} +16 -15
  128. package/lib/esm/{index-bsED907r.js.map → index-VP76m4nW.js.map} +1 -1
  129. package/lib/esm/{index-PkBZpDL4.js → index-Vl0W0S3h.js} +14 -13
  130. package/lib/esm/index-Vl0W0S3h.js.map +1 -0
  131. package/lib/esm/{index-rwcSpYkt.js → index-VoX_n1l_.js} +17 -16
  132. package/lib/{cjs/index-de3dfsQr.js.map → esm/index-VoX_n1l_.js.map} +1 -1
  133. package/lib/esm/{index-7BVeXLQZ.js → index-XH7OnwZl.js} +15 -14
  134. package/lib/{cjs/index-OA_u95ey.js.map → esm/index-XH7OnwZl.js.map} +1 -1
  135. package/lib/esm/{index-a-SAfeeT.js → index-Yuj7sNhQ.js} +18 -17
  136. package/lib/esm/{index-a-SAfeeT.js.map → index-Yuj7sNhQ.js.map} +1 -1
  137. package/lib/esm/{index-A9zdyi2L.js → index-_4fWmRbN.js} +15 -14
  138. package/lib/esm/{index-A9zdyi2L.js.map → index-_4fWmRbN.js.map} +1 -1
  139. package/lib/esm/{index-Grquo08f.js → index-bexsWrgs.js} +18 -17
  140. package/lib/{cjs/index-mJ47ZWO2.js.map → esm/index-bexsWrgs.js.map} +1 -1
  141. package/lib/esm/{index-pHsvfB_I.js → index-chrnjY1D.js} +29 -62
  142. package/lib/esm/index-chrnjY1D.js.map +1 -0
  143. package/lib/esm/{index-UBeneu17.js → index-eqd5wtjX.js} +15 -14
  144. package/lib/esm/{index-UBeneu17.js.map → index-eqd5wtjX.js.map} +1 -1
  145. package/lib/esm/{index-4QzlLVWs.js → index-g_3dzLYU.js} +15 -14
  146. package/lib/{cjs/index-i0_v2uVp.js.map → esm/index-g_3dzLYU.js.map} +1 -1
  147. package/lib/esm/{index-0khVa44f.js → index-grT-Kuf2.js} +15 -14
  148. package/lib/{cjs/index-LdEYPSZc.js.map → esm/index-grT-Kuf2.js.map} +1 -1
  149. package/lib/esm/{index-AHPvVH4H.js → index-hF04phbf.js} +20 -28
  150. package/lib/esm/index-hF04phbf.js.map +1 -0
  151. package/lib/esm/{index-q-qE7-96.js → index-i79QMXpJ.js} +55 -52
  152. package/lib/esm/index-i79QMXpJ.js.map +1 -0
  153. package/lib/esm/{index-DoEghZHy.js → index-rvOBAXap.js} +18 -17
  154. package/lib/{cjs/index-TEjdwq--.js.map → esm/index-rvOBAXap.js.map} +1 -1
  155. package/lib/esm/index-uP9BKsTM.js +446 -0
  156. package/lib/esm/index-uP9BKsTM.js.map +1 -0
  157. package/lib/esm/index-ueQQMSgm.js +1351 -0
  158. package/lib/esm/index-ueQQMSgm.js.map +1 -0
  159. package/lib/esm/{index-U71v7KdA.js → index-x8SyiPMC.js} +15 -14
  160. package/lib/esm/{index-U71v7KdA.js.map → index-x8SyiPMC.js.map} +1 -1
  161. package/lib/esm/{index-U8q-F7hU.js → index-zrQXXSXm.js} +15 -14
  162. package/lib/esm/{index-U8q-F7hU.js.map → index-zrQXXSXm.js.map} +1 -1
  163. package/lib/esm/index.js +7 -6
  164. package/lib/esm/index.js.map +1 -1
  165. package/lib/esm/{schema-hVsy-vme.js → schema-JWJqD9qa.js} +3 -3
  166. package/lib/esm/{schema-hVsy-vme.js.map → schema-JWJqD9qa.js.map} +1 -1
  167. package/lib/esm/todoList-M-PGJKde.js +378 -0
  168. package/lib/esm/todoList-M-PGJKde.js.map +1 -0
  169. package/lib/esm/{tooltip-plugin-vZefVSGL.js → tooltip-plugin-iw2EQWIG.js} +10 -19
  170. package/lib/esm/tooltip-plugin-iw2EQWIG.js.map +1 -0
  171. package/lib/theme/_internal/classic-common.css +3 -2
  172. package/lib/theme/common/block-edit.css +3 -1
  173. package/lib/theme/common/code-mirror.css +15 -0
  174. package/lib/theme/common/cursor.css +1 -1
  175. package/lib/theme/common/image-block.css +2 -0
  176. package/lib/theme/common/link-tooltip.css +10 -13
  177. package/lib/theme/common/list-item.css +16 -1
  178. package/lib/theme/common/prosemirror.css +1 -1
  179. package/lib/theme/common/style.css +1 -0
  180. package/lib/theme/common/table.css +217 -0
  181. package/lib/theme/common/toolbar.css +11 -4
  182. package/lib/theme/{classic-dark → crepe-dark}/style.css +2 -2
  183. package/lib/theme/frame/style.css +28 -0
  184. package/lib/theme/frame-dark/style.css +28 -0
  185. package/lib/theme/nord/style.css +28 -0
  186. package/lib/theme/nord-dark/style.css +28 -0
  187. package/lib/types/core/crepe.d.ts +5 -3
  188. package/lib/types/core/crepe.d.ts.map +1 -1
  189. package/lib/types/core/slice.d.ts +2 -2
  190. package/lib/types/core/slice.d.ts.map +1 -1
  191. package/lib/types/feature/block-edit/handle/component.d.ts +3 -0
  192. package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
  193. package/lib/types/feature/block-edit/handle/index.d.ts +5 -4
  194. package/lib/types/feature/block-edit/handle/index.d.ts.map +1 -1
  195. package/lib/types/feature/block-edit/index.d.ts +43 -2
  196. package/lib/types/feature/block-edit/index.d.ts.map +1 -1
  197. package/lib/types/feature/block-edit/menu/component.d.ts +3 -1
  198. package/lib/types/feature/block-edit/menu/component.d.ts.map +1 -1
  199. package/lib/types/feature/block-edit/menu/config.d.ts +3 -12
  200. package/lib/types/feature/block-edit/menu/config.d.ts.map +1 -1
  201. package/lib/types/feature/block-edit/menu/group-builder.d.ts +29 -0
  202. package/lib/types/feature/block-edit/menu/group-builder.d.ts.map +1 -0
  203. package/lib/types/feature/block-edit/menu/index.d.ts +5 -4
  204. package/lib/types/feature/block-edit/menu/index.d.ts.map +1 -1
  205. package/lib/types/feature/block-edit/menu/utils.d.ts +28 -0
  206. package/lib/types/feature/block-edit/menu/utils.d.ts.map +1 -0
  207. package/lib/types/feature/code-mirror/index.d.ts +9 -1
  208. package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
  209. package/lib/types/feature/cursor/index.d.ts +1 -1
  210. package/lib/types/feature/cursor/index.d.ts.map +1 -1
  211. package/lib/types/feature/image-block/index.d.ts +19 -2
  212. package/lib/types/feature/image-block/index.d.ts.map +1 -1
  213. package/lib/types/feature/index.d.ts +17 -2
  214. package/lib/types/feature/index.d.ts.map +1 -1
  215. package/lib/types/feature/link-tooltip/index.d.ts +12 -2
  216. package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
  217. package/lib/types/feature/list-item/index.d.ts +8 -2
  218. package/lib/types/feature/list-item/index.d.ts.map +1 -1
  219. package/lib/types/feature/placeholder/index.d.ts +2 -2
  220. package/lib/types/feature/placeholder/index.d.ts.map +1 -1
  221. package/lib/types/feature/shared.d.ts +3 -1
  222. package/lib/types/feature/shared.d.ts.map +1 -1
  223. package/lib/types/feature/table/index.d.ts +16 -0
  224. package/lib/types/feature/table/index.d.ts.map +1 -0
  225. package/lib/types/feature/toolbar/component.d.ts +3 -1
  226. package/lib/types/feature/toolbar/component.d.ts.map +1 -1
  227. package/lib/types/feature/toolbar/index.d.ts +11 -2
  228. package/lib/types/feature/toolbar/index.d.ts.map +1 -1
  229. package/lib/types/icons/alignCenter.d.ts +2 -0
  230. package/lib/types/icons/alignCenter.d.ts.map +1 -0
  231. package/lib/types/icons/alignLeft.d.ts +2 -0
  232. package/lib/types/icons/alignLeft.d.ts.map +1 -0
  233. package/lib/types/icons/alignRight.d.ts +2 -0
  234. package/lib/types/icons/alignRight.d.ts.map +1 -0
  235. package/lib/types/icons/bold.d.ts +2 -0
  236. package/lib/types/icons/bold.d.ts.map +1 -0
  237. package/lib/types/{feature/list-item/consts.d.ts → icons/bullet.d.ts} +1 -1
  238. package/lib/types/icons/bullet.d.ts.map +1 -0
  239. package/lib/types/icons/bulletList.d.ts +2 -0
  240. package/lib/types/icons/bulletList.d.ts.map +1 -0
  241. package/lib/types/icons/caption.d.ts +2 -0
  242. package/lib/types/icons/caption.d.ts.map +1 -0
  243. package/lib/types/icons/checkBoxChecked.d.ts +2 -0
  244. package/lib/types/icons/checkBoxChecked.d.ts.map +1 -0
  245. package/lib/types/icons/checkBoxUnchecked.d.ts +2 -0
  246. package/lib/types/icons/checkBoxUnchecked.d.ts.map +1 -0
  247. package/lib/types/icons/chevronDown.d.ts +2 -0
  248. package/lib/types/icons/chevronDown.d.ts.map +1 -0
  249. package/lib/types/icons/clear.d.ts +2 -0
  250. package/lib/types/icons/clear.d.ts.map +1 -0
  251. package/lib/types/icons/code.d.ts +2 -0
  252. package/lib/types/icons/code.d.ts.map +1 -0
  253. package/lib/types/icons/confirm.d.ts +2 -0
  254. package/lib/types/icons/confirm.d.ts.map +1 -0
  255. package/lib/types/icons/divider.d.ts +2 -0
  256. package/lib/types/icons/divider.d.ts.map +1 -0
  257. package/lib/types/icons/dragHandle.d.ts +2 -0
  258. package/lib/types/icons/dragHandle.d.ts.map +1 -0
  259. package/lib/types/icons/edit.d.ts +2 -0
  260. package/lib/types/icons/edit.d.ts.map +1 -0
  261. package/lib/types/icons/h1.d.ts +2 -0
  262. package/lib/types/icons/h1.d.ts.map +1 -0
  263. package/lib/types/icons/h2.d.ts +2 -0
  264. package/lib/types/icons/h2.d.ts.map +1 -0
  265. package/lib/types/icons/h3.d.ts +2 -0
  266. package/lib/types/icons/h3.d.ts.map +1 -0
  267. package/lib/types/icons/h4.d.ts +2 -0
  268. package/lib/types/icons/h4.d.ts.map +1 -0
  269. package/lib/types/icons/h5.d.ts +2 -0
  270. package/lib/types/icons/h5.d.ts.map +1 -0
  271. package/lib/types/icons/h6.d.ts +2 -0
  272. package/lib/types/icons/h6.d.ts.map +1 -0
  273. package/lib/types/icons/image.d.ts +2 -0
  274. package/lib/types/icons/image.d.ts.map +1 -0
  275. package/lib/types/icons/index.d.ts +36 -0
  276. package/lib/types/icons/index.d.ts.map +1 -0
  277. package/lib/types/icons/italic.d.ts +2 -0
  278. package/lib/types/icons/italic.d.ts.map +1 -0
  279. package/lib/types/icons/link.d.ts +2 -0
  280. package/lib/types/icons/link.d.ts.map +1 -0
  281. package/lib/types/icons/menu.d.ts +2 -0
  282. package/lib/types/icons/menu.d.ts.map +1 -0
  283. package/lib/types/icons/orderedList.d.ts +2 -0
  284. package/lib/types/icons/orderedList.d.ts.map +1 -0
  285. package/lib/types/icons/plus.d.ts +2 -0
  286. package/lib/types/icons/plus.d.ts.map +1 -0
  287. package/lib/types/icons/quote.d.ts +2 -0
  288. package/lib/types/icons/quote.d.ts.map +1 -0
  289. package/lib/types/icons/remove.d.ts +2 -0
  290. package/lib/types/icons/remove.d.ts.map +1 -0
  291. package/lib/types/icons/search.d.ts +2 -0
  292. package/lib/types/icons/search.d.ts.map +1 -0
  293. package/lib/types/icons/strikethrough.d.ts +2 -0
  294. package/lib/types/icons/strikethrough.d.ts.map +1 -0
  295. package/lib/types/icons/table.d.ts +2 -0
  296. package/lib/types/icons/table.d.ts.map +1 -0
  297. package/lib/types/icons/text.d.ts +2 -0
  298. package/lib/types/icons/text.d.ts.map +1 -0
  299. package/lib/types/icons/todoList.d.ts +2 -0
  300. package/lib/types/icons/todoList.d.ts.map +1 -0
  301. package/lib/types/utils/index.d.ts +1 -1
  302. package/lib/types/utils/index.d.ts.map +1 -1
  303. package/package.json +9 -23
  304. package/src/core/crepe.ts +15 -9
  305. package/src/core/slice.ts +2 -2
  306. package/src/feature/block-edit/handle/component.ts +13 -29
  307. package/src/feature/block-edit/handle/index.ts +16 -17
  308. package/src/feature/block-edit/index.ts +50 -5
  309. package/src/feature/block-edit/menu/component.ts +6 -7
  310. package/src/feature/block-edit/menu/config.ts +203 -274
  311. package/src/feature/block-edit/menu/group-builder.ts +50 -0
  312. package/src/feature/block-edit/menu/index.ts +11 -8
  313. package/src/feature/block-edit/menu/utils.ts +89 -0
  314. package/src/feature/code-mirror/index.ts +27 -19
  315. package/src/feature/cursor/index.ts +3 -4
  316. package/src/feature/image-block/index.ts +34 -41
  317. package/src/feature/index.ts +23 -3
  318. package/src/feature/link-tooltip/index.ts +23 -10
  319. package/src/feature/list-item/index.ts +21 -9
  320. package/src/feature/placeholder/index.ts +11 -6
  321. package/src/feature/shared.ts +4 -1
  322. package/src/feature/table/index.ts +54 -0
  323. package/src/feature/toolbar/component.ts +29 -11
  324. package/src/feature/toolbar/index.ts +21 -9
  325. package/src/icons/alignCenter.ts +7 -0
  326. package/src/icons/alignLeft.ts +7 -0
  327. package/src/icons/alignRight.ts +7 -0
  328. package/src/icons/bold.ts +7 -0
  329. package/src/{feature/list-item/consts.ts → icons/bullet.ts} +3 -3
  330. package/src/icons/bulletList.ts +14 -0
  331. package/src/icons/caption.ts +7 -0
  332. package/src/icons/checkBoxChecked.ts +14 -0
  333. package/src/icons/checkBoxUnchecked.ts +14 -0
  334. package/src/icons/chevronDown.ts +7 -0
  335. package/src/icons/clear.ts +14 -0
  336. package/src/icons/code.ts +14 -0
  337. package/src/icons/confirm.ts +14 -0
  338. package/src/icons/divider.ts +14 -0
  339. package/src/icons/dragHandle.ts +7 -0
  340. package/src/icons/edit.ts +14 -0
  341. package/src/icons/h1.ts +14 -0
  342. package/src/icons/h2.ts +14 -0
  343. package/src/icons/h3.ts +14 -0
  344. package/src/icons/h4.ts +14 -0
  345. package/src/icons/h5.ts +14 -0
  346. package/src/icons/h6.ts +14 -0
  347. package/src/icons/image.ts +14 -0
  348. package/src/icons/index.ts +35 -0
  349. package/src/icons/italic.ts +7 -0
  350. package/src/icons/link.ts +7 -0
  351. package/src/icons/menu.ts +14 -0
  352. package/src/icons/orderedList.ts +14 -0
  353. package/src/icons/plus.ts +14 -0
  354. package/src/icons/quote.ts +14 -0
  355. package/src/icons/remove.ts +7 -0
  356. package/src/icons/search.ts +7 -0
  357. package/src/icons/strikethrough.ts +7 -0
  358. package/src/icons/table.ts +14 -0
  359. package/src/icons/text.ts +14 -0
  360. package/src/icons/todoList.ts +7 -0
  361. package/src/theme/_internal/classic-common.css +3 -2
  362. package/src/theme/common/block-edit.css +3 -1
  363. package/src/theme/common/code-mirror.css +13 -0
  364. package/src/theme/common/cursor.css +1 -1
  365. package/src/theme/common/image-block.css +2 -0
  366. package/src/theme/common/link-tooltip.css +11 -14
  367. package/src/theme/common/list-item.css +9 -0
  368. package/src/theme/common/prosemirror.css +1 -1
  369. package/src/theme/common/style.css +1 -0
  370. package/src/theme/common/table.css +204 -0
  371. package/src/theme/common/toolbar.css +14 -4
  372. package/src/theme/{classic-dark → crepe-dark}/style.css +2 -2
  373. package/src/theme/frame/style.css +28 -0
  374. package/src/theme/frame-dark/style.css +28 -0
  375. package/src/theme/nord/style.css +28 -0
  376. package/src/theme/nord-dark/style.css +28 -0
  377. package/src/utils/index.ts +1 -1
  378. package/lib/cjs/clsx-7JLENl8W.js +0 -62
  379. package/lib/cjs/clsx-7JLENl8W.js.map +0 -1
  380. package/lib/cjs/composed-offset-position.browser.min-FwypoGc1.js.map +0 -1
  381. package/lib/cjs/helper-OEW-2Vxr.js +0 -9
  382. package/lib/cjs/helper-OEW-2Vxr.js.map +0 -1
  383. package/lib/cjs/index-2oxl5Zo4.js.map +0 -1
  384. package/lib/cjs/index-GKolgvC5.js.map +0 -1
  385. package/lib/cjs/index-JAqL0ybh.js.map +0 -1
  386. package/lib/cjs/index-Ne_pk53w.js +0 -178
  387. package/lib/cjs/index-Ne_pk53w.js.map +0 -1
  388. package/lib/cjs/index-O3vRXWIP.js.map +0 -1
  389. package/lib/cjs/index-OIQn1x0L.js.map +0 -1
  390. package/lib/cjs/index-kNI3S3lF.js.map +0 -1
  391. package/lib/cjs/index-kvO8ReCY.js +0 -1960
  392. package/lib/cjs/index-kvO8ReCY.js.map +0 -1
  393. package/lib/cjs/index-llNS_EuP.js.map +0 -1
  394. package/lib/cjs/index-xqKfEyRA.js.map +0 -1
  395. package/lib/cjs/meta-q8q9fHyr.js +0 -14
  396. package/lib/cjs/meta-q8q9fHyr.js.map +0 -1
  397. package/lib/cjs/tooltip-plugin-Mk9fRTxI.js.map +0 -1
  398. package/lib/esm/clsx-R7WFaNKL.js +0 -52
  399. package/lib/esm/clsx-R7WFaNKL.js.map +0 -1
  400. package/lib/esm/composed-offset-position.browser.min-Tnm31e-m.js.map +0 -1
  401. package/lib/esm/helper-iYEjPbOY.js +0 -7
  402. package/lib/esm/helper-iYEjPbOY.js.map +0 -1
  403. package/lib/esm/index-218OjRxG.js.map +0 -1
  404. package/lib/esm/index-AHPvVH4H.js.map +0 -1
  405. package/lib/esm/index-DoEghZHy.js.map +0 -1
  406. package/lib/esm/index-JkHHp3K-.js.map +0 -1
  407. package/lib/esm/index-PkBZpDL4.js.map +0 -1
  408. package/lib/esm/index-TNMG6UrN.js.map +0 -1
  409. package/lib/esm/index-VyZguCIt.js.map +0 -1
  410. package/lib/esm/index-h1arGiXv.js +0 -1958
  411. package/lib/esm/index-h1arGiXv.js.map +0 -1
  412. package/lib/esm/index-pHsvfB_I.js.map +0 -1
  413. package/lib/esm/index-q-qE7-96.js.map +0 -1
  414. package/lib/esm/index-u8tWJbca.js +0 -176
  415. package/lib/esm/index-u8tWJbca.js.map +0 -1
  416. package/lib/esm/meta-3ZYGAGrY.js +0 -12
  417. package/lib/esm/meta-3ZYGAGrY.js.map +0 -1
  418. package/lib/esm/tooltip-plugin-vZefVSGL.js.map +0 -1
  419. package/lib/types/feature/block-edit/menu/icons.d.ts +0 -14
  420. package/lib/types/feature/block-edit/menu/icons.d.ts.map +0 -1
  421. package/lib/types/feature/link-tooltip/consts.d.ts +0 -5
  422. package/lib/types/feature/link-tooltip/consts.d.ts.map +0 -1
  423. package/lib/types/feature/list-item/consts.d.ts.map +0 -1
  424. package/lib/types/feature/toolbar/consts.d.ts +0 -5
  425. package/lib/types/feature/toolbar/consts.d.ts.map +0 -1
  426. package/src/feature/block-edit/menu/icons.ts +0 -170
  427. package/src/feature/link-tooltip/consts.ts +0 -46
  428. package/src/feature/toolbar/consts.ts +0 -25
  429. /package/lib/theme/{classic → crepe}/style.css +0 -0
  430. /package/src/theme/{classic → crepe}/style.css +0 -0
@@ -0,0 +1,89 @@
1
+ import type { html } from 'atomico'
2
+ import type { Ctx } from '@milkdown/kit/ctx'
3
+ import type { Command, Transaction } from '@milkdown/kit/prose/state'
4
+ import type { Attrs, NodeType } from '@milkdown/kit/prose/model'
5
+ import { findWrapping } from '@milkdown/kit/prose/transform'
6
+
7
+ export interface MenuItem {
8
+ index: number
9
+ key: string
10
+ label: string
11
+ icon: ReturnType<typeof html>
12
+ onRun: (ctx: Ctx) => void
13
+ }
14
+
15
+ type WithRange<T, HasIndex extends true | false = true> = HasIndex extends true ? T & { range: [start: number, end: number] } : T
16
+
17
+ export type MenuItemGroup<HasIndex extends true | false = true> = WithRange<{
18
+ key: string
19
+ label: string
20
+ items: HasIndex extends true ? MenuItem[] : Omit<MenuItem, 'index'>[]
21
+ }, HasIndex>
22
+
23
+ export function clearRange(tr: Transaction) {
24
+ const { $from, $to } = tr.selection
25
+ const { pos: from } = $from
26
+ const { pos: to } = $to
27
+ tr = tr.deleteRange(from - $from.node().content.size, to)
28
+ return tr
29
+ }
30
+
31
+ export function setBlockType(tr: Transaction, nodeType: NodeType, attrs: Attrs | null = null) {
32
+ const { from, to } = tr.selection
33
+ return tr.setBlockType(from, to, nodeType, attrs)
34
+ }
35
+
36
+ export function wrapInBlockType(tr: Transaction, nodeType: NodeType, attrs: Attrs | null = null) {
37
+ const { $from, $to } = tr.selection
38
+
39
+ const range = $from.blockRange($to)
40
+ const wrapping = range && findWrapping(range, nodeType, attrs)
41
+ if (!wrapping)
42
+ return null
43
+
44
+ return tr.wrap(range, wrapping)
45
+ }
46
+
47
+ export function addBlockType(tr: Transaction, nodeType: NodeType, attrs: Attrs | null = null) {
48
+ const node = nodeType.createAndFill(attrs)
49
+ if (!node)
50
+ return null
51
+
52
+ return tr.replaceSelectionWith(node)
53
+ }
54
+
55
+ export function clearContentAndSetBlockType(nodeType: NodeType, attrs: Attrs | null = null): Command {
56
+ return (state, dispatch) => {
57
+ if (dispatch) {
58
+ const tr = setBlockType(clearRange(state.tr), nodeType, attrs)
59
+ dispatch(tr.scrollIntoView())
60
+ }
61
+ return true
62
+ }
63
+ }
64
+
65
+ export function clearContentAndWrapInBlockType(nodeType: NodeType, attrs: Attrs | null = null): Command {
66
+ return (state, dispatch) => {
67
+ const tr = wrapInBlockType(clearRange(state.tr), nodeType, attrs)
68
+ if (!tr)
69
+ return false
70
+
71
+ if (dispatch)
72
+ dispatch(tr.scrollIntoView())
73
+
74
+ return true
75
+ }
76
+ }
77
+
78
+ export function clearContentAndAddBlockType(nodeType: NodeType, attrs: Attrs | null = null): Command {
79
+ return (state, dispatch) => {
80
+ const tr = addBlockType(clearRange(state.tr), nodeType, attrs)
81
+ if (!tr)
82
+ return false
83
+
84
+ if (dispatch)
85
+ dispatch(tr.scrollIntoView())
86
+
87
+ return true
88
+ }
89
+ }
@@ -1,28 +1,26 @@
1
- import { codeBlockComponent, codeBlockConfig } from '@milkdown/components/code-block'
1
+ import { codeBlockComponent, codeBlockConfig } from '@milkdown/kit/component/code-block'
2
2
  import type { LanguageDescription } from '@codemirror/language'
3
3
  import type { Extension } from '@codemirror/state'
4
4
  import { basicSetup } from 'codemirror'
5
5
  import { keymap } from '@codemirror/view'
6
6
  import { defaultKeymap, indentWithTab } from '@codemirror/commands'
7
- import { html } from 'atomico'
8
- import type { DefineFeature } from '../shared'
9
-
10
- const clearIcon = html`
11
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
12
- <g clip-path="url(#clip0_1098_15553)">
13
- <path d="M18.3007 5.70973C17.9107 5.31973 17.2807 5.31973 16.8907 5.70973L12.0007 10.5897L7.1107 5.69973C6.7207 5.30973 6.0907 5.30973 5.7007 5.69973C5.3107 6.08973 5.3107 6.71973 5.7007 7.10973L10.5907 11.9997L5.7007 16.8897C5.3107 17.2797 5.3107 17.9097 5.7007 18.2997C6.0907 18.6897 6.7207 18.6897 7.1107 18.2997L12.0007 13.4097L16.8907 18.2997C17.2807 18.6897 17.9107 18.6897 18.3007 18.2997C18.6907 17.9097 18.6907 17.2797 18.3007 16.8897L13.4107 11.9997L18.3007 7.10973C18.6807 6.72973 18.6807 6.08973 18.3007 5.70973Z" fill="#817567"/>
14
- </g>
15
- <defs>
16
- <clipPath id="clip0_1098_15553">
17
- <rect width="24" height="24" fill="white"/>
18
- </clipPath>
19
- </defs>
20
- </svg>
21
- `
7
+ import type { html } from 'atomico'
8
+ import type { DefineFeature, Icon } from '../shared'
9
+ import { chevronDownIcon, clearIcon, searchIcon } from '../../icons'
22
10
 
23
11
  interface CodeMirrorConfig {
12
+ extensions: Extension[]
24
13
  languages: LanguageDescription[]
25
14
  theme: Extension
15
+
16
+ expandIcon: Icon
17
+ searchIcon: Icon
18
+ clearSearchIcon: Icon
19
+
20
+ searchPlaceholder: string
21
+ noResultText: string
22
+
23
+ renderLanguage: (language: string, selected: boolean) => ReturnType<typeof html> | string | HTMLElement
26
24
  }
27
25
  export type CodeMirrorFeatureConfig = Partial<CodeMirrorConfig>
28
26
 
@@ -42,10 +40,20 @@ export const defineFeature: DefineFeature<CodeMirrorFeatureConfig> = (editor, co
42
40
  theme = nord
43
41
  }
44
42
  ctx.update(codeBlockConfig.key, defaultConfig => ({
45
- ...defaultConfig,
43
+ extensions: [
44
+ keymap.of(defaultKeymap.concat(indentWithTab)),
45
+ basicSetup,
46
+ theme,
47
+ ...config?.extensions ?? [],
48
+ ],
46
49
  languages,
47
- clearSearchIcon: () => clearIcon,
48
- extensions: [basicSetup, keymap.of(defaultKeymap.concat(indentWithTab)), theme],
50
+
51
+ expandIcon: config.expandIcon || (() => chevronDownIcon),
52
+ searchIcon: config.searchIcon || (() => searchIcon),
53
+ clearSearchIcon: config.clearSearchIcon || (() => clearIcon),
54
+ searchPlaceholder: config.searchPlaceholder || 'Search language',
55
+ noResultText: config.noResultText || 'No result',
56
+ renderLanguage: config.renderLanguage || defaultConfig.renderLanguage,
49
57
  }))
50
58
  })
51
59
  .use(codeBlockComponent)
@@ -1,4 +1,4 @@
1
- import { cursor, dropCursorConfig } from '@milkdown/plugin-cursor'
1
+ import { cursor, dropCursorConfig } from '@milkdown/kit/plugin/cursor'
2
2
 
3
3
  import type { DefineFeature } from '../shared'
4
4
 
@@ -6,13 +6,12 @@ interface CursorConfig {
6
6
  color: string | false
7
7
  width: number
8
8
  }
9
- export type CursorFeatureConfig = CursorConfig
9
+ export type CursorFeatureConfig = Partial<CursorConfig>
10
10
 
11
11
  export const defineFeature: DefineFeature<CursorFeatureConfig> = (editor, config) => {
12
12
  editor
13
13
  .config((ctx) => {
14
- ctx.update(dropCursorConfig.key, value => ({
15
- ...value,
14
+ ctx.update(dropCursorConfig.key, () => ({
16
15
  class: 'crepe-drop-cursor',
17
16
  width: config?.width ?? 4,
18
17
  color: config?.color ?? false,
@@ -1,53 +1,46 @@
1
- import { imageBlockComponent, imageBlockConfig } from '@milkdown/components/image-block'
2
- import { imageInlineComponent, inlineImageConfig } from '@milkdown/components/image-inline'
3
- import { html } from 'atomico'
4
- import type { DefineFeature } from '../shared'
1
+ import { imageBlockComponent, imageBlockConfig } from '@milkdown/kit/component/image-block'
2
+ import { imageInlineComponent, inlineImageConfig } from '@milkdown/kit/component/image-inline'
3
+ import type { DefineFeature, Icon } from '../shared'
4
+ import { captionIcon, confirmIcon, imageIcon } from '../../icons'
5
5
 
6
- const imageIcon = html`
7
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
8
- <g clip-path="url(#clip0_1013_1596)">
9
- <path d="M19 5V19H5V5H19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM14.14 11.86L11.14 15.73L9 13.14L6 17H18L14.14 11.86Z" fill="#817567"/>
10
- </g>
11
- <defs>
12
- <clipPath id="clip0_1013_1596">
13
- <rect width="24" height="24" fill="white"/>
14
- </clipPath>
15
- </defs>
16
- </svg>
17
- `
6
+ interface ImageBlockConfig {
7
+ onUpload: (file: File) => Promise<string>
18
8
 
19
- const confirmIcon = html`
20
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
21
- <g clip-path="url(#clip0_1013_1606)">
22
- <path d="M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z" fill="#817567"/>
23
- </g>
24
- <defs>
25
- <clipPath id="clip0_1013_1606">
26
- <rect width="24" height="24" fill="white"/>
27
- </clipPath>
28
- </defs>
29
- </svg>
30
- `
9
+ inlineImageIcon: Icon
10
+ inlineConfirmButton: Icon
11
+ inlineUploadButton: Icon
12
+ inlineUploadPlaceholderText: string
13
+ inlineOnUpload: (file: File) => Promise<string>
31
14
 
32
- const captionIcon = html`
33
- <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M9 22a1 1 0 0 1-1-1v-3H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6.1l-3.7 3.71c-.2.19-.45.29-.7.29zm1-6v3.08L13.08 16H20V4H4v12z"/></svg>
34
- `
15
+ blockImageIcon: Icon
16
+ blockConfirmButton: Icon
17
+ blockCaptionIcon: Icon
18
+ blockUploadButton: Icon
19
+ blockCaptionPlaceholderText: string
20
+ blockUploadPlaceholderText: string
21
+ blockOnUpload: (file: File) => Promise<string>
22
+ }
23
+
24
+ export type ImageBlockFeatureConfig = Partial<ImageBlockConfig>
35
25
 
36
- export const defineFeature: DefineFeature = (editor) => {
26
+ export const defineFeature: DefineFeature<ImageBlockFeatureConfig> = (editor, config) => {
37
27
  editor
38
28
  .config((ctx) => {
39
29
  ctx.update(inlineImageConfig.key, value => ({
40
- ...value,
41
- imageIcon: () => imageIcon,
42
- confirmButton: () => confirmIcon,
43
- uploadPlaceholderText: 'or paste link',
30
+ uploadButton: config?.inlineUploadButton ?? (() => 'Upload'),
31
+ imageIcon: config?.inlineImageIcon ?? (() => imageIcon),
32
+ confirmButton: config?.inlineConfirmButton ?? (() => confirmIcon),
33
+ uploadPlaceholderText: config?.inlineUploadPlaceholderText ?? 'or paste link',
34
+ onUpload: config?.inlineOnUpload ?? config?.onUpload ?? value.onUpload,
44
35
  }))
45
36
  ctx.update(imageBlockConfig.key, value => ({
46
- ...value,
47
- imageIcon: () => imageIcon,
48
- captionIcon: () => captionIcon,
49
- confirmButton: () => html`Confirm`,
50
- captionPlaceholderText: 'Write Image Caption',
37
+ uploadButton: config?.blockUploadButton ?? (() => 'Upload file'),
38
+ imageIcon: config?.blockImageIcon ?? (() => imageIcon),
39
+ captionIcon: config?.blockCaptionIcon ?? (() => captionIcon),
40
+ confirmButton: config?.blockConfirmButton ?? (() => 'Confirm'),
41
+ captionPlaceholderText: config?.blockCaptionPlaceholderText ?? 'Write Image Caption',
42
+ uploadPlaceholderText: config?.blockUploadPlaceholderText ?? 'or paste link',
43
+ onUpload: config?.blockOnUpload ?? config?.onUpload ?? value.onUpload,
51
44
  }))
52
45
  })
53
46
  .use(imageBlockComponent)
@@ -1,6 +1,13 @@
1
- import type { Editor } from '@milkdown/core'
1
+ import type { Editor } from '@milkdown/kit/core'
2
2
  import type { PlaceHolderFeatureConfig } from './placeholder'
3
3
  import type { CodeMirrorFeatureConfig } from './code-mirror'
4
+ import type { BlockEditFeatureConfig } from './block-edit'
5
+ import type { CursorFeatureConfig } from './cursor'
6
+ import type { ImageBlockFeatureConfig } from './image-block'
7
+ import type { LinkTooltipFeatureConfig } from './link-tooltip'
8
+ import type { ListItemFeatureConfig } from './list-item'
9
+ import type { ToolbarFeatureConfig } from './toolbar'
10
+ import type { TableFeatureConfig } from './table'
4
11
 
5
12
  export enum CrepeFeature {
6
13
  CodeMirror = 'code-mirror',
@@ -11,22 +18,31 @@ export enum CrepeFeature {
11
18
  BlockEdit = 'block-edit',
12
19
  Toolbar = 'toolbar',
13
20
  Placeholder = 'placeholder',
21
+ Table = 'table',
14
22
  }
15
23
 
16
24
  export interface CrepeFeatureConfig {
25
+ [CrepeFeature.Cursor]?: CursorFeatureConfig
26
+ [CrepeFeature.ListItem]?: ListItemFeatureConfig
27
+ [CrepeFeature.LinkTooltip]?: LinkTooltipFeatureConfig
28
+ [CrepeFeature.ImageBlock]?: ImageBlockFeatureConfig
29
+ [CrepeFeature.BlockEdit]?: BlockEditFeatureConfig
17
30
  [CrepeFeature.Placeholder]?: PlaceHolderFeatureConfig
31
+ [CrepeFeature.Toolbar]?: ToolbarFeatureConfig
18
32
  [CrepeFeature.CodeMirror]?: CodeMirrorFeatureConfig
33
+ [CrepeFeature.Table]?: TableFeatureConfig
19
34
  }
20
35
 
21
36
  export const defaultFeatures: Record<CrepeFeature, boolean> = {
37
+ [CrepeFeature.Cursor]: true,
22
38
  [CrepeFeature.ListItem]: true,
23
39
  [CrepeFeature.LinkTooltip]: true,
24
40
  [CrepeFeature.ImageBlock]: true,
25
- [CrepeFeature.Cursor]: true,
26
41
  [CrepeFeature.BlockEdit]: true,
27
42
  [CrepeFeature.Placeholder]: true,
28
43
  [CrepeFeature.Toolbar]: true,
29
- [CrepeFeature.CodeMirror]: false,
44
+ [CrepeFeature.CodeMirror]: true,
45
+ [CrepeFeature.Table]: true,
30
46
  }
31
47
 
32
48
  export async function loadFeature(feature: CrepeFeature, editor: Editor, config?: never) {
@@ -63,5 +79,9 @@ export async function loadFeature(feature: CrepeFeature, editor: Editor, config?
63
79
  const { defineFeature } = await import('./toolbar')
64
80
  return defineFeature(editor, config)
65
81
  }
82
+ case CrepeFeature.Table: {
83
+ const { defineFeature } = await import('./table')
84
+ return defineFeature(editor, config)
85
+ }
66
86
  }
67
87
  }
@@ -1,17 +1,30 @@
1
- import { configureLinkTooltip, linkTooltipConfig, linkTooltipPlugin } from '@milkdown/components/link-tooltip'
2
- import type { DefineFeature } from '../shared'
3
- import { confirmIcon, deleteIcon, editIcon, linkIcon } from './consts'
1
+ import { configureLinkTooltip, linkTooltipConfig, linkTooltipPlugin } from '@milkdown/kit/component/link-tooltip'
2
+ import type { DefineFeature, Icon } from '../shared'
3
+ import { confirmIcon, editIcon, linkIcon, removeIcon } from '../../icons'
4
4
 
5
- export const defineFeature: DefineFeature = (editor) => {
5
+ interface LinkTooltipConfig {
6
+ linkIcon: Icon
7
+ editButton: Icon
8
+ removeButton: Icon
9
+ confirmButton: Icon
10
+ inputPlaceholder: string
11
+ onCopyLink: (link: string) => void
12
+ }
13
+
14
+ export type LinkTooltipFeatureConfig = Partial<LinkTooltipConfig>
15
+
16
+ export const defineFeature: DefineFeature<LinkTooltipFeatureConfig> = (editor, config) => {
6
17
  editor
7
18
  .config(configureLinkTooltip)
8
19
  .config((ctx) => {
9
- ctx.update(linkTooltipConfig.key, config => ({
10
- ...config,
11
- linkIcon: () => linkIcon,
12
- editButton: () => editIcon,
13
- removeButton: () => deleteIcon,
14
- confirmButton: () => confirmIcon,
20
+ ctx.update(linkTooltipConfig.key, prev => ({
21
+ ...prev,
22
+ linkIcon: config?.linkIcon ?? (() => linkIcon),
23
+ editButton: config?.editButton ?? (() => editIcon),
24
+ removeButton: config?.removeButton ?? (() => removeIcon),
25
+ confirmButton: config?.confirmButton ?? (() => confirmIcon),
26
+ inputPlaceholder: config?.inputPlaceholder ?? 'Paste link...',
27
+ onCopyLink: config?.onCopyLink ?? (() => {}),
15
28
  }))
16
29
  })
17
30
  .use(linkTooltipPlugin)
@@ -1,26 +1,38 @@
1
- import type { Ctx } from '@milkdown/ctx'
2
- import { listItemBlockComponent, listItemBlockConfig } from '@milkdown/components/list-item-block'
1
+ import type { Ctx } from '@milkdown/kit/ctx'
2
+ import { listItemBlockComponent, listItemBlockConfig } from '@milkdown/kit/component/list-item-block'
3
3
  import { html } from 'atomico'
4
- import type { DefineFeature } from '../shared'
5
- import { bulletIcon } from './consts'
4
+ import clsx from 'clsx'
5
+ import type { DefineFeature, Icon } from '../shared'
6
+ import { bulletIcon, checkBoxCheckedIcon, checkBoxUncheckedIcon } from '../../icons'
6
7
 
7
- function configureListItem(ctx: Ctx) {
8
+ export interface ListItemConfig {
9
+ bulletIcon: Icon
10
+ checkBoxCheckedIcon: Icon
11
+ checkBoxUncheckedIcon: Icon
12
+ }
13
+
14
+ export type ListItemFeatureConfig = Partial<ListItemConfig>
15
+
16
+ function configureListItem(ctx: Ctx, config?: ListItemFeatureConfig) {
8
17
  ctx.set(listItemBlockConfig.key, {
9
18
  renderLabel: ({ label, listType, checked, readonly }) => {
10
19
  if (checked == null) {
11
20
  if (listType === 'bullet')
12
- return html`<span class='label'>${bulletIcon}</span>`
21
+ return html`<span class='label'>${config?.bulletIcon?.() ?? bulletIcon}</span>`
13
22
 
14
23
  return html`<span class='label'>${label}</span>`
15
24
  }
16
25
 
17
- return html`<input disabled=${readonly} class='label' type="checkbox" checked=${checked} />`
26
+ if (checked)
27
+ return html`<span class=${clsx('label checkbox', readonly && 'readonly')}>${config?.checkBoxCheckedIcon?.() ?? checkBoxCheckedIcon}</span>`
28
+
29
+ return html`<span class=${clsx('label checkbox', readonly && 'readonly')}>${config?.checkBoxUncheckedIcon?.() ?? checkBoxUncheckedIcon}</span>`
18
30
  },
19
31
  })
20
32
  }
21
33
 
22
- export const defineFeature: DefineFeature = (editor) => {
34
+ export const defineFeature: DefineFeature<ListItemFeatureConfig> = (editor, config) => {
23
35
  editor
24
- .config(configureListItem)
36
+ .config(ctx => configureListItem(ctx, config))
25
37
  .use(listItemBlockComponent)
26
38
  }
@@ -1,8 +1,9 @@
1
- import { $ctx, $prose } from '@milkdown/utils'
2
- import type { EditorState } from '@milkdown/prose/state'
3
- import { Plugin, PluginKey } from '@milkdown/prose/state'
4
- import type { Node } from '@milkdown/prose/model'
5
- import { Decoration, DecorationSet } from '@milkdown/prose/view'
1
+ import { $ctx, $prose } from '@milkdown/kit/utils'
2
+ import type { EditorState } from '@milkdown/kit/prose/state'
3
+ import { Plugin, PluginKey } from '@milkdown/kit/prose/state'
4
+ import type { Node } from '@milkdown/kit/prose/model'
5
+ import { Decoration, DecorationSet } from '@milkdown/kit/prose/view'
6
+ import { findParent } from '@milkdown/kit/prose'
6
7
  import type { DefineFeature } from '../shared'
7
8
  import { isInCodeBlock, isInList } from '../../utils'
8
9
 
@@ -23,6 +24,10 @@ function createPlaceholderDecoration(
23
24
  if (node.content.size > 0)
24
25
  return null
25
26
 
27
+ const inTable = findParent(node => node.type.name === 'table')($pos)
28
+ if (inTable)
29
+ return null
30
+
26
31
  const before = $pos.before()
27
32
 
28
33
  return Decoration.node(before, before + node.nodeSize, {
@@ -55,7 +60,7 @@ export const placeholderPlugin = $prose((ctx) => {
55
60
  if (isInCodeBlock(state.selection) || isInList(state.selection))
56
61
  return null
57
62
 
58
- const placeholderText = config.text
63
+ const placeholderText = config.text ?? 'Please enter...'
59
64
  const deco = createPlaceholderDecoration(state, placeholderText)
60
65
  if (!deco)
61
66
  return null
@@ -1,3 +1,6 @@
1
- import type { Editor } from '@milkdown/core'
1
+ import type { Editor } from '@milkdown/kit/core'
2
+ import type { html } from 'atomico'
2
3
 
3
4
  export type DefineFeature<Config = unknown> = (editor: Editor, config?: Config) => void | Promise<void>
5
+
6
+ export type Icon = () => HTMLElement | ReturnType<typeof html> | string | null
@@ -0,0 +1,54 @@
1
+ import { tableBlock, tableBlockConfig } from '@milkdown/kit/component/table-block'
2
+ import type { DefineFeature, Icon } from '../shared'
3
+ import {
4
+ alignCenterIcon,
5
+ alignLeftIcon,
6
+ alignRightIcon,
7
+ dragHandleIcon,
8
+ plusIcon,
9
+ removeIcon,
10
+ } from '../../icons'
11
+
12
+ interface TableConfig {
13
+ addRowIcon: Icon
14
+ addColIcon: Icon
15
+ deleteRowIcon: Icon
16
+ deleteColIcon: Icon
17
+ alignLeftIcon: Icon
18
+ alignCenterIcon: Icon
19
+ alignRightIcon: Icon
20
+ colDragHandleIcon: Icon
21
+ rowDragHandleIcon: Icon
22
+ }
23
+
24
+ export type TableFeatureConfig = Partial<TableConfig>
25
+
26
+ export const defineFeature: DefineFeature<TableFeatureConfig> = (editor, config) => {
27
+ editor.config((ctx) => {
28
+ ctx.update(tableBlockConfig.key, defaultConfig => ({
29
+ ...defaultConfig,
30
+ renderButton: (renderType) => {
31
+ switch (renderType) {
32
+ case 'add_row':
33
+ return config?.addRowIcon?.() ?? plusIcon
34
+ case 'add_col':
35
+ return config?.addColIcon?.() ?? plusIcon
36
+ case 'delete_row':
37
+ return config?.deleteRowIcon?.() ?? removeIcon
38
+ case 'delete_col':
39
+ return config?.deleteColIcon?.() ?? removeIcon
40
+ case 'align_col_left':
41
+ return config?.alignLeftIcon?.() ?? alignLeftIcon
42
+ case 'align_col_center':
43
+ return config?.alignCenterIcon?.() ?? alignCenterIcon
44
+ case 'align_col_right':
45
+ return config?.alignRightIcon?.() ?? alignRightIcon
46
+ case 'col_drag_handle':
47
+ return config?.colDragHandleIcon?.() ?? dragHandleIcon
48
+ case 'row_drag_handle':
49
+ return config?.rowDragHandleIcon?.() ?? dragHandleIcon
50
+ }
51
+ },
52
+ }))
53
+ }).use(tableBlock)
54
+ }
@@ -1,7 +1,7 @@
1
1
  import type { Component } from 'atomico'
2
2
  import { c, html, useEffect, useUpdate } from 'atomico'
3
- import type { Ctx } from '@milkdown/ctx'
4
- import { commandsCtx, editorViewCtx } from '@milkdown/core'
3
+ import type { Ctx } from '@milkdown/kit/ctx'
4
+ import { commandsCtx, editorViewCtx } from '@milkdown/kit/core'
5
5
  import {
6
6
  emphasisSchema,
7
7
  inlineCodeSchema,
@@ -10,19 +10,27 @@ import {
10
10
  toggleEmphasisCommand,
11
11
  toggleInlineCodeCommand,
12
12
  toggleStrongCommand,
13
- } from '@milkdown/preset-commonmark'
14
- import type { MarkType } from '@milkdown/prose/model'
13
+ } from '@milkdown/kit/preset/commonmark'
14
+ import type { MarkType } from '@milkdown/kit/prose/model'
15
15
  import clsx from 'clsx'
16
- import { linkTooltipAPI } from '@milkdown/components'
17
- import { boldIcon, codeIcon, italicIcon, linkIcon } from './consts'
16
+ import { linkTooltipAPI } from '@milkdown/kit/component/link-tooltip'
17
+ import { strikethroughSchema, toggleStrikethroughCommand } from '@milkdown/kit/preset/gfm'
18
+ import { boldIcon, codeIcon, italicIcon, linkIcon, strikethroughIcon } from '../../icons'
19
+ import type { ToolbarFeatureConfig } from './index'
18
20
 
19
21
  export interface ToolbarProps {
20
22
  ctx: Ctx
21
23
  hide: () => void
22
24
  show: boolean
25
+ config?: ToolbarFeatureConfig
23
26
  }
24
27
 
25
- export const toolbarComponent: Component<ToolbarProps> = ({ ctx, hide, show }) => {
28
+ export const toolbarComponent: Component<ToolbarProps> = ({
29
+ ctx,
30
+ hide,
31
+ show,
32
+ config,
33
+ }) => {
26
34
  const update = useUpdate()
27
35
  useEffect(() => {
28
36
  update()
@@ -50,7 +58,7 @@ export const toolbarComponent: Component<ToolbarProps> = ({ ctx, hide, show }) =
50
58
  commands.call(toggleStrongCommand.key)
51
59
  })}
52
60
  >
53
- ${boldIcon}
61
+ ${config?.boldIcon?.() ?? boldIcon}
54
62
  </button>
55
63
  <button
56
64
  class=${clsx('toolbar-item', ctx && isActive(emphasisSchema.type(ctx)) && 'active')}
@@ -59,7 +67,16 @@ export const toolbarComponent: Component<ToolbarProps> = ({ ctx, hide, show }) =
59
67
  commands.call(toggleEmphasisCommand.key)
60
68
  })}
61
69
  >
62
- ${italicIcon}
70
+ ${config?.italicIcon?.() ?? italicIcon}
71
+ </button>
72
+ <button
73
+ class=${clsx('toolbar-item', ctx && isActive(strikethroughSchema.type(ctx)) && 'active')}
74
+ onmousedown=${onClick((ctx) => {
75
+ const commands = ctx.get(commandsCtx)
76
+ commands.call(toggleStrikethroughCommand.key)
77
+ })}
78
+ >
79
+ ${config?.strikethroughIcon?.() ?? strikethroughIcon}
63
80
  </button>
64
81
  <div class="divider"></div>
65
82
  <button
@@ -69,7 +86,7 @@ export const toolbarComponent: Component<ToolbarProps> = ({ ctx, hide, show }) =
69
86
  commands.call(toggleInlineCodeCommand.key)
70
87
  })}
71
88
  >
72
- ${codeIcon}
89
+ ${config?.codeIcon?.() ?? codeIcon}
73
90
  </button>
74
91
  <button
75
92
  class=${clsx('toolbar-item', ctx && isActive(linkSchema.type(ctx)) && 'active')}
@@ -86,7 +103,7 @@ export const toolbarComponent: Component<ToolbarProps> = ({ ctx, hide, show }) =
86
103
  hide?.()
87
104
  })}
88
105
  >
89
- ${linkIcon}
106
+ ${config?.linkIcon?.() ?? linkIcon}
90
107
  </button>
91
108
  </host>`
92
109
  }
@@ -95,6 +112,7 @@ toolbarComponent.props = {
95
112
  ctx: Object,
96
113
  hide: Function,
97
114
  show: Boolean,
115
+ config: Object,
98
116
  }
99
117
 
100
118
  export const ToolbarElement = c(toolbarComponent)