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