reactjs-tiptap-editor 0.4.2 → 1.0.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/lib/ActionMenuButton-BKOg7hkq.js +38 -0
  2. package/lib/ActionMenuButton-DLQyd_gx.cjs +1 -0
  3. package/lib/Attachment.cjs +2 -2
  4. package/lib/Attachment.d.cts +32 -44
  5. package/lib/Attachment.d.ts +32 -44
  6. package/lib/Attachment.js +129 -99
  7. package/lib/Blockquote.cjs +3 -3
  8. package/lib/Blockquote.d.cts +32 -44
  9. package/lib/Blockquote.d.ts +32 -44
  10. package/lib/Blockquote.js +50 -22
  11. package/lib/Bold.cjs +1 -1
  12. package/lib/Bold.d.cts +32 -44
  13. package/lib/Bold.d.ts +32 -44
  14. package/lib/Bold.js +48 -20
  15. package/lib/BulletList.cjs +1 -1
  16. package/lib/BulletList.d.cts +32 -44
  17. package/lib/BulletList.d.ts +32 -44
  18. package/lib/BulletList.js +38 -9
  19. package/lib/Clear.cjs +1 -1
  20. package/lib/Clear.d.cts +32 -44
  21. package/lib/Clear.d.ts +32 -44
  22. package/lib/Clear.js +32 -6
  23. package/lib/Code.cjs +1 -1
  24. package/lib/Code.d.cts +32 -44
  25. package/lib/Code.d.ts +32 -44
  26. package/lib/Code.js +53 -25
  27. package/lib/CodeBlock.cjs +35 -35
  28. package/lib/CodeBlock.d.cts +32 -44
  29. package/lib/CodeBlock.d.ts +32 -44
  30. package/lib/CodeBlock.js +605 -590
  31. package/lib/CodeView.cjs +1 -1
  32. package/lib/CodeView.d.cts +33 -45
  33. package/lib/CodeView.d.ts +33 -45
  34. package/lib/CodeView.js +49 -21
  35. package/lib/Color.cjs +1 -1
  36. package/lib/Color.d.cts +36 -44
  37. package/lib/Color.d.ts +36 -44
  38. package/lib/Color.js +123 -79
  39. package/lib/Column.cjs +1 -0
  40. package/lib/{Document.d.cts → Column.d.cts} +38 -47
  41. package/lib/{Document.d.ts → Column.d.ts} +38 -47
  42. package/lib/Column.js +217 -0
  43. package/lib/{Drawer-CaAfmqNo.js → Drawer-DZ5jvmrX.js} +404 -394
  44. package/lib/Drawer-SRhwOc6T.cjs +1 -0
  45. package/lib/Drawer.cjs +1 -1
  46. package/lib/Drawer.d.cts +32 -44
  47. package/lib/Drawer.d.ts +32 -44
  48. package/lib/Drawer.js +6 -5
  49. package/lib/Emoji.cjs +1 -1
  50. package/lib/Emoji.d.cts +32 -49
  51. package/lib/Emoji.d.ts +32 -49
  52. package/lib/Emoji.js +377 -392
  53. package/lib/Excalidraw-DwBRXEtC.js +345 -0
  54. package/lib/Excalidraw-ZN3DQvDC.cjs +1 -0
  55. package/lib/Excalidraw.cjs +1 -1
  56. package/lib/Excalidraw.d.cts +32 -44
  57. package/lib/Excalidraw.d.ts +32 -44
  58. package/lib/Excalidraw.js +6 -4
  59. package/lib/ExportPdf.cjs +5 -5
  60. package/lib/ExportPdf.d.cts +32 -44
  61. package/lib/ExportPdf.d.ts +32 -44
  62. package/lib/ExportPdf.js +60 -32
  63. package/lib/ExportWord.cjs +1 -1
  64. package/lib/ExportWord.d.cts +33 -45
  65. package/lib/ExportWord.d.ts +33 -45
  66. package/lib/ExportWord.js +84 -21
  67. package/lib/FontFamily.cjs +1 -1
  68. package/lib/FontFamily.d.cts +46 -47
  69. package/lib/FontFamily.d.ts +46 -47
  70. package/lib/FontFamily.js +72 -74
  71. package/lib/FontSize.cjs +1 -1
  72. package/lib/FontSize.d.cts +43 -47
  73. package/lib/FontSize.d.ts +43 -47
  74. package/lib/FontSize.js +72 -64
  75. package/lib/Heading.cjs +1 -1
  76. package/lib/Heading.d.cts +46 -44
  77. package/lib/Heading.d.ts +46 -44
  78. package/lib/Heading.js +91 -73
  79. package/lib/Highlight.cjs +1 -1
  80. package/lib/Highlight.d.cts +36 -44
  81. package/lib/Highlight.d.ts +36 -44
  82. package/lib/Highlight.js +152 -21
  83. package/lib/History.cjs +1 -1
  84. package/lib/History.d.cts +34 -44
  85. package/lib/History.d.ts +34 -44
  86. package/lib/History.js +976 -53
  87. package/lib/HorizontalRule.cjs +1 -1
  88. package/lib/HorizontalRule.d.cts +32 -44
  89. package/lib/HorizontalRule.d.ts +32 -44
  90. package/lib/HorizontalRule.js +97 -17
  91. package/lib/Icon-DUpv2cI6.cjs +1 -0
  92. package/lib/Icon-jKs8Hr6p.js +11 -0
  93. package/lib/Iframe-CmXkEqOd.js +431 -0
  94. package/lib/Iframe-Cvca2G7X.cjs +1 -0
  95. package/lib/Iframe.cjs +1 -1
  96. package/lib/Iframe.d.cts +31 -50
  97. package/lib/Iframe.d.ts +31 -50
  98. package/lib/Iframe.js +6 -4
  99. package/lib/Image.cjs +1 -1
  100. package/lib/Image.d.cts +32 -45
  101. package/lib/Image.d.ts +32 -45
  102. package/lib/Image.js +848 -5
  103. package/lib/ImageGif.cjs +1 -1
  104. package/lib/ImageGif.d.cts +33 -47
  105. package/lib/ImageGif.d.ts +33 -47
  106. package/lib/ImageGif.js +424 -5
  107. package/lib/ImportWord.cjs +48 -48
  108. package/lib/ImportWord.d.cts +33 -45
  109. package/lib/ImportWord.d.ts +33 -45
  110. package/lib/ImportWord.js +2596 -2588
  111. package/lib/Indent.cjs +1 -1
  112. package/lib/Indent.d.cts +32 -44
  113. package/lib/Indent.d.ts +32 -44
  114. package/lib/Indent.js +97 -27
  115. package/lib/Italic.cjs +1 -1
  116. package/lib/Italic.d.cts +32 -44
  117. package/lib/Italic.d.ts +32 -44
  118. package/lib/Italic.js +47 -19
  119. package/lib/Katex-DsYXsjSS.js +2740 -0
  120. package/lib/Katex-XfrNne6U.cjs +4 -0
  121. package/lib/Katex.cjs +1 -1
  122. package/lib/Katex.d.cts +32 -44
  123. package/lib/Katex.d.ts +32 -44
  124. package/lib/Katex.js +5 -196
  125. package/lib/LineHeight.cjs +1 -1
  126. package/lib/LineHeight.d.cts +34 -50
  127. package/lib/LineHeight.d.ts +34 -50
  128. package/lib/LineHeight.js +71 -112
  129. package/lib/Link.cjs +1 -1
  130. package/lib/Link.d.cts +33 -47
  131. package/lib/Link.d.ts +33 -47
  132. package/lib/Link.js +3 -3
  133. package/lib/LinkEditBlock-BZenZq-Z.cjs +5 -0
  134. package/lib/LinkEditBlock-CB8yIffE.js +1241 -0
  135. package/lib/Mention.cjs +1 -1
  136. package/lib/Mention.d.cts +29 -44
  137. package/lib/Mention.d.ts +29 -44
  138. package/lib/Mention.js +112 -124
  139. package/lib/Mermaid.cjs +2 -2
  140. package/lib/Mermaid.d.cts +32 -44
  141. package/lib/Mermaid.d.ts +32 -44
  142. package/lib/Mermaid.js +177 -165
  143. package/lib/MoreMark.cjs +1 -1
  144. package/lib/MoreMark.d.cts +47 -46
  145. package/lib/MoreMark.d.ts +47 -46
  146. package/lib/MoreMark.js +125 -55
  147. package/lib/OrderedList.cjs +1 -1
  148. package/lib/OrderedList.d.cts +32 -44
  149. package/lib/OrderedList.d.ts +32 -44
  150. package/lib/OrderedList.js +37 -9
  151. package/lib/SearchAndReplace.cjs +1 -1
  152. package/lib/SearchAndReplace.d.cts +32 -47
  153. package/lib/SearchAndReplace.d.ts +32 -47
  154. package/lib/SearchAndReplace.js +221 -197
  155. package/lib/SlashCommand.cjs +1 -1
  156. package/lib/SlashCommand.d.cts +44 -51
  157. package/lib/SlashCommand.d.ts +44 -51
  158. package/lib/SlashCommand.js +235 -249
  159. package/lib/Strike.cjs +1 -1
  160. package/lib/Strike.d.cts +32 -44
  161. package/lib/Strike.d.ts +32 -44
  162. package/lib/Strike.js +39 -11
  163. package/lib/Table-B1j1Ebmh.cjs +9 -0
  164. package/lib/Table-Db8TcQX8.js +1984 -0
  165. package/lib/Table.cjs +1 -9
  166. package/lib/Table.d.cts +33 -47
  167. package/lib/Table.d.ts +33 -47
  168. package/lib/Table.js +3 -558
  169. package/lib/TaskList.cjs +1 -1
  170. package/lib/TaskList.d.cts +32 -44
  171. package/lib/TaskList.d.ts +32 -44
  172. package/lib/TaskList.js +38 -10
  173. package/lib/TextAlign.cjs +1 -1
  174. package/lib/TextAlign.d.cts +45 -44
  175. package/lib/TextAlign.d.ts +45 -44
  176. package/lib/TextAlign.js +108 -101
  177. package/lib/TextDirection.cjs +1 -1
  178. package/lib/TextDirection.d.cts +61 -44
  179. package/lib/TextDirection.d.ts +61 -44
  180. package/lib/TextDirection.js +105 -112
  181. package/lib/TextUnderline.cjs +1 -1
  182. package/lib/TextUnderline.d.cts +32 -44
  183. package/lib/TextUnderline.d.ts +32 -44
  184. package/lib/TextUnderline.js +46 -18
  185. package/lib/{Twitter-BFULyqdR.js → Twitter-CXmmjz9R.js} +536 -498
  186. package/lib/Twitter-CtVTIWJW.cjs +1 -0
  187. package/lib/Twitter.cjs +1 -1
  188. package/lib/Twitter.d.cts +32 -44
  189. package/lib/Twitter.d.ts +32 -44
  190. package/lib/Twitter.js +5 -4
  191. package/lib/Video.cjs +1 -1
  192. package/lib/Video.d.cts +32 -44
  193. package/lib/Video.d.ts +32 -44
  194. package/lib/Video.js +261 -4
  195. package/lib/_commonjsHelpers-BItOPCY9.js +28 -0
  196. package/lib/_commonjsHelpers-BTDuMlIz.cjs +1 -0
  197. package/lib/bubble.cjs +2 -0
  198. package/lib/{bubble-extra.d.cts → bubble.d.cts} +58 -59
  199. package/lib/{bubble-extra.d.ts → bubble.d.ts} +58 -59
  200. package/lib/bubble.js +1925 -0
  201. package/lib/button-B12K7BJ4.cjs +1 -0
  202. package/lib/button-DXMsXUEn.js +43 -0
  203. package/lib/clsx-C11secjj.cjs +1 -0
  204. package/lib/clsx-OuTLNxxd.js +16 -0
  205. package/lib/delete-node-CosiBes5.cjs +1 -0
  206. package/lib/delete-node-IyVmiRbI.js +22 -0
  207. package/lib/dialog-CaCS-W5S.cjs +1 -0
  208. package/lib/dialog-PtQivpHS.js +100 -0
  209. package/lib/dom-dataset-BqoJhJXt.cjs +1 -0
  210. package/lib/dom-dataset-CIEeltF6.js +47 -0
  211. package/lib/dropdown-menu-BPp2Z_U-.js +136 -0
  212. package/lib/dropdown-menu-CdSm4emp.cjs +1 -0
  213. package/lib/file-BLas99n7.js +43 -0
  214. package/lib/file-i7e4nQY2.cjs +1 -0
  215. package/lib/floating-ui.dom-U1vPFQ5f.js +1151 -0
  216. package/lib/floating-ui.dom-VCrc58uF.cjs +1 -0
  217. package/lib/icons-Cllpys39.js +362 -0
  218. package/lib/icons-CqHjeW5T.cjs +1 -0
  219. package/lib/index-BH4bc3jN.cjs +33 -0
  220. package/lib/index-BPfVXs5_.js +2380 -0
  221. package/lib/index-Bnmd0WvY.js +1631 -0
  222. package/lib/{index-Ch6dBBad.js → index-CBce_TWY.js} +40 -42
  223. package/lib/{index-5iBZLua9.cjs → index-D-5U8dY8.cjs} +8 -8
  224. package/lib/{index-ByurDDMv.js → index-D2TUfKkC.js} +2 -2
  225. package/lib/index-DV5kbgRU.cjs +1 -0
  226. package/lib/{index-LmrOdnen.js → index-DYkucCoF.js} +396 -495
  227. package/lib/index-Dfmm6FTT.cjs +1 -0
  228. package/lib/index-DnWWK9F_.js +6374 -0
  229. package/lib/index-DzcKxutn.js +632 -0
  230. package/lib/index-DzvuNTxo.cjs +4 -0
  231. package/lib/{index-BeCTd5v2.cjs → index-N--9MohJ.cjs} +1 -1
  232. package/lib/index-RfTlOzIr.cjs +22 -0
  233. package/lib/index.cjs +132 -1
  234. package/lib/index.d.cts +34 -285
  235. package/lib/index.d.ts +34 -285
  236. package/lib/index.js +243 -2
  237. package/lib/input-_ECRfn3Y.cjs +1 -0
  238. package/lib/input-wJ9PDEzZ.js +21 -0
  239. package/lib/isNumber-ClPupm7P.cjs +1 -0
  240. package/lib/isNumber-fpLGS0AZ.js +15 -0
  241. package/lib/label-BkgAe7IY.cjs +1 -0
  242. package/lib/label-CGdLYWv7.js +19 -0
  243. package/lib/locale-bundle.cjs +1 -1
  244. package/lib/locale-bundle.d.cts +5410 -62
  245. package/lib/locale-bundle.d.ts +5410 -62
  246. package/lib/locale-bundle.js +9 -7
  247. package/lib/popover-BgmUNMHj.cjs +1 -0
  248. package/lib/popover-CAuEW0Mr.js +23 -0
  249. package/lib/separator-CuBW_w98.js +328 -0
  250. package/lib/separator-DRIrVZ2N.cjs +1 -0
  251. package/lib/store-DX599H5W.js +10 -0
  252. package/lib/store-WStcMOiW.cjs +1 -0
  253. package/lib/style.css +1 -1
  254. package/lib/switch-CnLJ7Y-b.cjs +1 -0
  255. package/lib/switch-Coix_FA1.js +27 -0
  256. package/lib/tabs-B5mVSN1I.js +46 -0
  257. package/lib/tabs-BoLCMcCI.cjs +1 -0
  258. package/lib/textarea-B-6zTKQz.cjs +1 -0
  259. package/lib/{textarea-aPtytkDx.js → textarea-DUUM1jZd.js} +1 -1
  260. package/lib/theme-B7aAsK_T.js +15 -0
  261. package/lib/theme-D8_cxGqB.cjs +1 -0
  262. package/lib/throttle-CdwDrFpn.js +249 -0
  263. package/lib/throttle-qX7Yjtsg.cjs +1 -0
  264. package/lib/toggle-Cdp4IT2U.js +85 -0
  265. package/lib/toggle-D41PzQLJ.cjs +1 -0
  266. package/lib/tooltip-BuEiE96N.cjs +1 -0
  267. package/lib/tooltip-CopwsU8q.js +23 -0
  268. package/lib/updatePosition-8Sdem5jb.cjs +1 -0
  269. package/lib/updatePosition-BPmcE0YD.js +215 -0
  270. package/lib/use-toast-Bz3QCOtE.cjs +1 -0
  271. package/lib/use-toast-Crf7-q5H.js +98 -0
  272. package/lib/useButtonProps-BsEd4zYM.js +141 -0
  273. package/lib/useButtonProps-C6Vpn190.cjs +1 -0
  274. package/package.json +22 -105
  275. package/lib/ActionMenuButton-CYdM1xx5.cjs +0 -1
  276. package/lib/ActionMenuButton-DKRF6oa0.js +0 -33
  277. package/lib/BaseKit.cjs +0 -3
  278. package/lib/BaseKit.d.cts +0 -481
  279. package/lib/BaseKit.d.ts +0 -481
  280. package/lib/BaseKit.js +0 -132
  281. package/lib/Document.cjs +0 -1
  282. package/lib/Document.js +0 -9
  283. package/lib/Drawer-CdvCMSzN.cjs +0 -1
  284. package/lib/Excalidraw-BbMQhNvs.cjs +0 -1
  285. package/lib/Excalidraw-CVWz2Vyn.js +0 -290
  286. package/lib/FormatPainter.cjs +0 -1
  287. package/lib/FormatPainter.d.cts +0 -372
  288. package/lib/FormatPainter.d.ts +0 -372
  289. package/lib/FormatPainter.js +0 -76
  290. package/lib/ListItem.cjs +0 -1
  291. package/lib/ListItem.d.cts +0 -290
  292. package/lib/ListItem.d.ts +0 -290
  293. package/lib/ListItem.js +0 -7
  294. package/lib/MultiColumn.cjs +0 -1
  295. package/lib/MultiColumn.d.cts +0 -294
  296. package/lib/MultiColumn.d.ts +0 -294
  297. package/lib/MultiColumn.js +0 -8
  298. package/lib/RichTextEditor-CxvwGvQG.cjs +0 -142
  299. package/lib/RichTextEditor-DGcKEUGr.js +0 -22166
  300. package/lib/Selection.cjs +0 -1
  301. package/lib/Selection.d.cts +0 -289
  302. package/lib/Selection.d.ts +0 -289
  303. package/lib/Selection.js +0 -25
  304. package/lib/SubAndSuperScript.cjs +0 -1
  305. package/lib/SubAndSuperScript.d.cts +0 -377
  306. package/lib/SubAndSuperScript.d.ts +0 -377
  307. package/lib/SubAndSuperScript.js +0 -43
  308. package/lib/TableOfContent.cjs +0 -1
  309. package/lib/TableOfContent.d.cts +0 -291
  310. package/lib/TableOfContent.d.ts +0 -291
  311. package/lib/TableOfContent.js +0 -185
  312. package/lib/TextBubble.cjs +0 -1
  313. package/lib/TextBubble.d.cts +0 -362
  314. package/lib/TextBubble.d.ts +0 -362
  315. package/lib/TextBubble.js +0 -133
  316. package/lib/TrailingNode.cjs +0 -1
  317. package/lib/TrailingNode.d.cts +0 -297
  318. package/lib/TrailingNode.d.ts +0 -297
  319. package/lib/TrailingNode.js +0 -41
  320. package/lib/Twitter-Cutpkh3h.cjs +0 -1
  321. package/lib/bubble-extra.cjs +0 -2
  322. package/lib/bubble-extra.js +0 -631
  323. package/lib/dom-dataset-_6-diIRQ.cjs +0 -33
  324. package/lib/dom-dataset-lYeH6gfI.js +0 -2361
  325. package/lib/index-6D1J-A-o.cjs +0 -1
  326. package/lib/index-B96Cclrj.cjs +0 -3
  327. package/lib/index-BBz7Nmv9.js +0 -55
  328. package/lib/index-CUogRI7j.cjs +0 -1
  329. package/lib/index-DF2Lp4HZ.cjs +0 -100
  330. package/lib/index-D_L6n8O8.js +0 -76
  331. package/lib/index-Dbvi-Bvh.cjs +0 -1
  332. package/lib/index-DpCrt7xs.cjs +0 -1
  333. package/lib/index-DsAX1Vq8.cjs +0 -1
  334. package/lib/index-Dy4DlW9o.js +0 -12
  335. package/lib/index-J3jHHZ4d.js +0 -200
  336. package/lib/index-VvXaaKe3.js +0 -898
  337. package/lib/index-kbO3iWqL.js +0 -13432
  338. package/lib/textarea-DFo_aXnj.cjs +0 -1
