@novaprose/core 0.7.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 (347) hide show
  1. package/README.md +15 -2
  2. package/dist/a11y.cjs +314 -0
  3. package/dist/a11y.cjs.map +1 -0
  4. package/dist/a11y.d.cts +51 -0
  5. package/dist/a11y.d.ts +51 -0
  6. package/dist/a11y.js +11 -0
  7. package/dist/a11y.js.map +1 -0
  8. package/dist/a11ychecker-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-5FNKPLUX.js → advlist-CEHE6YXS.js} +10 -7
  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-45LTODWB.js → autolink-N427KVQO.js} +11 -8
  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-GMWJ5BPE.js → autosave-L7OZ3KLK.js} +7 -7
  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-2GC7LF7G.js → charmap-5CBBDWOP.js} +7 -7
  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-ND2CWNVG.js → chunk-3BOK3S3T.js} +2 -27
  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-PVFKXRID.js → chunk-4VPDY3LF.js} +1 -1
  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-T3GY6IVK.js → chunk-AC3YCAX4.js} +71 -9
  57. package/dist/chunk-AC3YCAX4.js.map +1 -0
  58. package/dist/{chunk-5AW2HHG6.js → chunk-ADRPQLZ2.js} +47 -3
  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-R2UMUCVI.js → chunk-DEYYVZ7O.js} +50 -8
  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-KWXFL4WS.js → chunk-GHVB6SV4.js} +8 -5
  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-KPE3QRPB.js → chunk-J6W2CDRF.js} +16 -315
  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-JPJVTB45.js → chunk-QU3KXMYT.js} +8 -2
  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-FCMZ7TUQ.js → chunk-TAM2FHKG.js} +172 -43
  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/{table-SSNABG5W.js → chunk-VK6YF2AA.js} +119 -61
  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-HXMWSRAW.js → comments-panel-SOLBZ46Q.js} +9 -5
  147. package/dist/comments-panel-SOLBZ46Q.js.map +1 -0
  148. package/dist/{directionality-5JLWQGP2.js → directionality-EGQKGDZA.js} +13 -10
  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-ZD6ZRIWG.js → emoticons-EGHNZKSA.js} +7 -7
  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 +19 -17
  189. package/dist/html-rules.cjs.map +1 -1
  190. package/dist/html-rules.d.cts +37 -35
  191. package/dist/html-rules.d.ts +37 -35
  192. package/dist/html-rules.js +24 -20
  193. package/dist/html-rules.js.map +1 -1
  194. package/dist/i18n/de.cjs +346 -0
  195. package/dist/i18n/de.cjs.map +1 -1
  196. package/dist/i18n/de.d.cts +1 -1
  197. package/dist/i18n/de.d.ts +1 -1
  198. package/dist/i18n/de.js +346 -0
  199. package/dist/i18n/de.js.map +1 -1
  200. package/dist/i18n/es.cjs +346 -0
  201. package/dist/i18n/es.cjs.map +1 -1
  202. package/dist/i18n/es.d.cts +1 -1
  203. package/dist/i18n/es.d.ts +1 -1
  204. package/dist/i18n/es.js +346 -0
  205. package/dist/i18n/es.js.map +1 -1
  206. package/dist/i18n/fr.cjs +346 -0
  207. package/dist/i18n/fr.cjs.map +1 -1
  208. package/dist/i18n/fr.d.cts +1 -1
  209. package/dist/i18n/fr.d.ts +1 -1
  210. package/dist/i18n/fr.js +346 -0
  211. package/dist/i18n/fr.js.map +1 -1
  212. package/dist/i18n/it.cjs +346 -0
  213. package/dist/i18n/it.cjs.map +1 -1
  214. package/dist/i18n/it.d.cts +1 -1
  215. package/dist/i18n/it.d.ts +1 -1
  216. package/dist/i18n/it.js +346 -0
  217. package/dist/i18n/it.js.map +1 -1
  218. package/dist/i18n/pt-BR.cjs +346 -0
  219. package/dist/i18n/pt-BR.cjs.map +1 -1
  220. package/dist/i18n/pt-BR.d.cts +1 -1
  221. package/dist/i18n/pt-BR.d.ts +1 -1
  222. package/dist/i18n/pt-BR.js +346 -0
  223. package/dist/i18n/pt-BR.js.map +1 -1
  224. package/dist/i18n/ru.cjs +346 -0
  225. package/dist/i18n/ru.cjs.map +1 -1
  226. package/dist/i18n/ru.d.cts +3 -3
  227. package/dist/i18n/ru.d.ts +3 -3
  228. package/dist/i18n/ru.js +346 -0
  229. package/dist/i18n/ru.js.map +1 -1
  230. package/dist/importcss-JLNIRKGH.js +127 -0
  231. package/dist/importcss-JLNIRKGH.js.map +1 -0
  232. package/dist/importword-D7Z6RXGQ.js +73 -0
  233. package/dist/importword-D7Z6RXGQ.js.map +1 -0
  234. package/dist/{index-C603bU6r.d.ts → index-CZ9yDvmQ.d.cts} +36 -17
  235. package/dist/{index-C603bU6r.d.cts → index-CZ9yDvmQ.d.ts} +36 -17
  236. package/dist/index.cjs +28858 -10442
  237. package/dist/index.cjs.map +1 -1
  238. package/dist/index.d.cts +138 -64
  239. package/dist/index.d.ts +138 -64
  240. package/dist/index.js +199 -1411
  241. package/dist/index.js.map +1 -1
  242. package/dist/{insertdatetime-CRO7TJAQ.js → insertdatetime-YW2VHYZH.js} +7 -7
  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 +94 -11
  249. package/dist/markdown.cjs.map +1 -1
  250. package/dist/markdown.d.cts +12 -10
  251. package/dist/markdown.d.ts +12 -10
  252. package/dist/markdown.js +4 -235
  253. package/dist/markdown.js.map +1 -1
  254. package/dist/math-ui-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-66LFZV2W.js → nonbreaking-GYRUH4UO.js} +7 -7
  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-F3QW4WWO.js → paste-office-3A6KWKCV.js} +82 -2
  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-7E2QRS7J.js → quickbars-UZ2Q67TX.js} +20 -12
  279. package/dist/quickbars-UZ2Q67TX.js.map +1 -0
  280. package/dist/{revisionhistory-DXE7KU4R.js → revisionhistory-ACRB23HL.js} +42 -153
  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-6DLBXYOA.js → visualblocks-O5QW7ZDT.js} +7 -7
  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 +53 -3
  313. package/src/style.css +320 -544
  314. package/dist/advlist-5FNKPLUX.js.map +0 -1
  315. package/dist/autolink-45LTODWB.js.map +0 -1
  316. package/dist/autoresize-UB3GOA6D.js.map +0 -1
  317. package/dist/autosave-GMWJ5BPE.js.map +0 -1
  318. package/dist/charmap-2GC7LF7G.js.map +0 -1
  319. package/dist/chunk-5AW2HHG6.js.map +0 -1
  320. package/dist/chunk-DWZLSZDG.js +0 -5664
  321. package/dist/chunk-DWZLSZDG.js.map +0 -1
  322. package/dist/chunk-FCMZ7TUQ.js.map +0 -1
  323. package/dist/chunk-HPLT3XRZ.js.map +0 -1
  324. package/dist/chunk-JPJVTB45.js.map +0 -1
  325. package/dist/chunk-KPE3QRPB.js.map +0 -1
  326. package/dist/chunk-KWXFL4WS.js.map +0 -1
  327. package/dist/chunk-ND2CWNVG.js.map +0 -1
  328. package/dist/chunk-PVFKXRID.js.map +0 -1
  329. package/dist/chunk-R2UMUCVI.js.map +0 -1
  330. package/dist/chunk-T3GY6IVK.js.map +0 -1
  331. package/dist/chunk-Z3ELZ77W.js.map +0 -1
  332. package/dist/comments-panel-HXMWSRAW.js.map +0 -1
  333. package/dist/directionality-5JLWQGP2.js.map +0 -1
  334. package/dist/editor-CXkltf1R.d.ts +0 -1886
  335. package/dist/editor-CgSBFTke.d.cts +0 -1886
  336. package/dist/emoticons-ZD6ZRIWG.js.map +0 -1
  337. package/dist/form-dialog-QH6KAERD.js +0 -180
  338. package/dist/form-dialog-QH6KAERD.js.map +0 -1
  339. package/dist/html-rules-api-D3fKQi-R.d.cts +0 -40
  340. package/dist/html-rules-api-D3fKQi-R.d.ts +0 -40
  341. package/dist/insertdatetime-CRO7TJAQ.js.map +0 -1
  342. package/dist/nonbreaking-66LFZV2W.js.map +0 -1
  343. package/dist/paste-office-F3QW4WWO.js.map +0 -1
  344. package/dist/quickbars-7E2QRS7J.js.map +0 -1
  345. package/dist/revisionhistory-DXE7KU4R.js.map +0 -1
  346. package/dist/table-SSNABG5W.js.map +0 -1
  347. package/dist/visualblocks-6DLBXYOA.js.map +0 -1
