@milkdown/crepe 7.4.0 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (430) hide show
  1. package/lib/cjs/{_view-TbSIR42F.js → _view-N32ied53.js} +2 -2
  2. package/lib/cjs/{_view-TbSIR42F.js.map → _view-N32ied53.js.map} +1 -1
  3. package/lib/cjs/clsx-dASsG01A.js +6 -0
  4. package/lib/cjs/clsx-dASsG01A.js.map +1 -0
  5. package/lib/cjs/{composed-offset-position.browser.min-FwypoGc1.js → floating-ui.dom-2cjBpir5.js} +14 -18
  6. package/lib/cjs/floating-ui.dom-2cjBpir5.js.map +1 -0
  7. package/lib/cjs/helper-1aludV1Z.js +15 -0
  8. package/lib/cjs/helper-1aludV1Z.js.map +1 -0
  9. package/lib/cjs/{index-tbEq3xma.js → index--sa4NMpW.js} +15 -14
  10. package/lib/cjs/{index-tbEq3xma.js.map → index--sa4NMpW.js.map} +1 -1
  11. package/lib/cjs/{index-5PcT4iSf.js → index--tnUmqZ_.js} +18 -17
  12. package/lib/cjs/{index-5PcT4iSf.js.map → index--tnUmqZ_.js.map} +1 -1
  13. package/lib/cjs/{index-i0_v2uVp.js → index-1vHyMXH8.js} +15 -14
  14. package/lib/{esm/index-4QzlLVWs.js.map → cjs/index-1vHyMXH8.js.map} +1 -1
  15. package/lib/cjs/index-28q261C7.js +448 -0
  16. package/lib/cjs/index-28q261C7.js.map +1 -0
  17. package/lib/cjs/{index-mJ47ZWO2.js → index-55VIM-52.js} +18 -17
  18. package/lib/{esm/index-Grquo08f.js.map → cjs/index-55VIM-52.js.map} +1 -1
  19. package/lib/cjs/{index-lrFGGa_l.js → index-92bwto5V.js} +15 -14
  20. package/lib/cjs/{index-lrFGGa_l.js.map → index-92bwto5V.js.map} +1 -1
  21. package/lib/cjs/{index-2oxl5Zo4.js → index-Buu2tD9O.js} +45 -62
  22. package/lib/cjs/index-Buu2tD9O.js.map +1 -0
  23. package/lib/cjs/{index-OA_u95ey.js → index-E4Ist86Z.js} +15 -14
  24. package/lib/{esm/index-7BVeXLQZ.js.map → cjs/index-E4Ist86Z.js.map} +1 -1
  25. package/lib/cjs/{index-OIQn1x0L.js → index-FbNqlZU8.js} +14 -13
  26. package/lib/cjs/index-FbNqlZU8.js.map +1 -0
  27. package/lib/cjs/{index-SxWWV8XD.js → index-HH5lPgpj.js} +18 -17
  28. package/lib/cjs/{index-SxWWV8XD.js.map → index-HH5lPgpj.js.map} +1 -1
  29. package/lib/cjs/{index-vlxA_KJ8.js → index-J1-yHn7v.js} +15 -14
  30. package/lib/{esm/index-vwrMVELn.js.map → cjs/index-J1-yHn7v.js.map} +1 -1
  31. package/lib/cjs/{index-xqKfEyRA.js → index-J3XY9IPt.js} +12 -7
  32. package/lib/cjs/index-J3XY9IPt.js.map +1 -0
  33. package/lib/cjs/{index-llNS_EuP.js → index-Jztk6JlP.js} +58 -55
  34. package/lib/cjs/index-Jztk6JlP.js.map +1 -0
  35. package/lib/cjs/{index-O3vRXWIP.js → index-N6pPZY61.js} +22 -30
  36. package/lib/cjs/index-N6pPZY61.js.map +1 -0
  37. package/lib/cjs/{index-GKolgvC5.js → index-TUJs6KKL.js} +35 -68
  38. package/lib/cjs/index-TUJs6KKL.js.map +1 -0
  39. package/lib/cjs/{index-OtaMLv5l.js → index-Tjg8KyK7.js} +15 -14
  40. package/lib/cjs/{index-OtaMLv5l.js.map → index-Tjg8KyK7.js.map} +1 -1
  41. package/lib/cjs/{index-qRg5-QJH.js → index-VYwHTL3F.js} +16 -15
  42. package/lib/cjs/{index-qRg5-QJH.js.map → index-VYwHTL3F.js.map} +1 -1
  43. package/lib/cjs/index-_GOdKqUK.js +1147 -0
  44. package/lib/cjs/index-_GOdKqUK.js.map +1 -0
  45. package/lib/cjs/{index-PF7s7DOo.js → index-cKQcw-eu.js} +2 -2
  46. package/lib/cjs/{index-PF7s7DOo.js.map → index-cKQcw-eu.js.map} +1 -1
  47. package/lib/cjs/{index-fkT0ywfA.js → index-c_OzudR7.js} +15 -14
  48. package/lib/{esm/index-L7VXk-jT.js.map → cjs/index-c_OzudR7.js.map} +1 -1
  49. package/lib/cjs/{index-TEjdwq--.js → index-cb-5m0vG.js} +18 -17
  50. package/lib/cjs/index-cb-5m0vG.js.map +1 -0
  51. package/lib/cjs/index-cpC-j5Nt.js +176 -0
  52. package/lib/cjs/index-cpC-j5Nt.js.map +1 -0
  53. package/lib/cjs/index-crv_k6dv.js +1353 -0
  54. package/lib/cjs/index-crv_k6dv.js.map +1 -0
  55. package/lib/cjs/{index-78P4PeZ9.js → index-jlfsu92T.js} +16 -15
  56. package/lib/{esm/index-4oMdufW4.js.map → cjs/index-jlfsu92T.js.map} +1 -1
  57. package/lib/cjs/{index-de3dfsQr.js → index-jn036wuh.js} +17 -16
  58. package/lib/{esm/index-rwcSpYkt.js.map → cjs/index-jn036wuh.js.map} +1 -1
  59. package/lib/cjs/{index-JAqL0ybh.js → index-kqz-P6o6.js} +9 -9
  60. package/lib/cjs/index-kqz-P6o6.js.map +1 -0
  61. package/lib/cjs/{index-t_GA5F26.js → index-lBumFRUQ.js} +15 -14
  62. package/lib/cjs/{index-t_GA5F26.js.map → index-lBumFRUQ.js.map} +1 -1
  63. package/lib/cjs/{index-LdEYPSZc.js → index-lUNj3xuC.js} +15 -14
  64. package/lib/{esm/index-0khVa44f.js.map → cjs/index-lUNj3xuC.js.map} +1 -1
  65. package/lib/cjs/{index-ortUqbAp.js → index-mcxgNBq9.js} +15 -14
  66. package/lib/cjs/{index-ortUqbAp.js.map → index-mcxgNBq9.js.map} +1 -1
  67. package/lib/cjs/{index-GEIgbcVc.js → index-nTfDKYYi.js} +38 -37
  68. package/lib/{esm/index-NmjiRA0M.js.map → cjs/index-nTfDKYYi.js.map} +1 -1
  69. package/lib/cjs/{index-kNI3S3lF.js → index-tBw4NmwY.js} +11779 -404
  70. package/lib/cjs/index-tBw4NmwY.js.map +1 -0
  71. package/lib/cjs/{index-zBr61zy6.js → index-vfzLCXfi.js} +15 -14
  72. package/lib/cjs/{index-zBr61zy6.js.map → index-vfzLCXfi.js.map} +1 -1
  73. package/lib/cjs/{index-w9buMrFW.js → index-von4W2LG.js} +18 -17
  74. package/lib/cjs/{index-w9buMrFW.js.map → index-von4W2LG.js.map} +1 -1
  75. package/lib/cjs/index-z6pe2alg.js.map +1 -1
  76. package/lib/cjs/{index-wXLifZgm.js → index-zXSAHvAj.js} +2 -2
  77. package/lib/cjs/{index-wXLifZgm.js.map → index-zXSAHvAj.js.map} +1 -1
  78. package/lib/cjs/index.js +7 -6
  79. package/lib/cjs/index.js.map +1 -1
  80. package/lib/cjs/{schema-7d3meDfB.js → schema-RVrwDDcq.js} +4 -4
  81. package/lib/cjs/{schema-7d3meDfB.js.map → schema-RVrwDDcq.js.map} +1 -1
  82. package/lib/cjs/todoList-Ze4FLMlx.js +415 -0
  83. package/lib/cjs/todoList-Ze4FLMlx.js.map +1 -0
  84. package/lib/cjs/{tooltip-plugin-Mk9fRTxI.js → tooltip-plugin--lhebztC.js} +15 -24
  85. package/lib/cjs/tooltip-plugin--lhebztC.js.map +1 -0
  86. package/lib/esm/{_view-JjtfhQ8k.js → _view-IlZC8FA6.js} +2 -2
  87. package/lib/esm/{_view-JjtfhQ8k.js.map → _view-IlZC8FA6.js.map} +1 -1
  88. package/lib/esm/clsx-RxCLxYpD.js +4 -0
  89. package/lib/esm/clsx-RxCLxYpD.js.map +1 -0
  90. package/lib/esm/{composed-offset-position.browser.min-Tnm31e-m.js → floating-ui.dom-CAYjY8Gv.js} +15 -17
  91. package/lib/esm/floating-ui.dom-CAYjY8Gv.js.map +1 -0
  92. package/lib/esm/helper-wZAtC67x.js +13 -0
  93. package/lib/esm/helper-wZAtC67x.js.map +1 -0
  94. package/lib/esm/{index-Bg5GFp0g.js → index-0-j8Icms.js} +2 -2
  95. package/lib/esm/{index-Bg5GFp0g.js.map → index-0-j8Icms.js.map} +1 -1
  96. package/lib/esm/{index-4oMdufW4.js → index-1l-61HI-.js} +16 -15
  97. package/lib/{cjs/index-78P4PeZ9.js.map → esm/index-1l-61HI-.js.map} +1 -1
  98. package/lib/esm/{index-bVubJ6Rv.js → index-3HeWs5rX.js} +18 -17
  99. package/lib/esm/{index-bVubJ6Rv.js.map → index-3HeWs5rX.js.map} +1 -1
  100. package/lib/esm/{index-6P9Xk934.js → index-3bDzhU6z.js} +15 -14
  101. package/lib/esm/{index-6P9Xk934.js.map → index-3bDzhU6z.js.map} +1 -1
  102. package/lib/esm/{index-NmjiRA0M.js → index-6GrVnloh.js} +38 -37
  103. package/lib/{cjs/index-GEIgbcVc.js.map → esm/index-6GrVnloh.js.map} +1 -1
  104. package/lib/esm/index-8QJbxTYk.js +1145 -0
  105. package/lib/esm/index-8QJbxTYk.js.map +1 -0
  106. package/lib/esm/{index-218OjRxG.js → index-9w_hdnvb.js} +39 -56
  107. package/lib/esm/index-9w_hdnvb.js.map +1 -0
  108. package/lib/esm/index-A83StUe6.js +174 -0
  109. package/lib/esm/index-A83StUe6.js.map +1 -0
  110. package/lib/esm/{index-TNMG6UrN.js → index-AOoFzBaK.js} +9 -9
  111. package/lib/esm/index-AOoFzBaK.js.map +1 -0
  112. package/lib/esm/{index-L7VXk-jT.js → index-DS7Z4Ach.js} +15 -14
  113. package/lib/{cjs/index-fkT0ywfA.js.map → esm/index-DS7Z4Ach.js.map} +1 -1
  114. package/lib/esm/index-Jvxff1vU.js.map +1 -1
  115. package/lib/esm/{index-JkHHp3K-.js → index-LAdX6LsO.js} +11712 -352
  116. package/lib/esm/index-LAdX6LsO.js.map +1 -0
  117. package/lib/esm/{index-VyZguCIt.js → index-MB6wQe1U.js} +12 -7
  118. package/lib/esm/index-MB6wQe1U.js.map +1 -0
  119. package/lib/esm/{index-vwrMVELn.js → index-MxgqkRtj.js} +15 -14
  120. package/lib/{cjs/index-vlxA_KJ8.js.map → esm/index-MxgqkRtj.js.map} +1 -1
  121. package/lib/esm/{index-hQaRWeq1.js → index-NZ5-xr5_.js} +18 -17
  122. package/lib/esm/{index-hQaRWeq1.js.map → index-NZ5-xr5_.js.map} +1 -1
  123. package/lib/esm/{index-x-zW6gKj.js → index-OpUb5xP6.js} +2 -2
  124. package/lib/esm/{index-x-zW6gKj.js.map → index-OpUb5xP6.js.map} +1 -1
  125. package/lib/esm/{index-oMy83ynO.js → index-SDPCpsD5.js} +15 -14
  126. package/lib/esm/{index-oMy83ynO.js.map → index-SDPCpsD5.js.map} +1 -1
  127. package/lib/esm/{index-bsED907r.js → index-VP76m4nW.js} +16 -15
  128. package/lib/esm/{index-bsED907r.js.map → index-VP76m4nW.js.map} +1 -1
  129. package/lib/esm/{index-PkBZpDL4.js → index-Vl0W0S3h.js} +14 -13
  130. package/lib/esm/index-Vl0W0S3h.js.map +1 -0
  131. package/lib/esm/{index-rwcSpYkt.js → index-VoX_n1l_.js} +17 -16
  132. package/lib/{cjs/index-de3dfsQr.js.map → esm/index-VoX_n1l_.js.map} +1 -1
  133. package/lib/esm/{index-7BVeXLQZ.js → index-XH7OnwZl.js} +15 -14
  134. package/lib/{cjs/index-OA_u95ey.js.map → esm/index-XH7OnwZl.js.map} +1 -1
  135. package/lib/esm/{index-a-SAfeeT.js → index-Yuj7sNhQ.js} +18 -17
  136. package/lib/esm/{index-a-SAfeeT.js.map → index-Yuj7sNhQ.js.map} +1 -1
  137. package/lib/esm/{index-A9zdyi2L.js → index-_4fWmRbN.js} +15 -14
  138. package/lib/esm/{index-A9zdyi2L.js.map → index-_4fWmRbN.js.map} +1 -1
  139. package/lib/esm/{index-Grquo08f.js → index-bexsWrgs.js} +18 -17
  140. package/lib/{cjs/index-mJ47ZWO2.js.map → esm/index-bexsWrgs.js.map} +1 -1
  141. package/lib/esm/{index-pHsvfB_I.js → index-chrnjY1D.js} +29 -62
  142. package/lib/esm/index-chrnjY1D.js.map +1 -0
  143. package/lib/esm/{index-UBeneu17.js → index-eqd5wtjX.js} +15 -14
  144. package/lib/esm/{index-UBeneu17.js.map → index-eqd5wtjX.js.map} +1 -1
  145. package/lib/esm/{index-4QzlLVWs.js → index-g_3dzLYU.js} +15 -14
  146. package/lib/{cjs/index-i0_v2uVp.js.map → esm/index-g_3dzLYU.js.map} +1 -1
  147. package/lib/esm/{index-0khVa44f.js → index-grT-Kuf2.js} +15 -14
  148. package/lib/{cjs/index-LdEYPSZc.js.map → esm/index-grT-Kuf2.js.map} +1 -1
  149. package/lib/esm/{index-AHPvVH4H.js → index-hF04phbf.js} +20 -28
  150. package/lib/esm/index-hF04phbf.js.map +1 -0
  151. package/lib/esm/{index-q-qE7-96.js → index-i79QMXpJ.js} +55 -52
  152. package/lib/esm/index-i79QMXpJ.js.map +1 -0
  153. package/lib/esm/{index-DoEghZHy.js → index-rvOBAXap.js} +18 -17
  154. package/lib/{cjs/index-TEjdwq--.js.map → esm/index-rvOBAXap.js.map} +1 -1
  155. package/lib/esm/index-uP9BKsTM.js +446 -0
  156. package/lib/esm/index-uP9BKsTM.js.map +1 -0
  157. package/lib/esm/index-ueQQMSgm.js +1351 -0
  158. package/lib/esm/index-ueQQMSgm.js.map +1 -0
  159. package/lib/esm/{index-U71v7KdA.js → index-x8SyiPMC.js} +15 -14
  160. package/lib/esm/{index-U71v7KdA.js.map → index-x8SyiPMC.js.map} +1 -1
  161. package/lib/esm/{index-U8q-F7hU.js → index-zrQXXSXm.js} +15 -14
  162. package/lib/esm/{index-U8q-F7hU.js.map → index-zrQXXSXm.js.map} +1 -1
  163. package/lib/esm/index.js +7 -6
  164. package/lib/esm/index.js.map +1 -1
  165. package/lib/esm/{schema-hVsy-vme.js → schema-JWJqD9qa.js} +3 -3
  166. package/lib/esm/{schema-hVsy-vme.js.map → schema-JWJqD9qa.js.map} +1 -1
  167. package/lib/esm/todoList-M-PGJKde.js +378 -0
  168. package/lib/esm/todoList-M-PGJKde.js.map +1 -0
  169. package/lib/esm/{tooltip-plugin-vZefVSGL.js → tooltip-plugin-iw2EQWIG.js} +10 -19
  170. package/lib/esm/tooltip-plugin-iw2EQWIG.js.map +1 -0
  171. package/lib/theme/_internal/classic-common.css +3 -2
  172. package/lib/theme/common/block-edit.css +3 -1
  173. package/lib/theme/common/code-mirror.css +15 -0
  174. package/lib/theme/common/cursor.css +1 -1
  175. package/lib/theme/common/image-block.css +2 -0
  176. package/lib/theme/common/link-tooltip.css +10 -13
  177. package/lib/theme/common/list-item.css +16 -1
  178. package/lib/theme/common/prosemirror.css +1 -1
  179. package/lib/theme/common/style.css +1 -0
  180. package/lib/theme/common/table.css +217 -0
  181. package/lib/theme/common/toolbar.css +11 -4
  182. package/lib/theme/{classic-dark → crepe-dark}/style.css +2 -2
  183. package/lib/theme/frame/style.css +28 -0
  184. package/lib/theme/frame-dark/style.css +28 -0
  185. package/lib/theme/nord/style.css +28 -0
  186. package/lib/theme/nord-dark/style.css +28 -0
  187. package/lib/types/core/crepe.d.ts +5 -3
  188. package/lib/types/core/crepe.d.ts.map +1 -1
  189. package/lib/types/core/slice.d.ts +2 -2
  190. package/lib/types/core/slice.d.ts.map +1 -1
  191. package/lib/types/feature/block-edit/handle/component.d.ts +3 -0
  192. package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
  193. package/lib/types/feature/block-edit/handle/index.d.ts +5 -4
  194. package/lib/types/feature/block-edit/handle/index.d.ts.map +1 -1
  195. package/lib/types/feature/block-edit/index.d.ts +43 -2
  196. package/lib/types/feature/block-edit/index.d.ts.map +1 -1
  197. package/lib/types/feature/block-edit/menu/component.d.ts +3 -1
  198. package/lib/types/feature/block-edit/menu/component.d.ts.map +1 -1
  199. package/lib/types/feature/block-edit/menu/config.d.ts +3 -12
  200. package/lib/types/feature/block-edit/menu/config.d.ts.map +1 -1
  201. package/lib/types/feature/block-edit/menu/group-builder.d.ts +29 -0
  202. package/lib/types/feature/block-edit/menu/group-builder.d.ts.map +1 -0
  203. package/lib/types/feature/block-edit/menu/index.d.ts +5 -4
  204. package/lib/types/feature/block-edit/menu/index.d.ts.map +1 -1
  205. package/lib/types/feature/block-edit/menu/utils.d.ts +28 -0
  206. package/lib/types/feature/block-edit/menu/utils.d.ts.map +1 -0
  207. package/lib/types/feature/code-mirror/index.d.ts +9 -1
  208. package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
  209. package/lib/types/feature/cursor/index.d.ts +1 -1
  210. package/lib/types/feature/cursor/index.d.ts.map +1 -1
  211. package/lib/types/feature/image-block/index.d.ts +19 -2
  212. package/lib/types/feature/image-block/index.d.ts.map +1 -1
  213. package/lib/types/feature/index.d.ts +17 -2
  214. package/lib/types/feature/index.d.ts.map +1 -1
  215. package/lib/types/feature/link-tooltip/index.d.ts +12 -2
  216. package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
  217. package/lib/types/feature/list-item/index.d.ts +8 -2
  218. package/lib/types/feature/list-item/index.d.ts.map +1 -1
  219. package/lib/types/feature/placeholder/index.d.ts +2 -2
  220. package/lib/types/feature/placeholder/index.d.ts.map +1 -1
  221. package/lib/types/feature/shared.d.ts +3 -1
  222. package/lib/types/feature/shared.d.ts.map +1 -1
  223. package/lib/types/feature/table/index.d.ts +16 -0
  224. package/lib/types/feature/table/index.d.ts.map +1 -0
  225. package/lib/types/feature/toolbar/component.d.ts +3 -1
  226. package/lib/types/feature/toolbar/component.d.ts.map +1 -1
  227. package/lib/types/feature/toolbar/index.d.ts +11 -2
  228. package/lib/types/feature/toolbar/index.d.ts.map +1 -1
  229. package/lib/types/icons/alignCenter.d.ts +2 -0
  230. package/lib/types/icons/alignCenter.d.ts.map +1 -0
  231. package/lib/types/icons/alignLeft.d.ts +2 -0
  232. package/lib/types/icons/alignLeft.d.ts.map +1 -0
  233. package/lib/types/icons/alignRight.d.ts +2 -0
  234. package/lib/types/icons/alignRight.d.ts.map +1 -0
  235. package/lib/types/icons/bold.d.ts +2 -0
  236. package/lib/types/icons/bold.d.ts.map +1 -0
  237. package/lib/types/{feature/list-item/consts.d.ts → icons/bullet.d.ts} +1 -1
  238. package/lib/types/icons/bullet.d.ts.map +1 -0
  239. package/lib/types/icons/bulletList.d.ts +2 -0
  240. package/lib/types/icons/bulletList.d.ts.map +1 -0
  241. package/lib/types/icons/caption.d.ts +2 -0
  242. package/lib/types/icons/caption.d.ts.map +1 -0
  243. package/lib/types/icons/checkBoxChecked.d.ts +2 -0
  244. package/lib/types/icons/checkBoxChecked.d.ts.map +1 -0
  245. package/lib/types/icons/checkBoxUnchecked.d.ts +2 -0
  246. package/lib/types/icons/checkBoxUnchecked.d.ts.map +1 -0
  247. package/lib/types/icons/chevronDown.d.ts +2 -0
  248. package/lib/types/icons/chevronDown.d.ts.map +1 -0
  249. package/lib/types/icons/clear.d.ts +2 -0
  250. package/lib/types/icons/clear.d.ts.map +1 -0
  251. package/lib/types/icons/code.d.ts +2 -0
  252. package/lib/types/icons/code.d.ts.map +1 -0
  253. package/lib/types/icons/confirm.d.ts +2 -0
  254. package/lib/types/icons/confirm.d.ts.map +1 -0
  255. package/lib/types/icons/divider.d.ts +2 -0
  256. package/lib/types/icons/divider.d.ts.map +1 -0
  257. package/lib/types/icons/dragHandle.d.ts +2 -0
  258. package/lib/types/icons/dragHandle.d.ts.map +1 -0
  259. package/lib/types/icons/edit.d.ts +2 -0
  260. package/lib/types/icons/edit.d.ts.map +1 -0
  261. package/lib/types/icons/h1.d.ts +2 -0
  262. package/lib/types/icons/h1.d.ts.map +1 -0
  263. package/lib/types/icons/h2.d.ts +2 -0
  264. package/lib/types/icons/h2.d.ts.map +1 -0
  265. package/lib/types/icons/h3.d.ts +2 -0
  266. package/lib/types/icons/h3.d.ts.map +1 -0
  267. package/lib/types/icons/h4.d.ts +2 -0
  268. package/lib/types/icons/h4.d.ts.map +1 -0
  269. package/lib/types/icons/h5.d.ts +2 -0
  270. package/lib/types/icons/h5.d.ts.map +1 -0
  271. package/lib/types/icons/h6.d.ts +2 -0
  272. package/lib/types/icons/h6.d.ts.map +1 -0
  273. package/lib/types/icons/image.d.ts +2 -0
  274. package/lib/types/icons/image.d.ts.map +1 -0
  275. package/lib/types/icons/index.d.ts +36 -0
  276. package/lib/types/icons/index.d.ts.map +1 -0
  277. package/lib/types/icons/italic.d.ts +2 -0
  278. package/lib/types/icons/italic.d.ts.map +1 -0
  279. package/lib/types/icons/link.d.ts +2 -0
  280. package/lib/types/icons/link.d.ts.map +1 -0
  281. package/lib/types/icons/menu.d.ts +2 -0
  282. package/lib/types/icons/menu.d.ts.map +1 -0
  283. package/lib/types/icons/orderedList.d.ts +2 -0
  284. package/lib/types/icons/orderedList.d.ts.map +1 -0
  285. package/lib/types/icons/plus.d.ts +2 -0
  286. package/lib/types/icons/plus.d.ts.map +1 -0
  287. package/lib/types/icons/quote.d.ts +2 -0
  288. package/lib/types/icons/quote.d.ts.map +1 -0
  289. package/lib/types/icons/remove.d.ts +2 -0
  290. package/lib/types/icons/remove.d.ts.map +1 -0
  291. package/lib/types/icons/search.d.ts +2 -0
  292. package/lib/types/icons/search.d.ts.map +1 -0
  293. package/lib/types/icons/strikethrough.d.ts +2 -0
  294. package/lib/types/icons/strikethrough.d.ts.map +1 -0
  295. package/lib/types/icons/table.d.ts +2 -0
  296. package/lib/types/icons/table.d.ts.map +1 -0
  297. package/lib/types/icons/text.d.ts +2 -0
  298. package/lib/types/icons/text.d.ts.map +1 -0
  299. package/lib/types/icons/todoList.d.ts +2 -0
  300. package/lib/types/icons/todoList.d.ts.map +1 -0
  301. package/lib/types/utils/index.d.ts +1 -1
  302. package/lib/types/utils/index.d.ts.map +1 -1
  303. package/package.json +9 -23
  304. package/src/core/crepe.ts +15 -9
  305. package/src/core/slice.ts +2 -2
  306. package/src/feature/block-edit/handle/component.ts +13 -29
  307. package/src/feature/block-edit/handle/index.ts +16 -17
  308. package/src/feature/block-edit/index.ts +50 -5
  309. package/src/feature/block-edit/menu/component.ts +6 -7
  310. package/src/feature/block-edit/menu/config.ts +203 -274
  311. package/src/feature/block-edit/menu/group-builder.ts +50 -0
  312. package/src/feature/block-edit/menu/index.ts +11 -8
  313. package/src/feature/block-edit/menu/utils.ts +89 -0
  314. package/src/feature/code-mirror/index.ts +27 -19
  315. package/src/feature/cursor/index.ts +3 -4
  316. package/src/feature/image-block/index.ts +34 -41
  317. package/src/feature/index.ts +23 -3
  318. package/src/feature/link-tooltip/index.ts +23 -10
  319. package/src/feature/list-item/index.ts +21 -9
  320. package/src/feature/placeholder/index.ts +11 -6
  321. package/src/feature/shared.ts +4 -1
  322. package/src/feature/table/index.ts +54 -0
  323. package/src/feature/toolbar/component.ts +29 -11
  324. package/src/feature/toolbar/index.ts +21 -9
  325. package/src/icons/alignCenter.ts +7 -0
  326. package/src/icons/alignLeft.ts +7 -0
  327. package/src/icons/alignRight.ts +7 -0
  328. package/src/icons/bold.ts +7 -0
  329. package/src/{feature/list-item/consts.ts → icons/bullet.ts} +3 -3
  330. package/src/icons/bulletList.ts +14 -0
  331. package/src/icons/caption.ts +7 -0
  332. package/src/icons/checkBoxChecked.ts +14 -0
  333. package/src/icons/checkBoxUnchecked.ts +14 -0
  334. package/src/icons/chevronDown.ts +7 -0
  335. package/src/icons/clear.ts +14 -0
  336. package/src/icons/code.ts +14 -0
  337. package/src/icons/confirm.ts +14 -0
  338. package/src/icons/divider.ts +14 -0
  339. package/src/icons/dragHandle.ts +7 -0
  340. package/src/icons/edit.ts +14 -0
  341. package/src/icons/h1.ts +14 -0
  342. package/src/icons/h2.ts +14 -0
  343. package/src/icons/h3.ts +14 -0
  344. package/src/icons/h4.ts +14 -0
  345. package/src/icons/h5.ts +14 -0
  346. package/src/icons/h6.ts +14 -0
  347. package/src/icons/image.ts +14 -0
  348. package/src/icons/index.ts +35 -0
  349. package/src/icons/italic.ts +7 -0
  350. package/src/icons/link.ts +7 -0
  351. package/src/icons/menu.ts +14 -0
  352. package/src/icons/orderedList.ts +14 -0
  353. package/src/icons/plus.ts +14 -0
  354. package/src/icons/quote.ts +14 -0
  355. package/src/icons/remove.ts +7 -0
  356. package/src/icons/search.ts +7 -0
  357. package/src/icons/strikethrough.ts +7 -0
  358. package/src/icons/table.ts +14 -0
  359. package/src/icons/text.ts +14 -0
  360. package/src/icons/todoList.ts +7 -0
  361. package/src/theme/_internal/classic-common.css +3 -2
  362. package/src/theme/common/block-edit.css +3 -1
  363. package/src/theme/common/code-mirror.css +13 -0
  364. package/src/theme/common/cursor.css +1 -1
  365. package/src/theme/common/image-block.css +2 -0
  366. package/src/theme/common/link-tooltip.css +11 -14
  367. package/src/theme/common/list-item.css +9 -0
  368. package/src/theme/common/prosemirror.css +1 -1
  369. package/src/theme/common/style.css +1 -0
  370. package/src/theme/common/table.css +204 -0
  371. package/src/theme/common/toolbar.css +14 -4
  372. package/src/theme/{classic-dark → crepe-dark}/style.css +2 -2
  373. package/src/theme/frame/style.css +28 -0
  374. package/src/theme/frame-dark/style.css +28 -0
  375. package/src/theme/nord/style.css +28 -0
  376. package/src/theme/nord-dark/style.css +28 -0
  377. package/src/utils/index.ts +1 -1
  378. package/lib/cjs/clsx-7JLENl8W.js +0 -62
  379. package/lib/cjs/clsx-7JLENl8W.js.map +0 -1
  380. package/lib/cjs/composed-offset-position.browser.min-FwypoGc1.js.map +0 -1
  381. package/lib/cjs/helper-OEW-2Vxr.js +0 -9
  382. package/lib/cjs/helper-OEW-2Vxr.js.map +0 -1
  383. package/lib/cjs/index-2oxl5Zo4.js.map +0 -1
  384. package/lib/cjs/index-GKolgvC5.js.map +0 -1
  385. package/lib/cjs/index-JAqL0ybh.js.map +0 -1
  386. package/lib/cjs/index-Ne_pk53w.js +0 -178
  387. package/lib/cjs/index-Ne_pk53w.js.map +0 -1
  388. package/lib/cjs/index-O3vRXWIP.js.map +0 -1
  389. package/lib/cjs/index-OIQn1x0L.js.map +0 -1
  390. package/lib/cjs/index-kNI3S3lF.js.map +0 -1
  391. package/lib/cjs/index-kvO8ReCY.js +0 -1960
  392. package/lib/cjs/index-kvO8ReCY.js.map +0 -1
  393. package/lib/cjs/index-llNS_EuP.js.map +0 -1
  394. package/lib/cjs/index-xqKfEyRA.js.map +0 -1
  395. package/lib/cjs/meta-q8q9fHyr.js +0 -14
  396. package/lib/cjs/meta-q8q9fHyr.js.map +0 -1
  397. package/lib/cjs/tooltip-plugin-Mk9fRTxI.js.map +0 -1
  398. package/lib/esm/clsx-R7WFaNKL.js +0 -52
  399. package/lib/esm/clsx-R7WFaNKL.js.map +0 -1
  400. package/lib/esm/composed-offset-position.browser.min-Tnm31e-m.js.map +0 -1
  401. package/lib/esm/helper-iYEjPbOY.js +0 -7
  402. package/lib/esm/helper-iYEjPbOY.js.map +0 -1
  403. package/lib/esm/index-218OjRxG.js.map +0 -1
  404. package/lib/esm/index-AHPvVH4H.js.map +0 -1
  405. package/lib/esm/index-DoEghZHy.js.map +0 -1
  406. package/lib/esm/index-JkHHp3K-.js.map +0 -1
  407. package/lib/esm/index-PkBZpDL4.js.map +0 -1
  408. package/lib/esm/index-TNMG6UrN.js.map +0 -1
  409. package/lib/esm/index-VyZguCIt.js.map +0 -1
  410. package/lib/esm/index-h1arGiXv.js +0 -1958
  411. package/lib/esm/index-h1arGiXv.js.map +0 -1
  412. package/lib/esm/index-pHsvfB_I.js.map +0 -1
  413. package/lib/esm/index-q-qE7-96.js.map +0 -1
  414. package/lib/esm/index-u8tWJbca.js +0 -176
  415. package/lib/esm/index-u8tWJbca.js.map +0 -1
  416. package/lib/esm/meta-3ZYGAGrY.js +0 -12
  417. package/lib/esm/meta-3ZYGAGrY.js.map +0 -1
  418. package/lib/esm/tooltip-plugin-vZefVSGL.js.map +0 -1
  419. package/lib/types/feature/block-edit/menu/icons.d.ts +0 -14
  420. package/lib/types/feature/block-edit/menu/icons.d.ts.map +0 -1
  421. package/lib/types/feature/link-tooltip/consts.d.ts +0 -5
  422. package/lib/types/feature/link-tooltip/consts.d.ts.map +0 -1
  423. package/lib/types/feature/list-item/consts.d.ts.map +0 -1
  424. package/lib/types/feature/toolbar/consts.d.ts +0 -5
  425. package/lib/types/feature/toolbar/consts.d.ts.map +0 -1
  426. package/src/feature/block-edit/menu/icons.ts +0 -170
  427. package/src/feature/link-tooltip/consts.ts +0 -46
  428. package/src/feature/toolbar/consts.ts +0 -25
  429. /package/lib/theme/{classic → crepe}/style.css +0 -0
  430. /package/src/theme/{classic → crepe}/style.css +0 -0
