@novaprose/core 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -2
- package/dist/a11y.cjs +314 -0
- package/dist/a11y.cjs.map +1 -0
- package/dist/a11y.d.cts +51 -0
- package/dist/a11y.d.ts +51 -0
- package/dist/a11y.js +11 -0
- package/dist/a11y.js.map +1 -0
- package/dist/a11ychecker-7KQU7DD3.js +449 -0
- package/dist/a11ychecker-7KQU7DD3.js.map +1 -0
- package/dist/accordion-ui-FGN3I5UF.js +201 -0
- package/dist/accordion-ui-FGN3I5UF.js.map +1 -0
- package/dist/advcode-65Z2ELUB.js +51 -0
- package/dist/advcode-65Z2ELUB.js.map +1 -0
- package/dist/advcode-editor-WIOCY552.js +257 -0
- package/dist/advcode-editor-WIOCY552.js.map +1 -0
- package/dist/{advlist-5FNKPLUX.js → advlist-CEHE6YXS.js} +10 -7
- package/dist/advlist-CEHE6YXS.js.map +1 -0
- package/dist/advtable-ui-5CBOPTHW.js +364 -0
- package/dist/advtable-ui-5CBOPTHW.js.map +1 -0
- package/dist/ai-IRQYZHRK.js +1485 -0
- package/dist/ai-IRQYZHRK.js.map +1 -0
- package/dist/anchor-ui-NWIIRKGY.js +81 -0
- package/dist/anchor-ui-NWIIRKGY.js.map +1 -0
- package/dist/autocorrect-6GFLVDPC.js +851 -0
- package/dist/autocorrect-6GFLVDPC.js.map +1 -0
- package/dist/{autolink-45LTODWB.js → autolink-N427KVQO.js} +11 -8
- package/dist/autolink-N427KVQO.js.map +1 -0
- package/dist/{autoresize-UB3GOA6D.js → autoresize-YRZAVCNO.js} +2 -2
- package/dist/autoresize-YRZAVCNO.js.map +1 -0
- package/dist/{autosave-GMWJ5BPE.js → autosave-L7OZ3KLK.js} +7 -7
- package/dist/autosave-L7OZ3KLK.js.map +1 -0
- package/dist/casechange-5G6RAJ7K.js +201 -0
- package/dist/casechange-5G6RAJ7K.js.map +1 -0
- package/dist/{charmap-2GC7LF7G.js → charmap-5CBBDWOP.js} +7 -7
- package/dist/charmap-5CBBDWOP.js.map +1 -0
- package/dist/checklist-HM4VXZKY.js +189 -0
- package/dist/checklist-HM4VXZKY.js.map +1 -0
- package/dist/chunk-23ZLVT5D.js +163 -0
- package/dist/chunk-23ZLVT5D.js.map +1 -0
- package/dist/{chunk-ND2CWNVG.js → chunk-3BOK3S3T.js} +2 -27
- package/dist/chunk-3BOK3S3T.js.map +1 -0
- package/dist/chunk-4I4AYH2K.js +101 -0
- package/dist/chunk-4I4AYH2K.js.map +1 -0
- package/dist/{chunk-PVFKXRID.js → chunk-4VPDY3LF.js} +1 -1
- package/dist/chunk-4VPDY3LF.js.map +1 -0
- package/dist/chunk-53AY5NAF.js +214 -0
- package/dist/chunk-53AY5NAF.js.map +1 -0
- package/dist/chunk-5VCESSQB.js +137 -0
- package/dist/chunk-5VCESSQB.js.map +1 -0
- package/dist/chunk-66INZHZ2.js +79 -0
- package/dist/chunk-66INZHZ2.js.map +1 -0
- package/dist/chunk-6LQM7G4V.js +159 -0
- package/dist/chunk-6LQM7G4V.js.map +1 -0
- package/dist/chunk-6YSQGFV7.js +893 -0
- package/dist/chunk-6YSQGFV7.js.map +1 -0
- package/dist/{chunk-T3GY6IVK.js → chunk-AC3YCAX4.js} +71 -9
- package/dist/chunk-AC3YCAX4.js.map +1 -0
- package/dist/{chunk-5AW2HHG6.js → chunk-ADRPQLZ2.js} +47 -3
- package/dist/chunk-ADRPQLZ2.js.map +1 -0
- package/dist/chunk-ANE5ASXG.js +26 -0
- package/dist/chunk-ANE5ASXG.js.map +1 -0
- package/dist/{chunk-Z3ELZ77W.js → chunk-AP2PJFLB.js} +5 -2
- package/dist/chunk-AP2PJFLB.js.map +1 -0
- package/dist/chunk-AQV6FIKK.js +259 -0
- package/dist/chunk-AQV6FIKK.js.map +1 -0
- package/dist/chunk-AUQSATWL.js +322 -0
- package/dist/chunk-AUQSATWL.js.map +1 -0
- package/dist/chunk-C326LHHU.js +143 -0
- package/dist/chunk-C326LHHU.js.map +1 -0
- package/dist/{chunk-R2UMUCVI.js → chunk-DEYYVZ7O.js} +50 -8
- package/dist/chunk-DEYYVZ7O.js.map +1 -0
- package/dist/chunk-EOJ5XHKA.js +160 -0
- package/dist/chunk-EOJ5XHKA.js.map +1 -0
- package/dist/chunk-EXX2S352.js +3642 -0
- package/dist/chunk-EXX2S352.js.map +1 -0
- package/dist/chunk-FTEA6L2Q.js +47 -0
- package/dist/chunk-FTEA6L2Q.js.map +1 -0
- package/dist/chunk-G74HNSB6.js +9 -0
- package/dist/chunk-G74HNSB6.js.map +1 -0
- package/dist/{chunk-KWXFL4WS.js → chunk-GHVB6SV4.js} +8 -5
- package/dist/chunk-GHVB6SV4.js.map +1 -0
- package/dist/chunk-GTLE2HEW.js +108 -0
- package/dist/chunk-GTLE2HEW.js.map +1 -0
- package/dist/chunk-GXXXLPDQ.js +67 -0
- package/dist/chunk-GXXXLPDQ.js.map +1 -0
- package/dist/chunk-HC6RMBAD.js +163 -0
- package/dist/chunk-HC6RMBAD.js.map +1 -0
- package/dist/chunk-HNEAVVBC.js +98 -0
- package/dist/chunk-HNEAVVBC.js.map +1 -0
- package/dist/chunk-I7Y4KSM2.js +165 -0
- package/dist/chunk-I7Y4KSM2.js.map +1 -0
- package/dist/chunk-IG2BL4ON.js +127 -0
- package/dist/chunk-IG2BL4ON.js.map +1 -0
- package/dist/{chunk-KPE3QRPB.js → chunk-J6W2CDRF.js} +16 -315
- package/dist/chunk-J6W2CDRF.js.map +1 -0
- package/dist/chunk-LVEQBNLX.js +207 -0
- package/dist/chunk-LVEQBNLX.js.map +1 -0
- package/dist/chunk-MZGNOHSY.js +176 -0
- package/dist/chunk-MZGNOHSY.js.map +1 -0
- package/dist/chunk-N32H37AJ.js +373 -0
- package/dist/chunk-N32H37AJ.js.map +1 -0
- package/dist/chunk-NTGEKGXU.js +263 -0
- package/dist/chunk-NTGEKGXU.js.map +1 -0
- package/dist/chunk-OFHGXYG3.js +140 -0
- package/dist/chunk-OFHGXYG3.js.map +1 -0
- package/dist/chunk-OOVNE6MB.js +28 -0
- package/dist/chunk-OOVNE6MB.js.map +1 -0
- package/dist/chunk-OQMMHWMZ.js +7 -0
- package/dist/chunk-OQMMHWMZ.js.map +1 -0
- package/dist/chunk-P2UU2NLT.js +1149 -0
- package/dist/chunk-P2UU2NLT.js.map +1 -0
- package/dist/{chunk-JPJVTB45.js → chunk-QU3KXMYT.js} +8 -2
- package/dist/chunk-QU3KXMYT.js.map +1 -0
- package/dist/chunk-S2XZRKHA.js +29 -0
- package/dist/chunk-S2XZRKHA.js.map +1 -0
- package/dist/chunk-SCIRO4XK.js +144 -0
- package/dist/chunk-SCIRO4XK.js.map +1 -0
- package/dist/chunk-T3IRLTKK.js +158 -0
- package/dist/chunk-T3IRLTKK.js.map +1 -0
- package/dist/chunk-TABIUD2L.js +66 -0
- package/dist/chunk-TABIUD2L.js.map +1 -0
- package/dist/{chunk-FCMZ7TUQ.js → chunk-TAM2FHKG.js} +172 -43
- package/dist/chunk-TAM2FHKG.js.map +1 -0
- package/dist/chunk-UTMS2P2K.js +288 -0
- package/dist/chunk-UTMS2P2K.js.map +1 -0
- package/dist/{chunk-HPLT3XRZ.js → chunk-V7WUHUHM.js} +13 -1
- package/dist/chunk-V7WUHUHM.js.map +1 -0
- package/dist/{table-SSNABG5W.js → chunk-VK6YF2AA.js} +119 -61
- package/dist/chunk-VK6YF2AA.js.map +1 -0
- package/dist/chunk-WAOU5NGN.js +430 -0
- package/dist/chunk-WAOU5NGN.js.map +1 -0
- package/dist/chunk-XIH4SCO6.js +112 -0
- package/dist/chunk-XIH4SCO6.js.map +1 -0
- package/dist/chunk-XR7CY4NI.js +11 -0
- package/dist/chunk-XR7CY4NI.js.map +1 -0
- package/dist/chunk-YDF55N6Z.js +164 -0
- package/dist/chunk-YDF55N6Z.js.map +1 -0
- package/dist/chunk-YDPZCVXS.js +923 -0
- package/dist/chunk-YDPZCVXS.js.map +1 -0
- package/dist/chunk-YG5V7POU.js +137 -0
- package/dist/chunk-YG5V7POU.js.map +1 -0
- package/dist/chunk-YVSUR7E5.js +151 -0
- package/dist/chunk-YVSUR7E5.js.map +1 -0
- package/dist/codesample-GHWIC7PT.js +546 -0
- package/dist/codesample-GHWIC7PT.js.map +1 -0
- package/dist/{comments-panel-HXMWSRAW.js → comments-panel-SOLBZ46Q.js} +9 -5
- package/dist/comments-panel-SOLBZ46Q.js.map +1 -0
- package/dist/{directionality-5JLWQGP2.js → directionality-EGQKGDZA.js} +13 -10
- package/dist/directionality-EGQKGDZA.js.map +1 -0
- package/dist/document-0ft41E6d.d.ts +39 -0
- package/dist/document-IQqDDT4v.d.cts +39 -0
- package/dist/docx.cjs +23518 -0
- package/dist/docx.cjs.map +1 -0
- package/dist/docx.d.cts +83 -0
- package/dist/docx.d.ts +83 -0
- package/dist/docx.js +1821 -0
- package/dist/docx.js.map +1 -0
- package/dist/draghandle-U6CYZHPA.js +389 -0
- package/dist/draghandle-U6CYZHPA.js.map +1 -0
- package/dist/editimage-5EWPSM22.js +683 -0
- package/dist/editimage-5EWPSM22.js.map +1 -0
- package/dist/editor-BCMxe1M4.d.cts +2888 -0
- package/dist/editor-Dmtwjw2u.d.ts +2888 -0
- package/dist/email-ELNMEQ6E.js +177 -0
- package/dist/email-ELNMEQ6E.js.map +1 -0
- package/dist/email.cjs +588 -0
- package/dist/email.cjs.map +1 -0
- package/dist/email.d.cts +7 -0
- package/dist/email.d.ts +7 -0
- package/dist/email.js +21 -0
- package/dist/email.js.map +1 -0
- package/dist/{emoticons-ZD6ZRIWG.js → emoticons-EGHNZKSA.js} +7 -7
- package/dist/emoticons-EGHNZKSA.js.map +1 -0
- package/dist/exportpdf-4P7X3NY2.js +91 -0
- package/dist/exportpdf-4P7X3NY2.js.map +1 -0
- package/dist/exportword-JFJ3KTYZ.js +16 -0
- package/dist/exportword-JFJ3KTYZ.js.map +1 -0
- package/dist/footnotes-ui-FV6QRGDA.js +449 -0
- package/dist/footnotes-ui-FV6QRGDA.js.map +1 -0
- package/dist/form-dialog-SNWFPM2K.js +379 -0
- package/dist/form-dialog-SNWFPM2K.js.map +1 -0
- package/dist/formatpainter-IEXX27OJ.js +209 -0
- package/dist/formatpainter-IEXX27OJ.js.map +1 -0
- package/dist/fullpagehtml-ui-RE4C2NO5.js +220 -0
- package/dist/fullpagehtml-ui-RE4C2NO5.js.map +1 -0
- package/dist/html-rules-api-BLDDW9MO.d.cts +42 -0
- package/dist/html-rules-api-BLDDW9MO.d.ts +42 -0
- package/dist/html-rules.cjs +19 -17
- package/dist/html-rules.cjs.map +1 -1
- package/dist/html-rules.d.cts +37 -35
- package/dist/html-rules.d.ts +37 -35
- package/dist/html-rules.js +24 -20
- package/dist/html-rules.js.map +1 -1
- package/dist/i18n/de.cjs +346 -0
- package/dist/i18n/de.cjs.map +1 -1
- package/dist/i18n/de.d.cts +1 -1
- package/dist/i18n/de.d.ts +1 -1
- package/dist/i18n/de.js +346 -0
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/es.cjs +346 -0
- package/dist/i18n/es.cjs.map +1 -1
- package/dist/i18n/es.d.cts +1 -1
- package/dist/i18n/es.d.ts +1 -1
- package/dist/i18n/es.js +346 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.cjs +346 -0
- package/dist/i18n/fr.cjs.map +1 -1
- package/dist/i18n/fr.d.cts +1 -1
- package/dist/i18n/fr.d.ts +1 -1
- package/dist/i18n/fr.js +346 -0
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/it.cjs +346 -0
- package/dist/i18n/it.cjs.map +1 -1
- package/dist/i18n/it.d.cts +1 -1
- package/dist/i18n/it.d.ts +1 -1
- package/dist/i18n/it.js +346 -0
- package/dist/i18n/it.js.map +1 -1
- package/dist/i18n/pt-BR.cjs +346 -0
- package/dist/i18n/pt-BR.cjs.map +1 -1
- package/dist/i18n/pt-BR.d.cts +1 -1
- package/dist/i18n/pt-BR.d.ts +1 -1
- package/dist/i18n/pt-BR.js +346 -0
- package/dist/i18n/pt-BR.js.map +1 -1
- package/dist/i18n/ru.cjs +346 -0
- package/dist/i18n/ru.cjs.map +1 -1
- package/dist/i18n/ru.d.cts +3 -3
- package/dist/i18n/ru.d.ts +3 -3
- package/dist/i18n/ru.js +346 -0
- package/dist/i18n/ru.js.map +1 -1
- package/dist/importcss-JLNIRKGH.js +127 -0
- package/dist/importcss-JLNIRKGH.js.map +1 -0
- package/dist/importword-D7Z6RXGQ.js +73 -0
- package/dist/importword-D7Z6RXGQ.js.map +1 -0
- package/dist/{index-C603bU6r.d.ts → index-CZ9yDvmQ.d.cts} +36 -17
- package/dist/{index-C603bU6r.d.cts → index-CZ9yDvmQ.d.ts} +36 -17
- package/dist/index.cjs +28858 -10442
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +138 -64
- package/dist/index.d.ts +138 -64
- package/dist/index.js +199 -1411
- package/dist/index.js.map +1 -1
- package/dist/{insertdatetime-CRO7TJAQ.js → insertdatetime-YW2VHYZH.js} +7 -7
- package/dist/insertdatetime-YW2VHYZH.js.map +1 -0
- package/dist/linkchecker-3S3MCPOS.js +287 -0
- package/dist/linkchecker-3S3MCPOS.js.map +1 -0
- package/dist/markdown-26O3N3T2.js +136 -0
- package/dist/markdown-26O3N3T2.js.map +1 -0
- package/dist/markdown.cjs +94 -11
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.d.cts +12 -10
- package/dist/markdown.d.ts +12 -10
- package/dist/markdown.js +4 -235
- package/dist/markdown.js.map +1 -1
- package/dist/math-ui-RUTCHTRY.js +157 -0
- package/dist/math-ui-RUTCHTRY.js.map +1 -0
- package/dist/media-ui-36TE3CJD.js +123 -0
- package/dist/media-ui-36TE3CJD.js.map +1 -0
- package/dist/mediaembed-ui-ZNTGZ2SQ.js +207 -0
- package/dist/mediaembed-ui-ZNTGZ2SQ.js.map +1 -0
- package/dist/mentions-ui-O4IPWQT4.js +58 -0
- package/dist/mentions-ui-O4IPWQT4.js.map +1 -0
- package/dist/mergetags-ui-HS3Q2R36.js +73 -0
- package/dist/mergetags-ui-HS3Q2R36.js.map +1 -0
- package/dist/{nonbreaking-66LFZV2W.js → nonbreaking-GYRUH4UO.js} +7 -7
- package/dist/nonbreaking-GYRUH4UO.js.map +1 -0
- package/dist/pagebreak-ui-I4ZPYK3U.js +50 -0
- package/dist/pagebreak-ui-I4ZPYK3U.js.map +1 -0
- package/dist/pageembed-ui-WOY6VWRJ.js +172 -0
- package/dist/pageembed-ui-WOY6VWRJ.js.map +1 -0
- package/dist/pagelayout-ui-Y2IM7FJQ.js +236 -0
- package/dist/pagelayout-ui-Y2IM7FJQ.js.map +1 -0
- package/dist/{paste-office-F3QW4WWO.js → paste-office-3A6KWKCV.js} +82 -2
- package/dist/paste-office-3A6KWKCV.js.map +1 -0
- package/dist/permanentpen-6D5LLKFX.js +206 -0
- package/dist/permanentpen-6D5LLKFX.js.map +1 -0
- package/dist/print-MZMLQIQX.js +178 -0
- package/dist/print-MZMLQIQX.js.map +1 -0
- package/dist/{quickbars-7E2QRS7J.js → quickbars-UZ2Q67TX.js} +20 -12
- package/dist/quickbars-UZ2Q67TX.js.map +1 -0
- package/dist/{revisionhistory-DXE7KU4R.js → revisionhistory-ACRB23HL.js} +42 -153
- package/dist/revisionhistory-ACRB23HL.js.map +1 -0
- package/dist/save-72ZLF6AO.js +120 -0
- package/dist/save-72ZLF6AO.js.map +1 -0
- package/dist/search-bar-HTZQNPD3.js +212 -0
- package/dist/search-bar-HTZQNPD3.js.map +1 -0
- package/dist/spellchecker-DJ7SP5JY.js +474 -0
- package/dist/spellchecker-DJ7SP5JY.js.map +1 -0
- package/dist/suggestions-panel-RJXC4LCM.js +596 -0
- package/dist/suggestions-panel-RJXC4LCM.js.map +1 -0
- package/dist/suggestions-ui-PODMNH7D.js +395 -0
- package/dist/suggestions-ui-PODMNH7D.js.map +1 -0
- package/dist/table-OBHE465Y.js +54 -0
- package/dist/table-OBHE465Y.js.map +1 -0
- package/dist/table-dialogs-UMIIZQYE.js +119 -0
- package/dist/table-dialogs-UMIIZQYE.js.map +1 -0
- package/dist/tableofcontents-ui-U2PYNPX6.js +167 -0
- package/dist/tableofcontents-ui-U2PYNPX6.js.map +1 -0
- package/dist/template-YYC2MGVH.js +278 -0
- package/dist/template-YYC2MGVH.js.map +1 -0
- package/dist/typography-EQUXUXIN.js +399 -0
- package/dist/typography-EQUXUXIN.js.map +1 -0
- package/dist/upload.cjs +160 -0
- package/dist/upload.cjs.map +1 -0
- package/dist/upload.d.cts +72 -0
- package/dist/upload.d.ts +72 -0
- package/dist/upload.js +132 -0
- package/dist/upload.js.map +1 -0
- package/dist/{visualblocks-6DLBXYOA.js → visualblocks-O5QW7ZDT.js} +7 -7
- package/dist/visualblocks-O5QW7ZDT.js.map +1 -0
- package/dist/visualchars-UQFRWQPE.js +134 -0
- package/dist/visualchars-UQFRWQPE.js.map +1 -0
- package/package.json +53 -3
- package/src/style.css +320 -544
- package/dist/advlist-5FNKPLUX.js.map +0 -1
- package/dist/autolink-45LTODWB.js.map +0 -1
- package/dist/autoresize-UB3GOA6D.js.map +0 -1
- package/dist/autosave-GMWJ5BPE.js.map +0 -1
- package/dist/charmap-2GC7LF7G.js.map +0 -1
- package/dist/chunk-5AW2HHG6.js.map +0 -1
- package/dist/chunk-DWZLSZDG.js +0 -5664
- package/dist/chunk-DWZLSZDG.js.map +0 -1
- package/dist/chunk-FCMZ7TUQ.js.map +0 -1
- package/dist/chunk-HPLT3XRZ.js.map +0 -1
- package/dist/chunk-JPJVTB45.js.map +0 -1
- package/dist/chunk-KPE3QRPB.js.map +0 -1
- package/dist/chunk-KWXFL4WS.js.map +0 -1
- package/dist/chunk-ND2CWNVG.js.map +0 -1
- package/dist/chunk-PVFKXRID.js.map +0 -1
- package/dist/chunk-R2UMUCVI.js.map +0 -1
- package/dist/chunk-T3GY6IVK.js.map +0 -1
- package/dist/chunk-Z3ELZ77W.js.map +0 -1
- package/dist/comments-panel-HXMWSRAW.js.map +0 -1
- package/dist/directionality-5JLWQGP2.js.map +0 -1
- package/dist/editor-CXkltf1R.d.ts +0 -1886
- package/dist/editor-CgSBFTke.d.cts +0 -1886
- package/dist/emoticons-ZD6ZRIWG.js.map +0 -1
- package/dist/form-dialog-QH6KAERD.js +0 -180
- package/dist/form-dialog-QH6KAERD.js.map +0 -1
- package/dist/html-rules-api-D3fKQi-R.d.cts +0 -40
- package/dist/html-rules-api-D3fKQi-R.d.ts +0 -40
- package/dist/insertdatetime-CRO7TJAQ.js.map +0 -1
- package/dist/nonbreaking-66LFZV2W.js.map +0 -1
- package/dist/paste-office-F3QW4WWO.js.map +0 -1
- package/dist/quickbars-7E2QRS7J.js.map +0 -1
- package/dist/revisionhistory-DXE7KU4R.js.map +0 -1
- package/dist/table-SSNABG5W.js.map +0 -1
- package/dist/visualblocks-6DLBXYOA.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/markdown.ts"],"sourcesContent":["/**\n * Markdown in and out: a separate entry point `@novaprose/core/markdown` (~46 KB gzip with the parser,\n * not part of the core). Only data and functions: the core is imported here for types only.\n *\n * import { markdownToHTML, toMarkdown } from '@novaprose/core/markdown';\n * editor.setContent(markdownToHTML('# Heading'));\n * const md = toMarkdown(editor);\n *\n * Security: Markdown becomes HTML without raw HTML (`html: false`) and then goes through the\n * editor's schema like any content: links, images and CSS are checked there.\n */\nimport MarkdownIt from 'markdown-it';\nimport type { Mark, Node as PMNode } from 'prosemirror-model';\nimport {\n MarkdownSerializer,\n MarkdownSerializerState,\n defaultMarkdownSerializer,\n} from 'prosemirror-markdown';\nimport type { Editor } from './editor';\nimport { codeLanguage } from './code-language';\n\nexport interface MarkdownToHTMLOptions {\n /** Turn addresses like https://… into links (true by default). */\n linkify?: boolean;\n /** A single line break becomes <br> (as in chats). Default false (as in CommonMark). */\n breaks?: boolean;\n}\n\n/**\n * GFM tasks (\"- [ ] item\", \"- [x] done\") → a NovaProse checklist (data-type/data-checked, as in\n * Tiptap). Only in bulleted lists: the editor has no numbered checklists.\n */\nfunction taskLists(md: InstanceType<typeof MarkdownIt>): void {\n md.core.ruler.after('inline', 'nova-task-lists', (state) => {\n const tokens = state.tokens;\n for (let i = 2; i < tokens.length; i++) {\n const inline = tokens[i]!;\n const item = tokens[i - 2]!;\n if (inline.type !== 'inline' || tokens[i - 1]!.type !== 'paragraph_open') continue;\n if (item.type !== 'list_item_open') continue;\n const match = /^\\[([ xX])\\](?:\\s+|$)/.exec(inline.content);\n if (!match) continue;\n let list = -1;\n for (let j = i - 3; j >= 0; j--) {\n if (tokens[j]!.level === item.level - 1 && tokens[j]!.type.endsWith('_list_open')) {\n list = j;\n break;\n }\n }\n if (list < 0 || tokens[list]!.type !== 'bullet_list_open') continue;\n // Strip \"[ ] \" from the start of the item text (it may be split into several text tokens).\n let rest = match[0].length;\n for (const child of inline.children ?? []) {\n if (rest <= 0 || child.type !== 'text') break;\n const cut = Math.min(rest, child.content.length);\n child.content = child.content.slice(cut);\n rest -= cut;\n }\n inline.content = inline.content.slice(match[0].length);\n item.attrSet('data-type', 'taskItem');\n item.attrSet('data-checked', String(match[1] !== ' '));\n tokens[list]!.attrSet('data-type', 'taskList');\n }\n });\n}\n\n/** Markdown (CommonMark plus GFM tables and ~~strikethrough~~) → HTML for `setContent` / `insertContent`. */\nexport function markdownToHTML(markdown: string, options: MarkdownToHTMLOptions = {}): string {\n const md = new MarkdownIt('default', {\n html: false,\n linkify: options.linkify ?? true,\n breaks: options.breaks ?? false,\n });\n taskLists(md);\n // markdown-it ends the code in a block with a service \"\\n\": in the editor it would be an extra empty\n // line at the bottom of the block (and inside a quote it multiplied on every save). The content is escaped,\n // so \"</code></pre>\" can't occur in the code text.\n return md.render(markdown).replace(/\\n<\\/code><\\/pre>/g, '</code></pre>');\n}\n\nconst nodes = defaultMarkdownSerializer.nodes;\n\n/** The same address detector as in markdownToHTML (linkify). */\nconst linkify = new MarkdownIt('default', { linkify: true }).linkify;\n\n/**\n * Text without a link that looks like an address (\"example.com\", \"https://…\") would become a link when\n * the Markdown is read back, so the document would change from save to save. All the punctuation of the\n * address is escaped (`example\\.com`): it reads as the same text, and the detector sees only pieces without dots and \"//\".\n * Only for addresses the author left without a link, a rare case.\n * Found by a property-based test (packages/core/test/markdown.test.ts).\n */\n/** : for an image and for an image with a caption (figure). */\nfunction imageNode(state: MarkdownSerializerState, node: PMNode): void {\n const src = String(node.attrs.src ?? '');\n const alt = state.esc(String(node.attrs.alt ?? ''));\n const title = node.attrs.title ? ` \"${String(node.attrs.title).replace(/\"/g, '\\\\\"')}\"` : '';\n state.write(`]/g, '\\\\$&')}${title})`);\n}\n\n/** How many nodes of the same type stand in a row right before this one (to alternate list markers). */\nfunction siblingsBefore(parent: PMNode, index: number, node: PMNode): number {\n let count = 0;\n for (let i = index - 1; i >= 0 && parent.child(i).type === node.type; i--) count++;\n return count;\n}\n\n/** Characters the serializer escapes: the reader splits the text into pieces at them. */\nconst ESCAPED = /[`*\\\\~[\\]_]/g;\n\n/** Ranges [from, to) of the text that the reader would detect as an address. */\nfunction linkLikeRanges(text: string): [number, number][] {\n const ranges: [number, number][] = [];\n const add = (offset: number, chunk: string) => {\n for (const m of linkify.match(chunk) ?? [])\n ranges.push([offset + m.index, offset + m.lastIndex]);\n };\n add(0, text);\n // An address can \"appear\" in a piece between escaped characters: \"https://a.io_\" → \"…\\_\".\n let start = 0;\n for (const m of text.matchAll(ESCAPED)) {\n add(start, text.slice(start, m.index));\n start = m.index + 1;\n }\n add(start, text.slice(start));\n // markdown-it detects \"scheme://\" inside a word too (\"$https://…\"), with a separate rule.\n for (const m of text.matchAll(/[a-z][a-z\\d+.-]*:\\/\\/\\S*/gi)) {\n ranges.push([m.index, m.index + m[0].length]);\n }\n return ranges.sort((a, b) => a[0] - b[0]);\n}\n\nfunction textNode(state: MarkdownSerializerState, node: PMNode): void {\n const text = node.text ?? '';\n const ranges = node.marks.some((m) => m.type.name === 'link') ? [] : linkLikeRanges(text);\n if (!ranges.length) {\n state.text(text);\n return;\n }\n let last = 0;\n for (const [from, to] of ranges) {\n if (to <= last) continue;\n const begin = Math.max(from, last);\n state.text(text.slice(last, begin));\n // Any ASCII punctuation character can be escaped with a backslash (CommonMark).\n state.write(text.slice(begin, to).replace(/[!-/:-@[-`{-~]/g, '\\\\$&'));\n last = to;\n }\n state.text(text.slice(last));\n}\nconst marks = defaultMarkdownSerializer.marks;\n\n/** Formatting Markdown doesn't have: the text stays, the markup goes. */\nconst plain = { open: '', close: '', mixable: true, expelEnclosingWhitespace: true };\n\n/** Cell text on one line: \"|\" and line breaks are escaped, blocks are joined with a space. */\nfunction cellText(cell: PMNode): string {\n const parts: string[] = [];\n cell.forEach((block) => parts.push(serialize(block).replace(/\\n+/g, ' ').trim()));\n return parts.join(' ').replace(/\\|/g, '\\\\|');\n}\n\nconst serializer: MarkdownSerializer = new MarkdownSerializer(\n {\n ...nodes,\n text: textNode,\n heading(state, node) {\n state.write(`${'#'.repeat(Number(node.attrs.level) || 1)} `);\n state.renderInline(node);\n // \"# Tag #\": in CommonMark trailing \"#\" after a space are an optional closing of the heading\n // and get dropped, so the text would be lost on every save. The last \"#\" is escaped.\n const s = state as unknown as { out: string };\n if (\n /(^|[ \\t])#+$/.test(\n s.out.slice(s.out.lastIndexOf('\\n') + 1).slice(Number(node.attrs.level) + 1),\n )\n ) {\n s.out = `${s.out.slice(0, -1)}\\\\#`;\n }\n state.closeBlock(node);\n },\n code_block(state, node) {\n // From JSON the language can be anything: only a safe name goes into the fence line.\n const language = codeLanguage(node.attrs.language) ?? '';\n // The fence is longer than any run of backticks inside the code.\n const longest = Math.max(2, ...(node.textContent.match(/`+/g) ?? []).map((s) => s.length));\n const fence = '`'.repeat(longest + 1);\n state.write(`${fence}${language}\\n`);\n // An empty block has no empty line inside: otherwise reading it back makes the line content and the block\n // would grow with every save (found by a property-based test).\n // Exactly one \"\\n\" after the content: the reader drops it (see markdownToHTML).\n if (node.textContent) state.text(`${node.textContent}\\n`, false);\n state.write(fence);\n state.closeBlock(node);\n },\n // Adjacent lists of the same type alternate the marker (* / -, 1. / 1)): otherwise reading the Markdown\n // would merge them into one list (found by a property-based test).\n bullet_list(state, node, parent, index) {\n const marker = siblingsBefore(parent, index, node) % 2 ? '-' : '*';\n // A checklist becomes GFM tasks: \"- [ ] item\", \"- [x] done\".\n const box = (i: number) =>\n node.attrs.checklist === true ? `[${node.child(i).attrs.checked ? 'x' : ' '}] ` : '';\n state.renderList(node, ' ', (i) => `${marker} ${box(i)}`);\n },\n ordered_list(state, node, parent, index) {\n const start = (node.attrs.start as number | null) ?? 1;\n const delimiter = siblingsBefore(parent, index, node) % 2 ? ')' : '.';\n const maxW = String(start + node.childCount - 1).length;\n const space = ' '.repeat(maxW + 2);\n state.renderList(node, space, (i) => {\n const n = String(start + i);\n return `${' '.repeat(maxW - n.length)}${n}${delimiter} `;\n });\n },\n image: imageNode,\n // Markdown has no captions: the image, then the caption as a separate paragraph, so the text is kept.\n figure(state, node) {\n if (node.firstChild) imageNode(state, node.firstChild);\n state.closeBlock(node);\n const caption = node.childCount > 1 ? node.child(1) : null;\n if (caption?.content.size) {\n state.renderInline(caption);\n state.closeBlock(caption);\n }\n },\n figcaption() {},\n figure_image() {},\n table(state, node) {\n const rows: string[][] = [];\n node.forEach((row) => {\n const cells: string[] = [];\n row.forEach((cell) => cells.push(cellText(cell)));\n rows.push(cells);\n });\n const width = Math.max(...rows.map((r) => r.length));\n const line = (cells: string[]) =>\n `| ${Array.from({ length: width }, (_, i) => cells[i] ?? '').join(' | ')} |`;\n // In GFM a table always has a header row: take the first one.\n state.write(line(rows[0] ?? []));\n state.ensureNewLine();\n state.write(`| ${Array.from({ length: width }, () => '---').join(' | ')} |`);\n for (const row of rows.slice(1)) {\n state.ensureNewLine();\n state.write(line(row));\n }\n state.closeBlock(node);\n },\n // Cells and rows are serialized by table.\n table_row() {},\n table_cell() {},\n table_header() {},\n // Plugin nodes.\n mergetag(state, node) {\n state.write(`{{${String(node.attrs.key ?? '')}}}`);\n },\n mention(state, node) {\n state.text(`@${String(node.attrs.name ?? '')}`);\n },\n media(state, node) {\n const src = String(node.attrs.src ?? '');\n state.write(\n `[${state.esc(String(node.attrs.title || src))}](${src.replace(/[()]/g, '\\\\$&')})`,\n );\n state.closeBlock(node);\n },\n // A page's card: a link to it.\n link_card(state, node) {\n const src = String(node.attrs.href ?? '').trim();\n if (/^https?:\\/\\/\\S+$/i.test(src)) {\n const text = state.esc(String(node.attrs.title || src));\n state.write(`[${text}](${src.replace(/[()]/g, '\\\\$&')})`);\n }\n state.closeBlock(node);\n },\n // An embedded page: a link to it (Markdown has no frames).\n pageembed(state, node) {\n const src = String(node.attrs.src ?? '').trim();\n if (/^https?:\\/\\/\\S+$/i.test(src)) {\n const text = state.esc(String(node.attrs.title || src));\n state.write(`[${text}](${src.replace(/[()]/g, '\\\\$&')})`);\n }\n state.closeBlock(node);\n },\n anchor() {},\n // Elements from extendedValidElements / customElements: their text stays in Markdown.\n html_block(state, node) {\n state.renderContent(node);\n },\n html_textblock(state, node) {\n state.renderInline(node);\n state.closeBlock(node);\n },\n html_inline_atom() {},\n pagebreak(state, node) {\n state.closeBlock(node);\n },\n // Formulas go in dollars, as in most dialects (GitHub, Obsidian, Pandoc).\n math_inline(state, node) {\n state.write(`$${String(node.attrs.latex ?? '')}$`);\n },\n math_block(state, node) {\n state.write(`$$\\n${String(node.attrs.latex ?? '')}\\n$$`);\n state.closeBlock(node);\n },\n // The table of contents is built from headings: in Markdown, readers (and sites) build it themselves.\n toc() {},\n // Markdown has no collapsible block: the title becomes a paragraph, the content stays as is.\n details(state, node) {\n state.renderContent(node);\n },\n details_summary(state, node) {\n state.renderInline(node);\n state.closeBlock(node);\n },\n },\n {\n ...marks,\n bold: marks.strong!,\n italic: marks.em!,\n strike: { open: '~~', close: '~~', mixable: true, expelEnclosingWhitespace: true },\n link: {\n // Italic/bold may wrap a link entirely: \"*text [link](url)*\". Otherwise the formatting\n // closes before the link, and Markdown doesn't count a closing after a space.\n mixable: true,\n open: '[',\n close: (_state: MarkdownSerializerState, mark: Mark) => {\n const href = String(mark.attrs.href ?? '').replace(/[()]/g, '\\\\$&');\n const title = mark.attrs.title ? ` \"${String(mark.attrs.title).replace(/\"/g, '\\\\\"')}\"` : '';\n return `](${href}${title})`;\n },\n },\n underline: plain,\n subscript: plain,\n superscript: plain,\n color: plain,\n background: plain,\n font_family: plain,\n font_size: plain,\n span_class: plain,\n html_inline: plain,\n comment: plain,\n suggestion_insert: plain,\n suggestion_delete: plain,\n },\n { strict: false },\n);\n\n/**\n * A document → Markdown (CommonMark plus GFM tables and strikethrough). Formatting Markdown doesn't\n * have (underline, color, font, page break) is dropped and the text is kept. Template variables\n * become `{{key}}`, mentions `@Name`.\n */\nexport function toMarkdown(source: Editor | PMNode): string {\n const doc = 'view' in source ? source.view.state.doc : source;\n return serialize(doc).trim();\n}\n\n/**\n * Escaping at the start of a line in prosemirror-markdown is incomplete: \"0)\", \"2025.\" at the end of a line, \"+\" and\n * a line of \"=\" (a heading underline) would change the structure when read back: a paragraph became a list\n * or a heading, text disappeared. Our own subclass rather than a prototype patch: other code using the\n * same library isn't affected. Found by a property-based test.\n */\n// The constructor and `out` are marked internal in the library's types; at runtime they are public\n// (MarkdownSerializer.serialize itself uses them that way).\ntype StateConstructor = new (\n nodes: MarkdownSerializer['nodes'],\n marks: MarkdownSerializer['marks'],\n options: { tightLists?: boolean },\n) => MarkdownSerializerState & { out: string };\nconst BaseState = MarkdownSerializerState as unknown as StateConstructor;\n\nclass NovaMarkdownState extends BaseState {\n override esc(str: string, startOfLine = false): string {\n // The library treats only the start of a block as the start of a line; a line after a break (Shift+Enter)\n // is a start too: otherwise \"#\" there turned the rest of the paragraph into a heading.\n const self = this as unknown as { out: string; delim: string };\n const lastLine = self.out.slice(self.out.lastIndexOf('\\n') + 1);\n const lineStart =\n startOfLine || lastLine === self.delim || lastLine.trim() === self.delim.trim();\n let out = super.esc(str, lineStart);\n // A regular list item that starts with \"[ ]\" / \"[x]\" must not become a task when read back.\n if (/^\\s*(?:[*+-]|\\d{1,9}[.)])\\s$/.test(lastLine)) out = out.replace(/^\\[([ xX])\\]/, '\\\\[$1]');\n if (lineStart) {\n out = out\n .replace(/^(\\s*\\d{1,9})([.)])(?=\\s|$)/, '$1\\\\$2')\n .replace(/^(\\s*)\\+(?=\\s|$)/, '$1\\\\+')\n .replace(/^(\\s*)(=+)(\\s*)$/, '$1\\\\$2$3');\n }\n return out;\n }\n}\n\nfunction serialize(node: PMNode): string {\n const state = new NovaMarkdownState(serializer.nodes, serializer.marks, { tightLists: true });\n state.renderContent(\n node.type.name === 'doc' ? node : node.type.schema.topNodeType.create(null, node),\n );\n return state.out;\n}\n"],"mappings":";;;;;AAWA,OAAO,gBAAgB;AAEvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAeP,SAAS,UAAU,IAA2C;AAC5D,KAAG,KAAK,MAAM,MAAM,UAAU,mBAAmB,CAAC,UAAU;AAC1D,UAAM,SAAS,MAAM;AACrB,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,YAAM,SAAS,OAAO,CAAC;AACvB,YAAM,OAAO,OAAO,IAAI,CAAC;AACzB,UAAI,OAAO,SAAS,YAAY,OAAO,IAAI,CAAC,EAAG,SAAS,iBAAkB;AAC1E,UAAI,KAAK,SAAS,iBAAkB;AACpC,YAAM,QAAQ,wBAAwB,KAAK,OAAO,OAAO;AACzD,UAAI,CAAC,MAAO;AACZ,UAAI,OAAO;AACX,eAAS,IAAI,IAAI,GAAG,KAAK,GAAG,KAAK;AAC/B,YAAI,OAAO,CAAC,EAAG,UAAU,KAAK,QAAQ,KAAK,OAAO,CAAC,EAAG,KAAK,SAAS,YAAY,GAAG;AACjF,iBAAO;AACP;AAAA,QACF;AAAA,MACF;AACA,UAAI,OAAO,KAAK,OAAO,IAAI,EAAG,SAAS,mBAAoB;AAE3D,UAAI,OAAO,MAAM,CAAC,EAAE;AACpB,iBAAW,SAAS,OAAO,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W,KAAK,IAAI,MAAM,KAAK,IAAI,YAAY,IAAI,IAAI,CAAC;AAC9D,UAAM,YACJ,eAAe,aAAa,KAAK,SAAS,SAAS,KAAK,MAAM,KAAK,MAAM,KAAK;AAChF,QAAI,MAAM,MAAM,IAAI,KAAK,SAAS;AAElC,QAAI,+BAA+B,KAAK,QAAQ,EAAG,OAAM,IAAI,QAAQ,gBAAgB,QAAQ;AAC7F,QAAI,WAAW;AACb,YAAM,IACH,QAAQ,+BAA+B,QAAQ,EAC/C,QAAQ,oBAAoB,OAAO,EACnC,QAAQ,oBAAoB,UAAU;AAAA,IAC3C;AACA,WAAO;AAAA,EACT;AACF;AAEA,SAAS,UAAU,MAAsB;AACvC,QAAM,QAAQ,IAAI,kBAAkB,WAAW,OAAO,WAAW,OAAO,EAAE,YAAY,KAAK,CAAC;AAC5F,QAAM;AAAA,IACJ,KAAK,KAAK,SAAS,QAAQ,OAAO,KAAK,KAAK,OAAO,YAAY,OAAO,MAAM,IAAI;AAAA,EAClF;AACA,SAAO,MAAM;AACf;","names":[]}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pickLabels
|
|
3
|
+
} from "./chunk-DEYYVZ7O.js";
|
|
4
|
+
import {
|
|
5
|
+
definePlugin
|
|
6
|
+
} from "./chunk-V7WUHUHM.js";
|
|
7
|
+
|
|
8
|
+
// src/plugins/mergetags.ts
|
|
9
|
+
import { Plugin as PMPlugin } from "prosemirror-state";
|
|
10
|
+
var LABELS = {
|
|
11
|
+
en: {
|
|
12
|
+
insert: "Insert variable",
|
|
13
|
+
search: "Variables",
|
|
14
|
+
empty: "No variables found",
|
|
15
|
+
unknown: "Unknown variable"
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var KEY_RE = /^[\w.:-]{1,100}$/;
|
|
19
|
+
var ATTR_RE = /^data-[a-z0-9-]{1,40}$/;
|
|
20
|
+
function optionsOf(editor) {
|
|
21
|
+
return editor.options.pluginOptions?.mergetags ?? {};
|
|
22
|
+
}
|
|
23
|
+
function attributeOf(editor) {
|
|
24
|
+
const attribute = optionsOf(editor).attribute ?? "data-mergetag";
|
|
25
|
+
if (ATTR_RE.test(attribute)) return attribute;
|
|
26
|
+
console.warn(
|
|
27
|
+
`[nova] mergetags: attribute "${attribute}" must look like data-name; using data-mergetag`
|
|
28
|
+
);
|
|
29
|
+
return "data-mergetag";
|
|
30
|
+
}
|
|
31
|
+
var isGroup = (entry) => Array.isArray(entry.items);
|
|
32
|
+
function flatList(editor) {
|
|
33
|
+
return (optionsOf(editor).list ?? []).flatMap(
|
|
34
|
+
(entry) => isGroup(entry) ? entry.items : [entry]
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
function labelFor(editor, key) {
|
|
38
|
+
return flatList(editor).find((tag) => tag.key === key)?.label;
|
|
39
|
+
}
|
|
40
|
+
function buildNodes(editor) {
|
|
41
|
+
const attribute = attributeOf(editor);
|
|
42
|
+
return {
|
|
43
|
+
mergetag: {
|
|
44
|
+
group: "inline",
|
|
45
|
+
inline: true,
|
|
46
|
+
atom: true,
|
|
47
|
+
selectable: true,
|
|
48
|
+
draggable: true,
|
|
49
|
+
// The chip's own style (color, background, weight) is its look, not the formatting of the text around it.
|
|
50
|
+
ignoreStyles: true,
|
|
51
|
+
attrs: { key: {}, label: { default: "" } },
|
|
52
|
+
parseDOM: [
|
|
53
|
+
{
|
|
54
|
+
tag: `span[${attribute}]`,
|
|
55
|
+
// Above marks and styles: a variable is a whole node, not a span with formatting.
|
|
56
|
+
priority: 60,
|
|
57
|
+
getAttrs: (dom) => {
|
|
58
|
+
const el = dom;
|
|
59
|
+
const key = el.getAttribute(attribute) ?? "";
|
|
60
|
+
if (!KEY_RE.test(key)) return false;
|
|
61
|
+
return { key, label: labelFor(editor, key) ?? el.textContent?.trim() ?? key };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
// The document may come from JSON: the key is checked on output too.
|
|
66
|
+
toDOM: (node) => {
|
|
67
|
+
const key = KEY_RE.test(node.attrs.key) ? node.attrs.key : "";
|
|
68
|
+
const label = node.attrs.label == null || node.attrs.label === "" ? key : String(node.attrs.label);
|
|
69
|
+
return ["span", { [attribute]: key, contenteditable: "false" }, label];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
var MergeTagView = class {
|
|
75
|
+
constructor(node, editor, unknownTitle) {
|
|
76
|
+
this.node = node;
|
|
77
|
+
this.editor = editor;
|
|
78
|
+
this.unknownTitle = unknownTitle;
|
|
79
|
+
this.dom = document.createElement("span");
|
|
80
|
+
this.dom.className = "nova-mergetag";
|
|
81
|
+
this.dom.contentEditable = "false";
|
|
82
|
+
this.render();
|
|
83
|
+
}
|
|
84
|
+
node;
|
|
85
|
+
editor;
|
|
86
|
+
unknownTitle;
|
|
87
|
+
dom;
|
|
88
|
+
render() {
|
|
89
|
+
const key = this.node.attrs.key;
|
|
90
|
+
const known = labelFor(this.editor, key);
|
|
91
|
+
this.dom.textContent = known ?? (this.node.attrs.label || key);
|
|
92
|
+
this.dom.dataset.key = key;
|
|
93
|
+
const list = optionsOf(this.editor).list;
|
|
94
|
+
const unknown = !!list?.length && known === void 0;
|
|
95
|
+
this.dom.classList.toggle("is-unknown", unknown);
|
|
96
|
+
this.dom.title = unknown ? `${this.unknownTitle}: ${key}` : key;
|
|
97
|
+
}
|
|
98
|
+
update(node) {
|
|
99
|
+
if (node.type !== this.node.type) return false;
|
|
100
|
+
this.node = node;
|
|
101
|
+
this.render();
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
selectNode() {
|
|
105
|
+
this.dom.classList.add("is-selected");
|
|
106
|
+
}
|
|
107
|
+
deselectNode() {
|
|
108
|
+
this.dom.classList.remove("is-selected");
|
|
109
|
+
}
|
|
110
|
+
stopEvent() {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
ignoreMutation() {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var mergetags_default = definePlugin({
|
|
118
|
+
name: "mergetags",
|
|
119
|
+
toolbar: "mergetags",
|
|
120
|
+
nodes: buildNodes,
|
|
121
|
+
prosemirrorPlugins: (editor) => {
|
|
122
|
+
const labels = pickLabels(editor, "mergetags", LABELS);
|
|
123
|
+
return [
|
|
124
|
+
new PMPlugin({
|
|
125
|
+
props: {
|
|
126
|
+
nodeViews: {
|
|
127
|
+
mergetag: (node, _view) => new MergeTagView(node, editor, labels.unknown)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
];
|
|
132
|
+
},
|
|
133
|
+
load: () => import("./mergetags-ui-HS3Q2R36.js")
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
export {
|
|
137
|
+
LABELS,
|
|
138
|
+
optionsOf,
|
|
139
|
+
isGroup,
|
|
140
|
+
flatList,
|
|
141
|
+
mergetags_default
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=chunk-C326LHHU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugins/mergetags.ts"],"sourcesContent":["import type { Node as PMNode, NodeSpec } from 'prosemirror-model';\nimport { Plugin as PMPlugin } from 'prosemirror-state';\nimport type { EditorView } from 'prosemirror-view';\nimport type { Editor } from '../editor';\nimport { definePlugin } from '../plugins';\nimport { pickLabels } from './shared';\n\n/**\n * The mergetags plugin: template variables (\"Client name\", \"Order number\") that your server replaces\n * with values when printing or sending. In the text it is a non-editable chip, in HTML\n * `<span data-mergetag=\"client\">Client name</span>` (the attribute name can be changed).\n *\n * `plugins: ['mergetags']`, the list in `pluginOptions.mergetags.list`. Insert them with the\n * `mergetags` button or by typing `{{`. Variables missing from the list aren't lost: they show by key.\n * This part is the node and how it looks in the editor; the menu and typing `{{` are in mergetags-ui.ts.\n */\n\nexport interface MergeTag {\n /** The key your server sees: 'client', 'order.number'. */\n key: string;\n /** The label in the editor: 'Client name'. */\n label: string;\n}\n\nexport interface MergeTagGroup {\n title: string;\n items: MergeTag[];\n}\n\nexport interface MergeTagsOptions {\n /** Variables, as a list or in groups. */\n list?: (MergeTag | MergeTagGroup)[];\n /** The HTML attribute holding the key. Default 'data-mergetag'. */\n attribute?: string;\n}\n\nexport const LABELS = {\n en: {\n insert: 'Insert variable',\n search: 'Variables',\n empty: 'No variables found',\n unknown: 'Unknown variable',\n },\n};\n\n/** A key without spaces and quotes: it goes into an attribute and to your server. */\nconst KEY_RE = /^[\\w.:-]{1,100}$/;\n/** The attribute: only data-* (it can't be named onclick or href). */\nconst ATTR_RE = /^data-[a-z0-9-]{1,40}$/;\n\nexport function optionsOf(editor: Editor): MergeTagsOptions {\n return (editor.options.pluginOptions?.mergetags as MergeTagsOptions | undefined) ?? {};\n}\n\nfunction attributeOf(editor: Editor): string {\n const attribute = optionsOf(editor).attribute ?? 'data-mergetag';\n if (ATTR_RE.test(attribute)) return attribute;\n console.warn(\n `[nova] mergetags: attribute \"${attribute}\" must look like data-name; using data-mergetag`,\n );\n return 'data-mergetag';\n}\n\nexport const isGroup = (entry: MergeTag | MergeTagGroup): entry is MergeTagGroup =>\n Array.isArray((entry as MergeTagGroup).items);\n\nexport function flatList(editor: Editor): MergeTag[] {\n return (optionsOf(editor).list ?? []).flatMap((entry) =>\n isGroup(entry) ? entry.items : [entry],\n );\n}\n\nfunction labelFor(editor: Editor, key: string): string | undefined {\n return flatList(editor).find((tag) => tag.key === key)?.label;\n}\n\nfunction buildNodes(editor: Editor): Record<string, NodeSpec> {\n const attribute = attributeOf(editor);\n return {\n mergetag: {\n group: 'inline',\n inline: true,\n atom: true,\n selectable: true,\n draggable: true,\n // The chip's own style (color, background, weight) is its look, not the formatting of the text around it.\n ignoreStyles: true,\n attrs: { key: {}, label: { default: '' } },\n parseDOM: [\n {\n tag: `span[${attribute}]`,\n // Above marks and styles: a variable is a whole node, not a span with formatting.\n priority: 60,\n getAttrs: (dom) => {\n const el = dom as HTMLElement;\n const key = el.getAttribute(attribute) ?? '';\n if (!KEY_RE.test(key)) return false;\n return { key, label: labelFor(editor, key) ?? el.textContent?.trim() ?? key };\n },\n },\n ],\n // The document may come from JSON: the key is checked on output too.\n toDOM: (node) => {\n const key = KEY_RE.test(node.attrs.key as string) ? (node.attrs.key as string) : '';\n // JSON comes from outside: the label may be a number or null, it is output as a string.\n const label =\n node.attrs.label == null || node.attrs.label === '' ? key : String(node.attrs.label);\n return ['span', { [attribute]: key, contenteditable: 'false' }, label];\n },\n },\n };\n}\n\n/** The view in the editor: a chip with the label from the list (the label in the HTML may be outdated). */\nclass MergeTagView {\n readonly dom: HTMLElement;\n\n constructor(\n private node: PMNode,\n private readonly editor: Editor,\n private readonly unknownTitle: string,\n ) {\n this.dom = document.createElement('span');\n this.dom.className = 'nova-mergetag';\n this.dom.contentEditable = 'false';\n this.render();\n }\n\n private render(): void {\n const key = this.node.attrs.key as string;\n const known = labelFor(this.editor, key);\n this.dom.textContent = known ?? ((this.node.attrs.label as string) || key);\n this.dom.dataset.key = key;\n const list = optionsOf(this.editor).list;\n // The key isn't in the list: highlighted but not removed, so the template loses no data.\n const unknown = !!list?.length && known === undefined;\n this.dom.classList.toggle('is-unknown', unknown);\n this.dom.title = unknown ? `${this.unknownTitle}: ${key}` : key;\n }\n\n update(node: PMNode): boolean {\n if (node.type !== this.node.type) return false;\n this.node = node;\n this.render();\n return true;\n }\n\n selectNode(): void {\n this.dom.classList.add('is-selected');\n }\n\n deselectNode(): void {\n this.dom.classList.remove('is-selected');\n }\n\n stopEvent(): boolean {\n return false;\n }\n\n ignoreMutation(): boolean {\n return true;\n }\n}\n\nexport default definePlugin({\n name: 'mergetags',\n toolbar: 'mergetags',\n nodes: buildNodes,\n prosemirrorPlugins: (editor) => {\n const labels = pickLabels(editor, 'mergetags', LABELS);\n return [\n new PMPlugin({\n props: {\n nodeViews: {\n mergetag: (node: PMNode, _view: EditorView) =>\n new MergeTagView(node, editor, labels.unknown),\n },\n },\n }),\n ];\n },\n load: ()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AAM,QAAO;AACzC,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,WAAO;AAAA,EACT;AAAA,EAEA,aAAmB;AACjB,SAAK,IAAI,UAAU,IAAI,aAAa;AAAA,EACtC;AAAA,EAEA,eAAqB;AACnB,SAAK,IAAI,UAAU,OAAO,aAAa;AAAA,EACzC;AAAA,EAEA,YAAqB;AACnB,WAAO;AAAA,EACT;AAAA,EAEA,iBAA0B;AACxB,WAAO;AAAA,EACT;AACF;AAEA,IAAO,oBAAQ,aAAa;AAAA,EAC1B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,oBAAoB,CAAC,WAAW;AAC9B,UAAM,SAAS,WAAW,QAAQ,aAAa,MAAM;AACrD,WAAO;AAAA,MACL,IAAI,SAAS;AAAA,QACX,OAAO;AAAA,UACL,WAAW;AAAA,YACT,UAAU,CAAC,MAAc,UACvB,IAAI,aAAa,MAAM,QAAQ,OAAO,OAAO;AAAA,UACjD;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EACA,MAAM,MAAM,OAAO,4BAAgB;AACrC,CAAC;","names":[]}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
activeElement,
|
|
3
3
|
h,
|
|
4
4
|
logicalKey
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-QU3KXMYT.js";
|
|
6
6
|
|
|
7
7
|
// src/i18n/en.ts
|
|
8
8
|
var en = {
|
|
@@ -33,6 +33,8 @@ var en = {
|
|
|
33
33
|
alignJustify: "Justify",
|
|
34
34
|
blockquote: "Quote",
|
|
35
35
|
codeBlock: "Code block",
|
|
36
|
+
moveBlockUp: "Move block up",
|
|
37
|
+
moveBlockDown: "Move block down",
|
|
36
38
|
horizontalRule: "Horizontal line",
|
|
37
39
|
clearFormatting: "Clear formatting",
|
|
38
40
|
more: "More",
|
|
@@ -102,8 +104,14 @@ var en = {
|
|
|
102
104
|
"image.caption": "Caption",
|
|
103
105
|
"image.captionPlaceholder": "Add a caption\u2026",
|
|
104
106
|
"status.words": "{count} words",
|
|
107
|
+
"announce.on": "{name} on",
|
|
108
|
+
"announce.off": "{name} off",
|
|
105
109
|
"status.resize": "Resize editor",
|
|
106
110
|
"dialog.browse": "Browse",
|
|
111
|
+
"dialog.dropFiles": "Drop files here or",
|
|
112
|
+
"dialog.fileType": "This file type is not allowed",
|
|
113
|
+
"dialog.fileTooLarge": "The file is too large",
|
|
114
|
+
"dialog.removeFile": "Remove",
|
|
107
115
|
pasteAsText: "Paste as text",
|
|
108
116
|
"menu.label": "Menu",
|
|
109
117
|
"menu.file": "File",
|
|
@@ -112,6 +120,7 @@ var en = {
|
|
|
112
120
|
"menu.insert": "Insert",
|
|
113
121
|
"menu.format": "Format",
|
|
114
122
|
"menu.table": "Table",
|
|
123
|
+
"menu.tools": "Tools",
|
|
115
124
|
"menu.help": "Help",
|
|
116
125
|
selectAll: "Select all",
|
|
117
126
|
print: "Print",
|
|
@@ -202,15 +211,46 @@ function flatten(labels) {
|
|
|
202
211
|
}
|
|
203
212
|
return out;
|
|
204
213
|
}
|
|
214
|
+
var loaders = {};
|
|
215
|
+
var loading = {};
|
|
216
|
+
function install(lang, messages, below = false) {
|
|
217
|
+
userPacks[lang] = below ? { ...messages, ...userPacks[lang] } : { ...userPacks[lang], ...messages };
|
|
218
|
+
builtin[lang] = { ...en, ...userPacks[lang] };
|
|
219
|
+
}
|
|
205
220
|
function registerLanguage(code, messages) {
|
|
206
221
|
const lang = code.toLowerCase();
|
|
207
|
-
|
|
208
|
-
|
|
222
|
+
if (typeof messages === "function") loaders[lang] = messages;
|
|
223
|
+
else install(lang, messages);
|
|
224
|
+
}
|
|
225
|
+
function hasLanguage(code) {
|
|
226
|
+
const lang = code.toLowerCase();
|
|
227
|
+
return lang in builtin || lang.split("-")[0] in builtin;
|
|
228
|
+
}
|
|
229
|
+
function loadLanguage(code) {
|
|
230
|
+
const lang = code.toLowerCase();
|
|
231
|
+
const base = lang.split("-")[0];
|
|
232
|
+
const key = lang in loaders ? lang : base in loaders ? base : null;
|
|
233
|
+
if (!key) return Promise.resolve(hasLanguage(lang));
|
|
234
|
+
return loading[key] ??= loaders[key]().then(
|
|
235
|
+
(module) => {
|
|
236
|
+
install(
|
|
237
|
+
key,
|
|
238
|
+
module.default ?? module,
|
|
239
|
+
true
|
|
240
|
+
);
|
|
241
|
+
return true;
|
|
242
|
+
},
|
|
243
|
+
(error) => {
|
|
244
|
+
loading[key] = void 0;
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
);
|
|
209
248
|
}
|
|
210
249
|
function registerPluginMessages(namespace, dict) {
|
|
211
|
-
const
|
|
212
|
-
for (const [lang, labels] of Object.entries(dict))
|
|
213
|
-
|
|
250
|
+
const packs = pluginPacks[namespace] ??= {};
|
|
251
|
+
for (const [lang, labels] of Object.entries(dict)) {
|
|
252
|
+
if (labels) packs[lang] = { ...packs[lang], ...flatten(labels) };
|
|
253
|
+
}
|
|
214
254
|
}
|
|
215
255
|
function getPluginMessages() {
|
|
216
256
|
return pluginPacks;
|
|
@@ -223,7 +263,7 @@ function createTranslator(language = "en", overrides = {}) {
|
|
|
223
263
|
if (pack === en && base !== "en" && !warned.has(base)) {
|
|
224
264
|
warned.add(base);
|
|
225
265
|
console.warn(
|
|
226
|
-
`[nova] language "${language}" is not registered, using English. import pack from '@novaprose/core/i18n/${base}'; registerLanguage('${base}', pack);`
|
|
266
|
+
code in loaders || base in loaders ? `[nova] language "${language}" is not loaded yet, using English. Load it before creating the editor: await loadLanguage('${language}');` : `[nova] language "${language}" is not registered, using English. import pack from '@novaprose/core/i18n/${base}'; registerLanguage('${base}', pack);`
|
|
227
267
|
);
|
|
228
268
|
}
|
|
229
269
|
const messages = { ...en, ...pack, ...overrides };
|
|
@@ -341,6 +381,8 @@ function openSymbolDialog(editor, title, build) {
|
|
|
341
381
|
export {
|
|
342
382
|
en,
|
|
343
383
|
registerLanguage,
|
|
384
|
+
hasLanguage,
|
|
385
|
+
loadLanguage,
|
|
344
386
|
getPluginMessages,
|
|
345
387
|
createTranslator,
|
|
346
388
|
pickLabels,
|
|
@@ -348,4 +390,4 @@ export {
|
|
|
348
390
|
symbolPanel,
|
|
349
391
|
openSymbolDialog
|
|
350
392
|
};
|
|
351
|
-
//# sourceMappingURL=chunk-
|
|
393
|
+
//# sourceMappingURL=chunk-DEYYVZ7O.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/i18n/en.ts","../src/i18n/index.ts","../src/plugins/shared.ts"],"sourcesContent":["/** English UI strings: the default language and the reference set of keys for other languages. */\nexport const en = {\n 'toolbar.label': 'Formatting',\n 'toolbar.options': 'options',\n 'editor.label': 'Rich text editor',\n 'editor.required': 'Please fill in this field.',\n\n undo: 'Undo',\n redo: 'Redo',\n bold: 'Bold',\n italic: 'Italic',\n underline: 'Underline',\n strike: 'Strikethrough',\n code: 'Inline code',\n subscript: 'Subscript',\n superscript: 'Superscript',\n link: 'Link',\n unlink: 'Remove link',\n image: 'Image',\n bulletList: 'Bulleted list',\n orderedList: 'Numbered list',\n indent: 'Increase indent',\n outdent: 'Decrease indent',\n align: 'Alignment',\n alignLeft: 'Align left',\n alignCenter: 'Align center',\n alignRight: 'Align right',\n alignJustify: 'Justify',\n blockquote: 'Quote',\n codeBlock: 'Code block',\n moveBlockUp: 'Move block up',\n moveBlockDown: 'Move block down',\n horizontalRule: 'Horizontal line',\n clearFormatting: 'Clear formatting',\n more: 'More',\n moreFormats: 'More formatting',\n\n blocks: 'Text style',\n styles: 'Formats',\n 'styles.headings': 'Headings',\n 'styles.inline': 'Inline',\n 'styles.blocks': 'Blocks',\n 'styles.align': 'Align',\n paragraph: 'Paragraph',\n h1: 'Heading 1',\n h2: 'Heading 2',\n h3: 'Heading 3',\n h4: 'Heading 4',\n h5: 'Heading 5',\n h6: 'Heading 6',\n\n fontFamily: 'Font',\n fontSize: 'Font size',\n lineHeight: 'Line height',\n default: 'Default',\n textColor: 'Text color',\n backgroundColor: 'Highlight color',\n removeColor: 'Remove color',\n customColor: 'Custom color',\n\n 'dialog.cancel': 'Cancel',\n 'dialog.save': 'Save',\n 'dialog.insert': 'Insert',\n 'dialog.close': 'Close',\n 'dialog.required': 'This field is required',\n 'dialog.invalid': 'Check the format',\n\n 'link.title': 'Insert link',\n 'link.editTitle': 'Edit link',\n 'link.url': 'URL',\n 'link.text': 'Text to display',\n 'link.tooltip': 'Title (tooltip)',\n 'link.newTab': 'Open in new tab',\n 'link.open': 'Open link',\n 'link.edit': 'Edit link',\n 'link.copy': 'Copy link',\n 'link.copied': 'Link copied',\n 'link.invalid': 'This URL is not allowed',\n\n 'image.title': 'Insert image',\n 'image.url': 'Image URL',\n 'image.alt': 'Alternative text',\n 'image.altHint': 'Describe the image for people using screen readers',\n 'image.upload': 'Upload',\n 'image.drop': 'Drop an image here or click to choose',\n 'image.uploading': 'Uploading image…',\n 'image.uploadFailed': 'Image upload failed',\n 'image.retry': 'Retry',\n 'image.retrying': 'Connection problem — retrying the upload…',\n 'image.invalid': 'This image URL is not allowed',\n 'image.or': 'or',\n 'image.toolbar': 'Image options',\n 'image.alignLeft': 'Float left',\n 'image.alignCenter': 'Center',\n 'image.alignRight': 'Float right',\n 'image.editAlt': 'Alternative text',\n 'image.size': 'Size',\n 'image.sizeSmall': 'Small (25%)',\n 'image.sizeMedium': 'Medium (50%)',\n 'image.sizeLarge': 'Large (75%)',\n 'image.sizeFull': 'Full width',\n 'image.sizeOriginal': 'Original size',\n 'image.delete': 'Remove image',\n 'image.caption': 'Caption',\n 'image.captionPlaceholder': 'Add a caption…',\n\n 'status.words': '{count} words',\n 'announce.on': '{name} on',\n 'announce.off': '{name} off',\n 'status.resize': 'Resize editor',\n 'dialog.browse': 'Browse',\n 'dialog.dropFiles': 'Drop files here or',\n 'dialog.fileType': 'This file type is not allowed',\n 'dialog.fileTooLarge': 'The file is too large',\n 'dialog.removeFile': 'Remove',\n\n pasteAsText: 'Paste as text',\n\n 'menu.label': 'Menu',\n 'menu.file': 'File',\n 'menu.edit': 'Edit',\n 'menu.view': 'View',\n 'menu.insert': 'Insert',\n 'menu.format': 'Format',\n 'menu.table': 'Table',\n 'menu.tools': 'Tools',\n 'menu.help': 'Help',\n selectAll: 'Select all',\n print: 'Print',\n 'table.rows': 'Rows',\n 'table.cols': 'Columns',\n 'table.invalidSize': 'Enter a number from 1 to 50',\n\n 'quickbars.selection': 'Quick formatting',\n 'quickbars.insert': 'Quick insert',\n\n 'search.title': 'Find and replace',\n 'search.find': 'Find',\n 'search.replace': 'Replace with',\n 'search.next': 'Next match',\n 'search.prev': 'Previous match',\n 'search.replaceOne': 'Replace',\n 'search.replaceAll': 'Replace all',\n 'search.matchCase': 'Match case',\n 'search.wholeWord': 'Whole words only',\n 'search.count': '{current} of {total}',\n 'search.none': 'No results',\n\n fullscreen: 'Fullscreen',\n preview: 'Preview',\n sourceCode: 'Source code',\n help: 'Keyboard shortcuts',\n 'help.formatting': 'Text formatting',\n 'help.blocks': 'Paragraphs and lists',\n 'help.editing': 'Editing',\n 'help.navigation': 'Navigation',\n 'help.slash': 'Insert block (slash commands)',\n 'help.toMenubar': 'Move to the menu bar',\n 'help.toToolbar': 'Move to the toolbar',\n 'help.toContextToolbar': 'Move to the image/table toolbar',\n 'help.toEditor': 'Back to the text',\n 'help.nextCell': 'Next table cell',\n\n table: 'Table',\n 'table.insert': 'Insert table',\n 'table.size': '{rows} × {cols}',\n 'table.toolbar': 'Table options',\n 'table.rowBefore': 'Insert row above',\n 'table.rowAfter': 'Insert row below',\n 'table.rowDelete': 'Delete row',\n 'table.colBefore': 'Insert column left',\n 'table.colAfter': 'Insert column right',\n 'table.colDelete': 'Delete column',\n 'table.merge': 'Merge cells',\n 'table.split': 'Split cell',\n 'table.rowHeader': 'Header row',\n 'table.colHeader': 'Header column',\n 'table.cellBackground': 'Cell background',\n 'table.delete': 'Delete table',\n 'table.sort': 'Sort',\n 'table.sortAsc': 'Sort A → Z, 1 → 9',\n 'table.sortDesc': 'Sort Z → A, 9 → 1',\n 'table.props': 'Table properties',\n 'table.style': 'Style',\n 'table.styleDefault': 'Default',\n 'table.width': 'Width',\n 'table.widthHint': 'For example 100% or 600px. Leave empty to fit the content.',\n 'table.invalidWidth': 'Enter a width such as 100% or 600px',\n 'table.align': 'Alignment on the page',\n 'table.alignDefault': 'Default',\n 'table.alignCenter': 'Center',\n 'table.alignRight': 'Right',\n 'table.cellProps': 'Cell properties',\n 'table.valign': 'Vertical alignment',\n 'table.valignTop': 'Top',\n 'table.valignMiddle': 'Middle',\n 'table.valignBottom': 'Bottom',\n 'table.cellType': 'Cell type',\n 'table.cellData': 'Data cell',\n 'table.cellHeader': 'Header cell',\n 'table.colWidth': 'Column width, px',\n 'table.colWidthHint': 'Leave empty to fit the content.',\n 'table.invalidColWidth': 'Enter a number from 24 to 4000',\n\n 'slash.label': 'Commands',\n 'slash.empty': 'No matching commands',\n} as const;\n\nexport type MessageKey = keyof typeof en;\nexport type Messages = Record<MessageKey, string>;\n","import { en, type MessageKey, type Messages } from './en';\n\nexport type { MessageKey, Messages };\nexport { en };\n\n/**\n * Plugin strings: `<plugin>.<key>` ('comments.reply', 'anchor.title'). Plugins load lazily, so their\n * strings live in the plugin and are registered when it loads (registerPluginMessages), but they are\n * translated by the same system as the core: registerLanguage and the `translations` option see them.\n */\nexport type PluginMessageKey = `${string}.${string}`;\n\n/**\n * A language pack or individual overrides: core strings (with type hints) and plugin strings.\n * Missing keys fall back to English.\n */\nexport type LanguagePack = Partial<Messages> & { [key: PluginMessageKey]: string };\n\n/** Packs passed through registerLanguage: only what the user gave (without en mixed in). */\nconst userPacks: Record<string, LanguagePack> = {};\n/**\n * Only English is built in (the reference). Other languages are the @novaprose/core/i18n/<code> packs,\n * attached through registerLanguage: each customer downloads only their language.\n */\nconst builtin: Record<string, Messages> = { en };\nconst warned = new Set<string>();\n\n/** A plugin's strings in one language: a string or a list of strings (group names and the like). */\nexport type PluginLabels = Record<string, string | readonly string[]>;\n/** A plugin's dictionary by language; en is the reference and the fallback. */\nexport type PluginDict = { en: PluginLabels } & Record<string, PluginLabels | undefined>;\n\n/** Built-in plugin strings in flat form: namespace → language → 'key' | 'key.0' → string. */\nconst pluginPacks: Record<string, Record<string, Record<string, string>>> = {};\n\nfunction flatten(labels: PluginLabels): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(labels)) {\n if (typeof value === 'string') out[key] = value;\n else value.forEach((item, i) => (out[`${key}.${i}`] = item));\n }\n return out;\n}\n\n/** A pack loader: `() => import('@novaprose/core/i18n/de')` — the language downloads only when needed. */\nexport type LanguageLoader = () => Promise<LanguagePack | { default: LanguagePack }>;\n\nconst loaders: Record<string, LanguageLoader> = {};\nconst loading: Record<string, Promise<boolean> | undefined> = {};\n\n/** A pack's strings go into the language's shared dictionary: over the existing ones or under them (a loaded pack doesn't overwrite customizations). */\nfunction install(lang: string, messages: LanguagePack, below = false): void {\n userPacks[lang] = below\n ? { ...messages, ...userPacks[lang] }\n : { ...userPacks[lang], ...messages };\n builtin[lang] = { ...en, ...(userPacks[lang] as Partial<Messages>) };\n}\n\n/**\n * Register a language pack (BCP 47 code: 'de', 'pt-BR') or a function that loads it — then call\n * `await loadLanguage(code)` before creating the editor. Missing keys fall back to English.\n */\nexport function registerLanguage(code: string, messages: LanguagePack | LanguageLoader): void {\n const lang = code.toLowerCase();\n if (typeof messages === 'function') loaders[lang] = messages;\n else install(lang, messages);\n}\n\n/** Whether a language is ready for a new editor: its pack is registered (or it is English). */\nexport function hasLanguage(code: string): boolean {\n const lang = code.toLowerCase();\n return lang in builtin || lang.split('-')[0]! in builtin;\n}\n\n/**\n * Load a language registered with a loader (the CDN builds register every pack this way). true —\n * the language is ready, false — there is neither a pack nor a loader. Strings are taken when an\n * editor is created, so load first. A failed load can be retried: the failure isn't remembered.\n */\nexport function loadLanguage(code: string): Promise<boolean> {\n const lang = code.toLowerCase();\n const base = lang.split('-')[0]!;\n const key = lang in loaders ? lang : base in loaders ? base : null;\n if (!key) return Promise.resolve(hasLanguage(lang));\n return (loading[key] ??= loaders[key]!().then(\n (module) => {\n // A pack module (import()) or the pack itself.\n install(\n key,\n (module as { default?: LanguagePack }).default ?? (module as LanguagePack),\n true,\n );\n return true;\n },\n (error: unknown) => {\n loading[key] = undefined;\n throw error;\n },\n ));\n}\n\n/**\n * A plugin's strings by language (en is the reference). The plugin calls it when its module loads.\n * Strings add up: a plugin and its lazy part can each register theirs under the same namespace.\n */\nexport function registerPluginMessages(namespace: string, dict: PluginDict): void {\n const packs = (pluginPacks[namespace] ??= {});\n for (const [lang, labels] of Object.entries(dict)) {\n if (labels) packs[lang] = { ...packs[lang], ...flatten(labels) };\n }\n}\n\n/**\n * All registered plugin strings, flattened: namespace → language → key → string (to check that\n * translations are complete, and as a template for translators).\n */\nexport function getPluginMessages(): Readonly<\n Record<string, Readonly<Record<string, Record<string, string>>>>\n> {\n return pluginPacks;\n}\n\nexport type Translator = (\n key: MessageKey | PluginMessageKey,\n params?: Record<string, string | number>,\n) => string;\n\nconst interpolate = (template: string, params?: Record<string, string | number>) =>\n params\n ? template.replace(/\\{(\\w+)\\}/g, (_, name: string) => String(params[name] ?? `{${name}}`))\n : template;\n\n/**\n * The translator for an editor instance. Looks for the exact code ('pt-br'), then the base language ('pt'),\n * then English. overrides are targeted replacements of strings from the config (core and plugins alike).\n * Plugin strings are looked up at call time: lazy plugins register after the editor is created.\n */\nexport function createTranslator(language = 'en', overrides: LanguagePack = {}): Translator {\n const code = language.toLowerCase();\n const base = code.split('-')[0]!;\n const pack = builtin[code] ?? builtin[base] ?? en;\n if (pack === en && base !== 'en' && !warned.has(base)) {\n warned.add(base);\n console.warn(\n code in loaders || base in loaders\n ? `[nova] language \"${language}\" is not loaded yet, using English. ` +\n `Load it before creating the editor: await loadLanguage('${language}');`\n : `[nova] language \"${language}\" is not registered, using English. ` +\n `import pack from '@novaprose/core/i18n/${base}'; registerLanguage('${base}', pack);`,\n );\n }\n const messages: Record<string, string> = { ...en, ...pack, ...overrides };\n const user = { ...userPacks[base], ...userPacks[code] } as Record<string, string | undefined>;\n const own = overrides as Record<string, string | undefined>;\n\n return (key, params) => {\n const core = messages[key];\n if (core !== undefined) return interpolate(core, params);\n // A plugin string: config → registerLanguage → the plugin's built-in translation → English.\n const dot = key.indexOf('.');\n const dict = dot > 0 ? pluginPacks[key.slice(0, dot)] : undefined;\n const name = key.slice(dot + 1);\n const template =\n own[key] ??\n user[key] ??\n dict?.[code]?.[name] ??\n dict?.[base]?.[name] ??\n dict?.en?.[name] ??\n key;\n return interpolate(template, params);\n };\n}\n","import type { Editor } from '../editor';\nimport { activeElement, h, logicalKey } from '../ui/dom';\nimport { registerPluginMessages, type PluginLabels } from '../i18n';\n\n/**\n * Labels of a built-in plugin. Plugins load lazily, so the strings live in the plugin itself\n * (en is the reference; translations live in the language packs), but they go through the shared i18n system under the keys\n * `<plugin>.<key>`: registerLanguage('de', { 'anchor.title': … }) and the `translations` option see them.\n */\nexport function pickLabels<T extends PluginLabels>(\n editor: Editor,\n namespace: string,\n dict: { en: T } & Record<string, PluginLabels | undefined>,\n): T {\n registerPluginMessages(namespace, dict);\n const out: Record<string, string | string[]> = {};\n for (const [key, value] of Object.entries(dict.en)) {\n out[key] =\n typeof value === 'string'\n ? editor.ui.t(`${namespace}.${key}`)\n : value.map((_, i) => editor.ui.t(`${namespace}.${key}.${i}`));\n }\n return out as T;\n}\n\nexport function insertText(editor: Editor, text: string): void {\n const { state, dispatch } = editor.view;\n dispatch(state.tr.insertText(text).scrollIntoView());\n editor.focus();\n}\n\nexport interface SymbolGroup {\n title: string;\n /** [character, name for search and screen readers] */\n items: readonly (readonly [string, string])[];\n}\n\n/**\n * A character picker panel: search + a grid of buttons by group. Arrows move focus across the grid,\n * Enter/space inserts, Esc closes the panel (the shared popover stack).\n */\nexport function symbolPanel(options: {\n groups: SymbolGroup[];\n searchLabel: string;\n emptyText: string;\n className: string;\n onPick: (symbol: string) => void;\n}): HTMLElement {\n const search = h('input', {\n type: 'search',\n className: 'nova-input nova-symbols-search',\n placeholder: options.searchLabel,\n 'aria-label': options.searchLabel,\n }) as HTMLInputElement;\n const list = h('div', { className: 'nova-symbols-list' });\n const panel = h('div', { className: `nova-symbols ${options.className}` }, search, list);\n\n const render = (query: string) => {\n const q = query.trim().toLowerCase();\n const sections = options.groups\n .map((group) => ({\n title: group.title,\n items: q ? group.items.filter(([s, name]) => name.includes(q) || s === q) : group.items,\n }))\n .filter((g) => g.items.length);\n if (!sections.length) {\n list.replaceChildren(h('div', { className: 'nova-symbols-empty' }, options.emptyText));\n return;\n }\n list.replaceChildren(\n ...sections.map((section) =>\n h(\n 'div',\n { className: 'nova-symbols-group', role: 'group', 'aria-label': section.title },\n h('div', { className: 'nova-symbols-title' }, section.title),\n h(\n 'div',\n { className: 'nova-symbols-grid' },\n ...section.items.map(([symbol, name]) =>\n h(\n 'button',\n {\n type: 'button',\n className: 'nova-symbols-cell',\n title: name,\n 'aria-label': name,\n onclick: () => options.onPick(symbol),\n },\n symbol,\n ),\n ),\n ),\n ),\n ),\n );\n };\n\n search.addEventListener('input', () => render(search.value));\n search.addEventListener('keydown', (event) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n list.querySelector<HTMLButtonElement>('.nova-symbols-cell')?.focus();\n } else if (event.key === 'Enter') {\n event.preventDefault();\n list.querySelector<HTMLButtonElement>('.nova-symbols-cell')?.click();\n }\n });\n list.addEventListener('keydown', (event) => {\n const cells = [...list.querySelectorAll<HTMLButtonElement>('.nova-symbols-cell')];\n const index = cells.indexOf(activeElement(list) as HTMLButtonElement);\n if (index < 0) return;\n // The width of a grid row comes from the actual position of the buttons.\n const perRow = Math.max(1, cells.filter((c) => c.offsetTop === cells[0]!.offsetTop).length);\n const step: Record<string, number> = {\n ArrowRight: 1,\n ArrowLeft: -1,\n ArrowDown: perRow,\n ArrowUp: -perRow,\n };\n const key = logicalKey(event, list);\n if (!(key in step)) return;\n event.preventDefault();\n const next = index + step[key]!;\n if (next < 0) search.focus();\n else cells[Math.min(cells.length - 1, next)]?.focus();\n });\n\n render('');\n queueMicrotask(() => search.focus());\n return panel;\n}\n\n/** Opens the character panel in a dialog (for a menu item when the button isn't on the toolbar). */\nexport function openSymbolDialog(\n editor: Editor,\n title: string,\n build: (close: () => void) => HTMLElement,\n): void {\n let handle: { close(): void } | null = null;\n const body = build(() => handle?.close());\n handle = editor.ui.openDialog({ title, body, cancelLabel: editor.ui.t('dialog.close') });\n}\n"],"mappings":";;;;;;;AACO,IAAM,KAAK;AAAA,EAChB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EAEnB,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,WAAW;AAAA,EACX,aAAa;AAAA,EACb,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,WAAW;AAAA,EACX,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,aAAa;AAAA,EACb,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,MAAM;AAAA,EACN,aAAa;AAAA,EAEb,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EAEJ,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,SAAS;AAAA,EAC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,EAAE,CAAC;AACzF;","names":[]}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pickLabels
|
|
3
|
+
} from "./chunk-DEYYVZ7O.js";
|
|
4
|
+
import {
|
|
5
|
+
definePlugin
|
|
6
|
+
} from "./chunk-V7WUHUHM.js";
|
|
7
|
+
|
|
8
|
+
// src/plugins/math.ts
|
|
9
|
+
import { NodeSelection, Plugin, PluginKey } from "prosemirror-state";
|
|
10
|
+
|
|
11
|
+
// nova-raw-css:/home/runner/work/novaprose/novaprose/packages/core/src/plugins/math.css?raw
|
|
12
|
+
var math_default = '.nova-math{border-radius:4px;cursor:pointer}.nova-math-inline{display:inline-block;padding:0 2px}.nova-math-block{display:block;margin:0 0 .75em;padding:6px 8px;overflow-x:auto;text-align:center}.nova-math:hover{background:var(--nova-hover)}.nova-math.is-selected{outline:2px solid var(--nova-accent)}.nova-math:not(:has(math)){font-family:var(--nova-mono);font-size:.9em}.nova-math-error{color:var(--nova-danger);text-decoration:underline wavy;text-underline-offset:3px}.nova-math-empty:before{content:var(--nova-math-empty, "");color:var(--nova-muted);font-family:var(--nova-font)}.nova-math-preview{min-height:2.5em;padding:8px;overflow-x:auto;border:1px dashed var(--nova-border);border-radius:var(--nova-radius-sm);text-align:center}';
|
|
13
|
+
|
|
14
|
+
// src/plugins/math.ts
|
|
15
|
+
var LABELS = { en: { empty: "Formula" } };
|
|
16
|
+
function mathLatex(value) {
|
|
17
|
+
return typeof value === "string" ? value.slice(0, 1e4) : "";
|
|
18
|
+
}
|
|
19
|
+
var temml = null;
|
|
20
|
+
function loadTemml() {
|
|
21
|
+
temml ??= import("temml").then(
|
|
22
|
+
(module) => module.default,
|
|
23
|
+
(error) => {
|
|
24
|
+
temml = null;
|
|
25
|
+
console.warn("[nova] math: could not load the formula renderer", error);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
return temml;
|
|
30
|
+
}
|
|
31
|
+
function renderMath(engine, latex, target, block) {
|
|
32
|
+
try {
|
|
33
|
+
engine.render(latex, target, {
|
|
34
|
+
displayMode: block,
|
|
35
|
+
throwOnError: true,
|
|
36
|
+
trust: false,
|
|
37
|
+
annotate: true
|
|
38
|
+
});
|
|
39
|
+
return null;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
target.textContent = latex;
|
|
42
|
+
return error instanceof Error ? error.message.replace(/^ParseError:\s*/, "") : String(error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function mathSpec(block) {
|
|
46
|
+
const type = block ? "block-math" : "inline-math";
|
|
47
|
+
const tag = block ? "div" : "span";
|
|
48
|
+
return {
|
|
49
|
+
...block ? { group: "block" } : { group: "inline", inline: true },
|
|
50
|
+
atom: true,
|
|
51
|
+
selectable: true,
|
|
52
|
+
draggable: true,
|
|
53
|
+
attrs: { latex: { default: "" } },
|
|
54
|
+
parseDOM: [
|
|
55
|
+
{
|
|
56
|
+
tag: `${tag}[data-type="${type}"]`,
|
|
57
|
+
getAttrs: (dom) => ({ latex: mathLatex(dom.getAttribute("data-latex")) })
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
toDOM: (node) => {
|
|
61
|
+
const latex = mathLatex(node.attrs.latex);
|
|
62
|
+
return [
|
|
63
|
+
tag,
|
|
64
|
+
{ "data-type": type, "data-latex": latex },
|
|
65
|
+
block ? `\\[${latex}\\]` : `\\(${latex}\\)`
|
|
66
|
+
];
|
|
67
|
+
},
|
|
68
|
+
leafText: (node) => block ? `$$${mathLatex(node.attrs.latex)}$$` : `$${mathLatex(node.attrs.latex)}$`
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
var MathView = class {
|
|
72
|
+
constructor(node, view, getPos, editor) {
|
|
73
|
+
this.node = node;
|
|
74
|
+
this.view = view;
|
|
75
|
+
this.getPos = getPos;
|
|
76
|
+
this.editor = editor;
|
|
77
|
+
const block = node.type.name === "math_block";
|
|
78
|
+
this.dom = document.createElement(block ? "div" : "span");
|
|
79
|
+
this.dom.className = `nova-math ${block ? "nova-math-block" : "nova-math-inline"}`;
|
|
80
|
+
this.dom.contentEditable = "false";
|
|
81
|
+
this.dom.addEventListener("click", () => this.edit());
|
|
82
|
+
this.render();
|
|
83
|
+
}
|
|
84
|
+
node;
|
|
85
|
+
view;
|
|
86
|
+
getPos;
|
|
87
|
+
editor;
|
|
88
|
+
dom;
|
|
89
|
+
latex = "";
|
|
90
|
+
render() {
|
|
91
|
+
const latex = mathLatex(this.node.attrs.latex);
|
|
92
|
+
if (latex === this.latex && this.dom.childNodes.length) return;
|
|
93
|
+
this.latex = latex;
|
|
94
|
+
const block = this.node.type.name === "math_block";
|
|
95
|
+
this.dom.classList.toggle("nova-math-empty", !latex.trim());
|
|
96
|
+
this.dom.textContent = latex.trim() ? latex : "";
|
|
97
|
+
if (!latex.trim()) return;
|
|
98
|
+
void loadTemml().then((engine) => {
|
|
99
|
+
if (!engine || this.latex !== latex) return;
|
|
100
|
+
const error = renderMath(engine, latex, this.dom, block);
|
|
101
|
+
this.dom.classList.toggle("nova-math-error", !!error);
|
|
102
|
+
if (error) this.dom.title = error;
|
|
103
|
+
else this.dom.removeAttribute("title");
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/** Selects the formula and opens editing (the math button is registered by the lazy part). */
|
|
107
|
+
edit() {
|
|
108
|
+
const pos = this.getPos();
|
|
109
|
+
if (pos === void 0 || !this.editor.isEditable()) return;
|
|
110
|
+
this.view.dispatch(
|
|
111
|
+
this.view.state.tr.setSelection(NodeSelection.create(this.view.state.doc, pos))
|
|
112
|
+
);
|
|
113
|
+
const button = this.editor.ui.registry.get("math");
|
|
114
|
+
if (button?.type === "button") button.onAction(this.editor);
|
|
115
|
+
}
|
|
116
|
+
update(node) {
|
|
117
|
+
if (node.type !== this.node.type) return false;
|
|
118
|
+
this.node = node;
|
|
119
|
+
this.render();
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
selectNode() {
|
|
123
|
+
this.dom.classList.add("is-selected");
|
|
124
|
+
}
|
|
125
|
+
deselectNode() {
|
|
126
|
+
this.dom.classList.remove("is-selected");
|
|
127
|
+
}
|
|
128
|
+
ignoreMutation() {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var math_default2 = definePlugin({
|
|
133
|
+
name: "math",
|
|
134
|
+
nodes: { math_inline: mathSpec(false), math_block: mathSpec(true) },
|
|
135
|
+
prosemirrorPlugins: (editor) => [
|
|
136
|
+
new Plugin({
|
|
137
|
+
key: new PluginKey("nova-math"),
|
|
138
|
+
props: {
|
|
139
|
+
nodeViews: {
|
|
140
|
+
math_inline: (node, view, getPos) => new MathView(node, view, getPos, editor),
|
|
141
|
+
math_block: (node, view, getPos) => new MathView(node, view, getPos, editor)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
],
|
|
146
|
+
setup(editor) {
|
|
147
|
+
editor.ui.addStyles("nova-math", math_default);
|
|
148
|
+
const { empty } = pickLabels(editor, "math", LABELS);
|
|
149
|
+
editor.root.style.setProperty("--nova-math-empty", JSON.stringify(empty));
|
|
150
|
+
},
|
|
151
|
+
load: () => import("./math-ui-RUTCHTRY.js")
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
export {
|
|
155
|
+
mathLatex,
|
|
156
|
+
loadTemml,
|
|
157
|
+
renderMath,
|
|
158
|
+
math_default2 as math_default
|
|
159
|
+
};
|
|
160
|
+
//# sourceMappingURL=chunk-EOJ5XHKA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugins/math.ts","nova-raw-css:/home/runner/work/novaprose/novaprose/packages/core/src/plugins/math.css?raw"],"sourcesContent":["import type { DOMOutputSpec, Node as PMNode, NodeSpec } from 'prosemirror-model';\nimport { NodeSelection, Plugin, PluginKey } from 'prosemirror-state';\nimport type { EditorView, NodeView } from 'prosemirror-view';\nimport type TemmlEngine from 'temml';\nimport type { Editor } from '../editor';\nimport { definePlugin } from '../plugins';\nimport css from './math.css?raw';\nimport { pickLabels } from './shared';\n\n/**\n * The math plugin: LaTeX formulas inline (`$E=mc^2$`) and on their own line. `plugins: ['math']`.\n * The HTML holds the LaTeX source: `<span data-type=\"inline-math\" data-latex=\"E=mc^2\">\\(E=mc^2\\)</span>`\n * (the same format as Tiptap; KaTeX and MathJax on the site's page understand the text with \\( \\)). In the editor\n * the formula is drawn with MathML (Temml, ~58 KB gzip, loaded when the document has a formula):\n * the browser renders it itself, without fonts and styles.\n *\n * Here are the nodes and their view (needed from the first render); the dialog, `$…$` input and the button are in math-ui.ts.\n */\n\nexport const LABELS = { en: { empty: 'Formula' } };\n\n/** The formula source: a string of reasonable length (HTML and JSON can bring anything). */\nexport function mathLatex(value: unknown): string {\n return typeof value === 'string' ? value.slice(0, 10_000) : '';\n}\n\ntype Temml = typeof TemmlEngine;\nlet temml: Promise<Temml | null> | null = null;\n\n/** Temml: one per page, loaded on first demand. */\nexport function loadTemml(): Promise<Temml | null> {\n temml ??= import('temml').then(\n (module) => module.default,\n (error: unknown) => {\n temml = null; // a network hiccup: the next formula tries again\n console.warn('[nova] math: could not load the formula renderer', error);\n return null;\n },\n );\n return temml;\n}\n\n/**\n * Draws a formula into an element. No trust in the LaTeX (`trust: false`): \\href and the like don't work.\n * An error in the formula (or an engine failure) leaves the source in the element and the error text in the answer: how the error\n * shows is up to the caller (a tooltip on the formula, a line under the preview in the dialog).\n */\nexport function renderMath(\n engine: Temml,\n latex: string,\n target: HTMLElement,\n block: boolean,\n): string | null {\n try {\n engine.render(latex, target, {\n displayMode: block,\n throwOnError: true,\n trust: false,\n annotate: true,\n });\n return null;\n } catch (error) {\n target.textContent = latex;\n return error instanceof Error ? error.message.replace(/^ParseError:\\s*/, '') : String(error);\n }\n}\n\nfunction mathSpec(block: boolean): NodeSpec {\n const type = block ? 'block-math' : 'inline-math';\n const tag = block ? 'div' : 'span';\n return {\n ...(block ? { group: 'block' } : { group: 'inline', inline: true }),\n atom: true,\n selectable: true,\n draggable: true,\n attrs: { latex: { default: '' } },\n parseDOM: [\n {\n tag: `${tag}[data-type=\"${type}\"]`,\n getAttrs: (dom) => ({ latex: mathLatex((dom as HTMLElement).getAttribute('data-latex')) }),\n },\n ],\n toDOM: (node): DOMOutputSpec => {\n const latex = mathLatex(node.attrs.latex);\n return [\n tag,\n { 'data-type': type, 'data-latex': latex },\n block ? `\\\\[${latex}\\\\]` : `\\\\(${latex}\\\\)`,\n ];\n },\n leafText: (node) =>\n block ? `$$${mathLatex(node.attrs.latex)}$$` : `$${mathLatex(node.attrs.latex)}$`,\n };\n}\n\n/** The formula view: the source until Temml loads, then MathML. A click edits it (math-ui). */\nclass MathView implements NodeView {\n dom: HTMLElement;\n private latex = '';\n\n constructor(\n private node: PMNode,\n private readonly view: EditorView,\n private readonly getPos: () => number | undefined,\n private readonly editor: Editor,\n ) {\n const block = node.type.name === 'math_block';\n this.dom = document.createElement(block ? 'div' : 'span');\n this.dom.className = `nova-math ${block ? 'nova-math-block' : 'nova-math-inline'}`;\n this.dom.contentEditable = 'false';\n this.dom.addEventListener('click', () => this.edit());\n this.render();\n }\n\n private render(): void {\n const latex = mathLatex(this.node.attrs.latex);\n if (latex === this.latex && this.dom.childNodes.length) return;\n this.latex = latex;\n const block = this.node.type.name === 'math_block';\n this.dom.classList.toggle('nova-math-empty', !latex.trim());\n // The source right away (visible without a network), the formula once the engine loads.\n this.dom.textContent = latex.trim() ? latex : '';\n if (!latex.trim()) return;\n void loadTemml().then((engine) => {\n if (!engine || this.latex !== latex) return;\n const error = renderMath(engine, latex, this.dom, block);\n // An error: the source with a wavy underline, the error text in a tooltip.\n this.dom.classList.toggle('nova-math-error', !!error);\n if (error) this.dom.title = error;\n else this.dom.removeAttribute('title');\n });\n }\n\n /** Selects the formula and opens editing (the math button is registered by the lazy part). */\n private edit(): void {\n const pos = this.getPos();\n if (pos === undefined || !this.editor.isEditable()) return;\n this.view.dispatch(\n this.view.state.tr.setSelection(NodeSelection.create(this.view.state.doc, pos)),\n );\n const button = this.editor.ui.registry.get('math');\n if (button?.type === 'button') button.onAction(this.editor);\n }\n\n update(node: PMNode): boolean {\n if (node.type !== this.node.type) return false;\n this.node = node;\n this.render();\n return true;\n }\n\n selectNode(): void {\n this.dom.classList.add('is-selected');\n }\n\n deselectNode(): void {\n this.dom.classList.remove('is-selected');\n }\n\n ignoreMutation(): boolean {\n return true;\n }\n}\n\nexport default definePlugin({\n name: 'math',\n nodes: { math_inline: mathSpec(false), math_block: mathSpec(true) },\n prosemirrorPlugins: (editor) => [\n new Plugin({\n key: new PluginKey('nova-math'),\n props: {\n nodeViews: {\n math_inline: (node, view, getPos) => new MathView(node, view, getPos, editor),\n math_block: (node, view, getPos) => new MathView(node, view, getPos, editor),\n },\n },\n }),\n ],\n setup(editor) {\n editor.ui.addStyles('nova-math', css);\n // An empty formula shows a label in the interface language (it isn't in the document's HTML).\n const { empty } = pickLabels(editor, 'math', LABELS);\n editor.root.style.setProperty('--nova-math-empty', JSON.stringify(empty));\n },\n load: () => import('./math-ui'),\n});\n",".nova-math{border-radius:4px;cursor:pointer}.nova-math-inline{display:inline-block;padding:0 2px}.nova-math-block{display:block;margin:0 0 .75em;padding:6px 8px;overflow-x:auto;text-align:center}.nova-math:hover{background:var(--nova-hover)}.nova-math.is-selected{outline:2px solid var(--nova-accent)}.nova-math:not(:has(math)){font-family:var(--nova-mono);font-size:.9em}.nova-math-error{color:var(--nova-danger);text-decoration:underline wavy;text-underline-offset:3px}.nova-math-empty:before{content:var(--nova-math-empty, \"\");color:var(--nova-muted);font-family:var(--nova-font)}.nova-math-preview{min-height:2.5em;padding:8px;overflow-x:auto;border:1px dashed var(--nova-border);border-radius:var(--nova-radius-sm);text-align:center}"],"mappings":";;;;;;;;AACA,SAAS,eAAe,QAAQ,iBAAiB;;;ACDjD;;;ADmBO,IAAM,SAAS,EAAE,IAAI,EAAE,OAAO,UAAU,EAAE;AAG1C,SAAS,UAAU,OAAwB;AAChD,SAAO,OAAO,UAAU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