@jackuait/blok 0.6.0-beta.9 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blok.mjs +2 -2
- package/dist/chunks/{blok-Bn6Q_o8h.mjs → blok-BAh1rvUC.mjs} +3410 -2927
- package/dist/chunks/i18next-B47TKgbU.mjs +1303 -0
- package/dist/chunks/{i18next-loader-DjR4d8M7.mjs → i18next-loader-CHtGO6IK.mjs} +2 -2
- package/dist/chunks/{index-oe38cp86.mjs → index-DBWWKrDe.mjs} +12 -12
- package/dist/chunks/{inline-tool-convert-SRTkyaZn.mjs → inline-tool-convert-DduRc0fF.mjs} +1467 -951
- package/dist/chunks/{messages-BogRq8lt.mjs → messages-0AbcLMLm.mjs} +6 -0
- package/dist/chunks/{messages-DJDG55Vq.mjs → messages-0E0AkrNu.mjs} +6 -0
- package/dist/{messages-DnXLrlHh.mjs → chunks/messages-4v4MuVEc.mjs} +6 -0
- package/dist/chunks/{messages-DnIhyAJk.mjs → messages-62v-CLC-.mjs} +6 -0
- package/dist/chunks/{messages-Dzwxv9v1.mjs → messages-8DeO60Oo.mjs} +6 -0
- package/dist/chunks/{messages-B1Aww8q7.mjs → messages-8IPXkrDl.mjs} +6 -0
- package/dist/{messages-uKX8WBaD.mjs → chunks/messages-96kNZDll.mjs} +6 -0
- package/dist/chunks/{messages-BL0tXcDf.mjs → messages-B1FZ8lxU.mjs} +6 -0
- package/dist/{messages-DBn76jVV.mjs → chunks/messages-B217znr-.mjs} +8 -2
- package/dist/{messages-DT4dP5uK.mjs → chunks/messages-B8WNljW3.mjs} +6 -0
- package/dist/chunks/{messages-BdeLo0N9.mjs → messages-BC8IN4Bf.mjs} +6 -0
- package/dist/{messages-CZygwLwM.mjs → chunks/messages-BI43k_BD.mjs} +6 -0
- package/dist/{messages-CzTufCHu.mjs → chunks/messages-BJ6zrz2j.mjs} +6 -0
- package/dist/{messages-BoJc_p1r.mjs → chunks/messages-BUl_Rcnj.mjs} +6 -0
- package/dist/chunks/{messages-CnwibSvh.mjs → messages-BZlmVRwn.mjs} +6 -0
- package/dist/{messages-C2htQ_3F.mjs → chunks/messages-BcpCubnC.mjs} +6 -0
- package/dist/{messages-D5C3J9qr.mjs → chunks/messages-Bm-E4iRC.mjs} +6 -0
- package/dist/chunks/{messages-BELRf6DU.mjs → messages-C4jL-90N.mjs} +6 -0
- package/dist/chunks/{messages-1fC8IMyX.mjs → messages-CDBLbUOQ.mjs} +6 -0
- package/dist/chunks/{messages-7QoX8DkW.mjs → messages-CH4hrauY.mjs} +6 -0
- package/dist/{messages-Dz9L52ol.mjs → chunks/messages-CRJ_mchV.mjs} +6 -0
- package/dist/chunks/{messages-JELdtT6E.mjs → messages-CW4c4cRk.mjs} +6 -0
- package/dist/chunks/{messages-CKI54h6O.mjs → messages-C_4otP7U.mjs} +6 -0
- package/dist/{messages-R3hUSvr3.mjs → chunks/messages-CfiyT2Wi.mjs} +6 -0
- package/dist/{messages-CJdUsQ-c.mjs → chunks/messages-CgTq3QhU.mjs} +6 -0
- package/dist/chunks/{messages-D1Hv8XGo.mjs → messages-Chb7k3Rg.mjs} +6 -0
- package/dist/{messages-Q7AO_FLv.mjs → chunks/messages-Cjjo7yHR.mjs} +6 -0
- package/dist/{messages-C99mq906.mjs → chunks/messages-Cl6ayUaq.mjs} +6 -0
- package/dist/chunks/{messages-Diu6jAaR.mjs → messages-CmR9ftc_.mjs} +6 -0
- package/dist/chunks/{messages-LPVfA-8K.mjs → messages-Cr49Nt3U.mjs} +6 -0
- package/dist/chunks/{messages-DqM1LFg5.mjs → messages-Cr94GzbX.mjs} +6 -0
- package/dist/{messages-BWF-zUpY.mjs → chunks/messages-CrCYPCk3.mjs} +6 -0
- package/dist/{messages-D-ZtY5v0.mjs → chunks/messages-Cs8zmZ3L.mjs} +6 -0
- package/dist/{messages-DprmQg6V.mjs → chunks/messages-CzK0LEhb.mjs} +6 -0
- package/dist/chunks/{messages-BSbjsyHY.mjs → messages-D00x4S8o.mjs} +6 -0
- package/dist/chunks/{messages-Xq8UmkVs.mjs → messages-D1mn7Zd5.mjs} +6 -0
- package/dist/chunks/{messages-BC86qLvI.mjs → messages-D2NOpHn9.mjs} +6 -0
- package/dist/{messages-kep5wtm4.mjs → chunks/messages-D4qqwVgQ.mjs} +6 -0
- package/dist/chunks/{messages-7W4d0DwD.mjs → messages-D5S1Dnpm.mjs} +6 -0
- package/dist/{messages-CY8_RyFE.mjs → chunks/messages-D7u2bmP2.mjs} +6 -0
- package/dist/chunks/{messages-BFG6Wlgy.mjs → messages-D85FqxgY.mjs} +6 -0
- package/dist/{messages-DLfR5bMd.mjs → chunks/messages-D9ndgBnU.mjs} +6 -0
- package/dist/{messages-CVw84KdI.mjs → chunks/messages-DDTQgImT.mjs} +6 -0
- package/dist/{messages-_ErNTNhk.mjs → chunks/messages-DH_jBeED.mjs} +6 -0
- package/dist/chunks/{messages-CMkNSDTo.mjs → messages-DRXWF0PV.mjs} +6 -0
- package/dist/chunks/{messages-BYyy6Wqf.mjs → messages-DVQvl8Qj.mjs} +6 -0
- package/dist/chunks/{messages-CznZadDf.mjs → messages-DXktiao_.mjs} +6 -0
- package/dist/chunks/{messages-DhLKYm2j.mjs → messages-DdK-nFGm.mjs} +6 -0
- package/dist/chunks/{messages-BMXCuEKO.mjs → messages-DlJbPF2T.mjs} +6 -0
- package/dist/chunks/{messages-CvGLfqmV.mjs → messages-DnVlmiNT.mjs} +6 -0
- package/dist/{messages-Z9nEU2xK.mjs → chunks/messages-DviiFSv2.mjs} +6 -0
- package/dist/chunks/{messages-BB5z9Uba.mjs → messages-DzqM3Fel.mjs} +6 -0
- package/dist/{messages-w7v1GNaE.mjs → chunks/messages-Dzzn6XoD.mjs} +6 -0
- package/dist/{messages-CqWJcCbY.mjs → chunks/messages-GSByFygY.mjs} +6 -0
- package/dist/chunks/{messages-_ncGrKHh.mjs → messages-L_kl2Qvh.mjs} +6 -0
- package/dist/chunks/{messages-BrPFGbM-.mjs → messages-Phkd7XmE.mjs} +6 -0
- package/dist/{messages-BU2nlrLK.mjs → chunks/messages-RonBBCnh.mjs} +6 -0
- package/dist/{messages-Bmu_S7GM.mjs → chunks/messages-VDriF5Qy.mjs} +6 -0
- package/dist/{messages-CLhcMlTc.mjs → chunks/messages-ZjUAIWb1.mjs} +6 -0
- package/dist/{messages-9SihnaXQ.mjs → chunks/messages-b1EdvUm0.mjs} +6 -0
- package/dist/{messages-DvFLX36Q.mjs → chunks/messages-begYOTgC.mjs} +6 -0
- package/dist/{messages-BMv4xwIr.mjs → chunks/messages-jrncnb-H.mjs} +6 -0
- package/dist/{messages-D5iv1Kox.mjs → chunks/messages-nefz1S71.mjs} +6 -0
- package/dist/{messages-CQwpzUFp.mjs → chunks/messages-ucTVgS5G.mjs} +6 -0
- package/dist/chunks/{messages-DBRw-7Zc.mjs → messages-v3GipbFl.mjs} +6 -0
- package/dist/{messages-C9eaarcK.mjs → chunks/messages-wmi-iFkH.mjs} +6 -0
- package/dist/chunks/{messages-O5tQus_0.mjs → messages-yHcs38yI.mjs} +6 -0
- package/dist/full.mjs +2 -2
- package/dist/locales.mjs +90 -84
- package/dist/{messages-BogRq8lt.mjs → messages-0AbcLMLm.mjs} +6 -0
- package/dist/{messages-DJDG55Vq.mjs → messages-0E0AkrNu.mjs} +6 -0
- package/dist/{chunks/messages-DnXLrlHh.mjs → messages-4v4MuVEc.mjs} +6 -0
- package/dist/{messages-DnIhyAJk.mjs → messages-62v-CLC-.mjs} +6 -0
- package/dist/{messages-Dzwxv9v1.mjs → messages-8DeO60Oo.mjs} +6 -0
- package/dist/{messages-B1Aww8q7.mjs → messages-8IPXkrDl.mjs} +6 -0
- package/dist/{chunks/messages-uKX8WBaD.mjs → messages-96kNZDll.mjs} +6 -0
- package/dist/{messages-BL0tXcDf.mjs → messages-B1FZ8lxU.mjs} +6 -0
- package/dist/{chunks/messages-DBn76jVV.mjs → messages-B217znr-.mjs} +8 -2
- package/dist/{chunks/messages-DT4dP5uK.mjs → messages-B8WNljW3.mjs} +6 -0
- package/dist/{messages-BdeLo0N9.mjs → messages-BC8IN4Bf.mjs} +6 -0
- package/dist/{chunks/messages-CZygwLwM.mjs → messages-BI43k_BD.mjs} +6 -0
- package/dist/{chunks/messages-CzTufCHu.mjs → messages-BJ6zrz2j.mjs} +6 -0
- package/dist/{chunks/messages-BoJc_p1r.mjs → messages-BUl_Rcnj.mjs} +6 -0
- package/dist/{messages-CnwibSvh.mjs → messages-BZlmVRwn.mjs} +6 -0
- package/dist/{chunks/messages-C2htQ_3F.mjs → messages-BcpCubnC.mjs} +6 -0
- package/dist/{chunks/messages-D5C3J9qr.mjs → messages-Bm-E4iRC.mjs} +6 -0
- package/dist/{messages-BELRf6DU.mjs → messages-C4jL-90N.mjs} +6 -0
- package/dist/{messages-1fC8IMyX.mjs → messages-CDBLbUOQ.mjs} +6 -0
- package/dist/{messages-7QoX8DkW.mjs → messages-CH4hrauY.mjs} +6 -0
- package/dist/{chunks/messages-Dz9L52ol.mjs → messages-CRJ_mchV.mjs} +6 -0
- package/dist/{messages-JELdtT6E.mjs → messages-CW4c4cRk.mjs} +6 -0
- package/dist/{messages-CKI54h6O.mjs → messages-C_4otP7U.mjs} +6 -0
- package/dist/{chunks/messages-R3hUSvr3.mjs → messages-CfiyT2Wi.mjs} +6 -0
- package/dist/{chunks/messages-CJdUsQ-c.mjs → messages-CgTq3QhU.mjs} +6 -0
- package/dist/{messages-D1Hv8XGo.mjs → messages-Chb7k3Rg.mjs} +6 -0
- package/dist/{chunks/messages-Q7AO_FLv.mjs → messages-Cjjo7yHR.mjs} +6 -0
- package/dist/{chunks/messages-C99mq906.mjs → messages-Cl6ayUaq.mjs} +6 -0
- package/dist/{messages-Diu6jAaR.mjs → messages-CmR9ftc_.mjs} +6 -0
- package/dist/{messages-LPVfA-8K.mjs → messages-Cr49Nt3U.mjs} +6 -0
- package/dist/{messages-DqM1LFg5.mjs → messages-Cr94GzbX.mjs} +6 -0
- package/dist/{chunks/messages-BWF-zUpY.mjs → messages-CrCYPCk3.mjs} +6 -0
- package/dist/{chunks/messages-D-ZtY5v0.mjs → messages-Cs8zmZ3L.mjs} +6 -0
- package/dist/{chunks/messages-DprmQg6V.mjs → messages-CzK0LEhb.mjs} +6 -0
- package/dist/{messages-BSbjsyHY.mjs → messages-D00x4S8o.mjs} +6 -0
- package/dist/{messages-Xq8UmkVs.mjs → messages-D1mn7Zd5.mjs} +6 -0
- package/dist/{messages-BC86qLvI.mjs → messages-D2NOpHn9.mjs} +6 -0
- package/dist/{chunks/messages-kep5wtm4.mjs → messages-D4qqwVgQ.mjs} +6 -0
- package/dist/{messages-7W4d0DwD.mjs → messages-D5S1Dnpm.mjs} +6 -0
- package/dist/{chunks/messages-CY8_RyFE.mjs → messages-D7u2bmP2.mjs} +6 -0
- package/dist/{messages-BFG6Wlgy.mjs → messages-D85FqxgY.mjs} +6 -0
- package/dist/{chunks/messages-DLfR5bMd.mjs → messages-D9ndgBnU.mjs} +6 -0
- package/dist/{chunks/messages-CVw84KdI.mjs → messages-DDTQgImT.mjs} +6 -0
- package/dist/{chunks/messages-_ErNTNhk.mjs → messages-DH_jBeED.mjs} +6 -0
- package/dist/{messages-CMkNSDTo.mjs → messages-DRXWF0PV.mjs} +6 -0
- package/dist/{messages-BYyy6Wqf.mjs → messages-DVQvl8Qj.mjs} +6 -0
- package/dist/{messages-CznZadDf.mjs → messages-DXktiao_.mjs} +6 -0
- package/dist/{messages-DhLKYm2j.mjs → messages-DdK-nFGm.mjs} +6 -0
- package/dist/{messages-BMXCuEKO.mjs → messages-DlJbPF2T.mjs} +6 -0
- package/dist/{messages-CvGLfqmV.mjs → messages-DnVlmiNT.mjs} +6 -0
- package/dist/{chunks/messages-Z9nEU2xK.mjs → messages-DviiFSv2.mjs} +6 -0
- package/dist/{messages-BB5z9Uba.mjs → messages-DzqM3Fel.mjs} +6 -0
- package/dist/{chunks/messages-w7v1GNaE.mjs → messages-Dzzn6XoD.mjs} +6 -0
- package/dist/{chunks/messages-CqWJcCbY.mjs → messages-GSByFygY.mjs} +6 -0
- package/dist/{messages-_ncGrKHh.mjs → messages-L_kl2Qvh.mjs} +6 -0
- package/dist/{messages-BrPFGbM-.mjs → messages-Phkd7XmE.mjs} +6 -0
- package/dist/{chunks/messages-BU2nlrLK.mjs → messages-RonBBCnh.mjs} +6 -0
- package/dist/{chunks/messages-Bmu_S7GM.mjs → messages-VDriF5Qy.mjs} +6 -0
- package/dist/{chunks/messages-CLhcMlTc.mjs → messages-ZjUAIWb1.mjs} +6 -0
- package/dist/{chunks/messages-9SihnaXQ.mjs → messages-b1EdvUm0.mjs} +6 -0
- package/dist/{chunks/messages-DvFLX36Q.mjs → messages-begYOTgC.mjs} +6 -0
- package/dist/{chunks/messages-BMv4xwIr.mjs → messages-jrncnb-H.mjs} +6 -0
- package/dist/{chunks/messages-D5iv1Kox.mjs → messages-nefz1S71.mjs} +6 -0
- package/dist/{chunks/messages-CQwpzUFp.mjs → messages-ucTVgS5G.mjs} +6 -0
- package/dist/{messages-DBRw-7Zc.mjs → messages-v3GipbFl.mjs} +6 -0
- package/dist/{chunks/messages-C9eaarcK.mjs → messages-wmi-iFkH.mjs} +6 -0
- package/dist/{messages-O5tQus_0.mjs → messages-yHcs38yI.mjs} +6 -0
- package/dist/tools.mjs +3190 -1690
- package/dist/vendor.LICENSE.txt +109 -109
- package/package.json +43 -57
- package/src/blok.ts +12 -0
- package/src/components/__module.ts +21 -0
- package/src/components/block/api.ts +17 -0
- package/src/components/block/style-manager.ts +6 -2
- package/src/components/block/tool-renderer.ts +33 -30
- package/src/components/blocks.ts +132 -15
- package/src/components/i18n/locales/am/messages.json +6 -0
- package/src/components/i18n/locales/ar/messages.json +6 -0
- package/src/components/i18n/locales/az/messages.json +6 -0
- package/src/components/i18n/locales/bg/messages.json +6 -0
- package/src/components/i18n/locales/bn/messages.json +6 -0
- package/src/components/i18n/locales/bs/messages.json +6 -0
- package/src/components/i18n/locales/cs/messages.json +6 -0
- package/src/components/i18n/locales/da/messages.json +6 -0
- package/src/components/i18n/locales/de/messages.json +6 -0
- package/src/components/i18n/locales/dv/messages.json +6 -0
- package/src/components/i18n/locales/el/messages.json +6 -0
- package/src/components/i18n/locales/en/messages.json +6 -0
- package/src/components/i18n/locales/es/messages.json +6 -0
- package/src/components/i18n/locales/et/messages.json +6 -0
- package/src/components/i18n/locales/fa/messages.json +6 -0
- package/src/components/i18n/locales/fi/messages.json +6 -0
- package/src/components/i18n/locales/fil/messages.json +6 -0
- package/src/components/i18n/locales/fr/messages.json +6 -0
- package/src/components/i18n/locales/gu/messages.json +6 -0
- package/src/components/i18n/locales/he/messages.json +6 -0
- package/src/components/i18n/locales/hi/messages.json +6 -0
- package/src/components/i18n/locales/hr/messages.json +6 -0
- package/src/components/i18n/locales/hu/messages.json +6 -0
- package/src/components/i18n/locales/hy/messages.json +6 -0
- package/src/components/i18n/locales/id/messages.json +6 -0
- package/src/components/i18n/locales/it/messages.json +6 -0
- package/src/components/i18n/locales/ja/messages.json +6 -0
- package/src/components/i18n/locales/ka/messages.json +6 -0
- package/src/components/i18n/locales/km/messages.json +6 -0
- package/src/components/i18n/locales/kn/messages.json +6 -0
- package/src/components/i18n/locales/ko/messages.json +6 -0
- package/src/components/i18n/locales/ku/messages.json +6 -0
- package/src/components/i18n/locales/lo/messages.json +6 -0
- package/src/components/i18n/locales/lt/messages.json +6 -0
- package/src/components/i18n/locales/lv/messages.json +6 -0
- package/src/components/i18n/locales/mk/messages.json +6 -0
- package/src/components/i18n/locales/ml/messages.json +6 -0
- package/src/components/i18n/locales/mn/messages.json +6 -0
- package/src/components/i18n/locales/mr/messages.json +6 -0
- package/src/components/i18n/locales/ms/messages.json +6 -0
- package/src/components/i18n/locales/my/messages.json +6 -0
- package/src/components/i18n/locales/ne/messages.json +6 -0
- package/src/components/i18n/locales/nl/messages.json +6 -0
- package/src/components/i18n/locales/no/messages.json +6 -0
- package/src/components/i18n/locales/pa/messages.json +6 -0
- package/src/components/i18n/locales/pl/messages.json +6 -0
- package/src/components/i18n/locales/ps/messages.json +6 -0
- package/src/components/i18n/locales/pt/messages.json +6 -0
- package/src/components/i18n/locales/ro/messages.json +6 -0
- package/src/components/i18n/locales/ru/messages.json +6 -0
- package/src/components/i18n/locales/sd/messages.json +6 -0
- package/src/components/i18n/locales/si/messages.json +6 -0
- package/src/components/i18n/locales/sk/messages.json +6 -0
- package/src/components/i18n/locales/sl/messages.json +6 -0
- package/src/components/i18n/locales/sq/messages.json +6 -0
- package/src/components/i18n/locales/sr/messages.json +6 -0
- package/src/components/i18n/locales/sv/messages.json +6 -0
- package/src/components/i18n/locales/sw/messages.json +6 -0
- package/src/components/i18n/locales/ta/messages.json +6 -0
- package/src/components/i18n/locales/te/messages.json +6 -0
- package/src/components/i18n/locales/th/messages.json +6 -0
- package/src/components/i18n/locales/tr/messages.json +6 -0
- package/src/components/i18n/locales/ug/messages.json +6 -0
- package/src/components/i18n/locales/uk/messages.json +6 -0
- package/src/components/i18n/locales/ur/messages.json +6 -0
- package/src/components/i18n/locales/vi/messages.json +6 -0
- package/src/components/i18n/locales/yi/messages.json +6 -0
- package/src/components/i18n/locales/zh/messages.json +6 -0
- package/src/components/icons/index.ts +17 -0
- package/src/components/inline-tools/inline-tool-link.ts +1 -1
- package/src/components/inline-tools/inline-tool-marker.ts +737 -0
- package/src/components/inline-tools/utils/formatting-range-utils.ts +6 -3
- package/src/components/inline-tools/utils/marker-dom-utils.ts +17 -0
- package/src/components/modules/api/blocks.ts +34 -9
- package/src/components/modules/blockEvents/composers/keyboardNavigation.ts +75 -29
- package/src/components/modules/blockEvents/index.ts +13 -5
- package/src/components/modules/blockManager/blockManager.ts +81 -2
- package/src/components/modules/blockManager/hierarchy.ts +20 -2
- package/src/components/modules/blockManager/operations.ts +70 -35
- package/src/components/modules/blockManager/repository.ts +22 -0
- package/src/components/modules/blockManager/types.ts +3 -1
- package/src/components/modules/blockManager/yjs-sync.ts +173 -39
- package/src/components/modules/blockSelection.ts +3 -0
- package/src/components/modules/crossBlockSelection.ts +11 -3
- package/src/components/modules/drag/preview/DragPreview.ts +10 -2
- package/src/components/modules/drag/target/DropTargetDetector.ts +100 -11
- package/src/components/modules/drag/utils/drag.constants.ts +1 -1
- package/src/components/modules/normalizeInlineImages.ts +263 -0
- package/src/components/modules/paste/google-docs-preprocessor.ts +197 -0
- package/src/components/modules/paste/handlers/base.ts +43 -2
- package/src/components/modules/paste/handlers/html-handler.ts +1 -1
- package/src/components/modules/paste/handlers/index.ts +1 -0
- package/src/components/modules/paste/handlers/table-cells-handler.ts +104 -0
- package/src/components/modules/paste/index.ts +20 -3
- package/src/components/modules/readonly.ts +8 -2
- package/src/components/modules/rectangleSelection.ts +5 -2
- package/src/components/modules/renderer.ts +35 -0
- package/src/components/modules/saver.ts +52 -2
- package/src/components/modules/toolbar/blockSettings.ts +52 -44
- package/src/components/modules/toolbar/index.ts +124 -17
- package/src/components/modules/toolbar/inline/index.ts +4 -4
- package/src/components/modules/toolbar/plus-button.ts +3 -3
- package/src/components/modules/toolbar/settings-toggler.ts +3 -3
- package/src/components/modules/toolbar/styles.ts +7 -7
- package/src/components/modules/ui.ts +6 -6
- package/src/components/modules/uiControllers/controllers/blockHover.ts +16 -2
- package/src/components/modules/uiControllers/handlers/touch.ts +83 -10
- package/src/components/modules/yjs/block-observer.ts +9 -3
- package/src/components/modules/yjs/document-store.ts +10 -7
- package/src/components/modules/yjs/types.ts +8 -6
- package/src/components/modules/yjs/undo-history.ts +90 -11
- package/src/components/selection/fake-background/shadows.ts +1 -1
- package/src/components/shared/color-picker.ts +211 -0
- package/src/components/shared/color-presets.ts +25 -0
- package/src/components/ui/toolbox.ts +19 -11
- package/src/components/utils/color-mapping.ts +241 -0
- package/src/components/utils/notifier/draw.ts +9 -9
- package/src/components/utils/placeholder.ts +24 -8
- package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.const.ts +2 -2
- package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts +14 -12
- package/src/components/utils/popover/components/search-input/search-input.const.ts +2 -2
- package/src/components/utils/popover/popover-abstract.ts +27 -3
- package/src/components/utils/popover/popover-desktop.ts +26 -3
- package/src/components/utils/popover/popover-inline.ts +14 -1
- package/src/components/utils/popover/popover-mobile.ts +4 -4
- package/src/components/utils/popover/popover.const.ts +2 -2
- package/src/components/utils/sanitizer.ts +24 -3
- package/src/components/utils/tw.ts +17 -5
- package/src/stories/Header.stories.ts +106 -0
- package/src/stories/MarkerColors.stories.ts +730 -0
- package/src/stories/Popover.stories.ts +1 -3
- package/src/stories/Table.stories.ts +1662 -0
- package/src/styles/main.css +207 -37
- package/src/tools/header/index.ts +1 -1
- package/src/tools/index.ts +3 -1
- package/src/tools/list/caret-manager.ts +28 -10
- package/src/tools/list/constants.ts +2 -2
- package/src/tools/list/dom-builder.ts +3 -3
- package/src/tools/list/static-configs.ts +0 -1
- package/src/tools/paragraph/index.ts +9 -5
- package/src/tools/table/core/table-commands.ts +99 -0
- package/src/tools/table/core/table-controller.ts +231 -0
- package/src/tools/table/core/table-events.ts +102 -0
- package/src/tools/table/index.ts +1070 -174
- package/src/tools/table/ownership/table-event-broker.ts +74 -0
- package/src/tools/table/ownership/table-ownership-registry.ts +126 -0
- package/src/tools/table/table-add-controls.ts +85 -15
- package/src/tools/table/table-cell-blocks.ts +336 -38
- package/src/tools/table/table-cell-clipboard.ts +415 -0
- package/src/tools/table/table-cell-color-picker.ts +34 -0
- package/src/tools/table/table-cell-selection.ts +264 -15
- package/src/tools/table/table-core.ts +3 -42
- package/src/tools/table/table-heading-toggle.ts +2 -2
- package/src/tools/table/table-model.ts +623 -0
- package/src/tools/table/table-operations.ts +59 -78
- package/src/tools/table/table-resize.ts +15 -11
- package/src/tools/table/table-restrictions.ts +69 -3
- package/src/tools/table/table-row-col-action-handler.ts +22 -7
- package/src/tools/table/table-row-col-controls.ts +129 -12
- package/src/tools/table/table-row-col-drag.ts +14 -0
- package/src/tools/table/table-scroll-haze.ts +152 -0
- package/src/tools/table/types.ts +22 -1
- package/src/tools/table/view/table-cell-blocks-adapter.ts +47 -0
- package/src/variants/blok-minimum.ts +13 -0
- package/types/api/block.d.ts +13 -0
- package/types/api/blocks.d.ts +16 -0
- package/types/tools/table.d.ts +2 -0
- package/dist/chunks/i18next-CugVlwWp.mjs +0 -1292
- package/src/tools/table/data-normalizer.ts +0 -32
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { I18n } from '../../../types/api';
|
|
2
|
-
import { IconCross } from '../../components/icons';
|
|
3
|
-
import {
|
|
2
|
+
import { IconCopy, IconCross, IconMarker } from '../../components/icons';
|
|
3
|
+
import { MODIFIER_KEY } from '../../components/constants';
|
|
4
|
+
import { PopoverDesktop, PopoverItemType } from '../../components/utils/popover';
|
|
4
5
|
import { twMerge } from '../../components/utils/tw';
|
|
5
6
|
|
|
6
7
|
import { CELL_ATTR, ROW_ATTR } from './table-core';
|
|
8
|
+
import { createCellColorPicker } from './table-cell-color-picker';
|
|
9
|
+
import type { CellColorMode } from './table-cell-color-picker';
|
|
7
10
|
import { createGripDotsSvg } from './table-grip-visuals';
|
|
8
11
|
|
|
9
12
|
import { PopoverEvent } from '@/types/utils/popover/popover-event';
|
|
@@ -20,8 +23,8 @@ const PILL_IDLE_SIZE = 4;
|
|
|
20
23
|
|
|
21
24
|
const PILL_CLASSES = [
|
|
22
25
|
'absolute',
|
|
23
|
-
'z-
|
|
24
|
-
'rounded',
|
|
26
|
+
'z-3',
|
|
27
|
+
'rounded-sm',
|
|
25
28
|
'select-none',
|
|
26
29
|
'transition-[opacity,background-color,width]',
|
|
27
30
|
'duration-150',
|
|
@@ -33,6 +36,13 @@ const PILL_CLASSES = [
|
|
|
33
36
|
'bg-blue-500',
|
|
34
37
|
];
|
|
35
38
|
|
|
39
|
+
export interface SelectionRange {
|
|
40
|
+
minRow: number;
|
|
41
|
+
maxRow: number;
|
|
42
|
+
minCol: number;
|
|
43
|
+
maxCol: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
36
46
|
interface CellCoord {
|
|
37
47
|
row: number;
|
|
38
48
|
col: number;
|
|
@@ -56,7 +66,13 @@ interface CellSelectionOptions {
|
|
|
56
66
|
grid: HTMLElement;
|
|
57
67
|
rectangleSelection?: { cancelActiveSelection: () => void };
|
|
58
68
|
onSelectionActiveChange?: (hasSelection: boolean) => void;
|
|
69
|
+
onSelectionRangeChange?: (range: SelectionRange) => void;
|
|
59
70
|
onClearContent?: (cells: HTMLElement[]) => void;
|
|
71
|
+
onCopy?: (cells: HTMLElement[], clipboardData: DataTransfer) => void;
|
|
72
|
+
onCut?: (cells: HTMLElement[], clipboardData: DataTransfer) => void;
|
|
73
|
+
onCopyViaButton?: (cells: HTMLElement[]) => void;
|
|
74
|
+
onColorChange?: (cells: HTMLElement[], color: string | null, mode: CellColorMode) => void;
|
|
75
|
+
isPopoverOpen?: () => boolean;
|
|
60
76
|
i18n: I18n;
|
|
61
77
|
}
|
|
62
78
|
|
|
@@ -74,6 +90,15 @@ export class TableCellSelection {
|
|
|
74
90
|
private overlay: HTMLElement | null = null;
|
|
75
91
|
private pill: HTMLElement | null = null;
|
|
76
92
|
private pillPopover: PopoverDesktop | null = null;
|
|
93
|
+
private resizeObserver: ResizeObserver | null = null;
|
|
94
|
+
|
|
95
|
+
private onCopy: ((cells: HTMLElement[], clipboardData: DataTransfer) => void) | undefined;
|
|
96
|
+
private onCut: ((cells: HTMLElement[], clipboardData: DataTransfer) => void) | undefined;
|
|
97
|
+
private onCopyViaButton: ((cells: HTMLElement[]) => void) | undefined;
|
|
98
|
+
private onColorChange: ((cells: HTMLElement[], color: string | null, mode: CellColorMode) => void) | undefined;
|
|
99
|
+
private onSelectionRangeChange: ((range: SelectionRange) => void) | undefined;
|
|
100
|
+
private isPopoverOpen: (() => boolean) | undefined;
|
|
101
|
+
private lastPaintedRange: SelectionRange | null = null;
|
|
77
102
|
|
|
78
103
|
private boundPointerDown: (e: PointerEvent) => void;
|
|
79
104
|
private boundPointerMove: (e: PointerEvent) => void;
|
|
@@ -81,12 +106,21 @@ export class TableCellSelection {
|
|
|
81
106
|
private boundClearSelection: (e: PointerEvent) => void;
|
|
82
107
|
private boundCancelRectangle: (e: MouseEvent) => void;
|
|
83
108
|
private boundKeyDown: (e: KeyboardEvent) => void;
|
|
109
|
+
private boundCopyHandler: (e: ClipboardEvent) => void;
|
|
110
|
+
private boundCutHandler: (e: ClipboardEvent) => void;
|
|
111
|
+
private boundPreventDragStart: (e: Event) => void;
|
|
84
112
|
|
|
85
113
|
constructor(options: CellSelectionOptions) {
|
|
86
114
|
this.grid = options.grid;
|
|
87
115
|
this.rectangleSelection = options.rectangleSelection;
|
|
88
116
|
this.onSelectionActiveChange = options.onSelectionActiveChange;
|
|
89
117
|
this.onClearContent = options.onClearContent;
|
|
118
|
+
this.onCopy = options.onCopy;
|
|
119
|
+
this.onCut = options.onCut;
|
|
120
|
+
this.onCopyViaButton = options.onCopyViaButton;
|
|
121
|
+
this.onColorChange = options.onColorChange;
|
|
122
|
+
this.onSelectionRangeChange = options.onSelectionRangeChange;
|
|
123
|
+
this.isPopoverOpen = options.isPopoverOpen;
|
|
90
124
|
this.i18n = options.i18n;
|
|
91
125
|
this.grid.style.position = 'relative';
|
|
92
126
|
|
|
@@ -96,20 +130,30 @@ export class TableCellSelection {
|
|
|
96
130
|
this.boundClearSelection = this.handleClearSelection.bind(this);
|
|
97
131
|
this.boundCancelRectangle = this.handleCancelRectangle.bind(this);
|
|
98
132
|
this.boundKeyDown = this.handleKeyDown.bind(this);
|
|
133
|
+
this.boundCopyHandler = this.handleCopy.bind(this);
|
|
134
|
+
this.boundCutHandler = this.handleCut.bind(this);
|
|
135
|
+
this.boundPreventDragStart = this.handleDragStart.bind(this);
|
|
99
136
|
|
|
100
137
|
this.grid.addEventListener('pointerdown', this.boundPointerDown);
|
|
138
|
+
this.grid.addEventListener('dragstart', this.boundPreventDragStart);
|
|
101
139
|
document.addEventListener('keydown', this.boundKeyDown);
|
|
140
|
+
document.addEventListener('copy', this.boundCopyHandler);
|
|
141
|
+
document.addEventListener('cut', this.boundCutHandler);
|
|
102
142
|
}
|
|
103
143
|
|
|
104
144
|
public destroy(): void {
|
|
105
145
|
this.destroyPillPopover();
|
|
146
|
+
this.disconnectResizeObserver();
|
|
106
147
|
this.clearSelection();
|
|
107
148
|
this.grid.removeEventListener('pointerdown', this.boundPointerDown);
|
|
149
|
+
this.grid.removeEventListener('dragstart', this.boundPreventDragStart);
|
|
108
150
|
document.removeEventListener('pointermove', this.boundPointerMove);
|
|
109
151
|
document.removeEventListener('pointerup', this.boundPointerUp);
|
|
110
152
|
document.removeEventListener('pointerdown', this.boundClearSelection);
|
|
111
153
|
document.removeEventListener('mousemove', this.boundCancelRectangle, true);
|
|
112
154
|
document.removeEventListener('keydown', this.boundKeyDown);
|
|
155
|
+
document.removeEventListener('copy', this.boundCopyHandler);
|
|
156
|
+
document.removeEventListener('cut', this.boundCutHandler);
|
|
113
157
|
}
|
|
114
158
|
|
|
115
159
|
/**
|
|
@@ -147,6 +191,32 @@ export class TableCellSelection {
|
|
|
147
191
|
this.clearSelection();
|
|
148
192
|
}
|
|
149
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Return the currently painted selection range, or null if nothing is selected.
|
|
196
|
+
*/
|
|
197
|
+
public getSelectedRange(): SelectionRange | null {
|
|
198
|
+
return this.hasSelection ? this.lastPaintedRange : null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Programmatically restore a selection range (e.g. after a DOM rebuild).
|
|
203
|
+
*/
|
|
204
|
+
public selectRange(range: SelectionRange): void {
|
|
205
|
+
this.showProgrammaticSelection(range.minRow, range.minCol, range.maxRow, range.maxCol);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Prevent native drag-and-drop while a cell selection drag is in progress.
|
|
210
|
+
* Without this, the browser can fire dragstart on contenteditable cells
|
|
211
|
+
* during a pointer drag, which suppresses pointermove events and breaks
|
|
212
|
+
* the cell selection.
|
|
213
|
+
*/
|
|
214
|
+
private handleDragStart(e: Event): void {
|
|
215
|
+
if (this.anchorCell) {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
150
220
|
private handlePointerDown(e: PointerEvent): void {
|
|
151
221
|
// Don't interfere with grip drags, resize, or add-button drags
|
|
152
222
|
if (isOtherInteractionActive(this.grid)) {
|
|
@@ -171,8 +241,19 @@ export class TableCellSelection {
|
|
|
171
241
|
return;
|
|
172
242
|
}
|
|
173
243
|
|
|
174
|
-
// If
|
|
175
|
-
|
|
244
|
+
// If clicking the same single-cell that's already selected, keep the
|
|
245
|
+
// selection instead of clearing and re-creating it (avoids border flash).
|
|
246
|
+
const clickedSameCell = this.hasSelection
|
|
247
|
+
&& this.lastPaintedRange !== null
|
|
248
|
+
&& this.lastPaintedRange.minRow === cell.row
|
|
249
|
+
&& this.lastPaintedRange.maxRow === cell.row
|
|
250
|
+
&& this.lastPaintedRange.minCol === cell.col
|
|
251
|
+
&& this.lastPaintedRange.maxCol === cell.col;
|
|
252
|
+
|
|
253
|
+
if (clickedSameCell) {
|
|
254
|
+
// Remove the document clear handler so it doesn't fire for this click
|
|
255
|
+
document.removeEventListener('pointerdown', this.boundClearSelection);
|
|
256
|
+
} else if (this.hasSelection) {
|
|
176
257
|
this.clearSelection();
|
|
177
258
|
}
|
|
178
259
|
|
|
@@ -256,10 +337,28 @@ export class TableCellSelection {
|
|
|
256
337
|
this.grid.style.userSelect = '';
|
|
257
338
|
this.hasSelection = true;
|
|
258
339
|
|
|
259
|
-
|
|
260
|
-
|
|
340
|
+
if (this.lastPaintedRange) {
|
|
341
|
+
this.onSelectionRangeChange?.(this.lastPaintedRange);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Listen for next pointerdown anywhere to clear selection.
|
|
345
|
+
// Register synchronously — pointerdown for the drag already fired
|
|
346
|
+
// before this pointerup, so there is no risk of the current
|
|
347
|
+
// interaction's pointerdown triggering the clear handler.
|
|
348
|
+
document.addEventListener('pointerdown', this.boundClearSelection);
|
|
349
|
+
} else if (this.anchorCell) {
|
|
350
|
+
if (this.hasSelection) {
|
|
351
|
+
// Already selected (same single cell) — just re-register clear handler
|
|
261
352
|
document.addEventListener('pointerdown', this.boundClearSelection);
|
|
262
|
-
}
|
|
353
|
+
} else {
|
|
354
|
+
// Single click without drag — select the clicked cell
|
|
355
|
+
this.showProgrammaticSelection(
|
|
356
|
+
this.anchorCell.row,
|
|
357
|
+
this.anchorCell.col,
|
|
358
|
+
this.anchorCell.row,
|
|
359
|
+
this.anchorCell.col,
|
|
360
|
+
);
|
|
361
|
+
}
|
|
263
362
|
}
|
|
264
363
|
|
|
265
364
|
this.isSelecting = false;
|
|
@@ -274,12 +373,17 @@ export class TableCellSelection {
|
|
|
274
373
|
return;
|
|
275
374
|
}
|
|
276
375
|
|
|
277
|
-
// Don't clear
|
|
376
|
+
// Don't clear when clicking inside an open popover — the user may be
|
|
278
377
|
// clicking a popover item whose pointerdown bubbles to the document.
|
|
279
|
-
|
|
378
|
+
// Popovers render on document.body and carry `data-blok-popover-opened`.
|
|
379
|
+
if (target instanceof HTMLElement && target.closest('[data-blok-popover-opened]') !== null) {
|
|
280
380
|
return;
|
|
281
381
|
}
|
|
282
382
|
|
|
383
|
+
if (this.pillPopover !== null) {
|
|
384
|
+
this.destroyPillPopover();
|
|
385
|
+
}
|
|
386
|
+
|
|
283
387
|
document.removeEventListener('pointerdown', this.boundClearSelection);
|
|
284
388
|
this.clearSelection();
|
|
285
389
|
}
|
|
@@ -295,6 +399,12 @@ export class TableCellSelection {
|
|
|
295
399
|
return;
|
|
296
400
|
}
|
|
297
401
|
|
|
402
|
+
// For single-cell selections, let the browser handle Delete/Backspace
|
|
403
|
+
// as normal character-level editing in the contenteditable cell.
|
|
404
|
+
if (this.selectedCells.length <= 1) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
|
|
298
408
|
// Prevent default behavior
|
|
299
409
|
e.preventDefault();
|
|
300
410
|
|
|
@@ -303,11 +413,32 @@ export class TableCellSelection {
|
|
|
303
413
|
this.clearSelection();
|
|
304
414
|
}
|
|
305
415
|
|
|
416
|
+
private handleCopy(e: ClipboardEvent): void {
|
|
417
|
+
if (!this.hasSelection || !e.clipboardData) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
e.preventDefault();
|
|
422
|
+
this.onCopy?.([...this.selectedCells], e.clipboardData);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
private handleCut(e: ClipboardEvent): void {
|
|
426
|
+
if (!this.hasSelection || !e.clipboardData) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
e.preventDefault();
|
|
431
|
+
this.onCut?.([...this.selectedCells], e.clipboardData);
|
|
432
|
+
this.onClearContent?.([...this.selectedCells]);
|
|
433
|
+
this.clearSelection();
|
|
434
|
+
}
|
|
435
|
+
|
|
306
436
|
private clearSelection(): void {
|
|
307
437
|
const hadSelection = this.hasSelection;
|
|
308
438
|
|
|
309
439
|
this.restoreModifiedCells();
|
|
310
440
|
this.hasSelection = false;
|
|
441
|
+
this.lastPaintedRange = null;
|
|
311
442
|
|
|
312
443
|
if (hadSelection) {
|
|
313
444
|
this.onSelectionActiveChange?.(false);
|
|
@@ -316,6 +447,7 @@ export class TableCellSelection {
|
|
|
316
447
|
|
|
317
448
|
private restoreModifiedCells(): void {
|
|
318
449
|
this.destroyPillPopover();
|
|
450
|
+
this.disconnectResizeObserver();
|
|
319
451
|
|
|
320
452
|
this.selectedCells.forEach(cell => {
|
|
321
453
|
cell.removeAttribute(SELECTED_ATTR);
|
|
@@ -346,13 +478,18 @@ export class TableCellSelection {
|
|
|
346
478
|
this.paintSelection();
|
|
347
479
|
this.hasSelection = true;
|
|
348
480
|
this.onSelectionActiveChange?.(true);
|
|
481
|
+
|
|
482
|
+
if (this.lastPaintedRange) {
|
|
483
|
+
this.onSelectionRangeChange?.(this.lastPaintedRange);
|
|
484
|
+
}
|
|
485
|
+
|
|
349
486
|
this.anchorCell = null;
|
|
350
487
|
this.extentCell = null;
|
|
351
488
|
|
|
352
|
-
// Listen for next pointerdown anywhere to clear the programmatic selection
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
489
|
+
// Listen for next pointerdown anywhere to clear the programmatic selection.
|
|
490
|
+
// Register synchronously to avoid race conditions where a fast
|
|
491
|
+
// pointerdown arrives before the next animation frame.
|
|
492
|
+
document.addEventListener('pointerdown', this.boundClearSelection);
|
|
356
493
|
}
|
|
357
494
|
|
|
358
495
|
private paintSelection(): void {
|
|
@@ -372,6 +509,8 @@ export class TableCellSelection {
|
|
|
372
509
|
const minCol = Math.min(this.anchorCell.col, this.extentCell.col);
|
|
373
510
|
const maxCol = Math.max(this.anchorCell.col, this.extentCell.col);
|
|
374
511
|
|
|
512
|
+
this.lastPaintedRange = { minRow, maxRow, minCol, maxCol };
|
|
513
|
+
|
|
375
514
|
const rows = this.grid.querySelectorAll(`[${ROW_ATTR}]`);
|
|
376
515
|
|
|
377
516
|
// Mark selected cells
|
|
@@ -434,6 +573,78 @@ export class TableCellSelection {
|
|
|
434
573
|
// Position at center of the 2px right border; translate(-50%,-50%) handles centering
|
|
435
574
|
this.pill.style.left = `${left + width - 1}px`;
|
|
436
575
|
this.pill.style.top = `${top + height / 2}px`;
|
|
576
|
+
|
|
577
|
+
this.observeCellResizes();
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Recalculate overlay and pill positions from the last painted range.
|
|
582
|
+
* Called by the ResizeObserver when selected cells change size.
|
|
583
|
+
*/
|
|
584
|
+
private repositionOverlay(): void {
|
|
585
|
+
const range = this.lastPaintedRange;
|
|
586
|
+
|
|
587
|
+
if (!range || !this.overlay) {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
const rows = this.grid.querySelectorAll(`[${ROW_ATTR}]`);
|
|
592
|
+
const firstCell = rows[range.minRow]?.querySelectorAll(`[${CELL_ATTR}]`)[range.minCol] as HTMLElement | undefined;
|
|
593
|
+
const lastCell = rows[range.maxRow]?.querySelectorAll(`[${CELL_ATTR}]`)[range.maxCol] as HTMLElement | undefined;
|
|
594
|
+
|
|
595
|
+
if (!firstCell || !lastCell) {
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
const gridRect = this.grid.getBoundingClientRect();
|
|
600
|
+
const firstRect = firstCell.getBoundingClientRect();
|
|
601
|
+
const lastRect = lastCell.getBoundingClientRect();
|
|
602
|
+
|
|
603
|
+
const gridStyle = getComputedStyle(this.grid);
|
|
604
|
+
const borderTop = parseFloat(gridStyle.borderTopWidth) || 0;
|
|
605
|
+
const borderLeft = parseFloat(gridStyle.borderLeftWidth) || 0;
|
|
606
|
+
|
|
607
|
+
const width = lastRect.right - firstRect.left + 1;
|
|
608
|
+
const height = lastRect.bottom - firstRect.top + 1;
|
|
609
|
+
const top = firstRect.top - gridRect.top - borderTop - 1;
|
|
610
|
+
const left = firstRect.left - gridRect.left - borderLeft - 1;
|
|
611
|
+
|
|
612
|
+
this.overlay.style.top = `${top}px`;
|
|
613
|
+
this.overlay.style.left = `${left}px`;
|
|
614
|
+
this.overlay.style.width = `${width}px`;
|
|
615
|
+
this.overlay.style.height = `${height}px`;
|
|
616
|
+
|
|
617
|
+
if (this.pill) {
|
|
618
|
+
this.pill.style.left = `${left + width - 1}px`;
|
|
619
|
+
this.pill.style.top = `${top + height / 2}px`;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Start observing selected cells for size changes so the overlay
|
|
625
|
+
* stays in sync when cell content grows or shrinks.
|
|
626
|
+
*/
|
|
627
|
+
private observeCellResizes(): void {
|
|
628
|
+
this.disconnectResizeObserver();
|
|
629
|
+
|
|
630
|
+
if (this.selectedCells.length === 0) {
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
635
|
+
this.repositionOverlay();
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
for (const cell of this.selectedCells) {
|
|
639
|
+
this.resizeObserver.observe(cell);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
private disconnectResizeObserver(): void {
|
|
644
|
+
if (this.resizeObserver) {
|
|
645
|
+
this.resizeObserver.disconnect();
|
|
646
|
+
this.resizeObserver = null;
|
|
647
|
+
}
|
|
437
648
|
}
|
|
438
649
|
|
|
439
650
|
private createPill(): HTMLElement {
|
|
@@ -482,10 +693,48 @@ export class TableCellSelection {
|
|
|
482
693
|
|
|
483
694
|
this.expandPill();
|
|
484
695
|
|
|
696
|
+
const copyShortcut = MODIFIER_KEY === 'Meta' ? '⌘C' : 'Ctrl+C';
|
|
697
|
+
|
|
698
|
+
const colorPickerItems: PopoverItemParams[] = [];
|
|
699
|
+
|
|
700
|
+
if (this.onColorChange !== undefined) {
|
|
701
|
+
const { element: pickerElement } = createCellColorPicker({
|
|
702
|
+
i18n: this.i18n,
|
|
703
|
+
onColorSelect: (color: string | null, mode: CellColorMode): void => {
|
|
704
|
+
this.onColorChange?.([...this.selectedCells], color, mode);
|
|
705
|
+
},
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
colorPickerItems.push({
|
|
709
|
+
icon: IconMarker,
|
|
710
|
+
title: this.i18n.t('tools.table.cellColor'),
|
|
711
|
+
name: 'cellColor',
|
|
712
|
+
children: {
|
|
713
|
+
items: [{
|
|
714
|
+
type: PopoverItemType.Html,
|
|
715
|
+
element: pickerElement,
|
|
716
|
+
}],
|
|
717
|
+
isFlippable: false,
|
|
718
|
+
width: '12.5rem',
|
|
719
|
+
},
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
|
|
485
723
|
const items: PopoverItemParams[] = [
|
|
724
|
+
...colorPickerItems,
|
|
725
|
+
{
|
|
726
|
+
icon: IconCopy,
|
|
727
|
+
title: this.i18n.t('tools.table.copySelection'),
|
|
728
|
+
secondaryLabel: copyShortcut,
|
|
729
|
+
closeOnActivate: true,
|
|
730
|
+
onActivate: (): void => {
|
|
731
|
+
this.onCopyViaButton?.([...this.selectedCells]);
|
|
732
|
+
},
|
|
733
|
+
},
|
|
486
734
|
{
|
|
487
735
|
icon: IconCross,
|
|
488
736
|
title: this.i18n.t('tools.table.clearSelection'),
|
|
737
|
+
secondaryLabel: 'Del',
|
|
489
738
|
closeOnActivate: true,
|
|
490
739
|
onActivate: (): void => {
|
|
491
740
|
this.onClearContent?.([...this.selectedCells]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { twMerge } from '../../components/utils/tw';
|
|
2
2
|
|
|
3
3
|
import { CELL_BLOCKS_ATTR } from './table-cell-blocks';
|
|
4
|
-
import type {
|
|
4
|
+
import type { LegacyCellContent } from './types';
|
|
5
5
|
|
|
6
6
|
export const ROW_ATTR = 'data-blok-table-row';
|
|
7
7
|
export const CELL_ATTR = 'data-blok-table-cell';
|
|
@@ -17,7 +17,7 @@ const CELL_CLASSES = [
|
|
|
17
17
|
'py-1',
|
|
18
18
|
'px-2',
|
|
19
19
|
'min-h-[2em]',
|
|
20
|
-
'outline-
|
|
20
|
+
'outline-hidden',
|
|
21
21
|
'leading-normal',
|
|
22
22
|
'text-sm',
|
|
23
23
|
'cursor-text',
|
|
@@ -38,7 +38,7 @@ interface TableGridOptions {
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Manages the table grid DOM structure.
|
|
41
|
-
* Creates
|
|
41
|
+
* Creates, deletes, moves, and queries rows, columns, and cells.
|
|
42
42
|
*/
|
|
43
43
|
export class TableGrid {
|
|
44
44
|
private readOnly: boolean;
|
|
@@ -73,27 +73,6 @@ export class TableGrid {
|
|
|
73
73
|
// Content is populated by TableCellBlocks.initializeCells()
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
/**
|
|
77
|
-
* Extract 2D array from grid DOM
|
|
78
|
-
*/
|
|
79
|
-
public getData(table: HTMLElement): CellContent[][] {
|
|
80
|
-
const rows = table.querySelectorAll(`[${ROW_ATTR}]`);
|
|
81
|
-
const result: CellContent[][] = [];
|
|
82
|
-
|
|
83
|
-
rows.forEach(row => {
|
|
84
|
-
const cells = row.querySelectorAll(`[${CELL_ATTR}]`);
|
|
85
|
-
const rowData: CellContent[] = [];
|
|
86
|
-
|
|
87
|
-
cells.forEach(cell => {
|
|
88
|
-
rowData.push(this.getCellContent(cell as HTMLElement));
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
result.push(rowData);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
76
|
/**
|
|
98
77
|
* Add a row. If index is provided, inserts before that row.
|
|
99
78
|
* Otherwise appends at the end.
|
|
@@ -375,24 +354,6 @@ export class TableGrid {
|
|
|
375
354
|
return widths;
|
|
376
355
|
}
|
|
377
356
|
|
|
378
|
-
/**
|
|
379
|
-
* Get cell content as block references
|
|
380
|
-
*/
|
|
381
|
-
private getCellContent(cell: HTMLElement): CellContent {
|
|
382
|
-
const blocksContainer = cell.querySelector(`[${CELL_BLOCKS_ATTR}]`);
|
|
383
|
-
|
|
384
|
-
if (!blocksContainer) {
|
|
385
|
-
return { blocks: [] };
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
const blockElements = blocksContainer.querySelectorAll('[data-blok-id]');
|
|
389
|
-
const blockIds = Array.from(blockElements)
|
|
390
|
-
.map(el => el.getAttribute('data-blok-id') ?? '')
|
|
391
|
-
.filter(id => id !== '');
|
|
392
|
-
|
|
393
|
-
return { blocks: blockIds };
|
|
394
|
-
}
|
|
395
|
-
|
|
396
357
|
/**
|
|
397
358
|
* Detect whether cells use 'px' or '%' widths
|
|
398
359
|
*/
|
|
@@ -10,7 +10,7 @@ const TOGGLE_ROW_CLASSES = [
|
|
|
10
10
|
'border-none',
|
|
11
11
|
'bg-transparent',
|
|
12
12
|
'rounded-md',
|
|
13
|
-
'p-
|
|
13
|
+
'p-(--item-padding)',
|
|
14
14
|
'text-text-primary',
|
|
15
15
|
'mb-px',
|
|
16
16
|
'cursor-pointer',
|
|
@@ -59,7 +59,7 @@ const THUMB_CLASSES = [
|
|
|
59
59
|
'h-4',
|
|
60
60
|
'rounded-full',
|
|
61
61
|
'bg-white',
|
|
62
|
-
'shadow-
|
|
62
|
+
'shadow-xs',
|
|
63
63
|
'transition-[left]',
|
|
64
64
|
'duration-200',
|
|
65
65
|
];
|