@milkdown/crepe 7.5.6 → 7.5.8

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 (227) hide show
  1. package/lib/cjs/{index-_mXHbJMH.js → index-3mj4YaCA.js} +5 -8
  2. package/lib/cjs/index-3mj4YaCA.js.map +1 -0
  3. package/lib/cjs/{index-wORIFtqa.js → index-A8IrOmzS.js} +33 -12
  4. package/lib/cjs/index-A8IrOmzS.js.map +1 -0
  5. package/lib/cjs/{index-z6pe2alg.js → index-AlHHvSR_.js} +1 -1
  6. package/lib/cjs/index-AlHHvSR_.js.map +1 -0
  7. package/lib/cjs/{index-YoPS8A3_.js → index-BIXWL4Or.js} +2 -2
  8. package/lib/cjs/index-BIXWL4Or.js.map +1 -0
  9. package/lib/cjs/{index-MLK151KV.js → index-BrCpWPcp.js} +2 -2
  10. package/lib/cjs/index-BrCpWPcp.js.map +1 -0
  11. package/lib/cjs/{index-uleaJDBC.js → index-BuSAwj4j.js} +1 -1
  12. package/lib/cjs/index-BuSAwj4j.js.map +1 -0
  13. package/lib/cjs/{index-vNNxr8yy.js → index-By3ewOiO.js} +173 -139
  14. package/lib/cjs/index-By3ewOiO.js.map +1 -0
  15. package/lib/cjs/{index-KeJUBENN.js → index-DmOOfQPi.js} +2 -2
  16. package/lib/cjs/index-DmOOfQPi.js.map +1 -0
  17. package/lib/cjs/index-Dt55rF23.js +35 -0
  18. package/lib/cjs/index-Dt55rF23.js.map +1 -0
  19. package/lib/cjs/{index-rFFAL9YA.js → index-Dub20F3z.js} +15 -17
  20. package/lib/cjs/index-Dub20F3z.js.map +1 -0
  21. package/lib/cjs/index.js +11 -13
  22. package/lib/cjs/index.js.map +1 -1
  23. package/lib/cjs/todoList-V4JWO5-M.js +675 -0
  24. package/lib/cjs/todoList-V4JWO5-M.js.map +1 -0
  25. package/lib/esm/{index-HHuxH8Dm.js → index-6VoEpEnX.js} +2 -2
  26. package/lib/esm/index-6VoEpEnX.js.map +1 -0
  27. package/lib/esm/{index-RJV0C6Af.js → index-BB3Rq6BU.js} +5 -8
  28. package/lib/esm/index-BB3Rq6BU.js.map +1 -0
  29. package/lib/esm/{index-uThMsyF6.js → index-BDGHz9p-.js} +2 -2
  30. package/lib/esm/index-BDGHz9p-.js.map +1 -0
  31. package/lib/esm/{index-X2mjLDJS.js → index-BoTKwL_u.js} +2 -2
  32. package/lib/esm/index-BoTKwL_u.js.map +1 -0
  33. package/lib/esm/{index-6JoGWH2I.js → index-CxJ9fxJm.js} +1 -1
  34. package/lib/esm/index-CxJ9fxJm.js.map +1 -0
  35. package/lib/esm/{index-Jvxff1vU.js → index-D6fLMv29.js} +1 -1
  36. package/lib/esm/index-D6fLMv29.js.map +1 -0
  37. package/lib/esm/{index-CMGDOz11.js → index-DOrkOhki.js} +15 -17
  38. package/lib/esm/index-DOrkOhki.js.map +1 -0
  39. package/lib/esm/index-DlX33Dj0.js +33 -0
  40. package/lib/esm/index-DlX33Dj0.js.map +1 -0
  41. package/lib/esm/{index-eZXAY3yz.js → index-kGl7HgN2.js} +33 -12
  42. package/lib/esm/index-kGl7HgN2.js.map +1 -0
  43. package/lib/esm/{index-sE0tYrbc.js → index-zKiGjwHz.js} +173 -139
  44. package/lib/esm/index-zKiGjwHz.js.map +1 -0
  45. package/lib/esm/index.js +11 -13
  46. package/lib/esm/index.js.map +1 -1
  47. package/lib/esm/todoList-CAbx4396.js +638 -0
  48. package/lib/esm/todoList-CAbx4396.js.map +1 -0
  49. package/lib/theme/_internal/classic-common.css +44 -19
  50. package/lib/theme/common/block-edit.css +12 -3
  51. package/lib/theme/common/code-mirror.css +1 -1
  52. package/lib/theme/common/cursor.css +7 -3
  53. package/lib/theme/common/image-block.css +28 -7
  54. package/lib/theme/common/link-tooltip.css +1 -0
  55. package/lib/theme/common/placeholder.css +5 -1
  56. package/lib/theme/common/prosemirror.css +1 -1
  57. package/lib/theme/common/style.css +10 -10
  58. package/lib/theme/common/table.css +17 -15
  59. package/lib/theme/common/toolbar.css +7 -3
  60. package/lib/theme/crepe/style.css +22 -20
  61. package/lib/theme/crepe-dark/style.css +25 -23
  62. package/lib/theme/frame/style.css +23 -20
  63. package/lib/theme/frame-dark/style.css +23 -20
  64. package/lib/theme/nord/style.css +25 -22
  65. package/lib/theme/nord-dark/style.css +23 -20
  66. package/lib/types/core/crepe.d.ts.map +1 -1
  67. package/lib/types/core/slice.d.ts +1 -1
  68. package/lib/types/core/slice.d.ts.map +1 -1
  69. package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
  70. package/lib/types/feature/block-edit/handle/index.d.ts.map +1 -1
  71. package/lib/types/feature/block-edit/index.d.ts.map +1 -1
  72. package/lib/types/feature/block-edit/menu/component.d.ts.map +1 -1
  73. package/lib/types/feature/block-edit/menu/config.d.ts +2 -7
  74. package/lib/types/feature/block-edit/menu/config.d.ts.map +1 -1
  75. package/lib/types/feature/block-edit/menu/group-builder.d.ts +2 -2
  76. package/lib/types/feature/block-edit/menu/group-builder.d.ts.map +1 -1
  77. package/lib/types/feature/block-edit/menu/index.d.ts +2 -2
  78. package/lib/types/feature/block-edit/menu/index.d.ts.map +1 -1
  79. package/lib/types/feature/block-edit/menu/utils.d.ts.map +1 -1
  80. package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
  81. package/lib/types/feature/cursor/index.d.ts.map +1 -1
  82. package/lib/types/feature/image-block/index.d.ts.map +1 -1
  83. package/lib/types/feature/index.d.ts.map +1 -1
  84. package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
  85. package/lib/types/feature/list-item/index.d.ts.map +1 -1
  86. package/lib/types/feature/placeholder/index.d.ts +2 -2
  87. package/lib/types/feature/placeholder/index.d.ts.map +1 -1
  88. package/lib/types/feature/shared.d.ts.map +1 -1
  89. package/lib/types/feature/table/index.d.ts.map +1 -1
  90. package/lib/types/feature/toolbar/component.d.ts.map +1 -1
  91. package/lib/types/feature/toolbar/index.d.ts.map +1 -1
  92. package/lib/types/icons/alignCenter.d.ts.map +1 -1
  93. package/lib/types/icons/alignLeft.d.ts.map +1 -1
  94. package/lib/types/icons/alignRight.d.ts.map +1 -1
  95. package/lib/types/icons/bold.d.ts.map +1 -1
  96. package/lib/types/icons/bullet.d.ts.map +1 -1
  97. package/lib/types/icons/bulletList.d.ts.map +1 -1
  98. package/lib/types/icons/caption.d.ts.map +1 -1
  99. package/lib/types/icons/checkBoxChecked.d.ts.map +1 -1
  100. package/lib/types/icons/checkBoxUnchecked.d.ts.map +1 -1
  101. package/lib/types/icons/chevronDown.d.ts.map +1 -1
  102. package/lib/types/icons/clear.d.ts.map +1 -1
  103. package/lib/types/icons/code.d.ts.map +1 -1
  104. package/lib/types/icons/confirm.d.ts.map +1 -1
  105. package/lib/types/icons/divider.d.ts.map +1 -1
  106. package/lib/types/icons/dragHandle.d.ts.map +1 -1
  107. package/lib/types/icons/edit.d.ts.map +1 -1
  108. package/lib/types/icons/h1.d.ts.map +1 -1
  109. package/lib/types/icons/h2.d.ts.map +1 -1
  110. package/lib/types/icons/h3.d.ts.map +1 -1
  111. package/lib/types/icons/h4.d.ts.map +1 -1
  112. package/lib/types/icons/h5.d.ts.map +1 -1
  113. package/lib/types/icons/h6.d.ts.map +1 -1
  114. package/lib/types/icons/image.d.ts.map +1 -1
  115. package/lib/types/icons/italic.d.ts.map +1 -1
  116. package/lib/types/icons/link.d.ts.map +1 -1
  117. package/lib/types/icons/menu.d.ts.map +1 -1
  118. package/lib/types/icons/orderedList.d.ts.map +1 -1
  119. package/lib/types/icons/plus.d.ts.map +1 -1
  120. package/lib/types/icons/quote.d.ts.map +1 -1
  121. package/lib/types/icons/remove.d.ts.map +1 -1
  122. package/lib/types/icons/search.d.ts.map +1 -1
  123. package/lib/types/icons/strikethrough.d.ts.map +1 -1
  124. package/lib/types/icons/table.d.ts.map +1 -1
  125. package/lib/types/icons/text.d.ts.map +1 -1
  126. package/lib/types/icons/todoList.d.ts.map +1 -1
  127. package/lib/types/utils/index.d.ts.map +1 -1
  128. package/package.json +3 -3
  129. package/src/core/crepe.ts +18 -12
  130. package/src/feature/block-edit/handle/component.ts +7 -4
  131. package/src/feature/block-edit/handle/index.ts +14 -11
  132. package/src/feature/block-edit/index.ts +6 -3
  133. package/src/feature/block-edit/menu/component.ts +138 -117
  134. package/src/feature/block-edit/menu/config.ts +42 -23
  135. package/src/feature/block-edit/menu/group-builder.ts +2 -3
  136. package/src/feature/block-edit/menu/index.ts +25 -15
  137. package/src/feature/block-edit/menu/utils.ts +45 -25
  138. package/src/feature/code-mirror/index.ts +20 -12
  139. package/src/feature/cursor/index.ts +4 -1
  140. package/src/feature/image-block/index.ts +20 -8
  141. package/src/feature/index.ts +5 -1
  142. package/src/feature/link-tooltip/index.ts +10 -3
  143. package/src/feature/list-item/index.ts +25 -8
  144. package/src/feature/placeholder/index.ts +19 -18
  145. package/src/feature/shared.ts +4 -1
  146. package/src/feature/table/index.ts +37 -29
  147. package/src/feature/toolbar/component.ts +40 -10
  148. package/src/feature/toolbar/index.ts +15 -9
  149. package/src/icons/alignCenter.ts +9 -2
  150. package/src/icons/alignLeft.ts +9 -2
  151. package/src/icons/alignRight.ts +9 -2
  152. package/src/icons/bold.ts +9 -2
  153. package/src/icons/bullet.ts +8 -3
  154. package/src/icons/bulletList.ts +10 -3
  155. package/src/icons/caption.ts +10 -2
  156. package/src/icons/checkBoxChecked.ts +10 -3
  157. package/src/icons/checkBoxUnchecked.ts +10 -3
  158. package/src/icons/chevronDown.ts +13 -2
  159. package/src/icons/clear.ts +10 -3
  160. package/src/icons/code.ts +10 -3
  161. package/src/icons/confirm.ts +11 -2
  162. package/src/icons/divider.ts +12 -3
  163. package/src/icons/dragHandle.ts +9 -2
  164. package/src/icons/edit.ts +10 -3
  165. package/src/icons/h1.ts +10 -3
  166. package/src/icons/h2.ts +10 -3
  167. package/src/icons/h3.ts +10 -3
  168. package/src/icons/h4.ts +10 -3
  169. package/src/icons/h5.ts +10 -3
  170. package/src/icons/h6.ts +10 -3
  171. package/src/icons/image.ts +10 -3
  172. package/src/icons/italic.ts +9 -2
  173. package/src/icons/link.ts +9 -2
  174. package/src/icons/menu.ts +10 -3
  175. package/src/icons/orderedList.ts +10 -3
  176. package/src/icons/plus.ts +10 -3
  177. package/src/icons/quote.ts +10 -3
  178. package/src/icons/remove.ts +9 -2
  179. package/src/icons/search.ts +13 -2
  180. package/src/icons/strikethrough.ts +9 -2
  181. package/src/icons/table.ts +10 -3
  182. package/src/icons/text.ts +10 -3
  183. package/src/icons/todoList.ts +9 -2
  184. package/src/theme/_internal/classic-common.css +39 -14
  185. package/src/theme/common/block-edit.css +12 -3
  186. package/src/theme/common/code-mirror.css +1 -1
  187. package/src/theme/common/cursor.css +7 -3
  188. package/src/theme/common/image-block.css +28 -7
  189. package/src/theme/common/link-tooltip.css +1 -0
  190. package/src/theme/common/placeholder.css +5 -1
  191. package/src/theme/common/prosemirror.css +1 -1
  192. package/src/theme/common/style.css +10 -10
  193. package/src/theme/common/table.css +17 -14
  194. package/src/theme/common/toolbar.css +7 -3
  195. package/src/theme/crepe/style.css +22 -20
  196. package/src/theme/crepe-dark/style.css +25 -23
  197. package/src/theme/frame/style.css +23 -20
  198. package/src/theme/frame-dark/style.css +23 -20
  199. package/src/theme/nord/style.css +25 -22
  200. package/src/theme/nord-dark/style.css +23 -20
  201. package/src/utils/index.ts +4 -1
  202. package/lib/cjs/index-9Lsv_-NW.js +0 -28
  203. package/lib/cjs/index-9Lsv_-NW.js.map +0 -1
  204. package/lib/cjs/index-KeJUBENN.js.map +0 -1
  205. package/lib/cjs/index-MLK151KV.js.map +0 -1
  206. package/lib/cjs/index-YoPS8A3_.js.map +0 -1
  207. package/lib/cjs/index-_mXHbJMH.js.map +0 -1
  208. package/lib/cjs/index-rFFAL9YA.js.map +0 -1
  209. package/lib/cjs/index-uleaJDBC.js.map +0 -1
  210. package/lib/cjs/index-vNNxr8yy.js.map +0 -1
  211. package/lib/cjs/index-wORIFtqa.js.map +0 -1
  212. package/lib/cjs/index-z6pe2alg.js.map +0 -1
  213. package/lib/cjs/todoList-Qb2JsRGC.js +0 -419
  214. package/lib/cjs/todoList-Qb2JsRGC.js.map +0 -1
  215. package/lib/esm/index-6JoGWH2I.js.map +0 -1
  216. package/lib/esm/index-CMGDOz11.js.map +0 -1
  217. package/lib/esm/index-HHuxH8Dm.js.map +0 -1
  218. package/lib/esm/index-J3c6JQEf.js +0 -26
  219. package/lib/esm/index-J3c6JQEf.js.map +0 -1
  220. package/lib/esm/index-Jvxff1vU.js.map +0 -1
  221. package/lib/esm/index-RJV0C6Af.js.map +0 -1
  222. package/lib/esm/index-X2mjLDJS.js.map +0 -1
  223. package/lib/esm/index-eZXAY3yz.js.map +0 -1
  224. package/lib/esm/index-sE0tYrbc.js.map +0 -1
  225. package/lib/esm/index-uThMsyF6.js.map +0 -1
  226. package/lib/esm/todoList-eAxCDaQj.js +0 -382
  227. package/lib/esm/todoList-eAxCDaQj.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"h5.d.ts","sourceRoot":"","sources":["../../../src/icons/h5.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,KAWlB,CAAA"}
