@novaprose/core 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/README.md +15 -2
  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-6ES3UMU3.js +449 -0
  9. package/dist/a11ychecker-6ES3UMU3.js.map +1 -0
  10. package/dist/accordion-ui-B4I2FJXE.js +201 -0
  11. package/dist/accordion-ui-B4I2FJXE.js.map +1 -0
  12. package/dist/advcode-7S6N64C7.js +51 -0
  13. package/dist/advcode-7S6N64C7.js.map +1 -0
  14. package/dist/advcode-editor-ENCPFVLO.js +257 -0
  15. package/dist/advcode-editor-ENCPFVLO.js.map +1 -0
  16. package/dist/{advlist-5FNKPLUX.js → advlist-FEDGNLMQ.js} +10 -7
  17. package/dist/advlist-FEDGNLMQ.js.map +1 -0
  18. package/dist/advtable-ui-JAVJY4L4.js +364 -0
  19. package/dist/advtable-ui-JAVJY4L4.js.map +1 -0
  20. package/dist/ai-5KM776QW.js +1485 -0
  21. package/dist/ai-5KM776QW.js.map +1 -0
  22. package/dist/anchor-ui-VPKNKZ7J.js +81 -0
  23. package/dist/anchor-ui-VPKNKZ7J.js.map +1 -0
  24. package/dist/autocorrect-5QLICCRN.js +851 -0
  25. package/dist/autocorrect-5QLICCRN.js.map +1 -0
  26. package/dist/{autolink-45LTODWB.js → autolink-ZYIPRXBA.js} +11 -8
  27. package/dist/autolink-ZYIPRXBA.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-GMWJ5BPE.js → autosave-IC7YYG44.js} +7 -7
  31. package/dist/autosave-IC7YYG44.js.map +1 -0
  32. package/dist/casechange-R7IO2APS.js +201 -0
  33. package/dist/casechange-R7IO2APS.js.map +1 -0
  34. package/dist/{charmap-2GC7LF7G.js → charmap-CARYZFKD.js} +7 -7
  35. package/dist/charmap-CARYZFKD.js.map +1 -0
  36. package/dist/checklist-7E47QW6L.js +189 -0
  37. package/dist/checklist-7E47QW6L.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-ND2CWNVG.js → chunk-3BOK3S3T.js} +2 -27
  41. package/dist/chunk-3BOK3S3T.js.map +1 -0
  42. package/dist/chunk-3KBQEAX2.js +926 -0
  43. package/dist/chunk-3KBQEAX2.js.map +1 -0
  44. package/dist/chunk-3NNILZVB.js +259 -0
  45. package/dist/chunk-3NNILZVB.js.map +1 -0
  46. package/dist/{chunk-PVFKXRID.js → chunk-4VPDY3LF.js} +1 -1
  47. package/dist/chunk-4VPDY3LF.js.map +1 -0
  48. package/dist/chunk-53AY5NAF.js +214 -0
  49. package/dist/chunk-53AY5NAF.js.map +1 -0
  50. package/dist/{chunk-5AW2HHG6.js → chunk-5KERLFDD.js} +50 -3
  51. package/dist/chunk-5KERLFDD.js.map +1 -0
  52. package/dist/{chunk-FCMZ7TUQ.js → chunk-6BJEOL5V.js} +296 -43
  53. package/dist/chunk-6BJEOL5V.js.map +1 -0
  54. package/dist/chunk-6LQM7G4V.js +159 -0
  55. package/dist/chunk-6LQM7G4V.js.map +1 -0
  56. package/dist/chunk-AB67XUSR.js +178 -0
  57. package/dist/chunk-AB67XUSR.js.map +1 -0
  58. package/dist/chunk-ANE5ASXG.js +26 -0
  59. package/dist/chunk-ANE5ASXG.js.map +1 -0
  60. package/dist/{chunk-Z3ELZ77W.js → chunk-AP2PJFLB.js} +5 -2
  61. package/dist/chunk-AP2PJFLB.js.map +1 -0
  62. package/dist/chunk-ARBKIZZU.js +137 -0
  63. package/dist/chunk-ARBKIZZU.js.map +1 -0
  64. package/dist/chunk-AUQSATWL.js +322 -0
  65. package/dist/chunk-AUQSATWL.js.map +1 -0
  66. package/dist/chunk-BMCH63QN.js +165 -0
  67. package/dist/chunk-BMCH63QN.js.map +1 -0
  68. package/dist/chunk-BUABAYZL.js +160 -0
  69. package/dist/chunk-BUABAYZL.js.map +1 -0
  70. package/dist/chunk-DCMPJ25E.js +140 -0
  71. package/dist/chunk-DCMPJ25E.js.map +1 -0
  72. package/dist/chunk-DV7TGRU6.js +47 -0
  73. package/dist/chunk-DV7TGRU6.js.map +1 -0
  74. package/dist/chunk-F2WT77ZG.js +163 -0
  75. package/dist/chunk-F2WT77ZG.js.map +1 -0
  76. package/dist/chunk-FNJ7AEJK.js +955 -0
  77. package/dist/chunk-FNJ7AEJK.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-GTLE2HEW.js +108 -0
  81. package/dist/chunk-GTLE2HEW.js.map +1 -0
  82. package/dist/chunk-GUZCRDK6.js +143 -0
  83. package/dist/chunk-GUZCRDK6.js.map +1 -0
  84. package/dist/chunk-HNEAVVBC.js +98 -0
  85. package/dist/chunk-HNEAVVBC.js.map +1 -0
  86. package/dist/chunk-HSVNJGK3.js +1149 -0
  87. package/dist/chunk-HSVNJGK3.js.map +1 -0
  88. package/dist/chunk-IFSD6O5M.js +29 -0
  89. package/dist/chunk-IFSD6O5M.js.map +1 -0
  90. package/dist/{table-SSNABG5W.js → chunk-IO5PU52K.js} +119 -61
  91. package/dist/chunk-IO5PU52K.js.map +1 -0
  92. package/dist/chunk-K4LFGNS7.js +137 -0
  93. package/dist/chunk-K4LFGNS7.js.map +1 -0
  94. package/dist/chunk-KGEHUWGL.js +79 -0
  95. package/dist/chunk-KGEHUWGL.js.map +1 -0
  96. package/dist/chunk-KW6ATQPN.js +151 -0
  97. package/dist/chunk-KW6ATQPN.js.map +1 -0
  98. package/dist/chunk-NX3KWIP5.js +207 -0
  99. package/dist/chunk-NX3KWIP5.js.map +1 -0
  100. package/dist/chunk-OOVNE6MB.js +28 -0
  101. package/dist/chunk-OOVNE6MB.js.map +1 -0
  102. package/dist/chunk-OQMMHWMZ.js +7 -0
  103. package/dist/chunk-OQMMHWMZ.js.map +1 -0
  104. package/dist/{chunk-JPJVTB45.js → chunk-QU3KXMYT.js} +8 -2
  105. package/dist/chunk-QU3KXMYT.js.map +1 -0
  106. package/dist/chunk-QWT56RVG.js +158 -0
  107. package/dist/chunk-QWT56RVG.js.map +1 -0
  108. package/dist/chunk-RJ7T56OH.js +3787 -0
  109. package/dist/chunk-RJ7T56OH.js.map +1 -0
  110. package/dist/{chunk-KWXFL4WS.js → chunk-RPHA4HRX.js} +8 -5
  111. package/dist/chunk-RPHA4HRX.js.map +1 -0
  112. package/dist/chunk-S4DCQA74.js +66 -0
  113. package/dist/chunk-S4DCQA74.js.map +1 -0
  114. package/dist/chunk-SCIRO4XK.js +144 -0
  115. package/dist/chunk-SCIRO4XK.js.map +1 -0
  116. package/dist/chunk-SNVYHGGO.js +127 -0
  117. package/dist/chunk-SNVYHGGO.js.map +1 -0
  118. package/dist/chunk-T4543CB2.js +67 -0
  119. package/dist/chunk-T4543CB2.js.map +1 -0
  120. package/dist/{chunk-T3GY6IVK.js → chunk-UHUOAQA6.js} +71 -9
  121. package/dist/chunk-UHUOAQA6.js.map +1 -0
  122. package/dist/chunk-UTMS2P2K.js +288 -0
  123. package/dist/chunk-UTMS2P2K.js.map +1 -0
  124. package/dist/{chunk-HPLT3XRZ.js → chunk-V7WUHUHM.js} +13 -1
  125. package/dist/chunk-V7WUHUHM.js.map +1 -0
  126. package/dist/chunk-WAOU5NGN.js +430 -0
  127. package/dist/chunk-WAOU5NGN.js.map +1 -0
  128. package/dist/{chunk-R2UMUCVI.js → chunk-XCXJD5DO.js} +53 -8
  129. package/dist/chunk-XCXJD5DO.js.map +1 -0
  130. package/dist/chunk-XIH4SCO6.js +112 -0
  131. package/dist/chunk-XIH4SCO6.js.map +1 -0
  132. package/dist/chunk-XR7CY4NI.js +11 -0
  133. package/dist/chunk-XR7CY4NI.js.map +1 -0
  134. package/dist/chunk-Y2OXWCM7.js +263 -0
  135. package/dist/chunk-Y2OXWCM7.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-YOTA26H7.js +373 -0
  139. package/dist/chunk-YOTA26H7.js.map +1 -0
  140. package/dist/chunk-YP7N47QR.js +101 -0
  141. package/dist/chunk-YP7N47QR.js.map +1 -0
  142. package/dist/{chunk-KPE3QRPB.js → chunk-YYCDRUE2.js} +16 -315
  143. package/dist/chunk-YYCDRUE2.js.map +1 -0
  144. package/dist/codesample-FOWXMCTC.js +546 -0
  145. package/dist/codesample-FOWXMCTC.js.map +1 -0
  146. package/dist/{comments-panel-HXMWSRAW.js → comments-panel-SOLBZ46Q.js} +9 -5
  147. package/dist/comments-panel-SOLBZ46Q.js.map +1 -0
  148. package/dist/{directionality-5JLWQGP2.js → directionality-BXWXNPRZ.js} +13 -10
  149. package/dist/directionality-BXWXNPRZ.js.map +1 -0
  150. package/dist/document-B0hLRhuH.d.cts +39 -0
  151. package/dist/document-Dh-jz1SK.d.ts +39 -0
  152. package/dist/docx.cjs +23575 -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 +1826 -0
  157. package/dist/docx.js.map +1 -0
  158. package/dist/draghandle-3IBHVHDE.js +389 -0
  159. package/dist/draghandle-3IBHVHDE.js.map +1 -0
  160. package/dist/editimage-GTLFGHYU.js +683 -0
  161. package/dist/editimage-GTLFGHYU.js.map +1 -0
  162. package/dist/editor-DnAN9aPd.d.ts +2948 -0
  163. package/dist/editor-S8w_w5W0.d.cts +2948 -0
  164. package/dist/email-FDSENENR.js +177 -0
  165. package/dist/email-FDSENENR.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-ZD6ZRIWG.js → emoticons-SHYSAEID.js} +7 -7
  173. package/dist/emoticons-SHYSAEID.js.map +1 -0
  174. package/dist/exportpdf-TEBDQZSN.js +91 -0
  175. package/dist/exportpdf-TEBDQZSN.js.map +1 -0
  176. package/dist/exportword-BGH2CZXO.js +16 -0
  177. package/dist/exportword-BGH2CZXO.js.map +1 -0
  178. package/dist/footnotes-ui-KPKFDSN7.js +449 -0
  179. package/dist/footnotes-ui-KPKFDSN7.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-CB4ZTKR5.js +209 -0
  183. package/dist/formatpainter-CB4ZTKR5.js.map +1 -0
  184. package/dist/fullpagehtml-ui-JPGRMXHD.js +220 -0
  185. package/dist/fullpagehtml-ui-JPGRMXHD.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 +21 -19
  189. package/dist/html-rules.cjs.map +1 -1
  190. package/dist/html-rules.d.cts +37 -35
  191. package/dist/html-rules.d.ts +37 -35
  192. package/dist/html-rules.js +26 -22
  193. package/dist/html-rules.js.map +1 -1
  194. package/dist/i18n/de.cjs +349 -0
  195. package/dist/i18n/de.cjs.map +1 -1
  196. package/dist/i18n/de.d.cts +1 -1
  197. package/dist/i18n/de.d.ts +1 -1
  198. package/dist/i18n/de.js +349 -0
  199. package/dist/i18n/de.js.map +1 -1
  200. package/dist/i18n/es.cjs +349 -0
  201. package/dist/i18n/es.cjs.map +1 -1
  202. package/dist/i18n/es.d.cts +1 -1
  203. package/dist/i18n/es.d.ts +1 -1
  204. package/dist/i18n/es.js +349 -0
  205. package/dist/i18n/es.js.map +1 -1
  206. package/dist/i18n/fr.cjs +349 -0
  207. package/dist/i18n/fr.cjs.map +1 -1
  208. package/dist/i18n/fr.d.cts +1 -1
  209. package/dist/i18n/fr.d.ts +1 -1
  210. package/dist/i18n/fr.js +349 -0
  211. package/dist/i18n/fr.js.map +1 -1
  212. package/dist/i18n/it.cjs +349 -0
  213. package/dist/i18n/it.cjs.map +1 -1
  214. package/dist/i18n/it.d.cts +1 -1
  215. package/dist/i18n/it.d.ts +1 -1
  216. package/dist/i18n/it.js +349 -0
  217. package/dist/i18n/it.js.map +1 -1
  218. package/dist/i18n/pt-BR.cjs +349 -0
  219. package/dist/i18n/pt-BR.cjs.map +1 -1
  220. package/dist/i18n/pt-BR.d.cts +1 -1
  221. package/dist/i18n/pt-BR.d.ts +1 -1
  222. package/dist/i18n/pt-BR.js +349 -0
  223. package/dist/i18n/pt-BR.js.map +1 -1
  224. package/dist/i18n/ru.cjs +349 -0
  225. package/dist/i18n/ru.cjs.map +1 -1
  226. package/dist/i18n/ru.d.cts +3 -3
  227. package/dist/i18n/ru.d.ts +3 -3
  228. package/dist/i18n/ru.js +349 -0
  229. package/dist/i18n/ru.js.map +1 -1
  230. package/dist/importcss-JLNIRKGH.js +127 -0
  231. package/dist/importcss-JLNIRKGH.js.map +1 -0
  232. package/dist/importword-ZOWLUWSN.js +73 -0
  233. package/dist/importword-ZOWLUWSN.js.map +1 -0
  234. package/dist/{index-C603bU6r.d.ts → index-Pb2r0V-S.d.cts} +39 -17
  235. package/dist/{index-C603bU6r.d.cts → index-Pb2r0V-S.d.ts} +39 -17
  236. package/dist/index.cjs +29422 -10640
  237. package/dist/index.cjs.map +1 -1
  238. package/dist/index.d.cts +139 -64
  239. package/dist/index.d.ts +139 -64
  240. package/dist/index.js +204 -1412
  241. package/dist/index.js.map +1 -1
  242. package/dist/{insertdatetime-CRO7TJAQ.js → insertdatetime-BXQ3XXPH.js} +7 -7
  243. package/dist/insertdatetime-BXQ3XXPH.js.map +1 -0
  244. package/dist/linkchecker-JASSETVI.js +287 -0
  245. package/dist/linkchecker-JASSETVI.js.map +1 -0
  246. package/dist/markdown-OTLTCK26.js +136 -0
  247. package/dist/markdown-OTLTCK26.js.map +1 -0
  248. package/dist/markdown.cjs +94 -11
  249. package/dist/markdown.cjs.map +1 -1
  250. package/dist/markdown.d.cts +12 -10
  251. package/dist/markdown.d.ts +12 -10
  252. package/dist/markdown.js +4 -235
  253. package/dist/markdown.js.map +1 -1
  254. package/dist/math-ui-TY4VZF7Q.js +157 -0
  255. package/dist/math-ui-TY4VZF7Q.js.map +1 -0
  256. package/dist/media-ui-IXN4ENVF.js +123 -0
  257. package/dist/media-ui-IXN4ENVF.js.map +1 -0
  258. package/dist/mediaembed-ui-ODX5ECXC.js +207 -0
  259. package/dist/mediaembed-ui-ODX5ECXC.js.map +1 -0
  260. package/dist/mentions-ui-55GCKC6F.js +58 -0
  261. package/dist/mentions-ui-55GCKC6F.js.map +1 -0
  262. package/dist/mergetags-ui-6T7Z7MAZ.js +73 -0
  263. package/dist/mergetags-ui-6T7Z7MAZ.js.map +1 -0
  264. package/dist/{nonbreaking-66LFZV2W.js → nonbreaking-PONHSOMJ.js} +7 -7
  265. package/dist/nonbreaking-PONHSOMJ.js.map +1 -0
  266. package/dist/pagebreak-ui-AKAW7M5I.js +50 -0
  267. package/dist/pagebreak-ui-AKAW7M5I.js.map +1 -0
  268. package/dist/pageembed-ui-GUNPKMBR.js +172 -0
  269. package/dist/pageembed-ui-GUNPKMBR.js.map +1 -0
  270. package/dist/pagelayout-ui-JSFVEMHS.js +236 -0
  271. package/dist/pagelayout-ui-JSFVEMHS.js.map +1 -0
  272. package/dist/{paste-office-F3QW4WWO.js → paste-office-TORLAZ5L.js} +94 -4
  273. package/dist/paste-office-TORLAZ5L.js.map +1 -0
  274. package/dist/permanentpen-EACURV5U.js +206 -0
  275. package/dist/permanentpen-EACURV5U.js.map +1 -0
  276. package/dist/print-4XJCOANX.js +178 -0
  277. package/dist/print-4XJCOANX.js.map +1 -0
  278. package/dist/{quickbars-7E2QRS7J.js → quickbars-BT5PETRX.js} +20 -12
  279. package/dist/quickbars-BT5PETRX.js.map +1 -0
  280. package/dist/{revisionhistory-DXE7KU4R.js → revisionhistory-3FKLMJHJ.js} +42 -153
  281. package/dist/revisionhistory-3FKLMJHJ.js.map +1 -0
  282. package/dist/save-ZHFXH222.js +120 -0
  283. package/dist/save-ZHFXH222.js.map +1 -0
  284. package/dist/search-bar-6MVRMTK6.js +212 -0
  285. package/dist/search-bar-6MVRMTK6.js.map +1 -0
  286. package/dist/spellchecker-JJKA6B4R.js +474 -0
  287. package/dist/spellchecker-JJKA6B4R.js.map +1 -0
  288. package/dist/suggestions-panel-X37NFLXE.js +596 -0
  289. package/dist/suggestions-panel-X37NFLXE.js.map +1 -0
  290. package/dist/suggestions-ui-WN7QNYHB.js +395 -0
  291. package/dist/suggestions-ui-WN7QNYHB.js.map +1 -0
  292. package/dist/table-PEF56QG5.js +54 -0
  293. package/dist/table-PEF56QG5.js.map +1 -0
  294. package/dist/table-dialogs-QS3VFZD2.js +119 -0
  295. package/dist/table-dialogs-QS3VFZD2.js.map +1 -0
  296. package/dist/tableofcontents-ui-U7EV3UU7.js +167 -0
  297. package/dist/tableofcontents-ui-U7EV3UU7.js.map +1 -0
  298. package/dist/template-ZRTKIP2J.js +278 -0
  299. package/dist/template-ZRTKIP2J.js.map +1 -0
  300. package/dist/typography-S7RO54DB.js +399 -0
  301. package/dist/typography-S7RO54DB.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-6DLBXYOA.js → visualblocks-KJYRHF2L.js} +7 -7
  309. package/dist/visualblocks-KJYRHF2L.js.map +1 -0
  310. package/dist/visualchars-TDLZKFXD.js +134 -0
  311. package/dist/visualchars-TDLZKFXD.js.map +1 -0
  312. package/package.json +53 -3
  313. package/src/style.css +376 -550
  314. package/dist/advlist-5FNKPLUX.js.map +0 -1
  315. package/dist/autolink-45LTODWB.js.map +0 -1
  316. package/dist/autoresize-UB3GOA6D.js.map +0 -1
  317. package/dist/autosave-GMWJ5BPE.js.map +0 -1
  318. package/dist/charmap-2GC7LF7G.js.map +0 -1
  319. package/dist/chunk-5AW2HHG6.js.map +0 -1
  320. package/dist/chunk-DWZLSZDG.js +0 -5664
  321. package/dist/chunk-DWZLSZDG.js.map +0 -1
  322. package/dist/chunk-FCMZ7TUQ.js.map +0 -1
  323. package/dist/chunk-HPLT3XRZ.js.map +0 -1
  324. package/dist/chunk-JPJVTB45.js.map +0 -1
  325. package/dist/chunk-KPE3QRPB.js.map +0 -1
  326. package/dist/chunk-KWXFL4WS.js.map +0 -1
  327. package/dist/chunk-ND2CWNVG.js.map +0 -1
  328. package/dist/chunk-PVFKXRID.js.map +0 -1
  329. package/dist/chunk-R2UMUCVI.js.map +0 -1
  330. package/dist/chunk-T3GY6IVK.js.map +0 -1
  331. package/dist/chunk-Z3ELZ77W.js.map +0 -1
  332. package/dist/comments-panel-HXMWSRAW.js.map +0 -1
  333. package/dist/directionality-5JLWQGP2.js.map +0 -1
  334. package/dist/editor-CXkltf1R.d.ts +0 -1886
  335. package/dist/editor-CgSBFTke.d.cts +0 -1886
  336. package/dist/emoticons-ZD6ZRIWG.js.map +0 -1
  337. package/dist/form-dialog-QH6KAERD.js +0 -180
  338. package/dist/form-dialog-QH6KAERD.js.map +0 -1
  339. package/dist/html-rules-api-D3fKQi-R.d.cts +0 -40
  340. package/dist/html-rules-api-D3fKQi-R.d.ts +0 -40
  341. package/dist/insertdatetime-CRO7TJAQ.js.map +0 -1
  342. package/dist/nonbreaking-66LFZV2W.js.map +0 -1
  343. package/dist/paste-office-F3QW4WWO.js.map +0 -1
  344. package/dist/quickbars-7E2QRS7J.js.map +0 -1
  345. package/dist/revisionhistory-DXE7KU4R.js.map +0 -1
  346. package/dist/table-SSNABG5W.js.map +0 -1
  347. package/dist/visualblocks-6DLBXYOA.js.map +0 -1
