@novaprose/core 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/README.md +20 -4
  2. package/dist/a11y.cjs +314 -0
  3. package/dist/a11y.cjs.map +1 -0
  4. package/dist/a11y.d.cts +51 -0
  5. package/dist/a11y.d.ts +51 -0
  6. package/dist/a11y.js +11 -0
  7. package/dist/a11y.js.map +1 -0
  8. package/dist/a11ychecker-7KQU7DD3.js +449 -0
  9. package/dist/a11ychecker-7KQU7DD3.js.map +1 -0
  10. package/dist/accordion-ui-FGN3I5UF.js +201 -0
  11. package/dist/accordion-ui-FGN3I5UF.js.map +1 -0
  12. package/dist/advcode-65Z2ELUB.js +51 -0
  13. package/dist/advcode-65Z2ELUB.js.map +1 -0
  14. package/dist/advcode-editor-WIOCY552.js +257 -0
  15. package/dist/advcode-editor-WIOCY552.js.map +1 -0
  16. package/dist/{advlist-K2U3VPH2.js → advlist-CEHE6YXS.js} +14 -20
  17. package/dist/advlist-CEHE6YXS.js.map +1 -0
  18. package/dist/advtable-ui-5CBOPTHW.js +364 -0
  19. package/dist/advtable-ui-5CBOPTHW.js.map +1 -0
  20. package/dist/ai-IRQYZHRK.js +1485 -0
  21. package/dist/ai-IRQYZHRK.js.map +1 -0
  22. package/dist/anchor-ui-NWIIRKGY.js +81 -0
  23. package/dist/anchor-ui-NWIIRKGY.js.map +1 -0
  24. package/dist/autocorrect-6GFLVDPC.js +851 -0
  25. package/dist/autocorrect-6GFLVDPC.js.map +1 -0
  26. package/dist/{autolink-XWDTLY37.js → autolink-N427KVQO.js} +13 -7
  27. package/dist/autolink-N427KVQO.js.map +1 -0
  28. package/dist/{autoresize-UB3GOA6D.js → autoresize-YRZAVCNO.js} +2 -2
  29. package/dist/autoresize-YRZAVCNO.js.map +1 -0
  30. package/dist/{autosave-MWNRUNU3.js → autosave-L7OZ3KLK.js} +9 -13
  31. package/dist/autosave-L7OZ3KLK.js.map +1 -0
  32. package/dist/casechange-5G6RAJ7K.js +201 -0
  33. package/dist/casechange-5G6RAJ7K.js.map +1 -0
  34. package/dist/{charmap-ADLYOIB3.js → charmap-5CBBDWOP.js} +9 -14
  35. package/dist/charmap-5CBBDWOP.js.map +1 -0
  36. package/dist/checklist-HM4VXZKY.js +189 -0
  37. package/dist/checklist-HM4VXZKY.js.map +1 -0
  38. package/dist/chunk-23ZLVT5D.js +163 -0
  39. package/dist/chunk-23ZLVT5D.js.map +1 -0
  40. package/dist/chunk-3BOK3S3T.js +26 -0
  41. package/dist/chunk-3BOK3S3T.js.map +1 -0
  42. package/dist/chunk-4I4AYH2K.js +101 -0
  43. package/dist/chunk-4I4AYH2K.js.map +1 -0
  44. package/dist/chunk-4VPDY3LF.js +27 -0
  45. package/dist/chunk-4VPDY3LF.js.map +1 -0
  46. package/dist/chunk-53AY5NAF.js +214 -0
  47. package/dist/chunk-53AY5NAF.js.map +1 -0
  48. package/dist/chunk-5VCESSQB.js +137 -0
  49. package/dist/chunk-5VCESSQB.js.map +1 -0
  50. package/dist/chunk-66INZHZ2.js +79 -0
  51. package/dist/chunk-66INZHZ2.js.map +1 -0
  52. package/dist/chunk-6LQM7G4V.js +159 -0
  53. package/dist/chunk-6LQM7G4V.js.map +1 -0
  54. package/dist/chunk-6YSQGFV7.js +893 -0
  55. package/dist/chunk-6YSQGFV7.js.map +1 -0
  56. package/dist/{chunk-GHEFKKRC.js → chunk-AC3YCAX4.js} +108 -29
  57. package/dist/chunk-AC3YCAX4.js.map +1 -0
  58. package/dist/{chunk-NPKAIW34.js → chunk-ADRPQLZ2.js} +50 -1
  59. package/dist/chunk-ADRPQLZ2.js.map +1 -0
  60. package/dist/chunk-ANE5ASXG.js +26 -0
  61. package/dist/chunk-ANE5ASXG.js.map +1 -0
  62. package/dist/{chunk-Z3ELZ77W.js → chunk-AP2PJFLB.js} +5 -2
  63. package/dist/chunk-AP2PJFLB.js.map +1 -0
  64. package/dist/chunk-AQV6FIKK.js +259 -0
  65. package/dist/chunk-AQV6FIKK.js.map +1 -0
  66. package/dist/chunk-AUQSATWL.js +322 -0
  67. package/dist/chunk-AUQSATWL.js.map +1 -0
  68. package/dist/chunk-C326LHHU.js +143 -0
  69. package/dist/chunk-C326LHHU.js.map +1 -0
  70. package/dist/chunk-DEYYVZ7O.js +393 -0
  71. package/dist/chunk-DEYYVZ7O.js.map +1 -0
  72. package/dist/chunk-EOJ5XHKA.js +160 -0
  73. package/dist/chunk-EOJ5XHKA.js.map +1 -0
  74. package/dist/chunk-EXX2S352.js +3642 -0
  75. package/dist/chunk-EXX2S352.js.map +1 -0
  76. package/dist/chunk-FTEA6L2Q.js +47 -0
  77. package/dist/chunk-FTEA6L2Q.js.map +1 -0
  78. package/dist/chunk-G74HNSB6.js +9 -0
  79. package/dist/chunk-G74HNSB6.js.map +1 -0
  80. package/dist/chunk-GHVB6SV4.js +177 -0
  81. package/dist/chunk-GHVB6SV4.js.map +1 -0
  82. package/dist/chunk-GTLE2HEW.js +108 -0
  83. package/dist/chunk-GTLE2HEW.js.map +1 -0
  84. package/dist/chunk-GXXXLPDQ.js +67 -0
  85. package/dist/chunk-GXXXLPDQ.js.map +1 -0
  86. package/dist/chunk-HC6RMBAD.js +163 -0
  87. package/dist/chunk-HC6RMBAD.js.map +1 -0
  88. package/dist/chunk-HNEAVVBC.js +98 -0
  89. package/dist/chunk-HNEAVVBC.js.map +1 -0
  90. package/dist/chunk-I7Y4KSM2.js +165 -0
  91. package/dist/chunk-I7Y4KSM2.js.map +1 -0
  92. package/dist/chunk-IG2BL4ON.js +127 -0
  93. package/dist/chunk-IG2BL4ON.js.map +1 -0
  94. package/dist/chunk-J6W2CDRF.js +425 -0
  95. package/dist/chunk-J6W2CDRF.js.map +1 -0
  96. package/dist/chunk-LVEQBNLX.js +207 -0
  97. package/dist/chunk-LVEQBNLX.js.map +1 -0
  98. package/dist/chunk-MZGNOHSY.js +176 -0
  99. package/dist/chunk-MZGNOHSY.js.map +1 -0
  100. package/dist/chunk-N32H37AJ.js +373 -0
  101. package/dist/chunk-N32H37AJ.js.map +1 -0
  102. package/dist/chunk-NTGEKGXU.js +263 -0
  103. package/dist/chunk-NTGEKGXU.js.map +1 -0
  104. package/dist/chunk-OFHGXYG3.js +140 -0
  105. package/dist/chunk-OFHGXYG3.js.map +1 -0
  106. package/dist/chunk-OOVNE6MB.js +28 -0
  107. package/dist/chunk-OOVNE6MB.js.map +1 -0
  108. package/dist/chunk-OQMMHWMZ.js +7 -0
  109. package/dist/chunk-OQMMHWMZ.js.map +1 -0
  110. package/dist/chunk-P2UU2NLT.js +1149 -0
  111. package/dist/chunk-P2UU2NLT.js.map +1 -0
  112. package/dist/{chunk-HZRIBOPW.js → chunk-QU3KXMYT.js} +45 -3
  113. package/dist/chunk-QU3KXMYT.js.map +1 -0
  114. package/dist/chunk-S2XZRKHA.js +29 -0
  115. package/dist/chunk-S2XZRKHA.js.map +1 -0
  116. package/dist/chunk-SCIRO4XK.js +144 -0
  117. package/dist/chunk-SCIRO4XK.js.map +1 -0
  118. package/dist/chunk-T3IRLTKK.js +158 -0
  119. package/dist/chunk-T3IRLTKK.js.map +1 -0
  120. package/dist/chunk-TABIUD2L.js +66 -0
  121. package/dist/chunk-TABIUD2L.js.map +1 -0
  122. package/dist/{chunk-7ON7PR5R.js → chunk-TAM2FHKG.js} +374 -52
  123. package/dist/chunk-TAM2FHKG.js.map +1 -0
  124. package/dist/chunk-UTMS2P2K.js +288 -0
  125. package/dist/chunk-UTMS2P2K.js.map +1 -0
  126. package/dist/{chunk-HPLT3XRZ.js → chunk-V7WUHUHM.js} +13 -1
  127. package/dist/chunk-V7WUHUHM.js.map +1 -0
  128. package/dist/chunk-VK6YF2AA.js +359 -0
  129. package/dist/chunk-VK6YF2AA.js.map +1 -0
  130. package/dist/chunk-WAOU5NGN.js +430 -0
  131. package/dist/chunk-WAOU5NGN.js.map +1 -0
  132. package/dist/chunk-XIH4SCO6.js +112 -0
  133. package/dist/chunk-XIH4SCO6.js.map +1 -0
  134. package/dist/chunk-XR7CY4NI.js +11 -0
  135. package/dist/chunk-XR7CY4NI.js.map +1 -0
  136. package/dist/chunk-YDF55N6Z.js +164 -0
  137. package/dist/chunk-YDF55N6Z.js.map +1 -0
  138. package/dist/chunk-YDPZCVXS.js +923 -0
  139. package/dist/chunk-YDPZCVXS.js.map +1 -0
  140. package/dist/chunk-YG5V7POU.js +137 -0
  141. package/dist/chunk-YG5V7POU.js.map +1 -0
  142. package/dist/chunk-YVSUR7E5.js +151 -0
  143. package/dist/chunk-YVSUR7E5.js.map +1 -0
  144. package/dist/codesample-GHWIC7PT.js +546 -0
  145. package/dist/codesample-GHWIC7PT.js.map +1 -0
  146. package/dist/{comments-panel-FYJE3U64.js → comments-panel-SOLBZ46Q.js} +12 -6
  147. package/dist/comments-panel-SOLBZ46Q.js.map +1 -0
  148. package/dist/{directionality-XOHJFSL6.js → directionality-EGQKGDZA.js} +16 -11
  149. package/dist/directionality-EGQKGDZA.js.map +1 -0
  150. package/dist/document-0ft41E6d.d.ts +39 -0
  151. package/dist/document-IQqDDT4v.d.cts +39 -0
  152. package/dist/docx.cjs +23518 -0
  153. package/dist/docx.cjs.map +1 -0
  154. package/dist/docx.d.cts +83 -0
  155. package/dist/docx.d.ts +83 -0
  156. package/dist/docx.js +1821 -0
  157. package/dist/docx.js.map +1 -0
  158. package/dist/draghandle-U6CYZHPA.js +389 -0
  159. package/dist/draghandle-U6CYZHPA.js.map +1 -0
  160. package/dist/editimage-5EWPSM22.js +683 -0
  161. package/dist/editimage-5EWPSM22.js.map +1 -0
  162. package/dist/editor-BCMxe1M4.d.cts +2888 -0
  163. package/dist/editor-Dmtwjw2u.d.ts +2888 -0
  164. package/dist/email-ELNMEQ6E.js +177 -0
  165. package/dist/email-ELNMEQ6E.js.map +1 -0
  166. package/dist/email.cjs +588 -0
  167. package/dist/email.cjs.map +1 -0
  168. package/dist/email.d.cts +7 -0
  169. package/dist/email.d.ts +7 -0
  170. package/dist/email.js +21 -0
  171. package/dist/email.js.map +1 -0
  172. package/dist/{emoticons-TP4N4ZGY.js → emoticons-EGHNZKSA.js} +9 -14
  173. package/dist/emoticons-EGHNZKSA.js.map +1 -0
  174. package/dist/exportpdf-4P7X3NY2.js +91 -0
  175. package/dist/exportpdf-4P7X3NY2.js.map +1 -0
  176. package/dist/exportword-JFJ3KTYZ.js +16 -0
  177. package/dist/exportword-JFJ3KTYZ.js.map +1 -0
  178. package/dist/footnotes-ui-FV6QRGDA.js +449 -0
  179. package/dist/footnotes-ui-FV6QRGDA.js.map +1 -0
  180. package/dist/form-dialog-SNWFPM2K.js +379 -0
  181. package/dist/form-dialog-SNWFPM2K.js.map +1 -0
  182. package/dist/formatpainter-IEXX27OJ.js +209 -0
  183. package/dist/formatpainter-IEXX27OJ.js.map +1 -0
  184. package/dist/fullpagehtml-ui-RE4C2NO5.js +220 -0
  185. package/dist/fullpagehtml-ui-RE4C2NO5.js.map +1 -0
  186. package/dist/html-rules-api-BLDDW9MO.d.cts +42 -0
  187. package/dist/html-rules-api-BLDDW9MO.d.ts +42 -0
  188. package/dist/html-rules.cjs +482 -0
  189. package/dist/html-rules.cjs.map +1 -0
  190. package/dist/html-rules.d.cts +89 -0
  191. package/dist/html-rules.d.ts +89 -0
  192. package/dist/html-rules.js +417 -0
  193. package/dist/html-rules.js.map +1 -0
  194. package/dist/i18n/de.cjs +670 -0
  195. package/dist/i18n/de.cjs.map +1 -0
  196. package/dist/i18n/de.d.cts +9 -0
  197. package/dist/i18n/de.d.ts +9 -0
  198. package/dist/i18n/de.js +649 -0
  199. package/dist/i18n/de.js.map +1 -0
  200. package/dist/i18n/es.cjs +670 -0
  201. package/dist/i18n/es.cjs.map +1 -0
  202. package/dist/i18n/es.d.cts +9 -0
  203. package/dist/i18n/es.d.ts +9 -0
  204. package/dist/i18n/es.js +649 -0
  205. package/dist/i18n/es.js.map +1 -0
  206. package/dist/i18n/fr.cjs +670 -0
  207. package/dist/i18n/fr.cjs.map +1 -0
  208. package/dist/i18n/fr.d.cts +9 -0
  209. package/dist/i18n/fr.d.ts +9 -0
  210. package/dist/i18n/fr.js +649 -0
  211. package/dist/i18n/fr.js.map +1 -0
  212. package/dist/i18n/it.cjs +670 -0
  213. package/dist/i18n/it.cjs.map +1 -0
  214. package/dist/i18n/it.d.cts +9 -0
  215. package/dist/i18n/it.d.ts +9 -0
  216. package/dist/i18n/it.js +649 -0
  217. package/dist/i18n/it.js.map +1 -0
  218. package/dist/i18n/pt-BR.cjs +670 -0
  219. package/dist/i18n/pt-BR.cjs.map +1 -0
  220. package/dist/i18n/pt-BR.d.cts +9 -0
  221. package/dist/i18n/pt-BR.d.ts +9 -0
  222. package/dist/i18n/pt-BR.js +649 -0
  223. package/dist/i18n/pt-BR.js.map +1 -0
  224. package/dist/i18n/ru.cjs +670 -0
  225. package/dist/i18n/ru.cjs.map +1 -0
  226. package/dist/i18n/ru.d.cts +10 -0
  227. package/dist/i18n/ru.d.ts +10 -0
  228. package/dist/i18n/ru.js +649 -0
  229. package/dist/i18n/ru.js.map +1 -0
  230. package/dist/importcss-JLNIRKGH.js +127 -0
  231. package/dist/importcss-JLNIRKGH.js.map +1 -0
  232. package/dist/importword-D7Z6RXGQ.js +73 -0
  233. package/dist/importword-D7Z6RXGQ.js.map +1 -0
  234. package/dist/index-CZ9yDvmQ.d.cts +235 -0
  235. package/dist/index-CZ9yDvmQ.d.ts +235 -0
  236. package/dist/index.cjs +29531 -10134
  237. package/dist/index.cjs.map +1 -1
  238. package/dist/index.d.cts +160 -1828
  239. package/dist/index.d.ts +160 -1828
  240. package/dist/index.js +212 -1480
  241. package/dist/index.js.map +1 -1
  242. package/dist/{insertdatetime-T4SEMQWP.js → insertdatetime-YW2VHYZH.js} +10 -16
  243. package/dist/insertdatetime-YW2VHYZH.js.map +1 -0
  244. package/dist/linkchecker-3S3MCPOS.js +287 -0
  245. package/dist/linkchecker-3S3MCPOS.js.map +1 -0
  246. package/dist/markdown-26O3N3T2.js +136 -0
  247. package/dist/markdown-26O3N3T2.js.map +1 -0
  248. package/dist/markdown.cjs +356 -0
  249. package/dist/markdown.cjs.map +1 -0
  250. package/dist/markdown.d.cts +25 -0
  251. package/dist/markdown.d.ts +25 -0
  252. package/dist/markdown.js +10 -0
  253. package/dist/markdown.js.map +1 -0
  254. package/dist/math-ui-RUTCHTRY.js +157 -0
  255. package/dist/math-ui-RUTCHTRY.js.map +1 -0
  256. package/dist/media-ui-36TE3CJD.js +123 -0
  257. package/dist/media-ui-36TE3CJD.js.map +1 -0
  258. package/dist/mediaembed-ui-ZNTGZ2SQ.js +207 -0
  259. package/dist/mediaembed-ui-ZNTGZ2SQ.js.map +1 -0
  260. package/dist/mentions-ui-O4IPWQT4.js +58 -0
  261. package/dist/mentions-ui-O4IPWQT4.js.map +1 -0
  262. package/dist/mergetags-ui-HS3Q2R36.js +73 -0
  263. package/dist/mergetags-ui-HS3Q2R36.js.map +1 -0
  264. package/dist/{nonbreaking-HG5HV6AL.js → nonbreaking-GYRUH4UO.js} +10 -9
  265. package/dist/nonbreaking-GYRUH4UO.js.map +1 -0
  266. package/dist/pagebreak-ui-I4ZPYK3U.js +50 -0
  267. package/dist/pagebreak-ui-I4ZPYK3U.js.map +1 -0
  268. package/dist/pageembed-ui-WOY6VWRJ.js +172 -0
  269. package/dist/pageembed-ui-WOY6VWRJ.js.map +1 -0
  270. package/dist/pagelayout-ui-Y2IM7FJQ.js +236 -0
  271. package/dist/pagelayout-ui-Y2IM7FJQ.js.map +1 -0
  272. package/dist/paste-office-3A6KWKCV.js +520 -0
  273. package/dist/paste-office-3A6KWKCV.js.map +1 -0
  274. package/dist/permanentpen-6D5LLKFX.js +206 -0
  275. package/dist/permanentpen-6D5LLKFX.js.map +1 -0
  276. package/dist/print-MZMLQIQX.js +178 -0
  277. package/dist/print-MZMLQIQX.js.map +1 -0
  278. package/dist/{quickbars-4NU4SIPL.js → quickbars-UZ2Q67TX.js} +24 -12
  279. package/dist/quickbars-UZ2Q67TX.js.map +1 -0
  280. package/dist/{revisionhistory-3YQPLPLM.js → revisionhistory-ACRB23HL.js} +48 -173
  281. package/dist/revisionhistory-ACRB23HL.js.map +1 -0
  282. package/dist/save-72ZLF6AO.js +120 -0
  283. package/dist/save-72ZLF6AO.js.map +1 -0
  284. package/dist/search-bar-HTZQNPD3.js +212 -0
  285. package/dist/search-bar-HTZQNPD3.js.map +1 -0
  286. package/dist/spellchecker-DJ7SP5JY.js +474 -0
  287. package/dist/spellchecker-DJ7SP5JY.js.map +1 -0
  288. package/dist/suggestions-panel-RJXC4LCM.js +596 -0
  289. package/dist/suggestions-panel-RJXC4LCM.js.map +1 -0
  290. package/dist/suggestions-ui-PODMNH7D.js +395 -0
  291. package/dist/suggestions-ui-PODMNH7D.js.map +1 -0
  292. package/dist/table-OBHE465Y.js +54 -0
  293. package/dist/table-OBHE465Y.js.map +1 -0
  294. package/dist/table-dialogs-UMIIZQYE.js +119 -0
  295. package/dist/table-dialogs-UMIIZQYE.js.map +1 -0
  296. package/dist/tableofcontents-ui-U2PYNPX6.js +167 -0
  297. package/dist/tableofcontents-ui-U2PYNPX6.js.map +1 -0
  298. package/dist/template-YYC2MGVH.js +278 -0
  299. package/dist/template-YYC2MGVH.js.map +1 -0
  300. package/dist/typography-EQUXUXIN.js +399 -0
  301. package/dist/typography-EQUXUXIN.js.map +1 -0
  302. package/dist/upload.cjs +160 -0
  303. package/dist/upload.cjs.map +1 -0
  304. package/dist/upload.d.cts +72 -0
  305. package/dist/upload.d.ts +72 -0
  306. package/dist/upload.js +132 -0
  307. package/dist/upload.js.map +1 -0
  308. package/dist/{visualblocks-RTAYJOGR.js → visualblocks-O5QW7ZDT.js} +10 -9
  309. package/dist/visualblocks-O5QW7ZDT.js.map +1 -0
  310. package/dist/visualchars-UQFRWQPE.js +134 -0
  311. package/dist/visualchars-UQFRWQPE.js.map +1 -0
  312. package/package.json +96 -6
  313. package/src/style.css +440 -508
  314. package/dist/advlist-K2U3VPH2.js.map +0 -1
  315. package/dist/autolink-XWDTLY37.js.map +0 -1
  316. package/dist/autoresize-UB3GOA6D.js.map +0 -1
  317. package/dist/autosave-MWNRUNU3.js.map +0 -1
  318. package/dist/charmap-ADLYOIB3.js.map +0 -1
  319. package/dist/chunk-435CRWKA.js +0 -983
  320. package/dist/chunk-435CRWKA.js.map +0 -1
  321. package/dist/chunk-46RIM5KP.js +0 -5949
  322. package/dist/chunk-46RIM5KP.js.map +0 -1
  323. package/dist/chunk-6RJENZXT.js +0 -104
  324. package/dist/chunk-6RJENZXT.js.map +0 -1
  325. package/dist/chunk-7ON7PR5R.js.map +0 -1
  326. package/dist/chunk-GHEFKKRC.js.map +0 -1
  327. package/dist/chunk-HPLT3XRZ.js.map +0 -1
  328. package/dist/chunk-HZRIBOPW.js.map +0 -1
  329. package/dist/chunk-NPKAIW34.js.map +0 -1
  330. package/dist/chunk-Z3ELZ77W.js.map +0 -1
  331. package/dist/comments-panel-FYJE3U64.js.map +0 -1
  332. package/dist/directionality-XOHJFSL6.js.map +0 -1
  333. package/dist/emoticons-TP4N4ZGY.js.map +0 -1
  334. package/dist/insertdatetime-T4SEMQWP.js.map +0 -1
  335. package/dist/nonbreaking-HG5HV6AL.js.map +0 -1
  336. package/dist/quickbars-4NU4SIPL.js.map +0 -1
  337. package/dist/revisionhistory-3YQPLPLM.js.map +0 -1
  338. package/dist/visualblocks-RTAYJOGR.js.map +0 -1
