@jackuait/blok 0.10.0-beta.5 → 0.10.0-beta.7
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/codemod/migrate-editorjs-to-blok.js +0 -2
- package/codemod/test.js +0 -6
- package/dist/blok.mjs +3 -3
- package/dist/chunks/_basePickBy-BHRNO12X.mjs +410 -0
- package/dist/chunks/_baseUniq-DtFPDBML.mjs +1045 -0
- package/dist/chunks/_getTag-ozrhqxk_.mjs +26 -0
- package/dist/chunks/arc-BEqJP9HX.mjs +80 -0
- package/dist/chunks/architecture-YZFGNWBL-Bcu-90pi.mjs +3 -0
- package/dist/chunks/architectureDiagram-Q4EWVU46-BMno5LCn.mjs +4066 -0
- package/dist/chunks/array-Cyf-61SV.mjs +6 -0
- package/dist/chunks/blockDiagram-DXYQGD6D-DlP_cPth.mjs +3259 -0
- package/dist/chunks/{blok-DH-WEcA8.mjs → blok-CiLRmoHI.mjs} +2030 -1996
- package/dist/chunks/c4Diagram-AHTNJAMY-BbVV8EXj.mjs +2956 -0
- package/dist/chunks/channel-DPcniO2B.mjs +5 -0
- package/dist/chunks/chunk-2KRD3SAO-CazES4VS.mjs +20 -0
- package/dist/chunks/chunk-336JU56O-heO72r_k.mjs +49 -0
- package/dist/chunks/chunk-426QAEUC-CmCcml1z.mjs +13 -0
- package/dist/chunks/chunk-4BX2VUAB-B10DxOza.mjs +19 -0
- package/dist/chunks/chunk-4TB4RGXK-B0snhZOU.mjs +3250 -0
- package/dist/chunks/chunk-55IACEB6-CGkn5ABd.mjs +8 -0
- package/dist/chunks/chunk-5FUZZQ4R-USdumo_u.mjs +3786 -0
- package/dist/chunks/chunk-5PVQY5BW-CxUGVzQL.mjs +1692 -0
- package/dist/chunks/chunk-67CJDMHE-Bvw55oRa.mjs +20 -0
- package/dist/chunks/chunk-7N4EOEYR-Bs2qDy88.mjs +29 -0
- package/dist/chunks/chunk-AA7GKIK3-Bss0LgrN.mjs +24 -0
- package/dist/chunks/chunk-BSJP7CBP-CpUW7gi5.mjs +83 -0
- package/dist/chunks/chunk-CIAEETIT-DlRbLLf3.mjs +20 -0
- package/dist/chunks/chunk-D6kmoKXy.mjs +20 -0
- package/dist/chunks/chunk-EDXVE4YY-DEcX4XWm.mjs +26 -0
- package/dist/chunks/chunk-ENJZ2VHE-B4THRZkR.mjs +566 -0
- package/dist/chunks/chunk-FMBD7UC4-CF6BKEiV.mjs +5 -0
- package/dist/chunks/chunk-FOC6F5B3--xuza7Yn.mjs +20 -0
- package/dist/chunks/chunk-ICPOFSXX-BMja8cuy.mjs +3290 -0
- package/dist/chunks/chunk-K5T4RW27-CHEqGHFS.mjs +16370 -0
- package/dist/chunks/chunk-KGLVRYIC-DHYYpR8v.mjs +20 -0
- package/dist/chunks/chunk-LIHQZDEY-AvbOvyLE.mjs +55 -0
- package/dist/chunks/chunk-ORNJ4GCN-38fbR5OS.mjs +25 -0
- package/dist/chunks/chunk-OYMX7WX6-BiqlATPA.mjs +2038 -0
- package/dist/chunks/chunk-QZHKN3VN-DitZIvj8.mjs +12 -0
- package/dist/chunks/chunk-U2HBQHQK-DJytnHmZ.mjs +1875 -0
- package/dist/chunks/chunk-X2U36JSP-DlOifw1K.mjs +68 -0
- package/dist/chunks/chunk-XPW4576I-s4fsi4XO.mjs +1146 -0
- package/dist/chunks/chunk-YZCP3GAM-Ch258bXC.mjs +60 -0
- package/dist/chunks/chunk-ZZ45TVLE-DWziaKxP.mjs +33 -0
- package/dist/chunks/classDiagram-6PBFFD2Q-BOkAe08u.mjs +30 -0
- package/dist/chunks/classDiagram-v2-HSJHXN6E-DeKatSvh.mjs +30 -0
- package/dist/chunks/clone-CJCz7VRp.mjs +8 -0
- package/dist/chunks/{constants-Ccno9NZS.mjs → constants-DFS8l39Y.mjs} +525 -552
- package/dist/chunks/cose-bilkent-S5V4N54A-CzLGVqvr.mjs +2246 -0
- package/dist/chunks/cytoscape.esm-D0iglm-M.mjs +18108 -0
- package/dist/chunks/dagre-KV5264BT-XbHSjleO.mjs +298 -0
- package/dist/chunks/dagre-XY8CZ1sg.mjs +1536 -0
- package/dist/chunks/default-DIfXCS2E.mjs +4 -0
- package/dist/chunks/defaultLocale-DFhS1600.mjs +201 -0
- package/dist/chunks/diagram-5BDNPKRD-CM7c3UTI.mjs +112 -0
- package/dist/chunks/diagram-G4DWMVQ6-Bhg4ps6b.mjs +546 -0
- package/dist/chunks/diagram-MMDJMWI5-C-UCVaxB.mjs +234 -0
- package/dist/chunks/diagram-TYMM5635-BOHSujSD.mjs +144 -0
- package/dist/chunks/dist-DHsXIYdd.mjs +59 -0
- package/dist/chunks/erDiagram-SMLLAGMA-CwKxXFMB.mjs +1712 -0
- package/dist/chunks/flowDiagram-DWJPFMVM-rQJKfyuO.mjs +4175 -0
- package/dist/chunks/ganttDiagram-T4ZO3ILL-DfaZirLX.mjs +3083 -0
- package/dist/chunks/gitGraph-7Q5UKJZL-BKG8cHGz.mjs +3 -0
- package/dist/chunks/gitGraphDiagram-UUTBAWPF-CRa-ymsI.mjs +792 -0
- package/dist/chunks/graphlib-CuDElSdG.mjs +223 -0
- package/dist/chunks/{i18next-G6FKbZqA.mjs → i18next-BBGW2sDE.mjs} +1 -1
- package/dist/chunks/{i18next-loader-CwNimni3.mjs → i18next-loader-CasQQb5s.mjs} +2 -2
- package/dist/chunks/info-OMHHGYJF-FKqYyUn9.mjs +3 -0
- package/dist/chunks/infoDiagram-42DDH7IO-CvyJU2nE.mjs +29 -0
- package/dist/chunks/init-JlKGZtuT.mjs +15 -0
- package/dist/chunks/ishikawaDiagram-UXIWVN3A-CIpbw1BK.mjs +719 -0
- package/dist/chunks/journeyDiagram-VCZTEJTY-H96UcUK9.mjs +885 -0
- package/dist/chunks/kanban-definition-6JOO6SKY-BYZT3srA.mjs +980 -0
- package/dist/chunks/katex-JyOgX6MW.mjs +22026 -0
- package/dist/chunks/{lightweight-i18n-DWCdzAw0.mjs → lightweight-i18n-Cvv8CWh4.mjs} +29 -18
- package/dist/chunks/line-B9xUUA7k.mjs +34 -0
- package/dist/chunks/linear-Dj-1yA_B.mjs +289 -0
- package/dist/chunks/mdast-util-math-CHYUxOHk.mjs +151 -0
- package/dist/chunks/mermaid-parser.core-D6OPAUtM.mjs +57 -0
- package/dist/chunks/mermaid.core-BPN9ZHKQ.mjs +989 -0
- package/dist/{messages-B-4fku2H2.mjs → chunks/messages--YKhFEDE.mjs} +30 -19
- package/dist/{messages-BCG_evLg.mjs → chunks/messages-0Uwu1AMJ2.mjs} +28 -17
- package/dist/{messages-CdlsTFB1.mjs → chunks/messages-1__0Ph4Q.mjs} +28 -17
- package/dist/chunks/{messages-wLSVQbsA2.mjs → messages-4sm9Pb0C.mjs} +28 -17
- package/dist/chunks/{messages-R2W_rGOo2.mjs → messages-4uxjtzKW.mjs} +28 -17
- package/dist/chunks/{messages-Dm4YVlrm.mjs → messages-B-SwLgkQ.mjs} +30 -19
- package/dist/{messages--S8_taOd2.mjs → chunks/messages-B1ylBxXQ.mjs} +28 -17
- package/dist/chunks/{messages-B7MIRzCa2.mjs → messages-B5m3dhKc.mjs} +28 -17
- package/dist/chunks/{messages-Dplnp19q.mjs → messages-B6n2zDtv.mjs} +29 -18
- package/dist/chunks/{messages-DD7BI6BK.mjs → messages-BC9w4zAT.mjs} +28 -17
- package/dist/chunks/{messages-BrFl5773.mjs → messages-BOj-7N3p.mjs} +28 -17
- package/dist/chunks/{messages-BbdNugdi.mjs → messages-BRYHTS18.mjs} +28 -17
- package/dist/chunks/{messages-JQKFJo7C.mjs → messages-BSBbVjor.mjs} +35 -24
- package/dist/{messages-CBzd_x7H.mjs → chunks/messages-BUUkmUGc.mjs} +28 -17
- package/dist/{messages-CjmSrt1D.mjs → chunks/messages-Bb3YEV2P.mjs} +33 -22
- package/dist/{messages-BvgXeMSL2.mjs → chunks/messages-Be_6YLzJ.mjs} +29 -18
- package/dist/{messages-pgPcitDH.mjs → chunks/messages-BevRhv5d.mjs} +28 -17
- package/dist/chunks/{messages-BW_7lfqG2.mjs → messages-Bhqr7Im2.mjs} +28 -17
- package/dist/chunks/{messages-LxumrNue2.mjs → messages-BpJFjSKa.mjs} +29 -18
- package/dist/{messages-xEI8gEDK.mjs → chunks/messages-BqYlq_Bn.mjs} +28 -17
- package/dist/{messages-CBdQ3XP9.mjs → chunks/messages-BtAwCUfD.mjs} +28 -17
- package/dist/{messages-D3cAcyzj.mjs → chunks/messages-Bthbp65G.mjs} +29 -18
- package/dist/{messages-CYX48nfg.mjs → chunks/messages-BvHMZ8Pi2.mjs} +28 -17
- package/dist/{messages-Dddxv8-f2.mjs → chunks/messages-Bw1BE9jW.mjs} +28 -17
- package/dist/chunks/{messages-d0Ky6QjR.mjs → messages-Bx6Wt285.mjs} +28 -17
- package/dist/chunks/{messages-BPog17132.mjs → messages-BzslJRYv.mjs} +29 -18
- package/dist/{messages-hTpeKUaW.mjs → chunks/messages-C02M0Tpw.mjs} +28 -17
- package/dist/chunks/{messages-C-b6tPad2.mjs → messages-C1u3E9qg.mjs} +28 -17
- package/dist/{messages-BJ7BuFZi.mjs → chunks/messages-C68WgSKk.mjs} +29 -18
- package/dist/chunks/{messages-Bpda_3PM2.mjs → messages-C8w8JCP0.mjs} +30 -19
- package/dist/chunks/{messages-CmrMwBv3.mjs → messages-CFOZdSk4.mjs} +28 -17
- package/dist/{messages-DVQNjdPk.mjs → chunks/messages-CGOY79lr.mjs} +28 -17
- package/dist/chunks/{messages-DAVsuDWh2.mjs → messages-CGaSMZPu.mjs} +28 -17
- package/dist/{messages-DtrSrdfE2.mjs → chunks/messages-CJJgQ0BH.mjs} +28 -17
- package/dist/{messages-CgzbJ8_l2.mjs → chunks/messages-CTD6rtQj2.mjs} +28 -17
- package/dist/chunks/{messages-p4byLfvR.mjs → messages-CZymJML9.mjs} +32 -21
- package/dist/{messages-CqkRG9mH.mjs → chunks/messages-CfeFJbiv.mjs} +32 -21
- package/dist/{messages-DjJQoYvP2.mjs → chunks/messages-Cgatzu_z.mjs} +30 -19
- package/dist/{messages-CM5fsPo02.mjs → chunks/messages-Ch2zBI602.mjs} +28 -17
- package/dist/chunks/{messages-CyNsByCY.mjs → messages-CiAHsUfO.mjs} +28 -17
- package/dist/{messages-BXI3qIos.mjs → chunks/messages-Cuzq-tNW.mjs} +28 -17
- package/dist/chunks/{messages-FHrCEJmY2.mjs → messages-Cw4qiMwb.mjs} +28 -17
- package/dist/chunks/{messages-xfjdrZmx.mjs → messages-Cyh-mz40.mjs} +28 -17
- package/dist/{messages-Bo_FUvVH.mjs → chunks/messages-D-I2QO8H.mjs} +28 -17
- package/dist/chunks/{messages-Ct7AMBS82.mjs → messages-D0D2gruy.mjs} +28 -17
- package/dist/chunks/{messages-CrMfiGu5.mjs → messages-D1BKxfLD.mjs} +29 -18
- package/dist/chunks/{messages-CmXADeab2.mjs → messages-D4eDs6R_.mjs} +28 -17
- package/dist/chunks/{messages-ClRHDxzh.mjs → messages-D9Xr-hES.mjs} +28 -17
- package/dist/{messages-tsHpMdDT2.mjs → chunks/messages-D9eJPHia.mjs} +30 -19
- package/dist/{messages-DUBHHfEt.mjs → chunks/messages-DBFWSzKY2.mjs} +28 -17
- package/dist/{messages-i4S6q64n2.mjs → chunks/messages-DC0wu2S7.mjs} +28 -17
- package/dist/chunks/{messages-BnznaKEP2.mjs → messages-DF9o19rG.mjs} +28 -17
- package/dist/{messages-DA-o8X3A.mjs → chunks/messages-DFS_n986.mjs} +51 -40
- package/dist/{messages-BGsDZTQp2.mjs → chunks/messages-DGS4H30T.mjs} +28 -17
- package/dist/chunks/{messages-Cdx4QMR1.mjs → messages-DKjddpzJ.mjs} +30 -19
- package/dist/chunks/{messages-B3s2vra72.mjs → messages-DMvTdUXC.mjs} +30 -19
- package/dist/{messages-Dcyrzdxa2.mjs → chunks/messages-DQUX-QYI2.mjs} +28 -17
- package/dist/chunks/{messages-BS1nOvZ-.mjs → messages-DUigq8FO2.mjs} +28 -17
- package/dist/{messages-BKjqW08U.mjs → chunks/messages-DY0FJdpH.mjs} +28 -17
- package/dist/{messages-BBvDbp62.mjs → chunks/messages-DfVXiqt-2.mjs} +28 -17
- package/dist/chunks/{messages-DHCVA7XQ.mjs → messages-DgZc9TJw.mjs} +28 -17
- package/dist/chunks/{messages-1Raf1IK82.mjs → messages-QD4BCUDP.mjs} +28 -17
- package/dist/{messages-JhoVMjfX2.mjs → chunks/messages-USmweex9.mjs} +28 -17
- package/dist/chunks/{messages-DBpXyvRe2.mjs → messages-a1JTi0Qm.mjs} +31 -20
- package/dist/chunks/{messages-D5IgUbBD2.mjs → messages-jcgCHPRn.mjs} +28 -17
- package/dist/chunks/{messages-Dfpi8pDY.mjs → messages-tnnqHpbd.mjs} +29 -18
- package/dist/{messages-DZEcrbmH.mjs → chunks/messages-vzWKPLJO.mjs} +28 -17
- package/dist/chunks/micromark-extension-math-Cz_ZZ_0Y.mjs +169 -0
- package/dist/chunks/micromark-factory-space-WwmyBO_J.mjs +36 -0
- package/dist/chunks/mindmap-definition-QFDTVHPH-BswFuNN6.mjs +1013 -0
- package/dist/chunks/{notifier-Butv4Dvo.mjs → notifier-B1zCi9G1.mjs} +1 -1
- package/dist/chunks/{objectSpread2-BY4mgzrQ.mjs → objectSpread2-CWwMYL_U.mjs} +1 -1
- package/dist/chunks/ordinal-D1_lEgAO.mjs +65 -0
- package/dist/chunks/packet-4T2RLAQJ-DTUW2U0C.mjs +3 -0
- package/dist/chunks/path-6nYPAvNb.mjs +85 -0
- package/dist/chunks/pie-ZZUOXDRM-D-umqvEM.mjs +3 -0
- package/dist/chunks/pieDiagram-DEJITSTG-1WJgvK1w.mjs +179 -0
- package/dist/chunks/quadrantDiagram-34T5L4WZ-B_YH8QGl.mjs +1960 -0
- package/dist/chunks/radar-PYXPWWZC-DkQelf08.mjs +3 -0
- package/dist/chunks/requirementDiagram-MS252O5E-DRl0YJRI.mjs +2224 -0
- package/dist/chunks/rough.esm-CSWJruu5.mjs +1353 -0
- package/dist/chunks/sankeyDiagram-XADWPNL6-B-8IrknH.mjs +909 -0
- package/dist/chunks/sequenceDiagram-FGHM5R23-DTLb8qmO.mjs +4181 -0
- package/dist/chunks/src-CRgEHLPW.mjs +2149 -0
- package/dist/chunks/stateDiagram-FHFEXIEX-B0JFjLFy.mjs +218 -0
- package/dist/chunks/stateDiagram-v2-QKLJ7IA2-Co9CUU_z.mjs +28 -0
- package/dist/chunks/timeline-definition-GMOUNBTQ-CS9KTh-Q.mjs +1084 -0
- package/dist/chunks/{tools-C2_IVsQY.mjs → tools-CSYsrnud.mjs} +2846 -3098
- package/dist/chunks/treeView-SZITEDCU-DOOoyNP9.mjs +3 -0
- package/dist/chunks/treemap-W4RFUUIX-CsOoUA-u.mjs +3 -0
- package/dist/chunks/vennDiagram-DHZGUBPP-0BNu5Wna.mjs +1876 -0
- package/dist/chunks/wardley-RL74JXVD-CCzZcmEk.mjs +3 -0
- package/dist/chunks/wardleyDiagram-NUSXRM2D-Ca9XByNH.mjs +594 -0
- package/dist/chunks/xychartDiagram-5P7HB3ND-C8AyKUAE.mjs +2017 -0
- package/dist/cli.mjs +1 -1
- package/dist/full.mjs +14 -14
- package/dist/locales.mjs +95 -84
- package/dist/markdown.mjs +3962 -0
- package/dist/{chunks/messages-6mikOS4D2.mjs → messages-5jvKxQNu2.mjs} +28 -17
- package/dist/{messages-BAcH6PtT2.mjs → messages-7QD-X6XT2.mjs} +28 -17
- package/dist/{messages-DbxbxUiK2.mjs → messages-96iaAUds2.mjs} +29 -18
- package/dist/{messages-CVcQD-9u.mjs → messages-B19o-Teb.mjs} +30 -19
- package/dist/{messages-Ccd587Yn.mjs → messages-B1ZUQagA.mjs} +28 -17
- package/dist/{messages-upqrRZQH2.mjs → messages-B7ieAJBd2.mjs} +28 -17
- package/dist/{chunks/messages-Csvm4mtA.mjs → messages-BECMxmfX.mjs} +28 -17
- package/dist/{chunks/messages-DA7Zk-Cy.mjs → messages-BIHc0KHY.mjs} +29 -18
- package/dist/{chunks/messages-BdnSVKOw.mjs → messages-BIoeoik5.mjs} +28 -17
- package/dist/{chunks/messages-DQ5AyNCU.mjs → messages-BJeGJksD.mjs} +28 -17
- package/dist/{messages-C5XPUD9T2.mjs → messages-BRZX964b2.mjs} +29 -18
- package/dist/{messages-Dkg99bfr2.mjs → messages-BTQPpoM42.mjs} +31 -20
- package/dist/{messages-fLi0P2dP.mjs → messages-BYNcD6uR.mjs} +28 -17
- package/dist/{messages-BvgTQLf72.mjs → messages-BYmmMDrN2.mjs} +28 -17
- package/dist/{chunks/messages-CgRvtOEY.mjs → messages-BbYq1pk-.mjs} +28 -17
- package/dist/{chunks/messages-DUDgFEEe2.mjs → messages-BiUGXvYr2.mjs} +28 -17
- package/dist/{chunks/messages-DJkIeapn.mjs → messages-BiiongNz2.mjs} +28 -17
- package/dist/{messages-BBq0M604.mjs → messages-Bm0Feca1.mjs} +32 -21
- package/dist/{messages-eTourT12.mjs → messages-BmAn22OX.mjs} +28 -17
- package/dist/{messages-C6Y4Jv2N.mjs → messages-Bq3F2Tp_.mjs} +28 -17
- package/dist/{messages-DIRha_gg2.mjs → messages-BsycN_JI2.mjs} +28 -17
- package/dist/{chunks/messages-CljStrYi.mjs → messages-BwHs4cm1.mjs} +32 -21
- package/dist/{chunks/messages-Cs9XBt4T.mjs → messages-CJTy6JZt.mjs} +28 -17
- package/dist/{messages-BokEflKa.mjs → messages-CR_L_UtK.mjs} +28 -17
- package/dist/{chunks/messages-ZJ0b1C3a.mjs → messages-CSUHBs4c2.mjs} +28 -17
- package/dist/{messages-BcFQFcJ92.mjs → messages-CWIXvnDf2.mjs} +28 -17
- package/dist/{messages-DnatBKPm.mjs → messages-CcF4y-E4.mjs} +28 -17
- package/dist/{messages-BywbKcPC.mjs → messages-Ce6KVEbT.mjs} +29 -18
- package/dist/{messages-DOTJ2NvJ.mjs → messages-Ci0KqX-J.mjs} +35 -24
- package/dist/{messages-BtxaN-xx.mjs → messages-CjbnogEC.mjs} +28 -17
- package/dist/{messages-BSe3QDnQ.mjs → messages-CmB406HW.mjs} +30 -19
- package/dist/{messages-BVKZK-3t.mjs → messages-CqXtJTpU.mjs} +28 -17
- package/dist/{chunks/messages-DJA6fb_P2.mjs → messages-D0aw5_0k2.mjs} +30 -19
- package/dist/{chunks/messages-DPykxECP2.mjs → messages-D8FQWulF2.mjs} +28 -17
- package/dist/{chunks/messages-CpzO7KRA.mjs → messages-DBiVgUs2.mjs} +29 -18
- package/dist/{chunks/messages-B0ffBqzr.mjs → messages-DIJlIqlQ2.mjs} +28 -17
- package/dist/{chunks/messages-BaPZuLjN.mjs → messages-DLX_iBDJ.mjs} +28 -17
- package/dist/{chunks/messages-CvfKofOP.mjs → messages-DLlc9QPw.mjs} +28 -17
- package/dist/{chunks/messages-Czny5pPT2.mjs → messages-DMr62KiO2.mjs} +28 -17
- package/dist/{chunks/messages-IDEUsFhQ2.mjs → messages-DPA-mMWC2.mjs} +29 -18
- package/dist/{messages-BCuTVHBV.mjs → messages-DTh9a8mR.mjs} +28 -17
- package/dist/{chunks/messages-DT7fRpCy.mjs → messages-DY4IqlhY.mjs} +28 -17
- package/dist/{chunks/messages-BgVEGd4c.mjs → messages-DYTTu0O12.mjs} +28 -17
- package/dist/{messages-Bk984gRE2.mjs → messages-DbySKTKt2.mjs} +30 -19
- package/dist/{chunks/messages-ID1PHnMv.mjs → messages-Ddnj2iTG2.mjs} +28 -17
- package/dist/{messages-BmNaAyKS.mjs → messages-DkLU_rWm.mjs} +28 -17
- package/dist/{messages-C6OJvnJg2.mjs → messages-Dl3Sv6Rq2.mjs} +29 -18
- package/dist/{chunks/messages-C1OqT_nL.mjs → messages-Dl5Y2-Ia.mjs} +51 -40
- package/dist/{chunks/messages-Cqc-6rfh2.mjs → messages-DnG0ef8t2.mjs} +30 -19
- package/dist/{chunks/messages-BkCjgGxc.mjs → messages-DnGJD4TL.mjs} +28 -17
- package/dist/{messages-Bio7KYsr2.mjs → messages-Dnp9N6RU2.mjs} +28 -17
- package/dist/{chunks/messages-Df87zXXG.mjs → messages-Dvn35ksS.mjs} +28 -17
- package/dist/{messages-CHJ5SOZI.mjs → messages-Dw__BcTj.mjs} +28 -17
- package/dist/{chunks/messages-DC7TX-YT.mjs → messages-Dy-Y_nEI.mjs} +28 -17
- package/dist/{messages-DV9e1DW7.mjs → messages-E_ZuzGDt.mjs} +28 -17
- package/dist/{messages-DD5pW0zJ.mjs → messages-F2xRoY1w.mjs} +28 -17
- package/dist/{chunks/messages-BgsPQXfP.mjs → messages-Smt4GBbj.mjs} +33 -22
- package/dist/{messages-DJT4Bt_02.mjs → messages-aMXpHt5X2.mjs} +28 -17
- package/dist/{chunks/messages-B2pW6jO_.mjs → messages-aWZH50vu2.mjs} +30 -19
- package/dist/{chunks/messages-u2yxkNTE2.mjs → messages-dv19AkyJ.mjs} +28 -17
- package/dist/{messages-DJKLtW7u.mjs → messages-hWwSRF-2.mjs} +28 -17
- package/dist/{messages-tK67CBqn.mjs → messages-j7o5rT9s.mjs} +28 -17
- package/dist/{messages-DqyqEw1_.mjs → messages-nUVjeh7K.mjs} +29 -18
- package/dist/{chunks/messages-DSjXen8E.mjs → messages-nlhESX9t.mjs} +28 -17
- package/dist/{messages-C30Vz-UZ2.mjs → messages-rk-A1Wa42.mjs} +30 -19
- package/dist/{chunks/messages-DR09nkcZ.mjs → messages-xh2eOLvs.mjs} +28 -17
- package/dist/{chunks/messages-C11byid72.mjs → messages-ynAe7ewZ.mjs} +28 -17
- package/dist/react.mjs +3 -3
- package/dist/tools.mjs +3 -3
- package/dist/vendor.LICENSE.txt +4609 -212
- package/package.json +21 -3
- package/src/components/blocks.ts +26 -1
- package/src/components/constants/data-attributes.ts +0 -2
- package/src/components/i18n/locales/am/messages.json +28 -17
- package/src/components/i18n/locales/ar/messages.json +28 -17
- package/src/components/i18n/locales/az/messages.json +28 -17
- package/src/components/i18n/locales/bg/messages.json +28 -17
- package/src/components/i18n/locales/bn/messages.json +28 -17
- package/src/components/i18n/locales/bs/messages.json +30 -19
- package/src/components/i18n/locales/cs/messages.json +32 -21
- package/src/components/i18n/locales/da/messages.json +35 -24
- package/src/components/i18n/locales/de/messages.json +33 -22
- package/src/components/i18n/locales/dv/messages.json +28 -17
- package/src/components/i18n/locales/el/messages.json +28 -17
- package/src/components/i18n/locales/en/messages.json +28 -17
- package/src/components/i18n/locales/es/messages.json +29 -18
- package/src/components/i18n/locales/et/messages.json +32 -21
- package/src/components/i18n/locales/fa/messages.json +28 -17
- package/src/components/i18n/locales/fi/messages.json +28 -17
- package/src/components/i18n/locales/fil/messages.json +51 -40
- package/src/components/i18n/locales/fr/messages.json +29 -18
- package/src/components/i18n/locales/gu/messages.json +28 -17
- package/src/components/i18n/locales/he/messages.json +28 -17
- package/src/components/i18n/locales/hi/messages.json +28 -17
- package/src/components/i18n/locales/hr/messages.json +30 -19
- package/src/components/i18n/locales/hu/messages.json +29 -18
- package/src/components/i18n/locales/hy/messages.json +28 -17
- package/src/components/i18n/locales/id/messages.json +28 -17
- package/src/components/i18n/locales/it/messages.json +29 -18
- package/src/components/i18n/locales/ja/messages.json +28 -17
- package/src/components/i18n/locales/ka/messages.json +28 -17
- package/src/components/i18n/locales/km/messages.json +28 -17
- package/src/components/i18n/locales/kn/messages.json +28 -17
- package/src/components/i18n/locales/ko/messages.json +28 -17
- package/src/components/i18n/locales/ku/messages.json +28 -17
- package/src/components/i18n/locales/lo/messages.json +28 -17
- package/src/components/i18n/locales/lt/messages.json +28 -17
- package/src/components/i18n/locales/lv/messages.json +28 -17
- package/src/components/i18n/locales/mk/messages.json +28 -17
- package/src/components/i18n/locales/ml/messages.json +28 -17
- package/src/components/i18n/locales/mn/messages.json +28 -17
- package/src/components/i18n/locales/mr/messages.json +28 -17
- package/src/components/i18n/locales/ms/messages.json +30 -19
- package/src/components/i18n/locales/my/messages.json +28 -17
- package/src/components/i18n/locales/ne/messages.json +28 -17
- package/src/components/i18n/locales/nl/messages.json +30 -19
- package/src/components/i18n/locales/no/messages.json +31 -20
- package/src/components/i18n/locales/pa/messages.json +28 -17
- package/src/components/i18n/locales/pl/messages.json +29 -18
- package/src/components/i18n/locales/ps/messages.json +28 -17
- package/src/components/i18n/locales/pt/messages.json +29 -18
- package/src/components/i18n/locales/ro/messages.json +29 -18
- package/src/components/i18n/locales/ru/messages.json +28 -17
- package/src/components/i18n/locales/sd/messages.json +28 -17
- package/src/components/i18n/locales/si/messages.json +28 -17
- package/src/components/i18n/locales/sk/messages.json +30 -19
- package/src/components/i18n/locales/sl/messages.json +30 -19
- package/src/components/i18n/locales/sq/messages.json +29 -18
- package/src/components/i18n/locales/sr/messages.json +28 -17
- package/src/components/i18n/locales/sv/messages.json +30 -19
- package/src/components/i18n/locales/sw/messages.json +28 -17
- package/src/components/i18n/locales/ta/messages.json +28 -17
- package/src/components/i18n/locales/te/messages.json +28 -17
- package/src/components/i18n/locales/th/messages.json +28 -17
- package/src/components/i18n/locales/tr/messages.json +28 -17
- package/src/components/i18n/locales/ug/messages.json +28 -17
- package/src/components/i18n/locales/uk/messages.json +28 -17
- package/src/components/i18n/locales/ur/messages.json +28 -17
- package/src/components/i18n/locales/vi/messages.json +28 -17
- package/src/components/i18n/locales/yi/messages.json +28 -17
- package/src/components/i18n/locales/zh/messages.json +28 -17
- package/src/components/icons/index.ts +59 -47
- package/src/components/inline-tools/inline-tool-code.ts +399 -0
- package/src/components/modules/api/blocks.ts +17 -0
- package/src/components/modules/api/tools.ts +0 -19
- package/src/components/modules/blockEvents/composers/blockSelectionKeys.ts +20 -3
- package/src/components/modules/blockEvents/composers/keyboardNavigation.ts +5 -5
- package/src/components/modules/blockManager/blockManager.ts +0 -11
- package/src/components/modules/blockManager/event-binder.ts +1 -12
- package/src/components/modules/paste/handlers/html-handler.ts +13 -10
- package/src/components/modules/paste/handlers/index.ts +1 -0
- package/src/components/modules/paste/index.ts +6 -0
- package/src/components/modules/themeManager.ts +1 -3
- package/src/components/modules/toolbar/blockSettings.ts +1 -0
- package/src/components/modules/toolbar/inline/index.ts +3 -0
- package/src/components/modules/ui.ts +0 -13
- package/src/components/modules/uiControllers/controllers/keyboard.ts +0 -29
- package/src/components/modules/uiControllers/controllers/selection.ts +2 -14
- package/src/components/ui/toolbox.ts +1 -0
- package/src/components/utils/popover/popover-position.ts +2 -4
- package/src/markdown/index.ts +63 -0
- package/src/markdown/markdown-handler.ts +110 -0
- package/src/markdown/mdast-to-blocks.ts +418 -0
- package/src/markdown/phrasing-to-html.ts +60 -0
- package/src/markdown/types.ts +42 -0
- package/src/stories/EditorModes.stories.ts +0 -60
- package/src/styles/main.css +39 -1140
- package/src/tools/callout/emoji-picker/index.ts +3 -2
- package/src/tools/callout/index.ts +24 -0
- package/src/tools/code/code-keyboard.ts +142 -0
- package/src/tools/code/constants.ts +96 -0
- package/src/tools/code/dom-builder.ts +181 -0
- package/src/tools/code/highlight-applier.ts +229 -0
- package/src/tools/code/index.ts +462 -0
- package/src/tools/code/katex-loader.ts +50 -0
- package/src/tools/code/language-picker.ts +241 -0
- package/src/tools/code/mermaid-loader.ts +45 -0
- package/src/tools/code/shiki-loader.ts +135 -0
- package/src/tools/divider/index.ts +9 -1
- package/src/tools/index.ts +4 -2
- package/src/tools/list/block-operations.ts +3 -1
- package/src/tools/list/depth-validator.ts +4 -7
- package/src/tools/list/dom-builder.ts +5 -3
- package/src/tools/list/index.ts +21 -3
- package/src/tools/list/list-helpers.ts +9 -2
- package/src/tools/list/list-keyboard.ts +56 -14
- package/src/tools/list/list-lifecycle.ts +3 -1
- package/src/tools/list/marker-calculator.ts +37 -0
- package/src/tools/list/ordered-marker-manager.ts +4 -2
- package/src/tools/table/core/table-commands.ts +16 -0
- package/src/tools/table/core/table-controller.ts +29 -0
- package/src/tools/table/core/table-events.ts +17 -0
- package/src/tools/table/index.ts +196 -13
- package/src/tools/table/table-cell-blocks.ts +9 -6
- package/src/tools/table/table-cell-clipboard.ts +7 -2
- package/src/tools/table/table-cell-placement-picker.ts +133 -0
- package/src/tools/table/table-cell-selection.ts +174 -19
- package/src/tools/table/table-core.ts +321 -113
- package/src/tools/table/table-map.ts +279 -0
- package/src/tools/table/table-model.ts +901 -1
- package/src/tools/table/table-operations.ts +78 -44
- package/src/tools/table/table-resize.ts +19 -17
- package/src/tools/table/table-row-col-drag.ts +24 -10
- package/src/tools/table/types.ts +24 -2
- package/types/api/tools.d.ts +0 -18
- package/types/data-attributes.d.ts +0 -1
- package/types/index.d.ts +0 -16
- package/types/markdown.d.ts +2 -0
- package/types/tools/code.d.ts +13 -0
- package/src/tools/database/database-backend-sync.ts +0 -101
- package/src/tools/database/database-board-view.ts +0 -301
- package/src/tools/database/database-card-drag.ts +0 -306
- package/src/tools/database/database-card-drawer.ts +0 -546
- package/src/tools/database/database-column-controls.ts +0 -46
- package/src/tools/database/database-column-drag.ts +0 -262
- package/src/tools/database/database-keyboard.ts +0 -35
- package/src/tools/database/database-list-row-drag.ts +0 -245
- package/src/tools/database/database-list-view.ts +0 -333
- package/src/tools/database/database-model.ts +0 -246
- package/src/tools/database/database-property-type-popover.ts +0 -108
- package/src/tools/database/database-tab-bar.ts +0 -532
- package/src/tools/database/database-view-popover.ts +0 -109
- package/src/tools/database/database-view-renderer.ts +0 -25
- package/src/tools/database/index.ts +0 -948
- package/src/tools/database/types.ts +0 -144
- package/types/tools/database.d.ts +0 -145
- /package/dist/chunks/{am-CHDDMHkd.mjs → am-rVzV1W41.mjs} +0 -0
- /package/dist/chunks/{ar-DoqfNqut.mjs → ar-C710lkoH.mjs} +0 -0
- /package/dist/chunks/{az-C34P9iEa.mjs → az-BOp1pgua.mjs} +0 -0
- /package/dist/chunks/{bg-jroXLY8Y.mjs → bg-CL9p09ZD.mjs} +0 -0
- /package/dist/chunks/{bn-BRI-WqxY.mjs → bn-CNmSeyAy.mjs} +0 -0
- /package/dist/chunks/{bs-CCGUpNHu.mjs → bs-BRzMGqzk.mjs} +0 -0
- /package/dist/chunks/{cs-D5qZOGuc.mjs → cs-BYPBLmnF.mjs} +0 -0
- /package/dist/chunks/{da-DrJ7W37K.mjs → da-CBC_LR1c.mjs} +0 -0
- /package/dist/chunks/{de-BW6-kp2c.mjs → de-DxRFMoAj.mjs} +0 -0
- /package/dist/chunks/{el-C-Vc_Otu.mjs → el-Bk6YbySf.mjs} +0 -0
- /package/dist/chunks/{es-B6fI5K9i.mjs → es-DpT3FCMR.mjs} +0 -0
- /package/dist/chunks/{et-BhVlZ-Yz.mjs → et-DE9Dr_g9.mjs} +0 -0
- /package/dist/chunks/{fa-D55Ijdqa.mjs → fa-Banj1QUE.mjs} +0 -0
- /package/dist/chunks/{fi-jNLjhKUQ.mjs → fi-DfN3M5ER.mjs} +0 -0
- /package/dist/chunks/{fil-DYd0T5aX.mjs → fil-DbCsRS1d.mjs} +0 -0
- /package/dist/chunks/{fr-yxy5xWw_.mjs → fr-D1clKhgt.mjs} +0 -0
- /package/dist/chunks/{gu-CcY_LJe7.mjs → gu-1CsZyRwT.mjs} +0 -0
- /package/dist/chunks/{he-DL9s7wNw.mjs → he-qQdnL6eK.mjs} +0 -0
- /package/dist/chunks/{hi-C8eGXgw5.mjs → hi-DxM0Nff1.mjs} +0 -0
- /package/dist/chunks/{hr-DLpybOhU.mjs → hr-Onldyi-u.mjs} +0 -0
- /package/dist/chunks/{hu-BkT0gT00.mjs → hu-CAn3pBuY.mjs} +0 -0
- /package/dist/chunks/{hy-CVFDCp2S.mjs → hy-D43q7NxE.mjs} +0 -0
- /package/dist/chunks/{id-0P4W9Az0.mjs → id-Xrw5Dd0Y.mjs} +0 -0
- /package/dist/chunks/{it-mLY6_uoW.mjs → it-CA9ZDMSc.mjs} +0 -0
- /package/dist/chunks/{ja-7RkeRNWG.mjs → ja-D0J6WRFh.mjs} +0 -0
- /package/dist/chunks/{ka-C7Lx-Qsh.mjs → ka-BZL7xDuY.mjs} +0 -0
- /package/dist/chunks/{km-Q8udaraH.mjs → km-BimgQZVU.mjs} +0 -0
- /package/dist/chunks/{kn-BiETM-iq.mjs → kn-C2n2cPHK.mjs} +0 -0
- /package/dist/chunks/{ko-tiB80pF1.mjs → ko-n4Cn93D3.mjs} +0 -0
- /package/dist/chunks/{ku-CY-OABkR.mjs → ku-BYZCgT44.mjs} +0 -0
- /package/dist/chunks/{lo-CTBhEnyk.mjs → lo-DVXiAE4N.mjs} +0 -0
- /package/dist/chunks/{lt-BHKHEtqK.mjs → lt-B9KlQFnY.mjs} +0 -0
- /package/dist/chunks/{lv-DWxgtfUg.mjs → lv-BINeOdyx.mjs} +0 -0
- /package/dist/chunks/{mk-BjookGdx.mjs → mk-_-QrPrLN.mjs} +0 -0
- /package/dist/chunks/{ml-L-NnZcp9.mjs → ml-KvJSC1KT.mjs} +0 -0
- /package/dist/chunks/{mn-OMWi7Hl_.mjs → mn-CjFjWnRG.mjs} +0 -0
- /package/dist/chunks/{mr-B6JPzITo.mjs → mr-DqAZ7FRX.mjs} +0 -0
- /package/dist/chunks/{ms-CG3S-sPB.mjs → ms-BZcV4UG_.mjs} +0 -0
- /package/dist/chunks/{my-BLAmGfhT.mjs → my-97SC9jYN.mjs} +0 -0
- /package/dist/chunks/{native-BPcABu9z.mjs → native-CzYG0YgY.mjs} +0 -0
- /package/dist/chunks/{ne-D1JHLfYw.mjs → ne-Bs-M2TyF.mjs} +0 -0
- /package/dist/chunks/{nl-Ca7Q8FnY.mjs → nl-2ZwQilo-.mjs} +0 -0
- /package/dist/chunks/{no-Coxcohcz.mjs → no-fOQTpFq1.mjs} +0 -0
- /package/dist/chunks/{pa-CCaXqpaI.mjs → pa-DLOqkMi0.mjs} +0 -0
- /package/dist/chunks/{pl-Cl_fAZ84.mjs → pl-FYs9QrXU.mjs} +0 -0
- /package/dist/chunks/{ps-WD5qGAWy.mjs → ps-CTXe6pSe.mjs} +0 -0
- /package/dist/chunks/{pt-C4zvLfvq.mjs → pt-B1X4x7d1.mjs} +0 -0
- /package/dist/chunks/{ro-DbefHcmM.mjs → ro-Bf7S2FaR.mjs} +0 -0
- /package/dist/chunks/{ru-uU1J14jd.mjs → ru-B8lqnu_j.mjs} +0 -0
- /package/dist/chunks/{sd-DKu368Ip.mjs → sd-CHRYJm2r.mjs} +0 -0
- /package/dist/chunks/{si-BsJCiPkZ.mjs → si-CI0Hs6vH.mjs} +0 -0
- /package/dist/chunks/{sk-CD-a3SN6.mjs → sk-Bdvq1Kb_.mjs} +0 -0
- /package/dist/chunks/{sl-CXhrPJe_.mjs → sl-B_qiFTV5.mjs} +0 -0
- /package/dist/chunks/{sq-CTctCoFQ.mjs → sq-E0j1hysP.mjs} +0 -0
- /package/dist/chunks/{sr-BZkhBwXj.mjs → sr-VPpVNTZw.mjs} +0 -0
- /package/dist/chunks/{sv-NmRZb_xi.mjs → sv-gKmDSR3d.mjs} +0 -0
- /package/dist/chunks/{sw-Be5ik3H6.mjs → sw-zeFLiO23.mjs} +0 -0
- /package/dist/chunks/{ta-DsXh6neL.mjs → ta-Ci-j89hR.mjs} +0 -0
- /package/dist/chunks/{te-CwpCbM8M.mjs → te-qyMI0M7a.mjs} +0 -0
- /package/dist/chunks/{th-CcZ15OLk.mjs → th-DPxHtpdb.mjs} +0 -0
- /package/dist/chunks/{tr-q3bTgvhW.mjs → tr-CRV6GS-G.mjs} +0 -0
- /package/dist/chunks/{tw-DmW6-pCY.mjs → tw-CqxBf-1Y.mjs} +0 -0
- /package/dist/chunks/{ug-919EhLsL.mjs → ug-DW0YFpo5.mjs} +0 -0
- /package/dist/chunks/{uk-aNMEzd0Y.mjs → uk-ssteuphK.mjs} +0 -0
- /package/dist/chunks/{ur-BwQI77sh.mjs → ur-qhY3-jY7.mjs} +0 -0
- /package/dist/chunks/{vi-Dxq806-F.mjs → vi-CHriMMC8.mjs} +0 -0
- /package/dist/chunks/{zh-BcHuy1Ti.mjs → zh-BJktawVN.mjs} +0 -0
|
@@ -613,8 +613,9 @@ export class EmojiPicker {
|
|
|
613
613
|
this._body.appendChild(section);
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
-
// Standard categories
|
|
617
|
-
const
|
|
616
|
+
// Standard categories (exclude curated emojis to avoid duplicates)
|
|
617
|
+
const curatedSet = new Set(CURATED_CALLOUT_EMOJIS);
|
|
618
|
+
const byCategory = groupEmojisByCategory(emojis.filter(e => !curatedSet.has(e.native)));
|
|
618
619
|
|
|
619
620
|
for (const [category, categoryEmojis] of byCategory) {
|
|
620
621
|
visibleCategories.add(category);
|
|
@@ -7,6 +7,8 @@ import type {
|
|
|
7
7
|
ToolboxConfig,
|
|
8
8
|
ConversionConfig,
|
|
9
9
|
ToolSanitizerConfig,
|
|
10
|
+
PasteConfig,
|
|
11
|
+
HTMLPasteEvent,
|
|
10
12
|
} from '../../../types';
|
|
11
13
|
import type { MenuConfig } from '../../../types/tools/menu-config';
|
|
12
14
|
import { PopoverItemType } from '../../components/utils/popover';
|
|
@@ -177,6 +179,22 @@ export class CalloutTool implements BlockTool {
|
|
|
177
179
|
return true;
|
|
178
180
|
}
|
|
179
181
|
|
|
182
|
+
public onPaste(event: HTMLPasteEvent): void {
|
|
183
|
+
const content = event.detail.data;
|
|
184
|
+
const style = content.getAttribute('style') ?? '';
|
|
185
|
+
const bgMatch = /background(?:-color)?\s*:\s*([^;]+)/i.exec(style);
|
|
186
|
+
|
|
187
|
+
if (bgMatch?.[1]) {
|
|
188
|
+
const presetName = mapToNearestPresetName(bgMatch[1].trim(), 'bg');
|
|
189
|
+
|
|
190
|
+
if (presetName) {
|
|
191
|
+
this._data.backgroundColor = presetName;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
this.applyColors();
|
|
196
|
+
}
|
|
197
|
+
|
|
180
198
|
public renderSettings(): MenuConfig {
|
|
181
199
|
if (this._colorPicker === null) {
|
|
182
200
|
const picker = createColorPicker({
|
|
@@ -374,6 +392,12 @@ export class CalloutTool implements BlockTool {
|
|
|
374
392
|
};
|
|
375
393
|
}
|
|
376
394
|
|
|
395
|
+
public static get pasteConfig(): PasteConfig {
|
|
396
|
+
return {
|
|
397
|
+
tags: [{ ASIDE: { style: true } }],
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
|
|
377
401
|
public static get sanitize(): ToolSanitizerConfig {
|
|
378
402
|
return {
|
|
379
403
|
emoji: false,
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { TAB_STRING } from './constants';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handle keydown events inside the code block.
|
|
5
|
+
* Returns true if the event was handled (caller should preventDefault).
|
|
6
|
+
*/
|
|
7
|
+
export function handleCodeKeydown(
|
|
8
|
+
event: KeyboardEvent,
|
|
9
|
+
codeElement: HTMLElement,
|
|
10
|
+
onExit: () => void
|
|
11
|
+
): boolean {
|
|
12
|
+
if (event.key === 'Enter' && event.shiftKey) {
|
|
13
|
+
onExit();
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (event.key === 'Enter') {
|
|
18
|
+
insertNewline(codeElement);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (event.key === 'Tab' && !event.shiftKey) {
|
|
23
|
+
insertTab();
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (event.key === 'Tab' && event.shiftKey) {
|
|
28
|
+
removeTab(codeElement);
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function insertNewline(codeElement: HTMLElement): void {
|
|
36
|
+
const selection = window.getSelection();
|
|
37
|
+
if (!selection || selection.rangeCount === 0) return;
|
|
38
|
+
|
|
39
|
+
const range = selection.getRangeAt(0);
|
|
40
|
+
|
|
41
|
+
const preCaretRange = range.cloneRange();
|
|
42
|
+
preCaretRange.selectNodeContents(codeElement);
|
|
43
|
+
preCaretRange.setEnd(range.startContainer, range.startOffset);
|
|
44
|
+
const caretOffset = preCaretRange.toString().length;
|
|
45
|
+
|
|
46
|
+
const text = codeElement.textContent ?? '';
|
|
47
|
+
const before = text.substring(0, caretOffset);
|
|
48
|
+
const after = text.substring(caretOffset);
|
|
49
|
+
|
|
50
|
+
while (codeElement.firstChild) {
|
|
51
|
+
codeElement.removeChild(codeElement.firstChild);
|
|
52
|
+
}
|
|
53
|
+
codeElement.appendChild(document.createTextNode(before + '\n' + after));
|
|
54
|
+
|
|
55
|
+
restoreCaretOffset(codeElement, caretOffset + 1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function insertTab(): void {
|
|
59
|
+
const selection = window.getSelection();
|
|
60
|
+
if (!selection || selection.rangeCount === 0) return;
|
|
61
|
+
|
|
62
|
+
const range = selection.getRangeAt(0);
|
|
63
|
+
range.deleteContents();
|
|
64
|
+
|
|
65
|
+
const tab = document.createTextNode(TAB_STRING);
|
|
66
|
+
range.insertNode(tab);
|
|
67
|
+
range.setStartAfter(tab);
|
|
68
|
+
range.collapse(true);
|
|
69
|
+
|
|
70
|
+
selection.removeAllRanges();
|
|
71
|
+
selection.addRange(range);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Count leading spaces on the line (up to TAB_STRING length).
|
|
76
|
+
*/
|
|
77
|
+
function countLeadingSpaces(lineContent: string): number {
|
|
78
|
+
const limit = Math.min(TAB_STRING.length, lineContent.length);
|
|
79
|
+
const match = lineContent.substring(0, limit).match(/^ */);
|
|
80
|
+
|
|
81
|
+
return match ? match[0].length : 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function removeTab(codeElement: HTMLElement): void {
|
|
85
|
+
const selection = window.getSelection();
|
|
86
|
+
if (!selection || selection.rangeCount === 0) return;
|
|
87
|
+
|
|
88
|
+
const range = selection.getRangeAt(0);
|
|
89
|
+
const textContent = codeElement.textContent ?? '';
|
|
90
|
+
|
|
91
|
+
const preCaretRange = range.cloneRange();
|
|
92
|
+
preCaretRange.selectNodeContents(codeElement);
|
|
93
|
+
preCaretRange.setEnd(range.startContainer, range.startOffset);
|
|
94
|
+
|
|
95
|
+
const caretOffset = preCaretRange.toString().length;
|
|
96
|
+
const lineStart = textContent.lastIndexOf('\n', caretOffset - 1) + 1;
|
|
97
|
+
const lineContent = textContent.substring(lineStart);
|
|
98
|
+
|
|
99
|
+
const spacesToRemove = countLeadingSpaces(lineContent);
|
|
100
|
+
|
|
101
|
+
if (spacesToRemove === 0) return;
|
|
102
|
+
|
|
103
|
+
const before = textContent.substring(0, lineStart);
|
|
104
|
+
const after = textContent.substring(lineStart + spacesToRemove);
|
|
105
|
+
const updated = before + after;
|
|
106
|
+
|
|
107
|
+
// Replace text by clearing children and inserting a new text node
|
|
108
|
+
while (codeElement.firstChild) {
|
|
109
|
+
codeElement.removeChild(codeElement.firstChild);
|
|
110
|
+
}
|
|
111
|
+
codeElement.appendChild(document.createTextNode(updated));
|
|
112
|
+
|
|
113
|
+
const newCaretOffset = Math.max(lineStart, caretOffset - spacesToRemove);
|
|
114
|
+
restoreCaretOffset(codeElement, newCaretOffset);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function restoreCaretOffset(element: HTMLElement, offset: number): void {
|
|
118
|
+
const selection = window.getSelection();
|
|
119
|
+
if (!selection) return;
|
|
120
|
+
|
|
121
|
+
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
|
122
|
+
|
|
123
|
+
const findNode = (accumulated: number): void => {
|
|
124
|
+
const current = walker.nextNode();
|
|
125
|
+
if (!current) return;
|
|
126
|
+
|
|
127
|
+
const nodeLength = (current.textContent ?? '').length;
|
|
128
|
+
|
|
129
|
+
if (accumulated + nodeLength >= offset) {
|
|
130
|
+
const range = document.createRange();
|
|
131
|
+
range.setStart(current, offset - accumulated);
|
|
132
|
+
range.collapse(true);
|
|
133
|
+
selection.removeAllRanges();
|
|
134
|
+
selection.addRange(range);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
findNode(accumulated + nodeLength);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
findNode(0);
|
|
142
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export const TOOL_NAME = 'code';
|
|
2
|
+
|
|
3
|
+
// i18n keys
|
|
4
|
+
export const PLACEHOLDER_KEY = 'tools.code.placeholder';
|
|
5
|
+
export const LANGUAGE_KEY = 'tools.code.language';
|
|
6
|
+
export const COPIED_KEY = 'tools.code.copied';
|
|
7
|
+
export const COPY_CODE_KEY = 'tools.code.copyCode';
|
|
8
|
+
export const WRAP_LINES_KEY = 'tools.code.wrapLines';
|
|
9
|
+
export const SEARCH_LANGUAGE_KEY = 'tools.code.searchLanguage';
|
|
10
|
+
|
|
11
|
+
// Default values
|
|
12
|
+
export const DEFAULT_LANGUAGE = 'plain text';
|
|
13
|
+
export const TAB_STRING = ' '; // 2 spaces
|
|
14
|
+
|
|
15
|
+
// Language list — display name + lowercase identifier
|
|
16
|
+
export interface LanguageEntry {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const LANGUAGES: LanguageEntry[] = [
|
|
22
|
+
{ id: 'plain text', name: 'Plain Text' },
|
|
23
|
+
{ id: 'javascript', name: 'JavaScript' },
|
|
24
|
+
{ id: 'typescript', name: 'TypeScript' },
|
|
25
|
+
{ id: 'python', name: 'Python' },
|
|
26
|
+
{ id: 'java', name: 'Java' },
|
|
27
|
+
{ id: 'c', name: 'C' },
|
|
28
|
+
{ id: 'cpp', name: 'C++' },
|
|
29
|
+
{ id: 'csharp', name: 'C#' },
|
|
30
|
+
{ id: 'go', name: 'Go' },
|
|
31
|
+
{ id: 'rust', name: 'Rust' },
|
|
32
|
+
{ id: 'ruby', name: 'Ruby' },
|
|
33
|
+
{ id: 'php', name: 'PHP' },
|
|
34
|
+
{ id: 'swift', name: 'Swift' },
|
|
35
|
+
{ id: 'kotlin', name: 'Kotlin' },
|
|
36
|
+
{ id: 'latex', name: 'LaTeX' },
|
|
37
|
+
{ id: 'mermaid', name: 'Mermaid' },
|
|
38
|
+
{ id: 'sql', name: 'SQL' },
|
|
39
|
+
{ id: 'html', name: 'HTML' },
|
|
40
|
+
{ id: 'css', name: 'CSS' },
|
|
41
|
+
{ id: 'json', name: 'JSON' },
|
|
42
|
+
{ id: 'yaml', name: 'YAML' },
|
|
43
|
+
{ id: 'markdown', name: 'Markdown' },
|
|
44
|
+
{ id: 'bash', name: 'Bash' },
|
|
45
|
+
{ id: 'shell', name: 'Shell' },
|
|
46
|
+
{ id: 'dockerfile', name: 'Dockerfile' },
|
|
47
|
+
{ id: 'xml', name: 'XML' },
|
|
48
|
+
{ id: 'graphql', name: 'GraphQL' },
|
|
49
|
+
{ id: 'r', name: 'R' },
|
|
50
|
+
{ id: 'scala', name: 'Scala' },
|
|
51
|
+
{ id: 'dart', name: 'Dart' },
|
|
52
|
+
{ id: 'lua', name: 'Lua' },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
// CSS — Tailwind classes
|
|
56
|
+
export const WRAPPER_STYLES = 'flex flex-col rounded-lg bg-bg-secondary overflow-hidden my-1';
|
|
57
|
+
export const HEADER_STYLES = 'flex items-center gap-1 px-3 py-1.5 border-b border-border-primary text-xs text-gray-text';
|
|
58
|
+
export const LANGUAGE_BUTTON_STYLES = 'px-1.5 py-0.5 rounded cursor-pointer bg-transparent border-0 text-xs text-gray-text font-medium transition-colors can-hover:hover:bg-item-hover-bg select-none';
|
|
59
|
+
export const HEADER_BUTTON_STYLES = 'p-1 rounded cursor-pointer bg-transparent border-0 text-gray-text transition-colors can-hover:hover:bg-item-hover-bg flex items-center justify-center';
|
|
60
|
+
export const CODE_AREA_STYLES = 'block px-4 py-3 font-mono text-sm leading-relaxed outline-hidden whitespace-pre-wrap overflow-x-auto min-h-[1.5em]';
|
|
61
|
+
export const COPIED_FEEDBACK_STYLES = 'text-xs text-gray-text font-medium select-none';
|
|
62
|
+
|
|
63
|
+
// Languages that support preview rendering
|
|
64
|
+
export const PREVIEWABLE_LANGUAGES = new Set(['latex', 'mermaid']);
|
|
65
|
+
|
|
66
|
+
// i18n keys — preview tabs
|
|
67
|
+
export const CODE_TAB_KEY = 'tools.code.codeTab';
|
|
68
|
+
export const PREVIEW_TAB_KEY = 'tools.code.previewTab';
|
|
69
|
+
|
|
70
|
+
// CSS — preview tab styles
|
|
71
|
+
export const TAB_STYLES = 'px-2 py-0.5 rounded text-xs font-medium cursor-pointer border-0 transition-colors select-none';
|
|
72
|
+
export const TAB_ACTIVE_STYLES = 'bg-blue-500 text-white';
|
|
73
|
+
export const TAB_INACTIVE_STYLES = 'bg-transparent text-gray-text can-hover:hover:bg-item-hover-bg';
|
|
74
|
+
export const PREVIEW_AREA_STYLES = 'px-4 py-3 overflow-x-auto min-h-[1.5em] flex justify-center';
|
|
75
|
+
|
|
76
|
+
// Shiki theme names for syntax highlighting
|
|
77
|
+
export const SHIKI_LIGHT_THEME = 'one-light';
|
|
78
|
+
export const SHIKI_DARK_THEME = 'vitesse-dark';
|
|
79
|
+
|
|
80
|
+
// CSS selector for dark mode (Tailwind convention)
|
|
81
|
+
export const DARK_MODE_SELECTOR = '.dark';
|
|
82
|
+
|
|
83
|
+
// Languages that support syntax highlighting (all except plain text)
|
|
84
|
+
export const HIGHLIGHTABLE_LANGUAGES = new Set(
|
|
85
|
+
LANGUAGES
|
|
86
|
+
.map((lang) => lang.id)
|
|
87
|
+
.filter((id) => id !== DEFAULT_LANGUAGE)
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// i18n key — line numbers toggle
|
|
91
|
+
export const LINE_NUMBERS_KEY = 'tools.code.lineNumbers';
|
|
92
|
+
|
|
93
|
+
// CSS — line number gutter
|
|
94
|
+
export const CODE_BODY_STYLES = 'flex overflow-hidden';
|
|
95
|
+
export const GUTTER_STYLES = 'select-none text-right pr-3 py-3 font-mono text-sm leading-relaxed text-gray-text/40 border-r border-border-primary shrink-0';
|
|
96
|
+
export const GUTTER_LINE_STYLES = 'leading-relaxed';
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WRAPPER_STYLES,
|
|
3
|
+
HEADER_STYLES,
|
|
4
|
+
LANGUAGE_BUTTON_STYLES,
|
|
5
|
+
HEADER_BUTTON_STYLES,
|
|
6
|
+
CODE_AREA_STYLES,
|
|
7
|
+
TAB_STYLES,
|
|
8
|
+
TAB_ACTIVE_STYLES,
|
|
9
|
+
TAB_INACTIVE_STYLES,
|
|
10
|
+
PREVIEW_AREA_STYLES,
|
|
11
|
+
CODE_BODY_STYLES,
|
|
12
|
+
GUTTER_STYLES,
|
|
13
|
+
GUTTER_LINE_STYLES,
|
|
14
|
+
} from './constants';
|
|
15
|
+
import { IconCopy, IconWrap, IconLineNumbers } from '../../components/icons';
|
|
16
|
+
|
|
17
|
+
export interface CodeDOMRefs {
|
|
18
|
+
wrapper: HTMLElement;
|
|
19
|
+
languageButton: HTMLButtonElement;
|
|
20
|
+
lineNumbersButton: HTMLButtonElement;
|
|
21
|
+
copyButton: HTMLButtonElement;
|
|
22
|
+
wrapButton: HTMLButtonElement;
|
|
23
|
+
preElement: HTMLPreElement;
|
|
24
|
+
codeElement: HTMLElement;
|
|
25
|
+
gutterElement: HTMLElement;
|
|
26
|
+
codeTab: HTMLButtonElement | null;
|
|
27
|
+
previewTab: HTMLButtonElement | null;
|
|
28
|
+
previewElement: HTMLDivElement | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface BuildCodeDOMOptions {
|
|
32
|
+
code: string;
|
|
33
|
+
languageName: string;
|
|
34
|
+
readOnly: boolean;
|
|
35
|
+
copyLabel: string;
|
|
36
|
+
wrapLabel: string;
|
|
37
|
+
lineNumbersLabel?: string;
|
|
38
|
+
previewable?: boolean;
|
|
39
|
+
codeTabLabel?: string;
|
|
40
|
+
previewTabLabel?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function buildPreviewElements(
|
|
44
|
+
codeTabLabel?: string,
|
|
45
|
+
previewTabLabel?: string,
|
|
46
|
+
): { codeTab: HTMLButtonElement; previewTab: HTMLButtonElement; previewElement: HTMLDivElement } {
|
|
47
|
+
const codeTab = document.createElement('button');
|
|
48
|
+
|
|
49
|
+
codeTab.type = 'button';
|
|
50
|
+
codeTab.className = `${TAB_STYLES} ${TAB_INACTIVE_STYLES}`;
|
|
51
|
+
codeTab.textContent = codeTabLabel ?? 'Code';
|
|
52
|
+
codeTab.setAttribute('data-blok-testid', 'code-code-tab');
|
|
53
|
+
|
|
54
|
+
const previewTab = document.createElement('button');
|
|
55
|
+
|
|
56
|
+
previewTab.type = 'button';
|
|
57
|
+
previewTab.className = `${TAB_STYLES} ${TAB_ACTIVE_STYLES}`;
|
|
58
|
+
previewTab.textContent = previewTabLabel ?? 'Preview';
|
|
59
|
+
previewTab.setAttribute('data-blok-testid', 'code-preview-tab');
|
|
60
|
+
|
|
61
|
+
const previewElement = document.createElement('div');
|
|
62
|
+
|
|
63
|
+
previewElement.className = PREVIEW_AREA_STYLES;
|
|
64
|
+
previewElement.setAttribute('data-blok-testid', 'code-preview');
|
|
65
|
+
|
|
66
|
+
return { codeTab, previewTab, previewElement };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function buildCodeDOM(options: BuildCodeDOMOptions): CodeDOMRefs {
|
|
70
|
+
const { code, languageName, readOnly, copyLabel, wrapLabel, lineNumbersLabel, previewable, codeTabLabel, previewTabLabel } = options;
|
|
71
|
+
|
|
72
|
+
// Wrapper
|
|
73
|
+
const wrapper = document.createElement('div');
|
|
74
|
+
wrapper.className = WRAPPER_STYLES;
|
|
75
|
+
|
|
76
|
+
// Header
|
|
77
|
+
const header = document.createElement('div');
|
|
78
|
+
header.className = HEADER_STYLES;
|
|
79
|
+
|
|
80
|
+
// Language button (opens language picker)
|
|
81
|
+
const languageButton = document.createElement('button');
|
|
82
|
+
languageButton.type = 'button';
|
|
83
|
+
languageButton.className = LANGUAGE_BUTTON_STYLES;
|
|
84
|
+
languageButton.textContent = languageName;
|
|
85
|
+
languageButton.setAttribute('aria-haspopup', 'listbox');
|
|
86
|
+
languageButton.setAttribute('data-blok-testid', 'code-language-btn');
|
|
87
|
+
|
|
88
|
+
// Spacer
|
|
89
|
+
const spacer = document.createElement('div');
|
|
90
|
+
spacer.className = 'flex-1';
|
|
91
|
+
|
|
92
|
+
// Tab buttons (only when previewable)
|
|
93
|
+
const { codeTab, previewTab, previewElement } = previewable
|
|
94
|
+
? buildPreviewElements(codeTabLabel, previewTabLabel)
|
|
95
|
+
: { codeTab: null, previewTab: null, previewElement: null };
|
|
96
|
+
|
|
97
|
+
// Wrap toggle button
|
|
98
|
+
const wrapButton = document.createElement('button');
|
|
99
|
+
wrapButton.type = 'button';
|
|
100
|
+
wrapButton.className = HEADER_BUTTON_STYLES;
|
|
101
|
+
wrapButton.innerHTML = IconWrap;
|
|
102
|
+
wrapButton.setAttribute('aria-label', wrapLabel);
|
|
103
|
+
wrapButton.setAttribute('data-blok-testid', 'code-wrap-btn');
|
|
104
|
+
|
|
105
|
+
// Line numbers toggle button
|
|
106
|
+
const lineNumbersButton = document.createElement('button');
|
|
107
|
+
lineNumbersButton.type = 'button';
|
|
108
|
+
lineNumbersButton.className = HEADER_BUTTON_STYLES;
|
|
109
|
+
lineNumbersButton.innerHTML = IconLineNumbers;
|
|
110
|
+
lineNumbersButton.setAttribute('aria-label', lineNumbersLabel ?? 'Line numbers');
|
|
111
|
+
lineNumbersButton.setAttribute('data-blok-testid', 'code-line-numbers-btn');
|
|
112
|
+
|
|
113
|
+
// Copy button
|
|
114
|
+
const copyButton = document.createElement('button');
|
|
115
|
+
copyButton.type = 'button';
|
|
116
|
+
copyButton.className = HEADER_BUTTON_STYLES;
|
|
117
|
+
copyButton.innerHTML = IconCopy;
|
|
118
|
+
copyButton.setAttribute('aria-label', copyLabel);
|
|
119
|
+
copyButton.setAttribute('data-blok-testid', 'code-copy-btn');
|
|
120
|
+
|
|
121
|
+
// Code area
|
|
122
|
+
const codeElement = document.createElement('code');
|
|
123
|
+
codeElement.className = CODE_AREA_STYLES;
|
|
124
|
+
codeElement.setAttribute('data-blok-testid', 'code-content');
|
|
125
|
+
|
|
126
|
+
if (code) {
|
|
127
|
+
codeElement.textContent = code;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (!readOnly) {
|
|
131
|
+
codeElement.setAttribute('contenteditable', 'plaintext-only');
|
|
132
|
+
codeElement.setAttribute('spellcheck', 'false');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Line number gutter
|
|
136
|
+
const gutterElement = document.createElement('div');
|
|
137
|
+
gutterElement.className = GUTTER_STYLES;
|
|
138
|
+
gutterElement.setAttribute('aria-hidden', 'true');
|
|
139
|
+
gutterElement.setAttribute('data-blok-testid', 'code-gutter');
|
|
140
|
+
|
|
141
|
+
const lineCount = code ? code.split('\n').length : 1;
|
|
142
|
+
Array.from({ length: lineCount }, (_, idx) => {
|
|
143
|
+
const lineEl = document.createElement('div');
|
|
144
|
+
lineEl.className = GUTTER_LINE_STYLES;
|
|
145
|
+
lineEl.textContent = String(idx + 1);
|
|
146
|
+
gutterElement.appendChild(lineEl);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Assemble header
|
|
150
|
+
header.appendChild(languageButton);
|
|
151
|
+
header.appendChild(spacer);
|
|
152
|
+
|
|
153
|
+
if (codeTab && previewTab) {
|
|
154
|
+
header.appendChild(codeTab);
|
|
155
|
+
header.appendChild(previewTab);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
header.appendChild(lineNumbersButton);
|
|
159
|
+
header.appendChild(wrapButton);
|
|
160
|
+
header.appendChild(copyButton);
|
|
161
|
+
|
|
162
|
+
// Pre wrapper for semantic HTML
|
|
163
|
+
const preElement = document.createElement('pre');
|
|
164
|
+
preElement.appendChild(codeElement);
|
|
165
|
+
|
|
166
|
+
// Code body container (flex: gutter + pre)
|
|
167
|
+
const codeBody = document.createElement('div');
|
|
168
|
+
codeBody.className = CODE_BODY_STYLES;
|
|
169
|
+
codeBody.appendChild(gutterElement);
|
|
170
|
+
codeBody.appendChild(preElement);
|
|
171
|
+
|
|
172
|
+
// Assemble wrapper
|
|
173
|
+
wrapper.appendChild(header);
|
|
174
|
+
wrapper.appendChild(codeBody);
|
|
175
|
+
|
|
176
|
+
if (previewElement) {
|
|
177
|
+
wrapper.appendChild(previewElement);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return { wrapper, languageButton, lineNumbersButton, copyButton, wrapButton, preElement, codeElement, gutterElement, codeTab, previewTab, previewElement };
|
|
181
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { DARK_MODE_SELECTOR } from './constants';
|
|
2
|
+
|
|
3
|
+
export interface HighlightToken {
|
|
4
|
+
content: string;
|
|
5
|
+
color: string;
|
|
6
|
+
/** Character offset from the start of the LINE (not document) */
|
|
7
|
+
offset: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ThemeTokens {
|
|
11
|
+
tokens: HighlightToken[][];
|
|
12
|
+
fg: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DualThemeTokens {
|
|
16
|
+
light: ThemeTokens;
|
|
17
|
+
dark: ThemeTokens;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Typed subset of Highlight (Set-like, as per the CSS Custom Highlight API spec) */
|
|
21
|
+
interface HighlightSet extends Highlight {
|
|
22
|
+
add(range: Range): void;
|
|
23
|
+
delete(range: Range): boolean;
|
|
24
|
+
size: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Typed subset of the CSS Custom Highlight API HighlightRegistry (Map-like) */
|
|
28
|
+
interface HighlightMap {
|
|
29
|
+
get(name: string): HighlightSet | undefined;
|
|
30
|
+
set(name: string, highlight: HighlightSet): void;
|
|
31
|
+
delete(name: string): void;
|
|
32
|
+
keys(): IterableIterator<string>;
|
|
33
|
+
size: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** CSS global augmented with the highlights registry (feature-detected at runtime) */
|
|
37
|
+
interface CSSWithHighlights {
|
|
38
|
+
highlights: HighlightMap;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const state = {
|
|
42
|
+
stylesheet: null as CSSStyleSheet | null,
|
|
43
|
+
knownRules: new Set<string>(),
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export function isHighlightingSupported(): boolean {
|
|
47
|
+
return typeof CSS !== 'undefined' && 'highlights' in CSS;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function getHighlights(): HighlightMap {
|
|
51
|
+
return (CSS as unknown as CSSWithHighlights).highlights;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function ensureStylesheet(): CSSStyleSheet {
|
|
55
|
+
if (!state.stylesheet) {
|
|
56
|
+
state.stylesheet = new CSSStyleSheet();
|
|
57
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, state.stylesheet];
|
|
58
|
+
}
|
|
59
|
+
return state.stylesheet;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function colorToId(hex: string): string {
|
|
63
|
+
const clean = hex.replace('#', '').toLowerCase();
|
|
64
|
+
return clean.length > 6 ? clean.substring(0, 6) : clean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function ensureRule(stylesheet: CSSStyleSheet, name: string, color: string, scope?: string): void {
|
|
68
|
+
const key = `${scope ?? ''}::${name}`;
|
|
69
|
+
if (state.knownRules.has(key)) return;
|
|
70
|
+
|
|
71
|
+
const rule = scope
|
|
72
|
+
? `${scope} ::highlight(${name}) { color: ${color}; }`
|
|
73
|
+
: `::highlight(${name}) { color: ${color}; }`;
|
|
74
|
+
|
|
75
|
+
stylesheet.insertRule(rule, stylesheet.cssRules.length);
|
|
76
|
+
state.knownRules.add(key);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function findTextNode(
|
|
80
|
+
element: HTMLElement,
|
|
81
|
+
targetOffset: number
|
|
82
|
+
): { node: Node; offset: number } | null {
|
|
83
|
+
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
|
84
|
+
|
|
85
|
+
const find = (node: Node | null, accumulated: number): { node: Node; offset: number } | null => {
|
|
86
|
+
if (!node) {
|
|
87
|
+
if (targetOffset === accumulated && element.lastChild) {
|
|
88
|
+
return { node: element.lastChild, offset: element.lastChild.textContent?.length ?? 0 };
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const len = node.textContent?.length ?? 0;
|
|
93
|
+
if (accumulated + len > targetOffset) {
|
|
94
|
+
return { node, offset: targetOffset - accumulated };
|
|
95
|
+
}
|
|
96
|
+
return find(walker.nextNode(), accumulated + len);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return find(walker.nextNode(), 0);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function buildLineOffsets(text: string): number[] {
|
|
103
|
+
return text.split('\n').reduce<{ offsets: number[]; pos: number }>(
|
|
104
|
+
(acc, line) => ({
|
|
105
|
+
offsets: [...acc.offsets, acc.pos],
|
|
106
|
+
pos: acc.pos + line.length + 1,
|
|
107
|
+
}),
|
|
108
|
+
{ offsets: [], pos: 0 }
|
|
109
|
+
).offsets;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function applyToken(
|
|
113
|
+
element: HTMLElement,
|
|
114
|
+
text: string,
|
|
115
|
+
lineBase: number,
|
|
116
|
+
token: HighlightToken,
|
|
117
|
+
themeKey: string,
|
|
118
|
+
scope: string | undefined,
|
|
119
|
+
priority: number,
|
|
120
|
+
stylesheet: CSSStyleSheet,
|
|
121
|
+
ownedRanges: Array<[string, Range]>
|
|
122
|
+
): void {
|
|
123
|
+
if (!token.content.trim()) return;
|
|
124
|
+
|
|
125
|
+
const start = lineBase + token.offset;
|
|
126
|
+
const end = start + token.content.length;
|
|
127
|
+
if (end > text.length) return;
|
|
128
|
+
|
|
129
|
+
const startPos = findTextNode(element, start);
|
|
130
|
+
const endPos = findTextNode(element, end);
|
|
131
|
+
if (!startPos || !endPos) return;
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
const range = new Range();
|
|
135
|
+
range.setStart(startPos.node, startPos.offset);
|
|
136
|
+
range.setEnd(endPos.node, endPos.offset);
|
|
137
|
+
|
|
138
|
+
const colorId = colorToId(token.color);
|
|
139
|
+
const hlName = `blok-${themeKey}-${colorId}`;
|
|
140
|
+
const highlights = getHighlights();
|
|
141
|
+
|
|
142
|
+
ensureRule(stylesheet, hlName, token.color, scope);
|
|
143
|
+
|
|
144
|
+
const existing = highlights.get(hlName);
|
|
145
|
+
const highlight = existing ?? (new Highlight() as unknown as HighlightSet);
|
|
146
|
+
if (!existing) {
|
|
147
|
+
highlight.priority = priority;
|
|
148
|
+
highlights.set(hlName, highlight);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
highlight.add(range);
|
|
152
|
+
ownedRanges.push([hlName, range]);
|
|
153
|
+
} catch {
|
|
154
|
+
// Skip invalid ranges
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function applyThemeTokens(
|
|
159
|
+
element: HTMLElement,
|
|
160
|
+
text: string,
|
|
161
|
+
lineOffsets: number[],
|
|
162
|
+
themeData: ThemeTokens,
|
|
163
|
+
themeKey: string,
|
|
164
|
+
scope: string | undefined,
|
|
165
|
+
priority: number,
|
|
166
|
+
stylesheet: CSSStyleSheet,
|
|
167
|
+
ownedRanges: Array<[string, Range]>
|
|
168
|
+
): void {
|
|
169
|
+
for (const [lineIdx, lineTokens] of themeData.tokens.entries()) {
|
|
170
|
+
const lineBase = lineOffsets[lineIdx];
|
|
171
|
+
if (lineBase === undefined) continue;
|
|
172
|
+
|
|
173
|
+
for (const token of lineTokens) {
|
|
174
|
+
applyToken(element, text, lineBase, token, themeKey, scope, priority, stylesheet, ownedRanges);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function applyHighlights(element: HTMLElement, themes: DualThemeTokens): () => void {
|
|
180
|
+
if (!isHighlightingSupported()) return () => {};
|
|
181
|
+
|
|
182
|
+
const stylesheet = ensureStylesheet();
|
|
183
|
+
const ownedRanges: Array<[string, Range]> = [];
|
|
184
|
+
const text = element.textContent ?? '';
|
|
185
|
+
const lineOffsets = buildLineOffsets(text);
|
|
186
|
+
|
|
187
|
+
const themeEntries: Array<[string, ThemeTokens, string | undefined, number]> = [
|
|
188
|
+
['l', themes.light, undefined, 0],
|
|
189
|
+
['d', themes.dark, DARK_MODE_SELECTOR, 1],
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
for (const [themeKey, themeData, scope, priority] of themeEntries) {
|
|
193
|
+
applyThemeTokens(element, text, lineOffsets, themeData, themeKey, scope, priority, stylesheet, ownedRanges);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return () => cleanupRanges(ownedRanges, getHighlights());
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function cleanupRanges(ownedRanges: Array<[string, Range]>, highlights: HighlightMap): void {
|
|
200
|
+
for (const [name, range] of ownedRanges) {
|
|
201
|
+
const hl = highlights.get(name);
|
|
202
|
+
if (!hl) continue;
|
|
203
|
+
hl.delete(range);
|
|
204
|
+
if (hl.size === 0) {
|
|
205
|
+
highlights.delete(name);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function removeBlokHighlights(highlights: HighlightMap): void {
|
|
211
|
+
const blokNames = [...highlights.keys()].filter((name) => name.startsWith('blok-'));
|
|
212
|
+
for (const name of blokNames) {
|
|
213
|
+
highlights.delete(name);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function disposeAllHighlights(): void {
|
|
218
|
+
if (isHighlightingSupported()) {
|
|
219
|
+
removeBlokHighlights(getHighlights());
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (state.stylesheet) {
|
|
223
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(
|
|
224
|
+
(s) => s !== state.stylesheet
|
|
225
|
+
);
|
|
226
|
+
state.stylesheet = null;
|
|
227
|
+
state.knownRules.clear();
|
|
228
|
+
}
|
|
229
|
+
}
|