@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
package/dist/chunk-435CRWKA.js
DELETED
|
@@ -1,983 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
classAttr,
|
|
3
|
-
cssValue,
|
|
4
|
-
schema
|
|
5
|
-
} from "./chunk-7ON7PR5R.js";
|
|
6
|
-
import {
|
|
7
|
-
FOCUSABLE,
|
|
8
|
-
h,
|
|
9
|
-
icon,
|
|
10
|
-
uniqueId
|
|
11
|
-
} from "./chunk-HZRIBOPW.js";
|
|
12
|
-
import {
|
|
13
|
-
icons
|
|
14
|
-
} from "./chunk-NPKAIW34.js";
|
|
15
|
-
import {
|
|
16
|
-
getLinkAt,
|
|
17
|
-
insertImage,
|
|
18
|
-
isSafeImageUrl,
|
|
19
|
-
isSafeLinkUrl,
|
|
20
|
-
markRange,
|
|
21
|
-
marksOf,
|
|
22
|
-
nodesOf
|
|
23
|
-
} from "./chunk-GHEFKKRC.js";
|
|
24
|
-
|
|
25
|
-
// src/ui/file-picker.ts
|
|
26
|
-
function attachFilePicker(editor, field, type, onPick) {
|
|
27
|
-
const { filePicker: picker, filePickerTypes: types } = editor.options;
|
|
28
|
-
if (!picker || types && !types.includes(type)) return;
|
|
29
|
-
const { input } = field;
|
|
30
|
-
const button = h(
|
|
31
|
-
"button",
|
|
32
|
-
{
|
|
33
|
-
type: "button",
|
|
34
|
-
className: "nova-btn nova-input-action",
|
|
35
|
-
"aria-label": editor.ui.t("dialog.browse"),
|
|
36
|
-
title: editor.ui.t("dialog.browse")
|
|
37
|
-
},
|
|
38
|
-
icon(icons.browse)
|
|
39
|
-
);
|
|
40
|
-
const group = h("div", { className: "nova-input-group" });
|
|
41
|
-
input.replaceWith(group);
|
|
42
|
-
group.append(input, button);
|
|
43
|
-
button.addEventListener("click", async () => {
|
|
44
|
-
button.disabled = true;
|
|
45
|
-
try {
|
|
46
|
-
const result = await picker({ type, value: input.value });
|
|
47
|
-
if (!result?.url) return;
|
|
48
|
-
input.value = result.url;
|
|
49
|
-
input.removeAttribute("aria-invalid");
|
|
50
|
-
onPick?.(result);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error("[nova] filePicker failed:", error);
|
|
53
|
-
} finally {
|
|
54
|
-
button.disabled = false;
|
|
55
|
-
if (input.isConnected) input.focus();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// src/image.ts
|
|
61
|
-
import {
|
|
62
|
-
NodeSelection,
|
|
63
|
-
Plugin,
|
|
64
|
-
PluginKey
|
|
65
|
-
} from "prosemirror-state";
|
|
66
|
-
|
|
67
|
-
// src/ui/dialog.ts
|
|
68
|
-
function openDialog(options) {
|
|
69
|
-
const titleId = uniqueId("nova-dialog-title");
|
|
70
|
-
const error = h("p", { className: "nova-dialog-error", role: "alert", hidden: true });
|
|
71
|
-
const submit = h(
|
|
72
|
-
"button",
|
|
73
|
-
{ type: "submit", className: "nova-button nova-button-primary", hidden: !options.submitLabel },
|
|
74
|
-
options.submitLabel ?? ""
|
|
75
|
-
);
|
|
76
|
-
const cancel = h("button", { type: "button", className: "nova-button" }, options.cancelLabel);
|
|
77
|
-
const closeButton = h(
|
|
78
|
-
"button",
|
|
79
|
-
{ type: "button", className: "nova-btn nova-dialog-close", "aria-label": options.closeLabel },
|
|
80
|
-
icon(icons.close)
|
|
81
|
-
);
|
|
82
|
-
const form = h(
|
|
83
|
-
"form",
|
|
84
|
-
{
|
|
85
|
-
className: options.size === "large" ? "nova-dialog nova-dialog-large" : "nova-dialog",
|
|
86
|
-
role: "dialog",
|
|
87
|
-
"aria-modal": "true",
|
|
88
|
-
"aria-labelledby": titleId,
|
|
89
|
-
novalidate: true
|
|
90
|
-
},
|
|
91
|
-
h(
|
|
92
|
-
"header",
|
|
93
|
-
{ className: "nova-dialog-header" },
|
|
94
|
-
h("h2", { id: titleId }, options.title),
|
|
95
|
-
closeButton
|
|
96
|
-
),
|
|
97
|
-
h("div", { className: "nova-dialog-body" }, options.body, error),
|
|
98
|
-
h("footer", { className: "nova-dialog-footer" }, cancel, submit)
|
|
99
|
-
);
|
|
100
|
-
const backdrop = h("div", { className: "nova-dialog-backdrop" }, form);
|
|
101
|
-
options.host.append(backdrop);
|
|
102
|
-
let closed = false;
|
|
103
|
-
const close = () => {
|
|
104
|
-
if (closed) return;
|
|
105
|
-
closed = true;
|
|
106
|
-
backdrop.remove();
|
|
107
|
-
document.removeEventListener("focusin", keepFocusInside, true);
|
|
108
|
-
options.onClose?.();
|
|
109
|
-
options.returnFocus?.();
|
|
110
|
-
};
|
|
111
|
-
const setError = (message) => {
|
|
112
|
-
error.hidden = !message;
|
|
113
|
-
error.textContent = message ?? "";
|
|
114
|
-
};
|
|
115
|
-
const setBusy = (busy) => {
|
|
116
|
-
submit.disabled = busy;
|
|
117
|
-
form.setAttribute("aria-busy", String(busy));
|
|
118
|
-
};
|
|
119
|
-
form.addEventListener("submit", async (event) => {
|
|
120
|
-
event.preventDefault();
|
|
121
|
-
setError(null);
|
|
122
|
-
setBusy(true);
|
|
123
|
-
try {
|
|
124
|
-
const result = options.onSubmit ? await options.onSubmit() : true;
|
|
125
|
-
if (typeof result === "string") setError(result);
|
|
126
|
-
else if (result !== false) close();
|
|
127
|
-
} finally {
|
|
128
|
-
if (!closed) setBusy(false);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
cancel.addEventListener("click", close);
|
|
132
|
-
closeButton.addEventListener("click", close);
|
|
133
|
-
backdrop.addEventListener("mousedown", (event) => {
|
|
134
|
-
if (event.target === backdrop) close();
|
|
135
|
-
});
|
|
136
|
-
form.addEventListener("keydown", (event) => {
|
|
137
|
-
if (event.key === "Escape") {
|
|
138
|
-
event.preventDefault();
|
|
139
|
-
event.stopPropagation();
|
|
140
|
-
close();
|
|
141
|
-
} else if (event.key === "Tab") {
|
|
142
|
-
const focusable = [...form.querySelectorAll(FOCUSABLE)].filter(
|
|
143
|
-
(el) => !el.hidden
|
|
144
|
-
);
|
|
145
|
-
const first2 = focusable[0];
|
|
146
|
-
const last = focusable[focusable.length - 1];
|
|
147
|
-
if (!first2 || !last) return;
|
|
148
|
-
if (event.shiftKey && document.activeElement === first2) {
|
|
149
|
-
event.preventDefault();
|
|
150
|
-
last.focus();
|
|
151
|
-
} else if (!event.shiftKey && document.activeElement === last) {
|
|
152
|
-
event.preventDefault();
|
|
153
|
-
first2.focus();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
const keepFocusInside = (event) => {
|
|
158
|
-
if (!form.contains(event.target)) {
|
|
159
|
-
(form.querySelector(FOCUSABLE) ?? form).focus();
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
document.addEventListener("focusin", keepFocusInside, true);
|
|
163
|
-
const first = options.initialFocus ?? form.querySelector(".nova-dialog-body input, .nova-dialog-body textarea");
|
|
164
|
-
(first ?? (options.submitLabel ? submit : cancel)).focus();
|
|
165
|
-
return { el: form, close, setError, setBusy };
|
|
166
|
-
}
|
|
167
|
-
function textField(options) {
|
|
168
|
-
const id = uniqueId("nova-field");
|
|
169
|
-
const hintId = options.hint ? `${id}-hint` : void 0;
|
|
170
|
-
const input = h("input", {
|
|
171
|
-
id,
|
|
172
|
-
type: options.type ?? "text",
|
|
173
|
-
className: "nova-input",
|
|
174
|
-
value: options.value ?? "",
|
|
175
|
-
placeholder: options.placeholder,
|
|
176
|
-
required: options.required ?? false,
|
|
177
|
-
autocomplete: options.autocomplete ?? "off",
|
|
178
|
-
spellcheck: "false",
|
|
179
|
-
"aria-describedby": hintId
|
|
180
|
-
});
|
|
181
|
-
input.value = options.value ?? "";
|
|
182
|
-
const el = h(
|
|
183
|
-
"div",
|
|
184
|
-
{ className: "nova-field" },
|
|
185
|
-
h("label", { for: id, className: "nova-label" }, options.label),
|
|
186
|
-
input,
|
|
187
|
-
options.hint ? h("p", { id: hintId, className: "nova-hint" }, options.hint) : null
|
|
188
|
-
);
|
|
189
|
-
return { el, input };
|
|
190
|
-
}
|
|
191
|
-
function checkboxField(label, checked = false) {
|
|
192
|
-
const id = uniqueId("nova-check");
|
|
193
|
-
const input = h("input", { id, type: "checkbox", className: "nova-checkbox" });
|
|
194
|
-
input.checked = checked;
|
|
195
|
-
const el = h(
|
|
196
|
-
"div",
|
|
197
|
-
{ className: "nova-field nova-field-inline" },
|
|
198
|
-
input,
|
|
199
|
-
h("label", { for: id }, label)
|
|
200
|
-
);
|
|
201
|
-
return { el, input };
|
|
202
|
-
}
|
|
203
|
-
function selectField(options) {
|
|
204
|
-
const id = uniqueId("nova-field");
|
|
205
|
-
const select = h(
|
|
206
|
-
"select",
|
|
207
|
-
{ id, className: "nova-input nova-select" },
|
|
208
|
-
...options.options.map((o) => h("option", { value: o.value }, o.label))
|
|
209
|
-
);
|
|
210
|
-
select.value = options.value;
|
|
211
|
-
const el = h(
|
|
212
|
-
"div",
|
|
213
|
-
{ className: "nova-field" },
|
|
214
|
-
h("label", { for: id, className: "nova-label" }, options.label),
|
|
215
|
-
select
|
|
216
|
-
);
|
|
217
|
-
return { el, select };
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// src/image.ts
|
|
221
|
-
var IMAGE_TYPES = /^image\/(png|jpe?g|gif|webp|avif|bmp)$/;
|
|
222
|
-
function isSupportedImage(file) {
|
|
223
|
-
return IMAGE_TYPES.test(file.type);
|
|
224
|
-
}
|
|
225
|
-
function readAsDataUrl(file) {
|
|
226
|
-
return new Promise((resolve, reject) => {
|
|
227
|
-
const reader = new FileReader();
|
|
228
|
-
reader.onload = () => resolve(String(reader.result));
|
|
229
|
-
reader.onerror = () => reject(reader.error ?? new Error("FileReader failed"));
|
|
230
|
-
reader.readAsDataURL(file);
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
function findImage(view, src) {
|
|
234
|
-
let found = null;
|
|
235
|
-
view.state.doc.descendants((node, pos) => {
|
|
236
|
-
if (found !== null) return false;
|
|
237
|
-
if (node.type === nodesOf(view.state).image && node.attrs.src === src) found = pos;
|
|
238
|
-
return true;
|
|
239
|
-
});
|
|
240
|
-
return found;
|
|
241
|
-
}
|
|
242
|
-
function uploadImages(editor, files, pos) {
|
|
243
|
-
const images = files.filter(isSupportedImage);
|
|
244
|
-
const view = editor.view;
|
|
245
|
-
for (const file of images) {
|
|
246
|
-
const blobUrl = URL.createObjectURL(file);
|
|
247
|
-
const node = nodesOf(view.state).image.create({ src: blobUrl, alt: null });
|
|
248
|
-
const tr = view.state.tr;
|
|
249
|
-
if (pos !== void 0) tr.insert(Math.min(pos, tr.doc.content.size), node);
|
|
250
|
-
else tr.replaceSelectionWith(node);
|
|
251
|
-
view.dispatch(tr.scrollIntoView());
|
|
252
|
-
const handler = editor.options.uploadImage;
|
|
253
|
-
const notice = handler ? editor.ui.notify({ text: editor.ui.t("image.uploading"), timeout: 0 }) : null;
|
|
254
|
-
const upload = handler ? handler(
|
|
255
|
-
file,
|
|
256
|
-
(percent) => notice?.setText(`${editor.ui.t("image.uploading")} ${Math.round(percent)}%`)
|
|
257
|
-
) : readAsDataUrl(file);
|
|
258
|
-
upload.then((url) => {
|
|
259
|
-
if (!isSafeImageUrl(url)) throw new Error(`Unsafe image URL returned: ${url}`);
|
|
260
|
-
const at = findImage(view, blobUrl);
|
|
261
|
-
if (at === null) return;
|
|
262
|
-
const current = view.state.doc.nodeAt(at);
|
|
263
|
-
view.dispatch(
|
|
264
|
-
view.state.tr.setNodeMarkup(at, void 0, { ...current.attrs, src: url }).setMeta("addToHistory", false)
|
|
265
|
-
);
|
|
266
|
-
}).catch((error) => {
|
|
267
|
-
console.error("[nova] image upload failed", error);
|
|
268
|
-
const at = findImage(view, blobUrl);
|
|
269
|
-
if (at !== null)
|
|
270
|
-
view.dispatch(view.state.tr.delete(at, at + 1).setMeta("addToHistory", false));
|
|
271
|
-
editor.ui.notify({ text: editor.ui.t("image.uploadFailed"), type: "error" });
|
|
272
|
-
}).finally(() => {
|
|
273
|
-
notice?.close();
|
|
274
|
-
URL.revokeObjectURL(blobUrl);
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
var DATA_IMAGE = /^data:(image\/(?:png|jpe?g|gif|webp|avif|bmp));base64,(.+)$/i;
|
|
279
|
-
function dataUrlToFile(src, name = "pasted-image") {
|
|
280
|
-
const match = src.match(DATA_IMAGE);
|
|
281
|
-
if (!match) return null;
|
|
282
|
-
const type = match[1].toLowerCase();
|
|
283
|
-
try {
|
|
284
|
-
const binary = atob(match[2]);
|
|
285
|
-
const bytes = new Uint8Array(binary.length);
|
|
286
|
-
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
287
|
-
const ext = type.split("/")[1].replace("jpeg", "jpg");
|
|
288
|
-
return new File([bytes], `${name}.${ext}`, { type });
|
|
289
|
-
} catch {
|
|
290
|
-
return null;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
function replaceImageSrc(view, from, to) {
|
|
294
|
-
const tr = view.state.tr;
|
|
295
|
-
view.state.doc.descendants((node, pos) => {
|
|
296
|
-
if (node.type === nodesOf(view.state).image && node.attrs.src === from) {
|
|
297
|
-
tr.setNodeMarkup(pos, void 0, { ...node.attrs, src: to });
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
if (tr.docChanged) view.dispatch(tr.setMeta("addToHistory", false));
|
|
301
|
-
}
|
|
302
|
-
async function uploadEmbeddedImage(editor, src) {
|
|
303
|
-
const handler = editor.options.uploadImage;
|
|
304
|
-
const file = handler ? dataUrlToFile(src) : null;
|
|
305
|
-
if (!handler || !file) return;
|
|
306
|
-
const notice = editor.ui.notify({ text: editor.ui.t("image.uploading"), timeout: 0 });
|
|
307
|
-
try {
|
|
308
|
-
const url = await handler(
|
|
309
|
-
file,
|
|
310
|
-
(percent) => notice.setText(`${editor.ui.t("image.uploading")} ${Math.round(percent)}%`)
|
|
311
|
-
);
|
|
312
|
-
if (!isSafeImageUrl(url)) throw new Error(`Unsafe image URL returned: ${url}`);
|
|
313
|
-
replaceImageSrc(editor.view, src, url);
|
|
314
|
-
} catch (error) {
|
|
315
|
-
console.error("[nova] embedded image upload failed", error);
|
|
316
|
-
editor.ui.notify({ text: editor.ui.t("image.uploadFailed"), type: "error" });
|
|
317
|
-
} finally {
|
|
318
|
-
notice.close();
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
function dataImageSrcs(doc, type) {
|
|
322
|
-
const srcs = /* @__PURE__ */ new Set();
|
|
323
|
-
doc.descendants((node) => {
|
|
324
|
-
if (node.type === type && DATA_IMAGE.test(node.attrs.src)) srcs.add(node.attrs.src);
|
|
325
|
-
});
|
|
326
|
-
return srcs;
|
|
327
|
-
}
|
|
328
|
-
function embeddedImageUploadPlugin(editor) {
|
|
329
|
-
return new Plugin({
|
|
330
|
-
key: new PluginKey("nova-embedded-image-upload"),
|
|
331
|
-
appendTransaction(transactions, oldState, newState) {
|
|
332
|
-
if (!editor.options.uploadImage) return null;
|
|
333
|
-
const fromUser = transactions.some(
|
|
334
|
-
(tr) => ["paste", "drop"].includes(tr.getMeta("uiEvent"))
|
|
335
|
-
);
|
|
336
|
-
if (!fromUser || !transactions.some((tr) => tr.docChanged)) return null;
|
|
337
|
-
const type = nodesOf(newState).image;
|
|
338
|
-
const before = dataImageSrcs(oldState.doc, type);
|
|
339
|
-
const added = [...dataImageSrcs(newState.doc, type)].filter((src) => !before.has(src));
|
|
340
|
-
if (added.length)
|
|
341
|
-
queueMicrotask(() => added.forEach((src) => void uploadEmbeddedImage(editor, src)));
|
|
342
|
-
return null;
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
function imageDropPastePlugin(editor) {
|
|
347
|
-
return new Plugin({
|
|
348
|
-
key: new PluginKey("nova-image-drop-paste"),
|
|
349
|
-
props: {
|
|
350
|
-
handlePaste(_view, event) {
|
|
351
|
-
if (!editor.isAllowed("image")) return false;
|
|
352
|
-
const data = event.clipboardData;
|
|
353
|
-
if (!data) return false;
|
|
354
|
-
if (data.getData("text/html")) return false;
|
|
355
|
-
const files = [...data.files].filter(isSupportedImage);
|
|
356
|
-
if (!files.length) return false;
|
|
357
|
-
uploadImages(editor, files);
|
|
358
|
-
return true;
|
|
359
|
-
},
|
|
360
|
-
handleDrop(view, event) {
|
|
361
|
-
if (!editor.isAllowed("image")) return false;
|
|
362
|
-
const files = [...event.dataTransfer?.files ?? []].filter(isSupportedImage);
|
|
363
|
-
if (!files.length) return false;
|
|
364
|
-
event.preventDefault();
|
|
365
|
-
const coords = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
366
|
-
uploadImages(editor, files, coords?.pos);
|
|
367
|
-
return true;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
function openImageDialog(editor) {
|
|
373
|
-
const { t } = editor.ui;
|
|
374
|
-
const fileInput = h("input", {
|
|
375
|
-
type: "file",
|
|
376
|
-
accept: "image/png,image/jpeg,image/gif,image/webp,image/avif",
|
|
377
|
-
className: "nova-visually-hidden",
|
|
378
|
-
tabindex: "-1"
|
|
379
|
-
});
|
|
380
|
-
const dropzone = h(
|
|
381
|
-
"button",
|
|
382
|
-
{ type: "button", className: "nova-dropzone" },
|
|
383
|
-
icon(icons.upload),
|
|
384
|
-
h("span", {}, t("image.drop"))
|
|
385
|
-
);
|
|
386
|
-
const url = textField({ label: t("image.url"), type: "url", placeholder: "https://" });
|
|
387
|
-
const alt = textField({ label: t("image.alt"), hint: t("image.altHint") });
|
|
388
|
-
attachFilePicker(editor, url, "image", (picked) => {
|
|
389
|
-
if (picked.alt) alt.input.value = picked.alt;
|
|
390
|
-
});
|
|
391
|
-
const body = h(
|
|
392
|
-
"div",
|
|
393
|
-
{ className: "nova-form" },
|
|
394
|
-
dropzone,
|
|
395
|
-
fileInput,
|
|
396
|
-
h("div", { className: "nova-divider" }, h("span", {}, t("image.or"))),
|
|
397
|
-
url.el,
|
|
398
|
-
alt.el
|
|
399
|
-
);
|
|
400
|
-
const dialog = editor.ui.openDialog({
|
|
401
|
-
title: t("image.title"),
|
|
402
|
-
body,
|
|
403
|
-
submitLabel: t("dialog.insert"),
|
|
404
|
-
initialFocus: url.input,
|
|
405
|
-
onSubmit: () => {
|
|
406
|
-
const src = url.input.value.trim();
|
|
407
|
-
if (!src || !isSafeImageUrl(src)) {
|
|
408
|
-
url.input.setAttribute("aria-invalid", "true");
|
|
409
|
-
url.input.focus();
|
|
410
|
-
return t("image.invalid");
|
|
411
|
-
}
|
|
412
|
-
editor.exec(insertImage(src, alt.input.value.trim() || void 0));
|
|
413
|
-
return true;
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
const takeFiles = (files) => {
|
|
417
|
-
const images = files.filter(isSupportedImage);
|
|
418
|
-
if (!images.length) return;
|
|
419
|
-
dialog.close();
|
|
420
|
-
uploadImages(editor, images);
|
|
421
|
-
};
|
|
422
|
-
dropzone.addEventListener("click", () => fileInput.click());
|
|
423
|
-
fileInput.addEventListener("change", () => takeFiles([...fileInput.files ?? []]));
|
|
424
|
-
dropzone.addEventListener("dragover", (event) => {
|
|
425
|
-
event.preventDefault();
|
|
426
|
-
dropzone.classList.add("is-dragover");
|
|
427
|
-
});
|
|
428
|
-
dropzone.addEventListener("dragleave", () => dropzone.classList.remove("is-dragover"));
|
|
429
|
-
dropzone.addEventListener("drop", (event) => {
|
|
430
|
-
event.preventDefault();
|
|
431
|
-
dropzone.classList.remove("is-dragover");
|
|
432
|
-
takeFiles([...event.dataTransfer?.files ?? []]);
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
function getSelectedImage(state) {
|
|
436
|
-
const { selection } = state;
|
|
437
|
-
if (selection instanceof NodeSelection && selection.node.type === nodesOf(state).image) {
|
|
438
|
-
return { node: selection.node, pos: selection.from };
|
|
439
|
-
}
|
|
440
|
-
return null;
|
|
441
|
-
}
|
|
442
|
-
function setImageAttrs(attrs) {
|
|
443
|
-
return (state, dispatch) => {
|
|
444
|
-
const image = getSelectedImage(state);
|
|
445
|
-
if (!image) return false;
|
|
446
|
-
if (dispatch) {
|
|
447
|
-
const tr = state.tr.setNodeMarkup(image.pos, void 0, { ...image.node.attrs, ...attrs });
|
|
448
|
-
tr.setSelection(NodeSelection.create(tr.doc, image.pos));
|
|
449
|
-
dispatch(tr);
|
|
450
|
-
}
|
|
451
|
-
return true;
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
function setImageWidthFraction(editor, fraction) {
|
|
455
|
-
const image = getSelectedImage(editor.view.state);
|
|
456
|
-
if (!image) return false;
|
|
457
|
-
if (fraction === null) return editor.exec(setImageAttrs({ width: null, height: null }));
|
|
458
|
-
const dom = editor.view.nodeDOM(image.pos);
|
|
459
|
-
const img = dom?.querySelector("img") ?? null;
|
|
460
|
-
const style = getComputedStyle(editor.view.dom);
|
|
461
|
-
const contentWidth = editor.view.dom.clientWidth - parseFloat(style.paddingLeft || "0") - parseFloat(style.paddingRight || "0");
|
|
462
|
-
const width = Math.max(24, Math.round(contentWidth * fraction));
|
|
463
|
-
const ratio = img && img.naturalWidth ? img.naturalHeight / img.naturalWidth : null;
|
|
464
|
-
return editor.exec(setImageAttrs({ width, height: ratio ? Math.round(width * ratio) : null }));
|
|
465
|
-
}
|
|
466
|
-
function openImageAltDialog(editor) {
|
|
467
|
-
const image = getSelectedImage(editor.view.state);
|
|
468
|
-
if (!image) return;
|
|
469
|
-
const { t } = editor.ui;
|
|
470
|
-
const alt = textField({
|
|
471
|
-
label: t("image.alt"),
|
|
472
|
-
value: image.node.attrs.alt ?? "",
|
|
473
|
-
hint: t("image.altHint")
|
|
474
|
-
});
|
|
475
|
-
const title = textField({ label: t("link.tooltip"), value: image.node.attrs.title ?? "" });
|
|
476
|
-
editor.ui.openDialog({
|
|
477
|
-
title: t("image.editAlt"),
|
|
478
|
-
body: h("div", { className: "nova-form" }, alt.el, title.el),
|
|
479
|
-
submitLabel: t("dialog.save"),
|
|
480
|
-
initialFocus: alt.input,
|
|
481
|
-
onSubmit: () => {
|
|
482
|
-
editor.exec(
|
|
483
|
-
setImageAttrs({
|
|
484
|
-
alt: alt.input.value.trim() || null,
|
|
485
|
-
title: title.input.value.trim() || null
|
|
486
|
-
})
|
|
487
|
-
);
|
|
488
|
-
return true;
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
// src/link.ts
|
|
494
|
-
function normalizeUrl(input) {
|
|
495
|
-
const url = input.trim();
|
|
496
|
-
if (!url) return "";
|
|
497
|
-
if (/^[a-z][a-z0-9+.-]*:/i.test(url) || /^[/#?.]/.test(url)) return url;
|
|
498
|
-
if (/^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(url)) return `mailto:${url}`;
|
|
499
|
-
if (/^(www\.)?[^\s/]+\.[a-z]{2,}([/:?#].*)?$/i.test(url)) return `https://${url}`;
|
|
500
|
-
return url;
|
|
501
|
-
}
|
|
502
|
-
function linkTarget(state) {
|
|
503
|
-
const { from, to, empty, $from } = state.selection;
|
|
504
|
-
if (empty) return markRange(state, marksOf(state).link, $from.pos) ?? { from, to };
|
|
505
|
-
return { from, to };
|
|
506
|
-
}
|
|
507
|
-
function applyLink(attrs) {
|
|
508
|
-
return (state, dispatch) => {
|
|
509
|
-
const href = normalizeUrl(attrs.href);
|
|
510
|
-
if (!href || !isSafeLinkUrl(href)) return false;
|
|
511
|
-
if (!dispatch) return true;
|
|
512
|
-
const { from, to } = linkTarget(state);
|
|
513
|
-
const linkMark = marksOf(state).link.create({
|
|
514
|
-
href,
|
|
515
|
-
title: attrs.title || null,
|
|
516
|
-
target: attrs.target || null
|
|
517
|
-
});
|
|
518
|
-
const currentText = state.doc.textBetween(from, to);
|
|
519
|
-
const text = attrs.text?.trim() ? attrs.text : null;
|
|
520
|
-
const tr = state.tr;
|
|
521
|
-
if (from === to || text !== null && text !== currentText) {
|
|
522
|
-
const baseMarks = marksOf(state).link.removeFromSet(state.doc.resolve(from).marks());
|
|
523
|
-
const node = state.schema.text(text ?? (currentText || href), linkMark.addToSet(baseMarks));
|
|
524
|
-
tr.replaceWith(from, to, node);
|
|
525
|
-
} else {
|
|
526
|
-
tr.removeMark(from, to, marksOf(state).link).addMark(from, to, linkMark);
|
|
527
|
-
}
|
|
528
|
-
dispatch(tr.scrollIntoView());
|
|
529
|
-
return true;
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
function removeLink() {
|
|
533
|
-
return (state, dispatch) => {
|
|
534
|
-
const { from, to } = linkTarget(state);
|
|
535
|
-
if (from === to || !state.doc.rangeHasMark(from, to, marksOf(state).link)) return false;
|
|
536
|
-
dispatch?.(state.tr.removeMark(from, to, marksOf(state).link));
|
|
537
|
-
return true;
|
|
538
|
-
};
|
|
539
|
-
}
|
|
540
|
-
function openLinkDialog(editor) {
|
|
541
|
-
const { t } = editor.ui;
|
|
542
|
-
const state = editor.view.state;
|
|
543
|
-
const existing = getLinkAt(state);
|
|
544
|
-
const range = linkTarget(state);
|
|
545
|
-
const selectedText = state.doc.textBetween(range.from, range.to);
|
|
546
|
-
const canEditText = !selectedText.includes("\n") && state.selection.$from.sameParent(state.doc.resolve(range.to));
|
|
547
|
-
const url = textField({
|
|
548
|
-
label: t("link.url"),
|
|
549
|
-
type: "url",
|
|
550
|
-
value: existing?.href ?? "",
|
|
551
|
-
placeholder: "https://",
|
|
552
|
-
required: true
|
|
553
|
-
});
|
|
554
|
-
const text = textField({ label: t("link.text"), value: selectedText });
|
|
555
|
-
const title = textField({ label: t("link.tooltip"), value: existing?.title ?? "" });
|
|
556
|
-
const newTab = checkboxField(t("link.newTab"), existing?.target === "_blank");
|
|
557
|
-
attachFilePicker(editor, url, "file", (picked) => {
|
|
558
|
-
if (picked.text && !text.input.value.trim()) text.input.value = picked.text;
|
|
559
|
-
if (picked.title) title.input.value = picked.title;
|
|
560
|
-
});
|
|
561
|
-
const body = h(
|
|
562
|
-
"div",
|
|
563
|
-
{ className: "nova-form" },
|
|
564
|
-
url.el,
|
|
565
|
-
canEditText ? text.el : null,
|
|
566
|
-
title.el,
|
|
567
|
-
newTab.el
|
|
568
|
-
);
|
|
569
|
-
editor.ui.openDialog({
|
|
570
|
-
title: existing ? t("link.editTitle") : t("link.title"),
|
|
571
|
-
body,
|
|
572
|
-
submitLabel: existing ? t("dialog.save") : t("dialog.insert"),
|
|
573
|
-
initialFocus: url.input,
|
|
574
|
-
onSubmit: () => {
|
|
575
|
-
const href = normalizeUrl(url.input.value);
|
|
576
|
-
if (!href || !isSafeLinkUrl(href)) {
|
|
577
|
-
url.input.setAttribute("aria-invalid", "true");
|
|
578
|
-
url.input.focus();
|
|
579
|
-
return t("link.invalid");
|
|
580
|
-
}
|
|
581
|
-
editor.exec(
|
|
582
|
-
applyLink({
|
|
583
|
-
href,
|
|
584
|
-
...canEditText ? { text: text.input.value } : {},
|
|
585
|
-
title: title.input.value.trim() || null,
|
|
586
|
-
target: newTab.input.checked ? "_blank" : null
|
|
587
|
-
})
|
|
588
|
-
);
|
|
589
|
-
return true;
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
// src/table.ts
|
|
595
|
-
import { keymap } from "prosemirror-keymap";
|
|
596
|
-
import { Fragment } from "prosemirror-model";
|
|
597
|
-
import { TextSelection } from "prosemirror-state";
|
|
598
|
-
import {
|
|
599
|
-
addColumnAfter,
|
|
600
|
-
addColumnBefore,
|
|
601
|
-
addRowAfter,
|
|
602
|
-
addRowBefore,
|
|
603
|
-
CellSelection,
|
|
604
|
-
columnResizing,
|
|
605
|
-
deleteColumn,
|
|
606
|
-
deleteRow,
|
|
607
|
-
deleteTable,
|
|
608
|
-
findTable,
|
|
609
|
-
goToNextCell,
|
|
610
|
-
isInTable,
|
|
611
|
-
mergeCells,
|
|
612
|
-
selectedRect,
|
|
613
|
-
setCellAttr,
|
|
614
|
-
splitCell,
|
|
615
|
-
tableEditing,
|
|
616
|
-
TableView,
|
|
617
|
-
toggleHeader
|
|
618
|
-
} from "prosemirror-tables";
|
|
619
|
-
var MAX_GRID = 10;
|
|
620
|
-
function createTable(rows, cols, withHeader = true, schema2 = schema) {
|
|
621
|
-
const { table, table_row, table_cell, table_header, paragraph } = schema2.nodes;
|
|
622
|
-
const rowNodes = [];
|
|
623
|
-
for (let r = 0; r < rows; r++) {
|
|
624
|
-
const cellType = withHeader && r === 0 ? table_header : table_cell;
|
|
625
|
-
const cells = [];
|
|
626
|
-
for (let c = 0; c < cols; c++) cells.push(cellType.create(null, paragraph.create()));
|
|
627
|
-
rowNodes.push(table_row.create(null, cells));
|
|
628
|
-
}
|
|
629
|
-
return table.create(null, rowNodes);
|
|
630
|
-
}
|
|
631
|
-
function insertTable(rows, cols, withHeader = true) {
|
|
632
|
-
return (state, dispatch) => {
|
|
633
|
-
if (rows < 1 || cols < 1 || rows > 100 || cols > 50) return false;
|
|
634
|
-
if (isInTable(state)) return false;
|
|
635
|
-
if (dispatch) {
|
|
636
|
-
const node = createTable(rows, cols, withHeader, state.schema);
|
|
637
|
-
const tr = state.tr.replaceSelectionWith(node);
|
|
638
|
-
let tablePos = -1;
|
|
639
|
-
tr.doc.descendants((n, pos) => {
|
|
640
|
-
if (n === node) tablePos = pos;
|
|
641
|
-
return tablePos < 0;
|
|
642
|
-
});
|
|
643
|
-
if (tablePos >= 0) tr.setSelection(TextSelection.near(tr.doc.resolve(tablePos + 3)));
|
|
644
|
-
dispatch(tr.scrollIntoView());
|
|
645
|
-
}
|
|
646
|
-
return true;
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
var nextCellOrNewRow = (state, dispatch, view) => {
|
|
650
|
-
if (!isInTable(state)) return false;
|
|
651
|
-
if (goToNextCell(1)(state, dispatch, view)) return true;
|
|
652
|
-
if (!dispatch) return true;
|
|
653
|
-
let next = state;
|
|
654
|
-
addRowAfter(state, (tr) => {
|
|
655
|
-
next = state.apply(tr);
|
|
656
|
-
dispatch(tr);
|
|
657
|
-
});
|
|
658
|
-
return goToNextCell(1)(next, dispatch, view);
|
|
659
|
-
};
|
|
660
|
-
function tablePlugins() {
|
|
661
|
-
return [
|
|
662
|
-
// defaultCellMinWidth — минимум для столбцов без заданной ширины (по умолчанию 100px:
|
|
663
|
-
// таблица из 5+ столбцов раньше времени вылезала за край узкого редактора).
|
|
664
|
-
columnResizing({ cellMinWidth: 48, defaultCellMinWidth: 48, View: NovaTableView }),
|
|
665
|
-
tableEditing(),
|
|
666
|
-
keymap({
|
|
667
|
-
Tab: nextCellOrNewRow,
|
|
668
|
-
"Shift-Tab": goToNextCell(-1)
|
|
669
|
-
})
|
|
670
|
-
];
|
|
671
|
-
}
|
|
672
|
-
var tableCommands = {
|
|
673
|
-
addRowBefore,
|
|
674
|
-
addRowAfter,
|
|
675
|
-
deleteRow,
|
|
676
|
-
addColumnBefore,
|
|
677
|
-
addColumnAfter,
|
|
678
|
-
deleteColumn,
|
|
679
|
-
mergeCells,
|
|
680
|
-
splitCell,
|
|
681
|
-
// Без устаревшей логики (та смотрит на угловую ячейку и путает строку/столбец заголовков).
|
|
682
|
-
toggleHeaderRow: toggleHeader("row"),
|
|
683
|
-
toggleHeaderColumn: toggleHeader("column"),
|
|
684
|
-
deleteTable
|
|
685
|
-
};
|
|
686
|
-
function setCellBackground(color) {
|
|
687
|
-
return setCellAttr("background", color);
|
|
688
|
-
}
|
|
689
|
-
function hasHeaderRow(state) {
|
|
690
|
-
if (!isInTable(state)) return false;
|
|
691
|
-
const firstRow = findTable(state.selection.$from)?.node.firstChild;
|
|
692
|
-
if (!firstRow || firstRow.childCount === 0) return false;
|
|
693
|
-
let all = true;
|
|
694
|
-
firstRow.forEach((cell) => {
|
|
695
|
-
if (cell.type !== state.schema.nodes.table_header) all = false;
|
|
696
|
-
});
|
|
697
|
-
return all;
|
|
698
|
-
}
|
|
699
|
-
function hasHeaderColumn(state) {
|
|
700
|
-
if (!isInTable(state)) return false;
|
|
701
|
-
const table = findTable(state.selection.$from)?.node;
|
|
702
|
-
if (!table) return false;
|
|
703
|
-
let all = true;
|
|
704
|
-
table.forEach((row) => {
|
|
705
|
-
if (row.firstChild?.type !== state.schema.nodes.table_header) all = false;
|
|
706
|
-
});
|
|
707
|
-
return all;
|
|
708
|
-
}
|
|
709
|
-
function tableRect(editor) {
|
|
710
|
-
const { state } = editor.view;
|
|
711
|
-
if (!isInTable(state)) return null;
|
|
712
|
-
const table = findTable(state.selection.$from);
|
|
713
|
-
if (!table) return null;
|
|
714
|
-
const dom = editor.view.nodeDOM(table.pos);
|
|
715
|
-
return dom?.getBoundingClientRect() ?? null;
|
|
716
|
-
}
|
|
717
|
-
function createTableGridPanel(onPick, label, gridLabel) {
|
|
718
|
-
let rows = 1;
|
|
719
|
-
let cols = 1;
|
|
720
|
-
const cells = [];
|
|
721
|
-
const caption = h("div", { className: "nova-grid-caption", "aria-live": "polite" });
|
|
722
|
-
const grid = h("div", { className: "nova-grid", role: "grid", "aria-label": gridLabel });
|
|
723
|
-
const paint = () => {
|
|
724
|
-
for (const cell of cells) {
|
|
725
|
-
const r = Number(cell.dataset.row);
|
|
726
|
-
const c = Number(cell.dataset.col);
|
|
727
|
-
cell.classList.toggle("is-on", r <= rows && c <= cols);
|
|
728
|
-
cell.tabIndex = r === rows && c === cols ? 0 : -1;
|
|
729
|
-
}
|
|
730
|
-
caption.textContent = label(rows, cols);
|
|
731
|
-
};
|
|
732
|
-
for (let r = 1; r <= MAX_GRID; r++) {
|
|
733
|
-
for (let c = 1; c <= MAX_GRID; c++) {
|
|
734
|
-
const cell = h("button", {
|
|
735
|
-
type: "button",
|
|
736
|
-
className: "nova-grid-cell",
|
|
737
|
-
role: "gridcell",
|
|
738
|
-
"aria-label": label(r, c),
|
|
739
|
-
"data-row": String(r),
|
|
740
|
-
"data-col": String(c)
|
|
741
|
-
});
|
|
742
|
-
cell.addEventListener("mouseenter", () => {
|
|
743
|
-
rows = r;
|
|
744
|
-
cols = c;
|
|
745
|
-
paint();
|
|
746
|
-
});
|
|
747
|
-
cell.addEventListener("click", () => onPick(r, c));
|
|
748
|
-
cells.push(cell);
|
|
749
|
-
grid.append(cell);
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
grid.addEventListener("keydown", (event) => {
|
|
753
|
-
const moves = {
|
|
754
|
-
ArrowRight: [0, 1],
|
|
755
|
-
ArrowLeft: [0, -1],
|
|
756
|
-
ArrowDown: [1, 0],
|
|
757
|
-
ArrowUp: [-1, 0]
|
|
758
|
-
};
|
|
759
|
-
const move = moves[event.key];
|
|
760
|
-
if (!move) return;
|
|
761
|
-
event.preventDefault();
|
|
762
|
-
rows = Math.min(MAX_GRID, Math.max(1, rows + move[0]));
|
|
763
|
-
cols = Math.min(MAX_GRID, Math.max(1, cols + move[1]));
|
|
764
|
-
paint();
|
|
765
|
-
cells[(rows - 1) * MAX_GRID + (cols - 1)].focus();
|
|
766
|
-
});
|
|
767
|
-
paint();
|
|
768
|
-
return h("div", { className: "nova-grid-panel" }, grid, caption);
|
|
769
|
-
}
|
|
770
|
-
function numericValue(text) {
|
|
771
|
-
const cleaned = text.replace(/\s/g, "").replace(/^[^\d+-]+|[^\d]+$/g, "").replace(/,(?=\d{3}(?:\D|$))/g, "").replace(",", ".");
|
|
772
|
-
if (!/^[+-]?\d+(\.\d+)?$/.test(cleaned)) return null;
|
|
773
|
-
return Number(cleaned);
|
|
774
|
-
}
|
|
775
|
-
function sortTarget(state) {
|
|
776
|
-
if (!isInTable(state)) return null;
|
|
777
|
-
const rect = selectedRect(state);
|
|
778
|
-
const table = rect.table;
|
|
779
|
-
let merged = false;
|
|
780
|
-
table.descendants((node) => {
|
|
781
|
-
if (node.attrs.colspan > 1 || node.attrs.rowspan > 1) merged = true;
|
|
782
|
-
return !merged && node.type.spec.tableRole !== "cell" && node.type.spec.tableRole !== "header_cell";
|
|
783
|
-
});
|
|
784
|
-
if (merged) return null;
|
|
785
|
-
const nodes = state.schema.nodes;
|
|
786
|
-
let headerRows = 0;
|
|
787
|
-
for (let i = 0; i < table.childCount; i++) {
|
|
788
|
-
let allHeaders = true;
|
|
789
|
-
table.child(i).forEach((cell) => {
|
|
790
|
-
if (cell.type !== nodes.table_header) allHeaders = false;
|
|
791
|
-
});
|
|
792
|
-
if (!allHeaders) break;
|
|
793
|
-
headerRows++;
|
|
794
|
-
}
|
|
795
|
-
if (table.childCount - headerRows < 2) return null;
|
|
796
|
-
return { pos: rect.tableStart - 1, table, column: rect.left, headerRows };
|
|
797
|
-
}
|
|
798
|
-
function sortTable(direction, locale) {
|
|
799
|
-
return (state, dispatch) => {
|
|
800
|
-
const target = sortTarget(state);
|
|
801
|
-
if (!target) return false;
|
|
802
|
-
if (dispatch) {
|
|
803
|
-
const { table, column, headerRows, pos } = target;
|
|
804
|
-
const rows = [];
|
|
805
|
-
table.forEach((row) => rows.push(row));
|
|
806
|
-
const head = rows.slice(0, headerRows);
|
|
807
|
-
const body = rows.slice(headerRows);
|
|
808
|
-
const texts = body.map(
|
|
809
|
-
(row) => column < row.childCount ? row.child(column).textContent.trim() : ""
|
|
810
|
-
);
|
|
811
|
-
const numbers = texts.map(numericValue);
|
|
812
|
-
const numeric = texts.every((t, i) => t === "" || numbers[i] !== null);
|
|
813
|
-
const collator = new Intl.Collator(locale, { numeric: true, sensitivity: "base" });
|
|
814
|
-
const order = body.map((row, i) => ({ row, i })).sort((a, b) => {
|
|
815
|
-
const ta = texts[a.i];
|
|
816
|
-
const tb = texts[b.i];
|
|
817
|
-
if (!ta || !tb) return ta ? -1 : tb ? 1 : a.i - b.i;
|
|
818
|
-
const cmp = numeric ? numbers[a.i] - numbers[b.i] : collator.compare(ta, tb);
|
|
819
|
-
return (direction === "asc" ? cmp : -cmp) || a.i - b.i;
|
|
820
|
-
}).map(({ row }) => row);
|
|
821
|
-
const sorted = table.copy(Fragment.from([...head, ...order]));
|
|
822
|
-
dispatch(state.tr.replaceWith(pos, pos + table.nodeSize, sorted).scrollIntoView());
|
|
823
|
-
}
|
|
824
|
-
return true;
|
|
825
|
-
};
|
|
826
|
-
}
|
|
827
|
-
var NovaTableView = class extends TableView {
|
|
828
|
-
constructor(node, cellMinWidth) {
|
|
829
|
-
super(node, cellMinWidth);
|
|
830
|
-
this.apply(node);
|
|
831
|
-
}
|
|
832
|
-
update(node) {
|
|
833
|
-
if (!super.update(node)) return false;
|
|
834
|
-
this.apply(node);
|
|
835
|
-
return true;
|
|
836
|
-
}
|
|
837
|
-
apply(node) {
|
|
838
|
-
const width = cssValue.length(node.attrs.width);
|
|
839
|
-
if (width) {
|
|
840
|
-
this.table.style.width = width;
|
|
841
|
-
this.table.style.minWidth = "";
|
|
842
|
-
}
|
|
843
|
-
const align = node.attrs.align;
|
|
844
|
-
this.table.style.marginLeft = align ? "auto" : "";
|
|
845
|
-
this.table.style.marginRight = align === "center" ? "auto" : "";
|
|
846
|
-
const cls = classAttr(node.attrs.class).class;
|
|
847
|
-
if (cls) this.table.setAttribute("class", cls);
|
|
848
|
-
else this.table.removeAttribute("class");
|
|
849
|
-
}
|
|
850
|
-
};
|
|
851
|
-
function getTableProps(state) {
|
|
852
|
-
const found = findTable(state.selection.$from);
|
|
853
|
-
return found ? {
|
|
854
|
-
width: found.node.attrs.width ?? null,
|
|
855
|
-
align: found.node.attrs.align ?? null,
|
|
856
|
-
class: found.node.attrs.class ?? null
|
|
857
|
-
} : null;
|
|
858
|
-
}
|
|
859
|
-
function setTableProps(props) {
|
|
860
|
-
return (state, dispatch) => {
|
|
861
|
-
const found = findTable(state.selection.$from);
|
|
862
|
-
if (!found) return false;
|
|
863
|
-
if (props.width !== null && !cssValue.length(props.width)) return false;
|
|
864
|
-
const attrs = {
|
|
865
|
-
...found.node.attrs,
|
|
866
|
-
width: props.width,
|
|
867
|
-
align: props.align
|
|
868
|
-
};
|
|
869
|
-
if (props.class !== void 0) attrs.class = classAttr(props.class).class ?? null;
|
|
870
|
-
dispatch?.(state.tr.setNodeMarkup(found.pos, void 0, attrs));
|
|
871
|
-
return true;
|
|
872
|
-
};
|
|
873
|
-
}
|
|
874
|
-
function selectedCells(state) {
|
|
875
|
-
const out = [];
|
|
876
|
-
if (state.selection instanceof CellSelection) {
|
|
877
|
-
state.selection.forEachCell((node, pos) => out.push({ node, pos }));
|
|
878
|
-
return out;
|
|
879
|
-
}
|
|
880
|
-
const { $from } = state.selection;
|
|
881
|
-
for (let depth = $from.depth; depth > 0; depth--) {
|
|
882
|
-
const node = $from.node(depth);
|
|
883
|
-
const role = node.type.spec.tableRole;
|
|
884
|
-
if (role === "cell" || role === "header_cell") {
|
|
885
|
-
out.push({ node, pos: $from.before(depth) });
|
|
886
|
-
break;
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
return out;
|
|
890
|
-
}
|
|
891
|
-
function getCellProps(state) {
|
|
892
|
-
const cell = selectedCells(state)[0];
|
|
893
|
-
if (!cell) return null;
|
|
894
|
-
const widths = cell.node.attrs.colwidth;
|
|
895
|
-
return {
|
|
896
|
-
valign: cell.node.attrs.valign ?? null,
|
|
897
|
-
header: cell.node.type === state.schema.nodes.table_header,
|
|
898
|
-
width: widths?.[0] ?? null,
|
|
899
|
-
class: cell.node.attrs.class ?? null
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
function setCellProps(props) {
|
|
903
|
-
return (state, dispatch) => {
|
|
904
|
-
const cells = selectedCells(state);
|
|
905
|
-
if (!cells.length) return false;
|
|
906
|
-
if (props.width != null && !(props.width >= 24 && props.width <= 4e3)) return false;
|
|
907
|
-
if (!dispatch) return true;
|
|
908
|
-
const nodes = state.schema.nodes;
|
|
909
|
-
const tr = state.tr;
|
|
910
|
-
for (const { pos, node } of cells) {
|
|
911
|
-
const type = props.header === void 0 ? node.type : props.header ? nodes.table_header : nodes.table_cell;
|
|
912
|
-
const attrs = {
|
|
913
|
-
...node.attrs,
|
|
914
|
-
...props.valign !== void 0 ? { valign: props.valign } : {},
|
|
915
|
-
...props.class !== void 0 ? { class: classAttr(props.class).class ?? null } : {}
|
|
916
|
-
};
|
|
917
|
-
tr.setNodeMarkup(pos, type, attrs);
|
|
918
|
-
}
|
|
919
|
-
if (props.width !== void 0) {
|
|
920
|
-
const rect = selectedRect(state);
|
|
921
|
-
const map = rect.map;
|
|
922
|
-
const seen = /* @__PURE__ */ new Set();
|
|
923
|
-
for (let col = rect.left; col < rect.right; col++) {
|
|
924
|
-
for (let row = 0; row < map.height; row++) {
|
|
925
|
-
const cellPos = map.map[row * map.width + col];
|
|
926
|
-
const key = cellPos * 1e3 + col;
|
|
927
|
-
if (seen.has(key)) continue;
|
|
928
|
-
seen.add(key);
|
|
929
|
-
const absolute = rect.tableStart + cellPos;
|
|
930
|
-
const cell = tr.doc.nodeAt(absolute);
|
|
931
|
-
if (!cell) continue;
|
|
932
|
-
const index = col - map.colCount(cellPos);
|
|
933
|
-
const widths = [
|
|
934
|
-
...cell.attrs.colwidth ?? new Array(cell.attrs.colspan).fill(0)
|
|
935
|
-
];
|
|
936
|
-
widths[index] = props.width ?? 0;
|
|
937
|
-
tr.setNodeMarkup(absolute, void 0, {
|
|
938
|
-
...cell.attrs,
|
|
939
|
-
colwidth: widths.every((w) => !w) ? null : widths
|
|
940
|
-
});
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
dispatch(tr);
|
|
945
|
-
return true;
|
|
946
|
-
};
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
export {
|
|
950
|
-
openDialog,
|
|
951
|
-
textField,
|
|
952
|
-
selectField,
|
|
953
|
-
attachFilePicker,
|
|
954
|
-
isSupportedImage,
|
|
955
|
-
uploadImages,
|
|
956
|
-
embeddedImageUploadPlugin,
|
|
957
|
-
imageDropPastePlugin,
|
|
958
|
-
openImageDialog,
|
|
959
|
-
getSelectedImage,
|
|
960
|
-
setImageAttrs,
|
|
961
|
-
setImageWidthFraction,
|
|
962
|
-
openImageAltDialog,
|
|
963
|
-
normalizeUrl,
|
|
964
|
-
applyLink,
|
|
965
|
-
removeLink,
|
|
966
|
-
openLinkDialog,
|
|
967
|
-
isInTable,
|
|
968
|
-
createTable,
|
|
969
|
-
insertTable,
|
|
970
|
-
tablePlugins,
|
|
971
|
-
tableCommands,
|
|
972
|
-
setCellBackground,
|
|
973
|
-
hasHeaderRow,
|
|
974
|
-
hasHeaderColumn,
|
|
975
|
-
tableRect,
|
|
976
|
-
createTableGridPanel,
|
|
977
|
-
sortTable,
|
|
978
|
-
getTableProps,
|
|
979
|
-
setTableProps,
|
|
980
|
-
getCellProps,
|
|
981
|
-
setCellProps
|
|
982
|
-
};
|
|
983
|
-
//# sourceMappingURL=chunk-435CRWKA.js.map
|