@@ -0,0 +1,1149 @@
1
+ import {
2
+ SET_CONTENT_META
3
+ } from "./chunk-OQMMHWMZ.js";
4
+ import {
5
+ pickLabels
6
+ } from "./chunk-DEYYVZ7O.js";
7
+ import {
8
+ definePlugin
9
+ } from "./chunk-V7WUHUHM.js";
10
+
11
+ // src/plugins/suggestions.ts
12
+ import {
13
+ Fragment,
14
+ Slice
15
+ } from "prosemirror-model";
16
+ import {
17
+ EditorState,
18
+ NodeSelection,
19
+ Plugin,
20
+ PluginKey,
21
+ Selection,
22
+ TextSelection
23
+ } from "prosemirror-state";
24
+ import { liftListItem } from "prosemirror-schema-list";
25
+ import {
26
+ AddMarkStep,
27
+ AttrStep,
28
+ canJoin,
29
+ liftTarget,
30
+ RemoveMarkStep,
31
+ ReplaceAroundStep,
32
+ ReplaceStep,
33
+ Transform
34
+ } from "prosemirror-transform";
35
+ import { Decoration, DecorationSet } from "prosemirror-view";
36
+ import { keymap } from "prosemirror-keymap";
37
+ var ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
38
+ var USER_ID_RE = /^[\w.@:+-]{1,128}$/;
39
+ var LABELS = {
40
+ en: {
41
+ toggle: "Suggest edits",
42
+ review: "Review suggestions",
43
+ accept: "Accept",
44
+ reject: "Reject",
45
+ acceptAll: "Accept all suggestions",
46
+ rejectAll: "Reject all suggestions",
47
+ next: "Next suggestion",
48
+ previous: "Previous suggestion",
49
+ inserted: "Inserted by {name}",
50
+ deleted: "Deleted by {name}",
51
+ formatted: "Formatted by {name}",
52
+ toolbar: "Suggestion",
53
+ guest: "Guest",
54
+ none: "No suggestions",
55
+ unsupported: "This change can\u2019t be a suggestion",
56
+ unsupportedDirect: "This change can\u2019t be a suggestion. To make it, turn off Suggest edits."
57
+ }
58
+ };
59
+ var suggestionsKey = new PluginKey("nova-suggestions");
60
+ var OWN = "nova-suggestions-own";
61
+ var RESOLVED = "nova-suggestions-resolved";
62
+ var PALETTE = ["#116329", "#6639ba", "#99286e", "#0550ae", "#953800", "#0e5b5e"];
63
+ function suggestionColor(key) {
64
+ let hash = 0;
65
+ for (const ch of String(key ?? "")) hash = hash * 31 + ch.charCodeAt(0) | 0;
66
+ return PALETTE[Math.abs(hash) % PALETTE.length];
67
+ }
68
+ function newId() {
69
+ const bytes = new Uint8Array(9);
70
+ globalThis.crypto.getRandomValues(bytes);
71
+ return "s" + Array.from(bytes, (b) => (b % 36).toString(36)).join("");
72
+ }
73
+ function markSpec(kind) {
74
+ const tag = kind === "insert" ? "ins" : "del";
75
+ return {
76
+ attrs: { id: {}, author: { default: "" }, name: { default: "" }, time: { default: 0 } },
77
+ inclusive: false,
78
+ excludes: "",
79
+ parseDOM: [
80
+ {
81
+ tag: `${tag}[data-suggestion]`,
82
+ // Before the strike-through rules (<del> without data-suggestion is a regular strike-through).
83
+ priority: 60,
84
+ getAttrs: (dom) => {
85
+ const el = dom;
86
+ const id = el.getAttribute("data-suggestion") ?? "";
87
+ if (!ID_RE.test(id)) return false;
88
+ const author = el.getAttribute("data-author") ?? "";
89
+ return {
90
+ id,
91
+ author: USER_ID_RE.test(author) ? author : "",
92
+ name: (el.getAttribute("data-name") ?? "").slice(0, 80),
93
+ time: Number(el.getAttribute("data-time")) || 0
94
+ };
95
+ }
96
+ }
97
+ ],
98
+ toDOM: (mark) => [
99
+ tag,
100
+ {
101
+ "data-suggestion": ID_RE.test(mark.attrs.id) ? mark.attrs.id : null,
102
+ "data-author": USER_ID_RE.test(mark.attrs.author) ? mark.attrs.author : null,
103
+ "data-name": String(mark.attrs.name ?? "").slice(0, 80) || null,
104
+ "data-time": Number(mark.attrs.time) || null
105
+ },
106
+ 0
107
+ ]
108
+ };
109
+ }
110
+ function cleanFormat(value) {
111
+ let list;
112
+ try {
113
+ list = typeof value === "string" ? JSON.parse(value) : value;
114
+ } catch {
115
+ return "[]";
116
+ }
117
+ if (!Array.isArray(list)) return "[]";
118
+ const out = [];
119
+ for (const item of list.slice(0, 16)) {
120
+ const type = item?.type;
121
+ if (typeof type !== "string" || !/^[a-z][a-z0-9_]{0,39}$/.test(type)) continue;
122
+ const attrs = cleanAttrs(item.attrs, 8);
123
+ out.push(Object.keys(attrs).length ? { type, attrs } : { type });
124
+ }
125
+ return JSON.stringify(out);
126
+ }
127
+ function cleanAttrs(raw, max) {
128
+ const attrs = {};
129
+ if (raw && typeof raw === "object" && !Array.isArray(raw)) {
130
+ for (const [key, attr] of Object.entries(raw).slice(0, max)) {
131
+ if (!/^[A-Za-z][\w-]{0,39}$/.test(key) || key === "suggestion") continue;
132
+ if (typeof attr === "string") attrs[key] = attr.slice(0, 2e3);
133
+ else if (typeof attr === "number" || typeof attr === "boolean" || attr === null)
134
+ attrs[key] = attr;
135
+ }
136
+ }
137
+ return attrs;
138
+ }
139
+ function blockSuggestion(value) {
140
+ if (!value || typeof value !== "object") return null;
141
+ const raw = value;
142
+ if (typeof raw.id !== "string" || !ID_RE.test(raw.id)) return null;
143
+ const author = String(raw.author ?? "");
144
+ const base = {
145
+ id: raw.id,
146
+ author: USER_ID_RE.test(author) ? author : "",
147
+ name: String(raw.name ?? "").slice(0, 80),
148
+ time: Number(raw.time) || 0
149
+ };
150
+ if (raw.change === "split" || raw.change === "join") {
151
+ const before2 = raw.change === "join" && raw.before != null ? parseBefore(raw.before) : null;
152
+ return {
153
+ ...base,
154
+ change: raw.change,
155
+ depth: Math.min(4, Math.max(1, Math.trunc(Number(raw.depth)) || 1)),
156
+ ...before2 ? { before: before2 } : {}
157
+ };
158
+ }
159
+ if (raw.change === "insert" || raw.change === "delete") return { ...base, change: raw.change };
160
+ if (raw.change === "wrap" || raw.change === "unwrap") {
161
+ return {
162
+ ...base,
163
+ change: raw.change,
164
+ depth: Math.min(9, Math.max(1, Math.trunc(Number(raw.depth)) || 1))
165
+ };
166
+ }
167
+ const before = parseBefore(raw.before);
168
+ return before ? { ...base, change: "block", before } : null;
169
+ }
170
+ function parseBefore(value) {
171
+ let before = value;
172
+ try {
173
+ if (typeof before === "string") before = JSON.parse(before);
174
+ } catch {
175
+ return null;
176
+ }
177
+ const type = before?.type;
178
+ if (typeof type !== "string" || !/^[a-z][a-z0-9_]{0,39}$/.test(type)) return null;
179
+ return { type, attrs: cleanAttrs(before.attrs, 12) };
180
+ }
181
+ var blockAttribute = {
182
+ nodes: "all",
183
+ default: null,
184
+ parse: (dom) => dom.hasAttribute("data-before") || dom.hasAttribute("data-change") ? blockSuggestion({
185
+ id: dom.getAttribute("data-suggestion"),
186
+ author: dom.getAttribute("data-author"),
187
+ name: dom.getAttribute("data-name"),
188
+ time: dom.getAttribute("data-time"),
189
+ before: dom.getAttribute("data-before"),
190
+ change: dom.getAttribute("data-change"),
191
+ depth: dom.getAttribute("data-depth")
192
+ }) : null,
193
+ render(value) {
194
+ const s = blockSuggestion(value);
195
+ if (!s) return {};
196
+ const out = { "data-suggestion": s.id };
197
+ if (s.change !== "block") out["data-change"] = s.change;
198
+ if (s.before) out["data-before"] = JSON.stringify(s.before);
199
+ if ((s.depth ?? 1) > 1) out["data-depth"] = String(s.depth);
200
+ if (s.author) out["data-author"] = s.author;
201
+ if (s.name) out["data-name"] = s.name;
202
+ if (s.time) out["data-time"] = String(s.time);
203
+ return out;
204
+ }
205
+ };
206
+ var trackers = null;
207
+ function setStructureTrackers(value) {
208
+ trackers = value;
209
+ }
210
+ function formatSpec() {
211
+ return {
212
+ attrs: {
213
+ id: {},
214
+ author: { default: "" },
215
+ name: { default: "" },
216
+ time: { default: 0 },
217
+ before: { default: "[]" }
218
+ },
219
+ inclusive: false,
220
+ excludes: "",
221
+ parseDOM: [
222
+ {
223
+ tag: "span[data-suggestion][data-format]",
224
+ priority: 60,
225
+ getAttrs: (dom) => {
226
+ const el = dom;
227
+ const id = el.getAttribute("data-suggestion") ?? "";
228
+ if (!ID_RE.test(id)) return false;
229
+ const author = el.getAttribute("data-author") ?? "";
230
+ return {
231
+ id,
232
+ author: USER_ID_RE.test(author) ? author : "",
233
+ name: (el.getAttribute("data-name") ?? "").slice(0, 80),
234
+ time: Number(el.getAttribute("data-time")) || 0,
235
+ before: cleanFormat(el.getAttribute("data-format"))
236
+ };
237
+ }
238
+ }
239
+ ],
240
+ toDOM: (mark) => [
241
+ "span",
242
+ {
243
+ "data-suggestion": ID_RE.test(mark.attrs.id) ? mark.attrs.id : null,
244
+ "data-format": cleanFormat(mark.attrs.before),
245
+ "data-author": USER_ID_RE.test(mark.attrs.author) ? mark.attrs.author : null,
246
+ "data-name": String(mark.attrs.name ?? "").slice(0, 80) || null,
247
+ "data-time": Number(mark.attrs.time) || null
248
+ },
249
+ 0
250
+ ]
251
+ };
252
+ }
253
+ var typesOf = (schema) => ({
254
+ insert: schema.marks.suggestion_insert,
255
+ delete: schema.marks.suggestion_delete,
256
+ format: schema.marks.suggestion_format
257
+ });
258
+ var NOT_FORMATTING = /* @__PURE__ */ new Set([
259
+ "suggestion_insert",
260
+ "suggestion_delete",
261
+ "suggestion_format",
262
+ "comment"
263
+ ]);
264
+ var formatting = (marks) => marks.filter((m) => !NOT_FORMATTING.has(m.type.name));
265
+ function formatMarks(schema, before) {
266
+ const marks = [];
267
+ for (const json of JSON.parse(cleanFormat(before))) {
268
+ if (NOT_FORMATTING.has(json.type) || !schema.marks[json.type]) continue;
269
+ try {
270
+ const mark = schema.markFromJSON(json);
271
+ if (!mark.isInSet(marks)) marks.push(mark);
272
+ } catch {
273
+ }
274
+ }
275
+ return marks;
276
+ }
277
+ var sameMarks = (a, b) => a.length === b.length && a.every((mark) => mark.isInSet(b));
278
+ function isUserEdit(tr) {
279
+ if (!tr.docChanged || tr.getMeta(OWN)) return false;
280
+ if (tr.getMeta("addToHistory") === false) return false;
281
+ if (tr.getMeta(SET_CONTENT_META)) return false;
282
+ if (tr.getMeta("history$")) return false;
283
+ const ySync = tr.getMeta("y-sync$");
284
+ return !ySync?.isChangeOrigin;
285
+ }
286
+ var carries = (node) => !!node.type.spec.attrs && "suggestion" in node.type.spec.attrs;
287
+ function nodeValue(change, id, author, time, depth = 1) {
288
+ return {
289
+ id,
290
+ author: author.id,
291
+ name: author.name,
292
+ time,
293
+ change,
294
+ ...depth > 1 ? { depth } : {}
295
+ };
296
+ }
297
+ function around(doc, pos, authorId) {
298
+ const $pos = doc.resolve(pos);
299
+ const result = { own: false, deleted: false };
300
+ for (let depth = $pos.depth; depth > 0; depth--) {
301
+ const s = blockSuggestion($pos.node(depth).attrs.suggestion);
302
+ if (s?.change === "insert" && s.author === authorId) result.own = true;
303
+ if (s?.change === "delete") result.deleted = true;
304
+ }
305
+ return result;
306
+ }
307
+ function hasInline(fragment) {
308
+ let found = false;
309
+ fragment.descendants((node) => {
310
+ if (node.isInline) found = true;
311
+ return !found;
312
+ });
313
+ return found;
314
+ }
315
+ function markup(node) {
316
+ const attrs = {};
317
+ for (const [key, value] of Object.entries(node.attrs)) {
318
+ if (key === "suggestion") continue;
319
+ if (value === null || ["string", "number", "boolean"].includes(typeof value))
320
+ attrs[key] = value;
321
+ }
322
+ return { type: node.type.name, attrs };
323
+ }
324
+ function attrValue(schema, block, key) {
325
+ return block.attrs[key] ?? schema.nodes[block.type]?.spec.attrs?.[key]?.default ?? null;
326
+ }
327
+ function differ(schema, a, b) {
328
+ return [.../* @__PURE__ */ new Set([...Object.keys(a.attrs), ...Object.keys(b.attrs)])].filter(
329
+ (key) => attrValue(schema, a, key) !== attrValue(schema, b, key)
330
+ );
331
+ }
332
+ function markupChange(step, doc) {
333
+ if (step instanceof AttrStep) return doc.nodeAt(step.pos) ? step.pos : null;
334
+ if (step instanceof ReplaceAroundStep) {
335
+ const old = doc.nodeAt(step.from);
336
+ const next = step.slice.content.firstChild;
337
+ const markupOnly = !!old && !!next && !next.isLeaf && step.slice.content.childCount === 1 && step.slice.openStart === 0 && step.slice.openEnd === 0 && step.insert === 1 && step.to === step.from + old.nodeSize && step.gapFrom === step.from + 1 && step.gapTo === step.to - 1 && next.content.size === 0;
338
+ return markupOnly ? step.from : null;
339
+ }
340
+ if (step instanceof ReplaceStep) {
341
+ const { from, to, slice } = step;
342
+ const old = doc.nodeAt(from);
343
+ const next = slice.content.firstChild;
344
+ return old?.isLeaf && !old.isText && next?.isLeaf && old.type === next.type && to === from + old.nodeSize && slice.content.childCount === 1 && slice.openStart === 0 && slice.openEnd === 0 && sameMarks(old.marks, next.marks) && !old.eq(next) ? from : null;
345
+ }
346
+ return null;
347
+ }
348
+ var LAYOUT = /* @__PURE__ */ new Set(["colwidth"]);
349
+ function suggestMarkup(out, pos, next, author, id, time) {
350
+ const old = out.doc.nodeAt(pos);
351
+ if (!old || !carries(old) || !carries(next)) return false;
352
+ const schema = out.doc.type.schema;
353
+ const apply = (value) => out.setNodeMarkup(pos, next.type, { ...next.attrs, suggestion: value }, next.marks);
354
+ const existing = blockSuggestion(old.attrs.suggestion);
355
+ const was = markup(old);
356
+ const now = markup(next);
357
+ const own = old.marks.some((m) => m.type.name === "suggestion_insert" && m.attrs.author === author.id) || (existing?.change === "insert" || existing?.change === "split") && existing.author === author.id || around(out.doc, pos, author.id).own;
358
+ if (own || was.type === now.type && differ(schema, was, now).every((k) => LAYOUT.has(k))) {
359
+ apply(old.attrs.suggestion);
360
+ return true;
361
+ }
362
+ if (existing && existing.change !== "block") return false;
363
+ const before = existing?.before ?? was;
364
+ const same = before.type === now.type && differ(schema, before, now).length === 0;
365
+ apply(
366
+ same ? null : {
367
+ id: existing?.id ?? id(),
368
+ author: author.id,
369
+ name: author.name,
370
+ time,
371
+ change: "block",
372
+ before
373
+ }
374
+ );
375
+ return true;
376
+ }
377
+ function liftOnce(tr, pos) {
378
+ const node = tr.doc.nodeAt(pos);
379
+ if (!node || node.isLeaf) return null;
380
+ const start = tr.steps.length;
381
+ const item = tr.doc.type.schema.nodes.list_item;
382
+ if (node.type === item && item) {
383
+ const state = EditorState.create({
384
+ doc: tr.doc,
385
+ selection: TextSelection.near(tr.doc.resolve(pos + 1))
386
+ });
387
+ let lifted = false;
388
+ liftListItem(item)(state, (done) => {
389
+ for (const step of done.steps) tr.step(step);
390
+ lifted = true;
391
+ });
392
+ if (!lifted) return null;
393
+ } else {
394
+ const range = tr.doc.resolve(pos + 1).blockRange(tr.doc.resolve(pos + node.nodeSize - 1));
395
+ const target = range && liftTarget(range);
396
+ if (target === null || target === void 0) return null;
397
+ tr.lift(range, target);
398
+ }
399
+ return tr.mapping.slice(start).map(pos + 1, 1);
400
+ }
401
+ function wrapperAt(doc, contentStart) {
402
+ const $pos = doc.resolve(contentStart);
403
+ return $pos.depth > 0 && contentStart === $pos.start() ? $pos.before() : null;
404
+ }
405
+ function liftEach(tr, positions) {
406
+ return [...positions].sort((a, b) => b - a).every((pos) => liftOnce(tr, pos) !== null);
407
+ }
408
+ function suggestStructure(out, start, before, state, author, id, time) {
409
+ const found = trackers?.structure(before, out.doc);
410
+ if (!found?.nodes.length) return null;
411
+ const ownBy = (s, ...changes) => !!s && s.author === author.id && changes.includes(s.change);
412
+ if (found.change === "wrap") {
413
+ const check2 = new Transform(out.doc);
414
+ if (!liftEach(check2, found.nodes) || !check2.doc.eq(before)) return null;
415
+ for (const pos of found.nodes) {
416
+ const s = blockSuggestion(out.doc.nodeAt(pos).attrs.suggestion);
417
+ if (ownBy(s, "insert")) continue;
418
+ if (s && !ownBy(s, "wrap")) return null;
419
+ out.setNodeAttribute(
420
+ pos,
421
+ "suggestion",
422
+ nodeValue("wrap", s?.id ?? id(), author, time, (s?.depth ?? 0) + 1)
423
+ );
424
+ }
425
+ return out;
426
+ }
427
+ const check = new Transform(before);
428
+ if (!liftEach(check, found.nodes) || !check.doc.eq(out.doc)) return null;
429
+ const nodes = found.nodes.map((pos) => ({ pos, node: before.nodeAt(pos) }));
430
+ const ownNew = ({ node }) => {
431
+ const block = node.childCount === 1 ? node.firstChild : null;
432
+ const s = blockSuggestion(node.attrs.suggestion) ?? blockSuggestion(block?.attrs.suggestion);
433
+ let ownText = true;
434
+ block?.descendants((child) => {
435
+ if (child.isInline && !child.marks.some(
436
+ (m) => m.type.name === "suggestion_insert" && m.attrs.author === author.id
437
+ ))
438
+ ownText = false;
439
+ return ownText;
440
+ });
441
+ return !!block?.isTextblock && ownBy(s, "split", "insert") && ownText;
442
+ };
443
+ const ownLevel = ({ node }) => ownBy(blockSuggestion(node.attrs.suggestion), "wrap");
444
+ if (nodes.every((n) => ownNew(n) || ownLevel(n))) {
445
+ const map = out.mapping.slice(start);
446
+ for (const n of nodes) {
447
+ const contentStart = map.map(n.pos + 1, 1);
448
+ const wrapper = wrapperAt(out.doc, contentStart);
449
+ const moved = wrapper === null ? null : out.doc.nodeAt(wrapper);
450
+ if (ownLevel(n)) {
451
+ const s2 = blockSuggestion(n.node.attrs.suggestion);
452
+ if (moved?.type === n.node.type)
453
+ out.setNodeAttribute(
454
+ wrapper,
455
+ "suggestion",
456
+ (s2.depth ?? 1) > 1 ? nodeValue("wrap", s2.id, author, s2.time, s2.depth - 1) : null
457
+ );
458
+ continue;
459
+ }
460
+ const block = out.doc.nodeAt(contentStart);
461
+ const s = blockSuggestion(n.node.attrs.suggestion) ?? blockSuggestion(n.node.firstChild.attrs.suggestion);
462
+ if (block?.isTextblock && moved?.type.name !== "list_item")
463
+ out.setNodeAttribute(contentStart, "suggestion", nodeValue("insert", s.id, author, s.time));
464
+ }
465
+ return out;
466
+ }
467
+ const kept = state.tr;
468
+ for (const step of out.steps.slice(0, start)) kept.step(step);
469
+ if (!kept.doc.eq(before)) return null;
470
+ for (const { pos, node } of nodes) {
471
+ const s = blockSuggestion(node.attrs.suggestion);
472
+ if (s && !ownBy(s, "unwrap")) return null;
473
+ kept.setNodeAttribute(
474
+ pos,
475
+ "suggestion",
476
+ nodeValue("unwrap", s?.id ?? id(), author, time, (s?.depth ?? 0) + 1)
477
+ );
478
+ }
479
+ return kept;
480
+ }
481
+ function suggestFormat(out, from, to, op, mark, author, time) {
482
+ const types = typesOf(out.doc.type.schema);
483
+ const apply = (start, end) => op === "add" ? out.addMark(start, end, mark) : out.removeMark(start, end, mark);
484
+ if (NOT_FORMATTING.has(mark.type.name) || !types.format) {
485
+ apply(from, to);
486
+ return;
487
+ }
488
+ const pieces = [];
489
+ out.doc.nodesBetween(from, to, (node, pos, parent) => {
490
+ if (!node.isInline) return true;
491
+ const start = Math.max(pos, from);
492
+ const end = Math.min(pos + node.nodeSize, to);
493
+ if (start < end && parent?.type.allowsMarkType(mark.type))
494
+ pieces.push({ from: start, to: end, node });
495
+ return false;
496
+ });
497
+ let id = null;
498
+ for (const { from: start, to: end, node } of pieces) {
499
+ const after = op === "add" ? mark.addToSet(node.marks) : mark.removeFromSet(node.marks);
500
+ if (sameMarks(after, node.marks)) continue;
501
+ apply(start, end);
502
+ const own = node.marks.some((m) => m.type === types.insert && m.attrs.author === author.id);
503
+ if (own || types.delete.isInSet(node.marks)) continue;
504
+ const suggested = node.marks.find((m) => m.type === types.format);
505
+ if (suggested) {
506
+ const before2 = formatMarks(out.doc.type.schema, suggested.attrs.before);
507
+ if (sameMarks(formatting(after), before2)) out.removeMark(start, end, suggested);
508
+ continue;
509
+ }
510
+ id ??= newId();
511
+ const before = cleanFormat(formatting(node.marks).map((m) => m.toJSON()));
512
+ out.addMark(
513
+ start,
514
+ end,
515
+ types.format.create({ id, author: author.id, name: author.name, time, before })
516
+ );
517
+ }
518
+ }
519
+ function neighbourMark(doc, pos, type, authorId) {
520
+ const $pos = doc.resolve(pos);
521
+ for (const node of [$pos.nodeBefore, $pos.nodeAfter]) {
522
+ const mark = node?.marks.find((m) => m.type === type && m.attrs.author === authorId);
523
+ if (mark) return mark;
524
+ }
525
+ return null;
526
+ }
527
+ function withInsert(fragment, mark, parent, openStart, openEnd, value) {
528
+ const nodes = [];
529
+ fragment.forEach((node, _offset, index) => {
530
+ if (node.isInline) {
531
+ nodes.push(
532
+ parent && !parent.allowsMarkType(mark.type) ? node : node.mark(mark.addToSet(node.marks))
533
+ );
534
+ return;
535
+ }
536
+ const openLeft = index === 0 && openStart > 0;
537
+ const openRight = index === fragment.childCount - 1 && openEnd > 0;
538
+ if (!openLeft && !openRight && carries(node)) {
539
+ nodes.push(
540
+ node.type.create({ ...node.attrs, suggestion: value() }, node.content, node.marks)
541
+ );
542
+ return;
543
+ }
544
+ nodes.push(
545
+ node.copy(
546
+ withInsert(
547
+ node.content,
548
+ mark,
549
+ node.type,
550
+ openLeft ? openStart - 1 : 0,
551
+ openRight ? openEnd - 1 : 0,
552
+ value
553
+ )
554
+ )
555
+ );
556
+ });
557
+ return Fragment.from(nodes);
558
+ }
559
+ function insertAt(out, at, slice) {
560
+ if (out.maybeStep(new ReplaceStep(at, at, slice)).failed) out.replace(at, at, slice);
561
+ }
562
+ function mapSelection(selection, doc, map) {
563
+ if (selection instanceof NodeSelection) {
564
+ const pos = map(selection.from);
565
+ const node = doc.nodeAt(pos);
566
+ if (node && NodeSelection.isSelectable(node)) return NodeSelection.create(doc, pos);
567
+ }
568
+ return TextSelection.between(
569
+ doc.resolve(map(selection.anchor)),
570
+ doc.resolve(map(selection.head))
571
+ );
572
+ }
573
+ function suggestTransaction(tr, state, author, onRefuse) {
574
+ if (!isUserEdit(tr)) return tr;
575
+ const refuse = () => {
576
+ onRefuse?.();
577
+ return state.tr;
578
+ };
579
+ const breaks = trackers?.breaks(tr, state, author);
580
+ if (breaks) return breaks;
581
+ const types = typesOf(state.schema);
582
+ let out = state.tr;
583
+ const time = Date.now();
584
+ let nodeId = null;
585
+ const idFor = () => nodeId ??= newId();
586
+ let toOut = (pos) => pos;
587
+ let forwardDeleteEnd = null;
588
+ let afterDeleted = null;
589
+ let inserted = null;
590
+ let movesPositions = false;
591
+ let keptDeletion = false;
592
+ let markupChanged = false;
593
+ let structureStart = null;
594
+ let structureBefore = null;
595
+ for (let i = 0; i < tr.steps.length; i++) {
596
+ const rawStep = tr.steps[i];
597
+ const doc = tr.docs[i];
598
+ if (rawStep instanceof AddMarkStep || rawStep instanceof RemoveMarkStep) {
599
+ if (structureStart !== null) return refuse();
600
+ const op = rawStep instanceof AddMarkStep ? "add" : "remove";
601
+ suggestFormat(out, toOut(rawStep.from), toOut(rawStep.to), op, rawStep.mark, author, time);
602
+ continue;
603
+ }
604
+ const markupAt = markupChange(rawStep, doc);
605
+ if (markupAt !== null) {
606
+ if (structureStart !== null || keptDeletion) return refuse();
607
+ markupChanged = true;
608
+ const next = (tr.docs[i + 1] ?? tr.doc).nodeAt(markupAt);
609
+ if (!next || !suggestMarkup(out, toOut(markupAt), next, author, idFor, time)) return refuse();
610
+ continue;
611
+ }
612
+ if (rawStep instanceof ReplaceAroundStep || structureStart !== null) {
613
+ const touchesText = rawStep instanceof ReplaceStep && (hasInline(doc.slice(rawStep.from, rawStep.to).content) || hasInline(rawStep.slice.content));
614
+ if (!trackers || touchesText || !(rawStep instanceof ReplaceAroundStep || rawStep instanceof ReplaceStep))
615
+ return refuse();
616
+ if (structureStart === null) {
617
+ if (!out.doc.eq(doc)) return refuse();
618
+ structureStart = out.steps.length;
619
+ structureBefore = out.doc;
620
+ }
621
+ if (out.maybeStep(rawStep).failed) return refuse();
622
+ continue;
623
+ }
624
+ if (!(rawStep instanceof ReplaceStep)) return refuse();
625
+ movesPositions = true;
626
+ const step = rawStep;
627
+ const outStart = out.steps.length;
628
+ const prev = toOut;
629
+ let from = prev(step.from);
630
+ let to = Math.max(from, prev(step.to));
631
+ let keptWhole = false;
632
+ if (to > from) {
633
+ const own = [];
634
+ const plain = [];
635
+ const whole = [];
636
+ out.doc.nodesBetween(from, to, (node, pos) => {
637
+ const start = Math.max(pos, from);
638
+ const end = Math.min(pos + node.nodeSize, to);
639
+ if (start >= end) return false;
640
+ if (!node.isInline) {
641
+ if (pos < from || pos + node.nodeSize > to) return true;
642
+ const s = blockSuggestion(node.attrs.suggestion);
643
+ if (s?.change === "insert" && s.author === author.id) {
644
+ own.push({ from: pos, to: pos + node.nodeSize });
645
+ return false;
646
+ }
647
+ if (s?.change === "delete") return false;
648
+ if (!carries(node) || s) return true;
649
+ whole.push(pos);
650
+ return false;
651
+ }
652
+ const here = around(out.doc, pos, author.id);
653
+ if (here.deleted) return false;
654
+ const mine = here.own || node.marks.some((m) => m.type === types.insert && m.attrs.author === author.id);
655
+ if (mine) own.push({ from: start, to: end });
656
+ else if (!types.delete.isInSet(node.marks)) plain.push({ from: start, to: end });
657
+ return false;
658
+ });
659
+ let deleteId = null;
660
+ if (plain.length) {
661
+ const first = plain[0];
662
+ const mark = neighbourMark(out.doc, first.from, types.delete, author.id) ?? neighbourMark(out.doc, plain[plain.length - 1].to, types.delete, author.id) ?? types.delete.create({ id: newId(), author: author.id, name: author.name, time });
663
+ for (const range of plain) out.addMark(range.from, range.to, mark);
664
+ deleteId = mark.attrs.id;
665
+ }
666
+ for (const pos of whole) {
667
+ out.setNodeAttribute(
668
+ pos,
669
+ "suggestion",
670
+ nodeValue("delete", deleteId ?? idFor(), author, time)
671
+ );
672
+ }
673
+ const $start = out.doc.resolve(from);
674
+ const $end = out.doc.resolve(to);
675
+ const last = $end.parent;
676
+ if ($start.parent !== last && $start.parent.isTextblock && last.isTextblock && $start.depth === $end.depth && $end.start() > from && carries(last) && !last.attrs.suggestion && !whole.includes($end.before())) {
677
+ out.setNodeAttribute($end.before(), "suggestion", {
678
+ id: deleteId ?? idFor(),
679
+ author: author.id,
680
+ name: author.name,
681
+ time,
682
+ change: "join",
683
+ depth: $end.depth - $start.sharedDepth(to)
684
+ });
685
+ }
686
+ if (plain.length || whole.length) {
687
+ keptDeletion = true;
688
+ if (markupChanged) return refuse();
689
+ }
690
+ keptWhole = whole.length > 0;
691
+ for (const range of own.sort((a, b) => b.from - a.from)) out.delete(range.from, range.to);
692
+ const map = out.mapping.slice(outStart);
693
+ from = map.map(from, 1);
694
+ to = map.map(to, -1);
695
+ const sel = state.selection;
696
+ if (tr.steps.length === 1 && step.slice.size === 0) {
697
+ if (sel.empty && sel.from === step.from && tr.selection.head === step.from) {
698
+ forwardDeleteEnd = to;
699
+ }
700
+ if (sel instanceof NodeSelection && whole.includes(prev(sel.from))) {
701
+ afterDeleted = map.map(prev(sel.to), 1);
702
+ }
703
+ }
704
+ }
705
+ const filler = keptWhole && step.slice.content.childCount === 1 && !step.slice.openStart && !!step.slice.content.firstChild.isTextblock && !step.slice.content.firstChild.content.size;
706
+ if (step.slice.size > 0 && !filler) {
707
+ let at = to;
708
+ if (around(out.doc, at, author.id).own) {
709
+ const $in = out.doc.resolve(at);
710
+ const ownBlock = $in.parent.isTextblock ? blockSuggestion($in.parent.attrs.suggestion) : null;
711
+ insertAt(out, at, step.slice);
712
+ if (ownBlock?.change === "insert" && step.slice.openEnd > 0) {
713
+ const $end = out.doc.resolve(at + step.slice.size);
714
+ if ($end.parent.isTextblock && !$end.parent.attrs.suggestion)
715
+ out.setNodeAttribute($end.before(), "suggestion", ownBlock);
716
+ }
717
+ if (tr.steps.length === 1) inserted = { at, from: step.from, size: step.slice.size };
718
+ const inverse2 = step.getMap().invert();
719
+ const outMap2 = out.mapping.slice(outStart);
720
+ toOut = (pos) => outMap2.map(prev(inverse2.map(pos, -1)), 1);
721
+ continue;
722
+ }
723
+ if (!step.slice.openStart) {
724
+ for (let next = out.doc.resolve(at).nodeAfter; next && types.delete.isInSet(next.marks); ) {
725
+ at += next.nodeSize;
726
+ next = out.doc.resolve(at).nodeAfter;
727
+ }
728
+ }
729
+ const mark = neighbourMark(out.doc, at, types.insert, author.id) ?? types.insert.create({ id: newId(), author: author.id, name: author.name, time });
730
+ const $at = out.doc.resolve(at);
731
+ const nodeSuggestion = () => nodeValue(
732
+ "insert",
733
+ hasInline(step.slice.content) ? mark.attrs.id : idFor(),
734
+ author,
735
+ time
736
+ );
737
+ const content = withInsert(
738
+ step.slice.content,
739
+ mark,
740
+ step.slice.openStart ? null : $at.parent.type,
741
+ step.slice.openStart,
742
+ step.slice.openEnd,
743
+ nodeSuggestion
744
+ );
745
+ insertAt(out, at, new Slice(content, step.slice.openStart, step.slice.openEnd));
746
+ if (tr.steps.length === 1) inserted = { at, from: step.from, size: step.slice.size };
747
+ const { openStart, openEnd } = step.slice;
748
+ if (openStart > 0 && openStart === openEnd && $at.parent.isTextblock) {
749
+ const $end = out.doc.resolve(at + step.slice.size);
750
+ const outer = $end.depth >= openEnd ? $end.before($end.depth - openEnd + 1) : -1;
751
+ const atEnd = $at.parentOffset === $at.parent.content.size && outer >= 0 && outer + out.doc.nodeAt(outer).nodeSize === at + step.slice.size + openEnd;
752
+ const target = atEnd ? outer : $end.depth > 0 ? $end.before() : -1;
753
+ const node = target >= 0 ? out.doc.nodeAt(target) : null;
754
+ if ($end.parent.isTextblock && node && carries(node)) {
755
+ out.setNodeAttribute(
756
+ target,
757
+ "suggestion",
758
+ atEnd ? nodeValue("insert", mark.attrs.id, author, time) : {
759
+ id: mark.attrs.id,
760
+ author: author.id,
761
+ name: author.name,
762
+ time,
763
+ change: "split",
764
+ depth: openEnd
765
+ }
766
+ );
767
+ }
768
+ }
769
+ }
770
+ const inverse = step.getMap().invert();
771
+ const outMap = out.mapping.slice(outStart);
772
+ toOut = (pos) => outMap.map(prev(inverse.map(pos, -1)), 1);
773
+ }
774
+ if (structureStart !== null) {
775
+ const done = suggestStructure(
776
+ out,
777
+ structureStart,
778
+ structureBefore,
779
+ state,
780
+ author,
781
+ idFor,
782
+ time
783
+ );
784
+ if (!done) return refuse();
785
+ if (done === out) {
786
+ out.setSelection(tr.selection.map(out.doc, out.mapping.slice(out.steps.length)));
787
+ } else {
788
+ out = done;
789
+ out.setSelection(state.selection.map(out.doc, out.mapping));
790
+ }
791
+ } else if (!movesPositions) {
792
+ out.setSelection(tr.selection.map(out.doc, out.mapping.slice(out.steps.length)));
793
+ } else if (forwardDeleteEnd !== null) {
794
+ out.setSelection(TextSelection.create(out.doc, forwardDeleteEnd));
795
+ } else if (afterDeleted !== null) {
796
+ out.setSelection(Selection.near(out.doc.resolve(afterDeleted), 1));
797
+ } else if (inserted) {
798
+ const { at, from, size } = inserted;
799
+ const { anchor, head, empty } = tr.selection;
800
+ const inside = (pos) => pos >= from && pos <= from + size;
801
+ if (empty && head === from + size) {
802
+ out.setSelection(TextSelection.create(out.doc, at + size));
803
+ } else if (inside(anchor) && inside(head)) {
804
+ out.setSelection(mapSelection(tr.selection, out.doc, (pos) => pos - from + at));
805
+ } else if (empty) {
806
+ const $end = out.doc.resolve(at + size);
807
+ out.setSelection(TextSelection.between($end, $end));
808
+ } else out.setSelection(mapSelection(tr.selection, out.doc, toOut));
809
+ } else {
810
+ out.setSelection(mapSelection(tr.selection, out.doc, toOut));
811
+ }
812
+ for (const key of ["addToHistory", "uiEvent", "paste", "scrollIntoView"]) {
813
+ const value = tr.getMeta(key);
814
+ if (value !== void 0) out.setMeta(key, value);
815
+ }
816
+ if (tr.scrolledIntoView) out.scrollIntoView();
817
+ return out;
818
+ }
819
+ function formatChange(node, mark) {
820
+ const before = formatMarks(node.type.schema, mark.attrs.before);
821
+ const now = formatting(node.marks);
822
+ const added = now.filter((m) => !m.isInSet(before)).map((m) => m.type.name);
823
+ const removed = before.filter((m) => !m.isInSet(now) && !added.includes(m.type.name)).map((m) => m.type.name);
824
+ return { added, removed };
825
+ }
826
+ var addAll = (list, more) => {
827
+ for (const name of more) if (!list.includes(name)) list.push(name);
828
+ };
829
+ function listSuggestions(doc) {
830
+ const types = typesOf(doc.type.schema);
831
+ const result = [];
832
+ doc.descendants((node, pos) => {
833
+ if (!node.isText) {
834
+ const block = blockSuggestion(node.attrs.suggestion);
835
+ if (block) {
836
+ result.push({
837
+ id: block.id,
838
+ kind: block.change,
839
+ author: { id: block.author, name: block.name },
840
+ time: block.time,
841
+ from: pos,
842
+ to: pos + node.nodeSize,
843
+ text: node.isLeaf ? node.type.spec.leafText?.(node) ?? "" : node.textContent,
844
+ node: node.type.name,
845
+ ...block.before ? { before: block.before } : {},
846
+ ...block.depth ? { depth: block.depth } : {}
847
+ });
848
+ }
849
+ if (!node.isInline) return true;
850
+ }
851
+ for (const mark of node.marks) {
852
+ const kind = mark.type === types.insert ? "insert" : mark.type === types.delete ? "delete" : mark.type === types.format ? "format" : null;
853
+ if (!kind) continue;
854
+ const last = result[result.length - 1];
855
+ const text = node.isText ? node.text : node.type.spec.leafText?.(node) ?? "";
856
+ const change = kind === "format" ? formatChange(node, mark) : null;
857
+ if (last && last.id === mark.attrs.id && last.kind === kind && last.to === pos) {
858
+ last.to = pos + node.nodeSize;
859
+ last.text += text;
860
+ if (change) {
861
+ addAll(last.added, change.added);
862
+ addAll(last.removed, change.removed);
863
+ }
864
+ } else {
865
+ result.push({
866
+ id: mark.attrs.id,
867
+ kind,
868
+ author: { id: mark.attrs.author, name: mark.attrs.name },
869
+ time: Number(mark.attrs.time) || 0,
870
+ from: pos,
871
+ to: pos + node.nodeSize,
872
+ text,
873
+ ...change ?? {}
874
+ });
875
+ }
876
+ }
877
+ return false;
878
+ });
879
+ return result;
880
+ }
881
+ function resolveFormat(tr, s, action) {
882
+ const type = typesOf(tr.doc.type.schema).format;
883
+ const pieces = [];
884
+ tr.doc.nodesBetween(s.from, s.to, (node, pos) => {
885
+ if (!node.isInline) return true;
886
+ const mark = node.marks.find((m) => m.type === type && m.attrs.id === s.id);
887
+ if (mark) {
888
+ pieces.push({
889
+ from: Math.max(pos, s.from),
890
+ to: Math.min(pos + node.nodeSize, s.to),
891
+ node,
892
+ mark
893
+ });
894
+ }
895
+ return false;
896
+ });
897
+ for (const { from, to, node, mark } of pieces) {
898
+ if (action === "reject") {
899
+ const before = formatMarks(tr.doc.type.schema, mark.attrs.before);
900
+ for (const m of formatting(node.marks)) if (!m.isInSet(before)) tr.removeMark(from, to, m);
901
+ for (const m of before) if (!m.isInSet(node.marks)) tr.addMark(from, to, m);
902
+ }
903
+ tr.removeMark(from, to, mark);
904
+ }
905
+ }
906
+ function resolveBlock(tr, s, action) {
907
+ const pos = s.from;
908
+ const node = tr.doc.nodeAt(pos);
909
+ if (!node) return;
910
+ const type = action === "reject" ? tr.doc.type.schema.nodes[s.before.type] : void 0;
911
+ const $pos = tr.doc.resolve(pos);
912
+ if (type?.spec.attrs && "suggestion" in type.spec.attrs && $pos.parent.canReplaceWith($pos.index(), $pos.index() + 1, type) && (node.isLeaf ? type.isLeaf : !type.isLeaf && type.validContent(node.content))) {
913
+ const attrs = Object.fromEntries(
914
+ Object.entries(s.before.attrs).filter(([key]) => key in type.spec.attrs)
915
+ );
916
+ try {
917
+ tr.setNodeMarkup(pos, type, { ...node.attrs, ...attrs, suggestion: null }, node.marks);
918
+ return;
919
+ } catch {
920
+ }
921
+ }
922
+ tr.setNodeAttribute(pos, "suggestion", null);
923
+ }
924
+ function removeNode(tr, pos) {
925
+ const node = tr.doc.nodeAt(pos);
926
+ if (!node) return;
927
+ const $pos = tr.doc.resolve(pos);
928
+ let from = pos;
929
+ let to = pos + node.nodeSize;
930
+ for (let depth = $pos.depth; ; depth--) {
931
+ const parent = $pos.node(depth);
932
+ const index = $pos.index(depth);
933
+ if (parent.canReplace(index, index + 1)) {
934
+ tr.delete(from, to);
935
+ return;
936
+ }
937
+ if (depth === 0 || parent.childCount > 1 || parent.type.spec.isolating) {
938
+ const fill = parent.type.contentMatch.defaultType?.createAndFill();
939
+ if (fill && parent.canReplace(index, index + 1, Fragment.from(fill)))
940
+ tr.replaceWith(from, to, fill);
941
+ return;
942
+ }
943
+ from = $pos.before(depth);
944
+ to = $pos.after(depth);
945
+ }
946
+ }
947
+ function resolveSuggestions(state, action, ids) {
948
+ const types = typesOf(state.schema);
949
+ const tr = state.tr.setMeta(OWN, true);
950
+ const chosen = listSuggestions(state.doc).filter((s) => !ids || ids.includes(s.id));
951
+ tr.setMeta(RESOLVED, { action, ids: [...new Set(chosen.map((s) => s.id))] });
952
+ for (const s of chosen) if (s.kind === "format") resolveFormat(tr, s, action);
953
+ const removals = [];
954
+ const pending = [];
955
+ for (const s of chosen) {
956
+ if (!s.node) continue;
957
+ const reject = action === "reject";
958
+ const op = s.kind === "block" ? reject && "style" : s.kind === "join" ? reject ? !!s.before && "style" : "join" : s.kind === "split" ? reject && "join" : s.kind === "insert" ? reject && "remove" : s.kind === "delete" ? !reject && "remove" : s.kind === "wrap" ? reject && "lift" : !reject && "lift";
959
+ if (!op) tr.setNodeAttribute(s.from, "suggestion", null);
960
+ else if (op === "remove") removals.push(s);
961
+ else pending.push({ s, op });
962
+ }
963
+ for (const s of [...chosen].sort((a, b) => b.from - a.from)) {
964
+ if (s.kind !== "insert" && s.kind !== "delete" || s.node) continue;
965
+ if (s.kind === "insert" === (action === "reject")) tr.delete(s.from, s.to);
966
+ else tr.removeMark(s.from, s.to, s.kind === "insert" ? types.insert : types.delete);
967
+ }
968
+ const nodeNow = (s) => {
969
+ const mapped = tr.mapping.mapResult(s.from, 1);
970
+ const node = mapped.deleted ? null : tr.doc.nodeAt(mapped.pos);
971
+ return node?.type.name === s.node ? mapped.pos : null;
972
+ };
973
+ for (const s of removals.sort((a, b) => b.from - a.from)) {
974
+ const pos = nodeNow(s);
975
+ if (pos !== null) removeNode(tr, pos);
976
+ }
977
+ const apply = ({ s, op }, last) => {
978
+ const pos = nodeNow(s);
979
+ if (pos === null) return true;
980
+ if (op === "join") {
981
+ const boundary = pos - ((s.depth ?? 1) - 1);
982
+ if (!canJoin(tr.doc, boundary)) return false;
983
+ try {
984
+ tr.join(boundary, s.depth ?? 1);
985
+ } catch {
986
+ return false;
987
+ }
988
+ return true;
989
+ }
990
+ if (op === "style") {
991
+ if (!last && !restorable(tr.doc, pos, s)) return false;
992
+ resolveBlock(tr, { ...s, from: pos }, "reject");
993
+ return true;
994
+ }
995
+ if (liftOnce(new Transform(tr.doc), pos) === null) return false;
996
+ tr.setNodeAttribute(pos, "suggestion", null);
997
+ let at = pos;
998
+ for (let level = 0; level < (s.depth ?? 1) && at !== null; level++) {
999
+ const contentStart = liftOnce(tr, at);
1000
+ at = contentStart === null ? null : wrapperAt(tr.doc, contentStart);
1001
+ }
1002
+ return true;
1003
+ };
1004
+ const order = { join: 0, style: 1, lift: 2 };
1005
+ const left = pending.sort((a, b) => order[a.op] - order[b.op] || b.s.from - a.s.from);
1006
+ for (let done = 0; done >= 0; ) {
1007
+ done = left.findIndex((item) => apply(item, false));
1008
+ if (done >= 0) left.splice(done, 1);
1009
+ }
1010
+ for (const item of left) {
1011
+ if (item.op === "style") apply(item, true);
1012
+ else {
1013
+ const pos = nodeNow(item.s);
1014
+ if (pos !== null) tr.setNodeAttribute(pos, "suggestion", null);
1015
+ }
1016
+ }
1017
+ return tr;
1018
+ }
1019
+ function restorable(doc, pos, s) {
1020
+ const node = doc.nodeAt(pos);
1021
+ const type = s.before ? doc.type.schema.nodes[s.before.type] : void 0;
1022
+ if (!node || !type) return false;
1023
+ const $pos = doc.resolve(pos);
1024
+ return $pos.parent.canReplaceWith($pos.index(), $pos.index() + 1, type) && (node.isLeaf ? type.isLeaf : !type.isLeaf && type.validContent(node.content));
1025
+ }
1026
+ function suggestionsResult(editor, action) {
1027
+ return resolveSuggestions(editor.view.state, action).doc;
1028
+ }
1029
+ function withoutSuggestions(fragment) {
1030
+ const nodes = [];
1031
+ fragment.forEach((node) => {
1032
+ const marks = node.marks.filter((m) => !m.type.name.startsWith("suggestion_"));
1033
+ if (node.isText) {
1034
+ nodes.push(node.mark(marks));
1035
+ return;
1036
+ }
1037
+ const attrs = node.attrs.suggestion != null ? { ...node.attrs, suggestion: null } : node.attrs;
1038
+ nodes.push(node.type.create(attrs, withoutSuggestions(node.content), marks));
1039
+ });
1040
+ return Fragment.from(nodes);
1041
+ }
1042
+ var refusedAt = /* @__PURE__ */ new WeakMap();
1043
+ function isSuggesting(state) {
1044
+ return suggestionsKey.getState(state)?.enabled ?? false;
1045
+ }
1046
+ function setSuggesting(editor, enabled) {
1047
+ const { state, dispatch } = editor.view;
1048
+ dispatch(state.tr.setMeta(suggestionsKey, { enabled }).setMeta(OWN, true));
1049
+ editor.updateUI();
1050
+ }
1051
+ var suggestions_default = definePlugin({
1052
+ name: "suggestions",
1053
+ toolbar: "suggestions reviewsuggestions suggestionspanel",
1054
+ marks: {
1055
+ suggestion_insert: markSpec("insert"),
1056
+ suggestion_delete: markSpec("delete"),
1057
+ suggestion_format: formatSpec()
1058
+ },
1059
+ nodeAttributes: { suggestion: blockAttribute },
1060
+ prosemirrorPlugins: (editor) => {
1061
+ const options = editor.options.pluginOptions?.suggestions ?? {};
1062
+ let cache = null;
1063
+ return [
1064
+ new Plugin({
1065
+ key: suggestionsKey,
1066
+ state: {
1067
+ init: () => ({ enabled: !!(options.enabled || options.force) }),
1068
+ apply(tr, value) {
1069
+ const meta = tr.getMeta(suggestionsKey);
1070
+ if (!meta) return value;
1071
+ return { enabled: options.force ? true : meta.enabled };
1072
+ }
1073
+ },
1074
+ props: {
1075
+ attributes: (state) => suggestionsKey.getState(state)?.enabled ? { class: "nova-suggesting" } : {},
1076
+ transformPasted: (slice) => new Slice(withoutSuggestions(slice.content), slice.openStart, slice.openEnd),
1077
+ decorations(state) {
1078
+ if (cache?.doc === state.doc) return cache.set;
1079
+ const labels = pickLabels(editor, "suggestions", LABELS);
1080
+ const time = new Intl.DateTimeFormat(editor.options.language ?? "en", {
1081
+ dateStyle: "medium",
1082
+ timeStyle: "short"
1083
+ });
1084
+ const set = DecorationSet.create(
1085
+ state.doc,
1086
+ listSuggestions(state.doc).map(
1087
+ (s) => (
1088
+ // Text: on the text; a suggestion a node carries: on the node.
1089
+ (s.node ? Decoration.node : Decoration.inline)(s.from, s.to, {
1090
+ title: (s.kind === "insert" || s.kind === "split" ? labels.inserted : s.kind === "delete" || s.kind === "join" ? labels.deleted : labels.formatted).replace("{name}", s.author.name || labels.guest) + (s.time ? ` \xB7 ${time.format(s.time)}` : ""),
1091
+ // A whole node inserted or deleted: its text looks inserted or deleted, the node is outlined.
1092
+ class: s.node && (s.kind === "insert" || s.kind === "delete") ? `nova-sugg-${s.kind} nova-sugg-node` : `nova-sugg-${s.kind}`,
1093
+ style: `--nova-suggestion: ${suggestionColor(s.author.id || s.author.name)}`
1094
+ })
1095
+ )
1096
+ )
1097
+ );
1098
+ cache = { doc: state.doc, set };
1099
+ return set;
1100
+ }
1101
+ }
1102
+ }),
1103
+ keymap({
1104
+ // Ctrl/Cmd+Alt+Shift+E toggles suggesting mode.
1105
+ "Mod-Alt-Shift-e": () => {
1106
+ if (options.force) return false;
1107
+ setSuggesting(editor, !isSuggesting(editor.view.state));
1108
+ return true;
1109
+ }
1110
+ })
1111
+ ];
1112
+ },
1113
+ transformTransaction(tr, state, editor) {
1114
+ if (!isSuggesting(state)) return tr;
1115
+ const options = editor.options.pluginOptions?.suggestions ?? {};
1116
+ const labels = pickLabels(editor, "suggestions", LABELS);
1117
+ const author = {
1118
+ id: USER_ID_RE.test(options.author?.id ?? "") ? options.author.id : "guest",
1119
+ name: String(options.author?.name || labels.guest).slice(0, 80)
1120
+ };
1121
+ return suggestTransaction(tr, state, author, () => {
1122
+ const now = Date.now();
1123
+ if (now - (refusedAt.get(editor) ?? 0) < 3e3) return;
1124
+ refusedAt.set(editor, now);
1125
+ editor.ui.notify(options.force ? labels.unsupported : labels.unsupportedDirect);
1126
+ });
1127
+ },
1128
+ load: () => import("./suggestions-ui-PODMNH7D.js")
1129
+ });
1130
+
1131
+ export {
1132
+ LABELS,
1133
+ OWN,
1134
+ RESOLVED,
1135
+ suggestionColor,
1136
+ blockSuggestion,
1137
+ setStructureTrackers,
1138
+ formatMarks,
1139
+ around,
1140
+ hasInline,
1141
+ suggestTransaction,
1142
+ listSuggestions,
1143
+ resolveSuggestions,
1144
+ suggestionsResult,
1145
+ isSuggesting,
1146
+ setSuggesting,
1147
+ suggestions_default
1148
+ };
1149
+ //# sourceMappingURL=chunk-P2UU2NLT.js.map