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