@@ -0,0 +1,683 @@
1
+ import {
2
+ dataUrlToFile,
3
+ getSelectedImage
4
+ } from "./chunk-J6W2CDRF.js";
5
+ import "./chunk-FTEA6L2Q.js";
6
+ import "./chunk-MZGNOHSY.js";
7
+ import {
8
+ nodesOf
9
+ } from "./chunk-AC3YCAX4.js";
10
+ import "./chunk-HNEAVVBC.js";
11
+ import "./chunk-TAM2FHKG.js";
12
+ import "./chunk-XR7CY4NI.js";
13
+ import "./chunk-ADRPQLZ2.js";
14
+ import {
15
+ pickLabels
16
+ } from "./chunk-DEYYVZ7O.js";
17
+ import {
18
+ definePlugin
19
+ } from "./chunk-V7WUHUHM.js";
20
+ import {
21
+ h,
22
+ icon
23
+ } from "./chunk-QU3KXMYT.js";
24
+ import "./chunk-G74HNSB6.js";
25
+ import {
26
+ isSafeImageUrl
27
+ } from "./chunk-4VPDY3LF.js";
28
+
29
+ // src/plugins/editimage.ts
30
+ import { closeHistory } from "prosemirror-history";
31
+ import { NodeSelection } from "prosemirror-state";
32
+
33
+ // nova-raw-css:/home/runner/work/novaprose/novaprose/packages/core/src/plugins/editimage.css?raw
34
+ var editimage_default = ".nova-editimage{display:flex;flex-direction:column;gap:10px}.nova-editimage-tools{display:flex;align-items:center;gap:2px}.nova-editimage-tools .nova-button{margin-inline-start:6px}.nova-editimage-stage{position:relative;align-self:center;max-width:100%;overflow:hidden;line-height:0;background:repeating-conic-gradient(var(--nova-hover) 0 25%,transparent 0 50%) 0 0 / 16px 16px;cursor:crosshair;touch-action:none;user-select:none}.nova-editimage-canvas{display:block;max-width:100%}.nova-editimage-crop{position:absolute;box-sizing:border-box;border:2px solid #ffffff;outline:1px solid rgb(0 0 0 / .6);box-shadow:0 0 0 9999px #00000073;cursor:move;pointer-events:none}.nova-editimage-crop[hidden]{display:none}.nova-editimage-group{display:flex;flex-wrap:wrap;align-items:flex-end;gap:8px 12px;margin:0;padding:8px 0 0;border:0;border-top:1px solid var(--nova-border)}.nova-editimage-group legend{padding:0 0 4px;font-weight:600}.nova-editimage-field{display:flex;flex-direction:column;gap:4px;font-size:13px}.nova-editimage-field .nova-input{width:96px}.nova-editimage-field select.nova-input{width:140px}.nova-editimage-range{flex-direction:row;flex-wrap:wrap;align-items:center;column-gap:8px}.nova-editimage-range span{flex-basis:100%}.nova-editimage-range input{width:150px;accent-color:var(--nova-accent)}.nova-editimage-value{min-width:3ch;color:var(--nova-muted);font-variant-numeric:tabular-nums}.nova-editimage-check{display:flex;align-items:center;gap:6px;padding-bottom:8px;font-size:13px}";
35
+
36
+ // src/plugins/editimage-pixels.ts
37
+ var NO_EDIT = {
38
+ rotate: 0,
39
+ flipH: false,
40
+ flipV: false,
41
+ crop: null,
42
+ width: null,
43
+ height: null,
44
+ brightness: 0,
45
+ contrast: 0,
46
+ saturation: 0
47
+ };
48
+ function rotatedSize(width, height, rotate) {
49
+ return rotate % 180 === 0 ? [width, height] : [height, width];
50
+ }
51
+ function turn(rotate, by) {
52
+ return ((rotate + by) % 360 + 360) % 360;
53
+ }
54
+ function clampRect(rect, width, height) {
55
+ const x = Math.min(Math.max(0, Math.round(rect.x)), width - 1);
56
+ const y = Math.min(Math.max(0, Math.round(rect.y)), height - 1);
57
+ return {
58
+ x,
59
+ y,
60
+ width: Math.min(Math.max(1, Math.round(rect.width)), width - x),
61
+ height: Math.min(Math.max(1, Math.round(rect.height)), height - y)
62
+ };
63
+ }
64
+ function rectOfRatio(width, height, ratio) {
65
+ if (!ratio || !Number.isFinite(ratio) || ratio <= 0) return { x: 0, y: 0, width, height };
66
+ let w = width;
67
+ let h2 = Math.round(width / ratio);
68
+ if (h2 > height) {
69
+ h2 = height;
70
+ w = Math.round(height * ratio);
71
+ }
72
+ return { x: Math.round((width - w) / 2), y: Math.round((height - h2) / 2), width: w, height: h2 };
73
+ }
74
+ function editGeometry(sourceWidth, sourceHeight, edit) {
75
+ const [w, h2] = rotatedSize(sourceWidth, sourceHeight, edit.rotate);
76
+ const crop = edit.crop ? clampRect(edit.crop, w, h2) : { x: 0, y: 0, width: w, height: h2 };
77
+ const size = (value, fallback) => value && Number.isFinite(value) ? Math.min(1e4, Math.max(1, Math.round(value))) : fallback;
78
+ return { crop, width: size(edit.width, crop.width), height: size(edit.height, crop.height) };
79
+ }
80
+ function hasColorEdit(edit) {
81
+ return edit.brightness !== 0 || edit.contrast !== 0 || edit.saturation !== 0;
82
+ }
83
+ function adjustPixels(data, { brightness, contrast, saturation }) {
84
+ const b = 1 + clamp100(brightness) / 100;
85
+ const c = 1 + clamp100(contrast) / 100;
86
+ const s = 1 + clamp100(saturation) / 100;
87
+ for (let i = 0; i < data.length; i += 4) {
88
+ let r = data[i] * b;
89
+ let g = data[i + 1] * b;
90
+ let bl = data[i + 2] * b;
91
+ r = (r - 128) * c + 128;
92
+ g = (g - 128) * c + 128;
93
+ bl = (bl - 128) * c + 128;
94
+ const gray = 0.2126 * r + 0.7152 * g + 0.0722 * bl;
95
+ data[i] = gray + (r - gray) * s;
96
+ data[i + 1] = gray + (g - gray) * s;
97
+ data[i + 2] = gray + (bl - gray) * s;
98
+ }
99
+ }
100
+ function clamp100(value) {
101
+ return Number.isFinite(value) ? Math.min(100, Math.max(-100, value)) : 0;
102
+ }
103
+ function outputType(type) {
104
+ return type === "image/jpeg" || type === "image/webp" ? type : "image/png";
105
+ }
106
+ function editedName(src, type) {
107
+ const ext = type === "image/jpeg" ? "jpg" : type.split("/")[1] ?? "png";
108
+ let base = "image";
109
+ try {
110
+ const path = new URL(src, "https://x.invalid/").pathname;
111
+ const last = decodeURIComponent(path.split("/").pop() ?? "").replace(/\.[a-z0-9]{1,5}$/i, "");
112
+ if (/^[\w.-]{1,80}$/.test(last) && !src.startsWith("data:") && !src.startsWith("blob:"))
113
+ base = last;
114
+ } catch {
115
+ }
116
+ return `${base.replace(/-edited$/, "")}-edited.${ext}`;
117
+ }
118
+
119
+ // src/plugins/editimage.ts
120
+ var LABELS = {
121
+ en: {
122
+ rotateLeft: "Rotate left",
123
+ rotateRight: "Rotate right",
124
+ flipH: "Flip horizontally",
125
+ flipV: "Flip vertically",
126
+ edit: "Edit image",
127
+ reset: "Start over",
128
+ apply: "Apply",
129
+ preview: "The image with the changes",
130
+ crop: "Crop",
131
+ shape: "Shape",
132
+ free: "Free",
133
+ original: "As the image",
134
+ square: "Square",
135
+ left: "Left, px",
136
+ top: "Top, px",
137
+ width: "Width, px",
138
+ height: "Height, px",
139
+ size: "Size",
140
+ keepRatio: "Keep the proportions",
141
+ colors: "Colors",
142
+ brightness: "Brightness",
143
+ contrast: "Contrast",
144
+ saturation: "Saturation",
145
+ working: "Editing the image\u2026",
146
+ unreadable: "This image is on a site that doesn\u2019t allow editing it here. Save it and insert it again to edit it.",
147
+ unsupported: "Only PNG, JPEG, WebP, GIF, AVIF and BMP images can be edited.",
148
+ failed: "The edited image couldn\u2019t be saved."
149
+ }
150
+ };
151
+ var svg = (paths) => `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${paths}</svg>`;
152
+ var ICONS = {
153
+ rotateLeft: svg('<path d="M3 4v5h5"/><path d="M3.5 9A8.5 8.5 0 1 1 6 16.5"/>'),
154
+ rotateRight: svg('<path d="M21 4v5h-5"/><path d="M20.5 9A8.5 8.5 0 1 0 18 16.5"/>'),
155
+ flipH: svg('<path d="M12 3v18"/><path d="M9 7 4 12l5 5V7Z"/><path d="M15 7v10l5-5-5-5Z"/>'),
156
+ flipV: svg('<path d="M3 12h18"/><path d="M7 9l5-5 5 5H7Z"/><path d="M7 15h10l-5 5-5-5Z"/>'),
157
+ edit: svg(
158
+ '<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/><path d="M14 3v4"/><path d="M12 5h4"/>'
159
+ )
160
+ };
161
+ var EDITABLE = /^image\/(png|jpe?g|gif|webp|avif|bmp)$/;
162
+ var UnreadableImage = class extends Error {
163
+ };
164
+ var UnsupportedImage = class extends Error {
165
+ };
166
+ var isBlob = (value) => !!value && typeof value === "object" && typeof value.slice === "function" && typeof value.type === "string" && typeof value.size === "number";
167
+ async function sniffType(blob) {
168
+ const bytes = new Uint8Array(await blob.slice(0, 12).arrayBuffer());
169
+ const at = (i, ...values) => values.every((v, k) => bytes[i + k] === v);
170
+ if (at(0, 137, 80, 78, 71)) return "image/png";
171
+ if (at(0, 255, 216, 255)) return "image/jpeg";
172
+ if (at(0, 71, 73, 70, 56)) return "image/gif";
173
+ if (at(0, 82, 73, 70, 70) && at(8, 87, 69, 66, 80)) return "image/webp";
174
+ if (at(0, 66, 77)) return "image/bmp";
175
+ if (at(4, 102, 116, 121, 112, 97, 118, 105, 102)) return "image/avif";
176
+ return "";
177
+ }
178
+ async function loadImage(src, options) {
179
+ let blob;
180
+ if (typeof options.fetchImage === "function") {
181
+ blob = await options.fetchImage(src);
182
+ } else if (/^data:/i.test(src)) {
183
+ const file = dataUrlToFile(src);
184
+ if (!file) throw new UnsupportedImage("not an editable data: image");
185
+ blob = file;
186
+ } else {
187
+ let url;
188
+ try {
189
+ url = new URL(src, document.baseURI);
190
+ } catch {
191
+ throw new UnsupportedImage("a malformed address");
192
+ }
193
+ if (!["http:", "https:", "blob:"].includes(url.protocol)) throw new UnsupportedImage(src);
194
+ const own = url.origin === location.origin || url.protocol === "blob:";
195
+ const hosts = Array.isArray(options.credentialsHosts) ? options.credentialsHosts : [];
196
+ const credentials = own ? "same-origin" : hosts.includes(url.hostname) ? "include" : "omit";
197
+ let response;
198
+ try {
199
+ response = await fetch(url.href, { credentials });
200
+ } catch (error) {
201
+ throw new UnreadableImage(String(error));
202
+ }
203
+ if (!response.ok) throw new UnreadableImage(`${response.status}`);
204
+ blob = await response.blob();
205
+ }
206
+ if (!isBlob(blob)) throw new UnreadableImage("no file");
207
+ const declared = blob.type.toLowerCase();
208
+ if (declared.includes("svg")) throw new UnsupportedImage("svg");
209
+ const type = EDITABLE.test(declared) ? declared : await sniffType(blob);
210
+ if (!EDITABLE.test(type)) throw new UnsupportedImage(type || "unknown");
211
+ return type === declared ? blob : new Blob([blob], { type });
212
+ }
213
+ function drawTurned(bitmap, edit, scale = 1) {
214
+ const [w, h2] = rotatedSize(bitmap.width, bitmap.height, edit.rotate);
215
+ const canvas = document.createElement("canvas");
216
+ canvas.width = Math.max(1, Math.round(w * scale));
217
+ canvas.height = Math.max(1, Math.round(h2 * scale));
218
+ const ctx = canvas.getContext("2d");
219
+ ctx.translate(canvas.width / 2, canvas.height / 2);
220
+ ctx.scale(edit.flipH ? -1 : 1, edit.flipV ? -1 : 1);
221
+ ctx.rotate(edit.rotate * Math.PI / 180);
222
+ ctx.scale(scale, scale);
223
+ ctx.drawImage(bitmap, -bitmap.width / 2, -bitmap.height / 2);
224
+ return canvas;
225
+ }
226
+ async function renderEdit(bitmap, edit, type, quality) {
227
+ const { crop, width, height } = editGeometry(bitmap.width, bitmap.height, edit);
228
+ const turned = drawTurned(bitmap, edit);
229
+ const out = document.createElement("canvas");
230
+ out.width = width;
231
+ out.height = height;
232
+ const ctx = out.getContext("2d");
233
+ ctx.imageSmoothingQuality = "high";
234
+ ctx.drawImage(turned, crop.x, crop.y, crop.width, crop.height, 0, 0, width, height);
235
+ if (hasColorEdit(edit)) {
236
+ const pixels = ctx.getImageData(0, 0, width, height);
237
+ adjustPixels(pixels.data, edit);
238
+ ctx.putImageData(pixels, 0, 0);
239
+ }
240
+ return new Promise(
241
+ (resolve, reject) => out.toBlob(
242
+ (blob) => blob ? resolve(blob) : reject(new Error("the canvas gave no file")),
243
+ type,
244
+ quality
245
+ )
246
+ );
247
+ }
248
+ function readAsDataUrl(file) {
249
+ return new Promise((resolve, reject) => {
250
+ const reader = new FileReader();
251
+ reader.onload = () => resolve(String(reader.result));
252
+ reader.onerror = () => reject(reader.error ?? new Error("FileReader failed"));
253
+ reader.readAsDataURL(file);
254
+ });
255
+ }
256
+ function findImageNode(editor, src, near) {
257
+ const { doc } = editor.view.state;
258
+ const nodes = nodesOf(editor.view.state);
259
+ const isImage = (node) => !!node && (node.type === nodes.image || node.type === nodes.figure_image) && node.attrs.src === src;
260
+ if (near !== void 0 && near >= 0 && near < doc.content.size && isImage(doc.nodeAt(near)))
261
+ return near;
262
+ let found = null;
263
+ doc.descendants((node, pos) => {
264
+ if (found !== null) return false;
265
+ if (isImage(node)) found = pos;
266
+ return true;
267
+ });
268
+ return found;
269
+ }
270
+ function selectedImageNode(editor) {
271
+ const selected = getSelectedImage(editor.view.state);
272
+ if (!selected) return null;
273
+ const nodes = nodesOf(editor.view.state);
274
+ if (selected.node.type === nodes.figure) {
275
+ const inner = selected.node.firstChild;
276
+ return inner ? { pos: selected.pos + 1, node: inner } : null;
277
+ }
278
+ return { pos: selected.pos, node: selected.node };
279
+ }
280
+ function setAttrs(editor, pos, attrs, history, select) {
281
+ const { state } = editor.view;
282
+ const node = state.doc.nodeAt(pos);
283
+ if (!node) return;
284
+ const tr = state.tr.setNodeMarkup(pos, void 0, { ...node.attrs, ...attrs });
285
+ if (select && node.type === nodesOf(state).image)
286
+ tr.setSelection(NodeSelection.create(tr.doc, pos));
287
+ if (history) closeHistory(tr);
288
+ else tr.setMeta("addToHistory", false);
289
+ editor.view.dispatch(tr);
290
+ }
291
+ async function replaceImage(editor, labels, at, file, size) {
292
+ const original = {
293
+ src: at.node.attrs.src,
294
+ width: at.node.attrs.width,
295
+ height: at.node.attrs.height
296
+ };
297
+ const handler = editor.options.uploadImage;
298
+ const embedded = handler ? null : await readAsDataUrl(file);
299
+ const pos = findImageNode(editor, String(original.src), at.pos);
300
+ if (pos === null) return;
301
+ if (!handler) {
302
+ setAttrs(editor, pos, { src: embedded, ...size }, true, true);
303
+ editor.focus();
304
+ return;
305
+ }
306
+ const local = URL.createObjectURL(file);
307
+ setAttrs(editor, pos, { src: local, ...size }, true, true);
308
+ editor.focus();
309
+ try {
310
+ const url = await handler(file, () => {
311
+ });
312
+ if (!isSafeImageUrl(url)) throw new Error(`Unsafe image URL returned: ${url}`);
313
+ const now = findImageNode(editor, local);
314
+ if (now !== null) setAttrs(editor, now, { src: url }, false, false);
315
+ } catch (error) {
316
+ console.error("[nova] editimage: the upload failed", error);
317
+ const now = findImageNode(editor, local);
318
+ if (now !== null) setAttrs(editor, now, original, false, false);
319
+ editor.ui.notify({ text: labels.failed, type: "error" });
320
+ } finally {
321
+ URL.revokeObjectURL(local);
322
+ }
323
+ }
324
+ function displaySize(node, bitmap, edit) {
325
+ const { width, height } = editGeometry(bitmap.width, bitmap.height, edit);
326
+ const shown = Number(node.attrs.width);
327
+ if (!shown || edit.width !== null || edit.height !== null) return { width: null, height: null };
328
+ const scale = shown / bitmap.width;
329
+ return {
330
+ width: Math.max(1, Math.round(width * scale)),
331
+ height: node.attrs.height ? Math.max(1, Math.round(height * scale)) : null
332
+ };
333
+ }
334
+ function problem(error, labels) {
335
+ if (error instanceof UnsupportedImage) return labels.unsupported;
336
+ if (error instanceof UnreadableImage) return labels.unreadable;
337
+ return labels.failed;
338
+ }
339
+ var editimage_default2 = definePlugin({
340
+ name: "editimage",
341
+ setup(editor) {
342
+ const labels = pickLabels(editor, "editimage", LABELS);
343
+ const options = editor.options.pluginOptions?.editimage ?? {};
344
+ const quality = Number.isFinite(options.quality) ? Math.min(1, Math.max(0.1, options.quality)) : 0.92;
345
+ editor.ui.addStyles("nova-editimage", editimage_default);
346
+ const apply = async (edit, read) => {
347
+ const at = read?.at ?? selectedImageNode(editor);
348
+ if (!at) return;
349
+ const notice = editor.ui.notify({ text: labels.working, timeout: 0 });
350
+ try {
351
+ const blob = read?.blob ?? await loadImage(String(at.node.attrs.src), options);
352
+ const bitmap = read?.bitmap ?? await createImageBitmap(blob);
353
+ const type = outputType(blob.type);
354
+ const result = await renderEdit(bitmap, edit, type, quality);
355
+ const file = new File([result], editedName(String(at.node.attrs.src), type), { type });
356
+ await replaceImage(editor, labels, at, file, displaySize(at.node, bitmap, edit));
357
+ } catch (error) {
358
+ console.warn("[nova] editimage:", error);
359
+ editor.ui.notify({ text: problem(error, labels), type: "error" });
360
+ } finally {
361
+ notice.close();
362
+ }
363
+ };
364
+ const quick = (name, label, svgIcon, edit) => {
365
+ editor.ui.registry.addButton(name, {
366
+ icon: svgIcon,
367
+ tooltip: label,
368
+ isEnabled: (e) => e.isEditable() && !!selectedImageNode(e),
369
+ onAction: () => void apply({ ...NO_EDIT, ...edit })
370
+ });
371
+ };
372
+ quick("rotateleft", labels.rotateLeft, ICONS.rotateLeft, { rotate: 270 });
373
+ quick("rotateright", labels.rotateRight, ICONS.rotateRight, { rotate: 90 });
374
+ quick("fliph", labels.flipH, ICONS.flipH, { flipH: true });
375
+ quick("flipv", labels.flipV, ICONS.flipV, { flipV: true });
376
+ const openEditor = async () => {
377
+ const at = selectedImageNode(editor);
378
+ if (!at) return;
379
+ let blob;
380
+ let bitmap;
381
+ try {
382
+ blob = await loadImage(String(at.node.attrs.src), options);
383
+ bitmap = await createImageBitmap(blob);
384
+ } catch (error) {
385
+ console.warn("[nova] editimage:", error);
386
+ editor.ui.notify({ text: problem(error, labels), type: "error" });
387
+ return;
388
+ }
389
+ openEditDialog(editor, labels, bitmap, (edit) => void apply(edit, { blob, bitmap, at }));
390
+ };
391
+ editor.ui.registry.addButton("editimage", {
392
+ icon: ICONS.edit,
393
+ tooltip: labels.edit,
394
+ isEnabled: (e) => e.isEditable() && !!selectedImageNode(e),
395
+ onAction: () => void openEditor()
396
+ });
397
+ const toolbar = typeof options.toolbar === "string" ? options.toolbar : "rotateleft rotateright | flipv fliph | editimage";
398
+ const image = editor.ui.registry.getContextToolbars().find(([name]) => name === "image")?.[1];
399
+ if (image && toolbar.trim())
400
+ editor.ui.registry.addContextToolbar("image", {
401
+ ...image,
402
+ items: `${image.items} | ${toolbar}`
403
+ });
404
+ }
405
+ });
406
+ function openEditDialog(editor, labels, bitmap, onApply) {
407
+ let edit = { ...NO_EDIT };
408
+ let ratio = null;
409
+ const MAX_W = 620;
410
+ const MAX_H = 320;
411
+ const canvas = h("canvas", { className: "nova-editimage-canvas" });
412
+ const cropBox = h("div", { className: "nova-editimage-crop", "aria-hidden": "true" });
413
+ const stage = h(
414
+ "div",
415
+ { className: "nova-editimage-stage", role: "img", "aria-label": labels.preview },
416
+ canvas,
417
+ cropBox
418
+ );
419
+ const num = (label, min = 0) => {
420
+ const input = h("input", {
421
+ type: "number",
422
+ className: "nova-input",
423
+ min: String(min),
424
+ step: "1",
425
+ inputmode: "numeric"
426
+ });
427
+ const field = h("label", { className: "nova-editimage-field" }, h("span", {}, label), input);
428
+ return { input, field };
429
+ };
430
+ const range = (label) => {
431
+ const input = h("input", { type: "range", min: "-100", max: "100", step: "1", value: "0" });
432
+ const output = h("output", { className: "nova-editimage-value" }, "0");
433
+ const field = h(
434
+ "label",
435
+ { className: "nova-editimage-field nova-editimage-range" },
436
+ h("span", {}, label),
437
+ input,
438
+ output
439
+ );
440
+ return { input, output, field };
441
+ };
442
+ const shape = h(
443
+ "select",
444
+ { className: "nova-input" },
445
+ ...[
446
+ ["", labels.free],
447
+ ["original", labels.original],
448
+ ["1", labels.square],
449
+ [String(4 / 3), "4:3"],
450
+ [String(3 / 2), "3:2"],
451
+ [String(16 / 9), "16:9"]
452
+ ].map(([value, text]) => h("option", { value }, text))
453
+ );
454
+ const x = num(labels.left);
455
+ const y = num(labels.top);
456
+ const cw = num(labels.width, 1);
457
+ const ch = num(labels.height, 1);
458
+ const ow = num(labels.width, 1);
459
+ const oh = num(labels.height, 1);
460
+ const keep = h("input", {
461
+ type: "checkbox",
462
+ className: "nova-checkbox",
463
+ checked: true
464
+ });
465
+ const brightness = range(labels.brightness);
466
+ const contrast = range(labels.contrast);
467
+ const saturation = range(labels.saturation);
468
+ const tool = (svgIcon, label, run) => {
469
+ const button = h(
470
+ "button",
471
+ { type: "button", className: "nova-btn", "aria-label": label, "data-tooltip": label },
472
+ icon(svgIcon)
473
+ );
474
+ button.addEventListener("click", run);
475
+ editor.ui.tooltip.attach(button);
476
+ return button;
477
+ };
478
+ const reset = h("button", { type: "button", className: "nova-button" }, labels.reset);
479
+ const turned = () => rotatedSize(bitmap.width, bitmap.height, edit.rotate);
480
+ const currentCrop = () => {
481
+ const [w, hgt] = turned();
482
+ return edit.crop ? clampRect(edit.crop, w, hgt) : { x: 0, y: 0, width: w, height: hgt };
483
+ };
484
+ let scale = 1;
485
+ let frame = 0;
486
+ const draw = () => {
487
+ cancelAnimationFrame(frame);
488
+ frame = requestAnimationFrame(() => {
489
+ const [w, hgt] = turned();
490
+ const room = Math.min(MAX_W, stage.parentElement?.clientWidth || MAX_W);
491
+ scale = Math.min(1, room / w, MAX_H / hgt);
492
+ const preview = drawTurned(bitmap, edit, scale);
493
+ canvas.width = preview.width;
494
+ canvas.height = preview.height;
495
+ const ctx = canvas.getContext("2d");
496
+ ctx.drawImage(preview, 0, 0);
497
+ if (hasColorEdit(edit)) {
498
+ const pixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
499
+ adjustPixels(pixels.data, edit);
500
+ ctx.putImageData(pixels, 0, 0);
501
+ }
502
+ const crop = currentCrop();
503
+ cropBox.hidden = !edit.crop;
504
+ cropBox.style.left = `${crop.x * scale}px`;
505
+ cropBox.style.top = `${crop.y * scale}px`;
506
+ cropBox.style.width = `${crop.width * scale}px`;
507
+ cropBox.style.height = `${crop.height * scale}px`;
508
+ });
509
+ };
510
+ const fill = () => {
511
+ const crop = currentCrop();
512
+ x.input.value = String(crop.x);
513
+ y.input.value = String(crop.y);
514
+ cw.input.value = String(crop.width);
515
+ ch.input.value = String(crop.height);
516
+ const { width, height } = editGeometry(bitmap.width, bitmap.height, edit);
517
+ ow.input.value = String(width);
518
+ oh.input.value = String(height);
519
+ for (const [r, value] of [
520
+ [brightness, edit.brightness],
521
+ [contrast, edit.contrast],
522
+ [saturation, edit.saturation]
523
+ ]) {
524
+ r.input.value = String(value);
525
+ r.output.textContent = String(value);
526
+ }
527
+ draw();
528
+ };
529
+ const setCrop = (rect) => {
530
+ const [w, hgt] = turned();
531
+ const crop = rect ? clampRect(rect, w, hgt) : null;
532
+ const whole = crop && crop.x === 0 && crop.y === 0 && crop.width === w && crop.height === hgt;
533
+ edit = { ...edit, crop: whole ? null : crop, width: null, height: null };
534
+ fill();
535
+ };
536
+ const shapeRatio = () => {
537
+ if (!shape.value) return null;
538
+ if (shape.value === "original") {
539
+ const [w, hgt] = turned();
540
+ return w / hgt;
541
+ }
542
+ return Number(shape.value) || null;
543
+ };
544
+ const tools = h(
545
+ "div",
546
+ { className: "nova-editimage-tools", role: "toolbar", "aria-label": labels.edit },
547
+ tool(ICONS.rotateLeft, labels.rotateLeft, () => {
548
+ edit = { ...edit, rotate: turn(edit.rotate, -90), crop: null, width: null, height: null };
549
+ fill();
550
+ }),
551
+ tool(ICONS.rotateRight, labels.rotateRight, () => {
552
+ edit = { ...edit, rotate: turn(edit.rotate, 90), crop: null, width: null, height: null };
553
+ fill();
554
+ }),
555
+ tool(ICONS.flipH, labels.flipH, () => {
556
+ edit = { ...edit, flipH: !edit.flipH, crop: null, width: null, height: null };
557
+ fill();
558
+ }),
559
+ tool(ICONS.flipV, labels.flipV, () => {
560
+ edit = { ...edit, flipV: !edit.flipV, crop: null, width: null, height: null };
561
+ fill();
562
+ }),
563
+ h("span", { className: "nova-bubble-sep", role: "separator" }),
564
+ reset
565
+ );
566
+ reset.addEventListener("click", () => {
567
+ edit = { ...NO_EDIT };
568
+ shape.value = "";
569
+ ratio = null;
570
+ fill();
571
+ });
572
+ shape.addEventListener("change", () => {
573
+ ratio = shapeRatio();
574
+ const [w, hgt] = turned();
575
+ setCrop(ratio ? rectOfRatio(w, hgt, ratio) : null);
576
+ });
577
+ const fromCropFields = () => {
578
+ const width = Number(cw.input.value) || 1;
579
+ const height = ratio ? Math.round(width / ratio) : Number(ch.input.value) || 1;
580
+ setCrop({ x: Number(x.input.value) || 0, y: Number(y.input.value) || 0, width, height });
581
+ };
582
+ for (const field of [x, y, cw, ch]) field.input.addEventListener("change", fromCropFields);
583
+ ow.input.addEventListener("change", () => {
584
+ const crop = currentCrop();
585
+ const width = Math.max(1, Number(ow.input.value) || crop.width);
586
+ const height = keep.checked ? Math.max(1, Math.round(width * crop.height / crop.width)) : Number(oh.input.value) || crop.height;
587
+ edit = { ...edit, width, height };
588
+ fill();
589
+ });
590
+ oh.input.addEventListener("change", () => {
591
+ const crop = currentCrop();
592
+ const height = Math.max(1, Number(oh.input.value) || crop.height);
593
+ const width = keep.checked ? Math.max(1, Math.round(height * crop.width / crop.height)) : Number(ow.input.value) || crop.width;
594
+ edit = { ...edit, width, height };
595
+ fill();
596
+ });
597
+ for (const [r, key] of [
598
+ [brightness, "brightness"],
599
+ [contrast, "contrast"],
600
+ [saturation, "saturation"]
601
+ ]) {
602
+ r.input.addEventListener("input", () => {
603
+ edit = { ...edit, [key]: Number(r.input.value) || 0 };
604
+ r.output.textContent = r.input.value;
605
+ draw();
606
+ });
607
+ }
608
+ stage.addEventListener("pointerdown", (event) => {
609
+ if (event.button !== 0) return;
610
+ const box = canvas.getBoundingClientRect();
611
+ const toImage = (e) => ({
612
+ x: Math.min(Math.max(0, (e.clientX - box.left) / scale), turned()[0]),
613
+ y: Math.min(Math.max(0, (e.clientY - box.top) / scale), turned()[1])
614
+ });
615
+ const start = toImage(event);
616
+ const crop = currentCrop();
617
+ const moving = !!edit.crop && start.x >= crop.x && start.x <= crop.x + crop.width && start.y >= crop.y && start.y <= crop.y + crop.height;
618
+ stage.setPointerCapture(event.pointerId);
619
+ event.preventDefault();
620
+ const onMove = (e) => {
621
+ const p = toImage(e);
622
+ if (moving) {
623
+ setCrop({ ...crop, x: crop.x + p.x - start.x, y: crop.y + p.y - start.y });
624
+ return;
625
+ }
626
+ const width = Math.abs(p.x - start.x);
627
+ const height = ratio ? width / ratio : Math.abs(p.y - start.y);
628
+ if (width < 4 || height < 4) return;
629
+ setCrop({
630
+ x: p.x < start.x ? start.x - width : start.x,
631
+ y: p.y < start.y ? start.y - height : start.y,
632
+ width,
633
+ height
634
+ });
635
+ };
636
+ const onUp = () => {
637
+ stage.removeEventListener("pointermove", onMove);
638
+ stage.removeEventListener("pointerup", onUp);
639
+ stage.removeEventListener("pointercancel", onUp);
640
+ };
641
+ stage.addEventListener("pointermove", onMove);
642
+ stage.addEventListener("pointerup", onUp);
643
+ stage.addEventListener("pointercancel", onUp);
644
+ });
645
+ const group = (title, ...children) => h("fieldset", { className: "nova-editimage-group" }, h("legend", {}, title), ...children);
646
+ const body = h(
647
+ "div",
648
+ { className: "nova-editimage" },
649
+ tools,
650
+ stage,
651
+ group(
652
+ labels.crop,
653
+ h("label", { className: "nova-editimage-field" }, h("span", {}, labels.shape), shape),
654
+ x.field,
655
+ y.field,
656
+ cw.field,
657
+ ch.field
658
+ ),
659
+ group(
660
+ labels.size,
661
+ ow.field,
662
+ oh.field,
663
+ h("label", { className: "nova-editimage-check" }, keep, h("span", {}, labels.keepRatio))
664
+ ),
665
+ group(labels.colors, brightness.field, contrast.field, saturation.field)
666
+ );
667
+ editor.ui.openDialog({
668
+ title: labels.edit,
669
+ body,
670
+ size: "large",
671
+ submitLabel: labels.apply,
672
+ onSubmit: () => {
673
+ onApply({ ...edit });
674
+ return true;
675
+ }
676
+ });
677
+ fill();
678
+ }
679
+ export {
680
+ LABELS,
681
+ editimage_default2 as default
682
+ };
683
+ //# sourceMappingURL=editimage-5EWPSM22.js.map