@milkdown/preset-commonmark 7.2.2 → 7.2.4
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/index.es.js +675 -648
- package/lib/index.es.js.map +1 -1
- package/lib/mark/emphasis.d.ts.map +1 -1
- package/lib/mark/link.d.ts.map +1 -1
- package/lib/mark/strong.d.ts.map +1 -1
- package/lib/node/blockquote.d.ts.map +1 -1
- package/lib/node/bullet-list.d.ts.map +1 -1
- package/lib/node/code-block.d.ts.map +1 -1
- package/lib/node/list-item.d.ts.map +1 -1
- package/lib/node/ordered-list.d.ts.map +1 -1
- package/lib/node/paragraph.d.ts.map +1 -1
- package/lib/plugin/index.d.ts +1 -0
- 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/inline-sync-plugin/regexp.d.ts +1 -0
- package/lib/plugin/inline-sync-plugin/regexp.d.ts.map +1 -1
- package/lib/plugin/inline-sync-plugin/replacer.d.ts.map +1 -1
- package/lib/plugin/remark-marker-plugin.d.ts +2 -0
- package/lib/plugin/remark-marker-plugin.d.ts.map +1 -0
- package/package.json +7 -7
- package/src/composed/plugins.ts +2 -1
- package/src/mark/emphasis.ts +14 -6
- package/src/mark/inline-code.ts +4 -4
- package/src/mark/link.ts +5 -5
- package/src/mark/strong.ts +14 -6
- package/src/node/blockquote.ts +2 -2
- package/src/node/bullet-list.ts +2 -2
- package/src/node/code-block.ts +2 -2
- package/src/node/hardbreak.ts +2 -2
- package/src/node/heading.ts +10 -10
- package/src/node/hr.ts +5 -5
- package/src/node/image.ts +6 -6
- package/src/node/list-item.ts +8 -7
- package/src/node/ordered-list.ts +3 -3
- package/src/node/paragraph.ts +1 -1
- package/src/plugin/hardbreak-clear-mark-plugin.ts +4 -4
- package/src/plugin/index.ts +1 -0
- package/src/plugin/inline-sync-plugin/inline-sync-plugin.ts +0 -2
- package/src/plugin/inline-sync-plugin/regexp.ts +3 -1
- package/src/plugin/inline-sync-plugin/replacer.ts +11 -0
- package/src/plugin/inline-sync-plugin/utils.ts +4 -4
- package/src/plugin/remark-marker-plugin.ts +20 -0
- package/src/plugin/sync-heading-id-plugin.ts +1 -1
- package/src/plugin/sync-list-order-plugin.ts +4 -4
package/lib/index.es.js
CHANGED
|
@@ -1,155 +1,167 @@
|
|
|
1
|
-
import { $markAttr as
|
|
2
|
-
import { commandsCtx as
|
|
3
|
-
import { toggleMark as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { expectDomTypeError as
|
|
6
|
-
import { textblockTypeInputRule as
|
|
7
|
-
import
|
|
8
|
-
import { TextSelection as
|
|
9
|
-
import { findSelectedNodeOfType as
|
|
10
|
-
import { sinkListItem as
|
|
11
|
-
import { ReplaceStep as
|
|
12
|
-
import { Decoration as
|
|
13
|
-
import { visit as
|
|
14
|
-
import
|
|
15
|
-
const
|
|
1
|
+
import { $markAttr as V, $markSchema as j, $command as h, $useKeymap as N, $node as Ye, $nodeAttr as I, $nodeSchema as C, $ctx as Z, $inputRule as w, pipe as At, $prose as O, $remark as $ } from "@milkdown/utils";
|
|
2
|
+
import { remarkStringifyOptionsCtx as Je, commandsCtx as y, editorViewCtx as X, serializerCtx as vt, parserCtx as Ht } from "@milkdown/core";
|
|
3
|
+
import { toggleMark as ee, setBlockType as _, wrapIn as te } from "@milkdown/prose/commands";
|
|
4
|
+
import { Fragment as Bt } from "@milkdown/prose/model";
|
|
5
|
+
import { expectDomTypeError as A } from "@milkdown/exception";
|
|
6
|
+
import { textblockTypeInputRule as Qe, wrappingInputRule as re, InputRule as Xe } from "@milkdown/prose/inputrules";
|
|
7
|
+
import Ot from "@sindresorhus/slugify";
|
|
8
|
+
import { TextSelection as G, Selection as Ze, PluginKey as T, Plugin as K } from "@milkdown/prose/state";
|
|
9
|
+
import { findSelectedNodeOfType as Tt } from "@milkdown/prose";
|
|
10
|
+
import { sinkListItem as Kt, liftListItem as et, splitListItem as Dt } from "@milkdown/prose/schema-list";
|
|
11
|
+
import { ReplaceStep as Rt, AddMarkStep as Pt } from "@milkdown/prose/transform";
|
|
12
|
+
import { Decoration as ze, DecorationSet as Ue } from "@milkdown/prose/view";
|
|
13
|
+
import { visit as ae } from "unist-util-visit";
|
|
14
|
+
import Et from "remark-inline-links";
|
|
15
|
+
const tt = (t, e) => {
|
|
16
16
|
var o;
|
|
17
17
|
if (!(e.childCount >= 1 && ((o = e.lastChild) == null ? void 0 : o.type.name) === "hardbreak")) {
|
|
18
18
|
t.next(e.content);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
const a = [];
|
|
22
|
-
e.content.forEach((s,
|
|
23
|
-
|
|
24
|
-
}), t.next(
|
|
22
|
+
e.content.forEach((s, l, i) => {
|
|
23
|
+
i !== e.childCount - 1 && a.push(s);
|
|
24
|
+
}), t.next(Bt.fromArray(a));
|
|
25
25
|
}, n = (t, e) => (Object.assign(t, {
|
|
26
26
|
meta: {
|
|
27
27
|
package: "@milkdown/preset-commonmark",
|
|
28
28
|
...e
|
|
29
29
|
}
|
|
30
|
-
}), t),
|
|
31
|
-
n(
|
|
30
|
+
}), t), ne = V("emphasis");
|
|
31
|
+
n(ne, {
|
|
32
32
|
displayName: "Attr<emphasis>",
|
|
33
33
|
group: "Emphasis"
|
|
34
34
|
});
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const z = j("emphasis", (t) => ({
|
|
36
|
+
attrs: {
|
|
37
|
+
marker: {
|
|
38
|
+
default: t.get(Je).emphasis || "*"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
37
41
|
parseDOM: [
|
|
38
42
|
{ tag: "i" },
|
|
39
43
|
{ tag: "em" },
|
|
40
44
|
{ style: "font-style", getAttrs: (e) => e === "italic" }
|
|
41
45
|
],
|
|
42
|
-
toDOM: (e) => ["em", t.get(
|
|
46
|
+
toDOM: (e) => ["em", t.get(ne.key)(e)],
|
|
43
47
|
parseMarkdown: {
|
|
44
48
|
match: (e) => e.type === "emphasis",
|
|
45
49
|
runner: (e, r, a) => {
|
|
46
|
-
e.openMark(a), e.next(r.children), e.closeMark(a);
|
|
50
|
+
e.openMark(a, { marker: r.marker }), e.next(r.children), e.closeMark(a);
|
|
47
51
|
}
|
|
48
52
|
},
|
|
49
53
|
toMarkdown: {
|
|
50
54
|
match: (e) => e.type.name === "emphasis",
|
|
51
55
|
runner: (e, r) => {
|
|
52
|
-
e.withMark(r, "emphasis"
|
|
56
|
+
e.withMark(r, "emphasis", void 0, {
|
|
57
|
+
marker: r.attrs.marker
|
|
58
|
+
});
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
}));
|
|
56
|
-
n(
|
|
62
|
+
n(z.mark, {
|
|
57
63
|
displayName: "MarkSchema<emphasis>",
|
|
58
64
|
group: "Emphasis"
|
|
59
65
|
});
|
|
60
|
-
n(
|
|
66
|
+
n(z.ctx, {
|
|
61
67
|
displayName: "MarkSchemaCtx<emphasis>",
|
|
62
68
|
group: "Emphasis"
|
|
63
69
|
});
|
|
64
|
-
const
|
|
65
|
-
n(
|
|
70
|
+
const oe = h("ToggleEmphasis", (t) => () => ee(z.type(t)));
|
|
71
|
+
n(oe, {
|
|
66
72
|
displayName: "Command<toggleEmphasisCommand>",
|
|
67
73
|
group: "Emphasis"
|
|
68
74
|
});
|
|
69
|
-
const
|
|
75
|
+
const se = N("emphasisKeymap", {
|
|
70
76
|
ToggleEmphasis: {
|
|
71
77
|
shortcuts: "Mod-i",
|
|
72
78
|
command: (t) => {
|
|
73
|
-
const e = t.get(
|
|
74
|
-
return () => e.call(
|
|
79
|
+
const e = t.get(y);
|
|
80
|
+
return () => e.call(oe.key);
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
});
|
|
78
|
-
n(
|
|
84
|
+
n(se.ctx, {
|
|
79
85
|
displayName: "KeymapCtx<emphasis>",
|
|
80
86
|
group: "Emphasis"
|
|
81
87
|
});
|
|
82
|
-
n(
|
|
88
|
+
n(se.shortcuts, {
|
|
83
89
|
displayName: "Keymap<emphasis>",
|
|
84
90
|
group: "Emphasis"
|
|
85
91
|
});
|
|
86
|
-
const
|
|
87
|
-
n(
|
|
92
|
+
const le = V("strong");
|
|
93
|
+
n(le, {
|
|
88
94
|
displayName: "Attr<strong>",
|
|
89
95
|
group: "Strong"
|
|
90
96
|
});
|
|
91
|
-
const
|
|
92
|
-
|
|
97
|
+
const U = j("strong", (t) => ({
|
|
98
|
+
attrs: {
|
|
99
|
+
marker: {
|
|
100
|
+
default: t.get(Je).strong || "*"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
93
103
|
parseDOM: [
|
|
94
104
|
{ tag: "b" },
|
|
95
105
|
{ tag: "strong" },
|
|
96
106
|
{ style: "font-style", getAttrs: (e) => e === "bold" }
|
|
97
107
|
],
|
|
98
|
-
toDOM: (e) => ["strong", t.get(
|
|
108
|
+
toDOM: (e) => ["strong", t.get(le.key)(e)],
|
|
99
109
|
parseMarkdown: {
|
|
100
110
|
match: (e) => e.type === "strong",
|
|
101
111
|
runner: (e, r, a) => {
|
|
102
|
-
e.openMark(a), e.next(r.children), e.closeMark(a);
|
|
112
|
+
e.openMark(a, { marker: r.marker }), e.next(r.children), e.closeMark(a);
|
|
103
113
|
}
|
|
104
114
|
},
|
|
105
115
|
toMarkdown: {
|
|
106
116
|
match: (e) => e.type.name === "strong",
|
|
107
117
|
runner: (e, r) => {
|
|
108
|
-
e.withMark(r, "strong"
|
|
118
|
+
e.withMark(r, "strong", void 0, {
|
|
119
|
+
marker: r.attrs.marker
|
|
120
|
+
});
|
|
109
121
|
}
|
|
110
122
|
}
|
|
111
123
|
}));
|
|
112
|
-
n(
|
|
124
|
+
n(U.mark, {
|
|
113
125
|
displayName: "MarkSchema<strong>",
|
|
114
126
|
group: "Strong"
|
|
115
127
|
});
|
|
116
|
-
n(
|
|
128
|
+
n(U.ctx, {
|
|
117
129
|
displayName: "MarkSchemaCtx<strong>",
|
|
118
130
|
group: "Strong"
|
|
119
131
|
});
|
|
120
|
-
const
|
|
121
|
-
n(
|
|
132
|
+
const ie = h("ToggleStrong", (t) => () => ee(U.type(t)));
|
|
133
|
+
n(ie, {
|
|
122
134
|
displayName: "Command<toggleStrongCommand>",
|
|
123
135
|
group: "Strong"
|
|
124
136
|
});
|
|
125
|
-
const
|
|
137
|
+
const ce = N("strongKeymap", {
|
|
126
138
|
ToggleBold: {
|
|
127
139
|
shortcuts: ["Mod-b"],
|
|
128
140
|
command: (t) => {
|
|
129
|
-
const e = t.get(
|
|
130
|
-
return () => e.call(
|
|
141
|
+
const e = t.get(y);
|
|
142
|
+
return () => e.call(ie.key);
|
|
131
143
|
}
|
|
132
144
|
}
|
|
133
145
|
});
|
|
134
|
-
n(
|
|
146
|
+
n(ce.ctx, {
|
|
135
147
|
displayName: "KeymapCtx<strong>",
|
|
136
148
|
group: "Strong"
|
|
137
149
|
});
|
|
138
|
-
n(
|
|
150
|
+
n(ce.shortcuts, {
|
|
139
151
|
displayName: "Keymap<strong>",
|
|
140
152
|
group: "Strong"
|
|
141
153
|
});
|
|
142
|
-
const
|
|
143
|
-
n(
|
|
154
|
+
const de = V("inlineCode");
|
|
155
|
+
n(de, {
|
|
144
156
|
displayName: "Attr<inlineCode>",
|
|
145
157
|
group: "InlineCode"
|
|
146
158
|
});
|
|
147
|
-
const
|
|
159
|
+
const x = j("inlineCode", (t) => ({
|
|
148
160
|
priority: 100,
|
|
149
161
|
code: !0,
|
|
150
162
|
inclusive: !1,
|
|
151
163
|
parseDOM: [{ tag: "code" }],
|
|
152
|
-
toDOM: (e) => ["code", t.get(
|
|
164
|
+
toDOM: (e) => ["code", t.get(de.key)(e)],
|
|
153
165
|
parseMarkdown: {
|
|
154
166
|
match: (e) => e.type === "inlineCode",
|
|
155
167
|
runner: (e, r, a) => {
|
|
@@ -163,50 +175,50 @@ const b = F("inlineCode", (t) => ({
|
|
|
163
175
|
}
|
|
164
176
|
}
|
|
165
177
|
}));
|
|
166
|
-
n(
|
|
178
|
+
n(x.mark, {
|
|
167
179
|
displayName: "MarkSchema<inlineCode>",
|
|
168
180
|
group: "InlineCode"
|
|
169
181
|
});
|
|
170
|
-
n(
|
|
182
|
+
n(x.ctx, {
|
|
171
183
|
displayName: "MarkSchemaCtx<inlineCode>",
|
|
172
184
|
group: "InlineCode"
|
|
173
185
|
});
|
|
174
|
-
const
|
|
175
|
-
const { selection:
|
|
176
|
-
if (
|
|
186
|
+
const me = h("ToggleInlineCode", (t) => () => (e, r) => {
|
|
187
|
+
const { selection: a, tr: o } = e;
|
|
188
|
+
if (a.empty)
|
|
177
189
|
return !1;
|
|
178
|
-
const { from:
|
|
179
|
-
return
|
|
180
|
-
|
|
181
|
-
}),
|
|
190
|
+
const { from: s, to: l } = a;
|
|
191
|
+
return e.doc.rangeHasMark(s, l, x.type(t)) ? (r == null || r(o.removeMark(s, l, x.type(t))), !0) : (Object.keys(e.schema.marks).filter((d) => d !== x.type.name).map((d) => e.schema.marks[d]).forEach((d) => {
|
|
192
|
+
o.removeMark(s, l, d);
|
|
193
|
+
}), r == null || r(o.addMark(s, l, x.type(t).create())), !0);
|
|
182
194
|
});
|
|
183
|
-
n(
|
|
195
|
+
n(me, {
|
|
184
196
|
displayName: "Command<toggleInlineCodeCommand>",
|
|
185
197
|
group: "InlineCode"
|
|
186
198
|
});
|
|
187
|
-
const
|
|
199
|
+
const ue = N("inlineCodeKeymap", {
|
|
188
200
|
ToggleInlineCode: {
|
|
189
201
|
shortcuts: "Mod-e",
|
|
190
202
|
command: (t) => {
|
|
191
|
-
const e = t.get(
|
|
192
|
-
return () => e.call(
|
|
203
|
+
const e = t.get(y);
|
|
204
|
+
return () => e.call(me.key);
|
|
193
205
|
}
|
|
194
206
|
}
|
|
195
207
|
});
|
|
196
|
-
n(
|
|
208
|
+
n(ue.ctx, {
|
|
197
209
|
displayName: "KeymapCtx<inlineCode>",
|
|
198
210
|
group: "InlineCode"
|
|
199
211
|
});
|
|
200
|
-
n(
|
|
212
|
+
n(ue.shortcuts, {
|
|
201
213
|
displayName: "Keymap<inlineCode>",
|
|
202
214
|
group: "InlineCode"
|
|
203
215
|
});
|
|
204
|
-
const
|
|
205
|
-
n(
|
|
216
|
+
const pe = V("link");
|
|
217
|
+
n(pe, {
|
|
206
218
|
displayName: "Attr<link>",
|
|
207
219
|
group: "Link"
|
|
208
220
|
});
|
|
209
|
-
const
|
|
221
|
+
const B = j("link", (t) => ({
|
|
210
222
|
attrs: {
|
|
211
223
|
href: {},
|
|
212
224
|
title: { default: null }
|
|
@@ -216,12 +228,12 @@ const v = F("link", (t) => ({
|
|
|
216
228
|
tag: "a[href]",
|
|
217
229
|
getAttrs: (e) => {
|
|
218
230
|
if (!(e instanceof HTMLElement))
|
|
219
|
-
throw
|
|
231
|
+
throw A(e);
|
|
220
232
|
return { href: e.getAttribute("href"), title: e.getAttribute("title") };
|
|
221
233
|
}
|
|
222
234
|
}
|
|
223
235
|
],
|
|
224
|
-
toDOM: (e) => ["a", { ...t.get(
|
|
236
|
+
toDOM: (e) => ["a", { ...t.get(pe.key)(e), ...e.attrs }],
|
|
225
237
|
parseMarkdown: {
|
|
226
238
|
match: (e) => e.type === "link",
|
|
227
239
|
runner: (e, r, a) => {
|
|
@@ -239,38 +251,38 @@ const v = F("link", (t) => ({
|
|
|
239
251
|
}
|
|
240
252
|
}
|
|
241
253
|
}));
|
|
242
|
-
n(
|
|
254
|
+
n(B.mark, {
|
|
243
255
|
displayName: "MarkSchema<link>",
|
|
244
256
|
group: "Link"
|
|
245
257
|
});
|
|
246
|
-
const
|
|
247
|
-
n(
|
|
258
|
+
const rt = h("ToggleLink", (t) => (e = {}) => ee(B.type(t), e));
|
|
259
|
+
n(rt, {
|
|
248
260
|
displayName: "Command<toggleLinkCommand>",
|
|
249
261
|
group: "Link"
|
|
250
262
|
});
|
|
251
|
-
const
|
|
252
|
-
if (!
|
|
263
|
+
const at = h("UpdateLink", (t) => (e = {}) => (r, a) => {
|
|
264
|
+
if (!a)
|
|
253
265
|
return !1;
|
|
254
|
-
let
|
|
255
|
-
const { selection:
|
|
256
|
-
if (
|
|
257
|
-
if (
|
|
258
|
-
return
|
|
259
|
-
}), !
|
|
266
|
+
let o, s = -1;
|
|
267
|
+
const { selection: l } = r, { from: i, to: c } = l;
|
|
268
|
+
if (r.doc.nodesBetween(i, i === c ? c + 1 : c, (g, f) => {
|
|
269
|
+
if (B.type(t).isInSet(g.marks))
|
|
270
|
+
return o = g, s = f, !1;
|
|
271
|
+
}), !o)
|
|
260
272
|
return !1;
|
|
261
|
-
const
|
|
262
|
-
if (!
|
|
273
|
+
const d = o.marks.find(({ type: g }) => g === B.type(t));
|
|
274
|
+
if (!d)
|
|
263
275
|
return !1;
|
|
264
|
-
const
|
|
265
|
-
return
|
|
266
|
-
u.removeMark(
|
|
276
|
+
const m = s, p = s + o.nodeSize, { tr: u } = r, k = B.type(t).create({ ...d.attrs, ...e });
|
|
277
|
+
return k ? (a(
|
|
278
|
+
u.removeMark(m, p, d).addMark(m, p, k).setSelection(new G(u.selection.$anchor)).scrollIntoView()
|
|
267
279
|
), !0) : !1;
|
|
268
280
|
});
|
|
269
|
-
n(
|
|
281
|
+
n(at, {
|
|
270
282
|
displayName: "Command<updateLinkCommand>",
|
|
271
283
|
group: "Link"
|
|
272
284
|
});
|
|
273
|
-
const
|
|
285
|
+
const nt = Ye("doc", () => ({
|
|
274
286
|
content: "block+",
|
|
275
287
|
parseMarkdown: {
|
|
276
288
|
match: ({ type: t }) => t === "root",
|
|
@@ -285,20 +297,20 @@ const rt = ze("doc", () => ({
|
|
|
285
297
|
}
|
|
286
298
|
}
|
|
287
299
|
}));
|
|
288
|
-
n(
|
|
300
|
+
n(nt, {
|
|
289
301
|
displayName: "NodeSchema<doc>",
|
|
290
302
|
group: "Doc"
|
|
291
303
|
});
|
|
292
|
-
const
|
|
293
|
-
n(
|
|
304
|
+
const ge = I("paragraph");
|
|
305
|
+
n(ge, {
|
|
294
306
|
displayName: "Attr<paragraph>",
|
|
295
307
|
group: "Paragraph"
|
|
296
308
|
});
|
|
297
|
-
const
|
|
309
|
+
const v = C("paragraph", (t) => ({
|
|
298
310
|
content: "inline*",
|
|
299
311
|
group: "block",
|
|
300
312
|
parseDOM: [{ tag: "p" }],
|
|
301
|
-
toDOM: (e) => ["p", t.get(
|
|
313
|
+
toDOM: (e) => ["p", t.get(ge.key)(e), 0],
|
|
302
314
|
parseMarkdown: {
|
|
303
315
|
match: (e) => e.type === "paragraph",
|
|
304
316
|
runner: (e, r, a) => {
|
|
@@ -308,52 +320,52 @@ const w = I("paragraph", (t) => ({
|
|
|
308
320
|
toMarkdown: {
|
|
309
321
|
match: (e) => e.type.name === "paragraph",
|
|
310
322
|
runner: (e, r) => {
|
|
311
|
-
e.openNode("paragraph"),
|
|
323
|
+
e.openNode("paragraph"), tt(e, r), e.closeNode();
|
|
312
324
|
}
|
|
313
325
|
}
|
|
314
326
|
}));
|
|
315
|
-
n(
|
|
327
|
+
n(v.node, {
|
|
316
328
|
displayName: "NodeSchema<paragraph>",
|
|
317
329
|
group: "Paragraph"
|
|
318
330
|
});
|
|
319
|
-
n(
|
|
331
|
+
n(v.ctx, {
|
|
320
332
|
displayName: "NodeSchemaCtx<paragraph>",
|
|
321
333
|
group: "Paragraph"
|
|
322
334
|
});
|
|
323
|
-
const
|
|
324
|
-
n(
|
|
335
|
+
const he = h("TurnIntoText", (t) => () => _(v.type(t)));
|
|
336
|
+
n(he, {
|
|
325
337
|
displayName: "Command<turnIntoTextCommand>",
|
|
326
338
|
group: "Paragraph"
|
|
327
339
|
});
|
|
328
|
-
const
|
|
340
|
+
const ye = N("paragraphKeymap", {
|
|
329
341
|
TurnIntoText: {
|
|
330
342
|
shortcuts: "Mod-Alt-0",
|
|
331
343
|
command: (t) => {
|
|
332
|
-
const e = t.get(
|
|
333
|
-
return () => e.call(
|
|
344
|
+
const e = t.get(y);
|
|
345
|
+
return () => e.call(he.key);
|
|
334
346
|
}
|
|
335
347
|
}
|
|
336
348
|
});
|
|
337
|
-
n(
|
|
349
|
+
n(ye.ctx, {
|
|
338
350
|
displayName: "KeymapCtx<paragraph>",
|
|
339
351
|
group: "Paragraph"
|
|
340
352
|
});
|
|
341
|
-
n(
|
|
353
|
+
n(ye.shortcuts, {
|
|
342
354
|
displayName: "Keymap<paragraph>",
|
|
343
355
|
group: "Paragraph"
|
|
344
356
|
});
|
|
345
|
-
const
|
|
346
|
-
n(
|
|
357
|
+
const _t = Array(6).fill(0).map((t, e) => e + 1), $t = (t) => Ot(t.textContent), Y = Z($t, "headingIdGenerator");
|
|
358
|
+
n(Y, {
|
|
347
359
|
displayName: "Ctx<HeadingIdGenerator>",
|
|
348
360
|
group: "Heading"
|
|
349
361
|
});
|
|
350
|
-
const
|
|
351
|
-
n(
|
|
362
|
+
const ke = I("heading");
|
|
363
|
+
n(ke, {
|
|
352
364
|
displayName: "Attr<heading>",
|
|
353
365
|
group: "Heading"
|
|
354
366
|
});
|
|
355
|
-
const
|
|
356
|
-
const e = t.get(
|
|
367
|
+
const H = C("heading", (t) => {
|
|
368
|
+
const e = t.get(Y.key);
|
|
357
369
|
return {
|
|
358
370
|
content: "inline*",
|
|
359
371
|
group: "block",
|
|
@@ -366,18 +378,18 @@ const A = I("heading", (t) => {
|
|
|
366
378
|
default: 1
|
|
367
379
|
}
|
|
368
380
|
},
|
|
369
|
-
parseDOM:
|
|
381
|
+
parseDOM: _t.map((r) => ({
|
|
370
382
|
tag: `h${r}`,
|
|
371
383
|
getAttrs: (a) => {
|
|
372
384
|
if (!(a instanceof HTMLElement))
|
|
373
|
-
throw
|
|
385
|
+
throw A(a);
|
|
374
386
|
return { level: r, id: a.id };
|
|
375
387
|
}
|
|
376
388
|
})),
|
|
377
389
|
toDOM: (r) => [
|
|
378
390
|
`h${r.attrs.level}`,
|
|
379
391
|
{
|
|
380
|
-
...t.get(
|
|
392
|
+
...t.get(ke.key)(r),
|
|
381
393
|
id: r.attrs.id || e(r)
|
|
382
394
|
},
|
|
383
395
|
0
|
|
@@ -392,123 +404,123 @@ const A = I("heading", (t) => {
|
|
|
392
404
|
toMarkdown: {
|
|
393
405
|
match: (r) => r.type.name === "heading",
|
|
394
406
|
runner: (r, a) => {
|
|
395
|
-
r.openNode("heading", void 0, { depth: a.attrs.level }),
|
|
407
|
+
r.openNode("heading", void 0, { depth: a.attrs.level }), tt(r, a), r.closeNode();
|
|
396
408
|
}
|
|
397
409
|
}
|
|
398
410
|
};
|
|
399
411
|
});
|
|
400
|
-
n(
|
|
412
|
+
n(H.node, {
|
|
401
413
|
displayName: "NodeSchema<heading>",
|
|
402
414
|
group: "Heading"
|
|
403
415
|
});
|
|
404
|
-
n(
|
|
416
|
+
n(H.ctx, {
|
|
405
417
|
displayName: "NodeSchemaCtx<heading>",
|
|
406
418
|
group: "Heading"
|
|
407
419
|
});
|
|
408
|
-
const
|
|
409
|
-
var
|
|
410
|
-
const r = ((
|
|
420
|
+
const ot = w((t) => Qe(/^(?<hashes>#+)\s$/, H.type(t), (e) => {
|
|
421
|
+
var l, i;
|
|
422
|
+
const r = ((i = (l = e.groups) == null ? void 0 : l.hashes) == null ? void 0 : i.length) || 0, a = t.get(X), { $from: o } = a.state.selection, s = o.node();
|
|
411
423
|
if (s.type.name === "heading") {
|
|
412
424
|
let c = Number(s.attrs.level) + Number(r);
|
|
413
425
|
return c > 6 && (c = 6), { level: c };
|
|
414
426
|
}
|
|
415
427
|
return { level: r };
|
|
416
428
|
}));
|
|
417
|
-
n(
|
|
429
|
+
n(ot, {
|
|
418
430
|
displayName: "InputRule<wrapInHeadingInputRule>",
|
|
419
431
|
group: "Heading"
|
|
420
432
|
});
|
|
421
|
-
const
|
|
422
|
-
n(
|
|
433
|
+
const b = h("WrapInHeading", (t) => (e) => (e ?? (e = 1), e < 1 ? _(v.type(t)) : _(H.type(t), { level: e })));
|
|
434
|
+
n(b, {
|
|
423
435
|
displayName: "Command<wrapInHeadingCommand>",
|
|
424
436
|
group: "Heading"
|
|
425
437
|
});
|
|
426
|
-
const
|
|
427
|
-
const { $from:
|
|
428
|
-
if (
|
|
438
|
+
const fe = h("DowngradeHeading", (t) => () => (e, r, a) => {
|
|
439
|
+
const { $from: o } = e.selection, s = o.node();
|
|
440
|
+
if (s.type !== H.type(t) || !e.selection.empty || o.parentOffset !== 0)
|
|
429
441
|
return !1;
|
|
430
|
-
const
|
|
431
|
-
return
|
|
432
|
-
|
|
433
|
-
...
|
|
434
|
-
level:
|
|
442
|
+
const l = s.attrs.level - 1;
|
|
443
|
+
return l ? (r == null || r(
|
|
444
|
+
e.tr.setNodeMarkup(e.selection.$from.before(), void 0, {
|
|
445
|
+
...s.attrs,
|
|
446
|
+
level: l
|
|
435
447
|
})
|
|
436
|
-
), !0) :
|
|
448
|
+
), !0) : _(v.type(t))(e, r, a);
|
|
437
449
|
});
|
|
438
|
-
n(
|
|
450
|
+
n(fe, {
|
|
439
451
|
displayName: "Command<downgradeHeadingCommand>",
|
|
440
452
|
group: "Heading"
|
|
441
453
|
});
|
|
442
|
-
const
|
|
454
|
+
const Ne = N("headingKeymap", {
|
|
443
455
|
TurnIntoH1: {
|
|
444
456
|
shortcuts: "Mod-Alt-1",
|
|
445
457
|
command: (t) => {
|
|
446
|
-
const e = t.get(
|
|
447
|
-
return () => e.call(
|
|
458
|
+
const e = t.get(y);
|
|
459
|
+
return () => e.call(b.key, 1);
|
|
448
460
|
}
|
|
449
461
|
},
|
|
450
462
|
TurnIntoH2: {
|
|
451
463
|
shortcuts: "Mod-Alt-2",
|
|
452
464
|
command: (t) => {
|
|
453
|
-
const e = t.get(
|
|
454
|
-
return () => e.call(
|
|
465
|
+
const e = t.get(y);
|
|
466
|
+
return () => e.call(b.key, 2);
|
|
455
467
|
}
|
|
456
468
|
},
|
|
457
469
|
TurnIntoH3: {
|
|
458
470
|
shortcuts: "Mod-Alt-3",
|
|
459
471
|
command: (t) => {
|
|
460
|
-
const e = t.get(
|
|
461
|
-
return () => e.call(
|
|
472
|
+
const e = t.get(y);
|
|
473
|
+
return () => e.call(b.key, 3);
|
|
462
474
|
}
|
|
463
475
|
},
|
|
464
476
|
TurnIntoH4: {
|
|
465
477
|
shortcuts: "Mod-Alt-4",
|
|
466
478
|
command: (t) => {
|
|
467
|
-
const e = t.get(
|
|
468
|
-
return () => e.call(
|
|
479
|
+
const e = t.get(y);
|
|
480
|
+
return () => e.call(b.key, 4);
|
|
469
481
|
}
|
|
470
482
|
},
|
|
471
483
|
TurnIntoH5: {
|
|
472
484
|
shortcuts: "Mod-Alt-5",
|
|
473
485
|
command: (t) => {
|
|
474
|
-
const e = t.get(
|
|
475
|
-
return () => e.call(
|
|
486
|
+
const e = t.get(y);
|
|
487
|
+
return () => e.call(b.key, 5);
|
|
476
488
|
}
|
|
477
489
|
},
|
|
478
490
|
TurnIntoH6: {
|
|
479
491
|
shortcuts: "Mod-Alt-6",
|
|
480
492
|
command: (t) => {
|
|
481
|
-
const e = t.get(
|
|
482
|
-
return () => e.call(
|
|
493
|
+
const e = t.get(y);
|
|
494
|
+
return () => e.call(b.key, 6);
|
|
483
495
|
}
|
|
484
496
|
},
|
|
485
497
|
DowngradeHeading: {
|
|
486
498
|
shortcuts: ["Delete", "Backspace"],
|
|
487
499
|
command: (t) => {
|
|
488
|
-
const e = t.get(
|
|
489
|
-
return () => e.call(
|
|
500
|
+
const e = t.get(y);
|
|
501
|
+
return () => e.call(fe.key);
|
|
490
502
|
}
|
|
491
503
|
}
|
|
492
504
|
});
|
|
493
|
-
n(
|
|
505
|
+
n(Ne.ctx, {
|
|
494
506
|
displayName: "KeymapCtx<heading>",
|
|
495
507
|
group: "Heading"
|
|
496
508
|
});
|
|
497
|
-
n(
|
|
509
|
+
n(Ne.shortcuts, {
|
|
498
510
|
displayName: "Keymap<heading>",
|
|
499
511
|
group: "Heading"
|
|
500
512
|
});
|
|
501
|
-
const
|
|
502
|
-
n(
|
|
513
|
+
const Ie = I("blockquote");
|
|
514
|
+
n(Ie, {
|
|
503
515
|
displayName: "Attr<blockquote>",
|
|
504
516
|
group: "Blockquote"
|
|
505
517
|
});
|
|
506
|
-
const
|
|
518
|
+
const q = C("blockquote", (t) => ({
|
|
507
519
|
content: "block+",
|
|
508
520
|
group: "block",
|
|
509
521
|
defining: !0,
|
|
510
522
|
parseDOM: [{ tag: "blockquote" }],
|
|
511
|
-
toDOM: (e) => ["blockquote", t.get(
|
|
523
|
+
toDOM: (e) => ["blockquote", t.get(Ie.key)(e), 0],
|
|
512
524
|
parseMarkdown: {
|
|
513
525
|
match: ({ type: e }) => e === "blockquote",
|
|
514
526
|
runner: (e, r, a) => {
|
|
@@ -522,50 +534,50 @@ const E = I("blockquote", (t) => ({
|
|
|
522
534
|
}
|
|
523
535
|
}
|
|
524
536
|
}));
|
|
525
|
-
n(
|
|
537
|
+
n(q.node, {
|
|
526
538
|
displayName: "NodeSchema<blockquote>",
|
|
527
539
|
group: "Blockquote"
|
|
528
540
|
});
|
|
529
|
-
n(
|
|
541
|
+
n(q.ctx, {
|
|
530
542
|
displayName: "NodeSchemaCtx<blockquote>",
|
|
531
543
|
group: "Blockquote"
|
|
532
544
|
});
|
|
533
|
-
const
|
|
534
|
-
n(
|
|
545
|
+
const st = w((t) => re(/^\s*>\s$/, q.type(t)));
|
|
546
|
+
n(st, {
|
|
535
547
|
displayName: "InputRule<wrapInBlockquoteInputRule>",
|
|
536
548
|
group: "Blockquote"
|
|
537
549
|
});
|
|
538
|
-
const
|
|
539
|
-
n(
|
|
550
|
+
const Ce = h("WrapInBlockquote", (t) => () => te(q.type(t)));
|
|
551
|
+
n(Ce, {
|
|
540
552
|
displayName: "Command<wrapInBlockquoteCommand>",
|
|
541
553
|
group: "Blockquote"
|
|
542
554
|
});
|
|
543
|
-
const
|
|
555
|
+
const Me = N("blockquoteKeymap", {
|
|
544
556
|
WrapInBlockquote: {
|
|
545
557
|
shortcuts: "Mod-Shift-b",
|
|
546
558
|
command: (t) => {
|
|
547
|
-
const e = t.get(
|
|
548
|
-
return () => e.call(
|
|
559
|
+
const e = t.get(y);
|
|
560
|
+
return () => e.call(Ce.key);
|
|
549
561
|
}
|
|
550
562
|
}
|
|
551
563
|
});
|
|
552
|
-
n(
|
|
564
|
+
n(Me.ctx, {
|
|
553
565
|
displayName: "KeymapCtx<blockquote>",
|
|
554
566
|
group: "Blockquote"
|
|
555
567
|
});
|
|
556
|
-
n(
|
|
568
|
+
n(Me.shortcuts, {
|
|
557
569
|
displayName: "Keymap<blockquote>",
|
|
558
570
|
group: "Blockquote"
|
|
559
571
|
});
|
|
560
|
-
const
|
|
572
|
+
const be = I("codeBlock", () => ({
|
|
561
573
|
pre: {},
|
|
562
574
|
code: {}
|
|
563
575
|
}));
|
|
564
|
-
n(
|
|
576
|
+
n(be, {
|
|
565
577
|
displayName: "Attr<codeBlock>",
|
|
566
578
|
group: "CodeBlock"
|
|
567
579
|
});
|
|
568
|
-
const
|
|
580
|
+
const W = C("code_block", (t) => ({
|
|
569
581
|
content: "text*",
|
|
570
582
|
group: "block",
|
|
571
583
|
marks: "",
|
|
@@ -582,13 +594,13 @@ const _ = I("code_block", (t) => ({
|
|
|
582
594
|
preserveWhitespace: "full",
|
|
583
595
|
getAttrs: (e) => {
|
|
584
596
|
if (!(e instanceof HTMLElement))
|
|
585
|
-
throw
|
|
597
|
+
throw A(e);
|
|
586
598
|
return { language: e.dataset.language };
|
|
587
599
|
}
|
|
588
600
|
}
|
|
589
601
|
],
|
|
590
602
|
toDOM: (e) => {
|
|
591
|
-
const r = t.get(
|
|
603
|
+
const r = t.get(be.key)(e);
|
|
592
604
|
return [
|
|
593
605
|
"pre",
|
|
594
606
|
{
|
|
@@ -615,57 +627,57 @@ const _ = I("code_block", (t) => ({
|
|
|
615
627
|
}
|
|
616
628
|
}
|
|
617
629
|
}));
|
|
618
|
-
n(
|
|
630
|
+
n(W.node, {
|
|
619
631
|
displayName: "NodeSchema<codeBlock>",
|
|
620
632
|
group: "CodeBlock"
|
|
621
633
|
});
|
|
622
|
-
n(
|
|
634
|
+
n(W.ctx, {
|
|
623
635
|
displayName: "NodeSchemaCtx<codeBlock>",
|
|
624
636
|
group: "CodeBlock"
|
|
625
637
|
});
|
|
626
|
-
const
|
|
627
|
-
var
|
|
638
|
+
const lt = w((t) => Qe(/^```(?<language>[a-z]*)?[\s\n]$/, W.type(t), (e) => {
|
|
639
|
+
var r;
|
|
628
640
|
return {
|
|
629
|
-
language: ((
|
|
641
|
+
language: ((r = e.groups) == null ? void 0 : r.language) ?? ""
|
|
630
642
|
};
|
|
631
643
|
}));
|
|
632
|
-
n(
|
|
644
|
+
n(lt, {
|
|
633
645
|
displayName: "InputRule<createCodeBlockInputRule>",
|
|
634
646
|
group: "CodeBlock"
|
|
635
647
|
});
|
|
636
|
-
const
|
|
637
|
-
n(
|
|
648
|
+
const Le = h("CreateCodeBlock", (t) => (e = "") => _(W.type(t), { language: e }));
|
|
649
|
+
n(Le, {
|
|
638
650
|
displayName: "Command<createCodeBlockCommand>",
|
|
639
651
|
group: "CodeBlock"
|
|
640
652
|
});
|
|
641
|
-
const
|
|
642
|
-
n(
|
|
653
|
+
const qt = h("UpdateCodeBlockLanguage", () => ({ pos: t, language: e } = { pos: -1, language: "" }) => (r, a) => t >= 0 ? (a == null || a(r.tr.setNodeAttribute(t, "language", e)), !0) : !1);
|
|
654
|
+
n(qt, {
|
|
643
655
|
displayName: "Command<updateCodeBlockLanguageCommand>",
|
|
644
656
|
group: "CodeBlock"
|
|
645
657
|
});
|
|
646
|
-
const
|
|
658
|
+
const xe = N("codeBlockKeymap", {
|
|
647
659
|
CreateCodeBlock: {
|
|
648
660
|
shortcuts: "Mod-Alt-c",
|
|
649
661
|
command: (t) => {
|
|
650
|
-
const e = t.get(
|
|
651
|
-
return () => e.call(
|
|
662
|
+
const e = t.get(y);
|
|
663
|
+
return () => e.call(Le.key);
|
|
652
664
|
}
|
|
653
665
|
}
|
|
654
666
|
});
|
|
655
|
-
n(
|
|
667
|
+
n(xe.ctx, {
|
|
656
668
|
displayName: "KeymapCtx<codeBlock>",
|
|
657
669
|
group: "CodeBlock"
|
|
658
670
|
});
|
|
659
|
-
n(
|
|
671
|
+
n(xe.shortcuts, {
|
|
660
672
|
displayName: "Keymap<codeBlock>",
|
|
661
673
|
group: "CodeBlock"
|
|
662
674
|
});
|
|
663
|
-
const
|
|
664
|
-
n(
|
|
675
|
+
const Se = I("image");
|
|
676
|
+
n(Se, {
|
|
665
677
|
displayName: "Attr<image>",
|
|
666
678
|
group: "Image"
|
|
667
679
|
});
|
|
668
|
-
const
|
|
680
|
+
const D = C("image", (t) => ({
|
|
669
681
|
inline: !0,
|
|
670
682
|
group: "inline",
|
|
671
683
|
selectable: !0,
|
|
@@ -684,7 +696,7 @@ const O = I("image", (t) => ({
|
|
|
684
696
|
tag: "img[src]",
|
|
685
697
|
getAttrs: (e) => {
|
|
686
698
|
if (!(e instanceof HTMLElement))
|
|
687
|
-
throw
|
|
699
|
+
throw A(e);
|
|
688
700
|
return {
|
|
689
701
|
src: e.getAttribute("src") || "",
|
|
690
702
|
alt: e.getAttribute("alt") || "",
|
|
@@ -693,15 +705,15 @@ const O = I("image", (t) => ({
|
|
|
693
705
|
}
|
|
694
706
|
}
|
|
695
707
|
],
|
|
696
|
-
toDOM: (e) => ["img", { ...t.get(
|
|
708
|
+
toDOM: (e) => ["img", { ...t.get(Se.key)(e), ...e.attrs }],
|
|
697
709
|
parseMarkdown: {
|
|
698
710
|
match: ({ type: e }) => e === "image",
|
|
699
711
|
runner: (e, r, a) => {
|
|
700
|
-
const o = r.url, s = r.alt,
|
|
712
|
+
const o = r.url, s = r.alt, l = r.title;
|
|
701
713
|
e.addNode(a, {
|
|
702
714
|
src: o,
|
|
703
715
|
alt: s,
|
|
704
|
-
title:
|
|
716
|
+
title: l
|
|
705
717
|
});
|
|
706
718
|
}
|
|
707
719
|
},
|
|
@@ -716,54 +728,54 @@ const O = I("image", (t) => ({
|
|
|
716
728
|
}
|
|
717
729
|
}
|
|
718
730
|
}));
|
|
719
|
-
n(
|
|
731
|
+
n(D.node, {
|
|
720
732
|
displayName: "NodeSchema<image>",
|
|
721
733
|
group: "Image"
|
|
722
734
|
});
|
|
723
|
-
n(
|
|
735
|
+
n(D.ctx, {
|
|
724
736
|
displayName: "NodeSchemaCtx<image>",
|
|
725
737
|
group: "Image"
|
|
726
738
|
});
|
|
727
|
-
const
|
|
728
|
-
if (!
|
|
739
|
+
const it = h("InsertImage", (t) => (e = {}) => (r, a) => {
|
|
740
|
+
if (!a)
|
|
729
741
|
return !0;
|
|
730
|
-
const { src:
|
|
731
|
-
return i && r
|
|
742
|
+
const { src: o = "", alt: s = "", title: l = "" } = e, i = D.type(t).create({ src: o, alt: s, title: l });
|
|
743
|
+
return i && a(r.tr.replaceSelectionWith(i).scrollIntoView()), !0;
|
|
732
744
|
});
|
|
733
|
-
n(
|
|
745
|
+
n(it, {
|
|
734
746
|
displayName: "Command<insertImageCommand>",
|
|
735
747
|
group: "Image"
|
|
736
748
|
});
|
|
737
|
-
const
|
|
738
|
-
const
|
|
739
|
-
if (!
|
|
749
|
+
const ct = h("UpdateImage", (t) => (e = {}) => (r, a) => {
|
|
750
|
+
const o = Tt(r.selection, D.type(t));
|
|
751
|
+
if (!o)
|
|
740
752
|
return !1;
|
|
741
|
-
const { node:
|
|
742
|
-
return
|
|
753
|
+
const { node: s, pos: l } = o, i = { ...s.attrs }, { src: c, alt: d, title: m } = e;
|
|
754
|
+
return c !== void 0 && (i.src = c), d !== void 0 && (i.alt = d), m !== void 0 && (i.title = m), a == null || a(r.tr.setNodeMarkup(l, void 0, i).scrollIntoView()), !0;
|
|
743
755
|
});
|
|
744
|
-
n(
|
|
756
|
+
n(ct, {
|
|
745
757
|
displayName: "Command<updateImageCommand>",
|
|
746
758
|
group: "Image"
|
|
747
759
|
});
|
|
748
|
-
const
|
|
760
|
+
const Wt = w((t) => new Xe(
|
|
749
761
|
/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,
|
|
750
|
-
(
|
|
751
|
-
const [
|
|
752
|
-
return
|
|
762
|
+
(e, r, a, o) => {
|
|
763
|
+
const [s, l, i = "", c] = r;
|
|
764
|
+
return s ? e.tr.replaceWith(a, o, D.type(t).create({ src: i, alt: l, title: c })) : null;
|
|
753
765
|
}
|
|
754
766
|
));
|
|
755
|
-
n(
|
|
767
|
+
n(Wt, {
|
|
756
768
|
displayName: "InputRule<insertImageInputRule>",
|
|
757
769
|
group: "Image"
|
|
758
770
|
});
|
|
759
|
-
const
|
|
771
|
+
const we = I("hardbreak", (t) => ({
|
|
760
772
|
"data-is-inline": t.attrs.isInline
|
|
761
773
|
}));
|
|
762
|
-
n(
|
|
774
|
+
n(we, {
|
|
763
775
|
displayName: "Attr<hardbreak>",
|
|
764
776
|
group: "Hardbreak"
|
|
765
777
|
});
|
|
766
|
-
const
|
|
778
|
+
const S = C("hardbreak", (t) => ({
|
|
767
779
|
inline: !0,
|
|
768
780
|
group: "inline",
|
|
769
781
|
attrs: {
|
|
@@ -773,7 +785,7 @@ const x = I("hardbreak", (t) => ({
|
|
|
773
785
|
},
|
|
774
786
|
selectable: !1,
|
|
775
787
|
parseDOM: [{ tag: "br" }],
|
|
776
|
-
toDOM: (e) => ["br", t.get(
|
|
788
|
+
toDOM: (e) => ["br", t.get(we.key)(e)],
|
|
777
789
|
parseMarkdown: {
|
|
778
790
|
match: ({ type: e }) => e === "break",
|
|
779
791
|
runner: (e, r, a) => {
|
|
@@ -791,56 +803,56 @@ const x = I("hardbreak", (t) => ({
|
|
|
791
803
|
}
|
|
792
804
|
}
|
|
793
805
|
}));
|
|
794
|
-
n(
|
|
806
|
+
n(S.node, {
|
|
795
807
|
displayName: "NodeSchema<hardbreak>",
|
|
796
808
|
group: "Hardbreak"
|
|
797
809
|
});
|
|
798
|
-
n(
|
|
810
|
+
n(S.ctx, {
|
|
799
811
|
displayName: "NodeSchemaCtx<hardbreak>",
|
|
800
812
|
group: "Hardbreak"
|
|
801
813
|
});
|
|
802
|
-
const
|
|
803
|
-
var
|
|
804
|
-
const { selection:
|
|
805
|
-
if (
|
|
806
|
-
const
|
|
807
|
-
if (
|
|
808
|
-
return
|
|
809
|
-
|
|
814
|
+
const Ae = h("InsertHardbreak", (t) => () => (e, r) => {
|
|
815
|
+
var s;
|
|
816
|
+
const { selection: a, tr: o } = e;
|
|
817
|
+
if (a.empty) {
|
|
818
|
+
const l = a.$from.node();
|
|
819
|
+
if (l.childCount > 0 && ((s = l.lastChild) == null ? void 0 : s.type.name) === "hardbreak")
|
|
820
|
+
return r == null || r(
|
|
821
|
+
o.replaceRangeWith(a.to - 1, a.to, e.schema.node("paragraph")).setSelection(Ze.near(o.doc.resolve(a.to))).scrollIntoView()
|
|
810
822
|
), !0;
|
|
811
823
|
}
|
|
812
|
-
return
|
|
824
|
+
return r == null || r(o.setMeta("hardbreak", !0).replaceSelectionWith(S.type(t).create()).scrollIntoView()), !0;
|
|
813
825
|
});
|
|
814
|
-
n(
|
|
826
|
+
n(Ae, {
|
|
815
827
|
displayName: "Command<insertHardbreakCommand>",
|
|
816
828
|
group: "Hardbreak"
|
|
817
829
|
});
|
|
818
|
-
const
|
|
830
|
+
const ve = N("hardbreakKeymap", {
|
|
819
831
|
InsertHardbreak: {
|
|
820
832
|
shortcuts: "Shift-Enter",
|
|
821
833
|
command: (t) => {
|
|
822
|
-
const e = t.get(
|
|
823
|
-
return () => e.call(
|
|
834
|
+
const e = t.get(y);
|
|
835
|
+
return () => e.call(Ae.key);
|
|
824
836
|
}
|
|
825
837
|
}
|
|
826
838
|
});
|
|
827
|
-
n(
|
|
839
|
+
n(ve.ctx, {
|
|
828
840
|
displayName: "KeymapCtx<hardbreak>",
|
|
829
841
|
group: "Hardbreak"
|
|
830
842
|
});
|
|
831
|
-
n(
|
|
843
|
+
n(ve.shortcuts, {
|
|
832
844
|
displayName: "Keymap<hardbreak>",
|
|
833
845
|
group: "Hardbreak"
|
|
834
846
|
});
|
|
835
|
-
const
|
|
836
|
-
n(
|
|
847
|
+
const He = I("hr");
|
|
848
|
+
n(He, {
|
|
837
849
|
displayName: "Attr<hr>",
|
|
838
850
|
group: "Hr"
|
|
839
851
|
});
|
|
840
|
-
const
|
|
852
|
+
const F = C("hr", (t) => ({
|
|
841
853
|
group: "block",
|
|
842
854
|
parseDOM: [{ tag: "hr" }],
|
|
843
|
-
toDOM: (e) => ["hr", t.get(
|
|
855
|
+
toDOM: (e) => ["hr", t.get(He.key)(e)],
|
|
844
856
|
parseMarkdown: {
|
|
845
857
|
match: ({ type: e }) => e === "thematicBreak",
|
|
846
858
|
runner: (e, r, a) => {
|
|
@@ -854,44 +866,44 @@ const $ = I("hr", (t) => ({
|
|
|
854
866
|
}
|
|
855
867
|
}
|
|
856
868
|
}));
|
|
857
|
-
n(
|
|
869
|
+
n(F.node, {
|
|
858
870
|
displayName: "NodeSchema<hr>",
|
|
859
871
|
group: "Hr"
|
|
860
872
|
});
|
|
861
|
-
n(
|
|
873
|
+
n(F.ctx, {
|
|
862
874
|
displayName: "NodeSchemaCtx<hr>",
|
|
863
875
|
group: "Hr"
|
|
864
876
|
});
|
|
865
|
-
const
|
|
877
|
+
const dt = w((t) => new Xe(
|
|
866
878
|
/^(?:---|___\s|\*\*\*\s)$/,
|
|
867
|
-
(
|
|
868
|
-
const { tr:
|
|
869
|
-
return
|
|
879
|
+
(e, r, a, o) => {
|
|
880
|
+
const { tr: s } = e;
|
|
881
|
+
return r[0] && s.replaceWith(a - 1, o, F.type(t).create()), s;
|
|
870
882
|
}
|
|
871
883
|
));
|
|
872
|
-
n(
|
|
884
|
+
n(dt, {
|
|
873
885
|
displayName: "InputRule<insertHrInputRule>",
|
|
874
886
|
group: "Hr"
|
|
875
887
|
});
|
|
876
|
-
const
|
|
877
|
-
if (!
|
|
888
|
+
const mt = h("InsertHr", (t) => () => (e, r) => {
|
|
889
|
+
if (!r)
|
|
878
890
|
return !0;
|
|
879
|
-
const
|
|
891
|
+
const a = v.node.type(t).create(), { tr: o, selection: s } = e, { from: l } = s, i = F.type(t).create();
|
|
880
892
|
if (!i)
|
|
881
893
|
return !0;
|
|
882
|
-
const
|
|
883
|
-
return
|
|
894
|
+
const c = o.replaceSelectionWith(i).insert(l, a), d = Ze.findFrom(c.doc.resolve(l), 1, !0);
|
|
895
|
+
return d && r(c.setSelection(d).scrollIntoView()), !0;
|
|
884
896
|
});
|
|
885
|
-
n(
|
|
897
|
+
n(mt, {
|
|
886
898
|
displayName: "Command<insertHrCommand>",
|
|
887
899
|
group: "Hr"
|
|
888
900
|
});
|
|
889
|
-
const
|
|
890
|
-
n(
|
|
901
|
+
const Be = I("bulletList");
|
|
902
|
+
n(Be, {
|
|
891
903
|
displayName: "Attr<bulletList>",
|
|
892
904
|
group: "BulletList"
|
|
893
905
|
});
|
|
894
|
-
const
|
|
906
|
+
const R = C("bullet_list", (t) => ({
|
|
895
907
|
content: "listItem+",
|
|
896
908
|
group: "block",
|
|
897
909
|
attrs: {
|
|
@@ -904,7 +916,7 @@ const K = I("bullet_list", (t) => ({
|
|
|
904
916
|
tag: "ul",
|
|
905
917
|
getAttrs: (e) => {
|
|
906
918
|
if (!(e instanceof HTMLElement))
|
|
907
|
-
throw
|
|
919
|
+
throw A(e);
|
|
908
920
|
return {
|
|
909
921
|
spread: e.dataset.spread
|
|
910
922
|
};
|
|
@@ -914,7 +926,7 @@ const K = I("bullet_list", (t) => ({
|
|
|
914
926
|
toDOM: (e) => [
|
|
915
927
|
"ul",
|
|
916
928
|
{
|
|
917
|
-
...t.get(
|
|
929
|
+
...t.get(Be.key)(e),
|
|
918
930
|
"data-spread": e.attrs.spread
|
|
919
931
|
},
|
|
920
932
|
0
|
|
@@ -933,47 +945,47 @@ const K = I("bullet_list", (t) => ({
|
|
|
933
945
|
}
|
|
934
946
|
}
|
|
935
947
|
}));
|
|
936
|
-
n(
|
|
948
|
+
n(R.node, {
|
|
937
949
|
displayName: "NodeSchema<bulletList>",
|
|
938
950
|
group: "BulletList"
|
|
939
951
|
});
|
|
940
|
-
n(
|
|
952
|
+
n(R.ctx, {
|
|
941
953
|
displayName: "NodeSchemaCtx<bulletList>",
|
|
942
954
|
group: "BulletList"
|
|
943
955
|
});
|
|
944
|
-
const
|
|
945
|
-
n(
|
|
956
|
+
const ut = w((t) => re(/^\s*([-+*])\s$/, R.type(t)));
|
|
957
|
+
n(ut, {
|
|
946
958
|
displayName: "InputRule<wrapInBulletListInputRule>",
|
|
947
959
|
group: "BulletList"
|
|
948
960
|
});
|
|
949
|
-
const
|
|
950
|
-
n(
|
|
961
|
+
const Oe = h("WrapInBulletList", (t) => () => te(R.type(t)));
|
|
962
|
+
n(Oe, {
|
|
951
963
|
displayName: "Command<wrapInBulletListCommand>",
|
|
952
964
|
group: "BulletList"
|
|
953
965
|
});
|
|
954
|
-
const
|
|
966
|
+
const Te = N("bulletListKeymap", {
|
|
955
967
|
WrapInBulletList: {
|
|
956
968
|
shortcuts: "Mod-Alt-8",
|
|
957
969
|
command: (t) => {
|
|
958
|
-
const e = t.get(
|
|
959
|
-
return () => e.call(
|
|
970
|
+
const e = t.get(y);
|
|
971
|
+
return () => e.call(Oe.key);
|
|
960
972
|
}
|
|
961
973
|
}
|
|
962
974
|
});
|
|
963
|
-
n(
|
|
975
|
+
n(Te.ctx, {
|
|
964
976
|
displayName: "KeymapCtx<bulletListKeymap>",
|
|
965
977
|
group: "BulletList"
|
|
966
978
|
});
|
|
967
|
-
n(
|
|
979
|
+
n(Te.shortcuts, {
|
|
968
980
|
displayName: "Keymap<bulletListKeymap>",
|
|
969
981
|
group: "BulletList"
|
|
970
982
|
});
|
|
971
|
-
const
|
|
972
|
-
n(
|
|
983
|
+
const Ke = I("orderedList");
|
|
984
|
+
n(Ke, {
|
|
973
985
|
displayName: "Attr<orderedList>",
|
|
974
986
|
group: "OrderedList"
|
|
975
987
|
});
|
|
976
|
-
const
|
|
988
|
+
const P = C("ordered_list", (t) => ({
|
|
977
989
|
content: "listItem+",
|
|
978
990
|
group: "block",
|
|
979
991
|
attrs: {
|
|
@@ -989,7 +1001,7 @@ const D = I("ordered_list", (t) => ({
|
|
|
989
1001
|
tag: "ol",
|
|
990
1002
|
getAttrs: (e) => {
|
|
991
1003
|
if (!(e instanceof HTMLElement))
|
|
992
|
-
throw
|
|
1004
|
+
throw A(e);
|
|
993
1005
|
return {
|
|
994
1006
|
spread: e.dataset.spread,
|
|
995
1007
|
order: e.hasAttribute("start") ? Number(e.getAttribute("start")) : 1
|
|
@@ -1000,7 +1012,7 @@ const D = I("ordered_list", (t) => ({
|
|
|
1000
1012
|
toDOM: (e) => [
|
|
1001
1013
|
"ol",
|
|
1002
1014
|
{
|
|
1003
|
-
...t.get(
|
|
1015
|
+
...t.get(Ke.key)(e),
|
|
1004
1016
|
...e.attrs.order === 1 ? {} : e.attrs.order,
|
|
1005
1017
|
"data-spread": e.attrs.spread
|
|
1006
1018
|
},
|
|
@@ -1020,52 +1032,52 @@ const D = I("ordered_list", (t) => ({
|
|
|
1020
1032
|
}
|
|
1021
1033
|
}
|
|
1022
1034
|
}));
|
|
1023
|
-
n(
|
|
1035
|
+
n(P.node, {
|
|
1024
1036
|
displayName: "NodeSchema<orderedList>",
|
|
1025
1037
|
group: "OrderedList"
|
|
1026
1038
|
});
|
|
1027
|
-
n(
|
|
1039
|
+
n(P.ctx, {
|
|
1028
1040
|
displayName: "NodeSchemaCtx<orderedList>",
|
|
1029
1041
|
group: "OrderedList"
|
|
1030
1042
|
});
|
|
1031
|
-
const
|
|
1043
|
+
const pt = w((t) => re(
|
|
1032
1044
|
/^\s*(\d+)\.\s$/,
|
|
1033
|
-
|
|
1034
|
-
(
|
|
1035
|
-
(
|
|
1045
|
+
P.type(t),
|
|
1046
|
+
(e) => ({ order: Number(e[1]) }),
|
|
1047
|
+
(e, r) => r.childCount + r.attrs.order === Number(e[1])
|
|
1036
1048
|
));
|
|
1037
|
-
n(
|
|
1049
|
+
n(pt, {
|
|
1038
1050
|
displayName: "InputRule<wrapInOrderedListInputRule>",
|
|
1039
1051
|
group: "OrderedList"
|
|
1040
1052
|
});
|
|
1041
|
-
const
|
|
1042
|
-
n(
|
|
1053
|
+
const De = h("WrapInOrderedList", (t) => () => te(P.type(t)));
|
|
1054
|
+
n(De, {
|
|
1043
1055
|
displayName: "Command<wrapInOrderedListCommand>",
|
|
1044
1056
|
group: "OrderedList"
|
|
1045
1057
|
});
|
|
1046
|
-
const
|
|
1058
|
+
const Re = N("orderedListKeymap", {
|
|
1047
1059
|
WrapInOrderedList: {
|
|
1048
1060
|
shortcuts: "Mod-Alt-7",
|
|
1049
1061
|
command: (t) => {
|
|
1050
|
-
const e = t.get(
|
|
1051
|
-
return () => e.call(
|
|
1062
|
+
const e = t.get(y);
|
|
1063
|
+
return () => e.call(De.key);
|
|
1052
1064
|
}
|
|
1053
1065
|
}
|
|
1054
1066
|
});
|
|
1055
|
-
n(
|
|
1067
|
+
n(Re.ctx, {
|
|
1056
1068
|
displayName: "KeymapCtx<orderedList>",
|
|
1057
1069
|
group: "OrderedList"
|
|
1058
1070
|
});
|
|
1059
|
-
n(
|
|
1071
|
+
n(Re.shortcuts, {
|
|
1060
1072
|
displayName: "Keymap<orderedList>",
|
|
1061
1073
|
group: "OrderedList"
|
|
1062
1074
|
});
|
|
1063
|
-
const
|
|
1064
|
-
n(
|
|
1075
|
+
const Pe = I("listItem");
|
|
1076
|
+
n(Pe, {
|
|
1065
1077
|
displayName: "Attr<listItem>",
|
|
1066
1078
|
group: "ListItem"
|
|
1067
1079
|
});
|
|
1068
|
-
const
|
|
1080
|
+
const M = C("list_item", (t) => ({
|
|
1069
1081
|
group: "listItem",
|
|
1070
1082
|
content: "paragraph block*",
|
|
1071
1083
|
attrs: {
|
|
@@ -1085,7 +1097,7 @@ const C = I("list_item", (t) => ({
|
|
|
1085
1097
|
tag: "li",
|
|
1086
1098
|
getAttrs: (e) => {
|
|
1087
1099
|
if (!(e instanceof HTMLElement))
|
|
1088
|
-
throw
|
|
1100
|
+
throw A(e);
|
|
1089
1101
|
return {
|
|
1090
1102
|
label: e.dataset.label,
|
|
1091
1103
|
listType: e.dataset["list-type"],
|
|
@@ -1097,7 +1109,7 @@ const C = I("list_item", (t) => ({
|
|
|
1097
1109
|
toDOM: (e) => [
|
|
1098
1110
|
"li",
|
|
1099
1111
|
{
|
|
1100
|
-
...t.get(
|
|
1112
|
+
...t.get(Pe.key)(e),
|
|
1101
1113
|
"data-label": e.attrs.label,
|
|
1102
1114
|
"data-list-type": e.attrs.listType,
|
|
1103
1115
|
"data-spread": e.attrs.spread
|
|
@@ -1107,8 +1119,8 @@ const C = I("list_item", (t) => ({
|
|
|
1107
1119
|
parseMarkdown: {
|
|
1108
1120
|
match: ({ type: e }) => e === "listItem",
|
|
1109
1121
|
runner: (e, r, a) => {
|
|
1110
|
-
const o = r.label != null ? `${r.label}.` : "•", s = r.label != null ? "ordered" : "bullet",
|
|
1111
|
-
e.openNode(a, { label: o, listType: s, spread:
|
|
1122
|
+
const o = r.label != null ? `${r.label}.` : "•", s = r.label != null ? "ordered" : "bullet", l = r.spread != null ? `${r.spread}` : "true";
|
|
1123
|
+
e.openNode(a, { label: o, listType: s, spread: l }), e.next(r.children), e.closeNode();
|
|
1112
1124
|
}
|
|
1113
1125
|
},
|
|
1114
1126
|
toMarkdown: {
|
|
@@ -1118,82 +1130,82 @@ const C = I("list_item", (t) => ({
|
|
|
1118
1130
|
}
|
|
1119
1131
|
}
|
|
1120
1132
|
}));
|
|
1121
|
-
n(
|
|
1133
|
+
n(M.node, {
|
|
1122
1134
|
displayName: "NodeSchema<listItem>",
|
|
1123
1135
|
group: "ListItem"
|
|
1124
1136
|
});
|
|
1125
|
-
n(
|
|
1137
|
+
n(M.ctx, {
|
|
1126
1138
|
displayName: "NodeSchemaCtx<listItem>",
|
|
1127
1139
|
group: "ListItem"
|
|
1128
1140
|
});
|
|
1129
|
-
const
|
|
1130
|
-
n(
|
|
1141
|
+
const Ee = h("SinkListItem", (t) => () => Kt(M.type(t)));
|
|
1142
|
+
n(Ee, {
|
|
1131
1143
|
displayName: "Command<sinkListItemCommand>",
|
|
1132
1144
|
group: "ListItem"
|
|
1133
1145
|
});
|
|
1134
|
-
const
|
|
1135
|
-
n(
|
|
1146
|
+
const _e = h("SplitListItem", (t) => () => et(M.type(t)));
|
|
1147
|
+
n(_e, {
|
|
1136
1148
|
displayName: "Command<liftListItemCommand>",
|
|
1137
1149
|
group: "ListItem"
|
|
1138
1150
|
});
|
|
1139
|
-
const
|
|
1140
|
-
n(
|
|
1151
|
+
const $e = h("SplitListItem", (t) => () => Dt(M.type(t)));
|
|
1152
|
+
n($e, {
|
|
1141
1153
|
displayName: "Command<splitListItemCommand>",
|
|
1142
1154
|
group: "ListItem"
|
|
1143
1155
|
});
|
|
1144
|
-
const
|
|
1145
|
-
const { selection:
|
|
1146
|
-
if (!(
|
|
1156
|
+
const Ft = (t) => (e, r, a) => {
|
|
1157
|
+
const { selection: o } = e;
|
|
1158
|
+
if (!(o instanceof G))
|
|
1147
1159
|
return !1;
|
|
1148
|
-
const { empty:
|
|
1149
|
-
if (!
|
|
1160
|
+
const { empty: s, $from: l } = o;
|
|
1161
|
+
if (!s || l.parentOffset !== 0)
|
|
1150
1162
|
return !1;
|
|
1151
|
-
const i =
|
|
1152
|
-
return i.type !==
|
|
1153
|
-
},
|
|
1154
|
-
n(
|
|
1163
|
+
const i = l.node(-1);
|
|
1164
|
+
return i.type !== M.type(t) || i.firstChild !== l.node() || l.node(-2).childCount > 1 ? !1 : et(M.type(t))(e, r, a);
|
|
1165
|
+
}, qe = h("LiftFirstListItem", (t) => () => Ft(t));
|
|
1166
|
+
n(qe, {
|
|
1155
1167
|
displayName: "Command<liftFirstListItemCommand>",
|
|
1156
1168
|
group: "ListItem"
|
|
1157
1169
|
});
|
|
1158
|
-
const
|
|
1170
|
+
const We = N("listItemKeymap", {
|
|
1159
1171
|
NextListItem: {
|
|
1160
1172
|
shortcuts: "Enter",
|
|
1161
1173
|
command: (t) => {
|
|
1162
|
-
const e = t.get(
|
|
1163
|
-
return () => e.call(
|
|
1174
|
+
const e = t.get(y);
|
|
1175
|
+
return () => e.call($e.key);
|
|
1164
1176
|
}
|
|
1165
1177
|
},
|
|
1166
1178
|
SinkListItem: {
|
|
1167
1179
|
shortcuts: ["Tab", "Mod-]"],
|
|
1168
1180
|
command: (t) => {
|
|
1169
|
-
const e = t.get(
|
|
1170
|
-
return () => e.call(
|
|
1181
|
+
const e = t.get(y);
|
|
1182
|
+
return () => e.call(Ee.key);
|
|
1171
1183
|
}
|
|
1172
1184
|
},
|
|
1173
1185
|
LiftListItem: {
|
|
1174
1186
|
shortcuts: ["Shift-Tab", "Mod-["],
|
|
1175
1187
|
command: (t) => {
|
|
1176
|
-
const e = t.get(
|
|
1177
|
-
return () => e.call(
|
|
1188
|
+
const e = t.get(y);
|
|
1189
|
+
return () => e.call(_e.key);
|
|
1178
1190
|
}
|
|
1179
1191
|
},
|
|
1180
1192
|
LiftFirstListItem: {
|
|
1181
1193
|
shortcuts: ["Backspace", "Delete"],
|
|
1182
1194
|
command: (t) => {
|
|
1183
|
-
const e = t.get(
|
|
1184
|
-
return () => e.call(
|
|
1195
|
+
const e = t.get(y);
|
|
1196
|
+
return () => e.call(qe.key);
|
|
1185
1197
|
}
|
|
1186
1198
|
}
|
|
1187
1199
|
});
|
|
1188
|
-
n(
|
|
1200
|
+
n(We.ctx, {
|
|
1189
1201
|
displayName: "KeymapCtx<listItem>",
|
|
1190
1202
|
group: "ListItem"
|
|
1191
1203
|
});
|
|
1192
|
-
n(
|
|
1204
|
+
n(We.shortcuts, {
|
|
1193
1205
|
displayName: "Keymap<listItem>",
|
|
1194
1206
|
group: "ListItem"
|
|
1195
1207
|
});
|
|
1196
|
-
const
|
|
1208
|
+
const gt = Ye("text", () => ({
|
|
1197
1209
|
group: "inline",
|
|
1198
1210
|
parseMarkdown: {
|
|
1199
1211
|
match: ({ type: t }) => t === "text",
|
|
@@ -1208,16 +1220,16 @@ const ut = ze("text", () => ({
|
|
|
1208
1220
|
}
|
|
1209
1221
|
}
|
|
1210
1222
|
}));
|
|
1211
|
-
n(
|
|
1223
|
+
n(gt, {
|
|
1212
1224
|
displayName: "NodeSchema<text>",
|
|
1213
1225
|
group: "Text"
|
|
1214
1226
|
});
|
|
1215
|
-
const
|
|
1216
|
-
n(
|
|
1227
|
+
const Fe = I("html");
|
|
1228
|
+
n(Fe, {
|
|
1217
1229
|
displayName: "Attr<html>",
|
|
1218
1230
|
group: "Html"
|
|
1219
1231
|
});
|
|
1220
|
-
const
|
|
1232
|
+
const Ge = C("html", (t) => ({
|
|
1221
1233
|
atom: !0,
|
|
1222
1234
|
group: "inline",
|
|
1223
1235
|
inline: !0,
|
|
@@ -1228,7 +1240,7 @@ const qe = I("html", (t) => ({
|
|
|
1228
1240
|
},
|
|
1229
1241
|
toDOM: (e) => {
|
|
1230
1242
|
const r = document.createElement("span"), a = {
|
|
1231
|
-
...t.get(
|
|
1243
|
+
...t.get(Fe.key)(e),
|
|
1232
1244
|
"data-value": e.attrs.value,
|
|
1233
1245
|
"data-type": "html"
|
|
1234
1246
|
};
|
|
@@ -1253,117 +1265,117 @@ const qe = I("html", (t) => ({
|
|
|
1253
1265
|
}
|
|
1254
1266
|
}
|
|
1255
1267
|
}));
|
|
1256
|
-
n(
|
|
1268
|
+
n(Ge.node, {
|
|
1257
1269
|
displayName: "NodeSchema<html>",
|
|
1258
1270
|
group: "Html"
|
|
1259
1271
|
});
|
|
1260
|
-
n(
|
|
1272
|
+
n(Ge.ctx, {
|
|
1261
1273
|
displayName: "NodeSchemaCtx<html>",
|
|
1262
1274
|
group: "Html"
|
|
1263
1275
|
});
|
|
1264
|
-
const
|
|
1265
|
-
|
|
1266
|
-
me,
|
|
1267
|
-
w,
|
|
1268
|
-
z,
|
|
1276
|
+
const Gt = [
|
|
1277
|
+
nt,
|
|
1269
1278
|
ge,
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
x,
|
|
1279
|
+
v,
|
|
1280
|
+
Y,
|
|
1273
1281
|
ke,
|
|
1274
|
-
|
|
1275
|
-
Ie,
|
|
1276
|
-
_,
|
|
1282
|
+
H,
|
|
1277
1283
|
we,
|
|
1278
|
-
|
|
1284
|
+
S,
|
|
1285
|
+
Ie,
|
|
1286
|
+
q,
|
|
1279
1287
|
be,
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1288
|
+
W,
|
|
1289
|
+
He,
|
|
1290
|
+
F,
|
|
1291
|
+
Se,
|
|
1284
1292
|
D,
|
|
1293
|
+
Be,
|
|
1294
|
+
R,
|
|
1285
1295
|
Ke,
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1296
|
+
P,
|
|
1297
|
+
Pe,
|
|
1298
|
+
M,
|
|
1289
1299
|
ne,
|
|
1290
|
-
|
|
1300
|
+
z,
|
|
1291
1301
|
le,
|
|
1292
|
-
|
|
1302
|
+
U,
|
|
1293
1303
|
de,
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1304
|
+
x,
|
|
1305
|
+
pe,
|
|
1306
|
+
B,
|
|
1307
|
+
Fe,
|
|
1308
|
+
Ge,
|
|
1309
|
+
gt
|
|
1310
|
+
].flat(), Vt = [
|
|
1311
|
+
st,
|
|
1312
|
+
ut,
|
|
1313
|
+
pt,
|
|
1314
|
+
lt,
|
|
1300
1315
|
dt,
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
it,
|
|
1304
|
-
at
|
|
1305
|
-
].flat(), Ft = [
|
|
1306
|
-
ue,
|
|
1307
|
-
fe,
|
|
1308
|
-
M,
|
|
1316
|
+
ot
|
|
1317
|
+
].flat(), jt = [
|
|
1309
1318
|
he,
|
|
1310
1319
|
Ce,
|
|
1320
|
+
b,
|
|
1321
|
+
fe,
|
|
1311
1322
|
Le,
|
|
1323
|
+
Ae,
|
|
1324
|
+
mt,
|
|
1325
|
+
it,
|
|
1312
1326
|
ct,
|
|
1313
|
-
st,
|
|
1314
|
-
lt,
|
|
1315
|
-
Te,
|
|
1316
|
-
ve,
|
|
1317
1327
|
De,
|
|
1318
|
-
|
|
1319
|
-
Pe,
|
|
1328
|
+
Oe,
|
|
1320
1329
|
Ee,
|
|
1321
|
-
|
|
1322
|
-
|
|
1330
|
+
$e,
|
|
1331
|
+
_e,
|
|
1332
|
+
qe,
|
|
1323
1333
|
oe,
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1334
|
+
me,
|
|
1335
|
+
ie,
|
|
1336
|
+
rt,
|
|
1337
|
+
at
|
|
1338
|
+
], zt = [
|
|
1328
1339
|
Me,
|
|
1329
|
-
|
|
1340
|
+
xe,
|
|
1341
|
+
ve,
|
|
1342
|
+
Ne,
|
|
1343
|
+
We,
|
|
1344
|
+
Re,
|
|
1345
|
+
Te,
|
|
1330
1346
|
ye,
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
ce,
|
|
1337
|
-
se
|
|
1338
|
-
].flat(), U = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)/, Vt = (t) => new RegExp(`\\\\(?=[^\\w\\s${t}\\\\]|_)`, "g"), jt = (t) => {
|
|
1339
|
-
let e = t, r = e.match(U);
|
|
1347
|
+
se,
|
|
1348
|
+
ue,
|
|
1349
|
+
ce
|
|
1350
|
+
].flat(), Ut = /\[([^\]]+)]\([^\s\]]+\)/, Q = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)/, Yt = (t) => new RegExp(`\\\\(?=[^\\w\\s${t}\\\\]|_)`, "g"), Jt = (t) => {
|
|
1351
|
+
let e = t, r = e.match(Q);
|
|
1340
1352
|
for (; r && r.groups; ) {
|
|
1341
1353
|
const { span: a } = r.groups;
|
|
1342
|
-
e = e.replace(
|
|
1354
|
+
e = e.replace(Q, a), r = e.match(Q);
|
|
1343
1355
|
}
|
|
1344
1356
|
return e;
|
|
1345
|
-
},
|
|
1357
|
+
}, Qt = (t, e, r) => {
|
|
1346
1358
|
const a = t.split(""), o = a[e];
|
|
1347
1359
|
return a[e] && a[r] && (a[e] = a[r], a[r] = o), a.join("").toString();
|
|
1348
|
-
},
|
|
1360
|
+
}, Xt = (t) => (e) => e.replace(Yt(t), ""), Zt = (t) => (e) => {
|
|
1349
1361
|
const r = e.indexOf(t.hole), a = e.charAt(r - 1), o = e.charAt(r + 1), s = /[^\w]|_/;
|
|
1350
1362
|
return o ? a && s.test(a) && s.test(o) ? t.punctuation : t.char : t.punctuation;
|
|
1351
|
-
},
|
|
1363
|
+
}, er = (t, e, r) => {
|
|
1352
1364
|
let a = e, o = !1;
|
|
1353
1365
|
return t.descendants((s) => {
|
|
1354
|
-
var
|
|
1366
|
+
var l;
|
|
1355
1367
|
if (o)
|
|
1356
1368
|
return !1;
|
|
1357
1369
|
if (!s.textContent.includes(r))
|
|
1358
1370
|
return a += s.nodeSize, !1;
|
|
1359
1371
|
if (s.isText) {
|
|
1360
|
-
const
|
|
1361
|
-
if (
|
|
1362
|
-
return o = !0, a +=
|
|
1372
|
+
const i = (l = s.text) == null ? void 0 : l.indexOf(r);
|
|
1373
|
+
if (i != null && i >= 0)
|
|
1374
|
+
return o = !0, a += i, !1;
|
|
1363
1375
|
}
|
|
1364
1376
|
return a += 1, !0;
|
|
1365
1377
|
}), a;
|
|
1366
|
-
},
|
|
1378
|
+
}, tr = {
|
|
1367
1379
|
placeholderConfig: {
|
|
1368
1380
|
hole: "∅",
|
|
1369
1381
|
punctuation: "⁂",
|
|
@@ -1375,93 +1387,96 @@ const qt = [
|
|
|
1375
1387
|
const r = ["*", "_"];
|
|
1376
1388
|
let a = e.indexOf(t);
|
|
1377
1389
|
for (; r.includes(e[a - 1] || "") && r.includes(e[a + 1] || ""); )
|
|
1378
|
-
e =
|
|
1390
|
+
e = Qt(e, a, a + 1), a = a + 1;
|
|
1379
1391
|
return e;
|
|
1380
1392
|
}
|
|
1381
|
-
},
|
|
1382
|
-
n(
|
|
1393
|
+
}, E = Z(tr, "inlineSyncConfig");
|
|
1394
|
+
n(E, {
|
|
1383
1395
|
displayName: "Ctx<inlineSyncConfig>",
|
|
1384
1396
|
group: "Prose"
|
|
1385
1397
|
});
|
|
1386
|
-
const
|
|
1387
|
-
const o = t.get(
|
|
1398
|
+
const rr = (t) => t.selection.$from.node(), ar = (t, e, r, a) => {
|
|
1399
|
+
const o = t.get(vt), s = e.schema.topNodeType.create(void 0, [r, ...a]);
|
|
1388
1400
|
return o(s);
|
|
1389
|
-
},
|
|
1390
|
-
const r = t.get(
|
|
1401
|
+
}, nr = (t, e) => {
|
|
1402
|
+
const r = t.get(E.key), a = r.placeholderConfig.hole, [o = "", ...s] = e.split(`
|
|
1391
1403
|
|
|
1392
|
-
`),
|
|
1393
|
-
let c =
|
|
1394
|
-
const d =
|
|
1404
|
+
`), l = (m) => r.movePlaceholder(a, m);
|
|
1405
|
+
let c = At(Xt(a), l, Jt)(o);
|
|
1406
|
+
const d = Zt(r.placeholderConfig)(c);
|
|
1395
1407
|
return c = c.replace(a, d), c = [c, ...s].join(`
|
|
1396
1408
|
|
|
1397
1409
|
`), [c, d];
|
|
1398
|
-
},
|
|
1399
|
-
const a = t.get(
|
|
1410
|
+
}, or = (t, e) => {
|
|
1411
|
+
const a = t.get(Ht)(e);
|
|
1400
1412
|
return a ? a.firstChild : null;
|
|
1401
|
-
},
|
|
1402
|
-
const { globalNodes: r } = t.get(
|
|
1413
|
+
}, sr = (t, e) => {
|
|
1414
|
+
const { globalNodes: r } = t.get(E.key), a = [];
|
|
1403
1415
|
return e.doc.descendants((o) => {
|
|
1404
1416
|
if (r.includes(o.type.name) || r.includes(o.type))
|
|
1405
1417
|
return a.push(o), !1;
|
|
1406
1418
|
}), a;
|
|
1407
|
-
},
|
|
1419
|
+
}, lr = (t) => t.split(`
|
|
1408
1420
|
|
|
1409
|
-
`)[0] || "",
|
|
1421
|
+
`)[0] || "", ir = (t) => t.childCount === 1 && t.child(0).type.name === "html", ht = (t, e) => {
|
|
1410
1422
|
try {
|
|
1411
|
-
const r =
|
|
1412
|
-
return !
|
|
1413
|
-
var
|
|
1414
|
-
const m = c.marks.find((
|
|
1415
|
-
m && ((
|
|
1423
|
+
const r = sr(t, e), a = rr(e), o = ar(t, e, a, r), [s, l] = nr(t, o), i = or(t, s);
|
|
1424
|
+
return !i || a.type !== i.type || ir(i) ? null : (i.attrs = { ...a.attrs }, i.descendants((c) => {
|
|
1425
|
+
var p;
|
|
1426
|
+
const m = c.marks.find((u) => u.type.name === "link");
|
|
1427
|
+
m && ((p = c.text) != null && p.includes(l)) && m.attrs.href.includes(l) && (m.attrs.href = m.attrs.href.replace(l, ""));
|
|
1416
1428
|
}), {
|
|
1417
|
-
text:
|
|
1429
|
+
text: lr(s),
|
|
1418
1430
|
prevNode: a,
|
|
1419
|
-
nextNode:
|
|
1420
|
-
placeholder:
|
|
1431
|
+
nextNode: i,
|
|
1432
|
+
placeholder: l
|
|
1421
1433
|
});
|
|
1422
1434
|
} catch {
|
|
1423
1435
|
return null;
|
|
1424
1436
|
}
|
|
1425
|
-
},
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1437
|
+
}, cr = (t, e, r, a, o) => {
|
|
1438
|
+
var L;
|
|
1439
|
+
const { placeholderConfig: s } = t.get(E.key), l = s.hole;
|
|
1440
|
+
let i = r.tr.setMeta(e, !0).insertText(l, r.selection.from);
|
|
1441
|
+
const c = r.apply(i), d = ht(t, c);
|
|
1429
1442
|
if (!d)
|
|
1430
1443
|
return;
|
|
1431
|
-
const { $from:
|
|
1432
|
-
|
|
1433
|
-
|
|
1444
|
+
const m = d.text.slice(0, d.text.indexOf(d.placeholder)), { $from: p } = c.selection, u = p.before(), k = p.after(), g = er(d.nextNode, u, d.placeholder);
|
|
1445
|
+
i = i.replaceWith(u, k, d.nextNode).setNodeMarkup(u, void 0, o).delete(g + 1, g + 2), i = i.setSelection(G.near(i.doc.resolve(g + 1))), (Ut.test(m) || ["*", "_", "~"].includes(m.at(-1) || "")) && i.selection instanceof G && (((L = i.selection.$cursor) == null ? void 0 : L.marks()) ?? []).forEach((J) => {
|
|
1446
|
+
i = i.removeStoredMark(J.type);
|
|
1447
|
+
}), a(i);
|
|
1448
|
+
}, yt = O((t) => {
|
|
1434
1449
|
let e = null;
|
|
1435
|
-
const r = new
|
|
1436
|
-
return new
|
|
1450
|
+
const r = new T("MILKDOWN_INLINE_SYNC");
|
|
1451
|
+
return new K({
|
|
1437
1452
|
key: r,
|
|
1438
1453
|
state: {
|
|
1439
1454
|
init: () => null,
|
|
1440
|
-
apply: (a, o, s,
|
|
1441
|
-
var
|
|
1442
|
-
const
|
|
1443
|
-
if (!((
|
|
1455
|
+
apply: (a, o, s, l) => {
|
|
1456
|
+
var g;
|
|
1457
|
+
const i = t.get(X);
|
|
1458
|
+
if (!((g = i.hasFocus) != null && g.call(i)) || !i.editable || !a.docChanged || a.getMeta(r))
|
|
1444
1459
|
return null;
|
|
1445
|
-
const d =
|
|
1460
|
+
const d = ht(t, l);
|
|
1446
1461
|
if (!d)
|
|
1447
1462
|
return null;
|
|
1448
1463
|
e && (cancelAnimationFrame(e), e = null);
|
|
1449
|
-
const { prevNode: m, nextNode:
|
|
1450
|
-
return
|
|
1464
|
+
const { prevNode: m, nextNode: p, text: u } = d, { shouldSyncNode: k } = t.get(E.key);
|
|
1465
|
+
return k({ prevNode: m, nextNode: p, ctx: t, tr: a, text: u }) && (e = requestAnimationFrame(() => {
|
|
1451
1466
|
e = null;
|
|
1452
|
-
const { dispatch:
|
|
1453
|
-
|
|
1454
|
-
})
|
|
1467
|
+
const { dispatch: f, state: L } = t.get(X);
|
|
1468
|
+
cr(t, r, L, f, m.attrs);
|
|
1469
|
+
})), null;
|
|
1455
1470
|
}
|
|
1456
1471
|
}
|
|
1457
1472
|
});
|
|
1458
1473
|
});
|
|
1459
|
-
n(
|
|
1474
|
+
n(yt, {
|
|
1460
1475
|
displayName: "Prose<inlineSyncPlugin>",
|
|
1461
1476
|
group: "Prose"
|
|
1462
1477
|
});
|
|
1463
|
-
const
|
|
1464
|
-
|
|
1478
|
+
const kt = $(() => () => (t) => {
|
|
1479
|
+
ae(t, "list", (e) => {
|
|
1465
1480
|
if (e.ordered) {
|
|
1466
1481
|
const r = e.start ?? 1;
|
|
1467
1482
|
e.children.forEach((a, o) => {
|
|
@@ -1470,68 +1485,78 @@ const ht = G(() => () => (t) => {
|
|
|
1470
1485
|
}
|
|
1471
1486
|
});
|
|
1472
1487
|
});
|
|
1473
|
-
n(
|
|
1488
|
+
n(kt, {
|
|
1474
1489
|
displayName: "Remark<remarkAddOrderInListPlugin>",
|
|
1475
1490
|
group: "Remark"
|
|
1476
1491
|
});
|
|
1477
|
-
const
|
|
1492
|
+
const ft = $(() => () => (t) => {
|
|
1478
1493
|
const e = /[\t ]*(?:\r?\n|\r)/g;
|
|
1479
|
-
|
|
1494
|
+
ae(t, "text", (r, a, o) => {
|
|
1480
1495
|
if (!r.value || typeof r.value != "string")
|
|
1481
1496
|
return;
|
|
1482
1497
|
const s = [];
|
|
1483
|
-
let
|
|
1498
|
+
let l = 0;
|
|
1484
1499
|
e.lastIndex = 0;
|
|
1485
|
-
let
|
|
1486
|
-
for (;
|
|
1487
|
-
const d =
|
|
1488
|
-
|
|
1500
|
+
let i = e.exec(r.value);
|
|
1501
|
+
for (; i; ) {
|
|
1502
|
+
const d = i.index;
|
|
1503
|
+
l !== d && s.push({ type: "text", value: r.value.slice(l, d) }), s.push({ type: "break", data: { isInline: !0 } }), l = d + i[0].length, i = e.exec(r.value);
|
|
1489
1504
|
}
|
|
1490
1505
|
if (s.length > 0 && o && typeof a == "number")
|
|
1491
|
-
return
|
|
1506
|
+
return l < r.value.length && s.push({ type: "text", value: r.value.slice(l) }), o.children.splice(a, 1, ...s), a + s.length;
|
|
1492
1507
|
});
|
|
1493
1508
|
});
|
|
1494
|
-
n(
|
|
1509
|
+
n(ft, {
|
|
1495
1510
|
displayName: "Remark<remarkLineBreak>",
|
|
1496
1511
|
group: "Remark"
|
|
1497
1512
|
});
|
|
1498
|
-
const
|
|
1499
|
-
n(
|
|
1513
|
+
const Nt = $(() => Et);
|
|
1514
|
+
n(Nt, {
|
|
1500
1515
|
displayName: "Remark<remarkInlineLinkPlugin>",
|
|
1501
1516
|
group: "Remark"
|
|
1502
1517
|
});
|
|
1503
|
-
const
|
|
1504
|
-
function
|
|
1518
|
+
const dr = (t) => !!t.children, mr = (t) => t.type === "html";
|
|
1519
|
+
function ur(t, e) {
|
|
1505
1520
|
return r(t, 0, null)[0];
|
|
1506
1521
|
function r(a, o, s) {
|
|
1507
|
-
if (
|
|
1508
|
-
const
|
|
1509
|
-
for (let
|
|
1510
|
-
const d = a.children[
|
|
1522
|
+
if (dr(a)) {
|
|
1523
|
+
const l = [];
|
|
1524
|
+
for (let i = 0, c = a.children.length; i < c; i++) {
|
|
1525
|
+
const d = a.children[i];
|
|
1511
1526
|
if (d) {
|
|
1512
|
-
const m = r(d,
|
|
1527
|
+
const m = r(d, i, a);
|
|
1513
1528
|
if (m)
|
|
1514
|
-
for (let
|
|
1515
|
-
const
|
|
1516
|
-
|
|
1529
|
+
for (let p = 0, u = m.length; p < u; p++) {
|
|
1530
|
+
const k = m[p];
|
|
1531
|
+
k && l.push(k);
|
|
1517
1532
|
}
|
|
1518
1533
|
}
|
|
1519
1534
|
}
|
|
1520
|
-
a.children =
|
|
1535
|
+
a.children = l;
|
|
1521
1536
|
}
|
|
1522
1537
|
return e(a, o, s);
|
|
1523
1538
|
}
|
|
1524
1539
|
}
|
|
1525
|
-
const
|
|
1526
|
-
|
|
1540
|
+
const It = $(() => () => (t) => {
|
|
1541
|
+
ur(t, (e, r, a) => mr(e) ? ((a == null ? void 0 : a.type) === "root" && (e.children = [{ ...e }], delete e.value, e.type = "paragraph"), [e]) : [e]);
|
|
1527
1542
|
});
|
|
1528
|
-
n(
|
|
1543
|
+
n(It, {
|
|
1529
1544
|
displayName: "Remark<remarkHtmlTransformer>",
|
|
1530
1545
|
group: "Remark"
|
|
1531
1546
|
});
|
|
1532
|
-
const
|
|
1547
|
+
const Ct = $(() => () => (t, e) => {
|
|
1548
|
+
const r = (a) => e.value.charAt(a.position.start.offset);
|
|
1549
|
+
ae(t, (a) => ["strong", "emphasis"].includes(a.type), (a) => {
|
|
1550
|
+
a.marker = r(a);
|
|
1551
|
+
});
|
|
1552
|
+
});
|
|
1553
|
+
n(Ct, {
|
|
1554
|
+
displayName: "Remark<remarkMarker>",
|
|
1555
|
+
group: "Remark"
|
|
1556
|
+
});
|
|
1557
|
+
const Mt = O(() => {
|
|
1533
1558
|
let t = !1;
|
|
1534
|
-
const e = new
|
|
1559
|
+
const e = new T("MILKDOWN_INLINE_NODES_CURSOR"), r = new K({
|
|
1535
1560
|
key: e,
|
|
1536
1561
|
state: {
|
|
1537
1562
|
init() {
|
|
@@ -1540,119 +1565,119 @@ const Nt = H(() => {
|
|
|
1540
1565
|
apply(a) {
|
|
1541
1566
|
if (!a.selection.empty)
|
|
1542
1567
|
return !1;
|
|
1543
|
-
const o = a.selection.$from, s = o.nodeBefore,
|
|
1544
|
-
return !!(s &&
|
|
1568
|
+
const o = a.selection.$from, s = o.nodeBefore, l = o.nodeAfter;
|
|
1569
|
+
return !!(s && l && s.isInline && !s.isText && l.isInline && !l.isText);
|
|
1545
1570
|
}
|
|
1546
1571
|
},
|
|
1547
1572
|
props: {
|
|
1548
1573
|
handleDOMEvents: {
|
|
1549
1574
|
compositionend: (a, o) => t ? (t = !1, requestAnimationFrame(() => {
|
|
1550
1575
|
if (r.getState(a.state)) {
|
|
1551
|
-
const
|
|
1552
|
-
o.preventDefault(), a.dispatch(a.state.tr.insertText(o.data || "",
|
|
1576
|
+
const l = a.state.selection.from;
|
|
1577
|
+
o.preventDefault(), a.dispatch(a.state.tr.insertText(o.data || "", l));
|
|
1553
1578
|
}
|
|
1554
1579
|
}), !0) : !1,
|
|
1555
1580
|
compositionstart: (a) => (r.getState(a.state) && (t = !0), !1),
|
|
1556
1581
|
beforeinput: (a, o) => {
|
|
1557
1582
|
if (r.getState(a.state) && o instanceof InputEvent && o.data && !t) {
|
|
1558
|
-
const
|
|
1559
|
-
return o.preventDefault(), a.dispatch(a.state.tr.insertText(o.data || "",
|
|
1583
|
+
const l = a.state.selection.from;
|
|
1584
|
+
return o.preventDefault(), a.dispatch(a.state.tr.insertText(o.data || "", l)), !0;
|
|
1560
1585
|
}
|
|
1561
1586
|
return !1;
|
|
1562
1587
|
}
|
|
1563
1588
|
},
|
|
1564
1589
|
decorations(a) {
|
|
1565
1590
|
if (r.getState(a)) {
|
|
1566
|
-
const
|
|
1591
|
+
const l = a.selection.$from.pos, i = document.createElement("span"), c = ze.widget(l, i, {
|
|
1567
1592
|
side: -1
|
|
1568
|
-
}), d = document.createElement("span"), m =
|
|
1593
|
+
}), d = document.createElement("span"), m = ze.widget(l, d);
|
|
1569
1594
|
return setTimeout(() => {
|
|
1570
|
-
|
|
1571
|
-
}),
|
|
1595
|
+
i.contentEditable = "true", d.contentEditable = "true";
|
|
1596
|
+
}), Ue.create(a.doc, [c, m]);
|
|
1572
1597
|
}
|
|
1573
|
-
return
|
|
1598
|
+
return Ue.empty;
|
|
1574
1599
|
}
|
|
1575
1600
|
}
|
|
1576
1601
|
});
|
|
1577
1602
|
return r;
|
|
1578
1603
|
});
|
|
1579
|
-
n(
|
|
1604
|
+
n(Mt, {
|
|
1580
1605
|
displayName: "Prose<inlineNodesCursorPlugin>",
|
|
1581
1606
|
group: "Prose"
|
|
1582
1607
|
});
|
|
1583
|
-
const
|
|
1584
|
-
key: new
|
|
1585
|
-
appendTransaction: (
|
|
1586
|
-
if (!
|
|
1608
|
+
const bt = O((t) => new K({
|
|
1609
|
+
key: new T("MILKDOWN_HARDBREAK_MARKS"),
|
|
1610
|
+
appendTransaction: (e, r, a) => {
|
|
1611
|
+
if (!e.length)
|
|
1587
1612
|
return;
|
|
1588
|
-
const [
|
|
1589
|
-
if (!
|
|
1613
|
+
const [o] = e;
|
|
1614
|
+
if (!o)
|
|
1590
1615
|
return;
|
|
1591
|
-
const [
|
|
1592
|
-
if (
|
|
1593
|
-
if (!(
|
|
1616
|
+
const [s] = o.steps;
|
|
1617
|
+
if (o.getMeta("hardbreak")) {
|
|
1618
|
+
if (!(s instanceof Rt))
|
|
1594
1619
|
return;
|
|
1595
|
-
const { from:
|
|
1596
|
-
return
|
|
1620
|
+
const { from: c } = s;
|
|
1621
|
+
return a.tr.setNodeMarkup(c, S.type(t), void 0, []);
|
|
1597
1622
|
}
|
|
1598
|
-
if (
|
|
1599
|
-
let
|
|
1600
|
-
const { from:
|
|
1601
|
-
return
|
|
1602
|
-
|
|
1603
|
-
}),
|
|
1623
|
+
if (s instanceof Pt) {
|
|
1624
|
+
let c = a.tr;
|
|
1625
|
+
const { from: d, to: m } = s;
|
|
1626
|
+
return a.doc.nodesBetween(d, m, (p, u) => {
|
|
1627
|
+
p.type === S.type(t) && (c = c.setNodeMarkup(u, S.type(t), void 0, []));
|
|
1628
|
+
}), c;
|
|
1604
1629
|
}
|
|
1605
1630
|
}
|
|
1606
1631
|
}));
|
|
1607
|
-
n(
|
|
1632
|
+
n(bt, {
|
|
1608
1633
|
displayName: "Prose<hardbreakClearMarkPlugin>",
|
|
1609
1634
|
group: "Prose"
|
|
1610
1635
|
});
|
|
1611
|
-
const
|
|
1612
|
-
n(
|
|
1636
|
+
const Ve = Z(["table", "code_block"], "hardbreakFilterNodes");
|
|
1637
|
+
n(Ve, {
|
|
1613
1638
|
displayName: "Ctx<hardbreakFilterNodes>",
|
|
1614
1639
|
group: "Prose"
|
|
1615
1640
|
});
|
|
1616
|
-
const
|
|
1617
|
-
const e = t.get(
|
|
1618
|
-
return new
|
|
1619
|
-
key: new
|
|
1641
|
+
const Lt = O((t) => {
|
|
1642
|
+
const e = t.get(Ve.key);
|
|
1643
|
+
return new K({
|
|
1644
|
+
key: new T("MILKDOWN_HARDBREAK_FILTER"),
|
|
1620
1645
|
filterTransaction: (r, a) => {
|
|
1621
1646
|
const o = r.getMeta("hardbreak"), [s] = r.steps;
|
|
1622
1647
|
if (o && s) {
|
|
1623
|
-
const { from:
|
|
1624
|
-
let c =
|
|
1648
|
+
const { from: l } = s, i = a.doc.resolve(l);
|
|
1649
|
+
let c = i.depth, d = !0;
|
|
1625
1650
|
for (; c > 0; )
|
|
1626
|
-
e.includes(
|
|
1651
|
+
e.includes(i.node(c).type.name) && (d = !1), c--;
|
|
1627
1652
|
return d;
|
|
1628
1653
|
}
|
|
1629
1654
|
return !0;
|
|
1630
1655
|
}
|
|
1631
1656
|
});
|
|
1632
1657
|
});
|
|
1633
|
-
n(
|
|
1658
|
+
n(Lt, {
|
|
1634
1659
|
displayName: "Prose<hardbreakFilterPlugin>",
|
|
1635
1660
|
group: "Prose"
|
|
1636
1661
|
});
|
|
1637
|
-
const
|
|
1638
|
-
const e = new
|
|
1662
|
+
const xt = O((t) => {
|
|
1663
|
+
const e = new T("MILKDOWN_HEADING_ID"), r = (a) => {
|
|
1639
1664
|
if (a.composing || !a.editable)
|
|
1640
1665
|
return;
|
|
1641
|
-
const o = t.get(
|
|
1642
|
-
let
|
|
1643
|
-
a.state.doc.descendants((
|
|
1644
|
-
if (
|
|
1645
|
-
if (
|
|
1666
|
+
const o = t.get(Y.key), s = a.state.tr.setMeta("addToHistory", !1);
|
|
1667
|
+
let l = !1;
|
|
1668
|
+
a.state.doc.descendants((i, c) => {
|
|
1669
|
+
if (i.type === H.type(t)) {
|
|
1670
|
+
if (i.textContent.trim().length === 0)
|
|
1646
1671
|
return;
|
|
1647
|
-
const d =
|
|
1648
|
-
d.id !== m && (
|
|
1672
|
+
const d = i.attrs, m = o(i);
|
|
1673
|
+
d.id !== m && (l = !0, s.setMeta(e, !0).setNodeMarkup(c, void 0, {
|
|
1649
1674
|
...d,
|
|
1650
1675
|
id: m
|
|
1651
1676
|
}));
|
|
1652
1677
|
}
|
|
1653
|
-
}),
|
|
1678
|
+
}), l && a.dispatch(s);
|
|
1654
1679
|
};
|
|
1655
|
-
return new
|
|
1680
|
+
return new K({
|
|
1656
1681
|
key: e,
|
|
1657
1682
|
view: (a) => (r(a), {
|
|
1658
1683
|
update: (o) => {
|
|
@@ -1661,155 +1686,157 @@ const Mt = H((t) => {
|
|
|
1661
1686
|
})
|
|
1662
1687
|
});
|
|
1663
1688
|
});
|
|
1664
|
-
n(
|
|
1689
|
+
n(xt, {
|
|
1665
1690
|
displayName: "Prose<syncHeadingIdPlugin>",
|
|
1666
1691
|
group: "Prose"
|
|
1667
1692
|
});
|
|
1668
|
-
const
|
|
1669
|
-
const
|
|
1670
|
-
if (
|
|
1693
|
+
const St = O((t) => {
|
|
1694
|
+
const e = (r) => {
|
|
1695
|
+
if (r.composing || !r.editable)
|
|
1671
1696
|
return;
|
|
1672
|
-
const
|
|
1697
|
+
const a = P.type(t), o = R.type(t), s = M.type(t), l = r.state, i = (m, p) => {
|
|
1673
1698
|
let u = !1;
|
|
1674
|
-
const
|
|
1675
|
-
return
|
|
1699
|
+
const k = `${p + 1}.`;
|
|
1700
|
+
return m.label !== k && (m.label = k, u = !0), u;
|
|
1676
1701
|
};
|
|
1677
|
-
let
|
|
1678
|
-
|
|
1679
|
-
if (
|
|
1680
|
-
const
|
|
1681
|
-
(
|
|
1682
|
-
if (
|
|
1683
|
-
const
|
|
1684
|
-
i(
|
|
1702
|
+
let c = l.tr, d = !1;
|
|
1703
|
+
l.doc.descendants((m, p, u, k) => {
|
|
1704
|
+
if (m.type === o) {
|
|
1705
|
+
const g = m.maybeChild(0);
|
|
1706
|
+
(g == null ? void 0 : g.type) === s && g.attrs.listType === "ordered" && (d = !0, c.setNodeMarkup(p, a, { spread: "true" }), m.descendants((f, L, wt, J) => {
|
|
1707
|
+
if (f.type === s) {
|
|
1708
|
+
const je = { ...f.attrs };
|
|
1709
|
+
i(je, J) && (c = c.setNodeMarkup(L, void 0, je));
|
|
1685
1710
|
}
|
|
1686
1711
|
return !1;
|
|
1687
1712
|
}));
|
|
1688
|
-
} else if (
|
|
1689
|
-
const
|
|
1690
|
-
let
|
|
1691
|
-
|
|
1713
|
+
} else if (m.type === s && (u == null ? void 0 : u.type) === a) {
|
|
1714
|
+
const g = { ...m.attrs };
|
|
1715
|
+
let f = !1;
|
|
1716
|
+
g.listType !== "ordered" && (g.listType = "ordered", f = !0), (u == null ? void 0 : u.maybeChild(0)) && (f = i(g, k)), f && (c = c.setNodeMarkup(p, void 0, g), d = !0);
|
|
1692
1717
|
}
|
|
1693
|
-
}),
|
|
1718
|
+
}), d && r.dispatch(c.setMeta("addToHistory", !1));
|
|
1694
1719
|
};
|
|
1695
|
-
return new
|
|
1696
|
-
key: new
|
|
1697
|
-
view: (
|
|
1698
|
-
update: (
|
|
1699
|
-
|
|
1720
|
+
return new K({
|
|
1721
|
+
key: new T("MILKDOWN_KEEP_LIST_ORDER"),
|
|
1722
|
+
view: (r) => (e(r), {
|
|
1723
|
+
update: (a) => {
|
|
1724
|
+
e(a);
|
|
1700
1725
|
}
|
|
1701
1726
|
})
|
|
1702
1727
|
});
|
|
1703
1728
|
});
|
|
1704
|
-
n(
|
|
1729
|
+
n(St, {
|
|
1705
1730
|
displayName: "Prose<syncListOrderPlugin>",
|
|
1706
1731
|
group: "Prose"
|
|
1707
1732
|
});
|
|
1708
|
-
const
|
|
1709
|
-
|
|
1710
|
-
gt,
|
|
1711
|
-
It,
|
|
1712
|
-
We,
|
|
1713
|
-
Ct,
|
|
1714
|
-
Nt,
|
|
1715
|
-
ht,
|
|
1716
|
-
kt,
|
|
1733
|
+
const pr = [
|
|
1734
|
+
E,
|
|
1717
1735
|
yt,
|
|
1718
|
-
|
|
1736
|
+
bt,
|
|
1737
|
+
Ve,
|
|
1738
|
+
Lt,
|
|
1719
1739
|
Mt,
|
|
1720
|
-
|
|
1721
|
-
|
|
1740
|
+
kt,
|
|
1741
|
+
Nt,
|
|
1742
|
+
ft,
|
|
1743
|
+
It,
|
|
1744
|
+
Ct,
|
|
1745
|
+
xt,
|
|
1746
|
+
St
|
|
1747
|
+
], vr = [Gt, Vt, jt, zt, pr].flat();
|
|
1722
1748
|
export {
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1749
|
+
Ie as blockquoteAttr,
|
|
1750
|
+
Me as blockquoteKeymap,
|
|
1751
|
+
q as blockquoteSchema,
|
|
1752
|
+
Be as bulletListAttr,
|
|
1753
|
+
Te as bulletListKeymap,
|
|
1754
|
+
R as bulletListSchema,
|
|
1755
|
+
be as codeBlockAttr,
|
|
1756
|
+
xe as codeBlockKeymap,
|
|
1757
|
+
W as codeBlockSchema,
|
|
1758
|
+
jt as commands,
|
|
1759
|
+
vr as commonmark,
|
|
1760
|
+
Le as createCodeBlockCommand,
|
|
1761
|
+
lt as createCodeBlockInputRule,
|
|
1762
|
+
tr as defaultConfig,
|
|
1763
|
+
nt as docSchema,
|
|
1764
|
+
fe as downgradeHeadingCommand,
|
|
1765
|
+
ne as emphasisAttr,
|
|
1766
|
+
se as emphasisKeymap,
|
|
1767
|
+
z as emphasisSchema,
|
|
1768
|
+
we as hardbreakAttr,
|
|
1769
|
+
bt as hardbreakClearMarkPlugin,
|
|
1770
|
+
Ve as hardbreakFilterNodes,
|
|
1771
|
+
Lt as hardbreakFilterPlugin,
|
|
1772
|
+
ve as hardbreakKeymap,
|
|
1773
|
+
S as hardbreakSchema,
|
|
1774
|
+
ke as headingAttr,
|
|
1775
|
+
Y as headingIdGenerator,
|
|
1776
|
+
Ne as headingKeymap,
|
|
1777
|
+
H as headingSchema,
|
|
1778
|
+
He as hrAttr,
|
|
1779
|
+
F as hrSchema,
|
|
1780
|
+
Fe as htmlAttr,
|
|
1781
|
+
Ge as htmlSchema,
|
|
1782
|
+
Se as imageAttr,
|
|
1783
|
+
D as imageSchema,
|
|
1784
|
+
de as inlineCodeAttr,
|
|
1785
|
+
ue as inlineCodeKeymap,
|
|
1786
|
+
x as inlineCodeSchema,
|
|
1787
|
+
Mt as inlineNodesCursorPlugin,
|
|
1788
|
+
E as inlineSyncConfig,
|
|
1789
|
+
yt as inlineSyncPlugin,
|
|
1790
|
+
Vt as inputrules,
|
|
1791
|
+
Ae as insertHardbreakCommand,
|
|
1792
|
+
mt as insertHrCommand,
|
|
1793
|
+
dt as insertHrInputRule,
|
|
1794
|
+
it as insertImageCommand,
|
|
1795
|
+
Wt as insertImageInputRule,
|
|
1796
|
+
zt as keymap,
|
|
1797
|
+
qe as liftFirstListItemCommand,
|
|
1798
|
+
_e as liftListItemCommand,
|
|
1799
|
+
pe as linkAttr,
|
|
1800
|
+
B as linkSchema,
|
|
1801
|
+
Pe as listItemAttr,
|
|
1802
|
+
We as listItemKeymap,
|
|
1803
|
+
M as listItemSchema,
|
|
1804
|
+
Ke as orderedListAttr,
|
|
1805
|
+
Re as orderedListKeymap,
|
|
1806
|
+
P as orderedListSchema,
|
|
1807
|
+
ge as paragraphAttr,
|
|
1808
|
+
ye as paragraphKeymap,
|
|
1809
|
+
v as paragraphSchema,
|
|
1810
|
+
pr as plugins,
|
|
1811
|
+
kt as remarkAddOrderInListPlugin,
|
|
1812
|
+
It as remarkHtmlTransformer,
|
|
1813
|
+
Nt as remarkInlineLinkPlugin,
|
|
1814
|
+
ft as remarkLineBreak,
|
|
1815
|
+
Ct as remarkMarker,
|
|
1816
|
+
Gt as schema,
|
|
1817
|
+
Ee as sinkListItemCommand,
|
|
1818
|
+
$e as splitListItemCommand,
|
|
1819
|
+
le as strongAttr,
|
|
1820
|
+
ce as strongKeymap,
|
|
1821
|
+
U as strongSchema,
|
|
1822
|
+
xt as syncHeadingIdPlugin,
|
|
1823
|
+
St as syncListOrderPlugin,
|
|
1824
|
+
gt as textSchema,
|
|
1825
|
+
oe as toggleEmphasisCommand,
|
|
1826
|
+
me as toggleInlineCodeCommand,
|
|
1827
|
+
rt as toggleLinkCommand,
|
|
1828
|
+
ie as toggleStrongCommand,
|
|
1829
|
+
he as turnIntoTextCommand,
|
|
1830
|
+
qt as updateCodeBlockLanguageCommand,
|
|
1831
|
+
ct as updateImageCommand,
|
|
1832
|
+
at as updateLinkCommand,
|
|
1833
|
+
Ce as wrapInBlockquoteCommand,
|
|
1834
|
+
st as wrapInBlockquoteInputRule,
|
|
1835
|
+
Oe as wrapInBulletListCommand,
|
|
1836
|
+
ut as wrapInBulletListInputRule,
|
|
1837
|
+
b as wrapInHeadingCommand,
|
|
1838
|
+
ot as wrapInHeadingInputRule,
|
|
1839
|
+
De as wrapInOrderedListCommand,
|
|
1840
|
+
pt as wrapInOrderedListInputRule
|
|
1814
1841
|
};
|
|
1815
1842
|
//# sourceMappingURL=index.es.js.map
|