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