@jackuait/blok 0.7.3 → 0.8.1
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-BmlbETK7.mjs → blok-Ddy2vDUq.mjs} +2158 -2147
- package/dist/chunks/{constants-WhLyFkza.mjs → constants-CuG2mgIj.mjs} +84 -84
- package/dist/chunks/{i18next-loader-CZARkla1.mjs → i18next-loader-p-7ioTwr.mjs} +1 -1
- package/dist/chunks/{lightweight-i18n-BQa0F2X6.mjs → lightweight-i18n-BPeH69Dl.mjs} +5 -1
- package/dist/{messages-BbLCMWln2.mjs → chunks/messages--aM83pib2.mjs} +14 -1
- package/dist/chunks/{messages-ni0ahgYk2.mjs → messages-4OvVdaG52.mjs} +14 -1
- package/dist/chunks/{messages-DnPkoMz1.mjs → messages-5ohIWynJ.mjs} +14 -1
- package/dist/{messages-CzSLUJQt.mjs → chunks/messages-5thhSeME.mjs} +14 -1
- package/dist/chunks/{messages-hngFJrES2.mjs → messages-8pf7gRQm2.mjs} +14 -1
- package/dist/chunks/{messages-DcPtg90i.mjs → messages-B-i-d1Bc.mjs} +14 -1
- package/dist/chunks/{messages-CRxkRJRN.mjs → messages-B9zocutJ.mjs} +14 -1
- package/dist/chunks/{messages-BUy3odZo.mjs → messages-BAC7nLeM.mjs} +14 -1
- package/dist/chunks/{messages-DjOY_EqX.mjs → messages-BARPMN7R.mjs} +14 -1
- package/dist/{messages-Bsz7Qgj_.mjs → chunks/messages-BAgTIgPH.mjs} +15 -2
- package/dist/{messages-C7R0m6oE2.mjs → chunks/messages-BDTgiBJY2.mjs} +14 -1
- package/dist/chunks/{messages-BM1Su_Uy2.mjs → messages-BHf_VcXb2.mjs} +14 -1
- package/dist/{messages-wRvz0vQ3.mjs → chunks/messages-BIrkzbBP.mjs} +14 -1
- package/dist/chunks/{messages-DotEkUpQ.mjs → messages-BKjLgO5d.mjs} +14 -1
- package/dist/{messages-gldjQk7M.mjs → chunks/messages-BMzmli1K.mjs} +14 -1
- package/dist/chunks/{messages-CficsmSH2.mjs → messages-BO_jtRbZ2.mjs} +14 -1
- package/dist/{messages-B2bHgIcC2.mjs → chunks/messages-B_fFjpX12.mjs} +14 -1
- package/dist/chunks/{messages-CnzaTbel.mjs → messages-Bdk5tBNu.mjs} +14 -1
- package/dist/{messages-CRMZ79Xf.mjs → chunks/messages-BgaGPFuy2.mjs} +14 -1
- package/dist/{messages-DCOKudVN.mjs → chunks/messages-BsYzg2le.mjs} +14 -1
- package/dist/chunks/{messages-Dxrg70jo.mjs → messages-BtS6JWMT.mjs} +14 -1
- package/dist/{messages-Cgy54529.mjs → chunks/messages-BvlSf_pu.mjs} +14 -1
- package/dist/{messages-oH0ADQ362.mjs → chunks/messages-C03I_oR-2.mjs} +14 -1
- package/dist/chunks/{messages-B_nVGWdk.mjs → messages-CDJLoStb.mjs} +14 -1
- package/dist/chunks/{messages-ClOxDE0y2.mjs → messages-CH_cexo62.mjs} +14 -1
- package/dist/chunks/{messages-DoDbCS02.mjs → messages-CIBuZccC.mjs} +14 -1
- package/dist/{messages-CkmVEyEQ2.mjs → chunks/messages-CIZkNCpW.mjs} +14 -1
- package/dist/{messages-CJYE0_hr2.mjs → chunks/messages-CIugNDDO2.mjs} +14 -1
- package/dist/{messages-DpY9s4Qi2.mjs → chunks/messages-COkQfKa72.mjs} +14 -1
- package/dist/{messages-Bw-GC0m5.mjs → chunks/messages-CSpfBhlK2.mjs} +14 -1
- package/dist/chunks/{messages-tBHnC2Rj2.mjs → messages-CWp6-Y8f2.mjs} +14 -1
- package/dist/{messages-GrVSCmXW.mjs → chunks/messages-Co4WFeQ8.mjs} +14 -1
- package/dist/{messages-voUPclMU.mjs → chunks/messages-CoRQE_Jc.mjs} +14 -1
- package/dist/{messages-DGZQXeav2.mjs → chunks/messages-CuRN1_ep2.mjs} +14 -1
- package/dist/{messages-BwdowdYD.mjs → chunks/messages-D0IKicWg.mjs} +14 -1
- package/dist/chunks/{messages-1C3OS98e.mjs → messages-D14soBOO.mjs} +14 -1
- package/dist/chunks/{messages-nE9Ko73n2.mjs → messages-D1SqLcxI2.mjs} +14 -1
- package/dist/{messages-COU4L-pL2.mjs → chunks/messages-D2uBlGXR2.mjs} +14 -1
- package/dist/{messages-m1uf_AMy2.mjs → chunks/messages-DDpgr0B1.mjs} +14 -1
- package/dist/{messages-CB0RKGVM.mjs → chunks/messages-DEGzGmEQ2.mjs} +14 -1
- package/dist/{messages--XEfVx572.mjs → chunks/messages-DKChC8Qu.mjs} +14 -1
- package/dist/{messages-BP8ZuVaD.mjs → chunks/messages-DKCoHa5D.mjs} +14 -1
- package/dist/chunks/{messages-C3AJz_i6.mjs → messages-DPoPrTiZ.mjs} +14 -1
- package/dist/{messages-CaJRIGUu2.mjs → chunks/messages-DQOk-dTH.mjs} +14 -1
- package/dist/chunks/{messages-uLIUXFmU.mjs → messages-DUp8NnKT.mjs} +15 -2
- package/dist/chunks/{messages-rJdSnvyi.mjs → messages-DVg69mRj.mjs} +14 -1
- package/dist/chunks/{messages-Cq6wj6FG.mjs → messages-DeLzropc.mjs} +14 -1
- package/dist/{messages-BlnZ8CkJ2.mjs → chunks/messages-Df69rfTF2.mjs} +15 -2
- package/dist/{messages-BZgGD0zf2.mjs → chunks/messages-DfsHFEWa.mjs} +14 -1
- package/dist/chunks/{messages-yJmwc3zD.mjs → messages-DgZnRQRS.mjs} +14 -1
- package/dist/chunks/{messages-m6bLP64R2.mjs → messages-DhGHk-Ma2.mjs} +14 -1
- package/dist/{messages-3aRjZXpv.mjs → chunks/messages-Di7mfvB8.mjs} +14 -1
- package/dist/chunks/{messages-C1iQkKu82.mjs → messages-DlM9TmqS2.mjs} +14 -1
- package/dist/chunks/{messages-CejEH4FW2.mjs → messages-DmrsEYQm2.mjs} +14 -1
- package/dist/chunks/{messages-DK6pBwD2.mjs → messages-Dr-Ig3sw.mjs} +14 -1
- package/dist/{messages-BOxe7ewT.mjs → chunks/messages-DrXNb1gu.mjs} +14 -1
- package/dist/chunks/{messages-CvLXClh9.mjs → messages-EDTq4Q52.mjs} +14 -1
- package/dist/{messages-huTzItxA.mjs → chunks/messages-Ehx9YYeb2.mjs} +14 -1
- package/dist/chunks/{messages-CxTq0x772.mjs → messages-FCmAVA792.mjs} +14 -1
- package/dist/{messages-q7HzQPVt.mjs → chunks/messages-LL3Tflph.mjs} +14 -1
- package/dist/chunks/{messages-D9qyilS0.mjs → messages-N72K1hw3.mjs} +14 -1
- package/dist/chunks/{messages-C9XSSqS5.mjs → messages-Nz8C7Znm.mjs} +15 -2
- package/dist/chunks/{messages-D6SAC8Lc2.mjs → messages-OIelQDL32.mjs} +14 -1
- package/dist/{messages-BQJzUYP-.mjs → chunks/messages-SsrFJhTN.mjs} +14 -1
- package/dist/{messages-CVBsztOg.mjs → chunks/messages-ohtcmr1w.mjs} +14 -1
- package/dist/chunks/{messages-CVzvKl6U.mjs → messages-stUQR58d.mjs} +14 -1
- package/dist/{messages-DlrZrm3s.mjs → chunks/messages-wUoSWFsJ2.mjs} +14 -1
- package/dist/chunks/{tools-BCb5bMO3.mjs → tools-F4UyWgGo.mjs} +1086 -802
- package/dist/full.mjs +15 -13
- package/dist/locales.mjs +72 -68
- package/dist/{messages-mVFAkdcY.mjs → messages-1_FCq0It.mjs} +14 -1
- package/dist/{messages-DkkrjINb2.mjs → messages-8zo-T-Nx2.mjs} +14 -1
- package/dist/{chunks/messages-DacahKek.mjs → messages-B21zLG6b.mjs} +14 -1
- package/dist/{messages-BBgyeB_N.mjs → messages-B9ythxux.mjs} +14 -1
- package/dist/{messages-C_RPN2GV.mjs → messages-BAZK-8Zb.mjs} +14 -1
- package/dist/{messages-D6Sr5cUE.mjs → messages-BB8umWL1.mjs} +14 -1
- package/dist/{chunks/messages-Dhe8_mnQ.mjs → messages-BD_U2EnE.mjs} +14 -1
- package/dist/{messages-6G0Eia-2.mjs → messages-BRC9E_sp.mjs} +14 -1
- package/dist/{messages-pgqtPci-.mjs → messages-BSLYh59S.mjs} +14 -1
- package/dist/{messages-K7ROT6ea.mjs → messages-BSwhWcYw.mjs} +14 -1
- package/dist/{messages-BztXgybv2.mjs → messages-BTR3QlIb2.mjs} +14 -1
- package/dist/{messages-C0gyqo4h2.mjs → messages-BZXBdD_S2.mjs} +14 -1
- package/dist/{chunks/messages-DDRCk44J2.mjs → messages-Bm8I_Li12.mjs} +15 -2
- package/dist/{chunks/messages-BKtWlK39.mjs → messages-BrcgNZOJ.mjs} +14 -1
- package/dist/{messages-Be1CCcsp2.mjs → messages-BzZ8LahA2.mjs} +14 -1
- package/dist/{chunks/messages-B_90PYaG.mjs → messages-C4HpNHfK.mjs} +14 -1
- package/dist/{messages-B8M4YRFO2.mjs → messages-C5hD5pSd2.mjs} +14 -1
- package/dist/{messages-ruU_e2LK.mjs → messages-C7Rz00Tp.mjs} +14 -1
- package/dist/{chunks/messages-C1lqY56F2.mjs → messages-C92tAUYT2.mjs} +14 -1
- package/dist/{messages-Kye1BINC.mjs → messages-C9LsEUfG.mjs} +14 -1
- package/dist/{chunks/messages-tg78NAmW.mjs → messages-CHWfj4ik.mjs} +14 -1
- package/dist/{chunks/messages-DziA-L3p.mjs → messages-CHeucLGl2.mjs} +14 -1
- package/dist/{messages-eCyczLYY.mjs → messages-CIxT1nSh.mjs} +14 -1
- package/dist/{chunks/messages-Cb-x47kY2.mjs → messages-CKX9iXIb2.mjs} +14 -1
- package/dist/{chunks/messages-BjkDJuqh.mjs → messages-CKmmJ9tW.mjs} +14 -1
- package/dist/{chunks/messages-Cn5n0nHe2.mjs → messages-CTFwu5-h2.mjs} +14 -1
- package/dist/{messages-DAssrN5L2.mjs → messages-CTPFrtK92.mjs} +14 -1
- package/dist/{chunks/messages-6EJxSImH.mjs → messages-CWzET_9H2.mjs} +14 -1
- package/dist/{chunks/messages-BZ45xBlV.mjs → messages-CkIRmpfZ2.mjs} +14 -1
- package/dist/{chunks/messages-kHTrX3wo2.mjs → messages-CmoTIebG2.mjs} +14 -1
- package/dist/{messages-DZbsds_k2.mjs → messages-Co26RSCV2.mjs} +14 -1
- package/dist/{messages-DrouoDgp.mjs → messages-CqNzlpWi.mjs} +15 -2
- package/dist/{chunks/messages-DDr8J4FE.mjs → messages-CrWsU4Xw2.mjs} +14 -1
- package/dist/{messages-TseLyyoU.mjs → messages-CsmTziC6.mjs} +14 -1
- package/dist/{messages-CAffVeAE2.mjs → messages-CsnglxbV2.mjs} +14 -1
- package/dist/{messages-CE305J0p.mjs → messages-Cu7Lr1wp.mjs} +14 -1
- package/dist/{chunks/messages-Ul43l29K2.mjs → messages-Cy3Ne_M9.mjs} +14 -1
- package/dist/{chunks/messages-CzCqu58X2.mjs → messages-CzZAfGif.mjs} +14 -1
- package/dist/{messages-C_4VGaBC.mjs → messages-D5rnT-BC.mjs} +14 -1
- package/dist/{messages-MaHxNgKA.mjs → messages-D8iCBMg7.mjs} +14 -1
- package/dist/{chunks/messages-BtNOlsMj.mjs → messages-DDJOu049.mjs} +14 -1
- package/dist/{messages-BU9luYgO.mjs → messages-DDiP6yex.mjs} +14 -1
- package/dist/{messages-DB9U3VIh.mjs → messages-DHJ1fZLL.mjs} +14 -1
- package/dist/{chunks/messages-3ePgbbpx2.mjs → messages-DToWAonn2.mjs} +14 -1
- package/dist/{messages-BxQ1gzJF2.mjs → messages-DV29fJMD2.mjs} +14 -1
- package/dist/{chunks/messages-DJWRON2S.mjs → messages-D_-rh8gl.mjs} +14 -1
- package/dist/{messages-e-KHuxtY2.mjs → messages-D_cAZ4Ic2.mjs} +14 -1
- package/dist/{chunks/messages-pKUiAqlX2.mjs → messages-Dc7ZzqYN.mjs} +14 -1
- package/dist/{chunks/messages-JRavIeeW.mjs → messages-DiSeSE8p.mjs} +14 -1
- package/dist/{chunks/messages-DbS9Oibb.mjs → messages-Djhu5RJd.mjs} +14 -1
- package/dist/{messages-BdJ1lCo_.mjs → messages-Dr9L1psl.mjs} +15 -2
- package/dist/{chunks/messages-IJhiftj5.mjs → messages-EIeWKoc5.mjs} +14 -1
- package/dist/{chunks/messages-CteKp81J.mjs → messages-EwoT2jof.mjs} +14 -1
- package/dist/{messages-C8iAUPzI.mjs → messages-F7cRf-20.mjs} +14 -1
- package/dist/{messages-B9qltgXa.mjs → messages-JZhs_0pf.mjs} +14 -1
- package/dist/{chunks/messages-C232njMF2.mjs → messages-JwMkLben.mjs} +14 -1
- package/dist/{messages-Cb5JJ8C_2.mjs → messages-LyzjEEIj2.mjs} +14 -1
- package/dist/{chunks/messages-DQ4VyVJf2.mjs → messages-SepwOOcg.mjs} +14 -1
- package/dist/{chunks/messages-DfTU2I8J.mjs → messages-TI0u6Ked.mjs} +14 -1
- package/dist/{chunks/messages-D7aoKTPD.mjs → messages-Tx25QErT.mjs} +14 -1
- package/dist/{chunks/messages-D9nReG4C2.mjs → messages-bRqMCja-2.mjs} +14 -1
- package/dist/{chunks/messages-h474TGR72.mjs → messages-lEyiemqU2.mjs} +14 -1
- package/dist/{messages-BENRci-_2.mjs → messages-mVLfVtQX2.mjs} +14 -1
- package/dist/{messages-CEhkWwqI.mjs → messages-ouO9js8Z.mjs} +14 -1
- package/dist/{chunks/messages-6z-ULVyk.mjs → messages-ouRGTAKo2.mjs} +14 -1
- package/dist/{chunks/messages-DNrK8lCg2.mjs → messages-qV14y_oA2.mjs} +14 -1
- package/dist/{chunks/messages-Yk__PXZQ.mjs → messages-rM6YFLZH.mjs} +15 -2
- package/dist/react.mjs +2 -2
- package/dist/tools.mjs +3 -3
- package/package.json +1 -1
- package/src/components/i18n/locales/am/messages.json +14 -1
- package/src/components/i18n/locales/ar/messages.json +14 -1
- package/src/components/i18n/locales/az/messages.json +14 -1
- package/src/components/i18n/locales/bg/messages.json +15 -2
- package/src/components/i18n/locales/bn/messages.json +14 -1
- package/src/components/i18n/locales/bs/messages.json +14 -1
- package/src/components/i18n/locales/cs/messages.json +14 -1
- package/src/components/i18n/locales/da/messages.json +14 -1
- package/src/components/i18n/locales/de/messages.json +14 -1
- package/src/components/i18n/locales/dv/messages.json +14 -1
- package/src/components/i18n/locales/el/messages.json +14 -1
- package/src/components/i18n/locales/en/messages.json +5 -1
- package/src/components/i18n/locales/es/messages.json +14 -1
- package/src/components/i18n/locales/et/messages.json +15 -2
- package/src/components/i18n/locales/fa/messages.json +14 -1
- package/src/components/i18n/locales/fi/messages.json +14 -1
- package/src/components/i18n/locales/fil/messages.json +14 -1
- package/src/components/i18n/locales/fr/messages.json +14 -1
- package/src/components/i18n/locales/gu/messages.json +14 -1
- package/src/components/i18n/locales/he/messages.json +14 -1
- package/src/components/i18n/locales/hi/messages.json +14 -1
- package/src/components/i18n/locales/hr/messages.json +14 -1
- package/src/components/i18n/locales/hu/messages.json +14 -1
- package/src/components/i18n/locales/hy/messages.json +14 -1
- package/src/components/i18n/locales/id/messages.json +14 -1
- package/src/components/i18n/locales/it/messages.json +14 -1
- package/src/components/i18n/locales/ja/messages.json +14 -1
- package/src/components/i18n/locales/ka/messages.json +14 -1
- package/src/components/i18n/locales/km/messages.json +14 -1
- package/src/components/i18n/locales/kn/messages.json +14 -1
- package/src/components/i18n/locales/ko/messages.json +14 -1
- package/src/components/i18n/locales/ku/messages.json +14 -1
- package/src/components/i18n/locales/lo/messages.json +14 -1
- package/src/components/i18n/locales/lt/messages.json +14 -1
- package/src/components/i18n/locales/lv/messages.json +14 -1
- package/src/components/i18n/locales/mk/messages.json +14 -1
- package/src/components/i18n/locales/ml/messages.json +14 -1
- package/src/components/i18n/locales/mn/messages.json +14 -1
- package/src/components/i18n/locales/mr/messages.json +14 -1
- package/src/components/i18n/locales/ms/messages.json +14 -1
- package/src/components/i18n/locales/my/messages.json +14 -1
- package/src/components/i18n/locales/ne/messages.json +14 -1
- package/src/components/i18n/locales/nl/messages.json +14 -1
- package/src/components/i18n/locales/no/messages.json +14 -1
- package/src/components/i18n/locales/pa/messages.json +14 -1
- package/src/components/i18n/locales/pl/messages.json +14 -1
- package/src/components/i18n/locales/ps/messages.json +14 -1
- package/src/components/i18n/locales/pt/messages.json +14 -1
- package/src/components/i18n/locales/ro/messages.json +14 -1
- package/src/components/i18n/locales/ru/messages.json +15 -2
- package/src/components/i18n/locales/sd/messages.json +14 -1
- package/src/components/i18n/locales/si/messages.json +14 -1
- package/src/components/i18n/locales/sk/messages.json +14 -1
- package/src/components/i18n/locales/sl/messages.json +14 -1
- package/src/components/i18n/locales/sq/messages.json +14 -1
- package/src/components/i18n/locales/sr/messages.json +14 -1
- package/src/components/i18n/locales/sv/messages.json +14 -1
- package/src/components/i18n/locales/sw/messages.json +14 -1
- package/src/components/i18n/locales/ta/messages.json +14 -1
- package/src/components/i18n/locales/te/messages.json +14 -1
- package/src/components/i18n/locales/th/messages.json +14 -1
- package/src/components/i18n/locales/tr/messages.json +14 -1
- package/src/components/i18n/locales/ug/messages.json +14 -1
- package/src/components/i18n/locales/uk/messages.json +15 -2
- package/src/components/i18n/locales/ur/messages.json +14 -1
- package/src/components/i18n/locales/vi/messages.json +14 -1
- package/src/components/i18n/locales/yi/messages.json +14 -1
- package/src/components/i18n/locales/zh/messages.json +14 -1
- package/src/components/icons/index.ts +18 -0
- package/src/components/inline-tools/inline-tool-strikethrough.ts +408 -0
- package/src/components/inline-tools/inline-tool-underline.ts +408 -0
- package/src/components/modules/paste/handlers/base.ts +14 -4
- package/src/components/modules/rectangleSelection.ts +48 -0
- package/src/components/modules/toolbar/index.ts +5 -2
- package/src/components/modules/toolbar/inline/shortcuts-manager.ts +4 -3
- package/src/components/shared/color-picker.ts +10 -2
- package/src/full.ts +7 -1
- package/src/stories/MarkerColors.stories.ts +13 -34
- package/src/styles/main.css +1 -1
- package/src/tools/header/index.ts +6 -4
- package/src/tools/index.ts +4 -0
- package/src/tools/list/constants.ts +3 -3
- package/src/tools/list/dom-builder.ts +1 -0
- package/src/tools/table/table-cell-blocks.ts +25 -0
- package/src/tools/toggle/constants.ts +12 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $ as e, A as t,
|
|
2
|
-
import { t as
|
|
3
|
-
import { n as
|
|
1
|
+
import { $ as e, A as t, At as n, B as r, Bt as i, Ct as a, D as o, En as s, Et as c, F as l, G as u, H as d, I as f, It as p, J as m, K as h, L as g, Lt as _, M as ee, Mn as v, N as te, Nn as y, Nt as ne, P as re, R as ie, St as ae, U as oe, V as se, Vt as ce, W as le, X as ue, Y as de, Z as fe, _t as pe, a as me, at as he, bt as ge, c as _e, ct as ve, d as ye, dt as be, f as xe, ft as Se, g as Ce, gt as we, h as Te, ht as Ee, i as De, it as Oe, j as ke, jt as Ae, k as je, l as Me, lt as Ne, mt as Pe, n as Fe, nn as Ie, nt as Le, o as Re, ot as ze, p as Be, pt as Ve, q as He, r as Ue, rt as We, s as Ge, st as Ke, t as qe, tt as Je, u as b, v as Ye, vt as Xe, xt as Ze, yt as Qe, z as $e } from "./constants-CuG2mgIj.mjs";
|
|
2
|
+
import { t as x } from "./objectSpread2-CyPxu8-u.mjs";
|
|
3
|
+
import { n as S } from "./tw-DmW6-pCY.mjs";
|
|
4
4
|
//#region src/components/utils/html.ts
|
|
5
|
-
var
|
|
5
|
+
var et = (e) => {
|
|
6
6
|
if (!e || !e.includes("data-blok-fake-background")) return e;
|
|
7
7
|
let t = document.createElement("div");
|
|
8
8
|
return t.innerHTML = e, t.querySelectorAll("[data-blok-fake-background=\"true\"]").forEach((e) => {
|
|
@@ -12,7 +12,7 @@ var $e = (e) => {
|
|
|
12
12
|
t.removeChild(e);
|
|
13
13
|
}
|
|
14
14
|
}), t.innerHTML;
|
|
15
|
-
},
|
|
15
|
+
}, C = [
|
|
16
16
|
"empty:before:pointer-events-none",
|
|
17
17
|
"empty:before:text-gray-text",
|
|
18
18
|
"empty:before:cursor-text",
|
|
@@ -21,7 +21,7 @@ var $e = (e) => {
|
|
|
21
21
|
"data-[blok-empty=true]:before:text-gray-text",
|
|
22
22
|
"data-[blok-empty=true]:before:cursor-text",
|
|
23
23
|
"data-[blok-empty=true]:before:content-[attr(data-placeholder)]"
|
|
24
|
-
],
|
|
24
|
+
], tt = [
|
|
25
25
|
"empty:before:pointer-events-none",
|
|
26
26
|
"empty:before:text-gray-text",
|
|
27
27
|
"empty:before:cursor-text",
|
|
@@ -30,7 +30,7 @@ var $e = (e) => {
|
|
|
30
30
|
"data-[empty=true]:before:text-gray-text",
|
|
31
31
|
"data-[empty=true]:before:cursor-text",
|
|
32
32
|
"data-[empty=true]:before:content-[attr(data-blok-placeholder-active)]"
|
|
33
|
-
],
|
|
33
|
+
], nt = [
|
|
34
34
|
"empty:focus:before:pointer-events-none",
|
|
35
35
|
"empty:focus:before:text-gray-text",
|
|
36
36
|
"empty:focus:before:cursor-text",
|
|
@@ -39,7 +39,7 @@ var $e = (e) => {
|
|
|
39
39
|
"[&[data-empty=true]:focus]:before:text-gray-text",
|
|
40
40
|
"[&[data-empty=true]:focus]:before:cursor-text",
|
|
41
41
|
"[&[data-empty=true]:focus]:before:content-[attr(data-blok-placeholder-active)]"
|
|
42
|
-
],
|
|
42
|
+
], rt = [
|
|
43
43
|
"empty:in-data-[blok-empty=true]:before:pointer-events-none",
|
|
44
44
|
"empty:in-data-[blok-empty=true]:before:text-gray-text",
|
|
45
45
|
"empty:in-data-[blok-empty=true]:before:cursor-text",
|
|
@@ -48,25 +48,25 @@ var $e = (e) => {
|
|
|
48
48
|
"[[data-blok-empty=true]_&[data-empty=true]]:before:text-gray-text",
|
|
49
49
|
"[[data-blok-empty=true]_&[data-empty=true]]:before:cursor-text",
|
|
50
50
|
"[[data-blok-empty=true]_&[data-empty=true]]:before:content-[attr(data-blok-placeholder-active)]"
|
|
51
|
-
],
|
|
51
|
+
], it = (e) => {
|
|
52
52
|
let t = e.innerHTML.trim();
|
|
53
53
|
return t === "" || t === "<br>";
|
|
54
|
-
},
|
|
54
|
+
}, at = (e) => {
|
|
55
55
|
e.innerHTML === "<br>" && (e.innerHTML = "");
|
|
56
56
|
let t = window.getSelection();
|
|
57
57
|
if (!t) return;
|
|
58
58
|
let n = document.createRange();
|
|
59
59
|
n.selectNodeContents(e), n.collapse(!0), t.removeAllRanges(), t.addRange(n);
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
e.setAttribute(n, t == null ? "" : t), e.addEventListener("focus", () =>
|
|
64
|
-
},
|
|
60
|
+
}, ot = (e) => {
|
|
61
|
+
it(e) && at(e);
|
|
62
|
+
}, st = (e, t, n = "data-placeholder") => {
|
|
63
|
+
e.setAttribute(n, t == null ? "" : t), e.addEventListener("focus", () => ot(e));
|
|
64
|
+
}, ct, lt = (e) => {
|
|
65
65
|
let t = document.createElement("div");
|
|
66
66
|
t.innerHTML = e.trim();
|
|
67
67
|
let n = document.createDocumentFragment();
|
|
68
68
|
return n.append(...Array.from(t.childNodes)), n;
|
|
69
|
-
},
|
|
69
|
+
}, ut = class e {
|
|
70
70
|
static get DEFAULT_PLACEHOLDER() {
|
|
71
71
|
return "tools.paragraph.placeholder";
|
|
72
72
|
}
|
|
@@ -85,9 +85,9 @@ var $e = (e) => {
|
|
|
85
85
|
}
|
|
86
86
|
drawView() {
|
|
87
87
|
let t = document.createElement("DIV");
|
|
88
|
-
t.className =
|
|
89
|
-
let
|
|
90
|
-
return Object.keys(
|
|
88
|
+
t.className = S(this.api.styles.block, e.WRAPPER_CLASSES, nt, rt), t.setAttribute(v.tool, "paragraph"), t.contentEditable = "false";
|
|
89
|
+
let n = this.buildInlineStyles();
|
|
90
|
+
return Object.keys(n).length > 0 && Object.assign(t.style, n), this._data.text ? t.innerHTML = this._data.text : this.readOnly && (t.innerHTML = "<br>"), this.readOnly || (t.contentEditable = "true", t.addEventListener("keyup", this.onKeyUp), st(t, this.api.i18n.t(this._placeholder), "data-blok-placeholder-active")), t;
|
|
91
91
|
}
|
|
92
92
|
render() {
|
|
93
93
|
return this._element = this.drawView(), this._element;
|
|
@@ -95,14 +95,14 @@ var $e = (e) => {
|
|
|
95
95
|
merge(e) {
|
|
96
96
|
if (!this._element) return;
|
|
97
97
|
this._data.text += e.text;
|
|
98
|
-
let t =
|
|
98
|
+
let t = lt(e.text);
|
|
99
99
|
this._element.appendChild(t), this._element.normalize();
|
|
100
100
|
}
|
|
101
101
|
validate(e) {
|
|
102
102
|
return !(e.text.trim() === "" && !this._preserveBlank);
|
|
103
103
|
}
|
|
104
104
|
save(e) {
|
|
105
|
-
return { text:
|
|
105
|
+
return { text: et(e.innerHTML) };
|
|
106
106
|
}
|
|
107
107
|
onPaste(e) {
|
|
108
108
|
let t = e.detail;
|
|
@@ -134,7 +134,7 @@ var $e = (e) => {
|
|
|
134
134
|
}
|
|
135
135
|
static get toolbox() {
|
|
136
136
|
return {
|
|
137
|
-
icon:
|
|
137
|
+
icon: We,
|
|
138
138
|
title: "Text",
|
|
139
139
|
titleKey: "text",
|
|
140
140
|
searchTerms: [
|
|
@@ -145,7 +145,7 @@ var $e = (e) => {
|
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
|
|
148
|
+
ct = ut, ct.WRAPPER_CLASSES = [
|
|
149
149
|
"leading-[1.5]",
|
|
150
150
|
"outline-hidden",
|
|
151
151
|
"mt-px",
|
|
@@ -155,54 +155,54 @@ st = lt, st.WRAPPER_CLASSES = [
|
|
|
155
155
|
];
|
|
156
156
|
//#endregion
|
|
157
157
|
//#region src/tools/toggle/dom-builder.ts
|
|
158
|
-
var
|
|
159
|
-
let { data: t, readOnly:
|
|
160
|
-
|
|
161
|
-
let
|
|
162
|
-
|
|
163
|
-
let
|
|
164
|
-
|
|
165
|
-
let
|
|
166
|
-
return
|
|
167
|
-
wrapper:
|
|
168
|
-
arrowElement:
|
|
169
|
-
contentElement:
|
|
170
|
-
bodyPlaceholderElement:
|
|
171
|
-
childContainerElement:
|
|
158
|
+
var dt = (e) => {
|
|
159
|
+
let { data: t, readOnly: n, isOpen: r, keydownHandler: i, onArrowClick: a, onBodyPlaceholderClick: o } = e, s = document.createElement("div");
|
|
160
|
+
s.className = me, s.setAttribute(v.tool, Be), s.setAttribute(b.toggleOpen, String(r));
|
|
161
|
+
let c = document.createElement("div");
|
|
162
|
+
c.className = xe;
|
|
163
|
+
let l = ft(r, a, {}, e.ariaLabels), u = mt(t, n, i);
|
|
164
|
+
c.appendChild(l), c.appendChild(u);
|
|
165
|
+
let d = pt(o, e.bodyPlaceholderText), f = document.createElement("div");
|
|
166
|
+
return f.className = ye, f.setAttribute(b.toggleChildren, ""), f.setAttribute("data-blok-mutation-free", "true"), f.id = `toggle-children-${Date.now()}-${Math.random().toString(36).slice(2)}`, l.setAttribute("aria-controls", f.id), s.appendChild(c), s.appendChild(d), s.appendChild(f), {
|
|
167
|
+
wrapper: s,
|
|
168
|
+
arrowElement: l,
|
|
169
|
+
contentElement: u,
|
|
170
|
+
bodyPlaceholderElement: d,
|
|
171
|
+
childContainerElement: f
|
|
172
172
|
};
|
|
173
|
-
},
|
|
173
|
+
}, ft = (e, t, n = {}, r = {
|
|
174
174
|
collapse: "Collapse",
|
|
175
175
|
expand: "Expand"
|
|
176
176
|
}) => {
|
|
177
|
-
let
|
|
178
|
-
|
|
179
|
-
let
|
|
180
|
-
return
|
|
177
|
+
let i = document.createElement("span");
|
|
178
|
+
i.className = De, i.setAttribute(b.toggleArrow, ""), i.setAttribute(v.mutationFree, "true"), i.setAttribute("role", "button"), i.setAttribute("tabindex", "0"), i.setAttribute("aria-label", e ? r.collapse : r.expand), i.setAttribute("aria-expanded", String(e)), n.contentEditableFalse === !0 && (i.contentEditable = "false"), i.innerHTML = Ue;
|
|
179
|
+
let a = i.querySelector("svg");
|
|
180
|
+
return a && (a.style.transition = "transform 200ms ease-in-out", e && (a.style.transform = "rotate(90deg)")), t && (i.addEventListener("click", (e) => {
|
|
181
181
|
e.stopPropagation(), t();
|
|
182
|
-
}),
|
|
182
|
+
}), i.addEventListener("keydown", (e) => {
|
|
183
183
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), t());
|
|
184
|
-
})),
|
|
185
|
-
},
|
|
184
|
+
})), i;
|
|
185
|
+
}, pt = (e, t) => {
|
|
186
186
|
let n = document.createElement("div");
|
|
187
|
-
return n.className =
|
|
188
|
-
},
|
|
187
|
+
return n.className = Ge, n.setAttribute(b.toggleBodyPlaceholder, ""), n.setAttribute("data-blok-mutation-free", "true"), n.textContent = t, e && n.addEventListener("click", e), n;
|
|
188
|
+
}, mt = (e, t, n) => {
|
|
189
189
|
let r = document.createElement("div");
|
|
190
|
-
return r.className =
|
|
191
|
-
},
|
|
192
|
-
let t =
|
|
193
|
-
return t.contentElement &&
|
|
194
|
-
},
|
|
190
|
+
return r.className = S(_e, tt, rt), r.setAttribute(b.toggleContent, ""), r.contentEditable = t ? "false" : "true", r.innerHTML = e.text, n && r.addEventListener("keydown", n), r;
|
|
191
|
+
}, ht = (e) => {
|
|
192
|
+
let t = dt(e);
|
|
193
|
+
return t.contentElement && st(t.contentElement, e.placeholder, "data-blok-placeholder-active"), t;
|
|
194
|
+
}, w = (e, t, n, r = {
|
|
195
195
|
collapse: "Collapse",
|
|
196
196
|
expand: "Expand"
|
|
197
197
|
}) => {
|
|
198
198
|
let i = e.querySelector("svg");
|
|
199
|
-
i && (i.style.transform = n ? "rotate(90deg)" : ""), e.setAttribute("aria-label", n ? r.collapse : r.expand), e.setAttribute("aria-expanded", String(n)), t.setAttribute(
|
|
200
|
-
},
|
|
199
|
+
i && (i.style.transform = n ? "rotate(90deg)" : ""), e.setAttribute("aria-label", n ? r.collapse : r.expand), e.setAttribute("aria-expanded", String(n)), t.setAttribute(b.toggleOpen, String(n));
|
|
200
|
+
}, gt = (e, t, n, r, i) => {
|
|
201
201
|
let a = e.blocks.getChildren(t);
|
|
202
202
|
!n && r && i && r.contains(document.activeElement) && i.focus();
|
|
203
203
|
for (let e of a) r && e.holder.parentElement !== r && r.appendChild(e.holder), n ? e.holder.classList.remove("hidden") : e.holder.classList.add("hidden");
|
|
204
204
|
r && (n ? r.removeAttribute("aria-hidden") : r.setAttribute("aria-hidden", "true"));
|
|
205
|
-
},
|
|
205
|
+
}, _t = (e, t, n, r, i) => {
|
|
206
206
|
if (e === null) return;
|
|
207
207
|
if (i) {
|
|
208
208
|
e.classList.add("hidden");
|
|
@@ -210,27 +210,27 @@ var ut = (e) => {
|
|
|
210
210
|
}
|
|
211
211
|
let a = t.blocks.getChildren(n);
|
|
212
212
|
r && a.length === 0 ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
213
|
-
},
|
|
213
|
+
}, vt = async (e) => {
|
|
214
214
|
var t;
|
|
215
215
|
let { api: n, blockId: r, data: i, getContentElement: a, syncContentFromDOM: o, isOpen: s } = e;
|
|
216
216
|
if (o(), r === void 0) return;
|
|
217
217
|
let c = a(), l = window.getSelection();
|
|
218
218
|
if (!c || !l || l.rangeCount === 0) return;
|
|
219
|
-
let { beforeContent: u, afterContent: d } =
|
|
219
|
+
let { beforeContent: u, afterContent: d } = bt(c, l.getRangeAt(0)), f = (t = n.blocks.getBlockIndex(r)) == null ? n.blocks.getCurrentBlockIndex() : t;
|
|
220
220
|
if (s && d === "") {
|
|
221
221
|
let e = n.blocks.insertInsideParent(r, f + 1);
|
|
222
222
|
n.caret.setToBlock(e.id, "start");
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
|
-
n.blocks.splitBlock(r, { text: u },
|
|
226
|
-
},
|
|
225
|
+
n.blocks.splitBlock(r, { text: u }, Be, { text: d }, f + 1), i.text = u;
|
|
226
|
+
}, yt = async (e, t) => {
|
|
227
227
|
let { api: n, blockId: r, data: i, getContentElement: a, syncContentFromDOM: o } = e;
|
|
228
228
|
if (o(), r === void 0) return;
|
|
229
229
|
let s = a();
|
|
230
|
-
if (!s || !
|
|
231
|
-
let
|
|
232
|
-
|
|
233
|
-
},
|
|
230
|
+
if (!s || !c(s)) return;
|
|
231
|
+
let l = i.text;
|
|
232
|
+
l === "" && (t.preventDefault(), await n.blocks.convert(r, "paragraph", { text: l }));
|
|
233
|
+
}, bt = (e, t) => {
|
|
234
234
|
if (!e.lastChild) return {
|
|
235
235
|
beforeContent: "",
|
|
236
236
|
afterContent: ""
|
|
@@ -246,13 +246,13 @@ var ut = (e) => {
|
|
|
246
246
|
beforeContent: i.innerHTML,
|
|
247
247
|
afterContent: a.innerHTML
|
|
248
248
|
};
|
|
249
|
-
},
|
|
249
|
+
}, xt = async (e) => {
|
|
250
250
|
var t;
|
|
251
251
|
let { api: n, blockId: r, getContentElement: i, syncContentFromDOM: a, isOpen: o, currentLevel: s } = e;
|
|
252
252
|
if (a(), r === void 0) return;
|
|
253
253
|
let c = i(), l = window.getSelection();
|
|
254
254
|
if (!c || !l || l.rangeCount === 0) return;
|
|
255
|
-
let { beforeContent: u, afterContent: d } =
|
|
255
|
+
let { beforeContent: u, afterContent: d } = bt(c, l.getRangeAt(0)), f = (t = n.blocks.getBlockIndex(r)) == null ? n.blocks.getCurrentBlockIndex() : t;
|
|
256
256
|
if (o && d === "") {
|
|
257
257
|
let e = n.blocks.insertInsideParent(r, f + 1);
|
|
258
258
|
n.caret.setToBlock(e.id, "start");
|
|
@@ -267,17 +267,17 @@ var ut = (e) => {
|
|
|
267
267
|
level: s,
|
|
268
268
|
isToggleable: !0
|
|
269
269
|
}, f + 1);
|
|
270
|
-
},
|
|
270
|
+
}, St = async (e, t) => {
|
|
271
271
|
let { api: n, blockId: r, getText: i, getContentElement: a, syncContentFromDOM: o, currentLevel: s } = e;
|
|
272
272
|
if (o(), r === void 0) return;
|
|
273
|
-
let
|
|
274
|
-
if (!
|
|
275
|
-
let
|
|
276
|
-
|
|
277
|
-
text:
|
|
273
|
+
let l = a();
|
|
274
|
+
if (!l || !c(l)) return;
|
|
275
|
+
let u = i();
|
|
276
|
+
u === "" && (t.preventDefault(), await n.blocks.convert(r, "header", {
|
|
277
|
+
text: u,
|
|
278
278
|
level: s
|
|
279
279
|
}));
|
|
280
|
-
},
|
|
280
|
+
}, Ct, wt = class e {
|
|
281
281
|
constructor({ data: e, config: t, api: n, readOnly: r, block: i }) {
|
|
282
282
|
var a;
|
|
283
283
|
this._arrowElement = null, this._wrapper = null, this._headerRow = null, this._childContainerElement = null, this._bodyPlaceholderElement = null, this.handleKeyDown = (e) => {
|
|
@@ -285,7 +285,7 @@ var ut = (e) => {
|
|
|
285
285
|
e.preventDefault(), this.handleEnter();
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
|
-
e.key === "Backspace" &&
|
|
288
|
+
e.key === "Backspace" && St(this.createKeyboardContext(), e);
|
|
289
289
|
}, this.handleBlockChanged = (e) => {
|
|
290
290
|
this.isBlockChangedPayload(e) && (e.event.type === "block-removed" || e.event.type === "block-added") && this.updateBodyPlaceholderVisibility();
|
|
291
291
|
}, this.api = n, this.readOnly = r, this._settings = t || {}, this._data = this.normalizeData(e), this._isOpen = (a = this._data.isOpen) == null ? !r : a, this._element = this.getTag(), i && (this.blockId = i.id), !r && this._data.isToggleable && this.api.events.on("block changed", this.handleBlockChanged);
|
|
@@ -311,7 +311,7 @@ var ut = (e) => {
|
|
|
311
311
|
if (e.isToggleable === !0 && (r.isToggleable = !0), typeof e.isOpen == "boolean" && (r.isOpen = e.isOpen), r.text) {
|
|
312
312
|
let e = document.createElement("div");
|
|
313
313
|
e.innerHTML = r.text;
|
|
314
|
-
let t = e.querySelector(`[${
|
|
314
|
+
let t = e.querySelector(`[${b.toggleArrow}]`);
|
|
315
315
|
t && (t.remove(), r.text = e.innerHTML);
|
|
316
316
|
}
|
|
317
317
|
return r;
|
|
@@ -326,13 +326,13 @@ var ut = (e) => {
|
|
|
326
326
|
this.api.events.off("block changed", this.handleBlockChanged), this._element.removeEventListener("keydown", this.handleKeyDown);
|
|
327
327
|
}
|
|
328
328
|
expand() {
|
|
329
|
-
!this._data.isToggleable || this._isOpen || (this._isOpen = !0, this._arrowElement && this._element &&
|
|
329
|
+
!this._data.isToggleable || this._isOpen || (this._isOpen = !0, this._arrowElement && this._element && w(this._arrowElement, this._element, this._isOpen, {
|
|
330
330
|
collapse: this.api.i18n.t("tools.toggle.ariaLabelCollapse"),
|
|
331
331
|
expand: this.api.i18n.t("tools.toggle.ariaLabelExpand")
|
|
332
332
|
}), this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility());
|
|
333
333
|
}
|
|
334
334
|
collapse() {
|
|
335
|
-
!this._data.isToggleable || !this._isOpen || (this._isOpen = !1, this._arrowElement && this._element &&
|
|
335
|
+
!this._data.isToggleable || !this._isOpen || (this._isOpen = !1, this._arrowElement && this._element && w(this._arrowElement, this._element, this._isOpen, {
|
|
336
336
|
collapse: this.api.i18n.t("tools.toggle.ariaLabelCollapse"),
|
|
337
337
|
expand: this.api.i18n.t("tools.toggle.ariaLabelExpand")
|
|
338
338
|
}), this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility());
|
|
@@ -360,14 +360,14 @@ var ut = (e) => {
|
|
|
360
360
|
merge(e) {
|
|
361
361
|
let t = document.createElement("div");
|
|
362
362
|
t.innerHTML = e.text;
|
|
363
|
-
let n = t.querySelector(`[${
|
|
363
|
+
let n = t.querySelector(`[${b.toggleArrow}]`);
|
|
364
364
|
n && n.remove(), this._element.insertAdjacentHTML("beforeend", t.innerHTML);
|
|
365
365
|
}
|
|
366
366
|
validate(e) {
|
|
367
367
|
return typeof e.text == "string";
|
|
368
368
|
}
|
|
369
369
|
setData(e) {
|
|
370
|
-
return this._data = this.normalizeData(e), typeof e.text == "string" && (this._element.innerHTML = e.text), this._data.isToggleable && typeof this._data.isOpen == "boolean" && (this._isOpen = this._data.isOpen, this._arrowElement && this._element &&
|
|
370
|
+
return this._data = this.normalizeData(e), typeof e.text == "string" && (this._element.innerHTML = e.text), this._data.isToggleable && typeof this._data.isOpen == "boolean" && (this._isOpen = this._data.isOpen, this._arrowElement && this._element && w(this._arrowElement, this._element, this._isOpen, {
|
|
371
371
|
collapse: this.api.i18n.t("tools.toggle.ariaLabelCollapse"),
|
|
372
372
|
expand: this.api.i18n.t("tools.toggle.ariaLabelExpand")
|
|
373
373
|
}), this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility()), !0;
|
|
@@ -406,13 +406,13 @@ var ut = (e) => {
|
|
|
406
406
|
e.innerHTML = this._element.innerHTML, this._element.parentNode.replaceChild(e, this._element), this._element = e;
|
|
407
407
|
}
|
|
408
408
|
if (t.text !== void 0 && (this._element.innerHTML = this._data.text || ""), this._data.isToggleable) {
|
|
409
|
-
if (this._element.setAttribute(
|
|
410
|
-
else if (!this._wrapper.querySelector(`[${
|
|
409
|
+
if (this._element.setAttribute(b.toggleOpen, String(this._isOpen)), this._element.className = S(e.BASE_STYLES, this.currentLevel.styles, C, "pl-8"), !this._wrapper) this.createToggleWrapper();
|
|
410
|
+
else if (!this._wrapper.querySelector(`[${b.toggleArrow}]`)) {
|
|
411
411
|
var n;
|
|
412
412
|
let e = this.buildArrow();
|
|
413
413
|
this._arrowElement = e, ((n = this._headerRow) == null ? this._wrapper : n).prepend(e);
|
|
414
414
|
}
|
|
415
|
-
} else if (this._element.removeAttribute(
|
|
415
|
+
} else if (this._element.removeAttribute(b.toggleOpen), this._element.className = S(e.BASE_STYLES, this.currentLevel.styles, C), this._arrowElement = null, this._wrapper) {
|
|
416
416
|
let e = this._wrapper.parentNode;
|
|
417
417
|
e && e.replaceChild(this._element, this._wrapper), this._wrapper = null, this._headerRow = null;
|
|
418
418
|
}
|
|
@@ -422,14 +422,14 @@ var ut = (e) => {
|
|
|
422
422
|
}
|
|
423
423
|
getTag() {
|
|
424
424
|
let t = document.createElement(this.currentLevel.tag);
|
|
425
|
-
t.innerHTML = this._data.text || "", t.className =
|
|
426
|
-
let { inlineStyles:
|
|
427
|
-
|
|
428
|
-
let
|
|
429
|
-
return this.readOnly ? t.setAttribute("data-placeholder",
|
|
425
|
+
t.innerHTML = this._data.text || "", t.className = S(e.BASE_STYLES, this.currentLevel.styles, C, this._data.isToggleable ? "pl-8" : "");
|
|
426
|
+
let { inlineStyles: n } = this.currentLevel;
|
|
427
|
+
n && Object.assign(t.style, n), t.setAttribute(v.tool, "header"), t.contentEditable = this.readOnly ? "false" : "true", this._data.isToggleable && t.setAttribute(b.toggleOpen, String(this._isOpen));
|
|
428
|
+
let r = this.api.i18n.t(this.currentLevel.nameKey), i = this.resolvePlaceholderText(r);
|
|
429
|
+
return this.readOnly ? t.setAttribute("data-placeholder", i) : st(t, i), !this.readOnly && this._data.isToggleable && t.addEventListener("keydown", this.handleKeyDown), t;
|
|
430
430
|
}
|
|
431
431
|
buildArrow() {
|
|
432
|
-
let e =
|
|
432
|
+
let e = ft(this._isOpen, () => this.toggleOpen(), {}, {
|
|
433
433
|
collapse: this.api.i18n.t("tools.toggle.ariaLabelCollapse"),
|
|
434
434
|
expand: this.api.i18n.t("tools.toggle.ariaLabelExpand")
|
|
435
435
|
});
|
|
@@ -441,9 +441,9 @@ var ut = (e) => {
|
|
|
441
441
|
let n = this.buildArrow();
|
|
442
442
|
this._arrowElement = n, t.appendChild(n), t.appendChild(this._element), e.appendChild(t);
|
|
443
443
|
let r = document.createElement("div");
|
|
444
|
-
r.className =
|
|
444
|
+
r.className = S(Ge, "pl-8"), r.setAttribute(b.toggleBodyPlaceholder, ""), r.setAttribute("data-blok-mutation-free", "true"), r.textContent = this.api.i18n.t("tools.toggle.bodyPlaceholder"), this.readOnly || r.addEventListener("click", () => this.handleBodyPlaceholderClick()), this._bodyPlaceholderElement = r, e.appendChild(r);
|
|
445
445
|
let i = document.createElement("div");
|
|
446
|
-
return i.className =
|
|
446
|
+
return i.className = "pl-8", i.setAttribute(b.toggleChildren, ""), i.setAttribute("data-blok-mutation-free", "true"), this._childContainerElement = i, e.appendChild(i), e;
|
|
447
447
|
}
|
|
448
448
|
createToggleWrapper() {
|
|
449
449
|
let e = this._element.parentNode;
|
|
@@ -468,19 +468,19 @@ var ut = (e) => {
|
|
|
468
468
|
}
|
|
469
469
|
async handleEnter() {
|
|
470
470
|
var e = this;
|
|
471
|
-
await
|
|
471
|
+
await xt(e.createKeyboardContext()), e.updateChildrenVisibility(), e.updateBodyPlaceholderVisibility();
|
|
472
472
|
}
|
|
473
473
|
toggleOpen() {
|
|
474
|
-
this._isOpen = !this._isOpen, this._arrowElement && this._element &&
|
|
474
|
+
this._isOpen = !this._isOpen, this._arrowElement && this._element && w(this._arrowElement, this._element, this._isOpen, {
|
|
475
475
|
collapse: this.api.i18n.t("tools.toggle.ariaLabelCollapse"),
|
|
476
476
|
expand: this.api.i18n.t("tools.toggle.ariaLabelExpand")
|
|
477
477
|
}), this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility();
|
|
478
478
|
}
|
|
479
479
|
updateChildrenVisibility() {
|
|
480
|
-
this.blockId !== void 0 &&
|
|
480
|
+
this.blockId !== void 0 && gt(this.api, this.blockId, this._isOpen, this._childContainerElement, this._arrowElement);
|
|
481
481
|
}
|
|
482
482
|
updateBodyPlaceholderVisibility() {
|
|
483
|
-
this.blockId !== void 0 &&
|
|
483
|
+
this.blockId !== void 0 && _t(this._bodyPlaceholderElement, this.api, this.blockId, this._isOpen, this.readOnly);
|
|
484
484
|
}
|
|
485
485
|
handleBodyPlaceholderClick() {
|
|
486
486
|
var e;
|
|
@@ -558,9 +558,9 @@ var ut = (e) => {
|
|
|
558
558
|
],
|
|
559
559
|
shortcut: "#".repeat(e.number)
|
|
560
560
|
})), n = {
|
|
561
|
-
1:
|
|
562
|
-
2:
|
|
563
|
-
3:
|
|
561
|
+
1: Oe,
|
|
562
|
+
2: he,
|
|
563
|
+
3: ze
|
|
564
564
|
}, r = e.DEFAULT_LEVELS.filter((e) => e.number <= 3).map((e) => ({
|
|
565
565
|
icon: n[e.number],
|
|
566
566
|
title: `Toggle heading ${e.number}`,
|
|
@@ -581,13 +581,13 @@ var ut = (e) => {
|
|
|
581
581
|
return [...t, ...r];
|
|
582
582
|
}
|
|
583
583
|
};
|
|
584
|
-
|
|
584
|
+
Ct = wt, Ct.BASE_STYLES = "py-[7px] px-[2px] m-0 leading-[1.3]! outline-hidden [&_p]:p-0! [&_p]:m-0! [&_div]:p-0! [&_div]:m-0!", Ct.DEFAULT_LEVELS = [
|
|
585
585
|
{
|
|
586
586
|
number: 1,
|
|
587
587
|
tag: "H1",
|
|
588
588
|
nameKey: "tools.header.heading1",
|
|
589
589
|
name: "Heading 1",
|
|
590
|
-
icon:
|
|
590
|
+
icon: ee,
|
|
591
591
|
styles: "text-3xl font-semibold mt-8 mb-px"
|
|
592
592
|
},
|
|
593
593
|
{
|
|
@@ -595,7 +595,7 @@ St = Ct, St.BASE_STYLES = "py-[3px] px-[2px] m-0 leading-[1.3]! outline-hidden [
|
|
|
595
595
|
tag: "H2",
|
|
596
596
|
nameKey: "tools.header.heading2",
|
|
597
597
|
name: "Heading 2",
|
|
598
|
-
icon:
|
|
598
|
+
icon: te,
|
|
599
599
|
styles: "text-2xl font-semibold mt-[26px] mb-px"
|
|
600
600
|
},
|
|
601
601
|
{
|
|
@@ -603,7 +603,7 @@ St = Ct, St.BASE_STYLES = "py-[3px] px-[2px] m-0 leading-[1.3]! outline-hidden [
|
|
|
603
603
|
tag: "H3",
|
|
604
604
|
nameKey: "tools.header.heading3",
|
|
605
605
|
name: "Heading 3",
|
|
606
|
-
icon:
|
|
606
|
+
icon: re,
|
|
607
607
|
styles: "text-xl font-semibold mt-5 mb-px"
|
|
608
608
|
},
|
|
609
609
|
{
|
|
@@ -611,7 +611,7 @@ St = Ct, St.BASE_STYLES = "py-[3px] px-[2px] m-0 leading-[1.3]! outline-hidden [
|
|
|
611
611
|
tag: "H4",
|
|
612
612
|
nameKey: "tools.header.heading4",
|
|
613
613
|
name: "Heading 4",
|
|
614
|
-
icon:
|
|
614
|
+
icon: l,
|
|
615
615
|
styles: "text-lg font-semibold mt-3 mb-px"
|
|
616
616
|
},
|
|
617
617
|
{
|
|
@@ -619,7 +619,7 @@ St = Ct, St.BASE_STYLES = "py-[3px] px-[2px] m-0 leading-[1.3]! outline-hidden [
|
|
|
619
619
|
tag: "H5",
|
|
620
620
|
nameKey: "tools.header.heading5",
|
|
621
621
|
name: "Heading 5",
|
|
622
|
-
icon:
|
|
622
|
+
icon: f,
|
|
623
623
|
styles: "text-base font-semibold mt-3 mb-px"
|
|
624
624
|
},
|
|
625
625
|
{
|
|
@@ -627,16 +627,16 @@ St = Ct, St.BASE_STYLES = "py-[3px] px-[2px] m-0 leading-[1.3]! outline-hidden [
|
|
|
627
627
|
tag: "H6",
|
|
628
628
|
nameKey: "tools.header.heading6",
|
|
629
629
|
name: "Heading 6",
|
|
630
|
-
icon:
|
|
630
|
+
icon: g,
|
|
631
631
|
styles: "text-sm font-semibold mt-3 mb-px"
|
|
632
632
|
}
|
|
633
633
|
];
|
|
634
634
|
//#endregion
|
|
635
635
|
//#region src/tools/list/constants.ts
|
|
636
|
-
var
|
|
636
|
+
var Tt = "outline-hidden py-[7px] mt-[2px] mb-px", Et = "outline-hidden pl-0.5 leading-[1.5] items-start", Dt = "flex items-start pl-0.5", Ot = "mt-0.5 w-5 mr-2 h-5 cursor-pointer accent-current", kt = "tools.list.placeholder", At = "list", jt = {
|
|
637
637
|
contentContainer: "list-content-container",
|
|
638
638
|
checklistContent: "list-checklist-content"
|
|
639
|
-
},
|
|
639
|
+
}, Mt = (e, t) => {
|
|
640
640
|
let n = e;
|
|
641
641
|
n._placeholder = t, Object.defineProperty(n, "getPlaceholder", {
|
|
642
642
|
value: () => n._placeholder,
|
|
@@ -644,8 +644,8 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
644
644
|
enumerable: !0,
|
|
645
645
|
configurable: !1
|
|
646
646
|
});
|
|
647
|
-
},
|
|
648
|
-
let { data: t, keydownHandler: n, readOnly: r } = e, i =
|
|
647
|
+
}, Nt = (e) => {
|
|
648
|
+
let { data: t, keydownHandler: n, readOnly: r } = e, i = Pt(e), a = t.style === "checklist" ? It(e) : Ft(e);
|
|
649
649
|
i.appendChild(a), !r && n && i.addEventListener("keydown", n);
|
|
650
650
|
let o = a.querySelector("[data-list-marker]"), s = a.querySelector("input[type=\"checkbox\"]"), c = a.querySelector("[contenteditable]");
|
|
651
651
|
return {
|
|
@@ -654,49 +654,49 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
654
654
|
markerElement: o,
|
|
655
655
|
checkboxElement: s
|
|
656
656
|
};
|
|
657
|
-
}, Nt = (e) => {
|
|
658
|
-
var t;
|
|
659
|
-
let { data: r } = e, i = document.createElement("div");
|
|
660
|
-
return i.className = wt, i.setAttribute(n.tool, kt), i.setAttribute("data-list-style", r.style), i.setAttribute("data-list-depth", String((t = r.depth) == null ? 0 : t)), r.start !== void 0 && r.start !== 1 && i.setAttribute("data-list-start", String(r.start)), i;
|
|
661
657
|
}, Pt = (e) => {
|
|
658
|
+
var t;
|
|
659
|
+
let { data: n } = e, r = document.createElement("div");
|
|
660
|
+
return r.className = Tt, r.setAttribute(v.tool, At), r.setAttribute("data-list-style", n.style), r.setAttribute("data-list-depth", String((t = n.depth) == null ? 0 : t)), n.start !== void 0 && n.start !== 1 && r.setAttribute("data-list-start", String(n.start)), r;
|
|
661
|
+
}, Ft = (e) => {
|
|
662
662
|
var t;
|
|
663
663
|
let { data: n, itemColor: r, itemSize: i, placeholder: a } = e, o = document.createElement("div");
|
|
664
|
-
o.setAttribute("role", "listitem"), o.className =
|
|
664
|
+
o.setAttribute("role", "listitem"), o.className = S(Et, "flex", ...C), r && (o.style.color = r), i && (o.style.fontSize = i);
|
|
665
665
|
let s = (t = n.depth) == null ? 0 : t;
|
|
666
666
|
if (s > 0) {
|
|
667
667
|
let e = n.style === "ordered" ? 26 : 27;
|
|
668
668
|
o.style.marginLeft = `${s * e}px`;
|
|
669
669
|
}
|
|
670
|
-
let c =
|
|
670
|
+
let c = Lt(n.style, s);
|
|
671
671
|
c.setAttribute("data-list-marker", "true"), c.setAttribute("data-blok-mutation-free", "true"), o.appendChild(c);
|
|
672
672
|
let l = document.createElement("div");
|
|
673
|
-
return l.className =
|
|
674
|
-
},
|
|
673
|
+
return l.className = S("flex-1 min-w-0 outline-hidden", ...C), l.setAttribute("data-blok-testid", jt.contentContainer), l.contentEditable = e.readOnly ? "false" : "true", l.innerHTML = n.text, Mt(l, a), o.appendChild(l), o;
|
|
674
|
+
}, It = (e) => {
|
|
675
675
|
var t;
|
|
676
676
|
let { data: n, itemColor: r, itemSize: i, placeholder: a, readOnly: o } = e, s = document.createElement("div");
|
|
677
|
-
s.setAttribute("role", "listitem"), s.className =
|
|
677
|
+
s.setAttribute("role", "listitem"), s.className = Dt, r && (s.style.color = r), i && (s.style.fontSize = i);
|
|
678
678
|
let c = (t = n.depth) == null ? 0 : t;
|
|
679
679
|
c > 0 && (s.style.marginLeft = `${c * 27}px`);
|
|
680
680
|
let l = document.createElement("input");
|
|
681
|
-
l.type = "checkbox", l.className =
|
|
681
|
+
l.type = "checkbox", l.className = Ot, l.checked = !!n.checked, l.disabled = o;
|
|
682
682
|
let u = document.createElement("div");
|
|
683
|
-
return u.className =
|
|
684
|
-
},
|
|
683
|
+
return u.className = S("flex-1 outline-hidden leading-[1.5]", n.checked ? "line-through opacity-60" : "", ...C), u.setAttribute("data-blok-testid", jt.checklistContent), u.setAttribute("data-checked", String(n.checked)), u.contentEditable = o ? "false" : "true", u.innerHTML = n.text, Mt(u, a), s.appendChild(l), s.appendChild(u), s;
|
|
684
|
+
}, Lt = (e, t) => {
|
|
685
685
|
let n = document.createElement("span");
|
|
686
|
-
return n.className = "shrink-0 select-none", n.setAttribute("aria-hidden", "true"), n.contentEditable = "false", e === "ordered" ? (n.textContent = "1.", n.className =
|
|
687
|
-
},
|
|
686
|
+
return n.className = "shrink-0 select-none", n.setAttribute("aria-hidden", "true"), n.contentEditable = "false", e === "ordered" ? (n.textContent = "1.", n.className = S(n.className, "text-right"), n.style.paddingRight = "11px", n.style.minWidth = "fit-content") : (n.textContent = Rt(t), n.className = S(n.className, "w-6 text-center flex justify-center"), n.style.paddingLeft = "1px", n.style.paddingRight = "13px", n.style.fontSize = "24px", n.style.fontFamily = "Arial", n.style.lineHeight = "1.5rem"), n;
|
|
687
|
+
}, Rt = (e) => {
|
|
688
688
|
let t = [
|
|
689
689
|
"•",
|
|
690
690
|
"◦",
|
|
691
691
|
"▪"
|
|
692
692
|
];
|
|
693
693
|
return t[e % t.length];
|
|
694
|
-
},
|
|
694
|
+
}, zt = (e) => {
|
|
695
695
|
let { data: t, readOnly: n, placeholder: r, itemColor: i, itemSize: a, element: o, setupItemPlaceholder: s, onCheckboxChange: c, keydownHandler: l } = e;
|
|
696
696
|
if (!o) return null;
|
|
697
697
|
let u = o.parentNode;
|
|
698
698
|
if (!u) return null;
|
|
699
|
-
let d =
|
|
699
|
+
let d = Nt({
|
|
700
700
|
data: t,
|
|
701
701
|
readOnly: n,
|
|
702
702
|
placeholder: r,
|
|
@@ -711,14 +711,14 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
711
711
|
});
|
|
712
712
|
}
|
|
713
713
|
return u.replaceChild(d.wrapper, o), d.wrapper;
|
|
714
|
-
},
|
|
714
|
+
}, Bt = (e, t, n) => {
|
|
715
715
|
if (!t) return e;
|
|
716
|
-
let r = n(), i =
|
|
717
|
-
text: r ?
|
|
716
|
+
let r = n(), i = x({
|
|
717
|
+
text: r ? et(r.innerHTML) : e.text,
|
|
718
718
|
style: e.style
|
|
719
719
|
}, e.style === "checklist" ? { checked: !!e.checked } : {});
|
|
720
720
|
return e.start !== void 0 && e.start !== 1 && (i.start = e.start), e.depth !== void 0 && e.depth > 0 && (i.depth = e.depth), i;
|
|
721
|
-
},
|
|
721
|
+
}, Vt = (e, t, n, r, i) => {
|
|
722
722
|
var a, o;
|
|
723
723
|
if (!n) return {
|
|
724
724
|
newData: e,
|
|
@@ -729,7 +729,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
729
729
|
newData: e,
|
|
730
730
|
inPlace: !1
|
|
731
731
|
};
|
|
732
|
-
let d = "depth" in t ? t.depth : 0, f =
|
|
732
|
+
let d = "depth" in t ? t.depth : 0, f = x(x(x({}, e), t), {}, { depth: d }), p = r();
|
|
733
733
|
if (p && typeof t.text == "string" && (p.innerHTML = t.text), s !== c) return i.adjustDepthTo(c), i.updateMarkerForDepth(c, u), {
|
|
734
734
|
newData: f,
|
|
735
735
|
inPlace: !0
|
|
@@ -742,7 +742,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
742
742
|
newData: f,
|
|
743
743
|
inPlace: !0
|
|
744
744
|
};
|
|
745
|
-
},
|
|
745
|
+
}, Ht = (e, t) => {
|
|
746
746
|
let { element: n, getContentElement: r, parseHTML: i, data: a } = e;
|
|
747
747
|
if (!n) return;
|
|
748
748
|
a.text += t.text;
|
|
@@ -751,29 +751,29 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
751
751
|
let e = i(t.text);
|
|
752
752
|
o.appendChild(e), o.normalize();
|
|
753
753
|
}
|
|
754
|
-
},
|
|
754
|
+
}, Ut = (e, t, n, r) => e.map((e) => ({
|
|
755
755
|
icon: e.icon,
|
|
756
756
|
title: n(`toolNames.${e.titleKey}`),
|
|
757
757
|
onActivate: () => r(e.style),
|
|
758
758
|
closeOnActivate: !0,
|
|
759
759
|
isActive: t === e.style
|
|
760
|
-
})),
|
|
760
|
+
})), Wt = (e) => {
|
|
761
761
|
if (!e) return;
|
|
762
762
|
let t = (e.getAttribute("style") || "").match(/margin-left:\s*(\d+)px/);
|
|
763
763
|
if (!t) return;
|
|
764
764
|
let n = parseInt(t[1], 10);
|
|
765
765
|
return n > 0 ? { left: n } : void 0;
|
|
766
|
-
},
|
|
766
|
+
}, Gt = (e) => {
|
|
767
767
|
let t = e.closest("[data-list-depth]");
|
|
768
768
|
if (!t) return;
|
|
769
769
|
let n = t.getAttribute("data-list-depth");
|
|
770
770
|
if (n === null) return;
|
|
771
771
|
let r = parseInt(n, 10);
|
|
772
772
|
return r > 0 ? { left: r * 27 } : void 0;
|
|
773
|
-
},
|
|
774
|
-
let t =
|
|
775
|
-
return t === void 0 ?
|
|
776
|
-
},
|
|
773
|
+
}, Kt = (e) => {
|
|
774
|
+
let t = Wt(e.closest("[role=\"listitem\"]") || e.querySelector("[role=\"listitem\"]"));
|
|
775
|
+
return t === void 0 ? Gt(e) : t;
|
|
776
|
+
}, qt = (e, t) => {
|
|
777
777
|
let n = document.createRange();
|
|
778
778
|
if (n.setStart(e, 0), n.setEnd(t.startContainer, t.startOffset), !e.lastChild) return {
|
|
779
779
|
beforeContent: "",
|
|
@@ -781,32 +781,32 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
781
781
|
};
|
|
782
782
|
let r = document.createRange();
|
|
783
783
|
return r.setStart(t.endContainer, t.endOffset), r.setEndAfter(e.lastChild), {
|
|
784
|
-
beforeContent:
|
|
785
|
-
afterContent:
|
|
784
|
+
beforeContent: Jt(n.cloneContents()),
|
|
785
|
+
afterContent: Jt(r.cloneContents())
|
|
786
786
|
};
|
|
787
|
-
},
|
|
787
|
+
}, Jt = (e) => {
|
|
788
788
|
let t = document.createElement("div");
|
|
789
789
|
return t.appendChild(e), t.innerHTML;
|
|
790
|
-
},
|
|
790
|
+
}, Yt = (e) => {
|
|
791
791
|
let t = document.createElement("div");
|
|
792
792
|
t.innerHTML = e.trim();
|
|
793
793
|
let n = document.createDocumentFragment();
|
|
794
794
|
return n.append(...Array.from(t.childNodes)), n;
|
|
795
|
-
},
|
|
795
|
+
}, Xt = (e, t) => {
|
|
796
796
|
let n = document.createRange();
|
|
797
797
|
return n.selectNodeContents(e), n.setEnd(t.startContainer, t.startOffset), n.toString().length === 0;
|
|
798
|
-
},
|
|
798
|
+
}, Zt = (e, t) => {
|
|
799
799
|
let n = document.createRange();
|
|
800
800
|
n.selectNodeContents(e), n.setEnd(t.startContainer, t.startOffset);
|
|
801
801
|
let r = n.toString().length === 0, i = document.createRange();
|
|
802
802
|
i.selectNodeContents(e), i.setStart(t.endContainer, t.endOffset);
|
|
803
803
|
let a = i.toString().length === 0;
|
|
804
804
|
return r && a;
|
|
805
|
-
},
|
|
805
|
+
}, Qt = (e) => {
|
|
806
806
|
if (typeof e != "object" || !e) return !1;
|
|
807
807
|
let t = Object.entries(e).find(([e]) => e === "items");
|
|
808
808
|
return t === void 0 ? !1 : Array.isArray(t[1]);
|
|
809
|
-
},
|
|
809
|
+
}, $t = (e) => typeof e == "object" && !!e, en = (e) => typeof e == "string" ? e : "", tn = (e, t) => e === "unordered" || e === "ordered" || e === "checklist" ? e : t, nn = (e) => !!e, rn = (e, t) => typeof e == "number" ? e : t, an = (e, t) => {
|
|
810
810
|
let n = t.defaultStyle || "unordered";
|
|
811
811
|
if (!e || typeof e != "object") return {
|
|
812
812
|
text: "",
|
|
@@ -814,18 +814,18 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
814
814
|
checked: !1,
|
|
815
815
|
depth: 0
|
|
816
816
|
};
|
|
817
|
-
if (
|
|
817
|
+
if (Qt(e)) {
|
|
818
818
|
let t = e.items[0], r = (t == null ? void 0 : t.content) || "", i = (t == null ? void 0 : t.checked) || !1;
|
|
819
|
-
return
|
|
819
|
+
return x({
|
|
820
820
|
text: r,
|
|
821
821
|
style: e.style || n,
|
|
822
822
|
checked: !!i,
|
|
823
823
|
depth: 0
|
|
824
824
|
}, e.start !== void 0 && e.start !== 1 ? { start: e.start } : {});
|
|
825
825
|
}
|
|
826
|
-
if (
|
|
827
|
-
let t =
|
|
828
|
-
return
|
|
826
|
+
if ($t(e)) {
|
|
827
|
+
let t = en(e.text), r = tn(e.style, n), i = nn(e.checked), a = rn(e.depth, 0), o = e.start, s = typeof o == "number" && o !== void 0 && o !== 1 ? o : void 0;
|
|
828
|
+
return x({
|
|
829
829
|
text: t,
|
|
830
830
|
style: r,
|
|
831
831
|
checked: i,
|
|
@@ -838,7 +838,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
838
838
|
checked: !1,
|
|
839
839
|
depth: 0
|
|
840
840
|
};
|
|
841
|
-
},
|
|
841
|
+
}, on = class {
|
|
842
842
|
constructor(e) {
|
|
843
843
|
this.blocks = e;
|
|
844
844
|
}
|
|
@@ -866,7 +866,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
866
866
|
let n = (t = e.holder) == null || (t = t.querySelector("[role=\"listitem\"]")) == null ? void 0 : t.getAttribute("style"), r = n == null ? void 0 : n.match(/margin-left:\s*(\d+)px/);
|
|
867
867
|
return r ? Math.round(parseInt(r[1], 10) / 27) : 0;
|
|
868
868
|
}
|
|
869
|
-
},
|
|
869
|
+
}, sn = (e, t) => {
|
|
870
870
|
if (!e) return null;
|
|
871
871
|
if (t === "checklist") {
|
|
872
872
|
let t = e.querySelector("[contenteditable]");
|
|
@@ -874,15 +874,15 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
874
874
|
}
|
|
875
875
|
let n = e.querySelector("[data-blok-testid=\"list-content-container\"]");
|
|
876
876
|
return n instanceof HTMLElement ? n : null;
|
|
877
|
-
},
|
|
877
|
+
}, cn = (e, t, n) => {
|
|
878
878
|
e && e.setAttribute("data-list-depth", String(n));
|
|
879
879
|
let r = e == null ? void 0 : e.querySelector("[role=\"listitem\"]");
|
|
880
880
|
r instanceof HTMLElement && (r.style.marginLeft = n > 0 ? `${n * 27}px` : ""), t.depth = n;
|
|
881
|
-
},
|
|
881
|
+
}, ln = (e, t) => t.getBlockDepth(e), un = (e, t) => t.getBlockStyle(e), dn = (e, t) => t.getBulletCharacter(e), fn = (e, t, n, r, i) => {
|
|
882
882
|
var a;
|
|
883
883
|
let o = e ? (a = r.getBlockIndex(e)) == null ? r.getCurrentBlockIndex() : a : r.getCurrentBlockIndex();
|
|
884
884
|
return o <= 0 ? 0 : i.getSiblingIndex(o, t, n);
|
|
885
|
-
},
|
|
885
|
+
}, pn = (e, t, n, r, i, a) => {
|
|
886
886
|
var o;
|
|
887
887
|
if (e === 0) {
|
|
888
888
|
var s;
|
|
@@ -890,10 +890,10 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
890
890
|
}
|
|
891
891
|
let c = n ? (o = i.getBlockIndex(n)) == null ? i.getCurrentBlockIndex() : o : i.getCurrentBlockIndex(), l = a.findFirstItemIndex(c - 1, t, e, r.style);
|
|
892
892
|
return l === null ? 1 : a.getBlockStartValue(l);
|
|
893
|
-
},
|
|
894
|
-
let o =
|
|
893
|
+
}, mn = (e, t, n, r, i, a) => {
|
|
894
|
+
let o = pn(e, t, r, n, i, a) + e;
|
|
895
895
|
return a.formatNumber(o, t);
|
|
896
|
-
},
|
|
896
|
+
}, hn = (e, t, n, r) => r.findGroupStart(e, t, n), gn = (e, t, n, r) => {
|
|
897
897
|
if (!e) return;
|
|
898
898
|
let i = e.holder, a = i == null ? void 0 : i.querySelector("[data-list-style=\"ordered\"]");
|
|
899
899
|
if (!a) return;
|
|
@@ -901,9 +901,9 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
901
901
|
if (!o) return;
|
|
902
902
|
let s = t.getBlockIndex(e.id);
|
|
903
903
|
if (s == null) return;
|
|
904
|
-
let c =
|
|
904
|
+
let c = ln(e, n), l = un(e, r) || "ordered", u = r.getSiblingIndex(s, c, l), d = r.getGroupStartValue(s, c, u, l) + u;
|
|
905
905
|
o.textContent = r.formatNumber(d, c);
|
|
906
|
-
},
|
|
906
|
+
}, _n = (e, t, n, r, i, a, o, s) => {
|
|
907
907
|
let c = (e) => {
|
|
908
908
|
if (e >= t) return;
|
|
909
909
|
if (e === n) {
|
|
@@ -912,25 +912,25 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
912
912
|
}
|
|
913
913
|
let l = a.getBlockByIndex(e);
|
|
914
914
|
if (!l || l.name !== "list") return;
|
|
915
|
-
let u =
|
|
915
|
+
let u = ln(l, o);
|
|
916
916
|
if (!(u < r)) {
|
|
917
917
|
if (u > r) {
|
|
918
918
|
c(e + 1);
|
|
919
919
|
return;
|
|
920
920
|
}
|
|
921
|
-
|
|
921
|
+
un(l, s) === i && (gn(l, a, o, s), c(e + 1));
|
|
922
922
|
}
|
|
923
923
|
};
|
|
924
924
|
c(e);
|
|
925
|
-
},
|
|
925
|
+
}, vn = (e, t, n) => {
|
|
926
926
|
let r = e.getBlocksCount();
|
|
927
927
|
Array.from({ length: r }, (e, t) => t).forEach((r) => {
|
|
928
928
|
let i = e.getBlockByIndex(r);
|
|
929
929
|
if (!i || i.name !== "list") return;
|
|
930
930
|
let a = i.holder;
|
|
931
|
-
a != null && a.querySelector("[data-list-style=\"ordered\"]") &&
|
|
931
|
+
a != null && a.querySelector("[data-list-style=\"ordered\"]") && gn(i, e, t, n);
|
|
932
932
|
});
|
|
933
|
-
},
|
|
933
|
+
}, T = (e, t, n = "end") => {
|
|
934
934
|
let r = () => {
|
|
935
935
|
let r = t.holder;
|
|
936
936
|
if (!r) return;
|
|
@@ -946,7 +946,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
946
946
|
n === "start" ? (o.setStart(i, 0), o.collapse(!0)) : (o.selectNodeContents(i), o.collapse(!1)), a.removeAllRanges(), a.addRange(o), e.caret.updateLastCaretAfterPosition();
|
|
947
947
|
}, i = t.holder;
|
|
948
948
|
(i == null ? void 0 : i.querySelector("[contenteditable=\"true\"]")) instanceof HTMLElement ? r() : requestAnimationFrame(() => r());
|
|
949
|
-
},
|
|
949
|
+
}, yn = async (e) => {
|
|
950
950
|
var t;
|
|
951
951
|
let { api: n, blockId: r, data: i, element: a, getContentElement: o } = e, s = window.getSelection();
|
|
952
952
|
if (!s || !a) return;
|
|
@@ -954,49 +954,49 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
954
954
|
if (!c) return;
|
|
955
955
|
let l = c.innerHTML.trim();
|
|
956
956
|
if (l === "" || l === "<br>") {
|
|
957
|
-
await
|
|
957
|
+
await bn(e);
|
|
958
958
|
return;
|
|
959
959
|
}
|
|
960
|
-
let { beforeContent: u, afterContent: d } =
|
|
960
|
+
let { beforeContent: u, afterContent: d } = qt(c, s.getRangeAt(0)), f = r ? (t = n.blocks.getBlockIndex(r)) == null ? n.blocks.getCurrentBlockIndex() : t : n.blocks.getCurrentBlockIndex();
|
|
961
961
|
if (!r) {
|
|
962
|
-
c.innerHTML = u, i.text = u,
|
|
962
|
+
c.innerHTML = u, i.text = u, T(n, n.blocks.insert(At, x(x({
|
|
963
963
|
text: d,
|
|
964
964
|
style: i.style
|
|
965
965
|
}, i.style === "checklist" ? { checked: !!i.checked } : {}), {}, { depth: i.depth }), void 0, f + 1, !0), "start");
|
|
966
966
|
return;
|
|
967
967
|
}
|
|
968
|
-
let p = n.blocks.splitBlock(r, { text: u },
|
|
968
|
+
let p = n.blocks.splitBlock(r, { text: u }, At, x(x({
|
|
969
969
|
text: d,
|
|
970
970
|
style: i.style
|
|
971
971
|
}, i.style === "checklist" ? { checked: !!i.checked } : {}), {}, { depth: i.depth }), f + 1);
|
|
972
|
-
i.text = u,
|
|
973
|
-
},
|
|
972
|
+
i.text = u, T(n, p, "start");
|
|
973
|
+
}, bn = async (e) => {
|
|
974
974
|
let { api: t, blockId: n, getDepth: r } = e;
|
|
975
975
|
if (r() > 0) {
|
|
976
|
-
await
|
|
976
|
+
await Cn(e);
|
|
977
977
|
return;
|
|
978
978
|
}
|
|
979
|
-
n !== void 0 &&
|
|
980
|
-
},
|
|
979
|
+
n !== void 0 && T(t, await t.blocks.convert(n, "paragraph", { text: "" }), "start");
|
|
980
|
+
}, xn = async (e, t) => {
|
|
981
981
|
let { api: n, blockId: r, data: i, element: a, getContentElement: o, getDepth: s, syncContentFromDOM: c } = e, l = window.getSelection();
|
|
982
982
|
if (!l || !a) return;
|
|
983
983
|
let u = l.getRangeAt(0), d = o();
|
|
984
984
|
if (!d) return;
|
|
985
985
|
c();
|
|
986
986
|
let f = i.text, p = s();
|
|
987
|
-
if (
|
|
987
|
+
if (Zt(d, u) && !l.isCollapsed) {
|
|
988
988
|
t.preventDefault(), d.innerHTML = "", i.text = "";
|
|
989
989
|
let e = document.createRange();
|
|
990
990
|
e.setStart(d, 0), e.collapse(!0), l.removeAllRanges(), l.addRange(e);
|
|
991
991
|
return;
|
|
992
992
|
}
|
|
993
|
-
if (!
|
|
993
|
+
if (!Xt(d, u) || (t.preventDefault(), r === void 0)) return;
|
|
994
994
|
let m = await n.blocks.convert(r, "paragraph", { text: f });
|
|
995
995
|
p > 0 && requestAnimationFrame(() => {
|
|
996
996
|
let e = m.holder;
|
|
997
997
|
e && (e.style.marginLeft = `${p * 27}px`, e.setAttribute("data-blok-depth", String(p)));
|
|
998
|
-
}),
|
|
999
|
-
},
|
|
998
|
+
}), T(n, m, "start");
|
|
999
|
+
}, Sn = async (e, t) => {
|
|
1000
1000
|
let { api: n, blockId: r, data: i, syncContentFromDOM: a, getDepth: o } = e, s = n.blocks.getCurrentBlockIndex();
|
|
1001
1001
|
if (s === 0) return;
|
|
1002
1002
|
let c = n.blocks.getBlockByIndex(s - 1);
|
|
@@ -1005,15 +1005,15 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1005
1005
|
if (l > t.getBlockDepth(c)) return;
|
|
1006
1006
|
a();
|
|
1007
1007
|
let u = l + 1;
|
|
1008
|
-
i.depth = u,
|
|
1009
|
-
},
|
|
1008
|
+
i.depth = u, T(n, await n.blocks.update(r || "", x(x({}, i), {}, { depth: u })));
|
|
1009
|
+
}, Cn = async (e) => {
|
|
1010
1010
|
let { api: t, blockId: n, data: r, syncContentFromDOM: i, getDepth: a } = e, o = a();
|
|
1011
1011
|
if (o === 0) return;
|
|
1012
1012
|
i();
|
|
1013
1013
|
let s = o - 1;
|
|
1014
|
-
r.depth = s,
|
|
1015
|
-
},
|
|
1016
|
-
let { data: t, readOnly: n, placeholder: r, itemColor: i, itemSize: a, setupItemPlaceholder: o, onCheckboxChange: s, keydownHandler: c } = e, l =
|
|
1014
|
+
r.depth = s, T(t, await t.blocks.update(n || "", x(x({}, r), {}, { depth: s })));
|
|
1015
|
+
}, wn = (e) => {
|
|
1016
|
+
let { data: t, readOnly: n, placeholder: r, itemColor: i, itemSize: a, setupItemPlaceholder: o, onCheckboxChange: s, keydownHandler: c } = e, l = Nt({
|
|
1017
1017
|
data: t,
|
|
1018
1018
|
readOnly: n,
|
|
1019
1019
|
placeholder: r,
|
|
@@ -1028,14 +1028,14 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1028
1028
|
});
|
|
1029
1029
|
}
|
|
1030
1030
|
return l.wrapper;
|
|
1031
|
-
},
|
|
1031
|
+
}, Tn = (e) => {
|
|
1032
1032
|
let t = (e) => {
|
|
1033
1033
|
if (e <= 0) return "";
|
|
1034
1034
|
let n = e - 1;
|
|
1035
1035
|
return t(Math.floor(n / 26)) + String.fromCharCode(97 + n % 26);
|
|
1036
1036
|
};
|
|
1037
1037
|
return t(e);
|
|
1038
|
-
},
|
|
1038
|
+
}, En = (e) => {
|
|
1039
1039
|
let t = [
|
|
1040
1040
|
[1e3, "m"],
|
|
1041
1041
|
[900, "cm"],
|
|
@@ -1056,7 +1056,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1056
1056
|
return e >= i ? a + n(e - i, r) : n(e, r + 1);
|
|
1057
1057
|
};
|
|
1058
1058
|
return n(e, 0);
|
|
1059
|
-
},
|
|
1059
|
+
}, Dn = class {
|
|
1060
1060
|
constructor(e) {
|
|
1061
1061
|
this.blocks = e;
|
|
1062
1062
|
}
|
|
@@ -1082,7 +1082,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1082
1082
|
}
|
|
1083
1083
|
formatNumber(e, t) {
|
|
1084
1084
|
let n = t % 3;
|
|
1085
|
-
return n === 1 ? `${
|
|
1085
|
+
return n === 1 ? `${Tn(e)}.` : n === 2 ? `${En(e)}.` : `${e}.`;
|
|
1086
1086
|
}
|
|
1087
1087
|
getGroupStartValue(e, t, n, r) {
|
|
1088
1088
|
if (n === 0) return this.getBlockStartValue(e);
|
|
@@ -1137,9 +1137,9 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1137
1137
|
let a = this.getBlockDepth(i);
|
|
1138
1138
|
return a < n ? t : a > n ? this.findGroupStartRecursive(e - 1, t, n, r) : this.getBlockStyle(i) === r ? this.findGroupStartRecursive(e - 1, e, n, r) : t;
|
|
1139
1139
|
}
|
|
1140
|
-
},
|
|
1140
|
+
}, On = { value: !1 }, kn = class {
|
|
1141
1141
|
constructor(e) {
|
|
1142
|
-
this.blocks = e, this.depthValidator = new
|
|
1142
|
+
this.blocks = e, this.depthValidator = new on(e), this.markerCalculator = new Dn(e);
|
|
1143
1143
|
}
|
|
1144
1144
|
updateMarker(e, t, n) {
|
|
1145
1145
|
let r = e.querySelector("[data-list-marker]");
|
|
@@ -1166,8 +1166,8 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1166
1166
|
}
|
|
1167
1167
|
}
|
|
1168
1168
|
scheduleUpdateAll() {
|
|
1169
|
-
|
|
1170
|
-
|
|
1169
|
+
On.value || (On.value = !0, requestAnimationFrame(() => {
|
|
1170
|
+
On.value = !1, this.updateAllMarkers();
|
|
1171
1171
|
}));
|
|
1172
1172
|
}
|
|
1173
1173
|
findListGroupStartIndex(e, t, n) {
|
|
@@ -1206,12 +1206,12 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1206
1206
|
})() : c) + s;
|
|
1207
1207
|
r.textContent = this.markerCalculator.formatNumber(l, a);
|
|
1208
1208
|
}
|
|
1209
|
-
},
|
|
1209
|
+
}, An = (e) => e instanceof HTMLElement, jn = new Set(/* @__PURE__ */ "decimal.decimal-leading-zero.lower-roman.upper-roman.lower-greek.lower-latin.upper-latin.lower-alpha.upper-alpha.arabic-indic.armenian.bengali.cambodian.cjk-decimal.devanagari.georgian.gujarati.gurmukhi.hebrew.kannada.khmer.lao.malayalam.mongolian.myanmar.oriya.persian.telugu.thai.tibetan".split(".")), Mn = new Set([
|
|
1210
1210
|
"disc",
|
|
1211
1211
|
"circle",
|
|
1212
1212
|
"square",
|
|
1213
1213
|
"none"
|
|
1214
|
-
]),
|
|
1214
|
+
]), Nn = (e) => {
|
|
1215
1215
|
let t = e.getAttribute("data-list-style");
|
|
1216
1216
|
if (t === "ordered") return "ordered";
|
|
1217
1217
|
if (t === "unordered") return "unordered";
|
|
@@ -1220,24 +1220,24 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1220
1220
|
let r = n.match(/list-style-type\s*:\s*([^;]+)/);
|
|
1221
1221
|
if (!r) return null;
|
|
1222
1222
|
let i = r[1].trim().toLowerCase();
|
|
1223
|
-
return
|
|
1224
|
-
},
|
|
1223
|
+
return jn.has(i) ? "ordered" : Mn.has(i) ? "unordered" : null;
|
|
1224
|
+
}, Pn = (e, t) => {
|
|
1225
1225
|
let n = e.parentElement;
|
|
1226
|
-
return (n == null ? void 0 : n.tagName) === "OL" ? "ordered" : (n == null ? void 0 : n.tagName) === "UL" ? e.querySelector("input[type=\"checkbox\"]") ? "checklist" : "unordered" :
|
|
1227
|
-
},
|
|
1226
|
+
return (n == null ? void 0 : n.tagName) === "OL" ? "ordered" : (n == null ? void 0 : n.tagName) === "UL" ? e.querySelector("input[type=\"checkbox\"]") ? "checklist" : "unordered" : Nn(e) || t;
|
|
1227
|
+
}, Fn = (e) => {
|
|
1228
1228
|
let t = e.innerHTML || e.textContent || "", n = e.querySelector("input[type=\"checkbox\"]");
|
|
1229
1229
|
return {
|
|
1230
1230
|
text: t,
|
|
1231
1231
|
checked: n instanceof HTMLInputElement ? n.checked : !1
|
|
1232
1232
|
};
|
|
1233
|
-
},
|
|
1233
|
+
}, In = (e) => {
|
|
1234
1234
|
let t = e.getAttribute("aria-level");
|
|
1235
1235
|
if (t) {
|
|
1236
1236
|
let e = parseInt(t, 10);
|
|
1237
1237
|
return Math.max(0, e - 1);
|
|
1238
1238
|
}
|
|
1239
1239
|
return 0;
|
|
1240
|
-
},
|
|
1240
|
+
}, Ln = () => ({ text: {
|
|
1241
1241
|
br: !0,
|
|
1242
1242
|
a: {
|
|
1243
1243
|
href: !0,
|
|
@@ -1246,38 +1246,38 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1246
1246
|
},
|
|
1247
1247
|
b: !0,
|
|
1248
1248
|
i: !0
|
|
1249
|
-
} }),
|
|
1249
|
+
} }), Rn = () => ({ tags: [{ li: {
|
|
1250
1250
|
style: !0,
|
|
1251
1251
|
"aria-level": !0
|
|
1252
|
-
} }] }),
|
|
1252
|
+
} }] }), zn = () => ({
|
|
1253
1253
|
export: (e) => e.text,
|
|
1254
1254
|
import: (e) => ({
|
|
1255
1255
|
text: e,
|
|
1256
1256
|
style: "unordered",
|
|
1257
1257
|
checked: !1
|
|
1258
1258
|
})
|
|
1259
|
-
}),
|
|
1259
|
+
}), Bn = [
|
|
1260
1260
|
{
|
|
1261
1261
|
name: "bulletedList",
|
|
1262
1262
|
titleKey: "bulletedList",
|
|
1263
1263
|
style: "unordered",
|
|
1264
|
-
icon:
|
|
1264
|
+
icon: He
|
|
1265
1265
|
},
|
|
1266
1266
|
{
|
|
1267
1267
|
name: "numberedList",
|
|
1268
1268
|
titleKey: "numberedList",
|
|
1269
1269
|
style: "ordered",
|
|
1270
|
-
icon:
|
|
1270
|
+
icon: de
|
|
1271
1271
|
},
|
|
1272
1272
|
{
|
|
1273
1273
|
name: "todoList",
|
|
1274
1274
|
titleKey: "todoList",
|
|
1275
1275
|
style: "checklist",
|
|
1276
|
-
icon:
|
|
1276
|
+
icon: m
|
|
1277
1277
|
}
|
|
1278
|
-
],
|
|
1278
|
+
], Vn = () => [
|
|
1279
1279
|
{
|
|
1280
|
-
icon:
|
|
1280
|
+
icon: He,
|
|
1281
1281
|
title: "Bulleted list",
|
|
1282
1282
|
titleKey: "bulletedList",
|
|
1283
1283
|
data: { style: "unordered" },
|
|
@@ -1291,7 +1291,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1291
1291
|
shortcut: "-"
|
|
1292
1292
|
},
|
|
1293
1293
|
{
|
|
1294
|
-
icon:
|
|
1294
|
+
icon: de,
|
|
1295
1295
|
title: "Numbered list",
|
|
1296
1296
|
titleKey: "numberedList",
|
|
1297
1297
|
data: { style: "ordered" },
|
|
@@ -1305,7 +1305,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1305
1305
|
shortcut: "1."
|
|
1306
1306
|
},
|
|
1307
1307
|
{
|
|
1308
|
-
icon:
|
|
1308
|
+
icon: m,
|
|
1309
1309
|
title: "To-do list",
|
|
1310
1310
|
titleKey: "todoList",
|
|
1311
1311
|
data: { style: "checklist" },
|
|
@@ -1319,24 +1319,24 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1319
1319
|
],
|
|
1320
1320
|
shortcut: "[]"
|
|
1321
1321
|
}
|
|
1322
|
-
],
|
|
1322
|
+
], Hn = class {
|
|
1323
1323
|
constructor({ data: e, config: t, api: n, readOnly: r, block: i }) {
|
|
1324
1324
|
this._element = null, this.handleBlockChanged = (e) => {
|
|
1325
1325
|
if (this.isBlockChangedEventPayload(e) && (e.event.type === "block-removed" || e.event.type === "block-added")) {
|
|
1326
1326
|
var t;
|
|
1327
1327
|
(t = this.markerManager) == null || t.scheduleUpdateAll();
|
|
1328
1328
|
}
|
|
1329
|
-
}, this.api = n, this.readOnly = r, this._settings = t || {}, this._data = this.normalizeData(e), this.depthValidator = new
|
|
1329
|
+
}, this.api = n, this.readOnly = r, this._settings = t || {}, this._data = this.normalizeData(e), this.depthValidator = new on(n.blocks), this.markerCalculator = new Dn(n.blocks), this.markerManager = this._data.style === "ordered" ? new kn(n.blocks) : null, i && (this.blockId = i.id), this._data.style === "ordered" && this.api.events.on("block changed", this.handleBlockChanged);
|
|
1330
1330
|
}
|
|
1331
1331
|
isBlockChangedEventPayload(e) {
|
|
1332
1332
|
return typeof e == "object" && !!e && "event" in e && typeof e.event == "object" && e.event !== null && "type" in e.event && typeof e.event.type == "string";
|
|
1333
1333
|
}
|
|
1334
1334
|
normalizeData(e) {
|
|
1335
|
-
return
|
|
1335
|
+
return an(e, this._settings);
|
|
1336
1336
|
}
|
|
1337
1337
|
get availableStyles() {
|
|
1338
1338
|
let e = this._settings.styles;
|
|
1339
|
-
return !e || e.length === 0 ?
|
|
1339
|
+
return !e || e.length === 0 ? Bn : Bn.filter((t) => e.includes(t.style));
|
|
1340
1340
|
}
|
|
1341
1341
|
get itemColor() {
|
|
1342
1342
|
return this._settings.itemColor;
|
|
@@ -1345,13 +1345,13 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1345
1345
|
return this._settings.itemSize;
|
|
1346
1346
|
}
|
|
1347
1347
|
get placeholder() {
|
|
1348
|
-
return this.api.i18n.t(
|
|
1348
|
+
return this.api.i18n.t(kt);
|
|
1349
1349
|
}
|
|
1350
1350
|
setupItemPlaceholder(e) {
|
|
1351
|
-
this.readOnly ||
|
|
1351
|
+
this.readOnly || st(e, this.placeholder);
|
|
1352
1352
|
}
|
|
1353
1353
|
render() {
|
|
1354
|
-
return this._element =
|
|
1354
|
+
return this._element = wn({
|
|
1355
1355
|
data: this._data,
|
|
1356
1356
|
readOnly: this.readOnly,
|
|
1357
1357
|
placeholder: this.placeholder,
|
|
@@ -1382,31 +1382,31 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1382
1382
|
n !== r && this.adjustDepthTo(r);
|
|
1383
1383
|
}
|
|
1384
1384
|
adjustDepthTo(e) {
|
|
1385
|
-
|
|
1385
|
+
cn(this._element, this._data, e);
|
|
1386
1386
|
}
|
|
1387
1387
|
removed() {
|
|
1388
1388
|
var e;
|
|
1389
1389
|
this._data.style === "ordered" && (this.api.events.off("block changed", this.handleBlockChanged), (e = this.markerManager) == null || e.scheduleUpdateAll());
|
|
1390
1390
|
}
|
|
1391
1391
|
updateAllOrderedListMarkers() {
|
|
1392
|
-
|
|
1392
|
+
vn(this.api.blocks, this.depthValidator, this.markerCalculator);
|
|
1393
1393
|
}
|
|
1394
1394
|
updateMarker() {
|
|
1395
1395
|
var e;
|
|
1396
1396
|
let t = (e = this._element) == null ? void 0 : e.querySelector("[data-list-marker]");
|
|
1397
1397
|
if (!t) return;
|
|
1398
1398
|
let n = this.getDepth();
|
|
1399
|
-
t.textContent =
|
|
1399
|
+
t.textContent = mn(fn(this.blockId, n, this._data.style, this.api.blocks, this.markerCalculator), n, this._data, this.blockId, this.api.blocks, this.markerCalculator);
|
|
1400
1400
|
}
|
|
1401
1401
|
updateSiblingListMarkers() {
|
|
1402
1402
|
var e;
|
|
1403
1403
|
let t = this.blockId ? (e = this.api.blocks.getBlockIndex(this.blockId)) == null ? this.api.blocks.getCurrentBlockIndex() : e : this.api.blocks.getCurrentBlockIndex(), n = this.getDepth(), r = this._data.style, i = this.api.blocks.getBlocksCount();
|
|
1404
|
-
|
|
1404
|
+
_n(hn(t, n, r, this.markerCalculator), i, t, n, r, this.api.blocks, this.depthValidator, this.markerCalculator);
|
|
1405
1405
|
}
|
|
1406
1406
|
updateMarkerForDepth(e, t) {
|
|
1407
1407
|
var n;
|
|
1408
1408
|
let r = (n = this._element) == null ? void 0 : n.querySelector("[aria-hidden=\"true\"]");
|
|
1409
|
-
r instanceof HTMLElement && (t === "ordered" ? r.textContent =
|
|
1409
|
+
r instanceof HTMLElement && (t === "ordered" ? r.textContent = mn(fn(this.blockId, e, this._data.style, this.api.blocks, this.markerCalculator), e, this._data, this.blockId, this.api.blocks, this.markerCalculator) : r.textContent = dn(e, this.markerCalculator));
|
|
1410
1410
|
}
|
|
1411
1411
|
updateCheckboxState(e) {
|
|
1412
1412
|
var t;
|
|
@@ -1436,7 +1436,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1436
1436
|
}
|
|
1437
1437
|
async handleEnter() {
|
|
1438
1438
|
var e = this;
|
|
1439
|
-
await
|
|
1439
|
+
await yn({
|
|
1440
1440
|
api: e.api,
|
|
1441
1441
|
blockId: e.blockId,
|
|
1442
1442
|
data: e._data,
|
|
@@ -1448,7 +1448,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1448
1448
|
}
|
|
1449
1449
|
async handleBackspace(e) {
|
|
1450
1450
|
var t = this;
|
|
1451
|
-
await
|
|
1451
|
+
await xn({
|
|
1452
1452
|
api: t.api,
|
|
1453
1453
|
blockId: t.blockId,
|
|
1454
1454
|
data: t._data,
|
|
@@ -1460,7 +1460,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1460
1460
|
}
|
|
1461
1461
|
async handleIndent() {
|
|
1462
1462
|
var e = this;
|
|
1463
|
-
await
|
|
1463
|
+
await Sn({
|
|
1464
1464
|
api: e.api,
|
|
1465
1465
|
blockId: e.blockId,
|
|
1466
1466
|
data: e._data,
|
|
@@ -1472,7 +1472,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1472
1472
|
}
|
|
1473
1473
|
async handleOutdent() {
|
|
1474
1474
|
var e = this;
|
|
1475
|
-
await
|
|
1475
|
+
await Cn({
|
|
1476
1476
|
api: e.api,
|
|
1477
1477
|
blockId: e.blockId,
|
|
1478
1478
|
data: e._data,
|
|
@@ -1490,10 +1490,10 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1490
1490
|
n instanceof HTMLInputElement && (this._data.checked = n.checked);
|
|
1491
1491
|
}
|
|
1492
1492
|
getContentElement() {
|
|
1493
|
-
return
|
|
1493
|
+
return sn(this._element, this._data.style);
|
|
1494
1494
|
}
|
|
1495
1495
|
renderSettings() {
|
|
1496
|
-
return
|
|
1496
|
+
return Ut(this.availableStyles, this._data.style, this.api.i18n.t, (e) => this.setStyle(e));
|
|
1497
1497
|
}
|
|
1498
1498
|
setStyle(e) {
|
|
1499
1499
|
let t = this._data.style;
|
|
@@ -1503,7 +1503,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1503
1503
|
}
|
|
1504
1504
|
}
|
|
1505
1505
|
rerender() {
|
|
1506
|
-
let e =
|
|
1506
|
+
let e = zt({
|
|
1507
1507
|
data: this._data,
|
|
1508
1508
|
readOnly: this.readOnly,
|
|
1509
1509
|
placeholder: this.placeholder,
|
|
@@ -1522,10 +1522,10 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1522
1522
|
return typeof e.text == "string";
|
|
1523
1523
|
}
|
|
1524
1524
|
save() {
|
|
1525
|
-
return
|
|
1525
|
+
return Bt(this._data, this._element, this.getContentElement.bind(this));
|
|
1526
1526
|
}
|
|
1527
1527
|
setData(e) {
|
|
1528
|
-
let t =
|
|
1528
|
+
let t = Vt(this._data, e, this._element, this.getContentElement.bind(this), {
|
|
1529
1529
|
adjustDepthTo: this.adjustDepthTo.bind(this),
|
|
1530
1530
|
updateMarkerForDepth: this.updateMarkerForDepth.bind(this),
|
|
1531
1531
|
updateCheckboxState: this.updateCheckboxState.bind(this)
|
|
@@ -1533,31 +1533,31 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1533
1533
|
return this._data = t.newData, t.inPlace;
|
|
1534
1534
|
}
|
|
1535
1535
|
merge(e) {
|
|
1536
|
-
|
|
1536
|
+
Ht({
|
|
1537
1537
|
data: this._data,
|
|
1538
1538
|
element: this._element,
|
|
1539
1539
|
getContentElement: this.getContentElement.bind(this),
|
|
1540
|
-
parseHTML:
|
|
1540
|
+
parseHTML: Yt
|
|
1541
1541
|
}, e);
|
|
1542
1542
|
}
|
|
1543
1543
|
static get conversionConfig() {
|
|
1544
|
-
return
|
|
1544
|
+
return zn();
|
|
1545
1545
|
}
|
|
1546
1546
|
static get sanitize() {
|
|
1547
|
-
return
|
|
1547
|
+
return Ln();
|
|
1548
1548
|
}
|
|
1549
1549
|
static get pasteConfig() {
|
|
1550
|
-
return
|
|
1550
|
+
return Rn();
|
|
1551
1551
|
}
|
|
1552
1552
|
onPaste(e) {
|
|
1553
1553
|
let t = e.detail;
|
|
1554
1554
|
if (!("data" in t)) return;
|
|
1555
1555
|
let n = t.data;
|
|
1556
|
-
if (!
|
|
1557
|
-
let { text: r, checked: i } =
|
|
1556
|
+
if (!An(n)) return;
|
|
1557
|
+
let { text: r, checked: i } = Fn(n), a = In(n);
|
|
1558
1558
|
this._data = {
|
|
1559
1559
|
text: r,
|
|
1560
|
-
style:
|
|
1560
|
+
style: Pn(n, this._data.style),
|
|
1561
1561
|
checked: i,
|
|
1562
1562
|
depth: a
|
|
1563
1563
|
}, this.rerender();
|
|
@@ -1566,18 +1566,18 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1566
1566
|
return !0;
|
|
1567
1567
|
}
|
|
1568
1568
|
getContentOffset(e) {
|
|
1569
|
-
return
|
|
1569
|
+
return Kt(e);
|
|
1570
1570
|
}
|
|
1571
1571
|
static get toolbox() {
|
|
1572
|
-
return
|
|
1572
|
+
return Vn();
|
|
1573
1573
|
}
|
|
1574
|
-
},
|
|
1574
|
+
}, Un = "data-blok-table-add-row", Wn = "data-blok-table-add-col", Gn = 150, Kn = 5, qn = 40, Jn = [
|
|
1575
1575
|
"flex",
|
|
1576
1576
|
"items-center",
|
|
1577
1577
|
"justify-center",
|
|
1578
1578
|
"transition-opacity",
|
|
1579
1579
|
"duration-150"
|
|
1580
|
-
],
|
|
1580
|
+
], Yn = [
|
|
1581
1581
|
"flex",
|
|
1582
1582
|
"items-center",
|
|
1583
1583
|
"justify-center",
|
|
@@ -1585,7 +1585,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1585
1585
|
"border-gray-300",
|
|
1586
1586
|
"rounded-full",
|
|
1587
1587
|
"group-hover/add:bg-gray-50"
|
|
1588
|
-
],
|
|
1588
|
+
], Xn = "12", Zn = class {
|
|
1589
1589
|
constructor(e) {
|
|
1590
1590
|
this.rowHideTimeout = null, this.colHideTimeout = null, this.rowVisible = !1, this.colVisible = !1, this.interactive = !0, this.dragState = null, this.scrollContainer = null, this.boundScrollHandler = null, this.scrollContainerResizeObserver = null, this.wrapper = e.wrapper, this.grid = e.grid, this.i18n = e.i18n, this.boundAddRowClick = e.onAddRow, this.boundAddColClick = e.onAddColumn, this.onDragStart = e.onDragStart, this.onDragAddRow = e.onDragAddRow, this.onDragRemoveRow = e.onDragRemoveRow, this.onDragAddCol = e.onDragAddCol, this.onDragRemoveCol = e.onDragRemoveCol, this.onDragEnd = e.onDragEnd, this.getNewColumnWidth = e.getNewColumnWidth, this.boundMouseMove = this.handleMouseMove.bind(this), this.boundDocumentMouseMove = this.handleDocumentMouseMove.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), document.addEventListener("mousemove", this.boundDocumentMouseMove), this.addRowBtn.addEventListener("pointerdown", this.boundRowPointerDown), this.addColBtn.addEventListener("pointerdown", this.boundColPointerDown);
|
|
1591
1591
|
}
|
|
@@ -1658,10 +1658,10 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1658
1658
|
}
|
|
1659
1659
|
handlePointerMove(e) {
|
|
1660
1660
|
if (!this.dragState) return;
|
|
1661
|
-
let { axis: t, startPos:
|
|
1662
|
-
for (; this.dragState.addedCount <
|
|
1663
|
-
for (; this.dragState.addedCount >
|
|
1664
|
-
Math.abs(
|
|
1661
|
+
let { axis: t, startPos: r, unitSize: i } = this.dragState, a = (t === "row" ? e.clientY : e.clientX) - r, o = Math.floor(a / i);
|
|
1662
|
+
for (; this.dragState.addedCount < o;) t === "row" ? this.onDragAddRow() : this.onDragAddCol(), this.dragState.addedCount++;
|
|
1663
|
+
for (; this.dragState.addedCount > o;) t === "row" ? this.onDragRemoveRow() : this.onDragRemoveCol(), this.dragState.addedCount--;
|
|
1664
|
+
Math.abs(a) > Kn && !this.dragState.didDrag && (this.dragState.didDrag = !0, document.body.style.cursor = t === "row" ? "row-resize" : "col-resize", n(), this.onDragStart());
|
|
1665
1665
|
}
|
|
1666
1666
|
handlePointerUp(e) {
|
|
1667
1667
|
if (!this.dragState) return;
|
|
@@ -1690,14 +1690,14 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1690
1690
|
}
|
|
1691
1691
|
handleMouseMove(e) {
|
|
1692
1692
|
let t = this.grid.getBoundingClientRect(), n = this.grid.parentElement, r = n !== null && n !== this.wrapper ? Math.min(t.right, n.getBoundingClientRect().right) : t.right, i = Math.abs(e.clientY - t.bottom), a = Math.abs(e.clientX - r);
|
|
1693
|
-
i <=
|
|
1693
|
+
i <= qn ? this.showRow() : this.scheduleHideRow(), a <= qn ? this.showCol() : this.scheduleHideCol();
|
|
1694
1694
|
}
|
|
1695
1695
|
handleMouseLeave() {
|
|
1696
1696
|
this.scheduleHideRow(), this.scheduleHideCol();
|
|
1697
1697
|
}
|
|
1698
1698
|
handleDocumentMouseMove(e) {
|
|
1699
1699
|
if (this.wrapper.contains(e.target)) return;
|
|
1700
|
-
let t = this.grid.getBoundingClientRect(), n =
|
|
1700
|
+
let t = this.grid.getBoundingClientRect(), n = qn;
|
|
1701
1701
|
e.clientX >= t.left - n && e.clientX <= t.right + n && e.clientY >= t.top - n && e.clientY <= t.bottom + n && this.handleMouseMove(e);
|
|
1702
1702
|
}
|
|
1703
1703
|
showRow() {
|
|
@@ -1710,13 +1710,13 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1710
1710
|
var e;
|
|
1711
1711
|
!this.rowVisible || this.rowHideTimeout !== null || ((e = this.dragState) == null ? void 0 : e.axis) === "row" || (this.rowHideTimeout = setTimeout(() => {
|
|
1712
1712
|
this.addRowBtn.style.opacity = "0", this.addRowBtn.style.pointerEvents = "none", this.rowVisible = !1, this.rowHideTimeout = null;
|
|
1713
|
-
},
|
|
1713
|
+
}, Gn));
|
|
1714
1714
|
}
|
|
1715
1715
|
scheduleHideCol() {
|
|
1716
1716
|
var e;
|
|
1717
1717
|
!this.colVisible || this.colHideTimeout !== null || ((e = this.dragState) == null ? void 0 : e.axis) === "col" || (this.colHideTimeout = setTimeout(() => {
|
|
1718
1718
|
this.addColBtn.style.opacity = "0", this.addColBtn.style.pointerEvents = "none", this.colVisible = !1, this.colHideTimeout = null;
|
|
1719
|
-
},
|
|
1719
|
+
}, Gn));
|
|
1720
1720
|
}
|
|
1721
1721
|
clearRowTimeout() {
|
|
1722
1722
|
this.rowHideTimeout !== null && (clearTimeout(this.rowHideTimeout), this.rowHideTimeout = null);
|
|
@@ -1726,25 +1726,25 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1726
1726
|
}
|
|
1727
1727
|
createAddRowButton() {
|
|
1728
1728
|
let e = document.createElement("div");
|
|
1729
|
-
e.className =
|
|
1729
|
+
e.className = S(Jn, "group/add", "items-start", "cursor-row-resize"), e.setAttribute(Un, ""), e.setAttribute("contenteditable", "false"), e.style.opacity = "0", e.style.pointerEvents = "none", e.style.position = "absolute", e.style.left = "0", e.style.bottom = "-36px", e.style.zIndex = "1", e.style.height = "32px";
|
|
1730
1730
|
let t = document.createElement("div");
|
|
1731
|
-
return t.className =
|
|
1731
|
+
return t.className = S(Yn), t.style.width = "100%", t.style.height = "16px", this.appendIcon(t), e.appendChild(t), Ae(e, Te([this.i18n.t("tools.table.clickToAddRow"), this.i18n.t("tools.table.dragToAddRemoveRows")]), {
|
|
1732
1732
|
placement: "bottom",
|
|
1733
1733
|
marginTop: -16
|
|
1734
1734
|
}), e;
|
|
1735
1735
|
}
|
|
1736
1736
|
createAddColumnButton() {
|
|
1737
1737
|
let e = document.createElement("div");
|
|
1738
|
-
e.className =
|
|
1738
|
+
e.className = S(Jn, "group/add", "justify-start", "cursor-col-resize"), e.setAttribute(Wn, ""), e.setAttribute("contenteditable", "false"), e.style.opacity = "0", e.style.pointerEvents = "none", e.style.position = "absolute", e.style.right = "-36px", e.style.top = "0px", e.style.bottom = "0px", e.style.width = "32px";
|
|
1739
1739
|
let t = document.createElement("div");
|
|
1740
|
-
return t.className =
|
|
1740
|
+
return t.className = S(Yn), t.style.width = "16px", t.style.height = "100%", this.appendIcon(t), e.appendChild(t), Ae(e, Te([this.i18n.t("tools.table.clickToAddColumn"), this.i18n.t("tools.table.dragToAddRemoveColumns")]), { placement: "bottom" }), e;
|
|
1741
1741
|
}
|
|
1742
1742
|
appendIcon(t) {
|
|
1743
1743
|
t.insertAdjacentHTML("beforeend", e);
|
|
1744
1744
|
let n = t.querySelector("svg");
|
|
1745
|
-
n && (n.setAttribute("width",
|
|
1745
|
+
n && (n.setAttribute("width", Xn), n.setAttribute("height", Xn), n.setAttribute("viewBox", "0 0 24 24"), n.classList.add("text-gray-500", "pointer-events-none"));
|
|
1746
1746
|
}
|
|
1747
|
-
},
|
|
1747
|
+
}, E = "data-blok-table-row", D = "data-blok-table-cell", Qn = "1px solid var(--blok-table-border)", $n = ["flex"], er = [
|
|
1748
1748
|
"py-1",
|
|
1749
1749
|
"px-2",
|
|
1750
1750
|
"min-h-[2em]",
|
|
@@ -1752,37 +1752,37 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1752
1752
|
"leading-none",
|
|
1753
1753
|
"text-sm",
|
|
1754
1754
|
"cursor-text"
|
|
1755
|
-
],
|
|
1755
|
+
], tr = (e) => {
|
|
1756
1756
|
let t = Math.round(100 / e * 100) / 100;
|
|
1757
1757
|
return Array.from({ length: e }, () => t);
|
|
1758
|
-
},
|
|
1758
|
+
}, nr = class {
|
|
1759
1759
|
constructor(e) {
|
|
1760
1760
|
this.readOnly = e.readOnly;
|
|
1761
1761
|
}
|
|
1762
1762
|
createGrid(e, t, n) {
|
|
1763
1763
|
let r = document.createElement("div");
|
|
1764
|
-
r.style.borderTop =
|
|
1765
|
-
let i = n == null ?
|
|
1764
|
+
r.style.borderTop = Qn, r.style.borderLeft = Qn;
|
|
1765
|
+
let i = n == null ? tr(t) : n;
|
|
1766
1766
|
return Array.from({ length: e }).forEach(() => {
|
|
1767
1767
|
r.appendChild(this.createRow(t, i));
|
|
1768
1768
|
}), r;
|
|
1769
1769
|
}
|
|
1770
1770
|
fillGrid(e, t) {}
|
|
1771
1771
|
addRow(e, t) {
|
|
1772
|
-
let n = this.getColumnCount(e), r = this.getRawCellWidths(e), i = this.createRow(n, r), a = e.querySelectorAll(`[${
|
|
1772
|
+
let n = this.getColumnCount(e), r = this.getRawCellWidths(e), i = this.createRow(n, r), a = e.querySelectorAll(`[${E}]`);
|
|
1773
1773
|
return t !== void 0 && t < a.length ? e.insertBefore(i, a[t]) : e.appendChild(i), i;
|
|
1774
1774
|
}
|
|
1775
1775
|
deleteRow(e, t) {
|
|
1776
|
-
let n = e.querySelectorAll(`[${
|
|
1776
|
+
let n = e.querySelectorAll(`[${E}]`);
|
|
1777
1777
|
t < n.length && n[t].remove();
|
|
1778
1778
|
}
|
|
1779
1779
|
addColumn(e, t, n, r) {
|
|
1780
|
-
let i = e.querySelectorAll(`[${
|
|
1780
|
+
let i = e.querySelectorAll(`[${E}]`), a = this.getColumnCount(e), o = n !== void 0 && n.length === a, s = o || this.detectWidthUnit(e) === "px";
|
|
1781
1781
|
return o && this.convertToPixelWidths(i, n), s ? (this.addColumnPx(i, a, t, r), !0) : (this.addColumnPercent(i, a, t), !0);
|
|
1782
1782
|
}
|
|
1783
1783
|
convertToPixelWidths(e, t) {
|
|
1784
1784
|
e.forEach((e) => {
|
|
1785
|
-
e.querySelectorAll(`[${
|
|
1785
|
+
e.querySelectorAll(`[${D}]`).forEach((e, n) => {
|
|
1786
1786
|
if (n < t.length) {
|
|
1787
1787
|
let r = e;
|
|
1788
1788
|
r.style.width = `${t[n]}px`;
|
|
@@ -1793,7 +1793,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1793
1793
|
addColumnPx(e, t, n, r) {
|
|
1794
1794
|
let i = r == null ? this.computeHalfAvgPxWidth(e, t) : r;
|
|
1795
1795
|
e.forEach((e) => {
|
|
1796
|
-
let t = e.querySelectorAll(`[${
|
|
1796
|
+
let t = e.querySelectorAll(`[${D}]`), r = n === void 0 || n >= t.length, a = this.createCell(`${i}px`);
|
|
1797
1797
|
if (!r) {
|
|
1798
1798
|
e.insertBefore(a, t[n]);
|
|
1799
1799
|
return;
|
|
@@ -1802,17 +1802,17 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1802
1802
|
});
|
|
1803
1803
|
}
|
|
1804
1804
|
computeHalfAvgPxWidth(e, t) {
|
|
1805
|
-
let n = e[0], r = n == null ? void 0 : n.querySelectorAll(`[${
|
|
1805
|
+
let n = e[0], r = n == null ? void 0 : n.querySelectorAll(`[${D}]`), i = Array.from(r == null ? [] : r).reduce((e, t) => e + (parseFloat(t.style.width) || 0), 0);
|
|
1806
1806
|
return t > 0 ? Math.round(i / t / 2 * 100) / 100 : 0;
|
|
1807
1807
|
}
|
|
1808
1808
|
addColumnPercent(e, t, n) {
|
|
1809
1809
|
let r = 1 - .5 / t;
|
|
1810
1810
|
e.forEach((e) => {
|
|
1811
|
-
e.querySelectorAll(`[${
|
|
1811
|
+
e.querySelectorAll(`[${D}]`).forEach((e) => {
|
|
1812
1812
|
let n = e, i = parseFloat(n.style.width) || 100 / t, a = Math.round(i * r * 100) / 100;
|
|
1813
1813
|
n.style.width = `${a}%`;
|
|
1814
1814
|
});
|
|
1815
|
-
let i = Math.round(100 / t / 2 * 100) / 100, a = e.querySelectorAll(`[${
|
|
1815
|
+
let i = Math.round(100 / t / 2 * 100) / 100, a = e.querySelectorAll(`[${D}]`), o = n === void 0 || n >= a.length, s = this.createCell(`${i}%`);
|
|
1816
1816
|
if (!o) {
|
|
1817
1817
|
e.insertBefore(s, a[n]);
|
|
1818
1818
|
return;
|
|
@@ -1821,77 +1821,77 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1821
1821
|
});
|
|
1822
1822
|
}
|
|
1823
1823
|
deleteColumn(e, t) {
|
|
1824
|
-
e.querySelectorAll(`[${
|
|
1825
|
-
let n = e.querySelectorAll(`[${
|
|
1824
|
+
e.querySelectorAll(`[${E}]`).forEach((e) => {
|
|
1825
|
+
let n = e.querySelectorAll(`[${D}]`);
|
|
1826
1826
|
t >= n.length || n[t].remove();
|
|
1827
1827
|
});
|
|
1828
1828
|
}
|
|
1829
1829
|
moveRow(e, t, n) {
|
|
1830
1830
|
if (t === n) return;
|
|
1831
|
-
let r = Array.from(e.querySelectorAll(`[${
|
|
1831
|
+
let r = Array.from(e.querySelectorAll(`[${E}]`));
|
|
1832
1832
|
if (t >= r.length || n >= r.length) return;
|
|
1833
1833
|
let i = r[t];
|
|
1834
1834
|
i.remove();
|
|
1835
|
-
let a = Array.from(e.querySelectorAll(`[${
|
|
1835
|
+
let a = Array.from(e.querySelectorAll(`[${E}]`));
|
|
1836
1836
|
n >= a.length ? e.appendChild(i) : e.insertBefore(i, a[n]);
|
|
1837
1837
|
}
|
|
1838
1838
|
moveColumn(e, t, n) {
|
|
1839
|
-
t !== n && e.querySelectorAll(`[${
|
|
1840
|
-
let r = Array.from(e.querySelectorAll(`[${
|
|
1839
|
+
t !== n && e.querySelectorAll(`[${E}]`).forEach((e) => {
|
|
1840
|
+
let r = Array.from(e.querySelectorAll(`[${D}]`));
|
|
1841
1841
|
if (t >= r.length || n >= r.length) return;
|
|
1842
1842
|
let i = r[t];
|
|
1843
1843
|
i.remove();
|
|
1844
|
-
let a = Array.from(e.querySelectorAll(`[${
|
|
1844
|
+
let a = Array.from(e.querySelectorAll(`[${D}]`));
|
|
1845
1845
|
n >= a.length ? e.appendChild(i) : e.insertBefore(i, a[n]);
|
|
1846
1846
|
});
|
|
1847
1847
|
}
|
|
1848
1848
|
getRowCount(e) {
|
|
1849
|
-
return e.querySelectorAll(`[${
|
|
1849
|
+
return e.querySelectorAll(`[${E}]`).length;
|
|
1850
1850
|
}
|
|
1851
1851
|
getColumnCount(e) {
|
|
1852
|
-
let t = e.querySelector(`[${
|
|
1853
|
-
return t ? t.querySelectorAll(`[${
|
|
1852
|
+
let t = e.querySelector(`[${E}]`);
|
|
1853
|
+
return t ? t.querySelectorAll(`[${D}]`).length : 0;
|
|
1854
1854
|
}
|
|
1855
1855
|
getCell(e, t, n) {
|
|
1856
|
-
let r = e.querySelectorAll(`[${
|
|
1856
|
+
let r = e.querySelectorAll(`[${E}]`);
|
|
1857
1857
|
if (t >= r.length) return null;
|
|
1858
|
-
let i = r[t].querySelectorAll(`[${
|
|
1858
|
+
let i = r[t].querySelectorAll(`[${D}]`);
|
|
1859
1859
|
return n >= i.length ? null : i[n];
|
|
1860
1860
|
}
|
|
1861
1861
|
getColWidths(e) {
|
|
1862
|
-
let t = e.querySelector(`[${
|
|
1862
|
+
let t = e.querySelector(`[${E}]`);
|
|
1863
1863
|
if (!t) return [];
|
|
1864
|
-
let n = t.querySelectorAll(`[${
|
|
1864
|
+
let n = t.querySelectorAll(`[${D}]`), r = [];
|
|
1865
1865
|
return n.forEach((e) => {
|
|
1866
1866
|
let t = parseFloat(e.style.width);
|
|
1867
1867
|
r.push(isNaN(t) ? 0 : t);
|
|
1868
1868
|
}), r;
|
|
1869
1869
|
}
|
|
1870
1870
|
detectWidthUnit(e) {
|
|
1871
|
-
let t = e.querySelector(`[${
|
|
1871
|
+
let t = e.querySelector(`[${E}]`);
|
|
1872
1872
|
if (!t) return "%";
|
|
1873
|
-
let n = t.querySelector(`[${
|
|
1873
|
+
let n = t.querySelector(`[${D}]`);
|
|
1874
1874
|
return n && n.style.width.endsWith("px") ? "px" : "%";
|
|
1875
1875
|
}
|
|
1876
1876
|
getRawCellWidths(e) {
|
|
1877
|
-
let t = e.querySelector(`[${
|
|
1877
|
+
let t = e.querySelector(`[${E}]`);
|
|
1878
1878
|
if (!t) return [];
|
|
1879
|
-
let n = t.querySelectorAll(`[${
|
|
1879
|
+
let n = t.querySelectorAll(`[${D}]`);
|
|
1880
1880
|
return Array.from(n).map((e) => e.style.width);
|
|
1881
1881
|
}
|
|
1882
1882
|
createRow(e, t) {
|
|
1883
1883
|
let n = document.createElement("div");
|
|
1884
|
-
return n.className =
|
|
1884
|
+
return n.className = S($n), n.setAttribute(E, ""), Array.from({ length: e }).forEach((e, r) => {
|
|
1885
1885
|
n.appendChild(this.createCell(t[r]));
|
|
1886
1886
|
}), n;
|
|
1887
1887
|
}
|
|
1888
1888
|
createCell(e) {
|
|
1889
1889
|
let t = document.createElement("div");
|
|
1890
|
-
t.className =
|
|
1890
|
+
t.className = S(er), t.style.borderRight = Qn, t.style.borderBottom = Qn, t.style.flexShrink = "0", t.style.overflow = "hidden", t.style.overflowWrap = "break-word", e !== void 0 && (t.style.width = typeof e == "string" ? e : `${e}%`), t.setAttribute(D, "");
|
|
1891
1891
|
let n = document.createElement("div");
|
|
1892
|
-
return n.setAttribute(
|
|
1892
|
+
return n.setAttribute(k, ""), t.appendChild(n), t;
|
|
1893
1893
|
}
|
|
1894
|
-
},
|
|
1894
|
+
}, O = (e) => typeof e == "object" && !!e && "blocks" in e, k = "data-blok-table-cell-blocks", rr = class {
|
|
1895
1895
|
constructor(e) {
|
|
1896
1896
|
var t;
|
|
1897
1897
|
this._activeCellWithBlocks = null, this.cellsPendingCheck = /* @__PURE__ */ new Set(), this.pendingCheckScheduled = !1, this.removedBlockCells = /* @__PURE__ */ new Map(), this.deferredEvents = [], this.isExitingTable = !1, this.handleBlockMutation = (e) => {
|
|
@@ -1913,15 +1913,17 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1913
1913
|
this.claimBlockForCell(i.cell, n.target.id), this.syncBlockToModel(i.cell, n.target.id), this.cellsPendingCheck.delete(i.cell);
|
|
1914
1914
|
return;
|
|
1915
1915
|
}
|
|
1916
|
-
let a = n.target.holder, o = a.closest(`[${
|
|
1916
|
+
let a = n.target.holder, o = a.closest(`[${k}]`);
|
|
1917
1917
|
o && this.stripPlaceholders(o);
|
|
1918
|
-
let s = o && !this.model.findCellForBlock(n.target.id) ? o.closest(`[${
|
|
1918
|
+
let s = o && !this.model.findCellForBlock(n.target.id) ? o.closest(`[${D}]`) : null;
|
|
1919
1919
|
if (s && this.syncBlockToModel(s, n.target.id), o) return;
|
|
1920
1920
|
if (!this.gridElement.contains(a)) {
|
|
1921
|
-
let e = this.api.blocks.
|
|
1922
|
-
if (
|
|
1923
|
-
let i = this.
|
|
1924
|
-
|
|
1921
|
+
let e = this.api.blocks.getBlockIndex(this.tableBlockId), t = e === void 0 ? null : this.api.blocks.getBlockByIndex(e);
|
|
1922
|
+
if (t && !t.holder.contains(a)) return;
|
|
1923
|
+
let i = this.api.blocks.getCurrentBlockIndex(), o = i >= 0 ? this.api.blocks.getBlockByIndex(i) : null;
|
|
1924
|
+
if (!(o != null && this.getOwnedCellForBlock(o.id) !== null)) return;
|
|
1925
|
+
let s = this.findCellForNewBlock(r);
|
|
1926
|
+
s && (this.claimBlockForCell(s, n.target.id), this.syncBlockToModel(s, n.target.id), this.cellsPendingCheck.delete(s));
|
|
1925
1927
|
return;
|
|
1926
1928
|
}
|
|
1927
1929
|
let c = this.findCellForNewBlock(r);
|
|
@@ -1929,11 +1931,11 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
1929
1931
|
}, this.handleCellBlankSpaceClick = (e) => {
|
|
1930
1932
|
let t = e.target;
|
|
1931
1933
|
if (!t) return;
|
|
1932
|
-
let n = t.hasAttribute(
|
|
1934
|
+
let n = t.hasAttribute(D), r = t.hasAttribute(k);
|
|
1933
1935
|
if (!n && !r) return;
|
|
1934
|
-
let i = n ? t : t.closest(`[${
|
|
1936
|
+
let i = n ? t : t.closest(`[${D}]`);
|
|
1935
1937
|
if (!i) return;
|
|
1936
|
-
let a = n ? i.querySelector(`[${
|
|
1938
|
+
let a = n ? i.querySelector(`[${k}]`) : t;
|
|
1937
1939
|
if (!a) return;
|
|
1938
1940
|
let o = a.querySelectorAll("[data-blok-id]"), s = o[o.length - 1];
|
|
1939
1941
|
if (!s) return;
|
|
@@ -2009,8 +2011,8 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
2009
2011
|
}
|
|
2010
2012
|
this.isExitingTable = !0;
|
|
2011
2013
|
try {
|
|
2012
|
-
let
|
|
2013
|
-
this.api.caret.setToBlock(
|
|
2014
|
+
let t = this.api.blocks.getBlocksCount(), n = this.api.blocks.insert(void 0, {}, {}, t, !0), r = this.gridElement.contains(n.holder) ? this.api.blocks.getBlockByIndex(e) : null;
|
|
2015
|
+
r && r.holder.after(n.holder), this.api.caret.setToBlock(n.id, "start");
|
|
2014
2016
|
} finally {
|
|
2015
2017
|
this.isExitingTable = !1;
|
|
2016
2018
|
}
|
|
@@ -2031,7 +2033,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
2031
2033
|
this.clearActiveCellWithBlocks();
|
|
2032
2034
|
let r = this.getCell(e.row, e.col);
|
|
2033
2035
|
if (!r) return;
|
|
2034
|
-
let i = r.querySelector(`[${
|
|
2036
|
+
let i = r.querySelector(`[${k}]`);
|
|
2035
2037
|
if (!i) return;
|
|
2036
2038
|
let a = i.querySelectorAll("[contenteditable=\"true\"]");
|
|
2037
2039
|
a.length !== 0 && ((t ? a[a.length - 1] : a[0]).focus(), (n = this.onNavigateToCell) == null || n.call(this, e));
|
|
@@ -2050,18 +2052,18 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
2050
2052
|
return r ? (n = r.querySelectorAll("[data-blok-table-cell]")[t]) == null ? null : n : null;
|
|
2051
2053
|
}
|
|
2052
2054
|
initializeCells(e) {
|
|
2053
|
-
let t = this.gridElement.querySelectorAll(`[${
|
|
2055
|
+
let t = this.gridElement.querySelectorAll(`[${E}]`), n = [];
|
|
2054
2056
|
return e.forEach((e, r) => {
|
|
2055
2057
|
let i = t[r];
|
|
2056
2058
|
if (!i) return;
|
|
2057
|
-
let a = i.querySelectorAll(`[${
|
|
2059
|
+
let a = i.querySelectorAll(`[${D}]`), o = [];
|
|
2058
2060
|
e.forEach((e, t) => {
|
|
2059
2061
|
let n = a[t];
|
|
2060
2062
|
if (!n) return;
|
|
2061
|
-
let r = n.querySelector(`[${
|
|
2063
|
+
let r = n.querySelector(`[${k}]`);
|
|
2062
2064
|
if (!r) return;
|
|
2063
|
-
let i =
|
|
2064
|
-
if (
|
|
2065
|
+
let i = O(e) && e.blocks.length > 0 ? [...e.blocks] : null, s = i ? this.mountBlocksInCell(r, i) : [], c = {};
|
|
2066
|
+
if (O(e) && (e.color !== void 0 && (c.color = e.color), e.textColor !== void 0 && (c.textColor = e.textColor)), s.length > 0) o.push(x({ blocks: i == null ? s : i }, c));
|
|
2065
2067
|
else {
|
|
2066
2068
|
var l;
|
|
2067
2069
|
let t = typeof e == "string" ? e : (l = e.text) == null ? "" : l, n = t.split(/<br\s*\/?>/i).map((e) => e.trim()).filter(Boolean), a = n.length > 0 ? n : [t], s = [];
|
|
@@ -2069,7 +2071,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
2069
2071
|
let t = this.api.blocks.insert("paragraph", { text: e }, {}, this.api.blocks.getBlocksCount(), !1);
|
|
2070
2072
|
r.appendChild(t.holder), this.api.blocks.setBlockParent(t.id, this.tableBlockId), s.push(t.id);
|
|
2071
2073
|
}
|
|
2072
|
-
o.push(
|
|
2074
|
+
o.push(x({ blocks: i === null ? s : [...i, ...s] }, c));
|
|
2073
2075
|
}
|
|
2074
2076
|
this.stripPlaceholders(r);
|
|
2075
2077
|
}), n.push(o);
|
|
@@ -2094,7 +2096,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
2094
2096
|
}
|
|
2095
2097
|
claimBlockForCell(e, t) {
|
|
2096
2098
|
var n, r;
|
|
2097
|
-
let i = e.querySelector(`[${
|
|
2099
|
+
let i = e.querySelector(`[${k}]`);
|
|
2098
2100
|
if (!i) return;
|
|
2099
2101
|
let a = this.api.blocks.getBlockIndex(t);
|
|
2100
2102
|
if (a === void 0) return;
|
|
@@ -2108,12 +2110,12 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
2108
2110
|
}
|
|
2109
2111
|
findCellForAdjacentBlock(e) {
|
|
2110
2112
|
if (e < 0 || e >= this.api.blocks.getBlocksCount()) return null;
|
|
2111
|
-
let t = this.api.blocks.getBlockByIndex(e), n = t == null ? void 0 : t.holder.closest(`[${
|
|
2113
|
+
let t = this.api.blocks.getBlockByIndex(e), n = t == null ? void 0 : t.holder.closest(`[${D}]`);
|
|
2112
2114
|
return n && this.gridElement.contains(n) ? n : null;
|
|
2113
2115
|
}
|
|
2114
2116
|
ensureCellHasBlock(e) {
|
|
2115
2117
|
var t, n;
|
|
2116
|
-
let r = e.querySelector(`[${
|
|
2118
|
+
let r = e.querySelector(`[${k}]`);
|
|
2117
2119
|
r && r.querySelector("[data-blok-id]") === null && ((t = (n = this.api.blocks).transactWithoutCapture) == null || t.call(n, () => {
|
|
2118
2120
|
let t = this.api.blocks.insert("paragraph", { text: "" }, {}, this.api.blocks.getBlocksCount(), !0);
|
|
2119
2121
|
r.appendChild(t.holder), this.api.blocks.setBlockParent(t.id, this.tableBlockId), this.syncBlockToModel(e, t.id), this.stripPlaceholders(r);
|
|
@@ -2135,11 +2137,11 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
2135
2137
|
n && this.model.addBlockToCell(n.row, n.col, t);
|
|
2136
2138
|
}
|
|
2137
2139
|
getCellPosition(e) {
|
|
2138
|
-
let t = e.closest(`[${
|
|
2140
|
+
let t = e.closest(`[${E}]`);
|
|
2139
2141
|
if (!t) return null;
|
|
2140
|
-
let n = Array.from(this.gridElement.querySelectorAll(`[${
|
|
2142
|
+
let n = Array.from(this.gridElement.querySelectorAll(`[${E}]`)).indexOf(t);
|
|
2141
2143
|
if (n < 0) return null;
|
|
2142
|
-
let r = Array.from(t.querySelectorAll(`[${
|
|
2144
|
+
let r = Array.from(t.querySelectorAll(`[${D}]`)).indexOf(e);
|
|
2143
2145
|
return r < 0 ? null : {
|
|
2144
2146
|
row: n,
|
|
2145
2147
|
col: r
|
|
@@ -2147,7 +2149,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
2147
2149
|
}
|
|
2148
2150
|
recordRemovedBlockCell(e) {
|
|
2149
2151
|
if (e.index === void 0) return;
|
|
2150
|
-
let t = e.target.holder.closest(`[${
|
|
2152
|
+
let t = e.target.holder.closest(`[${D}]`);
|
|
2151
2153
|
t && this.gridElement.contains(t) && this.removedBlockCells.set(e.target.id, {
|
|
2152
2154
|
cell: t,
|
|
2153
2155
|
index: e.index
|
|
@@ -2195,7 +2197,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
2195
2197
|
getBlockIdsFromCells(e) {
|
|
2196
2198
|
let t = [];
|
|
2197
2199
|
return Array.from(e).forEach((e) => {
|
|
2198
|
-
let n = e.querySelector(`[${
|
|
2200
|
+
let n = e.querySelector(`[${k}]`);
|
|
2199
2201
|
n && n.querySelectorAll("[data-blok-id]").forEach((e) => {
|
|
2200
2202
|
let n = e.getAttribute("data-blok-id");
|
|
2201
2203
|
n && t.push(n);
|
|
@@ -2208,7 +2210,7 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
2208
2210
|
});
|
|
2209
2211
|
}
|
|
2210
2212
|
deleteAllBlocks() {
|
|
2211
|
-
let e = this.gridElement.querySelectorAll(`[${
|
|
2213
|
+
let e = this.gridElement.querySelectorAll(`[${D}]`), t = this.getBlockIdsFromCells(e);
|
|
2212
2214
|
this.deleteBlocks(t);
|
|
2213
2215
|
}
|
|
2214
2216
|
destroy() {
|
|
@@ -2225,18 +2227,18 @@ var wt = "outline-hidden py-[3px] mt-[2px] mb-px", Tt = "outline-hidden pl-0.5 l
|
|
|
2225
2227
|
};
|
|
2226
2228
|
//#endregion
|
|
2227
2229
|
//#region src/components/shared/color-picker.ts
|
|
2228
|
-
function
|
|
2230
|
+
function ir() {
|
|
2229
2231
|
var e, t;
|
|
2230
2232
|
let n = document.documentElement.getAttribute("data-blok-theme");
|
|
2231
|
-
return n === "dark" ?
|
|
2233
|
+
return n === "dark" ? ae : n === "light" ? Ze : typeof window < "u" && (e = (t = window).matchMedia) != null && e.call(t, "(prefers-color-scheme: dark)").matches ? ae : Ze;
|
|
2232
2234
|
}
|
|
2233
|
-
function
|
|
2235
|
+
function ar(e, t) {
|
|
2234
2236
|
if (e === t) return !0;
|
|
2235
|
-
let n =
|
|
2237
|
+
let n = ge(e), r = ge(t);
|
|
2236
2238
|
return n === null || r === null ? !1 : n[0] === r[0] && n[1] === r[1] && n[2] === r[2];
|
|
2237
2239
|
}
|
|
2238
|
-
var
|
|
2239
|
-
function
|
|
2240
|
+
var or = "var(--blok-swatch-neutral-bg)";
|
|
2241
|
+
function sr(e) {
|
|
2240
2242
|
let { i18n: t, modes: n, testIdPrefix: r, onColorSelect: i } = e, a = { activeColors: Object.fromEntries(n.map((e) => [e.key, null])) }, o = document.createElement("div");
|
|
2241
2243
|
o.setAttribute("data-blok-testid", `${r}-picker`), o.className = "flex flex-col gap-3 p-2";
|
|
2242
2244
|
let s = [];
|
|
@@ -2249,17 +2251,21 @@ function or(e) {
|
|
|
2249
2251
|
a.className = "grid gap-1", a.style.gridTemplateColumns = "repeat(5, 2.25rem)", s.push(a), n.appendChild(i), n.appendChild(a), o.appendChild(n);
|
|
2250
2252
|
});
|
|
2251
2253
|
let c = (e) => {
|
|
2252
|
-
let o = s[e], c = n[e], l =
|
|
2254
|
+
let o = s[e], c = n[e], l = ir();
|
|
2253
2255
|
o.innerHTML = "";
|
|
2254
2256
|
let u = a.activeColors[c.key], d = document.createElement("button"), f = u === null;
|
|
2255
|
-
d.setAttribute("data-blok-testid", `${r}-swatch-${c.key}-default`), d.className =
|
|
2257
|
+
d.setAttribute("data-blok-testid", `${r}-swatch-${c.key}-default`), d.className = S("w-9 h-9 rounded-md cursor-pointer border-none outline-hidden", "flex items-center justify-center text-sm font-semibold", "transition-[box-shadow,transform] ring-inset hover:ring-2 hover:ring-swatch-ring-hover active:scale-90", f && "ring-2 ring-swatch-ring-hover"), d.textContent = c.presetField === "text" ? "A" : "", c.presetField === "text" && (d.style.color = "var(--blok-text-primary)"), d.style.backgroundColor = or, d.addEventListener("click", () => {
|
|
2256
2258
|
i(null, c.key);
|
|
2257
|
-
})
|
|
2259
|
+
});
|
|
2260
|
+
let p = t.t("tools.colorPicker.defaultSwatchLabel").replace("{default}", t.t("tools.marker.default")).replace("{mode}", t.t(c.labelKey).toLowerCase());
|
|
2261
|
+
Ae(d, p.charAt(0).toUpperCase() + p.slice(1), { placement: "top" }), o.appendChild(d);
|
|
2258
2262
|
for (let e of l) {
|
|
2259
|
-
let n = document.createElement("button"), a = c.presetField === "text" ? e.text : e.bg, s = u !== null &&
|
|
2260
|
-
n.setAttribute("data-blok-testid", `${r}-swatch-${c.key}-${e.name}`), n.className =
|
|
2263
|
+
let n = document.createElement("button"), a = c.presetField === "text" ? e.text : e.bg, s = u !== null && ar(a, u);
|
|
2264
|
+
n.setAttribute("data-blok-testid", `${r}-swatch-${c.key}-${e.name}`), n.className = S("w-9 h-9 rounded-md cursor-pointer border-none outline-hidden", "flex items-center justify-center text-sm font-semibold", "transition-[box-shadow,transform] ring-inset hover:ring-2 hover:ring-swatch-ring-hover active:scale-90", s && "ring-2 ring-swatch-ring-hover"), n.textContent = c.presetField === "text" ? "A" : "", c.presetField === "text" ? (n.style.color = e.text, n.style.backgroundColor = or) : (n.style.color = l === ae ? e.text : "#37352f", n.style.backgroundColor = e.bg), n.addEventListener("click", () => {
|
|
2261
2265
|
i(a, c.key);
|
|
2262
|
-
})
|
|
2266
|
+
});
|
|
2267
|
+
let d = t.t("tools.colorPicker.colorSwatchLabel").replace("{color}", t.t("tools.colorPicker.color." + e.name)).replace("{mode}", t.t(c.labelKey).toLowerCase());
|
|
2268
|
+
Ae(n, d.charAt(0).toUpperCase() + d.slice(1), { placement: "top" }), o.appendChild(n);
|
|
2263
2269
|
}
|
|
2264
2270
|
}, l = () => {
|
|
2265
2271
|
n.forEach((e, t) => c(t));
|
|
@@ -2278,8 +2284,8 @@ function or(e) {
|
|
|
2278
2284
|
}
|
|
2279
2285
|
//#endregion
|
|
2280
2286
|
//#region src/tools/table/table-cell-color-picker.ts
|
|
2281
|
-
var
|
|
2282
|
-
let t =
|
|
2287
|
+
var cr = (e) => {
|
|
2288
|
+
let t = sr({
|
|
2283
2289
|
i18n: e.i18n,
|
|
2284
2290
|
testIdPrefix: "cell-color",
|
|
2285
2291
|
modes: [{
|
|
@@ -2296,40 +2302,40 @@ var sr = (e) => {
|
|
|
2296
2302
|
}
|
|
2297
2303
|
});
|
|
2298
2304
|
return { element: t.element };
|
|
2299
|
-
},
|
|
2305
|
+
}, lr = (e, t, n) => {
|
|
2300
2306
|
t === "col" ? Object.assign(e.style, { height: `${n}px` }) : Object.assign(e.style, { width: `${n}px` });
|
|
2301
|
-
},
|
|
2307
|
+
}, ur = [
|
|
2302
2308
|
[2, 2],
|
|
2303
2309
|
[8, 2],
|
|
2304
2310
|
[2, 7],
|
|
2305
2311
|
[8, 7],
|
|
2306
2312
|
[2, 12],
|
|
2307
2313
|
[8, 12]
|
|
2308
|
-
],
|
|
2314
|
+
], dr = [
|
|
2309
2315
|
[2, 2],
|
|
2310
2316
|
[7, 2],
|
|
2311
2317
|
[12, 2],
|
|
2312
2318
|
[2, 8],
|
|
2313
2319
|
[7, 8],
|
|
2314
2320
|
[12, 8]
|
|
2315
|
-
],
|
|
2321
|
+
], fr = (e) => {
|
|
2316
2322
|
let t = document.createElementNS("http://www.w3.org/2000/svg", "svg"), n = e === "horizontal";
|
|
2317
2323
|
t.setAttribute("width", n ? "14" : "10"), t.setAttribute("height", n ? "10" : "14"), t.setAttribute("viewBox", n ? "0 0 14 10" : "0 0 10 14"), t.setAttribute("fill", "currentColor"), t.classList.add("opacity-0", "transition-opacity", "duration-150", "text-gray-400", "pointer-events-none");
|
|
2318
|
-
let r = n ?
|
|
2324
|
+
let r = n ? dr : ur;
|
|
2319
2325
|
for (let [e, n] of r) {
|
|
2320
2326
|
let r = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
2321
2327
|
r.setAttribute("cx", String(e)), r.setAttribute("cy", String(n)), r.setAttribute("r", "1.5"), t.appendChild(r);
|
|
2322
2328
|
}
|
|
2323
2329
|
return t;
|
|
2324
|
-
},
|
|
2330
|
+
}, pr = (e, t) => {
|
|
2325
2331
|
t === "col" ? Object.assign(e.style, { height: "16px" }) : Object.assign(e.style, { width: "16px" }), e.classList.add("bg-gray-200"), e.classList.remove("bg-gray-300");
|
|
2326
2332
|
let n = e.querySelector("svg");
|
|
2327
2333
|
n && (n.classList.remove("opacity-0"), n.classList.add("opacity-100"));
|
|
2328
|
-
},
|
|
2329
|
-
|
|
2334
|
+
}, mr = (e, t, n) => {
|
|
2335
|
+
lr(e, t, n), e.classList.remove("bg-gray-200"), e.classList.add("bg-gray-300");
|
|
2330
2336
|
let r = e.querySelector("svg");
|
|
2331
2337
|
r && (r.classList.add("opacity-0"), r.classList.remove("opacity-100"));
|
|
2332
|
-
},
|
|
2338
|
+
}, hr = "data-blok-table-cell-selected", gr = "2px solid #3b82f6", _r = "data-blok-table-selection-pill", vr = 16, yr = 20, br = 4, xr = [
|
|
2333
2339
|
"absolute",
|
|
2334
2340
|
"z-3",
|
|
2335
2341
|
"rounded-sm",
|
|
@@ -2342,7 +2348,7 @@ var sr = (e) => {
|
|
|
2342
2348
|
"overflow-hidden",
|
|
2343
2349
|
"cursor-pointer",
|
|
2344
2350
|
"bg-blue-500"
|
|
2345
|
-
],
|
|
2351
|
+
], Sr = (e) => e.style.userSelect === "none", Cr = class {
|
|
2346
2352
|
constructor(e) {
|
|
2347
2353
|
this.anchorCell = null, this.extentCell = null, this.isSelecting = !1, this.hasSelection = !1, this.selectedCells = [], this.overlay = null, this.pill = null, this.pillPopover = null, this.resizeObserver = null, this.lastPaintedRange = null, this.grid = e.grid, this.rectangleSelection = e.rectangleSelection, this.onSelectionActiveChange = e.onSelectionActiveChange, this.onClearContent = e.onClearContent, this.onCopy = e.onCopy, this.onCut = e.onCut, this.onCopyViaButton = e.onCopyViaButton, this.onColorChange = e.onColorChange, this.onSelectionRangeChange = e.onSelectionRangeChange, this.onPointerDragActiveChange = e.onPointerDragActiveChange, this.isPopoverOpen = e.isPopoverOpen, this.i18n = e.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.boundPreventDragStart = this.handleDragStart.bind(this), this.grid.addEventListener("pointerdown", this.boundPointerDown), this.grid.addEventListener("dragstart", this.boundPreventDragStart), document.addEventListener("keydown", this.boundKeyDown), document.addEventListener("copy", this.boundCopyHandler), document.addEventListener("cut", this.boundCutHandler);
|
|
2348
2354
|
}
|
|
@@ -2359,7 +2365,7 @@ var sr = (e) => {
|
|
|
2359
2365
|
r !== 0 && this.showProgrammaticSelection(e, 0, e, r - 1);
|
|
2360
2366
|
}
|
|
2361
2367
|
selectColumn(e) {
|
|
2362
|
-
let t = this.grid.querySelectorAll(`[${
|
|
2368
|
+
let t = this.grid.querySelectorAll(`[${E}]`).length;
|
|
2363
2369
|
t !== 0 && this.showProgrammaticSelection(0, e, t - 1, e);
|
|
2364
2370
|
}
|
|
2365
2371
|
clearActiveSelection() {
|
|
@@ -2376,9 +2382,9 @@ var sr = (e) => {
|
|
|
2376
2382
|
}
|
|
2377
2383
|
handlePointerDown(e) {
|
|
2378
2384
|
var t;
|
|
2379
|
-
if (
|
|
2385
|
+
if (Sr(this.grid) || e.button !== 0) return;
|
|
2380
2386
|
let n = e.target;
|
|
2381
|
-
if (n.closest("[data-blok-table-grip]") || n.closest("[data-blok-table-resize]") || n.closest(`[${
|
|
2387
|
+
if (n.closest("[data-blok-table-grip]") || n.closest("[data-blok-table-resize]") || n.closest(`[${_r}]`)) return;
|
|
2382
2388
|
let r = this.resolveCellCoord(n);
|
|
2383
2389
|
r && (this.hasSelection && this.lastPaintedRange !== null && this.lastPaintedRange.minRow === r.row && this.lastPaintedRange.maxRow === r.row && this.lastPaintedRange.minCol === r.col && this.lastPaintedRange.maxCol === r.col ? document.removeEventListener("pointerdown", this.boundClearSelection) : this.hasSelection && this.clearSelection(), this.anchorCell = r, this.isSelecting = !1, (t = this.onPointerDragActiveChange) == null || t.call(this, !0), document.addEventListener("mousemove", this.boundCancelRectangle, !0), document.addEventListener("pointermove", this.boundPointerMove), document.addEventListener("pointerup", this.boundPointerUp), document.addEventListener("pointercancel", this.boundPointerUp));
|
|
2384
2390
|
}
|
|
@@ -2420,7 +2426,7 @@ var sr = (e) => {
|
|
|
2420
2426
|
}
|
|
2421
2427
|
handleClearSelection(e) {
|
|
2422
2428
|
let t = e.target;
|
|
2423
|
-
t instanceof HTMLElement && t.closest(`[${
|
|
2429
|
+
t instanceof HTMLElement && t.closest(`[${_r}]`) || t instanceof HTMLElement && t.closest("[data-blok-popover-opened]") !== null || (this.pillPopover !== null && this.destroyPillPopover(), document.removeEventListener("pointerdown", this.boundClearSelection), this.clearSelection());
|
|
2424
2430
|
}
|
|
2425
2431
|
handleKeyDown(e) {
|
|
2426
2432
|
var t;
|
|
@@ -2443,7 +2449,7 @@ var sr = (e) => {
|
|
|
2443
2449
|
}
|
|
2444
2450
|
restoreModifiedCells() {
|
|
2445
2451
|
this.destroyPillPopover(), this.disconnectResizeObserver(), this.selectedCells.forEach((e) => {
|
|
2446
|
-
e.removeAttribute(
|
|
2452
|
+
e.removeAttribute(hr);
|
|
2447
2453
|
}), this.pill && (this.pill.remove(), this.pill = null), this.overlay && (this.overlay.remove(), this.overlay = null), this.selectedCells = [];
|
|
2448
2454
|
}
|
|
2449
2455
|
showProgrammaticSelection(e, t, n, r) {
|
|
@@ -2464,7 +2470,7 @@ var sr = (e) => {
|
|
|
2464
2470
|
var e, t;
|
|
2465
2471
|
if (!this.anchorCell || !this.extentCell) return;
|
|
2466
2472
|
this.selectedCells.forEach((e) => {
|
|
2467
|
-
e.removeAttribute(
|
|
2473
|
+
e.removeAttribute(hr);
|
|
2468
2474
|
}), this.selectedCells = [];
|
|
2469
2475
|
let n = Math.min(this.anchorCell.row, this.extentCell.row), r = Math.max(this.anchorCell.row, this.extentCell.row), i = Math.min(this.anchorCell.col, this.extentCell.col), a = Math.max(this.anchorCell.col, this.extentCell.col);
|
|
2470
2476
|
this.lastPaintedRange = {
|
|
@@ -2473,20 +2479,20 @@ var sr = (e) => {
|
|
|
2473
2479
|
minCol: i,
|
|
2474
2480
|
maxCol: a
|
|
2475
2481
|
};
|
|
2476
|
-
let o = this.grid.querySelectorAll(`[${
|
|
2482
|
+
let o = this.grid.querySelectorAll(`[${E}]`);
|
|
2477
2483
|
this.selectedCells = this.collectCellsInRange(o, n, r, i, a), this.selectedCells.forEach((e) => {
|
|
2478
|
-
e.setAttribute(
|
|
2484
|
+
e.setAttribute(hr, "");
|
|
2479
2485
|
});
|
|
2480
|
-
let s = (e = o[n]) == null ? void 0 : e.querySelectorAll(`[${
|
|
2486
|
+
let s = (e = o[n]) == null ? void 0 : e.querySelectorAll(`[${D}]`)[i], c = (t = o[r]) == null ? void 0 : t.querySelectorAll(`[${D}]`)[a];
|
|
2481
2487
|
if (!s || !c) return;
|
|
2482
2488
|
let l = this.grid.getBoundingClientRect(), u = s.getBoundingClientRect(), d = c.getBoundingClientRect(), f = getComputedStyle(this.grid), p = parseFloat(f.borderTopWidth) || 0, m = parseFloat(f.borderLeftWidth) || 0, h = d.right - u.left + 1, g = d.bottom - u.top + 1, _ = u.top - l.top - p - 1, ee = u.left - l.left - m - 1;
|
|
2483
|
-
this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border =
|
|
2489
|
+
this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border = gr, 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 = `${_}px`, this.overlay.style.left = `${ee}px`, this.overlay.style.width = `${h}px`, this.overlay.style.height = `${g}px`, this.pill || (this.pill = this.createPill(), this.grid.appendChild(this.pill)), this.pill.style.left = `${ee + h - 1}px`, this.pill.style.top = `${_ + g / 2}px`, this.observeCellResizes();
|
|
2484
2490
|
}
|
|
2485
2491
|
repositionOverlay() {
|
|
2486
2492
|
var e, t;
|
|
2487
2493
|
let n = this.lastPaintedRange;
|
|
2488
2494
|
if (!n || !this.overlay) return;
|
|
2489
|
-
let r = this.grid.querySelectorAll(`[${
|
|
2495
|
+
let r = this.grid.querySelectorAll(`[${E}]`), i = (e = r[n.minRow]) == null ? void 0 : e.querySelectorAll(`[${D}]`)[n.minCol], a = (t = r[n.maxRow]) == null ? void 0 : t.querySelectorAll(`[${D}]`)[n.maxCol];
|
|
2490
2496
|
if (!i || !a) return;
|
|
2491
2497
|
let o = this.grid.getBoundingClientRect(), s = i.getBoundingClientRect(), c = a.getBoundingClientRect(), l = getComputedStyle(this.grid), u = parseFloat(l.borderTopWidth) || 0, d = parseFloat(l.borderLeftWidth) || 0, f = c.right - s.left + 1, p = c.bottom - s.top + 1, m = s.top - o.top - u - 1, h = s.left - o.left - d - 1;
|
|
2492
2498
|
this.overlay.style.top = `${m}px`, this.overlay.style.left = `${h}px`, this.overlay.style.width = `${f}px`, this.overlay.style.height = `${p}px`, this.pill && (this.pill.style.left = `${h + f - 1}px`, this.pill.style.top = `${m + p / 2}px`);
|
|
@@ -2504,8 +2510,8 @@ var sr = (e) => {
|
|
|
2504
2510
|
}
|
|
2505
2511
|
createPill() {
|
|
2506
2512
|
let e = document.createElement("div");
|
|
2507
|
-
e.setAttribute(
|
|
2508
|
-
let t =
|
|
2513
|
+
e.setAttribute(_r, ""), e.setAttribute("contenteditable", "false"), e.className = S(xr), e.style.width = `${br}px`, e.style.height = `${yr}px`, e.style.pointerEvents = "auto", e.style.transform = "translate(-50%, -50%)", e.style.outline = "2px solid var(--blok-table-grip-outline, transparent)";
|
|
2514
|
+
let t = fr("vertical");
|
|
2509
2515
|
return t.classList.remove("text-gray-400"), t.classList.add("text-white"), e.appendChild(t), e.addEventListener("mouseenter", () => {
|
|
2510
2516
|
this.pillPopover === null && this.expandPill();
|
|
2511
2517
|
}), e.addEventListener("mouseleave", () => {
|
|
@@ -2517,9 +2523,9 @@ var sr = (e) => {
|
|
|
2517
2523
|
openPillPopover() {
|
|
2518
2524
|
if (this.destroyPillPopover(), !this.pill) return;
|
|
2519
2525
|
this.expandPill();
|
|
2520
|
-
let e =
|
|
2526
|
+
let e = ce === "Meta" ? "⌘C" : "Ctrl+C", n = [];
|
|
2521
2527
|
if (this.onColorChange !== void 0) {
|
|
2522
|
-
let { element: e } =
|
|
2528
|
+
let { element: e } = cr({
|
|
2523
2529
|
i18n: this.i18n,
|
|
2524
2530
|
onColorSelect: (e, t) => {
|
|
2525
2531
|
var n;
|
|
@@ -2527,23 +2533,23 @@ var sr = (e) => {
|
|
|
2527
2533
|
}
|
|
2528
2534
|
});
|
|
2529
2535
|
n.push({
|
|
2530
|
-
icon:
|
|
2536
|
+
icon: fe,
|
|
2531
2537
|
title: this.i18n.t("tools.table.cellColor"),
|
|
2532
2538
|
name: "cellColor",
|
|
2533
2539
|
children: {
|
|
2534
2540
|
items: [{
|
|
2535
|
-
type:
|
|
2541
|
+
type: p.Html,
|
|
2536
2542
|
element: e
|
|
2537
2543
|
}],
|
|
2538
2544
|
isFlippable: !1
|
|
2539
2545
|
}
|
|
2540
2546
|
});
|
|
2541
2547
|
}
|
|
2542
|
-
this.pillPopover = new
|
|
2548
|
+
this.pillPopover = new Ce({
|
|
2543
2549
|
items: [
|
|
2544
2550
|
...n,
|
|
2545
2551
|
{
|
|
2546
|
-
icon:
|
|
2552
|
+
icon: je,
|
|
2547
2553
|
title: this.i18n.t("tools.table.copySelection"),
|
|
2548
2554
|
secondaryLabel: e,
|
|
2549
2555
|
closeOnActivate: !0,
|
|
@@ -2565,19 +2571,19 @@ var sr = (e) => {
|
|
|
2565
2571
|
],
|
|
2566
2572
|
trigger: this.pill,
|
|
2567
2573
|
flippable: !0
|
|
2568
|
-
}), this.pillPopover.on(
|
|
2574
|
+
}), this.pillPopover.on(Ye.Closed, () => {
|
|
2569
2575
|
this.pillPopover !== null && (this.destroyPillPopover(), this.collapsePill());
|
|
2570
2576
|
}), this.pillPopover.show();
|
|
2571
2577
|
}
|
|
2572
2578
|
expandPill() {
|
|
2573
2579
|
if (!this.pill) return;
|
|
2574
|
-
this.pill.style.width = `${
|
|
2580
|
+
this.pill.style.width = `${vr}px`;
|
|
2575
2581
|
let e = this.pill.querySelector("svg");
|
|
2576
2582
|
e && (e.classList.remove("opacity-0"), e.classList.add("opacity-100"));
|
|
2577
2583
|
}
|
|
2578
2584
|
collapsePill() {
|
|
2579
2585
|
if (!this.pill) return;
|
|
2580
|
-
this.pill.style.width = `${
|
|
2586
|
+
this.pill.style.width = `${br}px`;
|
|
2581
2587
|
let e = this.pill.querySelector("svg");
|
|
2582
2588
|
e && (e.classList.add("opacity-0"), e.classList.remove("opacity-100"));
|
|
2583
2589
|
}
|
|
@@ -2588,13 +2594,13 @@ var sr = (e) => {
|
|
|
2588
2594
|
}
|
|
2589
2595
|
}
|
|
2590
2596
|
resolveCellCoord(e) {
|
|
2591
|
-
let t = e.closest(`[${
|
|
2597
|
+
let t = e.closest(`[${D}]`);
|
|
2592
2598
|
if (!t) return null;
|
|
2593
|
-
let n = t.closest(`[${
|
|
2599
|
+
let n = t.closest(`[${E}]`);
|
|
2594
2600
|
if (!n || !this.grid.contains(n)) return null;
|
|
2595
|
-
let r = Array.from(this.grid.querySelectorAll(`[${
|
|
2601
|
+
let r = Array.from(this.grid.querySelectorAll(`[${E}]`)).indexOf(n);
|
|
2596
2602
|
if (r < 0) return null;
|
|
2597
|
-
let i = Array.from(n.querySelectorAll(`[${
|
|
2603
|
+
let i = Array.from(n.querySelectorAll(`[${D}]`)).indexOf(t);
|
|
2598
2604
|
return i < 0 ? null : {
|
|
2599
2605
|
row: r,
|
|
2600
2606
|
col: i
|
|
@@ -2603,7 +2609,7 @@ var sr = (e) => {
|
|
|
2603
2609
|
clampExtentToEdge(e) {
|
|
2604
2610
|
var t, n, r, i, a, o;
|
|
2605
2611
|
if (!this.anchorCell || !this.isSelecting) return;
|
|
2606
|
-
let s = this.grid.getBoundingClientRect(), c = this.grid.querySelectorAll(`[${
|
|
2612
|
+
let s = this.grid.getBoundingClientRect(), c = this.grid.querySelectorAll(`[${E}]`), l = c.length, u = (t = (n = c[0]) == null ? void 0 : n.querySelectorAll("[data-blok-table-cell]").length) == null ? 0 : t;
|
|
2607
2613
|
if (l === 0 || u === 0) return;
|
|
2608
2614
|
let d = {
|
|
2609
2615
|
row: this.clampAxis(e.clientY, s.top, s.bottom, l, (r = (i = this.extentCell) == null ? void 0 : i.row) == null ? this.anchorCell.row : r),
|
|
@@ -2613,106 +2619,106 @@ var sr = (e) => {
|
|
|
2613
2619
|
}
|
|
2614
2620
|
collectCellsInRange(e, t, n, r, i) {
|
|
2615
2621
|
return Array.from(e).slice(t, n + 1).flatMap((e) => {
|
|
2616
|
-
let t = e.querySelectorAll(`[${
|
|
2622
|
+
let t = e.querySelectorAll(`[${D}]`);
|
|
2617
2623
|
return Array.from(t).slice(r, i + 1).filter((e) => e instanceof HTMLElement);
|
|
2618
2624
|
});
|
|
2619
2625
|
}
|
|
2620
2626
|
clampAxis(e, t, n, r, i) {
|
|
2621
2627
|
return e < t ? 0 : e > n ? r - 1 : i;
|
|
2622
2628
|
}
|
|
2623
|
-
},
|
|
2624
|
-
let t = e.querySelector(`[${
|
|
2629
|
+
}, A = (e) => {
|
|
2630
|
+
let t = e.querySelector(`[${E}]`);
|
|
2625
2631
|
if (!t) return [];
|
|
2626
|
-
let n = t.querySelectorAll(`[${
|
|
2632
|
+
let n = t.querySelectorAll(`[${D}]`);
|
|
2627
2633
|
return Array.from(n).map((e) => e.getBoundingClientRect().width);
|
|
2628
|
-
},
|
|
2634
|
+
}, j = (e, t) => {
|
|
2629
2635
|
let n = t.reduce((e, t) => e + t, 0), r = e;
|
|
2630
|
-
r.style.width = `${n + 1}px`, e.querySelectorAll(`[${
|
|
2631
|
-
e.querySelectorAll(`[${
|
|
2636
|
+
r.style.width = `${n + 1}px`, e.querySelectorAll(`[${E}]`).forEach((e) => {
|
|
2637
|
+
e.querySelectorAll(`[${D}]`).forEach((e, n) => {
|
|
2632
2638
|
if (n < t.length) {
|
|
2633
2639
|
let r = e;
|
|
2634
2640
|
r.style.width = `${t[n]}px`;
|
|
2635
2641
|
}
|
|
2636
2642
|
});
|
|
2637
2643
|
});
|
|
2638
|
-
},
|
|
2639
|
-
let n = Array.from(e.querySelectorAll(`[${
|
|
2644
|
+
}, wr = (e, t) => {
|
|
2645
|
+
let n = Array.from(e.querySelectorAll(`[${E}]`)), r = n.findIndex((e) => Array.from(e.querySelectorAll(`[${D}]`)).includes(t));
|
|
2640
2646
|
return r === -1 ? null : {
|
|
2641
2647
|
row: r,
|
|
2642
|
-
col: Array.from(n[r].querySelectorAll(`[${
|
|
2648
|
+
col: Array.from(n[r].querySelectorAll(`[${D}]`)).indexOf(t)
|
|
2643
2649
|
};
|
|
2644
|
-
},
|
|
2650
|
+
}, Tr = (e) => {
|
|
2645
2651
|
var t;
|
|
2646
|
-
let n = e.querySelector(`[${
|
|
2652
|
+
let n = e.querySelector(`[${k}]`);
|
|
2647
2653
|
return n ? ((t = n.textContent) == null ? "" : t).trim().length === 0 : !0;
|
|
2648
|
-
}, Tr = (e, t) => {
|
|
2649
|
-
let n = e.querySelectorAll(`[${T}]`)[t];
|
|
2650
|
-
if (!n) return !0;
|
|
2651
|
-
let r = n.querySelectorAll(`[${E}]`);
|
|
2652
|
-
return Array.from(r).every((e) => wr(e));
|
|
2653
2654
|
}, Er = (e, t) => {
|
|
2654
|
-
let n = e.querySelectorAll(`[${
|
|
2655
|
+
let n = e.querySelectorAll(`[${E}]`)[t];
|
|
2656
|
+
if (!n) return !0;
|
|
2657
|
+
let r = n.querySelectorAll(`[${D}]`);
|
|
2658
|
+
return Array.from(r).every((e) => Tr(e));
|
|
2659
|
+
}, Dr = (e, t) => {
|
|
2660
|
+
let n = e.querySelectorAll(`[${E}]`);
|
|
2655
2661
|
return Array.from(n).every((e) => {
|
|
2656
|
-
let n = e.querySelectorAll(`[${
|
|
2657
|
-
return !n ||
|
|
2662
|
+
let n = e.querySelectorAll(`[${D}]`)[t];
|
|
2663
|
+
return !n || Tr(n);
|
|
2658
2664
|
});
|
|
2659
|
-
},
|
|
2660
|
-
let t = e.querySelectorAll(`[${
|
|
2665
|
+
}, Or = (e) => {
|
|
2666
|
+
let t = e.querySelectorAll(`[${E}]`), n = t[0];
|
|
2661
2667
|
if (!n) return;
|
|
2662
|
-
let r = n.querySelectorAll(`[${
|
|
2668
|
+
let r = n.querySelectorAll(`[${D}]`), i = Array.from(r).reduce((e, t) => e + (parseFloat(t.style.width) || 0), 0);
|
|
2663
2669
|
if (i <= 0) return;
|
|
2664
2670
|
let a = 100 / i;
|
|
2665
2671
|
t.forEach((e) => {
|
|
2666
|
-
e.querySelectorAll(`[${
|
|
2672
|
+
e.querySelectorAll(`[${D}]`).forEach((e) => {
|
|
2667
2673
|
let t = e, n = parseFloat(t.style.width) || 0;
|
|
2668
2674
|
t.style.width = `${Math.round(n * a * 100) / 100}%`;
|
|
2669
2675
|
});
|
|
2670
2676
|
});
|
|
2671
|
-
},
|
|
2677
|
+
}, kr = (e, t, n) => {
|
|
2672
2678
|
if (!e) return e;
|
|
2673
2679
|
let r = [...e], [i] = r.splice(t, 1);
|
|
2674
2680
|
return r.splice(n, 0, i), r;
|
|
2675
|
-
},
|
|
2681
|
+
}, Ar = (e, t) => {
|
|
2676
2682
|
if (!e) return e;
|
|
2677
2683
|
let n = [...e];
|
|
2678
2684
|
return n.splice(t, 1), n.length > 0 ? n : void 0;
|
|
2679
|
-
},
|
|
2680
|
-
let a = n == null ?
|
|
2685
|
+
}, jr = (e, t, n, r, i) => {
|
|
2686
|
+
let a = n == null ? A(e) : n, o = r === void 0 ? M(a) : Math.round(r / 2 * 100) / 100;
|
|
2681
2687
|
i.addColumn(e, t, a, o);
|
|
2682
2688
|
let s = [...a];
|
|
2683
2689
|
return s.splice(t, 0, o), s;
|
|
2684
|
-
},
|
|
2690
|
+
}, M = (e) => Math.round(e.reduce((e, t) => e + t, 0) / e.length / 2 * 100) / 100, Mr = (e) => e.length === 0 ? 0 : Math.round(e.reduce((e, t) => e + t, 0) / e.length * 100) / 100, Nr = (e, t, n) => {
|
|
2685
2691
|
var r;
|
|
2686
2692
|
if (!e) return [];
|
|
2687
|
-
let i = e.querySelectorAll(`[${
|
|
2693
|
+
let i = e.querySelectorAll(`[${E}]`)[n];
|
|
2688
2694
|
return i ? (r = t == null ? void 0 : t.getBlockIdsFromCells(i.querySelectorAll("[data-blok-table-cell]"))) == null ? [] : r : [];
|
|
2689
|
-
},
|
|
2695
|
+
}, Pr = (e, t, n) => {
|
|
2690
2696
|
var r;
|
|
2691
2697
|
if (!e) return [];
|
|
2692
|
-
let i = e.querySelectorAll(`[${
|
|
2698
|
+
let i = e.querySelectorAll(`[${E}]`), a = [];
|
|
2693
2699
|
return i.forEach((e) => {
|
|
2694
|
-
let t = e.querySelectorAll(`[${
|
|
2700
|
+
let t = e.querySelectorAll(`[${D}]`);
|
|
2695
2701
|
n < t.length && a.push(t[n]);
|
|
2696
2702
|
}), (r = t == null ? void 0 : t.getBlockIdsFromCells(a)) == null ? [] : r;
|
|
2697
|
-
},
|
|
2698
|
-
e.querySelectorAll(`[${
|
|
2703
|
+
}, N = (e, t) => {
|
|
2704
|
+
e.querySelectorAll(`[${D}]`).forEach((e) => {
|
|
2699
2705
|
t == null || t.ensureCellHasBlock(e);
|
|
2700
2706
|
});
|
|
2701
|
-
},
|
|
2702
|
-
let i = e.querySelectorAll(`[${
|
|
2707
|
+
}, Fr = (e, t, n, r) => {
|
|
2708
|
+
let i = e.querySelectorAll(`[${E}]`);
|
|
2703
2709
|
t.forEach((e, t) => {
|
|
2704
2710
|
let r = i[t];
|
|
2705
2711
|
if (!r) return;
|
|
2706
|
-
let a = r.querySelectorAll(`[${
|
|
2712
|
+
let a = r.querySelectorAll(`[${D}]`);
|
|
2707
2713
|
e.forEach((e, t) => {
|
|
2708
2714
|
var r;
|
|
2709
2715
|
let i = a[t];
|
|
2710
2716
|
if (!i) return;
|
|
2711
|
-
let o = i.querySelector(`[${
|
|
2717
|
+
let o = i.querySelector(`[${k}]`);
|
|
2712
2718
|
if (!o) return;
|
|
2713
2719
|
let s = o.querySelectorAll("[data-blok-id]").length > 0;
|
|
2714
|
-
if (!(!
|
|
2715
|
-
if (!
|
|
2720
|
+
if (!(!O(e) && s)) {
|
|
2721
|
+
if (!O(e)) {
|
|
2716
2722
|
o.innerHTML = e;
|
|
2717
2723
|
return;
|
|
2718
2724
|
}
|
|
@@ -2731,7 +2737,7 @@ var sr = (e) => {
|
|
|
2731
2737
|
}
|
|
2732
2738
|
});
|
|
2733
2739
|
});
|
|
2734
|
-
},
|
|
2740
|
+
}, Ir = (e, t) => {
|
|
2735
2741
|
var n, r, i, a, o, s, c;
|
|
2736
2742
|
if (!(typeof e == "object" && e && "content" in e)) {
|
|
2737
2743
|
var l, u;
|
|
@@ -2751,40 +2757,40 @@ var sr = (e) => {
|
|
|
2751
2757
|
colWidths: m,
|
|
2752
2758
|
initialColWidth: d.initialColWidth
|
|
2753
2759
|
};
|
|
2754
|
-
},
|
|
2760
|
+
}, Lr = (e, t) => {
|
|
2755
2761
|
e.addEventListener("keydown", (n) => {
|
|
2756
|
-
let r = n.target.closest(`[${
|
|
2762
|
+
let r = n.target.closest(`[${D}]`);
|
|
2757
2763
|
if (!r) return;
|
|
2758
|
-
let i =
|
|
2764
|
+
let i = wr(e, r);
|
|
2759
2765
|
i && (t == null || t.handleKeyDown(n, i));
|
|
2760
2766
|
});
|
|
2761
|
-
},
|
|
2762
|
-
e == null || e.classList.add(...
|
|
2763
|
-
},
|
|
2767
|
+
}, Rr = ["overflow-x-auto", "overflow-y-hidden"], zr = (e) => {
|
|
2768
|
+
e == null || e.classList.add(...Rr);
|
|
2769
|
+
}, P = (e, t) => {
|
|
2764
2770
|
if (!e) return;
|
|
2765
|
-
let n = e.querySelectorAll(`[${
|
|
2771
|
+
let n = e.querySelectorAll(`[${E}]`);
|
|
2766
2772
|
n.forEach((e) => {
|
|
2767
2773
|
e.removeAttribute("data-blok-table-heading");
|
|
2768
2774
|
}), t && n.length > 0 && n[0].setAttribute("data-blok-table-heading", "");
|
|
2769
|
-
},
|
|
2770
|
-
let n = e.querySelectorAll(`[${
|
|
2775
|
+
}, F = (e, t) => {
|
|
2776
|
+
let n = e.querySelectorAll(`[${E}]`);
|
|
2771
2777
|
t.forEach((e, t) => {
|
|
2772
2778
|
if (t >= n.length) return;
|
|
2773
|
-
let r = n[t].querySelectorAll(`[${
|
|
2779
|
+
let r = n[t].querySelectorAll(`[${D}]`);
|
|
2774
2780
|
e.forEach((e, t) => {
|
|
2775
2781
|
if (t >= r.length) return;
|
|
2776
2782
|
let n = r[t];
|
|
2777
|
-
|
|
2783
|
+
O(e) && e.color ? n.style.backgroundColor = e.color : n.style.backgroundColor = "", O(e) && e.textColor ? n.style.color = e.textColor : n.style.color = "";
|
|
2778
2784
|
});
|
|
2779
2785
|
});
|
|
2780
|
-
},
|
|
2781
|
-
e && (e.querySelectorAll(`[${
|
|
2786
|
+
}, I = (e, t) => {
|
|
2787
|
+
e && (e.querySelectorAll(`[${D}]`).forEach((e) => {
|
|
2782
2788
|
e.removeAttribute("data-blok-table-heading-col");
|
|
2783
|
-
}), t && e.querySelectorAll(`[${
|
|
2784
|
-
let t = e.querySelector(`[${
|
|
2789
|
+
}), t && e.querySelectorAll(`[${E}]`).forEach((e) => {
|
|
2790
|
+
let t = e.querySelector(`[${D}]`);
|
|
2785
2791
|
t && t.setAttribute("data-blok-table-heading-col", "");
|
|
2786
2792
|
}));
|
|
2787
|
-
},
|
|
2793
|
+
}, Br = (e) => !!(/^#[0-9a-f]{3,4}$/i.test(e) || /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e) || /^rgba?\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*(,\s*[\d.]+\s*)?\)$/i.test(e) || /^hsla?\(\s*[\d.]+\s*,\s*[\d.]+%\s*,\s*[\d.]+%\s*(,\s*[\d.]+\s*)?\)$/i.test(e) || e === "transparent"), Vr = class {
|
|
2788
2794
|
constructor(e) {
|
|
2789
2795
|
var t, n, r;
|
|
2790
2796
|
this.withHeadingsValue = (t = e == null ? void 0 : e.withHeadings) == null ? !1 : t, this.withHeadingColumnValue = (n = e == null ? void 0 : e.withHeadingColumn) == null ? !1 : n, this.stretchedValue = (r = e == null ? void 0 : e.stretched) == null ? !1 : r, this.colWidthsValue = e != null && e.colWidths ? [...e.colWidths] : void 0, this.initialColWidthValue = e == null ? void 0 : e.initialColWidth, this.contentGrid = this.normalizeContent(e == null ? void 0 : e.content), this.blockCellMap = /* @__PURE__ */ new Map(), this.rebuildBlockCellMap();
|
|
@@ -2857,13 +2863,13 @@ var sr = (e) => {
|
|
|
2857
2863
|
return this.isInBounds(e, t) ? [...this.contentGrid[e][t].blocks] : [];
|
|
2858
2864
|
}
|
|
2859
2865
|
setCellColor(e, t, n) {
|
|
2860
|
-
this.isInBounds(e, t) && (n === void 0 ? delete this.contentGrid[e][t].color :
|
|
2866
|
+
this.isInBounds(e, t) && (n === void 0 ? delete this.contentGrid[e][t].color : Br(n) && (this.contentGrid[e][t].color = n));
|
|
2861
2867
|
}
|
|
2862
2868
|
getCellColor(e, t) {
|
|
2863
2869
|
if (this.isInBounds(e, t)) return this.contentGrid[e][t].color;
|
|
2864
2870
|
}
|
|
2865
2871
|
setCellTextColor(e, t, n) {
|
|
2866
|
-
this.isInBounds(e, t) && (n === void 0 ? delete this.contentGrid[e][t].textColor :
|
|
2872
|
+
this.isInBounds(e, t) && (n === void 0 ? delete this.contentGrid[e][t].textColor : Br(n) && (this.contentGrid[e][t].textColor = n));
|
|
2867
2873
|
}
|
|
2868
2874
|
getCellTextColor(e, t) {
|
|
2869
2875
|
if (this.isInBounds(e, t)) return this.contentGrid[e][t].textColor;
|
|
@@ -3001,9 +3007,9 @@ var sr = (e) => {
|
|
|
3001
3007
|
return !e || !Array.isArray(e) ? [] : e.map((e) => (e == null ? [] : e).map((e) => this.normalizeCell(e)));
|
|
3002
3008
|
}
|
|
3003
3009
|
normalizeCell(e) {
|
|
3004
|
-
if (
|
|
3010
|
+
if (O(e)) {
|
|
3005
3011
|
let t = { blocks: [...e.blocks] };
|
|
3006
|
-
return e.color !== void 0 &&
|
|
3012
|
+
return e.color !== void 0 && Br(e.color) && (t.color = e.color), e.textColor !== void 0 && Br(e.textColor) && (t.textColor = e.textColor), t;
|
|
3007
3013
|
}
|
|
3008
3014
|
return { blocks: [] };
|
|
3009
3015
|
}
|
|
@@ -3036,7 +3042,7 @@ var sr = (e) => {
|
|
|
3036
3042
|
for (let n of this.contentGrid) e < n.length && t.push(...n[e].blocks);
|
|
3037
3043
|
return t;
|
|
3038
3044
|
}
|
|
3039
|
-
},
|
|
3045
|
+
}, Hr = "data-blok-table-resize", Ur = "data-blok-table-cell", Wr = "data-blok-table-row", Gr = 50, Kr = 16, qr = class {
|
|
3040
3046
|
get enabled() {
|
|
3041
3047
|
return this._enabled;
|
|
3042
3048
|
}
|
|
@@ -3063,7 +3069,7 @@ var sr = (e) => {
|
|
|
3063
3069
|
}
|
|
3064
3070
|
createHandle(e) {
|
|
3065
3071
|
let t = document.createElement("div"), n = this.getHandleLeftPx(e);
|
|
3066
|
-
return t.setAttribute(
|
|
3072
|
+
return t.setAttribute(Hr, ""), t.setAttribute("data-col", String(e)), t.style.position = "absolute", t.style.top = "-1px", t.style.bottom = "0px", t.style.width = `${Kr}px`, t.style.left = `${n - Kr / 2}px`, t.style.cursor = "col-resize", t.style.zIndex = "2", t.style.background = "linear-gradient(to right, transparent 7px, #3b82f6 7px, #3b82f6 9px, transparent 9px)", t.style.opacity = "0", t.style.transition = "opacity 150ms ease", t.setAttribute("contenteditable", "false"), t.addEventListener("mouseenter", () => {
|
|
3067
3073
|
this.isDragging || (t.style.opacity = "1");
|
|
3068
3074
|
}), t.addEventListener("mouseleave", () => {
|
|
3069
3075
|
this.isDragging || (t.style.opacity = "0");
|
|
@@ -3075,14 +3081,14 @@ var sr = (e) => {
|
|
|
3075
3081
|
updateHandlePositions() {
|
|
3076
3082
|
this.handles.forEach((e, t) => {
|
|
3077
3083
|
let n = this.getHandleLeftPx(t), r = e;
|
|
3078
|
-
r.style.left = `${n -
|
|
3084
|
+
r.style.left = `${n - Kr / 2}px`;
|
|
3079
3085
|
});
|
|
3080
3086
|
}
|
|
3081
3087
|
onPointerDown(e) {
|
|
3082
3088
|
var t;
|
|
3083
3089
|
if (!this._enabled) return;
|
|
3084
3090
|
let n = e.target;
|
|
3085
|
-
if (!n.hasAttribute(
|
|
3091
|
+
if (!n.hasAttribute(Hr)) return;
|
|
3086
3092
|
e.preventDefault(), this.needsInitialApply && (this.applyWidths(), this.updateHandlePositions(), this.needsInitialApply = !1);
|
|
3087
3093
|
let r = n.getAttribute("data-col");
|
|
3088
3094
|
r !== null && (this.dragColIndex = Number(r), this.isDragging = !0, this.dragStartX = e.clientX, this.startColWidth = this.colWidths[this.dragColIndex], this.dragRowCells = this.resolveRowCells(), (t = this.onDragStart) == null || t.call(this), this.gridEl.style.userSelect = "none", n.style.opacity = "1", n.setPointerCapture && n.setPointerCapture(e.pointerId), document.addEventListener("pointermove", this.boundPointerMove), document.addEventListener("pointerup", this.boundPointerUp));
|
|
@@ -3090,7 +3096,7 @@ var sr = (e) => {
|
|
|
3090
3096
|
onPointerMove(e) {
|
|
3091
3097
|
var t, n;
|
|
3092
3098
|
if (!this.isDragging) return;
|
|
3093
|
-
let r = e.clientX - this.dragStartX, i = this.startColWidth + r, a = Math.max(
|
|
3099
|
+
let r = e.clientX - this.dragStartX, i = this.startColWidth + r, a = Math.max(Gr, i);
|
|
3094
3100
|
this.colWidths[this.dragColIndex] = a, this.applyWidths((t = this.dragRowCells) == null ? void 0 : t), this.updateHandlePositions(), (n = this.onDrag) == null || n.call(this);
|
|
3095
3101
|
}
|
|
3096
3102
|
onPointerUp() {
|
|
@@ -3100,8 +3106,8 @@ var sr = (e) => {
|
|
|
3100
3106
|
e && (e.style.opacity = "0"), document.removeEventListener("pointermove", this.boundPointerMove), document.removeEventListener("pointerup", this.boundPointerUp), this.dragRowCells = null, this.onChange([...this.colWidths]);
|
|
3101
3107
|
}
|
|
3102
3108
|
resolveRowCells() {
|
|
3103
|
-
let e = this.gridEl.querySelectorAll(`[${
|
|
3104
|
-
return Array.from(e, (e) => Array.from(e.querySelectorAll(`[${
|
|
3109
|
+
let e = this.gridEl.querySelectorAll(`[${Wr}]`);
|
|
3110
|
+
return Array.from(e, (e) => Array.from(e.querySelectorAll(`[${Ur}]`)));
|
|
3105
3111
|
}
|
|
3106
3112
|
applyWidths(e = this.resolveRowCells()) {
|
|
3107
3113
|
let t = this.colWidths.reduce((e, t) => e + t, 0);
|
|
@@ -3111,7 +3117,7 @@ var sr = (e) => {
|
|
|
3111
3117
|
});
|
|
3112
3118
|
});
|
|
3113
3119
|
}
|
|
3114
|
-
},
|
|
3120
|
+
}, Jr = (e, t, n) => (n.grid.addRow(e, t), N(e, n.cellBlocks), {
|
|
3115
3121
|
pendingHighlight: {
|
|
3116
3122
|
type: "row",
|
|
3117
3123
|
index: t
|
|
@@ -3120,9 +3126,9 @@ var sr = (e) => {
|
|
|
3120
3126
|
colWidths: n.data.colWidths,
|
|
3121
3127
|
withHeadings: n.data.withHeadings,
|
|
3122
3128
|
withHeadingColumn: n.data.withHeadingColumn
|
|
3123
|
-
}),
|
|
3124
|
-
let r =
|
|
3125
|
-
return
|
|
3129
|
+
}), Yr = (e, t, n) => {
|
|
3130
|
+
let r = jr(e, t, n.data.colWidths, n.data.initialColWidth, n.grid);
|
|
3131
|
+
return N(e, n.cellBlocks), {
|
|
3126
3132
|
pendingHighlight: {
|
|
3127
3133
|
type: "col",
|
|
3128
3134
|
index: t
|
|
@@ -3132,7 +3138,7 @@ var sr = (e) => {
|
|
|
3132
3138
|
withHeadings: n.data.withHeadings,
|
|
3133
3139
|
withHeadingColumn: n.data.withHeadingColumn
|
|
3134
3140
|
};
|
|
3135
|
-
},
|
|
3141
|
+
}, Xr = (e, t, n, r) => (r.grid.moveRow(e, t, n), {
|
|
3136
3142
|
pendingHighlight: null,
|
|
3137
3143
|
moveSelection: {
|
|
3138
3144
|
type: "row",
|
|
@@ -3141,16 +3147,16 @@ var sr = (e) => {
|
|
|
3141
3147
|
colWidths: r.data.colWidths,
|
|
3142
3148
|
withHeadings: r.data.withHeadings,
|
|
3143
3149
|
withHeadingColumn: r.data.withHeadingColumn
|
|
3144
|
-
}),
|
|
3150
|
+
}), Zr = (e, t, n, r) => (r.grid.moveColumn(e, t, n), {
|
|
3145
3151
|
pendingHighlight: null,
|
|
3146
3152
|
moveSelection: {
|
|
3147
3153
|
type: "col",
|
|
3148
3154
|
index: n
|
|
3149
3155
|
},
|
|
3150
|
-
colWidths:
|
|
3156
|
+
colWidths: kr(r.data.colWidths, t, n),
|
|
3151
3157
|
withHeadings: r.data.withHeadings,
|
|
3152
3158
|
withHeadingColumn: r.data.withHeadingColumn
|
|
3153
|
-
}),
|
|
3159
|
+
}), Qr = (e, t, n) => {
|
|
3154
3160
|
var r, i;
|
|
3155
3161
|
return (r = n.cellBlocks) == null || r.deleteBlocks((i = n.blocksToDelete) == null ? [] : i), n.grid.deleteRow(e, t), {
|
|
3156
3162
|
pendingHighlight: {
|
|
@@ -3162,11 +3168,11 @@ var sr = (e) => {
|
|
|
3162
3168
|
withHeadings: n.data.withHeadings,
|
|
3163
3169
|
withHeadingColumn: n.data.withHeadingColumn
|
|
3164
3170
|
};
|
|
3165
|
-
},
|
|
3171
|
+
}, $r = (e, t, n) => {
|
|
3166
3172
|
var r, i;
|
|
3167
3173
|
(r = n.cellBlocks) == null || r.deleteBlocks((i = n.blocksToDelete) == null ? [] : i), n.grid.deleteColumn(e, t);
|
|
3168
|
-
let a =
|
|
3169
|
-
return a ?
|
|
3174
|
+
let a = Ar(n.data.colWidths, t);
|
|
3175
|
+
return a ? j(e, a) : Or(e), {
|
|
3170
3176
|
pendingHighlight: {
|
|
3171
3177
|
type: "col",
|
|
3172
3178
|
index: t < n.grid.getColumnCount(e) ? t : t - 1
|
|
@@ -3176,16 +3182,16 @@ var sr = (e) => {
|
|
|
3176
3182
|
withHeadings: n.data.withHeadings,
|
|
3177
3183
|
withHeadingColumn: n.data.withHeadingColumn
|
|
3178
3184
|
};
|
|
3179
|
-
},
|
|
3185
|
+
}, ei = (e, t, n) => {
|
|
3180
3186
|
switch (t.type) {
|
|
3181
|
-
case "insert-row-above": return
|
|
3182
|
-
case "insert-row-below": return
|
|
3183
|
-
case "insert-col-left": return
|
|
3184
|
-
case "insert-col-right": return
|
|
3185
|
-
case "move-row": return
|
|
3186
|
-
case "move-col": return
|
|
3187
|
-
case "delete-row": return
|
|
3188
|
-
case "delete-col": return
|
|
3187
|
+
case "insert-row-above": return Jr(e, t.index, n);
|
|
3188
|
+
case "insert-row-below": return Jr(e, t.index + 1, n);
|
|
3189
|
+
case "insert-col-left": return Yr(e, t.index, n);
|
|
3190
|
+
case "insert-col-right": return Yr(e, t.index + 1, n);
|
|
3191
|
+
case "move-row": return Xr(e, t.fromIndex, t.toIndex, n);
|
|
3192
|
+
case "move-col": return Zr(e, t.fromIndex, t.toIndex, n);
|
|
3193
|
+
case "delete-row": return Qr(e, t.index, n);
|
|
3194
|
+
case "delete-col": return $r(e, t.index, n);
|
|
3189
3195
|
case "toggle-heading": return {
|
|
3190
3196
|
pendingHighlight: {
|
|
3191
3197
|
type: "row",
|
|
@@ -3207,13 +3213,13 @@ var sr = (e) => {
|
|
|
3207
3213
|
withHeadingColumn: !n.data.withHeadingColumn
|
|
3208
3214
|
};
|
|
3209
3215
|
}
|
|
3210
|
-
},
|
|
3211
|
-
let t = e.querySelector(`[${
|
|
3212
|
-
return t ? Array.from(t.querySelectorAll(`[${
|
|
3216
|
+
}, ti = 10, ni = "data-blok-table-drag-ghost", ri = (e) => {
|
|
3217
|
+
let t = e.querySelector(`[${E}]`);
|
|
3218
|
+
return t ? Array.from(t.querySelectorAll(`[${D}]`)).reduce((e, t) => {
|
|
3213
3219
|
let n = e[e.length - 1];
|
|
3214
3220
|
return [...e, n + t.offsetWidth];
|
|
3215
3221
|
}, [0]) : [0];
|
|
3216
|
-
},
|
|
3222
|
+
}, ii = class {
|
|
3217
3223
|
constructor(e) {
|
|
3218
3224
|
var t;
|
|
3219
3225
|
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 = e.grid, this.onAction = e.onAction, this.onDragStateChange = (t = e.onDragStateChange) == null ? null : t, this.boundDocPointerMove = this.handleDocPointerMove.bind(this), this.boundDocPointerUp = this.handleDocPointerUp.bind(this), this.boundDocPointerCancel = this.handleDocPointerCancel.bind(this);
|
|
@@ -3232,7 +3238,7 @@ var sr = (e) => {
|
|
|
3232
3238
|
}
|
|
3233
3239
|
handleDocPointerMove(e) {
|
|
3234
3240
|
let t = Math.abs(e.clientX - this.dragStartX), n = Math.abs(e.clientY - this.dragStartY);
|
|
3235
|
-
!this.isDragging && (t >
|
|
3241
|
+
!this.isDragging && (t > ti || n > ti) && (this.isDragging = !0, this.startDrag()), this.isDragging && (this.updateDragIndicator(e), this.updateGhostPosition(e));
|
|
3236
3242
|
}
|
|
3237
3243
|
handleDocPointerUp(e) {
|
|
3238
3244
|
if (document.removeEventListener("pointermove", this.boundDocPointerMove), document.removeEventListener("pointerup", this.boundDocPointerUp), document.removeEventListener("pointercancel", this.boundDocPointerCancel), this.isDragging) {
|
|
@@ -3253,7 +3259,7 @@ var sr = (e) => {
|
|
|
3253
3259
|
this.grid.style.userSelect = "none", document.body.style.cursor = "grabbing", (e = this.onDragStateChange) == null || e.call(this, !0, this.dragType), this.highlightSourceCells(), this.createDropIndicator(), this.createGhost();
|
|
3254
3260
|
}
|
|
3255
3261
|
highlightSourceCells() {
|
|
3256
|
-
let e = this.grid.querySelectorAll(`[${
|
|
3262
|
+
let e = this.grid.querySelectorAll(`[${E}]`);
|
|
3257
3263
|
if (this.dragType === "row") {
|
|
3258
3264
|
this.highlightRowCells(e);
|
|
3259
3265
|
return;
|
|
@@ -3264,7 +3270,7 @@ var sr = (e) => {
|
|
|
3264
3270
|
let t = e[this.dragFromIndex];
|
|
3265
3271
|
if (!t) return;
|
|
3266
3272
|
let n = this.getDragSourceBg();
|
|
3267
|
-
t.querySelectorAll(`[${
|
|
3273
|
+
t.querySelectorAll(`[${D}]`).forEach((e) => {
|
|
3268
3274
|
let t = e;
|
|
3269
3275
|
t.style.backgroundColor = n, t.style.opacity = "0.7", this.dragOverlayCells.push(t);
|
|
3270
3276
|
});
|
|
@@ -3272,7 +3278,7 @@ var sr = (e) => {
|
|
|
3272
3278
|
highlightColumnCells(e) {
|
|
3273
3279
|
let t = this.getDragSourceBg();
|
|
3274
3280
|
e.forEach((e) => {
|
|
3275
|
-
let n = e.querySelectorAll(`[${
|
|
3281
|
+
let n = e.querySelectorAll(`[${D}]`);
|
|
3276
3282
|
if (this.dragFromIndex >= n.length) return;
|
|
3277
3283
|
let r = n[this.dragFromIndex];
|
|
3278
3284
|
r.style.backgroundColor = t, r.style.opacity = "0.7", this.dragOverlayCells.push(r);
|
|
@@ -3291,7 +3297,7 @@ var sr = (e) => {
|
|
|
3291
3297
|
let e = this.dropIndicator.style;
|
|
3292
3298
|
if (e.position = "absolute", e.backgroundColor = "#3b82f6", e.borderRadius = "1.5px", e.zIndex = "5", e.pointerEvents = "none", this.dropIndicator.setAttribute("contenteditable", "false"), this.dragType === "row") e.height = "3px", e.left = "-1px", e.right = "0", e.transition = "top 100ms ease";
|
|
3293
3299
|
else {
|
|
3294
|
-
let t = this.grid.querySelectorAll(`[${
|
|
3300
|
+
let t = this.grid.querySelectorAll(`[${E}]`), n = t[t.length - 1], r = n ? n.offsetTop + n.offsetHeight : 0;
|
|
3295
3301
|
e.width = "3px", e.top = "-1px", e.height = `${r + 1}px`, e.transition = "left 100ms ease";
|
|
3296
3302
|
}
|
|
3297
3303
|
this.grid.appendChild(this.dropIndicator);
|
|
@@ -3313,7 +3319,7 @@ var sr = (e) => {
|
|
|
3313
3319
|
updateColIndicator(e, t) {
|
|
3314
3320
|
var n;
|
|
3315
3321
|
if (!this.dropIndicator) return;
|
|
3316
|
-
let r = e.clientX - t.left, i = this.getColDropIndex(r), a =
|
|
3322
|
+
let r = e.clientX - t.left, i = this.getColDropIndex(r), a = ri(this.grid);
|
|
3317
3323
|
this.dropIndicator.style.left = `${((n = a[i]) == null ? 0 : n) - 1.5}px`;
|
|
3318
3324
|
}
|
|
3319
3325
|
finishDrag(e) {
|
|
@@ -3342,7 +3348,7 @@ var sr = (e) => {
|
|
|
3342
3348
|
}
|
|
3343
3349
|
createGhost() {
|
|
3344
3350
|
let e = document.createElement("div");
|
|
3345
|
-
e.setAttribute(
|
|
3351
|
+
e.setAttribute(ni, ""), e.setAttribute("contenteditable", "false");
|
|
3346
3352
|
let t = e.style;
|
|
3347
3353
|
t.position = "fixed", t.pointerEvents = "none", t.opacity = "0.5", t.zIndex = "50", t.borderRadius = "4px", t.overflow = "hidden", t.boxShadow = this.isDarkMode() ? "0 8px 24px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08)" : "0 4px 12px rgba(0, 0, 0, 0.15)", this.ghostEl = e;
|
|
3348
3354
|
let n = this.getSourceRect();
|
|
@@ -3353,22 +3359,22 @@ var sr = (e) => {
|
|
|
3353
3359
|
}
|
|
3354
3360
|
getRowSourceRect() {
|
|
3355
3361
|
var e;
|
|
3356
|
-
let t = this.grid.querySelectorAll(`[${
|
|
3362
|
+
let t = this.grid.querySelectorAll(`[${E}]`)[this.dragFromIndex];
|
|
3357
3363
|
return (e = t == null ? void 0 : t.getBoundingClientRect()) == null ? null : e;
|
|
3358
3364
|
}
|
|
3359
3365
|
getColSourceRect() {
|
|
3360
|
-
let e = this.grid.querySelectorAll(`[${
|
|
3366
|
+
let e = this.grid.querySelectorAll(`[${E}]`), t = e[0], n = e[e.length - 1];
|
|
3361
3367
|
if (!t || !n) return null;
|
|
3362
|
-
let r = t.querySelectorAll(`[${
|
|
3368
|
+
let r = t.querySelectorAll(`[${D}]`)[this.dragFromIndex], i = n.querySelectorAll(`[${D}]`)[this.dragFromIndex];
|
|
3363
3369
|
if (!r || !i) return null;
|
|
3364
3370
|
let a = r.getBoundingClientRect(), o = i.getBoundingClientRect();
|
|
3365
3371
|
return new DOMRect(a.left, a.top, a.width, o.bottom - a.top);
|
|
3366
3372
|
}
|
|
3367
3373
|
buildRowGhost() {
|
|
3368
|
-
let e = this.grid.querySelectorAll(`[${
|
|
3374
|
+
let e = this.grid.querySelectorAll(`[${E}]`)[this.dragFromIndex];
|
|
3369
3375
|
if (!e || !this.ghostEl) return;
|
|
3370
3376
|
let t = this.ghostEl.style;
|
|
3371
|
-
t.display = "flex", t.height = `${e.offsetHeight}px`, e.querySelectorAll(`[${
|
|
3377
|
+
t.display = "flex", t.height = `${e.offsetHeight}px`, e.querySelectorAll(`[${D}]`).forEach((e) => {
|
|
3372
3378
|
var t;
|
|
3373
3379
|
let n = e, r = n.cloneNode(!0);
|
|
3374
3380
|
r.style.width = `${n.offsetWidth}px`, r.style.flexShrink = "0", r.removeAttribute("contenteditable"), (t = this.ghostEl) == null || t.appendChild(r);
|
|
@@ -3376,10 +3382,10 @@ var sr = (e) => {
|
|
|
3376
3382
|
}
|
|
3377
3383
|
buildColumnGhost() {
|
|
3378
3384
|
if (!this.ghostEl) return;
|
|
3379
|
-
let e = this.grid.querySelectorAll(`[${
|
|
3385
|
+
let e = this.grid.querySelectorAll(`[${E}]`), t = this.ghostEl.style;
|
|
3380
3386
|
t.display = "flex", t.flexDirection = "column", e.forEach((e) => {
|
|
3381
3387
|
var t;
|
|
3382
|
-
let n = e.querySelectorAll(`[${
|
|
3388
|
+
let n = e.querySelectorAll(`[${D}]`);
|
|
3383
3389
|
if (this.dragFromIndex >= n.length) return;
|
|
3384
3390
|
let r = n[this.dragFromIndex], i = r.cloneNode(!0);
|
|
3385
3391
|
i.style.width = `${r.offsetWidth}px`, i.style.height = `${r.offsetHeight}px`, i.removeAttribute("contenteditable"), (t = this.ghostEl) == null || t.appendChild(i);
|
|
@@ -3391,7 +3397,7 @@ var sr = (e) => {
|
|
|
3391
3397
|
this.dragType === "row" && (t.top = `${e.clientY - this.ghostOffsetY}px`), this.dragType === "col" && (t.left = `${e.clientX - this.ghostOffsetX}px`);
|
|
3392
3398
|
}
|
|
3393
3399
|
getRowDropIndex(e) {
|
|
3394
|
-
let t = Array.from(this.grid.querySelectorAll(`[${
|
|
3400
|
+
let t = Array.from(this.grid.querySelectorAll(`[${E}]`)), n = t.map((e) => e.offsetTop);
|
|
3395
3401
|
if (t.length > 0) {
|
|
3396
3402
|
let e = t[t.length - 1];
|
|
3397
3403
|
n.push(e.offsetTop + e.offsetHeight);
|
|
@@ -3400,7 +3406,7 @@ var sr = (e) => {
|
|
|
3400
3406
|
return r.indexOf(i);
|
|
3401
3407
|
}
|
|
3402
3408
|
getRowDropTopPx(e) {
|
|
3403
|
-
let t = this.grid.querySelectorAll(`[${
|
|
3409
|
+
let t = this.grid.querySelectorAll(`[${E}]`);
|
|
3404
3410
|
if (e < t.length) return t[e].offsetTop;
|
|
3405
3411
|
if (t.length > 0) {
|
|
3406
3412
|
let e = t[t.length - 1];
|
|
@@ -3409,10 +3415,10 @@ var sr = (e) => {
|
|
|
3409
3415
|
return 0;
|
|
3410
3416
|
}
|
|
3411
3417
|
getColDropIndex(e) {
|
|
3412
|
-
let t =
|
|
3418
|
+
let t = ri(this.grid).map((t) => Math.abs(e - t)), n = Math.min(...t);
|
|
3413
3419
|
return t.indexOf(n);
|
|
3414
3420
|
}
|
|
3415
|
-
},
|
|
3421
|
+
}, ai = [
|
|
3416
3422
|
"flex",
|
|
3417
3423
|
"items-center",
|
|
3418
3424
|
"select-none",
|
|
@@ -3424,7 +3430,7 @@ var sr = (e) => {
|
|
|
3424
3430
|
"mb-px",
|
|
3425
3431
|
"cursor-pointer",
|
|
3426
3432
|
"can-hover:hover:bg-item-hover-bg"
|
|
3427
|
-
],
|
|
3433
|
+
], oi = [
|
|
3428
3434
|
"flex",
|
|
3429
3435
|
"items-center",
|
|
3430
3436
|
"justify-center",
|
|
@@ -3433,13 +3439,13 @@ var sr = (e) => {
|
|
|
3433
3439
|
"mr-2",
|
|
3434
3440
|
"[&_svg]:w-icon",
|
|
3435
3441
|
"[&_svg]:h-icon"
|
|
3436
|
-
],
|
|
3442
|
+
], si = [
|
|
3437
3443
|
"mr-auto",
|
|
3438
3444
|
"truncate",
|
|
3439
3445
|
"text-sm",
|
|
3440
3446
|
"font-medium",
|
|
3441
3447
|
"leading-5"
|
|
3442
|
-
],
|
|
3448
|
+
], ci = [
|
|
3443
3449
|
"relative",
|
|
3444
3450
|
"w-[30px]",
|
|
3445
3451
|
"h-[18px]",
|
|
@@ -3449,7 +3455,7 @@ var sr = (e) => {
|
|
|
3449
3455
|
"ease-out",
|
|
3450
3456
|
"shrink-0",
|
|
3451
3457
|
"ml-2"
|
|
3452
|
-
],
|
|
3458
|
+
], li = [
|
|
3453
3459
|
"absolute",
|
|
3454
3460
|
"top-[2px]",
|
|
3455
3461
|
"w-[14px]",
|
|
@@ -3459,36 +3465,36 @@ var sr = (e) => {
|
|
|
3459
3465
|
"transition-[left]",
|
|
3460
3466
|
"duration-[220ms]",
|
|
3461
3467
|
"[transition-timing-function:cubic-bezier(0.34,1.56,0.64,1)]"
|
|
3462
|
-
],
|
|
3468
|
+
], ui = (e) => {
|
|
3463
3469
|
let { icon: t, label: n, isActive: r, onToggle: i } = e, a = { active: r }, o = document.createElement("div");
|
|
3464
|
-
o.className =
|
|
3470
|
+
o.className = S(ai);
|
|
3465
3471
|
let s = document.createElement("div");
|
|
3466
|
-
s.className =
|
|
3472
|
+
s.className = S(oi), s.innerHTML = t, o.appendChild(s);
|
|
3467
3473
|
let c = document.createElement("span");
|
|
3468
|
-
c.className =
|
|
3474
|
+
c.className = S(si), c.textContent = n, o.appendChild(c);
|
|
3469
3475
|
let l = document.createElement("div");
|
|
3470
|
-
l.className =
|
|
3476
|
+
l.className = S(ci);
|
|
3471
3477
|
let u = document.createElement("div");
|
|
3472
|
-
u.className =
|
|
3478
|
+
u.className = S(li), l.appendChild(u), o.appendChild(l);
|
|
3473
3479
|
let d = () => {
|
|
3474
3480
|
l.style.backgroundColor = a.active ? "var(--blok-toggle-on-bg)" : "var(--blok-toggle-off-bg)", u.style.left = a.active ? "14px" : "2px", u.style.backgroundColor = a.active ? "var(--blok-toggle-thumb-on-bg)" : "", u.style.boxShadow = a.active ? "0 1px 3px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.04)" : "0 1px 3px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.06)";
|
|
3475
3481
|
};
|
|
3476
3482
|
return d(), o.addEventListener("click", (e) => {
|
|
3477
3483
|
e.stopPropagation(), a.active = !a.active, d(), i(a.active);
|
|
3478
3484
|
}), o;
|
|
3479
|
-
},
|
|
3485
|
+
}, di = (e, t) => {
|
|
3480
3486
|
let n = e === 0 ? [{
|
|
3481
|
-
type:
|
|
3482
|
-
element:
|
|
3483
|
-
icon:
|
|
3487
|
+
type: p.Html,
|
|
3488
|
+
element: ui({
|
|
3489
|
+
icon: $e,
|
|
3484
3490
|
label: t.i18n.t("tools.table.headerColumn"),
|
|
3485
3491
|
isActive: t.isHeadingColumn(),
|
|
3486
3492
|
onToggle: () => {
|
|
3487
3493
|
t.onAction({ type: "toggle-heading-column" });
|
|
3488
3494
|
}
|
|
3489
3495
|
})
|
|
3490
|
-
}, { type:
|
|
3491
|
-
icon:
|
|
3496
|
+
}, { type: p.Separator }] : [], r = [{
|
|
3497
|
+
icon: oe,
|
|
3492
3498
|
title: t.i18n.t("tools.table.insertColumnLeft"),
|
|
3493
3499
|
closeOnActivate: !0,
|
|
3494
3500
|
onActivate: () => {
|
|
@@ -3498,7 +3504,7 @@ var sr = (e) => {
|
|
|
3498
3504
|
});
|
|
3499
3505
|
}
|
|
3500
3506
|
}, {
|
|
3501
|
-
icon:
|
|
3507
|
+
icon: le,
|
|
3502
3508
|
title: t.i18n.t("tools.table.insertColumnRight"),
|
|
3503
3509
|
closeOnActivate: !0,
|
|
3504
3510
|
onActivate: () => {
|
|
@@ -3507,8 +3513,8 @@ var sr = (e) => {
|
|
|
3507
3513
|
index: e
|
|
3508
3514
|
});
|
|
3509
3515
|
}
|
|
3510
|
-
}], i = t.getColumnCount() > 1, a = [{ type:
|
|
3511
|
-
icon:
|
|
3516
|
+
}], i = t.getColumnCount() > 1, a = [{ type: p.Separator }, {
|
|
3517
|
+
icon: ve,
|
|
3512
3518
|
title: t.i18n.t("tools.table.deleteColumn"),
|
|
3513
3519
|
isDestructive: !0,
|
|
3514
3520
|
isDisabled: !i,
|
|
@@ -3525,10 +3531,10 @@ var sr = (e) => {
|
|
|
3525
3531
|
...r,
|
|
3526
3532
|
...a
|
|
3527
3533
|
];
|
|
3528
|
-
},
|
|
3534
|
+
}, fi = (e, t) => {
|
|
3529
3535
|
let n = e === 0 ? [{
|
|
3530
|
-
type:
|
|
3531
|
-
element:
|
|
3536
|
+
type: p.Html,
|
|
3537
|
+
element: ui({
|
|
3532
3538
|
icon: r,
|
|
3533
3539
|
label: t.i18n.t("tools.table.headerRow"),
|
|
3534
3540
|
isActive: t.isHeadingRow(),
|
|
@@ -3536,8 +3542,8 @@ var sr = (e) => {
|
|
|
3536
3542
|
t.onAction({ type: "toggle-heading" });
|
|
3537
3543
|
}
|
|
3538
3544
|
})
|
|
3539
|
-
}, { type:
|
|
3540
|
-
icon:
|
|
3545
|
+
}, { type: p.Separator }] : [], i = [{
|
|
3546
|
+
icon: se,
|
|
3541
3547
|
title: t.i18n.t("tools.table.insertRowAbove"),
|
|
3542
3548
|
closeOnActivate: !0,
|
|
3543
3549
|
onActivate: () => {
|
|
@@ -3547,7 +3553,7 @@ var sr = (e) => {
|
|
|
3547
3553
|
});
|
|
3548
3554
|
}
|
|
3549
3555
|
}, {
|
|
3550
|
-
icon:
|
|
3556
|
+
icon: d,
|
|
3551
3557
|
title: t.i18n.t("tools.table.insertRowBelow"),
|
|
3552
3558
|
closeOnActivate: !0,
|
|
3553
3559
|
onActivate: () => {
|
|
@@ -3556,8 +3562,8 @@ var sr = (e) => {
|
|
|
3556
3562
|
index: e
|
|
3557
3563
|
});
|
|
3558
3564
|
}
|
|
3559
|
-
}], a = t.getRowCount() > 1, o = [{ type:
|
|
3560
|
-
icon:
|
|
3565
|
+
}], a = t.getRowCount() > 1, o = [{ type: p.Separator }, {
|
|
3566
|
+
icon: ve,
|
|
3561
3567
|
title: t.i18n.t("tools.table.deleteRow"),
|
|
3562
3568
|
isDestructive: !0,
|
|
3563
3569
|
isDisabled: !a,
|
|
@@ -3574,26 +3580,26 @@ var sr = (e) => {
|
|
|
3574
3580
|
...i,
|
|
3575
3581
|
...o
|
|
3576
3582
|
];
|
|
3577
|
-
},
|
|
3583
|
+
}, pi = (e, t, n, r, i) => {
|
|
3578
3584
|
i.destroyPopover(), i.clearHideTimeout();
|
|
3579
3585
|
let a = e === "col" ? n.col[t] : n.row[t];
|
|
3580
3586
|
if (!a) return {
|
|
3581
3587
|
popover: null,
|
|
3582
3588
|
grip: null
|
|
3583
3589
|
};
|
|
3584
|
-
let o = new
|
|
3585
|
-
items: e === "col" ?
|
|
3590
|
+
let o = new Ce({
|
|
3591
|
+
items: e === "col" ? di(t, r) : fi(t, r),
|
|
3586
3592
|
trigger: a,
|
|
3587
3593
|
flippable: !0
|
|
3588
3594
|
});
|
|
3589
|
-
return o.on(
|
|
3595
|
+
return o.on(Ye.Closed, () => {
|
|
3590
3596
|
var e;
|
|
3591
3597
|
i.destroyPopover(), i.applyVisibleClasses(a), i.scheduleHideAll(), (e = i.onGripPopoverClose) == null || e.call(i);
|
|
3592
3598
|
}), i.hideAllGripsExcept(a), i.applyActiveClasses(a), e === "col" ? a.style.height = "16px" : a.style.width = "16px", {
|
|
3593
3599
|
popover: o,
|
|
3594
3600
|
grip: a
|
|
3595
3601
|
};
|
|
3596
|
-
},
|
|
3602
|
+
}, mi = "data-blok-table-grip", hi = "data-blok-table-grip-col", gi = "data-blok-table-grip-row", _i = 150, vi = 24, yi = 4, bi = 4, xi = 20, Si = [
|
|
3597
3603
|
"absolute",
|
|
3598
3604
|
"z-3",
|
|
3599
3605
|
"rounded-sm",
|
|
@@ -3606,25 +3612,25 @@ var sr = (e) => {
|
|
|
3606
3612
|
"items-center",
|
|
3607
3613
|
"justify-center",
|
|
3608
3614
|
"overflow-hidden"
|
|
3609
|
-
],
|
|
3615
|
+
], Ci = [
|
|
3610
3616
|
"bg-gray-300",
|
|
3611
3617
|
"opacity-0",
|
|
3612
3618
|
"pointer-events-none"
|
|
3613
|
-
],
|
|
3619
|
+
], wi = [
|
|
3614
3620
|
"bg-gray-300",
|
|
3615
3621
|
"opacity-100",
|
|
3616
3622
|
"pointer-events-auto"
|
|
3617
|
-
],
|
|
3623
|
+
], Ti = [
|
|
3618
3624
|
"bg-blue-500",
|
|
3619
3625
|
"text-white",
|
|
3620
3626
|
"opacity-100",
|
|
3621
3627
|
"pointer-events-auto"
|
|
3622
|
-
],
|
|
3628
|
+
], Ei = class {
|
|
3623
3629
|
constructor(e) {
|
|
3624
3630
|
this.colGrips = [], this.rowGrips = [], this.popoverState = {
|
|
3625
3631
|
popover: null,
|
|
3626
3632
|
grip: null
|
|
3627
|
-
}, this.lockedGrip = null, this.hideTimeout = null, this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.isInsideTable = !1, this.rowResizeObserver = null, this.boundScrollHandler = null, this.grid = e.grid, this.overlay = e.overlay, this.scrollContainer = e.scrollContainer, this.getColumnCount = e.getColumnCount, this.getRowCount = e.getRowCount, this.isHeadingRow = e.isHeadingRow, this.isHeadingColumn = e.isHeadingColumn, this.onAction = e.onAction, this.onGripClick = e.onGripClick, this.onGripPopoverClose = e.onGripPopoverClose, this.i18n = e.i18n, this.drag = new
|
|
3633
|
+
}, this.lockedGrip = null, this.hideTimeout = null, this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.isInsideTable = !1, this.rowResizeObserver = null, this.boundScrollHandler = null, this.grid = e.grid, this.overlay = e.overlay, this.scrollContainer = e.scrollContainer, this.getColumnCount = e.getColumnCount, this.getRowCount = e.getRowCount, this.isHeadingRow = e.isHeadingRow, this.isHeadingColumn = e.isHeadingColumn, this.onAction = e.onAction, this.onGripClick = e.onGripClick, this.onGripPopoverClose = e.onGripPopoverClose, this.i18n = e.i18n, this.drag = new ii({
|
|
3628
3634
|
grid: this.grid,
|
|
3629
3635
|
onAction: this.onAction,
|
|
3630
3636
|
onDragStateChange: (t, n) => {
|
|
@@ -3645,7 +3651,7 @@ var sr = (e) => {
|
|
|
3645
3651
|
}
|
|
3646
3652
|
handleUnlockGrip(e) {
|
|
3647
3653
|
document.removeEventListener("pointerdown", this.boundUnlockGrip), this.lockedGrip && (this.applyIdleClasses(this.lockedGrip), this.lockedGrip = null);
|
|
3648
|
-
let t = e.target instanceof HTMLElement ? e.target : null, n = t == null ? void 0 : t.closest(`[${
|
|
3654
|
+
let t = e.target instanceof HTMLElement ? e.target : null, n = t == null ? void 0 : t.closest(`[${D}]`);
|
|
3649
3655
|
if (n) {
|
|
3650
3656
|
let e = this.getCellPosition(n);
|
|
3651
3657
|
e && (this.clearHideTimeout(), this.showColGrip(e.col), this.showRowGrip(e.row), this.isInsideTable = !0);
|
|
@@ -3692,18 +3698,18 @@ var sr = (e) => {
|
|
|
3692
3698
|
}
|
|
3693
3699
|
createGripElement(e, t) {
|
|
3694
3700
|
let n = document.createElement("div");
|
|
3695
|
-
n.className =
|
|
3696
|
-
let r = e === "col" ?
|
|
3697
|
-
return n.style.width = `${r}px`, n.style.height = `${i}px`, n.style.transform = "translate(-50%, -50%)", n.style.outline = "2px solid var(--blok-table-grip-outline, transparent)", n.appendChild(
|
|
3698
|
-
this.overlay && this.clearHideTimeout(), this.isGripInteractionLocked() ||
|
|
3701
|
+
n.className = S(Si, Ci), n.setAttribute(mi, ""), n.setAttribute(e === "col" ? hi : gi, String(t)), n.setAttribute("contenteditable", "false");
|
|
3702
|
+
let r = e === "col" ? vi : bi, i = e === "col" ? yi : xi, a = e === "col" ? yi : bi;
|
|
3703
|
+
return n.style.width = `${r}px`, n.style.height = `${i}px`, n.style.transform = "translate(-50%, -50%)", n.style.outline = "2px solid var(--blok-table-grip-outline, transparent)", n.appendChild(fr(e === "col" ? "horizontal" : "vertical")), n.addEventListener("pointerdown", this.boundPointerDown), n.addEventListener("mouseenter", () => {
|
|
3704
|
+
this.overlay && this.clearHideTimeout(), this.isGripInteractionLocked() || pr(n, e);
|
|
3699
3705
|
}), n.addEventListener("mouseleave", () => {
|
|
3700
|
-
this.isGripInteractionLocked() || (
|
|
3706
|
+
this.isGripInteractionLocked() || (mr(n, e, a), this.overlay && this.scheduleHideAll());
|
|
3701
3707
|
}), n;
|
|
3702
3708
|
}
|
|
3703
3709
|
positionGrips() {
|
|
3704
|
-
let e = this.grid.querySelectorAll(`[${
|
|
3710
|
+
let e = this.grid.querySelectorAll(`[${E}]`);
|
|
3705
3711
|
if (!e[0]) return;
|
|
3706
|
-
let t =
|
|
3712
|
+
let t = ri(this.grid), n = this.overlay && this.scrollContainer ? this.scrollContainer.scrollLeft : 0, r = this.overlay && this.scrollContainer ? this.scrollContainer.clientWidth : Infinity;
|
|
3707
3713
|
this.colGrips.forEach((e, i) => {
|
|
3708
3714
|
if (i + 1 >= t.length) return;
|
|
3709
3715
|
let a = (t[i] + t[i + 1]) / 2 - n, o = e.style;
|
|
@@ -3718,7 +3724,7 @@ var sr = (e) => {
|
|
|
3718
3724
|
var e;
|
|
3719
3725
|
(e = this.rowResizeObserver) == null || e.disconnect(), this.rowResizeObserver = new ResizeObserver(() => {
|
|
3720
3726
|
this.positionGrips();
|
|
3721
|
-
}), this.grid.querySelectorAll(`[${
|
|
3727
|
+
}), this.grid.querySelectorAll(`[${E}]`).forEach((e) => {
|
|
3722
3728
|
var t;
|
|
3723
3729
|
(t = this.rowResizeObserver) == null || t.observe(e);
|
|
3724
3730
|
});
|
|
@@ -3728,7 +3734,7 @@ var sr = (e) => {
|
|
|
3728
3734
|
}
|
|
3729
3735
|
handleMouseOver(e) {
|
|
3730
3736
|
if (this.isGripInteractionLocked()) return;
|
|
3731
|
-
let t = e.target.closest(`[${
|
|
3737
|
+
let t = e.target.closest(`[${D}]`);
|
|
3732
3738
|
if (!t) return;
|
|
3733
3739
|
this.clearHideTimeout();
|
|
3734
3740
|
let n = this.getCellPosition(t);
|
|
@@ -3738,11 +3744,11 @@ var sr = (e) => {
|
|
|
3738
3744
|
this.isGripInteractionLocked() || this.scheduleHideAll();
|
|
3739
3745
|
}
|
|
3740
3746
|
getCellPosition(e) {
|
|
3741
|
-
let t = e.closest(`[${
|
|
3747
|
+
let t = e.closest(`[${E}]`);
|
|
3742
3748
|
if (!t) return null;
|
|
3743
|
-
let n = Array.from(this.grid.querySelectorAll(`[${
|
|
3749
|
+
let n = Array.from(this.grid.querySelectorAll(`[${E}]`)).indexOf(t);
|
|
3744
3750
|
if (n < 0) return null;
|
|
3745
|
-
let r = Array.from(t.querySelectorAll(`[${
|
|
3751
|
+
let r = Array.from(t.querySelectorAll(`[${D}]`)).indexOf(e);
|
|
3746
3752
|
return r < 0 ? null : {
|
|
3747
3753
|
row: n,
|
|
3748
3754
|
col: r
|
|
@@ -3771,13 +3777,13 @@ var sr = (e) => {
|
|
|
3771
3777
|
this.activeRowGripIndex >= 0 && this.activeRowGripIndex < this.rowGrips.length && this.applyIdleClasses(this.rowGrips[this.activeRowGripIndex]), this.activeRowGripIndex = -1;
|
|
3772
3778
|
}
|
|
3773
3779
|
applyVisibleClasses(e) {
|
|
3774
|
-
let t = e, n = t.hasAttribute(
|
|
3775
|
-
|
|
3780
|
+
let t = e, n = t.hasAttribute(hi);
|
|
3781
|
+
lr(t, n ? "col" : "row", n ? yi : bi), this.isInsideTable && (t.style.transition = "none"), t.className = S(Si, wi), t.setAttribute("data-blok-table-grip-visible", ""), this.isInsideTable && (t.offsetHeight, t.style.transition = "");
|
|
3776
3782
|
let r = t.querySelector("svg");
|
|
3777
3783
|
r && (r.classList.remove("text-white", "opacity-100"), r.classList.add("text-gray-400", "opacity-0"));
|
|
3778
3784
|
}
|
|
3779
3785
|
applyActiveClasses(e) {
|
|
3780
|
-
Object.assign(e, { className:
|
|
3786
|
+
Object.assign(e, { className: S(Si, Ti) }), e.setAttribute("data-blok-table-grip-visible", "");
|
|
3781
3787
|
let t = e.querySelector("svg");
|
|
3782
3788
|
t && (t.classList.remove("text-gray-400", "opacity-0"), t.classList.add("text-white", "opacity-100"));
|
|
3783
3789
|
}
|
|
@@ -3787,8 +3793,8 @@ var sr = (e) => {
|
|
|
3787
3793
|
});
|
|
3788
3794
|
}
|
|
3789
3795
|
applyIdleClasses(e) {
|
|
3790
|
-
let t = e, n = t.hasAttribute(
|
|
3791
|
-
this.isInsideTable && (t.style.transition = "none"),
|
|
3796
|
+
let t = e, n = t.hasAttribute(hi), r = n ? "col" : "row", i = n ? yi + 12 : bi + 12;
|
|
3797
|
+
this.isInsideTable && (t.style.transition = "none"), lr(t, r, i), t.className = S(Si, Ci), t.removeAttribute("data-blok-table-grip-visible");
|
|
3792
3798
|
let a = t.querySelector("svg");
|
|
3793
3799
|
a && (a.classList.add("opacity-0"), a.classList.remove("opacity-100")), this.isInsideTable && (t.offsetHeight, t.style.transition = "");
|
|
3794
3800
|
}
|
|
@@ -3801,13 +3807,13 @@ var sr = (e) => {
|
|
|
3801
3807
|
scheduleHideAll() {
|
|
3802
3808
|
this.hideTimeout = setTimeout(() => {
|
|
3803
3809
|
this.hideColGrip(), this.hideRowGrip(), this.isInsideTable = !1, this.hideTimeout = null;
|
|
3804
|
-
},
|
|
3810
|
+
}, _i);
|
|
3805
3811
|
}
|
|
3806
3812
|
clearHideTimeout() {
|
|
3807
3813
|
this.hideTimeout !== null && (clearTimeout(this.hideTimeout), this.hideTimeout = null);
|
|
3808
3814
|
}
|
|
3809
3815
|
handlePointerDown(e) {
|
|
3810
|
-
let t = e.target.closest(`[${
|
|
3816
|
+
let t = e.target.closest(`[${mi}]`);
|
|
3811
3817
|
if (!t) return;
|
|
3812
3818
|
e.preventDefault(), e.stopPropagation();
|
|
3813
3819
|
let n = this.detectGripType(t);
|
|
@@ -3816,12 +3822,12 @@ var sr = (e) => {
|
|
|
3816
3822
|
});
|
|
3817
3823
|
}
|
|
3818
3824
|
detectGripType(e) {
|
|
3819
|
-
let t = e.getAttribute(
|
|
3825
|
+
let t = e.getAttribute(hi);
|
|
3820
3826
|
if (t !== null) return {
|
|
3821
3827
|
type: "col",
|
|
3822
3828
|
index: Number(t)
|
|
3823
3829
|
};
|
|
3824
|
-
let n = e.getAttribute(
|
|
3830
|
+
let n = e.getAttribute(gi);
|
|
3825
3831
|
return n === null ? null : {
|
|
3826
3832
|
type: "row",
|
|
3827
3833
|
index: Number(n)
|
|
@@ -3829,7 +3835,7 @@ var sr = (e) => {
|
|
|
3829
3835
|
}
|
|
3830
3836
|
openPopover(e, t) {
|
|
3831
3837
|
var n, r;
|
|
3832
|
-
this.popoverState =
|
|
3838
|
+
this.popoverState = pi(e, t, {
|
|
3833
3839
|
col: this.colGrips,
|
|
3834
3840
|
row: this.rowGrips
|
|
3835
3841
|
}, {
|
|
@@ -3858,7 +3864,7 @@ var sr = (e) => {
|
|
|
3858
3864
|
}, e.destroy();
|
|
3859
3865
|
}
|
|
3860
3866
|
}
|
|
3861
|
-
},
|
|
3867
|
+
}, Di = "data-blok-table-haze", Oi = "data-blok-table-haze-visible", ki = 1, Ai = [
|
|
3862
3868
|
"absolute",
|
|
3863
3869
|
"top-0",
|
|
3864
3870
|
"bottom-0",
|
|
@@ -3868,17 +3874,17 @@ var sr = (e) => {
|
|
|
3868
3874
|
"transition-opacity",
|
|
3869
3875
|
"duration-150",
|
|
3870
3876
|
"z-1"
|
|
3871
|
-
],
|
|
3877
|
+
], ji = [
|
|
3872
3878
|
"left-0",
|
|
3873
3879
|
"bg-linear-to-r",
|
|
3874
3880
|
"from-white/80",
|
|
3875
3881
|
"to-transparent"
|
|
3876
|
-
],
|
|
3882
|
+
], Mi = [
|
|
3877
3883
|
"right-5",
|
|
3878
3884
|
"bg-linear-to-l",
|
|
3879
3885
|
"from-white/80",
|
|
3880
3886
|
"to-transparent"
|
|
3881
|
-
],
|
|
3887
|
+
], Ni = class {
|
|
3882
3888
|
constructor() {
|
|
3883
3889
|
this.leftHaze = null, this.rightHaze = null, this.scrollContainer = null, this.boundOnScroll = null, this.ticking = !1;
|
|
3884
3890
|
}
|
|
@@ -3898,7 +3904,7 @@ var sr = (e) => {
|
|
|
3898
3904
|
}
|
|
3899
3905
|
createHazeElement(e) {
|
|
3900
3906
|
let t = document.createElement("div");
|
|
3901
|
-
return t.setAttribute(
|
|
3907
|
+
return t.setAttribute(Di, e), t.setAttribute("aria-hidden", "true"), t.classList.add(...Ai, ...e === "left" ? ji : Mi), t;
|
|
3902
3908
|
}
|
|
3903
3909
|
syncVisibility() {
|
|
3904
3910
|
let e = this.scrollContainer;
|
|
@@ -3909,12 +3915,12 @@ var sr = (e) => {
|
|
|
3909
3915
|
return;
|
|
3910
3916
|
}
|
|
3911
3917
|
let { scrollLeft: n, scrollWidth: r, clientWidth: i } = e, a = r - i;
|
|
3912
|
-
this.setVisible(this.leftHaze, n >
|
|
3918
|
+
this.setVisible(this.leftHaze, n > ki), this.setVisible(this.rightHaze, a > ki && n < a - ki);
|
|
3913
3919
|
}
|
|
3914
3920
|
setVisible(e, t) {
|
|
3915
|
-
e && (t ? e.setAttribute(
|
|
3921
|
+
e && (t ? e.setAttribute(Oi, "") : e.removeAttribute(Oi));
|
|
3916
3922
|
}
|
|
3917
|
-
},
|
|
3923
|
+
}, Pi = 3, Fi = 3, Ii = ["my-2", "pr-5"], Li = [
|
|
3918
3924
|
"relative",
|
|
3919
3925
|
"after:content-[\"\"]",
|
|
3920
3926
|
"after:absolute",
|
|
@@ -3923,11 +3929,11 @@ var sr = (e) => {
|
|
|
3923
3929
|
"after:right-0",
|
|
3924
3930
|
"after:h-10",
|
|
3925
3931
|
"after:pointer-events-none"
|
|
3926
|
-
],
|
|
3932
|
+
], Ri = class {
|
|
3927
3933
|
constructor({ data: e, config: t, api: n, readOnly: r, block: i }) {
|
|
3928
3934
|
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 = r, this.config = t == null ? {} : t;
|
|
3929
|
-
let a =
|
|
3930
|
-
this.initialContent = a.content, this.grid = new
|
|
3935
|
+
let a = Ir(e, this.config);
|
|
3936
|
+
this.initialContent = a.content, this.grid = new nr({ readOnly: r }), this.model = new Vr(a), this.blockId = i == null ? void 0 : i.id, this.config.restrictedTools !== void 0 && (this.unregisterRestrictedTools = Ie(this.config.restrictedTools));
|
|
3931
3937
|
}
|
|
3932
3938
|
runStructuralOp(e, t = !1) {
|
|
3933
3939
|
this.structuralOpDepth++;
|
|
@@ -3962,7 +3968,7 @@ var sr = (e) => {
|
|
|
3962
3968
|
}
|
|
3963
3969
|
static get toolbox() {
|
|
3964
3970
|
return {
|
|
3965
|
-
icon:
|
|
3971
|
+
icon: Le,
|
|
3966
3972
|
title: "Table",
|
|
3967
3973
|
titleKey: "tools.table.title",
|
|
3968
3974
|
searchTerms: [
|
|
@@ -3995,7 +4001,7 @@ var sr = (e) => {
|
|
|
3995
4001
|
em: !0,
|
|
3996
4002
|
mark: (e) => {
|
|
3997
4003
|
let t = e.style, n = Array.from({ length: t.length }, (e, n) => t.item(n));
|
|
3998
|
-
for (let e of n)
|
|
4004
|
+
for (let e of n) be.has(e) || t.removeProperty(e);
|
|
3999
4005
|
return t.length > 0 ? { style: !0 } : {};
|
|
4000
4006
|
},
|
|
4001
4007
|
a: { href: !0 },
|
|
@@ -4014,28 +4020,28 @@ var sr = (e) => {
|
|
|
4014
4020
|
return n && this.element && (this.element.insertBefore(t, n), t.appendChild(n)), this.scrollContainer = t, (e = this.addControls) == null || e.attachScrollContainer(t), t;
|
|
4015
4021
|
}
|
|
4016
4022
|
render() {
|
|
4017
|
-
var e, t, r, i, a
|
|
4018
|
-
let
|
|
4019
|
-
|
|
4020
|
-
let
|
|
4023
|
+
var e, t, n, r, i, a;
|
|
4024
|
+
let o = document.createElement("div");
|
|
4025
|
+
o.className = S(Ii, !this.readOnly && Li), o.setAttribute(v.tool, "table"), this.readOnly && o.setAttribute("data-blok-table-readonly", ""), this.isNewTable = ((e = (t = this.initialContent) == null ? void 0 : t.length) == null ? 0 : e) === 0;
|
|
4026
|
+
let s = ((n = this.initialContent) == null ? void 0 : n.length) || this.config.rows || Pi, c = ((r = this.initialContent) == null ? void 0 : r.reduce((e, t) => {
|
|
4021
4027
|
var n;
|
|
4022
4028
|
return Math.max(e, (n = t == null ? void 0 : t.length) == null ? 0 : n);
|
|
4023
|
-
}, 0)) || this.config.cols ||
|
|
4024
|
-
if (((
|
|
4025
|
-
var
|
|
4026
|
-
this.grid.fillGrid(
|
|
4029
|
+
}, 0)) || this.config.cols || Fi, l = this.grid.createGrid(s, c, this.model.colWidths);
|
|
4030
|
+
if (((i = (a = this.initialContent) == null ? void 0 : a.length) == null ? 0 : i) > 0) {
|
|
4031
|
+
var u;
|
|
4032
|
+
this.grid.fillGrid(l, (u = this.initialContent) == null ? [] : u);
|
|
4027
4033
|
}
|
|
4028
|
-
if (this.model.colWidths &&
|
|
4034
|
+
if (this.model.colWidths && j(l, this.model.colWidths), this.gridElement = l, this.model.colWidths || !this.readOnly) {
|
|
4029
4035
|
let e = document.createElement("div");
|
|
4030
4036
|
e.setAttribute("data-blok-table-scroll", "");
|
|
4031
|
-
let t = this.model.colWidths ?
|
|
4032
|
-
e.classList.add(...t), e.appendChild(
|
|
4033
|
-
} else
|
|
4037
|
+
let t = this.model.colWidths ? Rr : [];
|
|
4038
|
+
e.classList.add(...t), e.appendChild(l), o.appendChild(e), this.scrollContainer = e;
|
|
4039
|
+
} else o.appendChild(l), this.scrollContainer = null;
|
|
4034
4040
|
if (!this.readOnly) {
|
|
4035
4041
|
let e = document.createElement("div");
|
|
4036
|
-
e.setAttribute("data-blok-table-grip-overlay", ""), e.style.position = "absolute", e.style.inset = "0", e.style.pointerEvents = "none", e.style.zIndex = "3",
|
|
4042
|
+
e.setAttribute("data-blok-table-grip-overlay", ""), e.style.position = "absolute", e.style.inset = "0", e.style.pointerEvents = "none", e.style.zIndex = "3", o.appendChild(e), this.gripOverlay = e;
|
|
4037
4043
|
}
|
|
4038
|
-
return this.element =
|
|
4044
|
+
return this.element = o, this.model.withHeadings && P(this.gridElement, this.model.withHeadings), this.model.withHeadingColumn && I(this.gridElement, this.model.withHeadingColumn), this.readOnly || (this.initCellBlocks(l), Lr(l, this.cellBlocks)), o;
|
|
4039
4045
|
}
|
|
4040
4046
|
rendered() {
|
|
4041
4047
|
if (!this.element || this.initialContent === null) return;
|
|
@@ -4044,22 +4050,22 @@ var sr = (e) => {
|
|
|
4044
4050
|
let t = this.initialContent;
|
|
4045
4051
|
if (this.initialContent = null, this.readOnly) {
|
|
4046
4052
|
var n;
|
|
4047
|
-
|
|
4053
|
+
Fr(e, t, this.api, (n = this.blockId) == null ? "" : n), F(e, this.model.snapshot().content), this.initScrollHaze();
|
|
4048
4054
|
return;
|
|
4049
4055
|
}
|
|
4050
4056
|
if (this.runTransactedStructuralOp(() => {
|
|
4051
4057
|
var n, r;
|
|
4052
|
-
let i = (n = (r = this.cellBlocks) == null ? void 0 : r.initializeCells(t)) == null ? t : n, a = this.isNewTable && i.length === 0 ? Array.from(e.querySelectorAll(`[${
|
|
4053
|
-
let t = e.querySelectorAll(`[${
|
|
4058
|
+
let i = (n = (r = this.cellBlocks) == null ? void 0 : r.initializeCells(t)) == null ? t : n, a = this.isNewTable && i.length === 0 ? Array.from(e.querySelectorAll(`[${E}]`), (e) => {
|
|
4059
|
+
let t = e.querySelectorAll(`[${D}]`).length;
|
|
4054
4060
|
return Array.from({ length: t }, () => ({ blocks: [] }));
|
|
4055
4061
|
}) : i;
|
|
4056
|
-
this.model.replaceAll(
|
|
4062
|
+
this.model.replaceAll(x(x({}, this.model.snapshot()), {}, { content: a })), this.isNewTable && N(e, this.cellBlocks), this.removeGhostChildren();
|
|
4057
4063
|
}, !0), this.model.initialColWidth === void 0) {
|
|
4058
4064
|
var r;
|
|
4059
|
-
let t = (r = this.model.colWidths) == null ?
|
|
4060
|
-
this.model.setInitialColWidth(t.length > 0 ?
|
|
4065
|
+
let t = (r = this.model.colWidths) == null ? A(e) : r;
|
|
4066
|
+
this.model.setInitialColWidth(t.length > 0 ? Mr(t) : void 0);
|
|
4061
4067
|
}
|
|
4062
|
-
if (this.initSubsystems(e),
|
|
4068
|
+
if (this.initSubsystems(e), F(e, this.model.snapshot().content), this.isNewTable) {
|
|
4063
4069
|
var i;
|
|
4064
4070
|
(i = this.cellSelection) == null || i.selectRange({
|
|
4065
4071
|
minRow: 0,
|
|
@@ -4087,7 +4093,7 @@ var sr = (e) => {
|
|
|
4087
4093
|
setData(e) {
|
|
4088
4094
|
var t, n, r, i, a;
|
|
4089
4095
|
this.setDataGeneration++;
|
|
4090
|
-
let o = this.setDataGeneration, s =
|
|
4096
|
+
let o = this.setDataGeneration, s = Ir(x(x({}, this.model.snapshot()), e), this.config);
|
|
4091
4097
|
this.initialContent = s.content, this.model.replaceAll(s), this.api.blocks.isSyncingFromYjs || this.runStructuralOp(() => {
|
|
4092
4098
|
var e;
|
|
4093
4099
|
(e = this.cellBlocks) == null || e.deleteAllBlocks();
|
|
@@ -4101,7 +4107,7 @@ var sr = (e) => {
|
|
|
4101
4107
|
let f = this.gridElement;
|
|
4102
4108
|
if (f) {
|
|
4103
4109
|
if (this.readOnly) {
|
|
4104
|
-
|
|
4110
|
+
F(f, this.model.snapshot().content);
|
|
4105
4111
|
return;
|
|
4106
4112
|
}
|
|
4107
4113
|
o === this.setDataGeneration && (this.runStructuralOp(() => {
|
|
@@ -4109,15 +4115,15 @@ var sr = (e) => {
|
|
|
4109
4115
|
let i = (e = (t = (n = this.cellBlocks) == null ? void 0 : n.initializeCells((r = this.initialContent) == null ? [] : r)) == null ? this.initialContent : t) == null ? [] : e;
|
|
4110
4116
|
if (o === this.setDataGeneration) {
|
|
4111
4117
|
if (this.api.blocks.isSyncingFromYjs && i.length === 0 && f) {
|
|
4112
|
-
let e = Array.from(f.querySelectorAll(`[${
|
|
4113
|
-
let t = e.querySelectorAll(`[${
|
|
4118
|
+
let e = Array.from(f.querySelectorAll(`[${E}]`), (e) => {
|
|
4119
|
+
let t = e.querySelectorAll(`[${D}]`).length;
|
|
4114
4120
|
return Array.from({ length: t }, () => ({ blocks: [] }));
|
|
4115
4121
|
});
|
|
4116
|
-
this.model.replaceAll(
|
|
4117
|
-
} else this.model.replaceAll(
|
|
4122
|
+
this.model.replaceAll(x(x({}, this.model.snapshot()), {}, { content: e })), N(f, this.cellBlocks);
|
|
4123
|
+
} else this.model.replaceAll(x(x({}, this.model.snapshot()), {}, { content: i }));
|
|
4118
4124
|
this.initialContent = null;
|
|
4119
4125
|
}
|
|
4120
|
-
}, !0), o === this.setDataGeneration && (this.initSubsystems(f), l !== null && this.cellSelection !== null && this.cellSelection.selectRange(l), u !== null && this.rowColControls !== null && this.rowColControls.restoreVisibleGrips(u.col, u.row),
|
|
4126
|
+
}, !0), o === this.setDataGeneration && (this.initSubsystems(f), l !== null && this.cellSelection !== null && this.cellSelection.selectRange(l), u !== null && this.rowColControls !== null && this.rowColControls.restoreVisibleGrips(u.col, u.row), F(f, this.model.snapshot().content)));
|
|
4121
4127
|
}
|
|
4122
4128
|
}
|
|
4123
4129
|
onPaste(e) {
|
|
@@ -4129,9 +4135,9 @@ var sr = (e) => {
|
|
|
4129
4135
|
var t;
|
|
4130
4136
|
n.push(e.innerHTML);
|
|
4131
4137
|
let i = (t = e.getAttribute("style")) == null ? "" : t, a = {}, o = /background-color\s*:\s*([^;]+)/i.exec(i);
|
|
4132
|
-
o != null && o[1] && (a.color =
|
|
4138
|
+
o != null && o[1] && (a.color = Xe(o[1].trim(), "bg"));
|
|
4133
4139
|
let s = (/* @__PURE__ */ RegExp("(?<![a-z-])color\\s*:\\s*([^;]+)", "i")).exec(i);
|
|
4134
|
-
s != null && s[1] && !
|
|
4140
|
+
s != null && s[1] && !Pe(s[1].trim()) && (a.textColor = Xe(s[1].trim(), "text")), r.push(a);
|
|
4135
4141
|
}), n.length > 0 && (a.push(n), o.push(r));
|
|
4136
4142
|
});
|
|
4137
4143
|
let s = r.querySelector("thead") !== null, c = ((t = i[0]) == null ? void 0 : t.querySelector("th")) !== null, l = s || c;
|
|
@@ -4147,12 +4153,12 @@ var sr = (e) => {
|
|
|
4147
4153
|
!this.readOnly && f && (this.runStructuralOp(() => {
|
|
4148
4154
|
var e, t, n, r;
|
|
4149
4155
|
let i = (e = (t = (n = this.cellBlocks) == null ? void 0 : n.initializeCells((r = this.initialContent) == null ? [] : r)) == null ? this.initialContent : t) == null ? [] : e;
|
|
4150
|
-
this.model.replaceAll(
|
|
4156
|
+
this.model.replaceAll(x(x({}, this.model.snapshot()), {}, { content: i })), this.initialContent = null, o.forEach((e, t) => {
|
|
4151
4157
|
e.forEach((e, n) => {
|
|
4152
4158
|
e.color !== void 0 && this.model.setCellColor(t, n, e.color), e.textColor !== void 0 && this.model.setCellTextColor(t, n, e.textColor);
|
|
4153
4159
|
});
|
|
4154
4160
|
});
|
|
4155
|
-
}, !0), this.initSubsystems(f),
|
|
4161
|
+
}, !0), this.initSubsystems(f), F(f, this.model.snapshot().content));
|
|
4156
4162
|
}
|
|
4157
4163
|
destroy() {
|
|
4158
4164
|
var e, t;
|
|
@@ -4179,35 +4185,35 @@ var sr = (e) => {
|
|
|
4179
4185
|
});
|
|
4180
4186
|
}
|
|
4181
4187
|
getBlockIdsInRow(e) {
|
|
4182
|
-
return
|
|
4188
|
+
return Nr(this.element, this.cellBlocks, e);
|
|
4183
4189
|
}
|
|
4184
4190
|
getBlockIdsInColumn(e) {
|
|
4185
|
-
return
|
|
4191
|
+
return Pr(this.element, this.cellBlocks, e);
|
|
4186
4192
|
}
|
|
4187
4193
|
initAddControls(e) {
|
|
4188
4194
|
var t;
|
|
4189
4195
|
if ((t = this.addControls) == null || t.destroy(), !this.element) return;
|
|
4190
4196
|
let n = { addedCols: 0 };
|
|
4191
|
-
this.addControls = new
|
|
4197
|
+
this.addControls = new Zn({
|
|
4192
4198
|
wrapper: this.element,
|
|
4193
4199
|
grid: e,
|
|
4194
4200
|
i18n: this.api.i18n,
|
|
4195
4201
|
getNewColumnWidth: () => {
|
|
4196
4202
|
var t;
|
|
4197
|
-
let n = (t = this.model.colWidths) == null ?
|
|
4198
|
-
return this.model.initialColWidth === void 0 ?
|
|
4203
|
+
let n = (t = this.model.colWidths) == null ? A(e) : t;
|
|
4204
|
+
return this.model.initialColWidth === void 0 ? M(n) : Math.round(this.model.initialColWidth / 2 * 100) / 100;
|
|
4199
4205
|
},
|
|
4200
4206
|
onAddRow: () => {
|
|
4201
4207
|
this.runTransactedStructuralOp(() => {
|
|
4202
4208
|
var t, n;
|
|
4203
|
-
this.grid.addRow(e), this.model.addRow(),
|
|
4209
|
+
this.grid.addRow(e), this.model.addRow(), N(e, this.cellBlocks), P(this.gridElement, this.model.withHeadings), I(this.gridElement, this.model.withHeadingColumn), this.initResize(e), (t = this.addControls) == null || t.syncRowButtonWidth(), (n = this.rowColControls) == null || n.refresh();
|
|
4204
4210
|
});
|
|
4205
4211
|
},
|
|
4206
4212
|
onAddColumn: () => {
|
|
4207
4213
|
this.runTransactedStructuralOp(() => {
|
|
4208
4214
|
var t, n, r;
|
|
4209
|
-
let i = (t = this.model.colWidths) == null ?
|
|
4210
|
-
this.grid.addColumn(e, void 0, i, a), this.model.addColumn(void 0, a), this.model.setColWidths([...i, a]),
|
|
4215
|
+
let i = (t = this.model.colWidths) == null ? A(e) : t, a = this.model.initialColWidth === void 0 ? M(i) : Math.round(this.model.initialColWidth / 2 * 100) / 100;
|
|
4216
|
+
this.grid.addColumn(e, void 0, i, a), this.model.addColumn(void 0, a), this.model.setColWidths([...i, a]), N(e, this.cellBlocks), I(this.gridElement, this.model.withHeadingColumn), this.initResize(e), (n = this.rowColControls) == null || n.refresh(), this.scrollContainer && (this.scrollContainer.scrollLeft = this.scrollContainer.scrollWidth), (r = this.addControls) == null || r.syncRowButtonWidth();
|
|
4211
4217
|
});
|
|
4212
4218
|
},
|
|
4213
4219
|
onDragStart: () => {
|
|
@@ -4216,13 +4222,13 @@ var sr = (e) => {
|
|
|
4216
4222
|
},
|
|
4217
4223
|
onDragAddRow: () => {
|
|
4218
4224
|
this.runTransactedStructuralOp(() => {
|
|
4219
|
-
this.grid.addRow(e), this.model.addRow(),
|
|
4225
|
+
this.grid.addRow(e), this.model.addRow(), N(e, this.cellBlocks), P(this.gridElement, this.model.withHeadings), I(this.gridElement, this.model.withHeadingColumn);
|
|
4220
4226
|
});
|
|
4221
4227
|
},
|
|
4222
4228
|
onDragRemoveRow: () => {
|
|
4223
4229
|
this.runTransactedStructuralOp(() => {
|
|
4224
4230
|
let t = this.grid.getRowCount(e);
|
|
4225
|
-
if (t > 1 &&
|
|
4231
|
+
if (t > 1 && Er(e, t - 1)) {
|
|
4226
4232
|
var n;
|
|
4227
4233
|
let { blocksToDelete: r } = this.model.deleteRow(t - 1);
|
|
4228
4234
|
(n = this.cellBlocks) == null || n.deleteBlocks(r), this.grid.deleteRow(e, t - 1);
|
|
@@ -4232,19 +4238,19 @@ var sr = (e) => {
|
|
|
4232
4238
|
onDragAddCol: () => {
|
|
4233
4239
|
this.runTransactedStructuralOp(() => {
|
|
4234
4240
|
var t;
|
|
4235
|
-
let r = (t = this.model.colWidths) == null ?
|
|
4236
|
-
this.grid.addColumn(e, void 0, r, i), this.model.addColumn(void 0, i), this.model.setColWidths(a),
|
|
4241
|
+
let r = (t = this.model.colWidths) == null ? A(e) : t, i = this.model.initialColWidth === void 0 ? M(r) : Math.round(this.model.initialColWidth / 2 * 100) / 100, a = [...r, i];
|
|
4242
|
+
this.grid.addColumn(e, void 0, r, i), this.model.addColumn(void 0, i), this.model.setColWidths(a), j(e, a), N(e, this.cellBlocks), I(this.gridElement, this.model.withHeadingColumn), this.initResize(e), n.addedCols++, this.scrollContainer && (this.scrollContainer.scrollLeft = this.scrollContainer.scrollWidth);
|
|
4237
4243
|
});
|
|
4238
4244
|
},
|
|
4239
4245
|
onDragRemoveCol: () => {
|
|
4240
4246
|
this.runTransactedStructuralOp(() => {
|
|
4241
4247
|
var t;
|
|
4242
4248
|
let r = this.grid.getColumnCount(e);
|
|
4243
|
-
if (r <= 1 || !
|
|
4249
|
+
if (r <= 1 || !Dr(e, r - 1)) return;
|
|
4244
4250
|
let { blocksToDelete: i } = this.model.deleteColumn(r - 1);
|
|
4245
4251
|
(t = this.cellBlocks) == null || t.deleteBlocks(i), this.grid.deleteColumn(e, r - 1);
|
|
4246
4252
|
let a = this.model.colWidths;
|
|
4247
|
-
a &&
|
|
4253
|
+
a && j(e, a), this.initResize(e), n.addedCols--;
|
|
4248
4254
|
});
|
|
4249
4255
|
},
|
|
4250
4256
|
onDragEnd: () => {
|
|
@@ -4255,7 +4261,7 @@ var sr = (e) => {
|
|
|
4255
4261
|
}
|
|
4256
4262
|
initRowColControls(e) {
|
|
4257
4263
|
var t, n, r;
|
|
4258
|
-
(t = this.rowColControls) == null || t.destroy(), this.element && (this.rowColControls = new
|
|
4264
|
+
(t = this.rowColControls) == null || t.destroy(), this.element && (this.rowColControls = new Ei({
|
|
4259
4265
|
grid: e,
|
|
4260
4266
|
overlay: (n = this.gripOverlay) == null ? void 0 : n,
|
|
4261
4267
|
scrollContainer: (r = this.scrollContainer) == null ? void 0 : r,
|
|
@@ -4303,7 +4309,7 @@ var sr = (e) => {
|
|
|
4303
4309
|
this.runTransactedStructuralOp(() => {
|
|
4304
4310
|
var r, i;
|
|
4305
4311
|
if (n !== this.setDataGeneration || this.gridElement !== e) return;
|
|
4306
|
-
let a = this.model.colWidths, { blocksToDelete: o } = this.syncModelForAction(t), s =
|
|
4312
|
+
let a = this.model.colWidths, { blocksToDelete: o } = this.syncModelForAction(t), s = ei(e, t, {
|
|
4307
4313
|
grid: this.grid,
|
|
4308
4314
|
data: {
|
|
4309
4315
|
colWidths: a,
|
|
@@ -4315,7 +4321,7 @@ var sr = (e) => {
|
|
|
4315
4321
|
blocksToDelete: o
|
|
4316
4322
|
});
|
|
4317
4323
|
if (n !== this.setDataGeneration || this.gridElement !== e) return;
|
|
4318
|
-
if (this.model.setColWidths(s.colWidths), this.model.setWithHeadings(s.withHeadings), this.model.setWithHeadingColumn(s.withHeadingColumn), this.pendingHighlight = s.pendingHighlight,
|
|
4324
|
+
if (this.model.setColWidths(s.colWidths), this.model.setWithHeadings(s.withHeadings), this.model.setWithHeadingColumn(s.withHeadingColumn), this.pendingHighlight = s.pendingHighlight, P(this.gridElement, this.model.withHeadings), I(this.gridElement, this.model.withHeadingColumn), this.initResize(e), (r = this.addControls) == null || r.syncRowButtonWidth(), !(t.type === "toggle-heading" || t.type === "toggle-heading-column")) {
|
|
4319
4325
|
var c;
|
|
4320
4326
|
(c = this.rowColControls) == null || c.refresh();
|
|
4321
4327
|
}
|
|
@@ -4361,10 +4367,10 @@ var sr = (e) => {
|
|
|
4361
4367
|
initResize(e) {
|
|
4362
4368
|
var t, n;
|
|
4363
4369
|
(t = this.resize) == null || t.destroy();
|
|
4364
|
-
let r = this.model.colWidths === void 0, i = (n = this.model.colWidths) == null ?
|
|
4365
|
-
r ||
|
|
4370
|
+
let r = this.model.colWidths === void 0, i = (n = this.model.colWidths) == null ? A(e) : n;
|
|
4371
|
+
r || zr(this.ensureScrollContainer()), this.resize = new qr(e, i, (e) => {
|
|
4366
4372
|
var t, n, r;
|
|
4367
|
-
this.model.setColWidths(e),
|
|
4373
|
+
this.model.setColWidths(e), zr(this.ensureScrollContainer()), (t = this.rowColControls) == null || t.positionGrips(), (n = this.addControls) == null || n.syncRowButtonWidth(), (r = this.scrollHaze) == null || r.update();
|
|
4368
4374
|
}, () => {
|
|
4369
4375
|
var e;
|
|
4370
4376
|
(e = this.rowColControls) == null || e.hideAllGrips();
|
|
@@ -4375,7 +4381,7 @@ var sr = (e) => {
|
|
|
4375
4381
|
}
|
|
4376
4382
|
initCellBlocks(e) {
|
|
4377
4383
|
var t;
|
|
4378
|
-
this.cellBlocks = new
|
|
4384
|
+
this.cellBlocks = new rr({
|
|
4379
4385
|
api: this.api,
|
|
4380
4386
|
gridElement: e,
|
|
4381
4387
|
tableBlockId: (t = this.blockId) == null ? "" : t,
|
|
@@ -4386,13 +4392,13 @@ var sr = (e) => {
|
|
|
4386
4392
|
handleCellCopy(e, t) {
|
|
4387
4393
|
let n = this.collectCellBlockData(e);
|
|
4388
4394
|
if (n.length === 0) return;
|
|
4389
|
-
let r =
|
|
4390
|
-
t.setData("text/html",
|
|
4395
|
+
let r = pe(n);
|
|
4396
|
+
t.setData("text/html", Se(r)), t.setData("text/plain", Ve(r));
|
|
4391
4397
|
}
|
|
4392
4398
|
handleCellCopyViaButton(e) {
|
|
4393
4399
|
let t = this.collectCellBlockData(e);
|
|
4394
4400
|
if (t.length === 0) return;
|
|
4395
|
-
let n =
|
|
4401
|
+
let n = pe(t), r = Se(n), i = Ve(n), a = new Blob([r], { type: "text/html" }), o = new Blob([i], { type: "text/plain" });
|
|
4396
4402
|
navigator.clipboard.write([new ClipboardItem({
|
|
4397
4403
|
"text/html": a,
|
|
4398
4404
|
"text/plain": o
|
|
@@ -4402,7 +4408,7 @@ var sr = (e) => {
|
|
|
4402
4408
|
let r = this.gridElement;
|
|
4403
4409
|
r && this.runTransactedStructuralOp(() => {
|
|
4404
4410
|
for (let i of e) {
|
|
4405
|
-
let e =
|
|
4411
|
+
let e = wr(r, i);
|
|
4406
4412
|
e && (n === "backgroundColor" ? (this.model.setCellColor(e.row, e.col, t == null ? void 0 : t), i.style.backgroundColor = t == null ? "" : t) : (this.model.setCellTextColor(e.row, e.col, t == null ? void 0 : t), i.style.color = t == null ? "" : t));
|
|
4407
4413
|
}
|
|
4408
4414
|
});
|
|
@@ -4410,12 +4416,12 @@ var sr = (e) => {
|
|
|
4410
4416
|
collectCellBlockData(e) {
|
|
4411
4417
|
let t = this.gridElement;
|
|
4412
4418
|
if (!t) return [];
|
|
4413
|
-
let n = Array.from(t.querySelectorAll(`[${
|
|
4419
|
+
let n = Array.from(t.querySelectorAll(`[${E}]`));
|
|
4414
4420
|
return e.map((e) => {
|
|
4415
4421
|
var t;
|
|
4416
|
-
let r = e.closest(`[${
|
|
4422
|
+
let r = e.closest(`[${E}]`);
|
|
4417
4423
|
if (!r) return null;
|
|
4418
|
-
let i = n.indexOf(r), a = Array.from(r.querySelectorAll(`[${
|
|
4424
|
+
let i = n.indexOf(r), a = Array.from(r.querySelectorAll(`[${D}]`)).indexOf(e), o = e.querySelector(`[${k}]`), s = [];
|
|
4419
4425
|
if (!o) return {
|
|
4420
4426
|
row: i,
|
|
4421
4427
|
col: a,
|
|
@@ -4427,7 +4433,7 @@ var sr = (e) => {
|
|
|
4427
4433
|
let n = this.api.blocks.getBlockIndex(t);
|
|
4428
4434
|
if (n === void 0) return;
|
|
4429
4435
|
let r = this.api.blocks.getBlockByIndex(n);
|
|
4430
|
-
r && s.push(
|
|
4436
|
+
r && s.push(x({
|
|
4431
4437
|
tool: r.name,
|
|
4432
4438
|
data: r.preservedData
|
|
4433
4439
|
}, Object.keys(r.preservedTunes).length > 0 ? { tunes: r.preservedTunes } : {}));
|
|
@@ -4438,7 +4444,7 @@ var sr = (e) => {
|
|
|
4438
4444
|
data: { text: c }
|
|
4439
4445
|
});
|
|
4440
4446
|
let l = this.model.getCellColor(i, a), u = this.model.getCellTextColor(i, a);
|
|
4441
|
-
return
|
|
4447
|
+
return x(x({
|
|
4442
4448
|
row: i,
|
|
4443
4449
|
col: a,
|
|
4444
4450
|
blocks: s
|
|
@@ -4449,7 +4455,7 @@ var sr = (e) => {
|
|
|
4449
4455
|
var t;
|
|
4450
4456
|
(t = this.cellSelection) == null || t.destroy();
|
|
4451
4457
|
let n = this.api.rectangleSelection;
|
|
4452
|
-
this.cellSelection = new
|
|
4458
|
+
this.cellSelection = new Cr({
|
|
4453
4459
|
grid: e,
|
|
4454
4460
|
rectangleSelection: n,
|
|
4455
4461
|
i18n: this.api.i18n,
|
|
@@ -4476,7 +4482,7 @@ var sr = (e) => {
|
|
|
4476
4482
|
t.deleteBlocks(n);
|
|
4477
4483
|
let r = this.gridElement;
|
|
4478
4484
|
if (r) for (let t of e) {
|
|
4479
|
-
let e =
|
|
4485
|
+
let e = wr(r, t);
|
|
4480
4486
|
e && (this.model.setCellColor(e.row, e.col, void 0), this.model.setCellTextColor(e.row, e.col, void 0), t.style.backgroundColor = "", t.style.color = "");
|
|
4481
4487
|
}
|
|
4482
4488
|
});
|
|
@@ -4497,7 +4503,7 @@ var sr = (e) => {
|
|
|
4497
4503
|
}
|
|
4498
4504
|
initScrollHaze() {
|
|
4499
4505
|
var e;
|
|
4500
|
-
(e = this.scrollHaze) == null || e.destroy(), !(!this.element || !this.scrollContainer) && (this.scrollHaze = new
|
|
4506
|
+
(e = this.scrollHaze) == null || e.destroy(), !(!this.element || !this.scrollContainer) && (this.scrollHaze = new Ni(), this.scrollHaze.init(this.element, this.scrollContainer));
|
|
4501
4507
|
}
|
|
4502
4508
|
initGridPasteListener(e) {
|
|
4503
4509
|
e.addEventListener("paste", (t) => {
|
|
@@ -4506,20 +4512,20 @@ var sr = (e) => {
|
|
|
4506
4512
|
}
|
|
4507
4513
|
handleGridPaste(e, t) {
|
|
4508
4514
|
if (this.readOnly || !e.clipboardData || e.defaultPrevented) return;
|
|
4509
|
-
let n = e.clipboardData.getData("text/html"), r =
|
|
4515
|
+
let n = e.clipboardData.getData("text/html"), r = Ee(n), i = r === null ? we(n) : null, a = r == null ? i : r;
|
|
4510
4516
|
if (!a || i !== null && new DOMParser().parseFromString(n, "text/html").querySelectorAll("table").length > 1) return;
|
|
4511
4517
|
let o = document.activeElement;
|
|
4512
4518
|
if (!o) return;
|
|
4513
|
-
let s = o.closest(`[${
|
|
4519
|
+
let s = o.closest(`[${D}]`);
|
|
4514
4520
|
if (!s || !t.contains(s)) return;
|
|
4515
|
-
let c = s.closest(`[${
|
|
4521
|
+
let c = s.closest(`[${E}]`);
|
|
4516
4522
|
if (!c) return;
|
|
4517
4523
|
if (a.rows === 1 && a.cols === 1) {
|
|
4518
4524
|
e.preventDefault(), e.stopPropagation(), this.insertSingleCellPayloadInline(a.cells[0][0]);
|
|
4519
4525
|
return;
|
|
4520
4526
|
}
|
|
4521
4527
|
e.preventDefault(), e.stopPropagation();
|
|
4522
|
-
let l = Array.from(t.querySelectorAll(`[${
|
|
4528
|
+
let l = Array.from(t.querySelectorAll(`[${E}]`)).indexOf(c), u = Array.from(c.querySelectorAll(`[${D}]`)).indexOf(s);
|
|
4523
4529
|
this.pastePayloadIntoCells(t, a, l, u);
|
|
4524
4530
|
}
|
|
4525
4531
|
insertSingleCellPayloadInline(e) {
|
|
@@ -4540,11 +4546,11 @@ var sr = (e) => {
|
|
|
4540
4546
|
this.runTransactedStructuralOp(() => {
|
|
4541
4547
|
var i, a;
|
|
4542
4548
|
this.expandGridForPaste(e, n + t.rows, r + t.cols);
|
|
4543
|
-
let o = e.querySelectorAll(`[${
|
|
4549
|
+
let o = e.querySelectorAll(`[${E}]`);
|
|
4544
4550
|
Array.from({ length: t.rows }, (e, t) => t).forEach((e) => {
|
|
4545
4551
|
let i = o[n + e];
|
|
4546
4552
|
if (!i) return;
|
|
4547
|
-
let a = i.querySelectorAll(`[${
|
|
4553
|
+
let a = i.querySelectorAll(`[${D}]`);
|
|
4548
4554
|
Array.from({ length: t.cols }, (e, t) => t).forEach((i) => {
|
|
4549
4555
|
let o = a[r + i];
|
|
4550
4556
|
if (o) {
|
|
@@ -4559,7 +4565,7 @@ var sr = (e) => {
|
|
|
4559
4565
|
});
|
|
4560
4566
|
}), this.initResize(e), (i = this.addControls) == null || i.syncRowButtonWidth(), (a = this.rowColControls) == null || a.refresh();
|
|
4561
4567
|
});
|
|
4562
|
-
let i = e.querySelectorAll(`[${
|
|
4568
|
+
let i = e.querySelectorAll(`[${E}]`)[n + t.rows - 1], a = i == null ? void 0 : i.querySelectorAll(`[${D}]`)[r + t.cols - 1];
|
|
4563
4569
|
if (!a || !this.cellBlocks || !this.api.caret) return;
|
|
4564
4570
|
let o = this.cellBlocks.getBlockIdsFromCells([a]), s = o[o.length - 1];
|
|
4565
4571
|
s !== void 0 && this.api.caret.setToBlock(s, "end");
|
|
@@ -4567,11 +4573,11 @@ var sr = (e) => {
|
|
|
4567
4573
|
expandGridForPaste(e, t, n) {
|
|
4568
4574
|
let r = this.grid.getRowCount(e), i = this.grid.getColumnCount(e);
|
|
4569
4575
|
Array.from({ length: Math.max(0, t - r) }).forEach(() => {
|
|
4570
|
-
this.grid.addRow(e), this.model.addRow(),
|
|
4576
|
+
this.grid.addRow(e), this.model.addRow(), N(e, this.cellBlocks), P(this.gridElement, this.model.withHeadings), I(this.gridElement, this.model.withHeadingColumn);
|
|
4571
4577
|
}), Array.from({ length: Math.max(0, n - i) }).forEach(() => {
|
|
4572
4578
|
var t;
|
|
4573
|
-
let n = (t = this.model.colWidths) == null ?
|
|
4574
|
-
this.grid.addColumn(e, void 0, n, r), this.model.addColumn(void 0, r), this.model.setColWidths([...n, r]),
|
|
4579
|
+
let n = (t = this.model.colWidths) == null ? A(e) : t, r = this.model.initialColWidth === void 0 ? M(n) : Math.round(this.model.initialColWidth / 2 * 100) / 100;
|
|
4580
|
+
this.grid.addColumn(e, void 0, n, r), this.model.addColumn(void 0, r), this.model.setColWidths([...n, r]), N(e, this.cellBlocks), I(this.gridElement, this.model.withHeadingColumn);
|
|
4575
4581
|
});
|
|
4576
4582
|
}
|
|
4577
4583
|
pasteCellPayload(e, t) {
|
|
@@ -4579,7 +4585,7 @@ var sr = (e) => {
|
|
|
4579
4585
|
let t = this.cellBlocks.getBlockIdsFromCells([e]);
|
|
4580
4586
|
this.cellBlocks.deleteBlocks(t);
|
|
4581
4587
|
}
|
|
4582
|
-
let n = e.querySelector(`[${
|
|
4588
|
+
let n = e.querySelector(`[${k}]`);
|
|
4583
4589
|
if (n) {
|
|
4584
4590
|
if (t.blocks.length === 0) {
|
|
4585
4591
|
var r;
|
|
@@ -4593,19 +4599,19 @@ var sr = (e) => {
|
|
|
4593
4599
|
}
|
|
4594
4600
|
}
|
|
4595
4601
|
}
|
|
4596
|
-
},
|
|
4602
|
+
}, zi = (e) => {
|
|
4597
4603
|
let t = document.createElement("div");
|
|
4598
4604
|
t.innerHTML = e.trim();
|
|
4599
4605
|
let n = document.createDocumentFragment();
|
|
4600
4606
|
return n.append(...Array.from(t.childNodes)), n;
|
|
4601
|
-
},
|
|
4607
|
+
}, Bi = (e, t, n, r) => {
|
|
4602
4608
|
if (!t) return e;
|
|
4603
4609
|
let i = n();
|
|
4604
4610
|
return {
|
|
4605
|
-
text: i ?
|
|
4611
|
+
text: i ? et(i.innerHTML) : e.text,
|
|
4606
4612
|
isOpen: r
|
|
4607
4613
|
};
|
|
4608
|
-
},
|
|
4614
|
+
}, Vi = (e, t) => {
|
|
4609
4615
|
let { data: n, getContentElement: r } = e;
|
|
4610
4616
|
n.text += t.text;
|
|
4611
4617
|
let i = r();
|
|
@@ -4613,18 +4619,18 @@ var sr = (e) => {
|
|
|
4613
4619
|
let n = e.parseHTML(t.text);
|
|
4614
4620
|
i.appendChild(n), i.normalize();
|
|
4615
4621
|
}
|
|
4616
|
-
},
|
|
4622
|
+
}, Hi = (e, t, n) => {
|
|
4617
4623
|
let r = n();
|
|
4618
4624
|
if (!r) return {
|
|
4619
4625
|
newData: e,
|
|
4620
4626
|
inPlace: !1
|
|
4621
4627
|
};
|
|
4622
|
-
let i =
|
|
4628
|
+
let i = x(x({}, e), t);
|
|
4623
4629
|
return typeof t.text == "string" && (r.innerHTML = t.text), {
|
|
4624
4630
|
newData: i,
|
|
4625
4631
|
inPlace: !0
|
|
4626
4632
|
};
|
|
4627
|
-
},
|
|
4633
|
+
}, Ui = class e {
|
|
4628
4634
|
constructor({ data: e, config: t, api: n, readOnly: r, block: i }) {
|
|
4629
4635
|
var a;
|
|
4630
4636
|
this._element = null, this._contentElement = null, this._arrowElement = null, this._bodyPlaceholderElement = null, this._childContainerElement = null, this.handleBlockChanged = (e) => {
|
|
@@ -4644,11 +4650,11 @@ var sr = (e) => {
|
|
|
4644
4650
|
}
|
|
4645
4651
|
get placeholder() {
|
|
4646
4652
|
if (this._settings.placeholder) return this._settings.placeholder;
|
|
4647
|
-
let e = this.api.i18n.t(
|
|
4653
|
+
let e = this.api.i18n.t(Me);
|
|
4648
4654
|
return e === "tools.toggle.placeholder" ? "Toggle" : e;
|
|
4649
4655
|
}
|
|
4650
4656
|
render() {
|
|
4651
|
-
let e =
|
|
4657
|
+
let e = ht({
|
|
4652
4658
|
data: this._data,
|
|
4653
4659
|
readOnly: this.readOnly,
|
|
4654
4660
|
isOpen: this._isOpen,
|
|
@@ -4656,10 +4662,10 @@ var sr = (e) => {
|
|
|
4656
4662
|
keydownHandler: this.readOnly ? null : this.handleKeyDown.bind(this),
|
|
4657
4663
|
onArrowClick: () => this.toggleOpen(),
|
|
4658
4664
|
onBodyPlaceholderClick: this.readOnly ? null : () => this.handleBodyPlaceholderClick(),
|
|
4659
|
-
bodyPlaceholderText: this.api.i18n.t(
|
|
4665
|
+
bodyPlaceholderText: this.api.i18n.t(Re),
|
|
4660
4666
|
ariaLabels: {
|
|
4661
|
-
collapse: this.api.i18n.t(
|
|
4662
|
-
expand: this.api.i18n.t(
|
|
4667
|
+
collapse: this.api.i18n.t(qe),
|
|
4668
|
+
expand: this.api.i18n.t(Fe)
|
|
4663
4669
|
}
|
|
4664
4670
|
});
|
|
4665
4671
|
return this._element = e.wrapper, this._contentElement = e.contentElement, this._arrowElement = e.arrowElement, this._bodyPlaceholderElement = e.bodyPlaceholderElement, this._childContainerElement = e.childContainerElement, this._element;
|
|
@@ -4668,31 +4674,31 @@ var sr = (e) => {
|
|
|
4668
4674
|
this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility();
|
|
4669
4675
|
}
|
|
4670
4676
|
save() {
|
|
4671
|
-
return
|
|
4677
|
+
return Bi(this._data, this._element, this.getContentElement.bind(this), this._isOpen);
|
|
4672
4678
|
}
|
|
4673
4679
|
validate(e) {
|
|
4674
4680
|
return !0;
|
|
4675
4681
|
}
|
|
4676
4682
|
merge(e) {
|
|
4677
|
-
|
|
4683
|
+
Vi({
|
|
4678
4684
|
data: this._data,
|
|
4679
4685
|
getContentElement: this.getContentElement.bind(this),
|
|
4680
|
-
parseHTML:
|
|
4686
|
+
parseHTML: zi
|
|
4681
4687
|
}, e);
|
|
4682
4688
|
}
|
|
4683
4689
|
onPaste(t) {
|
|
4684
4690
|
let n = t.detail;
|
|
4685
4691
|
if (!("data" in n)) return;
|
|
4686
|
-
let r = n.data, i = r.querySelector("summary"), a =
|
|
4692
|
+
let r = n.data, i = r.querySelector("summary"), a = ne(i === null ? r.innerHTML : i.innerHTML, e.sanitize.text);
|
|
4687
4693
|
this._data = { text: a };
|
|
4688
4694
|
let o = this.getContentElement();
|
|
4689
4695
|
o !== null && (o.innerHTML = a);
|
|
4690
4696
|
}
|
|
4691
4697
|
setData(e) {
|
|
4692
|
-
let t =
|
|
4693
|
-
return this._data = t.newData, typeof this._data.isOpen == "boolean" && (this._isOpen = this._data.isOpen), this._arrowElement && this._element &&
|
|
4694
|
-
collapse: this.api.i18n.t(
|
|
4695
|
-
expand: this.api.i18n.t(
|
|
4698
|
+
let t = Hi(this._data, e, this.getContentElement.bind(this));
|
|
4699
|
+
return this._data = t.newData, typeof this._data.isOpen == "boolean" && (this._isOpen = this._data.isOpen), this._arrowElement && this._element && w(this._arrowElement, this._element, this._isOpen, {
|
|
4700
|
+
collapse: this.api.i18n.t(qe),
|
|
4701
|
+
expand: this.api.i18n.t(Fe)
|
|
4696
4702
|
}), this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility(), t.inPlace;
|
|
4697
4703
|
}
|
|
4698
4704
|
renderSettings() {
|
|
@@ -4714,19 +4720,19 @@ var sr = (e) => {
|
|
|
4714
4720
|
return this._contentElement;
|
|
4715
4721
|
}
|
|
4716
4722
|
setOpenState(e) {
|
|
4717
|
-
this._isOpen = e, this._arrowElement && this._element &&
|
|
4718
|
-
collapse: this.api.i18n.t(
|
|
4719
|
-
expand: this.api.i18n.t(
|
|
4723
|
+
this._isOpen = e, this._arrowElement && this._element && w(this._arrowElement, this._element, this._isOpen, {
|
|
4724
|
+
collapse: this.api.i18n.t(qe),
|
|
4725
|
+
expand: this.api.i18n.t(Fe)
|
|
4720
4726
|
}), this.updateChildrenVisibility(), this.updateBodyPlaceholderVisibility();
|
|
4721
4727
|
}
|
|
4722
4728
|
toggleOpen() {
|
|
4723
4729
|
this.setOpenState(!this._isOpen);
|
|
4724
4730
|
}
|
|
4725
4731
|
updateChildrenVisibility() {
|
|
4726
|
-
this.blockId !== void 0 &&
|
|
4732
|
+
this.blockId !== void 0 && gt(this.api, this.blockId, this._isOpen, this._childContainerElement, this._arrowElement);
|
|
4727
4733
|
}
|
|
4728
4734
|
updateBodyPlaceholderVisibility() {
|
|
4729
|
-
this.blockId !== void 0 &&
|
|
4735
|
+
this.blockId !== void 0 && _t(this._bodyPlaceholderElement, this.api, this.blockId, this._isOpen, this.readOnly);
|
|
4730
4736
|
}
|
|
4731
4737
|
handleBodyPlaceholderClick() {
|
|
4732
4738
|
var e;
|
|
@@ -4762,10 +4768,10 @@ var sr = (e) => {
|
|
|
4762
4768
|
}
|
|
4763
4769
|
async handleEnter() {
|
|
4764
4770
|
var e = this;
|
|
4765
|
-
await
|
|
4771
|
+
await vt(e.createKeyboardContext()), e.updateBodyPlaceholderVisibility();
|
|
4766
4772
|
}
|
|
4767
4773
|
async handleBackspace(e) {
|
|
4768
|
-
await
|
|
4774
|
+
await yt(this.createKeyboardContext(), e);
|
|
4769
4775
|
}
|
|
4770
4776
|
syncContentFromDOM() {
|
|
4771
4777
|
let e = this.getContentElement();
|
|
@@ -4773,10 +4779,10 @@ var sr = (e) => {
|
|
|
4773
4779
|
}
|
|
4774
4780
|
static get toolbox() {
|
|
4775
4781
|
return {
|
|
4776
|
-
icon:
|
|
4782
|
+
icon: Ke,
|
|
4777
4783
|
title: "Toggle list",
|
|
4778
4784
|
titleKey: "toggleList",
|
|
4779
|
-
name:
|
|
4785
|
+
name: Be,
|
|
4780
4786
|
searchTerms: [
|
|
4781
4787
|
"toggle",
|
|
4782
4788
|
"collapse",
|
|
@@ -4815,36 +4821,36 @@ var sr = (e) => {
|
|
|
4815
4821
|
static get isReadOnlySupported() {
|
|
4816
4822
|
return !0;
|
|
4817
4823
|
}
|
|
4818
|
-
},
|
|
4824
|
+
}, L = (e) => {
|
|
4819
4825
|
let t = e.tagName;
|
|
4820
4826
|
return t === "B" || t === "STRONG";
|
|
4821
|
-
},
|
|
4827
|
+
}, Wi = (e) => !!(e && e.nodeType === Node.ELEMENT_NODE && L(e)), Gi = (e) => e.textContent.length === 0, R = (e) => e ? e.nodeType === Node.ELEMENT_NODE && L(e) ? z(e) : R(e.parentNode) : null, z = (e) => {
|
|
4822
4828
|
if (e.tagName === "STRONG") return e;
|
|
4823
4829
|
let t = document.createElement("strong");
|
|
4824
4830
|
for (e.hasAttributes() && Array.from(e.attributes).forEach((e) => {
|
|
4825
4831
|
t.setAttribute(e.name, e.value);
|
|
4826
4832
|
}); e.firstChild;) t.appendChild(e.firstChild);
|
|
4827
4833
|
return e.replaceWith(t), t;
|
|
4828
|
-
},
|
|
4834
|
+
}, Ki = (e) => {
|
|
4829
4835
|
let t = e.nextSibling;
|
|
4830
4836
|
if ((t == null ? void 0 : t.nodeType) === Node.TEXT_NODE) return t;
|
|
4831
4837
|
let n = e.parentNode;
|
|
4832
4838
|
if (!n) return null;
|
|
4833
4839
|
let r = e.ownerDocument.createTextNode("");
|
|
4834
4840
|
return n.insertBefore(r, t), r;
|
|
4835
|
-
},
|
|
4841
|
+
}, qi = (e) => {
|
|
4836
4842
|
if (!e.boldElement.isConnected) return null;
|
|
4837
|
-
let t =
|
|
4843
|
+
let t = z(e.boldElement), n = e.boundary, r = n.isConnected && n.previousSibling === t ? n : Ki(t);
|
|
4838
4844
|
return r ? {
|
|
4839
4845
|
boundary: r,
|
|
4840
4846
|
boldElement: t
|
|
4841
4847
|
} : null;
|
|
4842
|
-
},
|
|
4848
|
+
}, Ji = (e, t) => e ? e === t || t.contains(e) : !1, Yi, B = {
|
|
4843
4849
|
COLLAPSED_LENGTH: "data-blok-bold-collapsed-length",
|
|
4844
4850
|
COLLAPSED_ACTIVE: "data-blok-bold-collapsed-active",
|
|
4845
4851
|
PREV_LENGTH: "data-blok-bold-prev-length",
|
|
4846
4852
|
LEADING_WHITESPACE: "data-blok-bold-leading-ws"
|
|
4847
|
-
},
|
|
4853
|
+
}, V = class e {
|
|
4848
4854
|
constructor() {
|
|
4849
4855
|
this.records = /* @__PURE__ */ new Set();
|
|
4850
4856
|
}
|
|
@@ -4858,15 +4864,15 @@ var sr = (e) => {
|
|
|
4858
4864
|
return this.records.size > 0;
|
|
4859
4865
|
}
|
|
4860
4866
|
isActivePlaceholder(e) {
|
|
4861
|
-
return e.getAttribute(
|
|
4867
|
+
return e.getAttribute(B.COLLAPSED_ACTIVE) === "true" || e.hasAttribute(B.COLLAPSED_LENGTH);
|
|
4862
4868
|
}
|
|
4863
4869
|
static get ATTR() {
|
|
4864
|
-
return
|
|
4870
|
+
return B;
|
|
4865
4871
|
}
|
|
4866
4872
|
enter(e, t) {
|
|
4867
4873
|
if (!e.collapsed) return;
|
|
4868
4874
|
let n = document.createElement("strong"), r = document.createTextNode("");
|
|
4869
|
-
n.appendChild(r), n.setAttribute(
|
|
4875
|
+
n.appendChild(r), n.setAttribute(B.COLLAPSED_ACTIVE, "true");
|
|
4870
4876
|
let i = e.startContainer, a = e.startOffset;
|
|
4871
4877
|
if (!(i.nodeType === Node.TEXT_NODE ? this.insertCollapsedBoldIntoText(i, n, a) : i.nodeType === Node.ELEMENT_NODE && (this.insertCollapsedBoldIntoElement(i, n, a), !0))) return;
|
|
4872
4878
|
let o = document.createRange();
|
|
@@ -4883,23 +4889,23 @@ var sr = (e) => {
|
|
|
4883
4889
|
let i = e.textContent, a = i.slice(0, n), o = i.slice(n);
|
|
4884
4890
|
e.textContent = a;
|
|
4885
4891
|
let s = o.length ? document.createTextNode(o) : null;
|
|
4886
|
-
return s && r.insertBefore(s, e.nextSibling), r.insertBefore(t, s == null ? e.nextSibling : s), t.setAttribute(
|
|
4892
|
+
return s && r.insertBefore(s, e.nextSibling), r.insertBefore(t, s == null ? e.nextSibling : s), t.setAttribute(B.PREV_LENGTH, a.length.toString()), !0;
|
|
4887
4893
|
}
|
|
4888
4894
|
insertCollapsedBoldIntoElement(e, t, n) {
|
|
4889
4895
|
var r;
|
|
4890
4896
|
let i = (r = e.childNodes[n]) == null ? null : r;
|
|
4891
|
-
e.insertBefore(t, i), t.setAttribute(
|
|
4897
|
+
e.insertBefore(t, i), t.setAttribute(B.PREV_LENGTH, "0");
|
|
4892
4898
|
}
|
|
4893
4899
|
exit(e, t) {
|
|
4894
|
-
let n =
|
|
4895
|
-
if (r) return
|
|
4900
|
+
let n = z(t), r = n.parentNode;
|
|
4901
|
+
if (r) return Gi(n) ? this.removeEmptyBoldElement(e, n, r) : this.exitBoldWithContent(e, n, r);
|
|
4896
4902
|
}
|
|
4897
4903
|
removeEmptyBoldElement(e, t, n) {
|
|
4898
4904
|
let r = document.createRange();
|
|
4899
4905
|
return r.setStartBefore(t), r.collapse(!0), n.removeChild(t), e.removeAllRanges(), e.addRange(r), r;
|
|
4900
4906
|
}
|
|
4901
4907
|
exitBoldWithContent(e, t, n) {
|
|
4902
|
-
t.setAttribute(
|
|
4908
|
+
t.setAttribute(B.COLLAPSED_LENGTH, t.textContent.length.toString()), t.removeAttribute(B.PREV_LENGTH), t.removeAttribute(B.COLLAPSED_ACTIVE), t.removeAttribute(B.LEADING_WHITESPACE);
|
|
4903
4909
|
let r = t.nextSibling, i = !r || r.nodeType !== Node.TEXT_NODE, a = i ? document.createTextNode("") : null;
|
|
4904
4910
|
a && n.insertBefore(a, r);
|
|
4905
4911
|
let o = a == null ? r : a;
|
|
@@ -4916,7 +4922,7 @@ var sr = (e) => {
|
|
|
4916
4922
|
}
|
|
4917
4923
|
maintain() {
|
|
4918
4924
|
if (!(typeof document > "u")) for (let e of Array.from(this.records)) {
|
|
4919
|
-
let t =
|
|
4925
|
+
let t = qi(e);
|
|
4920
4926
|
if (!t) {
|
|
4921
4927
|
this.records.delete(e);
|
|
4922
4928
|
continue;
|
|
@@ -4948,13 +4954,13 @@ var sr = (e) => {
|
|
|
4948
4954
|
c && this.records.delete(e);
|
|
4949
4955
|
}
|
|
4950
4956
|
synchronize(e) {
|
|
4951
|
-
var t,
|
|
4952
|
-
let
|
|
4953
|
-
if (!
|
|
4954
|
-
let
|
|
4955
|
-
|
|
4957
|
+
var t, n;
|
|
4958
|
+
let r = (t = e == null ? void 0 : e.anchorNode) == null ? e == null ? void 0 : e.focusNode : t, i = r && r.nodeType === Node.ELEMENT_NODE ? r : r == null ? void 0 : r.parentElement, a = (n = i == null ? void 0 : i.closest(y(v.editor))) == null ? i == null ? void 0 : i.ownerDocument : n;
|
|
4959
|
+
if (!a) return;
|
|
4960
|
+
let o = `strong[${B.COLLAPSED_ACTIVE}="true"]`;
|
|
4961
|
+
a.querySelectorAll(o).forEach((t) => {
|
|
4956
4962
|
var n;
|
|
4957
|
-
let r = t.getAttribute(
|
|
4963
|
+
let r = t.getAttribute(B.PREV_LENGTH), i = t.previousSibling;
|
|
4958
4964
|
if (!r || !i || i.nodeType !== Node.TEXT_NODE) return;
|
|
4959
4965
|
let a = Number(r);
|
|
4960
4966
|
if (!Number.isFinite(a)) return;
|
|
@@ -4963,26 +4969,26 @@ var sr = (e) => {
|
|
|
4963
4969
|
let c = s.slice(0, a), l = s.slice(a);
|
|
4964
4970
|
o.textContent = c;
|
|
4965
4971
|
let u = l.match(/^[\u00A0\s]+/);
|
|
4966
|
-
if (u && !t.hasAttribute(
|
|
4967
|
-
let d = t.textContent, f = d + l, p = (n = t.getAttribute(
|
|
4972
|
+
if (u && !t.hasAttribute(B.LEADING_WHITESPACE) && t.setAttribute(B.LEADING_WHITESPACE, u[0]), l.length === 0) return;
|
|
4973
|
+
let d = t.textContent, f = d + l, p = (n = t.getAttribute(B.LEADING_WHITESPACE)) == null ? "" : n, m = p.length > 0 && d.length === 0 && !f.startsWith(p) ? p + f : f, h = document.createTextNode(m);
|
|
4968
4974
|
for (; t.firstChild;) t.removeChild(t.firstChild);
|
|
4969
|
-
if (t.appendChild(h), !(e != null && e.isCollapsed) || !
|
|
4975
|
+
if (t.appendChild(h), !(e != null && e.isCollapsed) || !Ji(e.focusNode, o)) return;
|
|
4970
4976
|
let g = document.createRange(), _ = h.textContent.length;
|
|
4971
4977
|
g.setStart(h, _), g.collapse(!0), e.removeAllRanges(), e.addRange(g);
|
|
4972
4978
|
});
|
|
4973
4979
|
}
|
|
4974
4980
|
enforceLengths(e) {
|
|
4975
4981
|
var t;
|
|
4976
|
-
let
|
|
4977
|
-
if (!
|
|
4978
|
-
let
|
|
4979
|
-
|
|
4982
|
+
let n = (t = e == null ? void 0 : e.anchorNode) == null ? e == null ? void 0 : e.focusNode : t;
|
|
4983
|
+
if (!n) return;
|
|
4984
|
+
let r = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement, i = r == null ? void 0 : r.closest(y(v.editor));
|
|
4985
|
+
i && i.querySelectorAll(`strong[${B.COLLAPSED_LENGTH}]`).forEach((t) => {
|
|
4980
4986
|
var n;
|
|
4981
|
-
let r = t.getAttribute(
|
|
4987
|
+
let r = t.getAttribute(B.COLLAPSED_LENGTH);
|
|
4982
4988
|
if (!r) return;
|
|
4983
4989
|
let i = Number(r), a = t.textContent;
|
|
4984
4990
|
if (!Number.isFinite(i)) return;
|
|
4985
|
-
let o = a.length > i, s = o ? this.splitCollapsedBoldText(t, i, a) : null, c = t.getAttribute(
|
|
4991
|
+
let o = a.length > i, s = o ? this.splitCollapsedBoldText(t, i, a) : null, c = t.getAttribute(B.PREV_LENGTH), l = c ? Number(c) : NaN, u = t.previousSibling, d = (u == null ? void 0 : u.nodeType) === Node.TEXT_NODE ? u : null, f = (n = d == null ? void 0 : d.textContent) == null ? "" : n, p = !!(c && Number.isFinite(l) && d && f.length > l);
|
|
4986
4992
|
if (p && d) {
|
|
4987
4993
|
var m;
|
|
4988
4994
|
let e = f.slice(0, l), n = f.slice(l);
|
|
@@ -4990,11 +4996,11 @@ var sr = (e) => {
|
|
|
4990
4996
|
let r = document.createTextNode(n);
|
|
4991
4997
|
(m = t.parentNode) == null || m.insertBefore(r, t.nextSibling);
|
|
4992
4998
|
}
|
|
4993
|
-
if (p && t.removeAttribute(
|
|
4999
|
+
if (p && t.removeAttribute(B.PREV_LENGTH), e != null && e.isCollapsed && s && Ji(e.focusNode, t)) {
|
|
4994
5000
|
let t = document.createRange(), n = s.textContent.length;
|
|
4995
5001
|
t.setStart(s, n), t.collapse(!0), e.removeAllRanges(), e.addRange(t);
|
|
4996
5002
|
}
|
|
4997
|
-
o && t.removeAttribute(
|
|
5003
|
+
o && t.removeAttribute(B.COLLAPSED_LENGTH);
|
|
4998
5004
|
});
|
|
4999
5005
|
}
|
|
5000
5006
|
splitCollapsedBoldText(e, t, n) {
|
|
@@ -5026,8 +5032,8 @@ var sr = (e) => {
|
|
|
5026
5032
|
if (!e.rangeCount) return;
|
|
5027
5033
|
let t = e.getRangeAt(0);
|
|
5028
5034
|
if (!t.collapsed) return;
|
|
5029
|
-
let n =
|
|
5030
|
-
(n == null ? void 0 : n.getAttribute(
|
|
5035
|
+
let n = R(t.startContainer);
|
|
5036
|
+
(n == null ? void 0 : n.getAttribute(B.COLLAPSED_ACTIVE)) !== "true" && (this.moveCaretFromElementContainer(e, t) || this.moveCaretFromTextContainer(e, t));
|
|
5031
5037
|
}
|
|
5032
5038
|
moveCaretFromElementContainer(e, t) {
|
|
5033
5039
|
if (t.startContainer.nodeType !== Node.ELEMENT_NODE) return !1;
|
|
@@ -5057,7 +5063,7 @@ var sr = (e) => {
|
|
|
5057
5063
|
this.setCaret(e, n, i.length);
|
|
5058
5064
|
return;
|
|
5059
5065
|
}
|
|
5060
|
-
let o =
|
|
5066
|
+
let o = R(n);
|
|
5061
5067
|
if (!o || t.startOffset !== n.textContent.length) return;
|
|
5062
5068
|
let s = this.ensureFollowingTextNode(o, o.nextSibling);
|
|
5063
5069
|
if (s) {
|
|
@@ -5084,18 +5090,18 @@ var sr = (e) => {
|
|
|
5084
5090
|
return t.tagName === "STRONG" || t.tagName === "B";
|
|
5085
5091
|
}
|
|
5086
5092
|
};
|
|
5087
|
-
|
|
5093
|
+
Yi = V, Yi.instance = null;
|
|
5088
5094
|
//#endregion
|
|
5089
5095
|
//#region src/components/inline-tools/services/bold-normalization-pass.ts
|
|
5090
|
-
var
|
|
5096
|
+
var Xi = {
|
|
5091
5097
|
convertLegacyTags: !0,
|
|
5092
5098
|
normalizeWhitespace: !0,
|
|
5093
5099
|
removeEmpty: !0,
|
|
5094
5100
|
mergeAdjacent: !0,
|
|
5095
5101
|
preserveNode: null
|
|
5096
|
-
},
|
|
5102
|
+
}, H = class e {
|
|
5097
5103
|
constructor(e) {
|
|
5098
|
-
this.options =
|
|
5104
|
+
this.options = x(x({}, Xi), e);
|
|
5099
5105
|
}
|
|
5100
5106
|
run(e) {
|
|
5101
5107
|
if (typeof document > "u") return;
|
|
@@ -5130,7 +5136,7 @@ var Wi = {
|
|
|
5130
5136
|
processCollectedElements(e, t) {
|
|
5131
5137
|
this.options.convertLegacyTags && e.forEach((e) => {
|
|
5132
5138
|
if (e.isConnected) {
|
|
5133
|
-
let n =
|
|
5139
|
+
let n = z(e);
|
|
5134
5140
|
t.push(n);
|
|
5135
5141
|
}
|
|
5136
5142
|
}), t.forEach((e) => {
|
|
@@ -5148,30 +5154,30 @@ var Wi = {
|
|
|
5148
5154
|
t.includes("\xA0") && (e.textContent = t.replace(/\u00A0/g, " "));
|
|
5149
5155
|
}
|
|
5150
5156
|
isEmptyAndSafe(e) {
|
|
5151
|
-
return e.textContent.length !== 0 ||
|
|
5157
|
+
return e.textContent.length !== 0 || V.getInstance().isActivePlaceholder(e) ? !1 : !(this.options.preserveNode && Ji(this.options.preserveNode, e));
|
|
5152
5158
|
}
|
|
5153
5159
|
mergeWithAdjacent(e) {
|
|
5154
5160
|
let t = e.previousSibling;
|
|
5155
|
-
if (t &&
|
|
5161
|
+
if (t && Wi(t)) {
|
|
5156
5162
|
this.mergeStrongNodes(t, e);
|
|
5157
5163
|
return;
|
|
5158
5164
|
}
|
|
5159
5165
|
let n = e.nextSibling;
|
|
5160
|
-
n &&
|
|
5166
|
+
n && Wi(n) && this.mergeStrongNodes(e, n);
|
|
5161
5167
|
}
|
|
5162
5168
|
mergeStrongNodes(e, t) {
|
|
5163
|
-
let n =
|
|
5169
|
+
let n = z(e), r = z(t);
|
|
5164
5170
|
for (; r.firstChild;) n.appendChild(r.firstChild);
|
|
5165
5171
|
r.remove();
|
|
5166
5172
|
}
|
|
5167
5173
|
static findScopeFromSelection(e) {
|
|
5168
|
-
var t,
|
|
5169
|
-
let
|
|
5170
|
-
if (!
|
|
5171
|
-
let
|
|
5172
|
-
return
|
|
5174
|
+
var t, n;
|
|
5175
|
+
let r = (t = e == null ? void 0 : e.anchorNode) == null ? e == null ? void 0 : e.focusNode : t;
|
|
5176
|
+
if (!r) return null;
|
|
5177
|
+
let i = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement;
|
|
5178
|
+
return i ? ((n = i.closest("[data-blok-component=\"paragraph\"]")) == null ? i.closest(y(v.elementContent)) : n) || i.closest(y(v.editor)) : null;
|
|
5173
5179
|
}
|
|
5174
|
-
},
|
|
5180
|
+
}, Zi, Qi = class e {
|
|
5175
5181
|
constructor() {
|
|
5176
5182
|
this.handlers = /* @__PURE__ */ new Map(), this.listenersRegistered = !1, this.handleSelectionChange = () => {
|
|
5177
5183
|
let e = this.getSelection();
|
|
@@ -5228,10 +5234,10 @@ var Wi = {
|
|
|
5228
5234
|
return !(t.meta && !n || t.ctrl && !e.ctrlKey);
|
|
5229
5235
|
}
|
|
5230
5236
|
};
|
|
5231
|
-
|
|
5237
|
+
Zi = Qi, Zi.instance = null;
|
|
5232
5238
|
//#endregion
|
|
5233
5239
|
//#region src/components/inline-tools/utils/formatting-range-utils.ts
|
|
5234
|
-
var
|
|
5240
|
+
var $i = (e, t) => {
|
|
5235
5241
|
try {
|
|
5236
5242
|
return e.intersectsNode(t);
|
|
5237
5243
|
} catch (n) {
|
|
@@ -5240,26 +5246,26 @@ var qi = (e, t) => {
|
|
|
5240
5246
|
let i = e.compareBoundaryPoints(Range.END_TO_START, r) > 0, a = e.compareBoundaryPoints(Range.START_TO_END, r) < 0;
|
|
5241
5247
|
return i && a;
|
|
5242
5248
|
}
|
|
5243
|
-
},
|
|
5249
|
+
}, ea = (e) => {
|
|
5244
5250
|
var t;
|
|
5245
5251
|
let n = e.commonAncestorContainer, r = n.nodeType === Node.TEXT_NODE ? (t = n.parentNode) == null ? n : t : n;
|
|
5246
|
-
return document.createTreeWalker(r, NodeFilter.SHOW_TEXT, { acceptNode: (t) =>
|
|
5247
|
-
},
|
|
5248
|
-
if (e.collapsed) return
|
|
5249
|
-
let r =
|
|
5252
|
+
return document.createTreeWalker(r, NodeFilter.SHOW_TEXT, { acceptNode: (t) => $i(e, t) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT });
|
|
5253
|
+
}, U = (e, t, n) => !e || e === n ? null : e.nodeType === Node.ELEMENT_NODE && t(e) ? e : U(e.parentNode, t, n), ta = (e, t) => U(e, t) !== null, W = (e, t, n = {}) => {
|
|
5254
|
+
if (e.collapsed) return U(e.startContainer, t) !== null;
|
|
5255
|
+
let r = ea(e), i = [];
|
|
5250
5256
|
for (; r.nextNode();) {
|
|
5251
5257
|
let e = r.currentNode, t = e.textContent;
|
|
5252
5258
|
n.ignoreWhitespace && t.trim().length === 0 || t.length !== 0 && i.push(e);
|
|
5253
5259
|
}
|
|
5254
|
-
return i.length === 0 ?
|
|
5255
|
-
},
|
|
5256
|
-
let n = /* @__PURE__ */ new Set(), r =
|
|
5260
|
+
return i.length === 0 ? U(e.startContainer, t) !== null : i.every((e) => ta(e, t));
|
|
5261
|
+
}, G = (e, t) => {
|
|
5262
|
+
let n = /* @__PURE__ */ new Set(), r = ea(e);
|
|
5257
5263
|
for (; r.nextNode();) {
|
|
5258
|
-
let e =
|
|
5264
|
+
let e = U(r.currentNode, t);
|
|
5259
5265
|
e && n.add(e);
|
|
5260
5266
|
}
|
|
5261
5267
|
return Array.from(n);
|
|
5262
|
-
},
|
|
5268
|
+
}, K, na = class e {
|
|
5263
5269
|
static get sanitize() {
|
|
5264
5270
|
return {
|
|
5265
5271
|
strong: {},
|
|
@@ -5271,7 +5277,7 @@ var qi = (e, t) => {
|
|
|
5271
5277
|
}
|
|
5272
5278
|
static initializeGlobalListeners() {
|
|
5273
5279
|
if (typeof document > "u") return !1;
|
|
5274
|
-
let t =
|
|
5280
|
+
let t = Qi.getInstance();
|
|
5275
5281
|
return t.hasHandler("bold") ? !0 : (t.register("bold", {
|
|
5276
5282
|
shortcut: {
|
|
5277
5283
|
key: "b",
|
|
@@ -5287,20 +5293,20 @@ var qi = (e, t) => {
|
|
|
5287
5293
|
onInput: (t, n) => {
|
|
5288
5294
|
e.refreshSelectionState("input");
|
|
5289
5295
|
},
|
|
5290
|
-
onBeforeInput: (e) => e.inputType === "formatBold" ? (
|
|
5296
|
+
onBeforeInput: (e) => e.inputType === "formatBold" ? (H.normalizeAroundSelection(window.getSelection()), !0) : !1,
|
|
5291
5297
|
isRelevant: (t) => e.isSelectionInsideBlok(t)
|
|
5292
5298
|
}), e.guardKeydownListenerRegistered || (document.addEventListener("keydown", (e) => {
|
|
5293
|
-
|
|
5299
|
+
V.getInstance().guardBoundaryKeydown(e);
|
|
5294
5300
|
}, !0), e.guardKeydownListenerRegistered = !0), e.ensureMutationObserver(), !0);
|
|
5295
5301
|
}
|
|
5296
5302
|
static mergeStrongNodes(e, t) {
|
|
5297
|
-
let n =
|
|
5303
|
+
let n = z(e), r = z(t);
|
|
5298
5304
|
for (; r.firstChild;) n.appendChild(r.firstChild);
|
|
5299
5305
|
return r.remove(), n;
|
|
5300
5306
|
}
|
|
5301
5307
|
render() {
|
|
5302
5308
|
return {
|
|
5303
|
-
icon:
|
|
5309
|
+
icon: o,
|
|
5304
5310
|
name: "bold",
|
|
5305
5311
|
onActivate: () => {
|
|
5306
5312
|
this.toggleBold();
|
|
@@ -5331,11 +5337,11 @@ var qi = (e, t) => {
|
|
|
5331
5337
|
r && n && (r.removeAllRanges(), r.addRange(n));
|
|
5332
5338
|
let i = this.findBoldElementFromRangeOrSelection(n, r);
|
|
5333
5339
|
if (!i) {
|
|
5334
|
-
|
|
5340
|
+
H.normalizeAroundSelection(r), this.notifySelectionChange();
|
|
5335
5341
|
return;
|
|
5336
5342
|
}
|
|
5337
5343
|
let a = this.mergeAdjacentBold(i);
|
|
5338
|
-
this.selectElementContents(a),
|
|
5344
|
+
this.selectElementContents(a), H.normalizeAroundSelection(r), this.notifySelectionChange();
|
|
5339
5345
|
}
|
|
5340
5346
|
unwrapBoldTags(t) {
|
|
5341
5347
|
let n = this.collectBoldAncestors(t), r = window.getSelection();
|
|
@@ -5344,7 +5350,7 @@ var qi = (e, t) => {
|
|
|
5344
5350
|
i.setAttribute("data-blok-bold-marker", `unwrap-${e.markerSequence++}`), i.appendChild(a), this.removeNestedBold(i), t.insertNode(i);
|
|
5345
5351
|
let o = document.createRange();
|
|
5346
5352
|
for (o.selectNodeContents(i), r.removeAllRanges(), r.addRange(o);;) {
|
|
5347
|
-
let e =
|
|
5353
|
+
let e = R(i);
|
|
5348
5354
|
if (!e) break;
|
|
5349
5355
|
this.moveMarkerOutOfBold(i, e);
|
|
5350
5356
|
}
|
|
@@ -5352,8 +5358,8 @@ var qi = (e, t) => {
|
|
|
5352
5358
|
this.unwrapElement(i), s && c && (() => {
|
|
5353
5359
|
let e = document.createRange();
|
|
5354
5360
|
return e.setStartBefore(s), e.setEndAfter(c), r.removeAllRanges(), r.addRange(e), e;
|
|
5355
|
-
})() || r.removeAllRanges(),
|
|
5356
|
-
|
|
5361
|
+
})() || r.removeAllRanges(), H.normalizeAroundSelection(r), n.forEach((e) => {
|
|
5362
|
+
Gi(e) && e.remove();
|
|
5357
5363
|
}), this.notifySelectionChange();
|
|
5358
5364
|
}
|
|
5359
5365
|
replaceRangeWithHtml(t, n) {
|
|
@@ -5393,7 +5399,7 @@ var qi = (e, t) => {
|
|
|
5393
5399
|
n.selectNodeContents(e), t.removeAllRanges(), t.addRange(n);
|
|
5394
5400
|
}
|
|
5395
5401
|
isRangeBold(e, t) {
|
|
5396
|
-
return
|
|
5402
|
+
return W(e, L, t);
|
|
5397
5403
|
}
|
|
5398
5404
|
removeNestedBold(e) {
|
|
5399
5405
|
e.querySelectorAll("b,strong").forEach((e) => {
|
|
@@ -5410,42 +5416,42 @@ var qi = (e, t) => {
|
|
|
5410
5416
|
t.removeChild(e);
|
|
5411
5417
|
}
|
|
5412
5418
|
findBoldElementFromRangeOrSelection(e, t) {
|
|
5413
|
-
return e ?
|
|
5419
|
+
return e ? R(e.startContainer) || R(e.commonAncestorContainer) || (e.startContainer.nodeType === Node.ELEMENT_NODE && L(e.startContainer) ? e.startContainer : null) : t ? R(t.focusNode) : null;
|
|
5414
5420
|
}
|
|
5415
5421
|
mergeAdjacentBold(t) {
|
|
5416
|
-
let n =
|
|
5417
|
-
return a && a.nodeType === Node.ELEMENT_NODE &&
|
|
5422
|
+
let n = z(t), r = n.previousSibling, i = r && r.nodeType === Node.ELEMENT_NODE && L(r) ? e.mergeStrongNodes(r, n) : n, a = i.nextSibling;
|
|
5423
|
+
return a && a.nodeType === Node.ELEMENT_NODE && L(a) ? e.mergeStrongNodes(i, a) : i;
|
|
5418
5424
|
}
|
|
5419
5425
|
toggleCollapsedSelection() {
|
|
5420
5426
|
let t = window.getSelection();
|
|
5421
5427
|
if (!t || t.rangeCount === 0) return;
|
|
5422
|
-
let n = t.getRangeAt(0), r =
|
|
5423
|
-
if (r && r.getAttribute(
|
|
5428
|
+
let n = t.getRangeAt(0), r = R(n.startContainer), i = (() => {
|
|
5429
|
+
if (r && r.getAttribute(V.ATTR.COLLAPSED_ACTIVE) !== "true") return V.getInstance().exit(t, r);
|
|
5424
5430
|
let i = r == null ? e.getBoundaryBold(n) : r;
|
|
5425
|
-
return i ?
|
|
5431
|
+
return i ? V.getInstance().exit(t, i) : this.startCollapsedBold(n);
|
|
5426
5432
|
})();
|
|
5427
|
-
document.dispatchEvent(new Event("selectionchange")), i && (t.removeAllRanges(), t.addRange(i)),
|
|
5433
|
+
document.dispatchEvent(new Event("selectionchange")), i && (t.removeAllRanges(), t.addRange(i)), H.normalizeAroundSelection(t), this.notifySelectionChange();
|
|
5428
5434
|
}
|
|
5429
5435
|
startCollapsedBold(e) {
|
|
5430
|
-
let t =
|
|
5431
|
-
return
|
|
5436
|
+
let t = V.getInstance().enter(e, (e) => this.mergeAdjacentBold(e)), n = window.getSelection();
|
|
5437
|
+
return H.normalizeAroundSelection(n), n && t && (n.removeAllRanges(), n.addRange(t)), this.notifySelectionChange(), t;
|
|
5432
5438
|
}
|
|
5433
5439
|
notifySelectionChange() {
|
|
5434
|
-
|
|
5440
|
+
V.getInstance().enforceLengths(window.getSelection()), document.dispatchEvent(new Event("selectionchange")), this.updateToolbarButtonState();
|
|
5435
5441
|
}
|
|
5436
5442
|
updateToolbarButtonState() {
|
|
5437
5443
|
let e = window.getSelection();
|
|
5438
5444
|
if (!e) return;
|
|
5439
|
-
let t = e.anchorNode,
|
|
5440
|
-
if (!
|
|
5441
|
-
let
|
|
5442
|
-
if (!(
|
|
5443
|
-
let
|
|
5444
|
-
|
|
5445
|
+
let t = e.anchorNode, n = (t == null ? void 0 : t.nodeType) === Node.ELEMENT_NODE ? t : t == null ? void 0 : t.parentElement, r = n == null ? void 0 : n.closest(y(v.editor));
|
|
5446
|
+
if (!r) return;
|
|
5447
|
+
let i = r.querySelector("[data-blok-testid=inline-toolbar]");
|
|
5448
|
+
if (!(i instanceof HTMLElement)) return;
|
|
5449
|
+
let a = i.querySelector("[data-blok-item-name=\"bold\"]");
|
|
5450
|
+
a instanceof HTMLElement && (this.isSelectionVisuallyBold(e) ? a.setAttribute("data-blok-popover-item-active", "true") : a.removeAttribute("data-blok-popover-item-active"));
|
|
5445
5451
|
}
|
|
5446
5452
|
static refreshSelectionState(e) {
|
|
5447
5453
|
let t = window.getSelection();
|
|
5448
|
-
|
|
5454
|
+
V.getInstance().enforceLengths(t), V.getInstance().maintain(), V.getInstance().synchronize(t), H.normalizeAroundSelection(t, { normalizeWhitespace: !1 }), e === "input" && t && V.getInstance().moveCaretAfterBoundaryBold(t);
|
|
5449
5455
|
}
|
|
5450
5456
|
static ensureMutationObserver() {
|
|
5451
5457
|
if (typeof MutationObserver > "u" || e.mutationObserver) return;
|
|
@@ -5454,7 +5460,7 @@ var qi = (e, t) => {
|
|
|
5454
5460
|
e.isProcessingMutation = !0;
|
|
5455
5461
|
try {
|
|
5456
5462
|
let n = (e) => {
|
|
5457
|
-
e && new
|
|
5463
|
+
e && new H({
|
|
5458
5464
|
mergeAdjacent: !1,
|
|
5459
5465
|
removeEmpty: !1,
|
|
5460
5466
|
normalizeWhitespace: !1
|
|
@@ -5478,7 +5484,7 @@ var qi = (e, t) => {
|
|
|
5478
5484
|
}
|
|
5479
5485
|
static findBlokScopeFromNode(e) {
|
|
5480
5486
|
let t = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
5481
|
-
return !t || typeof t.closest != "function" ? null : t.closest(`${v
|
|
5487
|
+
return !t || typeof t.closest != "function" ? null : t.closest(`${y(v.interface)}, ${y(v.editor)}`);
|
|
5482
5488
|
}
|
|
5483
5489
|
static getBoundaryBold(t) {
|
|
5484
5490
|
let n = t.startContainer;
|
|
@@ -5486,21 +5492,21 @@ var qi = (e, t) => {
|
|
|
5486
5492
|
}
|
|
5487
5493
|
static getBoundaryBoldForText(e, t) {
|
|
5488
5494
|
let n = t.textContent.length;
|
|
5489
|
-
if (e.startOffset === n) return
|
|
5495
|
+
if (e.startOffset === n) return R(t);
|
|
5490
5496
|
if (e.startOffset !== 0) return null;
|
|
5491
5497
|
let r = t.previousSibling;
|
|
5492
|
-
return
|
|
5498
|
+
return Wi(r) ? r : null;
|
|
5493
5499
|
}
|
|
5494
5500
|
static getBoundaryBoldForElement(e, t) {
|
|
5495
5501
|
if (e.startOffset <= 0) return null;
|
|
5496
5502
|
let n = t.childNodes[e.startOffset - 1];
|
|
5497
|
-
return
|
|
5503
|
+
return Wi(n) ? n : null;
|
|
5498
5504
|
}
|
|
5499
5505
|
static isSelectionInsideBlok(e) {
|
|
5500
5506
|
let t = e.anchorNode;
|
|
5501
5507
|
if (!t) return !1;
|
|
5502
|
-
let
|
|
5503
|
-
return !!(
|
|
5508
|
+
let n = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
|
|
5509
|
+
return !!(n != null && n.closest(y(v.editor)));
|
|
5504
5510
|
}
|
|
5505
5511
|
getRangeHtmlWithoutBold(e) {
|
|
5506
5512
|
let t = e.cloneContents();
|
|
@@ -5513,16 +5519,16 @@ var qi = (e, t) => {
|
|
|
5513
5519
|
return t.innerHTML = e, t.content;
|
|
5514
5520
|
}
|
|
5515
5521
|
collectBoldAncestors(e) {
|
|
5516
|
-
return
|
|
5522
|
+
return G(e, L);
|
|
5517
5523
|
}
|
|
5518
5524
|
};
|
|
5519
|
-
|
|
5525
|
+
K = na, K.isInline = !0, K.title = "Bold", K.titleKey = "bold", K.markerSequence = 0, K.isProcessingMutation = !1, K.instances = /* @__PURE__ */ new Set(), K.guardKeydownListenerRegistered = !1, K.shortcut = "CMD+B";
|
|
5520
5526
|
//#endregion
|
|
5521
5527
|
//#region src/components/inline-tools/inline-tool-italic.ts
|
|
5522
|
-
var
|
|
5528
|
+
var q, ra = (e) => {
|
|
5523
5529
|
let t = e.tagName;
|
|
5524
5530
|
return t === "I" || t === "EM";
|
|
5525
|
-
},
|
|
5531
|
+
}, ia = class {
|
|
5526
5532
|
static get sanitize() {
|
|
5527
5533
|
return {
|
|
5528
5534
|
i: {},
|
|
@@ -5531,7 +5537,7 @@ var X, Qi = (e) => {
|
|
|
5531
5537
|
}
|
|
5532
5538
|
render() {
|
|
5533
5539
|
return {
|
|
5534
|
-
icon:
|
|
5540
|
+
icon: u,
|
|
5535
5541
|
name: "italic",
|
|
5536
5542
|
onActivate: () => {
|
|
5537
5543
|
this.toggleItalic();
|
|
@@ -5571,7 +5577,7 @@ var X, Qi = (e) => {
|
|
|
5571
5577
|
return this.isRangeItalic(t, { ignoreWhitespace: !0 });
|
|
5572
5578
|
}
|
|
5573
5579
|
isRangeItalic(e, t) {
|
|
5574
|
-
return
|
|
5580
|
+
return W(e, ra, t);
|
|
5575
5581
|
}
|
|
5576
5582
|
wrapWithItalic(e) {
|
|
5577
5583
|
let t = this.getRangeHtmlWithoutItalic(e), n = this.replaceRangeWithHtml(e, `<i>${t}</i>`), r = window.getSelection();
|
|
@@ -5597,13 +5603,13 @@ var X, Qi = (e) => {
|
|
|
5597
5603
|
});
|
|
5598
5604
|
}
|
|
5599
5605
|
hasItalicParent(e) {
|
|
5600
|
-
return
|
|
5606
|
+
return ta(e, ra);
|
|
5601
5607
|
}
|
|
5602
5608
|
findItalicElement(e) {
|
|
5603
|
-
return
|
|
5609
|
+
return U(e, ra);
|
|
5604
5610
|
}
|
|
5605
5611
|
collectItalicAncestors(e) {
|
|
5606
|
-
return
|
|
5612
|
+
return G(e, ra);
|
|
5607
5613
|
}
|
|
5608
5614
|
getRangeHtmlWithoutItalic(e) {
|
|
5609
5615
|
let t = e.cloneContents();
|
|
@@ -5660,10 +5666,10 @@ var X, Qi = (e) => {
|
|
|
5660
5666
|
n.insertBefore(r, t.nextSibling), n.insertBefore(e, r);
|
|
5661
5667
|
}
|
|
5662
5668
|
};
|
|
5663
|
-
|
|
5669
|
+
q = ia, q.isInline = !0, q.title = "Italic", q.titleKey = "italic", q.shortcut = "CMD+I";
|
|
5664
5670
|
//#endregion
|
|
5665
5671
|
//#region src/components/inline-tools/inline-tool-link.ts
|
|
5666
|
-
var
|
|
5672
|
+
var J, aa = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text-left cursor-pointer can-hover:hover:bg-item-hover-bg transition-colors", oa = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text-left pointer-events-none", sa = class {
|
|
5667
5673
|
static get sanitize() {
|
|
5668
5674
|
return { a: {
|
|
5669
5675
|
href: !0,
|
|
@@ -5683,17 +5689,17 @@ var Z, ea = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text
|
|
|
5683
5689
|
button: null
|
|
5684
5690
|
}, this.inputOpened = !1, this.unlinkAvailable = !1, this.handleButtonClick = (e) => {
|
|
5685
5691
|
!this.inputOpened || !this.unlinkAvailable || (e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation(), this.restoreSelection(), this.unlink(), this.inlineToolbar.close());
|
|
5686
|
-
}, this.toolbar = e.toolbar, this.inlineToolbar = e.inlineToolbar, this.notifier = e.notifier, this.i18n = e.i18n, this.selection = new
|
|
5692
|
+
}, this.toolbar = e.toolbar, this.inlineToolbar = e.inlineToolbar, this.notifier = e.notifier, this.i18n = e.i18n, this.selection = new _(), this.nodes.input = this.createInput(), this.nodes.suggestion = this.createSuggestion(), this.nodes.inputWrapper = document.createElement("div"), this.nodes.inputWrapper.append(this.nodes.input, this.nodes.suggestion);
|
|
5687
5693
|
}
|
|
5688
5694
|
render() {
|
|
5689
5695
|
return {
|
|
5690
|
-
icon:
|
|
5696
|
+
icon: h,
|
|
5691
5697
|
name: "link",
|
|
5692
5698
|
isActive: () => !!this.selection.findParentTag("A"),
|
|
5693
5699
|
children: {
|
|
5694
5700
|
hideChevron: !0,
|
|
5695
5701
|
items: [{
|
|
5696
|
-
type:
|
|
5702
|
+
type: p.Html,
|
|
5697
5703
|
element: this.nodes.inputWrapper
|
|
5698
5704
|
}],
|
|
5699
5705
|
onOpen: () => {
|
|
@@ -5723,7 +5729,7 @@ var Z, ea = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text
|
|
|
5723
5729
|
let t = document.createElement("div");
|
|
5724
5730
|
t.className = "mt-1 mb-0.5 h-px bg-link-input-border";
|
|
5725
5731
|
let n = document.createElement("button");
|
|
5726
|
-
n.type = "button", n.className =
|
|
5732
|
+
n.type = "button", n.className = aa, n.setAttribute("data-link-suggestion-row", "");
|
|
5727
5733
|
let r = document.createElement("span");
|
|
5728
5734
|
r.className = "text-gray-text shrink-0 flex [&>svg]:size-7", r.setAttribute("data-link-suggestion-icon", "");
|
|
5729
5735
|
let i = document.createElement("span");
|
|
@@ -5741,20 +5747,20 @@ var Z, ea = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text
|
|
|
5741
5747
|
return;
|
|
5742
5748
|
}
|
|
5743
5749
|
let n = this.isLinkComplete(t), { icon: r, label: i } = this.getLinkTypeInfo(t), a = this.nodes.suggestion.querySelector("[data-link-suggestion-icon]"), o = this.nodes.suggestion.querySelector("[data-link-suggestion-url]"), s = this.nodes.suggestion.querySelector("[data-link-suggestion-type]"), c = this.nodes.suggestion.querySelector("[data-link-suggestion-row]");
|
|
5744
|
-
a && (a.innerHTML = r, a.className = `${n ? "text-gray-text" : "text-gray-text opacity-40"} shrink-0 flex [&>svg]:size-7`), o && (o.textContent = t, o.className = `block text-xs font-medium truncate ${n ? "text-text-primary" : "text-gray-text"}`), s && (s.textContent = n ? i : "Keep typing to add a link", s.className = "block text-[10.5px] text-gray-text leading-tight mt-px"), c && (c.className = n ?
|
|
5750
|
+
a && (a.innerHTML = r, a.className = `${n ? "text-gray-text" : "text-gray-text opacity-40"} shrink-0 flex [&>svg]:size-7`), o && (o.textContent = t, o.className = `block text-xs font-medium truncate ${n ? "text-text-primary" : "text-gray-text"}`), s && (s.textContent = n ? i : "Keep typing to add a link", s.className = "block text-[10.5px] text-gray-text leading-tight mt-px"), c && (c.className = n ? aa : oa), this.nodes.suggestion.classList.remove("hidden");
|
|
5745
5751
|
}
|
|
5746
5752
|
isLinkComplete(e) {
|
|
5747
5753
|
return /^https?:\/\//i.test(e) ? e.replace(/^https?:\/\//i, "").length > 0 : /^\w+:\/\//.test(e) ? e.replace(/^\w+:\/\//, "").length > 0 : /^\w+:/.test(e) ? e.slice(e.indexOf(":") + 1).length > 0 : e.startsWith("//") ? e.slice(2).length > 0 : e.startsWith("#") ? e.length > 1 : e.startsWith("/") ? !0 : /\.[a-zA-Z]{2,}/.test(e) || /^\d{1,3}(\.\d{1,3}){3}/.test(e);
|
|
5748
5754
|
}
|
|
5749
5755
|
getLinkTypeInfo(e) {
|
|
5750
5756
|
return e.startsWith("mailto:") ? {
|
|
5751
|
-
icon:
|
|
5757
|
+
icon: ue,
|
|
5752
5758
|
label: "Email address"
|
|
5753
5759
|
} : e.startsWith("#") ? {
|
|
5754
|
-
icon:
|
|
5760
|
+
icon: ie,
|
|
5755
5761
|
label: "Jump to section"
|
|
5756
5762
|
} : {
|
|
5757
|
-
icon:
|
|
5763
|
+
icon: ke,
|
|
5758
5764
|
label: "Link to web page"
|
|
5759
5765
|
};
|
|
5760
5766
|
}
|
|
@@ -5779,7 +5785,7 @@ var Z, ea = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text
|
|
|
5779
5785
|
let e = t.getAttribute("href");
|
|
5780
5786
|
this.nodes.input.value = e === null ? "" : e;
|
|
5781
5787
|
} else this.nodes.input.value = "";
|
|
5782
|
-
this.updateSuggestion(this.nodes.input.value), this.nodes.input.className =
|
|
5788
|
+
this.updateSuggestion(this.nodes.input.value), this.nodes.input.className = S(this.INPUT_BASE_CLASSES, "block"), this.setBooleanStateAttribute(this.nodes.input, this.DATA_ATTRIBUTES.inputOpened, !0), this.selection.setFakeBackground(), this.selection.save(), e && this.focusInputWithRetry(), this.inputOpened = !0;
|
|
5783
5789
|
}
|
|
5784
5790
|
focusInputWithRetry() {
|
|
5785
5791
|
this.nodes.input && (this.nodes.input.focus(), !(typeof window > "u" || typeof document > "u") && window.setTimeout(() => {
|
|
@@ -5790,7 +5796,7 @@ var Z, ea = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text
|
|
|
5790
5796
|
}, 0));
|
|
5791
5797
|
}
|
|
5792
5798
|
getButtonElement() {
|
|
5793
|
-
let e = document.querySelector(`${v
|
|
5799
|
+
let e = document.querySelector(`${y(v.interface, i)} [data-blok-item-name="link"]`);
|
|
5794
5800
|
return e && e !== this.nodes.button && (e.addEventListener("click", this.handleButtonClick, !0), this.nodes.button = e), e;
|
|
5795
5801
|
}
|
|
5796
5802
|
updateButtonStateAttributes(e) {
|
|
@@ -5804,7 +5810,7 @@ var Z, ea = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text
|
|
|
5804
5810
|
(this.selection.isFakeBackgroundEnabled || e && this.selection.savedSelectionRange) && this.restoreSelection(), this.nodes.input && (this.nodes.input.className = this.INPUT_BASE_CLASSES, this.setBooleanStateAttribute(this.nodes.input, this.DATA_ATTRIBUTES.inputOpened, !1), this.nodes.input.value = "", (t = this.nodes.suggestion) == null || t.classList.add("hidden"), this.updateButtonStateAttributes(!1), this.unlinkAvailable = !1, e && this.selection.clearSaved(), this.inputOpened = !1);
|
|
5805
5811
|
}
|
|
5806
5812
|
restoreSelection() {
|
|
5807
|
-
let e = new
|
|
5813
|
+
let e = new _(), t = _.isAtBlok;
|
|
5808
5814
|
if (t && e.save(), this.selection.removeFakeBackground(), this.selection.restore(), !t && this.selection.savedSelectionRange) {
|
|
5809
5815
|
let e = this.selection.savedSelectionRange.commonAncestorContainer, t = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
5810
5816
|
t == null || t.focus();
|
|
@@ -5828,7 +5834,7 @@ var Z, ea = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text
|
|
|
5828
5834
|
this.notifier.show({
|
|
5829
5835
|
message: this.i18n.t("tools.link.invalidLink"),
|
|
5830
5836
|
style: "error"
|
|
5831
|
-
}),
|
|
5837
|
+
}), s("Incorrect Link pasted", "warn", t);
|
|
5832
5838
|
return;
|
|
5833
5839
|
}
|
|
5834
5840
|
let n = this.prepareLink(t);
|
|
@@ -5851,7 +5857,7 @@ var Z, ea = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text
|
|
|
5851
5857
|
this.selection.expandToTag(t), t.href = e, t.target = "_blank", t.rel = "nofollow";
|
|
5852
5858
|
return;
|
|
5853
5859
|
}
|
|
5854
|
-
let n =
|
|
5860
|
+
let n = _.range;
|
|
5855
5861
|
if (!n) return;
|
|
5856
5862
|
let r = document.createElement("a");
|
|
5857
5863
|
r.href = e, r.target = "_blank", r.rel = "nofollow", r.appendChild(n.extractContents()), n.insertNode(r), this.selection.expandToTag(r);
|
|
@@ -5870,13 +5876,13 @@ var Z, ea = "flex items-center gap-2 w-full mt-0.5 px-1.5 py-1.5 rounded-md text
|
|
|
5870
5876
|
e && e.setAttribute(t, n ? "true" : "false");
|
|
5871
5877
|
}
|
|
5872
5878
|
};
|
|
5873
|
-
|
|
5879
|
+
J = sa, J.isInline = !0, J.title = "Link", J.titleKey = "link", J.shortcut = "CMD+K";
|
|
5874
5880
|
//#endregion
|
|
5875
5881
|
//#region src/components/inline-tools/utils/marker-dom-utils.ts
|
|
5876
|
-
var
|
|
5882
|
+
var Y = (e) => e.tagName === "MARK", ca = (e) => U(e, Y), X, la = {
|
|
5877
5883
|
color: "background-color",
|
|
5878
5884
|
"background-color": "color"
|
|
5879
|
-
},
|
|
5885
|
+
}, ua = class e {
|
|
5880
5886
|
static get sanitize() {
|
|
5881
5887
|
return { mark: (t) => {
|
|
5882
5888
|
let n = t.style, r = Array.from({ length: n.length }, (e, t) => n.item(t));
|
|
@@ -5885,7 +5891,7 @@ var Q = (e) => e.tagName === "MARK", ra = (e) => q(e, Q), $, ia = {
|
|
|
5885
5891
|
} };
|
|
5886
5892
|
}
|
|
5887
5893
|
constructor({ api: e }) {
|
|
5888
|
-
this.colorMode = "color", this.activeTextColor = null, this.activeBgColor = null, this.i18n = e.i18n, this.inlineToolbar = e.inlineToolbar, this.selection = new
|
|
5894
|
+
this.colorMode = "color", this.activeTextColor = null, this.activeBgColor = null, this.i18n = e.i18n, this.inlineToolbar = e.inlineToolbar, this.selection = new _(), this.picker = sr({
|
|
5889
5895
|
i18n: this.i18n,
|
|
5890
5896
|
testIdPrefix: "marker",
|
|
5891
5897
|
modes: [{
|
|
@@ -5904,12 +5910,12 @@ var Q = (e) => e.tagName === "MARK", ra = (e) => q(e, Q), $, ia = {
|
|
|
5904
5910
|
}
|
|
5905
5911
|
render() {
|
|
5906
5912
|
return {
|
|
5907
|
-
icon:
|
|
5913
|
+
icon: fe,
|
|
5908
5914
|
name: "marker",
|
|
5909
5915
|
isActive: () => {
|
|
5910
5916
|
let e = window.getSelection();
|
|
5911
5917
|
if (!e || e.rangeCount === 0) return !1;
|
|
5912
|
-
let t = e.getRangeAt(0), n =
|
|
5918
|
+
let t = e.getRangeAt(0), n = W(t, Y, { ignoreWhitespace: !0 });
|
|
5913
5919
|
if (n) {
|
|
5914
5920
|
let e = this.detectBothSelectionColors(t);
|
|
5915
5921
|
this.updateToolbarColors(e.text, e.bg);
|
|
@@ -5919,7 +5925,7 @@ var Q = (e) => e.tagName === "MARK", ra = (e) => q(e, Q), $, ia = {
|
|
|
5919
5925
|
children: {
|
|
5920
5926
|
hideChevron: !0,
|
|
5921
5927
|
items: [{
|
|
5922
|
-
type:
|
|
5928
|
+
type: p.Html,
|
|
5923
5929
|
element: this.picker.element
|
|
5924
5930
|
}],
|
|
5925
5931
|
onOpen: () => {
|
|
@@ -5960,10 +5966,10 @@ var Q = (e) => e.tagName === "MARK", ra = (e) => q(e, Q), $, ia = {
|
|
|
5960
5966
|
if (!r || r.rangeCount === 0) return;
|
|
5961
5967
|
let i = r.getRangeAt(0), a = i.startContainer, o = i.startOffset, s = i.endContainer, c = i.endOffset, l = i.toString(), u = i.commonAncestorContainer, d = u.nodeType === Node.ELEMENT_NODE ? u : u.parentElement, f = d != null && d.closest("mark") ? (t = (n = d.closest("mark")) == null ? void 0 : n.parentElement) == null ? d : t : d;
|
|
5962
5968
|
this.splitMarksAtBoundaries(i);
|
|
5963
|
-
let p =
|
|
5969
|
+
let p = G(i, Y);
|
|
5964
5970
|
for (let t of p) {
|
|
5965
5971
|
t.style.removeProperty(e);
|
|
5966
|
-
let n =
|
|
5972
|
+
let n = la[e], r = t.style.getPropertyValue(n);
|
|
5967
5973
|
r !== "" && r !== "transparent" ? this.ensureTransparentBg(t) : this.unwrapElement(t);
|
|
5968
5974
|
}
|
|
5969
5975
|
let m = a.isConnected, h = s.isConnected;
|
|
@@ -5991,7 +5997,7 @@ var Q = (e) => e.tagName === "MARK", ra = (e) => q(e, Q), $, ia = {
|
|
|
5991
5997
|
this.selection.removeFakeBackground(), this.selection.savedSelectionRange && this.selection.restore(), this.selection.clearSaved();
|
|
5992
5998
|
}
|
|
5993
5999
|
detectBothSelectionColors(e) {
|
|
5994
|
-
let t =
|
|
6000
|
+
let t = ca(e.startContainer);
|
|
5995
6001
|
if (!t) return {
|
|
5996
6002
|
text: null,
|
|
5997
6003
|
bg: null
|
|
@@ -6011,7 +6017,7 @@ var Q = (e) => e.tagName === "MARK", ra = (e) => q(e, Q), $, ia = {
|
|
|
6011
6017
|
text: null,
|
|
6012
6018
|
bg: null
|
|
6013
6019
|
};
|
|
6014
|
-
let t =
|
|
6020
|
+
let t = ca(e.getRangeAt(0).startContainer);
|
|
6015
6021
|
if (!t) return {
|
|
6016
6022
|
text: null,
|
|
6017
6023
|
bg: null
|
|
@@ -6031,14 +6037,14 @@ var Q = (e) => e.tagName === "MARK", ra = (e) => q(e, Q), $, ia = {
|
|
|
6031
6037
|
this.selection.savedSelectionRange && (this.selection.removeFakeBackground(), this.selection.restore(), this.selection.clearSaved());
|
|
6032
6038
|
}
|
|
6033
6039
|
findContainingMark(e) {
|
|
6034
|
-
let t =
|
|
6040
|
+
let t = ca(e.startContainer), n = ca(e.endContainer);
|
|
6035
6041
|
return t && t === n ? t : null;
|
|
6036
6042
|
}
|
|
6037
6043
|
removeNestedMarkStyle(e, t) {
|
|
6038
|
-
let n =
|
|
6044
|
+
let n = G(e, Y);
|
|
6039
6045
|
for (let e of n) {
|
|
6040
6046
|
e.style.removeProperty(t);
|
|
6041
|
-
let n =
|
|
6047
|
+
let n = la[t], r = e.style.getPropertyValue(n);
|
|
6042
6048
|
r !== "" && r !== "transparent" ? this.ensureTransparentBg(e) : this.unwrapElement(e);
|
|
6043
6049
|
}
|
|
6044
6050
|
}
|
|
@@ -6069,7 +6075,7 @@ var Q = (e) => e.tagName === "MARK", ra = (e) => q(e, Q), $, ia = {
|
|
|
6069
6075
|
}
|
|
6070
6076
|
}
|
|
6071
6077
|
splitMarksAtBoundaries(e) {
|
|
6072
|
-
let t =
|
|
6078
|
+
let t = G(e, Y);
|
|
6073
6079
|
for (let n of t) {
|
|
6074
6080
|
let t = document.createRange();
|
|
6075
6081
|
t.selectNodeContents(n);
|
|
@@ -6134,24 +6140,302 @@ var Q = (e) => e.tagName === "MARK", ra = (e) => q(e, Q), $, ia = {
|
|
|
6134
6140
|
}
|
|
6135
6141
|
resolveToVar(e, t) {
|
|
6136
6142
|
if (e.startsWith("var(")) return e;
|
|
6137
|
-
let n = t === "color" ? "text" : "bg", r =
|
|
6138
|
-
return r === null ? e :
|
|
6143
|
+
let n = t === "color" ? "text" : "bg", r = Qe(e, n);
|
|
6144
|
+
return r === null ? e : a(r, n);
|
|
6145
|
+
}
|
|
6146
|
+
};
|
|
6147
|
+
X = ua, X.isInline = !0, X.title = "Color", X.titleKey = "marker", X.shortcut = "CMD+SHIFT+H", X.ALLOWED_STYLE_PROPS = new Set(["color", "background-color"]);
|
|
6148
|
+
//#endregion
|
|
6149
|
+
//#region src/components/inline-tools/inline-tool-underline.ts
|
|
6150
|
+
var Z, da = (e) => e.tagName === "U", fa = class {
|
|
6151
|
+
static get sanitize() {
|
|
6152
|
+
return { u: {} };
|
|
6153
|
+
}
|
|
6154
|
+
render() {
|
|
6155
|
+
return {
|
|
6156
|
+
icon: Ne,
|
|
6157
|
+
name: "underline",
|
|
6158
|
+
onActivate: () => {
|
|
6159
|
+
this.toggleUnderline();
|
|
6160
|
+
},
|
|
6161
|
+
isActive: () => {
|
|
6162
|
+
let e = window.getSelection();
|
|
6163
|
+
return e ? this.isSelectionVisuallyUnderline(e) : !1;
|
|
6164
|
+
}
|
|
6165
|
+
};
|
|
6166
|
+
}
|
|
6167
|
+
toggleUnderline() {
|
|
6168
|
+
let e = window.getSelection();
|
|
6169
|
+
if (!e || e.rangeCount === 0) return;
|
|
6170
|
+
let t = e.getRangeAt(0);
|
|
6171
|
+
if (t.collapsed) {
|
|
6172
|
+
this.toggleCollapsedUnderline(t, e);
|
|
6173
|
+
return;
|
|
6174
|
+
}
|
|
6175
|
+
this.isRangeUnderline(t, { ignoreWhitespace: !0 }) ? this.unwrapUnderlineTags(t) : this.wrapWithUnderline(t);
|
|
6176
|
+
}
|
|
6177
|
+
toggleCollapsedUnderline(e, t) {
|
|
6178
|
+
if (this.isRangeUnderline(e, { ignoreWhitespace: !0 })) {
|
|
6179
|
+
let n = document.createTextNode("");
|
|
6180
|
+
e.insertNode(n), e.selectNode(n), this.unwrapUnderlineTags(e);
|
|
6181
|
+
let r = document.createRange();
|
|
6182
|
+
r.setStart(n, 1), r.setEnd(n, 1), t.removeAllRanges(), t.addRange(r);
|
|
6183
|
+
} else {
|
|
6184
|
+
let n = document.createElement("u"), r = document.createTextNode("");
|
|
6185
|
+
n.appendChild(r), e.insertNode(n);
|
|
6186
|
+
let i = document.createRange();
|
|
6187
|
+
i.setStart(r, 1), i.setEnd(r, 1), t.removeAllRanges(), t.addRange(i);
|
|
6188
|
+
}
|
|
6189
|
+
}
|
|
6190
|
+
isSelectionVisuallyUnderline(e) {
|
|
6191
|
+
if (e.rangeCount === 0) return !1;
|
|
6192
|
+
let t = e.getRangeAt(0);
|
|
6193
|
+
return this.isRangeUnderline(t, { ignoreWhitespace: !0 });
|
|
6194
|
+
}
|
|
6195
|
+
isRangeUnderline(e, t) {
|
|
6196
|
+
return W(e, da, t);
|
|
6197
|
+
}
|
|
6198
|
+
wrapWithUnderline(e) {
|
|
6199
|
+
let t = this.getRangeHtmlWithoutUnderline(e), n = this.replaceRangeWithHtml(e, `<u>${t}</u>`), r = window.getSelection();
|
|
6200
|
+
r && n && (r.removeAllRanges(), r.addRange(n));
|
|
6201
|
+
}
|
|
6202
|
+
unwrapUnderlineTags(e) {
|
|
6203
|
+
let t = this.collectUnderlineAncestors(e), n = window.getSelection();
|
|
6204
|
+
if (!n) return;
|
|
6205
|
+
let r = document.createElement("span"), i = e.extractContents();
|
|
6206
|
+
r.appendChild(i), this.removeNestedUnderline(r), e.insertNode(r);
|
|
6207
|
+
let a = document.createRange();
|
|
6208
|
+
for (a.selectNodeContents(r), n.removeAllRanges(), n.addRange(a);;) {
|
|
6209
|
+
let e = this.findUnderlineElement(r);
|
|
6210
|
+
if (!e) break;
|
|
6211
|
+
this.moveMarkerOutOfUnderline(r, e);
|
|
6212
|
+
}
|
|
6213
|
+
let o = r.firstChild, s = r.lastChild;
|
|
6214
|
+
this.unwrapElement(r), o && s && (() => {
|
|
6215
|
+
let e = document.createRange();
|
|
6216
|
+
return e.setStartBefore(o), e.setEndAfter(s), n.removeAllRanges(), n.addRange(e), e;
|
|
6217
|
+
})() || n.removeAllRanges(), t.forEach((e) => {
|
|
6218
|
+
e.textContent.length === 0 && e.remove();
|
|
6219
|
+
});
|
|
6220
|
+
}
|
|
6221
|
+
hasUnderlineParent(e) {
|
|
6222
|
+
return ta(e, da);
|
|
6223
|
+
}
|
|
6224
|
+
findUnderlineElement(e) {
|
|
6225
|
+
return U(e, da);
|
|
6226
|
+
}
|
|
6227
|
+
collectUnderlineAncestors(e) {
|
|
6228
|
+
return G(e, da);
|
|
6229
|
+
}
|
|
6230
|
+
getRangeHtmlWithoutUnderline(e) {
|
|
6231
|
+
let t = e.cloneContents();
|
|
6232
|
+
this.removeNestedUnderline(t);
|
|
6233
|
+
let n = document.createElement("div");
|
|
6234
|
+
return n.appendChild(t), n.innerHTML;
|
|
6235
|
+
}
|
|
6236
|
+
removeNestedUnderline(e) {
|
|
6237
|
+
e.querySelectorAll("u").forEach((e) => {
|
|
6238
|
+
this.unwrapElement(e);
|
|
6239
|
+
});
|
|
6240
|
+
}
|
|
6241
|
+
unwrapElement(e) {
|
|
6242
|
+
let t = e.parentNode;
|
|
6243
|
+
if (!t) {
|
|
6244
|
+
e.remove();
|
|
6245
|
+
return;
|
|
6246
|
+
}
|
|
6247
|
+
for (; e.firstChild;) t.insertBefore(e.firstChild, e);
|
|
6248
|
+
t.removeChild(e);
|
|
6249
|
+
}
|
|
6250
|
+
replaceRangeWithHtml(e, t) {
|
|
6251
|
+
var n, r;
|
|
6252
|
+
let i = this.createFragmentFromHtml(t), a = (n = i.firstChild) == null ? null : n, o = (r = i.lastChild) == null ? null : r;
|
|
6253
|
+
if (e.deleteContents(), !a || !o) return;
|
|
6254
|
+
e.insertNode(i);
|
|
6255
|
+
let s = document.createRange();
|
|
6256
|
+
return s.setStartBefore(a), s.setEndAfter(o), s;
|
|
6257
|
+
}
|
|
6258
|
+
createFragmentFromHtml(e) {
|
|
6259
|
+
let t = document.createElement("template");
|
|
6260
|
+
return t.innerHTML = e, t.content;
|
|
6261
|
+
}
|
|
6262
|
+
moveMarkerOutOfUnderline(e, t) {
|
|
6263
|
+
let n = t.parentNode;
|
|
6264
|
+
if (!n) return;
|
|
6265
|
+
if (Array.from(t.childNodes).forEach((e) => {
|
|
6266
|
+
var t;
|
|
6267
|
+
e.nodeType === Node.TEXT_NODE && ((t = e.textContent) == null ? "" : t).length === 0 && e.remove();
|
|
6268
|
+
}), t.childNodes.length === 1 && t.firstChild === e) {
|
|
6269
|
+
t.replaceWith(e);
|
|
6270
|
+
return;
|
|
6271
|
+
}
|
|
6272
|
+
if (t.firstChild === e) {
|
|
6273
|
+
n.insertBefore(e, t);
|
|
6274
|
+
return;
|
|
6275
|
+
}
|
|
6276
|
+
if (t.lastChild === e) {
|
|
6277
|
+
n.insertBefore(e, t.nextSibling);
|
|
6278
|
+
return;
|
|
6279
|
+
}
|
|
6280
|
+
let r = t.cloneNode(!1);
|
|
6281
|
+
for (; e.nextSibling;) r.appendChild(e.nextSibling);
|
|
6282
|
+
n.insertBefore(r, t.nextSibling), n.insertBefore(e, r);
|
|
6283
|
+
}
|
|
6284
|
+
};
|
|
6285
|
+
Z = fa, Z.isInline = !0, Z.title = "Underline", Z.titleKey = "underline", Z.shortcut = "CMD+U";
|
|
6286
|
+
//#endregion
|
|
6287
|
+
//#region src/components/inline-tools/inline-tool-strikethrough.ts
|
|
6288
|
+
var Q, $ = (e) => e.tagName === "S", pa = class {
|
|
6289
|
+
static get sanitize() {
|
|
6290
|
+
return { s: {} };
|
|
6291
|
+
}
|
|
6292
|
+
render() {
|
|
6293
|
+
return {
|
|
6294
|
+
icon: Je,
|
|
6295
|
+
name: "strikethrough",
|
|
6296
|
+
onActivate: () => {
|
|
6297
|
+
this.toggleStrikethrough();
|
|
6298
|
+
},
|
|
6299
|
+
isActive: () => {
|
|
6300
|
+
let e = window.getSelection();
|
|
6301
|
+
return e ? this.isSelectionVisuallyStrikethrough(e) : !1;
|
|
6302
|
+
}
|
|
6303
|
+
};
|
|
6304
|
+
}
|
|
6305
|
+
toggleStrikethrough() {
|
|
6306
|
+
let e = window.getSelection();
|
|
6307
|
+
if (!e || e.rangeCount === 0) return;
|
|
6308
|
+
let t = e.getRangeAt(0);
|
|
6309
|
+
if (t.collapsed) {
|
|
6310
|
+
this.toggleCollapsedStrikethrough(t, e);
|
|
6311
|
+
return;
|
|
6312
|
+
}
|
|
6313
|
+
this.isRangeStrikethrough(t, { ignoreWhitespace: !0 }) ? this.unwrapStrikethroughTags(t) : this.wrapWithStrikethrough(t);
|
|
6314
|
+
}
|
|
6315
|
+
toggleCollapsedStrikethrough(e, t) {
|
|
6316
|
+
if (this.isRangeStrikethrough(e, { ignoreWhitespace: !0 })) {
|
|
6317
|
+
let n = document.createTextNode("");
|
|
6318
|
+
e.insertNode(n), e.selectNode(n), this.unwrapStrikethroughTags(e);
|
|
6319
|
+
let r = document.createRange();
|
|
6320
|
+
r.setStart(n, 1), r.setEnd(n, 1), t.removeAllRanges(), t.addRange(r);
|
|
6321
|
+
} else {
|
|
6322
|
+
let n = document.createElement("s"), r = document.createTextNode("");
|
|
6323
|
+
n.appendChild(r), e.insertNode(n);
|
|
6324
|
+
let i = document.createRange();
|
|
6325
|
+
i.setStart(r, 1), i.setEnd(r, 1), t.removeAllRanges(), t.addRange(i);
|
|
6326
|
+
}
|
|
6327
|
+
}
|
|
6328
|
+
isSelectionVisuallyStrikethrough(e) {
|
|
6329
|
+
if (e.rangeCount === 0) return !1;
|
|
6330
|
+
let t = e.getRangeAt(0);
|
|
6331
|
+
return this.isRangeStrikethrough(t, { ignoreWhitespace: !0 });
|
|
6332
|
+
}
|
|
6333
|
+
isRangeStrikethrough(e, t) {
|
|
6334
|
+
return W(e, $, t);
|
|
6335
|
+
}
|
|
6336
|
+
wrapWithStrikethrough(e) {
|
|
6337
|
+
let t = this.getRangeHtmlWithoutStrikethrough(e), n = this.replaceRangeWithHtml(e, `<s>${t}</s>`), r = window.getSelection();
|
|
6338
|
+
r && n && (r.removeAllRanges(), r.addRange(n));
|
|
6339
|
+
}
|
|
6340
|
+
unwrapStrikethroughTags(e) {
|
|
6341
|
+
let t = this.collectStrikethroughAncestors(e), n = window.getSelection();
|
|
6342
|
+
if (!n) return;
|
|
6343
|
+
let r = document.createElement("span"), i = e.extractContents();
|
|
6344
|
+
r.appendChild(i), this.removeNestedStrikethrough(r), e.insertNode(r);
|
|
6345
|
+
let a = document.createRange();
|
|
6346
|
+
for (a.selectNodeContents(r), n.removeAllRanges(), n.addRange(a);;) {
|
|
6347
|
+
let e = this.findStrikethroughElement(r);
|
|
6348
|
+
if (!e) break;
|
|
6349
|
+
this.moveMarkerOutOfStrikethrough(r, e);
|
|
6350
|
+
}
|
|
6351
|
+
let o = r.firstChild, s = r.lastChild;
|
|
6352
|
+
this.unwrapElement(r), o && s && (() => {
|
|
6353
|
+
let e = document.createRange();
|
|
6354
|
+
return e.setStartBefore(o), e.setEndAfter(s), n.removeAllRanges(), n.addRange(e), e;
|
|
6355
|
+
})() || n.removeAllRanges(), t.forEach((e) => {
|
|
6356
|
+
e.textContent.length === 0 && e.remove();
|
|
6357
|
+
});
|
|
6358
|
+
}
|
|
6359
|
+
hasStrikethroughParent(e) {
|
|
6360
|
+
return ta(e, $);
|
|
6361
|
+
}
|
|
6362
|
+
findStrikethroughElement(e) {
|
|
6363
|
+
return U(e, $);
|
|
6364
|
+
}
|
|
6365
|
+
collectStrikethroughAncestors(e) {
|
|
6366
|
+
return G(e, $);
|
|
6367
|
+
}
|
|
6368
|
+
getRangeHtmlWithoutStrikethrough(e) {
|
|
6369
|
+
let t = e.cloneContents();
|
|
6370
|
+
this.removeNestedStrikethrough(t);
|
|
6371
|
+
let n = document.createElement("div");
|
|
6372
|
+
return n.appendChild(t), n.innerHTML;
|
|
6373
|
+
}
|
|
6374
|
+
removeNestedStrikethrough(e) {
|
|
6375
|
+
e.querySelectorAll("s").forEach((e) => {
|
|
6376
|
+
this.unwrapElement(e);
|
|
6377
|
+
});
|
|
6378
|
+
}
|
|
6379
|
+
unwrapElement(e) {
|
|
6380
|
+
let t = e.parentNode;
|
|
6381
|
+
if (!t) {
|
|
6382
|
+
e.remove();
|
|
6383
|
+
return;
|
|
6384
|
+
}
|
|
6385
|
+
for (; e.firstChild;) t.insertBefore(e.firstChild, e);
|
|
6386
|
+
t.removeChild(e);
|
|
6387
|
+
}
|
|
6388
|
+
replaceRangeWithHtml(e, t) {
|
|
6389
|
+
var n, r;
|
|
6390
|
+
let i = this.createFragmentFromHtml(t), a = (n = i.firstChild) == null ? null : n, o = (r = i.lastChild) == null ? null : r;
|
|
6391
|
+
if (e.deleteContents(), !a || !o) return;
|
|
6392
|
+
e.insertNode(i);
|
|
6393
|
+
let s = document.createRange();
|
|
6394
|
+
return s.setStartBefore(a), s.setEndAfter(o), s;
|
|
6395
|
+
}
|
|
6396
|
+
createFragmentFromHtml(e) {
|
|
6397
|
+
let t = document.createElement("template");
|
|
6398
|
+
return t.innerHTML = e, t.content;
|
|
6399
|
+
}
|
|
6400
|
+
moveMarkerOutOfStrikethrough(e, t) {
|
|
6401
|
+
let n = t.parentNode;
|
|
6402
|
+
if (!n) return;
|
|
6403
|
+
if (Array.from(t.childNodes).forEach((e) => {
|
|
6404
|
+
var t;
|
|
6405
|
+
e.nodeType === Node.TEXT_NODE && ((t = e.textContent) == null ? "" : t).length === 0 && e.remove();
|
|
6406
|
+
}), t.childNodes.length === 1 && t.firstChild === e) {
|
|
6407
|
+
t.replaceWith(e);
|
|
6408
|
+
return;
|
|
6409
|
+
}
|
|
6410
|
+
if (t.firstChild === e) {
|
|
6411
|
+
n.insertBefore(e, t);
|
|
6412
|
+
return;
|
|
6413
|
+
}
|
|
6414
|
+
if (t.lastChild === e) {
|
|
6415
|
+
n.insertBefore(e, t.nextSibling);
|
|
6416
|
+
return;
|
|
6417
|
+
}
|
|
6418
|
+
let r = t.cloneNode(!1);
|
|
6419
|
+
for (; e.nextSibling;) r.appendChild(e.nextSibling);
|
|
6420
|
+
n.insertBefore(r, t.nextSibling), n.insertBefore(e, r);
|
|
6139
6421
|
}
|
|
6140
6422
|
};
|
|
6141
|
-
|
|
6423
|
+
Q = pa, Q.isInline = !0, Q.title = "Strikethrough", Q.titleKey = "strikethrough", Q.shortcut = "CMD+SHIFT+S";
|
|
6142
6424
|
//#endregion
|
|
6143
6425
|
//#region src/tools/index.ts
|
|
6144
|
-
var
|
|
6426
|
+
var ma = {
|
|
6145
6427
|
paragraph: { preserveBlank: !0 },
|
|
6146
6428
|
header: {},
|
|
6147
6429
|
list: {},
|
|
6148
6430
|
table: {},
|
|
6149
6431
|
toggle: {}
|
|
6150
|
-
},
|
|
6432
|
+
}, ha = {
|
|
6151
6433
|
bold: {},
|
|
6152
6434
|
italic: {},
|
|
6153
6435
|
link: {},
|
|
6154
|
-
marker: {}
|
|
6436
|
+
marker: {},
|
|
6437
|
+
underline: {},
|
|
6438
|
+
strikethrough: {}
|
|
6155
6439
|
};
|
|
6156
6440
|
//#endregion
|
|
6157
|
-
export {
|
|
6441
|
+
export { ua as a, na as c, Hn as d, wt as f, fa as i, Ui as l, ha as n, sa as o, ut as p, pa as r, ia as s, ma as t, Ri as u };
|