@templatical/editor 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AiChatSidebar-D30WPhbv.js → AiChatSidebar-BMwpZx-6.js} +14 -14
- package/dist/{AiFeatureMenu-B5CJX5zr.js → AiFeatureMenu-xgaIGUCo.js} +8 -8
- package/dist/{BlockIssueBadge-CkB4Yyz2.js → BlockIssueBadge-3kNs6WoD.js} +5 -5
- package/dist/{CloudEditor-nT-R769W.js → CloudEditor-Dm9hiaui.js} +159 -156
- package/dist/{CollaboratorBar-CwhlXODK.js → CollaboratorBar-Cz_evoU4.js} +4 -4
- package/dist/{CommentsSidebar-gpZMMI5w.js → CommentsSidebar-jFZj_CTo.js} +13 -13
- package/dist/{CountdownBlock-BNvuXucv.js → CountdownBlock-S-SCyVye.js} +4 -4
- package/dist/{CountdownToolbar-Dl82DAmI.js → CountdownToolbar-Ckdo-3P-.js} +3 -3
- package/dist/{DesignReferenceSidebar-Bs5AMxVd.js → DesignReferenceSidebar-B9QNPZNV.js} +10 -10
- package/dist/{IssuesPanel-CqQa2BtU.js → IssuesPanel-_E_fbSM8.js} +8 -8
- package/dist/{LoadingTrack-xCOLUR3o.js → LoadingTrack-BZ5KJyZ_.js} +2 -2
- package/dist/{ModuleBrowserModal-BWWgF0LC.js → ModuleBrowserModal-BB22urqi.js} +10 -10
- package/dist/{ModulePreviewCanvas-D7Tk5HOt.js → ModulePreviewCanvas-CH5OdXv8.js} +3 -3
- package/dist/{NumberWithSuffix-DVy5HxMi.js → NumberWithSuffix-BHDXHMpo.js} +3 -3
- package/dist/{ParagraphEditor-DVSGdMOo.js → ParagraphEditor-BmY7LLgN.js} +26 -26
- package/dist/{RichTextEditorContent-DN-fRjMa.js → RichTextEditorContent-COijbaWp.js} +8 -8
- package/dist/{SaveModuleDialog-CkEYkyVD.js → SaveModuleDialog-D5WN-je_.js} +7 -7
- package/dist/{SnapshotHistory-Nx9wrlbF.js → SnapshotHistory-BQ55Rhri.js} +9 -9
- package/dist/{TemplateScoringPanel-BG9M-29t.js → TemplateScoringPanel-Dhf_Qgr7.js} +15 -15
- package/dist/{TestEmailModal-CRjtEs6S.js → TestEmailModal-DH_Viz_m.js} +5 -5
- package/dist/{TitleEditor-CvtV4pCA.js → TitleEditor-Dn613K8o.js} +12 -12
- package/dist/{TplModal-BudEYVcJ.js → TplModal-Dxa3rhHI.js} +4 -4
- package/dist/{blockTypeIcons-Dd-UvfnC.js → blockTypeIcons-CrcSCTD6.js} +2 -2
- package/dist/bundle-stats.json +6 -6
- package/dist/cdn/chunks/{AiFeatureMenu-DKOv8VnB.js → AiFeatureMenu-CCsgxyN9.js} +4 -4
- package/dist/cdn/chunks/{AiFeatureMenu-DKOv8VnB.js.map → AiFeatureMenu-CCsgxyN9.js.map} +1 -1
- package/dist/cdn/chunks/{BlockIssueBadge-DpiSTwM7.js → BlockIssueBadge-Lc3NWFV8.js} +3 -3
- package/dist/cdn/chunks/{BlockIssueBadge-DpiSTwM7.js.map → BlockIssueBadge-Lc3NWFV8.js.map} +1 -1
- package/dist/cdn/chunks/{CloudEditor-xc_uOEgn.js → CloudEditor-KkwvBhyt.js} +131 -128
- package/dist/cdn/chunks/CloudEditor-KkwvBhyt.js.map +1 -0
- package/dist/cdn/chunks/{CollaboratorBar-VWfPri_h.js → CollaboratorBar-BGIGiFSm.js} +4 -4
- package/dist/cdn/chunks/{CollaboratorBar-VWfPri_h.js.map → CollaboratorBar-BGIGiFSm.js.map} +1 -1
- package/dist/cdn/chunks/{CountdownBlock-BKsCWboK.js → CountdownBlock-gqnpxKp_.js} +4 -4
- package/dist/cdn/chunks/{CountdownBlock-BKsCWboK.js.map → CountdownBlock-gqnpxKp_.js.map} +1 -1
- package/dist/cdn/chunks/{CountdownToolbar-BLtECDNb.js → CountdownToolbar-xHpaWQE2.js} +4 -4
- package/dist/cdn/chunks/{CountdownToolbar-BLtECDNb.js.map → CountdownToolbar-xHpaWQE2.js.map} +1 -1
- package/dist/cdn/chunks/{IssuesPanel-BW2piyvs.js → IssuesPanel-DHTTHu65.js} +4 -4
- package/dist/cdn/chunks/{IssuesPanel-BW2piyvs.js.map → IssuesPanel-DHTTHu65.js.map} +1 -1
- package/dist/cdn/chunks/{ModuleBrowserModal-TLlKpvjX.js → ModuleBrowserModal-DDTjrKph.js} +6 -6
- package/dist/cdn/chunks/{ModuleBrowserModal-TLlKpvjX.js.map → ModuleBrowserModal-DDTjrKph.js.map} +1 -1
- package/dist/cdn/chunks/{ModulePreviewCanvas-wu7y-vrh.js → ModulePreviewCanvas-DeFq0hVi.js} +3 -3
- package/dist/cdn/chunks/{ModulePreviewCanvas-wu7y-vrh.js.map → ModulePreviewCanvas-DeFq0hVi.js.map} +1 -1
- package/dist/cdn/chunks/{NumberWithSuffix-DxoUtTMr.js → NumberWithSuffix-D4wtmU9O.js} +3 -3
- package/dist/cdn/chunks/{NumberWithSuffix-DxoUtTMr.js.map → NumberWithSuffix-D4wtmU9O.js.map} +1 -1
- package/dist/cdn/chunks/{ParagraphEditor-DvxIO2LN.js → ParagraphEditor-CwY8GeWa.js} +20 -20
- package/dist/cdn/chunks/{ParagraphEditor-DvxIO2LN.js.map → ParagraphEditor-CwY8GeWa.js.map} +1 -1
- package/dist/cdn/chunks/{RichTextEditorContent-Dm9GXJmo.js → RichTextEditorContent-C_bMURGF.js} +5 -5
- package/dist/cdn/chunks/{RichTextEditorContent-Dm9GXJmo.js.map → RichTextEditorContent-C_bMURGF.js.map} +1 -1
- package/dist/cdn/chunks/{SaveModuleDialog-BRAdVcYM.js → SaveModuleDialog-DEi8PSP6.js} +3 -3
- package/dist/cdn/chunks/{SaveModuleDialog-BRAdVcYM.js.map → SaveModuleDialog-DEi8PSP6.js.map} +1 -1
- package/dist/cdn/chunks/{TitleEditor-D3gPRd0x.js → TitleEditor-Betpo8AZ.js} +9 -9
- package/dist/cdn/chunks/{TitleEditor-D3gPRd0x.js.map → TitleEditor-Betpo8AZ.js.map} +1 -1
- package/dist/cdn/chunks/{blockTypeIcons-C2cm4RjU.js → blockTypeIcons-Xz6OBq3U.js} +3 -3
- package/dist/cdn/chunks/{blockTypeIcons-C2cm4RjU.js.map → blockTypeIcons-Xz6OBq3U.js.map} +1 -1
- package/dist/cdn/chunks/{draggable-BwWMFq33.js → draggable-BTGr7_-X.js} +1271 -1270
- package/dist/cdn/chunks/draggable-BTGr7_-X.js.map +1 -0
- package/dist/cdn/chunks/{extensions-SS1ywPUR.js → extensions-D_j4UWxi.js} +108 -105
- package/dist/cdn/chunks/{extensions-SS1ywPUR.js.map → extensions-D_j4UWxi.js.map} +1 -1
- package/dist/cdn/chunks/{features-CwZTdcbt.js → features-A28DQtjE.js} +831 -820
- package/dist/cdn/chunks/features-A28DQtjE.js.map +1 -0
- package/dist/cdn/chunks/{icons-CbNEr1kc.js → icons-C9D3N0-J.js} +12 -12
- package/dist/cdn/chunks/{icons-CbNEr1kc.js.map → icons-C9D3N0-J.js.map} +1 -1
- package/dist/cdn/chunks/{liquid.browser-rMoPo2t_.js → liquid.browser-DUDc3U21.js} +10 -10
- package/dist/cdn/chunks/{liquid.browser-rMoPo2t_.js.map → liquid.browser-DUDc3U21.js.map} +1 -1
- package/dist/cdn/chunks/{media-library-BRpHZOl7.js → media-library-CH1Wx5wP.js} +13 -9
- package/dist/cdn/chunks/media-library-CH1Wx5wP.js.map +1 -0
- package/dist/cdn/chunks/pusher-CHo5Cua0.js.map +1 -1
- package/dist/cdn/chunks/{quality-BqJqIPRU.js → quality-D4NeyFej.js} +530 -530
- package/dist/cdn/chunks/{quality-BqJqIPRU.js.map → quality-D4NeyFej.js.map} +1 -1
- package/dist/cdn/chunks/{renderer-CGVYkdUi.js → renderer-BQnGfLhL.js} +62 -61
- package/dist/cdn/chunks/renderer-BQnGfLhL.js.map +1 -0
- package/dist/cdn/chunks/{src-CvzfrFlT.js → src-BkKEyLw1.js} +6 -6
- package/dist/cdn/chunks/{src-CvzfrFlT.js.map → src-BkKEyLw1.js.map} +1 -1
- package/dist/cdn/chunks/{styles-2P5yvfsS.js → styles-BDVaiw3K.js} +150 -150
- package/dist/cdn/chunks/{styles-2P5yvfsS.js.map → styles-BDVaiw3K.js.map} +1 -1
- package/dist/cdn/chunks/{tiptap-BBbH3IT9.js → tiptap-P5abGB13.js} +4437 -2580
- package/dist/cdn/chunks/tiptap-P5abGB13.js.map +1 -0
- package/dist/cdn/editor.css +1 -1
- package/dist/cdn/editor.js +100 -100
- package/dist/cdn/editor.js.map +1 -1
- package/dist/{check-ChQyfxJ3.js → check-KooI2jyS.js} +1 -1
- package/dist/{chevron-down-DJjo0jSV.js → chevron-down-mnlFgueW.js} +1 -1
- package/dist/{circle-alert-CPH6l3Lc.js → circle-alert-D89_hB8j.js} +1 -1
- package/dist/{clock-DHl_BIkU.js → clock-BaadyUrg.js} +1 -1
- package/dist/{cloud-BBC7bv8q.js → cloud-D-FScaHx.js} +80 -74
- package/dist/{createLucideIcon-XgXOJ05E.js → createLucideIcon-D-6fpD2L.js} +3 -3
- package/dist/{dist-DXaxGLsw.js → dist-BttO3Zdx.js} +44 -44
- package/dist/{dist-C8wMh_gi.js → dist-C1WcikEF.js} +5 -5
- package/dist/dist-CjULgTep.js +4072 -0
- package/dist/{dist-GAmhYvUK.js → dist-D6L_WdRL.js} +96 -86
- package/dist/{dist-DYO-w_Jf.js → dist-DaajG7Fo.js} +5 -5
- package/dist/dist-Df4eV6Zi.js +5 -0
- package/dist/{dist-D8C6jIXM.js → dist-Dnqx5UF3.js} +171 -158
- package/dist/{dist-CUpJmrjt.js → dist-Drp5bNAu.js} +5 -5
- package/dist/dist-WJ1fVd5b.js +5 -0
- package/dist/{dist-BxP6TB0l.js → dist-XA2i70J5.js} +8 -8
- package/dist/{dist-UK-lbEBc.js → dist-b52vYHb5.js} +2 -2
- package/dist/{dist-CNLAS2v2.js → dist-cl33Ip6W.js} +3 -3
- package/dist/{dist-C0jo8wtG.js → dist-sqf7pq5q.js} +16 -16
- package/dist/{dist-BzuC8o3y.js → dist-zInT3Lf6.js} +78 -60
- package/dist/{extensions-C87ZSllQ.js → extensions-DA-w1gVg.js} +128 -125
- package/dist/{image-up-CPBCOMit.js → image-up-DjwfAom6.js} +1 -1
- package/dist/{info-DIY9mguM.js → info-Db3HlTr8.js} +1 -1
- package/dist/{keys-Vt3XipJl.js → keys-BjmL5YCT.js} +1 -1
- package/dist/{liquid.browser-IgQrXHPQ.js → liquid.browser--qtl1Fqy.js} +9 -9
- package/dist/{list-checks-CSCyu3fH.js → list-checks-BlAB0X8a.js} +1 -1
- package/dist/{loader-circle-Rz_4vJLH.js → loader-circle-EVqyIxjU.js} +1 -1
- package/dist/{message-circle-D-umK_MU.js → message-circle-BuI5pBVG.js} +1 -1
- package/dist/{refresh-cw-CvWF4jfR.js → refresh-cw-C2vM_6zQ.js} +1 -1
- package/dist/{scan-line-wanvAFDr.js → scan-line-AUIh_SHI.js} +1 -1
- package/dist/{send-BhbhbIFT.js → send-nrbwF7xg.js} +1 -1
- package/dist/{shield-check-CXPPMWth.js → shield-check-B55Ozmva.js} +1 -1
- package/dist/{sparkles-CrUN0KWY.js → sparkles-oh1NUSFq.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/{styles-DOjWbqA9.js → styles-Byhh107n.js} +41 -41
- package/dist/templatical-editor.js +81 -80
- package/dist/{text-align-end-Bkq8oBrD.js → text-align-start-B2MqzZwU.js} +11 -11
- package/dist/{trash-2-BpY5BCLT.js → trash-2-DH8RBwAx.js} +1 -1
- package/dist/{triangle-alert-MwJBKR2e.js → triangle-alert-BQHjCt3B.js} +1 -1
- package/dist/{useAliveFlag-BLyG8L4d.js → useAliveFlag-B_b9ubwD.js} +1 -1
- package/dist/{useCloudI18n-sRfoQCZY.js → useCloudI18n-BHCrmQgj.js} +2 -2
- package/dist/{useEditorCore-DxApq2hZ.js → useEditorCore-BEgc3KFu.js} +370 -377
- package/dist/{useI18n-lF6hYgZu.js → useI18n-Bb9-ha9X.js} +2 -2
- package/dist/{useMergeTag-CZVI7Xe5.js → useMergeTag-HykzEtBn.js} +3 -3
- package/dist/usePopoverRoot-BZDkRRry.js +8 -0
- package/dist/{vue.runtime.esm-bundler-BDSGA5hA.js → vue.runtime.esm-bundler-MzYCkFSH.js} +1306 -1305
- package/dist/{x-rcnxRG8Y.js → x-DgCCENgP.js} +1 -1
- package/package.json +27 -27
- package/dist/cdn/chunks/CloudEditor-xc_uOEgn.js.map +0 -1
- package/dist/cdn/chunks/draggable-BwWMFq33.js.map +0 -1
- package/dist/cdn/chunks/features-CwZTdcbt.js.map +0 -1
- package/dist/cdn/chunks/media-library-BRpHZOl7.js.map +0 -1
- package/dist/cdn/chunks/renderer-CGVYkdUi.js.map +0 -1
- package/dist/cdn/chunks/tiptap-BBbH3IT9.js.map +0 -1
- package/dist/dist-BDgf2G-V.js +0 -2243
- package/dist/dist-D5lmdi1F.js +0 -5
- package/dist/dist-DILjuzSv.js +0 -5
- package/dist/usePopoverRoot-p2BanBI7.js +0 -8
|
@@ -0,0 +1,4072 @@
|
|
|
1
|
+
import { Cn as e, Ct as t, Dn as n, En as r, Mt as i, Nt as a, On as o, Pt as s, Sn as c, Tn as l, Ut as u, Wt as d, Xt as f, Z as p, _n as ee, at as te, bn as ne, c as m, en as re, gn as h, i as g, in as ie, k as ae, mn as oe, ot as se, qt as _, rt as ce, u as v, v as le, vn as y, wn as b, wt as ue, xn as x, y as de, yn as S } from "./dist-zInT3Lf6.js";
|
|
2
|
+
import { Link as fe } from "./dist-BttO3Zdx.js";
|
|
3
|
+
import { Underline as pe } from "./dist-DaajG7Fo.js";
|
|
4
|
+
//#region ../../node_modules/.pnpm/@tiptap+core@3.26.0_@tiptap+pm@3.26.0/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js
|
|
5
|
+
var C = (e, t) => {
|
|
6
|
+
if (e === "slot") return 0;
|
|
7
|
+
if (e instanceof Function) return e(t);
|
|
8
|
+
let { children: n, ...r } = t ?? {};
|
|
9
|
+
if (e === "svg") throw Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");
|
|
10
|
+
return [
|
|
11
|
+
e,
|
|
12
|
+
r,
|
|
13
|
+
n
|
|
14
|
+
];
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region ../../node_modules/.pnpm/@tiptap+extension-blockquote@3.26.0_@tiptap+core@3.26.0_@tiptap+pm@3.26.0_/node_modules/@tiptap/extension-blockquote/dist/index.js
|
|
18
|
+
function me(e, t, n) {
|
|
19
|
+
for (let r = 0;; r++) {
|
|
20
|
+
if (r == e.childCount || r == t.childCount) return e.childCount == t.childCount ? null : n;
|
|
21
|
+
let i = e.child(r), a = t.child(r);
|
|
22
|
+
if (i == a) {
|
|
23
|
+
n += i.nodeSize;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (!i.sameMarkup(a)) return n;
|
|
27
|
+
if (i.isText && i.text != a.text) {
|
|
28
|
+
for (let e = 0; i.text[e] == a.text[e]; e++) n++;
|
|
29
|
+
return n;
|
|
30
|
+
}
|
|
31
|
+
if (i.content.size || a.content.size) {
|
|
32
|
+
let e = me(i.content, a.content, n + 1);
|
|
33
|
+
if (e != null) return e;
|
|
34
|
+
}
|
|
35
|
+
n += i.nodeSize;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function he(e, t, n, r) {
|
|
39
|
+
for (let i = e.childCount, a = t.childCount;;) {
|
|
40
|
+
if (i == 0 || a == 0) return i == a ? null : {
|
|
41
|
+
a: n,
|
|
42
|
+
b: r
|
|
43
|
+
};
|
|
44
|
+
let o = e.child(--i), s = t.child(--a), c = o.nodeSize;
|
|
45
|
+
if (o == s) {
|
|
46
|
+
n -= c, r -= c;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (!o.sameMarkup(s)) return {
|
|
50
|
+
a: n,
|
|
51
|
+
b: r
|
|
52
|
+
};
|
|
53
|
+
if (o.isText && o.text != s.text) {
|
|
54
|
+
let e = 0, t = Math.min(o.text.length, s.text.length);
|
|
55
|
+
for (; e < t && o.text[o.text.length - e - 1] == s.text[s.text.length - e - 1];) e++, n--, r--;
|
|
56
|
+
return {
|
|
57
|
+
a: n,
|
|
58
|
+
b: r
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (o.content.size || s.content.size) {
|
|
62
|
+
let e = he(o.content, s.content, n - 1, r - 1);
|
|
63
|
+
if (e) return e;
|
|
64
|
+
}
|
|
65
|
+
n -= c, r -= c;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
var w = class e {
|
|
69
|
+
constructor(e, t) {
|
|
70
|
+
if (this.content = e, this.size = t || 0, t == null) for (let t = 0; t < e.length; t++) this.size += e[t].nodeSize;
|
|
71
|
+
}
|
|
72
|
+
nodesBetween(e, t, n, r = 0, i) {
|
|
73
|
+
for (let a = 0, o = 0; o < t; a++) {
|
|
74
|
+
let s = this.content[a], c = o + s.nodeSize;
|
|
75
|
+
if (c > e && n(s, r + o, i || null, a) !== !1 && s.content.size) {
|
|
76
|
+
let i = o + 1;
|
|
77
|
+
s.nodesBetween(Math.max(0, e - i), Math.min(s.content.size, t - i), n, r + i);
|
|
78
|
+
}
|
|
79
|
+
o = c;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
descendants(e) {
|
|
83
|
+
this.nodesBetween(0, this.size, e);
|
|
84
|
+
}
|
|
85
|
+
textBetween(e, t, n, r) {
|
|
86
|
+
let i = "", a = !0;
|
|
87
|
+
return this.nodesBetween(e, t, (o, s) => {
|
|
88
|
+
let c = o.isText ? o.text.slice(Math.max(e, s) - s, t - s) : o.isLeaf ? r ? typeof r == "function" ? r(o) : r : o.type.spec.leafText ? o.type.spec.leafText(o) : "" : "";
|
|
89
|
+
o.isBlock && (o.isLeaf && c || o.isTextblock) && n && (a ? a = !1 : i += n), i += c;
|
|
90
|
+
}, 0), i;
|
|
91
|
+
}
|
|
92
|
+
append(t) {
|
|
93
|
+
if (!t.size) return this;
|
|
94
|
+
if (!this.size) return t;
|
|
95
|
+
let n = this.lastChild, r = t.firstChild, i = this.content.slice(), a = 0;
|
|
96
|
+
for (n.isText && n.sameMarkup(r) && (i[i.length - 1] = n.withText(n.text + r.text), a = 1); a < t.content.length; a++) i.push(t.content[a]);
|
|
97
|
+
return new e(i, this.size + t.size);
|
|
98
|
+
}
|
|
99
|
+
cut(t, n = this.size) {
|
|
100
|
+
if (t == 0 && n == this.size) return this;
|
|
101
|
+
let r = [], i = 0;
|
|
102
|
+
if (n > t) for (let e = 0, a = 0; a < n; e++) {
|
|
103
|
+
let o = this.content[e], s = a + o.nodeSize;
|
|
104
|
+
s > t && ((a < t || s > n) && (o = o.isText ? o.cut(Math.max(0, t - a), Math.min(o.text.length, n - a)) : o.cut(Math.max(0, t - a - 1), Math.min(o.content.size, n - a - 1))), r.push(o), i += o.nodeSize), a = s;
|
|
105
|
+
}
|
|
106
|
+
return new e(r, i);
|
|
107
|
+
}
|
|
108
|
+
cutByIndex(t, n) {
|
|
109
|
+
return t == n ? e.empty : t == 0 && n == this.content.length ? this : new e(this.content.slice(t, n));
|
|
110
|
+
}
|
|
111
|
+
replaceChild(t, n) {
|
|
112
|
+
let r = this.content[t];
|
|
113
|
+
if (r == n) return this;
|
|
114
|
+
let i = this.content.slice(), a = this.size + n.nodeSize - r.nodeSize;
|
|
115
|
+
return i[t] = n, new e(i, a);
|
|
116
|
+
}
|
|
117
|
+
addToStart(t) {
|
|
118
|
+
return new e([t].concat(this.content), this.size + t.nodeSize);
|
|
119
|
+
}
|
|
120
|
+
addToEnd(t) {
|
|
121
|
+
return new e(this.content.concat(t), this.size + t.nodeSize);
|
|
122
|
+
}
|
|
123
|
+
eq(e) {
|
|
124
|
+
if (this.content.length != e.content.length) return !1;
|
|
125
|
+
for (let t = 0; t < this.content.length; t++) if (!this.content[t].eq(e.content[t])) return !1;
|
|
126
|
+
return !0;
|
|
127
|
+
}
|
|
128
|
+
get firstChild() {
|
|
129
|
+
return this.content.length ? this.content[0] : null;
|
|
130
|
+
}
|
|
131
|
+
get lastChild() {
|
|
132
|
+
return this.content.length ? this.content[this.content.length - 1] : null;
|
|
133
|
+
}
|
|
134
|
+
get childCount() {
|
|
135
|
+
return this.content.length;
|
|
136
|
+
}
|
|
137
|
+
child(e) {
|
|
138
|
+
let t = this.content[e];
|
|
139
|
+
if (!t) throw RangeError("Index " + e + " out of range for " + this);
|
|
140
|
+
return t;
|
|
141
|
+
}
|
|
142
|
+
maybeChild(e) {
|
|
143
|
+
return this.content[e] || null;
|
|
144
|
+
}
|
|
145
|
+
forEach(e) {
|
|
146
|
+
for (let t = 0, n = 0; t < this.content.length; t++) {
|
|
147
|
+
let r = this.content[t];
|
|
148
|
+
e(r, n, t), n += r.nodeSize;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
findDiffStart(e, t = 0) {
|
|
152
|
+
return me(this, e, t);
|
|
153
|
+
}
|
|
154
|
+
findDiffEnd(e, t = this.size, n = e.size) {
|
|
155
|
+
return he(this, e, t, n);
|
|
156
|
+
}
|
|
157
|
+
findIndex(e) {
|
|
158
|
+
if (e == 0) return _e(0, e);
|
|
159
|
+
if (e == this.size) return _e(this.content.length, e);
|
|
160
|
+
if (e > this.size || e < 0) throw RangeError(`Position ${e} outside of fragment (${this})`);
|
|
161
|
+
for (let t = 0, n = 0;; t++) {
|
|
162
|
+
let r = this.child(t), i = n + r.nodeSize;
|
|
163
|
+
if (i >= e) return i == e ? _e(t + 1, i) : _e(t, n);
|
|
164
|
+
n = i;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
toString() {
|
|
168
|
+
return "<" + this.toStringInner() + ">";
|
|
169
|
+
}
|
|
170
|
+
toStringInner() {
|
|
171
|
+
return this.content.join(", ");
|
|
172
|
+
}
|
|
173
|
+
toJSON() {
|
|
174
|
+
return this.content.length ? this.content.map((e) => e.toJSON()) : null;
|
|
175
|
+
}
|
|
176
|
+
static fromJSON(t, n) {
|
|
177
|
+
if (!n) return e.empty;
|
|
178
|
+
if (!Array.isArray(n)) throw RangeError("Invalid input for Fragment.fromJSON");
|
|
179
|
+
return e.fromArray(n.map(t.nodeFromJSON));
|
|
180
|
+
}
|
|
181
|
+
static fromArray(t) {
|
|
182
|
+
if (!t.length) return e.empty;
|
|
183
|
+
let n, r = 0;
|
|
184
|
+
for (let e = 0; e < t.length; e++) {
|
|
185
|
+
let i = t[e];
|
|
186
|
+
r += i.nodeSize, e && i.isText && t[e - 1].sameMarkup(i) ? (n ||= t.slice(0, e), n[n.length - 1] = i.withText(n[n.length - 1].text + i.text)) : n && n.push(i);
|
|
187
|
+
}
|
|
188
|
+
return new e(n || t, r);
|
|
189
|
+
}
|
|
190
|
+
static from(t) {
|
|
191
|
+
if (!t) return e.empty;
|
|
192
|
+
if (t instanceof e) return t;
|
|
193
|
+
if (Array.isArray(t)) return this.fromArray(t);
|
|
194
|
+
if (t.attrs) return new e([t], t.nodeSize);
|
|
195
|
+
throw RangeError("Can not convert " + t + " to a Fragment" + (t.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
w.empty = new w([], 0);
|
|
199
|
+
var ge = {
|
|
200
|
+
index: 0,
|
|
201
|
+
offset: 0
|
|
202
|
+
};
|
|
203
|
+
function _e(e, t) {
|
|
204
|
+
return ge.index = e, ge.offset = t, ge;
|
|
205
|
+
}
|
|
206
|
+
function ve(e, t) {
|
|
207
|
+
if (e === t) return !0;
|
|
208
|
+
if (!(e && typeof e == "object") || !(t && typeof t == "object")) return !1;
|
|
209
|
+
let n = Array.isArray(e);
|
|
210
|
+
if (Array.isArray(t) != n) return !1;
|
|
211
|
+
if (n) {
|
|
212
|
+
if (e.length != t.length) return !1;
|
|
213
|
+
for (let n = 0; n < e.length; n++) if (!ve(e[n], t[n])) return !1;
|
|
214
|
+
} else {
|
|
215
|
+
for (let n in e) if (!(n in t) || !ve(e[n], t[n])) return !1;
|
|
216
|
+
for (let n in t) if (!(n in e)) return !1;
|
|
217
|
+
}
|
|
218
|
+
return !0;
|
|
219
|
+
}
|
|
220
|
+
var T = class e {
|
|
221
|
+
constructor(e, t) {
|
|
222
|
+
this.type = e, this.attrs = t;
|
|
223
|
+
}
|
|
224
|
+
addToSet(e) {
|
|
225
|
+
let t, n = !1;
|
|
226
|
+
for (let r = 0; r < e.length; r++) {
|
|
227
|
+
let i = e[r];
|
|
228
|
+
if (this.eq(i)) return e;
|
|
229
|
+
if (this.type.excludes(i.type)) t ||= e.slice(0, r);
|
|
230
|
+
else if (i.type.excludes(this.type)) return e;
|
|
231
|
+
else !n && i.type.rank > this.type.rank && (t ||= e.slice(0, r), t.push(this), n = !0), t && t.push(i);
|
|
232
|
+
}
|
|
233
|
+
return t ||= e.slice(), n || t.push(this), t;
|
|
234
|
+
}
|
|
235
|
+
removeFromSet(e) {
|
|
236
|
+
for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return e.slice(0, t).concat(e.slice(t + 1));
|
|
237
|
+
return e;
|
|
238
|
+
}
|
|
239
|
+
isInSet(e) {
|
|
240
|
+
for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return !0;
|
|
241
|
+
return !1;
|
|
242
|
+
}
|
|
243
|
+
eq(e) {
|
|
244
|
+
return this == e || this.type == e.type && ve(this.attrs, e.attrs);
|
|
245
|
+
}
|
|
246
|
+
toJSON() {
|
|
247
|
+
let e = { type: this.type.name };
|
|
248
|
+
for (let t in this.attrs) {
|
|
249
|
+
e.attrs = this.attrs;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
return e;
|
|
253
|
+
}
|
|
254
|
+
static fromJSON(e, t) {
|
|
255
|
+
if (!t) throw RangeError("Invalid input for Mark.fromJSON");
|
|
256
|
+
let n = e.marks[t.type];
|
|
257
|
+
if (!n) throw RangeError(`There is no mark type ${t.type} in this schema`);
|
|
258
|
+
let r = n.create(t.attrs);
|
|
259
|
+
return n.checkAttrs(r.attrs), r;
|
|
260
|
+
}
|
|
261
|
+
static sameSet(e, t) {
|
|
262
|
+
if (e == t) return !0;
|
|
263
|
+
if (e.length != t.length) return !1;
|
|
264
|
+
for (let n = 0; n < e.length; n++) if (!e[n].eq(t[n])) return !1;
|
|
265
|
+
return !0;
|
|
266
|
+
}
|
|
267
|
+
static setFrom(t) {
|
|
268
|
+
if (!t || Array.isArray(t) && t.length == 0) return e.none;
|
|
269
|
+
if (t instanceof e) return [t];
|
|
270
|
+
let n = t.slice();
|
|
271
|
+
return n.sort((e, t) => e.type.rank - t.type.rank), n;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
T.none = [];
|
|
275
|
+
var E = class extends Error {}, D = class e {
|
|
276
|
+
constructor(e, t, n) {
|
|
277
|
+
this.content = e, this.openStart = t, this.openEnd = n;
|
|
278
|
+
}
|
|
279
|
+
get size() {
|
|
280
|
+
return this.content.size - this.openStart - this.openEnd;
|
|
281
|
+
}
|
|
282
|
+
insertAt(t, n) {
|
|
283
|
+
let r = be(this.content, t + this.openStart, n, this.openStart + 1, this.openEnd + 1);
|
|
284
|
+
return r && new e(r, this.openStart, this.openEnd);
|
|
285
|
+
}
|
|
286
|
+
removeBetween(t, n) {
|
|
287
|
+
return new e(ye(this.content, t + this.openStart, n + this.openStart), this.openStart, this.openEnd);
|
|
288
|
+
}
|
|
289
|
+
eq(e) {
|
|
290
|
+
return this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd;
|
|
291
|
+
}
|
|
292
|
+
toString() {
|
|
293
|
+
return this.content + "(" + this.openStart + "," + this.openEnd + ")";
|
|
294
|
+
}
|
|
295
|
+
toJSON() {
|
|
296
|
+
if (!this.content.size) return null;
|
|
297
|
+
let e = { content: this.content.toJSON() };
|
|
298
|
+
return this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e;
|
|
299
|
+
}
|
|
300
|
+
static fromJSON(t, n) {
|
|
301
|
+
if (!n) return e.empty;
|
|
302
|
+
let r = n.openStart || 0, i = n.openEnd || 0;
|
|
303
|
+
if (typeof r != "number" || typeof i != "number") throw RangeError("Invalid input for Slice.fromJSON");
|
|
304
|
+
return new e(w.fromJSON(t, n.content), r, i);
|
|
305
|
+
}
|
|
306
|
+
static maxOpen(t, n = !0) {
|
|
307
|
+
let r = 0, i = 0;
|
|
308
|
+
for (let e = t.firstChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.firstChild) r++;
|
|
309
|
+
for (let e = t.lastChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.lastChild) i++;
|
|
310
|
+
return new e(t, r, i);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
D.empty = new D(w.empty, 0, 0);
|
|
314
|
+
function ye(e, t, n) {
|
|
315
|
+
let { index: r, offset: i } = e.findIndex(t), a = e.maybeChild(r), { index: o, offset: s } = e.findIndex(n);
|
|
316
|
+
if (i == t || a.isText) {
|
|
317
|
+
if (s != n && !e.child(o).isText) throw RangeError("Removing non-flat range");
|
|
318
|
+
return e.cut(0, t).append(e.cut(n));
|
|
319
|
+
}
|
|
320
|
+
if (r != o) throw RangeError("Removing non-flat range");
|
|
321
|
+
return e.replaceChild(r, a.copy(ye(a.content, t - i - 1, n - i - 1)));
|
|
322
|
+
}
|
|
323
|
+
function be(e, t, n, r, i, a) {
|
|
324
|
+
let { index: o, offset: s } = e.findIndex(t), c = e.maybeChild(o);
|
|
325
|
+
if (s == t || c.isText) return a && r <= 0 && i <= 0 && !a.canReplace(o, o, n) ? null : e.cut(0, t).append(n).append(e.cut(t));
|
|
326
|
+
let l = be(c.content, t - s - 1, n, o == 0 ? r - 1 : 0, o == e.childCount - 1 ? i - 1 : 0, c);
|
|
327
|
+
return l && e.replaceChild(o, c.copy(l));
|
|
328
|
+
}
|
|
329
|
+
function xe(e, t, n) {
|
|
330
|
+
if (n.openStart > e.depth) throw new E("Inserted content deeper than insertion position");
|
|
331
|
+
if (e.depth - n.openStart != t.depth - n.openEnd) throw new E("Inconsistent open depths");
|
|
332
|
+
return Se(e, t, n, 0);
|
|
333
|
+
}
|
|
334
|
+
function Se(e, t, n, r) {
|
|
335
|
+
let i = e.index(r), a = e.node(r);
|
|
336
|
+
if (i == t.index(r) && r < e.depth - n.openStart) {
|
|
337
|
+
let o = Se(e, t, n, r + 1);
|
|
338
|
+
return a.copy(a.content.replaceChild(i, o));
|
|
339
|
+
} else if (!n.content.size) return A(a, j(e, t, r));
|
|
340
|
+
else if (!n.openStart && !n.openEnd && e.depth == r && t.depth == r) {
|
|
341
|
+
let r = e.parent, i = r.content;
|
|
342
|
+
return A(r, i.cut(0, e.parentOffset).append(n.content).append(i.cut(t.parentOffset)));
|
|
343
|
+
} else {
|
|
344
|
+
let { start: i, end: o } = Ee(n, e);
|
|
345
|
+
return A(a, Te(e, i, o, t, r));
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function Ce(e, t) {
|
|
349
|
+
if (!t.type.compatibleContent(e.type)) throw new E("Cannot join " + t.type.name + " onto " + e.type.name);
|
|
350
|
+
}
|
|
351
|
+
function we(e, t, n) {
|
|
352
|
+
let r = e.node(n);
|
|
353
|
+
return Ce(r, t.node(n)), r;
|
|
354
|
+
}
|
|
355
|
+
function O(e, t) {
|
|
356
|
+
let n = t.length - 1;
|
|
357
|
+
n >= 0 && e.isText && e.sameMarkup(t[n]) ? t[n] = e.withText(t[n].text + e.text) : t.push(e);
|
|
358
|
+
}
|
|
359
|
+
function k(e, t, n, r) {
|
|
360
|
+
let i = (t || e).node(n), a = 0, o = t ? t.index(n) : i.childCount;
|
|
361
|
+
e && (a = e.index(n), e.depth > n ? a++ : e.textOffset && (O(e.nodeAfter, r), a++));
|
|
362
|
+
for (let e = a; e < o; e++) O(i.child(e), r);
|
|
363
|
+
t && t.depth == n && t.textOffset && O(t.nodeBefore, r);
|
|
364
|
+
}
|
|
365
|
+
function A(e, t) {
|
|
366
|
+
return e.type.checkContent(t), e.copy(t);
|
|
367
|
+
}
|
|
368
|
+
function Te(e, t, n, r, i) {
|
|
369
|
+
let a = e.depth > i && we(e, t, i + 1), o = r.depth > i && we(n, r, i + 1), s = [];
|
|
370
|
+
return k(null, e, i, s), a && o && t.index(i) == n.index(i) ? (Ce(a, o), O(A(a, Te(e, t, n, r, i + 1)), s)) : (a && O(A(a, j(e, t, i + 1)), s), k(t, n, i, s), o && O(A(o, j(n, r, i + 1)), s)), k(r, null, i, s), new w(s);
|
|
371
|
+
}
|
|
372
|
+
function j(e, t, n) {
|
|
373
|
+
let r = [];
|
|
374
|
+
return k(null, e, n, r), e.depth > n && O(A(we(e, t, n + 1), j(e, t, n + 1)), r), k(t, null, n, r), new w(r);
|
|
375
|
+
}
|
|
376
|
+
function Ee(e, t) {
|
|
377
|
+
let n = t.depth - e.openStart, r = t.node(n).copy(e.content);
|
|
378
|
+
for (let e = n - 1; e >= 0; e--) r = t.node(e).copy(w.from(r));
|
|
379
|
+
return {
|
|
380
|
+
start: r.resolveNoCache(e.openStart + n),
|
|
381
|
+
end: r.resolveNoCache(r.content.size - e.openEnd - n)
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
var De = class e {
|
|
385
|
+
constructor(e, t, n) {
|
|
386
|
+
this.pos = e, this.path = t, this.parentOffset = n, this.depth = t.length / 3 - 1;
|
|
387
|
+
}
|
|
388
|
+
resolveDepth(e) {
|
|
389
|
+
return e == null ? this.depth : e < 0 ? this.depth + e : e;
|
|
390
|
+
}
|
|
391
|
+
get parent() {
|
|
392
|
+
return this.node(this.depth);
|
|
393
|
+
}
|
|
394
|
+
get doc() {
|
|
395
|
+
return this.node(0);
|
|
396
|
+
}
|
|
397
|
+
node(e) {
|
|
398
|
+
return this.path[this.resolveDepth(e) * 3];
|
|
399
|
+
}
|
|
400
|
+
index(e) {
|
|
401
|
+
return this.path[this.resolveDepth(e) * 3 + 1];
|
|
402
|
+
}
|
|
403
|
+
indexAfter(e) {
|
|
404
|
+
return e = this.resolveDepth(e), this.index(e) + (e == this.depth && !this.textOffset ? 0 : 1);
|
|
405
|
+
}
|
|
406
|
+
start(e) {
|
|
407
|
+
return e = this.resolveDepth(e), e == 0 ? 0 : this.path[e * 3 - 1] + 1;
|
|
408
|
+
}
|
|
409
|
+
end(e) {
|
|
410
|
+
return e = this.resolveDepth(e), this.start(e) + this.node(e).content.size;
|
|
411
|
+
}
|
|
412
|
+
before(e) {
|
|
413
|
+
if (e = this.resolveDepth(e), !e) throw RangeError("There is no position before the top-level node");
|
|
414
|
+
return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1];
|
|
415
|
+
}
|
|
416
|
+
after(e) {
|
|
417
|
+
if (e = this.resolveDepth(e), !e) throw RangeError("There is no position after the top-level node");
|
|
418
|
+
return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1] + this.path[e * 3].nodeSize;
|
|
419
|
+
}
|
|
420
|
+
get textOffset() {
|
|
421
|
+
return this.pos - this.path[this.path.length - 1];
|
|
422
|
+
}
|
|
423
|
+
get nodeAfter() {
|
|
424
|
+
let e = this.parent, t = this.index(this.depth);
|
|
425
|
+
if (t == e.childCount) return null;
|
|
426
|
+
let n = this.pos - this.path[this.path.length - 1], r = e.child(t);
|
|
427
|
+
return n ? e.child(t).cut(n) : r;
|
|
428
|
+
}
|
|
429
|
+
get nodeBefore() {
|
|
430
|
+
let e = this.index(this.depth), t = this.pos - this.path[this.path.length - 1];
|
|
431
|
+
return t ? this.parent.child(e).cut(0, t) : e == 0 ? null : this.parent.child(e - 1);
|
|
432
|
+
}
|
|
433
|
+
posAtIndex(e, t) {
|
|
434
|
+
t = this.resolveDepth(t);
|
|
435
|
+
let n = this.path[t * 3], r = t == 0 ? 0 : this.path[t * 3 - 1] + 1;
|
|
436
|
+
for (let t = 0; t < e; t++) r += n.child(t).nodeSize;
|
|
437
|
+
return r;
|
|
438
|
+
}
|
|
439
|
+
marks() {
|
|
440
|
+
let e = this.parent, t = this.index();
|
|
441
|
+
if (e.content.size == 0) return T.none;
|
|
442
|
+
if (this.textOffset) return e.child(t).marks;
|
|
443
|
+
let n = e.maybeChild(t - 1), r = e.maybeChild(t);
|
|
444
|
+
if (!n) {
|
|
445
|
+
let e = n;
|
|
446
|
+
n = r, r = e;
|
|
447
|
+
}
|
|
448
|
+
let i = n.marks;
|
|
449
|
+
for (var a = 0; a < i.length; a++) i[a].type.spec.inclusive === !1 && (!r || !i[a].isInSet(r.marks)) && (i = i[a--].removeFromSet(i));
|
|
450
|
+
return i;
|
|
451
|
+
}
|
|
452
|
+
marksAcross(e) {
|
|
453
|
+
let t = this.parent.maybeChild(this.index());
|
|
454
|
+
if (!t || !t.isInline) return null;
|
|
455
|
+
let n = t.marks, r = e.parent.maybeChild(e.index());
|
|
456
|
+
for (var i = 0; i < n.length; i++) n[i].type.spec.inclusive === !1 && (!r || !n[i].isInSet(r.marks)) && (n = n[i--].removeFromSet(n));
|
|
457
|
+
return n;
|
|
458
|
+
}
|
|
459
|
+
sharedDepth(e) {
|
|
460
|
+
for (let t = this.depth; t > 0; t--) if (this.start(t) <= e && this.end(t) >= e) return t;
|
|
461
|
+
return 0;
|
|
462
|
+
}
|
|
463
|
+
blockRange(e = this, t) {
|
|
464
|
+
if (e.pos < this.pos) return e.blockRange(this);
|
|
465
|
+
for (let n = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); n >= 0; n--) if (e.pos <= this.end(n) && (!t || t(this.node(n)))) return new je(this, e, n);
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
sameParent(e) {
|
|
469
|
+
return this.pos - this.parentOffset == e.pos - e.parentOffset;
|
|
470
|
+
}
|
|
471
|
+
max(e) {
|
|
472
|
+
return e.pos > this.pos ? e : this;
|
|
473
|
+
}
|
|
474
|
+
min(e) {
|
|
475
|
+
return e.pos < this.pos ? e : this;
|
|
476
|
+
}
|
|
477
|
+
toString() {
|
|
478
|
+
let e = "";
|
|
479
|
+
for (let t = 1; t <= this.depth; t++) e += (e ? "/" : "") + this.node(t).type.name + "_" + this.index(t - 1);
|
|
480
|
+
return e + ":" + this.parentOffset;
|
|
481
|
+
}
|
|
482
|
+
static resolve(t, n) {
|
|
483
|
+
if (!(n >= 0 && n <= t.content.size)) throw RangeError("Position " + n + " out of range");
|
|
484
|
+
let r = [], i = 0, a = n;
|
|
485
|
+
for (let e = t;;) {
|
|
486
|
+
let { index: t, offset: n } = e.content.findIndex(a), o = a - n;
|
|
487
|
+
if (r.push(e, t, i + n), !o || (e = e.child(t), e.isText)) break;
|
|
488
|
+
a = o - 1, i += n + 1;
|
|
489
|
+
}
|
|
490
|
+
return new e(n, r, a);
|
|
491
|
+
}
|
|
492
|
+
static resolveCached(t, n) {
|
|
493
|
+
let r = Ae.get(t);
|
|
494
|
+
if (r) for (let e = 0; e < r.elts.length; e++) {
|
|
495
|
+
let t = r.elts[e];
|
|
496
|
+
if (t.pos == n) return t;
|
|
497
|
+
}
|
|
498
|
+
else Ae.set(t, r = new Oe());
|
|
499
|
+
let i = r.elts[r.i] = e.resolve(t, n);
|
|
500
|
+
return r.i = (r.i + 1) % ke, i;
|
|
501
|
+
}
|
|
502
|
+
}, Oe = class {
|
|
503
|
+
constructor() {
|
|
504
|
+
this.elts = [], this.i = 0;
|
|
505
|
+
}
|
|
506
|
+
}, ke = 12, Ae = /* @__PURE__ */ new WeakMap(), je = class {
|
|
507
|
+
constructor(e, t, n) {
|
|
508
|
+
this.$from = e, this.$to = t, this.depth = n;
|
|
509
|
+
}
|
|
510
|
+
get start() {
|
|
511
|
+
return this.$from.before(this.depth + 1);
|
|
512
|
+
}
|
|
513
|
+
get end() {
|
|
514
|
+
return this.$to.after(this.depth + 1);
|
|
515
|
+
}
|
|
516
|
+
get parent() {
|
|
517
|
+
return this.$from.node(this.depth);
|
|
518
|
+
}
|
|
519
|
+
get startIndex() {
|
|
520
|
+
return this.$from.index(this.depth);
|
|
521
|
+
}
|
|
522
|
+
get endIndex() {
|
|
523
|
+
return this.$to.indexAfter(this.depth);
|
|
524
|
+
}
|
|
525
|
+
}, Me = /* @__PURE__ */ Object.create(null), Ne = class e {
|
|
526
|
+
constructor(e, t, n, r = T.none) {
|
|
527
|
+
this.type = e, this.attrs = t, this.marks = r, this.content = n || w.empty;
|
|
528
|
+
}
|
|
529
|
+
get children() {
|
|
530
|
+
return this.content.content;
|
|
531
|
+
}
|
|
532
|
+
get nodeSize() {
|
|
533
|
+
return this.isLeaf ? 1 : 2 + this.content.size;
|
|
534
|
+
}
|
|
535
|
+
get childCount() {
|
|
536
|
+
return this.content.childCount;
|
|
537
|
+
}
|
|
538
|
+
child(e) {
|
|
539
|
+
return this.content.child(e);
|
|
540
|
+
}
|
|
541
|
+
maybeChild(e) {
|
|
542
|
+
return this.content.maybeChild(e);
|
|
543
|
+
}
|
|
544
|
+
forEach(e) {
|
|
545
|
+
this.content.forEach(e);
|
|
546
|
+
}
|
|
547
|
+
nodesBetween(e, t, n, r = 0) {
|
|
548
|
+
this.content.nodesBetween(e, t, n, r, this);
|
|
549
|
+
}
|
|
550
|
+
descendants(e) {
|
|
551
|
+
this.nodesBetween(0, this.content.size, e);
|
|
552
|
+
}
|
|
553
|
+
get textContent() {
|
|
554
|
+
return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, "");
|
|
555
|
+
}
|
|
556
|
+
textBetween(e, t, n, r) {
|
|
557
|
+
return this.content.textBetween(e, t, n, r);
|
|
558
|
+
}
|
|
559
|
+
get firstChild() {
|
|
560
|
+
return this.content.firstChild;
|
|
561
|
+
}
|
|
562
|
+
get lastChild() {
|
|
563
|
+
return this.content.lastChild;
|
|
564
|
+
}
|
|
565
|
+
eq(e) {
|
|
566
|
+
return this == e || this.sameMarkup(e) && this.content.eq(e.content);
|
|
567
|
+
}
|
|
568
|
+
sameMarkup(e) {
|
|
569
|
+
return this.hasMarkup(e.type, e.attrs, e.marks);
|
|
570
|
+
}
|
|
571
|
+
hasMarkup(e, t, n) {
|
|
572
|
+
return this.type == e && ve(this.attrs, t || e.defaultAttrs || Me) && T.sameSet(this.marks, n || T.none);
|
|
573
|
+
}
|
|
574
|
+
copy(t = null) {
|
|
575
|
+
return t == this.content ? this : new e(this.type, this.attrs, t, this.marks);
|
|
576
|
+
}
|
|
577
|
+
mark(t) {
|
|
578
|
+
return t == this.marks ? this : new e(this.type, this.attrs, this.content, t);
|
|
579
|
+
}
|
|
580
|
+
cut(e, t = this.content.size) {
|
|
581
|
+
return e == 0 && t == this.content.size ? this : this.copy(this.content.cut(e, t));
|
|
582
|
+
}
|
|
583
|
+
slice(e, t = this.content.size, n = !1) {
|
|
584
|
+
if (e == t) return D.empty;
|
|
585
|
+
let r = this.resolve(e), i = this.resolve(t), a = n ? 0 : r.sharedDepth(t), o = r.start(a);
|
|
586
|
+
return new D(r.node(a).content.cut(r.pos - o, i.pos - o), r.depth - a, i.depth - a);
|
|
587
|
+
}
|
|
588
|
+
replace(e, t, n) {
|
|
589
|
+
return xe(this.resolve(e), this.resolve(t), n);
|
|
590
|
+
}
|
|
591
|
+
nodeAt(e) {
|
|
592
|
+
for (let t = this;;) {
|
|
593
|
+
let { index: n, offset: r } = t.content.findIndex(e);
|
|
594
|
+
if (t = t.maybeChild(n), !t) return null;
|
|
595
|
+
if (r == e || t.isText) return t;
|
|
596
|
+
e -= r + 1;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
childAfter(e) {
|
|
600
|
+
let { index: t, offset: n } = this.content.findIndex(e);
|
|
601
|
+
return {
|
|
602
|
+
node: this.content.maybeChild(t),
|
|
603
|
+
index: t,
|
|
604
|
+
offset: n
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
childBefore(e) {
|
|
608
|
+
if (e == 0) return {
|
|
609
|
+
node: null,
|
|
610
|
+
index: 0,
|
|
611
|
+
offset: 0
|
|
612
|
+
};
|
|
613
|
+
let { index: t, offset: n } = this.content.findIndex(e);
|
|
614
|
+
if (n < e) return {
|
|
615
|
+
node: this.content.child(t),
|
|
616
|
+
index: t,
|
|
617
|
+
offset: n
|
|
618
|
+
};
|
|
619
|
+
let r = this.content.child(t - 1);
|
|
620
|
+
return {
|
|
621
|
+
node: r,
|
|
622
|
+
index: t - 1,
|
|
623
|
+
offset: n - r.nodeSize
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
resolve(e) {
|
|
627
|
+
return De.resolveCached(this, e);
|
|
628
|
+
}
|
|
629
|
+
resolveNoCache(e) {
|
|
630
|
+
return De.resolve(this, e);
|
|
631
|
+
}
|
|
632
|
+
rangeHasMark(e, t, n) {
|
|
633
|
+
let r = !1;
|
|
634
|
+
return t > e && this.nodesBetween(e, t, (e) => (n.isInSet(e.marks) && (r = !0), !r)), r;
|
|
635
|
+
}
|
|
636
|
+
get isBlock() {
|
|
637
|
+
return this.type.isBlock;
|
|
638
|
+
}
|
|
639
|
+
get isTextblock() {
|
|
640
|
+
return this.type.isTextblock;
|
|
641
|
+
}
|
|
642
|
+
get inlineContent() {
|
|
643
|
+
return this.type.inlineContent;
|
|
644
|
+
}
|
|
645
|
+
get isInline() {
|
|
646
|
+
return this.type.isInline;
|
|
647
|
+
}
|
|
648
|
+
get isText() {
|
|
649
|
+
return this.type.isText;
|
|
650
|
+
}
|
|
651
|
+
get isLeaf() {
|
|
652
|
+
return this.type.isLeaf;
|
|
653
|
+
}
|
|
654
|
+
get isAtom() {
|
|
655
|
+
return this.type.isAtom;
|
|
656
|
+
}
|
|
657
|
+
toString() {
|
|
658
|
+
if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this);
|
|
659
|
+
let e = this.type.name;
|
|
660
|
+
return this.content.size && (e += "(" + this.content.toStringInner() + ")"), Pe(this.marks, e);
|
|
661
|
+
}
|
|
662
|
+
contentMatchAt(e) {
|
|
663
|
+
let t = this.type.contentMatch.matchFragment(this.content, 0, e);
|
|
664
|
+
if (!t) throw Error("Called contentMatchAt on a node with invalid content");
|
|
665
|
+
return t;
|
|
666
|
+
}
|
|
667
|
+
canReplace(e, t, n = w.empty, r = 0, i = n.childCount) {
|
|
668
|
+
let a = this.contentMatchAt(e).matchFragment(n, r, i), o = a && a.matchFragment(this.content, t);
|
|
669
|
+
if (!o || !o.validEnd) return !1;
|
|
670
|
+
for (let e = r; e < i; e++) if (!this.type.allowsMarks(n.child(e).marks)) return !1;
|
|
671
|
+
return !0;
|
|
672
|
+
}
|
|
673
|
+
canReplaceWith(e, t, n, r) {
|
|
674
|
+
if (r && !this.type.allowsMarks(r)) return !1;
|
|
675
|
+
let i = this.contentMatchAt(e).matchType(n), a = i && i.matchFragment(this.content, t);
|
|
676
|
+
return a ? a.validEnd : !1;
|
|
677
|
+
}
|
|
678
|
+
canAppend(e) {
|
|
679
|
+
return e.content.size ? this.canReplace(this.childCount, this.childCount, e.content) : this.type.compatibleContent(e.type);
|
|
680
|
+
}
|
|
681
|
+
check() {
|
|
682
|
+
this.type.checkContent(this.content), this.type.checkAttrs(this.attrs);
|
|
683
|
+
let e = T.none;
|
|
684
|
+
for (let t = 0; t < this.marks.length; t++) {
|
|
685
|
+
let n = this.marks[t];
|
|
686
|
+
n.type.checkAttrs(n.attrs), e = n.addToSet(e);
|
|
687
|
+
}
|
|
688
|
+
if (!T.sameSet(e, this.marks)) throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e) => e.type.name)}`);
|
|
689
|
+
this.content.forEach((e) => e.check());
|
|
690
|
+
}
|
|
691
|
+
toJSON() {
|
|
692
|
+
let e = { type: this.type.name };
|
|
693
|
+
for (let t in this.attrs) {
|
|
694
|
+
e.attrs = this.attrs;
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
return this.content.size && (e.content = this.content.toJSON()), this.marks.length && (e.marks = this.marks.map((e) => e.toJSON())), e;
|
|
698
|
+
}
|
|
699
|
+
static fromJSON(e, t) {
|
|
700
|
+
if (!t) throw RangeError("Invalid input for Node.fromJSON");
|
|
701
|
+
let n;
|
|
702
|
+
if (t.marks) {
|
|
703
|
+
if (!Array.isArray(t.marks)) throw RangeError("Invalid mark data for Node.fromJSON");
|
|
704
|
+
n = t.marks.map(e.markFromJSON);
|
|
705
|
+
}
|
|
706
|
+
if (t.type == "text") {
|
|
707
|
+
if (typeof t.text != "string") throw RangeError("Invalid text node in JSON");
|
|
708
|
+
return e.text(t.text, n);
|
|
709
|
+
}
|
|
710
|
+
let r = w.fromJSON(e, t.content), i = e.nodeType(t.type).create(t.attrs, r, n);
|
|
711
|
+
return i.type.checkAttrs(i.attrs), i;
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
Ne.prototype.text = void 0;
|
|
715
|
+
function Pe(e, t) {
|
|
716
|
+
for (let n = e.length - 1; n >= 0; n--) t = e[n].type.name + "(" + t + ")";
|
|
717
|
+
return t;
|
|
718
|
+
}
|
|
719
|
+
var Fe = class e {
|
|
720
|
+
constructor(e) {
|
|
721
|
+
this.validEnd = e, this.next = [], this.wrapCache = [];
|
|
722
|
+
}
|
|
723
|
+
static parse(t, n) {
|
|
724
|
+
let r = new Ie(t, n);
|
|
725
|
+
if (r.next == null) return e.empty;
|
|
726
|
+
let i = Le(r);
|
|
727
|
+
r.next && r.err("Unexpected trailing text");
|
|
728
|
+
let a = qe(We(i));
|
|
729
|
+
return Je(a, r), a;
|
|
730
|
+
}
|
|
731
|
+
matchType(e) {
|
|
732
|
+
for (let t = 0; t < this.next.length; t++) if (this.next[t].type == e) return this.next[t].next;
|
|
733
|
+
return null;
|
|
734
|
+
}
|
|
735
|
+
matchFragment(e, t = 0, n = e.childCount) {
|
|
736
|
+
let r = this;
|
|
737
|
+
for (let i = t; r && i < n; i++) r = r.matchType(e.child(i).type);
|
|
738
|
+
return r;
|
|
739
|
+
}
|
|
740
|
+
get inlineContent() {
|
|
741
|
+
return this.next.length != 0 && this.next[0].type.isInline;
|
|
742
|
+
}
|
|
743
|
+
get defaultType() {
|
|
744
|
+
for (let e = 0; e < this.next.length; e++) {
|
|
745
|
+
let { type: t } = this.next[e];
|
|
746
|
+
if (!(t.isText || t.hasRequiredAttrs())) return t;
|
|
747
|
+
}
|
|
748
|
+
return null;
|
|
749
|
+
}
|
|
750
|
+
compatible(e) {
|
|
751
|
+
for (let t = 0; t < this.next.length; t++) for (let n = 0; n < e.next.length; n++) if (this.next[t].type == e.next[n].type) return !0;
|
|
752
|
+
return !1;
|
|
753
|
+
}
|
|
754
|
+
fillBefore(e, t = !1, n = 0) {
|
|
755
|
+
let r = [this];
|
|
756
|
+
function i(a, o) {
|
|
757
|
+
let s = a.matchFragment(e, n);
|
|
758
|
+
if (s && (!t || s.validEnd)) return w.from(o.map((e) => e.createAndFill()));
|
|
759
|
+
for (let e = 0; e < a.next.length; e++) {
|
|
760
|
+
let { type: t, next: n } = a.next[e];
|
|
761
|
+
if (!(t.isText || t.hasRequiredAttrs()) && r.indexOf(n) == -1) {
|
|
762
|
+
r.push(n);
|
|
763
|
+
let e = i(n, o.concat(t));
|
|
764
|
+
if (e) return e;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
return null;
|
|
768
|
+
}
|
|
769
|
+
return i(this, []);
|
|
770
|
+
}
|
|
771
|
+
findWrapping(e) {
|
|
772
|
+
for (let t = 0; t < this.wrapCache.length; t += 2) if (this.wrapCache[t] == e) return this.wrapCache[t + 1];
|
|
773
|
+
let t = this.computeWrapping(e);
|
|
774
|
+
return this.wrapCache.push(e, t), t;
|
|
775
|
+
}
|
|
776
|
+
computeWrapping(e) {
|
|
777
|
+
let t = /* @__PURE__ */ Object.create(null), n = [{
|
|
778
|
+
match: this,
|
|
779
|
+
type: null,
|
|
780
|
+
via: null
|
|
781
|
+
}];
|
|
782
|
+
for (; n.length;) {
|
|
783
|
+
let r = n.shift(), i = r.match;
|
|
784
|
+
if (i.matchType(e)) {
|
|
785
|
+
let e = [];
|
|
786
|
+
for (let t = r; t.type; t = t.via) e.push(t.type);
|
|
787
|
+
return e.reverse();
|
|
788
|
+
}
|
|
789
|
+
for (let e = 0; e < i.next.length; e++) {
|
|
790
|
+
let { type: a, next: o } = i.next[e];
|
|
791
|
+
!a.isLeaf && !a.hasRequiredAttrs() && !(a.name in t) && (!r.type || o.validEnd) && (n.push({
|
|
792
|
+
match: a.contentMatch,
|
|
793
|
+
type: a,
|
|
794
|
+
via: r
|
|
795
|
+
}), t[a.name] = !0);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
return null;
|
|
799
|
+
}
|
|
800
|
+
get edgeCount() {
|
|
801
|
+
return this.next.length;
|
|
802
|
+
}
|
|
803
|
+
edge(e) {
|
|
804
|
+
if (e >= this.next.length) throw RangeError(`There's no ${e}th edge in this content match`);
|
|
805
|
+
return this.next[e];
|
|
806
|
+
}
|
|
807
|
+
toString() {
|
|
808
|
+
let e = [];
|
|
809
|
+
function t(n) {
|
|
810
|
+
e.push(n);
|
|
811
|
+
for (let r = 0; r < n.next.length; r++) e.indexOf(n.next[r].next) == -1 && t(n.next[r].next);
|
|
812
|
+
}
|
|
813
|
+
return t(this), e.map((t, n) => {
|
|
814
|
+
let r = n + (t.validEnd ? "*" : " ") + " ";
|
|
815
|
+
for (let n = 0; n < t.next.length; n++) r += (n ? ", " : "") + t.next[n].type.name + "->" + e.indexOf(t.next[n].next);
|
|
816
|
+
return r;
|
|
817
|
+
}).join("\n");
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
Fe.empty = new Fe(!0);
|
|
821
|
+
var Ie = class {
|
|
822
|
+
constructor(e, t) {
|
|
823
|
+
this.string = e, this.nodeTypes = t, this.inline = null, this.pos = 0, this.tokens = e.split(/\s*(?=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift();
|
|
824
|
+
}
|
|
825
|
+
get next() {
|
|
826
|
+
return this.tokens[this.pos];
|
|
827
|
+
}
|
|
828
|
+
eat(e) {
|
|
829
|
+
return this.next == e && (this.pos++ || !0);
|
|
830
|
+
}
|
|
831
|
+
err(e) {
|
|
832
|
+
throw SyntaxError(e + " (in content expression '" + this.string + "')");
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
function Le(e) {
|
|
836
|
+
let t = [];
|
|
837
|
+
do
|
|
838
|
+
t.push(Re(e));
|
|
839
|
+
while (e.eat("|"));
|
|
840
|
+
return t.length == 1 ? t[0] : {
|
|
841
|
+
type: "choice",
|
|
842
|
+
exprs: t
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
function Re(e) {
|
|
846
|
+
let t = [];
|
|
847
|
+
do
|
|
848
|
+
t.push(ze(e));
|
|
849
|
+
while (e.next && e.next != ")" && e.next != "|");
|
|
850
|
+
return t.length == 1 ? t[0] : {
|
|
851
|
+
type: "seq",
|
|
852
|
+
exprs: t
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
function ze(e) {
|
|
856
|
+
let t = Ue(e);
|
|
857
|
+
for (;;) if (e.eat("+")) t = {
|
|
858
|
+
type: "plus",
|
|
859
|
+
expr: t
|
|
860
|
+
};
|
|
861
|
+
else if (e.eat("*")) t = {
|
|
862
|
+
type: "star",
|
|
863
|
+
expr: t
|
|
864
|
+
};
|
|
865
|
+
else if (e.eat("?")) t = {
|
|
866
|
+
type: "opt",
|
|
867
|
+
expr: t
|
|
868
|
+
};
|
|
869
|
+
else if (e.eat("{")) t = Ve(e, t);
|
|
870
|
+
else break;
|
|
871
|
+
return t;
|
|
872
|
+
}
|
|
873
|
+
function Be(e) {
|
|
874
|
+
/\D/.test(e.next) && e.err("Expected number, got '" + e.next + "'");
|
|
875
|
+
let t = Number(e.next);
|
|
876
|
+
return e.pos++, t;
|
|
877
|
+
}
|
|
878
|
+
function Ve(e, t) {
|
|
879
|
+
let n = Be(e), r = n;
|
|
880
|
+
return e.eat(",") && (r = e.next == "}" ? -1 : Be(e)), e.eat("}") || e.err("Unclosed braced range"), {
|
|
881
|
+
type: "range",
|
|
882
|
+
min: n,
|
|
883
|
+
max: r,
|
|
884
|
+
expr: t
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
function He(e, t) {
|
|
888
|
+
let n = e.nodeTypes, r = n[t];
|
|
889
|
+
if (r) return [r];
|
|
890
|
+
let i = [];
|
|
891
|
+
for (let e in n) {
|
|
892
|
+
let r = n[e];
|
|
893
|
+
r.isInGroup(t) && i.push(r);
|
|
894
|
+
}
|
|
895
|
+
return i.length == 0 && e.err("No node type or group '" + t + "' found"), i;
|
|
896
|
+
}
|
|
897
|
+
function Ue(e) {
|
|
898
|
+
if (e.eat("(")) {
|
|
899
|
+
let t = Le(e);
|
|
900
|
+
return e.eat(")") || e.err("Missing closing paren"), t;
|
|
901
|
+
} else if (/\W/.test(e.next)) e.err("Unexpected token '" + e.next + "'");
|
|
902
|
+
else {
|
|
903
|
+
let t = He(e, e.next).map((t) => (e.inline == null ? e.inline = t.isInline : e.inline != t.isInline && e.err("Mixing inline and block content"), {
|
|
904
|
+
type: "name",
|
|
905
|
+
value: t
|
|
906
|
+
}));
|
|
907
|
+
return e.pos++, t.length == 1 ? t[0] : {
|
|
908
|
+
type: "choice",
|
|
909
|
+
exprs: t
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
function We(e) {
|
|
914
|
+
let t = [[]];
|
|
915
|
+
return i(a(e, 0), n()), t;
|
|
916
|
+
function n() {
|
|
917
|
+
return t.push([]) - 1;
|
|
918
|
+
}
|
|
919
|
+
function r(e, n, r) {
|
|
920
|
+
let i = {
|
|
921
|
+
term: r,
|
|
922
|
+
to: n
|
|
923
|
+
};
|
|
924
|
+
return t[e].push(i), i;
|
|
925
|
+
}
|
|
926
|
+
function i(e, t) {
|
|
927
|
+
e.forEach((e) => e.to = t);
|
|
928
|
+
}
|
|
929
|
+
function a(e, t) {
|
|
930
|
+
if (e.type == "choice") return e.exprs.reduce((e, n) => e.concat(a(n, t)), []);
|
|
931
|
+
if (e.type == "seq") for (let r = 0;; r++) {
|
|
932
|
+
let o = a(e.exprs[r], t);
|
|
933
|
+
if (r == e.exprs.length - 1) return o;
|
|
934
|
+
i(o, t = n());
|
|
935
|
+
}
|
|
936
|
+
else if (e.type == "star") {
|
|
937
|
+
let o = n();
|
|
938
|
+
return r(t, o), i(a(e.expr, o), o), [r(o)];
|
|
939
|
+
} else if (e.type == "plus") {
|
|
940
|
+
let o = n();
|
|
941
|
+
return i(a(e.expr, t), o), i(a(e.expr, o), o), [r(o)];
|
|
942
|
+
} else if (e.type == "opt") return [r(t)].concat(a(e.expr, t));
|
|
943
|
+
else if (e.type == "range") {
|
|
944
|
+
let o = t;
|
|
945
|
+
for (let t = 0; t < e.min; t++) {
|
|
946
|
+
let t = n();
|
|
947
|
+
i(a(e.expr, o), t), o = t;
|
|
948
|
+
}
|
|
949
|
+
if (e.max == -1) i(a(e.expr, o), o);
|
|
950
|
+
else for (let t = e.min; t < e.max; t++) {
|
|
951
|
+
let t = n();
|
|
952
|
+
r(o, t), i(a(e.expr, o), t), o = t;
|
|
953
|
+
}
|
|
954
|
+
return [r(o)];
|
|
955
|
+
} else if (e.type == "name") return [r(t, void 0, e.value)];
|
|
956
|
+
else throw Error("Unknown expr type");
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
function Ge(e, t) {
|
|
960
|
+
return t - e;
|
|
961
|
+
}
|
|
962
|
+
function Ke(e, t) {
|
|
963
|
+
let n = [];
|
|
964
|
+
return r(t), n.sort(Ge);
|
|
965
|
+
function r(t) {
|
|
966
|
+
let i = e[t];
|
|
967
|
+
if (i.length == 1 && !i[0].term) return r(i[0].to);
|
|
968
|
+
n.push(t);
|
|
969
|
+
for (let e = 0; e < i.length; e++) {
|
|
970
|
+
let { term: t, to: a } = i[e];
|
|
971
|
+
!t && n.indexOf(a) == -1 && r(a);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
function qe(e) {
|
|
976
|
+
let t = /* @__PURE__ */ Object.create(null);
|
|
977
|
+
return n(Ke(e, 0));
|
|
978
|
+
function n(r) {
|
|
979
|
+
let i = [];
|
|
980
|
+
r.forEach((t) => {
|
|
981
|
+
e[t].forEach(({ term: t, to: n }) => {
|
|
982
|
+
if (!t) return;
|
|
983
|
+
let r;
|
|
984
|
+
for (let e = 0; e < i.length; e++) i[e][0] == t && (r = i[e][1]);
|
|
985
|
+
Ke(e, n).forEach((e) => {
|
|
986
|
+
r || i.push([t, r = []]), r.indexOf(e) == -1 && r.push(e);
|
|
987
|
+
});
|
|
988
|
+
});
|
|
989
|
+
});
|
|
990
|
+
let a = t[r.join(",")] = new Fe(r.indexOf(e.length - 1) > -1);
|
|
991
|
+
for (let e = 0; e < i.length; e++) {
|
|
992
|
+
let r = i[e][1].sort(Ge);
|
|
993
|
+
a.next.push({
|
|
994
|
+
type: i[e][0],
|
|
995
|
+
next: t[r.join(",")] || n(r)
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
return a;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
function Je(e, t) {
|
|
1002
|
+
for (let n = 0, r = [e]; n < r.length; n++) {
|
|
1003
|
+
let e = r[n], i = !e.validEnd, a = [];
|
|
1004
|
+
for (let t = 0; t < e.next.length; t++) {
|
|
1005
|
+
let { type: n, next: o } = e.next[t];
|
|
1006
|
+
a.push(n.name), i && !(n.isText || n.hasRequiredAttrs()) && (i = !1), r.indexOf(o) == -1 && r.push(o);
|
|
1007
|
+
}
|
|
1008
|
+
i && t.err("Only non-generatable nodes (" + a.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)");
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
var Ye = 65535, Xe = 2 ** 16;
|
|
1012
|
+
function Ze(e, t) {
|
|
1013
|
+
return e + t * Xe;
|
|
1014
|
+
}
|
|
1015
|
+
function Qe(e) {
|
|
1016
|
+
return e & Ye;
|
|
1017
|
+
}
|
|
1018
|
+
function $e(e) {
|
|
1019
|
+
return (e - (e & Ye)) / Xe;
|
|
1020
|
+
}
|
|
1021
|
+
var et = 1, tt = 2, M = 4, nt = 8, rt = class {
|
|
1022
|
+
constructor(e, t, n) {
|
|
1023
|
+
this.pos = e, this.delInfo = t, this.recover = n;
|
|
1024
|
+
}
|
|
1025
|
+
get deleted() {
|
|
1026
|
+
return (this.delInfo & nt) > 0;
|
|
1027
|
+
}
|
|
1028
|
+
get deletedBefore() {
|
|
1029
|
+
return (this.delInfo & (et | M)) > 0;
|
|
1030
|
+
}
|
|
1031
|
+
get deletedAfter() {
|
|
1032
|
+
return (this.delInfo & (tt | M)) > 0;
|
|
1033
|
+
}
|
|
1034
|
+
get deletedAcross() {
|
|
1035
|
+
return (this.delInfo & M) > 0;
|
|
1036
|
+
}
|
|
1037
|
+
}, N = class e {
|
|
1038
|
+
constructor(t, n = !1) {
|
|
1039
|
+
if (this.ranges = t, this.inverted = n, !t.length && e.empty) return e.empty;
|
|
1040
|
+
}
|
|
1041
|
+
recover(e) {
|
|
1042
|
+
let t = 0, n = Qe(e);
|
|
1043
|
+
if (!this.inverted) for (let e = 0; e < n; e++) t += this.ranges[e * 3 + 2] - this.ranges[e * 3 + 1];
|
|
1044
|
+
return this.ranges[n * 3] + t + $e(e);
|
|
1045
|
+
}
|
|
1046
|
+
mapResult(e, t = 1) {
|
|
1047
|
+
return this._map(e, t, !1);
|
|
1048
|
+
}
|
|
1049
|
+
map(e, t = 1) {
|
|
1050
|
+
return this._map(e, t, !0);
|
|
1051
|
+
}
|
|
1052
|
+
_map(e, t, n) {
|
|
1053
|
+
let r = 0, i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2;
|
|
1054
|
+
for (let o = 0; o < this.ranges.length; o += 3) {
|
|
1055
|
+
let s = this.ranges[o] - (this.inverted ? r : 0);
|
|
1056
|
+
if (s > e) break;
|
|
1057
|
+
let c = this.ranges[o + i], l = this.ranges[o + a], u = s + c;
|
|
1058
|
+
if (e <= u) {
|
|
1059
|
+
let i = c ? e == s ? -1 : e == u ? 1 : t : t, a = s + r + (i < 0 ? 0 : l);
|
|
1060
|
+
if (n) return a;
|
|
1061
|
+
let d = e == (t < 0 ? s : u) ? null : Ze(o / 3, e - s), f = e == s ? tt : e == u ? et : M;
|
|
1062
|
+
return (t < 0 ? e != s : e != u) && (f |= nt), new rt(a, f, d);
|
|
1063
|
+
}
|
|
1064
|
+
r += l - c;
|
|
1065
|
+
}
|
|
1066
|
+
return n ? e + r : new rt(e + r, 0, null);
|
|
1067
|
+
}
|
|
1068
|
+
touches(e, t) {
|
|
1069
|
+
let n = 0, r = Qe(t), i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2;
|
|
1070
|
+
for (let t = 0; t < this.ranges.length; t += 3) {
|
|
1071
|
+
let o = this.ranges[t] - (this.inverted ? n : 0);
|
|
1072
|
+
if (o > e) break;
|
|
1073
|
+
let s = this.ranges[t + i];
|
|
1074
|
+
if (e <= o + s && t == r * 3) return !0;
|
|
1075
|
+
n += this.ranges[t + a] - s;
|
|
1076
|
+
}
|
|
1077
|
+
return !1;
|
|
1078
|
+
}
|
|
1079
|
+
forEach(e) {
|
|
1080
|
+
let t = this.inverted ? 2 : 1, n = this.inverted ? 1 : 2;
|
|
1081
|
+
for (let r = 0, i = 0; r < this.ranges.length; r += 3) {
|
|
1082
|
+
let a = this.ranges[r], o = a - (this.inverted ? i : 0), s = a + (this.inverted ? 0 : i), c = this.ranges[r + t], l = this.ranges[r + n];
|
|
1083
|
+
e(o, o + c, s, s + l), i += l - c;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
invert() {
|
|
1087
|
+
return new e(this.ranges, !this.inverted);
|
|
1088
|
+
}
|
|
1089
|
+
toString() {
|
|
1090
|
+
return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
|
|
1091
|
+
}
|
|
1092
|
+
static offset(t) {
|
|
1093
|
+
return t == 0 ? e.empty : new e(t < 0 ? [
|
|
1094
|
+
0,
|
|
1095
|
+
-t,
|
|
1096
|
+
0
|
|
1097
|
+
] : [
|
|
1098
|
+
0,
|
|
1099
|
+
0,
|
|
1100
|
+
t
|
|
1101
|
+
]);
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
N.empty = new N([]);
|
|
1105
|
+
var it = /* @__PURE__ */ Object.create(null), P = class {
|
|
1106
|
+
getMap() {
|
|
1107
|
+
return N.empty;
|
|
1108
|
+
}
|
|
1109
|
+
merge(e) {
|
|
1110
|
+
return null;
|
|
1111
|
+
}
|
|
1112
|
+
static fromJSON(e, t) {
|
|
1113
|
+
if (!t || !t.stepType) throw RangeError("Invalid input for Step.fromJSON");
|
|
1114
|
+
let n = it[t.stepType];
|
|
1115
|
+
if (!n) throw RangeError(`No step type ${t.stepType} defined`);
|
|
1116
|
+
return n.fromJSON(e, t);
|
|
1117
|
+
}
|
|
1118
|
+
static jsonID(e, t) {
|
|
1119
|
+
if (e in it) throw RangeError("Duplicate use of step JSON ID " + e);
|
|
1120
|
+
return it[e] = t, t.prototype.jsonID = e, t;
|
|
1121
|
+
}
|
|
1122
|
+
}, F = class e {
|
|
1123
|
+
constructor(e, t) {
|
|
1124
|
+
this.doc = e, this.failed = t;
|
|
1125
|
+
}
|
|
1126
|
+
static ok(t) {
|
|
1127
|
+
return new e(t, null);
|
|
1128
|
+
}
|
|
1129
|
+
static fail(t) {
|
|
1130
|
+
return new e(null, t);
|
|
1131
|
+
}
|
|
1132
|
+
static fromReplace(t, n, r, i) {
|
|
1133
|
+
try {
|
|
1134
|
+
return e.ok(t.replace(n, r, i));
|
|
1135
|
+
} catch (t) {
|
|
1136
|
+
if (t instanceof E) return e.fail(t.message);
|
|
1137
|
+
throw t;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
function at(e, t, n) {
|
|
1142
|
+
let r = [];
|
|
1143
|
+
for (let i = 0; i < e.childCount; i++) {
|
|
1144
|
+
let a = e.child(i);
|
|
1145
|
+
a.content.size && (a = a.copy(at(a.content, t, a))), a.isInline && (a = t(a, n, i)), r.push(a);
|
|
1146
|
+
}
|
|
1147
|
+
return w.fromArray(r);
|
|
1148
|
+
}
|
|
1149
|
+
var ot = class e extends P {
|
|
1150
|
+
constructor(e, t, n) {
|
|
1151
|
+
super(), this.from = e, this.to = t, this.mark = n;
|
|
1152
|
+
}
|
|
1153
|
+
apply(e) {
|
|
1154
|
+
let t = e.slice(this.from, this.to), n = e.resolve(this.from), r = n.node(n.sharedDepth(this.to)), i = new D(at(t.content, (e, t) => !e.isAtom || !t.type.allowsMarkType(this.mark.type) ? e : e.mark(this.mark.addToSet(e.marks)), r), t.openStart, t.openEnd);
|
|
1155
|
+
return F.fromReplace(e, this.from, this.to, i);
|
|
1156
|
+
}
|
|
1157
|
+
invert() {
|
|
1158
|
+
return new st(this.from, this.to, this.mark);
|
|
1159
|
+
}
|
|
1160
|
+
map(t) {
|
|
1161
|
+
let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
|
|
1162
|
+
return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark);
|
|
1163
|
+
}
|
|
1164
|
+
merge(t) {
|
|
1165
|
+
return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null;
|
|
1166
|
+
}
|
|
1167
|
+
toJSON() {
|
|
1168
|
+
return {
|
|
1169
|
+
stepType: "addMark",
|
|
1170
|
+
mark: this.mark.toJSON(),
|
|
1171
|
+
from: this.from,
|
|
1172
|
+
to: this.to
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
static fromJSON(t, n) {
|
|
1176
|
+
if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for AddMarkStep.fromJSON");
|
|
1177
|
+
return new e(n.from, n.to, t.markFromJSON(n.mark));
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
P.jsonID("addMark", ot);
|
|
1181
|
+
var st = class e extends P {
|
|
1182
|
+
constructor(e, t, n) {
|
|
1183
|
+
super(), this.from = e, this.to = t, this.mark = n;
|
|
1184
|
+
}
|
|
1185
|
+
apply(e) {
|
|
1186
|
+
let t = e.slice(this.from, this.to), n = new D(at(t.content, (e) => e.mark(this.mark.removeFromSet(e.marks)), e), t.openStart, t.openEnd);
|
|
1187
|
+
return F.fromReplace(e, this.from, this.to, n);
|
|
1188
|
+
}
|
|
1189
|
+
invert() {
|
|
1190
|
+
return new ot(this.from, this.to, this.mark);
|
|
1191
|
+
}
|
|
1192
|
+
map(t) {
|
|
1193
|
+
let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
|
|
1194
|
+
return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark);
|
|
1195
|
+
}
|
|
1196
|
+
merge(t) {
|
|
1197
|
+
return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null;
|
|
1198
|
+
}
|
|
1199
|
+
toJSON() {
|
|
1200
|
+
return {
|
|
1201
|
+
stepType: "removeMark",
|
|
1202
|
+
mark: this.mark.toJSON(),
|
|
1203
|
+
from: this.from,
|
|
1204
|
+
to: this.to
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
static fromJSON(t, n) {
|
|
1208
|
+
if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for RemoveMarkStep.fromJSON");
|
|
1209
|
+
return new e(n.from, n.to, t.markFromJSON(n.mark));
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1212
|
+
P.jsonID("removeMark", st);
|
|
1213
|
+
var ct = class e extends P {
|
|
1214
|
+
constructor(e, t) {
|
|
1215
|
+
super(), this.pos = e, this.mark = t;
|
|
1216
|
+
}
|
|
1217
|
+
apply(e) {
|
|
1218
|
+
let t = e.nodeAt(this.pos);
|
|
1219
|
+
if (!t) return F.fail("No node at mark step's position");
|
|
1220
|
+
let n = t.type.create(t.attrs, null, this.mark.addToSet(t.marks));
|
|
1221
|
+
return F.fromReplace(e, this.pos, this.pos + 1, new D(w.from(n), 0, +!t.isLeaf));
|
|
1222
|
+
}
|
|
1223
|
+
invert(t) {
|
|
1224
|
+
let n = t.nodeAt(this.pos);
|
|
1225
|
+
if (n) {
|
|
1226
|
+
let t = this.mark.addToSet(n.marks);
|
|
1227
|
+
if (t.length == n.marks.length) {
|
|
1228
|
+
for (let r = 0; r < n.marks.length; r++) if (!n.marks[r].isInSet(t)) return new e(this.pos, n.marks[r]);
|
|
1229
|
+
return new e(this.pos, this.mark);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
return new lt(this.pos, this.mark);
|
|
1233
|
+
}
|
|
1234
|
+
map(t) {
|
|
1235
|
+
let n = t.mapResult(this.pos, 1);
|
|
1236
|
+
return n.deletedAfter ? null : new e(n.pos, this.mark);
|
|
1237
|
+
}
|
|
1238
|
+
toJSON() {
|
|
1239
|
+
return {
|
|
1240
|
+
stepType: "addNodeMark",
|
|
1241
|
+
pos: this.pos,
|
|
1242
|
+
mark: this.mark.toJSON()
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
static fromJSON(t, n) {
|
|
1246
|
+
if (typeof n.pos != "number") throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");
|
|
1247
|
+
return new e(n.pos, t.markFromJSON(n.mark));
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
P.jsonID("addNodeMark", ct);
|
|
1251
|
+
var lt = class e extends P {
|
|
1252
|
+
constructor(e, t) {
|
|
1253
|
+
super(), this.pos = e, this.mark = t;
|
|
1254
|
+
}
|
|
1255
|
+
apply(e) {
|
|
1256
|
+
let t = e.nodeAt(this.pos);
|
|
1257
|
+
if (!t) return F.fail("No node at mark step's position");
|
|
1258
|
+
let n = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks));
|
|
1259
|
+
return F.fromReplace(e, this.pos, this.pos + 1, new D(w.from(n), 0, +!t.isLeaf));
|
|
1260
|
+
}
|
|
1261
|
+
invert(e) {
|
|
1262
|
+
let t = e.nodeAt(this.pos);
|
|
1263
|
+
return !t || !this.mark.isInSet(t.marks) ? this : new ct(this.pos, this.mark);
|
|
1264
|
+
}
|
|
1265
|
+
map(t) {
|
|
1266
|
+
let n = t.mapResult(this.pos, 1);
|
|
1267
|
+
return n.deletedAfter ? null : new e(n.pos, this.mark);
|
|
1268
|
+
}
|
|
1269
|
+
toJSON() {
|
|
1270
|
+
return {
|
|
1271
|
+
stepType: "removeNodeMark",
|
|
1272
|
+
pos: this.pos,
|
|
1273
|
+
mark: this.mark.toJSON()
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
static fromJSON(t, n) {
|
|
1277
|
+
if (typeof n.pos != "number") throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
|
|
1278
|
+
return new e(n.pos, t.markFromJSON(n.mark));
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
P.jsonID("removeNodeMark", lt);
|
|
1282
|
+
var ut = class e extends P {
|
|
1283
|
+
constructor(e, t, n, r = !1) {
|
|
1284
|
+
super(), this.from = e, this.to = t, this.slice = n, this.structure = r;
|
|
1285
|
+
}
|
|
1286
|
+
apply(e) {
|
|
1287
|
+
return this.structure && ft(e, this.from, this.to) ? F.fail("Structure replace would overwrite content") : F.fromReplace(e, this.from, this.to, this.slice);
|
|
1288
|
+
}
|
|
1289
|
+
getMap() {
|
|
1290
|
+
return new N([
|
|
1291
|
+
this.from,
|
|
1292
|
+
this.to - this.from,
|
|
1293
|
+
this.slice.size
|
|
1294
|
+
]);
|
|
1295
|
+
}
|
|
1296
|
+
invert(t) {
|
|
1297
|
+
return new e(this.from, this.from + this.slice.size, t.slice(this.from, this.to));
|
|
1298
|
+
}
|
|
1299
|
+
map(t) {
|
|
1300
|
+
let n = t.mapResult(this.to, -1), r = this.from == this.to && e.MAP_BIAS < 0 ? n : t.mapResult(this.from, 1);
|
|
1301
|
+
return r.deletedAcross && n.deletedAcross ? null : new e(r.pos, Math.max(r.pos, n.pos), this.slice, this.structure);
|
|
1302
|
+
}
|
|
1303
|
+
merge(t) {
|
|
1304
|
+
if (!(t instanceof e) || t.structure || this.structure) return null;
|
|
1305
|
+
if (this.from + this.slice.size == t.from && !this.slice.openEnd && !t.slice.openStart) {
|
|
1306
|
+
let n = this.slice.size + t.slice.size == 0 ? D.empty : new D(this.slice.content.append(t.slice.content), this.slice.openStart, t.slice.openEnd);
|
|
1307
|
+
return new e(this.from, this.to + (t.to - t.from), n, this.structure);
|
|
1308
|
+
} else if (t.to == this.from && !this.slice.openStart && !t.slice.openEnd) {
|
|
1309
|
+
let n = this.slice.size + t.slice.size == 0 ? D.empty : new D(t.slice.content.append(this.slice.content), t.slice.openStart, this.slice.openEnd);
|
|
1310
|
+
return new e(t.from, this.to, n, this.structure);
|
|
1311
|
+
} else return null;
|
|
1312
|
+
}
|
|
1313
|
+
toJSON() {
|
|
1314
|
+
let e = {
|
|
1315
|
+
stepType: "replace",
|
|
1316
|
+
from: this.from,
|
|
1317
|
+
to: this.to
|
|
1318
|
+
};
|
|
1319
|
+
return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
|
|
1320
|
+
}
|
|
1321
|
+
static fromJSON(t, n) {
|
|
1322
|
+
if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for ReplaceStep.fromJSON");
|
|
1323
|
+
return new e(n.from, n.to, D.fromJSON(t, n.slice), !!n.structure);
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
ut.MAP_BIAS = 1, P.jsonID("replace", ut);
|
|
1327
|
+
var dt = class e extends P {
|
|
1328
|
+
constructor(e, t, n, r, i, a, o = !1) {
|
|
1329
|
+
super(), this.from = e, this.to = t, this.gapFrom = n, this.gapTo = r, this.slice = i, this.insert = a, this.structure = o;
|
|
1330
|
+
}
|
|
1331
|
+
apply(e) {
|
|
1332
|
+
if (this.structure && (ft(e, this.from, this.gapFrom) || ft(e, this.gapTo, this.to))) return F.fail("Structure gap-replace would overwrite content");
|
|
1333
|
+
let t = e.slice(this.gapFrom, this.gapTo);
|
|
1334
|
+
if (t.openStart || t.openEnd) return F.fail("Gap is not a flat range");
|
|
1335
|
+
let n = this.slice.insertAt(this.insert, t.content);
|
|
1336
|
+
return n ? F.fromReplace(e, this.from, this.to, n) : F.fail("Content does not fit in gap");
|
|
1337
|
+
}
|
|
1338
|
+
getMap() {
|
|
1339
|
+
return new N([
|
|
1340
|
+
this.from,
|
|
1341
|
+
this.gapFrom - this.from,
|
|
1342
|
+
this.insert,
|
|
1343
|
+
this.gapTo,
|
|
1344
|
+
this.to - this.gapTo,
|
|
1345
|
+
this.slice.size - this.insert
|
|
1346
|
+
]);
|
|
1347
|
+
}
|
|
1348
|
+
invert(t) {
|
|
1349
|
+
let n = this.gapTo - this.gapFrom;
|
|
1350
|
+
return new e(this.from, this.from + this.slice.size + n, this.from + this.insert, this.from + this.insert + n, t.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
|
|
1351
|
+
}
|
|
1352
|
+
map(t) {
|
|
1353
|
+
let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1), i = this.from == this.gapFrom ? n.pos : t.map(this.gapFrom, -1), a = this.to == this.gapTo ? r.pos : t.map(this.gapTo, 1);
|
|
1354
|
+
return n.deletedAcross && r.deletedAcross || i < n.pos || a > r.pos ? null : new e(n.pos, r.pos, i, a, this.slice, this.insert, this.structure);
|
|
1355
|
+
}
|
|
1356
|
+
toJSON() {
|
|
1357
|
+
let e = {
|
|
1358
|
+
stepType: "replaceAround",
|
|
1359
|
+
from: this.from,
|
|
1360
|
+
to: this.to,
|
|
1361
|
+
gapFrom: this.gapFrom,
|
|
1362
|
+
gapTo: this.gapTo,
|
|
1363
|
+
insert: this.insert
|
|
1364
|
+
};
|
|
1365
|
+
return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
|
|
1366
|
+
}
|
|
1367
|
+
static fromJSON(t, n) {
|
|
1368
|
+
if (typeof n.from != "number" || typeof n.to != "number" || typeof n.gapFrom != "number" || typeof n.gapTo != "number" || typeof n.insert != "number") throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");
|
|
1369
|
+
return new e(n.from, n.to, n.gapFrom, n.gapTo, D.fromJSON(t, n.slice), n.insert, !!n.structure);
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
P.jsonID("replaceAround", dt);
|
|
1373
|
+
function ft(e, t, n) {
|
|
1374
|
+
let r = e.resolve(t), i = n - t, a = r.depth;
|
|
1375
|
+
for (; i > 0 && a > 0 && r.indexAfter(a) == r.node(a).childCount;) a--, i--;
|
|
1376
|
+
if (i > 0) {
|
|
1377
|
+
let e = r.node(a).maybeChild(r.indexAfter(a));
|
|
1378
|
+
for (; i > 0;) {
|
|
1379
|
+
if (!e || e.isLeaf) return !0;
|
|
1380
|
+
e = e.firstChild, i--;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
return !1;
|
|
1384
|
+
}
|
|
1385
|
+
var pt = class e extends P {
|
|
1386
|
+
constructor(e, t, n) {
|
|
1387
|
+
super(), this.pos = e, this.attr = t, this.value = n;
|
|
1388
|
+
}
|
|
1389
|
+
apply(e) {
|
|
1390
|
+
let t = e.nodeAt(this.pos);
|
|
1391
|
+
if (!t) return F.fail("No node at attribute step's position");
|
|
1392
|
+
let n = /* @__PURE__ */ Object.create(null);
|
|
1393
|
+
for (let e in t.attrs) n[e] = t.attrs[e];
|
|
1394
|
+
n[this.attr] = this.value;
|
|
1395
|
+
let r = t.type.create(n, null, t.marks);
|
|
1396
|
+
return F.fromReplace(e, this.pos, this.pos + 1, new D(w.from(r), 0, +!t.isLeaf));
|
|
1397
|
+
}
|
|
1398
|
+
getMap() {
|
|
1399
|
+
return N.empty;
|
|
1400
|
+
}
|
|
1401
|
+
invert(t) {
|
|
1402
|
+
return new e(this.pos, this.attr, t.nodeAt(this.pos).attrs[this.attr]);
|
|
1403
|
+
}
|
|
1404
|
+
map(t) {
|
|
1405
|
+
let n = t.mapResult(this.pos, 1);
|
|
1406
|
+
return n.deletedAfter ? null : new e(n.pos, this.attr, this.value);
|
|
1407
|
+
}
|
|
1408
|
+
toJSON() {
|
|
1409
|
+
return {
|
|
1410
|
+
stepType: "attr",
|
|
1411
|
+
pos: this.pos,
|
|
1412
|
+
attr: this.attr,
|
|
1413
|
+
value: this.value
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
static fromJSON(t, n) {
|
|
1417
|
+
if (typeof n.pos != "number" || typeof n.attr != "string") throw RangeError("Invalid input for AttrStep.fromJSON");
|
|
1418
|
+
return new e(n.pos, n.attr, n.value);
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
P.jsonID("attr", pt);
|
|
1422
|
+
var mt = class e extends P {
|
|
1423
|
+
constructor(e, t) {
|
|
1424
|
+
super(), this.attr = e, this.value = t;
|
|
1425
|
+
}
|
|
1426
|
+
apply(e) {
|
|
1427
|
+
let t = /* @__PURE__ */ Object.create(null);
|
|
1428
|
+
for (let n in e.attrs) t[n] = e.attrs[n];
|
|
1429
|
+
t[this.attr] = this.value;
|
|
1430
|
+
let n = e.type.create(t, e.content, e.marks);
|
|
1431
|
+
return F.ok(n);
|
|
1432
|
+
}
|
|
1433
|
+
getMap() {
|
|
1434
|
+
return N.empty;
|
|
1435
|
+
}
|
|
1436
|
+
invert(t) {
|
|
1437
|
+
return new e(this.attr, t.attrs[this.attr]);
|
|
1438
|
+
}
|
|
1439
|
+
map(e) {
|
|
1440
|
+
return this;
|
|
1441
|
+
}
|
|
1442
|
+
toJSON() {
|
|
1443
|
+
return {
|
|
1444
|
+
stepType: "docAttr",
|
|
1445
|
+
attr: this.attr,
|
|
1446
|
+
value: this.value
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
static fromJSON(t, n) {
|
|
1450
|
+
if (typeof n.attr != "string") throw RangeError("Invalid input for DocAttrStep.fromJSON");
|
|
1451
|
+
return new e(n.attr, n.value);
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
P.jsonID("docAttr", mt);
|
|
1455
|
+
var I = class extends Error {};
|
|
1456
|
+
I = function e(t) {
|
|
1457
|
+
let n = Error.call(this, t);
|
|
1458
|
+
return n.__proto__ = e.prototype, n;
|
|
1459
|
+
}, I.prototype = Object.create(Error.prototype), I.prototype.constructor = I, I.prototype.name = "TransformError";
|
|
1460
|
+
var ht = /* @__PURE__ */ Object.create(null), L = class {
|
|
1461
|
+
constructor(e, t, n) {
|
|
1462
|
+
this.$anchor = e, this.$head = t, this.ranges = n || [new gt(e.min(t), e.max(t))];
|
|
1463
|
+
}
|
|
1464
|
+
get anchor() {
|
|
1465
|
+
return this.$anchor.pos;
|
|
1466
|
+
}
|
|
1467
|
+
get head() {
|
|
1468
|
+
return this.$head.pos;
|
|
1469
|
+
}
|
|
1470
|
+
get from() {
|
|
1471
|
+
return this.$from.pos;
|
|
1472
|
+
}
|
|
1473
|
+
get to() {
|
|
1474
|
+
return this.$to.pos;
|
|
1475
|
+
}
|
|
1476
|
+
get $from() {
|
|
1477
|
+
return this.ranges[0].$from;
|
|
1478
|
+
}
|
|
1479
|
+
get $to() {
|
|
1480
|
+
return this.ranges[0].$to;
|
|
1481
|
+
}
|
|
1482
|
+
get empty() {
|
|
1483
|
+
let e = this.ranges;
|
|
1484
|
+
for (let t = 0; t < e.length; t++) if (e[t].$from.pos != e[t].$to.pos) return !1;
|
|
1485
|
+
return !0;
|
|
1486
|
+
}
|
|
1487
|
+
content() {
|
|
1488
|
+
return this.$from.doc.slice(this.from, this.to, !0);
|
|
1489
|
+
}
|
|
1490
|
+
replace(e, t = D.empty) {
|
|
1491
|
+
let n = t.content.lastChild, r = null;
|
|
1492
|
+
for (let e = 0; e < t.openEnd; e++) r = n, n = n.lastChild;
|
|
1493
|
+
let i = e.steps.length, a = this.ranges;
|
|
1494
|
+
for (let o = 0; o < a.length; o++) {
|
|
1495
|
+
let { $from: s, $to: c } = a[o], l = e.mapping.slice(i);
|
|
1496
|
+
e.replaceRange(l.map(s.pos), l.map(c.pos), o ? D.empty : t), o == 0 && St(e, i, (n ? n.isInline : r && r.isTextblock) ? -1 : 1);
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
replaceWith(e, t) {
|
|
1500
|
+
let n = e.steps.length, r = this.ranges;
|
|
1501
|
+
for (let i = 0; i < r.length; i++) {
|
|
1502
|
+
let { $from: a, $to: o } = r[i], s = e.mapping.slice(n), c = s.map(a.pos), l = s.map(o.pos);
|
|
1503
|
+
i ? e.deleteRange(c, l) : (e.replaceRangeWith(c, l, t), St(e, n, t.isInline ? -1 : 1));
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
static findFrom(e, t, n = !1) {
|
|
1507
|
+
let r = e.parent.inlineContent ? new R(e) : V(e.node(0), e.parent, e.pos, e.index(), t, n);
|
|
1508
|
+
if (r) return r;
|
|
1509
|
+
for (let r = e.depth - 1; r >= 0; r--) {
|
|
1510
|
+
let i = t < 0 ? V(e.node(0), e.node(r), e.before(r + 1), e.index(r), t, n) : V(e.node(0), e.node(r), e.after(r + 1), e.index(r) + 1, t, n);
|
|
1511
|
+
if (i) return i;
|
|
1512
|
+
}
|
|
1513
|
+
return null;
|
|
1514
|
+
}
|
|
1515
|
+
static near(e, t = 1) {
|
|
1516
|
+
return this.findFrom(e, t) || this.findFrom(e, -t) || new B(e.node(0));
|
|
1517
|
+
}
|
|
1518
|
+
static atStart(e) {
|
|
1519
|
+
return V(e, e, 0, 0, 1) || new B(e);
|
|
1520
|
+
}
|
|
1521
|
+
static atEnd(e) {
|
|
1522
|
+
return V(e, e, e.content.size, e.childCount, -1) || new B(e);
|
|
1523
|
+
}
|
|
1524
|
+
static fromJSON(e, t) {
|
|
1525
|
+
if (!t || !t.type) throw RangeError("Invalid input for Selection.fromJSON");
|
|
1526
|
+
let n = ht[t.type];
|
|
1527
|
+
if (!n) throw RangeError(`No selection type ${t.type} defined`);
|
|
1528
|
+
return n.fromJSON(e, t);
|
|
1529
|
+
}
|
|
1530
|
+
static jsonID(e, t) {
|
|
1531
|
+
if (e in ht) throw RangeError("Duplicate use of selection JSON ID " + e);
|
|
1532
|
+
return ht[e] = t, t.prototype.jsonID = e, t;
|
|
1533
|
+
}
|
|
1534
|
+
getBookmark() {
|
|
1535
|
+
return R.between(this.$anchor, this.$head).getBookmark();
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
L.prototype.visible = !0;
|
|
1539
|
+
var gt = class {
|
|
1540
|
+
constructor(e, t) {
|
|
1541
|
+
this.$from = e, this.$to = t;
|
|
1542
|
+
}
|
|
1543
|
+
}, _t = !1;
|
|
1544
|
+
function vt(e) {
|
|
1545
|
+
!_t && !e.parent.inlineContent && (_t = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + e.parent.type.name + ")"));
|
|
1546
|
+
}
|
|
1547
|
+
var R = class e extends L {
|
|
1548
|
+
constructor(e, t = e) {
|
|
1549
|
+
vt(e), vt(t), super(e, t);
|
|
1550
|
+
}
|
|
1551
|
+
get $cursor() {
|
|
1552
|
+
return this.$anchor.pos == this.$head.pos ? this.$head : null;
|
|
1553
|
+
}
|
|
1554
|
+
map(t, n) {
|
|
1555
|
+
let r = t.resolve(n.map(this.head));
|
|
1556
|
+
if (!r.parent.inlineContent) return L.near(r);
|
|
1557
|
+
let i = t.resolve(n.map(this.anchor));
|
|
1558
|
+
return new e(i.parent.inlineContent ? i : r, r);
|
|
1559
|
+
}
|
|
1560
|
+
replace(e, t = D.empty) {
|
|
1561
|
+
if (super.replace(e, t), t == D.empty) {
|
|
1562
|
+
let t = this.$from.marksAcross(this.$to);
|
|
1563
|
+
t && e.ensureMarks(t);
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
eq(t) {
|
|
1567
|
+
return t instanceof e && t.anchor == this.anchor && t.head == this.head;
|
|
1568
|
+
}
|
|
1569
|
+
getBookmark() {
|
|
1570
|
+
return new yt(this.anchor, this.head);
|
|
1571
|
+
}
|
|
1572
|
+
toJSON() {
|
|
1573
|
+
return {
|
|
1574
|
+
type: "text",
|
|
1575
|
+
anchor: this.anchor,
|
|
1576
|
+
head: this.head
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
static fromJSON(t, n) {
|
|
1580
|
+
if (typeof n.anchor != "number" || typeof n.head != "number") throw RangeError("Invalid input for TextSelection.fromJSON");
|
|
1581
|
+
return new e(t.resolve(n.anchor), t.resolve(n.head));
|
|
1582
|
+
}
|
|
1583
|
+
static create(e, t, n = t) {
|
|
1584
|
+
let r = e.resolve(t);
|
|
1585
|
+
return new this(r, n == t ? r : e.resolve(n));
|
|
1586
|
+
}
|
|
1587
|
+
static between(t, n, r) {
|
|
1588
|
+
let i = t.pos - n.pos;
|
|
1589
|
+
if ((!r || i) && (r = i >= 0 ? 1 : -1), !n.parent.inlineContent) {
|
|
1590
|
+
let e = L.findFrom(n, r, !0) || L.findFrom(n, -r, !0);
|
|
1591
|
+
if (e) n = e.$head;
|
|
1592
|
+
else return L.near(n, r);
|
|
1593
|
+
}
|
|
1594
|
+
return t.parent.inlineContent || (i == 0 ? t = n : (t = (L.findFrom(t, -r, !0) || L.findFrom(t, r, !0)).$anchor, t.pos < n.pos != i < 0 && (t = n))), new e(t, n);
|
|
1595
|
+
}
|
|
1596
|
+
};
|
|
1597
|
+
L.jsonID("text", R);
|
|
1598
|
+
var yt = class e {
|
|
1599
|
+
constructor(e, t) {
|
|
1600
|
+
this.anchor = e, this.head = t;
|
|
1601
|
+
}
|
|
1602
|
+
map(t) {
|
|
1603
|
+
return new e(t.map(this.anchor), t.map(this.head));
|
|
1604
|
+
}
|
|
1605
|
+
resolve(e) {
|
|
1606
|
+
return R.between(e.resolve(this.anchor), e.resolve(this.head));
|
|
1607
|
+
}
|
|
1608
|
+
}, z = class e extends L {
|
|
1609
|
+
constructor(e) {
|
|
1610
|
+
let t = e.nodeAfter, n = e.node(0).resolve(e.pos + t.nodeSize);
|
|
1611
|
+
super(e, n), this.node = t;
|
|
1612
|
+
}
|
|
1613
|
+
map(t, n) {
|
|
1614
|
+
let { deleted: r, pos: i } = n.mapResult(this.anchor), a = t.resolve(i);
|
|
1615
|
+
return r ? L.near(a) : new e(a);
|
|
1616
|
+
}
|
|
1617
|
+
content() {
|
|
1618
|
+
return new D(w.from(this.node), 0, 0);
|
|
1619
|
+
}
|
|
1620
|
+
eq(t) {
|
|
1621
|
+
return t instanceof e && t.anchor == this.anchor;
|
|
1622
|
+
}
|
|
1623
|
+
toJSON() {
|
|
1624
|
+
return {
|
|
1625
|
+
type: "node",
|
|
1626
|
+
anchor: this.anchor
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
getBookmark() {
|
|
1630
|
+
return new bt(this.anchor);
|
|
1631
|
+
}
|
|
1632
|
+
static fromJSON(t, n) {
|
|
1633
|
+
if (typeof n.anchor != "number") throw RangeError("Invalid input for NodeSelection.fromJSON");
|
|
1634
|
+
return new e(t.resolve(n.anchor));
|
|
1635
|
+
}
|
|
1636
|
+
static create(t, n) {
|
|
1637
|
+
return new e(t.resolve(n));
|
|
1638
|
+
}
|
|
1639
|
+
static isSelectable(e) {
|
|
1640
|
+
return !e.isText && e.type.spec.selectable !== !1;
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
z.prototype.visible = !1, L.jsonID("node", z);
|
|
1644
|
+
var bt = class e {
|
|
1645
|
+
constructor(e) {
|
|
1646
|
+
this.anchor = e;
|
|
1647
|
+
}
|
|
1648
|
+
map(t) {
|
|
1649
|
+
let { deleted: n, pos: r } = t.mapResult(this.anchor);
|
|
1650
|
+
return n ? new yt(r, r) : new e(r);
|
|
1651
|
+
}
|
|
1652
|
+
resolve(e) {
|
|
1653
|
+
let t = e.resolve(this.anchor), n = t.nodeAfter;
|
|
1654
|
+
return n && z.isSelectable(n) ? new z(t) : L.near(t);
|
|
1655
|
+
}
|
|
1656
|
+
}, B = class e extends L {
|
|
1657
|
+
constructor(e) {
|
|
1658
|
+
super(e.resolve(0), e.resolve(e.content.size));
|
|
1659
|
+
}
|
|
1660
|
+
replace(e, t = D.empty) {
|
|
1661
|
+
if (t == D.empty) {
|
|
1662
|
+
e.delete(0, e.doc.content.size);
|
|
1663
|
+
let t = L.atStart(e.doc);
|
|
1664
|
+
t.eq(e.selection) || e.setSelection(t);
|
|
1665
|
+
} else super.replace(e, t);
|
|
1666
|
+
}
|
|
1667
|
+
toJSON() {
|
|
1668
|
+
return { type: "all" };
|
|
1669
|
+
}
|
|
1670
|
+
static fromJSON(t) {
|
|
1671
|
+
return new e(t);
|
|
1672
|
+
}
|
|
1673
|
+
map(t) {
|
|
1674
|
+
return new e(t);
|
|
1675
|
+
}
|
|
1676
|
+
eq(t) {
|
|
1677
|
+
return t instanceof e;
|
|
1678
|
+
}
|
|
1679
|
+
getBookmark() {
|
|
1680
|
+
return xt;
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
L.jsonID("all", B);
|
|
1684
|
+
var xt = {
|
|
1685
|
+
map() {
|
|
1686
|
+
return this;
|
|
1687
|
+
},
|
|
1688
|
+
resolve(e) {
|
|
1689
|
+
return new B(e);
|
|
1690
|
+
}
|
|
1691
|
+
};
|
|
1692
|
+
function V(e, t, n, r, i, a = !1) {
|
|
1693
|
+
if (t.inlineContent) return R.create(e, n);
|
|
1694
|
+
for (let o = r - (i > 0 ? 0 : 1); i > 0 ? o < t.childCount : o >= 0; o += i) {
|
|
1695
|
+
let r = t.child(o);
|
|
1696
|
+
if (!r.isAtom) {
|
|
1697
|
+
let t = V(e, r, n + i, i < 0 ? r.childCount : 0, i, a);
|
|
1698
|
+
if (t) return t;
|
|
1699
|
+
} else if (!a && z.isSelectable(r)) return z.create(e, n - (i < 0 ? r.nodeSize : 0));
|
|
1700
|
+
n += r.nodeSize * i;
|
|
1701
|
+
}
|
|
1702
|
+
return null;
|
|
1703
|
+
}
|
|
1704
|
+
function St(e, t, n) {
|
|
1705
|
+
let r = e.steps.length - 1;
|
|
1706
|
+
if (r < t) return;
|
|
1707
|
+
let i = e.steps[r];
|
|
1708
|
+
if (!(i instanceof ut || i instanceof dt)) return;
|
|
1709
|
+
let a = e.mapping.maps[r], o;
|
|
1710
|
+
a.forEach((e, t, n, r) => {
|
|
1711
|
+
o ??= r;
|
|
1712
|
+
}), e.setSelection(L.near(e.doc.resolve(o), n));
|
|
1713
|
+
}
|
|
1714
|
+
function Ct(e, t) {
|
|
1715
|
+
return !t || !e ? e : e.bind(t);
|
|
1716
|
+
}
|
|
1717
|
+
var H = class {
|
|
1718
|
+
constructor(e, t, n) {
|
|
1719
|
+
this.name = e, this.init = Ct(t.init, n), this.apply = Ct(t.apply, n);
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
new H("doc", {
|
|
1723
|
+
init(e) {
|
|
1724
|
+
return e.doc || e.schema.topNodeType.createAndFill();
|
|
1725
|
+
},
|
|
1726
|
+
apply(e) {
|
|
1727
|
+
return e.doc;
|
|
1728
|
+
}
|
|
1729
|
+
}), new H("selection", {
|
|
1730
|
+
init(e, t) {
|
|
1731
|
+
return e.selection || L.atStart(t.doc);
|
|
1732
|
+
},
|
|
1733
|
+
apply(e) {
|
|
1734
|
+
return e.selection;
|
|
1735
|
+
}
|
|
1736
|
+
}), new H("storedMarks", {
|
|
1737
|
+
init(e) {
|
|
1738
|
+
return e.storedMarks || null;
|
|
1739
|
+
},
|
|
1740
|
+
apply(e, t, n, r) {
|
|
1741
|
+
return r.selection.$cursor ? e.storedMarks : null;
|
|
1742
|
+
}
|
|
1743
|
+
}), new H("scrollToSelection", {
|
|
1744
|
+
init() {
|
|
1745
|
+
return 0;
|
|
1746
|
+
},
|
|
1747
|
+
apply(e, t) {
|
|
1748
|
+
return e.scrolledIntoView ? t + 1 : t;
|
|
1749
|
+
}
|
|
1750
|
+
});
|
|
1751
|
+
var wt = (e, t) => {
|
|
1752
|
+
let { state: n, view: r } = e, { selection: i } = n;
|
|
1753
|
+
if (!i.empty) return !1;
|
|
1754
|
+
let { $from: a } = i;
|
|
1755
|
+
if (a.parentOffset !== 0) return !1;
|
|
1756
|
+
let o = a.depth - 1, s = a.node(o), c = a.index(o);
|
|
1757
|
+
if (c === 0) return !1;
|
|
1758
|
+
if (s.type === t) return e.commands.lift(t.name);
|
|
1759
|
+
let l = s.child(c - 1);
|
|
1760
|
+
if (l.type !== t || !l.lastChild?.isTextblock) return !1;
|
|
1761
|
+
let u = a.before(), d = u - 1 - 1, { tr: f } = n;
|
|
1762
|
+
return f.delete(u, a.after()).insert(d, a.parent.content), f.setSelection(R.create(f.doc, d)), r.dispatch(f.scrollIntoView()), !0;
|
|
1763
|
+
}, Tt = /^\s*>\s$/, Et = v.create({
|
|
1764
|
+
name: "blockquote",
|
|
1765
|
+
addOptions() {
|
|
1766
|
+
return { HTMLAttributes: {} };
|
|
1767
|
+
},
|
|
1768
|
+
content: "block+",
|
|
1769
|
+
group: "block",
|
|
1770
|
+
defining: !0,
|
|
1771
|
+
parseHTML() {
|
|
1772
|
+
return [{ tag: "blockquote" }];
|
|
1773
|
+
},
|
|
1774
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
1775
|
+
return /* @__PURE__ */ C("blockquote", {
|
|
1776
|
+
..._(this.options.HTMLAttributes, e),
|
|
1777
|
+
children: /* @__PURE__ */ C("slot", {})
|
|
1778
|
+
});
|
|
1779
|
+
},
|
|
1780
|
+
parseMarkdown: (e, t) => {
|
|
1781
|
+
let n = t.parseBlockChildren ?? t.parseChildren;
|
|
1782
|
+
return t.createNode("blockquote", void 0, n(e.tokens || []));
|
|
1783
|
+
},
|
|
1784
|
+
renderMarkdown: (e, t) => {
|
|
1785
|
+
if (!e.content) return "";
|
|
1786
|
+
let n = [];
|
|
1787
|
+
return e.content.forEach((e, r) => {
|
|
1788
|
+
let i = (t.renderChild?.call(t, e, r) ?? t.renderChildren([e])).split("\n").map((e) => e.trim() === "" ? ">" : `> ${e}`);
|
|
1789
|
+
n.push(i.join("\n"));
|
|
1790
|
+
}), n.join("\n>\n");
|
|
1791
|
+
},
|
|
1792
|
+
addCommands() {
|
|
1793
|
+
return {
|
|
1794
|
+
setBlockquote: () => ({ commands: e }) => e.wrapIn(this.name),
|
|
1795
|
+
toggleBlockquote: () => ({ commands: e }) => e.toggleWrap(this.name),
|
|
1796
|
+
unsetBlockquote: () => ({ commands: e }) => e.lift(this.name)
|
|
1797
|
+
};
|
|
1798
|
+
},
|
|
1799
|
+
addKeyboardShortcuts() {
|
|
1800
|
+
return {
|
|
1801
|
+
"Mod-Shift-b": () => this.editor.commands.toggleBlockquote(),
|
|
1802
|
+
Backspace: () => wt(this.editor, this.type)
|
|
1803
|
+
};
|
|
1804
|
+
},
|
|
1805
|
+
addInputRules() {
|
|
1806
|
+
return [h({
|
|
1807
|
+
find: Tt,
|
|
1808
|
+
type: this.type
|
|
1809
|
+
})];
|
|
1810
|
+
}
|
|
1811
|
+
}), Dt = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/, Ot = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g, kt = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/, At = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g, jt = m.create({
|
|
1812
|
+
name: "bold",
|
|
1813
|
+
addOptions() {
|
|
1814
|
+
return { HTMLAttributes: {} };
|
|
1815
|
+
},
|
|
1816
|
+
parseHTML() {
|
|
1817
|
+
return [
|
|
1818
|
+
{ tag: "strong" },
|
|
1819
|
+
{
|
|
1820
|
+
tag: "b",
|
|
1821
|
+
getAttrs: (e) => e.style.fontWeight !== "normal" && null
|
|
1822
|
+
},
|
|
1823
|
+
{
|
|
1824
|
+
style: "font-weight=400",
|
|
1825
|
+
clearMark: (e) => e.type.name === this.name
|
|
1826
|
+
},
|
|
1827
|
+
{
|
|
1828
|
+
style: "font-weight",
|
|
1829
|
+
getAttrs: (e) => /^(bold(er)?|[5-9]\d{2,})$/.test(e) && null
|
|
1830
|
+
}
|
|
1831
|
+
];
|
|
1832
|
+
},
|
|
1833
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
1834
|
+
return /* @__PURE__ */ C("strong", {
|
|
1835
|
+
..._(this.options.HTMLAttributes, e),
|
|
1836
|
+
children: /* @__PURE__ */ C("slot", {})
|
|
1837
|
+
});
|
|
1838
|
+
},
|
|
1839
|
+
markdownTokenName: "strong",
|
|
1840
|
+
parseMarkdown: (e, t) => t.applyMark("bold", t.parseInline(e.tokens || [])),
|
|
1841
|
+
markdownOptions: { htmlReopen: {
|
|
1842
|
+
open: "<strong>",
|
|
1843
|
+
close: "</strong>"
|
|
1844
|
+
} },
|
|
1845
|
+
renderMarkdown: (e, t) => `**${t.renderChildren(e)}**`,
|
|
1846
|
+
addCommands() {
|
|
1847
|
+
return {
|
|
1848
|
+
setBold: () => ({ commands: e }) => e.setMark(this.name),
|
|
1849
|
+
toggleBold: () => ({ commands: e }) => e.toggleMark(this.name),
|
|
1850
|
+
unsetBold: () => ({ commands: e }) => e.unsetMark(this.name)
|
|
1851
|
+
};
|
|
1852
|
+
},
|
|
1853
|
+
addKeyboardShortcuts() {
|
|
1854
|
+
return {
|
|
1855
|
+
"Mod-b": () => this.editor.commands.toggleBold(),
|
|
1856
|
+
"Mod-B": () => this.editor.commands.toggleBold()
|
|
1857
|
+
};
|
|
1858
|
+
},
|
|
1859
|
+
addInputRules() {
|
|
1860
|
+
return [u({
|
|
1861
|
+
find: Dt,
|
|
1862
|
+
type: this.type
|
|
1863
|
+
}), u({
|
|
1864
|
+
find: kt,
|
|
1865
|
+
type: this.type
|
|
1866
|
+
})];
|
|
1867
|
+
},
|
|
1868
|
+
addPasteRules() {
|
|
1869
|
+
return [d({
|
|
1870
|
+
find: Ot,
|
|
1871
|
+
type: this.type
|
|
1872
|
+
}), d({
|
|
1873
|
+
find: At,
|
|
1874
|
+
type: this.type
|
|
1875
|
+
})];
|
|
1876
|
+
}
|
|
1877
|
+
}), Mt = (e) => {
|
|
1878
|
+
let t = /`([^`]+)`(?!`)$/.exec(e);
|
|
1879
|
+
return !t || t.index > 0 && e[t.index - 1] === "`" ? null : {
|
|
1880
|
+
index: t.index,
|
|
1881
|
+
text: t[0],
|
|
1882
|
+
replaceWith: t[1]
|
|
1883
|
+
};
|
|
1884
|
+
}, Nt = (e) => {
|
|
1885
|
+
let t = /`([^`]+)`(?!`)/g, n = [], r;
|
|
1886
|
+
for (; (r = t.exec(e)) !== null;) r.index > 0 && e[r.index - 1] === "`" || n.push({
|
|
1887
|
+
index: r.index,
|
|
1888
|
+
text: r[0],
|
|
1889
|
+
replaceWith: r[1]
|
|
1890
|
+
});
|
|
1891
|
+
return n;
|
|
1892
|
+
}, Pt = m.create({
|
|
1893
|
+
name: "code",
|
|
1894
|
+
addOptions() {
|
|
1895
|
+
return { HTMLAttributes: {} };
|
|
1896
|
+
},
|
|
1897
|
+
excludes: "_",
|
|
1898
|
+
code: !0,
|
|
1899
|
+
exitable: !0,
|
|
1900
|
+
parseHTML() {
|
|
1901
|
+
return [{ tag: "code" }];
|
|
1902
|
+
},
|
|
1903
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
1904
|
+
return [
|
|
1905
|
+
"code",
|
|
1906
|
+
_(this.options.HTMLAttributes, e),
|
|
1907
|
+
0
|
|
1908
|
+
];
|
|
1909
|
+
},
|
|
1910
|
+
markdownTokenName: "codespan",
|
|
1911
|
+
parseMarkdown: (e, t) => t.applyMark("code", [{
|
|
1912
|
+
type: "text",
|
|
1913
|
+
text: e.text || ""
|
|
1914
|
+
}]),
|
|
1915
|
+
renderMarkdown: (e, t) => e.content ? `\`${t.renderChildren(e.content)}\`` : "",
|
|
1916
|
+
addCommands() {
|
|
1917
|
+
return {
|
|
1918
|
+
setCode: () => ({ commands: e }) => e.setMark(this.name),
|
|
1919
|
+
toggleCode: () => ({ commands: e }) => e.toggleMark(this.name),
|
|
1920
|
+
unsetCode: () => ({ commands: e }) => e.unsetMark(this.name)
|
|
1921
|
+
};
|
|
1922
|
+
},
|
|
1923
|
+
addKeyboardShortcuts() {
|
|
1924
|
+
return { "Mod-e": () => this.editor.commands.toggleCode() };
|
|
1925
|
+
},
|
|
1926
|
+
addInputRules() {
|
|
1927
|
+
return [u({
|
|
1928
|
+
find: Mt,
|
|
1929
|
+
type: this.type
|
|
1930
|
+
})];
|
|
1931
|
+
},
|
|
1932
|
+
addPasteRules() {
|
|
1933
|
+
return [d({
|
|
1934
|
+
find: Nt,
|
|
1935
|
+
type: this.type
|
|
1936
|
+
})];
|
|
1937
|
+
}
|
|
1938
|
+
}), Ft = 4, It = /^```([a-z]+)?[\s\n]$/, Lt = /^~~~([a-z]+)?[\s\n]$/, Rt = v.create({
|
|
1939
|
+
name: "codeBlock",
|
|
1940
|
+
addOptions() {
|
|
1941
|
+
return {
|
|
1942
|
+
languageClassPrefix: "language-",
|
|
1943
|
+
exitOnTripleEnter: !0,
|
|
1944
|
+
exitOnArrowDown: !0,
|
|
1945
|
+
defaultLanguage: null,
|
|
1946
|
+
enableTabIndentation: !1,
|
|
1947
|
+
tabSize: Ft,
|
|
1948
|
+
HTMLAttributes: {}
|
|
1949
|
+
};
|
|
1950
|
+
},
|
|
1951
|
+
content: "text*",
|
|
1952
|
+
marks: "",
|
|
1953
|
+
group: "block",
|
|
1954
|
+
code: !0,
|
|
1955
|
+
defining: !0,
|
|
1956
|
+
addAttributes() {
|
|
1957
|
+
return { language: {
|
|
1958
|
+
default: this.options.defaultLanguage,
|
|
1959
|
+
parseHTML: (e) => {
|
|
1960
|
+
let { languageClassPrefix: t } = this.options;
|
|
1961
|
+
return t && [...e.firstElementChild?.classList || []].filter((e) => e.startsWith(t)).map((e) => e.replace(t, ""))[0] || null;
|
|
1962
|
+
},
|
|
1963
|
+
rendered: !1
|
|
1964
|
+
} };
|
|
1965
|
+
},
|
|
1966
|
+
parseHTML() {
|
|
1967
|
+
return [{
|
|
1968
|
+
tag: "pre",
|
|
1969
|
+
preserveWhitespace: "full"
|
|
1970
|
+
}];
|
|
1971
|
+
},
|
|
1972
|
+
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
1973
|
+
return [
|
|
1974
|
+
"pre",
|
|
1975
|
+
_(this.options.HTMLAttributes, t),
|
|
1976
|
+
[
|
|
1977
|
+
"code",
|
|
1978
|
+
{ class: e.attrs.language ? this.options.languageClassPrefix + e.attrs.language : null },
|
|
1979
|
+
0
|
|
1980
|
+
]
|
|
1981
|
+
];
|
|
1982
|
+
},
|
|
1983
|
+
markdownTokenName: "code",
|
|
1984
|
+
parseMarkdown: (e, t) => e.raw?.startsWith("```") === !1 && e.raw?.startsWith("~~~") === !1 && e.codeBlockStyle !== "indented" ? [] : t.createNode("codeBlock", { language: e.lang || null }, e.text ? [t.createTextNode(e.text)] : []),
|
|
1985
|
+
renderMarkdown: (e, t) => {
|
|
1986
|
+
let n = "", r = e.attrs?.language || "";
|
|
1987
|
+
return n = e.content ? [
|
|
1988
|
+
`\`\`\`${r}`,
|
|
1989
|
+
t.renderChildren(e.content),
|
|
1990
|
+
"```"
|
|
1991
|
+
].join("\n") : `\`\`\`${r}
|
|
1992
|
+
|
|
1993
|
+
\`\`\``, n;
|
|
1994
|
+
},
|
|
1995
|
+
addCommands() {
|
|
1996
|
+
return {
|
|
1997
|
+
setCodeBlock: (e) => ({ commands: t }) => t.setNode(this.name, e),
|
|
1998
|
+
toggleCodeBlock: (e) => ({ commands: t }) => t.toggleNode(this.name, "paragraph", e)
|
|
1999
|
+
};
|
|
2000
|
+
},
|
|
2001
|
+
addKeyboardShortcuts() {
|
|
2002
|
+
return {
|
|
2003
|
+
"Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(),
|
|
2004
|
+
Backspace: () => {
|
|
2005
|
+
let { empty: e, $anchor: t } = this.editor.state.selection, n = t.pos === 1;
|
|
2006
|
+
return !e || t.parent.type.name !== this.name ? !1 : n || !t.parent.textContent.length ? this.editor.commands.clearNodes() : !1;
|
|
2007
|
+
},
|
|
2008
|
+
Tab: ({ editor: e }) => {
|
|
2009
|
+
if (!this.options.enableTabIndentation) return !1;
|
|
2010
|
+
let t = this.options.tabSize ?? Ft, { state: n } = e, { selection: r } = n, { $from: i, empty: a } = r;
|
|
2011
|
+
if (i.parent.type !== this.type) return !1;
|
|
2012
|
+
let o = " ".repeat(t);
|
|
2013
|
+
return a ? e.commands.insertContent(o) : e.commands.command(({ tr: e }) => {
|
|
2014
|
+
let { from: t, to: i } = r, a = n.doc.textBetween(t, i, "\n", "\n").split("\n").map((e) => o + e).join("\n");
|
|
2015
|
+
return e.replaceWith(t, i, n.schema.text(a)), !0;
|
|
2016
|
+
});
|
|
2017
|
+
},
|
|
2018
|
+
"Shift-Tab": ({ editor: e }) => {
|
|
2019
|
+
if (!this.options.enableTabIndentation) return !1;
|
|
2020
|
+
let t = this.options.tabSize ?? Ft, { state: n } = e, { selection: r } = n, { $from: i, empty: a } = r;
|
|
2021
|
+
return i.parent.type === this.type ? a ? e.commands.command(({ tr: e }) => {
|
|
2022
|
+
let { pos: r } = i, a = i.start(), o = i.end(), s = n.doc.textBetween(a, o, "\n", "\n").split("\n"), c = 0, l = 0, u = r - a;
|
|
2023
|
+
for (let e = 0; e < s.length; e += 1) {
|
|
2024
|
+
if (l + s[e].length >= u) {
|
|
2025
|
+
c = e;
|
|
2026
|
+
break;
|
|
2027
|
+
}
|
|
2028
|
+
l += s[e].length + 1;
|
|
2029
|
+
}
|
|
2030
|
+
let d = s[c].match(/^ */)?.[0] || "", f = Math.min(d.length, t);
|
|
2031
|
+
if (f === 0) return !0;
|
|
2032
|
+
let p = a;
|
|
2033
|
+
for (let e = 0; e < c; e += 1) p += s[e].length + 1;
|
|
2034
|
+
return e.delete(p, p + f), r - p <= f && e.setSelection(b.create(e.doc, p)), !0;
|
|
2035
|
+
}) : e.commands.command(({ tr: e }) => {
|
|
2036
|
+
let { from: i, to: a } = r, o = n.doc.textBetween(i, a, "\n", "\n").split("\n").map((e) => {
|
|
2037
|
+
let n = e.match(/^ */)?.[0] || "", r = Math.min(n.length, t);
|
|
2038
|
+
return e.slice(r);
|
|
2039
|
+
}).join("\n");
|
|
2040
|
+
return e.replaceWith(i, a, n.schema.text(o)), !0;
|
|
2041
|
+
}) : !1;
|
|
2042
|
+
},
|
|
2043
|
+
Enter: ({ editor: e }) => {
|
|
2044
|
+
if (!this.options.exitOnTripleEnter) return !1;
|
|
2045
|
+
let { state: t } = e, { selection: n } = t, { $from: r, empty: i } = n;
|
|
2046
|
+
if (!i || r.parent.type !== this.type) return !1;
|
|
2047
|
+
let a = r.parentOffset === r.parent.nodeSize - 2, o = r.parent.textContent.endsWith("\n\n");
|
|
2048
|
+
return !a || !o ? !1 : e.chain().command(({ tr: e }) => (e.delete(r.pos - 2, r.pos), !0)).exitCode().run();
|
|
2049
|
+
},
|
|
2050
|
+
ArrowDown: ({ editor: t }) => {
|
|
2051
|
+
if (!this.options.exitOnArrowDown) return !1;
|
|
2052
|
+
let { state: n } = t, { selection: r, doc: i } = n, { $from: a, empty: o } = r;
|
|
2053
|
+
if (!o || a.parent.type !== this.type || a.parentOffset !== a.parent.nodeSize - 2) return !1;
|
|
2054
|
+
let s = a.after();
|
|
2055
|
+
return s === void 0 ? !1 : i.nodeAt(s) ? t.commands.command(({ tr: t }) => (t.setSelection(e.near(i.resolve(s))), !0)) : t.commands.exitCode();
|
|
2056
|
+
}
|
|
2057
|
+
};
|
|
2058
|
+
},
|
|
2059
|
+
addInputRules() {
|
|
2060
|
+
return [oe({
|
|
2061
|
+
find: It,
|
|
2062
|
+
type: this.type,
|
|
2063
|
+
getAttributes: (e) => ({ language: e[1] })
|
|
2064
|
+
}), oe({
|
|
2065
|
+
find: Lt,
|
|
2066
|
+
type: this.type,
|
|
2067
|
+
getAttributes: (e) => ({ language: e[1] })
|
|
2068
|
+
})];
|
|
2069
|
+
},
|
|
2070
|
+
addProseMirrorPlugins() {
|
|
2071
|
+
return [new x({
|
|
2072
|
+
key: new c("codeBlockVSCodeHandler"),
|
|
2073
|
+
props: { handlePaste: (e, t) => {
|
|
2074
|
+
if (!t.clipboardData || this.editor.isActive(this.type.name)) return !1;
|
|
2075
|
+
let n = t.clipboardData.getData("text/plain"), r = t.clipboardData.getData("vscode-editor-data"), i = (r ? JSON.parse(r) : void 0)?.mode;
|
|
2076
|
+
if (!n || !i) return !1;
|
|
2077
|
+
let { tr: a, schema: o } = e.state, s = o.text(n.replace(/\r\n?/g, "\n"));
|
|
2078
|
+
return a.replaceSelectionWith(this.type.create({ language: i }, s)), a.selection.$from.parent.type !== this.type && a.setSelection(b.near(a.doc.resolve(Math.max(0, a.selection.from - 2)))), a.setMeta("paste", !0), e.dispatch(a), !0;
|
|
2079
|
+
} }
|
|
2080
|
+
})];
|
|
2081
|
+
}
|
|
2082
|
+
}), zt = v.create({
|
|
2083
|
+
name: "doc",
|
|
2084
|
+
topNode: !0,
|
|
2085
|
+
content: "block+",
|
|
2086
|
+
renderMarkdown: (e, t) => e.content ? t.renderChildren(e.content, "\n\n") : ""
|
|
2087
|
+
}), Bt = v.create({
|
|
2088
|
+
name: "hardBreak",
|
|
2089
|
+
markdownTokenName: "br",
|
|
2090
|
+
addOptions() {
|
|
2091
|
+
return {
|
|
2092
|
+
keepMarks: !0,
|
|
2093
|
+
HTMLAttributes: {}
|
|
2094
|
+
};
|
|
2095
|
+
},
|
|
2096
|
+
inline: !0,
|
|
2097
|
+
group: "inline",
|
|
2098
|
+
selectable: !1,
|
|
2099
|
+
linebreakReplacement: !0,
|
|
2100
|
+
parseHTML() {
|
|
2101
|
+
return [{ tag: "br" }];
|
|
2102
|
+
},
|
|
2103
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
2104
|
+
return ["br", _(this.options.HTMLAttributes, e)];
|
|
2105
|
+
},
|
|
2106
|
+
renderText() {
|
|
2107
|
+
return "\n";
|
|
2108
|
+
},
|
|
2109
|
+
renderMarkdown: () => " \n",
|
|
2110
|
+
parseMarkdown: () => ({ type: "hardBreak" }),
|
|
2111
|
+
addCommands() {
|
|
2112
|
+
return { setHardBreak: () => ({ commands: e, chain: t, state: n, editor: r }) => e.first([() => e.exitCode(), () => e.command(() => {
|
|
2113
|
+
let { selection: e, storedMarks: i } = n;
|
|
2114
|
+
if (e.$from.parent.type.spec.isolating) return !1;
|
|
2115
|
+
let { keepMarks: a } = this.options, { splittableMarks: o } = r.extensionManager, s = i || e.$to.parentOffset && e.$from.marks();
|
|
2116
|
+
return t().insertContent({ type: this.name }).command(({ tr: e, dispatch: t }) => {
|
|
2117
|
+
if (t && s && a) {
|
|
2118
|
+
let t = s.filter((e) => o.includes(e.type.name));
|
|
2119
|
+
e.ensureMarks(t);
|
|
2120
|
+
}
|
|
2121
|
+
return !0;
|
|
2122
|
+
}).run();
|
|
2123
|
+
})]) };
|
|
2124
|
+
},
|
|
2125
|
+
addKeyboardShortcuts() {
|
|
2126
|
+
return {
|
|
2127
|
+
"Mod-Enter": () => this.editor.commands.setHardBreak(),
|
|
2128
|
+
"Shift-Enter": () => this.editor.commands.setHardBreak()
|
|
2129
|
+
};
|
|
2130
|
+
}
|
|
2131
|
+
}), Vt = v.create({
|
|
2132
|
+
name: "heading",
|
|
2133
|
+
addOptions() {
|
|
2134
|
+
return {
|
|
2135
|
+
levels: [
|
|
2136
|
+
1,
|
|
2137
|
+
2,
|
|
2138
|
+
3,
|
|
2139
|
+
4,
|
|
2140
|
+
5,
|
|
2141
|
+
6
|
|
2142
|
+
],
|
|
2143
|
+
HTMLAttributes: {}
|
|
2144
|
+
};
|
|
2145
|
+
},
|
|
2146
|
+
content: "inline*",
|
|
2147
|
+
group: "block",
|
|
2148
|
+
defining: !0,
|
|
2149
|
+
addAttributes() {
|
|
2150
|
+
return { level: {
|
|
2151
|
+
default: 1,
|
|
2152
|
+
rendered: !1
|
|
2153
|
+
} };
|
|
2154
|
+
},
|
|
2155
|
+
parseHTML() {
|
|
2156
|
+
return this.options.levels.map((e) => ({
|
|
2157
|
+
tag: `h${e}`,
|
|
2158
|
+
attrs: { level: e }
|
|
2159
|
+
}));
|
|
2160
|
+
},
|
|
2161
|
+
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
2162
|
+
return [
|
|
2163
|
+
`h${this.options.levels.includes(e.attrs.level) ? e.attrs.level : this.options.levels[0]}`,
|
|
2164
|
+
_(this.options.HTMLAttributes, t),
|
|
2165
|
+
0
|
|
2166
|
+
];
|
|
2167
|
+
},
|
|
2168
|
+
parseMarkdown: (e, t) => t.createNode("heading", { level: e.depth || 1 }, t.parseInline(e.tokens || [])),
|
|
2169
|
+
renderMarkdown: (e, t) => {
|
|
2170
|
+
let n = e.attrs?.level ? parseInt(e.attrs.level, 10) : 1, r = "#".repeat(n);
|
|
2171
|
+
return e.content ? `${r} ${t.renderChildren(e.content)}` : "";
|
|
2172
|
+
},
|
|
2173
|
+
addCommands() {
|
|
2174
|
+
return {
|
|
2175
|
+
setHeading: (e) => ({ commands: t }) => this.options.levels.includes(e.level) ? t.setNode(this.name, e) : !1,
|
|
2176
|
+
toggleHeading: (e) => ({ commands: t }) => this.options.levels.includes(e.level) ? t.toggleNode(this.name, "paragraph", e) : !1
|
|
2177
|
+
};
|
|
2178
|
+
},
|
|
2179
|
+
addKeyboardShortcuts() {
|
|
2180
|
+
return this.options.levels.reduce((e, t) => ({
|
|
2181
|
+
...e,
|
|
2182
|
+
[`Mod-Alt-${t}`]: () => this.editor.commands.toggleHeading({ level: t })
|
|
2183
|
+
}), {});
|
|
2184
|
+
},
|
|
2185
|
+
addInputRules() {
|
|
2186
|
+
return this.options.levels.map((e) => oe({
|
|
2187
|
+
find: RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),
|
|
2188
|
+
type: this.type,
|
|
2189
|
+
getAttributes: { level: e }
|
|
2190
|
+
}));
|
|
2191
|
+
}
|
|
2192
|
+
}), Ht = v.create({
|
|
2193
|
+
name: "horizontalRule",
|
|
2194
|
+
addOptions() {
|
|
2195
|
+
return {
|
|
2196
|
+
HTMLAttributes: {},
|
|
2197
|
+
nextNodeType: "paragraph"
|
|
2198
|
+
};
|
|
2199
|
+
},
|
|
2200
|
+
group: "block",
|
|
2201
|
+
parseHTML() {
|
|
2202
|
+
return [{ tag: "hr" }];
|
|
2203
|
+
},
|
|
2204
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
2205
|
+
return ["hr", _(this.options.HTMLAttributes, e)];
|
|
2206
|
+
},
|
|
2207
|
+
markdownTokenName: "hr",
|
|
2208
|
+
parseMarkdown: (e, t) => t.createNode("horizontalRule"),
|
|
2209
|
+
renderMarkdown: () => "---",
|
|
2210
|
+
addCommands() {
|
|
2211
|
+
return { setHorizontalRule: () => ({ chain: e, state: t }) => {
|
|
2212
|
+
if (!de(t, t.schema.nodes[this.name])) return !1;
|
|
2213
|
+
let { selection: n } = t, { $to: r } = n, i = e();
|
|
2214
|
+
return s(n) ? i.insertContentAt(r.pos, { type: this.name }) : i.insertContent({ type: this.name }), i.command(({ state: e, tr: t, dispatch: n }) => {
|
|
2215
|
+
if (n) {
|
|
2216
|
+
let { $to: n } = t.selection, r = n.end();
|
|
2217
|
+
if (n.nodeAfter) n.nodeAfter.isTextblock ? t.setSelection(b.create(t.doc, n.pos + 1)) : n.nodeAfter.isBlock ? t.setSelection(ne.create(t.doc, n.pos)) : t.setSelection(b.create(t.doc, n.pos));
|
|
2218
|
+
else {
|
|
2219
|
+
let i = (e.schema.nodes[this.options.nextNodeType] || n.parent.type.contentMatch.defaultType)?.create();
|
|
2220
|
+
i && (t.insert(r, i), t.setSelection(b.create(t.doc, r + 1)));
|
|
2221
|
+
}
|
|
2222
|
+
t.scrollIntoView();
|
|
2223
|
+
}
|
|
2224
|
+
return !0;
|
|
2225
|
+
}).run();
|
|
2226
|
+
} };
|
|
2227
|
+
},
|
|
2228
|
+
addInputRules() {
|
|
2229
|
+
return [f({
|
|
2230
|
+
find: /^(?:---|—-|___\s|\*\*\*\s)$/,
|
|
2231
|
+
type: this.type
|
|
2232
|
+
})];
|
|
2233
|
+
}
|
|
2234
|
+
}), Ut = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, Wt = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, Gt = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, Kt = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, qt = m.create({
|
|
2235
|
+
name: "italic",
|
|
2236
|
+
addOptions() {
|
|
2237
|
+
return { HTMLAttributes: {} };
|
|
2238
|
+
},
|
|
2239
|
+
parseHTML() {
|
|
2240
|
+
return [
|
|
2241
|
+
{ tag: "em" },
|
|
2242
|
+
{
|
|
2243
|
+
tag: "i",
|
|
2244
|
+
getAttrs: (e) => e.style.fontStyle !== "normal" && null
|
|
2245
|
+
},
|
|
2246
|
+
{
|
|
2247
|
+
style: "font-style=normal",
|
|
2248
|
+
clearMark: (e) => e.type.name === this.name
|
|
2249
|
+
},
|
|
2250
|
+
{ style: "font-style=italic" }
|
|
2251
|
+
];
|
|
2252
|
+
},
|
|
2253
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
2254
|
+
return [
|
|
2255
|
+
"em",
|
|
2256
|
+
_(this.options.HTMLAttributes, e),
|
|
2257
|
+
0
|
|
2258
|
+
];
|
|
2259
|
+
},
|
|
2260
|
+
addCommands() {
|
|
2261
|
+
return {
|
|
2262
|
+
setItalic: () => ({ commands: e }) => e.setMark(this.name),
|
|
2263
|
+
toggleItalic: () => ({ commands: e }) => e.toggleMark(this.name),
|
|
2264
|
+
unsetItalic: () => ({ commands: e }) => e.unsetMark(this.name)
|
|
2265
|
+
};
|
|
2266
|
+
},
|
|
2267
|
+
markdownTokenName: "em",
|
|
2268
|
+
parseMarkdown: (e, t) => t.applyMark("italic", t.parseInline(e.tokens || [])),
|
|
2269
|
+
markdownOptions: { htmlReopen: {
|
|
2270
|
+
open: "<em>",
|
|
2271
|
+
close: "</em>"
|
|
2272
|
+
} },
|
|
2273
|
+
renderMarkdown: (e, t) => `*${t.renderChildren(e)}*`,
|
|
2274
|
+
addKeyboardShortcuts() {
|
|
2275
|
+
return {
|
|
2276
|
+
"Mod-i": () => this.editor.commands.toggleItalic(),
|
|
2277
|
+
"Mod-I": () => this.editor.commands.toggleItalic()
|
|
2278
|
+
};
|
|
2279
|
+
},
|
|
2280
|
+
addInputRules() {
|
|
2281
|
+
return [u({
|
|
2282
|
+
find: Ut,
|
|
2283
|
+
type: this.type
|
|
2284
|
+
}), u({
|
|
2285
|
+
find: Gt,
|
|
2286
|
+
type: this.type
|
|
2287
|
+
})];
|
|
2288
|
+
},
|
|
2289
|
+
addPasteRules() {
|
|
2290
|
+
return [d({
|
|
2291
|
+
find: Wt,
|
|
2292
|
+
type: this.type
|
|
2293
|
+
}), d({
|
|
2294
|
+
find: Kt,
|
|
2295
|
+
type: this.type
|
|
2296
|
+
})];
|
|
2297
|
+
}
|
|
2298
|
+
}), Jt = Object.defineProperty, Yt = (e, t) => {
|
|
2299
|
+
for (var n in t) Jt(e, n, {
|
|
2300
|
+
get: t[n],
|
|
2301
|
+
enumerable: !0
|
|
2302
|
+
});
|
|
2303
|
+
}, Xt = "listItem", Zt = "textStyle", Qt = /^\s*([-+*])\s$/, $t = v.create({
|
|
2304
|
+
name: "bulletList",
|
|
2305
|
+
addOptions() {
|
|
2306
|
+
return {
|
|
2307
|
+
itemTypeName: "listItem",
|
|
2308
|
+
HTMLAttributes: {},
|
|
2309
|
+
keepMarks: !1,
|
|
2310
|
+
keepAttributes: !1
|
|
2311
|
+
};
|
|
2312
|
+
},
|
|
2313
|
+
group: "block list",
|
|
2314
|
+
content() {
|
|
2315
|
+
return `${this.options.itemTypeName}+`;
|
|
2316
|
+
},
|
|
2317
|
+
parseHTML() {
|
|
2318
|
+
return [{ tag: "ul" }];
|
|
2319
|
+
},
|
|
2320
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
2321
|
+
return [
|
|
2322
|
+
"ul",
|
|
2323
|
+
_(this.options.HTMLAttributes, e),
|
|
2324
|
+
0
|
|
2325
|
+
];
|
|
2326
|
+
},
|
|
2327
|
+
markdownTokenName: "list",
|
|
2328
|
+
parseMarkdown: (e, t) => e.type !== "list" || e.ordered ? [] : {
|
|
2329
|
+
type: "bulletList",
|
|
2330
|
+
content: e.items ? t.parseChildren(e.items) : []
|
|
2331
|
+
},
|
|
2332
|
+
renderMarkdown: (e, t) => e.content ? t.renderChildren(e.content, "\n") : "",
|
|
2333
|
+
markdownOptions: { indentsContent: !0 },
|
|
2334
|
+
addCommands() {
|
|
2335
|
+
return { toggleBulletList: () => ({ commands: e, chain: t }) => this.options.keepAttributes ? t().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(Xt, this.editor.getAttributes(Zt)).run() : e.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks) };
|
|
2336
|
+
},
|
|
2337
|
+
addKeyboardShortcuts() {
|
|
2338
|
+
return { "Mod-Shift-8": () => this.editor.commands.toggleBulletList() };
|
|
2339
|
+
},
|
|
2340
|
+
addInputRules() {
|
|
2341
|
+
let e = h({
|
|
2342
|
+
find: Qt,
|
|
2343
|
+
type: this.type
|
|
2344
|
+
});
|
|
2345
|
+
return (this.options.keepMarks || this.options.keepAttributes) && (e = h({
|
|
2346
|
+
find: Qt,
|
|
2347
|
+
type: this.type,
|
|
2348
|
+
keepMarks: this.options.keepMarks,
|
|
2349
|
+
keepAttributes: this.options.keepAttributes,
|
|
2350
|
+
getAttributes: () => this.editor.getAttributes(Zt),
|
|
2351
|
+
editor: this.editor
|
|
2352
|
+
})), [e];
|
|
2353
|
+
}
|
|
2354
|
+
}), en = (e, t, n) => {
|
|
2355
|
+
let { selection: r } = e;
|
|
2356
|
+
if (!r.empty) return null;
|
|
2357
|
+
let { $from: i } = r;
|
|
2358
|
+
if (!i.parent.isTextblock || i.parentOffset !== i.parent.content.size) return null;
|
|
2359
|
+
let a = -1;
|
|
2360
|
+
for (let e = i.depth; e > 0; --e) if (i.node(e).type.name === t) {
|
|
2361
|
+
a = e;
|
|
2362
|
+
break;
|
|
2363
|
+
}
|
|
2364
|
+
if (a < 0) return null;
|
|
2365
|
+
let o = i.node(a), s = i.index(a);
|
|
2366
|
+
if (s + 1 >= o.childCount) return null;
|
|
2367
|
+
let c = o.child(s + 1);
|
|
2368
|
+
if (!n.includes(c.type.name)) return null;
|
|
2369
|
+
let l = e.schema.nodes[t], u = !1;
|
|
2370
|
+
if (c.forEach((e) => {
|
|
2371
|
+
e.type === l && e.childCount > 1 && (u = !0);
|
|
2372
|
+
}), !u) return null;
|
|
2373
|
+
let d = e.doc.resolve(i.after()).nodeAfter;
|
|
2374
|
+
if (!d || !n.includes(d.type.name)) return null;
|
|
2375
|
+
let f = [];
|
|
2376
|
+
return d.forEach((e) => {
|
|
2377
|
+
f.push(e);
|
|
2378
|
+
}), f.length === 0 ? null : {
|
|
2379
|
+
listItemDepth: a,
|
|
2380
|
+
nestedList: d,
|
|
2381
|
+
nestedListPos: i.after(),
|
|
2382
|
+
insertPos: i.after(a),
|
|
2383
|
+
items: f
|
|
2384
|
+
};
|
|
2385
|
+
}, tn = (e, t, r, i) => {
|
|
2386
|
+
let a = en(e, r, i);
|
|
2387
|
+
if (!a) return !1;
|
|
2388
|
+
let { selection: o } = e, { nestedList: s, nestedListPos: c, insertPos: l, items: u } = a, d = e.tr;
|
|
2389
|
+
d.delete(c, c + s.nodeSize);
|
|
2390
|
+
let f = d.mapping.map(l);
|
|
2391
|
+
return d.insert(f, n.from(u)), d.setSelection(o.map(d.doc, d.mapping)), t && t(d), !0;
|
|
2392
|
+
}, nn = (e, t, n) => tn(e.state, e.view.dispatch, t, n), rn = (e, t) => g.create({
|
|
2393
|
+
name: `${e}BranchingDeleteKeymap`,
|
|
2394
|
+
priority: 101,
|
|
2395
|
+
addKeyboardShortcuts() {
|
|
2396
|
+
let n = () => nn(this.editor, e, t);
|
|
2397
|
+
return {
|
|
2398
|
+
Delete: n,
|
|
2399
|
+
"Mod-Delete": n
|
|
2400
|
+
};
|
|
2401
|
+
}
|
|
2402
|
+
});
|
|
2403
|
+
function an(e) {
|
|
2404
|
+
let t = e.tokens?.[0];
|
|
2405
|
+
return !!(e.text && e.tokens?.length === 1 && t?.type === "list" && t.ordered && t.raw === e.text);
|
|
2406
|
+
}
|
|
2407
|
+
function on(e, t) {
|
|
2408
|
+
return t.tokenizeInline ? t.parseInline(t.tokenizeInline(e)) : t.parseInline([{
|
|
2409
|
+
type: "text",
|
|
2410
|
+
raw: e,
|
|
2411
|
+
text: e
|
|
2412
|
+
}]);
|
|
2413
|
+
}
|
|
2414
|
+
var sn = v.create({
|
|
2415
|
+
name: "listItem",
|
|
2416
|
+
addOptions() {
|
|
2417
|
+
return {
|
|
2418
|
+
HTMLAttributes: {},
|
|
2419
|
+
bulletListTypeName: "bulletList",
|
|
2420
|
+
orderedListTypeName: "orderedList"
|
|
2421
|
+
};
|
|
2422
|
+
},
|
|
2423
|
+
content: "paragraph block*",
|
|
2424
|
+
defining: !0,
|
|
2425
|
+
parseHTML() {
|
|
2426
|
+
return [{ tag: "li" }];
|
|
2427
|
+
},
|
|
2428
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
2429
|
+
return [
|
|
2430
|
+
"li",
|
|
2431
|
+
_(this.options.HTMLAttributes, e),
|
|
2432
|
+
0
|
|
2433
|
+
];
|
|
2434
|
+
},
|
|
2435
|
+
markdownTokenName: "list_item",
|
|
2436
|
+
parseMarkdown: (e, t) => {
|
|
2437
|
+
if (e.type !== "list_item") return [];
|
|
2438
|
+
let n = t.parseBlockChildren ?? t.parseChildren, r = [];
|
|
2439
|
+
if (e.tokens && e.tokens.length > 0) {
|
|
2440
|
+
if (an(e)) return {
|
|
2441
|
+
type: "listItem",
|
|
2442
|
+
content: [{
|
|
2443
|
+
type: "paragraph",
|
|
2444
|
+
content: on(e.text || "", t)
|
|
2445
|
+
}]
|
|
2446
|
+
};
|
|
2447
|
+
if (e.tokens.some((e) => e.type === "paragraph")) r = n(e.tokens);
|
|
2448
|
+
else {
|
|
2449
|
+
let i = e.tokens[0];
|
|
2450
|
+
if (i && i.type === "text" && i.tokens && i.tokens.length > 0) {
|
|
2451
|
+
if (r = [{
|
|
2452
|
+
type: "paragraph",
|
|
2453
|
+
content: t.parseInline(i.tokens)
|
|
2454
|
+
}], e.tokens.length > 1) {
|
|
2455
|
+
let t = n(e.tokens.slice(1));
|
|
2456
|
+
r.push(...t);
|
|
2457
|
+
}
|
|
2458
|
+
} else r = n(e.tokens);
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
return r.length === 0 && (r = [{
|
|
2462
|
+
type: "paragraph",
|
|
2463
|
+
content: []
|
|
2464
|
+
}]), {
|
|
2465
|
+
type: "listItem",
|
|
2466
|
+
content: r
|
|
2467
|
+
};
|
|
2468
|
+
},
|
|
2469
|
+
renderMarkdown: (e, t, n) => ie(e, t, (e) => e.parentType === "bulletList" ? "- " : e.parentType === "orderedList" ? `${(e.meta?.parentAttrs?.start || 1) + e.index}. ` : "- ", n),
|
|
2470
|
+
addExtensions() {
|
|
2471
|
+
return [rn(this.name, [this.options.bulletListTypeName, this.options.orderedListTypeName])];
|
|
2472
|
+
},
|
|
2473
|
+
addKeyboardShortcuts() {
|
|
2474
|
+
return {
|
|
2475
|
+
Enter: () => this.editor.commands.splitListItem(this.name),
|
|
2476
|
+
Tab: () => this.editor.commands.sinkListItem(this.name),
|
|
2477
|
+
"Shift-Tab": () => this.editor.commands.liftListItem(this.name)
|
|
2478
|
+
};
|
|
2479
|
+
}
|
|
2480
|
+
});
|
|
2481
|
+
Yt({}, {
|
|
2482
|
+
findListItemPos: () => U,
|
|
2483
|
+
getNextListDepth: () => cn,
|
|
2484
|
+
handleBackspace: () => un,
|
|
2485
|
+
handleDelete: () => pn,
|
|
2486
|
+
hasListBefore: () => ln,
|
|
2487
|
+
hasListItemAfter: () => mn,
|
|
2488
|
+
hasListItemBefore: () => hn,
|
|
2489
|
+
listItemHasSubList: () => gn,
|
|
2490
|
+
nextListIsDeeper: () => dn,
|
|
2491
|
+
nextListIsHigher: () => fn
|
|
2492
|
+
});
|
|
2493
|
+
var U = (e, t) => {
|
|
2494
|
+
let { $from: n } = t.selection, r = te(e, t.schema), i = null, a = n.depth, o = n.pos, s = null;
|
|
2495
|
+
for (; a > 0 && s === null;) i = n.node(a), i.type === r ? s = a : (--a, --o);
|
|
2496
|
+
return s === null ? null : {
|
|
2497
|
+
$pos: t.doc.resolve(o),
|
|
2498
|
+
depth: s
|
|
2499
|
+
};
|
|
2500
|
+
}, cn = (e, t) => {
|
|
2501
|
+
let n = U(e, t);
|
|
2502
|
+
if (!n) return !1;
|
|
2503
|
+
let [, r] = ce(t, e, n.$pos.pos + 4);
|
|
2504
|
+
return r;
|
|
2505
|
+
}, ln = (e, t, n) => {
|
|
2506
|
+
let { $anchor: r } = e.selection, i = Math.max(0, r.pos - 2), a = e.doc.resolve(i).node();
|
|
2507
|
+
return !(!a || !n.includes(a.type.name));
|
|
2508
|
+
}, un = (e, t, n) => {
|
|
2509
|
+
if (e.commands.undoInputRule()) return !0;
|
|
2510
|
+
if (e.state.selection.from !== e.state.selection.to) return !1;
|
|
2511
|
+
if (!i(e.state, t) && ln(e.state, t, n)) {
|
|
2512
|
+
let { $anchor: n } = e.state.selection, r = e.state.doc.resolve(n.before() - 1), i = [];
|
|
2513
|
+
r.node().descendants((e, n) => {
|
|
2514
|
+
e.type.name === t && i.push({
|
|
2515
|
+
node: e,
|
|
2516
|
+
pos: n
|
|
2517
|
+
});
|
|
2518
|
+
});
|
|
2519
|
+
let a = i.at(-1);
|
|
2520
|
+
if (!a) return !1;
|
|
2521
|
+
let o = e.state.doc.resolve(r.start() + a.pos + 1);
|
|
2522
|
+
return e.chain().cut({
|
|
2523
|
+
from: n.start() - 1,
|
|
2524
|
+
to: n.end() + 1
|
|
2525
|
+
}, o.end()).joinForward().run();
|
|
2526
|
+
}
|
|
2527
|
+
return !i(e.state, t) || !ue(e.state) ? !1 : e.chain().liftListItem(t).run();
|
|
2528
|
+
}, dn = (e, t) => {
|
|
2529
|
+
let n = cn(e, t), r = U(e, t);
|
|
2530
|
+
return !r || !n ? !1 : n > r.depth;
|
|
2531
|
+
}, fn = (e, t) => {
|
|
2532
|
+
let n = cn(e, t), r = U(e, t);
|
|
2533
|
+
return !r || !n ? !1 : n < r.depth;
|
|
2534
|
+
}, pn = (e, n) => {
|
|
2535
|
+
if (!i(e.state, n) || !t(e.state, n)) return !1;
|
|
2536
|
+
let { selection: r } = e.state, { $from: a, $to: o } = r;
|
|
2537
|
+
return !r.empty && a.sameParent(o) ? !1 : dn(n, e.state) ? e.chain().focus(e.state.selection.from + 4).lift(n).joinBackward().run() : fn(n, e.state) ? e.chain().joinForward().joinBackward().run() : e.commands.joinItemForward();
|
|
2538
|
+
}, mn = (e, t) => {
|
|
2539
|
+
let { $anchor: n } = t.selection, r = t.doc.resolve(n.pos - n.parentOffset - 2);
|
|
2540
|
+
return !(r.index() === r.parent.childCount - 1 || r.nodeAfter?.type.name !== e);
|
|
2541
|
+
}, hn = (e, t) => {
|
|
2542
|
+
let { $anchor: n } = t.selection, r = t.doc.resolve(n.pos - 2);
|
|
2543
|
+
return !(r.index() === 0 || r.nodeBefore?.type.name !== e);
|
|
2544
|
+
}, gn = (e, t, n) => {
|
|
2545
|
+
if (!n) return !1;
|
|
2546
|
+
let r = te(e, t.schema), i = !1;
|
|
2547
|
+
return n.descendants((e) => {
|
|
2548
|
+
e.type === r && (i = !0);
|
|
2549
|
+
}), i;
|
|
2550
|
+
}, _n = g.create({
|
|
2551
|
+
name: "listKeymap",
|
|
2552
|
+
addOptions() {
|
|
2553
|
+
return { listTypes: [{
|
|
2554
|
+
itemName: "listItem",
|
|
2555
|
+
wrapperNames: ["bulletList", "orderedList"]
|
|
2556
|
+
}, {
|
|
2557
|
+
itemName: "taskItem",
|
|
2558
|
+
wrapperNames: ["taskList"]
|
|
2559
|
+
}] };
|
|
2560
|
+
},
|
|
2561
|
+
addKeyboardShortcuts() {
|
|
2562
|
+
return {
|
|
2563
|
+
Delete: ({ editor: e }) => {
|
|
2564
|
+
let t = !1;
|
|
2565
|
+
return this.options.listTypes.forEach(({ itemName: n }) => {
|
|
2566
|
+
e.state.schema.nodes[n] !== void 0 && pn(e, n) && (t = !0);
|
|
2567
|
+
}), t;
|
|
2568
|
+
},
|
|
2569
|
+
"Mod-Delete": ({ editor: e }) => {
|
|
2570
|
+
let t = !1;
|
|
2571
|
+
return this.options.listTypes.forEach(({ itemName: n }) => {
|
|
2572
|
+
e.state.schema.nodes[n] !== void 0 && pn(e, n) && (t = !0);
|
|
2573
|
+
}), t;
|
|
2574
|
+
},
|
|
2575
|
+
Backspace: ({ editor: e }) => {
|
|
2576
|
+
let t = !1;
|
|
2577
|
+
return this.options.listTypes.forEach(({ itemName: n, wrapperNames: r }) => {
|
|
2578
|
+
e.state.schema.nodes[n] !== void 0 && un(e, n, r) && (t = !0);
|
|
2579
|
+
}), t;
|
|
2580
|
+
},
|
|
2581
|
+
"Mod-Backspace": ({ editor: e }) => {
|
|
2582
|
+
let t = !1;
|
|
2583
|
+
return this.options.listTypes.forEach(({ itemName: n, wrapperNames: r }) => {
|
|
2584
|
+
e.state.schema.nodes[n] !== void 0 && un(e, n, r) && (t = !0);
|
|
2585
|
+
}), t;
|
|
2586
|
+
}
|
|
2587
|
+
};
|
|
2588
|
+
}
|
|
2589
|
+
}), vn = /^(\s*)(\d+)\.\s+(.*)$/, yn = /^\s/;
|
|
2590
|
+
function bn(e) {
|
|
2591
|
+
let t = e.trimStart();
|
|
2592
|
+
return /^[-+*]\s+/.test(t) || /^\d+\.\s+/.test(t) || /^>\s?/.test(t) || /^```/.test(t) || /^~~~/.test(t);
|
|
2593
|
+
}
|
|
2594
|
+
function xn(e) {
|
|
2595
|
+
let t = [], n = [], r = !1;
|
|
2596
|
+
return e.forEach((e) => {
|
|
2597
|
+
if (r) {
|
|
2598
|
+
n.push(e);
|
|
2599
|
+
return;
|
|
2600
|
+
}
|
|
2601
|
+
if (e.trim() === "") {
|
|
2602
|
+
r = !0, n.push(e);
|
|
2603
|
+
return;
|
|
2604
|
+
}
|
|
2605
|
+
if (t.length > 0 && bn(e)) {
|
|
2606
|
+
r = !0, n.push(e);
|
|
2607
|
+
return;
|
|
2608
|
+
}
|
|
2609
|
+
t.push(e);
|
|
2610
|
+
}), {
|
|
2611
|
+
paragraphLines: t,
|
|
2612
|
+
blockLines: n
|
|
2613
|
+
};
|
|
2614
|
+
}
|
|
2615
|
+
function Sn(e) {
|
|
2616
|
+
let t = [], n = 0, r = 0;
|
|
2617
|
+
for (; n < e.length;) {
|
|
2618
|
+
let i = e[n], a = i.match(vn);
|
|
2619
|
+
if (!a) break;
|
|
2620
|
+
let [, o, s, c] = a, l = o.length, u = [c], d = n + 1, f = [i], p = !1;
|
|
2621
|
+
for (; d < e.length;) {
|
|
2622
|
+
let t = e[d];
|
|
2623
|
+
if (t.match(vn)) break;
|
|
2624
|
+
if (t.trim() === "") f.push(t), u.push(""), p = !0, d += 1;
|
|
2625
|
+
else if (t.match(yn)) f.push(t), u.push(t.slice(l + 2)), d += 1;
|
|
2626
|
+
else {
|
|
2627
|
+
if (p) break;
|
|
2628
|
+
f.push(t), u.push(t), d += 1;
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
t.push({
|
|
2632
|
+
indent: l,
|
|
2633
|
+
number: parseInt(s, 10),
|
|
2634
|
+
content: u.join("\n").trim(),
|
|
2635
|
+
contentLines: u,
|
|
2636
|
+
raw: f.join("\n")
|
|
2637
|
+
}), r = d, n = d;
|
|
2638
|
+
}
|
|
2639
|
+
return [t, r];
|
|
2640
|
+
}
|
|
2641
|
+
function Cn(e, t, n) {
|
|
2642
|
+
let r = [], i = 0;
|
|
2643
|
+
for (; i < e.length;) {
|
|
2644
|
+
let a = e[i];
|
|
2645
|
+
if (a.indent === t) {
|
|
2646
|
+
let { paragraphLines: o, blockLines: s } = xn(a.contentLines), c = o.join("\n").trim(), l = [];
|
|
2647
|
+
c && l.push({
|
|
2648
|
+
type: "paragraph",
|
|
2649
|
+
raw: c,
|
|
2650
|
+
tokens: n.inlineTokens(c)
|
|
2651
|
+
});
|
|
2652
|
+
let u = s.join("\n").trim();
|
|
2653
|
+
if (u) {
|
|
2654
|
+
let e = n.blockTokens(u);
|
|
2655
|
+
l.push(...e);
|
|
2656
|
+
}
|
|
2657
|
+
let d = i + 1, f = [];
|
|
2658
|
+
for (; d < e.length && e[d].indent > t;) f.push(e[d]), d += 1;
|
|
2659
|
+
if (f.length > 0) {
|
|
2660
|
+
let e = Cn(f, Math.min(...f.map((e) => e.indent)), n);
|
|
2661
|
+
l.push({
|
|
2662
|
+
type: "list",
|
|
2663
|
+
ordered: !0,
|
|
2664
|
+
start: f[0].number,
|
|
2665
|
+
items: e,
|
|
2666
|
+
raw: f.map((e) => e.raw).join("\n")
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
r.push({
|
|
2670
|
+
type: "list_item",
|
|
2671
|
+
raw: a.raw,
|
|
2672
|
+
tokens: l
|
|
2673
|
+
}), i = d;
|
|
2674
|
+
} else i += 1;
|
|
2675
|
+
}
|
|
2676
|
+
return r;
|
|
2677
|
+
}
|
|
2678
|
+
function wn(e, t) {
|
|
2679
|
+
return e.map((e) => {
|
|
2680
|
+
if (e.type !== "list_item") return t.parseChildren([e])[0];
|
|
2681
|
+
let n = [];
|
|
2682
|
+
return e.tokens && e.tokens.length > 0 && e.tokens.forEach((e) => {
|
|
2683
|
+
if (e.type === "paragraph" || e.type === "list" || e.type === "blockquote" || e.type === "code") n.push(...t.parseChildren([e]));
|
|
2684
|
+
else if (e.type === "text" && e.tokens) {
|
|
2685
|
+
let r = t.parseChildren([e]);
|
|
2686
|
+
n.push({
|
|
2687
|
+
type: "paragraph",
|
|
2688
|
+
content: r
|
|
2689
|
+
});
|
|
2690
|
+
} else {
|
|
2691
|
+
let r = t.parseChildren([e]);
|
|
2692
|
+
r.length > 0 && n.push(...r);
|
|
2693
|
+
}
|
|
2694
|
+
}), {
|
|
2695
|
+
type: "listItem",
|
|
2696
|
+
content: n
|
|
2697
|
+
};
|
|
2698
|
+
});
|
|
2699
|
+
}
|
|
2700
|
+
var Tn = "listItem", En = "textStyle", Dn = /^(\d+)\.\s$/, On = v.create({
|
|
2701
|
+
name: "orderedList",
|
|
2702
|
+
addOptions() {
|
|
2703
|
+
return {
|
|
2704
|
+
itemTypeName: "listItem",
|
|
2705
|
+
HTMLAttributes: {},
|
|
2706
|
+
keepMarks: !1,
|
|
2707
|
+
keepAttributes: !1
|
|
2708
|
+
};
|
|
2709
|
+
},
|
|
2710
|
+
group: "block list",
|
|
2711
|
+
content() {
|
|
2712
|
+
return `${this.options.itemTypeName}+`;
|
|
2713
|
+
},
|
|
2714
|
+
addAttributes() {
|
|
2715
|
+
return {
|
|
2716
|
+
start: {
|
|
2717
|
+
default: 1,
|
|
2718
|
+
parseHTML: (e) => e.hasAttribute("start") ? parseInt(e.getAttribute("start") || "", 10) : 1
|
|
2719
|
+
},
|
|
2720
|
+
type: {
|
|
2721
|
+
default: null,
|
|
2722
|
+
parseHTML: (e) => e.getAttribute("type")
|
|
2723
|
+
}
|
|
2724
|
+
};
|
|
2725
|
+
},
|
|
2726
|
+
parseHTML() {
|
|
2727
|
+
return [{ tag: "ol" }];
|
|
2728
|
+
},
|
|
2729
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
2730
|
+
let { start: t, ...n } = e;
|
|
2731
|
+
return t === 1 ? [
|
|
2732
|
+
"ol",
|
|
2733
|
+
_(this.options.HTMLAttributes, n),
|
|
2734
|
+
0
|
|
2735
|
+
] : [
|
|
2736
|
+
"ol",
|
|
2737
|
+
_(this.options.HTMLAttributes, e),
|
|
2738
|
+
0
|
|
2739
|
+
];
|
|
2740
|
+
},
|
|
2741
|
+
markdownTokenName: "list",
|
|
2742
|
+
parseMarkdown: (e, t) => {
|
|
2743
|
+
if (e.type !== "list" || !e.ordered) return [];
|
|
2744
|
+
let n = e.start || 1, r = e.items ? wn(e.items, t) : [];
|
|
2745
|
+
return n === 1 ? {
|
|
2746
|
+
type: "orderedList",
|
|
2747
|
+
content: r
|
|
2748
|
+
} : {
|
|
2749
|
+
type: "orderedList",
|
|
2750
|
+
attrs: { start: n },
|
|
2751
|
+
content: r
|
|
2752
|
+
};
|
|
2753
|
+
},
|
|
2754
|
+
renderMarkdown: (e, t) => e.content ? t.renderChildren(e.content, "\n") : "",
|
|
2755
|
+
markdownTokenizer: {
|
|
2756
|
+
name: "orderedList",
|
|
2757
|
+
level: "block",
|
|
2758
|
+
start: (e) => {
|
|
2759
|
+
let t = e.match(/^(\s*)(\d+)\.\s+/)?.index;
|
|
2760
|
+
return t === void 0 ? -1 : t;
|
|
2761
|
+
},
|
|
2762
|
+
tokenize: (e, t, n) => {
|
|
2763
|
+
let r = e.split("\n"), [i, a] = Sn(r);
|
|
2764
|
+
if (i.length === 0) return;
|
|
2765
|
+
let o = Cn(i, 0, n);
|
|
2766
|
+
if (o.length !== 0) return {
|
|
2767
|
+
type: "list",
|
|
2768
|
+
ordered: !0,
|
|
2769
|
+
start: i[0]?.number || 1,
|
|
2770
|
+
items: o,
|
|
2771
|
+
raw: r.slice(0, a).join("\n")
|
|
2772
|
+
};
|
|
2773
|
+
}
|
|
2774
|
+
},
|
|
2775
|
+
markdownOptions: { indentsContent: !0 },
|
|
2776
|
+
addCommands() {
|
|
2777
|
+
return { toggleOrderedList: () => ({ commands: e, chain: t }) => this.options.keepAttributes ? t().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(Tn, this.editor.getAttributes(En)).run() : e.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks) };
|
|
2778
|
+
},
|
|
2779
|
+
addKeyboardShortcuts() {
|
|
2780
|
+
return { "Mod-Shift-7": () => this.editor.commands.toggleOrderedList() };
|
|
2781
|
+
},
|
|
2782
|
+
addInputRules() {
|
|
2783
|
+
let e = h({
|
|
2784
|
+
find: Dn,
|
|
2785
|
+
type: this.type,
|
|
2786
|
+
getAttributes: (e) => ({ start: +e[1] }),
|
|
2787
|
+
joinPredicate: (e, t) => t.childCount + t.attrs.start === +e[1]
|
|
2788
|
+
});
|
|
2789
|
+
return (this.options.keepMarks || this.options.keepAttributes) && (e = h({
|
|
2790
|
+
find: Dn,
|
|
2791
|
+
type: this.type,
|
|
2792
|
+
keepMarks: this.options.keepMarks,
|
|
2793
|
+
keepAttributes: this.options.keepAttributes,
|
|
2794
|
+
getAttributes: (e) => ({
|
|
2795
|
+
start: +e[1],
|
|
2796
|
+
...this.editor.getAttributes(En)
|
|
2797
|
+
}),
|
|
2798
|
+
joinPredicate: (e, t) => t.childCount + t.attrs.start === +e[1],
|
|
2799
|
+
editor: this.editor
|
|
2800
|
+
})), [e];
|
|
2801
|
+
}
|
|
2802
|
+
}), kn = /^\s*(\[([( |x])?\])\s$/, An = v.create({
|
|
2803
|
+
name: "taskItem",
|
|
2804
|
+
addOptions() {
|
|
2805
|
+
return {
|
|
2806
|
+
nested: !1,
|
|
2807
|
+
HTMLAttributes: {},
|
|
2808
|
+
taskListTypeName: "taskList",
|
|
2809
|
+
a11y: void 0
|
|
2810
|
+
};
|
|
2811
|
+
},
|
|
2812
|
+
content() {
|
|
2813
|
+
return this.options.nested ? "paragraph block*" : "paragraph+";
|
|
2814
|
+
},
|
|
2815
|
+
defining: !0,
|
|
2816
|
+
addAttributes() {
|
|
2817
|
+
return { checked: {
|
|
2818
|
+
default: !1,
|
|
2819
|
+
keepOnSplit: !1,
|
|
2820
|
+
parseHTML: (e) => {
|
|
2821
|
+
let t = e.getAttribute("data-checked");
|
|
2822
|
+
return t === "" || t === "true";
|
|
2823
|
+
},
|
|
2824
|
+
renderHTML: (e) => ({ "data-checked": e.checked })
|
|
2825
|
+
} };
|
|
2826
|
+
},
|
|
2827
|
+
parseHTML() {
|
|
2828
|
+
return [{
|
|
2829
|
+
tag: `li[data-type="${this.name}"]`,
|
|
2830
|
+
priority: 51
|
|
2831
|
+
}];
|
|
2832
|
+
},
|
|
2833
|
+
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
2834
|
+
return [
|
|
2835
|
+
"li",
|
|
2836
|
+
_(this.options.HTMLAttributes, t, { "data-type": this.name }),
|
|
2837
|
+
[
|
|
2838
|
+
"label",
|
|
2839
|
+
["input", {
|
|
2840
|
+
type: "checkbox",
|
|
2841
|
+
checked: e.attrs.checked ? "checked" : null
|
|
2842
|
+
}],
|
|
2843
|
+
["span"]
|
|
2844
|
+
],
|
|
2845
|
+
["div", 0]
|
|
2846
|
+
];
|
|
2847
|
+
},
|
|
2848
|
+
parseMarkdown: (e, t) => {
|
|
2849
|
+
let n = [];
|
|
2850
|
+
if (e.tokens && e.tokens.length > 0 ? n.push(t.createNode("paragraph", {}, t.parseInline(e.tokens))) : e.text ? n.push(t.createNode("paragraph", {}, [t.createNode("text", { text: e.text })])) : n.push(t.createNode("paragraph", {}, [])), e.nestedTokens && e.nestedTokens.length > 0) {
|
|
2851
|
+
let r = t.parseChildren(e.nestedTokens);
|
|
2852
|
+
n.push(...r);
|
|
2853
|
+
}
|
|
2854
|
+
return t.createNode("taskItem", { checked: e.checked || !1 }, n);
|
|
2855
|
+
},
|
|
2856
|
+
renderMarkdown: (e, t) => ie(e, t, `- [${e.attrs?.checked ? "x" : " "}] `),
|
|
2857
|
+
addExtensions() {
|
|
2858
|
+
return this.options.nested ? [rn(this.name, [this.options.taskListTypeName])] : [];
|
|
2859
|
+
},
|
|
2860
|
+
addKeyboardShortcuts() {
|
|
2861
|
+
let e = {
|
|
2862
|
+
Enter: () => this.editor.commands.splitListItem(this.name),
|
|
2863
|
+
"Shift-Tab": () => this.editor.commands.liftListItem(this.name)
|
|
2864
|
+
};
|
|
2865
|
+
return this.options.nested ? {
|
|
2866
|
+
...e,
|
|
2867
|
+
Tab: () => this.editor.commands.sinkListItem(this.name)
|
|
2868
|
+
} : e;
|
|
2869
|
+
},
|
|
2870
|
+
addNodeView() {
|
|
2871
|
+
return ({ node: e, HTMLAttributes: t, getPos: n, editor: r }) => {
|
|
2872
|
+
let i = document.createElement("li"), a = document.createElement("label"), o = document.createElement("span"), s = document.createElement("input"), c = document.createElement("div"), l = (e) => {
|
|
2873
|
+
var t;
|
|
2874
|
+
s.ariaLabel = ((t = this.options.a11y)?.checkboxLabel)?.call(t, e, s.checked) || `Task item checkbox for ${e.textContent || "empty task item"}`;
|
|
2875
|
+
};
|
|
2876
|
+
l(e), a.contentEditable = "false", s.type = "checkbox", s.addEventListener("mousedown", (e) => e.preventDefault()), s.addEventListener("change", (t) => {
|
|
2877
|
+
if (!r.isEditable && !this.options.onReadOnlyChecked) {
|
|
2878
|
+
s.checked = !s.checked;
|
|
2879
|
+
return;
|
|
2880
|
+
}
|
|
2881
|
+
let { checked: i } = t.target;
|
|
2882
|
+
r.isEditable && typeof n == "function" && r.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: e }) => {
|
|
2883
|
+
let t = n();
|
|
2884
|
+
if (typeof t != "number") return !1;
|
|
2885
|
+
let r = e.doc.nodeAt(t);
|
|
2886
|
+
return e.setNodeMarkup(t, void 0, {
|
|
2887
|
+
...r?.attrs,
|
|
2888
|
+
checked: i
|
|
2889
|
+
}), !0;
|
|
2890
|
+
}).run(), !r.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(e, i) || (s.checked = !s.checked));
|
|
2891
|
+
}), Object.entries(this.options.HTMLAttributes).forEach(([e, t]) => {
|
|
2892
|
+
i.setAttribute(e, t);
|
|
2893
|
+
}), i.dataset.checked = e.attrs.checked, s.checked = e.attrs.checked, a.append(s, o), i.append(a, c), Object.entries(t).forEach(([e, t]) => {
|
|
2894
|
+
i.setAttribute(e, t);
|
|
2895
|
+
});
|
|
2896
|
+
let u = new Set(Object.keys(t));
|
|
2897
|
+
return {
|
|
2898
|
+
dom: i,
|
|
2899
|
+
contentDOM: c,
|
|
2900
|
+
update: (e) => {
|
|
2901
|
+
if (e.type !== this.type) return !1;
|
|
2902
|
+
i.dataset.checked = e.attrs.checked, s.checked = e.attrs.checked, l(e);
|
|
2903
|
+
let t = r.extensionManager.attributes, n = se(e, t), a = new Set(Object.keys(n)), o = this.options.HTMLAttributes;
|
|
2904
|
+
return u.forEach((e) => {
|
|
2905
|
+
a.has(e) || (e in o ? i.setAttribute(e, o[e]) : i.removeAttribute(e));
|
|
2906
|
+
}), Object.entries(n).forEach(([e, t]) => {
|
|
2907
|
+
t == null ? e in o ? i.setAttribute(e, o[e]) : i.removeAttribute(e) : i.setAttribute(e, t);
|
|
2908
|
+
}), u = a, !0;
|
|
2909
|
+
}
|
|
2910
|
+
};
|
|
2911
|
+
};
|
|
2912
|
+
},
|
|
2913
|
+
addInputRules() {
|
|
2914
|
+
return [h({
|
|
2915
|
+
find: kn,
|
|
2916
|
+
type: this.type,
|
|
2917
|
+
getAttributes: (e) => ({ checked: e[e.length - 1] === "x" })
|
|
2918
|
+
})];
|
|
2919
|
+
}
|
|
2920
|
+
}), jn = v.create({
|
|
2921
|
+
name: "taskList",
|
|
2922
|
+
addOptions() {
|
|
2923
|
+
return {
|
|
2924
|
+
itemTypeName: "taskItem",
|
|
2925
|
+
HTMLAttributes: {}
|
|
2926
|
+
};
|
|
2927
|
+
},
|
|
2928
|
+
group: "block list",
|
|
2929
|
+
content() {
|
|
2930
|
+
return `${this.options.itemTypeName}+`;
|
|
2931
|
+
},
|
|
2932
|
+
parseHTML() {
|
|
2933
|
+
return [{
|
|
2934
|
+
tag: `ul[data-type="${this.name}"]`,
|
|
2935
|
+
priority: 51
|
|
2936
|
+
}];
|
|
2937
|
+
},
|
|
2938
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
2939
|
+
return [
|
|
2940
|
+
"ul",
|
|
2941
|
+
_(this.options.HTMLAttributes, e, { "data-type": this.name }),
|
|
2942
|
+
0
|
|
2943
|
+
];
|
|
2944
|
+
},
|
|
2945
|
+
parseMarkdown: (e, t) => t.createNode("taskList", {}, t.parseChildren(e.items || [])),
|
|
2946
|
+
renderMarkdown: (e, t) => e.content ? t.renderChildren(e.content, "\n") : "",
|
|
2947
|
+
markdownTokenizer: {
|
|
2948
|
+
name: "taskList",
|
|
2949
|
+
level: "block",
|
|
2950
|
+
start(e) {
|
|
2951
|
+
let t = e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;
|
|
2952
|
+
return t === void 0 ? -1 : t;
|
|
2953
|
+
},
|
|
2954
|
+
tokenize(e, t, n) {
|
|
2955
|
+
let r = (e) => {
|
|
2956
|
+
let t = re(e, {
|
|
2957
|
+
itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
|
|
2958
|
+
extractItemData: (e) => ({
|
|
2959
|
+
indentLevel: e[1].length,
|
|
2960
|
+
mainContent: e[4],
|
|
2961
|
+
checked: e[3].toLowerCase() === "x"
|
|
2962
|
+
}),
|
|
2963
|
+
createToken: (e, t) => ({
|
|
2964
|
+
type: "taskItem",
|
|
2965
|
+
raw: "",
|
|
2966
|
+
mainContent: e.mainContent,
|
|
2967
|
+
indentLevel: e.indentLevel,
|
|
2968
|
+
checked: e.checked,
|
|
2969
|
+
text: e.mainContent,
|
|
2970
|
+
tokens: n.inlineTokens(e.mainContent),
|
|
2971
|
+
nestedTokens: t
|
|
2972
|
+
}),
|
|
2973
|
+
customNestedParser: r
|
|
2974
|
+
}, n);
|
|
2975
|
+
return t ? [{
|
|
2976
|
+
type: "taskList",
|
|
2977
|
+
raw: t.raw,
|
|
2978
|
+
items: t.items
|
|
2979
|
+
}] : n.blockTokens(e);
|
|
2980
|
+
}, i = re(e, {
|
|
2981
|
+
itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
|
|
2982
|
+
extractItemData: (e) => ({
|
|
2983
|
+
indentLevel: e[1].length,
|
|
2984
|
+
mainContent: e[4],
|
|
2985
|
+
checked: e[3].toLowerCase() === "x"
|
|
2986
|
+
}),
|
|
2987
|
+
createToken: (e, t) => ({
|
|
2988
|
+
type: "taskItem",
|
|
2989
|
+
raw: "",
|
|
2990
|
+
mainContent: e.mainContent,
|
|
2991
|
+
indentLevel: e.indentLevel,
|
|
2992
|
+
checked: e.checked,
|
|
2993
|
+
text: e.mainContent,
|
|
2994
|
+
tokens: n.inlineTokens(e.mainContent),
|
|
2995
|
+
nestedTokens: t
|
|
2996
|
+
}),
|
|
2997
|
+
customNestedParser: r
|
|
2998
|
+
}, n);
|
|
2999
|
+
if (i) return {
|
|
3000
|
+
type: "taskList",
|
|
3001
|
+
raw: i.raw,
|
|
3002
|
+
items: i.items
|
|
3003
|
+
};
|
|
3004
|
+
}
|
|
3005
|
+
},
|
|
3006
|
+
markdownOptions: { indentsContent: !0 },
|
|
3007
|
+
addCommands() {
|
|
3008
|
+
return { toggleTaskList: () => ({ commands: e }) => e.toggleList(this.name, this.options.itemTypeName) };
|
|
3009
|
+
},
|
|
3010
|
+
addKeyboardShortcuts() {
|
|
3011
|
+
return { "Mod-Shift-9": () => this.editor.commands.toggleTaskList() };
|
|
3012
|
+
}
|
|
3013
|
+
});
|
|
3014
|
+
g.create({
|
|
3015
|
+
name: "listKit",
|
|
3016
|
+
addExtensions() {
|
|
3017
|
+
let e = [];
|
|
3018
|
+
return this.options.bulletList !== !1 && e.push($t.configure(this.options.bulletList)), this.options.listItem !== !1 && e.push(sn.configure(this.options.listItem)), this.options.listKeymap !== !1 && e.push(_n.configure(this.options.listKeymap)), this.options.orderedList !== !1 && e.push(On.configure(this.options.orderedList)), this.options.taskItem !== !1 && e.push(An.configure(this.options.taskItem)), this.options.taskList !== !1 && e.push(jn.configure(this.options.taskList)), e;
|
|
3019
|
+
}
|
|
3020
|
+
});
|
|
3021
|
+
//#endregion
|
|
3022
|
+
//#region ../../node_modules/.pnpm/@tiptap+extension-paragraph@3.26.0_@tiptap+core@3.26.0_@tiptap+pm@3.26.0_/node_modules/@tiptap/extension-paragraph/dist/index.js
|
|
3023
|
+
var W = " ", Mn = "\xA0", Nn = v.create({
|
|
3024
|
+
name: "paragraph",
|
|
3025
|
+
priority: 1e3,
|
|
3026
|
+
addOptions() {
|
|
3027
|
+
return { HTMLAttributes: {} };
|
|
3028
|
+
},
|
|
3029
|
+
group: "block",
|
|
3030
|
+
content: "inline*",
|
|
3031
|
+
parseHTML() {
|
|
3032
|
+
return [{ tag: "p" }];
|
|
3033
|
+
},
|
|
3034
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
3035
|
+
return [
|
|
3036
|
+
"p",
|
|
3037
|
+
_(this.options.HTMLAttributes, e),
|
|
3038
|
+
0
|
|
3039
|
+
];
|
|
3040
|
+
},
|
|
3041
|
+
parseMarkdown: (e, t) => {
|
|
3042
|
+
let n = e.tokens || [];
|
|
3043
|
+
if (n.length === 1 && n[0].type === "image") return t.parseChildren([n[0]]);
|
|
3044
|
+
let r = t.parseInline(n);
|
|
3045
|
+
return n.length === 1 && n[0].type === "text" && (n[0].raw === W || n[0].text === W || n[0].raw === Mn || n[0].text === Mn) && r.length === 1 && r[0].type === "text" && (r[0].text === W || r[0].text === Mn) ? t.createNode("paragraph", void 0, []) : t.createNode("paragraph", void 0, r);
|
|
3046
|
+
},
|
|
3047
|
+
renderMarkdown: (e, t, n) => {
|
|
3048
|
+
if (!e) return "";
|
|
3049
|
+
let r = Array.isArray(e.content) ? e.content : [];
|
|
3050
|
+
if (r.length === 0) {
|
|
3051
|
+
let e = Array.isArray(n?.previousNode?.content) ? n.previousNode.content : [];
|
|
3052
|
+
return n?.previousNode?.type === "paragraph" && e.length === 0 ? W : "";
|
|
3053
|
+
}
|
|
3054
|
+
return t.renderChildren(r);
|
|
3055
|
+
},
|
|
3056
|
+
addCommands() {
|
|
3057
|
+
return { setParagraph: () => ({ commands: e }) => e.setNode(this.name) };
|
|
3058
|
+
},
|
|
3059
|
+
addKeyboardShortcuts() {
|
|
3060
|
+
return { "Mod-Alt-0": () => this.editor.commands.setParagraph() };
|
|
3061
|
+
}
|
|
3062
|
+
}), Pn = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, Fn = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, In = m.create({
|
|
3063
|
+
name: "strike",
|
|
3064
|
+
addOptions() {
|
|
3065
|
+
return { HTMLAttributes: {} };
|
|
3066
|
+
},
|
|
3067
|
+
parseHTML() {
|
|
3068
|
+
return [
|
|
3069
|
+
{ tag: "s" },
|
|
3070
|
+
{ tag: "del" },
|
|
3071
|
+
{ tag: "strike" },
|
|
3072
|
+
{
|
|
3073
|
+
style: "text-decoration",
|
|
3074
|
+
consuming: !1,
|
|
3075
|
+
getAttrs: (e) => e.includes("line-through") ? {} : !1
|
|
3076
|
+
}
|
|
3077
|
+
];
|
|
3078
|
+
},
|
|
3079
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
3080
|
+
return [
|
|
3081
|
+
"s",
|
|
3082
|
+
_(this.options.HTMLAttributes, e),
|
|
3083
|
+
0
|
|
3084
|
+
];
|
|
3085
|
+
},
|
|
3086
|
+
markdownTokenName: "del",
|
|
3087
|
+
parseMarkdown: (e, t) => t.applyMark("strike", t.parseInline(e.tokens || [])),
|
|
3088
|
+
renderMarkdown: (e, t) => `~~${t.renderChildren(e)}~~`,
|
|
3089
|
+
addCommands() {
|
|
3090
|
+
return {
|
|
3091
|
+
setStrike: () => ({ commands: e }) => e.setMark(this.name),
|
|
3092
|
+
toggleStrike: () => ({ commands: e }) => e.toggleMark(this.name),
|
|
3093
|
+
unsetStrike: () => ({ commands: e }) => e.unsetMark(this.name)
|
|
3094
|
+
};
|
|
3095
|
+
},
|
|
3096
|
+
addKeyboardShortcuts() {
|
|
3097
|
+
return { "Mod-Shift-s": () => this.editor.commands.toggleStrike() };
|
|
3098
|
+
},
|
|
3099
|
+
addInputRules() {
|
|
3100
|
+
return [u({
|
|
3101
|
+
find: Pn,
|
|
3102
|
+
type: this.type
|
|
3103
|
+
})];
|
|
3104
|
+
},
|
|
3105
|
+
addPasteRules() {
|
|
3106
|
+
return [d({
|
|
3107
|
+
find: Fn,
|
|
3108
|
+
type: this.type
|
|
3109
|
+
})];
|
|
3110
|
+
}
|
|
3111
|
+
}), Ln = v.create({
|
|
3112
|
+
name: "text",
|
|
3113
|
+
group: "inline",
|
|
3114
|
+
parseMarkdown: (e) => ({
|
|
3115
|
+
type: "text",
|
|
3116
|
+
text: e.text || ""
|
|
3117
|
+
}),
|
|
3118
|
+
renderMarkdown: (e) => e.text || ""
|
|
3119
|
+
});
|
|
3120
|
+
//#endregion
|
|
3121
|
+
//#region ../../node_modules/.pnpm/prosemirror-dropcursor@1.8.2/node_modules/prosemirror-dropcursor/dist/index.js
|
|
3122
|
+
function Rn(e = {}) {
|
|
3123
|
+
return new x({ view(t) {
|
|
3124
|
+
return new zn(t, e);
|
|
3125
|
+
} });
|
|
3126
|
+
}
|
|
3127
|
+
var zn = class {
|
|
3128
|
+
constructor(e, t) {
|
|
3129
|
+
this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = t.width ?? 1, this.color = t.color === !1 ? void 0 : t.color || "black", this.class = t.class, this.handlers = [
|
|
3130
|
+
"dragover",
|
|
3131
|
+
"dragend",
|
|
3132
|
+
"drop",
|
|
3133
|
+
"dragleave"
|
|
3134
|
+
].map((t) => {
|
|
3135
|
+
let n = (e) => {
|
|
3136
|
+
this[t](e);
|
|
3137
|
+
};
|
|
3138
|
+
return e.dom.addEventListener(t, n), {
|
|
3139
|
+
name: t,
|
|
3140
|
+
handler: n
|
|
3141
|
+
};
|
|
3142
|
+
});
|
|
3143
|
+
}
|
|
3144
|
+
destroy() {
|
|
3145
|
+
this.handlers.forEach(({ name: e, handler: t }) => this.editorView.dom.removeEventListener(e, t));
|
|
3146
|
+
}
|
|
3147
|
+
update(e, t) {
|
|
3148
|
+
this.cursorPos != null && t.doc != e.state.doc && (this.cursorPos > e.state.doc.content.size ? this.setCursor(null) : this.updateOverlay());
|
|
3149
|
+
}
|
|
3150
|
+
setCursor(e) {
|
|
3151
|
+
e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
|
|
3152
|
+
}
|
|
3153
|
+
updateOverlay() {
|
|
3154
|
+
let e = this.editorView.state.doc.resolve(this.cursorPos), t = !e.parent.inlineContent, n, r = this.editorView.dom, i = r.getBoundingClientRect(), a = i.width / r.offsetWidth, o = i.height / r.offsetHeight;
|
|
3155
|
+
if (t) {
|
|
3156
|
+
let t = e.nodeBefore, r = e.nodeAfter;
|
|
3157
|
+
if (t || r) {
|
|
3158
|
+
let e = this.editorView.nodeDOM(this.cursorPos - (t ? t.nodeSize : 0));
|
|
3159
|
+
if (e) {
|
|
3160
|
+
let i = e.getBoundingClientRect(), a = t ? i.bottom : i.top;
|
|
3161
|
+
t && r && (a = (a + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
|
|
3162
|
+
let s = this.width / 2 * o;
|
|
3163
|
+
n = {
|
|
3164
|
+
left: i.left,
|
|
3165
|
+
right: i.right,
|
|
3166
|
+
top: a - s,
|
|
3167
|
+
bottom: a + s
|
|
3168
|
+
};
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
if (!n) {
|
|
3173
|
+
let e = this.editorView.coordsAtPos(this.cursorPos), t = this.width / 2 * a;
|
|
3174
|
+
n = {
|
|
3175
|
+
left: e.left - t,
|
|
3176
|
+
right: e.left + t,
|
|
3177
|
+
top: e.top,
|
|
3178
|
+
bottom: e.bottom
|
|
3179
|
+
};
|
|
3180
|
+
}
|
|
3181
|
+
let s = this.editorView.dom.offsetParent;
|
|
3182
|
+
this.element || (this.element = s.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", t), this.element.classList.toggle("prosemirror-dropcursor-inline", !t);
|
|
3183
|
+
let c, l;
|
|
3184
|
+
if (!s || s == document.body && getComputedStyle(s).position == "static") c = -pageXOffset, l = -pageYOffset;
|
|
3185
|
+
else {
|
|
3186
|
+
let e = s.getBoundingClientRect(), t = e.width / s.offsetWidth, n = e.height / s.offsetHeight;
|
|
3187
|
+
c = e.left - s.scrollLeft * t, l = e.top - s.scrollTop * n;
|
|
3188
|
+
}
|
|
3189
|
+
this.element.style.left = (n.left - c) / a + "px", this.element.style.top = (n.top - l) / o + "px", this.element.style.width = (n.right - n.left) / a + "px", this.element.style.height = (n.bottom - n.top) / o + "px";
|
|
3190
|
+
}
|
|
3191
|
+
scheduleRemoval(e) {
|
|
3192
|
+
clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
|
|
3193
|
+
}
|
|
3194
|
+
dragover(e) {
|
|
3195
|
+
if (!this.editorView.editable) return;
|
|
3196
|
+
let t = this.editorView.posAtCoords({
|
|
3197
|
+
left: e.clientX,
|
|
3198
|
+
top: e.clientY
|
|
3199
|
+
}), n = t && t.inside >= 0 && this.editorView.state.doc.nodeAt(t.inside), i = n && n.type.spec.disableDropCursor, a = typeof i == "function" ? i(this.editorView, t, e) : i;
|
|
3200
|
+
if (t && !a) {
|
|
3201
|
+
let e = t.pos;
|
|
3202
|
+
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
3203
|
+
let t = r(this.editorView.state.doc, e, this.editorView.dragging.slice);
|
|
3204
|
+
t != null && (e = t);
|
|
3205
|
+
}
|
|
3206
|
+
this.setCursor(e), this.scheduleRemoval(5e3);
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
dragend() {
|
|
3210
|
+
this.scheduleRemoval(20);
|
|
3211
|
+
}
|
|
3212
|
+
drop() {
|
|
3213
|
+
this.scheduleRemoval(20);
|
|
3214
|
+
}
|
|
3215
|
+
dragleave(e) {
|
|
3216
|
+
this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null);
|
|
3217
|
+
}
|
|
3218
|
+
}, G = class t extends e {
|
|
3219
|
+
constructor(e) {
|
|
3220
|
+
super(e, e);
|
|
3221
|
+
}
|
|
3222
|
+
map(n, r) {
|
|
3223
|
+
let i = n.resolve(r.map(this.head));
|
|
3224
|
+
return t.valid(i) ? new t(i) : e.near(i);
|
|
3225
|
+
}
|
|
3226
|
+
content() {
|
|
3227
|
+
return o.empty;
|
|
3228
|
+
}
|
|
3229
|
+
eq(e) {
|
|
3230
|
+
return e instanceof t && e.head == this.head;
|
|
3231
|
+
}
|
|
3232
|
+
toJSON() {
|
|
3233
|
+
return {
|
|
3234
|
+
type: "gapcursor",
|
|
3235
|
+
pos: this.head
|
|
3236
|
+
};
|
|
3237
|
+
}
|
|
3238
|
+
static fromJSON(e, n) {
|
|
3239
|
+
if (typeof n.pos != "number") throw RangeError("Invalid input for GapCursor.fromJSON");
|
|
3240
|
+
return new t(e.resolve(n.pos));
|
|
3241
|
+
}
|
|
3242
|
+
getBookmark() {
|
|
3243
|
+
return new Bn(this.anchor);
|
|
3244
|
+
}
|
|
3245
|
+
static valid(e) {
|
|
3246
|
+
let t = e.parent;
|
|
3247
|
+
if (t.inlineContent || !Hn(e) || !Un(e)) return !1;
|
|
3248
|
+
let n = t.type.spec.allowGapCursor;
|
|
3249
|
+
if (n != null) return n;
|
|
3250
|
+
let r = t.contentMatchAt(e.index()).defaultType;
|
|
3251
|
+
return r && r.isTextblock;
|
|
3252
|
+
}
|
|
3253
|
+
static findGapCursorFrom(e, n, r = !1) {
|
|
3254
|
+
search: for (;;) {
|
|
3255
|
+
if (!r && t.valid(e)) return e;
|
|
3256
|
+
let i = e.pos, a = null;
|
|
3257
|
+
for (let r = e.depth;; r--) {
|
|
3258
|
+
let o = e.node(r);
|
|
3259
|
+
if (n > 0 ? e.indexAfter(r) < o.childCount : e.index(r) > 0) {
|
|
3260
|
+
a = o.child(n > 0 ? e.indexAfter(r) : e.index(r) - 1);
|
|
3261
|
+
break;
|
|
3262
|
+
} else if (r == 0) return null;
|
|
3263
|
+
i += n;
|
|
3264
|
+
let s = e.doc.resolve(i);
|
|
3265
|
+
if (t.valid(s)) return s;
|
|
3266
|
+
}
|
|
3267
|
+
for (;;) {
|
|
3268
|
+
let o = n > 0 ? a.firstChild : a.lastChild;
|
|
3269
|
+
if (!o) {
|
|
3270
|
+
if (a.isAtom && !a.isText && !ne.isSelectable(a)) {
|
|
3271
|
+
e = e.doc.resolve(i + a.nodeSize * n), r = !1;
|
|
3272
|
+
continue search;
|
|
3273
|
+
}
|
|
3274
|
+
break;
|
|
3275
|
+
}
|
|
3276
|
+
a = o, i += n;
|
|
3277
|
+
let s = e.doc.resolve(i);
|
|
3278
|
+
if (t.valid(s)) return s;
|
|
3279
|
+
}
|
|
3280
|
+
return null;
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
};
|
|
3284
|
+
G.prototype.visible = !1, G.findFrom = G.findGapCursorFrom, e.jsonID("gapcursor", G);
|
|
3285
|
+
var Bn = class t {
|
|
3286
|
+
constructor(e) {
|
|
3287
|
+
this.pos = e;
|
|
3288
|
+
}
|
|
3289
|
+
map(e) {
|
|
3290
|
+
return new t(e.map(this.pos));
|
|
3291
|
+
}
|
|
3292
|
+
resolve(t) {
|
|
3293
|
+
let n = t.resolve(this.pos);
|
|
3294
|
+
return G.valid(n) ? new G(n) : e.near(n);
|
|
3295
|
+
}
|
|
3296
|
+
};
|
|
3297
|
+
function Vn(e) {
|
|
3298
|
+
return e.isAtom || e.spec.isolating || e.spec.createGapCursor;
|
|
3299
|
+
}
|
|
3300
|
+
function Hn(e) {
|
|
3301
|
+
for (let t = e.depth; t >= 0; t--) {
|
|
3302
|
+
let n = e.index(t), r = e.node(t);
|
|
3303
|
+
if (n == 0) {
|
|
3304
|
+
if (r.type.spec.isolating) return !0;
|
|
3305
|
+
continue;
|
|
3306
|
+
}
|
|
3307
|
+
for (let e = r.child(n - 1);; e = e.lastChild) {
|
|
3308
|
+
if (e.childCount == 0 && !e.inlineContent || Vn(e.type)) return !0;
|
|
3309
|
+
if (e.inlineContent) return !1;
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
return !0;
|
|
3313
|
+
}
|
|
3314
|
+
function Un(e) {
|
|
3315
|
+
for (let t = e.depth; t >= 0; t--) {
|
|
3316
|
+
let n = e.indexAfter(t), r = e.node(t);
|
|
3317
|
+
if (n == r.childCount) {
|
|
3318
|
+
if (r.type.spec.isolating) return !0;
|
|
3319
|
+
continue;
|
|
3320
|
+
}
|
|
3321
|
+
for (let e = r.child(n);; e = e.firstChild) {
|
|
3322
|
+
if (e.childCount == 0 && !e.inlineContent || Vn(e.type)) return !0;
|
|
3323
|
+
if (e.inlineContent) return !1;
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
return !0;
|
|
3327
|
+
}
|
|
3328
|
+
function Wn() {
|
|
3329
|
+
return new x({ props: {
|
|
3330
|
+
decorations: Jn,
|
|
3331
|
+
createSelectionBetween(e, t, n) {
|
|
3332
|
+
return t.pos == n.pos && G.valid(n) ? new G(n) : null;
|
|
3333
|
+
},
|
|
3334
|
+
handleClick: Kn,
|
|
3335
|
+
handleKeyDown: Gn,
|
|
3336
|
+
handleDOMEvents: { beforeinput: qn }
|
|
3337
|
+
} });
|
|
3338
|
+
}
|
|
3339
|
+
var Gn = ee({
|
|
3340
|
+
ArrowLeft: K("horiz", -1),
|
|
3341
|
+
ArrowRight: K("horiz", 1),
|
|
3342
|
+
ArrowUp: K("vert", -1),
|
|
3343
|
+
ArrowDown: K("vert", 1)
|
|
3344
|
+
});
|
|
3345
|
+
function K(e, t) {
|
|
3346
|
+
let n = e == "vert" ? t > 0 ? "down" : "up" : t > 0 ? "right" : "left";
|
|
3347
|
+
return function(e, r, i) {
|
|
3348
|
+
let a = e.selection, o = t > 0 ? a.$to : a.$from, s = a.empty;
|
|
3349
|
+
if (a instanceof b) {
|
|
3350
|
+
if (!i.endOfTextblock(n) || o.depth == 0) return !1;
|
|
3351
|
+
s = !1, o = e.doc.resolve(t > 0 ? o.after() : o.before());
|
|
3352
|
+
}
|
|
3353
|
+
let c = G.findGapCursorFrom(o, t, s);
|
|
3354
|
+
return c ? (r && r(e.tr.setSelection(new G(c))), !0) : !1;
|
|
3355
|
+
};
|
|
3356
|
+
}
|
|
3357
|
+
function Kn(e, t, n) {
|
|
3358
|
+
if (!e || !e.editable) return !1;
|
|
3359
|
+
let r = e.state.doc.resolve(t);
|
|
3360
|
+
if (!G.valid(r)) return !1;
|
|
3361
|
+
let i = e.posAtCoords({
|
|
3362
|
+
left: n.clientX,
|
|
3363
|
+
top: n.clientY
|
|
3364
|
+
});
|
|
3365
|
+
return i && i.inside > -1 && ne.isSelectable(e.state.doc.nodeAt(i.inside)) ? !1 : (e.dispatch(e.state.tr.setSelection(new G(r))), !0);
|
|
3366
|
+
}
|
|
3367
|
+
function qn(e, t) {
|
|
3368
|
+
if (t.inputType != "insertCompositionText" || !(e.state.selection instanceof G)) return !1;
|
|
3369
|
+
let { $from: r } = e.state.selection, i = r.parent.contentMatchAt(r.index()).findWrapping(e.state.schema.nodes.text);
|
|
3370
|
+
if (!i) return !1;
|
|
3371
|
+
let a = n.empty;
|
|
3372
|
+
for (let e = i.length - 1; e >= 0; e--) a = n.from(i[e].createAndFill(null, a));
|
|
3373
|
+
let s = e.state.tr.replace(r.pos, r.pos, new o(a, 0, 0));
|
|
3374
|
+
return s.setSelection(b.near(s.doc.resolve(r.pos + 1))), e.dispatch(s), !1;
|
|
3375
|
+
}
|
|
3376
|
+
function Jn(e) {
|
|
3377
|
+
if (!(e.selection instanceof G)) return null;
|
|
3378
|
+
let t = document.createElement("div");
|
|
3379
|
+
return t.className = "ProseMirror-gapcursor", S.create(e.doc, [y.widget(e.selection.head, t, { key: "gapcursor" })]);
|
|
3380
|
+
}
|
|
3381
|
+
//#endregion
|
|
3382
|
+
//#region ../../node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.js
|
|
3383
|
+
var q = 200, J = function() {};
|
|
3384
|
+
J.prototype.append = function(e) {
|
|
3385
|
+
return e.length ? (e = J.from(e), !this.length && e || e.length < q && this.leafAppend(e) || this.length < q && e.leafPrepend(this) || this.appendInner(e)) : this;
|
|
3386
|
+
}, J.prototype.prepend = function(e) {
|
|
3387
|
+
return e.length ? J.from(e).append(this) : this;
|
|
3388
|
+
}, J.prototype.appendInner = function(e) {
|
|
3389
|
+
return new Xn(this, e);
|
|
3390
|
+
}, J.prototype.slice = function(e, t) {
|
|
3391
|
+
return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ? J.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, t));
|
|
3392
|
+
}, J.prototype.get = function(e) {
|
|
3393
|
+
if (!(e < 0 || e >= this.length)) return this.getInner(e);
|
|
3394
|
+
}, J.prototype.forEach = function(e, t, n) {
|
|
3395
|
+
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);
|
|
3396
|
+
}, J.prototype.map = function(e, t, n) {
|
|
3397
|
+
t === void 0 && (t = 0), n === void 0 && (n = this.length);
|
|
3398
|
+
var r = [];
|
|
3399
|
+
return this.forEach(function(t, n) {
|
|
3400
|
+
return r.push(e(t, n));
|
|
3401
|
+
}, t, n), r;
|
|
3402
|
+
}, J.from = function(e) {
|
|
3403
|
+
return e instanceof J ? e : e && e.length ? new Yn(e) : J.empty;
|
|
3404
|
+
};
|
|
3405
|
+
var Yn = /* @__PURE__ */ function(e) {
|
|
3406
|
+
function t(t) {
|
|
3407
|
+
e.call(this), this.values = t;
|
|
3408
|
+
}
|
|
3409
|
+
e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t;
|
|
3410
|
+
var n = {
|
|
3411
|
+
length: { configurable: !0 },
|
|
3412
|
+
depth: { configurable: !0 }
|
|
3413
|
+
};
|
|
3414
|
+
return t.prototype.flatten = function() {
|
|
3415
|
+
return this.values;
|
|
3416
|
+
}, t.prototype.sliceInner = function(e, n) {
|
|
3417
|
+
return e == 0 && n == this.length ? this : new t(this.values.slice(e, n));
|
|
3418
|
+
}, t.prototype.getInner = function(e) {
|
|
3419
|
+
return this.values[e];
|
|
3420
|
+
}, t.prototype.forEachInner = function(e, t, n, r) {
|
|
3421
|
+
for (var i = t; i < n; i++) if (e(this.values[i], r + i) === !1) return !1;
|
|
3422
|
+
}, t.prototype.forEachInvertedInner = function(e, t, n, r) {
|
|
3423
|
+
for (var i = t - 1; i >= n; i--) if (e(this.values[i], r + i) === !1) return !1;
|
|
3424
|
+
}, t.prototype.leafAppend = function(e) {
|
|
3425
|
+
if (this.length + e.length <= q) return new t(this.values.concat(e.flatten()));
|
|
3426
|
+
}, t.prototype.leafPrepend = function(e) {
|
|
3427
|
+
if (this.length + e.length <= q) return new t(e.flatten().concat(this.values));
|
|
3428
|
+
}, n.length.get = function() {
|
|
3429
|
+
return this.values.length;
|
|
3430
|
+
}, n.depth.get = function() {
|
|
3431
|
+
return 0;
|
|
3432
|
+
}, Object.defineProperties(t.prototype, n), t;
|
|
3433
|
+
}(J);
|
|
3434
|
+
J.empty = new Yn([]);
|
|
3435
|
+
var Xn = /* @__PURE__ */ function(e) {
|
|
3436
|
+
function t(t, n) {
|
|
3437
|
+
e.call(this), this.left = t, this.right = n, this.length = t.length + n.length, this.depth = Math.max(t.depth, n.depth) + 1;
|
|
3438
|
+
}
|
|
3439
|
+
return e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t, t.prototype.flatten = function() {
|
|
3440
|
+
return this.left.flatten().concat(this.right.flatten());
|
|
3441
|
+
}, t.prototype.getInner = function(e) {
|
|
3442
|
+
return e < this.left.length ? this.left.get(e) : this.right.get(e - this.left.length);
|
|
3443
|
+
}, t.prototype.forEachInner = function(e, t, n, r) {
|
|
3444
|
+
var i = this.left.length;
|
|
3445
|
+
if (t < i && this.left.forEachInner(e, t, Math.min(n, i), r) === !1 || n > i && this.right.forEachInner(e, Math.max(t - i, 0), Math.min(this.length, n) - i, r + i) === !1) return !1;
|
|
3446
|
+
}, t.prototype.forEachInvertedInner = function(e, t, n, r) {
|
|
3447
|
+
var i = this.left.length;
|
|
3448
|
+
if (t > i && this.right.forEachInvertedInner(e, t - i, Math.max(n, i) - i, r + i) === !1 || n < i && this.left.forEachInvertedInner(e, Math.min(t, i), n, r) === !1) return !1;
|
|
3449
|
+
}, t.prototype.sliceInner = function(e, t) {
|
|
3450
|
+
if (e == 0 && t == this.length) return this;
|
|
3451
|
+
var n = this.left.length;
|
|
3452
|
+
return t <= n ? this.left.slice(e, t) : e >= n ? this.right.slice(e - n, t - n) : this.left.slice(e, n).append(this.right.slice(0, t - n));
|
|
3453
|
+
}, t.prototype.leafAppend = function(e) {
|
|
3454
|
+
var n = this.right.leafAppend(e);
|
|
3455
|
+
if (n) return new t(this.left, n);
|
|
3456
|
+
}, t.prototype.leafPrepend = function(e) {
|
|
3457
|
+
var n = this.left.leafPrepend(e);
|
|
3458
|
+
if (n) return new t(n, this.right);
|
|
3459
|
+
}, t.prototype.appendInner = function(e) {
|
|
3460
|
+
return this.left.depth >= Math.max(this.right.depth, e.depth) + 1 ? new t(this.left, new t(this.right, e)) : new t(this, e);
|
|
3461
|
+
}, t;
|
|
3462
|
+
}(J), Zn = 500, Y = class e {
|
|
3463
|
+
constructor(e, t) {
|
|
3464
|
+
this.items = e, this.eventCount = t;
|
|
3465
|
+
}
|
|
3466
|
+
popEvent(t, n) {
|
|
3467
|
+
if (this.eventCount == 0) return null;
|
|
3468
|
+
let r = this.items.length;
|
|
3469
|
+
for (;; r--) if (this.items.get(r - 1).selection) {
|
|
3470
|
+
--r;
|
|
3471
|
+
break;
|
|
3472
|
+
}
|
|
3473
|
+
let i, a;
|
|
3474
|
+
n && (i = this.remapping(r, this.items.length), a = i.maps.length);
|
|
3475
|
+
let o = t.tr, s, c, l = [], u = [];
|
|
3476
|
+
return this.items.forEach((t, n) => {
|
|
3477
|
+
if (!t.step) {
|
|
3478
|
+
i || (i = this.remapping(r, n + 1), a = i.maps.length), a--, u.push(t);
|
|
3479
|
+
return;
|
|
3480
|
+
}
|
|
3481
|
+
if (i) {
|
|
3482
|
+
u.push(new X(t.map));
|
|
3483
|
+
let e = t.step.map(i.slice(a)), n;
|
|
3484
|
+
e && o.maybeStep(e).doc && (n = o.mapping.maps[o.mapping.maps.length - 1], l.push(new X(n, void 0, void 0, l.length + u.length))), a--, n && i.appendMap(n, a);
|
|
3485
|
+
} else o.maybeStep(t.step);
|
|
3486
|
+
if (t.selection) return s = i ? t.selection.map(i.slice(a)) : t.selection, c = new e(this.items.slice(0, r).append(u.reverse().concat(l)), this.eventCount - 1), !1;
|
|
3487
|
+
}, this.items.length, 0), {
|
|
3488
|
+
remaining: c,
|
|
3489
|
+
transform: o,
|
|
3490
|
+
selection: s
|
|
3491
|
+
};
|
|
3492
|
+
}
|
|
3493
|
+
addTransform(t, n, r, i) {
|
|
3494
|
+
let a = [], o = this.eventCount, s = this.items, c = !i && s.length ? s.get(s.length - 1) : null;
|
|
3495
|
+
for (let e = 0; e < t.steps.length; e++) {
|
|
3496
|
+
let r = t.steps[e].invert(t.docs[e]), l = new X(t.mapping.maps[e], r, n), u;
|
|
3497
|
+
(u = c && c.merge(l)) && (l = u, e ? a.pop() : s = s.slice(0, s.length - 1)), a.push(l), n &&= (o++, void 0), i || (c = l);
|
|
3498
|
+
}
|
|
3499
|
+
let l = o - r.depth;
|
|
3500
|
+
return l > $n && (s = Qn(s, l), o -= l), new e(s.append(a), o);
|
|
3501
|
+
}
|
|
3502
|
+
remapping(e, t) {
|
|
3503
|
+
let n = new l();
|
|
3504
|
+
return this.items.forEach((t, r) => {
|
|
3505
|
+
let i = t.mirrorOffset != null && r - t.mirrorOffset >= e ? n.maps.length - t.mirrorOffset : void 0;
|
|
3506
|
+
n.appendMap(t.map, i);
|
|
3507
|
+
}, e, t), n;
|
|
3508
|
+
}
|
|
3509
|
+
addMaps(t) {
|
|
3510
|
+
return this.eventCount == 0 ? this : new e(this.items.append(t.map((e) => new X(e))), this.eventCount);
|
|
3511
|
+
}
|
|
3512
|
+
rebased(t, n) {
|
|
3513
|
+
if (!this.eventCount) return this;
|
|
3514
|
+
let r = [], i = Math.max(0, this.items.length - n), a = t.mapping, o = t.steps.length, s = this.eventCount;
|
|
3515
|
+
this.items.forEach((e) => {
|
|
3516
|
+
e.selection && s--;
|
|
3517
|
+
}, i);
|
|
3518
|
+
let c = n;
|
|
3519
|
+
this.items.forEach((e) => {
|
|
3520
|
+
let n = a.getMirror(--c);
|
|
3521
|
+
if (n == null) return;
|
|
3522
|
+
o = Math.min(o, n);
|
|
3523
|
+
let i = a.maps[n];
|
|
3524
|
+
if (e.step) {
|
|
3525
|
+
let o = t.steps[n].invert(t.docs[n]), l = e.selection && e.selection.map(a.slice(c + 1, n));
|
|
3526
|
+
l && s++, r.push(new X(i, o, l));
|
|
3527
|
+
} else r.push(new X(i));
|
|
3528
|
+
}, i);
|
|
3529
|
+
let l = [];
|
|
3530
|
+
for (let e = n; e < o; e++) l.push(new X(a.maps[e]));
|
|
3531
|
+
let u = new e(this.items.slice(0, i).append(l).append(r), s);
|
|
3532
|
+
return u.emptyItemCount() > Zn && (u = u.compress(this.items.length - r.length)), u;
|
|
3533
|
+
}
|
|
3534
|
+
emptyItemCount() {
|
|
3535
|
+
let e = 0;
|
|
3536
|
+
return this.items.forEach((t) => {
|
|
3537
|
+
t.step || e++;
|
|
3538
|
+
}), e;
|
|
3539
|
+
}
|
|
3540
|
+
compress(t = this.items.length) {
|
|
3541
|
+
let n = this.remapping(0, t), r = n.maps.length, i = [], a = 0;
|
|
3542
|
+
return this.items.forEach((e, o) => {
|
|
3543
|
+
if (o >= t) i.push(e), e.selection && a++;
|
|
3544
|
+
else if (e.step) {
|
|
3545
|
+
let t = e.step.map(n.slice(r)), o = t && t.getMap();
|
|
3546
|
+
if (r--, o && n.appendMap(o, r), t) {
|
|
3547
|
+
let s = e.selection && e.selection.map(n.slice(r));
|
|
3548
|
+
s && a++;
|
|
3549
|
+
let c = new X(o.invert(), t, s), l, u = i.length - 1;
|
|
3550
|
+
(l = i.length && i[u].merge(c)) ? i[u] = l : i.push(c);
|
|
3551
|
+
}
|
|
3552
|
+
} else e.map && r--;
|
|
3553
|
+
}, this.items.length, 0), new e(J.from(i.reverse()), a);
|
|
3554
|
+
}
|
|
3555
|
+
};
|
|
3556
|
+
Y.empty = new Y(J.empty, 0);
|
|
3557
|
+
function Qn(e, t) {
|
|
3558
|
+
let n;
|
|
3559
|
+
return e.forEach((e, r) => {
|
|
3560
|
+
if (e.selection && t-- == 0) return n = r, !1;
|
|
3561
|
+
}), e.slice(n);
|
|
3562
|
+
}
|
|
3563
|
+
var X = class e {
|
|
3564
|
+
constructor(e, t, n, r) {
|
|
3565
|
+
this.map = e, this.step = t, this.selection = n, this.mirrorOffset = r;
|
|
3566
|
+
}
|
|
3567
|
+
merge(t) {
|
|
3568
|
+
if (this.step && t.step && !t.selection) {
|
|
3569
|
+
let n = t.step.merge(this.step);
|
|
3570
|
+
if (n) return new e(n.getMap().invert(), n, this.selection);
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
}, Z = class {
|
|
3574
|
+
constructor(e, t, n, r, i) {
|
|
3575
|
+
this.done = e, this.undone = t, this.prevRanges = n, this.prevTime = r, this.prevComposition = i;
|
|
3576
|
+
}
|
|
3577
|
+
}, $n = 20;
|
|
3578
|
+
function er(e, t, n, r) {
|
|
3579
|
+
let i = n.getMeta(Q), a;
|
|
3580
|
+
if (i) return i.historyState;
|
|
3581
|
+
n.getMeta(cr) && (e = new Z(e.done, e.undone, null, 0, -1));
|
|
3582
|
+
let o = n.getMeta("appendedTransaction");
|
|
3583
|
+
if (n.steps.length == 0) return e;
|
|
3584
|
+
if (o && o.getMeta(Q)) return o.getMeta(Q).redo ? new Z(e.done.addTransform(n, void 0, r, sr(t)), e.undone, nr(n.mapping.maps), e.prevTime, e.prevComposition) : new Z(e.done, e.undone.addTransform(n, void 0, r, sr(t)), null, e.prevTime, e.prevComposition);
|
|
3585
|
+
if (n.getMeta("addToHistory") !== !1 && !(o && o.getMeta("addToHistory") === !1)) {
|
|
3586
|
+
let i = n.getMeta("composition"), a = e.prevTime == 0 || !o && e.prevComposition != i && (e.prevTime < (n.time || 0) - r.newGroupDelay || !tr(n, e.prevRanges)), s = o ? rr(e.prevRanges, n.mapping) : nr(n.mapping.maps);
|
|
3587
|
+
return new Z(e.done.addTransform(n, a ? t.selection.getBookmark() : void 0, r, sr(t)), Y.empty, s, n.time, i ?? e.prevComposition);
|
|
3588
|
+
} else if (a = n.getMeta("rebased")) return new Z(e.done.rebased(n, a), e.undone.rebased(n, a), rr(e.prevRanges, n.mapping), e.prevTime, e.prevComposition);
|
|
3589
|
+
else return new Z(e.done.addMaps(n.mapping.maps), e.undone.addMaps(n.mapping.maps), rr(e.prevRanges, n.mapping), e.prevTime, e.prevComposition);
|
|
3590
|
+
}
|
|
3591
|
+
function tr(e, t) {
|
|
3592
|
+
if (!t) return !1;
|
|
3593
|
+
if (!e.docChanged) return !0;
|
|
3594
|
+
let n = !1;
|
|
3595
|
+
return e.mapping.maps[0].forEach((e, r) => {
|
|
3596
|
+
for (let i = 0; i < t.length; i += 2) e <= t[i + 1] && r >= t[i] && (n = !0);
|
|
3597
|
+
}), n;
|
|
3598
|
+
}
|
|
3599
|
+
function nr(e) {
|
|
3600
|
+
let t = [];
|
|
3601
|
+
for (let n = e.length - 1; n >= 0 && t.length == 0; n--) e[n].forEach((e, n, r, i) => t.push(r, i));
|
|
3602
|
+
return t;
|
|
3603
|
+
}
|
|
3604
|
+
function rr(e, t) {
|
|
3605
|
+
if (!e) return null;
|
|
3606
|
+
let n = [];
|
|
3607
|
+
for (let r = 0; r < e.length; r += 2) {
|
|
3608
|
+
let i = t.map(e[r], 1), a = t.map(e[r + 1], -1);
|
|
3609
|
+
i <= a && n.push(i, a);
|
|
3610
|
+
}
|
|
3611
|
+
return n;
|
|
3612
|
+
}
|
|
3613
|
+
function ir(e, t, n) {
|
|
3614
|
+
let r = sr(t), i = Q.get(t).spec.config, a = (n ? e.undone : e.done).popEvent(t, r);
|
|
3615
|
+
if (!a) return null;
|
|
3616
|
+
let o = a.selection.resolve(a.transform.doc), s = (n ? e.done : e.undone).addTransform(a.transform, t.selection.getBookmark(), i, r), c = new Z(n ? s : a.remaining, n ? a.remaining : s, null, 0, -1);
|
|
3617
|
+
return a.transform.setSelection(o).setMeta(Q, {
|
|
3618
|
+
redo: n,
|
|
3619
|
+
historyState: c
|
|
3620
|
+
});
|
|
3621
|
+
}
|
|
3622
|
+
var ar = !1, or = null;
|
|
3623
|
+
function sr(e) {
|
|
3624
|
+
let t = e.plugins;
|
|
3625
|
+
if (or != t) {
|
|
3626
|
+
ar = !1, or = t;
|
|
3627
|
+
for (let e = 0; e < t.length; e++) if (t[e].spec.historyPreserveItems) {
|
|
3628
|
+
ar = !0;
|
|
3629
|
+
break;
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
return ar;
|
|
3633
|
+
}
|
|
3634
|
+
var Q = new c("history"), cr = new c("closeHistory");
|
|
3635
|
+
function lr(e = {}) {
|
|
3636
|
+
return e = {
|
|
3637
|
+
depth: e.depth || 100,
|
|
3638
|
+
newGroupDelay: e.newGroupDelay || 500
|
|
3639
|
+
}, new x({
|
|
3640
|
+
key: Q,
|
|
3641
|
+
state: {
|
|
3642
|
+
init() {
|
|
3643
|
+
return new Z(Y.empty, Y.empty, null, 0, -1);
|
|
3644
|
+
},
|
|
3645
|
+
apply(t, n, r) {
|
|
3646
|
+
return er(n, r, t, e);
|
|
3647
|
+
}
|
|
3648
|
+
},
|
|
3649
|
+
config: e,
|
|
3650
|
+
props: { handleDOMEvents: { beforeinput(e, t) {
|
|
3651
|
+
let n = t.inputType, r = n == "historyUndo" ? dr : n == "historyRedo" ? fr : null;
|
|
3652
|
+
return !r || !e.editable ? !1 : (t.preventDefault(), r(e.state, e.dispatch));
|
|
3653
|
+
} } }
|
|
3654
|
+
});
|
|
3655
|
+
}
|
|
3656
|
+
function ur(e, t) {
|
|
3657
|
+
return (n, r) => {
|
|
3658
|
+
let i = Q.getState(n);
|
|
3659
|
+
if (!i || (e ? i.undone : i.done).eventCount == 0) return !1;
|
|
3660
|
+
if (r) {
|
|
3661
|
+
let a = ir(i, n, e);
|
|
3662
|
+
a && r(t ? a.scrollIntoView() : a);
|
|
3663
|
+
}
|
|
3664
|
+
return !0;
|
|
3665
|
+
};
|
|
3666
|
+
}
|
|
3667
|
+
var dr = ur(!1, !0), fr = ur(!0, !0);
|
|
3668
|
+
g.create({
|
|
3669
|
+
name: "characterCount",
|
|
3670
|
+
addOptions() {
|
|
3671
|
+
return {
|
|
3672
|
+
limit: null,
|
|
3673
|
+
autoTrim: !0,
|
|
3674
|
+
mode: "textSize",
|
|
3675
|
+
textCounter: (e) => e.length,
|
|
3676
|
+
wordCounter: (e) => e.split(" ").filter((e) => e !== "").length
|
|
3677
|
+
};
|
|
3678
|
+
},
|
|
3679
|
+
addStorage() {
|
|
3680
|
+
return {
|
|
3681
|
+
characters: () => 0,
|
|
3682
|
+
words: () => 0
|
|
3683
|
+
};
|
|
3684
|
+
},
|
|
3685
|
+
onBeforeCreate() {
|
|
3686
|
+
this.storage.characters = (e) => {
|
|
3687
|
+
let t = e?.node || this.editor.state.doc;
|
|
3688
|
+
if ((e?.mode || this.options.mode) === "textSize") {
|
|
3689
|
+
let e = t.textBetween(0, t.content.size, void 0, " ");
|
|
3690
|
+
return this.options.textCounter(e);
|
|
3691
|
+
}
|
|
3692
|
+
return t.nodeSize;
|
|
3693
|
+
}, this.storage.words = (e) => {
|
|
3694
|
+
let t = e?.node || this.editor.state.doc, n = t.textBetween(0, t.content.size, " ", " ");
|
|
3695
|
+
return this.options.wordCounter(n);
|
|
3696
|
+
};
|
|
3697
|
+
},
|
|
3698
|
+
addProseMirrorPlugins() {
|
|
3699
|
+
let e = !1;
|
|
3700
|
+
return [new x({
|
|
3701
|
+
key: new c("characterCount"),
|
|
3702
|
+
appendTransaction: (t, n, r) => {
|
|
3703
|
+
if (e) return;
|
|
3704
|
+
let i = this.options.limit, a = this.options.autoTrim;
|
|
3705
|
+
if (i == null || i === 0 || a === !1) {
|
|
3706
|
+
e = !0;
|
|
3707
|
+
return;
|
|
3708
|
+
}
|
|
3709
|
+
let o = this.storage.characters({ node: r.doc });
|
|
3710
|
+
if (o > i) {
|
|
3711
|
+
let t = o - i;
|
|
3712
|
+
console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);
|
|
3713
|
+
let n = r.tr.deleteRange(0, t);
|
|
3714
|
+
return e = !0, n;
|
|
3715
|
+
}
|
|
3716
|
+
e = !0;
|
|
3717
|
+
},
|
|
3718
|
+
filterTransaction: (e, t) => {
|
|
3719
|
+
let n = this.options.limit;
|
|
3720
|
+
if (!e.docChanged || n === 0 || n == null) return !0;
|
|
3721
|
+
let r = this.storage.characters({ node: t.doc }), i = this.storage.characters({ node: e.doc });
|
|
3722
|
+
if (i <= n || r > n && i > n && i <= r) return !0;
|
|
3723
|
+
if (r > n && i > n && i > r || !e.getMeta("paste")) return !1;
|
|
3724
|
+
let a = e.selection.$head.pos, o = a - (i - n), s = a;
|
|
3725
|
+
return e.deleteRange(o, s), !(this.storage.characters({ node: e.doc }) > n);
|
|
3726
|
+
}
|
|
3727
|
+
})];
|
|
3728
|
+
}
|
|
3729
|
+
});
|
|
3730
|
+
var pr = g.create({
|
|
3731
|
+
name: "dropCursor",
|
|
3732
|
+
addOptions() {
|
|
3733
|
+
return {
|
|
3734
|
+
color: "currentColor",
|
|
3735
|
+
width: 1,
|
|
3736
|
+
class: void 0
|
|
3737
|
+
};
|
|
3738
|
+
},
|
|
3739
|
+
addProseMirrorPlugins() {
|
|
3740
|
+
return [Rn(this.options)];
|
|
3741
|
+
}
|
|
3742
|
+
});
|
|
3743
|
+
g.create({
|
|
3744
|
+
name: "focus",
|
|
3745
|
+
addOptions() {
|
|
3746
|
+
return {
|
|
3747
|
+
className: "has-focus",
|
|
3748
|
+
mode: "all"
|
|
3749
|
+
};
|
|
3750
|
+
},
|
|
3751
|
+
addProseMirrorPlugins() {
|
|
3752
|
+
return [new x({
|
|
3753
|
+
key: new c("focus"),
|
|
3754
|
+
props: { decorations: ({ doc: e, selection: t }) => {
|
|
3755
|
+
let { isEditable: n, isFocused: r } = this.editor, { anchor: i } = t, a = [];
|
|
3756
|
+
if (!n || !r) return S.create(e, []);
|
|
3757
|
+
let o = 0;
|
|
3758
|
+
this.options.mode === "deepest" && e.descendants((e, t) => {
|
|
3759
|
+
if (!e.isText) {
|
|
3760
|
+
if (!(i >= t && i <= t + e.nodeSize - 1)) return !1;
|
|
3761
|
+
o += 1;
|
|
3762
|
+
}
|
|
3763
|
+
});
|
|
3764
|
+
let s = 0;
|
|
3765
|
+
return e.descendants((e, t) => {
|
|
3766
|
+
if (e.isText || !(i >= t && i <= t + e.nodeSize - 1)) return !1;
|
|
3767
|
+
if (s += 1, this.options.mode === "deepest" && o - s > 0 || this.options.mode === "shallowest" && s > 1) return this.options.mode === "deepest";
|
|
3768
|
+
a.push(y.node(t, t + e.nodeSize, { class: this.options.className }));
|
|
3769
|
+
}), S.create(e, a);
|
|
3770
|
+
} }
|
|
3771
|
+
})];
|
|
3772
|
+
}
|
|
3773
|
+
});
|
|
3774
|
+
var mr = g.create({
|
|
3775
|
+
name: "gapCursor",
|
|
3776
|
+
addProseMirrorPlugins() {
|
|
3777
|
+
return [Wn()];
|
|
3778
|
+
},
|
|
3779
|
+
extendNodeSchema(e) {
|
|
3780
|
+
return { allowGapCursor: le(p(e, "allowGapCursor", {
|
|
3781
|
+
name: e.name,
|
|
3782
|
+
options: e.options,
|
|
3783
|
+
storage: e.storage
|
|
3784
|
+
})) ?? null };
|
|
3785
|
+
}
|
|
3786
|
+
}), hr = "placeholder", $ = new c("tiptap__placeholder"), gr = 200;
|
|
3787
|
+
function _r(e) {
|
|
3788
|
+
let { editor: t, placeholder: n, dataAttribute: r, pos: i, node: a, isEmptyDoc: o, hasAnchor: s, classes: { emptyNode: c, emptyEditor: l } } = e, u = [c];
|
|
3789
|
+
return o && u.push(l), y.node(i, i + a.nodeSize, {
|
|
3790
|
+
class: u.join(" "),
|
|
3791
|
+
[r]: typeof n == "function" ? n({
|
|
3792
|
+
editor: t,
|
|
3793
|
+
node: a,
|
|
3794
|
+
pos: i,
|
|
3795
|
+
hasAnchor: s
|
|
3796
|
+
}) : n
|
|
3797
|
+
});
|
|
3798
|
+
}
|
|
3799
|
+
function vr(e, t) {
|
|
3800
|
+
return typeof e == "function" ? e(t) : e;
|
|
3801
|
+
}
|
|
3802
|
+
function yr({ editor: e, options: t, dataAttribute: n, doc: r, selection: i }) {
|
|
3803
|
+
if (!(e.isEditable || !t.showOnlyWhenEditable)) return null;
|
|
3804
|
+
let { anchor: o } = i, s = [], c = e.isEmpty;
|
|
3805
|
+
if (t.showOnlyCurrent && !t.includeChildren) {
|
|
3806
|
+
let i = r.resolve(o), l = i.depth > 0 ? i.node(1) : i.nodeAfter, u = i.depth > 0 ? i.before(1) : o;
|
|
3807
|
+
if (l && l.type.isTextblock && a(l)) {
|
|
3808
|
+
let r = o >= u && o <= u + l.nodeSize;
|
|
3809
|
+
s.push(_r({
|
|
3810
|
+
editor: e,
|
|
3811
|
+
isEmptyDoc: c,
|
|
3812
|
+
dataAttribute: n,
|
|
3813
|
+
hasAnchor: r,
|
|
3814
|
+
placeholder: t.placeholder,
|
|
3815
|
+
classes: {
|
|
3816
|
+
emptyEditor: t.emptyEditorClass,
|
|
3817
|
+
emptyNode: vr(t.emptyNodeClass, {
|
|
3818
|
+
editor: e,
|
|
3819
|
+
node: l,
|
|
3820
|
+
pos: u,
|
|
3821
|
+
hasAnchor: r
|
|
3822
|
+
})
|
|
3823
|
+
},
|
|
3824
|
+
node: l,
|
|
3825
|
+
pos: u
|
|
3826
|
+
}));
|
|
3827
|
+
}
|
|
3828
|
+
} else {
|
|
3829
|
+
let i = $.getState(e.state), l = i?.topPos ?? 0, u = i?.bottomPos ?? r.content.size;
|
|
3830
|
+
r.nodesBetween(l, u, (r, i) => {
|
|
3831
|
+
let l = o >= i && o <= i + r.nodeSize, u = !r.isLeaf && a(r);
|
|
3832
|
+
return r.type.isTextblock && (l || !t.showOnlyCurrent) && u && s.push(_r({
|
|
3833
|
+
editor: e,
|
|
3834
|
+
isEmptyDoc: c,
|
|
3835
|
+
dataAttribute: n,
|
|
3836
|
+
hasAnchor: l,
|
|
3837
|
+
placeholder: t.placeholder,
|
|
3838
|
+
classes: {
|
|
3839
|
+
emptyEditor: t.emptyEditorClass,
|
|
3840
|
+
emptyNode: vr(t.emptyNodeClass, {
|
|
3841
|
+
editor: e,
|
|
3842
|
+
node: r,
|
|
3843
|
+
pos: i,
|
|
3844
|
+
hasAnchor: l
|
|
3845
|
+
})
|
|
3846
|
+
},
|
|
3847
|
+
node: r,
|
|
3848
|
+
pos: i
|
|
3849
|
+
})), t.includeChildren;
|
|
3850
|
+
});
|
|
3851
|
+
}
|
|
3852
|
+
return S.create(r, s);
|
|
3853
|
+
}
|
|
3854
|
+
function br(e) {
|
|
3855
|
+
return e.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
|
|
3856
|
+
}
|
|
3857
|
+
function xr(e) {
|
|
3858
|
+
let t = getComputedStyle(e), n = `${t.overflow} ${t.overflowY} ${t.overflowX}`;
|
|
3859
|
+
return /auto|scroll|overlay/.test(n);
|
|
3860
|
+
}
|
|
3861
|
+
function Sr(e) {
|
|
3862
|
+
let t = e;
|
|
3863
|
+
for (; t;) {
|
|
3864
|
+
if (xr(t)) return t;
|
|
3865
|
+
let e = t.parentElement;
|
|
3866
|
+
if (!e) {
|
|
3867
|
+
let e = t.getRootNode();
|
|
3868
|
+
if (e instanceof ShadowRoot) {
|
|
3869
|
+
t = e.host;
|
|
3870
|
+
continue;
|
|
3871
|
+
}
|
|
3872
|
+
return window;
|
|
3873
|
+
}
|
|
3874
|
+
t = e;
|
|
3875
|
+
}
|
|
3876
|
+
return window;
|
|
3877
|
+
}
|
|
3878
|
+
function Cr(e) {
|
|
3879
|
+
return e === window ? {
|
|
3880
|
+
top: 0,
|
|
3881
|
+
bottom: window.innerHeight
|
|
3882
|
+
} : e.getBoundingClientRect();
|
|
3883
|
+
}
|
|
3884
|
+
function wr({ doc: e, view: t, scrollContainer: n }) {
|
|
3885
|
+
let r = t.dom.getBoundingClientRect(), i = n ? Cr(n) : {
|
|
3886
|
+
top: 0,
|
|
3887
|
+
bottom: window.innerHeight
|
|
3888
|
+
}, a = Math.max(r.top, i.top) - gr, o = Math.min(r.bottom, i.bottom) + gr;
|
|
3889
|
+
if (a >= o) return {
|
|
3890
|
+
top: 0,
|
|
3891
|
+
bottom: e.content.size
|
|
3892
|
+
};
|
|
3893
|
+
let s = getComputedStyle(t.dom).direction === "rtl" ? Math.max(r.right - 2, r.left + 2) : r.left + 2, c = t.posAtCoords({
|
|
3894
|
+
left: s,
|
|
3895
|
+
top: a + 2
|
|
3896
|
+
}), l = t.posAtCoords({
|
|
3897
|
+
left: s,
|
|
3898
|
+
top: o - 2
|
|
3899
|
+
});
|
|
3900
|
+
return {
|
|
3901
|
+
top: c ? c.pos : 0,
|
|
3902
|
+
bottom: l ? l.pos : e.content.size
|
|
3903
|
+
};
|
|
3904
|
+
}
|
|
3905
|
+
var Tr = {
|
|
3906
|
+
init() {
|
|
3907
|
+
return {
|
|
3908
|
+
topPos: null,
|
|
3909
|
+
bottomPos: null
|
|
3910
|
+
};
|
|
3911
|
+
},
|
|
3912
|
+
apply(e, t) {
|
|
3913
|
+
let n = e.getMeta($);
|
|
3914
|
+
return n?.positions ? {
|
|
3915
|
+
topPos: n.positions.top,
|
|
3916
|
+
bottomPos: n.positions.bottom
|
|
3917
|
+
} : e.docChanged ? {
|
|
3918
|
+
topPos: t.topPos === null ? null : e.mapping.map(t.topPos),
|
|
3919
|
+
bottomPos: t.bottomPos === null ? null : e.mapping.map(t.bottomPos)
|
|
3920
|
+
} : t;
|
|
3921
|
+
}
|
|
3922
|
+
};
|
|
3923
|
+
function Er(e) {
|
|
3924
|
+
let t = Sr(e.dom), n = () => {
|
|
3925
|
+
let n = wr({
|
|
3926
|
+
view: e,
|
|
3927
|
+
doc: e.state.doc,
|
|
3928
|
+
scrollContainer: t
|
|
3929
|
+
}), r = $.getState(e.state);
|
|
3930
|
+
if (r?.topPos === n.top && r?.bottomPos === n.bottom) return;
|
|
3931
|
+
let i = e.state.tr.setMeta($, { positions: n });
|
|
3932
|
+
e.dispatch(i);
|
|
3933
|
+
}, r = null, i = 0, a = () => {
|
|
3934
|
+
r === null && (r = requestAnimationFrame(() => {
|
|
3935
|
+
r = null;
|
|
3936
|
+
let e = performance.now();
|
|
3937
|
+
e - i >= 150 ? (i = e, n()) : a();
|
|
3938
|
+
}));
|
|
3939
|
+
};
|
|
3940
|
+
return t.addEventListener("scroll", a, { passive: !0 }), n(), {
|
|
3941
|
+
update(t, n) {
|
|
3942
|
+
e.state.doc.content.size !== n.doc.content.size && a();
|
|
3943
|
+
},
|
|
3944
|
+
destroy: () => {
|
|
3945
|
+
r !== null && cancelAnimationFrame(r), t.removeEventListener("scroll", a);
|
|
3946
|
+
}
|
|
3947
|
+
};
|
|
3948
|
+
}
|
|
3949
|
+
function Dr({ editor: e, options: t }) {
|
|
3950
|
+
let n = t.dataAttribute ? `data-${br(t.dataAttribute)}` : `data-${hr}`;
|
|
3951
|
+
return new x({
|
|
3952
|
+
key: $,
|
|
3953
|
+
state: Tr,
|
|
3954
|
+
view: Er,
|
|
3955
|
+
props: { decorations: ({ doc: r, selection: i }) => yr({
|
|
3956
|
+
editor: e,
|
|
3957
|
+
options: t,
|
|
3958
|
+
dataAttribute: n,
|
|
3959
|
+
doc: r,
|
|
3960
|
+
selection: i
|
|
3961
|
+
}) }
|
|
3962
|
+
});
|
|
3963
|
+
}
|
|
3964
|
+
g.create({
|
|
3965
|
+
name: "placeholder",
|
|
3966
|
+
addOptions() {
|
|
3967
|
+
return {
|
|
3968
|
+
emptyEditorClass: "is-editor-empty",
|
|
3969
|
+
emptyNodeClass: "is-empty",
|
|
3970
|
+
dataAttribute: hr,
|
|
3971
|
+
placeholder: "Write something …",
|
|
3972
|
+
showOnlyWhenEditable: !0,
|
|
3973
|
+
showOnlyCurrent: !0,
|
|
3974
|
+
includeChildren: !1
|
|
3975
|
+
};
|
|
3976
|
+
},
|
|
3977
|
+
addProseMirrorPlugins() {
|
|
3978
|
+
return [Dr({
|
|
3979
|
+
editor: this.editor,
|
|
3980
|
+
options: this.options
|
|
3981
|
+
})];
|
|
3982
|
+
}
|
|
3983
|
+
});
|
|
3984
|
+
var Or = ".ProseMirror:not(.ProseMirror-focused) *::selection {\n background: transparent;\n}\n\n.ProseMirror:not(.ProseMirror-focused) *::-moz-selection {\n background: transparent;\n}";
|
|
3985
|
+
g.create({
|
|
3986
|
+
name: "selection",
|
|
3987
|
+
addOptions() {
|
|
3988
|
+
return { className: "selection" };
|
|
3989
|
+
},
|
|
3990
|
+
addProseMirrorPlugins() {
|
|
3991
|
+
let { editor: e, options: t } = this;
|
|
3992
|
+
return e.options.injectCSS && typeof document < "u" && ae(Or, e.options.injectNonce, "selection"), [new x({
|
|
3993
|
+
key: new c("selection"),
|
|
3994
|
+
props: { decorations(n) {
|
|
3995
|
+
return n.selection.empty || e.isFocused || !e.isEditable || s(n.selection) || e.view.dragging ? null : S.create(n.doc, [y.inline(n.selection.from, n.selection.to, { class: t.className })]);
|
|
3996
|
+
} }
|
|
3997
|
+
})];
|
|
3998
|
+
}
|
|
3999
|
+
});
|
|
4000
|
+
function kr({ types: e, node: t }) {
|
|
4001
|
+
return t && Array.isArray(e) && e.includes(t.type) || t?.type === e;
|
|
4002
|
+
}
|
|
4003
|
+
var Ar = g.create({
|
|
4004
|
+
name: "trailingNode",
|
|
4005
|
+
addOptions() {
|
|
4006
|
+
return {
|
|
4007
|
+
node: void 0,
|
|
4008
|
+
notAfter: []
|
|
4009
|
+
};
|
|
4010
|
+
},
|
|
4011
|
+
addProseMirrorPlugins() {
|
|
4012
|
+
let e = new c(this.name), t = this.options.node || this.editor.schema.topNodeType.contentMatch.defaultType?.name || "paragraph", n = Object.entries(this.editor.schema.nodes).map(([, e]) => e).filter((e) => (this.options.notAfter || []).concat(t).includes(e.name));
|
|
4013
|
+
return [new x({
|
|
4014
|
+
key: e,
|
|
4015
|
+
appendTransaction: (n, r, i) => {
|
|
4016
|
+
let { doc: a, tr: o, schema: s } = i, c = e.getState(i), l = a.content.size, u = s.nodes[t];
|
|
4017
|
+
if (!n.some((e) => e.getMeta("skipTrailingNode")) && c) return o.insert(l, u.create());
|
|
4018
|
+
},
|
|
4019
|
+
state: {
|
|
4020
|
+
init: (e, t) => {
|
|
4021
|
+
let r = t.tr.doc.lastChild;
|
|
4022
|
+
return !kr({
|
|
4023
|
+
node: r,
|
|
4024
|
+
types: n
|
|
4025
|
+
});
|
|
4026
|
+
},
|
|
4027
|
+
apply: (e, t) => {
|
|
4028
|
+
if (!e.docChanged || e.getMeta("__uniqueIDTransaction")) return t;
|
|
4029
|
+
let r = e.doc.lastChild;
|
|
4030
|
+
return !kr({
|
|
4031
|
+
node: r,
|
|
4032
|
+
types: n
|
|
4033
|
+
});
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4036
|
+
})];
|
|
4037
|
+
}
|
|
4038
|
+
}), jr = g.create({
|
|
4039
|
+
name: "undoRedo",
|
|
4040
|
+
addOptions() {
|
|
4041
|
+
return {
|
|
4042
|
+
depth: 100,
|
|
4043
|
+
newGroupDelay: 500
|
|
4044
|
+
};
|
|
4045
|
+
},
|
|
4046
|
+
addCommands() {
|
|
4047
|
+
return {
|
|
4048
|
+
undo: () => ({ state: e, dispatch: t }) => dr(e, t),
|
|
4049
|
+
redo: () => ({ state: e, dispatch: t }) => fr(e, t)
|
|
4050
|
+
};
|
|
4051
|
+
},
|
|
4052
|
+
addProseMirrorPlugins() {
|
|
4053
|
+
return [lr(this.options)];
|
|
4054
|
+
},
|
|
4055
|
+
addKeyboardShortcuts() {
|
|
4056
|
+
return {
|
|
4057
|
+
"Mod-z": () => this.editor.commands.undo(),
|
|
4058
|
+
"Shift-Mod-z": () => this.editor.commands.redo(),
|
|
4059
|
+
"Mod-y": () => this.editor.commands.redo(),
|
|
4060
|
+
"Mod-я": () => this.editor.commands.undo(),
|
|
4061
|
+
"Shift-Mod-я": () => this.editor.commands.redo()
|
|
4062
|
+
};
|
|
4063
|
+
}
|
|
4064
|
+
}), Mr = g.create({
|
|
4065
|
+
name: "starterKit",
|
|
4066
|
+
addExtensions() {
|
|
4067
|
+
let e = [];
|
|
4068
|
+
return this.options.bold !== !1 && e.push(jt.configure(this.options.bold)), this.options.blockquote !== !1 && e.push(Et.configure(this.options.blockquote)), this.options.bulletList !== !1 && e.push($t.configure(this.options.bulletList)), this.options.code !== !1 && e.push(Pt.configure(this.options.code)), this.options.codeBlock !== !1 && e.push(Rt.configure(this.options.codeBlock)), this.options.document !== !1 && e.push(zt.configure(this.options.document)), this.options.dropcursor !== !1 && e.push(pr.configure(this.options.dropcursor)), this.options.gapcursor !== !1 && e.push(mr.configure(this.options.gapcursor)), this.options.hardBreak !== !1 && e.push(Bt.configure(this.options.hardBreak)), this.options.heading !== !1 && e.push(Vt.configure(this.options.heading)), this.options.undoRedo !== !1 && e.push(jr.configure(this.options.undoRedo)), this.options.horizontalRule !== !1 && e.push(Ht.configure(this.options.horizontalRule)), this.options.italic !== !1 && e.push(qt.configure(this.options.italic)), this.options.listItem !== !1 && e.push(sn.configure(this.options.listItem)), this.options.listKeymap !== !1 && e.push(_n.configure(this.options?.listKeymap)), this.options.link !== !1 && e.push(fe.configure(this.options?.link)), this.options.orderedList !== !1 && e.push(On.configure(this.options.orderedList)), this.options.paragraph !== !1 && e.push(Nn.configure(this.options.paragraph)), this.options.strike !== !1 && e.push(In.configure(this.options.strike)), this.options.text !== !1 && e.push(Ln.configure(this.options.text)), this.options.underline !== !1 && e.push(pe.configure(this.options?.underline)), this.options.trailingNode !== !1 && e.push(Ar.configure(this.options?.trailingNode)), e;
|
|
4069
|
+
}
|
|
4070
|
+
}), Nr = Mr;
|
|
4071
|
+
//#endregion
|
|
4072
|
+
export { Mr as StarterKit, Nr as default };
|