@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 @@
1
+ {"version":3,"sources":["../src/paste.ts","../src/ui/menubar.ts","../src/ui/menu-items.ts","../src/ui/toolbar.ts","../src/ui/slash.ts","../src/ui/statusbar.ts","../src/editor.ts","../src/first-click.ts","../src/announce.ts","../src/deprecations.ts","../src/inputrules.ts","../src/text-patterns.ts","../src/keymap.ts","../src/plugin-views.ts","../src/chain.ts","../src/selection.ts","../src/ui/context-toolbar.ts","../src/ui/image-view.ts","../src/ui/autocompleter.ts","../src/ui/notification.ts","../src/ui/registry.ts","../src/ui/sidebar.ts","nova-raw-css:/home/runner/work/novaprose/novaprose/packages/core/src/ui/editor-views.css?raw","../src/ui/editor-views.ts","../src/ui/tooltip.ts","../src/ui/manager.ts"],"sourcesContent":["import { Fragment, Slice } from 'prosemirror-model';\nimport { Plugin, PluginKey } from 'prosemirror-state';\nimport type { EditorView } from 'prosemirror-view';\nimport { codeLanguage } from './code-language';\nimport type { Editor } from './editor';\nimport type * as PasteOffice from './paste-office';\nimport type { PasteStyles } from './paste-office';\n\n/**\n * Office/Google paste cleanup (~11 KB) is a separate chunk: it is needed only at the moment of pasting.\n * It loads in the background right after the editor is created (and is part of `editor.ready`), so by the first\n * Ctrl+V it is usually ready. If a paste happens earlier, handleDOMEvents.paste below waits for it.\n */\ntype PasteCleaner = typeof PasteOffice;\n\n/** Whether the HTML has images with local file: links (a sign of Word images, the data is in the RTF). */\nfunction hasLocalFileImages(html: string): boolean {\n return /<img[^>]+src=[\"']?file:/i.test(html);\n}\nlet cleaner: PasteCleaner | null = null;\nlet loading: Promise<PasteCleaner | null> | null = null;\n\nexport function loadPasteCleaner(): Promise<PasteCleaner | null> {\n loading ??= import('./paste-office').then(\n (module) => (cleaner = module),\n () => {\n // The network failed: try again on the next paste, and paste without Office cleanup for now.\n loading = null;\n return null;\n },\n );\n return loading;\n}\n\n/**\n * Paste handling:\n * - \"Paste as text\" mode (the pastetext toggle): any content is pasted without formatting;\n * - Ctrl/Cmd+Shift+V pastes once without formatting (ProseMirror itself hands over text/plain when\n * Shift is held; we only make sure the HTML branch doesn't take it);\n * - the pastePreprocess (HTML string before parsing) and pastePostprocess (DOM after the browser parsed it) hooks.\n */\n\nexport interface PasteOptions {\n /** Change the HTML before it is parsed: return a new string. */\n pastePreprocess?: (html: string, editor: Editor) => string;\n /** Change the DOM after it is parsed: nodes can be removed or changed in place. */\n pastePostprocess?: (fragment: HTMLElement, editor: Editor) => void;\n /** Start in \"paste as text\" mode. */\n pasteAsText?: boolean;\n /**\n * Formatting when pasting from Word, Google Docs, Excel and web pages. 'clean' (default) keeps\n * bold, italic, colors, lists, tables and links, but not the source document's font, size and\n * spacing; 'keep' brings those too.\n */\n pasteStyles?: PasteStyles;\n}\n\nconst key = new PluginKey('nova-paste');\n\n/** Turns HTML into plain text, keeping paragraphs (for \"paste as text\" mode). */\nexport function htmlToPlainText(html: string): string {\n const template = document.createElement('template');\n template.innerHTML = html;\n const blocks = /^(P|DIV|H[1-6]|LI|BLOCKQUOTE|PRE|TR|SECTION|ARTICLE|HEADER|FOOTER)$/;\n let out = '';\n const walk = (node: Node) => {\n if (node.nodeType === Node.TEXT_NODE) {\n out += (node.textContent ?? '').replace(/\\s+/g, ' ');\n return;\n }\n if (!(node instanceof Element)) {\n node.childNodes.forEach(walk);\n return;\n }\n if (/^(SCRIPT|STYLE|META|TITLE|HEAD)$/.test(node.tagName)) return;\n if (node.tagName === 'BR') {\n out += '\\n';\n return;\n }\n const block = blocks.test(node.tagName);\n if (block && out && !out.endsWith('\\n')) out += '\\n';\n node.childNodes.forEach(walk);\n if (block) out += '\\n';\n };\n template.content.childNodes.forEach(walk);\n return out\n .split('\\n')\n .map((line) => line.trim())\n .join('\\n')\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim();\n}\n\nexport function pastePlugin(editor: Editor): Plugin {\n // A recursion guard flag: pasteText itself triggers paste handling.\n let reentrant = false;\n return new Plugin({\n key,\n props: {\n /**\n * Pasting into an empty paragraph replaces it entirely: otherwise the first pasted paragraph \"merges\" with\n * the empty one and loses its formatting (alignment, spacing, block type). Into a non-empty paragraph\n * it works as usual: the first paragraph continues the current one, as in Word.\n */\n transformPasted(slice, view) {\n const { selection } = view.state;\n const parent = selection.$from.parent;\n if (\n slice.openStart > 0 &&\n selection.empty &&\n parent.isTextblock &&\n parent.content.size === 0 &&\n slice.content.firstChild?.isBlock\n ) {\n return new Slice(slice.content, 0, slice.openEnd);\n }\n return slice;\n },\n transformPastedHTML(html) {\n const { pastePreprocess, pastePostprocess, pasteStyles } = editor.options;\n let result = pastePreprocess ? pastePreprocess(html, editor) : html;\n // Cleans up Word, Google Docs, Excel and similar markup (copying inside the editor is left alone).\n // The schema and the sanitizer work without it too: security doesn't depend on this chunk.\n if (cleaner) result = cleaner.cleanPastedHTML(result, pasteStyles ?? 'clean');\n if (pastePostprocess) {\n // Parsing in a <template> is inert: scripts don't run, images don't load.\n const template = document.createElement('template');\n template.innerHTML = result;\n const container = document.createElement('div');\n container.append(template.content);\n pastePostprocess(container, editor);\n result = container.innerHTML;\n }\n return result;\n },\n handleDOMEvents: {\n /**\n * HTML pasted before the cleanup has loaded (the first milliseconds after creation or\n * a slow network): take the clipboard data now (after the event it is gone), wait for the chunk\n * and paste as usual, through transformPastedHTML, this time with the cleanup.\n */\n paste(view, event) {\n if (cleaner || reentrant || editor.isPasteAsText()) return false;\n const data = event.clipboardData;\n // From the code editor: its own path (handlePaste), no Office cleanup needed there.\n if (data?.getData(VSCODE_DATA)) return false;\n const html = data?.getData('text/html');\n if (!html) return false;\n const rtf = hasLocalFileImages(html) ? (data?.getData('text/rtf') ?? '') : '';\n event.preventDefault();\n void loadPasteCleaner().then(() => {\n if (view.isDestroyed) return;\n // RTF images are read by the cleanup chunk (it has just loaded, or failed to).\n const withImages =\n rtf && cleaner && editor.isAllowed('image')\n ? cleaner.replaceLocalImages(html, cleaner.extractRtfImages(rtf))\n : html;\n reentrant = true;\n try {\n view.pasteHTML(withImages);\n } finally {\n reentrant = false;\n }\n });\n return true;\n },\n },\n handlePaste(view, event, slice) {\n if (reentrant) return false;\n const pasteText = (text: string) => {\n reentrant = true;\n try {\n view.pasteText(text);\n } finally {\n reentrant = false;\n }\n };\n if (pasteFromCodeEditor(view, event, editor, pasteText)) return true;\n // An empty string (not only null) also means \"no data\": in Firefox the clipboardData\n // of a synthetic event is empty but exists.\n const html = event.clipboardData?.getData('text/html');\n\n if (!editor.isPasteAsText()) {\n // Images from desktop Word: the HTML has unreachable file: paths, the data is in the RTF.\n const rtf =\n html && hasLocalFileImages(html) ? event.clipboardData?.getData('text/rtf') : '';\n // The cleanup chunk is loaded here (before it is, the paste handler above takes the paste).\n if (!html || !rtf || !cleaner || !editor.isAllowed('image')) return false;\n const withImages = cleaner.replaceLocalImages(html, cleaner.extractRtfImages(rtf));\n if (withImages === html) return false;\n reentrant = true;\n try {\n view.pasteHTML(withImages, event);\n } finally {\n reentrant = false;\n }\n return true;\n }\n\n const text = html\n ? htmlToPlainText(html)\n : event.clipboardData?.getData('text/plain') ||\n slice.content.textBetween(0, slice.content.size, '\\n\\n');\n if (!text) return false;\n pasteText(text);\n return true;\n },\n },\n });\n}\n\n/** Metadata that VS Code (and editors based on it) puts on the clipboard along with code. */\nconst VSCODE_DATA = 'vscode-editor-data';\n\n/** VS Code languages whose names differ from the usual ones in `language-…`. */\nconst VSCODE_LANGUAGES: Record<string, string> = {\n shellscript: 'bash',\n typescriptreact: 'tsx',\n javascriptreact: 'jsx',\n jsonc: 'json',\n};\n\n/**\n * Paste from VS Code: the clipboard HTML has markup with the colors and font of the editor theme, which the\n * document doesn't need. Several lines of code become a code block with the file's language; one line, Markdown and plain\n * text become regular text (without the theme colors).\n */\nfunction pasteFromCodeEditor(\n view: EditorView,\n event: ClipboardEvent,\n editor: Editor,\n pasteText: (text: string) => void,\n): boolean {\n const data = event.clipboardData;\n const meta = data?.getData(VSCODE_DATA);\n const raw = data?.getData('text/plain');\n if (!meta || !raw) return false;\n // Inside a code block ProseMirror pastes plain text anyway.\n if (view.state.selection.$from.parent.type.spec.code) return false;\n let mode: unknown;\n try {\n mode = (JSON.parse(meta) as { mode?: unknown }).mode;\n } catch {\n // Not JSON: the language is unknown, paste as code without a language.\n }\n // Markdown becomes formatting when the markdown plugin is on: its own handlePaste takes it.\n if (mode === 'markdown' && editor.hasPlugin('markdown') && !editor.isPasteAsText()) return false;\n // A whole copied line (Ctrl+C without a selection) ends with a line break, which is extra.\n const text = raw.replace(/\\r\\n?/g, '\\n').replace(/\\n$/, '');\n const codeBlock = view.state.schema.nodes.code_block;\n if (\n !text.includes('\\n') ||\n mode === 'markdown' ||\n mode === 'plaintext' ||\n editor.isPasteAsText() ||\n !codeBlock ||\n !editor.isAllowed('codeblock')\n ) {\n pasteText(text);\n return true;\n }\n const language =\n typeof mode === 'string'\n ? Object.hasOwn(VSCODE_LANGUAGES, mode)\n ? VSCODE_LANGUAGES[mode]\n : codeLanguage(mode)\n : null;\n const block = codeBlock.create({ language }, view.state.schema.text(text));\n view.dispatch(\n view.state.tr\n .replaceSelection(new Slice(Fragment.from(block), 0, 0))\n .setMeta('uiEvent', 'paste')\n .scrollIntoView(),\n );\n return true;\n}\n","import type { Editor } from '../editor';\nimport type { MessageKey } from '../i18n';\nimport { activeElement, h, logicalKey } from './dom';\nimport { createMenu, focusMenu, type MenuEntry } from './menu';\nimport type { Popover } from './popover';\n\nexport interface MenuDefinition {\n /** The menu title (a string) or a translation key. */\n title: string;\n /** Items separated by spaces, '|' is a separator: 'undo redo | searchreplace'. */\n items: string;\n}\n\n/** The standard menus. Item names come from the registry of menu items or toolbar buttons. */\nexport const DEFAULT_MENUS: Record<string, MenuDefinition> = {\n file: {\n title: 'menu.file',\n items: 'save cancel | fullpagehtml | importword exportword exportpdf | preview | print',\n },\n edit: { title: 'menu.edit', items: 'undo redo | selectall | searchreplace pastetext' },\n view: { title: 'menu.view', items: 'code preview | fullscreen | visualblocks visualchars' },\n insert: {\n title: 'menu.insert',\n items: 'image link media pageembed inserttable hr | insertdatetime template footnotes',\n },\n format: {\n title: 'menu.format',\n items:\n 'bold italic underline strikethrough superscript subscript inlinecode | ' +\n 'paragraph h1 h2 h3 blockquote codeblock | alignleft aligncenter alignright alignjustify | ' +\n 'lowercase uppercase titlecase | formatpainter permanentpen configurepermanentpen | removeformat',\n },\n table: {\n title: 'menu.table',\n items:\n 'inserttable | tableinsertrowbefore tableinsertrowafter tabledeleterow | ' +\n 'tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | ' +\n 'advtablesort advtablerownumbering | tabledelete',\n },\n // Not in the default menu bar: its items come from plugins (spellchecker, autocorrect, a11ychecker).\n tools: {\n title: 'menu.tools',\n items:\n 'spellchecker spellcheckdialog | autocorrect capitalization typography | linkchecker a11ycheck',\n },\n help: { title: 'menu.help', items: 'help' },\n};\n\nexport const DEFAULT_MENUBAR = 'file edit view insert format table help';\n\nexport interface MenubarHandle {\n focus(): void;\n destroy(): void;\n}\n\n/**\n * The menubar per WAI-ARIA menubar: Alt+F9 focuses it, the ←/→ arrows go to neighboring menus (with a menu open\n * too), ↓/Enter opens, Esc closes and returns to the text.\n */\nexport function createMenubar(\n editor: Editor,\n host: HTMLElement,\n config: string,\n menus: Record<string, MenuDefinition>,\n): MenubarHandle {\n const { t } = editor.ui;\n host.className = 'nova-menubar';\n host.setAttribute('role', 'menubar');\n host.setAttribute('aria-label', t('menu.label'));\n const listeners = new AbortController();\n const { signal } = listeners;\n\n const title = (def: MenuDefinition) =>\n def.title.startsWith('menu.') ? t(def.title as MessageKey) : def.title;\n\n /** Menu items: unknown/forbidden ones are skipped, extra separators removed. */\n const entries = (def: MenuDefinition): MenuEntry[] => {\n const out: MenuEntry[] = [];\n for (const token of def.items.split(/\\s+/)) {\n if (!token) continue;\n if (token === '|') {\n if (out.length && out[out.length - 1]!.type !== 'separator')\n out.push({ type: 'separator' });\n continue;\n }\n if (!editor.isAllowed(token)) continue;\n const item = editor.ui.registry.getMenuItem(token);\n if (!item) continue;\n out.push({\n id: token,\n label: item.text,\n ...(item.icon ? { icon: item.icon } : {}),\n ...(item.shortcut ? { shortcut: item.shortcut } : {}),\n ...(item.isActive ? { active: item.isActive(editor), checkbox: true } : {}),\n disabled: !editor.isEditable() || (item.isEnabled ? !item.isEnabled(editor) : false),\n onSelect: () => item.onAction(editor),\n });\n }\n while (out.length && out[out.length - 1]!.type === 'separator') out.pop();\n return out;\n };\n\n const buttons: HTMLButtonElement[] = [];\n let open: { index: number; popover: Popover } | null = null;\n\n const close = () => {\n open?.popover.close();\n open = null;\n };\n\n const openMenu = (index: number, focusFirst: boolean) => {\n close();\n const button = buttons[index]!;\n const def = menus[button.dataset.menu!]!;\n const items = entries(def);\n if (!items.length) return;\n const menu = createMenu(items, () => editor.ui.closePopover(), title(def));\n // ←/→ inside an open menu go to the neighboring menu (standard menubar behavior).\n menu.addEventListener('keydown', (event) => {\n const key = logicalKey(event, menu);\n if (key !== 'ArrowLeft' && key !== 'ArrowRight') return;\n event.preventDefault();\n const next = (index + (key === 'ArrowRight' ? 1 : -1) + buttons.length) % buttons.length;\n openMenu(next, true);\n });\n button.setAttribute('aria-expanded', 'true');\n const popover = editor.ui.openPopover({\n anchor: button,\n content: menu,\n ignore: [host],\n className: 'nova-popover-menu',\n onClose: (reason) => {\n button.setAttribute('aria-expanded', 'false');\n if (open?.popover === popover) open = null;\n if (reason === 'escape') button.focus();\n },\n });\n open = { index, popover };\n if (focusFirst) focusMenu(menu);\n };\n\n for (const name of config.split(/\\s+/).filter(Boolean)) {\n const def = menus[name];\n if (!def) continue;\n const button = h(\n 'button',\n {\n type: 'button',\n className: 'nova-menubar-item',\n role: 'menuitem',\n 'aria-haspopup': 'menu',\n 'aria-expanded': 'false',\n 'data-menu': name,\n tabindex: buttons.length === 0 ? '0' : '-1',\n },\n title(def),\n );\n const index = buttons.length;\n button.addEventListener('click', (event) => {\n if (open?.index === index) return close();\n openMenu(index, event.detail === 0);\n });\n // With a menu open, hovering over a neighboring title switches the menu (as in desktop applications).\n button.addEventListener('mouseenter', () => {\n if (open && open.index !== index) openMenu(index, false);\n });\n buttons.push(button);\n host.append(button);\n }\n\n host.addEventListener(\n 'keydown',\n (event) => {\n const index = buttons.indexOf(activeElement(host) as HTMLButtonElement);\n if (index < 0) return;\n const move = (to: number) => {\n event.preventDefault();\n const next = (to + buttons.length) % buttons.length;\n buttons.forEach((b, i) => (b.tabIndex = i === next ? 0 : -1));\n buttons[next]!.focus();\n };\n const key = logicalKey(event, host);\n if (key === 'ArrowRight') move(index + 1);\n else if (key === 'ArrowLeft') move(index - 1);\n else if (event.key === 'Home') move(0);\n else if (event.key === 'End') move(buttons.length - 1);\n else if (event.key === 'ArrowDown') {\n event.preventDefault();\n openMenu(index, true);\n } else if (event.key === 'Escape') {\n event.preventDefault();\n editor.focus();\n }\n },\n { signal },\n );\n // A mouse click doesn't take focus from the text, otherwise the selection disappears.\n host.addEventListener(\n 'mousedown',\n (event) => {\n if ((event.target as HTMLElement).closest('button')) event.preventDefault();\n },\n { signal },\n );\n\n return {\n focus: () => (buttons.find((b) => b.tabIndex === 0) ?? buttons[0])?.focus(),\n destroy: () => {\n close();\n listeners.abort();\n host.replaceChildren();\n },\n };\n}\n","import { AllSelection } from 'prosemirror-state';\nimport type { Editor } from '../editor';\nimport { insertTable } from '../tables';\nimport { textField } from './dialog';\nimport { h } from './dom';\nimport { icons } from './icons';\n\n/**\n * Print what the editor shows (with node views and the page's styles; with page layout, the same\n * sheet). The print module is lazy: it loads on the first print.\n */\nexport function printContent(editor: Editor): void {\n void import('./print').then(\n (module) => module.print(editor),\n (error: unknown) => console.error('[nova] print: could not load the print module', error),\n );\n}\n\n/** The \"Insert table\" dialog for the menu (the toolbar has the grid). */\nexport function openInsertTableDialog(editor: Editor): void {\n const { t } = editor.ui;\n const rows = textField({ label: t('table.rows'), value: '3' });\n const cols = textField({ label: t('table.cols'), value: '3' });\n for (const field of [rows, cols]) {\n field.input.type = 'number';\n field.input.min = '1';\n field.input.max = '50';\n field.input.inputMode = 'numeric';\n }\n editor.ui.openDialog({\n title: t('table.insert'),\n body: h('div', { className: 'nova-form nova-form-row' }, rows.el, cols.el),\n submitLabel: t('dialog.insert'),\n initialFocus: rows.input,\n onSubmit: () => {\n const r = Number(rows.input.value);\n const c = Number(cols.input.value);\n if (!Number.isInteger(r) || !Number.isInteger(c) || r < 1 || c < 1 || r > 50 || c > 50) {\n return t('table.invalidSize');\n }\n editor.exec(insertTable(r, c));\n return true;\n },\n });\n}\n\nexport function registerMenuItems(editor: Editor): void {\n const { registry, t } = editor.ui;\n registry.addToggleMenuItem('paragraph', {\n text: t('paragraph'),\n icon: icons.paragraph,\n shortcut: 'Mod-Alt-0',\n isActive: (e) => e.view.state.selection.$from.parent.type.name === 'paragraph',\n onAction: (e) => e.exec('paragraph'),\n });\n registry.addMenuItem('selectall', {\n text: t('selectAll'),\n shortcut: 'Mod-a',\n onAction: (e) => {\n e.view.dispatch(e.view.state.tr.setSelection(new AllSelection(e.view.state.doc)));\n e.focus();\n },\n });\n registry.addMenuItem('print', {\n text: t('print'),\n icon: icons.print,\n shortcut: 'Mod-p',\n onAction: (e) => printContent(e),\n });\n registry.addMenuItem('inserttable', {\n text: t('table.insert'),\n icon: icons.table,\n isEnabled: (e) => e.can(insertTable(1, 1)),\n onAction: (e) => openInsertTableDialog(e),\n });\n}\n","import type { Editor } from '../editor';\nimport { activeElement, h, icon, logicalKey, uniqueId } from './dom';\nimport { icons } from './icons';\nimport { createMenu, focusMenu } from './menu';\nimport { Popover } from './popover';\nimport type { ControlSpec, SplitButtonSpec } from './registry';\n\n/**\n * Toolbar configuration: a string in the familiar format ('undo redo | bold italic') or an array of\n * names, where '|' separates groups.\n */\nexport type ToolbarConfig = string | string[];\n\n/**\n * What the toolbar does when it runs out of width: 'floating' (the groups that don't fit open from\n * \"⋯\" in a panel over the text), 'sliding' (they open from \"⋯\" in a strip under the toolbar), 'scrolling'\n * (one row that scrolls sideways, for touch screens), 'wrap' (more rows).\n */\nexport type ToolbarMode = 'floating' | 'sliding' | 'scrolling' | 'wrap';\n\n// Order = priority: when space runs out, groups from the end move into \"⋯\",\n// so frequent actions (style, B/I/U, color, links) come first.\nexport const defaultToolbar =\n 'undo redo | blocks | bold italic underline strikethrough moreformats | forecolor backcolor | link image table | ' +\n 'bullist numlist | align lineheight outdent indent | fontfamily fontsize | blockquote codeblock hr | removeformat | searchreplace preview code fullscreen help';\n\nexport function parseToolbar(config: ToolbarConfig): string[][] {\n const tokens = Array.isArray(config) ? config : config.split(/\\s+/);\n const groups: string[][] = [[]];\n for (const raw of tokens) {\n const token = raw.trim();\n if (!token) continue;\n if (token === '|') groups.push([]);\n else groups[groups.length - 1]!.push(token);\n }\n return groups.filter((g) => g.length > 0);\n}\n\nexport interface RenderedControl {\n el: HTMLElement;\n update(): void;\n}\n\nexport interface ToolbarHandle {\n update(): void;\n focus(): void;\n destroy(): void;\n}\n\nexport function createToolbar(\n editor: Editor,\n host: HTMLElement,\n config: ToolbarConfig,\n mode: ToolbarMode,\n { warnUnknown = true }: { warnUnknown?: boolean } = {},\n): ToolbarHandle {\n const { ui } = editor;\n const t = ui.t;\n // Every listener on host is removed at once on destroy (the toolbar is rebuilt after plugins load).\n const listeners = new AbortController();\n const { signal } = listeners;\n host.className = `nova-toolbar nova-toolbar-${mode}`;\n host.setAttribute('role', 'toolbar');\n host.setAttribute('aria-label', t('toolbar.label'));\n\n const controls: RenderedControl[] = [];\n const groups: HTMLElement[] = [];\n\n for (const names of parseToolbar(config)) {\n const group = h('div', { className: 'nova-tb-group', role: 'group' });\n for (const name of names) {\n // Forbidden by the content restrictions: the button isn't shown.\n if (!editor.isAllowed(name)) continue;\n const spec = ui.registry.get(name);\n if (!spec) {\n if (warnUnknown) console.warn(`[nova] Unknown toolbar item \"${name}\"`);\n continue;\n }\n const control = renderControl(editor, name, spec);\n controls.push(control);\n group.append(control.el);\n }\n if (group.childElementCount) {\n groups.push(group);\n host.append(group);\n }\n }\n\n // ---------- overflow: \"⋯\" with the groups that don't fit (floating, sliding) ----------\n const overflows = mode === 'floating' || mode === 'sliding';\n const strip = mode === 'sliding';\n const overflowBox = h('div', {\n className: strip ? 'nova-toolbar nova-tb-strip' : 'nova-toolbar nova-tb-overflow',\n role: 'group',\n id: uniqueId('nova-tb-more'),\n 'aria-label': t('more'),\n hidden: strip,\n });\n const moreButton = h(\n 'button',\n {\n type: 'button',\n className: 'nova-btn nova-tb-more',\n 'aria-label': t('more'),\n 'aria-expanded': 'false',\n 'data-tooltip': t('more'),\n hidden: true,\n // The strip is right under the toolbar; the panel floats.\n ...(strip ? { 'aria-controls': overflowBox.id } : { 'aria-haspopup': 'true' }),\n },\n icon(icons.more),\n );\n ui.tooltip.attach(moreButton);\n let overflowPopover: Popover | null = null;\n\n const closeOverflow = () => {\n overflowPopover?.close();\n overflowPopover = null;\n if (strip && !overflowBox.hidden) {\n overflowBox.hidden = true;\n moreButton.setAttribute('aria-expanded', 'false');\n }\n };\n\n const offDialog = ui.onDialogOpen(() => {\n if (!strip) closeOverflow();\n });\n\n moreButton.addEventListener('click', (event) => {\n if (strip) {\n // The strip opens under the toolbar and stays open until \"⋯\" again or Escape in it.\n const open = overflowBox.hidden;\n overflowBox.hidden = !open;\n moreButton.setAttribute('aria-expanded', String(open));\n if (open && event.detail === 0)\n overflowBox.querySelector<HTMLButtonElement>('button:not(:disabled)')?.focus();\n return;\n }\n if (overflowPopover) return closeOverflow();\n moreButton.setAttribute('aria-expanded', 'true');\n const popover: Popover = new Popover({\n host: ui.overlayHost,\n anchor: moreButton,\n placement: 'bottom-end',\n content: overflowBox,\n className: 'nova-tb-overflow-popover',\n // Clicks on nested menus (they are in overlayHost too) don't close the panel.\n ignore: [ui.overlayHost, moreButton],\n onClose: (reason) => {\n overflowPopover = null;\n moreButton.setAttribute('aria-expanded', 'false');\n if (reason === 'escape' && popover.focusWasInside) moreButton.focus();\n },\n });\n overflowPopover = popover;\n if (event.detail === 0)\n overflowBox.querySelector<HTMLButtonElement>('button:not(:disabled)')?.focus();\n });\n\n if (overflows) host.append(moreButton);\n if (strip) host.after(overflowBox);\n // Scrolling: the button that gets focus (Tab, arrows) scrolls into view.\n if (mode === 'scrolling') {\n host.addEventListener(\n 'focusin',\n (event) =>\n (event.target as HTMLElement).scrollIntoView?.({ block: 'nearest', inline: 'nearest' }),\n { signal },\n );\n }\n\n const layout = () => {\n if (!overflows) return;\n for (const group of groups) host.insertBefore(group, moreButton);\n moreButton.hidden = true;\n if (host.scrollWidth <= host.clientWidth + 1) {\n closeOverflow();\n return;\n }\n moreButton.hidden = false;\n let visible = groups.length;\n while (visible > 1 && host.scrollWidth > host.clientWidth + 1) {\n visible -= 1;\n overflowBox.prepend(groups[visible]!);\n }\n if (!overflowBox.childElementCount) {\n moreButton.hidden = true;\n closeOverflow();\n }\n overflowPopover?.reposition();\n resetRoving();\n };\n\n // Re-layout only when the width changes: moving groups around must not trigger it by itself.\n let lastWidth = -1;\n const resizeObserver =\n typeof ResizeObserver !== 'undefined' && overflows\n ? new ResizeObserver(() => {\n if (host.clientWidth === lastWidth) return;\n lastWidth = host.clientWidth;\n layout();\n })\n : null;\n resizeObserver?.observe(host);\n\n // ---------- keyboard: roving tabindex per the WAI-ARIA toolbar pattern ----------\n const focusables = (): HTMLButtonElement[] =>\n [...host.querySelectorAll<HTMLButtonElement>('button')].filter((b) => !b.disabled && !b.hidden);\n\n let current: HTMLButtonElement | null = null;\n const resetRoving = () => {\n const list = focusables();\n if (!current || !list.includes(current)) current = list[0] ?? null;\n for (const b of host.querySelectorAll<HTMLButtonElement>('button'))\n b.tabIndex = b === current ? 0 : -1;\n };\n\n host.addEventListener(\n 'focusin',\n (event) => {\n const target = event.target as HTMLElement;\n if (target instanceof HTMLButtonElement && host.contains(target)) {\n current = target;\n resetRoving();\n }\n },\n { signal },\n );\n\n host.addEventListener(\n 'keydown',\n (event) => {\n const list = focusables();\n const index = list.indexOf(activeElement(host) as HTMLButtonElement);\n if (index < 0) return;\n let next: number | null = null;\n const key = logicalKey(event, host);\n if (key === 'ArrowRight') next = index + 1;\n else if (key === 'ArrowLeft') next = index - 1;\n else if (event.key === 'Home') next = 0;\n else if (event.key === 'End') next = list.length - 1;\n else if (event.key === 'Escape') {\n event.preventDefault();\n editor.focus();\n return;\n }\n if (next === null) return;\n event.preventDefault();\n list[(next + list.length) % list.length]!.focus();\n },\n { signal },\n );\n\n // Buttons don't take focus from the editor on mouse down, otherwise the selection is lost.\n const keepFocus = (event: MouseEvent) => {\n if ((event.target as HTMLElement).closest('button')) event.preventDefault();\n };\n host.addEventListener('mousedown', keepFocus, { signal });\n overflowBox.addEventListener('mousedown', keepFocus);\n overflowBox.addEventListener('keydown', (event) => {\n if (event.key === 'Escape') {\n // The panel closes itself; the strip closes here and the focus goes back to \"⋯\".\n if (strip) {\n event.preventDefault();\n closeOverflow();\n moreButton.focus();\n }\n return;\n }\n const list = [...overflowBox.querySelectorAll<HTMLButtonElement>('button')].filter(\n (b) => !b.disabled,\n );\n const index = list.indexOf(activeElement(overflowBox) as HTMLButtonElement);\n if (index < 0) return;\n const key = logicalKey(event, overflowBox);\n if (key === 'ArrowRight' || key === 'ArrowDown') {\n event.preventDefault();\n list[(index + 1) % list.length]!.focus();\n } else if (key === 'ArrowLeft' || key === 'ArrowUp') {\n event.preventDefault();\n list[(index - 1 + list.length) % list.length]!.focus();\n }\n });\n\n const update = () => {\n for (const control of controls) control.update();\n resetRoving();\n };\n update();\n layout();\n\n return {\n update,\n focus: () => {\n resetRoving();\n current?.focus();\n },\n destroy: () => {\n resizeObserver?.disconnect();\n offDialog();\n closeOverflow();\n listeners.abort();\n host.replaceChildren();\n if (strip) overflowBox.remove();\n },\n };\n}\n\nexport function renderControl(editor: Editor, name: string, spec: ControlSpec): RenderedControl {\n if (spec.type === 'split') return renderSplit(editor, name, spec);\n const { ui } = editor;\n const el = h('button', {\n type: 'button',\n className: `nova-btn nova-tb-${spec.type}`,\n 'aria-label': spec.tooltip,\n 'data-tooltip': spec.tooltip,\n 'data-control': name,\n ...(spec.shortcut ? { 'data-shortcut': spec.shortcut } : {}),\n });\n ui.tooltip.attach(el);\n\n if (spec.icon) el.append(icon(spec.icon));\n const label =\n spec.type === 'menu' && (spec.label || spec.text)\n ? h('span', { className: 'nova-tb-label' })\n : null;\n if (label) {\n if (spec.type === 'menu' && spec.minChars) label.style.minWidth = `${spec.minChars}ch`;\n el.append(label);\n el.classList.add('nova-tb-has-label');\n } else if (!spec.icon && spec.text) {\n el.append(spec.text);\n }\n\n let colorBar: HTMLElement | null = null;\n if (spec.type === 'panel' && spec.indicator) {\n colorBar = h('span', { className: 'nova-color-bar' });\n el.append(colorBar);\n }\n if (spec.type !== 'button') {\n el.setAttribute('aria-haspopup', spec.type === 'menu' ? 'menu' : 'dialog');\n el.setAttribute('aria-expanded', 'false');\n el.append(icon(icons.chevronDown));\n el.lastElementChild?.classList.add('nova-chevron');\n }\n\n el.addEventListener('click', (event) => {\n if (spec.type === 'button') {\n spec.onAction(editor);\n return;\n }\n // A second click on an open button closes its popover.\n if (el.getAttribute('aria-expanded') === 'true') {\n ui.closePopover();\n return;\n }\n const fromKeyboard = event.detail === 0;\n const closeAndRefocus = () => ui.closePopover();\n const content =\n spec.type === 'menu'\n ? createMenu(spec.items(editor), closeAndRefocus, spec.tooltip)\n : spec.render(editor, closeAndRefocus);\n el.setAttribute('aria-expanded', 'true');\n const popover = ui.openPopover({\n anchor: el,\n content,\n ignore: [el],\n className: spec.type === 'menu' ? 'nova-popover-menu' : 'nova-popover-panel',\n onClose: (reason) => {\n el.setAttribute('aria-expanded', 'false');\n // Focus was in the panel: return it to the button; if it was in the text, it stays there.\n if (reason === 'escape' && popover.focusWasInside) el.focus();\n },\n });\n if (spec.type === 'menu') focusMenu(content);\n else if (fromKeyboard) content.querySelector<HTMLElement>('button, input')?.focus();\n });\n\n // The menu also opens with the down arrow, as native drop-down lists do.\n if (spec.type !== 'button') {\n el.addEventListener('keydown', (event) => {\n if (event.key === 'ArrowDown' && el.getAttribute('aria-expanded') !== 'true') {\n event.preventDefault();\n el.click();\n }\n });\n }\n\n const update = () => {\n const editable = editor.isEditable();\n el.disabled = !editable || (spec.isEnabled ? !spec.isEnabled(editor) : false);\n if (spec.isActive) {\n const active = spec.isActive(editor);\n el.classList.toggle('is-active', active);\n if (spec.type === 'button') el.setAttribute('aria-pressed', String(active));\n }\n if (label && spec.type === 'menu') {\n const text = spec.label?.(editor) ?? spec.text ?? '';\n label.textContent = text;\n // WCAG 2.5.3: the accessible name starts with the visible text (\"Paragraph, Blocks\"),\n // otherwise voice control (\"click Paragraph\") can't find the button.\n el.setAttribute(\n 'aria-label',\n text && text !== spec.tooltip ? `${text}, ${spec.tooltip}` : (spec.tooltip ?? text),\n );\n }\n if (colorBar && spec.type === 'panel' && spec.indicator) {\n const color = spec.indicator(editor);\n colorBar.style.background = color ?? '';\n colorBar.classList.toggle('is-empty', !color);\n }\n };\n\n return { el, update };\n}\n\n/**\n * A split button = a regular button (data-control=name) + an arrow button with a menu of variants.\n * In arrow navigation these are two stops, as with split buttons in desktop editors.\n */\nfunction renderSplit(editor: Editor, name: string, spec: SplitButtonSpec): RenderedControl {\n const main = renderControl(editor, name, {\n type: 'button',\n tooltip: spec.tooltip,\n onAction: spec.onAction,\n ...(spec.icon ? { icon: spec.icon } : {}),\n ...(spec.text ? { text: spec.text } : {}),\n ...(spec.shortcut ? { shortcut: spec.shortcut } : {}),\n ...(spec.isActive ? { isActive: spec.isActive } : {}),\n ...(spec.isEnabled ? { isEnabled: spec.isEnabled } : {}),\n });\n const more = renderControl(editor, `${name}-options`, {\n type: 'menu',\n tooltip: `${spec.tooltip}: ${editor.ui.t('toolbar.options')}`,\n items: spec.items,\n ...(spec.isEnabled ? { isEnabled: spec.isEnabled } : {}),\n });\n more.el.classList.add('nova-tb-split-more');\n const el = h('span', { className: 'nova-tb-split' }, main.el, more.el);\n return {\n el,\n update: () => {\n main.update();\n more.update();\n },\n };\n}\n","import type { CommandName } from '../commands';\nimport type { Editor } from '../editor';\nimport type { MessageKey } from '../i18n';\nimport { openImageDialog } from '../image';\nimport { openLinkDialog } from '../link';\nimport { insertTable } from '../tables';\nimport type { AutocompleterItem } from './autocompleter';\nimport { icons } from './icons';\n\nexport interface SlashCommand {\n name: string;\n /** Translation key of the label. */\n label: MessageKey;\n icon: string;\n /** Extra search words (English, so \"/h1\" and \"/quote\" work in any UI language). */\n keywords: string[];\n shortcut?: string;\n run: (editor: Editor) => void;\n}\n\nconst exec = (command: CommandName) => (editor: Editor) => editor.exec(command);\n\nexport const defaultSlashCommands: SlashCommand[] = [\n {\n name: 'paragraph',\n label: 'paragraph',\n icon: icons.paragraph,\n keywords: ['text', 'p', 'paragraph'],\n run: exec('paragraph'),\n },\n {\n name: 'h1',\n label: 'h1',\n icon: icons.h1,\n keywords: ['h1', 'heading', 'title'],\n shortcut: 'Mod-Alt-1',\n run: exec('h1'),\n },\n {\n name: 'h2',\n label: 'h2',\n icon: icons.h2,\n keywords: ['h2', 'heading', 'subtitle'],\n shortcut: 'Mod-Alt-2',\n run: exec('h2'),\n },\n {\n name: 'h3',\n label: 'h3',\n icon: icons.h3,\n keywords: ['h3', 'heading'],\n shortcut: 'Mod-Alt-3',\n run: exec('h3'),\n },\n {\n name: 'bullist',\n label: 'bulletList',\n icon: icons.bulletList,\n keywords: ['ul', 'list', 'bullet'],\n shortcut: 'Mod-Shift-8',\n run: exec('bulletList'),\n },\n {\n name: 'numlist',\n label: 'orderedList',\n icon: icons.orderedList,\n keywords: ['ol', 'list', 'numbered'],\n shortcut: 'Mod-Shift-7',\n run: exec('orderedList'),\n },\n {\n name: 'blockquote',\n label: 'blockquote',\n icon: icons.blockquote,\n keywords: ['quote', 'blockquote', 'citation'],\n run: exec('blockquote'),\n },\n {\n name: 'codeblock',\n label: 'codeBlock',\n icon: icons.codeBlock,\n keywords: ['code', 'pre', 'snippet'],\n run: exec('codeBlock'),\n },\n {\n name: 'hr',\n label: 'horizontalRule',\n icon: icons.horizontalRule,\n keywords: ['hr', 'divider', 'line', 'separator'],\n run: exec('horizontalRule'),\n },\n {\n name: 'table',\n label: 'table',\n icon: icons.table,\n keywords: ['table', 'grid'],\n run: (e) => e.exec(insertTable(3, 3)),\n },\n {\n name: 'image',\n label: 'image',\n icon: icons.image,\n keywords: ['image', 'picture', 'photo', 'img'],\n run: (e) => openImageDialog(e),\n },\n {\n name: 'link',\n label: 'link',\n icon: icons.link,\n keywords: ['link', 'url', 'href'],\n shortcut: 'Mod-k',\n run: (e) => openLinkDialog(e),\n },\n];\n\n/**\n * Ranking: a match at the start of the label beats a match at the start of a keyword,\n * and that beats a match in the middle. An empty query lists all commands in order.\n */\nexport function rankSlashCommands(\n commands: SlashCommand[],\n query: string,\n t: (k: MessageKey) => string,\n): SlashCommand[] {\n const q = query.toLowerCase();\n if (!q) return commands;\n const scored: [number, number, SlashCommand][] = [];\n commands.forEach((cmd, index) => {\n const label = t(cmd.label).toLowerCase();\n const words = [label, ...label.split(/\\s+/), ...cmd.keywords];\n let score = -1;\n if (label.startsWith(q)) score = 3;\n else if (words.some((w) => w.startsWith(q))) score = 2;\n else if (words.some((w) => w.includes(q))) score = 1;\n if (score > 0) scored.push([score, index, cmd]);\n });\n return scored.sort((a, b) => b[0] - a[0] || a[1] - b[1]).map(([, , cmd]) => cmd);\n}\n\n/** Registers the \"/\" autocompleter with the standard commands (plus custom ones through the option). */\nexport function registerSlashCommands(editor: Editor, extra: SlashCommand[] = []): void {\n const { t } = editor.ui;\n const commands = [...defaultSlashCommands, ...extra].filter((cmd) => editor.isAllowed(cmd.name));\n editor.ui.registry.addAutocompleter('slashcommands', {\n trigger: '/',\n label: t('slash.label'),\n emptyText: t('slash.empty'),\n fetch: (query) =>\n rankSlashCommands(commands, query, t).map<AutocompleterItem>((cmd) => ({\n value: cmd.name,\n label: t(cmd.label),\n icon: cmd.icon,\n ...(cmd.shortcut ? { shortcut: cmd.shortcut } : {}),\n })),\n onSelect: (item, range, e) => {\n const cmd = commands.find((c) => c.name === item.value);\n if (!cmd) return;\n // First remove \"/query\", then run the command on the cleared spot.\n e.view.dispatch(e.view.state.tr.delete(range.from, range.to));\n cmd.run(e);\n },\n });\n}\n","import type { Node as PMNode } from 'prosemirror-model';\nimport type { Editor } from '../editor';\nimport { h, icon, isRtl, logicalKey } from './dom';\nimport { icons } from './icons';\n\nconst TAGS: Record<string, (node: PMNode) => string> = {\n paragraph: () => 'p',\n heading: (n) => `h${n.attrs.level}`,\n blockquote: () => 'blockquote',\n code_block: () => 'pre',\n bullet_list: () => 'ul',\n ordered_list: () => 'ol',\n list_item: () => 'li',\n table: () => 'table',\n table_row: () => 'tr',\n table_cell: () => 'td',\n table_header: () => 'th',\n};\n\nconst MARK_TAGS: Record<string, string> = {\n bold: 'strong',\n italic: 'em',\n underline: 'u',\n strike: 's',\n code: 'code',\n link: 'a',\n subscript: 'sub',\n superscript: 'sup',\n};\n\n/**\n * Counts words the way a person does: numbers and words with a hyphen/apostrophe are one word.\n * In Chinese and Japanese words aren't separated by spaces: every ideograph, hiragana and katakana character\n * counts as a word (as in word processors). Korean is written with spaces and counts as usual.\n */\nconst CJK = String.raw`\\p{sc=Han}\\p{sc=Hiragana}\\p{sc=Katakana}`;\nconst LETTER = String.raw`(?:(?![${CJK}])[\\p{L}\\p{N}])`;\nconst WORD = new RegExp(`[${CJK}]|${LETTER}+(?:['’-]${LETTER}+)*`, 'gu');\n\nexport function countWords(text: string): number {\n return text.match(WORD)?.length ?? 0;\n}\n\n/** The statusbar: the path to the element under the cursor (p › strong) and the word count. */\nexport function createStatusbar(editor: Editor, host: HTMLElement) {\n host.className = 'nova-statusbar';\n const path = h('div', { className: 'nova-path', 'aria-hidden': 'true' });\n const words = h('div', { className: 'nova-wordcount', 'aria-live': 'off' });\n host.append(path, words);\n const resize = editor.options.resize;\n const removeHandle = resize ? createResizeHandle(editor, host, resize === 'both') : null;\n\n let timer: ReturnType<typeof setTimeout> | null = null;\n const updateWords = () => {\n const doc = editor.view.state.doc;\n words.textContent = editor.ui.t('status.words', {\n count: countWords(doc.textBetween(0, doc.content.size, ' ', ' ')),\n });\n };\n\n const update = (docChanged: boolean) => {\n const { $from } = editor.view.state.selection;\n const parts: string[] = [];\n for (let depth = 1; depth <= $from.depth; depth++) {\n const node = $from.node(depth);\n const tag = TAGS[node.type.name]?.(node);\n if (tag) parts.push(tag);\n }\n // A whole node is selected (an image): it is part of the path too.\n const selected = (editor.view.state.selection as { node?: PMNode }).node;\n if (selected?.type.name === 'image') parts.push('img');\n for (const mark of $from.marks()) {\n const tag = MARK_TAGS[mark.type.name];\n if (tag) parts.push(tag);\n }\n // Each tag is a separate isolated fragment: right to left, the path runs right to left\n // (otherwise consecutive Latin names would merge into one left-to-right string); the browser mirrors \"›\".\n path.replaceChildren(\n ...parts.flatMap((tag, i) => [\n ...(i ? [' › '] : []),\n h('span', { className: 'nova-path-item' }, tag),\n ]),\n );\n // Counting the words of a large document doesn't happen on every keystroke.\n if (docChanged) {\n if (timer) clearTimeout(timer);\n timer = setTimeout(updateWords, 250);\n }\n };\n\n updateWords();\n update(false);\n\n return {\n update,\n destroy: () => {\n if (timer) clearTimeout(timer);\n removeHandle?.();\n host.replaceChildren();\n },\n };\n}\n\nconst MIN_HEIGHT = 100;\nconst MIN_WIDTH = 200;\nconst KEY_STEP = 20;\n\n/**\n * The resize handle in the statusbar corner: drag it with a mouse or a finger, arrows from the keyboard.\n * The size is set on the editor root (height, and width too for 'both').\n */\nfunction createResizeHandle(editor: Editor, host: HTMLElement, both: boolean): () => void {\n const root = editor.root;\n const handle = h('div', {\n className: 'nova-resize-handle',\n role: 'separator',\n tabIndex: 0,\n 'aria-orientation': 'horizontal',\n 'aria-label': editor.ui.t('status.resize'),\n });\n handle.append(icon(both ? icons.resizeHandleBoth : icons.resizeHandle));\n root.dataset.resize = both ? 'both' : 'vertical';\n host.append(handle);\n\n const setSize = (height: number, width?: number) => {\n // The size is measured by the border box (offsetHeight), so it is set by the border box too, without a jump of the border width.\n root.style.boxSizing = 'border-box';\n root.style.height = `${Math.max(MIN_HEIGHT, Math.round(height))}px`;\n if (both && width !== undefined) {\n const max = root.parentElement?.clientWidth || Infinity;\n root.style.width = `${Math.min(max, Math.max(MIN_WIDTH, Math.round(width)))}px`;\n }\n handle.setAttribute('aria-valuenow', String(root.offsetHeight));\n };\n\n let start: { x: number; y: number; height: number; width: number } | null = null;\n const onDown = (event: PointerEvent) => {\n if (editor.isDisabled()) return;\n event.preventDefault();\n handle.setPointerCapture(event.pointerId);\n start = {\n x: event.clientX,\n y: event.clientY,\n height: root.offsetHeight,\n width: root.offsetWidth,\n };\n };\n const onMove = (event: PointerEvent) => {\n if (!start) return;\n // Right to left the handle is in the left corner: the width grows when moving left.\n const dx = (event.clientX - start.x) * (isRtl(root) ? -1 : 1);\n setSize(start.height + event.clientY - start.y, start.width + dx);\n };\n const onUp = (event: PointerEvent) => {\n if (!start) return;\n start = null;\n if (handle.hasPointerCapture(event.pointerId)) handle.releasePointerCapture(event.pointerId);\n };\n const onKey = (event: KeyboardEvent) => {\n const dy = event.key === 'ArrowDown' ? KEY_STEP : event.key === 'ArrowUp' ? -KEY_STEP : 0;\n const key = logicalKey(event, root);\n const dx = both ? (key === 'ArrowRight' ? KEY_STEP : key === 'ArrowLeft' ? -KEY_STEP : 0) : 0;\n if (!dx && !dy) return;\n event.preventDefault();\n setSize(root.offsetHeight + dy, root.offsetWidth + dx);\n };\n handle.addEventListener('pointerdown', onDown);\n handle.addEventListener('pointermove', onMove);\n handle.addEventListener('pointerup', onUp);\n handle.addEventListener('pointercancel', onUp);\n handle.addEventListener('keydown', onKey);\n return () => {\n handle.remove();\n delete root.dataset.resize;\n };\n}\n","import type { AccordionOptions } from './plugins/accordion';\nimport type { TableOfContentsOptions } from './plugins/tableofcontents';\nimport type { PageLayoutOptions } from './plugins/pagelayout';\nimport type { ExportPdfOptions } from './plugins/exportpdf';\nimport type { ExportWordOptions } from './plugins/exportword';\nimport type { ImportWordOptions } from './plugins/importword';\nimport type { AiOptions } from './plugins/ai-core';\nimport type { SpellCheckerOptions } from './plugins/spellchecker';\nimport type { AutocorrectOptions } from './plugins/autocorrect';\nimport type { LinkCheckerOptions } from './plugins/linkchecker';\nimport type { PageEmbedOptions } from './plugins/pageembed';\nimport type { AdvTableOptions } from './plugins/advtable-ui';\nimport type { AdvCodeOptions } from './plugins/advcode';\nimport type { EditImageOptions } from './plugins/editimage';\nimport type { MediaEmbedOptions } from './plugins/mediaembed';\nimport type { FullPageHtmlOptions } from './plugins/fullpagehtml';\nimport type { TypographyOptions } from './plugins/typography';\nimport type { A11yCheckerOptions } from './plugins/a11ychecker';\nimport type { EmailOptions } from './email';\nimport type { AutosaveOptions } from './plugins/autosave';\nimport type { CodeSampleOptions } from './plugins/codesample';\nimport { Formatter, type FormatSpec, type StyleFormat } from './formats';\nimport { attachCss, loadCss, scopeCss } from './content-css';\nimport type { FilePicker, FilePickType } from './ui/file-picker';\nimport type { CommentsOptions } from './plugins/comments';\nimport type { MentionsOptions } from './plugins/mentions';\nimport type { MergeTagsOptions } from './plugins/mergetags';\nimport type { QuickbarsOptions } from './plugins/quickbars';\nimport type { RevisionHistoryOptions } from './plugins/revisionhistory';\nimport { dropCursor } from 'prosemirror-dropcursor';\nimport { gapCursor } from 'prosemirror-gapcursor';\nimport { history } from 'prosemirror-history';\nimport { keymap } from 'prosemirror-keymap';\nimport { Node as PMNode, Slice } from 'prosemirror-model';\nimport { EditorState, Plugin, type Command, type Transaction } from 'prosemirror-state';\nimport { EditorView } from 'prosemirror-view';\nimport { commands, isCommandActive, type CommandName } from './commands';\nimport { createTranslator, type LanguagePack } from './i18n';\nimport { embeddedImageUploadPlugin, imageDropPastePlugin, type UploadImageHandler } from './image';\nimport { firstClickPlugin } from './first-click';\nimport { announcePlugin } from './announce';\nimport { currentName, renameOptions } from './deprecations';\nimport { buildInputRules, codeFenceKeymap } from './inputrules';\nimport { textPatternsPlugin, type TextPattern, type TextPatternContext } from './text-patterns';\nimport { buildKeymap } from './keymap';\nimport { openLinkDialog } from './link';\nimport { loadPasteCleaner, pastePlugin, type PasteOptions } from './paste';\nimport { loadTables } from './tables';\nimport { activeElement } from './ui/dom';\nimport { htmlSerializer, isRtlLanguage, sanitizeJSON, schemaFromOptions } from './document';\nimport { keepPluginViews, reconfigurePlugins } from './plugin-views';\nimport { parserFor } from './parser';\nimport {\n createMenubar,\n DEFAULT_MENUBAR,\n DEFAULT_MENUS,\n type MenuDefinition,\n type MenubarHandle,\n} from './ui/menubar';\nimport { registerMenuItems } from './ui/menu-items';\nimport { ContentRules, contentRulesPlugin, type ContentRulesOptions } from './content-rules';\nimport {\n loadPlugin,\n orderPlugins,\n pageHandlerOf,\n resolveEntries,\n type NovaPlugin,\n type PageHandler,\n type PluginEntry,\n} from './plugins';\nimport { createChain, type CommandChain } from './chain';\nimport { pages } from './page';\nimport { bookmarksPlugin, createSelection, type EditorSelection } from './selection';\nimport { searchPlugin } from './search';\nimport type { SearchBarHandle } from './ui/search-bar';\nimport { openHelp, toggleFullscreen } from './ui/views';\nimport type { NovaSchema } from './schema';\nimport { registerBuiltins, type FontOption } from './ui/builtins';\nimport { linkBubblePlugin } from './ui/link-bubble';\nimport { contextToolbarPlugin, focusContextToolbar } from './ui/context-toolbar';\nimport { ImageView } from './ui/image-view';\nimport { flatMarkViews } from './mark-views';\nimport { autocompleterPlugin } from './ui/autocompleter';\nimport { registerSlashCommands, type SlashCommand } from './ui/slash';\nimport { SET_CONTENT_META } from './meta';\nimport { UiManager } from './ui/manager';\nimport { createStatusbar } from './ui/statusbar';\nimport {\n createToolbar,\n defaultToolbar,\n type ToolbarConfig,\n type ToolbarHandle,\n type ToolbarMode,\n} from './ui/toolbar';\n\nexport type EditorMode = 'classic' | 'inline' | 'distraction-free';\n\n/** Marks a transaction that came from a collaborator (set by @novaprose/collab): it is not user input. */\nexport const REMOTE_CHANGE_META = 'nova:remote';\n/** A transaction marker from the API (setContent, insertContent): it doesn't count as input. */\nexport const API_CHANGE_META = 'nova:api';\n\n/** Event details: the second argument of a listener, `editor.on(event, (editor, detail) => …)`. */\nexport interface EditorEventDetails {\n /** The editor is ready: lazy plugins and content styles are loaded (same as `await editor.ready`). */\n init: undefined;\n /** The document changed in any way: typing, the API, a collaborator. */\n change: { transaction: Transaction };\n /** The user of this editor changed the document (typing, paste, toolbar buttons, shortcuts). */\n input: { transaction: Transaction };\n selectionChange: { transaction: Transaction };\n focus: { event: FocusEvent };\n blur: { event: FocusEvent };\n editableChange: undefined;\n destroy: undefined;\n /** Before setContent: `detail.content` can be replaced. */\n beforeSetContent: { content: string | Record<string, unknown> };\n setContent: { content: string | Record<string, unknown> };\n /** A key in the text, before the editor handles it; `detail.event.preventDefault()` cancels that. */\n keydown: { event: KeyboardEvent };\n}\n\nexport type EditorEvent = keyof EditorEventDetails;\n\nexport type EditorListener<E extends EditorEvent = EditorEvent> = (\n editor: Editor,\n detail: EditorEventDetails[E],\n) => void;\n\n/**\n * Options of the built-in plugins (typed, so your code editor suggests them) and of any other plugin\n * by name. Types only: plugin modules are not pulled into the core.\n */\nexport interface PluginOptions {\n comments?: CommentsOptions;\n mentions?: MentionsOptions;\n mergetags?: MergeTagsOptions;\n revisionhistory?: RevisionHistoryOptions;\n autosave?: AutosaveOptions;\n quickbars?: QuickbarsOptions;\n codesample?: CodeSampleOptions;\n accordion?: AccordionOptions;\n tableofcontents?: TableOfContentsOptions;\n pagelayout?: PageLayoutOptions;\n exportword?: ExportWordOptions;\n exportpdf?: ExportPdfOptions;\n importword?: ImportWordOptions;\n ai?: AiOptions;\n spellchecker?: SpellCheckerOptions;\n autocorrect?: AutocorrectOptions;\n typography?: TypographyOptions;\n a11ychecker?: A11yCheckerOptions;\n linkchecker?: LinkCheckerOptions;\n pageembed?: PageEmbedOptions;\n advtable?: AdvTableOptions;\n advcode?: AdvCodeOptions;\n editimage?: EditImageOptions;\n mediaembed?: MediaEmbedOptions;\n fullpagehtml?: FullPageHtmlOptions;\n /** The email plugin's options; emailHTML() from @novaprose/core/email uses them too. */\n email?: EmailOptions;\n [plugin: string]: unknown;\n}\n\nexport interface EditorOptions extends PasteOptions, ContentRulesOptions {\n /** The element the editor is mounted into. */\n element: HTMLElement;\n /** Initial content: an HTML string or a JSON document. */\n content?: string | Record<string, unknown>;\n /**\n * Toolbar: a string ('undo redo | bold italic'), an array of names, or false (headless: you draw\n * the UI). Defaults to the standard set.\n */\n toolbar?: false | ToolbarConfig;\n /**\n * What the toolbar does when it runs out of width: 'floating' (default: the groups that don't fit\n * open from \"⋯\" over the text), 'sliding' (they open in a strip under the toolbar), 'scrolling'\n * (one row that scrolls sideways), 'wrap' (more rows).\n */\n toolbarMode?: ToolbarMode;\n /**\n * classic — a frame with bars (default); inline — no frame, the toolbar appears above the text on\n * focus; distraction-free — no permanent bars, only quick toolbars over the selection and empty lines.\n */\n mode?: EditorMode;\n /** Menu bar: true for the standard one ('file edit view insert format table help'), a string for your own set. Off by default. */\n menubar?: boolean | string;\n /**\n * Shortcuts that react to typed characters: Markdown (\"# \" a heading, \"- \" a list, \"```\" a code\n * block) and typography (\"--\" a dash, \"...\" an ellipsis). On by default; false turns them off,\n * for people who dictate or type those characters as text (WCAG 2.1.4). A list of patterns\n * replaces the built-in ones: `[{ start: '*', end: '*', format: 'italic' }, { start: '#', format:\n * 'h1' }, { start: '(c)', replacement: '©' }]`.\n */\n textPatterns?: boolean | TextPattern[];\n /** More patterns on every attempt (from the text before the cursor and its block): added to textPatterns. */\n textPatternsLookup?: (context: TextPatternContext) => TextPattern[];\n /** Your own menus, or overrides of the standard ones: { insert: { title: 'Insert', items: 'image link | hr' } }. */\n menu?: Record<string, MenuDefinition>;\n /** Status bar with the element path and the word count. On by default. */\n statusbar?: boolean;\n /** Placeholder for an empty document. */\n placeholder?: string;\n editable?: boolean;\n /**\n * A disabled editor, like a disabled form field: the text can't be edited or focused and the bars\n * are inactive. Unlike editable: false (read-only), it looks dimmed.\n */\n disabled?: boolean;\n /**\n * Resize handle in the status bar: true — height, 'both' — height and width. Works with a mouse,\n * a finger or the keyboard (arrow keys on the handle). Off by default.\n */\n resize?: boolean | 'both';\n /**\n * Items of the block list (the `blocks` button) and their order: [{ label: 'Subheading', block: 'h3' }].\n * Default: paragraph, H1–H6 and code block.\n */\n blockFormats?: BlockFormat[];\n /**\n * Content styles (like content_style in TinyMCE), applied only to this editor's text. `body` and\n * `html` in selectors mean the text area itself: 'body { font-family: Georgia }'.\n */\n contentStyle?: string;\n /**\n * Content style sheets (like content_css), loaded and applied only to this editor's text;\n * relative url() and @import work. `await editor.ready` waits for them.\n */\n contentCss?: string | string[];\n /**\n * Named formats (like formats in TinyMCE): { note: { block: 'p', classes: 'note' } }. Apply them\n * with editor.formatter.apply('note'); their classes are kept when HTML is parsed.\n */\n formats?: Record<string, FormatSpec | FormatSpec[]>;\n /**\n * Items of the Styles menu (the `styles` button): your formats, references to named formats and\n * groups. Default: headings, text, blocks and alignment.\n */\n styleFormats?: StyleFormat[];\n /** true — add styleFormats to the standard set instead of replacing it. */\n styleFormatsMerge?: boolean;\n /**\n * Which classes to keep in the HTML besides those of the formats: a list, or true for all. By\n * default only format classes (pasted clutter such as MsoNormal stays out of the document).\n */\n validClasses?: string[] | true;\n /**\n * Table styles to choose from in the table properties (like table_class_list in TinyMCE):\n * [{ title: 'Bordered', value: 'grid' }]. Your CSS (contentCss) defines how they look.\n */\n tableClassList?: ClassOption[];\n /** Cell styles to choose from in the cell properties (like table_cell_class_list). */\n tableCellClassList?: ClassOption[];\n /** UI language (BCP 47): 'en', 'de'… Default 'en'. */\n language?: string;\n /**\n * Writing direction of the UI and the text. By default right-to-left for Arabic, Hebrew, Persian\n * and Urdu (from `language`), otherwise the page's direction.\n */\n direction?: 'ltr' | 'rtl';\n /** Override individual UI strings. */\n translations?: LanguagePack;\n /** Upload images to your server. Without it, images are embedded as data: URLs. */\n uploadImage?: UploadImageHandler;\n /**\n * Your own file picker: a Browse button next to the address field of the link, image and video\n * dialogs. Gets the field type and the current address, returns { url, text?, title?, alt? } or null.\n */\n filePicker?: FilePicker;\n /** Which fields get Browse: 'file' (link), 'image', 'media'. Default: all of them. */\n filePickerTypes?: FilePickType[];\n fontFamilies?: FontOption[];\n fontSizes?: string[];\n lineHeights?: string[];\n colors?: string[];\n /** Slash commands (\"/\"). false turns them off; an array adds commands to the standard ones. */\n slashCommands?: false | SlashCommand[];\n /**\n * NovaProse plugins: an object, a registered name ('insertdatetime') or a lazy loader\n * (() => import(...)). Lazy ones load after the editor is created; wait for them with `await editor.ready`.\n */\n plugins?: PluginEntry[];\n /** Plugin options by name: { comments: {...}, mentions: {...} }. Built-in plugins are typed. */\n pluginOptions?: PluginOptions;\n /** Raw ProseMirror plugins (for low-level extensions). */\n prosemirrorPlugins?: Plugin[];\n /** Called before the toolbar is drawn — the place for editor.ui.registry.addButton(...). */\n setup?: (editor: Editor) => void;\n onChange?: (editor: Editor) => void;\n}\n\n/** An item of the table or cell style list: a label and a class. */\nexport interface ClassOption {\n title: string;\n value: string;\n}\n\n/** An item of the block list: a label and the block's tag. */\nexport interface BlockFormat {\n label: string;\n block: 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'pre';\n}\n\n/** Tags that insertContent inserts as separate blocks. */\nconst INSERT_BLOCK_TAGS = new Set(\n 'P H1 H2 H3 H4 H5 H6 UL OL TABLE BLOCKQUOTE PRE HR DIV FIGURE'.split(' '),\n);\n\n/** The \"insert HTML at the cursor\" command (editor.insertContent and a chain step). */\nfunction insertContentCommand(html: string): Command {\n return (state, dispatch) => {\n if (!dispatch) return true;\n const template = document.createElement('template');\n template.innerHTML = html;\n const container = document.createElement('div');\n container.append(template.content);\n const parser = parserFor(state.schema as NovaSchema);\n const hasBlocks = [...container.children].some((el) => INSERT_BLOCK_TAGS.has(el.tagName));\n const slice = hasBlocks\n ? new Slice(parser.parse(container).content, 0, 0)\n : parser.parseSlice(container);\n let hasTable = false;\n slice.content.descendants((node) => {\n if (node.type.spec.tableRole === 'table') hasTable = true;\n return !hasTable;\n });\n const { $from } = state.selection;\n let tableDepth = 0;\n for (let depth = 1; depth <= $from.depth; depth++) {\n if ($from.node(depth).type.spec.tableRole === 'table') {\n tableDepth = depth;\n break;\n }\n }\n const tr =\n hasTable && tableDepth\n ? state.tr.insert($from.after(tableDepth), slice.content)\n : state.tr.replaceSelection(slice);\n dispatch(tr.setMeta(API_CHANGE_META, true).scrollIntoView());\n return true;\n };\n}\n\n/** The number of the content style scope (contentStyle/contentCss), unique on the page. */\nlet contentScopeId = 0;\n\n/** Unknown command names already warned about (once per page each). */\nconst unknownCommands = new Set<string>();\n\n/**\n * The public API of a NovaProse editor. The framework wrappers (React, Vue…) work only through this\n * class, never with ProseMirror directly.\n */\nexport class Editor {\n readonly view: EditorView;\n readonly root: HTMLElement;\n readonly ui: UiManager;\n readonly options: Readonly<EditorOptions>;\n private readonly listeners = new Map<EditorEvent, Set<EditorListener>>();\n /** Resolves when all lazy plugins are loaded and set up. */\n readonly ready: Promise<void>;\n private toolbar: ToolbarHandle | null;\n private readonly toolbarHost: HTMLElement;\n private readonly menubar: MenubarHandle | null;\n readonly mode: EditorMode;\n /** The editor's writing direction (the direction option, the language or the page's dir). */\n readonly direction: 'ltr' | 'rtl';\n private readonly pluginsByName = new Map<string, NovaPlugin>();\n private readonly commandOverrides = new Map<CommandName, Command>();\n private readonly transactionTransforms: NonNullable<NovaPlugin['transformTransaction']>[] = [];\n private readonly cleanups: (() => void)[] = [];\n /** Content restrictions (validElements/invalidElements/validStyles), or null when there are none. */\n private readonly contentRules: ContentRules | null;\n /** This editor's document schema: the built-in one plus nodes and marks of plugins. */\n readonly schema: NovaSchema;\n /** Formats: register / apply / remove / toggle / match. */\n readonly formatter: Formatter;\n /** The selection: its HTML and text, its range and place on screen, moving it, bookmarks. */\n readonly selection: EditorSelection;\n private readonly statusbar: ReturnType<typeof createStatusbar> | null;\n /** The find and replace bar: a lazy part, there once editor.ready resolves (see loadSearchBar). */\n private searchBar: SearchBarHandle | null = null;\n private searchBarLoad: Promise<SearchBarHandle | null> | null = null;\n private contentHost!: HTMLElement;\n private destroyed = false;\n private editable: boolean;\n private disabled: boolean;\n private pasteAsText: boolean;\n\n constructor(options: EditorOptions) {\n // Renamed options keep working under their old names, with a console warning (deprecations.ts).\n options = renameOptions(options);\n this.options = options;\n this.root = document.createElement('div');\n this.root.className = 'nova-editor';\n const direction = options.direction ?? (isRtlLanguage(options.language) ? 'rtl' : undefined);\n if (direction) this.root.dir = direction;\n // Without an explicit direction, follow the page (dir on <html> or the container).\n this.direction =\n direction ??\n (options.element.closest('[dir]')?.getAttribute('dir') === 'rtl' ? 'rtl' : 'ltr');\n options.element.appendChild(this.root);\n\n const toolbarHost = document.createElement('div');\n const contentHost = document.createElement('div');\n const statusbarHost = document.createElement('div');\n contentHost.className = 'nova-content';\n // Header: menubar + toolbar. The header is sticky, not the toolbar inside it.\n const header = document.createElement('div');\n header.className = 'nova-header';\n const menubarHost = document.createElement('div');\n header.append(menubarHost, toolbarHost);\n this.root.append(header, contentHost, statusbarHost);\n this.toolbarHost = toolbarHost;\n\n this.mode = options.mode ?? 'classic';\n this.root.classList.add(`nova-mode-${this.mode}`);\n const distractionFree = this.mode === 'distraction-free';\n if (this.mode !== 'classic') {\n // Focus is somewhere inside the editor (text, panels, menus, dialogs): show the header.\n this.root.addEventListener('focusin', () => this.root.classList.add('is-focused'));\n this.root.addEventListener('focusout', () => {\n setTimeout(() => {\n if (!this.root.contains(activeElement(this.root)))\n this.root.classList.remove('is-focused');\n }, 0);\n });\n }\n\n this.ui = new UiManager(\n this.root,\n createTranslator(options.language, options.translations),\n () => this.focus(),\n this,\n );\n // The interface says its language (WCAG 3.1.2), so it is read in that language on a page in\n // another one; the text keeps the page's language.\n if (options.language) {\n for (const part of [header, statusbarHost, this.ui.overlayHost]) part.lang = options.language;\n }\n // The prompt in an empty image caption goes through a CSS variable (it isn't in the document's HTML).\n this.root.style.setProperty(\n '--nova-caption-placeholder',\n JSON.stringify(this.ui.t('image.captionPlaceholder')),\n );\n\n const editorKeys = keymap({\n 'Mod-k': () => (openLinkDialog(this), true),\n // The standard accessibility shortcut: move from the text to the toolbar.\n 'Alt-F9': () => {\n if (!this.menubar) return false;\n this.menubar.focus();\n return true;\n },\n 'Alt-F10': () => {\n if (!this.toolbar) return false;\n this.toolbar.focus();\n return true;\n },\n // Move to the context toolbar (image, table).\n 'Ctrl-F9': () => focusContextToolbar(this),\n 'Mod-f': () => (this.openSearch(), true),\n 'Mod-Shift-f': () => (toggleFullscreen(this), true),\n 'Alt-0': () => (openHelp(this), true),\n // Escape in the text closes the search bar if it is open.\n Escape: () => {\n if (!this.searchBar?.isOpen()) return false;\n this.searchBar.close();\n return true;\n },\n });\n\n // Plugins: synchronous ones are attached right away (their ProseMirror plugins go into the initial state),\n // lazy ones after the editor is created.\n // distraction-free makes no sense without quickbars, so it is attached automatically.\n const pluginEntries = [...(options.plugins ?? [])];\n if (distractionFree && !pluginEntries.includes('quickbars')) pluginEntries.push('quickbars');\n const resolved = resolveEntries(pluginEntries);\n resolved.errors.forEach((message) => reportPluginError(message));\n const { ordered: syncPlugins, errors: orderErrors } = orderPlugins(resolved.plugins);\n orderErrors.forEach((message) => reportPluginError(message));\n // Lazy parts of plugins with nodes (NovaPlugin.load) load together with the lazy plugins.\n for (const plugin of syncPlugins) if (plugin.load) resolved.loaders.push(plugin.load);\n const pluginPm = syncPlugins.flatMap((plugin) => this.collectPmPlugins(plugin));\n\n const hasRules =\n options.validElements !== undefined ||\n options.invalidElements !== undefined ||\n options.validStyles !== undefined;\n this.contentRules = hasRules ? new ContentRules(options) : null;\n // The same schema as createRenderer() on the server: the editor's and the server's HTML match.\n // The set of classes is live: formatter.register() in setup adds to it as well.\n const { schema, allowedClasses } = schemaFromOptions(\n options,\n syncPlugins,\n this.direction,\n this,\n );\n this.schema = schema;\n this.formatter = new Formatter(this, allowedClasses);\n this.selection = createSelection(this);\n for (const [name, spec] of Object.entries(options.formats ?? {}))\n this.formatter.register(name, spec);\n syncPlugins.forEach((plugin) => this.registerCommands(plugin));\n // A whole page around the content (fullpagehtml): its head lives in the document's attributes.\n const page = pageHandlerOf(syncPlugins, this);\n if (page) pages.set(this, page);\n const initialDoc = parseContent(this.schema, options.content ?? '', page);\n\n const tablesAnchor = searchPlugin();\n const initialPlugins = [\n // First: while the list is open, Enter/Tab/arrows belong to the autocompleter, not the keymap.\n autocompleterPlugin(this),\n ...(options.textPatterns === false\n ? []\n : Array.isArray(options.textPatterns) || options.textPatternsLookup\n ? [\n textPatternsPlugin(\n this,\n Array.isArray(options.textPatterns) ? options.textPatterns : [],\n options.textPatternsLookup,\n ),\n ]\n : [\n buildInputRules((name) => this.isAllowed(name), this.schema),\n codeFenceKeymap((name) => this.isAllowed(name), this.schema),\n ]),\n editorKeys,\n // The table plugins go here (before the general keymap) once the mechanics load: Tab in a table is\n // the next cell, not a list indent. See installTables().\n tablesAnchor,\n ...buildKeymap((name) => this.resolveCommand(name)),\n // Screen readers hear what a formatting shortcut or a typed Markdown shortcut changed.\n announcePlugin(this.ui.t, (text) => this.ui.announce(text)),\n ...(syncPlugins.some((plugin) => plugin.replaceHistory) ? [] : [history()]),\n dropCursor({ color: 'var(--nova-accent)', width: 2 }),\n gapCursor(),\n imageDropPastePlugin(this),\n embeddedImageUploadPlugin(this),\n pastePlugin(this),\n linkBubblePlugin(this),\n contextToolbarPlugin(this),\n ...(this.contentRules ? [contentRulesPlugin(this.contentRules)] : []),\n // After plugins with their own clicks (link, panels): the first click without focus lands where you clicked.\n firstClickPlugin(),\n // editor.selection's bookmarks move along with the changes.\n bookmarksPlugin(),\n ...pluginPm,\n ...(options.prosemirrorPlugins ?? []),\n ];\n // Loading lazy parts rebuilds the set of plugins, and their views must survive it.\n keepPluginViews(initialPlugins);\n const state = EditorState.create({\n doc: this.contentRules ? this.contentRules.normalizeDoc(initialDoc) : initialDoc,\n plugins: initialPlugins,\n });\n\n this.editable = options.editable ?? true;\n this.disabled = options.disabled ?? false;\n this.pasteAsText = options.pasteAsText ?? false;\n const handleTransaction = this.handleTransaction.bind(this);\n this.view = new EditorView(contentHost, {\n state,\n editable: () => this.isEditable(),\n attributes: {\n class: 'nova-prosemirror',\n role: 'textbox',\n 'aria-multiline': 'true',\n 'aria-label': this.ui.t('editor.label'),\n // The visible placeholder is CSS generated content with empty alternative text (style.css);\n // screen readers get it as aria-placeholder, not as text inside the document.\n ...(options.placeholder\n ? { 'data-placeholder': options.placeholder, 'aria-placeholder': options.placeholder }\n : {}),\n },\n // ProseMirror calls dispatchTransaction with this = the view: plugins (collaboration sync,\n // for example) may dispatch a transaction while still inside the EditorView constructor,\n // when the editor's this.view isn't assigned yet.\n dispatchTransaction: function (this: EditorView, tr: Transaction) {\n handleTransaction(tr, this);\n },\n // The same parser for paste as for setContent: the same preprocessing.\n clipboardParser: parserFor(this.schema),\n nodeViews: {\n image: (node, view, getPos) => new ImageView(node, view, getPos, this),\n },\n // Bold, italic and the like stay part of the line's text for screen readers (mark-views.ts).\n markViews: flatMarkViews(this.schema),\n handleDOMEvents: {\n focus: (_view, event) => (this.emit('focus', { event }), false),\n blur: (_view, event) => (this.emit('blur', { event }), false),\n },\n handleKeyDown: (_view, event) => {\n this.emit('keydown', { event });\n return event.defaultPrevented;\n },\n });\n this.root.classList.toggle('nova-readonly', !this.editable);\n this.applyDisabled();\n\n registerBuiltins(this);\n registerMenuItems(this);\n if (options.slashCommands !== false) registerSlashCommands(this, options.slashCommands ?? []);\n syncPlugins.forEach((plugin) => this.setupPlugin(plugin));\n options.setup?.(this);\n\n const menubarConfig =\n options.menubar === true\n ? DEFAULT_MENUBAR\n : typeof options.menubar === 'string'\n ? options.menubar\n : null;\n this.menubar = menubarConfig\n ? createMenubar(this, menubarHost, menubarConfig, { ...DEFAULT_MENUS, ...options.menu })\n : null;\n if (!this.menubar) menubarHost.remove();\n\n this.toolbar =\n options.toolbar === false || (distractionFree && options.toolbar === undefined)\n ? null\n : createToolbar(\n this,\n toolbarHost,\n this.toolbarConfig(),\n options.toolbarMode ?? 'floating',\n // Until lazy plugins load, their buttons aren't registered yet, so no warning.\n { warnUnknown: resolved.loaders.length === 0 },\n );\n if (!this.toolbar) toolbarHost.remove();\n if (!this.toolbar && !this.menubar) header.remove();\n\n // The find and replace bar is a separate chunk, loaded right away (and awaited by ready): it is\n // there before anyone presses Ctrl+F, without weighing on the first load.\n this.contentHost = contentHost;\n const searchBar = this.loadSearchBar();\n // The statusbar is on by default only in classic: inline/distraction-free are part of the page.\n const statusbar = options.statusbar ?? this.mode === 'classic';\n this.statusbar = statusbar ? createStatusbar(this, statusbarHost) : null;\n if (!this.statusbar) statusbarHost.remove();\n\n if (options.onChange) this.on('change', options.onChange);\n this.updatePlaceholder();\n\n const contentCss = this.applyContentStyles();\n this.ready = Promise.all([\n resolved.loaders.length ? this.loadLazyPlugins(resolved.loaders) : undefined,\n contentCss,\n // Office paste cleanup is a separate chunk, loaded in the background (see paste.ts).\n loadPasteCleaner(),\n // Table mechanics are a separate chunk (~10 KB gzip), loaded in the background (see tables.ts).\n this.installTables(tablesAnchor),\n searchBar,\n ]).then(() => {\n if (!this.destroyed) this.emit('init');\n });\n }\n\n /**\n * Install table editing (cell selection, column widths, Tab between cells) once it has loaded, at\n * its place before `anchor`, as if the plugins had been there from the start.\n */\n private async installTables(anchor: Plugin): Promise<void> {\n const tables = await loadTables();\n if (!tables || this.destroyed) return;\n const { state } = this.view;\n const at = state.plugins.indexOf(anchor);\n const plugins = [...state.plugins];\n plugins.splice(at < 0 ? plugins.length : at, 0, ...tables.tablePlugins());\n reconfigurePlugins(this.view, plugins);\n this.updateUI();\n }\n\n /** contentStyle right away, contentCss as it loads. Each editor gets its own scope. */\n private applyContentStyles(): Promise<void> | undefined {\n const { contentStyle, contentCss } = this.options;\n const files =\n contentCss === undefined ? [] : Array.isArray(contentCss) ? contentCss : [contentCss];\n if (!contentStyle && !files.length) return undefined;\n const id = `nova-cs-${++contentScopeId}`;\n this.root.classList.add(id);\n const scope = `.nova-editor.${id} .nova-prosemirror`;\n // The order as in TinyMCE: files first, then content_style (it overrides the files).\n const sheets: string[] = files.map(() => '');\n let detach: (() => void) | null = null;\n const apply = () => {\n if (this.destroyed) return;\n detach?.();\n detach = attachCss(this.root, scopeCss([...sheets, contentStyle ?? ''].join('\\n'), scope));\n };\n this.cleanups.push(() => detach?.());\n apply();\n if (!files.length) return undefined;\n return Promise.all(\n files.map((url, index) =>\n loadCss(url).then(\n (css) => {\n sheets[index] = css;\n },\n (error) => console.warn(`[nova] contentCss: could not load ${url}`, error),\n ),\n ),\n ).then(apply);\n }\n\n // ---------- plugins ----------\n\n /** Whether content restrictions allow a control, command or tag (always true without restrictions). */\n isAllowed(name: string): boolean {\n return this.contentRules?.isAllowed(name) ?? true;\n }\n\n hasPlugin(name: string): boolean {\n return this.pluginsByName.has(name);\n }\n\n private collectPmPlugins(plugin: NovaPlugin): Plugin[] {\n try {\n const pm = plugin.prosemirrorPlugins?.(this) ?? [];\n if (plugin.nodeViews) {\n const nodeViews = Object.fromEntries(\n Object.entries(plugin.nodeViews).map(([name, factory]) => [name, factory(this)]),\n );\n pm.push(new Plugin({ props: { nodeViews } }));\n }\n return pm;\n } catch (error) {\n reportPluginError(`Plugin \"${plugin.name}\" failed to create ProseMirror plugins`, error);\n return [];\n }\n }\n\n /** setup with errors isolated: a failing plugin doesn't break the editor. */\n private setupPlugin(plugin: NovaPlugin): void {\n try {\n const cleanup = plugin.setup?.(this);\n if (typeof cleanup === 'function') this.cleanups.push(cleanup);\n this.pluginsByName.set(plugin.name, plugin);\n } catch (error) {\n reportPluginError(`Plugin \"${plugin.name}\" failed during setup`, error);\n }\n }\n\n private async loadLazyPlugins(loaders: Parameters<typeof loadPlugin>[0][]): Promise<void> {\n const results = await Promise.all(\n loaders.map((loader) =>\n loadPlugin(loader).catch((error: unknown) => {\n reportPluginError('Failed to load plugin', error);\n return null;\n }),\n ),\n );\n if (this.destroyed) return;\n // The schema is fixed when the editor is created: a lazy plugin can't add nodes and marks.\n const loaded = results.filter((p): p is NovaPlugin => {\n if (!p) return false;\n if (p.nodes || p.marks) {\n reportPluginError(\n `Plugin \"${p.name}\" defines nodes or marks and cannot be loaded lazily; pass the plugin object instead`,\n );\n return false;\n }\n return true;\n });\n const { ordered, errors } = orderPlugins(loaded, new Set(this.pluginsByName.keys()));\n errors.forEach((message) => reportPluginError(message));\n const extraPm = ordered.flatMap((plugin) => this.collectPmPlugins(plugin));\n if (extraPm.length) {\n reconfigurePlugins(this.view, [...this.view.state.plugins, ...extraPm]);\n }\n ordered.forEach((plugin) => {\n this.registerCommands(plugin);\n this.setupPlugin(plugin);\n });\n this.rebuildToolbar();\n }\n\n /**\n * Refresh the button state (pressed / enabled) without changing the document — for example, after a\n * plugin switched a display mode. Document changes refresh the UI by themselves.\n */\n updateUI(): void {\n if (this.destroyed) return;\n this.toolbar?.update();\n }\n\n /** Rebuild the toolbar (after plugins registered new buttons). */\n rebuildToolbar(): void {\n if (!this.toolbar || this.destroyed) return;\n this.toolbar.destroy();\n this.toolbar = createToolbar(\n this,\n this.toolbarHost,\n this.toolbarConfig(),\n this.options.toolbarMode ?? 'floating',\n );\n }\n\n /** Toolbar configuration: yours as it is; the default one plus the buttons of active plugins. */\n private toolbarConfig(): ToolbarConfig {\n if (this.options.toolbar) return this.options.toolbar;\n const extra = [...this.pluginsByName.values()].map((p) => p.toolbar).filter(Boolean);\n return extra.length ? `${defaultToolbar} | ${extra.join(' ')}` : defaultToolbar;\n }\n\n private handleTransaction(tr: Transaction, view: EditorView = this.view): void {\n // Plugins with timers (collaboration cursors) may send a transaction\n // after destroy(), and there is nothing to apply it to.\n if (view.isDestroyed) return;\n for (const transform of this.transactionTransforms) tr = transform(tr, view.state, this);\n view.updateState(view.state.apply(tr));\n // Still inside the EditorView constructor: no interface and no subscribers yet, only the state.\n if (!this.view) return;\n this.toolbar?.update();\n this.statusbar?.update(tr.docChanged);\n this.searchBar?.update();\n this.updatePlaceholder();\n if (tr.docChanged) {\n this.emit('change', { transaction: tr });\n const programmatic = tr.getMeta(API_CHANGE_META) || tr.getMeta(REMOTE_CHANGE_META);\n if (!programmatic && tr.getMeta('addToHistory') !== false) {\n this.emit('input', { transaction: tr });\n }\n }\n if (tr.selectionSet || tr.docChanged) this.emit('selectionChange', { transaction: tr });\n }\n\n private updatePlaceholder(): void {\n const doc = this.view.state.doc;\n const empty =\n doc.childCount === 1 &&\n doc.firstChild?.type === this.schema.nodes.paragraph &&\n doc.firstChild.content.size === 0;\n this.view.dom.classList.toggle('nova-empty', empty);\n }\n\n // ---------- content ----------\n\n /**\n * The document's HTML. Deterministic: the same in every browser and in Node. With the fullpagehtml\n * plugin it is the whole page (doctype, head, body); `fullPage: false` gives only the content.\n */\n getHTML({ fullPage = true }: { fullPage?: boolean } = {}): string {\n const doc = this.view.state.doc;\n const content = htmlSerializer.serializeFragment(doc.content);\n const page = fullPage ? pages.get(this) : undefined;\n return page ? page.write(content, doc.attrs) : content;\n }\n\n getJSON(): Record<string, unknown> {\n return this.view.state.doc.toJSON() as Record<string, unknown>;\n }\n\n getText(): string {\n return this.view.state.doc.textBetween(0, this.view.state.doc.content.size, '\\n\\n');\n }\n\n /**\n * Replace the content. By default it can be undone. With the fullpagehtml plugin, HTML that is a\n * whole page (or JSON) replaces the page too; HTML that is only content, or `fullPage: false`,\n * keeps the page as it is.\n */\n setContent(\n content: string | Record<string, unknown>,\n { addToHistory = true, fullPage = true }: { addToHistory?: boolean; fullPage?: boolean } = {},\n ): void {\n const detail = { content };\n this.emit('beforeSetContent', detail);\n const page = fullPage ? pages.get(this) : undefined;\n const doc = parseContent(this.schema, detail.content, page);\n const tr = this.view.state.tr.replaceWith(0, this.view.state.doc.content.size, doc.content);\n // The page's attributes come from JSON or from HTML that is a whole page; only content keeps them.\n if (page && (typeof detail.content !== 'string' || wholePages.has(doc))) {\n for (const [name, value] of Object.entries(doc.attrs)) {\n if (value !== this.view.state.doc.attrs[name]) tr.setDocAttribute(name, value);\n }\n }\n tr.setMeta(API_CHANGE_META, true).setMeta(SET_CONTENT_META, true);\n if (!addToHistory) tr.setMeta('addToHistory', false);\n this.view.dispatch(tr);\n this.emit('setContent', { content: detail.content });\n }\n\n /**\n * Insert HTML at the cursor (like insertContent in TinyMCE). The HTML is parsed by the editor's\n * schema, as a paste is: no scripts, unsafe links or unknown tags. Blocks (paragraphs, tables) are\n * inserted as separate blocks. A table inserted with the cursor inside a table goes after it\n * rather than replacing its cells.\n */\n insertContent(html: string): boolean {\n if (!this.isEditable()) return false;\n return insertContentCommand(html)(this.view.state, this.view.dispatch);\n }\n\n isEmpty(): boolean {\n return this.view.dom.classList.contains('nova-empty');\n }\n\n // ---------- commands ----------\n\n /** The command for a name: a plugin's override or the built-in one; unknown names return false. */\n private resolveCommand(name: CommandName): Command {\n name = currentName('commands', name) as CommandName;\n const command =\n this.commandOverrides.get(name) ??\n (Object.prototype.hasOwnProperty.call(commands, name) ? commands[name] : undefined);\n if (command) return command;\n // A name from untyped JavaScript (CDN): not an exception but \"not executed\" and a hint in the console.\n if (!unknownCommands.has(name)) {\n unknownCommands.add(name);\n console.warn(`[nova] unknown command \"${String(name)}\": editor.exec() returns false`);\n }\n return () => false;\n }\n\n private registerCommands(plugin: NovaPlugin): void {\n for (const [name, command] of Object.entries(plugin.commands ?? {})) {\n if (command) this.commandOverrides.set(name as CommandName, command);\n }\n if (plugin.transformTransaction) this.transactionTransforms.push(plugin.transformTransaction);\n }\n\n /** Run a named command or any ProseMirror command; returns whether it ran. */\n exec(command: CommandName | Command): boolean {\n const cmd = typeof command === 'string' ? this.resolveCommand(command) : command;\n const result = cmd(this.view.state, this.view.dispatch, this.view);\n if (result) this.view.focus();\n return result;\n }\n\n /**\n * Several commands as one edit — one undo step, one change event:\n * `editor.chain().exec('h2').exec('alignCenter').run()`. If a step fails, the document doesn't\n * change and run() returns false; `chain().….can()` checks without changing anything (for buttons).\n */\n chain(): CommandChain {\n return createChain({\n view: () => (this.destroyed ? null : this.view),\n resolve: (name) => this.resolveCommand(name),\n insertContent: (html) => (state, dispatch, view) =>\n this.isEditable() && insertContentCommand(html)(state, dispatch, view),\n });\n }\n\n /**\n * Whether the command can run in the current state (for disabled buttons). A command that throws\n * (a document with content its schema doesn't allow, from JSON) can't run: the buttons go on\n * updating instead of breaking.\n */\n can(command: CommandName | Command): boolean {\n const cmd = typeof command === 'string' ? this.resolveCommand(command) : command;\n try {\n return cmd(this.view.state, undefined, this.view);\n } catch {\n return false;\n }\n }\n\n /** Whether a named command is active for the current selection (for your own toolbar buttons). */\n isActive(command: CommandName): boolean {\n return isCommandActive(this.view.state, currentName('commands', command) as CommandName);\n }\n\n /**\n * The state of a named command for your own toolbar: whether it is active (a pressed button) and\n * whether it can run now. The equivalent of queryCommandState / queryCommandEnabled.\n */\n getCommandState(command: CommandName): { active: boolean; enabled: boolean } {\n return { active: this.isActive(command), enabled: this.isEditable() && this.can(command) };\n }\n\n focus(): void {\n if (!this.destroyed) this.view.focus();\n }\n\n /** \"Paste as text\" mode (the pastetext toggle). */\n isPasteAsText(): boolean {\n return this.pasteAsText;\n }\n\n setPasteAsText(value: boolean): void {\n this.pasteAsText = value;\n this.toolbar?.update();\n }\n\n /** The find and replace bar, loaded once (a separate chunk: the first load stays smaller). */\n private loadSearchBar(): Promise<SearchBarHandle | null> {\n this.searchBarLoad ??= import('./ui/search-bar').then(\n ({ createSearchBar }) => {\n if (this.destroyed) return null;\n this.searchBar = createSearchBar(this, this.contentHost);\n return this.searchBar;\n },\n (error: unknown) => {\n reportPluginError('The find and replace bar failed to load', error);\n return null;\n },\n );\n return this.searchBarLoad;\n }\n\n /** Open the find and replace bar (Ctrl/Cmd+F). Resolves once it is open. */\n openSearch(): Promise<void> {\n return this.loadSearchBar().then((bar) => bar?.open());\n }\n\n closeSearch(): void {\n this.searchBar?.close();\n }\n\n /** Whether the text can be edited now: neither read-only nor disabled. */\n isEditable(): boolean {\n return this.editable && !this.disabled;\n }\n\n isDisabled(): boolean {\n return this.disabled;\n }\n\n /** Disable or enable the editor (like disabled on a form field). */\n setDisabled(value: boolean): void {\n if (this.disabled === value) return;\n this.disabled = value;\n this.view.setProps({});\n this.applyDisabled();\n if (value) {\n this.ui.closePopover();\n this.view.dom.blur();\n }\n this.toolbar?.update();\n this.emit('editableChange');\n }\n\n private applyDisabled(): void {\n this.root.classList.toggle('nova-disabled', this.disabled);\n if (this.disabled) this.root.setAttribute('aria-disabled', 'true');\n else this.root.removeAttribute('aria-disabled');\n // A disabled field leaves the Tab order (like <textarea disabled>).\n if (this.disabled) this.view.dom.setAttribute('tabindex', '-1');\n else this.view.dom.removeAttribute('tabindex');\n }\n\n setEditable(value: boolean): void {\n if (this.editable === value) return;\n this.editable = value;\n this.view.setProps({});\n this.root.classList.toggle('nova-readonly', !value);\n if (!value) this.ui.closePopover();\n this.toolbar?.update();\n this.emit('editableChange');\n }\n\n // ---------- events ----------\n\n on<E extends EditorEvent>(event: E, listener: EditorListener<E>): () => void {\n event = currentName('events', event) as E;\n let set = this.listeners.get(event);\n if (!set) this.listeners.set(event, (set = new Set()));\n set.add(listener as EditorListener);\n return () => this.off(event, listener);\n }\n\n off<E extends EditorEvent>(event: E, listener: EditorListener<E>): void {\n event = currentName('events', event) as E;\n this.listeners.get(event)?.delete(listener as EditorListener);\n }\n\n private emit<E extends EditorEvent>(\n event: E,\n ...[detail]: EditorEventDetails[E] extends undefined ? [] : [EditorEventDetails[E]]\n ): void {\n for (const listener of this.listeners.get(event) ?? []) {\n // An error in the customer's handler must not break the editor and the other subscribers.\n try {\n (listener as EditorListener<E>)(this, detail as EditorEventDetails[E]);\n } catch (error) {\n reportPluginError(`Listener for \"${event}\" failed`, error);\n }\n }\n }\n\n destroy(): void {\n if (this.destroyed) return;\n this.emit('destroy');\n this.destroyed = true;\n this.menubar?.destroy();\n this.ui.destroy();\n this.toolbar?.destroy();\n this.statusbar?.destroy();\n for (const cleanup of this.cleanups.splice(0)) {\n try {\n cleanup();\n } catch (error) {\n reportPluginError('Plugin cleanup failed', error);\n }\n }\n this.searchBar?.destroy();\n if (this.root.classList.contains('nova-fullscreen')) toggleFullscreen(this, false);\n this.view.destroy();\n this.root.remove();\n this.listeners.clear();\n }\n}\n\nfunction reportPluginError(message: string, error?: unknown): void {\n console.error(`[nova] ${message}`, ...(error === undefined ? [] : [error]));\n}\n\n/** Documents read from HTML that was a whole page: their attributes are that page's. */\nconst wholePages = new WeakSet<PMNode>();\n\nexport function parseContent(\n schema: NovaSchema,\n content: string | Record<string, unknown>,\n page?: PageHandler | null,\n): PMNode {\n if (typeof content !== 'string') return PMNode.fromJSON(schema, sanitizeJSON(schema, content));\n // A whole page: its head goes into the document's attributes, its body is the content.\n const parts = page ? page.read(content) : null;\n const container = document.createElement('div');\n // Parsing through <template>: scripts and handlers don't run while parsing.\n // A full sanitizer will come as a separate module.\n const template = document.createElement('template');\n template.innerHTML = parts ? parts.content : content;\n container.appendChild(template.content);\n const doc = parserFor(schema).parse(container);\n if (!parts) return doc;\n const whole = doc.type.create(parts.attrs, doc.content);\n wholePages.add(whole);\n return whole;\n}\n\nexport function createEditor(options: EditorOptions): Editor {\n return new Editor(options);\n}\n","import { Plugin, Selection } from 'prosemirror-state';\nimport type { EditorView } from 'prosemirror-view';\n\n/** The browser's cursor position in the document; null when the selection isn't in the editor's text (or is in a shadow root). */\nfunction browserCaret(view: EditorView): number | null {\n const selection = view.dom.ownerDocument.getSelection();\n const node = selection?.focusNode;\n if (!selection || !node || !view.dom.contains(node)) return null;\n try {\n return view.posAtDOM(node, selection.focusOffset);\n } catch {\n return null;\n }\n}\n\n/**\n * The first click into an unfocused editor lands where you clicked. A click away from the text (to the right of\n * the last line, below it) is turned by browsers into a cursor at the start of the document when they focus,\n * in Chromium, WebKit and Firefox. The click position ProseMirror computes is correct: if\n * the browser's cursor ended up in another block, it is put there. The same block is left alone;\n * ProseMirror itself selects images, mentions and other atom nodes.\n */\nexport function firstClickPlugin(): Plugin {\n let focusedOnMouseDown = true;\n return new Plugin({\n props: {\n handleDOMEvents: {\n mousedown(view) {\n focusedOnMouseDown = view.hasFocus();\n return false;\n },\n },\n handleClick(view, pos, event) {\n if (focusedOnMouseDown || event.button !== 0 || event.shiftKey || event.detail > 1)\n return false;\n const { doc } = view.state;\n const hit = view.posAtCoords({ left: event.clientX, top: event.clientY });\n const node = hit && hit.inside >= 0 ? doc.nodeAt(hit.inside) : null;\n if (node && !node.isTextblock) return false;\n const $pos = doc.resolve(pos);\n const caret = browserCaret(view);\n if (caret !== null && doc.resolve(caret).parent === $pos.parent) return false;\n const selection = Selection.near($pos);\n if (!view.state.selection.eq(selection))\n view.dispatch(view.state.tr.setSelection(selection).setMeta('pointer', true));\n // The browser has already placed its selection: focus() writes the editor's selection into the DOM.\n view.focus();\n return true;\n },\n },\n });\n}\n","import { Plugin, PluginKey, type Command, type EditorState } from 'prosemirror-state';\nimport { commands, isCommandActive, type CommandName } from './commands';\nimport type { MessageKey } from './i18n/en';\nimport type { Translator } from './i18n';\n\n/**\n * Spoken feedback for changes a sighted person sees at once but a screen reader doesn't report by itself:\n * a format switched with a shortcut (Ctrl+B says \"Bold on\") and a Markdown shortcut that turned the line\n * into something else (typing \"- \" says \"Bulleted list\"). The text goes to the editor's hidden polite\n * live region (editor.ui.announce), so focus and the caret stay where they are.\n */\n\ntype Spoken = { command: CommandName } | { typed: true };\n\n/** Transaction meta: the named command ran from a keyboard shortcut. */\nexport const announceKey = new PluginKey<Spoken | null>('nova-announce');\n\n/** A shortcut whose result is spoken: its transaction carries the command's name. */\nexport function spokenCommand(name: CommandName): Command {\n return (state, dispatch, view) =>\n commands[name](state, dispatch && ((tr) => dispatch(tr.setMeta(announceKey, name))), view);\n}\n\n/** Formats with an on/off state: the line says which. */\nconst TOGGLES: ReadonlySet<CommandName> = new Set<CommandName>([\n 'bold',\n 'italic',\n 'underline',\n 'strike',\n 'code',\n 'subscript',\n 'superscript',\n 'bulletList',\n 'orderedList',\n]);\nconst BLOCK_TYPES: ReadonlySet<CommandName> = new Set<CommandName>([\n 'paragraph',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n]);\nconst ALIGNMENTS: readonly CommandName[] = [\n 'alignLeft',\n 'alignCenter',\n 'alignRight',\n 'alignJustify',\n];\n\n/** The structure around the cursor, outermost first, as label keys: lists, quotes, headings, code. */\nfunction blockKeys(state: EditorState): MessageKey[] {\n const { $from } = state.selection;\n const keys: MessageKey[] = [];\n for (let depth = 1; depth <= $from.depth; depth++) {\n const node = $from.node(depth);\n const name = node.type.name;\n if (name === 'bullet_list') keys.push('bulletList');\n else if (name === 'ordered_list') keys.push('orderedList');\n else if (name === 'blockquote') keys.push('blockquote');\n else if (name === 'code_block') keys.push('codeBlock');\n else if (name === 'heading')\n keys.push(`h${Math.min(6, Math.max(1, Number(node.attrs.level) || 1))}` as MessageKey);\n }\n return keys;\n}\n\n/** What a shortcut changed, in words. */\nexport function describeCommand(state: EditorState, command: CommandName, t: Translator): string {\n if (TOGGLES.has(command)) {\n return t(isCommandActive(state, command) ? 'announce.on' : 'announce.off', {\n name: t(command as MessageKey),\n });\n }\n if (BLOCK_TYPES.has(command)) {\n const heading = blockKeys(state)\n .filter((key) => /^h[1-6]$/.test(key))\n .pop();\n return t(heading ?? 'paragraph');\n }\n if (ALIGNMENTS.includes(command)) {\n return t(ALIGNMENTS.find((align) => isCommandActive(state, align)) ?? 'alignLeft');\n }\n return t(command as MessageKey);\n}\n\n/** What a typed Markdown shortcut turned the line into, or null when the structure didn't change (\"...\" → \"…\"). */\nexport function describeTyped(\n before: EditorState,\n after: EditorState,\n t: Translator,\n): string | null {\n const old = blockKeys(before);\n const now = blockKeys(after);\n const changed = now.findIndex((key, i) => key !== old[i]);\n return changed < 0 ? null : t(now[changed]!);\n}\n\n/** Watches transactions and says what changed. `say` writes to the live region. */\nexport function announcePlugin(t: Translator, say: (text: string) => void): Plugin<Spoken | null> {\n return new Plugin<Spoken | null>({\n key: announceKey,\n state: {\n init: () => null,\n apply(tr, _value, _old, state) {\n const command = tr.getMeta(announceKey) as CommandName | undefined;\n if (command) return { command };\n // Markdown shortcuts come from input-rule plugins (ours and plugins'): their transactions carry the plugin as meta.\n if (state.plugins.some((plugin) => plugin.spec.isInputRules && tr.getMeta(plugin)))\n return { typed: true };\n return null;\n },\n },\n view: () => ({\n update(view, prevState) {\n const spoken = announceKey.getState(view.state);\n if (!spoken || spoken === announceKey.getState(prevState)) return;\n const text =\n 'command' in spoken\n ? describeCommand(view.state, spoken.command, t)\n : describeTyped(prevState, view.state, t);\n if (text) say(text);\n },\n }),\n });\n}\n","/**\n * Renamed parts of the public API keep working: an old option, command or event name is mapped to the\n * new one, and the console says so once per page, naming the replacement. From 1.0 an old name stays for\n * at least one minor version (https://novaprose.com/project/versioning/). The tables below are empty\n * until something is renamed; a rename adds one line here and a line in the changelog.\n */\n\nexport interface Renames {\n options: Record<string, string>;\n commands: Record<string, string>;\n events: Record<string, string>;\n}\n\n/** What has been renamed: old name → new name. */\nexport const RENAMED: Renames = { options: {}, commands: {}, events: {} };\n\nconst KIND: Record<keyof Renames, string> = {\n options: 'the option',\n commands: 'the command',\n events: 'the event',\n};\n\nconst warned = new Set<string>();\n\n/** Logs once per page that something is deprecated and what to use instead. */\nexport function deprecate(what: string, instead: string): void {\n if (warned.has(what)) return;\n warned.add(what);\n console.warn(\n `[nova] ${what} is deprecated: use ${instead}. Old names keep working for at least one minor version (https://novaprose.com/project/versioning/).`,\n );\n}\n\nconst own = (table: Record<string, string>, key: string) =>\n Object.prototype.hasOwnProperty.call(table, key) ? table[key] : undefined;\n\n/** The current name of an option, command or event: a renamed one is mapped, with a warning. */\nexport function currentName(kind: keyof Renames, name: string, renamed: Renames = RENAMED): string {\n const next = own(renamed[kind], name);\n if (next === undefined) return name;\n deprecate(`${KIND[kind]} \"${name}\"`, `\"${next}\"`);\n return next;\n}\n\n/** Options with renamed keys moved to their new names. A new name given as well wins. */\nexport function renameOptions<T extends object>(options: T, renamed: Renames = RENAMED): T {\n let result = options as Record<string, unknown>;\n for (const [old, next] of Object.entries(renamed.options)) {\n if (!Object.prototype.hasOwnProperty.call(options, old)) continue;\n deprecate(`${KIND.options} \"${old}\"`, `\"${next}\"`);\n if (result === options) result = { ...result };\n if (!Object.prototype.hasOwnProperty.call(result, next)) result[next] = result[old];\n delete result[old];\n }\n return result as T;\n}\n","import {\n inputRules,\n textblockTypeInputRule,\n wrappingInputRule,\n ellipsis,\n emDash,\n type InputRule,\n} from 'prosemirror-inputrules';\nimport { keymap } from 'prosemirror-keymap';\nimport type { Command, Plugin } from 'prosemirror-state';\nimport { schema as baseSchema, type NovaSchema } from './schema';\n\n/** The language after a code block fence: the same characters the `language-…` class allows. */\nconst LANGUAGE = '([A-Za-z0-9_+#.-]{0,32})';\n\n/**\n * Markdown shortcuts while typing (text patterns): #, -, 1., >, ```.\n * isAllowed applies the content restrictions: a forbidden shortcut simply doesn't fire.\n */\nexport function buildInputRules(\n isAllowed: (name: string) => boolean = () => true,\n schema: NovaSchema = baseSchema,\n): Plugin {\n const { nodes } = schema;\n const rules: InputRule[] = [ellipsis, emDash];\n if (isAllowed('blockquote')) rules.push(wrappingInputRule(/^\\s*>\\s$/, nodes.blockquote));\n if (isAllowed('numlist')) {\n rules.push(\n wrappingInputRule(\n /^(\\d+)\\.\\s$/,\n nodes.ordered_list,\n (match) => ({ start: Number(match[1]) }),\n (match, node) => node.childCount + node.attrs.start === Number(match[1]),\n ),\n );\n }\n if (isAllowed('bullist')) rules.push(wrappingInputRule(/^\\s*([-+*])\\s$/, nodes.bullet_list));\n if (isAllowed('codeblock')) {\n // A fence as in Markdown: \"```\" and a space (or Enter, codeFenceKeymap), with a language \"```js \".\n rules.push(\n textblockTypeInputRule(new RegExp(`^\\`\\`\\`${LANGUAGE}\\\\s$`), nodes.code_block, (match) => ({\n language: match[1] || null,\n })),\n );\n }\n // One rule per allowed level: \"## \" must not produce a forbidden h2.\n for (let level = 1; level <= 6; level++) {\n if (!isAllowed(`h${level}`)) continue;\n rules.push(textblockTypeInputRule(new RegExp(`^(#{${level}})\\\\s$`), nodes.heading, { level }));\n }\n // Typographic quotes depend on the language (« guillemets » vs “curly quotes”), so they are left out for now.\n return inputRules({ rules });\n}\n\n/**\n * Enter at the end of a \"```\" or \"```js\" paragraph makes a code block (with the language). Input rules fire only\n * on typed text, and a Markdown fence is usually closed with Enter.\n */\nexport function codeFenceKeymap(\n isAllowed: (name: string) => boolean = () => true,\n schema: NovaSchema = baseSchema,\n): Plugin {\n const fence = new RegExp(`^\\`\\`\\`${LANGUAGE}$`);\n const fenceToCodeBlock: Command = (state, dispatch) => {\n const { $from, empty } = state.selection;\n const block = $from.parent;\n if (!empty || block.type !== schema.nodes.paragraph || !isAllowed('codeblock')) return false;\n if ($from.parentOffset !== block.content.size || block.childCount !== 1) return false;\n const match = block.firstChild!.isText ? fence.exec(block.textContent) : null;\n if (!match) return false;\n const index = $from.index(-1);\n if (!$from.node(-1).canReplaceWith(index, index + 1, schema.nodes.code_block)) return false;\n if (dispatch) {\n const start = $from.start();\n const tr = state.tr\n .delete(start, $from.pos)\n .setBlockType(start, start, schema.nodes.code_block, { language: match[1] || null });\n dispatch(tr.scrollIntoView());\n }\n return true;\n };\n return keymap({ Enter: fenceToCodeBlock });\n}\n","import { Plugin, TextSelection, type EditorState } from 'prosemirror-state';\nimport type { EditorView } from 'prosemirror-view';\nimport type { CommandName } from './commands';\nimport type { Editor } from './editor';\n\n/**\n * Your own typing shortcuts (`textPatterns: [...]`), in place of the built-in ones. Three kinds:\n * - at the start of a block: `{ start: '#', format: 'h1' }`, `{ start: '1.', command: 'orderedList' }`\n * — when a space follows the start (or Enter, `trigger: 'enter'`);\n * - between two markers: `{ start: '*', end: '*', format: 'italic' }` — when the end marker is typed\n * and a space or Enter follows it;\n * - a replacement: `{ start: '(c)', replacement: '©' }` — when a space or Enter follows it.\n * `format` is a format registered with `formats` (`editor.formatter`) or a built-in one: bold, italic,\n * underline, strikethrough, code, subscript, superscript, p, h1–h6, blockquote, pre. `command` is a\n * named command or a function that gets the editor and `value`.\n */\nexport type TextPattern = InlinePattern | BlockPattern | ReplacementPattern;\n\n/** A command a pattern runs: a named one, or your own function. */\nexport type TextPatternCommand = CommandName | ((editor: Editor, value?: unknown) => void);\n\nexport interface InlinePattern {\n start: string;\n end: string;\n format?: string;\n command?: TextPatternCommand;\n value?: unknown;\n}\n\nexport interface BlockPattern {\n start: string;\n format?: string;\n command?: TextPatternCommand;\n value?: unknown;\n /** What completes the pattern: a space after it (default) or Enter at the end of the block. */\n trigger?: 'space' | 'enter';\n}\n\nexport interface ReplacementPattern {\n start: string;\n replacement: string;\n}\n\n/** What `textPatternsLookup` gets on every attempt: the block's text before the cursor and its element. */\nexport interface TextPatternContext {\n text: string;\n block: HTMLElement | null;\n}\n\n/** Built-in format names and the commands that make them. */\nconst FORMATS: Record<string, CommandName> = {\n bold: 'bold',\n italic: 'italic',\n underline: 'underline',\n strikethrough: 'strike',\n strike: 'strike',\n code: 'code',\n subscript: 'subscript',\n superscript: 'superscript',\n p: 'paragraph',\n paragraph: 'paragraph',\n h1: 'h1',\n h2: 'h2',\n h3: 'h3',\n h4: 'h4',\n h5: 'h5',\n h6: 'h6',\n blockquote: 'blockquote',\n pre: 'codeBlock',\n};\n\n/** Patterns from options can be anything: only well-formed ones are kept. */\nfunction clean(list: readonly unknown[]): TextPattern[] {\n const out: TextPattern[] = [];\n for (const raw of list) {\n const p = raw as Partial<InlinePattern & BlockPattern & ReplacementPattern> | null;\n if (!p || typeof p.start !== 'string' || !p.start || p.start.length > 40) continue;\n if (typeof p.replacement === 'string') out.push({ start: p.start, replacement: p.replacement });\n else if (typeof p.format !== 'string' && !p.command) continue;\n else if (typeof p.end === 'string' && p.end) out.push(p as InlinePattern);\n else out.push(p as BlockPattern);\n }\n // The longest first: \"**\" before \"*\".\n return out.sort((a, b) => b.start.length - a.start.length);\n}\n\n/** The block's text before the cursor, one character for each non-text node (positions stay exact). */\nfunction textBefore(state: EditorState): string | null {\n const { $from, empty } = state.selection;\n if (!empty || !$from.parent.isTextblock || $from.parent.type.spec.code) return null;\n if ($from.marks().some((m) => m.type.spec.code)) return null;\n return $from.parent.textBetween(0, $from.parentOffset, undefined, '');\n}\n\n/** Runs a pattern's format or command on the current selection. */\nfunction run(editor: Editor, pattern: InlinePattern | BlockPattern): void {\n const { format, command, value } = pattern;\n if (typeof command === 'function') command(editor, value);\n else if (typeof command === 'string') editor.exec(command);\n else if (format && editor.formatter.has(format)) editor.formatter.apply(format);\n else if (format && FORMATS[format]) editor.exec(FORMATS[format]);\n}\n\nexport function textPatternsPlugin(\n editor: Editor,\n patterns: readonly unknown[],\n lookup?: (context: TextPatternContext) => unknown[],\n): Plugin {\n const fixed = clean(patterns);\n const all = (view: EditorView, text: string): TextPattern[] => {\n if (!lookup) return fixed;\n const { $from } = view.state.selection;\n const dom = view.nodeDOM($from.before());\n let extra: unknown = [];\n try {\n extra = lookup({ text, block: dom instanceof HTMLElement ? dom : null });\n } catch (error) {\n console.error('[nova] textPatternsLookup failed:', error);\n }\n return Array.isArray(extra) ? clean([...fixed, ...extra]) : fixed;\n };\n\n /** Tries the patterns at the cursor: the kind of the one applied, or null. */\n const attempt = (\n view: EditorView,\n trigger: 'space' | 'enter',\n ): 'block' | 'inline' | 'replacement' | null => {\n const text = textBefore(view.state);\n if (text === null || !editor.isEditable()) return null;\n const { $from } = view.state.selection;\n const start = $from.start();\n for (const pattern of all(view, text)) {\n if ('replacement' in pattern) {\n if (!text.endsWith(pattern.start)) continue;\n const from = $from.pos - pattern.start.length;\n if (/<[a-z]/i.test(pattern.replacement)) {\n // HTML: put in through the schema, like any inserted content.\n view.dispatch(view.state.tr.delete(from, $from.pos));\n editor.insertContent(pattern.replacement);\n // Its formatting doesn't go on into the text typed next.\n view.dispatch(view.state.tr.setStoredMarks([]));\n } else view.dispatch(view.state.tr.insertText(pattern.replacement, from, $from.pos));\n return 'replacement';\n }\n if ('end' in pattern) {\n if (!text.endsWith(pattern.end)) continue;\n const inner = text.lastIndexOf(pattern.start, text.length - pattern.end.length - 1);\n const contentStart = inner + pattern.start.length;\n const contentEnd = text.length - pattern.end.length;\n // Something between the markers, not starting or ending with a space (\"2 * 3 * 4\" stays).\n if (inner < 0 || contentEnd <= contentStart) continue;\n if (/^\\s|\\s$/.test(text.slice(contentStart, contentEnd))) continue;\n const tr = view.state.tr\n .delete(start + contentEnd, start + text.length)\n .delete(start + inner, start + contentStart);\n const from = start + inner;\n const to = from + (contentEnd - contentStart);\n view.dispatch(tr.setSelection(TextSelection.create(tr.doc, from, to)));\n run(editor, pattern);\n const { state } = view;\n view.dispatch(state.tr.setSelection(TextSelection.create(state.doc, state.selection.to)));\n // The format doesn't go on into the text typed next.\n view.dispatch(view.state.tr.setStoredMarks([]));\n return 'inline';\n }\n if ((pattern.trigger ?? 'space') !== trigger) continue;\n // Space: the block's text before the cursor is the start; Enter: the block starts with it.\n const matches =\n trigger === 'space'\n ? text === pattern.start\n : $from.parent.textContent.startsWith(pattern.start) &&\n $from.parentOffset === $from.parent.content.size;\n if (!matches) continue;\n view.dispatch(view.state.tr.delete(start, start + pattern.start.length));\n run(editor, pattern);\n return 'block';\n }\n return null;\n };\n\n return new Plugin({\n props: {\n handleTextInput(view, from, to, text) {\n if (text !== ' ' || from !== to) return false;\n // A block pattern takes the space (the start and the space go); the others keep it.\n const kind = attempt(view, 'space');\n if (!kind) return false;\n if (kind !== 'block') view.dispatch(view.state.tr.insertText(' '));\n return true;\n },\n handleKeyDown(view, event) {\n if (event.key !== 'Enter' || event.shiftKey || event.ctrlKey || event.metaKey) return false;\n // The pattern is applied, then Enter goes on as usual (a new line).\n attempt(view, 'enter');\n return false;\n },\n },\n });\n}\n","import { baseKeymap, chainCommands, exitCode } from 'prosemirror-commands';\nimport { keymap } from 'prosemirror-keymap';\nimport { splitListItem } from 'prosemirror-schema-list';\nimport type { Command, EditorState, Plugin } from 'prosemirror-state';\nimport { spokenCommand as spoken } from './announce';\nimport { commands, listIndent, listOutdent, nodesOf, type CommandName } from './commands';\nimport { exitImageCaption } from './image';\n\nconst mac = typeof navigator !== 'undefined' && /Mac|iP(hone|[oa]d)/.test(navigator.platform);\n\nconst insertHardBreak: Command = chainCommands(exitCode, (state, dispatch) => {\n dispatch?.(state.tr.replaceSelectionWith(nodesOf(state).hard_break.create()).scrollIntoView());\n return true;\n});\n\n/** Keyboard shortcuts in the spirit of Word / Google Docs. Mod = Cmd on macOS, Ctrl elsewhere. */\n/** A command by name, with plugin overrides applied (see Editor.resolveCommand). */\ntype Resolve = (name: CommandName) => Command;\nconst byName =\n (resolve: Resolve, name: CommandName): Command =>\n (state, dispatch, view) =>\n resolve(name)(state, dispatch, view);\n\nexport function buildKeymap(resolve: Resolve = (name) => commands[name]): Plugin[] {\n const keys: Record<string, Command> = {\n 'Mod-z': byName(resolve, 'undo'),\n 'Shift-Mod-z': byName(resolve, 'redo'),\n // Formatting shortcuts say what they did to screen readers (\"Bold on\", \"Heading 2\"): announce.ts.\n 'Mod-b': spoken('bold'),\n 'Mod-i': spoken('italic'),\n 'Mod-u': spoken('underline'),\n 'Mod-Shift-x': spoken('strike'),\n 'Mod-e': spoken('code'),\n 'Mod-,': spoken('subscript'),\n 'Mod-.': spoken('superscript'),\n 'Mod-Alt-0': spoken('paragraph'),\n 'Mod-Alt-1': spoken('h1'),\n 'Mod-Alt-2': spoken('h2'),\n 'Mod-Alt-3': spoken('h3'),\n 'Mod-Alt-4': spoken('h4'),\n 'Mod-Alt-5': spoken('h5'),\n 'Mod-Alt-6': spoken('h6'),\n 'Mod-Shift-7': spoken('orderedList'),\n 'Mod-Shift-8': spoken('bulletList'),\n 'Mod-Shift-l': spoken('alignLeft'),\n 'Mod-Shift-e': spoken('alignCenter'),\n 'Mod-Shift-r': spoken('alignRight'),\n 'Mod-Shift-j': spoken('alignJustify'),\n 'Mod-\\\\': spoken('clearFormatting'),\n 'Shift-Enter': insertHardBreak,\n Enter: chainCommands(exitImageCaption, (state, dispatch) => {\n // A new checklist item is unchecked (not a copy of a checked one and not a regular item).\n const item = parentListItem(state);\n const attrs = typeof item?.attrs.checked === 'boolean' ? { checked: false } : undefined;\n return splitListItem(nodesOf(state).list_item, attrs)(state, dispatch);\n }),\n // Tab is for lists only (in a paragraph it still moves focus). A paragraph indent is Mod-] / Mod-[.\n Tab: listIndent,\n 'Shift-Tab': listOutdent,\n 'Mod-]': commands.indent,\n 'Mod-[': commands.outdent,\n // Move a block (a list item, a paragraph, a table), as in Word.\n 'Alt-Shift-ArrowUp': commands.moveBlockUp,\n 'Alt-Shift-ArrowDown': commands.moveBlockDown,\n };\n if (!mac) keys['Mod-y'] = byName(resolve, 'redo');\n return [keymap(keys), keymap(baseKeymap)];\n}\n\n/** The nearest list item around the cursor. */\nfunction parentListItem(state: EditorState) {\n const { $from } = state.selection;\n for (let depth = $from.depth; depth > 0; depth--) {\n const node = $from.node(depth);\n if (node.type === nodesOf(state).list_item) return node;\n }\n return null;\n}\n","/**\n * ProseMirror plugin views that survive a rebuild of the plugin set.\n *\n * The editor loads parts lazily (table mechanics, plugins by name) and attaches them through\n * `state.reconfigure`. On any change of the plugin set, ProseMirror destroys the views of ALL\n * plugins and creates them again: an open autocomplete list closed, collaboration sync\n * redrew the document, y-prosemirror undo lost its history. Here a view\n * is created once per editor: on a rebuild done by the editor itself\n * (`reconfigurePlugins`) it is kept and keeps receiving updates, and it is destroyed when\n * the editor closes or its plugin is removed from the set.\n */\nimport type { Plugin, PluginView } from 'prosemirror-state';\nimport type { EditorView } from 'prosemirror-view';\n\nconst reconfiguring = new WeakSet<EditorView>();\nconst kept = new WeakMap<EditorView, Map<Plugin, PluginView>>();\nconst wrapped = new WeakSet<Plugin>();\n\n/** Prepares the plugins: their views will survive `reconfigurePlugins`. */\nexport function keepPluginViews(plugins: readonly Plugin[]): void {\n for (const plugin of plugins) {\n const spec = plugin.spec;\n const create = spec.view;\n if (!create || wrapped.has(plugin)) continue;\n wrapped.add(plugin);\n spec.view = (view) => {\n let views = kept.get(view);\n if (!views) kept.set(view, (views = new Map()));\n let inner = views.get(plugin);\n if (!inner) views.set(plugin, (inner = create(view)));\n const current = inner;\n return {\n update: (v, prev) => current.update?.(v, prev),\n destroy: () => {\n if (reconfiguring.has(view)) return;\n views.delete(plugin);\n current.destroy?.();\n },\n };\n };\n }\n}\n\n/** Changes the plugin set, keeping the views of the plugins that stay. */\nexport function reconfigurePlugins(view: EditorView, plugins: Plugin[]): void {\n keepPluginViews(plugins);\n reconfiguring.add(view);\n try {\n view.updateState(view.state.reconfigure({ plugins }));\n } finally {\n reconfiguring.delete(view);\n }\n // The plugin was removed from the set: its view isn't needed anymore.\n const views = kept.get(view);\n if (!views) return;\n for (const [plugin, inner] of views) {\n if (!plugins.includes(plugin)) {\n views.delete(plugin);\n inner.destroy?.();\n }\n }\n}\n","import type { Command, EditorState, Transaction } from 'prosemirror-state';\nimport type { EditorView } from 'prosemirror-view';\nimport type { CommandName } from './commands';\n\n/**\n * A command chain: several steps as one edit (one undo step, one change event).\n *\n * editor.chain().exec('h2').exec('alignCenter').run();\n * editor.chain().insertContent('<p>Note</p>').exec(setStyle('color', '#e03e2d')).run();\n *\n * Steps work on a shared transaction: each sees the document and the selection after the previous\n * ones (like chains in other ProseMirror editors). The difference is all-or-nothing: if a step\n * fails, the document doesn't change and run() returns false. can() checks the chain honestly: the\n * steps run on a draft transaction that is never applied.\n */\n\n/** Named commands for a chain: undo and redo only work on their own (editor.exec). */\nexport type ChainCommandName = Exclude<CommandName, 'undo' | 'redo'>;\n\nexport interface CommandChain {\n /** A step: a named command or a ProseMirror command (setStyle(…), applyLink(…), your own). */\n exec(command: ChainCommandName | Command): CommandChain;\n /** A step: insert HTML at the cursor, like editor.insertContent(). */\n insertContent(html: string): CommandChain;\n /** Run the steps as one edit. If a step fails, the document doesn't change and the result is false. */\n run(): boolean;\n /** Whether run() would succeed now (for buttons). The document doesn't change. */\n can(): boolean;\n}\n\nexport interface ChainHost {\n /** The editor view; null when the editor is destroyed. */\n view(): EditorView | null;\n resolve(name: CommandName): Command;\n insertContent(html: string): Command;\n}\n\n/**\n * The state for a chain step: the document, the selection and stored marks come from the shared transaction,\n * and `state.tr` is that transaction. The rest (schema, plugins, their states) comes from the original state.\n */\nfunction chainableState(state: EditorState, tr: Transaction): EditorState {\n let { selection, doc, storedMarks } = tr;\n return Object.create(state, {\n doc: { get: () => doc },\n selection: { get: () => selection },\n storedMarks: { get: () => storedMarks },\n tr: {\n get: () => {\n ({ selection, doc, storedMarks } = tr);\n return tr;\n },\n },\n }) as EditorState;\n}\n\nfunction warn(message: string): void {\n console.warn(`[nova] chain: ${message}`);\n}\n\nexport function createChain(host: ChainHost): CommandChain {\n const steps: Command[] = [];\n\n const attempt = (apply: boolean): boolean => {\n const view = host.view();\n if (!view) return false;\n const { state } = view;\n const tr = state.tr;\n for (const step of steps) {\n let foreign = false;\n // A step changes the shared transaction (state.tr); dispatch here is only a sign of consent.\n const dispatch = (dispatched: Transaction) => {\n if (dispatched !== tr) foreign = true;\n };\n if (!step(chainableState(state, tr), dispatch, view)) return false;\n if (foreign) {\n // Its own transaction (view.state.tr) doesn't see the previous steps: they can't be mixed.\n warn('a command dispatched its own transaction; build it from state.tr');\n return false;\n }\n }\n if (apply) {\n view.dispatch(tr);\n view.focus();\n }\n return true;\n };\n\n const chain: CommandChain = {\n exec(command) {\n if (command === ('undo' as string) || command === ('redo' as string)) {\n warn(`\"${command as string}\" runs on its own — use editor.exec()`);\n steps.push(() => false);\n } else {\n steps.push(typeof command === 'string' ? host.resolve(command) : command);\n }\n return chain;\n },\n insertContent(html) {\n steps.push(host.insertContent(html));\n return chain;\n },\n run: () => attempt(true),\n can: () => attempt(false),\n };\n return chain;\n}\n","import { AllSelection, NodeSelection, Plugin, PluginKey, TextSelection } from 'prosemirror-state';\nimport { htmlSerializer } from './document';\nimport type { Editor } from './editor';\n\n/**\n * editor.selection: what is selected, as HTML or text, where it is on the screen, and ways to move\n * it. Positions are document positions (0 is before the first block), the numbers ProseMirror uses.\n */\n\n/** A place in the document kept across changes: moveToBookmark() puts the selection back there. */\nexport interface SelectionBookmark {\n readonly id: number;\n}\n\nexport interface EditorSelection {\n /** Where the selection starts and ends, as document positions (from ≤ to). */\n getRange(): { from: number; to: number };\n /** Selects from…to (kept inside the document); without `to`, puts the cursor at `from`. */\n setRange(from: number, to?: number): void;\n /** Whether nothing is selected: only a cursor. */\n isCollapsed(): boolean;\n /** Collapses the selection to its start (true) or its end. */\n collapse(toStart?: boolean): void;\n /** Selects the whole document. */\n selectAll(): void;\n /** The selected content as HTML, as getHTML() writes it; '' for a cursor. */\n getHTML(): string;\n /** The selected text, blocks on separate lines. */\n getText(): string;\n /** Replaces the selection with HTML, read and checked like insertContent(). */\n setHTML(html: string): boolean;\n /** The element of the editing area where the selection starts. */\n getNode(): HTMLElement | null;\n /** Selects an element of the editing area: the whole of it, or only what is inside it. */\n select(node: Node, content?: boolean): void;\n /** Puts the cursor in an element of the editing area, `offset` into it (its start by default). */\n setCursorLocation(node: Node, offset?: number): void;\n /** The selection as a DOM Range (to measure it, or for a popup of your own); null when hidden. */\n getDOMRange(): Range | null;\n /** Where the selection is on the screen; null when the editor isn't shown. */\n getRect(): DOMRect | null;\n /** Remembers the selection; later changes to the document move it along. */\n getBookmark(): SelectionBookmark;\n /** Puts the selection back where the bookmark is now; false when its text was deleted. */\n moveToBookmark(bookmark: SelectionBookmark): boolean;\n /** Scrolls the selection into view. */\n scrollIntoView(): void;\n}\n\ninterface Kept {\n from: number;\n to: number;\n gone: boolean;\n}\n\n/** At most this many bookmarks are kept; the oldest go first. */\nconst MAX_BOOKMARKS = 200;\n\nconst bookmarksKey = new PluginKey<Map<number, Kept>>('nova-bookmarks');\n\n/** Moves every kept bookmark along with each change to the document. */\nexport function bookmarksPlugin(): Plugin {\n return new Plugin<Map<number, Kept>>({\n key: bookmarksKey,\n state: {\n init: () => new Map(),\n apply(tr, kept) {\n const added = tr.getMeta(bookmarksKey) as Map<number, Kept> | undefined;\n if (added) return added;\n if (!tr.docChanged || !kept.size) return kept;\n const next = new Map<number, Kept>();\n for (const [id, mark] of kept) {\n const start = tr.mapping.mapResult(mark.from, 1);\n const end = tr.mapping.mapResult(mark.to, -1);\n next.set(id, {\n from: start.pos,\n to: Math.max(start.pos, end.pos),\n // A selected text that was deleted as a whole is gone; a cursor always has a place.\n gone: mark.gone || (mark.from !== mark.to && start.pos >= end.pos),\n });\n }\n return next;\n },\n },\n });\n}\n\nlet nextBookmark = 1;\n\nexport function createSelection(editor: Editor): EditorSelection {\n const view = () => editor.view;\n const clamp = (pos: unknown) => {\n const size = view().state.doc.content.size;\n const n = typeof pos === 'number' && Number.isFinite(pos) ? Math.round(pos) : 0;\n return Math.max(0, Math.min(n, size));\n };\n const inEditor = (node: unknown): node is Node =>\n node instanceof Node && node !== view().dom && view().dom.contains(node);\n\n const api: EditorSelection = {\n getRange() {\n const { from, to } = view().state.selection;\n return { from, to };\n },\n setRange(from, to = from) {\n const { state, dispatch } = view();\n const selection = TextSelection.between(\n state.doc.resolve(clamp(from)),\n state.doc.resolve(clamp(to)),\n );\n dispatch(state.tr.setSelection(selection));\n },\n isCollapsed: () => view().state.selection.empty,\n collapse(toStart = false) {\n const { from, to } = view().state.selection;\n api.setRange(toStart ? from : to);\n },\n selectAll() {\n const { state, dispatch } = view();\n dispatch(state.tr.setSelection(new AllSelection(state.doc)));\n },\n getHTML() {\n const { selection } = view().state;\n return selection.empty ? '' : htmlSerializer.serializeFragment(selection.content().content);\n },\n getText() {\n const { state } = view();\n return state.doc.textBetween(state.selection.from, state.selection.to, '\\n');\n },\n setHTML: (html) => editor.insertContent(html),\n getNode() {\n const v = view();\n const { selection } = v.state;\n if (selection instanceof NodeSelection) {\n const dom = v.nodeDOM(selection.from);\n if (dom instanceof HTMLElement) return dom;\n }\n const elementAt = (pos: number, side: number) => {\n const { node } = v.domAtPos(pos, side);\n return node instanceof HTMLElement ? node : node.parentElement;\n };\n // Both ends looked at from inside the selection: all of a bold word gives that <strong>, a\n // selection across elements their common parent.\n let el = elementAt(selection.from, selection.empty ? 0 : 1);\n if (!selection.empty) {\n const end = elementAt(selection.to, -1);\n while (el && end && !el.contains(end)) el = el.parentElement;\n }\n return el && v.dom.contains(el) ? el : null;\n },\n select(node, content = false) {\n if (!inEditor(node)) return;\n const v = view();\n const { doc } = v.state;\n const pos = v.posAtDOM(node, 0);\n // The element of a document node (an image, a paragraph): that node, or what is inside it.\n for (const at of [pos - 1, pos]) {\n if (at < 0 || at >= doc.content.size) continue;\n const found = doc.nodeAt(at);\n if (!found || found.isText) continue;\n // A leaf's view may wrap its element (an image in its resize frame).\n const dom = v.nodeDOM(at);\n if (dom !== node && !(found.isLeaf && dom instanceof Node && dom.contains(node))) continue;\n if (found.isLeaf || (!content && NodeSelection.isSelectable(found)))\n v.dispatch(v.state.tr.setSelection(NodeSelection.create(doc, at)));\n else api.setRange(at + 1, at + found.nodeSize - 1);\n return;\n }\n // Text or a formatting element (a link, bold text): what it holds.\n api.setRange(pos, v.posAtDOM(node, node.childNodes.length));\n },\n setCursorLocation(node, offset = 0) {\n if (!inEditor(node)) return;\n const max = node.nodeType === 3 ? (node as Text).length : node.childNodes.length;\n api.setRange(view().posAtDOM(node, Math.max(0, Math.min(offset, max))));\n },\n getDOMRange() {\n const v = view();\n if (!v.dom.isConnected) return null;\n const { from, to } = v.state.selection;\n try {\n const start = v.domAtPos(from);\n const end = v.domAtPos(to);\n const range = document.createRange();\n range.setStart(start.node, start.offset);\n range.setEnd(end.node, end.offset);\n return range;\n } catch {\n return null;\n }\n },\n getRect() {\n const v = view();\n if (!v.dom.isConnected) return null;\n const { from, to, empty } = v.state.selection;\n try {\n if (!empty) {\n const rect = api.getDOMRange()?.getBoundingClientRect?.();\n if (rect && (rect.width || rect.height)) return rect;\n }\n const a = v.coordsAtPos(from);\n const b = empty ? a : v.coordsAtPos(to);\n const left = Math.min(a.left, b.left);\n const top = Math.min(a.top, b.top);\n return new DOMRect(\n left,\n top,\n Math.max(a.right, b.right) - left,\n Math.max(a.bottom, b.bottom) - top,\n );\n } catch {\n return null;\n }\n },\n getBookmark() {\n const v = view();\n const id = nextBookmark++;\n if (v.isDestroyed) return { id };\n const kept = new Map(bookmarksKey.getState(v.state));\n while (kept.size >= MAX_BOOKMARKS) kept.delete(kept.keys().next().value!);\n const { from, to } = v.state.selection;\n kept.set(id, { from, to, gone: false });\n v.dispatch(v.state.tr.setMeta(bookmarksKey, kept).setMeta('addToHistory', false));\n return { id };\n },\n moveToBookmark(bookmark) {\n const v = view();\n const id = (bookmark as SelectionBookmark | undefined)?.id;\n const mark = typeof id === 'number' ? bookmarksKey.getState(v.state)?.get(id) : undefined;\n if (!mark || mark.gone) return false;\n api.setRange(mark.from, mark.to);\n return true;\n },\n scrollIntoView() {\n const { state, dispatch } = view();\n dispatch(state.tr.scrollIntoView());\n },\n };\n return api;\n}\n","import { NodeSelection, Plugin, PluginKey } from 'prosemirror-state';\nimport type { EditorView } from 'prosemirror-view';\nimport type { Editor } from '../editor';\nimport { activeElement, h, listenDocument, logicalKey } from './dom';\nimport { positionFloating, visibleArea } from './popover';\nimport type { ContextToolbarSpec } from './registry';\nimport { parseToolbar, renderControl, type RenderedControl } from './toolbar';\n\ninterface Rendered {\n el: HTMLElement;\n controls: RenderedControl[];\n}\n\n/**\n * The context toolbars plugin (editor.ui.registry.addContextToolbar).\n * One floating container; its content is the first toolbar whose predicate is currently true.\n */\nexport function contextToolbarPlugin(editor: Editor): Plugin {\n return new Plugin({\n key: new PluginKey('nova-context-toolbar'),\n view(view) {\n const container = h('div', {\n className: 'nova-bubble nova-context-toolbar',\n role: 'toolbar',\n hidden: true,\n });\n editor.ui.overlayHost.append(container);\n const cache = new Map<string, Rendered>();\n let current: string | null = null;\n\n const render = (name: string, spec: ContextToolbarSpec): Rendered => {\n let rendered = cache.get(name);\n if (rendered) return rendered;\n const el = h('div', { className: 'nova-context-items' });\n const controls: RenderedControl[] = [];\n parseToolbar(spec.items).forEach((group, index) => {\n if (index > 0) el.append(h('span', { className: 'nova-bubble-sep', role: 'separator' }));\n for (const item of group) {\n if (!editor.isAllowed(item)) continue;\n const control = editor.ui.registry.get(item);\n if (!control) continue;\n const r = renderControl(editor, item, control);\n controls.push(r);\n el.append(r.el);\n }\n });\n rendered = { el, controls };\n cache.set(name, rendered);\n return rendered;\n };\n\n const hide = () => {\n container.hidden = true;\n current = null;\n };\n\n const anchorRect = (spec: ContextToolbarSpec): DOMRect | null => {\n const { selection } = view.state;\n if ((spec.position ?? 'node') === 'node' && selection instanceof NodeSelection) {\n const dom = view.nodeDOM(selection.from) as HTMLElement | null;\n return dom?.getBoundingClientRect() ?? null;\n }\n const start = view.coordsAtPos(selection.from);\n const end = view.coordsAtPos(selection.to);\n return new DOMRect(\n start.left,\n start.top,\n Math.max(1, end.right - start.left),\n end.bottom - start.top,\n );\n };\n\n // While the mouse drags a selection the panel isn't shown (otherwise it flickers): it shows after release.\n let dragging = false;\n const onPointerDown = (event: PointerEvent) => {\n if (event.pointerType === 'mouse' && event.button === 0) dragging = true;\n };\n const onPointerUp = () => {\n if (!dragging) return;\n dragging = false;\n // After mouseup the browser still finishes updating the selection: let ProseMirror read it.\n setTimeout(() => update(view), 0);\n };\n view.dom.addEventListener('pointerdown', onPointerDown);\n const stopPointerUp = listenDocument(container, 'pointerup', onPointerUp);\n\n const coarse = typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;\n\n /**\n * Touch screens: the selection toolbar doesn't float next to the selection: the selection handles and\n * the system \"Copy/Paste\" menu are there, and it would cover them (or they would cover it). The panel\n * is pinned to the bottom of the visible part of the window, that is, above the keyboard, full width.\n */\n const dock = () => {\n const area = visibleArea();\n container.style.left = `${Math.round(area.left)}px`;\n container.style.width = `${Math.round(area.right - area.left)}px`;\n container.style.top = `${Math.round(area.bottom - container.offsetHeight)}px`;\n container.dataset.side = 'docked';\n };\n\n const update = (v: EditorView) => {\n const focused = v.hasFocus() || container.contains(activeElement(container));\n if (!focused || !editor.isEditable() || editor.ui.activeDialog || dragging) return hide();\n const match = editor.ui.registry\n .getContextToolbars()\n .find(([, spec]) => spec.predicate(editor));\n if (!match) return hide();\n const [name, spec] = match;\n const rendered = render(name, spec);\n if (current !== name) {\n container.replaceChildren(rendered.el);\n container.setAttribute('aria-label', spec.label);\n current = name;\n }\n for (const control of rendered.controls) control.update();\n const rect = spec.anchor ? spec.anchor(editor) : anchorRect(spec);\n if (!rect) return hide();\n container.hidden = false;\n const docked = coarse && spec.position === 'selection';\n container.classList.toggle('nova-context-toolbar-docked', docked);\n if (docked) return dock();\n container.style.width = '';\n const placement =\n (typeof spec.placement === 'function' ? spec.placement(editor) : spec.placement) ??\n (spec.position === 'selection' ? 'bottom-start' : 'top-start');\n positionFloating(container, rect, placement);\n };\n\n // Buttons don't take focus, otherwise the node selection disappears.\n container.addEventListener('mousedown', (event) => {\n if ((event.target as HTMLElement).closest('button')) event.preventDefault();\n });\n container.addEventListener('keydown', (event) => {\n const buttons = [...container.querySelectorAll<HTMLButtonElement>('button:not(:disabled)')];\n const index = buttons.indexOf(activeElement(container) as HTMLButtonElement);\n if (event.key === 'Escape') {\n event.preventDefault();\n editor.focus();\n } else if (index >= 0 && (event.key === 'ArrowRight' || event.key === 'ArrowLeft')) {\n event.preventDefault();\n const step = logicalKey(event, container) === 'ArrowRight' ? 1 : -1;\n buttons[(index + step + buttons.length) % buttons.length]!.focus();\n }\n });\n\n const onBlur = (event: FocusEvent) => {\n const next = event.relatedTarget as Node | null;\n if (!container.contains(next) && !editor.ui.overlayHost.contains(next)) hide();\n };\n view.dom.addEventListener('blur', onBlur);\n container.addEventListener('focusout', (event) => {\n const next = event.relatedTarget as Node | null;\n if (!container.contains(next) && !view.hasFocus() && !editor.ui.overlayHost.contains(next))\n hide();\n });\n // The position depends on the layout: updated on scroll and window resize.\n const reposition = () => {\n if (!container.hidden) update(view);\n };\n window.addEventListener('scroll', reposition, true);\n window.addEventListener('resize', reposition);\n // An image that finishes loading changes the layout (a new or edited image had no size yet).\n view.dom.addEventListener('load', reposition, true);\n // A phone keyboard changes the visible part of the window without touching the window.\n window.visualViewport?.addEventListener('resize', reposition);\n window.visualViewport?.addEventListener('scroll', reposition);\n\n return {\n update,\n destroy() {\n view.dom.removeEventListener('blur', onBlur);\n view.dom.removeEventListener('pointerdown', onPointerDown);\n stopPointerUp();\n window.removeEventListener('scroll', reposition, true);\n window.removeEventListener('resize', reposition);\n view.dom.removeEventListener('load', reposition, true);\n window.visualViewport?.removeEventListener('resize', reposition);\n window.visualViewport?.removeEventListener('scroll', reposition);\n container.remove();\n },\n };\n },\n });\n}\n\n/** Focus on the context toolbar (Ctrl+F9, the common shortcut). */\nexport function focusContextToolbar(editor: Editor): boolean {\n const button = editor.ui.overlayHost.querySelector<HTMLButtonElement>(\n '.nova-context-toolbar:not([hidden]) button:not(:disabled)',\n );\n button?.focus();\n return !!button;\n}\n","import type { Node as PMNode } from 'prosemirror-model';\nimport { NodeSelection } from 'prosemirror-state';\nimport type { EditorView, NodeView } from 'prosemirror-view';\nimport type { Editor } from '../editor';\nimport { classAttr, imageSize } from '../schema';\nimport { isSafeImageUrl } from '../url';\n\nconst MIN_WIDTH = 24;\ntype Corner = 'nw' | 'ne' | 'sw' | 'se';\n\n/**\n * The image view in the editor: a wrapper + resize handles in the corners (visible while the image is selected).\n * Resizing keeps the proportions and works with a mouse or a finger (Pointer Events). The wrapper doesn't\n * reach the HTML output: serialization follows the schema's toDOM.\n */\nexport class ImageView implements NodeView {\n readonly dom: HTMLSpanElement;\n private readonly img: HTMLImageElement;\n private node: PMNode;\n private resizing = false;\n\n constructor(\n node: PMNode,\n private readonly view: EditorView,\n private readonly getPos: () => number | undefined,\n private readonly editor: Editor,\n ) {\n this.node = node;\n this.dom = document.createElement('span');\n this.dom.className = 'nova-image';\n this.img = document.createElement('img');\n this.img.draggable = false;\n this.dom.append(this.img);\n\n for (const corner of ['nw', 'ne', 'sw', 'se'] as Corner[]) {\n const handle = document.createElement('span');\n handle.className = `nova-image-handle nova-image-handle-${corner}`;\n handle.dataset.corner = corner;\n handle.addEventListener('pointerdown', (event) => this.startResize(event, corner));\n this.dom.append(handle);\n }\n this.render();\n }\n\n private render(): void {\n const { src, alt, title, width, height, align } = this.node.attrs;\n const safeSrc = isSafeImageUrl(src) ? src : '';\n if (this.img.getAttribute('src') !== safeSrc) this.img.setAttribute('src', safeSrc);\n this.setAttr('alt', alt);\n this.setAttr('title', title);\n this.setAttr('class', classAttr(this.node.attrs.class).class ?? null);\n const w = imageSize(width);\n const h = imageSize(height);\n this.img.style.width = w ? `${w}px` : '';\n // The height isn't fixed: with max-width: 100% the image must shrink proportionally.\n this.img.style.aspectRatio = w && h ? `${w} / ${h}` : '';\n this.dom.dataset.align = align ?? '';\n }\n\n private setAttr(name: string, value: string | null): void {\n if (value) this.img.setAttribute(name, value);\n else this.img.removeAttribute(name);\n }\n\n update(node: PMNode): boolean {\n if (node.type !== this.node.type) return false;\n this.node = node;\n if (!this.resizing) this.render();\n return true;\n }\n\n selectNode(): void {\n this.dom.classList.add('is-selected');\n }\n\n deselectNode(): void {\n this.dom.classList.remove('is-selected');\n }\n\n /** The handles are ours; ProseMirror must not handle events on them. */\n stopEvent(event: Event): boolean {\n return (event.target as HTMLElement).classList?.contains('nova-image-handle') ?? false;\n }\n\n ignoreMutation(): boolean {\n return true;\n }\n\n private startResize(event: PointerEvent, corner: Corner): void {\n if (!this.editor.isEditable()) return;\n event.preventDefault();\n event.stopPropagation();\n const handle = event.currentTarget as HTMLElement;\n handle.setPointerCapture(event.pointerId);\n\n const rect = this.img.getBoundingClientRect();\n const startX = event.clientX;\n const startWidth = rect.width;\n const ratio =\n rect.width > 0\n ? rect.height / rect.width\n : this.img.naturalHeight / (this.img.naturalWidth || 1);\n const maxWidth = Math.max(MIN_WIDTH, this.view.dom.clientWidth - 40);\n const direction = corner === 'ne' || corner === 'se' ? 1 : -1;\n let width = startWidth;\n this.resizing = true;\n this.dom.classList.add('is-resizing');\n\n const onMove = (e: PointerEvent) => {\n width = Math.round(\n Math.min(maxWidth, Math.max(MIN_WIDTH, startWidth + direction * (e.clientX - startX))),\n );\n this.img.style.width = `${width}px`;\n this.dom.dataset.size = `${width} × ${Math.round(width * ratio)}`;\n };\n\n const onUp = () => {\n handle.removeEventListener('pointermove', onMove);\n handle.removeEventListener('pointerup', onUp);\n handle.removeEventListener('pointercancel', onUp);\n this.resizing = false;\n this.dom.classList.remove('is-resizing');\n delete this.dom.dataset.size;\n const pos = this.getPos();\n if (pos === undefined || Math.abs(width - startWidth) < 1) return this.render();\n const tr = this.view.state.tr.setNodeMarkup(pos, undefined, {\n ...this.node.attrs,\n width,\n height: Math.round(width * ratio),\n });\n // The image stays selected, so you can keep resizing or open the toolbar.\n tr.setSelection(NodeSelection.create(tr.doc, pos));\n this.view.dispatch(tr);\n };\n\n handle.addEventListener('pointermove', onMove);\n handle.addEventListener('pointerup', onUp);\n handle.addEventListener('pointercancel', onUp);\n }\n}\n","import { Plugin, PluginKey } from 'prosemirror-state';\nimport type { EditorView } from 'prosemirror-view';\nimport type { Editor } from '../editor';\nimport { formatShortcut, h, icon, uniqueId } from './dom';\nimport { positionFloating } from './popover';\n\nexport interface AutocompleterItem {\n value: string;\n label: string;\n icon?: string;\n /** A hint on the right: a shortcut in 'Mod-b' format. */\n shortcut?: string;\n /** A hint on the right as plain text (a job title, an e-mail). */\n detail?: string;\n}\n\nexport interface AutocompleterSpec {\n /** The trigger character: '/', '@', ':'. */\n trigger: string;\n /** How many characters after the trigger before the list shows (0 by default). */\n minChars?: number;\n /** Items for a query; may return a Promise (a search on the server). */\n fetch: (query: string, editor: Editor) => AutocompleterItem[] | Promise<AutocompleterItem[]>;\n /** An item was chosen. range — the positions of \"trigger + query\", usually deleted. */\n onSelect: (item: AutocompleterItem, range: { from: number; to: number }, editor: Editor) => void;\n /** Label of the list for screen readers. */\n label: string;\n /** Text when nothing is found (otherwise the list hides). */\n emptyText?: string;\n maxResults?: number;\n}\n\ninterface Match {\n name: string;\n spec: AutocompleterSpec;\n from: number;\n to: number;\n query: string;\n}\n\nconst MAX_QUERY = 30;\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/** Looks for \"trigger + query\" right before the cursor: at the start of a block or after a space. */\nfunction findMatch(view: EditorView, editor: Editor): Match | null {\n const { selection } = view.state;\n if (!selection.empty) return null;\n const $pos = selection.$from;\n if (!$pos.parent.isTextblock || $pos.parent.type.spec.code) return null;\n const before = $pos.parent.textBetween(\n Math.max(0, $pos.parentOffset - MAX_QUERY - 1),\n $pos.parentOffset,\n '\\0',\n '\\0',\n );\n for (const [name, spec] of editor.ui.registry.getAutocompleters()) {\n const re = new RegExp(`(?:^|\\\\s)${escapeRegExp(spec.trigger)}([\\\\p{L}\\\\p{N}_-]*)$`, 'u');\n const m = before.match(re);\n if (!m) continue;\n const query = m[1] ?? '';\n if (query.length < (spec.minChars ?? 0)) continue;\n // The trigger at the start of the requested piece could be in the middle of a word we can't see.\n const start = $pos.parentOffset - query.length - spec.trigger.length;\n const prevChar = start > 0 ? $pos.parent.textBetween(start - 1, start, '\\0', '\\0') : '';\n if (prevChar && !/\\s/.test(prevChar)) continue;\n return { name, spec, from: $pos.pos - query.length - spec.trigger.length, to: $pos.pos, query };\n }\n return null;\n}\n\n/**\n * The autocompleters plugin (slash commands, mentions, emoji).\n * Focus stays in the text; the list is linked to the editor through aria-activedescendant (the combobox pattern).\n */\nexport function autocompleterPlugin(editor: Editor): Plugin {\n let list: HTMLDivElement;\n let items: AutocompleterItem[] = [];\n let active = 0;\n let match: Match | null = null;\n /** The position of a trigger the user pressed Escape for: it isn't opened again. */\n let dismissedAt: number | null = null;\n let requestId = 0;\n const listId = uniqueId('nova-ac');\n\n const isOpen = () => !list.hidden;\n\n const close = (view: EditorView) => {\n list.hidden = true;\n match = null;\n items = [];\n view.dom.removeAttribute('aria-activedescendant');\n view.dom.removeAttribute('aria-controls');\n // aria-expanded isn't allowed on role=textbox (axe: aria-allowed-attr): the list is linked through\n // aria-controls and aria-activedescendant, which is enough for screen readers.\n view.dom.removeAttribute('aria-expanded');\n };\n\n const select = (view: EditorView, index: number) => {\n const item = items[index];\n if (!item || !match) return;\n const { spec, from, to } = match;\n close(view);\n spec.onSelect(item, { from, to }, editor);\n };\n\n const renderItems = (view: EditorView) => {\n if (!match) return;\n const { spec } = match;\n list.replaceChildren();\n list.setAttribute('aria-label', spec.label);\n if (!items.length) {\n if (!spec.emptyText) return close(view);\n list.append(h('div', { className: 'nova-ac-empty' }, spec.emptyText));\n }\n items.forEach((item, index) => {\n const option = h(\n 'div',\n {\n id: `${listId}-${index}`,\n className: 'nova-menu-item nova-ac-item',\n role: 'option',\n 'aria-selected': String(index === active),\n },\n item.icon ? icon(item.icon) : null,\n h('span', { className: 'nova-menu-label' }, item.label),\n item.shortcut\n ? h('kbd', { className: 'nova-menu-shortcut' }, formatShortcut(item.shortcut))\n : item.detail\n ? h('span', { className: 'nova-menu-shortcut' }, item.detail)\n : null,\n );\n // mousedown, not click: otherwise the editor loses focus and the selection before the choice.\n option.addEventListener('mousedown', (event) => {\n event.preventDefault();\n select(view, index);\n });\n option.addEventListener('mousemove', () => {\n if (active !== index) setActive(view, index);\n });\n list.append(option);\n });\n list.hidden = false;\n view.dom.setAttribute('aria-controls', listId);\n setActive(view, Math.min(active, Math.max(0, items.length - 1)));\n const coords = view.coordsAtPos(match.from);\n positionFloating(\n list,\n new DOMRect(coords.left, coords.top, 1, coords.bottom - coords.top),\n 'bottom-start',\n );\n };\n\n const setActive = (view: EditorView, index: number) => {\n active = index;\n list\n .querySelectorAll('[role=\"option\"]')\n .forEach((el, i) => el.setAttribute('aria-selected', String(i === index)));\n const current = list.querySelector<HTMLElement>(`#${listId}-${index}`);\n if (current) {\n view.dom.setAttribute('aria-activedescendant', current.id);\n current.scrollIntoView?.({ block: 'nearest' });\n }\n };\n\n const refresh = (view: EditorView) => {\n const next = editor.isEditable() && view.hasFocus() ? findMatch(view, editor) : null;\n if (!next || next.from === dismissedAt) {\n if (!next) dismissedAt = null;\n if (isOpen() || match) close(view);\n return;\n }\n const changed = !match || match.query !== next.query || match.from !== next.from;\n match = next;\n if (!changed && isOpen()) return renderItems(view);\n const id = ++requestId;\n void Promise.resolve(next.spec.fetch(next.query, editor)).then((result) => {\n // The answer is outdated: the user has kept typing.\n if (id !== requestId || !match) return;\n items = result.slice(0, next.spec.maxResults ?? 10);\n active = 0;\n renderItems(view);\n });\n };\n\n return new Plugin({\n key: new PluginKey('nova-autocompleter'),\n view(view) {\n list = h('div', {\n className: 'nova-popover nova-ac',\n id: listId,\n role: 'listbox',\n hidden: true,\n });\n editor.ui.overlayHost.append(list);\n view.dom.setAttribute('aria-autocomplete', 'list');\n const onBlur = () => close(view);\n view.dom.addEventListener('blur', onBlur);\n return {\n update: (v) => refresh(v),\n destroy() {\n view.dom.removeEventListener('blur', onBlur);\n list.remove();\n },\n };\n },\n props: {\n handleKeyDown(view, event) {\n if (!isOpen() || !match) return false;\n const count = items.length;\n switch (event.key) {\n case 'ArrowDown':\n if (count) setActive(view, (active + 1) % count);\n return true;\n case 'ArrowUp':\n if (count) setActive(view, (active - 1 + count) % count);\n return true;\n case 'Enter':\n case 'Tab':\n if (!count) return false;\n select(view, active);\n return true;\n case 'Escape':\n dismissedAt = match.from;\n close(view);\n return true;\n default:\n return false;\n }\n },\n },\n });\n}\n","import { h, icon } from './dom';\nimport { icons } from './icons';\n\nexport type NotificationType = 'info' | 'success' | 'warning' | 'error';\n\nexport interface NotificationOptions {\n text: string;\n type?: NotificationType;\n /** ms until it closes by itself; 0 — never. Default 4000 (errors: 0). */\n timeout?: number;\n /** Action buttons (\"Retry\"): clicking one runs the action and closes the notification. */\n actions?: NotificationAction[];\n /** The notification was closed with the close button or by its timer (not through an action). */\n onClose?: () => void;\n}\n\nexport interface NotificationAction {\n label: string;\n onAction: () => void;\n}\n\nexport interface NotificationHandle {\n close(): void;\n setText(text: string): void;\n}\n\n/** Notifications inside the editor (like editor.notificationManager). */\nexport class Notifications {\n private readonly region: HTMLDivElement;\n private readonly closeLabel: string;\n\n constructor(host: HTMLElement, closeLabel: string) {\n this.closeLabel = closeLabel;\n // aria-live: the screen reader reads notifications without moving focus.\n this.region = h('div', { className: 'nova-notifications', 'aria-live': 'polite' });\n host.append(this.region);\n }\n\n open(options: NotificationOptions): NotificationHandle {\n const type = options.type ?? 'info';\n const timeout = options.timeout ?? (type === 'error' ? 0 : 4000);\n const text = h('span', { className: 'nova-notification-text' }, options.text);\n const closeBtn = h(\n 'button',\n { type: 'button', className: 'nova-btn', 'aria-label': this.closeLabel },\n icon(icons.close),\n );\n const actions = (options.actions ?? []).map((action) =>\n h('button', { type: 'button', className: 'nova-btn nova-notification-action' }, action.label),\n );\n const el = h(\n 'div',\n {\n className: `nova-notification nova-notification-${type}`,\n role: type === 'error' ? 'alert' : 'status',\n },\n text,\n ...actions,\n closeBtn,\n );\n this.region.append(el);\n\n let timer: ReturnType<typeof setTimeout> | null = null;\n let closed = false;\n const close = () => {\n if (closed) return;\n closed = true;\n if (timer) clearTimeout(timer);\n el.remove();\n };\n const dismiss = () => {\n if (closed) return;\n close();\n options.onClose?.();\n };\n actions.forEach((button, i) =>\n button.addEventListener('click', () => {\n close();\n options.actions![i]!.onAction();\n }),\n );\n closeBtn.addEventListener('click', dismiss);\n if (timeout > 0) timer = setTimeout(dismiss, timeout);\n // With an action, focus goes to it: from the keyboard you can press \"Retry\" right away.\n actions[0]?.focus({ preventScroll: true });\n\n return { close, setText: (value) => (text.textContent = value) };\n }\n\n destroy(): void {\n this.region.remove();\n }\n}\n","import type { Editor } from '../editor';\nimport type { StyleFormat } from '../formats';\nimport type { AutocompleterSpec } from './autocompleter';\nimport type { MenuEntry } from './menu';\nimport { icons } from './icons';\nimport type { SidebarSpec } from './sidebar';\nimport type { ViewSpec } from './editor-views';\n\nconst sidebarIcon = icons.sidebar;\n\ninterface ControlBase {\n /** Text for the tooltip and aria-label. */\n tooltip: string;\n /** An SVG icon (string). Without one, `text` is shown. */\n icon?: string;\n /** Text on the button (for dropdowns: \"Paragraph ▾\"). */\n text?: string;\n /** Shortcut in ProseMirror format ('Mod-b'), shown in the tooltip only. */\n shortcut?: string;\n isEnabled?: (editor: Editor) => boolean;\n}\n\nexport interface ButtonSpec extends ControlBase {\n type: 'button';\n onAction: (editor: Editor) => void;\n /** When set, the button becomes a toggle (aria-pressed). */\n isActive?: (editor: Editor) => boolean;\n}\n\nexport interface MenuButtonSpec extends ControlBase {\n type: 'menu';\n items: (editor: Editor) => MenuEntry[];\n /** A dynamic label (the current block style, font and so on). */\n label?: (editor: Editor) => string;\n isActive?: (editor: Editor) => boolean;\n /** Minimum label width in characters, so the toolbar doesn't jump. */\n minChars?: number;\n}\n\nexport interface PanelButtonSpec extends ControlBase {\n type: 'panel';\n render: (editor: Editor, close: () => void) => HTMLElement;\n /** Color of the bar under the icon (the current text or background color). */\n indicator?: (editor: Editor) => string | null;\n isActive?: (editor: Editor) => boolean;\n}\n\n/**\n * A split button: the main part runs an action (toggle a list), the arrow opens a menu of variants\n * (the bullet style). Like bullist/numlist with the advlist plugin.\n */\nexport interface SplitButtonSpec extends ControlBase {\n type: 'split';\n onAction: (editor: Editor) => void;\n items: (editor: Editor) => MenuEntry[];\n isActive?: (editor: Editor) => boolean;\n}\n\nexport type ControlSpec = ButtonSpec | MenuButtonSpec | PanelButtonSpec | SplitButtonSpec;\n\n/** A menu bar item. */\nexport interface MenuItemSpec {\n text: string;\n icon?: string;\n shortcut?: string;\n onAction: (editor: Editor) => void;\n /** A check mark (toggle). */\n isActive?: (editor: Editor) => boolean;\n isEnabled?: (editor: Editor) => boolean;\n}\n\nexport type ContextPlacement = 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';\n\n/** A context toolbar: appears next to the selected object (image, table, link). */\nexport interface ContextToolbarSpec {\n /** When to show it. Checked in order of registration; the first match wins. */\n predicate: (editor: Editor) => boolean;\n /** Buttons in toolbar format ('a b | c'), from the same registry. */\n items: string | string[];\n /** Label for screen readers. */\n label: string;\n /** Where to show it: above the selected node (default) or below the selection. */\n position?: 'node' | 'selection';\n /** Your own anchor (for example, the whole table). Overrides position. */\n anchor?: (editor: Editor) => DOMRect | null;\n /**\n * The side relative to the anchor; flips when there isn't room. A function when the side depends\n * on the state (a code block is always left-to-right, even in a right-to-left document).\n */\n placement?: ContextPlacement | ((editor: Editor) => ContextPlacement);\n /** Check order: higher goes first (default 0). Text selected in a table → the quickbar beats the table. */\n priority?: number;\n}\n\ntype WithoutType<T> = Omit<T, 'type'>;\n\n/**\n * The registry of toolbar controls (like editor.ui.registry). Built-in buttons are registered the\n * same way as yours, so plugins can do everything the core can.\n */\nexport class Registry {\n private readonly controls = new Map<string, ControlSpec>();\n\n addButton(name: string, spec: WithoutType<ButtonSpec>): void {\n this.controls.set(name.toLowerCase(), { type: 'button', ...spec });\n }\n\n /** A synonym of addButton with isActive, for the familiar API. */\n addToggleButton(name: string, spec: WithoutType<ButtonSpec>): void {\n this.addButton(name, spec);\n }\n\n addMenuButton(name: string, spec: WithoutType<MenuButtonSpec>): void {\n this.controls.set(name.toLowerCase(), { type: 'menu', ...spec });\n }\n\n addPanelButton(name: string, spec: WithoutType<PanelButtonSpec>): void {\n this.controls.set(name.toLowerCase(), { type: 'panel', ...spec });\n }\n\n addSplitButton(name: string, spec: WithoutType<SplitButtonSpec>): void {\n this.controls.set(name.toLowerCase(), { type: 'split', ...spec });\n }\n\n private readonly menuItems = new Map<string, MenuItemSpec>();\n\n private styleFormats: { items: StyleFormat[]; replace: boolean } = { items: [], replace: false };\n\n /**\n * Items for the Styles menu from a plugin (importcss): after the menu's own items, or instead of\n * them (`replace`).\n */\n addStyleFormats(items: StyleFormat[], { replace = false } = {}): void {\n this.styleFormats = {\n items: [...this.styleFormats.items, ...items],\n replace: this.styleFormats.replace || replace,\n };\n }\n\n /** What plugins added to the Styles menu. */\n getStyleFormats(): { items: readonly StyleFormat[]; replace: boolean } {\n return this.styleFormats;\n }\n\n /** A menu bar item (like addMenuItem). */\n addMenuItem(name: string, spec: MenuItemSpec): void {\n this.menuItems.set(name.toLowerCase(), spec);\n }\n\n /** A toggle item (with a check mark). */\n addToggleMenuItem(\n name: string,\n spec: MenuItemSpec & { isActive: (editor: Editor) => boolean },\n ): void {\n this.addMenuItem(name, spec);\n }\n\n /**\n * A menu item by name. If there is no separate item, it is built from the toolbar button of the\n * same name (label = tooltip), so each feature isn't defined twice.\n */\n getMenuItem(name: string): MenuItemSpec | undefined {\n const own = this.menuItems.get(name.toLowerCase());\n if (own) return own;\n const control = this.get(name);\n // In a menu a split button is its main action.\n if (control?.type !== 'button' && control?.type !== 'split') return undefined;\n return {\n text: control.tooltip,\n ...(control.icon ? { icon: control.icon } : {}),\n ...(control.shortcut ? { shortcut: control.shortcut } : {}),\n onAction: control.onAction,\n ...(control.isActive ? { isActive: control.isActive } : {}),\n ...(control.isEnabled ? { isEnabled: control.isEnabled } : {}),\n };\n }\n\n private readonly contextToolbars = new Map<string, ContextToolbarSpec>();\n private readonly autocompleters = new Map<string, AutocompleterSpec>();\n\n /** An autocompleter on a trigger character: '/' — commands, '@' — mentions, ':' — emoji. */\n private readonly sidebars = new Map<string, SidebarSpec>();\n\n /**\n * A sidebar (shown with editor.ui.sidebar). If the name is free, a toggle button with that name is\n * added for the toolbar and menus too (`button: false` — without it).\n */\n addSidebar(name: string, spec: SidebarSpec): void {\n this.sidebars.set(name, spec);\n if (spec.button === false || this.has(name)) return;\n this.addToggleButton(name, {\n tooltip: spec.tooltip ?? spec.title,\n icon: spec.icon ?? sidebarIcon,\n isActive: (editor) => editor.ui.sidebar.isOpen(name),\n onAction: (editor) => void editor.ui.sidebar.toggle(name),\n });\n }\n\n getSidebar(name: string): SidebarSpec | undefined {\n return this.sidebars.get(name);\n }\n\n private readonly views = new Map<string, ViewSpec>();\n\n /** A view: a plugin's screen in place of the editor (shown with editor.ui.view). */\n addView(name: string, spec: ViewSpec): void {\n this.views.set(name, spec);\n }\n\n getView(name: string): ViewSpec | undefined {\n return this.views.get(name);\n }\n\n addAutocompleter(name: string, spec: AutocompleterSpec): void {\n this.autocompleters.set(name.toLowerCase(), spec);\n }\n\n getAutocompleters(): [string, AutocompleterSpec][] {\n return [...this.autocompleters];\n }\n\n addContextToolbar(name: string, spec: ContextToolbarSpec): void {\n this.contextToolbars.set(name.toLowerCase(), spec);\n }\n\n /** By descending priority; equal ones in registration order (the sort is stable). */\n getContextToolbars(): [string, ContextToolbarSpec][] {\n return [...this.contextToolbars].sort((a, b) => (b[1].priority ?? 0) - (a[1].priority ?? 0));\n }\n\n get(name: string): ControlSpec | undefined {\n return this.controls.get(name.toLowerCase());\n }\n\n has(name: string): boolean {\n return this.controls.has(name.toLowerCase());\n }\n\n names(): string[] {\n return [...this.controls.keys()];\n }\n}\n","import type { Editor } from '../editor';\nimport { activeElement, FOCUSABLE, h, icon, uniqueId } from './dom';\nimport { icons } from './icons';\n\n/**\n * Plugin sidebars (comments, an outline, your own tools): a column next to the text, below it on a\n * narrow screen. One sidebar is open at a time. Its content is drawn on first show (it can load\n * lazily), and the sidebar stays in the DOM, keeping its state between shows.\n *\n * editor.ui.registry.addSidebar('outline', {\n * title: 'Outline',\n * icon: '<svg …>',\n * render: (container, editor) => { … },\n * });\n * editor.ui.sidebar.toggle('outline');\n */\nexport interface SidebarSpec {\n /** The sidebar's title (visible and announced) and the default button label. */\n title: string;\n /** Icon of the toolbar button (an SVG string). */\n icon?: string;\n /** Tooltip of the button (title by default). */\n tooltip?: string;\n /**\n * A toolbar toggle button and a menu item named after the sidebar (yes by default, if the name is\n * free). false — toggle the sidebar with your own buttons through editor.ui.sidebar.\n */\n button?: boolean;\n /** false — the sidebar draws its own title and close button (the container then has no role). */\n header?: boolean;\n /** Draw the content — once, on first show. May return a cleanup function. */\n render: (\n container: HTMLElement,\n editor: Editor,\n ) => void | (() => void) | Promise<void | (() => void)>;\n onShow?: (editor: Editor) => void;\n onHide?: (editor: Editor) => void;\n}\n\ninterface Mounted {\n el: HTMLElement;\n ready: Promise<boolean>;\n cleanup?: () => void;\n}\n\nexport class Sidebars {\n private current: string | null = null;\n private readonly mounted = new Map<string, Mounted>();\n private column: HTMLElement | null = null;\n private opening: Promise<void> = Promise.resolve();\n private destroyed = false;\n\n constructor(private readonly editor: Editor) {}\n\n /** Name of the open sidebar, or null. */\n get active(): string | null {\n return this.current;\n }\n\n isOpen(name: string): boolean {\n return this.current === name;\n }\n\n /**\n * Show a sidebar (another open one closes). `focus` — move focus into the sidebar (for example,\n * when it was opened from the keyboard, to work with it right away).\n */\n async show(name: string, options: { focus?: boolean } = {}): Promise<void> {\n const spec = this.editor.ui.registry.getSidebar(name);\n if (!spec) {\n console.warn(`[nova] sidebar \"${name}\" is not registered`);\n return;\n }\n if (this.current !== name) {\n this.hide({ restoreFocus: false });\n this.editor.ui.closeOverlays();\n this.current = name;\n const mounted = this.mount(name, spec);\n this.opening = mounted.ready.then((ok) => {\n if (!ok || this.current !== name || this.destroyed) {\n if (this.current === name) this.current = null;\n return;\n }\n mounted.el.hidden = false;\n this.editor.root.classList.add('nova-sidebar-open');\n spec.onShow?.(this.editor);\n this.editor.updateUI();\n });\n }\n // A repeated call while the panel is loading waits for the same load.\n await this.opening;\n if (options.focus && this.current === name) {\n const el = this.mounted.get(name)!.el;\n (el.querySelector<HTMLElement>(FOCUSABLE) ?? el).focus();\n }\n }\n\n /** Close the open sidebar. Focus returns from it to the text. */\n hide(options: { restoreFocus?: boolean } = {}): void {\n const name = this.current;\n if (!name) return;\n this.current = null;\n const mounted = this.mounted.get(name);\n if (!mounted) return;\n const hadFocus = mounted.el.contains(activeElement(mounted.el));\n mounted.el.hidden = true;\n this.editor.root.classList.remove('nova-sidebar-open');\n this.editor.ui.registry.getSidebar(name)?.onHide?.(this.editor);\n this.editor.updateUI();\n if (hadFocus && options.restoreFocus !== false) this.editor.focus();\n }\n\n toggle(name: string, options: { focus?: boolean } = {}): Promise<void> {\n if (this.current === name) {\n this.hide();\n return Promise.resolve();\n }\n return this.show(name, options);\n }\n\n destroy(): void {\n this.destroyed = true;\n this.mounted.forEach((mounted) => mounted.cleanup?.());\n this.mounted.clear();\n }\n\n /** The \"text + sidebar\" column: created with the first sidebar; without sidebars the markup doesn't change. */\n private host(): HTMLElement {\n if (this.column) return this.column;\n const content = this.editor.view.dom.parentElement!;\n const column = h('div', { className: 'nova-body' });\n content.before(column);\n column.append(content);\n this.column = column;\n return column;\n }\n\n private mount(name: string, spec: SidebarSpec): Mounted {\n const existing = this.mounted.get(name);\n if (existing) return existing;\n const titleId = uniqueId('nova-sidebar-title');\n const body = h('div', { className: 'nova-sidebar-body' });\n const close = h(\n 'button',\n {\n type: 'button',\n className: 'nova-btn nova-sidebar-close',\n 'aria-label': this.editor.ui.t('dialog.close'),\n onClick: () => this.hide(),\n },\n icon(icons.close),\n );\n const header =\n spec.header === false\n ? null\n : h(\n 'div',\n { className: 'nova-sidebar-head' },\n h('h2', { id: titleId, className: 'nova-sidebar-title' }, spec.title),\n close,\n );\n const el = h(\n 'div',\n {\n className: `nova-sidebar${header ? '' : ' nova-sidebar-bare'}`,\n hidden: true,\n 'data-sidebar': name,\n ...(this.editor.options.language ? { lang: this.editor.options.language } : {}),\n ...(header ? { role: 'complementary', 'aria-labelledby': titleId } : {}),\n onKeydown: ((event: KeyboardEvent) => {\n if (event.key !== 'Escape' || event.defaultPrevented) return;\n event.preventDefault();\n this.hide();\n }) as EventListener,\n },\n header,\n body,\n );\n this.host().append(el);\n const mounted: Mounted = { el, ready: Promise.resolve(false) };\n mounted.ready = (async () => {\n try {\n const cleanup = await spec.render(body, this.editor);\n if (typeof cleanup === 'function') mounted.cleanup = cleanup;\n return true;\n } catch (error) {\n console.error(`[nova] sidebar \"${name}\" failed to render`, error);\n el.remove();\n this.mounted.delete(name);\n return false;\n }\n })();\n this.mounted.set(name, mounted);\n return mounted;\n }\n}\n",".nova-editor.nova-view-open>:not(.nova-view):not(.nova-overlays){display:none}.nova-view{display:flex;flex:1 1 auto;flex-direction:column;min-height:240px;background:var(--nova-surface);color:var(--nova-fg)}.nova-view[hidden]{display:none}.nova-view:focus{outline:none}.nova-view-head{display:flex;align-items:center;gap:8px;padding:8px 12px;border-bottom:1px solid var(--nova-border);background:var(--nova-toolbar-bg)}.nova-view-title{margin:0;font-size:15px;font-weight:600}.nova-view-buttons{display:flex;gap:8px;margin-inline-start:auto}.nova-view-body{flex:1;min-height:0;padding:12px;overflow:auto}","import type { Editor } from '../editor';\nimport css from './editor-views.css?raw';\nimport { activeElement, FOCUSABLE, h } from './dom';\n\n/**\n * Views: a plugin's own screen in place of the editor (a review, a history, a report), with its own\n * buttons. One view is open at a time; while it is, the editor's toolbar, text and status bar are out\n * of sight (and out of the Tab order), and Escape or the view's buttons bring the text back.\n *\n * editor.ui.registry.addView('report', {\n * title: 'Report',\n * buttons: [{ text: 'Done', buttonType: 'primary', onAction: (e) => e.ui.view.hide() }],\n * onShow: (api) => api.getContainer().replaceChildren(…),\n * });\n * editor.ui.view.toggle('report');\n */\nexport interface ViewButton {\n text: string;\n /** primary: the view's main action (a filled button). */\n buttonType?: 'primary' | 'secondary';\n onAction: (editor: Editor) => void;\n}\n\nexport interface ViewApi {\n /** The element the view draws its content into. */\n getContainer(): HTMLElement;\n}\n\nexport interface ViewSpec {\n /** The view's heading (visible and announced); without it the view is named after its name. */\n title?: string;\n /** Buttons at the top of the view, on the end side. */\n buttons?: ViewButton[];\n /** Draw or refresh the content: called every time the view is shown. */\n onShow?: (api: ViewApi) => void;\n onHide?: (api: ViewApi) => void;\n}\n\ninterface Mounted {\n el: HTMLElement;\n api: ViewApi;\n}\n\nexport class Views {\n private current: string | null = null;\n private readonly mounted = new Map<string, Mounted>();\n\n constructor(private readonly editor: Editor) {}\n\n /** The name of the open view, or null. */\n get active(): string | null {\n return this.current;\n }\n\n isOpen(name: string): boolean {\n return this.current === name;\n }\n\n show(name: string): void {\n const spec = this.editor.ui.registry.getView(name);\n if (!spec) {\n console.warn(`[nova] view \"${name}\" is not registered`);\n return;\n }\n if (this.current === name) return;\n this.hide({ restoreFocus: false });\n this.editor.ui.closeOverlays();\n this.editor.ui.addStyles('nova-editor-views', css);\n const mounted = this.mount(name, spec);\n this.current = name;\n mounted.el.hidden = false;\n this.editor.root.classList.add('nova-view-open');\n try {\n spec.onShow?.(mounted.api);\n } catch (error) {\n console.error(`[nova] view \"${name}\" failed to show`, error);\n }\n (mounted.el.querySelector<HTMLElement>(FOCUSABLE) ?? mounted.el).focus();\n this.editor.updateUI();\n }\n\n /** Close the open view: the editor comes back, and focus returns to the text. */\n hide(options: { restoreFocus?: boolean } = {}): void {\n const name = this.current;\n if (!name) return;\n this.current = null;\n const mounted = this.mounted.get(name);\n if (!mounted) return;\n const hadFocus = mounted.el.contains(activeElement(mounted.el));\n mounted.el.hidden = true;\n this.editor.root.classList.remove('nova-view-open');\n try {\n this.editor.ui.registry.getView(name)?.onHide?.(mounted.api);\n } catch (error) {\n console.error(`[nova] view \"${name}\" failed to hide`, error);\n }\n this.editor.updateUI();\n if (hadFocus && options.restoreFocus !== false) this.editor.focus();\n }\n\n toggle(name: string): void {\n if (this.current === name) this.hide();\n else this.show(name);\n }\n\n destroy(): void {\n this.mounted.forEach(({ el }) => el.remove());\n this.mounted.clear();\n this.current = null;\n }\n\n private mount(name: string, spec: ViewSpec): Mounted {\n const existing = this.mounted.get(name);\n if (existing) return existing;\n const body = h('div', { className: 'nova-view-body' });\n const buttons = (spec.buttons ?? []).map((button) =>\n h(\n 'button',\n {\n type: 'button',\n className:\n button.buttonType === 'primary' ? 'nova-button nova-button-primary' : 'nova-button',\n onClick: () => {\n try {\n button.onAction(this.editor);\n } catch (error) {\n console.error(`[nova] a button of view \"${name}\" failed`, error);\n }\n },\n },\n button.text,\n ),\n );\n const el = h(\n 'section',\n {\n className: 'nova-view',\n hidden: true,\n tabindex: '-1',\n 'data-view': name,\n 'aria-label': spec.title ?? name,\n ...(this.editor.options.language ? { lang: this.editor.options.language } : {}),\n onKeydown: ((event: KeyboardEvent) => {\n if (event.key !== 'Escape' || event.defaultPrevented) return;\n event.preventDefault();\n this.hide();\n }) as EventListener,\n },\n h(\n 'div',\n { className: 'nova-view-head' },\n spec.title ? h('h2', { className: 'nova-view-title' }, spec.title) : null,\n h('div', { className: 'nova-view-buttons' }, ...buttons),\n ),\n body,\n );\n this.editor.root.append(el);\n const mounted: Mounted = { el, api: { getContainer: () => body } };\n this.mounted.set(name, mounted);\n return mounted;\n }\n}\n","import { formatShortcut, h, listenDocument } from './dom';\nimport { positionFloating } from './popover';\n\nconst SHOW_DELAY = 450;\n/** The time the pointer has to get from a button onto its tooltip. */\nconst HIDE_DELAY = 150;\n\n/**\n * One shared tooltip per editor: the button name plus its shortcut. With a delay for the mouse, at\n * once for keyboard focus. Not shown on touch devices (there the label is in aria-label rather than\n * hidden in a tooltip). Content on hover as WCAG 1.4.13 asks: Escape dismisses it without moving\n * focus or the pointer, and the pointer can move onto it without it disappearing.\n */\nexport class Tooltip {\n private readonly el: HTMLDivElement;\n private timer: ReturnType<typeof setTimeout> | null = null;\n private target: HTMLElement | null = null;\n private offEscape: (() => void) | null = null;\n\n constructor(host: HTMLElement) {\n this.el = h('div', { className: 'nova-tooltip', role: 'tooltip', hidden: true });\n this.el.addEventListener('pointerenter', () => this.clearTimer());\n this.el.addEventListener('pointerleave', () => this.hide());\n this.el.addEventListener('pointerdown', () => this.hide());\n host.append(this.el);\n }\n\n /** Attach the tooltip to an element. The text comes from data-tooltip and data-shortcut. */\n attach(target: HTMLElement): void {\n target.addEventListener('pointerenter', (e) => {\n if (e.pointerType === 'mouse') this.schedule(target);\n });\n // Not at once: the pointer may be on its way to the tooltip.\n target.addEventListener('pointerleave', () => {\n this.clearTimer();\n if (!this.el.hidden) this.timer = setTimeout(() => this.hide(), HIDE_DELAY);\n });\n target.addEventListener('focus', () => {\n if (target.matches(':focus-visible')) this.show(target);\n });\n target.addEventListener('blur', () => this.hide());\n target.addEventListener('pointerdown', () => this.hide());\n }\n\n private schedule(target: HTMLElement): void {\n this.clearTimer();\n this.timer = setTimeout(() => this.show(target), SHOW_DELAY);\n }\n\n show(target: HTMLElement): void {\n this.clearTimer();\n const text = target.dataset.tooltip;\n if (!text || target.getAttribute('aria-expanded') === 'true') return;\n this.target = target;\n const shortcut = target.dataset.shortcut;\n this.el.replaceChildren(h('span', {}, text));\n if (shortcut) this.el.append(h('kbd', {}, formatShortcut(shortcut)));\n this.el.hidden = false;\n positionFloating(this.el, target.getBoundingClientRect(), 'bottom');\n // Escape is the tooltip's while it shows: it goes away, focus and the pointer stay put.\n this.offEscape ??= listenDocument(this.el, 'keydown', (event) => {\n if (event.key !== 'Escape' || this.el.hidden) return;\n event.preventDefault();\n event.stopPropagation();\n this.hide();\n });\n }\n\n hide(): void {\n this.clearTimer();\n this.el.hidden = true;\n this.target = null;\n this.offEscape?.();\n this.offEscape = null;\n }\n\n get current(): HTMLElement | null {\n return this.target;\n }\n\n destroy(): void {\n this.hide();\n this.el.remove();\n }\n\n private clearTimer(): void {\n if (this.timer) clearTimeout(this.timer);\n this.timer = null;\n }\n}\n","import type { Editor } from '../editor';\nimport type { Translator } from '../i18n';\n\n/** Which styles are already attached to the document or a shadow root (once per root). */\nconst addedStyles = new WeakMap<Document | ShadowRoot, Set<string>>();\nimport { openDialog, type DialogHandle, type DialogOptions } from './dialog';\nimport { h } from './dom';\nimport type { DialogData, DialogSpec } from './form-dialog-types';\nimport { Notifications, type NotificationHandle, type NotificationOptions } from './notification';\nimport { Popover, type PopoverOptions } from './popover';\nimport { Registry } from './registry';\nimport { Sidebars } from './sidebar';\nimport { Views } from './editor-views';\nimport { Tooltip } from './tooltip';\n\n/**\n * The UI layer of an editor instance: the control registry, overlays (popovers, dialogs, tooltips),\n * notifications and translations. Available as editor.ui.\n */\nexport class UiManager {\n readonly registry = new Registry();\n readonly t: Translator;\n /** The layer for all floating elements. It sits inside .nova-editor, so it inherits the theme. */\n readonly overlayHost: HTMLDivElement;\n readonly tooltip: Tooltip;\n /** Plugin sidebars: show / hide / toggle (register them with registry.addSidebar). */\n readonly sidebar: Sidebars;\n /** Plugin views in place of the editor: show / hide / toggle (register them with registry.addView). */\n readonly view: Views;\n private readonly notifications: Notifications;\n private popover: Popover | null = null;\n private currentDialog: DialogHandle | null = null;\n /** The hidden polite live region for announce(); it exists from the start, so screen readers watch it. */\n private readonly liveRegion: HTMLElement;\n private announceTimer: ReturnType<typeof setTimeout> | undefined;\n\n private readonly rootEl: HTMLElement;\n\n constructor(\n root: HTMLElement,\n t: Translator,\n private readonly focusEditor: () => void,\n editor: Editor,\n ) {\n this.t = t;\n this.rootEl = root;\n this.overlayHost = h('div', { className: 'nova-overlays' });\n root.append(this.overlayHost);\n this.tooltip = new Tooltip(this.overlayHost);\n this.notifications = new Notifications(root, t('dialog.close'));\n this.sidebar = new Sidebars(editor);\n this.view = new Views(editor);\n this.liveRegion = h('div', {\n className: 'nova-visually-hidden nova-announcer',\n role: 'status',\n 'aria-live': 'polite',\n 'aria-atomic': 'true',\n });\n root.append(this.liveRegion);\n }\n\n /**\n * Say a short message to screen readers without moving focus: what a shortcut or a typed Markdown\n * shortcut changed (\"Bold on\", \"Bulleted list\"). Plugins can use it for their own changes.\n */\n announce(message: string): void {\n const region = this.liveRegion;\n // Clear first and fill a moment later: the same text twice in a row (bold on, off, on) is read again.\n region.textContent = '';\n clearTimeout(this.announceTimer);\n this.announceTimer = setTimeout(() => {\n region.textContent = message;\n }, 50);\n }\n\n /**\n * Add a plugin's styles to the editor's document (or shadow root) — once per page, however many\n * editors there are. For panels and dialogs that load lazily: their styles don't belong in the\n * first-load style.css. Constructed style sheets don't need 'unsafe-inline' in your CSP; where they\n * aren't supported, a plain <style> is used. Override such styles with a selector at least as specific.\n */\n addStyles(id: string, css: string): void {\n const root = this.rootEl.getRootNode() as Document | ShadowRoot;\n let ids = addedStyles.get(root);\n if (!ids) addedStyles.set(root, (ids = new Set()));\n if (ids.has(id)) return;\n ids.add(id);\n if ('adoptedStyleSheets' in root && typeof CSSStyleSheet !== 'undefined') {\n try {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];\n return;\n } catch {\n // partial support: fall through to <style>\n }\n }\n const style = document.createElement('style');\n style.dataset.novaStyles = id;\n style.textContent = css;\n ((root as Document).head ?? root).append(style);\n }\n\n /**\n * A dialog described by its fields (for plugins): validation, errors at the fields, accessibility.\n * Returns the data, or null if the dialog was closed. The implementation loads when first opened.\n */\n async dialog(spec: DialogSpec): Promise<DialogData | null> {\n const { openFormDialog, formDialogCss } = await import('./form-dialog');\n this.addStyles('nova-form-dialog', formDialogCss);\n return openFormDialog(spec, this.t, (options) => this.openDialog(options));\n }\n\n /** Open a popover; only one is open at a time (except the toolbar overflow panel). */\n openPopover(options: Omit<PopoverOptions, 'host'>): Popover {\n this.closePopover();\n this.tooltip.hide();\n const popover = new Popover({\n ...options,\n host: this.overlayHost,\n onClose: (reason) => {\n if (this.popover === popover) this.popover = null;\n options.onClose?.(reason);\n },\n });\n this.popover = popover;\n return popover;\n }\n\n closePopover(): void {\n this.popover?.close('api');\n this.popover = null;\n }\n\n get activePopover(): Popover | null {\n return this.popover;\n }\n\n private readonly dialogListeners = new Set<() => void>();\n\n /**\n * Subscribe to a dialog opening (returns an unsubscribe function). The toolbar uses it to close\n * its \"⋯\" panel, which on a narrow screen otherwise stayed over the text after a dialog opened from it closed.\n */\n onDialogOpen(listener: () => void): () => void {\n this.dialogListeners.add(listener);\n return () => this.dialogListeners.delete(listener);\n }\n\n /**\n * Close floating panels and the toolbar's \"⋯\" before a plugin opens its own panel or view (version\n * history, comments), so they don't stay on top.\n */\n closeOverlays(): void {\n this.closePopover();\n this.dialogListeners.forEach((listener) => listener());\n }\n\n openDialog(\n options: Omit<DialogOptions, 'host' | 'cancelLabel' | 'closeLabel' | 'returnFocus'> & {\n cancelLabel?: string;\n },\n ): DialogHandle {\n this.closePopover();\n this.dialogListeners.forEach((listener) => listener());\n this.currentDialog?.close();\n const handle = openDialog({\n cancelLabel: this.t('dialog.cancel'),\n closeLabel: this.t('dialog.close'),\n ...options,\n host: this.overlayHost,\n returnFocus: this.focusEditor,\n onClose: () => {\n if (this.currentDialog === handle) this.currentDialog = null;\n options.onClose?.();\n },\n });\n this.currentDialog = handle;\n return handle;\n }\n\n get activeDialog(): DialogHandle | null {\n return this.currentDialog;\n }\n\n notify(options: NotificationOptions | string): NotificationHandle {\n return this.notifications.open(typeof options === 'string' ? { text: options } : options);\n }\n\n destroy(): void {\n this.sidebar.destroy();\n this.view.destroy();\n this.closePopover();\n this.currentDialog?.close();\n this.tooltip.destroy();\n this.notifications.destroy();\n this.overlayHost.remove();\n clearTimeout(this.announceTimer);\n this.liveRegion.remove();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AQ;AAChB,SAAK,SAAS,QAAQ;AACtB,SAAK,WAAW,QAAQ;AACxB,eAAW,WAAW,KAAK,SAAS,OAAO,CAAC,GAAG;AAC7C,UAAI;AACF,gBAAQ;AAAA,MACV,SAAS,OAAO;AACd,0BAAkB,yBAAyB,KAAK;AAAA,MAClD;AAAA,IACF;AACA,SAAK,WAAW,QAAQ;AACxB,QAAI,KAAK,KAAK,UAAU,SAAS,iBAAiB,EAAG,kBAAiB,MAAM,KAAK;AACjF,SAAK,KAAK,QAAQ;AAClB,SAAK,KAAK,OAAO;AACjB,SAAK,UAAU,MAAM;AAAA,EACvB;AACF;AAEA,SAAS,kBAAkB,SAAiB,OAAuB;AACjE,UAAQ,MAAM,UAAU,OAAO,IAAI,GAAI,UAAU,SAAY,CAAC,IAAI,CAAC,KAAK,CAAE;AAC5E;AAGA,IAAM,aAAa,oBAAI,QAAgB;AAEhC,SAAS,aACdD,SACA,SACA,MACQ;AACR,MAAI,OAAO,YAAY,SAAU,QAAO,OAAO,SAASA,SAAQ,aAAaA,SAAQ,OAAO,CAAC;AAE7F,QAAM,QAAQ,OAAO,KAAK,KAAK,OAAO,IAAI;AAC1C,QAAM,YAAY,SAAS,cAAc,KAAK;AAG9C,QAAM,WAAW,SAAS,cAAc,UAAU;AAClD,WAAS,YAAY,QAAQ,MAAM,UAAU;AAC7C,YAAU,YAAY,SAAS,OAAO;AACtC,QAAM,MAAM,UAAUA,OAAM,EAAE,MAAM,SAAS;AAC7C,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,QAAQ,IAAI,KAAK,OAAO,MAAM,OAAO,IAAI,OAAO;AACtD,aAAW,IAAI,KAAK;AACpB,SAAO;AACT;AAEO,SAAS,aAAa,SAAgC;AAC3D,SAAO,IAAI,OAAO,OAAO;AAC3B;","names":["text","key","key","commands","key","keymap","Slice","Plugin","Plugin","Plugin","PluginKey","PluginKey","key","Plugin","key","schema","Plugin","keymap","keymap","AllSelection","Plugin","PluginKey","TextSelection","PluginKey","Plugin","kept","TextSelection","AllSelection","NodeSelection","Plugin","PluginKey","Plugin","PluginKey","NodeSelection","spec","NodeSelection","MIN_WIDTH","h","NodeSelection","Plugin","PluginKey","Plugin","PluginKey","own","Slice","keymap","schema","Plugin"]}