@milkdown/preset-commonmark 6.5.4 → 7.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/composed/commands.d.ts +3 -0
- package/lib/composed/commands.d.ts.map +1 -0
- package/lib/composed/index.d.ts +6 -0
- package/lib/composed/index.d.ts.map +1 -0
- package/lib/composed/inputrules.d.ts +3 -0
- package/lib/composed/inputrules.d.ts.map +1 -0
- package/lib/composed/keymap.d.ts +3 -0
- package/lib/composed/keymap.d.ts.map +1 -0
- package/lib/composed/plugins.d.ts +2 -0
- package/lib/composed/plugins.d.ts.map +1 -0
- package/lib/composed/schema.d.ts +3 -0
- package/lib/composed/schema.d.ts.map +1 -0
- package/lib/index.d.ts +4 -29
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +1101 -1386
- package/lib/index.es.js.map +1 -1
- package/lib/mark/emphasis.d.ts +5 -0
- package/lib/mark/emphasis.d.ts.map +1 -0
- package/lib/mark/index.d.ts +3 -4
- package/lib/mark/index.d.ts.map +1 -1
- package/lib/mark/inline-code.d.ts +5 -0
- package/lib/mark/inline-code.d.ts.map +1 -0
- package/lib/mark/link.d.ts +8 -10
- package/lib/mark/link.d.ts.map +1 -1
- package/lib/mark/strong.d.ts +4 -2
- package/lib/mark/strong.d.ts.map +1 -1
- package/lib/node/blockquote.d.ts +6 -2
- package/lib/node/blockquote.d.ts.map +1 -1
- package/lib/node/bullet-list.d.ts +5 -2
- package/lib/node/bullet-list.d.ts.map +1 -1
- package/lib/node/code-block.d.ts +10 -0
- package/lib/node/code-block.d.ts.map +1 -0
- package/lib/node/doc.d.ts +1 -1
- package/lib/node/doc.d.ts.map +1 -1
- package/lib/node/hardbreak.d.ts +4 -6
- package/lib/node/hardbreak.d.ts.map +1 -1
- package/lib/node/heading.d.ts +7 -12
- package/lib/node/heading.d.ts.map +1 -1
- package/lib/node/hr.d.ts +4 -2
- package/lib/node/hr.d.ts.map +1 -1
- package/lib/node/image.d.ts +10 -11
- package/lib/node/image.d.ts.map +1 -1
- package/lib/node/index.d.ts +6 -8
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/list-item.d.ts +6 -7
- package/lib/node/list-item.d.ts.map +1 -1
- package/lib/node/ordered-list.d.ts +5 -2
- package/lib/node/ordered-list.d.ts.map +1 -1
- package/lib/node/paragraph.d.ts +4 -2
- package/lib/node/paragraph.d.ts.map +1 -1
- package/lib/node/text.d.ts +1 -1
- package/lib/node/text.d.ts.map +1 -1
- package/lib/plugin/hardbreak-clear-mark-plugin.d.ts +2 -0
- package/lib/plugin/hardbreak-clear-mark-plugin.d.ts.map +1 -0
- package/lib/plugin/hardbreak-filter-plugin.d.ts +3 -0
- package/lib/plugin/hardbreak-filter-plugin.d.ts.map +1 -0
- package/lib/plugin/index.d.ts +9 -3
- package/lib/plugin/index.d.ts.map +1 -1
- package/lib/plugin/{inline-nodes-cursor.d.ts → inline-nodes-cursor-plugin.d.ts} +2 -3
- package/lib/plugin/inline-nodes-cursor-plugin.d.ts.map +1 -0
- package/lib/plugin/{inline-sync → inline-sync-plugin}/config.d.ts +2 -2
- package/lib/plugin/inline-sync-plugin/config.d.ts.map +1 -0
- package/lib/plugin/{inline-sync → inline-sync-plugin}/context.d.ts +1 -2
- package/lib/plugin/inline-sync-plugin/context.d.ts.map +1 -0
- package/lib/plugin/inline-sync-plugin/index.d.ts +3 -0
- package/lib/plugin/inline-sync-plugin/index.d.ts.map +1 -0
- package/lib/plugin/inline-sync-plugin/inline-sync-plugin.d.ts +2 -0
- package/lib/plugin/inline-sync-plugin/inline-sync-plugin.d.ts.map +1 -0
- package/lib/plugin/{inline-sync → inline-sync-plugin}/regexp.d.ts +0 -0
- package/lib/plugin/inline-sync-plugin/regexp.d.ts.map +1 -0
- package/lib/plugin/{inline-sync → inline-sync-plugin}/replacer.d.ts +1 -1
- package/lib/plugin/inline-sync-plugin/replacer.d.ts.map +1 -0
- package/lib/plugin/{inline-sync → inline-sync-plugin}/utils.d.ts +0 -0
- package/lib/plugin/inline-sync-plugin/utils.d.ts.map +1 -0
- package/lib/plugin/remark-add-order-in-list-plugin.d.ts +2 -0
- package/lib/plugin/remark-add-order-in-list-plugin.d.ts.map +1 -0
- package/lib/plugin/remark-inline-link-plugin.d.ts +2 -0
- package/lib/plugin/remark-inline-link-plugin.d.ts.map +1 -0
- package/lib/plugin/remark-line-break.d.ts +2 -0
- package/lib/plugin/remark-line-break.d.ts.map +1 -0
- package/lib/plugin/sync-heading-id-plugin.d.ts +2 -0
- package/lib/plugin/sync-heading-id-plugin.d.ts.map +1 -0
- package/lib/plugin/sync-list-order-plugin.d.ts +2 -0
- package/lib/plugin/sync-list-order-plugin.d.ts.map +1 -0
- package/package.json +9 -7
- package/src/composed/commands.ts +30 -0
- package/src/composed/index.ts +6 -0
- package/src/composed/inputrules.ts +12 -0
- package/src/composed/keymap.ts +19 -0
- package/src/composed/plugins.ts +21 -0
- package/src/composed/schema.ts +54 -0
- package/src/index.ts +5 -52
- package/src/mark/emphasis.ts +42 -0
- package/src/mark/index.ts +3 -10
- package/src/mark/inline-code.ts +64 -0
- package/src/mark/link.ts +87 -247
- package/src/mark/strong.ts +35 -36
- package/src/node/blockquote.ts +32 -33
- package/src/node/bullet-list.ts +56 -56
- package/src/node/code-block.ts +93 -0
- package/src/node/doc.ts +17 -22
- package/src/node/hardbreak.ts +60 -117
- package/src/node/heading.ts +158 -281
- package/src/node/hr.ts +51 -57
- package/src/node/image.ts +102 -209
- package/src/node/index.ts +6 -35
- package/src/node/list-item.ts +81 -142
- package/src/node/ordered-list.ts +64 -65
- package/src/node/paragraph.ts +48 -50
- package/src/node/text.ts +13 -16
- package/src/plugin/hardbreak-clear-mark-plugin.ts +44 -0
- package/src/plugin/hardbreak-filter-plugin.ts +31 -0
- package/src/plugin/index.ts +12 -14
- package/src/plugin/{inline-nodes-cursor.ts → inline-nodes-cursor-plugin.ts} +4 -4
- package/src/plugin/{inline-sync → inline-sync-plugin}/config.ts +4 -3
- package/src/plugin/{inline-sync → inline-sync-plugin}/context.ts +4 -6
- package/src/plugin/inline-sync-plugin/index.ts +4 -0
- package/src/plugin/{inline-sync/index.ts → inline-sync-plugin/inline-sync-plugin.ts} +9 -11
- package/src/plugin/{inline-sync → inline-sync-plugin}/regexp.ts +0 -0
- package/src/plugin/{inline-sync → inline-sync-plugin}/replacer.ts +3 -3
- package/src/plugin/{inline-sync → inline-sync-plugin}/utils.ts +0 -0
- package/src/plugin/remark-add-order-in-list-plugin.ts +15 -0
- package/src/plugin/remark-inline-link-plugin.ts +5 -0
- package/src/plugin/remark-line-break.ts +41 -0
- package/src/plugin/sync-heading-id-plugin.ts +53 -0
- package/src/plugin/sync-list-order-plugin.ts +57 -0
- package/lib/mark/code-inline.d.ts +0 -3
- package/lib/mark/code-inline.d.ts.map +0 -1
- package/lib/mark/em.d.ts +0 -3
- package/lib/mark/em.d.ts.map +0 -1
- package/lib/node/code-fence.d.ts +0 -7
- package/lib/node/code-fence.d.ts.map +0 -1
- package/lib/plugin/add-order-in-list.d.ts +0 -3
- package/lib/plugin/add-order-in-list.d.ts.map +0 -1
- package/lib/plugin/filter-html.d.ts +0 -3
- package/lib/plugin/filter-html.d.ts.map +0 -1
- package/lib/plugin/inline-nodes-cursor.d.ts.map +0 -1
- package/lib/plugin/inline-sync/config.d.ts.map +0 -1
- package/lib/plugin/inline-sync/context.d.ts.map +0 -1
- package/lib/plugin/inline-sync/index.d.ts +0 -6
- package/lib/plugin/inline-sync/index.d.ts.map +0 -1
- package/lib/plugin/inline-sync/regexp.d.ts.map +0 -1
- package/lib/plugin/inline-sync/replacer.d.ts.map +0 -1
- package/lib/plugin/inline-sync/utils.d.ts.map +0 -1
- package/lib/supported-keys.d.ts +0 -23
- package/lib/supported-keys.d.ts.map +0 -1
- package/src/mark/code-inline.ts +0 -66
- package/src/mark/em.ts +0 -42
- package/src/node/code-fence.ts +0 -245
- package/src/plugin/add-order-in-list.ts +0 -19
- package/src/plugin/filter-html.ts +0 -43
- package/src/supported-keys.ts +0 -25
- package/src/types.d.ts +0 -5
package/lib/index.es.js
CHANGED
|
@@ -1,1486 +1,1201 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { toggleMark as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
H1: "H1",
|
|
21
|
-
H2: "H2",
|
|
22
|
-
H3: "H3",
|
|
23
|
-
H4: "H4",
|
|
24
|
-
H5: "H5",
|
|
25
|
-
H6: "H6",
|
|
26
|
-
DowngradeHeading: "DowngradeHeading",
|
|
27
|
-
Text: "Text",
|
|
28
|
-
CodeInline: "CodeInline",
|
|
29
|
-
Em: "Em",
|
|
30
|
-
Bold: "Bold",
|
|
31
|
-
NextListItem: "NextListItem",
|
|
32
|
-
SinkListItem: "SinkListItem",
|
|
33
|
-
LiftListItem: "LiftListItem"
|
|
34
|
-
}, ke = "code_inline", ee = I("ToggleInlineCode"), Ye = q((a) => ({
|
|
35
|
-
id: ke,
|
|
36
|
-
schema: () => ({
|
|
37
|
-
priority: 100,
|
|
38
|
-
code: !0,
|
|
39
|
-
inclusive: !1,
|
|
40
|
-
parseDOM: [{ tag: "code" }],
|
|
41
|
-
toDOM: (e) => ["code", { class: a.getClassName(e.attrs, "code-inline") }],
|
|
42
|
-
parseMarkdown: {
|
|
43
|
-
match: (e) => e.type === "inlineCode",
|
|
44
|
-
runner: (e, t, r) => {
|
|
45
|
-
e.openMark(r), e.addText(t.value), e.closeMark(r);
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
toMarkdown: {
|
|
49
|
-
match: (e) => e.type.name === ke,
|
|
50
|
-
runner: (e, t, r) => {
|
|
51
|
-
e.withMark(t, "inlineCode", r.text || "");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}),
|
|
55
|
-
commands: (e) => [
|
|
56
|
-
N(ee, () => (t, r) => {
|
|
57
|
-
const { selection: n, tr: o } = t;
|
|
58
|
-
if (n.empty)
|
|
59
|
-
return !1;
|
|
60
|
-
const { from: l, to: s } = n;
|
|
61
|
-
return t.doc.rangeHasMark(l, s, e) ? (r == null || r(o.removeMark(l, s, e)), !0) : (Object.keys(t.schema.marks).filter((u) => u !== e.name).map((u) => t.schema.marks[u]).forEach((u) => {
|
|
62
|
-
o.removeMark(l, s, u);
|
|
63
|
-
}), r == null || r(o.addMark(l, s, e.create())), !0);
|
|
64
|
-
})
|
|
1
|
+
import { $markAttr as H, $markSchema as K, $command as u, $useKeymap as f, $node as X, $nodeAttr as k, $nodeSchema as y, $ctx as P, $inputRule as I, pipe as Be, $prose as w, $remark as W } from "@milkdown/utils";
|
|
2
|
+
import { commandsCtx as m, editorViewCtx as R, serializerCtx as Re, parserCtx as Pe } from "@milkdown/core";
|
|
3
|
+
import { toggleMark as q, setBlockType as S, wrapIn as F } from "@milkdown/prose/commands";
|
|
4
|
+
import { Fragment as Z } from "@milkdown/prose/model";
|
|
5
|
+
import { expectDomTypeError as b } from "@milkdown/exception";
|
|
6
|
+
import { textblockTypeInputRule as ee, wrappingInputRule as V, InputRule as te } from "@milkdown/prose/inputrules";
|
|
7
|
+
import { TextSelection as re, Selection as ne, PluginKey as N, Plugin as C } from "@milkdown/prose/state";
|
|
8
|
+
import { findSelectedNodeOfType as We } from "@milkdown/prose";
|
|
9
|
+
import { sinkListItem as qe, splitListItem as Fe, liftListItem as Ve } from "@milkdown/prose/schema-list";
|
|
10
|
+
import { ReplaceStep as Ge, AddMarkStep as ze } from "@milkdown/prose/transform";
|
|
11
|
+
import { Decoration as J, DecorationSet as Q } from "@milkdown/prose/view";
|
|
12
|
+
import { visit as oe } from "unist-util-visit";
|
|
13
|
+
import je from "remark-inline-links";
|
|
14
|
+
const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
15
|
+
inclusive: !1,
|
|
16
|
+
parseDOM: [
|
|
17
|
+
{ tag: "i" },
|
|
18
|
+
{ tag: "em" },
|
|
19
|
+
{ style: "font-style", getAttrs: (e) => e === "italic" }
|
|
65
20
|
],
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
],
|
|
78
|
-
toDOM: (e) => ["em", { class: a.getClassName(e.attrs, j) }],
|
|
79
|
-
parseMarkdown: {
|
|
80
|
-
match: (e) => e.type === "emphasis",
|
|
81
|
-
runner: (e, t, r) => {
|
|
82
|
-
e.openMark(r), e.next(t.children), e.closeMark(r);
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
toMarkdown: {
|
|
86
|
-
match: (e) => e.type.name === j,
|
|
87
|
-
runner: (e, t) => {
|
|
88
|
-
e.withMark(t, "emphasis");
|
|
89
|
-
}
|
|
21
|
+
toDOM: (e) => ["em", r.get(ae.key)(e)],
|
|
22
|
+
parseMarkdown: {
|
|
23
|
+
match: (e) => e.type === "emphasis",
|
|
24
|
+
runner: (e, t, n) => {
|
|
25
|
+
e.openMark(n), e.next(t.children), e.closeMark(n);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
toMarkdown: {
|
|
29
|
+
match: (e) => e.type.name === "emphasis",
|
|
30
|
+
runner: (e, t) => {
|
|
31
|
+
e.withMark(t, "emphasis");
|
|
90
32
|
}
|
|
91
|
-
}),
|
|
92
|
-
commands: (e) => [N(te, () => pe(e))],
|
|
93
|
-
shortcuts: {
|
|
94
|
-
[y.Em]: M(te, "Mod-i")
|
|
95
33
|
}
|
|
96
|
-
})),
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
parseDOM: [
|
|
104
|
-
{
|
|
105
|
-
tag: "a[href]",
|
|
106
|
-
getAttrs: (t) => {
|
|
107
|
-
if (!(t instanceof HTMLElement))
|
|
108
|
-
throw x(t);
|
|
109
|
-
return { href: t.getAttribute("href"), title: t.getAttribute("title") };
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
],
|
|
113
|
-
toDOM: (t) => ["a", { ...t.attrs, class: a.getClassName(t.attrs, $) }],
|
|
114
|
-
parseMarkdown: {
|
|
115
|
-
match: (t) => t.type === "link",
|
|
116
|
-
runner: (t, r, n) => {
|
|
117
|
-
const o = r.url, l = r.title;
|
|
118
|
-
t.openMark(n, { href: o, title: l }), t.next(r.children), t.closeMark(n);
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
toMarkdown: {
|
|
122
|
-
match: (t) => t.type.name === $,
|
|
123
|
-
runner: (t, r) => {
|
|
124
|
-
t.withMark(r, "link", void 0, {
|
|
125
|
-
title: r.attrs.title,
|
|
126
|
-
url: r.attrs.href
|
|
127
|
-
});
|
|
128
|
-
}
|
|
34
|
+
})), le = u("ToggleEmphasis", () => () => q(se.type())), Ue = f("emphasisKeymap", {
|
|
35
|
+
ToggleEmphasis: {
|
|
36
|
+
shortcuts: "Mod-i",
|
|
37
|
+
command: (r) => {
|
|
38
|
+
const e = r.get(m);
|
|
39
|
+
return () => e.call(le.key);
|
|
129
40
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const { marks: l } = n.schema;
|
|
138
|
-
let s, c = -1;
|
|
139
|
-
const { selection: i } = n, { from: u, to: f } = i;
|
|
140
|
-
if (n.doc.nodesBetween(u, u === f ? f + 1 : f, (b, w) => {
|
|
141
|
-
var L;
|
|
142
|
-
if ((L = l.link) != null && L.isInSet(b.marks))
|
|
143
|
-
return s = b, c = w, !1;
|
|
144
|
-
}), !s)
|
|
145
|
-
return !1;
|
|
146
|
-
const d = s.marks.find(({ type: b }) => b === t);
|
|
147
|
-
if (!d)
|
|
148
|
-
return !1;
|
|
149
|
-
const m = c, p = c + s.nodeSize, { tr: g } = n, h = (k = l.link) == null ? void 0 : k.create({ ...d.attrs, href: r });
|
|
150
|
-
return h ? (o(
|
|
151
|
-
g.removeMark(m, p, d).addMark(m, p, h).setSelection(new Q(g.selection.$anchor)).scrollIntoView()
|
|
152
|
-
), !0) : !1;
|
|
153
|
-
})
|
|
41
|
+
}
|
|
42
|
+
}), ce = H("strong"), ie = K("strong", (r) => ({
|
|
43
|
+
inclusive: !1,
|
|
44
|
+
parseDOM: [
|
|
45
|
+
{ tag: "b" },
|
|
46
|
+
{ tag: "strong" },
|
|
47
|
+
{ style: "font-style", getAttrs: (e) => e === "bold" }
|
|
154
48
|
],
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
},
|
|
168
|
-
calculatePosition: (m, p) => {
|
|
169
|
-
Be(m, p, (g, h, k, b) => {
|
|
170
|
-
const w = m.dom.parentElement;
|
|
171
|
-
if (!w)
|
|
172
|
-
throw Pe();
|
|
173
|
-
const L = h.left - g.left;
|
|
174
|
-
let D = g.left - b.left - (k.width - L) / 2, _ = g.bottom - b.top + 14 + w.scrollTop;
|
|
175
|
-
n && (_ = g.top - b.top - k.height - 14 + w.scrollTop), D < 0 && (D = 0);
|
|
176
|
-
const he = w.clientWidth - (k.width + 4);
|
|
177
|
-
return D > he && (D = he), [_, D];
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
if (!l)
|
|
182
|
-
return {};
|
|
183
|
-
const s = (m) => {
|
|
184
|
-
var b;
|
|
185
|
-
const { selection: p, doc: g } = m.state, { from: h, to: k } = p;
|
|
186
|
-
if (!m.hasFocus())
|
|
187
|
-
return !1;
|
|
188
|
-
if (p instanceof Q && k < g.content.size && h < g.content.size && g.rangeHasMark(h, h === k ? k + 1 : k, t)) {
|
|
189
|
-
let w = p.empty;
|
|
190
|
-
if (((b = e == null ? void 0 : e.input) == null ? void 0 : b.displayWhenSelected) && !w && g.nodesBetween(h, h === k ? k + 1 : k, (L, D) => {
|
|
191
|
-
if (L.marks.some(
|
|
192
|
-
(_) => _.type === t && h >= D && k <= D + L.nodeSize
|
|
193
|
-
))
|
|
194
|
-
return w = !0, !1;
|
|
195
|
-
}), w)
|
|
196
|
-
return n = !1, !0;
|
|
197
|
-
}
|
|
198
|
-
if (p instanceof qe) {
|
|
199
|
-
const { node: w } = p;
|
|
200
|
-
if (w.type.name === "image" && w.marks.findIndex((L) => L.type.name === $) > -1)
|
|
201
|
-
return n = !0, !0;
|
|
202
|
-
}
|
|
203
|
-
return !1;
|
|
204
|
-
}, c = (m) => {
|
|
205
|
-
const { selection: p } = m.state;
|
|
206
|
-
let g;
|
|
207
|
-
const { from: h, to: k } = p;
|
|
208
|
-
if (m.state.doc.nodesBetween(h, h === k ? k + 1 : k, (L) => {
|
|
209
|
-
if (t.isInSet(L.marks))
|
|
210
|
-
return g = L, !1;
|
|
211
|
-
}), !g)
|
|
212
|
-
return;
|
|
213
|
-
const b = g.marks.find((L) => L.type === t);
|
|
214
|
-
return b ? b.attrs.href : void 0;
|
|
215
|
-
}, i = (m) => {
|
|
216
|
-
if (!m.editable)
|
|
217
|
-
return;
|
|
218
|
-
s(m) ? (l.show(m), l.update(c(m))) : l.hide();
|
|
219
|
-
};
|
|
220
|
-
return l.init(o), i(o), {
|
|
221
|
-
update: (m, p) => {
|
|
222
|
-
(p == null ? void 0 : p.doc.eq(m.state.doc)) && p.selection.eq(m.state.selection) || requestAnimationFrame(() => {
|
|
223
|
-
i(m);
|
|
224
|
-
});
|
|
225
|
-
},
|
|
226
|
-
destroy: () => {
|
|
227
|
-
l.destroy();
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
})
|
|
232
|
-
];
|
|
49
|
+
toDOM: (e) => ["strong", r.get(ce.key)(e)],
|
|
50
|
+
parseMarkdown: {
|
|
51
|
+
match: (e) => e.type === "strong",
|
|
52
|
+
runner: (e, t, n) => {
|
|
53
|
+
e.openMark(n), e.next(t.children), e.closeMark(n);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
toMarkdown: {
|
|
57
|
+
match: (e) => e.type.name === "strong",
|
|
58
|
+
runner: (e, t) => {
|
|
59
|
+
e.withMark(t, "strong");
|
|
60
|
+
}
|
|
233
61
|
}
|
|
234
|
-
})),
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
{ tag: "strong" },
|
|
241
|
-
{ style: "font-style", getAttrs: (e) => e === "bold" }
|
|
242
|
-
],
|
|
243
|
-
toDOM: (e) => ["strong", { class: a.getClassName(e.attrs, z) }],
|
|
244
|
-
parseMarkdown: {
|
|
245
|
-
match: (e) => e.type === "strong",
|
|
246
|
-
runner: (e, t, r) => {
|
|
247
|
-
e.openMark(r), e.next(t.children), e.closeMark(r);
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
toMarkdown: {
|
|
251
|
-
match: (e) => e.type.name === z,
|
|
252
|
-
runner: (e, t) => {
|
|
253
|
-
e.withMark(t, "strong");
|
|
254
|
-
}
|
|
62
|
+
})), de = u("ToggleStrong", () => () => q(ie.type())), Ye = f("strongKeymap", {
|
|
63
|
+
ToggleBold: {
|
|
64
|
+
shortcuts: ["Mod-b"],
|
|
65
|
+
command: (r) => {
|
|
66
|
+
const e = r.get(m);
|
|
67
|
+
return () => e.call(de.key);
|
|
255
68
|
}
|
|
256
|
-
}),
|
|
257
|
-
commands: (e) => [N(ne, () => pe(e))],
|
|
258
|
-
shortcuts: {
|
|
259
|
-
[y.Bold]: M(ne, "Mod-b")
|
|
260
69
|
}
|
|
261
|
-
})
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
runner: (e, t) => {
|
|
278
|
-
e.openNode("blockquote").next(t.content).closeNode();
|
|
279
|
-
}
|
|
70
|
+
}), ue = H("inlineCode"), A = K("inlineCode", (r) => ({
|
|
71
|
+
priority: 100,
|
|
72
|
+
code: !0,
|
|
73
|
+
inclusive: !1,
|
|
74
|
+
parseDOM: [{ tag: "code" }],
|
|
75
|
+
toDOM: (e) => ["code", r.get(ue.key)(e)],
|
|
76
|
+
parseMarkdown: {
|
|
77
|
+
match: (e) => e.type === "inlineCode",
|
|
78
|
+
runner: (e, t, n) => {
|
|
79
|
+
e.openMark(n), e.addText(t.value), e.closeMark(n);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
toMarkdown: {
|
|
83
|
+
match: (e) => e.type.name === "inlineCode",
|
|
84
|
+
runner: (e, t, n) => {
|
|
85
|
+
e.withMark(t, "inlineCode", n.text || "");
|
|
280
86
|
}
|
|
281
|
-
}),
|
|
282
|
-
inputRules: (e) => [K(/^\s*>\s$/, e)],
|
|
283
|
-
commands: (e) => [N(se, () => ge(e))],
|
|
284
|
-
shortcuts: {
|
|
285
|
-
[y.Blockquote]: M(se, "Mod-Shift-b")
|
|
286
87
|
}
|
|
287
|
-
})),
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
tag: "ul",
|
|
302
|
-
getAttrs: (t) => {
|
|
303
|
-
if (!(t instanceof HTMLElement))
|
|
304
|
-
throw x(t);
|
|
305
|
-
return {
|
|
306
|
-
spread: t.dataset.spread
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
],
|
|
311
|
-
toDOM: (t) => [
|
|
312
|
-
"ul",
|
|
313
|
-
{
|
|
314
|
-
"data-spread": t.attrs.spread,
|
|
315
|
-
class: a.getClassName(t.attrs, "bullet-list")
|
|
316
|
-
},
|
|
317
|
-
0
|
|
318
|
-
],
|
|
319
|
-
parseMarkdown: {
|
|
320
|
-
match: ({ type: t, ordered: r }) => t === "list" && !r,
|
|
321
|
-
runner: (t, r, n) => {
|
|
322
|
-
const o = r.spread != null ? `${r.spread}` : "false";
|
|
323
|
-
t.openNode(n, { spread: o }).next(r.children).closeNode();
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
toMarkdown: {
|
|
327
|
-
match: (t) => t.type.name === e,
|
|
328
|
-
runner: (t, r) => {
|
|
329
|
-
t.openNode("list", void 0, { ordered: !1, spread: r.attrs.spread === "true" }).next(r.content).closeNode();
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}),
|
|
333
|
-
inputRules: (t) => [K(/^\s*([-+*])\s$/, t)],
|
|
334
|
-
commands: (t) => [N(oe, () => ge(t))],
|
|
335
|
-
shortcuts: {
|
|
336
|
-
[y.BulletList]: M(oe, "Mod-Alt-8")
|
|
88
|
+
})), pe = u("ToggleInlineCode", () => () => (r, e) => {
|
|
89
|
+
const { selection: t, tr: n } = r;
|
|
90
|
+
if (t.empty)
|
|
91
|
+
return !1;
|
|
92
|
+
const { from: o, to: a } = t;
|
|
93
|
+
return r.doc.rangeHasMark(o, a, A.type()) ? (e == null || e(n.removeMark(o, a, A.type())), !0) : (Object.keys(r.schema.marks).filter((c) => c !== A.type.name).map((c) => r.schema.marks[c]).forEach((c) => {
|
|
94
|
+
n.removeMark(o, a, c);
|
|
95
|
+
}), e == null || e(n.addMark(o, a, A.type().create())), !0);
|
|
96
|
+
}), Je = f("inlineCodeKeymap", {
|
|
97
|
+
ToggleInlineCode: {
|
|
98
|
+
shortcuts: "Mod-e",
|
|
99
|
+
command: (r) => {
|
|
100
|
+
const e = r.get(m);
|
|
101
|
+
return () => e.call(pe.key);
|
|
337
102
|
}
|
|
338
|
-
}
|
|
339
|
-
}),
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
"ruby",
|
|
352
|
-
"python",
|
|
353
|
-
"go",
|
|
354
|
-
"rust",
|
|
355
|
-
"markdown"
|
|
356
|
-
], st = /^```(?<language>[a-z]*)?[\s\n]$/, ot = /^~~~(?<language>[a-z]*)?[\s\n]$/, ae = I("TurnIntoCodeFence"), U = "fence", at = C((a, e) => {
|
|
357
|
-
const t = (e == null ? void 0 : e.languageList) || nt;
|
|
358
|
-
return {
|
|
359
|
-
id: U,
|
|
360
|
-
schema: (r) => ({
|
|
361
|
-
content: "text*",
|
|
362
|
-
group: "block",
|
|
363
|
-
marks: "",
|
|
364
|
-
defining: !0,
|
|
365
|
-
code: !0,
|
|
366
|
-
attrs: {
|
|
367
|
-
language: {
|
|
368
|
-
default: ""
|
|
369
|
-
},
|
|
370
|
-
fold: {
|
|
371
|
-
default: !0
|
|
372
|
-
}
|
|
373
|
-
},
|
|
374
|
-
parseDOM: [
|
|
375
|
-
{
|
|
376
|
-
tag: "div.code-fence-container",
|
|
377
|
-
preserveWhitespace: "full",
|
|
378
|
-
getAttrs: (n) => {
|
|
379
|
-
var o;
|
|
380
|
-
if (!(n instanceof HTMLElement))
|
|
381
|
-
throw x(n);
|
|
382
|
-
return { language: (o = n.querySelector("pre")) == null ? void 0 : o.dataset.language };
|
|
383
|
-
},
|
|
384
|
-
getContent: (n, o) => {
|
|
385
|
-
var c, i;
|
|
386
|
-
if (!(n instanceof HTMLElement))
|
|
387
|
-
throw x(n);
|
|
388
|
-
const l = (i = (c = n.querySelector("pre")) == null ? void 0 : c.textContent) != null ? i : "";
|
|
389
|
-
if (!l)
|
|
390
|
-
return W.empty;
|
|
391
|
-
const s = o.text(l);
|
|
392
|
-
return W.from(s);
|
|
393
|
-
}
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
tag: "pre",
|
|
397
|
-
preserveWhitespace: "full",
|
|
398
|
-
getAttrs: (n) => {
|
|
399
|
-
if (!(n instanceof HTMLElement))
|
|
400
|
-
throw x(n);
|
|
401
|
-
return { language: n.dataset.language };
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
],
|
|
405
|
-
toDOM: (n) => {
|
|
406
|
-
const o = document.createElement("select");
|
|
407
|
-
return t.forEach((l) => {
|
|
408
|
-
const s = document.createElement("option");
|
|
409
|
-
s.value = l, s.innerText = l || "--", l === n.attrs.language && (s.selected = !0), o.appendChild(s);
|
|
410
|
-
}), o.onchange = (l) => {
|
|
411
|
-
const s = l.target;
|
|
412
|
-
if (!(s instanceof HTMLSelectElement))
|
|
413
|
-
return;
|
|
414
|
-
const c = r.get(v);
|
|
415
|
-
if (!c.editable) {
|
|
416
|
-
s.value = n.attrs.language;
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
const { top: i, left: u } = s.getBoundingClientRect(), f = c.posAtCoords({ top: i, left: u });
|
|
420
|
-
if (!f)
|
|
421
|
-
return;
|
|
422
|
-
const { tr: d } = c.state;
|
|
423
|
-
c.dispatch(
|
|
424
|
-
d.setNodeMarkup(f.inside, void 0, {
|
|
425
|
-
...n.attrs,
|
|
426
|
-
language: s.value
|
|
427
|
-
})
|
|
428
|
-
);
|
|
429
|
-
}, [
|
|
430
|
-
"div",
|
|
431
|
-
{
|
|
432
|
-
class: "code-fence-container"
|
|
433
|
-
},
|
|
434
|
-
o,
|
|
435
|
-
[
|
|
436
|
-
"pre",
|
|
437
|
-
{
|
|
438
|
-
"data-language": n.attrs.language,
|
|
439
|
-
class: a.getClassName(n.attrs, "code-fence")
|
|
440
|
-
},
|
|
441
|
-
["code", { spellCheck: "false" }, 0]
|
|
442
|
-
]
|
|
443
|
-
];
|
|
444
|
-
},
|
|
445
|
-
parseMarkdown: {
|
|
446
|
-
match: ({ type: n }) => n === "code",
|
|
447
|
-
runner: (n, o, l) => {
|
|
448
|
-
const s = o.lang, c = o.value;
|
|
449
|
-
n.openNode(l, { language: s }), c && n.addText(c), n.closeNode();
|
|
450
|
-
}
|
|
451
|
-
},
|
|
452
|
-
toMarkdown: {
|
|
453
|
-
match: (n) => n.type.name === U,
|
|
454
|
-
runner: (n, o) => {
|
|
455
|
-
var l;
|
|
456
|
-
n.addNode("code", void 0, ((l = o.content.firstChild) == null ? void 0 : l.text) || "", {
|
|
457
|
-
lang: o.attrs.language
|
|
458
|
-
});
|
|
459
|
-
}
|
|
103
|
+
}
|
|
104
|
+
}), me = H("link"), v = K("link", (r) => ({
|
|
105
|
+
attrs: {
|
|
106
|
+
href: {},
|
|
107
|
+
title: { default: null }
|
|
108
|
+
},
|
|
109
|
+
parseDOM: [
|
|
110
|
+
{
|
|
111
|
+
tag: "a[href]",
|
|
112
|
+
getAttrs: (e) => {
|
|
113
|
+
if (!(e instanceof HTMLElement))
|
|
114
|
+
throw b(e);
|
|
115
|
+
return { href: e.getAttribute("href"), title: e.getAttribute("title") };
|
|
460
116
|
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
},
|
|
478
|
-
view: () => (r, n, o) => {
|
|
479
|
-
let l = r;
|
|
480
|
-
const s = (g) => {
|
|
481
|
-
const { tr: h } = n.state;
|
|
482
|
-
n.dispatch(
|
|
483
|
-
h.setNodeMarkup(o(), void 0, {
|
|
484
|
-
fold: !0,
|
|
485
|
-
language: g
|
|
486
|
-
})
|
|
487
|
-
);
|
|
488
|
-
}, c = () => {
|
|
489
|
-
const { tr: g } = n.state;
|
|
490
|
-
n.dispatch(
|
|
491
|
-
g.setNodeMarkup(o(), void 0, {
|
|
492
|
-
...l.attrs,
|
|
493
|
-
fold: !0
|
|
494
|
-
})
|
|
495
|
-
);
|
|
496
|
-
}, i = () => {
|
|
497
|
-
const { tr: g } = n.state;
|
|
498
|
-
n.dispatch(
|
|
499
|
-
g.setNodeMarkup(o(), void 0, {
|
|
500
|
-
...l.attrs,
|
|
501
|
-
fold: !1
|
|
502
|
-
})
|
|
503
|
-
);
|
|
504
|
-
}, u = a.themeManager.get("code-fence", {
|
|
505
|
-
view: n,
|
|
506
|
-
onBlur: c,
|
|
507
|
-
onFocus: i,
|
|
508
|
-
onSelectLanguage: s,
|
|
509
|
-
editable: () => n.editable,
|
|
510
|
-
languageList: t
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
toDOM: (e) => ["a", { ...r.get(me.key)(e), ...e.attrs }],
|
|
120
|
+
parseMarkdown: {
|
|
121
|
+
match: (e) => e.type === "link",
|
|
122
|
+
runner: (e, t, n) => {
|
|
123
|
+
const o = t.url, a = t.title;
|
|
124
|
+
e.openMark(n, { href: o, title: a }), e.next(t.children), e.closeMark(n);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
toMarkdown: {
|
|
128
|
+
match: (e) => e.type.name === "link",
|
|
129
|
+
runner: (e, t) => {
|
|
130
|
+
e.withMark(t, "link", void 0, {
|
|
131
|
+
title: t.attrs.title,
|
|
132
|
+
url: t.attrs.href
|
|
511
133
|
});
|
|
512
|
-
if (!u)
|
|
513
|
-
return {};
|
|
514
|
-
const { dom: f, contentDOM: d, onUpdate: m, onDestroy: p } = u;
|
|
515
|
-
return m(l), {
|
|
516
|
-
dom: f,
|
|
517
|
-
contentDOM: d,
|
|
518
|
-
update: (g) => g.type.name !== U ? !1 : (l = g, m(l), !0),
|
|
519
|
-
destroy: p
|
|
520
|
-
};
|
|
521
134
|
}
|
|
522
|
-
}
|
|
523
|
-
}),
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
135
|
+
}
|
|
136
|
+
})), Qe = u("ToggleLink", () => (r = {}) => q(v.type(), r)), Xe = u("UpdateLink", () => (r = {}) => (e, t) => {
|
|
137
|
+
if (!t)
|
|
138
|
+
return !1;
|
|
139
|
+
let n, o = -1;
|
|
140
|
+
const { selection: a } = e, { from: s, to: l } = a;
|
|
141
|
+
if (e.doc.nodesBetween(s, s === l ? l + 1 : l, (h, _) => {
|
|
142
|
+
if (v.type().isInSet(h.marks))
|
|
143
|
+
return n = h, o = _, !1;
|
|
144
|
+
}), !n)
|
|
145
|
+
return !1;
|
|
146
|
+
const c = n.marks.find(({ type: h }) => h === v.type());
|
|
147
|
+
if (!c)
|
|
148
|
+
return !1;
|
|
149
|
+
const i = o, d = o + n.nodeSize, { tr: p } = e, g = v.type().create({ ...c.attrs, ...r });
|
|
150
|
+
return g ? (t(
|
|
151
|
+
p.removeMark(i, d, c).addMark(i, d, g).setSelection(new re(p.selection.$anchor)).scrollIntoView()
|
|
152
|
+
), !0) : !1;
|
|
153
|
+
}), Ze = X("doc", () => ({
|
|
154
|
+
content: "block+",
|
|
155
|
+
parseMarkdown: {
|
|
156
|
+
match: ({ type: r }) => r === "root",
|
|
157
|
+
runner: (r, e, t) => {
|
|
158
|
+
r.injectRoot(e, t);
|
|
538
159
|
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
id: "hardbreak",
|
|
545
|
-
schema: () => ({
|
|
546
|
-
inline: !0,
|
|
547
|
-
group: "inline",
|
|
548
|
-
selectable: !1,
|
|
549
|
-
parseDOM: [{ tag: "br" }],
|
|
550
|
-
toDOM: (n) => ["br", { class: a.getClassName(n.attrs, "hardbreak") }],
|
|
551
|
-
parseMarkdown: {
|
|
552
|
-
match: ({ type: n }) => n === "break",
|
|
553
|
-
runner: (n, o, l) => {
|
|
554
|
-
n.addNode(l);
|
|
555
|
-
}
|
|
556
|
-
},
|
|
557
|
-
toMarkdown: {
|
|
558
|
-
match: (n) => n.type.name === "hardbreak",
|
|
559
|
-
runner: (n) => {
|
|
560
|
-
n.addNode("break");
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
}),
|
|
564
|
-
commands: (n) => [
|
|
565
|
-
N(le, () => (o, l) => {
|
|
566
|
-
var i;
|
|
567
|
-
const { selection: s, tr: c } = o;
|
|
568
|
-
if (s.empty) {
|
|
569
|
-
const u = s.$from.node();
|
|
570
|
-
if (u.childCount > 0 && ((i = u.lastChild) == null ? void 0 : i.type.name) === "hardbreak")
|
|
571
|
-
return l == null || l(
|
|
572
|
-
c.replaceRangeWith(s.to - 1, s.to, o.schema.node("paragraph")).setSelection(Ce.near(c.doc.resolve(s.to))).scrollIntoView()
|
|
573
|
-
), !0;
|
|
574
|
-
}
|
|
575
|
-
return l == null || l(c.setMeta("hardbreak", !0).replaceSelectionWith(n.create()).scrollIntoView()), !0;
|
|
576
|
-
})
|
|
577
|
-
],
|
|
578
|
-
shortcuts: {
|
|
579
|
-
[y.HardBreak]: M(le, "Shift-Enter")
|
|
580
|
-
},
|
|
581
|
-
prosePlugins: (n) => [
|
|
582
|
-
new T({
|
|
583
|
-
key: ct,
|
|
584
|
-
filterTransaction: (o, l) => {
|
|
585
|
-
const s = o.getMeta("hardbreak"), [c] = o.steps;
|
|
586
|
-
if (s && c) {
|
|
587
|
-
const { from: i } = c, u = l.doc.resolve(i);
|
|
588
|
-
let f = u.depth, d = !0;
|
|
589
|
-
for (; f > 0; )
|
|
590
|
-
t.includes(u.node(f).type.name) && (d = !1), f--;
|
|
591
|
-
return d;
|
|
592
|
-
}
|
|
593
|
-
return !0;
|
|
594
|
-
}
|
|
595
|
-
}),
|
|
596
|
-
new T({
|
|
597
|
-
key: new H("MILKDOWN_HARDBREAK_MARKS"),
|
|
598
|
-
appendTransaction: (o, l, s) => {
|
|
599
|
-
if (!o.length)
|
|
600
|
-
return;
|
|
601
|
-
const [c] = o;
|
|
602
|
-
if (!c)
|
|
603
|
-
return;
|
|
604
|
-
const [i] = c.steps;
|
|
605
|
-
if (c.getMeta("hardbreak")) {
|
|
606
|
-
if (!(i instanceof Ke))
|
|
607
|
-
return;
|
|
608
|
-
const { from: d } = i;
|
|
609
|
-
return s.tr.setNodeMarkup(d, n, void 0, []);
|
|
610
|
-
}
|
|
611
|
-
if (i instanceof Fe) {
|
|
612
|
-
let d = s.tr;
|
|
613
|
-
const { from: m, to: p } = i;
|
|
614
|
-
return s.doc.nodesBetween(m, p, (g, h) => {
|
|
615
|
-
g.type === n && (d = d.setNodeMarkup(h, n, void 0, []));
|
|
616
|
-
}), d;
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
})
|
|
620
|
-
]
|
|
621
|
-
};
|
|
622
|
-
}), Me = Array(6).fill(0).map((a, e) => e + 1), O = I("TurnIntoHeading"), ye = I("DowngradeHeading"), V = new H("MILKDOWN_HEADING_ID"), ut = new H("MILKDOWN_HEADING_HASH"), dt = (a) => a.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "-").toLowerCase().trim(), ft = (a, e, t) => {
|
|
623
|
-
let r = !1;
|
|
624
|
-
const n = (o, l) => {
|
|
625
|
-
const s = o.tr.setMeta("addToHistory", !1);
|
|
626
|
-
let c = !1;
|
|
627
|
-
o.doc.descendants((i, u) => {
|
|
628
|
-
if (i.type === e && !r) {
|
|
629
|
-
if (i.textContent.trim().length === 0)
|
|
630
|
-
return;
|
|
631
|
-
const f = i.attrs, d = t(i);
|
|
632
|
-
f.id !== d && (c = !0, s.setMeta(V, !0).setNodeMarkup(u, void 0, {
|
|
633
|
-
...f,
|
|
634
|
-
id: d
|
|
635
|
-
}));
|
|
636
|
-
}
|
|
637
|
-
}), c && l(s);
|
|
638
|
-
};
|
|
639
|
-
return new T({
|
|
640
|
-
key: V,
|
|
641
|
-
props: {
|
|
642
|
-
handleDOMEvents: {
|
|
643
|
-
compositionstart: () => (r = !0, !1),
|
|
644
|
-
compositionend: () => {
|
|
645
|
-
r = !1;
|
|
646
|
-
const o = a.get(v);
|
|
647
|
-
return setTimeout(() => {
|
|
648
|
-
n(o.state, (l) => o.dispatch(l));
|
|
649
|
-
}, 0), !1;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
},
|
|
653
|
-
appendTransaction: (o, l, s) => {
|
|
654
|
-
let c = null;
|
|
655
|
-
return o.every((i) => !i.getMeta(V)) && o.some((i) => i.docChanged) && n(s, (i) => {
|
|
656
|
-
c = i;
|
|
657
|
-
}), c;
|
|
658
|
-
},
|
|
659
|
-
view: (o) => {
|
|
660
|
-
const l = o.state.doc;
|
|
661
|
-
let s = o.state.tr.setMeta("addToHistory", !1);
|
|
662
|
-
return l.descendants((c, i) => {
|
|
663
|
-
c.type.name === "heading" && c.attrs.level && (c.attrs.id || (s = s.setNodeMarkup(i, void 0, {
|
|
664
|
-
...c.attrs,
|
|
665
|
-
id: t(c)
|
|
666
|
-
})));
|
|
667
|
-
}), o.dispatch(s), {};
|
|
160
|
+
},
|
|
161
|
+
toMarkdown: {
|
|
162
|
+
match: (r) => r.type.name === "doc",
|
|
163
|
+
runner: (r, e) => {
|
|
164
|
+
r.openNode("root"), r.next(e.content);
|
|
668
165
|
}
|
|
669
|
-
}
|
|
670
|
-
},
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
const { $from: o } = r.selection, l = o.node();
|
|
680
|
-
if (l.type !== e)
|
|
681
|
-
return S.empty;
|
|
682
|
-
const s = l.attrs.level, c = (d) => Array(d).fill(0).map((m) => "#").join(""), i = document.createElement("span");
|
|
683
|
-
i.textContent = c(s), i.contentEditable = "false", t.themeManager.onFlush(() => {
|
|
684
|
-
const d = t.getStyle(({ css: m }) => {
|
|
685
|
-
const p = Ae(t.themeManager);
|
|
686
|
-
return m`
|
|
687
|
-
margin-right: 4px;
|
|
688
|
-
color: ${p("primary")};
|
|
689
|
-
`;
|
|
690
|
-
});
|
|
691
|
-
d && (i.className = d);
|
|
692
|
-
});
|
|
693
|
-
const u = Z.widget(o.before() + 1, i, { side: -1 });
|
|
694
|
-
return S.create(r.doc, [u]);
|
|
166
|
+
}
|
|
167
|
+
})), ge = k("paragraph"), L = y("paragraph", (r) => ({
|
|
168
|
+
content: "inline*",
|
|
169
|
+
group: "block",
|
|
170
|
+
parseDOM: [{ tag: "p" }],
|
|
171
|
+
toDOM: (e) => ["p", r.get(ge.key)(e), 0],
|
|
172
|
+
parseMarkdown: {
|
|
173
|
+
match: (e) => e.type === "paragraph",
|
|
174
|
+
runner: (e, t, n) => {
|
|
175
|
+
e.openNode(n), t.children ? e.next(t.children) : e.addText(t.value || ""), e.closeNode();
|
|
695
176
|
}
|
|
696
177
|
},
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
178
|
+
toMarkdown: {
|
|
179
|
+
match: (e) => e.type.name === "paragraph",
|
|
180
|
+
runner: (e, t) => {
|
|
181
|
+
var o;
|
|
182
|
+
if (e.openNode("paragraph"), t.childCount >= 1 && ((o = t.lastChild) == null ? void 0 : o.type.name) === "hardbreak") {
|
|
183
|
+
const a = [];
|
|
184
|
+
t.content.forEach((s, l, c) => {
|
|
185
|
+
c !== t.childCount - 1 && a.push(s);
|
|
186
|
+
}), e.next(Z.fromArray(a));
|
|
187
|
+
} else
|
|
188
|
+
e.next(t.content);
|
|
189
|
+
e.closeNode();
|
|
706
190
|
}
|
|
707
191
|
}
|
|
708
|
-
}),
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
content: "inline*",
|
|
716
|
-
group: "block",
|
|
717
|
-
defining: !0,
|
|
718
|
-
attrs: {
|
|
719
|
-
id: {
|
|
720
|
-
default: ""
|
|
721
|
-
},
|
|
722
|
-
level: {
|
|
723
|
-
default: 1
|
|
724
|
-
}
|
|
725
|
-
},
|
|
726
|
-
parseDOM: Me.map((s) => ({
|
|
727
|
-
tag: `h${s}`,
|
|
728
|
-
getAttrs: (c) => {
|
|
729
|
-
if (!(c instanceof HTMLElement))
|
|
730
|
-
throw x(c);
|
|
731
|
-
return { level: s, id: c.id };
|
|
732
|
-
}
|
|
733
|
-
})),
|
|
734
|
-
toDOM: (s) => [
|
|
735
|
-
`h${s.attrs.level}`,
|
|
736
|
-
{
|
|
737
|
-
id: s.attrs.id || r(s),
|
|
738
|
-
class: a.getClassName(s.attrs, `heading h${s.attrs.level}`)
|
|
739
|
-
},
|
|
740
|
-
0
|
|
741
|
-
],
|
|
742
|
-
parseMarkdown: {
|
|
743
|
-
match: ({ type: s }) => s === t,
|
|
744
|
-
runner: (s, c, i) => {
|
|
745
|
-
const u = c.depth;
|
|
746
|
-
s.openNode(i, { level: u }), s.next(c.children), s.closeNode();
|
|
747
|
-
}
|
|
748
|
-
},
|
|
749
|
-
toMarkdown: {
|
|
750
|
-
match: (s) => s.type.name === t,
|
|
751
|
-
runner: (s, c) => {
|
|
752
|
-
var u;
|
|
753
|
-
if (s.openNode("heading", void 0, { depth: c.attrs.level }), c.childCount >= 1 && ((u = c.lastChild) == null ? void 0 : u.type.name) === "hardbreak") {
|
|
754
|
-
const f = [];
|
|
755
|
-
c.content.forEach((d, m, p) => {
|
|
756
|
-
p !== c.childCount - 1 && f.push(d);
|
|
757
|
-
}), s.next(W.fromArray(f));
|
|
758
|
-
} else
|
|
759
|
-
s.next(c.content);
|
|
760
|
-
s.closeNode();
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
}),
|
|
764
|
-
inputRules: (s, c) => Me.map(
|
|
765
|
-
(i) => X(new RegExp(`^(#{1,${i}})\\s$`), s, () => {
|
|
766
|
-
const u = c.get(v), { $from: f } = u.state.selection, d = f.node();
|
|
767
|
-
if (d.type.name === "heading") {
|
|
768
|
-
let m = Number(d.attrs.level) + Number(i);
|
|
769
|
-
return m > 6 && (m = 6), {
|
|
770
|
-
level: m
|
|
771
|
-
};
|
|
772
|
-
}
|
|
773
|
-
return {
|
|
774
|
-
level: i
|
|
775
|
-
};
|
|
776
|
-
})
|
|
777
|
-
),
|
|
778
|
-
commands: (s, c) => [
|
|
779
|
-
N(O, (i = 1) => i < 1 ? A(i === 0 && c.get(R).nodes.paragraph || s) : A(i === 0 && c.get(R).nodes.paragraph || s, { level: i })),
|
|
780
|
-
N(ye, () => (i, u, f) => {
|
|
781
|
-
const { $from: d } = i.selection, m = d.node();
|
|
782
|
-
if (m.type !== s || !i.selection.empty || d.parentOffset !== 0)
|
|
783
|
-
return !1;
|
|
784
|
-
const p = m.attrs.level - 1;
|
|
785
|
-
return p ? (u == null || u(
|
|
786
|
-
i.tr.setNodeMarkup(i.selection.$from.before(), void 0, {
|
|
787
|
-
...m.attrs,
|
|
788
|
-
level: p
|
|
789
|
-
})
|
|
790
|
-
), !0) : A(c.get(R).nodes.paragraph || s)(i, u, f);
|
|
791
|
-
})
|
|
792
|
-
],
|
|
793
|
-
shortcuts: {
|
|
794
|
-
[y.H1]: M(O, "Mod-Alt-1", 1),
|
|
795
|
-
[y.H2]: M(O, "Mod-Alt-2", 2),
|
|
796
|
-
[y.H3]: M(O, "Mod-Alt-3", 3),
|
|
797
|
-
[y.H4]: M(O, "Mod-Alt-4", 4),
|
|
798
|
-
[y.H5]: M(O, "Mod-Alt-5", 5),
|
|
799
|
-
[y.H6]: M(O, "Mod-Alt-6", 6),
|
|
800
|
-
[y.DowngradeHeading]: M(ye, ["Backspace", "Delete"])
|
|
801
|
-
},
|
|
802
|
-
prosePlugins: (s, c) => {
|
|
803
|
-
const i = [ft(c, s, r)];
|
|
804
|
-
return n && i.push(mt(c, s, a)), i;
|
|
805
|
-
}
|
|
806
|
-
};
|
|
192
|
+
})), fe = u("TurnIntoText", () => () => S(L.type())), et = f("paragraphKeymap", {
|
|
193
|
+
TurnIntoText: {
|
|
194
|
+
shortcuts: "Mod-Alt-0",
|
|
195
|
+
command: (r) => {
|
|
196
|
+
const e = r.get(m);
|
|
197
|
+
return () => e.call(fe.key);
|
|
198
|
+
}
|
|
807
199
|
}
|
|
808
|
-
), G = "
|
|
809
|
-
|
|
810
|
-
|
|
200
|
+
}), tt = Array(6).fill(0).map((r, e) => e + 1), rt = (r) => r.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "-").toLowerCase().trim(), G = P(rt, "headingIdGenerator"), he = k("heading"), T = y("heading", (r) => {
|
|
201
|
+
const e = r.get(G.key);
|
|
202
|
+
return {
|
|
203
|
+
content: "inline*",
|
|
811
204
|
group: "block",
|
|
812
|
-
parseDOM: [{ tag: "hr" }],
|
|
813
|
-
toDOM: (e) => ["hr", { class: a.getClassName(e.attrs, G) }],
|
|
814
|
-
parseMarkdown: {
|
|
815
|
-
match: ({ type: e }) => e === "thematicBreak",
|
|
816
|
-
runner: (e, t, r) => {
|
|
817
|
-
e.addNode(r);
|
|
818
|
-
}
|
|
819
|
-
},
|
|
820
|
-
toMarkdown: {
|
|
821
|
-
match: (e) => e.type.name === G,
|
|
822
|
-
runner: (e) => {
|
|
823
|
-
e.addNode("thematicBreak");
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
}),
|
|
827
|
-
inputRules: (e) => [
|
|
828
|
-
new xe(/^(?:---|___\s|\*\*\*\s)$/, (t, r, n, o) => {
|
|
829
|
-
const { tr: l } = t;
|
|
830
|
-
return r[0] && l.replaceWith(n - 1, o, e.create()), l;
|
|
831
|
-
})
|
|
832
|
-
],
|
|
833
|
-
commands: (e, t) => [
|
|
834
|
-
N(He, () => (r, n) => {
|
|
835
|
-
if (!n)
|
|
836
|
-
return !0;
|
|
837
|
-
const o = t.get(R).node("paragraph"), { tr: l, selection: s } = r, { from: c } = s, i = e.create();
|
|
838
|
-
if (!i)
|
|
839
|
-
return !0;
|
|
840
|
-
const u = l.replaceSelectionWith(i).insert(c, o), f = Ce.findFrom(u.doc.resolve(c), 1, !0);
|
|
841
|
-
return f && n(u.setSelection(f).scrollIntoView()), !0;
|
|
842
|
-
})
|
|
843
|
-
]
|
|
844
|
-
})), ce = I("ModifyImage"), De = I("InsertImage"), B = "image", ht = new H("MILKDOWN_IMAGE_INPUT"), kt = C((a, e) => ({
|
|
845
|
-
id: "image",
|
|
846
|
-
schema: () => ({
|
|
847
|
-
inline: !0,
|
|
848
|
-
group: "inline",
|
|
849
|
-
selectable: !0,
|
|
850
|
-
draggable: !0,
|
|
851
|
-
marks: "",
|
|
852
|
-
atom: !0,
|
|
853
205
|
defining: !0,
|
|
854
|
-
isolating: !0,
|
|
855
206
|
attrs: {
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
207
|
+
id: {
|
|
208
|
+
default: ""
|
|
209
|
+
},
|
|
210
|
+
level: {
|
|
211
|
+
default: 1
|
|
212
|
+
}
|
|
859
213
|
},
|
|
860
|
-
parseDOM:
|
|
861
|
-
{
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
return {
|
|
867
|
-
src: t.getAttribute("src") || "",
|
|
868
|
-
alt: t.getAttribute("alt") || "",
|
|
869
|
-
title: t.getAttribute("title") || t.getAttribute("alt") || ""
|
|
870
|
-
};
|
|
871
|
-
}
|
|
214
|
+
parseDOM: tt.map((t) => ({
|
|
215
|
+
tag: `h${t}`,
|
|
216
|
+
getAttrs: (n) => {
|
|
217
|
+
if (!(n instanceof HTMLElement))
|
|
218
|
+
throw b(n);
|
|
219
|
+
return { level: t, id: n.id };
|
|
872
220
|
}
|
|
873
|
-
|
|
221
|
+
})),
|
|
874
222
|
toDOM: (t) => [
|
|
875
|
-
|
|
223
|
+
`h${t.attrs.level}`,
|
|
876
224
|
{
|
|
877
|
-
...t
|
|
878
|
-
|
|
879
|
-
}
|
|
225
|
+
...r.get(he.key)(t),
|
|
226
|
+
id: t.attrs.id || e(t)
|
|
227
|
+
},
|
|
228
|
+
0
|
|
880
229
|
],
|
|
881
230
|
parseMarkdown: {
|
|
882
|
-
match: ({ type: t }) => t ===
|
|
883
|
-
runner: (t,
|
|
884
|
-
const
|
|
885
|
-
t.
|
|
886
|
-
src: o,
|
|
887
|
-
alt: l,
|
|
888
|
-
title: s
|
|
889
|
-
});
|
|
231
|
+
match: ({ type: t }) => t === "heading",
|
|
232
|
+
runner: (t, n, o) => {
|
|
233
|
+
const a = n.depth;
|
|
234
|
+
t.openNode(o, { level: a }), t.next(n.children), t.closeNode();
|
|
890
235
|
}
|
|
891
236
|
},
|
|
892
237
|
toMarkdown: {
|
|
893
|
-
match: (t) => t.type.name ===
|
|
894
|
-
runner: (t,
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
238
|
+
match: (t) => t.type.name === "heading",
|
|
239
|
+
runner: (t, n) => {
|
|
240
|
+
var a;
|
|
241
|
+
if (t.openNode("heading", void 0, { depth: n.attrs.level }), n.childCount >= 1 && ((a = n.lastChild) == null ? void 0 : a.type.name) === "hardbreak") {
|
|
242
|
+
const s = [];
|
|
243
|
+
n.content.forEach((l, c, i) => {
|
|
244
|
+
i !== n.childCount - 1 && s.push(l);
|
|
245
|
+
}), t.next(Z.fromArray(s));
|
|
246
|
+
} else
|
|
247
|
+
t.next(n.content);
|
|
248
|
+
t.closeNode();
|
|
900
249
|
}
|
|
901
250
|
}
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
251
|
+
};
|
|
252
|
+
}), nt = I(
|
|
253
|
+
(r) => ee(/^(?<hashes>#+)\s$/, T.type(), (e) => {
|
|
254
|
+
var s, l;
|
|
255
|
+
const t = ((l = (s = e.groups) == null ? void 0 : s.hashes) == null ? void 0 : l.length) || 0, n = r.get(R), { $from: o } = n.state.selection, a = o.node();
|
|
256
|
+
if (a.type.name === "heading") {
|
|
257
|
+
let c = Number(a.attrs.level) + Number(t);
|
|
258
|
+
return c > 6 && (c = 6), { level: c };
|
|
259
|
+
}
|
|
260
|
+
return { level: t };
|
|
261
|
+
})
|
|
262
|
+
), M = u("WrapInHeading", () => (r) => (r ?? (r = 1), r < 1 ? S(L.type()) : S(T.type(), { level: r }))), ke = u("DowngradeHeading", () => () => (r, e, t) => {
|
|
263
|
+
const { $from: n } = r.selection, o = n.node();
|
|
264
|
+
if (o.type !== T.type() || !r.selection.empty || n.parentOffset !== 0)
|
|
265
|
+
return !1;
|
|
266
|
+
const a = o.attrs.level - 1;
|
|
267
|
+
return a ? (e == null || e(
|
|
268
|
+
r.tr.setNodeMarkup(r.selection.$from.before(), void 0, {
|
|
269
|
+
...o.attrs,
|
|
270
|
+
level: a
|
|
921
271
|
})
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
272
|
+
), !0) : S(L.type())(r, e, t);
|
|
273
|
+
}), ot = f("headingKeymap", {
|
|
274
|
+
TurnIntoH1: {
|
|
275
|
+
shortcuts: "Mod-Alt-1",
|
|
276
|
+
command: (r) => {
|
|
277
|
+
const e = r.get(m);
|
|
278
|
+
return () => e.call(M.key, 1);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
TurnIntoH2: {
|
|
282
|
+
shortcuts: "Mod-Alt-2",
|
|
283
|
+
command: (r) => {
|
|
284
|
+
const e = r.get(m);
|
|
285
|
+
return () => e.call(M.key, 2);
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
TurnIntoH3: {
|
|
289
|
+
shortcuts: "Mod-Alt-3",
|
|
290
|
+
command: (r) => {
|
|
291
|
+
const e = r.get(m);
|
|
292
|
+
return () => e.call(M.key, 3);
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
TurnIntoH4: {
|
|
296
|
+
shortcuts: "Mod-Alt-4",
|
|
297
|
+
command: (r) => {
|
|
298
|
+
const e = r.get(m);
|
|
299
|
+
return () => e.call(M.key, 3);
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
TurnIntoH5: {
|
|
303
|
+
shortcuts: "Mod-Alt-5",
|
|
304
|
+
command: (r) => {
|
|
305
|
+
const e = r.get(m);
|
|
306
|
+
return () => e.call(M.key, 3);
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
TurnIntoH6: {
|
|
310
|
+
shortcuts: "Mod-Alt-6",
|
|
311
|
+
command: (r) => {
|
|
312
|
+
const e = r.get(m);
|
|
313
|
+
return () => e.call(M.key, 3);
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
DowngradeHeading: {
|
|
317
|
+
shortcuts: ["Delete", "Backspace"],
|
|
318
|
+
command: (r) => {
|
|
319
|
+
const e = r.get(m);
|
|
320
|
+
return () => e.call(ke.key);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}), ye = k("blockquote"), z = y("blockquote", (r) => ({
|
|
324
|
+
content: "block+",
|
|
325
|
+
group: "block",
|
|
326
|
+
defining: !0,
|
|
327
|
+
parseDOM: [{ tag: "blockquote" }],
|
|
328
|
+
toDOM: (e) => ["blockquote", r.get(ye.key)(e), 0],
|
|
329
|
+
parseMarkdown: {
|
|
330
|
+
match: ({ type: e }) => e === "blockquote",
|
|
331
|
+
runner: (e, t, n) => {
|
|
332
|
+
e.openNode(n).next(t.children).closeNode();
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
toMarkdown: {
|
|
336
|
+
match: (e) => e.type.name === "blockquote",
|
|
337
|
+
runner: (e, t) => {
|
|
338
|
+
e.openNode("blockquote").next(t.content).closeNode();
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
})), at = I(() => V(/^\s*>\s$/, z.type())), Me = u("WrapInBlockquote", () => () => F(z.type())), st = f("blockquoteKeymap", {
|
|
342
|
+
WrapInBlockquote: {
|
|
343
|
+
shortcuts: "Mod-Shift-b",
|
|
344
|
+
command: (r) => {
|
|
345
|
+
const e = r.get(m);
|
|
346
|
+
return () => e.call(Me.key);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}), Ie = k("codeBlock", () => ({
|
|
350
|
+
pre: {},
|
|
351
|
+
code: {}
|
|
352
|
+
})), j = y("code_block", (r) => ({
|
|
353
|
+
content: "text*",
|
|
354
|
+
group: "block",
|
|
355
|
+
marks: "",
|
|
356
|
+
defining: !0,
|
|
357
|
+
code: !0,
|
|
358
|
+
attrs: {
|
|
359
|
+
language: {
|
|
360
|
+
default: ""
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
parseDOM: [
|
|
364
|
+
{
|
|
365
|
+
tag: "pre",
|
|
366
|
+
preserveWhitespace: "full",
|
|
367
|
+
getAttrs: (e) => {
|
|
368
|
+
if (!(e instanceof HTMLElement))
|
|
369
|
+
throw b(e);
|
|
370
|
+
return { language: e.dataset.language };
|
|
929
371
|
}
|
|
930
|
-
|
|
372
|
+
}
|
|
931
373
|
],
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
if (!l)
|
|
940
|
-
return {};
|
|
941
|
-
const { dom: s, onUpdate: c } = l;
|
|
942
|
-
return c(r), {
|
|
943
|
-
dom: s,
|
|
944
|
-
update: (f) => f.type.name !== B ? !1 : (r = f, c(r), !0),
|
|
945
|
-
selectNode: () => {
|
|
946
|
-
s.classList.add("ProseMirror-selectednode");
|
|
374
|
+
toDOM: (e) => {
|
|
375
|
+
const t = r.get(Ie.key)(e);
|
|
376
|
+
return [
|
|
377
|
+
"pre",
|
|
378
|
+
{
|
|
379
|
+
...t.pre,
|
|
380
|
+
"data-language": e.attrs.language
|
|
947
381
|
},
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
}
|
|
951
|
-
};
|
|
382
|
+
["code", t.code, 0]
|
|
383
|
+
];
|
|
952
384
|
},
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
if (!d.editable)
|
|
974
|
-
return;
|
|
975
|
-
l(d) ? (o.show(d), o.update(s(d))) : o.hide();
|
|
976
|
-
};
|
|
977
|
-
return o.init(n), c(n), {
|
|
978
|
-
update: (d, m) => {
|
|
979
|
-
(m == null ? void 0 : m.doc.eq(d.state.doc)) && m.selection.eq(d.state.selection) || c(d);
|
|
980
|
-
},
|
|
981
|
-
destroy: () => {
|
|
982
|
-
o.destroy();
|
|
983
|
-
}
|
|
984
|
-
};
|
|
985
|
-
}
|
|
986
|
-
})
|
|
987
|
-
]
|
|
988
|
-
})), Ne = "list_item", ie = I("SplitListItem"), ue = I("SinkListItem"), de = I("LiftListItem"), Mt = new H("MILKDOWN_KEEP_LIST_ORDER"), yt = (a) => {
|
|
989
|
-
const e = (t, r) => {
|
|
990
|
-
const n = We("ordered_list", t.schema);
|
|
991
|
-
let o = t.tr;
|
|
992
|
-
t.doc.descendants((l, s, c, i) => {
|
|
993
|
-
if (l.type === a && (c == null ? void 0 : c.type) === n) {
|
|
994
|
-
let u = !1;
|
|
995
|
-
const f = { ...l.attrs };
|
|
996
|
-
l.attrs.listType !== "ordered" && (f.listType = "ordered", u = !0);
|
|
997
|
-
const d = c == null ? void 0 : c.maybeChild(0);
|
|
998
|
-
d && d.type === a && d.attrs.listType === "ordered" && (f.label = `${i + 1}.`, u = !0), l.attrs.label === "\u2022" && (f.label = `${i + 1}.`, u = !0), u && (o = o.setNodeMarkup(s, void 0, f));
|
|
999
|
-
}
|
|
1000
|
-
}), r(o);
|
|
385
|
+
parseMarkdown: {
|
|
386
|
+
match: ({ type: e }) => e === "code",
|
|
387
|
+
runner: (e, t, n) => {
|
|
388
|
+
const o = t.lang, a = t.value;
|
|
389
|
+
e.openNode(n, { language: o }), a && e.addText(a), e.closeNode();
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
toMarkdown: {
|
|
393
|
+
match: (e) => e.type.name === "code_block",
|
|
394
|
+
runner: (e, t) => {
|
|
395
|
+
var n;
|
|
396
|
+
e.addNode("code", void 0, ((n = t.content.firstChild) == null ? void 0 : n.text) || "", {
|
|
397
|
+
lang: t.attrs.language
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
})), lt = I(() => ee(/^```(?<language>[a-z]*)?[\s\n]$/, j.type(), (r) => {
|
|
402
|
+
var e;
|
|
403
|
+
return {
|
|
404
|
+
language: ((e = r.groups) == null ? void 0 : e.language) ?? ""
|
|
1001
405
|
};
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
}), o;
|
|
406
|
+
})), be = u("CreateCodeBlock", () => (r = "") => S(j.type(), { language: r })), lr = u("UpdateCodeBlockLanguage", () => ({ pos: r, language: e } = { pos: -1, language: "" }) => (t, n) => r >= 0 ? (n == null || n(t.tr.setNodeAttribute(r, "language", e)), !0) : !1), ct = f("codeBlockKeymap", {
|
|
407
|
+
CreateCodeBlock: {
|
|
408
|
+
shortcuts: "Mod-Alt-c",
|
|
409
|
+
command: (r) => {
|
|
410
|
+
const e = r.get(m);
|
|
411
|
+
return () => e.call(be.key);
|
|
1009
412
|
}
|
|
1010
|
-
}
|
|
1011
|
-
},
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
listType: e.dataset["list-type"],
|
|
1037
|
-
spread: e.dataset.spread
|
|
1038
|
-
};
|
|
1039
|
-
},
|
|
1040
|
-
contentElement: (e) => {
|
|
1041
|
-
if (!(e instanceof HTMLElement))
|
|
1042
|
-
throw x(e);
|
|
1043
|
-
const t = e.querySelector(".list-item_body");
|
|
1044
|
-
return t || e;
|
|
1045
|
-
}
|
|
1046
|
-
},
|
|
1047
|
-
{ tag: "li" }
|
|
1048
|
-
],
|
|
1049
|
-
toDOM: (e) => [
|
|
1050
|
-
"li",
|
|
1051
|
-
{
|
|
1052
|
-
class: a.getClassName(e.attrs, "list-item"),
|
|
1053
|
-
"data-label": e.attrs.label,
|
|
1054
|
-
"data-list-type": e.attrs.listType,
|
|
1055
|
-
"data-spread": e.attrs.spread
|
|
1056
|
-
},
|
|
1057
|
-
["div", { class: a.getClassName(e.attrs, "list-item_label") }, e.attrs.label],
|
|
1058
|
-
["div", { class: a.getClassName(e.attrs, "list-item_body") }, 0]
|
|
1059
|
-
],
|
|
1060
|
-
parseMarkdown: {
|
|
1061
|
-
match: ({ type: e, checked: t }) => e === "listItem" && t === null,
|
|
1062
|
-
runner: (e, t, r) => {
|
|
1063
|
-
const n = t.label != null ? `${t.label}.` : "\u2022", o = t.label != null ? "ordered" : "bullet", l = t.spread != null ? `${t.spread}` : "true";
|
|
1064
|
-
e.openNode(r, { label: n, listType: o, spread: l }), e.next(t.children), e.closeNode();
|
|
1065
|
-
}
|
|
1066
|
-
},
|
|
1067
|
-
toMarkdown: {
|
|
1068
|
-
match: (e) => e.type.name === Ne,
|
|
1069
|
-
runner: (e, t) => {
|
|
1070
|
-
e.openNode("listItem", void 0, { spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
|
|
413
|
+
}
|
|
414
|
+
}), we = k("image"), $ = y("image", (r) => ({
|
|
415
|
+
inline: !0,
|
|
416
|
+
group: "inline",
|
|
417
|
+
selectable: !0,
|
|
418
|
+
draggable: !0,
|
|
419
|
+
marks: "",
|
|
420
|
+
atom: !0,
|
|
421
|
+
defining: !0,
|
|
422
|
+
isolating: !0,
|
|
423
|
+
attrs: {
|
|
424
|
+
src: { default: "" },
|
|
425
|
+
alt: { default: "" },
|
|
426
|
+
title: { default: "" }
|
|
427
|
+
},
|
|
428
|
+
parseDOM: [
|
|
429
|
+
{
|
|
430
|
+
tag: "img[src]",
|
|
431
|
+
getAttrs: (e) => {
|
|
432
|
+
if (!(e instanceof HTMLElement))
|
|
433
|
+
throw b(e);
|
|
434
|
+
return {
|
|
435
|
+
src: e.getAttribute("src") || "",
|
|
436
|
+
alt: e.getAttribute("alt") || "",
|
|
437
|
+
title: e.getAttribute("title") || e.getAttribute("alt") || ""
|
|
438
|
+
};
|
|
1071
439
|
}
|
|
1072
440
|
}
|
|
1073
|
-
}),
|
|
1074
|
-
inputRules: (e) => [K(/^\s*([-+*])\s$/, e)],
|
|
1075
|
-
commands: (e) => [
|
|
1076
|
-
N(ie, () => je(e)),
|
|
1077
|
-
N(ue, () => ze(e)),
|
|
1078
|
-
N(de, () => Ue(e))
|
|
1079
441
|
],
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
442
|
+
toDOM: (e) => ["img", { ...r.get(we.key)(e), ...e.attrs }],
|
|
443
|
+
parseMarkdown: {
|
|
444
|
+
match: ({ type: e }) => e === "image",
|
|
445
|
+
runner: (e, t, n) => {
|
|
446
|
+
const o = t.url, a = t.alt, s = t.title;
|
|
447
|
+
e.addNode(n, {
|
|
448
|
+
src: o,
|
|
449
|
+
alt: a,
|
|
450
|
+
title: s
|
|
451
|
+
});
|
|
452
|
+
}
|
|
1084
453
|
},
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
454
|
+
toMarkdown: {
|
|
455
|
+
match: (e) => e.type.name === "image",
|
|
456
|
+
runner: (e, t) => {
|
|
457
|
+
e.addNode("image", void 0, void 0, {
|
|
458
|
+
title: t.attrs.title,
|
|
459
|
+
url: t.attrs.src,
|
|
460
|
+
alt: t.attrs.alt
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
})), it = u("InsertImage", () => (r = {}) => (e, t) => {
|
|
465
|
+
if (!t)
|
|
466
|
+
return !0;
|
|
467
|
+
const { src: n = "", alt: o = "", title: a = "" } = r, s = $.type().create({ src: n, alt: o, title: a });
|
|
468
|
+
return s && t(e.tr.replaceSelectionWith(s).scrollIntoView()), !0;
|
|
469
|
+
}), dt = u("UpdateImage", () => (r = {}) => (e, t) => {
|
|
470
|
+
const n = We(e.selection, $.type());
|
|
471
|
+
if (!n)
|
|
472
|
+
return !1;
|
|
473
|
+
const { node: o, pos: a } = n, s = { ...o.attrs }, { src: l, alt: c, title: i } = r;
|
|
474
|
+
return l !== void 0 && (s.src = l), c !== void 0 && (s.alt = c), i !== void 0 && (s.title = i), t == null || t(e.tr.setNodeMarkup(a, void 0, s).scrollIntoView()), !0;
|
|
475
|
+
}), cr = I(() => new te(
|
|
476
|
+
/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,
|
|
477
|
+
(r, e, t, n) => {
|
|
478
|
+
const [o, a, s = "", l] = e;
|
|
479
|
+
return o ? r.tr.replaceWith(t, n, $.type().create({ src: s, alt: a, title: l })) : null;
|
|
480
|
+
}
|
|
481
|
+
)), Ne = k("hardbreak", (r) => ({
|
|
482
|
+
"data-is-inline": r.attrs.isInline
|
|
483
|
+
})), x = y("hardbreak", (r) => ({
|
|
484
|
+
inline: !0,
|
|
485
|
+
group: "inline",
|
|
486
|
+
attrs: {
|
|
487
|
+
isInline: {
|
|
488
|
+
default: !1
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
selectable: !1,
|
|
492
|
+
parseDOM: [{ tag: "br" }],
|
|
493
|
+
toDOM: (e) => ["br", r.get(Ne.key)(e)],
|
|
494
|
+
parseMarkdown: {
|
|
495
|
+
match: ({ type: e }) => e === "break",
|
|
496
|
+
runner: (e, t, n) => {
|
|
497
|
+
var o;
|
|
498
|
+
e.addNode(n, { isInline: Boolean((o = t.data) == null ? void 0 : o.isInline) });
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
toMarkdown: {
|
|
502
|
+
match: (e) => e.type.name === "hardbreak",
|
|
503
|
+
runner: (e, t) => {
|
|
504
|
+
t.attrs.isInline ? e.addNode("text", void 0, `
|
|
505
|
+
`) : e.addNode("break");
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
})), Ce = u("InsertHardbreak", () => () => (r, e) => {
|
|
509
|
+
var o;
|
|
510
|
+
const { selection: t, tr: n } = r;
|
|
511
|
+
if (t.empty) {
|
|
512
|
+
const a = t.$from.node();
|
|
513
|
+
if (a.childCount > 0 && ((o = a.lastChild) == null ? void 0 : o.type.name) === "hardbreak")
|
|
514
|
+
return e == null || e(
|
|
515
|
+
n.replaceRangeWith(t.to - 1, t.to, r.schema.node("paragraph")).setSelection(ne.near(n.doc.resolve(t.to))).scrollIntoView()
|
|
516
|
+
), !0;
|
|
517
|
+
}
|
|
518
|
+
return e == null || e(n.setMeta("hardbreak", !0).replaceSelectionWith(x.type().create()).scrollIntoView()), !0;
|
|
519
|
+
}), ut = f("hardbreakKeymap", {
|
|
520
|
+
InsertHardbreak: {
|
|
521
|
+
shortcuts: "Shift-Enter",
|
|
522
|
+
command: (r) => {
|
|
523
|
+
const e = r.get(m);
|
|
524
|
+
return () => e.call(Ce.key);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}), Ae = k("hr"), U = y("hr", (r) => ({
|
|
528
|
+
group: "block",
|
|
529
|
+
parseDOM: [{ tag: "hr" }],
|
|
530
|
+
toDOM: (e) => ["hr", r.get(Ae.key)(e)],
|
|
531
|
+
parseMarkdown: {
|
|
532
|
+
match: ({ type: e }) => e === "thematicBreak",
|
|
533
|
+
runner: (e, t, n) => {
|
|
534
|
+
e.addNode(n);
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
toMarkdown: {
|
|
538
|
+
match: (e) => e.type.name === "hr",
|
|
539
|
+
runner: (e) => {
|
|
540
|
+
e.addNode("thematicBreak");
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
})), pt = I(() => new te(
|
|
544
|
+
/^(?:---|___\s|\*\*\*\s)$/,
|
|
545
|
+
(r, e, t, n) => {
|
|
546
|
+
const { tr: o } = r;
|
|
547
|
+
return e[0] && o.replaceWith(t - 1, n, U.type().create()), o;
|
|
548
|
+
}
|
|
549
|
+
)), mt = u("InsertHr", () => () => (r, e) => {
|
|
550
|
+
if (!e)
|
|
551
|
+
return !0;
|
|
552
|
+
const t = L.node.type().create(), { tr: n, selection: o } = r, { from: a } = o, s = U.type().create();
|
|
553
|
+
if (!s)
|
|
554
|
+
return !0;
|
|
555
|
+
const l = n.replaceSelectionWith(s).insert(a, t), c = ne.findFrom(l.doc.resolve(a), 1, !0);
|
|
556
|
+
return c && e(l.setSelection(c).scrollIntoView()), !0;
|
|
557
|
+
}), ve = k("bulletList"), Y = y("bullet_list", (r) => ({
|
|
558
|
+
content: "listItem+",
|
|
559
|
+
group: "block",
|
|
560
|
+
attrs: {
|
|
561
|
+
spread: {
|
|
562
|
+
default: !1
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
parseDOM: [
|
|
566
|
+
{
|
|
567
|
+
tag: "ul",
|
|
568
|
+
getAttrs: (e) => {
|
|
569
|
+
if (!(e instanceof HTMLElement))
|
|
570
|
+
throw b(e);
|
|
571
|
+
return {
|
|
572
|
+
spread: e.dataset.spread
|
|
573
|
+
};
|
|
1097
574
|
}
|
|
575
|
+
}
|
|
576
|
+
],
|
|
577
|
+
toDOM: (e) => [
|
|
578
|
+
"ul",
|
|
579
|
+
{
|
|
580
|
+
...r.get(ve.key)(e),
|
|
581
|
+
"data-spread": e.attrs.spread
|
|
1098
582
|
},
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
583
|
+
0
|
|
584
|
+
],
|
|
585
|
+
parseMarkdown: {
|
|
586
|
+
match: ({ type: e, ordered: t }) => e === "list" && !t,
|
|
587
|
+
runner: (e, t, n) => {
|
|
588
|
+
const o = t.spread != null ? `${t.spread}` : "false";
|
|
589
|
+
e.openNode(n, { spread: o }).next(t.children).closeNode();
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
toMarkdown: {
|
|
593
|
+
match: (e) => e.type.name === "bullet_list",
|
|
594
|
+
runner: (e, t) => {
|
|
595
|
+
e.openNode("list", void 0, { ordered: !1, spread: t.attrs.spread === "true" }).next(t.content).closeNode();
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
})), gt = I(() => V(/^\s*([-+*])\s$/, Y.type())), xe = u("WrapInBulletList", () => () => F(Y.type())), ft = f("bulletListKeymap", {
|
|
599
|
+
WrapInBulletList: {
|
|
600
|
+
shortcuts: "Mod-Alt-8",
|
|
601
|
+
command: (r) => {
|
|
602
|
+
const e = r.get(m);
|
|
603
|
+
return () => e.call(xe.key);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}), Se = k("orderedList"), E = y("ordered_list", (r) => ({
|
|
607
|
+
content: "listItem+",
|
|
608
|
+
group: "block",
|
|
609
|
+
attrs: {
|
|
610
|
+
order: {
|
|
611
|
+
default: 1
|
|
1127
612
|
},
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
613
|
+
spread: {
|
|
614
|
+
default: !1
|
|
615
|
+
}
|
|
616
|
+
},
|
|
617
|
+
parseDOM: [
|
|
618
|
+
{
|
|
619
|
+
tag: "ol",
|
|
620
|
+
getAttrs: (e) => {
|
|
621
|
+
if (!(e instanceof HTMLElement))
|
|
622
|
+
throw b(e);
|
|
623
|
+
return {
|
|
624
|
+
spread: e.dataset.spread,
|
|
625
|
+
order: e.hasAttribute("start") ? Number(e.getAttribute("start")) : 1
|
|
626
|
+
};
|
|
1132
627
|
}
|
|
1133
628
|
}
|
|
1134
|
-
}),
|
|
1135
|
-
inputRules: (e) => [
|
|
1136
|
-
K(
|
|
1137
|
-
/^(\d+)\.\s$/,
|
|
1138
|
-
e,
|
|
1139
|
-
(t) => ({ order: Number(t[1]) }),
|
|
1140
|
-
(t, r) => r.childCount + r.attrs.order === Number(t[1])
|
|
1141
|
-
)
|
|
1142
629
|
],
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
schema: () => ({
|
|
1150
|
-
content: "inline*",
|
|
1151
|
-
group: "block",
|
|
1152
|
-
parseDOM: [{ tag: "p" }],
|
|
1153
|
-
toDOM: (e) => ["p", { class: a.getClassName(e.attrs, be) }, 0],
|
|
1154
|
-
parseMarkdown: {
|
|
1155
|
-
match: (e) => e.type === "paragraph",
|
|
1156
|
-
runner: (e, t, r) => {
|
|
1157
|
-
e.openNode(r), t.children ? e.next(t.children) : e.addText(t.value), e.closeNode();
|
|
1158
|
-
}
|
|
630
|
+
toDOM: (e) => [
|
|
631
|
+
"ol",
|
|
632
|
+
{
|
|
633
|
+
...r.get(Se.key)(e),
|
|
634
|
+
...e.attrs.order === 1 ? {} : e.attrs.order,
|
|
635
|
+
"data-spread": e.attrs.spread
|
|
1159
636
|
},
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
}
|
|
637
|
+
0
|
|
638
|
+
],
|
|
639
|
+
parseMarkdown: {
|
|
640
|
+
match: ({ type: e, ordered: t }) => e === "list" && !!t,
|
|
641
|
+
runner: (e, t, n) => {
|
|
642
|
+
const o = t.spread != null ? `${t.spread}` : "true";
|
|
643
|
+
e.openNode(n, { spread: o }).next(t.children).closeNode();
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
toMarkdown: {
|
|
647
|
+
match: (e) => e.type.name === "ordered_list",
|
|
648
|
+
runner: (e, t) => {
|
|
649
|
+
e.openNode("list", void 0, { ordered: !0, start: 1, spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
|
|
1173
650
|
}
|
|
1174
|
-
}),
|
|
1175
|
-
commands: (e) => [N(me, () => A(e))],
|
|
1176
|
-
shortcuts: {
|
|
1177
|
-
[y.Text]: M(me, "Mod-Alt-0")
|
|
1178
651
|
}
|
|
1179
|
-
})),
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
match: (a) => a.type.name === "text",
|
|
1191
|
-
runner: (a, e) => {
|
|
1192
|
-
a.addNode("text", void 0, e.text);
|
|
1193
|
-
}
|
|
652
|
+
})), ht = I(() => V(
|
|
653
|
+
/^\s*(\d+)\.\s$/,
|
|
654
|
+
E.type(),
|
|
655
|
+
(r) => ({ order: Number(r[1]) }),
|
|
656
|
+
(r, e) => e.childCount + e.attrs.order === Number(r[1])
|
|
657
|
+
)), Le = u("WrapInOrderedList", () => () => F(E.type())), kt = f("orderedListKeymap", {
|
|
658
|
+
WrapInOrderedList: {
|
|
659
|
+
shortcuts: "Mod-Alt-7",
|
|
660
|
+
command: (r) => {
|
|
661
|
+
const e = r.get(m);
|
|
662
|
+
return () => e.call(Le.key);
|
|
1194
663
|
}
|
|
1195
|
-
})
|
|
1196
|
-
})), Lt = [
|
|
1197
|
-
lt(),
|
|
1198
|
-
bt(),
|
|
1199
|
-
it(),
|
|
1200
|
-
tt(),
|
|
1201
|
-
at(),
|
|
1202
|
-
rt(),
|
|
1203
|
-
It(),
|
|
1204
|
-
Nt(),
|
|
1205
|
-
pt(),
|
|
1206
|
-
gt(),
|
|
1207
|
-
kt(),
|
|
1208
|
-
wt()
|
|
1209
|
-
], Ct = () => {
|
|
1210
|
-
function a(e) {
|
|
1211
|
-
Ge(e, "list", (t) => {
|
|
1212
|
-
var r;
|
|
1213
|
-
if (t.ordered) {
|
|
1214
|
-
const n = (r = t.start) != null ? r : 1;
|
|
1215
|
-
t.children.forEach((o, l) => {
|
|
1216
|
-
o.label = l + n;
|
|
1217
|
-
});
|
|
1218
|
-
}
|
|
1219
|
-
});
|
|
1220
664
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
665
|
+
}), Te = k("listItem"), D = y("list_item", (r) => ({
|
|
666
|
+
group: "listItem",
|
|
667
|
+
content: "paragraph block*",
|
|
668
|
+
attrs: {
|
|
669
|
+
label: {
|
|
670
|
+
default: "•"
|
|
671
|
+
},
|
|
672
|
+
listType: {
|
|
673
|
+
default: "bullet"
|
|
674
|
+
},
|
|
675
|
+
spread: {
|
|
676
|
+
default: "true"
|
|
677
|
+
}
|
|
678
|
+
},
|
|
679
|
+
defining: !0,
|
|
680
|
+
parseDOM: [
|
|
681
|
+
{
|
|
682
|
+
tag: "li",
|
|
683
|
+
getAttrs: (e) => {
|
|
684
|
+
if (!(e instanceof HTMLElement))
|
|
685
|
+
throw b(e);
|
|
686
|
+
return {
|
|
687
|
+
label: e.dataset.label,
|
|
688
|
+
listType: e.dataset["list-type"],
|
|
689
|
+
spread: e.dataset.spread
|
|
690
|
+
};
|
|
1238
691
|
}
|
|
1239
|
-
r.children = l;
|
|
1240
692
|
}
|
|
1241
|
-
|
|
693
|
+
],
|
|
694
|
+
toDOM: (e) => [
|
|
695
|
+
"li",
|
|
696
|
+
{
|
|
697
|
+
...r.get(Te.key)(e),
|
|
698
|
+
"data-label": e.attrs.label,
|
|
699
|
+
"data-list-type": e.attrs.listType,
|
|
700
|
+
"data-spread": e.attrs.spread
|
|
701
|
+
},
|
|
702
|
+
0
|
|
703
|
+
],
|
|
704
|
+
parseMarkdown: {
|
|
705
|
+
match: ({ type: e }) => e === "listItem",
|
|
706
|
+
runner: (e, t, n) => {
|
|
707
|
+
const o = t.label != null ? `${t.label}.` : "•", a = t.label != null ? "ordered" : "bullet", s = t.spread != null ? `${t.spread}` : "true";
|
|
708
|
+
e.openNode(n, { label: o, listType: a, spread: s }), e.next(t.children), e.closeNode();
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
toMarkdown: {
|
|
712
|
+
match: (e) => e.type.name === "list_item",
|
|
713
|
+
runner: (e, t) => {
|
|
714
|
+
e.openNode("listItem", void 0, { spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
|
|
715
|
+
}
|
|
1242
716
|
}
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
717
|
+
})), De = u("SinkListItem", () => () => qe(D.type())), Oe = u("SplitListItem", () => () => Fe(D.type())), _e = u("SplitListItem", () => () => Ve(D.type())), yt = f("listItemKeymap", {
|
|
718
|
+
NextListItem: {
|
|
719
|
+
shortcuts: "Enter",
|
|
720
|
+
command: (r) => {
|
|
721
|
+
const e = r.get(m);
|
|
722
|
+
return () => e.call(Oe.key);
|
|
723
|
+
}
|
|
724
|
+
},
|
|
725
|
+
SinkListItem: {
|
|
726
|
+
shortcuts: ["Tab", "Mod-]"],
|
|
727
|
+
command: (r) => {
|
|
728
|
+
const e = r.get(m);
|
|
729
|
+
return () => e.call(De.key);
|
|
730
|
+
}
|
|
731
|
+
},
|
|
732
|
+
LiftListItem: {
|
|
733
|
+
shortcuts: ["Shift-Tab", "Mod-["],
|
|
734
|
+
command: (r) => {
|
|
735
|
+
const e = r.get(m);
|
|
736
|
+
return () => e.call(_e.key);
|
|
737
|
+
}
|
|
1247
738
|
}
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
init() {
|
|
1255
|
-
return !1;
|
|
1256
|
-
},
|
|
1257
|
-
apply(t) {
|
|
1258
|
-
if (!t.selection.empty)
|
|
1259
|
-
return !1;
|
|
1260
|
-
const r = t.selection.$from, n = r.nodeBefore, o = r.nodeAfter;
|
|
1261
|
-
return !!(n && o && n.isInline && !n.isText && o.isInline && !o.isText);
|
|
1262
|
-
}
|
|
1263
|
-
},
|
|
1264
|
-
props: {
|
|
1265
|
-
handleDOMEvents: {
|
|
1266
|
-
compositionend: (t, r) => a ? (a = !1, requestAnimationFrame(() => {
|
|
1267
|
-
if (e.getState(t.state)) {
|
|
1268
|
-
const o = t.state.selection.from;
|
|
1269
|
-
r.preventDefault(), t.dispatch(t.state.tr.insertText(r.data || "", o));
|
|
1270
|
-
}
|
|
1271
|
-
}), !0) : !1,
|
|
1272
|
-
compositionstart: (t) => (e.getState(t.state) && (a = !0), !1),
|
|
1273
|
-
beforeinput: (t, r) => {
|
|
1274
|
-
if (e.getState(t.state) && r instanceof InputEvent && r.data && !a) {
|
|
1275
|
-
const o = t.state.selection.from;
|
|
1276
|
-
return r.preventDefault(), t.dispatch(t.state.tr.insertText(r.data || "", o)), !0;
|
|
1277
|
-
}
|
|
1278
|
-
return !1;
|
|
1279
|
-
}
|
|
1280
|
-
},
|
|
1281
|
-
decorations(t) {
|
|
1282
|
-
if (e.getState(t)) {
|
|
1283
|
-
const o = t.selection.$from.pos, l = document.createElement("span"), s = Z.widget(o, l, {
|
|
1284
|
-
side: -1
|
|
1285
|
-
}), c = document.createElement("span"), i = Z.widget(o, c);
|
|
1286
|
-
return setTimeout(() => {
|
|
1287
|
-
l.contentEditable = "true", c.contentEditable = "true";
|
|
1288
|
-
}), S.create(t.doc, [s, i]);
|
|
1289
|
-
}
|
|
1290
|
-
return S.empty;
|
|
1291
|
-
}
|
|
739
|
+
}), Mt = X("text", () => ({
|
|
740
|
+
group: "inline",
|
|
741
|
+
parseMarkdown: {
|
|
742
|
+
match: ({ type: r }) => r === "text",
|
|
743
|
+
runner: (r, e) => {
|
|
744
|
+
r.addText(e.value);
|
|
1292
745
|
}
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
746
|
+
},
|
|
747
|
+
toMarkdown: {
|
|
748
|
+
match: (r) => r.type.name === "text",
|
|
749
|
+
runner: (r, e) => {
|
|
750
|
+
r.addNode("text", void 0, e.text);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
})), It = [
|
|
754
|
+
Ze,
|
|
755
|
+
ge,
|
|
756
|
+
L,
|
|
757
|
+
G,
|
|
758
|
+
he,
|
|
759
|
+
T,
|
|
760
|
+
Ne,
|
|
761
|
+
x,
|
|
762
|
+
ye,
|
|
763
|
+
z,
|
|
764
|
+
Ie,
|
|
765
|
+
j,
|
|
766
|
+
Ae,
|
|
767
|
+
U,
|
|
768
|
+
we,
|
|
769
|
+
$,
|
|
770
|
+
ve,
|
|
771
|
+
Y,
|
|
772
|
+
Se,
|
|
773
|
+
E,
|
|
774
|
+
Te,
|
|
775
|
+
D,
|
|
776
|
+
ae,
|
|
777
|
+
se,
|
|
778
|
+
ce,
|
|
779
|
+
ie,
|
|
780
|
+
ue,
|
|
781
|
+
A,
|
|
782
|
+
me,
|
|
783
|
+
v,
|
|
784
|
+
Mt
|
|
785
|
+
].flat(), bt = [
|
|
786
|
+
at,
|
|
787
|
+
gt,
|
|
788
|
+
ht,
|
|
789
|
+
lt,
|
|
790
|
+
pt,
|
|
791
|
+
nt
|
|
792
|
+
].flat(), wt = [
|
|
793
|
+
fe,
|
|
794
|
+
Me,
|
|
795
|
+
M,
|
|
796
|
+
ke,
|
|
797
|
+
be,
|
|
798
|
+
Ce,
|
|
799
|
+
mt,
|
|
800
|
+
it,
|
|
801
|
+
dt,
|
|
802
|
+
Le,
|
|
803
|
+
xe,
|
|
804
|
+
De,
|
|
805
|
+
Oe,
|
|
806
|
+
_e,
|
|
807
|
+
le,
|
|
808
|
+
pe,
|
|
809
|
+
de,
|
|
810
|
+
Qe,
|
|
811
|
+
Xe
|
|
812
|
+
], Nt = [
|
|
813
|
+
st,
|
|
814
|
+
ct,
|
|
815
|
+
ut,
|
|
816
|
+
ot,
|
|
817
|
+
yt,
|
|
818
|
+
kt,
|
|
819
|
+
ft,
|
|
820
|
+
et,
|
|
821
|
+
Ue,
|
|
822
|
+
Je,
|
|
823
|
+
Ye
|
|
824
|
+
].flat(), B = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)/, Ct = (r) => new RegExp(`\\\\(?=[^\\w\\s${r}\\\\]|_)`, "g"), At = (r) => {
|
|
825
|
+
let e = r, t = e.match(B);
|
|
1297
826
|
for (; t && t.groups; ) {
|
|
1298
|
-
const { span:
|
|
1299
|
-
e = e.replace(
|
|
827
|
+
const { span: n } = t.groups;
|
|
828
|
+
e = e.replace(B, n), t = e.match(B);
|
|
1300
829
|
}
|
|
1301
830
|
return e;
|
|
1302
|
-
},
|
|
1303
|
-
const
|
|
1304
|
-
return
|
|
1305
|
-
},
|
|
1306
|
-
const t = e.indexOf(
|
|
1307
|
-
return
|
|
1308
|
-
},
|
|
1309
|
-
let
|
|
1310
|
-
return
|
|
1311
|
-
var
|
|
1312
|
-
if (
|
|
831
|
+
}, vt = (r, e, t) => {
|
|
832
|
+
const n = r.split(""), o = n[e];
|
|
833
|
+
return n[e] && n[t] && (n[e] = n[t], n[t] = o), n.join("").toString();
|
|
834
|
+
}, xt = (r) => (e) => e.replace(Ct(r), ""), St = (r) => (e) => {
|
|
835
|
+
const t = e.indexOf(r.hole), n = e.charAt(t - 1), o = e.charAt(t + 1), a = /[^\w]|_/;
|
|
836
|
+
return o ? n && a.test(n) && a.test(o) ? r.punctuation : r.char : r.punctuation;
|
|
837
|
+
}, Lt = (r, e, t) => {
|
|
838
|
+
let n = e, o = !1;
|
|
839
|
+
return r.descendants((a) => {
|
|
840
|
+
var s;
|
|
841
|
+
if (o)
|
|
1313
842
|
return !1;
|
|
1314
|
-
if (
|
|
1315
|
-
const
|
|
1316
|
-
if (
|
|
1317
|
-
return
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
}),
|
|
1321
|
-
},
|
|
843
|
+
if (a.isText) {
|
|
844
|
+
const l = (s = a.text) == null ? void 0 : s.indexOf(t);
|
|
845
|
+
if (l != null && l >= 0)
|
|
846
|
+
return o = !0, n += l, !1;
|
|
847
|
+
}
|
|
848
|
+
n += a.nodeSize;
|
|
849
|
+
}), n;
|
|
850
|
+
}, Tt = {
|
|
1322
851
|
placeholderConfig: {
|
|
1323
|
-
hole: "
|
|
1324
|
-
punctuation: "
|
|
1325
|
-
char: "
|
|
852
|
+
hole: "∅",
|
|
853
|
+
punctuation: "⁂",
|
|
854
|
+
char: "∴"
|
|
1326
855
|
},
|
|
1327
856
|
globalNodes: ["footnote_definition"],
|
|
1328
|
-
shouldSyncNode: ({ prevNode:
|
|
1329
|
-
movePlaceholder: (
|
|
857
|
+
shouldSyncNode: ({ prevNode: r, nextNode: e }) => r.inlineContent && e && r.type === e.type && !r.eq(e),
|
|
858
|
+
movePlaceholder: (r, e) => {
|
|
1330
859
|
const t = ["*", "_"];
|
|
1331
|
-
let
|
|
1332
|
-
for (; t.includes(e[
|
|
1333
|
-
e =
|
|
860
|
+
let n = e.indexOf(r);
|
|
861
|
+
for (; t.includes(e[n - 1] || "") && t.includes(e[n + 1] || ""); )
|
|
862
|
+
e = vt(e, n, n + 1), n = n + 1;
|
|
1334
863
|
return e;
|
|
1335
864
|
}
|
|
1336
|
-
},
|
|
1337
|
-
const { selection: e } =
|
|
865
|
+
}, O = P(Tt, "inlineSyncConfig"), Dt = (r) => {
|
|
866
|
+
const { selection: e } = r, { $from: t } = e;
|
|
1338
867
|
return t.node();
|
|
1339
|
-
},
|
|
1340
|
-
const
|
|
1341
|
-
return
|
|
1342
|
-
},
|
|
1343
|
-
const t =
|
|
868
|
+
}, Ot = (r, e, t, n) => {
|
|
869
|
+
const o = r.get(Re), a = e.schema.topNodeType.create(void 0, [t, ...n]);
|
|
870
|
+
return o(a);
|
|
871
|
+
}, _t = (r, e) => {
|
|
872
|
+
const t = r.get(O.key), n = t.placeholderConfig.hole, [o = "", ...a] = e.split(`
|
|
1344
873
|
|
|
1345
|
-
`),
|
|
1346
|
-
let c =
|
|
1347
|
-
const i =
|
|
1348
|
-
return c = c.replace(
|
|
874
|
+
`), s = (d) => t.movePlaceholder(n, d);
|
|
875
|
+
let c = Be(xt(n), s, At)(o);
|
|
876
|
+
const i = St(t.placeholderConfig)(c);
|
|
877
|
+
return c = c.replace(n, i), c = [c, ...a].join(`
|
|
1349
878
|
|
|
1350
879
|
`), [c, i];
|
|
1351
|
-
},
|
|
1352
|
-
const
|
|
1353
|
-
return
|
|
1354
|
-
},
|
|
1355
|
-
const { globalNodes: t } =
|
|
1356
|
-
return e.doc.descendants((
|
|
1357
|
-
if (t.includes(
|
|
1358
|
-
return
|
|
1359
|
-
}),
|
|
1360
|
-
},
|
|
880
|
+
}, Ht = (r, e) => {
|
|
881
|
+
const n = r.get(Pe)(e);
|
|
882
|
+
return n ? n.firstChild : null;
|
|
883
|
+
}, Kt = (r, e) => {
|
|
884
|
+
const { globalNodes: t } = r.get(O.key), n = [];
|
|
885
|
+
return e.doc.descendants((o) => {
|
|
886
|
+
if (t.includes(o.type.name) || t.includes(o.type))
|
|
887
|
+
return n.push(o), !1;
|
|
888
|
+
}), n;
|
|
889
|
+
}, $t = (r) => r.split(`
|
|
1361
890
|
|
|
1362
|
-
`)[0] || "",
|
|
891
|
+
`)[0] || "", He = (r, e) => {
|
|
1363
892
|
try {
|
|
1364
|
-
const t =
|
|
1365
|
-
return !
|
|
1366
|
-
var
|
|
1367
|
-
const
|
|
1368
|
-
|
|
893
|
+
const t = Kt(r, e), n = Dt(e), o = Ot(r, e, n, t), [a, s] = _t(r, o), l = Ht(r, a);
|
|
894
|
+
return !l || n.type !== l.type ? null : (l.attrs = { ...n.attrs }, l.descendants((c) => {
|
|
895
|
+
var p;
|
|
896
|
+
const d = c.marks.find((g) => g.type.name === "link");
|
|
897
|
+
d && ((p = c.text) == null ? void 0 : p.includes(s)) && d.attrs.href.includes(s) && (d.attrs.href = d.attrs.href.replace(s, ""));
|
|
1369
898
|
}), {
|
|
1370
|
-
text:
|
|
1371
|
-
prevNode:
|
|
1372
|
-
nextNode:
|
|
1373
|
-
placeholder:
|
|
899
|
+
text: $t(a),
|
|
900
|
+
prevNode: n,
|
|
901
|
+
nextNode: l,
|
|
902
|
+
placeholder: s
|
|
1374
903
|
});
|
|
1375
904
|
} catch {
|
|
1376
905
|
return null;
|
|
1377
906
|
}
|
|
1378
|
-
},
|
|
1379
|
-
const { placeholderConfig:
|
|
1380
|
-
let
|
|
1381
|
-
const c = t.apply(
|
|
907
|
+
}, Et = (r, e, t, n, o) => {
|
|
908
|
+
const { placeholderConfig: a } = r.get(O.key), s = a.hole;
|
|
909
|
+
let l = t.tr.setMeta(e, !0).insertText(s, t.selection.from);
|
|
910
|
+
const c = t.apply(l), i = He(r, c);
|
|
1382
911
|
if (!i)
|
|
1383
912
|
return;
|
|
1384
|
-
const { $from:
|
|
1385
|
-
|
|
1386
|
-
},
|
|
913
|
+
const { $from: d } = c.selection, p = d.before(), g = d.after(), h = Lt(i.nextNode, p, i.placeholder);
|
|
914
|
+
l = l.replaceWith(p, g, i.nextNode).setNodeMarkup(p, void 0, o).delete(h + 1, h + 2), l = l.setSelection(re.near(l.doc.resolve(h + 1))), n(l);
|
|
915
|
+
}, Bt = w((r) => {
|
|
1387
916
|
let e = null;
|
|
1388
|
-
|
|
1389
|
-
|
|
917
|
+
const t = new N("MILKDOWN_INLINE_SYNC");
|
|
918
|
+
return new C({
|
|
919
|
+
key: t,
|
|
1390
920
|
state: {
|
|
1391
921
|
init: () => null,
|
|
1392
|
-
apply: (
|
|
1393
|
-
var
|
|
1394
|
-
const
|
|
1395
|
-
if (!((
|
|
922
|
+
apply: (n, o, a, s) => {
|
|
923
|
+
var _;
|
|
924
|
+
const l = r.get(R);
|
|
925
|
+
if (!((_ = l.hasFocus) != null && _.call(l)) || !l.editable || !n.docChanged || n.getMeta(t))
|
|
1396
926
|
return null;
|
|
1397
|
-
const i =
|
|
927
|
+
const i = He(r, s);
|
|
1398
928
|
if (!i)
|
|
1399
929
|
return null;
|
|
1400
930
|
e && (cancelAnimationFrame(e), e = null);
|
|
1401
|
-
const { prevNode:
|
|
1402
|
-
return
|
|
931
|
+
const { prevNode: d, nextNode: p, text: g } = i, { shouldSyncNode: h } = r.get(O.key);
|
|
932
|
+
return h({ prevNode: d, nextNode: p, ctx: r, tr: n, text: g }) && (e = requestAnimationFrame(() => {
|
|
1403
933
|
e = null;
|
|
1404
|
-
const { dispatch:
|
|
1405
|
-
|
|
934
|
+
const { dispatch: $e, state: Ee } = r.get(R);
|
|
935
|
+
Et(r, t, Ee, $e, d.attrs);
|
|
1406
936
|
})), null;
|
|
1407
937
|
}
|
|
1408
938
|
}
|
|
1409
939
|
});
|
|
1410
|
-
},
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
}
|
|
940
|
+
}), Rt = W(() => () => (r) => {
|
|
941
|
+
oe(r, "list", (e) => {
|
|
942
|
+
if (e.ordered) {
|
|
943
|
+
const t = e.start ?? 1;
|
|
944
|
+
e.children.forEach((n, o) => {
|
|
945
|
+
n.label = o + t;
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
});
|
|
949
|
+
}), Pt = W(() => () => (r) => {
|
|
950
|
+
const e = /[\t ]*(?:\r?\n|\r)/g;
|
|
951
|
+
oe(r, "text", (t, n, o) => {
|
|
952
|
+
if (!t.value || typeof t.value != "string")
|
|
953
|
+
return;
|
|
954
|
+
const a = [];
|
|
955
|
+
let s = 0;
|
|
956
|
+
e.lastIndex = 0;
|
|
957
|
+
let l = e.exec(t.value);
|
|
958
|
+
for (; l; ) {
|
|
959
|
+
const i = l.index;
|
|
960
|
+
s !== i && a.push({ type: "text", value: t.value.slice(s, i) }), a.push({ type: "break", data: { isInline: !0 } }), s = i + l[0].length, l = e.exec(t.value);
|
|
961
|
+
}
|
|
962
|
+
if (!!(a.length > 0 && o && typeof n == "number"))
|
|
963
|
+
return s < t.value.length && a.push({ type: "text", value: t.value.slice(s) }), o.children.splice(n, 1, ...a), n + a.length;
|
|
964
|
+
});
|
|
965
|
+
}), Wt = W(() => je), qt = w(() => {
|
|
966
|
+
let r = !1;
|
|
967
|
+
const e = new N("MILKDOWN_INLINE_NODES_CURSOR"), t = new C({
|
|
968
|
+
key: e,
|
|
969
|
+
state: {
|
|
970
|
+
init() {
|
|
971
|
+
return !1;
|
|
972
|
+
},
|
|
973
|
+
apply(n) {
|
|
974
|
+
if (!n.selection.empty)
|
|
975
|
+
return !1;
|
|
976
|
+
const o = n.selection.$from, a = o.nodeBefore, s = o.nodeAfter;
|
|
977
|
+
return !!(a && s && a.isInline && !a.isText && s.isInline && !s.isText);
|
|
978
|
+
}
|
|
979
|
+
},
|
|
980
|
+
props: {
|
|
981
|
+
handleDOMEvents: {
|
|
982
|
+
compositionend: (n, o) => r ? (r = !1, requestAnimationFrame(() => {
|
|
983
|
+
if (t.getState(n.state)) {
|
|
984
|
+
const s = n.state.selection.from;
|
|
985
|
+
o.preventDefault(), n.dispatch(n.state.tr.insertText(o.data || "", s));
|
|
986
|
+
}
|
|
987
|
+
}), !0) : !1,
|
|
988
|
+
compositionstart: (n) => (t.getState(n.state) && (r = !0), !1),
|
|
989
|
+
beforeinput: (n, o) => {
|
|
990
|
+
if (t.getState(n.state) && o instanceof InputEvent && o.data && !r) {
|
|
991
|
+
const s = n.state.selection.from;
|
|
992
|
+
return o.preventDefault(), n.dispatch(n.state.tr.insertText(o.data || "", s)), !0;
|
|
993
|
+
}
|
|
994
|
+
return !1;
|
|
995
|
+
}
|
|
996
|
+
},
|
|
997
|
+
decorations(n) {
|
|
998
|
+
if (t.getState(n)) {
|
|
999
|
+
const s = n.selection.$from.pos, l = document.createElement("span"), c = J.widget(s, l, {
|
|
1000
|
+
side: -1
|
|
1001
|
+
}), i = document.createElement("span"), d = J.widget(s, i);
|
|
1002
|
+
return setTimeout(() => {
|
|
1003
|
+
l.contentEditable = "true", i.contentEditable = "true";
|
|
1004
|
+
}), Q.create(n.doc, [c, d]);
|
|
1005
|
+
}
|
|
1006
|
+
return Q.empty;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
return t;
|
|
1011
|
+
}), Ft = w(() => new C({
|
|
1012
|
+
key: new N("MILKDOWN_HARDBREAK_MARKS"),
|
|
1013
|
+
appendTransaction: (r, e, t) => {
|
|
1014
|
+
if (!r.length)
|
|
1015
|
+
return;
|
|
1016
|
+
const [n] = r;
|
|
1017
|
+
if (!n)
|
|
1018
|
+
return;
|
|
1019
|
+
const [o] = n.steps;
|
|
1020
|
+
if (n.getMeta("hardbreak")) {
|
|
1021
|
+
if (!(o instanceof Ge))
|
|
1022
|
+
return;
|
|
1023
|
+
const { from: l } = o;
|
|
1024
|
+
return t.tr.setNodeMarkup(l, x.type(), void 0, []);
|
|
1025
|
+
}
|
|
1026
|
+
if (o instanceof ze) {
|
|
1027
|
+
let l = t.tr;
|
|
1028
|
+
const { from: c, to: i } = o;
|
|
1029
|
+
return t.doc.nodesBetween(c, i, (d, p) => {
|
|
1030
|
+
d.type === x.type() && (l = l.setNodeMarkup(p, x.type(), void 0, []));
|
|
1031
|
+
}), l;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
})), Ke = P(["table", "code_block"], "hardbreakFilterNodes"), Vt = w((r) => {
|
|
1035
|
+
const e = r.get(Ke.key);
|
|
1036
|
+
return new C({
|
|
1037
|
+
key: new N("MILKDOWN_HARDBREAK_FILTER"),
|
|
1038
|
+
filterTransaction: (t, n) => {
|
|
1039
|
+
const o = t.getMeta("hardbreak"), [a] = t.steps;
|
|
1040
|
+
if (o && a) {
|
|
1041
|
+
const { from: s } = a, l = n.doc.resolve(s);
|
|
1042
|
+
let c = l.depth, i = !0;
|
|
1043
|
+
for (; c > 0; )
|
|
1044
|
+
e.includes(l.node(c).type.name) && (i = !1), c--;
|
|
1045
|
+
return i;
|
|
1046
|
+
}
|
|
1047
|
+
return !0;
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
}), Gt = w((r) => {
|
|
1051
|
+
const e = new N("MILKDOWN_HEADING_ID"), t = (n) => {
|
|
1052
|
+
if (n.composing || !n.editable)
|
|
1053
|
+
return;
|
|
1054
|
+
const o = r.get(G.key), a = n.state.tr.setMeta("addToHistory", !1);
|
|
1055
|
+
let s = !1;
|
|
1056
|
+
n.state.doc.descendants((l, c) => {
|
|
1057
|
+
if (l.type === T.type()) {
|
|
1058
|
+
if (l.textContent.trim().length === 0)
|
|
1059
|
+
return;
|
|
1060
|
+
const i = l.attrs, d = o(l);
|
|
1061
|
+
i.id !== d && (s = !0, a.setMeta(e, !0).setNodeMarkup(c, void 0, {
|
|
1062
|
+
...i,
|
|
1063
|
+
id: d
|
|
1064
|
+
}));
|
|
1065
|
+
}
|
|
1066
|
+
}), s && n.dispatch(a);
|
|
1067
|
+
};
|
|
1068
|
+
return new C({
|
|
1069
|
+
key: e,
|
|
1070
|
+
view: (n) => (t(n), {
|
|
1071
|
+
update: (o) => {
|
|
1072
|
+
t(o);
|
|
1073
|
+
}
|
|
1074
|
+
})
|
|
1075
|
+
});
|
|
1076
|
+
}), zt = w(() => {
|
|
1077
|
+
const r = (e, t) => {
|
|
1078
|
+
const n = E.type(), o = D.type();
|
|
1079
|
+
let a = e.tr;
|
|
1080
|
+
e.doc.descendants((s, l, c, i) => {
|
|
1081
|
+
if (s.type === o && (c == null ? void 0 : c.type) === n) {
|
|
1082
|
+
let d = !1;
|
|
1083
|
+
const p = { ...s.attrs };
|
|
1084
|
+
s.attrs.listType !== "ordered" && (p.listType = "ordered", d = !0);
|
|
1085
|
+
const g = c == null ? void 0 : c.maybeChild(0);
|
|
1086
|
+
g === s ? (p.label = "1.", d = !0) : (g == null ? void 0 : g.type) === o && g.attrs.listType === "ordered" ? (p.label = `${i + 1}.`, d = !0) : s.attrs.label === "•" && (p.label = `${i + 1}.`, d = !0), d && (a = a.setNodeMarkup(l, void 0, p));
|
|
1087
|
+
}
|
|
1088
|
+
}), t(a);
|
|
1089
|
+
};
|
|
1090
|
+
return new C({
|
|
1091
|
+
key: new N("MILKDOWN_KEEP_LIST_ORDER"),
|
|
1092
|
+
appendTransaction: (e, t, n) => {
|
|
1093
|
+
let o = null;
|
|
1094
|
+
return e.some((a) => a.docChanged) && r(n, (a) => {
|
|
1095
|
+
o = a;
|
|
1096
|
+
}), o;
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
}), jt = [
|
|
1100
|
+
O,
|
|
1101
|
+
Bt,
|
|
1102
|
+
Ft,
|
|
1103
|
+
Ke,
|
|
1104
|
+
Vt,
|
|
1105
|
+
qt,
|
|
1106
|
+
Rt,
|
|
1107
|
+
Wt,
|
|
1108
|
+
Pt,
|
|
1109
|
+
Gt,
|
|
1110
|
+
zt
|
|
1111
|
+
], ir = [It, bt, wt, Nt, jt].flat();
|
|
1436
1112
|
export {
|
|
1437
|
-
ye as
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
se as
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1113
|
+
ye as blockquoteAttr,
|
|
1114
|
+
st as blockquoteKeymap,
|
|
1115
|
+
z as blockquoteSchema,
|
|
1116
|
+
ve as bulletListAttr,
|
|
1117
|
+
ft as bulletListKeymap,
|
|
1118
|
+
Y as bulletListSchema,
|
|
1119
|
+
Ie as codeBlockAttr,
|
|
1120
|
+
ct as codeBlockKeymap,
|
|
1121
|
+
j as codeBlockSchema,
|
|
1122
|
+
wt as commands,
|
|
1123
|
+
ir as commonmark,
|
|
1124
|
+
be as createCodeBlockCommand,
|
|
1125
|
+
lt as createCodeBlockInputRule,
|
|
1126
|
+
Tt as defaultConfig,
|
|
1127
|
+
Ze as docSchema,
|
|
1128
|
+
ke as downgradeHeadingCommand,
|
|
1129
|
+
ae as emphasisAttr,
|
|
1130
|
+
Ue as emphasisKeymap,
|
|
1131
|
+
se as emphasisSchema,
|
|
1132
|
+
Ne as hardbreakAttr,
|
|
1133
|
+
Ft as hardbreakClearMarkPlugin,
|
|
1134
|
+
Ke as hardbreakFilterNodes,
|
|
1135
|
+
Vt as hardbreakFilterPlugin,
|
|
1136
|
+
ut as hardbreakKeymap,
|
|
1137
|
+
x as hardbreakSchema,
|
|
1138
|
+
he as headingAttr,
|
|
1139
|
+
G as headingIdGenerator,
|
|
1140
|
+
ot as headingKeymap,
|
|
1141
|
+
T as headingSchema,
|
|
1142
|
+
Ae as hrAttr,
|
|
1143
|
+
U as hrSchema,
|
|
1144
|
+
we as imageAttr,
|
|
1145
|
+
$ as imageSchema,
|
|
1146
|
+
ue as inlineCodeAttr,
|
|
1147
|
+
Je as inlineCodeKeymap,
|
|
1148
|
+
A as inlineCodeSchema,
|
|
1149
|
+
qt as inlineNodesCursorPlugin,
|
|
1150
|
+
O as inlineSyncConfig,
|
|
1151
|
+
Bt as inlineSyncPlugin,
|
|
1152
|
+
bt as inputrules,
|
|
1153
|
+
Ce as insertHardbreakCommand,
|
|
1154
|
+
mt as insertHrCommand,
|
|
1155
|
+
pt as insertHrInputRule,
|
|
1156
|
+
it as insertImageCommand,
|
|
1157
|
+
cr as insertImageInputRule,
|
|
1158
|
+
Nt as keymap,
|
|
1159
|
+
_e as liftListItemCommand,
|
|
1160
|
+
me as linkAttr,
|
|
1161
|
+
v as linkSchema,
|
|
1162
|
+
Te as listItemAttr,
|
|
1163
|
+
yt as listItemKeymap,
|
|
1164
|
+
D as listItemSchema,
|
|
1165
|
+
Se as orderedListAttr,
|
|
1166
|
+
kt as orderedListKeymap,
|
|
1167
|
+
E as orderedListSchema,
|
|
1168
|
+
ge as paragraphAttr,
|
|
1169
|
+
et as paragraphKeymap,
|
|
1170
|
+
L as paragraphSchema,
|
|
1171
|
+
jt as plugins,
|
|
1172
|
+
Rt as remarkAddOrderInListPlugin,
|
|
1173
|
+
Wt as remarkInlineLinkPlugin,
|
|
1174
|
+
Pt as remarkLineBreak,
|
|
1175
|
+
It as schema,
|
|
1176
|
+
De as sinkListItemCommand,
|
|
1177
|
+
Oe as splitListItemCommand,
|
|
1178
|
+
ce as strongAttr,
|
|
1179
|
+
Ye as strongKeymap,
|
|
1180
|
+
ie as strongSchema,
|
|
1181
|
+
Gt as syncHeadingIdPlugin,
|
|
1182
|
+
zt as syncListOrderPlugin,
|
|
1183
|
+
Mt as textSchema,
|
|
1184
|
+
le as toggleEmphasisCommand,
|
|
1185
|
+
pe as toggleInlineCodeCommand,
|
|
1186
|
+
Qe as toggleLinkCommand,
|
|
1187
|
+
de as toggleStrongCommand,
|
|
1188
|
+
fe as turnIntoTextCommand,
|
|
1189
|
+
lr as updateCodeBlockLanguageCommand,
|
|
1190
|
+
dt as updateImageCommand,
|
|
1191
|
+
Xe as updateLinkCommand,
|
|
1192
|
+
Me as wrapInBlockquoteCommand,
|
|
1193
|
+
at as wrapInBlockquoteInputRule,
|
|
1194
|
+
xe as wrapInBulletListCommand,
|
|
1195
|
+
gt as wrapInBulletListInputRule,
|
|
1196
|
+
M as wrapInHeadingCommand,
|
|
1197
|
+
nt as wrapInHeadingInputRule,
|
|
1198
|
+
Le as wrapInOrderedListCommand,
|
|
1199
|
+
ht as wrapInOrderedListInputRule
|
|
1485
1200
|
};
|
|
1486
1201
|
//# sourceMappingURL=index.es.js.map
|