@novaprose/core 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/README.md +20 -4
  2. package/dist/a11y.cjs +314 -0
  3. package/dist/a11y.cjs.map +1 -0
  4. package/dist/a11y.d.cts +51 -0
  5. package/dist/a11y.d.ts +51 -0
  6. package/dist/a11y.js +11 -0
  7. package/dist/a11y.js.map +1 -0
  8. package/dist/a11ychecker-7KQU7DD3.js +449 -0
  9. package/dist/a11ychecker-7KQU7DD3.js.map +1 -0
  10. package/dist/accordion-ui-FGN3I5UF.js +201 -0
  11. package/dist/accordion-ui-FGN3I5UF.js.map +1 -0
  12. package/dist/advcode-65Z2ELUB.js +51 -0
  13. package/dist/advcode-65Z2ELUB.js.map +1 -0
  14. package/dist/advcode-editor-WIOCY552.js +257 -0
  15. package/dist/advcode-editor-WIOCY552.js.map +1 -0
  16. package/dist/{advlist-K2U3VPH2.js → advlist-CEHE6YXS.js} +14 -20
  17. package/dist/advlist-CEHE6YXS.js.map +1 -0
  18. package/dist/advtable-ui-5CBOPTHW.js +364 -0
  19. package/dist/advtable-ui-5CBOPTHW.js.map +1 -0
  20. package/dist/ai-IRQYZHRK.js +1485 -0
  21. package/dist/ai-IRQYZHRK.js.map +1 -0
  22. package/dist/anchor-ui-NWIIRKGY.js +81 -0
  23. package/dist/anchor-ui-NWIIRKGY.js.map +1 -0
  24. package/dist/autocorrect-6GFLVDPC.js +851 -0
  25. package/dist/autocorrect-6GFLVDPC.js.map +1 -0
  26. package/dist/{autolink-XWDTLY37.js → autolink-N427KVQO.js} +13 -7
  27. package/dist/autolink-N427KVQO.js.map +1 -0
  28. package/dist/{autoresize-UB3GOA6D.js → autoresize-YRZAVCNO.js} +2 -2
  29. package/dist/autoresize-YRZAVCNO.js.map +1 -0
  30. package/dist/{autosave-MWNRUNU3.js → autosave-L7OZ3KLK.js} +9 -13
  31. package/dist/autosave-L7OZ3KLK.js.map +1 -0
  32. package/dist/casechange-5G6RAJ7K.js +201 -0
  33. package/dist/casechange-5G6RAJ7K.js.map +1 -0
  34. package/dist/{charmap-ADLYOIB3.js → charmap-5CBBDWOP.js} +9 -14
  35. package/dist/charmap-5CBBDWOP.js.map +1 -0
  36. package/dist/checklist-HM4VXZKY.js +189 -0
  37. package/dist/checklist-HM4VXZKY.js.map +1 -0
  38. package/dist/chunk-23ZLVT5D.js +163 -0
  39. package/dist/chunk-23ZLVT5D.js.map +1 -0
  40. package/dist/chunk-3BOK3S3T.js +26 -0
  41. package/dist/chunk-3BOK3S3T.js.map +1 -0
  42. package/dist/chunk-4I4AYH2K.js +101 -0
  43. package/dist/chunk-4I4AYH2K.js.map +1 -0
  44. package/dist/chunk-4VPDY3LF.js +27 -0
  45. package/dist/chunk-4VPDY3LF.js.map +1 -0
  46. package/dist/chunk-53AY5NAF.js +214 -0
  47. package/dist/chunk-53AY5NAF.js.map +1 -0
  48. package/dist/chunk-5VCESSQB.js +137 -0
  49. package/dist/chunk-5VCESSQB.js.map +1 -0
  50. package/dist/chunk-66INZHZ2.js +79 -0
  51. package/dist/chunk-66INZHZ2.js.map +1 -0
  52. package/dist/chunk-6LQM7G4V.js +159 -0
  53. package/dist/chunk-6LQM7G4V.js.map +1 -0
  54. package/dist/chunk-6YSQGFV7.js +893 -0
  55. package/dist/chunk-6YSQGFV7.js.map +1 -0
  56. package/dist/{chunk-GHEFKKRC.js → chunk-AC3YCAX4.js} +108 -29
  57. package/dist/chunk-AC3YCAX4.js.map +1 -0
  58. package/dist/{chunk-NPKAIW34.js → chunk-ADRPQLZ2.js} +50 -1
  59. package/dist/chunk-ADRPQLZ2.js.map +1 -0
  60. package/dist/chunk-ANE5ASXG.js +26 -0
  61. package/dist/chunk-ANE5ASXG.js.map +1 -0
  62. package/dist/{chunk-Z3ELZ77W.js → chunk-AP2PJFLB.js} +5 -2
  63. package/dist/chunk-AP2PJFLB.js.map +1 -0
  64. package/dist/chunk-AQV6FIKK.js +259 -0
  65. package/dist/chunk-AQV6FIKK.js.map +1 -0
  66. package/dist/chunk-AUQSATWL.js +322 -0
  67. package/dist/chunk-AUQSATWL.js.map +1 -0
  68. package/dist/chunk-C326LHHU.js +143 -0
  69. package/dist/chunk-C326LHHU.js.map +1 -0
  70. package/dist/chunk-DEYYVZ7O.js +393 -0
  71. package/dist/chunk-DEYYVZ7O.js.map +1 -0
  72. package/dist/chunk-EOJ5XHKA.js +160 -0
  73. package/dist/chunk-EOJ5XHKA.js.map +1 -0
  74. package/dist/chunk-EXX2S352.js +3642 -0
  75. package/dist/chunk-EXX2S352.js.map +1 -0
  76. package/dist/chunk-FTEA6L2Q.js +47 -0
  77. package/dist/chunk-FTEA6L2Q.js.map +1 -0
  78. package/dist/chunk-G74HNSB6.js +9 -0
  79. package/dist/chunk-G74HNSB6.js.map +1 -0
  80. package/dist/chunk-GHVB6SV4.js +177 -0
  81. package/dist/chunk-GHVB6SV4.js.map +1 -0
  82. package/dist/chunk-GTLE2HEW.js +108 -0
  83. package/dist/chunk-GTLE2HEW.js.map +1 -0
  84. package/dist/chunk-GXXXLPDQ.js +67 -0
  85. package/dist/chunk-GXXXLPDQ.js.map +1 -0
  86. package/dist/chunk-HC6RMBAD.js +163 -0
  87. package/dist/chunk-HC6RMBAD.js.map +1 -0
  88. package/dist/chunk-HNEAVVBC.js +98 -0
  89. package/dist/chunk-HNEAVVBC.js.map +1 -0
  90. package/dist/chunk-I7Y4KSM2.js +165 -0
  91. package/dist/chunk-I7Y4KSM2.js.map +1 -0
  92. package/dist/chunk-IG2BL4ON.js +127 -0
  93. package/dist/chunk-IG2BL4ON.js.map +1 -0
  94. package/dist/chunk-J6W2CDRF.js +425 -0
  95. package/dist/chunk-J6W2CDRF.js.map +1 -0
  96. package/dist/chunk-LVEQBNLX.js +207 -0
  97. package/dist/chunk-LVEQBNLX.js.map +1 -0
  98. package/dist/chunk-MZGNOHSY.js +176 -0
  99. package/dist/chunk-MZGNOHSY.js.map +1 -0
  100. package/dist/chunk-N32H37AJ.js +373 -0
  101. package/dist/chunk-N32H37AJ.js.map +1 -0
  102. package/dist/chunk-NTGEKGXU.js +263 -0
  103. package/dist/chunk-NTGEKGXU.js.map +1 -0
  104. package/dist/chunk-OFHGXYG3.js +140 -0
  105. package/dist/chunk-OFHGXYG3.js.map +1 -0
  106. package/dist/chunk-OOVNE6MB.js +28 -0
  107. package/dist/chunk-OOVNE6MB.js.map +1 -0
  108. package/dist/chunk-OQMMHWMZ.js +7 -0
  109. package/dist/chunk-OQMMHWMZ.js.map +1 -0
  110. package/dist/chunk-P2UU2NLT.js +1149 -0
  111. package/dist/chunk-P2UU2NLT.js.map +1 -0
  112. package/dist/{chunk-HZRIBOPW.js → chunk-QU3KXMYT.js} +45 -3
  113. package/dist/chunk-QU3KXMYT.js.map +1 -0
  114. package/dist/chunk-S2XZRKHA.js +29 -0
  115. package/dist/chunk-S2XZRKHA.js.map +1 -0
  116. package/dist/chunk-SCIRO4XK.js +144 -0
  117. package/dist/chunk-SCIRO4XK.js.map +1 -0
  118. package/dist/chunk-T3IRLTKK.js +158 -0
  119. package/dist/chunk-T3IRLTKK.js.map +1 -0
  120. package/dist/chunk-TABIUD2L.js +66 -0
  121. package/dist/chunk-TABIUD2L.js.map +1 -0
  122. package/dist/{chunk-7ON7PR5R.js → chunk-TAM2FHKG.js} +374 -52
  123. package/dist/chunk-TAM2FHKG.js.map +1 -0
  124. package/dist/chunk-UTMS2P2K.js +288 -0
  125. package/dist/chunk-UTMS2P2K.js.map +1 -0
  126. package/dist/{chunk-HPLT3XRZ.js → chunk-V7WUHUHM.js} +13 -1
  127. package/dist/chunk-V7WUHUHM.js.map +1 -0
  128. package/dist/chunk-VK6YF2AA.js +359 -0
  129. package/dist/chunk-VK6YF2AA.js.map +1 -0
  130. package/dist/chunk-WAOU5NGN.js +430 -0
  131. package/dist/chunk-WAOU5NGN.js.map +1 -0
  132. package/dist/chunk-XIH4SCO6.js +112 -0
  133. package/dist/chunk-XIH4SCO6.js.map +1 -0
  134. package/dist/chunk-XR7CY4NI.js +11 -0
  135. package/dist/chunk-XR7CY4NI.js.map +1 -0
  136. package/dist/chunk-YDF55N6Z.js +164 -0
  137. package/dist/chunk-YDF55N6Z.js.map +1 -0
  138. package/dist/chunk-YDPZCVXS.js +923 -0
  139. package/dist/chunk-YDPZCVXS.js.map +1 -0
  140. package/dist/chunk-YG5V7POU.js +137 -0
  141. package/dist/chunk-YG5V7POU.js.map +1 -0
  142. package/dist/chunk-YVSUR7E5.js +151 -0
  143. package/dist/chunk-YVSUR7E5.js.map +1 -0
  144. package/dist/codesample-GHWIC7PT.js +546 -0
  145. package/dist/codesample-GHWIC7PT.js.map +1 -0
  146. package/dist/{comments-panel-FYJE3U64.js → comments-panel-SOLBZ46Q.js} +12 -6
  147. package/dist/comments-panel-SOLBZ46Q.js.map +1 -0
  148. package/dist/{directionality-XOHJFSL6.js → directionality-EGQKGDZA.js} +16 -11
  149. package/dist/directionality-EGQKGDZA.js.map +1 -0
  150. package/dist/document-0ft41E6d.d.ts +39 -0
  151. package/dist/document-IQqDDT4v.d.cts +39 -0
  152. package/dist/docx.cjs +23518 -0
  153. package/dist/docx.cjs.map +1 -0
  154. package/dist/docx.d.cts +83 -0
  155. package/dist/docx.d.ts +83 -0
  156. package/dist/docx.js +1821 -0
  157. package/dist/docx.js.map +1 -0
  158. package/dist/draghandle-U6CYZHPA.js +389 -0
  159. package/dist/draghandle-U6CYZHPA.js.map +1 -0
  160. package/dist/editimage-5EWPSM22.js +683 -0
  161. package/dist/editimage-5EWPSM22.js.map +1 -0
  162. package/dist/editor-BCMxe1M4.d.cts +2888 -0
  163. package/dist/editor-Dmtwjw2u.d.ts +2888 -0
  164. package/dist/email-ELNMEQ6E.js +177 -0
  165. package/dist/email-ELNMEQ6E.js.map +1 -0
  166. package/dist/email.cjs +588 -0
  167. package/dist/email.cjs.map +1 -0
  168. package/dist/email.d.cts +7 -0
  169. package/dist/email.d.ts +7 -0
  170. package/dist/email.js +21 -0
  171. package/dist/email.js.map +1 -0
  172. package/dist/{emoticons-TP4N4ZGY.js → emoticons-EGHNZKSA.js} +9 -14
  173. package/dist/emoticons-EGHNZKSA.js.map +1 -0
  174. package/dist/exportpdf-4P7X3NY2.js +91 -0
  175. package/dist/exportpdf-4P7X3NY2.js.map +1 -0
  176. package/dist/exportword-JFJ3KTYZ.js +16 -0
  177. package/dist/exportword-JFJ3KTYZ.js.map +1 -0
  178. package/dist/footnotes-ui-FV6QRGDA.js +449 -0
  179. package/dist/footnotes-ui-FV6QRGDA.js.map +1 -0
  180. package/dist/form-dialog-SNWFPM2K.js +379 -0
  181. package/dist/form-dialog-SNWFPM2K.js.map +1 -0
  182. package/dist/formatpainter-IEXX27OJ.js +209 -0
  183. package/dist/formatpainter-IEXX27OJ.js.map +1 -0
  184. package/dist/fullpagehtml-ui-RE4C2NO5.js +220 -0
  185. package/dist/fullpagehtml-ui-RE4C2NO5.js.map +1 -0
  186. package/dist/html-rules-api-BLDDW9MO.d.cts +42 -0
  187. package/dist/html-rules-api-BLDDW9MO.d.ts +42 -0
  188. package/dist/html-rules.cjs +482 -0
  189. package/dist/html-rules.cjs.map +1 -0
  190. package/dist/html-rules.d.cts +89 -0
  191. package/dist/html-rules.d.ts +89 -0
  192. package/dist/html-rules.js +417 -0
  193. package/dist/html-rules.js.map +1 -0
  194. package/dist/i18n/de.cjs +670 -0
  195. package/dist/i18n/de.cjs.map +1 -0
  196. package/dist/i18n/de.d.cts +9 -0
  197. package/dist/i18n/de.d.ts +9 -0
  198. package/dist/i18n/de.js +649 -0
  199. package/dist/i18n/de.js.map +1 -0
  200. package/dist/i18n/es.cjs +670 -0
  201. package/dist/i18n/es.cjs.map +1 -0
  202. package/dist/i18n/es.d.cts +9 -0
  203. package/dist/i18n/es.d.ts +9 -0
  204. package/dist/i18n/es.js +649 -0
  205. package/dist/i18n/es.js.map +1 -0
  206. package/dist/i18n/fr.cjs +670 -0
  207. package/dist/i18n/fr.cjs.map +1 -0
  208. package/dist/i18n/fr.d.cts +9 -0
  209. package/dist/i18n/fr.d.ts +9 -0
  210. package/dist/i18n/fr.js +649 -0
  211. package/dist/i18n/fr.js.map +1 -0
  212. package/dist/i18n/it.cjs +670 -0
  213. package/dist/i18n/it.cjs.map +1 -0
  214. package/dist/i18n/it.d.cts +9 -0
  215. package/dist/i18n/it.d.ts +9 -0
  216. package/dist/i18n/it.js +649 -0
  217. package/dist/i18n/it.js.map +1 -0
  218. package/dist/i18n/pt-BR.cjs +670 -0
  219. package/dist/i18n/pt-BR.cjs.map +1 -0
  220. package/dist/i18n/pt-BR.d.cts +9 -0
  221. package/dist/i18n/pt-BR.d.ts +9 -0
  222. package/dist/i18n/pt-BR.js +649 -0
  223. package/dist/i18n/pt-BR.js.map +1 -0
  224. package/dist/i18n/ru.cjs +670 -0
  225. package/dist/i18n/ru.cjs.map +1 -0
  226. package/dist/i18n/ru.d.cts +10 -0
  227. package/dist/i18n/ru.d.ts +10 -0
  228. package/dist/i18n/ru.js +649 -0
  229. package/dist/i18n/ru.js.map +1 -0
  230. package/dist/importcss-JLNIRKGH.js +127 -0
  231. package/dist/importcss-JLNIRKGH.js.map +1 -0
  232. package/dist/importword-D7Z6RXGQ.js +73 -0
  233. package/dist/importword-D7Z6RXGQ.js.map +1 -0
  234. package/dist/index-CZ9yDvmQ.d.cts +235 -0
  235. package/dist/index-CZ9yDvmQ.d.ts +235 -0
  236. package/dist/index.cjs +29531 -10134
  237. package/dist/index.cjs.map +1 -1
  238. package/dist/index.d.cts +160 -1828
  239. package/dist/index.d.ts +160 -1828
  240. package/dist/index.js +212 -1480
  241. package/dist/index.js.map +1 -1
  242. package/dist/{insertdatetime-T4SEMQWP.js → insertdatetime-YW2VHYZH.js} +10 -16
  243. package/dist/insertdatetime-YW2VHYZH.js.map +1 -0
  244. package/dist/linkchecker-3S3MCPOS.js +287 -0
  245. package/dist/linkchecker-3S3MCPOS.js.map +1 -0
  246. package/dist/markdown-26O3N3T2.js +136 -0
  247. package/dist/markdown-26O3N3T2.js.map +1 -0
  248. package/dist/markdown.cjs +356 -0
  249. package/dist/markdown.cjs.map +1 -0
  250. package/dist/markdown.d.cts +25 -0
  251. package/dist/markdown.d.ts +25 -0
  252. package/dist/markdown.js +10 -0
  253. package/dist/markdown.js.map +1 -0
  254. package/dist/math-ui-RUTCHTRY.js +157 -0
  255. package/dist/math-ui-RUTCHTRY.js.map +1 -0
  256. package/dist/media-ui-36TE3CJD.js +123 -0
  257. package/dist/media-ui-36TE3CJD.js.map +1 -0
  258. package/dist/mediaembed-ui-ZNTGZ2SQ.js +207 -0
  259. package/dist/mediaembed-ui-ZNTGZ2SQ.js.map +1 -0
  260. package/dist/mentions-ui-O4IPWQT4.js +58 -0
  261. package/dist/mentions-ui-O4IPWQT4.js.map +1 -0
  262. package/dist/mergetags-ui-HS3Q2R36.js +73 -0
  263. package/dist/mergetags-ui-HS3Q2R36.js.map +1 -0
  264. package/dist/{nonbreaking-HG5HV6AL.js → nonbreaking-GYRUH4UO.js} +10 -9
  265. package/dist/nonbreaking-GYRUH4UO.js.map +1 -0
  266. package/dist/pagebreak-ui-I4ZPYK3U.js +50 -0
  267. package/dist/pagebreak-ui-I4ZPYK3U.js.map +1 -0
  268. package/dist/pageembed-ui-WOY6VWRJ.js +172 -0
  269. package/dist/pageembed-ui-WOY6VWRJ.js.map +1 -0
  270. package/dist/pagelayout-ui-Y2IM7FJQ.js +236 -0
  271. package/dist/pagelayout-ui-Y2IM7FJQ.js.map +1 -0
  272. package/dist/paste-office-3A6KWKCV.js +520 -0
  273. package/dist/paste-office-3A6KWKCV.js.map +1 -0
  274. package/dist/permanentpen-6D5LLKFX.js +206 -0
  275. package/dist/permanentpen-6D5LLKFX.js.map +1 -0
  276. package/dist/print-MZMLQIQX.js +178 -0
  277. package/dist/print-MZMLQIQX.js.map +1 -0
  278. package/dist/{quickbars-4NU4SIPL.js → quickbars-UZ2Q67TX.js} +24 -12
  279. package/dist/quickbars-UZ2Q67TX.js.map +1 -0
  280. package/dist/{revisionhistory-3YQPLPLM.js → revisionhistory-ACRB23HL.js} +48 -173
  281. package/dist/revisionhistory-ACRB23HL.js.map +1 -0
  282. package/dist/save-72ZLF6AO.js +120 -0
  283. package/dist/save-72ZLF6AO.js.map +1 -0
  284. package/dist/search-bar-HTZQNPD3.js +212 -0
  285. package/dist/search-bar-HTZQNPD3.js.map +1 -0
  286. package/dist/spellchecker-DJ7SP5JY.js +474 -0
  287. package/dist/spellchecker-DJ7SP5JY.js.map +1 -0
  288. package/dist/suggestions-panel-RJXC4LCM.js +596 -0
  289. package/dist/suggestions-panel-RJXC4LCM.js.map +1 -0
  290. package/dist/suggestions-ui-PODMNH7D.js +395 -0
  291. package/dist/suggestions-ui-PODMNH7D.js.map +1 -0
  292. package/dist/table-OBHE465Y.js +54 -0
  293. package/dist/table-OBHE465Y.js.map +1 -0
  294. package/dist/table-dialogs-UMIIZQYE.js +119 -0
  295. package/dist/table-dialogs-UMIIZQYE.js.map +1 -0
  296. package/dist/tableofcontents-ui-U2PYNPX6.js +167 -0
  297. package/dist/tableofcontents-ui-U2PYNPX6.js.map +1 -0
  298. package/dist/template-YYC2MGVH.js +278 -0
  299. package/dist/template-YYC2MGVH.js.map +1 -0
  300. package/dist/typography-EQUXUXIN.js +399 -0
  301. package/dist/typography-EQUXUXIN.js.map +1 -0
  302. package/dist/upload.cjs +160 -0
  303. package/dist/upload.cjs.map +1 -0
  304. package/dist/upload.d.cts +72 -0
  305. package/dist/upload.d.ts +72 -0
  306. package/dist/upload.js +132 -0
  307. package/dist/upload.js.map +1 -0
  308. package/dist/{visualblocks-RTAYJOGR.js → visualblocks-O5QW7ZDT.js} +10 -9
  309. package/dist/visualblocks-O5QW7ZDT.js.map +1 -0
  310. package/dist/visualchars-UQFRWQPE.js +134 -0
  311. package/dist/visualchars-UQFRWQPE.js.map +1 -0
  312. package/package.json +96 -6
  313. package/src/style.css +440 -508
  314. package/dist/advlist-K2U3VPH2.js.map +0 -1
  315. package/dist/autolink-XWDTLY37.js.map +0 -1
  316. package/dist/autoresize-UB3GOA6D.js.map +0 -1
  317. package/dist/autosave-MWNRUNU3.js.map +0 -1
  318. package/dist/charmap-ADLYOIB3.js.map +0 -1
  319. package/dist/chunk-435CRWKA.js +0 -983
  320. package/dist/chunk-435CRWKA.js.map +0 -1
  321. package/dist/chunk-46RIM5KP.js +0 -5949
  322. package/dist/chunk-46RIM5KP.js.map +0 -1
  323. package/dist/chunk-6RJENZXT.js +0 -104
  324. package/dist/chunk-6RJENZXT.js.map +0 -1
  325. package/dist/chunk-7ON7PR5R.js.map +0 -1
  326. package/dist/chunk-GHEFKKRC.js.map +0 -1
  327. package/dist/chunk-HPLT3XRZ.js.map +0 -1
  328. package/dist/chunk-HZRIBOPW.js.map +0 -1
  329. package/dist/chunk-NPKAIW34.js.map +0 -1
  330. package/dist/chunk-Z3ELZ77W.js.map +0 -1
  331. package/dist/comments-panel-FYJE3U64.js.map +0 -1
  332. package/dist/directionality-XOHJFSL6.js.map +0 -1
  333. package/dist/emoticons-TP4N4ZGY.js.map +0 -1
  334. package/dist/insertdatetime-T4SEMQWP.js.map +0 -1
  335. package/dist/nonbreaking-HG5HV6AL.js.map +0 -1
  336. package/dist/quickbars-4NU4SIPL.js.map +0 -1
  337. package/dist/revisionhistory-3YQPLPLM.js.map +0 -1
  338. package/dist/visualblocks-RTAYJOGR.js.map +0 -1
