@sovann72-dev/lynqify-ui 1.0.0 → 1.0.2

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 (60) hide show
  1. package/dist/components/NoteEditor/BatchImageGalleryNodeView.d.ts +19 -0
  2. package/dist/components/RichTextEditor/Extension/Image/ImageResize/constants/index.d.ts +22 -0
  3. package/dist/components/RichTextEditor/Extension/Image/ImageResize/controllers/image-node-view.d.ts +38 -0
  4. package/dist/components/RichTextEditor/Extension/Image/ImageResize/controllers/position-controller.d.ts +12 -0
  5. package/dist/components/RichTextEditor/Extension/Image/ImageResize/controllers/resize-controller.d.ts +13 -0
  6. package/dist/components/RichTextEditor/Extension/Image/ImageResize/image-resize.d.ts +22 -0
  7. package/dist/components/RichTextEditor/Extension/Image/ImageResize/index.d.ts +4 -0
  8. package/dist/components/RichTextEditor/Extension/Image/ImageResize/types/index.d.ts +20 -0
  9. package/dist/components/RichTextEditor/Extension/Image/ImageResize/utils/attribute-parser.d.ts +4 -0
  10. package/dist/components/RichTextEditor/Extension/Image/ImageResize/utils/clamp-width.d.ts +6 -0
  11. package/dist/components/RichTextEditor/Extension/Image/ImageResize/utils/index.d.ts +7 -0
  12. package/dist/components/RichTextEditor/Extension/Image/ImageResize/utils/resize-handler.d.ts +12 -0
  13. package/dist/components/RichTextEditor/Extension/Image/ImageResize/utils/style-manager.d.ts +6 -0
  14. package/dist/components/RichTextEditor/Extension/Indent/backspace.indent.handlers.d.ts +18 -0
  15. package/dist/components/RichTextEditor/Extension/Indent/indent.extension.d.ts +26 -0
  16. package/dist/components/RichTextEditor/Extension/Indent/indent.handlers.d.ts +16 -0
  17. package/{src/components/RichTextEditor/Extension/Indent/indent.types.ts → dist/components/RichTextEditor/Extension/Indent/indent.types.d.ts} +10 -35
  18. package/dist/components/RichTextEditor/Extension/Indent/indent.utils.d.ts +8 -0
  19. package/dist/components/RichTextEditor/Extension/Indent/outdent.handlers.d.ts +6 -0
  20. package/dist/components/RichTextEditor/Extension/Indent/shifttab.indent.handlers.d.ts +18 -0
  21. package/dist/components/RichTextEditor/Extension/Indent/tab.indent.handlers.d.ts +21 -0
  22. package/dist/components/RichTextEditor/Extension/List/custom-list-item.extension.d.ts +17 -0
  23. package/dist/components/RichTextEditor/Extension/List/dynamic-bullet-styling.extension.d.ts +2 -0
  24. package/dist/components/RichTextEditor/Extension/batch-segment-images.extension.d.ts +19 -0
  25. package/dist/components/RichTextEditor/Extension/batch-segment-images.types.d.ts +33 -0
  26. package/dist/components/RichTextEditor/Extension/custom-image.extension.d.ts +4 -0
  27. package/dist/components/RichTextEditor/Extension/custom-link.extension.d.ts +3 -0
  28. package/dist/components/RichTextEditor/Extension/custom-mention.extension.d.ts +3 -0
  29. package/dist/components/RichTextEditor/Extension/custom-paragraph.extension.d.ts +6 -0
  30. package/dist/components/RichTextEditor/Extension/extensions.d.ts +4 -0
  31. package/dist/components/RichTextEditor/Extension/file-filtering.extension.d.ts +1 -0
  32. package/dist/components/RichTextEditor/Extension/list-indent-integration.extension.d.ts +2 -0
  33. package/dist/components/RichTextEditor/Extension/mentionstorage.extension.d.ts +9 -0
  34. package/dist/components/RichTextEditor/Extension/tiptap-extension-fontsize.d.ts +21 -0
  35. package/dist/components/RichTextEditor/Extension/tiptap-extension-lineheight.d.ts +21 -0
  36. package/{src/index.ts → dist/index.d.ts} +9 -17
  37. package/dist/lynqify-ui.js +3806 -0
  38. package/dist/lynqify-ui.umd.cjs +53 -0
  39. package/package.json +60 -31
  40. package/src/components/RichTextEditor/Extension/Indent/backspace.indent.handlers.ts +0 -77
  41. package/src/components/RichTextEditor/Extension/Indent/indent.extension.ts +0 -285
  42. package/src/components/RichTextEditor/Extension/Indent/indent.handlers.ts +0 -121
  43. package/src/components/RichTextEditor/Extension/Indent/indent.utils.ts +0 -8
  44. package/src/components/RichTextEditor/Extension/Indent/outdent.handlers.ts +0 -71
  45. package/src/components/RichTextEditor/Extension/Indent/shifttab.indent.handlers.ts +0 -133
  46. package/src/components/RichTextEditor/Extension/Indent/tab.indent.handlers.ts +0 -103
  47. package/src/components/RichTextEditor/Extension/List/custom-list-item.extension.ts +0 -107
  48. package/src/components/RichTextEditor/Extension/List/dynamic-bullet-styling.extension.ts +0 -40
  49. package/src/components/RichTextEditor/Extension/batch-segment-images.extension.ts +0 -486
  50. package/src/components/RichTextEditor/Extension/batch-segment-images.types.ts +0 -35
  51. package/src/components/RichTextEditor/Extension/custom-image.extension.ts +0 -18
  52. package/src/components/RichTextEditor/Extension/custom-link.extension.ts +0 -58
  53. package/src/components/RichTextEditor/Extension/custom-mention.extension.ts +0 -29
  54. package/src/components/RichTextEditor/Extension/custom-paragraph.extension.ts +0 -46
  55. package/src/components/RichTextEditor/Extension/extensions.ts +0 -118
  56. package/src/components/RichTextEditor/Extension/file-filtering.extension.ts +0 -0
  57. package/src/components/RichTextEditor/Extension/list-indent-integration.extension.ts +0 -125
  58. package/src/components/RichTextEditor/Extension/mentionstorage.extension.ts +0 -10
  59. package/src/components/RichTextEditor/Extension/tiptap-extension-fontsize.ts +0 -73
  60. package/src/components/RichTextEditor/Extension/tiptap-extension-lineheight.ts +0 -73
