@milkdown/preset-commonmark 7.0.0-next.4 → 7.0.0-next.5
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 +160 -134
- package/lib/index.es.js.map +1 -1
- package/lib/plugin/index.d.ts +1 -0
- package/lib/plugin/index.d.ts.map +1 -1
- package/lib/plugin/remark-html-filter.d.ts +2 -0
- package/lib/plugin/remark-html-filter.d.ts.map +1 -0
- package/package.json +6 -6
- package/src/composed/plugins.ts +2 -1
- package/src/plugin/index.ts +1 -0
- package/src/plugin/remark-html-filter.ts +43 -0
package/lib/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $markAttr as
|
|
2
|
-
import { commandsCtx as
|
|
1
|
+
import { $markAttr as _, $markSchema as K, $command as m, $useKeymap as h, $node as X, $nodeAttr as k, $nodeSchema as y, $ctx as W, $inputRule as I, pipe as Be, $prose as w, $remark as $ } from "@milkdown/utils";
|
|
2
|
+
import { commandsCtx as p, editorViewCtx as P, serializerCtx as Re, parserCtx as Pe } from "@milkdown/core";
|
|
3
3
|
import { toggleMark as q, setBlockType as S, wrapIn as F } from "@milkdown/prose/commands";
|
|
4
4
|
import { Fragment as Z } from "@milkdown/prose/model";
|
|
5
5
|
import { expectDomTypeError as b } from "@milkdown/exception";
|
|
@@ -7,11 +7,11 @@ import { textblockTypeInputRule as ee, wrappingInputRule as V, InputRule as te }
|
|
|
7
7
|
import { TextSelection as re, Selection as ne, PluginKey as N, Plugin as C } from "@milkdown/prose/state";
|
|
8
8
|
import { findSelectedNodeOfType as We } from "@milkdown/prose";
|
|
9
9
|
import { sinkListItem as qe, liftListItem as Fe, splitListItem as Ve } from "@milkdown/prose/schema-list";
|
|
10
|
-
import { ReplaceStep as Ge, AddMarkStep as
|
|
10
|
+
import { ReplaceStep as Ge, AddMarkStep as je } from "@milkdown/prose/transform";
|
|
11
11
|
import { Decoration as J, DecorationSet as Q } from "@milkdown/prose/view";
|
|
12
12
|
import { visit as oe } from "unist-util-visit";
|
|
13
|
-
import
|
|
14
|
-
const ae =
|
|
13
|
+
import ze from "remark-inline-links";
|
|
14
|
+
const ae = _("emphasis"), se = K("emphasis", (r) => ({
|
|
15
15
|
inclusive: !1,
|
|
16
16
|
parseDOM: [
|
|
17
17
|
{ tag: "i" },
|
|
@@ -31,15 +31,15 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
31
31
|
e.withMark(t, "emphasis");
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
})), le =
|
|
34
|
+
})), le = m("ToggleEmphasis", () => () => q(se.type())), Ue = h("emphasisKeymap", {
|
|
35
35
|
ToggleEmphasis: {
|
|
36
36
|
shortcuts: "Mod-i",
|
|
37
37
|
command: (r) => {
|
|
38
|
-
const e = r.get(
|
|
38
|
+
const e = r.get(p);
|
|
39
39
|
return () => e.call(le.key);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
}), ce =
|
|
42
|
+
}), ce = _("strong"), ie = K("strong", (r) => ({
|
|
43
43
|
inclusive: !1,
|
|
44
44
|
parseDOM: [
|
|
45
45
|
{ tag: "b" },
|
|
@@ -59,15 +59,15 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
59
59
|
e.withMark(t, "strong");
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
})), de =
|
|
62
|
+
})), de = m("ToggleStrong", () => () => q(ie.type())), Ye = h("strongKeymap", {
|
|
63
63
|
ToggleBold: {
|
|
64
64
|
shortcuts: ["Mod-b"],
|
|
65
65
|
command: (r) => {
|
|
66
|
-
const e = r.get(
|
|
66
|
+
const e = r.get(p);
|
|
67
67
|
return () => e.call(de.key);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
}), ue =
|
|
70
|
+
}), ue = _("inlineCode"), A = K("inlineCode", (r) => ({
|
|
71
71
|
priority: 100,
|
|
72
72
|
code: !0,
|
|
73
73
|
inclusive: !1,
|
|
@@ -85,7 +85,7 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
85
85
|
e.withMark(t, "inlineCode", n.text || "");
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
})),
|
|
88
|
+
})), me = m("ToggleInlineCode", () => () => (r, e) => {
|
|
89
89
|
const { selection: t, tr: n } = r;
|
|
90
90
|
if (t.empty)
|
|
91
91
|
return !1;
|
|
@@ -93,15 +93,15 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
93
93
|
return r.doc.rangeHasMark(o, a, A.type()) ? (e == null || e(n.removeMark(o, a, A.type())), !0) : (Object.keys(r.schema.marks).filter((c) => c !== A.type.name).map((c) => r.schema.marks[c]).forEach((c) => {
|
|
94
94
|
n.removeMark(o, a, c);
|
|
95
95
|
}), e == null || e(n.addMark(o, a, A.type().create())), !0);
|
|
96
|
-
}), Je =
|
|
96
|
+
}), Je = h("inlineCodeKeymap", {
|
|
97
97
|
ToggleInlineCode: {
|
|
98
98
|
shortcuts: "Mod-e",
|
|
99
99
|
command: (r) => {
|
|
100
|
-
const e = r.get(
|
|
101
|
-
return () => e.call(
|
|
100
|
+
const e = r.get(p);
|
|
101
|
+
return () => e.call(me.key);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
}),
|
|
104
|
+
}), pe = _("link"), v = K("link", (r) => ({
|
|
105
105
|
attrs: {
|
|
106
106
|
href: {},
|
|
107
107
|
title: { default: null }
|
|
@@ -116,7 +116,7 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
],
|
|
119
|
-
toDOM: (e) => ["a", { ...r.get(
|
|
119
|
+
toDOM: (e) => ["a", { ...r.get(pe.key)(e), ...e.attrs }],
|
|
120
120
|
parseMarkdown: {
|
|
121
121
|
match: (e) => e.type === "link",
|
|
122
122
|
runner: (e, t, n) => {
|
|
@@ -133,22 +133,22 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
})), Qe =
|
|
136
|
+
})), Qe = m("ToggleLink", () => (r = {}) => q(v.type(), r)), Xe = m("UpdateLink", () => (r = {}) => (e, t) => {
|
|
137
137
|
if (!t)
|
|
138
138
|
return !1;
|
|
139
139
|
let n, o = -1;
|
|
140
140
|
const { selection: a } = e, { from: s, to: l } = a;
|
|
141
|
-
if (e.doc.nodesBetween(s, s === l ? l + 1 : l, (
|
|
142
|
-
if (v.type().isInSet(
|
|
143
|
-
return n =
|
|
141
|
+
if (e.doc.nodesBetween(s, s === l ? l + 1 : l, (f, H) => {
|
|
142
|
+
if (v.type().isInSet(f.marks))
|
|
143
|
+
return n = f, o = H, !1;
|
|
144
144
|
}), !n)
|
|
145
145
|
return !1;
|
|
146
|
-
const c = n.marks.find(({ type:
|
|
146
|
+
const c = n.marks.find(({ type: f }) => f === v.type());
|
|
147
147
|
if (!c)
|
|
148
148
|
return !1;
|
|
149
|
-
const i = o, d = o + n.nodeSize, { tr:
|
|
149
|
+
const i = o, d = o + n.nodeSize, { tr: u } = e, g = v.type().create({ ...c.attrs, ...r });
|
|
150
150
|
return g ? (t(
|
|
151
|
-
|
|
151
|
+
u.removeMark(i, d, c).addMark(i, d, g).setSelection(new re(u.selection.$anchor)).scrollIntoView()
|
|
152
152
|
), !0) : !1;
|
|
153
153
|
}), Ze = X("doc", () => ({
|
|
154
154
|
content: "block+",
|
|
@@ -189,15 +189,15 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
189
189
|
e.closeNode();
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
})), fe =
|
|
192
|
+
})), fe = m("TurnIntoText", () => () => S(L.type())), et = h("paragraphKeymap", {
|
|
193
193
|
TurnIntoText: {
|
|
194
194
|
shortcuts: "Mod-Alt-0",
|
|
195
195
|
command: (r) => {
|
|
196
|
-
const e = r.get(
|
|
196
|
+
const e = r.get(p);
|
|
197
197
|
return () => e.call(fe.key);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
}), tt = Array(6).fill(0).map((r, e) => e + 1), rt = (r) => r.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "-").toLowerCase().trim(), G =
|
|
200
|
+
}), tt = Array(6).fill(0).map((r, e) => e + 1), rt = (r) => r.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "-").toLowerCase().trim(), G = W(rt, "headingIdGenerator"), he = k("heading"), T = y("heading", (r) => {
|
|
201
201
|
const e = r.get(G.key);
|
|
202
202
|
return {
|
|
203
203
|
content: "inline*",
|
|
@@ -251,13 +251,13 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
251
251
|
};
|
|
252
252
|
}), nt = I((r) => ee(/^(?<hashes>#+)\s$/, T.type(), (e) => {
|
|
253
253
|
var s, l;
|
|
254
|
-
const t = ((l = (s = e.groups) == null ? void 0 : s.hashes) == null ? void 0 : l.length) || 0, n = r.get(
|
|
254
|
+
const t = ((l = (s = e.groups) == null ? void 0 : s.hashes) == null ? void 0 : l.length) || 0, n = r.get(P), { $from: o } = n.state.selection, a = o.node();
|
|
255
255
|
if (a.type.name === "heading") {
|
|
256
256
|
let c = Number(a.attrs.level) + Number(t);
|
|
257
257
|
return c > 6 && (c = 6), { level: c };
|
|
258
258
|
}
|
|
259
259
|
return { level: t };
|
|
260
|
-
})), M =
|
|
260
|
+
})), M = m("WrapInHeading", () => (r) => (r ?? (r = 1), r < 1 ? S(L.type()) : S(T.type(), { level: r }))), ke = m("DowngradeHeading", () => () => (r, e, t) => {
|
|
261
261
|
const { $from: n } = r.selection, o = n.node();
|
|
262
262
|
if (o.type !== T.type() || !r.selection.empty || n.parentOffset !== 0)
|
|
263
263
|
return !1;
|
|
@@ -268,57 +268,57 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
268
268
|
level: a
|
|
269
269
|
})
|
|
270
270
|
), !0) : S(L.type())(r, e, t);
|
|
271
|
-
}), ot =
|
|
271
|
+
}), ot = h("headingKeymap", {
|
|
272
272
|
TurnIntoH1: {
|
|
273
273
|
shortcuts: "Mod-Alt-1",
|
|
274
274
|
command: (r) => {
|
|
275
|
-
const e = r.get(
|
|
275
|
+
const e = r.get(p);
|
|
276
276
|
return () => e.call(M.key, 1);
|
|
277
277
|
}
|
|
278
278
|
},
|
|
279
279
|
TurnIntoH2: {
|
|
280
280
|
shortcuts: "Mod-Alt-2",
|
|
281
281
|
command: (r) => {
|
|
282
|
-
const e = r.get(
|
|
282
|
+
const e = r.get(p);
|
|
283
283
|
return () => e.call(M.key, 2);
|
|
284
284
|
}
|
|
285
285
|
},
|
|
286
286
|
TurnIntoH3: {
|
|
287
287
|
shortcuts: "Mod-Alt-3",
|
|
288
288
|
command: (r) => {
|
|
289
|
-
const e = r.get(
|
|
289
|
+
const e = r.get(p);
|
|
290
290
|
return () => e.call(M.key, 3);
|
|
291
291
|
}
|
|
292
292
|
},
|
|
293
293
|
TurnIntoH4: {
|
|
294
294
|
shortcuts: "Mod-Alt-4",
|
|
295
295
|
command: (r) => {
|
|
296
|
-
const e = r.get(
|
|
296
|
+
const e = r.get(p);
|
|
297
297
|
return () => e.call(M.key, 3);
|
|
298
298
|
}
|
|
299
299
|
},
|
|
300
300
|
TurnIntoH5: {
|
|
301
301
|
shortcuts: "Mod-Alt-5",
|
|
302
302
|
command: (r) => {
|
|
303
|
-
const e = r.get(
|
|
303
|
+
const e = r.get(p);
|
|
304
304
|
return () => e.call(M.key, 3);
|
|
305
305
|
}
|
|
306
306
|
},
|
|
307
307
|
TurnIntoH6: {
|
|
308
308
|
shortcuts: "Mod-Alt-6",
|
|
309
309
|
command: (r) => {
|
|
310
|
-
const e = r.get(
|
|
310
|
+
const e = r.get(p);
|
|
311
311
|
return () => e.call(M.key, 3);
|
|
312
312
|
}
|
|
313
313
|
},
|
|
314
314
|
DowngradeHeading: {
|
|
315
315
|
shortcuts: ["Delete", "Backspace"],
|
|
316
316
|
command: (r) => {
|
|
317
|
-
const e = r.get(
|
|
317
|
+
const e = r.get(p);
|
|
318
318
|
return () => e.call(ke.key);
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
}), ye = k("blockquote"),
|
|
321
|
+
}), ye = k("blockquote"), j = y("blockquote", (r) => ({
|
|
322
322
|
content: "block+",
|
|
323
323
|
group: "block",
|
|
324
324
|
defining: !0,
|
|
@@ -336,18 +336,18 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
336
336
|
e.openNode("blockquote").next(t.content).closeNode();
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
})), at = I(() => V(/^\s*>\s$/,
|
|
339
|
+
})), at = I(() => V(/^\s*>\s$/, j.type())), Me = m("WrapInBlockquote", () => () => F(j.type())), st = h("blockquoteKeymap", {
|
|
340
340
|
WrapInBlockquote: {
|
|
341
341
|
shortcuts: "Mod-Shift-b",
|
|
342
342
|
command: (r) => {
|
|
343
|
-
const e = r.get(
|
|
343
|
+
const e = r.get(p);
|
|
344
344
|
return () => e.call(Me.key);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
}), Ie = k("codeBlock", () => ({
|
|
348
348
|
pre: {},
|
|
349
349
|
code: {}
|
|
350
|
-
})),
|
|
350
|
+
})), z = y("code_block", (r) => ({
|
|
351
351
|
content: "text*",
|
|
352
352
|
group: "block",
|
|
353
353
|
marks: "",
|
|
@@ -396,20 +396,20 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
|
-
})), lt = I(() => ee(/^```(?<language>[a-z]*)?[\s\n]$/,
|
|
399
|
+
})), lt = I(() => ee(/^```(?<language>[a-z]*)?[\s\n]$/, z.type(), (r) => {
|
|
400
400
|
var e;
|
|
401
401
|
return {
|
|
402
402
|
language: ((e = r.groups) == null ? void 0 : e.language) ?? ""
|
|
403
403
|
};
|
|
404
|
-
})), be =
|
|
404
|
+
})), be = m("CreateCodeBlock", () => (r = "") => S(z.type(), { language: r })), ur = m("UpdateCodeBlockLanguage", () => ({ pos: r, language: e } = { pos: -1, language: "" }) => (t, n) => r >= 0 ? (n == null || n(t.tr.setNodeAttribute(r, "language", e)), !0) : !1), ct = h("codeBlockKeymap", {
|
|
405
405
|
CreateCodeBlock: {
|
|
406
406
|
shortcuts: "Mod-Alt-c",
|
|
407
407
|
command: (r) => {
|
|
408
|
-
const e = r.get(
|
|
408
|
+
const e = r.get(p);
|
|
409
409
|
return () => e.call(be.key);
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
}), we = k("image"),
|
|
412
|
+
}), we = k("image"), E = y("image", (r) => ({
|
|
413
413
|
inline: !0,
|
|
414
414
|
group: "inline",
|
|
415
415
|
selectable: !0,
|
|
@@ -459,22 +459,22 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
459
459
|
});
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
|
-
})), it =
|
|
462
|
+
})), it = m("InsertImage", () => (r = {}) => (e, t) => {
|
|
463
463
|
if (!t)
|
|
464
464
|
return !0;
|
|
465
|
-
const { src: n = "", alt: o = "", title: a = "" } = r, s =
|
|
465
|
+
const { src: n = "", alt: o = "", title: a = "" } = r, s = E.type().create({ src: n, alt: o, title: a });
|
|
466
466
|
return s && t(e.tr.replaceSelectionWith(s).scrollIntoView()), !0;
|
|
467
|
-
}), dt =
|
|
468
|
-
const n = We(e.selection,
|
|
467
|
+
}), dt = m("UpdateImage", () => (r = {}) => (e, t) => {
|
|
468
|
+
const n = We(e.selection, E.type());
|
|
469
469
|
if (!n)
|
|
470
470
|
return !1;
|
|
471
471
|
const { node: o, pos: a } = n, s = { ...o.attrs }, { src: l, alt: c, title: i } = r;
|
|
472
472
|
return l !== void 0 && (s.src = l), c !== void 0 && (s.alt = c), i !== void 0 && (s.title = i), t == null || t(e.tr.setNodeMarkup(a, void 0, s).scrollIntoView()), !0;
|
|
473
|
-
}),
|
|
473
|
+
}), mr = I(() => new te(
|
|
474
474
|
/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,
|
|
475
475
|
(r, e, t, n) => {
|
|
476
476
|
const [o, a, s = "", l] = e;
|
|
477
|
-
return o ? r.tr.replaceWith(t, n,
|
|
477
|
+
return o ? r.tr.replaceWith(t, n, E.type().create({ src: s, alt: a, title: l })) : null;
|
|
478
478
|
}
|
|
479
479
|
)), Ne = k("hardbreak", (r) => ({
|
|
480
480
|
"data-is-inline": r.attrs.isInline
|
|
@@ -503,7 +503,7 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
503
503
|
`) : e.addNode("break");
|
|
504
504
|
}
|
|
505
505
|
}
|
|
506
|
-
})), Ce =
|
|
506
|
+
})), Ce = m("InsertHardbreak", () => () => (r, e) => {
|
|
507
507
|
var o;
|
|
508
508
|
const { selection: t, tr: n } = r;
|
|
509
509
|
if (t.empty) {
|
|
@@ -514,11 +514,11 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
514
514
|
), !0;
|
|
515
515
|
}
|
|
516
516
|
return e == null || e(n.setMeta("hardbreak", !0).replaceSelectionWith(x.type().create()).scrollIntoView()), !0;
|
|
517
|
-
}), ut =
|
|
517
|
+
}), ut = h("hardbreakKeymap", {
|
|
518
518
|
InsertHardbreak: {
|
|
519
519
|
shortcuts: "Shift-Enter",
|
|
520
520
|
command: (r) => {
|
|
521
|
-
const e = r.get(
|
|
521
|
+
const e = r.get(p);
|
|
522
522
|
return () => e.call(Ce.key);
|
|
523
523
|
}
|
|
524
524
|
}
|
|
@@ -538,13 +538,13 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
538
538
|
e.addNode("thematicBreak");
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
|
-
})),
|
|
541
|
+
})), mt = I(() => new te(
|
|
542
542
|
/^(?:---|___\s|\*\*\*\s)$/,
|
|
543
543
|
(r, e, t, n) => {
|
|
544
544
|
const { tr: o } = r;
|
|
545
545
|
return e[0] && o.replaceWith(t - 1, n, U.type().create()), o;
|
|
546
546
|
}
|
|
547
|
-
)),
|
|
547
|
+
)), pt = m("InsertHr", () => () => (r, e) => {
|
|
548
548
|
if (!e)
|
|
549
549
|
return !0;
|
|
550
550
|
const t = L.node.type().create(), { tr: n, selection: o } = r, { from: a } = o, s = U.type().create();
|
|
@@ -593,15 +593,15 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
593
593
|
e.openNode("list", void 0, { ordered: !1, spread: t.attrs.spread === "true" }).next(t.content).closeNode();
|
|
594
594
|
}
|
|
595
595
|
}
|
|
596
|
-
})), gt = I(() => V(/^\s*([-+*])\s$/, Y.type())), xe =
|
|
596
|
+
})), gt = I(() => V(/^\s*([-+*])\s$/, Y.type())), xe = m("WrapInBulletList", () => () => F(Y.type())), ft = h("bulletListKeymap", {
|
|
597
597
|
WrapInBulletList: {
|
|
598
598
|
shortcuts: "Mod-Alt-8",
|
|
599
599
|
command: (r) => {
|
|
600
|
-
const e = r.get(
|
|
600
|
+
const e = r.get(p);
|
|
601
601
|
return () => e.call(xe.key);
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
|
-
}), Se = k("orderedList"),
|
|
604
|
+
}), Se = k("orderedList"), B = y("ordered_list", (r) => ({
|
|
605
605
|
content: "listItem+",
|
|
606
606
|
group: "block",
|
|
607
607
|
attrs: {
|
|
@@ -649,14 +649,14 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
649
649
|
}
|
|
650
650
|
})), ht = I(() => V(
|
|
651
651
|
/^\s*(\d+)\.\s$/,
|
|
652
|
-
|
|
652
|
+
B.type(),
|
|
653
653
|
(r) => ({ order: Number(r[1]) }),
|
|
654
654
|
(r, e) => e.childCount + e.attrs.order === Number(r[1])
|
|
655
|
-
)), Le =
|
|
655
|
+
)), Le = m("WrapInOrderedList", () => () => F(B.type())), kt = h("orderedListKeymap", {
|
|
656
656
|
WrapInOrderedList: {
|
|
657
657
|
shortcuts: "Mod-Alt-7",
|
|
658
658
|
command: (r) => {
|
|
659
|
-
const e = r.get(
|
|
659
|
+
const e = r.get(p);
|
|
660
660
|
return () => e.call(Le.key);
|
|
661
661
|
}
|
|
662
662
|
}
|
|
@@ -712,25 +712,25 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
712
712
|
e.openNode("listItem", void 0, { spread: t.attrs.spread === "true" }), e.next(t.content), e.closeNode();
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
|
-
})), De =
|
|
715
|
+
})), De = m("SinkListItem", () => () => qe(D.type())), Oe = m("SplitListItem", () => () => Fe(D.type())), He = m("SplitListItem", () => () => Ve(D.type())), yt = h("listItemKeymap", {
|
|
716
716
|
NextListItem: {
|
|
717
717
|
shortcuts: "Enter",
|
|
718
718
|
command: (r) => {
|
|
719
|
-
const e = r.get(
|
|
720
|
-
return () => e.call(
|
|
719
|
+
const e = r.get(p);
|
|
720
|
+
return () => e.call(He.key);
|
|
721
721
|
}
|
|
722
722
|
},
|
|
723
723
|
SinkListItem: {
|
|
724
724
|
shortcuts: ["Tab", "Mod-]"],
|
|
725
725
|
command: (r) => {
|
|
726
|
-
const e = r.get(
|
|
726
|
+
const e = r.get(p);
|
|
727
727
|
return () => e.call(De.key);
|
|
728
728
|
}
|
|
729
729
|
},
|
|
730
730
|
LiftListItem: {
|
|
731
731
|
shortcuts: ["Shift-Tab", "Mod-["],
|
|
732
732
|
command: (r) => {
|
|
733
|
-
const e = r.get(
|
|
733
|
+
const e = r.get(p);
|
|
734
734
|
return () => e.call(Oe.key);
|
|
735
735
|
}
|
|
736
736
|
}
|
|
@@ -758,17 +758,17 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
758
758
|
Ne,
|
|
759
759
|
x,
|
|
760
760
|
ye,
|
|
761
|
-
z,
|
|
762
|
-
Ie,
|
|
763
761
|
j,
|
|
762
|
+
Ie,
|
|
763
|
+
z,
|
|
764
764
|
Ae,
|
|
765
765
|
U,
|
|
766
766
|
we,
|
|
767
|
-
|
|
767
|
+
E,
|
|
768
768
|
ve,
|
|
769
769
|
Y,
|
|
770
770
|
Se,
|
|
771
|
-
|
|
771
|
+
B,
|
|
772
772
|
Te,
|
|
773
773
|
D,
|
|
774
774
|
ae,
|
|
@@ -777,7 +777,7 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
777
777
|
ie,
|
|
778
778
|
ue,
|
|
779
779
|
A,
|
|
780
|
-
|
|
780
|
+
pe,
|
|
781
781
|
v,
|
|
782
782
|
Mt
|
|
783
783
|
].flat(), bt = [
|
|
@@ -785,7 +785,7 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
785
785
|
gt,
|
|
786
786
|
ht,
|
|
787
787
|
lt,
|
|
788
|
-
|
|
788
|
+
mt,
|
|
789
789
|
nt
|
|
790
790
|
].flat(), wt = [
|
|
791
791
|
fe,
|
|
@@ -794,16 +794,16 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
794
794
|
ke,
|
|
795
795
|
be,
|
|
796
796
|
Ce,
|
|
797
|
-
|
|
797
|
+
pt,
|
|
798
798
|
it,
|
|
799
799
|
dt,
|
|
800
800
|
Le,
|
|
801
801
|
xe,
|
|
802
802
|
De,
|
|
803
|
-
|
|
803
|
+
He,
|
|
804
804
|
Oe,
|
|
805
805
|
le,
|
|
806
|
-
|
|
806
|
+
me,
|
|
807
807
|
de,
|
|
808
808
|
Qe,
|
|
809
809
|
Xe
|
|
@@ -819,11 +819,11 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
819
819
|
Ue,
|
|
820
820
|
Je,
|
|
821
821
|
Ye
|
|
822
|
-
].flat(),
|
|
823
|
-
let e = r, t = e.match(
|
|
822
|
+
].flat(), R = /\[(?<span>((www|https:\/\/|http:\/\/)[^\s\]]+))]\((?<url>[^\s\]]+)\)/, Ct = (r) => new RegExp(`\\\\(?=[^\\w\\s${r}\\\\]|_)`, "g"), At = (r) => {
|
|
823
|
+
let e = r, t = e.match(R);
|
|
824
824
|
for (; t && t.groups; ) {
|
|
825
825
|
const { span: n } = t.groups;
|
|
826
|
-
e = e.replace(
|
|
826
|
+
e = e.replace(R, n), t = e.match(R);
|
|
827
827
|
}
|
|
828
828
|
return e;
|
|
829
829
|
}, vt = (r, e, t) => {
|
|
@@ -860,13 +860,13 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
860
860
|
e = vt(e, n, n + 1), n = n + 1;
|
|
861
861
|
return e;
|
|
862
862
|
}
|
|
863
|
-
}, O =
|
|
863
|
+
}, O = W(Tt, "inlineSyncConfig"), Dt = (r) => {
|
|
864
864
|
const { selection: e } = r, { $from: t } = e;
|
|
865
865
|
return t.node();
|
|
866
866
|
}, Ot = (r, e, t, n) => {
|
|
867
867
|
const o = r.get(Re), a = e.schema.topNodeType.create(void 0, [t, ...n]);
|
|
868
868
|
return o(a);
|
|
869
|
-
},
|
|
869
|
+
}, Ht = (r, e) => {
|
|
870
870
|
const t = r.get(O.key), n = t.placeholderConfig.hole, [o = "", ...a] = e.split(`
|
|
871
871
|
|
|
872
872
|
`), s = (d) => t.movePlaceholder(n, d);
|
|
@@ -875,7 +875,7 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
875
875
|
return c = c.replace(n, i), c = [c, ...a].join(`
|
|
876
876
|
|
|
877
877
|
`), [c, i];
|
|
878
|
-
},
|
|
878
|
+
}, _t = (r, e) => {
|
|
879
879
|
const n = r.get(Pe)(e);
|
|
880
880
|
return n ? n.firstChild : null;
|
|
881
881
|
}, Kt = (r, e) => {
|
|
@@ -886,13 +886,13 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
886
886
|
}), n;
|
|
887
887
|
}, $t = (r) => r.split(`
|
|
888
888
|
|
|
889
|
-
`)[0] || "",
|
|
889
|
+
`)[0] || "", _e = (r, e) => {
|
|
890
890
|
try {
|
|
891
|
-
const t = Kt(r, e), n = Dt(e), o = Ot(r, e, n, t), [a, s] =
|
|
891
|
+
const t = Kt(r, e), n = Dt(e), o = Ot(r, e, n, t), [a, s] = Ht(r, o), l = _t(r, a);
|
|
892
892
|
return !l || n.type !== l.type ? null : (l.attrs = { ...n.attrs }, l.descendants((c) => {
|
|
893
|
-
var
|
|
893
|
+
var u;
|
|
894
894
|
const d = c.marks.find((g) => g.type.name === "link");
|
|
895
|
-
d && ((
|
|
895
|
+
d && ((u = c.text) == null ? void 0 : u.includes(s)) && d.attrs.href.includes(s) && (d.attrs.href = d.attrs.href.replace(s, ""));
|
|
896
896
|
}), {
|
|
897
897
|
text: $t(a),
|
|
898
898
|
prevNode: n,
|
|
@@ -905,11 +905,11 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
905
905
|
}, Et = (r, e, t, n, o) => {
|
|
906
906
|
const { placeholderConfig: a } = r.get(O.key), s = a.hole;
|
|
907
907
|
let l = t.tr.setMeta(e, !0).insertText(s, t.selection.from);
|
|
908
|
-
const c = t.apply(l), i =
|
|
908
|
+
const c = t.apply(l), i = _e(r, c);
|
|
909
909
|
if (!i)
|
|
910
910
|
return;
|
|
911
|
-
const { $from: d } = c.selection,
|
|
912
|
-
l = l.replaceWith(
|
|
911
|
+
const { $from: d } = c.selection, u = d.before(), g = d.after(), f = Lt(i.nextNode, u, i.placeholder);
|
|
912
|
+
l = l.replaceWith(u, g, i.nextNode).setNodeMarkup(u, void 0, o).delete(f + 1, f + 2), l = l.setSelection(re.near(l.doc.resolve(f + 1))), n(l);
|
|
913
913
|
}, Bt = w((r) => {
|
|
914
914
|
let e = null;
|
|
915
915
|
const t = new N("MILKDOWN_INLINE_SYNC");
|
|
@@ -918,24 +918,24 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
918
918
|
state: {
|
|
919
919
|
init: () => null,
|
|
920
920
|
apply: (n, o, a, s) => {
|
|
921
|
-
var
|
|
922
|
-
const l = r.get(
|
|
923
|
-
if (!((
|
|
921
|
+
var H;
|
|
922
|
+
const l = r.get(P);
|
|
923
|
+
if (!((H = l.hasFocus) != null && H.call(l)) || !l.editable || !n.docChanged || n.getMeta(t))
|
|
924
924
|
return null;
|
|
925
|
-
const i =
|
|
925
|
+
const i = _e(r, s);
|
|
926
926
|
if (!i)
|
|
927
927
|
return null;
|
|
928
928
|
e && (cancelAnimationFrame(e), e = null);
|
|
929
|
-
const { prevNode: d, nextNode:
|
|
930
|
-
return
|
|
929
|
+
const { prevNode: d, nextNode: u, text: g } = i, { shouldSyncNode: f } = r.get(O.key);
|
|
930
|
+
return f({ prevNode: d, nextNode: u, ctx: r, tr: n, text: g }) && (e = requestAnimationFrame(() => {
|
|
931
931
|
e = null;
|
|
932
|
-
const { dispatch: $e, state: Ee } = r.get(
|
|
932
|
+
const { dispatch: $e, state: Ee } = r.get(P);
|
|
933
933
|
Et(r, t, Ee, $e, d.attrs);
|
|
934
934
|
})), null;
|
|
935
935
|
}
|
|
936
936
|
}
|
|
937
937
|
});
|
|
938
|
-
}), Rt =
|
|
938
|
+
}), Rt = $(() => () => (r) => {
|
|
939
939
|
oe(r, "list", (e) => {
|
|
940
940
|
if (e.ordered) {
|
|
941
941
|
const t = e.start ?? 1;
|
|
@@ -944,7 +944,7 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
944
944
|
});
|
|
945
945
|
}
|
|
946
946
|
});
|
|
947
|
-
}), Pt =
|
|
947
|
+
}), Pt = $(() => () => (r) => {
|
|
948
948
|
const e = /[\t ]*(?:\r?\n|\r)/g;
|
|
949
949
|
oe(r, "text", (t, n, o) => {
|
|
950
950
|
if (!t.value || typeof t.value != "string")
|
|
@@ -960,7 +960,31 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
960
960
|
if (!!(a.length > 0 && o && typeof n == "number"))
|
|
961
961
|
return s < t.value.length && a.push({ type: "text", value: t.value.slice(s) }), o.children.splice(n, 1, ...a), n + a.length;
|
|
962
962
|
});
|
|
963
|
-
}), Wt =
|
|
963
|
+
}), Wt = $(() => ze), qt = (r) => !!r.children, Ft = (r) => r.type === "html";
|
|
964
|
+
function Vt(r, e) {
|
|
965
|
+
return t(r, 0, null)[0];
|
|
966
|
+
function t(n, o, a) {
|
|
967
|
+
if (qt(n)) {
|
|
968
|
+
const s = [];
|
|
969
|
+
for (let l = 0, c = n.children.length; l < c; l++) {
|
|
970
|
+
const i = n.children[l];
|
|
971
|
+
if (i) {
|
|
972
|
+
const d = t(i, l, n);
|
|
973
|
+
if (d)
|
|
974
|
+
for (let u = 0, g = d.length; u < g; u++) {
|
|
975
|
+
const f = d[u];
|
|
976
|
+
f && s.push(f);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
n.children = s;
|
|
981
|
+
}
|
|
982
|
+
return e(n, o, a);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
const Gt = $(() => () => (r) => {
|
|
986
|
+
Vt(r, (e) => Ft(e) ? [] : [e]);
|
|
987
|
+
}), jt = w(() => {
|
|
964
988
|
let r = !1;
|
|
965
989
|
const e = new N("MILKDOWN_INLINE_NODES_CURSOR"), t = new C({
|
|
966
990
|
key: e,
|
|
@@ -1006,7 +1030,7 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
1006
1030
|
}
|
|
1007
1031
|
});
|
|
1008
1032
|
return t;
|
|
1009
|
-
}),
|
|
1033
|
+
}), zt = w(() => new C({
|
|
1010
1034
|
key: new N("MILKDOWN_HARDBREAK_MARKS"),
|
|
1011
1035
|
appendTransaction: (r, e, t) => {
|
|
1012
1036
|
if (!r.length)
|
|
@@ -1021,15 +1045,15 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
1021
1045
|
const { from: l } = o;
|
|
1022
1046
|
return t.tr.setNodeMarkup(l, x.type(), void 0, []);
|
|
1023
1047
|
}
|
|
1024
|
-
if (o instanceof
|
|
1048
|
+
if (o instanceof je) {
|
|
1025
1049
|
let l = t.tr;
|
|
1026
1050
|
const { from: c, to: i } = o;
|
|
1027
|
-
return t.doc.nodesBetween(c, i, (d,
|
|
1028
|
-
d.type === x.type() && (l = l.setNodeMarkup(
|
|
1051
|
+
return t.doc.nodesBetween(c, i, (d, u) => {
|
|
1052
|
+
d.type === x.type() && (l = l.setNodeMarkup(u, x.type(), void 0, []));
|
|
1029
1053
|
}), l;
|
|
1030
1054
|
}
|
|
1031
1055
|
}
|
|
1032
|
-
})), Ke =
|
|
1056
|
+
})), Ke = W(["table", "code_block"], "hardbreakFilterNodes"), Ut = w((r) => {
|
|
1033
1057
|
const e = r.get(Ke.key);
|
|
1034
1058
|
return new C({
|
|
1035
1059
|
key: new N("MILKDOWN_HARDBREAK_FILTER"),
|
|
@@ -1045,7 +1069,7 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
1045
1069
|
return !0;
|
|
1046
1070
|
}
|
|
1047
1071
|
});
|
|
1048
|
-
}),
|
|
1072
|
+
}), Yt = w((r) => {
|
|
1049
1073
|
const e = new N("MILKDOWN_HEADING_ID"), t = (n) => {
|
|
1050
1074
|
if (n.composing || !n.editable)
|
|
1051
1075
|
return;
|
|
@@ -1071,17 +1095,17 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
1071
1095
|
}
|
|
1072
1096
|
})
|
|
1073
1097
|
});
|
|
1074
|
-
}),
|
|
1098
|
+
}), Jt = w(() => {
|
|
1075
1099
|
const r = (e, t) => {
|
|
1076
|
-
const n =
|
|
1100
|
+
const n = B.type(), o = D.type();
|
|
1077
1101
|
let a = e.tr;
|
|
1078
1102
|
e.doc.descendants((s, l, c, i) => {
|
|
1079
1103
|
if (s.type === o && (c == null ? void 0 : c.type) === n) {
|
|
1080
1104
|
let d = !1;
|
|
1081
|
-
const
|
|
1082
|
-
s.attrs.listType !== "ordered" && (
|
|
1105
|
+
const u = { ...s.attrs };
|
|
1106
|
+
s.attrs.listType !== "ordered" && (u.listType = "ordered", d = !0);
|
|
1083
1107
|
const g = c == null ? void 0 : c.maybeChild(0);
|
|
1084
|
-
g === s ? (
|
|
1108
|
+
g === s ? (u.label = "1.", d = !0) : (g == null ? void 0 : g.type) === o && g.attrs.listType === "ordered" ? (u.label = `${i + 1}.`, d = !0) : s.attrs.label === "•" && (u.label = `${i + 1}.`, d = !0), d && (a = a.setNodeMarkup(l, void 0, u));
|
|
1085
1109
|
}
|
|
1086
1110
|
}), t(a);
|
|
1087
1111
|
};
|
|
@@ -1094,31 +1118,32 @@ const ae = H("emphasis"), se = K("emphasis", (r) => ({
|
|
|
1094
1118
|
}), o;
|
|
1095
1119
|
}
|
|
1096
1120
|
});
|
|
1097
|
-
}),
|
|
1121
|
+
}), Qt = [
|
|
1098
1122
|
O,
|
|
1099
1123
|
Bt,
|
|
1100
|
-
|
|
1124
|
+
zt,
|
|
1101
1125
|
Ke,
|
|
1102
|
-
|
|
1103
|
-
|
|
1126
|
+
Ut,
|
|
1127
|
+
jt,
|
|
1104
1128
|
Rt,
|
|
1105
1129
|
Wt,
|
|
1106
1130
|
Pt,
|
|
1107
1131
|
Gt,
|
|
1108
|
-
|
|
1109
|
-
|
|
1132
|
+
Yt,
|
|
1133
|
+
Jt
|
|
1134
|
+
], pr = [It, bt, wt, Nt, Qt].flat();
|
|
1110
1135
|
export {
|
|
1111
1136
|
ye as blockquoteAttr,
|
|
1112
1137
|
st as blockquoteKeymap,
|
|
1113
|
-
|
|
1138
|
+
j as blockquoteSchema,
|
|
1114
1139
|
ve as bulletListAttr,
|
|
1115
1140
|
ft as bulletListKeymap,
|
|
1116
1141
|
Y as bulletListSchema,
|
|
1117
1142
|
Ie as codeBlockAttr,
|
|
1118
1143
|
ct as codeBlockKeymap,
|
|
1119
|
-
|
|
1144
|
+
z as codeBlockSchema,
|
|
1120
1145
|
wt as commands,
|
|
1121
|
-
|
|
1146
|
+
pr as commonmark,
|
|
1122
1147
|
be as createCodeBlockCommand,
|
|
1123
1148
|
lt as createCodeBlockInputRule,
|
|
1124
1149
|
Tt as defaultConfig,
|
|
@@ -1128,9 +1153,9 @@ export {
|
|
|
1128
1153
|
Ue as emphasisKeymap,
|
|
1129
1154
|
se as emphasisSchema,
|
|
1130
1155
|
Ne as hardbreakAttr,
|
|
1131
|
-
|
|
1156
|
+
zt as hardbreakClearMarkPlugin,
|
|
1132
1157
|
Ke as hardbreakFilterNodes,
|
|
1133
|
-
|
|
1158
|
+
Ut as hardbreakFilterPlugin,
|
|
1134
1159
|
ut as hardbreakKeymap,
|
|
1135
1160
|
x as hardbreakSchema,
|
|
1136
1161
|
he as headingAttr,
|
|
@@ -1140,51 +1165,52 @@ export {
|
|
|
1140
1165
|
Ae as hrAttr,
|
|
1141
1166
|
U as hrSchema,
|
|
1142
1167
|
we as imageAttr,
|
|
1143
|
-
|
|
1168
|
+
E as imageSchema,
|
|
1144
1169
|
ue as inlineCodeAttr,
|
|
1145
1170
|
Je as inlineCodeKeymap,
|
|
1146
1171
|
A as inlineCodeSchema,
|
|
1147
|
-
|
|
1172
|
+
jt as inlineNodesCursorPlugin,
|
|
1148
1173
|
O as inlineSyncConfig,
|
|
1149
1174
|
Bt as inlineSyncPlugin,
|
|
1150
1175
|
bt as inputrules,
|
|
1151
1176
|
Ce as insertHardbreakCommand,
|
|
1152
|
-
|
|
1153
|
-
|
|
1177
|
+
pt as insertHrCommand,
|
|
1178
|
+
mt as insertHrInputRule,
|
|
1154
1179
|
it as insertImageCommand,
|
|
1155
|
-
|
|
1180
|
+
mr as insertImageInputRule,
|
|
1156
1181
|
Nt as keymap,
|
|
1157
1182
|
Oe as liftListItemCommand,
|
|
1158
|
-
|
|
1183
|
+
pe as linkAttr,
|
|
1159
1184
|
v as linkSchema,
|
|
1160
1185
|
Te as listItemAttr,
|
|
1161
1186
|
yt as listItemKeymap,
|
|
1162
1187
|
D as listItemSchema,
|
|
1163
1188
|
Se as orderedListAttr,
|
|
1164
1189
|
kt as orderedListKeymap,
|
|
1165
|
-
|
|
1190
|
+
B as orderedListSchema,
|
|
1166
1191
|
ge as paragraphAttr,
|
|
1167
1192
|
et as paragraphKeymap,
|
|
1168
1193
|
L as paragraphSchema,
|
|
1169
|
-
|
|
1194
|
+
Qt as plugins,
|
|
1170
1195
|
Rt as remarkAddOrderInListPlugin,
|
|
1196
|
+
Gt as remarkHTMLFilter,
|
|
1171
1197
|
Wt as remarkInlineLinkPlugin,
|
|
1172
1198
|
Pt as remarkLineBreak,
|
|
1173
1199
|
It as schema,
|
|
1174
1200
|
De as sinkListItemCommand,
|
|
1175
|
-
|
|
1201
|
+
He as splitListItemCommand,
|
|
1176
1202
|
ce as strongAttr,
|
|
1177
1203
|
Ye as strongKeymap,
|
|
1178
1204
|
ie as strongSchema,
|
|
1179
|
-
|
|
1180
|
-
|
|
1205
|
+
Yt as syncHeadingIdPlugin,
|
|
1206
|
+
Jt as syncListOrderPlugin,
|
|
1181
1207
|
Mt as textSchema,
|
|
1182
1208
|
le as toggleEmphasisCommand,
|
|
1183
|
-
|
|
1209
|
+
me as toggleInlineCodeCommand,
|
|
1184
1210
|
Qe as toggleLinkCommand,
|
|
1185
1211
|
de as toggleStrongCommand,
|
|
1186
1212
|
fe as turnIntoTextCommand,
|
|
1187
|
-
|
|
1213
|
+
ur as updateCodeBlockLanguageCommand,
|
|
1188
1214
|
dt as updateImageCommand,
|
|
1189
1215
|
Xe as updateLinkCommand,
|
|
1190
1216
|
Me as wrapInBlockquoteCommand,
|