@@ -0,0 +1,482 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/html-rules.ts
21
+ var html_rules_exports = {};
22
+ __export(html_rules_exports, {
23
+ BASE_TAGS: () => BASE_TAGS,
24
+ HtmlRules: () => HtmlRules,
25
+ applyHtmlRules: () => applyHtmlRules,
26
+ createHtmlRules: () => createHtmlRules,
27
+ htmlRules: () => htmlRules
28
+ });
29
+ module.exports = __toCommonJS(html_rules_exports);
30
+
31
+ // src/html-rules-api.ts
32
+ var OWN_STYLE = "data-nova-own-style";
33
+
34
+ // src/url.ts
35
+ var SAFE_LINK_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]);
36
+ var SAFE_IMAGE_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "blob:"]);
37
+ var SAFE_DATA_IMAGE = /^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,/i;
38
+ function protocolOf(url) {
39
+ if (typeof url !== "string") return null;
40
+ const cleaned = url.replace(/[\u0000- \u007f-\u009f]/g, "");
41
+ const match = cleaned.match(/^([a-z][a-z0-9+.-]*):/i);
42
+ return match ? `${match[1].toLowerCase()}:` : null;
43
+ }
44
+ function isSafeLinkUrl(url) {
45
+ if (typeof url !== "string") return false;
46
+ const protocol = protocolOf(url);
47
+ return protocol === null || SAFE_LINK_PROTOCOLS.has(protocol);
48
+ }
49
+ function isSafeImageUrl(url) {
50
+ if (typeof url !== "string") return false;
51
+ if (SAFE_DATA_IMAGE.test(url.trim())) return true;
52
+ const protocol = protocolOf(url);
53
+ return protocol === null || SAFE_IMAGE_PROTOCOLS.has(protocol);
54
+ }
55
+
56
+ // src/safe-attr.ts
57
+ var LINK_ATTRS = /* @__PURE__ */ new Set(["href", "xlink:href", "action", "formaction", "cite"]);
58
+ var RESOURCE_ATTRS = /* @__PURE__ */ new Set(["src", "poster", "data", "background"]);
59
+ var UNSAFE_CSS = /url\s*\(|expression\s*\(|javascript:|@import|behavior\s*:|-moz-binding/i;
60
+ function safeAttr(name, value) {
61
+ const lower = name.toLowerCase();
62
+ if (lower.startsWith("on")) return null;
63
+ if (LINK_ATTRS.has(lower)) return isSafeLinkUrl(value) ? value : null;
64
+ if (RESOURCE_ATTRS.has(lower)) return isSafeImageUrl(value) ? value : null;
65
+ if (lower === "srcset") {
66
+ const urls = value.split(",").map((part) => part.trim().split(/\s+/)[0] ?? "");
67
+ return urls.every((url) => isSafeImageUrl(url)) ? value : null;
68
+ }
69
+ if (lower === "style") return UNSAFE_CSS.test(value) ? null : value;
70
+ return value;
71
+ }
72
+
73
+ // src/html-rules.ts
74
+ var NEVER = new Set(
75
+ "script,style,iframe,frame,frameset,object,embed,applet,base,link,meta,title,head,html,body,template,slot,noscript,form,input,button,select,option,optgroup,textarea,fieldset,legend,datalist,output,progress,meter,svg,math,canvas,audio,video,source,track,picture,map,area,portal,dialog,param,xmp,plaintext,listing,noembed,noframes,image".split(",")
76
+ );
77
+ var NEVER_ATTR = /^(on|xmlns)|^(srcdoc|formaction|action|contenteditable|autofocus|is|slot|nonce)$/;
78
+ var ATTR_NAME = /^[a-z_:][a-z0-9_.:-]*$/;
79
+ var TAG_NAME = /^[a-z][a-z0-9._-]*$/;
80
+ var BASE_TAGS = new Set(
81
+ "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(
82
+ ","
83
+ )
84
+ );
85
+ var SPLIT = /* @__PURE__ */ new Set(["span", "i", "b", "del", "strike", "mark"]);
86
+ var INLINE = new Set(
87
+ "abbr,acronym,bdi,bdo,big,cite,data,dfn,ins,kbd,q,samp,small,time,tt,var,label,ruby,rt,rp,wbr".split(
88
+ ","
89
+ )
90
+ );
91
+ var BLOCK = new Set(
92
+ "div,section,article,aside,header,footer,nav,main,address,details,summary,dl,dt,dd,center,hgroup,search".split(
93
+ ","
94
+ )
95
+ );
96
+ var BLOCK_LEVEL = /* @__PURE__ */ new Set([
97
+ ...BLOCK,
98
+ ..."p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,table,figure".split(",")
99
+ ]);
100
+ var ESSENTIAL = {
101
+ a: ["href"],
102
+ ul: ["data-type"],
103
+ li: ["data-type", "data-checked"],
104
+ img: ["src"],
105
+ td: ["colspan", "rowspan"],
106
+ th: ["colspan", "rowspan"]
107
+ };
108
+ function splitTopLevel(text) {
109
+ const out = [];
110
+ let depth = 0;
111
+ let current = "";
112
+ for (const ch of text) {
113
+ if (ch === "[") depth++;
114
+ else if (ch === "]") depth = Math.max(0, depth - 1);
115
+ if (ch === "," && !depth) {
116
+ out.push(current);
117
+ current = "";
118
+ } else current += ch;
119
+ }
120
+ out.push(current);
121
+ return out.map((s) => s.trim()).filter(Boolean);
122
+ }
123
+ function parseAttr(raw) {
124
+ let text = raw.trim();
125
+ const required = text.startsWith("!");
126
+ if (required) text = text.slice(1);
127
+ const m = /^([^=:<]+)(?:([=:<])(.*))?$/s.exec(text);
128
+ if (!m) return null;
129
+ const name = m[1].trim().toLowerCase();
130
+ if (!name) return null;
131
+ const rule = { name, required };
132
+ const value = m[3] ?? "";
133
+ if (m[2] === "=") rule.def = value;
134
+ else if (m[2] === ":") rule.forced = value;
135
+ else if (m[2] === "<") rule.values = value.split("?");
136
+ return rule;
137
+ }
138
+ function matches(pattern, name) {
139
+ if (pattern === "*") return true;
140
+ return pattern.endsWith("*") ? name.startsWith(pattern.slice(0, -1)) : pattern === name;
141
+ }
142
+ var warned = /* @__PURE__ */ new Set();
143
+ function warn(tag, reason) {
144
+ if (warned.has(tag)) return;
145
+ warned.add(tag);
146
+ console.warn(`[nova] <${tag}> in content rules is ignored: ${reason}`);
147
+ }
148
+ var HtmlRules = class {
149
+ /** The element's attribute list (null — no list given, built-in attributes). */
150
+ elements = /* @__PURE__ */ new Map();
151
+ globals = [];
152
+ /** Generic elements: tag in the input HTML → tag in the output (synonyms like `div/section`). */
153
+ blockTags = /* @__PURE__ */ new Map();
154
+ inlineTags = /* @__PURE__ */ new Map();
155
+ constructor(options) {
156
+ const invalid = new Set(
157
+ (options.invalidElements ?? "").split(",").map((s) => s.trim().toLowerCase()).filter(Boolean)
158
+ );
159
+ const inlineCustom = /* @__PURE__ */ new Set();
160
+ const custom = /* @__PURE__ */ new Set();
161
+ for (const raw of (options.customElements ?? "").split(",")) {
162
+ const name = raw.trim().toLowerCase();
163
+ const tag = name.replace(/^~/, "");
164
+ if (!TAG_NAME.test(tag)) continue;
165
+ if (NEVER.has(tag) || BASE_TAGS.has(tag)) {
166
+ warn(tag, "it cannot be a custom element");
167
+ continue;
168
+ }
169
+ custom.add(tag);
170
+ if (name.startsWith("~")) inlineCustom.add(tag);
171
+ }
172
+ const declare = (names, attrs) => {
173
+ const [main, ...aliases] = names;
174
+ if (!main) return;
175
+ if (main === "@" || main === "*") {
176
+ this.globals.push(...attrs ?? []);
177
+ return;
178
+ }
179
+ for (const tag of names) {
180
+ if (!TAG_NAME.test(tag) || invalid.has(tag)) continue;
181
+ if (NEVER.has(tag)) {
182
+ warn(tag, "not allowed for security reasons (iframes and video: use the media plugin)");
183
+ continue;
184
+ }
185
+ this.elements.set(tag, attrs);
186
+ const output = BASE_TAGS.has(tag) || SPLIT.has(tag) ? tag : main;
187
+ if (BASE_TAGS.has(tag)) continue;
188
+ if (SPLIT.has(tag)) {
189
+ if (tag === main && attrs?.length) this.inlineTags.set(tag, tag);
190
+ continue;
191
+ }
192
+ const isCustom = custom.has(tag) || custom.has(main) || tag.includes("-");
193
+ if (INLINE.has(main) || inlineCustom.has(main)) this.inlineTags.set(tag, output);
194
+ else if (BLOCK.has(main) || isCustom) this.blockTags.set(tag, output);
195
+ else if (!aliases.includes(tag) || tag === main) warn(tag, "unknown element");
196
+ }
197
+ };
198
+ for (const raw of splitTopLevel(options.validElements ?? "")) {
199
+ const { names, attrs } = parseRule(raw);
200
+ if (attrs) declare(names, attrs);
201
+ else if (!names.every((n) => BASE_TAGS.has(n) || SPLIT.has(n))) declare(names, null);
202
+ }
203
+ for (const raw of splitTopLevel(options.extendedValidElements ?? "")) {
204
+ const { names, attrs } = parseRule(raw);
205
+ declare(names, attrs);
206
+ }
207
+ for (const tag of custom) {
208
+ if (invalid.has(tag)) continue;
209
+ if (!this.elements.has(tag)) this.elements.set(tag, [{ name: "*", required: false }]);
210
+ if (inlineCustom.has(tag)) this.inlineTags.set(tag, tag);
211
+ else if (!this.inlineTags.has(tag)) this.blockTags.set(tag, tag);
212
+ }
213
+ }
214
+ apply(specs, ref) {
215
+ return applyHtmlRules(specs.nodes, specs.marks, this, ref);
216
+ }
217
+ /** Whether there is anything to apply (otherwise the editor does without this module). */
218
+ get active() {
219
+ return this.elements.size > 0 || this.globals.length > 0;
220
+ }
221
+ /** Whether the rules concern the element: an attribute list, values or common attributes. */
222
+ touches(tag) {
223
+ return this.globals.length > 0 || this.elements.has(tag);
224
+ }
225
+ rulesFor(tag) {
226
+ return [...this.elements.get(tag) ?? [], ...this.globals];
227
+ }
228
+ /** Whether the rule allows an attribute (not counting the element's built-in attributes). */
229
+ allows(tag, name) {
230
+ if (NEVER_ATTR.test(name) || !ATTR_NAME.test(name)) return false;
231
+ return this.rulesFor(tag).some((rule) => matches(rule.name, name));
232
+ }
233
+ /** Whether a built-in element may have attributes beyond its built-in ones (except class and style). */
234
+ extends(tag) {
235
+ return this.rulesFor(tag).some((rule) => rule.name !== "class" && rule.name !== "style");
236
+ }
237
+ /** Whether the rules allow class on any built-in element (then classes are kept). */
238
+ get classOnBuiltIn() {
239
+ if (this.globals.some((r) => matches(r.name, "class"))) return true;
240
+ for (const [tag, attrs] of this.elements) {
241
+ if (BASE_TAGS.has(tag) && attrs?.some((r) => matches(r.name, "class"))) return true;
242
+ }
243
+ return false;
244
+ }
245
+ /** All required attributes are present. */
246
+ hasRequired(tag, dom) {
247
+ return this.rulesFor(tag).every((rule) => !rule.required || dom.hasAttribute(rule.name));
248
+ }
249
+ /**
250
+ * The element's attributes allowed by the rule (values checked), or null. `skip` — attributes the
251
+ * element itself doesn't keep: class and style of built-in elements (validClasses, validStyles,
252
+ * formatting marks). The parser moves the own style of new elements to OWN_STYLE (see parser.ts).
253
+ */
254
+ readAttrs(tag, dom, skip) {
255
+ let out = null;
256
+ for (const attr of Array.from(dom.attributes)) {
257
+ let name = attr.name.toLowerCase();
258
+ if (name === OWN_STYLE) name = "style";
259
+ if (skip.includes(name) || !this.allows(tag, name)) continue;
260
+ const value = safeAttr(name, attr.value);
261
+ if (value !== null) (out ??= {})[name] = value;
262
+ }
263
+ return out;
264
+ }
265
+ /**
266
+ * Attributes for output: built-in ones plus kept ones (`extras`, which may have come from JSON as
267
+ * anything), then the element's list and the value rules.
268
+ */
269
+ outputAttrs(tag, builtIn, extras) {
270
+ const out = { ...builtIn };
271
+ if (extras && typeof extras === "object" && !Array.isArray(extras)) {
272
+ for (const [raw, value] of Object.entries(extras)) {
273
+ const name = raw.toLowerCase();
274
+ if (out[name] != null || !this.allows(tag, name)) continue;
275
+ if (!["string", "number", "boolean"].includes(typeof value)) continue;
276
+ const safe = safeAttr(name, String(value));
277
+ if (safe !== null) out[name] = safe;
278
+ }
279
+ }
280
+ const list = this.elements.get(tag);
281
+ if (list) {
282
+ for (const name of Object.keys(out)) {
283
+ if (this.allows(tag, name) || ESSENTIAL[tag]?.includes(name)) continue;
284
+ if (name.startsWith("data-nova-")) continue;
285
+ delete out[name];
286
+ }
287
+ }
288
+ for (const rule of this.rulesFor(tag)) {
289
+ if (rule.name.includes("*")) continue;
290
+ if (rule.forced !== void 0) out[rule.name] = rule.forced;
291
+ else if (rule.def !== void 0 && out[rule.name] == null) out[rule.name] = rule.def;
292
+ const value = out[rule.name];
293
+ if (rule.values && value != null && !rule.values.includes(String(value))) {
294
+ delete out[rule.name];
295
+ }
296
+ }
297
+ if (tag === "a" && out.target != null && out.rel == null) out.rel = "noopener noreferrer";
298
+ return out;
299
+ }
300
+ /** Apply the rules to toDOM output: attributes of the spec's top element. */
301
+ decorate(spec, extras) {
302
+ if (!Array.isArray(spec) || typeof spec[0] !== "string") return spec;
303
+ const raw = spec[0];
304
+ const tag = (raw.includes(" ") ? raw.split(" ")[1] : raw).toLowerCase();
305
+ if (!this.touches(tag)) return spec;
306
+ const second = spec[1];
307
+ const hasAttrs = !!second && typeof second === "object" && !Array.isArray(second) && second.nodeType === void 0;
308
+ const attrs = this.outputAttrs(tag, hasAttrs ? second : {}, extras);
309
+ return [raw, attrs, ...spec.slice(hasAttrs ? 2 : 1)];
310
+ }
311
+ };
312
+ function parseRule(raw) {
313
+ const m = /^([^[]*)(?:\[(.*)\])?$/s.exec(raw.trim());
314
+ const names = (m?.[1] ?? "").trim().replace(/^[-#+!]+/, "").split("/").map((n) => n.trim().toLowerCase()).filter(Boolean);
315
+ const list = m?.[2];
316
+ const attrs = list === void 0 ? null : list.split("|").map(parseAttr).filter((a) => a !== null);
317
+ return { names, attrs };
318
+ }
319
+ function createHtmlRules(options) {
320
+ if (!options.validElements && !options.extendedValidElements && !options.customElements) {
321
+ return null;
322
+ }
323
+ const rules = new HtmlRules(options);
324
+ return rules.active ? rules : null;
325
+ }
326
+ var tagOf = (selector) => (/^[a-z][a-z0-9-]*/i.exec(selector)?.[0] ?? "").toLowerCase();
327
+ function producedNames(ref, kind, name, attrs, toDOM) {
328
+ try {
329
+ const schema = ref.schema;
330
+ const spec = kind === "node" ? toDOM(schema.nodes[name].create(attrs)) : toDOM(schema.marks[name].create(attrs), true);
331
+ const second = Array.isArray(spec) ? spec[1] : null;
332
+ return second && typeof second === "object" && !Array.isArray(second) ? Object.keys(second) : [];
333
+ } catch {
334
+ return [];
335
+ }
336
+ }
337
+ function wrapBase(name, spec, kind, rules, ref) {
338
+ const tags = (spec.parseDOM ?? []).map((rule) => rule.tag ? tagOf(rule.tag) : "").filter((tag) => BASE_TAGS.has(tag) && rules.touches(tag));
339
+ if (!tags.length || !spec.toDOM) return spec;
340
+ const withExtras = tags.some((tag) => rules.extends(tag));
341
+ const toDOM = spec.toDOM;
342
+ return {
343
+ ...spec,
344
+ ...withExtras ? { attrs: { ...spec.attrs, htmlAttrs: { default: null } } } : {},
345
+ parseDOM: spec.parseDOM.map((rule) => {
346
+ const tag = rule.tag ? tagOf(rule.tag) : "";
347
+ if (!tags.includes(tag)) return rule;
348
+ const getAttrs = rule.getAttrs;
349
+ return {
350
+ ...rule,
351
+ getAttrs: (dom) => {
352
+ const base = getAttrs ? getAttrs(dom) : rule.attrs ?? null;
353
+ if (base === false || !rules.hasRequired(tag, dom)) return false;
354
+ if (!withExtras) return base;
355
+ const extras = rules.readAttrs(tag, dom, ["class", "style"]);
356
+ if (!extras) return base;
357
+ for (const produced of producedNames(ref, kind, name, { ...base }, toDOM)) {
358
+ delete extras[produced];
359
+ }
360
+ return Object.keys(extras).length ? { ...base, htmlAttrs: extras } : base;
361
+ }
362
+ };
363
+ }),
364
+ toDOM: ((value, inline) => rules.decorate(toDOM(value, inline), value.attrs.htmlAttrs))
365
+ };
366
+ }
367
+ function hasBlockChild(dom, rules) {
368
+ return Array.from(dom.children).some((child) => {
369
+ const tag = child.localName;
370
+ return BLOCK_LEVEL.has(tag) || rules.blockTags.has(tag);
371
+ });
372
+ }
373
+ function genericSpecs(rules) {
374
+ const nodes = {};
375
+ const marks = {};
376
+ const read = (output, dom, mark) => {
377
+ if (!rules.hasRequired(output, dom)) return false;
378
+ const split = SPLIT.has(output);
379
+ const skip = !split ? [] : mark && output === "span" ? ["class", "style"] : ["style"];
380
+ const htmlAttrs = rules.readAttrs(output, dom, skip);
381
+ if (split && !htmlAttrs) return false;
382
+ return { tag: output, htmlAttrs };
383
+ };
384
+ const ownStyle = (tags) => [...tags].filter(([, output]) => !SPLIT.has(output)).map(([input]) => input);
385
+ const out = (allowed, fallback, attrs) => {
386
+ const tag = typeof attrs.tag === "string" && allowed.has(attrs.tag) ? attrs.tag : fallback;
387
+ return { tag, attrs: rules.outputAttrs(tag, {}, attrs.htmlAttrs) };
388
+ };
389
+ const blocks = [...rules.blockTags];
390
+ if (blocks.length) {
391
+ const allowed = new Set(rules.blockTags.values());
392
+ const fallback = allowed.has("div") ? "div" : [...allowed][0];
393
+ const attrs = { tag: { default: fallback }, htmlAttrs: { default: null } };
394
+ nodes.html_block = {
395
+ ownStyleTags: ownStyle(rules.blockTags),
396
+ group: "block",
397
+ content: "block+",
398
+ defining: true,
399
+ attrs,
400
+ parseDOM: blocks.map(([input, output]) => ({
401
+ tag: input,
402
+ getAttrs: (dom) => hasBlockChild(dom, rules) ? read(output, dom, false) : false
403
+ })),
404
+ toDOM: (node) => {
405
+ const { tag, attrs: a } = out(allowed, fallback, node.attrs);
406
+ return [tag, a, 0];
407
+ }
408
+ };
409
+ nodes.html_textblock = {
410
+ group: "block",
411
+ content: "inline*",
412
+ attrs,
413
+ parseDOM: blocks.map(([input, output]) => ({
414
+ tag: input,
415
+ getAttrs: (dom) => hasBlockChild(dom, rules) ? false : read(output, dom, false)
416
+ })),
417
+ toDOM: (node) => {
418
+ const { tag, attrs: a } = out(allowed, fallback, node.attrs);
419
+ return [tag, a, 0];
420
+ }
421
+ };
422
+ }
423
+ const inline = [...rules.inlineTags];
424
+ if (inline.length) {
425
+ const allowed = new Set(rules.inlineTags.values());
426
+ const fallback = allowed.has("span") ? "span" : [...allowed][0];
427
+ const attrs = { tag: { default: fallback }, htmlAttrs: { default: null } };
428
+ nodes.html_inline_atom = {
429
+ ownStyleTags: ownStyle(rules.inlineTags),
430
+ group: "inline",
431
+ inline: true,
432
+ atom: true,
433
+ attrs,
434
+ parseDOM: inline.map(([input, output]) => ({
435
+ tag: input,
436
+ // Before marks of the same tag (it has 60) and built-in marks (italic for <i>).
437
+ priority: 65,
438
+ getAttrs: (dom) => dom.firstChild ? false : read(output, dom, false)
439
+ })),
440
+ toDOM: (node) => {
441
+ const { tag, attrs: a } = out(allowed, fallback, node.attrs);
442
+ return [tag, a];
443
+ }
444
+ };
445
+ marks.html_inline = {
446
+ attrs,
447
+ // Different elements (abbr inside kbd) are instances of one mark and must not push each other out.
448
+ excludes: "",
449
+ parseDOM: inline.map(([input, output]) => ({
450
+ tag: input,
451
+ // span: after class marks and plugin nodes (they parse their own spans earlier).
452
+ priority: output === "span" ? 40 : 60,
453
+ getAttrs: (dom) => dom.firstChild ? read(output, dom, true) : false
454
+ })),
455
+ toDOM: (mark) => {
456
+ const { tag, attrs: a } = out(allowed, fallback, mark.attrs);
457
+ return [tag, a, 0];
458
+ }
459
+ };
460
+ }
461
+ return { nodes, marks };
462
+ }
463
+ function applyHtmlRules(nodes, marks, rules, ref) {
464
+ const wrap = (specs, kind) => Object.fromEntries(
465
+ Object.entries(specs).map(([name, spec]) => [name, wrapBase(name, spec, kind, rules, ref)])
466
+ );
467
+ const generic = genericSpecs(rules);
468
+ return {
469
+ nodes: { ...wrap(nodes, "node"), ...generic.nodes },
470
+ marks: { ...wrap(marks, "mark"), ...generic.marks }
471
+ };
472
+ }
473
+ var htmlRules = { create: createHtmlRules };
474
+ // Annotate the CommonJS export names for ESM import in node:
475
+ 0 && (module.exports = {
476
+ BASE_TAGS,
477
+ HtmlRules,
478
+ applyHtmlRules,
479
+ createHtmlRules,
480
+ htmlRules
481
+ });
482
+ //# sourceMappingURL=html-rules.cjs.map
@@ -0,0 +1 @@
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 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 * 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 || !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,MAA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