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