@@ -1,15 +1,19 @@
1
+ import {
2
+ moveBlock
3
+ } from "./chunk-HNEAVVBC.js";
1
4
  import {
2
5
  indentLevel
3
- } from "./chunk-FCMZ7TUQ.js";
6
+ } from "./chunk-6BJEOL5V.js";
4
7
  import {
5
8
  isSafeImageUrl,
6
9
  isSafeLinkUrl
7
- } from "./chunk-PVFKXRID.js";
10
+ } from "./chunk-4VPDY3LF.js";
8
11
 
9
12
  // src/commands.ts
10
13
  import { lift, setBlockType, toggleMark, wrapIn } from "prosemirror-commands";
11
14
  import { redo, undo } from "prosemirror-history";
12
15
  import { liftListItem, sinkListItem, wrapInList } from "prosemirror-schema-list";
16
+ import { Selection } from "prosemirror-state";
13
17
  var nodesOf = (state) => state.schema.nodes;
14
18
  var marksOf = (state) => state.schema.marks;
15
19
  var withNode = (name, make) => (state, dispatch, view) => make(nodesOf(state)[name])(state, dispatch, view);
@@ -31,9 +35,26 @@ function setAlign(align) {
31
35
  return true;
32
36
  };
33
37
  }
38
+ function replaceSelectionWithBlock(tr, node) {
39
+ const { $from } = tr.selection;
40
+ if (node.isBlock) {
41
+ for (let depth = $from.depth - 1; depth > 0; depth--) {
42
+ const container = $from.node(depth);
43
+ if (!container.type.spec.isolating) continue;
44
+ let fits = false;
45
+ for (let i = 0; i <= container.childCount && !fits; i++)
46
+ fits = container.canReplaceWith(i, i, node.type);
47
+ if (fits) break;
48
+ const after = $from.after(depth);
49
+ tr.insert(after, node);
50
+ return tr.setSelection(Selection.near(tr.doc.resolve(after + node.nodeSize)));
51
+ }
52
+ }
53
+ return tr.replaceSelectionWith(node);
54
+ }
34
55
  var insertHorizontalRule = (state, dispatch) => {
35
56
  dispatch?.(
36
- state.tr.replaceSelectionWith(nodesOf(state).horizontal_rule.create()).scrollIntoView()
57
+ replaceSelectionWithBlock(state.tr, nodesOf(state).horizontal_rule.create()).scrollIntoView()
37
58
  );
38
59
  return true;
39
60
  };
