@milkdown/crepe 7.4.0 → 7.5.1

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 (424) hide show
  1. package/lib/cjs/clsx-dASsG01A.js +6 -0
  2. package/lib/cjs/clsx-dASsG01A.js.map +1 -0
  3. package/lib/cjs/{index-5PcT4iSf.js → index--2zEz40J.js} +8 -22
  4. package/lib/cjs/{index-5PcT4iSf.js.map → index--2zEz40J.js.map} +1 -1
  5. package/lib/cjs/{index-lrFGGa_l.js → index-5n9R-QCl.js} +5 -19
  6. package/lib/cjs/{index-lrFGGa_l.js.map → index-5n9R-QCl.js.map} +1 -1
  7. package/lib/cjs/{index-SxWWV8XD.js → index-HEdBw63r.js} +8 -22
  8. package/lib/cjs/{index-SxWWV8XD.js.map → index-HEdBw63r.js.map} +1 -1
  9. package/lib/cjs/{index-vlxA_KJ8.js → index-Hlt9dRH5.js} +5 -19
  10. package/lib/cjs/{index-vlxA_KJ8.js.map → index-Hlt9dRH5.js.map} +1 -1
  11. package/lib/cjs/{index-TEjdwq--.js → index-KCW2CzRk.js} +8 -22
  12. package/lib/{esm/index-DoEghZHy.js.map → cjs/index-KCW2CzRk.js.map} +1 -1
  13. package/lib/cjs/{index-qRg5-QJH.js → index-KSZhahYb.js} +6 -20
  14. package/lib/cjs/{index-qRg5-QJH.js.map → index-KSZhahYb.js.map} +1 -1
  15. package/lib/cjs/index-N1cRxqdw.js +39 -0
  16. package/lib/cjs/index-N1cRxqdw.js.map +1 -0
  17. package/lib/cjs/{index-fkT0ywfA.js → index-NNo_VSEA.js} +5 -19
  18. package/lib/cjs/{index-fkT0ywfA.js.map → index-NNo_VSEA.js.map} +1 -1
  19. package/lib/cjs/{index-OtaMLv5l.js → index-O1bDbloo.js} +5 -19
  20. package/lib/cjs/{index-OtaMLv5l.js.map → index-O1bDbloo.js.map} +1 -1
  21. package/lib/cjs/{index-mJ47ZWO2.js → index-OPh9naof.js} +8 -22
  22. package/lib/cjs/{index-mJ47ZWO2.js.map → index-OPh9naof.js.map} +1 -1
  23. package/lib/cjs/{index-OA_u95ey.js → index-PAhfZtcH.js} +5 -19
  24. package/lib/cjs/{index-OA_u95ey.js.map → index-PAhfZtcH.js.map} +1 -1
  25. package/lib/cjs/{index-zBr61zy6.js → index-PeRHVz4A.js} +5 -19
  26. package/lib/{esm/index-6P9Xk934.js.map → cjs/index-PeRHVz4A.js.map} +1 -1
  27. package/lib/cjs/{index-llNS_EuP.js → index-U7GWrg-w.js} +26 -470
  28. package/lib/cjs/index-U7GWrg-w.js.map +1 -0
  29. package/lib/cjs/{index-wXLifZgm.js → index-UTb0Az5e.js} +2 -2
  30. package/lib/cjs/{index-wXLifZgm.js.map → index-UTb0Az5e.js.map} +1 -1
  31. package/lib/cjs/{index-t_GA5F26.js → index-UnEAyH8X.js} +5 -19
  32. package/lib/cjs/{index-t_GA5F26.js.map → index-UnEAyH8X.js.map} +1 -1
  33. package/lib/cjs/{index-i0_v2uVp.js → index-VCkq0ru1.js} +5 -19
  34. package/lib/{esm/index-4QzlLVWs.js.map → cjs/index-VCkq0ru1.js.map} +1 -1
  35. package/lib/cjs/{index-OIQn1x0L.js → index-WQl7Du53.js} +4 -18
  36. package/lib/cjs/index-WQl7Du53.js.map +1 -0
  37. package/lib/cjs/{index-GEIgbcVc.js → index-ahL5MvrQ.js} +28 -42
  38. package/lib/cjs/{index-GEIgbcVc.js.map → index-ahL5MvrQ.js.map} +1 -1
  39. package/lib/cjs/{index-tbEq3xma.js → index-bpgWLeRY.js} +5 -19
  40. package/lib/cjs/{index-tbEq3xma.js.map → index-bpgWLeRY.js.map} +1 -1
  41. package/lib/cjs/index-dEVmN_aj.js +26 -0
  42. package/lib/cjs/index-dEVmN_aj.js.map +1 -0
  43. package/lib/cjs/{index-w9buMrFW.js → index-fZupvR_f.js} +8 -22
  44. package/lib/{esm/index-hQaRWeq1.js.map → cjs/index-fZupvR_f.js.map} +1 -1
  45. package/lib/cjs/{index-ortUqbAp.js → index-gSM-jgti.js} +5 -19
  46. package/lib/{esm/index-oMy83ynO.js.map → cjs/index-gSM-jgti.js.map} +1 -1
  47. package/lib/cjs/{index-LdEYPSZc.js → index-jlPr_A_N.js} +5 -19
  48. package/lib/cjs/{index-LdEYPSZc.js.map → index-jlPr_A_N.js.map} +1 -1
  49. package/lib/cjs/index-ocxd4A-M.js +675 -0
  50. package/lib/cjs/index-ocxd4A-M.js.map +1 -0
  51. package/lib/cjs/{index-xqKfEyRA.js → index-rFFAL9YA.js} +14 -17
  52. package/lib/cjs/index-rFFAL9YA.js.map +1 -0
  53. package/lib/cjs/index-tlx25I_m.js +36 -0
  54. package/lib/cjs/index-tlx25I_m.js.map +1 -0
  55. package/lib/cjs/index-tqAbVyds.js +28 -0
  56. package/lib/cjs/index-tqAbVyds.js.map +1 -0
  57. package/lib/cjs/index-udZSknd8.js +167 -0
  58. package/lib/cjs/index-udZSknd8.js.map +1 -0
  59. package/lib/cjs/index-uleaJDBC.js +19 -0
  60. package/lib/cjs/index-uleaJDBC.js.map +1 -0
  61. package/lib/cjs/{index-de3dfsQr.js → index-urB-WDqA.js} +7 -21
  62. package/lib/cjs/{index-de3dfsQr.js.map → index-urB-WDqA.js.map} +1 -1
  63. package/lib/cjs/{index-78P4PeZ9.js → index-xWgWtxUR.js} +6 -20
  64. package/lib/cjs/{index-78P4PeZ9.js.map → index-xWgWtxUR.js.map} +1 -1
  65. package/lib/cjs/index-z6pe2alg.js.map +1 -1
  66. package/lib/cjs/index.js +150 -13
  67. package/lib/cjs/index.js.map +1 -1
  68. package/lib/cjs/todoList-YYRQo7wG.js +404 -0
  69. package/lib/cjs/todoList-YYRQo7wG.js.map +1 -0
  70. package/lib/esm/clsx-RxCLxYpD.js +4 -0
  71. package/lib/esm/clsx-RxCLxYpD.js.map +1 -0
  72. package/lib/esm/{index-a-SAfeeT.js → index-1NetiFdJ.js} +8 -22
  73. package/lib/esm/{index-a-SAfeeT.js.map → index-1NetiFdJ.js.map} +1 -1
  74. package/lib/esm/{index-NmjiRA0M.js → index-2I_xbjAZ.js} +28 -42
  75. package/lib/esm/{index-NmjiRA0M.js.map → index-2I_xbjAZ.js.map} +1 -1
  76. package/lib/esm/{index-Grquo08f.js → index-2huXYfuJ.js} +8 -22
  77. package/lib/esm/{index-Grquo08f.js.map → index-2huXYfuJ.js.map} +1 -1
  78. package/lib/esm/{index-U8q-F7hU.js → index-4x6_TVZv.js} +5 -19
  79. package/lib/esm/{index-U8q-F7hU.js.map → index-4x6_TVZv.js.map} +1 -1
  80. package/lib/esm/index-6JoGWH2I.js +17 -0
  81. package/lib/esm/index-6JoGWH2I.js.map +1 -0
  82. package/lib/esm/{index-x-zW6gKj.js → index-A-dNwMMf.js} +2 -2
  83. package/lib/esm/{index-x-zW6gKj.js.map → index-A-dNwMMf.js.map} +1 -1
  84. package/lib/esm/{index-oMy83ynO.js → index-AV99ipmP.js} +5 -19
  85. package/lib/{cjs/index-ortUqbAp.js.map → esm/index-AV99ipmP.js.map} +1 -1
  86. package/lib/esm/{index-VyZguCIt.js → index-CMGDOz11.js} +10 -13
  87. package/lib/esm/index-CMGDOz11.js.map +1 -0
  88. package/lib/esm/index-HlPKwzLC.js +34 -0
  89. package/lib/esm/index-HlPKwzLC.js.map +1 -0
  90. package/lib/esm/index-Jvxff1vU.js.map +1 -1
  91. package/lib/esm/{index-vwrMVELn.js → index-PC2bahtq.js} +5 -19
  92. package/lib/esm/{index-vwrMVELn.js.map → index-PC2bahtq.js.map} +1 -1
  93. package/lib/esm/{index-UBeneu17.js → index-QBYz82jZ.js} +5 -19
  94. package/lib/esm/{index-UBeneu17.js.map → index-QBYz82jZ.js.map} +1 -1
  95. package/lib/esm/{index-bsED907r.js → index-W1pAMr_8.js} +6 -20
  96. package/lib/esm/{index-bsED907r.js.map → index-W1pAMr_8.js.map} +1 -1
  97. package/lib/esm/{index-q-qE7-96.js → index-Xzdc2jbA.js} +25 -469
  98. package/lib/esm/index-Xzdc2jbA.js.map +1 -0
  99. package/lib/esm/{index-A9zdyi2L.js → index-ZAtZWqJQ.js} +5 -19
  100. package/lib/esm/{index-A9zdyi2L.js.map → index-ZAtZWqJQ.js.map} +1 -1
  101. package/lib/esm/index-_A9vu1ED.js +673 -0
  102. package/lib/esm/index-_A9vu1ED.js.map +1 -0
  103. package/lib/esm/{index-U71v7KdA.js → index-bnSKBrbD.js} +5 -19
  104. package/lib/esm/{index-U71v7KdA.js.map → index-bnSKBrbD.js.map} +1 -1
  105. package/lib/esm/index-fVrfHXda.js +24 -0
  106. package/lib/esm/index-fVrfHXda.js.map +1 -0
  107. package/lib/esm/{index-PkBZpDL4.js → index-ftnOhuRS.js} +4 -18
  108. package/lib/esm/index-ftnOhuRS.js.map +1 -0
  109. package/lib/esm/{index-4oMdufW4.js → index-iQPB0Rdl.js} +6 -20
  110. package/lib/esm/{index-4oMdufW4.js.map → index-iQPB0Rdl.js.map} +1 -1
  111. package/lib/esm/{index-0khVa44f.js → index-kPj3-TKp.js} +5 -19
  112. package/lib/esm/{index-0khVa44f.js.map → index-kPj3-TKp.js.map} +1 -1
  113. package/lib/esm/{index-hQaRWeq1.js → index-kgOR7SZ6.js} +8 -22
  114. package/lib/{cjs/index-w9buMrFW.js.map → esm/index-kgOR7SZ6.js.map} +1 -1
  115. package/lib/esm/index-lm00PM0y.js +165 -0
  116. package/lib/esm/index-lm00PM0y.js.map +1 -0
  117. package/lib/esm/{index-4QzlLVWs.js → index-m49Bj3q7.js} +5 -19
  118. package/lib/{cjs/index-i0_v2uVp.js.map → esm/index-m49Bj3q7.js.map} +1 -1
  119. package/lib/esm/index-ohmbt6Ys.js +37 -0
  120. package/lib/esm/index-ohmbt6Ys.js.map +1 -0
  121. package/lib/esm/{index-DoEghZHy.js → index-sWVjGw-3.js} +8 -22
  122. package/lib/esm/index-sWVjGw-3.js.map +1 -0
  123. package/lib/esm/{index-L7VXk-jT.js → index-twh8lL5o.js} +5 -19
  124. package/lib/esm/{index-L7VXk-jT.js.map → index-twh8lL5o.js.map} +1 -1
  125. package/lib/esm/{index-6P9Xk934.js → index-v02MCz4_.js} +5 -19
  126. package/lib/{cjs/index-zBr61zy6.js.map → esm/index-v02MCz4_.js.map} +1 -1
  127. package/lib/esm/index-v3rvbocl.js +26 -0
  128. package/lib/esm/index-v3rvbocl.js.map +1 -0
  129. package/lib/esm/{index-7BVeXLQZ.js → index-wEXT8mbN.js} +5 -19
  130. package/lib/esm/{index-7BVeXLQZ.js.map → index-wEXT8mbN.js.map} +1 -1
  131. package/lib/esm/{index-rwcSpYkt.js → index-wFIac5Kw.js} +7 -21
  132. package/lib/esm/{index-rwcSpYkt.js.map → index-wFIac5Kw.js.map} +1 -1
  133. package/lib/esm/{index-bVubJ6Rv.js → index-wg94ewRo.js} +8 -22
  134. package/lib/esm/{index-bVubJ6Rv.js.map → index-wg94ewRo.js.map} +1 -1
  135. package/lib/esm/index.js +152 -11
  136. package/lib/esm/index.js.map +1 -1
  137. package/lib/esm/todoList-9QsDDcmB.js +368 -0
  138. package/lib/esm/todoList-9QsDDcmB.js.map +1 -0
  139. package/lib/theme/_internal/classic-common.css +3 -2
  140. package/lib/theme/common/block-edit.css +3 -1
  141. package/lib/theme/common/code-mirror.css +15 -0
  142. package/lib/theme/common/cursor.css +1 -1
  143. package/lib/theme/common/image-block.css +2 -0
  144. package/lib/theme/common/link-tooltip.css +10 -13
  145. package/lib/theme/common/list-item.css +16 -1
  146. package/lib/theme/common/prosemirror.css +1 -1
  147. package/lib/theme/common/style.css +1 -0
  148. package/lib/theme/common/table.css +217 -0
  149. package/lib/theme/common/toolbar.css +11 -4
  150. package/lib/theme/{classic-dark → crepe-dark}/style.css +2 -2
  151. package/lib/theme/frame/style.css +28 -0
  152. package/lib/theme/frame-dark/style.css +28 -0
  153. package/lib/theme/nord/style.css +28 -0
  154. package/lib/theme/nord-dark/style.css +28 -0
  155. package/lib/types/core/crepe.d.ts +5 -3
  156. package/lib/types/core/crepe.d.ts.map +1 -1
  157. package/lib/types/core/slice.d.ts +2 -2
  158. package/lib/types/core/slice.d.ts.map +1 -1
  159. package/lib/types/feature/block-edit/handle/component.d.ts +3 -0
  160. package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
  161. package/lib/types/feature/block-edit/handle/index.d.ts +5 -4
  162. package/lib/types/feature/block-edit/handle/index.d.ts.map +1 -1
  163. package/lib/types/feature/block-edit/index.d.ts +43 -2
  164. package/lib/types/feature/block-edit/index.d.ts.map +1 -1
  165. package/lib/types/feature/block-edit/menu/component.d.ts +3 -1
  166. package/lib/types/feature/block-edit/menu/component.d.ts.map +1 -1
  167. package/lib/types/feature/block-edit/menu/config.d.ts +3 -12
  168. package/lib/types/feature/block-edit/menu/config.d.ts.map +1 -1
  169. package/lib/types/feature/block-edit/menu/group-builder.d.ts +29 -0
  170. package/lib/types/feature/block-edit/menu/group-builder.d.ts.map +1 -0
  171. package/lib/types/feature/block-edit/menu/index.d.ts +5 -4
  172. package/lib/types/feature/block-edit/menu/index.d.ts.map +1 -1
  173. package/lib/types/feature/block-edit/menu/utils.d.ts +28 -0
  174. package/lib/types/feature/block-edit/menu/utils.d.ts.map +1 -0
  175. package/lib/types/feature/code-mirror/index.d.ts +9 -1
  176. package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
  177. package/lib/types/feature/cursor/index.d.ts +1 -1
  178. package/lib/types/feature/cursor/index.d.ts.map +1 -1
  179. package/lib/types/feature/image-block/index.d.ts +19 -2
  180. package/lib/types/feature/image-block/index.d.ts.map +1 -1
  181. package/lib/types/feature/index.d.ts +17 -2
  182. package/lib/types/feature/index.d.ts.map +1 -1
  183. package/lib/types/feature/link-tooltip/index.d.ts +12 -2
  184. package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
  185. package/lib/types/feature/list-item/index.d.ts +8 -2
  186. package/lib/types/feature/list-item/index.d.ts.map +1 -1
  187. package/lib/types/feature/placeholder/index.d.ts +2 -2
  188. package/lib/types/feature/placeholder/index.d.ts.map +1 -1
  189. package/lib/types/feature/shared.d.ts +3 -1
  190. package/lib/types/feature/shared.d.ts.map +1 -1
  191. package/lib/types/feature/table/index.d.ts +16 -0
  192. package/lib/types/feature/table/index.d.ts.map +1 -0
  193. package/lib/types/feature/toolbar/component.d.ts +3 -1
  194. package/lib/types/feature/toolbar/component.d.ts.map +1 -1
  195. package/lib/types/feature/toolbar/index.d.ts +11 -2
  196. package/lib/types/feature/toolbar/index.d.ts.map +1 -1
  197. package/lib/types/icons/alignCenter.d.ts +2 -0
  198. package/lib/types/icons/alignCenter.d.ts.map +1 -0
  199. package/lib/types/icons/alignLeft.d.ts +2 -0
  200. package/lib/types/icons/alignLeft.d.ts.map +1 -0
  201. package/lib/types/icons/alignRight.d.ts +2 -0
  202. package/lib/types/icons/alignRight.d.ts.map +1 -0
  203. package/lib/types/icons/bold.d.ts +2 -0
  204. package/lib/types/icons/bold.d.ts.map +1 -0
  205. package/lib/types/{feature/list-item/consts.d.ts → icons/bullet.d.ts} +1 -1
  206. package/lib/types/icons/bullet.d.ts.map +1 -0
  207. package/lib/types/icons/bulletList.d.ts +2 -0
  208. package/lib/types/icons/bulletList.d.ts.map +1 -0
  209. package/lib/types/icons/caption.d.ts +2 -0
  210. package/lib/types/icons/caption.d.ts.map +1 -0
  211. package/lib/types/icons/checkBoxChecked.d.ts +2 -0
  212. package/lib/types/icons/checkBoxChecked.d.ts.map +1 -0
  213. package/lib/types/icons/checkBoxUnchecked.d.ts +2 -0
  214. package/lib/types/icons/checkBoxUnchecked.d.ts.map +1 -0
  215. package/lib/types/icons/chevronDown.d.ts +2 -0
  216. package/lib/types/icons/chevronDown.d.ts.map +1 -0
  217. package/lib/types/icons/clear.d.ts +2 -0
  218. package/lib/types/icons/clear.d.ts.map +1 -0
  219. package/lib/types/icons/code.d.ts +2 -0
  220. package/lib/types/icons/code.d.ts.map +1 -0
  221. package/lib/types/icons/confirm.d.ts +2 -0
  222. package/lib/types/icons/confirm.d.ts.map +1 -0
  223. package/lib/types/icons/divider.d.ts +2 -0
  224. package/lib/types/icons/divider.d.ts.map +1 -0
  225. package/lib/types/icons/dragHandle.d.ts +2 -0
  226. package/lib/types/icons/dragHandle.d.ts.map +1 -0
  227. package/lib/types/icons/edit.d.ts +2 -0
  228. package/lib/types/icons/edit.d.ts.map +1 -0
  229. package/lib/types/icons/h1.d.ts +2 -0
  230. package/lib/types/icons/h1.d.ts.map +1 -0
  231. package/lib/types/icons/h2.d.ts +2 -0
  232. package/lib/types/icons/h2.d.ts.map +1 -0
  233. package/lib/types/icons/h3.d.ts +2 -0
  234. package/lib/types/icons/h3.d.ts.map +1 -0
  235. package/lib/types/icons/h4.d.ts +2 -0
  236. package/lib/types/icons/h4.d.ts.map +1 -0
  237. package/lib/types/icons/h5.d.ts +2 -0
  238. package/lib/types/icons/h5.d.ts.map +1 -0
  239. package/lib/types/icons/h6.d.ts +2 -0
  240. package/lib/types/icons/h6.d.ts.map +1 -0
  241. package/lib/types/icons/image.d.ts +2 -0
  242. package/lib/types/icons/image.d.ts.map +1 -0
  243. package/lib/types/icons/index.d.ts +36 -0
  244. package/lib/types/icons/index.d.ts.map +1 -0
  245. package/lib/types/icons/italic.d.ts +2 -0
  246. package/lib/types/icons/italic.d.ts.map +1 -0
  247. package/lib/types/icons/link.d.ts +2 -0
  248. package/lib/types/icons/link.d.ts.map +1 -0
  249. package/lib/types/icons/menu.d.ts +2 -0
  250. package/lib/types/icons/menu.d.ts.map +1 -0
  251. package/lib/types/icons/orderedList.d.ts +2 -0
  252. package/lib/types/icons/orderedList.d.ts.map +1 -0
  253. package/lib/types/icons/plus.d.ts +2 -0
  254. package/lib/types/icons/plus.d.ts.map +1 -0
  255. package/lib/types/icons/quote.d.ts +2 -0
  256. package/lib/types/icons/quote.d.ts.map +1 -0
  257. package/lib/types/icons/remove.d.ts +2 -0
  258. package/lib/types/icons/remove.d.ts.map +1 -0
  259. package/lib/types/icons/search.d.ts +2 -0
  260. package/lib/types/icons/search.d.ts.map +1 -0
  261. package/lib/types/icons/strikethrough.d.ts +2 -0
  262. package/lib/types/icons/strikethrough.d.ts.map +1 -0
  263. package/lib/types/icons/table.d.ts +2 -0
  264. package/lib/types/icons/table.d.ts.map +1 -0
  265. package/lib/types/icons/text.d.ts +2 -0
  266. package/lib/types/icons/text.d.ts.map +1 -0
  267. package/lib/types/icons/todoList.d.ts +2 -0
  268. package/lib/types/icons/todoList.d.ts.map +1 -0
  269. package/lib/types/utils/index.d.ts +1 -1
  270. package/lib/types/utils/index.d.ts.map +1 -1
  271. package/package.json +9 -23
  272. package/src/core/crepe.ts +15 -9
  273. package/src/core/slice.ts +2 -2
  274. package/src/feature/block-edit/handle/component.ts +13 -29
  275. package/src/feature/block-edit/handle/index.ts +16 -17
  276. package/src/feature/block-edit/index.ts +50 -5
  277. package/src/feature/block-edit/menu/component.ts +6 -7
  278. package/src/feature/block-edit/menu/config.ts +203 -274
  279. package/src/feature/block-edit/menu/group-builder.ts +50 -0
  280. package/src/feature/block-edit/menu/index.ts +11 -8
  281. package/src/feature/block-edit/menu/utils.ts +89 -0
  282. package/src/feature/code-mirror/index.ts +27 -19
  283. package/src/feature/cursor/index.ts +3 -4
  284. package/src/feature/image-block/index.ts +34 -41
  285. package/src/feature/index.ts +23 -3
  286. package/src/feature/link-tooltip/index.ts +23 -10
  287. package/src/feature/list-item/index.ts +21 -9
  288. package/src/feature/placeholder/index.ts +11 -6
  289. package/src/feature/shared.ts +4 -1
  290. package/src/feature/table/index.ts +54 -0
  291. package/src/feature/toolbar/component.ts +29 -11
  292. package/src/feature/toolbar/index.ts +21 -9
  293. package/src/icons/alignCenter.ts +7 -0
  294. package/src/icons/alignLeft.ts +7 -0
  295. package/src/icons/alignRight.ts +7 -0
  296. package/src/icons/bold.ts +7 -0
  297. package/src/{feature/list-item/consts.ts → icons/bullet.ts} +3 -3
  298. package/src/icons/bulletList.ts +14 -0
  299. package/src/icons/caption.ts +7 -0
  300. package/src/icons/checkBoxChecked.ts +14 -0
  301. package/src/icons/checkBoxUnchecked.ts +14 -0
  302. package/src/icons/chevronDown.ts +7 -0
  303. package/src/icons/clear.ts +14 -0
  304. package/src/icons/code.ts +14 -0
  305. package/src/icons/confirm.ts +14 -0
  306. package/src/icons/divider.ts +14 -0
  307. package/src/icons/dragHandle.ts +7 -0
  308. package/src/icons/edit.ts +14 -0
  309. package/src/icons/h1.ts +14 -0
  310. package/src/icons/h2.ts +14 -0
  311. package/src/icons/h3.ts +14 -0
  312. package/src/icons/h4.ts +14 -0
  313. package/src/icons/h5.ts +14 -0
  314. package/src/icons/h6.ts +14 -0
  315. package/src/icons/image.ts +14 -0
  316. package/src/icons/index.ts +35 -0
  317. package/src/icons/italic.ts +7 -0
  318. package/src/icons/link.ts +7 -0
  319. package/src/icons/menu.ts +14 -0
  320. package/src/icons/orderedList.ts +14 -0
  321. package/src/icons/plus.ts +14 -0
  322. package/src/icons/quote.ts +14 -0
  323. package/src/icons/remove.ts +7 -0
  324. package/src/icons/search.ts +7 -0
  325. package/src/icons/strikethrough.ts +7 -0
  326. package/src/icons/table.ts +14 -0
  327. package/src/icons/text.ts +14 -0
  328. package/src/icons/todoList.ts +7 -0
  329. package/src/theme/_internal/classic-common.css +3 -2
  330. package/src/theme/common/block-edit.css +3 -1
  331. package/src/theme/common/code-mirror.css +13 -0
  332. package/src/theme/common/cursor.css +1 -1
  333. package/src/theme/common/image-block.css +2 -0
  334. package/src/theme/common/link-tooltip.css +11 -14
  335. package/src/theme/common/list-item.css +9 -0
  336. package/src/theme/common/prosemirror.css +1 -1
  337. package/src/theme/common/style.css +1 -0
  338. package/src/theme/common/table.css +204 -0
  339. package/src/theme/common/toolbar.css +14 -4
  340. package/src/theme/{classic-dark → crepe-dark}/style.css +2 -2
  341. package/src/theme/frame/style.css +28 -0
  342. package/src/theme/frame-dark/style.css +28 -0
  343. package/src/theme/nord/style.css +28 -0
  344. package/src/theme/nord-dark/style.css +28 -0
  345. package/src/utils/index.ts +1 -1
  346. package/lib/cjs/_view-TbSIR42F.js +0 -27
  347. package/lib/cjs/_view-TbSIR42F.js.map +0 -1
  348. package/lib/cjs/clsx-7JLENl8W.js +0 -62
  349. package/lib/cjs/clsx-7JLENl8W.js.map +0 -1
  350. package/lib/cjs/composed-offset-position.browser.min-FwypoGc1.js +0 -1138
  351. package/lib/cjs/composed-offset-position.browser.min-FwypoGc1.js.map +0 -1
  352. package/lib/cjs/helper-OEW-2Vxr.js +0 -9
  353. package/lib/cjs/helper-OEW-2Vxr.js.map +0 -1
  354. package/lib/cjs/index-2oxl5Zo4.js +0 -551
  355. package/lib/cjs/index-2oxl5Zo4.js.map +0 -1
  356. package/lib/cjs/index-GKolgvC5.js +0 -505
  357. package/lib/cjs/index-GKolgvC5.js.map +0 -1
  358. package/lib/cjs/index-JAqL0ybh.js +0 -55
  359. package/lib/cjs/index-JAqL0ybh.js.map +0 -1
  360. package/lib/cjs/index-Ne_pk53w.js +0 -178
  361. package/lib/cjs/index-Ne_pk53w.js.map +0 -1
  362. package/lib/cjs/index-O3vRXWIP.js +0 -199
  363. package/lib/cjs/index-O3vRXWIP.js.map +0 -1
  364. package/lib/cjs/index-OIQn1x0L.js.map +0 -1
  365. package/lib/cjs/index-PF7s7DOo.js +0 -386
  366. package/lib/cjs/index-PF7s7DOo.js.map +0 -1
  367. package/lib/cjs/index-TEjdwq--.js.map +0 -1
  368. package/lib/cjs/index-kNI3S3lF.js +0 -22477
  369. package/lib/cjs/index-kNI3S3lF.js.map +0 -1
  370. package/lib/cjs/index-kvO8ReCY.js +0 -1960
  371. package/lib/cjs/index-kvO8ReCY.js.map +0 -1
  372. package/lib/cjs/index-llNS_EuP.js.map +0 -1
  373. package/lib/cjs/index-xqKfEyRA.js.map +0 -1
  374. package/lib/cjs/meta-q8q9fHyr.js +0 -14
  375. package/lib/cjs/meta-q8q9fHyr.js.map +0 -1
  376. package/lib/cjs/schema-7d3meDfB.js +0 -74
  377. package/lib/cjs/schema-7d3meDfB.js.map +0 -1
  378. package/lib/cjs/tooltip-plugin-Mk9fRTxI.js +0 -200
  379. package/lib/cjs/tooltip-plugin-Mk9fRTxI.js.map +0 -1
  380. package/lib/esm/_view-JjtfhQ8k.js +0 -25
  381. package/lib/esm/_view-JjtfhQ8k.js.map +0 -1
  382. package/lib/esm/clsx-R7WFaNKL.js +0 -52
  383. package/lib/esm/clsx-R7WFaNKL.js.map +0 -1
  384. package/lib/esm/composed-offset-position.browser.min-Tnm31e-m.js +0 -1132
  385. package/lib/esm/composed-offset-position.browser.min-Tnm31e-m.js.map +0 -1
  386. package/lib/esm/helper-iYEjPbOY.js +0 -7
  387. package/lib/esm/helper-iYEjPbOY.js.map +0 -1
  388. package/lib/esm/index-218OjRxG.js +0 -549
  389. package/lib/esm/index-218OjRxG.js.map +0 -1
  390. package/lib/esm/index-AHPvVH4H.js +0 -197
  391. package/lib/esm/index-AHPvVH4H.js.map +0 -1
  392. package/lib/esm/index-Bg5GFp0g.js +0 -384
  393. package/lib/esm/index-Bg5GFp0g.js.map +0 -1
  394. package/lib/esm/index-JkHHp3K-.js +0 -22445
  395. package/lib/esm/index-JkHHp3K-.js.map +0 -1
  396. package/lib/esm/index-PkBZpDL4.js.map +0 -1
  397. package/lib/esm/index-TNMG6UrN.js +0 -53
  398. package/lib/esm/index-TNMG6UrN.js.map +0 -1
  399. package/lib/esm/index-VyZguCIt.js.map +0 -1
  400. package/lib/esm/index-h1arGiXv.js +0 -1958
  401. package/lib/esm/index-h1arGiXv.js.map +0 -1
  402. package/lib/esm/index-pHsvfB_I.js +0 -503
  403. package/lib/esm/index-pHsvfB_I.js.map +0 -1
  404. package/lib/esm/index-q-qE7-96.js.map +0 -1
  405. package/lib/esm/index-u8tWJbca.js +0 -176
  406. package/lib/esm/index-u8tWJbca.js.map +0 -1
  407. package/lib/esm/meta-3ZYGAGrY.js +0 -12
  408. package/lib/esm/meta-3ZYGAGrY.js.map +0 -1
  409. package/lib/esm/schema-hVsy-vme.js +0 -71
  410. package/lib/esm/schema-hVsy-vme.js.map +0 -1
  411. package/lib/esm/tooltip-plugin-vZefVSGL.js +0 -194
  412. package/lib/esm/tooltip-plugin-vZefVSGL.js.map +0 -1
  413. package/lib/types/feature/block-edit/menu/icons.d.ts +0 -14
  414. package/lib/types/feature/block-edit/menu/icons.d.ts.map +0 -1
  415. package/lib/types/feature/link-tooltip/consts.d.ts +0 -5
  416. package/lib/types/feature/link-tooltip/consts.d.ts.map +0 -1
  417. package/lib/types/feature/list-item/consts.d.ts.map +0 -1
  418. package/lib/types/feature/toolbar/consts.d.ts +0 -5
  419. package/lib/types/feature/toolbar/consts.d.ts.map +0 -1
  420. package/src/feature/block-edit/menu/icons.ts +0 -170
  421. package/src/feature/link-tooltip/consts.ts +0 -46
  422. package/src/feature/toolbar/consts.ts +0 -25
  423. /package/lib/theme/{classic → crepe}/style.css +0 -0
  424. /package/src/theme/{classic → crepe}/style.css +0 -0
