@novaprose/core 0.6.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 +20 -4
- 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-K2U3VPH2.js → advlist-CEHE6YXS.js} +14 -20
- 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-XWDTLY37.js → autolink-N427KVQO.js} +13 -7
- 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-MWNRUNU3.js → autosave-L7OZ3KLK.js} +9 -13
- 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-ADLYOIB3.js → charmap-5CBBDWOP.js} +9 -14
- 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-3BOK3S3T.js +26 -0
- 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-4VPDY3LF.js +27 -0
- 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-GHEFKKRC.js → chunk-AC3YCAX4.js} +108 -29
- package/dist/chunk-AC3YCAX4.js.map +1 -0
- package/dist/{chunk-NPKAIW34.js → chunk-ADRPQLZ2.js} +50 -1
- 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-DEYYVZ7O.js +393 -0
- 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-GHVB6SV4.js +177 -0
- 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-J6W2CDRF.js +425 -0
- 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-HZRIBOPW.js → chunk-QU3KXMYT.js} +45 -3
- 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-7ON7PR5R.js → chunk-TAM2FHKG.js} +374 -52
- 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/chunk-VK6YF2AA.js +359 -0
- 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-FYJE3U64.js → comments-panel-SOLBZ46Q.js} +12 -6
- package/dist/comments-panel-SOLBZ46Q.js.map +1 -0
- package/dist/{directionality-XOHJFSL6.js → directionality-EGQKGDZA.js} +16 -11
- 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-TP4N4ZGY.js → emoticons-EGHNZKSA.js} +9 -14
- 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 +482 -0
- package/dist/html-rules.cjs.map +1 -0
- package/dist/html-rules.d.cts +89 -0
- package/dist/html-rules.d.ts +89 -0
- package/dist/html-rules.js +417 -0
- package/dist/html-rules.js.map +1 -0
- package/dist/i18n/de.cjs +670 -0
- package/dist/i18n/de.cjs.map +1 -0
- package/dist/i18n/de.d.cts +9 -0
- package/dist/i18n/de.d.ts +9 -0
- package/dist/i18n/de.js +649 -0
- package/dist/i18n/de.js.map +1 -0
- package/dist/i18n/es.cjs +670 -0
- package/dist/i18n/es.cjs.map +1 -0
- package/dist/i18n/es.d.cts +9 -0
- package/dist/i18n/es.d.ts +9 -0
- package/dist/i18n/es.js +649 -0
- package/dist/i18n/es.js.map +1 -0
- package/dist/i18n/fr.cjs +670 -0
- package/dist/i18n/fr.cjs.map +1 -0
- package/dist/i18n/fr.d.cts +9 -0
- package/dist/i18n/fr.d.ts +9 -0
- package/dist/i18n/fr.js +649 -0
- package/dist/i18n/fr.js.map +1 -0
- package/dist/i18n/it.cjs +670 -0
- package/dist/i18n/it.cjs.map +1 -0
- package/dist/i18n/it.d.cts +9 -0
- package/dist/i18n/it.d.ts +9 -0
- package/dist/i18n/it.js +649 -0
- package/dist/i18n/it.js.map +1 -0
- package/dist/i18n/pt-BR.cjs +670 -0
- package/dist/i18n/pt-BR.cjs.map +1 -0
- package/dist/i18n/pt-BR.d.cts +9 -0
- package/dist/i18n/pt-BR.d.ts +9 -0
- package/dist/i18n/pt-BR.js +649 -0
- package/dist/i18n/pt-BR.js.map +1 -0
- package/dist/i18n/ru.cjs +670 -0
- package/dist/i18n/ru.cjs.map +1 -0
- package/dist/i18n/ru.d.cts +10 -0
- package/dist/i18n/ru.d.ts +10 -0
- package/dist/i18n/ru.js +649 -0
- package/dist/i18n/ru.js.map +1 -0
- 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-CZ9yDvmQ.d.cts +235 -0
- package/dist/index-CZ9yDvmQ.d.ts +235 -0
- package/dist/index.cjs +29531 -10134
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +160 -1828
- package/dist/index.d.ts +160 -1828
- package/dist/index.js +212 -1480
- package/dist/index.js.map +1 -1
- package/dist/{insertdatetime-T4SEMQWP.js → insertdatetime-YW2VHYZH.js} +10 -16
- 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 +356 -0
- package/dist/markdown.cjs.map +1 -0
- package/dist/markdown.d.cts +25 -0
- package/dist/markdown.d.ts +25 -0
- package/dist/markdown.js +10 -0
- package/dist/markdown.js.map +1 -0
- 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-HG5HV6AL.js → nonbreaking-GYRUH4UO.js} +10 -9
- 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-3A6KWKCV.js +520 -0
- 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-4NU4SIPL.js → quickbars-UZ2Q67TX.js} +24 -12
- package/dist/quickbars-UZ2Q67TX.js.map +1 -0
- package/dist/{revisionhistory-3YQPLPLM.js → revisionhistory-ACRB23HL.js} +48 -173
- 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-RTAYJOGR.js → visualblocks-O5QW7ZDT.js} +10 -9
- 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 +96 -6
- package/src/style.css +440 -508
- package/dist/advlist-K2U3VPH2.js.map +0 -1
- package/dist/autolink-XWDTLY37.js.map +0 -1
- package/dist/autoresize-UB3GOA6D.js.map +0 -1
- package/dist/autosave-MWNRUNU3.js.map +0 -1
- package/dist/charmap-ADLYOIB3.js.map +0 -1
- package/dist/chunk-435CRWKA.js +0 -983
- package/dist/chunk-435CRWKA.js.map +0 -1
- package/dist/chunk-46RIM5KP.js +0 -5949
- package/dist/chunk-46RIM5KP.js.map +0 -1
- package/dist/chunk-6RJENZXT.js +0 -104
- package/dist/chunk-6RJENZXT.js.map +0 -1
- package/dist/chunk-7ON7PR5R.js.map +0 -1
- package/dist/chunk-GHEFKKRC.js.map +0 -1
- package/dist/chunk-HPLT3XRZ.js.map +0 -1
- package/dist/chunk-HZRIBOPW.js.map +0 -1
- package/dist/chunk-NPKAIW34.js.map +0 -1
- package/dist/chunk-Z3ELZ77W.js.map +0 -1
- package/dist/comments-panel-FYJE3U64.js.map +0 -1
- package/dist/directionality-XOHJFSL6.js.map +0 -1
- package/dist/emoticons-TP4N4ZGY.js.map +0 -1
- package/dist/insertdatetime-T4SEMQWP.js.map +0 -1
- package/dist/nonbreaking-HG5HV6AL.js.map +0 -1
- package/dist/quickbars-4NU4SIPL.js.map +0 -1
- package/dist/revisionhistory-3YQPLPLM.js.map +0 -1
- package/dist/visualblocks-RTAYJOGR.js.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
icons
|
|
3
|
+
} from "./chunk-ADRPQLZ2.js";
|
|
4
|
+
import {
|
|
5
|
+
h,
|
|
6
|
+
icon
|
|
7
|
+
} from "./chunk-QU3KXMYT.js";
|
|
8
|
+
|
|
9
|
+
// src/ui/file-picker.ts
|
|
10
|
+
function attachFilePicker(editor, field, type, onPick) {
|
|
11
|
+
const { filePicker: picker, filePickerTypes: types } = editor.options;
|
|
12
|
+
if (!picker || types && !types.includes(type)) return;
|
|
13
|
+
const { input } = field;
|
|
14
|
+
const button = h(
|
|
15
|
+
"button",
|
|
16
|
+
{
|
|
17
|
+
type: "button",
|
|
18
|
+
className: "nova-btn nova-input-action",
|
|
19
|
+
"aria-label": editor.ui.t("dialog.browse"),
|
|
20
|
+
title: editor.ui.t("dialog.browse")
|
|
21
|
+
},
|
|
22
|
+
icon(icons.browse)
|
|
23
|
+
);
|
|
24
|
+
const group = h("div", { className: "nova-input-group" });
|
|
25
|
+
input.replaceWith(group);
|
|
26
|
+
group.append(input, button);
|
|
27
|
+
button.addEventListener("click", async () => {
|
|
28
|
+
button.disabled = true;
|
|
29
|
+
try {
|
|
30
|
+
const result = await picker({ type, value: input.value });
|
|
31
|
+
if (!result?.url) return;
|
|
32
|
+
input.value = result.url;
|
|
33
|
+
input.removeAttribute("aria-invalid");
|
|
34
|
+
onPick?.(result);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error("[nova] filePicker failed:", error);
|
|
37
|
+
} finally {
|
|
38
|
+
button.disabled = false;
|
|
39
|
+
if (input.isConnected) input.focus();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
attachFilePicker
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=chunk-FTEA6L2Q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/file-picker.ts"],"sourcesContent":["import type { Editor } from '../editor';\nimport { h, icon } from './dom';\nimport { icons } from './icons';\n\n/** What the user chose in your file manager. */\nexport interface FilePickResult {\n url: string;\n /** Link text (in the link dialog, when the text is still empty). */\n text?: string;\n /** The link's tooltip (title) or the video's name. */\n title?: string;\n /** The image's alternative text. */\n alt?: string;\n}\n\n/** Which field asks for a file: a link to any file, an image or a video. */\nexport type FilePickType = 'file' | 'image' | 'media';\n\n/**\n * Your own file picker (like file_picker_callback in TinyMCE): open your file manager and return an\n * address. null/undefined — the user changed their mind.\n */\nexport type FilePicker = (request: {\n type: FilePickType;\n value: string;\n}) => Promise<FilePickResult | null | undefined> | FilePickResult | null | undefined;\n\n/**\n * Adds a \"Browse\" button to an address field when options.filePicker is set.\n * onPick fills in the dialog's other fields (link text, alt…).\n */\nexport function attachFilePicker(\n editor: Editor,\n field: { el: HTMLElement; input: HTMLInputElement },\n type: FilePickType,\n onPick?: (result: FilePickResult) => void,\n): void {\n const { filePicker: picker, filePickerTypes: types } = editor.options;\n if (!picker || (types && !types.includes(type))) return;\n const { input } = field;\n const button = h(\n 'button',\n {\n type: 'button',\n className: 'nova-btn nova-input-action',\n 'aria-label': editor.ui.t('dialog.browse'),\n title: editor.ui.t('dialog.browse'),\n },\n icon(icons.browse),\n );\n const group = h('div', { className: 'nova-input-group' });\n input.replaceWith(group);\n group.append(input, button);\n\n button.addEventListener('click', async () => {\n button.disabled = true;\n try {\n const result = await picker({ type, value: input.value });\n if (!result?.url) return;\n input.value = result.url;\n input.removeAttribute('aria-invalid');\n onPick?.(result);\n } catch (error) {\n console.error('[nova] filePicker failed:', error);\n } finally {\n button.disabled = false;\n // The dialog may have closed while your file manager was open.\n if (input.isConnected) input.focus();\n }\n });\n}\n"],"mappings":";;;;;;;;;AA+BO,SAAS,iBACd,QACA,OACA,MACA,QACM;AACN,QAAM,EAAE,YAAY,QAAQ,iBAAiB,MAAM,IAAI,OAAO;AAC9D,MAAI,CAAC,UAAW,SAAS,CAAC,MAAM,SAAS,IAAI,EAAI;AACjD,QAAM,EAAE,MAAM,IAAI;AAClB,QAAM,SAAS;AAAA,IACb;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,WAAW;AAAA,MACX,cAAc,OAAO,GAAG,EAAE,eAAe;AAAA,MACzC,OAAO,OAAO,GAAG,EAAE,eAAe;AAAA,IACpC;AAAA,IACA,KAAK,MAAM,MAAM;AAAA,EACnB;AACA,QAAM,QAAQ,EAAE,OAAO,EAAE,WAAW,mBAAmB,CAAC;AACxD,QAAM,YAAY,KAAK;AACvB,QAAM,OAAO,OAAO,MAAM;AAE1B,SAAO,iBAAiB,SAAS,YAAY;AAC3C,WAAO,WAAW;AAClB,QAAI;AACF,YAAM,SAAS,MAAM,OAAO,EAAE,MAAM,OAAO,MAAM,MAAM,CAAC;AACxD,UAAI,CAAC,QAAQ,IAAK;AAClB,YAAM,QAAQ,OAAO;AACrB,YAAM,gBAAgB,cAAc;AACpC,eAAS,MAAM;AAAA,IACjB,SAAS,OAAO;AACd,cAAQ,MAAM,6BAA6B,KAAK;AAAA,IAClD,UAAE;AACA,aAAO,WAAW;AAElB,UAAI,MAAM,YAAa,OAAM,MAAM;AAAA,IACrC;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/code-language.ts"],"sourcesContent":["/**\n * A code block's language: only a safe name (Latin letters, digits, \"+#._-\", up to 32 characters): the value\n * goes into the `language-…` class and the Markdown fence, and JSON can bring anything.\n * A separate module: both the schema and the markdown entry point (without the schema) need it.\n */\nexport function codeLanguage(value: unknown): string | null {\n return typeof value === 'string' && /^[A-Za-z0-9_+#.-]{1,32}$/.test(value) ? value : null;\n}\n"],"mappings":";AAKO,SAAS,aAAa,OAA+B;AAC1D,SAAO,OAAO,UAAU,YAAY,2BAA2B,KAAK,KAAK,IAAI,QAAQ;AACvF;","names":[]}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import {
|
|
2
|
+
replaceSelectionWithBlock
|
|
3
|
+
} from "./chunk-AC3YCAX4.js";
|
|
4
|
+
import {
|
|
5
|
+
isInTable,
|
|
6
|
+
schema
|
|
7
|
+
} from "./chunk-TAM2FHKG.js";
|
|
8
|
+
import {
|
|
9
|
+
h
|
|
10
|
+
} from "./chunk-QU3KXMYT.js";
|
|
11
|
+
|
|
12
|
+
// src/tables.ts
|
|
13
|
+
import "prosemirror-model";
|
|
14
|
+
import { TextSelection } from "prosemirror-state";
|
|
15
|
+
var tables = null;
|
|
16
|
+
var loading = null;
|
|
17
|
+
function loadTables() {
|
|
18
|
+
loading ??= import("./table-OBHE465Y.js").then(
|
|
19
|
+
(module) => tables = module,
|
|
20
|
+
(error) => {
|
|
21
|
+
console.warn("[nova] failed to load table editing", error);
|
|
22
|
+
loading = null;
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
return loading;
|
|
27
|
+
}
|
|
28
|
+
var lazy = (name) => (state, dispatch, view) => tables ? tables.tableCommands[name](state, dispatch, view) : false;
|
|
29
|
+
var tableCommands = {
|
|
30
|
+
addRowBefore: lazy("addRowBefore"),
|
|
31
|
+
addRowAfter: lazy("addRowAfter"),
|
|
32
|
+
deleteRow: lazy("deleteRow"),
|
|
33
|
+
addColumnBefore: lazy("addColumnBefore"),
|
|
34
|
+
addColumnAfter: lazy("addColumnAfter"),
|
|
35
|
+
deleteColumn: lazy("deleteColumn"),
|
|
36
|
+
mergeCells: lazy("mergeCells"),
|
|
37
|
+
splitCell: lazy("splitCell"),
|
|
38
|
+
toggleHeaderRow: lazy("toggleHeaderRow"),
|
|
39
|
+
toggleHeaderColumn: lazy("toggleHeaderColumn"),
|
|
40
|
+
deleteTable: lazy("deleteTable")
|
|
41
|
+
};
|
|
42
|
+
function setCellBackground(color) {
|
|
43
|
+
return (state, dispatch, view) => tables ? tables.setCellBackground(color)(state, dispatch, view) : false;
|
|
44
|
+
}
|
|
45
|
+
function hasHeaderRow(state) {
|
|
46
|
+
return tables?.hasHeaderRow(state) ?? false;
|
|
47
|
+
}
|
|
48
|
+
function hasHeaderColumn(state) {
|
|
49
|
+
return tables?.hasHeaderColumn(state) ?? false;
|
|
50
|
+
}
|
|
51
|
+
function getTableProps(state) {
|
|
52
|
+
return tables?.getTableProps(state) ?? null;
|
|
53
|
+
}
|
|
54
|
+
function setTableProps(props) {
|
|
55
|
+
return (state, dispatch, view) => tables ? tables.setTableProps(props)(state, dispatch, view) : false;
|
|
56
|
+
}
|
|
57
|
+
function getCellProps(state) {
|
|
58
|
+
return tables?.getCellProps(state) ?? null;
|
|
59
|
+
}
|
|
60
|
+
function setCellProps(props) {
|
|
61
|
+
return (state, dispatch, view) => tables ? tables.setCellProps(props)(state, dispatch, view) : false;
|
|
62
|
+
}
|
|
63
|
+
function sortTable(direction, locale) {
|
|
64
|
+
return (state, dispatch, view) => tables ? tables.sortTable(direction, locale)(state, dispatch, view) : false;
|
|
65
|
+
}
|
|
66
|
+
var MAX_GRID = 10;
|
|
67
|
+
function tableRect(editor) {
|
|
68
|
+
const { $from } = editor.view.state.selection;
|
|
69
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
70
|
+
if ($from.node(depth).type.spec.tableRole === "table") {
|
|
71
|
+
const dom = editor.view.nodeDOM($from.before(depth));
|
|
72
|
+
return dom?.getBoundingClientRect() ?? null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
function createTable(rows, cols, withHeader = true, schema2 = schema) {
|
|
78
|
+
const { table, table_row, table_cell, table_header, paragraph } = schema2.nodes;
|
|
79
|
+
const rowNodes = [];
|
|
80
|
+
for (let r = 0; r < rows; r++) {
|
|
81
|
+
const cellType = withHeader && r === 0 ? table_header : table_cell;
|
|
82
|
+
const cells = [];
|
|
83
|
+
for (let c = 0; c < cols; c++) cells.push(cellType.create(null, paragraph.create()));
|
|
84
|
+
rowNodes.push(table_row.create(null, cells));
|
|
85
|
+
}
|
|
86
|
+
return table.create(null, rowNodes);
|
|
87
|
+
}
|
|
88
|
+
function insertTable(rows, cols, withHeader = true) {
|
|
89
|
+
return (state, dispatch) => {
|
|
90
|
+
if (rows < 1 || cols < 1 || rows > 100 || cols > 50) return false;
|
|
91
|
+
if (isInTable(state)) return false;
|
|
92
|
+
if (dispatch) {
|
|
93
|
+
const node = createTable(rows, cols, withHeader, state.schema);
|
|
94
|
+
const tr = replaceSelectionWithBlock(state.tr, node);
|
|
95
|
+
let tablePos = -1;
|
|
96
|
+
tr.doc.descendants((n, pos) => {
|
|
97
|
+
if (n === node) tablePos = pos;
|
|
98
|
+
return tablePos < 0;
|
|
99
|
+
});
|
|
100
|
+
if (tablePos >= 0) tr.setSelection(TextSelection.near(tr.doc.resolve(tablePos + 3)));
|
|
101
|
+
dispatch(tr.scrollIntoView());
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function createTableGridPanel(onPick, label, gridLabel) {
|
|
107
|
+
let rows = 1;
|
|
108
|
+
let cols = 1;
|
|
109
|
+
const cells = [];
|
|
110
|
+
const caption = h("div", { className: "nova-grid-caption", "aria-live": "polite" });
|
|
111
|
+
const grid = h("div", { className: "nova-grid", role: "grid", "aria-label": gridLabel });
|
|
112
|
+
const paint = () => {
|
|
113
|
+
for (const cell of cells) {
|
|
114
|
+
const r = Number(cell.dataset.row);
|
|
115
|
+
const c = Number(cell.dataset.col);
|
|
116
|
+
cell.classList.toggle("is-on", r <= rows && c <= cols);
|
|
117
|
+
cell.tabIndex = r === rows && c === cols ? 0 : -1;
|
|
118
|
+
}
|
|
119
|
+
caption.textContent = label(rows, cols);
|
|
120
|
+
};
|
|
121
|
+
for (let r = 1; r <= MAX_GRID; r++) {
|
|
122
|
+
for (let c = 1; c <= MAX_GRID; c++) {
|
|
123
|
+
const cell = h("button", {
|
|
124
|
+
type: "button",
|
|
125
|
+
className: "nova-grid-cell",
|
|
126
|
+
role: "gridcell",
|
|
127
|
+
"aria-label": label(r, c),
|
|
128
|
+
"data-row": String(r),
|
|
129
|
+
"data-col": String(c)
|
|
130
|
+
});
|
|
131
|
+
cell.addEventListener("mouseenter", () => {
|
|
132
|
+
rows = r;
|
|
133
|
+
cols = c;
|
|
134
|
+
paint();
|
|
135
|
+
});
|
|
136
|
+
cell.addEventListener("click", () => onPick(r, c));
|
|
137
|
+
cells.push(cell);
|
|
138
|
+
grid.append(cell);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
grid.addEventListener("keydown", (event) => {
|
|
142
|
+
const moves = {
|
|
143
|
+
ArrowRight: [0, 1],
|
|
144
|
+
ArrowLeft: [0, -1],
|
|
145
|
+
ArrowDown: [1, 0],
|
|
146
|
+
ArrowUp: [-1, 0]
|
|
147
|
+
};
|
|
148
|
+
const move = moves[event.key];
|
|
149
|
+
if (!move) return;
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
rows = Math.min(MAX_GRID, Math.max(1, rows + move[0]));
|
|
152
|
+
cols = Math.min(MAX_GRID, Math.max(1, cols + move[1]));
|
|
153
|
+
paint();
|
|
154
|
+
cells[(rows - 1) * MAX_GRID + (cols - 1)].focus();
|
|
155
|
+
});
|
|
156
|
+
paint();
|
|
157
|
+
return h("div", { className: "nova-grid-panel" }, grid, caption);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export {
|
|
161
|
+
loadTables,
|
|
162
|
+
tableCommands,
|
|
163
|
+
setCellBackground,
|
|
164
|
+
hasHeaderRow,
|
|
165
|
+
hasHeaderColumn,
|
|
166
|
+
getTableProps,
|
|
167
|
+
setTableProps,
|
|
168
|
+
getCellProps,
|
|
169
|
+
setCellProps,
|
|
170
|
+
sortTable,
|
|
171
|
+
MAX_GRID,
|
|
172
|
+
tableRect,
|
|
173
|
+
createTable,
|
|
174
|
+
insertTable,
|
|
175
|
+
createTableGridPanel
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=chunk-GHVB6SV4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tables.ts"],"sourcesContent":["/**\n * Tables in the first load are only the light part: creating and inserting a table, the size grid,\n * the table's position on screen. The mechanics (cell selection, column widths, row and column\n * commands, sorting, properties) are the ./table module on prosemirror-tables: ~10 KB gzip, loaded\n * in the background right after the editor is created and part of `editor.ready`.\n *\n * The commands and helpers of the mechanics are available here as stand-ins with the same API:\n * until the module has loaded (the first milliseconds), a command is \"unavailable\" (false), like any command that doesn't apply.\n */\nimport { type Node as PMNode } from 'prosemirror-model';\nimport { TextSelection, type Command, type EditorState, type Plugin } from 'prosemirror-state';\nimport type { Editor } from './editor';\nimport { schema as baseSchema, type NovaSchema } from './schema';\nimport type { CellProps, SortDirection, TableProps } from './table';\nimport { isInTable } from './table-nodes';\nimport { h } from './ui/dom';\nimport { replaceSelectionWithBlock } from './commands';\n\nexport { isInTable };\n\n// ---------- lazy mechanics ----------\n\ntype TableCommandName =\n | 'addRowBefore'\n | 'addRowAfter'\n | 'deleteRow'\n | 'addColumnBefore'\n | 'addColumnAfter'\n | 'deleteColumn'\n | 'mergeCells'\n | 'splitCell'\n | 'toggleHeaderRow'\n | 'toggleHeaderColumn'\n | 'deleteTable';\n\n/**\n * What the table mechanics (./table) give the light part. An explicit interface instead of `import type * as`:\n * easier to read, and the .d.ts build doesn't trip over mutual imports between modules.\n */\ninterface TableModule {\n tableCommands: Record<TableCommandName, Command>;\n tablePlugins(): Plugin[];\n setCellBackground(color: string | null): Command;\n hasHeaderRow(state: EditorState): boolean;\n hasHeaderColumn(state: EditorState): boolean;\n isCellSelection(state: EditorState): boolean;\n getTableProps(state: EditorState): TableProps | null;\n setTableProps(props: TableProps): Command;\n getCellProps(state: EditorState): Required<CellProps> | null;\n setCellProps(props: CellProps): Command;\n sortTable(direction: SortDirection, locale?: string): Command;\n}\n\nlet tables: TableModule | null = null;\nlet loading: Promise<TableModule | null> | null = null;\n\n/** Loads the table mechanics (once per page). On a network failure it retries on the next call. */\nexport function loadTables(): Promise<TableModule | null> {\n loading ??= import('./table').then(\n (module) => (tables = module),\n (error: unknown) => {\n console.warn('[nova] failed to load table editing', error);\n loading = null;\n return null;\n },\n );\n return loading;\n}\n\n/** The loaded table mechanics module, or null. */\nexport function loadedTables(): TableModule | null {\n return tables;\n}\n\nconst lazy =\n (name: TableCommandName): Command =>\n (state, dispatch, view) =>\n tables ? tables.tableCommands[name](state, dispatch, view) : false;\n\n/** Row, column and cell commands (public API; unavailable until the mechanics have loaded). */\nexport const tableCommands: Record<TableCommandName, Command> = {\n addRowBefore: lazy('addRowBefore'),\n addRowAfter: lazy('addRowAfter'),\n deleteRow: lazy('deleteRow'),\n addColumnBefore: lazy('addColumnBefore'),\n addColumnAfter: lazy('addColumnAfter'),\n deleteColumn: lazy('deleteColumn'),\n mergeCells: lazy('mergeCells'),\n splitCell: lazy('splitCell'),\n toggleHeaderRow: lazy('toggleHeaderRow'),\n toggleHeaderColumn: lazy('toggleHeaderColumn'),\n deleteTable: lazy('deleteTable'),\n};\n\n/** Background of the selected cells (null removes it). */\nexport function setCellBackground(color: string | null): Command {\n return (state, dispatch, view) =>\n tables ? tables.setCellBackground(color)(state, dispatch, view) : false;\n}\n\nexport function hasHeaderRow(state: EditorState): boolean {\n return tables?.hasHeaderRow(state) ?? false;\n}\n\nexport function hasHeaderColumn(state: EditorState): boolean {\n return tables?.hasHeaderColumn(state) ?? false;\n}\n\n/** Whether several cells are selected (for \"merge\"). */\nexport function isCellSelection(state: EditorState): boolean {\n return tables?.isCellSelection(state) ?? false;\n}\n\nexport function getTableProps(state: EditorState): TableProps | null {\n return tables?.getTableProps(state) ?? null;\n}\n\nexport function setTableProps(props: TableProps): Command {\n return (state, dispatch, view) =>\n tables ? tables.setTableProps(props)(state, dispatch, view) : false;\n}\n\nexport function getCellProps(state: EditorState): Required<CellProps> | null {\n return tables?.getCellProps(state) ?? null;\n}\n\nexport function setCellProps(props: CellProps): Command {\n return (state, dispatch, view) =>\n tables ? tables.setCellProps(props)(state, dispatch, view) : false;\n}\n\nexport function sortTable(direction: SortDirection, locale?: string): Command {\n return (state, dispatch, view) =>\n tables ? tables.sortTable(direction, locale)(state, dispatch, view) : false;\n}\n\n// ---------- the light part ----------\n\nexport const MAX_GRID = 10;\n\n/** The DOM rectangle of the current table (to position the context toolbar). */\nexport function tableRect(editor: Editor): DOMRect | null {\n const { $from } = editor.view.state.selection;\n for (let depth = $from.depth; depth > 0; depth--) {\n if ($from.node(depth).type.spec.tableRole === 'table') {\n const dom = editor.view.nodeDOM($from.before(depth)) as HTMLElement | null;\n return dom?.getBoundingClientRect() ?? null;\n }\n }\n return null;\n}\n\n/** Create a rows×cols table; the first row is headers when withHeader. */\nexport function createTable(\n rows: number,\n cols: number,\n withHeader = true,\n schema: NovaSchema = baseSchema,\n): PMNode {\n const { table, table_row, table_cell, table_header, paragraph } = schema.nodes;\n const rowNodes: PMNode[] = [];\n for (let r = 0; r < rows; r++) {\n const cellType = withHeader && r === 0 ? table_header : table_cell;\n const cells: PMNode[] = [];\n for (let c = 0; c < cols; c++) cells.push(cellType.create(null, paragraph.create()));\n rowNodes.push(table_row.create(null, cells));\n }\n return table.create(null, rowNodes);\n}\n\n/** Insert a table in place of the selection and put the cursor in its first cell. */\nexport function insertTable(rows: number, cols: number, withHeader = true): Command {\n return (state, dispatch) => {\n if (rows < 1 || cols < 1 || rows > 100 || cols > 50) return false;\n // Tables inside tables aren't inserted, as in most editors.\n if (isInTable(state)) return false;\n if (dispatch) {\n const node = createTable(rows, cols, withHeader, state.schema as NovaSchema);\n const tr = replaceSelectionWithBlock(state.tr, node);\n // Nodes are immutable: the inserted table is found by object reference.\n let tablePos = -1;\n tr.doc.descendants((n, pos) => {\n if (n === node) tablePos = pos;\n return tablePos < 0;\n });\n // +3: table → row → cell → inside the first paragraph.\n if (tablePos >= 0) tr.setSelection(TextSelection.near(tr.doc.resolve(tablePos + 3)));\n dispatch(tr.scrollIntoView());\n }\n return true;\n };\n}\n\n/**\n * The table size picker: a grid up to 10×10, highlighted on hover/arrows,\n * with a \"3 × 4\" label. Works from the keyboard (arrows + Enter).\n */\nexport function createTableGridPanel(\n onPick: (rows: number, cols: number) => void,\n label: (rows: number, cols: number) => string,\n gridLabel: string,\n): HTMLElement {\n let rows = 1;\n let cols = 1;\n const cells: HTMLButtonElement[] = [];\n const caption = h('div', { className: 'nova-grid-caption', 'aria-live': 'polite' });\n const grid = h('div', { className: 'nova-grid', role: 'grid', 'aria-label': gridLabel });\n\n const paint = () => {\n for (const cell of cells) {\n const r = Number(cell.dataset.row);\n const c = Number(cell.dataset.col);\n cell.classList.toggle('is-on', r <= rows && c <= cols);\n cell.tabIndex = r === rows && c === cols ? 0 : -1;\n }\n caption.textContent = label(rows, cols);\n };\n\n for (let r = 1; r <= MAX_GRID; r++) {\n for (let c = 1; c <= MAX_GRID; c++) {\n const cell = h('button', {\n type: 'button',\n className: 'nova-grid-cell',\n role: 'gridcell',\n 'aria-label': label(r, c),\n 'data-row': String(r),\n 'data-col': String(c),\n });\n cell.addEventListener('mouseenter', () => {\n rows = r;\n cols = c;\n paint();\n });\n cell.addEventListener('click', () => onPick(r, c));\n cells.push(cell);\n grid.append(cell);\n }\n }\n\n grid.addEventListener('keydown', (event) => {\n const moves: Record<string, [number, number]> = {\n ArrowRight: [0, 1],\n ArrowLeft: [0, -1],\n ArrowDown: [1, 0],\n ArrowUp: [-1, 0],\n };\n const move = moves[event.key];\n if (!move) return;\n event.preventDefault();\n rows = Math.min(MAX_GRID, Math.max(1, rows + move[0]));\n cols = Math.min(MAX_GRID, Math.max(1, cols + move[1]));\n paint();\n cells[(rows - 1) * MAX_GRID + (cols - 1)]!.focus();\n });\n\n paint();\n return h('div', { className: 'nova-grid-panel' }, grid, caption);\n}\n"],"mappings":";;;;;;;;;;;;AASA,OAAoC;AACpC,SAAS,qBAAkE;AA2C3E,IAAI,SAA6B;AACjC,IAAI,UAA8C;AAG3C,SAAS,aAA0C;AACxD,cAAY,OAAO,qBAAS,E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AAA,MACR,CAAC;AACD,WAAK,iBAAiB,SAAS,MAAM,OAAO,GAAG,CAAC,CAAC;AACjD,YAAM,KAAK,IAAI;AACf,WAAK,OAAO,IAAI;AAAA,IAClB;AAAA,EACF;AAEA,OAAK,iBAAiB,WAAW,CAAC,UAAU;AAC1C,UAAM,QAA0C;AAAA,MAC9C,YAAY,CAAC,GAAG,CAAC;AAAA,MACjB,WAAW,CAAC,GAAG,EAAE;AAAA,MACjB,WAAW,CAAC,GAAG,CAAC;AAAA,MAChB,SAAS,CAAC,IAAI,CAAC;AAAA,IACjB;AACA,UAAM,OAAO,MAAM,MAAM,GAAG;AAC5B,QAAI,CAAC,KAAM;AACX,UAAM,eAAe;AACrB,WAAO,KAAK,IAAI,UAAU,KAAK,IAAI,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC;AACrD,WAAO,KAAK,IAAI,UAAU,KAAK,IAAI,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC;AACrD,UAAM;AACN,WAAO,OAAO,KAAK,YAAY,OAAO,EAAE,EAAG,MAAM;AAAA,EACnD,CAAC;AAED,QAAM;AACN,SAAO,EAAE,OAAO,EAAE,WAAW,kBAAkB,GAAG,MAAM,OAAO;AACjE;","names":["schema"]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
activeElement,
|
|
3
|
+
isRtl,
|
|
4
|
+
listenDocument
|
|
5
|
+
} from "./chunk-QU3KXMYT.js";
|
|
6
|
+
|
|
7
|
+
// src/ui/popover.ts
|
|
8
|
+
var GAP = 6;
|
|
9
|
+
var VIEWPORT_PADDING = 8;
|
|
10
|
+
function visibleArea() {
|
|
11
|
+
const vv = window.visualViewport;
|
|
12
|
+
if (!vv) return { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight };
|
|
13
|
+
return {
|
|
14
|
+
left: vv.offsetLeft,
|
|
15
|
+
top: vv.offsetTop,
|
|
16
|
+
right: vv.offsetLeft + vv.width,
|
|
17
|
+
bottom: vv.offsetTop + vv.height
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function positionFloating(floating, anchorRect, placement) {
|
|
21
|
+
const area = visibleArea();
|
|
22
|
+
const width = floating.offsetWidth;
|
|
23
|
+
const height = floating.offsetHeight;
|
|
24
|
+
const spaceBelow = area.bottom - anchorRect.bottom;
|
|
25
|
+
const spaceAbove = anchorRect.top - area.top;
|
|
26
|
+
const preferTop = placement === "top-start" || placement === "top-end";
|
|
27
|
+
const placeTop = preferTop ? spaceAbove >= height + GAP || spaceAbove > spaceBelow : spaceBelow < height + GAP && spaceAbove > spaceBelow;
|
|
28
|
+
let top = placeTop ? anchorRect.top - height - GAP : anchorRect.bottom + GAP;
|
|
29
|
+
const rtl = isRtl(floating);
|
|
30
|
+
const alignEnd = (placement === "bottom-end" || placement === "top-end") !== rtl;
|
|
31
|
+
let left = placement === "bottom" ? anchorRect.left + anchorRect.width / 2 - width / 2 : alignEnd ? anchorRect.right - width : anchorRect.left;
|
|
32
|
+
left = Math.max(
|
|
33
|
+
area.left + VIEWPORT_PADDING,
|
|
34
|
+
Math.min(left, area.right - width - VIEWPORT_PADDING)
|
|
35
|
+
);
|
|
36
|
+
top = Math.max(
|
|
37
|
+
area.top + VIEWPORT_PADDING,
|
|
38
|
+
Math.min(top, area.bottom - height - VIEWPORT_PADDING)
|
|
39
|
+
);
|
|
40
|
+
floating.style.left = `${Math.round(left)}px`;
|
|
41
|
+
floating.style.top = `${Math.round(top)}px`;
|
|
42
|
+
floating.dataset.side = placeTop ? "top" : "bottom";
|
|
43
|
+
}
|
|
44
|
+
var openStack = [];
|
|
45
|
+
var Popover = class {
|
|
46
|
+
el;
|
|
47
|
+
options;
|
|
48
|
+
closed = false;
|
|
49
|
+
unlisten = [];
|
|
50
|
+
constructor(options) {
|
|
51
|
+
this.options = options;
|
|
52
|
+
this.el = document.createElement("div");
|
|
53
|
+
this.el.className = `nova-popover ${options.className ?? ""}`.trim();
|
|
54
|
+
this.el.append(options.content);
|
|
55
|
+
options.host.append(this.el);
|
|
56
|
+
this.reposition();
|
|
57
|
+
this.unlisten = [
|
|
58
|
+
listenDocument(this.el, "keydown", this.onKeyDown),
|
|
59
|
+
listenDocument(this.el, "pointerdown", this.onPointerDown)
|
|
60
|
+
];
|
|
61
|
+
openStack.push(this);
|
|
62
|
+
window.addEventListener("resize", this.reposition);
|
|
63
|
+
window.addEventListener("scroll", this.reposition, true);
|
|
64
|
+
}
|
|
65
|
+
get isOpen() {
|
|
66
|
+
return !this.closed;
|
|
67
|
+
}
|
|
68
|
+
reposition = () => {
|
|
69
|
+
if (this.closed) return;
|
|
70
|
+
const { anchor, placement = "bottom-start" } = this.options;
|
|
71
|
+
const rect = typeof anchor === "function" ? anchor() : anchor.getBoundingClientRect();
|
|
72
|
+
positionFloating(this.el, rect, placement);
|
|
73
|
+
};
|
|
74
|
+
close(reason = "api") {
|
|
75
|
+
if (this.closed) return;
|
|
76
|
+
this.closed = true;
|
|
77
|
+
openStack.splice(openStack.indexOf(this), 1);
|
|
78
|
+
this.unlisten.forEach((stop) => stop());
|
|
79
|
+
window.removeEventListener("resize", this.reposition);
|
|
80
|
+
window.removeEventListener("scroll", this.reposition, true);
|
|
81
|
+
this.el.remove();
|
|
82
|
+
this.options.onClose?.(reason);
|
|
83
|
+
}
|
|
84
|
+
/** Whether focus was inside the panel when it closed (then it goes back to the button). */
|
|
85
|
+
focusWasInside = false;
|
|
86
|
+
onKeyDown = (event, target) => {
|
|
87
|
+
if (event.key !== "Escape" || event.defaultPrevented) return;
|
|
88
|
+
if (openStack[openStack.length - 1] !== this) return;
|
|
89
|
+
if (target?.closest?.(".nova-dialog")) return;
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
event.stopPropagation();
|
|
92
|
+
this.focusWasInside = this.el.contains(activeElement(this.el));
|
|
93
|
+
this.close("escape");
|
|
94
|
+
};
|
|
95
|
+
onPointerDown = (_event, target) => {
|
|
96
|
+
if (this.options.dismissOnOutside === false) return;
|
|
97
|
+
if (this.el.contains(target)) return;
|
|
98
|
+
if (this.options.ignore?.some((el) => el.contains(target))) return;
|
|
99
|
+
this.close("outside");
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
visibleArea,
|
|
105
|
+
positionFloating,
|
|
106
|
+
Popover
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=chunk-GTLE2HEW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/popover.ts"],"sourcesContent":["import { activeElement, isRtl, listenDocument } from './dom';\n\nexport type Placement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end' | 'bottom';\n\nexport type Anchor = HTMLElement | (() => DOMRect);\n\nconst GAP = 6;\nconst VIEWPORT_PADDING = 8;\n\n/**\n * The visible part of the window in getBoundingClientRect and position: fixed coordinates. On a phone with the\n * keyboard open it is smaller than the window and shifts with scrolling (visualViewport); window.innerHeight there is\n * the height of the visible part, while coordinates are relative to the whole page: mixing them made the panel drift.\n */\nexport function visibleArea(): { left: number; top: number; right: number; bottom: number } {\n const vv = window.visualViewport;\n if (!vv) return { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight };\n return {\n left: vv.offsetLeft,\n top: vv.offsetTop,\n right: vv.offsetLeft + vv.width,\n bottom: vv.offsetTop + vv.height,\n };\n}\n\n/**\n * Positions a floating element (position: fixed) relative to an anchor:\n * below it, or above when it doesn't fit; horizontally it is kept within the window edges.\n */\nexport function positionFloating(\n floating: HTMLElement,\n anchorRect: DOMRect,\n placement: Placement,\n): void {\n const area = visibleArea();\n // The size without transforms: the panel appears with an animation (scale 0.98), and getBoundingClientRect\n // is smaller than the real size at that moment, so an edge aligned with the button's right edge drifted by 2%.\n const width = floating.offsetWidth;\n const height = floating.offsetHeight;\n\n const spaceBelow = area.bottom - anchorRect.bottom;\n const spaceAbove = anchorRect.top - area.top;\n const preferTop = placement === 'top-start' || placement === 'top-end';\n const placeTop = preferTop\n ? spaceAbove >= height + GAP || spaceAbove > spaceBelow\n : spaceBelow < height + GAP && spaceAbove > spaceBelow;\n\n let top = placeTop ? anchorRect.top - height - GAP : anchorRect.bottom + GAP;\n // start/end are the edges of the start and end of the line: right to left, the \"start\" is the right edge.\n const rtl = isRtl(floating);\n const alignEnd = (placement === 'bottom-end' || placement === 'top-end') !== rtl;\n let left =\n placement === 'bottom'\n ? anchorRect.left + anchorRect.width / 2 - width / 2\n : alignEnd\n ? anchorRect.right - width\n : anchorRect.left;\n\n left = Math.max(\n area.left + VIEWPORT_PADDING,\n Math.min(left, area.right - width - VIEWPORT_PADDING),\n );\n top = Math.max(\n area.top + VIEWPORT_PADDING,\n Math.min(top, area.bottom - height - VIEWPORT_PADDING),\n );\n\n floating.style.left = `${Math.round(left)}px`;\n floating.style.top = `${Math.round(top)}px`;\n floating.dataset.side = placeTop ? 'top' : 'bottom';\n}\n\nexport interface PopoverOptions {\n host: HTMLElement;\n anchor: Anchor;\n content: HTMLElement;\n placement?: Placement;\n className?: string;\n /** Close on a click outside the panel (yes by default). */\n dismissOnOutside?: boolean;\n /** Elements whose clicks don't count as \"outside\" (for example, the anchor button). */\n ignore?: HTMLElement[];\n onClose?: (reason: 'escape' | 'outside' | 'api') => void;\n}\n\nconst openStack: Popover[] = [];\n\n/** A floating panel: a menu, the color palette, the link panel, the toolbar overflow. */\nexport class Popover {\n readonly el: HTMLDivElement;\n private readonly options: PopoverOptions;\n private closed = false;\n private unlisten: (() => void)[] = [];\n\n constructor(options: PopoverOptions) {\n this.options = options;\n this.el = document.createElement('div');\n this.el.className = `nova-popover ${options.className ?? ''}`.trim();\n this.el.append(options.content);\n options.host.append(this.el);\n\n this.reposition();\n // Escape is caught on the document: a panel opened with the mouse doesn't take focus from the text,\n // but it still has to close on Escape.\n this.unlisten = [\n listenDocument(this.el, 'keydown', this.onKeyDown),\n listenDocument(this.el, 'pointerdown', this.onPointerDown),\n ];\n openStack.push(this);\n window.addEventListener('resize', this.reposition);\n window.addEventListener('scroll', this.reposition, true);\n }\n\n get isOpen(): boolean {\n return !this.closed;\n }\n\n reposition = (): void => {\n if (this.closed) return;\n const { anchor, placement = 'bottom-start' } = this.options;\n const rect = typeof anchor === 'function' ? anchor() : anchor.getBoundingClientRect();\n positionFloating(this.el, rect, placement);\n };\n\n close(reason: 'escape' | 'outside' | 'api' = 'api'): void {\n if (this.closed) return;\n this.closed = true;\n openStack.splice(openStack.indexOf(this), 1);\n this.unlisten.forEach((stop) => stop());\n window.removeEventListener('resize', this.reposition);\n window.removeEventListener('scroll', this.reposition, true);\n this.el.remove();\n this.options.onClose?.(reason);\n }\n\n /** Whether focus was inside the panel when it closed (then it goes back to the button). */\n focusWasInside = false;\n\n private onKeyDown = (event: KeyboardEvent, target: Node | null): void => {\n if (event.key !== 'Escape' || event.defaultPrevented) return;\n // Nested panels (\"⋯\" → menu): Escape closes only the top one.\n if (openStack[openStack.length - 1] !== this) return;\n // If a dialog is open on top, Escape belongs to it.\n if ((target as Element | null)?.closest?.('.nova-dialog')) return;\n event.preventDefault();\n event.stopPropagation();\n this.focusWasInside = this.el.contains(activeElement(this.el));\n this.close('escape');\n };\n\n private onPointerDown = (_event: PointerEvent, target: Node | null): void => {\n if (this.options.dismissOnOutside === false) return;\n if (this.el.contains(target)) return;\n if (this.options.ignore?.some((el) => el.contains(target))) return;\n this.close('outside');\n };\n}\n"],"mappings":";;;;;;;AAMA,IAAM,MAAM;AACZ,IAAM,mBAAmB;AAOlB,SAAS,cAA4E;AAC1F,QAAM,KAAK,OAAO;AAClB,MAAI,CAAC,GAAI,QAAO,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,OAAO,YAAY,QAAQ,OAAO,YAAY;AACxF,SAAO;AAAA,IACL,MAAM,GAAG;AAAA,IACT,KAAK,GAAG;AAAA,IACR,OAAO,GAAG,aAAa,GAAG;AAAA,IAC1B,QAAQ,GAAG,YAAY,GAAG;AAAA,EAC5B;AACF;AAMO,SAAS,iBACd,UACA,YACA,WACM;AACN,QAAM,OAA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Q,qBAAqB,MAAO;AAC7C,QAAI,KAAK,GAAG,SAAS,MAAM,EAAG;AAC9B,QAAI,KAAK,QAAQ,QAAQ,KAAK,CAAC,OAAO,GAAG,SAAS,MAAM,CAAC,EAAG;AAC5D,SAAK,MAAM,SAAS;AAAA,EACtB;AACF;","names":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
definePlugin
|
|
3
|
+
} from "./chunk-V7WUHUHM.js";
|
|
4
|
+
|
|
5
|
+
// src/plugins/mentions.ts
|
|
6
|
+
var MENTION_ID_RE = /^[\w.@:+-]{1,128}$/;
|
|
7
|
+
var MAX_NAME = 80;
|
|
8
|
+
var cleanName = (value) => value.replace(/^@/, "").trim().slice(0, MAX_NAME);
|
|
9
|
+
async function findMentionUsers(fetch, query, max = 8) {
|
|
10
|
+
const result = await fetch(query);
|
|
11
|
+
if (!Array.isArray(result)) return [];
|
|
12
|
+
return result.filter((u) => u && typeof u.id === "string" && MENTION_ID_RE.test(u.id) && u.name).slice(0, max).map((u) => ({
|
|
13
|
+
id: u.id,
|
|
14
|
+
name: cleanName(String(u.name)),
|
|
15
|
+
...u.description ? { description: String(u.description).slice(0, 120) } : {}
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
function getMentions(editorOrDoc) {
|
|
19
|
+
const doc = "view" in editorOrDoc ? editorOrDoc.view.state.doc : editorOrDoc;
|
|
20
|
+
const seen = /* @__PURE__ */ new Map();
|
|
21
|
+
doc.descendants((node) => {
|
|
22
|
+
if (node.type.name === "mention" && !seen.has(node.attrs.id)) {
|
|
23
|
+
seen.set(node.attrs.id, {
|
|
24
|
+
id: node.attrs.id,
|
|
25
|
+
name: node.attrs.name
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return [...seen.values()];
|
|
30
|
+
}
|
|
31
|
+
var mentions_default = definePlugin({
|
|
32
|
+
name: "mentions",
|
|
33
|
+
nodes: {
|
|
34
|
+
mention: {
|
|
35
|
+
group: "inline",
|
|
36
|
+
inline: true,
|
|
37
|
+
atom: true,
|
|
38
|
+
selectable: false,
|
|
39
|
+
attrs: { id: {}, name: { default: "" } },
|
|
40
|
+
parseDOM: [
|
|
41
|
+
{
|
|
42
|
+
tag: "span[data-mention]",
|
|
43
|
+
getAttrs: (dom) => {
|
|
44
|
+
const el = dom;
|
|
45
|
+
const id = el.getAttribute("data-mention") ?? "";
|
|
46
|
+
return MENTION_ID_RE.test(id) ? { id, name: cleanName(el.textContent ?? "") } : false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
// The document may come from JSON: the id is checked on output too, the name is only text.
|
|
51
|
+
toDOM: (node) => [
|
|
52
|
+
"span",
|
|
53
|
+
{ "data-mention": MENTION_ID_RE.test(node.attrs.id) ? node.attrs.id : null },
|
|
54
|
+
`@${cleanName(String(node.attrs.name))}`
|
|
55
|
+
],
|
|
56
|
+
leafText: (node) => `@${cleanName(String(node.attrs.name))}`
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
load: () => import("./mentions-ui-O4IPWQT4.js")
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
findMentionUsers,
|
|
64
|
+
getMentions,
|
|
65
|
+
mentions_default
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=chunk-GXXXLPDQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugins/mentions.ts"],"sourcesContent":["import type { Node as PMNode } from 'prosemirror-model';\nimport type { Editor } from '../editor';\nimport { definePlugin } from '../plugins';\n\n/**\n * The mentions plugin: \"@\" in the text → a list of people → a mention\n * `<span data-mention=\"id\">@Name</span>`. `plugins: ['mentions']`, the people come from\n * `pluginOptions.mentions.fetch` (usually a search in your API). Comments use the same source for\n * \"@\" in a comment field. This part is the node and shared functions; the list while typing \"@\" is in mentions-ui.ts.\n */\n\nexport interface MentionUser {\n id: string;\n name: string;\n /** A second line in the list: a job title, an e-mail. */\n description?: string;\n}\n\nexport interface MentionsOptions {\n /** Find people by the start of their name (the query without \"@\"). May return a Promise. */\n fetch: (query: string) => MentionUser[] | Promise<MentionUser[]>;\n /** Someone was mentioned in the text (for notifications — or collect them on save with getMentions). */\n onMention?: (user: MentionUser, editor: Editor) => void;\n /** How many to show in the list (8 by default). */\n maxResults?: number;\n}\n\n/** A user id: UUIDs, numbers, e-mails, logins, without spaces, quotes or angle brackets. */\nexport const MENTION_ID_RE = /^[\\w.@:+-]{1,128}$/;\nconst MAX_NAME = 80;\n\nconst cleanName = (value: string) => value.replace(/^@/, '').trim().slice(0, MAX_NAME);\n\n/** Matching people: id and name checked and trimmed (the data comes from someone else's API). */\nexport async function findMentionUsers(\n fetch: MentionsOptions['fetch'],\n query: string,\n max = 8,\n): Promise<MentionUser[]> {\n const result = await fetch(query);\n if (!Array.isArray(result)) return [];\n return result\n .filter((u) => u && typeof u.id === 'string' && MENTION_ID_RE.test(u.id) && u.name)\n .slice(0, max)\n .map((u) => ({\n id: u.id,\n name: cleanName(String(u.name)),\n ...(u.description ? { description: String(u.description).slice(0, 120) } : {}),\n }));\n}\n\n/** Who is mentioned in the document (no repeats, in order of appearance) — for example, to notify them. */\nexport function getMentions(editorOrDoc: Editor | PMNode): MentionUser[] {\n const doc = 'view' in editorOrDoc ? editorOrDoc.view.state.doc : editorOrDoc;\n const seen = new Map<string, MentionUser>();\n doc.descendants((node) => {\n if (node.type.name === 'mention' && !seen.has(node.attrs.id as string)) {\n seen.set(node.attrs.id as string, {\n id: node.attrs.id as string,\n name: node.attrs.name as string,\n });\n }\n });\n return [...seen.values()];\n}\n\nexport default definePlugin({\n name: 'mentions',\n nodes: {\n mention: {\n group: 'inline',\n inline: true,\n atom: true,\n selectable: false,\n attrs: { id: {}, name: { default: '' } },\n parseDOM: [\n {\n tag: 'span[data-mention]',\n getAttrs: (dom) => {\n const el = dom as HTMLElement;\n const id = el.getAttribute('data-mention') ?? '';\n return MENTION_ID_RE.test(id) ? { id, name: cleanName(el.textContent ?? '') } : false;\n },\n },\n ],\n // The document may come from JSON: the id is checked on output too, the name is only text.\n toDOM: (node) => [\n 'span',\n { 'data-mention': MENTION_ID_RE.test(node.attrs.id as string) ? node.attrs.id : null },\n `@${cleanName(String(node.attrs.name))}`,\n ],\n leafText: (node) => `@${cleanName(String(node.attrs.name))}`,\n },\n },\n load: () => import('./mentions-ui'),\n});\n"],"mappings":";;;;;AA4BO,IAAM,gBAAgB;AAC7B,IAAM,WAAW;AAEjB,IAAM,YAAY,CAAC,UAAkB,MAAM,QAAQ,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ;AAGrF,eAAsB,iBACpB,OACA,OACA,MAAM,GACkB;AACxB,QAAM,SAAS,MAAM,MAAM,KAAK;AAChC,MAAI,CAAC,MAAM,QAAQ,MAAM,EAAG,QAAO,CAAC;AACpC,SAAO,OACJ,OAAO,CAAC,MAAM,KAAK,OAAO,EAAE,OAAO,YAAY,cAAc,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EACjF,MAAM,GAAG,GAAG,EACZ,IAAI,CAAC,OAAO;AAAA,IACX,IAAI,EAAE;AAAA,IACN,MAAM,UAAU,OAAO,EAAE,IAAI,CAAC;AAAA,IAC9B,GAAI,EAAE,cAAc,EAAE,aAAa,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC;AAAA,EAC9E,EAAE;AACN;AAGO,SAAS,YAAY,aAA6C;AACvE,QAAM,MAAM,UAAU,cAAc,YAAY,KAAK,MAAM,MAAM;AACjE,QAAM,OAAO,oBAAI,IAAyB;AAC1C,MAAI,YAAY,CAAC,SAAS;AACxB,QAAI,KAAK,KAAK,SAAS,aAAa,CAAC,KAAK,IAAI,KAAK,MAAM,EAAY,GAAG;AACtE,WAAK,IAAI,KAAK,MAAM,IAAc;AAAA,QAChC,IAAI,KAAK,MAAM;AAAA,QACf,MAAM,KAAK,MAAM;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACD,SAAO,CAAC,GAAG,KAAK,OAAO,CAAC;AAC1B;AAEA,IAAO,mBAAQ,aAAa;AAAA,EAC1B,MAAM;AAAA,EACN,OAAO;AAAA,IACL,SAAS;AAAA,MACP,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,OAAO,EAAE,IAAI,CAAC,GAAG,MAAM,EAAE,SAAS,GAAG,EAAE;AAAA,MACvC,UAAU;AAAA,QACR;AAAA,UACE,KAAK;AAAA,UACL,UAAU,CAAC,QAAQ;AACjB,kBAAM,KAAK;AACX,kBAAM,KAAK,GAAG,aAAa,cAAc,KAAK;AAC9C,mBAAO,cAAc,KAAK,EAAE,IAAI,EAAE,IAAI,MAAM,UAAU,GAAG,eAAe,EAAE,EAAE,IAAI;AAAA,UAClF;AAAA,QACF;AAAA,MACF;AAAA;AAAA,MAEA,OAAO,CAAC,SAAS;AAAA,QACf;AAAA,QACA,EAAE,gBAAgB,cAAc,KAAK,KAAK,MAAM,EAAY,IAAI,KAAK,MAAM,KAAK,KAAK;AAAA,QACrF,IAAI,UAAU,OAAO,KAAK,MAAM,IAAI,CAAC,CAAC;AAAA,MACxC;AAAA,MACA,UAAU,CAAC,SAAS,IAAI,UAAU,OAAO,KAAK,MAAM,IAAI,CAAC,CAAC;AAAA,IAC5D;AAAA,EACF;AAAA,EACA,MAAM,MAAM,OAAO,2BAAe;AACpC,CAAC;","names":[]}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import {
|
|
2
|
+
icons
|
|
3
|
+
} from "./chunk-ADRPQLZ2.js";
|
|
4
|
+
import {
|
|
5
|
+
pickLabels
|
|
6
|
+
} from "./chunk-DEYYVZ7O.js";
|
|
7
|
+
import {
|
|
8
|
+
definePlugin
|
|
9
|
+
} from "./chunk-V7WUHUHM.js";
|
|
10
|
+
import {
|
|
11
|
+
h,
|
|
12
|
+
icon
|
|
13
|
+
} from "./chunk-QU3KXMYT.js";
|
|
14
|
+
|
|
15
|
+
// src/plugins/accordion.ts
|
|
16
|
+
import { Plugin, PluginKey, TextSelection } from "prosemirror-state";
|
|
17
|
+
|
|
18
|
+
// nova-raw-css:/home/runner/work/novaprose/novaprose/packages/core/src/plugins/accordion.css?raw
|
|
19
|
+
var accordion_default = '.nova-details{position:relative;margin:0 0 .75em;padding-block:6px;padding-inline:34px 12px;border:1px solid var(--nova-border);border-radius:var(--nova-radius-sm)}.nova-details-toggle{position:absolute;top:7px;inset-inline-start:6px;display:flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;border-radius:4px;background:none;color:var(--nova-muted);cursor:pointer}.nova-details-toggle:hover{background:var(--nova-hover);color:var(--nova-fg)}.nova-details-toggle:focus-visible{outline:2px solid var(--nova-accent);outline-offset:1px}.nova-details-toggle svg{width:16px;height:16px;transition:transform .12s ease}.nova-details:not(.nova-details-open)>.nova-details-toggle svg{transform:rotate(-90deg)}[dir=rtl] .nova-details:not(.nova-details-open)>.nova-details-toggle svg{transform:rotate(90deg)}.nova-details-content>summary{position:relative;display:block;margin:0;font-weight:600;cursor:text;list-style:none}.nova-details-content>summary::-webkit-details-marker{display:none}.nova-details-content>summary:has(>br.ProseMirror-trailingBreak:only-child):before{content:var(--nova-summary-placeholder, "");position:absolute;color:var(--nova-muted);font-weight:400;pointer-events:none}.nova-details-open>.nova-details-content>summary{margin-bottom:.4em}.nova-details:not(.nova-details-open)>.nova-details-content>:not(summary){display:none}.nova-details-content>:last-child{margin-bottom:0}.nova-details.ProseMirror-selectednode{outline:2px solid var(--nova-accent);outline-offset:2px}@media(prefers-reduced-motion:reduce){.nova-details-toggle svg{transition:none}}';
|
|
20
|
+
|
|
21
|
+
// src/plugins/accordion.ts
|
|
22
|
+
var LABELS = {
|
|
23
|
+
en: {
|
|
24
|
+
accordion: "Accordion",
|
|
25
|
+
summary: "Summary",
|
|
26
|
+
expand: "Expand",
|
|
27
|
+
collapse: "Collapse"
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
function accordionNodes(editor) {
|
|
31
|
+
const options = editor.options.pluginOptions?.accordion ?? {};
|
|
32
|
+
const initial = options.initialState ?? "inherited";
|
|
33
|
+
const serialized = options.serializedState ?? "inherited";
|
|
34
|
+
return {
|
|
35
|
+
details: {
|
|
36
|
+
group: "block",
|
|
37
|
+
content: "details_summary block+",
|
|
38
|
+
defining: true,
|
|
39
|
+
// JSON can bring anything: only an explicit false means collapsed.
|
|
40
|
+
attrs: { open: { default: true } },
|
|
41
|
+
parseDOM: [
|
|
42
|
+
{
|
|
43
|
+
tag: "details",
|
|
44
|
+
getAttrs: (dom) => ({
|
|
45
|
+
open: initial === "inherited" ? dom.hasAttribute("open") : initial === "expanded"
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
toDOM: (node) => {
|
|
50
|
+
const open = serialized === "inherited" ? node.attrs.open !== false : serialized === "expanded";
|
|
51
|
+
return ["details", open ? { open: "" } : {}, 0];
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
details_summary: {
|
|
55
|
+
content: "inline*",
|
|
56
|
+
defining: true,
|
|
57
|
+
isolating: true,
|
|
58
|
+
// Only as the title of a collapsible block; a <summary> anywhere else is just text.
|
|
59
|
+
parseDOM: [{ tag: "summary", context: "details/" }],
|
|
60
|
+
toDOM: () => ["summary", 0]
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function detailsAround($pos) {
|
|
65
|
+
for (let depth = $pos.depth; depth > 0; depth--) {
|
|
66
|
+
const node = $pos.node(depth);
|
|
67
|
+
if (node.type.name === "details") return { node, pos: $pos.before(depth) };
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
var isOpen = (node) => node.attrs.open !== false;
|
|
72
|
+
var summaryEnd = (details) => details.pos + 2 + details.node.firstChild.content.size;
|
|
73
|
+
function setOpen(tr, details, open) {
|
|
74
|
+
return tr.setNodeAttribute(details.pos, "open", open).setMeta("addToHistory", false);
|
|
75
|
+
}
|
|
76
|
+
var DetailsView = class {
|
|
77
|
+
constructor(node, view, getPos, labels) {
|
|
78
|
+
this.node = node;
|
|
79
|
+
this.labels = labels;
|
|
80
|
+
this.toggle = h("button", {
|
|
81
|
+
type: "button",
|
|
82
|
+
className: "nova-details-toggle",
|
|
83
|
+
contentEditable: "false",
|
|
84
|
+
// Not in the Tab order (Tab leaves the editor); from the keyboard it is Ctrl/Cmd+Enter in the title.
|
|
85
|
+
tabIndex: -1
|
|
86
|
+
});
|
|
87
|
+
this.toggle.append(icon(icons.chevronDown));
|
|
88
|
+
this.toggle.addEventListener("mousedown", (event) => event.preventDefault());
|
|
89
|
+
this.toggle.addEventListener("click", () => {
|
|
90
|
+
const pos = getPos();
|
|
91
|
+
if (pos === void 0) return;
|
|
92
|
+
const current = view.state.doc.nodeAt(pos);
|
|
93
|
+
if (current?.type.name !== "details") return;
|
|
94
|
+
const details = { node: current, pos };
|
|
95
|
+
const open = isOpen(current);
|
|
96
|
+
const tr = setOpen(view.state.tr, details, !open);
|
|
97
|
+
const { from } = view.state.selection;
|
|
98
|
+
if (open && from > summaryEnd(details) && from < pos + current.nodeSize) {
|
|
99
|
+
tr.setSelection(TextSelection.create(tr.doc, summaryEnd(details)));
|
|
100
|
+
}
|
|
101
|
+
view.dispatch(tr);
|
|
102
|
+
});
|
|
103
|
+
this.contentDOM = h("div", { className: "nova-details-content" });
|
|
104
|
+
this.dom = h("div", { className: "nova-details" }, this.toggle, this.contentDOM);
|
|
105
|
+
this.sync();
|
|
106
|
+
}
|
|
107
|
+
node;
|
|
108
|
+
labels;
|
|
109
|
+
dom;
|
|
110
|
+
contentDOM;
|
|
111
|
+
toggle;
|
|
112
|
+
sync() {
|
|
113
|
+
const open = isOpen(this.node);
|
|
114
|
+
this.dom.classList.toggle("nova-details-open", open);
|
|
115
|
+
this.toggle.setAttribute("aria-expanded", String(open));
|
|
116
|
+
this.toggle.setAttribute("aria-label", open ? this.labels.collapse : this.labels.expand);
|
|
117
|
+
}
|
|
118
|
+
update(node) {
|
|
119
|
+
if (node.type !== this.node.type) return false;
|
|
120
|
+
this.node = node;
|
|
121
|
+
this.sync();
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
stopEvent(event) {
|
|
125
|
+
return event.target instanceof Node && this.toggle.contains(event.target);
|
|
126
|
+
}
|
|
127
|
+
ignoreMutation(mutation) {
|
|
128
|
+
return mutation.type !== "selection" && !this.contentDOM.contains(mutation.target);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var accordion_default2 = definePlugin({
|
|
132
|
+
name: "accordion",
|
|
133
|
+
nodes: accordionNodes,
|
|
134
|
+
prosemirrorPlugins: (editor) => {
|
|
135
|
+
const labels = pickLabels(editor, "accordion", LABELS);
|
|
136
|
+
return [
|
|
137
|
+
new Plugin({
|
|
138
|
+
key: new PluginKey("nova-accordion"),
|
|
139
|
+
props: {
|
|
140
|
+
nodeViews: {
|
|
141
|
+
details: (node, view, getPos) => new DetailsView(node, view, getPos, labels)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
];
|
|
146
|
+
},
|
|
147
|
+
setup(editor) {
|
|
148
|
+
editor.ui.addStyles("nova-accordion", accordion_default);
|
|
149
|
+
const { summary } = pickLabels(editor, "accordion", LABELS);
|
|
150
|
+
editor.root.style.setProperty("--nova-summary-placeholder", JSON.stringify(summary));
|
|
151
|
+
},
|
|
152
|
+
load: () => import("./accordion-ui-FGN3I5UF.js")
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
export {
|
|
156
|
+
LABELS,
|
|
157
|
+
detailsAround,
|
|
158
|
+
isOpen,
|
|
159
|
+
summaryEnd,
|
|
160
|
+
setOpen,
|
|
161
|
+
accordion_default2 as accordion_default
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=chunk-HC6RMBAD.js.map
|