@milkdown/preset-commonmark 7.0.1 → 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/composed/plugins.d.ts.map +1 -1
- package/lib/composed/schema.d.ts.map +1 -1
- package/lib/index.es.js +583 -550
- 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/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/node/paragraph.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/inline-sync-plugin/inline-sync-plugin.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/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/package.json +11 -8
- package/src/composed/plugins.ts +15 -2
- package/src/composed/schema.ts +29 -1
- package/src/node/hardbreak.ts +1 -0
- package/src/node/heading.ts +4 -20
- package/src/node/html.ts +47 -0
- package/src/node/index.ts +2 -0
- package/src/node/paragraph.ts +2 -16
- package/src/plugin/index.ts +1 -1
- package/src/plugin/inline-sync-plugin/context.ts +6 -6
- package/src/plugin/inline-sync-plugin/inline-sync-plugin.ts +2 -0
- package/src/plugin/inline-sync-plugin/replacer.ts +1 -1
- package/src/plugin/{remark-html-filter.ts → remark-html-transformer.ts} +9 -3
- package/src/utils/index.ts +22 -0
- 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,107 +1,108 @@
|
|
|
1
|
-
import { $markAttr as K, $markSchema as
|
|
2
|
-
import { commandsCtx as g, editorViewCtx as q, serializerCtx as
|
|
3
|
-
import { toggleMark as V, setBlockType as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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
|
+
import { commandsCtx as g, editorViewCtx as q, serializerCtx as qe, parserCtx as Fe } from "@milkdown/core";
|
|
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(
|
|
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
|
-
}),
|
|
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(
|
|
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
|
-
})), me =
|
|
63
|
+
})), me = p("ToggleStrong", () => () => V(ue.type())), et = k("strongKeymap", {
|
|
63
64
|
ToggleBold: {
|
|
64
65
|
shortcuts: ["Mod-b"],
|
|
65
|
-
command: (
|
|
66
|
-
const e =
|
|
66
|
+
command: (t) => {
|
|
67
|
+
const e = t.get(g);
|
|
67
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(
|
|
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
|
|
94
|
-
|
|
95
|
-
}), e == null || e(
|
|
96
|
-
}),
|
|
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) => {
|
|
95
|
+
n.removeMark(o, a, c);
|
|
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 = $("emphasis", (n) => ({
|
|
|
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(
|
|
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
|
-
let
|
|
140
|
+
let n, o = -1;
|
|
140
141
|
const { selection: a } = e, { from: l, to: s } = a;
|
|
141
|
-
if (e.doc.nodesBetween(l, l === s ? s + 1 : s, (
|
|
142
|
-
if (L.type().isInSet(
|
|
143
|
-
return
|
|
144
|
-
}), !
|
|
142
|
+
if (e.doc.nodesBetween(l, l === s ? s + 1 : s, (m, h) => {
|
|
143
|
+
if (L.type().isInSet(m.marks))
|
|
144
|
+
return n = m, o = h, !1;
|
|
145
|
+
}), !n)
|
|
145
146
|
return !1;
|
|
146
|
-
const c =
|
|
147
|
+
const c = n.marks.find(({ type: m }) => m === L.type());
|
|
147
148
|
if (!c)
|
|
148
149
|
return !1;
|
|
149
|
-
const i = o, d = o +
|
|
150
|
-
return f ? (
|
|
151
|
-
u.removeMark(i, d, c).addMark(i, d, f).setSelection(new
|
|
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(
|
|
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(ne.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 =
|
|
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 = $("emphasis", (n) => ({
|
|
|
211
214
|
default: 1
|
|
212
215
|
}
|
|
213
216
|
},
|
|
214
|
-
parseDOM:
|
|
215
|
-
tag: `h${
|
|
216
|
-
getAttrs: (
|
|
217
|
-
if (!(
|
|
218
|
-
throw
|
|
219
|
-
return { level:
|
|
217
|
+
parseDOM: st.map((r) => ({
|
|
218
|
+
tag: `h${r}`,
|
|
219
|
+
getAttrs: (n) => {
|
|
220
|
+
if (!(n instanceof HTMLElement))
|
|
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: (
|
|
233
|
-
const a =
|
|
234
|
-
|
|
234
|
+
match: ({ type: r }) => r === "heading",
|
|
235
|
+
runner: (r, n, o) => {
|
|
236
|
+
const a = n.depth;
|
|
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: r.attrs.level }), r.childCount >= 1 && ((a = r.lastChild) == null ? void 0 : a.type.name) === "hardbreak") {
|
|
242
|
-
const l = [];
|
|
243
|
-
r.content.forEach((s, c, i) => {
|
|
244
|
-
i !== r.childCount - 1 && l.push(s);
|
|
245
|
-
}), t.next(ne.fromArray(l));
|
|
246
|
-
} else
|
|
247
|
-
t.next(r.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 =
|
|
261
|
-
const { $from:
|
|
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(
|
|
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 = $("emphasis", (n) => ({
|
|
|
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 =
|
|
387
|
-
e.openNode(
|
|
380
|
+
runner: (e, r, n) => {
|
|
381
|
+
const o = r.lang, a = r.value;
|
|
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,
|
|
393
|
-
var
|
|
394
|
-
e.addNode("code", void 0, ((
|
|
395
|
-
lang:
|
|
387
|
+
runner: (e, r) => {
|
|
388
|
+
var n;
|
|
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
|
-
})),
|
|
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 =
|
|
409
|
-
return () => e.call(
|
|
402
|
+
command: (t) => {
|
|
403
|
+
const e = t.get(g);
|
|
404
|
+
return () => e.call(ve.key);
|
|
410
405
|
}
|
|
411
406
|
}
|
|
412
|
-
}),
|
|
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 = $("emphasis", (n) => ({
|
|
|
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,12 +432,12 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
|
|
|
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 =
|
|
445
|
-
e.addNode(
|
|
438
|
+
runner: (e, r, n) => {
|
|
439
|
+
const o = r.url, a = r.alt, l = r.title;
|
|
440
|
+
e.addNode(n, {
|
|
446
441
|
src: o,
|
|
447
442
|
alt: a,
|
|
448
443
|
title: l
|
|
@@ -451,34 +446,34 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
|
|
|
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 (!t)
|
|
464
|
-
return !0;
|
|
465
|
-
const { src: r = "", alt: o = "", title: a = "" } = n, l = B.type().create({ src: r, alt: o, title: a });
|
|
466
|
-
return l && t(e.tr.replaceSelectionWith(l).scrollIntoView()), !0;
|
|
467
|
-
}), pt = m("UpdateImage", () => (n = {}) => (e, t) => {
|
|
468
|
-
const r = Fe(e.selection, B.type());
|
|
457
|
+
})), gt = p("InsertImage", () => (t = {}) => (e, r) => {
|
|
469
458
|
if (!r)
|
|
459
|
+
return !0;
|
|
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());
|
|
464
|
+
if (!n)
|
|
470
465
|
return !1;
|
|
471
|
-
const { node: o, pos: a } =
|
|
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
|
-
)),
|
|
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,48 +483,50 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
|
|
|
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(
|
|
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
|
-
})),
|
|
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
|
-
|
|
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(
|
|
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 =
|
|
522
|
-
return () => e.call(
|
|
517
|
+
command: (t) => {
|
|
518
|
+
const e = t.get(g);
|
|
519
|
+
return () => e.call(Ae.key);
|
|
523
520
|
}
|
|
524
521
|
}
|
|
525
|
-
}),
|
|
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,
|
|
532
|
-
e.addNode(
|
|
528
|
+
runner: (e, r, n) => {
|
|
529
|
+
e.addNode(n);
|
|
533
530
|
}
|
|
534
531
|
},
|
|
535
532
|
toMarkdown: {
|
|
@@ -538,21 +535,21 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
|
|
|
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 =
|
|
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 = $("emphasis", (n) => ({
|
|
|
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 = $("emphasis", (n) => ({
|
|
|
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(
|
|
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 = $("emphasis", (n) => ({
|
|
|
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 = $("emphasis", (n) => ({
|
|
|
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(
|
|
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 =
|
|
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 = $("emphasis", (n) => ({
|
|
|
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 = $("emphasis", (n) => ({
|
|
|
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,366 +698,400 @@ const ce = K("emphasis"), ie = $("emphasis", (n) => ({
|
|
|
701
698
|
],
|
|
702
699
|
parseMarkdown: {
|
|
703
700
|
match: ({ type: e }) => e === "listItem",
|
|
704
|
-
runner: (e,
|
|
705
|
-
const o =
|
|
706
|
-
e.openNode(
|
|
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 =
|
|
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
|
-
})),
|
|
752
|
-
|
|
748
|
+
})), $e = y("html"), Ct = M("html", (t) => ({
|
|
749
|
+
atom: !0,
|
|
750
|
+
group: "inline",
|
|
751
|
+
inline: !0,
|
|
752
|
+
attrs: {
|
|
753
|
+
value: {
|
|
754
|
+
default: ""
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
toDOM: (e) => {
|
|
758
|
+
const r = document.createElement("span"), n = {
|
|
759
|
+
...t.get($e.key)(e),
|
|
760
|
+
"data-value": e.attrs.value,
|
|
761
|
+
"data-type": "html"
|
|
762
|
+
};
|
|
763
|
+
return r.textContent = e.attrs.value, ["span", n, e.attrs.value];
|
|
764
|
+
},
|
|
765
|
+
parseDOM: [{
|
|
766
|
+
tag: 'span[data-type="html"]',
|
|
767
|
+
getAttrs: (e) => ({
|
|
768
|
+
value: e.dataset.value ?? ""
|
|
769
|
+
})
|
|
770
|
+
}],
|
|
771
|
+
parseMarkdown: {
|
|
772
|
+
match: ({ type: e }) => Boolean(e === "html"),
|
|
773
|
+
runner: (e, r, n) => {
|
|
774
|
+
e.addNode(n, { value: r.value });
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
toMarkdown: {
|
|
778
|
+
match: (e) => e.type.name === "html",
|
|
779
|
+
runner: (e, r) => {
|
|
780
|
+
e.addNode("html", void 0, r.attrs.value);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
})), xt = [
|
|
784
|
+
ot,
|
|
753
785
|
ke,
|
|
754
|
-
|
|
755
|
-
|
|
786
|
+
S,
|
|
787
|
+
j,
|
|
756
788
|
Me,
|
|
757
789
|
D,
|
|
758
|
-
|
|
759
|
-
|
|
790
|
+
xe,
|
|
791
|
+
w,
|
|
760
792
|
be,
|
|
761
793
|
U,
|
|
762
|
-
|
|
794
|
+
we,
|
|
763
795
|
Y,
|
|
764
|
-
|
|
796
|
+
Le,
|
|
765
797
|
J,
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
798
|
+
Ce,
|
|
799
|
+
E,
|
|
800
|
+
Te,
|
|
769
801
|
R,
|
|
770
802
|
De,
|
|
771
803
|
P,
|
|
772
804
|
He,
|
|
773
805
|
O,
|
|
806
|
+
le,
|
|
774
807
|
ce,
|
|
775
|
-
|
|
808
|
+
de,
|
|
776
809
|
ue,
|
|
777
810
|
pe,
|
|
778
|
-
ge,
|
|
779
811
|
A,
|
|
780
|
-
|
|
812
|
+
fe,
|
|
781
813
|
L,
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
814
|
+
$e,
|
|
815
|
+
Ct,
|
|
816
|
+
vt
|
|
817
|
+
].flat(), At = [
|
|
818
|
+
dt,
|
|
819
|
+
Mt,
|
|
820
|
+
bt,
|
|
821
|
+
mt,
|
|
822
|
+
kt,
|
|
823
|
+
ct
|
|
824
|
+
].flat(), Lt = [
|
|
791
825
|
ye,
|
|
792
|
-
|
|
826
|
+
Ne,
|
|
793
827
|
I,
|
|
794
828
|
Ie,
|
|
795
|
-
|
|
796
|
-
|
|
829
|
+
ve,
|
|
830
|
+
Ae,
|
|
831
|
+
yt,
|
|
832
|
+
gt,
|
|
797
833
|
ft,
|
|
798
|
-
ut,
|
|
799
|
-
pt,
|
|
800
834
|
Oe,
|
|
801
|
-
|
|
835
|
+
Se,
|
|
802
836
|
_e,
|
|
803
|
-
|
|
837
|
+
Be,
|
|
804
838
|
Ke,
|
|
805
|
-
|
|
806
|
-
|
|
839
|
+
ie,
|
|
840
|
+
ge,
|
|
807
841
|
me,
|
|
842
|
+
rt,
|
|
843
|
+
nt
|
|
844
|
+
], Tt = [
|
|
845
|
+
ut,
|
|
846
|
+
pt,
|
|
847
|
+
ht,
|
|
848
|
+
it,
|
|
849
|
+
wt,
|
|
850
|
+
Nt,
|
|
851
|
+
It,
|
|
852
|
+
at,
|
|
808
853
|
Ze,
|
|
854
|
+
tt,
|
|
809
855
|
et
|
|
810
|
-
],
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
It,
|
|
816
|
-
Mt,
|
|
817
|
-
kt,
|
|
818
|
-
nt,
|
|
819
|
-
Je,
|
|
820
|
-
Xe,
|
|
821
|
-
Qe
|
|
822
|
-
].flat(), W = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)/, At = (n) => new RegExp(`\\\\(?=[^\\w\\s${n}\\\\]|_)`, "g"), Lt = (n) => {
|
|
823
|
-
let e = n, t = e.match(W);
|
|
824
|
-
for (; t && t.groups; ) {
|
|
825
|
-
const { span: r } = t.groups;
|
|
826
|
-
e = e.replace(W, r), t = e.match(W);
|
|
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);
|
|
827
861
|
}
|
|
828
862
|
return e;
|
|
829
|
-
},
|
|
830
|
-
const
|
|
831
|
-
return
|
|
832
|
-
},
|
|
833
|
-
const
|
|
834
|
-
return o ?
|
|
835
|
-
},
|
|
836
|
-
let
|
|
837
|
-
return
|
|
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) => {
|
|
870
|
+
let n = e, o = !1;
|
|
871
|
+
return t.descendants((a) => {
|
|
838
872
|
var l;
|
|
839
873
|
if (o)
|
|
840
874
|
return !1;
|
|
841
875
|
if (a.isText) {
|
|
842
|
-
const s = (l = a.text) == null ? void 0 : l.indexOf(
|
|
876
|
+
const s = (l = a.text) == null ? void 0 : l.indexOf(r);
|
|
843
877
|
if (s != null && s >= 0)
|
|
844
|
-
return o = !0,
|
|
878
|
+
return o = !0, n += s, !1;
|
|
845
879
|
}
|
|
846
|
-
|
|
847
|
-
}),
|
|
848
|
-
},
|
|
880
|
+
n += a.nodeSize;
|
|
881
|
+
}), n;
|
|
882
|
+
}, Bt = {
|
|
849
883
|
placeholderConfig: {
|
|
850
884
|
hole: "∅",
|
|
851
885
|
punctuation: "⁂",
|
|
852
886
|
char: "∴"
|
|
853
887
|
},
|
|
854
888
|
globalNodes: ["footnote_definition"],
|
|
855
|
-
shouldSyncNode: ({ prevNode:
|
|
856
|
-
movePlaceholder: (
|
|
857
|
-
const
|
|
858
|
-
let
|
|
859
|
-
for (;
|
|
860
|
-
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;
|
|
861
895
|
return e;
|
|
862
896
|
}
|
|
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]);
|
|
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]);
|
|
868
899
|
return o(a);
|
|
869
|
-
},
|
|
870
|
-
const
|
|
900
|
+
}, Rt = (t, e) => {
|
|
901
|
+
const r = t.get(H.key), n = r.placeholderConfig.hole, [o = "", ...a] = e.split(`
|
|
871
902
|
|
|
872
|
-
`), l = (d) =>
|
|
873
|
-
let c =
|
|
874
|
-
const i =
|
|
875
|
-
return c = c.replace(
|
|
903
|
+
`), l = (d) => r.movePlaceholder(n, d);
|
|
904
|
+
let c = We(Ht(n), l, Dt)(o);
|
|
905
|
+
const i = _t(r.placeholderConfig)(c);
|
|
906
|
+
return c = c.replace(n, i), c = [c, ...a].join(`
|
|
876
907
|
|
|
877
908
|
`), [c, i];
|
|
878
|
-
},
|
|
879
|
-
const
|
|
880
|
-
return
|
|
881
|
-
},
|
|
882
|
-
const { globalNodes:
|
|
909
|
+
}, Pt = (t, e) => {
|
|
910
|
+
const n = t.get(Fe)(e);
|
|
911
|
+
return n ? n.firstChild : null;
|
|
912
|
+
}, Wt = (t, e) => {
|
|
913
|
+
const { globalNodes: r } = t.get(H.key), n = [];
|
|
883
914
|
return e.doc.descendants((o) => {
|
|
884
|
-
if (
|
|
885
|
-
return
|
|
886
|
-
}),
|
|
887
|
-
},
|
|
915
|
+
if (r.includes(o.type.name) || r.includes(o.type))
|
|
916
|
+
return n.push(o), !1;
|
|
917
|
+
}), n;
|
|
918
|
+
}, qt = (t) => t.split(`
|
|
888
919
|
|
|
889
|
-
`)[0] || "", Ee = (
|
|
920
|
+
`)[0] || "", Ft = (t) => t.childCount === 1 && t.child(0).type.name === "html", Ee = (t, e) => {
|
|
890
921
|
try {
|
|
891
|
-
const
|
|
892
|
-
return !s ||
|
|
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) => {
|
|
893
924
|
var u;
|
|
894
925
|
const d = c.marks.find((f) => f.type.name === "link");
|
|
895
926
|
d && ((u = c.text) == null ? void 0 : u.includes(l)) && d.attrs.href.includes(l) && (d.attrs.href = d.attrs.href.replace(l, ""));
|
|
896
927
|
}), {
|
|
897
|
-
text:
|
|
898
|
-
prevNode:
|
|
928
|
+
text: qt(a),
|
|
929
|
+
prevNode: n,
|
|
899
930
|
nextNode: s,
|
|
900
931
|
placeholder: l
|
|
901
932
|
});
|
|
902
933
|
} catch {
|
|
903
934
|
return null;
|
|
904
935
|
}
|
|
905
|
-
},
|
|
906
|
-
const { placeholderConfig: a } =
|
|
907
|
-
let s =
|
|
908
|
-
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);
|
|
909
940
|
if (!i)
|
|
910
941
|
return;
|
|
911
|
-
const { $from: d } = c.selection, u = d.before(), f = d.after(),
|
|
912
|
-
s = s.replaceWith(u, f, i.nextNode).setNodeMarkup(u, void 0, o).delete(
|
|
913
|
-
},
|
|
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) => {
|
|
914
945
|
let e = null;
|
|
915
|
-
const
|
|
946
|
+
const r = new C("MILKDOWN_INLINE_SYNC");
|
|
916
947
|
return new x({
|
|
917
|
-
key:
|
|
948
|
+
key: r,
|
|
918
949
|
state: {
|
|
919
950
|
init: () => null,
|
|
920
|
-
apply: (
|
|
951
|
+
apply: (n, o, a, l) => {
|
|
921
952
|
var h;
|
|
922
|
-
const s =
|
|
923
|
-
if (!((h = s.hasFocus) != null && h.call(s)) || !s.editable || !
|
|
953
|
+
const s = t.get(q);
|
|
954
|
+
if (!((h = s.hasFocus) != null && h.call(s)) || !s.editable || !n.docChanged || n.getMeta(r))
|
|
924
955
|
return null;
|
|
925
|
-
const i = Ee(
|
|
956
|
+
const i = Ee(t, l);
|
|
926
957
|
if (!i)
|
|
927
958
|
return null;
|
|
928
959
|
e && (cancelAnimationFrame(e), e = null);
|
|
929
|
-
const { prevNode: d, nextNode: u, text: f } = i, { shouldSyncNode:
|
|
930
|
-
return
|
|
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(() => {
|
|
931
962
|
e = null;
|
|
932
|
-
const { dispatch: _, state: Q } =
|
|
933
|
-
|
|
934
|
-
})), null;
|
|
963
|
+
const { dispatch: _, state: Q } = t.get(q);
|
|
964
|
+
Vt(t, r, Q, _, d.attrs);
|
|
965
|
+
}), n.setMeta("addToHistory", !1)), null;
|
|
935
966
|
}
|
|
936
967
|
}
|
|
937
968
|
});
|
|
938
|
-
}),
|
|
939
|
-
|
|
969
|
+
}), Gt = $(() => () => (t) => {
|
|
970
|
+
se(t, "list", (e) => {
|
|
940
971
|
if (e.ordered) {
|
|
941
|
-
const
|
|
942
|
-
e.children.forEach((
|
|
943
|
-
|
|
972
|
+
const r = e.start ?? 1;
|
|
973
|
+
e.children.forEach((n, o) => {
|
|
974
|
+
n.label = o + r;
|
|
944
975
|
});
|
|
945
976
|
}
|
|
946
977
|
});
|
|
947
|
-
}),
|
|
978
|
+
}), jt = $(() => () => (t) => {
|
|
948
979
|
const e = /[\t ]*(?:\r?\n|\r)/g;
|
|
949
|
-
|
|
950
|
-
if (!
|
|
980
|
+
se(t, "text", (r, n, o) => {
|
|
981
|
+
if (!r.value || typeof r.value != "string")
|
|
951
982
|
return;
|
|
952
983
|
const a = [];
|
|
953
984
|
let l = 0;
|
|
954
985
|
e.lastIndex = 0;
|
|
955
|
-
let s = e.exec(
|
|
986
|
+
let s = e.exec(r.value);
|
|
956
987
|
for (; s; ) {
|
|
957
988
|
const i = s.index;
|
|
958
|
-
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);
|
|
959
990
|
}
|
|
960
|
-
if (!!(a.length > 0 && o && typeof
|
|
961
|
-
return l <
|
|
991
|
+
if (!!(a.length > 0 && o && typeof n == "number"))
|
|
992
|
+
return l < r.value.length && a.push({ type: "text", value: r.value.slice(l) }), o.children.splice(n, 1, ...a), n + a.length;
|
|
962
993
|
});
|
|
963
|
-
}),
|
|
964
|
-
function
|
|
965
|
-
return t
|
|
966
|
-
function
|
|
967
|
-
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)) {
|
|
968
999
|
const l = [];
|
|
969
|
-
for (let s = 0, c =
|
|
970
|
-
const i =
|
|
1000
|
+
for (let s = 0, c = n.children.length; s < c; s++) {
|
|
1001
|
+
const i = n.children[s];
|
|
971
1002
|
if (i) {
|
|
972
|
-
const d =
|
|
1003
|
+
const d = r(i, s, n);
|
|
973
1004
|
if (d)
|
|
974
1005
|
for (let u = 0, f = d.length; u < f; u++) {
|
|
975
|
-
const
|
|
976
|
-
|
|
1006
|
+
const m = d[u];
|
|
1007
|
+
m && l.push(m);
|
|
977
1008
|
}
|
|
978
1009
|
}
|
|
979
1010
|
}
|
|
980
|
-
|
|
1011
|
+
n.children = l;
|
|
981
1012
|
}
|
|
982
|
-
return e(
|
|
1013
|
+
return e(n, o, a);
|
|
983
1014
|
}
|
|
984
1015
|
}
|
|
985
|
-
const
|
|
986
|
-
|
|
987
|
-
}),
|
|
988
|
-
let
|
|
989
|
-
const e = new C("MILKDOWN_INLINE_NODES_CURSOR"),
|
|
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({
|
|
990
1021
|
key: e,
|
|
991
1022
|
state: {
|
|
992
1023
|
init() {
|
|
993
1024
|
return !1;
|
|
994
1025
|
},
|
|
995
|
-
apply(
|
|
996
|
-
if (!
|
|
1026
|
+
apply(n) {
|
|
1027
|
+
if (!n.selection.empty)
|
|
997
1028
|
return !1;
|
|
998
|
-
const o =
|
|
1029
|
+
const o = n.selection.$from, a = o.nodeBefore, l = o.nodeAfter;
|
|
999
1030
|
return !!(a && l && a.isInline && !a.isText && l.isInline && !l.isText);
|
|
1000
1031
|
}
|
|
1001
1032
|
},
|
|
1002
1033
|
props: {
|
|
1003
1034
|
handleDOMEvents: {
|
|
1004
|
-
compositionend: (
|
|
1005
|
-
if (
|
|
1006
|
-
const l =
|
|
1007
|
-
o.preventDefault(),
|
|
1035
|
+
compositionend: (n, o) => t ? (t = !1, requestAnimationFrame(() => {
|
|
1036
|
+
if (r.getState(n.state)) {
|
|
1037
|
+
const l = n.state.selection.from;
|
|
1038
|
+
o.preventDefault(), n.dispatch(n.state.tr.insertText(o.data || "", l));
|
|
1008
1039
|
}
|
|
1009
1040
|
}), !0) : !1,
|
|
1010
|
-
compositionstart: (
|
|
1011
|
-
beforeinput: (
|
|
1012
|
-
if (
|
|
1013
|
-
const l =
|
|
1014
|
-
return o.preventDefault(),
|
|
1041
|
+
compositionstart: (n) => (r.getState(n.state) && (t = !0), !1),
|
|
1042
|
+
beforeinput: (n, o) => {
|
|
1043
|
+
if (r.getState(n.state) && o instanceof InputEvent && o.data && !t) {
|
|
1044
|
+
const l = n.state.selection.from;
|
|
1045
|
+
return o.preventDefault(), n.dispatch(n.state.tr.insertText(o.data || "", l)), !0;
|
|
1015
1046
|
}
|
|
1016
1047
|
return !1;
|
|
1017
1048
|
}
|
|
1018
1049
|
},
|
|
1019
|
-
decorations(
|
|
1020
|
-
if (
|
|
1021
|
-
const l =
|
|
1050
|
+
decorations(n) {
|
|
1051
|
+
if (r.getState(n)) {
|
|
1052
|
+
const l = n.selection.$from.pos, s = document.createElement("span"), c = Z.widget(l, s, {
|
|
1022
1053
|
side: -1
|
|
1023
1054
|
}), i = document.createElement("span"), d = Z.widget(l, i);
|
|
1024
1055
|
return setTimeout(() => {
|
|
1025
1056
|
s.contentEditable = "true", i.contentEditable = "true";
|
|
1026
|
-
}), ee.create(
|
|
1057
|
+
}), ee.create(n.doc, [c, d]);
|
|
1027
1058
|
}
|
|
1028
1059
|
return ee.empty;
|
|
1029
1060
|
}
|
|
1030
1061
|
}
|
|
1031
1062
|
});
|
|
1032
|
-
return
|
|
1033
|
-
}),
|
|
1063
|
+
return r;
|
|
1064
|
+
}), er = v(() => new x({
|
|
1034
1065
|
key: new C("MILKDOWN_HARDBREAK_MARKS"),
|
|
1035
|
-
appendTransaction: (
|
|
1036
|
-
if (!
|
|
1066
|
+
appendTransaction: (t, e, r) => {
|
|
1067
|
+
if (!t.length)
|
|
1037
1068
|
return;
|
|
1038
|
-
const [
|
|
1039
|
-
if (!
|
|
1069
|
+
const [n] = t;
|
|
1070
|
+
if (!n)
|
|
1040
1071
|
return;
|
|
1041
|
-
const [o] =
|
|
1042
|
-
if (
|
|
1043
|
-
if (!(o instanceof
|
|
1072
|
+
const [o] = n.steps;
|
|
1073
|
+
if (n.getMeta("hardbreak")) {
|
|
1074
|
+
if (!(o instanceof Je))
|
|
1044
1075
|
return;
|
|
1045
1076
|
const { from: s } = o;
|
|
1046
|
-
return
|
|
1077
|
+
return r.tr.setNodeMarkup(s, w.type(), void 0, []);
|
|
1047
1078
|
}
|
|
1048
|
-
if (o instanceof
|
|
1049
|
-
let s =
|
|
1079
|
+
if (o instanceof Qe) {
|
|
1080
|
+
let s = r.tr;
|
|
1050
1081
|
const { from: c, to: i } = o;
|
|
1051
|
-
return
|
|
1052
|
-
d.type ===
|
|
1082
|
+
return r.doc.nodesBetween(c, i, (d, u) => {
|
|
1083
|
+
d.type === w.type() && (s = s.setNodeMarkup(u, w.type(), void 0, []));
|
|
1053
1084
|
}), s;
|
|
1054
1085
|
}
|
|
1055
1086
|
}
|
|
1056
|
-
})),
|
|
1057
|
-
const e =
|
|
1087
|
+
})), Re = F(["table", "code_block"], "hardbreakFilterNodes"), tr = v((t) => {
|
|
1088
|
+
const e = t.get(Re.key);
|
|
1058
1089
|
return new x({
|
|
1059
1090
|
key: new C("MILKDOWN_HARDBREAK_FILTER"),
|
|
1060
|
-
filterTransaction: (
|
|
1061
|
-
const o =
|
|
1091
|
+
filterTransaction: (r, n) => {
|
|
1092
|
+
const o = r.getMeta("hardbreak"), [a] = r.steps;
|
|
1062
1093
|
if (o && a) {
|
|
1063
|
-
const { from: l } = a, s =
|
|
1094
|
+
const { from: l } = a, s = n.doc.resolve(l);
|
|
1064
1095
|
let c = s.depth, i = !0;
|
|
1065
1096
|
for (; c > 0; )
|
|
1066
1097
|
e.includes(s.node(c).type.name) && (i = !1), c--;
|
|
@@ -1069,13 +1100,13 @@ const zt = E(() => () => (n) => {
|
|
|
1069
1100
|
return !0;
|
|
1070
1101
|
}
|
|
1071
1102
|
});
|
|
1072
|
-
}),
|
|
1073
|
-
const e = new C("MILKDOWN_HEADING_ID"),
|
|
1074
|
-
if (
|
|
1103
|
+
}), rr = v((t) => {
|
|
1104
|
+
const e = new C("MILKDOWN_HEADING_ID"), r = (n) => {
|
|
1105
|
+
if (n.composing || !n.editable)
|
|
1075
1106
|
return;
|
|
1076
|
-
const o =
|
|
1107
|
+
const o = t.get(j.key), a = n.state.tr.setMeta("addToHistory", !1);
|
|
1077
1108
|
let l = !1;
|
|
1078
|
-
|
|
1109
|
+
n.state.doc.descendants((s, c) => {
|
|
1079
1110
|
if (s.type === D.type()) {
|
|
1080
1111
|
if (s.textContent.trim().length === 0)
|
|
1081
1112
|
return;
|
|
@@ -1085,153 +1116,155 @@ const zt = E(() => () => (n) => {
|
|
|
1085
1116
|
id: d
|
|
1086
1117
|
}));
|
|
1087
1118
|
}
|
|
1088
|
-
}), l &&
|
|
1119
|
+
}), l && n.dispatch(a);
|
|
1089
1120
|
};
|
|
1090
1121
|
return new x({
|
|
1091
1122
|
key: e,
|
|
1092
|
-
view: (
|
|
1123
|
+
view: (n) => (r(n), {
|
|
1093
1124
|
update: (o) => {
|
|
1094
|
-
|
|
1125
|
+
r(o);
|
|
1095
1126
|
}
|
|
1096
1127
|
})
|
|
1097
1128
|
});
|
|
1098
|
-
}),
|
|
1099
|
-
const
|
|
1129
|
+
}), nr = v(() => {
|
|
1130
|
+
const t = (e) => {
|
|
1100
1131
|
if (e.composing || !e.editable)
|
|
1101
1132
|
return;
|
|
1102
|
-
const
|
|
1133
|
+
const r = P.type(), n = R.type(), o = O.type(), a = e.state, l = (i, d) => {
|
|
1103
1134
|
let u = !1;
|
|
1104
1135
|
const f = `${d + 1}.`;
|
|
1105
1136
|
return i.label !== f && (i.label = f, u = !0), u;
|
|
1106
1137
|
};
|
|
1107
1138
|
let s = a.tr, c = !1;
|
|
1108
1139
|
a.doc.descendants((i, d, u, f) => {
|
|
1109
|
-
if (i.type ===
|
|
1110
|
-
const
|
|
1111
|
-
(
|
|
1140
|
+
if (i.type === n) {
|
|
1141
|
+
const m = i.maybeChild(0);
|
|
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) => {
|
|
1112
1143
|
if (h.type === o) {
|
|
1113
1144
|
const X = { ...h.attrs };
|
|
1114
|
-
l(X,
|
|
1145
|
+
l(X, Pe) && (s = s.setNodeMarkup(_, void 0, X));
|
|
1115
1146
|
}
|
|
1116
1147
|
return !1;
|
|
1117
1148
|
}));
|
|
1118
|
-
} else if (i.type === o && (u == null ? void 0 : u.type) ===
|
|
1119
|
-
const
|
|
1149
|
+
} else if (i.type === o && (u == null ? void 0 : u.type) === r) {
|
|
1150
|
+
const m = { ...i.attrs };
|
|
1120
1151
|
let h = !1;
|
|
1121
|
-
|
|
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);
|
|
1122
1153
|
}
|
|
1123
1154
|
}), c && e.dispatch(s.setMeta("addToHistory", !1));
|
|
1124
1155
|
};
|
|
1125
1156
|
return new x({
|
|
1126
1157
|
key: new C("MILKDOWN_KEEP_LIST_ORDER"),
|
|
1127
|
-
view: (e) => (
|
|
1128
|
-
update: (
|
|
1129
|
-
|
|
1158
|
+
view: (e) => (t(e), {
|
|
1159
|
+
update: (r) => {
|
|
1160
|
+
t(r);
|
|
1130
1161
|
}
|
|
1131
1162
|
})
|
|
1132
1163
|
});
|
|
1133
|
-
}),
|
|
1164
|
+
}), or = [
|
|
1134
1165
|
H,
|
|
1135
|
-
Pt,
|
|
1136
|
-
Yt,
|
|
1137
|
-
Be,
|
|
1138
|
-
Jt,
|
|
1139
|
-
Ut,
|
|
1140
|
-
Wt,
|
|
1141
|
-
Ft,
|
|
1142
|
-
qt,
|
|
1143
1166
|
zt,
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1167
|
+
er,
|
|
1168
|
+
Re,
|
|
1169
|
+
tr,
|
|
1170
|
+
Zt,
|
|
1171
|
+
Gt,
|
|
1172
|
+
Ut,
|
|
1173
|
+
jt,
|
|
1174
|
+
Xt,
|
|
1175
|
+
rr,
|
|
1176
|
+
nr
|
|
1177
|
+
], Nr = [xt, At, Lt, Tt, or].flat();
|
|
1147
1178
|
export {
|
|
1148
1179
|
be as blockquoteAttr,
|
|
1149
|
-
|
|
1180
|
+
ut as blockquoteKeymap,
|
|
1150
1181
|
U as blockquoteSchema,
|
|
1151
|
-
|
|
1152
|
-
|
|
1182
|
+
Te as bulletListAttr,
|
|
1183
|
+
It as bulletListKeymap,
|
|
1153
1184
|
R as bulletListSchema,
|
|
1154
|
-
|
|
1155
|
-
|
|
1185
|
+
we as codeBlockAttr,
|
|
1186
|
+
pt as codeBlockKeymap,
|
|
1156
1187
|
Y as codeBlockSchema,
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1188
|
+
Lt as commands,
|
|
1189
|
+
Nr as commonmark,
|
|
1190
|
+
ve as createCodeBlockCommand,
|
|
1191
|
+
mt as createCodeBlockInputRule,
|
|
1192
|
+
Bt as defaultConfig,
|
|
1193
|
+
ot as docSchema,
|
|
1163
1194
|
Ie as downgradeHeadingCommand,
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1195
|
+
le as emphasisAttr,
|
|
1196
|
+
Ze as emphasisKeymap,
|
|
1197
|
+
ce as emphasisSchema,
|
|
1198
|
+
xe as hardbreakAttr,
|
|
1199
|
+
er as hardbreakClearMarkPlugin,
|
|
1200
|
+
Re as hardbreakFilterNodes,
|
|
1201
|
+
tr as hardbreakFilterPlugin,
|
|
1202
|
+
ht as hardbreakKeymap,
|
|
1203
|
+
w as hardbreakSchema,
|
|
1173
1204
|
Me as headingAttr,
|
|
1174
|
-
|
|
1175
|
-
|
|
1205
|
+
j as headingIdGenerator,
|
|
1206
|
+
it as headingKeymap,
|
|
1176
1207
|
D as headingSchema,
|
|
1177
|
-
|
|
1208
|
+
Le as hrAttr,
|
|
1178
1209
|
J as hrSchema,
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1210
|
+
$e as htmlAttr,
|
|
1211
|
+
Ct as htmlSchema,
|
|
1212
|
+
Ce as imageAttr,
|
|
1213
|
+
E as imageSchema,
|
|
1214
|
+
pe as inlineCodeAttr,
|
|
1215
|
+
tt as inlineCodeKeymap,
|
|
1183
1216
|
A as inlineCodeSchema,
|
|
1184
|
-
|
|
1217
|
+
Zt as inlineNodesCursorPlugin,
|
|
1185
1218
|
H as inlineSyncConfig,
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1219
|
+
zt as inlineSyncPlugin,
|
|
1220
|
+
At as inputrules,
|
|
1221
|
+
Ae as insertHardbreakCommand,
|
|
1222
|
+
yt as insertHrCommand,
|
|
1223
|
+
kt as insertHrInputRule,
|
|
1224
|
+
gt as insertImageCommand,
|
|
1225
|
+
br as insertImageInputRule,
|
|
1226
|
+
Tt as keymap,
|
|
1194
1227
|
Ke as liftListItemCommand,
|
|
1195
|
-
|
|
1228
|
+
fe as linkAttr,
|
|
1196
1229
|
L as linkSchema,
|
|
1197
1230
|
He as listItemAttr,
|
|
1198
|
-
|
|
1231
|
+
wt as listItemKeymap,
|
|
1199
1232
|
O as listItemSchema,
|
|
1200
1233
|
De as orderedListAttr,
|
|
1201
|
-
|
|
1234
|
+
Nt as orderedListKeymap,
|
|
1202
1235
|
P as orderedListSchema,
|
|
1203
1236
|
ke as paragraphAttr,
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
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,
|
|
1212
1245
|
_e as sinkListItemCommand,
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1246
|
+
Be as splitListItemCommand,
|
|
1247
|
+
de as strongAttr,
|
|
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,
|
|
1223
1256
|
me as toggleStrongCommand,
|
|
1224
1257
|
ye as turnIntoTextCommand,
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
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,
|
|
1232
1265
|
I as wrapInHeadingCommand,
|
|
1233
|
-
|
|
1266
|
+
ct as wrapInHeadingInputRule,
|
|
1234
1267
|
Oe as wrapInOrderedListCommand,
|
|
1235
|
-
|
|
1268
|
+
bt as wrapInOrderedListInputRule
|
|
1236
1269
|
};
|
|
1237
1270
|
//# sourceMappingURL=index.es.js.map
|