@novaprose/core 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -2
- package/dist/a11y.cjs +314 -0
- package/dist/a11y.cjs.map +1 -0
- package/dist/a11y.d.cts +51 -0
- package/dist/a11y.d.ts +51 -0
- package/dist/a11y.js +11 -0
- package/dist/a11y.js.map +1 -0
- package/dist/a11ychecker-7KQU7DD3.js +449 -0
- package/dist/a11ychecker-7KQU7DD3.js.map +1 -0
- package/dist/accordion-ui-FGN3I5UF.js +201 -0
- package/dist/accordion-ui-FGN3I5UF.js.map +1 -0
- package/dist/advcode-65Z2ELUB.js +51 -0
- package/dist/advcode-65Z2ELUB.js.map +1 -0
- package/dist/advcode-editor-WIOCY552.js +257 -0
- package/dist/advcode-editor-WIOCY552.js.map +1 -0
- package/dist/{advlist-5FNKPLUX.js → advlist-CEHE6YXS.js} +10 -7
- package/dist/advlist-CEHE6YXS.js.map +1 -0
- package/dist/advtable-ui-5CBOPTHW.js +364 -0
- package/dist/advtable-ui-5CBOPTHW.js.map +1 -0
- package/dist/ai-IRQYZHRK.js +1485 -0
- package/dist/ai-IRQYZHRK.js.map +1 -0
- package/dist/anchor-ui-NWIIRKGY.js +81 -0
- package/dist/anchor-ui-NWIIRKGY.js.map +1 -0
- package/dist/autocorrect-6GFLVDPC.js +851 -0
- package/dist/autocorrect-6GFLVDPC.js.map +1 -0
- package/dist/{autolink-45LTODWB.js → autolink-N427KVQO.js} +11 -8
- package/dist/autolink-N427KVQO.js.map +1 -0
- package/dist/{autoresize-UB3GOA6D.js → autoresize-YRZAVCNO.js} +2 -2
- package/dist/autoresize-YRZAVCNO.js.map +1 -0
- package/dist/{autosave-GMWJ5BPE.js → autosave-L7OZ3KLK.js} +7 -7
- package/dist/autosave-L7OZ3KLK.js.map +1 -0
- package/dist/casechange-5G6RAJ7K.js +201 -0
- package/dist/casechange-5G6RAJ7K.js.map +1 -0
- package/dist/{charmap-2GC7LF7G.js → charmap-5CBBDWOP.js} +7 -7
- package/dist/charmap-5CBBDWOP.js.map +1 -0
- package/dist/checklist-HM4VXZKY.js +189 -0
- package/dist/checklist-HM4VXZKY.js.map +1 -0
- package/dist/chunk-23ZLVT5D.js +163 -0
- package/dist/chunk-23ZLVT5D.js.map +1 -0
- package/dist/{chunk-ND2CWNVG.js → chunk-3BOK3S3T.js} +2 -27
- package/dist/chunk-3BOK3S3T.js.map +1 -0
- package/dist/chunk-4I4AYH2K.js +101 -0
- package/dist/chunk-4I4AYH2K.js.map +1 -0
- package/dist/{chunk-PVFKXRID.js → chunk-4VPDY3LF.js} +1 -1
- package/dist/chunk-4VPDY3LF.js.map +1 -0
- package/dist/chunk-53AY5NAF.js +214 -0
- package/dist/chunk-53AY5NAF.js.map +1 -0
- package/dist/chunk-5VCESSQB.js +137 -0
- package/dist/chunk-5VCESSQB.js.map +1 -0
- package/dist/chunk-66INZHZ2.js +79 -0
- package/dist/chunk-66INZHZ2.js.map +1 -0
- package/dist/chunk-6LQM7G4V.js +159 -0
- package/dist/chunk-6LQM7G4V.js.map +1 -0
- package/dist/chunk-6YSQGFV7.js +893 -0
- package/dist/chunk-6YSQGFV7.js.map +1 -0
- package/dist/{chunk-T3GY6IVK.js → chunk-AC3YCAX4.js} +71 -9
- package/dist/chunk-AC3YCAX4.js.map +1 -0
- package/dist/{chunk-5AW2HHG6.js → chunk-ADRPQLZ2.js} +47 -3
- package/dist/chunk-ADRPQLZ2.js.map +1 -0
- package/dist/chunk-ANE5ASXG.js +26 -0
- package/dist/chunk-ANE5ASXG.js.map +1 -0
- package/dist/{chunk-Z3ELZ77W.js → chunk-AP2PJFLB.js} +5 -2
- package/dist/chunk-AP2PJFLB.js.map +1 -0
- package/dist/chunk-AQV6FIKK.js +259 -0
- package/dist/chunk-AQV6FIKK.js.map +1 -0
- package/dist/chunk-AUQSATWL.js +322 -0
- package/dist/chunk-AUQSATWL.js.map +1 -0
- package/dist/chunk-C326LHHU.js +143 -0
- package/dist/chunk-C326LHHU.js.map +1 -0
- package/dist/{chunk-R2UMUCVI.js → chunk-DEYYVZ7O.js} +50 -8
- package/dist/chunk-DEYYVZ7O.js.map +1 -0
- package/dist/chunk-EOJ5XHKA.js +160 -0
- package/dist/chunk-EOJ5XHKA.js.map +1 -0
- package/dist/chunk-EXX2S352.js +3642 -0
- package/dist/chunk-EXX2S352.js.map +1 -0
- package/dist/chunk-FTEA6L2Q.js +47 -0
- package/dist/chunk-FTEA6L2Q.js.map +1 -0
- package/dist/chunk-G74HNSB6.js +9 -0
- package/dist/chunk-G74HNSB6.js.map +1 -0
- package/dist/{chunk-KWXFL4WS.js → chunk-GHVB6SV4.js} +8 -5
- package/dist/chunk-GHVB6SV4.js.map +1 -0
- package/dist/chunk-GTLE2HEW.js +108 -0
- package/dist/chunk-GTLE2HEW.js.map +1 -0
- package/dist/chunk-GXXXLPDQ.js +67 -0
- package/dist/chunk-GXXXLPDQ.js.map +1 -0
- package/dist/chunk-HC6RMBAD.js +163 -0
- package/dist/chunk-HC6RMBAD.js.map +1 -0
- package/dist/chunk-HNEAVVBC.js +98 -0
- package/dist/chunk-HNEAVVBC.js.map +1 -0
- package/dist/chunk-I7Y4KSM2.js +165 -0
- package/dist/chunk-I7Y4KSM2.js.map +1 -0
- package/dist/chunk-IG2BL4ON.js +127 -0
- package/dist/chunk-IG2BL4ON.js.map +1 -0
- package/dist/{chunk-KPE3QRPB.js → chunk-J6W2CDRF.js} +16 -315
- package/dist/chunk-J6W2CDRF.js.map +1 -0
- package/dist/chunk-LVEQBNLX.js +207 -0
- package/dist/chunk-LVEQBNLX.js.map +1 -0
- package/dist/chunk-MZGNOHSY.js +176 -0
- package/dist/chunk-MZGNOHSY.js.map +1 -0
- package/dist/chunk-N32H37AJ.js +373 -0
- package/dist/chunk-N32H37AJ.js.map +1 -0
- package/dist/chunk-NTGEKGXU.js +263 -0
- package/dist/chunk-NTGEKGXU.js.map +1 -0
- package/dist/chunk-OFHGXYG3.js +140 -0
- package/dist/chunk-OFHGXYG3.js.map +1 -0
- package/dist/chunk-OOVNE6MB.js +28 -0
- package/dist/chunk-OOVNE6MB.js.map +1 -0
- package/dist/chunk-OQMMHWMZ.js +7 -0
- package/dist/chunk-OQMMHWMZ.js.map +1 -0
- package/dist/chunk-P2UU2NLT.js +1149 -0
- package/dist/chunk-P2UU2NLT.js.map +1 -0
- package/dist/{chunk-JPJVTB45.js → chunk-QU3KXMYT.js} +8 -2
- package/dist/chunk-QU3KXMYT.js.map +1 -0
- package/dist/chunk-S2XZRKHA.js +29 -0
- package/dist/chunk-S2XZRKHA.js.map +1 -0
- package/dist/chunk-SCIRO4XK.js +144 -0
- package/dist/chunk-SCIRO4XK.js.map +1 -0
- package/dist/chunk-T3IRLTKK.js +158 -0
- package/dist/chunk-T3IRLTKK.js.map +1 -0
- package/dist/chunk-TABIUD2L.js +66 -0
- package/dist/chunk-TABIUD2L.js.map +1 -0
- package/dist/{chunk-FCMZ7TUQ.js → chunk-TAM2FHKG.js} +172 -43
- package/dist/chunk-TAM2FHKG.js.map +1 -0
- package/dist/chunk-UTMS2P2K.js +288 -0
- package/dist/chunk-UTMS2P2K.js.map +1 -0
- package/dist/{chunk-HPLT3XRZ.js → chunk-V7WUHUHM.js} +13 -1
- package/dist/chunk-V7WUHUHM.js.map +1 -0
- package/dist/{table-SSNABG5W.js → chunk-VK6YF2AA.js} +119 -61
- package/dist/chunk-VK6YF2AA.js.map +1 -0
- package/dist/chunk-WAOU5NGN.js +430 -0
- package/dist/chunk-WAOU5NGN.js.map +1 -0
- package/dist/chunk-XIH4SCO6.js +112 -0
- package/dist/chunk-XIH4SCO6.js.map +1 -0
- package/dist/chunk-XR7CY4NI.js +11 -0
- package/dist/chunk-XR7CY4NI.js.map +1 -0
- package/dist/chunk-YDF55N6Z.js +164 -0
- package/dist/chunk-YDF55N6Z.js.map +1 -0
- package/dist/chunk-YDPZCVXS.js +923 -0
- package/dist/chunk-YDPZCVXS.js.map +1 -0
- package/dist/chunk-YG5V7POU.js +137 -0
- package/dist/chunk-YG5V7POU.js.map +1 -0
- package/dist/chunk-YVSUR7E5.js +151 -0
- package/dist/chunk-YVSUR7E5.js.map +1 -0
- package/dist/codesample-GHWIC7PT.js +546 -0
- package/dist/codesample-GHWIC7PT.js.map +1 -0
- package/dist/{comments-panel-HXMWSRAW.js → comments-panel-SOLBZ46Q.js} +9 -5
- package/dist/comments-panel-SOLBZ46Q.js.map +1 -0
- package/dist/{directionality-5JLWQGP2.js → directionality-EGQKGDZA.js} +13 -10
- package/dist/directionality-EGQKGDZA.js.map +1 -0
- package/dist/document-0ft41E6d.d.ts +39 -0
- package/dist/document-IQqDDT4v.d.cts +39 -0
- package/dist/docx.cjs +23518 -0
- package/dist/docx.cjs.map +1 -0
- package/dist/docx.d.cts +83 -0
- package/dist/docx.d.ts +83 -0
- package/dist/docx.js +1821 -0
- package/dist/docx.js.map +1 -0
- package/dist/draghandle-U6CYZHPA.js +389 -0
- package/dist/draghandle-U6CYZHPA.js.map +1 -0
- package/dist/editimage-5EWPSM22.js +683 -0
- package/dist/editimage-5EWPSM22.js.map +1 -0
- package/dist/editor-BCMxe1M4.d.cts +2888 -0
- package/dist/editor-Dmtwjw2u.d.ts +2888 -0
- package/dist/email-ELNMEQ6E.js +177 -0
- package/dist/email-ELNMEQ6E.js.map +1 -0
- package/dist/email.cjs +588 -0
- package/dist/email.cjs.map +1 -0
- package/dist/email.d.cts +7 -0
- package/dist/email.d.ts +7 -0
- package/dist/email.js +21 -0
- package/dist/email.js.map +1 -0
- package/dist/{emoticons-ZD6ZRIWG.js → emoticons-EGHNZKSA.js} +7 -7
- package/dist/emoticons-EGHNZKSA.js.map +1 -0
- package/dist/exportpdf-4P7X3NY2.js +91 -0
- package/dist/exportpdf-4P7X3NY2.js.map +1 -0
- package/dist/exportword-JFJ3KTYZ.js +16 -0
- package/dist/exportword-JFJ3KTYZ.js.map +1 -0
- package/dist/footnotes-ui-FV6QRGDA.js +449 -0
- package/dist/footnotes-ui-FV6QRGDA.js.map +1 -0
- package/dist/form-dialog-SNWFPM2K.js +379 -0
- package/dist/form-dialog-SNWFPM2K.js.map +1 -0
- package/dist/formatpainter-IEXX27OJ.js +209 -0
- package/dist/formatpainter-IEXX27OJ.js.map +1 -0
- package/dist/fullpagehtml-ui-RE4C2NO5.js +220 -0
- package/dist/fullpagehtml-ui-RE4C2NO5.js.map +1 -0
- package/dist/html-rules-api-BLDDW9MO.d.cts +42 -0
- package/dist/html-rules-api-BLDDW9MO.d.ts +42 -0
- package/dist/html-rules.cjs +19 -17
- package/dist/html-rules.cjs.map +1 -1
- package/dist/html-rules.d.cts +37 -35
- package/dist/html-rules.d.ts +37 -35
- package/dist/html-rules.js +24 -20
- package/dist/html-rules.js.map +1 -1
- package/dist/i18n/de.cjs +346 -0
- package/dist/i18n/de.cjs.map +1 -1
- package/dist/i18n/de.d.cts +1 -1
- package/dist/i18n/de.d.ts +1 -1
- package/dist/i18n/de.js +346 -0
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/es.cjs +346 -0
- package/dist/i18n/es.cjs.map +1 -1
- package/dist/i18n/es.d.cts +1 -1
- package/dist/i18n/es.d.ts +1 -1
- package/dist/i18n/es.js +346 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.cjs +346 -0
- package/dist/i18n/fr.cjs.map +1 -1
- package/dist/i18n/fr.d.cts +1 -1
- package/dist/i18n/fr.d.ts +1 -1
- package/dist/i18n/fr.js +346 -0
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/it.cjs +346 -0
- package/dist/i18n/it.cjs.map +1 -1
- package/dist/i18n/it.d.cts +1 -1
- package/dist/i18n/it.d.ts +1 -1
- package/dist/i18n/it.js +346 -0
- package/dist/i18n/it.js.map +1 -1
- package/dist/i18n/pt-BR.cjs +346 -0
- package/dist/i18n/pt-BR.cjs.map +1 -1
- package/dist/i18n/pt-BR.d.cts +1 -1
- package/dist/i18n/pt-BR.d.ts +1 -1
- package/dist/i18n/pt-BR.js +346 -0
- package/dist/i18n/pt-BR.js.map +1 -1
- package/dist/i18n/ru.cjs +346 -0
- package/dist/i18n/ru.cjs.map +1 -1
- package/dist/i18n/ru.d.cts +3 -3
- package/dist/i18n/ru.d.ts +3 -3
- package/dist/i18n/ru.js +346 -0
- package/dist/i18n/ru.js.map +1 -1
- package/dist/importcss-JLNIRKGH.js +127 -0
- package/dist/importcss-JLNIRKGH.js.map +1 -0
- package/dist/importword-D7Z6RXGQ.js +73 -0
- package/dist/importword-D7Z6RXGQ.js.map +1 -0
- package/dist/{index-C603bU6r.d.ts → index-CZ9yDvmQ.d.cts} +36 -17
- package/dist/{index-C603bU6r.d.cts → index-CZ9yDvmQ.d.ts} +36 -17
- package/dist/index.cjs +28858 -10442
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +138 -64
- package/dist/index.d.ts +138 -64
- package/dist/index.js +199 -1411
- package/dist/index.js.map +1 -1
- package/dist/{insertdatetime-CRO7TJAQ.js → insertdatetime-YW2VHYZH.js} +7 -7
- package/dist/insertdatetime-YW2VHYZH.js.map +1 -0
- package/dist/linkchecker-3S3MCPOS.js +287 -0
- package/dist/linkchecker-3S3MCPOS.js.map +1 -0
- package/dist/markdown-26O3N3T2.js +136 -0
- package/dist/markdown-26O3N3T2.js.map +1 -0
- package/dist/markdown.cjs +94 -11
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.d.cts +12 -10
- package/dist/markdown.d.ts +12 -10
- package/dist/markdown.js +4 -235
- package/dist/markdown.js.map +1 -1
- package/dist/math-ui-RUTCHTRY.js +157 -0
- package/dist/math-ui-RUTCHTRY.js.map +1 -0
- package/dist/media-ui-36TE3CJD.js +123 -0
- package/dist/media-ui-36TE3CJD.js.map +1 -0
- package/dist/mediaembed-ui-ZNTGZ2SQ.js +207 -0
- package/dist/mediaembed-ui-ZNTGZ2SQ.js.map +1 -0
- package/dist/mentions-ui-O4IPWQT4.js +58 -0
- package/dist/mentions-ui-O4IPWQT4.js.map +1 -0
- package/dist/mergetags-ui-HS3Q2R36.js +73 -0
- package/dist/mergetags-ui-HS3Q2R36.js.map +1 -0
- package/dist/{nonbreaking-66LFZV2W.js → nonbreaking-GYRUH4UO.js} +7 -7
- package/dist/nonbreaking-GYRUH4UO.js.map +1 -0
- package/dist/pagebreak-ui-I4ZPYK3U.js +50 -0
- package/dist/pagebreak-ui-I4ZPYK3U.js.map +1 -0
- package/dist/pageembed-ui-WOY6VWRJ.js +172 -0
- package/dist/pageembed-ui-WOY6VWRJ.js.map +1 -0
- package/dist/pagelayout-ui-Y2IM7FJQ.js +236 -0
- package/dist/pagelayout-ui-Y2IM7FJQ.js.map +1 -0
- package/dist/{paste-office-F3QW4WWO.js → paste-office-3A6KWKCV.js} +82 -2
- package/dist/paste-office-3A6KWKCV.js.map +1 -0
- package/dist/permanentpen-6D5LLKFX.js +206 -0
- package/dist/permanentpen-6D5LLKFX.js.map +1 -0
- package/dist/print-MZMLQIQX.js +178 -0
- package/dist/print-MZMLQIQX.js.map +1 -0
- package/dist/{quickbars-7E2QRS7J.js → quickbars-UZ2Q67TX.js} +20 -12
- package/dist/quickbars-UZ2Q67TX.js.map +1 -0
- package/dist/{revisionhistory-DXE7KU4R.js → revisionhistory-ACRB23HL.js} +42 -153
- package/dist/revisionhistory-ACRB23HL.js.map +1 -0
- package/dist/save-72ZLF6AO.js +120 -0
- package/dist/save-72ZLF6AO.js.map +1 -0
- package/dist/search-bar-HTZQNPD3.js +212 -0
- package/dist/search-bar-HTZQNPD3.js.map +1 -0
- package/dist/spellchecker-DJ7SP5JY.js +474 -0
- package/dist/spellchecker-DJ7SP5JY.js.map +1 -0
- package/dist/suggestions-panel-RJXC4LCM.js +596 -0
- package/dist/suggestions-panel-RJXC4LCM.js.map +1 -0
- package/dist/suggestions-ui-PODMNH7D.js +395 -0
- package/dist/suggestions-ui-PODMNH7D.js.map +1 -0
- package/dist/table-OBHE465Y.js +54 -0
- package/dist/table-OBHE465Y.js.map +1 -0
- package/dist/table-dialogs-UMIIZQYE.js +119 -0
- package/dist/table-dialogs-UMIIZQYE.js.map +1 -0
- package/dist/tableofcontents-ui-U2PYNPX6.js +167 -0
- package/dist/tableofcontents-ui-U2PYNPX6.js.map +1 -0
- package/dist/template-YYC2MGVH.js +278 -0
- package/dist/template-YYC2MGVH.js.map +1 -0
- package/dist/typography-EQUXUXIN.js +399 -0
- package/dist/typography-EQUXUXIN.js.map +1 -0
- package/dist/upload.cjs +160 -0
- package/dist/upload.cjs.map +1 -0
- package/dist/upload.d.cts +72 -0
- package/dist/upload.d.ts +72 -0
- package/dist/upload.js +132 -0
- package/dist/upload.js.map +1 -0
- package/dist/{visualblocks-6DLBXYOA.js → visualblocks-O5QW7ZDT.js} +7 -7
- package/dist/visualblocks-O5QW7ZDT.js.map +1 -0
- package/dist/visualchars-UQFRWQPE.js +134 -0
- package/dist/visualchars-UQFRWQPE.js.map +1 -0
- package/package.json +53 -3
- package/src/style.css +320 -544
- package/dist/advlist-5FNKPLUX.js.map +0 -1
- package/dist/autolink-45LTODWB.js.map +0 -1
- package/dist/autoresize-UB3GOA6D.js.map +0 -1
- package/dist/autosave-GMWJ5BPE.js.map +0 -1
- package/dist/charmap-2GC7LF7G.js.map +0 -1
- package/dist/chunk-5AW2HHG6.js.map +0 -1
- package/dist/chunk-DWZLSZDG.js +0 -5664
- package/dist/chunk-DWZLSZDG.js.map +0 -1
- package/dist/chunk-FCMZ7TUQ.js.map +0 -1
- package/dist/chunk-HPLT3XRZ.js.map +0 -1
- package/dist/chunk-JPJVTB45.js.map +0 -1
- package/dist/chunk-KPE3QRPB.js.map +0 -1
- package/dist/chunk-KWXFL4WS.js.map +0 -1
- package/dist/chunk-ND2CWNVG.js.map +0 -1
- package/dist/chunk-PVFKXRID.js.map +0 -1
- package/dist/chunk-R2UMUCVI.js.map +0 -1
- package/dist/chunk-T3GY6IVK.js.map +0 -1
- package/dist/chunk-Z3ELZ77W.js.map +0 -1
- package/dist/comments-panel-HXMWSRAW.js.map +0 -1
- package/dist/directionality-5JLWQGP2.js.map +0 -1
- package/dist/editor-CXkltf1R.d.ts +0 -1886
- package/dist/editor-CgSBFTke.d.cts +0 -1886
- package/dist/emoticons-ZD6ZRIWG.js.map +0 -1
- package/dist/form-dialog-QH6KAERD.js +0 -180
- package/dist/form-dialog-QH6KAERD.js.map +0 -1
- package/dist/html-rules-api-D3fKQi-R.d.cts +0 -40
- package/dist/html-rules-api-D3fKQi-R.d.ts +0 -40
- package/dist/insertdatetime-CRO7TJAQ.js.map +0 -1
- package/dist/nonbreaking-66LFZV2W.js.map +0 -1
- package/dist/paste-office-F3QW4WWO.js.map +0 -1
- package/dist/quickbars-7E2QRS7J.js.map +0 -1
- package/dist/revisionhistory-DXE7KU4R.js.map +0 -1
- package/dist/table-SSNABG5W.js.map +0 -1
- package/dist/visualblocks-6DLBXYOA.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugins/formatpainter.ts"],"sourcesContent":["import type { Mark, MarkType, Node as PMNode, NodeType } from 'prosemirror-model';\nimport type { EditorState, Transaction } from 'prosemirror-state';\nimport { keymap } from 'prosemirror-keymap';\nimport type { Editor } from '../editor';\nimport { definePlugin } from '../plugins';\nimport { icons } from '../ui/icons';\nimport { pickLabels } from './shared';\n\n/**\n * The formatpainter plugin (named as in TinyMCE): copy the formatting of one place and apply it to\n * another.\n *\n * - The `formatpainter` button copies the formatting at the cursor; the next selection made with the\n * mouse gets it, then the painter turns off. A double click keeps it on for several selections, until\n * the button again or Escape.\n * - Keyboard: Ctrl+Alt+C (⌘⌥C on a Mac) copies, Ctrl+Alt+V (⌘⌥V) applies to the selection; repeat as\n * often as needed.\n *\n * Copied: text formatting (bold, italic, underline, strikethrough, inline code, subscript, superscript,\n * text and background color, font, size, style classes) and the block's kind and layout (paragraph or\n * heading level, alignment, line height, indent). Links, comments and suggestions are not formatting:\n * they stay where they are. Block formatting is applied when the target is a cursor, several blocks or\n * a whole block; part of one block gets only the text formatting. A cursor in a word paints the word.\n */\n\nexport const LABELS = {\n en: {\n button: 'Format painter',\n copied: 'Format copied. Select the text to apply it to.',\n sticky: 'Format painter stays on. Press Escape to stop.',\n stored: 'Format copied',\n applied: 'Format applied',\n off: 'Format painter off',\n },\n};\n\n/** Marks that are formatting (copied and replaced); the rest (links, comments…) stay. */\nconst FORMAT_MARKS = [\n 'bold',\n 'italic',\n 'underline',\n 'strike',\n 'code',\n 'subscript',\n 'superscript',\n 'color',\n 'background',\n 'font_family',\n 'font_size',\n 'span_class',\n];\n/** Block attributes that are layout (copied with the block's kind). */\nconst BLOCK_ATTRS = ['align', 'lineHeight', 'indent'];\n\nexport interface CopiedFormat {\n marks: readonly Mark[];\n /** The source block's kind (paragraph, heading) and its layout attributes. */\n block: { type: NodeType; attrs: Record<string, unknown> } | null;\n}\n\nconst formatMarkTypes = (state: EditorState): MarkType[] =>\n FORMAT_MARKS.flatMap((name) => state.schema.marks[name] ?? []);\n\nconst isFormatMark = (mark: Mark) => FORMAT_MARKS.includes(mark.type.name);\n\n/** The formatting at the cursor, or of the first letter of the selection. */\nexport function copyFormat(state: EditorState): CopiedFormat {\n const { selection } = state;\n let marks: readonly Mark[] = selection.empty\n ? (state.storedMarks ?? selection.$from.marks())\n : [];\n if (!selection.empty) {\n state.doc.nodesBetween(selection.from, selection.to, (node) => {\n if (node.isText && !marks.length) marks = node.marks;\n return !marks.length;\n });\n }\n const source = selection.$from.parent;\n const block =\n source.isTextblock && !source.type.spec.code\n ? {\n type: source.type,\n attrs: Object.fromEntries(\n Object.entries(source.attrs).filter(\n ([key]) => key === 'level' || BLOCK_ATTRS.includes(key),\n ),\n ),\n }\n : null;\n return { marks: marks.filter(isFormatMark), block };\n}\n\n/** The word at a cursor, or null. */\nfunction wordAt(state: EditorState): { from: number; to: number } | null {\n const { $from } = state.selection;\n if (!$from.parent.isTextblock) return null;\n const text = $from.parent.textBetween(0, $from.parent.content.size, undefined, '\\ufffc');\n const word = /[\\p{L}\\p{N}\\p{M}'’]/u;\n let start = $from.parentOffset;\n let end = start;\n while (start > 0 && word.test(text[start - 1]!)) start--;\n while (end < text.length && word.test(text[end]!)) end++;\n return start === end ? null : { from: $from.start() + start, to: $from.start() + end };\n}\n\n/** The block's new kind and attributes, or null when it can't take the copied kind here. */\nfunction blockMarkup(\n tr: Transaction,\n pos: number,\n node: PMNode,\n block: NonNullable<CopiedFormat['block']>,\n): { type: NodeType; attrs: Record<string, unknown> } {\n const $pos = tr.doc.resolve(pos);\n const index = $pos.index();\n const canChange = $pos.parent.canReplaceWith(index, index + 1, block.type);\n const type = canChange ? block.type : node.type;\n const attrs: Record<string, unknown> = {};\n for (const key of Object.keys(type.spec.attrs ?? {})) {\n attrs[key] =\n key in block.attrs && (key !== 'level' || canChange) ? block.attrs[key] : node.attrs[key];\n }\n return { type, attrs };\n}\n\n/** Applies a copied format to the selection; null when there is nothing to change. */\nexport function applyFormat(state: EditorState, format: CopiedFormat): Transaction | null {\n const { selection } = state;\n const tr = state.tr;\n const range = selection.empty ? wordAt(state) : { from: selection.from, to: selection.to };\n if (range) {\n for (const type of formatMarkTypes(state)) tr.removeMark(range.from, range.to, type);\n for (const mark of format.marks) tr.addMark(range.from, range.to, mark);\n } else if (selection.empty) {\n // An empty line: what is typed next gets the format.\n const keep = (state.storedMarks ?? selection.$from.marks()).filter((m) => !isFormatMark(m));\n tr.setStoredMarks([...keep, ...format.marks]);\n }\n const { $from, $to } = selection;\n const wholeBlock =\n $from.sameParent($to) &&\n $from.parentOffset === 0 &&\n $to.parentOffset === $to.parent.content.size;\n if (format.block && (selection.empty || !$from.sameParent($to) || wholeBlock)) {\n const block = format.block;\n state.doc.nodesBetween(selection.from, selection.to, (node, pos) => {\n if (!node.isTextblock) return true;\n if (node.type.spec.code) return false;\n const mapped = tr.mapping.map(pos);\n const { type, attrs } = blockMarkup(tr, mapped, node, block);\n const same =\n type === node.type && Object.keys(attrs).every((key) => attrs[key] === node.attrs[key]);\n if (!same) tr.setNodeMarkup(mapped, type, attrs, node.marks);\n return false;\n });\n }\n return tr.docChanged || tr.storedMarksSet ? tr.scrollIntoView() : null;\n}\n\ntype Mode = 'off' | 'once' | 'sticky';\n\n/** The painter of one editor: shared by its keys (created first) and its button. */\ninterface Painter {\n format: CopiedFormat | null;\n mode: Mode;\n armedAt: number;\n}\n\nconst painters = new WeakMap<Editor, Painter>();\n\nfunction painterOf(editor: Editor): Painter {\n let painter = painters.get(editor);\n if (!painter) {\n painter = { format: null, mode: 'off', armedAt: 0 };\n painters.set(editor, painter);\n }\n return painter;\n}\n\nfunction setMode(editor: Editor, mode: Mode): void {\n painterOf(editor).mode = mode;\n editor.view.dom.style.cursor = mode === 'off' ? '' : 'copy';\n editor.updateUI();\n}\n\nfunction paint(editor: Editor): boolean {\n const { format } = painterOf(editor);\n if (!format) return false;\n const tr = applyFormat(editor.view.state, format);\n if (tr) editor.view.dispatch(tr);\n editor.ui.announce(pickLabels(editor, 'formatpainter', LABELS).applied);\n return true;\n}\n\nexport default definePlugin({\n name: 'formatpainter',\n toolbar: 'formatpainter',\n prosemirrorPlugins: (editor) => [\n keymap({\n 'Mod-Alt-c': (state) => {\n painterOf(editor).format = copyFormat(state);\n editor.ui.announce(pickLabels(editor, 'formatpainter', LABELS).stored);\n return true;\n },\n 'Mod-Alt-v': () => editor.isEditable() && paint(editor),\n Escape: () => {\n if (painterOf(editor).mode === 'off') return false;\n setMode(editor, 'off');\n editor.ui.announce(pickLabels(editor, 'formatpainter', LABELS).off);\n return true;\n },\n }),\n ],\n setup(editor: Editor) {\n const labels = pickLabels(editor, 'formatpainter', LABELS);\n const painter = painterOf(editor);\n\n const onMouseUp = () => {\n if (painter.mode === 'off') return;\n // After mouseup the browser still finishes the selection: let ProseMirror read it first.\n setTimeout(() => {\n if (painter.mode === 'off' || !editor.view.dom.isConnected) return;\n paint(editor);\n if (painter.mode === 'once') setMode(editor, 'off');\n }, 0);\n };\n editor.view.dom.addEventListener('mouseup', onMouseUp);\n\n /** On (copying the format at the cursor) or off. */\n const toggle = (e: Editor) => {\n if (painter.mode !== 'off') {\n setMode(e, 'off');\n e.ui.announce(labels.off);\n } else {\n painter.format = copyFormat(e.view.state);\n painter.armedAt = Date.now();\n setMode(e, 'once');\n e.ui.announce(labels.copied);\n }\n e.focus();\n };\n const isActive = () => painter.mode !== 'off';\n const isEnabled = (e: Editor) => e.isEditable();\n\n editor.ui.registry.addButton('formatpainter', {\n icon: icons.formatPainter,\n tooltip: labels.button,\n isActive,\n isEnabled,\n onAction: (e) => {\n if (painter.mode === 'once' && Date.now() - painter.armedAt < 500) {\n // The second click of a double click: keep painting.\n setMode(e, 'sticky');\n e.ui.announce(labels.sticky);\n e.focus();\n } else toggle(e);\n },\n });\n // The menu item (and mceToggleFormatPainter) is a plain on/off: a menu has no double click.\n editor.ui.registry.addMenuItem('formatpainter', {\n text: labels.button,\n icon: icons.formatPainter,\n isActive,\n isEnabled,\n onAction: toggle,\n });\n\n return () => {\n editor.view.dom.removeEventListener('mouseup', onMouseUp);\n painters.delete(editor);\n };\n },\n});\n"],"mappings":";;;;;;;;;;;;AAEA,SAAS,cAAc;AAuBhB,IAAM,SAAS;AAAA,EACpB,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,KAAK;AAAA,EACP;AACF;AAGA,IAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,cAAc,CAAC,SAAS,cAAc,QAAQ;AAQpD,IAAM,kBAAkB,CAAC,UACvB,aAAa,QAAQ,CAAC,SAAS,MAAM,OAAO,MAAM,IAAI,KAAK,CAAC,CAAC;AAE/D,IAAM,eAAe,CAAC,SAAe,aAAa,SAAS,KAAK,KAAK,IAAI;AAGlE,SAAS,WAAW,OAAkC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,WAAO,GAAG,SAAS,UAAU,iBAAiB;AAAA,MAC5C,MAAM,MAAM;AAAA,MACZ,SAAS,OAAO;AAAA,MAChB;AAAA,MACA;AAAA,MACA,UAAU,CAAC,MAAM;AACf,YAAI,QAAQ,SAAS,UAAU,KAAK,IAAI,IAAI,QAAQ,UAAU,KAAK;AAEjE,kBAAQ,GAAG,QAAQ;AACnB,YAAE,GAAG,SAAS,OAAO,MAAM;AAC3B,YAAE,MAAM;AAAA,QACV,MAAO,QAAO,CAAC;AAAA,MACjB;AAAA,IACF,CAAC;AAED,WAAO,GAAG,SAAS,YAAY,iBAAiB;AAAA,MAC9C,MAAM,OAAO;AAAA,MACb,MAAM,MAAM;AAAA,MACZ;AAAA,MACA;AAAA,MACA,UAAU;AAAA,IACZ,CAAC;AAED,WAAO,MAAM;AACX,aAAO,KAAK,IAAI,oBAAoB,WAAW,SAAS;AACxD,eAAS,OAAO,MAAM;AAAA,IACxB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cleanPage
|
|
3
|
+
} from "./chunk-AQV6FIKK.js";
|
|
4
|
+
import "./chunk-53AY5NAF.js";
|
|
5
|
+
import "./chunk-TAM2FHKG.js";
|
|
6
|
+
import "./chunk-XR7CY4NI.js";
|
|
7
|
+
import {
|
|
8
|
+
pickLabels
|
|
9
|
+
} from "./chunk-DEYYVZ7O.js";
|
|
10
|
+
import {
|
|
11
|
+
definePlugin
|
|
12
|
+
} from "./chunk-V7WUHUHM.js";
|
|
13
|
+
import "./chunk-QU3KXMYT.js";
|
|
14
|
+
import "./chunk-G74HNSB6.js";
|
|
15
|
+
import "./chunk-3BOK3S3T.js";
|
|
16
|
+
import "./chunk-4VPDY3LF.js";
|
|
17
|
+
|
|
18
|
+
// src/plugins/fullpagehtml-ui.ts
|
|
19
|
+
var ICON = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M9 13h6"/><path d="M9 17h4"/></svg>';
|
|
20
|
+
var LABELS = {
|
|
21
|
+
en: {
|
|
22
|
+
title: "Document properties",
|
|
23
|
+
tabAbout: "About the page",
|
|
24
|
+
tabSearch: "Language and search",
|
|
25
|
+
pageTitle: "Title",
|
|
26
|
+
pageTitleHint: "Shown on the browser tab and in search results.",
|
|
27
|
+
description: "Description",
|
|
28
|
+
descriptionHint: "Search engines may show it under the title.",
|
|
29
|
+
keywords: "Keywords",
|
|
30
|
+
keywordsHint: "Separated by commas.",
|
|
31
|
+
author: "Author",
|
|
32
|
+
language: "Language",
|
|
33
|
+
languageHint: "A language code, such as en or de-CH: screen readers use it.",
|
|
34
|
+
languageInvalid: "Enter a language code, such as en or pt-BR.",
|
|
35
|
+
robots: "Search engines",
|
|
36
|
+
robotsAll: "Show the page and follow its links",
|
|
37
|
+
robotsNoFollow: "Show the page, don\u2019t follow its links",
|
|
38
|
+
robotsNoIndex: "Don\u2019t show the page, follow its links",
|
|
39
|
+
robotsNone: "Don\u2019t show the page or follow its links",
|
|
40
|
+
encoding: "Character encoding",
|
|
41
|
+
encodingNone: "Not declared"
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var LANG_RE = /^[a-z]{1,8}(?:-[a-z0-9]{1,8}){0,4}$/i;
|
|
45
|
+
var isMeta = (el, name) => el.tag === "meta" && el.attrs.name?.toLowerCase() === name;
|
|
46
|
+
function metaContent(page, name) {
|
|
47
|
+
const el = page.head?.find((item) => isMeta(item, name));
|
|
48
|
+
return el && el.tag === "meta" ? el.attrs.content ?? "" : "";
|
|
49
|
+
}
|
|
50
|
+
function withMeta(head, name, content) {
|
|
51
|
+
const at = head.findIndex((el2) => isMeta(el2, name));
|
|
52
|
+
if (!content) return at < 0 ? head : head.filter((_, i) => i !== at);
|
|
53
|
+
const el = { tag: "meta", attrs: { name, content } };
|
|
54
|
+
return at < 0 ? [...head, el] : head.map((old, i) => i === at ? el : old);
|
|
55
|
+
}
|
|
56
|
+
var isCharset = (el) => el.tag === "meta" && (!!el.attrs.charset || el.attrs["http-equiv"]?.toLowerCase() === "content-type");
|
|
57
|
+
function charsetOf(page) {
|
|
58
|
+
const el = page.head?.find(isCharset);
|
|
59
|
+
if (!el || el.tag !== "meta") return "";
|
|
60
|
+
return el.attrs.charset ?? /charset=([\w.:-]+)/i.exec(el.attrs.content ?? "")?.[1] ?? "";
|
|
61
|
+
}
|
|
62
|
+
function withCharset(head, charset) {
|
|
63
|
+
const rest = head.filter((el) => !isCharset(el));
|
|
64
|
+
return charset ? [{ tag: "meta", attrs: { charset } }, ...rest] : rest;
|
|
65
|
+
}
|
|
66
|
+
function titleOf(page) {
|
|
67
|
+
const el = page.head?.find((item) => item.tag === "title");
|
|
68
|
+
return el?.tag === "title" ? el.text : "";
|
|
69
|
+
}
|
|
70
|
+
function withTitle(head, text) {
|
|
71
|
+
const at = head.findIndex((el2) => el2.tag === "title");
|
|
72
|
+
if (!text) return at < 0 ? head : head.filter((_, i) => i !== at);
|
|
73
|
+
const el = { tag: "title", text };
|
|
74
|
+
if (at >= 0) return head.map((old, i) => i === at ? el : old);
|
|
75
|
+
const after = head.findIndex((item) => !isCharset(item));
|
|
76
|
+
const index = after < 0 ? head.length : after;
|
|
77
|
+
return [...head.slice(0, index), el, ...head.slice(index)];
|
|
78
|
+
}
|
|
79
|
+
function robotsOf(page) {
|
|
80
|
+
const words = metaContent(page, "robots").toLowerCase().split(/[\s,]+/).filter(Boolean);
|
|
81
|
+
const none = words.includes("none");
|
|
82
|
+
return {
|
|
83
|
+
index: !none && !words.includes("noindex"),
|
|
84
|
+
follow: !none && !words.includes("nofollow"),
|
|
85
|
+
other: words.filter(
|
|
86
|
+
(w) => !["none", "noindex", "nofollow", "index", "follow", "all"].includes(w)
|
|
87
|
+
)
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
var ROBOTS = ["all", "nofollow", "noindex", "none"];
|
|
91
|
+
var fullpagehtml_ui_default = definePlugin({
|
|
92
|
+
name: "fullpagehtml-ui",
|
|
93
|
+
requires: ["fullpagehtml"],
|
|
94
|
+
setup(editor) {
|
|
95
|
+
const labels = pickLabels(editor, "fullpagehtml", LABELS);
|
|
96
|
+
const open = async () => {
|
|
97
|
+
const page = cleanPage(editor.view.state.doc.attrs.page);
|
|
98
|
+
const robots = robotsOf(page);
|
|
99
|
+
const charset = charsetOf(page);
|
|
100
|
+
const data = await editor.ui.dialog({
|
|
101
|
+
title: labels.title,
|
|
102
|
+
initialData: {
|
|
103
|
+
title: titleOf(page),
|
|
104
|
+
description: metaContent(page, "description"),
|
|
105
|
+
keywords: metaContent(page, "keywords"),
|
|
106
|
+
author: metaContent(page, "author"),
|
|
107
|
+
lang: page.html?.lang ?? "",
|
|
108
|
+
robots: robots.index ? robots.follow ? "all" : "nofollow" : robots.follow ? "noindex" : "none",
|
|
109
|
+
encoding: charset
|
|
110
|
+
},
|
|
111
|
+
// Two short tabs rather than one long form: the dialog fits a laptop's screen.
|
|
112
|
+
tabs: [
|
|
113
|
+
{
|
|
114
|
+
title: labels.tabAbout,
|
|
115
|
+
fields: [
|
|
116
|
+
{
|
|
117
|
+
type: "text",
|
|
118
|
+
name: "title",
|
|
119
|
+
label: labels.pageTitle,
|
|
120
|
+
hint: labels.pageTitleHint
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: "textarea",
|
|
124
|
+
name: "description",
|
|
125
|
+
label: labels.description,
|
|
126
|
+
hint: labels.descriptionHint,
|
|
127
|
+
rows: 3
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: "text",
|
|
131
|
+
name: "keywords",
|
|
132
|
+
label: labels.keywords,
|
|
133
|
+
hint: labels.keywordsHint
|
|
134
|
+
},
|
|
135
|
+
{ type: "text", name: "author", label: labels.author }
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
title: labels.tabSearch,
|
|
140
|
+
fields: [
|
|
141
|
+
{
|
|
142
|
+
type: "text",
|
|
143
|
+
name: "lang",
|
|
144
|
+
label: labels.language,
|
|
145
|
+
hint: labels.languageHint,
|
|
146
|
+
validate: (value2) => typeof value2 === "string" && value2.trim() && !LANG_RE.test(value2.trim()) ? labels.languageInvalid : null
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: "select",
|
|
150
|
+
name: "robots",
|
|
151
|
+
label: labels.robots,
|
|
152
|
+
options: [
|
|
153
|
+
{ value: "all", label: labels.robotsAll },
|
|
154
|
+
{ value: "nofollow", label: labels.robotsNoFollow },
|
|
155
|
+
{ value: "noindex", label: labels.robotsNoIndex },
|
|
156
|
+
{ value: "none", label: labels.robotsNone }
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
type: "select",
|
|
161
|
+
name: "encoding",
|
|
162
|
+
label: labels.encoding,
|
|
163
|
+
// The page's own encoding as it is written, and UTF-8.
|
|
164
|
+
options: [
|
|
165
|
+
{ value: "", label: labels.encodingNone },
|
|
166
|
+
...charset ? [{ value: charset, label: charset }] : [],
|
|
167
|
+
...charset.toUpperCase() !== "UTF-8" ? [{ value: "UTF-8", label: "UTF-8" }] : []
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
});
|
|
174
|
+
if (!data) return;
|
|
175
|
+
const value = (name) => typeof data[name] === "string" ? data[name].replace(/\s+/g, " ").trim() : "";
|
|
176
|
+
let head = page.head ?? [];
|
|
177
|
+
if (value("encoding") !== charset) head = withCharset(head, value("encoding"));
|
|
178
|
+
head = withTitle(head, value("title"));
|
|
179
|
+
head = withMeta(head, "description", value("description"));
|
|
180
|
+
head = withMeta(head, "keywords", value("keywords"));
|
|
181
|
+
head = withMeta(head, "author", value("author"));
|
|
182
|
+
const choice = ROBOTS.includes(data.robots) ? data.robots : "all";
|
|
183
|
+
const words = [
|
|
184
|
+
...choice === "noindex" || choice === "none" ? ["noindex"] : [],
|
|
185
|
+
...choice === "nofollow" || choice === "none" ? ["nofollow"] : [],
|
|
186
|
+
...robots.other
|
|
187
|
+
];
|
|
188
|
+
head = withMeta(head, "robots", words.join(", "));
|
|
189
|
+
const lang = value("lang");
|
|
190
|
+
const html = { ...page.html };
|
|
191
|
+
if (lang) html.lang = lang;
|
|
192
|
+
else delete html.lang;
|
|
193
|
+
const next = cleanPage({ ...page, html, head });
|
|
194
|
+
if (JSON.stringify(next) !== JSON.stringify(cleanPage(editor.view.state.doc.attrs.page))) {
|
|
195
|
+
editor.view.dispatch(editor.view.state.tr.setDocAttribute("page", next));
|
|
196
|
+
}
|
|
197
|
+
editor.focus();
|
|
198
|
+
};
|
|
199
|
+
editor.ui.registry.addButton("fullpagehtml", {
|
|
200
|
+
icon: ICON,
|
|
201
|
+
tooltip: labels.title,
|
|
202
|
+
isEnabled: (e) => e.isEditable(),
|
|
203
|
+
onAction: () => void open()
|
|
204
|
+
});
|
|
205
|
+
editor.ui.registry.addMenuItem("fullpagehtml", {
|
|
206
|
+
text: labels.title,
|
|
207
|
+
icon: ICON,
|
|
208
|
+
isEnabled: (e) => e.isEditable(),
|
|
209
|
+
onAction: () => void open()
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
export {
|
|
214
|
+
LABELS,
|
|
215
|
+
charsetOf,
|
|
216
|
+
fullpagehtml_ui_default as default,
|
|
217
|
+
metaContent,
|
|
218
|
+
titleOf
|
|
219
|
+
};
|
|
220
|
+
//# sourceMappingURL=fullpagehtml-ui-RE4C2NO5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugins/fullpagehtml-ui.ts"],"sourcesContent":["import { definePlugin } from '../plugins';\nimport { cleanPage, type HeadElement, type PageData } from './fullpagehtml';\nimport { pickLabels } from './shared';\n\n/** The lazy part of fullpagehtml: the Document properties dialog, its button and menu item. */\n\nconst ICON =\n '<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z\"/><path d=\"M14 3v5h5\"/><path d=\"M9 13h6\"/><path d=\"M9 17h4\"/></svg>';\n\nexport const LABELS = {\n en: {\n title: 'Document properties',\n tabAbout: 'About the page',\n tabSearch: 'Language and search',\n pageTitle: 'Title',\n pageTitleHint: 'Shown on the browser tab and in search results.',\n description: 'Description',\n descriptionHint: 'Search engines may show it under the title.',\n keywords: 'Keywords',\n keywordsHint: 'Separated by commas.',\n author: 'Author',\n language: 'Language',\n languageHint: 'A language code, such as en or de-CH: screen readers use it.',\n languageInvalid: 'Enter a language code, such as en or pt-BR.',\n robots: 'Search engines',\n robotsAll: 'Show the page and follow its links',\n robotsNoFollow: 'Show the page, don’t follow its links',\n robotsNoIndex: 'Don’t show the page, follow its links',\n robotsNone: 'Don’t show the page or follow its links',\n encoding: 'Character encoding',\n encodingNone: 'Not declared',\n },\n};\n\nconst LANG_RE = /^[a-z]{1,8}(?:-[a-z0-9]{1,8}){0,4}$/i;\n\ntype Head = HeadElement[];\n\nconst isMeta = (el: HeadElement, name: string) =>\n el.tag === 'meta' && el.attrs.name?.toLowerCase() === name;\n\n/** The content of <meta name=\"…\">. */\nexport function metaContent(page: PageData, name: string): string {\n const el = page.head?.find((item) => isMeta(item, name));\n return el && el.tag === 'meta' ? (el.attrs.content ?? '') : '';\n}\n\n/** The head with <meta name=\"…\"> set to `content` (removed when empty), in its place or at the end. */\nfunction withMeta(head: Head, name: string, content: string): Head {\n const at = head.findIndex((el) => isMeta(el, name));\n if (!content) return at < 0 ? head : head.filter((_, i) => i !== at);\n const el: HeadElement = { tag: 'meta', attrs: { name, content } };\n return at < 0 ? [...head, el] : head.map((old, i) => (i === at ? el : old));\n}\n\nconst isCharset = (el: HeadElement) =>\n el.tag === 'meta' &&\n (!!el.attrs.charset || el.attrs['http-equiv']?.toLowerCase() === 'content-type');\n\nexport function charsetOf(page: PageData): string {\n const el = page.head?.find(isCharset);\n if (!el || el.tag !== 'meta') return '';\n return el.attrs.charset ?? /charset=([\\w.:-]+)/i.exec(el.attrs.content ?? '')?.[1] ?? '';\n}\n\nfunction withCharset(head: Head, charset: string): Head {\n const rest = head.filter((el) => !isCharset(el));\n return charset ? [{ tag: 'meta', attrs: { charset } }, ...rest] : rest;\n}\n\nexport function titleOf(page: PageData): string {\n const el = page.head?.find((item) => item.tag === 'title');\n return el?.tag === 'title' ? el.text : '';\n}\n\n/** The head with its title (removed when empty), in its place or after the character encoding. */\nfunction withTitle(head: Head, text: string): Head {\n const at = head.findIndex((el) => el.tag === 'title');\n if (!text) return at < 0 ? head : head.filter((_, i) => i !== at);\n const el: HeadElement = { tag: 'title', text };\n if (at >= 0) return head.map((old, i) => (i === at ? el : old));\n const after = head.findIndex((item) => !isCharset(item));\n const index = after < 0 ? head.length : after;\n return [...head.slice(0, index), el, ...head.slice(index)];\n}\n\n/** noindex and nofollow from <meta name=\"robots\">; its other words are kept. */\nfunction robotsOf(page: PageData): { index: boolean; follow: boolean; other: string[] } {\n const words = metaContent(page, 'robots')\n .toLowerCase()\n .split(/[\\s,]+/)\n .filter(Boolean);\n const none = words.includes('none');\n return {\n index: !none && !words.includes('noindex'),\n follow: !none && !words.includes('nofollow'),\n other: words.filter(\n (w) => !['none', 'noindex', 'nofollow', 'index', 'follow', 'all'].includes(w),\n ),\n };\n}\n\nconst ROBOTS = ['all', 'nofollow', 'noindex', 'none'] as const;\n\nexport default definePlugin({\n name: 'fullpagehtml-ui',\n requires: ['fullpagehtml'],\n setup(editor) {\n const labels = pickLabels(editor, 'fullpagehtml', LABELS);\n\n const open = async () => {\n const page = cleanPage(editor.view.state.doc.attrs.page);\n const robots = robotsOf(page);\n const charset = charsetOf(page);\n const data = await editor.ui.dialog({\n title: labels.title,\n initialData: {\n title: titleOf(page),\n description: metaContent(page, 'description'),\n keywords: metaContent(page, 'keywords'),\n author: metaContent(page, 'author'),\n lang: page.html?.lang ?? '',\n robots: robots.index\n ? robots.follow\n ? 'all'\n : 'nofollow'\n : robots.follow\n ? 'noindex'\n : 'none',\n encoding: charset,\n },\n // Two short tabs rather than one long form: the dialog fits a laptop's screen.\n tabs: [\n {\n title: labels.tabAbout,\n fields: [\n {\n type: 'text',\n name: 'title',\n label: labels.pageTitle,\n hint: labels.pageTitleHint,\n },\n {\n type: 'textarea',\n name: 'description',\n label: labels.description,\n hint: labels.descriptionHint,\n rows: 3,\n },\n {\n type: 'text',\n name: 'keywords',\n label: labels.keywords,\n hint: labels.keywordsHint,\n },\n { type: 'text', name: 'author', label: labels.author },\n ],\n },\n {\n title: labels.tabSearch,\n fields: [\n {\n type: 'text',\n name: 'lang',\n label: labels.language,\n hint: labels.languageHint,\n validate: (value) =>\n typeof value === 'string' && value.trim() && !LANG_RE.test(value.trim())\n ? labels.languageInvalid\n : null,\n },\n {\n type: 'select',\n name: 'robots',\n label: labels.robots,\n options: [\n { value: 'all', label: labels.robotsAll },\n { value: 'nofollow', label: labels.robotsNoFollow },\n { value: 'noindex', label: labels.robotsNoIndex },\n { value: 'none', label: labels.robotsNone },\n ],\n },\n {\n type: 'select',\n name: 'encoding',\n label: labels.encoding,\n // The page's own encoding as it is written, and UTF-8.\n options: [\n { value: '', label: labels.encodingNone },\n ...(charset ? [{ value: charset, label: charset }] : []),\n ...(charset.toUpperCase() !== 'UTF-8'\n ? [{ value: 'UTF-8', label: 'UTF-8' }]\n : []),\n ],\n },\n ],\n },\n ],\n });\n if (!data) return;\n const value = (name: string) =>\n typeof data[name] === 'string' ? (data[name] as string).replace(/\\s+/g, ' ').trim() : '';\n let head: Head = page.head ?? [];\n // Unchanged, the page's own way of saying it stays.\n if (value('encoding') !== charset) head = withCharset(head, value('encoding'));\n head = withTitle(head, value('title'));\n head = withMeta(head, 'description', value('description'));\n head = withMeta(head, 'keywords', value('keywords'));\n head = withMeta(head, 'author', value('author'));\n const choice = ROBOTS.includes(data.robots as (typeof ROBOTS)[number])\n ? (data.robots as (typeof ROBOTS)[number])\n : 'all';\n const words = [\n ...(choice === 'noindex' || choice === 'none' ? ['noindex'] : []),\n ...(choice === 'nofollow' || choice === 'none' ? ['nofollow'] : []),\n ...robots.other,\n ];\n head = withMeta(head, 'robots', words.join(', '));\n const lang = value('lang');\n const html = { ...page.html };\n if (lang) html.lang = lang;\n else delete html.lang;\n const next = cleanPage({ ...page, html, head });\n if (JSON.stringify(next) !== JSON.stringify(cleanPage(editor.view.state.doc.attrs.page))) {\n editor.view.dispatch(editor.view.state.tr.setDocAttribute('page', next));\n }\n editor.focus();\n };\n\n editor.ui.registry.addButton('fullpagehtml', {\n icon: ICON,\n tooltip: labels.title,\n isEnabled: (e) => e.isEditable(),\n onAction: () => void open(),\n });\n editor.ui.registry.addMenuItem('fullpagehtml', {\n text: labels.title,\n icon: ICON,\n isEnabled: (e) => e.isEditable(),\n onAction: () => void open(),\n });\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAMA,IAAM,OACJ;AAEK,IAAM,SAAS;AAAA,EACpB,IAAI;AAAA,IACF,OAAO;AAAA,IACP,UAAU;AAAA,IACV,WAAW;AAAA,IACX,WAAW;AAAA,IACX,eAAe;AAAA,IACf,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,UAAU;AAAA,IACV,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,cAAc;AAAA,IACd,iBAAiB;AAAA,IACjB,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,cAAc;AAAA,EAChB;AACF;AAEA,IAAM,UAAU;AAIhB,IAAM,SAAS,CAAC,IAAiB,SAC/B,GAAG,QA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W,aAAa,WAAW,SAAS,CAAC,SAAS,IAAI,CAAC;AAAA,QAC/D,GAAI,WAAW,cAAc,WAAW,SAAS,CAAC,UAAU,IAAI,CAAC;AAAA,QACjE,GAAG,OAAO;AAAA,MACZ;AACA,aAAO,SAAS,MAAM,UAAU,MAAM,KAAK,IAAI,CAAC;AAChD,YAAM,OAAO,MAAM,MAAM;AACzB,YAAM,OAAO,EAAE,GAAG,KAAK,KAAK;AAC5B,UAAI,KAAM,MAAK,OAAO;AAAA,UACjB,QAAO,KAAK;AACjB,YAAM,OAAO,UAAU,EAAE,GAAG,MAAM,MAAM,KAAK,CAAC;AAC9C,UAAI,KAAK,UAAU,IAAI,MAAM,KAAK,UAAU,UAAU,OAAO,KAAK,MAAM,IAAI,MAAM,IAAI,CAAC,GAAG;AACxF,eAAO,KAAK,SAAS,OAAO,KAAK,MAAM,GAAG,gBAAgB,QAAQ,IAAI,CAAC;AAAA,MACzE;AACA,aAAO,MAAM;AAAA,IACf;AAEA,WAAO,GAAG,SAAS,UAAU,gBAAgB;AAAA,MAC3C,MAAM;AAAA,MACN,SAAS,OAAO;AAAA,MAChB,WAAW,CAAC,MAAM,EAAE,WAAW;AAAA,MAC/B,UAAU,MAAM,KAAK,KAAK;AAAA,IAC5B,CAAC;AACD,WAAO,GAAG,SAAS,YAAY,gBAAgB;AAAA,MAC7C,MAAM,OAAO;AAAA,MACb,MAAM;AAAA,MACN,WAAW,CAAC,MAAM,EAAE,WAAW;AAAA,MAC/B,UAAU,MAAM,KAAK,KAAK;AAAA,IAC5B,CAAC;AAAA,EACH;AACF,CAAC;","names":["el","value"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { NodeSpec, MarkSpec, Schema } from 'prosemirror-model';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The hook for element and attribute rules. The implementation is a separate import,
|
|
5
|
+
* `@novaprose/core/html-rules` (~3 KB gzip): few need it, so it isn't part of the first load.
|
|
6
|
+
*
|
|
7
|
+
* import { registerHtmlRules } from '@novaprose/core';
|
|
8
|
+
* import { htmlRules } from '@novaprose/core/html-rules';
|
|
9
|
+
* registerHtmlRules(htmlRules);
|
|
10
|
+
*/
|
|
11
|
+
interface HtmlRulesOptions {
|
|
12
|
+
/** Only these elements are allowed; attributes in [...] are the complete list for the element. */
|
|
13
|
+
validElements?: string;
|
|
14
|
+
/** More elements and attributes: 'div[class],h2[id],i[class],a[href|rel|data-*]'. */
|
|
15
|
+
extendedValidElements?: string;
|
|
16
|
+
/** Disallowed elements. */
|
|
17
|
+
invalidElements?: string;
|
|
18
|
+
/** Your own elements: 'my-widget,~my-chip' (~ — inline, like span; without ~ — a block, like div). */
|
|
19
|
+
customElements?: string;
|
|
20
|
+
}
|
|
21
|
+
/** The node and mark specs the document schema is built from; HTML rules change them before that. */
|
|
22
|
+
interface SchemaSpecs {
|
|
23
|
+
nodes: Record<string, NodeSpec>;
|
|
24
|
+
marks: Record<string, MarkSpec>;
|
|
25
|
+
}
|
|
26
|
+
/** The rules of one editor: they change the schema specs. */
|
|
27
|
+
interface HtmlRulesInstance {
|
|
28
|
+
/** Whether the rules allow class on a built-in element (then classes are kept). */
|
|
29
|
+
readonly classOnBuiltIn: boolean;
|
|
30
|
+
/** Specs with the rules applied; after the schema is created, store it in `ref.schema`. */
|
|
31
|
+
apply(specs: SchemaSpecs, ref: {
|
|
32
|
+
schema?: Schema;
|
|
33
|
+
}): SchemaSpecs;
|
|
34
|
+
}
|
|
35
|
+
interface HtmlRulesModule {
|
|
36
|
+
create(options: HtmlRulesOptions): HtmlRulesInstance | null;
|
|
37
|
+
}
|
|
38
|
+
/** Install the element and attribute rules (once per page). */
|
|
39
|
+
declare function registerHtmlRules(module: HtmlRulesModule): void;
|
|
40
|
+
|
|
41
|
+
export { registerHtmlRules as r };
|
|
42
|
+
export type { HtmlRulesInstance as H, SchemaSpecs as S, HtmlRulesOptions as a, HtmlRulesModule as b };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { NodeSpec, MarkSpec, Schema } from 'prosemirror-model';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The hook for element and attribute rules. The implementation is a separate import,
|
|
5
|
+
* `@novaprose/core/html-rules` (~3 KB gzip): few need it, so it isn't part of the first load.
|
|
6
|
+
*
|
|
7
|
+
* import { registerHtmlRules } from '@novaprose/core';
|
|
8
|
+
* import { htmlRules } from '@novaprose/core/html-rules';
|
|
9
|
+
* registerHtmlRules(htmlRules);
|
|
10
|
+
*/
|
|
11
|
+
interface HtmlRulesOptions {
|
|
12
|
+
/** Only these elements are allowed; attributes in [...] are the complete list for the element. */
|
|
13
|
+
validElements?: string;
|
|
14
|
+
/** More elements and attributes: 'div[class],h2[id],i[class],a[href|rel|data-*]'. */
|
|
15
|
+
extendedValidElements?: string;
|
|
16
|
+
/** Disallowed elements. */
|
|
17
|
+
invalidElements?: string;
|
|
18
|
+
/** Your own elements: 'my-widget,~my-chip' (~ — inline, like span; without ~ — a block, like div). */
|
|
19
|
+
customElements?: string;
|
|
20
|
+
}
|
|
21
|
+
/** The node and mark specs the document schema is built from; HTML rules change them before that. */
|
|
22
|
+
interface SchemaSpecs {
|
|
23
|
+
nodes: Record<string, NodeSpec>;
|
|
24
|
+
marks: Record<string, MarkSpec>;
|
|
25
|
+
}
|
|
26
|
+
/** The rules of one editor: they change the schema specs. */
|
|
27
|
+
interface HtmlRulesInstance {
|
|
28
|
+
/** Whether the rules allow class on a built-in element (then classes are kept). */
|
|
29
|
+
readonly classOnBuiltIn: boolean;
|
|
30
|
+
/** Specs with the rules applied; after the schema is created, store it in `ref.schema`. */
|
|
31
|
+
apply(specs: SchemaSpecs, ref: {
|
|
32
|
+
schema?: Schema;
|
|
33
|
+
}): SchemaSpecs;
|
|
34
|
+
}
|
|
35
|
+
interface HtmlRulesModule {
|
|
36
|
+
create(options: HtmlRulesOptions): HtmlRulesInstance | null;
|
|
37
|
+
}
|
|
38
|
+
/** Install the element and attribute rules (once per page). */
|
|
39
|
+
declare function registerHtmlRules(module: HtmlRulesModule): void;
|
|
40
|
+
|
|
41
|
+
export { registerHtmlRules as r };
|
|
42
|
+
export type { HtmlRulesInstance as H, SchemaSpecs as S, HtmlRulesOptions as a, HtmlRulesModule as b };
|
package/dist/html-rules.cjs
CHANGED
|
@@ -99,6 +99,8 @@ var BLOCK_LEVEL = /* @__PURE__ */ new Set([
|
|
|
99
99
|
]);
|
|
100
100
|
var ESSENTIAL = {
|
|
101
101
|
a: ["href"],
|
|
102
|
+
ul: ["data-type"],
|
|
103
|
+
li: ["data-type", "data-checked"],
|
|
102
104
|
img: ["src"],
|
|
103
105
|
td: ["colspan", "rowspan"],
|
|
104
106
|
th: ["colspan", "rowspan"]
|
|
@@ -144,10 +146,10 @@ function warn(tag, reason) {
|
|
|
144
146
|
console.warn(`[nova] <${tag}> in content rules is ignored: ${reason}`);
|
|
145
147
|
}
|
|
146
148
|
var HtmlRules = class {
|
|
147
|
-
/**
|
|
149
|
+
/** The element's attribute list (null — no list given, built-in attributes). */
|
|
148
150
|
elements = /* @__PURE__ */ new Map();
|
|
149
151
|
globals = [];
|
|
150
|
-
/**
|
|
152
|
+
/** Generic elements: tag in the input HTML → tag in the output (synonyms like `div/section`). */
|
|
151
153
|
blockTags = /* @__PURE__ */ new Map();
|
|
152
154
|
inlineTags = /* @__PURE__ */ new Map();
|
|
153
155
|
constructor(options) {
|
|
@@ -212,27 +214,27 @@ var HtmlRules = class {
|
|
|
212
214
|
apply(specs, ref) {
|
|
213
215
|
return applyHtmlRules(specs.nodes, specs.marks, this, ref);
|
|
214
216
|
}
|
|
215
|
-
/**
|
|
217
|
+
/** Whether there is anything to apply (otherwise the editor does without this module). */
|
|
216
218
|
get active() {
|
|
217
219
|
return this.elements.size > 0 || this.globals.length > 0;
|
|
218
220
|
}
|
|
219
|
-
/**
|
|
221
|
+
/** Whether the rules concern the element: an attribute list, values or common attributes. */
|
|
220
222
|
touches(tag) {
|
|
221
223
|
return this.globals.length > 0 || this.elements.has(tag);
|
|
222
224
|
}
|
|
223
225
|
rulesFor(tag) {
|
|
224
226
|
return [...this.elements.get(tag) ?? [], ...this.globals];
|
|
225
227
|
}
|
|
226
|
-
/**
|
|
228
|
+
/** Whether the rule allows an attribute (not counting the element's built-in attributes). */
|
|
227
229
|
allows(tag, name) {
|
|
228
230
|
if (NEVER_ATTR.test(name) || !ATTR_NAME.test(name)) return false;
|
|
229
231
|
return this.rulesFor(tag).some((rule) => matches(rule.name, name));
|
|
230
232
|
}
|
|
231
|
-
/**
|
|
233
|
+
/** Whether a built-in element may have attributes beyond its built-in ones (except class and style). */
|
|
232
234
|
extends(tag) {
|
|
233
235
|
return this.rulesFor(tag).some((rule) => rule.name !== "class" && rule.name !== "style");
|
|
234
236
|
}
|
|
235
|
-
/**
|
|
237
|
+
/** Whether the rules allow class on any built-in element (then classes are kept). */
|
|
236
238
|
get classOnBuiltIn() {
|
|
237
239
|
if (this.globals.some((r) => matches(r.name, "class"))) return true;
|
|
238
240
|
for (const [tag, attrs] of this.elements) {
|
|
@@ -240,14 +242,14 @@ var HtmlRules = class {
|
|
|
240
242
|
}
|
|
241
243
|
return false;
|
|
242
244
|
}
|
|
243
|
-
/**
|
|
245
|
+
/** All required attributes are present. */
|
|
244
246
|
hasRequired(tag, dom) {
|
|
245
247
|
return this.rulesFor(tag).every((rule) => !rule.required || dom.hasAttribute(rule.name));
|
|
246
248
|
}
|
|
247
249
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
250
|
+
* The element's attributes allowed by the rule (values checked), or null. `skip` — attributes the
|
|
251
|
+
* element itself doesn't keep: class and style of built-in elements (validClasses, validStyles,
|
|
252
|
+
* formatting marks). The parser moves the own style of new elements to OWN_STYLE (see parser.ts).
|
|
251
253
|
*/
|
|
252
254
|
readAttrs(tag, dom, skip) {
|
|
253
255
|
let out = null;
|
|
@@ -261,8 +263,8 @@ var HtmlRules = class {
|
|
|
261
263
|
return out;
|
|
262
264
|
}
|
|
263
265
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
+
* Attributes for output: built-in ones plus kept ones (`extras`, which may have come from JSON as
|
|
267
|
+
* anything), then the element's list and the value rules.
|
|
266
268
|
*/
|
|
267
269
|
outputAttrs(tag, builtIn, extras) {
|
|
268
270
|
const out = { ...builtIn };
|
|
@@ -295,7 +297,7 @@ var HtmlRules = class {
|
|
|
295
297
|
if (tag === "a" && out.target != null && out.rel == null) out.rel = "noopener noreferrer";
|
|
296
298
|
return out;
|
|
297
299
|
}
|
|
298
|
-
/**
|
|
300
|
+
/** Apply the rules to toDOM output: attributes of the spec's top element. */
|
|
299
301
|
decorate(spec, extras) {
|
|
300
302
|
if (!Array.isArray(spec) || typeof spec[0] !== "string") return spec;
|
|
301
303
|
const raw = spec[0];
|
|
@@ -431,7 +433,7 @@ function genericSpecs(rules) {
|
|
|
431
433
|
attrs,
|
|
432
434
|
parseDOM: inline.map(([input, output]) => ({
|
|
433
435
|
tag: input,
|
|
434
|
-
//
|
|
436
|
+
// Before marks of the same tag (it has 60) and built-in marks (italic for <i>).
|
|
435
437
|
priority: 65,
|
|
436
438
|
getAttrs: (dom) => dom.firstChild ? false : read(output, dom, false)
|
|
437
439
|
})),
|
|
@@ -442,11 +444,11 @@ function genericSpecs(rules) {
|
|
|
442
444
|
};
|
|
443
445
|
marks.html_inline = {
|
|
444
446
|
attrs,
|
|
445
|
-
//
|
|
447
|
+
// Different elements (abbr inside kbd) are instances of one mark and must not push each other out.
|
|
446
448
|
excludes: "",
|
|
447
449
|
parseDOM: inline.map(([input, output]) => ({
|
|
448
450
|
tag: input,
|
|
449
|
-
// span:
|
|
451
|
+
// span: after class marks and plugin nodes (they parse their own spans earlier).
|
|
450
452
|
priority: output === "span" ? 40 : 60,
|
|
451
453
|
getAttrs: (dom) => dom.firstChild ? read(output, dom, true) : false
|
|
452
454
|
})),
|