@milkdown/preset-commonmark 6.5.0 → 6.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.es.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { createMark as
|
|
2
|
-
import { createCmdKey as y, createCmd as M, commandsCtx as
|
|
3
|
-
import { toggleMark as me, wrapIn as pe, setBlockType as
|
|
4
|
-
import { expectDomTypeError as L, missingRootElement as
|
|
5
|
-
import { calculateTextPosition as
|
|
6
|
-
import { PluginKey as
|
|
7
|
-
import { wrappingInputRule as
|
|
8
|
-
import { Fragment as
|
|
9
|
-
import { ReplaceStep as
|
|
1
|
+
import { createMark as W, createShortcut as h, createNode as w, pipe as Se, createPlugin as Ae, AtomList as we } from "@milkdown/utils";
|
|
2
|
+
import { createCmdKey as y, createCmd as M, commandsCtx as Le, editorViewCtx as S, schemaCtx as B, getPalette as Ee, createSlice as ve, serializerCtx as _e, parserCtx as $e } from "@milkdown/core";
|
|
3
|
+
import { toggleMark as me, wrapIn as pe, setBlockType as E } from "@milkdown/prose/commands";
|
|
4
|
+
import { expectDomTypeError as L, missingRootElement as Pe } from "@milkdown/exception";
|
|
5
|
+
import { calculateTextPosition as Be, cloneTr as Re, findSelectedNodeOfType as K, getNodeFromSchema as We } from "@milkdown/prose";
|
|
6
|
+
import { PluginKey as H, TextSelection as J, Plugin as T, NodeSelection as qe, Selection as Ce } from "@milkdown/prose/state";
|
|
7
|
+
import { wrappingInputRule as q, textblockTypeInputRule as Q, InputRule as xe } from "@milkdown/prose/inputrules";
|
|
8
|
+
import { Fragment as R } from "@milkdown/prose/model";
|
|
9
|
+
import { ReplaceStep as Ke, AddMarkStep as Fe } from "@milkdown/prose/transform";
|
|
10
10
|
import { DecorationSet as O, Decoration as X } from "@milkdown/prose/view";
|
|
11
|
-
import { splitListItem as
|
|
12
|
-
import
|
|
13
|
-
import { visit as
|
|
11
|
+
import { splitListItem as je, sinkListItem as ze, liftListItem as Ue } from "@milkdown/prose/schema-list";
|
|
12
|
+
import Ve from "remark-inline-links";
|
|
13
|
+
import { visit as Ge } from "unist-util-visit";
|
|
14
14
|
const k = {
|
|
15
15
|
HardBreak: "HardBreak",
|
|
16
16
|
Blockquote: "Blockquote",
|
|
@@ -31,8 +31,8 @@ const k = {
|
|
|
31
31
|
NextListItem: "NextListItem",
|
|
32
32
|
SinkListItem: "SinkListItem",
|
|
33
33
|
LiftListItem: "LiftListItem"
|
|
34
|
-
},
|
|
35
|
-
id:
|
|
34
|
+
}, ke = "code_inline", Z = y("ToggleInlineCode"), Ye = W((a) => ({
|
|
35
|
+
id: ke,
|
|
36
36
|
schema: () => ({
|
|
37
37
|
priority: 100,
|
|
38
38
|
code: !0,
|
|
@@ -46,7 +46,7 @@ const k = {
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
toMarkdown: {
|
|
49
|
-
match: (e) => e.type.name ===
|
|
49
|
+
match: (e) => e.type.name === ke,
|
|
50
50
|
runner: (e, t, r) => {
|
|
51
51
|
e.withMark(t, "inlineCode", r.text || "");
|
|
52
52
|
}
|
|
@@ -66,7 +66,7 @@ const k = {
|
|
|
66
66
|
shortcuts: {
|
|
67
67
|
[k.CodeInline]: h(Z, "Mod-e")
|
|
68
68
|
}
|
|
69
|
-
})), F = "em", ee = y("ToggleItalic"),
|
|
69
|
+
})), F = "em", ee = y("ToggleItalic"), Je = W((a) => ({
|
|
70
70
|
id: F,
|
|
71
71
|
schema: () => ({
|
|
72
72
|
inclusive: !1,
|
|
@@ -93,8 +93,8 @@ const k = {
|
|
|
93
93
|
shortcuts: {
|
|
94
94
|
[k.Em]: h(ee, "Mod-i")
|
|
95
95
|
}
|
|
96
|
-
})),
|
|
97
|
-
id:
|
|
96
|
+
})), Qe = new H("MILKDOWN_LINK_INPUT"), Te = y("ToggleLink"), te = y("ModifyLink"), _ = "link", Xe = W((a, e) => ({
|
|
97
|
+
id: _,
|
|
98
98
|
schema: () => ({
|
|
99
99
|
attrs: {
|
|
100
100
|
href: {},
|
|
@@ -110,7 +110,7 @@ const k = {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
],
|
|
113
|
-
toDOM: (t) => ["a", { ...t.attrs, class: a.getClassName(t.attrs,
|
|
113
|
+
toDOM: (t) => ["a", { ...t.attrs, class: a.getClassName(t.attrs, _) }],
|
|
114
114
|
parseMarkdown: {
|
|
115
115
|
match: (t) => t.type === "link",
|
|
116
116
|
runner: (t, r, n) => {
|
|
@@ -119,7 +119,7 @@ const k = {
|
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
121
|
toMarkdown: {
|
|
122
|
-
match: (t) => t.type.name ===
|
|
122
|
+
match: (t) => t.type.name === _,
|
|
123
123
|
runner: (t, r) => {
|
|
124
124
|
t.withMark(r, "link", void 0, {
|
|
125
125
|
title: r.attrs.title,
|
|
@@ -129,7 +129,7 @@ const k = {
|
|
|
129
129
|
}
|
|
130
130
|
}),
|
|
131
131
|
commands: (t) => [
|
|
132
|
-
M(
|
|
132
|
+
M(Te, (r = "") => me(t, { href: r })),
|
|
133
133
|
M(te, (r = "") => (n, o) => {
|
|
134
134
|
var I;
|
|
135
135
|
if (!o)
|
|
@@ -137,40 +137,44 @@ const k = {
|
|
|
137
137
|
const { marks: l } = n.schema;
|
|
138
138
|
let s, c = -1;
|
|
139
139
|
const { selection: i } = n, { from: u, to: f } = i;
|
|
140
|
-
if (n.doc.nodesBetween(u, u === f ? f + 1 : f, (b,
|
|
141
|
-
var
|
|
142
|
-
if ((
|
|
143
|
-
return s = b, c =
|
|
140
|
+
if (n.doc.nodesBetween(u, u === f ? f + 1 : f, (b, C) => {
|
|
141
|
+
var x;
|
|
142
|
+
if ((x = l.link) != null && x.isInSet(b.marks))
|
|
143
|
+
return s = b, c = C, !1;
|
|
144
144
|
}), !s)
|
|
145
145
|
return !1;
|
|
146
146
|
const d = s.marks.find(({ type: b }) => b === t);
|
|
147
147
|
if (!d)
|
|
148
148
|
return !1;
|
|
149
149
|
const m = c, p = c + s.nodeSize, { tr: g } = n, N = (I = l.link) == null ? void 0 : I.create({ ...d.attrs, href: r });
|
|
150
|
-
return N ? (o(
|
|
150
|
+
return N ? (o(
|
|
151
|
+
g.removeMark(m, p, d).addMark(m, p, N).setSelection(new J(g.selection.$anchor)).scrollIntoView()
|
|
152
|
+
), !0) : !1;
|
|
151
153
|
})
|
|
152
154
|
],
|
|
153
155
|
prosePlugins: (t, r) => {
|
|
154
156
|
let n = !1;
|
|
155
157
|
return [
|
|
156
|
-
new
|
|
157
|
-
key:
|
|
158
|
+
new T({
|
|
159
|
+
key: Qe,
|
|
158
160
|
view: (o) => {
|
|
159
161
|
var u, f, d;
|
|
160
162
|
const l = a.themeManager.get("input-chip", {
|
|
161
163
|
placeholder: (f = (u = e == null ? void 0 : e.input) == null ? void 0 : u.placeholder) != null ? f : "Input Web Link",
|
|
162
164
|
buttonText: (d = e == null ? void 0 : e.input) == null ? void 0 : d.buttonText,
|
|
163
165
|
onUpdate: (m) => {
|
|
164
|
-
r.get(
|
|
166
|
+
r.get(Le).call(te, m);
|
|
165
167
|
},
|
|
166
168
|
calculatePosition: (m, p) => {
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
if (!
|
|
170
|
-
throw
|
|
171
|
-
const
|
|
172
|
-
let
|
|
173
|
-
|
|
169
|
+
Be(m, p, (g, N, I, b) => {
|
|
170
|
+
const C = m.dom.parentElement;
|
|
171
|
+
if (!C)
|
|
172
|
+
throw Pe();
|
|
173
|
+
const x = N.left - g.left;
|
|
174
|
+
let A = g.left - b.left - (I.width - x) / 2, ge = g.bottom - b.top + 14 + C.scrollTop;
|
|
175
|
+
n && (ge = g.top - b.top - I.height - 14 + C.scrollTop), A < 0 && (A = 0);
|
|
176
|
+
const he = C.clientWidth - (I.width + 4);
|
|
177
|
+
return A > he && (A = he), [ge, A];
|
|
174
178
|
});
|
|
175
179
|
}
|
|
176
180
|
});
|
|
@@ -182,9 +186,9 @@ const k = {
|
|
|
182
186
|
return !1;
|
|
183
187
|
if (p.empty && p instanceof J && I < g.content.size && N < g.content.size && g.rangeHasMark(N, N === I ? I + 1 : I, t))
|
|
184
188
|
return n = !1, !0;
|
|
185
|
-
if (p instanceof
|
|
189
|
+
if (p instanceof qe) {
|
|
186
190
|
const { node: b } = p;
|
|
187
|
-
if (b.type.name === "image" && b.marks.findIndex((
|
|
191
|
+
if (b.type.name === "image" && b.marks.findIndex((C) => C.type.name === _) > -1)
|
|
188
192
|
return n = !0, !0;
|
|
189
193
|
}
|
|
190
194
|
return !1;
|
|
@@ -192,12 +196,12 @@ const k = {
|
|
|
192
196
|
const { selection: p } = m.state;
|
|
193
197
|
let g;
|
|
194
198
|
const { from: N, to: I } = p;
|
|
195
|
-
if (m.state.doc.nodesBetween(N, N === I ? I + 1 : I, (
|
|
196
|
-
if (t.isInSet(
|
|
197
|
-
return g =
|
|
199
|
+
if (m.state.doc.nodesBetween(N, N === I ? I + 1 : I, (x) => {
|
|
200
|
+
if (t.isInSet(x.marks))
|
|
201
|
+
return g = x, !1;
|
|
198
202
|
}), !g)
|
|
199
203
|
return;
|
|
200
|
-
const b = g.marks.find((
|
|
204
|
+
const b = g.marks.find((x) => x.type === t);
|
|
201
205
|
return b ? b.attrs.href : void 0;
|
|
202
206
|
}, i = (m) => {
|
|
203
207
|
if (!m.editable)
|
|
@@ -218,7 +222,7 @@ const k = {
|
|
|
218
222
|
})
|
|
219
223
|
];
|
|
220
224
|
}
|
|
221
|
-
})), j = "strong", re = y("ToggleBold"),
|
|
225
|
+
})), j = "strong", re = y("ToggleBold"), Ze = W((a) => ({
|
|
222
226
|
id: j,
|
|
223
227
|
schema: () => ({
|
|
224
228
|
inclusive: !1,
|
|
@@ -245,33 +249,33 @@ const k = {
|
|
|
245
249
|
shortcuts: {
|
|
246
250
|
[k.Bold]: h(re, "Mod-b")
|
|
247
251
|
}
|
|
248
|
-
})),
|
|
249
|
-
id:
|
|
252
|
+
})), et = [Ye(), Je(), Ze(), Xe()], $ = "blockquote", ne = y("WrapInBlockquote"), tt = w((a) => ({
|
|
253
|
+
id: $,
|
|
250
254
|
schema: () => ({
|
|
251
255
|
content: "block+",
|
|
252
256
|
group: "block",
|
|
253
257
|
defining: !0,
|
|
254
258
|
parseDOM: [{ tag: "blockquote" }],
|
|
255
|
-
toDOM: (e) => ["blockquote", { class: a.getClassName(e.attrs,
|
|
259
|
+
toDOM: (e) => ["blockquote", { class: a.getClassName(e.attrs, $) }, 0],
|
|
256
260
|
parseMarkdown: {
|
|
257
|
-
match: ({ type: e }) => e ===
|
|
261
|
+
match: ({ type: e }) => e === $,
|
|
258
262
|
runner: (e, t, r) => {
|
|
259
263
|
e.openNode(r).next(t.children).closeNode();
|
|
260
264
|
}
|
|
261
265
|
},
|
|
262
266
|
toMarkdown: {
|
|
263
|
-
match: (e) => e.type.name ===
|
|
267
|
+
match: (e) => e.type.name === $,
|
|
264
268
|
runner: (e, t) => {
|
|
265
269
|
e.openNode("blockquote").next(t.content).closeNode();
|
|
266
270
|
}
|
|
267
271
|
}
|
|
268
272
|
}),
|
|
269
|
-
inputRules: (e) => [
|
|
273
|
+
inputRules: (e) => [q(/^\s*>\s$/, e)],
|
|
270
274
|
commands: (e) => [M(ne, () => pe(e))],
|
|
271
275
|
shortcuts: {
|
|
272
276
|
[k.Blockquote]: h(ne, "Mod-Shift-b")
|
|
273
277
|
}
|
|
274
|
-
})), se = y("WrapInBulletList"),
|
|
278
|
+
})), se = y("WrapInBulletList"), rt = w((a) => {
|
|
275
279
|
const e = "bullet_list";
|
|
276
280
|
return {
|
|
277
281
|
id: e,
|
|
@@ -317,13 +321,13 @@ const k = {
|
|
|
317
321
|
}
|
|
318
322
|
}
|
|
319
323
|
}),
|
|
320
|
-
inputRules: (t) => [
|
|
324
|
+
inputRules: (t) => [q(/^\s*([-+*])\s$/, t)],
|
|
321
325
|
commands: (t) => [M(se, () => pe(t))],
|
|
322
326
|
shortcuts: {
|
|
323
327
|
[k.BulletList]: h(se, "Mod-Alt-8")
|
|
324
328
|
}
|
|
325
329
|
};
|
|
326
|
-
}),
|
|
330
|
+
}), nt = [
|
|
327
331
|
"",
|
|
328
332
|
"javascript",
|
|
329
333
|
"typescript",
|
|
@@ -340,8 +344,8 @@ const k = {
|
|
|
340
344
|
"go",
|
|
341
345
|
"rust",
|
|
342
346
|
"markdown"
|
|
343
|
-
],
|
|
344
|
-
const t = (e == null ? void 0 : e.languageList) ||
|
|
347
|
+
], st = /^```(?<language>[a-z]*)?[\s\n]$/, ot = /^~~~(?<language>[a-z]*)?[\s\n]$/, oe = y("TurnIntoCodeFence"), z = "fence", at = w((a, e) => {
|
|
348
|
+
const t = (e == null ? void 0 : e.languageList) || nt;
|
|
345
349
|
return {
|
|
346
350
|
id: z,
|
|
347
351
|
schema: (r) => ({
|
|
@@ -374,9 +378,9 @@ const k = {
|
|
|
374
378
|
throw L(n);
|
|
375
379
|
const l = (i = (c = n.querySelector("pre")) == null ? void 0 : c.textContent) != null ? i : "";
|
|
376
380
|
if (!l)
|
|
377
|
-
return
|
|
381
|
+
return R.empty;
|
|
378
382
|
const s = o.text(l);
|
|
379
|
-
return
|
|
383
|
+
return R.from(s);
|
|
380
384
|
}
|
|
381
385
|
},
|
|
382
386
|
{
|
|
@@ -407,10 +411,12 @@ const k = {
|
|
|
407
411
|
if (!f)
|
|
408
412
|
return;
|
|
409
413
|
const { tr: d } = c.state;
|
|
410
|
-
c.dispatch(
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
+
c.dispatch(
|
|
415
|
+
d.setNodeMarkup(f.inside, void 0, {
|
|
416
|
+
...n.attrs,
|
|
417
|
+
language: s.value
|
|
418
|
+
})
|
|
419
|
+
);
|
|
414
420
|
}, [
|
|
415
421
|
"div",
|
|
416
422
|
{
|
|
@@ -445,18 +451,18 @@ const k = {
|
|
|
445
451
|
}
|
|
446
452
|
}),
|
|
447
453
|
inputRules: (r) => [
|
|
448
|
-
Q(
|
|
454
|
+
Q(st, r, (n) => {
|
|
449
455
|
const [o, l] = n;
|
|
450
456
|
if (!!o)
|
|
451
457
|
return { language: l };
|
|
452
458
|
}),
|
|
453
|
-
Q(
|
|
459
|
+
Q(ot, r, (n) => {
|
|
454
460
|
const [o, l] = n;
|
|
455
461
|
if (!!o)
|
|
456
462
|
return { language: l };
|
|
457
463
|
})
|
|
458
464
|
],
|
|
459
|
-
commands: (r) => [M(oe, () =>
|
|
465
|
+
commands: (r) => [M(oe, () => E(r))],
|
|
460
466
|
shortcuts: {
|
|
461
467
|
[k.CodeFence]: h(oe, "Mod-Alt-c")
|
|
462
468
|
},
|
|
@@ -464,22 +470,28 @@ const k = {
|
|
|
464
470
|
let l = r;
|
|
465
471
|
const s = (g) => {
|
|
466
472
|
const { tr: N } = n.state;
|
|
467
|
-
n.dispatch(
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
473
|
+
n.dispatch(
|
|
474
|
+
N.setNodeMarkup(o(), void 0, {
|
|
475
|
+
fold: !0,
|
|
476
|
+
language: g
|
|
477
|
+
})
|
|
478
|
+
);
|
|
471
479
|
}, c = () => {
|
|
472
480
|
const { tr: g } = n.state;
|
|
473
|
-
n.dispatch(
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
481
|
+
n.dispatch(
|
|
482
|
+
g.setNodeMarkup(o(), void 0, {
|
|
483
|
+
...l.attrs,
|
|
484
|
+
fold: !0
|
|
485
|
+
})
|
|
486
|
+
);
|
|
477
487
|
}, i = () => {
|
|
478
488
|
const { tr: g } = n.state;
|
|
479
|
-
n.dispatch(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
489
|
+
n.dispatch(
|
|
490
|
+
g.setNodeMarkup(o(), void 0, {
|
|
491
|
+
...l.attrs,
|
|
492
|
+
fold: !1
|
|
493
|
+
})
|
|
494
|
+
);
|
|
483
495
|
}, u = a.themeManager.get("code-fence", {
|
|
484
496
|
onBlur: c,
|
|
485
497
|
onFocus: i,
|
|
@@ -498,7 +510,7 @@ const k = {
|
|
|
498
510
|
};
|
|
499
511
|
}
|
|
500
512
|
};
|
|
501
|
-
}),
|
|
513
|
+
}), lt = w(() => ({
|
|
502
514
|
id: "doc",
|
|
503
515
|
schema: () => ({
|
|
504
516
|
content: "block+",
|
|
@@ -515,7 +527,7 @@ const k = {
|
|
|
515
527
|
}
|
|
516
528
|
}
|
|
517
529
|
})
|
|
518
|
-
})), ae = y("InsertHardbreak"),
|
|
530
|
+
})), ae = y("InsertHardbreak"), ct = new H("MILKDOWN_HARDBREAK_FILTER"), it = w((a, e) => {
|
|
519
531
|
var r;
|
|
520
532
|
const t = (r = e == null ? void 0 : e.notIn) != null ? r : ["table", "fence"];
|
|
521
533
|
return {
|
|
@@ -546,7 +558,9 @@ const k = {
|
|
|
546
558
|
if (s.empty) {
|
|
547
559
|
const u = s.$from.node();
|
|
548
560
|
if (u.childCount > 0 && ((i = u.lastChild) == null ? void 0 : i.type.name) === "hardbreak")
|
|
549
|
-
return l == null || l(
|
|
561
|
+
return l == null || l(
|
|
562
|
+
c.replaceRangeWith(s.to - 1, s.to, o.schema.node("paragraph")).setSelection(Ce.near(c.doc.resolve(s.to))).scrollIntoView()
|
|
563
|
+
), !0;
|
|
550
564
|
}
|
|
551
565
|
return l == null || l(c.setMeta("hardbreak", !0).replaceSelectionWith(n.create()).scrollIntoView()), !0;
|
|
552
566
|
})
|
|
@@ -555,8 +569,8 @@ const k = {
|
|
|
555
569
|
[k.HardBreak]: h(ae, "Shift-Enter")
|
|
556
570
|
},
|
|
557
571
|
prosePlugins: (n) => [
|
|
558
|
-
new
|
|
559
|
-
key:
|
|
572
|
+
new T({
|
|
573
|
+
key: ct,
|
|
560
574
|
filterTransaction: (o, l) => {
|
|
561
575
|
const s = o.getMeta("hardbreak"), [c] = o.steps;
|
|
562
576
|
if (s && c) {
|
|
@@ -569,8 +583,8 @@ const k = {
|
|
|
569
583
|
return !0;
|
|
570
584
|
}
|
|
571
585
|
}),
|
|
572
|
-
new
|
|
573
|
-
key: new
|
|
586
|
+
new T({
|
|
587
|
+
key: new H("MILKDOWN_HARDBREAK_MARKS"),
|
|
574
588
|
appendTransaction: (o, l, s) => {
|
|
575
589
|
if (!o.length)
|
|
576
590
|
return;
|
|
@@ -579,12 +593,12 @@ const k = {
|
|
|
579
593
|
return;
|
|
580
594
|
const [i] = c.steps;
|
|
581
595
|
if (c.getMeta("hardbreak")) {
|
|
582
|
-
if (!(i instanceof
|
|
596
|
+
if (!(i instanceof Ke))
|
|
583
597
|
return;
|
|
584
598
|
const { from: d } = i;
|
|
585
599
|
return s.tr.setNodeMarkup(d, n, void 0, []);
|
|
586
600
|
}
|
|
587
|
-
if (i instanceof
|
|
601
|
+
if (i instanceof Fe) {
|
|
588
602
|
let d = s.tr;
|
|
589
603
|
const { from: m, to: p } = i;
|
|
590
604
|
return s.doc.nodesBetween(m, p, (g, N) => {
|
|
@@ -595,7 +609,7 @@ const k = {
|
|
|
595
609
|
})
|
|
596
610
|
]
|
|
597
611
|
};
|
|
598
|
-
}),
|
|
612
|
+
}), Me = Array(6).fill(0).map((a, e) => e + 1), D = y("TurnIntoHeading"), ye = y("DowngradeHeading"), U = new H("MILKDOWN_HEADING_ID"), ut = new H("MILKDOWN_HEADING_HASH"), dt = (a) => a.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "-").toLowerCase().trim(), ft = (a, e, t) => {
|
|
599
613
|
let r = !1;
|
|
600
614
|
const n = (o, l) => {
|
|
601
615
|
const s = o.tr.setMeta("addToHistory", !1);
|
|
@@ -612,7 +626,7 @@ const k = {
|
|
|
612
626
|
}
|
|
613
627
|
}), c && l(s);
|
|
614
628
|
};
|
|
615
|
-
return new
|
|
629
|
+
return new T({
|
|
616
630
|
key: U,
|
|
617
631
|
props: {
|
|
618
632
|
handleDOMEvents: {
|
|
@@ -643,8 +657,8 @@ const k = {
|
|
|
643
657
|
}), o.dispatch(s), {};
|
|
644
658
|
}
|
|
645
659
|
});
|
|
646
|
-
},
|
|
647
|
-
key:
|
|
660
|
+
}, mt = (a, e, t) => new T({
|
|
661
|
+
key: ut,
|
|
648
662
|
state: {
|
|
649
663
|
init: () => O.empty,
|
|
650
664
|
apply: (r) => {
|
|
@@ -658,7 +672,7 @@ const k = {
|
|
|
658
672
|
const s = l.attrs.level, c = (d) => Array(d).fill(0).map((m) => "#").join(""), i = document.createElement("span");
|
|
659
673
|
i.textContent = c(s), i.contentEditable = "false", t.themeManager.onFlush(() => {
|
|
660
674
|
const d = t.getStyle(({ css: m }) => {
|
|
661
|
-
const p =
|
|
675
|
+
const p = Ee(t.themeManager);
|
|
662
676
|
return m`
|
|
663
677
|
margin-right: 4px;
|
|
664
678
|
color: ${p("primary")};
|
|
@@ -673,7 +687,7 @@ const k = {
|
|
|
673
687
|
props: {
|
|
674
688
|
handleDOMEvents: {
|
|
675
689
|
focus: (r) => {
|
|
676
|
-
const n =
|
|
690
|
+
const n = Re(r.state.tr);
|
|
677
691
|
return r.dispatch(n), !1;
|
|
678
692
|
}
|
|
679
693
|
},
|
|
@@ -681,101 +695,107 @@ const k = {
|
|
|
681
695
|
return this.getState(r);
|
|
682
696
|
}
|
|
683
697
|
}
|
|
684
|
-
}),
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
698
|
+
}), pt = w(
|
|
699
|
+
(a, e) => {
|
|
700
|
+
var o, l;
|
|
701
|
+
const t = "heading", r = (o = e == null ? void 0 : e.getId) != null ? o : dt, n = (l = e == null ? void 0 : e.displayHashtag) != null ? l : !0;
|
|
702
|
+
return {
|
|
703
|
+
id: t,
|
|
704
|
+
schema: () => ({
|
|
705
|
+
content: "inline*",
|
|
706
|
+
group: "block",
|
|
707
|
+
defining: !0,
|
|
708
|
+
attrs: {
|
|
709
|
+
id: {
|
|
710
|
+
default: ""
|
|
711
|
+
},
|
|
712
|
+
level: {
|
|
713
|
+
default: 1
|
|
714
|
+
}
|
|
696
715
|
},
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
716
|
+
parseDOM: Me.map((s) => ({
|
|
717
|
+
tag: `h${s}`,
|
|
718
|
+
getAttrs: (c) => {
|
|
719
|
+
if (!(c instanceof HTMLElement))
|
|
720
|
+
throw L(c);
|
|
721
|
+
return { level: s, id: c.id };
|
|
722
|
+
}
|
|
723
|
+
})),
|
|
724
|
+
toDOM: (s) => [
|
|
725
|
+
`h${s.attrs.level}`,
|
|
726
|
+
{
|
|
727
|
+
id: s.attrs.id || r(s),
|
|
728
|
+
class: a.getClassName(s.attrs, `heading h${s.attrs.level}`)
|
|
729
|
+
},
|
|
730
|
+
0
|
|
731
|
+
],
|
|
732
|
+
parseMarkdown: {
|
|
733
|
+
match: ({ type: s }) => s === t,
|
|
734
|
+
runner: (s, c, i) => {
|
|
735
|
+
const u = c.depth;
|
|
736
|
+
s.openNode(i, { level: u }), s.next(c.children), s.closeNode();
|
|
737
|
+
}
|
|
714
738
|
},
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
739
|
+
toMarkdown: {
|
|
740
|
+
match: (s) => s.type.name === t,
|
|
741
|
+
runner: (s, c) => {
|
|
742
|
+
var u;
|
|
743
|
+
if (s.openNode("heading", void 0, { depth: c.attrs.level }), c.childCount >= 1 && ((u = c.lastChild) == null ? void 0 : u.type.name) === "hardbreak") {
|
|
744
|
+
const f = [];
|
|
745
|
+
c.content.forEach((d, m, p) => {
|
|
746
|
+
p !== c.childCount - 1 && f.push(d);
|
|
747
|
+
}), s.next(R.fromArray(f));
|
|
748
|
+
} else
|
|
749
|
+
s.next(c.content);
|
|
750
|
+
s.closeNode();
|
|
751
|
+
}
|
|
722
752
|
}
|
|
753
|
+
}),
|
|
754
|
+
inputRules: (s, c) => Me.map(
|
|
755
|
+
(i) => Q(new RegExp(`^(#{1,${i}})\\s$`), s, () => {
|
|
756
|
+
const u = c.get(S), { $from: f } = u.state.selection, d = f.node();
|
|
757
|
+
if (d.type.name === "heading") {
|
|
758
|
+
let m = Number(d.attrs.level) + Number(i);
|
|
759
|
+
return m > 6 && (m = 6), {
|
|
760
|
+
level: m
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
return {
|
|
764
|
+
level: i
|
|
765
|
+
};
|
|
766
|
+
})
|
|
767
|
+
),
|
|
768
|
+
commands: (s, c) => [
|
|
769
|
+
M(D, (i = 1) => i < 1 ? E(i === 0 && c.get(B).nodes.paragraph || s) : E(i === 0 && c.get(B).nodes.paragraph || s, { level: i })),
|
|
770
|
+
M(ye, () => (i, u, f) => {
|
|
771
|
+
const { $from: d } = i.selection, m = d.node();
|
|
772
|
+
if (m.type !== s || !i.selection.empty || d.parentOffset !== 0)
|
|
773
|
+
return !1;
|
|
774
|
+
const p = m.attrs.level - 1;
|
|
775
|
+
return p ? (u == null || u(
|
|
776
|
+
i.tr.setNodeMarkup(i.selection.$from.before(), void 0, {
|
|
777
|
+
...m.attrs,
|
|
778
|
+
level: p
|
|
779
|
+
})
|
|
780
|
+
), !0) : E(c.get(B).nodes.paragraph || s)(i, u, f);
|
|
781
|
+
})
|
|
782
|
+
],
|
|
783
|
+
shortcuts: {
|
|
784
|
+
[k.H1]: h(D, "Mod-Alt-1", 1),
|
|
785
|
+
[k.H2]: h(D, "Mod-Alt-2", 2),
|
|
786
|
+
[k.H3]: h(D, "Mod-Alt-3", 3),
|
|
787
|
+
[k.H4]: h(D, "Mod-Alt-4", 4),
|
|
788
|
+
[k.H5]: h(D, "Mod-Alt-5", 5),
|
|
789
|
+
[k.H6]: h(D, "Mod-Alt-6", 6),
|
|
790
|
+
[k.DowngradeHeading]: h(ye, ["Backspace", "Delete"])
|
|
723
791
|
},
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
var u;
|
|
728
|
-
if (s.openNode("heading", void 0, { depth: c.attrs.level }), c.childCount >= 1 && ((u = c.lastChild) == null ? void 0 : u.type.name) === "hardbreak") {
|
|
729
|
-
const f = [];
|
|
730
|
-
c.content.forEach((d, m, p) => {
|
|
731
|
-
p !== c.childCount - 1 && f.push(d);
|
|
732
|
-
}), s.next(B.fromArray(f));
|
|
733
|
-
} else
|
|
734
|
-
s.next(c.content);
|
|
735
|
-
s.closeNode();
|
|
736
|
-
}
|
|
792
|
+
prosePlugins: (s, c) => {
|
|
793
|
+
const i = [ft(c, s, r)];
|
|
794
|
+
return n && i.push(mt(c, s, a)), i;
|
|
737
795
|
}
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
if (d.type.name === "heading") {
|
|
742
|
-
let m = Number(d.attrs.level) + Number(i);
|
|
743
|
-
return m > 6 && (m = 6), {
|
|
744
|
-
level: m
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
return {
|
|
748
|
-
level: i
|
|
749
|
-
};
|
|
750
|
-
})),
|
|
751
|
-
commands: (s, c) => [
|
|
752
|
-
M(D, (i = 1) => i < 1 ? A(i === 0 && c.get(P).nodes.paragraph || s) : A(i === 0 && c.get(P).nodes.paragraph || s, { level: i })),
|
|
753
|
-
M(Me, () => (i, u, f) => {
|
|
754
|
-
const { $from: d } = i.selection, m = d.node();
|
|
755
|
-
if (m.type !== s || !i.selection.empty || d.parentOffset !== 0)
|
|
756
|
-
return !1;
|
|
757
|
-
const p = m.attrs.level - 1;
|
|
758
|
-
return p ? (u == null || u(i.tr.setNodeMarkup(i.selection.$from.before(), void 0, {
|
|
759
|
-
...m.attrs,
|
|
760
|
-
level: p
|
|
761
|
-
})), !0) : A(c.get(P).nodes.paragraph || s)(i, u, f);
|
|
762
|
-
})
|
|
763
|
-
],
|
|
764
|
-
shortcuts: {
|
|
765
|
-
[k.H1]: h(D, "Mod-Alt-1", 1),
|
|
766
|
-
[k.H2]: h(D, "Mod-Alt-2", 2),
|
|
767
|
-
[k.H3]: h(D, "Mod-Alt-3", 3),
|
|
768
|
-
[k.H4]: h(D, "Mod-Alt-4", 4),
|
|
769
|
-
[k.H5]: h(D, "Mod-Alt-5", 5),
|
|
770
|
-
[k.H6]: h(D, "Mod-Alt-6", 6),
|
|
771
|
-
[k.DowngradeHeading]: h(Me, ["Backspace", "Delete"])
|
|
772
|
-
},
|
|
773
|
-
prosePlugins: (s, c) => {
|
|
774
|
-
const i = [dt(c, s, r)];
|
|
775
|
-
return n && i.push(ft(c, s, a)), i;
|
|
776
|
-
}
|
|
777
|
-
};
|
|
778
|
-
}), V = "hr", Te = y("InsertHr"), pt = w((a) => ({
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
), V = "hr", He = y("InsertHr"), gt = w((a) => ({
|
|
779
799
|
id: V,
|
|
780
800
|
schema: () => ({
|
|
781
801
|
group: "block",
|
|
@@ -795,23 +815,23 @@ const k = {
|
|
|
795
815
|
}
|
|
796
816
|
}),
|
|
797
817
|
inputRules: (e) => [
|
|
798
|
-
new
|
|
818
|
+
new xe(/^(?:---|___\s|\*\*\*\s)$/, (t, r, n, o) => {
|
|
799
819
|
const { tr: l } = t;
|
|
800
820
|
return r[0] && l.replaceWith(n - 1, o, e.create()), l;
|
|
801
821
|
})
|
|
802
822
|
],
|
|
803
823
|
commands: (e, t) => [
|
|
804
|
-
M(
|
|
824
|
+
M(He, () => (r, n) => {
|
|
805
825
|
if (!n)
|
|
806
826
|
return !0;
|
|
807
|
-
const o = t.get(
|
|
827
|
+
const o = t.get(B).node("paragraph"), { tr: l, selection: s } = r, { from: c } = s, i = e.create();
|
|
808
828
|
if (!i)
|
|
809
829
|
return !0;
|
|
810
|
-
const u = l.replaceSelectionWith(i).insert(c, o), f =
|
|
830
|
+
const u = l.replaceSelectionWith(i).insert(c, o), f = Ce.findFrom(u.doc.resolve(c), 1, !0);
|
|
811
831
|
return f && n(u.setSelection(f).scrollIntoView()), !0;
|
|
812
832
|
})
|
|
813
833
|
]
|
|
814
|
-
})), le = y("ModifyImage"),
|
|
834
|
+
})), le = y("ModifyImage"), De = y("InsertImage"), P = "image", ht = new H("MILKDOWN_IMAGE_INPUT"), kt = w((a, e) => ({
|
|
815
835
|
id: "image",
|
|
816
836
|
schema: () => ({
|
|
817
837
|
inline: !0,
|
|
@@ -845,11 +865,11 @@ const k = {
|
|
|
845
865
|
"img",
|
|
846
866
|
{
|
|
847
867
|
...t.attrs,
|
|
848
|
-
class: a.getClassName(t.attrs,
|
|
868
|
+
class: a.getClassName(t.attrs, P)
|
|
849
869
|
}
|
|
850
870
|
],
|
|
851
871
|
parseMarkdown: {
|
|
852
|
-
match: ({ type: t }) => t ===
|
|
872
|
+
match: ({ type: t }) => t === P,
|
|
853
873
|
runner: (t, r, n) => {
|
|
854
874
|
const o = r.url, l = r.alt, s = r.title;
|
|
855
875
|
t.addNode(n, {
|
|
@@ -860,7 +880,7 @@ const k = {
|
|
|
860
880
|
}
|
|
861
881
|
},
|
|
862
882
|
toMarkdown: {
|
|
863
|
-
match: (t) => t.type.name ===
|
|
883
|
+
match: (t) => t.type.name === P,
|
|
864
884
|
runner: (t, r) => {
|
|
865
885
|
t.addNode("image", void 0, void 0, {
|
|
866
886
|
title: r.attrs.title,
|
|
@@ -871,7 +891,7 @@ const k = {
|
|
|
871
891
|
}
|
|
872
892
|
}),
|
|
873
893
|
commands: (t) => [
|
|
874
|
-
M(
|
|
894
|
+
M(De, (r = "") => (n, o) => {
|
|
875
895
|
if (!o)
|
|
876
896
|
return !0;
|
|
877
897
|
const { tr: l } = n, s = t.create({ src: r });
|
|
@@ -885,14 +905,19 @@ const k = {
|
|
|
885
905
|
if (!l)
|
|
886
906
|
return !1;
|
|
887
907
|
const { tr: s } = n;
|
|
888
|
-
return o == null || o(
|
|
908
|
+
return o == null || o(
|
|
909
|
+
s.setNodeMarkup(l.pos, void 0, { ...l.node.attrs, loading: !0, src: r }).scrollIntoView()
|
|
910
|
+
), !0;
|
|
889
911
|
})
|
|
890
912
|
],
|
|
891
913
|
inputRules: (t) => [
|
|
892
|
-
new
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
914
|
+
new xe(
|
|
915
|
+
/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,
|
|
916
|
+
(r, n, o, l) => {
|
|
917
|
+
const [s, c, i = "", u] = n, { tr: f } = r;
|
|
918
|
+
return s && f.replaceWith(o, l, t.create({ src: i, alt: c, title: u })), f;
|
|
919
|
+
}
|
|
920
|
+
)
|
|
896
921
|
],
|
|
897
922
|
view: () => (t) => {
|
|
898
923
|
var i, u;
|
|
@@ -906,7 +931,7 @@ const k = {
|
|
|
906
931
|
const { dom: s, onUpdate: c } = l;
|
|
907
932
|
return c(r), {
|
|
908
933
|
dom: s,
|
|
909
|
-
update: (f) => f.type.name !==
|
|
934
|
+
update: (f) => f.type.name !== P ? !1 : (r = f, c(r), !0),
|
|
910
935
|
selectNode: () => {
|
|
911
936
|
s.classList.add("ProseMirror-selectednode");
|
|
912
937
|
},
|
|
@@ -916,20 +941,22 @@ const k = {
|
|
|
916
941
|
};
|
|
917
942
|
},
|
|
918
943
|
prosePlugins: (t, r) => [
|
|
919
|
-
new
|
|
920
|
-
key:
|
|
944
|
+
new T({
|
|
945
|
+
key: ht,
|
|
921
946
|
view: (n) => {
|
|
922
947
|
var i, u, f;
|
|
923
948
|
const o = a.themeManager.get("input-chip", {
|
|
924
949
|
placeholder: (u = (i = e == null ? void 0 : e.input) == null ? void 0 : i.placeholder) != null ? u : "Input Image Link",
|
|
925
950
|
buttonText: (f = e == null ? void 0 : e.input) == null ? void 0 : f.buttonText,
|
|
926
951
|
onUpdate: (d) => {
|
|
927
|
-
r.get(
|
|
952
|
+
r.get(Le).call(le, d);
|
|
928
953
|
}
|
|
929
954
|
});
|
|
930
955
|
if (!o)
|
|
931
956
|
return {};
|
|
932
|
-
const l = (d) => Boolean(
|
|
957
|
+
const l = (d) => Boolean(
|
|
958
|
+
d.hasFocus() && t && K(d.state.selection, t)
|
|
959
|
+
), s = (d) => {
|
|
933
960
|
const m = K(d.state.selection, t);
|
|
934
961
|
return m ? m.node.attrs.src : void 0;
|
|
935
962
|
}, c = (d) => {
|
|
@@ -948,9 +975,9 @@ const k = {
|
|
|
948
975
|
}
|
|
949
976
|
})
|
|
950
977
|
]
|
|
951
|
-
})),
|
|
978
|
+
})), Ne = "list_item", ce = y("SplitListItem"), ie = y("SinkListItem"), ue = y("LiftListItem"), Mt = new H("MILKDOWN_KEEP_LIST_ORDER"), yt = (a) => {
|
|
952
979
|
const e = (t, r) => {
|
|
953
|
-
const n =
|
|
980
|
+
const n = We("ordered_list", t.schema);
|
|
954
981
|
let o = t.tr;
|
|
955
982
|
t.doc.descendants((l, s, c, i) => {
|
|
956
983
|
if (l.type === a && (c == null ? void 0 : c.type) === n) {
|
|
@@ -962,8 +989,8 @@ const k = {
|
|
|
962
989
|
}
|
|
963
990
|
}), r(o);
|
|
964
991
|
};
|
|
965
|
-
return new
|
|
966
|
-
key:
|
|
992
|
+
return new T({
|
|
993
|
+
key: Mt,
|
|
967
994
|
appendTransaction: (t, r, n) => {
|
|
968
995
|
let o = null;
|
|
969
996
|
return t.some((l) => l.docChanged) && e(n, (l) => {
|
|
@@ -971,8 +998,8 @@ const k = {
|
|
|
971
998
|
}), o;
|
|
972
999
|
}
|
|
973
1000
|
});
|
|
974
|
-
},
|
|
975
|
-
id:
|
|
1001
|
+
}, Nt = w((a) => ({
|
|
1002
|
+
id: Ne,
|
|
976
1003
|
schema: () => ({
|
|
977
1004
|
group: "listItem",
|
|
978
1005
|
content: "paragraph block*",
|
|
@@ -1028,26 +1055,26 @@ const k = {
|
|
|
1028
1055
|
}
|
|
1029
1056
|
},
|
|
1030
1057
|
toMarkdown: {
|
|
1031
|
-
match: (e) => e.type.name ===
|
|
1058
|
+
match: (e) => e.type.name === Ne,
|
|
1032
1059
|
runner: (e, t) => {
|
|
1033
1060
|
e.openNode("listItem", void 0, { spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
|
|
1034
1061
|
}
|
|
1035
1062
|
}
|
|
1036
1063
|
}),
|
|
1037
|
-
inputRules: (e) => [
|
|
1064
|
+
inputRules: (e) => [q(/^\s*([-+*])\s$/, e)],
|
|
1038
1065
|
commands: (e) => [
|
|
1039
|
-
M(ce, () =>
|
|
1040
|
-
M(ie, () =>
|
|
1041
|
-
M(ue, () =>
|
|
1066
|
+
M(ce, () => je(e)),
|
|
1067
|
+
M(ie, () => ze(e)),
|
|
1068
|
+
M(ue, () => Ue(e))
|
|
1042
1069
|
],
|
|
1043
1070
|
shortcuts: {
|
|
1044
1071
|
[k.NextListItem]: h(ce, "Enter"),
|
|
1045
1072
|
[k.SinkListItem]: h(ie, "Mod-]"),
|
|
1046
1073
|
[k.LiftListItem]: h(ue, "Mod-[")
|
|
1047
1074
|
},
|
|
1048
|
-
prosePlugins: (e) => [
|
|
1049
|
-
})), de = y("WrapInOrderedList"),
|
|
1050
|
-
id:
|
|
1075
|
+
prosePlugins: (e) => [yt(e)]
|
|
1076
|
+
})), de = y("WrapInOrderedList"), Ie = "ordered_list", It = w((a) => ({
|
|
1077
|
+
id: Ie,
|
|
1051
1078
|
schema: () => ({
|
|
1052
1079
|
content: "listItem+",
|
|
1053
1080
|
group: "block",
|
|
@@ -1089,26 +1116,31 @@ const k = {
|
|
|
1089
1116
|
}
|
|
1090
1117
|
},
|
|
1091
1118
|
toMarkdown: {
|
|
1092
|
-
match: (e) => e.type.name ===
|
|
1119
|
+
match: (e) => e.type.name === Ie,
|
|
1093
1120
|
runner: (e, t) => {
|
|
1094
1121
|
e.openNode("list", void 0, { ordered: !0, start: 1, spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
|
|
1095
1122
|
}
|
|
1096
1123
|
}
|
|
1097
1124
|
}),
|
|
1098
1125
|
inputRules: (e) => [
|
|
1099
|
-
|
|
1126
|
+
q(
|
|
1127
|
+
/^(\d+)\.\s$/,
|
|
1128
|
+
e,
|
|
1129
|
+
(t) => ({ order: Number(t[1]) }),
|
|
1130
|
+
(t, r) => r.childCount + r.attrs.order === Number(t[1])
|
|
1131
|
+
)
|
|
1100
1132
|
],
|
|
1101
1133
|
commands: (e) => [M(de, () => pe(e))],
|
|
1102
1134
|
shortcuts: {
|
|
1103
1135
|
[k.OrderedList]: h(de, "Mod-Alt-7")
|
|
1104
1136
|
}
|
|
1105
|
-
})), fe = y("TurnIntoText"),
|
|
1106
|
-
id:
|
|
1137
|
+
})), fe = y("TurnIntoText"), be = "paragraph", bt = w((a) => ({
|
|
1138
|
+
id: be,
|
|
1107
1139
|
schema: () => ({
|
|
1108
1140
|
content: "inline*",
|
|
1109
1141
|
group: "block",
|
|
1110
1142
|
parseDOM: [{ tag: "p" }],
|
|
1111
|
-
toDOM: (e) => ["p", { class: a.getClassName(e.attrs,
|
|
1143
|
+
toDOM: (e) => ["p", { class: a.getClassName(e.attrs, be) }, 0],
|
|
1112
1144
|
parseMarkdown: {
|
|
1113
1145
|
match: (e) => e.type === "paragraph",
|
|
1114
1146
|
runner: (e, t, r) => {
|
|
@@ -1123,18 +1155,18 @@ const k = {
|
|
|
1123
1155
|
const o = [];
|
|
1124
1156
|
t.content.forEach((l, s, c) => {
|
|
1125
1157
|
c !== t.childCount - 1 && o.push(l);
|
|
1126
|
-
}), e.next(
|
|
1158
|
+
}), e.next(R.fromArray(o));
|
|
1127
1159
|
} else
|
|
1128
1160
|
e.next(t.content);
|
|
1129
1161
|
e.closeNode();
|
|
1130
1162
|
}
|
|
1131
1163
|
}
|
|
1132
1164
|
}),
|
|
1133
|
-
commands: (e) => [M(fe, () =>
|
|
1165
|
+
commands: (e) => [M(fe, () => E(e))],
|
|
1134
1166
|
shortcuts: {
|
|
1135
1167
|
[k.Text]: h(fe, "Mod-Alt-0")
|
|
1136
1168
|
}
|
|
1137
|
-
})),
|
|
1169
|
+
})), wt = w(() => ({
|
|
1138
1170
|
id: "text",
|
|
1139
1171
|
schema: () => ({
|
|
1140
1172
|
group: "inline",
|
|
@@ -1151,22 +1183,22 @@ const k = {
|
|
|
1151
1183
|
}
|
|
1152
1184
|
}
|
|
1153
1185
|
})
|
|
1154
|
-
})),
|
|
1186
|
+
})), Lt = [
|
|
1187
|
+
lt(),
|
|
1188
|
+
bt(),
|
|
1189
|
+
it(),
|
|
1190
|
+
tt(),
|
|
1155
1191
|
at(),
|
|
1192
|
+
rt(),
|
|
1156
1193
|
It(),
|
|
1157
|
-
ct(),
|
|
1158
|
-
et(),
|
|
1159
|
-
ot(),
|
|
1160
|
-
tt(),
|
|
1161
1194
|
Nt(),
|
|
1162
|
-
yt(),
|
|
1163
|
-
mt(),
|
|
1164
1195
|
pt(),
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1196
|
+
gt(),
|
|
1197
|
+
kt(),
|
|
1198
|
+
wt()
|
|
1199
|
+
], Ct = () => {
|
|
1168
1200
|
function a(e) {
|
|
1169
|
-
|
|
1201
|
+
Ge(e, "list", (t) => {
|
|
1170
1202
|
var r;
|
|
1171
1203
|
if (t.ordered) {
|
|
1172
1204
|
const n = (r = t.start) != null ? r : 1;
|
|
@@ -1178,11 +1210,11 @@ const k = {
|
|
|
1178
1210
|
});
|
|
1179
1211
|
}
|
|
1180
1212
|
return a;
|
|
1181
|
-
},
|
|
1182
|
-
function
|
|
1213
|
+
}, xt = (a) => !!a.children, Tt = (a) => a.type === "html";
|
|
1214
|
+
function Ht(a, e) {
|
|
1183
1215
|
return t(a, 0, null)[0];
|
|
1184
1216
|
function t(r, n, o) {
|
|
1185
|
-
if (
|
|
1217
|
+
if (xt(r)) {
|
|
1186
1218
|
const l = [];
|
|
1187
1219
|
for (let s = 0, c = r.children.length; s < c; s++) {
|
|
1188
1220
|
const i = r.children[s];
|
|
@@ -1200,15 +1232,15 @@ function Tt(a, e) {
|
|
|
1200
1232
|
return e(r, n, o);
|
|
1201
1233
|
}
|
|
1202
1234
|
}
|
|
1203
|
-
const
|
|
1235
|
+
const Dt = () => {
|
|
1204
1236
|
function a(e) {
|
|
1205
|
-
|
|
1237
|
+
Ht(e, (t) => Tt(t) ? [] : [t]);
|
|
1206
1238
|
}
|
|
1207
1239
|
return a;
|
|
1208
|
-
},
|
|
1240
|
+
}, Ot = new H("MILKDOWN_INLINE_NODES_CURSOR"), St = () => {
|
|
1209
1241
|
let a = !1;
|
|
1210
|
-
const e = new
|
|
1211
|
-
key:
|
|
1242
|
+
const e = new T({
|
|
1243
|
+
key: Ot,
|
|
1212
1244
|
state: {
|
|
1213
1245
|
init() {
|
|
1214
1246
|
return !1;
|
|
@@ -1251,20 +1283,20 @@ const Ht = () => {
|
|
|
1251
1283
|
}
|
|
1252
1284
|
});
|
|
1253
1285
|
return e;
|
|
1254
|
-
}, G = /\[(?<span>((www|https:\/\/|http:\/\/)\
|
|
1286
|
+
}, G = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)/, At = (a) => new RegExp(`\\\\(?=[^\\w\\s${a}\\\\]|_)`, "g"), Et = (a) => {
|
|
1255
1287
|
let e = a, t = e.match(G);
|
|
1256
1288
|
for (; t && t.groups; ) {
|
|
1257
1289
|
const { span: r } = t.groups;
|
|
1258
1290
|
e = e.replace(G, r), t = e.match(G);
|
|
1259
1291
|
}
|
|
1260
1292
|
return e;
|
|
1261
|
-
},
|
|
1293
|
+
}, vt = (a, e, t) => {
|
|
1262
1294
|
const r = a.split(""), n = r[e];
|
|
1263
1295
|
return r[e] && r[t] && (r[e] = r[t], r[t] = n), r.join("").toString();
|
|
1264
|
-
},
|
|
1296
|
+
}, _t = (a) => (e) => e.replace(At(a), ""), $t = (a) => (e) => {
|
|
1265
1297
|
const t = e.indexOf(a.hole), r = e.charAt(t - 1), n = e.charAt(t + 1), o = /[^\w]|_/;
|
|
1266
1298
|
return n ? r && o.test(r) && o.test(n) ? a.punctuation : a.char : a.punctuation;
|
|
1267
|
-
},
|
|
1299
|
+
}, Pt = (a, e, t) => {
|
|
1268
1300
|
let r = e, n = !1;
|
|
1269
1301
|
return a.descendants((o) => {
|
|
1270
1302
|
var l;
|
|
@@ -1277,7 +1309,7 @@ const Ht = () => {
|
|
|
1277
1309
|
}
|
|
1278
1310
|
r += o.nodeSize;
|
|
1279
1311
|
}), r;
|
|
1280
|
-
},
|
|
1312
|
+
}, Bt = {
|
|
1281
1313
|
placeholderConfig: {
|
|
1282
1314
|
hole: "\u2205",
|
|
1283
1315
|
punctuation: "\u2042",
|
|
@@ -1289,44 +1321,44 @@ const Ht = () => {
|
|
|
1289
1321
|
const t = ["*", "_"];
|
|
1290
1322
|
let r = e.indexOf(a);
|
|
1291
1323
|
for (; t.includes(e[r - 1] || "") && t.includes(e[r + 1] || ""); )
|
|
1292
|
-
e =
|
|
1324
|
+
e = vt(e, r, r + 1), r = r + 1;
|
|
1293
1325
|
return e;
|
|
1294
1326
|
}
|
|
1295
|
-
},
|
|
1327
|
+
}, v = ve(Bt, "inlineSyncConfig"), Rt = (a) => {
|
|
1296
1328
|
const { selection: e } = a, { $from: t } = e;
|
|
1297
1329
|
return t.node();
|
|
1298
|
-
},
|
|
1299
|
-
const n = a.get(
|
|
1330
|
+
}, Wt = (a, e, t, r) => {
|
|
1331
|
+
const n = a.get(_e), o = e.schema.topNodeType.create(void 0, [t, ...r]);
|
|
1300
1332
|
return n(o);
|
|
1301
|
-
},
|
|
1302
|
-
const t = a.get(
|
|
1333
|
+
}, qt = (a, e) => {
|
|
1334
|
+
const t = a.get(v), r = t.placeholderConfig.hole, [n = "", ...o] = e.split(`
|
|
1303
1335
|
|
|
1304
1336
|
`), l = (u) => t.movePlaceholder(r, u);
|
|
1305
|
-
let c =
|
|
1306
|
-
const i =
|
|
1337
|
+
let c = Se(_t(r), l, Et)(n);
|
|
1338
|
+
const i = $t(t.placeholderConfig)(c);
|
|
1307
1339
|
return c = c.replace(r, i), c = [c, ...o].join(`
|
|
1308
1340
|
|
|
1309
1341
|
`), [c, i];
|
|
1310
|
-
}, qt = (a, e) => {
|
|
1311
|
-
const r = a.get(_e)(e);
|
|
1312
|
-
return r ? r.firstChild : null;
|
|
1313
1342
|
}, Kt = (a, e) => {
|
|
1314
|
-
const
|
|
1343
|
+
const r = a.get($e)(e);
|
|
1344
|
+
return r ? r.firstChild : null;
|
|
1345
|
+
}, Ft = (a, e) => {
|
|
1346
|
+
const { globalNodes: t } = a.get(v), r = [];
|
|
1315
1347
|
return e.doc.descendants((n) => {
|
|
1316
1348
|
if (t.includes(n.type.name) || t.includes(n.type))
|
|
1317
1349
|
return r.push(n), !1;
|
|
1318
1350
|
}), r;
|
|
1319
|
-
},
|
|
1351
|
+
}, jt = (a) => a.split(`
|
|
1320
1352
|
|
|
1321
|
-
`)[0] || "",
|
|
1353
|
+
`)[0] || "", Oe = (a, e) => {
|
|
1322
1354
|
try {
|
|
1323
|
-
const t =
|
|
1355
|
+
const t = Ft(a, e), r = Rt(e), n = Wt(a, e, r, t), [o, l] = qt(a, n), s = Kt(a, o);
|
|
1324
1356
|
return !s || r.type !== s.type ? null : (s.attrs = { ...r.attrs }, s.descendants((c) => {
|
|
1325
1357
|
var f;
|
|
1326
1358
|
const u = c.marks.find((d) => d.type.name === "link");
|
|
1327
1359
|
u && ((f = c.text) == null ? void 0 : f.includes(l)) && u.attrs.href.includes(l) && (u.attrs.href = u.attrs.href.replace(l, ""));
|
|
1328
1360
|
}), {
|
|
1329
|
-
text:
|
|
1361
|
+
text: jt(o),
|
|
1330
1362
|
prevNode: r,
|
|
1331
1363
|
nextNode: s,
|
|
1332
1364
|
placeholder: l
|
|
@@ -1334,17 +1366,17 @@ const Ht = () => {
|
|
|
1334
1366
|
} catch {
|
|
1335
1367
|
return null;
|
|
1336
1368
|
}
|
|
1337
|
-
},
|
|
1338
|
-
const { placeholderConfig: o } = a.get(
|
|
1369
|
+
}, zt = (a, e, t, r, n) => {
|
|
1370
|
+
const { placeholderConfig: o } = a.get(v), l = o.hole;
|
|
1339
1371
|
let s = t.tr.setMeta(e, !0).insertText(l, t.selection.from);
|
|
1340
|
-
const c = t.apply(s), i =
|
|
1372
|
+
const c = t.apply(s), i = Oe(a, c);
|
|
1341
1373
|
if (!i)
|
|
1342
1374
|
return;
|
|
1343
|
-
const { $from: u } = c.selection, f = u.before(), d = u.after(), m =
|
|
1375
|
+
const { $from: u } = c.selection, f = u.before(), d = u.after(), m = Pt(i.nextNode, f, i.placeholder);
|
|
1344
1376
|
s = s.replaceWith(f, d, i.nextNode).setNodeMarkup(f, void 0, n).delete(m + 1, m + 2), s = s.setSelection(J.near(s.doc.resolve(m + 1))), r(s);
|
|
1345
|
-
}, Y = new
|
|
1377
|
+
}, Y = new H("MILKDOWN_INLINE_SYNC"), Ut = (a) => {
|
|
1346
1378
|
let e = null;
|
|
1347
|
-
return new
|
|
1379
|
+
return new T({
|
|
1348
1380
|
key: Y,
|
|
1349
1381
|
state: {
|
|
1350
1382
|
init: () => null,
|
|
@@ -1353,29 +1385,29 @@ const Ht = () => {
|
|
|
1353
1385
|
const s = a.get(S);
|
|
1354
1386
|
if (!((p = s.hasFocus) != null && p.call(s)) || !s.editable || !r.docChanged || r.getMeta(Y))
|
|
1355
1387
|
return null;
|
|
1356
|
-
const i =
|
|
1388
|
+
const i = Oe(a, l);
|
|
1357
1389
|
if (!i)
|
|
1358
1390
|
return null;
|
|
1359
1391
|
e && (cancelAnimationFrame(e), e = null);
|
|
1360
|
-
const { prevNode: u, nextNode: f, text: d } = i, { shouldSyncNode: m } = a.get(
|
|
1392
|
+
const { prevNode: u, nextNode: f, text: d } = i, { shouldSyncNode: m } = a.get(v);
|
|
1361
1393
|
return m({ prevNode: u, nextNode: f, ctx: a, tr: r, text: d }) && (e = requestAnimationFrame(() => {
|
|
1362
1394
|
e = null;
|
|
1363
1395
|
const { dispatch: g, state: N } = a.get(S);
|
|
1364
|
-
|
|
1396
|
+
zt(a, Y, N, g, u.attrs);
|
|
1365
1397
|
})), null;
|
|
1366
1398
|
}
|
|
1367
1399
|
}
|
|
1368
1400
|
});
|
|
1369
|
-
},
|
|
1370
|
-
|
|
1371
|
-
injectSlices: [
|
|
1372
|
-
prosePlugins: (a, e) => [
|
|
1373
|
-
remarkPlugins: () => [
|
|
1401
|
+
}, Vt = [
|
|
1402
|
+
Ae(() => ({
|
|
1403
|
+
injectSlices: [v],
|
|
1404
|
+
prosePlugins: (a, e) => [St(), Ut(e)],
|
|
1405
|
+
remarkPlugins: () => [Ve, Dt, Ct]
|
|
1374
1406
|
}))()
|
|
1375
|
-
],
|
|
1407
|
+
], Gt = we.create([...Lt, ...et]), cr = we.create([...Vt, ...Gt]), ir = {
|
|
1376
1408
|
ToggleInlineCode: Z,
|
|
1377
1409
|
ToggleItalic: ee,
|
|
1378
|
-
ToggleLink:
|
|
1410
|
+
ToggleLink: Te,
|
|
1379
1411
|
ToggleBold: re,
|
|
1380
1412
|
ModifyLink: te,
|
|
1381
1413
|
ModifyImage: le,
|
|
@@ -1386,18 +1418,18 @@ const Ht = () => {
|
|
|
1386
1418
|
TurnIntoHeading: D,
|
|
1387
1419
|
TurnIntoText: fe,
|
|
1388
1420
|
InsertHardbreak: ae,
|
|
1389
|
-
InsertHr:
|
|
1390
|
-
InsertImage:
|
|
1421
|
+
InsertHr: He,
|
|
1422
|
+
InsertImage: De,
|
|
1391
1423
|
SplitListItem: ce,
|
|
1392
1424
|
SinkListItem: ie,
|
|
1393
1425
|
LiftListItem: ue
|
|
1394
1426
|
};
|
|
1395
1427
|
export {
|
|
1396
|
-
|
|
1397
|
-
|
|
1428
|
+
ye as DowngradeHeading,
|
|
1429
|
+
ct as HardbreakFilterPluginKey,
|
|
1398
1430
|
ae as InsertHardbreak,
|
|
1399
|
-
|
|
1400
|
-
|
|
1431
|
+
He as InsertHr,
|
|
1432
|
+
De as InsertImage,
|
|
1401
1433
|
ue as LiftListItem,
|
|
1402
1434
|
le as ModifyImage,
|
|
1403
1435
|
te as ModifyLink,
|
|
@@ -1407,39 +1439,39 @@ export {
|
|
|
1407
1439
|
re as ToggleBold,
|
|
1408
1440
|
Z as ToggleInlineCode,
|
|
1409
1441
|
ee as ToggleItalic,
|
|
1410
|
-
|
|
1442
|
+
Te as ToggleLink,
|
|
1411
1443
|
oe as TurnIntoCodeFence,
|
|
1412
1444
|
D as TurnIntoHeading,
|
|
1413
1445
|
fe as TurnIntoText,
|
|
1414
1446
|
ne as WrapInBlockquote,
|
|
1415
1447
|
se as WrapInBulletList,
|
|
1416
1448
|
de as WrapInOrderedList,
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1449
|
+
st as backtickInputRegex,
|
|
1450
|
+
tt as blockquote,
|
|
1451
|
+
rt as bulletList,
|
|
1452
|
+
at as codeFence,
|
|
1453
|
+
Ye as codeInline,
|
|
1454
|
+
ir as commands,
|
|
1455
|
+
cr as commonmark,
|
|
1456
|
+
Gt as commonmarkNodes,
|
|
1457
|
+
Vt as commonmarkPlugins,
|
|
1458
|
+
lt as doc,
|
|
1459
|
+
Je as em,
|
|
1460
|
+
it as hardbreak,
|
|
1461
|
+
pt as heading,
|
|
1462
|
+
ut as headingHashPluginKey,
|
|
1431
1463
|
U as headingIdPluginKey,
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1464
|
+
gt as hr,
|
|
1465
|
+
kt as image,
|
|
1466
|
+
v as inlineSyncConfigCtx,
|
|
1467
|
+
Xe as link,
|
|
1468
|
+
Nt as listItem,
|
|
1469
|
+
et as marks,
|
|
1470
|
+
Lt as nodes,
|
|
1471
|
+
It as orderedList,
|
|
1472
|
+
bt as paragraph,
|
|
1473
|
+
Ze as strong,
|
|
1474
|
+
wt as text,
|
|
1475
|
+
ot as tildeInputRegex
|
|
1444
1476
|
};
|
|
1445
1477
|
//# sourceMappingURL=index.es.js.map
|