@@ -0,0 +1,1145 @@
1
+ import { w as withMeta, G as dragHandleIcon, H as alignRightIcon, I as alignCenterIcon, J as alignLeftIcon, r as removeIcon, B as plusIcon } from './todoList-M-PGJKde.js';
2
+ import { $ as $ctx, e as editorViewCtx, C as findTable, u as commandsCtx, D as selectColCommand, E as moveColCommand, F as selectRowCommand, G as moveRowCommand, H as addRowAfterCommand, I as addRowBeforeCommand, J as addColAfterCommand, K as addColBeforeCommand, L as deleteSelectedCellsCommand, M as setAlignCommand, N as tableSchema } from './index-LAdX6LsO.js';
3
+ import { NodeSelection } from '@milkdown/prose/state';
4
+ import { findParent } from '@milkdown/prose';
5
+ import { CellSelection } from '@milkdown/prose/tables';
6
+ import { d as defIfNotExists } from './helper-wZAtC67x.js';
7
+ import { useHost, useMemo, useEffect, useCallback, c, useRef, useLayoutEffect, html } from 'atomico';
8
+ import { c as clsx } from './clsx-RxCLxYpD.js';
9
+ import { t as throttle } from './index-uP9BKsTM.js';
10
+ import { c as computePosition, o as offset } from './floating-ui.dom-CAYjY8Gv.js';
11
+ import { $ as $view } from './_view-IlZC8FA6.js';
12
+ import '@milkdown/prose/model';
13
+ import '@milkdown/prose/commands';
14
+ import '@milkdown/prose/inputrules';
15
+ import '@milkdown/prose/keymap';
16
+ import '@milkdown/prose/view';
17
+ import '@milkdown/prose/schema-list';
18
+ import '@milkdown/prose/transform';
19
+ import '@milkdown/prose/history';
20
+
21
+ const defaultTableBlockConfig = {
22
+ renderButton: (renderType) => {
23
+ switch (renderType) {
24
+ case "add_row":
25
+ return "+";
26
+ case "add_col":
27
+ return "+";
28
+ case "delete_row":
29
+ return "-";
30
+ case "delete_col":
31
+ return "-";
32
+ case "align_col_left":
33
+ return "left";
34
+ case "align_col_center":
35
+ return "center";
36
+ case "align_col_right":
37
+ return "right";
38
+ case "col_drag_handle":
39
+ return "=";
40
+ case "row_drag_handle":
41
+ return "=";
42
+ }
43
+ }
44
+ };
45
+ const tableBlockConfig = $ctx({ ...defaultTableBlockConfig }, "tableBlockConfigCtx");
46
+ withMeta(tableBlockConfig, {
47
+ displayName: "Config<table-block>",
48
+ group: "TableBlock"
49
+ });
50
+
51
+ function findNodeIndex(parent, child) {
52
+ for (let i = 0; i < parent.childCount; i++) {
53
+ if (parent.child(i) === child)
54
+ return i;
55
+ }
56
+ return -1;
57
+ }
58
+ function findPointerIndex(event, view) {
59
+ var _a, _b, _c;
60
+ if (!view)
61
+ return;
62
+ const posAtCoords = view.posAtCoords({ left: event.clientX, top: event.clientY });
63
+ if (!posAtCoords)
64
+ return;
65
+ const pos = posAtCoords == null ? void 0 : posAtCoords.inside;
66
+ if (pos == null || pos < 0)
67
+ return;
68
+ const $pos = view.state.doc.resolve(pos);
69
+ const node = view.state.doc.nodeAt(pos);
70
+ if (!node)
71
+ return;
72
+ const cellType = ["table_cell", "table_header"];
73
+ const rowType = ["table_row", "table_header_row"];
74
+ const cell = cellType.includes(node.type.name) ? node : (_a = findParent((node2) => cellType.includes(node2.type.name))($pos)) == null ? void 0 : _a.node;
75
+ const row = (_b = findParent((node2) => rowType.includes(node2.type.name))($pos)) == null ? void 0 : _b.node;
76
+ const table = (_c = findParent((node2) => node2.type.name === "table")($pos)) == null ? void 0 : _c.node;
77
+ if (!cell || !row || !table)
78
+ return;
79
+ const columnIndex = findNodeIndex(row, cell);
80
+ const rowIndex = findNodeIndex(table, row);
81
+ return [rowIndex, columnIndex];
82
+ }
83
+ function getRelatedDOM(contentWrapperRef, [rowIndex, columnIndex]) {
84
+ const content = contentWrapperRef.current;
85
+ if (!content)
86
+ return;
87
+ const rows = content.querySelectorAll("tr");
88
+ const row = rows[rowIndex];
89
+ if (!row)
90
+ return;
91
+ const firstRow = rows[0];
92
+ if (!firstRow)
93
+ return;
94
+ const headerCol = firstRow.children[columnIndex];
95
+ if (!headerCol)
96
+ return;
97
+ const col = row.children[columnIndex];
98
+ if (!col)
99
+ return;
100
+ return {
101
+ row,
102
+ col,
103
+ headerCol
104
+ };
105
+ }
106
+ function recoveryStateBetweenUpdate(refs, ctx, node) {
107
+ if (!ctx)
108
+ return;
109
+ if (!node)
110
+ return;
111
+ const { selection } = ctx.get(editorViewCtx).state;
112
+ if (!(selection instanceof CellSelection))
113
+ return;
114
+ const { $from } = selection;
115
+ const table = findTable($from);
116
+ if (!table || table.node !== node)
117
+ return;
118
+ if (selection.isColSelection()) {
119
+ const { $head } = selection;
120
+ const colIndex = $head.index($head.depth - 1);
121
+ computeColHandlePositionByIndex({
122
+ refs,
123
+ index: [0, colIndex],
124
+ before: (handleDOM) => {
125
+ var _a;
126
+ (_a = handleDOM.querySelector(".button-group")) == null ? void 0 : _a.setAttribute("data-show", "true");
127
+ }
128
+ });
129
+ return;
130
+ }
131
+ if (selection.isRowSelection()) {
132
+ const { $head } = selection;
133
+ const rowNode = findParent((node2) => node2.type.name === "table_row" || node2.type.name === "table_header_row")($head);
134
+ if (!rowNode)
135
+ return;
136
+ const rowIndex = findNodeIndex(table.node, rowNode.node);
137
+ computeRowHandlePositionByIndex({
138
+ refs,
139
+ index: [rowIndex, 0],
140
+ before: (handleDOM) => {
141
+ var _a;
142
+ if (rowIndex > 0)
143
+ (_a = handleDOM.querySelector(".button-group")) == null ? void 0 : _a.setAttribute("data-show", "true");
144
+ }
145
+ });
146
+ }
147
+ }
148
+ function computeColHandlePositionByIndex({
149
+ refs,
150
+ index,
151
+ before,
152
+ after
153
+ }) {
154
+ const {
155
+ contentWrapperRef,
156
+ colHandleRef,
157
+ hoverIndex
158
+ } = refs;
159
+ const colHandle = colHandleRef.current;
160
+ if (!colHandle)
161
+ return;
162
+ hoverIndex.current = index;
163
+ const dom = getRelatedDOM(contentWrapperRef, index);
164
+ if (!dom)
165
+ return;
166
+ const { headerCol: col } = dom;
167
+ colHandle.dataset.show = "true";
168
+ if (before)
169
+ before(colHandle);
170
+ computePosition(col, colHandle, { placement: "top" }).then(({ x, y }) => {
171
+ Object.assign(colHandle.style, {
172
+ left: `${x}px`,
173
+ top: `${y}px`
174
+ });
175
+ if (after)
176
+ after(colHandle);
177
+ });
178
+ }
179
+ function computeRowHandlePositionByIndex({
180
+ refs,
181
+ index,
182
+ before,
183
+ after
184
+ }) {
185
+ const {
186
+ contentWrapperRef,
187
+ rowHandleRef,
188
+ hoverIndex
189
+ } = refs;
190
+ const rowHandle = rowHandleRef.current;
191
+ if (!rowHandle)
192
+ return;
193
+ hoverIndex.current = index;
194
+ const dom = getRelatedDOM(contentWrapperRef, index);
195
+ if (!dom)
196
+ return;
197
+ const { row } = dom;
198
+ rowHandle.dataset.show = "true";
199
+ if (before)
200
+ before(rowHandle);
201
+ computePosition(row, rowHandle, { placement: "left" }).then(({ x, y }) => {
202
+ Object.assign(rowHandle.style, {
203
+ left: `${x}px`,
204
+ top: `${y}px`
205
+ });
206
+ if (after)
207
+ after(rowHandle);
208
+ });
209
+ }
210
+
211
+ function prepareDndContext(refs) {
212
+ const {
213
+ dragPreviewRef,
214
+ tableWrapperRef,
215
+ contentWrapperRef,
216
+ yLineHandleRef,
217
+ xLineHandleRef,
218
+ colHandleRef,
219
+ rowHandleRef
220
+ } = refs;
221
+ const preview = dragPreviewRef.current;
222
+ if (!preview)
223
+ return;
224
+ const wrapper = tableWrapperRef.current;
225
+ if (!wrapper)
226
+ return;
227
+ const content = contentWrapperRef.current;
228
+ if (!content)
229
+ return;
230
+ const contentRoot = content.querySelector("tbody");
231
+ if (!contentRoot)
232
+ return;
233
+ const previewRoot = preview.querySelector("tbody");
234
+ if (!previewRoot)
235
+ return;
236
+ const yHandle = yLineHandleRef.current;
237
+ if (!yHandle)
238
+ return;
239
+ const xHandle = xLineHandleRef.current;
240
+ if (!xHandle)
241
+ return;
242
+ const colHandle = colHandleRef.current;
243
+ if (!colHandle)
244
+ return;
245
+ const rowHandle = rowHandleRef.current;
246
+ if (!rowHandle)
247
+ return;
248
+ const context = {
249
+ preview,
250
+ wrapper,
251
+ content,
252
+ contentRoot,
253
+ previewRoot,
254
+ yHandle,
255
+ xHandle,
256
+ colHandle,
257
+ rowHandle
258
+ };
259
+ return context;
260
+ }
261
+ function handleDrag(refs, event, ctx, fn) {
262
+ const view = ctx == null ? void 0 : ctx.get(editorViewCtx);
263
+ if (!(view == null ? void 0 : view.editable))
264
+ return;
265
+ event.stopPropagation();
266
+ if (event.dataTransfer)
267
+ event.dataTransfer.effectAllowed = "move";
268
+ const context = prepareDndContext(refs);
269
+ if (!context)
270
+ return;
271
+ requestAnimationFrame(() => {
272
+ fn(context);
273
+ });
274
+ }
275
+ function createDragRowHandler(refs, ctx) {
276
+ return (event) => {
277
+ handleDrag(refs, event, ctx, ({
278
+ preview,
279
+ content,
280
+ previewRoot,
281
+ yHandle,
282
+ xHandle,
283
+ colHandle,
284
+ rowHandle
285
+ }) => {
286
+ var _a;
287
+ const { hoverIndex, dragInfo } = refs;
288
+ xHandle.dataset.displayType = "indicator";
289
+ yHandle.dataset.show = "false";
290
+ colHandle.dataset.show = "false";
291
+ (_a = rowHandle.querySelector(".button-group")) == null ? void 0 : _a.setAttribute("data-show", "false");
292
+ const [rowIndex] = hoverIndex.current;
293
+ dragInfo.current = {
294
+ startCoords: [event.clientX, event.clientY],
295
+ startIndex: rowIndex,
296
+ endIndex: rowIndex,
297
+ type: "row"
298
+ };
299
+ preview.dataset.direction = "vertical";
300
+ const rows = content.querySelectorAll("tr");
301
+ while (previewRoot.firstChild)
302
+ previewRoot.removeChild(previewRoot.firstChild);
303
+ const row = rows[rowIndex];
304
+ if (!row)
305
+ return;
306
+ previewRoot.appendChild(row.cloneNode(true));
307
+ const height = row.getBoundingClientRect().height;
308
+ const { width } = content.querySelector("tbody").getBoundingClientRect();
309
+ Object.assign(preview.style, {
310
+ width: `${width}px`,
311
+ height: `${height}px`
312
+ });
313
+ preview.dataset.show = "true";
314
+ });
315
+ };
316
+ }
317
+ function createDragColHandler(refs, ctx) {
318
+ return (event) => {
319
+ handleDrag(refs, event, ctx, ({
320
+ preview,
321
+ content,
322
+ previewRoot,
323
+ yHandle,
324
+ xHandle,
325
+ colHandle,
326
+ rowHandle
327
+ }) => {
328
+ var _a;
329
+ const { hoverIndex, dragInfo } = refs;
330
+ xHandle.dataset.show = "false";
331
+ yHandle.dataset.displayType = "indicator";
332
+ rowHandle.dataset.show = "false";
333
+ (_a = colHandle.querySelector(".button-group")) == null ? void 0 : _a.setAttribute("data-show", "false");
334
+ const [_, colIndex] = hoverIndex.current;
335
+ dragInfo.current = {
336
+ startCoords: [event.clientX, event.clientY],
337
+ startIndex: colIndex,
338
+ endIndex: colIndex,
339
+ type: "col"
340
+ };
341
+ preview.dataset.direction = "horizontal";
342
+ const rows = content.querySelectorAll("tr");
343
+ while (previewRoot.firstChild)
344
+ previewRoot.removeChild(previewRoot.firstChild);
345
+ let width;
346
+ Array.from(rows).forEach((row) => {
347
+ const col = row.children[colIndex];
348
+ if (!col)
349
+ return;
350
+ if (width === void 0)
351
+ width = col.getBoundingClientRect().width;
352
+ const tr = col.parentElement.cloneNode(false);
353
+ const clone = col.cloneNode(true);
354
+ tr.appendChild(clone);
355
+ previewRoot.appendChild(tr);
356
+ });
357
+ const { height } = content.querySelector("tbody").getBoundingClientRect();
358
+ Object.assign(preview.style, {
359
+ width: `${width}px`,
360
+ height: `${height}px`
361
+ });
362
+ preview.dataset.show = "true";
363
+ });
364
+ };
365
+ }
366
+ function createDragOverHandler(refs) {
367
+ return throttle((e) => {
368
+ const context = prepareDndContext(refs);
369
+ if (!context)
370
+ return;
371
+ const {
372
+ preview,
373
+ content,
374
+ contentRoot,
375
+ xHandle,
376
+ yHandle
377
+ } = context;
378
+ const {
379
+ dragInfo,
380
+ hoverIndex
381
+ } = refs;
382
+ if (preview.dataset.show === "false")
383
+ return;
384
+ const dom = getRelatedDOM(refs.contentWrapperRef, hoverIndex.current);
385
+ if (!dom)
386
+ return;
387
+ const firstRow = contentRoot.querySelector("tr");
388
+ if (!firstRow)
389
+ return;
390
+ const info = dragInfo.current;
391
+ if (!info)
392
+ return;
393
+ const wrapperOffsetTop = contentRoot.offsetParent.offsetTop;
394
+ const wrapperOffsetLeft = contentRoot.offsetParent.offsetLeft;
395
+ if (info.type === "col") {
396
+ const width = dom.col.getBoundingClientRect().width;
397
+ const { left, width: fullWidth } = contentRoot.getBoundingClientRect();
398
+ const leftGap = wrapperOffsetLeft - left;
399
+ const previewLeft = e.clientX + leftGap - width / 2;
400
+ const previewRight = e.clientX + leftGap + width / 2;
401
+ const [startX] = info.startCoords;
402
+ const direction = startX < e.clientX ? "right" : "left";
403
+ preview.style.top = `${wrapperOffsetTop}px`;
404
+ const previewLeftOffset = previewLeft < left + leftGap - 20 ? left + leftGap - 20 : previewLeft > left + fullWidth + leftGap - width + 20 ? left + fullWidth + leftGap - width + 20 : previewLeft;
405
+ preview.style.left = `${previewLeftOffset}px`;
406
+ const children = Array.from(firstRow.children);
407
+ const col = children.find((col2, index) => {
408
+ const boundary = col2.getBoundingClientRect();
409
+ const boundaryLeft = boundary.left + wrapperOffsetLeft - left;
410
+ const boundaryRight = boundary.right + wrapperOffsetLeft - left;
411
+ if (direction === "right") {
412
+ if (boundaryLeft <= previewRight && boundaryRight >= previewRight)
413
+ return true;
414
+ if (index === firstRow.children.length - 1 && previewRight > boundaryRight)
415
+ return true;
416
+ } else {
417
+ if (boundaryLeft <= previewLeft && boundaryRight >= previewLeft)
418
+ return true;
419
+ if (index === 0 && previewLeft < boundaryLeft)
420
+ return true;
421
+ }
422
+ return false;
423
+ });
424
+ if (col) {
425
+ const yHandleWidth = yHandle.getBoundingClientRect().width;
426
+ const contentBoundary = content.getBoundingClientRect();
427
+ const index = children.indexOf(col);
428
+ info.endIndex = index;
429
+ computePosition(col, yHandle, {
430
+ placement: direction === "left" ? "left" : "right",
431
+ middleware: [offset(direction === "left" ? -1 * yHandleWidth : 0)]
432
+ }).then(({ x }) => {
433
+ yHandle.dataset.show = "true";
434
+ Object.assign(yHandle.style, {
435
+ height: `${contentBoundary.height}px`,
436
+ left: `${x}px`,
437
+ top: `${wrapperOffsetTop}px`
438
+ });
439
+ });
440
+ }
441
+ } else if (info.type === "row") {
442
+ const height = dom.row.getBoundingClientRect().height;
443
+ const { top, height: fullHeight } = contentRoot.getBoundingClientRect();
444
+ const topGap = wrapperOffsetTop - top;
445
+ const previewTop = e.clientY + topGap - height / 2;
446
+ const previewBottom = e.clientY + topGap + height / 2;
447
+ const [_, startY] = info.startCoords;
448
+ const direction = startY < e.clientY ? "down" : "up";
449
+ const previewTopOffset = previewTop < top + topGap - 20 ? top + topGap - 20 : previewTop > top + fullHeight + topGap - height + 20 ? top + fullHeight + topGap - height + 20 : previewTop;
450
+ preview.style.top = `${previewTopOffset}px`;
451
+ preview.style.left = `${wrapperOffsetLeft}px`;
452
+ const rows = Array.from(contentRoot.querySelectorAll("tr"));
453
+ const row = rows.find((row2, index) => {
454
+ const boundary = row2.getBoundingClientRect();
455
+ const boundaryTop = boundary.top + wrapperOffsetTop - top;
456
+ const boundaryBottom = boundary.bottom + wrapperOffsetTop - top;
457
+ if (direction === "down") {
458
+ if (boundaryTop <= previewBottom && boundaryBottom >= previewBottom)
459
+ return true;
460
+ if (index === rows.length - 1 && previewBottom > boundaryBottom)
461
+ return true;
462
+ } else {
463
+ if (boundaryTop <= previewTop && boundaryBottom >= previewTop)
464
+ return true;
465
+ if (index === 0 && previewTop < boundaryTop)
466
+ return true;
467
+ }
468
+ return false;
469
+ });
470
+ if (row) {
471
+ const xHandleHeight = xHandle.getBoundingClientRect().height;
472
+ const contentBoundary = content.getBoundingClientRect();
473
+ const index = rows.indexOf(row);
474
+ info.endIndex = index;
475
+ computePosition(row, xHandle, {
476
+ placement: direction === "up" ? "top" : "bottom",
477
+ middleware: [offset(direction === "up" ? -1 * xHandleHeight : 0)]
478
+ }).then(({ y }) => {
479
+ xHandle.dataset.show = "true";
480
+ Object.assign(xHandle.style, {
481
+ width: `${contentBoundary.width}px`,
482
+ top: `${y}px`
483
+ });
484
+ });
485
+ }
486
+ }
487
+ }, 20);
488
+ }
489
+ function useDragHandlers(refs, ctx, getPos) {
490
+ const {
491
+ dragPreviewRef,
492
+ yLineHandleRef,
493
+ xLineHandleRef,
494
+ dragInfo
495
+ } = refs;
496
+ const host = useHost();
497
+ const root = useMemo(() => host.current.getRootNode(), [host]);
498
+ const dragRow = useMemo(() => createDragRowHandler(refs, ctx), [refs]);
499
+ const dragCol = useMemo(() => createDragColHandler(refs, ctx), [refs]);
500
+ useEffect(() => {
501
+ const onDragEnd = () => {
502
+ const preview = dragPreviewRef.current;
503
+ if (!preview)
504
+ return;
505
+ if (preview.dataset.show === "false")
506
+ return;
507
+ const previewRoot = preview == null ? void 0 : preview.querySelector("tbody");
508
+ while (previewRoot == null ? void 0 : previewRoot.firstChild)
509
+ previewRoot == null ? void 0 : previewRoot.removeChild(previewRoot.firstChild);
510
+ if (preview)
511
+ preview.dataset.show = "false";
512
+ };
513
+ const onDrop = () => {
514
+ var _a;
515
+ const preview = dragPreviewRef.current;
516
+ if (!preview)
517
+ return;
518
+ const yHandle = yLineHandleRef.current;
519
+ if (!yHandle)
520
+ return;
521
+ const xHandle = xLineHandleRef.current;
522
+ if (!xHandle)
523
+ return;
524
+ const info = dragInfo.current;
525
+ if (!info)
526
+ return;
527
+ if (!ctx)
528
+ return;
529
+ if (preview.dataset.show === "false")
530
+ return;
531
+ const colHandle = refs.colHandleRef.current;
532
+ if (!colHandle)
533
+ return;
534
+ const rowHandle = refs.rowHandleRef.current;
535
+ if (!rowHandle)
536
+ return;
537
+ yHandle.dataset.show = "false";
538
+ xHandle.dataset.show = "false";
539
+ if (info.startIndex === info.endIndex)
540
+ return;
541
+ const commands = ctx.get(commandsCtx);
542
+ const payload = {
543
+ from: info.startIndex,
544
+ to: info.endIndex,
545
+ pos: ((_a = getPos == null ? void 0 : getPos()) != null ? _a : 0) + 1
546
+ };
547
+ if (info.type === "col") {
548
+ commands.call(selectColCommand.key, {
549
+ pos: payload.pos,
550
+ index: info.startIndex
551
+ });
552
+ commands.call(moveColCommand.key, payload);
553
+ const index = [0, info.endIndex];
554
+ computeColHandlePositionByIndex({
555
+ refs,
556
+ index
557
+ });
558
+ } else {
559
+ commands.call(selectRowCommand.key, {
560
+ pos: payload.pos,
561
+ index: info.startIndex
562
+ });
563
+ commands.call(moveRowCommand.key, payload);
564
+ const index = [info.endIndex, 0];
565
+ computeRowHandlePositionByIndex({
566
+ refs,
567
+ index
568
+ });
569
+ }
570
+ };
571
+ const onDragOver = createDragOverHandler(refs);
572
+ root.addEventListener("dragover", onDragOver);
573
+ root.addEventListener("dragend", onDragEnd);
574
+ root.addEventListener("drop", onDrop);
575
+ return () => {
576
+ root.removeEventListener("dragover", onDragOver);
577
+ root.removeEventListener("dragend", onDragEnd);
578
+ root.removeEventListener("drop", onDrop);
579
+ };
580
+ }, []);
581
+ return {
582
+ dragRow,
583
+ dragCol
584
+ };
585
+ }
586
+
587
+ function createPointerMoveHandler(refs, view) {
588
+ return throttle((e) => {
589
+ if (!(view == null ? void 0 : view.editable))
590
+ return;
591
+ const {
592
+ contentWrapperRef,
593
+ yLineHandleRef,
594
+ xLineHandleRef,
595
+ colHandleRef,
596
+ rowHandleRef,
597
+ hoverIndex,
598
+ lineHoverIndex
599
+ } = refs;
600
+ const yHandle = yLineHandleRef.current;
601
+ if (!yHandle)
602
+ return;
603
+ const xHandle = xLineHandleRef.current;
604
+ if (!xHandle)
605
+ return;
606
+ const content = contentWrapperRef.current;
607
+ if (!content)
608
+ return;
609
+ const rowHandle = rowHandleRef.current;
610
+ if (!rowHandle)
611
+ return;
612
+ const colHandle = colHandleRef.current;
613
+ if (!colHandle)
614
+ return;
615
+ const index = findPointerIndex(e, view);
616
+ if (!index)
617
+ return;
618
+ const dom = getRelatedDOM(contentWrapperRef, index);
619
+ if (!dom)
620
+ return;
621
+ const [rowIndex, colIndex] = index;
622
+ const boundary = dom.col.getBoundingClientRect();
623
+ const closeToBoundaryLeft = Math.abs(e.clientX - boundary.left) < 8;
624
+ const closeToBoundaryRight = Math.abs(boundary.right - e.clientX) < 8;
625
+ const closeToBoundaryTop = Math.abs(e.clientY - boundary.top) < 8;
626
+ const closeToBoundaryBottom = Math.abs(boundary.bottom - e.clientY) < 8;
627
+ const closeToBoundary = closeToBoundaryLeft || closeToBoundaryRight || closeToBoundaryTop || closeToBoundaryBottom;
628
+ const rowButtonGroup = rowHandle.querySelector(".button-group");
629
+ const colButtonGroup = colHandle.querySelector(".button-group");
630
+ if (rowButtonGroup)
631
+ rowButtonGroup.dataset.show = "false";
632
+ if (colButtonGroup)
633
+ colButtonGroup.dataset.show = "false";
634
+ if (closeToBoundary) {
635
+ const contentBoundary = content.getBoundingClientRect();
636
+ rowHandle.dataset.show = "false";
637
+ colHandle.dataset.show = "false";
638
+ xHandle.dataset.displayType = "tool";
639
+ yHandle.dataset.displayType = "tool";
640
+ const yHandleWidth = yHandle.getBoundingClientRect().width;
641
+ const xHandleHeight = xHandle.getBoundingClientRect().height;
642
+ if (closeToBoundaryLeft || closeToBoundaryRight) {
643
+ lineHoverIndex.current[1] = closeToBoundaryLeft ? colIndex : colIndex + 1;
644
+ computePosition(dom.col, yHandle, {
645
+ placement: closeToBoundaryLeft ? "left" : "right",
646
+ middleware: [offset(closeToBoundaryLeft ? -1 * yHandleWidth : 0)]
647
+ }).then(({ x }) => {
648
+ yHandle.dataset.show = "true";
649
+ Object.assign(yHandle.style, {
650
+ height: `${contentBoundary.height}px`,
651
+ left: `${x}px`
652
+ });
653
+ });
654
+ } else {
655
+ yHandle.dataset.show = "false";
656
+ }
657
+ if (index[0] !== 0 && (closeToBoundaryTop || closeToBoundaryBottom)) {
658
+ lineHoverIndex.current[0] = closeToBoundaryTop ? rowIndex : rowIndex + 1;
659
+ computePosition(dom.row, xHandle, {
660
+ placement: closeToBoundaryTop ? "top" : "bottom",
661
+ middleware: [offset(closeToBoundaryTop ? -1 * xHandleHeight : 0)]
662
+ }).then(({ y }) => {
663
+ xHandle.dataset.show = "true";
664
+ Object.assign(xHandle.style, {
665
+ width: `${contentBoundary.width}px`,
666
+ top: `${y}px`
667
+ });
668
+ });
669
+ } else {
670
+ xHandle.dataset.show = "false";
671
+ }
672
+ return;
673
+ }
674
+ lineHoverIndex.current = [-1, -1];
675
+ yHandle.dataset.show = "false";
676
+ xHandle.dataset.show = "false";
677
+ rowHandle.dataset.show = "true";
678
+ colHandle.dataset.show = "true";
679
+ computeRowHandlePositionByIndex({
680
+ refs,
681
+ index
682
+ });
683
+ computeColHandlePositionByIndex({
684
+ refs,
685
+ index
686
+ });
687
+ hoverIndex.current = index;
688
+ }, 20);
689
+ }
690
+ function createPointerLeaveHandler(refs) {
691
+ return () => {
692
+ const {
693
+ rowHandleRef,
694
+ colHandleRef,
695
+ yLineHandleRef,
696
+ xLineHandleRef
697
+ } = refs;
698
+ setTimeout(() => {
699
+ const rowHandle = rowHandleRef.current;
700
+ if (!rowHandle)
701
+ return;
702
+ const colHandle = colHandleRef.current;
703
+ if (!colHandle)
704
+ return;
705
+ const yHandle = yLineHandleRef.current;
706
+ if (!yHandle)
707
+ return;
708
+ const xHandle = xLineHandleRef.current;
709
+ if (!xHandle)
710
+ return;
711
+ rowHandle.dataset.show = "false";
712
+ colHandle.dataset.show = "false";
713
+ yHandle.dataset.show = "false";
714
+ xHandle.dataset.show = "false";
715
+ }, 200);
716
+ };
717
+ }
718
+ function usePointerHandlers(refs, view) {
719
+ const pointerMove = useMemo(() => createPointerMoveHandler(refs, view), []);
720
+ const pointerLeave = useMemo(() => createPointerLeaveHandler(refs), []);
721
+ return {
722
+ pointerMove,
723
+ pointerLeave
724
+ };
725
+ }
726
+
727
+ function useOperation(refs, ctx, getPos) {
728
+ const {
729
+ xLineHandleRef,
730
+ contentWrapperRef,
731
+ colHandleRef,
732
+ rowHandleRef,
733
+ hoverIndex,
734
+ lineHoverIndex
735
+ } = refs;
736
+ const onAddRow = useCallback(() => {
737
+ var _a, _b, _c;
738
+ if (!ctx)
739
+ return;
740
+ const xHandle = xLineHandleRef.current;
741
+ if (!xHandle)
742
+ return;
743
+ const [rowIndex] = lineHoverIndex.current;
744
+ if (rowIndex < 0)
745
+ return;
746
+ if (!ctx.get(editorViewCtx).editable)
747
+ return;
748
+ const rows = Array.from((_b = (_a = contentWrapperRef.current) == null ? void 0 : _a.querySelectorAll("tr")) != null ? _b : []);
749
+ const commands = ctx.get(commandsCtx);
750
+ const pos = ((_c = getPos == null ? void 0 : getPos()) != null ? _c : 0) + 1;
751
+ if (rows.length === rowIndex) {
752
+ commands.call(selectRowCommand.key, { pos, index: rowIndex - 1 });
753
+ commands.call(addRowAfterCommand.key);
754
+ } else {
755
+ commands.call(selectRowCommand.key, { pos, index: rowIndex });
756
+ commands.call(addRowBeforeCommand.key);
757
+ }
758
+ commands.call(selectRowCommand.key, { pos, index: rowIndex });
759
+ xHandle.dataset.show = "false";
760
+ }, []);
761
+ const onAddCol = useCallback(() => {
762
+ var _a, _b, _c, _d;
763
+ if (!ctx)
764
+ return;
765
+ const xHandle = xLineHandleRef.current;
766
+ if (!xHandle)
767
+ return;
768
+ const [_, colIndex] = lineHoverIndex.current;
769
+ if (colIndex < 0)
770
+ return;
771
+ if (!ctx.get(editorViewCtx).editable)
772
+ return;
773
+ const cols = Array.from((_c = (_b = (_a = contentWrapperRef.current) == null ? void 0 : _a.querySelector("tr")) == null ? void 0 : _b.children) != null ? _c : []);
774
+ const commands = ctx.get(commandsCtx);
775
+ const pos = ((_d = getPos == null ? void 0 : getPos()) != null ? _d : 0) + 1;
776
+ if (cols.length === colIndex) {
777
+ commands.call(selectColCommand.key, { pos, index: colIndex - 1 });
778
+ commands.call(addColAfterCommand.key);
779
+ } else {
780
+ commands.call(selectColCommand.key, { pos, index: colIndex });
781
+ commands.call(addColBeforeCommand.key);
782
+ }
783
+ commands.call(selectColCommand.key, { pos, index: colIndex });
784
+ }, []);
785
+ const selectCol = useCallback(() => {
786
+ var _a, _b;
787
+ if (!ctx)
788
+ return;
789
+ const [_, colIndex] = hoverIndex.current;
790
+ const commands = ctx.get(commandsCtx);
791
+ const pos = ((_a = getPos == null ? void 0 : getPos()) != null ? _a : 0) + 1;
792
+ commands.call(selectColCommand.key, { pos, index: colIndex });
793
+ const buttonGroup = (_b = colHandleRef.current) == null ? void 0 : _b.querySelector(".button-group");
794
+ if (buttonGroup)
795
+ buttonGroup.dataset.show = buttonGroup.dataset.show === "true" ? "false" : "true";
796
+ }, []);
797
+ const selectRow = useCallback(() => {
798
+ var _a, _b;
799
+ if (!ctx)
800
+ return;
801
+ const [rowIndex, _] = hoverIndex.current;
802
+ const commands = ctx.get(commandsCtx);
803
+ const pos = ((_a = getPos == null ? void 0 : getPos()) != null ? _a : 0) + 1;
804
+ commands.call(selectRowCommand.key, { pos, index: rowIndex });
805
+ const buttonGroup = (_b = rowHandleRef.current) == null ? void 0 : _b.querySelector(".button-group");
806
+ if (buttonGroup && rowIndex > 0)
807
+ buttonGroup.dataset.show = buttonGroup.dataset.show === "true" ? "false" : "true";
808
+ }, []);
809
+ const deleteSelected = useCallback((e) => {
810
+ if (!ctx)
811
+ return;
812
+ if (!ctx.get(editorViewCtx).editable)
813
+ return;
814
+ e.preventDefault();
815
+ e.stopPropagation();
816
+ const commands = ctx.get(commandsCtx);
817
+ commands.call(deleteSelectedCellsCommand.key);
818
+ }, []);
819
+ const onAlign = useCallback((direction) => (e) => {
820
+ if (!ctx)
821
+ return;
822
+ if (!ctx.get(editorViewCtx).editable)
823
+ return;
824
+ e.preventDefault();
825
+ e.stopPropagation();
826
+ const commands = ctx.get(commandsCtx);
827
+ commands.call(setAlignCommand.key, direction);
828
+ }, []);
829
+ return {
830
+ onAddRow,
831
+ onAddCol,
832
+ selectCol,
833
+ selectRow,
834
+ deleteSelected,
835
+ onAlign
836
+ };
837
+ }
838
+
839
+ const tableComponent = ({
840
+ view,
841
+ ctx,
842
+ getPos,
843
+ node,
844
+ config
845
+ }) => {
846
+ const host = useHost();
847
+ const contentWrapperRef = useRef();
848
+ const colHandleRef = useRef();
849
+ const rowHandleRef = useRef();
850
+ const xLineHandleRef = useRef();
851
+ const yLineHandleRef = useRef();
852
+ const tableWrapperRef = useRef();
853
+ const dragPreviewRef = useRef();
854
+ const hoverIndex = useRef([0, 0]);
855
+ const lineHoverIndex = useRef([-1, -1]);
856
+ const dragInfo = useRef();
857
+ const refs = useMemo(() => {
858
+ return {
859
+ dragPreviewRef,
860
+ tableWrapperRef,
861
+ contentWrapperRef,
862
+ yLineHandleRef,
863
+ xLineHandleRef,
864
+ colHandleRef,
865
+ rowHandleRef,
866
+ hoverIndex,
867
+ lineHoverIndex,
868
+ dragInfo
869
+ };
870
+ }, []);
871
+ useLayoutEffect(() => {
872
+ const current = contentWrapperRef.current;
873
+ if (!current)
874
+ return;
875
+ const contentDOM = host.current.querySelector("[data-content-dom]");
876
+ if (contentDOM)
877
+ current.appendChild(contentDOM);
878
+ if (view == null ? void 0 : view.editable)
879
+ recoveryStateBetweenUpdate(refs, ctx, node);
880
+ }, []);
881
+ const { pointerLeave, pointerMove } = usePointerHandlers(refs, view);
882
+ const { dragRow, dragCol } = useDragHandlers(refs, ctx, getPos);
883
+ const {
884
+ onAddRow,
885
+ onAddCol,
886
+ selectCol,
887
+ selectRow,
888
+ deleteSelected,
889
+ onAlign
890
+ } = useOperation(refs, ctx, getPos);
891
+ return html`
892
+ <host
893
+ class=${clsx(!(view == null ? void 0 : view.editable) && "readonly")}
894
+ ondragstart=${(e) => e.preventDefault()}
895
+ ondragover=${(e) => e.preventDefault()}
896
+ ondragleave=${(e) => e.preventDefault()}
897
+ onpointermove=${pointerMove}
898
+ onpointerleave=${pointerLeave}
899
+ >
900
+ <button
901
+ data-show="false"
902
+ contenteditable="false"
903
+ draggable="true"
904
+ data-role="col-drag-handle"
905
+ class="handle cell-handle"
906
+ ondragstart=${dragCol}
907
+ onclick=${selectCol}
908
+ onpointerdown=${(e) => e.stopPropagation()}
909
+ onpointermove=${(e) => e.stopPropagation()}
910
+ ref=${colHandleRef}
911
+ >
912
+ ${config == null ? void 0 : config.renderButton("col_drag_handle")}
913
+ <div
914
+ data-show="false"
915
+ class="button-group"
916
+ onpointermove=${(e) => e.stopPropagation}
917
+ >
918
+ <button onpointerdown=${onAlign("left")}>
919
+ ${config == null ? void 0 : config.renderButton("align_col_left")}
920
+ </button>
921
+ <button onpointerdown=${onAlign("center")}>
922
+ ${config == null ? void 0 : config.renderButton("align_col_center")}
923
+ </button>
924
+ <button onpointerdown=${onAlign("right")}>
925
+ ${config == null ? void 0 : config.renderButton("align_col_right")}
926
+ </button>
927
+ <button onpointerdown=${deleteSelected}>
928
+ ${config == null ? void 0 : config.renderButton("delete_col")}
929
+ </button>
930
+ </div>
931
+ </button>
932
+ <button
933
+ data-show="false"
934
+ contenteditable="false"
935
+ draggable="true"
936
+ data-role="row-drag-handle"
937
+ class="handle cell-handle"
938
+ ondragstart=${dragRow}
939
+ onclick=${selectRow}
940
+ onpointerdown=${(e) => e.stopPropagation()}
941
+ onpointermove=${(e) => e.stopPropagation()}
942
+ ref=${rowHandleRef}
943
+ >
944
+ ${config == null ? void 0 : config.renderButton("row_drag_handle")}
945
+ <div
946
+ data-show="false"
947
+ class="button-group"
948
+ onpointermove=${(e) => e.stopPropagation}
949
+ >
950
+ <button onpointerdown=${deleteSelected}>
951
+ ${config == null ? void 0 : config.renderButton("delete_row")}
952
+ </button>
953
+ </div>
954
+ </button>
955
+ <div class="table-wrapper" ref=${tableWrapperRef}>
956
+ <div
957
+ data-show="false"
958
+ class="drag-preview"
959
+ data-direction="vertical"
960
+ ref=${dragPreviewRef}
961
+ >
962
+ <table>
963
+ <tbody>
964
+ </tbody>
965
+ </table>
966
+ </div>
967
+ <div
968
+ data-show="false"
969
+ contenteditable="false"
970
+ data-display-type="tool"
971
+ data-role="x-line-drag-handle"
972
+ class="handle line-handle"
973
+ onpointermove=${(e) => e.stopPropagation}
974
+ ref=${xLineHandleRef}
975
+ >
976
+ <button onclick=${onAddRow} class="add-button">
977
+ ${config == null ? void 0 : config.renderButton("add_row")}
978
+ </button>
979
+ </div>
980
+ <div
981
+ data-show="false"
982
+ contenteditable="false"
983
+ data-display-type="tool"
984
+ data-role="y-line-drag-handle"
985
+ class="handle line-handle"
986
+ onpointermove=${(e) => e.stopPropagation}
987
+ ref=${yLineHandleRef}
988
+ >
989
+ <button onclick=${onAddCol} class="add-button">
990
+ ${config == null ? void 0 : config.renderButton("add_col")}
991
+ </button>
992
+ </div>
993
+ <table ref=${contentWrapperRef} class="children"></table>
994
+ </div>
995
+ </host>
996
+ `;
997
+ };
998
+ tableComponent.props = {
999
+ getPos: Function,
1000
+ view: Object,
1001
+ ctx: Object,
1002
+ node: Object,
1003
+ config: Object
1004
+ };
1005
+ const TableElement = c(tableComponent);
1006
+
1007
+ var __typeError = (msg) => {
1008
+ throw TypeError(msg);
1009
+ };
1010
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
1011
+ 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);
1012
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
1013
+ var _TableNodeView_instances, handleClick_fn;
1014
+ class TableNodeView {
1015
+ constructor(ctx, node, view, getPos) {
1016
+ this.ctx = ctx;
1017
+ this.node = node;
1018
+ this.view = view;
1019
+ this.getPos = getPos;
1020
+ __privateAdd(this, _TableNodeView_instances);
1021
+ const dom = document.createElement("milkdown-table-block");
1022
+ this.dom = dom;
1023
+ dom.view = view;
1024
+ dom.ctx = ctx;
1025
+ dom.getPos = getPos;
1026
+ dom.node = node;
1027
+ dom.config = ctx.get(tableBlockConfig.key);
1028
+ const contentDOM = document.createElement("tbody");
1029
+ this.contentDOM = contentDOM;
1030
+ contentDOM.setAttribute("data-content-dom", "true");
1031
+ contentDOM.classList.add("content-dom");
1032
+ dom.appendChild(contentDOM);
1033
+ }
1034
+ update(node) {
1035
+ if (node.type !== this.node.type)
1036
+ return false;
1037
+ if (node.sameMarkup(this.node) && node.content.eq(this.node.content))
1038
+ return false;
1039
+ this.node = node;
1040
+ this.dom.node = node;
1041
+ return true;
1042
+ }
1043
+ stopEvent(e) {
1044
+ if (e.type === "drop" || e.type.startsWith("drag"))
1045
+ return true;
1046
+ if (e.type === "mousedown") {
1047
+ if (e.target instanceof HTMLButtonElement)
1048
+ return true;
1049
+ const target = e.target;
1050
+ if (target instanceof HTMLElement && (target.closest("th") || target.closest("td"))) {
1051
+ const event = e;
1052
+ return __privateMethod(this, _TableNodeView_instances, handleClick_fn).call(this, event);
1053
+ }
1054
+ }
1055
+ return false;
1056
+ }
1057
+ ignoreMutation(mutation) {
1058
+ if (!this.dom || !this.contentDOM)
1059
+ return true;
1060
+ if (mutation.type === "selection")
1061
+ return false;
1062
+ if (this.contentDOM === mutation.target && mutation.type === "attributes")
1063
+ return true;
1064
+ if (this.contentDOM.contains(mutation.target))
1065
+ return false;
1066
+ return true;
1067
+ }
1068
+ }
1069
+ _TableNodeView_instances = new WeakSet();
1070
+ handleClick_fn = function(event) {
1071
+ const view = this.view;
1072
+ if (!view.editable)
1073
+ return false;
1074
+ const { state, dispatch } = view;
1075
+ const pos = view.posAtCoords({ left: event.clientX, top: event.clientY });
1076
+ if (!pos)
1077
+ return false;
1078
+ const $pos = state.doc.resolve(pos.inside);
1079
+ const node = findParent((node2) => node2.type.name === "table_cell" || node2.type.name === "table_header")($pos);
1080
+ if (!node)
1081
+ return false;
1082
+ const { from } = node;
1083
+ const selection = NodeSelection.create(state.doc, from + 1);
1084
+ if (state.selection.eq(selection))
1085
+ return false;
1086
+ if (state.selection instanceof CellSelection) {
1087
+ setTimeout(() => {
1088
+ dispatch(state.tr.setSelection(selection).scrollIntoView());
1089
+ }, 20);
1090
+ } else {
1091
+ requestAnimationFrame(() => {
1092
+ dispatch(state.tr.setSelection(selection).scrollIntoView());
1093
+ });
1094
+ }
1095
+ return true;
1096
+ };
1097
+ defIfNotExists("milkdown-table-block", TableElement);
1098
+ const tableBlockView = $view(tableSchema.node, (ctx) => {
1099
+ return (initialNode, view, getPos) => {
1100
+ return new TableNodeView(ctx, initialNode, view, getPos);
1101
+ };
1102
+ });
1103
+ withMeta(tableBlockView, {
1104
+ displayName: "NodeView<table-block>",
1105
+ group: "TableBlock"
1106
+ });
1107
+
1108
+ const tableBlock = [
1109
+ tableBlockConfig,
1110
+ tableBlockView
1111
+ ];
1112
+
1113
+ const defineFeature = (editor, config) => {
1114
+ editor.config((ctx) => {
1115
+ ctx.update(tableBlockConfig.key, (defaultConfig) => ({
1116
+ ...defaultConfig,
1117
+ renderButton: (renderType) => {
1118
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1119
+ switch (renderType) {
1120
+ case "add_row":
1121
+ return (_b = (_a = config == null ? void 0 : config.addRowIcon) == null ? void 0 : _a.call(config)) != null ? _b : plusIcon;
1122
+ case "add_col":
1123
+ return (_d = (_c = config == null ? void 0 : config.addColIcon) == null ? void 0 : _c.call(config)) != null ? _d : plusIcon;
1124
+ case "delete_row":
1125
+ return (_f = (_e = config == null ? void 0 : config.deleteRowIcon) == null ? void 0 : _e.call(config)) != null ? _f : removeIcon;
1126
+ case "delete_col":
1127
+ return (_h = (_g = config == null ? void 0 : config.deleteColIcon) == null ? void 0 : _g.call(config)) != null ? _h : removeIcon;
1128
+ case "align_col_left":
1129
+ return (_j = (_i = config == null ? void 0 : config.alignLeftIcon) == null ? void 0 : _i.call(config)) != null ? _j : alignLeftIcon;
1130
+ case "align_col_center":
1131
+ return (_l = (_k = config == null ? void 0 : config.alignCenterIcon) == null ? void 0 : _k.call(config)) != null ? _l : alignCenterIcon;
1132
+ case "align_col_right":
1133
+ return (_n = (_m = config == null ? void 0 : config.alignRightIcon) == null ? void 0 : _m.call(config)) != null ? _n : alignRightIcon;
1134
+ case "col_drag_handle":
1135
+ return (_p = (_o = config == null ? void 0 : config.colDragHandleIcon) == null ? void 0 : _o.call(config)) != null ? _p : dragHandleIcon;
1136
+ case "row_drag_handle":
1137
+ return (_r = (_q = config == null ? void 0 : config.rowDragHandleIcon) == null ? void 0 : _q.call(config)) != null ? _r : dragHandleIcon;
1138
+ }
1139
+ }
1140
+ }));
1141
+ }).use(tableBlock);
1142
+ };
1143
+
1144
+ export { defineFeature };
1145
+ //# sourceMappingURL=index-8QJbxTYk.js.map