@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
@@ -1,1960 +0,0 @@
1
- 'use strict';
2
-
3
- var index = require('./index-kNI3S3lF.js');
4
- var state = require('@milkdown/prose/state');
5
- var prose = require('@milkdown/prose');
6
- var transform = require('@milkdown/prose/transform');
7
- var model = require('@milkdown/prose/model');
8
- var composedOffsetPosition_browser_min = require('./composed-offset-position.browser.min-FwypoGc1.js');
9
- var index$2 = require('./index-z6pe2alg.js');
10
- var atomico = require('atomico');
11
- var schema = require('./schema-7d3meDfB.js');
12
- var index$1 = require('./index-PF7s7DOo.js');
13
- require('@milkdown/prose/history');
14
- require('@milkdown/prose/keymap');
15
- require('@milkdown/prose/commands');
16
- require('@milkdown/prose/inputrules');
17
- require('@milkdown/prose/schema-list');
18
- require('@milkdown/prose/view');
19
- require('./meta-q8q9fHyr.js');
20
-
21
- function withMeta(plugin, meta) {
22
- Object.assign(plugin, {
23
- meta: {
24
- package: "@milkdown/plugin-block",
25
- ...meta
26
- }
27
- });
28
- return plugin;
29
- }
30
-
31
- const defaultNodeFilter = (_pos, node) => {
32
- const { name } = node.type;
33
- if (name.startsWith("table") && name !== "table")
34
- return false;
35
- return true;
36
- };
37
- const blockConfig = index.$ctx({ filterNodes: defaultNodeFilter }, "blockConfig");
38
- withMeta(blockConfig, {
39
- displayName: "Ctx<blockConfig>"
40
- });
41
-
42
- /**
43
- * lodash (Custom Build) <https://lodash.com/>
44
- * Build: `lodash modularize exports="npm" -o ./`
45
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
46
- * Released under MIT license <https://lodash.com/license>
47
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
48
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
49
- */
50
-
51
- /** Used as the `TypeError` message for "Functions" methods. */
52
- var FUNC_ERROR_TEXT = 'Expected a function';
53
-
54
- /** Used as references for various `Number` constants. */
55
- var NAN = 0 / 0;
56
-
57
- /** `Object#toString` result references. */
58
- var symbolTag = '[object Symbol]';
59
-
60
- /** Used to match leading and trailing whitespace. */
61
- var reTrim = /^\s+|\s+$/g;
62
-
63
- /** Used to detect bad signed hexadecimal string values. */
64
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
65
-
66
- /** Used to detect binary string values. */
67
- var reIsBinary = /^0b[01]+$/i;
68
-
69
- /** Used to detect octal string values. */
70
- var reIsOctal = /^0o[0-7]+$/i;
71
-
72
- /** Built-in method references without a dependency on `root`. */
73
- var freeParseInt = parseInt;
74
-
75
- /** Detect free variable `global` from Node.js. */
76
- var freeGlobal = typeof index.commonjsGlobal == 'object' && index.commonjsGlobal && index.commonjsGlobal.Object === Object && index.commonjsGlobal;
77
-
78
- /** Detect free variable `self`. */
79
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
80
-
81
- /** Used as a reference to the global object. */
82
- var root = freeGlobal || freeSelf || Function('return this')();
83
-
84
- /** Used for built-in method references. */
85
- var objectProto = Object.prototype;
86
-
87
- /**
88
- * Used to resolve the
89
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
90
- * of values.
91
- */
92
- var objectToString = objectProto.toString;
93
-
94
- /* Built-in method references for those with the same name as other `lodash` methods. */
95
- var nativeMax = Math.max,
96
- nativeMin = Math.min;
97
-
98
- /**
99
- * Gets the timestamp of the number of milliseconds that have elapsed since
100
- * the Unix epoch (1 January 1970 00:00:00 UTC).
101
- *
102
- * @static
103
- * @memberOf _
104
- * @since 2.4.0
105
- * @category Date
106
- * @returns {number} Returns the timestamp.
107
- * @example
108
- *
109
- * _.defer(function(stamp) {
110
- * console.log(_.now() - stamp);
111
- * }, _.now());
112
- * // => Logs the number of milliseconds it took for the deferred invocation.
113
- */
114
- var now = function() {
115
- return root.Date.now();
116
- };
117
-
118
- /**
119
- * Creates a debounced function that delays invoking `func` until after `wait`
120
- * milliseconds have elapsed since the last time the debounced function was
121
- * invoked. The debounced function comes with a `cancel` method to cancel
122
- * delayed `func` invocations and a `flush` method to immediately invoke them.
123
- * Provide `options` to indicate whether `func` should be invoked on the
124
- * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
125
- * with the last arguments provided to the debounced function. Subsequent
126
- * calls to the debounced function return the result of the last `func`
127
- * invocation.
128
- *
129
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
130
- * invoked on the trailing edge of the timeout only if the debounced function
131
- * is invoked more than once during the `wait` timeout.
132
- *
133
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
134
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
135
- *
136
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
137
- * for details over the differences between `_.debounce` and `_.throttle`.
138
- *
139
- * @static
140
- * @memberOf _
141
- * @since 0.1.0
142
- * @category Function
143
- * @param {Function} func The function to debounce.
144
- * @param {number} [wait=0] The number of milliseconds to delay.
145
- * @param {Object} [options={}] The options object.
146
- * @param {boolean} [options.leading=false]
147
- * Specify invoking on the leading edge of the timeout.
148
- * @param {number} [options.maxWait]
149
- * The maximum time `func` is allowed to be delayed before it's invoked.
150
- * @param {boolean} [options.trailing=true]
151
- * Specify invoking on the trailing edge of the timeout.
152
- * @returns {Function} Returns the new debounced function.
153
- * @example
154
- *
155
- * // Avoid costly calculations while the window size is in flux.
156
- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
157
- *
158
- * // Invoke `sendMail` when clicked, debouncing subsequent calls.
159
- * jQuery(element).on('click', _.debounce(sendMail, 300, {
160
- * 'leading': true,
161
- * 'trailing': false
162
- * }));
163
- *
164
- * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
165
- * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
166
- * var source = new EventSource('/stream');
167
- * jQuery(source).on('message', debounced);
168
- *
169
- * // Cancel the trailing debounced invocation.
170
- * jQuery(window).on('popstate', debounced.cancel);
171
- */
172
- function debounce(func, wait, options) {
173
- var lastArgs,
174
- lastThis,
175
- maxWait,
176
- result,
177
- timerId,
178
- lastCallTime,
179
- lastInvokeTime = 0,
180
- leading = false,
181
- maxing = false,
182
- trailing = true;
183
-
184
- if (typeof func != 'function') {
185
- throw new TypeError(FUNC_ERROR_TEXT);
186
- }
187
- wait = toNumber(wait) || 0;
188
- if (isObject(options)) {
189
- leading = !!options.leading;
190
- maxing = 'maxWait' in options;
191
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
192
- trailing = 'trailing' in options ? !!options.trailing : trailing;
193
- }
194
-
195
- function invokeFunc(time) {
196
- var args = lastArgs,
197
- thisArg = lastThis;
198
-
199
- lastArgs = lastThis = undefined;
200
- lastInvokeTime = time;
201
- result = func.apply(thisArg, args);
202
- return result;
203
- }
204
-
205
- function leadingEdge(time) {
206
- // Reset any `maxWait` timer.
207
- lastInvokeTime = time;
208
- // Start the timer for the trailing edge.
209
- timerId = setTimeout(timerExpired, wait);
210
- // Invoke the leading edge.
211
- return leading ? invokeFunc(time) : result;
212
- }
213
-
214
- function remainingWait(time) {
215
- var timeSinceLastCall = time - lastCallTime,
216
- timeSinceLastInvoke = time - lastInvokeTime,
217
- result = wait - timeSinceLastCall;
218
-
219
- return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
220
- }
221
-
222
- function shouldInvoke(time) {
223
- var timeSinceLastCall = time - lastCallTime,
224
- timeSinceLastInvoke = time - lastInvokeTime;
225
-
226
- // Either this is the first call, activity has stopped and we're at the
227
- // trailing edge, the system time has gone backwards and we're treating
228
- // it as the trailing edge, or we've hit the `maxWait` limit.
229
- return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
230
- (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
231
- }
232
-
233
- function timerExpired() {
234
- var time = now();
235
- if (shouldInvoke(time)) {
236
- return trailingEdge(time);
237
- }
238
- // Restart the timer.
239
- timerId = setTimeout(timerExpired, remainingWait(time));
240
- }
241
-
242
- function trailingEdge(time) {
243
- timerId = undefined;
244
-
245
- // Only invoke if we have `lastArgs` which means `func` has been
246
- // debounced at least once.
247
- if (trailing && lastArgs) {
248
- return invokeFunc(time);
249
- }
250
- lastArgs = lastThis = undefined;
251
- return result;
252
- }
253
-
254
- function cancel() {
255
- if (timerId !== undefined) {
256
- clearTimeout(timerId);
257
- }
258
- lastInvokeTime = 0;
259
- lastArgs = lastCallTime = lastThis = timerId = undefined;
260
- }
261
-
262
- function flush() {
263
- return timerId === undefined ? result : trailingEdge(now());
264
- }
265
-
266
- function debounced() {
267
- var time = now(),
268
- isInvoking = shouldInvoke(time);
269
-
270
- lastArgs = arguments;
271
- lastThis = this;
272
- lastCallTime = time;
273
-
274
- if (isInvoking) {
275
- if (timerId === undefined) {
276
- return leadingEdge(lastCallTime);
277
- }
278
- if (maxing) {
279
- // Handle invocations in a tight loop.
280
- timerId = setTimeout(timerExpired, wait);
281
- return invokeFunc(lastCallTime);
282
- }
283
- }
284
- if (timerId === undefined) {
285
- timerId = setTimeout(timerExpired, wait);
286
- }
287
- return result;
288
- }
289
- debounced.cancel = cancel;
290
- debounced.flush = flush;
291
- return debounced;
292
- }
293
-
294
- /**
295
- * Creates a throttled function that only invokes `func` at most once per
296
- * every `wait` milliseconds. The throttled function comes with a `cancel`
297
- * method to cancel delayed `func` invocations and a `flush` method to
298
- * immediately invoke them. Provide `options` to indicate whether `func`
299
- * should be invoked on the leading and/or trailing edge of the `wait`
300
- * timeout. The `func` is invoked with the last arguments provided to the
301
- * throttled function. Subsequent calls to the throttled function return the
302
- * result of the last `func` invocation.
303
- *
304
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
305
- * invoked on the trailing edge of the timeout only if the throttled function
306
- * is invoked more than once during the `wait` timeout.
307
- *
308
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
309
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
310
- *
311
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
312
- * for details over the differences between `_.throttle` and `_.debounce`.
313
- *
314
- * @static
315
- * @memberOf _
316
- * @since 0.1.0
317
- * @category Function
318
- * @param {Function} func The function to throttle.
319
- * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
320
- * @param {Object} [options={}] The options object.
321
- * @param {boolean} [options.leading=true]
322
- * Specify invoking on the leading edge of the timeout.
323
- * @param {boolean} [options.trailing=true]
324
- * Specify invoking on the trailing edge of the timeout.
325
- * @returns {Function} Returns the new throttled function.
326
- * @example
327
- *
328
- * // Avoid excessively updating the position while scrolling.
329
- * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
330
- *
331
- * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
332
- * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
333
- * jQuery(element).on('click', throttled);
334
- *
335
- * // Cancel the trailing throttled invocation.
336
- * jQuery(window).on('popstate', throttled.cancel);
337
- */
338
- function throttle(func, wait, options) {
339
- var leading = true,
340
- trailing = true;
341
-
342
- if (typeof func != 'function') {
343
- throw new TypeError(FUNC_ERROR_TEXT);
344
- }
345
- if (isObject(options)) {
346
- leading = 'leading' in options ? !!options.leading : leading;
347
- trailing = 'trailing' in options ? !!options.trailing : trailing;
348
- }
349
- return debounce(func, wait, {
350
- 'leading': leading,
351
- 'maxWait': wait,
352
- 'trailing': trailing
353
- });
354
- }
355
-
356
- /**
357
- * Checks if `value` is the
358
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
359
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
360
- *
361
- * @static
362
- * @memberOf _
363
- * @since 0.1.0
364
- * @category Lang
365
- * @param {*} value The value to check.
366
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
367
- * @example
368
- *
369
- * _.isObject({});
370
- * // => true
371
- *
372
- * _.isObject([1, 2, 3]);
373
- * // => true
374
- *
375
- * _.isObject(_.noop);
376
- * // => true
377
- *
378
- * _.isObject(null);
379
- * // => false
380
- */
381
- function isObject(value) {
382
- var type = typeof value;
383
- return !!value && (type == 'object' || type == 'function');
384
- }
385
-
386
- /**
387
- * Checks if `value` is object-like. A value is object-like if it's not `null`
388
- * and has a `typeof` result of "object".
389
- *
390
- * @static
391
- * @memberOf _
392
- * @since 4.0.0
393
- * @category Lang
394
- * @param {*} value The value to check.
395
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
396
- * @example
397
- *
398
- * _.isObjectLike({});
399
- * // => true
400
- *
401
- * _.isObjectLike([1, 2, 3]);
402
- * // => true
403
- *
404
- * _.isObjectLike(_.noop);
405
- * // => false
406
- *
407
- * _.isObjectLike(null);
408
- * // => false
409
- */
410
- function isObjectLike(value) {
411
- return !!value && typeof value == 'object';
412
- }
413
-
414
- /**
415
- * Checks if `value` is classified as a `Symbol` primitive or object.
416
- *
417
- * @static
418
- * @memberOf _
419
- * @since 4.0.0
420
- * @category Lang
421
- * @param {*} value The value to check.
422
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
423
- * @example
424
- *
425
- * _.isSymbol(Symbol.iterator);
426
- * // => true
427
- *
428
- * _.isSymbol('abc');
429
- * // => false
430
- */
431
- function isSymbol(value) {
432
- return typeof value == 'symbol' ||
433
- (isObjectLike(value) && objectToString.call(value) == symbolTag);
434
- }
435
-
436
- /**
437
- * Converts `value` to a number.
438
- *
439
- * @static
440
- * @memberOf _
441
- * @since 4.0.0
442
- * @category Lang
443
- * @param {*} value The value to process.
444
- * @returns {number} Returns the number.
445
- * @example
446
- *
447
- * _.toNumber(3.2);
448
- * // => 3.2
449
- *
450
- * _.toNumber(Number.MIN_VALUE);
451
- * // => 5e-324
452
- *
453
- * _.toNumber(Infinity);
454
- * // => Infinity
455
- *
456
- * _.toNumber('3.2');
457
- * // => 3.2
458
- */
459
- function toNumber(value) {
460
- if (typeof value == 'number') {
461
- return value;
462
- }
463
- if (isSymbol(value)) {
464
- return NAN;
465
- }
466
- if (isObject(value)) {
467
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
468
- value = isObject(other) ? (other + '') : other;
469
- }
470
- if (typeof value != 'string') {
471
- return value === 0 ? value : +value;
472
- }
473
- value = value.replace(reTrim, '');
474
- var isBinary = reIsBinary.test(value);
475
- return (isBinary || reIsOctal.test(value))
476
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
477
- : (reIsBadHex.test(value) ? NAN : +value);
478
- }
479
-
480
- var lodash_throttle = throttle;
481
-
482
- var throttle$1 = /*@__PURE__*/index.getDefaultExportFromCjs(lodash_throttle);
483
-
484
- function removePossibleTable(view, event) {
485
- var _a;
486
- const { state } = view;
487
- const $pos = state.selection.$anchor;
488
- for (let d = $pos.depth; d > 0; d--) {
489
- const node = $pos.node(d);
490
- if (node.type.spec.tableRole === "table") {
491
- const eventPos = view.posAtCoords({ left: event.clientX, top: event.clientY });
492
- if (!eventPos)
493
- return null;
494
- const slice = (_a = view.dragging) == null ? void 0 : _a.slice;
495
- if (!slice)
496
- return null;
497
- const $mouse = view.state.doc.resolve(eventPos.pos);
498
- const insertPos = transform.dropPoint(view.state.doc, $mouse.pos, slice);
499
- if (insertPos == null || insertPos < 0)
500
- return null;
501
- let tr = state.tr;
502
- tr = tr.delete($pos.before(d), $pos.after(d));
503
- const pos = tr.mapping.map(insertPos);
504
- tr = tr.replaceRange(pos, pos, slice);
505
- return tr;
506
- }
507
- }
508
- return null;
509
- }
510
-
511
- function selectRootNodeByDom(view, coords, filterNodes) {
512
- var _a;
513
- const root = view.dom.parentElement;
514
- if (!root)
515
- return null;
516
- const pos = (_a = view.posAtCoords({
517
- left: coords.x,
518
- top: coords.y
519
- })) == null ? void 0 : _a.inside;
520
- if (pos == null || pos < 0)
521
- return null;
522
- let $pos = view.state.doc.resolve(pos);
523
- let node = view.state.doc.nodeAt(pos);
524
- let element = view.nodeDOM(pos);
525
- const filter = () => {
526
- if ($pos.depth >= 1 && $pos.index($pos.depth) === 0) {
527
- const ancestorPos = $pos.before($pos.depth);
528
- node = view.state.doc.nodeAt(ancestorPos);
529
- element = view.nodeDOM(ancestorPos);
530
- $pos = view.state.doc.resolve(ancestorPos);
531
- if (!filterNodes($pos, node))
532
- filter();
533
- }
534
- };
535
- filter();
536
- if (!element || !node)
537
- return null;
538
- return { node, $pos, el: element };
539
- }
540
-
541
- let _detachedDoc = null;
542
- function detachedDoc() {
543
- return _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument("title"));
544
- }
545
- const wrapMap = {
546
- thead: ["table"],
547
- tbody: ["table"],
548
- tfoot: ["table"],
549
- caption: ["table"],
550
- colgroup: ["table"],
551
- col: ["table", "colgroup"],
552
- tr: ["table", "tbody"],
553
- td: ["table", "tbody", "tr"],
554
- th: ["table", "tbody", "tr"]
555
- };
556
- function serializeForClipboard(view, slice) {
557
- const context = [];
558
- let { openStart, openEnd, content } = slice;
559
- while (openStart > 1 && openEnd > 1 && content.childCount === 1 && content.firstChild.childCount === 1) {
560
- openStart -= 1;
561
- openEnd -= 1;
562
- const node = content.firstChild;
563
- context.push(
564
- node.type.name,
565
- node.attrs !== node.type.defaultAttrs ? node.attrs : null
566
- );
567
- content = node.content;
568
- }
569
- const serializer = view.someProp("clipboardSerializer") || model.DOMSerializer.fromSchema(view.state.schema);
570
- const doc = detachedDoc();
571
- const wrap = doc.createElement("div");
572
- wrap.appendChild(serializer.serializeFragment(content, { document: doc }));
573
- let firstChild = wrap.firstChild;
574
- let needsWrap;
575
- let wrappers = 0;
576
- while (firstChild && firstChild.nodeType === 1 && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
577
- for (let i = needsWrap.length - 1; i >= 0; i--) {
578
- const wrapper = doc.createElement(needsWrap[i]);
579
- while (wrap.firstChild) wrapper.appendChild(wrap.firstChild);
580
- wrap.appendChild(wrapper);
581
- wrappers++;
582
- }
583
- firstChild = wrap.firstChild;
584
- }
585
- if (firstChild && firstChild.nodeType === 1) {
586
- firstChild.setAttribute(
587
- "data-pm-slice",
588
- `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`
589
- );
590
- }
591
- const text = view.someProp("clipboardTextSerializer", (f) => f(slice, view)) || slice.content.textBetween(0, slice.content.size, "\n\n");
592
- return { dom: wrap, text };
593
- }
594
-
595
- var __typeError$4 = (msg) => {
596
- throw TypeError(msg);
597
- };
598
- var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
599
- var __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
600
- var __privateAdd$4 = (obj, member, value) => member.has(obj) ? __typeError$4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
601
- var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
602
- var _ctx$2, _createSelection, _activeSelection, _active, _activeDOMRect, _dragging, _BlockService_instances, filterNodes_get, view_get, _notify, _hide, _show, _handleMouseDown, _handleMouseUp, _handleDragStart, _mousemoveCallback, _dragEnd;
603
- const brokenClipboardAPI = prose.browser.ie && prose.browser.ie_version < 15 || prose.browser.ios && prose.browser.webkit_version < 604;
604
- const buffer = 20;
605
- class BlockService {
606
- constructor() {
607
- __privateAdd$4(this, _BlockService_instances);
608
- /// @internal
609
- __privateAdd$4(this, _ctx$2);
610
- /// @internal
611
- __privateAdd$4(this, _createSelection, () => {
612
- if (!__privateGet$4(this, _active))
613
- return null;
614
- const result = __privateGet$4(this, _active);
615
- const view = __privateGet$4(this, _BlockService_instances, view_get);
616
- if (view && state.NodeSelection.isSelectable(result.node)) {
617
- const nodeSelection = state.NodeSelection.create(view.state.doc, result.$pos.pos);
618
- view.dispatch(view.state.tr.setSelection(nodeSelection));
619
- view.focus();
620
- __privateSet$4(this, _activeSelection, nodeSelection);
621
- return nodeSelection;
622
- }
623
- return null;
624
- });
625
- /// @internal
626
- __privateAdd$4(this, _activeSelection, null);
627
- /// @internal
628
- __privateAdd$4(this, _active, null);
629
- /// @internal
630
- __privateAdd$4(this, _activeDOMRect);
631
- /// @internal
632
- __privateAdd$4(this, _dragging, false);
633
- /// @internal
634
- __privateAdd$4(this, _notify);
635
- /// @internal
636
- __privateAdd$4(this, _hide, () => {
637
- var _a;
638
- (_a = __privateGet$4(this, _notify)) == null ? void 0 : _a.call(this, { type: "hide" });
639
- __privateSet$4(this, _active, null);
640
- });
641
- /// @internal
642
- __privateAdd$4(this, _show, (active) => {
643
- var _a;
644
- __privateSet$4(this, _active, active);
645
- (_a = __privateGet$4(this, _notify)) == null ? void 0 : _a.call(this, { type: "show", active });
646
- });
647
- /// Bind editor context and notify function to the service.
648
- this.bind = (ctx, notify) => {
649
- __privateSet$4(this, _ctx$2, ctx);
650
- __privateSet$4(this, _notify, notify);
651
- };
652
- /// Add mouse event to the dom.
653
- this.addEvent = (dom) => {
654
- dom.addEventListener("mousedown", __privateGet$4(this, _handleMouseDown));
655
- dom.addEventListener("mouseup", __privateGet$4(this, _handleMouseUp));
656
- dom.addEventListener("dragstart", __privateGet$4(this, _handleDragStart));
657
- };
658
- /// Remove mouse event to the dom.
659
- this.removeEvent = (dom) => {
660
- dom.removeEventListener("mousedown", __privateGet$4(this, _handleMouseDown));
661
- dom.removeEventListener("mouseup", __privateGet$4(this, _handleMouseUp));
662
- dom.removeEventListener("dragstart", __privateGet$4(this, _handleDragStart));
663
- };
664
- /// Unbind the notify function.
665
- this.unBind = () => {
666
- __privateSet$4(this, _notify, void 0);
667
- };
668
- /// @internal
669
- __privateAdd$4(this, _handleMouseDown, () => {
670
- var _a;
671
- __privateSet$4(this, _activeDOMRect, (_a = __privateGet$4(this, _active)) == null ? void 0 : _a.el.getBoundingClientRect());
672
- __privateGet$4(this, _createSelection).call(this);
673
- });
674
- /// @internal
675
- __privateAdd$4(this, _handleMouseUp, () => {
676
- if (!__privateGet$4(this, _dragging)) {
677
- requestAnimationFrame(() => {
678
- var _a;
679
- if (!__privateGet$4(this, _activeDOMRect))
680
- return;
681
- (_a = __privateGet$4(this, _BlockService_instances, view_get)) == null ? void 0 : _a.focus();
682
- });
683
- return;
684
- }
685
- __privateSet$4(this, _dragging, false);
686
- __privateSet$4(this, _activeSelection, null);
687
- });
688
- /// @internal
689
- __privateAdd$4(this, _handleDragStart, (event) => {
690
- var _a;
691
- __privateSet$4(this, _dragging, true);
692
- const view = __privateGet$4(this, _BlockService_instances, view_get);
693
- if (!view)
694
- return;
695
- view.dom.dataset.dragging = "true";
696
- const selection = __privateGet$4(this, _activeSelection);
697
- if (event.dataTransfer && selection) {
698
- const slice = selection.content();
699
- event.dataTransfer.effectAllowed = "copyMove";
700
- const { dom, text } = serializeForClipboard(view, slice);
701
- event.dataTransfer.clearData();
702
- event.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML);
703
- if (!brokenClipboardAPI)
704
- event.dataTransfer.setData("text/plain", text);
705
- const activeEl = (_a = __privateGet$4(this, _active)) == null ? void 0 : _a.el;
706
- if (activeEl)
707
- event.dataTransfer.setDragImage(activeEl, 0, 0);
708
- view.dragging = {
709
- slice,
710
- move: true
711
- };
712
- __privateGet$4(this, _hide).call(this);
713
- }
714
- });
715
- /// @internal
716
- this.keydownCallback = (view) => {
717
- __privateGet$4(this, _hide).call(this);
718
- __privateSet$4(this, _dragging, false);
719
- view.dom.dataset.dragging = "false";
720
- return false;
721
- };
722
- /// @internal
723
- __privateAdd$4(this, _mousemoveCallback, throttle$1((view, event) => {
724
- if (!view.editable)
725
- return;
726
- const rect = view.dom.getBoundingClientRect();
727
- const x = rect.left + rect.width / 2;
728
- const dom = view.root.elementFromPoint(x, event.clientY);
729
- if (!(dom instanceof Element)) {
730
- __privateGet$4(this, _hide).call(this);
731
- return;
732
- }
733
- const filterNodes = __privateGet$4(this, _BlockService_instances, filterNodes_get);
734
- if (!filterNodes)
735
- return;
736
- const result = selectRootNodeByDom(view, { x, y: event.clientY }, filterNodes);
737
- if (!result) {
738
- __privateGet$4(this, _hide).call(this);
739
- return;
740
- }
741
- __privateGet$4(this, _show).call(this, result);
742
- }, 200));
743
- /// @internal
744
- this.mousemoveCallback = (view, event) => {
745
- if (view.composing || !view.editable)
746
- return false;
747
- __privateGet$4(this, _mousemoveCallback).call(this, view, event);
748
- return false;
749
- };
750
- /// @internal
751
- this.dragoverCallback = (view, event) => {
752
- var _a;
753
- if (__privateGet$4(this, _dragging)) {
754
- const root = (_a = __privateGet$4(this, _BlockService_instances, view_get)) == null ? void 0 : _a.dom.parentElement;
755
- if (!root)
756
- return false;
757
- const hasHorizontalScrollbar = root.scrollHeight > root.clientHeight;
758
- const rootRect = root.getBoundingClientRect();
759
- if (hasHorizontalScrollbar) {
760
- if (root.scrollTop > 0 && Math.abs(event.y - rootRect.y) < buffer) {
761
- const top = root.scrollTop > 10 ? root.scrollTop - 10 : 0;
762
- root.scrollTop = top;
763
- return false;
764
- }
765
- const totalHeight = Math.round(view.dom.getBoundingClientRect().height);
766
- const scrollBottom = Math.round(root.scrollTop + rootRect.height);
767
- if (scrollBottom < totalHeight && Math.abs(event.y - (rootRect.height + rootRect.y)) < buffer) {
768
- const top = root.scrollTop + 10;
769
- root.scrollTop = top;
770
- return false;
771
- }
772
- }
773
- }
774
- return false;
775
- };
776
- /// @internal
777
- this.dragenterCallback = (view) => {
778
- __privateSet$4(this, _dragging, true);
779
- view.dom.dataset.dragging = "true";
780
- };
781
- /// @internal
782
- this.dragleaveCallback = (view, event) => {
783
- const x = event.clientX;
784
- const y = event.clientY;
785
- if (x < 0 || y < 0 || x > window.innerWidth || y > window.innerHeight) {
786
- __privateSet$4(this, _active, null);
787
- __privateGet$4(this, _dragEnd).call(this, view);
788
- }
789
- };
790
- /// @internal
791
- this.dropCallback = (view, event) => {
792
- const tr = removePossibleTable(view, event);
793
- __privateGet$4(this, _dragEnd).call(this, view);
794
- if (tr) {
795
- view.dispatch(tr);
796
- event.preventDefault();
797
- return true;
798
- }
799
- return false;
800
- };
801
- /// @internal
802
- this.dragendCallback = (view) => {
803
- __privateGet$4(this, _dragEnd).call(this, view);
804
- };
805
- /// @internal
806
- __privateAdd$4(this, _dragEnd, (view) => {
807
- __privateSet$4(this, _dragging, false);
808
- view.dom.dataset.dragging = "false";
809
- });
810
- }
811
- }
812
- _ctx$2 = new WeakMap();
813
- _createSelection = new WeakMap();
814
- _activeSelection = new WeakMap();
815
- _active = new WeakMap();
816
- _activeDOMRect = new WeakMap();
817
- _dragging = new WeakMap();
818
- _BlockService_instances = new WeakSet();
819
- filterNodes_get = function() {
820
- var _a;
821
- return (_a = __privateGet$4(this, _ctx$2)) == null ? void 0 : _a.get(blockConfig.key).filterNodes;
822
- };
823
- view_get = function() {
824
- var _a;
825
- return (_a = __privateGet$4(this, _ctx$2)) == null ? void 0 : _a.get(index.editorViewCtx);
826
- };
827
- _notify = new WeakMap();
828
- _hide = new WeakMap();
829
- _show = new WeakMap();
830
- _handleMouseDown = new WeakMap();
831
- _handleMouseUp = new WeakMap();
832
- _handleDragStart = new WeakMap();
833
- _mousemoveCallback = new WeakMap();
834
- _dragEnd = new WeakMap();
835
-
836
- const blockService = index.$ctx(new BlockService(), "blockService");
837
- withMeta(blockConfig, {
838
- displayName: "Ctx<blockService>"
839
- });
840
- const blockSpec = index.$ctx({}, "blockSpec");
841
- withMeta(blockConfig, {
842
- displayName: "Ctx<blockSpec>"
843
- });
844
- const blockPlugin = index.$prose((ctx) => {
845
- const milkdownPluginBlockKey = new state.PluginKey("MILKDOWN_BLOCK");
846
- const service = ctx.get(blockService.key);
847
- const spec = ctx.get(blockSpec.key);
848
- return new state.Plugin({
849
- key: milkdownPluginBlockKey,
850
- ...spec,
851
- props: {
852
- ...spec.props,
853
- handleDOMEvents: {
854
- drop: (view, event) => {
855
- return service.dropCallback(view, event);
856
- },
857
- pointermove: (view, event) => {
858
- return service.mousemoveCallback(view, event);
859
- },
860
- keydown: (view) => {
861
- return service.keydownCallback(view);
862
- },
863
- dragover: (view, event) => {
864
- return service.dragoverCallback(view, event);
865
- },
866
- dragleave: (view, event) => {
867
- return service.dragleaveCallback(view, event);
868
- },
869
- dragenter: (view) => {
870
- return service.dragenterCallback(view);
871
- },
872
- dragend: (view) => {
873
- return service.dragendCallback(view);
874
- }
875
- }
876
- }
877
- });
878
- });
879
- withMeta(blockPlugin, {
880
- displayName: "Prose<block>"
881
- });
882
-
883
- var __typeError$3 = (msg) => {
884
- throw TypeError(msg);
885
- };
886
- var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
887
- var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
888
- var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
889
- var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
890
- var __privateMethod$1 = (obj, member, method) => (__accessCheck$3(obj, member, "access private method"), method);
891
- var _element, _ctx$1, _service, _activeNode, _initialized$1, _getOffset, _getPosition, _getPlacement, _BlockProvider_instances, init_fn;
892
- class BlockProvider {
893
- constructor(options) {
894
- __privateAdd$3(this, _BlockProvider_instances);
895
- /// @internal
896
- __privateAdd$3(this, _element);
897
- /// @internal
898
- __privateAdd$3(this, _ctx$1);
899
- /// @internal
900
- __privateAdd$3(this, _service);
901
- /// @internal
902
- __privateAdd$3(this, _activeNode, null);
903
- /// @internal
904
- __privateAdd$3(this, _initialized$1, false);
905
- /// @internal
906
- __privateAdd$3(this, _getOffset);
907
- /// @internal
908
- __privateAdd$3(this, _getPosition);
909
- /// @internal
910
- __privateAdd$3(this, _getPlacement);
911
- /// Update provider state by editor view.
912
- this.update = () => {
913
- requestAnimationFrame(() => {
914
- if (!__privateGet$3(this, _initialized$1)) {
915
- try {
916
- __privateMethod$1(this, _BlockProvider_instances, init_fn).call(this);
917
- __privateSet$3(this, _initialized$1, true);
918
- } catch (e) {
919
- }
920
- }
921
- });
922
- };
923
- /// Destroy the block.
924
- this.destroy = () => {
925
- var _a, _b;
926
- (_a = __privateGet$3(this, _service)) == null ? void 0 : _a.unBind();
927
- (_b = __privateGet$3(this, _service)) == null ? void 0 : _b.removeEvent(__privateGet$3(this, _element));
928
- __privateGet$3(this, _element).remove();
929
- };
930
- /// Show the block.
931
- this.show = (active) => {
932
- const dom = active.el;
933
- const editorDom = __privateGet$3(this, _ctx$1).get(index.editorViewCtx).dom;
934
- const deriveContext = {
935
- ctx: __privateGet$3(this, _ctx$1),
936
- active,
937
- editorDom,
938
- blockDom: __privateGet$3(this, _element)
939
- };
940
- const virtualEl = {
941
- contextElement: dom,
942
- getBoundingClientRect: () => {
943
- if (__privateGet$3(this, _getPosition))
944
- return __privateGet$3(this, _getPosition).call(this, deriveContext);
945
- return dom.getBoundingClientRect();
946
- }
947
- };
948
- const middleware = [composedOffsetPosition_browser_min.flip()];
949
- if (__privateGet$3(this, _getOffset)) {
950
- const offsetOption = __privateGet$3(this, _getOffset).call(this, deriveContext);
951
- const offsetExt = composedOffsetPosition_browser_min.offset(offsetOption);
952
- middleware.push(offsetExt);
953
- }
954
- composedOffsetPosition_browser_min.computePosition(virtualEl, __privateGet$3(this, _element), {
955
- placement: __privateGet$3(this, _getPlacement) ? __privateGet$3(this, _getPlacement).call(this, deriveContext) : "left",
956
- middleware,
957
- platform: {
958
- ...composedOffsetPosition_browser_min.platform,
959
- getOffsetParent: (element) => composedOffsetPosition_browser_min.platform.getOffsetParent(element, composedOffsetPosition_browser_min.t)
960
- }
961
- }).then(({ x, y }) => {
962
- Object.assign(__privateGet$3(this, _element).style, {
963
- left: `${x}px`,
964
- top: `${y}px`
965
- });
966
- __privateGet$3(this, _element).dataset.show = "true";
967
- });
968
- };
969
- /// Hide the block.
970
- this.hide = () => {
971
- __privateGet$3(this, _element).dataset.show = "false";
972
- Object.assign(__privateGet$3(this, _element).style, {
973
- left: `-999px`,
974
- top: `-999px`
975
- });
976
- };
977
- __privateSet$3(this, _ctx$1, options.ctx);
978
- __privateSet$3(this, _element, options.content);
979
- __privateSet$3(this, _getOffset, options.getOffset);
980
- __privateSet$3(this, _getPosition, options.getPosition);
981
- __privateSet$3(this, _getPlacement, options.getPlacement);
982
- this.hide();
983
- }
984
- /// The context of current active node.
985
- get active() {
986
- return __privateGet$3(this, _activeNode);
987
- }
988
- }
989
- _element = new WeakMap();
990
- _ctx$1 = new WeakMap();
991
- _service = new WeakMap();
992
- _activeNode = new WeakMap();
993
- _initialized$1 = new WeakMap();
994
- _getOffset = new WeakMap();
995
- _getPosition = new WeakMap();
996
- _getPlacement = new WeakMap();
997
- _BlockProvider_instances = new WeakSet();
998
- /// @internal
999
- init_fn = function() {
1000
- var _a;
1001
- const view = __privateGet$3(this, _ctx$1).get(index.editorViewCtx);
1002
- (_a = view.dom.parentElement) == null ? void 0 : _a.appendChild(__privateGet$3(this, _element));
1003
- const service = __privateGet$3(this, _ctx$1).get(blockService.key);
1004
- service.bind(__privateGet$3(this, _ctx$1), (message) => {
1005
- if (message.type === "hide") {
1006
- this.hide();
1007
- __privateSet$3(this, _activeNode, null);
1008
- } else if (message.type === "show") {
1009
- this.show(message.active);
1010
- __privateSet$3(this, _activeNode, message.active);
1011
- }
1012
- });
1013
- __privateSet$3(this, _service, service);
1014
- __privateGet$3(this, _service).addEvent(__privateGet$3(this, _element));
1015
- __privateGet$3(this, _element).draggable = true;
1016
- };
1017
-
1018
- const block = [blockSpec, blockConfig, blockService, blockPlugin];
1019
- block.key = blockSpec.key;
1020
- block.pluginKey = blockPlugin.key;
1021
-
1022
- function slashFactory(id) {
1023
- const slashSpec = index.$ctx({}, `${id}_SLASH_SPEC`);
1024
- const slashPlugin = index.$prose((ctx) => {
1025
- const spec = ctx.get(slashSpec.key);
1026
- return new state.Plugin({
1027
- key: new state.PluginKey(`${id}_SLASH`),
1028
- ...spec
1029
- });
1030
- });
1031
- const result = [slashSpec, slashPlugin];
1032
- result.key = slashSpec.key;
1033
- result.pluginKey = slashPlugin.key;
1034
- slashSpec.meta = {
1035
- package: "@milkdown/plugin-slash",
1036
- displayName: `Ctx<slashSpec>|${id}`
1037
- };
1038
- slashPlugin.meta = {
1039
- package: "@milkdown/plugin-slash",
1040
- displayName: `Prose<slash>|${id}`
1041
- };
1042
- return result;
1043
- }
1044
-
1045
- var __typeError$2 = (msg) => {
1046
- throw TypeError(msg);
1047
- };
1048
- var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
1049
- var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1050
- 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);
1051
- 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);
1052
- var __privateMethod = (obj, member, method) => (__accessCheck$2(obj, member, "access private method"), method);
1053
- var _initialized, _debounce, _trigger, _shouldShow, _offset, _onUpdate, _SlashProvider_instances, _shouldShow_fn;
1054
- class SlashProvider {
1055
- constructor(options) {
1056
- __privateAdd$2(this, _SlashProvider_instances);
1057
- /// @internal
1058
- __privateAdd$2(this, _initialized, false);
1059
- /// @internal
1060
- __privateAdd$2(this, _debounce);
1061
- /// @internal
1062
- __privateAdd$2(this, _trigger);
1063
- /// @internal
1064
- __privateAdd$2(this, _shouldShow);
1065
- /// The offset to get the block. Default is 0.
1066
- __privateAdd$2(this, _offset);
1067
- /// On show callback.
1068
- this.onShow = () => {
1069
- };
1070
- /// On hide callback.
1071
- this.onHide = () => {
1072
- };
1073
- /// @internal
1074
- __privateAdd$2(this, _onUpdate, (view, prevState) => {
1075
- var _a;
1076
- const { state, composing } = view;
1077
- const { selection, doc } = state;
1078
- const { ranges } = selection;
1079
- const from = Math.min(...ranges.map((range) => range.$from.pos));
1080
- const to = Math.max(...ranges.map((range) => range.$to.pos));
1081
- const isSame = prevState && prevState.doc.eq(doc) && prevState.selection.eq(selection);
1082
- if (!__privateGet$2(this, _initialized)) {
1083
- (_a = view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
1084
- __privateSet$2(this, _initialized, true);
1085
- }
1086
- if (composing || isSame)
1087
- return;
1088
- if (!__privateGet$2(this, _shouldShow).call(this, view, prevState)) {
1089
- this.hide();
1090
- return;
1091
- }
1092
- const virtualEl = {
1093
- getBoundingClientRect: () => prose.posToDOMRect(view, from, to)
1094
- };
1095
- composedOffsetPosition_browser_min.computePosition(virtualEl, this.element, {
1096
- placement: "bottom-start",
1097
- middleware: [composedOffsetPosition_browser_min.flip(), composedOffsetPosition_browser_min.offset(__privateGet$2(this, _offset))],
1098
- platform: {
1099
- ...composedOffsetPosition_browser_min.platform,
1100
- getOffsetParent: (element) => composedOffsetPosition_browser_min.platform.getOffsetParent(element, composedOffsetPosition_browser_min.t)
1101
- }
1102
- }).then(({ x, y }) => {
1103
- Object.assign(this.element.style, {
1104
- left: `${x}px`,
1105
- top: `${y}px`
1106
- });
1107
- });
1108
- this.show();
1109
- });
1110
- /// Update provider state by editor view.
1111
- this.update = (view, prevState) => {
1112
- const updater = index$1.debounce(__privateGet$2(this, _onUpdate), __privateGet$2(this, _debounce));
1113
- updater(view, prevState);
1114
- };
1115
- /// Get the content of the current text block.
1116
- /// Pass the `matchNode` function to determine whether the current node should be matched, by default, it will match the paragraph node.
1117
- this.getContent = (view, matchNode = (node) => node.type.name === "paragraph") => {
1118
- const { selection } = view.state;
1119
- const { empty, $from } = selection;
1120
- const isTextBlock = view.state.selection instanceof state.TextSelection;
1121
- const isSlashChildren = this.element.contains(document.activeElement);
1122
- const notHasFocus = !view.hasFocus() && !isSlashChildren;
1123
- const isReadonly = !view.editable;
1124
- const paragraph = prose.findParentNode(matchNode)(view.state.selection);
1125
- const isNotInParagraph = !paragraph;
1126
- if (notHasFocus || isReadonly || !empty || !isTextBlock || isNotInParagraph)
1127
- return;
1128
- return $from.parent.textBetween(Math.max(0, $from.parentOffset - 500), $from.parentOffset, void 0, "\uFFFC");
1129
- };
1130
- /// Destroy the slash.
1131
- this.destroy = () => {
1132
- };
1133
- /// Show the slash.
1134
- this.show = () => {
1135
- this.element.dataset.show = "true";
1136
- this.onShow();
1137
- };
1138
- /// Hide the slash.
1139
- this.hide = () => {
1140
- this.element.dataset.show = "false";
1141
- this.onHide();
1142
- };
1143
- var _a, _b, _c;
1144
- this.element = options.content;
1145
- __privateSet$2(this, _debounce, (_a = options.debounce) != null ? _a : 200);
1146
- __privateSet$2(this, _shouldShow, (_b = options.shouldShow) != null ? _b : __privateMethod(this, _SlashProvider_instances, _shouldShow_fn));
1147
- __privateSet$2(this, _trigger, (_c = options.trigger) != null ? _c : "/");
1148
- __privateSet$2(this, _offset, options.offset);
1149
- }
1150
- }
1151
- _initialized = new WeakMap();
1152
- _debounce = new WeakMap();
1153
- _trigger = new WeakMap();
1154
- _shouldShow = new WeakMap();
1155
- _offset = new WeakMap();
1156
- _onUpdate = new WeakMap();
1157
- _SlashProvider_instances = new WeakSet();
1158
- /// @internal
1159
- _shouldShow_fn = function(view) {
1160
- const currentTextBlockContent = this.getContent(view);
1161
- if (!currentTextBlockContent)
1162
- return false;
1163
- const target = currentTextBlockContent.at(-1);
1164
- if (!target)
1165
- return false;
1166
- return Array.isArray(__privateGet$2(this, _trigger)) ? __privateGet$2(this, _trigger).includes(target) : __privateGet$2(this, _trigger) === target;
1167
- };
1168
-
1169
- const textIcon = atomico.html`
1170
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1171
- <g clip-path="url(#clip0_992_5547)">
1172
- <path d="M5 5.5C5 6.33 5.67 7 6.5 7H10.5V17.5C10.5 18.33 11.17 19 12 19C12.83 19 13.5 18.33 13.5 17.5V7H17.5C18.33 7 19 6.33 19 5.5C19 4.67 18.33 4 17.5 4H6.5C5.67 4 5 4.67 5 5.5Z" fill="#817567"/>
1173
- </g>
1174
- <defs>
1175
- <clipPath id="clip0_992_5547">
1176
- <rect width="24" height="24" fill="white"/>
1177
- </clipPath>
1178
- </defs>
1179
- </svg>
1180
- `;
1181
- const h1Icon = atomico.html`
1182
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1183
- <g clip-path="url(#clip0_992_5553)">
1184
- <path d="M19 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 3ZM19 19H5V5H19V19ZM12 17H14V7H10V9H12V17Z" fill="#817567"/>
1185
- </g>
1186
- <defs>
1187
- <clipPath id="clip0_992_5553">
1188
- <rect width="24" height="24" fill="white"/>
1189
- </clipPath>
1190
- </defs>
1191
- </svg>
1192
- `;
1193
- const h2Icon = atomico.html`
1194
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1195
- <g clip-path="url(#clip0_992_5559)">
1196
- <path d="M19 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 3ZM19 19H5V5H19V19ZM15 15H11V13H13C14.1 13 15 12.11 15 11V9C15 7.89 14.1 7 13 7H9V9H13V11H11C9.9 11 9 11.89 9 13V17H15V15Z" fill="#817567"/>
1197
- </g>
1198
- <defs>
1199
- <clipPath id="clip0_992_5559">
1200
- <rect width="24" height="24" fill="white"/>
1201
- </clipPath>
1202
- </defs>
1203
- </svg>
1204
- `;
1205
- const h3Icon = atomico.html`
1206
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1207
- <g clip-path="url(#clip0_992_5565)">
1208
- <path d="M19 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 3ZM19 19H5V5H19V19ZM15 15V13.5C15 12.67 14.33 12 13.5 12C14.33 12 15 11.33 15 10.5V9C15 7.89 14.1 7 13 7H9V9H13V11H11V13H13V15H9V17H13C14.1 17 15 16.11 15 15Z" fill="#817567"/>
1209
- </g>
1210
- <defs>
1211
- <clipPath id="clip0_992_5565">
1212
- <rect width="24" height="24" fill="white"/>
1213
- </clipPath>
1214
- </defs>
1215
- </svg>
1216
- `;
1217
- const h4Icon = atomico.html`
1218
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1219
- <g clip-path="url(#clip0_977_7757)">
1220
- <path d="M19.04 3H5.04004C3.94004 3 3.04004 3.9 3.04004 5V19C3.04004 20.1 3.94004 21 5.04004 21H19.04C20.14 21 21.04 20.1 21.04 19V5C21.04 3.9 20.14 3 19.04 3ZM19.04 19H5.04004V5H19.04V19ZM13.04 17H15.04V7H13.04V11H11.04V7H9.04004V13H13.04V17Z" fill="#817567"/>
1221
- </g>
1222
- <defs>
1223
- <clipPath id="clip0_977_7757">
1224
- <rect width="24" height="24" fill="white"/>
1225
- </clipPath>
1226
- </defs>
1227
- </svg>
1228
- `;
1229
- const h5Icon = atomico.html`
1230
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1231
- <g clip-path="url(#clip0_977_7760)">
1232
- <path d="M19 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 3ZM19 19H5V5H19V19ZM15 15V13C15 11.89 14.1 11 13 11H11V9H15V7H9V13H13V15H9V17H13C14.1 17 15 16.11 15 15Z" fill="#817567"/>
1233
- </g>
1234
- <defs>
1235
- <clipPath id="clip0_977_7760">
1236
- <rect width="24" height="24" fill="white"/>
1237
- </clipPath>
1238
- </defs>
1239
- </svg>
1240
- `;
1241
- const h6Icon = atomico.html`
1242
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1243
- <g clip-path="url(#clip0_977_7763)">
1244
- <path d="M11 17H13C14.1 17 15 16.11 15 15V13C15 11.89 14.1 11 13 11H11V9H15V7H11C9.9 7 9 7.89 9 9V15C9 16.11 9.9 17 11 17ZM11 13H13V15H11V13ZM19 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 3ZM19 19H5V5H19V19Z" fill="#817567"/>
1245
- </g>
1246
- <defs>
1247
- <clipPath id="clip0_977_7763">
1248
- <rect width="24" height="24" fill="white"/>
1249
- </clipPath>
1250
- </defs>
1251
- </svg>
1252
- `;
1253
- const bulletListIcon = atomico.html`
1254
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1255
- <g clip-path="url(#clip0_977_8070)">
1256
- <path d="M4 10.5C3.17 10.5 2.5 11.17 2.5 12C2.5 12.83 3.17 13.5 4 13.5C4.83 13.5 5.5 12.83 5.5 12C5.5 11.17 4.83 10.5 4 10.5ZM4 4.5C3.17 4.5 2.5 5.17 2.5 6C2.5 6.83 3.17 7.5 4 7.5C4.83 7.5 5.5 6.83 5.5 6C5.5 5.17 4.83 4.5 4 4.5ZM4 16.5C3.17 16.5 2.5 17.18 2.5 18C2.5 18.82 3.18 19.5 4 19.5C4.82 19.5 5.5 18.82 5.5 18C5.5 17.18 4.83 16.5 4 16.5ZM8 19H20C20.55 19 21 18.55 21 18C21 17.45 20.55 17 20 17H8C7.45 17 7 17.45 7 18C7 18.55 7.45 19 8 19ZM8 13H20C20.55 13 21 12.55 21 12C21 11.45 20.55 11 20 11H8C7.45 11 7 11.45 7 12C7 12.55 7.45 13 8 13ZM7 6C7 6.55 7.45 7 8 7H20C20.55 7 21 6.55 21 6C21 5.45 20.55 5 20 5H8C7.45 5 7 5.45 7 6Z" fill="#817567"/>
1257
- </g>
1258
- <defs>
1259
- <clipPath id="clip0_977_8070">
1260
- <rect width="24" height="24" fill="white"/>
1261
- </clipPath>
1262
- </defs>
1263
- </svg>
1264
- `;
1265
- const orderedListIcon = atomico.html`
1266
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1267
- <g clip-path="url(#clip0_977_8067)">
1268
- <path d="M8 7H20C20.55 7 21 6.55 21 6C21 5.45 20.55 5 20 5H8C7.45 5 7 5.45 7 6C7 6.55 7.45 7 8 7ZM20 17H8C7.45 17 7 17.45 7 18C7 18.55 7.45 19 8 19H20C20.55 19 21 18.55 21 18C21 17.45 20.55 17 20 17ZM20 11H8C7.45 11 7 11.45 7 12C7 12.55 7.45 13 8 13H20C20.55 13 21 12.55 21 12C21 11.45 20.55 11 20 11ZM4.5 16H2.5C2.22 16 2 16.22 2 16.5C2 16.78 2.22 17 2.5 17H4V17.5H3.5C3.22 17.5 3 17.72 3 18C3 18.28 3.22 18.5 3.5 18.5H4V19H2.5C2.22 19 2 19.22 2 19.5C2 19.78 2.22 20 2.5 20H4.5C4.78 20 5 19.78 5 19.5V16.5C5 16.22 4.78 16 4.5 16ZM2.5 5H3V7.5C3 7.78 3.22 8 3.5 8C3.78 8 4 7.78 4 7.5V4.5C4 4.22 3.78 4 3.5 4H2.5C2.22 4 2 4.22 2 4.5C2 4.78 2.22 5 2.5 5ZM4.5 10H2.5C2.22 10 2 10.22 2 10.5C2 10.78 2.22 11 2.5 11H3.8L2.12 12.96C2.04 13.05 2 13.17 2 13.28V13.5C2 13.78 2.22 14 2.5 14H4.5C4.78 14 5 13.78 5 13.5C5 13.22 4.78 13 4.5 13H3.2L4.88 11.04C4.96 10.95 5 10.83 5 10.72V10.5C5 10.22 4.78 10 4.5 10Z" fill="#817567"/>
1269
- </g>
1270
- <defs>
1271
- <clipPath id="clip0_977_8067">
1272
- <rect width="24" height="24" fill="white"/>
1273
- </clipPath>
1274
- </defs>
1275
- </svg>
1276
- `;
1277
- const quoteIcon = atomico.html`
1278
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1279
- <g clip-path="url(#clip0_977_7897)">
1280
- <path d="M7.17 17C7.68 17 8.15 16.71 8.37 16.26L9.79 13.42C9.93 13.14 10 12.84 10 12.53V8C10 7.45 9.55 7 9 7H5C4.45 7 4 7.45 4 8V12C4 12.55 4.45 13 5 13H7L5.97 15.06C5.52 15.95 6.17 17 7.17 17ZM17.17 17C17.68 17 18.15 16.71 18.37 16.26L19.79 13.42C19.93 13.14 20 12.84 20 12.53V8C20 7.45 19.55 7 19 7H15C14.45 7 14 7.45 14 8V12C14 12.55 14.45 13 15 13H17L15.97 15.06C15.52 15.95 16.17 17 17.17 17Z" fill="#817567"/>
1281
- </g>
1282
- <defs>
1283
- <clipPath id="clip0_977_7897">
1284
- <rect width="24" height="24" fill="white"/>
1285
- </clipPath>
1286
- </defs>
1287
- </svg>
1288
- `;
1289
- const dividerIcon = atomico.html`
1290
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1291
- <g clip-path="url(#clip0_977_7900)">
1292
- <path fill-rule="evenodd" clip-rule="evenodd" d="M19 13H5C4.45 13 4 12.55 4 12C4 11.45 4.45 11 5 11H19C19.55 11 20 11.45 20 12C20 12.55 19.55 13 19 13Z" fill="#817567"/>
1293
- </g>
1294
- <defs>
1295
- <clipPath id="clip0_977_7900">
1296
- <rect width="24" height="24" fill="white"/>
1297
- </clipPath>
1298
- </defs>
1299
- </svg>
1300
- `;
1301
- const imageIcon = atomico.html`
1302
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1303
- <g clip-path="url(#clip0_977_8075)">
1304
- <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"/>
1305
- </g>
1306
- <defs>
1307
- <clipPath id="clip0_977_8075">
1308
- <rect width="24" height="24" fill="white"/>
1309
- </clipPath>
1310
- </defs>
1311
- </svg>
1312
- `;
1313
- const codeIcon = atomico.html`
1314
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1315
- <g clip-path="url(#clip0_977_8081)">
1316
- <path d="M9.4 16.6L4.8 12L9.4 7.4L8 6L2 12L8 18L9.4 16.6ZM14.6 16.6L19.2 12L14.6 7.4L16 6L22 12L16 18L14.6 16.6Z" fill="#817567"/>
1317
- </g>
1318
- <defs>
1319
- <clipPath id="clip0_977_8081">
1320
- <rect width="24" height="24" fill="white"/>
1321
- </clipPath>
1322
- </defs>
1323
- </svg>
1324
- `;
1325
-
1326
- function clearRange(tr) {
1327
- const { $from, $to } = tr.selection;
1328
- const { pos: from } = $from;
1329
- const { pos: to } = $to;
1330
- tr = tr.deleteRange(from - $from.node().content.size, to);
1331
- return tr;
1332
- }
1333
- function setBlockType(tr, nodeType, attrs = null) {
1334
- const { from, to } = tr.selection;
1335
- return tr.setBlockType(from, to, nodeType, attrs);
1336
- }
1337
- function wrapInBlockType(tr, nodeType, attrs = null) {
1338
- const { $from, $to } = tr.selection;
1339
- const range = $from.blockRange($to);
1340
- const wrapping = range && transform.findWrapping(range, nodeType, attrs);
1341
- if (!wrapping)
1342
- return null;
1343
- return tr.wrap(range, wrapping);
1344
- }
1345
- function addBlockType(tr, nodeType, attrs = null) {
1346
- const node = nodeType.createAndFill(attrs);
1347
- if (!node)
1348
- return null;
1349
- return tr.replaceSelectionWith(node);
1350
- }
1351
- function clearContentAndSetBlockType(nodeType, attrs = null) {
1352
- return (state, dispatch) => {
1353
- if (dispatch) {
1354
- const tr = setBlockType(clearRange(state.tr), nodeType, attrs);
1355
- dispatch(tr.scrollIntoView());
1356
- }
1357
- return true;
1358
- };
1359
- }
1360
- function clearContentAndWrapInBlockType(nodeType, attrs = null) {
1361
- return (state, dispatch) => {
1362
- const tr = wrapInBlockType(clearRange(state.tr), nodeType, attrs);
1363
- if (!tr)
1364
- return false;
1365
- if (dispatch)
1366
- dispatch(tr.scrollIntoView());
1367
- return true;
1368
- };
1369
- }
1370
- function clearContentAndAddBlockType(nodeType, attrs = null) {
1371
- return (state, dispatch) => {
1372
- const tr = addBlockType(clearRange(state.tr), nodeType, attrs);
1373
- if (!tr)
1374
- return false;
1375
- if (dispatch)
1376
- dispatch(tr.scrollIntoView());
1377
- return true;
1378
- };
1379
- }
1380
- function getGroups(filter) {
1381
- let groups = [
1382
- {
1383
- key: "text",
1384
- label: "Text",
1385
- items: [
1386
- {
1387
- key: "text",
1388
- label: "Text",
1389
- icon: textIcon,
1390
- onRun: (ctx) => {
1391
- const view = ctx.get(index.editorViewCtx);
1392
- const { dispatch, state } = view;
1393
- const command = clearContentAndSetBlockType(index.paragraphSchema.type(ctx));
1394
- command(state, dispatch);
1395
- }
1396
- },
1397
- {
1398
- key: "h1",
1399
- label: "Heading 1",
1400
- icon: h1Icon,
1401
- onRun: (ctx) => {
1402
- const view = ctx.get(index.editorViewCtx);
1403
- const { dispatch, state } = view;
1404
- const command = clearContentAndSetBlockType(index.headingSchema.type(ctx), { level: 1 });
1405
- command(state, dispatch);
1406
- }
1407
- },
1408
- {
1409
- key: "h2",
1410
- label: "Heading 2",
1411
- icon: h2Icon,
1412
- onRun: (ctx) => {
1413
- const view = ctx.get(index.editorViewCtx);
1414
- const { dispatch, state } = view;
1415
- const command = clearContentAndSetBlockType(index.headingSchema.type(ctx), { level: 2 });
1416
- command(state, dispatch);
1417
- }
1418
- },
1419
- {
1420
- key: "h3",
1421
- label: "Heading 3",
1422
- icon: h3Icon,
1423
- onRun: (ctx) => {
1424
- const view = ctx.get(index.editorViewCtx);
1425
- const { dispatch, state } = view;
1426
- const command = clearContentAndSetBlockType(index.headingSchema.type(ctx), { level: 3 });
1427
- command(state, dispatch);
1428
- }
1429
- },
1430
- {
1431
- key: "h4",
1432
- label: "Heading 4",
1433
- icon: h4Icon,
1434
- onRun: (ctx) => {
1435
- const view = ctx.get(index.editorViewCtx);
1436
- const { dispatch, state } = view;
1437
- const command = clearContentAndSetBlockType(index.headingSchema.type(ctx), { level: 4 });
1438
- command(state, dispatch);
1439
- }
1440
- },
1441
- {
1442
- key: "h5",
1443
- label: "Heading 5",
1444
- icon: h5Icon,
1445
- onRun: (ctx) => {
1446
- const view = ctx.get(index.editorViewCtx);
1447
- const { dispatch, state } = view;
1448
- const command = clearContentAndSetBlockType(index.headingSchema.type(ctx), { level: 5 });
1449
- command(state, dispatch);
1450
- }
1451
- },
1452
- {
1453
- key: "h6",
1454
- label: "Heading 6",
1455
- icon: h6Icon,
1456
- onRun: (ctx) => {
1457
- const view = ctx.get(index.editorViewCtx);
1458
- const { dispatch, state } = view;
1459
- const command = clearContentAndSetBlockType(index.headingSchema.type(ctx), { level: 6 });
1460
- command(state, dispatch);
1461
- }
1462
- },
1463
- {
1464
- key: "quote",
1465
- label: "Quote",
1466
- icon: quoteIcon,
1467
- onRun: (ctx) => {
1468
- const view = ctx.get(index.editorViewCtx);
1469
- const { dispatch, state } = view;
1470
- const command = clearContentAndWrapInBlockType(index.blockquoteSchema.type(ctx));
1471
- command(state, dispatch);
1472
- }
1473
- },
1474
- {
1475
- key: "divider",
1476
- label: "Divider",
1477
- icon: dividerIcon,
1478
- onRun: (ctx) => {
1479
- const view = ctx.get(index.editorViewCtx);
1480
- const { dispatch, state } = view;
1481
- const command = clearContentAndAddBlockType(index.hrSchema.type(ctx));
1482
- command(state, dispatch);
1483
- }
1484
- }
1485
- ]
1486
- },
1487
- {
1488
- key: "list",
1489
- label: "List",
1490
- items: [
1491
- {
1492
- key: "bullet-list",
1493
- label: "Bullet List",
1494
- icon: bulletListIcon,
1495
- onRun: (ctx) => {
1496
- const view = ctx.get(index.editorViewCtx);
1497
- const { dispatch, state } = view;
1498
- const command = clearContentAndWrapInBlockType(index.bulletListSchema.type(ctx));
1499
- command(state, dispatch);
1500
- }
1501
- },
1502
- {
1503
- key: "ordered-list",
1504
- label: "Ordered List",
1505
- icon: orderedListIcon,
1506
- onRun: (ctx) => {
1507
- const view = ctx.get(index.editorViewCtx);
1508
- const { dispatch, state } = view;
1509
- const command = clearContentAndWrapInBlockType(index.orderedListSchema.type(ctx));
1510
- command(state, dispatch);
1511
- }
1512
- }
1513
- ]
1514
- },
1515
- {
1516
- key: "advanced",
1517
- label: "Advanced",
1518
- items: [
1519
- {
1520
- key: "image",
1521
- label: "Image",
1522
- icon: imageIcon,
1523
- onRun: (ctx) => {
1524
- const view = ctx.get(index.editorViewCtx);
1525
- const { dispatch, state } = view;
1526
- const command = clearContentAndAddBlockType(schema.imageBlockSchema.type(ctx));
1527
- command(state, dispatch);
1528
- }
1529
- },
1530
- {
1531
- key: "code",
1532
- label: "Code",
1533
- icon: codeIcon,
1534
- onRun: (ctx) => {
1535
- const view = ctx.get(index.editorViewCtx);
1536
- const { dispatch, state } = view;
1537
- const command = clearContentAndAddBlockType(index.codeBlockSchema.type(ctx));
1538
- command(state, dispatch);
1539
- }
1540
- }
1541
- ]
1542
- }
1543
- ];
1544
- if (filter) {
1545
- groups = groups.map((group) => {
1546
- const items2 = group.items.filter((item) => item.label.toLowerCase().includes(filter.toLowerCase()));
1547
- return {
1548
- ...group,
1549
- items: items2
1550
- };
1551
- }).filter((group) => group.items.length > 0);
1552
- }
1553
- const items = groups.flatMap((groups2) => groups2.items);
1554
- items.forEach((item, index) => {
1555
- Object.assign(item, {
1556
- index
1557
- });
1558
- });
1559
- groups.reduce((acc, group) => {
1560
- const end = acc + group.items.length;
1561
- Object.assign(group, {
1562
- range: [acc, end]
1563
- });
1564
- return end;
1565
- }, 0);
1566
- return {
1567
- groups,
1568
- size: items.length
1569
- };
1570
- }
1571
-
1572
- const menuComponent = ({
1573
- show,
1574
- hide,
1575
- ctx,
1576
- filter
1577
- }) => {
1578
- const { groups, size } = atomico.useMemo(() => getGroups(filter), [filter]);
1579
- const host = atomico.useHost();
1580
- const [hoverIndex, setHoverIndex] = atomico.useState(0);
1581
- const root = atomico.useMemo(() => host.current.getRootNode(), [host]);
1582
- const prevMousePosition = atomico.useRef({ x: -999, y: -999 });
1583
- const onMouseMove = atomico.useCallback((e) => {
1584
- const prevPos = prevMousePosition.current;
1585
- if (!prevPos)
1586
- return;
1587
- const { x, y } = e;
1588
- prevPos.x = x;
1589
- prevPos.y = y;
1590
- }, []);
1591
- atomico.useEffect(() => {
1592
- if (size === 0 && show)
1593
- hide == null ? void 0 : hide();
1594
- }, [size, show]);
1595
- const onHover = atomico.useCallback((index, after) => {
1596
- setHoverIndex((prev) => {
1597
- const next = typeof index === "function" ? index(prev) : index;
1598
- after == null ? void 0 : after(next);
1599
- return next;
1600
- });
1601
- }, []);
1602
- const scrollToIndex = atomico.useCallback((index) => {
1603
- const target = host.current.querySelector(`[data-index="${index}"]`);
1604
- const scrollRoot = host.current.querySelector(".menu-groups");
1605
- if (!target || !scrollRoot)
1606
- return;
1607
- scrollRoot.scrollTop = target.offsetTop - scrollRoot.offsetTop;
1608
- }, []);
1609
- const runByIndex = atomico.useCallback((index) => {
1610
- const item = groups.flatMap((group) => group.items).at(index);
1611
- if (item && ctx)
1612
- item.onRun(ctx);
1613
- hide == null ? void 0 : hide();
1614
- }, [groups]);
1615
- const onKeydown = atomico.useCallback((e) => {
1616
- if (e.key === "Escape") {
1617
- e.preventDefault();
1618
- hide == null ? void 0 : hide();
1619
- return;
1620
- }
1621
- if (e.key === "ArrowDown") {
1622
- e.preventDefault();
1623
- return onHover((index) => index < size - 1 ? index + 1 : index, scrollToIndex);
1624
- }
1625
- if (e.key === "ArrowUp") {
1626
- e.preventDefault();
1627
- return onHover((index) => index <= 0 ? index : index - 1, scrollToIndex);
1628
- }
1629
- if (e.key === "ArrowLeft") {
1630
- e.preventDefault();
1631
- return onHover((index) => {
1632
- const group = groups.find((group2) => group2.range[0] <= index && group2.range[1] > index);
1633
- if (!group)
1634
- return index;
1635
- const prevGroup = groups[groups.indexOf(group) - 1];
1636
- if (!prevGroup)
1637
- return index;
1638
- return prevGroup.range[1] - 1;
1639
- }, scrollToIndex);
1640
- }
1641
- if (e.key === "ArrowRight") {
1642
- e.preventDefault();
1643
- return onHover((index) => {
1644
- const group = groups.find((group2) => group2.range[0] <= index && group2.range[1] > index);
1645
- if (!group)
1646
- return index;
1647
- const nextGroup = groups[groups.indexOf(group) + 1];
1648
- if (!nextGroup)
1649
- return index;
1650
- return nextGroup.range[0];
1651
- }, scrollToIndex);
1652
- }
1653
- if (e.key === "Enter") {
1654
- e.preventDefault();
1655
- runByIndex(hoverIndex);
1656
- }
1657
- }, [hide, groups, hoverIndex]);
1658
- const onMouseEnter = atomico.useCallback((index) => {
1659
- return (e) => {
1660
- const prevPos = prevMousePosition.current;
1661
- if (!prevPos)
1662
- return;
1663
- const { x, y } = e;
1664
- if (x === prevPos.x && y === prevPos.y)
1665
- return;
1666
- onHover(index);
1667
- };
1668
- }, []);
1669
- atomico.useEffect(() => {
1670
- if (show)
1671
- root.addEventListener("keydown", onKeydown, { capture: true });
1672
- else root.removeEventListener("keydown", onKeydown, { capture: true });
1673
- return () => {
1674
- root.removeEventListener("keydown", onKeydown, { capture: true });
1675
- };
1676
- }, [show, onKeydown]);
1677
- return atomico.html`
1678
- <host onmousedown=${(e) => e.preventDefault()}>
1679
- <nav class="tab-group">
1680
- <ul>
1681
- ${groups.map((group) => atomico.html`<li
1682
- key=${group.key}
1683
- onmousedown=${() => onHover(group.range[0], scrollToIndex)}
1684
- class=${hoverIndex >= group.range[0] && hoverIndex < group.range[1] ? "selected" : ""}
1685
- >
1686
- ${group.label}
1687
- </li>`)}
1688
- </ul>
1689
- </nav>
1690
- <div class="menu-groups" onmousemove=${onMouseMove}>
1691
- ${groups.map((group) => {
1692
- return atomico.html`
1693
- <div key=${group.key} class="menu-group">
1694
- <h6>${group.label}</h6>
1695
- <ul>
1696
- ${group.items.map(
1697
- (item) => atomico.html`<li
1698
- key=${item.key}
1699
- data-index=${item.index}
1700
- class=${hoverIndex === item.index ? "hover" : ""}
1701
- onmouseenter=${onMouseEnter(item.index)}
1702
- onmousedown=${() => {
1703
- var _a;
1704
- (_a = host.current.querySelector(`[data-index="${item.index}"]`)) == null ? void 0 : _a.classList.add("active");
1705
- }}
1706
- onmouseup=${() => {
1707
- var _a;
1708
- (_a = host.current.querySelector(`[data-index="${item.index}"]`)) == null ? void 0 : _a.classList.remove("active");
1709
- runByIndex(item.index);
1710
- }}
1711
- >
1712
- ${item.icon}
1713
- <span>${item.label}</span>
1714
- </li>`
1715
- )}
1716
- </ul>
1717
- </div>
1718
- `;
1719
- })}
1720
- </div>
1721
- </host>
1722
- `;
1723
- };
1724
- menuComponent.props = {
1725
- ctx: Object,
1726
- show: Boolean,
1727
- filter: String,
1728
- hide: Function
1729
- };
1730
- const MenuElement = atomico.c(menuComponent);
1731
-
1732
- var __typeError$1 = (msg) => {
1733
- throw TypeError(msg);
1734
- };
1735
- var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
1736
- var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1737
- 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);
1738
- 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);
1739
- var _content$1, _slashProvider, _programmaticallyPos;
1740
- const menu = slashFactory("CREPE_MENU");
1741
- const menuAPI = index.$ctx({
1742
- show: () => {
1743
- },
1744
- hide: () => {
1745
- }
1746
- }, "menuAPICtx");
1747
- index$2.defIfNotExists("milkdown-slash-menu", MenuElement);
1748
- function configureMenu(ctx) {
1749
- ctx.set(menu.key, {
1750
- view: (view) => new MenuView(ctx, view)
1751
- });
1752
- }
1753
- class MenuView {
1754
- constructor(ctx, view) {
1755
- __privateAdd$1(this, _content$1);
1756
- __privateAdd$1(this, _slashProvider);
1757
- __privateAdd$1(this, _programmaticallyPos, null);
1758
- this.update = (view) => {
1759
- __privateGet$1(this, _slashProvider).update(view);
1760
- };
1761
- this.show = (pos) => {
1762
- __privateSet$1(this, _programmaticallyPos, pos);
1763
- __privateGet$1(this, _content$1).filter = "";
1764
- __privateGet$1(this, _slashProvider).show();
1765
- };
1766
- this.hide = () => {
1767
- __privateSet$1(this, _programmaticallyPos, null);
1768
- __privateGet$1(this, _slashProvider).hide();
1769
- };
1770
- this.destroy = () => {
1771
- __privateGet$1(this, _slashProvider).destroy();
1772
- __privateGet$1(this, _content$1).remove();
1773
- };
1774
- __privateSet$1(this, _content$1, new MenuElement());
1775
- __privateGet$1(this, _content$1).hide = this.hide;
1776
- __privateGet$1(this, _content$1).ctx = ctx;
1777
- const self = this;
1778
- __privateSet$1(this, _slashProvider, new SlashProvider({
1779
- content: __privateGet$1(this, _content$1),
1780
- debounce: 20,
1781
- shouldShow(view2) {
1782
- if (index$2.isInCodeBlock(view2.state.selection) || index$2.isInList(view2.state.selection))
1783
- return false;
1784
- const currentText = this.getContent(view2, (node) => ["paragraph", "heading"].includes(node.type.name));
1785
- if (currentText == null)
1786
- return false;
1787
- const pos = __privateGet$1(self, _programmaticallyPos);
1788
- __privateGet$1(self, _content$1).filter = currentText.startsWith("/") ? currentText.slice(1) : currentText;
1789
- if (typeof pos === "number") {
1790
- if (view2.state.doc.resolve(pos).node() !== view2.state.doc.resolve(view2.state.selection.from).node()) {
1791
- __privateSet$1(self, _programmaticallyPos, null);
1792
- return false;
1793
- }
1794
- return true;
1795
- }
1796
- if (!currentText.startsWith("/"))
1797
- return false;
1798
- return true;
1799
- }
1800
- }));
1801
- __privateGet$1(this, _slashProvider).onShow = () => {
1802
- __privateGet$1(this, _content$1).show = true;
1803
- };
1804
- __privateGet$1(this, _slashProvider).onHide = () => {
1805
- __privateGet$1(this, _content$1).show = false;
1806
- };
1807
- this.update(view);
1808
- ctx.set(menuAPI.key, {
1809
- show: (pos) => this.show(pos),
1810
- hide: () => this.hide()
1811
- });
1812
- }
1813
- }
1814
- _content$1 = new WeakMap();
1815
- _slashProvider = new WeakMap();
1816
- _programmaticallyPos = new WeakMap();
1817
-
1818
- const menuIcon = atomico.html`
1819
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1820
- <g clip-path="url(#clip0_971_7680)">
1821
- <path d="M11 18C11 19.1 10.1 20 9 20C7.9 20 7 19.1 7 18C7 16.9 7.9 16 9 16C10.1 16 11 16.9 11 18ZM9 10C7.9 10 7 10.9 7 12C7 13.1 7.9 14 9 14C10.1 14 11 13.1 11 12C11 10.9 10.1 10 9 10ZM9 4C7.9 4 7 4.9 7 6C7 7.1 7.9 8 9 8C10.1 8 11 7.1 11 6C11 4.9 10.1 4 9 4ZM15 8C16.1 8 17 7.1 17 6C17 4.9 16.1 4 15 4C13.9 4 13 4.9 13 6C13 7.1 13.9 8 15 8ZM15 10C13.9 10 13 10.9 13 12C13 13.1 13.9 14 15 14C16.1 14 17 13.1 17 12C17 10.9 16.1 10 15 10ZM15 16C13.9 16 13 16.9 13 18C13 19.1 13.9 20 15 20C16.1 20 17 19.1 17 18C17 16.9 16.1 16 15 16Z" fill="#817567"/>
1822
- </g>
1823
- <defs>
1824
- <clipPath id="clip0_971_7680">
1825
- <rect width="24" height="24" fill="white"/>
1826
- </clipPath>
1827
- </defs>
1828
- </svg>
1829
- `;
1830
- const plusIcon = atomico.html`
1831
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
1832
- <g clip-path="url(#clip0_971_7676)">
1833
- <path d="M18 13H13V18C13 18.55 12.55 19 12 19C11.45 19 11 18.55 11 18V13H6C5.45 13 5 12.55 5 12C5 11.45 5.45 11 6 11H11V6C11 5.45 11.45 5 12 5C12.55 5 13 5.45 13 6V11H18C18.55 11 19 11.45 19 12C19 12.55 18.55 13 18 13Z" fill="#817567"/>
1834
- </g>
1835
- <defs>
1836
- <clipPath id="clip0_971_7676">
1837
- <rect width="24" height="24" fill="white"/>
1838
- </clipPath>
1839
- </defs>
1840
- </svg>
1841
- `;
1842
- const blockHandleComponent = ({ onAdd }) => {
1843
- const ref = atomico.useRef();
1844
- atomico.useEffect(() => {
1845
- var _a;
1846
- (_a = ref.current) == null ? void 0 : _a.classList.remove("active");
1847
- });
1848
- const onMouseDown = (e) => {
1849
- var _a;
1850
- e.preventDefault();
1851
- e.stopPropagation();
1852
- (_a = ref.current) == null ? void 0 : _a.classList.add("active");
1853
- };
1854
- const onMouseUp = (e) => {
1855
- var _a;
1856
- e.preventDefault();
1857
- e.stopPropagation();
1858
- onAdd == null ? void 0 : onAdd();
1859
- (_a = ref.current) == null ? void 0 : _a.classList.remove("active");
1860
- };
1861
- return atomico.html`
1862
- <host>
1863
- <div ref=${ref} onmousedown=${onMouseDown} onmouseup=${onMouseUp} class="operation-item">
1864
- ${plusIcon}
1865
- </div>
1866
- <div class="operation-item">
1867
- ${menuIcon}
1868
- </div>
1869
- </host>
1870
- `;
1871
- };
1872
- blockHandleComponent.props = {
1873
- show: Boolean,
1874
- onAdd: Function
1875
- };
1876
- const BlockHandleElement = atomico.c(blockHandleComponent);
1877
-
1878
- var __typeError = (msg) => {
1879
- throw TypeError(msg);
1880
- };
1881
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
1882
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1883
- 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);
1884
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
1885
- var _content, _provider, _ctx;
1886
- class BlockHandleView {
1887
- constructor(ctx) {
1888
- __privateAdd(this, _content);
1889
- __privateAdd(this, _provider);
1890
- __privateAdd(this, _ctx);
1891
- this.update = () => {
1892
- __privateGet(this, _provider).update();
1893
- };
1894
- this.destroy = () => {
1895
- __privateGet(this, _provider).destroy();
1896
- __privateGet(this, _content).remove();
1897
- };
1898
- this.onAdd = () => {
1899
- const ctx = __privateGet(this, _ctx);
1900
- const view = ctx.get(index.editorViewCtx);
1901
- if (!view.hasFocus())
1902
- view.focus();
1903
- const { state: state$1, dispatch } = view;
1904
- const active = __privateGet(this, _provider).active;
1905
- if (!active)
1906
- return;
1907
- const pos = active.$pos;
1908
- const isNoneTextBlock = ["hr", "image-block"].includes(active.node.type.name);
1909
- const nodeSize = isNoneTextBlock ? active.node.nodeSize : active.node.content.size;
1910
- const side = pos.pos + nodeSize + (["blockquote"].includes(pos.parent.type.name) ? 1 : 0);
1911
- const offset = ["blockquote"].includes(pos.parent.type.name) ? 1 : isNoneTextBlock ? 1 : 2;
1912
- let tr = state$1.tr.insert(side, index.paragraphSchema.type(ctx).create());
1913
- tr = tr.setSelection(state.TextSelection.create(tr.doc, side + offset));
1914
- dispatch(tr.scrollIntoView());
1915
- __privateGet(this, _provider).hide();
1916
- ctx.get(menuAPI.key).show(tr.selection.from);
1917
- };
1918
- __privateSet(this, _ctx, ctx);
1919
- const content = new BlockHandleElement();
1920
- __privateSet(this, _content, content);
1921
- __privateGet(this, _content).onAdd = this.onAdd;
1922
- __privateSet(this, _provider, new BlockProvider({
1923
- ctx,
1924
- content,
1925
- getOffset: () => 16,
1926
- getPlacement: ({ active, blockDom }) => {
1927
- let totalDescendant = 0;
1928
- active.node.descendants((node) => {
1929
- totalDescendant += node.childCount;
1930
- });
1931
- const dom = active.el;
1932
- const domRect = dom.getBoundingClientRect();
1933
- const handleRect = blockDom.getBoundingClientRect();
1934
- const style = window.getComputedStyle(dom);
1935
- const paddingTop = Number.parseInt(style.paddingTop, 10) || 0;
1936
- const paddingBottom = Number.parseInt(style.paddingBottom, 10) || 0;
1937
- const height = domRect.height - paddingTop - paddingBottom;
1938
- const handleHeight = handleRect.height;
1939
- return totalDescendant > 2 || handleHeight * 2 < height ? "left-start" : "left";
1940
- }
1941
- }));
1942
- this.update();
1943
- }
1944
- }
1945
- _content = new WeakMap();
1946
- _provider = new WeakMap();
1947
- _ctx = new WeakMap();
1948
- index$2.defIfNotExists("milkdown-block-handle", BlockHandleElement);
1949
- function configureBlockHandle(ctx) {
1950
- ctx.set(block.key, {
1951
- view: () => new BlockHandleView(ctx)
1952
- });
1953
- }
1954
-
1955
- const defineFeature = (editor) => {
1956
- editor.config(configureBlockHandle).config(configureMenu).use(menuAPI).use(block).use(menu);
1957
- };
1958
-
1959
- exports.defineFeature = defineFeature;
1960
- //# sourceMappingURL=index-kvO8ReCY.js.map