@@ -102,7 +123,9 @@ function setBlockKeepAlign(type, attrs = {}) {
102
123
  ..."align" in type.spec.attrs && old.attrs.align ? { align: old.attrs.align } : {},
103
124
  ..."lineHeight" in type.spec.attrs && old.attrs.lineHeight ? { lineHeight: old.attrs.lineHeight } : {},
104
125
  ..."dir" in type.spec.attrs && old.attrs.dir ? { dir: old.attrs.dir } : {},
105
- ..."indent" in type.spec.attrs && old.attrs.indent ? { indent: old.attrs.indent } : {}
126
+ ..."indent" in type.spec.attrs && old.attrs.indent ? { indent: old.attrs.indent } : {},
127
+ // Changing the heading level doesn't break links to the section.
128
+ ..."id" in type.spec.attrs && old.attrs.id ? { id: old.attrs.id } : {}
106
129
  }));
107
130
  }
108
131
  dispatch(tr.scrollIntoView());
@@ -142,12 +165,48 @@ var commands = {
142
165
  unlink,
143
166
  clearFormatting,
144
167
  undo,
145
- redo
168
+ redo,
169
+ moveBlockUp: moveBlock(-1),
170
+ moveBlockDown: moveBlock(1)
146
171
  };
172
+ function findParentList(state) {
173
+ const nodes = nodesOf(state);
174
+ const { $from } = state.selection;
175
+ for (let depth = $from.depth; depth > 0; depth--) {
176
+ const node = $from.node(depth);
177
+ if (node.type === nodes.bullet_list || node.type === nodes.ordered_list) {
178
+ return { node, pos: $from.before(depth) };
179
+ }
180
+ }
181
+ return null;
182
+ }
183
+ function convertList(tr, list, type, checklist = false) {
184
+ const nodes = tr.doc.type.schema.nodes;
185
+ const isChecklist = type === nodes.bullet_list && checklist;
186
+ tr.setNodeMarkup(
187
+ list.pos,
188
+ type,
189
+ type === nodes.bullet_list ? { listStyle: null, checklist: isChecklist } : { start: 1 }
190
+ );
191
+ list.node.forEach((item, offset) => {
192
+ const previous = item.attrs.checked;
193
+ const checked = isChecklist ? typeof previous === "boolean" ? previous : false : null;
194
+ if (checked !== previous) {
195
+ tr.setNodeMarkup(list.pos + 1 + offset, void 0, { ...item.attrs, checked });
196
+ }
197
+ });
198
+ return tr;
199
+ }
147
200
  function toggleList(listType) {
148
201
  return (state, dispatch) => {
149
- if (isNodeActive(state, listType))
150
- return liftListItem(nodesOf(state).list_item)(state, dispatch);
202
+ const nodes = nodesOf(state);
203
+ const plain = listType === nodes.bullet_list ? { checklist: false } : void 0;
204
+ if (isNodeActive(state, listType, plain)) return liftListItem(nodes.list_item)(state, dispatch);
205
+ const list = findParentList(state);
206
+ if (list) {
207
+ if (dispatch) dispatch(convertList(state.tr, list, listType).scrollIntoView());
208
+ return true;
209
+ }
151
210
  return wrapInList(listType)(state, dispatch);
152
211
  };
153
212
  }
