@milkdown/preset-commonmark 7.0.0-next.6 → 7.0.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/lib/index.es.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { $markAttr as
|
|
2
|
-
import { commandsCtx as
|
|
3
|
-
import { toggleMark as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { expectDomTypeError as
|
|
6
|
-
import { textblockTypeInputRule as
|
|
7
|
-
import { TextSelection as
|
|
8
|
-
import { findSelectedNodeOfType as
|
|
9
|
-
import { sinkListItem as
|
|
10
|
-
import { ReplaceStep as
|
|
11
|
-
import { Decoration as
|
|
12
|
-
import { visit as
|
|
13
|
-
import
|
|
14
|
-
const
|
|
1
|
+
import { $markAttr as K, $markSchema as $, $command as m, $useKeymap as k, $node as te, $nodeAttr as y, $nodeSchema as M, $ctx as F, $inputRule as b, pipe as Pe, $prose as N, $remark as E } from "@milkdown/utils";
|
|
2
|
+
import { commandsCtx as g, editorViewCtx as q, serializerCtx as We, parserCtx as qe } from "@milkdown/core";
|
|
3
|
+
import { toggleMark as V, setBlockType as S, wrapIn as G } from "@milkdown/prose/commands";
|
|
4
|
+
import { Fragment as ne } from "@milkdown/prose/model";
|
|
5
|
+
import { expectDomTypeError as w } from "@milkdown/exception";
|
|
6
|
+
import { textblockTypeInputRule as re, wrappingInputRule as j, InputRule as oe } from "@milkdown/prose/inputrules";
|
|
7
|
+
import { TextSelection as ae, Selection as se, PluginKey as C, Plugin as x } from "@milkdown/prose/state";
|
|
8
|
+
import { findSelectedNodeOfType as Fe } from "@milkdown/prose";
|
|
9
|
+
import { sinkListItem as Ve, liftListItem as Ge, splitListItem as je } from "@milkdown/prose/schema-list";
|
|
10
|
+
import { ReplaceStep as ze, AddMarkStep as Ue } from "@milkdown/prose/transform";
|
|
11
|
+
import { Decoration as Z, DecorationSet as ee } from "@milkdown/prose/view";
|
|
12
|
+
import { visit as le } from "unist-util-visit";
|
|
13
|
+
import Ye from "remark-inline-links";
|
|
14
|
+
const ce = K("emphasis"), ie = $("emphasis", (n) => ({
|
|
15
15
|
inclusive: !1,
|
|
16
16
|
parseDOM: [
|
|
17
17
|
{ tag: "i" },
|
|
18
18
|
{ tag: "em" },
|
|
19
19
|
{ style: "font-style", getAttrs: (e) => e === "italic" }
|
|
20
20
|
],
|
|
21
|
-
toDOM: (e) => ["em",
|
|
21
|
+
toDOM: (e) => ["em", n.get(ce.key)(e)],
|
|
22
22
|
parseMarkdown: {
|
|
23
23
|
match: (e) => e.type === "emphasis",
|
|
24
|
-
runner: (e, t,
|
|
25
|
-
e.openMark(
|
|
24
|
+
runner: (e, t, r) => {
|
|
25
|
+
e.openMark(r), e.next(t.children), e.closeMark(r);
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
toMarkdown: {
|
|
@@ -31,26 +31,26 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
31
31
|
e.withMark(t, "emphasis");
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
})),
|
|
34
|
+
})), de = m("ToggleEmphasis", () => () => V(ie.type())), Je = k("emphasisKeymap", {
|
|
35
35
|
ToggleEmphasis: {
|
|
36
36
|
shortcuts: "Mod-i",
|
|
37
|
-
command: (
|
|
38
|
-
const e =
|
|
39
|
-
return () => e.call(
|
|
37
|
+
command: (n) => {
|
|
38
|
+
const e = n.get(g);
|
|
39
|
+
return () => e.call(de.key);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
}),
|
|
42
|
+
}), ue = K("strong"), pe = $("strong", (n) => ({
|
|
43
43
|
inclusive: !1,
|
|
44
44
|
parseDOM: [
|
|
45
45
|
{ tag: "b" },
|
|
46
46
|
{ tag: "strong" },
|
|
47
47
|
{ style: "font-style", getAttrs: (e) => e === "bold" }
|
|
48
48
|
],
|
|
49
|
-
toDOM: (e) => ["strong",
|
|
49
|
+
toDOM: (e) => ["strong", n.get(ue.key)(e)],
|
|
50
50
|
parseMarkdown: {
|
|
51
51
|
match: (e) => e.type === "strong",
|
|
52
|
-
runner: (e, t,
|
|
53
|
-
e.openMark(
|
|
52
|
+
runner: (e, t, r) => {
|
|
53
|
+
e.openMark(r), e.next(t.children), e.closeMark(r);
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
toMarkdown: {
|
|
@@ -59,49 +59,49 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
59
59
|
e.withMark(t, "strong");
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
})),
|
|
62
|
+
})), me = m("ToggleStrong", () => () => V(pe.type())), Qe = k("strongKeymap", {
|
|
63
63
|
ToggleBold: {
|
|
64
64
|
shortcuts: ["Mod-b"],
|
|
65
|
-
command: (
|
|
66
|
-
const e =
|
|
67
|
-
return () => e.call(
|
|
65
|
+
command: (n) => {
|
|
66
|
+
const e = n.get(g);
|
|
67
|
+
return () => e.call(me.key);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
}),
|
|
70
|
+
}), ge = K("inlineCode"), A = $("inlineCode", (n) => ({
|
|
71
71
|
priority: 100,
|
|
72
72
|
code: !0,
|
|
73
73
|
inclusive: !1,
|
|
74
74
|
parseDOM: [{ tag: "code" }],
|
|
75
|
-
toDOM: (e) => ["code",
|
|
75
|
+
toDOM: (e) => ["code", n.get(ge.key)(e)],
|
|
76
76
|
parseMarkdown: {
|
|
77
77
|
match: (e) => e.type === "inlineCode",
|
|
78
|
-
runner: (e, t,
|
|
79
|
-
e.openMark(
|
|
78
|
+
runner: (e, t, r) => {
|
|
79
|
+
e.openMark(r), e.addText(t.value), e.closeMark(r);
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
toMarkdown: {
|
|
83
83
|
match: (e) => e.type.name === "inlineCode",
|
|
84
|
-
runner: (e, t,
|
|
85
|
-
e.withMark(t, "inlineCode",
|
|
84
|
+
runner: (e, t, r) => {
|
|
85
|
+
e.withMark(t, "inlineCode", r.text || "");
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
})),
|
|
89
|
-
const { selection: t, tr:
|
|
88
|
+
})), fe = m("ToggleInlineCode", () => () => (n, e) => {
|
|
89
|
+
const { selection: t, tr: r } = n;
|
|
90
90
|
if (t.empty)
|
|
91
91
|
return !1;
|
|
92
92
|
const { from: o, to: a } = t;
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
}), e == null || e(
|
|
96
|
-
}),
|
|
93
|
+
return n.doc.rangeHasMark(o, a, A.type()) ? (e == null || e(r.removeMark(o, a, A.type())), !0) : (Object.keys(n.schema.marks).filter((c) => c !== A.type.name).map((c) => n.schema.marks[c]).forEach((c) => {
|
|
94
|
+
r.removeMark(o, a, c);
|
|
95
|
+
}), e == null || e(r.addMark(o, a, A.type().create())), !0);
|
|
96
|
+
}), Xe = k("inlineCodeKeymap", {
|
|
97
97
|
ToggleInlineCode: {
|
|
98
98
|
shortcuts: "Mod-e",
|
|
99
|
-
command: (
|
|
100
|
-
const e =
|
|
101
|
-
return () => e.call(
|
|
99
|
+
command: (n) => {
|
|
100
|
+
const e = n.get(g);
|
|
101
|
+
return () => e.call(fe.key);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
}),
|
|
104
|
+
}), he = K("link"), L = $("link", (n) => ({
|
|
105
105
|
attrs: {
|
|
106
106
|
href: {},
|
|
107
107
|
title: { default: null }
|
|
@@ -111,17 +111,17 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
111
111
|
tag: "a[href]",
|
|
112
112
|
getAttrs: (e) => {
|
|
113
113
|
if (!(e instanceof HTMLElement))
|
|
114
|
-
throw
|
|
114
|
+
throw w(e);
|
|
115
115
|
return { href: e.getAttribute("href"), title: e.getAttribute("title") };
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
],
|
|
119
|
-
toDOM: (e) => ["a", { ...
|
|
119
|
+
toDOM: (e) => ["a", { ...n.get(he.key)(e), ...e.attrs }],
|
|
120
120
|
parseMarkdown: {
|
|
121
121
|
match: (e) => e.type === "link",
|
|
122
|
-
runner: (e, t,
|
|
122
|
+
runner: (e, t, r) => {
|
|
123
123
|
const o = t.url, a = t.title;
|
|
124
|
-
e.openMark(
|
|
124
|
+
e.openMark(r, { href: o, title: a }), e.next(t.children), e.closeMark(r);
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
127
|
toMarkdown: {
|
|
@@ -133,46 +133,46 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
})),
|
|
136
|
+
})), Ze = m("ToggleLink", () => (n = {}) => V(L.type(), n)), et = m("UpdateLink", () => (n = {}) => (e, t) => {
|
|
137
137
|
if (!t)
|
|
138
138
|
return !1;
|
|
139
|
-
let
|
|
140
|
-
const { selection: a } = e, { from:
|
|
141
|
-
if (e.doc.nodesBetween(
|
|
142
|
-
if (
|
|
143
|
-
return
|
|
144
|
-
}), !
|
|
139
|
+
let r, o = -1;
|
|
140
|
+
const { selection: a } = e, { from: l, to: s } = a;
|
|
141
|
+
if (e.doc.nodesBetween(l, l === s ? s + 1 : s, (p, h) => {
|
|
142
|
+
if (L.type().isInSet(p.marks))
|
|
143
|
+
return r = p, o = h, !1;
|
|
144
|
+
}), !r)
|
|
145
145
|
return !1;
|
|
146
|
-
const c =
|
|
146
|
+
const c = r.marks.find(({ type: p }) => p === L.type());
|
|
147
147
|
if (!c)
|
|
148
148
|
return !1;
|
|
149
|
-
const i = o, d = o +
|
|
150
|
-
return
|
|
151
|
-
u.removeMark(i, d, c).addMark(i, d,
|
|
149
|
+
const i = o, d = o + r.nodeSize, { tr: u } = e, f = L.type().create({ ...c.attrs, ...n });
|
|
150
|
+
return f ? (t(
|
|
151
|
+
u.removeMark(i, d, c).addMark(i, d, f).setSelection(new ae(u.selection.$anchor)).scrollIntoView()
|
|
152
152
|
), !0) : !1;
|
|
153
|
-
}),
|
|
153
|
+
}), tt = te("doc", () => ({
|
|
154
154
|
content: "block+",
|
|
155
155
|
parseMarkdown: {
|
|
156
|
-
match: ({ type:
|
|
157
|
-
runner: (
|
|
158
|
-
|
|
156
|
+
match: ({ type: n }) => n === "root",
|
|
157
|
+
runner: (n, e, t) => {
|
|
158
|
+
n.injectRoot(e, t);
|
|
159
159
|
}
|
|
160
160
|
},
|
|
161
161
|
toMarkdown: {
|
|
162
|
-
match: (
|
|
163
|
-
runner: (
|
|
164
|
-
|
|
162
|
+
match: (n) => n.type.name === "doc",
|
|
163
|
+
runner: (n, e) => {
|
|
164
|
+
n.openNode("root"), n.next(e.content);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
})),
|
|
167
|
+
})), ke = y("paragraph"), T = M("paragraph", (n) => ({
|
|
168
168
|
content: "inline*",
|
|
169
169
|
group: "block",
|
|
170
170
|
parseDOM: [{ tag: "p" }],
|
|
171
|
-
toDOM: (e) => ["p",
|
|
171
|
+
toDOM: (e) => ["p", n.get(ke.key)(e), 0],
|
|
172
172
|
parseMarkdown: {
|
|
173
173
|
match: (e) => e.type === "paragraph",
|
|
174
|
-
runner: (e, t,
|
|
175
|
-
e.openNode(
|
|
174
|
+
runner: (e, t, r) => {
|
|
175
|
+
e.openNode(r), t.children ? e.next(t.children) : e.addText(t.value || ""), e.closeNode();
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
178
|
toMarkdown: {
|
|
@@ -181,24 +181,24 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
181
181
|
var o;
|
|
182
182
|
if (e.openNode("paragraph"), t.childCount >= 1 && ((o = t.lastChild) == null ? void 0 : o.type.name) === "hardbreak") {
|
|
183
183
|
const a = [];
|
|
184
|
-
t.content.forEach((
|
|
185
|
-
c !== t.childCount - 1 && a.push(
|
|
186
|
-
}), e.next(
|
|
184
|
+
t.content.forEach((l, s, c) => {
|
|
185
|
+
c !== t.childCount - 1 && a.push(l);
|
|
186
|
+
}), e.next(ne.fromArray(a));
|
|
187
187
|
} else
|
|
188
188
|
e.next(t.content);
|
|
189
189
|
e.closeNode();
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
})),
|
|
192
|
+
})), ye = m("TurnIntoText", () => () => S(T.type())), nt = k("paragraphKeymap", {
|
|
193
193
|
TurnIntoText: {
|
|
194
194
|
shortcuts: "Mod-Alt-0",
|
|
195
|
-
command: (
|
|
196
|
-
const e =
|
|
197
|
-
return () => e.call(
|
|
195
|
+
command: (n) => {
|
|
196
|
+
const e = n.get(g);
|
|
197
|
+
return () => e.call(ye.key);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
}),
|
|
201
|
-
const e =
|
|
200
|
+
}), rt = Array(6).fill(0).map((n, e) => e + 1), ot = (n) => n.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "-").toLowerCase().trim(), z = F(ot, "headingIdGenerator"), Me = y("heading"), D = M("heading", (n) => {
|
|
201
|
+
const e = n.get(z.key);
|
|
202
202
|
return {
|
|
203
203
|
content: "inline*",
|
|
204
204
|
group: "block",
|
|
@@ -211,123 +211,123 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
211
211
|
default: 1
|
|
212
212
|
}
|
|
213
213
|
},
|
|
214
|
-
parseDOM:
|
|
214
|
+
parseDOM: rt.map((t) => ({
|
|
215
215
|
tag: `h${t}`,
|
|
216
|
-
getAttrs: (
|
|
217
|
-
if (!(
|
|
218
|
-
throw
|
|
219
|
-
return { level: t, id:
|
|
216
|
+
getAttrs: (r) => {
|
|
217
|
+
if (!(r instanceof HTMLElement))
|
|
218
|
+
throw w(r);
|
|
219
|
+
return { level: t, id: r.id };
|
|
220
220
|
}
|
|
221
221
|
})),
|
|
222
222
|
toDOM: (t) => [
|
|
223
223
|
`h${t.attrs.level}`,
|
|
224
224
|
{
|
|
225
|
-
...
|
|
225
|
+
...n.get(Me.key)(t),
|
|
226
226
|
id: t.attrs.id || e(t)
|
|
227
227
|
},
|
|
228
228
|
0
|
|
229
229
|
],
|
|
230
230
|
parseMarkdown: {
|
|
231
231
|
match: ({ type: t }) => t === "heading",
|
|
232
|
-
runner: (t,
|
|
233
|
-
const a =
|
|
234
|
-
t.openNode(o, { level: a }), t.next(
|
|
232
|
+
runner: (t, r, o) => {
|
|
233
|
+
const a = r.depth;
|
|
234
|
+
t.openNode(o, { level: a }), t.next(r.children), t.closeNode();
|
|
235
235
|
}
|
|
236
236
|
},
|
|
237
237
|
toMarkdown: {
|
|
238
238
|
match: (t) => t.type.name === "heading",
|
|
239
|
-
runner: (t,
|
|
239
|
+
runner: (t, r) => {
|
|
240
240
|
var a;
|
|
241
|
-
if (t.openNode("heading", void 0, { depth:
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
i !==
|
|
245
|
-
}), t.next(
|
|
241
|
+
if (t.openNode("heading", void 0, { depth: r.attrs.level }), r.childCount >= 1 && ((a = r.lastChild) == null ? void 0 : a.type.name) === "hardbreak") {
|
|
242
|
+
const l = [];
|
|
243
|
+
r.content.forEach((s, c, i) => {
|
|
244
|
+
i !== r.childCount - 1 && l.push(s);
|
|
245
|
+
}), t.next(ne.fromArray(l));
|
|
246
246
|
} else
|
|
247
|
-
t.next(
|
|
247
|
+
t.next(r.content);
|
|
248
248
|
t.closeNode();
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
|
-
}),
|
|
253
|
-
var
|
|
254
|
-
const t = ((
|
|
252
|
+
}), at = b((n) => re(/^(?<hashes>#+)\s$/, D.type(), (e) => {
|
|
253
|
+
var l, s;
|
|
254
|
+
const t = ((s = (l = e.groups) == null ? void 0 : l.hashes) == null ? void 0 : s.length) || 0, r = n.get(q), { $from: o } = r.state.selection, a = o.node();
|
|
255
255
|
if (a.type.name === "heading") {
|
|
256
256
|
let c = Number(a.attrs.level) + Number(t);
|
|
257
257
|
return c > 6 && (c = 6), { level: c };
|
|
258
258
|
}
|
|
259
259
|
return { level: t };
|
|
260
|
-
})),
|
|
261
|
-
const { $from:
|
|
262
|
-
if (o.type !==
|
|
260
|
+
})), I = m("WrapInHeading", () => (n) => (n ?? (n = 1), n < 1 ? S(T.type()) : S(D.type(), { level: n }))), Ie = m("DowngradeHeading", () => () => (n, e, t) => {
|
|
261
|
+
const { $from: r } = n.selection, o = r.node();
|
|
262
|
+
if (o.type !== D.type() || !n.selection.empty || r.parentOffset !== 0)
|
|
263
263
|
return !1;
|
|
264
264
|
const a = o.attrs.level - 1;
|
|
265
265
|
return a ? (e == null || e(
|
|
266
|
-
|
|
266
|
+
n.tr.setNodeMarkup(n.selection.$from.before(), void 0, {
|
|
267
267
|
...o.attrs,
|
|
268
268
|
level: a
|
|
269
269
|
})
|
|
270
|
-
), !0) : S(
|
|
271
|
-
}),
|
|
270
|
+
), !0) : S(T.type())(n, e, t);
|
|
271
|
+
}), st = k("headingKeymap", {
|
|
272
272
|
TurnIntoH1: {
|
|
273
273
|
shortcuts: "Mod-Alt-1",
|
|
274
|
-
command: (
|
|
275
|
-
const e =
|
|
276
|
-
return () => e.call(
|
|
274
|
+
command: (n) => {
|
|
275
|
+
const e = n.get(g);
|
|
276
|
+
return () => e.call(I.key, 1);
|
|
277
277
|
}
|
|
278
278
|
},
|
|
279
279
|
TurnIntoH2: {
|
|
280
280
|
shortcuts: "Mod-Alt-2",
|
|
281
|
-
command: (
|
|
282
|
-
const e =
|
|
283
|
-
return () => e.call(
|
|
281
|
+
command: (n) => {
|
|
282
|
+
const e = n.get(g);
|
|
283
|
+
return () => e.call(I.key, 2);
|
|
284
284
|
}
|
|
285
285
|
},
|
|
286
286
|
TurnIntoH3: {
|
|
287
287
|
shortcuts: "Mod-Alt-3",
|
|
288
|
-
command: (
|
|
289
|
-
const e =
|
|
290
|
-
return () => e.call(
|
|
288
|
+
command: (n) => {
|
|
289
|
+
const e = n.get(g);
|
|
290
|
+
return () => e.call(I.key, 3);
|
|
291
291
|
}
|
|
292
292
|
},
|
|
293
293
|
TurnIntoH4: {
|
|
294
294
|
shortcuts: "Mod-Alt-4",
|
|
295
|
-
command: (
|
|
296
|
-
const e =
|
|
297
|
-
return () => e.call(
|
|
295
|
+
command: (n) => {
|
|
296
|
+
const e = n.get(g);
|
|
297
|
+
return () => e.call(I.key, 3);
|
|
298
298
|
}
|
|
299
299
|
},
|
|
300
300
|
TurnIntoH5: {
|
|
301
301
|
shortcuts: "Mod-Alt-5",
|
|
302
|
-
command: (
|
|
303
|
-
const e =
|
|
304
|
-
return () => e.call(
|
|
302
|
+
command: (n) => {
|
|
303
|
+
const e = n.get(g);
|
|
304
|
+
return () => e.call(I.key, 3);
|
|
305
305
|
}
|
|
306
306
|
},
|
|
307
307
|
TurnIntoH6: {
|
|
308
308
|
shortcuts: "Mod-Alt-6",
|
|
309
|
-
command: (
|
|
310
|
-
const e =
|
|
311
|
-
return () => e.call(
|
|
309
|
+
command: (n) => {
|
|
310
|
+
const e = n.get(g);
|
|
311
|
+
return () => e.call(I.key, 3);
|
|
312
312
|
}
|
|
313
313
|
},
|
|
314
314
|
DowngradeHeading: {
|
|
315
315
|
shortcuts: ["Delete", "Backspace"],
|
|
316
|
-
command: (
|
|
317
|
-
const e =
|
|
318
|
-
return () => e.call(
|
|
316
|
+
command: (n) => {
|
|
317
|
+
const e = n.get(g);
|
|
318
|
+
return () => e.call(Ie.key);
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
}),
|
|
321
|
+
}), be = y("blockquote"), U = M("blockquote", (n) => ({
|
|
322
322
|
content: "block+",
|
|
323
323
|
group: "block",
|
|
324
324
|
defining: !0,
|
|
325
325
|
parseDOM: [{ tag: "blockquote" }],
|
|
326
|
-
toDOM: (e) => ["blockquote",
|
|
326
|
+
toDOM: (e) => ["blockquote", n.get(be.key)(e), 0],
|
|
327
327
|
parseMarkdown: {
|
|
328
328
|
match: ({ type: e }) => e === "blockquote",
|
|
329
|
-
runner: (e, t,
|
|
330
|
-
e.openNode(
|
|
329
|
+
runner: (e, t, r) => {
|
|
330
|
+
e.openNode(r).next(t.children).closeNode();
|
|
331
331
|
}
|
|
332
332
|
},
|
|
333
333
|
toMarkdown: {
|
|
@@ -336,18 +336,18 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
336
336
|
e.openNode("blockquote").next(t.content).closeNode();
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
})),
|
|
339
|
+
})), lt = b(() => j(/^\s*>\s$/, U.type())), we = m("WrapInBlockquote", () => () => G(U.type())), ct = k("blockquoteKeymap", {
|
|
340
340
|
WrapInBlockquote: {
|
|
341
341
|
shortcuts: "Mod-Shift-b",
|
|
342
|
-
command: (
|
|
343
|
-
const e =
|
|
344
|
-
return () => e.call(
|
|
342
|
+
command: (n) => {
|
|
343
|
+
const e = n.get(g);
|
|
344
|
+
return () => e.call(we.key);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
}),
|
|
347
|
+
}), Ne = y("codeBlock", () => ({
|
|
348
348
|
pre: {},
|
|
349
349
|
code: {}
|
|
350
|
-
})),
|
|
350
|
+
})), Y = M("code_block", (n) => ({
|
|
351
351
|
content: "text*",
|
|
352
352
|
group: "block",
|
|
353
353
|
marks: "",
|
|
@@ -364,13 +364,13 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
364
364
|
preserveWhitespace: "full",
|
|
365
365
|
getAttrs: (e) => {
|
|
366
366
|
if (!(e instanceof HTMLElement))
|
|
367
|
-
throw
|
|
367
|
+
throw w(e);
|
|
368
368
|
return { language: e.dataset.language };
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
],
|
|
372
372
|
toDOM: (e) => {
|
|
373
|
-
const t =
|
|
373
|
+
const t = n.get(Ne.key)(e);
|
|
374
374
|
return [
|
|
375
375
|
"pre",
|
|
376
376
|
{
|
|
@@ -382,34 +382,34 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
382
382
|
},
|
|
383
383
|
parseMarkdown: {
|
|
384
384
|
match: ({ type: e }) => e === "code",
|
|
385
|
-
runner: (e, t,
|
|
385
|
+
runner: (e, t, r) => {
|
|
386
386
|
const o = t.lang, a = t.value;
|
|
387
|
-
e.openNode(
|
|
387
|
+
e.openNode(r, { language: o }), a && e.addText(a), e.closeNode();
|
|
388
388
|
}
|
|
389
389
|
},
|
|
390
390
|
toMarkdown: {
|
|
391
391
|
match: (e) => e.type.name === "code_block",
|
|
392
392
|
runner: (e, t) => {
|
|
393
|
-
var
|
|
394
|
-
e.addNode("code", void 0, ((
|
|
393
|
+
var r;
|
|
394
|
+
e.addNode("code", void 0, ((r = t.content.firstChild) == null ? void 0 : r.text) || "", {
|
|
395
395
|
lang: t.attrs.language
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
|
-
})),
|
|
399
|
+
})), it = b(() => re(/^```(?<language>[a-z]*)?[\s\n]$/, Y.type(), (n) => {
|
|
400
400
|
var e;
|
|
401
401
|
return {
|
|
402
|
-
language: ((e =
|
|
402
|
+
language: ((e = n.groups) == null ? void 0 : e.language) ?? ""
|
|
403
403
|
};
|
|
404
|
-
})),
|
|
404
|
+
})), Ce = m("CreateCodeBlock", () => (n = "") => S(Y.type(), { language: n })), fn = m("UpdateCodeBlockLanguage", () => ({ pos: n, language: e } = { pos: -1, language: "" }) => (t, r) => n >= 0 ? (r == null || r(t.tr.setNodeAttribute(n, "language", e)), !0) : !1), dt = k("codeBlockKeymap", {
|
|
405
405
|
CreateCodeBlock: {
|
|
406
406
|
shortcuts: "Mod-Alt-c",
|
|
407
|
-
command: (
|
|
408
|
-
const e =
|
|
409
|
-
return () => e.call(
|
|
407
|
+
command: (n) => {
|
|
408
|
+
const e = n.get(g);
|
|
409
|
+
return () => e.call(Ce.key);
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
}),
|
|
412
|
+
}), xe = y("image"), B = M("image", (n) => ({
|
|
413
413
|
inline: !0,
|
|
414
414
|
group: "inline",
|
|
415
415
|
selectable: !0,
|
|
@@ -428,7 +428,7 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
428
428
|
tag: "img[src]",
|
|
429
429
|
getAttrs: (e) => {
|
|
430
430
|
if (!(e instanceof HTMLElement))
|
|
431
|
-
throw
|
|
431
|
+
throw w(e);
|
|
432
432
|
return {
|
|
433
433
|
src: e.getAttribute("src") || "",
|
|
434
434
|
alt: e.getAttribute("alt") || "",
|
|
@@ -437,15 +437,15 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
439
|
],
|
|
440
|
-
toDOM: (e) => ["img", { ...
|
|
440
|
+
toDOM: (e) => ["img", { ...n.get(xe.key)(e), ...e.attrs }],
|
|
441
441
|
parseMarkdown: {
|
|
442
442
|
match: ({ type: e }) => e === "image",
|
|
443
|
-
runner: (e, t,
|
|
444
|
-
const o = t.url, a = t.alt,
|
|
445
|
-
e.addNode(
|
|
443
|
+
runner: (e, t, r) => {
|
|
444
|
+
const o = t.url, a = t.alt, l = t.title;
|
|
445
|
+
e.addNode(r, {
|
|
446
446
|
src: o,
|
|
447
447
|
alt: a,
|
|
448
|
-
title:
|
|
448
|
+
title: l
|
|
449
449
|
});
|
|
450
450
|
}
|
|
451
451
|
},
|
|
@@ -459,26 +459,26 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
459
459
|
});
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
|
-
})),
|
|
462
|
+
})), ut = m("InsertImage", () => (n = {}) => (e, t) => {
|
|
463
463
|
if (!t)
|
|
464
464
|
return !0;
|
|
465
|
-
const { src:
|
|
466
|
-
return
|
|
467
|
-
}),
|
|
468
|
-
const
|
|
469
|
-
if (!
|
|
465
|
+
const { src: r = "", alt: o = "", title: a = "" } = n, l = B.type().create({ src: r, alt: o, title: a });
|
|
466
|
+
return l && t(e.tr.replaceSelectionWith(l).scrollIntoView()), !0;
|
|
467
|
+
}), pt = m("UpdateImage", () => (n = {}) => (e, t) => {
|
|
468
|
+
const r = Fe(e.selection, B.type());
|
|
469
|
+
if (!r)
|
|
470
470
|
return !1;
|
|
471
|
-
const { node: o, pos: a } =
|
|
472
|
-
return
|
|
473
|
-
}),
|
|
471
|
+
const { node: o, pos: a } = r, l = { ...o.attrs }, { src: s, alt: c, title: i } = n;
|
|
472
|
+
return s !== void 0 && (l.src = s), c !== void 0 && (l.alt = c), i !== void 0 && (l.title = i), t == null || t(e.tr.setNodeMarkup(a, void 0, l).scrollIntoView()), !0;
|
|
473
|
+
}), hn = b(() => new oe(
|
|
474
474
|
/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,
|
|
475
|
-
(
|
|
476
|
-
const [o, a,
|
|
477
|
-
return o ?
|
|
475
|
+
(n, e, t, r) => {
|
|
476
|
+
const [o, a, l = "", s] = e;
|
|
477
|
+
return o ? n.tr.replaceWith(t, r, B.type().create({ src: l, alt: a, title: s })) : null;
|
|
478
478
|
}
|
|
479
|
-
)),
|
|
480
|
-
"data-is-inline":
|
|
481
|
-
})),
|
|
479
|
+
)), Ae = y("hardbreak", (n) => ({
|
|
480
|
+
"data-is-inline": n.attrs.isInline
|
|
481
|
+
})), v = M("hardbreak", (n) => ({
|
|
482
482
|
inline: !0,
|
|
483
483
|
group: "inline",
|
|
484
484
|
attrs: {
|
|
@@ -488,12 +488,12 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
488
488
|
},
|
|
489
489
|
selectable: !1,
|
|
490
490
|
parseDOM: [{ tag: "br" }],
|
|
491
|
-
toDOM: (e) => ["br",
|
|
491
|
+
toDOM: (e) => ["br", n.get(Ae.key)(e)],
|
|
492
492
|
parseMarkdown: {
|
|
493
493
|
match: ({ type: e }) => e === "break",
|
|
494
|
-
runner: (e, t,
|
|
494
|
+
runner: (e, t, r) => {
|
|
495
495
|
var o;
|
|
496
|
-
e.addNode(
|
|
496
|
+
e.addNode(r, { isInline: Boolean((o = t.data) == null ? void 0 : o.isInline) });
|
|
497
497
|
}
|
|
498
498
|
},
|
|
499
499
|
toMarkdown: {
|
|
@@ -503,33 +503,33 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
503
503
|
`) : e.addNode("break");
|
|
504
504
|
}
|
|
505
505
|
}
|
|
506
|
-
})),
|
|
506
|
+
})), Le = m("InsertHardbreak", () => () => (n, e) => {
|
|
507
507
|
var o;
|
|
508
|
-
const { selection: t, tr:
|
|
508
|
+
const { selection: t, tr: r } = n;
|
|
509
509
|
if (t.empty) {
|
|
510
510
|
const a = t.$from.node();
|
|
511
511
|
if (a.childCount > 0 && ((o = a.lastChild) == null ? void 0 : o.type.name) === "hardbreak")
|
|
512
512
|
return e == null || e(
|
|
513
|
-
|
|
513
|
+
r.replaceRangeWith(t.to - 1, t.to, n.schema.node("paragraph")).setSelection(se.near(r.doc.resolve(t.to))).scrollIntoView()
|
|
514
514
|
), !0;
|
|
515
515
|
}
|
|
516
|
-
return e == null || e(
|
|
517
|
-
}),
|
|
516
|
+
return e == null || e(r.setMeta("hardbreak", !0).replaceSelectionWith(v.type().create()).scrollIntoView()), !0;
|
|
517
|
+
}), mt = k("hardbreakKeymap", {
|
|
518
518
|
InsertHardbreak: {
|
|
519
519
|
shortcuts: "Shift-Enter",
|
|
520
|
-
command: (
|
|
521
|
-
const e =
|
|
522
|
-
return () => e.call(
|
|
520
|
+
command: (n) => {
|
|
521
|
+
const e = n.get(g);
|
|
522
|
+
return () => e.call(Le.key);
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
|
-
}),
|
|
525
|
+
}), ve = y("hr"), J = M("hr", (n) => ({
|
|
526
526
|
group: "block",
|
|
527
527
|
parseDOM: [{ tag: "hr" }],
|
|
528
|
-
toDOM: (e) => ["hr",
|
|
528
|
+
toDOM: (e) => ["hr", n.get(ve.key)(e)],
|
|
529
529
|
parseMarkdown: {
|
|
530
530
|
match: ({ type: e }) => e === "thematicBreak",
|
|
531
|
-
runner: (e, t,
|
|
532
|
-
e.addNode(
|
|
531
|
+
runner: (e, t, r) => {
|
|
532
|
+
e.addNode(r);
|
|
533
533
|
}
|
|
534
534
|
},
|
|
535
535
|
toMarkdown: {
|
|
@@ -538,21 +538,21 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
538
538
|
e.addNode("thematicBreak");
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
|
-
})),
|
|
541
|
+
})), gt = b(() => new oe(
|
|
542
542
|
/^(?:---|___\s|\*\*\*\s)$/,
|
|
543
|
-
(
|
|
544
|
-
const { tr: o } =
|
|
545
|
-
return e[0] && o.replaceWith(t - 1,
|
|
543
|
+
(n, e, t, r) => {
|
|
544
|
+
const { tr: o } = n;
|
|
545
|
+
return e[0] && o.replaceWith(t - 1, r, J.type().create()), o;
|
|
546
546
|
}
|
|
547
|
-
)),
|
|
547
|
+
)), ft = m("InsertHr", () => () => (n, e) => {
|
|
548
548
|
if (!e)
|
|
549
549
|
return !0;
|
|
550
|
-
const t =
|
|
551
|
-
if (!
|
|
550
|
+
const t = T.node.type().create(), { tr: r, selection: o } = n, { from: a } = o, l = J.type().create();
|
|
551
|
+
if (!l)
|
|
552
552
|
return !0;
|
|
553
|
-
const
|
|
554
|
-
return c && e(
|
|
555
|
-
}),
|
|
553
|
+
const s = r.replaceSelectionWith(l).insert(a, t), c = se.findFrom(s.doc.resolve(a), 1, !0);
|
|
554
|
+
return c && e(s.setSelection(c).scrollIntoView()), !0;
|
|
555
|
+
}), Se = y("bulletList"), R = M("bullet_list", (n) => ({
|
|
556
556
|
content: "listItem+",
|
|
557
557
|
group: "block",
|
|
558
558
|
attrs: {
|
|
@@ -565,7 +565,7 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
565
565
|
tag: "ul",
|
|
566
566
|
getAttrs: (e) => {
|
|
567
567
|
if (!(e instanceof HTMLElement))
|
|
568
|
-
throw
|
|
568
|
+
throw w(e);
|
|
569
569
|
return {
|
|
570
570
|
spread: e.dataset.spread
|
|
571
571
|
};
|
|
@@ -575,16 +575,16 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
575
575
|
toDOM: (e) => [
|
|
576
576
|
"ul",
|
|
577
577
|
{
|
|
578
|
-
...
|
|
578
|
+
...n.get(Se.key)(e),
|
|
579
579
|
"data-spread": e.attrs.spread
|
|
580
580
|
},
|
|
581
581
|
0
|
|
582
582
|
],
|
|
583
583
|
parseMarkdown: {
|
|
584
584
|
match: ({ type: e, ordered: t }) => e === "list" && !t,
|
|
585
|
-
runner: (e, t,
|
|
585
|
+
runner: (e, t, r) => {
|
|
586
586
|
const o = t.spread != null ? `${t.spread}` : "false";
|
|
587
|
-
e.openNode(
|
|
587
|
+
e.openNode(r, { spread: o }).next(t.children).closeNode();
|
|
588
588
|
}
|
|
589
589
|
},
|
|
590
590
|
toMarkdown: {
|
|
@@ -593,15 +593,15 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
593
593
|
e.openNode("list", void 0, { ordered: !1, spread: t.attrs.spread === "true" }).next(t.content).closeNode();
|
|
594
594
|
}
|
|
595
595
|
}
|
|
596
|
-
})),
|
|
596
|
+
})), ht = b(() => j(/^\s*([-+*])\s$/, R.type())), Te = m("WrapInBulletList", () => () => G(R.type())), kt = k("bulletListKeymap", {
|
|
597
597
|
WrapInBulletList: {
|
|
598
598
|
shortcuts: "Mod-Alt-8",
|
|
599
|
-
command: (
|
|
600
|
-
const e =
|
|
601
|
-
return () => e.call(
|
|
599
|
+
command: (n) => {
|
|
600
|
+
const e = n.get(g);
|
|
601
|
+
return () => e.call(Te.key);
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
|
-
}),
|
|
604
|
+
}), De = y("orderedList"), P = M("ordered_list", (n) => ({
|
|
605
605
|
content: "listItem+",
|
|
606
606
|
group: "block",
|
|
607
607
|
attrs: {
|
|
@@ -617,7 +617,7 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
617
617
|
tag: "ol",
|
|
618
618
|
getAttrs: (e) => {
|
|
619
619
|
if (!(e instanceof HTMLElement))
|
|
620
|
-
throw
|
|
620
|
+
throw w(e);
|
|
621
621
|
return {
|
|
622
622
|
spread: e.dataset.spread,
|
|
623
623
|
order: e.hasAttribute("start") ? Number(e.getAttribute("start")) : 1
|
|
@@ -628,7 +628,7 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
628
628
|
toDOM: (e) => [
|
|
629
629
|
"ol",
|
|
630
630
|
{
|
|
631
|
-
...
|
|
631
|
+
...n.get(De.key)(e),
|
|
632
632
|
...e.attrs.order === 1 ? {} : e.attrs.order,
|
|
633
633
|
"data-spread": e.attrs.spread
|
|
634
634
|
},
|
|
@@ -636,9 +636,9 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
636
636
|
],
|
|
637
637
|
parseMarkdown: {
|
|
638
638
|
match: ({ type: e, ordered: t }) => e === "list" && !!t,
|
|
639
|
-
runner: (e, t,
|
|
639
|
+
runner: (e, t, r) => {
|
|
640
640
|
const o = t.spread != null ? `${t.spread}` : "true";
|
|
641
|
-
e.openNode(
|
|
641
|
+
e.openNode(r, { spread: o }).next(t.children).closeNode();
|
|
642
642
|
}
|
|
643
643
|
},
|
|
644
644
|
toMarkdown: {
|
|
@@ -647,20 +647,20 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
647
647
|
e.openNode("list", void 0, { ordered: !0, start: 1, spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
|
-
})),
|
|
650
|
+
})), yt = b(() => j(
|
|
651
651
|
/^\s*(\d+)\.\s$/,
|
|
652
|
-
|
|
653
|
-
(
|
|
654
|
-
(
|
|
655
|
-
)),
|
|
652
|
+
P.type(),
|
|
653
|
+
(n) => ({ order: Number(n[1]) }),
|
|
654
|
+
(n, e) => e.childCount + e.attrs.order === Number(n[1])
|
|
655
|
+
)), Oe = m("WrapInOrderedList", () => () => G(P.type())), Mt = k("orderedListKeymap", {
|
|
656
656
|
WrapInOrderedList: {
|
|
657
657
|
shortcuts: "Mod-Alt-7",
|
|
658
|
-
command: (
|
|
659
|
-
const e =
|
|
660
|
-
return () => e.call(
|
|
658
|
+
command: (n) => {
|
|
659
|
+
const e = n.get(g);
|
|
660
|
+
return () => e.call(Oe.key);
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
|
-
}),
|
|
663
|
+
}), He = y("listItem"), O = M("list_item", (n) => ({
|
|
664
664
|
group: "listItem",
|
|
665
665
|
content: "paragraph block*",
|
|
666
666
|
attrs: {
|
|
@@ -680,7 +680,7 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
680
680
|
tag: "li",
|
|
681
681
|
getAttrs: (e) => {
|
|
682
682
|
if (!(e instanceof HTMLElement))
|
|
683
|
-
throw
|
|
683
|
+
throw w(e);
|
|
684
684
|
return {
|
|
685
685
|
label: e.dataset.label,
|
|
686
686
|
listType: e.dataset["list-type"],
|
|
@@ -692,7 +692,7 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
692
692
|
toDOM: (e) => [
|
|
693
693
|
"li",
|
|
694
694
|
{
|
|
695
|
-
...
|
|
695
|
+
...n.get(He.key)(e),
|
|
696
696
|
"data-label": e.attrs.label,
|
|
697
697
|
"data-list-type": e.attrs.listType,
|
|
698
698
|
"data-spread": e.attrs.spread
|
|
@@ -701,9 +701,9 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
701
701
|
],
|
|
702
702
|
parseMarkdown: {
|
|
703
703
|
match: ({ type: e }) => e === "listItem",
|
|
704
|
-
runner: (e, t,
|
|
705
|
-
const o = t.label != null ? `${t.label}.` : "•", a = t.label != null ? "ordered" : "bullet",
|
|
706
|
-
e.openNode(
|
|
704
|
+
runner: (e, t, r) => {
|
|
705
|
+
const o = t.label != null ? `${t.label}.` : "•", a = t.label != null ? "ordered" : "bullet", l = t.spread != null ? `${t.spread}` : "true";
|
|
706
|
+
e.openNode(r, { label: o, listType: a, spread: l }), e.next(t.children), e.closeNode();
|
|
707
707
|
}
|
|
708
708
|
},
|
|
709
709
|
toMarkdown: {
|
|
@@ -712,514 +712,526 @@ const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
|
712
712
|
e.openNode("listItem", void 0, { spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
|
-
})),
|
|
715
|
+
})), _e = m("SinkListItem", () => () => Ve(O.type())), Ke = m("SplitListItem", () => () => Ge(O.type())), $e = m("SplitListItem", () => () => je(O.type())), It = k("listItemKeymap", {
|
|
716
716
|
NextListItem: {
|
|
717
717
|
shortcuts: "Enter",
|
|
718
|
-
command: (
|
|
719
|
-
const e =
|
|
720
|
-
return () => e.call(
|
|
718
|
+
command: (n) => {
|
|
719
|
+
const e = n.get(g);
|
|
720
|
+
return () => e.call($e.key);
|
|
721
721
|
}
|
|
722
722
|
},
|
|
723
723
|
SinkListItem: {
|
|
724
724
|
shortcuts: ["Tab", "Mod-]"],
|
|
725
|
-
command: (
|
|
726
|
-
const e =
|
|
727
|
-
return () => e.call(
|
|
725
|
+
command: (n) => {
|
|
726
|
+
const e = n.get(g);
|
|
727
|
+
return () => e.call(_e.key);
|
|
728
728
|
}
|
|
729
729
|
},
|
|
730
730
|
LiftListItem: {
|
|
731
731
|
shortcuts: ["Shift-Tab", "Mod-["],
|
|
732
|
-
command: (
|
|
733
|
-
const e =
|
|
734
|
-
return () => e.call(
|
|
732
|
+
command: (n) => {
|
|
733
|
+
const e = n.get(g);
|
|
734
|
+
return () => e.call(Ke.key);
|
|
735
735
|
}
|
|
736
736
|
}
|
|
737
|
-
}),
|
|
737
|
+
}), bt = te("text", () => ({
|
|
738
738
|
group: "inline",
|
|
739
739
|
parseMarkdown: {
|
|
740
|
-
match: ({ type:
|
|
741
|
-
runner: (
|
|
742
|
-
|
|
740
|
+
match: ({ type: n }) => n === "text",
|
|
741
|
+
runner: (n, e) => {
|
|
742
|
+
n.addText(e.value);
|
|
743
743
|
}
|
|
744
744
|
},
|
|
745
745
|
toMarkdown: {
|
|
746
|
-
match: (
|
|
747
|
-
runner: (
|
|
748
|
-
|
|
746
|
+
match: (n) => n.type.name === "text",
|
|
747
|
+
runner: (n, e) => {
|
|
748
|
+
n.addNode("text", void 0, e.text);
|
|
749
749
|
}
|
|
750
750
|
}
|
|
751
|
-
})),
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
L,
|
|
755
|
-
G,
|
|
756
|
-
he,
|
|
751
|
+
})), wt = [
|
|
752
|
+
tt,
|
|
753
|
+
ke,
|
|
757
754
|
T,
|
|
758
|
-
Ne,
|
|
759
|
-
x,
|
|
760
|
-
ye,
|
|
761
|
-
j,
|
|
762
|
-
Ie,
|
|
763
755
|
z,
|
|
756
|
+
Me,
|
|
757
|
+
D,
|
|
764
758
|
Ae,
|
|
759
|
+
v,
|
|
760
|
+
be,
|
|
765
761
|
U,
|
|
766
|
-
|
|
767
|
-
E,
|
|
768
|
-
ve,
|
|
762
|
+
Ne,
|
|
769
763
|
Y,
|
|
770
|
-
|
|
764
|
+
ve,
|
|
765
|
+
J,
|
|
766
|
+
xe,
|
|
771
767
|
B,
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
768
|
+
Se,
|
|
769
|
+
R,
|
|
770
|
+
De,
|
|
771
|
+
P,
|
|
772
|
+
He,
|
|
773
|
+
O,
|
|
776
774
|
ce,
|
|
777
775
|
ie,
|
|
778
776
|
ue,
|
|
779
|
-
A,
|
|
780
777
|
pe,
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
778
|
+
ge,
|
|
779
|
+
A,
|
|
780
|
+
he,
|
|
781
|
+
L,
|
|
782
|
+
bt
|
|
783
|
+
].flat(), Nt = [
|
|
787
784
|
lt,
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
].flat(), wt = [
|
|
791
|
-
fe,
|
|
792
|
-
Me,
|
|
793
|
-
M,
|
|
794
|
-
ke,
|
|
795
|
-
be,
|
|
796
|
-
Ce,
|
|
797
|
-
pt,
|
|
785
|
+
ht,
|
|
786
|
+
yt,
|
|
798
787
|
it,
|
|
799
|
-
|
|
788
|
+
gt,
|
|
789
|
+
at
|
|
790
|
+
].flat(), Ct = [
|
|
791
|
+
ye,
|
|
792
|
+
we,
|
|
793
|
+
I,
|
|
794
|
+
Ie,
|
|
795
|
+
Ce,
|
|
800
796
|
Le,
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
797
|
+
ft,
|
|
798
|
+
ut,
|
|
799
|
+
pt,
|
|
804
800
|
Oe,
|
|
805
|
-
|
|
806
|
-
|
|
801
|
+
Te,
|
|
802
|
+
_e,
|
|
803
|
+
$e,
|
|
804
|
+
Ke,
|
|
807
805
|
de,
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
806
|
+
fe,
|
|
807
|
+
me,
|
|
808
|
+
Ze,
|
|
809
|
+
et
|
|
810
|
+
], xt = [
|
|
812
811
|
ct,
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
812
|
+
dt,
|
|
813
|
+
mt,
|
|
814
|
+
st,
|
|
815
|
+
It,
|
|
816
|
+
Mt,
|
|
816
817
|
kt,
|
|
817
|
-
|
|
818
|
-
et,
|
|
819
|
-
Ue,
|
|
818
|
+
nt,
|
|
820
819
|
Je,
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
820
|
+
Xe,
|
|
821
|
+
Qe
|
|
822
|
+
].flat(), W = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)/, At = (n) => new RegExp(`\\\\(?=[^\\w\\s${n}\\\\]|_)`, "g"), Lt = (n) => {
|
|
823
|
+
let e = n, t = e.match(W);
|
|
824
824
|
for (; t && t.groups; ) {
|
|
825
|
-
const { span:
|
|
826
|
-
e = e.replace(
|
|
825
|
+
const { span: r } = t.groups;
|
|
826
|
+
e = e.replace(W, r), t = e.match(W);
|
|
827
827
|
}
|
|
828
828
|
return e;
|
|
829
|
-
}, vt = (
|
|
830
|
-
const
|
|
831
|
-
return
|
|
832
|
-
},
|
|
833
|
-
const t = e.indexOf(
|
|
834
|
-
return o ?
|
|
835
|
-
},
|
|
836
|
-
let
|
|
837
|
-
return
|
|
838
|
-
var
|
|
829
|
+
}, vt = (n, e, t) => {
|
|
830
|
+
const r = n.split(""), o = r[e];
|
|
831
|
+
return r[e] && r[t] && (r[e] = r[t], r[t] = o), r.join("").toString();
|
|
832
|
+
}, St = (n) => (e) => e.replace(At(n), ""), Tt = (n) => (e) => {
|
|
833
|
+
const t = e.indexOf(n.hole), r = e.charAt(t - 1), o = e.charAt(t + 1), a = /[^\w]|_/;
|
|
834
|
+
return o ? r && a.test(r) && a.test(o) ? n.punctuation : n.char : n.punctuation;
|
|
835
|
+
}, Dt = (n, e, t) => {
|
|
836
|
+
let r = e, o = !1;
|
|
837
|
+
return n.descendants((a) => {
|
|
838
|
+
var l;
|
|
839
839
|
if (o)
|
|
840
840
|
return !1;
|
|
841
841
|
if (a.isText) {
|
|
842
|
-
const
|
|
843
|
-
if (
|
|
844
|
-
return o = !0,
|
|
842
|
+
const s = (l = a.text) == null ? void 0 : l.indexOf(t);
|
|
843
|
+
if (s != null && s >= 0)
|
|
844
|
+
return o = !0, r += s, !1;
|
|
845
845
|
}
|
|
846
|
-
|
|
847
|
-
}),
|
|
848
|
-
},
|
|
846
|
+
r += a.nodeSize;
|
|
847
|
+
}), r;
|
|
848
|
+
}, Ot = {
|
|
849
849
|
placeholderConfig: {
|
|
850
850
|
hole: "∅",
|
|
851
851
|
punctuation: "⁂",
|
|
852
852
|
char: "∴"
|
|
853
853
|
},
|
|
854
854
|
globalNodes: ["footnote_definition"],
|
|
855
|
-
shouldSyncNode: ({ prevNode:
|
|
856
|
-
movePlaceholder: (
|
|
855
|
+
shouldSyncNode: ({ prevNode: n, nextNode: e }) => n.inlineContent && e && n.type === e.type && !n.eq(e),
|
|
856
|
+
movePlaceholder: (n, e) => {
|
|
857
857
|
const t = ["*", "_"];
|
|
858
|
-
let
|
|
859
|
-
for (; t.includes(e[
|
|
860
|
-
e = vt(e,
|
|
858
|
+
let r = e.indexOf(n);
|
|
859
|
+
for (; t.includes(e[r - 1] || "") && t.includes(e[r + 1] || ""); )
|
|
860
|
+
e = vt(e, r, r + 1), r = r + 1;
|
|
861
861
|
return e;
|
|
862
862
|
}
|
|
863
|
-
},
|
|
864
|
-
const { selection: e } =
|
|
863
|
+
}, H = F(Ot, "inlineSyncConfig"), Ht = (n) => {
|
|
864
|
+
const { selection: e } = n, { $from: t } = e;
|
|
865
865
|
return t.node();
|
|
866
|
-
},
|
|
867
|
-
const o =
|
|
866
|
+
}, _t = (n, e, t, r) => {
|
|
867
|
+
const o = n.get(We), a = e.schema.topNodeType.create(void 0, [t, ...r]);
|
|
868
868
|
return o(a);
|
|
869
|
-
},
|
|
870
|
-
const t =
|
|
869
|
+
}, Kt = (n, e) => {
|
|
870
|
+
const t = n.get(H.key), r = t.placeholderConfig.hole, [o = "", ...a] = e.split(`
|
|
871
871
|
|
|
872
|
-
`),
|
|
873
|
-
let c =
|
|
874
|
-
const i =
|
|
875
|
-
return c = c.replace(
|
|
872
|
+
`), l = (d) => t.movePlaceholder(r, d);
|
|
873
|
+
let c = Pe(St(r), l, Lt)(o);
|
|
874
|
+
const i = Tt(t.placeholderConfig)(c);
|
|
875
|
+
return c = c.replace(r, i), c = [c, ...a].join(`
|
|
876
876
|
|
|
877
877
|
`), [c, i];
|
|
878
|
-
},
|
|
879
|
-
const
|
|
880
|
-
return
|
|
881
|
-
},
|
|
882
|
-
const { globalNodes: t } =
|
|
878
|
+
}, $t = (n, e) => {
|
|
879
|
+
const r = n.get(qe)(e);
|
|
880
|
+
return r ? r.firstChild : null;
|
|
881
|
+
}, Et = (n, e) => {
|
|
882
|
+
const { globalNodes: t } = n.get(H.key), r = [];
|
|
883
883
|
return e.doc.descendants((o) => {
|
|
884
884
|
if (t.includes(o.type.name) || t.includes(o.type))
|
|
885
|
-
return
|
|
886
|
-
}),
|
|
887
|
-
},
|
|
885
|
+
return r.push(o), !1;
|
|
886
|
+
}), r;
|
|
887
|
+
}, Bt = (n) => n.split(`
|
|
888
888
|
|
|
889
|
-
`)[0] || "",
|
|
889
|
+
`)[0] || "", Ee = (n, e) => {
|
|
890
890
|
try {
|
|
891
|
-
const t =
|
|
892
|
-
return !
|
|
891
|
+
const t = Et(n, e), r = Ht(e), o = _t(n, e, r, t), [a, l] = Kt(n, o), s = $t(n, a);
|
|
892
|
+
return !s || r.type !== s.type ? null : (s.attrs = { ...r.attrs }, s.descendants((c) => {
|
|
893
893
|
var u;
|
|
894
|
-
const d = c.marks.find((
|
|
895
|
-
d && ((u = c.text) == null ? void 0 : u.includes(
|
|
894
|
+
const d = c.marks.find((f) => f.type.name === "link");
|
|
895
|
+
d && ((u = c.text) == null ? void 0 : u.includes(l)) && d.attrs.href.includes(l) && (d.attrs.href = d.attrs.href.replace(l, ""));
|
|
896
896
|
}), {
|
|
897
|
-
text:
|
|
898
|
-
prevNode:
|
|
899
|
-
nextNode:
|
|
900
|
-
placeholder:
|
|
897
|
+
text: Bt(a),
|
|
898
|
+
prevNode: r,
|
|
899
|
+
nextNode: s,
|
|
900
|
+
placeholder: l
|
|
901
901
|
});
|
|
902
902
|
} catch {
|
|
903
903
|
return null;
|
|
904
904
|
}
|
|
905
|
-
},
|
|
906
|
-
const { placeholderConfig: a } =
|
|
907
|
-
let
|
|
908
|
-
const c = t.apply(
|
|
905
|
+
}, Rt = (n, e, t, r, o) => {
|
|
906
|
+
const { placeholderConfig: a } = n.get(H.key), l = a.hole;
|
|
907
|
+
let s = t.tr.setMeta(e, !0).insertText(l, t.selection.from);
|
|
908
|
+
const c = t.apply(s), i = Ee(n, c);
|
|
909
909
|
if (!i)
|
|
910
910
|
return;
|
|
911
|
-
const { $from: d } = c.selection, u = d.before(),
|
|
912
|
-
|
|
913
|
-
},
|
|
911
|
+
const { $from: d } = c.selection, u = d.before(), f = d.after(), p = Dt(i.nextNode, u, i.placeholder);
|
|
912
|
+
s = s.replaceWith(u, f, i.nextNode).setNodeMarkup(u, void 0, o).delete(p + 1, p + 2), s = s.setSelection(ae.near(s.doc.resolve(p + 1))), r(s);
|
|
913
|
+
}, Pt = N((n) => {
|
|
914
914
|
let e = null;
|
|
915
|
-
const t = new
|
|
916
|
-
return new
|
|
915
|
+
const t = new C("MILKDOWN_INLINE_SYNC");
|
|
916
|
+
return new x({
|
|
917
917
|
key: t,
|
|
918
918
|
state: {
|
|
919
919
|
init: () => null,
|
|
920
|
-
apply: (
|
|
921
|
-
var
|
|
922
|
-
const
|
|
923
|
-
if (!((
|
|
920
|
+
apply: (r, o, a, l) => {
|
|
921
|
+
var h;
|
|
922
|
+
const s = n.get(q);
|
|
923
|
+
if (!((h = s.hasFocus) != null && h.call(s)) || !s.editable || !r.docChanged || r.getMeta(t))
|
|
924
924
|
return null;
|
|
925
|
-
const i =
|
|
925
|
+
const i = Ee(n, l);
|
|
926
926
|
if (!i)
|
|
927
927
|
return null;
|
|
928
928
|
e && (cancelAnimationFrame(e), e = null);
|
|
929
|
-
const { prevNode: d, nextNode: u, text:
|
|
930
|
-
return
|
|
929
|
+
const { prevNode: d, nextNode: u, text: f } = i, { shouldSyncNode: p } = n.get(H.key);
|
|
930
|
+
return p({ prevNode: d, nextNode: u, ctx: n, tr: r, text: f }) && (e = requestAnimationFrame(() => {
|
|
931
931
|
e = null;
|
|
932
|
-
const { dispatch:
|
|
933
|
-
|
|
932
|
+
const { dispatch: _, state: Q } = n.get(q);
|
|
933
|
+
Rt(n, t, Q, _, d.attrs);
|
|
934
934
|
})), null;
|
|
935
935
|
}
|
|
936
936
|
}
|
|
937
937
|
});
|
|
938
|
-
}),
|
|
939
|
-
|
|
938
|
+
}), Wt = E(() => () => (n) => {
|
|
939
|
+
le(n, "list", (e) => {
|
|
940
940
|
if (e.ordered) {
|
|
941
941
|
const t = e.start ?? 1;
|
|
942
|
-
e.children.forEach((
|
|
943
|
-
|
|
942
|
+
e.children.forEach((r, o) => {
|
|
943
|
+
r.label = o + t;
|
|
944
944
|
});
|
|
945
945
|
}
|
|
946
946
|
});
|
|
947
|
-
}),
|
|
947
|
+
}), qt = E(() => () => (n) => {
|
|
948
948
|
const e = /[\t ]*(?:\r?\n|\r)/g;
|
|
949
|
-
|
|
949
|
+
le(n, "text", (t, r, o) => {
|
|
950
950
|
if (!t.value || typeof t.value != "string")
|
|
951
951
|
return;
|
|
952
952
|
const a = [];
|
|
953
|
-
let
|
|
953
|
+
let l = 0;
|
|
954
954
|
e.lastIndex = 0;
|
|
955
|
-
let
|
|
956
|
-
for (;
|
|
957
|
-
const i =
|
|
958
|
-
|
|
955
|
+
let s = e.exec(t.value);
|
|
956
|
+
for (; s; ) {
|
|
957
|
+
const i = s.index;
|
|
958
|
+
l !== i && a.push({ type: "text", value: t.value.slice(l, i) }), a.push({ type: "break", data: { isInline: !0 } }), l = i + s[0].length, s = e.exec(t.value);
|
|
959
959
|
}
|
|
960
|
-
if (!!(a.length > 0 && o && typeof
|
|
961
|
-
return
|
|
960
|
+
if (!!(a.length > 0 && o && typeof r == "number"))
|
|
961
|
+
return l < t.value.length && a.push({ type: "text", value: t.value.slice(l) }), o.children.splice(r, 1, ...a), r + a.length;
|
|
962
962
|
});
|
|
963
|
-
}),
|
|
964
|
-
function
|
|
965
|
-
return t(
|
|
966
|
-
function t(
|
|
967
|
-
if (
|
|
968
|
-
const
|
|
969
|
-
for (let
|
|
970
|
-
const i =
|
|
963
|
+
}), Ft = E(() => Ye), Vt = (n) => !!n.children, Gt = (n) => n.type === "html";
|
|
964
|
+
function jt(n, e) {
|
|
965
|
+
return t(n, 0, null)[0];
|
|
966
|
+
function t(r, o, a) {
|
|
967
|
+
if (Vt(r)) {
|
|
968
|
+
const l = [];
|
|
969
|
+
for (let s = 0, c = r.children.length; s < c; s++) {
|
|
970
|
+
const i = r.children[s];
|
|
971
971
|
if (i) {
|
|
972
|
-
const d = t(i,
|
|
972
|
+
const d = t(i, s, r);
|
|
973
973
|
if (d)
|
|
974
|
-
for (let u = 0,
|
|
975
|
-
const
|
|
976
|
-
|
|
974
|
+
for (let u = 0, f = d.length; u < f; u++) {
|
|
975
|
+
const p = d[u];
|
|
976
|
+
p && l.push(p);
|
|
977
977
|
}
|
|
978
978
|
}
|
|
979
979
|
}
|
|
980
|
-
|
|
980
|
+
r.children = l;
|
|
981
981
|
}
|
|
982
|
-
return e(
|
|
982
|
+
return e(r, o, a);
|
|
983
983
|
}
|
|
984
984
|
}
|
|
985
|
-
const
|
|
986
|
-
|
|
987
|
-
}),
|
|
988
|
-
let
|
|
989
|
-
const e = new
|
|
985
|
+
const zt = E(() => () => (n) => {
|
|
986
|
+
jt(n, (e) => Gt(e) ? [] : [e]);
|
|
987
|
+
}), Ut = N(() => {
|
|
988
|
+
let n = !1;
|
|
989
|
+
const e = new C("MILKDOWN_INLINE_NODES_CURSOR"), t = new x({
|
|
990
990
|
key: e,
|
|
991
991
|
state: {
|
|
992
992
|
init() {
|
|
993
993
|
return !1;
|
|
994
994
|
},
|
|
995
|
-
apply(
|
|
996
|
-
if (!
|
|
995
|
+
apply(r) {
|
|
996
|
+
if (!r.selection.empty)
|
|
997
997
|
return !1;
|
|
998
|
-
const o =
|
|
999
|
-
return !!(a &&
|
|
998
|
+
const o = r.selection.$from, a = o.nodeBefore, l = o.nodeAfter;
|
|
999
|
+
return !!(a && l && a.isInline && !a.isText && l.isInline && !l.isText);
|
|
1000
1000
|
}
|
|
1001
1001
|
},
|
|
1002
1002
|
props: {
|
|
1003
1003
|
handleDOMEvents: {
|
|
1004
|
-
compositionend: (
|
|
1005
|
-
if (t.getState(
|
|
1006
|
-
const
|
|
1007
|
-
o.preventDefault(),
|
|
1004
|
+
compositionend: (r, o) => n ? (n = !1, requestAnimationFrame(() => {
|
|
1005
|
+
if (t.getState(r.state)) {
|
|
1006
|
+
const l = r.state.selection.from;
|
|
1007
|
+
o.preventDefault(), r.dispatch(r.state.tr.insertText(o.data || "", l));
|
|
1008
1008
|
}
|
|
1009
1009
|
}), !0) : !1,
|
|
1010
|
-
compositionstart: (
|
|
1011
|
-
beforeinput: (
|
|
1012
|
-
if (t.getState(
|
|
1013
|
-
const
|
|
1014
|
-
return o.preventDefault(),
|
|
1010
|
+
compositionstart: (r) => (t.getState(r.state) && (n = !0), !1),
|
|
1011
|
+
beforeinput: (r, o) => {
|
|
1012
|
+
if (t.getState(r.state) && o instanceof InputEvent && o.data && !n) {
|
|
1013
|
+
const l = r.state.selection.from;
|
|
1014
|
+
return o.preventDefault(), r.dispatch(r.state.tr.insertText(o.data || "", l)), !0;
|
|
1015
1015
|
}
|
|
1016
1016
|
return !1;
|
|
1017
1017
|
}
|
|
1018
1018
|
},
|
|
1019
|
-
decorations(
|
|
1020
|
-
if (t.getState(
|
|
1021
|
-
const
|
|
1019
|
+
decorations(r) {
|
|
1020
|
+
if (t.getState(r)) {
|
|
1021
|
+
const l = r.selection.$from.pos, s = document.createElement("span"), c = Z.widget(l, s, {
|
|
1022
1022
|
side: -1
|
|
1023
|
-
}), i = document.createElement("span"), d =
|
|
1023
|
+
}), i = document.createElement("span"), d = Z.widget(l, i);
|
|
1024
1024
|
return setTimeout(() => {
|
|
1025
|
-
|
|
1026
|
-
}),
|
|
1025
|
+
s.contentEditable = "true", i.contentEditable = "true";
|
|
1026
|
+
}), ee.create(r.doc, [c, d]);
|
|
1027
1027
|
}
|
|
1028
|
-
return
|
|
1028
|
+
return ee.empty;
|
|
1029
1029
|
}
|
|
1030
1030
|
}
|
|
1031
1031
|
});
|
|
1032
1032
|
return t;
|
|
1033
|
-
}),
|
|
1034
|
-
key: new
|
|
1035
|
-
appendTransaction: (
|
|
1036
|
-
if (!
|
|
1033
|
+
}), Yt = N(() => new x({
|
|
1034
|
+
key: new C("MILKDOWN_HARDBREAK_MARKS"),
|
|
1035
|
+
appendTransaction: (n, e, t) => {
|
|
1036
|
+
if (!n.length)
|
|
1037
1037
|
return;
|
|
1038
|
-
const [
|
|
1039
|
-
if (!
|
|
1038
|
+
const [r] = n;
|
|
1039
|
+
if (!r)
|
|
1040
1040
|
return;
|
|
1041
|
-
const [o] =
|
|
1042
|
-
if (
|
|
1043
|
-
if (!(o instanceof
|
|
1041
|
+
const [o] = r.steps;
|
|
1042
|
+
if (r.getMeta("hardbreak")) {
|
|
1043
|
+
if (!(o instanceof ze))
|
|
1044
1044
|
return;
|
|
1045
|
-
const { from:
|
|
1046
|
-
return t.tr.setNodeMarkup(
|
|
1045
|
+
const { from: s } = o;
|
|
1046
|
+
return t.tr.setNodeMarkup(s, v.type(), void 0, []);
|
|
1047
1047
|
}
|
|
1048
|
-
if (o instanceof
|
|
1049
|
-
let
|
|
1048
|
+
if (o instanceof Ue) {
|
|
1049
|
+
let s = t.tr;
|
|
1050
1050
|
const { from: c, to: i } = o;
|
|
1051
1051
|
return t.doc.nodesBetween(c, i, (d, u) => {
|
|
1052
|
-
d.type ===
|
|
1053
|
-
}),
|
|
1052
|
+
d.type === v.type() && (s = s.setNodeMarkup(u, v.type(), void 0, []));
|
|
1053
|
+
}), s;
|
|
1054
1054
|
}
|
|
1055
1055
|
}
|
|
1056
|
-
})),
|
|
1057
|
-
const e =
|
|
1058
|
-
return new
|
|
1059
|
-
key: new
|
|
1060
|
-
filterTransaction: (t,
|
|
1056
|
+
})), Be = F(["table", "code_block"], "hardbreakFilterNodes"), Jt = N((n) => {
|
|
1057
|
+
const e = n.get(Be.key);
|
|
1058
|
+
return new x({
|
|
1059
|
+
key: new C("MILKDOWN_HARDBREAK_FILTER"),
|
|
1060
|
+
filterTransaction: (t, r) => {
|
|
1061
1061
|
const o = t.getMeta("hardbreak"), [a] = t.steps;
|
|
1062
1062
|
if (o && a) {
|
|
1063
|
-
const { from:
|
|
1064
|
-
let c =
|
|
1063
|
+
const { from: l } = a, s = r.doc.resolve(l);
|
|
1064
|
+
let c = s.depth, i = !0;
|
|
1065
1065
|
for (; c > 0; )
|
|
1066
|
-
e.includes(
|
|
1066
|
+
e.includes(s.node(c).type.name) && (i = !1), c--;
|
|
1067
1067
|
return i;
|
|
1068
1068
|
}
|
|
1069
1069
|
return !0;
|
|
1070
1070
|
}
|
|
1071
1071
|
});
|
|
1072
|
-
}),
|
|
1073
|
-
const e = new
|
|
1074
|
-
if (
|
|
1072
|
+
}), Qt = N((n) => {
|
|
1073
|
+
const e = new C("MILKDOWN_HEADING_ID"), t = (r) => {
|
|
1074
|
+
if (r.composing || !r.editable)
|
|
1075
1075
|
return;
|
|
1076
|
-
const o =
|
|
1077
|
-
let
|
|
1078
|
-
|
|
1079
|
-
if (
|
|
1080
|
-
if (
|
|
1076
|
+
const o = n.get(z.key), a = r.state.tr.setMeta("addToHistory", !1);
|
|
1077
|
+
let l = !1;
|
|
1078
|
+
r.state.doc.descendants((s, c) => {
|
|
1079
|
+
if (s.type === D.type()) {
|
|
1080
|
+
if (s.textContent.trim().length === 0)
|
|
1081
1081
|
return;
|
|
1082
|
-
const i =
|
|
1083
|
-
i.id !== d && (
|
|
1082
|
+
const i = s.attrs, d = o(s);
|
|
1083
|
+
i.id !== d && (l = !0, a.setMeta(e, !0).setNodeMarkup(c, void 0, {
|
|
1084
1084
|
...i,
|
|
1085
1085
|
id: d
|
|
1086
1086
|
}));
|
|
1087
1087
|
}
|
|
1088
|
-
}),
|
|
1088
|
+
}), l && r.dispatch(a);
|
|
1089
1089
|
};
|
|
1090
|
-
return new
|
|
1090
|
+
return new x({
|
|
1091
1091
|
key: e,
|
|
1092
|
-
view: (
|
|
1092
|
+
view: (r) => (t(r), {
|
|
1093
1093
|
update: (o) => {
|
|
1094
1094
|
t(o);
|
|
1095
1095
|
}
|
|
1096
1096
|
})
|
|
1097
1097
|
});
|
|
1098
|
-
}),
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1098
|
+
}), Xt = N(() => {
|
|
1099
|
+
const n = (e) => {
|
|
1100
|
+
if (e.composing || !e.editable)
|
|
1101
|
+
return;
|
|
1102
|
+
const t = P.type(), r = R.type(), o = O.type(), a = e.state, l = (i, d) => {
|
|
1103
|
+
let u = !1;
|
|
1104
|
+
const f = `${d + 1}.`;
|
|
1105
|
+
return i.label !== f && (i.label = f, u = !0), u;
|
|
1106
|
+
};
|
|
1107
|
+
let s = a.tr, c = !1;
|
|
1108
|
+
a.doc.descendants((i, d, u, f) => {
|
|
1109
|
+
if (i.type === r) {
|
|
1110
|
+
const p = i.maybeChild(0);
|
|
1111
|
+
(p == null ? void 0 : p.type) === o && p.attrs.listType === "ordered" && (c = !0, s.setNodeMarkup(d, t, { spread: "true" }), i.descendants((h, _, Q, Re) => {
|
|
1112
|
+
if (h.type === o) {
|
|
1113
|
+
const X = { ...h.attrs };
|
|
1114
|
+
l(X, Re) && (s = s.setNodeMarkup(_, void 0, X));
|
|
1115
|
+
}
|
|
1116
|
+
return !1;
|
|
1117
|
+
}));
|
|
1118
|
+
} else if (i.type === o && (u == null ? void 0 : u.type) === t) {
|
|
1119
|
+
const p = { ...i.attrs };
|
|
1120
|
+
let h = !1;
|
|
1121
|
+
p.listType !== "ordered" && (p.listType = "ordered", h = !0), (u == null ? void 0 : u.maybeChild(0)) && (h = l(p, f)), h && (s = s.setNodeMarkup(d, void 0, p), c = !0);
|
|
1109
1122
|
}
|
|
1110
|
-
}),
|
|
1123
|
+
}), c && e.dispatch(s.setMeta("addToHistory", !1));
|
|
1111
1124
|
};
|
|
1112
|
-
return new
|
|
1113
|
-
key: new
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
}
|
|
1125
|
+
return new x({
|
|
1126
|
+
key: new C("MILKDOWN_KEEP_LIST_ORDER"),
|
|
1127
|
+
view: (e) => (n(e), {
|
|
1128
|
+
update: (t) => {
|
|
1129
|
+
n(t);
|
|
1130
|
+
}
|
|
1131
|
+
})
|
|
1120
1132
|
});
|
|
1121
|
-
}),
|
|
1122
|
-
|
|
1123
|
-
Bt,
|
|
1124
|
-
zt,
|
|
1125
|
-
Ke,
|
|
1126
|
-
Ut,
|
|
1127
|
-
jt,
|
|
1128
|
-
Rt,
|
|
1129
|
-
Wt,
|
|
1133
|
+
}), Zt = [
|
|
1134
|
+
H,
|
|
1130
1135
|
Pt,
|
|
1131
|
-
Gt,
|
|
1132
1136
|
Yt,
|
|
1133
|
-
|
|
1134
|
-
|
|
1137
|
+
Be,
|
|
1138
|
+
Jt,
|
|
1139
|
+
Ut,
|
|
1140
|
+
Wt,
|
|
1141
|
+
Ft,
|
|
1142
|
+
qt,
|
|
1143
|
+
zt,
|
|
1144
|
+
Qt,
|
|
1145
|
+
Xt
|
|
1146
|
+
], kn = [wt, Nt, Ct, xt, Zt].flat();
|
|
1135
1147
|
export {
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1148
|
+
be as blockquoteAttr,
|
|
1149
|
+
ct as blockquoteKeymap,
|
|
1150
|
+
U as blockquoteSchema,
|
|
1151
|
+
Se as bulletListAttr,
|
|
1152
|
+
kt as bulletListKeymap,
|
|
1153
|
+
R as bulletListSchema,
|
|
1154
|
+
Ne as codeBlockAttr,
|
|
1155
|
+
dt as codeBlockKeymap,
|
|
1156
|
+
Y as codeBlockSchema,
|
|
1157
|
+
Ct as commands,
|
|
1158
|
+
kn as commonmark,
|
|
1159
|
+
Ce as createCodeBlockCommand,
|
|
1160
|
+
it as createCodeBlockInputRule,
|
|
1161
|
+
Ot as defaultConfig,
|
|
1162
|
+
tt as docSchema,
|
|
1163
|
+
Ie as downgradeHeadingCommand,
|
|
1164
|
+
ce as emphasisAttr,
|
|
1165
|
+
Je as emphasisKeymap,
|
|
1166
|
+
ie as emphasisSchema,
|
|
1167
|
+
Ae as hardbreakAttr,
|
|
1168
|
+
Yt as hardbreakClearMarkPlugin,
|
|
1169
|
+
Be as hardbreakFilterNodes,
|
|
1170
|
+
Jt as hardbreakFilterPlugin,
|
|
1171
|
+
mt as hardbreakKeymap,
|
|
1172
|
+
v as hardbreakSchema,
|
|
1173
|
+
Me as headingAttr,
|
|
1174
|
+
z as headingIdGenerator,
|
|
1175
|
+
st as headingKeymap,
|
|
1176
|
+
D as headingSchema,
|
|
1177
|
+
ve as hrAttr,
|
|
1178
|
+
J as hrSchema,
|
|
1179
|
+
xe as imageAttr,
|
|
1180
|
+
B as imageSchema,
|
|
1181
|
+
ge as inlineCodeAttr,
|
|
1182
|
+
Xe as inlineCodeKeymap,
|
|
1171
1183
|
A as inlineCodeSchema,
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1184
|
+
Ut as inlineNodesCursorPlugin,
|
|
1185
|
+
H as inlineSyncConfig,
|
|
1186
|
+
Pt as inlineSyncPlugin,
|
|
1187
|
+
Nt as inputrules,
|
|
1188
|
+
Le as insertHardbreakCommand,
|
|
1189
|
+
ft as insertHrCommand,
|
|
1190
|
+
gt as insertHrInputRule,
|
|
1191
|
+
ut as insertImageCommand,
|
|
1192
|
+
hn as insertImageInputRule,
|
|
1193
|
+
xt as keymap,
|
|
1194
|
+
Ke as liftListItemCommand,
|
|
1195
|
+
he as linkAttr,
|
|
1196
|
+
L as linkSchema,
|
|
1197
|
+
He as listItemAttr,
|
|
1198
|
+
It as listItemKeymap,
|
|
1199
|
+
O as listItemSchema,
|
|
1200
|
+
De as orderedListAttr,
|
|
1201
|
+
Mt as orderedListKeymap,
|
|
1202
|
+
P as orderedListSchema,
|
|
1203
|
+
ke as paragraphAttr,
|
|
1204
|
+
nt as paragraphKeymap,
|
|
1205
|
+
T as paragraphSchema,
|
|
1206
|
+
Zt as plugins,
|
|
1207
|
+
Wt as remarkAddOrderInListPlugin,
|
|
1208
|
+
zt as remarkHTMLFilter,
|
|
1209
|
+
Ft as remarkInlineLinkPlugin,
|
|
1210
|
+
qt as remarkLineBreak,
|
|
1211
|
+
wt as schema,
|
|
1212
|
+
_e as sinkListItemCommand,
|
|
1213
|
+
$e as splitListItemCommand,
|
|
1214
|
+
ue as strongAttr,
|
|
1215
|
+
Qe as strongKeymap,
|
|
1216
|
+
pe as strongSchema,
|
|
1217
|
+
Qt as syncHeadingIdPlugin,
|
|
1218
|
+
Xt as syncListOrderPlugin,
|
|
1219
|
+
bt as textSchema,
|
|
1220
|
+
de as toggleEmphasisCommand,
|
|
1221
|
+
fe as toggleInlineCodeCommand,
|
|
1222
|
+
Ze as toggleLinkCommand,
|
|
1223
|
+
me as toggleStrongCommand,
|
|
1224
|
+
ye as turnIntoTextCommand,
|
|
1225
|
+
fn as updateCodeBlockLanguageCommand,
|
|
1226
|
+
pt as updateImageCommand,
|
|
1227
|
+
et as updateLinkCommand,
|
|
1228
|
+
we as wrapInBlockquoteCommand,
|
|
1229
|
+
lt as wrapInBlockquoteInputRule,
|
|
1230
|
+
Te as wrapInBulletListCommand,
|
|
1231
|
+
ht as wrapInBulletListInputRule,
|
|
1232
|
+
I as wrapInHeadingCommand,
|
|
1233
|
+
at as wrapInHeadingInputRule,
|
|
1234
|
+
Oe as wrapInOrderedListCommand,
|
|
1235
|
+
yt as wrapInOrderedListInputRule
|
|
1224
1236
|
};
|
|
1225
1237
|
//# sourceMappingURL=index.es.js.map
|