@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,263 @@
1
+ import {
2
+ imageSize
3
+ } from "./chunk-TAM2FHKG.js";
4
+ import {
5
+ definePlugin
6
+ } from "./chunk-V7WUHUHM.js";
7
+ import {
8
+ h
9
+ } from "./chunk-QU3KXMYT.js";
10
+
11
+ // src/plugins/pageembed.ts
12
+ import { Plugin } from "prosemirror-state";
13
+ var DEFAULT_SANDBOX = "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation";
14
+ var DEFAULT_SIZES = ["21by9", "16by9", "4by3", "1by1"].map((ratio) => ({
15
+ value: `nova-pageembed--${ratio}`
16
+ }));
17
+ var FIXED = { width: 350, height: 260 };
18
+ var CLASS_RE = /^[\w-]{1,60}$/;
19
+ var RATIO_RE = /--(\d{1,3})by(\d{1,3})$/;
20
+ function pageEmbedOptions(context) {
21
+ const raw = context.options.pluginOptions?.pageembed ?? {};
22
+ const sizes = Array.isArray(raw.sizes) ? raw.sizes.filter(
23
+ (size) => !!size && typeof size.value === "string" && CLASS_RE.test(size.value)
24
+ ) : DEFAULT_SIZES;
25
+ const sandbox = raw.sandbox === false ? false : typeof raw.sandbox === "string" ? raw.sandbox.split(/\s+/).filter((word) => /^allow-[a-z-]{1,40}$/.test(word)).join(" ") : DEFAULT_SANDBOX;
26
+ return {
27
+ sizes,
28
+ inlineStyles: raw.inlineStyles !== false,
29
+ className: typeof raw.className === "string" && CLASS_RE.test(raw.className) ? raw.className : "nova-pageembed",
30
+ sandbox,
31
+ allowUrl: typeof raw.allowUrl === "function" ? raw.allowUrl : void 0
32
+ };
33
+ }
34
+ function ratioOf(value) {
35
+ const match = RATIO_RE.exec(value);
36
+ if (!match) return null;
37
+ const width = Number(match[1]);
38
+ const height = Number(match[2]);
39
+ return width > 0 && height > 0 ? [width, height] : null;
40
+ }
41
+ function embeddableUrl(url, allowUrl) {
42
+ if (typeof url !== "string") return null;
43
+ const value = url.trim();
44
+ if (value.length > 2e3 || !/^https?:\/\/[^\s/?#]/i.test(value)) return null;
45
+ let parsed;
46
+ try {
47
+ parsed = new URL(value);
48
+ } catch {
49
+ return null;
50
+ }
51
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return null;
52
+ if (parsed.username || parsed.password) return null;
53
+ try {
54
+ if (allowUrl && !allowUrl(parsed.href)) return null;
55
+ } catch {
56
+ return null;
57
+ }
58
+ return value;
59
+ }
60
+ function frameTitle(title, src) {
61
+ if (typeof title === "string" && title.trim()) return title.trim().slice(0, 300);
62
+ try {
63
+ return new URL(src).hostname;
64
+ } catch {
65
+ return src;
66
+ }
67
+ }
68
+ function sizeOf(value, settings) {
69
+ return typeof value === "string" && settings.sizes.some((size) => size.value === value) ? value : "";
70
+ }
71
+ function sizeFromClasses(classes, settings) {
72
+ const own = classes.find((name) => settings.sizes.some((size) => size.value === name));
73
+ if (own) return own;
74
+ for (const name of classes) {
75
+ const ratio = /^(?:nova|tiny)-pageembed--/.test(name) ? ratioOf(name) : null;
76
+ if (!ratio) continue;
77
+ const same = settings.sizes.find((size) => {
78
+ const other = ratioOf(size.value);
79
+ return !!other && other[0] * ratio[1] === other[1] * ratio[0];
80
+ });
81
+ if (same) return same.value;
82
+ }
83
+ return "";
84
+ }
85
+ function isWrapper(classes, settings) {
86
+ return classes.some(
87
+ (name) => name === settings.className || /^(?:nova|tiny)-pageembed(?:--[\w-]+)?$/.test(name) || settings.sizes.some((size) => size.value === name)
88
+ );
89
+ }
90
+ function frameAttrs(node, src, settings) {
91
+ return {
92
+ src,
93
+ title: frameTitle(node.attrs.title, src),
94
+ sandbox: settings.sandbox === false ? null : settings.sandbox,
95
+ allow: "fullscreen",
96
+ allowfullscreen: "",
97
+ loading: "lazy",
98
+ referrerpolicy: "strict-origin-when-cross-origin",
99
+ frameborder: node.attrs.border === true ? "1" : "0",
100
+ scrolling: node.attrs.scrolling === false ? "no" : null
101
+ };
102
+ }
103
+ function buildNodes(context) {
104
+ const settings = pageEmbedOptions(context);
105
+ return {
106
+ pageembed: {
107
+ group: "block",
108
+ atom: true,
109
+ selectable: true,
110
+ draggable: true,
111
+ attrs: {
112
+ src: { default: "" },
113
+ size: { default: "" },
114
+ width: { default: FIXED.width },
115
+ height: { default: FIXED.height },
116
+ title: { default: "" },
117
+ border: { default: false },
118
+ scrolling: { default: true }
119
+ },
120
+ parseDOM: [
121
+ {
122
+ tag: "div",
123
+ // Before element rules (extendedValidElements: 'div[*]') and plain blocks.
124
+ priority: 70,
125
+ getAttrs: (dom) => {
126
+ const el = dom;
127
+ const classes = [...el.classList];
128
+ if (!isWrapper(classes, settings)) return false;
129
+ const frame = el.querySelector("iframe");
130
+ const src = embeddableUrl(frame?.getAttribute("src"), settings.allowUrl);
131
+ if (!frame || !src) return false;
132
+ const border = frame.getAttribute("frameborder");
133
+ return {
134
+ src,
135
+ size: sizeFromClasses(classes, settings),
136
+ width: imageSize(frame.getAttribute("width")) ?? FIXED.width,
137
+ height: imageSize(frame.getAttribute("height")) ?? FIXED.height,
138
+ title: (frame.getAttribute("title") ?? "").trim().slice(0, 300),
139
+ border: border !== null && border !== "0" && border.toLowerCase() !== "no",
140
+ scrolling: frame.getAttribute("scrolling")?.toLowerCase() !== "no"
141
+ };
142
+ }
143
+ }
144
+ ],
145
+ toDOM: (node) => {
146
+ const src = embeddableUrl(node.attrs.src, settings.allowUrl);
147
+ if (!src) return ["div", { class: settings.className }];
148
+ const attrs = frameAttrs(node, src, settings);
149
+ const size = sizeOf(node.attrs.size, settings);
150
+ if (!size) {
151
+ attrs.width = String(imageSize(node.attrs.width) ?? FIXED.width);
152
+ attrs.height = String(imageSize(node.attrs.height) ?? FIXED.height);
153
+ return ["div", { class: settings.className }, ["iframe", attrs]];
154
+ }
155
+ const ratio = settings.inlineStyles ? ratioOf(size) : null;
156
+ if (ratio) {
157
+ const percent = Math.round(ratio[1] / ratio[0] * 1e6) / 1e4;
158
+ attrs.style = `position: absolute; top: 0; left: 0; width: 100%; height: 100%${node.attrs.border === true ? "" : "; border: 0"}`;
159
+ return [
160
+ "div",
161
+ {
162
+ class: `${settings.className} ${size}`,
163
+ style: `position: relative; width: 100%; padding-top: ${percent}%; overflow: hidden`
164
+ },
165
+ ["iframe", attrs]
166
+ ];
167
+ }
168
+ return ["div", { class: `${settings.className} ${size}` }, ["iframe", attrs]];
169
+ }
170
+ }
171
+ };
172
+ }
173
+ function pageEmbedView(node, settings) {
174
+ const dom = h("div", { className: "nova-media nova-pageembed-view", contenteditable: "false" });
175
+ const overlay = h("div", { className: "nova-media-overlay", "aria-hidden": "true" });
176
+ let frame = null;
177
+ let shown = null;
178
+ const render = (current) => {
179
+ const src = embeddableUrl(current.attrs.src, settings.allowUrl);
180
+ const size = sizeOf(current.attrs.size, settings);
181
+ const ratio = size ? ratioOf(size) : null;
182
+ dom.classList.toggle("is-responsive", !!size);
183
+ dom.classList.toggle("has-border", current.attrs.border === true);
184
+ if (!src) {
185
+ frame?.remove();
186
+ frame = null;
187
+ shown = null;
188
+ dom.replaceChildren(
189
+ h(
190
+ "div",
191
+ { className: "nova-pageembed-missing" },
192
+ typeof current.attrs.src === "string" ? current.attrs.src : ""
193
+ ),
194
+ overlay
195
+ );
196
+ return;
197
+ }
198
+ if (!frame || shown !== src) {
199
+ const attrs = frameAttrs(current, src, settings);
200
+ frame = h("iframe", {
201
+ src,
202
+ title: attrs.title,
203
+ ...attrs.sandbox === null ? {} : { sandbox: attrs.sandbox },
204
+ allow: "fullscreen",
205
+ loading: "lazy",
206
+ referrerpolicy: "strict-origin-when-cross-origin",
207
+ // Tab stays in the text: the page in the frame is not a stop while editing.
208
+ tabindex: "-1"
209
+ });
210
+ shown = src;
211
+ dom.replaceChildren(frame, overlay);
212
+ }
213
+ frame.title = frameTitle(current.attrs.title, src);
214
+ if (current.attrs.scrolling === false) frame.setAttribute("scrolling", "no");
215
+ else frame.removeAttribute("scrolling");
216
+ if (size) {
217
+ frame.removeAttribute("width");
218
+ frame.removeAttribute("height");
219
+ frame.style.aspectRatio = ratio ? `${ratio[0]} / ${ratio[1]}` : "16 / 9";
220
+ } else {
221
+ frame.style.aspectRatio = "";
222
+ frame.setAttribute("width", String(imageSize(current.attrs.width) ?? FIXED.width));
223
+ frame.setAttribute("height", String(imageSize(current.attrs.height) ?? FIXED.height));
224
+ }
225
+ };
226
+ render(node);
227
+ return {
228
+ dom,
229
+ update(next) {
230
+ if (next.type !== node.type) return false;
231
+ node = next;
232
+ render(next);
233
+ return true;
234
+ },
235
+ ignoreMutation: () => true,
236
+ stopEvent: () => false
237
+ };
238
+ }
239
+ var pageembed_default = definePlugin({
240
+ name: "pageembed",
241
+ toolbar: "pageembed",
242
+ nodes: buildNodes,
243
+ prosemirrorPlugins: (editor) => {
244
+ const settings = pageEmbedOptions(editor);
245
+ return [
246
+ new Plugin({
247
+ props: {
248
+ nodeViews: { pageembed: (node) => pageEmbedView(node, settings) }
249
+ }
250
+ })
251
+ ];
252
+ },
253
+ load: () => import("./pageembed-ui-WOY6VWRJ.js")
254
+ });
255
+
256
+ export {
257
+ FIXED,
258
+ pageEmbedOptions,
259
+ ratioOf,
260
+ embeddableUrl,
261
+ pageembed_default
262
+ };
263
+ //# sourceMappingURL=chunk-NTGEKGXU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/plugins/pageembed.ts"],"sourcesContent":["import type { Node as PMNode, NodeSpec } from 'prosemirror-model';\nimport { Plugin } from 'prosemirror-state';\nimport type { Editor } from '../editor';\nimport { definePlugin } from '../plugins';\nimport { imageSize } from '../schema';\nimport { h } from '../ui/dom';\n\n/**\n * The pageembed plugin: a web page shown in the document, in a frame. `plugins: ['pageembed']`.\n * Here are the node and its view in the editor; the dialog and the button are in pageembed-ui.ts.\n *\n * An embed is a wrapper with a frame: `<div class=\"nova-pageembed …\"><iframe …></iframe></div>`. A\n * sized one (`nova-pageembed--16by9`) fills the width and keeps the ratio, a fixed one has its own\n * width and height.\n *\n * Security: only absolute http(s) addresses are embedded, without a name and password in them,\n * when parsing and on output (a document can come as JSON); `allowUrl` narrows them to your list.\n * An <iframe> on its own isn't embedded, so a pasted web page doesn't bring its frames along. The\n * frame is sandboxed: the page runs its own scripts, forms and popups, but can't navigate the page\n * it is shown on, and gets no camera, microphone or location.\n */\n\nexport interface PageEmbedSize {\n /** The name in the dialog (\"Full width, 16:9\" when left out). */\n text?: string;\n /** The class it adds to the wrapper; \"…--16by9\" fills the width with that ratio. */\n value: string;\n}\n\nexport interface PageEmbedOptions {\n /** The sizes offered besides a fixed one. An empty list: only a fixed size. */\n sizes?: PageEmbedSize[];\n /** Sizes also as inline styles, so the page that shows the HTML needs no CSS for them (yes). */\n inlineStyles?: boolean;\n /** The wrapper's class ('nova-pageembed'). */\n className?: string;\n /** The frame's sandbox (`allow-*` words); false: no sandbox. */\n sandbox?: string | false;\n /** Which addresses may be embedded: every http(s) one by default. */\n allowUrl?: (url: string) => boolean;\n}\n\nexport const DEFAULT_SANDBOX =\n 'allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation';\n\nconst DEFAULT_SIZES: PageEmbedSize[] = ['21by9', '16by9', '4by3', '1by1'].map((ratio) => ({\n value: `nova-pageembed--${ratio}`,\n}));\n\n/** The width and height of a fixed size when the HTML doesn't say. */\nexport const FIXED = { width: 350, height: 260 };\n\nconst CLASS_RE = /^[\\w-]{1,60}$/;\nconst RATIO_RE = /--(\\d{1,3})by(\\d{1,3})$/;\n\n/** The plugin's settings, checked: what is wrong in them falls back to the default. */\nexport function pageEmbedOptions(context: { options: Editor['options'] }): Required<\n Omit<PageEmbedOptions, 'allowUrl'>\n> & {\n allowUrl?: (url: string) => boolean;\n} {\n const raw = (context.options.pluginOptions?.pageembed ?? {}) as PageEmbedOptions;\n const sizes = Array.isArray(raw.sizes)\n ? raw.sizes.filter(\n (size): size is PageEmbedSize =>\n !!size && typeof size.value === 'string' && CLASS_RE.test(size.value),\n )\n : DEFAULT_SIZES;\n const sandbox =\n raw.sandbox === false\n ? false\n : typeof raw.sandbox === 'string'\n ? raw.sandbox\n .split(/\\s+/)\n .filter((word) => /^allow-[a-z-]{1,40}$/.test(word))\n .join(' ')\n : DEFAULT_SANDBOX;\n return {\n sizes,\n inlineStyles: raw.inlineStyles !== false,\n className:\n typeof raw.className === 'string' && CLASS_RE.test(raw.className)\n ? raw.className\n : 'nova-pageembed',\n sandbox,\n allowUrl: typeof raw.allowUrl === 'function' ? raw.allowUrl : undefined,\n };\n}\n\n/** The ratio a size class keeps ([16, 9] for \"…--16by9\"), or null. */\nexport function ratioOf(value: string): [number, number] | null {\n const match = RATIO_RE.exec(value);\n if (!match) return null;\n const width = Number(match[1]);\n const height = Number(match[2]);\n return width > 0 && height > 0 ? [width, height] : null;\n}\n\n/** The address if it may be embedded: absolute http(s), no credentials, allowed by `allowUrl`. */\nexport function embeddableUrl(url: unknown, allowUrl?: (url: string) => boolean): string | null {\n if (typeof url !== 'string') return null;\n const value = url.trim();\n if (value.length > 2000 || !/^https?:\\/\\/[^\\s/?#]/i.test(value)) return null;\n let parsed: URL;\n try {\n parsed = new URL(value);\n } catch {\n return null;\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return null;\n if (parsed.username || parsed.password) return null;\n try {\n if (allowUrl && !allowUrl(parsed.href)) return null;\n } catch {\n return null;\n }\n return value;\n}\n\n/** A name for screen readers: the title, or the site's name. */\nfunction frameTitle(title: unknown, src: string): string {\n if (typeof title === 'string' && title.trim()) return title.trim().slice(0, 300);\n try {\n return new URL(src).hostname;\n } catch {\n return src;\n }\n}\n\ntype Settings = ReturnType<typeof pageEmbedOptions>;\n\n/** The size of a node: one of the configured classes, or '' (fixed). */\nfunction sizeOf(value: unknown, settings: Settings): string {\n return typeof value === 'string' && settings.sizes.some((size) => size.value === value)\n ? value\n : '';\n}\n\n/** The size of a wrapper's classes: a configured class, or one with the same ratio (another editor's). */\nfunction sizeFromClasses(classes: string[], settings: Settings): string {\n const own = classes.find((name) => settings.sizes.some((size) => size.value === name));\n if (own) return own;\n for (const name of classes) {\n const ratio = /^(?:nova|tiny)-pageembed--/.test(name) ? ratioOf(name) : null;\n if (!ratio) continue;\n const same = settings.sizes.find((size) => {\n const other = ratioOf(size.value);\n return !!other && other[0] * ratio[1] === other[1] * ratio[0];\n });\n if (same) return same.value;\n }\n return '';\n}\n\nfunction isWrapper(classes: string[], settings: Settings): boolean {\n return classes.some(\n (name) =>\n name === settings.className ||\n /^(?:nova|tiny)-pageembed(?:--[\\w-]+)?$/.test(name) ||\n settings.sizes.some((size) => size.value === name),\n );\n}\n\nfunction frameAttrs(node: PMNode, src: string, settings: Settings): Record<string, string | null> {\n return {\n src,\n title: frameTitle(node.attrs.title, src),\n sandbox: settings.sandbox === false ? null : settings.sandbox,\n allow: 'fullscreen',\n allowfullscreen: '',\n loading: 'lazy',\n referrerpolicy: 'strict-origin-when-cross-origin',\n frameborder: node.attrs.border === true ? '1' : '0',\n scrolling: node.attrs.scrolling === false ? 'no' : null,\n };\n}\n\nfunction buildNodes(context: { options: Editor['options'] }): Record<string, NodeSpec> {\n const settings = pageEmbedOptions(context);\n return {\n pageembed: {\n group: 'block',\n atom: true,\n selectable: true,\n draggable: true,\n attrs: {\n src: { default: '' },\n size: { default: '' },\n width: { default: FIXED.width },\n height: { default: FIXED.height },\n title: { default: '' },\n border: { default: false },\n scrolling: { default: true },\n },\n parseDOM: [\n {\n tag: 'div',\n // Before element rules (extendedValidElements: 'div[*]') and plain blocks.\n priority: 70,\n getAttrs: (dom) => {\n const el = dom as HTMLElement;\n const classes = [...el.classList];\n if (!isWrapper(classes, settings)) return false;\n const frame = el.querySelector('iframe');\n const src = embeddableUrl(frame?.getAttribute('src'), settings.allowUrl);\n if (!frame || !src) return false;\n const border = frame.getAttribute('frameborder');\n return {\n src,\n size: sizeFromClasses(classes, settings),\n width: imageSize(frame.getAttribute('width')) ?? FIXED.width,\n height: imageSize(frame.getAttribute('height')) ?? FIXED.height,\n title: (frame.getAttribute('title') ?? '').trim().slice(0, 300),\n border: border !== null && border !== '0' && border.toLowerCase() !== 'no',\n scrolling: frame.getAttribute('scrolling')?.toLowerCase() !== 'no',\n };\n },\n },\n ],\n toDOM: (node) => {\n // The document may come from JSON: the address is checked again.\n const src = embeddableUrl(node.attrs.src, settings.allowUrl);\n if (!src) return ['div', { class: settings.className }];\n const attrs = frameAttrs(node, src, settings);\n const size = sizeOf(node.attrs.size, settings);\n if (!size) {\n attrs.width = String(imageSize(node.attrs.width) ?? FIXED.width);\n attrs.height = String(imageSize(node.attrs.height) ?? FIXED.height);\n return ['div', { class: settings.className }, ['iframe', attrs]];\n }\n const ratio = settings.inlineStyles ? ratioOf(size) : null;\n if (ratio) {\n const percent = Math.round((ratio[1] / ratio[0]) * 1e6) / 1e4;\n attrs.style = `position: absolute; top: 0; left: 0; width: 100%; height: 100%${\n node.attrs.border === true ? '' : '; border: 0'\n }`;\n return [\n 'div',\n {\n class: `${settings.className} ${size}`,\n style: `position: relative; width: 100%; padding-top: ${percent}%; overflow: hidden`,\n },\n ['iframe', attrs],\n ];\n }\n return ['div', { class: `${settings.className} ${size}` }, ['iframe', attrs]];\n },\n },\n };\n}\n\n/** The view in the editor: the page in its frame under a layer, so a click selects the block. */\nfunction pageEmbedView(node: PMNode, settings: Settings) {\n const dom = h('div', { className: 'nova-media nova-pageembed-view', contenteditable: 'false' });\n const overlay = h('div', { className: 'nova-media-overlay', 'aria-hidden': 'true' });\n let frame: HTMLIFrameElement | null = null;\n let shown: string | null = null;\n\n const render = (current: PMNode) => {\n const src = embeddableUrl(current.attrs.src, settings.allowUrl);\n const size = sizeOf(current.attrs.size, settings);\n const ratio = size ? ratioOf(size) : null;\n dom.classList.toggle('is-responsive', !!size);\n dom.classList.toggle('has-border', current.attrs.border === true);\n if (!src) {\n frame?.remove();\n frame = null;\n shown = null;\n dom.replaceChildren(\n h(\n 'div',\n { className: 'nova-pageembed-missing' },\n typeof current.attrs.src === 'string' ? current.attrs.src : '',\n ),\n overlay,\n );\n return;\n }\n // The same address: the frame stays (it would load the page again otherwise).\n if (!frame || shown !== src) {\n const attrs = frameAttrs(current, src, settings);\n frame = h('iframe', {\n src,\n title: attrs.title!,\n ...(attrs.sandbox === null ? {} : { sandbox: attrs.sandbox }),\n allow: 'fullscreen',\n loading: 'lazy',\n referrerpolicy: 'strict-origin-when-cross-origin',\n // Tab stays in the text: the page in the frame is not a stop while editing.\n tabindex: '-1',\n }) as HTMLIFrameElement;\n shown = src;\n dom.replaceChildren(frame, overlay);\n }\n frame.title = frameTitle(current.attrs.title, src);\n if (current.attrs.scrolling === false) frame.setAttribute('scrolling', 'no');\n else frame.removeAttribute('scrolling');\n if (size) {\n frame.removeAttribute('width');\n frame.removeAttribute('height');\n frame.style.aspectRatio = ratio ? `${ratio[0]} / ${ratio[1]}` : '16 / 9';\n } else {\n frame.style.aspectRatio = '';\n frame.setAttribute('width', String(imageSize(current.attrs.width) ?? FIXED.width));\n frame.setAttribute('height', String(imageSize(current.attrs.height) ?? FIXED.height));\n }\n };\n render(node);\n\n return {\n dom,\n update(next: PMNode) {\n if (next.type !== node.type) return false;\n node = next;\n render(next);\n return true;\n },\n ignoreMutation: () => true,\n stopEvent: () => false,\n };\n}\n\nexport default definePlugin({\n name: 'pageembed',\n toolbar: 'pageembed',\n nodes: buildNodes,\n prosemirrorPlugins: (editor) => {\n const settings = pageEmbedOptions(editor);\n return [\n new Plugin({\n props: {\n nodeViews: { pageembed: (node) => pageEmbedView(node, settings) },\n },\n }),\n ];\n },\n load: () => import('./pageembed-ui'),\n});\n"],"mappings":";;;;;;;;;;;AACA,SAAS,cAAc;AAyChB,IAAM,kBACX;AAEF,IAAM,gBAAiC,CAAC,SAAS,SAAS,QAAQ,MAAM,EAAE,IAAI,CAAC,WAAW;AAAA,EACxF,OAAO,mBAAmB,KAAK;AACjC,EAAE;AAGK,IAAM,QAAQ,EAAE,OAAO,KAAK,QAAQ,IAAI;AAE/C,IAAM,WAAW;AACjB,IAAM,WAAW;AAGV,SAAS,iBAAiB,SAI/B;AACA,QAAM,MAAO,QAAQ,QAAQ,eAAe,aAAa,CAAC;AAC1D,QAAM,QAAQ,MAAM,QAAQ,IAAI,KAAK,IACjC,IAAI,MAAM;AAAA,IACR,CAAC,SACC,CAAC,CAAC,QAAQ,OAAO,KAAK,UAAU,YAAY,SAAS,KAAK,KAAK,KAAK;AAAA,EACxE,IACA;AACJ,QAAM,UACJ,IAAI,YAAY,QACZ,QACA,OAAO,IAAI,YAAY,WACrB,IAAI,QACD,MAAM,KAAK,EACX,OAAO,CAAC,SAAS,uBAAuB,KAAK,IAAI,CAAC,EAClD,KAAK,GAAG,IACX;AACR,SAAO;AAAA,IACL;AAAA,IACA,cAAc,IAAI,iBAAiB;AAAA,I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,UAAU,OAAO,UAAU,QAAQ,MAAM,MAAM,KAAK,MAAM,MAAM,CAAC;AAAA,IACtF;AAAA,EACF;AACA,SAAO,IAAI;AAEX,SAAO;AAAA,IACL;AAAA,IACA,OAAO,MAAc;AACnB,UAAI,KAAK,SAAS,KAAK,KAAM,QAAO;AACpC,aAAO;AACP,aAAO,IAAI;AACX,aAAO;AAAA,IACT;AAAA,IACA,gBAAgB,MAAM;AAAA,IACtB,WAAW,MAAM;AAAA,EACnB;AACF;AAEA,IAAO,oBAAQ,aAAa;AAAA,EAC1B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,oBAAoB,CAAC,WAAW;AAC9B,UAAM,WAAW,iBAAiB,MAAM;AACxC,WAAO;AAAA,MACL,IAAI,OAAO;AAAA,QACT,OAAO;AAAA,UACL,WAAW,EAAE,WAAW,CAAC,SAAS,cAAc,MAAM,QAAQ,EAAE;AAAA,QAClE;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EACA,MAAM,MAAM,OAAO,4BAAgB;AACrC,CAAC;","names":[]}
@@ -0,0 +1,140 @@
1
+ import {
2
+ definePlugin
3
+ } from "./chunk-V7WUHUHM.js";
4
+
5
+ // nova-raw-css:/home/runner/work/novaprose/novaprose/packages/core/src/plugins/pagelayout.css?raw
6
+ var pagelayout_default = ".nova-pages{--nova-desk: #e6e9ed}[data-theme=dark] .nova-pages{--nova-desk: #010409}@media(prefers-color-scheme:dark){.nova-pages:not([data-theme=light] *){--nova-desk: #010409}}.nova-pages .nova-content{position:relative;padding:24px 12px 32px;background:var(--nova-desk)}.nova-pages .nova-prosemirror{box-sizing:border-box;width:var(--nova-page-width);max-width:100%;min-height:max(var(--nova-page-height),var(--nova-pages-height, 0px));margin:0 auto;padding:var(--nova-page-margins);background:var(--nova-bg);color:var(--nova-fg);box-shadow:0 1px 3px #0000002e,0 8px 24px #00000014}@media(max-width:600px){.nova-pages .nova-content{padding:0}.nova-pages .nova-prosemirror{padding:16px;box-shadow:none}}";
7
+
8
+ // src/plugins/pagelayout.ts
9
+ var PAGE_SIZES = {
10
+ A3: [297, 420],
11
+ A4: [210, 297],
12
+ A5: [148, 210],
13
+ A6: [105, 148],
14
+ Letter: [215.9, 279.4],
15
+ Legal: [215.9, 355.6]
16
+ };
17
+ var DEFAULT_MARGIN = 20;
18
+ function millimetres(value, min, max, fallback) {
19
+ const n = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
20
+ return Number.isFinite(n) ? Math.min(max, Math.max(min, Math.round(n * 10) / 10)) : fallback;
21
+ }
22
+ function bandText(value) {
23
+ return typeof value === "string" ? value.replace(/\s+/g, " ").trim().slice(0, 200) : "";
24
+ }
25
+ function resolveBand(value) {
26
+ let parts = null;
27
+ if (typeof value === "string") parts = { left: "", center: bandText(value), right: "" };
28
+ else if (typeof value === "object" && value !== null) {
29
+ const given = value;
30
+ parts = {
31
+ left: bandText(given.left),
32
+ center: bandText(given.center),
33
+ right: bandText(given.right)
34
+ };
35
+ }
36
+ return parts && (parts.left || parts.center || parts.right) ? parts : null;
37
+ }
38
+ function fillBand(text, page, pages) {
39
+ return text.replace(/\{page\}/g, String(page)).replace(/\{pages\}/g, String(pages));
40
+ }
41
+ function resolvePageLayout(options = {}) {
42
+ const custom = typeof options.size === "object" && options.size !== null;
43
+ const name = !custom && typeof options.size === "string" && options.size in PAGE_SIZES ? options.size : "A4";
44
+ const given = options.size;
45
+ let [width, height] = custom ? [millimetres(given?.width, 30, 2e3, 210), millimetres(given?.height, 30, 2e3, 297)] : PAGE_SIZES[name];
46
+ if (options.orientation === "landscape" || options.orientation === "portrait") {
47
+ const landscape = options.orientation === "landscape";
48
+ const wide = width > height;
49
+ if (landscape !== wide) [width, height] = [height, width];
50
+ }
51
+ const limit = Math.min(width, height) / 3;
52
+ const raw = options.margins;
53
+ const side = (key) => millimetres(
54
+ typeof raw === "object" && raw !== null ? raw[key] : raw,
55
+ 0,
56
+ limit,
57
+ Math.min(DEFAULT_MARGIN, limit)
58
+ );
59
+ return {
60
+ size: custom ? "custom" : name,
61
+ orientation: width > height ? "landscape" : "portrait",
62
+ width,
63
+ height,
64
+ margins: { top: side("top"), right: side("right"), bottom: side("bottom"), left: side("left") },
65
+ header: resolveBand(options.header),
66
+ footer: resolveBand(options.footer),
67
+ differentFirstPage: options.differentFirstPage === true
68
+ };
69
+ }
70
+ var states = /* @__PURE__ */ new WeakMap();
71
+ function notify(state) {
72
+ for (const listener of [...state.listeners]) {
73
+ try {
74
+ listener();
75
+ } catch (error) {
76
+ console.error("[nova] pagelayout: listener failed", error);
77
+ }
78
+ }
79
+ }
80
+ function applyLayout(editor, layout) {
81
+ const { style } = editor.root;
82
+ const { top, right, bottom, left } = layout.margins;
83
+ style.setProperty("--nova-page-width", `${layout.width}mm`);
84
+ style.setProperty("--nova-page-height", `${layout.height}mm`);
85
+ style.setProperty("--nova-page-margins", `${top}mm ${right}mm ${bottom}mm ${left}mm`);
86
+ }
87
+ function pageLayout(editor) {
88
+ const state = states.get(editor);
89
+ if (!state) return void 0;
90
+ return {
91
+ get layout() {
92
+ return state.layout;
93
+ },
94
+ get pages() {
95
+ return state.pages;
96
+ },
97
+ set(options) {
98
+ state.options = { ...state.options, ...options };
99
+ state.layout = resolvePageLayout(state.options);
100
+ applyLayout(editor, state.layout);
101
+ notify(state);
102
+ },
103
+ onChange(listener) {
104
+ state.listeners.add(listener);
105
+ return () => state.listeners.delete(listener);
106
+ }
107
+ };
108
+ }
109
+ function setPageCount(editor, pages) {
110
+ const state = states.get(editor);
111
+ if (!state || state.pages === pages) return;
112
+ state.pages = pages;
113
+ notify(state);
114
+ }
115
+ var pagelayout_default2 = definePlugin({
116
+ name: "pagelayout",
117
+ setup(editor) {
118
+ const options = editor.options.pluginOptions?.pagelayout ?? {};
119
+ const layout = resolvePageLayout(options);
120
+ states.set(editor, { options, layout, pages: null, listeners: /* @__PURE__ */ new Set() });
121
+ editor.ui.addStyles("nova-pagelayout", pagelayout_default);
122
+ editor.root.classList.add("nova-pages");
123
+ applyLayout(editor, layout);
124
+ return () => {
125
+ states.delete(editor);
126
+ editor.root.classList.remove("nova-pages");
127
+ };
128
+ },
129
+ load: () => import("./pagelayout-ui-Y2IM7FJQ.js")
130
+ });
131
+
132
+ export {
133
+ PAGE_SIZES,
134
+ fillBand,
135
+ resolvePageLayout,
136
+ pageLayout,
137
+ setPageCount,
138
+ pagelayout_default2 as pagelayout_default
139
+ };
140
+ //# sourceMappingURL=chunk-OFHGXYG3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["nova-raw-css:/home/runner/work/novaprose/novaprose/packages/core/src/plugins/pagelayout.css?raw","../src/plugins/pagelayout.ts"],"sourcesContent":[".nova-pages{--nova-desk: #e6e9ed}[data-theme=dark] .nova-pages{--nova-desk: #010409}@media(prefers-color-scheme:dark){.nova-pages:not([data-theme=light] *){--nova-desk: #010409}}.nova-pages .nova-content{position:relative;padding:24px 12px 32px;background:var(--nova-desk)}.nova-pages .nova-prosemirror{box-sizing:border-box;width:var(--nova-page-width);max-width:100%;min-height:max(var(--nova-page-height),var(--nova-pages-height, 0px));margin:0 auto;padding:var(--nova-page-margins);background:var(--nova-bg);color:var(--nova-fg);box-shadow:0 1px 3px #0000002e,0 8px 24px #00000014}@media(max-width:600px){.nova-pages .nova-content{padding:0}.nova-pages .nova-prosemirror{padding:16px;box-shadow:none}}","import type { Editor } from '../editor';\nimport { definePlugin } from '../plugins';\nimport css from './pagelayout.css?raw';\n\n/**\n * The pagelayout plugin: page layout. The text sits on a sheet of the exact size with margins, as\n * when printed; page boundaries show right in the text; printing and export use the same sizes.\n *\n * plugins: ['pagelayout'],\n * pluginOptions: { pagelayout: { size: 'A4', orientation: 'portrait', margins: 20 } }\n *\n * This part is the sheet itself (needed from the first frame: a sheet appearing later would shift\n * the whole text) and the settings with pageLayout(editor). Page boundaries are computed in the lazy part, pagelayout-ui.ts.\n */\n\nexport type PageSizeName = 'A3' | 'A4' | 'A5' | 'A6' | 'Letter' | 'Legal';\n\nexport interface PageMargins {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\n/** Text in a page margin: one string (centered), or parts at the left, the center and the right. */\nexport type PageBand = string | { left?: string; center?: string; right?: string };\n\nexport interface PageLayoutOptions {\n /** Sheet size: 'A4' (default), 'A3', 'A5', 'A6', 'Letter', 'Legal' or { width, height } in mm. */\n size?: PageSizeName | { width: number; height: number };\n /** Orientation; without it, portrait for standard sizes and as given for your own size. */\n orientation?: 'portrait' | 'landscape';\n /** Margins in mm: one number for all sides, or per side. Default 20. */\n margins?: number | Partial<PageMargins>;\n /**\n * Text in the top margin of every page: one string (centered) or { left, center, right }.\n * `{page}` and `{pages}` become the page number and the number of pages: 'Page {page} of {pages}'.\n */\n header?: PageBand;\n /** Text in the bottom margin of every page, like `header`. */\n footer?: PageBand;\n /** The first page without header and footer (a title page), as \"Different first page\" in Word. */\n differentFirstPage?: boolean;\n}\n\n/** A header or footer: its three parts, '' where there is nothing. */\nexport interface PageBandParts {\n left: string;\n center: string;\n right: string;\n}\n\n/** The sheet in mm (orientation already applied), the margins and the header and footer. */\nexport interface PageLayout {\n size: PageSizeName | 'custom';\n orientation: 'portrait' | 'landscape';\n width: number;\n height: number;\n margins: PageMargins;\n /** null when there is none. */\n header: PageBandParts | null;\n footer: PageBandParts | null;\n differentFirstPage: boolean;\n}\n\n/** Sheet sizes in mm (portrait). */\nexport const PAGE_SIZES: Readonly<Record<PageSizeName, readonly [number, number]>> = {\n A3: [297, 420],\n A4: [210, 297],\n A5: [148, 210],\n A6: [105, 148],\n Letter: [215.9, 279.4],\n Legal: [215.9, 355.6],\n};\n\nconst DEFAULT_MARGIN = 20;\n\nfunction millimetres(value: unknown, min: number, max: number, fallback: number): number {\n const n = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : NaN;\n return Number.isFinite(n) ? Math.min(max, Math.max(min, Math.round(n * 10) / 10)) : fallback;\n}\n\n/** One line of plain text, at most 200 characters; anything but a string gives ''. */\nfunction bandText(value: unknown): string {\n return typeof value === 'string' ? value.replace(/\\s+/g, ' ').trim().slice(0, 200) : '';\n}\n\n/** A header or footer setting → its parts; null when it has no text. */\nexport function resolveBand(value: unknown): PageBandParts | null {\n let parts: PageBandParts | null = null;\n if (typeof value === 'string') parts = { left: '', center: bandText(value), right: '' };\n else if (typeof value === 'object' && value !== null) {\n const given = value as Record<string, unknown>;\n parts = {\n left: bandText(given.left),\n center: bandText(given.center),\n right: bandText(given.right),\n };\n }\n return parts && (parts.left || parts.center || parts.right) ? parts : null;\n}\n\n/** `{page}` and `{pages}` in a header or footer replaced with numbers (for the screen and for Word previews). */\nexport function fillBand(text: string, page: number, pages: number): string {\n return text.replace(/\\{page\\}/g, String(page)).replace(/\\{pages\\}/g, String(pages));\n}\n\n/** Settings → the sheet. Garbage from the config gets the defaults; a margin is at most a third of the sheet. */\nexport function resolvePageLayout(options: PageLayoutOptions = {}): PageLayout {\n const custom = typeof options.size === 'object' && options.size !== null;\n const name: PageSizeName =\n !custom && typeof options.size === 'string' && options.size in PAGE_SIZES\n ? (options.size as PageSizeName)\n : 'A4';\n const given = options.size as { width?: unknown; height?: unknown } | undefined;\n let [width, height] = custom\n ? [millimetres(given?.width, 30, 2000, 210), millimetres(given?.height, 30, 2000, 297)]\n : PAGE_SIZES[name];\n if (options.orientation === 'landscape' || options.orientation === 'portrait') {\n const landscape = options.orientation === 'landscape';\n const wide = width > height;\n if (landscape !== wide) [width, height] = [height, width];\n }\n const limit = Math.min(width, height) / 3;\n const raw = options.margins;\n const side = (key: keyof PageMargins) =>\n millimetres(\n typeof raw === 'object' && raw !== null ? raw[key] : raw,\n 0,\n limit,\n Math.min(DEFAULT_MARGIN, limit),\n );\n return {\n size: custom ? 'custom' : name,\n orientation: width > height ? 'landscape' : 'portrait',\n width,\n height,\n margins: { top: side('top'), right: side('right'), bottom: side('bottom'), left: side('left') },\n header: resolveBand(options.header),\n footer: resolveBand(options.footer),\n differentFirstPage: options.differentFirstPage === true,\n };\n}\n\nexport interface PageLayoutController {\n /** The current sheet (mm). */\n readonly layout: PageLayout;\n /**\n * How many pages the document has. null — not counted yet, or the sheet is narrower than the page\n * (a narrow screen: lines wrap differently than in print).\n */\n readonly pages: number | null;\n /** Change the size, orientation or margins (the rest stays). */\n set(options: PageLayoutOptions): void;\n /** The sheet or the page count changed. Returns an unsubscribe function. */\n onChange(listener: () => void): () => void;\n}\n\ninterface State {\n options: PageLayoutOptions;\n layout: PageLayout;\n pages: number | null;\n listeners: Set<() => void>;\n}\n\nconst states = new WeakMap<Editor, State>();\n\nfunction notify(state: State): void {\n for (const listener of [...state.listeners]) {\n try {\n listener();\n } catch (error) {\n console.error('[nova] pagelayout: listener failed', error);\n }\n }\n}\n\nfunction applyLayout(editor: Editor, layout: PageLayout): void {\n const { style } = editor.root;\n const { top, right, bottom, left } = layout.margins;\n style.setProperty('--nova-page-width', `${layout.width}mm`);\n style.setProperty('--nova-page-height', `${layout.height}mm`);\n style.setProperty('--nova-page-margins', `${top}mm ${right}mm ${bottom}mm ${left}mm`);\n}\n\n/** The editor's page layout (the pagelayout plugin); undefined when the plugin isn't active. */\nexport function pageLayout(editor: Editor): PageLayoutController | undefined {\n const state = states.get(editor);\n if (!state) return undefined;\n return {\n get layout() {\n return state.layout;\n },\n get pages() {\n return state.pages;\n },\n set(options) {\n state.options = { ...state.options, ...options };\n state.layout = resolvePageLayout(state.options);\n applyLayout(editor, state.layout);\n notify(state);\n },\n onChange(listener) {\n state.listeners.add(listener);\n return () => state.listeners.delete(listener);\n },\n };\n}\n\n/** For the lazy part: the number of pages has been computed. */\nexport function setPageCount(editor: Editor, pages: number | null): void {\n const state = states.get(editor);\n if (!state || state.pages === pages) return;\n state.pages = pages;\n notify(state);\n}\n\nexport default definePlugin({\n name: 'pagelayout',\n setup(editor) {\n const options = (editor.options.pluginOptions?.pagelayout ?? {}) as PageLayoutOptions;\n const layout = resolvePageLayout(options);\n states.set(editor, { options, layout, pages: null, listeners: new Set() });\n editor.ui.addStyles('nova-pagelayout', css);\n editor.root.classList.add('nova-pages');\n applyLayout(editor, layout);\n return () => {\n states.delete(editor);\n editor.root.classList.remove('nova-pages');\n };\n },\n load: () => import('./pagelayout-ui'),\n});\n"],"mappings":";;;;;AAAA;;;ACkEO,IAAM,aAAwE;AAAA,EACnF,IAAI,CAAC,KAAK,GAAG;AAAA,EACb,IAAI,CAAC,KAAK,GAAG;AAAA,EACb,IAAI,CAAC,KAAK,GAAG;AAAA,EACb,IAAI,CAAC,KAAK,GAAG;AAAA,EACb,QAAQ,CAAC,OAAO,KAAK;AAAA,EACrB,OAAO,CAAC,OAAO,KAAK;AACtB;AAEA,IAAM,iBAAiB;AAEvB,SAAS,YAAY,OAAgB,KAAa,KAAa,UAA0B;AACvF,QAAM,IAAI,OAAO,UAAU,WAAW,QAAQ,OAAO,UAAU,WAAW,OAAO,KAAK,IAAI;AAC1F,SAAO,OAAO,SAAS,CAAC,IAAI,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,MAAM,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI;AACtF;AAGA,SAAS,SAAS,OAAwB;AACxC,SAAO,OAAO,UAAU,WAAW,MAAM,QAAQ,QAAQ,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,IAAI;AACvF;AAGO,SAAS,YAAY,OAAsC;AAChE,MAAI,QAA8B;AAClC,MAAI,OAAO,UAAU,SAAU,SAAQ,EAAE,MAAM,IAAI,QAAQ,SAAS,KAAK,GAAG,OAAO,GAAG;AAAA,WAC7E,OAAO,UAAU,YAAY,UAAU,MAAM;AACpD,UAAM,QAAQ;AACd,YAAQ;AAAA,MACN,MAAM,SAAS,MAAM,IAAI;AAAA,MACzB,QAAQ,SAAS,MAAM,MAAM;AAAA,MAC7B,OAAO,SAAS,MAAM,KAAK;AAAA,IAC7B;AAAA,EACF;AACA,SAAO,UAAU,MAAM,QAAQ,MAAM,UAAU,MAAM,SAAS,QAAQ;AACxE;AAGO,SAAS,SAAS,MAAc,MAAc,OAAuB;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BAAQ,aAAa;AAAA,EAC1B,MAAM;AAAA,EACN,MAAM,QAAQ;AACZ,UAAM,UAAW,OAAO,QAAQ,eAAe,cAAc,CAAC;AAC9D,UAAM,SAAS,kBAAkB,OAAO;AACxC,WAAO,IAAI,QAAQ,EAAE,SAAS,QAAQ,OAAO,MAAM,WAAW,oBAAI,IAAI,EAAE,CAAC;AACzE,WAAO,GAAG,UAAU,mBAAmB,kBAAG;AAC1C,WAAO,KAAK,UAAU,IAAI,YAAY;AACtC,gBAAY,QAAQ,MAAM;AAC1B,WAAO,MAAM;AACX,aAAO,OAAO,MAAM;AACpB,aAAO,KAAK,UAAU,OAAO,YAAY;AAAA,IAC3C;AAAA,EACF;AAAA,EACA,MAAM,MAAM,OAAO,6BAAiB;AACtC,CAAC;","names":["pagelayout_default"]}
@@ -0,0 +1,28 @@
1
+ // src/html-rules-api.ts
2
+ var OWN_STYLE = "data-nova-own-style";
3
+ var registered = null;
4
+ function registerHtmlRules(module) {
5
+ registered = module;
6
+ }
7
+ var warned = false;
8
+ function htmlRulesFor(options) {
9
+ const needed = !!options.extendedValidElements || !!options.customElements || /\[/.test(options.validElements ?? "");
10
+ if (!needed) return null;
11
+ if (!registered) {
12
+ if (!warned) {
13
+ warned = true;
14
+ console.warn(
15
+ "[nova] attribute lists, extendedValidElements and customElements need: import { htmlRules } from '@novaprose/core/html-rules'; registerHtmlRules(htmlRules);"
16
+ );
17
+ }
18
+ return null;
19
+ }
20
+ return registered.create(options);
21
+ }
22
+
23
+ export {
24
+ OWN_STYLE,
25
+ registerHtmlRules,
26
+ htmlRulesFor
27
+ };
28
+ //# sourceMappingURL=chunk-OOVNE6MB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/html-rules-api.ts"],"sourcesContent":["import type { MarkSpec, NodeSpec, Schema } from 'prosemirror-model';\n\n/**\n * The hook for element and attribute rules. The implementation is a separate import,\n * `@novaprose/core/html-rules` (~3 KB gzip): few need it, so it isn't part of the first load.\n *\n * import { registerHtmlRules } from '@novaprose/core';\n * import { htmlRules } from '@novaprose/core/html-rules';\n * registerHtmlRules(htmlRules);\n */\n\nexport interface HtmlRulesOptions {\n /** Only these elements are allowed; attributes in [...] are the complete list for the element. */\n validElements?: string;\n /** More elements and attributes: 'div[class],h2[id],i[class],a[href|rel|data-*]'. */\n extendedValidElements?: string;\n /** Disallowed elements. */\n invalidElements?: string;\n /** Your own elements: 'my-widget,~my-chip' (~ — inline, like span; without ~ — a block, like div). */\n customElements?: string;\n}\n\n/** The node and mark specs the document schema is built from; HTML rules change them before that. */\nexport interface SchemaSpecs {\n nodes: Record<string, NodeSpec>;\n marks: Record<string, MarkSpec>;\n}\n\n/** The rules of one editor: they change the schema specs. */\nexport interface HtmlRulesInstance {\n /** Whether the rules allow class on a built-in element (then classes are kept). */\n readonly classOnBuiltIn: boolean;\n /** Specs with the rules applied; after the schema is created, store it in `ref.schema`. */\n apply(specs: SchemaSpecs, ref: { schema?: Schema }): SchemaSpecs;\n}\n\nexport interface HtmlRulesModule {\n create(options: HtmlRulesOptions): HtmlRulesInstance | null;\n}\n\n/** A service attribute: the parser moves the own style of new elements (div, abbr…) here. */\nexport const OWN_STYLE = 'data-nova-own-style';\n\nlet registered: HtmlRulesModule | null = null;\n\n/** Install the element and attribute rules (once per page). */\nexport function registerHtmlRules(module: HtmlRulesModule): void {\n registered = module;\n}\n\nlet warned = false;\n\n/** Rules for the editor's options, or null (the options need no rules / the module isn't attached). */\nexport function htmlRulesFor(options: HtmlRulesOptions): HtmlRulesInstance | null {\n const needed =\n !!options.extendedValidElements ||\n !!options.customElements ||\n /\\[/.test(options.validElements ?? '');\n if (!needed) return null;\n if (!registered) {\n if (!warned) {\n warned = true;\n console.warn(\n \"[nova] attribute lists, extendedValidElements and customElements need: import { htmlRules } from '@novaprose/core/html-rules'; registerHtmlRules(htmlRules);\",\n );\n }\n return null;\n }\n return registered.create(options);\n}\n"],"mappings":";AAyCO,IAAM,YAAY;AAEzB,IAAI,aAAqC;AAGlC,SAAS,kBAAkB,QAA+B;AAC/D,eAAa;AACf;AAEA,IAAI,SAAS;AAGN,SAAS,aAAa,SAAqD;AAChF,QAAM,SACJ,CAAC,CAAC,QAAQ,yBACV,CAAC,CAAC,QAAQ,kBACV,KAAK,KAAK,QAAQ,iBAAiB,EAAE;AACvC,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,CAAC,YAAY;AACf,QAAI,CAAC,QAAQ;AACX,eAAS;AACT,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACA,SAAO,WAAW,OAAO,OAAO;AAClC;","names":[]}
@@ -0,0 +1,7 @@
1
+ // src/meta.ts
2
+ var SET_CONTENT_META = "nova:set-content";
3
+
4
+ export {
5
+ SET_CONTENT_META
6
+ };
7
+ //# sourceMappingURL=chunk-OQMMHWMZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/meta.ts"],"sourcesContent":["/**\n * Transaction markers shared by the editor and first-load plugins. A module of its own, so a plugin\n * can read them without importing the editor (and everything it brings) into the server's imports.\n */\n\n/** setContent: a document is loaded, not edited (suggesting mode doesn't track it). */\nexport const SET_CONTENT_META = 'nova:set-content';\n"],"mappings":";AAMO,IAAM,mBAAmB;","names":[]}