@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.
- package/dist/blok.mjs +3 -3
- package/dist/chunks/{blok-D_0qAdUd.mjs → blok-BdlR_lX6.mjs} +2073 -2034
- package/dist/chunks/chunk-Byubey_H.mjs +20 -0
- package/dist/chunks/{constants-DxSXr7kd.mjs → constants-Cp8O0UfP.mjs} +524 -550
- package/dist/chunks/default-DIfXCS2E.mjs +4 -0
- package/dist/chunks/{i18next-G6FKbZqA.mjs → i18next-KNC_XV5x.mjs} +1 -1
- package/dist/chunks/{i18next-loader-CwNimni3.mjs → i18next-loader-oDO9ZKUV.mjs} +2 -2
- package/dist/chunks/katex-NjLaA6AJ.mjs +22026 -0
- package/dist/chunks/{lightweight-i18n-DWCdzAw0.mjs → lightweight-i18n-DTySD6f6.mjs} +16 -18
- package/dist/chunks/mdast-util-math-yS0EygZV.mjs +151 -0
- package/dist/{messages-DVQNjdPk.mjs → chunks/messages-5ArOv8cj.mjs} +3 -17
- package/dist/chunks/{messages-Czny5pPT2.mjs → messages-876bKyUj2.mjs} +3 -17
- package/dist/{messages-JhoVMjfX2.mjs → chunks/messages-9l49jauY.mjs} +3 -17
- package/dist/{messages-D3cAcyzj.mjs → chunks/messages-B5aAzExz.mjs} +3 -17
- package/dist/chunks/{messages-CmrMwBv3.mjs → messages-B5fKJXd6.mjs} +3 -17
- package/dist/chunks/{messages-DBpXyvRe2.mjs → messages-B9N__q552.mjs} +3 -17
- package/dist/{messages-CVcQD-9u.mjs → chunks/messages-BAP2OAQk.mjs} +3 -17
- package/dist/chunks/{messages-R2W_rGOo2.mjs → messages-BDXl53cy2.mjs} +3 -17
- package/dist/{messages-CM5fsPo02.mjs → chunks/messages-BGCQCeWd.mjs} +3 -17
- package/dist/{messages-DtrSrdfE2.mjs → chunks/messages-BHhbHLoq.mjs} +3 -17
- package/dist/{messages-C6Y4Jv2N.mjs → chunks/messages-BMq9k_lI.mjs} +3 -17
- package/dist/{messages-DjJQoYvP2.mjs → chunks/messages-BXSXk3oS2.mjs} +3 -17
- package/dist/{messages-pgPcitDH.mjs → chunks/messages-BXn9Vzbx2.mjs} +3 -17
- package/dist/chunks/{messages-DR09nkcZ.mjs → messages-BaoJwsEZ.mjs} +3 -17
- package/dist/{messages-CdlsTFB1.mjs → chunks/messages-BbfLRqLh2.mjs} +3 -17
- package/dist/{messages-BvgTQLf72.mjs → chunks/messages-BhcYsC_M2.mjs} +3 -17
- package/dist/chunks/{messages-Cdx4QMR1.mjs → messages-BlO_37l_.mjs} +3 -17
- package/dist/{messages--S8_taOd2.mjs → chunks/messages-BlcRm2I3.mjs} +3 -17
- package/dist/{messages-DbxbxUiK2.mjs → chunks/messages-Btr121zI2.mjs} +3 -17
- package/dist/chunks/{messages-p4byLfvR.mjs → messages-BxBID_0B.mjs} +3 -17
- package/dist/chunks/{messages-Cs9XBt4T.mjs → messages-ByAqzAhB.mjs} +3 -17
- package/dist/chunks/{messages-JQKFJo7C.mjs → messages-C-jA6Rf7.mjs} +3 -17
- package/dist/{messages-BAcH6PtT2.mjs → chunks/messages-C5aCWL7B.mjs} +3 -17
- package/dist/{messages-BCG_evLg.mjs → chunks/messages-CF_PfacZ.mjs} +3 -17
- package/dist/{messages-B-4fku2H2.mjs → chunks/messages-CKRJDX0K2.mjs} +3 -17
- package/dist/chunks/{messages-CrMfiGu5.mjs → messages-CL3mCbi6.mjs} +3 -17
- package/dist/chunks/{messages-BnznaKEP2.mjs → messages-CNEJxD8q2.mjs} +3 -17
- package/dist/{messages-hTpeKUaW.mjs → chunks/messages-CZ5Sbf8U.mjs} +3 -17
- package/dist/chunks/{messages-CljStrYi.mjs → messages-CcyIKgGU.mjs} +3 -17
- package/dist/{messages-Dcyrzdxa2.mjs → chunks/messages-CdzF0Hvl.mjs} +3 -17
- package/dist/chunks/{messages-IDEUsFhQ2.mjs → messages-CgedvWCf.mjs} +3 -17
- package/dist/chunks/{messages-CmXADeab2.mjs → messages-CjVPwkVy.mjs} +3 -17
- package/dist/chunks/{messages-wLSVQbsA2.mjs → messages-CnQydQJd2.mjs} +3 -17
- package/dist/chunks/{messages-BS1nOvZ-.mjs → messages-CqgEz7C5.mjs} +3 -17
- package/dist/{messages-BCuTVHBV.mjs → chunks/messages-CvlMT1e62.mjs} +3 -17
- package/dist/{messages-CYX48nfg.mjs → chunks/messages-CyxDkx8a.mjs} +3 -17
- package/dist/chunks/{messages-ClRHDxzh.mjs → messages-D7n_wJK7.mjs} +3 -17
- package/dist/chunks/{messages-Dplnp19q.mjs → messages-D8-N0FmU.mjs} +3 -17
- package/dist/chunks/{messages-DAVsuDWh2.mjs → messages-D8dKkyII2.mjs} +3 -17
- package/dist/chunks/{messages-B3s2vra72.mjs → messages-DGD6BiGd.mjs} +3 -17
- package/dist/chunks/{messages-DHCVA7XQ.mjs → messages-DJO0ERQT.mjs} +3 -17
- package/dist/chunks/{messages-B7MIRzCa2.mjs → messages-DMyRdafk2.mjs} +3 -17
- package/dist/chunks/{messages-C-b6tPad2.mjs → messages-DN-194c32.mjs} +3 -17
- package/dist/chunks/{messages-BW_7lfqG2.mjs → messages-DQ5ng0_t2.mjs} +3 -17
- package/dist/{messages-DUBHHfEt.mjs → chunks/messages-DRv4g-IA.mjs} +3 -17
- package/dist/chunks/{messages-xfjdrZmx.mjs → messages-DSO2U-ul.mjs} +3 -17
- package/dist/{messages-CgzbJ8_l2.mjs → chunks/messages-DUGEqDEG.mjs} +3 -17
- package/dist/{messages-DA-o8X3A.mjs → chunks/messages-DVKifYlq.mjs} +3 -17
- package/dist/{messages-tsHpMdDT2.mjs → chunks/messages-DWD0ry9x.mjs} +3 -17
- package/dist/{messages-Dddxv8-f2.mjs → chunks/messages-DYizZHT2.mjs} +3 -17
- package/dist/chunks/{messages-Csvm4mtA.mjs → messages-DZwCufSb.mjs} +3 -17
- package/dist/{messages-BJ7BuFZi.mjs → chunks/messages-DdmWzF5M.mjs} +3 -17
- package/dist/{messages-Bo_FUvVH.mjs → chunks/messages-DgEGJECT.mjs} +3 -17
- package/dist/chunks/{messages-Bpda_3PM2.mjs → messages-Dgng6KN8.mjs} +3 -17
- package/dist/{messages-CBzd_x7H.mjs → chunks/messages-DkTxBa1V.mjs} +3 -17
- package/dist/{messages-Bio7KYsr2.mjs → chunks/messages-DnJHflSh.mjs} +3 -17
- package/dist/{messages-CjmSrt1D.mjs → chunks/messages-DopbvJlg.mjs} +3 -17
- package/dist/{messages-DIRha_gg2.mjs → chunks/messages-Dux1S0-D2.mjs} +3 -17
- package/dist/chunks/{messages-1Raf1IK82.mjs → messages-Dw2rmKMi2.mjs} +3 -17
- package/dist/chunks/{messages-D5IgUbBD2.mjs → messages-Dz3UhEco2.mjs} +3 -17
- package/dist/{messages-C6OJvnJg2.mjs → chunks/messages-FYl9woii2.mjs} +3 -17
- package/dist/{messages-BBvDbp62.mjs → chunks/messages-Jps5Tc77.mjs} +3 -17
- package/dist/chunks/{messages-Dfpi8pDY.mjs → messages-NJsvFwJj.mjs} +3 -17
- package/dist/chunks/{messages-DPykxECP2.mjs → messages-SSDr5fGF2.mjs} +3 -17
- package/dist/{messages-BXI3qIos.mjs → chunks/messages-bmwto4UV.mjs} +3 -17
- package/dist/{messages-CBdQ3XP9.mjs → chunks/messages-vN4T4r67.mjs} +3 -17
- package/dist/{messages-tK67CBqn.mjs → chunks/messages-yszqJukE.mjs} +3 -17
- package/dist/chunks/micromark-extension-math-CCEGWpdz.mjs +169 -0
- package/dist/chunks/micromark-factory-space-WwmyBO_J.mjs +36 -0
- package/dist/chunks/{notifier-Butv4Dvo.mjs → notifier-BOwxj_Ok.mjs} +1 -1
- package/dist/chunks/{objectSpread2-BY4mgzrQ.mjs → objectSpread2-CWwMYL_U.mjs} +1 -1
- package/dist/chunks/{tools-DVZ3zU40.mjs → tools-DGOsJbHH.mjs} +1816 -2916
- package/dist/full.mjs +14 -14
- package/dist/locales.mjs +82 -84
- package/dist/markdown.mjs +3962 -0
- package/dist/{messages-DqyqEw1_.mjs → messages--cUQf9JX.mjs} +3 -17
- package/dist/{messages-BtxaN-xx.mjs → messages-12_eyAo-.mjs} +3 -17
- package/dist/{chunks/messages-LxumrNue2.mjs → messages-B3Yhiycb2.mjs} +3 -17
- package/dist/{chunks/messages-Cqc-6rfh2.mjs → messages-B4lhNMKm2.mjs} +3 -17
- package/dist/{chunks/messages-B0ffBqzr.mjs → messages-BOE2mzCj2.mjs} +3 -17
- package/dist/{chunks/messages-BaPZuLjN.mjs → messages-BPL7riv-.mjs} +3 -17
- package/dist/{messages-DD5pW0zJ.mjs → messages-BYQ769S5.mjs} +3 -17
- package/dist/{chunks/messages-C11byid72.mjs → messages-B_sKqaeK.mjs} +3 -17
- package/dist/{messages-BmNaAyKS.mjs → messages-Bdk4ocMI.mjs} +3 -17
- package/dist/{chunks/messages-6mikOS4D2.mjs → messages-BeI2HORe2.mjs} +3 -17
- package/dist/{chunks/messages-u2yxkNTE2.mjs → messages-Bug6Du35.mjs} +3 -17
- package/dist/{messages-eTourT12.mjs → messages-C2veeQpU.mjs} +3 -17
- package/dist/{messages-BokEflKa.mjs → messages-C5Uufygq.mjs} +3 -17
- package/dist/{chunks/messages-BPog17132.mjs → messages-C8f1I5EQ2.mjs} +3 -17
- package/dist/{chunks/messages-ID1PHnMv.mjs → messages-CBPiFbEf2.mjs} +3 -17
- package/dist/{messages-DZEcrbmH.mjs → messages-CByBLxWk.mjs} +3 -17
- package/dist/{chunks/messages-BgVEGd4c.mjs → messages-CD8K1g_t2.mjs} +3 -17
- package/dist/{messages-Dkg99bfr2.mjs → messages-CEEzfqMO2.mjs} +3 -17
- package/dist/{messages-DV9e1DW7.mjs → messages-CNNcKuGH.mjs} +3 -17
- package/dist/{messages-C30Vz-UZ2.mjs → messages-CSl0Wla62.mjs} +3 -17
- package/dist/{messages-fLi0P2dP.mjs → messages-CUzBNjnc.mjs} +3 -17
- package/dist/{chunks/messages-DJA6fb_P2.mjs → messages-CWEL1WDy2.mjs} +3 -17
- package/dist/{messages-BcFQFcJ92.mjs → messages-C_HmWyXc2.mjs} +3 -17
- package/dist/{chunks/messages-CpzO7KRA.mjs → messages-Cb3wXGnc.mjs} +3 -17
- package/dist/{messages-C5XPUD9T2.mjs → messages-Cd23UgLV2.mjs} +3 -17
- package/dist/{chunks/messages-DSjXen8E.mjs → messages-Cg1CF4pw.mjs} +3 -17
- package/dist/{messages-i4S6q64n2.mjs → messages-CgEDVri-2.mjs} +3 -17
- package/dist/{messages-CHJ5SOZI.mjs → messages-ChTWmxS8.mjs} +3 -17
- package/dist/{messages-BVKZK-3t.mjs → messages-Cho2VTAX.mjs} +3 -17
- package/dist/{chunks/messages-d0Ky6QjR.mjs → messages-CkySRhtd2.mjs} +3 -17
- package/dist/{chunks/messages-C1OqT_nL.mjs → messages-Clsh86WQ.mjs} +3 -17
- package/dist/{chunks/messages-BrFl5773.mjs → messages-CsiGzUSP2.mjs} +3 -17
- package/dist/{messages-BKjqW08U.mjs → messages-Cv-DKlZd.mjs} +3 -17
- package/dist/{messages-BGsDZTQp2.mjs → messages-CvvbLyTy2.mjs} +3 -17
- package/dist/{chunks/messages-DA7Zk-Cy.mjs → messages-CwCEcbWG.mjs} +3 -17
- package/dist/{chunks/messages-DQ5AyNCU.mjs → messages-D38h5XlF.mjs} +3 -17
- package/dist/{chunks/messages-DC7TX-YT.mjs → messages-D7juvhHp.mjs} +3 -17
- package/dist/{chunks/messages-BdnSVKOw.mjs → messages-D8WvwU42.mjs} +3 -17
- package/dist/{chunks/messages-Df87zXXG.mjs → messages-DACg1XAu.mjs} +3 -17
- package/dist/{messages-BBq0M604.mjs → messages-DIKCwGog.mjs} +3 -17
- package/dist/{messages-Ccd587Yn.mjs → messages-DJU4YLij.mjs} +3 -17
- package/dist/{chunks/messages-Dm4YVlrm.mjs → messages-DQN1y6E9.mjs} +3 -17
- package/dist/{messages-CqkRG9mH.mjs → messages-DRU_IgoW.mjs} +3 -17
- package/dist/{chunks/messages-DT7fRpCy.mjs → messages-DbZsJAff.mjs} +3 -17
- package/dist/{messages-upqrRZQH2.mjs → messages-Dg2CDXZi2.mjs} +3 -17
- package/dist/{messages-DJKLtW7u.mjs → messages-Dj79y02X.mjs} +3 -17
- package/dist/{chunks/messages-Ct7AMBS82.mjs → messages-DjWfVYHS2.mjs} +3 -17
- package/dist/{chunks/messages-B2pW6jO_.mjs → messages-DkvQ-6HC2.mjs} +3 -17
- package/dist/{chunks/messages-ZJ0b1C3a.mjs → messages-DnhEzmXJ2.mjs} +3 -17
- package/dist/{chunks/messages-BgsPQXfP.mjs → messages-DqJTZbwt.mjs} +3 -17
- package/dist/{chunks/messages-DUDgFEEe2.mjs → messages-Dq_v7slw2.mjs} +3 -17
- package/dist/{chunks/messages-CyNsByCY.mjs → messages-En8LDjUB.mjs} +3 -17
- package/dist/{chunks/messages-FHrCEJmY2.mjs → messages-JK9Okzsy2.mjs} +3 -17
- package/dist/{messages-DnatBKPm.mjs → messages-KSxF8eib.mjs} +3 -17
- package/dist/{chunks/messages-DD7BI6BK.mjs → messages-KbYSpNrE.mjs} +3 -17
- package/dist/{messages-BvgXeMSL2.mjs → messages-KqWQKmIu2.mjs} +3 -17
- package/dist/{messages-BSe3QDnQ.mjs → messages-PvMdmlxI.mjs} +3 -17
- package/dist/{chunks/messages-DJkIeapn.mjs → messages-So3SHdIc2.mjs} +3 -17
- package/dist/{messages-BywbKcPC.mjs → messages-X80Nh0ib.mjs} +3 -17
- package/dist/{messages-DOTJ2NvJ.mjs → messages-hrSlVSHp.mjs} +3 -17
- package/dist/{messages-DJT4Bt_02.mjs → messages-mipkPgwQ2.mjs} +3 -17
- package/dist/{messages-xEI8gEDK.mjs → messages-nOe1gJYu.mjs} +3 -17
- package/dist/{messages-Bk984gRE2.mjs → messages-rbox5gSb2.mjs} +3 -17
- package/dist/{chunks/messages-CgRvtOEY.mjs → messages-uCsQjz7M.mjs} +3 -17
- package/dist/{chunks/messages-BbdNugdi.mjs → messages-vcoib5Ga.mjs} +3 -17
- package/dist/{chunks/messages-CvfKofOP.mjs → messages-vptt-pVF.mjs} +3 -17
- package/dist/{chunks/messages-BkCjgGxc.mjs → messages-x353UCBI.mjs} +3 -17
- package/dist/react.mjs +3 -3
- package/dist/tools.mjs +3 -3
- package/dist/vendor.LICENSE.txt +1622 -182
- package/package.json +15 -2
- package/src/components/blocks.ts +26 -1
- package/src/components/i18n/locales/am/messages.json +3 -17
- package/src/components/i18n/locales/ar/messages.json +3 -17
- package/src/components/i18n/locales/az/messages.json +3 -17
- package/src/components/i18n/locales/bg/messages.json +3 -17
- package/src/components/i18n/locales/bn/messages.json +3 -17
- package/src/components/i18n/locales/bs/messages.json +3 -17
- package/src/components/i18n/locales/cs/messages.json +3 -17
- package/src/components/i18n/locales/da/messages.json +3 -17
- package/src/components/i18n/locales/de/messages.json +3 -17
- package/src/components/i18n/locales/dv/messages.json +3 -17
- package/src/components/i18n/locales/el/messages.json +3 -17
- package/src/components/i18n/locales/en/messages.json +15 -17
- package/src/components/i18n/locales/es/messages.json +3 -17
- package/src/components/i18n/locales/et/messages.json +3 -17
- package/src/components/i18n/locales/fa/messages.json +3 -17
- package/src/components/i18n/locales/fi/messages.json +3 -17
- package/src/components/i18n/locales/fil/messages.json +3 -17
- package/src/components/i18n/locales/fr/messages.json +3 -17
- package/src/components/i18n/locales/gu/messages.json +3 -17
- package/src/components/i18n/locales/he/messages.json +3 -17
- package/src/components/i18n/locales/hi/messages.json +3 -17
- package/src/components/i18n/locales/hr/messages.json +3 -17
- package/src/components/i18n/locales/hu/messages.json +3 -17
- package/src/components/i18n/locales/hy/messages.json +3 -17
- package/src/components/i18n/locales/id/messages.json +3 -17
- package/src/components/i18n/locales/it/messages.json +3 -17
- package/src/components/i18n/locales/ja/messages.json +3 -17
- package/src/components/i18n/locales/ka/messages.json +3 -17
- package/src/components/i18n/locales/km/messages.json +3 -17
- package/src/components/i18n/locales/kn/messages.json +3 -17
- package/src/components/i18n/locales/ko/messages.json +3 -17
- package/src/components/i18n/locales/ku/messages.json +3 -17
- package/src/components/i18n/locales/lo/messages.json +3 -17
- package/src/components/i18n/locales/lt/messages.json +3 -17
- package/src/components/i18n/locales/lv/messages.json +3 -17
- package/src/components/i18n/locales/mk/messages.json +3 -17
- package/src/components/i18n/locales/ml/messages.json +3 -17
- package/src/components/i18n/locales/mn/messages.json +3 -17
- package/src/components/i18n/locales/mr/messages.json +3 -17
- package/src/components/i18n/locales/ms/messages.json +3 -17
- package/src/components/i18n/locales/my/messages.json +3 -17
- package/src/components/i18n/locales/ne/messages.json +3 -17
- package/src/components/i18n/locales/nl/messages.json +3 -17
- package/src/components/i18n/locales/no/messages.json +3 -17
- package/src/components/i18n/locales/pa/messages.json +3 -17
- package/src/components/i18n/locales/pl/messages.json +3 -17
- package/src/components/i18n/locales/ps/messages.json +3 -17
- package/src/components/i18n/locales/pt/messages.json +3 -17
- package/src/components/i18n/locales/ro/messages.json +3 -17
- package/src/components/i18n/locales/ru/messages.json +3 -17
- package/src/components/i18n/locales/sd/messages.json +3 -17
- package/src/components/i18n/locales/si/messages.json +3 -17
- package/src/components/i18n/locales/sk/messages.json +3 -17
- package/src/components/i18n/locales/sl/messages.json +3 -17
- package/src/components/i18n/locales/sq/messages.json +3 -17
- package/src/components/i18n/locales/sr/messages.json +3 -17
- package/src/components/i18n/locales/sv/messages.json +3 -17
- package/src/components/i18n/locales/sw/messages.json +3 -17
- package/src/components/i18n/locales/ta/messages.json +3 -17
- package/src/components/i18n/locales/te/messages.json +3 -17
- package/src/components/i18n/locales/th/messages.json +3 -17
- package/src/components/i18n/locales/tr/messages.json +3 -17
- package/src/components/i18n/locales/ug/messages.json +3 -17
- package/src/components/i18n/locales/uk/messages.json +3 -17
- package/src/components/i18n/locales/ur/messages.json +3 -17
- package/src/components/i18n/locales/vi/messages.json +3 -17
- package/src/components/i18n/locales/yi/messages.json +3 -17
- package/src/components/i18n/locales/zh/messages.json +3 -17
- package/src/components/icons/index.ts +30 -56
- package/src/components/inline-tools/inline-tool-code.ts +399 -0
- package/src/components/modules/api/blocks.ts +17 -0
- package/src/components/modules/api/tools.ts +0 -19
- package/src/components/modules/blockEvents/composers/blockSelectionKeys.ts +20 -3
- package/src/components/modules/blockEvents/composers/keyboardNavigation.ts +5 -5
- package/src/components/modules/blockManager/blockManager.ts +0 -11
- package/src/components/modules/blockManager/event-binder.ts +1 -12
- package/src/components/modules/paste/handlers/html-handler.ts +13 -10
- package/src/components/modules/paste/handlers/index.ts +1 -0
- package/src/components/modules/paste/index.ts +6 -0
- package/src/components/modules/themeManager.ts +1 -3
- package/src/components/modules/toolbar/blockSettings.ts +1 -0
- package/src/components/modules/toolbar/inline/index.ts +3 -0
- package/src/components/modules/uiControllers/controllers/keyboard.ts +0 -29
- package/src/components/modules/uiControllers/controllers/selection.ts +2 -14
- package/src/components/ui/toolbox.ts +1 -0
- package/src/components/utils/popover/popover-position.ts +2 -4
- package/src/markdown/index.ts +63 -0
- package/src/markdown/markdown-handler.ts +110 -0
- package/src/markdown/mdast-to-blocks.ts +418 -0
- package/src/markdown/phrasing-to-html.ts +60 -0
- package/src/markdown/types.ts +42 -0
- package/src/styles/main.css +0 -1139
- package/src/tools/callout/index.ts +24 -0
- package/src/tools/code/code-keyboard.ts +135 -0
- package/src/tools/code/constants.ts +73 -0
- package/src/tools/code/dom-builder.ts +146 -0
- package/src/tools/code/index.ts +322 -0
- package/src/tools/code/katex-loader.ts +50 -0
- package/src/tools/code/language-picker.ts +241 -0
- package/src/tools/divider/index.ts +9 -1
- package/src/tools/index.ts +4 -2
- package/src/tools/list/block-operations.ts +3 -1
- package/src/tools/list/depth-validator.ts +4 -7
- package/src/tools/list/dom-builder.ts +5 -3
- package/src/tools/list/index.ts +21 -3
- package/src/tools/list/list-helpers.ts +9 -2
- package/src/tools/list/list-keyboard.ts +56 -14
- package/src/tools/list/list-lifecycle.ts +3 -1
- package/src/tools/list/marker-calculator.ts +37 -0
- package/src/tools/list/ordered-marker-manager.ts +4 -2
- package/src/tools/table/index.ts +2 -2
- package/src/tools/table/table-cell-clipboard.ts +1 -1
- package/types/api/tools.d.ts +0 -18
- package/types/markdown.d.ts +2 -0
- package/types/tools/code.d.ts +11 -0
- package/src/tools/database/database-backend-sync.ts +0 -101
- package/src/tools/database/database-board-view.ts +0 -301
- package/src/tools/database/database-card-drag.ts +0 -306
- package/src/tools/database/database-card-drawer.ts +0 -546
- package/src/tools/database/database-column-controls.ts +0 -46
- package/src/tools/database/database-column-drag.ts +0 -262
- package/src/tools/database/database-keyboard.ts +0 -35
- package/src/tools/database/database-list-row-drag.ts +0 -245
- package/src/tools/database/database-list-view.ts +0 -333
- package/src/tools/database/database-model.ts +0 -246
- package/src/tools/database/database-property-type-popover.ts +0 -108
- package/src/tools/database/database-tab-bar.ts +0 -532
- package/src/tools/database/database-view-popover.ts +0 -109
- package/src/tools/database/database-view-renderer.ts +0 -25
- package/src/tools/database/index.ts +0 -948
- package/src/tools/database/types.ts +0 -144
- /package/dist/chunks/{am-CHDDMHkd.mjs → am-CS-JjQ0N.mjs} +0 -0
- /package/dist/chunks/{ar-DoqfNqut.mjs → ar-Dt4XzR5U.mjs} +0 -0
- /package/dist/chunks/{az-C34P9iEa.mjs → az-CaDTXby8.mjs} +0 -0
- /package/dist/chunks/{bg-jroXLY8Y.mjs → bg-D1pLog-R.mjs} +0 -0
- /package/dist/chunks/{bn-BRI-WqxY.mjs → bn-Db_ae60m.mjs} +0 -0
- /package/dist/chunks/{bs-CCGUpNHu.mjs → bs-DJTg1R9e.mjs} +0 -0
- /package/dist/chunks/{cs-D5qZOGuc.mjs → cs-_Gc21gSL.mjs} +0 -0
- /package/dist/chunks/{da-DrJ7W37K.mjs → da-xDB8uhCd.mjs} +0 -0
- /package/dist/chunks/{de-BW6-kp2c.mjs → de-B6gVjh1Z.mjs} +0 -0
- /package/dist/chunks/{el-C-Vc_Otu.mjs → el-ClbRSnOs.mjs} +0 -0
- /package/dist/chunks/{es-B6fI5K9i.mjs → es-CuY9rnLK.mjs} +0 -0
- /package/dist/chunks/{et-BhVlZ-Yz.mjs → et-BLu5lDVc.mjs} +0 -0
- /package/dist/chunks/{fa-D55Ijdqa.mjs → fa-P3gnrZH8.mjs} +0 -0
- /package/dist/chunks/{fi-jNLjhKUQ.mjs → fi-B8PVHLjq.mjs} +0 -0
- /package/dist/chunks/{fil-DYd0T5aX.mjs → fil-B9JII5iF.mjs} +0 -0
- /package/dist/chunks/{fr-yxy5xWw_.mjs → fr-BWLDZdcc.mjs} +0 -0
- /package/dist/chunks/{gu-CcY_LJe7.mjs → gu-BH3R_s4c.mjs} +0 -0
- /package/dist/chunks/{he-DL9s7wNw.mjs → he-CCmeCVR_.mjs} +0 -0
- /package/dist/chunks/{hi-C8eGXgw5.mjs → hi-BBav00DN.mjs} +0 -0
- /package/dist/chunks/{hr-DLpybOhU.mjs → hr-B5ZX0r9G.mjs} +0 -0
- /package/dist/chunks/{hu-BkT0gT00.mjs → hu-1jgDa3YU.mjs} +0 -0
- /package/dist/chunks/{hy-CVFDCp2S.mjs → hy-LX4Kp2PE.mjs} +0 -0
- /package/dist/chunks/{id-0P4W9Az0.mjs → id-CcG40D1H.mjs} +0 -0
- /package/dist/chunks/{it-mLY6_uoW.mjs → it-Cb8_K72W.mjs} +0 -0
- /package/dist/chunks/{ja-7RkeRNWG.mjs → ja-ipCH91mv.mjs} +0 -0
- /package/dist/chunks/{ka-C7Lx-Qsh.mjs → ka-BRvREIgq.mjs} +0 -0
- /package/dist/chunks/{km-Q8udaraH.mjs → km-BJwVw7Fg.mjs} +0 -0
- /package/dist/chunks/{kn-BiETM-iq.mjs → kn-BPgUazCC.mjs} +0 -0
- /package/dist/chunks/{ko-tiB80pF1.mjs → ko-CQLzxe7k.mjs} +0 -0
- /package/dist/chunks/{ku-CY-OABkR.mjs → ku-BHhHu8Iz.mjs} +0 -0
- /package/dist/chunks/{lo-CTBhEnyk.mjs → lo-DsTgYblY.mjs} +0 -0
- /package/dist/chunks/{lt-BHKHEtqK.mjs → lt-CDzHJm71.mjs} +0 -0
- /package/dist/chunks/{lv-DWxgtfUg.mjs → lv-MLLIAnIX.mjs} +0 -0
- /package/dist/chunks/{mk-BjookGdx.mjs → mk-DQdmUquZ.mjs} +0 -0
- /package/dist/chunks/{ml-L-NnZcp9.mjs → ml-DqehZnra.mjs} +0 -0
- /package/dist/chunks/{mn-OMWi7Hl_.mjs → mn-4cFkKFjW.mjs} +0 -0
- /package/dist/chunks/{mr-B6JPzITo.mjs → mr-DWiztOP4.mjs} +0 -0
- /package/dist/chunks/{ms-CG3S-sPB.mjs → ms-BSz-iSnc.mjs} +0 -0
- /package/dist/chunks/{my-BLAmGfhT.mjs → my-DbtbM1MW.mjs} +0 -0
- /package/dist/chunks/{native-BPcABu9z.mjs → native-CzYG0YgY.mjs} +0 -0
- /package/dist/chunks/{ne-D1JHLfYw.mjs → ne-CqALWw_f.mjs} +0 -0
- /package/dist/chunks/{nl-Ca7Q8FnY.mjs → nl-D_ra6RvH.mjs} +0 -0
- /package/dist/chunks/{no-Coxcohcz.mjs → no-Cg_kz_jl.mjs} +0 -0
- /package/dist/chunks/{pa-CCaXqpaI.mjs → pa-NLAsNqwY.mjs} +0 -0
- /package/dist/chunks/{pl-Cl_fAZ84.mjs → pl-NHKp4YDg.mjs} +0 -0
- /package/dist/chunks/{ps-WD5qGAWy.mjs → ps-D1zEqNeg.mjs} +0 -0
- /package/dist/chunks/{pt-C4zvLfvq.mjs → pt-DBtqbUEB.mjs} +0 -0
- /package/dist/chunks/{ro-DbefHcmM.mjs → ro-lqr63ai5.mjs} +0 -0
- /package/dist/chunks/{ru-uU1J14jd.mjs → ru-BycNnDyN.mjs} +0 -0
- /package/dist/chunks/{sd-DKu368Ip.mjs → sd-DpHpIN9Z.mjs} +0 -0
- /package/dist/chunks/{si-BsJCiPkZ.mjs → si-BwiwaC7N.mjs} +0 -0
- /package/dist/chunks/{sk-CD-a3SN6.mjs → sk-CqRHT2Gp.mjs} +0 -0
- /package/dist/chunks/{sl-CXhrPJe_.mjs → sl-DA348uQ_.mjs} +0 -0
- /package/dist/chunks/{sq-CTctCoFQ.mjs → sq-D7JNgve1.mjs} +0 -0
- /package/dist/chunks/{sr-BZkhBwXj.mjs → sr-D8RK6Kwp.mjs} +0 -0
- /package/dist/chunks/{sv-NmRZb_xi.mjs → sv-dwgT67ZG.mjs} +0 -0
- /package/dist/chunks/{sw-Be5ik3H6.mjs → sw-ZRRJnkem.mjs} +0 -0
- /package/dist/chunks/{ta-DsXh6neL.mjs → ta-5x4L5Krl.mjs} +0 -0
- /package/dist/chunks/{te-CwpCbM8M.mjs → te-BZpEimwA.mjs} +0 -0
- /package/dist/chunks/{th-CcZ15OLk.mjs → th-Bhr-33kv.mjs} +0 -0
- /package/dist/chunks/{tr-q3bTgvhW.mjs → tr-6tSNKGNB.mjs} +0 -0
- /package/dist/chunks/{tw-DmW6-pCY.mjs → tw-CqxBf-1Y.mjs} +0 -0
- /package/dist/chunks/{ug-919EhLsL.mjs → ug-_e-jvr2b.mjs} +0 -0
- /package/dist/chunks/{uk-aNMEzd0Y.mjs → uk-DooSc2Ja.mjs} +0 -0
- /package/dist/chunks/{ur-BwQI77sh.mjs → ur-rb-krkIO.mjs} +0 -0
- /package/dist/chunks/{vi-Dxq806-F.mjs → vi-CQkLn2AQ.mjs} +0 -0
- /package/dist/chunks/{zh-BcHuy1Ti.mjs → zh-CXQ40Q2_.mjs} +0 -0
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
import type { I18n } from '../../../types';
|
|
2
|
-
import type { DatabaseRow, PropertyDefinition, PropertyValue, SelectOption } from './types';
|
|
3
|
-
import type { DatabaseViewRenderer } from './database-view-renderer';
|
|
4
|
-
|
|
5
|
-
interface DatabaseListViewOptions {
|
|
6
|
-
readOnly: boolean;
|
|
7
|
-
i18n: I18n;
|
|
8
|
-
rows: DatabaseRow[];
|
|
9
|
-
titlePropertyId: string;
|
|
10
|
-
schema: PropertyDefinition[];
|
|
11
|
-
visiblePropertyIds: string[];
|
|
12
|
-
options?: SelectOption[];
|
|
13
|
-
getRows?: (optionId: string) => DatabaseRow[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* DOM rendering layer for the flat list view.
|
|
18
|
-
* Renders rows as a flat list with optional property badges.
|
|
19
|
-
* All interactive elements use data-blok-database-* attributes for test selectors and event delegation.
|
|
20
|
-
*/
|
|
21
|
-
export class DatabaseListView implements DatabaseViewRenderer {
|
|
22
|
-
private readonly readOnly: boolean;
|
|
23
|
-
private readonly i18n: I18n;
|
|
24
|
-
private readonly rows: DatabaseRow[];
|
|
25
|
-
private readonly titlePropertyId: string;
|
|
26
|
-
private readonly schema: PropertyDefinition[];
|
|
27
|
-
private readonly visiblePropertyIds: string[];
|
|
28
|
-
private readonly groupOptions: SelectOption[] | undefined;
|
|
29
|
-
private readonly getGroupRows: ((optionId: string) => DatabaseRow[]) | undefined;
|
|
30
|
-
|
|
31
|
-
constructor({ readOnly, i18n, rows, titlePropertyId, schema, visiblePropertyIds, options, getRows }: DatabaseListViewOptions) {
|
|
32
|
-
this.readOnly = readOnly;
|
|
33
|
-
this.i18n = i18n;
|
|
34
|
-
this.rows = rows;
|
|
35
|
-
this.titlePropertyId = titlePropertyId;
|
|
36
|
-
this.schema = schema;
|
|
37
|
-
this.visiblePropertyIds = visiblePropertyIds;
|
|
38
|
-
this.groupOptions = options;
|
|
39
|
-
this.getGroupRows = getRows;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Creates the full list DOM from row data.
|
|
44
|
-
* When options are provided, renders grouped sections; otherwise renders a flat list.
|
|
45
|
-
*/
|
|
46
|
-
createView(): HTMLDivElement {
|
|
47
|
-
const wrapper = document.createElement('div');
|
|
48
|
-
|
|
49
|
-
wrapper.setAttribute('data-blok-database-list', '');
|
|
50
|
-
|
|
51
|
-
if (this.groupOptions !== undefined && this.groupOptions.length > 0 && this.getGroupRows !== undefined) {
|
|
52
|
-
for (const option of this.groupOptions) {
|
|
53
|
-
const rows = this.getGroupRows(option.id);
|
|
54
|
-
const groupEl = this.createGroupElement(option, rows);
|
|
55
|
-
|
|
56
|
-
wrapper.appendChild(groupEl);
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
wrapper.setAttribute('role', 'list');
|
|
60
|
-
wrapper.setAttribute('aria-label', 'List view');
|
|
61
|
-
|
|
62
|
-
for (const row of this.rows) {
|
|
63
|
-
const rowEl = this.createRowElement(row);
|
|
64
|
-
|
|
65
|
-
wrapper.appendChild(rowEl);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (!this.readOnly) {
|
|
69
|
-
const addRowBtn = this.createAddRowButton();
|
|
70
|
-
|
|
71
|
-
wrapper.appendChild(addRowBtn);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return wrapper;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Creates a collapsible group element for a select option.
|
|
80
|
-
*/
|
|
81
|
-
private createGroupElement(option: SelectOption, rows: DatabaseRow[]): HTMLDivElement {
|
|
82
|
-
const groupEl = document.createElement('div');
|
|
83
|
-
|
|
84
|
-
groupEl.setAttribute('data-blok-database-list-group', '');
|
|
85
|
-
groupEl.setAttribute('data-option-id', option.id);
|
|
86
|
-
|
|
87
|
-
// Header
|
|
88
|
-
const header = document.createElement('div');
|
|
89
|
-
|
|
90
|
-
header.setAttribute('data-blok-database-list-group-header', '');
|
|
91
|
-
|
|
92
|
-
const toggle = document.createElement('span');
|
|
93
|
-
|
|
94
|
-
toggle.setAttribute('data-blok-database-list-group-toggle', '');
|
|
95
|
-
toggle.textContent = '▼';
|
|
96
|
-
|
|
97
|
-
const dot = document.createElement('span');
|
|
98
|
-
|
|
99
|
-
dot.setAttribute('data-blok-database-list-group-dot', '');
|
|
100
|
-
|
|
101
|
-
if (option.color !== undefined) {
|
|
102
|
-
dot.style.backgroundColor = `var(--blok-color-${option.color}-text)`;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const title = document.createElement('span');
|
|
106
|
-
|
|
107
|
-
title.setAttribute('data-blok-database-list-group-title', '');
|
|
108
|
-
title.textContent = option.label;
|
|
109
|
-
|
|
110
|
-
const count = document.createElement('span');
|
|
111
|
-
|
|
112
|
-
count.setAttribute('data-blok-database-list-group-count', '');
|
|
113
|
-
count.textContent = String(rows.length);
|
|
114
|
-
|
|
115
|
-
header.appendChild(toggle);
|
|
116
|
-
header.appendChild(dot);
|
|
117
|
-
header.appendChild(title);
|
|
118
|
-
header.appendChild(count);
|
|
119
|
-
|
|
120
|
-
// Rows container
|
|
121
|
-
const rowsContainer = document.createElement('div');
|
|
122
|
-
|
|
123
|
-
rowsContainer.setAttribute('data-blok-database-list-rows', '');
|
|
124
|
-
rowsContainer.setAttribute('role', 'list');
|
|
125
|
-
|
|
126
|
-
for (const row of rows) {
|
|
127
|
-
const rowEl = this.createRowElement(row);
|
|
128
|
-
|
|
129
|
-
rowsContainer.appendChild(rowEl);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Add-row button
|
|
133
|
-
const addRowBtn = this.readOnly ? null : this.createAddRowButton(option.id);
|
|
134
|
-
|
|
135
|
-
// Collapse/expand toggle
|
|
136
|
-
header.addEventListener('click', () => {
|
|
137
|
-
const collapsed = rowsContainer.style.display === 'none';
|
|
138
|
-
|
|
139
|
-
rowsContainer.style.display = collapsed ? '' : 'none';
|
|
140
|
-
toggle.textContent = collapsed ? '▼' : '▶';
|
|
141
|
-
|
|
142
|
-
if (addRowBtn !== null) {
|
|
143
|
-
addRowBtn.style.display = collapsed ? '' : 'none';
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
groupEl.appendChild(header);
|
|
148
|
-
groupEl.appendChild(rowsContainer);
|
|
149
|
-
|
|
150
|
-
if (addRowBtn !== null) {
|
|
151
|
-
groupEl.appendChild(addRowBtn);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return groupEl;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Creates a row element and inserts it before the add-row button (if present), else appends.
|
|
159
|
-
*/
|
|
160
|
-
appendRow(container: HTMLElement, row: DatabaseRow): void {
|
|
161
|
-
const rowEl = this.createRowElement(row);
|
|
162
|
-
const addRowBtn = container.querySelector('[data-blok-database-add-row]');
|
|
163
|
-
|
|
164
|
-
if (addRowBtn !== null) {
|
|
165
|
-
container.insertBefore(rowEl, addRowBtn);
|
|
166
|
-
} else {
|
|
167
|
-
container.appendChild(rowEl);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Removes a row element from the wrapper by its data-row-id.
|
|
173
|
-
*/
|
|
174
|
-
removeRow(wrapper: HTMLElement, rowId: string): void {
|
|
175
|
-
const rowEl = wrapper.querySelector(`[data-row-id="${rowId}"]`);
|
|
176
|
-
|
|
177
|
-
rowEl?.remove();
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Updates the visible title of a row element found by its data-row-id.
|
|
182
|
-
*/
|
|
183
|
-
updateRowTitle(wrapper: HTMLElement, rowId: string, title: string): void {
|
|
184
|
-
const rowEl = wrapper.querySelector(`[data-row-id="${rowId}"]`);
|
|
185
|
-
const titleEl = rowEl?.querySelector('[data-blok-database-list-row-title]');
|
|
186
|
-
|
|
187
|
-
if (titleEl === null || titleEl === undefined) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (title) {
|
|
192
|
-
titleEl.textContent = title;
|
|
193
|
-
titleEl.removeAttribute('data-placeholder');
|
|
194
|
-
} else {
|
|
195
|
-
titleEl.textContent = this.i18n.t('tools.database.rowTitlePlaceholder');
|
|
196
|
-
titleEl.setAttribute('data-placeholder', '');
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Creates a single row element.
|
|
202
|
-
*/
|
|
203
|
-
private createRowElement(row: DatabaseRow): HTMLDivElement {
|
|
204
|
-
const rowEl = document.createElement('div');
|
|
205
|
-
const title = (row.properties[this.titlePropertyId] as string) ?? '';
|
|
206
|
-
|
|
207
|
-
rowEl.setAttribute('data-blok-database-list-row', '');
|
|
208
|
-
rowEl.setAttribute('data-row-id', row.id);
|
|
209
|
-
rowEl.setAttribute('role', 'listitem');
|
|
210
|
-
|
|
211
|
-
const titleEl = document.createElement('div');
|
|
212
|
-
|
|
213
|
-
titleEl.setAttribute('data-blok-database-list-row-title', '');
|
|
214
|
-
|
|
215
|
-
if (title) {
|
|
216
|
-
titleEl.textContent = title;
|
|
217
|
-
} else {
|
|
218
|
-
titleEl.textContent = this.i18n.t('tools.database.rowTitlePlaceholder');
|
|
219
|
-
titleEl.setAttribute('data-placeholder', '');
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
rowEl.appendChild(titleEl);
|
|
223
|
-
|
|
224
|
-
const propertiesEl = this.createPropertiesElement(row);
|
|
225
|
-
|
|
226
|
-
rowEl.appendChild(propertiesEl);
|
|
227
|
-
|
|
228
|
-
return rowEl;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Creates the properties container with badges, open button, and delete button.
|
|
233
|
-
*/
|
|
234
|
-
private createPropertiesElement(row: DatabaseRow): HTMLDivElement {
|
|
235
|
-
const propertiesEl = document.createElement('div');
|
|
236
|
-
|
|
237
|
-
propertiesEl.setAttribute('data-blok-database-list-row-properties', '');
|
|
238
|
-
|
|
239
|
-
for (const propId of this.visiblePropertyIds) {
|
|
240
|
-
const propDef = this.schema.find(p => p.id === propId);
|
|
241
|
-
|
|
242
|
-
if (propDef === undefined) {
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const value = row.properties[propId];
|
|
247
|
-
const badge = this.createPropertyBadge(propDef, value);
|
|
248
|
-
|
|
249
|
-
if (badge !== null) {
|
|
250
|
-
propertiesEl.appendChild(badge);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
const openBtn = document.createElement('button');
|
|
255
|
-
|
|
256
|
-
openBtn.setAttribute('data-blok-database-list-row-open', '');
|
|
257
|
-
openBtn.setAttribute('aria-label', this.i18n.t('tools.database.openRow'));
|
|
258
|
-
propertiesEl.appendChild(openBtn);
|
|
259
|
-
|
|
260
|
-
if (!this.readOnly) {
|
|
261
|
-
const deleteBtn = document.createElement('button');
|
|
262
|
-
|
|
263
|
-
deleteBtn.setAttribute('data-blok-database-delete-row', '');
|
|
264
|
-
deleteBtn.setAttribute('data-row-id', row.id);
|
|
265
|
-
deleteBtn.setAttribute('aria-label', this.i18n.t('tools.database.deleteRow'));
|
|
266
|
-
deleteBtn.textContent = '\u00d7';
|
|
267
|
-
propertiesEl.appendChild(deleteBtn);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return propertiesEl;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Creates a property badge span for a given property definition and value.
|
|
275
|
-
* Returns null if the value is undefined/null or if the select option is not found.
|
|
276
|
-
*/
|
|
277
|
-
private createPropertyBadge(propDef: PropertyDefinition, value: PropertyValue): HTMLSpanElement | null {
|
|
278
|
-
if (value === undefined || value === null) {
|
|
279
|
-
return null;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const badge = document.createElement('span');
|
|
283
|
-
|
|
284
|
-
badge.setAttribute('data-blok-database-list-row-property', '');
|
|
285
|
-
badge.setAttribute('data-property-id', propDef.id);
|
|
286
|
-
|
|
287
|
-
if (propDef.type === 'select') {
|
|
288
|
-
const options = propDef.config?.options ?? [];
|
|
289
|
-
const option = options.find(o => o.id === value);
|
|
290
|
-
|
|
291
|
-
if (option === undefined) {
|
|
292
|
-
return null;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
badge.textContent = option.label;
|
|
296
|
-
|
|
297
|
-
if (option.color !== undefined) {
|
|
298
|
-
badge.style.backgroundColor = `var(--blok-color-${option.color}-bg)`;
|
|
299
|
-
badge.style.color = `var(--blok-color-${option.color}-text)`;
|
|
300
|
-
}
|
|
301
|
-
} else if (propDef.type === 'checkbox') {
|
|
302
|
-
const checkbox = document.createElement('input');
|
|
303
|
-
|
|
304
|
-
checkbox.type = 'checkbox';
|
|
305
|
-
checkbox.checked = value === true;
|
|
306
|
-
badge.appendChild(checkbox);
|
|
307
|
-
} else if (typeof value === 'string' || typeof value === 'number') {
|
|
308
|
-
badge.textContent = String(value);
|
|
309
|
-
} else {
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
return badge;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Creates the "+ New" add-row button.
|
|
318
|
-
* When optionId is provided, sets data-option-id on the button.
|
|
319
|
-
*/
|
|
320
|
-
private createAddRowButton(optionId?: string): HTMLButtonElement {
|
|
321
|
-
const addRowBtn = document.createElement('button');
|
|
322
|
-
|
|
323
|
-
addRowBtn.setAttribute('data-blok-database-add-row', '');
|
|
324
|
-
addRowBtn.setAttribute('aria-label', this.i18n.t('tools.database.addRow'));
|
|
325
|
-
addRowBtn.textContent = '+ ' + this.i18n.t('tools.database.newRow');
|
|
326
|
-
|
|
327
|
-
if (optionId !== undefined) {
|
|
328
|
-
addRowBtn.setAttribute('data-option-id', optionId);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return addRowBtn;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import { generateKeyBetween } from 'fractional-indexing';
|
|
2
|
-
import { nanoid } from 'nanoid';
|
|
3
|
-
import type {
|
|
4
|
-
DatabaseData,
|
|
5
|
-
DatabaseRow,
|
|
6
|
-
DatabaseViewConfig,
|
|
7
|
-
PropertyConfig,
|
|
8
|
-
PropertyDefinition,
|
|
9
|
-
PropertyType,
|
|
10
|
-
PropertyValue,
|
|
11
|
-
SelectOption,
|
|
12
|
-
ViewType,
|
|
13
|
-
} from './types';
|
|
14
|
-
|
|
15
|
-
export class DatabaseModel {
|
|
16
|
-
private schema: PropertyDefinition[];
|
|
17
|
-
private rows: Record<string, DatabaseRow>;
|
|
18
|
-
private views: DatabaseViewConfig[];
|
|
19
|
-
|
|
20
|
-
constructor(data?: Partial<DatabaseData>) {
|
|
21
|
-
if (data?.schema !== undefined && data.schema.length > 0) {
|
|
22
|
-
this.schema = data.schema.map((p) => ({ ...p }));
|
|
23
|
-
} else {
|
|
24
|
-
this.schema = DatabaseModel.createDefaultSchema();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
this.rows = {};
|
|
28
|
-
if (data?.rows !== undefined) {
|
|
29
|
-
for (const [id, row] of Object.entries(data.rows)) {
|
|
30
|
-
this.rows[id] = { ...row, properties: { ...row.properties } };
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (data?.views !== undefined && data.views.length > 0) {
|
|
35
|
-
this.views = data.views.map((v) => ({ ...v, sorts: [...v.sorts], filters: [...v.filters], visibleProperties: [...v.visibleProperties] }));
|
|
36
|
-
} else {
|
|
37
|
-
const statusProp = this.schema.find((p) => p.type === 'select');
|
|
38
|
-
this.views = [DatabaseModel.createDefaultView(statusProp?.id)];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// ─── Schema ───
|
|
43
|
-
|
|
44
|
-
getSchema(): PropertyDefinition[] {
|
|
45
|
-
return [...this.schema];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
getProperty(propertyId: string): PropertyDefinition | undefined {
|
|
49
|
-
return this.schema.find((p) => p.id === propertyId);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
addProperty(name: string, type: PropertyType, config?: PropertyConfig): PropertyDefinition {
|
|
53
|
-
const lastPosition = this.schema.length > 0 ? this.schema[this.schema.length - 1].position : null;
|
|
54
|
-
const prop: PropertyDefinition = {
|
|
55
|
-
id: nanoid(),
|
|
56
|
-
name,
|
|
57
|
-
type,
|
|
58
|
-
position: generateKeyBetween(lastPosition, null),
|
|
59
|
-
...(config !== undefined ? { config } : {}),
|
|
60
|
-
};
|
|
61
|
-
this.schema.push(prop);
|
|
62
|
-
return prop;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
updateProperty(propertyId: string, changes: Partial<Pick<PropertyDefinition, 'name' | 'config'>>): void {
|
|
66
|
-
const prop = this.schema.find((p) => p.id === propertyId);
|
|
67
|
-
if (prop === undefined) return;
|
|
68
|
-
if (changes.name !== undefined) prop.name = changes.name;
|
|
69
|
-
if (changes.config !== undefined) prop.config = changes.config;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
deleteProperty(propertyId: string): void {
|
|
73
|
-
this.schema = this.schema.filter((p) => p.id !== propertyId);
|
|
74
|
-
for (const row of Object.values(this.rows)) {
|
|
75
|
-
const { [propertyId]: _, ...rest } = row.properties;
|
|
76
|
-
row.properties = rest;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// ─── Rows ───
|
|
81
|
-
|
|
82
|
-
getOrderedRows(): DatabaseRow[] {
|
|
83
|
-
return Object.values(this.rows).sort((a, b) => (a.position < b.position ? -1 : 1));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
getRow(rowId: string): DatabaseRow | undefined {
|
|
87
|
-
return this.rows[rowId];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
addRow(properties: Record<string, PropertyValue> = {}): DatabaseRow {
|
|
91
|
-
const orderedRows = this.getOrderedRows();
|
|
92
|
-
const lastPosition = orderedRows.length > 0 ? orderedRows[orderedRows.length - 1].position : null;
|
|
93
|
-
const row: DatabaseRow = {
|
|
94
|
-
id: nanoid(),
|
|
95
|
-
position: generateKeyBetween(lastPosition, null),
|
|
96
|
-
properties: { ...properties },
|
|
97
|
-
};
|
|
98
|
-
this.rows[row.id] = row;
|
|
99
|
-
return row;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
updateRow(rowId: string, properties: Record<string, PropertyValue>): void {
|
|
103
|
-
const row = this.rows[rowId];
|
|
104
|
-
if (row === undefined) return;
|
|
105
|
-
Object.assign(row.properties, properties);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
moveRow(rowId: string, position: string): void {
|
|
109
|
-
const row = this.rows[rowId];
|
|
110
|
-
if (row === undefined) return;
|
|
111
|
-
row.position = position;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
deleteRow(rowId: string): void {
|
|
115
|
-
const { [rowId]: _, ...rest } = this.rows;
|
|
116
|
-
this.rows = rest;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// ─── View-oriented queries ───
|
|
120
|
-
|
|
121
|
-
getRowsGroupedBy(propertyId: string): Map<string, DatabaseRow[]> {
|
|
122
|
-
const groups = new Map<string, DatabaseRow[]>();
|
|
123
|
-
const ordered = this.getOrderedRows();
|
|
124
|
-
for (const row of ordered) {
|
|
125
|
-
const rawValue = row.properties[propertyId];
|
|
126
|
-
const key = this.toGroupKey(rawValue);
|
|
127
|
-
const existing = groups.get(key);
|
|
128
|
-
if (existing !== undefined) {
|
|
129
|
-
existing.push(row);
|
|
130
|
-
} else {
|
|
131
|
-
groups.set(key, [row]);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return groups;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
getSelectOptions(propertyId: string): SelectOption[] {
|
|
138
|
-
const prop = this.getProperty(propertyId);
|
|
139
|
-
if (prop === undefined || (prop.type !== 'select' && prop.type !== 'multiSelect')) return [];
|
|
140
|
-
const options = prop.config?.options ?? [];
|
|
141
|
-
return [...options].sort((a, b) => (a.position < b.position ? -1 : 1));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// ─── Views ───
|
|
145
|
-
|
|
146
|
-
getViews(): DatabaseViewConfig[] {
|
|
147
|
-
return [...this.views];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
getView(viewId: string): DatabaseViewConfig | undefined {
|
|
151
|
-
return this.views.find((v) => v.id === viewId);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
addView(name: string, type: ViewType, config: Partial<Pick<DatabaseViewConfig, 'groupBy' | 'sorts' | 'filters' | 'visibleProperties'>> = {}): DatabaseViewConfig {
|
|
155
|
-
const sorted = [...this.views].sort((a, b) => (a.position < b.position ? -1 : 1));
|
|
156
|
-
const lastPosition = sorted.length > 0 ? sorted[sorted.length - 1].position : null;
|
|
157
|
-
const view: DatabaseViewConfig = {
|
|
158
|
-
id: nanoid(),
|
|
159
|
-
name,
|
|
160
|
-
type,
|
|
161
|
-
position: generateKeyBetween(lastPosition, null),
|
|
162
|
-
groupBy: config.groupBy,
|
|
163
|
-
sorts: config.sorts ?? [],
|
|
164
|
-
filters: config.filters ?? [],
|
|
165
|
-
visibleProperties: config.visibleProperties ?? [],
|
|
166
|
-
};
|
|
167
|
-
this.views.push(view);
|
|
168
|
-
return view;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
updateView(viewId: string, changes: Partial<Pick<DatabaseViewConfig, 'name' | 'type' | 'position' | 'groupBy' | 'sorts' | 'filters' | 'visibleProperties'>>): void {
|
|
172
|
-
const view = this.views.find((v) => v.id === viewId);
|
|
173
|
-
if (view === undefined) return;
|
|
174
|
-
Object.assign(view, changes);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
deleteView(viewId: string): void {
|
|
178
|
-
this.views = this.views.filter((v) => v.id !== viewId);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// ─── Hydrate ───
|
|
182
|
-
|
|
183
|
-
hydrate(data: { schema: PropertyDefinition[]; rows: Record<string, DatabaseRow>; views: DatabaseViewConfig[] }): void {
|
|
184
|
-
this.schema = data.schema.map((p) => ({ ...p }));
|
|
185
|
-
this.rows = {};
|
|
186
|
-
for (const [id, row] of Object.entries(data.rows)) {
|
|
187
|
-
this.rows[id] = { ...row, properties: { ...row.properties } };
|
|
188
|
-
}
|
|
189
|
-
this.views = data.views.map((v) => ({ ...v, sorts: [...v.sorts], filters: [...v.filters], visibleProperties: [...v.visibleProperties] }));
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// ─── Snapshot ───
|
|
193
|
-
|
|
194
|
-
snapshot(): DatabaseData {
|
|
195
|
-
const rowsCopy: Record<string, DatabaseRow> = {};
|
|
196
|
-
for (const [id, row] of Object.entries(this.rows)) {
|
|
197
|
-
rowsCopy[id] = {
|
|
198
|
-
id: row.id,
|
|
199
|
-
position: row.position,
|
|
200
|
-
properties: JSON.parse(JSON.stringify(row.properties)) as Record<string, PropertyValue>,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
return {
|
|
204
|
-
schema: JSON.parse(JSON.stringify(this.schema)) as PropertyDefinition[],
|
|
205
|
-
rows: rowsCopy,
|
|
206
|
-
views: JSON.parse(JSON.stringify(this.views)) as DatabaseViewConfig[],
|
|
207
|
-
activeViewId: this.views.length > 0 ? this.views[0].id : '',
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// ─── Static helpers ───
|
|
212
|
-
|
|
213
|
-
private toGroupKey(value: PropertyValue | undefined): string {
|
|
214
|
-
if (value === undefined || value === null) return '';
|
|
215
|
-
if (typeof value === 'string') return value;
|
|
216
|
-
if (typeof value === 'boolean' || typeof value === 'number') return String(value);
|
|
217
|
-
return '';
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
static positionBetween(after: string | null, before: string | null): string {
|
|
221
|
-
return generateKeyBetween(after, before);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
private static createDefaultSchema(): PropertyDefinition[] {
|
|
225
|
-
return [
|
|
226
|
-
{ id: nanoid(), name: 'Title', type: 'title', position: 'a0' },
|
|
227
|
-
{
|
|
228
|
-
id: nanoid(), name: 'Status', type: 'select', position: 'a1',
|
|
229
|
-
config: {
|
|
230
|
-
options: [
|
|
231
|
-
{ id: nanoid(), label: 'Not started', color: 'gray', position: 'a0' },
|
|
232
|
-
{ id: nanoid(), label: 'In progress', color: 'blue', position: 'a1' },
|
|
233
|
-
{ id: nanoid(), label: 'Done', color: 'green', position: 'a2' },
|
|
234
|
-
],
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
];
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
private static createDefaultView(groupByPropertyId?: string): DatabaseViewConfig {
|
|
241
|
-
return {
|
|
242
|
-
id: nanoid(), name: 'Board', type: 'board', position: 'a0',
|
|
243
|
-
groupBy: groupByPropertyId, sorts: [], filters: [], visibleProperties: [],
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IconText,
|
|
3
|
-
IconHash,
|
|
4
|
-
IconList,
|
|
5
|
-
IconListBulleted,
|
|
6
|
-
IconCalendar,
|
|
7
|
-
IconListChecklist,
|
|
8
|
-
IconGlobe,
|
|
9
|
-
} from '../../components/icons';
|
|
10
|
-
import type { PropertyType } from './types';
|
|
11
|
-
|
|
12
|
-
interface PropertyTypeOption {
|
|
13
|
-
type: PropertyType;
|
|
14
|
-
icon: string;
|
|
15
|
-
label: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const PROPERTY_TYPES: PropertyTypeOption[] = [
|
|
19
|
-
{ type: 'text', icon: IconText, label: 'Text' },
|
|
20
|
-
{ type: 'number', icon: IconHash, label: 'Number' },
|
|
21
|
-
{ type: 'select', icon: IconList, label: 'Select' },
|
|
22
|
-
{ type: 'multiSelect', icon: IconListBulleted, label: 'Multi-select' },
|
|
23
|
-
{ type: 'date', icon: IconCalendar, label: 'Date' },
|
|
24
|
-
{ type: 'checkbox', icon: IconListChecklist, label: 'Checkbox' },
|
|
25
|
-
{ type: 'url', icon: IconGlobe, label: 'URL' },
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
export interface PropertyTypePopoverOptions {
|
|
29
|
-
onSelect: (type: PropertyType) => void;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export class DatabasePropertyTypePopover {
|
|
33
|
-
private readonly onSelect: (type: PropertyType) => void;
|
|
34
|
-
private popoverEl: HTMLElement | null = null;
|
|
35
|
-
private boundOutsideClick: ((e: MouseEvent) => void) | null = null;
|
|
36
|
-
|
|
37
|
-
constructor(options: PropertyTypePopoverOptions) {
|
|
38
|
-
this.onSelect = options.onSelect;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
open(anchor: HTMLElement): void {
|
|
42
|
-
this.close();
|
|
43
|
-
|
|
44
|
-
const popover = document.createElement('div');
|
|
45
|
-
popover.setAttribute('data-blok-popover', '');
|
|
46
|
-
popover.setAttribute('data-blok-popover-opened', '');
|
|
47
|
-
popover.setAttribute('data-blok-database-property-type-popover', '');
|
|
48
|
-
popover.style.position = 'fixed';
|
|
49
|
-
popover.style.zIndex = '1000';
|
|
50
|
-
|
|
51
|
-
const rect = anchor.getBoundingClientRect();
|
|
52
|
-
popover.style.top = `${rect.bottom + 4}px`;
|
|
53
|
-
popover.style.left = `${rect.left}px`;
|
|
54
|
-
|
|
55
|
-
const heading = document.createElement('div');
|
|
56
|
-
heading.setAttribute('data-blok-database-property-type-heading', '');
|
|
57
|
-
heading.textContent = 'Property type';
|
|
58
|
-
popover.appendChild(heading);
|
|
59
|
-
|
|
60
|
-
for (const option of PROPERTY_TYPES) {
|
|
61
|
-
const item = document.createElement('div');
|
|
62
|
-
item.setAttribute('data-blok-database-property-type-option', option.type);
|
|
63
|
-
|
|
64
|
-
const iconEl = document.createElement('div');
|
|
65
|
-
iconEl.setAttribute('data-blok-database-property-type-option-icon', '');
|
|
66
|
-
iconEl.innerHTML = option.icon;
|
|
67
|
-
item.appendChild(iconEl);
|
|
68
|
-
|
|
69
|
-
const label = document.createElement('span');
|
|
70
|
-
label.textContent = option.label;
|
|
71
|
-
item.appendChild(label);
|
|
72
|
-
|
|
73
|
-
item.addEventListener('click', () => {
|
|
74
|
-
this.onSelect(option.type);
|
|
75
|
-
this.close();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
popover.appendChild(item);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
document.body.appendChild(popover);
|
|
82
|
-
this.popoverEl = popover;
|
|
83
|
-
|
|
84
|
-
this.boundOutsideClick = (e: MouseEvent): void => {
|
|
85
|
-
const target = e.target as HTMLElement;
|
|
86
|
-
if (!popover.contains(target) && !anchor.contains(target)) {
|
|
87
|
-
this.close();
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
document.addEventListener('mousedown', this.boundOutsideClick);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
close(): void {
|
|
95
|
-
if (this.popoverEl !== null) {
|
|
96
|
-
this.popoverEl.remove();
|
|
97
|
-
this.popoverEl = null;
|
|
98
|
-
}
|
|
99
|
-
if (this.boundOutsideClick !== null) {
|
|
100
|
-
document.removeEventListener('mousedown', this.boundOutsideClick);
|
|
101
|
-
this.boundOutsideClick = null;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
destroy(): void {
|
|
106
|
-
this.close();
|
|
107
|
-
}
|
|
108
|
-
}
|