@jackuait/blok 0.10.0-beta.4 → 0.10.0-beta.6

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 (355) hide show
  1. package/dist/blok.mjs +3 -3
  2. package/dist/chunks/{blok-D_0qAdUd.mjs → blok-BdlR_lX6.mjs} +2073 -2034
  3. package/dist/chunks/chunk-Byubey_H.mjs +20 -0
  4. package/dist/chunks/{constants-DxSXr7kd.mjs → constants-Cp8O0UfP.mjs} +524 -550
  5. package/dist/chunks/default-DIfXCS2E.mjs +4 -0
  6. package/dist/chunks/{i18next-G6FKbZqA.mjs → i18next-KNC_XV5x.mjs} +1 -1
  7. package/dist/chunks/{i18next-loader-CwNimni3.mjs → i18next-loader-oDO9ZKUV.mjs} +2 -2
  8. package/dist/chunks/katex-NjLaA6AJ.mjs +22026 -0
  9. package/dist/chunks/{lightweight-i18n-DWCdzAw0.mjs → lightweight-i18n-DTySD6f6.mjs} +16 -18
  10. package/dist/chunks/mdast-util-math-yS0EygZV.mjs +151 -0
  11. package/dist/{messages-DVQNjdPk.mjs → chunks/messages-5ArOv8cj.mjs} +3 -17
  12. package/dist/chunks/{messages-Czny5pPT2.mjs → messages-876bKyUj2.mjs} +3 -17
  13. package/dist/{messages-JhoVMjfX2.mjs → chunks/messages-9l49jauY.mjs} +3 -17
  14. package/dist/{messages-D3cAcyzj.mjs → chunks/messages-B5aAzExz.mjs} +3 -17
  15. package/dist/chunks/{messages-CmrMwBv3.mjs → messages-B5fKJXd6.mjs} +3 -17
  16. package/dist/chunks/{messages-DBpXyvRe2.mjs → messages-B9N__q552.mjs} +3 -17
  17. package/dist/{messages-CVcQD-9u.mjs → chunks/messages-BAP2OAQk.mjs} +3 -17
  18. package/dist/chunks/{messages-R2W_rGOo2.mjs → messages-BDXl53cy2.mjs} +3 -17
  19. package/dist/{messages-CM5fsPo02.mjs → chunks/messages-BGCQCeWd.mjs} +3 -17
  20. package/dist/{messages-DtrSrdfE2.mjs → chunks/messages-BHhbHLoq.mjs} +3 -17
  21. package/dist/{messages-C6Y4Jv2N.mjs → chunks/messages-BMq9k_lI.mjs} +3 -17
  22. package/dist/{messages-DjJQoYvP2.mjs → chunks/messages-BXSXk3oS2.mjs} +3 -17
  23. package/dist/{messages-pgPcitDH.mjs → chunks/messages-BXn9Vzbx2.mjs} +3 -17
  24. package/dist/chunks/{messages-DR09nkcZ.mjs → messages-BaoJwsEZ.mjs} +3 -17
  25. package/dist/{messages-CdlsTFB1.mjs → chunks/messages-BbfLRqLh2.mjs} +3 -17
  26. package/dist/{messages-BvgTQLf72.mjs → chunks/messages-BhcYsC_M2.mjs} +3 -17
  27. package/dist/chunks/{messages-Cdx4QMR1.mjs → messages-BlO_37l_.mjs} +3 -17
  28. package/dist/{messages--S8_taOd2.mjs → chunks/messages-BlcRm2I3.mjs} +3 -17
  29. package/dist/{messages-DbxbxUiK2.mjs → chunks/messages-Btr121zI2.mjs} +3 -17
  30. package/dist/chunks/{messages-p4byLfvR.mjs → messages-BxBID_0B.mjs} +3 -17
  31. package/dist/chunks/{messages-Cs9XBt4T.mjs → messages-ByAqzAhB.mjs} +3 -17
  32. package/dist/chunks/{messages-JQKFJo7C.mjs → messages-C-jA6Rf7.mjs} +3 -17
  33. package/dist/{messages-BAcH6PtT2.mjs → chunks/messages-C5aCWL7B.mjs} +3 -17
  34. package/dist/{messages-BCG_evLg.mjs → chunks/messages-CF_PfacZ.mjs} +3 -17
  35. package/dist/{messages-B-4fku2H2.mjs → chunks/messages-CKRJDX0K2.mjs} +3 -17
  36. package/dist/chunks/{messages-CrMfiGu5.mjs → messages-CL3mCbi6.mjs} +3 -17
  37. package/dist/chunks/{messages-BnznaKEP2.mjs → messages-CNEJxD8q2.mjs} +3 -17
  38. package/dist/{messages-hTpeKUaW.mjs → chunks/messages-CZ5Sbf8U.mjs} +3 -17
  39. package/dist/chunks/{messages-CljStrYi.mjs → messages-CcyIKgGU.mjs} +3 -17
  40. package/dist/{messages-Dcyrzdxa2.mjs → chunks/messages-CdzF0Hvl.mjs} +3 -17
  41. package/dist/chunks/{messages-IDEUsFhQ2.mjs → messages-CgedvWCf.mjs} +3 -17
  42. package/dist/chunks/{messages-CmXADeab2.mjs → messages-CjVPwkVy.mjs} +3 -17
  43. package/dist/chunks/{messages-wLSVQbsA2.mjs → messages-CnQydQJd2.mjs} +3 -17
  44. package/dist/chunks/{messages-BS1nOvZ-.mjs → messages-CqgEz7C5.mjs} +3 -17
  45. package/dist/{messages-BCuTVHBV.mjs → chunks/messages-CvlMT1e62.mjs} +3 -17
  46. package/dist/{messages-CYX48nfg.mjs → chunks/messages-CyxDkx8a.mjs} +3 -17
  47. package/dist/chunks/{messages-ClRHDxzh.mjs → messages-D7n_wJK7.mjs} +3 -17
  48. package/dist/chunks/{messages-Dplnp19q.mjs → messages-D8-N0FmU.mjs} +3 -17
  49. package/dist/chunks/{messages-DAVsuDWh2.mjs → messages-D8dKkyII2.mjs} +3 -17
  50. package/dist/chunks/{messages-B3s2vra72.mjs → messages-DGD6BiGd.mjs} +3 -17
  51. package/dist/chunks/{messages-DHCVA7XQ.mjs → messages-DJO0ERQT.mjs} +3 -17
  52. package/dist/chunks/{messages-B7MIRzCa2.mjs → messages-DMyRdafk2.mjs} +3 -17
  53. package/dist/chunks/{messages-C-b6tPad2.mjs → messages-DN-194c32.mjs} +3 -17
  54. package/dist/chunks/{messages-BW_7lfqG2.mjs → messages-DQ5ng0_t2.mjs} +3 -17
  55. package/dist/{messages-DUBHHfEt.mjs → chunks/messages-DRv4g-IA.mjs} +3 -17
  56. package/dist/chunks/{messages-xfjdrZmx.mjs → messages-DSO2U-ul.mjs} +3 -17
  57. package/dist/{messages-CgzbJ8_l2.mjs → chunks/messages-DUGEqDEG.mjs} +3 -17
  58. package/dist/{messages-DA-o8X3A.mjs → chunks/messages-DVKifYlq.mjs} +3 -17
  59. package/dist/{messages-tsHpMdDT2.mjs → chunks/messages-DWD0ry9x.mjs} +3 -17
  60. package/dist/{messages-Dddxv8-f2.mjs → chunks/messages-DYizZHT2.mjs} +3 -17
  61. package/dist/chunks/{messages-Csvm4mtA.mjs → messages-DZwCufSb.mjs} +3 -17
  62. package/dist/{messages-BJ7BuFZi.mjs → chunks/messages-DdmWzF5M.mjs} +3 -17
  63. package/dist/{messages-Bo_FUvVH.mjs → chunks/messages-DgEGJECT.mjs} +3 -17
  64. package/dist/chunks/{messages-Bpda_3PM2.mjs → messages-Dgng6KN8.mjs} +3 -17
  65. package/dist/{messages-CBzd_x7H.mjs → chunks/messages-DkTxBa1V.mjs} +3 -17
  66. package/dist/{messages-Bio7KYsr2.mjs → chunks/messages-DnJHflSh.mjs} +3 -17
  67. package/dist/{messages-CjmSrt1D.mjs → chunks/messages-DopbvJlg.mjs} +3 -17
  68. package/dist/{messages-DIRha_gg2.mjs → chunks/messages-Dux1S0-D2.mjs} +3 -17
  69. package/dist/chunks/{messages-1Raf1IK82.mjs → messages-Dw2rmKMi2.mjs} +3 -17
  70. package/dist/chunks/{messages-D5IgUbBD2.mjs → messages-Dz3UhEco2.mjs} +3 -17
  71. package/dist/{messages-C6OJvnJg2.mjs → chunks/messages-FYl9woii2.mjs} +3 -17
  72. package/dist/{messages-BBvDbp62.mjs → chunks/messages-Jps5Tc77.mjs} +3 -17
  73. package/dist/chunks/{messages-Dfpi8pDY.mjs → messages-NJsvFwJj.mjs} +3 -17
  74. package/dist/chunks/{messages-DPykxECP2.mjs → messages-SSDr5fGF2.mjs} +3 -17
  75. package/dist/{messages-BXI3qIos.mjs → chunks/messages-bmwto4UV.mjs} +3 -17
  76. package/dist/{messages-CBdQ3XP9.mjs → chunks/messages-vN4T4r67.mjs} +3 -17
  77. package/dist/{messages-tK67CBqn.mjs → chunks/messages-yszqJukE.mjs} +3 -17
  78. package/dist/chunks/micromark-extension-math-CCEGWpdz.mjs +169 -0
  79. package/dist/chunks/micromark-factory-space-WwmyBO_J.mjs +36 -0
  80. package/dist/chunks/{notifier-Butv4Dvo.mjs → notifier-BOwxj_Ok.mjs} +1 -1
  81. package/dist/chunks/{objectSpread2-BY4mgzrQ.mjs → objectSpread2-CWwMYL_U.mjs} +1 -1
  82. package/dist/chunks/{tools-DVZ3zU40.mjs → tools-DGOsJbHH.mjs} +1816 -2916
  83. package/dist/full.mjs +14 -14
  84. package/dist/locales.mjs +82 -84
  85. package/dist/markdown.mjs +3962 -0
  86. package/dist/{messages-DqyqEw1_.mjs → messages--cUQf9JX.mjs} +3 -17
  87. package/dist/{messages-BtxaN-xx.mjs → messages-12_eyAo-.mjs} +3 -17
  88. package/dist/{chunks/messages-LxumrNue2.mjs → messages-B3Yhiycb2.mjs} +3 -17
  89. package/dist/{chunks/messages-Cqc-6rfh2.mjs → messages-B4lhNMKm2.mjs} +3 -17
  90. package/dist/{chunks/messages-B0ffBqzr.mjs → messages-BOE2mzCj2.mjs} +3 -17
  91. package/dist/{chunks/messages-BaPZuLjN.mjs → messages-BPL7riv-.mjs} +3 -17
  92. package/dist/{messages-DD5pW0zJ.mjs → messages-BYQ769S5.mjs} +3 -17
  93. package/dist/{chunks/messages-C11byid72.mjs → messages-B_sKqaeK.mjs} +3 -17
  94. package/dist/{messages-BmNaAyKS.mjs → messages-Bdk4ocMI.mjs} +3 -17
  95. package/dist/{chunks/messages-6mikOS4D2.mjs → messages-BeI2HORe2.mjs} +3 -17
  96. package/dist/{chunks/messages-u2yxkNTE2.mjs → messages-Bug6Du35.mjs} +3 -17
  97. package/dist/{messages-eTourT12.mjs → messages-C2veeQpU.mjs} +3 -17
  98. package/dist/{messages-BokEflKa.mjs → messages-C5Uufygq.mjs} +3 -17
  99. package/dist/{chunks/messages-BPog17132.mjs → messages-C8f1I5EQ2.mjs} +3 -17
  100. package/dist/{chunks/messages-ID1PHnMv.mjs → messages-CBPiFbEf2.mjs} +3 -17
  101. package/dist/{messages-DZEcrbmH.mjs → messages-CByBLxWk.mjs} +3 -17
  102. package/dist/{chunks/messages-BgVEGd4c.mjs → messages-CD8K1g_t2.mjs} +3 -17
  103. package/dist/{messages-Dkg99bfr2.mjs → messages-CEEzfqMO2.mjs} +3 -17
  104. package/dist/{messages-DV9e1DW7.mjs → messages-CNNcKuGH.mjs} +3 -17
  105. package/dist/{messages-C30Vz-UZ2.mjs → messages-CSl0Wla62.mjs} +3 -17
  106. package/dist/{messages-fLi0P2dP.mjs → messages-CUzBNjnc.mjs} +3 -17
  107. package/dist/{chunks/messages-DJA6fb_P2.mjs → messages-CWEL1WDy2.mjs} +3 -17
  108. package/dist/{messages-BcFQFcJ92.mjs → messages-C_HmWyXc2.mjs} +3 -17
  109. package/dist/{chunks/messages-CpzO7KRA.mjs → messages-Cb3wXGnc.mjs} +3 -17
  110. package/dist/{messages-C5XPUD9T2.mjs → messages-Cd23UgLV2.mjs} +3 -17
  111. package/dist/{chunks/messages-DSjXen8E.mjs → messages-Cg1CF4pw.mjs} +3 -17
  112. package/dist/{messages-i4S6q64n2.mjs → messages-CgEDVri-2.mjs} +3 -17
  113. package/dist/{messages-CHJ5SOZI.mjs → messages-ChTWmxS8.mjs} +3 -17
  114. package/dist/{messages-BVKZK-3t.mjs → messages-Cho2VTAX.mjs} +3 -17
  115. package/dist/{chunks/messages-d0Ky6QjR.mjs → messages-CkySRhtd2.mjs} +3 -17
  116. package/dist/{chunks/messages-C1OqT_nL.mjs → messages-Clsh86WQ.mjs} +3 -17
  117. package/dist/{chunks/messages-BrFl5773.mjs → messages-CsiGzUSP2.mjs} +3 -17
  118. package/dist/{messages-BKjqW08U.mjs → messages-Cv-DKlZd.mjs} +3 -17
  119. package/dist/{messages-BGsDZTQp2.mjs → messages-CvvbLyTy2.mjs} +3 -17
  120. package/dist/{chunks/messages-DA7Zk-Cy.mjs → messages-CwCEcbWG.mjs} +3 -17
  121. package/dist/{chunks/messages-DQ5AyNCU.mjs → messages-D38h5XlF.mjs} +3 -17
  122. package/dist/{chunks/messages-DC7TX-YT.mjs → messages-D7juvhHp.mjs} +3 -17
  123. package/dist/{chunks/messages-BdnSVKOw.mjs → messages-D8WvwU42.mjs} +3 -17
  124. package/dist/{chunks/messages-Df87zXXG.mjs → messages-DACg1XAu.mjs} +3 -17
  125. package/dist/{messages-BBq0M604.mjs → messages-DIKCwGog.mjs} +3 -17
  126. package/dist/{messages-Ccd587Yn.mjs → messages-DJU4YLij.mjs} +3 -17
  127. package/dist/{chunks/messages-Dm4YVlrm.mjs → messages-DQN1y6E9.mjs} +3 -17
  128. package/dist/{messages-CqkRG9mH.mjs → messages-DRU_IgoW.mjs} +3 -17
  129. package/dist/{chunks/messages-DT7fRpCy.mjs → messages-DbZsJAff.mjs} +3 -17
  130. package/dist/{messages-upqrRZQH2.mjs → messages-Dg2CDXZi2.mjs} +3 -17
  131. package/dist/{messages-DJKLtW7u.mjs → messages-Dj79y02X.mjs} +3 -17
  132. package/dist/{chunks/messages-Ct7AMBS82.mjs → messages-DjWfVYHS2.mjs} +3 -17
  133. package/dist/{chunks/messages-B2pW6jO_.mjs → messages-DkvQ-6HC2.mjs} +3 -17
  134. package/dist/{chunks/messages-ZJ0b1C3a.mjs → messages-DnhEzmXJ2.mjs} +3 -17
  135. package/dist/{chunks/messages-BgsPQXfP.mjs → messages-DqJTZbwt.mjs} +3 -17
  136. package/dist/{chunks/messages-DUDgFEEe2.mjs → messages-Dq_v7slw2.mjs} +3 -17
  137. package/dist/{chunks/messages-CyNsByCY.mjs → messages-En8LDjUB.mjs} +3 -17
  138. package/dist/{chunks/messages-FHrCEJmY2.mjs → messages-JK9Okzsy2.mjs} +3 -17
  139. package/dist/{messages-DnatBKPm.mjs → messages-KSxF8eib.mjs} +3 -17
  140. package/dist/{chunks/messages-DD7BI6BK.mjs → messages-KbYSpNrE.mjs} +3 -17
  141. package/dist/{messages-BvgXeMSL2.mjs → messages-KqWQKmIu2.mjs} +3 -17
  142. package/dist/{messages-BSe3QDnQ.mjs → messages-PvMdmlxI.mjs} +3 -17
  143. package/dist/{chunks/messages-DJkIeapn.mjs → messages-So3SHdIc2.mjs} +3 -17
  144. package/dist/{messages-BywbKcPC.mjs → messages-X80Nh0ib.mjs} +3 -17
  145. package/dist/{messages-DOTJ2NvJ.mjs → messages-hrSlVSHp.mjs} +3 -17
  146. package/dist/{messages-DJT4Bt_02.mjs → messages-mipkPgwQ2.mjs} +3 -17
  147. package/dist/{messages-xEI8gEDK.mjs → messages-nOe1gJYu.mjs} +3 -17
  148. package/dist/{messages-Bk984gRE2.mjs → messages-rbox5gSb2.mjs} +3 -17
  149. package/dist/{chunks/messages-CgRvtOEY.mjs → messages-uCsQjz7M.mjs} +3 -17
  150. package/dist/{chunks/messages-BbdNugdi.mjs → messages-vcoib5Ga.mjs} +3 -17
  151. package/dist/{chunks/messages-CvfKofOP.mjs → messages-vptt-pVF.mjs} +3 -17
  152. package/dist/{chunks/messages-BkCjgGxc.mjs → messages-x353UCBI.mjs} +3 -17
  153. package/dist/react.mjs +3 -3
  154. package/dist/tools.mjs +3 -3
  155. package/dist/vendor.LICENSE.txt +1622 -182
  156. package/package.json +15 -2
  157. package/src/components/blocks.ts +26 -1
  158. package/src/components/i18n/locales/am/messages.json +3 -17
  159. package/src/components/i18n/locales/ar/messages.json +3 -17
  160. package/src/components/i18n/locales/az/messages.json +3 -17
  161. package/src/components/i18n/locales/bg/messages.json +3 -17
  162. package/src/components/i18n/locales/bn/messages.json +3 -17
  163. package/src/components/i18n/locales/bs/messages.json +3 -17
  164. package/src/components/i18n/locales/cs/messages.json +3 -17
  165. package/src/components/i18n/locales/da/messages.json +3 -17
  166. package/src/components/i18n/locales/de/messages.json +3 -17
  167. package/src/components/i18n/locales/dv/messages.json +3 -17
  168. package/src/components/i18n/locales/el/messages.json +3 -17
  169. package/src/components/i18n/locales/en/messages.json +15 -17
  170. package/src/components/i18n/locales/es/messages.json +3 -17
  171. package/src/components/i18n/locales/et/messages.json +3 -17
  172. package/src/components/i18n/locales/fa/messages.json +3 -17
  173. package/src/components/i18n/locales/fi/messages.json +3 -17
  174. package/src/components/i18n/locales/fil/messages.json +3 -17
  175. package/src/components/i18n/locales/fr/messages.json +3 -17
  176. package/src/components/i18n/locales/gu/messages.json +3 -17
  177. package/src/components/i18n/locales/he/messages.json +3 -17
  178. package/src/components/i18n/locales/hi/messages.json +3 -17
  179. package/src/components/i18n/locales/hr/messages.json +3 -17
  180. package/src/components/i18n/locales/hu/messages.json +3 -17
  181. package/src/components/i18n/locales/hy/messages.json +3 -17
  182. package/src/components/i18n/locales/id/messages.json +3 -17
  183. package/src/components/i18n/locales/it/messages.json +3 -17
  184. package/src/components/i18n/locales/ja/messages.json +3 -17
  185. package/src/components/i18n/locales/ka/messages.json +3 -17
  186. package/src/components/i18n/locales/km/messages.json +3 -17
  187. package/src/components/i18n/locales/kn/messages.json +3 -17
  188. package/src/components/i18n/locales/ko/messages.json +3 -17
  189. package/src/components/i18n/locales/ku/messages.json +3 -17
  190. package/src/components/i18n/locales/lo/messages.json +3 -17
  191. package/src/components/i18n/locales/lt/messages.json +3 -17
  192. package/src/components/i18n/locales/lv/messages.json +3 -17
  193. package/src/components/i18n/locales/mk/messages.json +3 -17
  194. package/src/components/i18n/locales/ml/messages.json +3 -17
  195. package/src/components/i18n/locales/mn/messages.json +3 -17
  196. package/src/components/i18n/locales/mr/messages.json +3 -17
  197. package/src/components/i18n/locales/ms/messages.json +3 -17
  198. package/src/components/i18n/locales/my/messages.json +3 -17
  199. package/src/components/i18n/locales/ne/messages.json +3 -17
  200. package/src/components/i18n/locales/nl/messages.json +3 -17
  201. package/src/components/i18n/locales/no/messages.json +3 -17
  202. package/src/components/i18n/locales/pa/messages.json +3 -17
  203. package/src/components/i18n/locales/pl/messages.json +3 -17
  204. package/src/components/i18n/locales/ps/messages.json +3 -17
  205. package/src/components/i18n/locales/pt/messages.json +3 -17
  206. package/src/components/i18n/locales/ro/messages.json +3 -17
  207. package/src/components/i18n/locales/ru/messages.json +3 -17
  208. package/src/components/i18n/locales/sd/messages.json +3 -17
  209. package/src/components/i18n/locales/si/messages.json +3 -17
  210. package/src/components/i18n/locales/sk/messages.json +3 -17
  211. package/src/components/i18n/locales/sl/messages.json +3 -17
  212. package/src/components/i18n/locales/sq/messages.json +3 -17
  213. package/src/components/i18n/locales/sr/messages.json +3 -17
  214. package/src/components/i18n/locales/sv/messages.json +3 -17
  215. package/src/components/i18n/locales/sw/messages.json +3 -17
  216. package/src/components/i18n/locales/ta/messages.json +3 -17
  217. package/src/components/i18n/locales/te/messages.json +3 -17
  218. package/src/components/i18n/locales/th/messages.json +3 -17
  219. package/src/components/i18n/locales/tr/messages.json +3 -17
  220. package/src/components/i18n/locales/ug/messages.json +3 -17
  221. package/src/components/i18n/locales/uk/messages.json +3 -17
  222. package/src/components/i18n/locales/ur/messages.json +3 -17
  223. package/src/components/i18n/locales/vi/messages.json +3 -17
  224. package/src/components/i18n/locales/yi/messages.json +3 -17
  225. package/src/components/i18n/locales/zh/messages.json +3 -17
  226. package/src/components/icons/index.ts +30 -56
  227. package/src/components/inline-tools/inline-tool-code.ts +399 -0
  228. package/src/components/modules/api/blocks.ts +17 -0
  229. package/src/components/modules/api/tools.ts +0 -19
  230. package/src/components/modules/blockEvents/composers/blockSelectionKeys.ts +20 -3
  231. package/src/components/modules/blockEvents/composers/keyboardNavigation.ts +5 -5
  232. package/src/components/modules/blockManager/blockManager.ts +0 -11
  233. package/src/components/modules/blockManager/event-binder.ts +1 -12
  234. package/src/components/modules/paste/handlers/html-handler.ts +13 -10
  235. package/src/components/modules/paste/handlers/index.ts +1 -0
  236. package/src/components/modules/paste/index.ts +6 -0
  237. package/src/components/modules/themeManager.ts +1 -3
  238. package/src/components/modules/toolbar/blockSettings.ts +1 -0
  239. package/src/components/modules/toolbar/inline/index.ts +3 -0
  240. package/src/components/modules/uiControllers/controllers/keyboard.ts +0 -29
  241. package/src/components/modules/uiControllers/controllers/selection.ts +2 -14
  242. package/src/components/ui/toolbox.ts +1 -0
  243. package/src/components/utils/popover/popover-position.ts +2 -4
  244. package/src/markdown/index.ts +63 -0
  245. package/src/markdown/markdown-handler.ts +110 -0
  246. package/src/markdown/mdast-to-blocks.ts +418 -0
  247. package/src/markdown/phrasing-to-html.ts +60 -0
  248. package/src/markdown/types.ts +42 -0
  249. package/src/styles/main.css +0 -1139
  250. package/src/tools/callout/index.ts +24 -0
  251. package/src/tools/code/code-keyboard.ts +135 -0
  252. package/src/tools/code/constants.ts +73 -0
  253. package/src/tools/code/dom-builder.ts +146 -0
  254. package/src/tools/code/index.ts +322 -0
  255. package/src/tools/code/katex-loader.ts +50 -0
  256. package/src/tools/code/language-picker.ts +241 -0
  257. package/src/tools/divider/index.ts +9 -1
  258. package/src/tools/index.ts +4 -2
  259. package/src/tools/list/block-operations.ts +3 -1
  260. package/src/tools/list/depth-validator.ts +4 -7
  261. package/src/tools/list/dom-builder.ts +5 -3
  262. package/src/tools/list/index.ts +21 -3
  263. package/src/tools/list/list-helpers.ts +9 -2
  264. package/src/tools/list/list-keyboard.ts +56 -14
  265. package/src/tools/list/list-lifecycle.ts +3 -1
  266. package/src/tools/list/marker-calculator.ts +37 -0
  267. package/src/tools/list/ordered-marker-manager.ts +4 -2
  268. package/src/tools/table/index.ts +2 -2
  269. package/src/tools/table/table-cell-clipboard.ts +1 -1
  270. package/types/api/tools.d.ts +0 -18
  271. package/types/markdown.d.ts +2 -0
  272. package/types/tools/code.d.ts +11 -0
  273. package/src/tools/database/database-backend-sync.ts +0 -101
  274. package/src/tools/database/database-board-view.ts +0 -301
  275. package/src/tools/database/database-card-drag.ts +0 -306
  276. package/src/tools/database/database-card-drawer.ts +0 -546
  277. package/src/tools/database/database-column-controls.ts +0 -46
  278. package/src/tools/database/database-column-drag.ts +0 -262
  279. package/src/tools/database/database-keyboard.ts +0 -35
  280. package/src/tools/database/database-list-row-drag.ts +0 -245
  281. package/src/tools/database/database-list-view.ts +0 -333
  282. package/src/tools/database/database-model.ts +0 -246
  283. package/src/tools/database/database-property-type-popover.ts +0 -108
  284. package/src/tools/database/database-tab-bar.ts +0 -532
  285. package/src/tools/database/database-view-popover.ts +0 -109
  286. package/src/tools/database/database-view-renderer.ts +0 -25
  287. package/src/tools/database/index.ts +0 -948
  288. package/src/tools/database/types.ts +0 -144
  289. /package/dist/chunks/{am-CHDDMHkd.mjs → am-CS-JjQ0N.mjs} +0 -0
  290. /package/dist/chunks/{ar-DoqfNqut.mjs → ar-Dt4XzR5U.mjs} +0 -0
  291. /package/dist/chunks/{az-C34P9iEa.mjs → az-CaDTXby8.mjs} +0 -0
  292. /package/dist/chunks/{bg-jroXLY8Y.mjs → bg-D1pLog-R.mjs} +0 -0
  293. /package/dist/chunks/{bn-BRI-WqxY.mjs → bn-Db_ae60m.mjs} +0 -0
  294. /package/dist/chunks/{bs-CCGUpNHu.mjs → bs-DJTg1R9e.mjs} +0 -0
  295. /package/dist/chunks/{cs-D5qZOGuc.mjs → cs-_Gc21gSL.mjs} +0 -0
  296. /package/dist/chunks/{da-DrJ7W37K.mjs → da-xDB8uhCd.mjs} +0 -0
  297. /package/dist/chunks/{de-BW6-kp2c.mjs → de-B6gVjh1Z.mjs} +0 -0
  298. /package/dist/chunks/{el-C-Vc_Otu.mjs → el-ClbRSnOs.mjs} +0 -0
  299. /package/dist/chunks/{es-B6fI5K9i.mjs → es-CuY9rnLK.mjs} +0 -0
  300. /package/dist/chunks/{et-BhVlZ-Yz.mjs → et-BLu5lDVc.mjs} +0 -0
  301. /package/dist/chunks/{fa-D55Ijdqa.mjs → fa-P3gnrZH8.mjs} +0 -0
  302. /package/dist/chunks/{fi-jNLjhKUQ.mjs → fi-B8PVHLjq.mjs} +0 -0
  303. /package/dist/chunks/{fil-DYd0T5aX.mjs → fil-B9JII5iF.mjs} +0 -0
  304. /package/dist/chunks/{fr-yxy5xWw_.mjs → fr-BWLDZdcc.mjs} +0 -0
  305. /package/dist/chunks/{gu-CcY_LJe7.mjs → gu-BH3R_s4c.mjs} +0 -0
  306. /package/dist/chunks/{he-DL9s7wNw.mjs → he-CCmeCVR_.mjs} +0 -0
  307. /package/dist/chunks/{hi-C8eGXgw5.mjs → hi-BBav00DN.mjs} +0 -0
  308. /package/dist/chunks/{hr-DLpybOhU.mjs → hr-B5ZX0r9G.mjs} +0 -0
  309. /package/dist/chunks/{hu-BkT0gT00.mjs → hu-1jgDa3YU.mjs} +0 -0
  310. /package/dist/chunks/{hy-CVFDCp2S.mjs → hy-LX4Kp2PE.mjs} +0 -0
  311. /package/dist/chunks/{id-0P4W9Az0.mjs → id-CcG40D1H.mjs} +0 -0
  312. /package/dist/chunks/{it-mLY6_uoW.mjs → it-Cb8_K72W.mjs} +0 -0
  313. /package/dist/chunks/{ja-7RkeRNWG.mjs → ja-ipCH91mv.mjs} +0 -0
  314. /package/dist/chunks/{ka-C7Lx-Qsh.mjs → ka-BRvREIgq.mjs} +0 -0
  315. /package/dist/chunks/{km-Q8udaraH.mjs → km-BJwVw7Fg.mjs} +0 -0
  316. /package/dist/chunks/{kn-BiETM-iq.mjs → kn-BPgUazCC.mjs} +0 -0
  317. /package/dist/chunks/{ko-tiB80pF1.mjs → ko-CQLzxe7k.mjs} +0 -0
  318. /package/dist/chunks/{ku-CY-OABkR.mjs → ku-BHhHu8Iz.mjs} +0 -0
  319. /package/dist/chunks/{lo-CTBhEnyk.mjs → lo-DsTgYblY.mjs} +0 -0
  320. /package/dist/chunks/{lt-BHKHEtqK.mjs → lt-CDzHJm71.mjs} +0 -0
  321. /package/dist/chunks/{lv-DWxgtfUg.mjs → lv-MLLIAnIX.mjs} +0 -0
  322. /package/dist/chunks/{mk-BjookGdx.mjs → mk-DQdmUquZ.mjs} +0 -0
  323. /package/dist/chunks/{ml-L-NnZcp9.mjs → ml-DqehZnra.mjs} +0 -0
  324. /package/dist/chunks/{mn-OMWi7Hl_.mjs → mn-4cFkKFjW.mjs} +0 -0
  325. /package/dist/chunks/{mr-B6JPzITo.mjs → mr-DWiztOP4.mjs} +0 -0
  326. /package/dist/chunks/{ms-CG3S-sPB.mjs → ms-BSz-iSnc.mjs} +0 -0
  327. /package/dist/chunks/{my-BLAmGfhT.mjs → my-DbtbM1MW.mjs} +0 -0
  328. /package/dist/chunks/{native-BPcABu9z.mjs → native-CzYG0YgY.mjs} +0 -0
  329. /package/dist/chunks/{ne-D1JHLfYw.mjs → ne-CqALWw_f.mjs} +0 -0
  330. /package/dist/chunks/{nl-Ca7Q8FnY.mjs → nl-D_ra6RvH.mjs} +0 -0
  331. /package/dist/chunks/{no-Coxcohcz.mjs → no-Cg_kz_jl.mjs} +0 -0
  332. /package/dist/chunks/{pa-CCaXqpaI.mjs → pa-NLAsNqwY.mjs} +0 -0
  333. /package/dist/chunks/{pl-Cl_fAZ84.mjs → pl-NHKp4YDg.mjs} +0 -0
  334. /package/dist/chunks/{ps-WD5qGAWy.mjs → ps-D1zEqNeg.mjs} +0 -0
  335. /package/dist/chunks/{pt-C4zvLfvq.mjs → pt-DBtqbUEB.mjs} +0 -0
  336. /package/dist/chunks/{ro-DbefHcmM.mjs → ro-lqr63ai5.mjs} +0 -0
  337. /package/dist/chunks/{ru-uU1J14jd.mjs → ru-BycNnDyN.mjs} +0 -0
  338. /package/dist/chunks/{sd-DKu368Ip.mjs → sd-DpHpIN9Z.mjs} +0 -0
  339. /package/dist/chunks/{si-BsJCiPkZ.mjs → si-BwiwaC7N.mjs} +0 -0
  340. /package/dist/chunks/{sk-CD-a3SN6.mjs → sk-CqRHT2Gp.mjs} +0 -0
  341. /package/dist/chunks/{sl-CXhrPJe_.mjs → sl-DA348uQ_.mjs} +0 -0
  342. /package/dist/chunks/{sq-CTctCoFQ.mjs → sq-D7JNgve1.mjs} +0 -0
  343. /package/dist/chunks/{sr-BZkhBwXj.mjs → sr-D8RK6Kwp.mjs} +0 -0
  344. /package/dist/chunks/{sv-NmRZb_xi.mjs → sv-dwgT67ZG.mjs} +0 -0
  345. /package/dist/chunks/{sw-Be5ik3H6.mjs → sw-ZRRJnkem.mjs} +0 -0
  346. /package/dist/chunks/{ta-DsXh6neL.mjs → ta-5x4L5Krl.mjs} +0 -0
  347. /package/dist/chunks/{te-CwpCbM8M.mjs → te-BZpEimwA.mjs} +0 -0
  348. /package/dist/chunks/{th-CcZ15OLk.mjs → th-Bhr-33kv.mjs} +0 -0
  349. /package/dist/chunks/{tr-q3bTgvhW.mjs → tr-6tSNKGNB.mjs} +0 -0
  350. /package/dist/chunks/{tw-DmW6-pCY.mjs → tw-CqxBf-1Y.mjs} +0 -0
  351. /package/dist/chunks/{ug-919EhLsL.mjs → ug-_e-jvr2b.mjs} +0 -0
  352. /package/dist/chunks/{uk-aNMEzd0Y.mjs → uk-DooSc2Ja.mjs} +0 -0
  353. /package/dist/chunks/{ur-BwQI77sh.mjs → ur-rb-krkIO.mjs} +0 -0
  354. /package/dist/chunks/{vi-Dxq806-F.mjs → vi-CQkLn2AQ.mjs} +0 -0
  355. /package/dist/chunks/{zh-BcHuy1Ti.mjs → zh-CXQ40Q2_.mjs} +0 -0