@@ -0,0 +1,3806 @@
1
+ var Ur = Object.defineProperty;
2
+ var qr = (n, e, t) => e in n ? Ur(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var b = (n, e, t) => qr(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import Nt from "@tiptap/extension-bold";
5
+ import { default as Li } from "@tiptap/extension-bold";
6
+ import Lt from "@tiptap/extension-color";
7
+ import { default as zi } from "@tiptap/extension-color";
8
+ import At from "@tiptap/extension-document";
9
+ import { default as Pi } from "@tiptap/extension-document";
10
+ import Kr from "@tiptap/extension-file-handler";
11
+ import { default as _i } from "@tiptap/extension-file-handler";
12
+ import zt from "@tiptap/extension-hard-break";
13
+ import { default as Bi } from "@tiptap/extension-hard-break";
14
+ import Yr from "@tiptap/extension-heading";
15
+ import { default as Ji } from "@tiptap/extension-heading";
16
+ import Xr from "@tiptap/extension-highlight";
17
+ import { default as Hi } from "@tiptap/extension-highlight";
18
+ import Gr from "@tiptap/extension-image";
19
+ import { default as ji } from "@tiptap/extension-image";
20
+ import Mt from "@tiptap/extension-italic";
21
+ import { default as qi } from "@tiptap/extension-italic";
22
+ import Zr from "@tiptap/extension-link";
23
+ import { default as Yi } from "@tiptap/extension-link";
24
+ import { BulletList as Pt, ListItem as Dt, OrderedList as _t, TaskItem as $t, ListKeymap as Qr, TaskList as en } from "@tiptap/extension-list";
25
+ import { BulletList as Gi, ListItem as Zi, ListKeymap as Qi, OrderedList as es, TaskItem as ts, TaskList as rs } from "@tiptap/extension-list";
26
+ import tn from "@tiptap/extension-mention";
27
+ import { default as is } from "@tiptap/extension-mention";
28
+ import Bt from "@tiptap/extension-paragraph";
29
+ import { default as os } from "@tiptap/extension-paragraph";
30
+ import { Table as rn, TableCell as nn, TableHeader as sn, TableRow as on } from "@tiptap/extension-table";
31
+ import { Table as ls, TableCell as cs, TableHeader as ds, TableRow as us } from "@tiptap/extension-table";
32
+ import Ft from "@tiptap/extension-text";
33
+ import { default as hs } from "@tiptap/extension-text";
34
+ import Jt from "@tiptap/extension-text-align";
35
+ import { default as ms } from "@tiptap/extension-text-align";
36
+ import { TextStyle as Wt } from "@tiptap/extension-text-style";
37
+ import { TextStyle as ys } from "@tiptap/extension-text-style";
38
+ import Ht from "@tiptap/extension-underline";
39
+ import { default as ws } from "@tiptap/extension-underline";
40
+ import { UndoRedo as Vt, CharacterCount as an, Placeholder as ln } from "@tiptap/extensions";
41
+ import { CharacterCount as Is, UndoRedo as Ss, Placeholder as Es } from "@tiptap/extensions";
42
+ import { Extension as ge, Node as cn } from "@tiptap/core";
43
+ import { Extension as dn } from "@tiptap/react";
44
+ import { Editor as Ts, EditorContent as Rs, useEditor as Cs } from "@tiptap/react";
45
+ import * as De from "react";
46
+ import jt from "react";
47
+ import un from "react-dom";
48
+ function Ut(n, e, t) {
49
+ for (let r = 0; ; r++) {
50
+ if (r == n.childCount || r == e.childCount)
51
+ return n.childCount == e.childCount ? null : t;
52
+ let i = n.child(r), s = e.child(r);
53
+ if (i == s) {
54
+ t += i.nodeSize;
55
+ continue;
56
+ }
57
+ if (!i.sameMarkup(s))
58
+ return t;
59
+ if (i.isText && i.text != s.text) {
60
+ for (let l = 0; i.text[l] == s.text[l]; l++)
61
+ t++;
62
+ return t;
63
+ }
64
+ if (i.content.size || s.content.size) {
65
+ let l = Ut(i.content, s.content, t + 1);
66
+ if (l != null)
67
+ return l;
68
+ }
69
+ t += i.nodeSize;
70
+ }
71
+ }
72
+ function qt(n, e, t, r) {
73
+ for (let i = n.childCount, s = e.childCount; ; ) {
74
+ if (i == 0 || s == 0)
75
+ return i == s ? null : { a: t, b: r };
76
+ let l = n.child(--i), a = e.child(--s), c = l.nodeSize;
77
+ if (l == a) {
78
+ t -= c, r -= c;
79
+ continue;
80
+ }
81
+ if (!l.sameMarkup(a))
82
+ return { a: t, b: r };
83
+ if (l.isText && l.text != a.text) {
84
+ let f = 0, d = Math.min(l.text.length, a.text.length);
85
+ for (; f < d && l.text[l.text.length - f - 1] == a.text[a.text.length - f - 1]; )
86
+ f++, t--, r--;
87
+ return { a: t, b: r };
88
+ }
89
+ if (l.content.size || a.content.size) {
90
+ let f = qt(l.content, a.content, t - 1, r - 1);
91
+ if (f)
92
+ return f;
93
+ }
94
+ t -= c, r -= c;
95
+ }
96
+ }
97
+ class C {
98
+ /**
99
+ @internal
100
+ */
101
+ constructor(e, t) {
102
+ if (this.content = e, this.size = t || 0, t == null)
103
+ for (let r = 0; r < e.length; r++)
104
+ this.size += e[r].nodeSize;
105
+ }
106
+ /**
107
+ Invoke a callback for all descendant nodes between the given two
108
+ positions (relative to start of this fragment). Doesn't descend
109
+ into a node when the callback returns `false`.
110
+ */
111
+ nodesBetween(e, t, r, i = 0, s) {
112
+ for (let l = 0, a = 0; a < t; l++) {
113
+ let c = this.content[l], f = a + c.nodeSize;
114
+ if (f > e && r(c, i + a, s || null, l) !== !1 && c.content.size) {
115
+ let d = a + 1;
116
+ c.nodesBetween(Math.max(0, e - d), Math.min(c.content.size, t - d), r, i + d);
117
+ }
118
+ a = f;
119
+ }
120
+ }
121
+ /**
122
+ Call the given callback for every descendant node. `pos` will be
123
+ relative to the start of the fragment. The callback may return
124
+ `false` to prevent traversal of a given node's children.
125
+ */
126
+ descendants(e) {
127
+ this.nodesBetween(0, this.size, e);
128
+ }
129
+ /**
130
+ Extract the text between `from` and `to`. See the same method on
131
+ [`Node`](https://prosemirror.net/docs/ref/#model.Node.textBetween).
132
+ */
133
+ textBetween(e, t, r, i) {
134
+ let s = "", l = !0;
135
+ return this.nodesBetween(e, t, (a, c) => {
136
+ let f = a.isText ? a.text.slice(Math.max(e, c) - c, t - c) : a.isLeaf ? i ? typeof i == "function" ? i(a) : i : a.type.spec.leafText ? a.type.spec.leafText(a) : "" : "";
137
+ a.isBlock && (a.isLeaf && f || a.isTextblock) && r && (l ? l = !1 : s += r), s += f;
138
+ }, 0), s;
139
+ }
140
+ /**
141
+ Create a new fragment containing the combined content of this
142
+ fragment and the other.
143
+ */
144
+ append(e) {
145
+ if (!e.size)
146
+ return this;
147
+ if (!this.size)
148
+ return e;
149
+ let t = this.lastChild, r = e.firstChild, i = this.content.slice(), s = 0;
150
+ for (t.isText && t.sameMarkup(r) && (i[i.length - 1] = t.withText(t.text + r.text), s = 1); s < e.content.length; s++)
151
+ i.push(e.content[s]);
152
+ return new C(i, this.size + e.size);
153
+ }
154
+ /**
155
+ Cut out the sub-fragment between the two given positions.
156
+ */
157
+ cut(e, t = this.size) {
158
+ if (e == 0 && t == this.size)
159
+ return this;
160
+ let r = [], i = 0;
161
+ if (t > e)
162
+ for (let s = 0, l = 0; l < t; s++) {
163
+ let a = this.content[s], c = l + a.nodeSize;
164
+ c > e && ((l < e || c > t) && (a.isText ? a = a.cut(Math.max(0, e - l), Math.min(a.text.length, t - l)) : a = a.cut(Math.max(0, e - l - 1), Math.min(a.content.size, t - l - 1))), r.push(a), i += a.nodeSize), l = c;
165
+ }
166
+ return new C(r, i);
167
+ }
168
+ /**
169
+ @internal
170
+ */
171
+ cutByIndex(e, t) {
172
+ return e == t ? C.empty : e == 0 && t == this.content.length ? this : new C(this.content.slice(e, t));
173
+ }
174
+ /**
175
+ Create a new fragment in which the node at the given index is
176
+ replaced by the given node.
177
+ */
178
+ replaceChild(e, t) {
179
+ let r = this.content[e];
180
+ if (r == t)
181
+ return this;
182
+ let i = this.content.slice(), s = this.size + t.nodeSize - r.nodeSize;
183
+ return i[e] = t, new C(i, s);
184
+ }
185
+ /**
186
+ Create a new fragment by prepending the given node to this
187
+ fragment.
188
+ */
189
+ addToStart(e) {
190
+ return new C([e].concat(this.content), this.size + e.nodeSize);
191
+ }
192
+ /**
193
+ Create a new fragment by appending the given node to this
194
+ fragment.
195
+ */
196
+ addToEnd(e) {
197
+ return new C(this.content.concat(e), this.size + e.nodeSize);
198
+ }
199
+ /**
200
+ Compare this fragment to another one.
201
+ */
202
+ eq(e) {
203
+ if (this.content.length != e.content.length)
204
+ return !1;
205
+ for (let t = 0; t < this.content.length; t++)
206
+ if (!this.content[t].eq(e.content[t]))
207
+ return !1;
208
+ return !0;
209
+ }
210
+ /**
211
+ The first child of the fragment, or `null` if it is empty.
212
+ */
213
+ get firstChild() {
214
+ return this.content.length ? this.content[0] : null;
215
+ }
216
+ /**
217
+ The last child of the fragment, or `null` if it is empty.
218
+ */
219
+ get lastChild() {
220
+ return this.content.length ? this.content[this.content.length - 1] : null;
221
+ }
222
+ /**
223
+ The number of child nodes in this fragment.
224
+ */
225
+ get childCount() {
226
+ return this.content.length;
227
+ }
228
+ /**
229
+ Get the child node at the given index. Raise an error when the
230
+ index is out of range.
231
+ */
232
+ child(e) {
233
+ let t = this.content[e];
234
+ if (!t)
235
+ throw new RangeError("Index " + e + " out of range for " + this);
236
+ return t;
237
+ }
238
+ /**
239
+ Get the child node at the given index, if it exists.
240
+ */
241
+ maybeChild(e) {
242
+ return this.content[e] || null;
243
+ }
244
+ /**
245
+ Call `f` for every child node, passing the node, its offset
246
+ into this parent node, and its index.
247
+ */
248
+ forEach(e) {
249
+ for (let t = 0, r = 0; t < this.content.length; t++) {
250
+ let i = this.content[t];
251
+ e(i, r, t), r += i.nodeSize;
252
+ }
253
+ }
254
+ /**
255
+ Find the first position at which this fragment and another
256
+ fragment differ, or `null` if they are the same.
257
+ */
258
+ findDiffStart(e, t = 0) {
259
+ return Ut(this, e, t);
260
+ }
261
+ /**
262
+ Find the first position, searching from the end, at which this
263
+ fragment and the given fragment differ, or `null` if they are
264
+ the same. Since this position will not be the same in both
265
+ nodes, an object with two separate positions is returned.
266
+ */
267
+ findDiffEnd(e, t = this.size, r = e.size) {
268
+ return qt(this, e, t, r);
269
+ }
270
+ /**
271
+ Find the index and inner offset corresponding to a given relative
272
+ position in this fragment. The result object will be reused
273
+ (overwritten) the next time the function is called. @internal
274
+ */
275
+ findIndex(e) {
276
+ if (e == 0)
277
+ return Ie(0, e);
278
+ if (e == this.size)
279
+ return Ie(this.content.length, e);
280
+ if (e > this.size || e < 0)
281
+ throw new RangeError(`Position ${e} outside of fragment (${this})`);
282
+ for (let t = 0, r = 0; ; t++) {
283
+ let i = this.child(t), s = r + i.nodeSize;
284
+ if (s >= e)
285
+ return s == e ? Ie(t + 1, s) : Ie(t, r);
286
+ r = s;
287
+ }
288
+ }
289
+ /**
290
+ Return a debugging string that describes this fragment.
291
+ */
292
+ toString() {
293
+ return "<" + this.toStringInner() + ">";
294
+ }
295
+ /**
296
+ @internal
297
+ */
298
+ toStringInner() {
299
+ return this.content.join(", ");
300
+ }
301
+ /**
302
+ Create a JSON-serializeable representation of this fragment.
303
+ */
304
+ toJSON() {
305
+ return this.content.length ? this.content.map((e) => e.toJSON()) : null;
306
+ }
307
+ /**
308
+ Deserialize a fragment from its JSON representation.
309
+ */
310
+ static fromJSON(e, t) {
311
+ if (!t)
312
+ return C.empty;
313
+ if (!Array.isArray(t))
314
+ throw new RangeError("Invalid input for Fragment.fromJSON");
315
+ return new C(t.map(e.nodeFromJSON));
316
+ }
317
+ /**
318
+ Build a fragment from an array of nodes. Ensures that adjacent
319
+ text nodes with the same marks are joined together.
320
+ */
321
+ static fromArray(e) {
322
+ if (!e.length)
323
+ return C.empty;
324
+ let t, r = 0;
325
+ for (let i = 0; i < e.length; i++) {
326
+ let s = e[i];
327
+ r += s.nodeSize, i && s.isText && e[i - 1].sameMarkup(s) ? (t || (t = e.slice(0, i)), t[t.length - 1] = s.withText(t[t.length - 1].text + s.text)) : t && t.push(s);
328
+ }
329
+ return new C(t || e, r);
330
+ }
331
+ /**
332
+ Create a fragment from something that can be interpreted as a
333
+ set of nodes. For `null`, it returns the empty fragment. For a
334
+ fragment, the fragment itself. For a node or array of nodes, a
335
+ fragment containing those nodes.
336
+ */
337
+ static from(e) {
338
+ if (!e)
339
+ return C.empty;
340
+ if (e instanceof C)
341
+ return e;
342
+ if (Array.isArray(e))
343
+ return this.fromArray(e);
344
+ if (e.attrs)
345
+ return new C([e], e.nodeSize);
346
+ throw new RangeError("Can not convert " + e + " to a Fragment" + (e.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
347
+ }
348
+ }
349
+ C.empty = new C([], 0);
350
+ const _e = { index: 0, offset: 0 };
351
+ function Ie(n, e) {
352
+ return _e.index = n, _e.offset = e, _e;
353
+ }
354
+ class fn extends Error {
355
+ }
356
+ class T {
357
+ /**
358
+ Create a slice. When specifying a non-zero open depth, you must
359
+ make sure that there are nodes of at least that depth at the
360
+ appropriate side of the fragment—i.e. if the fragment is an
361
+ empty paragraph node, `openStart` and `openEnd` can't be greater
362
+ than 1.
363
+
364
+ It is not necessary for the content of open nodes to conform to
365
+ the schema's content constraints, though it should be a valid
366
+ start/end/middle for such a node, depending on which sides are
367
+ open.
368
+ */
369
+ constructor(e, t, r) {
370
+ this.content = e, this.openStart = t, this.openEnd = r;
371
+ }
372
+ /**
373
+ The size this slice would add when inserted into a document.
374
+ */
375
+ get size() {
376
+ return this.content.size - this.openStart - this.openEnd;
377
+ }
378
+ /**
379
+ @internal
380
+ */
381
+ insertAt(e, t) {
382
+ let r = Yt(this.content, e + this.openStart, t);
383
+ return r && new T(r, this.openStart, this.openEnd);
384
+ }
385
+ /**
386
+ @internal
387
+ */
388
+ removeBetween(e, t) {
389
+ return new T(Kt(this.content, e + this.openStart, t + this.openStart), this.openStart, this.openEnd);
390
+ }
391
+ /**
392
+ Tests whether this slice is equal to another slice.
393
+ */
394
+ eq(e) {
395
+ return this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd;
396
+ }
397
+ /**
398
+ @internal
399
+ */
400
+ toString() {
401
+ return this.content + "(" + this.openStart + "," + this.openEnd + ")";
402
+ }
403
+ /**
404
+ Convert a slice to a JSON-serializable representation.
405
+ */
406
+ toJSON() {
407
+ if (!this.content.size)
408
+ return null;
409
+ let e = { content: this.content.toJSON() };
410
+ return this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e;
411
+ }
412
+ /**
413
+ Deserialize a slice from its JSON representation.
414
+ */
415
+ static fromJSON(e, t) {
416
+ if (!t)
417
+ return T.empty;
418
+ let r = t.openStart || 0, i = t.openEnd || 0;
419
+ if (typeof r != "number" || typeof i != "number")
420
+ throw new RangeError("Invalid input for Slice.fromJSON");
421
+ return new T(C.fromJSON(e, t.content), r, i);
422
+ }
423
+ /**
424
+ Create a slice from a fragment by taking the maximum possible
425
+ open value on both side of the fragment.
426
+ */
427
+ static maxOpen(e, t = !0) {
428
+ let r = 0, i = 0;
429
+ for (let s = e.firstChild; s && !s.isLeaf && (t || !s.type.spec.isolating); s = s.firstChild)
430
+ r++;
431
+ for (let s = e.lastChild; s && !s.isLeaf && (t || !s.type.spec.isolating); s = s.lastChild)
432
+ i++;
433
+ return new T(e, r, i);
434
+ }
435
+ }
436
+ T.empty = new T(C.empty, 0, 0);
437
+ function Kt(n, e, t) {
438
+ let { index: r, offset: i } = n.findIndex(e), s = n.maybeChild(r), { index: l, offset: a } = n.findIndex(t);
439
+ if (i == e || s.isText) {
440
+ if (a != t && !n.child(l).isText)
441
+ throw new RangeError("Removing non-flat range");
442
+ return n.cut(0, e).append(n.cut(t));
443
+ }
444
+ if (r != l)
445
+ throw new RangeError("Removing non-flat range");
446
+ return n.replaceChild(r, s.copy(Kt(s.content, e - i - 1, t - i - 1)));
447
+ }
448
+ function Yt(n, e, t, r) {
449
+ let { index: i, offset: s } = n.findIndex(e), l = n.maybeChild(i);
450
+ if (s == e || l.isText)
451
+ return r && !r.canReplace(i, i, t) ? null : n.cut(0, e).append(t).append(n.cut(e));
452
+ let a = Yt(l.content, e - s - 1, t, l);
453
+ return a && n.replaceChild(i, l.copy(a));
454
+ }
455
+ class Xt {
456
+ /**
457
+ Construct a node range. `$from` and `$to` should point into the
458
+ same node until at least the given `depth`, since a node range
459
+ denotes an adjacent set of nodes in a single parent node.
460
+ */
461
+ constructor(e, t, r) {
462
+ this.$from = e, this.$to = t, this.depth = r;
463
+ }
464
+ /**
465
+ The position at the start of the range.
466
+ */
467
+ get start() {
468
+ return this.$from.before(this.depth + 1);
469
+ }
470
+ /**
471
+ The position at the end of the range.
472
+ */
473
+ get end() {
474
+ return this.$to.after(this.depth + 1);
475
+ }
476
+ /**
477
+ The parent node that the range points into.
478
+ */
479
+ get parent() {
480
+ return this.$from.node(this.depth);
481
+ }
482
+ /**
483
+ The start index of the range in the parent node.
484
+ */
485
+ get startIndex() {
486
+ return this.$from.index(this.depth);
487
+ }
488
+ /**
489
+ The end index of the range in the parent node.
490
+ */
491
+ get endIndex() {
492
+ return this.$to.indexAfter(this.depth);
493
+ }
494
+ }
495
+ const Gt = 65535, Zt = Math.pow(2, 16);
496
+ function hn(n, e) {
497
+ return n + e * Zt;
498
+ }
499
+ function wt(n) {
500
+ return n & Gt;
501
+ }
502
+ function pn(n) {
503
+ return (n - (n & Gt)) / Zt;
504
+ }
505
+ const Qt = 1, er = 2, be = 4, tr = 8;
506
+ class xt {
507
+ /**
508
+ @internal
509
+ */
510
+ constructor(e, t, r) {
511
+ this.pos = e, this.delInfo = t, this.recover = r;
512
+ }
513
+ /**
514
+ Tells you whether the position was deleted, that is, whether the
515
+ step removed the token on the side queried (via the `assoc`)
516
+ argument from the document.
517
+ */
518
+ get deleted() {
519
+ return (this.delInfo & tr) > 0;
520
+ }
521
+ /**
522
+ Tells you whether the token before the mapped position was deleted.
523
+ */
524
+ get deletedBefore() {
525
+ return (this.delInfo & (Qt | be)) > 0;
526
+ }
527
+ /**
528
+ True when the token after the mapped position was deleted.
529
+ */
530
+ get deletedAfter() {
531
+ return (this.delInfo & (er | be)) > 0;
532
+ }
533
+ /**
534
+ Tells whether any of the steps mapped through deletes across the
535
+ position (including both the token before and after the
536
+ position).
537
+ */
538
+ get deletedAcross() {
539
+ return (this.delInfo & be) > 0;
540
+ }
541
+ }
542
+ class J {
543
+ /**
544
+ Create a position map. The modifications to the document are
545
+ represented as an array of numbers, in which each group of three
546
+ represents a modified chunk as `[start, oldSize, newSize]`.
547
+ */
548
+ constructor(e, t = !1) {
549
+ if (this.ranges = e, this.inverted = t, !e.length && J.empty)
550
+ return J.empty;
551
+ }
552
+ /**
553
+ @internal
554
+ */
555
+ recover(e) {
556
+ let t = 0, r = wt(e);
557
+ if (!this.inverted)
558
+ for (let i = 0; i < r; i++)
559
+ t += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1];
560
+ return this.ranges[r * 3] + t + pn(e);
561
+ }
562
+ mapResult(e, t = 1) {
563
+ return this._map(e, t, !1);
564
+ }
565
+ map(e, t = 1) {
566
+ return this._map(e, t, !0);
567
+ }
568
+ /**
569
+ @internal
570
+ */
571
+ _map(e, t, r) {
572
+ let i = 0, s = this.inverted ? 2 : 1, l = this.inverted ? 1 : 2;
573
+ for (let a = 0; a < this.ranges.length; a += 3) {
574
+ let c = this.ranges[a] - (this.inverted ? i : 0);
575
+ if (c > e)
576
+ break;
577
+ let f = this.ranges[a + s], d = this.ranges[a + l], h = c + f;
578
+ if (e <= h) {
579
+ let g = f ? e == c ? -1 : e == h ? 1 : t : t, v = c + i + (g < 0 ? 0 : d);
580
+ if (r)
581
+ return v;
582
+ let m = e == (t < 0 ? c : h) ? null : hn(a / 3, e - c), I = e == c ? er : e == h ? Qt : be;
583
+ return (t < 0 ? e != c : e != h) && (I |= tr), new xt(v, I, m);
584
+ }
585
+ i += d - f;
586
+ }
587
+ return r ? e + i : new xt(e + i, 0, null);
588
+ }
589
+ /**
590
+ @internal
591
+ */
592
+ touches(e, t) {
593
+ let r = 0, i = wt(t), s = this.inverted ? 2 : 1, l = this.inverted ? 1 : 2;
594
+ for (let a = 0; a < this.ranges.length; a += 3) {
595
+ let c = this.ranges[a] - (this.inverted ? r : 0);
596
+ if (c > e)
597
+ break;
598
+ let f = this.ranges[a + s], d = c + f;
599
+ if (e <= d && a == i * 3)
600
+ return !0;
601
+ r += this.ranges[a + l] - f;
602
+ }
603
+ return !1;
604
+ }
605
+ /**
606
+ Calls the given function on each of the changed ranges included in
607
+ this map.
608
+ */
609
+ forEach(e) {
610
+ let t = this.inverted ? 2 : 1, r = this.inverted ? 1 : 2;
611
+ for (let i = 0, s = 0; i < this.ranges.length; i += 3) {
612
+ let l = this.ranges[i], a = l - (this.inverted ? s : 0), c = l + (this.inverted ? 0 : s), f = this.ranges[i + t], d = this.ranges[i + r];
613
+ e(a, a + f, c, c + d), s += d - f;
614
+ }
615
+ }
616
+ /**
617
+ Create an inverted version of this map. The result can be used to
618
+ map positions in the post-step document to the pre-step document.
619
+ */
620
+ invert() {
621
+ return new J(this.ranges, !this.inverted);
622
+ }
623
+ /**
624
+ @internal
625
+ */
626
+ toString() {
627
+ return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
628
+ }
629
+ /**
630
+ Create a map that moves all positions by offset `n` (which may be
631
+ negative). This can be useful when applying steps meant for a
632
+ sub-document to a larger document, or vice-versa.
633
+ */
634
+ static offset(e) {
635
+ return e == 0 ? J.empty : new J(e < 0 ? [0, -e, 0] : [0, 0, e]);
636
+ }
637
+ }
638
+ J.empty = new J([]);
639
+ const $e = /* @__PURE__ */ Object.create(null);
640
+ class D {
641
+ /**
642
+ Get the step map that represents the changes made by this step,
643
+ and which can be used to transform between positions in the old
644
+ and the new document.
645
+ */
646
+ getMap() {
647
+ return J.empty;
648
+ }
649
+ /**
650
+ Try to merge this step with another one, to be applied directly
651
+ after it. Returns the merged step when possible, null if the
652
+ steps can't be merged.
653
+ */
654
+ merge(e) {
655
+ return null;
656
+ }
657
+ /**
658
+ Deserialize a step from its JSON representation. Will call
659
+ through to the step class' own implementation of this method.
660
+ */
661
+ static fromJSON(e, t) {
662
+ if (!t || !t.stepType)
663
+ throw new RangeError("Invalid input for Step.fromJSON");
664
+ let r = $e[t.stepType];
665
+ if (!r)
666
+ throw new RangeError(`No step type ${t.stepType} defined`);
667
+ return r.fromJSON(e, t);
668
+ }
669
+ /**
670
+ To be able to serialize steps to JSON, each step needs a string
671
+ ID to attach to its JSON representation. Use this method to
672
+ register an ID for your step classes. Try to pick something
673
+ that's unlikely to clash with steps from other modules.
674
+ */
675
+ static jsonID(e, t) {
676
+ if (e in $e)
677
+ throw new RangeError("Duplicate use of step JSON ID " + e);
678
+ return $e[e] = t, t.prototype.jsonID = e, t;
679
+ }
680
+ }
681
+ class N {
682
+ /**
683
+ @internal
684
+ */
685
+ constructor(e, t) {
686
+ this.doc = e, this.failed = t;
687
+ }
688
+ /**
689
+ Create a successful step result.
690
+ */
691
+ static ok(e) {
692
+ return new N(e, null);
693
+ }
694
+ /**
695
+ Create a failed step result.
696
+ */
697
+ static fail(e) {
698
+ return new N(null, e);
699
+ }
700
+ /**
701
+ Call [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) with the given
702
+ arguments. Create a successful result if it succeeds, and a
703
+ failed one if it throws a `ReplaceError`.
704
+ */
705
+ static fromReplace(e, t, r, i) {
706
+ try {
707
+ return N.ok(e.replace(t, r, i));
708
+ } catch (s) {
709
+ if (s instanceof fn)
710
+ return N.fail(s.message);
711
+ throw s;
712
+ }
713
+ }
714
+ }
715
+ function Ue(n, e, t) {
716
+ let r = [];
717
+ for (let i = 0; i < n.childCount; i++) {
718
+ let s = n.child(i);
719
+ s.content.size && (s = s.copy(Ue(s.content, e, s))), s.isInline && (s = e(s, t, i)), r.push(s);
720
+ }
721
+ return C.fromArray(r);
722
+ }
723
+ class Y extends D {
724
+ /**
725
+ Create a mark step.
726
+ */
727
+ constructor(e, t, r) {
728
+ super(), this.from = e, this.to = t, this.mark = r;
729
+ }
730
+ apply(e) {
731
+ let t = e.slice(this.from, this.to), r = e.resolve(this.from), i = r.node(r.sharedDepth(this.to)), s = new T(Ue(t.content, (l, a) => !l.isAtom || !a.type.allowsMarkType(this.mark.type) ? l : l.mark(this.mark.addToSet(l.marks)), i), t.openStart, t.openEnd);
732
+ return N.fromReplace(e, this.from, this.to, s);
733
+ }
734
+ invert() {
735
+ return new X(this.from, this.to, this.mark);
736
+ }
737
+ map(e) {
738
+ let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
739
+ return t.deleted && r.deleted || t.pos >= r.pos ? null : new Y(t.pos, r.pos, this.mark);
740
+ }
741
+ merge(e) {
742
+ return e instanceof Y && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new Y(Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark) : null;
743
+ }
744
+ toJSON() {
745
+ return {
746
+ stepType: "addMark",
747
+ mark: this.mark.toJSON(),
748
+ from: this.from,
749
+ to: this.to
750
+ };
751
+ }
752
+ /**
753
+ @internal
754
+ */
755
+ static fromJSON(e, t) {
756
+ if (typeof t.from != "number" || typeof t.to != "number")
757
+ throw new RangeError("Invalid input for AddMarkStep.fromJSON");
758
+ return new Y(t.from, t.to, e.markFromJSON(t.mark));
759
+ }
760
+ }
761
+ D.jsonID("addMark", Y);
762
+ class X extends D {
763
+ /**
764
+ Create a mark-removing step.
765
+ */
766
+ constructor(e, t, r) {
767
+ super(), this.from = e, this.to = t, this.mark = r;
768
+ }
769
+ apply(e) {
770
+ let t = e.slice(this.from, this.to), r = new T(Ue(t.content, (i) => i.mark(this.mark.removeFromSet(i.marks)), e), t.openStart, t.openEnd);
771
+ return N.fromReplace(e, this.from, this.to, r);
772
+ }
773
+ invert() {
774
+ return new Y(this.from, this.to, this.mark);
775
+ }
776
+ map(e) {
777
+ let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
778
+ return t.deleted && r.deleted || t.pos >= r.pos ? null : new X(t.pos, r.pos, this.mark);
779
+ }
780
+ merge(e) {
781
+ return e instanceof X && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new X(Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark) : null;
782
+ }
783
+ toJSON() {
784
+ return {
785
+ stepType: "removeMark",
786
+ mark: this.mark.toJSON(),
787
+ from: this.from,
788
+ to: this.to
789
+ };
790
+ }
791
+ /**
792
+ @internal
793
+ */
794
+ static fromJSON(e, t) {
795
+ if (typeof t.from != "number" || typeof t.to != "number")
796
+ throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");
797
+ return new X(t.from, t.to, e.markFromJSON(t.mark));
798
+ }
799
+ }
800
+ D.jsonID("removeMark", X);
801
+ class G extends D {
802
+ /**
803
+ Create a node mark step.
804
+ */
805
+ constructor(e, t) {
806
+ super(), this.pos = e, this.mark = t;
807
+ }
808
+ apply(e) {
809
+ let t = e.nodeAt(this.pos);
810
+ if (!t)
811
+ return N.fail("No node at mark step's position");
812
+ let r = t.type.create(t.attrs, null, this.mark.addToSet(t.marks));
813
+ return N.fromReplace(e, this.pos, this.pos + 1, new T(C.from(r), 0, t.isLeaf ? 0 : 1));
814
+ }
815
+ invert(e) {
816
+ let t = e.nodeAt(this.pos);
817
+ if (t) {
818
+ let r = this.mark.addToSet(t.marks);
819
+ if (r.length == t.marks.length) {
820
+ for (let i = 0; i < t.marks.length; i++)
821
+ if (!t.marks[i].isInSet(r))
822
+ return new G(this.pos, t.marks[i]);
823
+ return new G(this.pos, this.mark);
824
+ }
825
+ }
826
+ return new pe(this.pos, this.mark);
827
+ }
828
+ map(e) {
829
+ let t = e.mapResult(this.pos, 1);
830
+ return t.deletedAfter ? null : new G(t.pos, this.mark);
831
+ }
832
+ toJSON() {
833
+ return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON() };
834
+ }
835
+ /**
836
+ @internal
837
+ */
838
+ static fromJSON(e, t) {
839
+ if (typeof t.pos != "number")
840
+ throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");
841
+ return new G(t.pos, e.markFromJSON(t.mark));
842
+ }
843
+ }
844
+ D.jsonID("addNodeMark", G);
845
+ class pe extends D {
846
+ /**
847
+ Create a mark-removing step.
848
+ */
849
+ constructor(e, t) {
850
+ super(), this.pos = e, this.mark = t;
851
+ }
852
+ apply(e) {
853
+ let t = e.nodeAt(this.pos);
854
+ if (!t)
855
+ return N.fail("No node at mark step's position");
856
+ let r = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks));
857
+ return N.fromReplace(e, this.pos, this.pos + 1, new T(C.from(r), 0, t.isLeaf ? 0 : 1));
858
+ }
859
+ invert(e) {
860
+ let t = e.nodeAt(this.pos);
861
+ return !t || !this.mark.isInSet(t.marks) ? this : new G(this.pos, this.mark);
862
+ }
863
+ map(e) {
864
+ let t = e.mapResult(this.pos, 1);
865
+ return t.deletedAfter ? null : new pe(t.pos, this.mark);
866
+ }
867
+ toJSON() {
868
+ return { stepType: "removeNodeMark", pos: this.pos, mark: this.mark.toJSON() };
869
+ }
870
+ /**
871
+ @internal
872
+ */
873
+ static fromJSON(e, t) {
874
+ if (typeof t.pos != "number")
875
+ throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
876
+ return new pe(t.pos, e.markFromJSON(t.mark));
877
+ }
878
+ }
879
+ D.jsonID("removeNodeMark", pe);
880
+ class H extends D {
881
+ /**
882
+ The given `slice` should fit the 'gap' between `from` and
883
+ `to`—the depths must line up, and the surrounding nodes must be
884
+ able to be joined with the open sides of the slice. When
885
+ `structure` is true, the step will fail if the content between
886
+ from and to is not just a sequence of closing and then opening
887
+ tokens (this is to guard against rebased replace steps
888
+ overwriting something they weren't supposed to).
889
+ */
890
+ constructor(e, t, r, i = !1) {
891
+ super(), this.from = e, this.to = t, this.slice = r, this.structure = i;
892
+ }
893
+ apply(e) {
894
+ return this.structure && Ve(e, this.from, this.to) ? N.fail("Structure replace would overwrite content") : N.fromReplace(e, this.from, this.to, this.slice);
895
+ }
896
+ getMap() {
897
+ return new J([this.from, this.to - this.from, this.slice.size]);
898
+ }
899
+ invert(e) {
900
+ return new H(this.from, this.from + this.slice.size, e.slice(this.from, this.to));
901
+ }
902
+ map(e) {
903
+ let t = e.mapResult(this.to, -1), r = this.from == this.to && H.MAP_BIAS < 0 ? t : e.mapResult(this.from, 1);
904
+ return r.deletedAcross && t.deletedAcross ? null : new H(r.pos, Math.max(r.pos, t.pos), this.slice, this.structure);
905
+ }
906
+ merge(e) {
907
+ if (!(e instanceof H) || e.structure || this.structure)
908
+ return null;
909
+ if (this.from + this.slice.size == e.from && !this.slice.openEnd && !e.slice.openStart) {
910
+ let t = this.slice.size + e.slice.size == 0 ? T.empty : new T(this.slice.content.append(e.slice.content), this.slice.openStart, e.slice.openEnd);
911
+ return new H(this.from, this.to + (e.to - e.from), t, this.structure);
912
+ } else if (e.to == this.from && !this.slice.openStart && !e.slice.openEnd) {
913
+ let t = this.slice.size + e.slice.size == 0 ? T.empty : new T(e.slice.content.append(this.slice.content), e.slice.openStart, this.slice.openEnd);
914
+ return new H(e.from, this.to, t, this.structure);
915
+ } else
916
+ return null;
917
+ }
918
+ toJSON() {
919
+ let e = { stepType: "replace", from: this.from, to: this.to };
920
+ return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
921
+ }
922
+ /**
923
+ @internal
924
+ */
925
+ static fromJSON(e, t) {
926
+ if (typeof t.from != "number" || typeof t.to != "number")
927
+ throw new RangeError("Invalid input for ReplaceStep.fromJSON");
928
+ return new H(t.from, t.to, T.fromJSON(e, t.slice), !!t.structure);
929
+ }
930
+ }
931
+ H.MAP_BIAS = 1;
932
+ D.jsonID("replace", H);
933
+ class ie extends D {
934
+ /**
935
+ Create a replace-around step with the given range and gap.
936
+ `insert` should be the point in the slice into which the content
937
+ of the gap should be moved. `structure` has the same meaning as
938
+ it has in the [`ReplaceStep`](https://prosemirror.net/docs/ref/#transform.ReplaceStep) class.
939
+ */
940
+ constructor(e, t, r, i, s, l, a = !1) {
941
+ super(), this.from = e, this.to = t, this.gapFrom = r, this.gapTo = i, this.slice = s, this.insert = l, this.structure = a;
942
+ }
943
+ apply(e) {
944
+ if (this.structure && (Ve(e, this.from, this.gapFrom) || Ve(e, this.gapTo, this.to)))
945
+ return N.fail("Structure gap-replace would overwrite content");
946
+ let t = e.slice(this.gapFrom, this.gapTo);
947
+ if (t.openStart || t.openEnd)
948
+ return N.fail("Gap is not a flat range");
949
+ let r = this.slice.insertAt(this.insert, t.content);
950
+ return r ? N.fromReplace(e, this.from, this.to, r) : N.fail("Content does not fit in gap");
951
+ }
952
+ getMap() {
953
+ return new J([
954
+ this.from,
955
+ this.gapFrom - this.from,
956
+ this.insert,
957
+ this.gapTo,
958
+ this.to - this.gapTo,
959
+ this.slice.size - this.insert
960
+ ]);
961
+ }
962
+ invert(e) {
963
+ let t = this.gapTo - this.gapFrom;
964
+ return new ie(this.from, this.from + this.slice.size + t, this.from + this.insert, this.from + this.insert + t, e.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
965
+ }
966
+ map(e) {
967
+ let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1), i = this.from == this.gapFrom ? t.pos : e.map(this.gapFrom, -1), s = this.to == this.gapTo ? r.pos : e.map(this.gapTo, 1);
968
+ return t.deletedAcross && r.deletedAcross || i < t.pos || s > r.pos ? null : new ie(t.pos, r.pos, i, s, this.slice, this.insert, this.structure);
969
+ }
970
+ toJSON() {
971
+ let e = {
972
+ stepType: "replaceAround",
973
+ from: this.from,
974
+ to: this.to,
975
+ gapFrom: this.gapFrom,
976
+ gapTo: this.gapTo,
977
+ insert: this.insert
978
+ };
979
+ return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
980
+ }
981
+ /**
982
+ @internal
983
+ */
984
+ static fromJSON(e, t) {
985
+ if (typeof t.from != "number" || typeof t.to != "number" || typeof t.gapFrom != "number" || typeof t.gapTo != "number" || typeof t.insert != "number")
986
+ throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
987
+ return new ie(t.from, t.to, t.gapFrom, t.gapTo, T.fromJSON(e, t.slice), t.insert, !!t.structure);
988
+ }
989
+ }
990
+ D.jsonID("replaceAround", ie);
991
+ function Ve(n, e, t) {
992
+ let r = n.resolve(e), i = t - e, s = r.depth;
993
+ for (; i > 0 && s > 0 && r.indexAfter(s) == r.node(s).childCount; )
994
+ s--, i--;
995
+ if (i > 0) {
996
+ let l = r.node(s).maybeChild(r.indexAfter(s));
997
+ for (; i > 0; ) {
998
+ if (!l || l.isLeaf)
999
+ return !0;
1000
+ l = l.firstChild, i--;
1001
+ }
1002
+ }
1003
+ return !1;
1004
+ }
1005
+ function mn(n, e, t) {
1006
+ return (e == 0 || n.canReplace(e, n.childCount)) && (t == n.childCount || n.canReplace(0, t));
1007
+ }
1008
+ function rr(n) {
1009
+ let t = n.parent.content.cutByIndex(n.startIndex, n.endIndex);
1010
+ for (let r = n.depth, i = 0, s = 0; ; --r) {
1011
+ let l = n.$from.node(r), a = n.$from.index(r) + i, c = n.$to.indexAfter(r) - s;
1012
+ if (r < n.depth && l.canReplace(a, c, t))
1013
+ return r;
1014
+ if (r == 0 || l.type.spec.isolating || !mn(l, a, c))
1015
+ break;
1016
+ a && (i = 1), c < l.childCount && (s = 1);
1017
+ }
1018
+ return null;
1019
+ }
1020
+ class he extends D {
1021
+ /**
1022
+ Construct an attribute step.
1023
+ */
1024
+ constructor(e, t, r) {
1025
+ super(), this.pos = e, this.attr = t, this.value = r;
1026
+ }
1027
+ apply(e) {
1028
+ let t = e.nodeAt(this.pos);
1029
+ if (!t)
1030
+ return N.fail("No node at attribute step's position");
1031
+ let r = /* @__PURE__ */ Object.create(null);
1032
+ for (let s in t.attrs)
1033
+ r[s] = t.attrs[s];
1034
+ r[this.attr] = this.value;
1035
+ let i = t.type.create(r, null, t.marks);
1036
+ return N.fromReplace(e, this.pos, this.pos + 1, new T(C.from(i), 0, t.isLeaf ? 0 : 1));
1037
+ }
1038
+ getMap() {
1039
+ return J.empty;
1040
+ }
1041
+ invert(e) {
1042
+ return new he(this.pos, this.attr, e.nodeAt(this.pos).attrs[this.attr]);
1043
+ }
1044
+ map(e) {
1045
+ let t = e.mapResult(this.pos, 1);
1046
+ return t.deletedAfter ? null : new he(t.pos, this.attr, this.value);
1047
+ }
1048
+ toJSON() {
1049
+ return { stepType: "attr", pos: this.pos, attr: this.attr, value: this.value };
1050
+ }
1051
+ static fromJSON(e, t) {
1052
+ if (typeof t.pos != "number" || typeof t.attr != "string")
1053
+ throw new RangeError("Invalid input for AttrStep.fromJSON");
1054
+ return new he(t.pos, t.attr, t.value);
1055
+ }
1056
+ }
1057
+ D.jsonID("attr", he);
1058
+ class Te extends D {
1059
+ /**
1060
+ Construct an attribute step.
1061
+ */
1062
+ constructor(e, t) {
1063
+ super(), this.attr = e, this.value = t;
1064
+ }
1065
+ apply(e) {
1066
+ let t = /* @__PURE__ */ Object.create(null);
1067
+ for (let i in e.attrs)
1068
+ t[i] = e.attrs[i];
1069
+ t[this.attr] = this.value;
1070
+ let r = e.type.create(t, e.content, e.marks);
1071
+ return N.ok(r);
1072
+ }
1073
+ getMap() {
1074
+ return J.empty;
1075
+ }
1076
+ invert(e) {
1077
+ return new Te(this.attr, e.attrs[this.attr]);
1078
+ }
1079
+ map(e) {
1080
+ return this;
1081
+ }
1082
+ toJSON() {
1083
+ return { stepType: "docAttr", attr: this.attr, value: this.value };
1084
+ }
1085
+ static fromJSON(e, t) {
1086
+ if (typeof t.attr != "string")
1087
+ throw new RangeError("Invalid input for DocAttrStep.fromJSON");
1088
+ return new Te(t.attr, t.value);
1089
+ }
1090
+ }
1091
+ D.jsonID("docAttr", Te);
1092
+ let me = class extends Error {
1093
+ };
1094
+ me = function n(e) {
1095
+ let t = Error.call(this, e);
1096
+ return t.__proto__ = n.prototype, t;
1097
+ };
1098
+ me.prototype = Object.create(Error.prototype);
1099
+ me.prototype.constructor = me;
1100
+ me.prototype.name = "TransformError";
1101
+ const Be = /* @__PURE__ */ Object.create(null);
1102
+ class z {
1103
+ /**
1104
+ Initialize a selection with the head and anchor and ranges. If no
1105
+ ranges are given, constructs a single range across `$anchor` and
1106
+ `$head`.
1107
+ */
1108
+ constructor(e, t, r) {
1109
+ this.$anchor = e, this.$head = t, this.ranges = r || [new gn(e.min(t), e.max(t))];
1110
+ }
1111
+ /**
1112
+ The selection's anchor, as an unresolved position.
1113
+ */
1114
+ get anchor() {
1115
+ return this.$anchor.pos;
1116
+ }
1117
+ /**
1118
+ The selection's head.
1119
+ */
1120
+ get head() {
1121
+ return this.$head.pos;
1122
+ }
1123
+ /**
1124
+ The lower bound of the selection's main range.
1125
+ */
1126
+ get from() {
1127
+ return this.$from.pos;
1128
+ }
1129
+ /**
1130
+ The upper bound of the selection's main range.
1131
+ */
1132
+ get to() {
1133
+ return this.$to.pos;
1134
+ }
1135
+ /**
1136
+ The resolved lower bound of the selection's main range.
1137
+ */
1138
+ get $from() {
1139
+ return this.ranges[0].$from;
1140
+ }
1141
+ /**
1142
+ The resolved upper bound of the selection's main range.
1143
+ */
1144
+ get $to() {
1145
+ return this.ranges[0].$to;
1146
+ }
1147
+ /**
1148
+ Indicates whether the selection contains any content.
1149
+ */
1150
+ get empty() {
1151
+ let e = this.ranges;
1152
+ for (let t = 0; t < e.length; t++)
1153
+ if (e[t].$from.pos != e[t].$to.pos)
1154
+ return !1;
1155
+ return !0;
1156
+ }
1157
+ /**
1158
+ Get the content of this selection as a slice.
1159
+ */
1160
+ content() {
1161
+ return this.$from.doc.slice(this.from, this.to, !0);
1162
+ }
1163
+ /**
1164
+ Replace the selection with a slice or, if no slice is given,
1165
+ delete the selection. Will append to the given transaction.
1166
+ */
1167
+ replace(e, t = T.empty) {
1168
+ let r = t.content.lastChild, i = null;
1169
+ for (let a = 0; a < t.openEnd; a++)
1170
+ i = r, r = r.lastChild;
1171
+ let s = e.steps.length, l = this.ranges;
1172
+ for (let a = 0; a < l.length; a++) {
1173
+ let { $from: c, $to: f } = l[a], d = e.mapping.slice(s);
1174
+ e.replaceRange(d.map(c.pos), d.map(f.pos), a ? T.empty : t), a == 0 && Et(e, s, (r ? r.isInline : i && i.isTextblock) ? -1 : 1);
1175
+ }
1176
+ }
1177
+ /**
1178
+ Replace the selection with the given node, appending the changes
1179
+ to the given transaction.
1180
+ */
1181
+ replaceWith(e, t) {
1182
+ let r = e.steps.length, i = this.ranges;
1183
+ for (let s = 0; s < i.length; s++) {
1184
+ let { $from: l, $to: a } = i[s], c = e.mapping.slice(r), f = c.map(l.pos), d = c.map(a.pos);
1185
+ s ? e.deleteRange(f, d) : (e.replaceRangeWith(f, d, t), Et(e, r, t.isInline ? -1 : 1));
1186
+ }
1187
+ }
1188
+ /**
1189
+ Find a valid cursor or leaf node selection starting at the given
1190
+ position and searching back if `dir` is negative, and forward if
1191
+ positive. When `textOnly` is true, only consider cursor
1192
+ selections. Will return null when no valid selection position is
1193
+ found.
1194
+ */
1195
+ static findFrom(e, t, r = !1) {
1196
+ let i = e.parent.inlineContent ? new $(e) : re(e.node(0), e.parent, e.pos, e.index(), t, r);
1197
+ if (i)
1198
+ return i;
1199
+ for (let s = e.depth - 1; s >= 0; s--) {
1200
+ let l = t < 0 ? re(e.node(0), e.node(s), e.before(s + 1), e.index(s), t, r) : re(e.node(0), e.node(s), e.after(s + 1), e.index(s) + 1, t, r);
1201
+ if (l)
1202
+ return l;
1203
+ }
1204
+ return null;
1205
+ }
1206
+ /**
1207
+ Find a valid cursor or leaf node selection near the given
1208
+ position. Searches forward first by default, but if `bias` is
1209
+ negative, it will search backwards first.
1210
+ */
1211
+ static near(e, t = 1) {
1212
+ return this.findFrom(e, t) || this.findFrom(e, -t) || new j(e.node(0));
1213
+ }
1214
+ /**
1215
+ Find the cursor or leaf node selection closest to the start of
1216
+ the given document. Will return an
1217
+ [`AllSelection`](https://prosemirror.net/docs/ref/#state.AllSelection) if no valid position
1218
+ exists.
1219
+ */
1220
+ static atStart(e) {
1221
+ return re(e, e, 0, 0, 1) || new j(e);
1222
+ }
1223
+ /**
1224
+ Find the cursor or leaf node selection closest to the end of the
1225
+ given document.
1226
+ */
1227
+ static atEnd(e) {
1228
+ return re(e, e, e.content.size, e.childCount, -1) || new j(e);
1229
+ }
1230
+ /**
1231
+ Deserialize the JSON representation of a selection. Must be
1232
+ implemented for custom classes (as a static class method).
1233
+ */
1234
+ static fromJSON(e, t) {
1235
+ if (!t || !t.type)
1236
+ throw new RangeError("Invalid input for Selection.fromJSON");
1237
+ let r = Be[t.type];
1238
+ if (!r)
1239
+ throw new RangeError(`No selection type ${t.type} defined`);
1240
+ return r.fromJSON(e, t);
1241
+ }
1242
+ /**
1243
+ To be able to deserialize selections from JSON, custom selection
1244
+ classes must register themselves with an ID string, so that they
1245
+ can be disambiguated. Try to pick something that's unlikely to
1246
+ clash with classes from other modules.
1247
+ */
1248
+ static jsonID(e, t) {
1249
+ if (e in Be)
1250
+ throw new RangeError("Duplicate use of selection JSON ID " + e);
1251
+ return Be[e] = t, t.prototype.jsonID = e, t;
1252
+ }
1253
+ /**
1254
+ Get a [bookmark](https://prosemirror.net/docs/ref/#state.SelectionBookmark) for this selection,
1255
+ which is a value that can be mapped without having access to a
1256
+ current document, and later resolved to a real selection for a
1257
+ given document again. (This is used mostly by the history to
1258
+ track and restore old selections.) The default implementation of
1259
+ this method just converts the selection to a text selection and
1260
+ returns the bookmark for that.
1261
+ */
1262
+ getBookmark() {
1263
+ return $.between(this.$anchor, this.$head).getBookmark();
1264
+ }
1265
+ }
1266
+ z.prototype.visible = !0;
1267
+ class gn {
1268
+ /**
1269
+ Create a range.
1270
+ */
1271
+ constructor(e, t) {
1272
+ this.$from = e, this.$to = t;
1273
+ }
1274
+ }
1275
+ let It = !1;
1276
+ function St(n) {
1277
+ !It && !n.parent.inlineContent && (It = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + n.parent.type.name + ")"));
1278
+ }
1279
+ class $ extends z {
1280
+ /**
1281
+ Construct a text selection between the given points.
1282
+ */
1283
+ constructor(e, t = e) {
1284
+ St(e), St(t), super(e, t);
1285
+ }
1286
+ /**
1287
+ Returns a resolved position if this is a cursor selection (an
1288
+ empty text selection), and null otherwise.
1289
+ */
1290
+ get $cursor() {
1291
+ return this.$anchor.pos == this.$head.pos ? this.$head : null;
1292
+ }
1293
+ map(e, t) {
1294
+ let r = e.resolve(t.map(this.head));
1295
+ if (!r.parent.inlineContent)
1296
+ return z.near(r);
1297
+ let i = e.resolve(t.map(this.anchor));
1298
+ return new $(i.parent.inlineContent ? i : r, r);
1299
+ }
1300
+ replace(e, t = T.empty) {
1301
+ if (super.replace(e, t), t == T.empty) {
1302
+ let r = this.$from.marksAcross(this.$to);
1303
+ r && e.ensureMarks(r);
1304
+ }
1305
+ }
1306
+ eq(e) {
1307
+ return e instanceof $ && e.anchor == this.anchor && e.head == this.head;
1308
+ }
1309
+ getBookmark() {
1310
+ return new Re(this.anchor, this.head);
1311
+ }
1312
+ toJSON() {
1313
+ return { type: "text", anchor: this.anchor, head: this.head };
1314
+ }
1315
+ /**
1316
+ @internal
1317
+ */
1318
+ static fromJSON(e, t) {
1319
+ if (typeof t.anchor != "number" || typeof t.head != "number")
1320
+ throw new RangeError("Invalid input for TextSelection.fromJSON");
1321
+ return new $(e.resolve(t.anchor), e.resolve(t.head));
1322
+ }
1323
+ /**
1324
+ Create a text selection from non-resolved positions.
1325
+ */
1326
+ static create(e, t, r = t) {
1327
+ let i = e.resolve(t);
1328
+ return new this(i, r == t ? i : e.resolve(r));
1329
+ }
1330
+ /**
1331
+ Return a text selection that spans the given positions or, if
1332
+ they aren't text positions, find a text selection near them.
1333
+ `bias` determines whether the method searches forward (default)
1334
+ or backwards (negative number) first. Will fall back to calling
1335
+ [`Selection.near`](https://prosemirror.net/docs/ref/#state.Selection^near) when the document
1336
+ doesn't contain a valid text position.
1337
+ */
1338
+ static between(e, t, r) {
1339
+ let i = e.pos - t.pos;
1340
+ if ((!r || i) && (r = i >= 0 ? 1 : -1), !t.parent.inlineContent) {
1341
+ let s = z.findFrom(t, r, !0) || z.findFrom(t, -r, !0);
1342
+ if (s)
1343
+ t = s.$head;
1344
+ else
1345
+ return z.near(t, r);
1346
+ }
1347
+ return e.parent.inlineContent || (i == 0 ? e = t : (e = (z.findFrom(e, -r, !0) || z.findFrom(e, r, !0)).$anchor, e.pos < t.pos != i < 0 && (e = t))), new $(e, t);
1348
+ }
1349
+ }
1350
+ z.jsonID("text", $);
1351
+ class Re {
1352
+ constructor(e, t) {
1353
+ this.anchor = e, this.head = t;
1354
+ }
1355
+ map(e) {
1356
+ return new Re(e.map(this.anchor), e.map(this.head));
1357
+ }
1358
+ resolve(e) {
1359
+ return $.between(e.resolve(this.anchor), e.resolve(this.head));
1360
+ }
1361
+ }
1362
+ class P extends z {
1363
+ /**
1364
+ Create a node selection. Does not verify the validity of its
1365
+ argument.
1366
+ */
1367
+ constructor(e) {
1368
+ let t = e.nodeAfter, r = e.node(0).resolve(e.pos + t.nodeSize);
1369
+ super(e, r), this.node = t;
1370
+ }
1371
+ map(e, t) {
1372
+ let { deleted: r, pos: i } = t.mapResult(this.anchor), s = e.resolve(i);
1373
+ return r ? z.near(s) : new P(s);
1374
+ }
1375
+ content() {
1376
+ return new T(C.from(this.node), 0, 0);
1377
+ }
1378
+ eq(e) {
1379
+ return e instanceof P && e.anchor == this.anchor;
1380
+ }
1381
+ toJSON() {
1382
+ return { type: "node", anchor: this.anchor };
1383
+ }
1384
+ getBookmark() {
1385
+ return new qe(this.anchor);
1386
+ }
1387
+ /**
1388
+ @internal
1389
+ */
1390
+ static fromJSON(e, t) {
1391
+ if (typeof t.anchor != "number")
1392
+ throw new RangeError("Invalid input for NodeSelection.fromJSON");
1393
+ return new P(e.resolve(t.anchor));
1394
+ }
1395
+ /**
1396
+ Create a node selection from non-resolved positions.
1397
+ */
1398
+ static create(e, t) {
1399
+ return new P(e.resolve(t));
1400
+ }
1401
+ /**
1402
+ Determines whether the given node may be selected as a node
1403
+ selection.
1404
+ */
1405
+ static isSelectable(e) {
1406
+ return !e.isText && e.type.spec.selectable !== !1;
1407
+ }
1408
+ }
1409
+ P.prototype.visible = !1;
1410
+ z.jsonID("node", P);
1411
+ class qe {
1412
+ constructor(e) {
1413
+ this.anchor = e;
1414
+ }
1415
+ map(e) {
1416
+ let { deleted: t, pos: r } = e.mapResult(this.anchor);
1417
+ return t ? new Re(r, r) : new qe(r);
1418
+ }
1419
+ resolve(e) {
1420
+ let t = e.resolve(this.anchor), r = t.nodeAfter;
1421
+ return r && P.isSelectable(r) ? new P(t) : z.near(t);
1422
+ }
1423
+ }
1424
+ class j extends z {
1425
+ /**
1426
+ Create an all-selection over the given document.
1427
+ */
1428
+ constructor(e) {
1429
+ super(e.resolve(0), e.resolve(e.content.size));
1430
+ }
1431
+ replace(e, t = T.empty) {
1432
+ if (t == T.empty) {
1433
+ e.delete(0, e.doc.content.size);
1434
+ let r = z.atStart(e.doc);
1435
+ r.eq(e.selection) || e.setSelection(r);
1436
+ } else
1437
+ super.replace(e, t);
1438
+ }
1439
+ toJSON() {
1440
+ return { type: "all" };
1441
+ }
1442
+ /**
1443
+ @internal
1444
+ */
1445
+ static fromJSON(e) {
1446
+ return new j(e);
1447
+ }
1448
+ map(e) {
1449
+ return new j(e);
1450
+ }
1451
+ eq(e) {
1452
+ return e instanceof j;
1453
+ }
1454
+ getBookmark() {
1455
+ return yn;
1456
+ }
1457
+ }
1458
+ z.jsonID("all", j);
1459
+ const yn = {
1460
+ map() {
1461
+ return this;
1462
+ },
1463
+ resolve(n) {
1464
+ return new j(n);
1465
+ }
1466
+ };
1467
+ function re(n, e, t, r, i, s = !1) {
1468
+ if (e.inlineContent)
1469
+ return $.create(n, t);
1470
+ for (let l = r - (i > 0 ? 0 : 1); i > 0 ? l < e.childCount : l >= 0; l += i) {
1471
+ let a = e.child(l);
1472
+ if (a.isAtom) {
1473
+ if (!s && P.isSelectable(a))
1474
+ return P.create(n, t - (i < 0 ? a.nodeSize : 0));
1475
+ } else {
1476
+ let c = re(n, a, t + i, i < 0 ? a.childCount : 0, i, s);
1477
+ if (c)
1478
+ return c;
1479
+ }
1480
+ t += a.nodeSize * i;
1481
+ }
1482
+ return null;
1483
+ }
1484
+ function Et(n, e, t) {
1485
+ let r = n.steps.length - 1;
1486
+ if (r < e)
1487
+ return;
1488
+ let i = n.steps[r];
1489
+ if (!(i instanceof H || i instanceof ie))
1490
+ return;
1491
+ let s = n.mapping.maps[r], l;
1492
+ s.forEach((a, c, f, d) => {
1493
+ l == null && (l = d);
1494
+ }), n.setSelection(z.near(n.doc.resolve(l), t));
1495
+ }
1496
+ function bt(n, e) {
1497
+ return !e || !n ? n : n.bind(e);
1498
+ }
1499
+ class Se {
1500
+ constructor(e, t, r) {
1501
+ this.name = e, this.init = bt(t.init, r), this.apply = bt(t.apply, r);
1502
+ }
1503
+ }
1504
+ new Se("doc", {
1505
+ init(n) {
1506
+ return n.doc || n.schema.topNodeType.createAndFill();
1507
+ },
1508
+ apply(n) {
1509
+ return n.doc;
1510
+ }
1511
+ }), new Se("selection", {
1512
+ init(n, e) {
1513
+ return n.selection || z.atStart(e.doc);
1514
+ },
1515
+ apply(n) {
1516
+ return n.selection;
1517
+ }
1518
+ }), new Se("storedMarks", {
1519
+ init(n) {
1520
+ return n.storedMarks || null;
1521
+ },
1522
+ apply(n, e, t, r) {
1523
+ return r.selection.$cursor ? n.storedMarks : null;
1524
+ }
1525
+ }), new Se("scrollToSelection", {
1526
+ init() {
1527
+ return 0;
1528
+ },
1529
+ apply(n, e) {
1530
+ return n.scrolledIntoView ? e + 1 : e;
1531
+ }
1532
+ });
1533
+ function nr(n, e, t) {
1534
+ for (let r in n) {
1535
+ let i = n[r];
1536
+ i instanceof Function ? i = i.bind(e) : r == "handleDOMEvents" && (i = nr(i, e, {})), t[r] = i;
1537
+ }
1538
+ return t;
1539
+ }
1540
+ class se {
1541
+ /**
1542
+ Create a plugin.
1543
+ */
1544
+ constructor(e) {
1545
+ this.spec = e, this.props = {}, e.props && nr(e.props, this, this.props), this.key = e.key ? e.key.key : ir("plugin");
1546
+ }
1547
+ /**
1548
+ Extract the plugin's state field from an editor state.
1549
+ */
1550
+ getState(e) {
1551
+ return e[this.key];
1552
+ }
1553
+ }
1554
+ const Fe = /* @__PURE__ */ Object.create(null);
1555
+ function ir(n) {
1556
+ return n in Fe ? n + "$" + ++Fe[n] : (Fe[n] = 0, n + "$");
1557
+ }
1558
+ class vn {
1559
+ /**
1560
+ Create a plugin key.
1561
+ */
1562
+ constructor(e = "key") {
1563
+ this.key = ir(e);
1564
+ }
1565
+ /**
1566
+ Get the active plugin with this key, if any, from an editor
1567
+ state.
1568
+ */
1569
+ get(e) {
1570
+ return e.config.pluginsByKey[this.key];
1571
+ }
1572
+ /**
1573
+ Get the plugin's state from an editor state.
1574
+ */
1575
+ getState(e) {
1576
+ return e[this.key];
1577
+ }
1578
+ }
1579
+ const sr = Zr.extend({
1580
+ addAttributes() {
1581
+ var n;
1582
+ return {
1583
+ ...(n = this.parent) == null ? void 0 : n.call(this),
1584
+ "data-note-file-id": {
1585
+ default: null,
1586
+ parseHTML: (e) => e.getAttribute("data-note-file-id"),
1587
+ renderHTML: (e) => e["data-note-file-id"] ? { "data-note-file-id": e["data-note-file-id"] } : {}
1588
+ }
1589
+ };
1590
+ },
1591
+ addProseMirrorPlugins() {
1592
+ return [
1593
+ new se({
1594
+ appendTransaction(n, e, t) {
1595
+ if (!n.some((h) => h.docChanged)) return null;
1596
+ const { selection: r } = t;
1597
+ if (!r.empty) return null;
1598
+ const { $from: i } = r;
1599
+ if (i.parent.type.name !== "paragraph" || i.parent.content.size !== 0) return null;
1600
+ const s = i.before(i.depth), l = e.selection.$from;
1601
+ if (l.depth < 1) return null;
1602
+ const a = l.before(l.depth);
1603
+ if (s !== a) return null;
1604
+ const c = e.doc.nodeAt(s);
1605
+ if (!c || c.type.name !== "paragraph") return null;
1606
+ let f = !1;
1607
+ if (c.forEach((h) => {
1608
+ h.marks.some((g) => g.type.name === "link") && (f = !0);
1609
+ }), !f) return null;
1610
+ const d = t.tr;
1611
+ try {
1612
+ d.join(s);
1613
+ } catch {
1614
+ }
1615
+ return d.setStoredMarks([]);
1616
+ }
1617
+ })
1618
+ ];
1619
+ }
1620
+ }), wn = Bt.extend({
1621
+ // Keep name as 'paragraph' for schema compatibility
1622
+ addNodeView() {
1623
+ return ({ node: n }) => {
1624
+ const e = n.attrs.indent || 0, t = document.createElement("p");
1625
+ return t.setAttribute("data-indent", String(e)), e > 0 && (t.style.paddingLeft = `${e * 20}px`), { dom: t, contentDOM: t };
1626
+ };
1627
+ },
1628
+ // Placeholder positioning based on indent level
1629
+ addAttributes() {
1630
+ var n;
1631
+ return {
1632
+ ...(n = this.parent) == null ? void 0 : n.call(this),
1633
+ indent: {
1634
+ default: 0,
1635
+ parseHTML: (e) => parseInt(e.getAttribute("data-indent") || "0"),
1636
+ renderHTML: (e) => e.indent ? {
1637
+ "data-indent": e.indent,
1638
+ // CSS custom property for dynamic placeholder offset
1639
+ style: `--indent-level: ${e.indent};`
1640
+ } : {}
1641
+ }
1642
+ };
1643
+ }
1644
+ }), M = {
1645
+ MOBILE_BREAKPOINT: 768,
1646
+ ICON_SIZE: "24px",
1647
+ CONTROLLER_HEIGHT: "25px",
1648
+ DOT_SIZE: {
1649
+ MOBILE: 16,
1650
+ DESKTOP: 9
1651
+ },
1652
+ DOT_POSITION: {
1653
+ MOBILE: "-8px",
1654
+ DESKTOP: "-4px"
1655
+ },
1656
+ COLORS: {
1657
+ BORDER: "#6C6C6C",
1658
+ BACKGROUND: "rgba(255, 255, 255, 1)"
1659
+ },
1660
+ ICONS: {
1661
+ LEFT: "https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_left/default/20px.svg",
1662
+ CENTER: "https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_center/default/20px.svg",
1663
+ RIGHT: "https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/format_align_right/default/20px.svg"
1664
+ }
1665
+ }, Z = {
1666
+ isMobile() {
1667
+ return document.documentElement.clientWidth < M.MOBILE_BREAKPOINT;
1668
+ },
1669
+ getDotPosition() {
1670
+ return Z.isMobile() ? M.DOT_POSITION.MOBILE : M.DOT_POSITION.DESKTOP;
1671
+ },
1672
+ getDotSize() {
1673
+ return Z.isMobile() ? M.DOT_SIZE.MOBILE : M.DOT_SIZE.DESKTOP;
1674
+ },
1675
+ clearContainerBorder(n) {
1676
+ const e = n.getAttribute("style"), t = e == null ? void 0 : e.replace("border: 1px dashed #6C6C6C;", "").replace("border: 1px dashed rgb(108, 108, 108)", "");
1677
+ n.setAttribute("style", t);
1678
+ },
1679
+ removeResizeElements(n) {
1680
+ if (n.childElementCount > 3)
1681
+ for (let e = 0; e < 5; e++)
1682
+ n.removeChild(n.lastChild);
1683
+ }
1684
+ };
1685
+ class Je {
1686
+ static parseImageAttributes(e, t) {
1687
+ Object.entries(e).forEach(([r, i]) => {
1688
+ if (!(i == null || r === "wrapperStyle")) {
1689
+ if (r === "containerStyle") {
1690
+ const s = i.match(/width:\s*([0-9.]+)px/);
1691
+ s && t.setAttribute("width", s[1]);
1692
+ return;
1693
+ }
1694
+ t.setAttribute(r, i);
1695
+ }
1696
+ });
1697
+ }
1698
+ static extractWidthFromStyle(e) {
1699
+ const t = e.match(/width:\s*([0-9.]+)px/);
1700
+ return t ? (t == null ? void 0 : t.at(1)) ?? null : null;
1701
+ }
1702
+ }
1703
+ function je(n, e) {
1704
+ const { minWidth: t, maxWidth: r } = e, i = t !== void 0 ? Math.max(0, t) : 0;
1705
+ let s = Math.max(i, n);
1706
+ return r !== void 0 && s > r && (s = r), s;
1707
+ }
1708
+ class ne {
1709
+ static getContainerStyle(e, t) {
1710
+ return `${`width: ${t && t !== "0px" && t !== "0" ? t : "100%"}; height: auto; cursor: pointer;`} ${e ? "display: inline-block;" : ""}`;
1711
+ }
1712
+ static getWrapperStyle(e) {
1713
+ return e ? "display: inline-block; float: left; padding-right: 8px;" : "display: flex";
1714
+ }
1715
+ static getPositionControllerStyle(e) {
1716
+ return `
1717
+ position: absolute;
1718
+ top: 0%;
1719
+ left: 50%;
1720
+ width: ${e ? "66px" : "100px"};
1721
+ height: ${M.CONTROLLER_HEIGHT};
1722
+ z-index: 999;
1723
+ background-color: ${M.COLORS.BACKGROUND};
1724
+ border-radius: 3px;
1725
+ border: 1px solid ${M.COLORS.BORDER};
1726
+ cursor: pointer;
1727
+ transform: translate(-50%, -50%);
1728
+ justify-content: space-between;
1729
+ align-items: center;
1730
+ padding: 0 6px;
1731
+ display: none;
1732
+ `.replace(/\s+/g, " ").trim();
1733
+ }
1734
+ static getDotStyle(e) {
1735
+ const t = Z.getDotPosition(), r = Z.getDotSize(), i = [
1736
+ `top: ${t}; left: ${t}; cursor: nwse-resize;`,
1737
+ `top: ${t}; right: ${t}; cursor: nesw-resize;`,
1738
+ `bottom: ${t}; left: ${t}; cursor: nesw-resize;`,
1739
+ `bottom: ${t}; right: ${t}; cursor: nwse-resize;`
1740
+ ];
1741
+ return `
1742
+ position: absolute;
1743
+ width: ${r}px;
1744
+ height: ${r}px;
1745
+ border: 1.5px solid ${M.COLORS.BORDER};
1746
+ border-radius: 50%;
1747
+ ${i[e]}
1748
+ `.replace(/\s+/g, " ").trim();
1749
+ }
1750
+ }
1751
+ class xn {
1752
+ constructor(e, t, r) {
1753
+ b(this, "elements");
1754
+ b(this, "inline");
1755
+ b(this, "dispatchNodeView");
1756
+ this.elements = e, this.inline = t, this.dispatchNodeView = r;
1757
+ }
1758
+ createControllerIcon(e) {
1759
+ const t = document.createElement("img");
1760
+ return t.setAttribute("src", e), t.setAttribute(
1761
+ "style",
1762
+ `width: ${M.ICON_SIZE}; height: ${M.ICON_SIZE}; cursor: pointer;`
1763
+ ), t.addEventListener("mouseover", (r) => {
1764
+ r.target.style.opacity = "0.6";
1765
+ }), t.addEventListener("mouseout", (r) => {
1766
+ r.target.style.opacity = "1";
1767
+ }), t;
1768
+ }
1769
+ handleLeftClick() {
1770
+ if (!this.inline)
1771
+ this.elements.container.setAttribute(
1772
+ "style",
1773
+ `${this.elements.container.style.cssText} margin: 0 auto 0 0;`
1774
+ );
1775
+ else {
1776
+ const e = "display: inline-block; float: left; padding-right: 8px;";
1777
+ this.elements.wrapper.setAttribute("style", e), this.elements.container.setAttribute("style", e);
1778
+ }
1779
+ this.dispatchNodeView();
1780
+ }
1781
+ handleCenterClick() {
1782
+ this.elements.container.setAttribute(
1783
+ "style",
1784
+ `${this.elements.container.style.cssText} margin: 0 auto;`
1785
+ ), this.dispatchNodeView();
1786
+ }
1787
+ handleRightClick() {
1788
+ if (!this.inline)
1789
+ this.elements.container.setAttribute(
1790
+ "style",
1791
+ `${this.elements.container.style.cssText} margin: 0 0 0 auto;`
1792
+ );
1793
+ else {
1794
+ const e = "display: inline-block; float: right; padding-left: 8px;";
1795
+ this.elements.wrapper.setAttribute("style", e), this.elements.container.setAttribute("style", e);
1796
+ }
1797
+ this.dispatchNodeView();
1798
+ }
1799
+ createPositionControls() {
1800
+ const e = document.createElement("div");
1801
+ e.setAttribute("style", ne.getPositionControllerStyle(this.inline));
1802
+ const t = this.createControllerIcon(M.ICONS.LEFT);
1803
+ if (t.addEventListener("click", () => this.handleLeftClick()), e.appendChild(t), !this.inline) {
1804
+ const i = this.createControllerIcon(M.ICONS.CENTER);
1805
+ i.addEventListener("click", () => this.handleCenterClick()), e.appendChild(i);
1806
+ }
1807
+ const r = this.createControllerIcon(M.ICONS.RIGHT);
1808
+ return r.addEventListener("click", () => this.handleRightClick()), e.appendChild(r), this.elements.container.appendChild(e), this;
1809
+ }
1810
+ }
1811
+ class In {
1812
+ constructor(e, t, r = () => ({})) {
1813
+ b(this, "elements");
1814
+ b(this, "dispatchNodeView");
1815
+ b(this, "getResizeLimits");
1816
+ b(this, "state", {
1817
+ isResizing: !1,
1818
+ startX: 0,
1819
+ startWidth: 0
1820
+ });
1821
+ b(this, "handleMouseMove", (e, t) => {
1822
+ if (!this.state.isResizing) return;
1823
+ const r = t % 2 === 0 ? -(e.clientX - this.state.startX) : e.clientX - this.state.startX, i = je(this.state.startWidth + r, this.getResizeLimits());
1824
+ this.elements.container.style.width = i + "px", this.elements.img.style.width = i + "px";
1825
+ });
1826
+ b(this, "handleMouseUp", () => {
1827
+ this.state.isResizing && (this.state.isResizing = !1), this.dispatchNodeView();
1828
+ });
1829
+ b(this, "handleTouchMove", (e, t) => {
1830
+ if (!this.state.isResizing) return;
1831
+ const r = t % 2 === 0 ? -(e.touches[0].clientX - this.state.startX) : e.touches[0].clientX - this.state.startX, i = je(this.state.startWidth + r, this.getResizeLimits());
1832
+ this.elements.container.style.width = i + "px", this.elements.img.style.width = i + "px";
1833
+ });
1834
+ b(this, "handleTouchEnd", () => {
1835
+ this.state.isResizing && (this.state.isResizing = !1), this.dispatchNodeView();
1836
+ });
1837
+ this.elements = e, this.dispatchNodeView = t, this.getResizeLimits = r;
1838
+ }
1839
+ createResizeHandle(e) {
1840
+ const t = document.createElement("div");
1841
+ return t.setAttribute("style", ne.getDotStyle(e)), t.addEventListener("mousedown", (r) => {
1842
+ r.preventDefault(), this.state.isResizing = !0, this.state.startX = r.clientX, this.state.startWidth = this.elements.container.offsetWidth;
1843
+ const i = (l) => this.handleMouseMove(l, e), s = () => {
1844
+ this.handleMouseUp(), document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", s);
1845
+ };
1846
+ document.addEventListener("mousemove", i), document.addEventListener("mouseup", s);
1847
+ }), t.addEventListener(
1848
+ "touchstart",
1849
+ (r) => {
1850
+ r.cancelable && r.preventDefault(), this.state.isResizing = !0, this.state.startX = r.touches[0].clientX, this.state.startWidth = this.elements.container.offsetWidth;
1851
+ const i = (l) => this.handleTouchMove(l, e), s = () => {
1852
+ this.handleTouchEnd(), document.removeEventListener("touchmove", i), document.removeEventListener("touchend", s);
1853
+ };
1854
+ document.addEventListener("touchmove", i), document.addEventListener("touchend", s);
1855
+ },
1856
+ { passive: !1 }
1857
+ ), t;
1858
+ }
1859
+ }
1860
+ class Sn {
1861
+ constructor(e = {}) {
1862
+ b(this, "limits");
1863
+ this.limits = e;
1864
+ }
1865
+ update(e) {
1866
+ this.limits = { ...this.limits, ...e };
1867
+ }
1868
+ get() {
1869
+ return this.limits;
1870
+ }
1871
+ }
1872
+ class En {
1873
+ constructor(e, t, r = {}, i) {
1874
+ b(this, "context");
1875
+ b(this, "elements");
1876
+ b(this, "inline");
1877
+ b(this, "resizeLimitsRef");
1878
+ b(this, "resizeEventName");
1879
+ b(this, "handleResizeEvent");
1880
+ b(this, "clearContainerBorder", () => {
1881
+ Z.clearContainerBorder(this.elements.container);
1882
+ });
1883
+ b(this, "dispatchNodeView", () => {
1884
+ const { view: e, getPos: t } = this.context;
1885
+ if (typeof t == "function") {
1886
+ this.clearContainerBorder();
1887
+ const r = {
1888
+ ...this.context.node.attrs,
1889
+ width: Je.extractWidthFromStyle(this.elements.container.style.cssText) ?? this.context.node.attrs.width,
1890
+ containerStyle: `${this.elements.container.style.cssText}`,
1891
+ wrapperStyle: `${this.elements.wrapper.style.cssText}`
1892
+ };
1893
+ e.dispatch(e.state.tr.setNodeMarkup(t(), null, r));
1894
+ }
1895
+ });
1896
+ b(this, "removeResizeElements", () => {
1897
+ Z.removeResizeElements(this.elements.container);
1898
+ });
1899
+ this.context = e, this.inline = t, this.resizeLimitsRef = new Sn(r), this.resizeEventName = i, this.elements = this.createElements(), i && (this.handleResizeEvent = ((s) => {
1900
+ const l = s;
1901
+ l.detail && this.updateResizeLimits({ maxWidth: l.detail.maxWidth });
1902
+ }), window.addEventListener(i, this.handleResizeEvent));
1903
+ }
1904
+ destroy() {
1905
+ this.resizeEventName && this.handleResizeEvent && window.removeEventListener(this.resizeEventName, this.handleResizeEvent);
1906
+ }
1907
+ updateResizeLimits(e) {
1908
+ this.resizeLimitsRef.update(e);
1909
+ }
1910
+ createElements() {
1911
+ return {
1912
+ wrapper: document.createElement("div"),
1913
+ container: document.createElement("div"),
1914
+ img: document.createElement("img")
1915
+ };
1916
+ }
1917
+ setupImageAttributes() {
1918
+ Je.parseImageAttributes(this.context.node.attrs, this.elements.img);
1919
+ }
1920
+ setupDOMStructure() {
1921
+ const { wrapperStyle: e, containerStyle: t } = this.context.node.attrs;
1922
+ this.elements.wrapper.setAttribute("style", e), this.elements.wrapper.appendChild(this.elements.container), this.elements.container.setAttribute("style", t), this.elements.container.appendChild(this.elements.img);
1923
+ }
1924
+ /**
1925
+ * Applies min/max width limits to the container and image.
1926
+ * Enforces configured limits on initial render and when container style is re-applied.
1927
+ */
1928
+ applyResizeLimits() {
1929
+ const e = this.resizeLimitsRef.get();
1930
+ let t = Je.extractWidthFromStyle(this.elements.container.style.cssText);
1931
+ if (t === null) {
1932
+ const l = e.maxWidth;
1933
+ if (!l) return;
1934
+ t = l.toString();
1935
+ }
1936
+ const r = Number(t);
1937
+ if (Number.isNaN(r)) return;
1938
+ const i = je(r, e), s = `${i}px`;
1939
+ this.elements.container.style.width = s, this.elements.img.style.width = s, this.elements.img.setAttribute("width", String(i));
1940
+ }
1941
+ createPositionController() {
1942
+ new xn(
1943
+ this.elements,
1944
+ this.inline,
1945
+ this.dispatchNodeView
1946
+ ).createPositionControls();
1947
+ }
1948
+ createResizeHandler() {
1949
+ const e = new In(
1950
+ this.elements,
1951
+ this.dispatchNodeView,
1952
+ // eslint-disable-next-line prettier/prettier
1953
+ () => this.resizeLimitsRef.get()
1954
+ );
1955
+ Array.from({ length: 4 }, (t, r) => {
1956
+ const i = e.createResizeHandle(r);
1957
+ this.elements.container.appendChild(i);
1958
+ });
1959
+ }
1960
+ setupContainerClick() {
1961
+ this.elements.container.addEventListener("click", () => {
1962
+ var t;
1963
+ Z.isMobile() && ((t = document.querySelector(".ProseMirror-focused")) == null || t.blur()), this.removeResizeElements(), this.createPositionController(), this.elements.container.setAttribute(
1964
+ "style",
1965
+ `position: relative; border: 1px dashed ${M.COLORS.BORDER}; ${this.context.node.attrs.containerStyle}`
1966
+ ), this.applyResizeLimits(), this.createResizeHandler();
1967
+ });
1968
+ }
1969
+ setupContentClick() {
1970
+ document.addEventListener("click", (e) => {
1971
+ const t = e.target;
1972
+ this.elements.container.contains(t) || t.style.cssText === `width: ${M.ICON_SIZE}; height: ${M.ICON_SIZE}; cursor: pointer;` || (this.clearContainerBorder(), this.removeResizeElements());
1973
+ });
1974
+ }
1975
+ initialize() {
1976
+ this.setupDOMStructure(), this.setupImageAttributes(), this.applyResizeLimits();
1977
+ const { editable: e } = this.context.editor.options;
1978
+ return e ? (this.setupContainerClick(), this.setupContentClick(), {
1979
+ dom: this.elements.wrapper,
1980
+ destroy: () => this.destroy()
1981
+ }) : { dom: this.elements.container, destroy: () => this.destroy() };
1982
+ }
1983
+ }
1984
+ const or = "image-resize-limit-update";
1985
+ class bn {
1986
+ constructor(e) {
1987
+ b(this, "currentMaxWidth");
1988
+ b(this, "resizeTimeout");
1989
+ b(this, "rafId");
1990
+ b(this, "handleResize", () => {
1991
+ this.resizeTimeout && clearTimeout(this.resizeTimeout), this.resizeTimeout = window.setTimeout(() => {
1992
+ this.rafId && cancelAnimationFrame(this.rafId), this.rafId = requestAnimationFrame(() => {
1993
+ const e = this.measureContainerWidth();
1994
+ if (e !== this.currentMaxWidth) {
1995
+ this.currentMaxWidth = e;
1996
+ const t = new CustomEvent(or, {
1997
+ detail: { maxWidth: e }
1998
+ });
1999
+ window.dispatchEvent(t);
2000
+ }
2001
+ });
2002
+ }, 150);
2003
+ });
2004
+ this.editorElement = e, this.currentMaxWidth = this.measureContainerWidth(), window.addEventListener("resize", this.handleResize);
2005
+ }
2006
+ measureContainerWidth() {
2007
+ return this.editorElement.clientWidth;
2008
+ }
2009
+ getCurrentMaxWidth() {
2010
+ return this.currentMaxWidth;
2011
+ }
2012
+ destroy() {
2013
+ window.removeEventListener("resize", this.handleResize), this.resizeTimeout && clearTimeout(this.resizeTimeout), this.rafId && cancelAnimationFrame(this.rafId);
2014
+ }
2015
+ }
2016
+ const ar = Gr.extend({
2017
+ name: "imageResize",
2018
+ addOptions() {
2019
+ var n;
2020
+ return {
2021
+ ...(n = this.parent) == null ? void 0 : n.call(this),
2022
+ inline: !1,
2023
+ minWidth: void 0,
2024
+ maxWidth: void 0,
2025
+ allowBase64: !1
2026
+ };
2027
+ },
2028
+ onCreate() {
2029
+ const n = new bn(this.editor.view.dom);
2030
+ return this.resizeHandler = n, () => {
2031
+ n.destroy();
2032
+ };
2033
+ },
2034
+ renderHTML({ HTMLAttributes: n }) {
2035
+ const e = { ...n };
2036
+ if (n != null && n.id && (e["data-id"] = n.id), !(n != null && n.wrapperStyle))
2037
+ return ["img", e];
2038
+ const t = (n == null ? void 0 : n.width) ?? this.options.maxWidth ?? 0, r = this.options.inline, i = (n == null ? void 0 : n.containerStyle) ?? ne.getContainerStyle(r, `${t}px`), s = (n == null ? void 0 : n.wrapperStyle) ?? ne.getWrapperStyle(r);
2039
+ return ["div", { style: i }, ["div", { style: s }, ["img", e]]];
2040
+ },
2041
+ addAttributes() {
2042
+ var e;
2043
+ const n = this.options.inline;
2044
+ return {
2045
+ ...(e = this.parent) == null ? void 0 : e.call(this),
2046
+ id: {
2047
+ default: null,
2048
+ parseHTML: (t) => t.getAttribute("data-id"),
2049
+ renderHTML: (t) => t.id ? { "data-id": t.id, style: "margin-block: 10px;" } : {}
2050
+ },
2051
+ width: {
2052
+ renderHTML: (t) => t.width ? { width: t.width } : {}
2053
+ },
2054
+ containerStyle: {
2055
+ default: null,
2056
+ parseHTML: (t) => {
2057
+ const r = t.getAttribute("containerstyle");
2058
+ if (r)
2059
+ return r;
2060
+ const i = t.getAttribute("width");
2061
+ return i ? ne.getContainerStyle(n, `${i}px`) : `${t.style.cssText}`;
2062
+ },
2063
+ renderHTML: (t) => t.width ? { width: t.width } : {}
2064
+ },
2065
+ wrapperStyle: {
2066
+ default: ne.getWrapperStyle(n)
2067
+ }
2068
+ };
2069
+ },
2070
+ addNodeView() {
2071
+ return ({ node: n, editor: e, getPos: t }) => {
2072
+ var d;
2073
+ if (n.type.name !== "imageResize") {
2074
+ const h = document.createElement("img");
2075
+ return h.src = n.attrs.src, h.alt = n.attrs.alt || "", n.attrs.width && (h.width = n.attrs.width), n.attrs.height && (h.height = n.attrs.height), { dom: h };
2076
+ }
2077
+ const { inline: r, minWidth: i, maxWidth: s } = this.options, l = {
2078
+ node: n,
2079
+ editor: e,
2080
+ view: e.view,
2081
+ getPos: typeof t == "function" ? t : void 0
2082
+ }, a = {
2083
+ minWidth: i,
2084
+ maxWidth: s ?? ((d = this.resizeHandler) == null ? void 0 : d.getCurrentMaxWidth())
2085
+ }, f = new En(l, r, a, or).initialize();
2086
+ return f.dom.addEventListener("click", (h) => {
2087
+ h.preventDefault();
2088
+ const g = t();
2089
+ if (g !== void 0) {
2090
+ const { state: v, view: m } = e, I = v.tr.setSelection(P.create(v.doc, g));
2091
+ m.dispatch(I);
2092
+ }
2093
+ }), f;
2094
+ };
2095
+ },
2096
+ addCommands() {
2097
+ var n;
2098
+ return {
2099
+ ...(n = this.parent) == null ? void 0 : n.call(this),
2100
+ setResizableImage: (e) => ({ commands: t }) => t.insertContent({
2101
+ type: this.name,
2102
+ attrs: e
2103
+ })
2104
+ };
2105
+ },
2106
+ addKeyboardShortcuts() {
2107
+ return {
2108
+ Backspace: () => Tn(this.editor)
2109
+ };
2110
+ }
2111
+ }), Tn = (n) => {
2112
+ var t, r;
2113
+ const e = [];
2114
+ return n.state.doc.nodesBetween(
2115
+ n.state.selection.$from.pos,
2116
+ n.state.selection.$to.pos,
2117
+ (i) => {
2118
+ e == null || e.push(i);
2119
+ }
2120
+ ), e.length !== 1 || ((r = (t = e.at(0)) == null ? void 0 : t.type) == null ? void 0 : r.name) !== "imageResize" ? (console.log("trace 1: handled?"), !1) : (n.commands.deleteSelection(), !0);
2121
+ }, V = (n) => n === "bulletList" || n === "orderedList", Ce = (n) => n === "listItem", B = (n) => n === "paragraph" || n === "heading";
2122
+ function We(n, e) {
2123
+ for (const t of n)
2124
+ if (t(e))
2125
+ return !0;
2126
+ return !1;
2127
+ }
2128
+ function Rn(n, e) {
2129
+ for (const t of n)
2130
+ if (t(e)) return !0;
2131
+ return !1;
2132
+ }
2133
+ const Cn = ({
2134
+ editor: n,
2135
+ $from: e,
2136
+ currentNode: t
2137
+ }) => {
2138
+ const r = e.pos === e.start(), i = t.attrs.indent > 0;
2139
+ return B(t.type.name) && i && r ? n.commands.outdent() : !1;
2140
+ }, kn = ({
2141
+ state: n,
2142
+ view: e,
2143
+ $from: t,
2144
+ currentNode: r
2145
+ }) => {
2146
+ const i = r.content.size === 0, s = r.attrs.indent > 0;
2147
+ if (!(B(r.type.name) && s && i)) return !1;
2148
+ const a = t.before(t.depth), c = n.tr;
2149
+ return c.delete(a, a + r.nodeSize), e.dispatch(c), !0;
2150
+ }, On = ({
2151
+ state: n,
2152
+ view: e,
2153
+ $from: t,
2154
+ currentNode: r
2155
+ }) => {
2156
+ const i = t.pos === t.start(), s = r.content.size === 0, l = r.attrs.indent > 0, a = t.before(t.depth), c = n.doc.resolve(a).nodeBefore, f = c != null && V(c.type.name);
2157
+ if (B(r.type.name) && !l && s && i && f) {
2158
+ const h = n.tr;
2159
+ return h.delete(a, a + r.nodeSize), e.dispatch(h), !0;
2160
+ }
2161
+ return !1;
2162
+ }, Nn = (n) => {
2163
+ const { tr: e, state: t, dispatch: r } = n, { selection: i } = t, { $from: s, $to: l } = i;
2164
+ if (i.empty) return !1;
2165
+ let a = 0;
2166
+ if (t.doc.nodesBetween(s.pos, l.pos, (d) => {
2167
+ (V(d.type.name) || B(d.type.name)) && a++;
2168
+ }), a <= 1) return !1;
2169
+ const c = /* @__PURE__ */ new Set();
2170
+ let f = !1;
2171
+ return t.doc.nodesBetween(s.pos, l.pos, (d, h) => {
2172
+ var v;
2173
+ return !(V(d.type.name) || B(d.type.name)) || c.has(h) ? !0 : (c.add(h), e.setNodeAttribute(h, "indent", (((v = d.attrs) == null ? void 0 : v.indent) ?? 0) + 1), f = !0, !1);
2174
+ }), f ? (e.setMeta("addToHistory", !0), r == null || r(e), !0) : !1;
2175
+ }, Ln = (n) => {
2176
+ var f;
2177
+ const { tr: e, state: t, dispatch: r } = n, { selection: i } = t, { $from: s } = i;
2178
+ let l = null, a = null;
2179
+ for (let d = s.depth; d > 0; d--) {
2180
+ const h = s.node(d);
2181
+ if (V(h.type.name)) {
2182
+ l = { ...h, pos: s.before(d) }, a = { ...s.node(d + 1), pos: s.before(d + 1) };
2183
+ break;
2184
+ }
2185
+ }
2186
+ if (!l || !a) return !1;
2187
+ if (((f = l.content) == null ? void 0 : f.childCount) === 1 && i instanceof $) {
2188
+ const d = l.attrs.indent ?? 0;
2189
+ return e.setNodeAttribute(l.pos, "indent", d + 1), e.setMeta("addToHistory", !1), r == null || r(e), !0;
2190
+ }
2191
+ return n.chain().focus().sinkListItem("listItem").updateAttributes("bulletList", { indent: 1 }).updateAttributes("orderedList", { indent: 1 }).run(), !0;
2192
+ }, An = (n) => {
2193
+ const { tr: e, state: t, dispatch: r } = n, { selection: i } = t, { $from: s } = i, l = s.node();
2194
+ if (!(B(l.type.name) && i instanceof $)) return !1;
2195
+ const c = l.attrs.indent ?? 0;
2196
+ return e.setNodeAttribute(s.before(s.depth), "indent", c + 1), e.setMeta("addToHistory", !1), r == null || r(e), !0;
2197
+ }, Tt = ({
2198
+ state: n,
2199
+ view: e,
2200
+ $from: t,
2201
+ $to: r,
2202
+ selectionIsEmpty: i
2203
+ }) => {
2204
+ if (i) return !1;
2205
+ let s = 0;
2206
+ if (n.doc.nodesBetween(t.pos, r.pos, (h) => {
2207
+ (Ce(h.type.name) || B(h.type.name)) && s++;
2208
+ }), !(s > 1)) return !1;
2209
+ const { tr: a, doc: c } = n;
2210
+ let f = !1;
2211
+ const d = /* @__PURE__ */ new Set();
2212
+ return c.nodesBetween(t.pos, r.pos, (h, g) => {
2213
+ if (V(h.type.name) && (h.attrs.indent ?? 0) > 0) {
2214
+ if (!d.has(g)) {
2215
+ d.add(g);
2216
+ const v = h.attrs.indent ?? 0;
2217
+ a.setNodeAttribute(g, "indent", Math.max(0, v - 1)), f = !0;
2218
+ const m = n.doc.resolve(g), I = n.doc.resolve(g + h.nodeSize), A = new Xt(m, I, m.depth), L = rr(A);
2219
+ L != null && (a.lift(A, L), f = !0);
2220
+ }
2221
+ return !1;
2222
+ }
2223
+ if (B(h.type.name) && (h.attrs.indent ?? 0) > 0) {
2224
+ const v = h.attrs.indent ?? 0;
2225
+ a.setNodeAttribute(g, "indent", Math.max(0, v - 1)), f = !0;
2226
+ }
2227
+ return !0;
2228
+ }), f ? (a.setMeta("addToHistory", !0), e.dispatch(a), !0) : !1;
2229
+ }, zn = ({
2230
+ state: n,
2231
+ view: e,
2232
+ $from: t,
2233
+ $to: r,
2234
+ selectionIsEmpty: i
2235
+ }) => {
2236
+ if (i) return !1;
2237
+ let s = 0;
2238
+ if (n.doc.nodesBetween(t.pos, r.pos, (h) => {
2239
+ (Ce(h.type.name) || B(h.type.name)) && s++;
2240
+ }), !(s > 1)) return !1;
2241
+ const { tr: a, doc: c } = n;
2242
+ let f = !1;
2243
+ const d = /* @__PURE__ */ new Set();
2244
+ return c.nodesBetween(t.pos, r.pos, (h, g) => {
2245
+ if (V(h.type.name) && (h.attrs.indent ?? 0) > 0) {
2246
+ if (!d.has(g)) {
2247
+ d.add(g);
2248
+ const v = h.attrs.indent ?? 0;
2249
+ a.setNodeAttribute(g, "indent", Math.max(0, v - 1)), f = !0;
2250
+ const m = n.doc.resolve(g), I = n.doc.resolve(g + h.nodeSize), A = new Xt(m, I, m.depth), L = rr(A);
2251
+ L != null && (a.lift(A, L), f = !0);
2252
+ }
2253
+ return !1;
2254
+ }
2255
+ if (B(h.type.name) && (h.attrs.indent ?? 0) > 0) {
2256
+ const v = h.attrs.indent ?? 0;
2257
+ a.setNodeAttribute(g, "indent", Math.max(0, v - 1)), f = !0;
2258
+ }
2259
+ return !0;
2260
+ }), f ? (a.setMeta("addToHistory", !0), e.dispatch(a), !0) : !1;
2261
+ }, Mn = ({ $from: n, selectionIsEmpty: e }) => {
2262
+ var l;
2263
+ if (!e) return !1;
2264
+ let t = !1, r = !1, i = 0;
2265
+ for (let a = n.depth; a > 0; a--) {
2266
+ const c = n.node(a);
2267
+ if (V(c.type.name))
2268
+ if (!t)
2269
+ t = !0, i = ((l = c.attrs) == null ? void 0 : l.indent) ?? 0;
2270
+ else {
2271
+ r = !0;
2272
+ break;
2273
+ }
2274
+ }
2275
+ return t && !r ? i === 0 : !1;
2276
+ }, Pn = ({
2277
+ state: n,
2278
+ view: e,
2279
+ $from: t,
2280
+ currentNode: r,
2281
+ selectionIsEmpty: i
2282
+ }) => {
2283
+ if (!i || !(r.type.name === "paragraph" && r.content.size === 0)) return !1;
2284
+ const l = t.before(t.depth), a = n.doc.resolve(l).nodeBefore;
2285
+ if (!(a != null && V(a.type.name))) return !1;
2286
+ const f = n.doc.resolve(l - 1), d = n.tr.setSelection($.near(f, -1));
2287
+ return e.dispatch(d), !0;
2288
+ }, Dn = ({
2289
+ state: n,
2290
+ view: e,
2291
+ $from: t,
2292
+ $to: r,
2293
+ selectionIsEmpty: i
2294
+ }) => {
2295
+ if (i) return !1;
2296
+ let s = 0;
2297
+ if (n.doc.nodesBetween(t.pos, r.pos, (h) => {
2298
+ (Ce(h.type.name) || B(h.type.name)) && s++;
2299
+ }), !(s > 1)) return !1;
2300
+ const { tr: a, doc: c } = n;
2301
+ let f = !1;
2302
+ const d = /* @__PURE__ */ new Set();
2303
+ return c.nodesBetween(t.pos, r.pos, (h, g) => {
2304
+ if ((V(h.type.name) || B(h.type.name)) && !d.has(g)) {
2305
+ d.add(g);
2306
+ const m = h.attrs.indent ?? 0;
2307
+ return a.setNodeAttribute(g, "indent", m + 1), f = !0, !1;
2308
+ }
2309
+ return !0;
2310
+ }), f ? (a.setMeta("addToHistory", !0), e.dispatch(a), !0) : !1;
2311
+ }, _n = ({
2312
+ state: n,
2313
+ view: e,
2314
+ $from: t,
2315
+ selectionIsEmpty: r
2316
+ }) => r || t.path.some((s) => {
2317
+ var l;
2318
+ return ((l = s == null ? void 0 : s.type) == null ? void 0 : l.name) === "listItem";
2319
+ }) ? !1 : (e.dispatch(n.tr.insertText(" ")), !0), $n = ({ editor: n, currentNode: e, $from: t }) => {
2320
+ const r = e.content.size === 0, i = t.node(t.depth - 1);
2321
+ return i && Ce(i.type.name) && !r ? (n.chain().focus().indent().focus().run(), !0) : !1;
2322
+ }, Bn = ({ state: n, view: e, $from: t, currentNode: r }) => {
2323
+ const i = t.pos === t.start(), s = r.content.size === 0;
2324
+ return !i && !s ? (e.dispatch(n.tr.insertText(" ")), !0) : !1;
2325
+ };
2326
+ function He(n) {
2327
+ const { state: e, view: t } = n, { $from: r, $to: i, empty: s } = e.selection;
2328
+ return { editor: n, state: e, view: t, $from: r, $to: i, selectionIsEmpty: s, currentNode: r.node() };
2329
+ }
2330
+ const Fn = dn.create({
2331
+ name: "indent",
2332
+ addKeyboardShortcuts() {
2333
+ return {
2334
+ Enter: () => this.editor.commands._handleEnterKeyDown(),
2335
+ Tab: () => {
2336
+ const n = He(this.editor);
2337
+ return We(
2338
+ [
2339
+ Dn,
2340
+ _n,
2341
+ $n,
2342
+ Bn
2343
+ ],
2344
+ n
2345
+ ) || this.editor.commands.indent();
2346
+ },
2347
+ Backspace: () => {
2348
+ const n = He(this.editor);
2349
+ return We(
2350
+ [
2351
+ Cn,
2352
+ kn,
2353
+ On
2354
+ ],
2355
+ n
2356
+ );
2357
+ },
2358
+ "Shift-Tab": () => {
2359
+ const n = He(this.editor);
2360
+ return We(
2361
+ [
2362
+ zn,
2363
+ Pn,
2364
+ Mn
2365
+ ],
2366
+ n
2367
+ ) || this.editor.chain().outdentShiftTab().run();
2368
+ },
2369
+ Space: () => this.editor.commands._handleSpaceKeyDown()
2370
+ };
2371
+ },
2372
+ addProseMirrorPlugins() {
2373
+ return [
2374
+ new se({
2375
+ // WHY: When a paragraph/heading inside a listItem gets an indent attribute (e.g. from a
2376
+ // paste or undo), the indent belongs on the parent list node, not the text node inside it.
2377
+ // This plugin corrects that automatically on every document change.
2378
+ appendTransaction: (n, e, t) => {
2379
+ if (!n.some((s) => s.docChanged)) return null;
2380
+ let i = null;
2381
+ return t.doc.descendants((s, l) => {
2382
+ var g;
2383
+ if (!(B(s.type.name) && (((g = s == null ? void 0 : s.attrs) == null ? void 0 : g.indent) ?? 0) > 0)) return;
2384
+ const c = t.doc.resolve(l);
2385
+ if (!(c.parent.type.name === "listItem")) return;
2386
+ let d = null;
2387
+ for (let v = c.depth - 1; v > 0; v--)
2388
+ if (V(c.node(v).type.name)) {
2389
+ d = c.start(v) - 1;
2390
+ break;
2391
+ }
2392
+ if (d === null || d < 0) return;
2393
+ i || (i = t.tr);
2394
+ const h = s.attrs.indent;
2395
+ i.setNodeAttribute(l, "indent", 0), i.setNodeAttribute(d, "indent", h);
2396
+ }), i;
2397
+ }
2398
+ })
2399
+ ];
2400
+ },
2401
+ addGlobalAttributes() {
2402
+ return [
2403
+ {
2404
+ types: this.options.types ?? ["orderedList", "bulletList", "paragraph", "heading"],
2405
+ attributes: {
2406
+ indent: {
2407
+ default: 1,
2408
+ parseHTML: (n) => parseInt(n.getAttribute("data-indent") || "1", 10),
2409
+ renderHTML: (n) => n != null && n.indent ? { style: `padding-left: ${n.indent * 20}px` } : {}
2410
+ }
2411
+ }
2412
+ }
2413
+ ];
2414
+ },
2415
+ addCommands() {
2416
+ return {
2417
+ _handleEnterKeyDown: () => (n) => {
2418
+ var c;
2419
+ const { tr: e, state: t, dispatch: r } = n, { $from: i } = t.selection, s = i.node();
2420
+ if (!(((c = s == null ? void 0 : s.type) == null ? void 0 : c.name) === "paragraph" && s.attrs.indent)) return !1;
2421
+ const a = s.attrs.indent;
2422
+ return e.split(i.pos), e.setNodeAttribute(e.selection.$from.before(), "indent", a), e.scrollIntoView(), e.setMeta("addToHistory", !1), r == null || r(e), !0;
2423
+ },
2424
+ _handleSpaceKeyDown: () => () => !1,
2425
+ indent: () => (n) => Rn(
2426
+ [Nn, Ln, An],
2427
+ n
2428
+ ),
2429
+ // WHY: `outdent` is used by Backspace. It only reduces indent when the cursor
2430
+ // is at the very start of the node, preventing accidental outdenting mid-sentence.
2431
+ outdent: () => (n) => {
2432
+ const { state: e, view: t, tr: r, dispatch: i } = n, { $from: s, $to: l, empty: a } = e.selection, c = {
2433
+ editor: n.editor,
2434
+ state: e,
2435
+ view: t,
2436
+ $from: s,
2437
+ $to: l,
2438
+ selectionIsEmpty: a,
2439
+ currentNode: s.node()
2440
+ };
2441
+ if (Tt(c)) return !0;
2442
+ const f = s.node();
2443
+ if (!(B(f.type.name) && f.attrs.indent > 0) || !(s.pos === s.start())) return !1;
2444
+ const g = Math.max(0, f.attrs.indent - 1);
2445
+ return r.setNodeAttribute(s.before(s.depth), "indent", g), r.setMeta("addToHistory", !1), i == null || i(r), !0;
2446
+ },
2447
+ // WHY: `outdentShiftTab` is used by Shift+Tab. Unlike `outdent`, it reduces indent
2448
+ // regardless of where the cursor is — Shift+Tab is an explicit intent to un-indent.
2449
+ outdentShiftTab: () => (n) => {
2450
+ const { state: e, tr: t, dispatch: r } = n, { $from: i } = e.selection, s = i.node();
2451
+ if (!(B(s.type.name) && s.attrs.indent > 0)) return !1;
2452
+ const a = Math.max(0, s.attrs.indent - 1);
2453
+ return t.setNodeAttribute(i.before(i.depth), "indent", a), t.setMeta("addToHistory", !1), r == null || r(t), !0;
2454
+ },
2455
+ increaseIndent: () => ({ commands: n }) => n.indent(),
2456
+ decreaseIndent: () => (n) => {
2457
+ const { state: e, view: t } = n, { $from: r, $to: i, empty: s } = e.selection, l = {
2458
+ editor: n.editor,
2459
+ state: e,
2460
+ view: t,
2461
+ $from: r,
2462
+ $to: i,
2463
+ selectionIsEmpty: s,
2464
+ currentNode: r.node()
2465
+ };
2466
+ return Tt(l) ? !0 : n.chain().outdentShiftTab().run();
2467
+ }
2468
+ };
2469
+ }
2470
+ });
2471
+ var Jn = Pt, Wn = Dt, Hn = _t;
2472
+ const Vn = Jn.extend({
2473
+ addAttributes() {
2474
+ var n;
2475
+ return {
2476
+ ...(n = this.parent) == null ? void 0 : n.call(this),
2477
+ indent: {
2478
+ default: 0,
2479
+ // Backward compatibility (FR-030)
2480
+ parseHTML: (e) => parseInt(e.getAttribute("data-indent") || "0", 10),
2481
+ renderHTML: (e) => e.indent ? { "data-indent": e.indent } : {}
2482
+ }
2483
+ };
2484
+ },
2485
+ addNodeView() {
2486
+ return ({ node: n }) => {
2487
+ const e = n.attrs.indent || 0, t = document.createElement("ul");
2488
+ return t.setAttribute("data-indent", String(e)), e > 0 && (t.style.paddingLeft = `${e * 20}px`), { dom: t, contentDOM: t };
2489
+ };
2490
+ }
2491
+ }), jn = Hn.extend({
2492
+ addAttributes() {
2493
+ var n;
2494
+ return {
2495
+ ...(n = this.parent) == null ? void 0 : n.call(this),
2496
+ indent: {
2497
+ default: 0,
2498
+ // Backward compatibility (FR-030)
2499
+ parseHTML: (e) => parseInt(e.getAttribute("data-indent") || "0", 10),
2500
+ renderHTML: (e) => e.indent ? { "data-indent": e.indent } : {}
2501
+ }
2502
+ };
2503
+ },
2504
+ addNodeView() {
2505
+ return ({ node: n }) => {
2506
+ const e = n.attrs.indent || 0, t = document.createElement("ol");
2507
+ return t.setAttribute("data-indent", String(e)), e > 0 && (t.style.paddingLeft = `${e * 20}px`), { dom: t, contentDOM: t };
2508
+ };
2509
+ }
2510
+ }), lr = Wn.extend({
2511
+ addAttributes() {
2512
+ var n;
2513
+ return {
2514
+ ...(n = this.parent) == null ? void 0 : n.call(this),
2515
+ class: {
2516
+ default: null,
2517
+ parseHTML: (e) => e.getAttribute("class"),
2518
+ renderHTML: (e) => e.class ? { class: e.class, ...e } : {}
2519
+ },
2520
+ indent: {
2521
+ default: 0,
2522
+ // Backward compatibility (FR-030)
2523
+ parseHTML: (e) => parseInt(e.getAttribute("data-indent") || "0", 10),
2524
+ renderHTML: (e) => e.indent ? { "data-indent": e.indent } : {}
2525
+ }
2526
+ };
2527
+ }
2528
+ }), cr = ge.create({
2529
+ name: "dynamicBulletStyling",
2530
+ addProseMirrorPlugins() {
2531
+ return [
2532
+ new se({
2533
+ key: new vn("dynamicBulletStyling"),
2534
+ appendTransaction: (n, e, t) => {
2535
+ const r = t.tr;
2536
+ let i = !1;
2537
+ return t.doc.descendants((s, l) => {
2538
+ if (s.type.name === "listItem") {
2539
+ let a = 0;
2540
+ const c = t.doc.resolve(l);
2541
+ for (let f = c.depth; f > 0; f--)
2542
+ if (c.node(f).type.name === "bulletList") {
2543
+ a = 1;
2544
+ break;
2545
+ }
2546
+ a > 0 && (r.setNodeAttribute(c.pos, "[data-style]", "line-height: inherit"), i = !0);
2547
+ }
2548
+ }), i ? r : null;
2549
+ }
2550
+ })
2551
+ ];
2552
+ }
2553
+ }), Un = (n) => n === "bulletList" || n === "orderedList", qn = (n) => n === "paragraph" || n === "heading", Kn = ge.create({
2554
+ name: "listIndentIntegration",
2555
+ addProseMirrorPlugins() {
2556
+ return [
2557
+ // Indent attribute transfer plugin
2558
+ new se({
2559
+ appendTransaction: (n, e, t) => {
2560
+ if (!n.find((i) => i.docChanged))
2561
+ return null;
2562
+ let r = null;
2563
+ return t.doc.descendants((i, s) => {
2564
+ var l;
2565
+ if (qn(i.type.name) && (((l = i == null ? void 0 : i.attrs) == null ? void 0 : l.indent) ?? 0) > 0) {
2566
+ const a = t.doc.resolve(s);
2567
+ if (a.parent.type.name === "listItem") {
2568
+ let f = null;
2569
+ for (let d = a.depth - 1; d > 0; d--) {
2570
+ const h = a.node(d);
2571
+ if (Un(h.type.name)) {
2572
+ f = a.start(d) - 1;
2573
+ break;
2574
+ }
2575
+ }
2576
+ if (f !== null && f >= 0) {
2577
+ r || (r = t.tr);
2578
+ const d = i.attrs.indent;
2579
+ r.setNodeAttribute(s, "indent", 0), r.setNodeAttribute(f, "indent", d);
2580
+ }
2581
+ }
2582
+ }
2583
+ }), r;
2584
+ }
2585
+ }),
2586
+ // T088, T089, T090: Paste transformation plugin
2587
+ new se({
2588
+ props: {
2589
+ transformPastedHTML(n) {
2590
+ const e = /<p[^>]*style="[^"]*(?:padding|margin)-left:\s*(\d+)(?:px|pt|em)[^"]*"[^>]*>/gi;
2591
+ n = n.replace(e, (i, s) => `<p data-indent="${Math.floor(parseInt(s, 10) / 40)}">`);
2592
+ const t = /<ol[^>]*style="[^"]*list-style-type:\s*(upper-roman|lower-roman|upper-alpha|lower-alpha)[^"]*"[^>]*>/gi;
2593
+ n = n.replace(t, () => "<ol>");
2594
+ const r = /<li[^>]*style="[^"]*list-style-type:\s*[^;"\s]+[^"]*"[^>]*>/gi;
2595
+ return n = n.replace(r, (i) => i.replace(/list-style-type:\s*[^;"\s]+;?/gi, "")), n;
2596
+ }
2597
+ }
2598
+ })
2599
+ ];
2600
+ }
2601
+ }), dr = ge.create({
2602
+ name: "fontSize",
2603
+ addOptions() {
2604
+ return {
2605
+ types: ["textStyle"],
2606
+ getStyle: (n) => `font-size: ${n}`
2607
+ };
2608
+ },
2609
+ addGlobalAttributes() {
2610
+ return [
2611
+ {
2612
+ types: this.options.types,
2613
+ attributes: {
2614
+ fontSize: {
2615
+ default: null,
2616
+ parseHTML: (n) => n.style.fontSize.replace(/['"]+/g, ""),
2617
+ renderHTML: (n) => n.fontSize ? {
2618
+ style: this.options.getStyle(n.fontSize)
2619
+ } : {}
2620
+ }
2621
+ }
2622
+ }
2623
+ ];
2624
+ },
2625
+ addCommands() {
2626
+ return {
2627
+ setFontSize: (n) => ({ chain: e }) => e().setMark("textStyle", { fontSize: n }).run(),
2628
+ unsetFontSize: () => ({ chain: n }) => n().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run()
2629
+ };
2630
+ }
2631
+ }), ur = ge.create({
2632
+ name: "lineHeight",
2633
+ addOptions() {
2634
+ return {
2635
+ types: ["textStyle"],
2636
+ getStyle: (n) => `line-height: ${n};`
2637
+ };
2638
+ },
2639
+ addGlobalAttributes() {
2640
+ return [
2641
+ {
2642
+ types: this.options.types,
2643
+ attributes: {
2644
+ lineHeight: {
2645
+ default: null,
2646
+ parseHTML: (n) => n.style.lineHeight.replace(/['"]+/g, ""),
2647
+ renderHTML: (n) => n.lineHeight ? {
2648
+ style: this.options.getStyle(n.lineHeight)
2649
+ } : {}
2650
+ }
2651
+ }
2652
+ }
2653
+ ];
2654
+ },
2655
+ addCommands() {
2656
+ return {
2657
+ setLineHeight: (n) => ({ chain: e }) => e().setMark("textStyle", { lineHeight: n }).run(),
2658
+ unsetLineHeight: () => ({ chain: n }) => n().setMark("textStyle", { lineHeight: null }).removeEmptyTextStyle().run()
2659
+ };
2660
+ }
2661
+ }), Ti = [
2662
+ Nt,
2663
+ an,
2664
+ Lt,
2665
+ At,
2666
+ Kr,
2667
+ Yr,
2668
+ Xr,
2669
+ ar,
2670
+ sr,
2671
+ Dt,
2672
+ Qr,
2673
+ tn,
2674
+ _t,
2675
+ ln,
2676
+ rn,
2677
+ nn,
2678
+ sn,
2679
+ on,
2680
+ $t,
2681
+ en,
2682
+ Jt,
2683
+ Wt,
2684
+ Ht,
2685
+ // Missing from BASE_EXTENSIONS
2686
+ Bt,
2687
+ Ft,
2688
+ Mt,
2689
+ // Gapcursor,
2690
+ zt,
2691
+ Vt,
2692
+ lr,
2693
+ dr,
2694
+ ur,
2695
+ Pt,
2696
+ cr
2697
+ ], Ri = [
2698
+ wn,
2699
+ // CONVENTION - Replaces Paragraph with selectable indent spacing (T006-T007)
2700
+ Wt,
2701
+ Lt,
2702
+ Vt.configure({
2703
+ // T012, T091: Pause-based undo/redo granularity (FR-032, FR-033)
2704
+ // Verified: Rapid Tab presses within 500ms are grouped as single undo unit
2705
+ // This matches Google Docs behavior (spec requirement)
2706
+ newGroupDelay: 500,
2707
+ // Group operations within 500ms window
2708
+ depth: 100
2709
+ // Max undo stack depth
2710
+ }),
2711
+ // COMMENTED OUT TEMPORARILY THE GAPCURSOR FIRST BECAUSE WE DON'T NEED VISUAL EFFECT FROM GAPCUROSR AND WE DO CUSTOM IMAGES CURSOR ANYWAY. UNCOMMENT IT IF NEEDED LATER.
2712
+ // Gapcursor,
2713
+ zt,
2714
+ Ht,
2715
+ Nt,
2716
+ Mt,
2717
+ $t,
2718
+ lr,
2719
+ // T011: ListItem with indent attribute
2720
+ At,
2721
+ Ft,
2722
+ dr,
2723
+ ur,
2724
+ Vn,
2725
+ // T009: BulletList with indent attribute
2726
+ // No custom keymap, just dynamic styling
2727
+ cr,
2728
+ ar,
2729
+ Kn,
2730
+ // T029: Indent attribute transfer (FR-020, FR-021, FR-023)
2731
+ Jt.configure({
2732
+ types: ["heading", "paragraph"]
2733
+ }),
2734
+ jn.configure({
2735
+ // T010: OrderedList with indent attribute
2736
+ itemTypeName: "listItem",
2737
+ keepMarks: !0,
2738
+ keepAttributes: !0
2739
+ }),
2740
+ sr,
2741
+ // Must be last to have highest keyboard shortcut priority
2742
+ Fn
2743
+ ], Ci = ge.create({
2744
+ name: "MentionStorage",
2745
+ addStorage() {
2746
+ return {
2747
+ suggestions: []
2748
+ };
2749
+ }
2750
+ });
2751
+ var te = {}, Rt;
2752
+ function Yn() {
2753
+ if (Rt) return te;
2754
+ Rt = 1;
2755
+ var n = un;
2756
+ if (process.env.NODE_ENV === "production")
2757
+ te.createRoot = n.createRoot, te.hydrateRoot = n.hydrateRoot;
2758
+ else {
2759
+ var e = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2760
+ te.createRoot = function(t, r) {
2761
+ e.usingClientEntryPoint = !0;
2762
+ try {
2763
+ return n.createRoot(t, r);
2764
+ } finally {
2765
+ e.usingClientEntryPoint = !1;
2766
+ }
2767
+ }, te.hydrateRoot = function(t, r, i) {
2768
+ e.usingClientEntryPoint = !0;
2769
+ try {
2770
+ return n.hydrateRoot(t, r, i);
2771
+ } finally {
2772
+ e.usingClientEntryPoint = !1;
2773
+ }
2774
+ };
2775
+ }
2776
+ return te;
2777
+ }
2778
+ var Xn = Yn(), Ee = { exports: {} }, ce = {};
2779
+ /**
2780
+ * @license React
2781
+ * react-jsx-runtime.production.min.js
2782
+ *
2783
+ * Copyright (c) Facebook, Inc. and its affiliates.
2784
+ *
2785
+ * This source code is licensed under the MIT license found in the
2786
+ * LICENSE file in the root directory of this source tree.
2787
+ */
2788
+ var Ct;
2789
+ function Gn() {
2790
+ if (Ct) return ce;
2791
+ Ct = 1;
2792
+ var n = jt, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, i = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
2793
+ function l(a, c, f) {
2794
+ var d, h = {}, g = null, v = null;
2795
+ f !== void 0 && (g = "" + f), c.key !== void 0 && (g = "" + c.key), c.ref !== void 0 && (v = c.ref);
2796
+ for (d in c) r.call(c, d) && !s.hasOwnProperty(d) && (h[d] = c[d]);
2797
+ if (a && a.defaultProps) for (d in c = a.defaultProps, c) h[d] === void 0 && (h[d] = c[d]);
2798
+ return { $$typeof: e, type: a, key: g, ref: v, props: h, _owner: i.current };
2799
+ }
2800
+ return ce.Fragment = t, ce.jsx = l, ce.jsxs = l, ce;
2801
+ }
2802
+ var de = {};
2803
+ /**
2804
+ * @license React
2805
+ * react-jsx-runtime.development.js
2806
+ *
2807
+ * Copyright (c) Facebook, Inc. and its affiliates.
2808
+ *
2809
+ * This source code is licensed under the MIT license found in the
2810
+ * LICENSE file in the root directory of this source tree.
2811
+ */
2812
+ var kt;
2813
+ function Zn() {
2814
+ return kt || (kt = 1, process.env.NODE_ENV !== "production" && (function() {
2815
+ var n = jt, e = Symbol.for("react.element"), t = Symbol.for("react.portal"), r = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), l = Symbol.for("react.provider"), a = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), f = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), g = Symbol.for("react.lazy"), v = Symbol.for("react.offscreen"), m = Symbol.iterator, I = "@@iterator";
2816
+ function A(o) {
2817
+ if (o === null || typeof o != "object")
2818
+ return null;
2819
+ var u = m && o[m] || o[I];
2820
+ return typeof u == "function" ? u : null;
2821
+ }
2822
+ var L = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2823
+ function R(o) {
2824
+ {
2825
+ for (var u = arguments.length, p = new Array(u > 1 ? u - 1 : 0), y = 1; y < u; y++)
2826
+ p[y - 1] = arguments[y];
2827
+ oe("error", o, p);
2828
+ }
2829
+ }
2830
+ function oe(o, u, p) {
2831
+ {
2832
+ var y = L.ReactDebugCurrentFrame, S = y.getStackAddendum();
2833
+ S !== "" && (u += "%s", p = p.concat([S]));
2834
+ var E = p.map(function(x) {
2835
+ return String(x);
2836
+ });
2837
+ E.unshift("Warning: " + u), Function.prototype.apply.call(console[o], console, E);
2838
+ }
2839
+ }
2840
+ var fr = !1, hr = !1, pr = !1, mr = !1, gr = !1, Ke;
2841
+ Ke = Symbol.for("react.module.reference");
2842
+ function yr(o) {
2843
+ return !!(typeof o == "string" || typeof o == "function" || o === r || o === s || gr || o === i || o === f || o === d || mr || o === v || fr || hr || pr || typeof o == "object" && o !== null && (o.$$typeof === g || o.$$typeof === h || o.$$typeof === l || o.$$typeof === a || o.$$typeof === c || // This needs to include all possible module reference object
2844
+ // types supported by any Flight configuration anywhere since
2845
+ // we don't know which Flight build this will end up being used
2846
+ // with.
2847
+ o.$$typeof === Ke || o.getModuleId !== void 0));
2848
+ }
2849
+ function vr(o, u, p) {
2850
+ var y = o.displayName;
2851
+ if (y)
2852
+ return y;
2853
+ var S = u.displayName || u.name || "";
2854
+ return S !== "" ? p + "(" + S + ")" : p;
2855
+ }
2856
+ function Ye(o) {
2857
+ return o.displayName || "Context";
2858
+ }
2859
+ function U(o) {
2860
+ if (o == null)
2861
+ return null;
2862
+ if (typeof o.tag == "number" && R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof o == "function")
2863
+ return o.displayName || o.name || null;
2864
+ if (typeof o == "string")
2865
+ return o;
2866
+ switch (o) {
2867
+ case r:
2868
+ return "Fragment";
2869
+ case t:
2870
+ return "Portal";
2871
+ case s:
2872
+ return "Profiler";
2873
+ case i:
2874
+ return "StrictMode";
2875
+ case f:
2876
+ return "Suspense";
2877
+ case d:
2878
+ return "SuspenseList";
2879
+ }
2880
+ if (typeof o == "object")
2881
+ switch (o.$$typeof) {
2882
+ case a:
2883
+ var u = o;
2884
+ return Ye(u) + ".Consumer";
2885
+ case l:
2886
+ var p = o;
2887
+ return Ye(p._context) + ".Provider";
2888
+ case c:
2889
+ return vr(o, o.render, "ForwardRef");
2890
+ case h:
2891
+ var y = o.displayName || null;
2892
+ return y !== null ? y : U(o.type) || "Memo";
2893
+ case g: {
2894
+ var S = o, E = S._payload, x = S._init;
2895
+ try {
2896
+ return U(x(E));
2897
+ } catch {
2898
+ return null;
2899
+ }
2900
+ }
2901
+ }
2902
+ return null;
2903
+ }
2904
+ var q = Object.assign, ae = 0, Xe, Ge, Ze, Qe, et, tt, rt;
2905
+ function nt() {
2906
+ }
2907
+ nt.__reactDisabledLog = !0;
2908
+ function wr() {
2909
+ {
2910
+ if (ae === 0) {
2911
+ Xe = console.log, Ge = console.info, Ze = console.warn, Qe = console.error, et = console.group, tt = console.groupCollapsed, rt = console.groupEnd;
2912
+ var o = {
2913
+ configurable: !0,
2914
+ enumerable: !0,
2915
+ value: nt,
2916
+ writable: !0
2917
+ };
2918
+ Object.defineProperties(console, {
2919
+ info: o,
2920
+ log: o,
2921
+ warn: o,
2922
+ error: o,
2923
+ group: o,
2924
+ groupCollapsed: o,
2925
+ groupEnd: o
2926
+ });
2927
+ }
2928
+ ae++;
2929
+ }
2930
+ }
2931
+ function xr() {
2932
+ {
2933
+ if (ae--, ae === 0) {
2934
+ var o = {
2935
+ configurable: !0,
2936
+ enumerable: !0,
2937
+ writable: !0
2938
+ };
2939
+ Object.defineProperties(console, {
2940
+ log: q({}, o, {
2941
+ value: Xe
2942
+ }),
2943
+ info: q({}, o, {
2944
+ value: Ge
2945
+ }),
2946
+ warn: q({}, o, {
2947
+ value: Ze
2948
+ }),
2949
+ error: q({}, o, {
2950
+ value: Qe
2951
+ }),
2952
+ group: q({}, o, {
2953
+ value: et
2954
+ }),
2955
+ groupCollapsed: q({}, o, {
2956
+ value: tt
2957
+ }),
2958
+ groupEnd: q({}, o, {
2959
+ value: rt
2960
+ })
2961
+ });
2962
+ }
2963
+ ae < 0 && R("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
2964
+ }
2965
+ }
2966
+ var ke = L.ReactCurrentDispatcher, Oe;
2967
+ function ye(o, u, p) {
2968
+ {
2969
+ if (Oe === void 0)
2970
+ try {
2971
+ throw Error();
2972
+ } catch (S) {
2973
+ var y = S.stack.trim().match(/\n( *(at )?)/);
2974
+ Oe = y && y[1] || "";
2975
+ }
2976
+ return `
2977
+ ` + Oe + o;
2978
+ }
2979
+ }
2980
+ var Ne = !1, ve;
2981
+ {
2982
+ var Ir = typeof WeakMap == "function" ? WeakMap : Map;
2983
+ ve = new Ir();
2984
+ }
2985
+ function it(o, u) {
2986
+ if (!o || Ne)
2987
+ return "";
2988
+ {
2989
+ var p = ve.get(o);
2990
+ if (p !== void 0)
2991
+ return p;
2992
+ }
2993
+ var y;
2994
+ Ne = !0;
2995
+ var S = Error.prepareStackTrace;
2996
+ Error.prepareStackTrace = void 0;
2997
+ var E;
2998
+ E = ke.current, ke.current = null, wr();
2999
+ try {
3000
+ if (u) {
3001
+ var x = function() {
3002
+ throw Error();
3003
+ };
3004
+ if (Object.defineProperty(x.prototype, "props", {
3005
+ set: function() {
3006
+ throw Error();
3007
+ }
3008
+ }), typeof Reflect == "object" && Reflect.construct) {
3009
+ try {
3010
+ Reflect.construct(x, []);
3011
+ } catch (F) {
3012
+ y = F;
3013
+ }
3014
+ Reflect.construct(o, [], x);
3015
+ } else {
3016
+ try {
3017
+ x.call();
3018
+ } catch (F) {
3019
+ y = F;
3020
+ }
3021
+ o.call(x.prototype);
3022
+ }
3023
+ } else {
3024
+ try {
3025
+ throw Error();
3026
+ } catch (F) {
3027
+ y = F;
3028
+ }
3029
+ o();
3030
+ }
3031
+ } catch (F) {
3032
+ if (F && y && typeof F.stack == "string") {
3033
+ for (var w = F.stack.split(`
3034
+ `), _ = y.stack.split(`
3035
+ `), k = w.length - 1, O = _.length - 1; k >= 1 && O >= 0 && w[k] !== _[O]; )
3036
+ O--;
3037
+ for (; k >= 1 && O >= 0; k--, O--)
3038
+ if (w[k] !== _[O]) {
3039
+ if (k !== 1 || O !== 1)
3040
+ do
3041
+ if (k--, O--, O < 0 || w[k] !== _[O]) {
3042
+ var W = `
3043
+ ` + w[k].replace(" at new ", " at ");
3044
+ return o.displayName && W.includes("<anonymous>") && (W = W.replace("<anonymous>", o.displayName)), typeof o == "function" && ve.set(o, W), W;
3045
+ }
3046
+ while (k >= 1 && O >= 0);
3047
+ break;
3048
+ }
3049
+ }
3050
+ } finally {
3051
+ Ne = !1, ke.current = E, xr(), Error.prepareStackTrace = S;
3052
+ }
3053
+ var ee = o ? o.displayName || o.name : "", K = ee ? ye(ee) : "";
3054
+ return typeof o == "function" && ve.set(o, K), K;
3055
+ }
3056
+ function Sr(o, u, p) {
3057
+ return it(o, !1);
3058
+ }
3059
+ function Er(o) {
3060
+ var u = o.prototype;
3061
+ return !!(u && u.isReactComponent);
3062
+ }
3063
+ function we(o, u, p) {
3064
+ if (o == null)
3065
+ return "";
3066
+ if (typeof o == "function")
3067
+ return it(o, Er(o));
3068
+ if (typeof o == "string")
3069
+ return ye(o);
3070
+ switch (o) {
3071
+ case f:
3072
+ return ye("Suspense");
3073
+ case d:
3074
+ return ye("SuspenseList");
3075
+ }
3076
+ if (typeof o == "object")
3077
+ switch (o.$$typeof) {
3078
+ case c:
3079
+ return Sr(o.render);
3080
+ case h:
3081
+ return we(o.type, u, p);
3082
+ case g: {
3083
+ var y = o, S = y._payload, E = y._init;
3084
+ try {
3085
+ return we(E(S), u, p);
3086
+ } catch {
3087
+ }
3088
+ }
3089
+ }
3090
+ return "";
3091
+ }
3092
+ var le = Object.prototype.hasOwnProperty, st = {}, ot = L.ReactDebugCurrentFrame;
3093
+ function xe(o) {
3094
+ if (o) {
3095
+ var u = o._owner, p = we(o.type, o._source, u ? u.type : null);
3096
+ ot.setExtraStackFrame(p);
3097
+ } else
3098
+ ot.setExtraStackFrame(null);
3099
+ }
3100
+ function br(o, u, p, y, S) {
3101
+ {
3102
+ var E = Function.call.bind(le);
3103
+ for (var x in o)
3104
+ if (E(o, x)) {
3105
+ var w = void 0;
3106
+ try {
3107
+ if (typeof o[x] != "function") {
3108
+ var _ = Error((y || "React class") + ": " + p + " type `" + x + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof o[x] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
3109
+ throw _.name = "Invariant Violation", _;
3110
+ }
3111
+ w = o[x](u, x, y, p, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
3112
+ } catch (k) {
3113
+ w = k;
3114
+ }
3115
+ w && !(w instanceof Error) && (xe(S), R("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", y || "React class", p, x, typeof w), xe(null)), w instanceof Error && !(w.message in st) && (st[w.message] = !0, xe(S), R("Failed %s type: %s", p, w.message), xe(null));
3116
+ }
3117
+ }
3118
+ }
3119
+ var Tr = Array.isArray;
3120
+ function Le(o) {
3121
+ return Tr(o);
3122
+ }
3123
+ function Rr(o) {
3124
+ {
3125
+ var u = typeof Symbol == "function" && Symbol.toStringTag, p = u && o[Symbol.toStringTag] || o.constructor.name || "Object";
3126
+ return p;
3127
+ }
3128
+ }
3129
+ function Cr(o) {
3130
+ try {
3131
+ return at(o), !1;
3132
+ } catch {
3133
+ return !0;
3134
+ }
3135
+ }
3136
+ function at(o) {
3137
+ return "" + o;
3138
+ }
3139
+ function lt(o) {
3140
+ if (Cr(o))
3141
+ return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Rr(o)), at(o);
3142
+ }
3143
+ var ct = L.ReactCurrentOwner, kr = {
3144
+ key: !0,
3145
+ ref: !0,
3146
+ __self: !0,
3147
+ __source: !0
3148
+ }, dt, ut;
3149
+ function Or(o) {
3150
+ if (le.call(o, "ref")) {
3151
+ var u = Object.getOwnPropertyDescriptor(o, "ref").get;
3152
+ if (u && u.isReactWarning)
3153
+ return !1;
3154
+ }
3155
+ return o.ref !== void 0;
3156
+ }
3157
+ function Nr(o) {
3158
+ if (le.call(o, "key")) {
3159
+ var u = Object.getOwnPropertyDescriptor(o, "key").get;
3160
+ if (u && u.isReactWarning)
3161
+ return !1;
3162
+ }
3163
+ return o.key !== void 0;
3164
+ }
3165
+ function Lr(o, u) {
3166
+ typeof o.ref == "string" && ct.current;
3167
+ }
3168
+ function Ar(o, u) {
3169
+ {
3170
+ var p = function() {
3171
+ dt || (dt = !0, R("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", u));
3172
+ };
3173
+ p.isReactWarning = !0, Object.defineProperty(o, "key", {
3174
+ get: p,
3175
+ configurable: !0
3176
+ });
3177
+ }
3178
+ }
3179
+ function zr(o, u) {
3180
+ {
3181
+ var p = function() {
3182
+ ut || (ut = !0, R("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", u));
3183
+ };
3184
+ p.isReactWarning = !0, Object.defineProperty(o, "ref", {
3185
+ get: p,
3186
+ configurable: !0
3187
+ });
3188
+ }
3189
+ }
3190
+ var Mr = function(o, u, p, y, S, E, x) {
3191
+ var w = {
3192
+ // This tag allows us to uniquely identify this as a React Element
3193
+ $$typeof: e,
3194
+ // Built-in properties that belong on the element
3195
+ type: o,
3196
+ key: u,
3197
+ ref: p,
3198
+ props: x,
3199
+ // Record the component responsible for creating this element.
3200
+ _owner: E
3201
+ };
3202
+ return w._store = {}, Object.defineProperty(w._store, "validated", {
3203
+ configurable: !1,
3204
+ enumerable: !1,
3205
+ writable: !0,
3206
+ value: !1
3207
+ }), Object.defineProperty(w, "_self", {
3208
+ configurable: !1,
3209
+ enumerable: !1,
3210
+ writable: !1,
3211
+ value: y
3212
+ }), Object.defineProperty(w, "_source", {
3213
+ configurable: !1,
3214
+ enumerable: !1,
3215
+ writable: !1,
3216
+ value: S
3217
+ }), Object.freeze && (Object.freeze(w.props), Object.freeze(w)), w;
3218
+ };
3219
+ function Pr(o, u, p, y, S) {
3220
+ {
3221
+ var E, x = {}, w = null, _ = null;
3222
+ p !== void 0 && (lt(p), w = "" + p), Nr(u) && (lt(u.key), w = "" + u.key), Or(u) && (_ = u.ref, Lr(u, S));
3223
+ for (E in u)
3224
+ le.call(u, E) && !kr.hasOwnProperty(E) && (x[E] = u[E]);
3225
+ if (o && o.defaultProps) {
3226
+ var k = o.defaultProps;
3227
+ for (E in k)
3228
+ x[E] === void 0 && (x[E] = k[E]);
3229
+ }
3230
+ if (w || _) {
3231
+ var O = typeof o == "function" ? o.displayName || o.name || "Unknown" : o;
3232
+ w && Ar(x, O), _ && zr(x, O);
3233
+ }
3234
+ return Mr(o, w, _, S, y, ct.current, x);
3235
+ }
3236
+ }
3237
+ var Ae = L.ReactCurrentOwner, ft = L.ReactDebugCurrentFrame;
3238
+ function Q(o) {
3239
+ if (o) {
3240
+ var u = o._owner, p = we(o.type, o._source, u ? u.type : null);
3241
+ ft.setExtraStackFrame(p);
3242
+ } else
3243
+ ft.setExtraStackFrame(null);
3244
+ }
3245
+ var ze;
3246
+ ze = !1;
3247
+ function Me(o) {
3248
+ return typeof o == "object" && o !== null && o.$$typeof === e;
3249
+ }
3250
+ function ht() {
3251
+ {
3252
+ if (Ae.current) {
3253
+ var o = U(Ae.current.type);
3254
+ if (o)
3255
+ return `
3256
+
3257
+ Check the render method of \`` + o + "`.";
3258
+ }
3259
+ return "";
3260
+ }
3261
+ }
3262
+ function Dr(o) {
3263
+ return "";
3264
+ }
3265
+ var pt = {};
3266
+ function _r(o) {
3267
+ {
3268
+ var u = ht();
3269
+ if (!u) {
3270
+ var p = typeof o == "string" ? o : o.displayName || o.name;
3271
+ p && (u = `
3272
+
3273
+ Check the top-level render call using <` + p + ">.");
3274
+ }
3275
+ return u;
3276
+ }
3277
+ }
3278
+ function mt(o, u) {
3279
+ {
3280
+ if (!o._store || o._store.validated || o.key != null)
3281
+ return;
3282
+ o._store.validated = !0;
3283
+ var p = _r(u);
3284
+ if (pt[p])
3285
+ return;
3286
+ pt[p] = !0;
3287
+ var y = "";
3288
+ o && o._owner && o._owner !== Ae.current && (y = " It was passed a child from " + U(o._owner.type) + "."), Q(o), R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', p, y), Q(null);
3289
+ }
3290
+ }
3291
+ function gt(o, u) {
3292
+ {
3293
+ if (typeof o != "object")
3294
+ return;
3295
+ if (Le(o))
3296
+ for (var p = 0; p < o.length; p++) {
3297
+ var y = o[p];
3298
+ Me(y) && mt(y, u);
3299
+ }
3300
+ else if (Me(o))
3301
+ o._store && (o._store.validated = !0);
3302
+ else if (o) {
3303
+ var S = A(o);
3304
+ if (typeof S == "function" && S !== o.entries)
3305
+ for (var E = S.call(o), x; !(x = E.next()).done; )
3306
+ Me(x.value) && mt(x.value, u);
3307
+ }
3308
+ }
3309
+ }
3310
+ function $r(o) {
3311
+ {
3312
+ var u = o.type;
3313
+ if (u == null || typeof u == "string")
3314
+ return;
3315
+ var p;
3316
+ if (typeof u == "function")
3317
+ p = u.propTypes;
3318
+ else if (typeof u == "object" && (u.$$typeof === c || // Note: Memo only checks outer props here.
3319
+ // Inner props are checked in the reconciler.
3320
+ u.$$typeof === h))
3321
+ p = u.propTypes;
3322
+ else
3323
+ return;
3324
+ if (p) {
3325
+ var y = U(u);
3326
+ br(p, o.props, "prop", y, o);
3327
+ } else if (u.PropTypes !== void 0 && !ze) {
3328
+ ze = !0;
3329
+ var S = U(u);
3330
+ R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", S || "Unknown");
3331
+ }
3332
+ typeof u.getDefaultProps == "function" && !u.getDefaultProps.isReactClassApproved && R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
3333
+ }
3334
+ }
3335
+ function Br(o) {
3336
+ {
3337
+ for (var u = Object.keys(o.props), p = 0; p < u.length; p++) {
3338
+ var y = u[p];
3339
+ if (y !== "children" && y !== "key") {
3340
+ Q(o), R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", y), Q(null);
3341
+ break;
3342
+ }
3343
+ }
3344
+ o.ref !== null && (Q(o), R("Invalid attribute `ref` supplied to `React.Fragment`."), Q(null));
3345
+ }
3346
+ }
3347
+ var yt = {};
3348
+ function vt(o, u, p, y, S, E) {
3349
+ {
3350
+ var x = yr(o);
3351
+ if (!x) {
3352
+ var w = "";
3353
+ (o === void 0 || typeof o == "object" && o !== null && Object.keys(o).length === 0) && (w += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
3354
+ var _ = Dr();
3355
+ _ ? w += _ : w += ht();
3356
+ var k;
3357
+ o === null ? k = "null" : Le(o) ? k = "array" : o !== void 0 && o.$$typeof === e ? (k = "<" + (U(o.type) || "Unknown") + " />", w = " Did you accidentally export a JSX literal instead of a component?") : k = typeof o, R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", k, w);
3358
+ }
3359
+ var O = Pr(o, u, p, S, E);
3360
+ if (O == null)
3361
+ return O;
3362
+ if (x) {
3363
+ var W = u.children;
3364
+ if (W !== void 0)
3365
+ if (y)
3366
+ if (Le(W)) {
3367
+ for (var ee = 0; ee < W.length; ee++)
3368
+ gt(W[ee], o);
3369
+ Object.freeze && Object.freeze(W);
3370
+ } else
3371
+ R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
3372
+ else
3373
+ gt(W, o);
3374
+ }
3375
+ if (le.call(u, "key")) {
3376
+ var K = U(o), F = Object.keys(u).filter(function(jr) {
3377
+ return jr !== "key";
3378
+ }), Pe = F.length > 0 ? "{key: someKey, " + F.join(": ..., ") + ": ...}" : "{key: someKey}";
3379
+ if (!yt[K + Pe]) {
3380
+ var Vr = F.length > 0 ? "{" + F.join(": ..., ") + ": ...}" : "{}";
3381
+ R(`A props object containing a "key" prop is being spread into JSX:
3382
+ let props = %s;
3383
+ <%s {...props} />
3384
+ React keys must be passed directly to JSX without using spread:
3385
+ let props = %s;
3386
+ <%s key={someKey} {...props} />`, Pe, K, Vr, K), yt[K + Pe] = !0;
3387
+ }
3388
+ }
3389
+ return o === r ? Br(O) : $r(O), O;
3390
+ }
3391
+ }
3392
+ function Fr(o, u, p) {
3393
+ return vt(o, u, p, !0);
3394
+ }
3395
+ function Jr(o, u, p) {
3396
+ return vt(o, u, p, !1);
3397
+ }
3398
+ var Wr = Jr, Hr = Fr;
3399
+ de.Fragment = r, de.jsx = Wr, de.jsxs = Hr;
3400
+ })()), de;
3401
+ }
3402
+ var Ot;
3403
+ function Qn() {
3404
+ return Ot || (Ot = 1, process.env.NODE_ENV === "production" ? Ee.exports = Gn() : Ee.exports = Zn()), Ee.exports;
3405
+ }
3406
+ var ue = Qn();
3407
+ const ei = ({
3408
+ images: n,
3409
+ onAdd: e,
3410
+ onDelete: t,
3411
+ onImageClick: r,
3412
+ focusedImageIndex: i
3413
+ }) => /* @__PURE__ */ ue.jsxs(
3414
+ "div",
3415
+ {
3416
+ className: "batch-image-gallery",
3417
+ style: { display: "flex", gap: "8px", overflowX: "auto", padding: "8px" },
3418
+ children: [
3419
+ n.map((s, l) => /* @__PURE__ */ ue.jsxs(
3420
+ "div",
3421
+ {
3422
+ style: {
3423
+ position: "relative",
3424
+ border: i === l ? "2px solid blue" : "2px solid transparent",
3425
+ cursor: "pointer"
3426
+ },
3427
+ onClick: () => r(s),
3428
+ children: [
3429
+ /* @__PURE__ */ ue.jsx(
3430
+ "img",
3431
+ {
3432
+ src: s.src,
3433
+ alt: s.alt,
3434
+ style: { width: "80px", height: "80px", objectFit: "cover" }
3435
+ }
3436
+ ),
3437
+ /* @__PURE__ */ ue.jsx(
3438
+ "button",
3439
+ {
3440
+ onClick: (a) => {
3441
+ a.stopPropagation(), t(l);
3442
+ },
3443
+ style: { position: "absolute", top: 0, right: 0 },
3444
+ children: "×"
3445
+ }
3446
+ )
3447
+ ]
3448
+ },
3449
+ s.id
3450
+ )),
3451
+ /* @__PURE__ */ ue.jsx("button", { onClick: e, style: { width: "80px", height: "80px" }, children: "+" })
3452
+ ]
3453
+ }
3454
+ );
3455
+ let fe = null;
3456
+ const ki = cn.create({
3457
+ name: "batchSegmentImages",
3458
+ group: "block",
3459
+ inline: !1,
3460
+ atom: !0,
3461
+ addOptions() {
3462
+ return {
3463
+ maxImageAmount: void 0,
3464
+ height: void 0,
3465
+ onAdd: void 0,
3466
+ onRemove: void 0,
3467
+ onImageClick: void 0,
3468
+ initialImageRegistry: void 0
3469
+ };
3470
+ },
3471
+ // Create a storage registry for this extension storage
3472
+ addStorage() {
3473
+ return {
3474
+ imageRegistry: new Map(this.options.initialImageRegistry)
3475
+ };
3476
+ },
3477
+ addAttributes() {
3478
+ return {
3479
+ batchId: {
3480
+ default: null,
3481
+ parseHTML: (n) => n.getAttribute("data-batch-id"),
3482
+ renderHTML: (n) => ({ "data-batch-id": n.batchId })
3483
+ },
3484
+ id: {
3485
+ default: null,
3486
+ parseHTML: (n) => n.getAttribute("data-id"),
3487
+ renderHTML: (n) => ({
3488
+ "data-id": n.id
3489
+ })
3490
+ },
3491
+ images: {
3492
+ default: [],
3493
+ parseHTML: (n) => {
3494
+ const e = n.querySelectorAll("img"), t = [];
3495
+ return e.forEach((r) => {
3496
+ const i = r.getAttribute("data-id"), s = r.getAttribute("src"), l = r.getAttribute("alt"), a = r.getAttribute("title");
3497
+ i && s && t.push({
3498
+ id: i,
3499
+ src: s,
3500
+ alt: l ?? void 0,
3501
+ title: a ?? void 0
3502
+ });
3503
+ }), t;
3504
+ },
3505
+ renderHTML: () => ({})
3506
+ },
3507
+ imageVersion: {
3508
+ default: 0,
3509
+ parseHTML: () => 0,
3510
+ renderHTML: () => ({})
3511
+ },
3512
+ // Ephemeral UI state — not persisted in HTML
3513
+ focusedImageIndex: {
3514
+ default: null,
3515
+ parseHTML: () => null,
3516
+ renderHTML: () => ({})
3517
+ }
3518
+ };
3519
+ },
3520
+ addProseMirrorPlugins() {
3521
+ return [
3522
+ new se({
3523
+ props: {
3524
+ handleKeyDown(n, e) {
3525
+ return e.key === "ArrowLeft" || e.key === "ArrowUp" ? fe = "left" : e.key === "ArrowRight" || e.key === "ArrowDown" ? fe = "right" : fe = null, !1;
3526
+ }
3527
+ }
3528
+ })
3529
+ ];
3530
+ },
3531
+ addKeyboardShortcuts() {
3532
+ const n = (r, i) => {
3533
+ const s = this.editor.state.tr.setNodeMarkup(r, void 0, { ...i.attrs, focusedImageIndex: null }).setMeta("addToHistory", !1);
3534
+ s.setSelection($.near(s.doc.resolve(r))), this.editor.view.dispatch(s);
3535
+ }, e = (r, i) => {
3536
+ const s = r + i.nodeSize, l = this.editor.state.tr.setNodeMarkup(r, void 0, { ...i.attrs, focusedImageIndex: null }).setMeta("addToHistory", !1);
3537
+ l.setSelection($.near(l.doc.resolve(s))), this.editor.view.dispatch(l);
3538
+ }, t = (r) => {
3539
+ var h, g;
3540
+ const { selection: i } = this.editor.state;
3541
+ if (!(i instanceof P)) return !1;
3542
+ const s = i.node;
3543
+ if (s.type.name !== "batchSegmentImages") return !1;
3544
+ const l = ((g = (h = this.editor.storage.batchSegmentImages) == null ? void 0 : h.imageRegistry) == null ? void 0 : g.get(s.attrs.batchId)) ?? s.attrs.images;
3545
+ if (!l.length) return !1;
3546
+ const a = i.from, c = s.attrs.focusedImageIndex, f = !!this.options.onAdd;
3547
+ let d;
3548
+ if (r === "right") {
3549
+ if (c === null)
3550
+ return e(a, s), !0;
3551
+ if (c < l.length - 1)
3552
+ d = c + 1;
3553
+ else if (c === l.length - 1 && f)
3554
+ d = null;
3555
+ else
3556
+ return e(a, s), !0;
3557
+ } else if (c === null)
3558
+ d = l.length - 1;
3559
+ else if (c > 0)
3560
+ d = c - 1;
3561
+ else
3562
+ return n(a, s), !0;
3563
+ if (this.editor.view.dispatch(
3564
+ this.editor.state.tr.setNodeMarkup(a, void 0, { ...s.attrs, focusedImageIndex: d }).setMeta("addToHistory", !1)
3565
+ ), d !== null && d >= 0 && d < l.length) {
3566
+ const v = this.editor.view.nodeDOM(a);
3567
+ v instanceof HTMLElement && requestAnimationFrame(() => {
3568
+ var I;
3569
+ (I = v.querySelectorAll("img")[d]) == null || I.scrollIntoView({ block: "nearest", inline: "nearest" });
3570
+ });
3571
+ }
3572
+ return !0;
3573
+ };
3574
+ return {
3575
+ ArrowLeft: () => t("left"),
3576
+ ArrowRight: () => t("right"),
3577
+ Space: () => {
3578
+ var c, f, d, h, g, v;
3579
+ const { selection: r } = this.editor.state;
3580
+ if (!(r instanceof P)) return !1;
3581
+ const i = r.node;
3582
+ if (i.type.name !== "batchSegmentImages") return !1;
3583
+ const s = ((f = (c = this.editor.storage.batchSegmentImages) == null ? void 0 : c.imageRegistry) == null ? void 0 : f.get(i.attrs.batchId)) ?? i.attrs.images, l = i.attrs.focusedImageIndex, a = r.from;
3584
+ if (l === null)
3585
+ return (h = (d = this.options).onAdd) == null || h.call(d, {
3586
+ position: "last",
3587
+ batchId: i.attrs.batchId,
3588
+ currentImages: s,
3589
+ getPos: () => a,
3590
+ editor: this.editor
3591
+ }), !0;
3592
+ if (l >= 0 && l < s.length) {
3593
+ const m = s[l];
3594
+ return (v = (g = this.options).onImageClick) == null || v.call(g, {
3595
+ imageId: m.id,
3596
+ batchId: i.attrs.batchId,
3597
+ src: m.src,
3598
+ getPos: () => a,
3599
+ editor: this.editor
3600
+ }), !0;
3601
+ }
3602
+ return !1;
3603
+ }
3604
+ };
3605
+ },
3606
+ renderHTML({ node: n }) {
3607
+ const e = n.attrs.images ?? [];
3608
+ return [
3609
+ "div",
3610
+ {
3611
+ "data-batch-id": n.attrs.batchId,
3612
+ style: "display: flex; overflow-x: auto; gap: 10px; white-space: nowrap; padding: 10px 0;"
3613
+ },
3614
+ ...e.map(
3615
+ (t) => [
3616
+ "img",
3617
+ {
3618
+ "data-id": t.id,
3619
+ src: t.src,
3620
+ alt: t.alt ?? "",
3621
+ title: t.title ?? "",
3622
+ style: "width: 80px; height: 80px; object-fit: cover; flex-shrink: 0;"
3623
+ }
3624
+ ]
3625
+ )
3626
+ ];
3627
+ },
3628
+ addNodeView() {
3629
+ return ({ node: n, getPos: e, editor: t }) => {
3630
+ const r = this.options, i = this.storage, s = document.createElement("div");
3631
+ s.style.width = "100%", s.classList.add("batch-segment-gallery"), i.imageRegistry.has(n.attrs.batchId) || i.imageRegistry.set(n.attrs.batchId, n.attrs.images ?? []);
3632
+ const l = Xn.createRoot(s), a = { current: n };
3633
+ let c = null;
3634
+ const f = () => {
3635
+ var m;
3636
+ (m = r.onAdd) == null || m.call(r, {
3637
+ position: "last",
3638
+ batchId: a.current.attrs.batchId,
3639
+ currentImages: i.imageRegistry.get(a.current.attrs.batchId) ?? [],
3640
+ getPos: e,
3641
+ editor: t
3642
+ });
3643
+ }, d = (m) => {
3644
+ var I, A;
3645
+ (A = r.onRemove) == null || A.call(r, {
3646
+ index: m,
3647
+ imageId: (I = (i.imageRegistry.get(a.current.attrs.batchId) ?? [])[m]) == null ? void 0 : I.id,
3648
+ batchId: a.current.attrs.batchId,
3649
+ getPos: e,
3650
+ editor: t
3651
+ });
3652
+ }, h = (m) => {
3653
+ var A;
3654
+ const I = e();
3655
+ if (I !== void 0) {
3656
+ const L = (i.imageRegistry.get(a.current.attrs.batchId) ?? []).findIndex((R) => R.id === m.id);
3657
+ t.view.dispatch(
3658
+ t.state.tr.setNodeMarkup(I, void 0, {
3659
+ ...a.current.attrs,
3660
+ focusedImageIndex: L
3661
+ }).setMeta("addToHistory", !1)
3662
+ );
3663
+ }
3664
+ (A = r.onImageClick) == null || A.call(r, {
3665
+ imageId: m.id,
3666
+ batchId: a.current.attrs.batchId,
3667
+ src: m.src,
3668
+ getPos: e,
3669
+ editor: t
3670
+ });
3671
+ }, g = () => {
3672
+ const [m, I] = De.useState({
3673
+ images: i.imageRegistry.get(n.attrs.batchId) ?? [],
3674
+ focusedImageIndex: n.attrs.focusedImageIndex,
3675
+ batchId: n.attrs.batchId
3676
+ });
3677
+ return c = I, De.createElement(ei, {
3678
+ batchId: m.batchId,
3679
+ images: m.images,
3680
+ maxImageAmount: r.maxImageAmount,
3681
+ height: r.height,
3682
+ focusedImageIndex: m.focusedImageIndex,
3683
+ onAdd: f,
3684
+ onDelete: d,
3685
+ onImageClick: h
3686
+ });
3687
+ };
3688
+ l.render(De.createElement(g));
3689
+ let v = n;
3690
+ return s.addEventListener("click", () => {
3691
+ const m = e();
3692
+ if (m !== void 0) {
3693
+ const { state: I, view: A } = t, L = I.doc.nodeAt(m);
3694
+ if (!L) return;
3695
+ const R = I.tr.setNodeMarkup(m, void 0, { ...L.attrs, focusedImageIndex: null }).setMeta("addToHistory", !1);
3696
+ A.dispatch(R.setSelection(P.create(R.doc, m)));
3697
+ }
3698
+ }), {
3699
+ dom: s,
3700
+ update: (m) => m.type !== n.type ? !1 : (m === v || (v = m, a.current = m, c == null || c({
3701
+ images: i.imageRegistry.get(m.attrs.batchId) ?? [],
3702
+ focusedImageIndex: m.attrs.focusedImageIndex,
3703
+ batchId: m.attrs.batchId
3704
+ })), !0),
3705
+ // selectNode fires when node becomes selected (ArrowUp/Down/Left/Right from outside).
3706
+ // Deferred via queueMicrotask — safe since selectNode is called during view.dispatch.
3707
+ selectNode: () => {
3708
+ const m = fe;
3709
+ fe = null;
3710
+ const I = e();
3711
+ if (I === void 0) return;
3712
+ const A = t.state.doc.nodeAt(I);
3713
+ if (!A || A.attrs.focusedImageIndex !== null) return;
3714
+ const L = m === "left" ? null : 0;
3715
+ queueMicrotask(() => {
3716
+ const R = e();
3717
+ if (R === void 0) return;
3718
+ const oe = t.state.doc.nodeAt(R);
3719
+ !oe || oe.attrs.focusedImageIndex !== null || t.state.selection instanceof P && t.view.dispatch(
3720
+ t.state.tr.setNodeMarkup(R, void 0, { ...oe.attrs, focusedImageIndex: L }).setMeta("addToHistory", !1)
3721
+ );
3722
+ });
3723
+ },
3724
+ deselectNode: () => {
3725
+ const m = e();
3726
+ if (m === void 0) return;
3727
+ const I = t.state.doc.nodeAt(m);
3728
+ !I || I.attrs.focusedImageIndex === null || t.view.dispatch(
3729
+ t.state.tr.setNodeMarkup(m, void 0, { ...I.attrs, focusedImageIndex: null }).setMeta("addToHistory", !1)
3730
+ );
3731
+ },
3732
+ destroy: () => {
3733
+ i.imageRegistry.delete(n.attrs.batchId), queueMicrotask(() => l.unmount());
3734
+ }
3735
+ };
3736
+ };
3737
+ },
3738
+ addCommands() {
3739
+ return {
3740
+ insertBatchImages: ({ batchId: n, images: e }) => (t) => (t.editor.storage.batchSegmentImages.imageRegistry.set(n, e), t.chain().insertContent({
3741
+ type: "batchSegmentImages",
3742
+ attrs: {
3743
+ batchId: n,
3744
+ images: e,
3745
+ id: crypto.randomUUID()
3746
+ }
3747
+ }).run())
3748
+ };
3749
+ },
3750
+ parseHTML() {
3751
+ return [
3752
+ {
3753
+ tag: "div[data-batch-id]"
3754
+ }
3755
+ ];
3756
+ }
3757
+ });
3758
+ export {
3759
+ Ti as ALL_EXTENSIONS,
3760
+ Ri as BASE_EXTENSIONS,
3761
+ ki as BatchSegmentImagesExtension,
3762
+ Li as Bold,
3763
+ Gi as BulletList,
3764
+ Is as CharacterCount,
3765
+ zi as Color,
3766
+ Vn as CustomBulletList,
3767
+ sr as CustomLink,
3768
+ lr as CustomListItem,
3769
+ jn as CustomOrderedList,
3770
+ wn as CustomParagraph,
3771
+ Pi as Document,
3772
+ cr as DynamicBulletStyling,
3773
+ Ts as Editor,
3774
+ Rs as EditorContent,
3775
+ _i as FileHandler,
3776
+ dr as FontSize,
3777
+ Bi as HardBreak,
3778
+ Ji as Heading,
3779
+ Hi as Highlight,
3780
+ Ss as History,
3781
+ ji as Image,
3782
+ ar as ImageResize,
3783
+ Fn as IndentExtension,
3784
+ qi as Italic,
3785
+ ur as LineHeight,
3786
+ Yi as Link,
3787
+ Kn as ListIndentIntegration,
3788
+ Zi as ListItem,
3789
+ Qi as ListKeymap,
3790
+ is as Mention,
3791
+ Ci as MentionStorage,
3792
+ es as OrderedList,
3793
+ os as Paragraph,
3794
+ Es as Placeholder,
3795
+ ls as Table,
3796
+ cs as TableCell,
3797
+ ds as TableHeader,
3798
+ us as TableRow,
3799
+ ts as TaskItem,
3800
+ rs as TaskList,
3801
+ hs as Text,
3802
+ ms as TextAlign,
3803
+ ys as TextStyle,
3804
+ ws as Underline,
3805
+ Cs as useEditor
3806
+ };