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