1
+ {"version":3,"file":"h5.d.ts","sourceRoot":"","sources":["../../../src/icons/h5.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,KAkBlB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"h6.d.ts","sourceRoot":"","sources":["../../../src/icons/h6.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,KAWlB,CAAA"}
1
+ {"version":3,"file":"h6.d.ts","sourceRoot":"","sources":["../../../src/icons/h6.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,KAkBlB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/icons/image.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,KAWrB,CAAA"}
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/icons/image.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,KAkBrB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"italic.d.ts","sourceRoot":"","sources":["../../../src/icons/italic.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,KAItB,CAAA"}
1
+ {"version":3,"file":"italic.d.ts","sourceRoot":"","sources":["../../../src/icons/italic.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,KAWtB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/icons/link.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,KAIpB,CAAA"}
1
+ {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/icons/link.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,KAWpB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../src/icons/menu.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,KAWpB,CAAA"}
1
+ {"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../src/icons/menu.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,KAkBpB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"orderedList.d.ts","sourceRoot":"","sources":["../../../src/icons/orderedList.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,KAW3B,CAAA"}
1
+ {"version":3,"file":"orderedList.d.ts","sourceRoot":"","sources":["../../../src/icons/orderedList.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,KAkB3B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plus.d.ts","sourceRoot":"","sources":["../../../src/icons/plus.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,KAWpB,CAAA"}
1
+ {"version":3,"file":"plus.d.ts","sourceRoot":"","sources":["../../../src/icons/plus.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,KAkBpB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../../src/icons/quote.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,KAWrB,CAAA"}
1
+ {"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../../src/icons/quote.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,KAkBrB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/icons/remove.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,KAItB,CAAA"}
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/icons/remove.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,KAWtB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/icons/search.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,KAItB,CAAA"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/icons/search.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,KAetB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"strikethrough.d.ts","sourceRoot":"","sources":["../../../src/icons/strikethrough.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,KAI7B,CAAA"}
1
+ {"version":3,"file":"strikethrough.d.ts","sourceRoot":"","sources":["../../../src/icons/strikethrough.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,KAW7B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/icons/table.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,KAWrB,CAAA"}
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/icons/table.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,KAkBrB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/icons/text.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,KAWpB,CAAA"}
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/icons/text.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,KAkBpB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"todoList.d.ts","sourceRoot":"","sources":["../../../src/icons/todoList.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,KAIxB,CAAA"}
1
+ {"version":3,"file":"todoList.d.ts","sourceRoot":"","sources":["../../../src/icons/todoList.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,KAWxB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAE1D,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,WAGjD;AAED,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,WAG5C;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,QAGhF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAE1D,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,WAGjD;AAED,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,WAG5C;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,wBAAwB,QAIlC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@milkdown/crepe",
3
3
  "type": "module",
4
- "version": "7.5.6",
4
+ "version": "7.5.8",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -40,13 +40,13 @@
40
40
  "@codemirror/language-data": "^6.3.1",
41
41
  "@codemirror/state": "^6.4.1",
42
42
  "@codemirror/view": "^6.16.0",
43
- "@uiw/codemirror-theme-nord": "^4.22.1",
43
+ "@codemirror/theme-one-dark": "^6.1.2",
44
44
  "atomico": "^1.75.1",
45
45
  "clsx": "^2.0.0",
46
46
  "codemirror": "^6.0.1",
47
47
  "nanoid": "^5.0.0",
48
48
  "tslib": "^2.5.0",
49
- "@milkdown/kit": "7.5.5"
49
+ "@milkdown/kit": "7.5.8"
50
50
  },
51
51
  "nx": {
52
52
  "targets": {
package/src/core/crepe.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import type { DefaultValue } from '@milkdown/kit/core'
2
- import { Editor, defaultValueCtx, editorViewOptionsCtx, rootCtx } from '@milkdown/kit/core'
2
+ import {
3
+ Editor,
4
+ defaultValueCtx,
5
+ editorViewOptionsCtx,
6
+ rootCtx,
7
+ } from '@milkdown/kit/core'
3
8
 
4
9
  import { commonmark } from '@milkdown/kit/preset/commonmark'
5
10
  import { gfm } from '@milkdown/kit/preset/gfm'
@@ -33,15 +38,16 @@ export class Crepe {
33
38
  featureConfigs = {},
34
39
  defaultValue = '',
35
40
  }: CrepeConfig) {
36
- const enabledFeatures = Object
37
- .entries({
38
- ...defaultFeatures,
39
- ...features,
40
- })
41
+ const enabledFeatures = Object.entries({
42
+ ...defaultFeatures,
43
+ ...features,
44
+ })
41
45
  .filter(([, enabled]) => enabled)
42
46
  .map(([feature]) => feature as CrepeFeature)
43
47
 
44
- this.#rootElement = (typeof root === 'string' ? document.querySelector(root) : root) ?? document.body
48
+ this.#rootElement =
49
+ (typeof root === 'string' ? document.querySelector(root) : root) ??
50
+ document.body
45
51
  this.#editor = Editor.make()
46
52
  .config(configureFeatures(enabledFeatures))
47
53
  .config((ctx) => {
@@ -50,7 +56,7 @@ export class Crepe {
50
56
  ctx.set(editorViewOptionsCtx, {
51
57
  editable: () => this.#editable,
52
58
  })
53
- ctx.update(indentConfig.key, value => ({
59
+ ctx.update(indentConfig.key, (value) => ({
54
60
  ...value,
55
61
  size: 4,
56
62
  }))
@@ -65,10 +71,10 @@ export class Crepe {
65
71
  const promiseList: Promise<unknown>[] = []
66
72
 
67
73
  enabledFeatures.forEach((feature) => {
68
- const config = (featureConfigs as Partial<Record<CrepeFeature, never>>)[feature]
69
- promiseList.push(
70
- loadFeature(feature, this.#editor, config),
71
- )
74
+ const config = (featureConfigs as Partial<Record<CrepeFeature, never>>)[
75
+ feature
76
+ ]
77
+ promiseList.push(loadFeature(feature, this.#editor, config))
72
78
  })
73
79
 
74
80
  this.#initPromise = Promise.all(promiseList)
@@ -31,12 +31,15 @@ const blockHandleComponent: Component<BlockHandleProps> = ({
31
31
  }
32
32
  return html`
33
33
  <host>
34
- <div ref=${ref} onmousedown=${onMouseDown} onmouseup=${onMouseUp} class="operation-item">
34
+ <div
35
+ ref=${ref}
36
+ onmousedown=${onMouseDown}
37
+ onmouseup=${onMouseUp}
38
+ class="operation-item"
39
+ >
35
40
  ${addIcon?.() || plusIcon}
36
41
  </div>
37
- <div class="operation-item">
38
- ${handleIcon?.() || menuIcon}
39
- </div>
42
+ <div class="operation-item">${handleIcon?.() || menuIcon}</div>
40
43
  </host>
41
44
  `
42
45
  }
@@ -29,8 +29,7 @@ export class BlockHandleView implements PluginView {
29
29
  content,
30
30
  getOffset: () => 16,
31
31
  getPlacement: ({ active, blockDom }) => {
32
- if (active.node.type.name === 'heading')
33
- return 'left'
32
+ if (active.node.type.name === 'heading') return 'left'
34
33
 
35
34
  let totalDescendant = 0
36
35
  active.node.descendants((node) => {
@@ -44,7 +43,9 @@ export class BlockHandleView implements PluginView {
44
43
  const paddingBottom = Number.parseInt(style.paddingBottom, 10) || 0
45
44
  const height = domRect.height - paddingTop - paddingBottom
46
45
  const handleHeight = handleRect.height
47
- return totalDescendant > 2 || handleHeight < height ? 'left-start' : 'left'
46
+ return totalDescendant > 2 || handleHeight < height
47
+ ? 'left-start'
48
+ : 'left'
48
49
  },
49
50
  })
50
51
  this.update()
@@ -62,13 +63,11 @@ export class BlockHandleView implements PluginView {
62
63
  onAdd = () => {
63
64
  const ctx = this.#ctx
64
65
  const view = ctx.get(editorViewCtx)
65
- if (!view.hasFocus())
66
- view.focus()
66
+ if (!view.hasFocus()) view.focus()
67
67
 
68
68
  const { state, dispatch } = view
69
69
  const active = this.#provider.active
70
- if (!active)
71
- return
70
+ if (!active) return
72
71
 
73
72
  const $pos = active.$pos
74
73
  const pos = $pos.pos + active.node.nodeSize
@@ -82,12 +81,16 @@ export class BlockHandleView implements PluginView {
82
81
  }
83
82
 
84
83
  defIfNotExists('milkdown-block-handle', BlockHandleElement)
85
- export function configureBlockHandle(ctx: Ctx, config?: BlockEditFeatureConfig) {
84
+ export function configureBlockHandle(
85
+ ctx: Ctx,
86
+ config?: BlockEditFeatureConfig
87
+ ) {
86
88
  ctx.set(blockConfig.key, {
87
89
  filterNodes: (pos) => {
88
- const filter = findParent(node => ['table', 'blockquote'].includes(node.type.name))(pos)
89
- if (filter)
90
- return false
90
+ const filter = findParent((node) =>
91
+ ['table', 'blockquote'].includes(node.type.name)
92
+ )(pos)
93
+ if (filter) return false
91
94
 
92
95
  return true
93
96
  },
@@ -48,10 +48,13 @@ interface BlockEditConfig {
48
48
 
49
49
  export type BlockEditFeatureConfig = Partial<BlockEditConfig>
50
50
 
51
- export const defineFeature: DefineFeature<BlockEditFeatureConfig> = (editor, config) => {
51
+ export const defineFeature: DefineFeature<BlockEditFeatureConfig> = (
52
+ editor,
53
+ config
54
+ ) => {
52
55
  editor
53
- .config(ctx => configureBlockHandle(ctx, config))
54
- .config(ctx => configureMenu(ctx, config))
56
+ .config((ctx) => configureBlockHandle(ctx, config))
57
+ .config((ctx) => configureMenu(ctx, config))
55
58
  .use(menuAPI)
56
59
  .use(block)
57
60
  .use(menu)
@@ -1,5 +1,14 @@
1
1
  import type { Component } from 'atomico'
2
- import { c, html, useCallback, useEffect, useHost, useMemo, useRef, useState } from 'atomico'
2
+ import {
3
+ c,
4
+ html,
5
+ useCallback,
6
+ useEffect,
7
+ useHost,
8
+ useMemo,
9
+ useRef,
10
+ useState,
11
+ } from 'atomico'
3
12
  import type { Ctx } from '@milkdown/kit/ctx'
4
13
  import type { BlockEditFeatureConfig } from '../index'
5
14
  import { getGroups } from './config'
@@ -30,8 +39,7 @@ export const menuComponent: Component<MenuProps> = ({
30
39
 
31
40
  const onMouseMove = useCallback((e: MouseEvent) => {
32
41
  const prevPos = prevMousePosition.current
33
- if (!prevPos)
34
- return
42
+ if (!prevPos) return
35
43
 
36
44
  const { x, y } = e
37
45
  prevPos.x = x
@@ -39,113 +47,122 @@ export const menuComponent: Component<MenuProps> = ({
39
47
  }, [])
40
48
 
41
49
  useEffect(() => {
42
- if (size === 0 && show)
43
- hide?.()
50
+ if (size === 0 && show) hide?.()
51
+ else if (hoverIndex >= size) setHoverIndex(0)
44
52
  }, [size, show])
45
53
 
46
- const onHover = useCallback((
47
- index: number | ((prev: number) => number),
48
- after?: (index: number) => void,
49
- ) => {
50
- setHoverIndex((prev) => {
51
- const next = typeof index === 'function' ? index(prev) : index
52
-
53
- after?.(next)
54
- return next
55
- })
56
- }, [])
54
+ const onHover = useCallback(
55
+ (
56
+ index: number | ((prev: number) => number),
57
+ after?: (index: number) => void
58
+ ) => {
59
+ setHoverIndex((prev) => {
60
+ const next = typeof index === 'function' ? index(prev) : index
61
+
62
+ after?.(next)
63
+ return next
64
+ })
65
+ },
66
+ []
67
+ )
57
68
 
58
69
  const scrollToIndex = useCallback((index: number) => {
59
- const target = host
60
- .current
61
- .querySelector<HTMLElement>(`[data-index="${index}"]`)
70
+ const target = host.current.querySelector<HTMLElement>(
71
+ `[data-index="${index}"]`
72
+ )
62
73
  const scrollRoot = host.current.querySelector<HTMLElement>('.menu-groups')
63
74
 
64
- if (!target || !scrollRoot)
65
- return
75
+ if (!target || !scrollRoot) return
66
76
 
67
77
  scrollRoot.scrollTop = target.offsetTop - scrollRoot.offsetTop
68
78
  }, [])
69
79
 
70
- const runByIndex = useCallback((index: number) => {
71
- const item = groups.flatMap(group => group.items).at(index)
72
- if (item && ctx)
73
- item.onRun(ctx)
80
+ const runByIndex = useCallback(
81
+ (index: number) => {
82
+ const item = groups.flatMap((group) => group.items).at(index)
83
+ if (item && ctx) item.onRun(ctx)
74
84
 
75
- hide?.()
76
- }, [groups])
77
-
78
- const onKeydown = useCallback((e: KeyboardEvent) => {
79
- if (e.key === 'Escape') {
80
- e.preventDefault()
81
85
  hide?.()
82
- return
83
- }
84
-
85
- if (e.key === 'ArrowDown') {
86
- e.preventDefault()
87
- return onHover(index => (index < size - 1) ? index + 1 : index, scrollToIndex)
88
- }
89
-
90
- if (e.key === 'ArrowUp') {
91
- e.preventDefault()
92
- return onHover(index => index <= 0 ? index : index - 1, scrollToIndex)
93
- }
94
-
95
- if (e.key === 'ArrowLeft') {
96
- e.preventDefault()
97
- return onHover((index) => {
98
- const group = groups.find(group => group.range[0] <= index && group.range[1] > index)
99
- if (!group)
100
- return index
101
-
102
- const prevGroup = groups[groups.indexOf(group) - 1]
103
- if (!prevGroup)
104
- return index
105
-
106
- return prevGroup.range[1] - 1
107
- }, scrollToIndex)
108
- }
109
-
110
- if (e.key === 'ArrowRight') {
111
- e.preventDefault()
112
- return onHover((index) => {
113
- const group = groups.find(group => group.range[0] <= index && group.range[1] > index)
114
- if (!group)
115
- return index
116
-
117
- const nextGroup = groups[groups.indexOf(group) + 1]
118
- if (!nextGroup)
119
- return index
120
-
121
- return nextGroup.range[0]
122
- }, scrollToIndex)
123
- }
124
-
125
- if (e.key === 'Enter') {
126
- e.preventDefault()
127
- runByIndex(hoverIndex)
128
- }
129
- }, [hide, groups, hoverIndex])
86
+ },
87
+ [groups]
88
+ )
89
+
90
+ const onKeydown = useCallback(
91
+ (e: KeyboardEvent) => {
92
+ if (e.key === 'Escape') {
93
+ e.preventDefault()
94
+ hide?.()
95
+ return
96
+ }
97
+
98
+ if (e.key === 'ArrowDown') {
99
+ e.preventDefault()
100
+ return onHover(
101
+ (index) => (index < size - 1 ? index + 1 : index),
102
+ scrollToIndex
103
+ )
104
+ }
105
+
106
+ if (e.key === 'ArrowUp') {
107
+ e.preventDefault()
108
+ return onHover(
109
+ (index) => (index <= 0 ? index : index - 1),
110
+ scrollToIndex
111
+ )
112
+ }
113
+
114
+ if (e.key === 'ArrowLeft') {
115
+ e.preventDefault()
116
+ return onHover((index) => {
117
+ const group = groups.find(
118
+ (group) => group.range[0] <= index && group.range[1] > index
119
+ )
120
+ if (!group) return index
121
+
122
+ const prevGroup = groups[groups.indexOf(group) - 1]
123
+ if (!prevGroup) return index
124
+
125
+ return prevGroup.range[1] - 1
126
+ }, scrollToIndex)
127
+ }
128
+
129
+ if (e.key === 'ArrowRight') {
130
+ e.preventDefault()
131
+ return onHover((index) => {
132
+ const group = groups.find(
133
+ (group) => group.range[0] <= index && group.range[1] > index
134
+ )
135
+ if (!group) return index
136
+
137
+ const nextGroup = groups[groups.indexOf(group) + 1]
138
+ if (!nextGroup) return index
139
+
140
+ return nextGroup.range[0]
141
+ }, scrollToIndex)
142
+ }
143
+
144
+ if (e.key === 'Enter') {
145
+ e.preventDefault()
146
+ runByIndex(hoverIndex)
147
+ }
148
+ },
149
+ [hide, groups, hoverIndex]
150
+ )
130
151
 
131
152
  const onMouseEnter = useCallback((index: number) => {
132
153
  return (e: MouseEvent) => {
133
154
  const prevPos = prevMousePosition.current
134
- if (!prevPos)
135
- return
155
+ if (!prevPos) return
136
156
 
137
157
  const { x, y } = e
138
- if (x === prevPos.x && y === prevPos.y)
139
- return
158
+ if (x === prevPos.x && y === prevPos.y) return
140
159
 
141
160
  onHover(index)
142
161
  }
143
162
  }, [])
144
163
 
145
164
  useEffect(() => {
146
- if (show)
147
- root.addEventListener('keydown', onKeydown, { capture: true })
148
-
165
+ if (show) root.addEventListener('keydown', onKeydown, { capture: true })
149
166
  else root.removeEventListener('keydown', onKeydown, { capture: true })
150
167
 
151
168
  return () => {
@@ -157,14 +174,19 @@ export const menuComponent: Component<MenuProps> = ({
157
174
  <host onmousedown=${(e: MouseEvent) => e.preventDefault()}>
158
175
  <nav class="tab-group">
159
176
  <ul>
160
- ${groups.map(group =>
161
- html`<li
162
- key=${group.key}
163
- onmousedown=${() => onHover(group.range[0], scrollToIndex)}
164
- class=${hoverIndex >= group.range[0] && hoverIndex < group.range[1] ? 'selected' : ''}
165
- >
166
- ${group.label}
167
- </li>`)}
177
+ ${groups.map(
178
+ (group) =>
179
+ html`<li
180
+ key=${group.key}
181
+ onmousedown=${() => onHover(group.range[0], scrollToIndex)}
182
+ class=${hoverIndex >= group.range[0] &&
183
+ hoverIndex < group.range[1]
184
+ ? 'selected'
185
+ : ''}
186
+ >
187
+ ${group.label}
188
+ </li>`
189
+ )}
168
190
  </ul>
169
191
  </nav>
170
192
  <div class="menu-groups" onmousemove=${onMouseMove}>
@@ -173,29 +195,28 @@ export const menuComponent: Component<MenuProps> = ({
173
195
  <div key=${group.key} class="menu-group">
174
196
  <h6>${group.label}</h6>
175
197
  <ul>
176
- ${group.items.map(item =>
177
- html`<li
178
- key=${item.key}
179
- data-index=${item.index}
180
- class=${hoverIndex === item.index ? 'hover' : ''}
181
- onmouseenter=${onMouseEnter(item.index)}
182
- onmousedown=${() => {
183
- host
184
- .current
185
- .querySelector(`[data-index="${item.index}"]`)
186
- ?.classList.add('active')
187
- }}
188
- onmouseup=${() => {
189
- host
190
- .current
191
- .querySelector(`[data-index="${item.index}"]`)
192
- ?.classList.remove('active')
193
- runByIndex(item.index)
194
- }}
195
- >
196
- ${item.icon}
197
- <span>${item.label}</span>
198
- </li>`,
198
+ ${group.items.map(
199
+ (item) =>
200
+ html`<li
201
+ key=${item.key}
202
+ data-index=${item.index}
203
+ class=${hoverIndex === item.index ? 'hover' : ''}
204
+ onmouseenter=${onMouseEnter(item.index)}
205
+ onmousedown=${() => {
206
+ host.current
207
+ .querySelector(`[data-index="${item.index}"]`)
208
+ ?.classList.add('active')
209
+ }}
210
+ onmouseup=${() => {
211
+ host.current
212
+ .querySelector(`[data-index="${item.index}"]`)
213
+ ?.classList.remove('active')
214
+ runByIndex(item.index)
215
+ }}
216
+ >
217
+ ${item.icon}
218
+ <span>${item.label}</span>
219
+ </li>`
199
220
  )}
200
221
  </ul>
201
222
  </div>