@@ -0,0 +1,673 @@
1
+ import { block, BlockProvider } from '@milkdown/kit/plugin/block';
2
+ import { NodeSelection, TextSelection } from '@milkdown/kit/prose/state';
3
+ import { editorViewCtx } from '@milkdown/kit/core';
4
+ import { paragraphSchema, headingSchema, blockquoteSchema, hrSchema, bulletListSchema, orderedListSchema, listItemSchema, codeBlockSchema } from '@milkdown/kit/preset/commonmark';
5
+ import { slashFactory, SlashProvider } from '@milkdown/kit/plugin/slash';
6
+ import { $ctx } from '@milkdown/kit/utils';
7
+ import { d as defIfNotExists, i as isInCodeBlock, a as isInList } from './index-Jvxff1vU.js';
8
+ import { c, useMemo, useHost, useState, useRef, useCallback, useEffect, html } from 'atomico';
9
+ import { imageBlockSchema } from '@milkdown/kit/component/image-block';
10
+ import { createTable } from '@milkdown/kit/preset/gfm';
11
+ import { t as textIcon, j as h1Icon, k as h2Icon, m as h3Icon, n as h4Icon, o as h5Icon, p as h6Icon, q as quoteIcon, u as dividerIcon, v as bulletListIcon, w as orderedListIcon, x as todoListIcon, i as imageIcon, y as codeIcon, z as tableIcon, A as plusIcon, B as menuIcon } from './todoList-9QsDDcmB.js';
12
+ import { findWrapping } from '@milkdown/kit/prose/transform';
13
+
14
+ function clearRange(tr) {
15
+ const { $from, $to } = tr.selection;
16
+ const { pos: from } = $from;
17
+ const { pos: to } = $to;
18
+ tr = tr.deleteRange(from - $from.node().content.size, to);
19
+ return tr;
20
+ }
21
+ function setBlockType(tr, nodeType, attrs = null) {
22
+ const { from, to } = tr.selection;
23
+ return tr.setBlockType(from, to, nodeType, attrs);
24
+ }
25
+ function wrapInBlockType(tr, nodeType, attrs = null) {
26
+ const { $from, $to } = tr.selection;
27
+ const range = $from.blockRange($to);
28
+ const wrapping = range && findWrapping(range, nodeType, attrs);
29
+ if (!wrapping)
30
+ return null;
31
+ return tr.wrap(range, wrapping);
32
+ }
33
+ function addBlockType(tr, nodeType, attrs = null) {
34
+ const node = nodeType.createAndFill(attrs);
35
+ if (!node)
36
+ return null;
37
+ return tr.replaceSelectionWith(node);
38
+ }
39
+ function clearContentAndSetBlockType(nodeType, attrs = null) {
40
+ return (state, dispatch) => {
41
+ if (dispatch) {
42
+ const tr = setBlockType(clearRange(state.tr), nodeType, attrs);
43
+ dispatch(tr.scrollIntoView());
44
+ }
45
+ return true;
46
+ };
47
+ }
48
+ function clearContentAndWrapInBlockType(nodeType, attrs = null) {
49
+ return (state, dispatch) => {
50
+ const tr = wrapInBlockType(clearRange(state.tr), nodeType, attrs);
51
+ if (!tr)
52
+ return false;
53
+ if (dispatch)
54
+ dispatch(tr.scrollIntoView());
55
+ return true;
56
+ };
57
+ }
58
+ function clearContentAndAddBlockType(nodeType, attrs = null) {
59
+ return (state, dispatch) => {
60
+ const tr = addBlockType(clearRange(state.tr), nodeType, attrs);
61
+ if (!tr)
62
+ return false;
63
+ if (dispatch)
64
+ dispatch(tr.scrollIntoView());
65
+ return true;
66
+ };
67
+ }
68
+
69
+ var __typeError$2 = (msg) => {
70
+ throw TypeError(msg);
71
+ };
72
+ var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
73
+ var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
74
+ var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
75
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
76
+ var _groups, _getGroupInstance;
77
+ class GroupBuilder {
78
+ constructor() {
79
+ __privateAdd$2(this, _groups, []);
80
+ this.clear = () => {
81
+ __privateSet$2(this, _groups, []);
82
+ return this;
83
+ };
84
+ __privateAdd$2(this, _getGroupInstance, (group) => {
85
+ const groupInstance = {
86
+ group,
87
+ addItem: (key, item) => {
88
+ const data = { key, ...item };
89
+ group.items.push(data);
90
+ return groupInstance;
91
+ },
92
+ clear: () => {
93
+ group.items = [];
94
+ return groupInstance;
95
+ }
96
+ };
97
+ return groupInstance;
98
+ });
99
+ this.addGroup = (key, label) => {
100
+ const items = [];
101
+ const group = {
102
+ key,
103
+ label,
104
+ items
105
+ };
106
+ __privateGet$2(this, _groups).push(group);
107
+ return __privateGet$2(this, _getGroupInstance).call(this, group);
108
+ };
109
+ this.getGroup = (key) => {
110
+ const group = __privateGet$2(this, _groups).find((group2) => group2.key === key);
111
+ if (!group)
112
+ throw new Error(`Group with key ${key} not found`);
113
+ return __privateGet$2(this, _getGroupInstance).call(this, group);
114
+ };
115
+ this.build = () => {
116
+ return __privateGet$2(this, _groups);
117
+ };
118
+ }
119
+ }
120
+ _groups = new WeakMap();
121
+ _getGroupInstance = new WeakMap();
122
+
123
+ function getGroups(filter, config) {
124
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W;
125
+ const groupBuilder = new GroupBuilder();
126
+ groupBuilder.addGroup("text", (_a = config == null ? void 0 : config.slashMenuTextGroupLabel) != null ? _a : "Text").addItem("text", {
127
+ label: (_b = config == null ? void 0 : config.slashMenuTextGroupLabel) != null ? _b : "Text",
128
+ icon: (_d = (_c = config == null ? void 0 : config.slashMenuTextIcon) == null ? void 0 : _c.call(config)) != null ? _d : textIcon,
129
+ onRun: (ctx) => {
130
+ const view = ctx.get(editorViewCtx);
131
+ const { dispatch, state } = view;
132
+ const command = clearContentAndSetBlockType(paragraphSchema.type(ctx));
133
+ command(state, dispatch);
134
+ }
135
+ }).addItem("h1", {
136
+ label: (_e = config == null ? void 0 : config.slashMenuH1Label) != null ? _e : "Heading 1",
137
+ icon: (_g = (_f = config == null ? void 0 : config.slashMenuH1Icon) == null ? void 0 : _f.call(config)) != null ? _g : h1Icon,
138
+ onRun: (ctx) => {
139
+ const view = ctx.get(editorViewCtx);
140
+ const { dispatch, state } = view;
141
+ const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 1 });
142
+ command(state, dispatch);
143
+ }
144
+ }).addItem("h2", {
145
+ label: (_h = config == null ? void 0 : config.slashMenuH2Label) != null ? _h : "Heading 2",
146
+ icon: (_j = (_i = config == null ? void 0 : config.slashMenuH2Icon) == null ? void 0 : _i.call(config)) != null ? _j : h2Icon,
147
+ onRun: (ctx) => {
148
+ const view = ctx.get(editorViewCtx);
149
+ const { dispatch, state } = view;
150
+ const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 2 });
151
+ command(state, dispatch);
152
+ }
153
+ }).addItem("h3", {
154
+ label: (_k = config == null ? void 0 : config.slashMenuH3Label) != null ? _k : "Heading 3",
155
+ icon: (_m = (_l = config == null ? void 0 : config.slashMenuH3Icon) == null ? void 0 : _l.call(config)) != null ? _m : h3Icon,
156
+ onRun: (ctx) => {
157
+ const view = ctx.get(editorViewCtx);
158
+ const { dispatch, state } = view;
159
+ const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 3 });
160
+ command(state, dispatch);
161
+ }
162
+ }).addItem("h4", {
163
+ label: (_n = config == null ? void 0 : config.slashMenuH4Label) != null ? _n : "Heading 4",
164
+ icon: (_p = (_o = config == null ? void 0 : config.slashMenuH4Icon) == null ? void 0 : _o.call(config)) != null ? _p : h4Icon,
165
+ onRun: (ctx) => {
166
+ const view = ctx.get(editorViewCtx);
167
+ const { dispatch, state } = view;
168
+ const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 4 });
169
+ command(state, dispatch);
170
+ }
171
+ }).addItem("h5", {
172
+ label: (_q = config == null ? void 0 : config.slashMenuH5Label) != null ? _q : "Heading 5",
173
+ icon: (_s = (_r = config == null ? void 0 : config.slashMenuH5Icon) == null ? void 0 : _r.call(config)) != null ? _s : h5Icon,
174
+ onRun: (ctx) => {
175
+ const view = ctx.get(editorViewCtx);
176
+ const { dispatch, state } = view;
177
+ const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 5 });
178
+ command(state, dispatch);
179
+ }
180
+ }).addItem("h6", {
181
+ label: (_t = config == null ? void 0 : config.slashMenuH6Label) != null ? _t : "Heading 6",
182
+ icon: (_v = (_u = config == null ? void 0 : config.slashMenuH6Icon) == null ? void 0 : _u.call(config)) != null ? _v : h6Icon,
183
+ onRun: (ctx) => {
184
+ const view = ctx.get(editorViewCtx);
185
+ const { dispatch, state } = view;
186
+ const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 6 });
187
+ command(state, dispatch);
188
+ }
189
+ }).addItem("quote", {
190
+ label: (_w = config == null ? void 0 : config.slashMenuQuoteLabel) != null ? _w : "Quote",
191
+ icon: (_y = (_x = config == null ? void 0 : config.slashMenuQuoteIcon) == null ? void 0 : _x.call(config)) != null ? _y : quoteIcon,
192
+ onRun: (ctx) => {
193
+ const view = ctx.get(editorViewCtx);
194
+ const { dispatch, state } = view;
195
+ const command = clearContentAndWrapInBlockType(blockquoteSchema.type(ctx));
196
+ command(state, dispatch);
197
+ }
198
+ }).addItem("divider", {
199
+ label: (_z = config == null ? void 0 : config.slashMenuDividerLabel) != null ? _z : "Divider",
200
+ icon: (_B = (_A = config == null ? void 0 : config.slashMenuDividerIcon) == null ? void 0 : _A.call(config)) != null ? _B : dividerIcon,
201
+ onRun: (ctx) => {
202
+ const view = ctx.get(editorViewCtx);
203
+ const { dispatch, state } = view;
204
+ const command = clearContentAndAddBlockType(hrSchema.type(ctx));
205
+ command(state, dispatch);
206
+ }
207
+ });
208
+ groupBuilder.addGroup("list", (_C = config == null ? void 0 : config.slashMenuListGroupLabel) != null ? _C : "List").addItem("bullet-list", {
209
+ label: (_D = config == null ? void 0 : config.slashMenuBulletListLabel) != null ? _D : "Bullet List",
210
+ icon: (_F = (_E = config == null ? void 0 : config.slashMenuBulletListIcon) == null ? void 0 : _E.call(config)) != null ? _F : bulletListIcon,
211
+ onRun: (ctx) => {
212
+ const view = ctx.get(editorViewCtx);
213
+ const { dispatch, state } = view;
214
+ const command = clearContentAndWrapInBlockType(bulletListSchema.type(ctx));
215
+ command(state, dispatch);
216
+ }
217
+ }).addItem("ordered-list", {
218
+ label: (_G = config == null ? void 0 : config.slashMenuOrderedListLabel) != null ? _G : "Ordered List",
219
+ icon: (_I = (_H = config == null ? void 0 : config.slashMenuOrderedListIcon) == null ? void 0 : _H.call(config)) != null ? _I : orderedListIcon,
220
+ onRun: (ctx) => {
221
+ const view = ctx.get(editorViewCtx);
222
+ const { dispatch, state } = view;
223
+ const command = clearContentAndWrapInBlockType(orderedListSchema.type(ctx));
224
+ command(state, dispatch);
225
+ }
226
+ }).addItem("todo-list", {
227
+ label: (_J = config == null ? void 0 : config.slashMenuTaskListLabel) != null ? _J : "Todo List",
228
+ icon: (_L = (_K = config == null ? void 0 : config.slashMenuTaskListIcon) == null ? void 0 : _K.call(config)) != null ? _L : todoListIcon,
229
+ onRun: (ctx) => {
230
+ const view = ctx.get(editorViewCtx);
231
+ const { dispatch, state } = view;
232
+ const command = clearContentAndWrapInBlockType(listItemSchema.type(ctx), { checked: false });
233
+ command(state, dispatch);
234
+ }
235
+ });
236
+ groupBuilder.addGroup("advanced", (_M = config == null ? void 0 : config.slashMenuAdvancedGroupLabel) != null ? _M : "Advanced").addItem("image", {
237
+ label: (_N = config == null ? void 0 : config.slashMenuImageLabel) != null ? _N : "Image",
238
+ icon: (_P = (_O = config == null ? void 0 : config.slashMenuImageIcon) == null ? void 0 : _O.call(config)) != null ? _P : imageIcon,
239
+ onRun: (ctx) => {
240
+ const view = ctx.get(editorViewCtx);
241
+ const { dispatch, state } = view;
242
+ const command = clearContentAndAddBlockType(imageBlockSchema.type(ctx));
243
+ command(state, dispatch);
244
+ }
245
+ }).addItem("code", {
246
+ label: (_Q = config == null ? void 0 : config.slashMenuCodeBlockLabel) != null ? _Q : "Code",
247
+ icon: (_S = (_R = config == null ? void 0 : config.slashMenuCodeBlockIcon) == null ? void 0 : _R.call(config)) != null ? _S : codeIcon,
248
+ onRun: (ctx) => {
249
+ const view = ctx.get(editorViewCtx);
250
+ const { dispatch, state } = view;
251
+ const command = clearContentAndAddBlockType(codeBlockSchema.type(ctx));
252
+ command(state, dispatch);
253
+ }
254
+ }).addItem("table", {
255
+ label: (_T = config == null ? void 0 : config.slashMenuTableLabel) != null ? _T : "Table",
256
+ icon: (_V = (_U = config == null ? void 0 : config.slashMenuTableIcon) == null ? void 0 : _U.call(config)) != null ? _V : tableIcon,
257
+ onRun: (ctx) => {
258
+ const view = ctx.get(editorViewCtx);
259
+ const { dispatch, state } = view;
260
+ const tr = clearRange(state.tr);
261
+ const table = createTable(ctx, 3, 3);
262
+ tr.replaceSelectionWith(table);
263
+ const { from } = tr.selection;
264
+ const pos = from - table.nodeSize + 2;
265
+ dispatch(tr);
266
+ requestAnimationFrame(() => {
267
+ const selection = NodeSelection.create(view.state.tr.doc, pos);
268
+ dispatch(view.state.tr.setSelection(selection).scrollIntoView());
269
+ });
270
+ }
271
+ });
272
+ (_W = config == null ? void 0 : config.buildMenu) == null ? void 0 : _W.call(config, groupBuilder);
273
+ let groups = groupBuilder.build();
274
+ if (filter) {
275
+ groups = groups.map((group) => {
276
+ const items2 = group.items.filter((item) => item.label.toLowerCase().includes(filter.toLowerCase()));
277
+ return {
278
+ ...group,
279
+ items: items2
280
+ };
281
+ }).filter((group) => group.items.length > 0);
282
+ }
283
+ const items = groups.flatMap((groups2) => groups2.items);
284
+ items.forEach((item, index) => {
285
+ Object.assign(item, { index });
286
+ });
287
+ groups.reduce((acc, group) => {
288
+ const end = acc + group.items.length;
289
+ Object.assign(group, {
290
+ range: [acc, end]
291
+ });
292
+ return end;
293
+ }, 0);
294
+ return {
295
+ groups,
296
+ size: items.length
297
+ };
298
+ }
299
+
300
+ const menuComponent = ({
301
+ show,
302
+ hide,
303
+ ctx,
304
+ filter,
305
+ config
306
+ }) => {
307
+ const { groups, size } = useMemo(() => getGroups(filter, config), [filter]);
308
+ const host = useHost();
309
+ const [hoverIndex, setHoverIndex] = useState(0);
310
+ const root = useMemo(() => host.current.getRootNode(), [host]);
311
+ const prevMousePosition = useRef({ x: -999, y: -999 });
312
+ const onMouseMove = useCallback((e) => {
313
+ const prevPos = prevMousePosition.current;
314
+ if (!prevPos)
315
+ return;
316
+ const { x, y } = e;
317
+ prevPos.x = x;
318
+ prevPos.y = y;
319
+ }, []);
320
+ useEffect(() => {
321
+ if (size === 0 && show)
322
+ hide == null ? void 0 : hide();
323
+ }, [size, show]);
324
+ const onHover = useCallback((index, after) => {
325
+ setHoverIndex((prev) => {
326
+ const next = typeof index === "function" ? index(prev) : index;
327
+ after == null ? void 0 : after(next);
328
+ return next;
329
+ });
330
+ }, []);
331
+ const scrollToIndex = useCallback((index) => {
332
+ const target = host.current.querySelector(`[data-index="${index}"]`);
333
+ const scrollRoot = host.current.querySelector(".menu-groups");
334
+ if (!target || !scrollRoot)
335
+ return;
336
+ scrollRoot.scrollTop = target.offsetTop - scrollRoot.offsetTop;
337
+ }, []);
338
+ const runByIndex = useCallback((index) => {
339
+ const item = groups.flatMap((group) => group.items).at(index);
340
+ if (item && ctx)
341
+ item.onRun(ctx);
342
+ hide == null ? void 0 : hide();
343
+ }, [groups]);
344
+ const onKeydown = useCallback((e) => {
345
+ if (e.key === "Escape") {
346
+ e.preventDefault();
347
+ hide == null ? void 0 : hide();
348
+ return;
349
+ }
350
+ if (e.key === "ArrowDown") {
351
+ e.preventDefault();
352
+ return onHover((index) => index < size - 1 ? index + 1 : index, scrollToIndex);
353
+ }
354
+ if (e.key === "ArrowUp") {
355
+ e.preventDefault();
356
+ return onHover((index) => index <= 0 ? index : index - 1, scrollToIndex);
357
+ }
358
+ if (e.key === "ArrowLeft") {
359
+ e.preventDefault();
360
+ return onHover((index) => {
361
+ const group = groups.find((group2) => group2.range[0] <= index && group2.range[1] > index);
362
+ if (!group)
363
+ return index;
364
+ const prevGroup = groups[groups.indexOf(group) - 1];
365
+ if (!prevGroup)
366
+ return index;
367
+ return prevGroup.range[1] - 1;
368
+ }, scrollToIndex);
369
+ }
370
+ if (e.key === "ArrowRight") {
371
+ e.preventDefault();
372
+ return onHover((index) => {
373
+ const group = groups.find((group2) => group2.range[0] <= index && group2.range[1] > index);
374
+ if (!group)
375
+ return index;
376
+ const nextGroup = groups[groups.indexOf(group) + 1];
377
+ if (!nextGroup)
378
+ return index;
379
+ return nextGroup.range[0];
380
+ }, scrollToIndex);
381
+ }
382
+ if (e.key === "Enter") {
383
+ e.preventDefault();
384
+ runByIndex(hoverIndex);
385
+ }
386
+ }, [hide, groups, hoverIndex]);
387
+ const onMouseEnter = useCallback((index) => {
388
+ return (e) => {
389
+ const prevPos = prevMousePosition.current;
390
+ if (!prevPos)
391
+ return;
392
+ const { x, y } = e;
393
+ if (x === prevPos.x && y === prevPos.y)
394
+ return;
395
+ onHover(index);
396
+ };
397
+ }, []);
398
+ useEffect(() => {
399
+ if (show)
400
+ root.addEventListener("keydown", onKeydown, { capture: true });
401
+ else root.removeEventListener("keydown", onKeydown, { capture: true });
402
+ return () => {
403
+ root.removeEventListener("keydown", onKeydown, { capture: true });
404
+ };
405
+ }, [show, onKeydown]);
406
+ return html`
407
+ <host onmousedown=${(e) => e.preventDefault()}>
408
+ <nav class="tab-group">
409
+ <ul>
410
+ ${groups.map((group) => html`<li
411
+ key=${group.key}
412
+ onmousedown=${() => onHover(group.range[0], scrollToIndex)}
413
+ class=${hoverIndex >= group.range[0] && hoverIndex < group.range[1] ? "selected" : ""}
414
+ >
415
+ ${group.label}
416
+ </li>`)}
417
+ </ul>
418
+ </nav>
419
+ <div class="menu-groups" onmousemove=${onMouseMove}>
420
+ ${groups.map((group) => {
421
+ return html`
422
+ <div key=${group.key} class="menu-group">
423
+ <h6>${group.label}</h6>
424
+ <ul>
425
+ ${group.items.map(
426
+ (item) => html`<li
427
+ key=${item.key}
428
+ data-index=${item.index}
429
+ class=${hoverIndex === item.index ? "hover" : ""}
430
+ onmouseenter=${onMouseEnter(item.index)}
431
+ onmousedown=${() => {
432
+ var _a;
433
+ (_a = host.current.querySelector(`[data-index="${item.index}"]`)) == null ? void 0 : _a.classList.add("active");
434
+ }}
435
+ onmouseup=${() => {
436
+ var _a;
437
+ (_a = host.current.querySelector(`[data-index="${item.index}"]`)) == null ? void 0 : _a.classList.remove("active");
438
+ runByIndex(item.index);
439
+ }}
440
+ >
441
+ ${item.icon}
442
+ <span>${item.label}</span>
443
+ </li>`
444
+ )}
445
+ </ul>
446
+ </div>
447
+ `;
448
+ })}
449
+ </div>
450
+ </host>
451
+ `;
452
+ };
453
+ menuComponent.props = {
454
+ ctx: Object,
455
+ config: Object,
456
+ show: Boolean,
457
+ filter: String,
458
+ hide: Function
459
+ };
460
+ const MenuElement = c(menuComponent);
461
+
462
+ var __typeError$1 = (msg) => {
463
+ throw TypeError(msg);
464
+ };
465
+ var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
466
+ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
467
+ var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
468
+ var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
469
+ var _content$1, _slashProvider, _programmaticallyPos;
470
+ const menu = slashFactory("CREPE_MENU");
471
+ const menuAPI = $ctx({
472
+ show: () => {
473
+ },
474
+ hide: () => {
475
+ }
476
+ }, "menuAPICtx");
477
+ defIfNotExists("milkdown-slash-menu", MenuElement);
478
+ function configureMenu(ctx, config) {
479
+ ctx.set(menu.key, {
480
+ view: (view) => new MenuView(ctx, view, config)
481
+ });
482
+ }
483
+ class MenuView {
484
+ constructor(ctx, view, config) {
485
+ __privateAdd$1(this, _content$1);
486
+ __privateAdd$1(this, _slashProvider);
487
+ __privateAdd$1(this, _programmaticallyPos, null);
488
+ this.update = (view) => {
489
+ __privateGet$1(this, _slashProvider).update(view);
490
+ };
491
+ this.show = (pos) => {
492
+ __privateSet$1(this, _programmaticallyPos, pos);
493
+ __privateGet$1(this, _content$1).filter = "";
494
+ __privateGet$1(this, _slashProvider).show();
495
+ };
496
+ this.hide = () => {
497
+ __privateSet$1(this, _programmaticallyPos, null);
498
+ __privateGet$1(this, _slashProvider).hide();
499
+ };
500
+ this.destroy = () => {
501
+ __privateGet$1(this, _slashProvider).destroy();
502
+ __privateGet$1(this, _content$1).remove();
503
+ };
504
+ __privateSet$1(this, _content$1, new MenuElement());
505
+ __privateGet$1(this, _content$1).hide = this.hide;
506
+ __privateGet$1(this, _content$1).ctx = ctx;
507
+ __privateGet$1(this, _content$1).config = config;
508
+ const self = this;
509
+ __privateSet$1(this, _slashProvider, new SlashProvider({
510
+ content: __privateGet$1(this, _content$1),
511
+ debounce: 20,
512
+ shouldShow(view2) {
513
+ if (isInCodeBlock(view2.state.selection) || isInList(view2.state.selection))
514
+ return false;
515
+ const currentText = this.getContent(view2, (node) => ["paragraph", "heading"].includes(node.type.name));
516
+ if (currentText == null)
517
+ return false;
518
+ const pos = __privateGet$1(self, _programmaticallyPos);
519
+ __privateGet$1(self, _content$1).filter = currentText.startsWith("/") ? currentText.slice(1) : currentText;
520
+ if (typeof pos === "number") {
521
+ if (view2.state.doc.resolve(pos).node() !== view2.state.doc.resolve(view2.state.selection.from).node()) {
522
+ __privateSet$1(self, _programmaticallyPos, null);
523
+ return false;
524
+ }
525
+ return true;
526
+ }
527
+ if (!currentText.startsWith("/"))
528
+ return false;
529
+ return true;
530
+ },
531
+ offset: 10
532
+ }));
533
+ __privateGet$1(this, _slashProvider).onShow = () => {
534
+ __privateGet$1(this, _content$1).show = true;
535
+ };
536
+ __privateGet$1(this, _slashProvider).onHide = () => {
537
+ __privateGet$1(this, _content$1).show = false;
538
+ };
539
+ this.update(view);
540
+ ctx.set(menuAPI.key, {
541
+ show: (pos) => this.show(pos),
542
+ hide: () => this.hide()
543
+ });
544
+ }
545
+ }
546
+ _content$1 = new WeakMap();
547
+ _slashProvider = new WeakMap();
548
+ _programmaticallyPos = new WeakMap();
549
+
550
+ const blockHandleComponent = ({
551
+ onAdd,
552
+ addIcon,
553
+ handleIcon
554
+ }) => {
555
+ const ref = useRef();
556
+ useEffect(() => {
557
+ var _a;
558
+ (_a = ref.current) == null ? void 0 : _a.classList.remove("active");
559
+ });
560
+ const onMouseDown = (e) => {
561
+ var _a;
562
+ e.preventDefault();
563
+ e.stopPropagation();
564
+ (_a = ref.current) == null ? void 0 : _a.classList.add("active");
565
+ };
566
+ const onMouseUp = (e) => {
567
+ var _a;
568
+ e.preventDefault();
569
+ e.stopPropagation();
570
+ onAdd == null ? void 0 : onAdd();
571
+ (_a = ref.current) == null ? void 0 : _a.classList.remove("active");
572
+ };
573
+ return html`
574
+ <host>
575
+ <div ref=${ref} onmousedown=${onMouseDown} onmouseup=${onMouseUp} class="operation-item">
576
+ ${(addIcon == null ? void 0 : addIcon()) || plusIcon}
577
+ </div>
578
+ <div class="operation-item">
579
+ ${(handleIcon == null ? void 0 : handleIcon()) || menuIcon}
580
+ </div>
581
+ </host>
582
+ `;
583
+ };
584
+ blockHandleComponent.props = {
585
+ show: Boolean,
586
+ onAdd: Function,
587
+ addIcon: Function,
588
+ handleIcon: Function
589
+ };
590
+ const BlockHandleElement = c(blockHandleComponent);
591
+
592
+ var __typeError = (msg) => {
593
+ throw TypeError(msg);
594
+ };
595
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
596
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
597
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
598
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
599
+ var _content, _provider, _ctx;
600
+ class BlockHandleView {
601
+ constructor(ctx, config) {
602
+ __privateAdd(this, _content);
603
+ __privateAdd(this, _provider);
604
+ __privateAdd(this, _ctx);
605
+ this.update = () => {
606
+ __privateGet(this, _provider).update();
607
+ };
608
+ this.destroy = () => {
609
+ __privateGet(this, _provider).destroy();
610
+ __privateGet(this, _content).remove();
611
+ };
612
+ this.onAdd = () => {
613
+ const ctx = __privateGet(this, _ctx);
614
+ const view = ctx.get(editorViewCtx);
615
+ if (!view.hasFocus())
616
+ view.focus();
617
+ const { state, dispatch } = view;
618
+ const active = __privateGet(this, _provider).active;
619
+ if (!active)
620
+ return;
621
+ const $pos = active.$pos;
622
+ const pos = $pos.pos + active.node.nodeSize;
623
+ let tr = state.tr.insert(pos, paragraphSchema.type(ctx).create());
624
+ tr = tr.setSelection(TextSelection.near(tr.doc.resolve(pos)));
625
+ dispatch(tr.scrollIntoView());
626
+ __privateGet(this, _provider).hide();
627
+ ctx.get(menuAPI.key).show(tr.selection.from);
628
+ };
629
+ __privateSet(this, _ctx, ctx);
630
+ const content = new BlockHandleElement();
631
+ __privateSet(this, _content, content);
632
+ __privateGet(this, _content).onAdd = this.onAdd;
633
+ __privateGet(this, _content).addIcon = config == null ? void 0 : config.handleAddIcon;
634
+ __privateGet(this, _content).handleIcon = config == null ? void 0 : config.handleDragIcon;
635
+ __privateSet(this, _provider, new BlockProvider({
636
+ ctx,
637
+ content,
638
+ getOffset: () => 16,
639
+ getPlacement: ({ active, blockDom }) => {
640
+ let totalDescendant = 0;
641
+ active.node.descendants((node) => {
642
+ totalDescendant += node.childCount;
643
+ });
644
+ const dom = active.el;
645
+ const domRect = dom.getBoundingClientRect();
646
+ const handleRect = blockDom.getBoundingClientRect();
647
+ const style = window.getComputedStyle(dom);
648
+ const paddingTop = Number.parseInt(style.paddingTop, 10) || 0;
649
+ const paddingBottom = Number.parseInt(style.paddingBottom, 10) || 0;
650
+ const height = domRect.height - paddingTop - paddingBottom;
651
+ const handleHeight = handleRect.height;
652
+ return totalDescendant > 2 || handleHeight * 2 < height ? "left-start" : "left";
653
+ }
654
+ }));
655
+ this.update();
656
+ }
657
+ }
658
+ _content = new WeakMap();
659
+ _provider = new WeakMap();
660
+ _ctx = new WeakMap();
661
+ defIfNotExists("milkdown-block-handle", BlockHandleElement);
662
+ function configureBlockHandle(ctx, config) {
663
+ ctx.set(block.key, {
664
+ view: () => new BlockHandleView(ctx, config)
665
+ });
666
+ }
667
+
668
+ const defineFeature = (editor, config) => {
669
+ editor.config((ctx) => configureBlockHandle(ctx, config)).config((ctx) => configureMenu(ctx, config)).use(menuAPI).use(block).use(menu);
670
+ };
671
+
672
+ export { defineFeature };
673
+ //# sourceMappingURL=index-_A9vu1ED.js.map