reactjs-tiptap-editor 1.0.22 → 1.0.24
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/lib/{ActionMenuButton-BBDqKvKg.cjs → ActionMenuButton-B8NhVw5m.cjs} +1 -1
- package/lib/{ActionMenuButton-B1067mIC.js → ActionMenuButton-HYlhmRvw.js} +1 -1
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +4 -4
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.js +2 -2
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +2 -2
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +2 -2
- package/lib/{Callout-lBlBlK_w.cjs → Callout-B-S2f0Qo.cjs} +1 -1
- package/lib/{Callout-V2mO6s2Y.js → Callout-CF7Y9yJ7.js} +4 -4
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +4 -4
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +2 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +6 -6
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.js +27 -27
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +2 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +3 -3
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +7 -7
- package/lib/{Drawer-Cyv27orn.js → Drawer-CaXVhxo4.js} +21 -21
- package/lib/{Drawer-BeYo9jAG.cjs → Drawer-Was4hxYH.cjs} +1 -1
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +4 -4
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +4312 -1860
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +3 -3
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +2 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +2 -2
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +5 -5
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +9 -9
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +5 -5
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +69 -46
- package/lib/History.cjs +1 -1
- package/lib/History.js +556 -418
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +2 -2
- package/lib/{Iframe-Bx-VDxSB.cjs → Iframe-BI0sq6pd.cjs} +1 -1
- package/lib/{Iframe-D9JVKzO0.js → Iframe-Bp986fj0.js} +3 -3
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +3 -3
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +3 -3
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +47 -47
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +3 -3
- package/lib/{Indent-B5tQ5Wfg.js → Indent-E6B8DkyN.js} +4 -4
- package/lib/{Indent-CCLO0KpG.cjs → Indent-FvM52kjA.cjs} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +2 -2
- package/lib/{Katex-rtfVV2pl.cjs → Katex-DP6EjdKz.cjs} +1 -1
- package/lib/{Katex-w_c6vAMd.js → Katex-pzwyyiFJ.js} +5 -5
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +3 -3
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +4 -4
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/LinkEditBlock-Cmkmp2fW.cjs +5 -0
- package/lib/{LinkEditBlock-CTlU8YnO.js → LinkEditBlock-OjN4F2rM.js} +222 -224
- package/lib/MarkdownPaste.cjs +1 -1
- package/lib/MarkdownPaste.js +1 -1
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +8 -8
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +34 -34
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +3 -3
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +2 -2
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +4 -4
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +7 -7
- package/lib/{SlashCommandNodeView-CVKjpS6r.cjs → SlashCommandNodeView-DarAytvt.cjs} +1 -1
- package/lib/{SlashCommandNodeView-DNkpJuM3.js → SlashCommandNodeView-o323V8li.js} +2 -2
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +2 -2
- package/lib/Table-CC9uNHPL.js +1984 -0
- package/lib/Table-Clnz-i4l.cjs +9 -0
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +2 -2
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +3 -3
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +3 -3
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +2 -2
- package/lib/{Twitter-BJjt8vv_.cjs → Twitter-0kmrijjL.cjs} +1 -1
- package/lib/{Twitter-CKm0M53B.js → Twitter-BVnXL8we.js} +5 -5
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +3 -3
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +3 -3
- package/lib/bubble.cjs +6 -6
- package/lib/bubble.js +1573 -1561
- package/lib/{clsx-Bg-2aTKh.js → clsx-0OU6n9va.js} +379 -353
- package/lib/clsx-D6gYQn3o.cjs +33 -0
- package/lib/{dropdown-menu-Dre693DD.cjs → dropdown-menu-BIGvxqiu.cjs} +1 -1
- package/lib/{dropdown-menu-AhMKS9PQ.js → dropdown-menu-BW2M6saA.js} +1 -1
- package/lib/index-BAb_UADw.cjs +1 -0
- package/lib/index-BF3EVCB1.cjs +2 -0
- package/lib/{index-D0EmqTpe.js → index-BblvcbTH.js} +1130 -1064
- package/lib/index-Bcj8cyOO.cjs +24 -0
- package/lib/{index-BfHAqkoX.js → index-BrsJsbds.js} +3 -3
- package/lib/index-CGjT-a9h.js +1377 -0
- package/lib/index-CPTpXLfX.cjs +11 -0
- package/lib/{index-C3dgmjIF.cjs → index-CUvjYuRp.cjs} +1 -1
- package/lib/{index-C4aGVY2E.cjs → index-CWw4s87s.cjs} +1 -1
- package/lib/{index-DXtVL0al.js → index-Cal5SPfB.js} +189 -134
- package/lib/{index-CjLxMm5d.js → index-D-Ouz0vF.js} +1 -1
- package/lib/{index-83hp1lZH.cjs → index-deubsx3z.cjs} +1 -1
- package/lib/{index-DtVRewGA.js → index-oj858lQO.js} +229 -31
- package/lib/{index-CbkpBnTX.js → index-zw-Kd38i.js} +47 -50
- package/lib/index.cjs +1 -1
- package/lib/index.js +2 -2
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.js +7 -6
- package/lib/locales/index.d.ts +199 -1
- package/lib/locales/ja.d.ts +198 -0
- package/lib/{popover-B1ptDngu.js → popover-BIVHT1W9.js} +1 -1
- package/lib/{popover-D7w_FVSV.cjs → popover-DoSfJsFS.cjs} +1 -1
- package/lib/{renderNodeView-CbxCTni3.js → renderNodeView-CfWJK4rG.js} +2 -2
- package/lib/{renderNodeView-DFVrJy0l.cjs → renderNodeView-D--fDFov.cjs} +1 -1
- package/lib/{separator-C_7KkuoG.cjs → separator-SRbPfmGa.cjs} +1 -1
- package/lib/{separator-CDoF4Z4Z.js → separator-b-qOPJmp.js} +3 -3
- package/lib/{textarea-CNzZnjjW.js → textarea-CpxXPky_.js} +1 -1
- package/lib/{textarea-CEtXap1b.cjs → textarea-DbGw9oCU.cjs} +1 -1
- package/lib/updatePosition-BwzAsiY0.js +16 -0
- package/lib/{updatePosition-CQE1ct18.cjs → updatePosition-DGPtRfWN.cjs} +1 -1
- package/package.json +60 -60
- package/lib/LinkEditBlock-_41zgSyl.cjs +0 -5
- package/lib/Table-BFiU40iW.cjs +0 -9
- package/lib/Table-yZtD5Qo1.js +0 -1945
- package/lib/clsx-DSAWW32g.cjs +0 -33
- package/lib/index-C4WLt4NA.cjs +0 -24
- package/lib/index-DlxZt4_j.cjs +0 -1
- package/lib/index-P5_MyY0i.js +0 -1362
- package/lib/index-TcJ2UKnv.cjs +0 -1
- package/lib/index-fbGGohBT.cjs +0 -12
- package/lib/updatePosition-BGD41Hbg.js +0 -16
package/lib/History.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Plugin as A, PluginKey as
|
|
3
|
-
import { DecorationSet as
|
|
4
|
-
import { k as
|
|
5
|
-
import { jsx as
|
|
6
|
-
import { u as
|
|
1
|
+
import { O as N, x as se, F as V, v as W, T as j, u as Y, S as x, Q as X, R as le, E as b, U as ae, V as ce, W as _, o as de } from "./index-BblvcbTH.js";
|
|
2
|
+
import { Plugin as A, PluginKey as T } from "@tiptap/pm/state";
|
|
3
|
+
import { DecorationSet as O, Decoration as L } from "@tiptap/pm/view";
|
|
4
|
+
import { k as pe, D as ue, a as he } from "./index-D-Ouz0vF.js";
|
|
5
|
+
import { jsx as R, Fragment as Z } from "react/jsx-runtime";
|
|
6
|
+
import { u as J, e as Q, A as $, i as fe } from "./index-BrsJsbds.js";
|
|
7
7
|
import "react";
|
|
8
8
|
import "./theme.js";
|
|
9
|
-
function
|
|
10
|
-
return new
|
|
9
|
+
function me(o = {}) {
|
|
10
|
+
return new N({
|
|
11
11
|
view(e) {
|
|
12
|
-
return new
|
|
12
|
+
return new ge(e, o);
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
class
|
|
16
|
+
class ge {
|
|
17
17
|
constructor(e, t) {
|
|
18
|
-
var
|
|
19
|
-
this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (
|
|
20
|
-
let
|
|
18
|
+
var n;
|
|
19
|
+
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) => {
|
|
20
|
+
let i = (s) => {
|
|
21
21
|
this[r](s);
|
|
22
22
|
};
|
|
23
|
-
return e.dom.addEventListener(r,
|
|
23
|
+
return e.dom.addEventListener(r, i), { name: r, handler: i };
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
destroy() {
|
|
@@ -33,33 +33,33 @@ class he {
|
|
|
33
33
|
e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
|
|
34
34
|
}
|
|
35
35
|
updateOverlay() {
|
|
36
|
-
let e = this.editorView.state.doc.resolve(this.cursorPos), t = !e.parent.inlineContent,
|
|
36
|
+
let e = this.editorView.state.doc.resolve(this.cursorPos), t = !e.parent.inlineContent, n, r = this.editorView.dom, i = r.getBoundingClientRect(), s = i.width / r.offsetWidth, l = i.height / r.offsetHeight;
|
|
37
37
|
if (t) {
|
|
38
|
-
let
|
|
39
|
-
if (
|
|
40
|
-
let
|
|
41
|
-
if (
|
|
42
|
-
let
|
|
43
|
-
|
|
38
|
+
let d = e.nodeBefore, u = e.nodeAfter;
|
|
39
|
+
if (d || u) {
|
|
40
|
+
let h = this.editorView.nodeDOM(this.cursorPos - (d ? d.nodeSize : 0));
|
|
41
|
+
if (h) {
|
|
42
|
+
let m = h.getBoundingClientRect(), y = d ? m.bottom : m.top;
|
|
43
|
+
d && u && (y = (y + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
|
|
44
44
|
let P = this.width / 2 * l;
|
|
45
|
-
|
|
45
|
+
n = { left: m.left, right: m.right, top: y - P, bottom: y + P };
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
if (!
|
|
50
|
-
let
|
|
51
|
-
|
|
49
|
+
if (!n) {
|
|
50
|
+
let d = this.editorView.coordsAtPos(this.cursorPos), u = this.width / 2 * s;
|
|
51
|
+
n = { left: d.left - u, right: d.left + u, top: d.top, bottom: d.bottom };
|
|
52
52
|
}
|
|
53
53
|
let a = this.editorView.dom.offsetParent;
|
|
54
54
|
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);
|
|
55
|
-
let
|
|
55
|
+
let c, p;
|
|
56
56
|
if (!a || a == document.body && getComputedStyle(a).position == "static")
|
|
57
|
-
|
|
57
|
+
c = -pageXOffset, p = -pageYOffset;
|
|
58
58
|
else {
|
|
59
|
-
let
|
|
60
|
-
|
|
59
|
+
let d = a.getBoundingClientRect(), u = d.width / a.offsetWidth, h = d.height / a.offsetHeight;
|
|
60
|
+
c = d.left - a.scrollLeft * u, p = d.top - a.scrollTop * h;
|
|
61
61
|
}
|
|
62
|
-
this.element.style.left = (
|
|
62
|
+
this.element.style.left = (n.left - c) / s + "px", this.element.style.top = (n.top - p) / l + "px", this.element.style.width = (n.right - n.left) / s + "px", this.element.style.height = (n.bottom - n.top) / l + "px";
|
|
63
63
|
}
|
|
64
64
|
scheduleRemoval(e) {
|
|
65
65
|
clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
|
|
@@ -67,11 +67,11 @@ class he {
|
|
|
67
67
|
dragover(e) {
|
|
68
68
|
if (!this.editorView.editable)
|
|
69
69
|
return;
|
|
70
|
-
let t = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }),
|
|
71
|
-
if (t && !
|
|
70
|
+
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, i = typeof r == "function" ? r(this.editorView, t, e) : r;
|
|
71
|
+
if (t && !i) {
|
|
72
72
|
let s = t.pos;
|
|
73
73
|
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
74
|
-
let l =
|
|
74
|
+
let l = se(this.editorView.state.doc, s, this.editorView.dragging.slice);
|
|
75
75
|
l != null && (s = l);
|
|
76
76
|
}
|
|
77
77
|
this.setCursor(s), this.scheduleRemoval(5e3);
|
|
@@ -87,7 +87,7 @@ class he {
|
|
|
87
87
|
this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
class
|
|
90
|
+
class f extends x {
|
|
91
91
|
/**
|
|
92
92
|
Create a gap cursor.
|
|
93
93
|
*/
|
|
@@ -95,14 +95,14 @@ class h extends T {
|
|
|
95
95
|
super(e, e);
|
|
96
96
|
}
|
|
97
97
|
map(e, t) {
|
|
98
|
-
let
|
|
99
|
-
return
|
|
98
|
+
let n = e.resolve(t.map(this.head));
|
|
99
|
+
return f.valid(n) ? new f(n) : x.near(n);
|
|
100
100
|
}
|
|
101
101
|
content() {
|
|
102
|
-
return
|
|
102
|
+
return W.empty;
|
|
103
103
|
}
|
|
104
104
|
eq(e) {
|
|
105
|
-
return e instanceof
|
|
105
|
+
return e instanceof f && e.head == this.head;
|
|
106
106
|
}
|
|
107
107
|
toJSON() {
|
|
108
108
|
return { type: "gapcursor", pos: this.head };
|
|
@@ -113,7 +113,7 @@ class h extends T {
|
|
|
113
113
|
static fromJSON(e, t) {
|
|
114
114
|
if (typeof t.pos != "number")
|
|
115
115
|
throw new RangeError("Invalid input for GapCursor.fromJSON");
|
|
116
|
-
return new
|
|
116
|
+
return new f(e.resolve(t.pos));
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
@internal
|
|
@@ -126,55 +126,55 @@ class h extends T {
|
|
|
126
126
|
*/
|
|
127
127
|
static valid(e) {
|
|
128
128
|
let t = e.parent;
|
|
129
|
-
if (t.inlineContent || !
|
|
129
|
+
if (t.inlineContent || !ve(e) || !we(e))
|
|
130
130
|
return !1;
|
|
131
|
-
let
|
|
132
|
-
if (
|
|
133
|
-
return
|
|
131
|
+
let n = t.type.spec.allowGapCursor;
|
|
132
|
+
if (n != null)
|
|
133
|
+
return n;
|
|
134
134
|
let r = t.contentMatchAt(e.index()).defaultType;
|
|
135
135
|
return r && r.isTextblock;
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
138
|
@internal
|
|
139
139
|
*/
|
|
140
|
-
static findGapCursorFrom(e, t,
|
|
140
|
+
static findGapCursorFrom(e, t, n = !1) {
|
|
141
141
|
e: for (; ; ) {
|
|
142
|
-
if (!
|
|
142
|
+
if (!n && f.valid(e))
|
|
143
143
|
return e;
|
|
144
|
-
let r = e.pos,
|
|
144
|
+
let r = e.pos, i = null;
|
|
145
145
|
for (let s = e.depth; ; s--) {
|
|
146
146
|
let l = e.node(s);
|
|
147
147
|
if (t > 0 ? e.indexAfter(s) < l.childCount : e.index(s) > 0) {
|
|
148
|
-
|
|
148
|
+
i = l.child(t > 0 ? e.indexAfter(s) : e.index(s) - 1);
|
|
149
149
|
break;
|
|
150
150
|
} else if (s == 0)
|
|
151
151
|
return null;
|
|
152
152
|
r += t;
|
|
153
153
|
let a = e.doc.resolve(r);
|
|
154
|
-
if (
|
|
154
|
+
if (f.valid(a))
|
|
155
155
|
return a;
|
|
156
156
|
}
|
|
157
157
|
for (; ; ) {
|
|
158
|
-
let s = t > 0 ?
|
|
158
|
+
let s = t > 0 ? i.firstChild : i.lastChild;
|
|
159
159
|
if (!s) {
|
|
160
|
-
if (
|
|
161
|
-
e = e.doc.resolve(r +
|
|
160
|
+
if (i.isAtom && !i.isText && !Y.isSelectable(i)) {
|
|
161
|
+
e = e.doc.resolve(r + i.nodeSize * t), n = !1;
|
|
162
162
|
continue e;
|
|
163
163
|
}
|
|
164
164
|
break;
|
|
165
165
|
}
|
|
166
|
-
|
|
166
|
+
i = s, r += t;
|
|
167
167
|
let l = e.doc.resolve(r);
|
|
168
|
-
if (
|
|
168
|
+
if (f.valid(l))
|
|
169
169
|
return l;
|
|
170
170
|
}
|
|
171
171
|
return null;
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
f.prototype.visible = !1;
|
|
176
|
+
f.findFrom = f.findGapCursorFrom;
|
|
177
|
+
x.jsonID("gapcursor", f);
|
|
178
178
|
class F {
|
|
179
179
|
constructor(e) {
|
|
180
180
|
this.pos = e;
|
|
@@ -184,22 +184,22 @@ class F {
|
|
|
184
184
|
}
|
|
185
185
|
resolve(e) {
|
|
186
186
|
let t = e.resolve(this.pos);
|
|
187
|
-
return
|
|
187
|
+
return f.valid(t) ? new f(t) : x.near(t);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
function
|
|
191
|
-
return
|
|
190
|
+
function q(o) {
|
|
191
|
+
return o.isAtom || o.spec.isolating || o.spec.createGapCursor;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
for (let e =
|
|
195
|
-
let t =
|
|
193
|
+
function ve(o) {
|
|
194
|
+
for (let e = o.depth; e >= 0; e--) {
|
|
195
|
+
let t = o.index(e), n = o.node(e);
|
|
196
196
|
if (t == 0) {
|
|
197
|
-
if (
|
|
197
|
+
if (n.type.spec.isolating)
|
|
198
198
|
return !0;
|
|
199
199
|
continue;
|
|
200
200
|
}
|
|
201
|
-
for (let r =
|
|
202
|
-
if (r.childCount == 0 && !r.inlineContent ||
|
|
201
|
+
for (let r = n.child(t - 1); ; r = r.lastChild) {
|
|
202
|
+
if (r.childCount == 0 && !r.inlineContent || q(r.type))
|
|
203
203
|
return !0;
|
|
204
204
|
if (r.inlineContent)
|
|
205
205
|
return !1;
|
|
@@ -207,16 +207,16 @@ function fe(n) {
|
|
|
207
207
|
}
|
|
208
208
|
return !0;
|
|
209
209
|
}
|
|
210
|
-
function
|
|
211
|
-
for (let e =
|
|
212
|
-
let t =
|
|
213
|
-
if (t ==
|
|
214
|
-
if (
|
|
210
|
+
function we(o) {
|
|
211
|
+
for (let e = o.depth; e >= 0; e--) {
|
|
212
|
+
let t = o.indexAfter(e), n = o.node(e);
|
|
213
|
+
if (t == n.childCount) {
|
|
214
|
+
if (n.type.spec.isolating)
|
|
215
215
|
return !0;
|
|
216
216
|
continue;
|
|
217
217
|
}
|
|
218
|
-
for (let r =
|
|
219
|
-
if (r.childCount == 0 && !r.inlineContent ||
|
|
218
|
+
for (let r = n.child(t); ; r = r.firstChild) {
|
|
219
|
+
if (r.childCount == 0 && !r.inlineContent || q(r.type))
|
|
220
220
|
return !0;
|
|
221
221
|
if (r.inlineContent)
|
|
222
222
|
return !1;
|
|
@@ -224,114 +224,114 @@ function me(n) {
|
|
|
224
224
|
}
|
|
225
225
|
return !0;
|
|
226
226
|
}
|
|
227
|
-
function
|
|
228
|
-
return new
|
|
227
|
+
function ye() {
|
|
228
|
+
return new N({
|
|
229
229
|
props: {
|
|
230
|
-
decorations:
|
|
231
|
-
createSelectionBetween(
|
|
232
|
-
return e.pos == t.pos &&
|
|
230
|
+
decorations: Ee,
|
|
231
|
+
createSelectionBetween(o, e, t) {
|
|
232
|
+
return e.pos == t.pos && f.valid(t) ? new f(t) : null;
|
|
233
233
|
},
|
|
234
|
-
handleClick:
|
|
235
|
-
handleKeyDown:
|
|
236
|
-
handleDOMEvents: { beforeinput:
|
|
234
|
+
handleClick: be,
|
|
235
|
+
handleKeyDown: Ce,
|
|
236
|
+
handleDOMEvents: { beforeinput: Pe }
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
|
-
const
|
|
241
|
-
ArrowLeft:
|
|
242
|
-
ArrowRight:
|
|
243
|
-
ArrowUp:
|
|
244
|
-
ArrowDown:
|
|
240
|
+
const Ce = pe({
|
|
241
|
+
ArrowLeft: I("horiz", -1),
|
|
242
|
+
ArrowRight: I("horiz", 1),
|
|
243
|
+
ArrowUp: I("vert", -1),
|
|
244
|
+
ArrowDown: I("vert", 1)
|
|
245
245
|
});
|
|
246
|
-
function
|
|
247
|
-
const t =
|
|
248
|
-
return function(
|
|
249
|
-
let s =
|
|
250
|
-
if (s instanceof
|
|
251
|
-
if (!
|
|
246
|
+
function I(o, e) {
|
|
247
|
+
const t = o == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
|
|
248
|
+
return function(n, r, i) {
|
|
249
|
+
let s = n.selection, l = e > 0 ? s.$to : s.$from, a = s.empty;
|
|
250
|
+
if (s instanceof j) {
|
|
251
|
+
if (!i.endOfTextblock(t) || l.depth == 0)
|
|
252
252
|
return !1;
|
|
253
|
-
a = !1, l =
|
|
253
|
+
a = !1, l = n.doc.resolve(e > 0 ? l.after() : l.before());
|
|
254
254
|
}
|
|
255
|
-
let
|
|
256
|
-
return
|
|
255
|
+
let c = f.findGapCursorFrom(l, e, a);
|
|
256
|
+
return c ? (r && r(n.tr.setSelection(new f(c))), !0) : !1;
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
|
-
function
|
|
260
|
-
if (!
|
|
259
|
+
function be(o, e, t) {
|
|
260
|
+
if (!o || !o.editable)
|
|
261
261
|
return !1;
|
|
262
|
-
let
|
|
263
|
-
if (!
|
|
262
|
+
let n = o.state.doc.resolve(e);
|
|
263
|
+
if (!f.valid(n))
|
|
264
264
|
return !1;
|
|
265
|
-
let r =
|
|
266
|
-
return r && r.inside > -1 &&
|
|
265
|
+
let r = o.posAtCoords({ left: t.clientX, top: t.clientY });
|
|
266
|
+
return r && r.inside > -1 && Y.isSelectable(o.state.doc.nodeAt(r.inside)) ? !1 : (o.dispatch(o.state.tr.setSelection(new f(n))), !0);
|
|
267
267
|
}
|
|
268
|
-
function
|
|
269
|
-
if (e.inputType != "insertCompositionText" || !(
|
|
268
|
+
function Pe(o, e) {
|
|
269
|
+
if (e.inputType != "insertCompositionText" || !(o.state.selection instanceof f))
|
|
270
270
|
return !1;
|
|
271
|
-
let { $from: t } =
|
|
272
|
-
if (!
|
|
271
|
+
let { $from: t } = o.state.selection, n = t.parent.contentMatchAt(t.index()).findWrapping(o.state.schema.nodes.text);
|
|
272
|
+
if (!n)
|
|
273
273
|
return !1;
|
|
274
|
-
let r =
|
|
275
|
-
for (let s =
|
|
276
|
-
r =
|
|
277
|
-
let
|
|
278
|
-
return
|
|
279
|
-
}
|
|
280
|
-
function
|
|
281
|
-
if (!(
|
|
274
|
+
let r = V.empty;
|
|
275
|
+
for (let s = n.length - 1; s >= 0; s--)
|
|
276
|
+
r = V.from(n[s].createAndFill(null, r));
|
|
277
|
+
let i = o.state.tr.replace(t.pos, t.pos, new W(r, 0, 0));
|
|
278
|
+
return i.setSelection(j.near(i.doc.resolve(t.pos + 1))), o.dispatch(i), !1;
|
|
279
|
+
}
|
|
280
|
+
function Ee(o) {
|
|
281
|
+
if (!(o.selection instanceof f))
|
|
282
282
|
return null;
|
|
283
283
|
let e = document.createElement("div");
|
|
284
|
-
return e.className = "ProseMirror-gapcursor",
|
|
284
|
+
return e.className = "ProseMirror-gapcursor", ue.create(o.doc, [he.widget(o.selection.head, e, { key: "gapcursor" })]);
|
|
285
285
|
}
|
|
286
|
-
var D = 200,
|
|
286
|
+
var D = 200, g = function() {
|
|
287
287
|
};
|
|
288
|
-
|
|
289
|
-
return e.length ? (e =
|
|
288
|
+
g.prototype.append = function(e) {
|
|
289
|
+
return e.length ? (e = g.from(e), !this.length && e || e.length < D && this.leafAppend(e) || this.length < D && e.leafPrepend(this) || this.appendInner(e)) : this;
|
|
290
290
|
};
|
|
291
|
-
|
|
292
|
-
return e.length ?
|
|
291
|
+
g.prototype.prepend = function(e) {
|
|
292
|
+
return e.length ? g.from(e).append(this) : this;
|
|
293
293
|
};
|
|
294
|
-
|
|
295
|
-
return new
|
|
294
|
+
g.prototype.appendInner = function(e) {
|
|
295
|
+
return new Me(this, e);
|
|
296
296
|
};
|
|
297
|
-
|
|
298
|
-
return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ?
|
|
297
|
+
g.prototype.slice = function(e, t) {
|
|
298
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ? g.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, t));
|
|
299
299
|
};
|
|
300
|
-
|
|
300
|
+
g.prototype.get = function(e) {
|
|
301
301
|
if (!(e < 0 || e >= this.length))
|
|
302
302
|
return this.getInner(e);
|
|
303
303
|
};
|
|
304
|
-
|
|
305
|
-
t === void 0 && (t = 0),
|
|
304
|
+
g.prototype.forEach = function(e, t, n) {
|
|
305
|
+
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);
|
|
306
306
|
};
|
|
307
|
-
|
|
308
|
-
t === void 0 && (t = 0),
|
|
307
|
+
g.prototype.map = function(e, t, n) {
|
|
308
|
+
t === void 0 && (t = 0), n === void 0 && (n = this.length);
|
|
309
309
|
var r = [];
|
|
310
|
-
return this.forEach(function(
|
|
311
|
-
return r.push(e(
|
|
312
|
-
}, t,
|
|
310
|
+
return this.forEach(function(i, s) {
|
|
311
|
+
return r.push(e(i, s));
|
|
312
|
+
}, t, n), r;
|
|
313
313
|
};
|
|
314
|
-
|
|
315
|
-
return e instanceof
|
|
314
|
+
g.from = function(e) {
|
|
315
|
+
return e instanceof g ? e : e && e.length ? new ee(e) : g.empty;
|
|
316
316
|
};
|
|
317
|
-
var
|
|
318
|
-
function e(
|
|
319
|
-
|
|
317
|
+
var ee = /* @__PURE__ */ (function(o) {
|
|
318
|
+
function e(n) {
|
|
319
|
+
o.call(this), this.values = n;
|
|
320
320
|
}
|
|
321
|
-
|
|
321
|
+
o && (e.__proto__ = o), e.prototype = Object.create(o && o.prototype), e.prototype.constructor = e;
|
|
322
322
|
var t = { length: { configurable: !0 }, depth: { configurable: !0 } };
|
|
323
323
|
return e.prototype.flatten = function() {
|
|
324
324
|
return this.values;
|
|
325
|
-
}, e.prototype.sliceInner = function(r,
|
|
326
|
-
return r == 0 &&
|
|
325
|
+
}, e.prototype.sliceInner = function(r, i) {
|
|
326
|
+
return r == 0 && i == this.length ? this : new e(this.values.slice(r, i));
|
|
327
327
|
}, e.prototype.getInner = function(r) {
|
|
328
328
|
return this.values[r];
|
|
329
|
-
}, e.prototype.forEachInner = function(r,
|
|
330
|
-
for (var a =
|
|
329
|
+
}, e.prototype.forEachInner = function(r, i, s, l) {
|
|
330
|
+
for (var a = i; a < s; a++)
|
|
331
331
|
if (r(this.values[a], l + a) === !1)
|
|
332
332
|
return !1;
|
|
333
|
-
}, e.prototype.forEachInvertedInner = function(r,
|
|
334
|
-
for (var a =
|
|
333
|
+
}, e.prototype.forEachInvertedInner = function(r, i, s, l) {
|
|
334
|
+
for (var a = i - 1; a >= s; a--)
|
|
335
335
|
if (r(this.values[a], l + a) === !1)
|
|
336
336
|
return !1;
|
|
337
337
|
}, e.prototype.leafAppend = function(r) {
|
|
@@ -345,42 +345,42 @@ var Q = /* @__PURE__ */ (function(n) {
|
|
|
345
345
|
}, t.depth.get = function() {
|
|
346
346
|
return 0;
|
|
347
347
|
}, Object.defineProperties(e.prototype, t), e;
|
|
348
|
-
})(
|
|
349
|
-
|
|
350
|
-
var
|
|
351
|
-
function e(t,
|
|
352
|
-
|
|
348
|
+
})(g);
|
|
349
|
+
g.empty = new ee([]);
|
|
350
|
+
var Me = /* @__PURE__ */ (function(o) {
|
|
351
|
+
function e(t, n) {
|
|
352
|
+
o.call(this), this.left = t, this.right = n, this.length = t.length + n.length, this.depth = Math.max(t.depth, n.depth) + 1;
|
|
353
353
|
}
|
|
354
|
-
return
|
|
354
|
+
return o && (e.__proto__ = o), e.prototype = Object.create(o && o.prototype), e.prototype.constructor = e, e.prototype.flatten = function() {
|
|
355
355
|
return this.left.flatten().concat(this.right.flatten());
|
|
356
|
-
}, e.prototype.getInner = function(
|
|
357
|
-
return
|
|
358
|
-
}, e.prototype.forEachInner = function(
|
|
356
|
+
}, e.prototype.getInner = function(n) {
|
|
357
|
+
return n < this.left.length ? this.left.get(n) : this.right.get(n - this.left.length);
|
|
358
|
+
}, e.prototype.forEachInner = function(n, r, i, s) {
|
|
359
359
|
var l = this.left.length;
|
|
360
|
-
if (r < l && this.left.forEachInner(
|
|
360
|
+
if (r < l && this.left.forEachInner(n, r, Math.min(i, l), s) === !1 || i > l && this.right.forEachInner(n, Math.max(r - l, 0), Math.min(this.length, i) - l, s + l) === !1)
|
|
361
361
|
return !1;
|
|
362
|
-
}, e.prototype.forEachInvertedInner = function(
|
|
362
|
+
}, e.prototype.forEachInvertedInner = function(n, r, i, s) {
|
|
363
363
|
var l = this.left.length;
|
|
364
|
-
if (r > l && this.right.forEachInvertedInner(
|
|
364
|
+
if (r > l && this.right.forEachInvertedInner(n, r - l, Math.max(i, l) - l, s + l) === !1 || i < l && this.left.forEachInvertedInner(n, Math.min(r, l), i, s) === !1)
|
|
365
365
|
return !1;
|
|
366
|
-
}, e.prototype.sliceInner = function(
|
|
367
|
-
if (
|
|
366
|
+
}, e.prototype.sliceInner = function(n, r) {
|
|
367
|
+
if (n == 0 && r == this.length)
|
|
368
368
|
return this;
|
|
369
|
-
var
|
|
370
|
-
return r <=
|
|
371
|
-
}, e.prototype.leafAppend = function(
|
|
372
|
-
var r = this.right.leafAppend(
|
|
369
|
+
var i = this.left.length;
|
|
370
|
+
return r <= i ? this.left.slice(n, r) : n >= i ? this.right.slice(n - i, r - i) : this.left.slice(n, i).append(this.right.slice(0, r - i));
|
|
371
|
+
}, e.prototype.leafAppend = function(n) {
|
|
372
|
+
var r = this.right.leafAppend(n);
|
|
373
373
|
if (r)
|
|
374
374
|
return new e(this.left, r);
|
|
375
|
-
}, e.prototype.leafPrepend = function(
|
|
376
|
-
var r = this.left.leafPrepend(
|
|
375
|
+
}, e.prototype.leafPrepend = function(n) {
|
|
376
|
+
var r = this.left.leafPrepend(n);
|
|
377
377
|
if (r)
|
|
378
378
|
return new e(r, this.right);
|
|
379
|
-
}, e.prototype.appendInner = function(
|
|
380
|
-
return this.left.depth >= Math.max(this.right.depth,
|
|
379
|
+
}, e.prototype.appendInner = function(n) {
|
|
380
|
+
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);
|
|
381
381
|
}, e;
|
|
382
|
-
})(
|
|
383
|
-
const
|
|
382
|
+
})(g);
|
|
383
|
+
const Ae = 500;
|
|
384
384
|
class v {
|
|
385
385
|
constructor(e, t) {
|
|
386
386
|
this.items = e, this.eventCount = t;
|
|
@@ -390,46 +390,46 @@ class v {
|
|
|
390
390
|
popEvent(e, t) {
|
|
391
391
|
if (this.eventCount == 0)
|
|
392
392
|
return null;
|
|
393
|
-
let
|
|
394
|
-
for (; ;
|
|
395
|
-
if (this.items.get(
|
|
396
|
-
--
|
|
393
|
+
let n = this.items.length;
|
|
394
|
+
for (; ; n--)
|
|
395
|
+
if (this.items.get(n - 1).selection) {
|
|
396
|
+
--n;
|
|
397
397
|
break;
|
|
398
398
|
}
|
|
399
|
-
let r,
|
|
400
|
-
t && (r = this.remapping(
|
|
401
|
-
let s = e.tr, l, a,
|
|
402
|
-
return this.items.forEach((
|
|
403
|
-
if (!
|
|
404
|
-
r || (r = this.remapping(
|
|
399
|
+
let r, i;
|
|
400
|
+
t && (r = this.remapping(n, this.items.length), i = r.maps.length);
|
|
401
|
+
let s = e.tr, l, a, c = [], p = [];
|
|
402
|
+
return this.items.forEach((d, u) => {
|
|
403
|
+
if (!d.step) {
|
|
404
|
+
r || (r = this.remapping(n, u + 1), i = r.maps.length), i--, p.push(d);
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
407
|
if (r) {
|
|
408
|
-
|
|
409
|
-
let
|
|
410
|
-
|
|
408
|
+
p.push(new w(d.map));
|
|
409
|
+
let h = d.step.map(r.slice(i)), m;
|
|
410
|
+
h && s.maybeStep(h).doc && (m = s.mapping.maps[s.mapping.maps.length - 1], c.push(new w(m, void 0, void 0, c.length + p.length))), i--, m && r.appendMap(m, i);
|
|
411
411
|
} else
|
|
412
|
-
s.maybeStep(
|
|
413
|
-
if (
|
|
414
|
-
return l = r ?
|
|
412
|
+
s.maybeStep(d.step);
|
|
413
|
+
if (d.selection)
|
|
414
|
+
return l = r ? d.selection.map(r.slice(i)) : d.selection, a = new v(this.items.slice(0, n).append(p.reverse().concat(c)), this.eventCount - 1), !1;
|
|
415
415
|
}, this.items.length, 0), { remaining: a, transform: s, selection: l };
|
|
416
416
|
}
|
|
417
417
|
// Create a new branch with the given transform added.
|
|
418
|
-
addTransform(e, t,
|
|
419
|
-
let
|
|
420
|
-
for (let
|
|
421
|
-
let
|
|
422
|
-
(
|
|
418
|
+
addTransform(e, t, n, r) {
|
|
419
|
+
let i = [], s = this.eventCount, l = this.items, a = !r && l.length ? l.get(l.length - 1) : null;
|
|
420
|
+
for (let p = 0; p < e.steps.length; p++) {
|
|
421
|
+
let d = e.steps[p].invert(e.docs[p]), u = new w(e.mapping.maps[p], d, t), h;
|
|
422
|
+
(h = a && a.merge(u)) && (u = h, p ? i.pop() : l = l.slice(0, l.length - 1)), i.push(u), t && (s++, t = void 0), r || (a = u);
|
|
423
423
|
}
|
|
424
|
-
let
|
|
425
|
-
return
|
|
424
|
+
let c = s - n.depth;
|
|
425
|
+
return c > Ie && (l = Te(l, c), s -= c), new v(l.append(i), s);
|
|
426
426
|
}
|
|
427
427
|
remapping(e, t) {
|
|
428
|
-
let
|
|
429
|
-
return this.items.forEach((r,
|
|
430
|
-
let s = r.mirrorOffset != null &&
|
|
431
|
-
|
|
432
|
-
}, e, t),
|
|
428
|
+
let n = new le();
|
|
429
|
+
return this.items.forEach((r, i) => {
|
|
430
|
+
let s = r.mirrorOffset != null && i - r.mirrorOffset >= e ? n.maps.length - r.mirrorOffset : void 0;
|
|
431
|
+
n.appendMap(r.map, s);
|
|
432
|
+
}, e, t), n;
|
|
433
433
|
}
|
|
434
434
|
addMaps(e) {
|
|
435
435
|
return this.eventCount == 0 ? this : new v(this.items.append(e.map((t) => new w(t))), this.eventCount);
|
|
@@ -441,28 +441,28 @@ class v {
|
|
|
441
441
|
rebased(e, t) {
|
|
442
442
|
if (!this.eventCount)
|
|
443
443
|
return this;
|
|
444
|
-
let
|
|
445
|
-
this.items.forEach((
|
|
446
|
-
|
|
444
|
+
let n = [], r = Math.max(0, this.items.length - t), i = e.mapping, s = e.steps.length, l = this.eventCount;
|
|
445
|
+
this.items.forEach((u) => {
|
|
446
|
+
u.selection && l--;
|
|
447
447
|
}, r);
|
|
448
448
|
let a = t;
|
|
449
|
-
this.items.forEach((
|
|
450
|
-
let
|
|
451
|
-
if (
|
|
449
|
+
this.items.forEach((u) => {
|
|
450
|
+
let h = i.getMirror(--a);
|
|
451
|
+
if (h == null)
|
|
452
452
|
return;
|
|
453
|
-
s = Math.min(s,
|
|
454
|
-
let
|
|
455
|
-
if (
|
|
456
|
-
let
|
|
457
|
-
P && l++,
|
|
453
|
+
s = Math.min(s, h);
|
|
454
|
+
let m = i.maps[h];
|
|
455
|
+
if (u.step) {
|
|
456
|
+
let y = e.steps[h].invert(e.docs[h]), P = u.selection && u.selection.map(i.slice(a + 1, h));
|
|
457
|
+
P && l++, n.push(new w(m, y, P));
|
|
458
458
|
} else
|
|
459
|
-
|
|
459
|
+
n.push(new w(m));
|
|
460
460
|
}, r);
|
|
461
|
-
let
|
|
462
|
-
for (let
|
|
463
|
-
|
|
464
|
-
let
|
|
465
|
-
return
|
|
461
|
+
let c = [];
|
|
462
|
+
for (let u = t; u < s; u++)
|
|
463
|
+
c.push(new w(i.maps[u]));
|
|
464
|
+
let p = this.items.slice(0, r).append(c).append(n), d = new v(p, l);
|
|
465
|
+
return d.emptyItemCount() > Ae && (d = d.compress(this.items.length - n.length)), d;
|
|
466
466
|
}
|
|
467
467
|
emptyItemCount() {
|
|
468
468
|
let e = 0;
|
|
@@ -477,33 +477,33 @@ class v {
|
|
|
477
477
|
// because `rebased` relies on a clean, untouched set of items in
|
|
478
478
|
// order to associate old items with rebased steps.
|
|
479
479
|
compress(e = this.items.length) {
|
|
480
|
-
let t = this.remapping(0, e),
|
|
480
|
+
let t = this.remapping(0, e), n = t.maps.length, r = [], i = 0;
|
|
481
481
|
return this.items.forEach((s, l) => {
|
|
482
482
|
if (l >= e)
|
|
483
|
-
r.push(s), s.selection &&
|
|
483
|
+
r.push(s), s.selection && i++;
|
|
484
484
|
else if (s.step) {
|
|
485
|
-
let a = s.step.map(t.slice(
|
|
486
|
-
if (
|
|
487
|
-
let
|
|
488
|
-
|
|
489
|
-
let
|
|
490
|
-
(
|
|
485
|
+
let a = s.step.map(t.slice(n)), c = a && a.getMap();
|
|
486
|
+
if (n--, c && t.appendMap(c, n), a) {
|
|
487
|
+
let p = s.selection && s.selection.map(t.slice(n));
|
|
488
|
+
p && i++;
|
|
489
|
+
let d = new w(c.invert(), a, p), u, h = r.length - 1;
|
|
490
|
+
(u = r.length && r[h].merge(d)) ? r[h] = u : r.push(d);
|
|
491
491
|
}
|
|
492
|
-
} else s.map &&
|
|
493
|
-
}, this.items.length, 0), new v(
|
|
492
|
+
} else s.map && n--;
|
|
493
|
+
}, this.items.length, 0), new v(g.from(r.reverse()), i);
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
v.empty = new v(
|
|
497
|
-
function
|
|
496
|
+
v.empty = new v(g.empty, 0);
|
|
497
|
+
function Te(o, e) {
|
|
498
498
|
let t;
|
|
499
|
-
return
|
|
500
|
-
if (
|
|
499
|
+
return o.forEach((n, r) => {
|
|
500
|
+
if (n.selection && e-- == 0)
|
|
501
501
|
return t = r, !1;
|
|
502
|
-
}),
|
|
502
|
+
}), o.slice(t);
|
|
503
503
|
}
|
|
504
504
|
class w {
|
|
505
|
-
constructor(e, t,
|
|
506
|
-
this.map = e, this.step = t, this.selection =
|
|
505
|
+
constructor(e, t, n, r) {
|
|
506
|
+
this.map = e, this.step = t, this.selection = n, this.mirrorOffset = r;
|
|
507
507
|
}
|
|
508
508
|
merge(e) {
|
|
509
509
|
if (this.step && e.step && !e.selection) {
|
|
@@ -513,66 +513,66 @@ class w {
|
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
|
-
class
|
|
517
|
-
constructor(e, t,
|
|
518
|
-
this.done = e, this.undone = t, this.prevRanges =
|
|
516
|
+
class C {
|
|
517
|
+
constructor(e, t, n, r, i) {
|
|
518
|
+
this.done = e, this.undone = t, this.prevRanges = n, this.prevTime = r, this.prevComposition = i;
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
|
-
const
|
|
522
|
-
function
|
|
523
|
-
let r = t.getMeta(E),
|
|
521
|
+
const Ie = 20;
|
|
522
|
+
function Se(o, e, t, n) {
|
|
523
|
+
let r = t.getMeta(E), i;
|
|
524
524
|
if (r)
|
|
525
525
|
return r.historyState;
|
|
526
|
-
t.getMeta(
|
|
526
|
+
t.getMeta(Re) && (o = new C(o.done, o.undone, null, 0, -1));
|
|
527
527
|
let s = t.getMeta("appendedTransaction");
|
|
528
528
|
if (t.steps.length == 0)
|
|
529
|
-
return
|
|
529
|
+
return o;
|
|
530
530
|
if (s && s.getMeta(E))
|
|
531
|
-
return s.getMeta(E).redo ? new
|
|
531
|
+
return s.getMeta(E).redo ? new C(o.done.addTransform(t, void 0, n, S(e)), o.undone, B(t.mapping.maps), o.prevTime, o.prevComposition) : new C(o.done, o.undone.addTransform(t, void 0, n, S(e)), null, o.prevTime, o.prevComposition);
|
|
532
532
|
if (t.getMeta("addToHistory") !== !1 && !(s && s.getMeta("addToHistory") === !1)) {
|
|
533
|
-
let l = t.getMeta("composition"), a =
|
|
534
|
-
return new
|
|
535
|
-
} else return (
|
|
533
|
+
let l = t.getMeta("composition"), a = o.prevTime == 0 || !s && o.prevComposition != l && (o.prevTime < (t.time || 0) - n.newGroupDelay || !xe(t, o.prevRanges)), c = s ? k(o.prevRanges, t.mapping) : B(t.mapping.maps);
|
|
534
|
+
return new C(o.done.addTransform(t, a ? e.selection.getBookmark() : void 0, n, S(e)), v.empty, c, t.time, l ?? o.prevComposition);
|
|
535
|
+
} else return (i = t.getMeta("rebased")) ? new C(o.done.rebased(t, i), o.undone.rebased(t, i), k(o.prevRanges, t.mapping), o.prevTime, o.prevComposition) : new C(o.done.addMaps(t.mapping.maps), o.undone.addMaps(t.mapping.maps), k(o.prevRanges, t.mapping), o.prevTime, o.prevComposition);
|
|
536
536
|
}
|
|
537
|
-
function
|
|
537
|
+
function xe(o, e) {
|
|
538
538
|
if (!e)
|
|
539
539
|
return !1;
|
|
540
|
-
if (!
|
|
540
|
+
if (!o.docChanged)
|
|
541
541
|
return !0;
|
|
542
542
|
let t = !1;
|
|
543
|
-
return
|
|
544
|
-
for (let
|
|
545
|
-
|
|
543
|
+
return o.mapping.maps[0].forEach((n, r) => {
|
|
544
|
+
for (let i = 0; i < e.length; i += 2)
|
|
545
|
+
n <= e[i + 1] && r >= e[i] && (t = !0);
|
|
546
546
|
}), t;
|
|
547
547
|
}
|
|
548
|
-
function
|
|
548
|
+
function B(o) {
|
|
549
549
|
let e = [];
|
|
550
|
-
for (let t =
|
|
551
|
-
|
|
550
|
+
for (let t = o.length - 1; t >= 0 && e.length == 0; t--)
|
|
551
|
+
o[t].forEach((n, r, i, s) => e.push(i, s));
|
|
552
552
|
return e;
|
|
553
553
|
}
|
|
554
|
-
function k(
|
|
555
|
-
if (!
|
|
554
|
+
function k(o, e) {
|
|
555
|
+
if (!o)
|
|
556
556
|
return null;
|
|
557
557
|
let t = [];
|
|
558
|
-
for (let
|
|
559
|
-
let r = e.map(n
|
|
560
|
-
r <=
|
|
558
|
+
for (let n = 0; n < o.length; n += 2) {
|
|
559
|
+
let r = e.map(o[n], 1), i = e.map(o[n + 1], -1);
|
|
560
|
+
r <= i && t.push(r, i);
|
|
561
561
|
}
|
|
562
562
|
return t;
|
|
563
563
|
}
|
|
564
|
-
function
|
|
565
|
-
let
|
|
566
|
-
if (!
|
|
564
|
+
function Oe(o, e, t) {
|
|
565
|
+
let n = S(e), r = E.get(e).spec.config, i = (t ? o.undone : o.done).popEvent(e, n);
|
|
566
|
+
if (!i)
|
|
567
567
|
return null;
|
|
568
|
-
let s =
|
|
569
|
-
return
|
|
570
|
-
}
|
|
571
|
-
let z = !1,
|
|
572
|
-
function
|
|
573
|
-
let e =
|
|
574
|
-
if (
|
|
575
|
-
z = !1,
|
|
568
|
+
let s = i.selection.resolve(i.transform.doc), l = (t ? o.done : o.undone).addTransform(i.transform, e.selection.getBookmark(), r, n), a = new C(t ? l : i.remaining, t ? i.remaining : l, null, 0, -1);
|
|
569
|
+
return i.transform.setSelection(s).setMeta(E, { redo: t, historyState: a });
|
|
570
|
+
}
|
|
571
|
+
let z = !1, K = null;
|
|
572
|
+
function S(o) {
|
|
573
|
+
let e = o.plugins;
|
|
574
|
+
if (K != e) {
|
|
575
|
+
z = !1, K = e;
|
|
576
576
|
for (let t = 0; t < e.length; t++)
|
|
577
577
|
if (e[t].spec.historyPreserveItems) {
|
|
578
578
|
z = !0;
|
|
@@ -581,53 +581,54 @@ function x(n) {
|
|
|
581
581
|
}
|
|
582
582
|
return z;
|
|
583
583
|
}
|
|
584
|
-
const E = new
|
|
585
|
-
function
|
|
586
|
-
return
|
|
587
|
-
depth:
|
|
588
|
-
newGroupDelay:
|
|
589
|
-
}, new
|
|
584
|
+
const E = new X("history"), Re = new X("closeHistory");
|
|
585
|
+
function De(o = {}) {
|
|
586
|
+
return o = {
|
|
587
|
+
depth: o.depth || 100,
|
|
588
|
+
newGroupDelay: o.newGroupDelay || 500
|
|
589
|
+
}, new N({
|
|
590
590
|
key: E,
|
|
591
591
|
state: {
|
|
592
592
|
init() {
|
|
593
|
-
return new
|
|
593
|
+
return new C(v.empty, v.empty, null, 0, -1);
|
|
594
594
|
},
|
|
595
|
-
apply(e, t,
|
|
596
|
-
return
|
|
595
|
+
apply(e, t, n) {
|
|
596
|
+
return Se(t, n, e, o);
|
|
597
597
|
}
|
|
598
598
|
},
|
|
599
|
-
config:
|
|
599
|
+
config: o,
|
|
600
600
|
props: {
|
|
601
601
|
handleDOMEvents: {
|
|
602
602
|
beforeinput(e, t) {
|
|
603
|
-
let
|
|
603
|
+
let n = t.inputType, r = n == "historyUndo" ? ne : n == "historyRedo" ? oe : null;
|
|
604
604
|
return !r || !e.editable ? !1 : (t.preventDefault(), r(e.state, e.dispatch));
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
607
|
}
|
|
608
608
|
});
|
|
609
609
|
}
|
|
610
|
-
function
|
|
611
|
-
return (t,
|
|
610
|
+
function te(o, e) {
|
|
611
|
+
return (t, n) => {
|
|
612
612
|
let r = E.getState(t);
|
|
613
|
-
if (!r || (
|
|
613
|
+
if (!r || (o ? r.undone : r.done).eventCount == 0)
|
|
614
614
|
return !1;
|
|
615
|
-
if (
|
|
616
|
-
let
|
|
617
|
-
|
|
615
|
+
if (n) {
|
|
616
|
+
let i = Oe(r, t, o);
|
|
617
|
+
i && n(e ? i.scrollIntoView() : i);
|
|
618
618
|
}
|
|
619
619
|
return !0;
|
|
620
620
|
};
|
|
621
621
|
}
|
|
622
|
-
const
|
|
623
|
-
|
|
622
|
+
const ne = te(!1, !0), oe = te(!0, !0);
|
|
623
|
+
b.create({
|
|
624
624
|
name: "characterCount",
|
|
625
625
|
addOptions() {
|
|
626
626
|
return {
|
|
627
627
|
limit: null,
|
|
628
|
+
autoTrim: !0,
|
|
628
629
|
mode: "textSize",
|
|
629
|
-
textCounter: (
|
|
630
|
-
wordCounter: (
|
|
630
|
+
textCounter: (o) => o.length,
|
|
631
|
+
wordCounter: (o) => o.split(" ").filter((e) => e !== "").length
|
|
631
632
|
};
|
|
632
633
|
},
|
|
633
634
|
addStorage() {
|
|
@@ -637,59 +638,59 @@ C.create({
|
|
|
637
638
|
};
|
|
638
639
|
},
|
|
639
640
|
onBeforeCreate() {
|
|
640
|
-
this.storage.characters = (
|
|
641
|
-
const e = (
|
|
642
|
-
if (((
|
|
643
|
-
const
|
|
644
|
-
return this.options.textCounter(
|
|
641
|
+
this.storage.characters = (o) => {
|
|
642
|
+
const e = (o == null ? void 0 : o.node) || this.editor.state.doc;
|
|
643
|
+
if (((o == null ? void 0 : o.mode) || this.options.mode) === "textSize") {
|
|
644
|
+
const n = e.textBetween(0, e.content.size, void 0, " ");
|
|
645
|
+
return this.options.textCounter(n);
|
|
645
646
|
}
|
|
646
647
|
return e.nodeSize;
|
|
647
|
-
}, this.storage.words = (
|
|
648
|
-
const e = (
|
|
648
|
+
}, this.storage.words = (o) => {
|
|
649
|
+
const e = (o == null ? void 0 : o.node) || this.editor.state.doc, t = e.textBetween(0, e.content.size, " ", " ");
|
|
649
650
|
return this.options.wordCounter(t);
|
|
650
651
|
};
|
|
651
652
|
},
|
|
652
653
|
addProseMirrorPlugins() {
|
|
653
|
-
let
|
|
654
|
+
let o = !1;
|
|
654
655
|
return [
|
|
655
656
|
new A({
|
|
656
|
-
key: new
|
|
657
|
-
appendTransaction: (e, t,
|
|
658
|
-
if (
|
|
657
|
+
key: new T("characterCount"),
|
|
658
|
+
appendTransaction: (e, t, n) => {
|
|
659
|
+
if (o)
|
|
659
660
|
return;
|
|
660
|
-
const r = this.options.limit;
|
|
661
|
-
if (r == null || r === 0) {
|
|
662
|
-
|
|
661
|
+
const r = this.options.limit, i = this.options.autoTrim;
|
|
662
|
+
if (r == null || r === 0 || i === !1) {
|
|
663
|
+
o = !0;
|
|
663
664
|
return;
|
|
664
665
|
}
|
|
665
|
-
const
|
|
666
|
-
if (
|
|
667
|
-
const
|
|
666
|
+
const s = this.storage.characters({ node: n.doc });
|
|
667
|
+
if (s > r) {
|
|
668
|
+
const l = s - r, a = 0, c = l;
|
|
668
669
|
console.warn(
|
|
669
670
|
`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`
|
|
670
671
|
);
|
|
671
|
-
const
|
|
672
|
-
return
|
|
672
|
+
const p = n.tr.deleteRange(a, c);
|
|
673
|
+
return o = !0, p;
|
|
673
674
|
}
|
|
674
|
-
|
|
675
|
+
o = !0;
|
|
675
676
|
},
|
|
676
677
|
filterTransaction: (e, t) => {
|
|
677
|
-
const
|
|
678
|
-
if (!e.docChanged ||
|
|
678
|
+
const n = this.options.limit;
|
|
679
|
+
if (!e.docChanged || n === 0 || n === null || n === void 0)
|
|
679
680
|
return !0;
|
|
680
|
-
const r = this.storage.characters({ node: t.doc }),
|
|
681
|
-
if (
|
|
681
|
+
const r = this.storage.characters({ node: t.doc }), i = this.storage.characters({ node: e.doc });
|
|
682
|
+
if (i <= n || r > n && i > n && i <= r)
|
|
682
683
|
return !0;
|
|
683
|
-
if (r >
|
|
684
|
+
if (r > n && i > n && i > r || !e.getMeta("paste"))
|
|
684
685
|
return !1;
|
|
685
|
-
const l = e.selection.$head.pos, a =
|
|
686
|
-
return e.deleteRange(
|
|
686
|
+
const l = e.selection.$head.pos, a = i - n, c = l - a, p = l;
|
|
687
|
+
return e.deleteRange(c, p), !(this.storage.characters({ node: e.doc }) > n);
|
|
687
688
|
}
|
|
688
689
|
})
|
|
689
690
|
];
|
|
690
691
|
}
|
|
691
692
|
});
|
|
692
|
-
|
|
693
|
+
b.create({
|
|
693
694
|
name: "dropCursor",
|
|
694
695
|
addOptions() {
|
|
695
696
|
return {
|
|
@@ -699,10 +700,10 @@ C.create({
|
|
|
699
700
|
};
|
|
700
701
|
},
|
|
701
702
|
addProseMirrorPlugins() {
|
|
702
|
-
return [
|
|
703
|
+
return [me(this.options)];
|
|
703
704
|
}
|
|
704
705
|
});
|
|
705
|
-
|
|
706
|
+
b.create({
|
|
706
707
|
name: "focus",
|
|
707
708
|
addOptions() {
|
|
708
709
|
return {
|
|
@@ -713,66 +714,137 @@ C.create({
|
|
|
713
714
|
addProseMirrorPlugins() {
|
|
714
715
|
return [
|
|
715
716
|
new A({
|
|
716
|
-
key: new
|
|
717
|
+
key: new T("focus"),
|
|
717
718
|
props: {
|
|
718
|
-
decorations: ({ doc:
|
|
719
|
-
const { isEditable: t, isFocused:
|
|
720
|
-
if (!t || !
|
|
721
|
-
return
|
|
719
|
+
decorations: ({ doc: o, selection: e }) => {
|
|
720
|
+
const { isEditable: t, isFocused: n } = this.editor, { anchor: r } = e, i = [];
|
|
721
|
+
if (!t || !n)
|
|
722
|
+
return O.create(o, []);
|
|
722
723
|
let s = 0;
|
|
723
|
-
this.options.mode === "deepest" &&
|
|
724
|
+
this.options.mode === "deepest" && o.descendants((a, c) => {
|
|
724
725
|
if (a.isText)
|
|
725
726
|
return;
|
|
726
|
-
if (!(r >=
|
|
727
|
+
if (!(r >= c && r <= c + a.nodeSize - 1))
|
|
727
728
|
return !1;
|
|
728
729
|
s += 1;
|
|
729
730
|
});
|
|
730
731
|
let l = 0;
|
|
731
|
-
return
|
|
732
|
-
if (a.isText || !(r >=
|
|
732
|
+
return o.descendants((a, c) => {
|
|
733
|
+
if (a.isText || !(r >= c && r <= c + a.nodeSize - 1))
|
|
733
734
|
return !1;
|
|
734
735
|
if (l += 1, this.options.mode === "deepest" && s - l > 0 || this.options.mode === "shallowest" && l > 1)
|
|
735
736
|
return this.options.mode === "deepest";
|
|
736
|
-
|
|
737
|
-
|
|
737
|
+
i.push(
|
|
738
|
+
L.node(c, c + a.nodeSize, {
|
|
738
739
|
class: this.options.className
|
|
739
740
|
})
|
|
740
741
|
);
|
|
741
|
-
}),
|
|
742
|
+
}), O.create(o, i);
|
|
742
743
|
}
|
|
743
744
|
}
|
|
744
745
|
})
|
|
745
746
|
];
|
|
746
747
|
}
|
|
747
748
|
});
|
|
748
|
-
|
|
749
|
+
b.create({
|
|
749
750
|
name: "gapCursor",
|
|
750
751
|
addProseMirrorPlugins() {
|
|
751
|
-
return [
|
|
752
|
+
return [ye()];
|
|
752
753
|
},
|
|
753
|
-
extendNodeSchema(
|
|
754
|
+
extendNodeSchema(o) {
|
|
754
755
|
var e;
|
|
755
756
|
const t = {
|
|
756
|
-
name:
|
|
757
|
-
options:
|
|
758
|
-
storage:
|
|
757
|
+
name: o.name,
|
|
758
|
+
options: o.options,
|
|
759
|
+
storage: o.storage
|
|
759
760
|
};
|
|
760
761
|
return {
|
|
761
|
-
allowGapCursor: (e =
|
|
762
|
+
allowGapCursor: (e = ae(ce(o, "allowGapCursor", t))) != null ? e : null
|
|
762
763
|
};
|
|
763
764
|
}
|
|
764
765
|
});
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
766
|
+
function H(o) {
|
|
767
|
+
const {
|
|
768
|
+
editor: e,
|
|
769
|
+
placeholder: t,
|
|
770
|
+
dataAttribute: n,
|
|
771
|
+
pos: r,
|
|
772
|
+
node: i,
|
|
773
|
+
isEmptyDoc: s,
|
|
774
|
+
hasAnchor: l,
|
|
775
|
+
classes: { emptyNode: a, emptyEditor: c }
|
|
776
|
+
} = o, p = [a];
|
|
777
|
+
return s && p.push(c), L.node(r, r + i.nodeSize, {
|
|
778
|
+
class: p.join(" "),
|
|
779
|
+
[n]: typeof t == "function" ? t({
|
|
780
|
+
editor: e,
|
|
781
|
+
node: i,
|
|
782
|
+
pos: r,
|
|
783
|
+
hasAnchor: l
|
|
784
|
+
}) : t
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
function ke(o) {
|
|
788
|
+
const e = getComputedStyle(o), t = `${e.overflow} ${e.overflowY} ${e.overflowX}`;
|
|
789
|
+
return /auto|scroll|overlay/.test(t);
|
|
790
|
+
}
|
|
791
|
+
function ze(o) {
|
|
792
|
+
let e = o;
|
|
793
|
+
for (; e; ) {
|
|
794
|
+
if (ke(e))
|
|
795
|
+
return e;
|
|
796
|
+
const t = e.parentElement;
|
|
797
|
+
if (!t) {
|
|
798
|
+
const n = e.getRootNode();
|
|
799
|
+
if (n instanceof ShadowRoot) {
|
|
800
|
+
e = n.host;
|
|
801
|
+
continue;
|
|
802
|
+
}
|
|
803
|
+
return window;
|
|
804
|
+
}
|
|
805
|
+
e = t;
|
|
806
|
+
}
|
|
807
|
+
return window;
|
|
768
808
|
}
|
|
769
|
-
|
|
809
|
+
function Ne(o) {
|
|
810
|
+
return o === window ? { top: 0, bottom: window.innerHeight } : o.getBoundingClientRect();
|
|
811
|
+
}
|
|
812
|
+
function Le({
|
|
813
|
+
doc: o,
|
|
814
|
+
view: e,
|
|
815
|
+
scrollContainer: t
|
|
816
|
+
}) {
|
|
817
|
+
const n = e.dom.getBoundingClientRect(), r = t ? Ne(t) : { top: 0, bottom: window.innerHeight }, i = Math.max(n.top, r.top), s = Math.min(n.bottom, r.bottom);
|
|
818
|
+
if (i >= s)
|
|
819
|
+
return { top: 0, bottom: o.content.size };
|
|
820
|
+
const a = getComputedStyle(e.dom).direction === "rtl" ? Math.max(n.right - 2, n.left + 2) : n.left + 2, c = e.posAtCoords({ left: a, top: i + 2 }), p = e.posAtCoords({ left: a, top: s - 2 });
|
|
821
|
+
return {
|
|
822
|
+
top: c ? c.pos : 0,
|
|
823
|
+
bottom: p ? p.pos : o.content.size
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
function Fe(o, e) {
|
|
827
|
+
let t = null;
|
|
828
|
+
return { call: ((...i) => {
|
|
829
|
+
t || (o(...i), t = setTimeout(() => {
|
|
830
|
+
t = null;
|
|
831
|
+
}, e));
|
|
832
|
+
}), cancel: () => {
|
|
833
|
+
t && (clearTimeout(t), t = null);
|
|
834
|
+
} };
|
|
835
|
+
}
|
|
836
|
+
var G = "placeholder";
|
|
837
|
+
function Ve(o) {
|
|
838
|
+
return o.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
|
|
839
|
+
}
|
|
840
|
+
var M = new T("tiptap__placeholder");
|
|
841
|
+
b.create({
|
|
770
842
|
name: "placeholder",
|
|
771
843
|
addOptions() {
|
|
772
844
|
return {
|
|
773
845
|
emptyEditorClass: "is-editor-empty",
|
|
774
846
|
emptyNodeClass: "is-empty",
|
|
775
|
-
dataAttribute:
|
|
847
|
+
dataAttribute: G,
|
|
776
848
|
placeholder: "Write something …",
|
|
777
849
|
showOnlyWhenEditable: !0,
|
|
778
850
|
showOnlyCurrent: !0,
|
|
@@ -780,43 +852,108 @@ C.create({
|
|
|
780
852
|
};
|
|
781
853
|
},
|
|
782
854
|
addProseMirrorPlugins() {
|
|
783
|
-
const
|
|
855
|
+
const o = this.options.dataAttribute ? `data-${Ve(this.options.dataAttribute)}` : `data-${G}`;
|
|
784
856
|
return [
|
|
785
857
|
new A({
|
|
786
|
-
|
|
858
|
+
state: {
|
|
859
|
+
init() {
|
|
860
|
+
return {
|
|
861
|
+
// null means "no viewport info yet" — decoration callback falls
|
|
862
|
+
// back to full document scan until the scroll handler fires.
|
|
863
|
+
topPos: null,
|
|
864
|
+
bottomPos: null
|
|
865
|
+
};
|
|
866
|
+
},
|
|
867
|
+
apply(e, t) {
|
|
868
|
+
const n = e.getMeta(M);
|
|
869
|
+
return n != null && n.positions ? {
|
|
870
|
+
topPos: n.positions.top,
|
|
871
|
+
bottomPos: n.positions.bottom
|
|
872
|
+
} : e.docChanged ? {
|
|
873
|
+
topPos: t.topPos !== null ? e.mapping.map(t.topPos) : null,
|
|
874
|
+
bottomPos: t.bottomPos !== null ? e.mapping.map(t.bottomPos) : null
|
|
875
|
+
} : t;
|
|
876
|
+
}
|
|
877
|
+
},
|
|
878
|
+
key: M,
|
|
879
|
+
view(e) {
|
|
880
|
+
const t = ze(e.dom), n = () => {
|
|
881
|
+
const l = Le({
|
|
882
|
+
view: e,
|
|
883
|
+
doc: e.state.doc,
|
|
884
|
+
scrollContainer: t
|
|
885
|
+
}), a = M.getState(e.state);
|
|
886
|
+
if (a.topPos === l.top && a.bottomPos === l.bottom)
|
|
887
|
+
return;
|
|
888
|
+
const c = e.state.tr.setMeta(M, { positions: l }).setMeta("tiptap__viewportUpdate", !0);
|
|
889
|
+
e.dispatch(c);
|
|
890
|
+
}, { call: r, cancel: i } = Fe(n, 250), s = t;
|
|
891
|
+
return s.addEventListener("scroll", r, { passive: !0 }), n(), {
|
|
892
|
+
update(l, a) {
|
|
893
|
+
e.state.doc.content.size !== a.doc.content.size && n();
|
|
894
|
+
},
|
|
895
|
+
destroy: () => {
|
|
896
|
+
i(), s.removeEventListener("scroll", r);
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
},
|
|
787
900
|
props: {
|
|
788
901
|
decorations: ({ doc: e, selection: t }) => {
|
|
789
|
-
|
|
790
|
-
if (!
|
|
902
|
+
var n, r;
|
|
903
|
+
if (!(this.editor.isEditable || !this.options.showOnlyWhenEditable))
|
|
791
904
|
return null;
|
|
792
|
-
const s = this.editor.isEmpty;
|
|
793
|
-
|
|
794
|
-
const
|
|
795
|
-
if (
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
905
|
+
const { anchor: s } = t, l = [], a = this.editor.isEmpty;
|
|
906
|
+
if (this.options.showOnlyCurrent && !this.options.includeChildren) {
|
|
907
|
+
const p = e.resolve(s);
|
|
908
|
+
if (p.depth > 0) {
|
|
909
|
+
const d = p.node(1), u = p.before(1);
|
|
910
|
+
if (d.type.isTextblock && _(d)) {
|
|
911
|
+
const h = s >= u && s <= u + d.nodeSize, m = H({
|
|
912
|
+
node: d,
|
|
913
|
+
dataAttribute: o,
|
|
914
|
+
hasAnchor: h,
|
|
915
|
+
placeholder: this.options.placeholder,
|
|
916
|
+
classes: {
|
|
917
|
+
emptyEditor: this.options.emptyEditorClass,
|
|
918
|
+
emptyNode: this.options.emptyNodeClass
|
|
919
|
+
},
|
|
803
920
|
editor: this.editor,
|
|
804
|
-
|
|
805
|
-
pos:
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
}
|
|
809
|
-
o.push(p);
|
|
921
|
+
isEmptyDoc: a,
|
|
922
|
+
pos: p.before(1)
|
|
923
|
+
});
|
|
924
|
+
l.push(m);
|
|
925
|
+
}
|
|
810
926
|
}
|
|
811
|
-
|
|
812
|
-
|
|
927
|
+
} else {
|
|
928
|
+
const p = M.getState(this.editor.state), d = (n = p.topPos) != null ? n : 0, u = (r = p.bottomPos) != null ? r : e.content.size;
|
|
929
|
+
e.nodesBetween(d, u, (h, m) => {
|
|
930
|
+
const y = s >= m && s <= m + h.nodeSize, P = !h.isLeaf && _(h);
|
|
931
|
+
if (!h.type.isTextblock)
|
|
932
|
+
return this.options.includeChildren;
|
|
933
|
+
if ((y || !this.options.showOnlyCurrent) && P) {
|
|
934
|
+
const ie = H({
|
|
935
|
+
classes: { emptyEditor: this.options.emptyEditorClass, emptyNode: this.options.emptyNodeClass },
|
|
936
|
+
editor: this.editor,
|
|
937
|
+
isEmptyDoc: a,
|
|
938
|
+
dataAttribute: o,
|
|
939
|
+
hasAnchor: y,
|
|
940
|
+
placeholder: this.options.placeholder,
|
|
941
|
+
node: h,
|
|
942
|
+
pos: m
|
|
943
|
+
});
|
|
944
|
+
l.push(ie);
|
|
945
|
+
}
|
|
946
|
+
return this.options.includeChildren;
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
return O.create(e, l);
|
|
813
950
|
}
|
|
814
951
|
}
|
|
815
952
|
})
|
|
816
953
|
];
|
|
817
954
|
}
|
|
818
955
|
});
|
|
819
|
-
|
|
956
|
+
b.create({
|
|
820
957
|
name: "selection",
|
|
821
958
|
addOptions() {
|
|
822
959
|
return {
|
|
@@ -824,14 +961,14 @@ C.create({
|
|
|
824
961
|
};
|
|
825
962
|
},
|
|
826
963
|
addProseMirrorPlugins() {
|
|
827
|
-
const { editor:
|
|
964
|
+
const { editor: o, options: e } = this;
|
|
828
965
|
return [
|
|
829
966
|
new A({
|
|
830
|
-
key: new
|
|
967
|
+
key: new T("selection"),
|
|
831
968
|
props: {
|
|
832
969
|
decorations(t) {
|
|
833
|
-
return t.selection.empty ||
|
|
834
|
-
|
|
970
|
+
return t.selection.empty || o.isFocused || !o.isEditable || de(t.selection) || o.view.dragging ? null : O.create(t.doc, [
|
|
971
|
+
L.inline(t.selection.from, t.selection.to, {
|
|
835
972
|
class: e.className
|
|
836
973
|
})
|
|
837
974
|
]);
|
|
@@ -841,10 +978,11 @@ C.create({
|
|
|
841
978
|
];
|
|
842
979
|
}
|
|
843
980
|
});
|
|
844
|
-
|
|
845
|
-
|
|
981
|
+
var _e = "skipTrailingNode";
|
|
982
|
+
function U({ types: o, node: e }) {
|
|
983
|
+
return e && Array.isArray(o) && o.includes(e.type) || (e == null ? void 0 : e.type) === o;
|
|
846
984
|
}
|
|
847
|
-
|
|
985
|
+
b.create({
|
|
848
986
|
name: "trailingNode",
|
|
849
987
|
addOptions() {
|
|
850
988
|
return {
|
|
@@ -853,33 +991,33 @@ C.create({
|
|
|
853
991
|
};
|
|
854
992
|
},
|
|
855
993
|
addProseMirrorPlugins() {
|
|
856
|
-
var
|
|
857
|
-
const e = new
|
|
994
|
+
var o;
|
|
995
|
+
const e = new T(this.name), t = this.options.node || ((o = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : o.name) || "paragraph", n = Object.entries(this.editor.schema.nodes).map(([, r]) => r).filter((r) => (this.options.notAfter || []).concat(t).includes(r.name));
|
|
858
996
|
return [
|
|
859
997
|
new A({
|
|
860
998
|
key: e,
|
|
861
|
-
appendTransaction: (r,
|
|
862
|
-
const { doc: l, tr: a, schema:
|
|
863
|
-
if (
|
|
864
|
-
return a.insert(
|
|
999
|
+
appendTransaction: (r, i, s) => {
|
|
1000
|
+
const { doc: l, tr: a, schema: c } = s, p = e.getState(s), d = l.content.size, u = c.nodes[t];
|
|
1001
|
+
if (!r.some((h) => h.getMeta(_e)) && p)
|
|
1002
|
+
return a.insert(d, u.create());
|
|
865
1003
|
},
|
|
866
1004
|
state: {
|
|
867
|
-
init: (r,
|
|
868
|
-
const s =
|
|
869
|
-
return !
|
|
1005
|
+
init: (r, i) => {
|
|
1006
|
+
const s = i.tr.doc.lastChild;
|
|
1007
|
+
return !U({ node: s, types: n });
|
|
870
1008
|
},
|
|
871
|
-
apply: (r,
|
|
1009
|
+
apply: (r, i) => {
|
|
872
1010
|
if (!r.docChanged || r.getMeta("__uniqueIDTransaction"))
|
|
873
|
-
return
|
|
1011
|
+
return i;
|
|
874
1012
|
const s = r.doc.lastChild;
|
|
875
|
-
return !
|
|
1013
|
+
return !U({ node: s, types: n });
|
|
876
1014
|
}
|
|
877
1015
|
}
|
|
878
1016
|
})
|
|
879
1017
|
];
|
|
880
1018
|
}
|
|
881
1019
|
});
|
|
882
|
-
var
|
|
1020
|
+
var Be = b.create({
|
|
883
1021
|
name: "undoRedo",
|
|
884
1022
|
addOptions() {
|
|
885
1023
|
return {
|
|
@@ -889,12 +1027,12 @@ var De = C.create({
|
|
|
889
1027
|
},
|
|
890
1028
|
addCommands() {
|
|
891
1029
|
return {
|
|
892
|
-
undo: () => ({ state:
|
|
893
|
-
redo: () => ({ state:
|
|
1030
|
+
undo: () => ({ state: o, dispatch: e }) => ne(o, e),
|
|
1031
|
+
redo: () => ({ state: o, dispatch: e }) => oe(o, e)
|
|
894
1032
|
};
|
|
895
1033
|
},
|
|
896
1034
|
addProseMirrorPlugins() {
|
|
897
|
-
return [
|
|
1035
|
+
return [De(this.options)];
|
|
898
1036
|
},
|
|
899
1037
|
addKeyboardShortcuts() {
|
|
900
1038
|
return {
|
|
@@ -907,71 +1045,71 @@ var De = C.create({
|
|
|
907
1045
|
};
|
|
908
1046
|
}
|
|
909
1047
|
});
|
|
910
|
-
function
|
|
911
|
-
var
|
|
912
|
-
const
|
|
1048
|
+
function Ze() {
|
|
1049
|
+
var p;
|
|
1050
|
+
const o = J(re.name), {
|
|
913
1051
|
icon: e = void 0,
|
|
914
1052
|
tooltip: t = void 0,
|
|
915
|
-
shortcutKeys:
|
|
1053
|
+
shortcutKeys: n = void 0,
|
|
916
1054
|
tooltipOptions: r = {},
|
|
917
|
-
action:
|
|
1055
|
+
action: i = void 0,
|
|
918
1056
|
isActive: s = void 0
|
|
919
|
-
} = ((
|
|
920
|
-
l ||
|
|
1057
|
+
} = ((p = o == null ? void 0 : o.componentProps) == null ? void 0 : p.undo) ?? {}, { disabled: l } = Q(s), a = fe[e], c = () => {
|
|
1058
|
+
l || i && i();
|
|
921
1059
|
};
|
|
922
|
-
return !
|
|
923
|
-
|
|
1060
|
+
return !o || !a ? /* @__PURE__ */ R(Z, {}) : /* @__PURE__ */ R(
|
|
1061
|
+
$,
|
|
924
1062
|
{
|
|
925
|
-
action:
|
|
1063
|
+
action: c,
|
|
926
1064
|
disabled: l,
|
|
927
1065
|
icon: e,
|
|
928
|
-
shortcutKeys:
|
|
1066
|
+
shortcutKeys: n,
|
|
929
1067
|
tooltip: t,
|
|
930
1068
|
tooltipOptions: r
|
|
931
1069
|
}
|
|
932
1070
|
);
|
|
933
1071
|
}
|
|
934
|
-
function
|
|
935
|
-
var
|
|
936
|
-
const
|
|
1072
|
+
function Je() {
|
|
1073
|
+
var c;
|
|
1074
|
+
const o = J(re.name), {
|
|
937
1075
|
icon: e = void 0,
|
|
938
1076
|
tooltip: t = void 0,
|
|
939
|
-
shortcutKeys:
|
|
1077
|
+
shortcutKeys: n = void 0,
|
|
940
1078
|
tooltipOptions: r = {},
|
|
941
|
-
action:
|
|
1079
|
+
action: i = void 0,
|
|
942
1080
|
isActive: s = void 0
|
|
943
|
-
} = ((
|
|
944
|
-
l ||
|
|
1081
|
+
} = ((c = o == null ? void 0 : o.componentProps) == null ? void 0 : c.redo) ?? {}, { disabled: l } = Q(s), a = () => {
|
|
1082
|
+
l || i && i();
|
|
945
1083
|
};
|
|
946
|
-
return
|
|
947
|
-
|
|
1084
|
+
return o ? /* @__PURE__ */ R(
|
|
1085
|
+
$,
|
|
948
1086
|
{
|
|
949
1087
|
action: a,
|
|
950
1088
|
disabled: l,
|
|
951
1089
|
icon: e,
|
|
952
|
-
shortcutKeys:
|
|
1090
|
+
shortcutKeys: n,
|
|
953
1091
|
tooltip: t,
|
|
954
1092
|
tooltipOptions: r
|
|
955
1093
|
}
|
|
956
|
-
) : /* @__PURE__ */
|
|
1094
|
+
) : /* @__PURE__ */ R(Z, {});
|
|
957
1095
|
}
|
|
958
|
-
const
|
|
1096
|
+
const re = /* @__PURE__ */ Be.extend({
|
|
959
1097
|
//@ts-expect-error
|
|
960
1098
|
addOptions() {
|
|
961
|
-
var
|
|
1099
|
+
var o;
|
|
962
1100
|
return {
|
|
963
|
-
...(
|
|
1101
|
+
...(o = this.parent) == null ? void 0 : o.call(this),
|
|
964
1102
|
depth: 100,
|
|
965
1103
|
newGroupDelay: 500,
|
|
966
|
-
button: ({ editor: e, t, extension:
|
|
967
|
-
var r,
|
|
1104
|
+
button: ({ editor: e, t, extension: n }) => {
|
|
1105
|
+
var r, i;
|
|
968
1106
|
return {
|
|
969
1107
|
componentProps: {
|
|
970
1108
|
undo: {
|
|
971
1109
|
action: () => {
|
|
972
1110
|
e.chain().focus().undo().run();
|
|
973
1111
|
},
|
|
974
|
-
shortcutKeys: ((r =
|
|
1112
|
+
shortcutKeys: ((r = n.options.shortcutKeys) == null ? void 0 : r[0]) ?? ["mod", "Z"],
|
|
975
1113
|
isActive: () => e.can().undo(),
|
|
976
1114
|
icon: "Undo2",
|
|
977
1115
|
tooltip: t("editor.undo.tooltip")
|
|
@@ -980,7 +1118,7 @@ const te = /* @__PURE__ */ De.extend({
|
|
|
980
1118
|
action: () => {
|
|
981
1119
|
e.chain().focus().redo().run();
|
|
982
1120
|
},
|
|
983
|
-
shortcutKeys: ((
|
|
1121
|
+
shortcutKeys: ((i = n.options.shortcutKeys) == null ? void 0 : i[1]) ?? ["shift", "mod", "Z"],
|
|
984
1122
|
isActive: () => e.can().redo(),
|
|
985
1123
|
icon: "Redo2",
|
|
986
1124
|
tooltip: t("editor.redo.tooltip")
|
|
@@ -992,7 +1130,7 @@ const te = /* @__PURE__ */ De.extend({
|
|
|
992
1130
|
}
|
|
993
1131
|
});
|
|
994
1132
|
export {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1133
|
+
re as History,
|
|
1134
|
+
Je as RichTextRedo,
|
|
1135
|
+
Ze as RichTextUndo
|
|
998
1136
|
};
|