@pie-element/shared-editor-runtime 0.1.1-next.0

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