@novaprose/core 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/README.md +15 -2
  2. package/dist/a11y.cjs +314 -0
  3. package/dist/a11y.cjs.map +1 -0
  4. package/dist/a11y.d.cts +51 -0
  5. package/dist/a11y.d.ts +51 -0
  6. package/dist/a11y.js +11 -0
  7. package/dist/a11y.js.map +1 -0
  8. package/dist/a11ychecker-6ES3UMU3.js +449 -0
  9. package/dist/a11ychecker-6ES3UMU3.js.map +1 -0
  10. package/dist/accordion-ui-B4I2FJXE.js +201 -0
  11. package/dist/accordion-ui-B4I2FJXE.js.map +1 -0
  12. package/dist/advcode-7S6N64C7.js +51 -0
  13. package/dist/advcode-7S6N64C7.js.map +1 -0
  14. package/dist/advcode-editor-ENCPFVLO.js +257 -0
  15. package/dist/advcode-editor-ENCPFVLO.js.map +1 -0
  16. package/dist/{advlist-5FNKPLUX.js → advlist-FEDGNLMQ.js} +10 -7
  17. package/dist/advlist-FEDGNLMQ.js.map +1 -0
  18. package/dist/advtable-ui-JAVJY4L4.js +364 -0
  19. package/dist/advtable-ui-JAVJY4L4.js.map +1 -0
  20. package/dist/ai-5KM776QW.js +1485 -0
  21. package/dist/ai-5KM776QW.js.map +1 -0
  22. package/dist/anchor-ui-VPKNKZ7J.js +81 -0
  23. package/dist/anchor-ui-VPKNKZ7J.js.map +1 -0
  24. package/dist/autocorrect-5QLICCRN.js +851 -0
  25. package/dist/autocorrect-5QLICCRN.js.map +1 -0
  26. package/dist/{autolink-45LTODWB.js → autolink-ZYIPRXBA.js} +11 -8
  27. package/dist/autolink-ZYIPRXBA.js.map +1 -0
  28. package/dist/{autoresize-UB3GOA6D.js → autoresize-YRZAVCNO.js} +2 -2
  29. package/dist/autoresize-YRZAVCNO.js.map +1 -0
  30. package/dist/{autosave-GMWJ5BPE.js → autosave-IC7YYG44.js} +7 -7
  31. package/dist/autosave-IC7YYG44.js.map +1 -0
  32. package/dist/casechange-R7IO2APS.js +201 -0
  33. package/dist/casechange-R7IO2APS.js.map +1 -0
  34. package/dist/{charmap-2GC7LF7G.js → charmap-CARYZFKD.js} +7 -7
  35. package/dist/charmap-CARYZFKD.js.map +1 -0
  36. package/dist/checklist-7E47QW6L.js +189 -0
  37. package/dist/checklist-7E47QW6L.js.map +1 -0
  38. package/dist/chunk-23ZLVT5D.js +163 -0
  39. package/dist/chunk-23ZLVT5D.js.map +1 -0
  40. package/dist/{chunk-ND2CWNVG.js → chunk-3BOK3S3T.js} +2 -27
  41. package/dist/chunk-3BOK3S3T.js.map +1 -0
  42. package/dist/chunk-3KBQEAX2.js +926 -0
  43. package/dist/chunk-3KBQEAX2.js.map +1 -0
  44. package/dist/chunk-3NNILZVB.js +259 -0
  45. package/dist/chunk-3NNILZVB.js.map +1 -0
  46. package/dist/{chunk-PVFKXRID.js → chunk-4VPDY3LF.js} +1 -1
  47. package/dist/chunk-4VPDY3LF.js.map +1 -0
  48. package/dist/chunk-53AY5NAF.js +214 -0
  49. package/dist/chunk-53AY5NAF.js.map +1 -0
  50. package/dist/{chunk-5AW2HHG6.js → chunk-5KERLFDD.js} +50 -3
  51. package/dist/chunk-5KERLFDD.js.map +1 -0
  52. package/dist/{chunk-FCMZ7TUQ.js → chunk-6BJEOL5V.js} +296 -43
  53. package/dist/chunk-6BJEOL5V.js.map +1 -0
  54. package/dist/chunk-6LQM7G4V.js +159 -0
  55. package/dist/chunk-6LQM7G4V.js.map +1 -0
  56. package/dist/chunk-AB67XUSR.js +178 -0
  57. package/dist/chunk-AB67XUSR.js.map +1 -0
  58. package/dist/chunk-ANE5ASXG.js +26 -0
  59. package/dist/chunk-ANE5ASXG.js.map +1 -0
  60. package/dist/{chunk-Z3ELZ77W.js → chunk-AP2PJFLB.js} +5 -2
  61. package/dist/chunk-AP2PJFLB.js.map +1 -0
  62. package/dist/chunk-ARBKIZZU.js +137 -0
  63. package/dist/chunk-ARBKIZZU.js.map +1 -0
  64. package/dist/chunk-AUQSATWL.js +322 -0
  65. package/dist/chunk-AUQSATWL.js.map +1 -0
  66. package/dist/chunk-BMCH63QN.js +165 -0
  67. package/dist/chunk-BMCH63QN.js.map +1 -0
  68. package/dist/chunk-BUABAYZL.js +160 -0
  69. package/dist/chunk-BUABAYZL.js.map +1 -0
  70. package/dist/chunk-DCMPJ25E.js +140 -0
  71. package/dist/chunk-DCMPJ25E.js.map +1 -0
  72. package/dist/chunk-DV7TGRU6.js +47 -0
  73. package/dist/chunk-DV7TGRU6.js.map +1 -0
  74. package/dist/chunk-F2WT77ZG.js +163 -0
  75. package/dist/chunk-F2WT77ZG.js.map +1 -0
  76. package/dist/chunk-FNJ7AEJK.js +955 -0
  77. package/dist/chunk-FNJ7AEJK.js.map +1 -0
  78. package/dist/chunk-G74HNSB6.js +9 -0
  79. package/dist/chunk-G74HNSB6.js.map +1 -0
  80. package/dist/chunk-GTLE2HEW.js +108 -0
  81. package/dist/chunk-GTLE2HEW.js.map +1 -0
  82. package/dist/chunk-GUZCRDK6.js +143 -0
  83. package/dist/chunk-GUZCRDK6.js.map +1 -0
  84. package/dist/chunk-HNEAVVBC.js +98 -0
  85. package/dist/chunk-HNEAVVBC.js.map +1 -0
  86. package/dist/chunk-HSVNJGK3.js +1149 -0
  87. package/dist/chunk-HSVNJGK3.js.map +1 -0
  88. package/dist/chunk-IFSD6O5M.js +29 -0
  89. package/dist/chunk-IFSD6O5M.js.map +1 -0
  90. package/dist/{table-SSNABG5W.js → chunk-IO5PU52K.js} +119 -61
  91. package/dist/chunk-IO5PU52K.js.map +1 -0
  92. package/dist/chunk-K4LFGNS7.js +137 -0
  93. package/dist/chunk-K4LFGNS7.js.map +1 -0
  94. package/dist/chunk-KGEHUWGL.js +79 -0
  95. package/dist/chunk-KGEHUWGL.js.map +1 -0
  96. package/dist/chunk-KW6ATQPN.js +151 -0
  97. package/dist/chunk-KW6ATQPN.js.map +1 -0
  98. package/dist/chunk-NX3KWIP5.js +207 -0
  99. package/dist/chunk-NX3KWIP5.js.map +1 -0
  100. package/dist/chunk-OOVNE6MB.js +28 -0
  101. package/dist/chunk-OOVNE6MB.js.map +1 -0
  102. package/dist/chunk-OQMMHWMZ.js +7 -0
  103. package/dist/chunk-OQMMHWMZ.js.map +1 -0
  104. package/dist/{chunk-JPJVTB45.js → chunk-QU3KXMYT.js} +8 -2
  105. package/dist/chunk-QU3KXMYT.js.map +1 -0
  106. package/dist/chunk-QWT56RVG.js +158 -0
  107. package/dist/chunk-QWT56RVG.js.map +1 -0
  108. package/dist/chunk-RJ7T56OH.js +3787 -0
  109. package/dist/chunk-RJ7T56OH.js.map +1 -0
  110. package/dist/{chunk-KWXFL4WS.js → chunk-RPHA4HRX.js} +8 -5
  111. package/dist/chunk-RPHA4HRX.js.map +1 -0
  112. package/dist/chunk-S4DCQA74.js +66 -0
  113. package/dist/chunk-S4DCQA74.js.map +1 -0
  114. package/dist/chunk-SCIRO4XK.js +144 -0
  115. package/dist/chunk-SCIRO4XK.js.map +1 -0
  116. package/dist/chunk-SNVYHGGO.js +127 -0
  117. package/dist/chunk-SNVYHGGO.js.map +1 -0
  118. package/dist/chunk-T4543CB2.js +67 -0
  119. package/dist/chunk-T4543CB2.js.map +1 -0
  120. package/dist/{chunk-T3GY6IVK.js → chunk-UHUOAQA6.js} +71 -9
  121. package/dist/chunk-UHUOAQA6.js.map +1 -0
  122. package/dist/chunk-UTMS2P2K.js +288 -0
  123. package/dist/chunk-UTMS2P2K.js.map +1 -0
  124. package/dist/{chunk-HPLT3XRZ.js → chunk-V7WUHUHM.js} +13 -1
  125. package/dist/chunk-V7WUHUHM.js.map +1 -0
  126. package/dist/chunk-WAOU5NGN.js +430 -0
  127. package/dist/chunk-WAOU5NGN.js.map +1 -0
  128. package/dist/{chunk-R2UMUCVI.js → chunk-XCXJD5DO.js} +53 -8
  129. package/dist/chunk-XCXJD5DO.js.map +1 -0
  130. package/dist/chunk-XIH4SCO6.js +112 -0
  131. package/dist/chunk-XIH4SCO6.js.map +1 -0
  132. package/dist/chunk-XR7CY4NI.js +11 -0
  133. package/dist/chunk-XR7CY4NI.js.map +1 -0
  134. package/dist/chunk-Y2OXWCM7.js +263 -0
  135. package/dist/chunk-Y2OXWCM7.js.map +1 -0
  136. package/dist/chunk-YDF55N6Z.js +164 -0
  137. package/dist/chunk-YDF55N6Z.js.map +1 -0
  138. package/dist/chunk-YOTA26H7.js +373 -0
  139. package/dist/chunk-YOTA26H7.js.map +1 -0
  140. package/dist/chunk-YP7N47QR.js +101 -0
  141. package/dist/chunk-YP7N47QR.js.map +1 -0
  142. package/dist/{chunk-KPE3QRPB.js → chunk-YYCDRUE2.js} +16 -315
  143. package/dist/chunk-YYCDRUE2.js.map +1 -0
  144. package/dist/codesample-FOWXMCTC.js +546 -0
  145. package/dist/codesample-FOWXMCTC.js.map +1 -0
  146. package/dist/{comments-panel-HXMWSRAW.js → comments-panel-SOLBZ46Q.js} +9 -5
  147. package/dist/comments-panel-SOLBZ46Q.js.map +1 -0
  148. package/dist/{directionality-5JLWQGP2.js → directionality-BXWXNPRZ.js} +13 -10
  149. package/dist/directionality-BXWXNPRZ.js.map +1 -0
  150. package/dist/document-B0hLRhuH.d.cts +39 -0
  151. package/dist/document-Dh-jz1SK.d.ts +39 -0
  152. package/dist/docx.cjs +23575 -0
  153. package/dist/docx.cjs.map +1 -0
  154. package/dist/docx.d.cts +83 -0
  155. package/dist/docx.d.ts +83 -0
  156. package/dist/docx.js +1826 -0
  157. package/dist/docx.js.map +1 -0
  158. package/dist/draghandle-3IBHVHDE.js +389 -0
  159. package/dist/draghandle-3IBHVHDE.js.map +1 -0
  160. package/dist/editimage-GTLFGHYU.js +683 -0
  161. package/dist/editimage-GTLFGHYU.js.map +1 -0
  162. package/dist/editor-DnAN9aPd.d.ts +2948 -0
  163. package/dist/editor-S8w_w5W0.d.cts +2948 -0
  164. package/dist/email-FDSENENR.js +177 -0
  165. package/dist/email-FDSENENR.js.map +1 -0
  166. package/dist/email.cjs +588 -0
  167. package/dist/email.cjs.map +1 -0
  168. package/dist/email.d.cts +7 -0
  169. package/dist/email.d.ts +7 -0
  170. package/dist/email.js +21 -0
  171. package/dist/email.js.map +1 -0
  172. package/dist/{emoticons-ZD6ZRIWG.js → emoticons-SHYSAEID.js} +7 -7
  173. package/dist/emoticons-SHYSAEID.js.map +1 -0
  174. package/dist/exportpdf-TEBDQZSN.js +91 -0
  175. package/dist/exportpdf-TEBDQZSN.js.map +1 -0
  176. package/dist/exportword-BGH2CZXO.js +16 -0
  177. package/dist/exportword-BGH2CZXO.js.map +1 -0
  178. package/dist/footnotes-ui-KPKFDSN7.js +449 -0
  179. package/dist/footnotes-ui-KPKFDSN7.js.map +1 -0
  180. package/dist/form-dialog-SNWFPM2K.js +379 -0
  181. package/dist/form-dialog-SNWFPM2K.js.map +1 -0
  182. package/dist/formatpainter-CB4ZTKR5.js +209 -0
  183. package/dist/formatpainter-CB4ZTKR5.js.map +1 -0
  184. package/dist/fullpagehtml-ui-JPGRMXHD.js +220 -0
  185. package/dist/fullpagehtml-ui-JPGRMXHD.js.map +1 -0
  186. package/dist/html-rules-api-BLDDW9MO.d.cts +42 -0
  187. package/dist/html-rules-api-BLDDW9MO.d.ts +42 -0
  188. package/dist/html-rules.cjs +21 -19
  189. package/dist/html-rules.cjs.map +1 -1
  190. package/dist/html-rules.d.cts +37 -35
  191. package/dist/html-rules.d.ts +37 -35
  192. package/dist/html-rules.js +26 -22
  193. package/dist/html-rules.js.map +1 -1
  194. package/dist/i18n/de.cjs +349 -0
  195. package/dist/i18n/de.cjs.map +1 -1
  196. package/dist/i18n/de.d.cts +1 -1
  197. package/dist/i18n/de.d.ts +1 -1
  198. package/dist/i18n/de.js +349 -0
  199. package/dist/i18n/de.js.map +1 -1
  200. package/dist/i18n/es.cjs +349 -0
  201. package/dist/i18n/es.cjs.map +1 -1
  202. package/dist/i18n/es.d.cts +1 -1
  203. package/dist/i18n/es.d.ts +1 -1
  204. package/dist/i18n/es.js +349 -0
  205. package/dist/i18n/es.js.map +1 -1
  206. package/dist/i18n/fr.cjs +349 -0
  207. package/dist/i18n/fr.cjs.map +1 -1
  208. package/dist/i18n/fr.d.cts +1 -1
  209. package/dist/i18n/fr.d.ts +1 -1
  210. package/dist/i18n/fr.js +349 -0
  211. package/dist/i18n/fr.js.map +1 -1
  212. package/dist/i18n/it.cjs +349 -0
  213. package/dist/i18n/it.cjs.map +1 -1
  214. package/dist/i18n/it.d.cts +1 -1
  215. package/dist/i18n/it.d.ts +1 -1
  216. package/dist/i18n/it.js +349 -0
  217. package/dist/i18n/it.js.map +1 -1
  218. package/dist/i18n/pt-BR.cjs +349 -0
  219. package/dist/i18n/pt-BR.cjs.map +1 -1
  220. package/dist/i18n/pt-BR.d.cts +1 -1
  221. package/dist/i18n/pt-BR.d.ts +1 -1
  222. package/dist/i18n/pt-BR.js +349 -0
  223. package/dist/i18n/pt-BR.js.map +1 -1
  224. package/dist/i18n/ru.cjs +349 -0
  225. package/dist/i18n/ru.cjs.map +1 -1
  226. package/dist/i18n/ru.d.cts +3 -3
  227. package/dist/i18n/ru.d.ts +3 -3
  228. package/dist/i18n/ru.js +349 -0
  229. package/dist/i18n/ru.js.map +1 -1
  230. package/dist/importcss-JLNIRKGH.js +127 -0
  231. package/dist/importcss-JLNIRKGH.js.map +1 -0
  232. package/dist/importword-ZOWLUWSN.js +73 -0
  233. package/dist/importword-ZOWLUWSN.js.map +1 -0
  234. package/dist/{index-C603bU6r.d.ts → index-Pb2r0V-S.d.cts} +39 -17
  235. package/dist/{index-C603bU6r.d.cts → index-Pb2r0V-S.d.ts} +39 -17
  236. package/dist/index.cjs +29422 -10640
  237. package/dist/index.cjs.map +1 -1
  238. package/dist/index.d.cts +139 -64
  239. package/dist/index.d.ts +139 -64
  240. package/dist/index.js +204 -1412
  241. package/dist/index.js.map +1 -1
  242. package/dist/{insertdatetime-CRO7TJAQ.js → insertdatetime-BXQ3XXPH.js} +7 -7
  243. package/dist/insertdatetime-BXQ3XXPH.js.map +1 -0
  244. package/dist/linkchecker-JASSETVI.js +287 -0
  245. package/dist/linkchecker-JASSETVI.js.map +1 -0
  246. package/dist/markdown-OTLTCK26.js +136 -0
  247. package/dist/markdown-OTLTCK26.js.map +1 -0
  248. package/dist/markdown.cjs +94 -11
  249. package/dist/markdown.cjs.map +1 -1
  250. package/dist/markdown.d.cts +12 -10
  251. package/dist/markdown.d.ts +12 -10
  252. package/dist/markdown.js +4 -235
  253. package/dist/markdown.js.map +1 -1
  254. package/dist/math-ui-TY4VZF7Q.js +157 -0
  255. package/dist/math-ui-TY4VZF7Q.js.map +1 -0
  256. package/dist/media-ui-IXN4ENVF.js +123 -0
  257. package/dist/media-ui-IXN4ENVF.js.map +1 -0
  258. package/dist/mediaembed-ui-ODX5ECXC.js +207 -0
  259. package/dist/mediaembed-ui-ODX5ECXC.js.map +1 -0
  260. package/dist/mentions-ui-55GCKC6F.js +58 -0
  261. package/dist/mentions-ui-55GCKC6F.js.map +1 -0
  262. package/dist/mergetags-ui-6T7Z7MAZ.js +73 -0
  263. package/dist/mergetags-ui-6T7Z7MAZ.js.map +1 -0
  264. package/dist/{nonbreaking-66LFZV2W.js → nonbreaking-PONHSOMJ.js} +7 -7
  265. package/dist/nonbreaking-PONHSOMJ.js.map +1 -0
  266. package/dist/pagebreak-ui-AKAW7M5I.js +50 -0
  267. package/dist/pagebreak-ui-AKAW7M5I.js.map +1 -0
  268. package/dist/pageembed-ui-GUNPKMBR.js +172 -0
  269. package/dist/pageembed-ui-GUNPKMBR.js.map +1 -0
  270. package/dist/pagelayout-ui-JSFVEMHS.js +236 -0
  271. package/dist/pagelayout-ui-JSFVEMHS.js.map +1 -0
  272. package/dist/{paste-office-F3QW4WWO.js → paste-office-TORLAZ5L.js} +94 -4
  273. package/dist/paste-office-TORLAZ5L.js.map +1 -0
  274. package/dist/permanentpen-EACURV5U.js +206 -0
  275. package/dist/permanentpen-EACURV5U.js.map +1 -0
  276. package/dist/print-4XJCOANX.js +178 -0
  277. package/dist/print-4XJCOANX.js.map +1 -0
  278. package/dist/{quickbars-7E2QRS7J.js → quickbars-BT5PETRX.js} +20 -12
  279. package/dist/quickbars-BT5PETRX.js.map +1 -0
  280. package/dist/{revisionhistory-DXE7KU4R.js → revisionhistory-3FKLMJHJ.js} +42 -153
  281. package/dist/revisionhistory-3FKLMJHJ.js.map +1 -0
  282. package/dist/save-ZHFXH222.js +120 -0
  283. package/dist/save-ZHFXH222.js.map +1 -0
  284. package/dist/search-bar-6MVRMTK6.js +212 -0
  285. package/dist/search-bar-6MVRMTK6.js.map +1 -0
  286. package/dist/spellchecker-JJKA6B4R.js +474 -0
  287. package/dist/spellchecker-JJKA6B4R.js.map +1 -0
  288. package/dist/suggestions-panel-X37NFLXE.js +596 -0
  289. package/dist/suggestions-panel-X37NFLXE.js.map +1 -0
  290. package/dist/suggestions-ui-WN7QNYHB.js +395 -0
  291. package/dist/suggestions-ui-WN7QNYHB.js.map +1 -0
  292. package/dist/table-PEF56QG5.js +54 -0
  293. package/dist/table-PEF56QG5.js.map +1 -0
  294. package/dist/table-dialogs-QS3VFZD2.js +119 -0
  295. package/dist/table-dialogs-QS3VFZD2.js.map +1 -0
  296. package/dist/tableofcontents-ui-U7EV3UU7.js +167 -0
  297. package/dist/tableofcontents-ui-U7EV3UU7.js.map +1 -0
  298. package/dist/template-ZRTKIP2J.js +278 -0
  299. package/dist/template-ZRTKIP2J.js.map +1 -0
  300. package/dist/typography-S7RO54DB.js +399 -0
  301. package/dist/typography-S7RO54DB.js.map +1 -0
  302. package/dist/upload.cjs +160 -0
  303. package/dist/upload.cjs.map +1 -0
  304. package/dist/upload.d.cts +72 -0
  305. package/dist/upload.d.ts +72 -0
  306. package/dist/upload.js +132 -0
  307. package/dist/upload.js.map +1 -0
  308. package/dist/{visualblocks-6DLBXYOA.js → visualblocks-KJYRHF2L.js} +7 -7
  309. package/dist/visualblocks-KJYRHF2L.js.map +1 -0
  310. package/dist/visualchars-TDLZKFXD.js +134 -0
  311. package/dist/visualchars-TDLZKFXD.js.map +1 -0
  312. package/package.json +53 -3
  313. package/src/style.css +376 -550
  314. package/dist/advlist-5FNKPLUX.js.map +0 -1
  315. package/dist/autolink-45LTODWB.js.map +0 -1
  316. package/dist/autoresize-UB3GOA6D.js.map +0 -1
  317. package/dist/autosave-GMWJ5BPE.js.map +0 -1
  318. package/dist/charmap-2GC7LF7G.js.map +0 -1
  319. package/dist/chunk-5AW2HHG6.js.map +0 -1
  320. package/dist/chunk-DWZLSZDG.js +0 -5664
  321. package/dist/chunk-DWZLSZDG.js.map +0 -1
  322. package/dist/chunk-FCMZ7TUQ.js.map +0 -1
  323. package/dist/chunk-HPLT3XRZ.js.map +0 -1
  324. package/dist/chunk-JPJVTB45.js.map +0 -1
  325. package/dist/chunk-KPE3QRPB.js.map +0 -1
  326. package/dist/chunk-KWXFL4WS.js.map +0 -1
  327. package/dist/chunk-ND2CWNVG.js.map +0 -1
  328. package/dist/chunk-PVFKXRID.js.map +0 -1
  329. package/dist/chunk-R2UMUCVI.js.map +0 -1
  330. package/dist/chunk-T3GY6IVK.js.map +0 -1
  331. package/dist/chunk-Z3ELZ77W.js.map +0 -1
  332. package/dist/comments-panel-HXMWSRAW.js.map +0 -1
  333. package/dist/directionality-5JLWQGP2.js.map +0 -1
  334. package/dist/editor-CXkltf1R.d.ts +0 -1886
  335. package/dist/editor-CgSBFTke.d.cts +0 -1886
  336. package/dist/emoticons-ZD6ZRIWG.js.map +0 -1
  337. package/dist/form-dialog-QH6KAERD.js +0 -180
  338. package/dist/form-dialog-QH6KAERD.js.map +0 -1
  339. package/dist/html-rules-api-D3fKQi-R.d.cts +0 -40
  340. package/dist/html-rules-api-D3fKQi-R.d.ts +0 -40
  341. package/dist/insertdatetime-CRO7TJAQ.js.map +0 -1
  342. package/dist/nonbreaking-66LFZV2W.js.map +0 -1
  343. package/dist/paste-office-F3QW4WWO.js.map +0 -1
  344. package/dist/quickbars-7E2QRS7J.js.map +0 -1
  345. package/dist/revisionhistory-DXE7KU4R.js.map +0 -1
  346. package/dist/table-SSNABG5W.js.map +0 -1
  347. package/dist/visualblocks-6DLBXYOA.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/plugins/suggestions.ts"],"sourcesContent":["import {\n Fragment,\n Slice,\n type Mark,\n type MarkSpec,\n type MarkType,\n type Node as PMNode,\n} from 'prosemirror-model';\nimport {\n EditorState,\n NodeSelection,\n Plugin,\n PluginKey,\n Selection,\n TextSelection,\n type Transaction,\n} from 'prosemirror-state';\nimport { liftListItem } from 'prosemirror-schema-list';\nimport {\n AddMarkStep,\n AttrStep,\n canJoin,\n liftTarget,\n RemoveMarkStep,\n ReplaceAroundStep,\n ReplaceStep,\n Transform,\n type Step,\n} from 'prosemirror-transform';\nimport { Decoration, DecorationSet } from 'prosemirror-view';\nimport { keymap } from 'prosemirror-keymap';\nimport type { Editor } from '../editor';\nimport type { NodeAttribute } from '../schema';\nimport { SET_CONTENT_META } from '../meta';\nimport { definePlugin } from '../plugins';\nimport { pickLabels } from './shared';\n\n/**\n * The suggestions plugin — suggesting mode (like \"Suggesting\" in Google Docs). In suggesting mode,\n * an edit doesn't change the document directly: insertions are marked <ins>, deletions <del> (the\n * text stays until a decision). Every suggestion knows its author and time; it is accepted or\n * rejected one by one (the panel above it) or all at once. In HTML: `<ins data-suggestion=\"id\" …>`.\n *\n * Inserting and deleting text is tracked, and so is text formatting (bold, a color, a link…): the\n * new formatting shows at once, and the text remembers what it was, to go back to it if the\n * suggestion is rejected (`<span data-suggestion=\"id\" data-format=\"[…]\">`). So is a node's type and\n * style (a heading instead of a paragraph, alignment, a numbered list instead of a bulleted one,\n * table and cell properties, an image's size): the node remembers what it was\n * (`<h2 data-suggestion=\"id\" data-before='{\"type\":\"paragraph\"}'>`). Whole nodes inserted or deleted\n * (a table, a row, a column, an image, a line) carry the suggestion themselves\n * (`<tr data-suggestion=\"id\" data-change=\"delete\">`); a deleted one stays until the deletion is\n * accepted. Putting paragraphs into a list or a quote, taking them out, Tab and Shift+Tab in a list\n * are suggestions on the item or the quote (`data-change=\"wrap\"` / `\"unwrap\"`). An edit that can't be\n * a suggestion (merging table cells, a page setup) isn't made in suggesting mode: nothing changes\n * the document directly.\n */\n\nexport interface SuggestionAuthor {\n id: string;\n name: string;\n}\n\nexport interface SuggestionsOptions {\n /** Who is suggesting. */\n author?: SuggestionAuthor;\n /** Start in suggesting mode. */\n enabled?: boolean;\n /** Suggestions only: the mode can't be turned off (someone who may not change the text directly). */\n force?: boolean;\n /** Whether this user can accept and reject suggestions (yes by default). */\n canReview?: boolean;\n}\n\nexport interface Suggestion {\n id: string;\n /**\n * insert and delete: text, or a whole node (`node` says which); format: the text's formatting\n * changed; block: a node's type or style; split: a new paragraph break before the block; join:\n * the paragraph break before it deleted; wrap: the node put into a list or a quote, or one level\n * deeper in a list (Tab); unwrap: taking it out of one suggested.\n */\n kind: 'insert' | 'delete' | 'format' | 'block' | 'split' | 'join' | 'wrap' | 'unwrap';\n author: SuggestionAuthor;\n time: number;\n /** Text: where it starts and ends. A suggestion a node carries (`node` is set): the whole node. */\n from: number;\n to: number;\n text: string;\n /** The type name of the node that carries the suggestion (not set for text). */\n node?: string;\n /** format: the formatting (mark names) the text got, and the formatting it lost. */\n added?: string[];\n removed?: string[];\n /** block: what the block was before: its type and attributes. */\n before?: BlockBefore;\n /** split and join: how many levels the paragraph break is (a list item: 2). */\n depth?: number;\n}\n\nexport interface BlockBefore {\n type: string;\n attrs: Record<string, string | number | boolean | null>;\n}\n\n/** A suggested change a node carries (its `suggestion` attribute). */\nexport interface BlockSuggestion {\n id: string;\n author: string;\n name: string;\n time: number;\n /**\n * block: its type or style changed; split: a new paragraph break before it; join: that break\n * deleted; insert / delete: the whole node; wrap / unwrap: put into a list or a quote, or one level\n * deeper (wrap), and taken out (unwrap).\n */\n change: 'block' | 'split' | 'join' | 'insert' | 'delete' | 'wrap' | 'unwrap';\n /** block: what it was before. */\n before?: BlockBefore;\n /** split: how many levels the break opened (a new list item: 2). */\n depth?: number;\n}\n\nconst ID_RE = /^[A-Za-z0-9_-]{1,64}$/;\nconst USER_ID_RE = /^[\\w.@:+-]{1,128}$/;\n\nexport const LABELS = {\n en: {\n toggle: 'Suggest edits',\n review: 'Review suggestions',\n accept: 'Accept',\n reject: 'Reject',\n acceptAll: 'Accept all suggestions',\n rejectAll: 'Reject all suggestions',\n next: 'Next suggestion',\n previous: 'Previous suggestion',\n inserted: 'Inserted by {name}',\n deleted: 'Deleted by {name}',\n formatted: 'Formatted by {name}',\n toolbar: 'Suggestion',\n guest: 'Guest',\n none: 'No suggestions',\n unsupported: 'This change can’t be a suggestion',\n unsupportedDirect: 'This change can’t be a suggestion. To make it, turn off Suggest edits.',\n },\n};\n\nexport const suggestionsKey = new PluginKey<{ enabled: boolean }>('nova-suggestions');\n\n/** The marker of the plugin's own transactions (accept/reject, toggling the mode): they aren't tracked. */\nexport const OWN = 'nova-suggestions-own';\n\n/** On a transaction that accepts or rejects suggestions: `{ action, ids }`. */\nexport const RESOLVED = 'nova-suggestions-resolved';\n\n/**\n * Author colors: the text of an edit in this color has a contrast of at least 6:1 on white, on the tinted\n * background (insertion) and in the dark theme (where the color is lightened by 45%). It was below 4.5:1 until axe caught it.\n */\nconst PALETTE = ['#116329', '#6639ba', '#99286e', '#0550ae', '#953800', '#0e5b5e'];\n\n/** The color of an edit's author: the same for the same person (by id, or by name without one). */\nexport function suggestionColor(key: string): string {\n let hash = 0;\n for (const ch of String(key ?? '')) hash = (hash * 31 + ch.charCodeAt(0)) | 0;\n return PALETTE[Math.abs(hash) % PALETTE.length]!;\n}\n\nfunction newId(): string {\n const bytes = new Uint8Array(9);\n globalThis.crypto.getRandomValues(bytes);\n return 's' + Array.from(bytes, (b) => (b % 36).toString(36)).join('');\n}\n\nfunction markSpec(kind: 'insert' | 'delete'): MarkSpec {\n const tag = kind === 'insert' ? 'ins' : 'del';\n return {\n attrs: { id: {}, author: { default: '' }, name: { default: '' }, time: { default: 0 } },\n inclusive: false,\n excludes: '',\n parseDOM: [\n {\n tag: `${tag}[data-suggestion]`,\n // Before the strike-through rules (<del> without data-suggestion is a regular strike-through).\n priority: 60,\n getAttrs: (dom) => {\n const el = dom as HTMLElement;\n const id = el.getAttribute('data-suggestion') ?? '';\n if (!ID_RE.test(id)) return false;\n const author = el.getAttribute('data-author') ?? '';\n return {\n id,\n author: USER_ID_RE.test(author) ? author : '',\n name: (el.getAttribute('data-name') ?? '').slice(0, 80),\n time: Number(el.getAttribute('data-time')) || 0,\n };\n },\n },\n ],\n toDOM: (mark: Mark) => [\n tag,\n {\n 'data-suggestion': ID_RE.test(mark.attrs.id as string) ? mark.attrs.id : null,\n 'data-author': USER_ID_RE.test(mark.attrs.author as string) ? mark.attrs.author : null,\n 'data-name': String(mark.attrs.name ?? '').slice(0, 80) || null,\n 'data-time': Number(mark.attrs.time) || null,\n },\n 0,\n ],\n };\n}\n\n/**\n * What the text's formatting was before a suggested change: a list of marks as JSON (`[{\"type\":\n * \"bold\"}, {\"type\": \"color\", \"attrs\": {…}}]`). From HTML or JSON it can be anything, so it is cleaned:\n * mark names only, plain attribute values, at most 16 marks; anything else becomes `[]`.\n */\nexport function cleanFormat(value: unknown): string {\n let list: unknown;\n try {\n list = typeof value === 'string' ? JSON.parse(value) : value;\n } catch {\n return '[]';\n }\n if (!Array.isArray(list)) return '[]';\n const out: { type: string; attrs?: Record<string, string | number | boolean | null> }[] = [];\n for (const item of list.slice(0, 16)) {\n const type = (item as { type?: unknown } | null)?.type;\n if (typeof type !== 'string' || !/^[a-z][a-z0-9_]{0,39}$/.test(type)) continue;\n const attrs = cleanAttrs((item as { attrs?: unknown }).attrs, 8);\n out.push(Object.keys(attrs).length ? { type, attrs } : { type });\n }\n return JSON.stringify(out);\n}\n\n/** Plain attribute values only (short strings, numbers, booleans, null), at most `max` of them. */\nfunction cleanAttrs(raw: unknown, max: number): BlockBefore['attrs'] {\n const attrs: BlockBefore['attrs'] = {};\n if (raw && typeof raw === 'object' && !Array.isArray(raw)) {\n for (const [key, attr] of Object.entries(raw).slice(0, max)) {\n if (!/^[A-Za-z][\\w-]{0,39}$/.test(key) || key === 'suggestion') continue;\n if (typeof attr === 'string') attrs[key] = attr.slice(0, 2000);\n else if (typeof attr === 'number' || typeof attr === 'boolean' || attr === null)\n attrs[key] = attr;\n }\n }\n return attrs;\n}\n\n/**\n * A block suggestion from a block's attribute, or null. It comes from HTML or JSON, so it can be\n * anything: only an id, an author, a time and a type name with plain attribute values are kept.\n */\nexport function blockSuggestion(value: unknown): BlockSuggestion | null {\n if (!value || typeof value !== 'object') return null;\n const raw = value as Record<string, unknown>;\n if (typeof raw.id !== 'string' || !ID_RE.test(raw.id)) return null;\n const author = String(raw.author ?? '');\n const base = {\n id: raw.id,\n author: USER_ID_RE.test(author) ? author : '',\n name: String(raw.name ?? '').slice(0, 80),\n time: Number(raw.time) || 0,\n };\n if (raw.change === 'split' || raw.change === 'join') {\n // A join that took the place of your own style suggestion remembers the style too.\n const before = raw.change === 'join' && raw.before != null ? parseBefore(raw.before) : null;\n return {\n ...base,\n change: raw.change,\n depth: Math.min(4, Math.max(1, Math.trunc(Number(raw.depth)) || 1)),\n ...(before ? { before } : {}),\n };\n }\n if (raw.change === 'insert' || raw.change === 'delete') return { ...base, change: raw.change };\n if (raw.change === 'wrap' || raw.change === 'unwrap') {\n return {\n ...base,\n change: raw.change,\n depth: Math.min(9, Math.max(1, Math.trunc(Number(raw.depth)) || 1)),\n };\n }\n const before = parseBefore(raw.before);\n return before ? { ...base, change: 'block', before } : null;\n}\n\n/** What a node was (a type name and plain attributes), from JSON or its string, or null. */\nfunction parseBefore(value: unknown): BlockBefore | null {\n let before = value;\n try {\n if (typeof before === 'string') before = JSON.parse(before);\n } catch {\n return null;\n }\n const type = (before as { type?: unknown } | null)?.type;\n if (typeof type !== 'string' || !/^[a-z][a-z0-9_]{0,39}$/.test(type)) return null;\n return { type, attrs: cleanAttrs((before as { attrs?: unknown }).attrs, 12) };\n}\n\n/** The suggestion attribute of nodes, read from and written to the node's element. */\nconst blockAttribute: NodeAttribute = {\n nodes: 'all',\n default: null,\n parse: (dom) =>\n dom.hasAttribute('data-before') || dom.hasAttribute('data-change')\n ? blockSuggestion({\n id: dom.getAttribute('data-suggestion'),\n author: dom.getAttribute('data-author'),\n name: dom.getAttribute('data-name'),\n time: dom.getAttribute('data-time'),\n before: dom.getAttribute('data-before'),\n change: dom.getAttribute('data-change'),\n depth: dom.getAttribute('data-depth'),\n })\n : null,\n render(value) {\n const s = blockSuggestion(value);\n if (!s) return {};\n const out: Record<string, string> = { 'data-suggestion': s.id };\n if (s.change !== 'block') out['data-change'] = s.change;\n if (s.before) out['data-before'] = JSON.stringify(s.before);\n if ((s.depth ?? 1) > 1) out['data-depth'] = String(s.depth);\n if (s.author) out['data-author'] = s.author;\n if (s.name) out['data-name'] = s.name;\n if (s.time) out['data-time'] = String(s.time);\n return out;\n },\n};\n\n/**\n * What a change of structure did (suggestions-blocks.ts works it out from the document before and\n * after it): nodes put into a list or a quote, or one level deeper in a list (wrap: their positions\n * after), or taken out (unwrap: their positions before).\n */\nexport interface StructureChange {\n change: 'wrap' | 'unwrap';\n /** The nodes that carry the suggestion: list items and quotes. */\n nodes: number[];\n}\n\n/** The trackers that load with the plugin's interface (suggestions-blocks.ts). */\nexport interface StructureTrackers {\n /** A paragraph break typed (Enter) or deleted (Backspace, Delete), or null for any other edit. */\n breaks(tr: Transaction, state: EditorState, author: SuggestionAuthor): Transaction | null;\n /** Lists and quotes: what changed between the two documents, or null for anything else. */\n structure(before: PMNode, after: PMNode): StructureChange | null;\n}\nlet trackers: StructureTrackers | null = null;\nexport function setStructureTrackers(value: StructureTrackers): void {\n trackers = value;\n}\n\nfunction formatSpec(): MarkSpec {\n return {\n attrs: {\n id: {},\n author: { default: '' },\n name: { default: '' },\n time: { default: 0 },\n before: { default: '[]' },\n },\n inclusive: false,\n excludes: '',\n parseDOM: [\n {\n tag: 'span[data-suggestion][data-format]',\n priority: 60,\n getAttrs: (dom) => {\n const el = dom as HTMLElement;\n const id = el.getAttribute('data-suggestion') ?? '';\n if (!ID_RE.test(id)) return false;\n const author = el.getAttribute('data-author') ?? '';\n return {\n id,\n author: USER_ID_RE.test(author) ? author : '',\n name: (el.getAttribute('data-name') ?? '').slice(0, 80),\n time: Number(el.getAttribute('data-time')) || 0,\n before: cleanFormat(el.getAttribute('data-format')),\n };\n },\n },\n ],\n toDOM: (mark: Mark) => [\n 'span',\n {\n 'data-suggestion': ID_RE.test(mark.attrs.id as string) ? mark.attrs.id : null,\n 'data-format': cleanFormat(mark.attrs.before),\n 'data-author': USER_ID_RE.test(mark.attrs.author as string) ? mark.attrs.author : null,\n 'data-name': String(mark.attrs.name ?? '').slice(0, 80) || null,\n 'data-time': Number(mark.attrs.time) || null,\n },\n 0,\n ],\n };\n}\n\nconst typesOf = (schema: EditorState['schema']) => ({\n insert: schema.marks.suggestion_insert as MarkType,\n delete: schema.marks.suggestion_delete as MarkType,\n format: schema.marks.suggestion_format as MarkType,\n});\n\n/** Marks that aren't formatting: suggestions themselves and comments. */\nconst NOT_FORMATTING = new Set([\n 'suggestion_insert',\n 'suggestion_delete',\n 'suggestion_format',\n 'comment',\n]);\n\nconst formatting = (marks: readonly Mark[]) =>\n marks.filter((m) => !NOT_FORMATTING.has(m.type.name));\n\n/** The marks of a `before` list that this schema knows (others are left out, never an error). */\nexport function formatMarks(schema: EditorState['schema'], before: unknown): Mark[] {\n const marks: Mark[] = [];\n for (const json of JSON.parse(cleanFormat(before)) as { type: string }[]) {\n if (NOT_FORMATTING.has(json.type) || !schema.marks[json.type]) continue;\n try {\n const mark = schema.markFromJSON(json);\n if (!mark.isInSet(marks)) marks.push(mark);\n } catch {\n // Attributes the mark doesn't take: without this mark.\n }\n }\n return marks;\n}\n\nconst sameMarks = (a: readonly Mark[], b: readonly Mark[]) =>\n a.length === b.length && a.every((mark) => mark.isInSet(b));\n\n/**\n * This user's own edit: not the plugin's own (accept, reject), not a document being loaded, not\n * undo or redo, not a collaborator's change, not one kept out of the history. Only these become\n * suggestions.\n */\nfunction isUserEdit(tr: Transaction): boolean {\n if (!tr.docChanged || tr.getMeta(OWN)) return false;\n if (tr.getMeta('addToHistory') === false) return false;\n // setContent loads a document: that is not an edit to suggest.\n if (tr.getMeta(SET_CONTENT_META)) return false;\n // Undo/redo (own and shared history) and other participants' edits arrive ready-made.\n if (tr.getMeta('history$')) return false;\n const ySync = tr.getMeta('y-sync$') as { isChangeOrigin?: boolean } | undefined;\n return !ySync?.isChangeOrigin;\n}\n\n/** Whether a node can carry a suggestion (every node but the document and text, with the plugin). */\nconst carries = (node: PMNode) => !!node.type.spec.attrs && 'suggestion' in node.type.spec.attrs;\n\n/** A suggestion a node carries: who, when, what. */\nfunction nodeValue(\n change: 'insert' | 'delete' | 'wrap' | 'unwrap',\n id: string,\n author: SuggestionAuthor,\n time: number,\n depth = 1,\n): BlockSuggestion {\n return {\n id,\n author: author.id,\n name: author.name,\n time,\n change,\n ...(depth > 1 ? { depth } : {}),\n };\n}\n\n/** What the nodes around a position say: inside your own new node, inside a deleted one. */\nexport function around(\n doc: PMNode,\n pos: number,\n authorId: string,\n): { own: boolean; deleted: boolean } {\n const $pos = doc.resolve(pos);\n const result = { own: false, deleted: false };\n for (let depth = $pos.depth; depth > 0; depth--) {\n const s = blockSuggestion($pos.node(depth).attrs.suggestion);\n if (s?.change === 'insert' && s.author === authorId) result.own = true;\n if (s?.change === 'delete') result.deleted = true;\n }\n return result;\n}\n\n/** Whether a fragment holds any inline content (text, an image, a mention). */\nexport function hasInline(fragment: Fragment): boolean {\n let found = false;\n fragment.descendants((node) => {\n if (node.isInline) found = true;\n return !found;\n });\n return found;\n}\n\n/** A node's type and plain attributes, without its suggestion. */\nexport function markup(node: PMNode): BlockBefore {\n const attrs: BlockBefore['attrs'] = {};\n for (const [key, value] of Object.entries(node.attrs)) {\n if (key === 'suggestion') continue;\n if (value === null || ['string', 'number', 'boolean'].includes(typeof value))\n attrs[key] = value as string | number | boolean | null;\n }\n return { type: node.type.name, attrs };\n}\n\n/** An attribute of a node's markup; a missing one is its default (HTML saved elsewhere may leave defaults out). */\nexport function attrValue(schema: EditorState['schema'], block: BlockBefore, key: string): unknown {\n return (\n block.attrs[key] ??\n (schema.nodes[block.type]?.spec.attrs?.[key] as { default?: unknown } | undefined)?.default ??\n null\n );\n}\n\n/** The attributes in which two markups differ. */\nfunction differ(schema: EditorState['schema'], a: BlockBefore, b: BlockBefore): string[] {\n return [...new Set([...Object.keys(a.attrs), ...Object.keys(b.attrs)])].filter(\n (key) => attrValue(schema, a, key) !== attrValue(schema, b, key),\n );\n}\n\n/**\n * The node whose markup (type, attributes) a step changes, or null for any other step. Such a step\n * moves no position.\n */\nfunction markupChange(step: Step, doc: PMNode): number | null {\n if (step instanceof AttrStep) return doc.nodeAt(step.pos) ? step.pos : null;\n if (step instanceof ReplaceAroundStep) {\n const old = doc.nodeAt(step.from);\n const next = step.slice.content.firstChild;\n const markupOnly =\n !!old &&\n !!next &&\n !next.isLeaf &&\n step.slice.content.childCount === 1 &&\n step.slice.openStart === 0 &&\n step.slice.openEnd === 0 &&\n step.insert === 1 &&\n step.to === step.from + old.nodeSize &&\n step.gapFrom === step.from + 1 &&\n step.gapTo === step.to - 1 &&\n next.content.size === 0;\n return markupOnly ? step.from : null;\n }\n if (step instanceof ReplaceStep) {\n // A leaf (an image, a line) gets new attributes as a copy of itself put in its place.\n const { from, to, slice } = step as ReplaceStep & { from: number; to: number };\n const old = doc.nodeAt(from);\n const next = slice.content.firstChild;\n return old?.isLeaf &&\n !old.isText &&\n next?.isLeaf &&\n old.type === next.type &&\n to === from + old.nodeSize &&\n slice.content.childCount === 1 &&\n slice.openStart === 0 &&\n slice.openEnd === 0 &&\n sameMarks(old.marks, next.marks) &&\n !old.eq(next)\n ? from\n : null;\n }\n return null;\n}\n\n/** Attributes whose change is layout, not content (a column's width dragged): made directly. */\nconst LAYOUT = new Set(['colwidth']);\n\n/**\n * A node's markup changed in suggesting mode: the change is made, and the node remembers what it\n * was (or keeps what it remembered already); back to that, the suggestion goes. Your own new node\n * is just changed. False: it can't be a suggestion (the node carries another kind of suggestion).\n */\nfunction suggestMarkup(\n out: Transaction,\n pos: number,\n next: PMNode,\n author: SuggestionAuthor,\n id: () => string,\n time: number,\n): boolean {\n const old = out.doc.nodeAt(pos);\n if (!old || !carries(old) || !carries(next)) return false;\n const schema = out.doc.type.schema;\n const apply = (value: unknown) =>\n out.setNodeMarkup(pos, next.type, { ...next.attrs, suggestion: value }, next.marks);\n const existing = blockSuggestion(old.attrs.suggestion);\n const was = markup(old);\n const now = markup(next);\n const own =\n old.marks.some((m) => m.type.name === 'suggestion_insert' && m.attrs.author === author.id) ||\n ((existing?.change === 'insert' || existing?.change === 'split') &&\n existing.author === author.id) ||\n around(out.doc, pos, author.id).own;\n // Layout (a column's width) and your own new node: made as it is.\n if (own || (was.type === now.type && differ(schema, was, now).every((k) => LAYOUT.has(k)))) {\n apply(old.attrs.suggestion);\n return true;\n }\n if (existing && existing.change !== 'block') return false;\n const before = existing?.before ?? was;\n const same = before.type === now.type && differ(schema, before, now).length === 0;\n apply(\n same\n ? null\n : {\n id: existing?.id ?? id(),\n author: author.id,\n name: author.name,\n time,\n change: 'block',\n before,\n },\n );\n return true;\n}\n\n/**\n * Lifts a list item one level (out of its list, or out of a nested list into the one around it) or\n * takes a quote's content out of it. Returns where the lifted node's content starts now, or null if\n * it can't be lifted.\n */\nfunction liftOnce(tr: Transform, pos: number): number | null {\n const node = tr.doc.nodeAt(pos);\n if (!node || node.isLeaf) return null;\n const start = tr.steps.length;\n const item = tr.doc.type.schema.nodes.list_item;\n if (node.type === item && item) {\n const state = EditorState.create({\n doc: tr.doc,\n selection: TextSelection.near(tr.doc.resolve(pos + 1)),\n });\n let lifted = false;\n liftListItem(item)(state, (done) => {\n for (const step of done.steps) tr.step(step);\n lifted = true;\n });\n if (!lifted) return null;\n } else {\n const range = tr.doc.resolve(pos + 1).blockRange(tr.doc.resolve(pos + node.nodeSize - 1));\n const target = range && liftTarget(range);\n if (target === null || target === undefined) return null;\n tr.lift(range!, target);\n }\n return tr.mapping.slice(start).map(pos + 1, 1);\n}\n\n/** The list item or quote whose content starts at a position (after a lift), or null. */\nfunction wrapperAt(doc: PMNode, contentStart: number): number | null {\n const $pos = doc.resolve(contentStart);\n return $pos.depth > 0 && contentStart === $pos.start() ? $pos.before() : null;\n}\n\n/** Lifts each node one level, the last first (positions before it stay). False if one can't be. */\nfunction liftEach(tr: Transform, positions: readonly number[]): boolean {\n return [...positions].sort((a, b) => b - a).every((pos) => liftOnce(tr, pos) !== null);\n}\n\n/**\n * A change of lists or quotes as suggestions (the steps from `start` on made it in `out`): nodes put\n * into a list or a quote carry \"wrap\" (rejecting lifts them back), nodes taken out stay where they\n * were and carry \"unwrap\" (accepting takes them out). Taking out what is your own suggestion (a new\n * list item, a level you added) is just made. Null if it can't be a suggestion: what rejecting or\n * accepting would do has to give exactly the documents before and after.\n */\nfunction suggestStructure(\n out: Transaction,\n start: number,\n before: PMNode,\n state: EditorState,\n author: SuggestionAuthor,\n id: () => string,\n time: number,\n): Transaction | null {\n const found = trackers?.structure(before, out.doc);\n if (!found?.nodes.length) return null;\n const ownBy = (s: BlockSuggestion | null, ...changes: BlockSuggestion['change'][]) =>\n !!s && s.author === author.id && changes.includes(s.change);\n if (found.change === 'wrap') {\n const check = new Transform(out.doc);\n if (!liftEach(check, found.nodes) || !check.doc.eq(before)) return null;\n for (const pos of found.nodes) {\n const s = blockSuggestion(out.doc.nodeAt(pos)!.attrs.suggestion);\n if (ownBy(s, 'insert')) continue;\n if (s && !ownBy(s, 'wrap')) return null;\n out.setNodeAttribute(\n pos,\n 'suggestion',\n nodeValue('wrap', s?.id ?? id(), author, time, (s?.depth ?? 0) + 1),\n );\n }\n return out;\n }\n // Taken out of a list or a quote: accepting has to give the document after.\n const check = new Transform(before);\n if (!liftEach(check, found.nodes) || !check.doc.eq(out.doc)) return null;\n const nodes = found.nodes.map((pos) => ({ pos, node: before.nodeAt(pos)! }));\n // Your own new list item (Enter in a list, then Enter again on the empty item), or a level you\n // added yourself (Tab, then Shift+Tab): the change is made.\n const ownNew = ({ node }: { node: PMNode }) => {\n const block = node.childCount === 1 ? node.firstChild! : null;\n // The item itself is new (Enter at the end of an item), or its paragraph is.\n const s = blockSuggestion(node.attrs.suggestion) ?? blockSuggestion(block?.attrs.suggestion);\n let ownText = true;\n block?.descendants((child) => {\n if (\n child.isInline &&\n !child.marks.some(\n (m) => m.type.name === 'suggestion_insert' && m.attrs.author === author.id,\n )\n )\n ownText = false;\n return ownText;\n });\n return !!block?.isTextblock && ownBy(s, 'split', 'insert') && ownText;\n };\n const ownLevel = ({ node }: { node: PMNode }) =>\n ownBy(blockSuggestion(node.attrs.suggestion), 'wrap');\n if (nodes.every((n) => ownNew(n) || ownLevel(n))) {\n const map = out.mapping.slice(start);\n for (const n of nodes) {\n const contentStart = map.map(n.pos + 1, 1);\n const wrapper = wrapperAt(out.doc, contentStart);\n const moved = wrapper === null ? null : out.doc.nodeAt(wrapper);\n if (ownLevel(n)) {\n const s = blockSuggestion(n.node.attrs.suggestion)!;\n // One level less; a list item taken out of its list altogether is gone with the level.\n if (moved?.type === n.node.type)\n out.setNodeAttribute(\n wrapper!,\n 'suggestion',\n (s.depth ?? 1) > 1 ? nodeValue('wrap', s.id, author, s.time, s.depth! - 1) : null,\n );\n continue;\n }\n // A new paragraph out of the list: a new block, gone if the suggestion is rejected.\n const block = out.doc.nodeAt(contentStart);\n const s = (blockSuggestion(n.node.attrs.suggestion) ??\n blockSuggestion(n.node.firstChild!.attrs.suggestion))!;\n if (block?.isTextblock && moved?.type.name !== 'list_item')\n out.setNodeAttribute(contentStart, 'suggestion', nodeValue('insert', s.id, author, s.time));\n }\n return out;\n }\n // Otherwise the nodes stay where they are and carry the suggestion to take them out.\n const kept = state.tr;\n for (const step of out.steps.slice(0, start)) kept.step(step);\n if (!kept.doc.eq(before)) return null;\n for (const { pos, node } of nodes) {\n const s = blockSuggestion(node.attrs.suggestion);\n if (s && !ownBy(s, 'unwrap')) return null;\n kept.setNodeAttribute(\n pos,\n 'suggestion',\n nodeValue('unwrap', s?.id ?? id(), author, time, (s?.depth ?? 0) + 1),\n );\n }\n return kept;\n}\n\n/**\n * A formatting change as a suggestion: the change is made (the new look shows at once), and text that\n * had no suggested format yet remembers its formatting before it. Your own suggested insertion is\n * just formatted: rejecting it removes the text anyway. A change that brings text back to how it was\n * takes the suggestion away.\n */\nfunction suggestFormat(\n out: Transaction,\n from: number,\n to: number,\n op: 'add' | 'remove',\n mark: Mark,\n author: SuggestionAuthor,\n time: number,\n): void {\n const types = typesOf(out.doc.type.schema);\n const apply = (start: number, end: number) =>\n op === 'add' ? out.addMark(start, end, mark) : out.removeMark(start, end, mark);\n if (NOT_FORMATTING.has(mark.type.name) || !types.format) {\n apply(from, to);\n return;\n }\n const pieces: { from: number; to: number; node: PMNode }[] = [];\n out.doc.nodesBetween(from, to, (node, pos, parent) => {\n if (!node.isInline) return true;\n const start = Math.max(pos, from);\n const end = Math.min(pos + node.nodeSize, to);\n if (start < end && parent?.type.allowsMarkType(mark.type))\n pieces.push({ from: start, to: end, node });\n return false;\n });\n let id: string | null = null;\n for (const { from: start, to: end, node } of pieces) {\n const after = op === 'add' ? mark.addToSet(node.marks) : mark.removeFromSet(node.marks);\n if (sameMarks(after, node.marks)) continue;\n apply(start, end);\n const own = node.marks.some((m) => m.type === types.insert && m.attrs.author === author.id);\n if (own || types.delete.isInSet(node.marks)) continue;\n const suggested = node.marks.find((m) => m.type === types.format);\n if (suggested) {\n // Already a suggested format: it keeps what the text was; back there, it goes away.\n const before = formatMarks(out.doc.type.schema, suggested.attrs.before);\n if (sameMarks(formatting(after), before)) out.removeMark(start, end, suggested);\n continue;\n }\n id ??= newId();\n const before = cleanFormat(formatting(node.marks).map((m) => m.toJSON()));\n out.addMark(\n start,\n end,\n types.format.create({ id, author: author.id, name: author.name, time, before }),\n );\n }\n}\n\n/**\n * An edit by the same author right next to the position is continued with the same mark (id and time), otherwise\n * neighboring letters would become separate suggestions.\n */\nfunction neighbourMark(doc: PMNode, pos: number, type: MarkType, authorId: string): Mark | null {\n const $pos = doc.resolve(pos);\n for (const node of [$pos.nodeBefore, $pos.nodeAfter]) {\n const mark = node?.marks.find((m) => m.type === type && m.attrs.author === authorId);\n if (mark) return mark;\n }\n return null;\n}\n\n/**\n * Inserted content marked \"inserted\": its text gets the mark; a whole new node (a paragraph, a table,\n * a row, a column's cell, an image, a line) carries the suggestion itself, and what is inside it is\n * new with it. The nodes on the slice's open edges are\n * parts of nodes already there, not new ones.\n */\nfunction withInsert(\n fragment: Fragment,\n mark: Mark,\n parent: PMNode['type'] | null,\n openStart: number,\n openEnd: number,\n value: () => BlockSuggestion,\n): Fragment {\n const nodes: PMNode[] = [];\n fragment.forEach((node, _offset, index) => {\n if (node.isInline) {\n nodes.push(\n parent && !parent.allowsMarkType(mark.type) ? node : node.mark(mark.addToSet(node.marks)),\n );\n return;\n }\n const openLeft = index === 0 && openStart > 0;\n const openRight = index === fragment.childCount - 1 && openEnd > 0;\n if (!openLeft && !openRight && carries(node)) {\n nodes.push(\n node.type.create({ ...node.attrs, suggestion: value() }, node.content, node.marks),\n );\n return;\n }\n nodes.push(\n node.copy(\n withInsert(\n node.content,\n mark,\n node.type,\n openLeft ? openStart - 1 : 0,\n openRight ? openEnd - 1 : 0,\n value,\n ),\n ),\n );\n });\n return Fragment.from(nodes);\n}\n\n/**\n * Puts inserted content in, as the original step did: the same slice as one step. Fitting it in\n * again (Transform.replace) could build it differently (an empty image to complete a split figure).\n */\nfunction insertAt(out: Transaction, at: number, slice: Slice): void {\n if (out.maybeStep(new ReplaceStep(at, at, slice)).failed) out.replace(at, at, slice);\n}\n\n/** A selection in another document: positions through `map`, a selected node stays selected. */\nfunction mapSelection(selection: Selection, doc: PMNode, map: (pos: number) => number): Selection {\n if (selection instanceof NodeSelection) {\n const pos = map(selection.from);\n const node = doc.nodeAt(pos);\n if (node && NodeSelection.isSelectable(node)) return NodeSelection.create(doc, pos);\n }\n return TextSelection.between(\n doc.resolve(map(selection.anchor)),\n doc.resolve(map(selection.head)),\n );\n}\n\n/**\n * Turns a user's edit into a suggestion: what was deleted gets marked, what was inserted gets marked,\n * a node's new markup is remembered, a list or quote change is a suggestion on the item or the quote.\n * Your own insertion that isn't accepted yet is deleted for real (fixing a typo in your own\n * suggestion). An edit that can't be a suggestion isn't made: an empty transaction comes back, and\n * `onRefuse` is called.\n */\nexport function suggestTransaction(\n tr: Transaction,\n state: EditorState,\n author: SuggestionAuthor,\n onRefuse?: () => void,\n): Transaction {\n if (!isUserEdit(tr)) return tr;\n const refuse = () => {\n onRefuse?.();\n return state.tr;\n };\n // A paragraph break typed or deleted: the block remembers it.\n const breaks = trackers?.breaks(tr, state, author);\n if (breaks) return breaks;\n const types = typesOf(state.schema);\n let out = state.tr;\n const time = Date.now();\n // One id for the node suggestions of one edit (a column is a cell in every row).\n let nodeId: string | null = null;\n const idFor = () => (nodeId ??= newId());\n // A position in the document of the original transaction (before step i) → a position in out.\n let toOut = (pos: number) => pos;\n let forwardDeleteEnd: number | null = null;\n // A selected node deleted (it stays, marked): the cursor goes after it.\n let afterDeleted: number | null = null;\n // Where the inserted content went (one step): the cursor keeps its place in it.\n let inserted: { at: number; from: number; size: number } | null = null;\n let movesPositions = false;\n // A deletion kept as a suggestion and a node's markup changed in one edit (merging table cells):\n // both together would leave a table that doesn't add up, so such an edit isn't a suggestion.\n let keptDeletion = false;\n let markupChanged = false;\n // Lists and quotes: their steps are made as they are, and what they did is worked out at the end,\n // from the document before them and after.\n let structureStart: number | null = null;\n let structureBefore: PMNode | null = null;\n\n for (let i = 0; i < tr.steps.length; i++) {\n const rawStep = tr.steps[i]!;\n const doc = tr.docs[i]!;\n if (rawStep instanceof AddMarkStep || rawStep instanceof RemoveMarkStep) {\n if (structureStart !== null) return refuse();\n // Formatting: marks don't move positions, here or in the original.\n const op = rawStep instanceof AddMarkStep ? 'add' : 'remove';\n suggestFormat(out, toOut(rawStep.from), toOut(rawStep.to), op, rawStep.mark, author, time);\n continue;\n }\n const markupAt = markupChange(rawStep, doc);\n if (markupAt !== null) {\n if (structureStart !== null || keptDeletion) return refuse();\n markupChanged = true;\n const next = (tr.docs[i + 1] ?? tr.doc).nodeAt(markupAt);\n if (!next || !suggestMarkup(out, toOut(markupAt), next, author, idFor, time)) return refuse();\n continue;\n }\n if (rawStep instanceof ReplaceAroundStep || structureStart !== null) {\n // A list or quote change: the steps are made as they are, in a document that is the same as\n // the original's so far.\n const touchesText =\n rawStep instanceof ReplaceStep &&\n (hasInline(doc.slice(rawStep.from, rawStep.to).content) ||\n hasInline(rawStep.slice.content));\n if (\n !trackers ||\n touchesText ||\n !(rawStep instanceof ReplaceAroundStep || rawStep instanceof ReplaceStep)\n )\n return refuse();\n if (structureStart === null) {\n if (!out.doc.eq(doc)) return refuse();\n structureStart = out.steps.length;\n structureBefore = out.doc;\n }\n if (out.maybeStep(rawStep).failed) return refuse();\n continue;\n }\n if (!(rawStep instanceof ReplaceStep)) return refuse();\n movesPositions = true;\n const step = rawStep as ReplaceStep & { from: number; to: number; slice: Slice };\n const outStart = out.steps.length;\n const prev = toOut;\n let from = prev(step.from);\n let to = Math.max(from, prev(step.to));\n // A whole node in the range stays, marked deleted.\n let keptWhole = false;\n\n // 1. Deletion: mark it; your own insertions are deleted for real. A whole node in the range (a\n // table, a row, an image, a line, an empty paragraph) carries the deletion.\n if (to > from) {\n const own: { from: number; to: number }[] = [];\n const plain: { from: number; to: number }[] = [];\n const whole: number[] = [];\n out.doc.nodesBetween(from, to, (node, pos) => {\n const start = Math.max(pos, from);\n const end = Math.min(pos + node.nodeSize, to);\n if (start >= end) return false;\n if (!node.isInline) {\n if (pos < from || pos + node.nodeSize > to) return true;\n const s = blockSuggestion(node.attrs.suggestion);\n if (s?.change === 'insert' && s.author === author.id) {\n own.push({ from: pos, to: pos + node.nodeSize });\n return false;\n }\n if (s?.change === 'delete') return false;\n // A node that carries another suggestion keeps it: what is inside it is marked instead.\n if (!carries(node) || s) return true;\n whole.push(pos);\n return false;\n }\n const here = around(out.doc, pos, author.id);\n if (here.deleted) return false;\n const mine =\n here.own ||\n node.marks.some((m) => m.type === types.insert && m.attrs.author === author.id);\n if (mine) own.push({ from: start, to: end });\n else if (!types.delete.isInSet(node.marks)) plain.push({ from: start, to: end });\n return false;\n });\n let deleteId: string | null = null;\n if (plain.length) {\n const first = plain[0]!;\n const mark =\n neighbourMark(out.doc, first.from, types.delete, author.id) ??\n neighbourMark(out.doc, plain[plain.length - 1]!.to, types.delete, author.id) ??\n types.delete.create({ id: newId(), author: author.id, name: author.name, time });\n for (const range of plain) out.addMark(range.from, range.to, mark);\n deleteId = mark.attrs.id as string;\n }\n for (const pos of whole) {\n out.setNodeAttribute(\n pos,\n 'suggestion',\n nodeValue('delete', deleteId ?? idFor(), author, time),\n );\n }\n // From inside one text block to inside another: the break between them is deleted too, and\n // accepting joins what is left of the two (as deleting across them does outside suggesting mode).\n const $start = out.doc.resolve(from);\n const $end = out.doc.resolve(to);\n const last = $end.parent;\n if (\n $start.parent !== last &&\n $start.parent.isTextblock &&\n last.isTextblock &&\n $start.depth === $end.depth &&\n $end.start() > from &&\n carries(last) &&\n !last.attrs.suggestion &&\n !whole.includes($end.before())\n ) {\n out.setNodeAttribute($end.before(), 'suggestion', {\n id: deleteId ?? idFor(),\n author: author.id,\n name: author.name,\n time,\n change: 'join',\n depth: $end.depth - $start.sharedDepth(to),\n });\n }\n if (plain.length || whole.length) {\n keptDeletion = true;\n if (markupChanged) return refuse();\n }\n keptWhole = whole.length > 0;\n for (const range of own.sort((a, b) => b.from - a.from)) out.delete(range.from, range.to);\n const map = out.mapping.slice(outStart);\n from = map.map(from, 1);\n to = map.map(to, -1);\n const sel = state.selection;\n if (tr.steps.length === 1 && step.slice.size === 0) {\n // Delete (forward) with the cursor at the start: the cursor jumps over the marked text.\n if (sel.empty && sel.from === step.from && tr.selection.head === step.from) {\n forwardDeleteEnd = to;\n }\n // A selected node deleted (an image, a table): the cursor goes after it.\n if (sel instanceof NodeSelection && whole.includes(prev(sel.from))) {\n afterDeleted = map.map(prev(sel.to), 1);\n }\n }\n }\n\n // 2. Insertion goes after the marked deleted text, marked \"inserted\". If the cursor is\n // right before the deleted text (a word erased with Backspace, then typing), it goes after it too: \"~~May~~ June\".\n // The empty paragraph a deletion puts in place of the only block (a table deleted from a\n // document with nothing else): not needed while the deleted node stays.\n const filler =\n keptWhole &&\n step.slice.content.childCount === 1 &&\n !step.slice.openStart &&\n !!step.slice.content.firstChild!.isTextblock &&\n !step.slice.content.firstChild!.content.size;\n if (step.slice.size > 0 && !filler) {\n let at = to;\n // Inside your own new node (text typed into a table you inserted): part of it, as it is.\n if (around(out.doc, at, author.id).own) {\n const $in = out.doc.resolve(at);\n const ownBlock = $in.parent.isTextblock\n ? blockSuggestion($in.parent.attrs.suggestion)\n : null;\n insertAt(out, at, step.slice);\n // A break in your own new block: the block it makes is new as well (the same suggestion).\n if (ownBlock?.change === 'insert' && step.slice.openEnd > 0) {\n const $end = out.doc.resolve(at + step.slice.size);\n if ($end.parent.isTextblock && !$end.parent.attrs.suggestion)\n out.setNodeAttribute($end.before(), 'suggestion', ownBlock);\n }\n if (tr.steps.length === 1) inserted = { at, from: step.from, size: step.slice.size };\n const inverse = step.getMap().invert();\n const outMap = out.mapping.slice(outStart);\n toOut = (pos) => outMap.map(prev(inverse.map(pos, -1)), 1);\n continue;\n }\n if (!step.slice.openStart) {\n for (let next = out.doc.resolve(at).nodeAfter; next && types.delete.isInSet(next.marks);) {\n at += next.nodeSize;\n next = out.doc.resolve(at).nodeAfter;\n }\n }\n const mark =\n neighbourMark(out.doc, at, types.insert, author.id) ??\n types.insert.create({ id: newId(), author: author.id, name: author.name, time });\n const $at = out.doc.resolve(at);\n // A node inserted with text shares the text's suggestion; nodes alone, the edit's.\n const nodeSuggestion = () =>\n nodeValue(\n 'insert',\n hasInline(step.slice.content) ? (mark.attrs.id as string) : idFor(),\n author,\n time,\n );\n const content = withInsert(\n step.slice.content,\n mark,\n step.slice.openStart ? null : $at.parent.type,\n step.slice.openStart,\n step.slice.openEnd,\n nodeSuggestion,\n );\n insertAt(out, at, new Slice(content, step.slice.openStart, step.slice.openEnd));\n if (tr.steps.length === 1) inserted = { at, from: step.from, size: step.slice.size };\n // Put in a text block with blocks of its own (a line, pasted paragraphs, a new paragraph):\n // in the middle, the block after it is the second half of the one it went into, a new\n // paragraph break that rejecting joins again; at the end of the block, the last block is new\n // as a whole (with a new list item around it), and rejecting removes it.\n const { openStart, openEnd } = step.slice;\n if (openStart > 0 && openStart === openEnd && $at.parent.isTextblock) {\n const $end = out.doc.resolve(at + step.slice.size);\n const outer = $end.depth >= openEnd ? $end.before($end.depth - openEnd + 1) : -1;\n // At the end, and nothing that was there moved into the new block (an item's nested list\n // would): new as a whole; otherwise a break.\n const atEnd =\n $at.parentOffset === $at.parent.content.size &&\n outer >= 0 &&\n outer + out.doc.nodeAt(outer)!.nodeSize === at + step.slice.size + openEnd;\n const target = atEnd ? outer : $end.depth > 0 ? $end.before() : -1;\n const node = target >= 0 ? out.doc.nodeAt(target) : null;\n if ($end.parent.isTextblock && node && carries(node)) {\n out.setNodeAttribute(\n target,\n 'suggestion',\n atEnd\n ? nodeValue('insert', mark.attrs.id as string, author, time)\n : {\n id: mark.attrs.id,\n author: author.id,\n name: author.name,\n time,\n change: 'split',\n depth: openEnd,\n },\n );\n }\n }\n }\n\n const inverse = step.getMap().invert();\n const outMap = out.mapping.slice(outStart);\n toOut = (pos) => outMap.map(prev(inverse.map(pos, -1)), 1);\n }\n\n // A list or quote change: on the item or the quote, or not a suggestion at all.\n if (structureStart !== null) {\n const done = suggestStructure(\n out,\n structureStart,\n structureBefore!,\n state,\n author,\n idFor,\n time,\n );\n if (!done) return refuse();\n if (done === out) {\n // Made as it is: the same positions as in the original transaction.\n out.setSelection(tr.selection.map(out.doc, out.mapping.slice(out.steps.length)));\n } else {\n // Not made: the selection stays where it was.\n out = done;\n out.setSelection(state.selection.map(out.doc, out.mapping));\n }\n } else if (!movesPositions) {\n // Formatting and markup only: positions are the same, the selection too (text, a node or everything).\n out.setSelection(tr.selection.map(out.doc, out.mapping.slice(out.steps.length)));\n } else if (forwardDeleteEnd !== null) {\n out.setSelection(TextSelection.create(out.doc, forwardDeleteEnd));\n } else if (afterDeleted !== null) {\n out.setSelection(Selection.near(out.doc.resolve(afterDeleted), 1));\n } else if (inserted) {\n const { at, from, size } = inserted;\n const { anchor, head, empty } = tr.selection;\n const inside = (pos: number) => pos >= from && pos <= from + size;\n if (empty && head === from + size) {\n // Typing: right after what was typed.\n out.setSelection(TextSelection.create(out.doc, at + size));\n } else if (inside(anchor) && inside(head)) {\n // Somewhere in what was inserted (the first cell of a new table): the same place in it.\n out.setSelection(mapSelection(tr.selection, out.doc, (pos) => pos - from + at));\n } else if (empty) {\n const $end = out.doc.resolve(at + size);\n out.setSelection(TextSelection.between($end, $end));\n } else out.setSelection(mapSelection(tr.selection, out.doc, toOut));\n } else {\n out.setSelection(mapSelection(tr.selection, out.doc, toOut));\n }\n for (const key of ['addToHistory', 'uiEvent', 'paste', 'scrollIntoView'] as const) {\n const value = tr.getMeta(key);\n if (value !== undefined) out.setMeta(key, value);\n }\n if (tr.scrolledIntoView) out.scrollIntoView();\n return out;\n}\n\n/** What a suggested format changed on a piece of text: mark names it got and lost. */\nfunction formatChange(node: PMNode, mark: Mark): { added: string[]; removed: string[] } {\n const before = formatMarks(node.type.schema, mark.attrs.before);\n const now = formatting(node.marks);\n const added = now.filter((m) => !m.isInSet(before)).map((m) => m.type.name);\n const removed = before\n .filter((m) => !m.isInSet(now) && !added.includes(m.type.name))\n .map((m) => m.type.name);\n return { added, removed };\n}\n\nconst addAll = (list: string[], more: string[]) => {\n for (const name of more) if (!list.includes(name)) list.push(name);\n};\n\n/** All suggestions in the document (consecutive parts of one suggestion are merged). */\nexport function listSuggestions(doc: PMNode): Suggestion[] {\n const types = typesOf(doc.type.schema);\n const result: Suggestion[] = [];\n doc.descendants((node, pos) => {\n if (!node.isText) {\n // A suggestion the node carries: from…to is the whole node.\n const block = blockSuggestion(node.attrs.suggestion);\n if (block) {\n result.push({\n id: block.id,\n kind: block.change,\n author: { id: block.author, name: block.name },\n time: block.time,\n from: pos,\n to: pos + node.nodeSize,\n text: node.isLeaf ? (node.type.spec.leafText?.(node) ?? '') : node.textContent,\n node: node.type.name,\n ...(block.before ? { before: block.before } : {}),\n ...(block.depth ? { depth: block.depth } : {}),\n });\n }\n if (!node.isInline) return true;\n }\n for (const mark of node.marks) {\n const kind =\n mark.type === types.insert\n ? 'insert'\n : mark.type === types.delete\n ? 'delete'\n : mark.type === types.format\n ? 'format'\n : null;\n if (!kind) continue;\n const last = result[result.length - 1];\n // Not text (a mention, a footnote number, a line break): its text form, if it has one.\n const text = node.isText ? node.text! : (node.type.spec.leafText?.(node) ?? '');\n const change = kind === 'format' ? formatChange(node, mark) : null;\n if (last && last.id === mark.attrs.id && last.kind === kind && last.to === pos) {\n last.to = pos + node.nodeSize;\n last.text += text;\n if (change) {\n addAll(last.added!, change.added);\n addAll(last.removed!, change.removed);\n }\n } else {\n result.push({\n id: mark.attrs.id as string,\n kind,\n author: { id: mark.attrs.author as string, name: mark.attrs.name as string },\n time: Number(mark.attrs.time) || 0,\n from: pos,\n to: pos + node.nodeSize,\n text,\n ...(change ?? {}),\n });\n }\n }\n return false;\n });\n return result;\n}\n\n/** A suggested format accepted (the mark goes) or rejected (the text gets back its formatting). */\nfunction resolveFormat(tr: Transaction, s: Suggestion, action: 'accept' | 'reject'): void {\n const type = typesOf(tr.doc.type.schema).format;\n const pieces: { from: number; to: number; node: PMNode; mark: Mark }[] = [];\n tr.doc.nodesBetween(s.from, s.to, (node, pos) => {\n if (!node.isInline) return true;\n const mark = node.marks.find((m) => m.type === type && m.attrs.id === s.id);\n if (mark) {\n pieces.push({\n from: Math.max(pos, s.from),\n to: Math.min(pos + node.nodeSize, s.to),\n node,\n mark,\n });\n }\n return false;\n });\n for (const { from, to, node, mark } of pieces) {\n if (action === 'reject') {\n const before = formatMarks(tr.doc.type.schema, mark.attrs.before);\n for (const m of formatting(node.marks)) if (!m.isInSet(before)) tr.removeMark(from, to, m);\n for (const m of before) if (!m.isInSet(node.marks)) tr.addMark(from, to, m);\n }\n tr.removeMark(from, to, mark);\n }\n}\n\n/**\n * A node's suggested type or style accepted (the node forgets what it was) or rejected (it gets\n * back its type and attributes; a type that can't hold what is in it now leaves it as it is).\n * Attributes it didn't remember (a column's widths) stay as they are.\n */\nfunction resolveBlock(tr: Transaction, s: Suggestion, action: 'accept' | 'reject'): void {\n const pos = s.from;\n const node = tr.doc.nodeAt(pos);\n if (!node) return;\n const type = action === 'reject' ? tr.doc.type.schema.nodes[s.before!.type] : undefined;\n const $pos = tr.doc.resolve(pos);\n // What it was came from HTML or JSON too: the type has to fit here and hold what is in the node.\n if (\n type?.spec.attrs &&\n 'suggestion' in type.spec.attrs &&\n $pos.parent.canReplaceWith($pos.index(), $pos.index() + 1, type) &&\n (node.isLeaf ? type.isLeaf : !type.isLeaf && type.validContent(node.content))\n ) {\n const attrs = Object.fromEntries(\n Object.entries(s.before!.attrs).filter(([key]) => key in type.spec.attrs!),\n );\n try {\n tr.setNodeMarkup(pos, type, { ...node.attrs, ...attrs, suggestion: null }, node.marks);\n return;\n } catch {\n // An attribute of the wrong kind (a number expected): the node stays as it is.\n }\n }\n tr.setNodeAttribute(pos, 'suggestion', null);\n}\n\n/**\n * Removes a whole node (a rejected insertion, an accepted deletion). If its parent can't be without\n * it, the parent goes too when it holds only this node (the last row takes the table with it); the\n * only block of the document or of a cell becomes an empty paragraph.\n */\nfunction removeNode(tr: Transaction, pos: number): void {\n const node = tr.doc.nodeAt(pos);\n if (!node) return;\n const $pos = tr.doc.resolve(pos);\n let from = pos;\n let to = pos + node.nodeSize;\n for (let depth = $pos.depth; ; depth--) {\n const parent = $pos.node(depth);\n const index = $pos.index(depth);\n if (parent.canReplace(index, index + 1)) {\n tr.delete(from, to);\n return;\n }\n if (depth === 0 || parent.childCount > 1 || parent.type.spec.isolating) {\n const fill = parent.type.contentMatch.defaultType?.createAndFill();\n if (fill && parent.canReplace(index, index + 1, Fragment.from(fill)))\n tr.replaceWith(from, to, fill);\n return;\n }\n from = $pos.before(depth);\n to = $pos.after(depth);\n }\n}\n\n/** Accept or reject suggestions (all of them, or those with the given ids). */\nexport function resolveSuggestions(\n state: EditorState,\n action: 'accept' | 'reject',\n ids?: readonly string[],\n): Transaction {\n const types = typesOf(state.schema);\n const tr = state.tr.setMeta(OWN, true);\n const chosen = listSuggestions(state.doc).filter((s) => !ids || ids.includes(s.id));\n tr.setMeta(RESOLVED, { action, ids: [...new Set(chosen.map((s) => s.id))] });\n // Formats first: they don't move text, and the text they are on may go next.\n for (const s of chosen) if (s.kind === 'format') resolveFormat(tr, s, action);\n // Suggestions a node carries. Some change the document's structure, after the text is done: a\n // rejected style gives the node its type back; a rejected new paragraph break and an accepted\n // deleted one join two blocks; a rejected new node and an accepted deletion remove it; a rejected\n // wrap and an accepted unwrap lift the node. The others just forget the suggestion.\n const removals: Suggestion[] = [];\n const pending: { s: Suggestion; op: 'join' | 'style' | 'lift' }[] = [];\n for (const s of chosen) {\n if (!s.node) continue;\n const reject = action === 'reject';\n // What deciding does to the node: nothing but forgetting the suggestion, or a change.\n const op =\n s.kind === 'block'\n ? reject && 'style'\n : s.kind === 'join'\n ? reject\n ? !!s.before && 'style'\n : 'join'\n : s.kind === 'split'\n ? reject && 'join'\n : s.kind === 'insert'\n ? reject && 'remove'\n : s.kind === 'delete'\n ? !reject && 'remove'\n : s.kind === 'wrap'\n ? reject && 'lift'\n : !reject && 'lift';\n if (!op) tr.setNodeAttribute(s.from, 'suggestion', null);\n else if (op === 'remove') removals.push(s);\n else pending.push({ s, op });\n }\n // Text, from the end, so positions ahead don't shift. A block whose text goes stays: a new or\n // deleted block carries its own suggestion, and a new paragraph break is a suggestion too.\n for (const s of [...chosen].sort((a, b) => b.from - a.from)) {\n if ((s.kind !== 'insert' && s.kind !== 'delete') || s.node) continue;\n if ((s.kind === 'insert') === (action === 'reject')) tr.delete(s.from, s.to);\n else tr.removeMark(s.from, s.to, s.kind === 'insert' ? types.insert : types.delete);\n }\n // The node at its place now (it may have gone with something around it), or null.\n const nodeNow = (s: Suggestion) => {\n const mapped = tr.mapping.mapResult(s.from, 1);\n const node = mapped.deleted ? null : tr.doc.nodeAt(mapped.pos);\n return node?.type.name === s.node ? mapped.pos : null;\n };\n for (const s of removals.sort((a, b) => b.from - a.from)) {\n const pos = nodeNow(s);\n if (pos !== null) removeNode(tr, pos);\n }\n // The structure: edits were made in some order (a style, then a list; a list, then Enter in it;\n // Enter, then a list) and are undone in the reverse one, which isn't recorded. So each pass makes\n // what can be made now (joins, then styles, then lifts), until nothing more can be; what still\n // can't is forgotten.\n const apply = ({ s, op }: (typeof pending)[number], last: boolean): boolean => {\n const pos = nodeNow(s);\n if (pos === null) return true;\n if (op === 'join') {\n const boundary = pos - ((s.depth ?? 1) - 1);\n if (!canJoin(tr.doc, boundary)) return false;\n try {\n tr.join(boundary, s.depth ?? 1);\n } catch {\n // A level inside doesn't join (a paragraph after an item's nested list): not now.\n return false;\n }\n return true;\n }\n if (op === 'style') {\n if (!last && !restorable(tr.doc, pos, s)) return false;\n resolveBlock(tr, { ...s, from: pos }, 'reject');\n return true;\n }\n if (liftOnce(new Transform(tr.doc), pos) === null) return false;\n tr.setNodeAttribute(pos, 'suggestion', null);\n let at: number | null = pos;\n for (let level = 0; level < (s.depth ?? 1) && at !== null; level++) {\n const contentStart = liftOnce(tr, at);\n at = contentStart === null ? null : wrapperAt(tr.doc, contentStart);\n }\n return true;\n };\n // One at a time: after each, the first that can be made in this order (a lift can make possible\n // a join that has to come before the next lift).\n const order = { join: 0, style: 1, lift: 2 } as const;\n const left = pending.sort((a, b) => order[a.op] - order[b.op] || b.s.from - a.s.from);\n for (let done = 0; done >= 0;) {\n done = left.findIndex((item) => apply(item, false));\n if (done >= 0) left.splice(done, 1);\n }\n for (const item of left) {\n if (item.op === 'style') apply(item, true);\n else {\n const pos = nodeNow(item.s);\n if (pos !== null) tr.setNodeAttribute(pos, 'suggestion', null);\n }\n }\n return tr;\n}\n\n/** Whether a node can get back the type and style it remembers, where it is now. */\nfunction restorable(doc: PMNode, pos: number, s: Suggestion): boolean {\n const node = doc.nodeAt(pos);\n const type = s.before ? doc.type.schema.nodes[s.before.type] : undefined;\n if (!node || !type) return false;\n const $pos = doc.resolve(pos);\n return (\n $pos.parent.canReplaceWith($pos.index(), $pos.index() + 1, type) &&\n (node.isLeaf ? type.isLeaf : !type.isLeaf && type.validContent(node.content))\n );\n}\n\n/** The document without suggestions: as if all were accepted (accept) or all rejected (reject). */\nexport function suggestionsResult(editor: Editor, action: 'accept' | 'reject'): PMNode {\n return resolveSuggestions(editor.view.state, action).doc;\n}\n\n/**\n * Pasted or dropped content is new content of whoever pastes it: suggestions in it (from another\n * document, from a web page) are dropped, so nobody's name can be put on a suggestion they didn't make.\n */\nfunction withoutSuggestions(fragment: Fragment): Fragment {\n const nodes: PMNode[] = [];\n fragment.forEach((node) => {\n const marks = node.marks.filter((m) => !m.type.name.startsWith('suggestion_'));\n if (node.isText) {\n nodes.push(node.mark(marks));\n return;\n }\n const attrs = node.attrs.suggestion != null ? { ...node.attrs, suggestion: null } : node.attrs;\n nodes.push(node.type.create(attrs, withoutSuggestions(node.content), marks));\n });\n return Fragment.from(nodes);\n}\n\n/** When an edit last couldn't be a suggestion, per editor (its notice isn't repeated right away). */\nconst refusedAt = new WeakMap<Editor, number>();\n\nexport function isSuggesting(state: EditorState): boolean {\n return suggestionsKey.getState(state)?.enabled ?? false;\n}\n\nexport function setSuggesting(editor: Editor, enabled: boolean): void {\n const { state, dispatch } = editor.view;\n dispatch(state.tr.setMeta(suggestionsKey, { enabled }).setMeta(OWN, true));\n editor.updateUI();\n}\n\nexport default definePlugin({\n name: 'suggestions',\n toolbar: 'suggestions reviewsuggestions suggestionspanel',\n marks: {\n suggestion_insert: markSpec('insert'),\n suggestion_delete: markSpec('delete'),\n suggestion_format: formatSpec(),\n },\n nodeAttributes: { suggestion: blockAttribute },\n prosemirrorPlugins: (editor) => {\n const options = (editor.options.pluginOptions?.suggestions ?? {}) as SuggestionsOptions;\n let cache: { doc: PMNode; set: DecorationSet } | null = null;\n return [\n new Plugin<{ enabled: boolean }>({\n key: suggestionsKey,\n state: {\n init: () => ({ enabled: !!(options.enabled || options.force) }),\n apply(tr, value) {\n const meta = tr.getMeta(suggestionsKey) as { enabled: boolean } | undefined;\n if (!meta) return value;\n return { enabled: options.force ? true : meta.enabled };\n },\n },\n props: {\n attributes: (state): Record<string, string> =>\n suggestionsKey.getState(state)?.enabled ? { class: 'nova-suggesting' } : {},\n transformPasted: (slice) =>\n new Slice(withoutSuggestions(slice.content), slice.openStart, slice.openEnd),\n decorations(state) {\n if (cache?.doc === state.doc) return cache.set;\n const labels = pickLabels(editor, 'suggestions', LABELS);\n const time = new Intl.DateTimeFormat(editor.options.language ?? 'en', {\n dateStyle: 'medium',\n timeStyle: 'short',\n });\n const set = DecorationSet.create(\n state.doc,\n listSuggestions(state.doc).map((s) =>\n // Text: on the text; a suggestion a node carries: on the node.\n (s.node ? Decoration.node : Decoration.inline)(s.from, s.to, {\n title:\n (s.kind === 'insert' || s.kind === 'split'\n ? labels.inserted\n : s.kind === 'delete' || s.kind === 'join'\n ? labels.deleted\n : labels.formatted\n ).replace('{name}', s.author.name || labels.guest) +\n (s.time ? ` · ${time.format(s.time)}` : ''),\n // A whole node inserted or deleted: its text looks inserted or deleted, the node is outlined.\n class:\n s.node && (s.kind === 'insert' || s.kind === 'delete')\n ? `nova-sugg-${s.kind} nova-sugg-node`\n : `nova-sugg-${s.kind}`,\n style: `--nova-suggestion: ${suggestionColor(s.author.id || s.author.name)}`,\n }),\n ),\n );\n cache = { doc: state.doc, set };\n return set;\n },\n },\n }),\n keymap({\n // Ctrl/Cmd+Alt+Shift+E toggles suggesting mode.\n 'Mod-Alt-Shift-e': () => {\n if (options.force) return false;\n setSuggesting(editor, !isSuggesting(editor.view.state));\n return true;\n },\n }),\n ];\n },\n transformTransaction(tr, state, editor) {\n if (!isSuggesting(state)) return tr;\n const options = (editor.options.pluginOptions?.suggestions ?? {}) as SuggestionsOptions;\n const labels = pickLabels(editor, 'suggestions', LABELS);\n const author = {\n id: USER_ID_RE.test(options.author?.id ?? '') ? options.author!.id : 'guest',\n name: String(options.author?.name || labels.guest).slice(0, 80),\n };\n return suggestTransaction(tr, state, author, () => {\n // Said at most every few seconds: a key held down shouldn't repeat it.\n const now = Date.now();\n if (now - (refusedAt.get(editor) ?? 0) < 3000) return;\n refusedAt.set(editor, now);\n editor.ui.notify(options.force ? labels.unsupported : labels.unsupportedDirect);\n });\n },\n load: () => import('./suggestions-ui'),\n});\n"],"mappings":";;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,YAAY,qBAAqB;AAC1C,SAAS,cAAc;AA4FvB,IAAM,QAAQ;AACd,IAAM,aAAa;AAEZ,IAAM,SAAS;AAAA,EACpB,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,WAAW;AAAA,IACX,MAAM;AAAA,IACN,UAAU;AAAA,IACV,UAAU;AAAA,IACV,SAAS;AAAA,IACT,WAAW;AAAA,IACX,SAAS;AAAA,IACT,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,IACb,mBAAmB;AAAA,EACrB;AACF;AAEO,IAAM,iBAAiB,IAAI,UAAgC,kBAAkB;AAG7E,IAAM,MAAM;AAGZ,IAAM,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AAO,QAAQ,MAAM;AAEjD,YAAM,MAAM,KAAK,IAAI;AACrB,UAAI,OAAO,UAAU,IAAI,MAAM,KAAK,KAAK,IAAM;AAC/C,gBAAU,IAAI,QAAQ,GAAG;AACzB,aAAO,GAAG,OAAO,QAAQ,QAAQ,OAAO,cAAc,OAAO,iBAAiB;AAAA,IAChF,CAAC;AAAA,EACH;AAAA,EACA,MAAM,MAAM,OAAO,8BAAkB;AACvC,CAAC;","names":["before","check","s","inverse","outMap"]}
@@ -0,0 +1,29 @@
1
+ import {
2
+ definePlugin
3
+ } from "./chunk-V7WUHUHM.js";
4
+
5
+ // src/plugins/advtable.ts
6
+ var SERIES_RE = /^[a-z][\w-]{0,39}$/i;
7
+ function seriesName(value) {
8
+ return typeof value === "string" && SERIES_RE.test(value) ? value : null;
9
+ }
10
+ var seriesAttribute = {
11
+ nodes: ["table_cell", "table_header"],
12
+ default: null,
13
+ parse: (dom) => seriesName(dom.getAttribute("data-series")),
14
+ render: (value) => {
15
+ const name = seriesName(value);
16
+ return name ? { "data-series": name } : {};
17
+ }
18
+ };
19
+ var advtable_default = definePlugin({
20
+ name: "advtable",
21
+ nodeAttributes: { series: seriesAttribute },
22
+ load: () => import("./advtable-ui-JAVJY4L4.js")
23
+ });
24
+
25
+ export {
26
+ seriesName,
27
+ advtable_default
28
+ };
29
+ //# sourceMappingURL=chunk-IFSD6O5M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/plugins/advtable.ts"],"sourcesContent":["import { definePlugin } from '../plugins';\nimport type { NodeAttribute } from '../schema';\n\n/**\n * The advtable plugin (advanced tables, named as in TinyMCE): a column of row numbers (or letters,\n * or your own series) that stays in order as rows are added, deleted and sorted, and sorting by any\n * column or row, of the whole table or the selected cells. `plugins: ['advtable']`.\n *\n * In the first load is only what the document holds: the cells of the numbers column carry\n * `data-series=\"numeric\"` (the series' name), so the column is found by its cells, not by its place,\n * and a number is never written over your text. The rest is advtable-ui.ts.\n */\n\nconst SERIES_RE = /^[a-z][\\w-]{0,39}$/i;\n\n/** A series' name from the HTML or JSON, or null. */\nexport function seriesName(value: unknown): string | null {\n return typeof value === 'string' && SERIES_RE.test(value) ? value : null;\n}\n\nconst seriesAttribute: NodeAttribute = {\n nodes: ['table_cell', 'table_header'],\n default: null,\n parse: (dom) => seriesName(dom.getAttribute('data-series')),\n render: (value): Record<string, string> => {\n const name = seriesName(value);\n return name ? { 'data-series': name } : {};\n },\n};\n\nexport default definePlugin({\n name: 'advtable',\n nodeAttributes: { series: seriesAttribute },\n load: () => import('./advtable-ui'),\n});\n"],"mappings":";;;;;AAaA,IAAM,YAAY;AAGX,SAAS,WAAW,OAA+B;AACxD,SAAO,OAAO,UAAU,YAAY,UAAU,KAAK,KAAK,IAAI,QAAQ;AACtE;AAEA,IAAM,kBAAiC;AAAA,EACrC,OAAO,CAAC,cAAc,cAAc;AAAA,EACpC,SAAS;AAAA,EACT,OAAO,CAAC,QAAQ,WAAW,IAAI,aAAa,aAAa,CAAC;AAAA,EAC1D,QAAQ,CAAC,UAAkC;AACzC,UAAM,OAAO,WAAW,KAAK;AAC7B,WAAO,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;AAAA,EAC3C;AACF;AAEA,IAAO,mBAAQ,aAAa;AAAA,EAC1B,MAAM;AAAA,EACN,gBAAgB,EAAE,QAAQ,gBAAgB;AAAA,EAC1C,MAAM,MAAM,OAAO,2BAAe;AACpC,CAAC;","names":[]}
@@ -1,16 +1,7 @@
1
- import {
2
- MAX_GRID,
3
- createTable,
4
- createTableGridPanel,
5
- insertTable,
6
- tableRect
7
- } from "./chunk-KWXFL4WS.js";
8
1
  import {
9
2
  classAttr,
10
3
  cssValue
11
- } from "./chunk-FCMZ7TUQ.js";
12
- import "./chunk-JPJVTB45.js";
13
- import "./chunk-PVFKXRID.js";
4
+ } from "./chunk-6BJEOL5V.js";
14
5
 
15
6
  // src/table.ts
16
7
  import { keymap } from "prosemirror-keymap";
@@ -50,8 +41,8 @@ var nextCellOrNewRow = (state, dispatch, view) => {
50
41
  };
51
42
  function tablePlugins() {
52
43
  return [
53
- // defaultCellMinWidth — минимум для столбцов без заданной ширины (по умолчанию 100px:
54
- // таблица из 5+ столбцов раньше времени вылезала за край узкого редактора).
44
+ // defaultCellMinWidth is the minimum for columns without a set width (100px by default:
45
+ // a table of 5+ columns ran off the edge of a narrow editor too early).
55
46
  columnResizing({ cellMinWidth: 48, defaultCellMinWidth: 48, View: NovaTableView }),
56
47
  tableEditing(),
57
48
  keymap({
@@ -69,7 +60,7 @@ var tableCommands = {
69
60
  deleteColumn,
70
61
  mergeCells,
71
62
  splitCell,
72
- // Без устаревшей логики (та смотрит на угловую ячейку и путает строку/столбец заголовков).
63
+ // Without the outdated logic (it looks at the corner cell and confuses the header row and column).
73
64
  toggleHeaderRow: toggleHeader("row"),
74
65
  toggleHeaderColumn: toggleHeader("column"),
75
66
  deleteTable
@@ -105,7 +96,10 @@ function numericValue(text) {
105
96
  if (!/^[+-]?\d+(\.\d+)?$/.test(cleaned)) return null;
106
97
  return Number(cleaned);
107
98
  }
108
- function sortTarget(state) {
99
+ function isHeader(cell, state) {
100
+ return cell?.type === state.schema.nodes.table_header;
101
+ }
102
+ function tableGrid(state) {
109
103
  if (!isInTable(state)) return null;
110
104
  const rect = selectedRect(state);
111
105
  const table = rect.table;
@@ -114,49 +108,115 @@ function sortTarget(state) {
114
108
  if (node.attrs.colspan > 1 || node.attrs.rowspan > 1) merged = true;
115
109
  return !merged && node.type.spec.tableRole !== "cell" && node.type.spec.tableRole !== "header_cell";
116
110
  });
117
- if (merged) return null;
118
- const nodes = state.schema.nodes;
111
+ if (merged) return "merged";
112
+ const rows = [];
113
+ table.forEach((row) => {
114
+ const cells = [];
115
+ row.forEach((cell) => cells.push(cell));
116
+ rows.push(cells);
117
+ });
118
+ const width = Math.min(...rows.map((cells) => cells.length));
119
119
  let headerRows = 0;
120
- for (let i = 0; i < table.childCount; i++) {
121
- let allHeaders = true;
122
- table.child(i).forEach((cell) => {
123
- if (cell.type !== nodes.table_header) allHeaders = false;
124
- });
125
- if (!allHeaders) break;
120
+ while (headerRows < rows.length && rows[headerRows].every((c) => isHeader(c, state)))
126
121
  headerRows++;
122
+ let headerColumns = 0;
123
+ while (headerColumns < width && rows.every(
124
+ (cells) => isHeader(cells[headerColumns], state) || !!cells[headerColumns]?.attrs.series
125
+ ))
126
+ headerColumns++;
127
+ return {
128
+ pos: rect.tableStart - 1,
129
+ table,
130
+ rows,
131
+ width,
132
+ headerRows,
133
+ headerColumns,
134
+ rect: { left: rect.left, right: rect.right, top: rect.top, bottom: rect.bottom }
135
+ };
136
+ }
137
+ function sortOrder(texts, direction, locale) {
138
+ const numbers = texts.map(numericValue);
139
+ const numeric = texts.every((t, i) => t === "" || numbers[i] !== null);
140
+ const collator = new Intl.Collator(locale, { numeric: true, sensitivity: "base" });
141
+ return texts.map((_, i) => i).sort((a, b) => {
142
+ const ta = texts[a];
143
+ const tb = texts[b];
144
+ if (!ta || !tb) return ta ? -1 : tb ? 1 : a - b;
145
+ const cmp = numeric ? numbers[a] - numbers[b] : collator.compare(ta, tb);
146
+ return (direction === "asc" ? cmp : -cmp) || a - b;
147
+ });
148
+ }
149
+ function sortProblem(state, options) {
150
+ const grid = tableGrid(state);
151
+ if (grid === null) return "few";
152
+ if (typeof grid === "string") return grid;
153
+ return sortRange(grid, options) ? null : "few";
154
+ }
155
+ function sortRange(grid, options) {
156
+ const byColumn = options.by === "column";
157
+ const first = byColumn ? grid.headerRows : grid.headerColumns;
158
+ const count = byColumn ? grid.rows.length : grid.width;
159
+ let [from, to] = [first, count];
160
+ if (options.scope === "selection") {
161
+ from = Math.max(first, byColumn ? grid.rect.top : grid.rect.left);
162
+ to = Math.min(count, byColumn ? grid.rect.bottom : grid.rect.right);
127
163
  }
128
- if (table.childCount - headerRows < 2) return null;
129
- return { pos: rect.tableStart - 1, table, column: rect.left, headerRows };
164
+ const key = options.index ?? (byColumn ? grid.rect.left : grid.rect.top);
165
+ const keyCount = byColumn ? grid.width : grid.rows.length;
166
+ if (!Number.isInteger(key) || key < 0 || key >= keyCount) return null;
167
+ return to - from >= 2 ? [from, to] : null;
130
168
  }
131
- function sortTable(direction, locale) {
169
+ function sortTableBy(options, locale) {
132
170
  return (state, dispatch) => {
133
- const target = sortTarget(state);
134
- if (!target) return false;
171
+ const grid = tableGrid(state);
172
+ if (!grid || typeof grid === "string") return false;
173
+ const range = sortRange(grid, options);
174
+ if (!range) return false;
135
175
  if (dispatch) {
136
- const { table, column, headerRows, pos } = target;
137
- const rows = [];
138
- table.forEach((row) => rows.push(row));
139
- const head = rows.slice(0, headerRows);
140
- const body = rows.slice(headerRows);
141
- const texts = body.map(
142
- (row) => column < row.childCount ? row.child(column).textContent.trim() : ""
143
- );
144
- const numbers = texts.map(numericValue);
145
- const numeric = texts.every((t, i) => t === "" || numbers[i] !== null);
146
- const collator = new Intl.Collator(locale, { numeric: true, sensitivity: "base" });
147
- const order = body.map((row, i) => ({ row, i })).sort((a, b) => {
148
- const ta = texts[a.i];
149
- const tb = texts[b.i];
150
- if (!ta || !tb) return ta ? -1 : tb ? 1 : a.i - b.i;
151
- const cmp = numeric ? numbers[a.i] - numbers[b.i] : collator.compare(ta, tb);
152
- return (direction === "asc" ? cmp : -cmp) || a.i - b.i;
153
- }).map(({ row }) => row);
154
- const sorted = table.copy(Fragment.from([...head, ...order]));
176
+ const [from, to] = range;
177
+ const { rows, table, pos } = grid;
178
+ const rowNodes = [];
179
+ table.forEach((row) => rowNodes.push(row));
180
+ let next;
181
+ if (options.by === "column") {
182
+ const column = options.index ?? grid.rect.left;
183
+ const order = sortOrder(
184
+ rows.slice(from, to).map((cells) => cells[column]?.textContent.trim() ?? ""),
185
+ options.direction,
186
+ locale
187
+ );
188
+ next = [
189
+ ...rowNodes.slice(0, from),
190
+ ...order.map((i) => rowNodes[from + i]),
191
+ ...rowNodes.slice(to)
192
+ ];
193
+ } else {
194
+ const keyRow = rows[options.index ?? grid.rect.top];
195
+ const order = sortOrder(
196
+ keyRow.slice(from, to).map((cell) => cell.textContent.trim()),
197
+ options.direction,
198
+ locale
199
+ );
200
+ next = rowNodes.map((row, r) => {
201
+ const cells = rows[r];
202
+ return row.copy(
203
+ Fragment.from([
204
+ ...cells.slice(0, from),
205
+ ...order.map((i) => cells[from + i]),
206
+ ...cells.slice(to)
207
+ ])
208
+ );
209
+ });
210
+ }
211
+ const sorted = table.copy(Fragment.from(next));
155
212
  dispatch(state.tr.replaceWith(pos, pos + table.nodeSize, sorted).scrollIntoView());
156
213
  }
157
214
  return true;
158
215
  };
159
216
  }
217
+ function sortTable(direction, locale) {
218
+ return sortTableBy({ by: "column", direction }, locale);
219
+ }
160
220
  var NovaTableView = class extends TableView {
161
221
  constructor(node, cellMinWidth) {
162
222
  super(node, cellMinWidth);
@@ -278,24 +338,22 @@ function setCellProps(props) {
278
338
  return true;
279
339
  };
280
340
  }
341
+
281
342
  export {
282
- MAX_GRID,
283
- createTable,
284
- createTableGridPanel,
285
- getCellProps,
286
- getTableProps,
287
- hasHeaderColumn,
288
- hasHeaderRow,
289
- insertTable,
290
- isCellSelection,
291
343
  isInTable,
292
344
  selectedRect,
345
+ tablePlugins,
346
+ tableCommands,
293
347
  setCellBackground,
294
- setCellProps,
295
- setTableProps,
348
+ hasHeaderRow,
349
+ hasHeaderColumn,
350
+ isCellSelection,
351
+ sortProblem,
352
+ sortTableBy,
296
353
  sortTable,
297
- tableCommands,
298
- tablePlugins,
299
- tableRect
354
+ getTableProps,
355
+ setTableProps,
356
+ getCellProps,
357
+ setCellProps
300
358
  };
301
- //# sourceMappingURL=table-SSNABG5W.js.map
359
+ //# sourceMappingURL=chunk-IO5PU52K.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/table.ts"],"sourcesContent":["import { keymap } from 'prosemirror-keymap';\nimport { Fragment, type Node as PMNode } from 'prosemirror-model';\nimport { type Command, type EditorState, type Plugin } from 'prosemirror-state';\nimport {\n addColumnAfter,\n addColumnBefore,\n addRowAfter,\n addRowBefore,\n CellSelection,\n columnResizing,\n deleteColumn,\n deleteRow,\n deleteTable,\n findTable,\n goToNextCell,\n isInTable,\n mergeCells,\n selectedRect,\n setCellAttr,\n splitCell,\n tableEditing,\n TableView,\n toggleHeader,\n} from 'prosemirror-tables';\nimport { createTable, createTableGridPanel, insertTable, MAX_GRID, tableRect } from './tables';\n\nexport { createTable, createTableGridPanel, insertTable, MAX_GRID, tableRect };\nimport { classAttr, cssValue, type CellVAlign, type NovaSchema, type TableAlign } from './schema';\n\n/** Tab moves to the next cell; in the last cell it adds a new row (as in Word and TinyMCE). */\nconst nextCellOrNewRow: Command = (state, dispatch, view) => {\n if (!isInTable(state)) return false;\n if (goToNextCell(1)(state, dispatch, view)) return true;\n if (!dispatch) return true;\n let next: EditorState = state;\n addRowAfter(state, (tr) => {\n next = state.apply(tr);\n dispatch(tr);\n });\n return goToNextCell(1)(next, dispatch, view);\n};\n\nexport function tablePlugins(): Plugin[] {\n return [\n // defaultCellMinWidth is the minimum for columns without a set width (100px by default:\n // a table of 5+ columns ran off the edge of a narrow editor too early).\n columnResizing({ cellMinWidth: 48, defaultCellMinWidth: 48, View: NovaTableView }),\n tableEditing(),\n keymap({\n Tab: nextCellOrNewRow,\n 'Shift-Tab': goToNextCell(-1),\n }),\n ];\n}\n\nexport const tableCommands = {\n addRowBefore,\n addRowAfter,\n deleteRow,\n addColumnBefore,\n addColumnAfter,\n deleteColumn,\n mergeCells,\n splitCell,\n // Without the outdated logic (it looks at the corner cell and confuses the header row and column).\n toggleHeaderRow: toggleHeader('row'),\n toggleHeaderColumn: toggleHeader('column'),\n deleteTable,\n} satisfies Record<string, Command>;\n\nexport { isInTable };\n\n/** Background of the selected cells (null removes it). */\nexport function setCellBackground(color: string | null): Command {\n return setCellAttr('background', color);\n}\n\n/** Whether the current table has a header row (the first row made of th). */\nexport function hasHeaderRow(state: EditorState): boolean {\n if (!isInTable(state)) return false;\n const firstRow = findTable(state.selection.$from)?.node.firstChild;\n if (!firstRow || firstRow.childCount === 0) return false;\n let all = true;\n firstRow.forEach((cell) => {\n if (cell.type !== (state.schema as NovaSchema).nodes.table_header) all = false;\n });\n return all;\n}\n\n/** Whether there is a header column (the first cell of every row is th). */\nexport function hasHeaderColumn(state: EditorState): boolean {\n if (!isInTable(state)) return false;\n const table = findTable(state.selection.$from)?.node;\n if (!table) return false;\n let all = true;\n table.forEach((row) => {\n if (row.firstChild?.type !== (state.schema as NovaSchema).nodes.table_header) all = false;\n });\n return all;\n}\n\n/** Whether several cells are selected (for \"merge\"). */\nexport function isCellSelection(state: EditorState): boolean {\n return state.selection instanceof CellSelection;\n}\n\nexport { selectedRect };\n\n// ---------- sorting by column ----------\n\nexport type SortDirection = 'asc' | 'desc';\n\n/** A number from the cell text (\"1 200\", \"$45.00\", \"-3,5 %\"), otherwise null and the text is compared instead. */\nfunction numericValue(text: string): number | null {\n const cleaned = text\n .replace(/\\s/g, '')\n .replace(/^[^\\d+-]+|[^\\d]+$/g, '') // currency and units at the edges\n .replace(/,(?=\\d{3}(?:\\D|$))/g, '') // the thousands separator in \"1,200\"\n .replace(',', '.'); // the decimal comma in \"3,5\"\n if (!/^[+-]?\\d+(\\.\\d+)?$/.test(cleaned)) return null;\n return Number(cleaned);\n}\n\n/** How to sort a table (the \"Sort\" dialog of advanced tables). */\nexport interface SortOptions {\n /** 'column': the rows, by the values in a column; 'row': the columns, by the values in a row. */\n by: 'column' | 'row';\n /** The column (or row) whose values decide, from 0; the one with the cursor when left out. */\n index?: number;\n direction: SortDirection;\n /** Only the selected rows (or columns), or the whole table (the default). */\n scope?: 'table' | 'selection';\n}\n\n/** Why a table can't be sorted: merged cells, or fewer than two rows (columns) to sort. */\nexport type SortProblem = 'merged' | 'few';\n\ninterface Grid {\n pos: number;\n table: PMNode;\n rows: PMNode[][];\n width: number;\n /** Header rows at the top and header columns at the left: they stay where they are. */\n headerRows: number;\n headerColumns: number;\n rect: { left: number; right: number; top: number; bottom: number };\n}\n\nfunction isHeader(cell: PMNode | undefined, state: EditorState): boolean {\n return cell?.type === (state.schema as NovaSchema).nodes.table_header;\n}\n\n/** The current table as a grid of cells; null with a reason when it can't be sorted. */\nfunction tableGrid(state: EditorState): Grid | SortProblem | null {\n if (!isInTable(state)) return null;\n const rect = selectedRect(state);\n const table = rect.table;\n // Merged cells break the reordering of rows and columns: such tables aren't sorted.\n let merged = false;\n table.descendants((node) => {\n if (node.attrs.colspan > 1 || node.attrs.rowspan > 1) merged = true;\n return (\n !merged && node.type.spec.tableRole !== 'cell' && node.type.spec.tableRole !== 'header_cell'\n );\n });\n if (merged) return 'merged';\n const rows: PMNode[][] = [];\n table.forEach((row) => {\n const cells: PMNode[] = [];\n row.forEach((cell) => cells.push(cell));\n rows.push(cells);\n });\n const width = Math.min(...rows.map((cells) => cells.length));\n let headerRows = 0;\n while (headerRows < rows.length && rows[headerRows]!.every((c) => isHeader(c, state)))\n headerRows++;\n // A header column, or a column of row numbers (advanced tables), stays at the left.\n let headerColumns = 0;\n while (\n headerColumns < width &&\n rows.every(\n (cells) => isHeader(cells[headerColumns], state) || !!cells[headerColumns]?.attrs.series,\n )\n )\n headerColumns++;\n return {\n pos: rect.tableStart - 1,\n table,\n rows,\n width,\n headerRows,\n headerColumns,\n rect: { left: rect.left, right: rect.right, top: rect.top, bottom: rect.bottom },\n };\n}\n\n/** The order of items by their texts: numbers as numbers when every one is, empty ones last. */\nfunction sortOrder(texts: string[], direction: SortDirection, locale?: string): number[] {\n const numbers = texts.map(numericValue);\n // Numeric sorting only if every non-empty cell holds a number.\n const numeric = texts.every((t, i) => t === '' || numbers[i] !== null);\n const collator = new Intl.Collator(locale, { numeric: true, sensitivity: 'base' });\n return texts\n .map((_, i) => i)\n .sort((a, b) => {\n const ta = texts[a]!;\n const tb = texts[b]!;\n // Empty cells always go last.\n if (!ta || !tb) return ta ? -1 : tb ? 1 : a - b;\n const cmp = numeric ? numbers[a]! - numbers[b]! : collator.compare(ta, tb);\n return (direction === 'asc' ? cmp : -cmp) || a - b;\n });\n}\n\n/** Whether the current table can be sorted that way, and if not, why. */\nexport function sortProblem(state: EditorState, options: SortOptions): SortProblem | null {\n const grid = tableGrid(state);\n if (grid === null) return 'few';\n if (typeof grid === 'string') return grid;\n return sortRange(grid, options) ? null : 'few';\n}\n\n/** The rows (or columns) to sort: [from, to). */\nfunction sortRange(grid: Grid, options: SortOptions): [number, number] | null {\n const byColumn = options.by === 'column';\n const first = byColumn ? grid.headerRows : grid.headerColumns;\n const count = byColumn ? grid.rows.length : grid.width;\n let [from, to] = [first, count];\n if (options.scope === 'selection') {\n from = Math.max(first, byColumn ? grid.rect.top : grid.rect.left);\n to = Math.min(count, byColumn ? grid.rect.bottom : grid.rect.right);\n }\n const key = options.index ?? (byColumn ? grid.rect.left : grid.rect.top);\n const keyCount = byColumn ? grid.width : grid.rows.length;\n if (!Number.isInteger(key) || key < 0 || key >= keyCount) return null;\n return to - from >= 2 ? [from, to] : null;\n}\n\n/**\n * Sorts the current table: its rows by a column, or its columns by a row; the whole table or the\n * selected part. Header rows and columns (and a column of row numbers) stay in place.\n */\nexport function sortTableBy(options: SortOptions, locale?: string): Command {\n return (state, dispatch) => {\n const grid = tableGrid(state);\n if (!grid || typeof grid === 'string') return false;\n const range = sortRange(grid, options);\n if (!range) return false;\n if (dispatch) {\n const [from, to] = range;\n const { rows, table, pos } = grid;\n const rowNodes: PMNode[] = [];\n table.forEach((row) => rowNodes.push(row));\n let next: PMNode[];\n if (options.by === 'column') {\n // Whole rows move (with their own attributes).\n const column = options.index ?? grid.rect.left;\n const order = sortOrder(\n rows.slice(from, to).map((cells) => cells[column]?.textContent.trim() ?? ''),\n options.direction,\n locale,\n );\n next = [\n ...rowNodes.slice(0, from),\n ...order.map((i) => rowNodes[from + i]!),\n ...rowNodes.slice(to),\n ];\n } else {\n // The cells of every row move to their column's new place.\n const keyRow = rows[options.index ?? grid.rect.top]!;\n const order = sortOrder(\n keyRow.slice(from, to).map((cell) => cell.textContent.trim()),\n options.direction,\n locale,\n );\n next = rowNodes.map((row, r) => {\n const cells = rows[r]!;\n return row.copy(\n Fragment.from([\n ...cells.slice(0, from),\n ...order.map((i) => cells[from + i]!),\n ...cells.slice(to),\n ]),\n );\n });\n }\n const sorted = table.copy(Fragment.from(next));\n dispatch(state.tr.replaceWith(pos, pos + table.nodeSize, sorted).scrollIntoView());\n }\n return true;\n };\n}\n\n/** Sorts the table rows by the column with the cursor. Header rows stay at the top. */\nexport function sortTable(direction: SortDirection, locale?: string): Command {\n return sortTableBy({ by: 'column', direction }, locale);\n}\n\n// ---------- table and cell properties ----------\n\n/**\n * The table view in the editor: on top of the column width calculation (prosemirror-tables) it applies\n * the table's set width and alignment, so the editor shows what the site will show.\n */\nclass NovaTableView extends TableView {\n constructor(node: PMNode, cellMinWidth: number) {\n super(node, cellMinWidth);\n this.apply(node);\n }\n\n override update(node: PMNode): boolean {\n if (!super.update(node)) return false;\n this.apply(node);\n return true;\n }\n\n private apply(node: PMNode): void {\n const width = cssValue.length(node.attrs.width);\n if (width) {\n this.table.style.width = width;\n this.table.style.minWidth = '';\n }\n const align = node.attrs.align as TableAlign | null;\n this.table.style.marginLeft = align ? 'auto' : '';\n this.table.style.marginRight = align === 'center' ? 'auto' : '';\n // The table style (a class), so the site's CSS (contentCss) shows the borders as in print.\n const cls = classAttr(node.attrs.class).class;\n if (cls) this.table.setAttribute('class', cls);\n else this.table.removeAttribute('class');\n }\n}\n\nexport interface TableProps {\n width: string | null;\n align: TableAlign | null;\n /** The table style (a class from tableClassList); null means no style. Not set means unchanged. */\n class?: string | null;\n}\n\nexport function getTableProps(state: EditorState): TableProps | null {\n const found = findTable(state.selection.$from);\n return found\n ? {\n width: found.node.attrs.width ?? null,\n align: found.node.attrs.align ?? null,\n class: found.node.attrs.class ?? null,\n }\n : null;\n}\n\n/** The table's width (px or %, null means by content) and alignment. */\nexport function setTableProps(props: TableProps): Command {\n return (state, dispatch) => {\n const found = findTable(state.selection.$from);\n if (!found) return false;\n if (props.width !== null && !cssValue.length(props.width)) return false;\n const attrs: Record<string, unknown> = {\n ...found.node.attrs,\n width: props.width,\n align: props.align,\n };\n if (props.class !== undefined) attrs.class = classAttr(props.class).class ?? null;\n dispatch?.(state.tr.setNodeMarkup(found.pos, undefined, attrs));\n return true;\n };\n}\n\nexport interface CellProps {\n valign?: CellVAlign | null;\n /** true for a header cell (th), false for a regular one (td). */\n header?: boolean;\n /** Width of the selection's column(s) in px; null means by content. */\n width?: number | null;\n /** The cell style (a class from tableCellClassList); null means no style. */\n class?: string | null;\n}\n\n/** Positions of the selected cells (or of the cell with the cursor). */\nfunction selectedCells(state: EditorState): { pos: number; node: PMNode }[] {\n const out: { pos: number; node: PMNode }[] = [];\n if (state.selection instanceof CellSelection) {\n state.selection.forEachCell((node, pos) => out.push({ node, pos }));\n return out;\n }\n const { $from } = state.selection;\n for (let depth = $from.depth; depth > 0; depth--) {\n const node = $from.node(depth);\n const role = node.type.spec.tableRole;\n if (role === 'cell' || role === 'header_cell') {\n out.push({ node, pos: $from.before(depth) });\n break;\n }\n }\n return out;\n}\n\nexport function getCellProps(state: EditorState): Required<CellProps> | null {\n const cell = selectedCells(state)[0];\n if (!cell) return null;\n const widths = cell.node.attrs.colwidth as number[] | null;\n return {\n valign: cell.node.attrs.valign ?? null,\n header: cell.node.type === (state.schema as NovaSchema).nodes.table_header,\n width: widths?.[0] ?? null,\n class: cell.node.attrs.class ?? null,\n };\n}\n\n/** Properties of the selected cells: vertical alignment, kind (th/td), column width. */\nexport function setCellProps(props: CellProps): Command {\n return (state, dispatch) => {\n const cells = selectedCells(state);\n if (!cells.length) return false;\n if (props.width != null && !(props.width >= 24 && props.width <= 4000)) return false;\n if (!dispatch) return true;\n const nodes = (state.schema as NovaSchema).nodes;\n const tr = state.tr;\n for (const { pos, node } of cells) {\n const type =\n props.header === undefined\n ? node.type\n : props.header\n ? nodes.table_header\n : nodes.table_cell;\n const attrs = {\n ...node.attrs,\n ...(props.valign !== undefined ? { valign: props.valign } : {}),\n ...(props.class !== undefined ? { class: classAttr(props.class).class ?? null } : {}),\n };\n tr.setNodeMarkup(pos, type, attrs);\n }\n if (props.width !== undefined) {\n // The width goes to every cell of the affected columns (colwidth is stored in each cell).\n const rect = selectedRect(state);\n const map = rect.map;\n const seen = new Set<number>();\n for (let col = rect.left; col < rect.right; col++) {\n for (let row = 0; row < map.height; row++) {\n const cellPos = map.map[row * map.width + col]!;\n const key = cellPos * 1000 + col;\n if (seen.has(key)) continue;\n seen.add(key);\n const absolute = rect.tableStart + cellPos;\n const cell = tr.doc.nodeAt(absolute);\n if (!cell) continue;\n const index = col - map.colCount(cellPos);\n const widths = [\n ...((cell.attrs.colwidth as number[] | null) ?? new Array(cell.attrs.colspan).fill(0)),\n ];\n widths[index] = props.width ?? 0;\n tr.setNodeMarkup(absolute, undefined, {\n ...cell.attrs,\n colwidth: widths.every((w) => !w) ? null : widths,\n });\n }\n }\n }\n dispatch(tr);\n return true;\n };\n}\n"],"mappings":";;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,gBAAqC;AAC9C,OAA4D;AAC5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOP,IAAM,mBAA4B,CAAC,OAAO,UAAU,SAAS;AAC3D,MAAI,CAAC,UAAU,KAAK,EAAG,QAAO;AAC9B,MAAI,aAAa,CAAC,EAAE,OAAO,UAAU,IAAI,EAAG,QAAO;AACnD,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI,OAAoB;AACxB,cAAY,OAAO,CAAC,OAAO;AACzB,WAAO,MAAM,MAAM,EAAE;AACrB,aAAS,EAAE;AAAA,EACb,CAAC;AACD,SAAO,aAAa,CAAC,EAAE,MAAM,UAAU,IAAI;AAC7C;AAEO,SAAS,eAAy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