package/lib/Image.js CHANGED
@@ -1,7 +1,850 @@
1
- import "./index-kbO3iWqL.js";
2
- import { U as t, U as e } from "./RichTextEditor-DGcKEUGr.js";
3
- import "./dom-dataset-lYeH6gfI.js";
1
+ import { m as pe } from "./index-DnWWK9F_.js";
2
+ import { a as Z, c as xe } from "./throttle-CdwDrFpn.js";
3
+ import { N as be, R as ye } from "./index-DzcKxutn.js";
4
+ import { jsx as r, jsxs as x, Fragment as H } from "react/jsx-runtime";
5
+ import * as we from "react";
6
+ import j, { useState as M, useMemo as P, useCallback as F, useEffect as W, useRef as ne } from "react";
7
+ import { I as J, m as K, n as Ie, u as le, k as ve, E as Te } from "./index-DYkucCoF.js";
8
+ import { i as Q, c as Ae } from "./isNumber-fpLGS0AZ.js";
9
+ import { A as Ce } from "./toggle-Cdp4IT2U.js";
10
+ import { c as ee, a as Ne } from "./index-BPfVXs5_.js";
11
+ import { I as $ } from "./Icon-jKs8Hr6p.js";
12
+ import { D as oe, a as se, b as ce, c as de, d as Ee } from "./dialog-PtQivpHS.js";
13
+ import Me from "react-image-crop";
14
+ import { B } from "./button-DXMsXUEn.js";
15
+ import { d as Le, r as Se } from "./file-BLas99n7.js";
16
+ import { d as ue, u as _e, a as ke } from "./useButtonProps-BsEd4zYM.js";
17
+ import { u as he } from "./use-toast-Crf7-q5H.js";
18
+ import { a as Re } from "./store-DX599H5W.js";
19
+ import { T as ze, a as Ue, b as te, c as ie } from "./tabs-B5mVSN1I.js";
20
+ import * as G from "@radix-ui/react-checkbox";
21
+ import { Check as De } from "lucide-react";
22
+ import { L as ae } from "./label-CGdLYWv7.js";
23
+ import { I as re } from "./input-wJ9PDEzZ.js";
24
+ const me = we.forwardRef(({ className: e, ...t }, a) => /* @__PURE__ */ r(
25
+ G.Root,
26
+ {
27
+ ref: a,
28
+ className: ee(
29
+ "!richtext-peer !richtext-h-4 !richtext-w-4 !richtext-p-0 !richtext-shrink-0 !richtext-rounded-sm !richtext-border !richtext-border-primary !richtext-ring-offset-background focus-visible:!richtext-outline-none focus-visible:!richtext-ring-2 focus-visible:!richtext-ring-ring focus-visible:!richtext-ring-offset-2 disabled:!richtext-cursor-not-allowed disabled:!richtext-opacity-50 data-[state=checked]:!richtext-bg-primary data-[state=checked]:!richtext-text-primary-foreground",
30
+ e
31
+ ),
32
+ ...t,
33
+ children: /* @__PURE__ */ r(
34
+ G.Indicator,
35
+ {
36
+ className: ee("!richtext-flex !richtext-p-0 !richtext-items-center !richtext-justify-center !richtext-text-current"),
37
+ children: /* @__PURE__ */ r(De, { className: "!richtext-h-4 !richtext-w-4" })
38
+ }
39
+ )
40
+ }
41
+ ));
42
+ me.displayName = G.Root.displayName;
43
+ const X = {
44
+ TOP_LEFT: "tl",
45
+ TOP_RIGHT: "tr",
46
+ BOTTOM_LEFT: "bl",
47
+ BOTTOM_RIGHT: "br"
48
+ };
49
+ function Oe(e) {
50
+ var O, d, L;
51
+ const [t, a] = M({
52
+ width: J,
53
+ height: J
54
+ }), [s, f] = M({
55
+ width: 0,
56
+ height: 0
57
+ }), [u] = M([
58
+ X.TOP_LEFT,
59
+ X.TOP_RIGHT,
60
+ X.BOTTOM_LEFT,
61
+ X.BOTTOM_RIGHT
62
+ ]), [g, v] = M(!1), [h, b] = M({
63
+ x: 0,
64
+ y: 0,
65
+ w: 0,
66
+ h: 0,
67
+ dir: ""
68
+ }), { align: C, inline: T } = (O = e == null ? void 0 : e.node) == null ? void 0 : O.attrs, _ = T && (C === "left" || C === "right"), S = P(() => {
69
+ var q;
70
+ const { src: n, alt: y, width: i, height: l, flipX: m, flipY: o } = (q = e == null ? void 0 : e.node) == null ? void 0 : q.attrs, w = Q(i) ? `${i}px` : i, I = Q(l) ? `${l}px` : l, Y = [];
71
+ m && Y.push("rotateX(180deg)"), o && Y.push("rotateY(180deg)");
72
+ const ge = Y.join(" ");
73
+ return {
74
+ src: n || void 0,
75
+ alt: y || void 0,
76
+ style: {
77
+ width: w || void 0,
78
+ height: I || void 0,
79
+ transform: ge || "none",
80
+ ..._ ? { float: C } : {}
81
+ }
82
+ };
83
+ }, [(d = e == null ? void 0 : e.node) == null ? void 0 : d.attrs]), z = P(() => {
84
+ const {
85
+ style: { width: n }
86
+ } = S;
87
+ return { width: n === "100%" ? n : void 0 };
88
+ }, [S]);
89
+ function R(n) {
90
+ f({
91
+ width: n.target.width,
92
+ height: n.target.height
93
+ });
94
+ }
95
+ function E() {
96
+ const { editor: n, getPos: y } = e;
97
+ n.commands.setNodeSelection(y());
98
+ }
99
+ const N = F(
100
+ Z(() => {
101
+ const { editor: n } = e, { width: y } = getComputedStyle(n.view.dom);
102
+ a((i) => ({
103
+ ...i,
104
+ width: Number.parseInt(y, 10)
105
+ }));
106
+ }, K),
107
+ [e == null ? void 0 : e.editor]
108
+ );
109
+ function k(n, y) {
110
+ n.preventDefault(), n.stopPropagation();
111
+ const i = s.width, l = s.height, m = i / l;
112
+ let o = Number(e.node.attrs.width), w = Number(e.node.attrs.height);
113
+ const I = t.width;
114
+ o && !w ? (o = o > I ? I : o, w = Math.round(o / m)) : w && !o ? (o = Math.round(w * m), o = o > I ? I : o) : !o && !w ? (o = i > I ? I : i, w = Math.round(o / m)) : o = o > I ? I : o, v(!0), b({
115
+ x: n.clientX,
116
+ y: n.clientY,
117
+ w: o,
118
+ h: w,
119
+ dir: y
120
+ });
121
+ }
122
+ const A = F(
123
+ Z((n) => {
124
+ if (n.preventDefault(), n.stopPropagation(), !g)
125
+ return;
126
+ const { x: y, w: i, dir: l } = h, m = (n.clientX - y) * (/l/.test(l) ? -1 : 1), o = Ae(i + m, Ie, t.width);
127
+ e.updateAttributes({
128
+ width: o,
129
+ height: null
130
+ });
131
+ }, K),
132
+ [g, h, t, e.updateAttributes]
133
+ ), p = F(
134
+ (n) => {
135
+ n.preventDefault(), n.stopPropagation(), g && (b({
136
+ x: 0,
137
+ y: 0,
138
+ w: 0,
139
+ h: 0,
140
+ dir: ""
141
+ }), v(!1), E());
142
+ },
143
+ [g, E]
144
+ ), c = F(() => {
145
+ document == null || document.addEventListener("mousemove", A, !0), document == null || document.addEventListener("mouseup", p, !0);
146
+ }, [A, p]), U = F(() => {
147
+ document == null || document.removeEventListener("mousemove", A, !0), document == null || document.removeEventListener("mouseup", p, !0);
148
+ }, [A, p]);
149
+ W(() => (g ? c() : U(), () => {
150
+ U();
151
+ }), [g, c, U]);
152
+ const D = P(() => new ResizeObserver(() => N()), [N]);
153
+ return W(() => (D.observe(e.editor.view.dom), () => {
154
+ D.disconnect();
155
+ }), [e.editor.view.dom, D]), /* @__PURE__ */ r(
156
+ be,
157
+ {
158
+ as: T ? "span" : "div",
159
+ className: "image-view",
160
+ style: {
161
+ float: _ ? C : void 0,
162
+ margin: _ ? C === "left" ? "1em 1em 1em 0" : "1em 0 1em 1em" : void 0,
163
+ display: T ? "inline" : "block",
164
+ textAlign: _ ? void 0 : C,
165
+ width: ((L = S.style) == null ? void 0 : L.width) ?? "auto",
166
+ ..._ ? {} : z
167
+ },
168
+ children: /* @__PURE__ */ x(
169
+ "div",
170
+ {
171
+ "data-drag-handle": !0,
172
+ draggable: "true",
173
+ style: z,
174
+ className: `image-view__body ${e != null && e.selected ? "image-view__body--focused" : ""} ${g ? "image-view__body--resizing" : ""}`,
175
+ children: [
176
+ /* @__PURE__ */ r(
177
+ "img",
178
+ {
179
+ alt: S.alt,
180
+ className: "image-view__body__image block",
181
+ height: "auto",
182
+ onClick: E,
183
+ onLoad: R,
184
+ src: S.src,
185
+ style: S.style
186
+ }
187
+ ),
188
+ (e == null ? void 0 : e.editor.view.editable) && ((e == null ? void 0 : e.selected) || g) && /* @__PURE__ */ r("div", { className: "image-resizer", children: u == null ? void 0 : u.map((n) => /* @__PURE__ */ r(
189
+ "span",
190
+ {
191
+ className: `image-resizer__handler image-resizer__handler--${n}`,
192
+ onMouseDown: (y) => k(y, n)
193
+ },
194
+ `image-dir-${n}`
195
+ )) })
196
+ ]
197
+ }
198
+ )
199
+ }
200
+ );
201
+ }
202
+ function Fe(e, t) {
203
+ const a = e.type, s = e.name.toLowerCase(), f = s.split(".").pop();
204
+ if (!f) return !1;
205
+ const g = a || {
206
+ heif: "image/heif",
207
+ heic: "image/heic",
208
+ dng: "image/x-adobe-dng",
209
+ cr2: "image/x-canon-cr2",
210
+ nef: "image/x-nikon-nef",
211
+ arw: "image/x-sony-arw",
212
+ raf: "image/x-fuji-raf",
213
+ orf: "image/x-olympus-orf"
214
+ }[f];
215
+ return t.some((v) => {
216
+ if (v.startsWith("."))
217
+ return s.endsWith(v);
218
+ if (v.endsWith("/*")) {
219
+ const h = v.split("/")[0];
220
+ return g == null ? void 0 : g.startsWith(h + "/");
221
+ }
222
+ return g === v;
223
+ });
224
+ }
225
+ function fe(e, t) {
226
+ const { acceptMimes: a, maxSize: s, t: f, toast: u } = t, g = [];
227
+ return (Array.isArray(e) ? e : Object.values(e)).forEach((h) => {
228
+ if (!Fe(h, a)) {
229
+ t.onError ? t.onError({
230
+ type: "type",
231
+ message: f("editor.upload.fileTypeNotSupported", { fileName: h.name }),
232
+ file: h
233
+ }) : u({
234
+ variant: "default",
235
+ title: f("editor.upload.fileTypeNotSupported", { fileName: h.name })
236
+ });
237
+ return;
238
+ }
239
+ if (h.size > s) {
240
+ const b = (s / 1024 / 1024).toFixed(2);
241
+ t.onError ? t.onError({
242
+ type: "size",
243
+ message: f("editor.upload.fileSizeTooBig", { fileName: h.name, size: b }),
244
+ file: h
245
+ }) : u({
246
+ variant: "default",
247
+ title: f("editor.upload.fileSizeTooBig", { fileName: h.name, size: b })
248
+ });
249
+ return;
250
+ }
251
+ g.push(h);
252
+ }), g;
253
+ }
254
+ function He({ editor: e, imageInline: t, onClose: a, disabled: s, alt: f }) {
255
+ var n, y;
256
+ const { t: u } = le(), { toast: g } = he(), [v, h] = M(!1), [b, C] = M(!1), T = j.useRef(null), [_, S] = j.useState(), [z, R] = j.useState(""), E = ne(null), [N, k] = M({
257
+ src: "",
258
+ file: null
259
+ }), A = ue(V.name), p = P(() => (A == null ? void 0 : A.options) ?? {}, [A]);
260
+ function c(i) {
261
+ if (T.current && i.width && i.height) {
262
+ const l = U(T.current, i);
263
+ R(l);
264
+ }
265
+ }
266
+ function U(i, l) {
267
+ const m = document.createElement("canvas"), o = i.naturalWidth / i.width, w = i.naturalHeight / i.height;
268
+ m.width = l.width * o, m.height = l.height * w;
269
+ const I = m.getContext("2d");
270
+ return I && (I.imageSmoothingEnabled = !1, I.drawImage(
271
+ i,
272
+ l.x * o,
273
+ l.y * w,
274
+ l.width * o,
275
+ l.height * w,
276
+ 0,
277
+ 0,
278
+ l.width * o,
279
+ l.height * w
280
+ )), m.toDataURL("image/png", 1);
281
+ }
282
+ const D = j.useCallback(async () => {
283
+ var i;
284
+ if (!b) {
285
+ C(!0);
286
+ try {
287
+ const l = Le(z, ((i = N == null ? void 0 : N.file) == null ? void 0 : i.name) || "image.png");
288
+ let m = "";
289
+ p.upload ? m = await p.upload(l) : m = URL.createObjectURL(l), e.chain().focus().setImageInline({ src: m, inline: t, alt: f }).run(), h(!1), k({
290
+ src: "",
291
+ file: null
292
+ }), L(), a();
293
+ } catch (l) {
294
+ console.log("Error cropping image", l);
295
+ } finally {
296
+ C(!1);
297
+ }
298
+ }
299
+ }, [z, e, t, b, a, (n = N == null ? void 0 : N.file) == null ? void 0 : n.name, p]);
300
+ function O(i) {
301
+ var l;
302
+ i.preventDefault(), (l = E.current) == null || l.click();
303
+ }
304
+ const d = async (i) => {
305
+ var I;
306
+ const l = (I = i == null ? void 0 : i.target) == null ? void 0 : I.files;
307
+ if (!e || e.isDestroyed || l.length === 0) {
308
+ i.target.value = "";
309
+ return;
310
+ }
311
+ const m = fe(l, {
312
+ acceptMimes: p == null ? void 0 : p.acceptMimes,
313
+ maxSize: p == null ? void 0 : p.maxSize,
314
+ t: u,
315
+ toast: g,
316
+ onError: p.onError
317
+ });
318
+ if (m.length <= 0) {
319
+ i.target.value = "";
320
+ return;
321
+ }
322
+ const o = m[0], w = await Se(o);
323
+ h(!0), k({
324
+ src: w.src,
325
+ file: o
326
+ });
327
+ }, L = () => {
328
+ E.current && (E.current.value = "");
329
+ };
330
+ return /* @__PURE__ */ x(H, { children: [
331
+ /* @__PURE__ */ r(
332
+ B,
333
+ {
334
+ className: "richtext-mt-1 richtext-w-full",
335
+ disabled: s,
336
+ onClick: O,
337
+ size: "sm",
338
+ children: u("editor.image.dialog.tab.uploadCrop")
339
+ }
340
+ ),
341
+ /* @__PURE__ */ x(
342
+ oe,
343
+ {
344
+ open: v,
345
+ onOpenChange: (i) => {
346
+ h(i), i || (k({ src: "", file: null }), L());
347
+ },
348
+ children: [
349
+ /* @__PURE__ */ r(se, {}),
350
+ /* @__PURE__ */ x(ce, { children: [
351
+ /* @__PURE__ */ r(de, { children: u("editor.image.dialog.tab.uploadCrop") }),
352
+ /* @__PURE__ */ r("div", { children: N.src && /* @__PURE__ */ r(
353
+ Me,
354
+ {
355
+ className: "richtext-w-full",
356
+ crop: _,
357
+ onChange: (i) => S(i),
358
+ onComplete: (i) => c(i),
359
+ children: /* @__PURE__ */ r(
360
+ "img",
361
+ {
362
+ alt: "Crop me",
363
+ ref: T,
364
+ src: N.src
365
+ }
366
+ )
367
+ }
368
+ ) }),
369
+ /* @__PURE__ */ x(Ee, { children: [
370
+ /* @__PURE__ */ x(
371
+ B,
372
+ {
373
+ disabled: b,
374
+ onClick: () => {
375
+ h(!1), k({
376
+ src: "",
377
+ file: null
378
+ }), L();
379
+ },
380
+ children: [
381
+ u("editor.imageUpload.cancel"),
382
+ /* @__PURE__ */ r(
383
+ $,
384
+ {
385
+ className: "richtext-ml-1",
386
+ name: "Trash2"
387
+ }
388
+ )
389
+ ]
390
+ }
391
+ ),
392
+ /* @__PURE__ */ r(
393
+ B,
394
+ {
395
+ className: "richtext-w-fit",
396
+ disabled: b || !_,
397
+ onClick: D,
398
+ children: b ? /* @__PURE__ */ x(H, { children: [
399
+ u("editor.imageUpload.uploading"),
400
+ /* @__PURE__ */ r(
401
+ $,
402
+ {
403
+ className: "richtext-ml-1 richtext-animate-spin",
404
+ name: "Loader"
405
+ }
406
+ )
407
+ ] }) : /* @__PURE__ */ x(H, { children: [
408
+ u("editor.imageUpload.crop"),
409
+ /* @__PURE__ */ r(
410
+ $,
411
+ {
412
+ className: "richtext-ml-1",
413
+ name: "Crop"
414
+ }
415
+ )
416
+ ] })
417
+ }
418
+ )
419
+ ] })
420
+ ] })
421
+ ]
422
+ }
423
+ ),
424
+ /* @__PURE__ */ r(
425
+ "input",
426
+ {
427
+ accept: ((y = p == null ? void 0 : p.acceptMimes) == null ? void 0 : y.join(",")) || "image/*",
428
+ multiple: !1,
429
+ onChange: d,
430
+ ref: E,
431
+ style: { display: "none" },
432
+ type: "file"
433
+ }
434
+ )
435
+ ] });
436
+ }
437
+ function ct() {
438
+ const { t: e } = le(), { toast: t } = he(), a = Ne(), s = _e(V.name), {
439
+ icon: f,
440
+ tooltip: u
441
+ } = (s == null ? void 0 : s.componentProps) ?? {}, { editorDisabled: g } = ke(), [v, h] = M(!1), [b, C] = M(!1), T = ue(V.name), _ = (d) => {
442
+ h(d.detail);
443
+ }, [S, z] = M(""), [R, E] = M(""), N = ne(null), k = (T == null ? void 0 : T.options.defaultInline) || !1, [A, p] = M(k), c = P(() => T == null ? void 0 : T.options, [T]);
444
+ W(() => {
445
+ const d = ve(Te.UPLOAD_IMAGE(a.id), _);
446
+ return () => {
447
+ d();
448
+ };
449
+ }, []);
450
+ async function U(d) {
451
+ var y;
452
+ const L = (y = d == null ? void 0 : d.target) == null ? void 0 : y.files;
453
+ if (!a || a.isDestroyed || L.length === 0 || b) {
454
+ d.target.value = "";
455
+ return;
456
+ }
457
+ const n = fe(L, {
458
+ acceptMimes: c == null ? void 0 : c.acceptMimes,
459
+ maxSize: c == null ? void 0 : c.maxSize,
460
+ t: e,
461
+ toast: t,
462
+ onError: c.onError
463
+ });
464
+ if (n.length <= 0) {
465
+ d.target.value = "";
466
+ return;
467
+ }
468
+ C(!0);
469
+ try {
470
+ if (c != null && c.multiple) {
471
+ const i = n.map(async (m) => {
472
+ let o = "";
473
+ return c.upload ? o = await c.upload(m) : o = URL.createObjectURL(m), o;
474
+ });
475
+ (await Promise.all(i)).forEach((m) => {
476
+ a.chain().focus().setImageInline({ src: m, inline: A, alt: R }).run();
477
+ });
478
+ } else {
479
+ const i = n[0];
480
+ let l = "";
481
+ c.upload ? l = await c.upload(i) : l = URL.createObjectURL(i), a.chain().focus().setImageInline({ src: l, inline: A, alt: R }).run();
482
+ }
483
+ h(!1), E(""), p(k);
484
+ } catch (i) {
485
+ console.error("Error uploading image", i), c.onError ? c.onError({
486
+ type: "upload",
487
+ message: e("editor.upload.error")
488
+ }) : t({
489
+ variant: "destructive",
490
+ title: e("editor.upload.error")
491
+ });
492
+ } finally {
493
+ C(!1), d.target.value = "";
494
+ }
495
+ }
496
+ function D(d) {
497
+ d.preventDefault(), d.stopPropagation(), a.chain().focus().setImageInline({ src: S, inline: A, alt: R }).run(), h(!1), p(k), z(""), E("");
498
+ }
499
+ function O(d) {
500
+ var L;
501
+ d.preventDefault(), (L = N.current) == null || L.click();
502
+ }
503
+ return s ? /* @__PURE__ */ x(
504
+ oe,
505
+ {
506
+ onOpenChange: h,
507
+ open: v,
508
+ children: [
509
+ /* @__PURE__ */ r(
510
+ se,
511
+ {
512
+ asChild: !0,
513
+ children: /* @__PURE__ */ r(
514
+ Ce,
515
+ {
516
+ disabled: g,
517
+ icon: f,
518
+ tooltip: u,
519
+ action: () => {
520
+ g || h(!0);
521
+ }
522
+ }
523
+ )
524
+ }
525
+ ),
526
+ /* @__PURE__ */ x(ce, { children: [
527
+ /* @__PURE__ */ r(de, { children: e("editor.image.dialog.title") }),
528
+ /* @__PURE__ */ x(
529
+ ze,
530
+ {
531
+ activationMode: "manual",
532
+ defaultValue: c.resourceImage === "both" || c.resourceImage === "upload" ? "upload" : "link",
533
+ children: [
534
+ c.resourceImage === "both" && /* @__PURE__ */ x(Ue, { className: "richtext-grid richtext-w-full richtext-grid-cols-2", children: [
535
+ /* @__PURE__ */ r(te, { value: "upload", children: e("editor.image.dialog.tab.upload") }),
536
+ /* @__PURE__ */ r(te, { value: "link", children: e("editor.image.dialog.tab.url") })
537
+ ] }),
538
+ /* @__PURE__ */ x("div", { className: "richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-[4px]", children: [
539
+ /* @__PURE__ */ r(
540
+ me,
541
+ {
542
+ checked: A,
543
+ onCheckedChange: (d) => {
544
+ p(d);
545
+ }
546
+ }
547
+ ),
548
+ /* @__PURE__ */ r(ae, { children: e("editor.link.dialog.inline") })
549
+ ] }),
550
+ c.enableAlt && /* @__PURE__ */ x("div", { className: "richtext-my-[10px] ", children: [
551
+ /* @__PURE__ */ r(ae, { className: "mb-[6px]", children: e("editor.imageUpload.alt") }),
552
+ /* @__PURE__ */ r(
553
+ re,
554
+ {
555
+ onChange: (d) => E(d.target.value),
556
+ required: !0,
557
+ type: "text",
558
+ value: R
559
+ }
560
+ )
561
+ ] }),
562
+ /* @__PURE__ */ x(ie, { value: "upload", children: [
563
+ /* @__PURE__ */ x("div", { className: "richtext-flex richtext-items-center richtext-gap-[10px]", children: [
564
+ /* @__PURE__ */ r(
565
+ B,
566
+ {
567
+ className: "richtext-mt-1 richtext-w-full",
568
+ disabled: b,
569
+ onClick: O,
570
+ size: "sm",
571
+ children: b ? /* @__PURE__ */ x(H, { children: [
572
+ e("editor.imageUpload.uploading"),
573
+ /* @__PURE__ */ r(
574
+ $,
575
+ {
576
+ className: "richtext-ml-1 richtext-animate-spin",
577
+ name: "Loader"
578
+ }
579
+ )
580
+ ] }) : e("editor.image.dialog.tab.upload")
581
+ }
582
+ ),
583
+ /* @__PURE__ */ r(
584
+ He,
585
+ {
586
+ alt: R,
587
+ disabled: b,
588
+ editor: a,
589
+ imageInline: A,
590
+ onClose: () => {
591
+ Re.setOpen(a.id, !1), E("");
592
+ }
593
+ }
594
+ )
595
+ ] }),
596
+ /* @__PURE__ */ r(
597
+ "input",
598
+ {
599
+ accept: c.acceptMimes.join(",") || "image/*",
600
+ multiple: c.multiple,
601
+ onChange: U,
602
+ ref: N,
603
+ style: { display: "none" },
604
+ type: "file"
605
+ }
606
+ )
607
+ ] }),
608
+ /* @__PURE__ */ r(ie, { value: "link", children: /* @__PURE__ */ r("form", { onSubmit: D, children: /* @__PURE__ */ x("div", { className: "richtext-flex richtext-items-center richtext-gap-2", children: [
609
+ /* @__PURE__ */ r(
610
+ re,
611
+ {
612
+ autoFocus: !0,
613
+ onChange: (d) => z(d.target.value),
614
+ placeholder: e("editor.image.dialog.placeholder"),
615
+ required: !0,
616
+ type: "url",
617
+ value: S
618
+ }
619
+ ),
620
+ /* @__PURE__ */ r(B, { type: "submit", children: e("editor.image.dialog.button.apply") })
621
+ ] }) }) })
622
+ ]
623
+ }
624
+ )
625
+ ] })
626
+ ]
627
+ }
628
+ ) : /* @__PURE__ */ r(H, {});
629
+ }
630
+ const Pe = {
631
+ acceptMimes: ["image/jpeg", "image/gif", "image/png", "image/jpg"],
632
+ maxSize: 1024 * 1024 * 5,
633
+ // 5MB
634
+ multiple: !0,
635
+ resourceImage: "both",
636
+ defaultInline: !1,
637
+ enableAlt: !0
638
+ }, V = /* @__PURE__ */ xe.extend({
639
+ group: "inline",
640
+ inline: !0,
641
+ defining: !0,
642
+ draggable: !0,
643
+ selectable: !0,
644
+ addOptions() {
645
+ var e;
646
+ return {
647
+ ...Pe,
648
+ ...(e = this.parent) == null ? void 0 : e.call(this),
649
+ upload: () => Promise.reject("Image Upload Function"),
650
+ button: ({
651
+ editor: t,
652
+ extension: a,
653
+ t: s
654
+ }) => {
655
+ var f, u;
656
+ return {
657
+ componentProps: {
658
+ action: () => !0,
659
+ upload: a.options.upload,
660
+ /* If setImage is not available(when Image Component is not imported), the button is disabled */
661
+ disabled: !((u = (f = t.can()).setImage) != null && u.call(f, {})),
662
+ icon: "ImageUp",
663
+ tooltip: s("editor.image.tooltip")
664
+ }
665
+ };
666
+ }
667
+ };
668
+ },
669
+ addAttributes() {
670
+ var e;
671
+ return {
672
+ ...(e = this.parent) == null ? void 0 : e.call(this),
673
+ flipX: {
674
+ default: !1
675
+ },
676
+ flipY: {
677
+ default: !1
678
+ },
679
+ width: {
680
+ default: null,
681
+ parseHTML: (t) => {
682
+ const a = t.style.width || t.getAttribute("width") || null;
683
+ return a ? Number.parseInt(a, 10) : null;
684
+ },
685
+ renderHTML: (t) => ({
686
+ width: t.width
687
+ })
688
+ },
689
+ align: {
690
+ default: "center",
691
+ parseHTML: (t) => t.getAttribute("align"),
692
+ renderHTML: (t) => ({
693
+ align: t.align
694
+ })
695
+ },
696
+ inline: {
697
+ default: !1,
698
+ parseHTML: (t) => !!t.getAttribute("inline"),
699
+ renderHTML: (t) => ({
700
+ inline: t.inline
701
+ })
702
+ },
703
+ alt: {
704
+ default: "",
705
+ parseHTML: (t) => t.getAttribute("alt"),
706
+ renderHTML: (t) => ({
707
+ alt: t.alt
708
+ })
709
+ }
710
+ };
711
+ },
712
+ addNodeView() {
713
+ return ye(Oe);
714
+ },
715
+ addCommands() {
716
+ var e;
717
+ return {
718
+ ...(e = this.parent) == null ? void 0 : e.call(this),
719
+ setImageInline: (t) => ({ commands: a }) => a.insertContent({
720
+ type: this.name,
721
+ attrs: {
722
+ ...t,
723
+ inline: t.inline ?? this.options.defaultInline
724
+ }
725
+ }),
726
+ updateImage: (t) => ({ commands: a }) => a.updateAttributes(this.name, t),
727
+ setAlignImage: (t) => ({ commands: a }) => a.updateAttributes(this.name, { align: t })
728
+ };
729
+ },
730
+ renderHTML({ HTMLAttributes: e }) {
731
+ const { flipX: t, flipY: a, align: s, inline: f } = e, u = f && (s === "left" || s === "right"), g = t || a ? `transform: rotateX(${t ? "180" : "0"}deg) rotateY(${a ? "180" : "0"}deg);` : "", v = u ? "" : `text-align: ${s};`, C = `${u ? `float: ${s};` : ""}${u ? s === "left" ? "margin: 1em 1em 1em 0;" : "margin: 1em 0 1em 1em;" : ""}${g}`;
732
+ return [
733
+ f ? "span" : "div",
734
+ {
735
+ style: v,
736
+ class: "image"
737
+ },
738
+ [
739
+ "img",
740
+ pe(
741
+ {
742
+ height: "auto",
743
+ style: C
744
+ },
745
+ this.options.HTMLAttributes,
746
+ e
747
+ )
748
+ ]
749
+ ];
750
+ },
751
+ parseHTML() {
752
+ return [
753
+ {
754
+ tag: "span.image img",
755
+ getAttrs: (e) => {
756
+ var u;
757
+ const t = e == null ? void 0 : e.parentElement, a = e == null ? void 0 : e.getAttribute("width"), s = (e == null ? void 0 : e.getAttribute("flipx")) || !1, f = (e == null ? void 0 : e.getAttribute("flipy")) || !1;
758
+ return {
759
+ src: e == null ? void 0 : e.getAttribute("src"),
760
+ alt: e == null ? void 0 : e.getAttribute("alt"),
761
+ caption: e == null ? void 0 : e.getAttribute("caption"),
762
+ width: a ? Number.parseInt(a, 10) : null,
763
+ align: (e == null ? void 0 : e.getAttribute("align")) || ((u = t == null ? void 0 : t.style) == null ? void 0 : u.textAlign) || null,
764
+ inline: (e == null ? void 0 : e.getAttribute("inline")) || !1,
765
+ flipX: s === "true",
766
+ flipY: f === "true"
767
+ };
768
+ }
769
+ },
770
+ {
771
+ tag: "div[class=image]",
772
+ getAttrs: (e) => {
773
+ const t = e.querySelector("img"), a = t == null ? void 0 : t.getAttribute("width"), s = (t == null ? void 0 : t.getAttribute("flipx")) || !1, f = (t == null ? void 0 : t.getAttribute("flipy")) || !1;
774
+ return {
775
+ src: t == null ? void 0 : t.getAttribute("src"),
776
+ alt: t == null ? void 0 : t.getAttribute("alt"),
777
+ caption: t == null ? void 0 : t.getAttribute("caption"),
778
+ width: a ? Number.parseInt(a, 10) : null,
779
+ align: (t == null ? void 0 : t.getAttribute("align")) || e.style.textAlign || null,
780
+ inline: (t == null ? void 0 : t.getAttribute("inline")) || !1,
781
+ flipX: s === "true",
782
+ flipY: f === "true"
783
+ };
784
+ }
785
+ },
786
+ {
787
+ tag: 'img[src]:not([src^="data:"])'
788
+ }
789
+ ];
790
+ }
791
+ // addProseMirrorPlugins() {
792
+ // const validateFile = (file: File): boolean => {
793
+ // // @ts-expect-error
794
+ // if (!this.options.acceptMimes.includes(file.type)) {
795
+ // // toast({ description: t.value('editor.imageUpload.fileTypeNotSupported'), duration: 2000 });
796
+ // return false;
797
+ // }
798
+ // // @ts-expect-error
799
+ // if (file.size > this.options.maxSize) {
800
+ // // toast({
801
+ // // description: `${t.value('editor.imageUpload.fileSizeTooBig')} ${formatFileSize(
802
+ // // this.options.maxSize,
803
+ // // )}.`,
804
+ // // duration: 2000,
805
+ // // });
806
+ // return false;
807
+ // }
808
+ // return true;
809
+ // };
810
+ // const uploadFn = createImageUpload({
811
+ // validateFn: validateFile,
812
+ // onUpload: this.options.upload as any,
813
+ // // postUpload: this.options.postUpload,
814
+ // defaultInline: this.options.defaultInline,
815
+ // });
816
+ // return [
817
+ // UploadImagesPlugin(),
818
+ // new Plugin({
819
+ // key: new PluginKey(`richtextCustomPlugin${this.name}`),
820
+ // props: {
821
+ // handlePaste: (view, event) => {
822
+ // const hasFiles =
823
+ // event.clipboardData &&
824
+ // event.clipboardData.files &&
825
+ // event.clipboardData.files?.length;
826
+ // if (!hasFiles) {
827
+ // return;
828
+ // }
829
+ // const items = [...(event.clipboardData.files || [])];
830
+ // if (items.some(x => x.type === 'text/html')) {
831
+ // return false;
832
+ // }
833
+ // return handleImagePaste(view, event, uploadFn);
834
+ // },
835
+ // handleDrop: (view, event, _, moved) => {
836
+ // if (!(event instanceof DragEvent) || !event.dataTransfer) {
837
+ // return false;
838
+ // }
839
+ // handleImageDrop(view, event, moved, uploadFn);
840
+ // return false;
841
+ // },
842
+ // },
843
+ // }),
844
+ // ];
845
+ // },
846
+ });
4
847
  export {
5
- t as Image,
6
- e as default
848
+ V as Image,
849
+ ct as RichTextImage
7
850
  };