@jackuait/blok 0.6.0-beta.13 → 0.6.0-beta.14
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-DzeTRJ_i.mjs → blok-Cl30YOLl.mjs} +1398 -1132
- package/dist/chunks/{i18next-loader-CgW4H90H.mjs → i18next-loader-DbTDlMux.mjs} +1 -1
- package/dist/chunks/{index-BWKk7PIS.mjs → index-DJmaYswj.mjs} +1 -1
- package/dist/chunks/{inline-tool-convert-DrSwadw_.mjs → inline-tool-convert-MjSaP8r7.mjs} +161 -145
- package/dist/{messages-B1Aww8q7.mjs → chunks/messages-1mYyrppy.mjs} +1 -0
- package/dist/chunks/{messages-DnIhyAJk.mjs → messages-4gHfbcDp.mjs} +1 -0
- package/dist/{messages-CQwpzUFp.mjs → chunks/messages-6xYv-U8A.mjs} +1 -0
- package/dist/chunks/{messages-CMkNSDTo.mjs → messages-7jqF79FO.mjs} +1 -0
- package/dist/chunks/{messages-BSbjsyHY.mjs → messages-B3EUuA7o.mjs} +1 -0
- package/dist/{messages-LPVfA-8K.mjs → chunks/messages-B6srtRn7.mjs} +1 -0
- package/dist/chunks/{messages-DJDG55Vq.mjs → messages-B85OIs0E.mjs} +1 -0
- package/dist/{messages-_ErNTNhk.mjs → chunks/messages-BCYBBG_u.mjs} +1 -0
- package/dist/{messages-CZygwLwM.mjs → chunks/messages-BDLNPiaW.mjs} +1 -0
- package/dist/{messages-C2htQ_3F.mjs → chunks/messages-BKpNd1Zb.mjs} +1 -0
- package/dist/chunks/{messages-CnwibSvh.mjs → messages-BLFUid_o.mjs} +1 -0
- package/dist/{messages-CVw84KdI.mjs → chunks/messages-BNPTVKnc.mjs} +1 -0
- package/dist/{messages-BMv4xwIr.mjs → chunks/messages-BQPXSkri.mjs} +1 -0
- package/dist/{messages-Dz9L52ol.mjs → chunks/messages-BQu6VNDq.mjs} +1 -0
- package/dist/{messages-DprmQg6V.mjs → chunks/messages-BRodFKUo.mjs} +1 -0
- package/dist/{messages-CznZadDf.mjs → chunks/messages-BWIikA8H.mjs} +1 -0
- package/dist/{messages-CqWJcCbY.mjs → chunks/messages-BXQvMilx.mjs} +1 -0
- package/dist/chunks/{messages-Z9nEU2xK.mjs → messages-BZ92luiw.mjs} +1 -0
- package/dist/chunks/{messages-BC86qLvI.mjs → messages-Bg0Phlcj.mjs} +1 -0
- package/dist/chunks/{messages-DnXLrlHh.mjs → messages-Bh6RBIu5.mjs} +1 -0
- package/dist/chunks/{messages-DhLKYm2j.mjs → messages-BnFHdIpg.mjs} +1 -0
- package/dist/{messages-BU2nlrLK.mjs → chunks/messages-Bq82EVsw.mjs} +1 -0
- package/dist/chunks/{messages-Diu6jAaR.mjs → messages-BxbcTiHh.mjs} +1 -0
- package/dist/{messages-BoJc_p1r.mjs → chunks/messages-ByO6bSV2.mjs} +1 -0
- package/dist/chunks/{messages-BrPFGbM-.mjs → messages-ByUNPiQ4.mjs} +1 -0
- package/dist/chunks/{messages-BB5z9Uba.mjs → messages-Byw0EHyf.mjs} +1 -0
- package/dist/chunks/{messages-D1Hv8XGo.mjs → messages-C-aP90zq.mjs} +1 -0
- package/dist/chunks/{messages-DBRw-7Zc.mjs → messages-C2f44jci.mjs} +1 -0
- package/dist/chunks/{messages-CJdUsQ-c.mjs → messages-CKYoAmm9.mjs} +1 -0
- package/dist/chunks/{messages-CvGLfqmV.mjs → messages-CSQJrJ_N.mjs} +1 -0
- package/dist/chunks/{messages-1fC8IMyX.mjs → messages-CX_o4Cgc.mjs} +1 -0
- package/dist/chunks/{messages-BdeLo0N9.mjs → messages-C_tfXllT.mjs} +1 -0
- package/dist/chunks/{messages-DBn76jVV.mjs → messages-Cj6TZ_By.mjs} +1 -0
- package/dist/{messages-CLhcMlTc.mjs → chunks/messages-CjdYkfzj.mjs} +1 -0
- package/dist/{messages-7W4d0DwD.mjs → chunks/messages-CmvWFWR6.mjs} +1 -0
- package/dist/{messages-CzTufCHu.mjs → chunks/messages-CnV-kxh6.mjs} +1 -0
- package/dist/chunks/{messages-BMXCuEKO.mjs → messages-CpuDfpdi.mjs} +1 -0
- package/dist/chunks/{messages-DT4dP5uK.mjs → messages-Cspe1oXk.mjs} +1 -0
- package/dist/{messages-D-ZtY5v0.mjs → chunks/messages-D2_d-Jt4.mjs} +1 -0
- package/dist/{messages-BELRf6DU.mjs → chunks/messages-DADSbW8l.mjs} +1 -0
- package/dist/chunks/{messages-O5tQus_0.mjs → messages-DHSeTQ4S.mjs} +1 -0
- package/dist/{messages-BFG6Wlgy.mjs → chunks/messages-DKeO2RsW.mjs} +1 -0
- package/dist/chunks/{messages-9SihnaXQ.mjs → messages-DLdlX_dY.mjs} +1 -0
- package/dist/chunks/{messages-BL0tXcDf.mjs → messages-DVxlJ4DU.mjs} +1 -0
- package/dist/chunks/{messages-CY8_RyFE.mjs → messages-DWSxENRk.mjs} +1 -0
- package/dist/{messages-Q7AO_FLv.mjs → chunks/messages-D_bVNZ12.mjs} +1 -0
- package/dist/chunks/{messages-BYyy6Wqf.mjs → messages-DdzjVwmG.mjs} +1 -0
- package/dist/chunks/{messages-DLfR5bMd.mjs → messages-DhyBKTi0.mjs} +1 -0
- package/dist/chunks/{messages-DvFLX36Q.mjs → messages-DlC9jDXa.mjs} +1 -0
- package/dist/chunks/{messages-D5C3J9qr.mjs → messages-DmBGk8ed.mjs} +1 -0
- package/dist/chunks/{messages-R3hUSvr3.mjs → messages-Dm_VqpU6.mjs} +1 -0
- package/dist/chunks/{messages-w7v1GNaE.mjs → messages-Dn9hI_ER.mjs} +1 -0
- package/dist/{messages-uKX8WBaD.mjs → chunks/messages-Dssp4AXT.mjs} +1 -0
- package/dist/chunks/{messages-Xq8UmkVs.mjs → messages-DzCc0JgS.mjs} +1 -0
- package/dist/chunks/{messages-JELdtT6E.mjs → messages-N6THNxo0.mjs} +1 -0
- package/dist/chunks/{messages-DqM1LFg5.mjs → messages-OctOxF2l.mjs} +1 -0
- package/dist/chunks/{messages-_ncGrKHh.mjs → messages-QT3JA95K.mjs} +1 -0
- package/dist/{messages-C9eaarcK.mjs → chunks/messages-QqWK83BF.mjs} +1 -0
- package/dist/chunks/{messages-BogRq8lt.mjs → messages-RsGaDzbb.mjs} +1 -0
- package/dist/chunks/{messages-Dzwxv9v1.mjs → messages-c7YlI6Wm.mjs} +1 -0
- package/dist/{messages-D5iv1Kox.mjs → chunks/messages-lZ8aF-4r.mjs} +1 -0
- package/dist/chunks/{messages-7QoX8DkW.mjs → messages-uGDrchjb.mjs} +1 -0
- package/dist/chunks/{messages-CKI54h6O.mjs → messages-xc2yNvog.mjs} +1 -0
- package/dist/{messages-Bmu_S7GM.mjs → chunks/messages-y5Q-ymIx.mjs} +1 -0
- package/dist/{messages-BWF-zUpY.mjs → chunks/messages-yJnyedAd.mjs} +1 -0
- package/dist/{messages-kep5wtm4.mjs → chunks/messages-yQ_4upHh.mjs} +1 -0
- package/dist/chunks/{messages-C99mq906.mjs → messages-ysbWD56Q.mjs} +1 -0
- package/dist/full.mjs +2 -2
- package/dist/locales.mjs +68 -67
- package/dist/{chunks/messages-B1Aww8q7.mjs → messages-1mYyrppy.mjs} +1 -0
- package/dist/{messages-DnIhyAJk.mjs → messages-4gHfbcDp.mjs} +1 -0
- package/dist/{chunks/messages-CQwpzUFp.mjs → messages-6xYv-U8A.mjs} +1 -0
- package/dist/{messages-CMkNSDTo.mjs → messages-7jqF79FO.mjs} +1 -0
- package/dist/{messages-BSbjsyHY.mjs → messages-B3EUuA7o.mjs} +1 -0
- package/dist/{chunks/messages-LPVfA-8K.mjs → messages-B6srtRn7.mjs} +1 -0
- package/dist/{messages-DJDG55Vq.mjs → messages-B85OIs0E.mjs} +1 -0
- package/dist/{chunks/messages-_ErNTNhk.mjs → messages-BCYBBG_u.mjs} +1 -0
- package/dist/{chunks/messages-CZygwLwM.mjs → messages-BDLNPiaW.mjs} +1 -0
- package/dist/{chunks/messages-C2htQ_3F.mjs → messages-BKpNd1Zb.mjs} +1 -0
- package/dist/{messages-CnwibSvh.mjs → messages-BLFUid_o.mjs} +1 -0
- package/dist/{chunks/messages-CVw84KdI.mjs → messages-BNPTVKnc.mjs} +1 -0
- package/dist/{chunks/messages-BMv4xwIr.mjs → messages-BQPXSkri.mjs} +1 -0
- package/dist/{chunks/messages-Dz9L52ol.mjs → messages-BQu6VNDq.mjs} +1 -0
- package/dist/{chunks/messages-DprmQg6V.mjs → messages-BRodFKUo.mjs} +1 -0
- package/dist/{chunks/messages-CznZadDf.mjs → messages-BWIikA8H.mjs} +1 -0
- package/dist/{chunks/messages-CqWJcCbY.mjs → messages-BXQvMilx.mjs} +1 -0
- package/dist/{messages-Z9nEU2xK.mjs → messages-BZ92luiw.mjs} +1 -0
- package/dist/{messages-BC86qLvI.mjs → messages-Bg0Phlcj.mjs} +1 -0
- package/dist/{messages-DnXLrlHh.mjs → messages-Bh6RBIu5.mjs} +1 -0
- package/dist/{messages-DhLKYm2j.mjs → messages-BnFHdIpg.mjs} +1 -0
- package/dist/{chunks/messages-BU2nlrLK.mjs → messages-Bq82EVsw.mjs} +1 -0
- package/dist/{messages-Diu6jAaR.mjs → messages-BxbcTiHh.mjs} +1 -0
- package/dist/{chunks/messages-BoJc_p1r.mjs → messages-ByO6bSV2.mjs} +1 -0
- package/dist/{messages-BrPFGbM-.mjs → messages-ByUNPiQ4.mjs} +1 -0
- package/dist/{messages-BB5z9Uba.mjs → messages-Byw0EHyf.mjs} +1 -0
- package/dist/{messages-D1Hv8XGo.mjs → messages-C-aP90zq.mjs} +1 -0
- package/dist/{messages-DBRw-7Zc.mjs → messages-C2f44jci.mjs} +1 -0
- package/dist/{messages-CJdUsQ-c.mjs → messages-CKYoAmm9.mjs} +1 -0
- package/dist/{messages-CvGLfqmV.mjs → messages-CSQJrJ_N.mjs} +1 -0
- package/dist/{messages-1fC8IMyX.mjs → messages-CX_o4Cgc.mjs} +1 -0
- package/dist/{messages-BdeLo0N9.mjs → messages-C_tfXllT.mjs} +1 -0
- package/dist/{messages-DBn76jVV.mjs → messages-Cj6TZ_By.mjs} +1 -0
- package/dist/{chunks/messages-CLhcMlTc.mjs → messages-CjdYkfzj.mjs} +1 -0
- package/dist/{chunks/messages-7W4d0DwD.mjs → messages-CmvWFWR6.mjs} +1 -0
- package/dist/{chunks/messages-CzTufCHu.mjs → messages-CnV-kxh6.mjs} +1 -0
- package/dist/{messages-BMXCuEKO.mjs → messages-CpuDfpdi.mjs} +1 -0
- package/dist/{messages-DT4dP5uK.mjs → messages-Cspe1oXk.mjs} +1 -0
- package/dist/{chunks/messages-D-ZtY5v0.mjs → messages-D2_d-Jt4.mjs} +1 -0
- package/dist/{chunks/messages-BELRf6DU.mjs → messages-DADSbW8l.mjs} +1 -0
- package/dist/{messages-O5tQus_0.mjs → messages-DHSeTQ4S.mjs} +1 -0
- package/dist/{chunks/messages-BFG6Wlgy.mjs → messages-DKeO2RsW.mjs} +1 -0
- package/dist/{messages-9SihnaXQ.mjs → messages-DLdlX_dY.mjs} +1 -0
- package/dist/{messages-BL0tXcDf.mjs → messages-DVxlJ4DU.mjs} +1 -0
- package/dist/{messages-CY8_RyFE.mjs → messages-DWSxENRk.mjs} +1 -0
- package/dist/{chunks/messages-Q7AO_FLv.mjs → messages-D_bVNZ12.mjs} +1 -0
- package/dist/{messages-BYyy6Wqf.mjs → messages-DdzjVwmG.mjs} +1 -0
- package/dist/{messages-DLfR5bMd.mjs → messages-DhyBKTi0.mjs} +1 -0
- package/dist/{messages-DvFLX36Q.mjs → messages-DlC9jDXa.mjs} +1 -0
- package/dist/{messages-D5C3J9qr.mjs → messages-DmBGk8ed.mjs} +1 -0
- package/dist/{messages-R3hUSvr3.mjs → messages-Dm_VqpU6.mjs} +1 -0
- package/dist/{messages-w7v1GNaE.mjs → messages-Dn9hI_ER.mjs} +1 -0
- package/dist/{chunks/messages-uKX8WBaD.mjs → messages-Dssp4AXT.mjs} +1 -0
- package/dist/{messages-Xq8UmkVs.mjs → messages-DzCc0JgS.mjs} +1 -0
- package/dist/{messages-JELdtT6E.mjs → messages-N6THNxo0.mjs} +1 -0
- package/dist/{messages-DqM1LFg5.mjs → messages-OctOxF2l.mjs} +1 -0
- package/dist/{messages-_ncGrKHh.mjs → messages-QT3JA95K.mjs} +1 -0
- package/dist/{chunks/messages-C9eaarcK.mjs → messages-QqWK83BF.mjs} +1 -0
- package/dist/{messages-BogRq8lt.mjs → messages-RsGaDzbb.mjs} +1 -0
- package/dist/{messages-Dzwxv9v1.mjs → messages-c7YlI6Wm.mjs} +1 -0
- package/dist/{chunks/messages-D5iv1Kox.mjs → messages-lZ8aF-4r.mjs} +1 -0
- package/dist/{messages-7QoX8DkW.mjs → messages-uGDrchjb.mjs} +1 -0
- package/dist/{messages-CKI54h6O.mjs → messages-xc2yNvog.mjs} +1 -0
- package/dist/{chunks/messages-Bmu_S7GM.mjs → messages-y5Q-ymIx.mjs} +1 -0
- package/dist/{chunks/messages-BWF-zUpY.mjs → messages-yJnyedAd.mjs} +1 -0
- package/dist/{chunks/messages-kep5wtm4.mjs → messages-yQ_4upHh.mjs} +1 -0
- package/dist/{messages-C99mq906.mjs → messages-ysbWD56Q.mjs} +1 -0
- package/dist/tools.mjs +887 -701
- package/package.json +2 -1
- package/src/components/block/style-manager.ts +5 -1
- package/src/components/blocks.ts +109 -9
- package/src/components/i18n/locales/am/messages.json +1 -0
- package/src/components/i18n/locales/ar/messages.json +1 -0
- package/src/components/i18n/locales/az/messages.json +1 -0
- package/src/components/i18n/locales/bg/messages.json +1 -0
- package/src/components/i18n/locales/bn/messages.json +1 -0
- package/src/components/i18n/locales/bs/messages.json +1 -0
- package/src/components/i18n/locales/cs/messages.json +1 -0
- package/src/components/i18n/locales/da/messages.json +1 -0
- package/src/components/i18n/locales/de/messages.json +1 -0
- package/src/components/i18n/locales/dv/messages.json +1 -0
- package/src/components/i18n/locales/el/messages.json +1 -0
- package/src/components/i18n/locales/en/messages.json +1 -0
- package/src/components/i18n/locales/es/messages.json +1 -0
- package/src/components/i18n/locales/et/messages.json +1 -0
- package/src/components/i18n/locales/fa/messages.json +1 -0
- package/src/components/i18n/locales/fi/messages.json +1 -0
- package/src/components/i18n/locales/fil/messages.json +1 -0
- package/src/components/i18n/locales/fr/messages.json +1 -0
- package/src/components/i18n/locales/gu/messages.json +1 -0
- package/src/components/i18n/locales/he/messages.json +1 -0
- package/src/components/i18n/locales/hi/messages.json +1 -0
- package/src/components/i18n/locales/hr/messages.json +1 -0
- package/src/components/i18n/locales/hu/messages.json +1 -0
- package/src/components/i18n/locales/hy/messages.json +1 -0
- package/src/components/i18n/locales/id/messages.json +1 -0
- package/src/components/i18n/locales/it/messages.json +1 -0
- package/src/components/i18n/locales/ja/messages.json +1 -0
- package/src/components/i18n/locales/ka/messages.json +1 -0
- package/src/components/i18n/locales/km/messages.json +1 -0
- package/src/components/i18n/locales/kn/messages.json +1 -0
- package/src/components/i18n/locales/ko/messages.json +1 -0
- package/src/components/i18n/locales/ku/messages.json +1 -0
- package/src/components/i18n/locales/lo/messages.json +1 -0
- package/src/components/i18n/locales/lt/messages.json +1 -0
- package/src/components/i18n/locales/lv/messages.json +1 -0
- package/src/components/i18n/locales/mk/messages.json +1 -0
- package/src/components/i18n/locales/ml/messages.json +1 -0
- package/src/components/i18n/locales/mn/messages.json +1 -0
- package/src/components/i18n/locales/mr/messages.json +1 -0
- package/src/components/i18n/locales/ms/messages.json +1 -0
- package/src/components/i18n/locales/my/messages.json +1 -0
- package/src/components/i18n/locales/ne/messages.json +1 -0
- package/src/components/i18n/locales/nl/messages.json +1 -0
- package/src/components/i18n/locales/no/messages.json +1 -0
- package/src/components/i18n/locales/pa/messages.json +1 -0
- package/src/components/i18n/locales/pl/messages.json +1 -0
- package/src/components/i18n/locales/ps/messages.json +1 -0
- package/src/components/i18n/locales/pt/messages.json +1 -0
- package/src/components/i18n/locales/ro/messages.json +1 -0
- package/src/components/i18n/locales/ru/messages.json +1 -0
- package/src/components/i18n/locales/sd/messages.json +1 -0
- package/src/components/i18n/locales/si/messages.json +1 -0
- package/src/components/i18n/locales/sk/messages.json +1 -0
- package/src/components/i18n/locales/sl/messages.json +1 -0
- package/src/components/i18n/locales/sq/messages.json +1 -0
- package/src/components/i18n/locales/sr/messages.json +1 -0
- package/src/components/i18n/locales/sv/messages.json +1 -0
- package/src/components/i18n/locales/sw/messages.json +1 -0
- package/src/components/i18n/locales/ta/messages.json +1 -0
- package/src/components/i18n/locales/te/messages.json +1 -0
- package/src/components/i18n/locales/th/messages.json +1 -0
- package/src/components/i18n/locales/tr/messages.json +1 -0
- package/src/components/i18n/locales/ug/messages.json +1 -0
- package/src/components/i18n/locales/uk/messages.json +1 -0
- package/src/components/i18n/locales/ur/messages.json +1 -0
- package/src/components/i18n/locales/vi/messages.json +1 -0
- package/src/components/i18n/locales/yi/messages.json +1 -0
- package/src/components/i18n/locales/zh/messages.json +1 -0
- package/src/components/icons/index.ts +8 -0
- package/src/components/modules/blockEvents/composers/keyboardNavigation.ts +51 -10
- package/src/components/modules/blockEvents/index.ts +2 -5
- package/src/components/modules/blockManager/blockManager.ts +10 -0
- package/src/components/modules/blockManager/operations.ts +11 -0
- package/src/components/modules/blockManager/repository.ts +22 -0
- package/src/components/modules/blockManager/yjs-sync.ts +148 -31
- package/src/components/modules/crossBlockSelection.ts +11 -3
- package/src/components/modules/drag/preview/DragPreview.ts +8 -0
- package/src/components/modules/drag/target/DropTargetDetector.ts +100 -11
- package/src/components/modules/paste/handlers/base.ts +3 -4
- package/src/components/modules/paste/index.ts +1 -1
- package/src/components/modules/rectangleSelection.ts +5 -2
- package/src/components/modules/toolbar/blockSettings.ts +52 -44
- package/src/components/modules/toolbar/index.ts +27 -7
- package/src/components/modules/toolbar/inline/index.ts +1 -1
- 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 +4 -2
- package/src/components/modules/yjs/types.ts +8 -6
- package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts +6 -4
- package/src/components/utils/popover/popover-desktop.ts +12 -0
- package/src/stories/Popover.stories.ts +0 -2
- package/src/styles/main.css +9 -1
- package/src/tools/list/caret-manager.ts +28 -10
- package/src/tools/table/index.ts +180 -37
- package/src/tools/table/table-add-controls.ts +51 -14
- package/src/tools/table/table-cell-blocks.ts +41 -2
- package/src/tools/table/table-cell-selection.ts +27 -1
- package/src/tools/table/table-operations.ts +12 -15
- package/src/tools/table/table-row-col-controls.ts +69 -6
- package/src/tools/table/table-scroll-haze.ts +152 -0
package/dist/tools.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var Le = Object.defineProperty, Ie = Object.defineProperties;
|
|
2
|
+
var De = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var Et = Object.getOwnPropertySymbols;
|
|
4
|
+
var He = Object.prototype.hasOwnProperty, Pe = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var xt = (r, t, e) => t in r ? Le(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, E = (r, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
He.call(t, e) && xt(r, e, t[e]);
|
|
8
|
+
if (Et)
|
|
9
|
+
for (var e of Et(t))
|
|
10
|
+
Pe.call(t, e) && xt(r, e, t[e]);
|
|
11
11
|
return r;
|
|
12
|
-
},
|
|
13
|
-
import { t as
|
|
14
|
-
import {
|
|
15
|
-
const
|
|
12
|
+
}, W = (r, t) => Ie(r, De(t));
|
|
13
|
+
import { t as v, D as L, at as Ne, au as Oe, a4 as Me, av as _e, aw as We, ax as Ge, ay as $e, az as qe, aA as Fe, aB as se, aC as ie, aD as re, n as ze, o as Tt, ab as Bt, a9 as Ve, aE as Ue, aF as Ke, R as le, X as ae, aG as je, P as U, aH as Xe, aI as Ye, a6 as ce, aJ as Ze, aK as Je, aL as Qe, aM as tn, aN as en, aO as nn, aP as Rt, aQ as Lt, aR as It, K as on, aS as sn, G as O, aT as rn, aU as ln, S as ot, aV as an, l as cn, ae as dn } from "./chunks/inline-tool-convert-MjSaP8r7.mjs";
|
|
14
|
+
import { ai as $s } from "./chunks/inline-tool-convert-MjSaP8r7.mjs";
|
|
15
|
+
const de = (r) => {
|
|
16
16
|
if (!r || !r.includes("data-blok-fake-background"))
|
|
17
17
|
return r;
|
|
18
18
|
const t = document.createElement("div");
|
|
@@ -33,7 +33,7 @@ const ie = (r) => {
|
|
|
33
33
|
"[&[data-blok-empty=true]]:before:text-gray-text",
|
|
34
34
|
"[&[data-blok-empty=true]]:before:cursor-text",
|
|
35
35
|
"[&[data-blok-empty=true]]:before:content-[attr(data-placeholder)]"
|
|
36
|
-
],
|
|
36
|
+
], hn = [
|
|
37
37
|
"empty:focus:before:pointer-events-none",
|
|
38
38
|
"empty:focus:before:text-gray-text",
|
|
39
39
|
"empty:focus:before:cursor-text",
|
|
@@ -42,7 +42,7 @@ const ie = (r) => {
|
|
|
42
42
|
"[&[data-empty=true]:focus]:before:text-gray-text",
|
|
43
43
|
"[&[data-empty=true]:focus]:before:cursor-text",
|
|
44
44
|
"[&[data-empty=true]:focus]:before:content-[attr(data-blok-placeholder-active)]"
|
|
45
|
-
],
|
|
45
|
+
], un = [
|
|
46
46
|
"[[data-blok-empty=true]_&]:empty:before:pointer-events-none",
|
|
47
47
|
"[[data-blok-empty=true]_&]:empty:before:text-gray-text",
|
|
48
48
|
"[[data-blok-empty=true]_&]:empty:before:cursor-text",
|
|
@@ -51,22 +51,22 @@ const ie = (r) => {
|
|
|
51
51
|
"[[data-blok-empty=true]_&[data-empty=true]]:before:text-gray-text",
|
|
52
52
|
"[[data-blok-empty=true]_&[data-empty=true]]:before:cursor-text",
|
|
53
53
|
"[[data-blok-empty=true]_&[data-empty=true]]:before:content-[attr(data-blok-placeholder-active)]"
|
|
54
|
-
],
|
|
54
|
+
], pn = (r) => {
|
|
55
55
|
const t = r.innerHTML.trim();
|
|
56
56
|
return t === "" || t === "<br>";
|
|
57
|
-
},
|
|
57
|
+
}, gn = (r) => {
|
|
58
58
|
r.innerHTML === "<br>" && (r.innerHTML = "");
|
|
59
59
|
const t = window.getSelection();
|
|
60
60
|
if (!t) return;
|
|
61
61
|
const e = document.createRange();
|
|
62
62
|
e.selectNodeContents(r), e.collapse(!0), t.removeAllRanges(), t.addRange(e);
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
},
|
|
63
|
+
}, fn = (r) => {
|
|
64
|
+
pn(r) && gn(r);
|
|
65
|
+
}, kt = (r, t, e = "data-placeholder") => {
|
|
66
66
|
r.setAttribute(e, t != null ? t : "");
|
|
67
|
-
const n = () =>
|
|
67
|
+
const n = () => fn(r);
|
|
68
68
|
r.addEventListener("focus", n), r.addEventListener("input", n);
|
|
69
|
-
},
|
|
69
|
+
}, mn = (r) => {
|
|
70
70
|
const t = document.createElement("div");
|
|
71
71
|
t.innerHTML = r.trim();
|
|
72
72
|
const e = document.createDocumentFragment();
|
|
@@ -116,14 +116,14 @@ const ie = (r) => {
|
|
|
116
116
|
}
|
|
117
117
|
drawView() {
|
|
118
118
|
const t = document.createElement("DIV");
|
|
119
|
-
t.className =
|
|
119
|
+
t.className = v(
|
|
120
120
|
this.api.styles.block,
|
|
121
121
|
nt.WRAPPER_CLASSES,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
), t.setAttribute(
|
|
122
|
+
hn,
|
|
123
|
+
un
|
|
124
|
+
), t.setAttribute(L.tool, "paragraph"), t.contentEditable = "false";
|
|
125
125
|
const e = this.buildInlineStyles();
|
|
126
|
-
return Object.keys(e).length > 0 && Object.assign(t.style, e), this._data.text && (t.innerHTML = this._data.text), this.readOnly ? t.setAttribute("data-blok-placeholder-active", this.api.i18n.t(this._placeholder)) : (t.contentEditable = "true", t.addEventListener("keyup", this.onKeyUp),
|
|
126
|
+
return Object.keys(e).length > 0 && Object.assign(t.style, e), this._data.text && (t.innerHTML = this._data.text), this.readOnly ? t.setAttribute("data-blok-placeholder-active", this.api.i18n.t(this._placeholder)) : (t.contentEditable = "true", t.addEventListener("keyup", this.onKeyUp), kt(t, this.api.i18n.t(this._placeholder), "data-blok-placeholder-active")), t;
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Return Tool's view
|
|
@@ -143,7 +143,7 @@ const ie = (r) => {
|
|
|
143
143
|
if (!this._element)
|
|
144
144
|
return;
|
|
145
145
|
this._data.text += t.text;
|
|
146
|
-
const e =
|
|
146
|
+
const e = mn(t.text);
|
|
147
147
|
this._element.appendChild(e), this._element.normalize();
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
@@ -164,7 +164,7 @@ const ie = (r) => {
|
|
|
164
164
|
*/
|
|
165
165
|
save(t) {
|
|
166
166
|
return {
|
|
167
|
-
text:
|
|
167
|
+
text: de(t.innerHTML)
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
@@ -241,7 +241,7 @@ const ie = (r) => {
|
|
|
241
241
|
*/
|
|
242
242
|
static get toolbox() {
|
|
243
243
|
return {
|
|
244
|
-
icon:
|
|
244
|
+
icon: Ne,
|
|
245
245
|
title: "Text",
|
|
246
246
|
titleKey: "text",
|
|
247
247
|
searchTerms: ["p", "paragraph", "plain"]
|
|
@@ -256,8 +256,8 @@ nt.WRAPPER_CLASSES = [
|
|
|
256
256
|
"[&>p:first-of-type]:mt-0",
|
|
257
257
|
"[&>p:last-of-type]:mb-0"
|
|
258
258
|
];
|
|
259
|
-
let
|
|
260
|
-
const
|
|
259
|
+
let Dt = nt;
|
|
260
|
+
const $ = class $ {
|
|
261
261
|
/**
|
|
262
262
|
* Render plugin's main Element and fill it with saved data
|
|
263
263
|
*
|
|
@@ -344,9 +344,9 @@ const G = class G {
|
|
|
344
344
|
buildSettingsFromToolboxEntries(t) {
|
|
345
345
|
return t.map((e) => {
|
|
346
346
|
var c, d, h, u;
|
|
347
|
-
const n = e.data, o = (c = n == null ? void 0 : n.level) != null ? c : this.defaultLevel.number, s =
|
|
347
|
+
const n = e.data, o = (c = n == null ? void 0 : n.level) != null ? c : this.defaultLevel.number, s = $.DEFAULT_LEVELS.find((p) => p.number === o), i = (d = s == null ? void 0 : s.name) != null ? d : `Heading ${o}`, l = this.resolveToolboxEntryTitle(e, i);
|
|
348
348
|
return {
|
|
349
|
-
icon: (u = (h = e.icon) != null ? h : s == null ? void 0 : s.icon) != null ? u :
|
|
349
|
+
icon: (u = (h = e.icon) != null ? h : s == null ? void 0 : s.icon) != null ? u : Oe,
|
|
350
350
|
title: l,
|
|
351
351
|
onActivate: () => this.setLevel(o),
|
|
352
352
|
closeOnActivate: !0,
|
|
@@ -365,7 +365,7 @@ const G = class G {
|
|
|
365
365
|
* @returns Resolved title string
|
|
366
366
|
*/
|
|
367
367
|
resolveToolboxEntryTitle(t, e) {
|
|
368
|
-
return
|
|
368
|
+
return Me(this.api.i18n, t, e);
|
|
369
369
|
}
|
|
370
370
|
/**
|
|
371
371
|
* Callback for Block's settings buttons
|
|
@@ -467,9 +467,9 @@ const G = class G {
|
|
|
467
467
|
*/
|
|
468
468
|
getTag() {
|
|
469
469
|
const t = document.createElement(this.currentLevel.tag);
|
|
470
|
-
t.innerHTML = this._data.text || "", t.className =
|
|
470
|
+
t.innerHTML = this._data.text || "", t.className = v($.BASE_STYLES, this.currentLevel.styles, ht);
|
|
471
471
|
const { inlineStyles: e } = this.currentLevel;
|
|
472
|
-
return e && Object.assign(t.style, e), t.setAttribute(
|
|
472
|
+
return e && Object.assign(t.style, e), t.setAttribute(L.tool, "header"), t.contentEditable = this.readOnly ? "false" : "true", this.readOnly ? t.setAttribute("data-placeholder", this.api.i18n.t(this._settings.placeholder || "")) : kt(t, this.api.i18n.t(this._settings.placeholder || "")), t;
|
|
473
473
|
}
|
|
474
474
|
/**
|
|
475
475
|
* Get current level
|
|
@@ -497,7 +497,7 @@ const G = class G {
|
|
|
497
497
|
* @returns Level array
|
|
498
498
|
*/
|
|
499
499
|
get levels() {
|
|
500
|
-
const t = this._settings.levelOverrides || {}, e =
|
|
500
|
+
const t = this._settings.levelOverrides || {}, e = $.DEFAULT_LEVELS.map((o) => {
|
|
501
501
|
var l;
|
|
502
502
|
const s = t[o.number] || {}, i = {};
|
|
503
503
|
return s.size && (i.fontSize = s.size), s.marginTop && (i.marginTop = s.marginTop), s.marginBottom && (i.marginBottom = s.marginBottom), {
|
|
@@ -554,7 +554,7 @@ const G = class G {
|
|
|
554
554
|
* @returns ToolboxConfig array with entries for H1-H6
|
|
555
555
|
*/
|
|
556
556
|
static get toolbox() {
|
|
557
|
-
return
|
|
557
|
+
return $.DEFAULT_LEVELS.map((t) => ({
|
|
558
558
|
icon: t.icon,
|
|
559
559
|
title: t.name,
|
|
560
560
|
titleKey: t.nameKey,
|
|
@@ -565,19 +565,19 @@ const G = class G {
|
|
|
565
565
|
}));
|
|
566
566
|
}
|
|
567
567
|
};
|
|
568
|
-
|
|
569
|
-
{ number: 1, tag: "H1", nameKey: "tools.header.heading1", name: "Heading 1", icon:
|
|
570
|
-
{ number: 2, tag: "H2", nameKey: "tools.header.heading2", name: "Heading 2", icon:
|
|
571
|
-
{ number: 3, tag: "H3", nameKey: "tools.header.heading3", name: "Heading 3", icon:
|
|
572
|
-
{ number: 4, tag: "H4", nameKey: "tools.header.heading4", name: "Heading 4", icon:
|
|
573
|
-
{ number: 5, tag: "H5", nameKey: "tools.header.heading5", name: "Heading 5", icon:
|
|
574
|
-
{ number: 6, tag: "H6", nameKey: "tools.header.heading6", name: "Heading 6", icon:
|
|
568
|
+
$.BASE_STYLES = "py-[3px] px-[2px] m-0 !leading-[1.3] outline-none [&_p]:!p-0 [&_p]:!m-0 [&_div]:!p-0 [&_div]:!m-0", $.DEFAULT_LEVELS = [
|
|
569
|
+
{ number: 1, tag: "H1", nameKey: "tools.header.heading1", name: "Heading 1", icon: _e, styles: "text-4xl font-bold mt-8 mb-1" },
|
|
570
|
+
{ number: 2, tag: "H2", nameKey: "tools.header.heading2", name: "Heading 2", icon: We, styles: "text-3xl font-semibold mt-6 mb-px" },
|
|
571
|
+
{ number: 3, tag: "H3", nameKey: "tools.header.heading3", name: "Heading 3", icon: Ge, styles: "text-2xl font-semibold mt-4 mb-px" },
|
|
572
|
+
{ number: 4, tag: "H4", nameKey: "tools.header.heading4", name: "Heading 4", icon: $e, styles: "text-xl font-semibold mt-3 mb-px" },
|
|
573
|
+
{ number: 5, tag: "H5", nameKey: "tools.header.heading5", name: "Heading 5", icon: qe, styles: "text-base font-semibold mt-3 mb-px" },
|
|
574
|
+
{ number: 6, tag: "H6", nameKey: "tools.header.heading6", name: "Heading 6", icon: Fe, styles: "text-sm font-semibold mt-3 mb-px" }
|
|
575
575
|
];
|
|
576
|
-
let
|
|
577
|
-
const K = 24,
|
|
576
|
+
let Ht = $;
|
|
577
|
+
const K = 24, Cn = "outline-none py-[3px] mt-[2px] mb-px", yn = "outline-none pl-0.5 leading-[1.6em]", bn = "flex items-start pl-0.5", vn = "mt-1 w-4 mr-2 h-4 cursor-pointer accent-current", Sn = "tools.list.placeholder", x = "list", he = {
|
|
578
578
|
contentContainer: "list-content-container",
|
|
579
579
|
checklistContent: "list-checklist-content"
|
|
580
|
-
},
|
|
580
|
+
}, ue = (r, t) => {
|
|
581
581
|
const e = r;
|
|
582
582
|
e._placeholder = t, Object.defineProperty(e, "getPlaceholder", {
|
|
583
583
|
value: () => e._placeholder,
|
|
@@ -585,8 +585,8 @@ const K = 24, pn = "outline-none py-[3px] mt-[2px] mb-px", gn = "outline-none pl
|
|
|
585
585
|
enumerable: !0,
|
|
586
586
|
configurable: !1
|
|
587
587
|
});
|
|
588
|
-
},
|
|
589
|
-
const { data: t, keydownHandler: e, readOnly: n } = r, o =
|
|
588
|
+
}, pe = (r) => {
|
|
589
|
+
const { data: t, keydownHandler: e, readOnly: n } = r, o = wn(r), s = t.style === "checklist" ? An(r) : kn(r);
|
|
590
590
|
o.appendChild(s), !n && e && o.addEventListener("keydown", e);
|
|
591
591
|
const i = s.querySelector("[data-list-marker]"), l = s.querySelector('input[type="checkbox"]'), a = s.querySelector("[contenteditable]");
|
|
592
592
|
return {
|
|
@@ -595,52 +595,52 @@ const K = 24, pn = "outline-none py-[3px] mt-[2px] mb-px", gn = "outline-none pl
|
|
|
595
595
|
markerElement: i,
|
|
596
596
|
checkboxElement: l
|
|
597
597
|
};
|
|
598
|
-
},
|
|
598
|
+
}, wn = (r) => {
|
|
599
599
|
var n;
|
|
600
600
|
const { data: t } = r, e = document.createElement("div");
|
|
601
|
-
return e.className =
|
|
602
|
-
},
|
|
601
|
+
return e.className = Cn, e.setAttribute(L.tool, x), e.setAttribute("data-list-style", t.style), e.setAttribute("data-list-depth", String((n = t.depth) != null ? n : 0)), t.start !== void 0 && t.start !== 1 && e.setAttribute("data-list-start", String(t.start)), e;
|
|
602
|
+
}, kn = (r) => {
|
|
603
603
|
var c;
|
|
604
604
|
const { data: t, itemColor: e, itemSize: n, placeholder: o } = r, s = document.createElement("div");
|
|
605
|
-
s.setAttribute("role", "listitem"), s.className =
|
|
605
|
+
s.setAttribute("role", "listitem"), s.className = v(yn, "flex", ...ht), e && (s.style.color = e), n && (s.style.fontSize = n);
|
|
606
606
|
const i = (c = t.depth) != null ? c : 0;
|
|
607
607
|
i > 0 && (s.style.marginLeft = `${i * K}px`);
|
|
608
|
-
const l =
|
|
608
|
+
const l = En(t.style, i);
|
|
609
609
|
l.setAttribute("data-list-marker", "true"), l.setAttribute("data-blok-mutation-free", "true"), s.appendChild(l);
|
|
610
610
|
const a = document.createElement("div");
|
|
611
|
-
return a.className =
|
|
612
|
-
},
|
|
611
|
+
return a.className = v("flex-1 min-w-0 outline-none", ...ht), a.setAttribute("data-blok-testid", he.contentContainer), a.contentEditable = r.readOnly ? "false" : "true", a.innerHTML = t.text, ue(a, o), s.appendChild(a), s;
|
|
612
|
+
}, An = (r) => {
|
|
613
613
|
var d;
|
|
614
614
|
const { data: t, itemColor: e, itemSize: n, placeholder: o, readOnly: s } = r, i = document.createElement("div");
|
|
615
|
-
i.setAttribute("role", "listitem"), i.className =
|
|
615
|
+
i.setAttribute("role", "listitem"), i.className = bn, e && (i.style.color = e), n && (i.style.fontSize = n);
|
|
616
616
|
const l = (d = t.depth) != null ? d : 0;
|
|
617
617
|
l > 0 && (i.style.marginLeft = `${l * K}px`);
|
|
618
618
|
const a = document.createElement("input");
|
|
619
|
-
a.type = "checkbox", a.className =
|
|
619
|
+
a.type = "checkbox", a.className = vn, a.checked = !!t.checked, a.disabled = s;
|
|
620
620
|
const c = document.createElement("div");
|
|
621
|
-
return c.className =
|
|
621
|
+
return c.className = v(
|
|
622
622
|
"flex-1 outline-none leading-[1.6em]",
|
|
623
623
|
t.checked ? "line-through opacity-60" : "",
|
|
624
624
|
...ht
|
|
625
|
-
), c.setAttribute("data-blok-testid",
|
|
626
|
-
},
|
|
625
|
+
), c.setAttribute("data-blok-testid", he.checklistContent), c.setAttribute("data-checked", String(t.checked)), c.contentEditable = s ? "false" : "true", c.innerHTML = t.text, ue(c, o), i.appendChild(a), i.appendChild(c), i;
|
|
626
|
+
}, En = (r, t) => {
|
|
627
627
|
const e = document.createElement("span");
|
|
628
628
|
if (e.className = "flex-shrink-0 select-none", e.setAttribute("aria-hidden", "true"), e.contentEditable = "false", r === "ordered")
|
|
629
|
-
e.textContent = "1.", e.className =
|
|
629
|
+
e.textContent = "1.", e.className = v(e.className, "text-right"), e.style.paddingRight = "11px", e.style.minWidth = "fit-content";
|
|
630
630
|
else {
|
|
631
|
-
const n =
|
|
632
|
-
e.textContent = n, e.className =
|
|
631
|
+
const n = xn(t);
|
|
632
|
+
e.textContent = n, e.className = v(e.className, "w-6 text-center flex justify-center"), e.style.paddingLeft = "1px", e.style.paddingRight = "13px", e.style.fontSize = "24px", e.style.fontFamily = "Arial";
|
|
633
633
|
}
|
|
634
634
|
return e;
|
|
635
|
-
},
|
|
635
|
+
}, xn = (r) => {
|
|
636
636
|
const t = ["•", "◦", "▪"];
|
|
637
637
|
return t[r % t.length];
|
|
638
|
-
},
|
|
638
|
+
}, Tn = (r) => {
|
|
639
639
|
const { data: t, readOnly: e, placeholder: n, itemColor: o, itemSize: s, element: i, setupItemPlaceholder: l, onCheckboxChange: a, keydownHandler: c } = r;
|
|
640
640
|
if (!i) return null;
|
|
641
641
|
const d = i.parentNode;
|
|
642
642
|
if (!d) return null;
|
|
643
|
-
const h =
|
|
643
|
+
const h = pe({
|
|
644
644
|
data: t,
|
|
645
645
|
readOnly: e,
|
|
646
646
|
placeholder: n,
|
|
@@ -655,26 +655,26 @@ const K = 24, pn = "outline-none py-[3px] mt-[2px] mb-px", gn = "outline-none pl
|
|
|
655
655
|
});
|
|
656
656
|
}
|
|
657
657
|
return d.replaceChild(h.wrapper, i), h.wrapper;
|
|
658
|
-
},
|
|
658
|
+
}, Bn = (r, t, e) => {
|
|
659
659
|
if (!t) return r;
|
|
660
660
|
const n = e(), s = {
|
|
661
|
-
text: n ?
|
|
661
|
+
text: n ? de(n.innerHTML) : r.text,
|
|
662
662
|
style: r.style,
|
|
663
663
|
checked: r.checked
|
|
664
664
|
};
|
|
665
665
|
return r.start !== void 0 && r.start !== 1 && (s.start = r.start), r.depth !== void 0 && r.depth > 0 && (s.depth = r.depth), s;
|
|
666
|
-
},
|
|
667
|
-
var
|
|
666
|
+
}, Rn = (r, t, e, n, o) => {
|
|
667
|
+
var C, f, y;
|
|
668
668
|
if (!e)
|
|
669
669
|
return { newData: r, inPlace: !1 };
|
|
670
|
-
const s = (
|
|
670
|
+
const s = (C = r.depth) != null ? C : 0, i = (f = t.depth) != null ? f : 0, l = r.style, a = t.style;
|
|
671
671
|
if (l !== a)
|
|
672
672
|
return { newData: r, inPlace: !1 };
|
|
673
|
-
const c = "depth" in t ? t.depth : 0, d =
|
|
673
|
+
const c = "depth" in t ? t.depth : 0, d = W(E(E({}, r), t), {
|
|
674
674
|
depth: c
|
|
675
675
|
}), h = n();
|
|
676
676
|
return h && typeof t.text == "string" && (h.innerHTML = t.text), s !== i ? (o.adjustDepthTo(i), o.updateMarkerForDepth(i, a), { newData: d, inPlace: !0 }) : (a === "checklist" && o.updateCheckboxState((y = t.checked) != null ? y : !1), { newData: d, inPlace: !0 });
|
|
677
|
-
},
|
|
677
|
+
}, Ln = (r, t) => {
|
|
678
678
|
const { element: e, getContentElement: n, parseHTML: o, data: s } = r;
|
|
679
679
|
if (!e)
|
|
680
680
|
return;
|
|
@@ -684,13 +684,13 @@ const K = 24, pn = "outline-none py-[3px] mt-[2px] mb-px", gn = "outline-none pl
|
|
|
684
684
|
const l = o(t.text);
|
|
685
685
|
i.appendChild(l), i.normalize();
|
|
686
686
|
}
|
|
687
|
-
},
|
|
687
|
+
}, In = (r, t, e, n) => r.map((o) => ({
|
|
688
688
|
icon: o.icon,
|
|
689
689
|
title: e(`toolNames.${o.titleKey}`),
|
|
690
690
|
onActivate: () => n(o.style),
|
|
691
691
|
closeOnActivate: !0,
|
|
692
692
|
isActive: t === o.style
|
|
693
|
-
})),
|
|
693
|
+
})), Dn = (r) => {
|
|
694
694
|
if (!r)
|
|
695
695
|
return;
|
|
696
696
|
const e = (r.getAttribute("style") || "").match(/margin-left:\s*(\d+)px/);
|
|
@@ -698,7 +698,7 @@ const K = 24, pn = "outline-none py-[3px] mt-[2px] mb-px", gn = "outline-none pl
|
|
|
698
698
|
return;
|
|
699
699
|
const n = parseInt(e[1], 10);
|
|
700
700
|
return n > 0 ? { left: n } : void 0;
|
|
701
|
-
},
|
|
701
|
+
}, Hn = (r) => {
|
|
702
702
|
const t = r.closest("[data-list-depth]");
|
|
703
703
|
if (!t)
|
|
704
704
|
return;
|
|
@@ -707,10 +707,10 @@ const K = 24, pn = "outline-none py-[3px] mt-[2px] mb-px", gn = "outline-none pl
|
|
|
707
707
|
return;
|
|
708
708
|
const n = parseInt(e, 10);
|
|
709
709
|
return n > 0 ? { left: n * K } : void 0;
|
|
710
|
-
},
|
|
711
|
-
const t = r.closest('[role="listitem"]') || r.querySelector('[role="listitem"]'), e =
|
|
712
|
-
return e !== void 0 ? e :
|
|
713
|
-
},
|
|
710
|
+
}, Pn = (r) => {
|
|
711
|
+
const t = r.closest('[role="listitem"]') || r.querySelector('[role="listitem"]'), e = Dn(t);
|
|
712
|
+
return e !== void 0 ? e : Hn(r);
|
|
713
|
+
}, Nn = (r, t) => {
|
|
714
714
|
const e = document.createRange();
|
|
715
715
|
if (e.setStart(r, 0), e.setEnd(t.startContainer, t.startOffset), !r.lastChild)
|
|
716
716
|
return {
|
|
@@ -719,33 +719,33 @@ const K = 24, pn = "outline-none py-[3px] mt-[2px] mb-px", gn = "outline-none pl
|
|
|
719
719
|
};
|
|
720
720
|
const n = document.createRange();
|
|
721
721
|
return n.setStart(t.endContainer, t.endOffset), n.setEndAfter(r.lastChild), {
|
|
722
|
-
beforeContent:
|
|
723
|
-
afterContent:
|
|
722
|
+
beforeContent: Pt(e.cloneContents()),
|
|
723
|
+
afterContent: Pt(n.cloneContents())
|
|
724
724
|
};
|
|
725
|
-
},
|
|
725
|
+
}, Pt = (r) => {
|
|
726
726
|
const t = document.createElement("div");
|
|
727
727
|
return t.appendChild(r), t.innerHTML;
|
|
728
|
-
},
|
|
728
|
+
}, On = (r) => {
|
|
729
729
|
const t = document.createElement("div");
|
|
730
730
|
t.innerHTML = r.trim();
|
|
731
731
|
const e = document.createDocumentFragment();
|
|
732
732
|
return e.append(...Array.from(t.childNodes)), e;
|
|
733
|
-
},
|
|
733
|
+
}, Mn = (r, t) => {
|
|
734
734
|
const e = document.createRange();
|
|
735
735
|
return e.selectNodeContents(r), e.setEnd(t.startContainer, t.startOffset), e.toString().length === 0;
|
|
736
|
-
},
|
|
736
|
+
}, _n = (r, t) => {
|
|
737
737
|
const e = document.createRange();
|
|
738
738
|
e.selectNodeContents(r), e.setEnd(t.startContainer, t.startOffset);
|
|
739
739
|
const n = e.toString().length === 0, o = document.createRange();
|
|
740
740
|
o.selectNodeContents(r), o.setStart(t.endContainer, t.endOffset);
|
|
741
741
|
const s = o.toString().length === 0;
|
|
742
742
|
return n && s;
|
|
743
|
-
},
|
|
743
|
+
}, Wn = (r) => {
|
|
744
744
|
if (typeof r != "object" || r === null)
|
|
745
745
|
return !1;
|
|
746
746
|
const e = Object.entries(r).find(([n]) => n === "items");
|
|
747
747
|
return e === void 0 ? !1 : Array.isArray(e[1]);
|
|
748
|
-
},
|
|
748
|
+
}, Gn = (r) => typeof r == "object" && r !== null, $n = (r) => typeof r == "string" ? r : "", qn = (r, t) => r === "unordered" || r === "ordered" || r === "checklist" ? r : t, Fn = (r) => !!r, zn = (r, t) => typeof r == "number" ? r : t, Vn = (r, t) => {
|
|
749
749
|
const e = t.defaultStyle || "unordered";
|
|
750
750
|
if (!r || typeof r != "object")
|
|
751
751
|
return {
|
|
@@ -754,7 +754,7 @@ const K = 24, pn = "outline-none py-[3px] mt-[2px] mb-px", gn = "outline-none pl
|
|
|
754
754
|
checked: !1,
|
|
755
755
|
depth: 0
|
|
756
756
|
};
|
|
757
|
-
if (
|
|
757
|
+
if (Wn(r)) {
|
|
758
758
|
const n = r.items[0], o = (n == null ? void 0 : n.content) || "", s = (n == null ? void 0 : n.checked) || !1;
|
|
759
759
|
return E({
|
|
760
760
|
text: o,
|
|
@@ -763,8 +763,8 @@ const K = 24, pn = "outline-none py-[3px] mt-[2px] mb-px", gn = "outline-none pl
|
|
|
763
763
|
depth: 0
|
|
764
764
|
}, r.start !== void 0 && r.start !== 1 ? { start: r.start } : {});
|
|
765
765
|
}
|
|
766
|
-
if (
|
|
767
|
-
const n =
|
|
766
|
+
if (Gn(r)) {
|
|
767
|
+
const n = $n(r.text), o = qn(r.style, e), s = Fn(r.checked), i = zn(r.depth, 0), l = r.start, a = typeof l == "number" && l !== void 0 && l !== 1 ? l : void 0;
|
|
768
768
|
return E({
|
|
769
769
|
text: n,
|
|
770
770
|
style: o,
|
|
@@ -779,7 +779,7 @@ const K = 24, pn = "outline-none py-[3px] mt-[2px] mb-px", gn = "outline-none pl
|
|
|
779
779
|
depth: 0
|
|
780
780
|
};
|
|
781
781
|
};
|
|
782
|
-
class
|
|
782
|
+
class ge {
|
|
783
783
|
constructor(t) {
|
|
784
784
|
this.blocks = t;
|
|
785
785
|
}
|
|
@@ -839,7 +839,7 @@ class ce {
|
|
|
839
839
|
return n ? Math.round(parseInt(n[1], 10) / K) : 0;
|
|
840
840
|
}
|
|
841
841
|
}
|
|
842
|
-
const
|
|
842
|
+
const Un = (r, t) => {
|
|
843
843
|
if (!r) return null;
|
|
844
844
|
if (t === "checklist") {
|
|
845
845
|
const n = r.querySelector("[contenteditable]");
|
|
@@ -847,15 +847,15 @@ const qn = (r, t) => {
|
|
|
847
847
|
}
|
|
848
848
|
const e = r.querySelector('[data-blok-testid="list-content-container"]');
|
|
849
849
|
return e instanceof HTMLElement ? e : null;
|
|
850
|
-
},
|
|
850
|
+
}, Kn = (r, t, e) => {
|
|
851
851
|
r && r.setAttribute("data-list-depth", String(e));
|
|
852
852
|
const n = r == null ? void 0 : r.querySelector('[role="listitem"]');
|
|
853
853
|
n instanceof HTMLElement && (n.style.marginLeft = e > 0 ? `${e * K}px` : ""), t.depth = e;
|
|
854
|
-
},
|
|
854
|
+
}, fe = (r, t) => t.getBlockDepth(r), me = (r, t) => t.getBlockStyle(r), jn = (r, t) => t.getBulletCharacter(r), Nt = (r, t, e, n, o) => {
|
|
855
855
|
var i;
|
|
856
856
|
const s = r && (i = n.getBlockIndex(r)) != null ? i : n.getCurrentBlockIndex();
|
|
857
857
|
return s <= 0 ? 0 : o.getSiblingIndex(s, t, e);
|
|
858
|
-
},
|
|
858
|
+
}, Xn = (r, t, e, n, o, s) => {
|
|
859
859
|
var a, c;
|
|
860
860
|
if (r === 0)
|
|
861
861
|
return (a = n.start) != null ? a : 1;
|
|
@@ -866,10 +866,10 @@ const qn = (r, t) => {
|
|
|
866
866
|
n.style
|
|
867
867
|
);
|
|
868
868
|
return l === null ? 1 : s.getBlockStartValue(l);
|
|
869
|
-
},
|
|
870
|
-
const l =
|
|
869
|
+
}, Ot = (r, t, e, n, o, s) => {
|
|
870
|
+
const l = Xn(r, t, n, e, o, s) + r;
|
|
871
871
|
return s.formatNumber(l, t);
|
|
872
|
-
},
|
|
872
|
+
}, Yn = (r, t, e, n) => n.findGroupStart(r, t, e), Ce = (r, t, e, n) => {
|
|
873
873
|
if (!r)
|
|
874
874
|
return;
|
|
875
875
|
const o = r.holder, s = o == null ? void 0 : o.querySelector('[data-list-style="ordered"]');
|
|
@@ -881,9 +881,9 @@ const qn = (r, t) => {
|
|
|
881
881
|
const l = t.getBlockIndex(r.id);
|
|
882
882
|
if (l == null)
|
|
883
883
|
return;
|
|
884
|
-
const a =
|
|
884
|
+
const a = fe(r, e), c = me(r, n) || "ordered", d = n.getSiblingIndex(l, a, c), u = n.getGroupStartValue(l, a, d, c) + d, p = n.formatNumber(u, a);
|
|
885
885
|
i.textContent = p;
|
|
886
|
-
},
|
|
886
|
+
}, Zn = (r, t, e, n, o, s, i, l) => {
|
|
887
887
|
const a = (c) => {
|
|
888
888
|
if (c >= t)
|
|
889
889
|
return;
|
|
@@ -894,61 +894,62 @@ const qn = (r, t) => {
|
|
|
894
894
|
const d = s.getBlockByIndex(c);
|
|
895
895
|
if (!d || d.name !== x)
|
|
896
896
|
return;
|
|
897
|
-
const h =
|
|
897
|
+
const h = fe(d, i);
|
|
898
898
|
if (h < n)
|
|
899
899
|
return;
|
|
900
900
|
if (h > n) {
|
|
901
901
|
a(c + 1);
|
|
902
902
|
return;
|
|
903
903
|
}
|
|
904
|
-
|
|
904
|
+
me(d, l) === o && (Ce(d, s, i, l), a(c + 1));
|
|
905
905
|
};
|
|
906
906
|
a(r);
|
|
907
|
-
},
|
|
907
|
+
}, Jn = (r, t, e) => {
|
|
908
908
|
const n = r.getBlocksCount();
|
|
909
909
|
Array.from({ length: n }, (o, s) => s).forEach((o) => {
|
|
910
910
|
const s = r.getBlockByIndex(o);
|
|
911
911
|
if (!s || s.name !== x)
|
|
912
912
|
return;
|
|
913
913
|
const i = s.holder;
|
|
914
|
-
i != null && i.querySelector('[data-list-style="ordered"]') &&
|
|
914
|
+
i != null && i.querySelector('[data-list-style="ordered"]') && Ce(s, r, t, e);
|
|
915
915
|
});
|
|
916
916
|
}, Y = (r, t, e = "end") => {
|
|
917
|
-
|
|
918
|
-
const
|
|
919
|
-
if (!
|
|
920
|
-
const
|
|
921
|
-
if (!(
|
|
922
|
-
r.caret.setToBlock(t, e), r.caret.updateLastCaretAfterPosition();
|
|
917
|
+
const n = (i) => {
|
|
918
|
+
const l = t.holder;
|
|
919
|
+
if (!l) return;
|
|
920
|
+
const a = l.querySelector('[contenteditable="true"]');
|
|
921
|
+
if (!(a instanceof HTMLElement)) {
|
|
922
|
+
r.caret.setToBlock(t, e), i && r.caret.updateLastCaretAfterPosition();
|
|
923
923
|
return;
|
|
924
924
|
}
|
|
925
|
-
|
|
926
|
-
const
|
|
927
|
-
if (!
|
|
928
|
-
const
|
|
929
|
-
e === "start" ? (
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
|
|
925
|
+
a.focus();
|
|
926
|
+
const c = window.getSelection();
|
|
927
|
+
if (!c) return;
|
|
928
|
+
const d = document.createRange();
|
|
929
|
+
e === "start" ? (d.setStart(a, 0), d.collapse(!0)) : (d.selectNodeContents(a), d.collapse(!1)), c.removeAllRanges(), c.addRange(d), i && r.caret.updateLastCaretAfterPosition();
|
|
930
|
+
}, o = t.holder;
|
|
931
|
+
(o == null ? void 0 : o.querySelector('[contenteditable="true"]')) instanceof HTMLElement ? n(!1) : requestAnimationFrame(() => n(!0));
|
|
932
|
+
}, Qn = async (r) => {
|
|
933
|
+
var C;
|
|
933
934
|
const { api: t, blockId: e, data: n, element: o, getContentElement: s } = r, i = window.getSelection();
|
|
934
935
|
if (!i || !o) return;
|
|
935
936
|
const l = s();
|
|
936
937
|
if (!l) return;
|
|
937
938
|
const a = l.innerHTML.trim();
|
|
938
939
|
if (a === "" || a === "<br>") {
|
|
939
|
-
await
|
|
940
|
+
await to(r);
|
|
940
941
|
return;
|
|
941
942
|
}
|
|
942
|
-
const c = i.getRangeAt(0), { beforeContent: d, afterContent: h } =
|
|
943
|
+
const c = i.getRangeAt(0), { beforeContent: d, afterContent: h } = Nn(l, c), u = e && (C = t.blocks.getBlockIndex(e)) != null ? C : t.blocks.getCurrentBlockIndex();
|
|
943
944
|
if (!e) {
|
|
944
945
|
l.innerHTML = d, n.text = d;
|
|
945
|
-
const
|
|
946
|
+
const f = t.blocks.insert(x, {
|
|
946
947
|
text: h,
|
|
947
948
|
style: n.style,
|
|
948
949
|
checked: !1,
|
|
949
950
|
depth: n.depth
|
|
950
951
|
}, void 0, u + 1, !0);
|
|
951
|
-
Y(t,
|
|
952
|
+
Y(t, f, "start");
|
|
952
953
|
return;
|
|
953
954
|
}
|
|
954
955
|
const p = t.blocks.splitBlock(
|
|
@@ -964,37 +965,37 @@ const qn = (r, t) => {
|
|
|
964
965
|
u + 1
|
|
965
966
|
);
|
|
966
967
|
n.text = d, Y(t, p, "start");
|
|
967
|
-
},
|
|
968
|
+
}, to = async (r) => {
|
|
968
969
|
const { api: t, blockId: e, getDepth: n } = r;
|
|
969
970
|
if (n() > 0) {
|
|
970
|
-
await
|
|
971
|
+
await ye(r);
|
|
971
972
|
return;
|
|
972
973
|
}
|
|
973
974
|
if (e === void 0)
|
|
974
975
|
return;
|
|
975
976
|
const s = await t.blocks.convert(e, "paragraph", { text: "" });
|
|
976
977
|
Y(t, s, "start");
|
|
977
|
-
},
|
|
978
|
+
}, eo = async (r, t) => {
|
|
978
979
|
const { api: e, blockId: n, data: o, element: s, getContentElement: i, getDepth: l, syncContentFromDOM: a } = r, c = window.getSelection();
|
|
979
980
|
if (!c || !s) return;
|
|
980
981
|
const d = c.getRangeAt(0), h = i();
|
|
981
982
|
if (!h) return;
|
|
982
983
|
a();
|
|
983
984
|
const u = o.text, p = l();
|
|
984
|
-
if (
|
|
985
|
+
if (_n(h, d) && !c.isCollapsed) {
|
|
985
986
|
t.preventDefault(), h.innerHTML = "", o.text = "";
|
|
986
987
|
const y = document.createRange();
|
|
987
988
|
y.setStart(h, 0), y.collapse(!0), c.removeAllRanges(), c.addRange(y);
|
|
988
989
|
return;
|
|
989
990
|
}
|
|
990
|
-
if (!
|
|
991
|
+
if (!Mn(h, d) || (t.preventDefault(), n === void 0))
|
|
991
992
|
return;
|
|
992
|
-
const
|
|
993
|
+
const f = await e.blocks.convert(n, "paragraph", { text: u });
|
|
993
994
|
p > 0 && requestAnimationFrame(() => {
|
|
994
|
-
const y =
|
|
995
|
+
const y = f.holder;
|
|
995
996
|
y && (y.style.marginLeft = `${p * K}px`, y.setAttribute("data-blok-depth", String(p)));
|
|
996
|
-
}), Y(e,
|
|
997
|
-
},
|
|
997
|
+
}), Y(e, f, "start");
|
|
998
|
+
}, no = async (r, t) => {
|
|
998
999
|
const { api: e, blockId: n, data: o, syncContentFromDOM: s, getDepth: i } = r, l = e.blocks.getCurrentBlockIndex();
|
|
999
1000
|
if (l === 0) return;
|
|
1000
1001
|
const a = e.blocks.getBlockByIndex(l - 1);
|
|
@@ -1004,22 +1005,22 @@ const qn = (r, t) => {
|
|
|
1004
1005
|
s();
|
|
1005
1006
|
const h = c + 1;
|
|
1006
1007
|
o.depth = h;
|
|
1007
|
-
const u = await e.blocks.update(n || "",
|
|
1008
|
+
const u = await e.blocks.update(n || "", W(E({}, o), {
|
|
1008
1009
|
depth: h
|
|
1009
1010
|
}));
|
|
1010
1011
|
Y(e, u);
|
|
1011
|
-
},
|
|
1012
|
+
}, ye = async (r) => {
|
|
1012
1013
|
const { api: t, blockId: e, data: n, syncContentFromDOM: o, getDepth: s } = r, i = s();
|
|
1013
1014
|
if (i === 0) return;
|
|
1014
1015
|
o();
|
|
1015
1016
|
const l = i - 1;
|
|
1016
1017
|
n.depth = l;
|
|
1017
|
-
const a = await t.blocks.update(e || "",
|
|
1018
|
+
const a = await t.blocks.update(e || "", W(E({}, n), {
|
|
1018
1019
|
depth: l
|
|
1019
1020
|
}));
|
|
1020
1021
|
Y(t, a);
|
|
1021
|
-
},
|
|
1022
|
-
const { data: t, readOnly: e, placeholder: n, itemColor: o, itemSize: s, setupItemPlaceholder: i, onCheckboxChange: l, keydownHandler: a } = r, c =
|
|
1022
|
+
}, oo = (r) => {
|
|
1023
|
+
const { data: t, readOnly: e, placeholder: n, itemColor: o, itemSize: s, setupItemPlaceholder: i, onCheckboxChange: l, keydownHandler: a } = r, c = pe({
|
|
1023
1024
|
data: t,
|
|
1024
1025
|
readOnly: e,
|
|
1025
1026
|
placeholder: n,
|
|
@@ -1034,14 +1035,14 @@ const qn = (r, t) => {
|
|
|
1034
1035
|
});
|
|
1035
1036
|
}
|
|
1036
1037
|
return c.wrapper;
|
|
1037
|
-
},
|
|
1038
|
+
}, so = (r) => {
|
|
1038
1039
|
const t = (e) => {
|
|
1039
1040
|
if (e <= 0) return "";
|
|
1040
1041
|
const n = e - 1;
|
|
1041
1042
|
return t(Math.floor(n / 26)) + String.fromCharCode(97 + n % 26);
|
|
1042
1043
|
};
|
|
1043
1044
|
return t(r);
|
|
1044
|
-
},
|
|
1045
|
+
}, io = (r) => {
|
|
1045
1046
|
const t = [
|
|
1046
1047
|
[1e3, "m"],
|
|
1047
1048
|
[900, "cm"],
|
|
@@ -1063,7 +1064,7 @@ const qn = (r, t) => {
|
|
|
1063
1064
|
};
|
|
1064
1065
|
return e(r, 0);
|
|
1065
1066
|
};
|
|
1066
|
-
class
|
|
1067
|
+
class be {
|
|
1067
1068
|
constructor(t) {
|
|
1068
1069
|
this.blocks = t;
|
|
1069
1070
|
}
|
|
@@ -1122,7 +1123,7 @@ class ge {
|
|
|
1122
1123
|
*/
|
|
1123
1124
|
formatNumber(t, e) {
|
|
1124
1125
|
const n = e % 3;
|
|
1125
|
-
return n === 1 ? `${
|
|
1126
|
+
return n === 1 ? `${so(t)}.` : n === 2 ? `${io(t)}.` : `${t}.`;
|
|
1126
1127
|
}
|
|
1127
1128
|
/**
|
|
1128
1129
|
* Get the start value for a list group.
|
|
@@ -1219,9 +1220,9 @@ class ge {
|
|
|
1219
1220
|
}
|
|
1220
1221
|
}
|
|
1221
1222
|
const gt = { value: !1 };
|
|
1222
|
-
class
|
|
1223
|
+
class ro {
|
|
1223
1224
|
constructor(t) {
|
|
1224
|
-
this.blocks = t, this.depthValidator = new
|
|
1225
|
+
this.blocks = t, this.depthValidator = new ge(t), this.markerCalculator = new be(t);
|
|
1225
1226
|
}
|
|
1226
1227
|
/**
|
|
1227
1228
|
* Update this block's marker element with the correct index.
|
|
@@ -1328,15 +1329,15 @@ class no {
|
|
|
1328
1329
|
if (s == null)
|
|
1329
1330
|
return;
|
|
1330
1331
|
const i = this.depthValidator.getBlockDepth(t), l = this.getBlockStyle(t) || "ordered", a = this.markerCalculator.getSiblingIndex(s, i, l), c = this.markerCalculator.getGroupStartValue(s, i, a, l), h = (a === 0 && c === 1 ? (() => {
|
|
1331
|
-
const p = n.closest("[data-list-start]"),
|
|
1332
|
-
if (!
|
|
1333
|
-
const
|
|
1334
|
-
return isNaN(
|
|
1332
|
+
const p = n.closest("[data-list-start]"), C = p == null ? void 0 : p.getAttribute("data-list-start");
|
|
1333
|
+
if (!C) return c;
|
|
1334
|
+
const f = parseInt(C, 10);
|
|
1335
|
+
return isNaN(f) ? c : f;
|
|
1335
1336
|
})() : c) + a, u = this.markerCalculator.formatNumber(h, i);
|
|
1336
1337
|
o.textContent = u;
|
|
1337
1338
|
}
|
|
1338
1339
|
}
|
|
1339
|
-
const
|
|
1340
|
+
const lo = (r) => r instanceof HTMLElement, ao = /* @__PURE__ */ new Set([
|
|
1340
1341
|
"decimal",
|
|
1341
1342
|
"decimal-leading-zero",
|
|
1342
1343
|
"lower-roman",
|
|
@@ -1367,12 +1368,12 @@ const oo = (r) => r instanceof HTMLElement, so = /* @__PURE__ */ new Set([
|
|
|
1367
1368
|
"telugu",
|
|
1368
1369
|
"thai",
|
|
1369
1370
|
"tibetan"
|
|
1370
|
-
]),
|
|
1371
|
+
]), co = /* @__PURE__ */ new Set([
|
|
1371
1372
|
"disc",
|
|
1372
1373
|
"circle",
|
|
1373
1374
|
"square",
|
|
1374
1375
|
"none"
|
|
1375
|
-
]),
|
|
1376
|
+
]), ho = (r) => {
|
|
1376
1377
|
const t = r.getAttribute("data-list-style");
|
|
1377
1378
|
if (t === "ordered") return "ordered";
|
|
1378
1379
|
if (t === "unordered") return "unordered";
|
|
@@ -1381,25 +1382,25 @@ const oo = (r) => r instanceof HTMLElement, so = /* @__PURE__ */ new Set([
|
|
|
1381
1382
|
const n = e.match(/list-style-type\s*:\s*([^;]+)/);
|
|
1382
1383
|
if (!n) return null;
|
|
1383
1384
|
const o = n[1].trim().toLowerCase();
|
|
1384
|
-
return
|
|
1385
|
-
},
|
|
1385
|
+
return ao.has(o) ? "ordered" : co.has(o) ? "unordered" : null;
|
|
1386
|
+
}, uo = (r, t) => {
|
|
1386
1387
|
const e = r.parentElement;
|
|
1387
1388
|
if ((e == null ? void 0 : e.tagName) === "OL") return "ordered";
|
|
1388
1389
|
if ((e == null ? void 0 : e.tagName) === "UL")
|
|
1389
1390
|
return r.querySelector('input[type="checkbox"]') ? "checklist" : "unordered";
|
|
1390
|
-
const n =
|
|
1391
|
+
const n = ho(r);
|
|
1391
1392
|
return n || t;
|
|
1392
|
-
},
|
|
1393
|
+
}, po = (r) => {
|
|
1393
1394
|
const t = r.innerHTML || r.textContent || "", e = r.querySelector('input[type="checkbox"]'), n = e instanceof HTMLInputElement ? e.checked : !1;
|
|
1394
1395
|
return { text: t, checked: n };
|
|
1395
|
-
},
|
|
1396
|
+
}, go = (r) => {
|
|
1396
1397
|
const t = r.getAttribute("aria-level");
|
|
1397
1398
|
if (t) {
|
|
1398
1399
|
const e = parseInt(t, 10);
|
|
1399
1400
|
return Math.max(0, e - 1);
|
|
1400
1401
|
}
|
|
1401
1402
|
return 0;
|
|
1402
|
-
},
|
|
1403
|
+
}, fo = () => ({
|
|
1403
1404
|
text: {
|
|
1404
1405
|
br: !0,
|
|
1405
1406
|
a: {
|
|
@@ -1411,7 +1412,7 @@ const oo = (r) => r instanceof HTMLElement, so = /* @__PURE__ */ new Set([
|
|
|
1411
1412
|
i: !0,
|
|
1412
1413
|
mark: !0
|
|
1413
1414
|
}
|
|
1414
|
-
}),
|
|
1415
|
+
}), mo = () => ({
|
|
1415
1416
|
tags: [
|
|
1416
1417
|
{
|
|
1417
1418
|
li: {
|
|
@@ -1422,35 +1423,35 @@ const oo = (r) => r instanceof HTMLElement, so = /* @__PURE__ */ new Set([
|
|
|
1422
1423
|
}
|
|
1423
1424
|
}
|
|
1424
1425
|
]
|
|
1425
|
-
}),
|
|
1426
|
+
}), Co = () => ({
|
|
1426
1427
|
export: (r) => r.text,
|
|
1427
1428
|
import: (r) => ({
|
|
1428
1429
|
text: r,
|
|
1429
1430
|
style: "unordered",
|
|
1430
1431
|
checked: !1
|
|
1431
1432
|
})
|
|
1432
|
-
}),
|
|
1433
|
+
}), Mt = [
|
|
1433
1434
|
{
|
|
1434
1435
|
name: "bulletedList",
|
|
1435
1436
|
titleKey: "bulletedList",
|
|
1436
1437
|
style: "unordered",
|
|
1437
|
-
icon:
|
|
1438
|
+
icon: se
|
|
1438
1439
|
},
|
|
1439
1440
|
{
|
|
1440
1441
|
name: "numberedList",
|
|
1441
1442
|
titleKey: "numberedList",
|
|
1442
1443
|
style: "ordered",
|
|
1443
|
-
icon:
|
|
1444
|
+
icon: ie
|
|
1444
1445
|
},
|
|
1445
1446
|
{
|
|
1446
1447
|
name: "todoList",
|
|
1447
1448
|
titleKey: "todoList",
|
|
1448
1449
|
style: "checklist",
|
|
1449
|
-
icon:
|
|
1450
|
+
icon: re
|
|
1450
1451
|
}
|
|
1451
|
-
],
|
|
1452
|
+
], yo = () => [
|
|
1452
1453
|
{
|
|
1453
|
-
icon:
|
|
1454
|
+
icon: se,
|
|
1454
1455
|
title: "Bulleted list",
|
|
1455
1456
|
titleKey: "bulletedList",
|
|
1456
1457
|
data: { style: "unordered" },
|
|
@@ -1459,7 +1460,7 @@ const oo = (r) => r instanceof HTMLElement, so = /* @__PURE__ */ new Set([
|
|
|
1459
1460
|
shortcut: "-"
|
|
1460
1461
|
},
|
|
1461
1462
|
{
|
|
1462
|
-
icon:
|
|
1463
|
+
icon: ie,
|
|
1463
1464
|
title: "Numbered list",
|
|
1464
1465
|
titleKey: "numberedList",
|
|
1465
1466
|
data: { style: "ordered" },
|
|
@@ -1468,7 +1469,7 @@ const oo = (r) => r instanceof HTMLElement, so = /* @__PURE__ */ new Set([
|
|
|
1468
1469
|
shortcut: "1."
|
|
1469
1470
|
},
|
|
1470
1471
|
{
|
|
1471
|
-
icon:
|
|
1472
|
+
icon: re,
|
|
1472
1473
|
title: "To-do list",
|
|
1473
1474
|
titleKey: "todoList",
|
|
1474
1475
|
data: { style: "checklist" },
|
|
@@ -1477,22 +1478,22 @@ const oo = (r) => r instanceof HTMLElement, so = /* @__PURE__ */ new Set([
|
|
|
1477
1478
|
shortcut: "[]"
|
|
1478
1479
|
}
|
|
1479
1480
|
];
|
|
1480
|
-
class
|
|
1481
|
+
class Ns {
|
|
1481
1482
|
constructor({ data: t, config: e, api: n, readOnly: o, block: s }) {
|
|
1482
1483
|
this._element = null, this.handleBlockChanged = (i) => {
|
|
1483
1484
|
var l;
|
|
1484
1485
|
this.isBlockChangedEventPayload(i) && (i.event.type === "block-removed" || i.event.type === "block-added") && ((l = this.markerManager) == null || l.scheduleUpdateAll());
|
|
1485
|
-
}, this.api = n, this.readOnly = o, this._settings = e || {}, this._data = this.normalizeData(t), this.depthValidator = new
|
|
1486
|
+
}, this.api = n, this.readOnly = o, this._settings = e || {}, this._data = this.normalizeData(t), this.depthValidator = new ge(n.blocks), this.markerCalculator = new be(n.blocks), this.markerManager = this._data.style === "ordered" ? new ro(n.blocks) : null, s && (this.blockId = s.id), this._data.style === "ordered" && this.api.events.on("block changed", this.handleBlockChanged);
|
|
1486
1487
|
}
|
|
1487
1488
|
isBlockChangedEventPayload(t) {
|
|
1488
1489
|
return typeof t == "object" && t !== null && "event" in t && typeof t.event == "object" && t.event !== null && "type" in t.event && typeof t.event.type == "string";
|
|
1489
1490
|
}
|
|
1490
1491
|
normalizeData(t) {
|
|
1491
|
-
return
|
|
1492
|
+
return Vn(t, this._settings);
|
|
1492
1493
|
}
|
|
1493
1494
|
get availableStyles() {
|
|
1494
1495
|
const t = this._settings.styles;
|
|
1495
|
-
return !t || t.length === 0 ?
|
|
1496
|
+
return !t || t.length === 0 ? Mt : Mt.filter((e) => t.includes(e.style));
|
|
1496
1497
|
}
|
|
1497
1498
|
get itemColor() {
|
|
1498
1499
|
return this._settings.itemColor;
|
|
@@ -1501,13 +1502,13 @@ class xs {
|
|
|
1501
1502
|
return this._settings.itemSize;
|
|
1502
1503
|
}
|
|
1503
1504
|
get placeholder() {
|
|
1504
|
-
return this.api.i18n.t(
|
|
1505
|
+
return this.api.i18n.t(Sn);
|
|
1505
1506
|
}
|
|
1506
1507
|
setupItemPlaceholder(t) {
|
|
1507
|
-
this.readOnly ||
|
|
1508
|
+
this.readOnly || kt(t, this.placeholder);
|
|
1508
1509
|
}
|
|
1509
1510
|
render() {
|
|
1510
|
-
return this._element =
|
|
1511
|
+
return this._element = oo({
|
|
1511
1512
|
data: this._data,
|
|
1512
1513
|
readOnly: this.readOnly,
|
|
1513
1514
|
placeholder: this.placeholder,
|
|
@@ -1537,7 +1538,7 @@ class xs {
|
|
|
1537
1538
|
e !== n && this.adjustDepthTo(n);
|
|
1538
1539
|
}
|
|
1539
1540
|
adjustDepthTo(t) {
|
|
1540
|
-
|
|
1541
|
+
Kn(this._element, this._data, t);
|
|
1541
1542
|
}
|
|
1542
1543
|
removed() {
|
|
1543
1544
|
this._data.style === "ordered" && (this.api.events.off("block changed", this.handleBlockChanged), requestAnimationFrame(() => {
|
|
@@ -1545,30 +1546,30 @@ class xs {
|
|
|
1545
1546
|
}));
|
|
1546
1547
|
}
|
|
1547
1548
|
updateAllOrderedListMarkers() {
|
|
1548
|
-
|
|
1549
|
+
Jn(this.api.blocks, this.depthValidator, this.markerCalculator);
|
|
1549
1550
|
}
|
|
1550
1551
|
updateMarker() {
|
|
1551
1552
|
var s;
|
|
1552
1553
|
const t = (s = this._element) == null ? void 0 : s.querySelector("[data-list-marker]");
|
|
1553
1554
|
if (!t)
|
|
1554
1555
|
return;
|
|
1555
|
-
const e = this.getDepth(), n =
|
|
1556
|
+
const e = this.getDepth(), n = Nt(this.blockId, e, this._data.style, this.api.blocks, this.markerCalculator), o = Ot(n, e, this._data, this.blockId, this.api.blocks, this.markerCalculator);
|
|
1556
1557
|
t.textContent = o;
|
|
1557
1558
|
}
|
|
1558
1559
|
updateSiblingListMarkers() {
|
|
1559
1560
|
var i;
|
|
1560
|
-
const t = this.blockId ? (i = this.api.blocks.getBlockIndex(this.blockId)) != null ? i : this.api.blocks.getCurrentBlockIndex() : this.api.blocks.getCurrentBlockIndex(), e = this.getDepth(), n = this._data.style, o = this.api.blocks.getBlocksCount(), s =
|
|
1561
|
-
|
|
1561
|
+
const t = this.blockId ? (i = this.api.blocks.getBlockIndex(this.blockId)) != null ? i : this.api.blocks.getCurrentBlockIndex() : this.api.blocks.getCurrentBlockIndex(), e = this.getDepth(), n = this._data.style, o = this.api.blocks.getBlocksCount(), s = Yn(t, e, n, this.markerCalculator);
|
|
1562
|
+
Zn(s, o, t, e, n, this.api.blocks, this.depthValidator, this.markerCalculator);
|
|
1562
1563
|
}
|
|
1563
1564
|
updateMarkerForDepth(t, e) {
|
|
1564
1565
|
var o;
|
|
1565
1566
|
const n = (o = this._element) == null ? void 0 : o.querySelector('[aria-hidden="true"]');
|
|
1566
1567
|
if (n instanceof HTMLElement)
|
|
1567
1568
|
if (e === "ordered") {
|
|
1568
|
-
const s =
|
|
1569
|
+
const s = Nt(this.blockId, t, this._data.style, this.api.blocks, this.markerCalculator), i = Ot(s, t, this._data, this.blockId, this.api.blocks, this.markerCalculator);
|
|
1569
1570
|
n.textContent = i;
|
|
1570
1571
|
} else {
|
|
1571
|
-
const s =
|
|
1572
|
+
const s = jn(t, this.markerCalculator);
|
|
1572
1573
|
n.textContent = s;
|
|
1573
1574
|
}
|
|
1574
1575
|
}
|
|
@@ -1608,7 +1609,7 @@ class xs {
|
|
|
1608
1609
|
syncContentFromDOM: this.syncContentFromDOM.bind(this),
|
|
1609
1610
|
getDepth: this.getDepth.bind(this)
|
|
1610
1611
|
};
|
|
1611
|
-
await
|
|
1612
|
+
await Qn(t);
|
|
1612
1613
|
}
|
|
1613
1614
|
async handleBackspace(t) {
|
|
1614
1615
|
const e = {
|
|
@@ -1620,7 +1621,7 @@ class xs {
|
|
|
1620
1621
|
syncContentFromDOM: this.syncContentFromDOM.bind(this),
|
|
1621
1622
|
getDepth: this.getDepth.bind(this)
|
|
1622
1623
|
};
|
|
1623
|
-
await
|
|
1624
|
+
await eo(e, t);
|
|
1624
1625
|
}
|
|
1625
1626
|
async handleIndent() {
|
|
1626
1627
|
const t = {
|
|
@@ -1632,7 +1633,7 @@ class xs {
|
|
|
1632
1633
|
syncContentFromDOM: this.syncContentFromDOM.bind(this),
|
|
1633
1634
|
getDepth: this.getDepth.bind(this)
|
|
1634
1635
|
};
|
|
1635
|
-
await
|
|
1636
|
+
await no(t, this.depthValidator);
|
|
1636
1637
|
}
|
|
1637
1638
|
async handleOutdent() {
|
|
1638
1639
|
const t = {
|
|
@@ -1644,7 +1645,7 @@ class xs {
|
|
|
1644
1645
|
syncContentFromDOM: this.syncContentFromDOM.bind(this),
|
|
1645
1646
|
getDepth: this.getDepth.bind(this)
|
|
1646
1647
|
};
|
|
1647
|
-
await
|
|
1648
|
+
await ye(t);
|
|
1648
1649
|
}
|
|
1649
1650
|
syncContentFromDOM() {
|
|
1650
1651
|
var n;
|
|
@@ -1655,10 +1656,10 @@ class xs {
|
|
|
1655
1656
|
e instanceof HTMLInputElement && (this._data.checked = e.checked);
|
|
1656
1657
|
}
|
|
1657
1658
|
getContentElement() {
|
|
1658
|
-
return
|
|
1659
|
+
return Un(this._element, this._data.style);
|
|
1659
1660
|
}
|
|
1660
1661
|
renderSettings() {
|
|
1661
|
-
return
|
|
1662
|
+
return In(this.availableStyles, this._data.style, this.api.i18n.t, (t) => this.setStyle(t));
|
|
1662
1663
|
}
|
|
1663
1664
|
setStyle(t) {
|
|
1664
1665
|
const e = this._data.style;
|
|
@@ -1667,7 +1668,7 @@ class xs {
|
|
|
1667
1668
|
});
|
|
1668
1669
|
}
|
|
1669
1670
|
rerender() {
|
|
1670
|
-
const t =
|
|
1671
|
+
const t = Tn({
|
|
1671
1672
|
data: this._data,
|
|
1672
1673
|
readOnly: this.readOnly,
|
|
1673
1674
|
placeholder: this.placeholder,
|
|
@@ -1686,10 +1687,10 @@ class xs {
|
|
|
1686
1687
|
return typeof t.text == "string";
|
|
1687
1688
|
}
|
|
1688
1689
|
save() {
|
|
1689
|
-
return
|
|
1690
|
+
return Bn(this._data, this._element, this.getContentElement.bind(this));
|
|
1690
1691
|
}
|
|
1691
1692
|
setData(t) {
|
|
1692
|
-
const e =
|
|
1693
|
+
const e = Rn(
|
|
1693
1694
|
this._data,
|
|
1694
1695
|
t,
|
|
1695
1696
|
this._element,
|
|
@@ -1703,35 +1704,35 @@ class xs {
|
|
|
1703
1704
|
return this._data = e.newData, e.inPlace;
|
|
1704
1705
|
}
|
|
1705
1706
|
merge(t) {
|
|
1706
|
-
|
|
1707
|
+
Ln(
|
|
1707
1708
|
{
|
|
1708
1709
|
data: this._data,
|
|
1709
1710
|
element: this._element,
|
|
1710
1711
|
getContentElement: this.getContentElement.bind(this),
|
|
1711
|
-
parseHTML:
|
|
1712
|
+
parseHTML: On
|
|
1712
1713
|
},
|
|
1713
1714
|
t
|
|
1714
1715
|
);
|
|
1715
1716
|
}
|
|
1716
1717
|
static get conversionConfig() {
|
|
1717
|
-
return
|
|
1718
|
+
return Co();
|
|
1718
1719
|
}
|
|
1719
1720
|
static get sanitize() {
|
|
1720
|
-
return
|
|
1721
|
+
return fo();
|
|
1721
1722
|
}
|
|
1722
1723
|
static get pasteConfig() {
|
|
1723
|
-
return
|
|
1724
|
+
return mo();
|
|
1724
1725
|
}
|
|
1725
1726
|
onPaste(t) {
|
|
1726
1727
|
const e = t.detail;
|
|
1727
1728
|
if (!("data" in e)) return;
|
|
1728
1729
|
const n = e.data;
|
|
1729
|
-
if (!
|
|
1730
|
+
if (!lo(n))
|
|
1730
1731
|
return;
|
|
1731
|
-
const { text: o, checked: s } =
|
|
1732
|
+
const { text: o, checked: s } = po(n), i = go(n);
|
|
1732
1733
|
this._data = {
|
|
1733
1734
|
text: o,
|
|
1734
|
-
style:
|
|
1735
|
+
style: uo(n, this._data.style),
|
|
1735
1736
|
checked: s,
|
|
1736
1737
|
depth: i
|
|
1737
1738
|
}, this.rerender();
|
|
@@ -1740,19 +1741,19 @@ class xs {
|
|
|
1740
1741
|
return !0;
|
|
1741
1742
|
}
|
|
1742
1743
|
getContentOffset(t) {
|
|
1743
|
-
return
|
|
1744
|
+
return Pn(t);
|
|
1744
1745
|
}
|
|
1745
1746
|
static get toolbox() {
|
|
1746
|
-
return
|
|
1747
|
+
return yo();
|
|
1747
1748
|
}
|
|
1748
1749
|
}
|
|
1749
|
-
const
|
|
1750
|
+
const bo = "data-blok-table-add-row", vo = "data-blok-table-add-col", _t = 150, So = 5, Wt = 40, Gt = [
|
|
1750
1751
|
"flex",
|
|
1751
1752
|
"items-center",
|
|
1752
1753
|
"justify-center",
|
|
1753
1754
|
"transition-opacity",
|
|
1754
1755
|
"duration-150"
|
|
1755
|
-
],
|
|
1756
|
+
], $t = [
|
|
1756
1757
|
"flex",
|
|
1757
1758
|
"items-center",
|
|
1758
1759
|
"justify-center",
|
|
@@ -1760,20 +1761,31 @@ const fo = "data-blok-table-add-row", mo = "data-blok-table-add-col", Nt = 150,
|
|
|
1760
1761
|
"border-gray-300",
|
|
1761
1762
|
"rounded-full",
|
|
1762
1763
|
"group-hover/add:bg-gray-50"
|
|
1763
|
-
],
|
|
1764
|
-
class
|
|
1764
|
+
], qt = "12";
|
|
1765
|
+
class wo {
|
|
1765
1766
|
constructor(t) {
|
|
1766
|
-
this.rowHideTimeout = null, this.colHideTimeout = null, this.rowVisible = !1, this.colVisible = !1, this.interactive = !0, this.dragState = null, this.wrapper = t.wrapper, this.grid = t.grid, this.i18n = t.i18n, this.boundAddRowClick = t.onAddRow, this.boundAddColClick = t.onAddColumn, this.onDragStart = t.onDragStart, this.onDragAddRow = t.onDragAddRow, this.onDragRemoveRow = t.onDragRemoveRow, this.onDragAddCol = t.onDragAddCol, this.onDragRemoveCol = t.onDragRemoveCol, this.onDragEnd = t.onDragEnd, this.getNewColumnWidth = t.getNewColumnWidth, this.boundMouseMove = this.handleMouseMove.bind(this), this.boundMouseLeave = this.handleMouseLeave.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.boundPointerCancel = this.handlePointerCancel.bind(this), this.boundRowPointerDown = (e) => this.handlePointerDown("row", e), this.boundColPointerDown = (e) => this.handlePointerDown("col", e), this.addRowBtn = this.createAddRowButton(), this.addColBtn = this.createAddColumnButton(), this.wrapper.appendChild(this.addRowBtn), this.
|
|
1767
|
+
this.rowHideTimeout = null, this.colHideTimeout = null, this.rowVisible = !1, this.colVisible = !1, this.interactive = !0, this.dragState = null, this.wrapper = t.wrapper, this.grid = t.grid, this.i18n = t.i18n, this.boundAddRowClick = t.onAddRow, this.boundAddColClick = t.onAddColumn, this.onDragStart = t.onDragStart, this.onDragAddRow = t.onDragAddRow, this.onDragRemoveRow = t.onDragRemoveRow, this.onDragAddCol = t.onDragAddCol, this.onDragRemoveCol = t.onDragRemoveCol, this.onDragEnd = t.onDragEnd, this.getNewColumnWidth = t.getNewColumnWidth, this.boundMouseMove = this.handleMouseMove.bind(this), this.boundMouseLeave = this.handleMouseLeave.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.boundPointerCancel = this.handlePointerCancel.bind(this), this.boundRowPointerDown = (e) => this.handlePointerDown("row", e), this.boundColPointerDown = (e) => this.handlePointerDown("col", e), this.addRowBtn = this.createAddRowButton(), this.addColBtn = this.createAddColumnButton(), this.wrapper.appendChild(this.addRowBtn), this.wrapper.appendChild(this.addColBtn), this.syncRowButtonWidth(), this.wrapper.addEventListener("mousemove", this.boundMouseMove), this.wrapper.addEventListener("mouseleave", this.boundMouseLeave), this.addRowBtn.addEventListener("pointerdown", this.boundRowPointerDown), this.addColBtn.addEventListener("pointerdown", this.boundColPointerDown);
|
|
1767
1768
|
}
|
|
1768
1769
|
/**
|
|
1769
|
-
* Match the add-row button width to the grid
|
|
1770
|
-
*
|
|
1771
|
-
*
|
|
1772
|
-
*
|
|
1770
|
+
* Match the add-row button width and horizontal position to the grid.
|
|
1771
|
+
*
|
|
1772
|
+
* Pixel mode (colWidths set): clamp to the scroll container's visible
|
|
1773
|
+
* width so the button never overflows the table boundary.
|
|
1774
|
+
*
|
|
1775
|
+
* Percent mode (no colWidths): clear `width` and use `left`/`right`
|
|
1776
|
+
* constraints so the browser auto-sizes the button to the wrapper's
|
|
1777
|
+
* content area, avoiding the wrapper's right padding.
|
|
1773
1778
|
*/
|
|
1774
1779
|
syncRowButtonWidth() {
|
|
1775
1780
|
const t = this.grid.style.width;
|
|
1776
|
-
|
|
1781
|
+
if (t && t.endsWith("px")) {
|
|
1782
|
+
const e = parseFloat(t), n = this.grid.parentElement, s = n !== null && n !== this.wrapper && n.clientWidth > 0 ? Math.min(e, n.clientWidth) : e;
|
|
1783
|
+
this.addRowBtn.style.width = `${s}px`, this.addRowBtn.style.right = "", this.addRowBtn.style.left = "0px", this.addRowBtn.style.transform = "", this.addColBtn.style.left = `${s}px`, this.addColBtn.style.right = "";
|
|
1784
|
+
} else {
|
|
1785
|
+
this.addRowBtn.style.width = "", this.addRowBtn.style.left = "0px", this.addRowBtn.style.transform = "";
|
|
1786
|
+
const e = parseFloat(getComputedStyle(this.wrapper).paddingRight) || 0;
|
|
1787
|
+
this.addRowBtn.style.right = `${e}px`, this.addColBtn.style.left = "", this.addColBtn.style.right = "-16px";
|
|
1788
|
+
}
|
|
1777
1789
|
}
|
|
1778
1790
|
/**
|
|
1779
1791
|
* Toggle display of both add buttons.
|
|
@@ -1823,7 +1835,7 @@ class yo {
|
|
|
1823
1835
|
e === "row" ? this.onDragAddRow() : this.onDragAddCol(), this.dragState.addedCount++;
|
|
1824
1836
|
for (; this.dragState.addedCount > l; )
|
|
1825
1837
|
e === "row" ? this.onDragRemoveRow() : this.onDragRemoveCol(), this.dragState.addedCount--;
|
|
1826
|
-
Math.abs(i) >
|
|
1838
|
+
Math.abs(i) > So && !this.dragState.didDrag && (this.dragState.didDrag = !0, document.body.style.cursor = e === "row" ? "row-resize" : "col-resize", ze(), this.onDragStart());
|
|
1827
1839
|
}
|
|
1828
1840
|
handlePointerUp(t) {
|
|
1829
1841
|
if (!this.dragState)
|
|
@@ -1859,8 +1871,8 @@ class yo {
|
|
|
1859
1871
|
return (o == null ? void 0 : o.offsetWidth) || 100;
|
|
1860
1872
|
}
|
|
1861
1873
|
handleMouseMove(t) {
|
|
1862
|
-
const e = this.grid.getBoundingClientRect(), n = Math.abs(t.clientY - e.bottom),
|
|
1863
|
-
|
|
1874
|
+
const e = this.grid.getBoundingClientRect(), n = this.grid.parentElement, s = n !== null && n !== this.wrapper ? Math.min(e.right, n.getBoundingClientRect().right) : e.right, i = Math.abs(t.clientY - e.bottom), l = Math.abs(t.clientX - s);
|
|
1875
|
+
i <= Wt ? this.showRow() : this.scheduleHideRow(), l <= Wt ? this.showCol() : this.scheduleHideCol();
|
|
1864
1876
|
}
|
|
1865
1877
|
handleMouseLeave() {
|
|
1866
1878
|
this.scheduleHideRow(), this.scheduleHideCol();
|
|
@@ -1875,13 +1887,13 @@ class yo {
|
|
|
1875
1887
|
var t;
|
|
1876
1888
|
!this.rowVisible || this.rowHideTimeout !== null || ((t = this.dragState) == null ? void 0 : t.axis) === "row" || (this.rowHideTimeout = setTimeout(() => {
|
|
1877
1889
|
this.addRowBtn.style.opacity = "0", this.addRowBtn.style.pointerEvents = "none", this.rowVisible = !1, this.rowHideTimeout = null;
|
|
1878
|
-
},
|
|
1890
|
+
}, _t));
|
|
1879
1891
|
}
|
|
1880
1892
|
scheduleHideCol() {
|
|
1881
1893
|
var t;
|
|
1882
1894
|
!this.colVisible || this.colHideTimeout !== null || ((t = this.dragState) == null ? void 0 : t.axis) === "col" || (this.colHideTimeout = setTimeout(() => {
|
|
1883
1895
|
this.addColBtn.style.opacity = "0", this.addColBtn.style.pointerEvents = "none", this.colVisible = !1, this.colHideTimeout = null;
|
|
1884
|
-
},
|
|
1896
|
+
}, _t));
|
|
1885
1897
|
}
|
|
1886
1898
|
clearRowTimeout() {
|
|
1887
1899
|
this.rowHideTimeout !== null && (clearTimeout(this.rowHideTimeout), this.rowHideTimeout = null);
|
|
@@ -1891,31 +1903,31 @@ class yo {
|
|
|
1891
1903
|
}
|
|
1892
1904
|
createAddRowButton() {
|
|
1893
1905
|
const t = document.createElement("div");
|
|
1894
|
-
t.className =
|
|
1906
|
+
t.className = v(Gt, "group/add", "items-start", "cursor-row-resize"), t.setAttribute(bo, ""), t.setAttribute("contenteditable", "false"), t.style.opacity = "0", t.style.pointerEvents = "none", t.style.position = "absolute", t.style.left = "0", t.style.bottom = "-36px", t.style.zIndex = "1", t.style.height = "32px";
|
|
1895
1907
|
const e = document.createElement("div");
|
|
1896
|
-
return e.className =
|
|
1908
|
+
return e.className = v($t), e.style.width = "100%", e.style.height = "16px", this.appendIcon(e), t.appendChild(e), Tt(t, Bt([
|
|
1897
1909
|
this.i18n.t("tools.table.clickToAddRow"),
|
|
1898
1910
|
this.i18n.t("tools.table.dragToAddRemoveRows")
|
|
1899
1911
|
]), { placement: "bottom", marginTop: -16 }), t;
|
|
1900
1912
|
}
|
|
1901
1913
|
createAddColumnButton() {
|
|
1902
1914
|
const t = document.createElement("div");
|
|
1903
|
-
t.className =
|
|
1915
|
+
t.className = v(Gt, "group/add", "justify-start", "cursor-col-resize"), t.setAttribute(vo, ""), t.setAttribute("contenteditable", "false"), t.style.opacity = "0", t.style.pointerEvents = "none", t.style.position = "absolute", t.style.right = "-16px", t.style.top = "0px", t.style.bottom = "0px", t.style.width = "32px";
|
|
1904
1916
|
const e = document.createElement("div");
|
|
1905
|
-
return e.className =
|
|
1917
|
+
return e.className = v($t), e.style.width = "16px", e.style.height = "100%", this.appendIcon(e), t.appendChild(e), Tt(t, Bt([
|
|
1906
1918
|
this.i18n.t("tools.table.clickToAddColumn"),
|
|
1907
1919
|
this.i18n.t("tools.table.dragToAddRemoveColumns")
|
|
1908
1920
|
]), { placement: "bottom" }), t;
|
|
1909
1921
|
}
|
|
1910
1922
|
appendIcon(t) {
|
|
1911
|
-
t.insertAdjacentHTML("beforeend",
|
|
1923
|
+
t.insertAdjacentHTML("beforeend", Ve);
|
|
1912
1924
|
const e = t.querySelector("svg");
|
|
1913
|
-
e && (e.setAttribute("width",
|
|
1925
|
+
e && (e.setAttribute("width", qt), e.setAttribute("height", qt), e.setAttribute("viewBox", "0 0 24 24"), e.classList.add("text-gray-500", "pointer-events-none"));
|
|
1914
1926
|
}
|
|
1915
1927
|
}
|
|
1916
|
-
const
|
|
1928
|
+
const m = "data-blok-table-row", g = "data-blok-table-cell", M = 1, st = `${M}px solid #d1d5db`, ko = [
|
|
1917
1929
|
"flex"
|
|
1918
|
-
],
|
|
1930
|
+
], Ao = [
|
|
1919
1931
|
"py-1",
|
|
1920
1932
|
"px-2",
|
|
1921
1933
|
"min-h-[2em]",
|
|
@@ -1923,11 +1935,11 @@ const f = "data-blok-table-row", g = "data-blok-table-cell", M = 1, st = `${M}px
|
|
|
1923
1935
|
"leading-normal",
|
|
1924
1936
|
"text-sm",
|
|
1925
1937
|
"cursor-text"
|
|
1926
|
-
],
|
|
1938
|
+
], Eo = (r) => {
|
|
1927
1939
|
const t = Math.round(100 / r * 100) / 100;
|
|
1928
1940
|
return Array.from({ length: r }, () => t);
|
|
1929
1941
|
};
|
|
1930
|
-
class
|
|
1942
|
+
class xo {
|
|
1931
1943
|
constructor(t) {
|
|
1932
1944
|
this.readOnly = t.readOnly;
|
|
1933
1945
|
}
|
|
@@ -1937,7 +1949,7 @@ class So {
|
|
|
1937
1949
|
createGrid(t, e, n) {
|
|
1938
1950
|
const o = document.createElement("div");
|
|
1939
1951
|
o.style.borderTop = st, o.style.borderLeft = st;
|
|
1940
|
-
const s = n != null ? n :
|
|
1952
|
+
const s = n != null ? n : Eo(e);
|
|
1941
1953
|
return Array.from({ length: t }).forEach(() => {
|
|
1942
1954
|
o.appendChild(this.createRow(e, s));
|
|
1943
1955
|
}), o;
|
|
@@ -1953,14 +1965,14 @@ class So {
|
|
|
1953
1965
|
* Otherwise appends at the end.
|
|
1954
1966
|
*/
|
|
1955
1967
|
addRow(t, e) {
|
|
1956
|
-
const n = this.getColumnCount(t), o = this.getRawCellWidths(t), s = this.createRow(n, o), i = t.querySelectorAll(`[${
|
|
1968
|
+
const n = this.getColumnCount(t), o = this.getRawCellWidths(t), s = this.createRow(n, o), i = t.querySelectorAll(`[${m}]`);
|
|
1957
1969
|
return e !== void 0 && e < i.length ? t.insertBefore(s, i[e]) : t.appendChild(s), s;
|
|
1958
1970
|
}
|
|
1959
1971
|
/**
|
|
1960
1972
|
* Delete a row at index
|
|
1961
1973
|
*/
|
|
1962
1974
|
deleteRow(t, e) {
|
|
1963
|
-
const n = t.querySelectorAll(`[${
|
|
1975
|
+
const n = t.querySelectorAll(`[${m}]`);
|
|
1964
1976
|
e < n.length && n[e].remove();
|
|
1965
1977
|
}
|
|
1966
1978
|
/**
|
|
@@ -1972,7 +1984,7 @@ class So {
|
|
|
1972
1984
|
* existing columns from shrinking when the table is in percent mode.
|
|
1973
1985
|
*/
|
|
1974
1986
|
addColumn(t, e, n, o) {
|
|
1975
|
-
const s = t.querySelectorAll(`[${
|
|
1987
|
+
const s = t.querySelectorAll(`[${m}]`), i = this.getColumnCount(t), l = n !== void 0 && n.length === i, a = l || this.detectWidthUnit(t) === "px";
|
|
1976
1988
|
return l && this.convertToPixelWidths(s, n), a ? (this.addColumnPx(s, i, e, o), !0) : (this.addColumnPercent(s, i, e), !0);
|
|
1977
1989
|
}
|
|
1978
1990
|
/**
|
|
@@ -2016,8 +2028,8 @@ class So {
|
|
|
2016
2028
|
const s = 1 - 0.5 / e;
|
|
2017
2029
|
t.forEach((i) => {
|
|
2018
2030
|
i.querySelectorAll(`[${g}]`).forEach((u) => {
|
|
2019
|
-
const p = u,
|
|
2020
|
-
p.style.width = `${
|
|
2031
|
+
const p = u, C = parseFloat(p.style.width) || 100 / e, f = Math.round(C * s * 100) / 100;
|
|
2032
|
+
p.style.width = `${f}%`;
|
|
2021
2033
|
});
|
|
2022
2034
|
const a = Math.round(100 / e / 2 * 100) / 100, c = i.querySelectorAll(`[${g}]`), d = n === void 0 || n >= c.length, h = this.createCell(`${a}%`);
|
|
2023
2035
|
if (!d) {
|
|
@@ -2031,7 +2043,7 @@ class So {
|
|
|
2031
2043
|
* Delete a column at index
|
|
2032
2044
|
*/
|
|
2033
2045
|
deleteColumn(t, e) {
|
|
2034
|
-
t.querySelectorAll(`[${
|
|
2046
|
+
t.querySelectorAll(`[${m}]`).forEach((o) => {
|
|
2035
2047
|
const s = o.querySelectorAll(`[${g}]`);
|
|
2036
2048
|
e >= s.length || s[e].remove();
|
|
2037
2049
|
});
|
|
@@ -2043,12 +2055,12 @@ class So {
|
|
|
2043
2055
|
moveRow(t, e, n) {
|
|
2044
2056
|
if (e === n)
|
|
2045
2057
|
return;
|
|
2046
|
-
const o = Array.from(t.querySelectorAll(`[${
|
|
2058
|
+
const o = Array.from(t.querySelectorAll(`[${m}]`));
|
|
2047
2059
|
if (e >= o.length || n >= o.length)
|
|
2048
2060
|
return;
|
|
2049
2061
|
const s = o[e];
|
|
2050
2062
|
s.remove();
|
|
2051
|
-
const i = Array.from(t.querySelectorAll(`[${
|
|
2063
|
+
const i = Array.from(t.querySelectorAll(`[${m}]`));
|
|
2052
2064
|
n >= i.length ? t.appendChild(s) : t.insertBefore(s, i[n]);
|
|
2053
2065
|
}
|
|
2054
2066
|
/**
|
|
@@ -2058,7 +2070,7 @@ class So {
|
|
|
2058
2070
|
moveColumn(t, e, n) {
|
|
2059
2071
|
if (e === n)
|
|
2060
2072
|
return;
|
|
2061
|
-
t.querySelectorAll(`[${
|
|
2073
|
+
t.querySelectorAll(`[${m}]`).forEach((s) => {
|
|
2062
2074
|
const i = Array.from(s.querySelectorAll(`[${g}]`));
|
|
2063
2075
|
if (e >= i.length || n >= i.length)
|
|
2064
2076
|
return;
|
|
@@ -2072,20 +2084,20 @@ class So {
|
|
|
2072
2084
|
* Get number of rows
|
|
2073
2085
|
*/
|
|
2074
2086
|
getRowCount(t) {
|
|
2075
|
-
return t.querySelectorAll(`[${
|
|
2087
|
+
return t.querySelectorAll(`[${m}]`).length;
|
|
2076
2088
|
}
|
|
2077
2089
|
/**
|
|
2078
2090
|
* Get number of columns (from first row)
|
|
2079
2091
|
*/
|
|
2080
2092
|
getColumnCount(t) {
|
|
2081
|
-
const e = t.querySelector(`[${
|
|
2093
|
+
const e = t.querySelector(`[${m}]`);
|
|
2082
2094
|
return e ? e.querySelectorAll(`[${g}]`).length : 0;
|
|
2083
2095
|
}
|
|
2084
2096
|
/**
|
|
2085
2097
|
* Get a specific cell element
|
|
2086
2098
|
*/
|
|
2087
2099
|
getCell(t, e, n) {
|
|
2088
|
-
const o = t.querySelectorAll(`[${
|
|
2100
|
+
const o = t.querySelectorAll(`[${m}]`);
|
|
2089
2101
|
if (e >= o.length)
|
|
2090
2102
|
return null;
|
|
2091
2103
|
const s = o[e].querySelectorAll(`[${g}]`);
|
|
@@ -2095,7 +2107,7 @@ class So {
|
|
|
2095
2107
|
* Read column widths from the DOM
|
|
2096
2108
|
*/
|
|
2097
2109
|
getColWidths(t) {
|
|
2098
|
-
const e = t.querySelector(`[${
|
|
2110
|
+
const e = t.querySelector(`[${m}]`);
|
|
2099
2111
|
if (!e)
|
|
2100
2112
|
return [];
|
|
2101
2113
|
const n = e.querySelectorAll(`[${g}]`), o = [];
|
|
@@ -2108,7 +2120,7 @@ class So {
|
|
|
2108
2120
|
* Detect whether cells use 'px' or '%' widths
|
|
2109
2121
|
*/
|
|
2110
2122
|
detectWidthUnit(t) {
|
|
2111
|
-
const e = t.querySelector(`[${
|
|
2123
|
+
const e = t.querySelector(`[${m}]`);
|
|
2112
2124
|
if (!e)
|
|
2113
2125
|
return "%";
|
|
2114
2126
|
const n = e.querySelector(`[${g}]`);
|
|
@@ -2118,7 +2130,7 @@ class So {
|
|
|
2118
2130
|
* Read raw CSS width strings (e.g. "200px", "33.33%") from first row cells
|
|
2119
2131
|
*/
|
|
2120
2132
|
getRawCellWidths(t) {
|
|
2121
|
-
const e = t.querySelector(`[${
|
|
2133
|
+
const e = t.querySelector(`[${m}]`);
|
|
2122
2134
|
if (!e)
|
|
2123
2135
|
return [];
|
|
2124
2136
|
const n = e.querySelectorAll(`[${g}]`);
|
|
@@ -2129,7 +2141,7 @@ class So {
|
|
|
2129
2141
|
*/
|
|
2130
2142
|
createRow(t, e) {
|
|
2131
2143
|
const n = document.createElement("div");
|
|
2132
|
-
return n.className =
|
|
2144
|
+
return n.className = v(ko), n.setAttribute(m, ""), Array.from({ length: t }).forEach((o, s) => {
|
|
2133
2145
|
n.appendChild(this.createCell(e[s]));
|
|
2134
2146
|
}), n;
|
|
2135
2147
|
}
|
|
@@ -2138,13 +2150,13 @@ class So {
|
|
|
2138
2150
|
*/
|
|
2139
2151
|
createCell(t) {
|
|
2140
2152
|
const e = document.createElement("div");
|
|
2141
|
-
e.className =
|
|
2153
|
+
e.className = v(Ao), e.style.borderRight = st, e.style.borderBottom = st, e.style.flexShrink = "0", e.style.overflow = "hidden", e.style.overflowWrap = "break-word", t !== void 0 && (e.style.width = typeof t == "string" ? t : `${t}%`), e.setAttribute(g, "");
|
|
2142
2154
|
const n = document.createElement("div");
|
|
2143
2155
|
return n.setAttribute(R, ""), e.appendChild(n), e;
|
|
2144
2156
|
}
|
|
2145
2157
|
}
|
|
2146
2158
|
const ut = (r) => typeof r == "object" && r !== null && "blocks" in r, R = "data-blok-table-cell-blocks";
|
|
2147
|
-
class
|
|
2159
|
+
class To {
|
|
2148
2160
|
constructor(t) {
|
|
2149
2161
|
var e;
|
|
2150
2162
|
this._activeCellWithBlocks = null, this.cellsPendingCheck = /* @__PURE__ */ new Set(), this.pendingCheckScheduled = !1, this.removedBlockCells = /* @__PURE__ */ new Map(), this.deferredEvents = [], this.handleBlockMutation = (n) => {
|
|
@@ -2159,7 +2171,7 @@ class ko {
|
|
|
2159
2171
|
this.handleBlockRemoved(s);
|
|
2160
2172
|
return;
|
|
2161
2173
|
}
|
|
2162
|
-
if (o !== "block-added")
|
|
2174
|
+
if (o !== "block-added" || s.target.id === this.tableBlockId)
|
|
2163
2175
|
return;
|
|
2164
2176
|
const i = s.index;
|
|
2165
2177
|
if (i === void 0)
|
|
@@ -2172,8 +2184,16 @@ class ko {
|
|
|
2172
2184
|
const a = s.target.holder, c = a.closest(`[${R}]`);
|
|
2173
2185
|
c && this.stripPlaceholders(c);
|
|
2174
2186
|
const d = c && !this.model.findCellForBlock(s.target.id) ? c.closest(`[${g}]`) : null;
|
|
2175
|
-
if (d && this.syncBlockToModel(d, s.target.id), c
|
|
2187
|
+
if (d && this.syncBlockToModel(d, s.target.id), c)
|
|
2176
2188
|
return;
|
|
2189
|
+
if (!this.gridElement.contains(a)) {
|
|
2190
|
+
const u = this.api.blocks.getCurrentBlockIndex(), p = u >= 0 ? this.api.blocks.getBlockByIndex(u) : null;
|
|
2191
|
+
if (!(p != null && this.getOwnedCellForBlock(p.id) !== null))
|
|
2192
|
+
return;
|
|
2193
|
+
const f = this.findCellForNewBlock(i);
|
|
2194
|
+
f && (this.claimBlockForCell(f, s.target.id), this.syncBlockToModel(f, s.target.id), this.cellsPendingCheck.delete(f));
|
|
2195
|
+
return;
|
|
2196
|
+
}
|
|
2177
2197
|
const h = this.findCellForNewBlock(i);
|
|
2178
2198
|
h && (this.claimBlockForCell(h, s.target.id), this.syncBlockToModel(h, s.target.id), this.cellsPendingCheck.delete(h));
|
|
2179
2199
|
}, this.handleCellBlankSpaceClick = (n) => {
|
|
@@ -2301,7 +2321,7 @@ class ko {
|
|
|
2301
2321
|
* - If referenced blocks are missing from BlockManager, a fallback paragraph is created.
|
|
2302
2322
|
*/
|
|
2303
2323
|
initializeCells(t) {
|
|
2304
|
-
const e = this.gridElement.querySelectorAll(`[${
|
|
2324
|
+
const e = this.gridElement.querySelectorAll(`[${m}]`), n = [];
|
|
2305
2325
|
return t.forEach((o, s) => {
|
|
2306
2326
|
const i = e[s];
|
|
2307
2327
|
if (!i)
|
|
@@ -2314,12 +2334,12 @@ class ko {
|
|
|
2314
2334
|
const u = h.querySelector(`[${R}]`);
|
|
2315
2335
|
if (!u)
|
|
2316
2336
|
return;
|
|
2317
|
-
const p = ut(c) && c.blocks.length > 0 ? [...c.blocks] : null,
|
|
2318
|
-
if (
|
|
2319
|
-
a.push({ blocks: p != null ? p :
|
|
2337
|
+
const p = ut(c) && c.blocks.length > 0 ? [...c.blocks] : null, C = p ? this.mountBlocksInCell(u, p) : [];
|
|
2338
|
+
if (C.length > 0)
|
|
2339
|
+
a.push({ blocks: p != null ? p : C });
|
|
2320
2340
|
else {
|
|
2321
|
-
const
|
|
2322
|
-
for (const A of
|
|
2341
|
+
const f = typeof c == "string" ? c : "", y = f.split(/<br\s*\/?>/i).map((A) => A.trim()).filter(Boolean), S = y.length > 0 ? y : [f], k = [];
|
|
2342
|
+
for (const A of S) {
|
|
2323
2343
|
const T = this.api.blocks.insert("paragraph", { text: A }, {}, this.api.blocks.getBlocksCount(), !1);
|
|
2324
2344
|
u.appendChild(T.holder), this.api.blocks.setBlockParent(T.id, this.tableBlockId), k.push(T.id);
|
|
2325
2345
|
}
|
|
@@ -2368,7 +2388,7 @@ class ko {
|
|
|
2368
2388
|
if (o === void 0)
|
|
2369
2389
|
return;
|
|
2370
2390
|
const s = this.api.blocks.getBlockByIndex(o);
|
|
2371
|
-
s && (n.appendChild(s.holder), this.api.blocks.setBlockParent(e, this.tableBlockId), this.stripPlaceholders(n));
|
|
2391
|
+
s && (s.holder.contains(n) || (n.appendChild(s.holder), this.api.blocks.setBlockParent(e, this.tableBlockId), this.stripPlaceholders(n)));
|
|
2372
2392
|
}
|
|
2373
2393
|
/**
|
|
2374
2394
|
* Given a new block's index, find which cell it should belong to
|
|
@@ -2424,10 +2444,10 @@ class ko {
|
|
|
2424
2444
|
* Get the row/col position of a cell element within the grid.
|
|
2425
2445
|
*/
|
|
2426
2446
|
getCellPosition(t) {
|
|
2427
|
-
const e = t.closest(`[${
|
|
2447
|
+
const e = t.closest(`[${m}]`);
|
|
2428
2448
|
if (!e)
|
|
2429
2449
|
return null;
|
|
2430
|
-
const o = Array.from(this.gridElement.querySelectorAll(`[${
|
|
2450
|
+
const o = Array.from(this.gridElement.querySelectorAll(`[${m}]`)).indexOf(e);
|
|
2431
2451
|
if (o < 0)
|
|
2432
2452
|
return null;
|
|
2433
2453
|
const i = Array.from(e.querySelectorAll(`[${g}]`)).indexOf(t);
|
|
@@ -2581,21 +2601,21 @@ class ko {
|
|
|
2581
2601
|
this.deferredEvents.length = 0;
|
|
2582
2602
|
}
|
|
2583
2603
|
}
|
|
2584
|
-
const Z = 16,
|
|
2604
|
+
const Z = 16, Bo = [
|
|
2585
2605
|
[2, 2],
|
|
2586
2606
|
[8, 2],
|
|
2587
2607
|
[2, 7],
|
|
2588
2608
|
[8, 7],
|
|
2589
2609
|
[2, 12],
|
|
2590
2610
|
[8, 12]
|
|
2591
|
-
],
|
|
2611
|
+
], Ro = [
|
|
2592
2612
|
[2, 2],
|
|
2593
2613
|
[7, 2],
|
|
2594
2614
|
[12, 2],
|
|
2595
2615
|
[2, 8],
|
|
2596
2616
|
[7, 8],
|
|
2597
2617
|
[12, 8]
|
|
2598
|
-
],
|
|
2618
|
+
], ve = (r) => {
|
|
2599
2619
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg"), e = r === "horizontal";
|
|
2600
2620
|
t.setAttribute("width", e ? "14" : "10"), t.setAttribute("height", e ? "10" : "14"), t.setAttribute("viewBox", e ? "0 0 14 10" : "0 0 10 14"), t.setAttribute("fill", "currentColor"), t.classList.add(
|
|
2601
2621
|
"opacity-0",
|
|
@@ -2604,13 +2624,13 @@ const Z = 16, Ao = [
|
|
|
2604
2624
|
"text-gray-400",
|
|
2605
2625
|
"pointer-events-none"
|
|
2606
2626
|
);
|
|
2607
|
-
const n = e ?
|
|
2627
|
+
const n = e ? Ro : Bo;
|
|
2608
2628
|
for (const [o, s] of n) {
|
|
2609
2629
|
const i = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
2610
2630
|
i.setAttribute("cx", String(o)), i.setAttribute("cy", String(s)), i.setAttribute("r", "1.5"), t.appendChild(i);
|
|
2611
2631
|
}
|
|
2612
2632
|
return t;
|
|
2613
|
-
},
|
|
2633
|
+
}, Lo = (r, t) => {
|
|
2614
2634
|
t === "col" ? Object.assign(r.style, { height: `${Z}px` }) : Object.assign(r.style, { width: `${Z}px` }), r.classList.add("bg-gray-200"), r.classList.remove("bg-gray-300");
|
|
2615
2635
|
const e = r.querySelector("svg");
|
|
2616
2636
|
e && (e.classList.remove("opacity-0"), e.classList.add("opacity-100"));
|
|
@@ -2618,7 +2638,7 @@ const Z = 16, Ao = [
|
|
|
2618
2638
|
t === "col" ? Object.assign(r.style, { height: `${e}px` }) : Object.assign(r.style, { width: `${e}px` }), r.classList.remove("bg-gray-200"), r.classList.add("bg-gray-300");
|
|
2619
2639
|
const n = r.querySelector("svg");
|
|
2620
2640
|
n && (n.classList.add("opacity-0"), n.classList.remove("opacity-100"));
|
|
2621
|
-
}, mt = "data-blok-table-cell-selected",
|
|
2641
|
+
}, mt = "data-blok-table-cell-selected", Io = "2px solid #3b82f6", Ct = "data-blok-table-selection-pill", Do = 16, Ho = 20, Ft = 4, Po = [
|
|
2622
2642
|
"absolute",
|
|
2623
2643
|
"z-[3]",
|
|
2624
2644
|
"rounded",
|
|
@@ -2631,10 +2651,10 @@ const Z = 16, Ao = [
|
|
|
2631
2651
|
"overflow-hidden",
|
|
2632
2652
|
"cursor-pointer",
|
|
2633
2653
|
"bg-blue-500"
|
|
2634
|
-
],
|
|
2635
|
-
class
|
|
2654
|
+
], No = (r) => r.style.userSelect === "none";
|
|
2655
|
+
class zt {
|
|
2636
2656
|
constructor(t) {
|
|
2637
|
-
this.anchorCell = null, this.extentCell = null, this.isSelecting = !1, this.hasSelection = !1, this.selectedCells = [], this.overlay = null, this.pill = null, this.pillPopover = null, this.grid = t.grid, this.rectangleSelection = t.rectangleSelection, this.onSelectionActiveChange = t.onSelectionActiveChange, this.onClearContent = t.onClearContent, this.onCopy = t.onCopy, this.onCut = t.onCut, this.i18n = t.i18n, this.grid.style.position = "relative", this.boundPointerDown = this.handlePointerDown.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.boundClearSelection = this.handleClearSelection.bind(this), this.boundCancelRectangle = this.handleCancelRectangle.bind(this), this.boundKeyDown = this.handleKeyDown.bind(this), this.boundCopyHandler = this.handleCopy.bind(this), this.boundCutHandler = this.handleCut.bind(this), this.grid.addEventListener("pointerdown", this.boundPointerDown), document.addEventListener("keydown", this.boundKeyDown), document.addEventListener("copy", this.boundCopyHandler), document.addEventListener("cut", this.boundCutHandler);
|
|
2657
|
+
this.anchorCell = null, this.extentCell = null, this.isSelecting = !1, this.hasSelection = !1, this.selectedCells = [], this.overlay = null, this.pill = null, this.pillPopover = null, this.grid = t.grid, this.rectangleSelection = t.rectangleSelection, this.onSelectionActiveChange = t.onSelectionActiveChange, this.onClearContent = t.onClearContent, this.onCopy = t.onCopy, this.onCut = t.onCut, this.onCopyViaButton = t.onCopyViaButton, this.isPopoverOpen = t.isPopoverOpen, this.i18n = t.i18n, this.grid.style.position = "relative", this.boundPointerDown = this.handlePointerDown.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.boundClearSelection = this.handleClearSelection.bind(this), this.boundCancelRectangle = this.handleCancelRectangle.bind(this), this.boundKeyDown = this.handleKeyDown.bind(this), this.boundCopyHandler = this.handleCopy.bind(this), this.boundCutHandler = this.handleCut.bind(this), this.grid.addEventListener("pointerdown", this.boundPointerDown), document.addEventListener("keydown", this.boundKeyDown), document.addEventListener("copy", this.boundCopyHandler), document.addEventListener("cut", this.boundCutHandler);
|
|
2638
2658
|
}
|
|
2639
2659
|
destroy() {
|
|
2640
2660
|
this.destroyPillPopover(), this.clearSelection(), this.grid.removeEventListener("pointerdown", this.boundPointerDown), document.removeEventListener("pointermove", this.boundPointerMove), document.removeEventListener("pointerup", this.boundPointerUp), document.removeEventListener("pointerdown", this.boundClearSelection), document.removeEventListener("mousemove", this.boundCancelRectangle, !0), document.removeEventListener("keydown", this.boundKeyDown), document.removeEventListener("copy", this.boundCopyHandler), document.removeEventListener("cut", this.boundCutHandler);
|
|
@@ -2644,14 +2664,14 @@ class Gt {
|
|
|
2644
2664
|
*/
|
|
2645
2665
|
selectRow(t) {
|
|
2646
2666
|
var o, s;
|
|
2647
|
-
const n = (s = (o = this.grid.querySelectorAll(`[${
|
|
2667
|
+
const n = (s = (o = this.grid.querySelectorAll(`[${m}]`)[0]) == null ? void 0 : o.querySelectorAll(`[${g}]`).length) != null ? s : 0;
|
|
2648
2668
|
n !== 0 && this.showProgrammaticSelection(t, 0, t, n - 1);
|
|
2649
2669
|
}
|
|
2650
2670
|
/**
|
|
2651
2671
|
* Programmatically select an entire column.
|
|
2652
2672
|
*/
|
|
2653
2673
|
selectColumn(t) {
|
|
2654
|
-
const n = this.grid.querySelectorAll(`[${
|
|
2674
|
+
const n = this.grid.querySelectorAll(`[${m}]`).length;
|
|
2655
2675
|
n !== 0 && this.showProgrammaticSelection(0, t, n - 1, t);
|
|
2656
2676
|
}
|
|
2657
2677
|
/**
|
|
@@ -2661,7 +2681,7 @@ class Gt {
|
|
|
2661
2681
|
this.clearSelection();
|
|
2662
2682
|
}
|
|
2663
2683
|
handlePointerDown(t) {
|
|
2664
|
-
if (
|
|
2684
|
+
if (No(this.grid) || t.button !== 0)
|
|
2665
2685
|
return;
|
|
2666
2686
|
const e = t.target;
|
|
2667
2687
|
if (e.closest("[data-blok-table-grip]") || e.closest("[data-blok-table-resize]") || e.closest(`[${Ct}]`))
|
|
@@ -2697,8 +2717,9 @@ class Gt {
|
|
|
2697
2717
|
document.removeEventListener("mousemove", this.boundCancelRectangle, !0), document.removeEventListener("pointermove", this.boundPointerMove), document.removeEventListener("pointerup", this.boundPointerUp), this.isSelecting && (this.grid.style.userSelect = "", this.hasSelection = !0, document.addEventListener("pointerdown", this.boundClearSelection)), this.isSelecting = !1, this.anchorCell = null, this.extentCell = null;
|
|
2698
2718
|
}
|
|
2699
2719
|
handleClearSelection(t) {
|
|
2720
|
+
var n;
|
|
2700
2721
|
const e = t.target;
|
|
2701
|
-
e instanceof HTMLElement && e.closest(`[${Ct}]`) || this.pillPopover === null && (document.removeEventListener("pointerdown", this.boundClearSelection), this.clearSelection());
|
|
2722
|
+
e instanceof HTMLElement && e.closest(`[${Ct}]`) || this.pillPopover === null && ((n = this.isPopoverOpen) != null && n.call(this) || (document.removeEventListener("pointerdown", this.boundClearSelection), this.clearSelection()));
|
|
2702
2723
|
}
|
|
2703
2724
|
handleKeyDown(t) {
|
|
2704
2725
|
var e;
|
|
@@ -2733,20 +2754,20 @@ class Gt {
|
|
|
2733
2754
|
this.selectedCells.forEach((T) => {
|
|
2734
2755
|
T.removeAttribute(mt);
|
|
2735
2756
|
}), this.selectedCells = [];
|
|
2736
|
-
const t = Math.min(this.anchorCell.row, this.extentCell.row), e = Math.max(this.anchorCell.row, this.extentCell.row), n = Math.min(this.anchorCell.col, this.extentCell.col), o = Math.max(this.anchorCell.col, this.extentCell.col), s = this.grid.querySelectorAll(`[${
|
|
2757
|
+
const t = Math.min(this.anchorCell.row, this.extentCell.row), e = Math.max(this.anchorCell.row, this.extentCell.row), n = Math.min(this.anchorCell.col, this.extentCell.col), o = Math.max(this.anchorCell.col, this.extentCell.col), s = this.grid.querySelectorAll(`[${m}]`);
|
|
2737
2758
|
this.selectedCells = this.collectCellsInRange(s, t, e, n, o), this.selectedCells.forEach((T) => {
|
|
2738
2759
|
T.setAttribute(mt, "");
|
|
2739
2760
|
});
|
|
2740
2761
|
const i = (k = s[t]) == null ? void 0 : k.querySelectorAll(`[${g}]`)[n], l = (A = s[e]) == null ? void 0 : A.querySelectorAll(`[${g}]`)[o];
|
|
2741
2762
|
if (!i || !l)
|
|
2742
2763
|
return;
|
|
2743
|
-
const a = this.grid.getBoundingClientRect(), c = i.getBoundingClientRect(), d = l.getBoundingClientRect(), h = getComputedStyle(this.grid), u = parseFloat(h.borderTopWidth) || 0, p = parseFloat(h.borderLeftWidth) || 0,
|
|
2744
|
-
this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border =
|
|
2764
|
+
const a = this.grid.getBoundingClientRect(), c = i.getBoundingClientRect(), d = l.getBoundingClientRect(), h = getComputedStyle(this.grid), u = parseFloat(h.borderTopWidth) || 0, p = parseFloat(h.borderLeftWidth) || 0, C = d.right - c.left + 1, f = d.bottom - c.top + 1, y = c.top - a.top - u - 1, S = c.left - a.left - p - 1;
|
|
2765
|
+
this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border = Io, this.overlay.style.pointerEvents = "none", this.overlay.style.boxSizing = "border-box", this.overlay.style.borderRadius = "2px", this.grid.appendChild(this.overlay)), this.overlay.style.top = `${y}px`, this.overlay.style.left = `${S}px`, this.overlay.style.width = `${C}px`, this.overlay.style.height = `${f}px`, this.pill || (this.pill = this.createPill(), this.grid.appendChild(this.pill)), this.pill.style.left = `${S + C - 1}px`, this.pill.style.top = `${y + f / 2}px`;
|
|
2745
2766
|
}
|
|
2746
2767
|
createPill() {
|
|
2747
2768
|
const t = document.createElement("div");
|
|
2748
|
-
t.setAttribute(Ct, ""), t.setAttribute("contenteditable", "false"), t.className =
|
|
2749
|
-
const e =
|
|
2769
|
+
t.setAttribute(Ct, ""), t.setAttribute("contenteditable", "false"), t.className = v(Po), t.style.width = `${Ft}px`, t.style.height = `${Ho}px`, t.style.pointerEvents = "auto", t.style.transform = "translate(-50%, -50%)", t.style.outline = "2px solid white";
|
|
2770
|
+
const e = ve("vertical");
|
|
2750
2771
|
return e.classList.remove("text-gray-400"), e.classList.add("text-white"), t.appendChild(e), t.addEventListener("mouseenter", () => {
|
|
2751
2772
|
this.pillPopover === null && this.expandPill();
|
|
2752
2773
|
}), t.addEventListener("mouseleave", () => {
|
|
@@ -2759,36 +2780,47 @@ class Gt {
|
|
|
2759
2780
|
if (this.destroyPillPopover(), !this.pill)
|
|
2760
2781
|
return;
|
|
2761
2782
|
this.expandPill();
|
|
2762
|
-
const t = [
|
|
2783
|
+
const t = je === "Meta" ? "⌘C" : "Ctrl+C", e = [
|
|
2763
2784
|
{
|
|
2764
|
-
icon:
|
|
2785
|
+
icon: Ue,
|
|
2786
|
+
title: this.i18n.t("tools.table.copySelection"),
|
|
2787
|
+
secondaryLabel: t,
|
|
2788
|
+
closeOnActivate: !0,
|
|
2789
|
+
onActivate: () => {
|
|
2790
|
+
var n;
|
|
2791
|
+
(n = this.onCopyViaButton) == null || n.call(this, [...this.selectedCells]);
|
|
2792
|
+
}
|
|
2793
|
+
},
|
|
2794
|
+
{
|
|
2795
|
+
icon: Ke,
|
|
2765
2796
|
title: this.i18n.t("tools.table.clearSelection"),
|
|
2797
|
+
secondaryLabel: "Del",
|
|
2766
2798
|
closeOnActivate: !0,
|
|
2767
2799
|
onActivate: () => {
|
|
2768
|
-
var
|
|
2769
|
-
(
|
|
2800
|
+
var n;
|
|
2801
|
+
(n = this.onClearContent) == null || n.call(this, [...this.selectedCells]), this.clearSelection();
|
|
2770
2802
|
}
|
|
2771
2803
|
}
|
|
2772
2804
|
];
|
|
2773
|
-
this.pillPopover = new
|
|
2774
|
-
items:
|
|
2805
|
+
this.pillPopover = new le({
|
|
2806
|
+
items: e,
|
|
2775
2807
|
trigger: this.pill,
|
|
2776
2808
|
flippable: !0
|
|
2777
|
-
}), this.pillPopover.on(
|
|
2809
|
+
}), this.pillPopover.on(ae.Closed, () => {
|
|
2778
2810
|
this.pillPopover !== null && (this.destroyPillPopover(), this.collapsePill());
|
|
2779
2811
|
}), this.pillPopover.show();
|
|
2780
2812
|
}
|
|
2781
2813
|
expandPill() {
|
|
2782
2814
|
if (!this.pill)
|
|
2783
2815
|
return;
|
|
2784
|
-
this.pill.style.width = `${
|
|
2816
|
+
this.pill.style.width = `${Do}px`;
|
|
2785
2817
|
const t = this.pill.querySelector("svg");
|
|
2786
2818
|
t && (t.classList.remove("opacity-0"), t.classList.add("opacity-100"));
|
|
2787
2819
|
}
|
|
2788
2820
|
collapsePill() {
|
|
2789
2821
|
if (!this.pill)
|
|
2790
2822
|
return;
|
|
2791
|
-
this.pill.style.width = `${
|
|
2823
|
+
this.pill.style.width = `${Ft}px`;
|
|
2792
2824
|
const t = this.pill.querySelector("svg");
|
|
2793
2825
|
t && (t.classList.add("opacity-0"), t.classList.remove("opacity-100"));
|
|
2794
2826
|
}
|
|
@@ -2802,23 +2834,23 @@ class Gt {
|
|
|
2802
2834
|
const e = t.closest(`[${g}]`);
|
|
2803
2835
|
if (!e)
|
|
2804
2836
|
return null;
|
|
2805
|
-
const n = e.closest(`[${
|
|
2837
|
+
const n = e.closest(`[${m}]`);
|
|
2806
2838
|
if (!n || !this.grid.contains(n))
|
|
2807
2839
|
return null;
|
|
2808
|
-
const s = Array.from(this.grid.querySelectorAll(`[${
|
|
2840
|
+
const s = Array.from(this.grid.querySelectorAll(`[${m}]`)).indexOf(n);
|
|
2809
2841
|
if (s < 0)
|
|
2810
2842
|
return null;
|
|
2811
2843
|
const l = Array.from(n.querySelectorAll(`[${g}]`)).indexOf(e);
|
|
2812
2844
|
return l < 0 ? null : { row: s, col: l };
|
|
2813
2845
|
}
|
|
2814
2846
|
clampExtentToEdge(t) {
|
|
2815
|
-
var c, d, h, u, p,
|
|
2847
|
+
var c, d, h, u, p, C;
|
|
2816
2848
|
if (!this.anchorCell || !this.isSelecting)
|
|
2817
2849
|
return;
|
|
2818
|
-
const e = this.grid.getBoundingClientRect(), n = this.grid.querySelectorAll(`[${
|
|
2850
|
+
const e = this.grid.getBoundingClientRect(), n = this.grid.querySelectorAll(`[${m}]`), o = n.length, s = (d = (c = n[0]) == null ? void 0 : c.querySelectorAll(`[${g}]`).length) != null ? d : 0;
|
|
2819
2851
|
if (o === 0 || s === 0)
|
|
2820
2852
|
return;
|
|
2821
|
-
const i = this.clampAxis(t.clientY, e.top, e.bottom, o, (u = (h = this.extentCell) == null ? void 0 : h.row) != null ? u : this.anchorCell.row), l = this.clampAxis(t.clientX, e.left, e.right, s, (
|
|
2853
|
+
const i = this.clampAxis(t.clientY, e.top, e.bottom, o, (u = (h = this.extentCell) == null ? void 0 : h.row) != null ? u : this.anchorCell.row), l = this.clampAxis(t.clientX, e.left, e.right, s, (C = (p = this.extentCell) == null ? void 0 : p.col) != null ? C : this.anchorCell.col), a = { row: i, col: l };
|
|
2822
2854
|
(!this.extentCell || this.extentCell.row !== a.row || this.extentCell.col !== a.col) && (this.extentCell = a, this.paintSelection());
|
|
2823
2855
|
}
|
|
2824
2856
|
collectCellsInRange(t, e, n, o, s) {
|
|
@@ -2835,8 +2867,8 @@ class Gt {
|
|
|
2835
2867
|
return t < e ? 0 : t > n ? o - 1 : s;
|
|
2836
2868
|
}
|
|
2837
2869
|
}
|
|
2838
|
-
const
|
|
2839
|
-
const t = r.querySelector(`[${
|
|
2870
|
+
const z = (r) => {
|
|
2871
|
+
const t = r.querySelector(`[${m}]`);
|
|
2840
2872
|
if (!t)
|
|
2841
2873
|
return [];
|
|
2842
2874
|
const e = t.querySelectorAll(`[${g}]`);
|
|
@@ -2845,7 +2877,7 @@ const V = (r) => {
|
|
|
2845
2877
|
);
|
|
2846
2878
|
}, dt = (r, t) => {
|
|
2847
2879
|
const e = t.reduce((s, i) => s + i, 0), n = r;
|
|
2848
|
-
n.style.width = `${e + M}px`, r.querySelectorAll(`[${
|
|
2880
|
+
n.style.width = `${e + M}px`, r.querySelectorAll(`[${m}]`).forEach((s) => {
|
|
2849
2881
|
s.querySelectorAll(`[${g}]`).forEach((l, a) => {
|
|
2850
2882
|
if (a < t.length) {
|
|
2851
2883
|
const c = l;
|
|
@@ -2853,30 +2885,30 @@ const V = (r) => {
|
|
|
2853
2885
|
}
|
|
2854
2886
|
});
|
|
2855
2887
|
});
|
|
2856
|
-
},
|
|
2857
|
-
const e = Array.from(r.querySelectorAll(`[${
|
|
2888
|
+
}, Oo = (r, t) => {
|
|
2889
|
+
const e = Array.from(r.querySelectorAll(`[${m}]`)), n = e.findIndex((i) => Array.from(i.querySelectorAll(`[${g}]`)).includes(t));
|
|
2858
2890
|
if (n === -1)
|
|
2859
2891
|
return null;
|
|
2860
2892
|
const s = Array.from(e[n].querySelectorAll(`[${g}]`)).indexOf(t);
|
|
2861
2893
|
return { row: n, col: s };
|
|
2862
|
-
},
|
|
2894
|
+
}, Se = (r) => {
|
|
2863
2895
|
var e;
|
|
2864
2896
|
const t = r.querySelector(`[${R}]`);
|
|
2865
2897
|
return t ? ((e = t.textContent) != null ? e : "").trim().length === 0 : !0;
|
|
2866
|
-
},
|
|
2867
|
-
const n = r.querySelectorAll(`[${
|
|
2898
|
+
}, Mo = (r, t) => {
|
|
2899
|
+
const n = r.querySelectorAll(`[${m}]`)[t];
|
|
2868
2900
|
if (!n)
|
|
2869
2901
|
return !0;
|
|
2870
2902
|
const o = n.querySelectorAll(`[${g}]`);
|
|
2871
|
-
return Array.from(o).every((s) =>
|
|
2872
|
-
},
|
|
2873
|
-
const e = r.querySelectorAll(`[${
|
|
2903
|
+
return Array.from(o).every((s) => Se(s));
|
|
2904
|
+
}, _o = (r, t) => {
|
|
2905
|
+
const e = r.querySelectorAll(`[${m}]`);
|
|
2874
2906
|
return Array.from(e).every((n) => {
|
|
2875
2907
|
const s = n.querySelectorAll(`[${g}]`)[t];
|
|
2876
|
-
return !s ||
|
|
2908
|
+
return !s || Se(s);
|
|
2877
2909
|
});
|
|
2878
|
-
},
|
|
2879
|
-
const t = r.querySelectorAll(`[${
|
|
2910
|
+
}, Wo = (r) => {
|
|
2911
|
+
const t = r.querySelectorAll(`[${m}]`), e = t[0];
|
|
2880
2912
|
if (!e)
|
|
2881
2913
|
return;
|
|
2882
2914
|
const n = e.querySelectorAll(`[${g}]`), o = Array.from(n).reduce(
|
|
@@ -2892,51 +2924,51 @@ const V = (r) => {
|
|
|
2892
2924
|
c.style.width = `${Math.round(d * s * 100) / 100}%`;
|
|
2893
2925
|
});
|
|
2894
2926
|
});
|
|
2895
|
-
},
|
|
2927
|
+
}, Go = (r, t, e) => {
|
|
2896
2928
|
if (!r)
|
|
2897
2929
|
return r;
|
|
2898
2930
|
const n = [...r], [o] = n.splice(t, 1);
|
|
2899
2931
|
return n.splice(e, 0, o), n;
|
|
2900
|
-
},
|
|
2932
|
+
}, $o = (r, t) => {
|
|
2901
2933
|
if (!r)
|
|
2902
2934
|
return r;
|
|
2903
2935
|
const e = [...r];
|
|
2904
2936
|
return e.splice(t, 1), e.length > 0 ? e : void 0;
|
|
2905
|
-
},
|
|
2906
|
-
const s = e != null ? e :
|
|
2937
|
+
}, qo = (r, t, e, n, o) => {
|
|
2938
|
+
const s = e != null ? e : z(r), i = n !== void 0 ? Math.round(n / 2 * 100) / 100 : et(s);
|
|
2907
2939
|
o.addColumn(r, t, s, i);
|
|
2908
2940
|
const l = [...s];
|
|
2909
2941
|
return l.splice(t, 0, i), l;
|
|
2910
2942
|
}, et = (r) => Math.round(
|
|
2911
2943
|
r.reduce((t, e) => t + e, 0) / r.length / 2 * 100
|
|
2912
|
-
) / 100,
|
|
2944
|
+
) / 100, Fo = (r) => r.length === 0 ? 0 : Math.round(r.reduce((t, e) => t + e, 0) / r.length * 100) / 100, zo = (r, t, e) => {
|
|
2913
2945
|
var s;
|
|
2914
2946
|
if (!r)
|
|
2915
2947
|
return [];
|
|
2916
|
-
const o = r.querySelectorAll(`[${
|
|
2948
|
+
const o = r.querySelectorAll(`[${m}]`)[e];
|
|
2917
2949
|
return o ? (s = t == null ? void 0 : t.getBlockIdsFromCells(o.querySelectorAll(`[${g}]`))) != null ? s : [] : [];
|
|
2918
|
-
},
|
|
2950
|
+
}, Vo = (r, t, e) => {
|
|
2919
2951
|
var s;
|
|
2920
2952
|
if (!r)
|
|
2921
2953
|
return [];
|
|
2922
|
-
const n = r.querySelectorAll(`[${
|
|
2954
|
+
const n = r.querySelectorAll(`[${m}]`), o = [];
|
|
2923
2955
|
return n.forEach((i) => {
|
|
2924
2956
|
const l = i.querySelectorAll(`[${g}]`);
|
|
2925
2957
|
e < l.length && o.push(l[e]);
|
|
2926
2958
|
}), (s = t == null ? void 0 : t.getBlockIdsFromCells(o)) != null ? s : [];
|
|
2927
|
-
},
|
|
2959
|
+
}, H = (r, t) => {
|
|
2928
2960
|
r.querySelectorAll(`[${g}]`).forEach((n) => {
|
|
2929
2961
|
t == null || t.ensureCellHasBlock(n);
|
|
2930
2962
|
});
|
|
2931
|
-
},
|
|
2932
|
-
const o = r.querySelectorAll(`[${
|
|
2963
|
+
}, Uo = (r, t, e, n) => {
|
|
2964
|
+
const o = r.querySelectorAll(`[${m}]`);
|
|
2933
2965
|
t.forEach((s, i) => {
|
|
2934
2966
|
const l = o[i];
|
|
2935
2967
|
if (!l)
|
|
2936
2968
|
return;
|
|
2937
2969
|
const a = l.querySelectorAll(`[${g}]`);
|
|
2938
2970
|
s.forEach((c, d) => {
|
|
2939
|
-
var
|
|
2971
|
+
var C;
|
|
2940
2972
|
const h = a[d];
|
|
2941
2973
|
if (!h)
|
|
2942
2974
|
return;
|
|
@@ -2946,23 +2978,28 @@ const V = (r) => {
|
|
|
2946
2978
|
const p = u.querySelectorAll("[data-blok-id]").length > 0;
|
|
2947
2979
|
if (!(!ut(c) && p)) {
|
|
2948
2980
|
if (!ut(c)) {
|
|
2949
|
-
const
|
|
2950
|
-
u.textContent =
|
|
2981
|
+
const f = typeof c == "string" ? c : "";
|
|
2982
|
+
u.textContent = f;
|
|
2951
2983
|
return;
|
|
2952
2984
|
}
|
|
2953
|
-
!p && ((
|
|
2954
|
-
for (const
|
|
2955
|
-
const y = e.blocks.getBlockIndex(
|
|
2985
|
+
!p && ((C = u.textContent) != null ? C : "").length > 0 && (u.textContent = "");
|
|
2986
|
+
for (const f of c.blocks) {
|
|
2987
|
+
const y = e.blocks.getBlockIndex(f);
|
|
2956
2988
|
if (y === void 0)
|
|
2957
2989
|
continue;
|
|
2958
|
-
const
|
|
2959
|
-
|
|
2990
|
+
const S = e.blocks.getBlockByIndex(y);
|
|
2991
|
+
S && u.appendChild(S.holder);
|
|
2960
2992
|
}
|
|
2993
|
+
u.querySelectorAll("[data-blok-placeholder-active]").forEach((f) => {
|
|
2994
|
+
f.removeAttribute("data-blok-placeholder-active");
|
|
2995
|
+
}), u.querySelectorAll("[data-placeholder]").forEach((f) => {
|
|
2996
|
+
f.removeAttribute("data-placeholder");
|
|
2997
|
+
});
|
|
2961
2998
|
}
|
|
2962
2999
|
});
|
|
2963
3000
|
});
|
|
2964
|
-
},
|
|
2965
|
-
var l, a, c, d, h, u, p,
|
|
3001
|
+
}, Vt = (r, t) => {
|
|
3002
|
+
var l, a, c, d, h, u, p, C, f, y;
|
|
2966
3003
|
if (!(typeof r == "object" && r !== null && "content" in r))
|
|
2967
3004
|
return {
|
|
2968
3005
|
withHeadings: (l = t.withHeadings) != null ? l : !1,
|
|
@@ -2974,45 +3011,39 @@ const V = (r) => {
|
|
|
2974
3011
|
return {
|
|
2975
3012
|
withHeadings: (u = (h = n.withHeadings) != null ? h : t.withHeadings) != null ? u : !1,
|
|
2976
3013
|
withHeadingColumn: (p = n.withHeadingColumn) != null ? p : !1,
|
|
2977
|
-
stretched: (
|
|
3014
|
+
stretched: (f = (C = n.stretched) != null ? C : t.stretched) != null ? f : !1,
|
|
2978
3015
|
content: (y = n.content) != null ? y : [],
|
|
2979
3016
|
colWidths: i,
|
|
2980
3017
|
initialColWidth: n.initialColWidth
|
|
2981
3018
|
};
|
|
2982
|
-
},
|
|
3019
|
+
}, Ko = (r, t) => {
|
|
2983
3020
|
r.addEventListener("keydown", (e) => {
|
|
2984
3021
|
const o = e.target.closest(`[${g}]`);
|
|
2985
3022
|
if (!o)
|
|
2986
3023
|
return;
|
|
2987
|
-
const s =
|
|
3024
|
+
const s = Oo(r, o);
|
|
2988
3025
|
s && (t == null || t.handleKeyDown(e, s));
|
|
2989
3026
|
});
|
|
2990
|
-
},
|
|
2991
|
-
r == null || r.classList.add(...
|
|
3027
|
+
}, we = ["overflow-x-auto", "overflow-y-hidden"], Ut = (r) => {
|
|
3028
|
+
r == null || r.classList.add(...we);
|
|
2992
3029
|
}, tt = (r, t) => {
|
|
2993
3030
|
if (!r)
|
|
2994
3031
|
return;
|
|
2995
|
-
const e = r.
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
o.removeAttribute("data-blok-table-heading");
|
|
3001
|
-
}), t && n.length > 0 && n[0].setAttribute("data-blok-table-heading", "");
|
|
3002
|
-
}, W = (r, t) => {
|
|
3032
|
+
const e = r.querySelectorAll(`[${m}]`);
|
|
3033
|
+
e.forEach((n) => {
|
|
3034
|
+
n.removeAttribute("data-blok-table-heading");
|
|
3035
|
+
}), t && e.length > 0 && e[0].setAttribute("data-blok-table-heading", "");
|
|
3036
|
+
}, G = (r, t) => {
|
|
3003
3037
|
if (!r)
|
|
3004
3038
|
return;
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
}), t && e.querySelectorAll(`[${f}]`).forEach((s) => {
|
|
3011
|
-
const i = s.querySelector(`[${g}]`);
|
|
3012
|
-
i && i.setAttribute("data-blok-table-heading-col", "");
|
|
3039
|
+
r.querySelectorAll(`[${g}]`).forEach((n) => {
|
|
3040
|
+
n.removeAttribute("data-blok-table-heading-col");
|
|
3041
|
+
}), t && r.querySelectorAll(`[${m}]`).forEach((o) => {
|
|
3042
|
+
const s = o.querySelector(`[${g}]`);
|
|
3043
|
+
s && s.setAttribute("data-blok-table-heading-col", "");
|
|
3013
3044
|
});
|
|
3014
3045
|
};
|
|
3015
|
-
class
|
|
3046
|
+
class jo {
|
|
3016
3047
|
constructor(t) {
|
|
3017
3048
|
var e, n, o;
|
|
3018
3049
|
this.withHeadingsValue = (e = t == null ? void 0 : t.withHeadings) != null ? e : !1, this.withHeadingColumnValue = (n = t == null ? void 0 : t.withHeadingColumn) != null ? n : !1, this.stretchedValue = (o = t == null ? void 0 : t.stretched) != null ? o : !1, this.colWidthsValue = t != null && t.colWidths ? [...t.colWidths] : void 0, this.initialColWidthValue = t == null ? void 0 : t.initialColWidth, this.contentGrid = this.normalizeContent(t == null ? void 0 : t.content), this.blockCellMap = /* @__PURE__ */ new Map(), this.rebuildBlockCellMap();
|
|
@@ -3308,8 +3339,8 @@ class Vo {
|
|
|
3308
3339
|
return e;
|
|
3309
3340
|
}
|
|
3310
3341
|
}
|
|
3311
|
-
const
|
|
3312
|
-
class
|
|
3342
|
+
const Kt = "data-blok-table-resize", Xo = "data-blok-table-cell", Yo = "data-blok-table-row", Zo = 50, yt = 16;
|
|
3343
|
+
class Jo {
|
|
3313
3344
|
constructor(t, e, n, o, s, i = !1) {
|
|
3314
3345
|
this._enabled = !0, this.isDragging = !1, this.dragStartX = 0, this.dragColIndex = -1, this.startColWidth = 0, this.dragRowCells = null, this.handles = [], this.gridEl = t, this.colWidths = [...e], this.onChange = n, this.onDragStart = o != null ? o : null, this.onDrag = s != null ? s : null, this.needsInitialApply = i, this.boundPointerDown = this.onPointerDown.bind(this), this.boundPointerMove = this.onPointerMove.bind(this), this.boundPointerUp = this.onPointerUp.bind(this), this.gridEl.style.position = "relative", i || this.applyWidths(), this.createHandles(), this.gridEl.addEventListener("pointerdown", this.boundPointerDown);
|
|
3315
3346
|
}
|
|
@@ -3336,7 +3367,7 @@ class jo {
|
|
|
3336
3367
|
}
|
|
3337
3368
|
createHandle(t) {
|
|
3338
3369
|
const e = document.createElement("div"), n = this.getHandleLeftPx(t);
|
|
3339
|
-
return e.setAttribute(
|
|
3370
|
+
return e.setAttribute(Kt, ""), e.setAttribute("data-col", String(t)), e.style.position = "absolute", e.style.top = `-${M}px`, e.style.bottom = "0px", e.style.width = `${yt}px`, e.style.left = `${n - yt / 2}px`, e.style.cursor = "col-resize", e.style.zIndex = "2", e.style.background = "linear-gradient(to right, transparent 7px, #3b82f6 7px, #3b82f6 9px, transparent 9px)", e.style.opacity = "0", e.style.transition = "opacity 150ms ease", e.setAttribute("contenteditable", "false"), e.addEventListener("mouseenter", () => {
|
|
3340
3371
|
this.isDragging || (e.style.opacity = "1");
|
|
3341
3372
|
}), e.addEventListener("mouseleave", () => {
|
|
3342
3373
|
this.isDragging || (e.style.opacity = "0");
|
|
@@ -3356,7 +3387,7 @@ class jo {
|
|
|
3356
3387
|
if (!this._enabled)
|
|
3357
3388
|
return;
|
|
3358
3389
|
const e = t.target;
|
|
3359
|
-
if (!e.hasAttribute(
|
|
3390
|
+
if (!e.hasAttribute(Kt))
|
|
3360
3391
|
return;
|
|
3361
3392
|
t.preventDefault(), this.needsInitialApply && (this.applyWidths(), this.updateHandlePositions(), this.needsInitialApply = !1);
|
|
3362
3393
|
const n = e.getAttribute("data-col");
|
|
@@ -3366,7 +3397,7 @@ class jo {
|
|
|
3366
3397
|
var s, i;
|
|
3367
3398
|
if (!this.isDragging)
|
|
3368
3399
|
return;
|
|
3369
|
-
const e = t.clientX - this.dragStartX, n = this.startColWidth + e, o = Math.max(
|
|
3400
|
+
const e = t.clientX - this.dragStartX, n = this.startColWidth + e, o = Math.max(Zo, n);
|
|
3370
3401
|
this.colWidths[this.dragColIndex] = o, this.applyWidths((s = this.dragRowCells) != null ? s : void 0), this.updateHandlePositions(), (i = this.onDrag) == null || i.call(this);
|
|
3371
3402
|
}
|
|
3372
3403
|
onPointerUp() {
|
|
@@ -3377,8 +3408,8 @@ class jo {
|
|
|
3377
3408
|
t && (t.style.opacity = "0"), document.removeEventListener("pointermove", this.boundPointerMove), document.removeEventListener("pointerup", this.boundPointerUp), this.dragRowCells = null, this.onChange([...this.colWidths]);
|
|
3378
3409
|
}
|
|
3379
3410
|
resolveRowCells() {
|
|
3380
|
-
const t = this.gridEl.querySelectorAll(`[${
|
|
3381
|
-
return Array.from(t, (e) => Array.from(e.querySelectorAll(`[${
|
|
3411
|
+
const t = this.gridEl.querySelectorAll(`[${Yo}]`);
|
|
3412
|
+
return Array.from(t, (e) => Array.from(e.querySelectorAll(`[${Xo}]`)));
|
|
3382
3413
|
}
|
|
3383
3414
|
applyWidths(t = this.resolveRowCells()) {
|
|
3384
3415
|
const e = this.colWidths.reduce((n, o) => n + o, 0);
|
|
@@ -3389,34 +3420,34 @@ class jo {
|
|
|
3389
3420
|
});
|
|
3390
3421
|
}
|
|
3391
3422
|
}
|
|
3392
|
-
const
|
|
3423
|
+
const jt = (r, t, e) => (e.grid.addRow(r, t), H(r, e.cellBlocks), {
|
|
3393
3424
|
pendingHighlight: { type: "row", index: t },
|
|
3394
3425
|
moveSelection: null,
|
|
3395
3426
|
colWidths: e.data.colWidths,
|
|
3396
3427
|
withHeadings: e.data.withHeadings,
|
|
3397
3428
|
withHeadingColumn: e.data.withHeadingColumn
|
|
3398
|
-
}),
|
|
3399
|
-
const n =
|
|
3400
|
-
return
|
|
3429
|
+
}), Xt = (r, t, e) => {
|
|
3430
|
+
const n = qo(r, t, e.data.colWidths, e.data.initialColWidth, e.grid);
|
|
3431
|
+
return H(r, e.cellBlocks), {
|
|
3401
3432
|
pendingHighlight: { type: "col", index: t },
|
|
3402
3433
|
moveSelection: null,
|
|
3403
3434
|
colWidths: n,
|
|
3404
3435
|
withHeadings: e.data.withHeadings,
|
|
3405
3436
|
withHeadingColumn: e.data.withHeadingColumn
|
|
3406
3437
|
};
|
|
3407
|
-
},
|
|
3438
|
+
}, Qo = (r, t, e, n) => (n.grid.moveRow(r, t, e), {
|
|
3408
3439
|
pendingHighlight: null,
|
|
3409
3440
|
moveSelection: { type: "row", index: e },
|
|
3410
3441
|
colWidths: n.data.colWidths,
|
|
3411
3442
|
withHeadings: n.data.withHeadings,
|
|
3412
3443
|
withHeadingColumn: n.data.withHeadingColumn
|
|
3413
|
-
}),
|
|
3444
|
+
}), ts = (r, t, e, n) => (n.grid.moveColumn(r, t, e), {
|
|
3414
3445
|
pendingHighlight: null,
|
|
3415
3446
|
moveSelection: { type: "col", index: e },
|
|
3416
|
-
colWidths:
|
|
3447
|
+
colWidths: Go(n.data.colWidths, t, e),
|
|
3417
3448
|
withHeadings: n.data.withHeadings,
|
|
3418
3449
|
withHeadingColumn: n.data.withHeadingColumn
|
|
3419
|
-
}),
|
|
3450
|
+
}), es = (r, t, e) => {
|
|
3420
3451
|
var s, i;
|
|
3421
3452
|
(i = e.cellBlocks) == null || i.deleteBlocks((s = e.blocksToDelete) != null ? s : []), e.grid.deleteRow(r, t);
|
|
3422
3453
|
const n = e.grid.getRowCount(r);
|
|
@@ -3427,11 +3458,11 @@ const Vt = (r, t, e) => (e.grid.addRow(r, t), N(r, e.cellBlocks), {
|
|
|
3427
3458
|
withHeadings: e.data.withHeadings,
|
|
3428
3459
|
withHeadingColumn: e.data.withHeadingColumn
|
|
3429
3460
|
};
|
|
3430
|
-
},
|
|
3461
|
+
}, ns = (r, t, e) => {
|
|
3431
3462
|
var i, l;
|
|
3432
3463
|
(l = e.cellBlocks) == null || l.deleteBlocks((i = e.blocksToDelete) != null ? i : []), e.grid.deleteColumn(r, t);
|
|
3433
|
-
const n =
|
|
3434
|
-
n ? dt(r, n) :
|
|
3464
|
+
const n = $o(e.data.colWidths, t);
|
|
3465
|
+
n ? dt(r, n) : Wo(r);
|
|
3435
3466
|
const o = e.grid.getColumnCount(r);
|
|
3436
3467
|
return {
|
|
3437
3468
|
pendingHighlight: { type: "col", index: t < o ? t : t - 1 },
|
|
@@ -3440,24 +3471,24 @@ const Vt = (r, t, e) => (e.grid.addRow(r, t), N(r, e.cellBlocks), {
|
|
|
3440
3471
|
withHeadings: e.data.withHeadings,
|
|
3441
3472
|
withHeadingColumn: e.data.withHeadingColumn
|
|
3442
3473
|
};
|
|
3443
|
-
},
|
|
3474
|
+
}, os = (r, t, e) => {
|
|
3444
3475
|
switch (t.type) {
|
|
3445
3476
|
case "insert-row-above":
|
|
3446
|
-
return
|
|
3477
|
+
return jt(r, t.index, e);
|
|
3447
3478
|
case "insert-row-below":
|
|
3448
|
-
return
|
|
3479
|
+
return jt(r, t.index + 1, e);
|
|
3449
3480
|
case "insert-col-left":
|
|
3450
|
-
return
|
|
3481
|
+
return Xt(r, t.index, e);
|
|
3451
3482
|
case "insert-col-right":
|
|
3452
|
-
return
|
|
3483
|
+
return Xt(r, t.index + 1, e);
|
|
3453
3484
|
case "move-row":
|
|
3454
|
-
return
|
|
3485
|
+
return Qo(r, t.fromIndex, t.toIndex, e);
|
|
3455
3486
|
case "move-col":
|
|
3456
|
-
return
|
|
3487
|
+
return ts(r, t.fromIndex, t.toIndex, e);
|
|
3457
3488
|
case "delete-row":
|
|
3458
|
-
return
|
|
3489
|
+
return es(r, t.index, e);
|
|
3459
3490
|
case "delete-col":
|
|
3460
|
-
return
|
|
3491
|
+
return ns(r, t.index, e);
|
|
3461
3492
|
case "toggle-heading":
|
|
3462
3493
|
return {
|
|
3463
3494
|
pendingHighlight: { type: "row", index: 0 },
|
|
@@ -3475,8 +3506,8 @@ const Vt = (r, t, e) => (e.grid.addRow(r, t), N(r, e.cellBlocks), {
|
|
|
3475
3506
|
withHeadingColumn: !e.data.withHeadingColumn
|
|
3476
3507
|
};
|
|
3477
3508
|
}
|
|
3478
|
-
},
|
|
3479
|
-
const t = r.querySelector(`[${
|
|
3509
|
+
}, Yt = 10, ss = "data-blok-table-drag-ghost", vt = (r) => {
|
|
3510
|
+
const t = r.querySelector(`[${m}]`);
|
|
3480
3511
|
return t ? Array.from(t.querySelectorAll(`[${g}]`)).reduce(
|
|
3481
3512
|
(n, o) => {
|
|
3482
3513
|
const s = n[n.length - 1];
|
|
@@ -3485,7 +3516,7 @@ const Vt = (r, t, e) => (e.grid.addRow(r, t), N(r, e.cellBlocks), {
|
|
|
3485
3516
|
[0]
|
|
3486
3517
|
) : [0];
|
|
3487
3518
|
};
|
|
3488
|
-
class
|
|
3519
|
+
class is {
|
|
3489
3520
|
constructor(t) {
|
|
3490
3521
|
var e;
|
|
3491
3522
|
this.isDragging = !1, this.dragType = null, this.dragFromIndex = -1, this.dragStartX = 0, this.dragStartY = 0, this.dropIndicator = null, this.dragOverlayCells = [], this.ghostEl = null, this.ghostOffsetX = 0, this.ghostOffsetY = 0, this.resolveTracking = null, this.grid = t.grid, this.onAction = t.onAction, this.onDragStateChange = (e = t.onDragStateChange) != null ? e : null, this.boundDocPointerMove = this.handleDocPointerMove.bind(this), this.boundDocPointerUp = this.handleDocPointerUp.bind(this), this.boundDocPointerCancel = this.handleDocPointerCancel.bind(this);
|
|
@@ -3509,7 +3540,7 @@ class es {
|
|
|
3509
3540
|
}
|
|
3510
3541
|
handleDocPointerMove(t) {
|
|
3511
3542
|
const e = Math.abs(t.clientX - this.dragStartX), n = Math.abs(t.clientY - this.dragStartY);
|
|
3512
|
-
!this.isDragging && (e >
|
|
3543
|
+
!this.isDragging && (e > Yt || n > Yt) && (this.isDragging = !0, this.startDrag()), this.isDragging && (this.updateDragIndicator(t), this.updateGhostPosition(t));
|
|
3513
3544
|
}
|
|
3514
3545
|
handleDocPointerUp(t) {
|
|
3515
3546
|
var e, n;
|
|
@@ -3528,7 +3559,7 @@ class es {
|
|
|
3528
3559
|
this.grid.style.userSelect = "none", document.body.style.cursor = "grabbing", (t = this.onDragStateChange) == null || t.call(this, !0, this.dragType), this.highlightSourceCells(), this.createDropIndicator(), this.createGhost();
|
|
3529
3560
|
}
|
|
3530
3561
|
highlightSourceCells() {
|
|
3531
|
-
const t = this.grid.querySelectorAll(`[${
|
|
3562
|
+
const t = this.grid.querySelectorAll(`[${m}]`);
|
|
3532
3563
|
if (this.dragType === "row") {
|
|
3533
3564
|
this.highlightRowCells(t);
|
|
3534
3565
|
return;
|
|
@@ -3559,7 +3590,7 @@ class es {
|
|
|
3559
3590
|
if (t.position = "absolute", t.backgroundColor = "#3b82f6", t.borderRadius = "1.5px", t.zIndex = "5", t.pointerEvents = "none", this.dropIndicator.setAttribute("contenteditable", "false"), this.dragType === "row")
|
|
3560
3591
|
t.height = "3px", t.left = `${-M}px`, t.right = "0", t.transition = "top 100ms ease";
|
|
3561
3592
|
else {
|
|
3562
|
-
const e = this.grid.querySelectorAll(`[${
|
|
3593
|
+
const e = this.grid.querySelectorAll(`[${m}]`), n = e[e.length - 1], o = n ? n.offsetTop + n.offsetHeight : 0;
|
|
3563
3594
|
t.width = "3px", t.top = `${-M}px`, t.height = `${o + M}px`, t.transition = "left 100ms ease";
|
|
3564
3595
|
}
|
|
3565
3596
|
this.grid.appendChild(this.dropIndicator);
|
|
@@ -3584,7 +3615,7 @@ class es {
|
|
|
3584
3615
|
var i;
|
|
3585
3616
|
if (!this.dropIndicator)
|
|
3586
3617
|
return;
|
|
3587
|
-
const n = t.clientX - e.left, o = this.getColDropIndex(n), s =
|
|
3618
|
+
const n = t.clientX - e.left, o = this.getColDropIndex(n), s = vt(this.grid);
|
|
3588
3619
|
this.dropIndicator.style.left = `${((i = s[o]) != null ? i : 0) - 1.5}px`;
|
|
3589
3620
|
}
|
|
3590
3621
|
finishDrag(t) {
|
|
@@ -3605,7 +3636,7 @@ class es {
|
|
|
3605
3636
|
}
|
|
3606
3637
|
createGhost() {
|
|
3607
3638
|
const t = document.createElement("div");
|
|
3608
|
-
t.setAttribute(
|
|
3639
|
+
t.setAttribute(ss, ""), t.setAttribute("contenteditable", "false");
|
|
3609
3640
|
const e = t.style;
|
|
3610
3641
|
e.position = "fixed", e.pointerEvents = "none", e.opacity = "0.5", e.zIndex = "50", e.borderRadius = "4px", e.overflow = "hidden", e.boxShadow = "0 4px 12px rgba(0,0,0,0.15)", this.ghostEl = t;
|
|
3611
3642
|
const n = this.getSourceRect();
|
|
@@ -3616,11 +3647,11 @@ class es {
|
|
|
3616
3647
|
}
|
|
3617
3648
|
getRowSourceRect() {
|
|
3618
3649
|
var n;
|
|
3619
|
-
const e = this.grid.querySelectorAll(`[${
|
|
3650
|
+
const e = this.grid.querySelectorAll(`[${m}]`)[this.dragFromIndex];
|
|
3620
3651
|
return (n = e == null ? void 0 : e.getBoundingClientRect()) != null ? n : null;
|
|
3621
3652
|
}
|
|
3622
3653
|
getColSourceRect() {
|
|
3623
|
-
const t = this.grid.querySelectorAll(`[${
|
|
3654
|
+
const t = this.grid.querySelectorAll(`[${m}]`), e = t[0], n = t[t.length - 1];
|
|
3624
3655
|
if (!e || !n)
|
|
3625
3656
|
return null;
|
|
3626
3657
|
const o = e.querySelectorAll(`[${g}]`)[this.dragFromIndex], s = n.querySelectorAll(`[${g}]`)[this.dragFromIndex];
|
|
@@ -3630,7 +3661,7 @@ class es {
|
|
|
3630
3661
|
return new DOMRect(i.left, i.top, i.width, l.bottom - i.top);
|
|
3631
3662
|
}
|
|
3632
3663
|
buildRowGhost() {
|
|
3633
|
-
const e = this.grid.querySelectorAll(`[${
|
|
3664
|
+
const e = this.grid.querySelectorAll(`[${m}]`)[this.dragFromIndex];
|
|
3634
3665
|
if (!e || !this.ghostEl)
|
|
3635
3666
|
return;
|
|
3636
3667
|
const n = this.ghostEl.style;
|
|
@@ -3643,7 +3674,7 @@ class es {
|
|
|
3643
3674
|
buildColumnGhost() {
|
|
3644
3675
|
if (!this.ghostEl)
|
|
3645
3676
|
return;
|
|
3646
|
-
const t = this.grid.querySelectorAll(`[${
|
|
3677
|
+
const t = this.grid.querySelectorAll(`[${m}]`), e = this.ghostEl.style;
|
|
3647
3678
|
e.display = "flex", e.flexDirection = "column", t.forEach((n) => {
|
|
3648
3679
|
var l;
|
|
3649
3680
|
const o = n.querySelectorAll(`[${g}]`);
|
|
@@ -3660,7 +3691,7 @@ class es {
|
|
|
3660
3691
|
this.dragType === "row" && (e.top = `${t.clientY - this.ghostOffsetY}px`), this.dragType === "col" && (e.left = `${t.clientX - this.ghostOffsetX}px`);
|
|
3661
3692
|
}
|
|
3662
3693
|
getRowDropIndex(t) {
|
|
3663
|
-
const e = Array.from(this.grid.querySelectorAll(`[${
|
|
3694
|
+
const e = Array.from(this.grid.querySelectorAll(`[${m}]`)), n = e.map((i) => i.offsetTop);
|
|
3664
3695
|
if (e.length > 0) {
|
|
3665
3696
|
const i = e[e.length - 1];
|
|
3666
3697
|
n.push(i.offsetTop + i.offsetHeight);
|
|
@@ -3669,7 +3700,7 @@ class es {
|
|
|
3669
3700
|
return o.indexOf(s);
|
|
3670
3701
|
}
|
|
3671
3702
|
getRowDropTopPx(t) {
|
|
3672
|
-
const e = this.grid.querySelectorAll(`[${
|
|
3703
|
+
const e = this.grid.querySelectorAll(`[${m}]`);
|
|
3673
3704
|
if (t < e.length)
|
|
3674
3705
|
return e[t].offsetTop;
|
|
3675
3706
|
if (e.length > 0) {
|
|
@@ -3679,11 +3710,11 @@ class es {
|
|
|
3679
3710
|
return 0;
|
|
3680
3711
|
}
|
|
3681
3712
|
getColDropIndex(t) {
|
|
3682
|
-
const n =
|
|
3713
|
+
const n = vt(this.grid).map((s) => Math.abs(t - s)), o = Math.min(...n);
|
|
3683
3714
|
return n.indexOf(o);
|
|
3684
3715
|
}
|
|
3685
3716
|
}
|
|
3686
|
-
const
|
|
3717
|
+
const rs = [
|
|
3687
3718
|
"flex",
|
|
3688
3719
|
"items-center",
|
|
3689
3720
|
"select-none",
|
|
@@ -3695,7 +3726,7 @@ const ns = [
|
|
|
3695
3726
|
"mb-px",
|
|
3696
3727
|
"cursor-pointer",
|
|
3697
3728
|
"can-hover:hover:bg-item-hover-bg"
|
|
3698
|
-
],
|
|
3729
|
+
], ls = [
|
|
3699
3730
|
"flex",
|
|
3700
3731
|
"items-center",
|
|
3701
3732
|
"justify-center",
|
|
@@ -3704,13 +3735,13 @@ const ns = [
|
|
|
3704
3735
|
"mr-2",
|
|
3705
3736
|
"[&_svg]:w-icon",
|
|
3706
3737
|
"[&_svg]:h-icon"
|
|
3707
|
-
],
|
|
3738
|
+
], as = [
|
|
3708
3739
|
"mr-auto",
|
|
3709
3740
|
"truncate",
|
|
3710
3741
|
"text-sm",
|
|
3711
3742
|
"font-medium",
|
|
3712
3743
|
"leading-5"
|
|
3713
|
-
],
|
|
3744
|
+
], cs = [
|
|
3714
3745
|
"relative",
|
|
3715
3746
|
"w-[34px]",
|
|
3716
3747
|
"h-[20px]",
|
|
@@ -3718,7 +3749,7 @@ const ns = [
|
|
|
3718
3749
|
"transition-colors",
|
|
3719
3750
|
"duration-200",
|
|
3720
3751
|
"shrink-0"
|
|
3721
|
-
],
|
|
3752
|
+
], ds = [
|
|
3722
3753
|
"absolute",
|
|
3723
3754
|
"top-[2px]",
|
|
3724
3755
|
"w-4",
|
|
@@ -3728,29 +3759,29 @@ const ns = [
|
|
|
3728
3759
|
"shadow-sm",
|
|
3729
3760
|
"transition-[left]",
|
|
3730
3761
|
"duration-200"
|
|
3731
|
-
],
|
|
3762
|
+
], ke = (r) => {
|
|
3732
3763
|
const { icon: t, label: e, isActive: n, onToggle: o } = r, s = { active: n }, i = document.createElement("div");
|
|
3733
|
-
i.className =
|
|
3764
|
+
i.className = v(rs);
|
|
3734
3765
|
const l = document.createElement("div");
|
|
3735
|
-
l.className =
|
|
3766
|
+
l.className = v(ls), l.innerHTML = t, i.appendChild(l);
|
|
3736
3767
|
const a = document.createElement("span");
|
|
3737
|
-
a.className =
|
|
3768
|
+
a.className = v(as), a.textContent = e, i.appendChild(a);
|
|
3738
3769
|
const c = document.createElement("div");
|
|
3739
|
-
c.className =
|
|
3770
|
+
c.className = v(cs);
|
|
3740
3771
|
const d = document.createElement("div");
|
|
3741
|
-
d.className =
|
|
3772
|
+
d.className = v(ds), c.appendChild(d), i.appendChild(c);
|
|
3742
3773
|
const h = () => {
|
|
3743
3774
|
c.style.backgroundColor = s.active ? "#3b82f6" : "#d1d5db", d.style.left = s.active ? "16px" : "2px";
|
|
3744
3775
|
};
|
|
3745
3776
|
return h(), i.addEventListener("click", (u) => {
|
|
3746
3777
|
u.stopPropagation(), s.active = !s.active, h(), o(s.active);
|
|
3747
3778
|
}), i;
|
|
3748
|
-
},
|
|
3779
|
+
}, hs = (r, t) => {
|
|
3749
3780
|
const e = r === 0 ? [
|
|
3750
3781
|
{
|
|
3751
3782
|
type: U.Html,
|
|
3752
|
-
element:
|
|
3753
|
-
icon:
|
|
3783
|
+
element: ke({
|
|
3784
|
+
icon: Qe,
|
|
3754
3785
|
label: t.i18n.t("tools.table.headerColumn"),
|
|
3755
3786
|
isActive: t.isHeadingColumn(),
|
|
3756
3787
|
onToggle: () => {
|
|
@@ -3761,7 +3792,7 @@ const ns = [
|
|
|
3761
3792
|
{ type: U.Separator }
|
|
3762
3793
|
] : [], n = [
|
|
3763
3794
|
{
|
|
3764
|
-
icon:
|
|
3795
|
+
icon: Xe,
|
|
3765
3796
|
title: t.i18n.t("tools.table.insertColumnLeft"),
|
|
3766
3797
|
closeOnActivate: !0,
|
|
3767
3798
|
onActivate: () => {
|
|
@@ -3769,7 +3800,7 @@ const ns = [
|
|
|
3769
3800
|
}
|
|
3770
3801
|
},
|
|
3771
3802
|
{
|
|
3772
|
-
icon:
|
|
3803
|
+
icon: Ye,
|
|
3773
3804
|
title: t.i18n.t("tools.table.insertColumnRight"),
|
|
3774
3805
|
closeOnActivate: !0,
|
|
3775
3806
|
onActivate: () => {
|
|
@@ -3779,7 +3810,7 @@ const ns = [
|
|
|
3779
3810
|
], o = t.getColumnCount() > 1, s = [
|
|
3780
3811
|
{ type: U.Separator },
|
|
3781
3812
|
{
|
|
3782
|
-
icon:
|
|
3813
|
+
icon: ce,
|
|
3783
3814
|
title: t.i18n.t("tools.table.deleteColumn"),
|
|
3784
3815
|
isDestructive: !0,
|
|
3785
3816
|
isDisabled: !o,
|
|
@@ -3790,12 +3821,12 @@ const ns = [
|
|
|
3790
3821
|
}
|
|
3791
3822
|
];
|
|
3792
3823
|
return [...e, ...n, ...s];
|
|
3793
|
-
},
|
|
3824
|
+
}, us = (r, t) => {
|
|
3794
3825
|
const e = r === 0 ? [
|
|
3795
3826
|
{
|
|
3796
3827
|
type: U.Html,
|
|
3797
|
-
element:
|
|
3798
|
-
icon:
|
|
3828
|
+
element: ke({
|
|
3829
|
+
icon: tn,
|
|
3799
3830
|
label: t.i18n.t("tools.table.headerRow"),
|
|
3800
3831
|
isActive: t.isHeadingRow(),
|
|
3801
3832
|
onToggle: () => {
|
|
@@ -3806,7 +3837,7 @@ const ns = [
|
|
|
3806
3837
|
{ type: U.Separator }
|
|
3807
3838
|
] : [], n = [
|
|
3808
3839
|
{
|
|
3809
|
-
icon:
|
|
3840
|
+
icon: Ze,
|
|
3810
3841
|
title: t.i18n.t("tools.table.insertRowAbove"),
|
|
3811
3842
|
closeOnActivate: !0,
|
|
3812
3843
|
onActivate: () => {
|
|
@@ -3814,7 +3845,7 @@ const ns = [
|
|
|
3814
3845
|
}
|
|
3815
3846
|
},
|
|
3816
3847
|
{
|
|
3817
|
-
icon:
|
|
3848
|
+
icon: Je,
|
|
3818
3849
|
title: t.i18n.t("tools.table.insertRowBelow"),
|
|
3819
3850
|
closeOnActivate: !0,
|
|
3820
3851
|
onActivate: () => {
|
|
@@ -3824,7 +3855,7 @@ const ns = [
|
|
|
3824
3855
|
], o = t.getRowCount() > 1, s = [
|
|
3825
3856
|
{ type: U.Separator },
|
|
3826
3857
|
{
|
|
3827
|
-
icon:
|
|
3858
|
+
icon: ce,
|
|
3828
3859
|
title: t.i18n.t("tools.table.deleteRow"),
|
|
3829
3860
|
isDestructive: !0,
|
|
3830
3861
|
isDisabled: !o,
|
|
@@ -3835,21 +3866,21 @@ const ns = [
|
|
|
3835
3866
|
}
|
|
3836
3867
|
];
|
|
3837
3868
|
return [...e, ...n, ...s];
|
|
3838
|
-
},
|
|
3869
|
+
}, ps = (r, t, e, n, o) => {
|
|
3839
3870
|
o.destroyPopover(), o.clearHideTimeout();
|
|
3840
3871
|
const s = r === "col" ? e.col[t] : e.row[t];
|
|
3841
3872
|
if (!s)
|
|
3842
3873
|
return { popover: null, grip: null };
|
|
3843
|
-
const i = r === "col" ?
|
|
3874
|
+
const i = r === "col" ? hs(t, n) : us(t, n), l = new le({
|
|
3844
3875
|
items: i,
|
|
3845
3876
|
trigger: s,
|
|
3846
3877
|
flippable: !0
|
|
3847
3878
|
});
|
|
3848
|
-
return l.on(
|
|
3879
|
+
return l.on(ae.Closed, () => {
|
|
3849
3880
|
var a;
|
|
3850
3881
|
o.destroyPopover(), o.applyVisibleClasses(s), o.scheduleHideAll(), (a = o.onGripPopoverClose) == null || a.call(o);
|
|
3851
3882
|
}), o.hideAllGripsExcept(s), o.applyActiveClasses(s), r === "col" ? s.style.height = `${Z}px` : s.style.width = `${Z}px`, { popover: l, grip: s };
|
|
3852
|
-
},
|
|
3883
|
+
}, Zt = "data-blok-table-grip", it = "data-blok-table-grip-col", Jt = "data-blok-table-grip-row", gs = 150, fs = 24, rt = 4, lt = 4, ms = 20, at = [
|
|
3853
3884
|
"absolute",
|
|
3854
3885
|
"z-[3]",
|
|
3855
3886
|
"rounded",
|
|
@@ -3862,23 +3893,23 @@ const ns = [
|
|
|
3862
3893
|
"items-center",
|
|
3863
3894
|
"justify-center",
|
|
3864
3895
|
"overflow-hidden"
|
|
3865
|
-
],
|
|
3896
|
+
], Qt = [
|
|
3866
3897
|
"bg-gray-300",
|
|
3867
3898
|
"opacity-0",
|
|
3868
3899
|
"pointer-events-none"
|
|
3869
|
-
],
|
|
3900
|
+
], Cs = [
|
|
3870
3901
|
"bg-gray-300",
|
|
3871
3902
|
"opacity-100",
|
|
3872
3903
|
"pointer-events-auto"
|
|
3873
|
-
],
|
|
3904
|
+
], ys = [
|
|
3874
3905
|
"bg-blue-500",
|
|
3875
3906
|
"text-white",
|
|
3876
3907
|
"opacity-100",
|
|
3877
3908
|
"pointer-events-auto"
|
|
3878
3909
|
];
|
|
3879
|
-
class
|
|
3910
|
+
class bs {
|
|
3880
3911
|
constructor(t) {
|
|
3881
|
-
this.colGrips = [], this.rowGrips = [], this.popoverState = { popover: null, grip: null }, this.lockedGrip = null, this.hideTimeout = null, this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.isInsideTable = !1, this.rowResizeObserver = null, this.grid = t.grid, this.getColumnCount = t.getColumnCount, this.getRowCount = t.getRowCount, this.isHeadingRow = t.isHeadingRow, this.isHeadingColumn = t.isHeadingColumn, this.onAction = t.onAction, this.onGripClick = t.onGripClick, this.onGripPopoverClose = t.onGripPopoverClose, this.i18n = t.i18n, this.drag = new
|
|
3912
|
+
this.colGrips = [], this.rowGrips = [], this.popoverState = { popover: null, grip: null }, this.lockedGrip = null, this.hideTimeout = null, this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.isInsideTable = !1, this.rowResizeObserver = null, this.boundScrollHandler = null, this.grid = t.grid, this.overlay = t.overlay, this.scrollContainer = t.scrollContainer, this.getColumnCount = t.getColumnCount, this.getRowCount = t.getRowCount, this.isHeadingRow = t.isHeadingRow, this.isHeadingColumn = t.isHeadingColumn, this.onAction = t.onAction, this.onGripClick = t.onGripClick, this.onGripPopoverClose = t.onGripPopoverClose, this.i18n = t.i18n, this.drag = new is({
|
|
3882
3913
|
grid: this.grid,
|
|
3883
3914
|
onAction: this.onAction,
|
|
3884
3915
|
onDragStateChange: (e, n) => {
|
|
@@ -3901,37 +3932,52 @@ class fs {
|
|
|
3901
3932
|
const n = t === "col" ? this.colGrips[e] : this.rowGrips[e];
|
|
3902
3933
|
n && (this.unlockGrip(), this.clearHideTimeout(), this.hideAllGripsExcept(n), this.applyActiveClasses(n), t === "col" ? n.style.height = `${Z}px` : n.style.width = `${Z}px`, this.lockedGrip = n, document.addEventListener("pointerdown", this.boundUnlockGrip));
|
|
3903
3934
|
}
|
|
3904
|
-
handleUnlockGrip() {
|
|
3935
|
+
handleUnlockGrip(t) {
|
|
3905
3936
|
document.removeEventListener("pointerdown", this.boundUnlockGrip), this.lockedGrip && (this.applyIdleClasses(this.lockedGrip), this.lockedGrip = null);
|
|
3937
|
+
const e = t.target instanceof HTMLElement ? t.target : null, n = e == null ? void 0 : e.closest(`[${g}]`);
|
|
3938
|
+
if (n) {
|
|
3939
|
+
const o = this.getCellPosition(n);
|
|
3940
|
+
o && (this.clearHideTimeout(), this.showColGrip(o.col), this.showRowGrip(o.row), this.isInsideTable = !0);
|
|
3941
|
+
}
|
|
3906
3942
|
}
|
|
3907
3943
|
unlockGrip() {
|
|
3908
3944
|
document.removeEventListener("pointerdown", this.boundUnlockGrip), this.lockedGrip = null;
|
|
3909
3945
|
}
|
|
3946
|
+
get isPopoverOpen() {
|
|
3947
|
+
return this.popoverState.popover !== null;
|
|
3948
|
+
}
|
|
3910
3949
|
destroy() {
|
|
3911
3950
|
this.destroyPopover(), this.unlockGrip(), this.drag.cleanup(), this.grid.removeEventListener("mouseover", this.boundMouseOver), this.grid.removeEventListener("mouseleave", this.boundMouseLeave), this.clearHideTimeout(), this.destroyGrips();
|
|
3912
3951
|
}
|
|
3913
3952
|
createGrips() {
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
this.
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
this.
|
|
3921
|
-
|
|
3953
|
+
var o;
|
|
3954
|
+
const t = this.getColumnCount(), e = this.getRowCount(), n = (o = this.overlay) != null ? o : this.grid;
|
|
3955
|
+
Array.from({ length: t }).forEach((s, i) => {
|
|
3956
|
+
const l = this.createGripElement("col", i);
|
|
3957
|
+
this.colGrips.push(l), n.appendChild(l);
|
|
3958
|
+
}), Array.from({ length: e }).forEach((s, i) => {
|
|
3959
|
+
const l = this.createGripElement("row", i);
|
|
3960
|
+
this.rowGrips.push(l), n.appendChild(l);
|
|
3961
|
+
}), this.positionGrips(), this.observeRowHeights(), this.attachScrollListener();
|
|
3962
|
+
}
|
|
3963
|
+
attachScrollListener() {
|
|
3964
|
+
this.overlay && this.scrollContainer && (this.boundScrollHandler = () => this.positionGrips(), this.scrollContainer.addEventListener("scroll", this.boundScrollHandler));
|
|
3965
|
+
}
|
|
3966
|
+
detachScrollListener() {
|
|
3967
|
+
this.boundScrollHandler && this.scrollContainer && (this.scrollContainer.removeEventListener("scroll", this.boundScrollHandler), this.boundScrollHandler = null);
|
|
3922
3968
|
}
|
|
3923
3969
|
destroyGrips() {
|
|
3924
3970
|
var t;
|
|
3925
|
-
(t = this.rowResizeObserver) == null || t.disconnect(), this.rowResizeObserver = null, this.colGrips.forEach((e) => e.remove()), this.rowGrips.forEach((e) => e.remove()), this.colGrips = [], this.rowGrips = [], this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.isInsideTable = !1;
|
|
3971
|
+
(t = this.rowResizeObserver) == null || t.disconnect(), this.rowResizeObserver = null, this.detachScrollListener(), this.colGrips.forEach((e) => e.remove()), this.rowGrips.forEach((e) => e.remove()), this.colGrips = [], this.rowGrips = [], this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.isInsideTable = !1;
|
|
3926
3972
|
}
|
|
3927
3973
|
createGripElement(t, e) {
|
|
3928
3974
|
const n = document.createElement("div");
|
|
3929
|
-
n.className =
|
|
3930
|
-
const o = t === "col" ?
|
|
3931
|
-
return n.style.width = `${o}px`, n.style.height = `${s}px`, n.style.transform = "translate(-50%, -50%)", n.style.outline = "2px solid white", n.appendChild(
|
|
3932
|
-
this.isGripInteractionLocked() ||
|
|
3975
|
+
n.className = v(at, Qt), n.setAttribute(Zt, ""), n.setAttribute(t === "col" ? it : Jt, String(e)), n.setAttribute("contenteditable", "false");
|
|
3976
|
+
const o = t === "col" ? fs : lt, s = t === "col" ? rt : ms, i = t === "col" ? rt : lt;
|
|
3977
|
+
return n.style.width = `${o}px`, n.style.height = `${s}px`, n.style.transform = "translate(-50%, -50%)", n.style.outline = "2px solid white", n.appendChild(ve(t === "col" ? "horizontal" : "vertical")), n.addEventListener("pointerdown", this.boundPointerDown), n.addEventListener("mouseenter", () => {
|
|
3978
|
+
this.overlay && this.clearHideTimeout(), this.isGripInteractionLocked() || Lo(n, t);
|
|
3933
3979
|
}), n.addEventListener("mouseleave", () => {
|
|
3934
|
-
this.isGripInteractionLocked() || ft(n, t, i);
|
|
3980
|
+
this.isGripInteractionLocked() || (ft(n, t, i), this.overlay && this.scheduleHideAll());
|
|
3935
3981
|
}), n;
|
|
3936
3982
|
}
|
|
3937
3983
|
/**
|
|
@@ -3939,20 +3985,20 @@ class fs {
|
|
|
3939
3985
|
* Called after resize or structural changes.
|
|
3940
3986
|
*/
|
|
3941
3987
|
positionGrips() {
|
|
3942
|
-
const t = this.grid.querySelectorAll(`[${
|
|
3988
|
+
const t = this.grid.querySelectorAll(`[${m}]`);
|
|
3943
3989
|
if (!t[0])
|
|
3944
3990
|
return;
|
|
3945
|
-
const n =
|
|
3946
|
-
this.colGrips.forEach((
|
|
3947
|
-
if (
|
|
3991
|
+
const n = vt(this.grid), o = this.overlay && this.scrollContainer ? this.scrollContainer.scrollLeft : 0, s = this.overlay && this.scrollContainer ? this.scrollContainer.clientWidth : 1 / 0;
|
|
3992
|
+
this.colGrips.forEach((i, l) => {
|
|
3993
|
+
if (l + 1 >= n.length)
|
|
3948
3994
|
return;
|
|
3949
|
-
const
|
|
3950
|
-
|
|
3951
|
-
}), this.rowGrips.forEach((
|
|
3952
|
-
if (
|
|
3995
|
+
const c = (n[l] + n[l + 1]) / 2 - o, d = i.style;
|
|
3996
|
+
d.top = `${-M / 2}px`, d.left = `${c}px`, this.overlay && (d.visibility = c < 0 || c > s ? "hidden" : "");
|
|
3997
|
+
}), this.rowGrips.forEach((i, l) => {
|
|
3998
|
+
if (l >= t.length)
|
|
3953
3999
|
return;
|
|
3954
|
-
const
|
|
3955
|
-
|
|
4000
|
+
const a = t[l], c = a.offsetTop + a.offsetHeight / 2, d = i.style;
|
|
4001
|
+
d.left = `${-M / 2}px`, d.top = `${c}px`;
|
|
3956
4002
|
});
|
|
3957
4003
|
}
|
|
3958
4004
|
/**
|
|
@@ -3962,7 +4008,7 @@ class fs {
|
|
|
3962
4008
|
var e;
|
|
3963
4009
|
(e = this.rowResizeObserver) == null || e.disconnect(), this.rowResizeObserver = new ResizeObserver(() => {
|
|
3964
4010
|
this.positionGrips();
|
|
3965
|
-
}), this.grid.querySelectorAll(`[${
|
|
4011
|
+
}), this.grid.querySelectorAll(`[${m}]`).forEach((n) => {
|
|
3966
4012
|
var o;
|
|
3967
4013
|
(o = this.rowResizeObserver) == null || o.observe(n);
|
|
3968
4014
|
});
|
|
@@ -3984,10 +4030,10 @@ class fs {
|
|
|
3984
4030
|
this.isGripInteractionLocked() || this.scheduleHideAll();
|
|
3985
4031
|
}
|
|
3986
4032
|
getCellPosition(t) {
|
|
3987
|
-
const e = t.closest(`[${
|
|
4033
|
+
const e = t.closest(`[${m}]`);
|
|
3988
4034
|
if (!e)
|
|
3989
4035
|
return null;
|
|
3990
|
-
const o = Array.from(this.grid.querySelectorAll(`[${
|
|
4036
|
+
const o = Array.from(this.grid.querySelectorAll(`[${m}]`)).indexOf(e);
|
|
3991
4037
|
if (o < 0)
|
|
3992
4038
|
return null;
|
|
3993
4039
|
const i = Array.from(e.querySelectorAll(`[${g}]`)).indexOf(t);
|
|
@@ -4025,12 +4071,12 @@ class fs {
|
|
|
4025
4071
|
}
|
|
4026
4072
|
applyVisibleClasses(t) {
|
|
4027
4073
|
const e = t, n = e.hasAttribute(it);
|
|
4028
|
-
ft(e, n ? "col" : "row", n ? rt : lt), this.isInsideTable && (e.style.transition = "none"), e.className =
|
|
4074
|
+
ft(e, n ? "col" : "row", n ? rt : lt), this.isInsideTable && (e.style.transition = "none"), e.className = v(at, Cs), e.setAttribute("data-blok-table-grip-visible", ""), this.isInsideTable && (e.offsetHeight, e.style.transition = "");
|
|
4029
4075
|
const i = e.querySelector("svg");
|
|
4030
4076
|
i && (i.classList.remove("text-white"), i.classList.add("text-gray-400"));
|
|
4031
4077
|
}
|
|
4032
4078
|
applyActiveClasses(t) {
|
|
4033
|
-
Object.assign(t, { className:
|
|
4079
|
+
Object.assign(t, { className: v(at, ys) }), t.setAttribute("data-blok-table-grip-visible", "");
|
|
4034
4080
|
const e = t.querySelector("svg");
|
|
4035
4081
|
e && (e.classList.remove("text-gray-400", "opacity-0"), e.classList.add("text-white", "opacity-100"));
|
|
4036
4082
|
}
|
|
@@ -4041,7 +4087,7 @@ class fs {
|
|
|
4041
4087
|
}
|
|
4042
4088
|
applyIdleClasses(t) {
|
|
4043
4089
|
const e = t, n = e.hasAttribute(it), o = n ? "col" : "row", s = 12, i = n ? rt + s : lt + s;
|
|
4044
|
-
this.isInsideTable && (e.style.transition = "none"), ft(e, o, i), e.className =
|
|
4090
|
+
this.isInsideTable && (e.style.transition = "none"), ft(e, o, i), e.className = v(at, Qt), e.removeAttribute("data-blok-table-grip-visible"), this.isInsideTable && (e.offsetHeight, e.style.transition = "");
|
|
4045
4091
|
}
|
|
4046
4092
|
handleDragStateChange(t, e) {
|
|
4047
4093
|
[...this.colGrips, ...this.rowGrips].forEach((n) => {
|
|
@@ -4052,14 +4098,14 @@ class fs {
|
|
|
4052
4098
|
scheduleHideAll() {
|
|
4053
4099
|
this.hideTimeout = setTimeout(() => {
|
|
4054
4100
|
this.hideColGrip(), this.hideRowGrip(), this.isInsideTable = !1, this.hideTimeout = null;
|
|
4055
|
-
},
|
|
4101
|
+
}, gs);
|
|
4056
4102
|
}
|
|
4057
4103
|
clearHideTimeout() {
|
|
4058
4104
|
this.hideTimeout !== null && (clearTimeout(this.hideTimeout), this.hideTimeout = null);
|
|
4059
4105
|
}
|
|
4060
4106
|
// ── Click / Drag discrimination ──────────────────────────────
|
|
4061
4107
|
handlePointerDown(t) {
|
|
4062
|
-
const n = t.target.closest(`[${
|
|
4108
|
+
const n = t.target.closest(`[${Zt}]`);
|
|
4063
4109
|
if (!n)
|
|
4064
4110
|
return;
|
|
4065
4111
|
t.preventDefault(), t.stopPropagation();
|
|
@@ -4072,13 +4118,13 @@ class fs {
|
|
|
4072
4118
|
const e = t.getAttribute(it);
|
|
4073
4119
|
if (e !== null)
|
|
4074
4120
|
return { type: "col", index: Number(e) };
|
|
4075
|
-
const n = t.getAttribute(
|
|
4121
|
+
const n = t.getAttribute(Jt);
|
|
4076
4122
|
return n !== null ? { type: "row", index: Number(n) } : null;
|
|
4077
4123
|
}
|
|
4078
4124
|
// ── Popover menus ────────────────────────────────────────────
|
|
4079
4125
|
openPopover(t, e) {
|
|
4080
4126
|
var n, o;
|
|
4081
|
-
this.popoverState =
|
|
4127
|
+
this.popoverState = ps(
|
|
4082
4128
|
t,
|
|
4083
4129
|
e,
|
|
4084
4130
|
{ col: this.colGrips, row: this.rowGrips },
|
|
@@ -4108,17 +4154,94 @@ class fs {
|
|
|
4108
4154
|
}
|
|
4109
4155
|
}
|
|
4110
4156
|
}
|
|
4111
|
-
const
|
|
4157
|
+
const vs = "data-blok-table-haze", te = "data-blok-table-haze-visible", bt = 1, Ss = [
|
|
4158
|
+
"absolute",
|
|
4159
|
+
"top-0",
|
|
4160
|
+
"bottom-0",
|
|
4161
|
+
"w-12",
|
|
4162
|
+
"pointer-events-none",
|
|
4163
|
+
"opacity-0",
|
|
4164
|
+
"transition-opacity",
|
|
4165
|
+
"duration-150",
|
|
4166
|
+
"z-[1]"
|
|
4167
|
+
], ws = [
|
|
4168
|
+
"left-0",
|
|
4169
|
+
"bg-gradient-to-r",
|
|
4170
|
+
"from-white/80",
|
|
4171
|
+
"to-transparent"
|
|
4172
|
+
], ks = [
|
|
4173
|
+
"right-5",
|
|
4174
|
+
"bg-gradient-to-l",
|
|
4175
|
+
"from-white/80",
|
|
4176
|
+
"to-transparent"
|
|
4177
|
+
];
|
|
4178
|
+
class As {
|
|
4179
|
+
constructor() {
|
|
4180
|
+
this.leftHaze = null, this.rightHaze = null, this.scrollContainer = null, this.boundOnScroll = null, this.ticking = !1;
|
|
4181
|
+
}
|
|
4182
|
+
/**
|
|
4183
|
+
* Create haze overlay elements and attach the scroll listener.
|
|
4184
|
+
*
|
|
4185
|
+
* @param wrapper - The table wrapper element (position: relative)
|
|
4186
|
+
* @param scrollContainer - The scroll container with overflow-x: auto
|
|
4187
|
+
*/
|
|
4188
|
+
init(t, e) {
|
|
4189
|
+
this.scrollContainer = e, this.leftHaze = this.createHazeElement("left"), this.rightHaze = this.createHazeElement("right"), t.appendChild(this.leftHaze), t.appendChild(this.rightHaze), this.boundOnScroll = () => {
|
|
4190
|
+
this.ticking || (requestAnimationFrame(() => {
|
|
4191
|
+
this.syncVisibility(), this.ticking = !1;
|
|
4192
|
+
}), this.ticking = !0);
|
|
4193
|
+
}, e.addEventListener("scroll", this.boundOnScroll, { passive: !0 }), this.syncVisibility();
|
|
4194
|
+
}
|
|
4195
|
+
/**
|
|
4196
|
+
* Recalculate haze visibility (e.g. after column resize or add/delete).
|
|
4197
|
+
*/
|
|
4198
|
+
update() {
|
|
4199
|
+
this.syncVisibility();
|
|
4200
|
+
}
|
|
4201
|
+
/**
|
|
4202
|
+
* Remove overlay elements and detach the scroll listener.
|
|
4203
|
+
*/
|
|
4204
|
+
destroy() {
|
|
4205
|
+
var t, e;
|
|
4206
|
+
this.boundOnScroll && this.scrollContainer && this.scrollContainer.removeEventListener("scroll", this.boundOnScroll), (t = this.leftHaze) == null || t.remove(), (e = this.rightHaze) == null || e.remove(), this.leftHaze = null, this.rightHaze = null, this.scrollContainer = null, this.boundOnScroll = null, this.ticking = !1;
|
|
4207
|
+
}
|
|
4208
|
+
createHazeElement(t) {
|
|
4209
|
+
const e = document.createElement("div");
|
|
4210
|
+
return e.setAttribute(vs, t), e.setAttribute("aria-hidden", "true"), e.classList.add(...Ss, ...t === "left" ? ws : ks), e;
|
|
4211
|
+
}
|
|
4212
|
+
syncVisibility() {
|
|
4213
|
+
const t = this.scrollContainer;
|
|
4214
|
+
if (!t)
|
|
4215
|
+
return;
|
|
4216
|
+
const { overflowX: e } = getComputedStyle(t);
|
|
4217
|
+
if (!(e === "auto" || e === "scroll")) {
|
|
4218
|
+
this.setVisible(this.leftHaze, !1), this.setVisible(this.rightHaze, !1);
|
|
4219
|
+
return;
|
|
4220
|
+
}
|
|
4221
|
+
const { scrollLeft: o, scrollWidth: s, clientWidth: i } = t, l = s - i;
|
|
4222
|
+
this.setVisible(this.leftHaze, o > bt), this.setVisible(this.rightHaze, l > bt && o < l - bt);
|
|
4223
|
+
}
|
|
4224
|
+
setVisible(t, e) {
|
|
4225
|
+
t && (e ? t.setAttribute(te, "") : t.removeAttribute(te));
|
|
4226
|
+
}
|
|
4227
|
+
}
|
|
4228
|
+
const Es = 3, xs = 3, Ts = [
|
|
4112
4229
|
"my-2",
|
|
4113
4230
|
"pr-5"
|
|
4114
|
-
],
|
|
4115
|
-
"relative"
|
|
4231
|
+
], Bs = [
|
|
4232
|
+
"relative",
|
|
4233
|
+
'after:content-[""]',
|
|
4234
|
+
"after:absolute",
|
|
4235
|
+
"after:-bottom-10",
|
|
4236
|
+
"after:left-0",
|
|
4237
|
+
"after:right-0",
|
|
4238
|
+
"after:h-10"
|
|
4116
4239
|
];
|
|
4117
|
-
class
|
|
4240
|
+
class Os {
|
|
4118
4241
|
constructor({ data: t, config: e, api: n, readOnly: o, block: s }) {
|
|
4119
|
-
this.initialContent = null, this.resize = null, this.addControls = null, this.rowColControls = null, this.cellBlocks = null, this.cellSelection = null, this.element = null, this.pendingHighlight = null, this.isNewTable = !1, this.unregisterRestrictedTools = null, this.setDataGeneration = 0, this.structuralOpDepth = 0, this.api = n, this.readOnly = o, this.config = e != null ? e : {};
|
|
4120
|
-
const i =
|
|
4121
|
-
this.initialContent = i.content, this.grid = new
|
|
4242
|
+
this.initialContent = null, this.resize = null, this.addControls = null, this.rowColControls = null, this.cellBlocks = null, this.cellSelection = null, this.scrollHaze = null, this.element = null, this.gridElement = null, this.scrollContainer = null, this.gripOverlay = null, this.pendingHighlight = null, this.isNewTable = !1, this.unregisterRestrictedTools = null, this.setDataGeneration = 0, this.structuralOpDepth = 0, this.api = n, this.readOnly = o, this.config = e != null ? e : {};
|
|
4243
|
+
const i = Vt(t, this.config);
|
|
4244
|
+
this.initialContent = i.content, this.grid = new xo({ readOnly: o }), this.model = new jo(i), this.blockId = s == null ? void 0 : s.id, this.config.restrictedTools !== void 0 && (this.unregisterRestrictedTools = en(this.config.restrictedTools));
|
|
4122
4245
|
}
|
|
4123
4246
|
/**
|
|
4124
4247
|
* Execute a function within a structural operation lock.
|
|
@@ -4143,14 +4266,17 @@ class Ts {
|
|
|
4143
4266
|
* Execute a structural operation within a Yjs transaction.
|
|
4144
4267
|
* Combines the structural op lock (event deferral) with Yjs undo grouping.
|
|
4145
4268
|
* Used for interactive operations that should be a single undo entry.
|
|
4269
|
+
*
|
|
4270
|
+
* @param fn - The structural operation to execute
|
|
4271
|
+
* @param discard - If true, discard deferred events (forwarded to runStructuralOp)
|
|
4146
4272
|
*/
|
|
4147
|
-
runTransactedStructuralOp(t) {
|
|
4273
|
+
runTransactedStructuralOp(t, e = !1) {
|
|
4148
4274
|
if (!this.api.blocks.transact)
|
|
4149
|
-
return this.runStructuralOp(t);
|
|
4150
|
-
const
|
|
4275
|
+
return this.runStructuralOp(t, e);
|
|
4276
|
+
const n = { current: void 0 };
|
|
4151
4277
|
return this.api.blocks.transact(() => {
|
|
4152
|
-
|
|
4153
|
-
}),
|
|
4278
|
+
n.current = this.runStructuralOp(t, e);
|
|
4279
|
+
}), n.current;
|
|
4154
4280
|
}
|
|
4155
4281
|
/**
|
|
4156
4282
|
* Tear down all visual subsystems (resize, add-controls, row/col-controls,
|
|
@@ -4158,8 +4284,8 @@ class Ts {
|
|
|
4158
4284
|
* destroy(). Does NOT tear down cellBlocks — that has special Yjs handling.
|
|
4159
4285
|
*/
|
|
4160
4286
|
teardownSubsystems() {
|
|
4161
|
-
var t, e, n, o;
|
|
4162
|
-
(t = this.resize) == null || t.destroy(), this.resize = null, (e = this.addControls) == null || e.destroy(), this.addControls = null, (n = this.rowColControls) == null || n.destroy(), this.rowColControls = null, (o = this.cellSelection) == null || o.destroy(), this.cellSelection = null;
|
|
4287
|
+
var t, e, n, o, s;
|
|
4288
|
+
(t = this.resize) == null || t.destroy(), this.resize = null, (e = this.addControls) == null || e.destroy(), this.addControls = null, (n = this.rowColControls) == null || n.destroy(), this.rowColControls = null, (o = this.cellSelection) == null || o.destroy(), this.cellSelection = null, (s = this.scrollHaze) == null || s.destroy(), this.scrollHaze = null;
|
|
4163
4289
|
}
|
|
4164
4290
|
/**
|
|
4165
4291
|
* Initialize all visual subsystems on a grid element.
|
|
@@ -4167,11 +4293,11 @@ class Ts {
|
|
|
4167
4293
|
* subsystem initialization order.
|
|
4168
4294
|
*/
|
|
4169
4295
|
initSubsystems(t) {
|
|
4170
|
-
this.initResize(t), this.initAddControls(t), this.initRowColControls(t), this.initCellSelection(t), this.initGridPasteListener(t);
|
|
4296
|
+
this.initResize(t), this.initAddControls(t), this.initRowColControls(t), this.initCellSelection(t), this.initGridPasteListener(t), this.initScrollHaze();
|
|
4171
4297
|
}
|
|
4172
4298
|
static get toolbox() {
|
|
4173
4299
|
return {
|
|
4174
|
-
icon:
|
|
4300
|
+
icon: nn,
|
|
4175
4301
|
title: "Table",
|
|
4176
4302
|
titleKey: "tools.table.title",
|
|
4177
4303
|
searchTerms: ["table", "grid", "spreadsheet"]
|
|
@@ -4199,40 +4325,63 @@ class Ts {
|
|
|
4199
4325
|
}
|
|
4200
4326
|
};
|
|
4201
4327
|
}
|
|
4328
|
+
/**
|
|
4329
|
+
* Ensure a scroll container exists between the wrapper and the grid.
|
|
4330
|
+
* Creates one on demand (e.g. when the first resize converts percent → pixel mode).
|
|
4331
|
+
*/
|
|
4332
|
+
ensureScrollContainer() {
|
|
4333
|
+
if (this.scrollContainer)
|
|
4334
|
+
return this.scrollContainer;
|
|
4335
|
+
const t = document.createElement("div");
|
|
4336
|
+
t.setAttribute("data-blok-table-scroll", "");
|
|
4337
|
+
const e = this.gridElement;
|
|
4338
|
+
return e && this.element && (this.element.insertBefore(t, e), t.appendChild(e)), this.scrollContainer = t, t;
|
|
4339
|
+
}
|
|
4202
4340
|
render() {
|
|
4203
4341
|
var s, i, l, a, c, d, h;
|
|
4204
4342
|
const t = document.createElement("div");
|
|
4205
|
-
t.className =
|
|
4206
|
-
const e = ((l = this.initialContent) == null ? void 0 : l.length) || this.config.rows ||
|
|
4207
|
-
var
|
|
4208
|
-
return Math.max(u, (
|
|
4209
|
-
}, 0)) || this.config.cols ||
|
|
4210
|
-
|
|
4343
|
+
t.className = v(Ts, !this.readOnly && Bs), t.setAttribute(L.tool, "table"), this.readOnly && t.setAttribute("data-blok-table-readonly", ""), this.isNewTable = ((i = (s = this.initialContent) == null ? void 0 : s.length) != null ? i : 0) === 0;
|
|
4344
|
+
const e = ((l = this.initialContent) == null ? void 0 : l.length) || this.config.rows || Es, n = ((a = this.initialContent) == null ? void 0 : a.reduce((u, p) => {
|
|
4345
|
+
var C;
|
|
4346
|
+
return Math.max(u, (C = p == null ? void 0 : p.length) != null ? C : 0);
|
|
4347
|
+
}, 0)) || this.config.cols || xs, o = this.grid.createGrid(e, n, this.model.colWidths);
|
|
4348
|
+
if (((d = (c = this.initialContent) == null ? void 0 : c.length) != null ? d : 0) > 0 && this.grid.fillGrid(o, (h = this.initialContent) != null ? h : []), this.model.colWidths && dt(o, this.model.colWidths), this.gridElement = o, this.model.colWidths || !this.readOnly) {
|
|
4349
|
+
const u = document.createElement("div");
|
|
4350
|
+
u.setAttribute("data-blok-table-scroll", "");
|
|
4351
|
+
const p = this.model.colWidths ? we : [];
|
|
4352
|
+
u.classList.add(...p), u.appendChild(o), t.appendChild(u), this.scrollContainer = u;
|
|
4353
|
+
} else
|
|
4354
|
+
t.appendChild(o), this.scrollContainer = null;
|
|
4355
|
+
if (!this.readOnly) {
|
|
4356
|
+
const u = document.createElement("div");
|
|
4357
|
+
u.setAttribute("data-blok-table-grip-overlay", ""), u.style.position = "absolute", u.style.inset = "0", u.style.pointerEvents = "none", u.style.zIndex = "3", t.appendChild(u), this.gripOverlay = u;
|
|
4358
|
+
}
|
|
4359
|
+
return this.element = t, this.model.withHeadings && tt(this.gridElement, this.model.withHeadings), this.model.withHeadingColumn && G(this.gridElement, this.model.withHeadingColumn), this.readOnly || (this.initCellBlocks(o), Ko(o, this.cellBlocks)), t;
|
|
4211
4360
|
}
|
|
4212
4361
|
rendered() {
|
|
4213
4362
|
var n, o;
|
|
4214
4363
|
if (!this.element || this.initialContent === null)
|
|
4215
4364
|
return;
|
|
4216
|
-
const t = this.
|
|
4365
|
+
const t = this.gridElement;
|
|
4217
4366
|
if (!t)
|
|
4218
4367
|
return;
|
|
4219
4368
|
const e = this.initialContent;
|
|
4220
4369
|
if (this.initialContent = null, this.readOnly) {
|
|
4221
|
-
|
|
4370
|
+
Uo(t, e, this.api, (n = this.blockId) != null ? n : ""), this.initReadOnlyCellSelection(t), this.initScrollHaze();
|
|
4222
4371
|
return;
|
|
4223
4372
|
}
|
|
4224
|
-
if (this.
|
|
4373
|
+
if (this.runTransactedStructuralOp(() => {
|
|
4225
4374
|
var l, a;
|
|
4226
|
-
const s = (a = (l = this.cellBlocks) == null ? void 0 : l.initializeCells(e)) != null ? a : e, i = this.isNewTable && s.length === 0 ? Array.from(t.querySelectorAll(`[${
|
|
4375
|
+
const s = (a = (l = this.cellBlocks) == null ? void 0 : l.initializeCells(e)) != null ? a : e, i = this.isNewTable && s.length === 0 ? Array.from(t.querySelectorAll(`[${m}]`), (c) => {
|
|
4227
4376
|
const d = c.querySelectorAll(`[${g}]`).length;
|
|
4228
4377
|
return Array.from({ length: d }, () => ({ blocks: [] }));
|
|
4229
4378
|
}) : s;
|
|
4230
|
-
this.model.replaceAll(
|
|
4379
|
+
this.model.replaceAll(W(E({}, this.model.snapshot()), {
|
|
4231
4380
|
content: i
|
|
4232
|
-
})), this.isNewTable &&
|
|
4381
|
+
})), this.isNewTable && H(t, this.cellBlocks);
|
|
4233
4382
|
}, !0), this.model.initialColWidth === void 0) {
|
|
4234
|
-
const s = (o = this.model.colWidths) != null ? o :
|
|
4235
|
-
this.model.setInitialColWidth(s.length > 0 ?
|
|
4383
|
+
const s = (o = this.model.colWidths) != null ? o : z(t);
|
|
4384
|
+
this.model.setInitialColWidth(s.length > 0 ? Fo(s) : void 0);
|
|
4236
4385
|
}
|
|
4237
4386
|
if (this.initSubsystems(t), this.isNewTable) {
|
|
4238
4387
|
const s = t.querySelector('[contenteditable="true"]');
|
|
@@ -4250,15 +4399,15 @@ class Ts {
|
|
|
4250
4399
|
* Follows the onPaste() pattern: delete old blocks, re-render, reinitialize.
|
|
4251
4400
|
*/
|
|
4252
4401
|
setData(t) {
|
|
4253
|
-
var l
|
|
4402
|
+
var l;
|
|
4254
4403
|
this.setDataGeneration++;
|
|
4255
|
-
const e = this.setDataGeneration, n =
|
|
4404
|
+
const e = this.setDataGeneration, n = Vt(
|
|
4256
4405
|
E(E({}, this.model.snapshot()), t),
|
|
4257
4406
|
this.config
|
|
4258
4407
|
);
|
|
4259
4408
|
this.initialContent = n.content, this.model.replaceAll(n), this.api.blocks.isSyncingFromYjs || this.runStructuralOp(() => {
|
|
4260
|
-
var
|
|
4261
|
-
(
|
|
4409
|
+
var a;
|
|
4410
|
+
(a = this.cellBlocks) == null || a.deleteAllBlocks();
|
|
4262
4411
|
}, !0), (l = this.cellBlocks) == null || l.destroy();
|
|
4263
4412
|
const o = this.element;
|
|
4264
4413
|
if (!(o != null && o.parentNode) || e !== this.setDataGeneration)
|
|
@@ -4266,96 +4415,106 @@ class Ts {
|
|
|
4266
4415
|
this.teardownSubsystems();
|
|
4267
4416
|
const s = this.render();
|
|
4268
4417
|
o.parentNode.replaceChild(s, o);
|
|
4269
|
-
const i =
|
|
4418
|
+
const i = this.gridElement;
|
|
4270
4419
|
this.readOnly || !i || e === this.setDataGeneration && (this.runStructuralOp(() => {
|
|
4271
|
-
var d, h, u
|
|
4272
|
-
const
|
|
4273
|
-
e === this.setDataGeneration
|
|
4274
|
-
|
|
4275
|
-
|
|
4420
|
+
var c, d, h, u;
|
|
4421
|
+
const a = (u = (h = (d = this.cellBlocks) == null ? void 0 : d.initializeCells((c = this.initialContent) != null ? c : [])) != null ? h : this.initialContent) != null ? u : [];
|
|
4422
|
+
if (e === this.setDataGeneration) {
|
|
4423
|
+
if (this.api.blocks.isSyncingFromYjs && a.length === 0 && i) {
|
|
4424
|
+
const p = Array.from(i.querySelectorAll(`[${m}]`), (C) => {
|
|
4425
|
+
const f = C.querySelectorAll(`[${g}]`).length;
|
|
4426
|
+
return Array.from({ length: f }, () => ({ blocks: [] }));
|
|
4427
|
+
});
|
|
4428
|
+
this.model.replaceAll(W(E({}, this.model.snapshot()), {
|
|
4429
|
+
content: p
|
|
4430
|
+
})), H(i, this.cellBlocks);
|
|
4431
|
+
} else
|
|
4432
|
+
this.model.replaceAll(W(E({}, this.model.snapshot()), {
|
|
4433
|
+
content: a
|
|
4434
|
+
}));
|
|
4435
|
+
this.initialContent = null;
|
|
4436
|
+
}
|
|
4276
4437
|
}, !0), e === this.setDataGeneration && this.initSubsystems(i));
|
|
4277
4438
|
}
|
|
4278
4439
|
onPaste(t) {
|
|
4279
|
-
var h, u
|
|
4440
|
+
var h, u;
|
|
4280
4441
|
const e = t.detail.data, n = e.querySelectorAll("tr"), o = [];
|
|
4281
|
-
n.forEach((
|
|
4282
|
-
const C =
|
|
4283
|
-
C.forEach((
|
|
4284
|
-
|
|
4285
|
-
}),
|
|
4442
|
+
n.forEach((p) => {
|
|
4443
|
+
const C = p.querySelectorAll("td, th"), f = [];
|
|
4444
|
+
C.forEach((y) => {
|
|
4445
|
+
f.push(y.innerHTML);
|
|
4446
|
+
}), f.length > 0 && o.push(f);
|
|
4286
4447
|
});
|
|
4287
4448
|
const s = e.querySelector("thead") !== null, i = ((h = n[0]) == null ? void 0 : h.querySelector("th")) !== null, l = s || i;
|
|
4288
4449
|
this.initialContent = o, this.model.setWithHeadings(l), this.model.setWithHeadingColumn(!1), this.model.setColWidths(void 0), this.runStructuralOp(() => {
|
|
4289
|
-
var
|
|
4290
|
-
(
|
|
4450
|
+
var p;
|
|
4451
|
+
(p = this.cellBlocks) == null || p.deleteAllBlocks();
|
|
4291
4452
|
}, !0), (u = this.cellBlocks) == null || u.destroy(), this.teardownSubsystems();
|
|
4292
4453
|
const a = this.element;
|
|
4293
4454
|
if (!(a != null && a.parentNode))
|
|
4294
4455
|
return;
|
|
4295
4456
|
const c = this.render();
|
|
4296
4457
|
a.parentNode.replaceChild(c, a);
|
|
4297
|
-
const d =
|
|
4458
|
+
const d = this.gridElement;
|
|
4298
4459
|
!this.readOnly && d && (this.runStructuralOp(() => {
|
|
4299
|
-
var C,
|
|
4300
|
-
const
|
|
4301
|
-
this.model.replaceAll(
|
|
4302
|
-
content:
|
|
4460
|
+
var C, f, y, S;
|
|
4461
|
+
const p = (S = (y = (f = this.cellBlocks) == null ? void 0 : f.initializeCells((C = this.initialContent) != null ? C : [])) != null ? y : this.initialContent) != null ? S : [];
|
|
4462
|
+
this.model.replaceAll(W(E({}, this.model.snapshot()), {
|
|
4463
|
+
content: p
|
|
4303
4464
|
})), this.initialContent = null;
|
|
4304
4465
|
}, !0), this.initSubsystems(d));
|
|
4305
4466
|
}
|
|
4306
4467
|
destroy() {
|
|
4307
4468
|
var t, e, n;
|
|
4308
|
-
(t = this.unregisterRestrictedTools) == null || t.call(this), this.unregisterRestrictedTools = null, this.api.blocks.isSyncingFromYjs || (e = this.cellBlocks) == null || e.deleteAllBlocks(), this.teardownSubsystems(), (n = this.cellBlocks) == null || n.destroy(), this.cellBlocks = null, this.element = null;
|
|
4469
|
+
(t = this.unregisterRestrictedTools) == null || t.call(this), this.unregisterRestrictedTools = null, this.api.blocks.isSyncingFromYjs || (e = this.cellBlocks) == null || e.deleteAllBlocks(), this.teardownSubsystems(), (n = this.cellBlocks) == null || n.destroy(), this.cellBlocks = null, this.gridElement = null, this.scrollContainer = null, this.element = null;
|
|
4309
4470
|
}
|
|
4310
4471
|
deleteRowWithCleanup(t) {
|
|
4311
|
-
|
|
4312
|
-
const e = (n = this.element) == null ? void 0 : n.firstElementChild;
|
|
4472
|
+
const e = this.gridElement;
|
|
4313
4473
|
e && this.runTransactedStructuralOp(() => {
|
|
4314
|
-
var
|
|
4315
|
-
const { blocksToDelete:
|
|
4316
|
-
(
|
|
4474
|
+
var o;
|
|
4475
|
+
const { blocksToDelete: n } = this.model.deleteRow(t);
|
|
4476
|
+
(o = this.cellBlocks) == null || o.deleteBlocks(n), this.grid.deleteRow(e, t);
|
|
4317
4477
|
});
|
|
4318
4478
|
}
|
|
4319
4479
|
deleteColumnWithCleanup(t) {
|
|
4320
|
-
|
|
4321
|
-
const e = (n = this.element) == null ? void 0 : n.firstElementChild;
|
|
4480
|
+
const e = this.gridElement;
|
|
4322
4481
|
e && this.runTransactedStructuralOp(() => {
|
|
4323
|
-
var
|
|
4324
|
-
const { blocksToDelete:
|
|
4325
|
-
(
|
|
4482
|
+
var o;
|
|
4483
|
+
const { blocksToDelete: n } = this.model.deleteColumn(t);
|
|
4484
|
+
(o = this.cellBlocks) == null || o.deleteBlocks(n), this.grid.deleteColumn(e, t);
|
|
4326
4485
|
});
|
|
4327
4486
|
}
|
|
4328
4487
|
getBlockIdsInRow(t) {
|
|
4329
|
-
return
|
|
4488
|
+
return zo(this.element, this.cellBlocks, t);
|
|
4330
4489
|
}
|
|
4331
4490
|
getBlockIdsInColumn(t) {
|
|
4332
|
-
return
|
|
4491
|
+
return Vo(this.element, this.cellBlocks, t);
|
|
4333
4492
|
}
|
|
4334
4493
|
initAddControls(t) {
|
|
4335
4494
|
var n;
|
|
4336
4495
|
if ((n = this.addControls) == null || n.destroy(), !this.element)
|
|
4337
4496
|
return;
|
|
4338
4497
|
const e = { addedCols: 0 };
|
|
4339
|
-
this.addControls = new
|
|
4498
|
+
this.addControls = new wo({
|
|
4340
4499
|
wrapper: this.element,
|
|
4341
4500
|
grid: t,
|
|
4342
4501
|
i18n: this.api.i18n,
|
|
4343
4502
|
getNewColumnWidth: () => {
|
|
4344
4503
|
var s;
|
|
4345
|
-
const o = (s = this.model.colWidths) != null ? s :
|
|
4504
|
+
const o = (s = this.model.colWidths) != null ? s : z(t);
|
|
4346
4505
|
return this.model.initialColWidth !== void 0 ? Math.round(this.model.initialColWidth / 2 * 100) / 100 : et(o);
|
|
4347
4506
|
},
|
|
4348
4507
|
onAddRow: () => {
|
|
4349
4508
|
this.runTransactedStructuralOp(() => {
|
|
4350
4509
|
var o, s;
|
|
4351
|
-
this.grid.addRow(t), this.model.addRow(),
|
|
4510
|
+
this.grid.addRow(t), this.model.addRow(), H(t, this.cellBlocks), tt(this.gridElement, this.model.withHeadings), G(this.gridElement, this.model.withHeadingColumn), this.initResize(t), (o = this.addControls) == null || o.syncRowButtonWidth(), (s = this.rowColControls) == null || s.refresh();
|
|
4352
4511
|
});
|
|
4353
4512
|
},
|
|
4354
4513
|
onAddColumn: () => {
|
|
4355
4514
|
this.runTransactedStructuralOp(() => {
|
|
4356
4515
|
var i, l, a;
|
|
4357
|
-
const o = (i = this.model.colWidths) != null ? i :
|
|
4358
|
-
this.grid.addColumn(t, void 0, o, s), this.model.addColumn(void 0, s), this.model.setColWidths([...o, s]),
|
|
4516
|
+
const o = (i = this.model.colWidths) != null ? i : z(t), s = this.model.initialColWidth !== void 0 ? Math.round(this.model.initialColWidth / 2 * 100) / 100 : et(o);
|
|
4517
|
+
this.grid.addColumn(t, void 0, o, s), this.model.addColumn(void 0, s), this.model.setColWidths([...o, s]), H(t, this.cellBlocks), G(this.gridElement, this.model.withHeadingColumn), this.initResize(t), (l = this.addControls) == null || l.syncRowButtonWidth(), (a = this.rowColControls) == null || a.refresh(), this.scrollContainer && (this.scrollContainer.scrollLeft = this.scrollContainer.scrollWidth);
|
|
4359
4518
|
});
|
|
4360
4519
|
},
|
|
4361
4520
|
onDragStart: () => {
|
|
@@ -4364,14 +4523,14 @@ class Ts {
|
|
|
4364
4523
|
},
|
|
4365
4524
|
onDragAddRow: () => {
|
|
4366
4525
|
this.runTransactedStructuralOp(() => {
|
|
4367
|
-
this.grid.addRow(t), this.model.addRow(),
|
|
4526
|
+
this.grid.addRow(t), this.model.addRow(), H(t, this.cellBlocks), tt(this.gridElement, this.model.withHeadings), G(this.gridElement, this.model.withHeadingColumn);
|
|
4368
4527
|
});
|
|
4369
4528
|
},
|
|
4370
4529
|
onDragRemoveRow: () => {
|
|
4371
4530
|
this.runTransactedStructuralOp(() => {
|
|
4372
4531
|
var s;
|
|
4373
4532
|
const o = this.grid.getRowCount(t);
|
|
4374
|
-
if (o > 1 &&
|
|
4533
|
+
if (o > 1 && Mo(t, o - 1)) {
|
|
4375
4534
|
const { blocksToDelete: i } = this.model.deleteRow(o - 1);
|
|
4376
4535
|
(s = this.cellBlocks) == null || s.deleteBlocks(i), this.grid.deleteRow(t, o - 1);
|
|
4377
4536
|
}
|
|
@@ -4380,15 +4539,15 @@ class Ts {
|
|
|
4380
4539
|
onDragAddCol: () => {
|
|
4381
4540
|
this.runTransactedStructuralOp(() => {
|
|
4382
4541
|
var l;
|
|
4383
|
-
const o = (l = this.model.colWidths) != null ? l :
|
|
4384
|
-
this.grid.addColumn(t, void 0, o, s), this.model.addColumn(void 0, s), this.model.setColWidths(i), dt(t, i),
|
|
4542
|
+
const o = (l = this.model.colWidths) != null ? l : z(t), s = this.model.initialColWidth !== void 0 ? Math.round(this.model.initialColWidth / 2 * 100) / 100 : et(o), i = [...o, s];
|
|
4543
|
+
this.grid.addColumn(t, void 0, o, s), this.model.addColumn(void 0, s), this.model.setColWidths(i), dt(t, i), H(t, this.cellBlocks), G(this.gridElement, this.model.withHeadingColumn), this.initResize(t), e.addedCols++, this.scrollContainer && (this.scrollContainer.scrollLeft = this.scrollContainer.scrollWidth);
|
|
4385
4544
|
});
|
|
4386
4545
|
},
|
|
4387
4546
|
onDragRemoveCol: () => {
|
|
4388
4547
|
this.runTransactedStructuralOp(() => {
|
|
4389
4548
|
var l;
|
|
4390
4549
|
const o = this.grid.getColumnCount(t);
|
|
4391
|
-
if (o <= 1 || !
|
|
4550
|
+
if (o <= 1 || !_o(t, o - 1))
|
|
4392
4551
|
return;
|
|
4393
4552
|
const { blocksToDelete: s } = this.model.deleteColumn(o - 1);
|
|
4394
4553
|
(l = this.cellBlocks) == null || l.deleteBlocks(s), this.grid.deleteColumn(t, o - 1);
|
|
@@ -4398,48 +4557,50 @@ class Ts {
|
|
|
4398
4557
|
},
|
|
4399
4558
|
onDragEnd: () => {
|
|
4400
4559
|
var o, s;
|
|
4401
|
-
this.initResize(t), (o = this.addControls) == null || o.syncRowButtonWidth(), (s = this.rowColControls) == null || s.refresh(), this.
|
|
4560
|
+
this.initResize(t), (o = this.addControls) == null || o.syncRowButtonWidth(), (s = this.rowColControls) == null || s.refresh(), this.scrollContainer && (this.scrollContainer.scrollLeft = e.addedCols > 0 ? this.scrollContainer.scrollWidth : 0), e.addedCols = 0;
|
|
4402
4561
|
}
|
|
4403
4562
|
});
|
|
4404
4563
|
}
|
|
4405
4564
|
initRowColControls(t) {
|
|
4406
|
-
var e;
|
|
4407
|
-
(e = this.rowColControls) == null || e.destroy(), this.element && (this.rowColControls = new
|
|
4565
|
+
var e, n, o;
|
|
4566
|
+
(e = this.rowColControls) == null || e.destroy(), this.element && (this.rowColControls = new bs({
|
|
4408
4567
|
grid: t,
|
|
4568
|
+
overlay: (n = this.gripOverlay) != null ? n : void 0,
|
|
4569
|
+
scrollContainer: (o = this.scrollContainer) != null ? o : void 0,
|
|
4409
4570
|
getColumnCount: () => this.grid.getColumnCount(t),
|
|
4410
4571
|
getRowCount: () => this.grid.getRowCount(t),
|
|
4411
4572
|
isHeadingRow: () => this.model.withHeadings,
|
|
4412
4573
|
isHeadingColumn: () => this.model.withHeadingColumn,
|
|
4413
4574
|
i18n: this.api.i18n,
|
|
4414
|
-
onAction: (
|
|
4415
|
-
onDragStateChange: (
|
|
4416
|
-
var
|
|
4417
|
-
this.resize && (this.resize.enabled = !
|
|
4575
|
+
onAction: (s) => this.handleRowColAction(t, s),
|
|
4576
|
+
onDragStateChange: (s) => {
|
|
4577
|
+
var i;
|
|
4578
|
+
this.resize && (this.resize.enabled = !s), (i = this.addControls) == null || i.setDisplay(!s), s && this.api.toolbar.close({ setExplicitlyClosed: !1 });
|
|
4418
4579
|
},
|
|
4419
|
-
onGripClick: (
|
|
4420
|
-
var
|
|
4421
|
-
|
|
4580
|
+
onGripClick: (s, i) => {
|
|
4581
|
+
var l, a;
|
|
4582
|
+
s === "row" ? (l = this.cellSelection) == null || l.selectRow(i) : (a = this.cellSelection) == null || a.selectColumn(i);
|
|
4422
4583
|
},
|
|
4423
4584
|
onGripPopoverClose: () => {
|
|
4424
|
-
var
|
|
4585
|
+
var s, i;
|
|
4425
4586
|
if (this.pendingHighlight) {
|
|
4426
|
-
const { type:
|
|
4427
|
-
this.pendingHighlight = null, (
|
|
4428
|
-
var
|
|
4429
|
-
|
|
4587
|
+
const { type: l, index: a } = this.pendingHighlight;
|
|
4588
|
+
this.pendingHighlight = null, (s = this.rowColControls) == null || s.setActiveGrip(l, a), requestAnimationFrame(() => {
|
|
4589
|
+
var c, d;
|
|
4590
|
+
l === "row" ? (c = this.cellSelection) == null || c.selectRow(a) : (d = this.cellSelection) == null || d.selectColumn(a);
|
|
4430
4591
|
});
|
|
4431
4592
|
} else
|
|
4432
|
-
(
|
|
4593
|
+
(i = this.cellSelection) == null || i.clearActiveSelection();
|
|
4433
4594
|
}
|
|
4434
4595
|
}));
|
|
4435
4596
|
}
|
|
4436
4597
|
handleRowColAction(t, e) {
|
|
4437
4598
|
const n = this.setDataGeneration;
|
|
4438
4599
|
this.runTransactedStructuralOp(() => {
|
|
4439
|
-
var c, d, h, u, p
|
|
4440
|
-
if (n !== this.setDataGeneration ||
|
|
4600
|
+
var c, d, h, u, p;
|
|
4601
|
+
if (n !== this.setDataGeneration || this.gridElement !== t)
|
|
4441
4602
|
return;
|
|
4442
|
-
const o = this.model.colWidths, { blocksToDelete: s } = this.syncModelForAction(e), i =
|
|
4603
|
+
const o = this.model.colWidths, { blocksToDelete: s } = this.syncModelForAction(e), i = os(
|
|
4443
4604
|
t,
|
|
4444
4605
|
e,
|
|
4445
4606
|
{
|
|
@@ -4454,10 +4615,10 @@ class Ts {
|
|
|
4454
4615
|
blocksToDelete: s
|
|
4455
4616
|
}
|
|
4456
4617
|
);
|
|
4457
|
-
if (n !== this.setDataGeneration ||
|
|
4618
|
+
if (n !== this.setDataGeneration || this.gridElement !== t || (this.model.setColWidths(i.colWidths), this.model.setWithHeadings(i.withHeadings), this.model.setWithHeadingColumn(i.withHeadingColumn), this.pendingHighlight = i.pendingHighlight, tt(this.gridElement, this.model.withHeadings), G(this.gridElement, this.model.withHeadingColumn), this.initResize(t), (c = this.addControls) == null || c.syncRowButtonWidth(), (d = this.rowColControls) == null || d.refresh(), !i.moveSelection))
|
|
4458
4619
|
return;
|
|
4459
4620
|
const { type: l, index: a } = i.moveSelection;
|
|
4460
|
-
l === "row" ? (
|
|
4621
|
+
l === "row" ? (h = this.cellSelection) == null || h.selectRow(a) : (u = this.cellSelection) == null || u.selectColumn(a), (p = this.rowColControls) == null || p.setActiveGrip(l, a);
|
|
4461
4622
|
});
|
|
4462
4623
|
}
|
|
4463
4624
|
syncModelForAction(t) {
|
|
@@ -4490,28 +4651,28 @@ class Ts {
|
|
|
4490
4651
|
initResize(t) {
|
|
4491
4652
|
var o, s;
|
|
4492
4653
|
(o = this.resize) == null || o.destroy();
|
|
4493
|
-
const e = this.model.colWidths === void 0, n = (s = this.model.colWidths) != null ? s :
|
|
4494
|
-
e ||
|
|
4654
|
+
const e = this.model.colWidths === void 0, n = (s = this.model.colWidths) != null ? s : z(t);
|
|
4655
|
+
e || Ut(this.ensureScrollContainer()), this.resize = new Jo(
|
|
4495
4656
|
t,
|
|
4496
4657
|
n,
|
|
4497
4658
|
(i) => {
|
|
4498
|
-
var l;
|
|
4499
|
-
this.model.setColWidths(i),
|
|
4659
|
+
var l, a, c;
|
|
4660
|
+
this.model.setColWidths(i), Ut(this.ensureScrollContainer()), (l = this.rowColControls) == null || l.positionGrips(), (a = this.addControls) == null || a.syncRowButtonWidth(), (c = this.scrollHaze) == null || c.update();
|
|
4500
4661
|
},
|
|
4501
4662
|
() => {
|
|
4502
4663
|
var i;
|
|
4503
4664
|
(i = this.rowColControls) == null || i.hideAllGrips();
|
|
4504
4665
|
},
|
|
4505
4666
|
() => {
|
|
4506
|
-
var i;
|
|
4507
|
-
(i = this.addControls) == null || i.syncRowButtonWidth();
|
|
4667
|
+
var i, l;
|
|
4668
|
+
(i = this.addControls) == null || i.syncRowButtonWidth(), (l = this.scrollHaze) == null || l.update();
|
|
4508
4669
|
},
|
|
4509
4670
|
e
|
|
4510
4671
|
);
|
|
4511
4672
|
}
|
|
4512
4673
|
initCellBlocks(t) {
|
|
4513
4674
|
var e;
|
|
4514
|
-
this.cellBlocks = new
|
|
4675
|
+
this.cellBlocks = new To({
|
|
4515
4676
|
api: this.api,
|
|
4516
4677
|
gridElement: t,
|
|
4517
4678
|
tableBlockId: (e = this.blockId) != null ? e : "",
|
|
@@ -4523,52 +4684,67 @@ class Ts {
|
|
|
4523
4684
|
const n = this.collectCellBlockData(t);
|
|
4524
4685
|
if (n.length === 0)
|
|
4525
4686
|
return;
|
|
4526
|
-
const o =
|
|
4527
|
-
e.setData("text/html",
|
|
4687
|
+
const o = Rt(n);
|
|
4688
|
+
e.setData("text/html", Lt(o)), e.setData("text/plain", It(o));
|
|
4689
|
+
}
|
|
4690
|
+
handleCellCopyViaButton(t) {
|
|
4691
|
+
const e = this.collectCellBlockData(t);
|
|
4692
|
+
if (e.length === 0)
|
|
4693
|
+
return;
|
|
4694
|
+
const n = Rt(e), o = Lt(n), s = It(n), i = new Blob([o], { type: "text/html" }), l = new Blob([s], { type: "text/plain" });
|
|
4695
|
+
navigator.clipboard.write([
|
|
4696
|
+
new ClipboardItem({
|
|
4697
|
+
"text/html": i,
|
|
4698
|
+
"text/plain": l
|
|
4699
|
+
})
|
|
4700
|
+
]);
|
|
4528
4701
|
}
|
|
4529
4702
|
collectCellBlockData(t) {
|
|
4530
|
-
|
|
4531
|
-
const e = (o = this.element) == null ? void 0 : o.firstElementChild;
|
|
4703
|
+
const e = this.gridElement;
|
|
4532
4704
|
if (!e)
|
|
4533
4705
|
return [];
|
|
4534
|
-
const n = Array.from(e.querySelectorAll(`[${
|
|
4535
|
-
return t.map((
|
|
4536
|
-
var
|
|
4537
|
-
const
|
|
4538
|
-
if (!
|
|
4706
|
+
const n = Array.from(e.querySelectorAll(`[${m}]`));
|
|
4707
|
+
return t.map((o) => {
|
|
4708
|
+
var u;
|
|
4709
|
+
const s = o.closest(`[${m}]`);
|
|
4710
|
+
if (!s)
|
|
4539
4711
|
return null;
|
|
4540
|
-
const
|
|
4541
|
-
if (!
|
|
4542
|
-
return { row:
|
|
4543
|
-
|
|
4544
|
-
const C =
|
|
4712
|
+
const i = n.indexOf(s), a = Array.from(s.querySelectorAll(`[${g}]`)).indexOf(o), c = o.querySelector(`[${R}]`), d = [];
|
|
4713
|
+
if (!c)
|
|
4714
|
+
return { row: i, col: a, blocks: d };
|
|
4715
|
+
c.querySelectorAll("[data-blok-id]").forEach((p) => {
|
|
4716
|
+
const C = p.getAttribute("data-blok-id");
|
|
4545
4717
|
if (!C)
|
|
4546
4718
|
return;
|
|
4547
|
-
const
|
|
4548
|
-
if (
|
|
4719
|
+
const f = this.api.blocks.getBlockIndex(C);
|
|
4720
|
+
if (f === void 0)
|
|
4549
4721
|
return;
|
|
4550
|
-
const
|
|
4551
|
-
|
|
4552
|
-
tool:
|
|
4553
|
-
data:
|
|
4554
|
-
}, Object.keys(
|
|
4722
|
+
const y = this.api.blocks.getBlockByIndex(f);
|
|
4723
|
+
y && d.push(E({
|
|
4724
|
+
tool: y.name,
|
|
4725
|
+
data: y.preservedData
|
|
4726
|
+
}, Object.keys(y.preservedTunes).length > 0 ? { tunes: y.preservedTunes } : {}));
|
|
4555
4727
|
});
|
|
4556
|
-
const
|
|
4557
|
-
return
|
|
4728
|
+
const h = d.length === 0 ? ((u = c.textContent) != null ? u : "").trim() : "";
|
|
4729
|
+
return d.length === 0 && h.length > 0 && d.push({
|
|
4558
4730
|
tool: "paragraph",
|
|
4559
|
-
data: { text:
|
|
4560
|
-
}), { row:
|
|
4561
|
-
}).filter((
|
|
4731
|
+
data: { text: h }
|
|
4732
|
+
}), { row: i, col: a, blocks: d };
|
|
4733
|
+
}).filter((o) => o !== null);
|
|
4562
4734
|
}
|
|
4563
4735
|
initCellSelection(t) {
|
|
4564
4736
|
var n;
|
|
4565
4737
|
(n = this.cellSelection) == null || n.destroy();
|
|
4566
4738
|
const e = this.api.rectangleSelection;
|
|
4567
|
-
this.cellSelection = new
|
|
4739
|
+
this.cellSelection = new zt({
|
|
4568
4740
|
grid: t,
|
|
4569
4741
|
rectangleSelection: e,
|
|
4570
4742
|
// Pass reference
|
|
4571
4743
|
i18n: this.api.i18n,
|
|
4744
|
+
isPopoverOpen: () => {
|
|
4745
|
+
var o, s;
|
|
4746
|
+
return (s = (o = this.rowColControls) == null ? void 0 : o.isPopoverOpen) != null ? s : !1;
|
|
4747
|
+
},
|
|
4572
4748
|
onSelectionActiveChange: (o) => {
|
|
4573
4749
|
var s, i;
|
|
4574
4750
|
this.resize && (this.resize.enabled = !o), (s = this.addControls) == null || s.setInteractive(!o), (i = this.rowColControls) == null || i.setGripsDisplay(!o);
|
|
@@ -4584,6 +4760,9 @@ class Ts {
|
|
|
4584
4760
|
},
|
|
4585
4761
|
onCut: (o, s) => {
|
|
4586
4762
|
this.handleCellCopy(o, s);
|
|
4763
|
+
},
|
|
4764
|
+
onCopyViaButton: (o) => {
|
|
4765
|
+
this.handleCellCopyViaButton(o);
|
|
4587
4766
|
}
|
|
4588
4767
|
});
|
|
4589
4768
|
}
|
|
@@ -4591,15 +4770,22 @@ class Ts {
|
|
|
4591
4770
|
var n;
|
|
4592
4771
|
(n = this.cellSelection) == null || n.destroy();
|
|
4593
4772
|
const e = this.api.rectangleSelection;
|
|
4594
|
-
this.cellSelection = new
|
|
4773
|
+
this.cellSelection = new zt({
|
|
4595
4774
|
grid: t,
|
|
4596
4775
|
rectangleSelection: e,
|
|
4597
4776
|
i18n: this.api.i18n,
|
|
4598
4777
|
onCopy: (o, s) => {
|
|
4599
4778
|
this.handleCellCopy(o, s);
|
|
4779
|
+
},
|
|
4780
|
+
onCopyViaButton: (o) => {
|
|
4781
|
+
this.handleCellCopyViaButton(o);
|
|
4600
4782
|
}
|
|
4601
4783
|
});
|
|
4602
4784
|
}
|
|
4785
|
+
initScrollHaze() {
|
|
4786
|
+
var t;
|
|
4787
|
+
(t = this.scrollHaze) == null || t.destroy(), !(!this.element || !this.scrollContainer) && (this.scrollHaze = new As(), this.scrollHaze.init(this.element, this.scrollContainer));
|
|
4788
|
+
}
|
|
4603
4789
|
initGridPasteListener(t) {
|
|
4604
4790
|
t.addEventListener("paste", (e) => {
|
|
4605
4791
|
this.handleGridPaste(e, t);
|
|
@@ -4608,7 +4794,7 @@ class Ts {
|
|
|
4608
4794
|
handleGridPaste(t, e) {
|
|
4609
4795
|
if (this.readOnly || !t.clipboardData || t.defaultPrevented)
|
|
4610
4796
|
return;
|
|
4611
|
-
const n = t.clipboardData.getData("text/html"), o =
|
|
4797
|
+
const n = t.clipboardData.getData("text/html"), o = on(n), s = o === null ? sn(n) : null, i = o != null ? o : s;
|
|
4612
4798
|
if (!i || s !== null && new DOMParser().parseFromString(n, "text/html").querySelectorAll("table").length > 1)
|
|
4613
4799
|
return;
|
|
4614
4800
|
const l = document.activeElement;
|
|
@@ -4617,35 +4803,35 @@ class Ts {
|
|
|
4617
4803
|
const a = l.closest(`[${g}]`);
|
|
4618
4804
|
if (!a || !e.contains(a))
|
|
4619
4805
|
return;
|
|
4620
|
-
const c = a.closest(`[${
|
|
4806
|
+
const c = a.closest(`[${m}]`);
|
|
4621
4807
|
if (!c)
|
|
4622
4808
|
return;
|
|
4623
4809
|
t.preventDefault(), t.stopPropagation();
|
|
4624
|
-
const h = Array.from(e.querySelectorAll(`[${
|
|
4810
|
+
const h = Array.from(e.querySelectorAll(`[${m}]`)).indexOf(c), p = Array.from(c.querySelectorAll(`[${g}]`)).indexOf(a);
|
|
4625
4811
|
this.pastePayloadIntoCells(e, i, h, p);
|
|
4626
4812
|
}
|
|
4627
4813
|
pastePayloadIntoCells(t, e, n, o) {
|
|
4628
4814
|
this.runTransactedStructuralOp(() => {
|
|
4629
4815
|
var h, u;
|
|
4630
4816
|
this.expandGridForPaste(t, n + e.rows, o + e.cols);
|
|
4631
|
-
const d = t.querySelectorAll(`[${
|
|
4632
|
-
Array.from({ length: e.rows }, (p,
|
|
4633
|
-
const
|
|
4634
|
-
if (!
|
|
4817
|
+
const d = t.querySelectorAll(`[${m}]`);
|
|
4818
|
+
Array.from({ length: e.rows }, (p, C) => C).forEach((p) => {
|
|
4819
|
+
const C = d[n + p];
|
|
4820
|
+
if (!C)
|
|
4635
4821
|
return;
|
|
4636
|
-
const
|
|
4637
|
-
Array.from({ length: e.cols }, (y,
|
|
4822
|
+
const f = C.querySelectorAll(`[${g}]`);
|
|
4823
|
+
Array.from({ length: e.cols }, (y, S) => S).forEach((y) => {
|
|
4638
4824
|
var k, A;
|
|
4639
|
-
const
|
|
4640
|
-
if (
|
|
4641
|
-
this.pasteCellPayload(
|
|
4642
|
-
const T = (A = (k = this.cellBlocks) == null ? void 0 : k.getBlockIdsFromCells([
|
|
4825
|
+
const S = f[o + y];
|
|
4826
|
+
if (S) {
|
|
4827
|
+
this.pasteCellPayload(S, e.cells[p][y]);
|
|
4828
|
+
const T = (A = (k = this.cellBlocks) == null ? void 0 : k.getBlockIdsFromCells([S])) != null ? A : [];
|
|
4643
4829
|
this.model.setCellBlocks(n + p, o + y, T);
|
|
4644
4830
|
}
|
|
4645
4831
|
});
|
|
4646
4832
|
}), this.initResize(t), (h = this.addControls) == null || h.syncRowButtonWidth(), (u = this.rowColControls) == null || u.refresh();
|
|
4647
4833
|
});
|
|
4648
|
-
const i = t.querySelectorAll(`[${
|
|
4834
|
+
const i = t.querySelectorAll(`[${m}]`)[n + e.rows - 1], l = i == null ? void 0 : i.querySelectorAll(`[${g}]`)[o + e.cols - 1];
|
|
4649
4835
|
if (!l || !this.cellBlocks || !this.api.caret)
|
|
4650
4836
|
return;
|
|
4651
4837
|
const a = this.cellBlocks.getBlockIdsFromCells([l]), c = a[a.length - 1];
|
|
@@ -4657,11 +4843,11 @@ class Ts {
|
|
|
4657
4843
|
expandGridForPaste(t, e, n) {
|
|
4658
4844
|
const o = this.grid.getRowCount(t), s = this.grid.getColumnCount(t);
|
|
4659
4845
|
Array.from({ length: Math.max(0, e - o) }).forEach(() => {
|
|
4660
|
-
this.grid.addRow(t), this.model.addRow(),
|
|
4846
|
+
this.grid.addRow(t), this.model.addRow(), H(t, this.cellBlocks), tt(this.gridElement, this.model.withHeadings), G(this.gridElement, this.model.withHeadingColumn);
|
|
4661
4847
|
}), Array.from({ length: Math.max(0, n - s) }).forEach(() => {
|
|
4662
4848
|
var a;
|
|
4663
|
-
const i = (a = this.model.colWidths) != null ? a :
|
|
4664
|
-
this.grid.addColumn(t, void 0, i, l), this.model.addColumn(void 0, l), this.model.setColWidths([...i, l]),
|
|
4849
|
+
const i = (a = this.model.colWidths) != null ? a : z(t), l = this.model.initialColWidth !== void 0 ? Math.round(this.model.initialColWidth / 2 * 100) / 100 : et(i);
|
|
4850
|
+
this.grid.addColumn(t, void 0, i, l), this.model.addColumn(void 0, l), this.model.setColWidths([...i, l]), H(t, this.cellBlocks), G(this.gridElement, this.model.withHeadingColumn);
|
|
4665
4851
|
});
|
|
4666
4852
|
}
|
|
4667
4853
|
/**
|
|
@@ -4692,10 +4878,10 @@ class Ts {
|
|
|
4692
4878
|
}
|
|
4693
4879
|
}
|
|
4694
4880
|
}
|
|
4695
|
-
const
|
|
4881
|
+
const V = (r) => {
|
|
4696
4882
|
const t = r.tagName;
|
|
4697
4883
|
return t === "B" || t === "STRONG";
|
|
4698
|
-
}, pt = (r) => !!(r && r.nodeType === Node.ELEMENT_NODE &&
|
|
4884
|
+
}, pt = (r) => !!(r && r.nodeType === Node.ELEMENT_NODE && V(r)), Ae = (r) => r.textContent.length === 0, N = (r) => r ? r.nodeType === Node.ELEMENT_NODE && V(r) ? _(r) : N(r.parentNode) : null, _ = (r) => {
|
|
4699
4885
|
if (r.tagName === "STRONG")
|
|
4700
4886
|
return r;
|
|
4701
4887
|
const t = document.createElement("strong");
|
|
@@ -4704,7 +4890,7 @@ const z = (r) => {
|
|
|
4704
4890
|
}); r.firstChild; )
|
|
4705
4891
|
t.appendChild(r.firstChild);
|
|
4706
4892
|
return r.replaceWith(t), t;
|
|
4707
|
-
},
|
|
4893
|
+
}, Rs = (r) => {
|
|
4708
4894
|
const t = r.nextSibling;
|
|
4709
4895
|
if ((t == null ? void 0 : t.nodeType) === Node.TEXT_NODE)
|
|
4710
4896
|
return t;
|
|
@@ -4713,15 +4899,15 @@ const z = (r) => {
|
|
|
4713
4899
|
return null;
|
|
4714
4900
|
const n = r.ownerDocument.createTextNode("");
|
|
4715
4901
|
return e.insertBefore(n, t), n;
|
|
4716
|
-
},
|
|
4902
|
+
}, Ls = (r) => {
|
|
4717
4903
|
if (!r.boldElement.isConnected)
|
|
4718
4904
|
return null;
|
|
4719
|
-
const t = _(r.boldElement), e = r.boundary, o = e.isConnected && e.previousSibling === t ? e :
|
|
4905
|
+
const t = _(r.boldElement), e = r.boundary, o = e.isConnected && e.previousSibling === t ? e : Rs(t);
|
|
4720
4906
|
return o ? {
|
|
4721
4907
|
boundary: o,
|
|
4722
4908
|
boldElement: t
|
|
4723
4909
|
} : null;
|
|
4724
|
-
},
|
|
4910
|
+
}, St = (r, t) => r ? r === t || t.contains(r) : !1, w = {
|
|
4725
4911
|
COLLAPSED_LENGTH: "data-blok-bold-collapsed-length",
|
|
4726
4912
|
COLLAPSED_ACTIVE: "data-blok-bold-collapsed-active",
|
|
4727
4913
|
PREV_LENGTH: "data-blok-bold-prev-length",
|
|
@@ -4754,13 +4940,13 @@ const z = (r) => {
|
|
|
4754
4940
|
* @param element - The element to check
|
|
4755
4941
|
*/
|
|
4756
4942
|
isActivePlaceholder(t) {
|
|
4757
|
-
return t.getAttribute(
|
|
4943
|
+
return t.getAttribute(w.COLLAPSED_ACTIVE) === "true" || t.hasAttribute(w.COLLAPSED_LENGTH);
|
|
4758
4944
|
}
|
|
4759
4945
|
/**
|
|
4760
4946
|
* Get the ATTR constants for external use
|
|
4761
4947
|
*/
|
|
4762
4948
|
static get ATTR() {
|
|
4763
|
-
return
|
|
4949
|
+
return w;
|
|
4764
4950
|
}
|
|
4765
4951
|
/**
|
|
4766
4952
|
* Enter collapsed bold mode by inserting an empty <strong> for typing
|
|
@@ -4771,7 +4957,7 @@ const z = (r) => {
|
|
|
4771
4957
|
if (!t.collapsed)
|
|
4772
4958
|
return;
|
|
4773
4959
|
const n = document.createElement("strong"), o = document.createTextNode("");
|
|
4774
|
-
n.appendChild(o), n.setAttribute(
|
|
4960
|
+
n.appendChild(o), n.setAttribute(w.COLLAPSED_ACTIVE, "true");
|
|
4775
4961
|
const s = t.startContainer, i = t.startOffset;
|
|
4776
4962
|
if (!(s.nodeType === Node.TEXT_NODE ? this.insertCollapsedBoldIntoText(s, n, i) : s.nodeType === Node.ELEMENT_NODE ? (this.insertCollapsedBoldIntoElement(s, n, i), !0) : !1))
|
|
4777
4963
|
return;
|
|
@@ -4793,7 +4979,7 @@ const z = (r) => {
|
|
|
4793
4979
|
const s = t.textContent, i = s.slice(0, n), l = s.slice(n);
|
|
4794
4980
|
t.textContent = i;
|
|
4795
4981
|
const a = l.length ? document.createTextNode(l) : null;
|
|
4796
|
-
return a && o.insertBefore(a, t.nextSibling), o.insertBefore(e, a != null ? a : t.nextSibling), e.setAttribute(
|
|
4982
|
+
return a && o.insertBefore(a, t.nextSibling), o.insertBefore(e, a != null ? a : t.nextSibling), e.setAttribute(w.PREV_LENGTH, i.length.toString()), !0;
|
|
4797
4983
|
}
|
|
4798
4984
|
/**
|
|
4799
4985
|
* Insert a collapsed bold wrapper directly into an element container
|
|
@@ -4801,7 +4987,7 @@ const z = (r) => {
|
|
|
4801
4987
|
insertCollapsedBoldIntoElement(t, e, n) {
|
|
4802
4988
|
var s;
|
|
4803
4989
|
const o = (s = t.childNodes[n]) != null ? s : null;
|
|
4804
|
-
t.insertBefore(e, o), e.setAttribute(
|
|
4990
|
+
t.insertBefore(e, o), e.setAttribute(w.PREV_LENGTH, "0");
|
|
4805
4991
|
}
|
|
4806
4992
|
/**
|
|
4807
4993
|
* Exit a collapsed bold selection by moving caret outside the bold element
|
|
@@ -4811,14 +4997,14 @@ const z = (r) => {
|
|
|
4811
4997
|
exit(t, e) {
|
|
4812
4998
|
const n = _(e), o = n.parentNode;
|
|
4813
4999
|
if (o)
|
|
4814
|
-
return
|
|
5000
|
+
return Ae(n) ? this.removeEmptyBoldElement(t, n, o) : this.exitBoldWithContent(t, n, o);
|
|
4815
5001
|
}
|
|
4816
5002
|
removeEmptyBoldElement(t, e, n) {
|
|
4817
5003
|
const o = document.createRange();
|
|
4818
5004
|
return o.setStartBefore(e), o.collapse(!0), n.removeChild(e), t.removeAllRanges(), t.addRange(o), o;
|
|
4819
5005
|
}
|
|
4820
5006
|
exitBoldWithContent(t, e, n) {
|
|
4821
|
-
e.setAttribute(
|
|
5007
|
+
e.setAttribute(w.COLLAPSED_LENGTH, e.textContent.length.toString()), e.removeAttribute(w.PREV_LENGTH), e.removeAttribute(w.COLLAPSED_ACTIVE), e.removeAttribute(w.LEADING_WHITESPACE);
|
|
4822
5008
|
const o = e.nextSibling, s = !o || o.nodeType !== Node.TEXT_NODE, i = s ? document.createTextNode("") : null;
|
|
4823
5009
|
i && n.insertBefore(i, o);
|
|
4824
5010
|
const l = i != null ? i : o;
|
|
@@ -4839,7 +5025,7 @@ const z = (r) => {
|
|
|
4839
5025
|
maintain() {
|
|
4840
5026
|
if (typeof document != "undefined")
|
|
4841
5027
|
for (const t of Array.from(this.records)) {
|
|
4842
|
-
const e =
|
|
5028
|
+
const e = Ls(t);
|
|
4843
5029
|
if (!e) {
|
|
4844
5030
|
this.records.delete(t);
|
|
4845
5031
|
continue;
|
|
@@ -4876,13 +5062,13 @@ const z = (r) => {
|
|
|
4876
5062
|
*/
|
|
4877
5063
|
synchronize(t) {
|
|
4878
5064
|
var i, l;
|
|
4879
|
-
const e = (i = t == null ? void 0 : t.anchorNode) != null ? i : t == null ? void 0 : t.focusNode, n = e && e.nodeType === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, o = (l = n == null ? void 0 : n.closest(O(
|
|
5065
|
+
const e = (i = t == null ? void 0 : t.anchorNode) != null ? i : t == null ? void 0 : t.focusNode, n = e && e.nodeType === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, o = (l = n == null ? void 0 : n.closest(O(L.editor))) != null ? l : n == null ? void 0 : n.ownerDocument;
|
|
4880
5066
|
if (!o)
|
|
4881
5067
|
return;
|
|
4882
|
-
const s = `strong[${
|
|
5068
|
+
const s = `strong[${w.COLLAPSED_ACTIVE}="true"]`;
|
|
4883
5069
|
o.querySelectorAll(s).forEach((a) => {
|
|
4884
|
-
var
|
|
4885
|
-
const c = a.getAttribute(
|
|
5070
|
+
var At;
|
|
5071
|
+
const c = a.getAttribute(w.PREV_LENGTH), d = a.previousSibling;
|
|
4886
5072
|
if (!c || !d || d.nodeType !== Node.TEXT_NODE)
|
|
4887
5073
|
return;
|
|
4888
5074
|
const h = Number(c);
|
|
@@ -4891,18 +5077,18 @@ const z = (r) => {
|
|
|
4891
5077
|
const u = d, p = u.textContent;
|
|
4892
5078
|
if (p.length <= h)
|
|
4893
5079
|
return;
|
|
4894
|
-
const
|
|
4895
|
-
u.textContent =
|
|
4896
|
-
const y =
|
|
4897
|
-
if (y && !a.hasAttribute(
|
|
5080
|
+
const C = p.slice(0, h), f = p.slice(h);
|
|
5081
|
+
u.textContent = C;
|
|
5082
|
+
const y = f.match(/^[\u00A0\s]+/);
|
|
5083
|
+
if (y && !a.hasAttribute(w.LEADING_WHITESPACE) && a.setAttribute(w.LEADING_WHITESPACE, y[0]), f.length === 0)
|
|
4898
5084
|
return;
|
|
4899
|
-
const
|
|
5085
|
+
const S = a.textContent, k = S + f, A = (At = a.getAttribute(w.LEADING_WHITESPACE)) != null ? At : "", q = A.length > 0 && S.length === 0 && !k.startsWith(A) ? A + k : k, F = document.createTextNode(q);
|
|
4900
5086
|
for (; a.firstChild; )
|
|
4901
5087
|
a.removeChild(a.firstChild);
|
|
4902
|
-
if (a.appendChild(
|
|
5088
|
+
if (a.appendChild(F), !(t != null && t.isCollapsed) || !St(t.focusNode, u))
|
|
4903
5089
|
return;
|
|
4904
|
-
const Q = document.createRange(),
|
|
4905
|
-
Q.setStart(
|
|
5090
|
+
const Q = document.createRange(), Re = F.textContent.length;
|
|
5091
|
+
Q.setStart(F, Re), Q.collapse(!0), t.removeAllRanges(), t.addRange(Q);
|
|
4906
5092
|
});
|
|
4907
5093
|
}
|
|
4908
5094
|
/**
|
|
@@ -4914,29 +5100,29 @@ const z = (r) => {
|
|
|
4914
5100
|
const e = (i = t == null ? void 0 : t.anchorNode) != null ? i : t == null ? void 0 : t.focusNode;
|
|
4915
5101
|
if (!e)
|
|
4916
5102
|
return;
|
|
4917
|
-
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement, o = n == null ? void 0 : n.closest(O(
|
|
5103
|
+
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement, o = n == null ? void 0 : n.closest(O(L.editor));
|
|
4918
5104
|
if (!o)
|
|
4919
5105
|
return;
|
|
4920
|
-
o.querySelectorAll(`strong[${
|
|
5106
|
+
o.querySelectorAll(`strong[${w.COLLAPSED_LENGTH}]`).forEach((l) => {
|
|
4921
5107
|
var A, T;
|
|
4922
|
-
const a = l.getAttribute(
|
|
5108
|
+
const a = l.getAttribute(w.COLLAPSED_LENGTH);
|
|
4923
5109
|
if (!a)
|
|
4924
5110
|
return;
|
|
4925
5111
|
const c = Number(a), d = l.textContent;
|
|
4926
5112
|
if (!Number.isFinite(c))
|
|
4927
5113
|
return;
|
|
4928
|
-
const h = d.length > c, u = h ? this.splitCollapsedBoldText(l, c, d) : null, p = l.getAttribute(
|
|
5114
|
+
const h = d.length > c, u = h ? this.splitCollapsedBoldText(l, c, d) : null, p = l.getAttribute(w.PREV_LENGTH), C = p ? Number(p) : NaN, f = l.previousSibling, y = (f == null ? void 0 : f.nodeType) === Node.TEXT_NODE ? f : null, S = (A = y == null ? void 0 : y.textContent) != null ? A : "", k = !!(p && Number.isFinite(C) && y && S.length > C);
|
|
4929
5115
|
if (k && y) {
|
|
4930
|
-
const
|
|
4931
|
-
y.textContent =
|
|
4932
|
-
const Q = document.createTextNode(
|
|
5116
|
+
const q = S.slice(0, C), F = S.slice(C);
|
|
5117
|
+
y.textContent = q;
|
|
5118
|
+
const Q = document.createTextNode(F);
|
|
4933
5119
|
(T = l.parentNode) == null || T.insertBefore(Q, l.nextSibling);
|
|
4934
5120
|
}
|
|
4935
|
-
if (k && l.removeAttribute(
|
|
4936
|
-
const
|
|
4937
|
-
|
|
5121
|
+
if (k && l.removeAttribute(w.PREV_LENGTH), t != null && t.isCollapsed && u && St(t.focusNode, l)) {
|
|
5122
|
+
const q = document.createRange(), F = u.textContent.length;
|
|
5123
|
+
q.setStart(u, F), q.collapse(!0), t.removeAllRanges(), t.addRange(q);
|
|
4938
5124
|
}
|
|
4939
|
-
h && l.removeAttribute(
|
|
5125
|
+
h && l.removeAttribute(w.COLLAPSED_LENGTH);
|
|
4940
5126
|
});
|
|
4941
5127
|
}
|
|
4942
5128
|
/**
|
|
@@ -4994,8 +5180,8 @@ const z = (r) => {
|
|
|
4994
5180
|
const e = t.getRangeAt(0);
|
|
4995
5181
|
if (!e.collapsed)
|
|
4996
5182
|
return;
|
|
4997
|
-
const n =
|
|
4998
|
-
(n == null ? void 0 : n.getAttribute(
|
|
5183
|
+
const n = N(e.startContainer);
|
|
5184
|
+
(n == null ? void 0 : n.getAttribute(w.COLLAPSED_ACTIVE)) !== "true" && (this.moveCaretFromElementContainer(t, e) || this.moveCaretFromTextContainer(t, e));
|
|
4999
5185
|
}
|
|
5000
5186
|
/**
|
|
5001
5187
|
* Adjust caret when selection container is an element adjacent to bold content
|
|
@@ -5053,7 +5239,7 @@ const z = (r) => {
|
|
|
5053
5239
|
this.setCaret(t, n, s.length);
|
|
5054
5240
|
return;
|
|
5055
5241
|
}
|
|
5056
|
-
const l =
|
|
5242
|
+
const l = N(n);
|
|
5057
5243
|
if (!l || e.startOffset !== n.textContent.length)
|
|
5058
5244
|
return;
|
|
5059
5245
|
const a = this.ensureFollowingTextNode(l, l.nextSibling);
|
|
@@ -5101,7 +5287,7 @@ const z = (r) => {
|
|
|
5101
5287
|
};
|
|
5102
5288
|
P.instance = null;
|
|
5103
5289
|
let B = P;
|
|
5104
|
-
const
|
|
5290
|
+
const Is = {
|
|
5105
5291
|
convertLegacyTags: !0,
|
|
5106
5292
|
normalizeWhitespace: !0,
|
|
5107
5293
|
removeEmpty: !0,
|
|
@@ -5114,7 +5300,7 @@ class D {
|
|
|
5114
5300
|
* @param options - Configuration for the normalization pass
|
|
5115
5301
|
*/
|
|
5116
5302
|
constructor(t) {
|
|
5117
|
-
this.options = E(E({},
|
|
5303
|
+
this.options = E(E({}, Is), t);
|
|
5118
5304
|
}
|
|
5119
5305
|
/**
|
|
5120
5306
|
* Run normalization on a scoped element
|
|
@@ -5210,7 +5396,7 @@ class D {
|
|
|
5210
5396
|
* @returns true if the element is empty and doesn't contain the preserved node
|
|
5211
5397
|
*/
|
|
5212
5398
|
isEmptyAndSafe(t) {
|
|
5213
|
-
return !(t.textContent.length === 0) || B.getInstance().isActivePlaceholder(t) ? !1 : !(this.options.preserveNode &&
|
|
5399
|
+
return !(t.textContent.length === 0) || B.getInstance().isActivePlaceholder(t) ? !1 : !(this.options.preserveNode && St(this.options.preserveNode, t));
|
|
5214
5400
|
}
|
|
5215
5401
|
/**
|
|
5216
5402
|
* Merge a <strong> element with adjacent <strong> siblings
|
|
@@ -5249,11 +5435,11 @@ class D {
|
|
|
5249
5435
|
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
5250
5436
|
if (!n)
|
|
5251
5437
|
return null;
|
|
5252
|
-
const o = (l = n.closest('[data-blok-component="paragraph"]')) != null ? l : n.closest(O(
|
|
5253
|
-
return o || n.closest(O(
|
|
5438
|
+
const o = (l = n.closest('[data-blok-component="paragraph"]')) != null ? l : n.closest(O(L.elementContent));
|
|
5439
|
+
return o || n.closest(O(L.editor));
|
|
5254
5440
|
}
|
|
5255
5441
|
}
|
|
5256
|
-
const
|
|
5442
|
+
const I = class I {
|
|
5257
5443
|
constructor() {
|
|
5258
5444
|
this.handlers = /* @__PURE__ */ new Map(), this.listenersRegistered = !1, this.handleSelectionChange = () => {
|
|
5259
5445
|
const t = this.getSelection();
|
|
@@ -5286,13 +5472,13 @@ const L = class L {
|
|
|
5286
5472
|
* Get the singleton instance
|
|
5287
5473
|
*/
|
|
5288
5474
|
static getInstance() {
|
|
5289
|
-
return
|
|
5475
|
+
return I.instance || (I.instance = new I()), I.instance;
|
|
5290
5476
|
}
|
|
5291
5477
|
/**
|
|
5292
5478
|
* Reset the singleton instance (for testing)
|
|
5293
5479
|
*/
|
|
5294
5480
|
static reset() {
|
|
5295
|
-
|
|
5481
|
+
I.instance && (I.instance.removeListeners(), I.instance.handlers.clear()), I.instance = null;
|
|
5296
5482
|
}
|
|
5297
5483
|
/**
|
|
5298
5484
|
* Register a handler for an inline tool
|
|
@@ -5344,9 +5530,9 @@ const L = class L {
|
|
|
5344
5530
|
return !(e.meta && !s || e.ctrl && !t.ctrlKey);
|
|
5345
5531
|
}
|
|
5346
5532
|
};
|
|
5347
|
-
|
|
5348
|
-
let wt =
|
|
5349
|
-
const
|
|
5533
|
+
I.instance = null;
|
|
5534
|
+
let wt = I;
|
|
5535
|
+
const Ds = (r, t) => {
|
|
5350
5536
|
try {
|
|
5351
5537
|
return r.intersectsNode(t);
|
|
5352
5538
|
} catch (e) {
|
|
@@ -5355,23 +5541,23 @@ const ks = (r, t) => {
|
|
|
5355
5541
|
const o = r.compareBoundaryPoints(Range.END_TO_START, n) > 0, s = r.compareBoundaryPoints(Range.START_TO_END, n) < 0;
|
|
5356
5542
|
return o && s;
|
|
5357
5543
|
}
|
|
5358
|
-
},
|
|
5544
|
+
}, Ee = (r) => document.createTreeWalker(
|
|
5359
5545
|
r.commonAncestorContainer,
|
|
5360
5546
|
NodeFilter.SHOW_TEXT,
|
|
5361
5547
|
{
|
|
5362
|
-
acceptNode: (t) =>
|
|
5548
|
+
acceptNode: (t) => Ds(r, t) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
|
|
5363
5549
|
}
|
|
5364
|
-
), J = (r, t) => r ? r.nodeType === Node.ELEMENT_NODE && t(r) ? r : J(r.parentNode, t) : null,
|
|
5550
|
+
), J = (r, t) => r ? r.nodeType === Node.ELEMENT_NODE && t(r) ? r : J(r.parentNode, t) : null, xe = (r, t) => J(r, t) !== null, Te = (r, t, e = {}) => {
|
|
5365
5551
|
if (r.collapsed)
|
|
5366
5552
|
return J(r.startContainer, t) !== null;
|
|
5367
|
-
const n =
|
|
5553
|
+
const n = Ee(r), o = [];
|
|
5368
5554
|
for (; n.nextNode(); ) {
|
|
5369
5555
|
const s = n.currentNode, i = s.textContent;
|
|
5370
5556
|
e.ignoreWhitespace && i.trim().length === 0 || i.length !== 0 && o.push(s);
|
|
5371
5557
|
}
|
|
5372
|
-
return o.length === 0 ? J(r.startContainer, t) !== null : o.every((s) =>
|
|
5373
|
-
},
|
|
5374
|
-
const e = /* @__PURE__ */ new Set(), n =
|
|
5558
|
+
return o.length === 0 ? J(r.startContainer, t) !== null : o.every((s) => xe(s, t));
|
|
5559
|
+
}, Be = (r, t) => {
|
|
5560
|
+
const e = /* @__PURE__ */ new Set(), n = Ee(r);
|
|
5375
5561
|
for (; n.nextNode(); ) {
|
|
5376
5562
|
const o = J(n.currentNode, t);
|
|
5377
5563
|
o && e.add(o);
|
|
@@ -5436,7 +5622,7 @@ const ks = (r, t) => {
|
|
|
5436
5622
|
*/
|
|
5437
5623
|
render() {
|
|
5438
5624
|
return {
|
|
5439
|
-
icon:
|
|
5625
|
+
icon: rn,
|
|
5440
5626
|
name: "bold",
|
|
5441
5627
|
onActivate: () => {
|
|
5442
5628
|
this.toggleBold();
|
|
@@ -5498,7 +5684,7 @@ const ks = (r, t) => {
|
|
|
5498
5684
|
o.setAttribute("data-blok-bold-marker", `unwrap-${b.markerSequence++}`), o.appendChild(s), this.removeNestedBold(o), t.insertNode(o);
|
|
5499
5685
|
const i = document.createRange();
|
|
5500
5686
|
for (i.selectNodeContents(o), n.removeAllRanges(), n.addRange(i); ; ) {
|
|
5501
|
-
const d =
|
|
5687
|
+
const d = N(o);
|
|
5502
5688
|
if (!d)
|
|
5503
5689
|
break;
|
|
5504
5690
|
this.moveMarkerOutOfBold(o, d);
|
|
@@ -5508,7 +5694,7 @@ const ks = (r, t) => {
|
|
|
5508
5694
|
const d = document.createRange();
|
|
5509
5695
|
return d.setStartBefore(l), d.setEndAfter(a), n.removeAllRanges(), n.addRange(d), d;
|
|
5510
5696
|
})() : void 0) || n.removeAllRanges(), D.normalizeAroundSelection(n), e.forEach((d) => {
|
|
5511
|
-
|
|
5697
|
+
Ae(d) && d.remove();
|
|
5512
5698
|
}), this.notifySelectionChange();
|
|
5513
5699
|
}
|
|
5514
5700
|
/**
|
|
@@ -5573,7 +5759,7 @@ const ks = (r, t) => {
|
|
|
5573
5759
|
* @param options.ignoreWhitespace - Whether to ignore whitespace-only text nodes
|
|
5574
5760
|
*/
|
|
5575
5761
|
isRangeBold(t, e) {
|
|
5576
|
-
return
|
|
5762
|
+
return Te(t, V, e);
|
|
5577
5763
|
}
|
|
5578
5764
|
/**
|
|
5579
5765
|
* Remove nested bold tags from a root node
|
|
@@ -5605,20 +5791,20 @@ const ks = (r, t) => {
|
|
|
5605
5791
|
*/
|
|
5606
5792
|
findBoldElementFromRangeOrSelection(t, e) {
|
|
5607
5793
|
if (!t)
|
|
5608
|
-
return e ?
|
|
5609
|
-
const n =
|
|
5794
|
+
return e ? N(e.focusNode) : null;
|
|
5795
|
+
const n = N(t.startContainer);
|
|
5610
5796
|
if (n)
|
|
5611
5797
|
return n;
|
|
5612
|
-
const o =
|
|
5613
|
-
return o || (t.startContainer.nodeType === Node.ELEMENT_NODE &&
|
|
5798
|
+
const o = N(t.commonAncestorContainer);
|
|
5799
|
+
return o || (t.startContainer.nodeType === Node.ELEMENT_NODE && V(t.startContainer) ? t.startContainer : null);
|
|
5614
5800
|
}
|
|
5615
5801
|
/**
|
|
5616
5802
|
* Merge adjacent bold elements into a single element
|
|
5617
5803
|
* @param element - The bold element to merge with adjacent elements
|
|
5618
5804
|
*/
|
|
5619
5805
|
mergeAdjacentBold(t) {
|
|
5620
|
-
const e = _(t), n = e.previousSibling, o = n && n.nodeType === Node.ELEMENT_NODE &&
|
|
5621
|
-
return s && s.nodeType === Node.ELEMENT_NODE &&
|
|
5806
|
+
const e = _(t), n = e.previousSibling, o = n && n.nodeType === Node.ELEMENT_NODE && V(n) ? b.mergeStrongNodes(n, e) : e, s = o.nextSibling;
|
|
5807
|
+
return s && s.nodeType === Node.ELEMENT_NODE && V(s) ? b.mergeStrongNodes(o, s) : o;
|
|
5622
5808
|
}
|
|
5623
5809
|
/**
|
|
5624
5810
|
* Toggle bold formatting for a collapsed selection (caret position)
|
|
@@ -5628,7 +5814,7 @@ const ks = (r, t) => {
|
|
|
5628
5814
|
const t = window.getSelection();
|
|
5629
5815
|
if (!t || t.rangeCount === 0)
|
|
5630
5816
|
return;
|
|
5631
|
-
const e = t.getRangeAt(0), n =
|
|
5817
|
+
const e = t.getRangeAt(0), n = N(e.startContainer), o = (() => {
|
|
5632
5818
|
if (n && n.getAttribute(B.ATTR.COLLAPSED_ACTIVE) !== "true")
|
|
5633
5819
|
return B.getInstance().exit(t, n);
|
|
5634
5820
|
const s = n != null ? n : b.getBoundaryBold(e);
|
|
@@ -5657,7 +5843,7 @@ const ks = (r, t) => {
|
|
|
5657
5843
|
const t = window.getSelection();
|
|
5658
5844
|
if (!t)
|
|
5659
5845
|
return;
|
|
5660
|
-
const e = t.anchorNode, n = (e == null ? void 0 : e.nodeType) === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, o = n == null ? void 0 : n.closest(O(
|
|
5846
|
+
const e = t.anchorNode, n = (e == null ? void 0 : e.nodeType) === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, o = n == null ? void 0 : n.closest(O(L.editor));
|
|
5661
5847
|
if (!o)
|
|
5662
5848
|
return;
|
|
5663
5849
|
const s = o.querySelector("[data-blok-testid=inline-toolbar]");
|
|
@@ -5712,7 +5898,7 @@ const ks = (r, t) => {
|
|
|
5712
5898
|
*/
|
|
5713
5899
|
static findBlokScopeFromNode(t) {
|
|
5714
5900
|
const e = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
|
|
5715
|
-
return !e || typeof e.closest != "function" ? null : e.closest(`${O(
|
|
5901
|
+
return !e || typeof e.closest != "function" ? null : e.closest(`${O(L.interface)}, ${O(L.editor)}`);
|
|
5716
5902
|
}
|
|
5717
5903
|
/**
|
|
5718
5904
|
* Get a bold element at the boundary of a collapsed range
|
|
@@ -5730,7 +5916,7 @@ const ks = (r, t) => {
|
|
|
5730
5916
|
static getBoundaryBoldForText(t, e) {
|
|
5731
5917
|
const n = e.textContent.length;
|
|
5732
5918
|
if (t.startOffset === n)
|
|
5733
|
-
return
|
|
5919
|
+
return N(e);
|
|
5734
5920
|
if (t.startOffset !== 0)
|
|
5735
5921
|
return null;
|
|
5736
5922
|
const o = e.previousSibling;
|
|
@@ -5756,7 +5942,7 @@ const ks = (r, t) => {
|
|
|
5756
5942
|
if (!e)
|
|
5757
5943
|
return !1;
|
|
5758
5944
|
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
5759
|
-
return !!(n != null && n.closest(O(
|
|
5945
|
+
return !!(n != null && n.closest(O(L.editor)));
|
|
5760
5946
|
}
|
|
5761
5947
|
/**
|
|
5762
5948
|
* Get HTML content of a range with bold tags removed
|
|
@@ -5781,11 +5967,11 @@ const ks = (r, t) => {
|
|
|
5781
5967
|
* @param range - The range to search for bold ancestors
|
|
5782
5968
|
*/
|
|
5783
5969
|
collectBoldAncestors(t) {
|
|
5784
|
-
return
|
|
5970
|
+
return Be(t, V);
|
|
5785
5971
|
}
|
|
5786
5972
|
};
|
|
5787
5973
|
b.isInline = !0, b.title = "Bold", b.titleKey = "bold", b.markerSequence = 0, b.isProcessingMutation = !1, b.instances = /* @__PURE__ */ new Set(), b.guardKeydownListenerRegistered = !1, b.shortcut = "CMD+B";
|
|
5788
|
-
let
|
|
5974
|
+
let ee = b;
|
|
5789
5975
|
const ct = (r) => {
|
|
5790
5976
|
const t = r.tagName;
|
|
5791
5977
|
return t === "I" || t === "EM";
|
|
@@ -5806,7 +5992,7 @@ const ct = (r) => {
|
|
|
5806
5992
|
*/
|
|
5807
5993
|
render() {
|
|
5808
5994
|
return {
|
|
5809
|
-
icon:
|
|
5995
|
+
icon: ln,
|
|
5810
5996
|
name: "italic",
|
|
5811
5997
|
onActivate: () => {
|
|
5812
5998
|
this.toggleItalic();
|
|
@@ -5865,7 +6051,7 @@ const ct = (r) => {
|
|
|
5865
6051
|
* @param options - Options for checking italic status
|
|
5866
6052
|
*/
|
|
5867
6053
|
isRangeItalic(t, e) {
|
|
5868
|
-
return
|
|
6054
|
+
return Te(t, ct, e);
|
|
5869
6055
|
}
|
|
5870
6056
|
/**
|
|
5871
6057
|
* Wrap selection with <i> tag
|
|
@@ -5905,7 +6091,7 @@ const ct = (r) => {
|
|
|
5905
6091
|
* @param node - The node to check
|
|
5906
6092
|
*/
|
|
5907
6093
|
hasItalicParent(t) {
|
|
5908
|
-
return
|
|
6094
|
+
return xe(t, ct);
|
|
5909
6095
|
}
|
|
5910
6096
|
/**
|
|
5911
6097
|
* Find an italic element in the parent chain
|
|
@@ -5919,7 +6105,7 @@ const ct = (r) => {
|
|
|
5919
6105
|
* @param range - The range to search for italic ancestors
|
|
5920
6106
|
*/
|
|
5921
6107
|
collectItalicAncestors(t) {
|
|
5922
|
-
return
|
|
6108
|
+
return Be(t, ct);
|
|
5923
6109
|
}
|
|
5924
6110
|
/**
|
|
5925
6111
|
* Get HTML content of a range with italic tags removed
|
|
@@ -6007,7 +6193,7 @@ const ct = (r) => {
|
|
|
6007
6193
|
}
|
|
6008
6194
|
};
|
|
6009
6195
|
j.isInline = !0, j.title = "Italic", j.titleKey = "italic", j.shortcut = "CMD+I";
|
|
6010
|
-
let
|
|
6196
|
+
let ne = j;
|
|
6011
6197
|
const X = class X {
|
|
6012
6198
|
/**
|
|
6013
6199
|
* @param api - Blok API
|
|
@@ -6043,7 +6229,7 @@ const X = class X {
|
|
|
6043
6229
|
*/
|
|
6044
6230
|
render() {
|
|
6045
6231
|
return {
|
|
6046
|
-
icon:
|
|
6232
|
+
icon: an,
|
|
6047
6233
|
name: "link",
|
|
6048
6234
|
isActive: () => !!this.selection.findParentTag("A"),
|
|
6049
6235
|
children: {
|
|
@@ -6086,7 +6272,7 @@ const X = class X {
|
|
|
6086
6272
|
this.nodes.input.value = o !== null ? o : "";
|
|
6087
6273
|
} else
|
|
6088
6274
|
this.nodes.input.value = "";
|
|
6089
|
-
this.nodes.input.className =
|
|
6275
|
+
this.nodes.input.className = v(this.INPUT_BASE_CLASSES, "block"), this.setBooleanStateAttribute(this.nodes.input, this.DATA_ATTRIBUTES.inputOpened, !0), this.selection.setFakeBackground(), this.selection.save(), t && this.focusInputWithRetry(), this.inputOpened = !0;
|
|
6090
6276
|
}
|
|
6091
6277
|
/**
|
|
6092
6278
|
* Ensures the link input receives focus even if other listeners steal it
|
|
@@ -6102,7 +6288,7 @@ const X = class X {
|
|
|
6102
6288
|
*/
|
|
6103
6289
|
getButtonElement() {
|
|
6104
6290
|
const t = document.querySelector(
|
|
6105
|
-
`${O(
|
|
6291
|
+
`${O(L.interface, dn)} [data-blok-item-name="link"]`
|
|
6106
6292
|
);
|
|
6107
6293
|
return t && t !== this.nodes.button && (t.addEventListener("click", this.handleButtonClick, !0), this.nodes.button = t), t;
|
|
6108
6294
|
}
|
|
@@ -6159,7 +6345,7 @@ const X = class X {
|
|
|
6159
6345
|
this.notifier.show({
|
|
6160
6346
|
message: this.i18n.t("tools.link.invalidLink"),
|
|
6161
6347
|
style: "error"
|
|
6162
|
-
}),
|
|
6348
|
+
}), cn("Incorrect Link pasted", "warn", e);
|
|
6163
6349
|
return;
|
|
6164
6350
|
}
|
|
6165
6351
|
const n = this.prepareLink(e);
|
|
@@ -6237,26 +6423,26 @@ const X = class X {
|
|
|
6237
6423
|
}
|
|
6238
6424
|
};
|
|
6239
6425
|
X.isInline = !0, X.title = "Link", X.titleKey = "link", X.shortcut = "CMD+K";
|
|
6240
|
-
let
|
|
6241
|
-
const
|
|
6426
|
+
let oe = X;
|
|
6427
|
+
const Ms = {
|
|
6242
6428
|
paragraph: { preserveBlank: !0 },
|
|
6243
6429
|
header: {},
|
|
6244
6430
|
list: {},
|
|
6245
6431
|
table: {}
|
|
6246
|
-
},
|
|
6432
|
+
}, _s = {
|
|
6247
6433
|
bold: {},
|
|
6248
6434
|
italic: {},
|
|
6249
6435
|
link: {}
|
|
6250
6436
|
};
|
|
6251
6437
|
export {
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6438
|
+
ee as Bold,
|
|
6439
|
+
$s as Convert,
|
|
6440
|
+
Ht as Header,
|
|
6441
|
+
ne as Italic,
|
|
6442
|
+
oe as Link,
|
|
6443
|
+
Ns as List,
|
|
6444
|
+
Dt as Paragraph,
|
|
6445
|
+
Os as Table,
|
|
6446
|
+
Ms as defaultBlockTools,
|
|
6447
|
+
_s as defaultInlineTools
|
|
6262
6448
|
};
|