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