reactjs-tiptap-editor 0.2.29 → 0.3.1

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 (255) hide show
  1. package/lib/ActionMenuButton-BllDdN2-.js +33 -0
  2. package/lib/ActionMenuButton-tLPdHfCT.cjs +1 -0
  3. package/lib/Attachment.cjs +19 -0
  4. package/lib/Attachment.d.cts +344 -0
  5. package/lib/Attachment.d.ts +344 -0
  6. package/lib/Attachment.js +259 -0
  7. package/lib/Blockquote.cjs +1 -0
  8. package/lib/Blockquote.d.cts +343 -0
  9. package/lib/Blockquote.d.ts +343 -0
  10. package/lib/Blockquote.js +65 -0
  11. package/lib/Bold.cjs +1 -0
  12. package/lib/Bold.d.cts +343 -0
  13. package/lib/Bold.d.ts +343 -0
  14. package/lib/Bold.js +90 -0
  15. package/lib/BulletList.cjs +1 -0
  16. package/lib/BulletList.d.cts +343 -0
  17. package/lib/BulletList.d.ts +343 -0
  18. package/lib/BulletList.js +72 -0
  19. package/lib/Clear.cjs +1 -0
  20. package/lib/Clear.d.cts +342 -0
  21. package/lib/Clear.d.ts +342 -0
  22. package/lib/Clear.js +23 -0
  23. package/lib/Code.cjs +1 -0
  24. package/lib/Code.d.cts +343 -0
  25. package/lib/Code.d.ts +343 -0
  26. package/lib/Code.js +70 -0
  27. package/lib/CodeBlock.cjs +44 -0
  28. package/lib/CodeBlock.d.cts +352 -0
  29. package/lib/CodeBlock.d.ts +352 -0
  30. package/lib/CodeBlock.js +4189 -0
  31. package/lib/Color.cjs +1 -0
  32. package/lib/Color.d.cts +350 -0
  33. package/lib/Color.d.ts +350 -0
  34. package/lib/Color.js +141 -0
  35. package/lib/Document.cjs +1 -0
  36. package/lib/Document.d.cts +272 -0
  37. package/lib/Document.d.ts +272 -0
  38. package/lib/Document.js +13 -0
  39. package/lib/Drawer-BBmEHEAp.cjs +1 -0
  40. package/lib/Drawer-hyBIiEP6.js +1367 -0
  41. package/lib/Drawer.cjs +1 -0
  42. package/lib/Drawer.d.cts +344 -0
  43. package/lib/Drawer.d.ts +344 -0
  44. package/lib/Drawer.js +7 -0
  45. package/lib/Emoji.cjs +1 -0
  46. package/lib/Emoji.d.cts +277 -0
  47. package/lib/Emoji.d.ts +277 -0
  48. package/lib/Emoji.js +2168 -0
  49. package/lib/Excalidraw-BQ2PeAoa.js +651 -0
  50. package/lib/Excalidraw-Cd01zFJl.cjs +1 -0
  51. package/lib/Excalidraw.cjs +1 -0
  52. package/lib/Excalidraw.d.cts +278 -0
  53. package/lib/Excalidraw.d.ts +278 -0
  54. package/lib/Excalidraw.js +6 -0
  55. package/lib/ExportPdf.cjs +15 -0
  56. package/lib/ExportPdf.d.cts +270 -0
  57. package/lib/ExportPdf.d.ts +270 -0
  58. package/lib/ExportPdf.js +67 -0
  59. package/lib/ExportWord.cjs +1 -0
  60. package/lib/ExportWord.d.cts +341 -0
  61. package/lib/ExportWord.d.ts +341 -0
  62. package/lib/ExportWord.js +72 -0
  63. package/lib/FontFamily.cjs +1 -0
  64. package/lib/FontFamily.d.cts +354 -0
  65. package/lib/FontFamily.d.ts +354 -0
  66. package/lib/FontFamily.js +136 -0
  67. package/lib/FontSize.cjs +1 -0
  68. package/lib/FontSize.d.cts +359 -0
  69. package/lib/FontSize.d.ts +359 -0
  70. package/lib/FontSize.js +110 -0
  71. package/lib/FormatPainter.cjs +1 -0
  72. package/lib/FormatPainter.d.cts +353 -0
  73. package/lib/FormatPainter.d.ts +353 -0
  74. package/lib/FormatPainter.js +74 -0
  75. package/lib/Heading.cjs +1 -0
  76. package/lib/Heading.d.cts +343 -0
  77. package/lib/Heading.d.ts +343 -0
  78. package/lib/Heading.js +147 -0
  79. package/lib/Highlight.cjs +1 -0
  80. package/lib/Highlight.d.cts +344 -0
  81. package/lib/Highlight.d.ts +344 -0
  82. package/lib/Highlight.js +85 -0
  83. package/lib/History.cjs +1 -0
  84. package/lib/History.d.cts +343 -0
  85. package/lib/History.d.ts +343 -0
  86. package/lib/History.js +431 -0
  87. package/lib/HorizontalRule.cjs +1 -0
  88. package/lib/HorizontalRule.d.cts +343 -0
  89. package/lib/HorizontalRule.d.ts +343 -0
  90. package/lib/HorizontalRule.js +87 -0
  91. package/lib/Iframe.cjs +1 -0
  92. package/lib/Iframe.d.cts +277 -0
  93. package/lib/Iframe.d.ts +277 -0
  94. package/lib/Iframe.js +6 -0
  95. package/lib/Image.cjs +1 -0
  96. package/lib/Image.d.cts +370 -0
  97. package/lib/Image.d.ts +370 -0
  98. package/lib/Image.js +7 -0
  99. package/lib/ImageGif.cjs +1 -0
  100. package/lib/ImageGif.d.cts +292 -0
  101. package/lib/ImageGif.d.ts +292 -0
  102. package/lib/ImageGif.js +7 -0
  103. package/lib/ImportWord.cjs +231 -0
  104. package/lib/ImportWord.d.cts +353 -0
  105. package/lib/ImportWord.d.ts +353 -0
  106. package/lib/ImportWord.js +16620 -0
  107. package/lib/Indent.cjs +1 -0
  108. package/lib/Indent.d.cts +344 -0
  109. package/lib/Indent.d.ts +344 -0
  110. package/lib/Indent.js +78 -0
  111. package/lib/Italic.cjs +1 -0
  112. package/lib/Italic.d.cts +343 -0
  113. package/lib/Italic.d.ts +343 -0
  114. package/lib/Italic.js +91 -0
  115. package/lib/Katex.cjs +1 -0
  116. package/lib/Katex.d.cts +279 -0
  117. package/lib/Katex.d.ts +279 -0
  118. package/lib/Katex.js +197 -0
  119. package/lib/LineHeight.cjs +1 -0
  120. package/lib/LineHeight.d.cts +347 -0
  121. package/lib/LineHeight.d.ts +347 -0
  122. package/lib/LineHeight.js +137 -0
  123. package/lib/Link.cjs +5 -0
  124. package/lib/Link.d.cts +343 -0
  125. package/lib/Link.d.ts +343 -0
  126. package/lib/Link.js +1048 -0
  127. package/lib/ListItem.cjs +1 -0
  128. package/lib/ListItem.d.cts +269 -0
  129. package/lib/ListItem.d.ts +269 -0
  130. package/lib/ListItem.js +33 -0
  131. package/lib/Mention.cjs +1 -0
  132. package/lib/Mention.d.cts +272 -0
  133. package/lib/Mention.d.ts +272 -0
  134. package/lib/Mention.js +233 -0
  135. package/lib/Mermaid.cjs +2 -0
  136. package/lib/Mermaid.d.cts +344 -0
  137. package/lib/Mermaid.d.ts +344 -0
  138. package/lib/Mermaid.js +390 -0
  139. package/lib/MoreMark.cjs +1 -0
  140. package/lib/MoreMark.d.cts +355 -0
  141. package/lib/MoreMark.d.ts +355 -0
  142. package/lib/MoreMark.js +95 -0
  143. package/lib/MultiColumn.cjs +1 -0
  144. package/lib/MultiColumn.d.cts +277 -0
  145. package/lib/MultiColumn.d.ts +277 -0
  146. package/lib/MultiColumn.js +8 -0
  147. package/lib/OrderedList.cjs +1 -0
  148. package/lib/OrderedList.d.cts +343 -0
  149. package/lib/OrderedList.d.ts +343 -0
  150. package/lib/OrderedList.js +90 -0
  151. package/lib/RichTextEditor-CM-Xq9RS.cjs +137 -0
  152. package/lib/RichTextEditor-DvrUVNK2.js +11417 -0
  153. package/lib/SearchAndReplace.cjs +1 -0
  154. package/lib/SearchAndReplace.d.cts +358 -0
  155. package/lib/SearchAndReplace.d.ts +358 -0
  156. package/lib/SearchAndReplace.js +339 -0
  157. package/lib/Selection.cjs +1 -0
  158. package/lib/Selection.d.cts +272 -0
  159. package/lib/Selection.d.ts +272 -0
  160. package/lib/Selection.js +25 -0
  161. package/lib/SlashCommand.cjs +1 -0
  162. package/lib/SlashCommand.d.cts +299 -0
  163. package/lib/SlashCommand.d.ts +299 -0
  164. package/lib/SlashCommand.js +369 -0
  165. package/lib/Strike.cjs +1 -0
  166. package/lib/Strike.d.cts +343 -0
  167. package/lib/Strike.d.ts +343 -0
  168. package/lib/Strike.js +80 -0
  169. package/lib/SubAndSuperScript.cjs +1 -0
  170. package/lib/SubAndSuperScript.d.cts +358 -0
  171. package/lib/SubAndSuperScript.d.ts +358 -0
  172. package/lib/SubAndSuperScript.js +41 -0
  173. package/lib/Table.cjs +1 -0
  174. package/lib/Table.d.cts +366 -0
  175. package/lib/Table.d.ts +366 -0
  176. package/lib/Table.js +2165 -0
  177. package/lib/TableOfContent.cjs +1 -0
  178. package/lib/TableOfContent.d.cts +274 -0
  179. package/lib/TableOfContent.d.ts +274 -0
  180. package/lib/TableOfContent.js +184 -0
  181. package/lib/TaskList.cjs +1 -0
  182. package/lib/TaskList.d.cts +349 -0
  183. package/lib/TaskList.d.ts +349 -0
  184. package/lib/TaskList.js +175 -0
  185. package/lib/TextAlign.cjs +1 -0
  186. package/lib/TextAlign.d.cts +353 -0
  187. package/lib/TextAlign.d.ts +353 -0
  188. package/lib/TextAlign.js +165 -0
  189. package/lib/TextBubble.cjs +1 -0
  190. package/lib/TextBubble.d.cts +343 -0
  191. package/lib/TextBubble.d.ts +343 -0
  192. package/lib/TextBubble.js +131 -0
  193. package/lib/TextDirection.cjs +1 -0
  194. package/lib/TextDirection.d.cts +270 -0
  195. package/lib/TextDirection.d.ts +270 -0
  196. package/lib/TextDirection.js +142 -0
  197. package/lib/TextUnderline.cjs +1 -0
  198. package/lib/TextUnderline.d.cts +343 -0
  199. package/lib/TextUnderline.d.ts +343 -0
  200. package/lib/TextUnderline.js +61 -0
  201. package/lib/TrailingNode.cjs +1 -0
  202. package/lib/TrailingNode.d.cts +280 -0
  203. package/lib/TrailingNode.d.ts +280 -0
  204. package/lib/TrailingNode.js +41 -0
  205. package/lib/Twitter-BuMkJKBq.cjs +17 -0
  206. package/lib/Twitter-BvdxYuDK.js +1743 -0
  207. package/lib/Twitter.cjs +1 -0
  208. package/lib/Twitter.d.cts +295 -0
  209. package/lib/Twitter.d.ts +295 -0
  210. package/lib/Twitter.js +6 -0
  211. package/lib/Video.cjs +1 -0
  212. package/lib/Video.d.cts +371 -0
  213. package/lib/Video.d.ts +371 -0
  214. package/lib/Video.js +6 -0
  215. package/lib/bubble-extra.cjs +2 -0
  216. package/lib/bubble-extra.d.cts +294 -0
  217. package/lib/bubble-extra.d.ts +294 -0
  218. package/lib/bubble-extra.js +623 -0
  219. package/lib/dom-dataset-CAXnsjYE.cjs +33 -0
  220. package/lib/dom-dataset-CJ7GyQ2E.js +999 -0
  221. package/lib/index-COecBbaE.cjs +89 -0
  222. package/lib/index-ClFtfQ0J.cjs +1 -0
  223. package/lib/index-CvYIX2-x.js +129 -0
  224. package/lib/index-CySbCeQd.cjs +1 -0
  225. package/lib/{index-CO-iymkb.js → index-D9llIWB5.js} +442 -101
  226. package/lib/index-DXBa3JBo.js +46 -0
  227. package/lib/index-DjP7Onch.cjs +1 -0
  228. package/lib/index-Drmyqk9P.js +12322 -0
  229. package/lib/index-DuhDIOel.js +76 -0
  230. package/lib/index-LbrE7K9i.cjs +1 -0
  231. package/lib/index.cjs +2 -1
  232. package/lib/index.d.cts +290 -108
  233. package/lib/index.d.ts +290 -108
  234. package/lib/index.js +587 -13
  235. package/lib/locale-bundle.cjs +1 -1
  236. package/lib/locale-bundle.d.cts +108 -108
  237. package/lib/locale-bundle.d.ts +108 -108
  238. package/lib/locale-bundle.js +1 -1
  239. package/lib/shortId-Bfj8TyNr.cjs +2 -0
  240. package/lib/shortId-WJVkrvml.js +30 -0
  241. package/lib/style.css +1 -1
  242. package/lib/textarea-B172kMgC.js +20 -0
  243. package/lib/textarea-CapyElEP.cjs +1 -0
  244. package/package.json +678 -15
  245. package/lib/RichTextEditor-Ce2IeNE6.js +0 -8265
  246. package/lib/RichTextEditor-hDDApaDD.cjs +0 -136
  247. package/lib/extension-bundle.cjs +0 -33
  248. package/lib/extension-bundle.d.cts +0 -951
  249. package/lib/extension-bundle.d.ts +0 -951
  250. package/lib/extension-bundle.js +0 -5982
  251. package/lib/index-CJ6Hb9MN.cjs +0 -1
  252. package/lib/tiptap-DOP8lVCQ.js +0 -5950
  253. package/lib/tiptap-Dq62HiQ9.cjs +0 -113
  254. package/lib/vendor-BbgkyoD-.js +0 -40297
  255. package/lib/vendor-DdwtMmSr.cjs +0 -302
