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/History.js CHANGED
@@ -1,70 +1,993 @@
1
- import { U as u } from "./index-VvXaaKe3.js";
2
- import { jsxs as d, jsx as e, Fragment as x } from "react/jsx-runtime";
3
- import { T as m, a as f, n as y, i as g, b as v, g as K } from "./RichTextEditor-DGcKEUGr.js";
4
- function T(t) {
5
- var l;
6
- const {
7
- icon: n = void 0,
8
- // title = undefined,
9
- tooltip: i = void 0,
10
- // disabled = false,
11
- customClass: s = "",
12
- // color = undefined,
13
- // loading = false,
14
- // shortcutKeys = undefined,
15
- tooltipOptions: o = {},
16
- action: r = void 0,
17
- isActive: c = void 0,
18
- children: a
19
- } = t, h = g[n];
20
- return /* @__PURE__ */ d(m, { children: [
21
- /* @__PURE__ */ e(f, { asChild: !0, children: /* @__PURE__ */ d(
22
- y,
23
- {
24
- size: "sm",
25
- className: `richtext-w-[32px] richtext-h-[32px] ${s}`,
26
- disabled: c == null ? void 0 : c(),
27
- onClick: r,
28
- children: [
29
- h && /* @__PURE__ */ e(h, { className: "richtext-w-4 richtext-h-4" }),
30
- a && /* @__PURE__ */ e(x, { children: a })
31
- ]
1
+ import { P as N, v as te, F as L, u as G, T as H, s as _, S as A, I as W, J as ne, E as C, K as re, L as ie, O as oe, l as se } from "./index-DnWWK9F_.js";
2
+ import { Plugin as M, PluginKey as b } from "@tiptap/pm/state";
3
+ import { DecorationSet as O, Decoration as R } from "@tiptap/pm/view";
4
+ import { k as le, D as ae, a as de } from "./index-Bnmd0WvY.js";
5
+ import { jsx as T, Fragment as j } from "react/jsx-runtime";
6
+ import { A as U } from "./toggle-Cdp4IT2U.js";
7
+ import "react";
8
+ import "./index-BPfVXs5_.js";
9
+ import { i as ce } from "./icons-Cllpys39.js";
10
+ import { u as X, b as Y } from "./useButtonProps-BsEd4zYM.js";
11
+ function ue(i = {}) {
12
+ return new N({
13
+ view(e) {
14
+ return new pe(e, i);
15
+ }
16
+ });
17
+ }
18
+ class pe {
19
+ constructor(e, t) {
20
+ var n;
21
+ this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (n = t.width) !== null && n !== void 0 ? n : 1, this.color = t.color === !1 ? void 0 : t.color || "black", this.class = t.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((r) => {
22
+ let o = (s) => {
23
+ this[r](s);
24
+ };
25
+ return e.dom.addEventListener(r, o), { name: r, handler: o };
26
+ });
27
+ }
28
+ destroy() {
29
+ this.handlers.forEach(({ name: e, handler: t }) => this.editorView.dom.removeEventListener(e, t));
30
+ }
31
+ update(e, t) {
32
+ this.cursorPos != null && t.doc != e.state.doc && (this.cursorPos > e.state.doc.content.size ? this.setCursor(null) : this.updateOverlay());
33
+ }
34
+ setCursor(e) {
35
+ e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
36
+ }
37
+ updateOverlay() {
38
+ let e = this.editorView.state.doc.resolve(this.cursorPos), t = !e.parent.inlineContent, n, r = this.editorView.dom, o = r.getBoundingClientRect(), s = o.width / r.offsetWidth, l = o.height / r.offsetHeight;
39
+ if (t) {
40
+ let c = e.nodeBefore, p = e.nodeAfter;
41
+ if (c || p) {
42
+ let h = this.editorView.nodeDOM(this.cursorPos - (c ? c.nodeSize : 0));
43
+ if (h) {
44
+ let g = h.getBoundingClientRect(), P = c ? g.bottom : g.top;
45
+ c && p && (P = (P + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
46
+ let I = this.width / 2 * l;
47
+ n = { left: g.left, right: g.right, top: P - I, bottom: P + I };
48
+ }
49
+ }
50
+ }
51
+ if (!n) {
52
+ let c = this.editorView.coordsAtPos(this.cursorPos), p = this.width / 2 * s;
53
+ n = { left: c.left - p, right: c.left + p, top: c.top, bottom: c.bottom };
54
+ }
55
+ let a = this.editorView.dom.offsetParent;
56
+ this.element || (this.element = a.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", t), this.element.classList.toggle("prosemirror-dropcursor-inline", !t);
57
+ let d, u;
58
+ if (!a || a == document.body && getComputedStyle(a).position == "static")
59
+ d = -pageXOffset, u = -pageYOffset;
60
+ else {
61
+ let c = a.getBoundingClientRect(), p = c.width / a.offsetWidth, h = c.height / a.offsetHeight;
62
+ d = c.left - a.scrollLeft * p, u = c.top - a.scrollTop * h;
63
+ }
64
+ this.element.style.left = (n.left - d) / s + "px", this.element.style.top = (n.top - u) / l + "px", this.element.style.width = (n.right - n.left) / s + "px", this.element.style.height = (n.bottom - n.top) / l + "px";
65
+ }
66
+ scheduleRemoval(e) {
67
+ clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
68
+ }
69
+ dragover(e) {
70
+ if (!this.editorView.editable)
71
+ return;
72
+ let t = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }), n = t && t.inside >= 0 && this.editorView.state.doc.nodeAt(t.inside), r = n && n.type.spec.disableDropCursor, o = typeof r == "function" ? r(this.editorView, t, e) : r;
73
+ if (t && !o) {
74
+ let s = t.pos;
75
+ if (this.editorView.dragging && this.editorView.dragging.slice) {
76
+ let l = te(this.editorView.state.doc, s, this.editorView.dragging.slice);
77
+ l != null && (s = l);
78
+ }
79
+ this.setCursor(s), this.scheduleRemoval(5e3);
80
+ }
81
+ }
82
+ dragend() {
83
+ this.scheduleRemoval(20);
84
+ }
85
+ drop() {
86
+ this.scheduleRemoval(20);
87
+ }
88
+ dragleave(e) {
89
+ this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null);
90
+ }
91
+ }
92
+ class f extends A {
93
+ /**
94
+ Create a gap cursor.
95
+ */
96
+ constructor(e) {
97
+ super(e, e);
98
+ }
99
+ map(e, t) {
100
+ let n = e.resolve(t.map(this.head));
101
+ return f.valid(n) ? new f(n) : A.near(n);
102
+ }
103
+ content() {
104
+ return G.empty;
105
+ }
106
+ eq(e) {
107
+ return e instanceof f && e.head == this.head;
108
+ }
109
+ toJSON() {
110
+ return { type: "gapcursor", pos: this.head };
111
+ }
112
+ /**
113
+ @internal
114
+ */
115
+ static fromJSON(e, t) {
116
+ if (typeof t.pos != "number")
117
+ throw new RangeError("Invalid input for GapCursor.fromJSON");
118
+ return new f(e.resolve(t.pos));
119
+ }
120
+ /**
121
+ @internal
122
+ */
123
+ getBookmark() {
124
+ return new F(this.anchor);
125
+ }
126
+ /**
127
+ @internal
128
+ */
129
+ static valid(e) {
130
+ let t = e.parent;
131
+ if (t.isTextblock || !fe(e) || !he(e))
132
+ return !1;
133
+ let n = t.type.spec.allowGapCursor;
134
+ if (n != null)
135
+ return n;
136
+ let r = t.contentMatchAt(e.index()).defaultType;
137
+ return r && r.isTextblock;
138
+ }
139
+ /**
140
+ @internal
141
+ */
142
+ static findGapCursorFrom(e, t, n = !1) {
143
+ e: for (; ; ) {
144
+ if (!n && f.valid(e))
145
+ return e;
146
+ let r = e.pos, o = null;
147
+ for (let s = e.depth; ; s--) {
148
+ let l = e.node(s);
149
+ if (t > 0 ? e.indexAfter(s) < l.childCount : e.index(s) > 0) {
150
+ o = l.child(t > 0 ? e.indexAfter(s) : e.index(s) - 1);
151
+ break;
152
+ } else if (s == 0)
153
+ return null;
154
+ r += t;
155
+ let a = e.doc.resolve(r);
156
+ if (f.valid(a))
157
+ return a;
158
+ }
159
+ for (; ; ) {
160
+ let s = t > 0 ? o.firstChild : o.lastChild;
161
+ if (!s) {
162
+ if (o.isAtom && !o.isText && !_.isSelectable(o)) {
163
+ e = e.doc.resolve(r + o.nodeSize * t), n = !1;
164
+ continue e;
165
+ }
166
+ break;
167
+ }
168
+ o = s, r += t;
169
+ let l = e.doc.resolve(r);
170
+ if (f.valid(l))
171
+ return l;
172
+ }
173
+ return null;
174
+ }
175
+ }
176
+ }
177
+ f.prototype.visible = !1;
178
+ f.findFrom = f.findGapCursorFrom;
179
+ A.jsonID("gapcursor", f);
180
+ class F {
181
+ constructor(e) {
182
+ this.pos = e;
183
+ }
184
+ map(e) {
185
+ return new F(e.map(this.pos));
186
+ }
187
+ resolve(e) {
188
+ let t = e.resolve(this.pos);
189
+ return f.valid(t) ? new f(t) : A.near(t);
190
+ }
191
+ }
192
+ function J(i) {
193
+ return i.isAtom || i.spec.isolating || i.spec.createGapCursor;
194
+ }
195
+ function fe(i) {
196
+ for (let e = i.depth; e >= 0; e--) {
197
+ let t = i.index(e), n = i.node(e);
198
+ if (t == 0) {
199
+ if (n.type.spec.isolating)
200
+ return !0;
201
+ continue;
202
+ }
203
+ for (let r = n.child(t - 1); ; r = r.lastChild) {
204
+ if (r.childCount == 0 && !r.inlineContent || J(r.type))
205
+ return !0;
206
+ if (r.inlineContent)
207
+ return !1;
208
+ }
209
+ }
210
+ return !0;
211
+ }
212
+ function he(i) {
213
+ for (let e = i.depth; e >= 0; e--) {
214
+ let t = i.indexAfter(e), n = i.node(e);
215
+ if (t == n.childCount) {
216
+ if (n.type.spec.isolating)
217
+ return !0;
218
+ continue;
219
+ }
220
+ for (let r = n.child(t); ; r = r.firstChild) {
221
+ if (r.childCount == 0 && !r.inlineContent || J(r.type))
222
+ return !0;
223
+ if (r.inlineContent)
224
+ return !1;
225
+ }
226
+ }
227
+ return !0;
228
+ }
229
+ function me() {
230
+ return new N({
231
+ props: {
232
+ decorations: ye,
233
+ createSelectionBetween(i, e, t) {
234
+ return e.pos == t.pos && f.valid(t) ? new f(t) : null;
235
+ },
236
+ handleClick: ve,
237
+ handleKeyDown: ge,
238
+ handleDOMEvents: { beforeinput: we }
239
+ }
240
+ });
241
+ }
242
+ const ge = le({
243
+ ArrowLeft: x("horiz", -1),
244
+ ArrowRight: x("horiz", 1),
245
+ ArrowUp: x("vert", -1),
246
+ ArrowDown: x("vert", 1)
247
+ });
248
+ function x(i, e) {
249
+ const t = i == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
250
+ return function(n, r, o) {
251
+ let s = n.selection, l = e > 0 ? s.$to : s.$from, a = s.empty;
252
+ if (s instanceof H) {
253
+ if (!o.endOfTextblock(t) || l.depth == 0)
254
+ return !1;
255
+ a = !1, l = n.doc.resolve(e > 0 ? l.after() : l.before());
256
+ }
257
+ let d = f.findGapCursorFrom(l, e, a);
258
+ return d ? (r && r(n.tr.setSelection(new f(d))), !0) : !1;
259
+ };
260
+ }
261
+ function ve(i, e, t) {
262
+ if (!i || !i.editable)
263
+ return !1;
264
+ let n = i.state.doc.resolve(e);
265
+ if (!f.valid(n))
266
+ return !1;
267
+ let r = i.posAtCoords({ left: t.clientX, top: t.clientY });
268
+ return r && r.inside > -1 && _.isSelectable(i.state.doc.nodeAt(r.inside)) ? !1 : (i.dispatch(i.state.tr.setSelection(new f(n))), !0);
269
+ }
270
+ function we(i, e) {
271
+ if (e.inputType != "insertCompositionText" || !(i.state.selection instanceof f))
272
+ return !1;
273
+ let { $from: t } = i.state.selection, n = t.parent.contentMatchAt(t.index()).findWrapping(i.state.schema.nodes.text);
274
+ if (!n)
275
+ return !1;
276
+ let r = L.empty;
277
+ for (let s = n.length - 1; s >= 0; s--)
278
+ r = L.from(n[s].createAndFill(null, r));
279
+ let o = i.state.tr.replace(t.pos, t.pos, new G(r, 0, 0));
280
+ return o.setSelection(H.near(o.doc.resolve(t.pos + 1))), i.dispatch(o), !1;
281
+ }
282
+ function ye(i) {
283
+ if (!(i.selection instanceof f))
284
+ return null;
285
+ let e = document.createElement("div");
286
+ return e.className = "ProseMirror-gapcursor", ae.create(i.doc, [de.widget(i.selection.head, e, { key: "gapcursor" })]);
287
+ }
288
+ var D = 200, m = function() {
289
+ };
290
+ m.prototype.append = function(e) {
291
+ return e.length ? (e = m.from(e), !this.length && e || e.length < D && this.leafAppend(e) || this.length < D && e.leafPrepend(this) || this.appendInner(e)) : this;
292
+ };
293
+ m.prototype.prepend = function(e) {
294
+ return e.length ? m.from(e).append(this) : this;
295
+ };
296
+ m.prototype.appendInner = function(e) {
297
+ return new Ce(this, e);
298
+ };
299
+ m.prototype.slice = function(e, t) {
300
+ return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ? m.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, t));
301
+ };
302
+ m.prototype.get = function(e) {
303
+ if (!(e < 0 || e >= this.length))
304
+ return this.getInner(e);
305
+ };
306
+ m.prototype.forEach = function(e, t, n) {
307
+ t === void 0 && (t = 0), n === void 0 && (n = this.length), t <= n ? this.forEachInner(e, t, n, 0) : this.forEachInvertedInner(e, t, n, 0);
308
+ };
309
+ m.prototype.map = function(e, t, n) {
310
+ t === void 0 && (t = 0), n === void 0 && (n = this.length);
311
+ var r = [];
312
+ return this.forEach(function(o, s) {
313
+ return r.push(e(o, s));
314
+ }, t, n), r;
315
+ };
316
+ m.from = function(e) {
317
+ return e instanceof m ? e : e && e.length ? new Z(e) : m.empty;
318
+ };
319
+ var Z = /* @__PURE__ */ (function(i) {
320
+ function e(n) {
321
+ i.call(this), this.values = n;
322
+ }
323
+ i && (e.__proto__ = i), e.prototype = Object.create(i && i.prototype), e.prototype.constructor = e;
324
+ var t = { length: { configurable: !0 }, depth: { configurable: !0 } };
325
+ return e.prototype.flatten = function() {
326
+ return this.values;
327
+ }, e.prototype.sliceInner = function(r, o) {
328
+ return r == 0 && o == this.length ? this : new e(this.values.slice(r, o));
329
+ }, e.prototype.getInner = function(r) {
330
+ return this.values[r];
331
+ }, e.prototype.forEachInner = function(r, o, s, l) {
332
+ for (var a = o; a < s; a++)
333
+ if (r(this.values[a], l + a) === !1)
334
+ return !1;
335
+ }, e.prototype.forEachInvertedInner = function(r, o, s, l) {
336
+ for (var a = o - 1; a >= s; a--)
337
+ if (r(this.values[a], l + a) === !1)
338
+ return !1;
339
+ }, e.prototype.leafAppend = function(r) {
340
+ if (this.length + r.length <= D)
341
+ return new e(this.values.concat(r.flatten()));
342
+ }, e.prototype.leafPrepend = function(r) {
343
+ if (this.length + r.length <= D)
344
+ return new e(r.flatten().concat(this.values));
345
+ }, t.length.get = function() {
346
+ return this.values.length;
347
+ }, t.depth.get = function() {
348
+ return 0;
349
+ }, Object.defineProperties(e.prototype, t), e;
350
+ })(m);
351
+ m.empty = new Z([]);
352
+ var Ce = /* @__PURE__ */ (function(i) {
353
+ function e(t, n) {
354
+ i.call(this), this.left = t, this.right = n, this.length = t.length + n.length, this.depth = Math.max(t.depth, n.depth) + 1;
355
+ }
356
+ return i && (e.__proto__ = i), e.prototype = Object.create(i && i.prototype), e.prototype.constructor = e, e.prototype.flatten = function() {
357
+ return this.left.flatten().concat(this.right.flatten());
358
+ }, e.prototype.getInner = function(n) {
359
+ return n < this.left.length ? this.left.get(n) : this.right.get(n - this.left.length);
360
+ }, e.prototype.forEachInner = function(n, r, o, s) {
361
+ var l = this.left.length;
362
+ if (r < l && this.left.forEachInner(n, r, Math.min(o, l), s) === !1 || o > l && this.right.forEachInner(n, Math.max(r - l, 0), Math.min(this.length, o) - l, s + l) === !1)
363
+ return !1;
364
+ }, e.prototype.forEachInvertedInner = function(n, r, o, s) {
365
+ var l = this.left.length;
366
+ if (r > l && this.right.forEachInvertedInner(n, r - l, Math.max(o, l) - l, s + l) === !1 || o < l && this.left.forEachInvertedInner(n, Math.min(r, l), o, s) === !1)
367
+ return !1;
368
+ }, e.prototype.sliceInner = function(n, r) {
369
+ if (n == 0 && r == this.length)
370
+ return this;
371
+ var o = this.left.length;
372
+ return r <= o ? this.left.slice(n, r) : n >= o ? this.right.slice(n - o, r - o) : this.left.slice(n, o).append(this.right.slice(0, r - o));
373
+ }, e.prototype.leafAppend = function(n) {
374
+ var r = this.right.leafAppend(n);
375
+ if (r)
376
+ return new e(this.left, r);
377
+ }, e.prototype.leafPrepend = function(n) {
378
+ var r = this.left.leafPrepend(n);
379
+ if (r)
380
+ return new e(r, this.right);
381
+ }, e.prototype.appendInner = function(n) {
382
+ return this.left.depth >= Math.max(this.right.depth, n.depth) + 1 ? new e(this.left, new e(this.right, n)) : new e(this, n);
383
+ }, e;
384
+ })(m);
385
+ const Ee = 500;
386
+ class v {
387
+ constructor(e, t) {
388
+ this.items = e, this.eventCount = t;
389
+ }
390
+ // Pop the latest event off the branch's history and apply it
391
+ // to a document transform.
392
+ popEvent(e, t) {
393
+ if (this.eventCount == 0)
394
+ return null;
395
+ let n = this.items.length;
396
+ for (; ; n--)
397
+ if (this.items.get(n - 1).selection) {
398
+ --n;
399
+ break;
32
400
  }
33
- ) }),
34
- i && /* @__PURE__ */ e(v, { ...o, children: /* @__PURE__ */ d("div", { className: "richtext-flex richtext-flex-col richtext-items-center richtext-text-center richtext-max-w-24", children: [
35
- /* @__PURE__ */ e("div", { children: i }),
36
- !!((l = t == null ? void 0 : t.shortcutKeys) != null && l.length) && /* @__PURE__ */ e("span", { children: K(t == null ? void 0 : t.shortcutKeys) })
37
- ] }) })
38
- ] });
39
- }
40
- const p = ["undo", "redo"], N = /* @__PURE__ */ u.extend({
401
+ let r, o;
402
+ t && (r = this.remapping(n, this.items.length), o = r.maps.length);
403
+ let s = e.tr, l, a, d = [], u = [];
404
+ return this.items.forEach((c, p) => {
405
+ if (!c.step) {
406
+ r || (r = this.remapping(n, p + 1), o = r.maps.length), o--, u.push(c);
407
+ return;
408
+ }
409
+ if (r) {
410
+ u.push(new w(c.map));
411
+ let h = c.step.map(r.slice(o)), g;
412
+ h && s.maybeStep(h).doc && (g = s.mapping.maps[s.mapping.maps.length - 1], d.push(new w(g, void 0, void 0, d.length + u.length))), o--, g && r.appendMap(g, o);
413
+ } else
414
+ s.maybeStep(c.step);
415
+ if (c.selection)
416
+ return l = r ? c.selection.map(r.slice(o)) : c.selection, a = new v(this.items.slice(0, n).append(u.reverse().concat(d)), this.eventCount - 1), !1;
417
+ }, this.items.length, 0), { remaining: a, transform: s, selection: l };
418
+ }
419
+ // Create a new branch with the given transform added.
420
+ addTransform(e, t, n, r) {
421
+ let o = [], s = this.eventCount, l = this.items, a = !r && l.length ? l.get(l.length - 1) : null;
422
+ for (let u = 0; u < e.steps.length; u++) {
423
+ let c = e.steps[u].invert(e.docs[u]), p = new w(e.mapping.maps[u], c, t), h;
424
+ (h = a && a.merge(p)) && (p = h, u ? o.pop() : l = l.slice(0, l.length - 1)), o.push(p), t && (s++, t = void 0), r || (a = p);
425
+ }
426
+ let d = s - n.depth;
427
+ return d > Ie && (l = Pe(l, d), s -= d), new v(l.append(o), s);
428
+ }
429
+ remapping(e, t) {
430
+ let n = new ne();
431
+ return this.items.forEach((r, o) => {
432
+ let s = r.mirrorOffset != null && o - r.mirrorOffset >= e ? n.maps.length - r.mirrorOffset : void 0;
433
+ n.appendMap(r.map, s);
434
+ }, e, t), n;
435
+ }
436
+ addMaps(e) {
437
+ return this.eventCount == 0 ? this : new v(this.items.append(e.map((t) => new w(t))), this.eventCount);
438
+ }
439
+ // When the collab module receives remote changes, the history has
440
+ // to know about those, so that it can adjust the steps that were
441
+ // rebased on top of the remote changes, and include the position
442
+ // maps for the remote changes in its array of items.
443
+ rebased(e, t) {
444
+ if (!this.eventCount)
445
+ return this;
446
+ let n = [], r = Math.max(0, this.items.length - t), o = e.mapping, s = e.steps.length, l = this.eventCount;
447
+ this.items.forEach((p) => {
448
+ p.selection && l--;
449
+ }, r);
450
+ let a = t;
451
+ this.items.forEach((p) => {
452
+ let h = o.getMirror(--a);
453
+ if (h == null)
454
+ return;
455
+ s = Math.min(s, h);
456
+ let g = o.maps[h];
457
+ if (p.step) {
458
+ let P = e.steps[h].invert(e.docs[h]), I = p.selection && p.selection.map(o.slice(a + 1, h));
459
+ I && l++, n.push(new w(g, P, I));
460
+ } else
461
+ n.push(new w(g));
462
+ }, r);
463
+ let d = [];
464
+ for (let p = t; p < s; p++)
465
+ d.push(new w(o.maps[p]));
466
+ let u = this.items.slice(0, r).append(d).append(n), c = new v(u, l);
467
+ return c.emptyItemCount() > Ee && (c = c.compress(this.items.length - n.length)), c;
468
+ }
469
+ emptyItemCount() {
470
+ let e = 0;
471
+ return this.items.forEach((t) => {
472
+ t.step || e++;
473
+ }), e;
474
+ }
475
+ // Compressing a branch means rewriting it to push the air (map-only
476
+ // items) out. During collaboration, these naturally accumulate
477
+ // because each remote change adds one. The `upto` argument is used
478
+ // to ensure that only the items below a given level are compressed,
479
+ // because `rebased` relies on a clean, untouched set of items in
480
+ // order to associate old items with rebased steps.
481
+ compress(e = this.items.length) {
482
+ let t = this.remapping(0, e), n = t.maps.length, r = [], o = 0;
483
+ return this.items.forEach((s, l) => {
484
+ if (l >= e)
485
+ r.push(s), s.selection && o++;
486
+ else if (s.step) {
487
+ let a = s.step.map(t.slice(n)), d = a && a.getMap();
488
+ if (n--, d && t.appendMap(d, n), a) {
489
+ let u = s.selection && s.selection.map(t.slice(n));
490
+ u && o++;
491
+ let c = new w(d.invert(), a, u), p, h = r.length - 1;
492
+ (p = r.length && r[h].merge(c)) ? r[h] = p : r.push(c);
493
+ }
494
+ } else s.map && n--;
495
+ }, this.items.length, 0), new v(m.from(r.reverse()), o);
496
+ }
497
+ }
498
+ v.empty = new v(m.empty, 0);
499
+ function Pe(i, e) {
500
+ let t;
501
+ return i.forEach((n, r) => {
502
+ if (n.selection && e-- == 0)
503
+ return t = r, !1;
504
+ }), i.slice(t);
505
+ }
506
+ class w {
507
+ constructor(e, t, n, r) {
508
+ this.map = e, this.step = t, this.selection = n, this.mirrorOffset = r;
509
+ }
510
+ merge(e) {
511
+ if (this.step && e.step && !e.selection) {
512
+ let t = e.step.merge(this.step);
513
+ if (t)
514
+ return new w(t.getMap().invert(), t, this.selection);
515
+ }
516
+ }
517
+ }
518
+ class y {
519
+ constructor(e, t, n, r, o) {
520
+ this.done = e, this.undone = t, this.prevRanges = n, this.prevTime = r, this.prevComposition = o;
521
+ }
522
+ }
523
+ const Ie = 20;
524
+ function Me(i, e, t, n) {
525
+ let r = t.getMeta(E), o;
526
+ if (r)
527
+ return r.historyState;
528
+ t.getMeta(Se) && (i = new y(i.done, i.undone, null, 0, -1));
529
+ let s = t.getMeta("appendedTransaction");
530
+ if (t.steps.length == 0)
531
+ return i;
532
+ if (s && s.getMeta(E))
533
+ return s.getMeta(E).redo ? new y(i.done.addTransform(t, void 0, n, S(e)), i.undone, V(t.mapping.maps), i.prevTime, i.prevComposition) : new y(i.done, i.undone.addTransform(t, void 0, n, S(e)), null, i.prevTime, i.prevComposition);
534
+ if (t.getMeta("addToHistory") !== !1 && !(s && s.getMeta("addToHistory") === !1)) {
535
+ let l = t.getMeta("composition"), a = i.prevTime == 0 || !s && i.prevComposition != l && (i.prevTime < (t.time || 0) - n.newGroupDelay || !be(t, i.prevRanges)), d = s ? k(i.prevRanges, t.mapping) : V(t.mapping.maps);
536
+ return new y(i.done.addTransform(t, a ? e.selection.getBookmark() : void 0, n, S(e)), v.empty, d, t.time, l ?? i.prevComposition);
537
+ } else return (o = t.getMeta("rebased")) ? new y(i.done.rebased(t, o), i.undone.rebased(t, o), k(i.prevRanges, t.mapping), i.prevTime, i.prevComposition) : new y(i.done.addMaps(t.mapping.maps), i.undone.addMaps(t.mapping.maps), k(i.prevRanges, t.mapping), i.prevTime, i.prevComposition);
538
+ }
539
+ function be(i, e) {
540
+ if (!e)
541
+ return !1;
542
+ if (!i.docChanged)
543
+ return !0;
544
+ let t = !1;
545
+ return i.mapping.maps[0].forEach((n, r) => {
546
+ for (let o = 0; o < e.length; o += 2)
547
+ n <= e[o + 1] && r >= e[o] && (t = !0);
548
+ }), t;
549
+ }
550
+ function V(i) {
551
+ let e = [];
552
+ for (let t = i.length - 1; t >= 0 && e.length == 0; t--)
553
+ i[t].forEach((n, r, o, s) => e.push(o, s));
554
+ return e;
555
+ }
556
+ function k(i, e) {
557
+ if (!i)
558
+ return null;
559
+ let t = [];
560
+ for (let n = 0; n < i.length; n += 2) {
561
+ let r = e.map(i[n], 1), o = e.map(i[n + 1], -1);
562
+ r <= o && t.push(r, o);
563
+ }
564
+ return t;
565
+ }
566
+ function xe(i, e, t) {
567
+ let n = S(e), r = E.get(e).spec.config, o = (t ? i.undone : i.done).popEvent(e, n);
568
+ if (!o)
569
+ return null;
570
+ let s = o.selection.resolve(o.transform.doc), l = (t ? i.done : i.undone).addTransform(o.transform, e.selection.getBookmark(), r, n), a = new y(t ? l : o.remaining, t ? o.remaining : l, null, 0, -1);
571
+ return o.transform.setSelection(s).setMeta(E, { redo: t, historyState: a });
572
+ }
573
+ let z = !1, K = null;
574
+ function S(i) {
575
+ let e = i.plugins;
576
+ if (K != e) {
577
+ z = !1, K = e;
578
+ for (let t = 0; t < e.length; t++)
579
+ if (e[t].spec.historyPreserveItems) {
580
+ z = !0;
581
+ break;
582
+ }
583
+ }
584
+ return z;
585
+ }
586
+ const E = new W("history"), Se = new W("closeHistory");
587
+ function Ae(i = {}) {
588
+ return i = {
589
+ depth: i.depth || 100,
590
+ newGroupDelay: i.newGroupDelay || 500
591
+ }, new N({
592
+ key: E,
593
+ state: {
594
+ init() {
595
+ return new y(v.empty, v.empty, null, 0, -1);
596
+ },
597
+ apply(e, t, n) {
598
+ return Me(t, n, e, i);
599
+ }
600
+ },
601
+ config: i,
602
+ props: {
603
+ handleDOMEvents: {
604
+ beforeinput(e, t) {
605
+ let n = t.inputType, r = n == "historyUndo" ? q : n == "historyRedo" ? $ : null;
606
+ return !r || !e.editable ? !1 : (t.preventDefault(), r(e.state, e.dispatch));
607
+ }
608
+ }
609
+ }
610
+ });
611
+ }
612
+ function Q(i, e) {
613
+ return (t, n) => {
614
+ let r = E.getState(t);
615
+ if (!r || (i ? r.undone : r.done).eventCount == 0)
616
+ return !1;
617
+ if (n) {
618
+ let o = xe(r, t, i);
619
+ o && n(e ? o.scrollIntoView() : o);
620
+ }
621
+ return !0;
622
+ };
623
+ }
624
+ const q = Q(!1, !0), $ = Q(!0, !0);
625
+ C.create({
626
+ name: "characterCount",
627
+ addOptions() {
628
+ return {
629
+ limit: null,
630
+ mode: "textSize",
631
+ textCounter: (i) => i.length,
632
+ wordCounter: (i) => i.split(" ").filter((e) => e !== "").length
633
+ };
634
+ },
635
+ addStorage() {
636
+ return {
637
+ characters: () => 0,
638
+ words: () => 0
639
+ };
640
+ },
641
+ onBeforeCreate() {
642
+ this.storage.characters = (i) => {
643
+ const e = (i == null ? void 0 : i.node) || this.editor.state.doc;
644
+ if (((i == null ? void 0 : i.mode) || this.options.mode) === "textSize") {
645
+ const n = e.textBetween(0, e.content.size, void 0, " ");
646
+ return this.options.textCounter(n);
647
+ }
648
+ return e.nodeSize;
649
+ }, this.storage.words = (i) => {
650
+ const e = (i == null ? void 0 : i.node) || this.editor.state.doc, t = e.textBetween(0, e.content.size, " ", " ");
651
+ return this.options.wordCounter(t);
652
+ };
653
+ },
654
+ addProseMirrorPlugins() {
655
+ let i = !1;
656
+ return [
657
+ new M({
658
+ key: new b("characterCount"),
659
+ appendTransaction: (e, t, n) => {
660
+ if (i)
661
+ return;
662
+ const r = this.options.limit;
663
+ if (r == null || r === 0) {
664
+ i = !0;
665
+ return;
666
+ }
667
+ const o = this.storage.characters({ node: n.doc });
668
+ if (o > r) {
669
+ const s = o - r, l = 0, a = s;
670
+ console.warn(
671
+ `[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`
672
+ );
673
+ const d = n.tr.deleteRange(l, a);
674
+ return i = !0, d;
675
+ }
676
+ i = !0;
677
+ },
678
+ filterTransaction: (e, t) => {
679
+ const n = this.options.limit;
680
+ if (!e.docChanged || n === 0 || n === null || n === void 0)
681
+ return !0;
682
+ const r = this.storage.characters({ node: t.doc }), o = this.storage.characters({ node: e.doc });
683
+ if (o <= n || r > n && o > n && o <= r)
684
+ return !0;
685
+ if (r > n && o > n && o > r || !e.getMeta("paste"))
686
+ return !1;
687
+ const l = e.selection.$head.pos, a = o - n, d = l - a, u = l;
688
+ return e.deleteRange(d, u), !(this.storage.characters({ node: e.doc }) > n);
689
+ }
690
+ })
691
+ ];
692
+ }
693
+ });
694
+ C.create({
695
+ name: "dropCursor",
696
+ addOptions() {
697
+ return {
698
+ color: "currentColor",
699
+ width: 1,
700
+ class: void 0
701
+ };
702
+ },
703
+ addProseMirrorPlugins() {
704
+ return [ue(this.options)];
705
+ }
706
+ });
707
+ C.create({
708
+ name: "focus",
709
+ addOptions() {
710
+ return {
711
+ className: "has-focus",
712
+ mode: "all"
713
+ };
714
+ },
715
+ addProseMirrorPlugins() {
716
+ return [
717
+ new M({
718
+ key: new b("focus"),
719
+ props: {
720
+ decorations: ({ doc: i, selection: e }) => {
721
+ const { isEditable: t, isFocused: n } = this.editor, { anchor: r } = e, o = [];
722
+ if (!t || !n)
723
+ return O.create(i, []);
724
+ let s = 0;
725
+ this.options.mode === "deepest" && i.descendants((a, d) => {
726
+ if (a.isText)
727
+ return;
728
+ if (!(r >= d && r <= d + a.nodeSize - 1))
729
+ return !1;
730
+ s += 1;
731
+ });
732
+ let l = 0;
733
+ return i.descendants((a, d) => {
734
+ if (a.isText || !(r >= d && r <= d + a.nodeSize - 1))
735
+ return !1;
736
+ if (l += 1, this.options.mode === "deepest" && s - l > 0 || this.options.mode === "shallowest" && l > 1)
737
+ return this.options.mode === "deepest";
738
+ o.push(
739
+ R.node(d, d + a.nodeSize, {
740
+ class: this.options.className
741
+ })
742
+ );
743
+ }), O.create(i, o);
744
+ }
745
+ }
746
+ })
747
+ ];
748
+ }
749
+ });
750
+ C.create({
751
+ name: "gapCursor",
752
+ addProseMirrorPlugins() {
753
+ return [me()];
754
+ },
755
+ extendNodeSchema(i) {
756
+ var e;
757
+ const t = {
758
+ name: i.name,
759
+ options: i.options,
760
+ storage: i.storage
761
+ };
762
+ return {
763
+ allowGapCursor: (e = re(ie(i, "allowGapCursor", t))) != null ? e : null
764
+ };
765
+ }
766
+ });
767
+ C.create({
768
+ name: "placeholder",
769
+ addOptions() {
770
+ return {
771
+ emptyEditorClass: "is-editor-empty",
772
+ emptyNodeClass: "is-empty",
773
+ placeholder: "Write something …",
774
+ showOnlyWhenEditable: !0,
775
+ showOnlyCurrent: !0,
776
+ includeChildren: !1
777
+ };
778
+ },
779
+ addProseMirrorPlugins() {
780
+ return [
781
+ new M({
782
+ key: new b("placeholder"),
783
+ props: {
784
+ decorations: ({ doc: i, selection: e }) => {
785
+ const t = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: n } = e, r = [];
786
+ if (!t)
787
+ return null;
788
+ const o = this.editor.isEmpty;
789
+ return i.descendants((s, l) => {
790
+ const a = n >= l && n <= l + s.nodeSize, d = !s.isLeaf && oe(s);
791
+ if ((a || !this.options.showOnlyCurrent) && d) {
792
+ const u = [this.options.emptyNodeClass];
793
+ o && u.push(this.options.emptyEditorClass);
794
+ const c = R.node(l, l + s.nodeSize, {
795
+ class: u.join(" "),
796
+ "data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
797
+ editor: this.editor,
798
+ node: s,
799
+ pos: l,
800
+ hasAnchor: a
801
+ }) : this.options.placeholder
802
+ });
803
+ r.push(c);
804
+ }
805
+ return this.options.includeChildren;
806
+ }), O.create(i, r);
807
+ }
808
+ }
809
+ })
810
+ ];
811
+ }
812
+ });
813
+ C.create({
814
+ name: "selection",
815
+ addOptions() {
816
+ return {
817
+ className: "selection"
818
+ };
819
+ },
820
+ addProseMirrorPlugins() {
821
+ const { editor: i, options: e } = this;
822
+ return [
823
+ new M({
824
+ key: new b("selection"),
825
+ props: {
826
+ decorations(t) {
827
+ return t.selection.empty || i.isFocused || !i.isEditable || se(t.selection) || i.view.dragging ? null : O.create(t.doc, [
828
+ R.inline(t.selection.from, t.selection.to, {
829
+ class: e.className
830
+ })
831
+ ]);
832
+ }
833
+ }
834
+ })
835
+ ];
836
+ }
837
+ });
838
+ function B({ types: i, node: e }) {
839
+ return e && Array.isArray(i) && i.includes(e.type) || (e == null ? void 0 : e.type) === i;
840
+ }
841
+ C.create({
842
+ name: "trailingNode",
843
+ addOptions() {
844
+ return {
845
+ node: void 0,
846
+ notAfter: []
847
+ };
848
+ },
849
+ addProseMirrorPlugins() {
850
+ var i;
851
+ const e = new b(this.name), t = this.options.node || ((i = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : i.name) || "paragraph", n = Object.entries(this.editor.schema.nodes).map(([, r]) => r).filter((r) => (this.options.notAfter || []).concat(t).includes(r.name));
852
+ return [
853
+ new M({
854
+ key: e,
855
+ appendTransaction: (r, o, s) => {
856
+ const { doc: l, tr: a, schema: d } = s, u = e.getState(s), c = l.content.size, p = d.nodes[t];
857
+ if (u)
858
+ return a.insert(c, p.create());
859
+ },
860
+ state: {
861
+ init: (r, o) => {
862
+ const s = o.tr.doc.lastChild;
863
+ return !B({ node: s, types: n });
864
+ },
865
+ apply: (r, o) => {
866
+ if (!r.docChanged || r.getMeta("__uniqueIDTransaction"))
867
+ return o;
868
+ const s = r.doc.lastChild;
869
+ return !B({ node: s, types: n });
870
+ }
871
+ }
872
+ })
873
+ ];
874
+ }
875
+ });
876
+ var Oe = C.create({
877
+ name: "undoRedo",
878
+ addOptions() {
879
+ return {
880
+ depth: 100,
881
+ newGroupDelay: 500
882
+ };
883
+ },
884
+ addCommands() {
885
+ return {
886
+ undo: () => ({ state: i, dispatch: e }) => q(i, e),
887
+ redo: () => ({ state: i, dispatch: e }) => $(i, e)
888
+ };
889
+ },
890
+ addProseMirrorPlugins() {
891
+ return [Ae(this.options)];
892
+ },
893
+ addKeyboardShortcuts() {
894
+ return {
895
+ "Mod-z": () => this.editor.commands.undo(),
896
+ "Shift-Mod-z": () => this.editor.commands.redo(),
897
+ "Mod-y": () => this.editor.commands.redo(),
898
+ // Russian keyboard layouts
899
+ "Mod-я": () => this.editor.commands.undo(),
900
+ "Shift-Mod-я": () => this.editor.commands.redo()
901
+ };
902
+ }
903
+ });
904
+ function Be() {
905
+ var u;
906
+ const i = X(ee.name), {
907
+ icon: e = void 0,
908
+ tooltip: t = void 0,
909
+ shortcutKeys: n = void 0,
910
+ tooltipOptions: r = {},
911
+ action: o = void 0,
912
+ isActive: s = void 0
913
+ } = ((u = i == null ? void 0 : i.componentProps) == null ? void 0 : u.undo) ?? {}, { disabled: l } = Y(s), a = ce[e], d = () => {
914
+ l || o && o();
915
+ };
916
+ return !i || !a ? /* @__PURE__ */ T(j, {}) : /* @__PURE__ */ T(
917
+ U,
918
+ {
919
+ action: d,
920
+ disabled: l,
921
+ icon: e,
922
+ shortcutKeys: n,
923
+ tooltip: t,
924
+ tooltipOptions: r
925
+ }
926
+ );
927
+ }
928
+ function Ge() {
929
+ var d;
930
+ const i = X(ee.name), {
931
+ icon: e = void 0,
932
+ tooltip: t = void 0,
933
+ shortcutKeys: n = void 0,
934
+ tooltipOptions: r = {},
935
+ action: o = void 0,
936
+ isActive: s = void 0
937
+ } = ((d = i == null ? void 0 : i.componentProps) == null ? void 0 : d.redo) ?? {}, { disabled: l } = Y(s), a = () => {
938
+ l || o && o();
939
+ };
940
+ return i ? /* @__PURE__ */ T(
941
+ U,
942
+ {
943
+ action: a,
944
+ disabled: l,
945
+ icon: e,
946
+ shortcutKeys: n,
947
+ tooltip: t,
948
+ tooltipOptions: r
949
+ }
950
+ ) : /* @__PURE__ */ T(j, {});
951
+ }
952
+ const ee = /* @__PURE__ */ Oe.extend({
41
953
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
42
954
  //@ts-expect-error
43
955
  addOptions() {
44
- var t;
956
+ var i;
45
957
  return {
46
- ...(t = this.parent) == null ? void 0 : t.call(this),
958
+ ...(i = this.parent) == null ? void 0 : i.call(this),
47
959
  depth: 100,
48
960
  newGroupDelay: 500,
49
- button: ({ editor: n, t: i, extension: s }) => p.map((o) => {
50
- var r, c;
961
+ button: ({ editor: e, t, extension: n }) => {
962
+ var r, o;
51
963
  return {
52
- component: T,
53
964
  componentProps: {
54
- action: () => {
55
- o === "undo" && n.chain().focus().undo().run(), o === "redo" && n.chain().focus().redo().run();
965
+ undo: {
966
+ action: () => {
967
+ e.chain().focus().undo().run();
968
+ },
969
+ shortcutKeys: ((r = n.options.shortcutKeys) == null ? void 0 : r[0]) ?? ["mod", "Z"],
970
+ isActive: () => e.can().undo(),
971
+ icon: "Undo2",
972
+ tooltip: t("editor.undo.tooltip")
56
973
  },
57
- shortcutKeys: o === "undo" ? ((r = s.options.shortcutKeys) == null ? void 0 : r[0]) ?? ["mod", "Z"] : ((c = s.options.shortcutKeys) == null ? void 0 : c[1]) ?? ["shift", "mod", "Z"],
58
- disabled: o === "undo" ? !n.can().undo() : !n.can().redo(),
59
- isActive: () => o === "undo" ? !n.can().undo() : !n.can().redo(),
60
- icon: o === "undo" ? "Undo2" : "Redo2",
61
- tooltip: i(`editor.${o}.tooltip`)
974
+ redo: {
975
+ action: () => {
976
+ e.chain().focus().redo().run();
977
+ },
978
+ shortcutKeys: ((o = n.options.shortcutKeys) == null ? void 0 : o[1]) ?? ["shift", "mod", "Z"],
979
+ isActive: () => e.can().redo(),
980
+ icon: "Redo2",
981
+ tooltip: t("editor.redo.tooltip")
982
+ }
62
983
  }
63
984
  };
64
- })
985
+ }
65
986
  };
66
987
  }
67
988
  });
68
989
  export {
69
- N as History
990
+ ee as History,
991
+ Ge as RichTextRedo,
992
+ Be as RichTextUndo
70
993
  };