@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
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import {
|
|
2
|
+
elementId
|
|
3
|
+
} from "./chunk-XR7CY4NI.js";
|
|
4
|
+
import {
|
|
5
|
+
pickLabels
|
|
6
|
+
} from "./chunk-XCXJD5DO.js";
|
|
7
|
+
import {
|
|
8
|
+
definePlugin
|
|
9
|
+
} from "./chunk-V7WUHUHM.js";
|
|
10
|
+
|
|
11
|
+
// nova-raw-css:/home/runner/work/novaprose/novaprose/packages/core/src/plugins/tableofcontents.css?raw
|
|
12
|
+
var tableofcontents_default = '.nova-prosemirror nav[data-toc]{margin:0 0 .75em;padding:10px 14px;border-inline-start:3px solid var(--nova-accent);border-radius:var(--nova-radius-sm);background:var(--nova-code-bg)}.nova-prosemirror nav[data-toc]>:is(p,h1,h2,h3,h4,h5,h6):first-child{margin:0 0 6px;font-size:1em;font-weight:600}.nova-prosemirror nav[data-toc] :is(ul,ol){margin:0;padding-inline-start:1.2em}.nova-prosemirror nav[data-toc]>:is(ul,ol){padding-inline-start:0}.nova-prosemirror nav[data-toc] ul{list-style:none}.nova-prosemirror nav[data-toc] li{margin:2px 0}.nova-prosemirror nav[data-toc] a{color:var(--nova-accent);text-decoration:none;cursor:pointer}.nova-prosemirror nav[data-toc] a:hover{text-decoration:underline}.nova-prosemirror nav[data-toc]:not(:has(a)):after{content:var(--nova-toc-empty, "");color:var(--nova-muted)}.nova-prosemirror nav[data-toc].ProseMirror-selectednode{outline:2px solid var(--nova-accent);outline-offset:2px}';
|
|
13
|
+
|
|
14
|
+
// src/plugins/tableofcontents.ts
|
|
15
|
+
var LABELS = {
|
|
16
|
+
en: {
|
|
17
|
+
title: "Contents",
|
|
18
|
+
insert: "Table of contents",
|
|
19
|
+
update: "Update table of contents",
|
|
20
|
+
empty: "Add headings \u2014 they will appear here"
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var CLASS_RE = /^[A-Za-z_][\w-]{0,63}$/;
|
|
24
|
+
function tocSettings(editor) {
|
|
25
|
+
const options = editor.options.pluginOptions?.tableofcontents ?? {};
|
|
26
|
+
const depth = Number(options.depth);
|
|
27
|
+
return {
|
|
28
|
+
depth: Number.isInteger(depth) && depth >= 1 && depth <= 6 ? depth : 3,
|
|
29
|
+
className: typeof options.className === "string" && CLASS_RE.test(options.className) ? options.className : "nova-toc",
|
|
30
|
+
titleTag: typeof options.titleTag === "string" && /^(p|h[1-6])$/i.test(options.titleTag) ? options.titleTag.toLowerCase() : "p",
|
|
31
|
+
title: typeof options.title === "string" ? options.title.slice(0, 200) : null,
|
|
32
|
+
list: options.orderedList ? "ol" : "ul"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function tocEntries(value) {
|
|
36
|
+
if (!Array.isArray(value)) return [];
|
|
37
|
+
const out = [];
|
|
38
|
+
for (const item of value.slice(0, 1e3)) {
|
|
39
|
+
if (!item || typeof item !== "object") continue;
|
|
40
|
+
const { level, id, text } = item;
|
|
41
|
+
const lvl = Number(level);
|
|
42
|
+
const safeId = elementId(id);
|
|
43
|
+
if (!Number.isInteger(lvl) || lvl < 1 || lvl > 6 || !safeId || typeof text !== "string")
|
|
44
|
+
continue;
|
|
45
|
+
out.push({ level: lvl, id: safeId, text: text.slice(0, 300) });
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
function nestedList(entries, tag) {
|
|
50
|
+
if (!entries.length) return null;
|
|
51
|
+
const root = [tag];
|
|
52
|
+
const stack = [
|
|
53
|
+
{ level: entries[0].level, list: root, last: null }
|
|
54
|
+
];
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
let top = stack[stack.length - 1];
|
|
57
|
+
if (entry.level > top.level && top.last) {
|
|
58
|
+
const sub = [tag];
|
|
59
|
+
top.last.push(sub);
|
|
60
|
+
stack.push({ level: entry.level, list: sub, last: null });
|
|
61
|
+
} else {
|
|
62
|
+
while (stack.length > 1 && entry.level < stack[stack.length - 1].level) stack.pop();
|
|
63
|
+
}
|
|
64
|
+
top = stack[stack.length - 1];
|
|
65
|
+
const item = ["li", ["a", { href: `#${entry.id}` }, entry.text]];
|
|
66
|
+
top.list.push(item);
|
|
67
|
+
top.last = item;
|
|
68
|
+
}
|
|
69
|
+
return root;
|
|
70
|
+
}
|
|
71
|
+
function readEntries(nav) {
|
|
72
|
+
const out = [];
|
|
73
|
+
for (const link of nav.querySelectorAll('a[href^="#"]')) {
|
|
74
|
+
let level = 0;
|
|
75
|
+
for (let el = link; el && el !== nav; el = el.parentElement) {
|
|
76
|
+
if (el.tagName === "UL" || el.tagName === "OL") level++;
|
|
77
|
+
}
|
|
78
|
+
out.push({
|
|
79
|
+
level: Math.min(Math.max(level, 1), 6),
|
|
80
|
+
id: link.getAttribute("href").slice(1),
|
|
81
|
+
text: (link.textContent ?? "").trim()
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return tocEntries(out);
|
|
85
|
+
}
|
|
86
|
+
function tocNodes(editor) {
|
|
87
|
+
const settings = tocSettings(editor);
|
|
88
|
+
return {
|
|
89
|
+
toc: {
|
|
90
|
+
group: "block",
|
|
91
|
+
atom: true,
|
|
92
|
+
selectable: true,
|
|
93
|
+
attrs: { entries: { default: [] }, title: { default: null } },
|
|
94
|
+
parseDOM: [
|
|
95
|
+
// Our own format, TinyMCE's (div.mce-toc) and a custom class from the settings.
|
|
96
|
+
...["nav[data-toc]", "div.mce-toc", `.${settings.className}`].map((tag) => ({
|
|
97
|
+
tag,
|
|
98
|
+
getAttrs: (dom) => {
|
|
99
|
+
const head = dom.querySelector(
|
|
100
|
+
":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5, :scope > h6, :scope > p"
|
|
101
|
+
);
|
|
102
|
+
return { entries: readEntries(dom), title: head?.textContent?.trim() || null };
|
|
103
|
+
}
|
|
104
|
+
}))
|
|
105
|
+
],
|
|
106
|
+
toDOM: (node) => {
|
|
107
|
+
const title = typeof node.attrs.title === "string" ? node.attrs.title.slice(0, 200) : "";
|
|
108
|
+
const list = nestedList(tocEntries(node.attrs.entries), settings.list);
|
|
109
|
+
return [
|
|
110
|
+
"nav",
|
|
111
|
+
{ class: settings.className, "data-toc": "" },
|
|
112
|
+
...title ? [[settings.titleTag, title]] : [],
|
|
113
|
+
...list ? [list] : []
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
var tableofcontents_default2 = definePlugin({
|
|
120
|
+
name: "tableofcontents",
|
|
121
|
+
nodes: tocNodes,
|
|
122
|
+
// The table of contents is visible from the first render: its styles and hint are needed right away, not with the lazy part.
|
|
123
|
+
setup(editor) {
|
|
124
|
+
editor.ui.addStyles("nova-tableofcontents", tableofcontents_default);
|
|
125
|
+
const { empty } = pickLabels(editor, "tableofcontents", LABELS);
|
|
126
|
+
editor.root.style.setProperty("--nova-toc-empty", JSON.stringify(empty));
|
|
127
|
+
},
|
|
128
|
+
load: () => import("./tableofcontents-ui-U7EV3UU7.js")
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
LABELS,
|
|
133
|
+
tocSettings,
|
|
134
|
+
tocEntries,
|
|
135
|
+
tableofcontents_default2 as tableofcontents_default
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=chunk-K4LFGNS7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["nova-raw-css:/home/runner/work/novaprose/novaprose/packages/core/src/plugins/tableofcontents.css?raw","../src/plugins/tableofcontents.ts"],"sourcesContent":[".nova-prosemirror nav[data-toc]{margin:0 0 .75em;padding:10px 14px;border-inline-start:3px solid var(--nova-accent);border-radius:var(--nova-radius-sm);background:var(--nova-code-bg)}.nova-prosemirror nav[data-toc]>:is(p,h1,h2,h3,h4,h5,h6):first-child{margin:0 0 6px;font-size:1em;font-weight:600}.nova-prosemirror nav[data-toc] :is(ul,ol){margin:0;padding-inline-start:1.2em}.nova-prosemirror nav[data-toc]>:is(ul,ol){padding-inline-start:0}.nova-prosemirror nav[data-toc] ul{list-style:none}.nova-prosemirror nav[data-toc] li{margin:2px 0}.nova-prosemirror nav[data-toc] a{color:var(--nova-accent);text-decoration:none;cursor:pointer}.nova-prosemirror nav[data-toc] a:hover{text-decoration:underline}.nova-prosemirror nav[data-toc]:not(:has(a)):after{content:var(--nova-toc-empty, \"\");color:var(--nova-muted)}.nova-prosemirror nav[data-toc].ProseMirror-selectednode{outline:2px solid var(--nova-accent);outline-offset:2px}","import type { DOMOutputSpec, NodeSpec } from 'prosemirror-model';\nimport type { Editor } from '../editor';\nimport { elementId } from '../element-id';\nimport { definePlugin } from '../plugins';\nimport css from './tableofcontents.css?raw';\nimport { pickLabels } from './shared';\n\n/**\n * The tableofcontents plugin: the document's table of contents, a block with links to the headings (as in TinyMCE).\n * It updates by itself when headings change; headings get stable ids (`toc-…`) while\n * the document has a table of contents. `plugins: ['tableofcontents']`.\n *\n * Here are the node, its HTML and styles (visible from the first render); buttons, updating and following\n * links are in the lazy part, tableofcontents-ui.ts.\n */\n\nexport const LABELS = {\n en: {\n title: 'Contents',\n insert: 'Table of contents',\n update: 'Update table of contents',\n empty: 'Add headings — they will appear here',\n },\n};\n\nexport interface TableOfContentsOptions {\n /** Which heading levels go into the table of contents: 1…depth (3 by default). */\n depth?: number;\n /** The block's class in HTML (`nova-toc` by default; TinyMCE uses `mce-toc`). */\n className?: string;\n /** Tag of the table of contents title: `p` (default) or `h1`–`h6`. */\n titleTag?: string;\n /** The title; \"Contents\" in the UI language by default. An empty string — no title. */\n title?: string;\n /** A numbered list instead of a bulleted one. */\n orderedList?: boolean;\n}\n\nexport interface TocEntry {\n level: number;\n id: string;\n text: string;\n}\n\nconst CLASS_RE = /^[A-Za-z_][\\w-]{0,63}$/;\n\n/** Settings with validation: the config can bring anything. */\nexport function tocSettings(editor: Editor) {\n const options = (editor.options.pluginOptions?.tableofcontents ?? {}) as TableOfContentsOptions;\n const depth = Number(options.depth);\n return {\n depth: Number.isInteger(depth) && depth >= 1 && depth <= 6 ? depth : 3,\n className:\n typeof options.className === 'string' && CLASS_RE.test(options.className)\n ? options.className\n : 'nova-toc',\n titleTag:\n typeof options.titleTag === 'string' && /^(p|h[1-6])$/i.test(options.titleTag)\n ? options.titleTag.toLowerCase()\n : 'p',\n title: typeof options.title === 'string' ? options.title.slice(0, 200) : null,\n list: options.orderedList ? 'ol' : 'ul',\n };\n}\n\n/** Table of contents items from the attribute (JSON can bring anything). */\nexport function tocEntries(value: unknown): TocEntry[] {\n if (!Array.isArray(value)) return [];\n const out: TocEntry[] = [];\n for (const item of value.slice(0, 1000)) {\n if (!item || typeof item !== 'object') continue;\n const { level, id, text } = item as Record<string, unknown>;\n const lvl = Number(level);\n const safeId = elementId(id);\n if (!Number.isInteger(lvl) || lvl < 1 || lvl > 6 || !safeId || typeof text !== 'string')\n continue;\n out.push({ level: lvl, id: safeId, text: text.slice(0, 300) });\n }\n return out;\n}\n\n/** Nested lists by heading level. */\nfunction nestedList(entries: TocEntry[], tag: string): DOMOutputSpec | null {\n if (!entries.length) return null;\n const root: unknown[] = [tag];\n const stack: { level: number; list: unknown[]; last: unknown[] | null }[] = [\n { level: entries[0]!.level, list: root, last: null },\n ];\n for (const entry of entries) {\n let top = stack[stack.length - 1]!;\n if (entry.level > top.level && top.last) {\n const sub: unknown[] = [tag];\n top.last.push(sub);\n stack.push({ level: entry.level, list: sub, last: null });\n } else {\n while (stack.length > 1 && entry.level < stack[stack.length - 1]!.level) stack.pop();\n }\n top = stack[stack.length - 1]!;\n const item: unknown[] = ['li', ['a', { href: `#${entry.id}` }, entry.text]];\n top.list.push(item);\n top.last = item;\n }\n return root as unknown as DOMOutputSpec;\n}\n\n/** Items from ready-made HTML (#id links and the nesting depth of lists), until the first update. */\nfunction readEntries(nav: HTMLElement): TocEntry[] {\n const out: TocEntry[] = [];\n for (const link of nav.querySelectorAll<HTMLAnchorElement>('a[href^=\"#\"]')) {\n let level = 0;\n for (let el: Element | null = link; el && el !== nav; el = el.parentElement) {\n if (el.tagName === 'UL' || el.tagName === 'OL') level++;\n }\n out.push({\n level: Math.min(Math.max(level, 1), 6),\n id: link.getAttribute('href')!.slice(1),\n text: (link.textContent ?? '').trim(),\n });\n }\n return tocEntries(out);\n}\n\nfunction tocNodes(editor: Editor): Record<string, NodeSpec> {\n const settings = tocSettings(editor);\n return {\n toc: {\n group: 'block',\n atom: true,\n selectable: true,\n attrs: { entries: { default: [] }, title: { default: null } },\n parseDOM: [\n // Our own format, TinyMCE's (div.mce-toc) and a custom class from the settings.\n ...['nav[data-toc]', 'div.mce-toc', `.${settings.className}`].map((tag) => ({\n tag,\n getAttrs: (dom: HTMLElement) => {\n const head = dom.querySelector(\n ':scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5, :scope > h6, :scope > p',\n );\n return { entries: readEntries(dom), title: head?.textContent?.trim() || null };\n },\n })),\n ],\n toDOM: (node): DOMOutputSpec => {\n const title = typeof node.attrs.title === 'string' ? node.attrs.title.slice(0, 200) : '';\n const list = nestedList(tocEntries(node.attrs.entries), settings.list);\n return [\n 'nav',\n { class: settings.className, 'data-toc': '' },\n ...(title ? [[settings.titleTag, title]] : []),\n ...(list ? [list] : []),\n ] as unknown as DOMOutputSpec;\n },\n },\n };\n}\n\nexport default definePlugin({\n name: 'tableofcontents',\n nodes: tocNodes,\n // The table of contents is visible from the first render: its styles and hint are needed right away, not with the lazy part.\n setup(editor) {\n editor.ui.addStyles('nova-tableofcontents', css);\n const { empty } = pickLabels(editor, 'tableofcontents', LABELS);\n editor.root.style.setProperty('--nova-toc-empty', JSON.stringify(empty));\n },\n load: () => import('./tableofcontents-ui'),\n});\n"],"mappings":";;;;;;;;;;;AAAA;;;ACgBO,IAAM,SAAS;AAAA,EACpB,IAAI;AAAA,IACF,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;AAqBA,IAAM,WAAW;AAGV,SAAS,YAAY,QAAgB;AAC1C,QAAM,UAAW,OAAO,QAAQ,eAAe,mBAAmB,CAAC;AACnE,QAAM,QAAQ,OAAO,QAAQ,KAAK;AAClC,SAAO;AAAA,IACL,OAAO,OAAO,UAAU,KAAK,KAAK,SAAS,KAAK,SAAS,IAAI,QAAQ;AAAA,IACrE,WACE,OAAO,QAAQ,cAAc,YAAY,SAAS,KAAK,QAAQ,SAAS,IACpE,QAAQ,YACR;AAAA,IACN,UACE,OAAO,QAAQ,aAAa,YAAY,gBAAgB,KAAK,QAAQ,QAAQ,IACzE,QAAQ,SAAS,YAAY,IAC7B;AAAA,IACN,OAAO,OAAO,QAAQ,UAAU,WAAW,QAAQ,MAAM,MAAM,GAAG,GAAG,IAAI;AAAA,IACzE,MAAM,QAAQ,cAAc,OAAO;AAAA,EACrC;AACF;AAGO,SAAS,WAAW,OAA4B;AACrD,MAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,QAAO,CAAC;AACnC,QAAM,MAAkB,CAAC;AACzB,aAAW,QAAQ,MAAM,MAAM,GAAG,GAAI,GAAG;AACvC,QAAI,CAAC,QAAQ,OAAO,SAAS,SAAU;AACvC,UAAM,EAAE,OAAO,IAAI,KAAK,IAAI;AAC5B,UAAM,MAAM,OAAO,KAAK;AACxB,UAAM,SAAS,UAAU,E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AAA,EACF;AACF;AAEA,IAAOA,2BAAQ,aAAa;AAAA,EAC1B,MAAM;AAAA,EACN,OAAO;AAAA;AAAA,EAEP,MAAM,QAAQ;AACZ,WAAO,GAAG,UAAU,wBAAwB,uBAAG;AAC/C,UAAM,EAAE,MAAM,IAAI,WAAW,QAAQ,mBAAmB,MAAM;AAC9D,WAAO,KAAK,MAAM,YAAY,oBAAoB,KAAK,UAAU,KAAK,CAAC;AAAA,EACzE;AAAA,EACA,MAAM,MAAM,OAAO,kCAAsB;AAC3C,CAAC;","names":["tableofcontents_default"]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
schema
|
|
3
|
+
} from "./chunk-6BJEOL5V.js";
|
|
4
|
+
import {
|
|
5
|
+
OWN_STYLE
|
|
6
|
+
} from "./chunk-OOVNE6MB.js";
|
|
7
|
+
|
|
8
|
+
// src/parser.ts
|
|
9
|
+
import {
|
|
10
|
+
DOMParser
|
|
11
|
+
} from "prosemirror-model";
|
|
12
|
+
var CELL_BG_ATTR = "data-nova-cell-bg";
|
|
13
|
+
var HTML_NS = "http://www.w3.org/1999/xhtml";
|
|
14
|
+
var MATHML_NS = "http://www.w3.org/1998/Math/MathML";
|
|
15
|
+
function replaceForeignElements(root) {
|
|
16
|
+
const foreign = [...root.querySelectorAll("*")].filter(
|
|
17
|
+
// Only the outermost ones: the parent is an HTML element or the fragment itself (parentElement = null).
|
|
18
|
+
(el) => el.namespaceURI !== HTML_NS && (el.parentElement?.namespaceURI ?? HTML_NS) === HTML_NS
|
|
19
|
+
);
|
|
20
|
+
for (const el of foreign) {
|
|
21
|
+
const text = el.namespaceURI === MATHML_NS ? el.textContent ?? "" : "";
|
|
22
|
+
el.replaceWith(el.ownerDocument.createTextNode(text));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function preprocessDOM(root) {
|
|
26
|
+
replaceForeignElements(root);
|
|
27
|
+
root.querySelectorAll("td, th").forEach((cell) => {
|
|
28
|
+
if (!cell.style) return;
|
|
29
|
+
const bg = cell.style.backgroundColor;
|
|
30
|
+
if (!bg) return;
|
|
31
|
+
cell.setAttribute(CELL_BG_ATTR, bg);
|
|
32
|
+
cell.style.removeProperty("background-color");
|
|
33
|
+
if (!cell.getAttribute("style")) cell.removeAttribute("style");
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
var NovaDOMParser = class extends DOMParser {
|
|
37
|
+
atomSelector;
|
|
38
|
+
ownStyleSelector;
|
|
39
|
+
prepare(dom) {
|
|
40
|
+
preprocessDOM(dom);
|
|
41
|
+
this.ownStyleSelector ??= Object.values(this.schema.nodes).flatMap((type) => type.spec.ownStyleTags ?? []).join(", ");
|
|
42
|
+
if (this.ownStyleSelector && "querySelectorAll" in dom) {
|
|
43
|
+
dom.querySelectorAll(this.ownStyleSelector).forEach((el) => {
|
|
44
|
+
const style = el.getAttribute("style");
|
|
45
|
+
if (style === null) return;
|
|
46
|
+
el.setAttribute(OWN_STYLE, style);
|
|
47
|
+
el.removeAttribute("style");
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
this.atomSelector ??= Object.values(this.schema.nodes).filter((type) => type.spec.ignoreStyles).flatMap((type) => (type.spec.parseDOM ?? []).map((rule) => rule.tag)).filter((tag) => !!tag).join(", ");
|
|
51
|
+
if (!this.atomSelector || !("querySelectorAll" in dom)) return;
|
|
52
|
+
dom.querySelectorAll(this.atomSelector).forEach((el) => {
|
|
53
|
+
el.removeAttribute("style");
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
parse(dom, options) {
|
|
57
|
+
this.prepare(dom);
|
|
58
|
+
return super.parse(dom, options);
|
|
59
|
+
}
|
|
60
|
+
parseSlice(dom, options) {
|
|
61
|
+
this.prepare(dom);
|
|
62
|
+
return super.parseSlice(dom, options);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var parsers = /* @__PURE__ */ new WeakMap();
|
|
66
|
+
function parserFor(target) {
|
|
67
|
+
let parser = parsers.get(target);
|
|
68
|
+
if (!parser) {
|
|
69
|
+
parser = new NovaDOMParser(target, DOMParser.fromSchema(target).rules);
|
|
70
|
+
parsers.set(target, parser);
|
|
71
|
+
}
|
|
72
|
+
return parser;
|
|
73
|
+
}
|
|
74
|
+
var novaParser = parserFor(schema);
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
parserFor
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=chunk-KGEHUWGL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/parser.ts"],"sourcesContent":["import {\n DOMParser,\n type ParseOptions,\n type Node as PMNode,\n type Schema,\n type Slice,\n} from 'prosemirror-model';\nimport { OWN_STYLE } from './html-rules-api';\nimport { schema } from './schema';\n\n/** The attribute that takes a cell's background before parsing (see preprocessDOM). */\nexport const CELL_BG_ATTR = 'data-nova-cell-bg';\n\nconst HTML_NS = 'http://www.w3.org/1999/xhtml';\nconst MATHML_NS = 'http://www.w3.org/1998/Math/MathML';\n\n/**\n * The schema doesn't support MathML and SVG. Inside them there are elements with HTML tag names\n * (`<math><td>`), but without `style` and the rest of the HTML API, and the parse rules crashed on them.\n * A formula (MathML, including from Word) is replaced with its text so the text isn't lost; SVG is removed.\n * Found by a property-based test (packages/core/test/security.property.test.ts).\n */\nfunction replaceForeignElements(root: ParentNode): void {\n const foreign = [...root.querySelectorAll('*')].filter(\n // Only the outermost ones: the parent is an HTML element or the fragment itself (parentElement = null).\n (el) => el.namespaceURI !== HTML_NS && (el.parentElement?.namespaceURI ?? HTML_NS) === HTML_NS,\n );\n for (const el of foreign) {\n const text = el.namespaceURI === MATHML_NS ? (el.textContent ?? '') : '';\n el.replaceWith(el.ownerDocument.createTextNode(text));\n }\n}\n\n/**\n * DOM preprocessing before the schema parses it, shared by setContent and paste.\n *\n * Cell background: ProseMirror's style rules apply to any element, so\n * `<td style=\"background-color\">` would otherwise also become a \"highlight\" mark on all the cell text.\n * The value moves into a service attribute and is removed from style.\n */\nexport function preprocessDOM(root: ParentNode): void {\n replaceForeignElements(root);\n root.querySelectorAll<HTMLElement>('td, th').forEach((cell) => {\n // Inside <math>/<svg> a \"td\" is an element of a foreign namespace and may have no style.\n if (!cell.style) return;\n const bg = cell.style.backgroundColor;\n if (!bg) return;\n cell.setAttribute(CELL_BG_ATTR, bg);\n cell.style.removeProperty('background-color');\n if (!cell.getAttribute('style')) cell.removeAttribute('style');\n });\n}\n\n/**\n * The DOMParser of the NovaProse schema with preprocessing: used both for content and the clipboard.\n *\n * Nodes with `ignoreStyles: true` in their spec (a template variable, a non-editable \"chip\") must not\n * get marks from their own style: ProseMirror reads an element's styles before it learns\n * that it is a whole node. So such elements lose their style before parsing.\n */\nclass NovaDOMParser extends DOMParser {\n private atomSelector: string | undefined;\n private ownStyleSelector: string | undefined;\n\n private prepare(dom: globalThis.Node): void {\n preprocessDOM(dom as ParentNode);\n // Elements from extendedValidElements (div, abbr…) keep style themselves. Otherwise ProseMirror would turn\n // it into formatting marks on the content as well, and the style would double on every save.\n this.ownStyleSelector ??= Object.values(this.schema.nodes)\n .flatMap((type) => (type.spec as { ownStyleTags?: string[] }).ownStyleTags ?? [])\n .join(', ');\n if (this.ownStyleSelector && 'querySelectorAll' in dom) {\n (dom as ParentNode).querySelectorAll(this.ownStyleSelector).forEach((el) => {\n const style = el.getAttribute('style');\n if (style === null) return;\n el.setAttribute(OWN_STYLE, style);\n el.removeAttribute('style');\n });\n }\n this.atomSelector ??= Object.values(this.schema.nodes)\n .filter((type) => (type.spec as { ignoreStyles?: boolean }).ignoreStyles)\n .flatMap((type) => (type.spec.parseDOM ?? []).map((rule) => rule.tag))\n .filter((tag): tag is string => !!tag)\n .join(', ');\n if (!this.atomSelector || !('querySelectorAll' in dom)) return;\n (dom as ParentNode).querySelectorAll(this.atomSelector).forEach((el) => {\n el.removeAttribute('style');\n });\n }\n\n override parse(dom: globalThis.Node, options?: ParseOptions): PMNode {\n this.prepare(dom);\n return super.parse(dom, options);\n }\n\n override parseSlice(dom: globalThis.Node, options?: ParseOptions): Slice {\n this.prepare(dom);\n return super.parseSlice(dom, options);\n }\n}\n\nconst parsers = new WeakMap<Schema, NovaDOMParser>();\n\n/** A parser for a specific editor's schema (created once per schema). */\nexport function parserFor(target: Schema): DOMParser {\n let parser = parsers.get(target);\n if (!parser) {\n parser = new NovaDOMParser(target, DOMParser.fromSchema(target).rules);\n parsers.set(target, parser);\n }\n return parser;\n}\n\n/** The parser of the base schema. */\nexport const novaParser = parserFor(schema);\n"],"mappings":";;;;;;;;AAAA;AAAA,EACE;AAAA,OAKK;AAKA,IAAM,eAAe;AAE5B,IAAM,UAAU;AAChB,IAAM,YAAY;AAQlB,SAAS,uBAAuB,MAAwB;AACtD,QAAM,UAAU,CAAC,GAAG,KAAK,iBAAiB,GAAG,CAAC,EAAE;AAAA;AAAA,IAE9C,CAAC,OAAO,GAAG,iBAAiB,YAAY,GAAG,eAAe,gBAAgB,aAAa;AAAA,EACzF;AACA,aAAW,MAAM,SAAS;AACxB,UAAM,OAAO,GAAG,iBAAiB,YAAa,GAAG,eAAe,KAAM;AACtE,OAAG,YAAY,GAAG,cAAc,eAAe,IAAI,CAAC;AAAA,EACtD;AACF;AASO,SAAS,cAAc,MAAwB;AACpD,yBAAuB,IAAI;AAC3B,OAAK,iBAA8B,QAAQ,EAAE,QAAQ,CAAC,SAAS;AAE7D,QAAI,CAAC,KAAK,MAAO;AACjB,UAAM,KAAK,KAAK,MAAM;AACtB,QAAI,CAAC,GAAI;AACT,SAAK,aAAa,cAAc,EAAE;AAClC,SAAK,MAAM,eAAe,kBAAkB;AAC5C,QAAI,CAAC,KAAK,aAAa,OAAO,EAAG,MAAK,gBAAgB,OAAO;AAAA,EAC/D,CAAC;AACH;AASA,IAAM,gBAAN,cAA4B,UAAU;AAAA,EAC5B;AAAA,EACA;AAAA,EAEA,QAAQ,KAA4B;AAC1C,kBAAc,GAAiB;AAG/B,SAAK,qBAAqB,OAAO,OAAO,KAAK,OAAO,KAAK,EACtD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,MAAM;","names":[]}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
positionFloating
|
|
3
|
+
} from "./chunk-GTLE2HEW.js";
|
|
4
|
+
import {
|
|
5
|
+
openLinkDialog,
|
|
6
|
+
removeLink
|
|
7
|
+
} from "./chunk-SNVYHGGO.js";
|
|
8
|
+
import {
|
|
9
|
+
getLinkAt,
|
|
10
|
+
markRange,
|
|
11
|
+
marksOf
|
|
12
|
+
} from "./chunk-UHUOAQA6.js";
|
|
13
|
+
import {
|
|
14
|
+
icons
|
|
15
|
+
} from "./chunk-5KERLFDD.js";
|
|
16
|
+
import {
|
|
17
|
+
activeElement,
|
|
18
|
+
h,
|
|
19
|
+
icon
|
|
20
|
+
} from "./chunk-QU3KXMYT.js";
|
|
21
|
+
import {
|
|
22
|
+
isSafeLinkUrl
|
|
23
|
+
} from "./chunk-4VPDY3LF.js";
|
|
24
|
+
|
|
25
|
+
// src/ui/link-bubble.ts
|
|
26
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
27
|
+
var noteProviders = /* @__PURE__ */ new WeakMap();
|
|
28
|
+
function addLinkNote(editor, provider) {
|
|
29
|
+
const set = noteProviders.get(editor) ?? /* @__PURE__ */ new Set();
|
|
30
|
+
noteProviders.set(editor, set);
|
|
31
|
+
set.add(provider);
|
|
32
|
+
return () => set.delete(provider);
|
|
33
|
+
}
|
|
34
|
+
function linkBubblePlugin(editor) {
|
|
35
|
+
return new Plugin({
|
|
36
|
+
key: new PluginKey("nova-link-bubble"),
|
|
37
|
+
view(view) {
|
|
38
|
+
const { t } = editor.ui;
|
|
39
|
+
const anchor = h("a", {
|
|
40
|
+
className: "nova-bubble-link",
|
|
41
|
+
target: "_blank",
|
|
42
|
+
rel: "noopener noreferrer"
|
|
43
|
+
});
|
|
44
|
+
const button = (svg, label, onClick) => {
|
|
45
|
+
const b = h(
|
|
46
|
+
"button",
|
|
47
|
+
{ type: "button", className: "nova-btn", "aria-label": label, "data-tooltip": label },
|
|
48
|
+
icon(svg)
|
|
49
|
+
);
|
|
50
|
+
b.addEventListener("click", onClick);
|
|
51
|
+
editor.ui.tooltip.attach(b);
|
|
52
|
+
return b;
|
|
53
|
+
};
|
|
54
|
+
const row = h(
|
|
55
|
+
"div",
|
|
56
|
+
{ className: "nova-bubble-row" },
|
|
57
|
+
icon(icons.externalLink),
|
|
58
|
+
anchor,
|
|
59
|
+
h("span", { className: "nova-bubble-sep" }),
|
|
60
|
+
button(icons.edit, t("link.edit"), () => openLinkDialog(editor)),
|
|
61
|
+
button(icons.copy, t("link.copy"), () => {
|
|
62
|
+
void navigator.clipboard?.writeText(anchor.href).then(
|
|
63
|
+
() => editor.ui.notify({ text: t("link.copied"), type: "success", timeout: 2e3 })
|
|
64
|
+
);
|
|
65
|
+
}),
|
|
66
|
+
button(icons.unlink, t("unlink"), () => editor.exec(removeLink()))
|
|
67
|
+
);
|
|
68
|
+
const noteText = h("span", { className: "nova-bubble-note-text" });
|
|
69
|
+
const noteAction = h("button", {
|
|
70
|
+
type: "button",
|
|
71
|
+
className: "nova-button nova-bubble-note-action"
|
|
72
|
+
});
|
|
73
|
+
const note = h("div", { className: "nova-bubble-note", hidden: true }, noteText, noteAction);
|
|
74
|
+
const el = h(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
className: "nova-bubble nova-link-bubble",
|
|
78
|
+
role: "toolbar",
|
|
79
|
+
"aria-label": t("link"),
|
|
80
|
+
hidden: true
|
|
81
|
+
},
|
|
82
|
+
row,
|
|
83
|
+
note
|
|
84
|
+
);
|
|
85
|
+
let noteRun = null;
|
|
86
|
+
noteAction.addEventListener("click", () => noteRun?.());
|
|
87
|
+
el.addEventListener("mousedown", (e) => {
|
|
88
|
+
if (e.target.closest("button")) e.preventDefault();
|
|
89
|
+
});
|
|
90
|
+
editor.ui.overlayHost.append(el);
|
|
91
|
+
const hide = () => {
|
|
92
|
+
el.hidden = true;
|
|
93
|
+
};
|
|
94
|
+
const update = () => {
|
|
95
|
+
const state = view.state;
|
|
96
|
+
const link = getLinkAt(state);
|
|
97
|
+
const focused = view.hasFocus() || el.contains(activeElement(el));
|
|
98
|
+
if (!link || !focused || !editor.isEditable() || editor.ui.activeDialog || !state.selection.empty) {
|
|
99
|
+
hide();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const range = markRange(state, marksOf(state).link, state.selection.from);
|
|
103
|
+
if (!range) return hide();
|
|
104
|
+
anchor.textContent = link.href;
|
|
105
|
+
anchor.title = link.href;
|
|
106
|
+
let found = null;
|
|
107
|
+
for (const provider of noteProviders.get(editor) ?? []) {
|
|
108
|
+
found = provider(link.href);
|
|
109
|
+
if (found) break;
|
|
110
|
+
}
|
|
111
|
+
note.hidden = !found;
|
|
112
|
+
noteText.textContent = found?.text ?? "";
|
|
113
|
+
noteAction.hidden = !found?.action;
|
|
114
|
+
noteAction.textContent = found?.action?.label ?? "";
|
|
115
|
+
noteRun = found?.action?.run ?? null;
|
|
116
|
+
if (isSafeLinkUrl(link.href)) anchor.setAttribute("href", link.href);
|
|
117
|
+
else anchor.removeAttribute("href");
|
|
118
|
+
el.hidden = false;
|
|
119
|
+
const start = view.coordsAtPos(range.from);
|
|
120
|
+
const end = view.coordsAtPos(range.to);
|
|
121
|
+
const rect = new DOMRect(
|
|
122
|
+
start.left,
|
|
123
|
+
start.top,
|
|
124
|
+
Math.max(1, end.right - start.left),
|
|
125
|
+
end.bottom - start.top
|
|
126
|
+
);
|
|
127
|
+
positionFloating(el, rect, "bottom-start");
|
|
128
|
+
};
|
|
129
|
+
const onBlur = (event) => {
|
|
130
|
+
if (!el.contains(event.relatedTarget)) hide();
|
|
131
|
+
};
|
|
132
|
+
view.dom.addEventListener("blur", onBlur);
|
|
133
|
+
el.addEventListener("focusout", (event) => {
|
|
134
|
+
if (!el.contains(event.relatedTarget) && !view.hasFocus()) hide();
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
update,
|
|
138
|
+
destroy() {
|
|
139
|
+
view.dom.removeEventListener("blur", onBlur);
|
|
140
|
+
el.remove();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
addLinkNote,
|
|
149
|
+
linkBubblePlugin
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=chunk-KW6ATQPN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/link-bubble.ts"],"sourcesContent":["import { Plugin, PluginKey } from 'prosemirror-state';\nimport { getLinkAt, markRange } from '../commands';\nimport type { Editor } from '../editor';\nimport { openLinkDialog, removeLink } from '../link';\nimport { marksOf } from '../commands';\nimport { isSafeLinkUrl } from '../url';\nimport { activeElement, h, icon } from './dom';\nimport { icons } from './icons';\nimport { positionFloating } from './popover';\n\n/** A note a plugin adds to a link's bubble (the link checker: \"This link seems broken\"). */\nexport interface LinkNote {\n text: string;\n /** One action next to it (\"Ignore\"). */\n action?: { label: string; run(): void };\n}\n\nconst noteProviders = new WeakMap<Editor, Set<(href: string) => LinkNote | null>>();\n\n/** A note on links in the bubble, from a plugin: the first one that has something to say is shown. */\nexport function addLinkNote(\n editor: Editor,\n provider: (href: string) => LinkNote | null,\n): () => void {\n const set = noteProviders.get(editor) ?? new Set();\n noteProviders.set(editor, set);\n set.add(provider);\n return () => set.delete(provider);\n}\n\n/**\n * The link context bubble (as in Google Docs): appears when the cursor is in a link.\n * Shows the address and the \"edit / copy / remove\" actions, and a plugin's note about the link.\n */\nexport function linkBubblePlugin(editor: Editor): Plugin {\n return new Plugin({\n key: new PluginKey('nova-link-bubble'),\n view(view) {\n const { t } = editor.ui;\n const anchor = h('a', {\n className: 'nova-bubble-link',\n target: '_blank',\n rel: 'noopener noreferrer',\n });\n const button = (svg: string, label: string, onClick: () => void) => {\n const b = h(\n 'button',\n { type: 'button', className: 'nova-btn', 'aria-label': label, 'data-tooltip': label },\n icon(svg),\n );\n b.addEventListener('click', onClick);\n editor.ui.tooltip.attach(b);\n return b;\n };\n const row = h(\n 'div',\n { className: 'nova-bubble-row' },\n icon(icons.externalLink),\n anchor,\n h('span', { className: 'nova-bubble-sep' }),\n button(icons.edit, t('link.edit'), () => openLinkDialog(editor)),\n button(icons.copy, t('link.copy'), () => {\n void navigator.clipboard\n ?.writeText(anchor.href)\n .then(() =>\n editor.ui.notify({ text: t('link.copied'), type: 'success', timeout: 2000 }),\n );\n }),\n button(icons.unlink, t('unlink'), () => editor.exec(removeLink())),\n );\n // A plugin's note about the link: a line under the address, with its action.\n const noteText = h('span', { className: 'nova-bubble-note-text' });\n const noteAction = h('button', {\n type: 'button',\n className: 'nova-button nova-bubble-note-action',\n });\n const note = h('div', { className: 'nova-bubble-note', hidden: true }, noteText, noteAction);\n const el = h(\n 'div',\n {\n className: 'nova-bubble nova-link-bubble',\n role: 'toolbar',\n 'aria-label': t('link'),\n hidden: true,\n },\n row,\n note,\n );\n let noteRun: (() => void) | null = null;\n noteAction.addEventListener('click', () => noteRun?.());\n el.addEventListener('mousedown', (e) => {\n if ((e.target as HTMLElement).closest('button')) e.preventDefault();\n });\n editor.ui.overlayHost.append(el);\n\n const hide = () => {\n el.hidden = true;\n };\n\n const update = () => {\n const state = view.state;\n const link = getLinkAt(state);\n const focused = view.hasFocus() || el.contains(activeElement(el));\n if (\n !link ||\n !focused ||\n !editor.isEditable() ||\n editor.ui.activeDialog ||\n !state.selection.empty\n ) {\n hide();\n return;\n }\n const range = markRange(state, marksOf(state).link, state.selection.from);\n if (!range) return hide();\n anchor.textContent = link.href;\n anchor.title = link.href;\n let found: LinkNote | null = null;\n for (const provider of noteProviders.get(editor) ?? []) {\n found = provider(link.href);\n if (found) break;\n }\n note.hidden = !found;\n noteText.textContent = found?.text ?? '';\n noteAction.hidden = !found?.action;\n noteAction.textContent = found?.action?.label ?? '';\n noteRun = found?.action?.run ?? null;\n if (isSafeLinkUrl(link.href)) anchor.setAttribute('href', link.href);\n else anchor.removeAttribute('href');\n el.hidden = false;\n const start = view.coordsAtPos(range.from);\n const end = view.coordsAtPos(range.to);\n const rect = new DOMRect(\n start.left,\n start.top,\n Math.max(1, end.right - start.left),\n end.bottom - start.top,\n );\n positionFloating(el, rect, 'bottom-start');\n };\n\n const onBlur = (event: FocusEvent) => {\n if (!el.contains(event.relatedTarget as Node)) hide();\n };\n view.dom.addEventListener('blur', onBlur);\n el.addEventListener('focusout', (event) => {\n if (!el.contains(event.relatedTarget as Node) && !view.hasFocus()) hide();\n });\n\n return {\n update,\n destroy() {\n view.dom.removeEventListener('blur', onBlur);\n el.remove();\n },\n };\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,QAAQ,iBAAiB;AAiBlC,IAAM,gBAAgB,oBAAI,QAAwD;AAG3E,SAAS,YACd,QACA,UACY;AACZ,QAAM,MAAM,cAAc,IAAI,MAAM,KAAK,oBAAI,IAAI;AACjD,gBAAc,IAAI,QAAQ,GAAG;AAC7B,MAAI,IAAI,QAAQ;AAChB,SAAO,MAAM,IAAI,OAAO,QAAQ;AAClC;AAMO,SAAS,iBAAiB,QAAwB;AACvD,SAAO,IAAI,OAAO;AAAA,IAChB,KAAK,IAAI,UAAU,kBAAkB;AAAA,IACrC,KAAK,MAAM;AACT,YAAM,EAAE,EAAE,IAAI,OAAO;AACrB,YAAM,SAAS,EAAE,KAAK;AAAA,QACpB,WAAW;AAAA,QACX,QAAQ;AAAA,QACR,KAAK;AAAA,MACP,CAAC;AACD,YAAM,SAAS,CAAC,KAAa,OAAe,YAAwB;AAClE,cAAM,IAAI;AAAA,UACR;AAAA,UACA,EAAE,MAAM,UAAU,WAAW,YAAY,cAAc,OAAO,gBAAgB,MAAM;AAAA,UACpF,KAAK,GAAG;AAAA,QACV;AACA,UAAE,iBAAiB,SAAS,OAAO;AACnC,eAAO,GAAG,QAAQ,OAAO,CAAC;AAC1B,eAAO;AAAA,MACT;AACA,YAAM,MAAM;AAAA,QACV;A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iB,YAAY,CAAC,UAAU;AACzC,YAAI,CAAC,GAAG,SAAS,MAAM,aAAqB,KAAK,CAAC,KAAK,SAAS,EAAG,MAAK;AAAA,MAC1E,CAAC;AAED,aAAO;AAAA,QACL;AAAA,QACA,UAAU;AACR,eAAK,IAAI,oBAAoB,QAAQ,MAAM;AAC3C,aAAG,OAAO;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import {
|
|
2
|
+
definePlugin
|
|
3
|
+
} from "./chunk-V7WUHUHM.js";
|
|
4
|
+
import {
|
|
5
|
+
h
|
|
6
|
+
} from "./chunk-QU3KXMYT.js";
|
|
7
|
+
import {
|
|
8
|
+
isSafeImageUrl,
|
|
9
|
+
isSafeLinkUrl
|
|
10
|
+
} from "./chunk-4VPDY3LF.js";
|
|
11
|
+
|
|
12
|
+
// src/plugins/mediaembed.ts
|
|
13
|
+
import { Plugin } from "prosemirror-state";
|
|
14
|
+
var CLASS_RE = /^[\w-]{1,60}$/;
|
|
15
|
+
function mediaEmbedOptions(context) {
|
|
16
|
+
const raw = context.options.pluginOptions?.mediaembed ?? {};
|
|
17
|
+
const maxWidth = Number(raw.maxWidth);
|
|
18
|
+
return {
|
|
19
|
+
className: typeof raw.className === "string" && CLASS_RE.test(raw.className) ? raw.className : "nova-card",
|
|
20
|
+
inlineStyles: raw.inlineStyles !== false,
|
|
21
|
+
maxWidth: Number.isFinite(maxWidth) && maxWidth >= 200 ? Math.min(2e3, Math.round(maxWidth)) : 650
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function cardText(value, max) {
|
|
25
|
+
return typeof value === "string" ? value.replace(/\s+/g, " ").trim().slice(0, max) : "";
|
|
26
|
+
}
|
|
27
|
+
function cardHref(value) {
|
|
28
|
+
if (typeof value !== "string") return null;
|
|
29
|
+
const href = value.trim();
|
|
30
|
+
return /^https?:\/\/[^\s/?#]/i.test(href) && href.length <= 2e3 && isSafeLinkUrl(href) ? href : null;
|
|
31
|
+
}
|
|
32
|
+
function cardImage(value) {
|
|
33
|
+
if (typeof value !== "string") return null;
|
|
34
|
+
const src = value.trim();
|
|
35
|
+
return /^https?:\/\/[^\s/?#]/i.test(src) && src.length <= 2e3 && isSafeImageUrl(src) ? src : null;
|
|
36
|
+
}
|
|
37
|
+
function hostOf(href) {
|
|
38
|
+
try {
|
|
39
|
+
return new URL(href).hostname.replace(/^www\./, "");
|
|
40
|
+
} catch {
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function cardFields(attrs) {
|
|
45
|
+
const href = cardHref(attrs.href);
|
|
46
|
+
return {
|
|
47
|
+
href,
|
|
48
|
+
title: cardText(attrs.title, 300) || (href ? hostOf(href) : ""),
|
|
49
|
+
description: cardText(attrs.description, 500),
|
|
50
|
+
image: cardImage(attrs.image),
|
|
51
|
+
site: cardText(attrs.site, 100) || (href ? hostOf(href) : ""),
|
|
52
|
+
author: cardText(attrs.author, 100)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function buildNodes(context) {
|
|
56
|
+
const settings = mediaEmbedOptions(context);
|
|
57
|
+
const prefixes = [.../* @__PURE__ */ new Set([settings.className, "nova-card", "ephox-summary-card"])];
|
|
58
|
+
const part = (el, name) => el.querySelector(prefixes.map((p) => `.${p}-${name}`).join(", "));
|
|
59
|
+
return {
|
|
60
|
+
link_card: {
|
|
61
|
+
group: "block",
|
|
62
|
+
atom: true,
|
|
63
|
+
selectable: true,
|
|
64
|
+
draggable: true,
|
|
65
|
+
attrs: {
|
|
66
|
+
href: { default: "" },
|
|
67
|
+
title: { default: "" },
|
|
68
|
+
description: { default: "" },
|
|
69
|
+
image: { default: "" },
|
|
70
|
+
site: { default: "" },
|
|
71
|
+
author: { default: "" }
|
|
72
|
+
},
|
|
73
|
+
parseDOM: [
|
|
74
|
+
{
|
|
75
|
+
tag: "a, div",
|
|
76
|
+
// Before links (marks) and plain blocks.
|
|
77
|
+
priority: 70,
|
|
78
|
+
getAttrs: (dom) => {
|
|
79
|
+
const el = dom;
|
|
80
|
+
if (!prefixes.some((p) => el.classList.contains(p))) return false;
|
|
81
|
+
const href = cardHref(
|
|
82
|
+
el.getAttribute("href") ?? el.querySelector("a[href]")?.getAttribute("href")
|
|
83
|
+
);
|
|
84
|
+
if (!href) return false;
|
|
85
|
+
const thumbnail = part(el, "thumbnail");
|
|
86
|
+
const image = thumbnail?.getAttribute("src") ?? thumbnail?.querySelector("img")?.getAttribute("src") ?? "";
|
|
87
|
+
return {
|
|
88
|
+
href,
|
|
89
|
+
title: cardText(part(el, "title")?.textContent, 300),
|
|
90
|
+
description: cardText(part(el, "description")?.textContent, 500),
|
|
91
|
+
image: cardImage(image) ?? "",
|
|
92
|
+
site: cardText(part(el, "website")?.textContent, 100),
|
|
93
|
+
author: cardText(part(el, "author")?.textContent, 100)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
toDOM: (node) => cardDOM(node, settings)
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
var style = (settings, css) => settings.inlineStyles ? css : null;
|
|
103
|
+
function cardDOM(node, settings) {
|
|
104
|
+
const f = cardFields(node.attrs);
|
|
105
|
+
const p = settings.className;
|
|
106
|
+
if (!f.href) return ["div", { class: p }, f.title];
|
|
107
|
+
const muted = "display: block; opacity: 0.75; font-size: 0.875em";
|
|
108
|
+
const text = [
|
|
109
|
+
[
|
|
110
|
+
"span",
|
|
111
|
+
{ class: `${p}-title`, style: style(settings, "display: block; font-weight: 600") },
|
|
112
|
+
f.title
|
|
113
|
+
]
|
|
114
|
+
];
|
|
115
|
+
if (f.description)
|
|
116
|
+
text.push([
|
|
117
|
+
"span",
|
|
118
|
+
{ class: `${p}-description`, style: style(settings, muted) },
|
|
119
|
+
f.description
|
|
120
|
+
]);
|
|
121
|
+
text.push(["span", { class: `${p}-website`, style: style(settings, muted) }, f.site]);
|
|
122
|
+
if (f.author)
|
|
123
|
+
text.push(["span", { class: `${p}-author`, style: style(settings, muted) }, f.author]);
|
|
124
|
+
return [
|
|
125
|
+
"a",
|
|
126
|
+
{
|
|
127
|
+
class: p,
|
|
128
|
+
href: f.href,
|
|
129
|
+
rel: "noopener noreferrer",
|
|
130
|
+
style: style(
|
|
131
|
+
settings,
|
|
132
|
+
`display: flex; flex-wrap: wrap; gap: 12px; max-width: ${settings.maxWidth}px; margin: 0.5em 0; padding: 12px; border: 1px solid rgb(127 127 127 / 0.35); border-radius: 8px; color: inherit; text-decoration: none; overflow: hidden`
|
|
133
|
+
)
|
|
134
|
+
},
|
|
135
|
+
...f.image ? [
|
|
136
|
+
[
|
|
137
|
+
"img",
|
|
138
|
+
{
|
|
139
|
+
class: `${p}-thumbnail`,
|
|
140
|
+
src: f.image,
|
|
141
|
+
alt: "",
|
|
142
|
+
loading: "lazy",
|
|
143
|
+
style: style(
|
|
144
|
+
settings,
|
|
145
|
+
"flex: none; width: 120px; height: 90px; object-fit: cover; border-radius: 4px"
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
] : [],
|
|
150
|
+
// Narrower than 180px beside the picture (a phone), the text goes under it.
|
|
151
|
+
["span", { style: style(settings, "display: block; flex: 1 1 180px; min-width: 0") }, ...text]
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
function cardView(node, settings) {
|
|
155
|
+
const dom = h("div", { className: "nova-card-view", contenteditable: "false" });
|
|
156
|
+
dom.style.maxWidth = `${settings.maxWidth}px`;
|
|
157
|
+
const render = (current) => {
|
|
158
|
+
const f = cardFields(current.attrs);
|
|
159
|
+
dom.replaceChildren(
|
|
160
|
+
...f.image ? [h("img", { className: "nova-card-view-image", src: f.image, alt: "" })] : [],
|
|
161
|
+
h(
|
|
162
|
+
"div",
|
|
163
|
+
{ className: "nova-card-view-text" },
|
|
164
|
+
h("div", { className: "nova-card-view-title" }, f.title),
|
|
165
|
+
f.description ? h("div", { className: "nova-card-view-description" }, f.description) : null,
|
|
166
|
+
h(
|
|
167
|
+
"div",
|
|
168
|
+
{ className: "nova-card-view-site" },
|
|
169
|
+
[f.site, f.author].filter(Boolean).join(" \xB7 ")
|
|
170
|
+
)
|
|
171
|
+
)
|
|
172
|
+
);
|
|
173
|
+
dom.title = f.href ?? "";
|
|
174
|
+
};
|
|
175
|
+
render(node);
|
|
176
|
+
return {
|
|
177
|
+
dom,
|
|
178
|
+
update(next) {
|
|
179
|
+
if (next.type !== node.type) return false;
|
|
180
|
+
node = next;
|
|
181
|
+
render(next);
|
|
182
|
+
return true;
|
|
183
|
+
},
|
|
184
|
+
ignoreMutation: () => true,
|
|
185
|
+
stopEvent: () => false
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
var mediaembed_default = definePlugin({
|
|
189
|
+
name: "mediaembed",
|
|
190
|
+
nodes: buildNodes,
|
|
191
|
+
prosemirrorPlugins: (editor) => {
|
|
192
|
+
const settings = mediaEmbedOptions(editor);
|
|
193
|
+
return [
|
|
194
|
+
new Plugin({ props: { nodeViews: { link_card: (node) => cardView(node, settings) } } })
|
|
195
|
+
];
|
|
196
|
+
},
|
|
197
|
+
load: () => import("./mediaembed-ui-ODX5ECXC.js")
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
export {
|
|
201
|
+
cardText,
|
|
202
|
+
cardHref,
|
|
203
|
+
cardImage,
|
|
204
|
+
cardFields,
|
|
205
|
+
mediaembed_default
|
|
206
|
+
};
|
|
207
|
+
//# sourceMappingURL=chunk-NX3KWIP5.js.map
|