@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,89 @@
1
+ import { Schema, DOMOutputSpec, NodeSpec, MarkSpec } from 'prosemirror-model';
2
+ import { a as HtmlRulesOptions } from './html-rules-api-BLDDW9MO.cjs';
3
+ import { HtmlRulesInstance, SchemaSpecs, HtmlRulesModule } from './index.cjs';
4
+
5
+ /**
6
+ * Rules for HTML elements and attributes: validElements (with attributes), extendedValidElements and
7
+ * customElements. The syntax is that of the TinyMCE options with the same names (from their public
8
+ * documentation): `a[href|title],div[class|data-*],@[id],my-widget`.
9
+ *
10
+ * Two directions:
11
+ * 1. Restricting. A list in [...] is the complete list of an element's attributes: `a[href|title]`
12
+ * drops target and class. Values: `name=v` — default, `name:v` — always, `name<a?b` — only from
13
+ * the list, `!name` — required (an element without it is not recognized). `@[...]` and `*[...]`
14
+ * apply to all elements.
15
+ * 2. Extending. Attributes the built-in schema doesn't know (`h2[id]`, `a[rel|data-*]`) are kept in
16
+ * the node attribute `htmlAttrs`. New elements (`div`, `section`, `abbr`, `<i class>` for icons,
17
+ * your own `my-widget`) become generic nodes html_block / html_textblock / html_inline_atom and
18
+ * the mark html_inline with a `tag` attribute.
19
+ *
20
+ * Rules never switch security off: script, iframe, forms and the like are not allowed, on* handlers,
21
+ * srcdoc and formaction are never kept, and addresses and CSS are checked when parsing and when
22
+ * writing (a document can arrive as JSON, bypassing the parser).
23
+ */
24
+
25
+ /** Elements of the built-in schema (their attributes can be restricted and extended). */
26
+ declare const BASE_TAGS: Set<string>;
27
+ type Attrs = Record<string, unknown>;
28
+ declare class HtmlRules implements HtmlRulesInstance {
29
+ /** The element's attribute list (null — no list given, built-in attributes). */
30
+ private readonly elements;
31
+ private readonly globals;
32
+ /** Generic elements: tag in the input HTML → tag in the output (synonyms like `div/section`). */
33
+ readonly blockTags: Map<string, string>;
34
+ readonly inlineTags: Map<string, string>;
35
+ constructor(options: HtmlRulesOptions);
36
+ apply(specs: SchemaSpecs, ref: {
37
+ schema?: Schema;
38
+ }): SchemaSpecs;
39
+ /** Whether there is anything to apply (otherwise the editor does without this module). */
40
+ get active(): boolean;
41
+ /** Whether the rules concern the element: an attribute list, values or common attributes. */
42
+ touches(tag: string): boolean;
43
+ private rulesFor;
44
+ /** Whether the rule allows an attribute (not counting the element's built-in attributes). */
45
+ allows(tag: string, name: string): boolean;
46
+ /** Whether a built-in element may have attributes beyond its built-in ones (except class and style). */
47
+ extends(tag: string): boolean;
48
+ /** Whether the rules allow class on any built-in element (then classes are kept). */
49
+ get classOnBuiltIn(): boolean;
50
+ /** All required attributes are present. */
51
+ hasRequired(tag: string, dom: HTMLElement): boolean;
52
+ /**
53
+ * The element's attributes allowed by the rule (values checked), or null. `skip` — attributes the
54
+ * element itself doesn't keep: class and style of built-in elements (validClasses, validStyles,
55
+ * formatting marks). The parser moves the own style of new elements to OWN_STYLE (see parser.ts).
56
+ */
57
+ readAttrs(tag: string, dom: HTMLElement, skip: readonly string[]): Record<string, string> | null;
58
+ /**
59
+ * Attributes for output: built-in ones plus kept ones (`extras`, which may have come from JSON as
60
+ * anything), then the element's list and the value rules.
61
+ */
62
+ outputAttrs(tag: string, builtIn: Attrs, extras: unknown): Attrs;
63
+ /** Apply the rules to toDOM output: attributes of the spec's top element. */
64
+ decorate(spec: DOMOutputSpec, extras: unknown): DOMOutputSpec;
65
+ }
66
+ /** Rules from the options, or null when there is nothing to apply. */
67
+ declare function createHtmlRules(options: HtmlRulesOptions): HtmlRules | null;
68
+ interface SchemaRef {
69
+ schema?: Schema;
70
+ }
71
+ /**
72
+ * Apply the rules to the schema specs: built-in nodes and marks get attribute rules, new elements
73
+ * get their own nodes and marks (at the end, so built-in parse rules keep priority). After the schema
74
+ * is created, store it in `ref.schema`.
75
+ */
76
+ declare function applyHtmlRules(nodes: Record<string, NodeSpec>, marks: Record<string, MarkSpec>, rules: HtmlRules, ref: SchemaRef): {
77
+ nodes: Record<string, NodeSpec>;
78
+ marks: Record<string, MarkSpec>;
79
+ };
80
+ /**
81
+ * The module to register in the core:
82
+ *
83
+ * import { registerHtmlRules } from '@novaprose/core';
84
+ * import { htmlRules } from '@novaprose/core/html-rules';
85
+ * registerHtmlRules(htmlRules);
86
+ */
87
+ declare const htmlRules: HtmlRulesModule;
88
+
89
+ export { BASE_TAGS, HtmlRules, HtmlRulesOptions, applyHtmlRules, createHtmlRules, htmlRules };
@@ -0,0 +1,89 @@
1
+ import { Schema, DOMOutputSpec, NodeSpec, MarkSpec } from 'prosemirror-model';
2
+ import { a as HtmlRulesOptions } from './html-rules-api-BLDDW9MO.js';
3
+ import { HtmlRulesInstance, SchemaSpecs, HtmlRulesModule } from './index.js';
4
+
5
+ /**
6
+ * Rules for HTML elements and attributes: validElements (with attributes), extendedValidElements and
7
+ * customElements. The syntax is that of the TinyMCE options with the same names (from their public
8
+ * documentation): `a[href|title],div[class|data-*],@[id],my-widget`.
9
+ *
10
+ * Two directions:
11
+ * 1. Restricting. A list in [...] is the complete list of an element's attributes: `a[href|title]`
12
+ * drops target and class. Values: `name=v` — default, `name:v` — always, `name<a?b` — only from
13
+ * the list, `!name` — required (an element without it is not recognized). `@[...]` and `*[...]`
14
+ * apply to all elements.
15
+ * 2. Extending. Attributes the built-in schema doesn't know (`h2[id]`, `a[rel|data-*]`) are kept in
16
+ * the node attribute `htmlAttrs`. New elements (`div`, `section`, `abbr`, `<i class>` for icons,
17
+ * your own `my-widget`) become generic nodes html_block / html_textblock / html_inline_atom and
18
+ * the mark html_inline with a `tag` attribute.
19
+ *
20
+ * Rules never switch security off: script, iframe, forms and the like are not allowed, on* handlers,
21
+ * srcdoc and formaction are never kept, and addresses and CSS are checked when parsing and when
22
+ * writing (a document can arrive as JSON, bypassing the parser).
23
+ */
24
+
25
+ /** Elements of the built-in schema (their attributes can be restricted and extended). */
26
+ declare const BASE_TAGS: Set<string>;
27
+ type Attrs = Record<string, unknown>;
28
+ declare class HtmlRules implements HtmlRulesInstance {
29
+ /** The element's attribute list (null — no list given, built-in attributes). */
30
+ private readonly elements;
31
+ private readonly globals;
32
+ /** Generic elements: tag in the input HTML → tag in the output (synonyms like `div/section`). */
33
+ readonly blockTags: Map<string, string>;
34
+ readonly inlineTags: Map<string, string>;
35
+ constructor(options: HtmlRulesOptions);
36
+ apply(specs: SchemaSpecs, ref: {
37
+ schema?: Schema;
38
+ }): SchemaSpecs;
39
+ /** Whether there is anything to apply (otherwise the editor does without this module). */
40
+ get active(): boolean;
41
+ /** Whether the rules concern the element: an attribute list, values or common attributes. */
42
+ touches(tag: string): boolean;
43
+ private rulesFor;
44
+ /** Whether the rule allows an attribute (not counting the element's built-in attributes). */
45
+ allows(tag: string, name: string): boolean;
46
+ /** Whether a built-in element may have attributes beyond its built-in ones (except class and style). */
47
+ extends(tag: string): boolean;
48
+ /** Whether the rules allow class on any built-in element (then classes are kept). */
49
+ get classOnBuiltIn(): boolean;
50
+ /** All required attributes are present. */
51
+ hasRequired(tag: string, dom: HTMLElement): boolean;
52
+ /**
53
+ * The element's attributes allowed by the rule (values checked), or null. `skip` — attributes the
54
+ * element itself doesn't keep: class and style of built-in elements (validClasses, validStyles,
55
+ * formatting marks). The parser moves the own style of new elements to OWN_STYLE (see parser.ts).
56
+ */
57
+ readAttrs(tag: string, dom: HTMLElement, skip: readonly string[]): Record<string, string> | null;
58
+ /**
59
+ * Attributes for output: built-in ones plus kept ones (`extras`, which may have come from JSON as
60
+ * anything), then the element's list and the value rules.
61
+ */
62
+ outputAttrs(tag: string, builtIn: Attrs, extras: unknown): Attrs;
63
+ /** Apply the rules to toDOM output: attributes of the spec's top element. */
64
+ decorate(spec: DOMOutputSpec, extras: unknown): DOMOutputSpec;
65
+ }
66
+ /** Rules from the options, or null when there is nothing to apply. */
67
+ declare function createHtmlRules(options: HtmlRulesOptions): HtmlRules | null;
68
+ interface SchemaRef {
69
+ schema?: Schema;
70
+ }
71
+ /**
72
+ * Apply the rules to the schema specs: built-in nodes and marks get attribute rules, new elements
73
+ * get their own nodes and marks (at the end, so built-in parse rules keep priority). After the schema
74
+ * is created, store it in `ref.schema`.
75
+ */
76
+ declare function applyHtmlRules(nodes: Record<string, NodeSpec>, marks: Record<string, MarkSpec>, rules: HtmlRules, ref: SchemaRef): {
77
+ nodes: Record<string, NodeSpec>;
78
+ marks: Record<string, MarkSpec>;
79
+ };
80
+ /**
81
+ * The module to register in the core:
82
+ *
83
+ * import { registerHtmlRules } from '@novaprose/core';
84
+ * import { htmlRules } from '@novaprose/core/html-rules';
85
+ * registerHtmlRules(htmlRules);
86
+ */
87
+ declare const htmlRules: HtmlRulesModule;
88
+
89
+ export { BASE_TAGS, HtmlRules, HtmlRulesOptions, applyHtmlRules, createHtmlRules, htmlRules };
@@ -0,0 +1,417 @@
1
+ import {
2
+ OWN_STYLE
3
+ } from "./chunk-OOVNE6MB.js";
4
+ import {
5
+ safeAttr
6
+ } from "./chunk-3BOK3S3T.js";
7
+ import "./chunk-4VPDY3LF.js";
8
+
9
+ // src/html-rules.ts
10
+ var NEVER = new Set(
11
+ "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(",")
12
+ );
13
+ var NEVER_ATTR = /^(on|xmlns)|^(srcdoc|formaction|action|contenteditable|autofocus|is|slot|nonce)$/;
14
+ var ATTR_NAME = /^[a-z_:][a-z0-9_.:-]*$/;
15
+ var TAG_NAME = /^[a-z][a-z0-9._-]*$/;
16
+ var BASE_TAGS = new Set(
17
+ "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(
18
+ ","
19
+ )
20
+ );
21
+ var SPLIT = /* @__PURE__ */ new Set(["span", "i", "b", "del", "strike", "mark"]);
22
+ var INLINE = new Set(
23
+ "abbr,acronym,bdi,bdo,big,cite,data,dfn,ins,kbd,q,samp,small,time,tt,var,label,ruby,rt,rp,wbr".split(
24
+ ","
25
+ )
26
+ );
27
+ var BLOCK = new Set(
28
+ "div,section,article,aside,header,footer,nav,main,address,details,summary,dl,dt,dd,center,hgroup,search".split(
29
+ ","
30
+ )
31
+ );
32
+ var BLOCK_LEVEL = /* @__PURE__ */ new Set([
33
+ ...BLOCK,
34
+ ..."p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,table,figure".split(",")
35
+ ]);
36
+ var ESSENTIAL = {
37
+ a: ["href"],
38
+ ul: ["data-type"],
39
+ li: ["data-type", "data-checked"],
40
+ img: ["src"],
41
+ td: ["colspan", "rowspan"],
42
+ th: ["colspan", "rowspan"]
43
+ };
44
+ function splitTopLevel(text) {
45
+ const out = [];
46
+ let depth = 0;
47
+ let current = "";
48
+ for (const ch of text) {
49
+ if (ch === "[") depth++;
50
+ else if (ch === "]") depth = Math.max(0, depth - 1);
51
+ if (ch === "," && !depth) {
52
+ out.push(current);
53
+ current = "";
54
+ } else current += ch;
55
+ }
56
+ out.push(current);
57
+ return out.map((s) => s.trim()).filter(Boolean);
58
+ }
59
+ function parseAttr(raw) {
60
+ let text = raw.trim();
61
+ const required = text.startsWith("!");
62
+ if (required) text = text.slice(1);
63
+ const m = /^([^=:<]+)(?:([=:<])(.*))?$/s.exec(text);
64
+ if (!m) return null;
65
+ const name = m[1].trim().toLowerCase();
66
+ if (!name) return null;
67
+ const rule = { name, required };
68
+ const value = m[3] ?? "";
69
+ if (m[2] === "=") rule.def = value;
70
+ else if (m[2] === ":") rule.forced = value;
71
+ else if (m[2] === "<") rule.values = value.split("?");
72
+ return rule;
73
+ }
74
+ function matches(pattern, name) {
75
+ if (pattern === "*") return true;
76
+ return pattern.endsWith("*") ? name.startsWith(pattern.slice(0, -1)) : pattern === name;
77
+ }
78
+ var warned = /* @__PURE__ */ new Set();
79
+ function warn(tag, reason) {
80
+ if (warned.has(tag)) return;
81
+ warned.add(tag);
82
+ console.warn(`[nova] <${tag}> in content rules is ignored: ${reason}`);
83
+ }
84
+ var HtmlRules = class {
85
+ /** The element's attribute list (null — no list given, built-in attributes). */
86
+ elements = /* @__PURE__ */ new Map();
87
+ globals = [];
88
+ /** Generic elements: tag in the input HTML → tag in the output (synonyms like `div/section`). */
89
+ blockTags = /* @__PURE__ */ new Map();
90
+ inlineTags = /* @__PURE__ */ new Map();
91
+ constructor(options) {
92
+ const invalid = new Set(
93
+ (options.invalidElements ?? "").split(",").map((s) => s.trim().toLowerCase()).filter(Boolean)
94
+ );
95
+ const inlineCustom = /* @__PURE__ */ new Set();
96
+ const custom = /* @__PURE__ */ new Set();
97
+ for (const raw of (options.customElements ?? "").split(",")) {
98
+ const name = raw.trim().toLowerCase();
99
+ const tag = name.replace(/^~/, "");
100
+ if (!TAG_NAME.test(tag)) continue;
101
+ if (NEVER.has(tag) || BASE_TAGS.has(tag)) {
102
+ warn(tag, "it cannot be a custom element");
103
+ continue;
104
+ }
105
+ custom.add(tag);
106
+ if (name.startsWith("~")) inlineCustom.add(tag);
107
+ }
108
+ const declare = (names, attrs) => {
109
+ const [main, ...aliases] = names;
110
+ if (!main) return;
111
+ if (main === "@" || main === "*") {
112
+ this.globals.push(...attrs ?? []);
113
+ return;
114
+ }
115
+ for (const tag of names) {
116
+ if (!TAG_NAME.test(tag) || invalid.has(tag)) continue;
117
+ if (NEVER.has(tag)) {
118
+ warn(tag, "not allowed for security reasons (iframes and video: use the media plugin)");
119
+ continue;
120
+ }
121
+ this.elements.set(tag, attrs);
122
+ const output = BASE_TAGS.has(tag) || SPLIT.has(tag) ? tag : main;
123
+ if (BASE_TAGS.has(tag)) continue;
124
+ if (SPLIT.has(tag)) {
125
+ if (tag === main && attrs?.length) this.inlineTags.set(tag, tag);
126
+ continue;
127
+ }
128
+ const isCustom = custom.has(tag) || custom.has(main) || tag.includes("-");
129
+ if (INLINE.has(main) || inlineCustom.has(main)) this.inlineTags.set(tag, output);
130
+ else if (BLOCK.has(main) || isCustom) this.blockTags.set(tag, output);
131
+ else if (!aliases.includes(tag) || tag === main) warn(tag, "unknown element");
132
+ }
133
+ };
134
+ for (const raw of splitTopLevel(options.validElements ?? "")) {
135
+ const { names, attrs } = parseRule(raw);
136
+ if (attrs) declare(names, attrs);
137
+ else if (!names.every((n) => BASE_TAGS.has(n) || SPLIT.has(n))) declare(names, null);
138
+ }
139
+ for (const raw of splitTopLevel(options.extendedValidElements ?? "")) {
140
+ const { names, attrs } = parseRule(raw);
141
+ declare(names, attrs);
142
+ }
143
+ for (const tag of custom) {
144
+ if (invalid.has(tag)) continue;
145
+ if (!this.elements.has(tag)) this.elements.set(tag, [{ name: "*", required: false }]);
146
+ if (inlineCustom.has(tag)) this.inlineTags.set(tag, tag);
147
+ else if (!this.inlineTags.has(tag)) this.blockTags.set(tag, tag);
148
+ }
149
+ }
150
+ apply(specs, ref) {
151
+ return applyHtmlRules(specs.nodes, specs.marks, this, ref);
152
+ }
153
+ /** Whether there is anything to apply (otherwise the editor does without this module). */
154
+ get active() {
155
+ return this.elements.size > 0 || this.globals.length > 0;
156
+ }
157
+ /** Whether the rules concern the element: an attribute list, values or common attributes. */
158
+ touches(tag) {
159
+ return this.globals.length > 0 || this.elements.has(tag);
160
+ }
161
+ rulesFor(tag) {
162
+ return [...this.elements.get(tag) ?? [], ...this.globals];
163
+ }
164
+ /** Whether the rule allows an attribute (not counting the element's built-in attributes). */
165
+ allows(tag, name) {
166
+ if (NEVER_ATTR.test(name) || !ATTR_NAME.test(name)) return false;
167
+ return this.rulesFor(tag).some((rule) => matches(rule.name, name));
168
+ }
169
+ /** Whether a built-in element may have attributes beyond its built-in ones (except class and style). */
170
+ extends(tag) {
171
+ return this.rulesFor(tag).some((rule) => rule.name !== "class" && rule.name !== "style");
172
+ }
173
+ /** Whether the rules allow class on any built-in element (then classes are kept). */
174
+ get classOnBuiltIn() {
175
+ if (this.globals.some((r) => matches(r.name, "class"))) return true;
176
+ for (const [tag, attrs] of this.elements) {
177
+ if (BASE_TAGS.has(tag) && attrs?.some((r) => matches(r.name, "class"))) return true;
178
+ }
179
+ return false;
180
+ }
181
+ /** All required attributes are present. */
182
+ hasRequired(tag, dom) {
183
+ return this.rulesFor(tag).every((rule) => !rule.required || dom.hasAttribute(rule.name));
184
+ }
185
+ /**
186
+ * The element's attributes allowed by the rule (values checked), or null. `skip` — attributes the
187
+ * element itself doesn't keep: class and style of built-in elements (validClasses, validStyles,
188
+ * formatting marks). The parser moves the own style of new elements to OWN_STYLE (see parser.ts).
189
+ */
190
+ readAttrs(tag, dom, skip) {
191
+ let out = null;
192
+ for (const attr of Array.from(dom.attributes)) {
193
+ let name = attr.name.toLowerCase();
194
+ if (name === OWN_STYLE) name = "style";
195
+ if (skip.includes(name) || !this.allows(tag, name)) continue;
196
+ const value = safeAttr(name, attr.value);
197
+ if (value !== null) (out ??= {})[name] = value;
198
+ }
199
+ return out;
200
+ }
201
+ /**
202
+ * Attributes for output: built-in ones plus kept ones (`extras`, which may have come from JSON as
203
+ * anything), then the element's list and the value rules.
204
+ */
205
+ outputAttrs(tag, builtIn, extras) {
206
+ const out = { ...builtIn };
207
+ if (extras && typeof extras === "object" && !Array.isArray(extras)) {
208
+ for (const [raw, value] of Object.entries(extras)) {
209
+ const name = raw.toLowerCase();
210
+ if (out[name] != null || !this.allows(tag, name)) continue;
211
+ if (!["string", "number", "boolean"].includes(typeof value)) continue;
212
+ const safe = safeAttr(name, String(value));
213
+ if (safe !== null) out[name] = safe;
214
+ }
215
+ }
216
+ const list = this.elements.get(tag);
217
+ if (list) {
218
+ for (const name of Object.keys(out)) {
219
+ if (this.allows(tag, name) || ESSENTIAL[tag]?.includes(name)) continue;
220
+ if (name.startsWith("data-nova-")) continue;
221
+ delete out[name];
222
+ }
223
+ }
224
+ for (const rule of this.rulesFor(tag)) {
225
+ if (rule.name.includes("*")) continue;
226
+ if (rule.forced !== void 0) out[rule.name] = rule.forced;
227
+ else if (rule.def !== void 0 && out[rule.name] == null) out[rule.name] = rule.def;
228
+ const value = out[rule.name];
229
+ if (rule.values && value != null && !rule.values.includes(String(value))) {
230
+ delete out[rule.name];
231
+ }
232
+ }
233
+ if (tag === "a" && out.target != null && out.rel == null) out.rel = "noopener noreferrer";
234
+ return out;
235
+ }
236
+ /** Apply the rules to toDOM output: attributes of the spec's top element. */
237
+ decorate(spec, extras) {
238
+ if (!Array.isArray(spec) || typeof spec[0] !== "string") return spec;
239
+ const raw = spec[0];
240
+ const tag = (raw.includes(" ") ? raw.split(" ")[1] : raw).toLowerCase();
241
+ if (!this.touches(tag)) return spec;
242
+ const second = spec[1];
243
+ const hasAttrs = !!second && typeof second === "object" && !Array.isArray(second) && second.nodeType === void 0;
244
+ const attrs = this.outputAttrs(tag, hasAttrs ? second : {}, extras);
245
+ return [raw, attrs, ...spec.slice(hasAttrs ? 2 : 1)];
246
+ }
247
+ };
248
+ function parseRule(raw) {
249
+ const m = /^([^[]*)(?:\[(.*)\])?$/s.exec(raw.trim());
250
+ const names = (m?.[1] ?? "").trim().replace(/^[-#+!]+/, "").split("/").map((n) => n.trim().toLowerCase()).filter(Boolean);
251
+ const list = m?.[2];
252
+ const attrs = list === void 0 ? null : list.split("|").map(parseAttr).filter((a) => a !== null);
253
+ return { names, attrs };
254
+ }
255
+ function createHtmlRules(options) {
256
+ if (!options.validElements && !options.extendedValidElements && !options.customElements) {
257
+ return null;
258
+ }
259
+ const rules = new HtmlRules(options);
260
+ return rules.active ? rules : null;
261
+ }
262
+ var tagOf = (selector) => (/^[a-z][a-z0-9-]*/i.exec(selector)?.[0] ?? "").toLowerCase();
263
+ function producedNames(ref, kind, name, attrs, toDOM) {
264
+ try {
265
+ const schema = ref.schema;
266
+ const spec = kind === "node" ? toDOM(schema.nodes[name].create(attrs)) : toDOM(schema.marks[name].create(attrs), true);
267
+ const second = Array.isArray(spec) ? spec[1] : null;
268
+ return second && typeof second === "object" && !Array.isArray(second) ? Object.keys(second) : [];
269
+ } catch {
270
+ return [];
271
+ }
272
+ }
273
+ function wrapBase(name, spec, kind, rules, ref) {
274
+ const tags = (spec.parseDOM ?? []).map((rule) => rule.tag ? tagOf(rule.tag) : "").filter((tag) => BASE_TAGS.has(tag) && rules.touches(tag));
275
+ if (!tags.length || !spec.toDOM) return spec;
276
+ const withExtras = tags.some((tag) => rules.extends(tag));
277
+ const toDOM = spec.toDOM;
278
+ return {
279
+ ...spec,
280
+ ...withExtras ? { attrs: { ...spec.attrs, htmlAttrs: { default: null } } } : {},
281
+ parseDOM: spec.parseDOM.map((rule) => {
282
+ const tag = rule.tag ? tagOf(rule.tag) : "";
283
+ if (!tags.includes(tag)) return rule;
284
+ const getAttrs = rule.getAttrs;
285
+ return {
286
+ ...rule,
287
+ getAttrs: (dom) => {
288
+ const base = getAttrs ? getAttrs(dom) : rule.attrs ?? null;
289
+ if (base === false || !rules.hasRequired(tag, dom)) return false;
290
+ if (!withExtras) return base;
291
+ const extras = rules.readAttrs(tag, dom, ["class", "style"]);
292
+ if (!extras) return base;
293
+ for (const produced of producedNames(ref, kind, name, { ...base }, toDOM)) {
294
+ delete extras[produced];
295
+ }
296
+ return Object.keys(extras).length ? { ...base, htmlAttrs: extras } : base;
297
+ }
298
+ };
299
+ }),
300
+ toDOM: ((value, inline) => rules.decorate(toDOM(value, inline), value.attrs.htmlAttrs))
301
+ };
302
+ }
303
+ function hasBlockChild(dom, rules) {
304
+ return Array.from(dom.children).some((child) => {
305
+ const tag = child.localName;
306
+ return BLOCK_LEVEL.has(tag) || rules.blockTags.has(tag);
307
+ });
308
+ }
309
+ function genericSpecs(rules) {
310
+ const nodes = {};
311
+ const marks = {};
312
+ const read = (output, dom, mark) => {
313
+ if (!rules.hasRequired(output, dom)) return false;
314
+ const split = SPLIT.has(output);
315
+ const skip = !split ? [] : mark && output === "span" ? ["class", "style"] : ["style"];
316
+ const htmlAttrs = rules.readAttrs(output, dom, skip);
317
+ if (split && !htmlAttrs) return false;
318
+ return { tag: output, htmlAttrs };
319
+ };
320
+ const ownStyle = (tags) => [...tags].filter(([, output]) => !SPLIT.has(output)).map(([input]) => input);
321
+ const out = (allowed, fallback, attrs) => {
322
+ const tag = typeof attrs.tag === "string" && allowed.has(attrs.tag) ? attrs.tag : fallback;
323
+ return { tag, attrs: rules.outputAttrs(tag, {}, attrs.htmlAttrs) };
324
+ };
325
+ const blocks = [...rules.blockTags];
326
+ if (blocks.length) {
327
+ const allowed = new Set(rules.blockTags.values());
328
+ const fallback = allowed.has("div") ? "div" : [...allowed][0];
329
+ const attrs = { tag: { default: fallback }, htmlAttrs: { default: null } };
330
+ nodes.html_block = {
331
+ ownStyleTags: ownStyle(rules.blockTags),
332
+ group: "block",
333
+ content: "block+",
334
+ defining: true,
335
+ attrs,
336
+ parseDOM: blocks.map(([input, output]) => ({
337
+ tag: input,
338
+ getAttrs: (dom) => hasBlockChild(dom, rules) ? read(output, dom, false) : false
339
+ })),
340
+ toDOM: (node) => {
341
+ const { tag, attrs: a } = out(allowed, fallback, node.attrs);
342
+ return [tag, a, 0];
343
+ }
344
+ };
345
+ nodes.html_textblock = {
346
+ group: "block",
347
+ content: "inline*",
348
+ attrs,
349
+ parseDOM: blocks.map(([input, output]) => ({
350
+ tag: input,
351
+ getAttrs: (dom) => hasBlockChild(dom, rules) ? false : read(output, dom, false)
352
+ })),
353
+ toDOM: (node) => {
354
+ const { tag, attrs: a } = out(allowed, fallback, node.attrs);
355
+ return [tag, a, 0];
356
+ }
357
+ };
358
+ }
359
+ const inline = [...rules.inlineTags];
360
+ if (inline.length) {
361
+ const allowed = new Set(rules.inlineTags.values());
362
+ const fallback = allowed.has("span") ? "span" : [...allowed][0];
363
+ const attrs = { tag: { default: fallback }, htmlAttrs: { default: null } };
364
+ nodes.html_inline_atom = {
365
+ ownStyleTags: ownStyle(rules.inlineTags),
366
+ group: "inline",
367
+ inline: true,
368
+ atom: true,
369
+ attrs,
370
+ parseDOM: inline.map(([input, output]) => ({
371
+ tag: input,
372
+ // Before marks of the same tag (it has 60) and built-in marks (italic for <i>).
373
+ priority: 65,
374
+ getAttrs: (dom) => dom.firstChild ? false : read(output, dom, false)
375
+ })),
376
+ toDOM: (node) => {
377
+ const { tag, attrs: a } = out(allowed, fallback, node.attrs);
378
+ return [tag, a];
379
+ }
380
+ };
381
+ marks.html_inline = {
382
+ attrs,
383
+ // Different elements (abbr inside kbd) are instances of one mark and must not push each other out.
384
+ excludes: "",
385
+ parseDOM: inline.map(([input, output]) => ({
386
+ tag: input,
387
+ // span: after class marks and plugin nodes (they parse their own spans earlier).
388
+ priority: output === "span" ? 40 : 60,
389
+ getAttrs: (dom) => dom.firstChild ? read(output, dom, true) : false
390
+ })),
391
+ toDOM: (mark) => {
392
+ const { tag, attrs: a } = out(allowed, fallback, mark.attrs);
393
+ return [tag, a, 0];
394
+ }
395
+ };
396
+ }
397
+ return { nodes, marks };
398
+ }
399
+ function applyHtmlRules(nodes, marks, rules, ref) {
400
+ const wrap = (specs, kind) => Object.fromEntries(
401
+ Object.entries(specs).map(([name, spec]) => [name, wrapBase(name, spec, kind, rules, ref)])
402
+ );
403
+ const generic = genericSpecs(rules);
404
+ return {
405
+ nodes: { ...wrap(nodes, "node"), ...generic.nodes },
406
+ marks: { ...wrap(marks, "mark"), ...generic.marks }
407
+ };
408
+ }
409
+ var htmlRules = { create: createHtmlRules };
410
+ export {
411
+ BASE_TAGS,
412
+ HtmlRules,
413
+ applyHtmlRules,
414
+ createHtmlRules,
415
+ htmlRules
416
+ };
417
+ //# sourceMappingURL=html-rules.js.map