@@ -1,948 +0,0 @@
1
- import type { API, BlockAPI, BlockTool, BlockToolConstructorOptions, OutputData, ToolboxConfig } from '../../../types';
2
- import type { DatabaseData, DatabaseConfig, DatabaseRow, ViewType, SelectOption, DatabaseViewConfig, PropertyValue } from './types';
3
- import { DatabaseModel } from './database-model';
4
- import { DatabaseBoardView } from './database-board-view';
5
- import { DatabaseListView } from './database-list-view';
6
- import type { DatabaseViewRenderer } from './database-view-renderer';
7
- import { DatabaseBackendSync } from './database-backend-sync';
8
- import { DatabaseCardDrag } from './database-card-drag';
9
- import type { CardDragResult } from './database-card-drag';
10
- import { DatabaseColumnDrag } from './database-column-drag';
11
- import type { GroupDragResult } from './database-column-drag';
12
- import { DatabaseColumnControls } from './database-column-controls';
13
- import { DatabaseListRowDrag } from './database-list-row-drag';
14
- import type { ListRowDragResult } from './database-list-row-drag';
15
- import { DatabaseCardDrawer } from './database-card-drawer';
16
- import { DatabaseKeyboard } from './database-keyboard';
17
- import { DatabaseTabBar } from './database-tab-bar';
18
- import { IconDatabase, IconBoard } from '../../components/icons';
19
- import { nanoid } from 'nanoid';
20
-
21
- /**
22
- * DatabaseTool — a multi-view Kanban board block tool for Blok.
23
- *
24
- * Orchestrates a single DatabaseModel (schema + rows + view configs), DatabaseView (DOM),
25
- * DatabaseBackendSync (adapter), and a DatabaseTabBar for view switching.
26
- */
27
- export class DatabaseTool implements BlockTool {
28
- private readonly api: API;
29
- private readonly block: BlockAPI;
30
- private readonly readOnly: boolean;
31
- private readonly config: DatabaseConfig;
32
-
33
- private activeViewId: string;
34
- private model: DatabaseModel;
35
- private view!: DatabaseViewRenderer;
36
- private sync!: DatabaseBackendSync;
37
-
38
- private element: HTMLDivElement | null = null;
39
- private boardContainer: HTMLDivElement | null = null;
40
- private tabBar: DatabaseTabBar | null = null;
41
-
42
- private cardDrag: DatabaseCardDrag | null = null;
43
- private columnDrag: DatabaseColumnDrag | null = null;
44
- private columnControls: DatabaseColumnControls | null = null;
45
- private listRowDrag: DatabaseListRowDrag | null = null;
46
- private cardDrawer: DatabaseCardDrawer | null = null;
47
- private keyboard: DatabaseKeyboard | null = null;
48
-
49
- constructor({ data, config, api, block, readOnly }: BlockToolConstructorOptions<DatabaseData, DatabaseConfig>) {
50
- this.api = api;
51
- this.block = block;
52
- this.readOnly = readOnly;
53
- this.config = config ?? {};
54
-
55
- this.model = new DatabaseModel(data as DatabaseData | undefined);
56
- const views = this.model.getViews();
57
- this.activeViewId = (data as DatabaseData | undefined)?.activeViewId ?? (views.length > 0 ? views[0].id : '');
58
-
59
- this.activateView(this.activeViewId);
60
- }
61
-
62
- static get toolbox(): ToolboxConfig {
63
- return [
64
- {
65
- icon: IconDatabase,
66
- title: 'Database',
67
- titleKey: 'database',
68
- name: 'database',
69
- searchTerms: ['database', 'kanban', 'board', 'cards', 'columns'],
70
- },
71
- {
72
- icon: IconBoard,
73
- title: 'Board',
74
- titleKey: 'board',
75
- name: 'board',
76
- searchTerms: ['board', 'kanban', 'cards', 'columns', 'database'],
77
- },
78
- ];
79
- }
80
-
81
- static get isReadOnlySupported(): boolean {
82
- return true;
83
- }
84
-
85
- render(): HTMLDivElement {
86
- const wrapper = document.createElement('div');
87
- wrapper.setAttribute('data-blok-tool', 'database');
88
- wrapper.setAttribute('data-blok-database-wrapper', '');
89
- wrapper.style.display = 'flex';
90
- wrapper.style.flexDirection = 'column';
91
- this.element = wrapper;
92
-
93
- if (!this.readOnly) {
94
- this.tabBar = this.createTabBar();
95
- wrapper.appendChild(this.tabBar.render());
96
- }
97
-
98
- const boardContainer = document.createElement('div');
99
- boardContainer.setAttribute('data-blok-database-board-container', '');
100
- boardContainer.style.overflow = 'hidden';
101
- boardContainer.style.position = 'relative';
102
- this.boardContainer = boardContainer;
103
- wrapper.appendChild(boardContainer);
104
-
105
- const boardEl = this.renderActiveView();
106
- boardContainer.appendChild(boardEl);
107
-
108
- if (!this.readOnly) {
109
- this.attachViewListeners(boardEl);
110
- this.initSubsystems(boardEl);
111
- }
112
-
113
- return wrapper;
114
- }
115
-
116
- rendered(): void {
117
- this.block.stretched = true;
118
- if (this.config.adapter !== undefined) {
119
- void this.loadFromBackend();
120
- }
121
- }
122
-
123
- private async loadFromBackend(): Promise<void> {
124
- const data = await this.sync.syncLoadDatabase();
125
-
126
- if (data === undefined) {
127
- return;
128
- }
129
-
130
- this.model.hydrate(data);
131
- const views = this.model.getViews();
132
-
133
- if (views.length > 0 && !views.some((v) => v.id === this.activeViewId)) {
134
- this.activeViewId = views[0].id;
135
- }
136
-
137
- this.rerenderView();
138
- }
139
-
140
- save(_blockContent: HTMLElement): DatabaseData {
141
- return {
142
- ...this.model.snapshot(),
143
- activeViewId: this.activeViewId,
144
- };
145
- }
146
-
147
- validate(savedData: DatabaseData): boolean {
148
- const hasTitleProp = savedData.schema?.some((p) => p.type === 'title') ?? false;
149
- const hasViews = savedData.views !== undefined && savedData.views.length > 0;
150
- const boardViewsValid = savedData.views?.filter((v) => v.type === 'board')
151
- .every((v) => v.groupBy !== undefined) ?? true;
152
- return hasTitleProp && hasViews && boardViewsValid;
153
- }
154
-
155
- destroy(): void {
156
- this.cardDrag?.destroy();
157
- this.columnDrag?.destroy();
158
- this.columnControls?.destroy();
159
- this.listRowDrag?.destroy();
160
- this.listRowDrag = null;
161
- this.cardDrawer?.destroy();
162
- this.keyboard?.destroy();
163
- this.tabBar?.destroy();
164
- this.sync.flushPendingUpdates();
165
- this.sync.destroy();
166
- this.element = null;
167
- this.boardContainer = null;
168
- this.tabBar = null;
169
- }
170
-
171
- // ---------------------------------------------------------------------------
172
- // View management
173
- // ---------------------------------------------------------------------------
174
-
175
- private activateView(viewId: string): void {
176
- const viewConfig = this.model.getView(viewId);
177
-
178
- if (viewConfig === undefined) {
179
- return;
180
- }
181
-
182
- this.activeViewId = viewId;
183
- this.sync = new DatabaseBackendSync(
184
- this.config.adapter,
185
- (error) => {
186
- this.api.notifier.show({
187
- message: String(error),
188
- style: 'error',
189
- });
190
- },
191
- );
192
- }
193
-
194
- private switchView(viewId: string): void {
195
- if (viewId === this.activeViewId || this.boardContainer === null) {
196
- return;
197
- }
198
-
199
- // Destroy per-view subsystems (not cardDrawer)
200
- this.cardDrag?.destroy();
201
- this.columnDrag?.destroy();
202
- this.columnControls?.destroy();
203
- this.listRowDrag?.destroy();
204
- this.keyboard?.destroy();
205
- this.cardDrag = null;
206
- this.columnDrag = null;
207
- this.columnControls = null;
208
- this.listRowDrag = null;
209
- this.keyboard = null;
210
-
211
- this.sync.flushPendingUpdates();
212
- this.sync.destroy();
213
-
214
- this.activateView(viewId);
215
-
216
- this.boardContainer.innerHTML = '';
217
- const newBoardWrapper = this.renderActiveView();
218
- this.boardContainer.appendChild(newBoardWrapper);
219
-
220
- if (!this.readOnly) {
221
- this.attachViewListeners(newBoardWrapper);
222
- this.initSubsystems(newBoardWrapper);
223
- }
224
-
225
- this.rebuildTabBar();
226
- }
227
-
228
- addView(type: ViewType): void {
229
- const statusProp = this.model.getSchema().find((p) => p.type === 'select');
230
- const defaultName = type === 'list' ? 'List' : 'Board';
231
- const newView = this.model.addView(defaultName, type, {
232
- groupBy: type === 'board' ? statusProp?.id : undefined,
233
- });
234
- void this.sync.syncCreateView({ id: newView.id, name: newView.name, type: newView.type, position: newView.position, groupBy: newView.groupBy });
235
- this.switchView(newView.id);
236
- }
237
-
238
- renameView(viewId: string, name: string): void {
239
- this.model.updateView(viewId, { name });
240
- void this.sync.syncUpdateView({ viewId, changes: { name } });
241
- }
242
-
243
- duplicateView(viewId: string): void {
244
- const sourceView = this.model.getView(viewId);
245
-
246
- if (sourceView === undefined) {
247
- return;
248
- }
249
-
250
- const newView = this.model.addView(sourceView.name, sourceView.type, {
251
- groupBy: sourceView.groupBy,
252
- sorts: [...sourceView.sorts],
253
- filters: [...sourceView.filters],
254
- visibleProperties: [...sourceView.visibleProperties],
255
- });
256
- void this.sync.syncCreateView({ id: newView.id, name: newView.name, type: newView.type, position: newView.position, groupBy: newView.groupBy });
257
- this.switchView(newView.id);
258
- }
259
-
260
- deleteView(viewId: string): void {
261
- const views = this.model.getViews();
262
-
263
- if (views.length <= 1) {
264
- return;
265
- }
266
-
267
- const index = views.findIndex((v) => v.id === viewId);
268
-
269
- if (index === -1) {
270
- return;
271
- }
272
-
273
- const wasActive = viewId === this.activeViewId;
274
-
275
- this.model.deleteView(viewId);
276
- void this.sync.syncDeleteView({ viewId });
277
-
278
- if (wasActive) {
279
- const remaining = this.model.getViews();
280
- const neighborIndex = Math.min(index, remaining.length - 1);
281
- this.switchView(remaining[neighborIndex].id);
282
- } else {
283
- this.rebuildTabBar();
284
- }
285
- }
286
-
287
- reorderView(viewId: string, newPosition: string): void {
288
- this.model.updateView(viewId, { position: newPosition });
289
- void this.sync.syncUpdateView({ viewId, changes: { position: newPosition } });
290
- this.rebuildTabBar();
291
- }
292
-
293
- private rebuildTabBar(): void {
294
- if (this.element === null || this.tabBar === null) {
295
- return;
296
- }
297
-
298
- const oldBarEl = this.element.querySelector('[data-blok-database-tab-bar]');
299
-
300
- this.tabBar.destroy();
301
- this.tabBar = this.createTabBar();
302
- const newBarEl = this.tabBar.render();
303
-
304
- if (oldBarEl !== null) {
305
- oldBarEl.replaceWith(newBarEl);
306
- } else {
307
- // Tab bar should be first child (before boardContainer)
308
- this.element.insertBefore(newBarEl, this.boardContainer);
309
- }
310
- }
311
-
312
- private createTabBar(): DatabaseTabBar {
313
- return new DatabaseTabBar({
314
- views: this.model.getViews(),
315
- activeViewId: this.activeViewId,
316
- onTabClick: (viewId) => this.switchView(viewId),
317
- onAddView: (type) => this.addView(type),
318
- onRename: (viewId, name) => this.renameView(viewId, name),
319
- onDuplicate: (viewId) => this.duplicateView(viewId),
320
- onDelete: (viewId) => this.deleteView(viewId),
321
- onReorder: (viewId, newPosition) => this.reorderView(viewId, newPosition),
322
- });
323
- }
324
-
325
- // ---------------------------------------------------------------------------
326
- // Board rendering helpers
327
- // ---------------------------------------------------------------------------
328
-
329
- private renderActiveView(): HTMLDivElement {
330
- const viewConfig = this.model.getView(this.activeViewId);
331
- const titleProp = this.model.getSchema().find((p) => p.type === 'title');
332
- const titlePropId = titleProp?.id ?? '';
333
- const groupByPropId = viewConfig?.groupBy;
334
-
335
- if (viewConfig?.type === 'list') {
336
- return this.renderListView(titlePropId, groupByPropId, viewConfig);
337
- }
338
-
339
- return this.renderBoardView(titlePropId, groupByPropId);
340
- }
341
-
342
- private renderBoardView(titlePropId: string, groupByPropId: string | undefined): HTMLDivElement {
343
- const options = groupByPropId !== undefined ? this.model.getSelectOptions(groupByPropId) : [];
344
- const groups: Map<string, DatabaseRow[]> = groupByPropId !== undefined ? this.model.getRowsGroupedBy(groupByPropId) : new Map<string, DatabaseRow[]>();
345
-
346
- this.view = new DatabaseBoardView({
347
- readOnly: this.readOnly,
348
- i18n: this.api.i18n,
349
- options,
350
- getRows: (optionId) => groups.get(optionId) ?? [],
351
- titlePropertyId: titlePropId,
352
- });
353
-
354
- return this.view.createView();
355
- }
356
-
357
- private renderListView(titlePropId: string, groupByPropId: string | undefined, viewConfig: DatabaseViewConfig): HTMLDivElement {
358
- const schema = this.model.getSchema();
359
-
360
- if (groupByPropId !== undefined) {
361
- const options = this.model.getSelectOptions(groupByPropId);
362
- const groups = this.model.getRowsGroupedBy(groupByPropId);
363
-
364
- this.view = new DatabaseListView({
365
- readOnly: this.readOnly,
366
- i18n: this.api.i18n,
367
- rows: [],
368
- titlePropertyId: titlePropId,
369
- schema,
370
- visiblePropertyIds: viewConfig.visibleProperties,
371
- options,
372
- getRows: (optionId) => groups.get(optionId) ?? [],
373
- });
374
- } else {
375
- this.view = new DatabaseListView({
376
- readOnly: this.readOnly,
377
- i18n: this.api.i18n,
378
- rows: this.model.getOrderedRows(),
379
- titlePropertyId: titlePropId,
380
- schema,
381
- visiblePropertyIds: viewConfig.visibleProperties,
382
- });
383
- }
384
-
385
- return this.view.createView();
386
- }
387
-
388
- // ---------------------------------------------------------------------------
389
- // Event listeners & subsystems
390
- // ---------------------------------------------------------------------------
391
-
392
- /**
393
- * Attaches a single click listener on the board element for event delegation.
394
- */
395
- private attachViewListeners(boardEl: HTMLDivElement): void {
396
- boardEl.addEventListener('click', (event) => {
397
- const target = event.target as HTMLElement;
398
-
399
- const addCardBtn = target.closest('[data-blok-database-add-card]');
400
-
401
- if (addCardBtn !== null) {
402
- const optionId = addCardBtn.getAttribute('data-option-id');
403
-
404
- if (optionId !== null) {
405
- this.handleAddRow(optionId, boardEl);
406
- }
407
-
408
- return;
409
- }
410
-
411
- const addColumnBtn = target.closest('[data-blok-database-add-column]');
412
-
413
- if (addColumnBtn !== null) {
414
- this.handleAddColumn(boardEl);
415
-
416
- return;
417
- }
418
-
419
- const deleteCardBtn = target.closest('[data-blok-database-delete-card]');
420
-
421
- if (deleteCardBtn !== null) {
422
- const rowId = deleteCardBtn.getAttribute('data-row-id');
423
-
424
- if (rowId !== null) {
425
- event.stopPropagation();
426
- this.model.deleteRow(rowId);
427
- this.view.removeRow(boardEl, rowId);
428
- void this.sync.syncDeleteRow({ rowId });
429
- }
430
-
431
- return;
432
- }
433
-
434
- // List: add row
435
- const addRowBtn = target.closest('[data-blok-database-add-row]');
436
-
437
- if (addRowBtn !== null) {
438
- const optionId = addRowBtn.getAttribute('data-option-id');
439
- this.handleAddListRow(optionId, boardEl);
440
- return;
441
- }
442
-
443
- // List: delete row
444
- const deleteRowBtn = target.closest('[data-blok-database-delete-row]');
445
-
446
- if (deleteRowBtn !== null) {
447
- const rowId = deleteRowBtn.getAttribute('data-row-id');
448
-
449
- if (rowId !== null) {
450
- event.stopPropagation();
451
- this.model.deleteRow(rowId);
452
- this.view.removeRow(boardEl, rowId);
453
- void this.sync.syncDeleteRow({ rowId });
454
- }
455
-
456
- return;
457
- }
458
-
459
- // List: row click
460
- const listRowEl = target.closest('[data-blok-database-list-row]');
461
-
462
- if (listRowEl !== null) {
463
- const rowId = listRowEl.getAttribute('data-row-id');
464
-
465
- if (rowId !== null) {
466
- this.handleRowClick(rowId);
467
- }
468
-
469
- return;
470
- }
471
-
472
- const cardEl = target.closest('[data-blok-database-card]');
473
-
474
- if (cardEl !== null) {
475
- const rowId = cardEl.getAttribute('data-row-id');
476
-
477
- if (rowId !== null) {
478
- this.handleRowClick(rowId);
479
- }
480
- }
481
- });
482
- }
483
-
484
- private handleAddListRow(optionId: string | null, viewEl: HTMLDivElement): void {
485
- const titleProp = this.model.getSchema().find((p) => p.type === 'title');
486
- const titlePropId = titleProp?.id ?? '';
487
- const viewConfig = this.model.getView(this.activeViewId);
488
- const groupByPropId = viewConfig?.groupBy;
489
-
490
- const properties: Record<string, PropertyValue> = { [titlePropId]: '' };
491
-
492
- if (groupByPropId !== undefined && optionId !== null) {
493
- properties[groupByPropId] = optionId;
494
- }
495
-
496
- const row = this.model.addRow(properties);
497
- this.view.appendRow(viewEl, row);
498
-
499
- void this.sync.syncCreateRow({
500
- id: row.id,
501
- properties: row.properties,
502
- position: row.position,
503
- });
504
- }
505
-
506
- private handleAddRow(optionId: string, boardEl: HTMLDivElement): void {
507
- const viewConfig = this.model.getView(this.activeViewId);
508
- const groupByPropId = viewConfig?.groupBy;
509
-
510
- if (groupByPropId === undefined) {
511
- return;
512
- }
513
-
514
- const titleProp = this.model.getSchema().find((p) => p.type === 'title');
515
- const titlePropId = titleProp?.id ?? '';
516
- const row = this.model.addRow({
517
- [titlePropId]: '',
518
- [groupByPropId]: optionId,
519
- });
520
-
521
- const columnEl = boardEl.querySelector(`[data-option-id="${optionId}"][data-blok-database-column]`);
522
-
523
- if (columnEl === null) {
524
- return;
525
- }
526
-
527
- const cardsContainer = columnEl.querySelector('[data-blok-database-cards]');
528
-
529
- if (cardsContainer === null) {
530
- return;
531
- }
532
-
533
- this.view.appendRow(cardsContainer as HTMLElement, row);
534
-
535
- void this.sync.syncCreateRow({
536
- id: row.id,
537
- properties: row.properties,
538
- position: row.position,
539
- });
540
- }
541
-
542
- private handleAddColumn(boardEl: HTMLDivElement): void {
543
- const viewConfig = this.model.getView(this.activeViewId);
544
- const groupByPropId = viewConfig?.groupBy;
545
-
546
- if (groupByPropId === undefined) {
547
- return;
548
- }
549
-
550
- const prop = this.model.getProperty(groupByPropId);
551
-
552
- if (prop?.config === undefined) {
553
- return;
554
- }
555
-
556
- const existingOptions = prop.config.options;
557
- const lastPos = existingOptions.length > 0 ? existingOptions[existingOptions.length - 1].position : null;
558
- const newOption: SelectOption = {
559
- id: nanoid(),
560
- label: this.api.i18n.t('tools.database.columnTitlePlaceholder'),
561
- position: DatabaseModel.positionBetween(lastPos, null),
562
- };
563
-
564
- this.model.updateProperty(groupByPropId, {
565
- config: { options: [...existingOptions, newOption] },
566
- });
567
-
568
- this.view.appendGroup?.(boardEl, newOption);
569
- void this.sync.syncUpdateProperty({ propertyId: groupByPropId, changes: { config: { options: [...existingOptions, newOption] } } });
570
- }
571
-
572
- /**
573
- * Initializes all subsystems: card drag, column drag, column controls, card drawer, keyboard.
574
- * boardEl is the current board element for drag/column operations.
575
- * cardDrawer is attached to this.element (outer wrapper) so it persists across view switches.
576
- */
577
- private initSubsystems(boardEl: HTMLDivElement): void {
578
- if (this.element === null) {
579
- return;
580
- }
581
-
582
- const viewConfig = this.model.getView(this.activeViewId);
583
- const isList = viewConfig?.type === 'list';
584
-
585
- const titleProp = this.model.getSchema().find((p) => p.type === 'title');
586
- const titlePropId = titleProp?.id ?? '';
587
- const descriptionProp = this.model.getSchema().find((p) => p.type === 'richText');
588
- const descriptionPropId = descriptionProp?.id;
589
-
590
- if (isList) {
591
- this.listRowDrag = new DatabaseListRowDrag({
592
- wrapper: boardEl,
593
- onDrop: (result) => this.handleListRowDrop(result),
594
- });
595
- } else {
596
- this.cardDrag = new DatabaseCardDrag({
597
- wrapper: boardEl,
598
- onDrop: (result) => this.handleRowDrop(result),
599
- });
600
-
601
- this.columnDrag = new DatabaseColumnDrag({
602
- wrapper: boardEl,
603
- onDrop: (result) => this.handleGroupDrop(result),
604
- });
605
-
606
- this.columnControls = new DatabaseColumnControls({
607
- i18n: this.api.i18n,
608
- onRename: (optionId, label) => this.handleOptionRename(optionId, label),
609
- onDelete: (optionId) => this.handleOptionDelete(optionId, boardEl),
610
- });
611
-
612
- this.makeColumnHeadersEditable(boardEl);
613
- }
614
-
615
- // cardDrawer is attached to outer wrapper so it stays across view switches
616
- if (this.cardDrawer === null) {
617
- this.cardDrawer = new DatabaseCardDrawer({
618
- wrapper: this.element,
619
- readOnly: this.readOnly,
620
- i18n: this.api.i18n,
621
- toolsConfig: this.api.tools.getToolsConfig(),
622
- titlePropertyId: titlePropId,
623
- descriptionPropertyId: descriptionPropId,
624
- schema: this.model.getSchema(),
625
- onTitleChange: (rowId, title) => {
626
- this.model.updateRow(rowId, { [titlePropId]: title });
627
- const currentView = this.boardContainer?.querySelector<HTMLElement>('[data-blok-database-board]')
628
- ?? this.boardContainer?.querySelector<HTMLElement>('[data-blok-database-list]');
629
-
630
- if (currentView !== null && currentView !== undefined) {
631
- this.view.updateRowTitle(currentView, rowId, title);
632
- }
633
-
634
- this.sync.syncUpdateRow({ rowId, properties: { [titlePropId]: title } });
635
- },
636
- onDescriptionChange: (rowId, description: OutputData) => {
637
- if (descriptionPropId !== undefined) {
638
- this.model.updateRow(rowId, { [descriptionPropId]: description });
639
- this.sync.syncUpdateRow({ rowId, properties: { [descriptionPropId]: description } });
640
- }
641
- },
642
- onClose: () => { /* no-op; drawer handles its own DOM cleanup */ },
643
- onAddProperty: (type) => {
644
- const prop = this.model.addProperty('Property', type);
645
- void this.sync.syncCreateProperty({
646
- id: prop.id,
647
- name: prop.name,
648
- type: prop.type,
649
- position: prop.position,
650
- });
651
- this.cardDrawer?.refreshSchema(this.model.getSchema());
652
- },
653
- });
654
- }
655
-
656
- this.keyboard = new DatabaseKeyboard({
657
- wrapper: boardEl,
658
- onEscape: () => {
659
- if (this.cardDrawer?.isOpen) {
660
- this.cardDrawer.close();
661
-
662
- return true;
663
- }
664
-
665
- return false;
666
- },
667
- });
668
- this.keyboard.attach();
669
-
670
- boardEl.addEventListener('pointerdown', (e) => {
671
- const target = e.target as HTMLElement;
672
-
673
- // Board: column header drag
674
- const columnHeader = target.closest('[data-blok-database-column-header]');
675
-
676
- if (columnHeader !== null) {
677
- const columnEl = columnHeader.closest<HTMLElement>('[data-blok-database-column]');
678
- const optId = columnEl?.getAttribute('data-option-id') ?? null;
679
-
680
- if (optId !== null) {
681
- e.preventDefault();
682
- e.stopPropagation();
683
- this.columnDrag?.beginTracking(optId, e.clientX, e.clientY);
684
- }
685
-
686
- return;
687
- }
688
-
689
- // Board: card drag
690
- const cardEl = target.closest('[data-blok-database-card]');
691
-
692
- if (cardEl !== null) {
693
- const rowId = cardEl.getAttribute('data-row-id');
694
-
695
- if (rowId !== null) {
696
- e.preventDefault();
697
- e.stopPropagation();
698
- this.cardDrag?.beginTracking(rowId, e.clientX, e.clientY);
699
- }
700
-
701
- return;
702
- }
703
-
704
- // List: row drag
705
- const listRowEl = target.closest('[data-blok-database-list-row]');
706
-
707
- if (listRowEl !== null) {
708
- const rowId = listRowEl.getAttribute('data-row-id');
709
-
710
- if (rowId !== null) {
711
- e.preventDefault();
712
- e.stopPropagation();
713
- this.listRowDrag?.beginTracking(rowId, e.clientX, e.clientY);
714
- }
715
- }
716
- });
717
- }
718
-
719
- private makeColumnHeadersEditable(boardEl: HTMLDivElement): void {
720
- if (this.columnControls === null) {
721
- return;
722
- }
723
-
724
- const headers = Array.from(boardEl.querySelectorAll<HTMLElement>('[data-blok-database-column-header]'));
725
-
726
- for (const header of headers) {
727
- const columnEl = header.closest<HTMLElement>('[data-blok-database-column]');
728
- const optId = columnEl?.getAttribute('data-option-id');
729
-
730
- if (optId !== null && optId !== undefined) {
731
- this.columnControls.makeEditable(header, optId);
732
- }
733
- }
734
- }
735
-
736
- private handleListRowDrop(result: ListRowDragResult): void {
737
- const { rowId, beforeRowId, afterRowId } = result;
738
-
739
- const beforeRow = beforeRowId !== null ? this.model.getRow(beforeRowId) : undefined;
740
- const afterRow = afterRowId !== null ? this.model.getRow(afterRowId) : undefined;
741
- const position = DatabaseModel.positionBetween(afterRow?.position ?? null, beforeRow?.position ?? null);
742
-
743
- this.model.moveRow(rowId, position);
744
- this.rerenderView();
745
-
746
- void this.sync.syncMoveRow({ rowId, position });
747
- }
748
-
749
- private handleRowDrop(result: CardDragResult): void {
750
- const { rowId, toOptionId, beforeRowId, afterRowId } = result;
751
- const viewConfig = this.model.getView(this.activeViewId);
752
- const groupByPropId = viewConfig?.groupBy;
753
-
754
- if (groupByPropId === undefined) {
755
- return;
756
- }
757
-
758
- const beforeRow = beforeRowId !== null ? this.model.getRow(beforeRowId) : undefined;
759
- const afterRow = afterRowId !== null ? this.model.getRow(afterRowId) : undefined;
760
- const position = DatabaseModel.positionBetween(afterRow?.position ?? null, beforeRow?.position ?? null);
761
-
762
- this.model.updateRow(rowId, { [groupByPropId]: toOptionId });
763
- this.model.moveRow(rowId, position);
764
- this.rerenderView();
765
-
766
- this.sync.syncUpdateRow({ rowId, properties: { [groupByPropId]: toOptionId } });
767
- void this.sync.syncMoveRow({ rowId, position });
768
- }
769
-
770
- private handleGroupDrop(result: GroupDragResult): void {
771
- const { optionId, beforeOptionId, afterOptionId } = result;
772
- const viewConfig = this.model.getView(this.activeViewId);
773
- const groupByPropId = viewConfig?.groupBy;
774
-
775
- if (groupByPropId === undefined) {
776
- return;
777
- }
778
-
779
- const prop = this.model.getProperty(groupByPropId);
780
-
781
- if (prop?.config === undefined) {
782
- return;
783
- }
784
-
785
- const options = [...prop.config.options];
786
- const draggedIdx = options.findIndex((o) => o.id === optionId);
787
-
788
- if (draggedIdx === -1) {
789
- return;
790
- }
791
-
792
- const beforeOpt = beforeOptionId !== null ? options.find((o) => o.id === beforeOptionId) : undefined;
793
- const afterOpt = afterOptionId !== null ? options.find((o) => o.id === afterOptionId) : undefined;
794
- const newPosition = DatabaseModel.positionBetween(afterOpt?.position ?? null, beforeOpt?.position ?? null);
795
-
796
- options[draggedIdx] = { ...options[draggedIdx], position: newPosition };
797
- this.model.updateProperty(groupByPropId, { config: { options } });
798
-
799
- this.moveColumnInDom(optionId, beforeOptionId);
800
- void this.sync.syncUpdateProperty({ propertyId: groupByPropId, changes: { config: { options } } });
801
- }
802
-
803
- /**
804
- * Moves a column element to a new position in the DOM without full re-render.
805
- */
806
- private moveColumnInDom(optionId: string, beforeOptionId: string | null): void {
807
- const boardEl = this.boardContainer?.querySelector<HTMLElement>('[data-blok-database-board]');
808
-
809
- if (boardEl === null || boardEl === undefined) {
810
- return;
811
- }
812
-
813
- const columnEl = boardEl.querySelector<HTMLElement>(`[data-option-id="${optionId}"]`);
814
-
815
- if (columnEl === null) {
816
- return;
817
- }
818
-
819
- if (beforeOptionId !== null) {
820
- const beforeEl = boardEl.querySelector(`[data-option-id="${beforeOptionId}"]`);
821
-
822
- if (beforeEl !== null) {
823
- boardEl.insertBefore(columnEl, beforeEl);
824
- }
825
- } else {
826
- const addColumnBtn = boardEl.querySelector('[data-blok-database-add-column]');
827
-
828
- if (addColumnBtn !== null) {
829
- boardEl.insertBefore(columnEl, addColumnBtn);
830
- } else {
831
- boardEl.appendChild(columnEl);
832
- }
833
- }
834
- }
835
-
836
- private handleOptionRename(optionId: string, label: string): void {
837
- const viewConfig = this.model.getView(this.activeViewId);
838
- const groupByPropId = viewConfig?.groupBy;
839
-
840
- if (groupByPropId === undefined) {
841
- return;
842
- }
843
-
844
- const prop = this.model.getProperty(groupByPropId);
845
-
846
- if (prop?.config === undefined) {
847
- return;
848
- }
849
-
850
- const options = prop.config.options.map((o) => o.id === optionId ? { ...o, label } : o);
851
- this.model.updateProperty(groupByPropId, { config: { options } });
852
- void this.sync.syncUpdateProperty({ propertyId: groupByPropId, changes: { config: { options } } });
853
- }
854
-
855
- private handleOptionDelete(optionId: string, boardEl: HTMLDivElement): void {
856
- const viewConfig = this.model.getView(this.activeViewId);
857
- const groupByPropId = viewConfig?.groupBy;
858
-
859
- if (groupByPropId === undefined) {
860
- return;
861
- }
862
-
863
- const prop = this.model.getProperty(groupByPropId);
864
-
865
- if (prop?.config === undefined) {
866
- return;
867
- }
868
-
869
- if (prop.config.options.length <= 1) {
870
- return;
871
- }
872
-
873
- // Delete rows in this group
874
- const groups = this.model.getRowsGroupedBy(groupByPropId);
875
- const rowsInGroup = groups.get(optionId) ?? [];
876
-
877
- for (const row of rowsInGroup) {
878
- this.model.deleteRow(row.id);
879
- void this.sync.syncDeleteRow({ rowId: row.id });
880
- }
881
-
882
- // Remove the option
883
- const filteredOptions = prop.config.options.filter((o) => o.id !== optionId);
884
- this.model.updateProperty(groupByPropId, { config: { options: filteredOptions } });
885
- this.view.removeGroup?.(boardEl, optionId);
886
- void this.sync.syncUpdateProperty({ propertyId: groupByPropId, changes: { config: { options: filteredOptions } } });
887
- }
888
-
889
- private handleRowClick(rowId: string): void {
890
- const row = this.model.getRow(rowId);
891
-
892
- if (row === undefined) {
893
- return;
894
- }
895
-
896
- this.cardDrawer?.open(row);
897
- }
898
-
899
- /**
900
- * Full re-render of the active board: tears down subsystems, rebuilds DOM, re-inits.
901
- *
902
- * Board DOM structure:
903
- * boardContainer
904
- * boardWrapper (div returned by createBoard / renderActiveBoard)
905
- * boardArea ([data-blok-database-board] — scrollable area with columns)
906
- */
907
- private rerenderView(): void {
908
- if (this.boardContainer === null) {
909
- return;
910
- }
911
-
912
- // The old board wrapper is the first/only direct child of boardContainer
913
- const oldBoardWrapper = this.boardContainer.querySelector<HTMLElement>('[data-blok-database-board]')
914
- ?.closest<HTMLElement>('[data-blok-tool]')
915
- ?? this.boardContainer.querySelector<HTMLElement>('[data-blok-database-list]')
916
- ?? this.boardContainer.firstElementChild as HTMLElement | null;
917
-
918
- const oldBoardArea = this.boardContainer.querySelector<HTMLElement>('[data-blok-database-board]');
919
- const savedScrollLeft = oldBoardArea?.scrollLeft ?? 0;
920
-
921
- this.cardDrag?.destroy();
922
- this.columnDrag?.destroy();
923
- this.columnControls?.destroy();
924
- this.listRowDrag?.destroy();
925
- this.listRowDrag = null;
926
- this.cardDrawer?.destroy();
927
- this.cardDrawer = null;
928
- this.keyboard?.destroy();
929
-
930
- const newBoardWrapper = this.renderActiveView();
931
-
932
- if (oldBoardWrapper !== null && oldBoardWrapper !== undefined) {
933
- oldBoardWrapper.replaceWith(newBoardWrapper);
934
- } else {
935
- this.boardContainer.appendChild(newBoardWrapper);
936
- }
937
-
938
- // Restore horizontal scroll on the new board area
939
- const newBoardArea = newBoardWrapper.querySelector<HTMLElement>('[data-blok-database-board]');
940
-
941
- if (newBoardArea !== null) {
942
- newBoardArea.scrollLeft = savedScrollLeft;
943
- }
944
-
945
- this.attachViewListeners(newBoardWrapper);
946
- this.initSubsystems(newBoardWrapper);
947
- }
948
- }