@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
|
@@ -1,11 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
elementId
|
|
3
|
+
} from "./chunk-XR7CY4NI.js";
|
|
4
|
+
import {
|
|
5
|
+
codeLanguage
|
|
6
|
+
} from "./chunk-G74HNSB6.js";
|
|
1
7
|
import {
|
|
2
8
|
isSafeImageUrl,
|
|
3
9
|
isSafeLinkUrl
|
|
4
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4VPDY3LF.js";
|
|
11
|
+
|
|
12
|
+
// src/table-nodes.ts
|
|
13
|
+
function getCellAttrs(dom, extra) {
|
|
14
|
+
if (typeof dom === "string") return {};
|
|
15
|
+
const widthAttr = dom.getAttribute("data-colwidth");
|
|
16
|
+
const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr) ? widthAttr.split(",").map((s) => Number(s)) : null;
|
|
17
|
+
const colspan = Number(dom.getAttribute("colspan") || 1);
|
|
18
|
+
const result = {
|
|
19
|
+
colspan,
|
|
20
|
+
rowspan: Number(dom.getAttribute("rowspan") || 1),
|
|
21
|
+
colwidth: widths && widths.length === colspan ? widths : null
|
|
22
|
+
};
|
|
23
|
+
for (const [name, spec] of Object.entries(extra)) {
|
|
24
|
+
const value = spec.getFromDOM?.(dom);
|
|
25
|
+
if (value != null) result[name] = value;
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
function setCellAttrs(node, extra) {
|
|
30
|
+
const attrs = {};
|
|
31
|
+
if (node.attrs.colspan !== 1) attrs.colspan = node.attrs.colspan;
|
|
32
|
+
if (node.attrs.rowspan !== 1) attrs.rowspan = node.attrs.rowspan;
|
|
33
|
+
if (Array.isArray(node.attrs.colwidth)) attrs["data-colwidth"] = node.attrs.colwidth.join(",");
|
|
34
|
+
for (const [name, spec] of Object.entries(extra)) spec.setDOMAttr?.(node.attrs[name], attrs);
|
|
35
|
+
return attrs;
|
|
36
|
+
}
|
|
37
|
+
function validateColwidth(value) {
|
|
38
|
+
if (value === null) return;
|
|
39
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "number")) {
|
|
40
|
+
throw new TypeError("colwidth must be null or an array of numbers");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function tableNodes(options) {
|
|
44
|
+
const extra = options.cellAttributes;
|
|
45
|
+
const cellAttrs = {
|
|
46
|
+
colspan: { default: 1, validate: "number" },
|
|
47
|
+
rowspan: { default: 1, validate: "number" },
|
|
48
|
+
colwidth: { default: null, validate: validateColwidth }
|
|
49
|
+
};
|
|
50
|
+
for (const [name, spec] of Object.entries(extra)) cellAttrs[name] = { default: spec.default };
|
|
51
|
+
const cell = (tag, role) => ({
|
|
52
|
+
content: options.cellContent,
|
|
53
|
+
attrs: cellAttrs,
|
|
54
|
+
tableRole: role,
|
|
55
|
+
isolating: true,
|
|
56
|
+
parseDOM: [{ tag, getAttrs: (dom) => getCellAttrs(dom, extra) }],
|
|
57
|
+
toDOM: (node) => [tag, setCellAttrs(node, extra), 0]
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
table: {
|
|
61
|
+
content: "table_row+",
|
|
62
|
+
tableRole: "table",
|
|
63
|
+
isolating: true,
|
|
64
|
+
group: options.tableGroup,
|
|
65
|
+
parseDOM: [{ tag: "table" }],
|
|
66
|
+
toDOM: () => ["table", ["tbody", 0]]
|
|
67
|
+
},
|
|
68
|
+
table_row: {
|
|
69
|
+
content: "(table_cell | table_header)*",
|
|
70
|
+
tableRole: "row",
|
|
71
|
+
parseDOM: [{ tag: "tr" }],
|
|
72
|
+
toDOM: () => ["tr", 0]
|
|
73
|
+
},
|
|
74
|
+
table_cell: cell("td", "cell"),
|
|
75
|
+
table_header: cell("th", "header_cell")
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function isInTable(state) {
|
|
79
|
+
const { $head } = state.selection;
|
|
80
|
+
for (let depth = $head.depth; depth > 0; depth--) {
|
|
81
|
+
if ($head.node(depth).type.spec.tableRole === "row") return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
5
85
|
|
|
6
86
|
// src/schema.ts
|
|
7
|
-
import {
|
|
8
|
-
|
|
87
|
+
import {
|
|
88
|
+
Fragment,
|
|
89
|
+
Schema
|
|
90
|
+
} from "prosemirror-model";
|
|
9
91
|
var ALIGNMENTS = ["left", "center", "right", "justify"];
|
|
10
92
|
var COLOR_RE = /^(#[0-9a-f]{3,8}|rgba?\(\s*[\d.]+%?\s*,\s*[\d.]+%?\s*,\s*[\d.]+%?\s*(,\s*[\d.]+%?\s*)?\)|[a-z]{3,20})$/i;
|
|
11
93
|
var LENGTH_RE = /^\d{1,4}(\.\d{1,3})?(px|pt|em|rem|%)$/;
|
|
@@ -24,7 +106,7 @@ function normalizeColor(value) {
|
|
|
24
106
|
return v;
|
|
25
107
|
}
|
|
26
108
|
var cssValue = {
|
|
27
|
-
color: (v) => typeof v === "string" && COLOR_RE.test(v.trim()) && //
|
|
109
|
+
color: (v) => typeof v === "string" && COLOR_RE.test(v.trim()) && // Not colors but "default": transparent (Google Docs), windowtext and auto (Word).
|
|
28
110
|
!/^(inherit|initial|unset|currentcolor|transparent|windowtext|window|auto|none)$/i.test(
|
|
29
111
|
v.trim()
|
|
30
112
|
) ? normalizeColor(v) : null,
|
|
@@ -32,34 +114,57 @@ var cssValue = {
|
|
|
32
114
|
lineHeight: (v) => typeof v === "string" && LINE_HEIGHT_RE.test(v.trim()) && v.trim() !== "normal" ? v.trim() : null,
|
|
33
115
|
fontFamily: (v) => typeof v === "string" && FONT_FAMILY_RE.test(v.trim()) ? v.trim() : null
|
|
34
116
|
};
|
|
117
|
+
var INDENT_STEP = 40;
|
|
118
|
+
var MAX_INDENT = 10;
|
|
119
|
+
function indentLevel(value) {
|
|
120
|
+
const level = Math.trunc(Number(value));
|
|
121
|
+
return Number.isFinite(level) ? Math.min(MAX_INDENT, Math.max(0, level)) : 0;
|
|
122
|
+
}
|
|
123
|
+
var CSS_LENGTH = /^(\d+(?:\.\d+)?)(px|pt|em|rem)$/;
|
|
124
|
+
var PX_PER = { px: 1, pt: 4 / 3, em: 16, rem: 16 };
|
|
125
|
+
function readIndent(dom, dir) {
|
|
126
|
+
if (dom.parentElement?.tagName === "LI") return 0;
|
|
127
|
+
const style = dom.style;
|
|
128
|
+
const raw = dir === "rtl" ? style.marginRight || style.paddingRight : style.marginLeft || style.paddingLeft;
|
|
129
|
+
const m = CSS_LENGTH.exec(raw?.trim() ?? "");
|
|
130
|
+
return m ? indentLevel(Math.round(Number(m[1]) * PX_PER[m[2]] / INDENT_STEP)) : 0;
|
|
131
|
+
}
|
|
35
132
|
function readDir(dom) {
|
|
36
133
|
const dir = dom.getAttribute("dir")?.toLowerCase();
|
|
37
134
|
return dir === "rtl" || dir === "ltr" ? dir : null;
|
|
38
135
|
}
|
|
39
|
-
function readBlockStyle(dom) {
|
|
136
|
+
function readBlockStyle(dom, rtl = false) {
|
|
40
137
|
const align = dom.style.textAlign;
|
|
138
|
+
const dir = readDir(dom);
|
|
41
139
|
return {
|
|
42
140
|
align: ALIGNMENTS.includes(align) ? align : null,
|
|
43
141
|
lineHeight: cssValue.lineHeight(dom.style.lineHeight),
|
|
44
|
-
dir
|
|
142
|
+
dir,
|
|
143
|
+
indent: readIndent(dom, dir ?? (rtl ? "rtl" : null))
|
|
45
144
|
};
|
|
46
145
|
}
|
|
47
|
-
function blockStyleAttrs(attrs) {
|
|
146
|
+
function blockStyleAttrs(attrs, rtl = false) {
|
|
48
147
|
const out = {};
|
|
49
148
|
if (attrs.dir === "rtl" || attrs.dir === "ltr") out.dir = attrs.dir;
|
|
149
|
+
const end = attrs.dir === "rtl" || rtl && attrs.dir !== "ltr";
|
|
50
150
|
const parts = [];
|
|
51
151
|
const align = attrs.align;
|
|
52
152
|
if (align && ALIGNMENTS.includes(align))
|
|
53
153
|
parts.push(`text-align: ${align};`);
|
|
54
154
|
const lineHeight = cssValue.lineHeight(attrs.lineHeight);
|
|
55
155
|
if (lineHeight) parts.push(`line-height: ${lineHeight};`);
|
|
156
|
+
const indent = indentLevel(attrs.indent);
|
|
157
|
+
if (indent) {
|
|
158
|
+
parts.push(`margin-${end ? "right" : "left"}: ${indent * INDENT_STEP}px;`);
|
|
159
|
+
}
|
|
56
160
|
if (parts.length) out.style = parts.join(" ");
|
|
57
161
|
return out;
|
|
58
162
|
}
|
|
59
163
|
var blockStyleSpec = {
|
|
60
164
|
align: { default: null },
|
|
61
165
|
lineHeight: { default: null },
|
|
62
|
-
dir: { default: null }
|
|
166
|
+
dir: { default: null },
|
|
167
|
+
indent: { default: 0 }
|
|
63
168
|
};
|
|
64
169
|
var BULLET_STYLES = ["disc", "circle", "square"];
|
|
65
170
|
var ORDERED_STYLES = [
|
|
@@ -121,7 +226,7 @@ function buildTableNodes(allow) {
|
|
|
121
226
|
tableGroup: "block",
|
|
122
227
|
cellContent: "block+",
|
|
123
228
|
cellAttributes: {
|
|
124
|
-
//
|
|
229
|
+
// A cell style from the list (tableCellClassList): the site's CSS sets borders and padding.
|
|
125
230
|
class: {
|
|
126
231
|
default: null,
|
|
127
232
|
getFromDOM: (dom) => readClass(dom, allow),
|
|
@@ -132,9 +237,9 @@ function buildTableNodes(allow) {
|
|
|
132
237
|
},
|
|
133
238
|
background: {
|
|
134
239
|
default: null,
|
|
135
|
-
//
|
|
240
|
+
// The background was moved into a data attribute beforehand (parser.ts → preprocessDOM); style is the fallback.
|
|
136
241
|
getFromDOM: (dom) => cssValue.color(
|
|
137
|
-
dom.getAttribute("data-nova-cell-bg") ?? dom.style
|
|
242
|
+
dom.getAttribute("data-nova-cell-bg") ?? dom.style?.backgroundColor
|
|
138
243
|
),
|
|
139
244
|
setDOMAttr: (value, attrs) => {
|
|
140
245
|
const color = cssValue.color(value);
|
|
@@ -159,7 +264,7 @@ function buildTableNodes(allow) {
|
|
|
159
264
|
specs.table.attrs = {
|
|
160
265
|
width: { default: null },
|
|
161
266
|
align: { default: null },
|
|
162
|
-
//
|
|
267
|
+
// A table style from the list (tableClassList): "with borders", "layout without borders"…
|
|
163
268
|
class: { default: null }
|
|
164
269
|
};
|
|
165
270
|
specs.table.parseDOM = [
|
|
@@ -204,6 +309,64 @@ function buildTableNodes(allow) {
|
|
|
204
309
|
}
|
|
205
310
|
var NO_CLASSES = () => false;
|
|
206
311
|
var CLASS_TOKEN = /^-?[_a-zA-Z][\w-]*$/;
|
|
312
|
+
var LANGUAGE_CLASS = /(?:^|\s)lang(?:uage)?-(\S+)/;
|
|
313
|
+
function readCodeLanguage(pre) {
|
|
314
|
+
for (const el of [pre.querySelector("code"), pre]) {
|
|
315
|
+
if (!el) continue;
|
|
316
|
+
const value = codeLanguage(LANGUAGE_CLASS.exec(el.getAttribute("class") ?? "")?.[1]) ?? codeLanguage(el.getAttribute("data-language"));
|
|
317
|
+
if (value) return value;
|
|
318
|
+
}
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
var PRE_BLOCKS = /^(?:P|DIV|H[1-6]|LI|UL|OL|DL|DT|DD|TABLE|TR|BLOCKQUOTE|PRE|SECTION|ARTICLE|HEADER|FOOTER)$/;
|
|
322
|
+
function preText(pre) {
|
|
323
|
+
let out = "";
|
|
324
|
+
let pendingLine = false;
|
|
325
|
+
const add = (text) => {
|
|
326
|
+
if (!text) return;
|
|
327
|
+
if (pendingLine) out += "\n";
|
|
328
|
+
pendingLine = false;
|
|
329
|
+
out += text;
|
|
330
|
+
};
|
|
331
|
+
const walk = (node) => {
|
|
332
|
+
for (const child of node.childNodes) {
|
|
333
|
+
if (child.nodeType === 3) add(child.data);
|
|
334
|
+
else if (child.nodeType === 1) {
|
|
335
|
+
const tag = child.tagName;
|
|
336
|
+
if (tag === "BR") {
|
|
337
|
+
pendingLine = false;
|
|
338
|
+
out += "\n";
|
|
339
|
+
} else if (PRE_BLOCKS.test(tag)) {
|
|
340
|
+
if (out && (pendingLine || !out.endsWith("\n"))) out += "\n";
|
|
341
|
+
pendingLine = false;
|
|
342
|
+
walk(child);
|
|
343
|
+
pendingLine = true;
|
|
344
|
+
} else walk(child);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
walk(pre);
|
|
349
|
+
return out;
|
|
350
|
+
}
|
|
351
|
+
function isChecklistElement(dom) {
|
|
352
|
+
return dom.getAttribute("data-type") === "taskList" || dom.classList.contains("tox-checklist") || dom.classList.contains("contains-task-list");
|
|
353
|
+
}
|
|
354
|
+
function readChecked(dom) {
|
|
355
|
+
const list = dom.parentElement;
|
|
356
|
+
if (!list || !isChecklistElement(list)) return null;
|
|
357
|
+
const data = dom.getAttribute("data-checked");
|
|
358
|
+
if (data === "true" || data === "false") return data === "true";
|
|
359
|
+
if (dom.classList.contains("tox-checklist--checked")) return true;
|
|
360
|
+
const box = [...dom.querySelectorAll('input[type="checkbox"]')].find(
|
|
361
|
+
(el) => el.closest("li") === dom
|
|
362
|
+
);
|
|
363
|
+
if (box) return box.hasAttribute("checked");
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
function headingLevel(value) {
|
|
367
|
+
const level = Math.trunc(Number(value));
|
|
368
|
+
return level >= 1 && level <= 6 ? level : 1;
|
|
369
|
+
}
|
|
207
370
|
function readClass(dom, allow) {
|
|
208
371
|
const kept = [...dom.classList].filter((c) => CLASS_TOKEN.test(c) && allow(c));
|
|
209
372
|
return kept.length ? kept.join(" ") : null;
|
|
@@ -214,7 +377,7 @@ function classAttr(value) {
|
|
|
214
377
|
return tokens.length ? { class: tokens.join(" ") } : {};
|
|
215
378
|
}
|
|
216
379
|
var classSpec = { class: { default: null } };
|
|
217
|
-
var buildNodes = (allow) => ({
|
|
380
|
+
var buildNodes = (allow, rtl = false) => ({
|
|
218
381
|
doc: { content: "block+" },
|
|
219
382
|
paragraph: {
|
|
220
383
|
group: "block",
|
|
@@ -224,14 +387,14 @@ var buildNodes = (allow) => ({
|
|
|
224
387
|
{
|
|
225
388
|
tag: "p",
|
|
226
389
|
getAttrs: (dom) => ({
|
|
227
|
-
...readBlockStyle(dom),
|
|
390
|
+
...readBlockStyle(dom, rtl),
|
|
228
391
|
class: readClass(dom, allow)
|
|
229
392
|
})
|
|
230
393
|
}
|
|
231
394
|
],
|
|
232
395
|
toDOM: (node) => [
|
|
233
396
|
"p",
|
|
234
|
-
{ ...classAttr(node.attrs.class), ...blockStyleAttrs(node.attrs) },
|
|
397
|
+
{ ...classAttr(node.attrs.class), ...blockStyleAttrs(node.attrs, rtl) },
|
|
235
398
|
0
|
|
236
399
|
]
|
|
237
400
|
},
|
|
@@ -239,18 +402,25 @@ var buildNodes = (allow) => ({
|
|
|
239
402
|
group: "block",
|
|
240
403
|
content: "inline*",
|
|
241
404
|
defining: true,
|
|
242
|
-
|
|
405
|
+
// id is for links to a section (table of contents, #anchor); checked both when parsing and on output.
|
|
406
|
+
attrs: { level: { default: 1 }, id: { default: null }, ...blockStyleSpec, ...classSpec },
|
|
243
407
|
parseDOM: [1, 2, 3, 4, 5, 6].map((level) => ({
|
|
244
408
|
tag: `h${level}`,
|
|
245
409
|
getAttrs: (dom) => ({
|
|
246
410
|
level,
|
|
247
|
-
|
|
411
|
+
id: elementId(dom.getAttribute("id")),
|
|
412
|
+
...readBlockStyle(dom, rtl),
|
|
248
413
|
class: readClass(dom, allow)
|
|
249
414
|
})
|
|
250
415
|
})),
|
|
251
416
|
toDOM: (node) => [
|
|
252
|
-
|
|
253
|
-
{
|
|
417
|
+
// The level could come from JSON as anything: only 1–6 gets into the tag name.
|
|
418
|
+
`h${headingLevel(node.attrs.level)}`,
|
|
419
|
+
{
|
|
420
|
+
...elementId(node.attrs.id) ? { id: node.attrs.id } : {},
|
|
421
|
+
...classAttr(node.attrs.class),
|
|
422
|
+
...blockStyleAttrs(node.attrs, rtl)
|
|
423
|
+
},
|
|
254
424
|
0
|
|
255
425
|
]
|
|
256
426
|
},
|
|
@@ -283,35 +453,39 @@ var buildNodes = (allow) => ({
|
|
|
283
453
|
{
|
|
284
454
|
tag: "pre",
|
|
285
455
|
preserveWhitespace: "full",
|
|
286
|
-
getAttrs: (dom) => {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
456
|
+
getAttrs: (dom) => ({ language: readCodeLanguage(dom) }),
|
|
457
|
+
// The text, read as it is (see preText).
|
|
458
|
+
getContent: (dom, schema2) => {
|
|
459
|
+
const text = preText(dom);
|
|
460
|
+
return text ? Fragment.from(schema2.text(text)) : Fragment.empty;
|
|
290
461
|
}
|
|
291
462
|
}
|
|
292
463
|
],
|
|
293
|
-
toDOM: (node) =>
|
|
294
|
-
|
|
295
|
-
["code",
|
|
296
|
-
|
|
464
|
+
toDOM: (node) => {
|
|
465
|
+
const language = codeLanguage(node.attrs.language);
|
|
466
|
+
return ["pre", ["code", language ? { class: `language-${language}` } : {}, 0]];
|
|
467
|
+
}
|
|
297
468
|
},
|
|
469
|
+
// A checklist is a bulleted list with the checklist flag (items with checked): all the list mechanics
|
|
470
|
+
// (Enter, Tab, indents, paste, Markdown) work without a second list type. The HTML is Tiptap's
|
|
471
|
+
// (data-type="taskList"/"taskItem", data-checked); parsing understands TinyMCE and GitHub too.
|
|
298
472
|
bullet_list: {
|
|
299
473
|
group: "block",
|
|
300
474
|
content: "list_item+",
|
|
301
|
-
attrs: { listStyle: { default: null } },
|
|
475
|
+
attrs: { listStyle: { default: null }, checklist: { default: false } },
|
|
302
476
|
parseDOM: [
|
|
303
477
|
{
|
|
304
478
|
tag: "ul",
|
|
305
|
-
getAttrs: (dom) =>
|
|
306
|
-
|
|
307
|
-
|
|
479
|
+
getAttrs: (dom) => {
|
|
480
|
+
const checklist = isChecklistElement(dom);
|
|
481
|
+
return {
|
|
482
|
+
listStyle: checklist ? null : readListStyle(dom, BULLET_STYLES, "disc"),
|
|
483
|
+
checklist
|
|
484
|
+
};
|
|
485
|
+
}
|
|
308
486
|
}
|
|
309
487
|
],
|
|
310
|
-
toDOM: (node) => [
|
|
311
|
-
"ul",
|
|
312
|
-
listStyleAttrs(node.attrs.listStyle, BULLET_STYLES),
|
|
313
|
-
0
|
|
314
|
-
]
|
|
488
|
+
toDOM: (node) => node.attrs.checklist === true ? ["ul", { "data-type": "taskList" }, 0] : ["ul", listStyleAttrs(node.attrs.listStyle, BULLET_STYLES), 0]
|
|
315
489
|
},
|
|
316
490
|
ordered_list: {
|
|
317
491
|
group: "block",
|
|
@@ -341,10 +515,95 @@ var buildNodes = (allow) => ({
|
|
|
341
515
|
list_item: {
|
|
342
516
|
content: "paragraph block*",
|
|
343
517
|
defining: true,
|
|
344
|
-
|
|
345
|
-
|
|
518
|
+
// checked: null is a regular item; true/false is a checklist item (checked / not).
|
|
519
|
+
attrs: { checked: { default: null } },
|
|
520
|
+
parseDOM: [{ tag: "li", getAttrs: (dom) => ({ checked: readChecked(dom) }) }],
|
|
521
|
+
toDOM: (node) => typeof node.attrs.checked === "boolean" ? ["li", { "data-type": "taskItem", "data-checked": String(node.attrs.checked) }, 0] : ["li", 0]
|
|
346
522
|
},
|
|
347
523
|
text: { group: "inline" },
|
|
524
|
+
/**
|
|
525
|
+
* An image with a caption: <figure><img><figcaption>…</figcaption></figure>, as in HTML — two
|
|
526
|
+
* blocks inside. So the caption can't become a heading or a list (the schema won't let another
|
|
527
|
+
* block into figure) and the image is never lost. Image attributes live on figure_image, alignment on figure.
|
|
528
|
+
*/
|
|
529
|
+
figure: {
|
|
530
|
+
group: "block",
|
|
531
|
+
content: "figure_image figcaption",
|
|
532
|
+
draggable: true,
|
|
533
|
+
isolating: true,
|
|
534
|
+
attrs: { align: { default: null }, ...classSpec },
|
|
535
|
+
parseDOM: [
|
|
536
|
+
{
|
|
537
|
+
tag: "figure",
|
|
538
|
+
getAttrs: (dom) => {
|
|
539
|
+
const el = dom;
|
|
540
|
+
const img = el.querySelector("img");
|
|
541
|
+
if (!img || !isSafeImageUrl(img.getAttribute("src") ?? "")) return false;
|
|
542
|
+
return { align: readImageAlign(el), class: readClass(el, allow) };
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
],
|
|
546
|
+
toDOM: (node) => {
|
|
547
|
+
const width = imageSize(node.firstChild?.attrs.width);
|
|
548
|
+
const align = IMAGE_ALIGN_STYLES[node.attrs.align] ?? "";
|
|
549
|
+
const style = `${align}${width ? `${align ? " " : ""}width: ${width}px;` : ""}`;
|
|
550
|
+
return ["figure", { ...classAttr(node.attrs.class), ...style ? { style } : {} }, 0];
|
|
551
|
+
}
|
|
552
|
+
},
|
|
553
|
+
/** An image inside figure (a block, unlike an image in a line). */
|
|
554
|
+
figure_image: {
|
|
555
|
+
atom: true,
|
|
556
|
+
selectable: false,
|
|
557
|
+
attrs: {
|
|
558
|
+
// ProseMirror needs a default value so that a required node can be filled in.
|
|
559
|
+
src: { default: "" },
|
|
560
|
+
alt: { default: null },
|
|
561
|
+
title: { default: null },
|
|
562
|
+
width: { default: null },
|
|
563
|
+
height: { default: null }
|
|
564
|
+
},
|
|
565
|
+
parseDOM: [
|
|
566
|
+
{
|
|
567
|
+
tag: "img[src]",
|
|
568
|
+
context: "figure/",
|
|
569
|
+
priority: 60,
|
|
570
|
+
getAttrs: (dom) => {
|
|
571
|
+
const el = dom;
|
|
572
|
+
if (!isSafeImageUrl(el.getAttribute("src") ?? "")) return false;
|
|
573
|
+
return {
|
|
574
|
+
src: el.getAttribute("src"),
|
|
575
|
+
alt: el.getAttribute("alt"),
|
|
576
|
+
title: el.getAttribute("title"),
|
|
577
|
+
width: imageSize(el.getAttribute("width") ?? el.style.width),
|
|
578
|
+
height: imageSize(el.getAttribute("height") ?? el.style.height)
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
],
|
|
583
|
+
toDOM: (node) => {
|
|
584
|
+
const { alt, title } = node.attrs;
|
|
585
|
+
const src = isSafeImageUrl(node.attrs.src) ? node.attrs.src : "";
|
|
586
|
+
const width = imageSize(node.attrs.width);
|
|
587
|
+
const height = imageSize(node.attrs.height);
|
|
588
|
+
return [
|
|
589
|
+
"img",
|
|
590
|
+
{
|
|
591
|
+
src,
|
|
592
|
+
// alt="" (a decorative image) is kept: screen readers skip such an image instead of
|
|
593
|
+
// reading its file name. No alt at all means it was never given.
|
|
594
|
+
...alt === null || alt === void 0 ? {} : { alt: String(alt) },
|
|
595
|
+
...title ? { title } : {},
|
|
596
|
+
...width ? { width: String(width) } : {},
|
|
597
|
+
...height ? { height: String(height) } : {}
|
|
598
|
+
}
|
|
599
|
+
];
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
figcaption: {
|
|
603
|
+
content: "inline*",
|
|
604
|
+
parseDOM: [{ tag: "figcaption", context: "figure/" }],
|
|
605
|
+
toDOM: () => ["figcaption", 0]
|
|
606
|
+
},
|
|
348
607
|
image: {
|
|
349
608
|
group: "inline",
|
|
350
609
|
inline: true,
|
|
@@ -387,7 +646,9 @@ var buildNodes = (allow) => ({
|
|
|
387
646
|
{
|
|
388
647
|
src,
|
|
389
648
|
...classAttr(node.attrs.class),
|
|
390
|
-
|
|
649
|
+
// alt="" (a decorative image) is kept: screen readers skip such an image instead of
|
|
650
|
+
// reading its file name. No alt at all means it was never given.
|
|
651
|
+
...alt === null || alt === void 0 ? {} : { alt: String(alt) },
|
|
391
652
|
...title ? { title } : {},
|
|
392
653
|
...width ? { width: String(width) } : {},
|
|
393
654
|
...height ? { height: String(height) } : {},
|
|
@@ -441,10 +702,10 @@ var buildMarks = (allow) => ({
|
|
|
441
702
|
bold: {
|
|
442
703
|
parseDOM: [
|
|
443
704
|
{ tag: "strong" },
|
|
444
|
-
// <b style="font-weight: normal">
|
|
705
|
+
// <b style="font-weight: normal"> shows up in content pasted from Google Docs: that is not bold.
|
|
445
706
|
{
|
|
446
707
|
tag: "b",
|
|
447
|
-
getAttrs: (dom) => dom.style
|
|
708
|
+
getAttrs: (dom) => dom.style?.fontWeight !== "normal" && null
|
|
448
709
|
},
|
|
449
710
|
{
|
|
450
711
|
style: "font-weight",
|
|
@@ -471,12 +732,14 @@ var buildMarks = (allow) => ({
|
|
|
471
732
|
toDOM: () => ["s", 0]
|
|
472
733
|
},
|
|
473
734
|
code: {
|
|
735
|
+
// Code: typing rules (-- → —, ... → …) and autocorrect leave it as typed.
|
|
736
|
+
code: true,
|
|
474
737
|
parseDOM: [{ tag: "code" }],
|
|
475
738
|
toDOM: () => ["code", 0]
|
|
476
739
|
},
|
|
477
740
|
subscript: {
|
|
478
741
|
excludes: "superscript",
|
|
479
|
-
// vertical-align
|
|
742
|
+
// vertical-align: the way Google Docs and Word pass subscript.
|
|
480
743
|
parseDOM: [{ tag: "sub" }, { style: "vertical-align=sub" }],
|
|
481
744
|
toDOM: () => ["sub", 0]
|
|
482
745
|
},
|
|
@@ -485,7 +748,7 @@ var buildMarks = (allow) => ({
|
|
|
485
748
|
parseDOM: [{ tag: "sup" }, { style: "vertical-align=super" }],
|
|
486
749
|
toDOM: () => ["sup", 0]
|
|
487
750
|
},
|
|
488
|
-
// ----------
|
|
751
|
+
// ---------- text styles: <span style="…"> as in TinyMCE ----------
|
|
489
752
|
color: {
|
|
490
753
|
attrs: { value: {} },
|
|
491
754
|
parseDOM: [
|
|
@@ -515,13 +778,13 @@ var buildMarks = (allow) => ({
|
|
|
515
778
|
parseDOM: [{ style: "font-size", getAttrs: (v) => styleAttr(cssValue.length(v)) }],
|
|
516
779
|
toDOM: (mark) => styleSpan("font-size", cssValue.length(mark.attrs.value))
|
|
517
780
|
},
|
|
518
|
-
/** <span class="…"> —
|
|
781
|
+
/** <span class="…"> — an inline style from style_formats. Allowed classes only. */
|
|
519
782
|
span_class: {
|
|
520
783
|
attrs: { class: {} },
|
|
521
784
|
parseDOM: [
|
|
522
785
|
{
|
|
523
786
|
tag: "span[class]",
|
|
524
|
-
//
|
|
787
|
+
// Doesn't "consume" the span: the color and font marks parse its style attributes.
|
|
525
788
|
consuming: false,
|
|
526
789
|
getAttrs: (dom) => {
|
|
527
790
|
const value = readClass(dom, allow);
|
|
@@ -540,27 +803,86 @@ function styleSpan(property, value) {
|
|
|
540
803
|
return value ? ["span", { style: `${property}: ${value};` }, 0] : ["span", 0];
|
|
541
804
|
}
|
|
542
805
|
var schema = new Schema({ nodes, marks });
|
|
543
|
-
function
|
|
806
|
+
function withAttribute(name, attr, spec) {
|
|
807
|
+
const toDOM = spec.toDOM;
|
|
808
|
+
return {
|
|
809
|
+
...spec,
|
|
810
|
+
attrs: { ...spec.attrs, [name]: { default: attr.default } },
|
|
811
|
+
parseDOM: spec.parseDOM?.map((rule) => {
|
|
812
|
+
if (!rule.tag) return rule;
|
|
813
|
+
const getAttrs = rule.getAttrs;
|
|
814
|
+
return {
|
|
815
|
+
...rule,
|
|
816
|
+
getAttrs: (dom) => {
|
|
817
|
+
const base = getAttrs ? getAttrs(dom) : rule.attrs ?? null;
|
|
818
|
+
if (base === false) return false;
|
|
819
|
+
const value = attr.parse(dom);
|
|
820
|
+
return value == null ? base : { ...base, [name]: value };
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
}),
|
|
824
|
+
...toDOM ? {
|
|
825
|
+
toDOM: (node) => {
|
|
826
|
+
const out = toDOM(node);
|
|
827
|
+
const extra = attr.render(node.attrs[name]);
|
|
828
|
+
if (!Array.isArray(out) || typeof out[0] !== "string" || !Object.keys(extra).length)
|
|
829
|
+
return out;
|
|
830
|
+
const second = out[1];
|
|
831
|
+
const hasAttrs = !!second && typeof second === "object" && !Array.isArray(second) && second.nodeType === void 0;
|
|
832
|
+
return [
|
|
833
|
+
out[0],
|
|
834
|
+
{ ...hasAttrs ? second : {}, ...extra },
|
|
835
|
+
...out.slice(hasAttrs ? 2 : 1)
|
|
836
|
+
];
|
|
837
|
+
}
|
|
838
|
+
} : {}
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
var holdsText = (spec) => /\b(inline|text)\b/.test(spec.content ?? "");
|
|
842
|
+
function createSchema(extensions = {}, classFilter, htmlRules, direction = "ltr") {
|
|
843
|
+
const rtl = direction === "rtl";
|
|
544
844
|
const extraNodes = Object.entries(extensions.nodes ?? {});
|
|
545
845
|
const extraMarks = Object.entries(extensions.marks ?? {});
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
846
|
+
const attributes = Object.entries(extensions.attributes ?? {});
|
|
847
|
+
if (!extraNodes.length && !extraMarks.length && !attributes.length && !classFilter && !htmlRules && !rtl)
|
|
848
|
+
return schema;
|
|
849
|
+
let baseNodes = classFilter || rtl ? buildNodes(classFilter ?? NO_CLASSES, rtl) : nodes;
|
|
850
|
+
let baseMarks = classFilter ? buildMarks(classFilter) : marks;
|
|
851
|
+
const ref = {};
|
|
852
|
+
if (htmlRules) {
|
|
853
|
+
({ nodes: baseNodes, marks: baseMarks } = htmlRules.apply(
|
|
854
|
+
{ nodes: baseNodes, marks: baseMarks },
|
|
855
|
+
ref
|
|
856
|
+
));
|
|
857
|
+
}
|
|
549
858
|
for (const [name] of extraNodes) {
|
|
550
859
|
if (name in nodes) throw new Error(`[nova] node "${name}" already exists in the base schema`);
|
|
551
860
|
}
|
|
552
861
|
for (const [name] of extraMarks) {
|
|
553
862
|
if (name in marks) throw new Error(`[nova] mark "${name}" already exists in the base schema`);
|
|
554
863
|
}
|
|
555
|
-
|
|
556
|
-
|
|
864
|
+
let allNodes = { ...baseNodes, ...Object.fromEntries(extraNodes) };
|
|
865
|
+
const gets = (attr, node, spec) => attr.nodes === "all" ? node !== "doc" && node !== "text" : attr.nodes === "textblock" ? holdsText(spec) : attr.nodes.includes(node);
|
|
866
|
+
for (const [name, attr] of attributes) {
|
|
867
|
+
allNodes = Object.fromEntries(
|
|
868
|
+
Object.entries(allNodes).map(([node, spec]) => [
|
|
869
|
+
node,
|
|
870
|
+
gets(attr, node, spec) && !spec.attrs?.[name] ? withAttribute(name, attr, spec) : spec
|
|
871
|
+
])
|
|
872
|
+
);
|
|
873
|
+
}
|
|
874
|
+
ref.schema = new Schema({
|
|
875
|
+
nodes: allNodes,
|
|
557
876
|
marks: { ...baseMarks, ...Object.fromEntries(extraMarks) }
|
|
558
877
|
});
|
|
878
|
+
return ref.schema;
|
|
559
879
|
}
|
|
560
880
|
|
|
561
881
|
export {
|
|
882
|
+
isInTable,
|
|
562
883
|
ALIGNMENTS,
|
|
563
884
|
cssValue,
|
|
885
|
+
indentLevel,
|
|
564
886
|
BULLET_STYLES,
|
|
565
887
|
ORDERED_STYLES,
|
|
566
888
|
imageSize,
|
|
@@ -568,4 +890,4 @@ export {
|
|
|
568
890
|
schema,
|
|
569
891
|
createSchema
|
|
570
892
|
};
|
|
571
|
-
//# sourceMappingURL=chunk-
|
|
893
|
+
//# sourceMappingURL=chunk-TAM2FHKG.js.map
|