reactjs-tiptap-editor 0.3.31 → 0.4.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.
- package/README.md +8 -2
- package/lib/{ActionMenuButton-BCgqJsST.cjs → ActionMenuButton-CYdM1xx5.cjs} +1 -1
- package/lib/{ActionMenuButton-D97K0UWT.js → ActionMenuButton-DKRF6oa0.js} +1 -1
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.d.cts +39 -43
- package/lib/Attachment.d.ts +39 -43
- package/lib/Attachment.js +7 -6
- package/lib/BaseKit.cjs +3 -0
- package/lib/BaseKit.d.cts +481 -0
- package/lib/BaseKit.d.ts +481 -0
- package/lib/BaseKit.js +132 -0
- package/lib/Blockquote.cjs +5 -1
- package/lib/Blockquote.d.cts +39 -43
- package/lib/Blockquote.d.ts +39 -43
- package/lib/Blockquote.js +33 -17
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.d.cts +39 -43
- package/lib/Bold.d.ts +39 -43
- package/lib/Bold.js +23 -16
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.d.cts +40 -44
- package/lib/BulletList.d.ts +40 -44
- package/lib/BulletList.js +11 -57
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.d.cts +39 -43
- package/lib/Clear.d.ts +39 -43
- package/lib/Clear.js +4 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.d.cts +39 -43
- package/lib/Code.d.ts +39 -43
- package/lib/Code.js +29 -25
- package/lib/CodeBlock.cjs +2 -2
- package/lib/CodeBlock.d.cts +39 -43
- package/lib/CodeBlock.d.ts +39 -43
- package/lib/CodeBlock.js +3 -3
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.d.cts +39 -43
- package/lib/CodeView.d.ts +39 -43
- package/lib/CodeView.js +3 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.d.cts +40 -44
- package/lib/Color.d.ts +40 -44
- package/lib/Color.js +42 -74
- package/lib/Document.cjs +1 -1
- package/lib/Document.d.cts +39 -43
- package/lib/Document.d.ts +39 -43
- package/lib/Document.js +4 -8
- package/lib/{Drawer-BHkje8ys.js → Drawer-CaAfmqNo.js} +37 -35
- package/lib/{Drawer-5Q_-WRhc.cjs → Drawer-CdvCMSzN.cjs} +1 -1
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.d.cts +39 -43
- package/lib/Drawer.d.ts +39 -43
- package/lib/Drawer.js +4 -4
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.d.cts +42 -44
- package/lib/Emoji.d.ts +42 -44
- package/lib/Emoji.js +19793 -182
- package/lib/{Excalidraw-GUVW-IqC.cjs → Excalidraw-BbMQhNvs.cjs} +1 -1
- package/lib/{Excalidraw-CG498239.js → Excalidraw-CVWz2Vyn.js} +20 -20
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.d.cts +39 -43
- package/lib/Excalidraw.d.ts +39 -43
- package/lib/Excalidraw.js +3 -3
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.d.cts +39 -43
- package/lib/ExportPdf.d.ts +39 -43
- package/lib/ExportPdf.js +4 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.d.cts +39 -43
- package/lib/ExportWord.d.ts +39 -43
- package/lib/ExportWord.js +22 -51
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.d.cts +40 -44
- package/lib/FontFamily.d.ts +40 -44
- package/lib/FontFamily.js +44 -73
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.d.cts +39 -43
- package/lib/FontSize.d.ts +39 -43
- package/lib/FontSize.js +7 -5
- package/lib/FormatPainter.cjs +1 -1
- package/lib/FormatPainter.d.cts +39 -43
- package/lib/FormatPainter.d.ts +39 -43
- package/lib/FormatPainter.js +4 -2
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.d.cts +39 -43
- package/lib/Heading.d.ts +39 -43
- package/lib/Heading.js +71 -60
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.d.cts +39 -43
- package/lib/Highlight.d.ts +39 -43
- package/lib/Highlight.js +5 -4
- package/lib/History.cjs +1 -1
- package/lib/History.d.cts +41 -45
- package/lib/History.d.ts +41 -45
- package/lib/History.js +39 -403
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.d.cts +39 -43
- package/lib/HorizontalRule.d.ts +39 -43
- package/lib/HorizontalRule.js +16 -65
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.d.cts +39 -43
- package/lib/Iframe.d.ts +39 -43
- package/lib/Iframe.js +4 -4
- package/lib/Image.cjs +1 -1
- package/lib/Image.d.cts +39 -43
- package/lib/Image.d.ts +39 -43
- package/lib/Image.js +3 -3
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.d.cts +39 -43
- package/lib/ImageGif.d.ts +39 -43
- package/lib/ImageGif.js +5 -5
- package/lib/ImportWord.cjs +72 -72
- package/lib/ImportWord.d.cts +39 -43
- package/lib/ImportWord.d.ts +39 -43
- package/lib/ImportWord.js +5652 -5615
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.d.cts +39 -43
- package/lib/Indent.d.ts +39 -43
- package/lib/Indent.js +4 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.d.cts +39 -43
- package/lib/Italic.d.ts +39 -43
- package/lib/Italic.js +20 -14
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.d.cts +39 -43
- package/lib/Katex.d.ts +39 -43
- package/lib/Katex.js +12 -12
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.d.cts +39 -43
- package/lib/LineHeight.d.ts +39 -43
- package/lib/LineHeight.js +5 -3
- package/lib/Link.cjs +1 -1
- package/lib/Link.d.cts +39 -43
- package/lib/Link.d.ts +39 -43
- package/lib/Link.js +4 -4
- package/lib/ListItem.cjs +1 -1
- package/lib/ListItem.d.cts +44 -44
- package/lib/ListItem.d.ts +44 -44
- package/lib/ListItem.js +4 -30
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.d.cts +39 -43
- package/lib/Mention.d.ts +39 -43
- package/lib/Mention.js +161 -132
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.d.cts +39 -43
- package/lib/Mermaid.d.ts +39 -43
- package/lib/Mermaid.js +50 -48
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.d.cts +39 -43
- package/lib/MoreMark.d.ts +39 -43
- package/lib/MoreMark.js +5 -3
- package/lib/MultiColumn.cjs +1 -1
- package/lib/MultiColumn.d.cts +39 -43
- package/lib/MultiColumn.d.ts +39 -43
- package/lib/MultiColumn.js +2 -2
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.d.cts +40 -44
- package/lib/OrderedList.d.ts +40 -44
- package/lib/OrderedList.js +11 -75
- package/lib/RichTextEditor-CxvwGvQG.cjs +142 -0
- package/lib/RichTextEditor-DGcKEUGr.js +22166 -0
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.d.cts +52 -126
- package/lib/SearchAndReplace.d.ts +52 -126
- package/lib/SearchAndReplace.js +204 -192
- package/lib/Selection.cjs +1 -1
- package/lib/Selection.d.cts +39 -43
- package/lib/Selection.d.ts +39 -43
- package/lib/Selection.js +1 -1
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.d.cts +39 -43
- package/lib/SlashCommand.d.ts +39 -43
- package/lib/SlashCommand.js +177 -222
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.d.cts +39 -43
- package/lib/Strike.d.ts +39 -43
- package/lib/Strike.js +20 -14
- package/lib/SubAndSuperScript.cjs +1 -1
- package/lib/SubAndSuperScript.d.cts +39 -43
- package/lib/SubAndSuperScript.d.ts +39 -43
- package/lib/SubAndSuperScript.js +5 -3
- package/lib/Table.cjs +8 -10
- package/lib/Table.d.cts +42 -46
- package/lib/Table.d.ts +42 -46
- package/lib/Table.js +382 -2022
- package/lib/TableOfContent.cjs +1 -1
- package/lib/TableOfContent.d.cts +39 -43
- package/lib/TableOfContent.d.ts +39 -43
- package/lib/TableOfContent.js +5 -5
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.d.cts +41 -45
- package/lib/TaskList.d.ts +41 -45
- package/lib/TaskList.js +12 -154
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.d.cts +39 -43
- package/lib/TextAlign.d.ts +39 -43
- package/lib/TextAlign.js +11 -9
- package/lib/TextBubble.cjs +1 -1
- package/lib/TextBubble.d.cts +39 -43
- package/lib/TextBubble.d.ts +39 -43
- package/lib/TextBubble.js +5 -3
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.d.cts +39 -43
- package/lib/TextDirection.d.ts +39 -43
- package/lib/TextDirection.js +2 -3
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.d.cts +39 -43
- package/lib/TextUnderline.d.ts +39 -43
- package/lib/TextUnderline.js +40 -12
- package/lib/TrailingNode.cjs +1 -1
- package/lib/TrailingNode.d.cts +39 -43
- package/lib/TrailingNode.d.ts +39 -43
- package/lib/TrailingNode.js +1 -1
- package/lib/Twitter-BFULyqdR.js +1628 -0
- package/lib/Twitter-Cutpkh3h.cjs +1 -0
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.d.cts +39 -43
- package/lib/Twitter.d.ts +39 -43
- package/lib/Twitter.js +3 -3
- package/lib/Video.cjs +1 -1
- package/lib/Video.d.cts +39 -43
- package/lib/Video.d.ts +39 -43
- package/lib/Video.js +3 -3
- package/lib/bubble-extra.cjs +2 -2
- package/lib/bubble-extra.d.cts +39 -43
- package/lib/bubble-extra.d.ts +39 -43
- package/lib/bubble-extra.js +200 -192
- package/lib/dom-dataset-_6-diIRQ.cjs +33 -0
- package/lib/dom-dataset-lYeH6gfI.js +2361 -0
- package/lib/index-5iBZLua9.cjs +12 -0
- package/lib/index-6D1J-A-o.cjs +1 -0
- package/lib/index-B96Cclrj.cjs +3 -0
- package/lib/index-BBz7Nmv9.js +55 -0
- package/lib/index-BeCTd5v2.cjs +1 -0
- package/lib/index-ByurDDMv.js +237 -0
- package/lib/index-CUogRI7j.cjs +1 -0
- package/lib/index-Ch6dBBad.js +709 -0
- package/lib/index-DF2Lp4HZ.cjs +100 -0
- package/lib/{index-LUL9mqY4.js → index-D_L6n8O8.js} +4 -4
- package/lib/index-Dbvi-Bvh.cjs +1 -0
- package/lib/index-DpCrt7xs.cjs +1 -0
- package/lib/index-DsAX1Vq8.cjs +1 -0
- package/lib/index-Dy4DlW9o.js +12 -0
- package/lib/index-J3jHHZ4d.js +200 -0
- package/lib/{index-CsK90iVd.js → index-LmrOdnen.js} +302 -389
- package/lib/index-VvXaaKe3.js +898 -0
- package/lib/index-kbO3iWqL.js +13432 -0
- package/lib/index.cjs +1 -2
- package/lib/index.d.cts +40 -243
- package/lib/index.d.ts +40 -243
- package/lib/index.js +2 -588
- package/lib/jsx-runtime-CT7Pcg-t.js +13 -0
- package/lib/jsx-runtime-C_NLcKys.cjs +1 -0
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.d.cts +39 -43
- package/lib/locale-bundle.d.ts +39 -43
- package/lib/locale-bundle.js +1 -1
- package/lib/style.css +1 -1
- package/lib/{textarea-DdH64g04.cjs → textarea-DFo_aXnj.cjs} +1 -1
- package/lib/{textarea-CktfkXNe.js → textarea-aPtytkDx.js} +1 -1
- package/package.json +76 -70
- package/lib/RichTextEditor-DWlLqTl9.cjs +0 -140
- package/lib/RichTextEditor-KP2Rgcqe.js +0 -12751
- package/lib/Twitter-99ivY5qv.js +0 -1744
- package/lib/Twitter-BvfvUtNT.cjs +0 -17
- package/lib/dom-dataset-Byuf1YmW.cjs +0 -33
- package/lib/dom-dataset-Di3tIRrR.js +0 -1031
- package/lib/index-BI-IcZcN.cjs +0 -1
- package/lib/index-ByRfqzMr.cjs +0 -89
- package/lib/index-C1fzuXpN.js +0 -46
- package/lib/index-CbQQFj2T.js +0 -133
- package/lib/index-DI9T3iLd.js +0 -12354
- package/lib/index-D_A0TBRA.cjs +0 -1
- package/lib/index-DclQSrIx.cjs +0 -1
- package/lib/index-Z4b9rzn-.cjs +0 -1
|
@@ -0,0 +1,898 @@
|
|
|
1
|
+
import { P as C, v as X, x as Y, F, S as G, T as B, b as _, D as x, j as k, y as O, a as I, z as J, E, B as Z, C as Q, G as q, i as $ } from "./index-kbO3iWqL.js";
|
|
2
|
+
function ee(i = {}) {
|
|
3
|
+
return new C({
|
|
4
|
+
view(e) {
|
|
5
|
+
return new te(e, i);
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
class te {
|
|
10
|
+
constructor(e, t) {
|
|
11
|
+
var n;
|
|
12
|
+
this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (n = t.width) !== null && n !== void 0 ? n : 1, this.color = t.color === !1 ? void 0 : t.color || "black", this.class = t.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((r) => {
|
|
13
|
+
let s = (o) => {
|
|
14
|
+
this[r](o);
|
|
15
|
+
};
|
|
16
|
+
return e.dom.addEventListener(r, s), { name: r, handler: s };
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
destroy() {
|
|
20
|
+
this.handlers.forEach(({ name: e, handler: t }) => this.editorView.dom.removeEventListener(e, t));
|
|
21
|
+
}
|
|
22
|
+
update(e, t) {
|
|
23
|
+
this.cursorPos != null && t.doc != e.state.doc && (this.cursorPos > e.state.doc.content.size ? this.setCursor(null) : this.updateOverlay());
|
|
24
|
+
}
|
|
25
|
+
setCursor(e) {
|
|
26
|
+
e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
|
|
27
|
+
}
|
|
28
|
+
updateOverlay() {
|
|
29
|
+
let e = this.editorView.state.doc.resolve(this.cursorPos), t = !e.parent.inlineContent, n, r = this.editorView.dom, s = r.getBoundingClientRect(), o = s.width / r.offsetWidth, l = s.height / r.offsetHeight;
|
|
30
|
+
if (t) {
|
|
31
|
+
let d = e.nodeBefore, p = e.nodeAfter;
|
|
32
|
+
if (d || p) {
|
|
33
|
+
let f = this.editorView.nodeDOM(this.cursorPos - (d ? d.nodeSize : 0));
|
|
34
|
+
if (f) {
|
|
35
|
+
let g = f.getBoundingClientRect(), b = d ? g.bottom : g.top;
|
|
36
|
+
d && p && (b = (b + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
|
|
37
|
+
let P = this.width / 2 * l;
|
|
38
|
+
n = { left: g.left, right: g.right, top: b - P, bottom: b + P };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (!n) {
|
|
43
|
+
let d = this.editorView.coordsAtPos(this.cursorPos), p = this.width / 2 * o;
|
|
44
|
+
n = { left: d.left - p, right: d.left + p, top: d.top, bottom: d.bottom };
|
|
45
|
+
}
|
|
46
|
+
let a = this.editorView.dom.offsetParent;
|
|
47
|
+
this.element || (this.element = a.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);
|
|
48
|
+
let c, u;
|
|
49
|
+
if (!a || a == document.body && getComputedStyle(a).position == "static")
|
|
50
|
+
c = -pageXOffset, u = -pageYOffset;
|
|
51
|
+
else {
|
|
52
|
+
let d = a.getBoundingClientRect(), p = d.width / a.offsetWidth, f = d.height / a.offsetHeight;
|
|
53
|
+
c = d.left - a.scrollLeft * p, u = d.top - a.scrollTop * f;
|
|
54
|
+
}
|
|
55
|
+
this.element.style.left = (n.left - c) / o + "px", this.element.style.top = (n.top - u) / l + "px", this.element.style.width = (n.right - n.left) / o + "px", this.element.style.height = (n.bottom - n.top) / l + "px";
|
|
56
|
+
}
|
|
57
|
+
scheduleRemoval(e) {
|
|
58
|
+
clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
|
|
59
|
+
}
|
|
60
|
+
dragover(e) {
|
|
61
|
+
if (!this.editorView.editable)
|
|
62
|
+
return;
|
|
63
|
+
let t = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }), n = t && t.inside >= 0 && this.editorView.state.doc.nodeAt(t.inside), r = n && n.type.spec.disableDropCursor, s = typeof r == "function" ? r(this.editorView, t, e) : r;
|
|
64
|
+
if (t && !s) {
|
|
65
|
+
let o = t.pos;
|
|
66
|
+
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
67
|
+
let l = X(this.editorView.state.doc, o, this.editorView.dragging.slice);
|
|
68
|
+
l != null && (o = l);
|
|
69
|
+
}
|
|
70
|
+
this.setCursor(o), this.scheduleRemoval(5e3);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
dragend() {
|
|
74
|
+
this.scheduleRemoval(20);
|
|
75
|
+
}
|
|
76
|
+
drop() {
|
|
77
|
+
this.scheduleRemoval(20);
|
|
78
|
+
}
|
|
79
|
+
dragleave(e) {
|
|
80
|
+
this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
class h extends O {
|
|
84
|
+
/**
|
|
85
|
+
Create a gap cursor.
|
|
86
|
+
*/
|
|
87
|
+
constructor(e) {
|
|
88
|
+
super(e, e);
|
|
89
|
+
}
|
|
90
|
+
map(e, t) {
|
|
91
|
+
let n = e.resolve(t.map(this.head));
|
|
92
|
+
return h.valid(n) ? new h(n) : O.near(n);
|
|
93
|
+
}
|
|
94
|
+
content() {
|
|
95
|
+
return G.empty;
|
|
96
|
+
}
|
|
97
|
+
eq(e) {
|
|
98
|
+
return e instanceof h && e.head == this.head;
|
|
99
|
+
}
|
|
100
|
+
toJSON() {
|
|
101
|
+
return { type: "gapcursor", pos: this.head };
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
@internal
|
|
105
|
+
*/
|
|
106
|
+
static fromJSON(e, t) {
|
|
107
|
+
if (typeof t.pos != "number")
|
|
108
|
+
throw new RangeError("Invalid input for GapCursor.fromJSON");
|
|
109
|
+
return new h(e.resolve(t.pos));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
@internal
|
|
113
|
+
*/
|
|
114
|
+
getBookmark() {
|
|
115
|
+
return new N(this.anchor);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
@internal
|
|
119
|
+
*/
|
|
120
|
+
static valid(e) {
|
|
121
|
+
let t = e.parent;
|
|
122
|
+
if (t.isTextblock || !ne(e) || !re(e))
|
|
123
|
+
return !1;
|
|
124
|
+
let n = t.type.spec.allowGapCursor;
|
|
125
|
+
if (n != null)
|
|
126
|
+
return n;
|
|
127
|
+
let r = t.contentMatchAt(e.index()).defaultType;
|
|
128
|
+
return r && r.isTextblock;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
@internal
|
|
132
|
+
*/
|
|
133
|
+
static findGapCursorFrom(e, t, n = !1) {
|
|
134
|
+
e: for (; ; ) {
|
|
135
|
+
if (!n && h.valid(e))
|
|
136
|
+
return e;
|
|
137
|
+
let r = e.pos, s = null;
|
|
138
|
+
for (let o = e.depth; ; o--) {
|
|
139
|
+
let l = e.node(o);
|
|
140
|
+
if (t > 0 ? e.indexAfter(o) < l.childCount : e.index(o) > 0) {
|
|
141
|
+
s = l.child(t > 0 ? e.indexAfter(o) : e.index(o) - 1);
|
|
142
|
+
break;
|
|
143
|
+
} else if (o == 0)
|
|
144
|
+
return null;
|
|
145
|
+
r += t;
|
|
146
|
+
let a = e.doc.resolve(r);
|
|
147
|
+
if (h.valid(a))
|
|
148
|
+
return a;
|
|
149
|
+
}
|
|
150
|
+
for (; ; ) {
|
|
151
|
+
let o = t > 0 ? s.firstChild : s.lastChild;
|
|
152
|
+
if (!o) {
|
|
153
|
+
if (s.isAtom && !s.isText && !_.isSelectable(s)) {
|
|
154
|
+
e = e.doc.resolve(r + s.nodeSize * t), n = !1;
|
|
155
|
+
continue e;
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
s = o, r += t;
|
|
160
|
+
let l = e.doc.resolve(r);
|
|
161
|
+
if (h.valid(l))
|
|
162
|
+
return l;
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
h.prototype.visible = !1;
|
|
169
|
+
h.findFrom = h.findGapCursorFrom;
|
|
170
|
+
O.jsonID("gapcursor", h);
|
|
171
|
+
class N {
|
|
172
|
+
constructor(e) {
|
|
173
|
+
this.pos = e;
|
|
174
|
+
}
|
|
175
|
+
map(e) {
|
|
176
|
+
return new N(e.map(this.pos));
|
|
177
|
+
}
|
|
178
|
+
resolve(e) {
|
|
179
|
+
let t = e.resolve(this.pos);
|
|
180
|
+
return h.valid(t) ? new h(t) : O.near(t);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function H(i) {
|
|
184
|
+
return i.isAtom || i.spec.isolating || i.spec.createGapCursor;
|
|
185
|
+
}
|
|
186
|
+
function ne(i) {
|
|
187
|
+
for (let e = i.depth; e >= 0; e--) {
|
|
188
|
+
let t = i.index(e), n = i.node(e);
|
|
189
|
+
if (t == 0) {
|
|
190
|
+
if (n.type.spec.isolating)
|
|
191
|
+
return !0;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
for (let r = n.child(t - 1); ; r = r.lastChild) {
|
|
195
|
+
if (r.childCount == 0 && !r.inlineContent || H(r.type))
|
|
196
|
+
return !0;
|
|
197
|
+
if (r.inlineContent)
|
|
198
|
+
return !1;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return !0;
|
|
202
|
+
}
|
|
203
|
+
function re(i) {
|
|
204
|
+
for (let e = i.depth; e >= 0; e--) {
|
|
205
|
+
let t = i.indexAfter(e), n = i.node(e);
|
|
206
|
+
if (t == n.childCount) {
|
|
207
|
+
if (n.type.spec.isolating)
|
|
208
|
+
return !0;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
for (let r = n.child(t); ; r = r.firstChild) {
|
|
212
|
+
if (r.childCount == 0 && !r.inlineContent || H(r.type))
|
|
213
|
+
return !0;
|
|
214
|
+
if (r.inlineContent)
|
|
215
|
+
return !1;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return !0;
|
|
219
|
+
}
|
|
220
|
+
function ie() {
|
|
221
|
+
return new C({
|
|
222
|
+
props: {
|
|
223
|
+
decorations: ae,
|
|
224
|
+
createSelectionBetween(i, e, t) {
|
|
225
|
+
return e.pos == t.pos && h.valid(t) ? new h(t) : null;
|
|
226
|
+
},
|
|
227
|
+
handleClick: oe,
|
|
228
|
+
handleKeyDown: se,
|
|
229
|
+
handleDOMEvents: { beforeinput: le }
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
const se = Y({
|
|
234
|
+
ArrowLeft: S("horiz", -1),
|
|
235
|
+
ArrowRight: S("horiz", 1),
|
|
236
|
+
ArrowUp: S("vert", -1),
|
|
237
|
+
ArrowDown: S("vert", 1)
|
|
238
|
+
});
|
|
239
|
+
function S(i, e) {
|
|
240
|
+
const t = i == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
|
|
241
|
+
return function(n, r, s) {
|
|
242
|
+
let o = n.selection, l = e > 0 ? o.$to : o.$from, a = o.empty;
|
|
243
|
+
if (o instanceof B) {
|
|
244
|
+
if (!s.endOfTextblock(t) || l.depth == 0)
|
|
245
|
+
return !1;
|
|
246
|
+
a = !1, l = n.doc.resolve(e > 0 ? l.after() : l.before());
|
|
247
|
+
}
|
|
248
|
+
let c = h.findGapCursorFrom(l, e, a);
|
|
249
|
+
return c ? (r && r(n.tr.setSelection(new h(c))), !0) : !1;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function oe(i, e, t) {
|
|
253
|
+
if (!i || !i.editable)
|
|
254
|
+
return !1;
|
|
255
|
+
let n = i.state.doc.resolve(e);
|
|
256
|
+
if (!h.valid(n))
|
|
257
|
+
return !1;
|
|
258
|
+
let r = i.posAtCoords({ left: t.clientX, top: t.clientY });
|
|
259
|
+
return r && r.inside > -1 && _.isSelectable(i.state.doc.nodeAt(r.inside)) ? !1 : (i.dispatch(i.state.tr.setSelection(new h(n))), !0);
|
|
260
|
+
}
|
|
261
|
+
function le(i, e) {
|
|
262
|
+
if (e.inputType != "insertCompositionText" || !(i.state.selection instanceof h))
|
|
263
|
+
return !1;
|
|
264
|
+
let { $from: t } = i.state.selection, n = t.parent.contentMatchAt(t.index()).findWrapping(i.state.schema.nodes.text);
|
|
265
|
+
if (!n)
|
|
266
|
+
return !1;
|
|
267
|
+
let r = F.empty;
|
|
268
|
+
for (let o = n.length - 1; o >= 0; o--)
|
|
269
|
+
r = F.from(n[o].createAndFill(null, r));
|
|
270
|
+
let s = i.state.tr.replace(t.pos, t.pos, new G(r, 0, 0));
|
|
271
|
+
return s.setSelection(B.near(s.doc.resolve(t.pos + 1))), i.dispatch(s), !1;
|
|
272
|
+
}
|
|
273
|
+
function ae(i) {
|
|
274
|
+
if (!(i.selection instanceof h))
|
|
275
|
+
return null;
|
|
276
|
+
let e = document.createElement("div");
|
|
277
|
+
return e.className = "ProseMirror-gapcursor", x.create(i.doc, [k.widget(i.selection.head, e, { key: "gapcursor" })]);
|
|
278
|
+
}
|
|
279
|
+
var A = 200, m = function() {
|
|
280
|
+
};
|
|
281
|
+
m.prototype.append = function(e) {
|
|
282
|
+
return e.length ? (e = m.from(e), !this.length && e || e.length < A && this.leafAppend(e) || this.length < A && e.leafPrepend(this) || this.appendInner(e)) : this;
|
|
283
|
+
};
|
|
284
|
+
m.prototype.prepend = function(e) {
|
|
285
|
+
return e.length ? m.from(e).append(this) : this;
|
|
286
|
+
};
|
|
287
|
+
m.prototype.appendInner = function(e) {
|
|
288
|
+
return new de(this, e);
|
|
289
|
+
};
|
|
290
|
+
m.prototype.slice = function(e, t) {
|
|
291
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ? m.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, t));
|
|
292
|
+
};
|
|
293
|
+
m.prototype.get = function(e) {
|
|
294
|
+
if (!(e < 0 || e >= this.length))
|
|
295
|
+
return this.getInner(e);
|
|
296
|
+
};
|
|
297
|
+
m.prototype.forEach = function(e, t, n) {
|
|
298
|
+
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);
|
|
299
|
+
};
|
|
300
|
+
m.prototype.map = function(e, t, n) {
|
|
301
|
+
t === void 0 && (t = 0), n === void 0 && (n = this.length);
|
|
302
|
+
var r = [];
|
|
303
|
+
return this.forEach(function(s, o) {
|
|
304
|
+
return r.push(e(s, o));
|
|
305
|
+
}, t, n), r;
|
|
306
|
+
};
|
|
307
|
+
m.from = function(e) {
|
|
308
|
+
return e instanceof m ? e : e && e.length ? new W(e) : m.empty;
|
|
309
|
+
};
|
|
310
|
+
var W = /* @__PURE__ */ (function(i) {
|
|
311
|
+
function e(n) {
|
|
312
|
+
i.call(this), this.values = n;
|
|
313
|
+
}
|
|
314
|
+
i && (e.__proto__ = i), e.prototype = Object.create(i && i.prototype), e.prototype.constructor = e;
|
|
315
|
+
var t = { length: { configurable: !0 }, depth: { configurable: !0 } };
|
|
316
|
+
return e.prototype.flatten = function() {
|
|
317
|
+
return this.values;
|
|
318
|
+
}, e.prototype.sliceInner = function(r, s) {
|
|
319
|
+
return r == 0 && s == this.length ? this : new e(this.values.slice(r, s));
|
|
320
|
+
}, e.prototype.getInner = function(r) {
|
|
321
|
+
return this.values[r];
|
|
322
|
+
}, e.prototype.forEachInner = function(r, s, o, l) {
|
|
323
|
+
for (var a = s; a < o; a++)
|
|
324
|
+
if (r(this.values[a], l + a) === !1)
|
|
325
|
+
return !1;
|
|
326
|
+
}, e.prototype.forEachInvertedInner = function(r, s, o, l) {
|
|
327
|
+
for (var a = s - 1; a >= o; a--)
|
|
328
|
+
if (r(this.values[a], l + a) === !1)
|
|
329
|
+
return !1;
|
|
330
|
+
}, e.prototype.leafAppend = function(r) {
|
|
331
|
+
if (this.length + r.length <= A)
|
|
332
|
+
return new e(this.values.concat(r.flatten()));
|
|
333
|
+
}, e.prototype.leafPrepend = function(r) {
|
|
334
|
+
if (this.length + r.length <= A)
|
|
335
|
+
return new e(r.flatten().concat(this.values));
|
|
336
|
+
}, t.length.get = function() {
|
|
337
|
+
return this.values.length;
|
|
338
|
+
}, t.depth.get = function() {
|
|
339
|
+
return 0;
|
|
340
|
+
}, Object.defineProperties(e.prototype, t), e;
|
|
341
|
+
})(m);
|
|
342
|
+
m.empty = new W([]);
|
|
343
|
+
var de = /* @__PURE__ */ (function(i) {
|
|
344
|
+
function e(t, n) {
|
|
345
|
+
i.call(this), this.left = t, this.right = n, this.length = t.length + n.length, this.depth = Math.max(t.depth, n.depth) + 1;
|
|
346
|
+
}
|
|
347
|
+
return i && (e.__proto__ = i), e.prototype = Object.create(i && i.prototype), e.prototype.constructor = e, e.prototype.flatten = function() {
|
|
348
|
+
return this.left.flatten().concat(this.right.flatten());
|
|
349
|
+
}, e.prototype.getInner = function(n) {
|
|
350
|
+
return n < this.left.length ? this.left.get(n) : this.right.get(n - this.left.length);
|
|
351
|
+
}, e.prototype.forEachInner = function(n, r, s, o) {
|
|
352
|
+
var l = this.left.length;
|
|
353
|
+
if (r < l && this.left.forEachInner(n, r, Math.min(s, l), o) === !1 || s > l && this.right.forEachInner(n, Math.max(r - l, 0), Math.min(this.length, s) - l, o + l) === !1)
|
|
354
|
+
return !1;
|
|
355
|
+
}, e.prototype.forEachInvertedInner = function(n, r, s, o) {
|
|
356
|
+
var l = this.left.length;
|
|
357
|
+
if (r > l && this.right.forEachInvertedInner(n, r - l, Math.max(s, l) - l, o + l) === !1 || s < l && this.left.forEachInvertedInner(n, Math.min(r, l), s, o) === !1)
|
|
358
|
+
return !1;
|
|
359
|
+
}, e.prototype.sliceInner = function(n, r) {
|
|
360
|
+
if (n == 0 && r == this.length)
|
|
361
|
+
return this;
|
|
362
|
+
var s = this.left.length;
|
|
363
|
+
return r <= s ? this.left.slice(n, r) : n >= s ? this.right.slice(n - s, r - s) : this.left.slice(n, s).append(this.right.slice(0, r - s));
|
|
364
|
+
}, e.prototype.leafAppend = function(n) {
|
|
365
|
+
var r = this.right.leafAppend(n);
|
|
366
|
+
if (r)
|
|
367
|
+
return new e(this.left, r);
|
|
368
|
+
}, e.prototype.leafPrepend = function(n) {
|
|
369
|
+
var r = this.left.leafPrepend(n);
|
|
370
|
+
if (r)
|
|
371
|
+
return new e(r, this.right);
|
|
372
|
+
}, e.prototype.appendInner = function(n) {
|
|
373
|
+
return this.left.depth >= Math.max(this.right.depth, n.depth) + 1 ? new e(this.left, new e(this.right, n)) : new e(this, n);
|
|
374
|
+
}, e;
|
|
375
|
+
})(m);
|
|
376
|
+
const ce = 500;
|
|
377
|
+
class v {
|
|
378
|
+
constructor(e, t) {
|
|
379
|
+
this.items = e, this.eventCount = t;
|
|
380
|
+
}
|
|
381
|
+
// Pop the latest event off the branch's history and apply it
|
|
382
|
+
// to a document transform.
|
|
383
|
+
popEvent(e, t) {
|
|
384
|
+
if (this.eventCount == 0)
|
|
385
|
+
return null;
|
|
386
|
+
let n = this.items.length;
|
|
387
|
+
for (; ; n--)
|
|
388
|
+
if (this.items.get(n - 1).selection) {
|
|
389
|
+
--n;
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
let r, s;
|
|
393
|
+
t && (r = this.remapping(n, this.items.length), s = r.maps.length);
|
|
394
|
+
let o = e.tr, l, a, c = [], u = [];
|
|
395
|
+
return this.items.forEach((d, p) => {
|
|
396
|
+
if (!d.step) {
|
|
397
|
+
r || (r = this.remapping(n, p + 1), s = r.maps.length), s--, u.push(d);
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (r) {
|
|
401
|
+
u.push(new w(d.map));
|
|
402
|
+
let f = d.step.map(r.slice(s)), g;
|
|
403
|
+
f && o.maybeStep(f).doc && (g = o.mapping.maps[o.mapping.maps.length - 1], c.push(new w(g, void 0, void 0, c.length + u.length))), s--, g && r.appendMap(g, s);
|
|
404
|
+
} else
|
|
405
|
+
o.maybeStep(d.step);
|
|
406
|
+
if (d.selection)
|
|
407
|
+
return l = r ? d.selection.map(r.slice(s)) : d.selection, a = new v(this.items.slice(0, n).append(u.reverse().concat(c)), this.eventCount - 1), !1;
|
|
408
|
+
}, this.items.length, 0), { remaining: a, transform: o, selection: l };
|
|
409
|
+
}
|
|
410
|
+
// Create a new branch with the given transform added.
|
|
411
|
+
addTransform(e, t, n, r) {
|
|
412
|
+
let s = [], o = this.eventCount, l = this.items, a = !r && l.length ? l.get(l.length - 1) : null;
|
|
413
|
+
for (let u = 0; u < e.steps.length; u++) {
|
|
414
|
+
let d = e.steps[u].invert(e.docs[u]), p = new w(e.mapping.maps[u], d, t), f;
|
|
415
|
+
(f = a && a.merge(p)) && (p = f, u ? s.pop() : l = l.slice(0, l.length - 1)), s.push(p), t && (o++, t = void 0), r || (a = p);
|
|
416
|
+
}
|
|
417
|
+
let c = o - n.depth;
|
|
418
|
+
return c > pe && (l = ue(l, c), o -= c), new v(l.append(s), o);
|
|
419
|
+
}
|
|
420
|
+
remapping(e, t) {
|
|
421
|
+
let n = new J();
|
|
422
|
+
return this.items.forEach((r, s) => {
|
|
423
|
+
let o = r.mirrorOffset != null && s - r.mirrorOffset >= e ? n.maps.length - r.mirrorOffset : void 0;
|
|
424
|
+
n.appendMap(r.map, o);
|
|
425
|
+
}, e, t), n;
|
|
426
|
+
}
|
|
427
|
+
addMaps(e) {
|
|
428
|
+
return this.eventCount == 0 ? this : new v(this.items.append(e.map((t) => new w(t))), this.eventCount);
|
|
429
|
+
}
|
|
430
|
+
// When the collab module receives remote changes, the history has
|
|
431
|
+
// to know about those, so that it can adjust the steps that were
|
|
432
|
+
// rebased on top of the remote changes, and include the position
|
|
433
|
+
// maps for the remote changes in its array of items.
|
|
434
|
+
rebased(e, t) {
|
|
435
|
+
if (!this.eventCount)
|
|
436
|
+
return this;
|
|
437
|
+
let n = [], r = Math.max(0, this.items.length - t), s = e.mapping, o = e.steps.length, l = this.eventCount;
|
|
438
|
+
this.items.forEach((p) => {
|
|
439
|
+
p.selection && l--;
|
|
440
|
+
}, r);
|
|
441
|
+
let a = t;
|
|
442
|
+
this.items.forEach((p) => {
|
|
443
|
+
let f = s.getMirror(--a);
|
|
444
|
+
if (f == null)
|
|
445
|
+
return;
|
|
446
|
+
o = Math.min(o, f);
|
|
447
|
+
let g = s.maps[f];
|
|
448
|
+
if (p.step) {
|
|
449
|
+
let b = e.steps[f].invert(e.docs[f]), P = p.selection && p.selection.map(s.slice(a + 1, f));
|
|
450
|
+
P && l++, n.push(new w(g, b, P));
|
|
451
|
+
} else
|
|
452
|
+
n.push(new w(g));
|
|
453
|
+
}, r);
|
|
454
|
+
let c = [];
|
|
455
|
+
for (let p = t; p < o; p++)
|
|
456
|
+
c.push(new w(s.maps[p]));
|
|
457
|
+
let u = this.items.slice(0, r).append(c).append(n), d = new v(u, l);
|
|
458
|
+
return d.emptyItemCount() > ce && (d = d.compress(this.items.length - n.length)), d;
|
|
459
|
+
}
|
|
460
|
+
emptyItemCount() {
|
|
461
|
+
let e = 0;
|
|
462
|
+
return this.items.forEach((t) => {
|
|
463
|
+
t.step || e++;
|
|
464
|
+
}), e;
|
|
465
|
+
}
|
|
466
|
+
// Compressing a branch means rewriting it to push the air (map-only
|
|
467
|
+
// items) out. During collaboration, these naturally accumulate
|
|
468
|
+
// because each remote change adds one. The `upto` argument is used
|
|
469
|
+
// to ensure that only the items below a given level are compressed,
|
|
470
|
+
// because `rebased` relies on a clean, untouched set of items in
|
|
471
|
+
// order to associate old items with rebased steps.
|
|
472
|
+
compress(e = this.items.length) {
|
|
473
|
+
let t = this.remapping(0, e), n = t.maps.length, r = [], s = 0;
|
|
474
|
+
return this.items.forEach((o, l) => {
|
|
475
|
+
if (l >= e)
|
|
476
|
+
r.push(o), o.selection && s++;
|
|
477
|
+
else if (o.step) {
|
|
478
|
+
let a = o.step.map(t.slice(n)), c = a && a.getMap();
|
|
479
|
+
if (n--, c && t.appendMap(c, n), a) {
|
|
480
|
+
let u = o.selection && o.selection.map(t.slice(n));
|
|
481
|
+
u && s++;
|
|
482
|
+
let d = new w(c.invert(), a, u), p, f = r.length - 1;
|
|
483
|
+
(p = r.length && r[f].merge(d)) ? r[f] = p : r.push(d);
|
|
484
|
+
}
|
|
485
|
+
} else o.map && n--;
|
|
486
|
+
}, this.items.length, 0), new v(m.from(r.reverse()), s);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
v.empty = new v(m.empty, 0);
|
|
490
|
+
function ue(i, e) {
|
|
491
|
+
let t;
|
|
492
|
+
return i.forEach((n, r) => {
|
|
493
|
+
if (n.selection && e-- == 0)
|
|
494
|
+
return t = r, !1;
|
|
495
|
+
}), i.slice(t);
|
|
496
|
+
}
|
|
497
|
+
class w {
|
|
498
|
+
constructor(e, t, n, r) {
|
|
499
|
+
this.map = e, this.step = t, this.selection = n, this.mirrorOffset = r;
|
|
500
|
+
}
|
|
501
|
+
merge(e) {
|
|
502
|
+
if (this.step && e.step && !e.selection) {
|
|
503
|
+
let t = e.step.merge(this.step);
|
|
504
|
+
if (t)
|
|
505
|
+
return new w(t.getMap().invert(), t, this.selection);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
class y {
|
|
510
|
+
constructor(e, t, n, r, s) {
|
|
511
|
+
this.done = e, this.undone = t, this.prevRanges = n, this.prevTime = r, this.prevComposition = s;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
const pe = 20;
|
|
515
|
+
function he(i, e, t, n) {
|
|
516
|
+
let r = t.getMeta(M), s;
|
|
517
|
+
if (r)
|
|
518
|
+
return r.historyState;
|
|
519
|
+
t.getMeta(ge) && (i = new y(i.done, i.undone, null, 0, -1));
|
|
520
|
+
let o = t.getMeta("appendedTransaction");
|
|
521
|
+
if (t.steps.length == 0)
|
|
522
|
+
return i;
|
|
523
|
+
if (o && o.getMeta(M))
|
|
524
|
+
return o.getMeta(M).redo ? new y(i.done.addTransform(t, void 0, n, T(e)), i.undone, R(t.mapping.maps), i.prevTime, i.prevComposition) : new y(i.done, i.undone.addTransform(t, void 0, n, T(e)), null, i.prevTime, i.prevComposition);
|
|
525
|
+
if (t.getMeta("addToHistory") !== !1 && !(o && o.getMeta("addToHistory") === !1)) {
|
|
526
|
+
let l = t.getMeta("composition"), a = i.prevTime == 0 || !o && i.prevComposition != l && (i.prevTime < (t.time || 0) - n.newGroupDelay || !fe(t, i.prevRanges)), c = o ? D(i.prevRanges, t.mapping) : R(t.mapping.maps);
|
|
527
|
+
return new y(i.done.addTransform(t, a ? e.selection.getBookmark() : void 0, n, T(e)), v.empty, c, t.time, l ?? i.prevComposition);
|
|
528
|
+
} else return (s = t.getMeta("rebased")) ? new y(i.done.rebased(t, s), i.undone.rebased(t, s), D(i.prevRanges, t.mapping), i.prevTime, i.prevComposition) : new y(i.done.addMaps(t.mapping.maps), i.undone.addMaps(t.mapping.maps), D(i.prevRanges, t.mapping), i.prevTime, i.prevComposition);
|
|
529
|
+
}
|
|
530
|
+
function fe(i, e) {
|
|
531
|
+
if (!e)
|
|
532
|
+
return !1;
|
|
533
|
+
if (!i.docChanged)
|
|
534
|
+
return !0;
|
|
535
|
+
let t = !1;
|
|
536
|
+
return i.mapping.maps[0].forEach((n, r) => {
|
|
537
|
+
for (let s = 0; s < e.length; s += 2)
|
|
538
|
+
n <= e[s + 1] && r >= e[s] && (t = !0);
|
|
539
|
+
}), t;
|
|
540
|
+
}
|
|
541
|
+
function R(i) {
|
|
542
|
+
let e = [];
|
|
543
|
+
for (let t = i.length - 1; t >= 0 && e.length == 0; t--)
|
|
544
|
+
i[t].forEach((n, r, s, o) => e.push(s, o));
|
|
545
|
+
return e;
|
|
546
|
+
}
|
|
547
|
+
function D(i, e) {
|
|
548
|
+
if (!i)
|
|
549
|
+
return null;
|
|
550
|
+
let t = [];
|
|
551
|
+
for (let n = 0; n < i.length; n += 2) {
|
|
552
|
+
let r = e.map(i[n], 1), s = e.map(i[n + 1], -1);
|
|
553
|
+
r <= s && t.push(r, s);
|
|
554
|
+
}
|
|
555
|
+
return t;
|
|
556
|
+
}
|
|
557
|
+
function me(i, e, t) {
|
|
558
|
+
let n = T(e), r = M.get(e).spec.config, s = (t ? i.undone : i.done).popEvent(e, n);
|
|
559
|
+
if (!s)
|
|
560
|
+
return null;
|
|
561
|
+
let o = s.selection.resolve(s.transform.doc), l = (t ? i.done : i.undone).addTransform(s.transform, e.selection.getBookmark(), r, n), a = new y(t ? l : s.remaining, t ? s.remaining : l, null, 0, -1);
|
|
562
|
+
return s.transform.setSelection(o).setMeta(M, { redo: t, historyState: a });
|
|
563
|
+
}
|
|
564
|
+
let z = !1, V = null;
|
|
565
|
+
function T(i) {
|
|
566
|
+
let e = i.plugins;
|
|
567
|
+
if (V != e) {
|
|
568
|
+
z = !1, V = e;
|
|
569
|
+
for (let t = 0; t < e.length; t++)
|
|
570
|
+
if (e[t].spec.historyPreserveItems) {
|
|
571
|
+
z = !0;
|
|
572
|
+
break;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return z;
|
|
576
|
+
}
|
|
577
|
+
const M = new I("history"), ge = new I("closeHistory");
|
|
578
|
+
function ve(i = {}) {
|
|
579
|
+
return i = {
|
|
580
|
+
depth: i.depth || 100,
|
|
581
|
+
newGroupDelay: i.newGroupDelay || 500
|
|
582
|
+
}, new C({
|
|
583
|
+
key: M,
|
|
584
|
+
state: {
|
|
585
|
+
init() {
|
|
586
|
+
return new y(v.empty, v.empty, null, 0, -1);
|
|
587
|
+
},
|
|
588
|
+
apply(e, t, n) {
|
|
589
|
+
return he(t, n, e, i);
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
config: i,
|
|
593
|
+
props: {
|
|
594
|
+
handleDOMEvents: {
|
|
595
|
+
beforeinput(e, t) {
|
|
596
|
+
let n = t.inputType, r = n == "historyUndo" ? K : n == "historyRedo" ? U : null;
|
|
597
|
+
return !r || !e.editable ? !1 : (t.preventDefault(), r(e.state, e.dispatch));
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
function j(i, e) {
|
|
604
|
+
return (t, n) => {
|
|
605
|
+
let r = M.getState(t);
|
|
606
|
+
if (!r || (i ? r.undone : r.done).eventCount == 0)
|
|
607
|
+
return !1;
|
|
608
|
+
if (n) {
|
|
609
|
+
let s = me(r, t, i);
|
|
610
|
+
s && n(e ? s.scrollIntoView() : s);
|
|
611
|
+
}
|
|
612
|
+
return !0;
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
const K = j(!1, !0), U = j(!0, !0);
|
|
616
|
+
var ye = E.create({
|
|
617
|
+
name: "characterCount",
|
|
618
|
+
addOptions() {
|
|
619
|
+
return {
|
|
620
|
+
limit: null,
|
|
621
|
+
mode: "textSize",
|
|
622
|
+
textCounter: (i) => i.length,
|
|
623
|
+
wordCounter: (i) => i.split(" ").filter((e) => e !== "").length
|
|
624
|
+
};
|
|
625
|
+
},
|
|
626
|
+
addStorage() {
|
|
627
|
+
return {
|
|
628
|
+
characters: () => 0,
|
|
629
|
+
words: () => 0
|
|
630
|
+
};
|
|
631
|
+
},
|
|
632
|
+
onBeforeCreate() {
|
|
633
|
+
this.storage.characters = (i) => {
|
|
634
|
+
const e = (i == null ? void 0 : i.node) || this.editor.state.doc;
|
|
635
|
+
if (((i == null ? void 0 : i.mode) || this.options.mode) === "textSize") {
|
|
636
|
+
const n = e.textBetween(0, e.content.size, void 0, " ");
|
|
637
|
+
return this.options.textCounter(n);
|
|
638
|
+
}
|
|
639
|
+
return e.nodeSize;
|
|
640
|
+
}, this.storage.words = (i) => {
|
|
641
|
+
const e = (i == null ? void 0 : i.node) || this.editor.state.doc, t = e.textBetween(0, e.content.size, " ", " ");
|
|
642
|
+
return this.options.wordCounter(t);
|
|
643
|
+
};
|
|
644
|
+
},
|
|
645
|
+
addProseMirrorPlugins() {
|
|
646
|
+
let i = !1;
|
|
647
|
+
return [
|
|
648
|
+
new C({
|
|
649
|
+
key: new I("characterCount"),
|
|
650
|
+
appendTransaction: (e, t, n) => {
|
|
651
|
+
if (i)
|
|
652
|
+
return;
|
|
653
|
+
const r = this.options.limit;
|
|
654
|
+
if (r == null || r === 0) {
|
|
655
|
+
i = !0;
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
const s = this.storage.characters({ node: n.doc });
|
|
659
|
+
if (s > r) {
|
|
660
|
+
const o = s - r, l = 0, a = o;
|
|
661
|
+
console.warn(
|
|
662
|
+
`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`
|
|
663
|
+
);
|
|
664
|
+
const c = n.tr.deleteRange(l, a);
|
|
665
|
+
return i = !0, c;
|
|
666
|
+
}
|
|
667
|
+
i = !0;
|
|
668
|
+
},
|
|
669
|
+
filterTransaction: (e, t) => {
|
|
670
|
+
const n = this.options.limit;
|
|
671
|
+
if (!e.docChanged || n === 0 || n === null || n === void 0)
|
|
672
|
+
return !0;
|
|
673
|
+
const r = this.storage.characters({ node: t.doc }), s = this.storage.characters({ node: e.doc });
|
|
674
|
+
if (s <= n || r > n && s > n && s <= r)
|
|
675
|
+
return !0;
|
|
676
|
+
if (r > n && s > n && s > r || !e.getMeta("paste"))
|
|
677
|
+
return !1;
|
|
678
|
+
const l = e.selection.$head.pos, a = s - n, c = l - a, u = l;
|
|
679
|
+
return e.deleteRange(c, u), !(this.storage.characters({ node: e.doc }) > n);
|
|
680
|
+
}
|
|
681
|
+
})
|
|
682
|
+
];
|
|
683
|
+
}
|
|
684
|
+
}), Ce = E.create({
|
|
685
|
+
name: "dropCursor",
|
|
686
|
+
addOptions() {
|
|
687
|
+
return {
|
|
688
|
+
color: "currentColor",
|
|
689
|
+
width: 1,
|
|
690
|
+
class: void 0
|
|
691
|
+
};
|
|
692
|
+
},
|
|
693
|
+
addProseMirrorPlugins() {
|
|
694
|
+
return [ee(this.options)];
|
|
695
|
+
}
|
|
696
|
+
}), Ee = E.create({
|
|
697
|
+
name: "focus",
|
|
698
|
+
addOptions() {
|
|
699
|
+
return {
|
|
700
|
+
className: "has-focus",
|
|
701
|
+
mode: "all"
|
|
702
|
+
};
|
|
703
|
+
},
|
|
704
|
+
addProseMirrorPlugins() {
|
|
705
|
+
return [
|
|
706
|
+
new C({
|
|
707
|
+
key: new I("focus"),
|
|
708
|
+
props: {
|
|
709
|
+
decorations: ({ doc: i, selection: e }) => {
|
|
710
|
+
const { isEditable: t, isFocused: n } = this.editor, { anchor: r } = e, s = [];
|
|
711
|
+
if (!t || !n)
|
|
712
|
+
return x.create(i, []);
|
|
713
|
+
let o = 0;
|
|
714
|
+
this.options.mode === "deepest" && i.descendants((a, c) => {
|
|
715
|
+
if (a.isText)
|
|
716
|
+
return;
|
|
717
|
+
if (!(r >= c && r <= c + a.nodeSize - 1))
|
|
718
|
+
return !1;
|
|
719
|
+
o += 1;
|
|
720
|
+
});
|
|
721
|
+
let l = 0;
|
|
722
|
+
return i.descendants((a, c) => {
|
|
723
|
+
if (a.isText || !(r >= c && r <= c + a.nodeSize - 1))
|
|
724
|
+
return !1;
|
|
725
|
+
if (l += 1, this.options.mode === "deepest" && o - l > 0 || this.options.mode === "shallowest" && l > 1)
|
|
726
|
+
return this.options.mode === "deepest";
|
|
727
|
+
s.push(
|
|
728
|
+
k.node(c, c + a.nodeSize, {
|
|
729
|
+
class: this.options.className
|
|
730
|
+
})
|
|
731
|
+
);
|
|
732
|
+
}), x.create(i, s);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
})
|
|
736
|
+
];
|
|
737
|
+
}
|
|
738
|
+
}), Me = E.create({
|
|
739
|
+
name: "gapCursor",
|
|
740
|
+
addProseMirrorPlugins() {
|
|
741
|
+
return [ie()];
|
|
742
|
+
},
|
|
743
|
+
extendNodeSchema(i) {
|
|
744
|
+
var e;
|
|
745
|
+
const t = {
|
|
746
|
+
name: i.name,
|
|
747
|
+
options: i.options,
|
|
748
|
+
storage: i.storage
|
|
749
|
+
};
|
|
750
|
+
return {
|
|
751
|
+
allowGapCursor: (e = Z(Q(i, "allowGapCursor", t))) != null ? e : null
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
}), Ie = E.create({
|
|
755
|
+
name: "placeholder",
|
|
756
|
+
addOptions() {
|
|
757
|
+
return {
|
|
758
|
+
emptyEditorClass: "is-editor-empty",
|
|
759
|
+
emptyNodeClass: "is-empty",
|
|
760
|
+
placeholder: "Write something …",
|
|
761
|
+
showOnlyWhenEditable: !0,
|
|
762
|
+
showOnlyCurrent: !0,
|
|
763
|
+
includeChildren: !1
|
|
764
|
+
};
|
|
765
|
+
},
|
|
766
|
+
addProseMirrorPlugins() {
|
|
767
|
+
return [
|
|
768
|
+
new C({
|
|
769
|
+
key: new I("placeholder"),
|
|
770
|
+
props: {
|
|
771
|
+
decorations: ({ doc: i, selection: e }) => {
|
|
772
|
+
const t = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: n } = e, r = [];
|
|
773
|
+
if (!t)
|
|
774
|
+
return null;
|
|
775
|
+
const s = this.editor.isEmpty;
|
|
776
|
+
return i.descendants((o, l) => {
|
|
777
|
+
const a = n >= l && n <= l + o.nodeSize, c = !o.isLeaf && q(o);
|
|
778
|
+
if ((a || !this.options.showOnlyCurrent) && c) {
|
|
779
|
+
const u = [this.options.emptyNodeClass];
|
|
780
|
+
s && u.push(this.options.emptyEditorClass);
|
|
781
|
+
const d = k.node(l, l + o.nodeSize, {
|
|
782
|
+
class: u.join(" "),
|
|
783
|
+
"data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
|
|
784
|
+
editor: this.editor,
|
|
785
|
+
node: o,
|
|
786
|
+
pos: l,
|
|
787
|
+
hasAnchor: a
|
|
788
|
+
}) : this.options.placeholder
|
|
789
|
+
});
|
|
790
|
+
r.push(d);
|
|
791
|
+
}
|
|
792
|
+
return this.options.includeChildren;
|
|
793
|
+
}), x.create(i, r);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
})
|
|
797
|
+
];
|
|
798
|
+
}
|
|
799
|
+
}), be = E.create({
|
|
800
|
+
name: "selection",
|
|
801
|
+
addOptions() {
|
|
802
|
+
return {
|
|
803
|
+
className: "selection"
|
|
804
|
+
};
|
|
805
|
+
},
|
|
806
|
+
addProseMirrorPlugins() {
|
|
807
|
+
const { editor: i, options: e } = this;
|
|
808
|
+
return [
|
|
809
|
+
new C({
|
|
810
|
+
key: new I("selection"),
|
|
811
|
+
props: {
|
|
812
|
+
decorations(t) {
|
|
813
|
+
return t.selection.empty || i.isFocused || !i.isEditable || $(t.selection) || i.view.dragging ? null : x.create(t.doc, [
|
|
814
|
+
k.inline(t.selection.from, t.selection.to, {
|
|
815
|
+
class: e.className
|
|
816
|
+
})
|
|
817
|
+
]);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
})
|
|
821
|
+
];
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
function L({ types: i, node: e }) {
|
|
825
|
+
return e && Array.isArray(i) && i.includes(e.type) || (e == null ? void 0 : e.type) === i;
|
|
826
|
+
}
|
|
827
|
+
var Pe = E.create({
|
|
828
|
+
name: "trailingNode",
|
|
829
|
+
addOptions() {
|
|
830
|
+
return {
|
|
831
|
+
node: void 0,
|
|
832
|
+
notAfter: []
|
|
833
|
+
};
|
|
834
|
+
},
|
|
835
|
+
addProseMirrorPlugins() {
|
|
836
|
+
var i;
|
|
837
|
+
const e = new I(this.name), t = this.options.node || ((i = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : i.name) || "paragraph", n = Object.entries(this.editor.schema.nodes).map(([, r]) => r).filter((r) => (this.options.notAfter || []).concat(t).includes(r.name));
|
|
838
|
+
return [
|
|
839
|
+
new C({
|
|
840
|
+
key: e,
|
|
841
|
+
appendTransaction: (r, s, o) => {
|
|
842
|
+
const { doc: l, tr: a, schema: c } = o, u = e.getState(o), d = l.content.size, p = c.nodes[t];
|
|
843
|
+
if (u)
|
|
844
|
+
return a.insert(d, p.create());
|
|
845
|
+
},
|
|
846
|
+
state: {
|
|
847
|
+
init: (r, s) => {
|
|
848
|
+
const o = s.tr.doc.lastChild;
|
|
849
|
+
return !L({ node: o, types: n });
|
|
850
|
+
},
|
|
851
|
+
apply: (r, s) => {
|
|
852
|
+
if (!r.docChanged || r.getMeta("__uniqueIDTransaction"))
|
|
853
|
+
return s;
|
|
854
|
+
const o = r.doc.lastChild;
|
|
855
|
+
return !L({ node: o, types: n });
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
})
|
|
859
|
+
];
|
|
860
|
+
}
|
|
861
|
+
}), xe = E.create({
|
|
862
|
+
name: "undoRedo",
|
|
863
|
+
addOptions() {
|
|
864
|
+
return {
|
|
865
|
+
depth: 100,
|
|
866
|
+
newGroupDelay: 500
|
|
867
|
+
};
|
|
868
|
+
},
|
|
869
|
+
addCommands() {
|
|
870
|
+
return {
|
|
871
|
+
undo: () => ({ state: i, dispatch: e }) => K(i, e),
|
|
872
|
+
redo: () => ({ state: i, dispatch: e }) => U(i, e)
|
|
873
|
+
};
|
|
874
|
+
},
|
|
875
|
+
addProseMirrorPlugins() {
|
|
876
|
+
return [ve(this.options)];
|
|
877
|
+
},
|
|
878
|
+
addKeyboardShortcuts() {
|
|
879
|
+
return {
|
|
880
|
+
"Mod-z": () => this.editor.commands.undo(),
|
|
881
|
+
"Shift-Mod-z": () => this.editor.commands.redo(),
|
|
882
|
+
"Mod-y": () => this.editor.commands.redo(),
|
|
883
|
+
// Russian keyboard layouts
|
|
884
|
+
"Mod-я": () => this.editor.commands.undo(),
|
|
885
|
+
"Shift-Mod-я": () => this.editor.commands.redo()
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
export {
|
|
890
|
+
ye as C,
|
|
891
|
+
Ce as D,
|
|
892
|
+
Ee as F,
|
|
893
|
+
Me as G,
|
|
894
|
+
Ie as P,
|
|
895
|
+
be as S,
|
|
896
|
+
Pe as T,
|
|
897
|
+
xe as U
|
|
898
|
+
};
|