@@ -231,7 +290,7 @@ function isCommandActive(state, command) {
231
290
  case "blockquote":
232
291
  return isNodeActive(state, nodes.blockquote);
233
292
  case "bulletList":
234
- return isNodeActive(state, nodes.bullet_list);
293
+ return isNodeActive(state, nodes.bullet_list, { checklist: false });
235
294
  case "orderedList":
236
295
  return isNodeActive(state, nodes.ordered_list);
237
296
  case "alignLeft":
@@ -270,9 +329,12 @@ function markRange(state, type, pos) {
270
329
  export {
271
330
  nodesOf,
272
331
  marksOf,
332
+ replaceSelectionWithBlock,
273
333
  listIndent,
274
334
  listOutdent,
275
335
  commands,
336
+ findParentList,
337
+ convertList,
276
338
  setLink,
277
339
  insertImage,
278
340
  isMarkActive,
@@ -282,4 +344,4 @@ export {
282
344
  getLinkAt,
283
345
  markRange
284
346
  };
285
- //# sourceMappingURL=chunk-T3GY6IVK.js.map
347
+ //# sourceMappingURL=chunk-UHUOAQA6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands.ts"],"sourcesContent":["import { lift, setBlockType, toggleMark, wrapIn } from 'prosemirror-commands';\nimport { redo, undo } from 'prosemirror-history';\nimport type { MarkType, Node as PMNode, NodeType } from 'prosemirror-model';\nimport { liftListItem, sinkListItem, wrapInList } from 'prosemirror-schema-list';\nimport { Selection, type Command, type EditorState, type Transaction } from 'prosemirror-state';\nimport {\n indentLevel,\n type MarkName,\n type NodeName,\n type NovaSchema,\n type TextAlign,\n} from './schema';\nimport { isSafeImageUrl, isSafeLinkUrl } from './url';\nimport { moveBlock } from './blocks';\n\n/** The editor's named commands. The names are part of the public API (see Editor.exec). */\nexport type CommandName =\n | 'bold'\n | 'italic'\n | 'underline'\n | 'strike'\n | 'code'\n | 'subscript'\n | 'superscript'\n | 'paragraph'\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n | 'blockquote'\n | 'codeBlock'\n | 'bulletList'\n | 'orderedList'\n | 'indent'\n | 'outdent'\n | 'alignLeft'\n | 'alignCenter'\n | 'alignRight'\n | 'alignJustify'\n | 'horizontalRule'\n | 'unlink'\n | 'clearFormatting'\n | 'undo'\n | 'redo'\n | 'moveBlockUp'\n | 'moveBlockDown';\n\n/**\n * Node and mark types come from the schema of the specific editor (state.schema): editors with\n * plugins have their own, and comparing with the shared base schema's types would give false.\n */\nexport const nodesOf = (state: EditorState) => (state.schema as NovaSchema).nodes;\nexport const marksOf = (state: EditorState) => (state.schema as NovaSchema).marks;\n\n/** A command parameterized by a node type taken from the state's schema. */\nconst withNode =\n (name: NodeName, make: (type: NodeType) => Command): Command =>\n (state, dispatch, view) =>\n make(nodesOf(state)[name])(state, dispatch, view);\n\nconst withMark =\n (name: MarkName, make: (type: MarkType) => Command): Command =>\n (state, dispatch, view) =>\n make(marksOf(state)[name])(state, dispatch, view);\n\nfunction setAlign(align: TextAlign | null): Command {\n return (state, dispatch) => {\n const { from, to } = state.selection;\n let tr = state.tr;\n let applicable = false;\n state.doc.nodesBetween(from, to, (node, pos) => {\n const nodes = nodesOf(state);\n if (node.type === nodes.paragraph || node.type === nodes.heading) {\n applicable = true;\n tr = tr.setNodeMarkup(pos, undefined, { ...node.attrs, align });\n }\n });\n if (!applicable) return false;\n dispatch?.(tr);\n return true;\n };\n}\n\n/**\n * A node in place of the selection, as replaceSelectionWith puts it, except that a block never cuts\n * through a node that can't hold it: in an image's caption the block goes after the image (split,\n * the image would become two, one of them without a picture).\n */\nexport function replaceSelectionWithBlock(tr: Transaction, node: PMNode): Transaction {\n const { $from } = tr.selection;\n if (node.isBlock) {\n for (let depth = $from.depth - 1; depth > 0; depth--) {\n const container = $from.node(depth);\n if (!container.type.spec.isolating) continue;\n let fits = false;\n for (let i = 0; i <= container.childCount && !fits; i++)\n fits = container.canReplaceWith(i, i, node.type);\n // A table cell holds blocks: the usual way.\n if (fits) break;\n const after = $from.after(depth);\n tr.insert(after, node);\n return tr.setSelection(Selection.near(tr.doc.resolve(after + node.nodeSize)));\n }\n }\n return tr.replaceSelectionWith(node);\n}\n\nconst insertHorizontalRule: Command = (state, dispatch) => {\n dispatch?.(\n replaceSelectionWithBlock(state.tr, nodesOf(state).horizontal_rule.create()).scrollIntoView(),\n );\n return true;\n};\n\nconst unlink: Command = (state, dispatch) => {\n const { from, to, empty, $from } = state.selection;\n const marks = marksOf(state);\n if (empty) {\n // The cursor is inside a link: remove the whole link.\n const range = markRange(state, marks.link, $from.pos);\n if (!range) return false;\n dispatch?.(state.tr.removeMark(range.from, range.to, marks.link));\n return true;\n }\n if (!state.doc.rangeHasMark(from, to, marks.link)) return false;\n dispatch?.(state.tr.removeMark(from, to, marks.link));\n return true;\n};\n\nconst clearFormatting: Command = (state, dispatch) => {\n const { from, to, empty } = state.selection;\n if (empty) return false;\n if (dispatch) {\n const marks = marksOf(state);\n let tr = state.tr;\n for (const mark of Object.values(marks)) {\n if (mark !== marks.link) tr = tr.removeMark(from, to, mark);\n }\n dispatch(tr);\n }\n return true;\n};\n\n/**\n * Like setBlockType from prosemirror-commands, but keeps the block's alignment\n * (a centered paragraph → a centered heading), as in Word and Google Docs.\n */\n/**\n * Indents paragraphs and headings in the selection (not in lists: there it is the list level). delta: +1 / -1.\n * Returns false when there is nothing to change (so the \"decrease indent\" button goes dim at level zero).\n */\nfunction changeIndent(delta: number): Command {\n return (state, dispatch) => {\n const nodes = nodesOf(state);\n const changes: { pos: number; attrs: Record<string, unknown> }[] = [];\n const { from, to } = state.selection;\n state.doc.nodesBetween(from, to, (node, pos, parent) => {\n if (node.type !== nodes.paragraph && node.type !== nodes.heading) return true;\n if (parent?.type !== nodes.list_item) {\n const current = indentLevel(node.attrs.indent);\n const next = indentLevel(current + delta);\n if (next !== current) changes.push({ pos, attrs: { ...node.attrs, indent: next } });\n }\n return false;\n });\n if (!changes.length) return false;\n if (dispatch) {\n const tr = state.tr;\n for (const { pos, attrs } of changes) tr.setNodeMarkup(pos, undefined, attrs);\n dispatch(tr.scrollIntoView());\n }\n return true;\n };\n}\n\n/** Indent: in a list, the item's nesting; otherwise the paragraph indent. */\nconst indentCommand: Command = (state, dispatch, view) =>\n sinkListItem(nodesOf(state).list_item)(state, dispatch, view) ||\n changeIndent(1)(state, dispatch, view);\n\nconst outdentCommand: Command = (state, dispatch, view) =>\n liftListItem(nodesOf(state).list_item)(state, dispatch, view) ||\n changeIndent(-1)(state, dispatch, view);\n\n/** Tab / Shift+Tab: lists only; in a paragraph Tab still moves the focus (no keyboard trap, WCAG 2.1.2). */\nexport const listIndent: Command = (state, dispatch, view) =>\n sinkListItem(nodesOf(state).list_item)(state, dispatch, view);\nexport const listOutdent: Command = (state, dispatch, view) =>\n liftListItem(nodesOf(state).list_item)(state, dispatch, view);\n\nfunction setBlockKeepAlign(type: NodeType, attrs: Record<string, unknown> = {}): Command {\n const base = setBlockType(type, attrs);\n return (state, dispatch) => {\n if (!base(state)) return false;\n if (dispatch) {\n const tr = state.tr;\n for (const range of state.selection.ranges) {\n tr.setBlockType(range.$from.pos, range.$to.pos, type, (old) => ({\n ...attrs,\n ...('align' in type.spec.attrs! && old.attrs.align ? { align: old.attrs.align } : {}),\n ...('lineHeight' in type.spec.attrs! && old.attrs.lineHeight\n ? { lineHeight: old.attrs.lineHeight }\n : {}),\n ...('dir' in type.spec.attrs! && old.attrs.dir ? { dir: old.attrs.dir } : {}),\n ...('indent' in type.spec.attrs! && old.attrs.indent ? { indent: old.attrs.indent } : {}),\n // Changing the heading level doesn't break links to the section.\n ...('id' in type.spec.attrs! && old.attrs.id ? { id: old.attrs.id } : {}),\n }));\n }\n dispatch(tr.scrollIntoView());\n }\n return true;\n };\n}\n\nfunction heading(level: number): Command {\n return withNode('heading', (type) => setBlockKeepAlign(type, { level }));\n}\n\nexport const commands: Record<CommandName, Command> = {\n bold: withMark('bold', toggleMark),\n italic: withMark('italic', toggleMark),\n underline: withMark('underline', toggleMark),\n strike: withMark('strike', toggleMark),\n code: withMark('code', toggleMark),\n subscript: withMark('subscript', toggleMark),\n superscript: withMark('superscript', toggleMark),\n paragraph: withNode('paragraph', (type) => setBlockKeepAlign(type)),\n h1: heading(1),\n h2: heading(2),\n h3: heading(3),\n h4: heading(4),\n h5: heading(5),\n h6: heading(6),\n blockquote: (state, dispatch) =>\n isNodeActive(state, nodesOf(state).blockquote)\n ? lift(state, dispatch)\n : wrapIn(nodesOf(state).blockquote)(state, dispatch),\n codeBlock: withNode('code_block', (type) => setBlockType(type)),\n bulletList: withNode('bullet_list', toggleList),\n orderedList: withNode('ordered_list', toggleList),\n indent: indentCommand,\n outdent: outdentCommand,\n alignLeft: setAlign(null),\n alignCenter: setAlign('center'),\n alignRight: setAlign('right'),\n alignJustify: setAlign('justify'),\n horizontalRule: insertHorizontalRule,\n unlink,\n clearFormatting,\n undo,\n redo,\n moveBlockUp: moveBlock(-1),\n moveBlockDown: moveBlock(1),\n};\n\n/** The nearest list around the cursor (bulleted, numbered, checklist) and its position. */\nexport function findParentList(state: EditorState): { node: PMNode; pos: number } | null {\n const nodes = nodesOf(state);\n const { $from } = state.selection;\n for (let depth = $from.depth; depth > 0; depth--) {\n const node = $from.node(depth);\n if (node.type === nodes.bullet_list || node.type === nodes.ordered_list) {\n return { node, pos: $from.before(depth) };\n }\n }\n return null;\n}\n\n/**\n * Changes the kind of a list in place: bulleted ↔ numbered ↔ checklist. Items get checked according\n * to the list kind (a checklist keeps true/false and the existing checks; otherwise null).\n */\nexport function convertList(\n tr: Transaction,\n list: { node: PMNode; pos: number },\n type: NodeType,\n checklist = false,\n): Transaction {\n const nodes = (tr.doc.type.schema as NovaSchema).nodes;\n const isChecklist = type === nodes.bullet_list && checklist;\n tr.setNodeMarkup(\n list.pos,\n type,\n type === nodes.bullet_list ? { listStyle: null, checklist: isChecklist } : { start: 1 },\n );\n list.node.forEach((item, offset) => {\n const previous = item.attrs.checked;\n const checked = isChecklist ? (typeof previous === 'boolean' ? previous : false) : null;\n if (checked !== previous) {\n tr.setNodeMarkup(list.pos + 1 + offset, undefined, { ...item.attrs, checked });\n }\n });\n return tr;\n}\n\nfunction toggleList(listType: NodeType): Command {\n return (state, dispatch) => {\n const nodes = nodesOf(state);\n // The same kind of list removes the list. A checklist isn't \"bulleted\": the bullet button doesn't remove it.\n const plain = listType === nodes.bullet_list ? { checklist: false } : undefined;\n if (isNodeActive(state, listType, plain)) return liftListItem(nodes.list_item)(state, dispatch);\n // Inside a different kind of list: change the kind (instead of nesting a new list).\n const list = findParentList(state);\n if (list) {\n if (dispatch) dispatch(convertList(state.tr, list, listType).scrollIntoView());\n return true;\n }\n return wrapInList(listType)(state, dispatch);\n };\n}\n\n/** Insert or update a link on the selection. */\nexport function setLink(href: string, attrs: { title?: string; target?: string } = {}): Command {\n return (state, dispatch) => {\n if (!isSafeLinkUrl(href)) return false;\n const { from, to, empty, $from } = state.selection;\n const marks = marksOf(state);\n const mark = marks.link.create({\n href,\n title: attrs.title ?? null,\n target: attrs.target ?? null,\n });\n if (empty) {\n const range = markRange(state, marks.link, $from.pos);\n if (range) {\n dispatch?.(\n state.tr.removeMark(range.from, range.to, marks.link).addMark(range.from, range.to, mark),\n );\n return true;\n }\n // An empty selection without a link: insert the address itself as the link text.\n dispatch?.(state.tr.insert(from, state.schema.text(href, [mark])));\n return true;\n }\n dispatch?.(state.tr.removeMark(from, to, marks.link).addMark(from, to, mark));\n return true;\n };\n}\n\n/** Insert an image in place of the selection. */\nexport function insertImage(src: string, alt?: string): Command {\n return (state, dispatch) => {\n if (!isSafeImageUrl(src)) return false;\n dispatch?.(\n state.tr\n .replaceSelectionWith(nodesOf(state).image.create({ src, alt: alt ?? null }))\n .scrollIntoView(),\n );\n return true;\n };\n}\n\n// ---------- state queries (like queryCommandState) ----------\n\nexport function isMarkActive(state: EditorState, type: MarkType): boolean {\n const { from, $from, to, empty } = state.selection;\n if (empty) return !!type.isInSet(state.storedMarks ?? $from.marks());\n return state.doc.rangeHasMark(from, to, type);\n}\n\nexport function isNodeActive(\n state: EditorState,\n type: NodeType,\n attrs?: Record<string, unknown>,\n): boolean {\n const { $from, to } = state.selection;\n for (let depth = $from.depth; depth > 0; depth--) {\n const node = $from.node(depth);\n if (\n node.type === type &&\n (!attrs || Object.entries(attrs).every(([k, v]) => node.attrs[k] === v))\n ) {\n return to <= $from.end(depth);\n }\n }\n return false;\n}\n\nexport function getActiveAlign(state: EditorState): TextAlign {\n const parent = state.selection.$from.parent;\n return (parent.attrs.align as TextAlign | null) ?? 'left';\n}\n\n/**\n * Whether a command is active for the current selection: the mark is applied, the block has the\n * right type, the alignment matches. Always `false` for action commands (undo, indent, horizontalRule…).\n */\nexport function isCommandActive(state: EditorState, command: CommandName): boolean {\n const parent = state.selection.$from.parent;\n const nodes = nodesOf(state);\n const marks = marksOf(state);\n switch (command) {\n case 'bold':\n case 'italic':\n case 'underline':\n case 'strike':\n case 'code':\n case 'subscript':\n case 'superscript':\n return isMarkActive(state, marks[command]);\n case 'paragraph':\n return parent.type === nodes.paragraph;\n case 'h1':\n case 'h2':\n case 'h3':\n case 'h4':\n case 'h5':\n case 'h6':\n return parent.type === nodes.heading && parent.attrs.level === Number(command[1]);\n case 'codeBlock':\n return parent.type === nodes.code_block;\n case 'blockquote':\n return isNodeActive(state, nodes.blockquote);\n case 'bulletList':\n return isNodeActive(state, nodes.bullet_list, { checklist: false });\n case 'orderedList':\n return isNodeActive(state, nodes.ordered_list);\n case 'alignLeft':\n return getActiveAlign(state) === 'left';\n case 'alignCenter':\n return getActiveAlign(state) === 'center';\n case 'alignRight':\n return getActiveAlign(state) === 'right';\n case 'alignJustify':\n return getActiveAlign(state) === 'justify';\n default:\n return false;\n }\n}\n\nexport function getLinkAt(\n state: EditorState,\n): { href: string; title: string | null; target: string | null } | null {\n const { $from } = state.selection;\n const marks = marksOf(state);\n const mark =\n marks.link.isInSet($from.marks()) ?? marks.link.isInSet($from.nodeAfter?.marks ?? []);\n return mark\n ? (mark.attrs as { href: string; title: string | null; target: string | null })\n : null;\n}\n\nexport function markRange(\n state: EditorState,\n type: MarkType,\n pos: number,\n): { from: number; to: number } | null {\n // Collect the continuous runs of text with this mark inside the parent block\n // and return the one that contains pos.\n const $pos = state.doc.resolve(pos);\n const base = $pos.start();\n const segments: { from: number; to: number }[] = [];\n $pos.parent.forEach((child, offset) => {\n if (!type.isInSet(child.marks)) return;\n const from = base + offset;\n const to = from + child.nodeSize;\n const last = segments[segments.length - 1];\n if (last && last.to === from) last.to = to;\n else segments.push({ from, to });\n });\n return segments.find((s) => s.from <= pos && pos <= s.to) ?? null;\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,MAAM,cAAc,YAAY,cAAc;AACvD,SAAS,MAAM,YAAY;AAE3B,SAAS,cAAc,cAAc,kBAAkB;AACvD,SAAS,iBAAmE;AAiDrE,IAAM,UAAU,CAAC,UAAwB,MAAM,OAAsB;AACrE,IAAM,UAAU,CAAC,UAAwB,MAAM,OAAsB;AAG5E,IAAM,WACJ,CAAC,MAAgB,SACjB,CAAC,OAAO,UAAU,SAChB,KAAK,QAAQ,KAAK,EAAE,IAAI,CAAC,EAAE,OAAO,UAAU,IAAI;AAEpD,IAAM,WACJ,CAAC,MAAgB,SACjB,CAAC,OAAO,UAAU,SAChB,KAAK,QAAQ,KAAK,EAAE,IAAI,CAAC,EAAE,OAAO,UAAU,IAAI;AAEpD,SAAS,SAAS,OAAkC;AAClD,SAAO,CAAC,OAAO,aAAa;AAC1B,UAAM,EAAE,MAAM,GAAG,IAAI,MAAM;AAC3B,QAAI,KAAK,MAAM;AACf,QAAI,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AAC,KAAK,QAAQ,MAAM,KAAK,EAAG;AAChC,UAAM,OAAO,OAAO;AACpB,UAAM,KAAK,OAAO,MAAM;AACxB,UAAM,OAAO,SAAS,SAAS,SAAS,CAAC;AACzC,QAAI,QAAQ,KAAK,OAAO,KAAM,MAAK,KAAK;AAAA,QACnC,UAAS,KAAK,EAAE,MAAM,GAAG,CAAC;AAAA,EACjC,CAAC;AACD,SAAO,SAAS,KAAK,CAAC,MAAM,EAAE,QAAQ,OAAO,OAAO,EAAE,EAAE,KAAK;AAC/D;","names":[]}
@@ -0,0 +1,288 @@
1
+ // src/a11y.ts
2
+ var RULES = {
3
+ I1: { severity: "error", level: "A" },
4
+ I2: { severity: "error", level: "A" },
5
+ I3: { severity: "error", level: "A" },
6
+ I4: { severity: "warning", level: "A" },
7
+ D1: { severity: "warning", level: "A" },
8
+ D2: { severity: "error", level: "A" },
9
+ D3: { severity: "error", level: "A" },
10
+ D4O: { severity: "error", level: "A" },
11
+ D4U: { severity: "error", level: "A" },
12
+ D5A: { severity: "error", level: "AA" },
13
+ D5B: { severity: "error", level: "AA" },
14
+ D5C: { severity: "error", level: "AAA" },
15
+ H93: { severity: "error", level: "A" },
16
+ T4B: { severity: "error", level: "A" },
17
+ N1: { severity: "warning", level: "A" },
18
+ N2: { severity: "error", level: "AA" },
19
+ N3: { severity: "error", level: "A" }
20
+ };
21
+ var RANK = { A: 1, AA: 2, AAA: 3, a: 1, aa: 2, aaa: 3 };
22
+ var VAGUE_LINKS = /* @__PURE__ */ new Set([
23
+ "click here",
24
+ "click",
25
+ "here",
26
+ "more",
27
+ "read more",
28
+ "learn more",
29
+ "more info",
30
+ "more information",
31
+ "details",
32
+ "link",
33
+ "this link",
34
+ "this",
35
+ "go",
36
+ "continue"
37
+ ]);
38
+ var BULLET = /^\s*[•◦▪▫‣⁃●○■□–—*-]\s+\S/;
39
+ var NUMBERED = /^\s*(\d{1,3})[.)]\s+\S/;
40
+ var FILE_NAME = /^[\w\s().-]+\.(png|jpe?g|gif|webp|svg|bmp|tiff?|heic|avif)$|^(img|dsc|dcim|image|photo|screenshot)[\s_-]?\d+$/i;
41
+ function snippet(text) {
42
+ const line = text.replace(/\s+/g, " ").trim();
43
+ return line.length > 80 ? `${line.slice(0, 79)}\u2026` : line;
44
+ }
45
+ var NAMED = {
46
+ black: "#000000",
47
+ white: "#ffffff",
48
+ red: "#ff0000",
49
+ green: "#008000",
50
+ blue: "#0000ff",
51
+ yellow: "#ffff00",
52
+ orange: "#ffa500",
53
+ gray: "#808080",
54
+ grey: "#808080",
55
+ silver: "#c0c0c0",
56
+ maroon: "#800000",
57
+ purple: "#800080",
58
+ fuchsia: "#ff00ff",
59
+ lime: "#00ff00",
60
+ olive: "#808000",
61
+ navy: "#000080",
62
+ teal: "#008080",
63
+ aqua: "#00ffff"
64
+ };
65
+ function parseColor(value) {
66
+ if (typeof value !== "string") return null;
67
+ const v = (NAMED[value.trim().toLowerCase()] ?? value).trim().toLowerCase();
68
+ let m = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(v);
69
+ if (m) return [m[1], m[2], m[3]].map((h) => parseInt(h + h, 16));
70
+ m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(ff)?$/.exec(v);
71
+ if (m) return [m[1], m[2], m[3]].map((h) => parseInt(h, 16));
72
+ m = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(1|1\.0*)\s*)?\)$/.exec(v);
73
+ if (m)
74
+ return [m[1], m[2], m[3]].map((n) => Math.min(255, Number(n)));
75
+ return null;
76
+ }
77
+ function luminance([r, g, b]) {
78
+ const channel = (c) => {
79
+ const s = c / 255;
80
+ return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
81
+ };
82
+ return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
83
+ }
84
+ function contrastRatio(a, b) {
85
+ const [light, dark] = [luminance(a), luminance(b)].sort((x, y) => y - x);
86
+ return (light + 0.05) / (dark + 0.05);
87
+ }
88
+ var HEADING_PX = [32, 24, 18.72, 16, 13.28, 10.72];
89
+ function pixels(value) {
90
+ const m = /^(\d+(?:\.\d+)?)(px|pt|em|rem|%)$/.exec(String(value ?? "").trim());
91
+ if (!m) return null;
92
+ const n = Number(m[1]);
93
+ return m[2] === "px" ? n : m[2] === "pt" ? n * 4 / 3 : m[2] === "%" ? n / 100 * 16 : n * 16;
94
+ }
95
+ function checkAccessibility(doc, options = {}) {
96
+ const maxLevel = RANK[options.level ?? "aa"] ?? 2;
97
+ const ignored = new Set(options.ignoredRules ?? []);
98
+ const allowDecorative = options.allowDecorativeImages !== false;
99
+ const maxAlt = options.altTextMaxLength ?? 150;
100
+ const page = parseColor(options.pageBackground ?? "#ffffff") ?? [255, 255, 255];
101
+ const issues = [];
102
+ const add = (rule, from, to, text, data) => {
103
+ const spec = RULES[rule];
104
+ if (ignored.has(rule) || RANK[spec.level] > maxLevel) return;
105
+ issues.push({ rule, ...spec, from, to, text: snippet(text), ...data ? { data } : {} });
106
+ };
107
+ let previousHeading = 0;
108
+ const ids = /* @__PURE__ */ new Set();
109
+ let run = null;
110
+ const flush = () => {
111
+ if (run && (run.kind === "bullet" || run.texts.length > 1)) {
112
+ add(run.kind === "bullet" ? "D4U" : "D4O", run.from, run.to, run.texts.join(" "), {
113
+ kind: run.kind
114
+ });
115
+ }
116
+ run = null;
117
+ };
118
+ const checkId = (node, pos) => {
119
+ const id = node.attrs.id;
120
+ if (typeof id !== "string" || !id) return;
121
+ if (ids.has(id)) add("H93", pos, pos + node.nodeSize, `#${id}`, { id });
122
+ ids.add(id);
123
+ };
124
+ doc.descendants((node, pos, parent) => {
125
+ const end = pos + node.nodeSize;
126
+ const topLevel = parent === doc;
127
+ const name = node.type.name;
128
+ if (topLevel) {
129
+ const text = name === "paragraph" ? node.textContent : "";
130
+ const bullet = BULLET.test(text);
131
+ const number = NUMBERED.exec(text);
132
+ if (bullet && (!run || run.kind === "bullet")) {
133
+ run ??= { kind: "bullet", from: pos, to: end, texts: [], next: 0 };
134
+ run.to = end;
135
+ run.texts.push(text);
136
+ } else if (number && (run?.kind === "ordered" ? Number(number[1]) === run.next : true)) {
137
+ if (run?.kind !== "ordered") {
138
+ flush();
139
+ run = { kind: "ordered", from: pos, to: end, texts: [], next: 0 };
140
+ }
141
+ run.to = end;
142
+ run.texts.push(text);
143
+ run.next = Number(number[1]) + 1;
144
+ } else {
145
+ flush();
146
+ if (bullet) run = { kind: "bullet", from: pos, to: end, texts: [text], next: 0 };
147
+ }
148
+ }
149
+ if (name === "heading") {
150
+ const level = Math.min(6, Math.max(1, Math.trunc(Number(node.attrs.level)) || 1));
151
+ const text = node.textContent;
152
+ let content = false;
153
+ node.forEach((child) => {
154
+ if (!child.isText && child.type.name !== "hard_break") content = true;
155
+ });
156
+ if (!text.trim() && !content) add("N2", pos, end, "", { level });
157
+ else {
158
+ if (previousHeading && level > previousHeading + 1) {
159
+ add("D2", pos, end, text, { level, to: previousHeading + 1 });
160
+ }
161
+ previousHeading = level;
162
+ }
163
+ checkId(node, pos);
164
+ } else if (name === "anchor") {
165
+ checkId(node, pos);
166
+ } else if (name === "image" || name === "figure_image") {
167
+ const raw = node.attrs.alt;
168
+ const alt = raw === null || raw === void 0 ? null : String(raw);
169
+ const file = String(node.attrs.src ?? "").split(/[/?#]/).filter(Boolean).pop() ?? "";
170
+ if (alt === null || alt !== "" && !alt.trim()) add("I2", pos, end, file);
171
+ else if (alt === "") {
172
+ if (!allowDecorative) add("I1", pos, end, file);
173
+ } else if (FILE_NAME.test(alt.trim()) || alt.trim() === file) add("I3", pos, end, alt);
174
+ else if (alt.length > maxAlt) add("I4", pos, end, alt, { length: alt.length, max: maxAlt });
175
+ } else if (name === "table") {
176
+ let rows = 0;
177
+ let headers = 0;
178
+ node.descendants((child) => {
179
+ if (child.type.name === "table_row") rows++;
180
+ if (child.type.name === "table_header") headers++;
181
+ return child.type.spec.tableRole !== "cell";
182
+ });
183
+ if (rows > 1 && !headers) add("T4B", pos, end, node.textContent);
184
+ }
185
+ if (node.isTextblock) {
186
+ checkTextblock(node, pos, name === "heading" ? Number(node.attrs.level) || 1 : 0);
187
+ if (topLevel && name === "paragraph") checkLooksLikeHeading(node, pos);
188
+ }
189
+ return true;
190
+ });
191
+ flush();
192
+ function checkLooksLikeHeading(node, pos) {
193
+ const text = node.textContent.trim();
194
+ if (!text || text.length > 80 || /[.!?:;,…]$/.test(text) || BULLET.test(text)) return;
195
+ if (NUMBERED.test(text)) return;
196
+ let texts = 0;
197
+ let bold = 0;
198
+ let large = 0;
199
+ node.forEach((child) => {
200
+ if (!child.isText || !child.text.trim()) return;
201
+ texts++;
202
+ if (child.marks.some((m) => m.type.name === "bold")) bold++;
203
+ const size = child.marks.find((m) => m.type.name === "font_size");
204
+ if (size && (pixels(size.attrs.value) ?? 0) >= 20) large++;
205
+ });
206
+ if (!texts || bold < texts && large < texts) return;
207
+ add("D1", pos, pos + node.nodeSize, text, {
208
+ level: Math.min(6, Math.max(2, previousHeading + 1))
209
+ });
210
+ }
211
+ function checkTextblock(node, pos, headingLevel) {
212
+ const start = pos + 1;
213
+ const runs = [];
214
+ let current = null;
215
+ let low = null;
216
+ const flushLow = () => {
217
+ if (low) add(low.data.rule, low.from, low.to, low.text, low.data);
218
+ low = null;
219
+ };
220
+ node.forEach((child, offset) => {
221
+ const from = start + offset;
222
+ const to = from + child.nodeSize;
223
+ const link = child.marks.find((m) => m.type.name === "link");
224
+ if (link && current && current.mark.eq(link) && current.to === from) {
225
+ current.to = to;
226
+ current.text += child.text ?? "";
227
+ current.hasImageText ||= !!(child.attrs.alt && String(child.attrs.alt).trim());
228
+ } else if (link) {
229
+ current = {
230
+ from,
231
+ to,
232
+ mark: link,
233
+ text: child.text ?? "",
234
+ hasImageText: !!(child.attrs.alt && String(child.attrs.alt).trim())
235
+ };
236
+ runs.push(current);
237
+ } else {
238
+ current = null;
239
+ }
240
+ if (!child.isText) return;
241
+ const color = child.marks.find((m) => m.type.name === "color");
242
+ const background = child.marks.find((m) => m.type.name === "background");
243
+ if (!color && !background) return flushLow();
244
+ const fg = color ? parseColor(color.attrs.value) : [0, 0, 0];
245
+ const bg = background ? parseColor(background.attrs.value) : page;
246
+ if (!fg || !bg) return flushLow();
247
+ const px = pixels(child.marks.find((m) => m.type.name === "font_size")?.attrs.value) ?? (headingLevel ? HEADING_PX[headingLevel - 1] : 16);
248
+ const bold = headingLevel > 0 || child.marks.some((m) => m.type.name === "bold");
249
+ const large = px >= 24 || px >= 18.66 && bold;
250
+ const ratio = contrastRatio(fg, bg);
251
+ const rule = maxLevel >= 3 ? "D5C" : large ? "D5A" : "D5B";
252
+ const required = maxLevel >= 3 ? large ? 4.5 : 7 : large ? 3 : 4.5;
253
+ if (ratio >= required) return flushLow();
254
+ const key = `${String(color?.attrs.value)}|${String(background?.attrs.value)}`;
255
+ const rounded = Math.floor(ratio * 100) / 100;
256
+ if (low && low.key === key && low.to === from) {
257
+ low.to = to;
258
+ low.text += child.text;
259
+ } else {
260
+ flushLow();
261
+ low = { from, to, text: child.text, key, data: { rule, ratio: rounded, required } };
262
+ }
263
+ });
264
+ flushLow();
265
+ runs.forEach((run2, index) => {
266
+ const text = run2.text.trim();
267
+ if (!text && !run2.hasImageText)
268
+ add("N3", run2.from, run2.to, String(run2.mark.attrs.href ?? ""));
269
+ else if (VAGUE_LINKS.has(
270
+ text.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, "").trim()
271
+ ))
272
+ add("N1", run2.from, run2.to, text);
273
+ const next = runs[index + 1];
274
+ if (next && next.mark.attrs.href === run2.mark.attrs.href) {
275
+ const between = node.textBetween(run2.to - start, next.from - start);
276
+ if (!between.trim()) add("D3", run2.from, next.to, `${run2.text} ${next.text}`);
277
+ }
278
+ });
279
+ }
280
+ return issues.sort((a, b) => a.from - b.from);
281
+ }
282
+
283
+ export {
284
+ parseColor,
285
+ contrastRatio,
286
+ checkAccessibility
287
+ };
288
+ //# sourceMappingURL=chunk-UTMS2P2K.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/a11y.ts"],"sourcesContent":["import type { Mark, Node as PMNode } from 'prosemirror-model';\n\n/**\n * Accessibility checks of a document (WCAG 2.1), without a DOM: the a11ychecker plugin uses them in\n * the editor, and `@novaprose/core/a11y` on a server — check stored content before it is published.\n *\n * import { checkAccessibility } from '@novaprose/core/a11y';\n * const issues = checkAccessibility(createRenderer(options).doc(json), { level: 'aa' });\n *\n * Rule ids are TinyMCE's where the check is the same (I2, D2…), so lists of ignored rules carry over;\n * N1, N2, N3 are ours.\n */\n\nexport type A11yLevel = 'a' | 'aa' | 'aaa';\n\nexport interface A11yCheckOptions {\n /** The WCAG level to check against: a, aa (default) or aaa. */\n level?: A11yLevel;\n /** Rule ids not to check, for example ['D1', 'N1']. */\n ignoredRules?: readonly string[];\n /**\n * Whether an image may be decorative: an empty alternative text (alt=\"\") tells screen readers to\n * skip it (yes by default, as WCAG allows; false flags such images too).\n */\n allowDecorativeImages?: boolean;\n /** Alternative text longer than this is a warning (150 characters by default). */\n altTextMaxLength?: number;\n /** The color behind the text where the content is shown, for contrast (white by default). */\n pageBackground?: string;\n}\n\nexport interface A11yIssue {\n /** The rule: I1–I4 images, D1–D5 document, H93 ids, T4B tables, N1–N3 ours. */\n rule: string;\n severity: 'error' | 'warning';\n /** The WCAG level of the success criterion behind the rule. */\n level: 'A' | 'AA' | 'AAA';\n /** Where it is in the document. */\n from: number;\n to: number;\n /** A short piece of the content it is about. */\n text: string;\n /** What a fix needs: the heading level to change to, the contrast found and needed, the id… */\n data?: Record<string, unknown>;\n}\n\nconst RULES: Record<string, { severity: 'error' | 'warning'; level: 'A' | 'AA' | 'AAA' }> = {\n I1: { severity: 'error', level: 'A' },\n I2: { severity: 'error', level: 'A' },\n I3: { severity: 'error', level: 'A' },\n I4: { severity: 'warning', level: 'A' },\n D1: { severity: 'warning', level: 'A' },\n D2: { severity: 'error', level: 'A' },\n D3: { severity: 'error', level: 'A' },\n D4O: { severity: 'error', level: 'A' },\n D4U: { severity: 'error', level: 'A' },\n D5A: { severity: 'error', level: 'AA' },\n D5B: { severity: 'error', level: 'AA' },\n D5C: { severity: 'error', level: 'AAA' },\n H93: { severity: 'error', level: 'A' },\n T4B: { severity: 'error', level: 'A' },\n N1: { severity: 'warning', level: 'A' },\n N2: { severity: 'error', level: 'AA' },\n N3: { severity: 'error', level: 'A' },\n};\n\nconst RANK = { A: 1, AA: 2, AAA: 3, a: 1, aa: 2, aaa: 3 } as const;\n\n/** Link texts that don't say where a link goes. */\nconst VAGUE_LINKS = new Set([\n 'click here',\n 'click',\n 'here',\n 'more',\n 'read more',\n 'learn more',\n 'more info',\n 'more information',\n 'details',\n 'link',\n 'this link',\n 'this',\n 'go',\n 'continue',\n]);\n\nconst BULLET = /^\\s*[•◦▪▫‣⁃●○■□–—*-]\\s+\\S/;\nconst NUMBERED = /^\\s*(\\d{1,3})[.)]\\s+\\S/;\n/** An alternative text that is a file name, or the name a camera gives. */\nconst FILE_NAME =\n /^[\\w\\s().-]+\\.(png|jpe?g|gif|webp|svg|bmp|tiff?|heic|avif)$|^(img|dsc|dcim|image|photo|screenshot)[\\s_-]?\\d+$/i;\n\n/** A text snippet for the list: one line, at most 80 characters. */\nfunction snippet(text: string): string {\n const line = text.replace(/\\s+/g, ' ').trim();\n return line.length > 80 ? `${line.slice(0, 79)}…` : line;\n}\n\n// ---------- contrast ----------\n\nconst NAMED: Record<string, string> = {\n black: '#000000',\n white: '#ffffff',\n red: '#ff0000',\n green: '#008000',\n blue: '#0000ff',\n yellow: '#ffff00',\n orange: '#ffa500',\n gray: '#808080',\n grey: '#808080',\n silver: '#c0c0c0',\n maroon: '#800000',\n purple: '#800080',\n fuchsia: '#ff00ff',\n lime: '#00ff00',\n olive: '#808000',\n navy: '#000080',\n teal: '#008080',\n aqua: '#00ffff',\n};\n\n/** A CSS color as [r, g, b] (0–255), or null for what can't be told here (transparent, unknown names). */\nexport function parseColor(value: unknown): [number, number, number] | null {\n if (typeof value !== 'string') return null;\n const v = (NAMED[value.trim().toLowerCase()] ?? value).trim().toLowerCase();\n let m = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(v);\n if (m) return [m[1]!, m[2]!, m[3]!].map((h) => parseInt(h + h, 16)) as [number, number, number];\n m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(ff)?$/.exec(v);\n if (m) return [m[1]!, m[2]!, m[3]!].map((h) => parseInt(h, 16)) as [number, number, number];\n m = /^rgba?\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*(?:,\\s*(1|1\\.0*)\\s*)?\\)$/.exec(v);\n if (m)\n return [m[1]!, m[2]!, m[3]!].map((n) => Math.min(255, Number(n))) as [number, number, number];\n return null;\n}\n\n/** WCAG relative luminance. */\nfunction luminance([r, g, b]: [number, number, number]): number {\n const channel = (c: number) => {\n const s = c / 255;\n return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;\n };\n return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);\n}\n\n/** The WCAG contrast ratio of two colors (1 to 21). */\nexport function contrastRatio(a: [number, number, number], b: [number, number, number]): number {\n const [light, dark] = [luminance(a), luminance(b)].sort((x, y) => y - x) as [number, number];\n return (light + 0.05) / (dark + 0.05);\n}\n\n/** The browser's heading sizes in pixels, h1 to h6. */\nconst HEADING_PX = [32, 24, 18.72, 16, 13.28, 10.72];\n\n/** A font size in CSS pixels (px, pt, em, rem, %), or null. */\nfunction pixels(value: unknown): number | null {\n const m = /^(\\d+(?:\\.\\d+)?)(px|pt|em|rem|%)$/.exec(String(value ?? '').trim());\n if (!m) return null;\n const n = Number(m[1]);\n return m[2] === 'px' ? n : m[2] === 'pt' ? (n * 4) / 3 : m[2] === '%' ? (n / 100) * 16 : n * 16;\n}\n\n// ---------- the check ----------\n\ninterface LinkRun {\n from: number;\n to: number;\n mark: Mark;\n text: string;\n hasImageText: boolean;\n}\n\n/** Problems found in the document, in document order. */\nexport function checkAccessibility(doc: PMNode, options: A11yCheckOptions = {}): A11yIssue[] {\n const maxLevel = RANK[options.level ?? 'aa'] ?? 2;\n const ignored = new Set(options.ignoredRules ?? []);\n const allowDecorative = options.allowDecorativeImages !== false;\n const maxAlt = options.altTextMaxLength ?? 150;\n const page = parseColor(options.pageBackground ?? '#ffffff') ?? [255, 255, 255];\n const issues: A11yIssue[] = [];\n const add = (\n rule: string,\n from: number,\n to: number,\n text: string,\n data?: Record<string, unknown>,\n ) => {\n const spec = RULES[rule]!;\n if (ignored.has(rule) || RANK[spec.level] > maxLevel) return;\n issues.push({ rule, ...spec, from, to, text: snippet(text), ...(data ? { data } : {}) });\n };\n\n let previousHeading = 0;\n const ids = new Set<string>();\n // Top-level paragraphs that look like list items, in a row.\n let run: {\n kind: 'bullet' | 'ordered';\n from: number;\n to: number;\n texts: string[];\n next: number;\n } | null = null;\n const flush = () => {\n // A numbered \"run\" of one paragraph (\"1. Introduction\") is not a list.\n if (run && (run.kind === 'bullet' || run.texts.length > 1)) {\n add(run.kind === 'bullet' ? 'D4U' : 'D4O', run.from, run.to, run.texts.join(' '), {\n kind: run.kind,\n });\n }\n run = null;\n };\n\n const checkId = (node: PMNode, pos: number) => {\n const id = node.attrs.id;\n if (typeof id !== 'string' || !id) return;\n if (ids.has(id)) add('H93', pos, pos + node.nodeSize, `#${id}`, { id });\n ids.add(id);\n };\n\n doc.descendants((node, pos, parent) => {\n const end = pos + node.nodeSize;\n const topLevel = parent === doc;\n const name = node.type.name;\n\n // Paragraphs typed as a list (• item, 1. item): a run of them is one problem.\n if (topLevel) {\n const text = name === 'paragraph' ? node.textContent : '';\n const bullet = BULLET.test(text);\n const number = NUMBERED.exec(text);\n if (bullet && (!run || run.kind === 'bullet')) {\n run ??= { kind: 'bullet', from: pos, to: end, texts: [], next: 0 };\n run.to = end;\n run.texts.push(text);\n } else if (number && (run?.kind === 'ordered' ? Number(number[1]) === run.next : true)) {\n if (run?.kind !== 'ordered') {\n flush();\n run = { kind: 'ordered', from: pos, to: end, texts: [], next: 0 };\n }\n run!.to = end;\n run!.texts.push(text);\n run!.next = Number(number[1]) + 1;\n } else {\n flush();\n if (bullet) run = { kind: 'bullet', from: pos, to: end, texts: [text], next: 0 };\n }\n }\n\n if (name === 'heading') {\n const level = Math.min(6, Math.max(1, Math.trunc(Number(node.attrs.level)) || 1));\n const text = node.textContent;\n // An image or a mention inside is content too; only line breaks are not.\n let content = false;\n node.forEach((child) => {\n if (!child.isText && child.type.name !== 'hard_break') content = true;\n });\n if (!text.trim() && !content) add('N2', pos, end, '', { level });\n else {\n if (previousHeading && level > previousHeading + 1) {\n add('D2', pos, end, text, { level, to: previousHeading + 1 });\n }\n previousHeading = level;\n }\n checkId(node, pos);\n } else if (name === 'anchor') {\n checkId(node, pos);\n } else if (name === 'image' || name === 'figure_image') {\n // null: no alternative text; \"\": decorative (alt=\"\"); blank: as good as none.\n const raw = node.attrs.alt;\n const alt = raw === null || raw === undefined ? null : String(raw);\n const file =\n String(node.attrs.src ?? '')\n .split(/[/?#]/)\n .filter(Boolean)\n .pop() ?? '';\n if (alt === null || (alt !== '' && !alt.trim())) add('I2', pos, end, file);\n else if (alt === '') {\n if (!allowDecorative) add('I1', pos, end, file);\n } else if (FILE_NAME.test(alt.trim()) || alt.trim() === file) add('I3', pos, end, alt);\n else if (alt.length > maxAlt) add('I4', pos, end, alt, { length: alt.length, max: maxAlt });\n } else if (name === 'table') {\n let rows = 0;\n let headers = 0;\n node.descendants((child) => {\n if (child.type.name === 'table_row') rows++;\n if (child.type.name === 'table_header') headers++;\n return child.type.spec.tableRole !== 'cell';\n });\n if (rows > 1 && !headers) add('T4B', pos, end, node.textContent);\n }\n\n if (node.isTextblock) {\n checkTextblock(node, pos, name === 'heading' ? Number(node.attrs.level) || 1 : 0);\n if (topLevel && name === 'paragraph') checkLooksLikeHeading(node, pos);\n // On into the paragraph: images in the text are checked like any other.\n }\n return true;\n });\n flush();\n\n /** D1: a short, all-bold (or large) paragraph with no closing punctuation. */\n function checkLooksLikeHeading(node: PMNode, pos: number) {\n const text = node.textContent.trim();\n if (!text || text.length > 80 || /[.!?:;,…]$/.test(text) || BULLET.test(text)) return;\n if (NUMBERED.test(text)) return;\n let texts = 0;\n let bold = 0;\n let large = 0;\n node.forEach((child) => {\n if (!child.isText || !child.text!.trim()) return;\n texts++;\n if (child.marks.some((m) => m.type.name === 'bold')) bold++;\n const size = child.marks.find((m) => m.type.name === 'font_size');\n if (size && (pixels(size.attrs.value) ?? 0) >= 20) large++;\n });\n if (!texts || (bold < texts && large < texts)) return;\n add('D1', pos, pos + node.nodeSize, text, {\n level: Math.min(6, Math.max(2, previousHeading + 1)),\n });\n }\n\n /** Links (D3, N1, N3) and contrast (D5) inside one paragraph or heading. */\n function checkTextblock(node: PMNode, pos: number, headingLevel: number) {\n const start = pos + 1;\n const runs: LinkRun[] = [];\n let current: LinkRun | null = null;\n // Text with too little contrast: consecutive pieces with the same colors are one problem.\n let low: {\n from: number;\n to: number;\n text: string;\n data: Record<string, unknown>;\n key: string;\n } | null = null;\n const flushLow = () => {\n if (low) add(low.data.rule as string, low.from, low.to, low.text, low.data);\n low = null;\n };\n node.forEach((child, offset) => {\n const from = start + offset;\n const to = from + child.nodeSize;\n const link = child.marks.find((m) => m.type.name === 'link');\n if (link && current && current.mark.eq(link) && current.to === from) {\n current.to = to;\n current.text += child.text ?? '';\n current.hasImageText ||= !!(child.attrs.alt && String(child.attrs.alt).trim());\n } else if (link) {\n current = {\n from,\n to,\n mark: link,\n text: child.text ?? '',\n hasImageText: !!(child.attrs.alt && String(child.attrs.alt).trim()),\n };\n runs.push(current);\n } else {\n current = null;\n }\n\n // Contrast of text with a color of its own or on a highlight.\n if (!child.isText) return;\n const color = child.marks.find((m) => m.type.name === 'color');\n const background = child.marks.find((m) => m.type.name === 'background');\n if (!color && !background) return flushLow();\n // Text without a color of its own is black (the usual default where content is published).\n const fg = color ? parseColor(color.attrs.value) : ([0, 0, 0] as [number, number, number]);\n const bg = background ? parseColor(background.attrs.value) : page;\n if (!fg || !bg) return flushLow();\n // Large text (WCAG): 24px, or 18.66px bold; headings are bold, at the browser's sizes.\n const px =\n pixels(child.marks.find((m) => m.type.name === 'font_size')?.attrs.value) ??\n (headingLevel ? HEADING_PX[headingLevel - 1]! : 16);\n const bold = headingLevel > 0 || child.marks.some((m) => m.type.name === 'bold');\n const large = px >= 24 || (px >= 18.66 && bold);\n const ratio = contrastRatio(fg, bg);\n const rule = maxLevel >= 3 ? 'D5C' : large ? 'D5A' : 'D5B';\n const required = maxLevel >= 3 ? (large ? 4.5 : 7) : large ? 3 : 4.5;\n if (ratio >= required) return flushLow();\n const key = `${String(color?.attrs.value)}|${String(background?.attrs.value)}`;\n const rounded = Math.floor(ratio * 100) / 100;\n if (low && low.key === key && low.to === from) {\n low.to = to;\n low.text += child.text;\n } else {\n flushLow();\n low = { from, to, text: child.text!, key, data: { rule, ratio: rounded, required } };\n }\n });\n flushLow();\n\n runs.forEach((run, index) => {\n const text = run.text.trim();\n if (!text && !run.hasImageText)\n add('N3', run.from, run.to, String(run.mark.attrs.href ?? ''));\n else if (\n VAGUE_LINKS.has(\n text\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}\\s]/gu, '')\n .trim(),\n )\n )\n add('N1', run.from, run.to, text);\n const next = runs[index + 1];\n if (next && next.mark.attrs.href === run.mark.attrs.href) {\n const between = node.textBetween(run.to - start, next.from - start);\n if (!between.trim()) add('D3', run.from, next.to, `${run.text} ${next.text}`);\n }\n });\n }\n\n return issues.sort((a, b) => a.from - b.from);\n}\n"],"mappings":";AA8CA,IAAM,QAAsF;AAAA,EAC1F,IAAI,EAAE,UAAU,SAAS,OAAO,IAAI;AAAA,EACpC,IAAI,EAAE,UAAU,SAAS,OAAO,IAAI;AAAA,EACpC,IAAI,EAAE,UAAU,SAAS,OAAO,IAAI;AAAA,EACpC,IAAI,EAAE,UAAU,WAAW,OAAO,IAAI;A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AAQ,CAACA,MAAK,UAAU;AAC3B,YAAM,OAAOA,KAAI,KAAK,KAAK;AAC3B,UAAI,CAAC,QAAQ,CAACA,KAAI;AAChB,YAAI,MAAMA,KAAI,MAAMA,KAAI,IAAI,OAAOA,KAAI,KAAK,MAAM,QAAQ,EAAE,CAAC;AAAA,eAE7D,YAAY;AAAA,QACV,KACG,YAAY,EACZ,QAAQ,qBAAqB,EAAE,EAC/B,KAAK;AAAA,MACV;AAEA,YAAI,MAAMA,KAAI,MAAMA,KAAI,IAAI,IAAI;AAClC,YAAM,OAAO,KAAK,QAAQ,CAAC;AAC3B,UAAI,QAAQ,KAAK,KAAK,MAAM,SAASA,KAAI,KAAK,MAAM,MAAM;AACxD,cAAM,UAAU,KAAK,YAAYA,KAAI,KAAK,OAAO,KAAK,OAAO,KAAK;AAClE,YAAI,CAAC,QAAQ,KAAK,EAAG,KAAI,MAAMA,KAAI,MAAM,KAAK,IAAI,GAAGA,KAAI,IAAI,IAAI,KAAK,IAAI,EAAE;AAAA,MAC9E;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO,OAAO,KAAK,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI;AAC9C;","names":["run"]}
@@ -1,4 +1,15 @@
1
1
  // src/plugins.ts
2
+ function pageHandlerOf(plugins, context) {
3
+ for (const plugin of plugins) {
4
+ if (!plugin.page) continue;
5
+ try {
6
+ return typeof plugin.page === "function" ? plugin.page(context) : plugin.page;
7
+ } catch (error) {
8
+ console.error(`[nova] Plugin "${plugin.name}" failed to set up its page`, error);
9
+ }
10
+ }
11
+ return null;
12
+ }
2
13
  function definePlugin(plugin) {
3
14
  return plugin;
4
15
  }
@@ -70,6 +81,7 @@ async function loadPlugin(loader) {
70
81
  }
71
82
 
72
83
  export {
84
+ pageHandlerOf,
73
85
  definePlugin,
74
86
  registerPlugin,
75
87
  isPluginRegistered,
@@ -77,4 +89,4 @@ export {
77
89
  orderPlugins,
78
90
  loadPlugin
79
91
  };
80
- //# sourceMappingURL=chunk-HPLT3XRZ.js.map
92
+ //# sourceMappingURL=chunk-V7WUHUHM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/plugins.ts"],"sourcesContent":["import type { MarkSpec, NodeSpec } from 'prosemirror-model';\nimport type { Command, EditorState, Plugin as PMPlugin, Transaction } from 'prosemirror-state';\nimport type { CommandName } from './commands';\nimport type { Editor } from './editor';\nimport type { NodeViewFactory } from './node-view';\nimport type { NodeAttribute } from './schema';\n\n/**\n * A NovaProse plugin. Built-in and third-party plugins use the same API.\n *\n * ```ts\n * export default definePlugin({\n * name: 'signature',\n * setup(editor) {\n * editor.ui.registry.addButton('signature', { text: 'Signature', tooltip: '…', onAction: … });\n * },\n * });\n * ```\n */\nexport interface NovaPlugin {\n /** A unique name: the plugin is listed under it in the configuration and in `requires` of other plugins. */\n name: string;\n /** Plugins that must be set up first. */\n requires?: string[];\n /** Register buttons, commands, autocompleters. May return a cleanup function (called on destroy). */\n setup?: (editor: Editor) => void | (() => void);\n /**\n * Buttons appended to the end of the default toolbar ('insertdatetime'). Not added when the user\n * set their own toolbar: their configuration wins.\n */\n toolbar?: string;\n /** ProseMirror plugins (input handling, decorations, keys). */\n prosemirrorPlugins?: (editor: Editor) => PMPlugin[];\n /**\n * New document nodes (with parseDOM and toDOM); they extend this editor's schema. A plugin with\n * nodes or marks is passed as an object, not a lazy loader: the schema is created right away.\n * The function gets the editor before it is created — read only `editor.options`; on the server\n * (createRenderer) it gets just the options.\n */\n nodes?: Record<string, NodeSpec> | ((editor: Editor) => Record<string, NodeSpec>);\n /** New marks (inline formatting) with parseDOM and toDOM. */\n marks?: Record<string, MarkSpec>;\n /**\n * Attributes added to existing nodes, by name: read from the node's element when HTML is parsed and\n * written back to it (`nodes: 'textblock'` for every node that holds text). The suggestions plugin\n * keeps a suggested change of a block's type or style this way.\n */\n nodeAttributes?: Record<string, NodeAttribute>;\n /**\n * Your own way to draw nodes in the editor: `{ callout: reactNodeView(Callout) }`, `vueNodeView(…)`\n * or `defineNodeView(…)`. Doesn't affect the HTML (that comes from toDOM). Views belong in the plugin\n * itself, not in its lazy part: adding them later would redraw the whole document.\n */\n nodeViews?: Record<string, NodeViewFactory>;\n /**\n * Override named commands (buttons, menus, shortcuts and editor.exec take them from here). For\n * example, collaboration replaces undo/redo with its own, which undo only your own changes.\n */\n commands?: Partial<Record<CommandName, Command>>;\n /** The plugin keeps its own history: the built-in one (prosemirror-history) is not added. */\n replaceHistory?: boolean;\n /**\n * Rewrite a transaction before it is applied (suggesting mode turns a deletion into a \"deleted\"\n * mark). Called for every transaction of the editor; return the same one when there is nothing to change.\n */\n transformTransaction?: (tr: Transaction, state: EditorState, editor: Editor) => Transaction;\n /**\n * The whole page around the content (the fullpagehtml plugin): how HTML that is a whole document\n * is taken apart, and how getHTML() puts the content back into its page. The page itself lives in\n * the document's attributes (declare them with `nodeAttributes`, `nodes: ['doc']`), so undo,\n * JSON and the server renderer keep it. A function gets the options, as `nodes` does.\n */\n page?: PageHandler | ((context: { options: Editor['options'] }) => PageHandler);\n /**\n * The lazy part of a plugin with nodes: buttons, dialogs, commands, keys. The schema is created\n * right away, so the nodes and everything that draws them (nodeViews) stay in the plugin itself\n * (first load), and the rest is a separate chunk loaded after the editor is created (part of\n * `editor.ready`). The part is an ordinary plugin without nodes.\n */\n load?: Loader;\n}\n\n/** A whole HTML document around the content: see `NovaPlugin.page`. */\nexport interface PageHandler {\n /**\n * HTML that is a whole document (a doctype, `<html>`, `<head>` or `<body>`), taken apart: the\n * content's HTML and the document's attributes. null when the HTML is only content.\n */\n read(html: string): { content: string; attrs: Record<string, unknown> } | null;\n /** The whole document: the content's HTML inside the page the document's attributes describe. */\n write(content: string, attrs: Readonly<Record<string, unknown>>): string;\n /** The source code view shows the whole document (true) or only the content. */\n inSource?: boolean;\n}\n\n/** The page handler of a set of plugins (the first one that has it), for these options. */\nexport function pageHandlerOf(\n plugins: readonly NovaPlugin[],\n context: { options: Editor['options'] },\n): PageHandler | null {\n for (const plugin of plugins) {\n if (!plugin.page) continue;\n try {\n return typeof plugin.page === 'function' ? plugin.page(context) : plugin.page;\n } catch (error) {\n console.error(`[nova] Plugin \"${plugin.name}\" failed to set up its page`, error);\n }\n }\n return null;\n}\n\ntype Loader = () => Promise<NovaPlugin | { default: NovaPlugin }>;\n\n/** An entry of the plugins option: an object, a registered name or a lazy loader. */\nexport type PluginEntry = NovaPlugin | string | Loader;\n\n/** A helper for typing a plugin definition. */\nexport function definePlugin(plugin: NovaPlugin): NovaPlugin {\n return plugin;\n}\n\n// ---------- the global registry (like PluginManager.add) ----------\n\nconst registry = new Map<string, NovaPlugin | Loader>();\n\n/** Register a plugin (or its lazy loader) under a name, for `plugins: ['name']`. */\nexport function registerPlugin(name: string, plugin: NovaPlugin | Loader): void {\n registry.set(name, plugin);\n}\n\nexport function isPluginRegistered(name: string): boolean {\n return registry.has(name);\n}\n\n// ---------- resolving the config ----------\n\nexport interface ResolvedPlugins {\n /** Synchronous plugins in dependency order. */\n plugins: NovaPlugin[];\n /** Lazy loaders (they load after the editor is created). */\n loaders: Loader[];\n errors: string[];\n}\n\nfunction isLoader(entry: unknown): entry is Loader {\n return typeof entry === 'function';\n}\n\n/** Turns the config into a list: names from the registry, loaders separately. */\nexport function resolveEntries(entries: PluginEntry[]): ResolvedPlugins {\n const plugins: NovaPlugin[] = [];\n const loaders: Loader[] = [];\n const errors: string[] = [];\n for (const entry of entries) {\n if (typeof entry === 'string') {\n const found = registry.get(entry);\n if (!found) errors.push(`Plugin \"${entry}\" is not registered`);\n else if (isLoader(found)) loaders.push(found);\n else plugins.push(found);\n } else if (isLoader(entry)) {\n loaders.push(entry);\n } else {\n plugins.push(entry);\n }\n }\n return { plugins, loaders, errors };\n}\n\n/**\n * Orders by dependencies (a topological sort).\n * A plugin with a missing or circular dependency is excluded, the others work.\n * available are the names of already attached plugins (for those loaded later).\n */\nexport function orderPlugins(\n plugins: NovaPlugin[],\n available: Set<string> = new Set(),\n): { ordered: NovaPlugin[]; errors: string[] } {\n const byName = new Map(plugins.map((p) => [p.name, p]));\n const ordered: NovaPlugin[] = [];\n const errors: string[] = [];\n const state = new Map<string, 'visiting' | 'done' | 'failed'>();\n\n const visit = (plugin: NovaPlugin, path: string[]): boolean => {\n const s = state.get(plugin.name);\n if (s === 'done') return true;\n if (s === 'failed') return false;\n if (s === 'visiting') {\n errors.push(`Plugin dependency cycle: ${[...path, plugin.name].join(' → ')}`);\n return false;\n }\n state.set(plugin.name, 'visiting');\n for (const dep of plugin.requires ?? []) {\n if (available.has(dep)) continue;\n const depPlugin = byName.get(dep);\n if (!depPlugin) {\n errors.push(`Plugin \"${plugin.name}\" requires \"${dep}\", which is not loaded`);\n state.set(plugin.name, 'failed');\n return false;\n }\n if (!visit(depPlugin, [...path, plugin.name])) {\n state.set(plugin.name, 'failed');\n return false;\n }\n }\n state.set(plugin.name, 'done');\n ordered.push(plugin);\n return true;\n };\n\n for (const plugin of plugins) visit(plugin, []);\n return { ordered, errors };\n}\n\nexport async function loadPlugin(loader: Loader): Promise<NovaPlugin> {\n const mod = await loader();\n return 'default' in mod && mod.default ? mod.default : (mod as NovaPlugin);\n}\n"],"mappings":";AAgGO,SAAS,cACd,SACA,SACoB;AACpB,aAAW,UAAU,SAAS;AAC5B,QAAI,CAAC,OAAO,KAAM;AAClB,QAAI;AACF,aAAO,OAAO,OAAO,SAAS,aAAa,OAAO,KAAK,OAAO,IAAI,OAAO;AAAA,IAC3E,SAAS,OAAO;AACd,cAAQ,MAAM,kBAAkB,OAAO,IAAI,+BAA+B,KAAK;AAAA,IACjF;AAAA,EACF;AACA,SAAO;AACT;AAQO,SAAS,aAAa,QAAgC;AAC3D,SAAO;AACT;AAIA,IAAM,WAAW,oBAAI,IAAiC;AAG/C,SAAS,eAAe,MAAc,QAAmC;AAC9E,WAAS,IAAI,MAAM,MAAM;AAC3B;AAEO,SAAS,mBAAmB,MAAuB;AACxD,SAAO,SAAS,IAAI,IAAI;AAC1B;AAYA,SAAS,SAAS,O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