@novaprose/core 0.7.0 → 0.9.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-6ES3UMU3.js +449 -0
- package/dist/a11ychecker-6ES3UMU3.js.map +1 -0
- package/dist/accordion-ui-B4I2FJXE.js +201 -0
- package/dist/accordion-ui-B4I2FJXE.js.map +1 -0
- package/dist/advcode-7S6N64C7.js +51 -0
- package/dist/advcode-7S6N64C7.js.map +1 -0
- package/dist/advcode-editor-ENCPFVLO.js +257 -0
- package/dist/advcode-editor-ENCPFVLO.js.map +1 -0
- package/dist/{advlist-5FNKPLUX.js → advlist-FEDGNLMQ.js} +10 -7
- package/dist/advlist-FEDGNLMQ.js.map +1 -0
- package/dist/advtable-ui-JAVJY4L4.js +364 -0
- package/dist/advtable-ui-JAVJY4L4.js.map +1 -0
- package/dist/ai-5KM776QW.js +1485 -0
- package/dist/ai-5KM776QW.js.map +1 -0
- package/dist/anchor-ui-VPKNKZ7J.js +81 -0
- package/dist/anchor-ui-VPKNKZ7J.js.map +1 -0
- package/dist/autocorrect-5QLICCRN.js +851 -0
- package/dist/autocorrect-5QLICCRN.js.map +1 -0
- package/dist/{autolink-45LTODWB.js → autolink-ZYIPRXBA.js} +11 -8
- package/dist/autolink-ZYIPRXBA.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-IC7YYG44.js} +7 -7
- package/dist/autosave-IC7YYG44.js.map +1 -0
- package/dist/casechange-R7IO2APS.js +201 -0
- package/dist/casechange-R7IO2APS.js.map +1 -0
- package/dist/{charmap-2GC7LF7G.js → charmap-CARYZFKD.js} +7 -7
- package/dist/charmap-CARYZFKD.js.map +1 -0
- package/dist/checklist-7E47QW6L.js +189 -0
- package/dist/checklist-7E47QW6L.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-3KBQEAX2.js +926 -0
- package/dist/chunk-3KBQEAX2.js.map +1 -0
- package/dist/chunk-3NNILZVB.js +259 -0
- package/dist/chunk-3NNILZVB.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-5AW2HHG6.js → chunk-5KERLFDD.js} +50 -3
- package/dist/chunk-5KERLFDD.js.map +1 -0
- package/dist/{chunk-FCMZ7TUQ.js → chunk-6BJEOL5V.js} +296 -43
- package/dist/chunk-6BJEOL5V.js.map +1 -0
- package/dist/chunk-6LQM7G4V.js +159 -0
- package/dist/chunk-6LQM7G4V.js.map +1 -0
- package/dist/chunk-AB67XUSR.js +178 -0
- package/dist/chunk-AB67XUSR.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-ARBKIZZU.js +137 -0
- package/dist/chunk-ARBKIZZU.js.map +1 -0
- package/dist/chunk-AUQSATWL.js +322 -0
- package/dist/chunk-AUQSATWL.js.map +1 -0
- package/dist/chunk-BMCH63QN.js +165 -0
- package/dist/chunk-BMCH63QN.js.map +1 -0
- package/dist/chunk-BUABAYZL.js +160 -0
- package/dist/chunk-BUABAYZL.js.map +1 -0
- package/dist/chunk-DCMPJ25E.js +140 -0
- package/dist/chunk-DCMPJ25E.js.map +1 -0
- package/dist/chunk-DV7TGRU6.js +47 -0
- package/dist/chunk-DV7TGRU6.js.map +1 -0
- package/dist/chunk-F2WT77ZG.js +163 -0
- package/dist/chunk-F2WT77ZG.js.map +1 -0
- package/dist/chunk-FNJ7AEJK.js +955 -0
- package/dist/chunk-FNJ7AEJK.js.map +1 -0
- package/dist/chunk-G74HNSB6.js +9 -0
- package/dist/chunk-G74HNSB6.js.map +1 -0
- package/dist/chunk-GTLE2HEW.js +108 -0
- package/dist/chunk-GTLE2HEW.js.map +1 -0
- package/dist/chunk-GUZCRDK6.js +143 -0
- package/dist/chunk-GUZCRDK6.js.map +1 -0
- package/dist/chunk-HNEAVVBC.js +98 -0
- package/dist/chunk-HNEAVVBC.js.map +1 -0
- package/dist/chunk-HSVNJGK3.js +1149 -0
- package/dist/chunk-HSVNJGK3.js.map +1 -0
- package/dist/chunk-IFSD6O5M.js +29 -0
- package/dist/chunk-IFSD6O5M.js.map +1 -0
- package/dist/{table-SSNABG5W.js → chunk-IO5PU52K.js} +119 -61
- package/dist/chunk-IO5PU52K.js.map +1 -0
- package/dist/chunk-K4LFGNS7.js +137 -0
- package/dist/chunk-K4LFGNS7.js.map +1 -0
- package/dist/chunk-KGEHUWGL.js +79 -0
- package/dist/chunk-KGEHUWGL.js.map +1 -0
- package/dist/chunk-KW6ATQPN.js +151 -0
- package/dist/chunk-KW6ATQPN.js.map +1 -0
- package/dist/chunk-NX3KWIP5.js +207 -0
- package/dist/chunk-NX3KWIP5.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-JPJVTB45.js → chunk-QU3KXMYT.js} +8 -2
- package/dist/chunk-QU3KXMYT.js.map +1 -0
- package/dist/chunk-QWT56RVG.js +158 -0
- package/dist/chunk-QWT56RVG.js.map +1 -0
- package/dist/chunk-RJ7T56OH.js +3787 -0
- package/dist/chunk-RJ7T56OH.js.map +1 -0
- package/dist/{chunk-KWXFL4WS.js → chunk-RPHA4HRX.js} +8 -5
- package/dist/chunk-RPHA4HRX.js.map +1 -0
- package/dist/chunk-S4DCQA74.js +66 -0
- package/dist/chunk-S4DCQA74.js.map +1 -0
- package/dist/chunk-SCIRO4XK.js +144 -0
- package/dist/chunk-SCIRO4XK.js.map +1 -0
- package/dist/chunk-SNVYHGGO.js +127 -0
- package/dist/chunk-SNVYHGGO.js.map +1 -0
- package/dist/chunk-T4543CB2.js +67 -0
- package/dist/chunk-T4543CB2.js.map +1 -0
- package/dist/{chunk-T3GY6IVK.js → chunk-UHUOAQA6.js} +71 -9
- package/dist/chunk-UHUOAQA6.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-WAOU5NGN.js +430 -0
- package/dist/chunk-WAOU5NGN.js.map +1 -0
- package/dist/{chunk-R2UMUCVI.js → chunk-XCXJD5DO.js} +53 -8
- package/dist/chunk-XCXJD5DO.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-Y2OXWCM7.js +263 -0
- package/dist/chunk-Y2OXWCM7.js.map +1 -0
- package/dist/chunk-YDF55N6Z.js +164 -0
- package/dist/chunk-YDF55N6Z.js.map +1 -0
- package/dist/chunk-YOTA26H7.js +373 -0
- package/dist/chunk-YOTA26H7.js.map +1 -0
- package/dist/chunk-YP7N47QR.js +101 -0
- package/dist/chunk-YP7N47QR.js.map +1 -0
- package/dist/{chunk-KPE3QRPB.js → chunk-YYCDRUE2.js} +16 -315
- package/dist/chunk-YYCDRUE2.js.map +1 -0
- package/dist/codesample-FOWXMCTC.js +546 -0
- package/dist/codesample-FOWXMCTC.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-BXWXNPRZ.js} +13 -10
- package/dist/directionality-BXWXNPRZ.js.map +1 -0
- package/dist/document-B0hLRhuH.d.cts +39 -0
- package/dist/document-Dh-jz1SK.d.ts +39 -0
- package/dist/docx.cjs +23575 -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 +1826 -0
- package/dist/docx.js.map +1 -0
- package/dist/draghandle-3IBHVHDE.js +389 -0
- package/dist/draghandle-3IBHVHDE.js.map +1 -0
- package/dist/editimage-GTLFGHYU.js +683 -0
- package/dist/editimage-GTLFGHYU.js.map +1 -0
- package/dist/editor-DnAN9aPd.d.ts +2948 -0
- package/dist/editor-S8w_w5W0.d.cts +2948 -0
- package/dist/email-FDSENENR.js +177 -0
- package/dist/email-FDSENENR.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-SHYSAEID.js} +7 -7
- package/dist/emoticons-SHYSAEID.js.map +1 -0
- package/dist/exportpdf-TEBDQZSN.js +91 -0
- package/dist/exportpdf-TEBDQZSN.js.map +1 -0
- package/dist/exportword-BGH2CZXO.js +16 -0
- package/dist/exportword-BGH2CZXO.js.map +1 -0
- package/dist/footnotes-ui-KPKFDSN7.js +449 -0
- package/dist/footnotes-ui-KPKFDSN7.js.map +1 -0
- package/dist/form-dialog-SNWFPM2K.js +379 -0
- package/dist/form-dialog-SNWFPM2K.js.map +1 -0
- package/dist/formatpainter-CB4ZTKR5.js +209 -0
- package/dist/formatpainter-CB4ZTKR5.js.map +1 -0
- package/dist/fullpagehtml-ui-JPGRMXHD.js +220 -0
- package/dist/fullpagehtml-ui-JPGRMXHD.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 +21 -19
- 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 +26 -22
- package/dist/html-rules.js.map +1 -1
- package/dist/i18n/de.cjs +349 -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 +349 -0
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/es.cjs +349 -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 +349 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.cjs +349 -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 +349 -0
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/it.cjs +349 -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 +349 -0
- package/dist/i18n/it.js.map +1 -1
- package/dist/i18n/pt-BR.cjs +349 -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 +349 -0
- package/dist/i18n/pt-BR.js.map +1 -1
- package/dist/i18n/ru.cjs +349 -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 +349 -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-ZOWLUWSN.js +73 -0
- package/dist/importword-ZOWLUWSN.js.map +1 -0
- package/dist/{index-C603bU6r.d.ts → index-Pb2r0V-S.d.cts} +39 -17
- package/dist/{index-C603bU6r.d.cts → index-Pb2r0V-S.d.ts} +39 -17
- package/dist/index.cjs +29422 -10640
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +139 -64
- package/dist/index.d.ts +139 -64
- package/dist/index.js +204 -1412
- package/dist/index.js.map +1 -1
- package/dist/{insertdatetime-CRO7TJAQ.js → insertdatetime-BXQ3XXPH.js} +7 -7
- package/dist/insertdatetime-BXQ3XXPH.js.map +1 -0
- package/dist/linkchecker-JASSETVI.js +287 -0
- package/dist/linkchecker-JASSETVI.js.map +1 -0
- package/dist/markdown-OTLTCK26.js +136 -0
- package/dist/markdown-OTLTCK26.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-TY4VZF7Q.js +157 -0
- package/dist/math-ui-TY4VZF7Q.js.map +1 -0
- package/dist/media-ui-IXN4ENVF.js +123 -0
- package/dist/media-ui-IXN4ENVF.js.map +1 -0
- package/dist/mediaembed-ui-ODX5ECXC.js +207 -0
- package/dist/mediaembed-ui-ODX5ECXC.js.map +1 -0
- package/dist/mentions-ui-55GCKC6F.js +58 -0
- package/dist/mentions-ui-55GCKC6F.js.map +1 -0
- package/dist/mergetags-ui-6T7Z7MAZ.js +73 -0
- package/dist/mergetags-ui-6T7Z7MAZ.js.map +1 -0
- package/dist/{nonbreaking-66LFZV2W.js → nonbreaking-PONHSOMJ.js} +7 -7
- package/dist/nonbreaking-PONHSOMJ.js.map +1 -0
- package/dist/pagebreak-ui-AKAW7M5I.js +50 -0
- package/dist/pagebreak-ui-AKAW7M5I.js.map +1 -0
- package/dist/pageembed-ui-GUNPKMBR.js +172 -0
- package/dist/pageembed-ui-GUNPKMBR.js.map +1 -0
- package/dist/pagelayout-ui-JSFVEMHS.js +236 -0
- package/dist/pagelayout-ui-JSFVEMHS.js.map +1 -0
- package/dist/{paste-office-F3QW4WWO.js → paste-office-TORLAZ5L.js} +94 -4
- package/dist/paste-office-TORLAZ5L.js.map +1 -0
- package/dist/permanentpen-EACURV5U.js +206 -0
- package/dist/permanentpen-EACURV5U.js.map +1 -0
- package/dist/print-4XJCOANX.js +178 -0
- package/dist/print-4XJCOANX.js.map +1 -0
- package/dist/{quickbars-7E2QRS7J.js → quickbars-BT5PETRX.js} +20 -12
- package/dist/quickbars-BT5PETRX.js.map +1 -0
- package/dist/{revisionhistory-DXE7KU4R.js → revisionhistory-3FKLMJHJ.js} +42 -153
- package/dist/revisionhistory-3FKLMJHJ.js.map +1 -0
- package/dist/save-ZHFXH222.js +120 -0
- package/dist/save-ZHFXH222.js.map +1 -0
- package/dist/search-bar-6MVRMTK6.js +212 -0
- package/dist/search-bar-6MVRMTK6.js.map +1 -0
- package/dist/spellchecker-JJKA6B4R.js +474 -0
- package/dist/spellchecker-JJKA6B4R.js.map +1 -0
- package/dist/suggestions-panel-X37NFLXE.js +596 -0
- package/dist/suggestions-panel-X37NFLXE.js.map +1 -0
- package/dist/suggestions-ui-WN7QNYHB.js +395 -0
- package/dist/suggestions-ui-WN7QNYHB.js.map +1 -0
- package/dist/table-PEF56QG5.js +54 -0
- package/dist/table-PEF56QG5.js.map +1 -0
- package/dist/table-dialogs-QS3VFZD2.js +119 -0
- package/dist/table-dialogs-QS3VFZD2.js.map +1 -0
- package/dist/tableofcontents-ui-U7EV3UU7.js +167 -0
- package/dist/tableofcontents-ui-U7EV3UU7.js.map +1 -0
- package/dist/template-ZRTKIP2J.js +278 -0
- package/dist/template-ZRTKIP2J.js.map +1 -0
- package/dist/typography-S7RO54DB.js +399 -0
- package/dist/typography-S7RO54DB.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-KJYRHF2L.js} +7 -7
- package/dist/visualblocks-KJYRHF2L.js.map +1 -0
- package/dist/visualchars-TDLZKFXD.js +134 -0
- package/dist/visualchars-TDLZKFXD.js.map +1 -0
- package/package.json +53 -3
- package/src/style.css +376 -550
- 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
package/dist/html-rules.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/html-rules.ts","../src/html-rules-api.ts","../src/url.ts","../src/safe-attr.ts"],"sourcesContent":["/**\n * Правила HTML-элементов и атрибутов: validElements (с атрибутами), extendedValidElements и\n * customElements. Синтаксис — как у одноимённых опций TinyMCE (по их публичной документации):\n * `a[href|title],div[class|data-*],@[id],my-widget`.\n *\n * Два направления:\n * 1. Ограничение. Список в [...] — полный список атрибутов элемента: `a[href|title]` снимает\n * target и class. Значения: `name=v` — по умолчанию, `name:v` — всегда, `name<a?b` — только из\n * списка, `!name` — обязателен (без него элемент не распознаётся). `@[...]` и `*[...]` — для всех.\n * 2. Расширение. Атрибуты, которых встроенная схема не знает (`h2[id]`, `a[rel|data-*]`), хранятся в\n * атрибуте узла `htmlAttrs`. Новые элементы (`div`, `section`, `abbr`, `<i class>` для иконок,\n * свои `my-widget`) — универсальные узлы html_block / html_textblock / html_inline_atom и марка\n * html_inline с атрибутом `tag`.\n *\n * Безопасность правилами не отключается: script, iframe, формы и т. п. не разрешаются, обработчики\n * on*, srcdoc и formaction не сохраняются, адреса и CSS проверяются при разборе и при выводе\n * (документ может прийти через JSON в обход разбора).\n */\nimport type { DOMOutputSpec, MarkSpec, NodeSpec, ParseRule, Schema } from 'prosemirror-model';\nimport {\n OWN_STYLE,\n type HtmlRulesInstance,\n type HtmlRulesModule,\n type HtmlRulesOptions,\n type SchemaSpecs,\n} from './html-rules-api';\nimport { safeAttr } from './safe-attr';\n\nexport type { HtmlRulesOptions };\n\ninterface AttrRule {\n name: string;\n required: boolean;\n def?: string;\n forced?: string;\n values?: string[];\n}\n\n/** Элементы, которые не разрешаются никаким правилом. */\nconst NEVER = new Set(\n (\n 'script,style,iframe,frame,frameset,object,embed,applet,base,link,meta,title,head,html,body,' +\n 'template,slot,noscript,form,input,button,select,option,optgroup,textarea,fieldset,legend,' +\n 'datalist,output,progress,meter,svg,math,canvas,audio,video,source,track,picture,map,area,' +\n 'portal,dialog,param,xmp,plaintext,listing,noembed,noframes,image'\n ).split(','),\n);\n/** Атрибуты, которые не сохраняются никаким правилом (в т.ч. «*»). */\nconst NEVER_ATTR =\n /^(on|xmlns)|^(srcdoc|formaction|action|contenteditable|autofocus|is|slot|nonce)$/;\nconst ATTR_NAME = /^[a-z_:][a-z0-9_.:-]*$/;\nconst TAG_NAME = /^[a-z][a-z0-9._-]*$/;\n\n/** Элементы встроенной схемы (их атрибуты можно ограничить и расширить). */\nexport const BASE_TAGS = new Set(\n 'p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,img,figure,figcaption,br,table,tr,td,th,strong,em,u,s,code,a,sub,sup'.split(\n ',',\n ),\n);\n/** Встроенные синонимы: становятся отдельным элементом, только если у них есть разрешённые атрибуты. */\nconst SPLIT = new Set(['span', 'i', 'b', 'del', 'strike', 'mark']);\nconst INLINE = new Set(\n 'abbr,acronym,bdi,bdo,big,cite,data,dfn,ins,kbd,q,samp,small,time,tt,var,label,ruby,rt,rp,wbr'.split(\n ',',\n ),\n);\nconst BLOCK = new Set(\n 'div,section,article,aside,header,footer,nav,main,address,details,summary,dl,dt,dd,center,hgroup,search'.split(\n ',',\n ),\n);\n/** Блочные элементы HTML: по ним универсальный блок выбирает «контейнер» или «текстовый блок». */\nconst BLOCK_LEVEL = new Set([\n ...BLOCK,\n ...'p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,table,figure'.split(','),\n]);\n/** Без этих атрибутов встроенный элемент не работает — их список в [...] не снимает. */\nconst ESSENTIAL: Record<string, string[]> = {\n a: ['href'],\n img: ['src'],\n td: ['colspan', 'rowspan'],\n th: ['colspan', 'rowspan'],\n};\n\nfunction splitTopLevel(text: string): string[] {\n const out: string[] = [];\n let depth = 0;\n let current = '';\n for (const ch of text) {\n if (ch === '[') depth++;\n else if (ch === ']') depth = Math.max(0, depth - 1);\n if (ch === ',' && !depth) {\n out.push(current);\n current = '';\n } else current += ch;\n }\n out.push(current);\n return out.map((s) => s.trim()).filter(Boolean);\n}\n\nfunction parseAttr(raw: string): AttrRule | null {\n let text = raw.trim();\n const required = text.startsWith('!');\n if (required) text = text.slice(1);\n const m = /^([^=:<]+)(?:([=:<])(.*))?$/s.exec(text);\n if (!m) return null;\n const name = m[1]!.trim().toLowerCase();\n if (!name) return null;\n const rule: AttrRule = { name, required };\n const value = m[3] ?? '';\n if (m[2] === '=') rule.def = value;\n else if (m[2] === ':') rule.forced = value;\n else if (m[2] === '<') rule.values = value.split('?');\n return rule;\n}\n\nfunction matches(pattern: string, name: string): boolean {\n if (pattern === '*') return true;\n return pattern.endsWith('*') ? name.startsWith(pattern.slice(0, -1)) : pattern === name;\n}\n\nconst warned = new Set<string>();\nfunction warn(tag: string, reason: string): void {\n if (warned.has(tag)) return;\n warned.add(tag);\n console.warn(`[nova] <${tag}> in content rules is ignored: ${reason}`);\n}\n\ntype Attrs = Record<string, unknown>;\n\nexport class HtmlRules implements HtmlRulesInstance {\n /** Список атрибутов элемента (null — список не задан, атрибуты встроенные). */\n private readonly elements = new Map<string, AttrRule[] | null>();\n private readonly globals: AttrRule[] = [];\n /** Универсальные элементы: тег во входном HTML → тег на выходе (синонимы `div/section`). */\n readonly blockTags = new Map<string, string>();\n readonly inlineTags = new Map<string, string>();\n\n constructor(options: HtmlRulesOptions) {\n const invalid = new Set(\n (options.invalidElements ?? '')\n .split(',')\n .map((s) => s.trim().toLowerCase())\n .filter(Boolean),\n );\n const inlineCustom = new Set<string>();\n const custom = new Set<string>();\n for (const raw of (options.customElements ?? '').split(',')) {\n const name = raw.trim().toLowerCase();\n const tag = name.replace(/^~/, '');\n if (!TAG_NAME.test(tag)) continue;\n if (NEVER.has(tag) || BASE_TAGS.has(tag)) {\n warn(tag, 'it cannot be a custom element');\n continue;\n }\n custom.add(tag);\n if (name.startsWith('~')) inlineCustom.add(tag);\n }\n\n const declare = (names: string[], attrs: AttrRule[] | null): void => {\n const [main, ...aliases] = names;\n if (!main) return;\n if (main === '@' || main === '*') {\n this.globals.push(...(attrs ?? []));\n return;\n }\n for (const tag of names) {\n if (!TAG_NAME.test(tag) || invalid.has(tag)) continue;\n if (NEVER.has(tag)) {\n warn(tag, 'not allowed for security reasons (iframes and video: use the media plugin)');\n continue;\n }\n // Правило элемента целиком заменяет прежнее (extended заменяет valid).\n this.elements.set(tag, attrs);\n const output = BASE_TAGS.has(tag) || SPLIT.has(tag) ? tag : main;\n if (BASE_TAGS.has(tag)) continue;\n if (SPLIT.has(tag)) {\n // `em/i` — обычный синоним; `i[class]` — отдельный элемент (иконки), если есть атрибуты.\n if (tag === main && attrs?.length) this.inlineTags.set(tag, tag);\n continue;\n }\n const isCustom = custom.has(tag) || custom.has(main) || tag.includes('-');\n if (INLINE.has(main) || inlineCustom.has(main)) this.inlineTags.set(tag, output);\n else if (BLOCK.has(main) || isCustom) this.blockTags.set(tag, output);\n else if (!aliases.includes(tag) || tag === main) warn(tag, 'unknown element');\n }\n };\n\n // validElements: только список атрибутов (что разрешено из элементов — решает ContentRules).\n for (const raw of splitTopLevel(options.validElements ?? '')) {\n const { names, attrs } = parseRule(raw);\n if (attrs) declare(names, attrs);\n else if (!names.every((n) => BASE_TAGS.has(n) || SPLIT.has(n))) declare(names, null);\n }\n for (const raw of splitTopLevel(options.extendedValidElements ?? '')) {\n const { names, attrs } = parseRule(raw);\n declare(names, attrs);\n }\n // Свои элементы без правила сохраняют все безопасные атрибуты.\n for (const tag of custom) {\n if (invalid.has(tag)) continue;\n if (!this.elements.has(tag)) this.elements.set(tag, [{ name: '*', required: false }]);\n if (inlineCustom.has(tag)) this.inlineTags.set(tag, tag);\n else if (!this.inlineTags.has(tag)) this.blockTags.set(tag, tag);\n }\n }\n\n apply(specs: SchemaSpecs, ref: { schema?: Schema }): SchemaSpecs {\n return applyHtmlRules(specs.nodes, specs.marks, this, ref);\n }\n\n /** Есть ли что применять (иначе редактор обходится без этого модуля). */\n get active(): boolean {\n return this.elements.size > 0 || this.globals.length > 0;\n }\n\n /** Правила касаются элемента: список атрибутов, значения или общие атрибуты. */\n touches(tag: string): boolean {\n return this.globals.length > 0 || this.elements.has(tag);\n }\n\n private rulesFor(tag: string): AttrRule[] {\n return [...(this.elements.get(tag) ?? []), ...this.globals];\n }\n\n /** Разрешает ли правило атрибут (без учёта встроенных атрибутов элемента). */\n allows(tag: string, name: string): boolean {\n if (NEVER_ATTR.test(name) || !ATTR_NAME.test(name)) return false;\n return this.rulesFor(tag).some((rule) => matches(rule.name, name));\n }\n\n /** Может ли у встроенного элемента быть атрибут сверх встроенных (кроме class и style). */\n extends(tag: string): boolean {\n return this.rulesFor(tag).some((rule) => rule.name !== 'class' && rule.name !== 'style');\n }\n\n /** Правила разрешают class у какого-либо встроенного элемента (тогда классы сохраняются). */\n get classOnBuiltIn(): boolean {\n if (this.globals.some((r) => matches(r.name, 'class'))) return true;\n for (const [tag, attrs] of this.elements) {\n if (BASE_TAGS.has(tag) && attrs?.some((r) => matches(r.name, 'class'))) return true;\n }\n return false;\n }\n\n /** Все обязательные атрибуты на месте. */\n hasRequired(tag: string, dom: HTMLElement): boolean {\n return this.rulesFor(tag).every((rule) => !rule.required || dom.hasAttribute(rule.name));\n }\n\n /**\n * Разрешённые правилом атрибуты элемента (значения проверены) или null. `skip` — атрибуты, которые\n * хранит не элемент: у встроенных class и style (validClasses, validStyles, марки оформления).\n * Собственный style новых элементов парсер заранее переносит в OWN_STYLE (см. parser.ts).\n */\n readAttrs(tag: string, dom: HTMLElement, skip: readonly string[]): Record<string, string> | null {\n let out: Record<string, string> | null = null;\n for (const attr of Array.from(dom.attributes)) {\n let name = attr.name.toLowerCase();\n if (name === OWN_STYLE) name = 'style';\n if (skip.includes(name) || !this.allows(tag, name)) continue;\n const value = safeAttr(name, attr.value);\n if (value !== null) (out ??= {})[name] = value;\n }\n return out;\n }\n\n /**\n * Атрибуты для вывода: встроенные + сохранённые (`extras`, могли прийти из JSON чем угодно),\n * затем список элемента и правила значений.\n */\n outputAttrs(tag: string, builtIn: Attrs, extras: unknown): Attrs {\n // Сначала встроенные, затем сохранённые — порядок не зависит от того, откуда пришло значение.\n const out: Attrs = { ...builtIn };\n if (extras && typeof extras === 'object' && !Array.isArray(extras)) {\n for (const [raw, value] of Object.entries(extras as Attrs)) {\n const name = raw.toLowerCase();\n if (out[name] != null || !this.allows(tag, name)) continue;\n if (!['string', 'number', 'boolean'].includes(typeof value)) continue;\n const safe = safeAttr(name, String(value));\n if (safe !== null) out[name] = safe;\n }\n }\n const list = this.elements.get(tag);\n if (list) {\n for (const name of Object.keys(out)) {\n if (this.allows(tag, name) || ESSENTIAL[tag]?.includes(name)) continue;\n if (name.startsWith('data-nova-')) continue;\n delete out[name];\n }\n }\n for (const rule of this.rulesFor(tag)) {\n if (rule.name.includes('*')) continue;\n if (rule.forced !== undefined) out[rule.name] = rule.forced;\n else if (rule.def !== undefined && out[rule.name] == null) out[rule.name] = rule.def;\n const value = out[rule.name];\n if (rule.values && value != null && !rule.values.includes(String(value))) {\n delete out[rule.name];\n }\n }\n // Ссылка в новой вкладке — без доступа к странице-источнику (как у встроенной ссылки).\n if (tag === 'a' && out.target != null && out.rel == null) out.rel = 'noopener noreferrer';\n return out;\n }\n\n /** Применить правила к выводу toDOM: атрибуты верхнего элемента спеки. */\n decorate(spec: DOMOutputSpec, extras: unknown): DOMOutputSpec {\n if (!Array.isArray(spec) || typeof spec[0] !== 'string') return spec;\n const raw = spec[0] as string;\n const tag = (raw.includes(' ') ? raw.split(' ')[1]! : raw).toLowerCase();\n if (!this.touches(tag)) return spec;\n const second = spec[1] as unknown;\n const hasAttrs =\n !!second &&\n typeof second === 'object' &&\n !Array.isArray(second) &&\n (second as { nodeType?: unknown }).nodeType === undefined;\n const attrs = this.outputAttrs(tag, hasAttrs ? (second as Attrs) : {}, extras);\n return [raw, attrs, ...(spec as unknown[]).slice(hasAttrs ? 2 : 1)] as unknown as DOMOutputSpec;\n }\n}\n\nfunction parseRule(raw: string): { names: string[]; attrs: AttrRule[] | null } {\n const m = /^([^[]*)(?:\\[(.*)\\])?$/s.exec(raw.trim());\n const names = (m?.[1] ?? '')\n .trim()\n .replace(/^[-#+!]+/, '')\n .split('/')\n .map((n) => n.trim().toLowerCase())\n .filter(Boolean);\n const list = m?.[2];\n const attrs =\n list === undefined\n ? null\n : list\n .split('|')\n .map(parseAttr)\n .filter((a): a is AttrRule => a !== null);\n return { names, attrs };\n}\n\n/** Правила из опций или null, если применять нечего. */\nexport function createHtmlRules(options: HtmlRulesOptions): HtmlRules | null {\n if (!options.validElements && !options.extendedValidElements && !options.customElements) {\n return null;\n }\n const rules = new HtmlRules(options);\n return rules.active ? rules : null;\n}\n\n// ---------- схема ----------\n\ntype Spec = NodeSpec | MarkSpec;\ninterface SchemaRef {\n schema?: Schema;\n}\n\nconst tagOf = (selector: string): string =>\n (/^[a-z][a-z0-9-]*/i.exec(selector)?.[0] ?? '').toLowerCase();\n\n/** Имена атрибутов, которые встроенный toDOM (исходный, без правил) выводит сам для этих attrs. */\nfunction producedNames(\n ref: SchemaRef,\n kind: 'node' | 'mark',\n name: string,\n attrs: Attrs,\n toDOM: (value: unknown, inline?: boolean) => DOMOutputSpec,\n): string[] {\n try {\n const schema = ref.schema!;\n const spec =\n kind === 'node'\n ? toDOM(schema.nodes[name]!.create(attrs))\n : toDOM(schema.marks[name]!.create(attrs), true);\n const second = Array.isArray(spec) ? (spec[1] as unknown) : null;\n return second && typeof second === 'object' && !Array.isArray(second)\n ? Object.keys(second)\n : [];\n } catch {\n return [];\n }\n}\n\n/** Встроенный узел/марка с правилами атрибутов. */\nfunction wrapBase<T extends Spec>(\n name: string,\n spec: T,\n kind: 'node' | 'mark',\n rules: HtmlRules,\n ref: SchemaRef,\n): T {\n const tags = (spec.parseDOM ?? [])\n .map((rule) => (rule.tag ? tagOf(rule.tag) : ''))\n .filter((tag) => BASE_TAGS.has(tag) && rules.touches(tag));\n if (!tags.length || !spec.toDOM) return spec;\n const withExtras = tags.some((tag) => rules.extends(tag));\n const toDOM = spec.toDOM as (value: unknown, inline?: boolean) => DOMOutputSpec;\n return {\n ...spec,\n ...(withExtras ? { attrs: { ...spec.attrs, htmlAttrs: { default: null } } } : {}),\n parseDOM: spec.parseDOM!.map((rule): ParseRule => {\n const tag = rule.tag ? tagOf(rule.tag) : '';\n if (!tags.includes(tag)) return rule;\n const getAttrs = rule.getAttrs as ((dom: HTMLElement) => Attrs | false | null) | undefined;\n return {\n ...rule,\n getAttrs: (dom: HTMLElement) => {\n const base = getAttrs ? getAttrs(dom) : (rule.attrs ?? null);\n if (base === false || !rules.hasRequired(tag, dom)) return false;\n if (!withExtras) return base;\n const extras = rules.readAttrs(tag, dom, ['class', 'style']);\n if (!extras) return base;\n // Что встроенный узел выводит сам, в extras не дублируем — иначе устаревшее значение\n // вернулось бы, когда пользователь его уберёт.\n for (const produced of producedNames(ref, kind, name, { ...base }, toDOM)) {\n delete extras[produced];\n }\n return Object.keys(extras).length ? { ...base, htmlAttrs: extras } : base;\n },\n } as ParseRule;\n }) as T['parseDOM'],\n toDOM: ((value: { attrs: Attrs }, inline?: boolean) =>\n rules.decorate(toDOM(value, inline), value.attrs.htmlAttrs)) as T['toDOM'],\n };\n}\n\nfunction hasBlockChild(dom: HTMLElement, rules: HtmlRules): boolean {\n return Array.from(dom.children).some((child) => {\n const tag = child.localName;\n return BLOCK_LEVEL.has(tag) || rules.blockTags.has(tag);\n });\n}\n\n/** Узлы и марки для новых элементов. */\nfunction genericSpecs(rules: HtmlRules): {\n nodes: Record<string, NodeSpec>;\n marks: Record<string, MarkSpec>;\n} {\n const nodes: Record<string, NodeSpec> = {};\n const marks: Record<string, MarkSpec> = {};\n /**\n * У синонимов встроенных элементов (span, i, mark…) style разбирают марки оформления — его не\n * дублируем; class у непустого span — марка классов. Синоним без своих атрибутов — встроенный.\n */\n const read = (output: string, dom: HTMLElement, mark: boolean) => {\n if (!rules.hasRequired(output, dom)) return false;\n const split = SPLIT.has(output);\n const skip = !split ? [] : mark && output === 'span' ? ['class', 'style'] : ['style'];\n const htmlAttrs = rules.readAttrs(output, dom, skip);\n if (split && !htmlAttrs) return false;\n return { tag: output, htmlAttrs };\n };\n // Теги, чей style остаётся на самом элементе, а не превращается в марки (см. parser.ts).\n const ownStyle = (tags: Map<string, string>) =>\n [...tags].filter(([, output]) => !SPLIT.has(output)).map(([input]) => input);\n const out = (allowed: Set<string>, fallback: string, attrs: Attrs) => {\n const tag = typeof attrs.tag === 'string' && allowed.has(attrs.tag) ? attrs.tag : fallback;\n return { tag, attrs: rules.outputAttrs(tag, {}, attrs.htmlAttrs) };\n };\n\n const blocks = [...rules.blockTags];\n if (blocks.length) {\n const allowed = new Set(rules.blockTags.values());\n const fallback = allowed.has('div') ? 'div' : [...allowed][0]!;\n const attrs = { tag: { default: fallback }, htmlAttrs: { default: null } };\n nodes.html_block = {\n ownStyleTags: ownStyle(rules.blockTags),\n group: 'block',\n content: 'block+',\n defining: true,\n attrs,\n parseDOM: blocks.map(([input, output]) => ({\n tag: input,\n getAttrs: (dom: HTMLElement) =>\n hasBlockChild(dom, rules) ? read(output, dom, false) : false,\n })),\n toDOM: (node) => {\n const { tag, attrs: a } = out(allowed, fallback, node.attrs);\n return [tag, a, 0];\n },\n };\n nodes.html_textblock = {\n group: 'block',\n content: 'inline*',\n attrs,\n parseDOM: blocks.map(([input, output]) => ({\n tag: input,\n getAttrs: (dom: HTMLElement) =>\n hasBlockChild(dom, rules) ? false : read(output, dom, false),\n })),\n toDOM: (node) => {\n const { tag, attrs: a } = out(allowed, fallback, node.attrs);\n return [tag, a, 0];\n },\n };\n }\n\n const inline = [...rules.inlineTags];\n if (inline.length) {\n const allowed = new Set(rules.inlineTags.values());\n const fallback = allowed.has('span') ? 'span' : [...allowed][0]!;\n const attrs = { tag: { default: fallback }, htmlAttrs: { default: null } };\n // Пустой элемент (иконка `<i class=\"fa fa-star\"></i>`) — неделимый узел: марке нечего охватить.\n nodes.html_inline_atom = {\n ownStyleTags: ownStyle(rules.inlineTags),\n group: 'inline',\n inline: true,\n atom: true,\n attrs,\n parseDOM: inline.map(([input, output]) => ({\n tag: input,\n // Раньше марки того же тега (у неё 60) и встроенных марок (курсив для <i>).\n priority: 65,\n getAttrs: (dom: HTMLElement) => (dom.firstChild ? false : read(output, dom, false)),\n })),\n toDOM: (node) => {\n const { tag, attrs: a } = out(allowed, fallback, node.attrs);\n return [tag, a];\n },\n };\n marks.html_inline = {\n attrs,\n // Разные элементы (abbr внутри kbd) — экземпляры одной марки, они не должны вытеснять друг друга.\n excludes: '',\n parseDOM: inline.map(([input, output]) => ({\n tag: input,\n // span: после марок классов и узлов плагинов (они разбирают свои span раньше).\n priority: output === 'span' ? 40 : 60,\n getAttrs: (dom: HTMLElement) => (dom.firstChild ? read(output, dom, true) : false),\n })),\n toDOM: (mark) => {\n const { tag, attrs: a } = out(allowed, fallback, mark.attrs);\n return [tag, a, 0];\n },\n };\n }\n return { nodes, marks };\n}\n\n/**\n * Применить правила к спекам схемы: встроенные узлы и марки получают правила атрибутов, новые\n * элементы — свои узлы и марки (в конце: встроенные правила разбора остаются в приоритете).\n * После создания схемы её нужно записать в `ref.schema`.\n */\nexport function applyHtmlRules(\n nodes: Record<string, NodeSpec>,\n marks: Record<string, MarkSpec>,\n rules: HtmlRules,\n ref: SchemaRef,\n): { nodes: Record<string, NodeSpec>; marks: Record<string, MarkSpec> } {\n const wrap = <T extends Spec>(specs: Record<string, T>, kind: 'node' | 'mark') =>\n Object.fromEntries(\n Object.entries(specs).map(([name, spec]) => [name, wrapBase(name, spec, kind, rules, ref)]),\n );\n const generic = genericSpecs(rules);\n return {\n nodes: { ...wrap(nodes, 'node'), ...generic.nodes },\n marks: { ...wrap(marks, 'mark'), ...generic.marks },\n };\n}\n\n/**\n * Модуль для регистрации в ядре:\n *\n * import { registerHtmlRules } from '@novaprose/core';\n * import { htmlRules } from '@novaprose/core/html-rules';\n * registerHtmlRules(htmlRules);\n */\nexport const htmlRules: HtmlRulesModule = { create: createHtmlRules };\n","import type { MarkSpec, NodeSpec, Schema } from 'prosemirror-model';\n\n/**\n * Точка подключения правил элементов и атрибутов. Реализация — отдельный импорт\n * `@novaprose/core/html-rules` (~3 КБ gzip): нужна немногим, поэтому не входит в первую загрузку.\n *\n * import { registerHtmlRules } from '@novaprose/core';\n * import { htmlRules } from '@novaprose/core/html-rules';\n * registerHtmlRules(htmlRules);\n */\n\nexport interface HtmlRulesOptions {\n /** Разрешены только эти элементы; атрибуты в [...] — полный список для элемента. */\n validElements?: string;\n /** Дополнительные элементы и атрибуты: 'div[class],h2[id],i[class],a[href|rel|data-*]'. */\n extendedValidElements?: string;\n /** Запрещённые элементы. */\n invalidElements?: string;\n /** Свои элементы: 'my-widget,~my-chip' (~ — строчный, как span; без ~ — блок, как div). */\n customElements?: string;\n}\n\nexport interface SchemaSpecs {\n nodes: Record<string, NodeSpec>;\n marks: Record<string, MarkSpec>;\n}\n\n/** Правила одного редактора: меняют спеки схемы. */\nexport interface HtmlRulesInstance {\n /** Правила разрешают class у встроенного элемента — тогда классы сохраняются. */\n readonly classOnBuiltIn: boolean;\n /** Спеки с правилами; после создания схемы её нужно записать в `ref.schema`. */\n apply(specs: SchemaSpecs, ref: { schema?: Schema }): SchemaSpecs;\n}\n\nexport interface HtmlRulesModule {\n create(options: HtmlRulesOptions): HtmlRulesInstance | null;\n}\n\n/** Служебный атрибут: сюда парсер переносит собственный style новых элементов (div, abbr…). */\nexport const OWN_STYLE = 'data-nova-own-style';\n\nlet registered: HtmlRulesModule | null = null;\n\n/** Подключить правила элементов и атрибутов (один раз на страницу). */\nexport function registerHtmlRules(module: HtmlRulesModule): void {\n registered = module;\n}\n\nlet warned = false;\n\n/** Правила для опций редактора или null (опции не требуют правил / модуль не подключён). */\nexport function htmlRulesFor(options: HtmlRulesOptions): HtmlRulesInstance | null {\n const needed =\n !!options.extendedValidElements ||\n !!options.customElements ||\n /\\[/.test(options.validElements ?? '');\n if (!needed) return null;\n if (!registered) {\n if (!warned) {\n warned = true;\n console.warn(\n \"[nova] attribute lists, extendedValidElements and customElements need: import { htmlRules } from '@novaprose/core/html-rules'; registerHtmlRules(htmlRules);\",\n );\n }\n return null;\n }\n return registered.create(options);\n}\n","/**\n * Проверка URL против XSS (javascript:, vbscript:, data:text/html и т.п.).\n * Относительные адреса и якоря разрешены.\n */\nconst SAFE_LINK_PROTOCOLS = new Set(['http:', 'https:', 'mailto:', 'tel:']);\nconst SAFE_IMAGE_PROTOCOLS = new Set(['http:', 'https:', 'blob:']);\nconst SAFE_DATA_IMAGE = /^data:image\\/(png|jpe?g|gif|webp|avif|bmp);base64,/i;\n\nfunction protocolOf(url: string): string | null {\n // Документ мог прийти из JSON: вместо строки — число или null.\n if (typeof url !== 'string') return null;\n // Убираем управляющие символы и пробелы, которыми маскируют \"java\\tscript:\".\n // eslint-disable-next-line no-control-regex\n const cleaned = url.replace(/[\\u0000- \\u007f-\\u009f]/g, '');\n const match = cleaned.match(/^([a-z][a-z0-9+.-]*):/i);\n return match ? `${match[1]!.toLowerCase()}:` : null;\n}\n\nexport function isSafeLinkUrl(url: string): boolean {\n if (typeof url !== 'string') return false;\n const protocol = protocolOf(url);\n return protocol === null || SAFE_LINK_PROTOCOLS.has(protocol);\n}\n\nexport function isSafeImageUrl(url: string): boolean {\n if (typeof url !== 'string') return false;\n if (SAFE_DATA_IMAGE.test(url.trim())) return true;\n const protocol = protocolOf(url);\n return protocol === null || SAFE_IMAGE_PROTOCOLS.has(protocol);\n}\n","import { isSafeImageUrl, isSafeLinkUrl } from './url';\n\n/**\n * Проверка значения атрибута на выходе: последний рубеж перед HTML, который уйдёт на сервер.\n * Общая для сериализатора и правил атрибутов (@novaprose/core/html-rules).\n */\nconst LINK_ATTRS = new Set(['href', 'xlink:href', 'action', 'formaction', 'cite']);\nconst RESOURCE_ATTRS = new Set(['src', 'poster', 'data', 'background']);\nconst UNSAFE_CSS = /url\\s*\\(|expression\\s*\\(|javascript:|@import|behavior\\s*:|-moz-binding/i;\n\n/** Значение атрибута, если оно безопасно, иначе null (атрибут не выводится). */\nexport function safeAttr(name: string, value: string): string | null {\n const lower = name.toLowerCase();\n if (lower.startsWith('on')) return null;\n if (LINK_ATTRS.has(lower)) return isSafeLinkUrl(value) ? value : null;\n if (RESOURCE_ATTRS.has(lower)) return isSafeImageUrl(value) ? value : null;\n if (lower === 'srcset') {\n const urls = value.split(',').map((part) => part.trim().split(/\\s+/)[0] ?? '');\n return urls.every((url) => isSafeImageUrl(url)) ? value : null;\n }\n if (lower === 'style') return UNSAFE_CSS.test(value) ? null : value;\n return value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACwCO,IAAM,YAAY;;;ACpCzB,IAAM,sBAAsB,oBAAI,IAAI,CAAC,SAAS,UAAU,WAAW,MAAM,CAAC;AAC1E,IAAM,uBAAuB,oBAAI,IAAI,CAAC,SAAS,UAAU,OAAO,CAAC;AACjE,IAAM,kBAAkB;AAExB,SAAS,WAAW,KAA4B;AAE9C,MAAI,OAAO,QAAQ,SAAU,QAAO;AAGpC,QAAM,UAAU,IAAI,QAAQ,4BAA4B,EAAE;AAC1D,QAAM,QAAQ,QAAQ,MAAM,wBAAwB;AACpD,S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AAa,KAAK,QAAQ,KAAK,IAAI,IAAI;AAAA,MAC9E,EAAE;AAAA,MACF,OAAO,CAAC,SAAS;AACf,cAAM,EAAE,KAAK,OAAO,EAAE,IAAI,IAAI,SAAS,UAAU,KAAK,KAAK;AAC3D,eAAO,CAAC,KAAK,GAAG,CAAC;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAE,OAAO,MAAM;AACxB;AAOO,SAAS,eACd,OACA,OACA,OACA,KACsE;AACtE,QAAM,OAAO,CAAiB,OAA0B,SACtD,OAAO;AAAA,IACL,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,SAAS,MAAM,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC;AAAA,EAC5F;AACF,QAAM,UAAU,aAAa,KAAK;AAClC,SAAO;AAAA,IACL,OAAO,EAAE,GAAG,KAAK,OAAO,MAAM,GAAG,GAAG,QAAQ,MAAM;AAAA,IAClD,OAAO,EAAE,GAAG,KAAK,OAAO,MAAM,GAAG,GAAG,QAAQ,MAAM;AAAA,EACpD;AACF;AASO,IAAM,YAA6B,EAAE,QAAQ,gBAAgB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/html-rules.ts","../src/html-rules-api.ts","../src/url.ts","../src/safe-attr.ts"],"sourcesContent":["/**\n * Rules for HTML elements and attributes: validElements (with attributes), extendedValidElements and\n * customElements. The syntax is that of the TinyMCE options with the same names (from their public\n * documentation): `a[href|title],div[class|data-*],@[id],my-widget`.\n *\n * Two directions:\n * 1. Restricting. A list in [...] is the complete list of an element's attributes: `a[href|title]`\n * drops target and class. Values: `name=v` — default, `name:v` — always, `name<a?b` — only from\n * the list, `!name` — required (an element without it is not recognized). `@[...]` and `*[...]`\n * apply to all elements.\n * 2. Extending. Attributes the built-in schema doesn't know (`h2[id]`, `a[rel|data-*]`) are kept in\n * the node attribute `htmlAttrs`. New elements (`div`, `section`, `abbr`, `<i class>` for icons,\n * your own `my-widget`) become generic nodes html_block / html_textblock / html_inline_atom and\n * the mark html_inline with a `tag` attribute.\n *\n * Rules never switch security off: script, iframe, forms and the like are not allowed, on* handlers,\n * srcdoc and formaction are never kept, and addresses and CSS are checked when parsing and when\n * writing (a document can arrive as JSON, bypassing the parser).\n */\nimport type { DOMOutputSpec, MarkSpec, NodeSpec, ParseRule, Schema } from 'prosemirror-model';\nimport {\n OWN_STYLE,\n type HtmlRulesInstance,\n type HtmlRulesModule,\n type HtmlRulesOptions,\n type SchemaSpecs,\n} from './html-rules-api';\nimport { safeAttr } from './safe-attr';\n\nexport type { HtmlRulesOptions };\n\ninterface AttrRule {\n name: string;\n required: boolean;\n def?: string;\n forced?: string;\n values?: string[];\n}\n\n/** Elements that no rule allows. */\nconst NEVER = new Set(\n (\n 'script,style,iframe,frame,frameset,object,embed,applet,base,link,meta,title,head,html,body,' +\n 'template,slot,noscript,form,input,button,select,option,optgroup,textarea,fieldset,legend,' +\n 'datalist,output,progress,meter,svg,math,canvas,audio,video,source,track,picture,map,area,' +\n 'portal,dialog,param,xmp,plaintext,listing,noembed,noframes,image'\n ).split(','),\n);\n/** Attributes that no rule keeps (including \"*\"). */\nconst NEVER_ATTR =\n /^(on|xmlns)|^(srcdoc|formaction|action|contenteditable|autofocus|is|slot|nonce)$/;\nconst ATTR_NAME = /^[a-z_:][a-z0-9_.:-]*$/;\nconst TAG_NAME = /^[a-z][a-z0-9._-]*$/;\n\n/** Elements of the built-in schema (their attributes can be restricted and extended). */\nexport const BASE_TAGS = new Set(\n 'p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,img,figure,figcaption,br,table,tr,td,th,strong,em,u,s,code,a,sub,sup'.split(\n ',',\n ),\n);\n/** Built-in synonyms: they become a separate element only when they have allowed attributes. */\nconst SPLIT = new Set(['span', 'i', 'b', 'del', 'strike', 'mark']);\nconst INLINE = new Set(\n 'abbr,acronym,bdi,bdo,big,cite,data,dfn,ins,kbd,q,samp,small,time,tt,var,label,ruby,rt,rp,wbr'.split(\n ',',\n ),\n);\nconst BLOCK = new Set(\n 'div,section,article,aside,header,footer,nav,main,address,details,summary,dl,dt,dd,center,hgroup,search'.split(\n ',',\n ),\n);\n/** HTML block elements: by them the generic block chooses \"container\" or \"text block\". */\nconst BLOCK_LEVEL = new Set([\n ...BLOCK,\n ...'p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,table,figure'.split(','),\n]);\n/** A built-in element doesn't work without these attributes, so the list in [...] doesn't remove them. */\nconst ESSENTIAL: Record<string, string[]> = {\n a: ['href'],\n ul: ['data-type'],\n li: ['data-type', 'data-checked'],\n img: ['src'],\n td: ['colspan', 'rowspan'],\n th: ['colspan', 'rowspan'],\n};\n\nfunction splitTopLevel(text: string): string[] {\n const out: string[] = [];\n let depth = 0;\n let current = '';\n for (const ch of text) {\n if (ch === '[') depth++;\n else if (ch === ']') depth = Math.max(0, depth - 1);\n if (ch === ',' && !depth) {\n out.push(current);\n current = '';\n } else current += ch;\n }\n out.push(current);\n return out.map((s) => s.trim()).filter(Boolean);\n}\n\nfunction parseAttr(raw: string): AttrRule | null {\n let text = raw.trim();\n const required = text.startsWith('!');\n if (required) text = text.slice(1);\n const m = /^([^=:<]+)(?:([=:<])(.*))?$/s.exec(text);\n if (!m) return null;\n const name = m[1]!.trim().toLowerCase();\n if (!name) return null;\n const rule: AttrRule = { name, required };\n const value = m[3] ?? '';\n if (m[2] === '=') rule.def = value;\n else if (m[2] === ':') rule.forced = value;\n else if (m[2] === '<') rule.values = value.split('?');\n return rule;\n}\n\nfunction matches(pattern: string, name: string): boolean {\n if (pattern === '*') return true;\n return pattern.endsWith('*') ? name.startsWith(pattern.slice(0, -1)) : pattern === name;\n}\n\nconst warned = new Set<string>();\nfunction warn(tag: string, reason: string): void {\n if (warned.has(tag)) return;\n warned.add(tag);\n console.warn(`[nova] <${tag}> in content rules is ignored: ${reason}`);\n}\n\ntype Attrs = Record<string, unknown>;\n\nexport class HtmlRules implements HtmlRulesInstance {\n /** The element's attribute list (null — no list given, built-in attributes). */\n private readonly elements = new Map<string, AttrRule[] | null>();\n private readonly globals: AttrRule[] = [];\n /** Generic elements: tag in the input HTML → tag in the output (synonyms like `div/section`). */\n readonly blockTags = new Map<string, string>();\n readonly inlineTags = new Map<string, string>();\n\n constructor(options: HtmlRulesOptions) {\n const invalid = new Set(\n (options.invalidElements ?? '')\n .split(',')\n .map((s) => s.trim().toLowerCase())\n .filter(Boolean),\n );\n const inlineCustom = new Set<string>();\n const custom = new Set<string>();\n for (const raw of (options.customElements ?? '').split(',')) {\n const name = raw.trim().toLowerCase();\n const tag = name.replace(/^~/, '');\n if (!TAG_NAME.test(tag)) continue;\n if (NEVER.has(tag) || BASE_TAGS.has(tag)) {\n warn(tag, 'it cannot be a custom element');\n continue;\n }\n custom.add(tag);\n if (name.startsWith('~')) inlineCustom.add(tag);\n }\n\n const declare = (names: string[], attrs: AttrRule[] | null): void => {\n const [main, ...aliases] = names;\n if (!main) return;\n if (main === '@' || main === '*') {\n this.globals.push(...(attrs ?? []));\n return;\n }\n for (const tag of names) {\n if (!TAG_NAME.test(tag) || invalid.has(tag)) continue;\n if (NEVER.has(tag)) {\n warn(tag, 'not allowed for security reasons (iframes and video: use the media plugin)');\n continue;\n }\n // An element's rule replaces the previous one entirely (extended replaces valid).\n this.elements.set(tag, attrs);\n const output = BASE_TAGS.has(tag) || SPLIT.has(tag) ? tag : main;\n if (BASE_TAGS.has(tag)) continue;\n if (SPLIT.has(tag)) {\n // `em/i` is a regular synonym; `i[class]` is a separate element (icons) when it has attributes.\n if (tag === main && attrs?.length) this.inlineTags.set(tag, tag);\n continue;\n }\n const isCustom = custom.has(tag) || custom.has(main) || tag.includes('-');\n if (INLINE.has(main) || inlineCustom.has(main)) this.inlineTags.set(tag, output);\n else if (BLOCK.has(main) || isCustom) this.blockTags.set(tag, output);\n else if (!aliases.includes(tag) || tag === main) warn(tag, 'unknown element');\n }\n };\n\n // validElements: only the attribute list (which elements are allowed is decided by ContentRules).\n for (const raw of splitTopLevel(options.validElements ?? '')) {\n const { names, attrs } = parseRule(raw);\n if (attrs) declare(names, attrs);\n else if (!names.every((n) => BASE_TAGS.has(n) || SPLIT.has(n))) declare(names, null);\n }\n for (const raw of splitTopLevel(options.extendedValidElements ?? '')) {\n const { names, attrs } = parseRule(raw);\n declare(names, attrs);\n }\n // Custom elements without a rule keep every safe attribute.\n for (const tag of custom) {\n if (invalid.has(tag)) continue;\n if (!this.elements.has(tag)) this.elements.set(tag, [{ name: '*', required: false }]);\n if (inlineCustom.has(tag)) this.inlineTags.set(tag, tag);\n else if (!this.inlineTags.has(tag)) this.blockTags.set(tag, tag);\n }\n }\n\n apply(specs: SchemaSpecs, ref: { schema?: Schema }): SchemaSpecs {\n return applyHtmlRules(specs.nodes, specs.marks, this, ref);\n }\n\n /** Whether there is anything to apply (otherwise the editor does without this module). */\n get active(): boolean {\n return this.elements.size > 0 || this.globals.length > 0;\n }\n\n /** Whether the rules concern the element: an attribute list, values or common attributes. */\n touches(tag: string): boolean {\n return this.globals.length > 0 || this.elements.has(tag);\n }\n\n private rulesFor(tag: string): AttrRule[] {\n return [...(this.elements.get(tag) ?? []), ...this.globals];\n }\n\n /** Whether the rule allows an attribute (not counting the element's built-in attributes). */\n allows(tag: string, name: string): boolean {\n if (NEVER_ATTR.test(name) || !ATTR_NAME.test(name)) return false;\n return this.rulesFor(tag).some((rule) => matches(rule.name, name));\n }\n\n /** Whether a built-in element may have attributes beyond its built-in ones (except class and style). */\n extends(tag: string): boolean {\n return this.rulesFor(tag).some((rule) => rule.name !== 'class' && rule.name !== 'style');\n }\n\n /** Whether the rules allow class on any built-in element (then classes are kept). */\n get classOnBuiltIn(): boolean {\n if (this.globals.some((r) => matches(r.name, 'class'))) return true;\n for (const [tag, attrs] of this.elements) {\n if (BASE_TAGS.has(tag) && attrs?.some((r) => matches(r.name, 'class'))) return true;\n }\n return false;\n }\n\n /** All required attributes are present. */\n hasRequired(tag: string, dom: HTMLElement): boolean {\n return this.rulesFor(tag).every((rule) => !rule.required || dom.hasAttribute(rule.name));\n }\n\n /**\n * The element's attributes allowed by the rule (values checked), or null. `skip` — attributes the\n * element itself doesn't keep: class and style of built-in elements (validClasses, validStyles,\n * formatting marks). The parser moves the own style of new elements to OWN_STYLE (see parser.ts).\n */\n readAttrs(tag: string, dom: HTMLElement, skip: readonly string[]): Record<string, string> | null {\n let out: Record<string, string> | null = null;\n for (const attr of Array.from(dom.attributes)) {\n let name = attr.name.toLowerCase();\n if (name === OWN_STYLE) name = 'style';\n // lang is the language mark's (a passage in another language): kept once, as the mark.\n if (name === 'lang' || skip.includes(name) || !this.allows(tag, name)) continue;\n const value = safeAttr(name, attr.value);\n if (value !== null) (out ??= {})[name] = value;\n }\n return out;\n }\n\n /**\n * Attributes for output: built-in ones plus kept ones (`extras`, which may have come from JSON as\n * anything), then the element's list and the value rules.\n */\n outputAttrs(tag: string, builtIn: Attrs, extras: unknown): Attrs {\n // Built-in first, then the kept ones: the order doesn't depend on where the value came from.\n const out: Attrs = { ...builtIn };\n if (extras && typeof extras === 'object' && !Array.isArray(extras)) {\n for (const [raw, value] of Object.entries(extras as Attrs)) {\n const name = raw.toLowerCase();\n if (out[name] != null || name === 'lang' || !this.allows(tag, name)) continue;\n if (!['string', 'number', 'boolean'].includes(typeof value)) continue;\n const safe = safeAttr(name, String(value));\n if (safe !== null) out[name] = safe;\n }\n }\n const list = this.elements.get(tag);\n if (list) {\n for (const name of Object.keys(out)) {\n if (this.allows(tag, name) || ESSENTIAL[tag]?.includes(name)) continue;\n if (name.startsWith('data-nova-')) continue;\n delete out[name];\n }\n }\n for (const rule of this.rulesFor(tag)) {\n if (rule.name.includes('*')) continue;\n if (rule.forced !== undefined) out[rule.name] = rule.forced;\n else if (rule.def !== undefined && out[rule.name] == null) out[rule.name] = rule.def;\n const value = out[rule.name];\n if (rule.values && value != null && !rule.values.includes(String(value))) {\n delete out[rule.name];\n }\n }\n // A link in a new tab gets no access to the source page (as with the built-in link).\n if (tag === 'a' && out.target != null && out.rel == null) out.rel = 'noopener noreferrer';\n return out;\n }\n\n /** Apply the rules to toDOM output: attributes of the spec's top element. */\n decorate(spec: DOMOutputSpec, extras: unknown): DOMOutputSpec {\n if (!Array.isArray(spec) || typeof spec[0] !== 'string') return spec;\n const raw = spec[0] as string;\n const tag = (raw.includes(' ') ? raw.split(' ')[1]! : raw).toLowerCase();\n if (!this.touches(tag)) return spec;\n const second = spec[1] as unknown;\n const hasAttrs =\n !!second &&\n typeof second === 'object' &&\n !Array.isArray(second) &&\n (second as { nodeType?: unknown }).nodeType === undefined;\n const attrs = this.outputAttrs(tag, hasAttrs ? (second as Attrs) : {}, extras);\n return [raw, attrs, ...(spec as unknown[]).slice(hasAttrs ? 2 : 1)] as unknown as DOMOutputSpec;\n }\n}\n\nfunction parseRule(raw: string): { names: string[]; attrs: AttrRule[] | null } {\n const m = /^([^[]*)(?:\\[(.*)\\])?$/s.exec(raw.trim());\n const names = (m?.[1] ?? '')\n .trim()\n .replace(/^[-#+!]+/, '')\n .split('/')\n .map((n) => n.trim().toLowerCase())\n .filter(Boolean);\n const list = m?.[2];\n const attrs =\n list === undefined\n ? null\n : list\n .split('|')\n .map(parseAttr)\n .filter((a): a is AttrRule => a !== null);\n return { names, attrs };\n}\n\n/** Rules from the options, or null when there is nothing to apply. */\nexport function createHtmlRules(options: HtmlRulesOptions): HtmlRules | null {\n if (!options.validElements && !options.extendedValidElements && !options.customElements) {\n return null;\n }\n const rules = new HtmlRules(options);\n return rules.active ? rules : null;\n}\n\n// ---------- schema ----------\n\ntype Spec = NodeSpec | MarkSpec;\ninterface SchemaRef {\n schema?: Schema;\n}\n\nconst tagOf = (selector: string): string =>\n (/^[a-z][a-z0-9-]*/i.exec(selector)?.[0] ?? '').toLowerCase();\n\n/** Attribute names that the built-in toDOM (the original one, without rules) outputs itself for these attrs. */\nfunction producedNames(\n ref: SchemaRef,\n kind: 'node' | 'mark',\n name: string,\n attrs: Attrs,\n toDOM: (value: unknown, inline?: boolean) => DOMOutputSpec,\n): string[] {\n try {\n const schema = ref.schema!;\n const spec =\n kind === 'node'\n ? toDOM(schema.nodes[name]!.create(attrs))\n : toDOM(schema.marks[name]!.create(attrs), true);\n const second = Array.isArray(spec) ? (spec[1] as unknown) : null;\n return second && typeof second === 'object' && !Array.isArray(second)\n ? Object.keys(second)\n : [];\n } catch {\n return [];\n }\n}\n\n/** A built-in node/mark with attribute rules. */\nfunction wrapBase<T extends Spec>(\n name: string,\n spec: T,\n kind: 'node' | 'mark',\n rules: HtmlRules,\n ref: SchemaRef,\n): T {\n const tags = (spec.parseDOM ?? [])\n .map((rule) => (rule.tag ? tagOf(rule.tag) : ''))\n .filter((tag) => BASE_TAGS.has(tag) && rules.touches(tag));\n if (!tags.length || !spec.toDOM) return spec;\n const withExtras = tags.some((tag) => rules.extends(tag));\n const toDOM = spec.toDOM as (value: unknown, inline?: boolean) => DOMOutputSpec;\n return {\n ...spec,\n ...(withExtras ? { attrs: { ...spec.attrs, htmlAttrs: { default: null } } } : {}),\n parseDOM: spec.parseDOM!.map((rule): ParseRule => {\n const tag = rule.tag ? tagOf(rule.tag) : '';\n if (!tags.includes(tag)) return rule;\n const getAttrs = rule.getAttrs as ((dom: HTMLElement) => Attrs | false | null) | undefined;\n return {\n ...rule,\n getAttrs: (dom: HTMLElement) => {\n const base = getAttrs ? getAttrs(dom) : (rule.attrs ?? null);\n if (base === false || !rules.hasRequired(tag, dom)) return false;\n if (!withExtras) return base;\n const extras = rules.readAttrs(tag, dom, ['class', 'style']);\n if (!extras) return base;\n // What the built-in node outputs itself isn't duplicated in extras, otherwise an outdated value\n // would come back after the user removes it.\n for (const produced of producedNames(ref, kind, name, { ...base }, toDOM)) {\n delete extras[produced];\n }\n return Object.keys(extras).length ? { ...base, htmlAttrs: extras } : base;\n },\n } as ParseRule;\n }) as T['parseDOM'],\n toDOM: ((value: { attrs: Attrs }, inline?: boolean) =>\n rules.decorate(toDOM(value, inline), value.attrs.htmlAttrs)) as T['toDOM'],\n };\n}\n\nfunction hasBlockChild(dom: HTMLElement, rules: HtmlRules): boolean {\n return Array.from(dom.children).some((child) => {\n const tag = child.localName;\n return BLOCK_LEVEL.has(tag) || rules.blockTags.has(tag);\n });\n}\n\n/** Nodes and marks for new elements. */\nfunction genericSpecs(rules: HtmlRules): {\n nodes: Record<string, NodeSpec>;\n marks: Record<string, MarkSpec>;\n} {\n const nodes: Record<string, NodeSpec> = {};\n const marks: Record<string, MarkSpec> = {};\n /**\n * For synonyms of built-in elements (span, i, mark…) the formatting marks parse style, so it isn't\n * duplicated; class on a non-empty span is the class mark. A synonym without its own attributes is the built-in one.\n */\n const read = (output: string, dom: HTMLElement, mark: boolean) => {\n if (!rules.hasRequired(output, dom)) return false;\n const split = SPLIT.has(output);\n const skip = !split ? [] : mark && output === 'span' ? ['class', 'style'] : ['style'];\n const htmlAttrs = rules.readAttrs(output, dom, skip);\n if (split && !htmlAttrs) return false;\n return { tag: output, htmlAttrs };\n };\n // Tags whose style stays on the element itself instead of turning into marks (see parser.ts).\n const ownStyle = (tags: Map<string, string>) =>\n [...tags].filter(([, output]) => !SPLIT.has(output)).map(([input]) => input);\n const out = (allowed: Set<string>, fallback: string, attrs: Attrs) => {\n const tag = typeof attrs.tag === 'string' && allowed.has(attrs.tag) ? attrs.tag : fallback;\n return { tag, attrs: rules.outputAttrs(tag, {}, attrs.htmlAttrs) };\n };\n\n const blocks = [...rules.blockTags];\n if (blocks.length) {\n const allowed = new Set(rules.blockTags.values());\n const fallback = allowed.has('div') ? 'div' : [...allowed][0]!;\n const attrs = { tag: { default: fallback }, htmlAttrs: { default: null } };\n nodes.html_block = {\n ownStyleTags: ownStyle(rules.blockTags),\n group: 'block',\n content: 'block+',\n defining: true,\n attrs,\n parseDOM: blocks.map(([input, output]) => ({\n tag: input,\n getAttrs: (dom: HTMLElement) =>\n hasBlockChild(dom, rules) ? read(output, dom, false) : false,\n })),\n toDOM: (node) => {\n const { tag, attrs: a } = out(allowed, fallback, node.attrs);\n return [tag, a, 0];\n },\n };\n nodes.html_textblock = {\n group: 'block',\n content: 'inline*',\n attrs,\n parseDOM: blocks.map(([input, output]) => ({\n tag: input,\n getAttrs: (dom: HTMLElement) =>\n hasBlockChild(dom, rules) ? false : read(output, dom, false),\n })),\n toDOM: (node) => {\n const { tag, attrs: a } = out(allowed, fallback, node.attrs);\n return [tag, a, 0];\n },\n };\n }\n\n const inline = [...rules.inlineTags];\n if (inline.length) {\n const allowed = new Set(rules.inlineTags.values());\n const fallback = allowed.has('span') ? 'span' : [...allowed][0]!;\n const attrs = { tag: { default: fallback }, htmlAttrs: { default: null } };\n // An empty element (an icon `<i class=\"fa fa-star\"></i>`) is an atomic node: a mark would have nothing to wrap.\n nodes.html_inline_atom = {\n ownStyleTags: ownStyle(rules.inlineTags),\n group: 'inline',\n inline: true,\n atom: true,\n attrs,\n parseDOM: inline.map(([input, output]) => ({\n tag: input,\n // Before marks of the same tag (it has 60) and built-in marks (italic for <i>).\n priority: 65,\n getAttrs: (dom: HTMLElement) => (dom.firstChild ? false : read(output, dom, false)),\n })),\n toDOM: (node) => {\n const { tag, attrs: a } = out(allowed, fallback, node.attrs);\n return [tag, a];\n },\n };\n marks.html_inline = {\n attrs,\n // Different elements (abbr inside kbd) are instances of one mark and must not push each other out.\n excludes: '',\n parseDOM: inline.map(([input, output]) => ({\n tag: input,\n // span: after class marks and plugin nodes (they parse their own spans earlier).\n priority: output === 'span' ? 40 : 60,\n getAttrs: (dom: HTMLElement) => (dom.firstChild ? read(output, dom, true) : false),\n })),\n toDOM: (mark) => {\n const { tag, attrs: a } = out(allowed, fallback, mark.attrs);\n return [tag, a, 0];\n },\n };\n }\n return { nodes, marks };\n}\n\n/**\n * Apply the rules to the schema specs: built-in nodes and marks get attribute rules, new elements\n * get their own nodes and marks (at the end, so built-in parse rules keep priority). After the schema\n * is created, store it in `ref.schema`.\n */\nexport function applyHtmlRules(\n nodes: Record<string, NodeSpec>,\n marks: Record<string, MarkSpec>,\n rules: HtmlRules,\n ref: SchemaRef,\n): { nodes: Record<string, NodeSpec>; marks: Record<string, MarkSpec> } {\n const wrap = <T extends Spec>(specs: Record<string, T>, kind: 'node' | 'mark') =>\n Object.fromEntries(\n Object.entries(specs).map(([name, spec]) => [name, wrapBase(name, spec, kind, rules, ref)]),\n );\n const generic = genericSpecs(rules);\n return {\n nodes: { ...wrap(nodes, 'node'), ...generic.nodes },\n marks: { ...wrap(marks, 'mark'), ...generic.marks },\n };\n}\n\n/**\n * The module to register in the core:\n *\n * import { registerHtmlRules } from '@novaprose/core';\n * import { htmlRules } from '@novaprose/core/html-rules';\n * registerHtmlRules(htmlRules);\n */\nexport const htmlRules: HtmlRulesModule = { create: createHtmlRules };\n","import type { MarkSpec, NodeSpec, Schema } from 'prosemirror-model';\n\n/**\n * The hook for element and attribute rules. The implementation is a separate import,\n * `@novaprose/core/html-rules` (~3 KB gzip): few need it, so it isn't part of the first load.\n *\n * import { registerHtmlRules } from '@novaprose/core';\n * import { htmlRules } from '@novaprose/core/html-rules';\n * registerHtmlRules(htmlRules);\n */\n\nexport interface HtmlRulesOptions {\n /** Only these elements are allowed; attributes in [...] are the complete list for the element. */\n validElements?: string;\n /** More elements and attributes: 'div[class],h2[id],i[class],a[href|rel|data-*]'. */\n extendedValidElements?: string;\n /** Disallowed elements. */\n invalidElements?: string;\n /** Your own elements: 'my-widget,~my-chip' (~ — inline, like span; without ~ — a block, like div). */\n customElements?: string;\n}\n\n/** The node and mark specs the document schema is built from; HTML rules change them before that. */\nexport interface SchemaSpecs {\n nodes: Record<string, NodeSpec>;\n marks: Record<string, MarkSpec>;\n}\n\n/** The rules of one editor: they change the schema specs. */\nexport interface HtmlRulesInstance {\n /** Whether the rules allow class on a built-in element (then classes are kept). */\n readonly classOnBuiltIn: boolean;\n /** Specs with the rules applied; after the schema is created, store it in `ref.schema`. */\n apply(specs: SchemaSpecs, ref: { schema?: Schema }): SchemaSpecs;\n}\n\nexport interface HtmlRulesModule {\n create(options: HtmlRulesOptions): HtmlRulesInstance | null;\n}\n\n/** A service attribute: the parser moves the own style of new elements (div, abbr…) here. */\nexport const OWN_STYLE = 'data-nova-own-style';\n\nlet registered: HtmlRulesModule | null = null;\n\n/** Install the element and attribute rules (once per page). */\nexport function registerHtmlRules(module: HtmlRulesModule): void {\n registered = module;\n}\n\nlet warned = false;\n\n/** Rules for the editor's options, or null (the options need no rules / the module isn't attached). */\nexport function htmlRulesFor(options: HtmlRulesOptions): HtmlRulesInstance | null {\n const needed =\n !!options.extendedValidElements ||\n !!options.customElements ||\n /\\[/.test(options.validElements ?? '');\n if (!needed) return null;\n if (!registered) {\n if (!warned) {\n warned = true;\n console.warn(\n \"[nova] attribute lists, extendedValidElements and customElements need: import { htmlRules } from '@novaprose/core/html-rules'; registerHtmlRules(htmlRules);\",\n );\n }\n return null;\n }\n return registered.create(options);\n}\n","/**\n * URL checks against XSS (javascript:, vbscript:, data:text/html and the like).\n * Relative addresses and anchors are allowed.\n */\nconst SAFE_LINK_PROTOCOLS = new Set(['http:', 'https:', 'mailto:', 'tel:']);\nconst SAFE_IMAGE_PROTOCOLS = new Set(['http:', 'https:', 'blob:']);\nconst SAFE_DATA_IMAGE = /^data:image\\/(png|jpe?g|gif|webp|avif|bmp);base64,/i;\n\nfunction protocolOf(url: string): string | null {\n // The document may come from JSON: a number or null instead of a string.\n if (typeof url !== 'string') return null;\n // Strip the control characters and spaces used to disguise \"java\\tscript:\".\n // eslint-disable-next-line no-control-regex\n const cleaned = url.replace(/[\\u0000- \\u007f-\\u009f]/g, '');\n const match = cleaned.match(/^([a-z][a-z0-9+.-]*):/i);\n return match ? `${match[1]!.toLowerCase()}:` : null;\n}\n\nexport function isSafeLinkUrl(url: string): boolean {\n if (typeof url !== 'string') return false;\n const protocol = protocolOf(url);\n return protocol === null || SAFE_LINK_PROTOCOLS.has(protocol);\n}\n\nexport function isSafeImageUrl(url: string): boolean {\n if (typeof url !== 'string') return false;\n if (SAFE_DATA_IMAGE.test(url.trim())) return true;\n const protocol = protocolOf(url);\n return protocol === null || SAFE_IMAGE_PROTOCOLS.has(protocol);\n}\n","import { isSafeImageUrl, isSafeLinkUrl } from './url';\n\n/**\n * Checks an attribute value on output: the last line of defense before HTML goes to the server.\n * Shared by the serializer and the attribute rules (@novaprose/core/html-rules).\n */\nconst LINK_ATTRS = new Set(['href', 'xlink:href', 'action', 'formaction', 'cite']);\nconst RESOURCE_ATTRS = new Set(['src', 'poster', 'data', 'background']);\nconst UNSAFE_CSS = /url\\s*\\(|expression\\s*\\(|javascript:|@import|behavior\\s*:|-moz-binding/i;\n\n/** The attribute value if it is safe, otherwise null (the attribute isn't output). */\nexport function safeAttr(name: string, value: string): string | null {\n const lower = name.toLowerCase();\n if (lower.startsWith('on')) return null;\n if (LINK_ATTRS.has(lower)) return isSafeLinkUrl(value) ? value : null;\n if (RESOURCE_ATTRS.has(lower)) return isSafeImageUrl(value) ? value : null;\n if (lower === 'srcset') {\n const urls = value.split(',').map((part) => part.trim().split(/\\s+/)[0] ?? '');\n return urls.every((url) => isSafeImageUrl(url)) ? value : null;\n }\n if (lower === 'style') return UNSAFE_CSS.test(value) ? null : value;\n return value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyCO,IAAM,YAAY;;;ACrCzB,IAAM,sBAAsB,oBAAI,IAAI,CAAC,SAAS,UAAU,WAAW,MAAM,CAAC;AAC1E,IAAM,uBAAuB,oBAAI,IAAI,CAAC,SAAS,UAAU,OAAO,CAAC;AACjE,IAAM,kBAAkB;AAExB,SAAS,WAAW,KAA4B;AAE9C,MAAI,OAAO,QAAQ,SAAU,QAAO;AAGpC,QAAM,UAAU,IAAI,QAAQ,4BAA4B,EAAE;AAC1D,QAAM,QAAQ,QAAQ,MAAM,wBAAwB;AACpD,SAAO,QAAQ,GAAG,MAAM,CAAC,EAAG,YAAY,CAAC,MAAM;AACjD;AAEO,SAAS,cAAc,KAAsB;A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I,aAAa,KAAK,QAAQ,KAAK,IAAI,IAAI;AAAA,MAC9E,EAAE;AAAA,MACF,OAAO,CAAC,SAAS;AACf,cAAM,EAAE,KAAK,OAAO,EAAE,IAAI,IAAI,SAAS,UAAU,KAAK,KAAK;AAC3D,eAAO,CAAC,KAAK,GAAG,CAAC;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAE,OAAO,MAAM;AACxB;AAOO,SAAS,eACd,OACA,OACA,OACA,KACsE;AACtE,QAAM,OAAO,CAAiB,OAA0B,SACtD,OAAO;AAAA,IACL,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,SAAS,MAAM,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC;AAAA,EAC5F;AACF,QAAM,UAAU,aAAa,KAAK;AAClC,SAAO;AAAA,IACL,OAAO,EAAE,GAAG,KAAK,OAAO,MAAM,GAAG,GAAG,QAAQ,MAAM;AAAA,IAClD,OAAO,EAAE,GAAG,KAAK,OAAO,MAAM,GAAG,GAAG,QAAQ,MAAM;AAAA,EACpD;AACF;AASO,IAAM,YAA6B,EAAE,QAAQ,gBAAgB;","names":[]}
|
package/dist/html-rules.d.cts
CHANGED
|
@@ -1,82 +1,84 @@
|
|
|
1
1
|
import { Schema, DOMOutputSpec, NodeSpec, MarkSpec } from 'prosemirror-model';
|
|
2
|
-
import {
|
|
2
|
+
import { a as HtmlRulesOptions } from './html-rules-api-BLDDW9MO.cjs';
|
|
3
|
+
import { HtmlRulesInstance, SchemaSpecs, HtmlRulesModule } from './index.cjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
* customElements.
|
|
7
|
-
* `a[href|title],div[class|data-*],@[id],my-widget`.
|
|
6
|
+
* Rules for HTML elements and attributes: validElements (with attributes), extendedValidElements and
|
|
7
|
+
* customElements. The syntax is that of the TinyMCE options with the same names (from their public
|
|
8
|
+
* documentation): `a[href|title],div[class|data-*],@[id],my-widget`.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
* 1.
|
|
11
|
-
* target
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* Two directions:
|
|
11
|
+
* 1. Restricting. A list in [...] is the complete list of an element's attributes: `a[href|title]`
|
|
12
|
+
* drops target and class. Values: `name=v` — default, `name:v` — always, `name<a?b` — only from
|
|
13
|
+
* the list, `!name` — required (an element without it is not recognized). `@[...]` and `*[...]`
|
|
14
|
+
* apply to all elements.
|
|
15
|
+
* 2. Extending. Attributes the built-in schema doesn't know (`h2[id]`, `a[rel|data-*]`) are kept in
|
|
16
|
+
* the node attribute `htmlAttrs`. New elements (`div`, `section`, `abbr`, `<i class>` for icons,
|
|
17
|
+
* your own `my-widget`) become generic nodes html_block / html_textblock / html_inline_atom and
|
|
18
|
+
* the mark html_inline with a `tag` attribute.
|
|
17
19
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* (
|
|
20
|
+
* Rules never switch security off: script, iframe, forms and the like are not allowed, on* handlers,
|
|
21
|
+
* srcdoc and formaction are never kept, and addresses and CSS are checked when parsing and when
|
|
22
|
+
* writing (a document can arrive as JSON, bypassing the parser).
|
|
21
23
|
*/
|
|
22
24
|
|
|
23
|
-
/**
|
|
25
|
+
/** Elements of the built-in schema (their attributes can be restricted and extended). */
|
|
24
26
|
declare const BASE_TAGS: Set<string>;
|
|
25
27
|
type Attrs = Record<string, unknown>;
|
|
26
28
|
declare class HtmlRules implements HtmlRulesInstance {
|
|
27
|
-
/**
|
|
29
|
+
/** The element's attribute list (null — no list given, built-in attributes). */
|
|
28
30
|
private readonly elements;
|
|
29
31
|
private readonly globals;
|
|
30
|
-
/**
|
|
32
|
+
/** Generic elements: tag in the input HTML → tag in the output (synonyms like `div/section`). */
|
|
31
33
|
readonly blockTags: Map<string, string>;
|
|
32
34
|
readonly inlineTags: Map<string, string>;
|
|
33
35
|
constructor(options: HtmlRulesOptions);
|
|
34
36
|
apply(specs: SchemaSpecs, ref: {
|
|
35
37
|
schema?: Schema;
|
|
36
38
|
}): SchemaSpecs;
|
|
37
|
-
/**
|
|
39
|
+
/** Whether there is anything to apply (otherwise the editor does without this module). */
|
|
38
40
|
get active(): boolean;
|
|
39
|
-
/**
|
|
41
|
+
/** Whether the rules concern the element: an attribute list, values or common attributes. */
|
|
40
42
|
touches(tag: string): boolean;
|
|
41
43
|
private rulesFor;
|
|
42
|
-
/**
|
|
44
|
+
/** Whether the rule allows an attribute (not counting the element's built-in attributes). */
|
|
43
45
|
allows(tag: string, name: string): boolean;
|
|
44
|
-
/**
|
|
46
|
+
/** Whether a built-in element may have attributes beyond its built-in ones (except class and style). */
|
|
45
47
|
extends(tag: string): boolean;
|
|
46
|
-
/**
|
|
48
|
+
/** Whether the rules allow class on any built-in element (then classes are kept). */
|
|
47
49
|
get classOnBuiltIn(): boolean;
|
|
48
|
-
/**
|
|
50
|
+
/** All required attributes are present. */
|
|
49
51
|
hasRequired(tag: string, dom: HTMLElement): boolean;
|
|
50
52
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
53
|
+
* The element's attributes allowed by the rule (values checked), or null. `skip` — attributes the
|
|
54
|
+
* element itself doesn't keep: class and style of built-in elements (validClasses, validStyles,
|
|
55
|
+
* formatting marks). The parser moves the own style of new elements to OWN_STYLE (see parser.ts).
|
|
54
56
|
*/
|
|
55
57
|
readAttrs(tag: string, dom: HTMLElement, skip: readonly string[]): Record<string, string> | null;
|
|
56
58
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
+
* Attributes for output: built-in ones plus kept ones (`extras`, which may have come from JSON as
|
|
60
|
+
* anything), then the element's list and the value rules.
|
|
59
61
|
*/
|
|
60
62
|
outputAttrs(tag: string, builtIn: Attrs, extras: unknown): Attrs;
|
|
61
|
-
/**
|
|
63
|
+
/** Apply the rules to toDOM output: attributes of the spec's top element. */
|
|
62
64
|
decorate(spec: DOMOutputSpec, extras: unknown): DOMOutputSpec;
|
|
63
65
|
}
|
|
64
|
-
/**
|
|
66
|
+
/** Rules from the options, or null when there is nothing to apply. */
|
|
65
67
|
declare function createHtmlRules(options: HtmlRulesOptions): HtmlRules | null;
|
|
66
68
|
interface SchemaRef {
|
|
67
69
|
schema?: Schema;
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
72
|
+
* Apply the rules to the schema specs: built-in nodes and marks get attribute rules, new elements
|
|
73
|
+
* get their own nodes and marks (at the end, so built-in parse rules keep priority). After the schema
|
|
74
|
+
* is created, store it in `ref.schema`.
|
|
73
75
|
*/
|
|
74
76
|
declare function applyHtmlRules(nodes: Record<string, NodeSpec>, marks: Record<string, MarkSpec>, rules: HtmlRules, ref: SchemaRef): {
|
|
75
77
|
nodes: Record<string, NodeSpec>;
|
|
76
78
|
marks: Record<string, MarkSpec>;
|
|
77
79
|
};
|
|
78
80
|
/**
|
|
79
|
-
*
|
|
81
|
+
* The module to register in the core:
|
|
80
82
|
*
|
|
81
83
|
* import { registerHtmlRules } from '@novaprose/core';
|
|
82
84
|
* import { htmlRules } from '@novaprose/core/html-rules';
|
package/dist/html-rules.d.ts
CHANGED
|
@@ -1,82 +1,84 @@
|
|
|
1
1
|
import { Schema, DOMOutputSpec, NodeSpec, MarkSpec } from 'prosemirror-model';
|
|
2
|
-
import {
|
|
2
|
+
import { a as HtmlRulesOptions } from './html-rules-api-BLDDW9MO.js';
|
|
3
|
+
import { HtmlRulesInstance, SchemaSpecs, HtmlRulesModule } from './index.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
* customElements.
|
|
7
|
-
* `a[href|title],div[class|data-*],@[id],my-widget`.
|
|
6
|
+
* Rules for HTML elements and attributes: validElements (with attributes), extendedValidElements and
|
|
7
|
+
* customElements. The syntax is that of the TinyMCE options with the same names (from their public
|
|
8
|
+
* documentation): `a[href|title],div[class|data-*],@[id],my-widget`.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
* 1.
|
|
11
|
-
* target
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* Two directions:
|
|
11
|
+
* 1. Restricting. A list in [...] is the complete list of an element's attributes: `a[href|title]`
|
|
12
|
+
* drops target and class. Values: `name=v` — default, `name:v` — always, `name<a?b` — only from
|
|
13
|
+
* the list, `!name` — required (an element without it is not recognized). `@[...]` and `*[...]`
|
|
14
|
+
* apply to all elements.
|
|
15
|
+
* 2. Extending. Attributes the built-in schema doesn't know (`h2[id]`, `a[rel|data-*]`) are kept in
|
|
16
|
+
* the node attribute `htmlAttrs`. New elements (`div`, `section`, `abbr`, `<i class>` for icons,
|
|
17
|
+
* your own `my-widget`) become generic nodes html_block / html_textblock / html_inline_atom and
|
|
18
|
+
* the mark html_inline with a `tag` attribute.
|
|
17
19
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* (
|
|
20
|
+
* Rules never switch security off: script, iframe, forms and the like are not allowed, on* handlers,
|
|
21
|
+
* srcdoc and formaction are never kept, and addresses and CSS are checked when parsing and when
|
|
22
|
+
* writing (a document can arrive as JSON, bypassing the parser).
|
|
21
23
|
*/
|
|
22
24
|
|
|
23
|
-
/**
|
|
25
|
+
/** Elements of the built-in schema (their attributes can be restricted and extended). */
|
|
24
26
|
declare const BASE_TAGS: Set<string>;
|
|
25
27
|
type Attrs = Record<string, unknown>;
|
|
26
28
|
declare class HtmlRules implements HtmlRulesInstance {
|
|
27
|
-
/**
|
|
29
|
+
/** The element's attribute list (null — no list given, built-in attributes). */
|
|
28
30
|
private readonly elements;
|
|
29
31
|
private readonly globals;
|
|
30
|
-
/**
|
|
32
|
+
/** Generic elements: tag in the input HTML → tag in the output (synonyms like `div/section`). */
|
|
31
33
|
readonly blockTags: Map<string, string>;
|
|
32
34
|
readonly inlineTags: Map<string, string>;
|
|
33
35
|
constructor(options: HtmlRulesOptions);
|
|
34
36
|
apply(specs: SchemaSpecs, ref: {
|
|
35
37
|
schema?: Schema;
|
|
36
38
|
}): SchemaSpecs;
|
|
37
|
-
/**
|
|
39
|
+
/** Whether there is anything to apply (otherwise the editor does without this module). */
|
|
38
40
|
get active(): boolean;
|
|
39
|
-
/**
|
|
41
|
+
/** Whether the rules concern the element: an attribute list, values or common attributes. */
|
|
40
42
|
touches(tag: string): boolean;
|
|
41
43
|
private rulesFor;
|
|
42
|
-
/**
|
|
44
|
+
/** Whether the rule allows an attribute (not counting the element's built-in attributes). */
|
|
43
45
|
allows(tag: string, name: string): boolean;
|
|
44
|
-
/**
|
|
46
|
+
/** Whether a built-in element may have attributes beyond its built-in ones (except class and style). */
|
|
45
47
|
extends(tag: string): boolean;
|
|
46
|
-
/**
|
|
48
|
+
/** Whether the rules allow class on any built-in element (then classes are kept). */
|
|
47
49
|
get classOnBuiltIn(): boolean;
|
|
48
|
-
/**
|
|
50
|
+
/** All required attributes are present. */
|
|
49
51
|
hasRequired(tag: string, dom: HTMLElement): boolean;
|
|
50
52
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
53
|
+
* The element's attributes allowed by the rule (values checked), or null. `skip` — attributes the
|
|
54
|
+
* element itself doesn't keep: class and style of built-in elements (validClasses, validStyles,
|
|
55
|
+
* formatting marks). The parser moves the own style of new elements to OWN_STYLE (see parser.ts).
|
|
54
56
|
*/
|
|
55
57
|
readAttrs(tag: string, dom: HTMLElement, skip: readonly string[]): Record<string, string> | null;
|
|
56
58
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
+
* Attributes for output: built-in ones plus kept ones (`extras`, which may have come from JSON as
|
|
60
|
+
* anything), then the element's list and the value rules.
|
|
59
61
|
*/
|
|
60
62
|
outputAttrs(tag: string, builtIn: Attrs, extras: unknown): Attrs;
|
|
61
|
-
/**
|
|
63
|
+
/** Apply the rules to toDOM output: attributes of the spec's top element. */
|
|
62
64
|
decorate(spec: DOMOutputSpec, extras: unknown): DOMOutputSpec;
|
|
63
65
|
}
|
|
64
|
-
/**
|
|
66
|
+
/** Rules from the options, or null when there is nothing to apply. */
|
|
65
67
|
declare function createHtmlRules(options: HtmlRulesOptions): HtmlRules | null;
|
|
66
68
|
interface SchemaRef {
|
|
67
69
|
schema?: Schema;
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
72
|
+
* Apply the rules to the schema specs: built-in nodes and marks get attribute rules, new elements
|
|
73
|
+
* get their own nodes and marks (at the end, so built-in parse rules keep priority). After the schema
|
|
74
|
+
* is created, store it in `ref.schema`.
|
|
73
75
|
*/
|
|
74
76
|
declare function applyHtmlRules(nodes: Record<string, NodeSpec>, marks: Record<string, MarkSpec>, rules: HtmlRules, ref: SchemaRef): {
|
|
75
77
|
nodes: Record<string, NodeSpec>;
|
|
76
78
|
marks: Record<string, MarkSpec>;
|
|
77
79
|
};
|
|
78
80
|
/**
|
|
79
|
-
*
|
|
81
|
+
* The module to register in the core:
|
|
80
82
|
*
|
|
81
83
|
* import { registerHtmlRules } from '@novaprose/core';
|
|
82
84
|
* import { htmlRules } from '@novaprose/core/html-rules';
|