@pie-element/shared-editor-runtime 0.1.1 → 0.1.2-next.20261005220847

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
@@ -0,0 +1,719 @@
1
+ import { Gn as e, Ht as t, Kn as n, Un as r, Vn as i, Vt as a, Wn as o, it as s, nt as c, qn as l, s as u, w as d } from "./dist-CbvLhouk.js";
2
+ import { _ as f, a as p, c as m, i as h, k as g, o as _, r as v, w as y } from "./dist-Pg4oVkv2.js";
3
+ //#region ../../../node_modules/.bun/prosemirror-dropcursor@1.8.4/node_modules/prosemirror-dropcursor/dist/index.js
4
+ function b(e = {}) {
5
+ return new h({ view(t) {
6
+ return new x(t, e);
7
+ } });
8
+ }
9
+ var x = 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 = f(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
+ }, S = class e extends _ {
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) : _.near(r);
114
+ }
115
+ content() {
116
+ return g.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 C(this.anchor);
133
+ }
134
+ static valid(e) {
135
+ let t = e.parent;
136
+ if (t.inlineContent || !T(e) || !E(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 && !v.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
+ S.prototype.visible = !1, S.findFrom = S.findGapCursorFrom, _.jsonID("gapcursor", S);
174
+ var C = 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 S.valid(t) ? new S(t) : _.near(t);
184
+ }
185
+ };
186
+ function w(e) {
187
+ return e.isAtom || e.spec.isolating || e.spec.createGapCursor;
188
+ }
189
+ function T(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 || w(e.type)) return !0;
198
+ if (e.inlineContent) return !1;
199
+ }
200
+ }
201
+ return !0;
202
+ }
203
+ function E(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 || w(e.type)) return !0;
212
+ if (e.inlineContent) return !1;
213
+ }
214
+ }
215
+ return !0;
216
+ }
217
+ function D() {
218
+ return new h({ props: {
219
+ decorations: te,
220
+ createSelectionBetween(e, t, n) {
221
+ return t.pos == n.pos && S.valid(n) ? new S(n) : null;
222
+ },
223
+ handleClick: A,
224
+ handleKeyDown: O,
225
+ handleDOMEvents: { beforeinput: ee }
226
+ } });
227
+ }
228
+ var O = e({
229
+ ArrowLeft: k("horiz", -1),
230
+ ArrowRight: k("horiz", 1),
231
+ ArrowUp: k("vert", -1),
232
+ ArrowDown: k("vert", 1)
233
+ });
234
+ function k(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 m) {
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 = S.findGapCursorFrom(o, t, s);
243
+ return c ? (r && r(e.tr.setSelection(new S(c))), !0) : !1;
244
+ };
245
+ }
246
+ function A(e, t, n) {
247
+ if (!e || !e.editable) return !1;
248
+ let r = e.state.doc.resolve(t);
249
+ if (!S.valid(r)) return !1;
250
+ let i = e.posAtCoords({
251
+ left: n.clientX,
252
+ top: n.clientY
253
+ });
254
+ return i && i.inside > -1 && v.isSelectable(e.state.doc.nodeAt(i.inside)) ? !1 : (e.dispatch(e.state.tr.setSelection(new S(r))), !0);
255
+ }
256
+ function ee(e, t) {
257
+ if (t.inputType != "insertCompositionText" || !(e.state.selection instanceof S)) 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 = y.empty;
261
+ for (let e = r.length - 1; e >= 0; e--) i = y.from(r[e].createAndFill(null, i));
262
+ let a = e.state.tr.replace(n.pos, n.pos, new g(i, 0, 0));
263
+ return a.setSelection(m.near(a.doc.resolve(n.pos + 1))), e.dispatch(a), !1;
264
+ }
265
+ function te(e) {
266
+ if (!(e.selection instanceof S)) return null;
267
+ let t = document.createElement("div");
268
+ return t.className = "ProseMirror-gapcursor", l.create(e.doc, [n.widget(e.selection.head, t, { key: "gapcursor" })]);
269
+ }
270
+ //#endregion
271
+ //#region ../../../node_modules/.bun/@tiptap+extensions@3.31.4+e39601fe346c19ab/node_modules/@tiptap/extensions/dist/index.js
272
+ var ne = u.create({
273
+ name: "characterCount",
274
+ addOptions() {
275
+ return {
276
+ limit: null,
277
+ autoTrim: !0,
278
+ mode: "textSize",
279
+ textCounter: (e) => e.length,
280
+ wordCounter: (e) => e.split(" ").filter((e) => e !== "").length
281
+ };
282
+ },
283
+ addStorage() {
284
+ return {
285
+ characters: () => 0,
286
+ words: () => 0
287
+ };
288
+ },
289
+ onBeforeCreate() {
290
+ this.storage.characters = (e) => {
291
+ let t = e?.node || this.editor.state.doc;
292
+ if ((e?.mode || this.options.mode) === "textSize") {
293
+ let e = t.textBetween(0, t.content.size, void 0, " ");
294
+ return this.options.textCounter(e);
295
+ }
296
+ return t.nodeSize;
297
+ }, this.storage.words = (e) => {
298
+ let t = e?.node || this.editor.state.doc, n = t.textBetween(0, t.content.size, " ", " ");
299
+ return this.options.wordCounter(n);
300
+ };
301
+ },
302
+ addProseMirrorPlugins() {
303
+ let e = !1;
304
+ return [new h({
305
+ key: new p("characterCount"),
306
+ appendTransaction: (t, n, r) => {
307
+ if (e) return;
308
+ let i = this.options.limit, a = this.options.autoTrim;
309
+ if (i == null || i === 0 || a === !1) {
310
+ e = !0;
311
+ return;
312
+ }
313
+ let o = this.storage.characters({ node: r.doc });
314
+ if (o > i) {
315
+ let t = o - i;
316
+ console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);
317
+ let n = r.tr.deleteRange(0, t);
318
+ return e = !0, n;
319
+ }
320
+ e = !0;
321
+ },
322
+ filterTransaction: (e, t) => {
323
+ let n = this.options.limit;
324
+ if (!e.docChanged || n === 0 || n == null) return !0;
325
+ let r = this.storage.characters({ node: t.doc }), i = this.storage.characters({ node: e.doc });
326
+ if (i <= n || r > n && i > n && i <= r) return !0;
327
+ if (r > n && i > n && i > r || !e.getMeta("paste")) return !1;
328
+ let a = e.selection.$head.pos, o = a - (i - n), s = a;
329
+ return e.deleteRange(o, s), !(this.storage.characters({ node: e.doc }) > n);
330
+ }
331
+ })];
332
+ }
333
+ }), j = u.create({
334
+ name: "dropCursor",
335
+ addOptions() {
336
+ return {
337
+ color: "currentColor",
338
+ width: 1,
339
+ class: void 0
340
+ };
341
+ },
342
+ addProseMirrorPlugins() {
343
+ return [b(this.options)];
344
+ }
345
+ }), M = u.create({
346
+ name: "focus",
347
+ addOptions() {
348
+ return {
349
+ className: "has-focus",
350
+ mode: "all"
351
+ };
352
+ },
353
+ addProseMirrorPlugins() {
354
+ return [new h({
355
+ key: new p("focus"),
356
+ props: { decorations: ({ doc: e, selection: t }) => {
357
+ let { isEditable: r, isFocused: i } = this.editor, { anchor: a } = t, o = [];
358
+ if (!r || !i) return l.create(e, []);
359
+ let s = 0;
360
+ this.options.mode === "deepest" && e.descendants((e, t) => {
361
+ if (!e.isText) {
362
+ if (!(a >= t && a <= t + e.nodeSize - 1)) return !1;
363
+ s += 1;
364
+ }
365
+ });
366
+ let c = 0;
367
+ return e.descendants((e, t) => {
368
+ if (e.isText || !(a >= t && a <= t + e.nodeSize - 1)) return !1;
369
+ if (c += 1, this.options.mode === "deepest" && s - c > 0 || this.options.mode === "shallowest" && c > 1) return this.options.mode === "deepest";
370
+ o.push(n.node(t, t + e.nodeSize, { class: this.options.className }));
371
+ }), l.create(e, o);
372
+ } }
373
+ })];
374
+ }
375
+ }), N = u.create({
376
+ name: "gapCursor",
377
+ addProseMirrorPlugins() {
378
+ return [D()];
379
+ },
380
+ extendNodeSchema(e) {
381
+ return { allowGapCursor: d(s(e, "allowGapCursor", {
382
+ name: e.name,
383
+ options: e.options,
384
+ storage: e.storage
385
+ })) ?? null };
386
+ }
387
+ }), P = "placeholder", F = new p("tiptap__placeholder");
388
+ function I(e) {
389
+ let { editor: t, placeholder: r, dataAttribute: i, pos: a, node: o, isEmptyDoc: s, hasAnchor: c, classes: { emptyNode: l, emptyEditor: u } } = e, d = [l];
390
+ return s && d.push(u), n.node(a, a + o.nodeSize, {
391
+ class: d.join(" "),
392
+ [i]: typeof r == "function" ? r({
393
+ editor: t,
394
+ node: o,
395
+ pos: a,
396
+ hasAnchor: c
397
+ }) : r
398
+ });
399
+ }
400
+ function L(e, t) {
401
+ return typeof e == "function" ? e(t) : e;
402
+ }
403
+ function R({ editor: e, options: t, dataAttribute: n, doc: r, selection: i, from: o, to: s }) {
404
+ let { anchor: c } = i, l = [], u = e.isEmpty;
405
+ return r.nodesBetween(o, s, (r, i) => {
406
+ let o = c >= i && c <= i + r.nodeSize, s = !r.isLeaf && a(r);
407
+ return r.type.isTextblock && (o || !t.showOnlyCurrent) && s && l.push(I({
408
+ editor: e,
409
+ isEmptyDoc: u,
410
+ dataAttribute: n,
411
+ hasAnchor: o,
412
+ placeholder: t.placeholder,
413
+ classes: {
414
+ emptyEditor: t.emptyEditorClass,
415
+ emptyNode: L(t.emptyNodeClass, {
416
+ editor: e,
417
+ node: r,
418
+ pos: i,
419
+ hasAnchor: o
420
+ })
421
+ },
422
+ node: r,
423
+ pos: i
424
+ })), t.includeChildren;
425
+ }), l;
426
+ }
427
+ function z({ editor: e, options: t, dataAttribute: n, doc: r, selection: i }) {
428
+ if (!(e.isEditable || !t.showOnlyWhenEditable)) return null;
429
+ let { anchor: o } = i, s = [], c = e.isEmpty;
430
+ if (t.showOnlyCurrent && !t.includeChildren) {
431
+ let i = r.resolve(o), l = i.depth > 0 ? i.node(1) : i.nodeAfter, u = i.depth > 0 ? i.before(1) : o;
432
+ if (l && l.type.isTextblock && a(l)) {
433
+ let r = o >= u && o <= u + l.nodeSize;
434
+ s.push(I({
435
+ editor: e,
436
+ isEmptyDoc: c,
437
+ dataAttribute: n,
438
+ hasAnchor: r,
439
+ placeholder: t.placeholder,
440
+ classes: {
441
+ emptyEditor: t.emptyEditorClass,
442
+ emptyNode: L(t.emptyNodeClass, {
443
+ editor: e,
444
+ node: l,
445
+ pos: u,
446
+ hasAnchor: r
447
+ })
448
+ },
449
+ node: l,
450
+ pos: u
451
+ }));
452
+ }
453
+ } else s.push(...R({
454
+ editor: e,
455
+ options: t,
456
+ dataAttribute: n,
457
+ doc: r,
458
+ selection: i,
459
+ from: 0,
460
+ to: r.content.size
461
+ }));
462
+ return l.create(r, s);
463
+ }
464
+ function B(e, t) {
465
+ let n = e.resolve(t);
466
+ if (n.depth === 0) {
467
+ let e = n.nodeAfter ?? n.nodeBefore;
468
+ if (!e) return {
469
+ from: t,
470
+ to: t
471
+ };
472
+ let r = n.nodeAfter ? t : t - e.nodeSize;
473
+ return {
474
+ from: r,
475
+ to: r + e.nodeSize
476
+ };
477
+ }
478
+ let r = n.before(1);
479
+ return {
480
+ from: r,
481
+ to: r + n.node(1).nodeSize
482
+ };
483
+ }
484
+ function V(e, t) {
485
+ return {
486
+ from: Math.max(0, t.from - 1),
487
+ to: Math.min(e.content.size, t.to - 1)
488
+ };
489
+ }
490
+ function H(e, t, n) {
491
+ let r = [];
492
+ return e.forEach((e, i) => {
493
+ let a = i, o = a + e.nodeSize, s = a + 1, c = o + 1;
494
+ s < n && c > t && r.push({
495
+ from: a,
496
+ to: o
497
+ });
498
+ }), r;
499
+ }
500
+ function U(e) {
501
+ if (e.length === 0) return [];
502
+ let t = [...e].sort((e, t) => e.from - t.from), n = [{ ...t[0] }];
503
+ for (let e = 1; e < t.length; e += 1) {
504
+ let r = n[n.length - 1], i = t[e];
505
+ i.from <= r.to ? r.to = Math.max(r.to, i.to) : n.push({ ...i });
506
+ }
507
+ return n;
508
+ }
509
+ function W(e, t) {
510
+ let n = H(e, t.from, t.to);
511
+ return n.push(V(e, B(e, t.from))), t.to > t.from ? n.push(V(e, B(e, Math.min(t.to, e.content.size + 1) - 1))) : t.from < e.content.size + 1 && n.push(V(e, B(e, Math.min(t.from + 1, e.content.size)))), n;
512
+ }
513
+ function G(e, t, n) {
514
+ let r = [];
515
+ if (e.docChanged) {
516
+ let t = c(e);
517
+ for (let e of t) r.push(...W(n.doc, e.newRange));
518
+ }
519
+ return e.selectionSet && (r.push(V(n.doc, B(n.doc, e.mapping.map(t.selection.anchor)))), r.push(V(n.doc, B(n.doc, n.selection.anchor)))), U(r);
520
+ }
521
+ function K(e, t, n) {
522
+ let r = Math.max(0, Math.min(e, n.content.size));
523
+ return {
524
+ from: r,
525
+ to: Math.max(r, Math.min(t, n.content.size))
526
+ };
527
+ }
528
+ function q({ decorations: e, ranges: t, editor: n, options: r, dataAttribute: i, doc: a, selection: o }) {
529
+ let s = e;
530
+ for (let e of t) {
531
+ let { from: t, to: c } = K(e.from, e.to, a), l = s.find(t, c).filter((e) => e.from >= t && e.to <= c);
532
+ l.length && (s = s.remove(l));
533
+ let u = R({
534
+ editor: n,
535
+ options: r,
536
+ dataAttribute: i,
537
+ doc: a,
538
+ selection: o,
539
+ from: t,
540
+ to: c
541
+ });
542
+ u.length && (s = s.add(a, u));
543
+ }
544
+ return s;
545
+ }
546
+ function J({ editor: e, options: t, dataAttribute: n }) {
547
+ return {
548
+ init(r, i) {
549
+ return z({
550
+ editor: e,
551
+ options: t,
552
+ dataAttribute: n,
553
+ doc: i.doc,
554
+ selection: i.selection
555
+ }) ?? l.empty;
556
+ },
557
+ apply(r, i, a, o) {
558
+ return !r.docChanged && !r.selectionSet ? i : q({
559
+ decorations: i.map(r.mapping, r.doc),
560
+ ranges: G(r, a, o),
561
+ editor: e,
562
+ options: t,
563
+ dataAttribute: n,
564
+ doc: o.doc,
565
+ selection: o.selection
566
+ });
567
+ }
568
+ };
569
+ }
570
+ function Y(e) {
571
+ return e.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
572
+ }
573
+ function X({ editor: e, options: t }) {
574
+ let n = t.dataAttribute ? `data-${Y(t.dataAttribute)}` : `data-${P}`, r = t.showOnlyCurrent && !t.includeChildren;
575
+ return new h({
576
+ key: F,
577
+ ...r ? {} : { state: J({
578
+ editor: e,
579
+ options: t,
580
+ dataAttribute: n
581
+ }) },
582
+ props: { decorations: r ? ({ doc: r, selection: i }) => z({
583
+ editor: e,
584
+ options: t,
585
+ dataAttribute: n,
586
+ doc: r,
587
+ selection: i
588
+ }) : (n) => t.showOnlyWhenEditable && !e.isEditable ? l.empty : F.getState(n) ?? l.empty }
589
+ });
590
+ }
591
+ var re = u.create({
592
+ name: "placeholder",
593
+ addOptions() {
594
+ return {
595
+ emptyEditorClass: "is-editor-empty",
596
+ emptyNodeClass: "is-empty",
597
+ dataAttribute: P,
598
+ placeholder: "Write something …",
599
+ showOnlyWhenEditable: !0,
600
+ showOnlyCurrent: !0,
601
+ includeChildren: !1
602
+ };
603
+ },
604
+ addProseMirrorPlugins() {
605
+ return [X({
606
+ editor: this.editor,
607
+ options: this.options
608
+ })];
609
+ }
610
+ });
611
+ function Z(e, n) {
612
+ return !e.selection.empty && !t(e.selection) && n.isEditable;
613
+ }
614
+ function ie(e, t) {
615
+ return Z(e, t) && !t.isFocused && !t.view.dragging;
616
+ }
617
+ function ae() {
618
+ var e;
619
+ (e = window.getSelection()) == null || e.removeAllRanges();
620
+ }
621
+ function oe(e) {
622
+ e.focus();
623
+ }
624
+ var se = u.create({
625
+ name: "selection",
626
+ addOptions() {
627
+ return { className: "selection" };
628
+ },
629
+ addProseMirrorPlugins() {
630
+ let { editor: e, options: t } = this;
631
+ return [new h({
632
+ key: new p("selection"),
633
+ props: {
634
+ decorations(r) {
635
+ return ie(r, e) ? l.create(r.doc, [n.inline(r.selection.from, r.selection.to, { class: t.className })]) : null;
636
+ },
637
+ handleDOMEvents: {
638
+ blur(t) {
639
+ return Z(t.state, e) && ae(), !1;
640
+ },
641
+ focus(t) {
642
+ return Z(t.state, e) && requestAnimationFrame(() => {
643
+ !e.isDestroyed && t.hasFocus() && oe(t);
644
+ }), !1;
645
+ }
646
+ }
647
+ }
648
+ })];
649
+ }
650
+ }), Q = "skipTrailingNode";
651
+ function $({ types: e, node: t }) {
652
+ return t && Array.isArray(e) && e.includes(t.type) || t?.type === e;
653
+ }
654
+ var ce = u.create({
655
+ name: "trailingNode",
656
+ addOptions() {
657
+ return {
658
+ node: void 0,
659
+ notAfter: []
660
+ };
661
+ },
662
+ addProseMirrorPlugins() {
663
+ let e = new p(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));
664
+ return [new h({
665
+ key: e,
666
+ appendTransaction: (n, r, i) => {
667
+ let { doc: a, tr: o, schema: s } = i, c = e.getState(i), l = a.content.size, u = s.nodes[t];
668
+ if (!n.some((e) => e.getMeta("skipTrailingNode")) && c) return o.insert(l, u.create());
669
+ },
670
+ state: {
671
+ init: (e, t) => {
672
+ let r = t.tr.doc.lastChild;
673
+ return !$({
674
+ node: r,
675
+ types: n
676
+ });
677
+ },
678
+ apply: (e, t) => {
679
+ if (!e.docChanged || e.getMeta("__uniqueIDTransaction")) return t;
680
+ let r = e.doc.lastChild;
681
+ return !$({
682
+ node: r,
683
+ types: n
684
+ });
685
+ }
686
+ }
687
+ })];
688
+ }
689
+ }), le = u.create({
690
+ name: "undoRedo",
691
+ addOptions() {
692
+ return {
693
+ depth: 100,
694
+ newGroupDelay: 500
695
+ };
696
+ },
697
+ addCommands() {
698
+ return {
699
+ undo: () => ({ state: e, dispatch: t }) => o(e, t),
700
+ redo: () => ({ state: e, dispatch: t }) => r(e, t)
701
+ };
702
+ },
703
+ addProseMirrorPlugins() {
704
+ return [i(this.options)];
705
+ },
706
+ addKeyboardShortcuts() {
707
+ return {
708
+ "Mod-z": () => this.editor.commands.undo(),
709
+ "Shift-Mod-z": () => this.editor.commands.redo(),
710
+ "Mod-y": () => this.editor.commands.redo(),
711
+ "Mod-я": () => this.editor.commands.undo(),
712
+ "Shift-Mod-я": () => this.editor.commands.redo()
713
+ };
714
+ }
715
+ });
716
+ //#endregion
717
+ export { N as a, se as c, Y as d, Q as f, M as i, ce as l, P as n, F as o, j as r, re as s, ne as t, le as u };
718
+
719
+ //# sourceMappingURL=dist-CJhbhuk0.js.map