package/lib/History.js ADDED
@@ -0,0 +1,431 @@
1
+ import { P as j, a as A, x as G, E as L } from "./index-Drmyqk9P.js";
2
+ import { jsxs as x, jsx as I, Fragment as F } from "react/jsx-runtime";
3
+ import { T as S, a as z, r as N, i as U, b as Z, g as $ } from "./RichTextEditor-DvrUVNK2.js";
4
+ var E = 200, f = function() {
5
+ };
6
+ f.prototype.append = function(e) {
7
+ return e.length ? (e = f.from(e), !this.length && e || e.length < E && this.leafAppend(e) || this.length < E && e.leafPrepend(this) || this.appendInner(e)) : this;
8
+ };
9
+ f.prototype.prepend = function(e) {
10
+ return e.length ? f.from(e).append(this) : this;
11
+ };
12
+ f.prototype.appendInner = function(e) {
13
+ return new R(this, e);
14
+ };
15
+ f.prototype.slice = function(e, t) {
16
+ return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ? f.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, t));
17
+ };
18
+ f.prototype.get = function(e) {
19
+ if (!(e < 0 || e >= this.length))
20
+ return this.getInner(e);
21
+ };
22
+ f.prototype.forEach = function(e, t, n) {
23
+ 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);
24
+ };
25
+ f.prototype.map = function(e, t, n) {
26
+ t === void 0 && (t = 0), n === void 0 && (n = this.length);
27
+ var r = [];
28
+ return this.forEach(function(s, l) {
29
+ return r.push(e(s, l));
30
+ }, t, n), r;
31
+ };
32
+ f.from = function(e) {
33
+ return e instanceof f ? e : e && e.length ? new H(e) : f.empty;
34
+ };
35
+ var H = /* @__PURE__ */ function(i) {
36
+ function e(n) {
37
+ i.call(this), this.values = n;
38
+ }
39
+ i && (e.__proto__ = i), e.prototype = Object.create(i && i.prototype), e.prototype.constructor = e;
40
+ var t = { length: { configurable: !0 }, depth: { configurable: !0 } };
41
+ return e.prototype.flatten = function() {
42
+ return this.values;
43
+ }, e.prototype.sliceInner = function(r, s) {
44
+ return r == 0 && s == this.length ? this : new e(this.values.slice(r, s));
45
+ }, e.prototype.getInner = function(r) {
46
+ return this.values[r];
47
+ }, e.prototype.forEachInner = function(r, s, l, o) {
48
+ for (var p = s; p < l; p++)
49
+ if (r(this.values[p], o + p) === !1)
50
+ return !1;
51
+ }, e.prototype.forEachInvertedInner = function(r, s, l, o) {
52
+ for (var p = s - 1; p >= l; p--)
53
+ if (r(this.values[p], o + p) === !1)
54
+ return !1;
55
+ }, e.prototype.leafAppend = function(r) {
56
+ if (this.length + r.length <= E)
57
+ return new e(this.values.concat(r.flatten()));
58
+ }, e.prototype.leafPrepend = function(r) {
59
+ if (this.length + r.length <= E)
60
+ return new e(r.flatten().concat(this.values));
61
+ }, t.length.get = function() {
62
+ return this.values.length;
63
+ }, t.depth.get = function() {
64
+ return 0;
65
+ }, Object.defineProperties(e.prototype, t), e;
66
+ }(f);
67
+ f.empty = new H([]);
68
+ var R = /* @__PURE__ */ function(i) {
69
+ function e(t, n) {
70
+ i.call(this), this.left = t, this.right = n, this.length = t.length + n.length, this.depth = Math.max(t.depth, n.depth) + 1;
71
+ }
72
+ return i && (e.__proto__ = i), e.prototype = Object.create(i && i.prototype), e.prototype.constructor = e, e.prototype.flatten = function() {
73
+ return this.left.flatten().concat(this.right.flatten());
74
+ }, e.prototype.getInner = function(n) {
75
+ return n < this.left.length ? this.left.get(n) : this.right.get(n - this.left.length);
76
+ }, e.prototype.forEachInner = function(n, r, s, l) {
77
+ var o = this.left.length;
78
+ if (r < o && this.left.forEachInner(n, r, Math.min(s, o), l) === !1 || s > o && this.right.forEachInner(n, Math.max(r - o, 0), Math.min(this.length, s) - o, l + o) === !1)
79
+ return !1;
80
+ }, e.prototype.forEachInvertedInner = function(n, r, s, l) {
81
+ var o = this.left.length;
82
+ if (r > o && this.right.forEachInvertedInner(n, r - o, Math.max(s, o) - o, l + o) === !1 || s < o && this.left.forEachInvertedInner(n, Math.min(r, o), s, l) === !1)
83
+ return !1;
84
+ }, e.prototype.sliceInner = function(n, r) {
85
+ if (n == 0 && r == this.length)
86
+ return this;
87
+ var s = this.left.length;
88
+ 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));
89
+ }, e.prototype.leafAppend = function(n) {
90
+ var r = this.right.leafAppend(n);
91
+ if (r)
92
+ return new e(this.left, r);
93
+ }, e.prototype.leafPrepend = function(n) {
94
+ var r = this.left.leafPrepend(n);
95
+ if (r)
96
+ return new e(r, this.right);
97
+ }, e.prototype.appendInner = function(n) {
98
+ 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);
99
+ }, e;
100
+ }(f);
101
+ const V = 500;
102
+ class m {
103
+ constructor(e, t) {
104
+ this.items = e, this.eventCount = t;
105
+ }
106
+ // Pop the latest event off the branch's history and apply it
107
+ // to a document transform.
108
+ popEvent(e, t) {
109
+ if (this.eventCount == 0)
110
+ return null;
111
+ let n = this.items.length;
112
+ for (; ; n--)
113
+ if (this.items.get(n - 1).selection) {
114
+ --n;
115
+ break;
116
+ }
117
+ let r, s;
118
+ t && (r = this.remapping(n, this.items.length), s = r.maps.length);
119
+ let l = e.tr, o, p, a = [], c = [];
120
+ return this.items.forEach((h, u) => {
121
+ if (!h.step) {
122
+ r || (r = this.remapping(n, u + 1), s = r.maps.length), s--, c.push(h);
123
+ return;
124
+ }
125
+ if (r) {
126
+ c.push(new g(h.map));
127
+ let d = h.step.map(r.slice(s)), w;
128
+ d && l.maybeStep(d).doc && (w = l.mapping.maps[l.mapping.maps.length - 1], a.push(new g(w, void 0, void 0, a.length + c.length))), s--, w && r.appendMap(w, s);
129
+ } else
130
+ l.maybeStep(h.step);
131
+ if (h.selection)
132
+ return o = r ? h.selection.map(r.slice(s)) : h.selection, p = new m(this.items.slice(0, n).append(c.reverse().concat(a)), this.eventCount - 1), !1;
133
+ }, this.items.length, 0), { remaining: p, transform: l, selection: o };
134
+ }
135
+ // Create a new branch with the given transform added.
136
+ addTransform(e, t, n, r) {
137
+ let s = [], l = this.eventCount, o = this.items, p = !r && o.length ? o.get(o.length - 1) : null;
138
+ for (let c = 0; c < e.steps.length; c++) {
139
+ let h = e.steps[c].invert(e.docs[c]), u = new g(e.mapping.maps[c], h, t), d;
140
+ (d = p && p.merge(u)) && (u = d, c ? s.pop() : o = o.slice(0, o.length - 1)), s.push(u), t && (l++, t = void 0), r || (p = u);
141
+ }
142
+ let a = l - n.depth;
143
+ return a > B && (o = W(o, a), l -= a), new m(o.append(s), l);
144
+ }
145
+ remapping(e, t) {
146
+ let n = new G();
147
+ return this.items.forEach((r, s) => {
148
+ let l = r.mirrorOffset != null && s - r.mirrorOffset >= e ? n.maps.length - r.mirrorOffset : void 0;
149
+ n.appendMap(r.map, l);
150
+ }, e, t), n;
151
+ }
152
+ addMaps(e) {
153
+ return this.eventCount == 0 ? this : new m(this.items.append(e.map((t) => new g(t))), this.eventCount);
154
+ }
155
+ // When the collab module receives remote changes, the history has
156
+ // to know about those, so that it can adjust the steps that were
157
+ // rebased on top of the remote changes, and include the position
158
+ // maps for the remote changes in its array of items.
159
+ rebased(e, t) {
160
+ if (!this.eventCount)
161
+ return this;
162
+ let n = [], r = Math.max(0, this.items.length - t), s = e.mapping, l = e.steps.length, o = this.eventCount;
163
+ this.items.forEach((u) => {
164
+ u.selection && o--;
165
+ }, r);
166
+ let p = t;
167
+ this.items.forEach((u) => {
168
+ let d = s.getMirror(--p);
169
+ if (d == null)
170
+ return;
171
+ l = Math.min(l, d);
172
+ let w = s.maps[d];
173
+ if (u.step) {
174
+ let K = e.steps[d].invert(e.docs[d]), P = u.selection && u.selection.map(s.slice(p + 1, d));
175
+ P && o++, n.push(new g(w, K, P));
176
+ } else
177
+ n.push(new g(w));
178
+ }, r);
179
+ let a = [];
180
+ for (let u = t; u < l; u++)
181
+ a.push(new g(s.maps[u]));
182
+ let c = this.items.slice(0, r).append(a).append(n), h = new m(c, o);
183
+ return h.emptyItemCount() > V && (h = h.compress(this.items.length - n.length)), h;
184
+ }
185
+ emptyItemCount() {
186
+ let e = 0;
187
+ return this.items.forEach((t) => {
188
+ t.step || e++;
189
+ }), e;
190
+ }
191
+ // Compressing a branch means rewriting it to push the air (map-only
192
+ // items) out. During collaboration, these naturally accumulate
193
+ // because each remote change adds one. The `upto` argument is used
194
+ // to ensure that only the items below a given level are compressed,
195
+ // because `rebased` relies on a clean, untouched set of items in
196
+ // order to associate old items with rebased steps.
197
+ compress(e = this.items.length) {
198
+ let t = this.remapping(0, e), n = t.maps.length, r = [], s = 0;
199
+ return this.items.forEach((l, o) => {
200
+ if (o >= e)
201
+ r.push(l), l.selection && s++;
202
+ else if (l.step) {
203
+ let p = l.step.map(t.slice(n)), a = p && p.getMap();
204
+ if (n--, a && t.appendMap(a, n), p) {
205
+ let c = l.selection && l.selection.map(t.slice(n));
206
+ c && s++;
207
+ let h = new g(a.invert(), p, c), u, d = r.length - 1;
208
+ (u = r.length && r[d].merge(h)) ? r[d] = u : r.push(h);
209
+ }
210
+ } else l.map && n--;
211
+ }, this.items.length, 0), new m(f.from(r.reverse()), s);
212
+ }
213
+ }
214
+ m.empty = new m(f.empty, 0);
215
+ function W(i, e) {
216
+ let t;
217
+ return i.forEach((n, r) => {
218
+ if (n.selection && e-- == 0)
219
+ return t = r, !1;
220
+ }), i.slice(t);
221
+ }
222
+ class g {
223
+ constructor(e, t, n, r) {
224
+ this.map = e, this.step = t, this.selection = n, this.mirrorOffset = r;
225
+ }
226
+ merge(e) {
227
+ if (this.step && e.step && !e.selection) {
228
+ let t = e.step.merge(this.step);
229
+ if (t)
230
+ return new g(t.getMap().invert(), t, this.selection);
231
+ }
232
+ }
233
+ }
234
+ class v {
235
+ constructor(e, t, n, r, s) {
236
+ this.done = e, this.undone = t, this.prevRanges = n, this.prevTime = r, this.prevComposition = s;
237
+ }
238
+ }
239
+ const B = 20;
240
+ function J(i, e, t, n) {
241
+ let r = t.getMeta(y), s;
242
+ if (r)
243
+ return r.historyState;
244
+ t.getMeta(Y) && (i = new v(i.done, i.undone, null, 0, -1));
245
+ let l = t.getMeta("appendedTransaction");
246
+ if (t.steps.length == 0)
247
+ return i;
248
+ if (l && l.getMeta(y))
249
+ return l.getMeta(y).redo ? new v(i.done.addTransform(t, void 0, n, M(e)), i.undone, b(t.mapping.maps), i.prevTime, i.prevComposition) : new v(i.done, i.undone.addTransform(t, void 0, n, M(e)), null, i.prevTime, i.prevComposition);
250
+ if (t.getMeta("addToHistory") !== !1 && !(l && l.getMeta("addToHistory") === !1)) {
251
+ let o = t.getMeta("composition"), p = i.prevTime == 0 || !l && i.prevComposition != o && (i.prevTime < (t.time || 0) - n.newGroupDelay || !Q(t, i.prevRanges)), a = l ? C(i.prevRanges, t.mapping) : b(t.mapping.maps);
252
+ return new v(i.done.addTransform(t, p ? e.selection.getBookmark() : void 0, n, M(e)), m.empty, a, t.time, o ?? i.prevComposition);
253
+ } else return (s = t.getMeta("rebased")) ? new v(i.done.rebased(t, s), i.undone.rebased(t, s), C(i.prevRanges, t.mapping), i.prevTime, i.prevComposition) : new v(i.done.addMaps(t.mapping.maps), i.undone.addMaps(t.mapping.maps), C(i.prevRanges, t.mapping), i.prevTime, i.prevComposition);
254
+ }
255
+ function Q(i, e) {
256
+ if (!e)
257
+ return !1;
258
+ if (!i.docChanged)
259
+ return !0;
260
+ let t = !1;
261
+ return i.mapping.maps[0].forEach((n, r) => {
262
+ for (let s = 0; s < e.length; s += 2)
263
+ n <= e[s + 1] && r >= e[s] && (t = !0);
264
+ }), t;
265
+ }
266
+ function b(i) {
267
+ let e = [];
268
+ for (let t = i.length - 1; t >= 0 && e.length == 0; t--)
269
+ i[t].forEach((n, r, s, l) => e.push(s, l));
270
+ return e;
271
+ }
272
+ function C(i, e) {
273
+ if (!i)
274
+ return null;
275
+ let t = [];
276
+ for (let n = 0; n < i.length; n += 2) {
277
+ let r = e.map(i[n], 1), s = e.map(i[n + 1], -1);
278
+ r <= s && t.push(r, s);
279
+ }
280
+ return t;
281
+ }
282
+ function X(i, e, t) {
283
+ let n = M(e), r = y.get(e).spec.config, s = (t ? i.undone : i.done).popEvent(e, n);
284
+ if (!s)
285
+ return null;
286
+ let l = s.selection.resolve(s.transform.doc), o = (t ? i.done : i.undone).addTransform(s.transform, e.selection.getBookmark(), r, n), p = new v(t ? o : s.remaining, t ? s.remaining : o, null, 0, -1);
287
+ return s.transform.setSelection(l).setMeta(y, { redo: t, historyState: p });
288
+ }
289
+ let T = !1, O = null;
290
+ function M(i) {
291
+ let e = i.plugins;
292
+ if (O != e) {
293
+ T = !1, O = e;
294
+ for (let t = 0; t < e.length; t++)
295
+ if (e[t].spec.historyPreserveItems) {
296
+ T = !0;
297
+ break;
298
+ }
299
+ }
300
+ return T;
301
+ }
302
+ const y = new A("history"), Y = new A("closeHistory");
303
+ function q(i = {}) {
304
+ return i = {
305
+ depth: i.depth || 100,
306
+ newGroupDelay: i.newGroupDelay || 500
307
+ }, new j({
308
+ key: y,
309
+ state: {
310
+ init() {
311
+ return new v(m.empty, m.empty, null, 0, -1);
312
+ },
313
+ apply(e, t, n) {
314
+ return J(t, n, e, i);
315
+ }
316
+ },
317
+ config: i,
318
+ props: {
319
+ handleDOMEvents: {
320
+ beforeinput(e, t) {
321
+ let n = t.inputType, r = n == "historyUndo" ? _ : n == "historyRedo" ? k : null;
322
+ return r ? (t.preventDefault(), r(e.state, e.dispatch)) : !1;
323
+ }
324
+ }
325
+ }
326
+ });
327
+ }
328
+ function D(i, e) {
329
+ return (t, n) => {
330
+ let r = y.getState(t);
331
+ if (!r || (i ? r.undone : r.done).eventCount == 0)
332
+ return !1;
333
+ if (n) {
334
+ let s = X(r, t, i);
335
+ s && n(e ? s.scrollIntoView() : s);
336
+ }
337
+ return !0;
338
+ };
339
+ }
340
+ const _ = D(!1, !0), k = D(!0, !0), ee = L.create({
341
+ name: "history",
342
+ addOptions() {
343
+ return {
344
+ depth: 100,
345
+ newGroupDelay: 500
346
+ };
347
+ },
348
+ addCommands() {
349
+ return {
350
+ undo: () => ({ state: i, dispatch: e }) => _(i, e),
351
+ redo: () => ({ state: i, dispatch: e }) => k(i, e)
352
+ };
353
+ },
354
+ addProseMirrorPlugins() {
355
+ return [
356
+ q(this.options)
357
+ ];
358
+ },
359
+ addKeyboardShortcuts() {
360
+ return {
361
+ "Mod-z": () => this.editor.commands.undo(),
362
+ "Shift-Mod-z": () => this.editor.commands.redo(),
363
+ "Mod-y": () => this.editor.commands.redo(),
364
+ // Russian keyboard layouts
365
+ "Mod-я": () => this.editor.commands.undo(),
366
+ "Shift-Mod-я": () => this.editor.commands.redo()
367
+ };
368
+ }
369
+ });
370
+ function te(i) {
371
+ var a;
372
+ const {
373
+ icon: e = void 0,
374
+ // title = undefined,
375
+ tooltip: t = void 0,
376
+ // disabled = false,
377
+ customClass: n = "",
378
+ // color = undefined,
379
+ // loading = false,
380
+ // shortcutKeys = undefined,
381
+ tooltipOptions: r = {},
382
+ action: s = void 0,
383
+ isActive: l = void 0,
384
+ children: o
385
+ } = i, p = U[e];
386
+ return /* @__PURE__ */ x(S, { children: [
387
+ /* @__PURE__ */ I(z, { asChild: !0, children: /* @__PURE__ */ x(
388
+ N,
389
+ {
390
+ size: "sm",
391
+ className: `richtext-w-[32px] richtext-h-[32px] ${n}`,
392
+ disabled: l == null ? void 0 : l(),
393
+ onClick: s,
394
+ children: [
395
+ p && /* @__PURE__ */ I(p, { className: "richtext-w-4 richtext-h-4" }),
396
+ o && /* @__PURE__ */ I(F, { children: o })
397
+ ]
398
+ }
399
+ ) }),
400
+ t && /* @__PURE__ */ I(Z, { ...r, children: /* @__PURE__ */ x("div", { className: "richtext-flex richtext-flex-col richtext-items-center richtext-text-center richtext-max-w-24", children: [
401
+ /* @__PURE__ */ I("div", { children: t }),
402
+ !!((a = i == null ? void 0 : i.shortcutKeys) != null && a.length) && /* @__PURE__ */ I("span", { children: $(i == null ? void 0 : i.shortcutKeys) })
403
+ ] }) })
404
+ ] });
405
+ }
406
+ const ne = ["undo", "redo"], le = /* @__PURE__ */ ee.extend({
407
+ addOptions() {
408
+ var i;
409
+ return {
410
+ ...(i = this.parent) == null ? void 0 : i.call(this),
411
+ depth: 100,
412
+ newGroupDelay: 500,
413
+ button: ({ editor: e, t }) => ne.map((n) => ({
414
+ component: te,
415
+ componentProps: {
416
+ action: () => {
417
+ n === "undo" && e.chain().focus().undo().run(), n === "redo" && e.chain().focus().redo().run();
418
+ },
419
+ shortcutKeys: n === "undo" ? ["mod", "Z"] : ["shift", "mod", "Z"],
420
+ disabled: n === "undo" ? !e.can().undo() : !e.can().redo(),
421
+ isActive: () => n === "undo" ? !e.can().undo() : !e.can().redo(),
422
+ icon: n === "undo" ? "Undo2" : "Redo2",
423
+ tooltip: t(`editor.${n}.tooltip`)
424
+ }
425
+ }))
426
+ };
427
+ }
428
+ });
429
+ export {
430
+ le as History
431
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-COecBbaE.cjs"),m=require("./RichTextEditor-CM-Xq9RS.cjs"),h=t.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",t.mergeAttributes(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:r})=>{const{selection:i}=r,{$from:a,$to:c}=i,s=n();return a.parentOffset===0?s.insertContentAt({from:Math.max(a.pos-1,0),to:c.pos},{type:this.name}):t.isNodeSelection(i)?s.insertContentAt(c.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:e,dispatch:p})=>{var l;if(p){const{$to:o}=e.selection,d=o.end();if(o.nodeAfter)o.nodeAfter.isTextblock?e.setSelection(t.TextSelection.create(e.doc,o.pos+1)):o.nodeAfter.isBlock?e.setSelection(t.NodeSelection.create(e.doc,o.pos)):e.setSelection(t.TextSelection.create(e.doc,o.pos));else{const u=(l=o.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();u&&(e.insert(d,u),e.setSelection(t.TextSelection.create(e.doc,d+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[t.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),f=h.extend({renderHTML(){return["div",t.mergeAttributes(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]},addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),button:({editor:r,t:i})=>({component:m.ActionButton,componentProps:{action:()=>r.commands.setHorizontalRule(),disabled:!r.can().setHorizontalRule(),icon:"Minus",shortcutKeys:["mod","alt","S"],tooltip:i("editor.horizontalrule.tooltip")}})}},addKeyboardShortcuts(){return{"Mod-Alt-s":()=>this.editor.commands.setHorizontalRule()}}});exports.HorizontalRule=f;