@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,546 +0,0 @@
1
- import type { I18n, OutputData } from '../../../types';
2
- import type { ToolsConfig } from '../../../types/api/tools';
3
- import type { DatabaseRow, PropertyDefinition, PropertyType, PropertyValue } from './types';
4
- import { IconChevronRight } from '../../components/icons';
5
- import { DatabasePropertyTypePopover } from './database-property-type-popover';
6
-
7
- interface BlokInstance {
8
- save(): Promise<OutputData>;
9
- destroy(): void;
10
- isReady: Promise<void>;
11
- }
12
-
13
- export interface CardDrawerOptions {
14
- wrapper: HTMLElement;
15
- readOnly: boolean;
16
- i18n?: I18n;
17
- toolsConfig?: ToolsConfig;
18
- titlePropertyId: string;
19
- descriptionPropertyId?: string;
20
- schema: PropertyDefinition[];
21
- onTitleChange: (rowId: string, title: string) => void;
22
- onDescriptionChange: (rowId: string, description: OutputData) => void;
23
- onClose: () => void;
24
- onAddProperty?: (type: PropertyType) => void;
25
- }
26
-
27
- /**
28
- * Side drawer that opens when a kanban card is clicked.
29
- * Sits beside the board as a flex sibling, taking layout space.
30
- * Contains a title input, status property, and a nested Blok editor for the card description.
31
- */
32
- export class DatabaseCardDrawer {
33
- private readonly wrapper: HTMLElement;
34
- private readonly readOnly: boolean;
35
- private readonly i18n: I18n | undefined;
36
- private readonly toolsConfig: ToolsConfig | undefined;
37
- private readonly titlePropertyId: string;
38
- private readonly descriptionPropertyId: string | undefined;
39
- private schema: PropertyDefinition[];
40
- private readonly onTitleChange: (rowId: string, title: string) => void;
41
- private readonly onDescriptionChange: (rowId: string, description: OutputData) => void;
42
- private readonly onClose: () => void;
43
- private readonly onAddProperty: ((type: PropertyType) => void) | undefined;
44
-
45
- private drawer: HTMLDivElement | null = null;
46
- private currentRowId: string | null = null;
47
- private currentRow: DatabaseRow | null = null;
48
- private blokInstance: BlokInstance | null = null;
49
- private escapeHandler: ((e: KeyboardEvent) => void) | null = null;
50
- private outsideClickHandler: ((e: MouseEvent) => void) | null = null;
51
- private propertyTypePopover: DatabasePropertyTypePopover | null = null;
52
-
53
- constructor(options: CardDrawerOptions) {
54
- this.wrapper = options.wrapper;
55
- this.readOnly = options.readOnly;
56
- this.i18n = options.i18n;
57
- this.toolsConfig = options.toolsConfig;
58
- this.titlePropertyId = options.titlePropertyId;
59
- this.descriptionPropertyId = options.descriptionPropertyId;
60
- this.schema = options.schema;
61
- this.onTitleChange = options.onTitleChange;
62
- this.onDescriptionChange = options.onDescriptionChange;
63
- this.onClose = options.onClose;
64
- this.onAddProperty = options.onAddProperty;
65
- }
66
-
67
- get isOpen(): boolean {
68
- return this.drawer !== null;
69
- }
70
-
71
- open(row: DatabaseRow): void {
72
- if (this.drawer) {
73
- if (row.id === this.currentRowId) {
74
- return;
75
- }
76
-
77
- this.loadCard(row);
78
-
79
- return;
80
- }
81
-
82
- // Remove any drawer still animating out from a previous close
83
- const exiting = this.wrapper.querySelector('[data-blok-database-drawer]');
84
-
85
- exiting?.remove();
86
-
87
- this.currentRowId = row.id;
88
- this.currentRow = row;
89
- this.updateActiveCard(row.id);
90
-
91
- const title = (row.properties[this.titlePropertyId] as string) ?? '';
92
-
93
- const drawer = document.createElement('div');
94
-
95
- drawer.setAttribute('data-blok-database-drawer', '');
96
- drawer.setAttribute('role', 'complementary');
97
- drawer.setAttribute('aria-label', 'Card details');
98
-
99
- // --- Top toolbar ---
100
- const toolbar = document.createElement('div');
101
-
102
- toolbar.setAttribute('data-blok-database-drawer-toolbar', '');
103
-
104
- const closeBtn = document.createElement('button');
105
-
106
- closeBtn.setAttribute('data-blok-database-drawer-close', '');
107
- closeBtn.setAttribute('aria-label', 'Close');
108
- closeBtn.innerHTML = IconChevronRight + IconChevronRight;
109
- closeBtn.addEventListener('click', () => {
110
- this.close();
111
- });
112
- toolbar.appendChild(closeBtn);
113
-
114
- drawer.appendChild(toolbar);
115
-
116
- // --- Scrollable content ---
117
- const content = document.createElement('div');
118
-
119
- content.setAttribute('data-blok-database-drawer-content', '');
120
-
121
- // --- Title input ---
122
- const titleInput = document.createElement('textarea');
123
-
124
- titleInput.setAttribute('data-blok-database-drawer-title', '');
125
- titleInput.setAttribute('aria-label', 'Card title');
126
- titleInput.placeholder = this.i18n?.t('tools.database.cardTitlePlaceholder') ?? 'Empty page';
127
- titleInput.value = title;
128
- titleInput.rows = 1;
129
- titleInput.readOnly = this.readOnly;
130
- titleInput.addEventListener('input', () => {
131
- if (this.currentRowId !== null) {
132
- this.onTitleChange(this.currentRowId, titleInput.value);
133
- }
134
- this.autoResizeTitle(titleInput);
135
- });
136
- titleInput.addEventListener('keydown', (e) => {
137
- if (e.key === 'Enter') {
138
- e.preventDefault();
139
- }
140
- });
141
- content.appendChild(titleInput);
142
-
143
- // --- Properties section ---
144
- const renderableSchema = this.getRenderableSchema();
145
-
146
- content.appendChild(this.buildPropsSection(renderableSchema, row));
147
-
148
- // --- Divider ---
149
- const divider = document.createElement('hr');
150
-
151
- content.appendChild(divider);
152
-
153
- // --- Editor holder ---
154
- const editorHolder = document.createElement('div');
155
-
156
- editorHolder.setAttribute('data-blok-database-drawer-editor', '');
157
- content.appendChild(editorHolder);
158
-
159
- drawer.appendChild(content);
160
- this.wrapper.appendChild(drawer);
161
- this.drawer = drawer;
162
-
163
- requestAnimationFrame(() => {
164
- drawer.style.width = '45%';
165
- drawer.addEventListener('transitionend', () => {
166
- this.autoResizeTitle(titleInput);
167
-
168
- if (!title) {
169
- titleInput.focus();
170
- }
171
- }, { once: true });
172
- });
173
-
174
- this.initNestedEditor(editorHolder, row);
175
-
176
- this.escapeHandler = (e: KeyboardEvent): void => {
177
- if (e.key !== 'Escape') {
178
- return;
179
- }
180
-
181
- const target = e.target as Node | null;
182
-
183
- if (target && editorHolder.contains(target)) {
184
- return;
185
- }
186
-
187
- this.close();
188
- };
189
- document.addEventListener('keydown', this.escapeHandler);
190
-
191
- this.outsideClickHandler = (e: MouseEvent): void => {
192
- const target = e.target as Node | null;
193
-
194
- if (target && drawer.contains(target)) {
195
- return;
196
- }
197
-
198
- /**
199
- * Toolbox and other popovers are portaled to document.body,
200
- * so they sit outside the drawer DOM tree. Without this check,
201
- * clicking a popover item would be treated as an "outside click"
202
- * and close the drawer.
203
- */
204
- if (target instanceof Element && target.closest('[data-blok-popover-opened]') !== null) {
205
- return;
206
- }
207
-
208
- /**
209
- * The tab bar lives outside the drawer DOM tree, so clicking a
210
- * tab to switch views would be treated as an outside click and
211
- * close the drawer before switchView() runs.
212
- */
213
- if (target instanceof Element && target.closest('[data-blok-database-tab-bar]') !== null) {
214
- return;
215
- }
216
-
217
- this.close();
218
- };
219
- document.addEventListener('mousedown', this.outsideClickHandler);
220
-
221
- titleInput.focus();
222
- }
223
-
224
- /**
225
- * Swaps content in the already-open drawer to show a different card
226
- * without closing/reopening the drawer panel.
227
- */
228
- private loadCard(row: DatabaseRow): void {
229
- if (this.drawer === null) {
230
- return;
231
- }
232
-
233
- this.cleanupEditor();
234
-
235
- this.currentRowId = row.id;
236
- this.currentRow = row;
237
- this.updateActiveCard(row.id);
238
-
239
- const title = (row.properties[this.titlePropertyId] as string) ?? '';
240
-
241
- // Update title
242
- const titleInput = this.drawer.querySelector<HTMLTextAreaElement>('[data-blok-database-drawer-title]');
243
-
244
- if (titleInput !== null) {
245
- titleInput.value = title;
246
- this.autoResizeTitle(titleInput);
247
-
248
- if (!title) {
249
- titleInput.focus();
250
- }
251
- }
252
-
253
- // Replace properties section
254
- this.drawer.querySelector('[data-blok-database-drawer-props]')?.remove();
255
-
256
- const renderableSchema = this.getRenderableSchema();
257
- const content = this.drawer.querySelector('[data-blok-database-drawer-content]');
258
- const divider = content?.querySelector('hr') ?? null;
259
-
260
- if (content !== null) {
261
- content.insertBefore(this.buildPropsSection(renderableSchema, row), divider);
262
- }
263
-
264
- // Reinitialize editor
265
- const editorHolder = this.drawer.querySelector<HTMLElement>('[data-blok-database-drawer-editor]');
266
-
267
- if (editorHolder !== null) {
268
- editorHolder.innerHTML = '';
269
- this.initNestedEditor(editorHolder, row);
270
- }
271
- }
272
-
273
- close(): void {
274
- const wasOpen = this.drawer !== null;
275
-
276
- this.updateActiveCard(null);
277
- this.cleanupListeners();
278
- this.cleanupEditor();
279
-
280
- if (this.drawer) {
281
- const drawer = this.drawer;
282
-
283
- this.drawer = null;
284
- drawer.style.width = '0px';
285
- drawer.addEventListener('transitionend', () => {
286
- drawer.remove();
287
- }, { once: true });
288
- }
289
-
290
- this.currentRowId = null;
291
- this.currentRow = null;
292
-
293
- if (wasOpen) {
294
- this.onClose();
295
- }
296
- }
297
-
298
- destroy(): void {
299
- this.cleanupListeners();
300
- this.cleanupEditor();
301
- this.propertyTypePopover?.destroy();
302
- this.propertyTypePopover = null;
303
-
304
- if (this.drawer) {
305
- this.drawer.remove();
306
- this.drawer = null;
307
- }
308
-
309
- // Remove any drawer still animating out
310
- const exiting = this.wrapper.querySelector('[data-blok-database-drawer]');
311
-
312
- exiting?.remove();
313
-
314
- this.currentRowId = null;
315
- this.currentRow = null;
316
- }
317
-
318
- /**
319
- * Updates the schema and, if the drawer is currently open, rebuilds the
320
- * properties section in-place using the current row's data.
321
- */
322
- refreshSchema(schema: PropertyDefinition[]): void {
323
- this.schema = schema;
324
-
325
- if (this.drawer === null || this.currentRow === null) {
326
- return;
327
- }
328
-
329
- this.drawer.querySelector('[data-blok-database-drawer-props]')?.remove();
330
-
331
- const renderableSchema = this.getRenderableSchema();
332
- const content = this.drawer.querySelector('[data-blok-database-drawer-content]');
333
- const divider = content?.querySelector('hr') ?? null;
334
-
335
- if (content !== null) {
336
- content.insertBefore(this.buildPropsSection(renderableSchema, this.currentRow), divider);
337
- }
338
- }
339
-
340
- /**
341
- * Builds a `[data-blok-database-drawer-props]` section element with one row per
342
- * renderable schema property.
343
- */
344
- private buildPropsSection(renderableSchema: PropertyDefinition[], row: DatabaseRow): HTMLDivElement {
345
- const propsSection = document.createElement('div');
346
-
347
- propsSection.setAttribute('data-blok-database-drawer-props', '');
348
-
349
- for (const def of renderableSchema) {
350
- propsSection.appendChild(this.createPropertyRow(def, row.properties[def.id] ?? null));
351
- }
352
-
353
- if (!this.readOnly) {
354
- const addBtn = document.createElement('button');
355
-
356
- addBtn.setAttribute('data-blok-database-drawer-add-prop', '');
357
- addBtn.textContent = '+ Add a property';
358
- addBtn.addEventListener('click', () => {
359
- if (this.propertyTypePopover === null) {
360
- this.propertyTypePopover = new DatabasePropertyTypePopover({
361
- onSelect: (type) => {
362
- this.onAddProperty?.(type);
363
- this.propertyTypePopover?.close();
364
- },
365
- });
366
- }
367
-
368
- this.propertyTypePopover.open(addBtn);
369
- });
370
- propsSection.appendChild(addBtn);
371
- }
372
-
373
- return propsSection;
374
- }
375
-
376
- /**
377
- * Returns schema properties that should be shown in the properties section,
378
- * sorted by position. Excludes 'title' and 'richText' (rendered separately).
379
- */
380
- private getRenderableSchema(): PropertyDefinition[] {
381
- return [...this.schema]
382
- .filter((def) => def.type !== 'title' && def.type !== 'richText')
383
- .sort((a, b) => {
384
- if (a.position < b.position) return -1;
385
- if (a.position > b.position) return 1;
386
-
387
- return 0;
388
- });
389
- }
390
-
391
- /**
392
- * Creates a pill badge element for a select option.
393
- */
394
- private createSelectPill(option: { label: string; color?: string }): HTMLSpanElement {
395
- const pill = document.createElement('span');
396
-
397
- pill.setAttribute('data-blok-database-drawer-prop-pill', '');
398
-
399
- if (option.color !== undefined) {
400
- pill.style.backgroundColor = `var(--blok-color-${option.color}-bg)`;
401
- pill.style.color = `var(--blok-color-${option.color}-text)`;
402
-
403
- const dot = document.createElement('span');
404
-
405
- dot.setAttribute('data-blok-database-drawer-prop-dot', '');
406
- dot.style.backgroundColor = `var(--blok-color-${option.color}-text)`;
407
- pill.appendChild(dot);
408
- }
409
-
410
- const pillText = document.createElement('span');
411
-
412
- pillText.textContent = option.label;
413
- pill.appendChild(pillText);
414
-
415
- return pill;
416
- }
417
-
418
- /**
419
- * Creates a property row that dispatches on the property type to render
420
- * the appropriate value representation.
421
- */
422
- private createPropertyRow(def: PropertyDefinition, value: PropertyValue): HTMLDivElement {
423
- const row = document.createElement('div');
424
-
425
- row.setAttribute('data-blok-database-drawer-prop-row', '');
426
-
427
- const label = document.createElement('span');
428
-
429
- label.setAttribute('data-blok-database-drawer-prop-label', '');
430
- label.textContent = def.name;
431
- row.appendChild(label);
432
-
433
- const valueEl = document.createElement('span');
434
-
435
- valueEl.setAttribute('data-blok-database-drawer-prop-value', '');
436
-
437
- if (def.type === 'select') {
438
- const config = def.config;
439
- const optionId = typeof value === 'string' ? value : null;
440
- const option = config?.options.find((o) => o.id === optionId);
441
-
442
- if (option !== undefined) {
443
- valueEl.appendChild(this.createSelectPill(option));
444
- }
445
- } else if (def.type === 'multiSelect') {
446
- const config = def.config;
447
- const selectedIds = Array.isArray(value) ? value : [];
448
-
449
- selectedIds
450
- .map((id) => config?.options.find((o) => o.id === id))
451
- .filter((opt): opt is NonNullable<typeof opt> => opt !== undefined)
452
- .forEach((opt) => valueEl.appendChild(this.createSelectPill(opt)));
453
- } else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
454
- valueEl.textContent = String(value);
455
- }
456
-
457
- row.appendChild(valueEl);
458
-
459
- return row;
460
- }
461
-
462
- private updateActiveCard(rowId: string | null): void {
463
- const prev = this.wrapper.querySelector('[data-blok-database-card-active]');
464
-
465
- prev?.removeAttribute('data-blok-database-card-active');
466
-
467
- if (rowId !== null) {
468
- const cardEl = this.wrapper.querySelector(`[data-blok-database-card][data-row-id="${rowId}"]`);
469
-
470
- cardEl?.setAttribute('data-blok-database-card-active', '');
471
- }
472
- }
473
-
474
- private cleanupListeners(): void {
475
- if (this.escapeHandler) {
476
- document.removeEventListener('keydown', this.escapeHandler);
477
- this.escapeHandler = null;
478
- }
479
-
480
- if (this.outsideClickHandler) {
481
- document.removeEventListener('mousedown', this.outsideClickHandler);
482
- this.outsideClickHandler = null;
483
- }
484
- }
485
-
486
- private cleanupEditor(): void {
487
- if (this.blokInstance) {
488
- try {
489
- const instance = this.blokInstance;
490
- const rowId = this.currentRowId;
491
-
492
- instance.save().then((data) => {
493
- if (rowId !== null) {
494
- this.onDescriptionChange(rowId, data);
495
- }
496
- instance.destroy();
497
- }).catch(() => {
498
- instance.destroy();
499
- });
500
- } catch {
501
- // Blok may already be destroyed
502
- }
503
- this.blokInstance = null;
504
- }
505
- }
506
-
507
- private autoResizeTitle(textarea: HTMLTextAreaElement): void {
508
- const { style } = textarea;
509
-
510
- style.height = 'auto';
511
-
512
- if (textarea.scrollHeight > 0) {
513
- style.height = `${textarea.scrollHeight}px`;
514
- }
515
- }
516
-
517
- private initNestedEditor(editorHolder: HTMLElement, row: DatabaseRow): void {
518
- import('../../blok').then(({ Blok }) => {
519
- const rowId = row.id;
520
- const description = this.descriptionPropertyId !== undefined
521
- ? row.properties[this.descriptionPropertyId]
522
- : undefined;
523
- const blok = new Blok({
524
- ...this.toolsConfig,
525
- holder: editorHolder,
526
- data: description as OutputData | undefined,
527
- readOnly: this.readOnly,
528
- onChange: async () => {
529
- try {
530
- const data = await this.blokInstance?.save();
531
-
532
- if (data !== undefined) {
533
- this.onDescriptionChange(rowId, data);
534
- }
535
- } catch {
536
- // save may fail if editor is being destroyed
537
- }
538
- },
539
- });
540
-
541
- this.blokInstance = blok as unknown as BlokInstance;
542
- }).catch(() => {
543
- // Blok import may fail in unit tests (jsdom), drawer still works for title
544
- });
545
- }
546
- }
@@ -1,46 +0,0 @@
1
- import type { I18n } from '../../../types';
2
-
3
- export interface ColumnControlsOptions {
4
- i18n: I18n;
5
- onRename: (optionId: string, label: string) => void;
6
- onDelete: (optionId: string) => void;
7
- }
8
-
9
- export class DatabaseColumnControls {
10
- private options: ColumnControlsOptions;
11
- private readonly i18n: I18n;
12
-
13
- constructor(options: ColumnControlsOptions) {
14
- this.options = options;
15
- this.i18n = options.i18n;
16
- }
17
-
18
- makeEditable(headerEl: HTMLElement, optionId: string): void {
19
- const titleEl = headerEl.querySelector('[data-blok-database-column-title]');
20
-
21
- if (titleEl) {
22
- const input = document.createElement('input');
23
-
24
- input.type = 'text';
25
- input.value = titleEl.textContent ?? '';
26
- input.setAttribute('data-blok-database-column-title-input', '');
27
- input.setAttribute('aria-label', this.i18n.t('tools.database.renameColumn'));
28
- input.addEventListener('change', () => {
29
- this.options.onRename(optionId, input.value);
30
- });
31
- titleEl.replaceWith(input);
32
- }
33
-
34
- const deleteBtn = document.createElement('button');
35
-
36
- deleteBtn.setAttribute('data-blok-database-delete-column', '');
37
- deleteBtn.setAttribute('aria-label', this.i18n.t('tools.database.deleteColumn'));
38
- deleteBtn.setAttribute('data-option-id', optionId);
39
- deleteBtn.addEventListener('click', () => {
40
- this.options.onDelete(optionId);
41
- });
42
- headerEl.appendChild(deleteBtn);
43
- }
44
-
45
- destroy(): void { /* no global listeners */ }
46
- }