@milkdown/preset-commonmark 6.3.0 → 6.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.es.js +379 -360
- package/lib/index.es.js.map +1 -1
- package/lib/node/hardbreak.d.ts +5 -1
- package/lib/node/hardbreak.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/node/hardbreak.ts +30 -1
package/lib/index.es.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { createMark as
|
|
2
|
-
import { createCmdKey as I, createCmd as M, schemaCtx as A, commandsCtx as we, editorViewCtx as
|
|
1
|
+
import { createMark as R, createShortcut as h, createNode as w, createPlugin as He, AtomList as Ne } from "@milkdown/utils";
|
|
2
|
+
import { createCmdKey as I, createCmd as M, schemaCtx as A, commandsCtx as we, editorViewCtx as B, getPalette as Te } from "@milkdown/core";
|
|
3
3
|
import { markRule as _, calculateTextPosition as Oe, cloneTr as Ae, findSelectedNodeOfType as K, getNodeFromSchema as Ee } from "@milkdown/prose";
|
|
4
4
|
import { toggleMark as P, wrapIn as de, setBlockType as E } from "@milkdown/prose/commands";
|
|
5
5
|
import { expectDomTypeError as D, missingRootElement as _e } from "@milkdown/exception";
|
|
6
6
|
import { InputRule as me, wrappingInputRule as W, textblockTypeInputRule as G } from "@milkdown/prose/inputrules";
|
|
7
|
-
import { PluginKey as
|
|
7
|
+
import { PluginKey as T, TextSelection as pe, Plugin as H, NodeSelection as ve, Selection as Le } from "@milkdown/prose/state";
|
|
8
8
|
import { Fragment as ge } from "@milkdown/prose/model";
|
|
9
9
|
import { ReplaceStep as $e, AddMarkStep as Se } from "@milkdown/prose/transform";
|
|
10
10
|
import { DecorationSet as O, Decoration as J } from "@milkdown/prose/view";
|
|
11
|
-
import { splitListItem as
|
|
11
|
+
import { splitListItem as Re, sinkListItem as Be, liftListItem as Pe } from "@milkdown/prose/schema-list";
|
|
12
12
|
import We from "remark-inline-links";
|
|
13
13
|
import { visit as qe } from "unist-util-visit";
|
|
14
14
|
const k = {
|
|
@@ -31,7 +31,7 @@ const k = {
|
|
|
31
31
|
NextListItem: "NextListItem",
|
|
32
32
|
SinkListItem: "SinkListItem",
|
|
33
33
|
LiftListItem: "LiftListItem"
|
|
34
|
-
}, he = "code_inline", Q = I("ToggleInlineCode"), Ke =
|
|
34
|
+
}, he = "code_inline", Q = I("ToggleInlineCode"), Ke = R((c) => ({
|
|
35
35
|
id: he,
|
|
36
36
|
schema: () => ({
|
|
37
37
|
priority: 100,
|
|
@@ -57,7 +57,7 @@ const k = {
|
|
|
57
57
|
shortcuts: {
|
|
58
58
|
[k.CodeInline]: h(Q, "Mod-e")
|
|
59
59
|
}
|
|
60
|
-
})), F = "em", X = I("ToggleItalic"), Fe =
|
|
60
|
+
})), F = "em", X = I("ToggleItalic"), Fe = R((c) => ({
|
|
61
61
|
id: F,
|
|
62
62
|
schema: () => ({
|
|
63
63
|
parseDOM: [
|
|
@@ -87,7 +87,7 @@ const k = {
|
|
|
87
87
|
shortcuts: {
|
|
88
88
|
[k.Em]: h(X, "Mod-i")
|
|
89
89
|
}
|
|
90
|
-
})), Ue = new
|
|
90
|
+
})), Ue = new T("MILKDOWN_LINK_INPUT"), xe = I("ToggleLink"), Y = I("ModifyLink"), v = "link", Ve = R((c, e) => ({
|
|
91
91
|
id: v,
|
|
92
92
|
schema: () => ({
|
|
93
93
|
attrs: {
|
|
@@ -109,8 +109,8 @@ const k = {
|
|
|
109
109
|
parseMarkdown: {
|
|
110
110
|
match: (t) => t.type === "link",
|
|
111
111
|
runner: (t, r, n) => {
|
|
112
|
-
const
|
|
113
|
-
t.openMark(n, { href:
|
|
112
|
+
const o = r.url, a = r.title;
|
|
113
|
+
t.openMark(n, { href: o, title: a }), t.next(r.children), t.closeMark(n);
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
116
|
toMarkdown: {
|
|
@@ -125,94 +125,94 @@ const k = {
|
|
|
125
125
|
}),
|
|
126
126
|
commands: (t) => [
|
|
127
127
|
M(xe, (r = "") => P(t, { href: r })),
|
|
128
|
-
M(Y, (r = "") => (n,
|
|
129
|
-
var
|
|
130
|
-
if (!
|
|
128
|
+
M(Y, (r = "") => (n, o) => {
|
|
129
|
+
var y;
|
|
130
|
+
if (!o)
|
|
131
131
|
return !1;
|
|
132
132
|
const { marks: a } = n.schema;
|
|
133
|
-
let
|
|
134
|
-
const { selection: i } = n, { from:
|
|
135
|
-
if (n.doc.nodesBetween(
|
|
133
|
+
let s, l = -1;
|
|
134
|
+
const { selection: i } = n, { from: u, to: g } = i;
|
|
135
|
+
if (n.doc.nodesBetween(u, u === g ? g + 1 : g, (N, x) => {
|
|
136
136
|
var L;
|
|
137
|
-
if ((L = a.link) != null && L.isInSet(
|
|
138
|
-
return
|
|
139
|
-
}), !
|
|
137
|
+
if ((L = a.link) != null && L.isInSet(N.marks))
|
|
138
|
+
return s = N, l = x, !1;
|
|
139
|
+
}), !s)
|
|
140
140
|
return !1;
|
|
141
|
-
const
|
|
142
|
-
if (!
|
|
141
|
+
const d = s.marks.find(({ type: N }) => N === t);
|
|
142
|
+
if (!d)
|
|
143
143
|
return !1;
|
|
144
|
-
const
|
|
145
|
-
return
|
|
144
|
+
const m = l, f = l + s.nodeSize, { tr: p } = n, b = (y = a.link) == null ? void 0 : y.create({ ...d.attrs, href: r });
|
|
145
|
+
return b ? (o(p.removeMark(m, f, d).addMark(m, f, b).setSelection(new pe(p.selection.$anchor)).scrollIntoView()), !0) : !1;
|
|
146
146
|
})
|
|
147
147
|
],
|
|
148
148
|
inputRules: (t, r) => [
|
|
149
|
-
new me(/\[(?<text>.*?)]\((?<href>.*?)(?=“|\))"?(?<title>[^"]+)?"?\)/, (n,
|
|
150
|
-
const [l, i = "",
|
|
149
|
+
new me(/\[(?<text>.*?)]\((?<href>.*?)(?=“|\))"?(?<title>[^"]+)?"?\)/, (n, o, a, s) => {
|
|
150
|
+
const [l, i = "", u, g] = o, { tr: d } = n;
|
|
151
151
|
if (l) {
|
|
152
|
-
const
|
|
153
|
-
|
|
152
|
+
const m = i || "link";
|
|
153
|
+
d.replaceWith(a, s, r.get(A).text(m)).addMark(a, m.length + a, t.create({ title: g, href: u }));
|
|
154
154
|
}
|
|
155
|
-
return
|
|
155
|
+
return d;
|
|
156
156
|
})
|
|
157
157
|
],
|
|
158
158
|
prosePlugins: (t, r) => {
|
|
159
159
|
let n = !1;
|
|
160
160
|
return [
|
|
161
|
-
new
|
|
161
|
+
new H({
|
|
162
162
|
key: Ue,
|
|
163
|
-
view: (
|
|
164
|
-
var
|
|
163
|
+
view: (o) => {
|
|
164
|
+
var u, g, d;
|
|
165
165
|
const a = c.themeManager.get("input-chip", {
|
|
166
|
-
placeholder: (
|
|
167
|
-
buttonText: (
|
|
168
|
-
onUpdate: (
|
|
169
|
-
r.get(we).call(Y,
|
|
166
|
+
placeholder: (g = (u = e == null ? void 0 : e.input) == null ? void 0 : u.placeholder) != null ? g : "Input Web Link",
|
|
167
|
+
buttonText: (d = e == null ? void 0 : e.input) == null ? void 0 : d.buttonText,
|
|
168
|
+
onUpdate: (m) => {
|
|
169
|
+
r.get(we).call(Y, m);
|
|
170
170
|
},
|
|
171
|
-
calculatePosition: (
|
|
172
|
-
Oe(
|
|
173
|
-
const x =
|
|
171
|
+
calculatePosition: (m, f) => {
|
|
172
|
+
Oe(m, f, (p, b, y, N) => {
|
|
173
|
+
const x = m.dom.parentElement;
|
|
174
174
|
if (!x)
|
|
175
175
|
throw _e();
|
|
176
|
-
const L =
|
|
177
|
-
let q = p.left -
|
|
178
|
-
return n && (fe = p.top -
|
|
176
|
+
const L = b.left - p.left;
|
|
177
|
+
let q = p.left - N.left - (y.width - L) / 2, fe = p.bottom - N.top + 14 + x.scrollTop;
|
|
178
|
+
return n && (fe = p.top - N.top - y.height - 14 + x.scrollTop), q < 0 && (q = 0), [fe, q];
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
if (!a)
|
|
183
183
|
return {};
|
|
184
|
-
const
|
|
185
|
-
const { selection: f, doc: p } =
|
|
186
|
-
if (!
|
|
184
|
+
const s = (m) => {
|
|
185
|
+
const { selection: f, doc: p } = m.state, { from: b, to: y } = f;
|
|
186
|
+
if (!m.hasFocus())
|
|
187
187
|
return !1;
|
|
188
|
-
if (f.empty && f instanceof pe &&
|
|
188
|
+
if (f.empty && f instanceof pe && y < p.content.size && b < p.content.size && p.rangeHasMark(b, b === y ? y + 1 : y, t))
|
|
189
189
|
return n = !1, !0;
|
|
190
190
|
if (f instanceof ve) {
|
|
191
|
-
const { node:
|
|
192
|
-
if (
|
|
191
|
+
const { node: N } = f;
|
|
192
|
+
if (N.type.name === "image" && N.marks.findIndex((x) => x.type.name === v) > -1)
|
|
193
193
|
return n = !0, !0;
|
|
194
194
|
}
|
|
195
195
|
return !1;
|
|
196
|
-
}, l = (
|
|
197
|
-
const { selection: f } =
|
|
196
|
+
}, l = (m) => {
|
|
197
|
+
const { selection: f } = m.state;
|
|
198
198
|
let p;
|
|
199
|
-
const { from:
|
|
200
|
-
if (
|
|
199
|
+
const { from: b, to: y } = f;
|
|
200
|
+
if (m.state.doc.nodesBetween(b, b === y ? y + 1 : y, (L) => {
|
|
201
201
|
if (t.isInSet(L.marks))
|
|
202
202
|
return p = L, !1;
|
|
203
203
|
}), !p)
|
|
204
204
|
return;
|
|
205
|
-
const
|
|
206
|
-
return
|
|
207
|
-
}, i = (
|
|
208
|
-
if (!
|
|
205
|
+
const N = p.marks.find((L) => L.type === t);
|
|
206
|
+
return N ? N.attrs.href : void 0;
|
|
207
|
+
}, i = (m) => {
|
|
208
|
+
if (!m.editable)
|
|
209
209
|
return;
|
|
210
|
-
|
|
210
|
+
s(m) ? (a.show(m), a.update(l(m))) : a.hide();
|
|
211
211
|
};
|
|
212
|
-
return a.init(
|
|
213
|
-
update: (
|
|
214
|
-
(f == null ? void 0 : f.doc.eq(
|
|
215
|
-
i(
|
|
212
|
+
return a.init(o), i(o), {
|
|
213
|
+
update: (m, f) => {
|
|
214
|
+
(f == null ? void 0 : f.doc.eq(m.state.doc)) && f.selection.eq(m.state.selection) || requestAnimationFrame(() => {
|
|
215
|
+
i(m);
|
|
216
216
|
});
|
|
217
217
|
},
|
|
218
218
|
destroy: () => {
|
|
@@ -223,7 +223,7 @@ const k = {
|
|
|
223
223
|
})
|
|
224
224
|
];
|
|
225
225
|
}
|
|
226
|
-
})), U = "strong", Z = I("ToggleBold"), je =
|
|
226
|
+
})), U = "strong", Z = I("ToggleBold"), je = R((c) => ({
|
|
227
227
|
id: U,
|
|
228
228
|
schema: () => ({
|
|
229
229
|
parseDOM: [
|
|
@@ -347,16 +347,16 @@ const k = {
|
|
|
347
347
|
tag: "div.code-fence-container",
|
|
348
348
|
preserveWhitespace: "full",
|
|
349
349
|
getAttrs: (n) => {
|
|
350
|
-
var
|
|
350
|
+
var o;
|
|
351
351
|
if (!(n instanceof HTMLElement))
|
|
352
352
|
throw D(n);
|
|
353
|
-
return { language: (
|
|
353
|
+
return { language: (o = n.querySelector("pre")) == null ? void 0 : o.dataset.language };
|
|
354
354
|
},
|
|
355
|
-
getContent: (n,
|
|
356
|
-
var
|
|
355
|
+
getContent: (n, o) => {
|
|
356
|
+
var s, l;
|
|
357
357
|
if (!(n instanceof HTMLElement))
|
|
358
358
|
throw D(n);
|
|
359
|
-
const a =
|
|
359
|
+
const a = o.text((l = (s = n.querySelector("pre")) == null ? void 0 : s.textContent) != null ? l : "");
|
|
360
360
|
return ge.from(a);
|
|
361
361
|
}
|
|
362
362
|
},
|
|
@@ -371,33 +371,33 @@ const k = {
|
|
|
371
371
|
}
|
|
372
372
|
],
|
|
373
373
|
toDOM: (n) => {
|
|
374
|
-
const
|
|
374
|
+
const o = document.createElement("select");
|
|
375
375
|
return t.forEach((a) => {
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
}),
|
|
379
|
-
const
|
|
380
|
-
if (!(
|
|
376
|
+
const s = document.createElement("option");
|
|
377
|
+
s.value = a, s.innerText = a || "--", a === n.attrs.language && (s.selected = !0), o.appendChild(s);
|
|
378
|
+
}), o.onchange = (a) => {
|
|
379
|
+
const s = a.target;
|
|
380
|
+
if (!(s instanceof HTMLSelectElement))
|
|
381
381
|
return;
|
|
382
|
-
const l = r.get(
|
|
382
|
+
const l = r.get(B);
|
|
383
383
|
if (!l.editable) {
|
|
384
|
-
|
|
384
|
+
s.value = n.attrs.language;
|
|
385
385
|
return;
|
|
386
386
|
}
|
|
387
|
-
const { top: i, left:
|
|
388
|
-
if (!
|
|
387
|
+
const { top: i, left: u } = s.getBoundingClientRect(), g = l.posAtCoords({ top: i, left: u });
|
|
388
|
+
if (!g)
|
|
389
389
|
return;
|
|
390
|
-
const { tr:
|
|
391
|
-
l.dispatch(
|
|
390
|
+
const { tr: d } = l.state;
|
|
391
|
+
l.dispatch(d.setNodeMarkup(g.inside, void 0, {
|
|
392
392
|
...n.attrs,
|
|
393
|
-
language:
|
|
393
|
+
language: s.value
|
|
394
394
|
}));
|
|
395
395
|
}, [
|
|
396
396
|
"div",
|
|
397
397
|
{
|
|
398
398
|
class: "code-fence-container"
|
|
399
399
|
},
|
|
400
|
-
|
|
400
|
+
o,
|
|
401
401
|
[
|
|
402
402
|
"pre",
|
|
403
403
|
{
|
|
@@ -410,30 +410,30 @@ const k = {
|
|
|
410
410
|
},
|
|
411
411
|
parseMarkdown: {
|
|
412
412
|
match: ({ type: n }) => n === "code",
|
|
413
|
-
runner: (n,
|
|
414
|
-
const
|
|
415
|
-
n.openNode(a, { language:
|
|
413
|
+
runner: (n, o, a) => {
|
|
414
|
+
const s = o.lang, l = o.value;
|
|
415
|
+
n.openNode(a, { language: s }), l && n.addText(l), n.closeNode();
|
|
416
416
|
}
|
|
417
417
|
},
|
|
418
418
|
toMarkdown: {
|
|
419
419
|
match: (n) => n.type.name === V,
|
|
420
|
-
runner: (n,
|
|
420
|
+
runner: (n, o) => {
|
|
421
421
|
var a;
|
|
422
|
-
n.addNode("code", void 0, ((a =
|
|
423
|
-
lang:
|
|
422
|
+
n.addNode("code", void 0, ((a = o.content.firstChild) == null ? void 0 : a.text) || "", {
|
|
423
|
+
lang: o.attrs.language
|
|
424
424
|
});
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
}),
|
|
428
428
|
inputRules: (r) => [
|
|
429
429
|
G(Xe, r, (n) => {
|
|
430
|
-
const [
|
|
431
|
-
if (!!
|
|
430
|
+
const [o, a] = n;
|
|
431
|
+
if (!!o)
|
|
432
432
|
return { language: a };
|
|
433
433
|
}),
|
|
434
434
|
G(Ye, r, (n) => {
|
|
435
|
-
const [
|
|
436
|
-
if (!!
|
|
435
|
+
const [o, a] = n;
|
|
436
|
+
if (!!o)
|
|
437
437
|
return { language: a };
|
|
438
438
|
})
|
|
439
439
|
],
|
|
@@ -441,40 +441,40 @@ const k = {
|
|
|
441
441
|
shortcuts: {
|
|
442
442
|
[k.CodeFence]: h(re, "Mod-Alt-c")
|
|
443
443
|
},
|
|
444
|
-
view: () => (r, n,
|
|
444
|
+
view: () => (r, n, o) => {
|
|
445
445
|
let a = r;
|
|
446
|
-
const
|
|
447
|
-
const { tr:
|
|
448
|
-
n.dispatch(
|
|
446
|
+
const s = (p) => {
|
|
447
|
+
const { tr: b } = n.state;
|
|
448
|
+
n.dispatch(b.setNodeMarkup(o(), void 0, {
|
|
449
449
|
fold: !0,
|
|
450
450
|
language: p
|
|
451
451
|
}));
|
|
452
452
|
}, l = () => {
|
|
453
453
|
const { tr: p } = n.state;
|
|
454
|
-
n.dispatch(p.setNodeMarkup(
|
|
454
|
+
n.dispatch(p.setNodeMarkup(o(), void 0, {
|
|
455
455
|
...a.attrs,
|
|
456
456
|
fold: !0
|
|
457
457
|
}));
|
|
458
458
|
}, i = () => {
|
|
459
459
|
const { tr: p } = n.state;
|
|
460
|
-
n.dispatch(p.setNodeMarkup(
|
|
460
|
+
n.dispatch(p.setNodeMarkup(o(), void 0, {
|
|
461
461
|
...a.attrs,
|
|
462
462
|
fold: !1
|
|
463
463
|
}));
|
|
464
|
-
},
|
|
464
|
+
}, u = c.themeManager.get("code-fence", {
|
|
465
465
|
onBlur: l,
|
|
466
466
|
onFocus: i,
|
|
467
|
-
onSelectLanguage:
|
|
467
|
+
onSelectLanguage: s,
|
|
468
468
|
editable: () => n.editable,
|
|
469
469
|
languageList: t
|
|
470
470
|
});
|
|
471
|
-
if (!
|
|
471
|
+
if (!u)
|
|
472
472
|
return {};
|
|
473
|
-
const { dom:
|
|
474
|
-
return
|
|
475
|
-
dom:
|
|
476
|
-
contentDOM:
|
|
477
|
-
update: (p) => p.type.name !== V ? !1 : (a = p,
|
|
473
|
+
const { dom: g, contentDOM: d, onUpdate: m, onDestroy: f } = u;
|
|
474
|
+
return m(a), {
|
|
475
|
+
dom: g,
|
|
476
|
+
contentDOM: d,
|
|
477
|
+
update: (p) => p.type.name !== V ? !1 : (a = p, m(a), !0),
|
|
478
478
|
destroy: f
|
|
479
479
|
};
|
|
480
480
|
}
|
|
@@ -496,139 +496,157 @@ const k = {
|
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
})
|
|
499
|
-
})), ne = I("InsertHardbreak"), tt = w((c) =>
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
499
|
+
})), ne = I("InsertHardbreak"), tt = new T("MILKDOWN_HARDBREAK_FILTER"), rt = w((c, e) => {
|
|
500
|
+
var r;
|
|
501
|
+
const t = (r = e == null ? void 0 : e.notIn) != null ? r : ["table", "fence"];
|
|
502
|
+
return {
|
|
503
|
+
id: "hardbreak",
|
|
504
|
+
schema: () => ({
|
|
505
|
+
inline: !0,
|
|
506
|
+
group: "inline",
|
|
507
|
+
selectable: !1,
|
|
508
|
+
parseDOM: [{ tag: "br" }],
|
|
509
|
+
toDOM: (n) => ["br", { class: c.getClassName(n.attrs, "hardbreak") }],
|
|
510
|
+
parseMarkdown: {
|
|
511
|
+
match: ({ type: n }) => n === "break",
|
|
512
|
+
runner: (n, o, a) => {
|
|
513
|
+
n.addNode(a);
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
toMarkdown: {
|
|
517
|
+
match: (n) => n.type.name === "hardbreak",
|
|
518
|
+
runner: (n) => {
|
|
519
|
+
n.addNode("break");
|
|
520
|
+
}
|
|
511
521
|
}
|
|
522
|
+
}),
|
|
523
|
+
commands: (n) => [
|
|
524
|
+
M(ne, () => (o, a) => {
|
|
525
|
+
var i;
|
|
526
|
+
const { selection: s, tr: l } = o;
|
|
527
|
+
if (s.empty) {
|
|
528
|
+
const u = s.$from.node();
|
|
529
|
+
if (u.childCount > 0 && ((i = u.lastChild) == null ? void 0 : i.type.name) === "hardbreak")
|
|
530
|
+
return a == null || a(l.replaceRangeWith(s.to - 1, s.to, o.schema.node("paragraph")).setSelection(Le.near(l.doc.resolve(s.to))).scrollIntoView()), !0;
|
|
531
|
+
}
|
|
532
|
+
return a == null || a(l.setMeta("hardbreak", !0).replaceSelectionWith(n.create()).scrollIntoView()), !0;
|
|
533
|
+
})
|
|
534
|
+
],
|
|
535
|
+
shortcuts: {
|
|
536
|
+
[k.HardBreak]: h(ne, "Shift-Enter")
|
|
512
537
|
},
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
if (o.childCount > 0 && ((a = o.lastChild) == null ? void 0 : a.type.name) === "hardbreak")
|
|
527
|
-
return r == null || r(s.replaceRangeWith(n.to - 1, n.to, t.schema.node("paragraph")).setSelection(Le.near(s.doc.resolve(n.to))).scrollIntoView()), !0;
|
|
528
|
-
}
|
|
529
|
-
return r == null || r(s.setMeta("hardbreak", !0).replaceSelectionWith(e.create()).scrollIntoView()), !0;
|
|
530
|
-
})
|
|
531
|
-
],
|
|
532
|
-
shortcuts: {
|
|
533
|
-
[k.HardBreak]: h(ne, "Shift-Enter")
|
|
534
|
-
},
|
|
535
|
-
prosePlugins: (e) => [
|
|
536
|
-
new T({
|
|
537
|
-
key: new H("MILKDOWN_HARDBREAK_MARKS"),
|
|
538
|
-
appendTransaction: (t, r, n) => {
|
|
539
|
-
if (!t.length)
|
|
540
|
-
return;
|
|
541
|
-
const [s] = t;
|
|
542
|
-
if (!s)
|
|
543
|
-
return;
|
|
544
|
-
const [a] = s.steps;
|
|
545
|
-
if (s.getMeta("hardbreak")) {
|
|
546
|
-
if (!(a instanceof $e))
|
|
547
|
-
return;
|
|
548
|
-
const { from: i } = a;
|
|
549
|
-
return n.tr.setNodeMarkup(i, e, void 0, []);
|
|
538
|
+
prosePlugins: (n) => [
|
|
539
|
+
new H({
|
|
540
|
+
key: tt,
|
|
541
|
+
filterTransaction: (o, a) => {
|
|
542
|
+
const s = o.getMeta("hardbreak"), [l] = o.steps;
|
|
543
|
+
if (s && l) {
|
|
544
|
+
const { from: i } = l, u = a.doc.resolve(i);
|
|
545
|
+
let g = u.depth, d = !0;
|
|
546
|
+
for (; g > 0; )
|
|
547
|
+
t.includes(u.node(g).type.name) && (d = !1), g--;
|
|
548
|
+
return d;
|
|
549
|
+
}
|
|
550
|
+
return !0;
|
|
550
551
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
552
|
+
}),
|
|
553
|
+
new H({
|
|
554
|
+
key: new T("MILKDOWN_HARDBREAK_MARKS"),
|
|
555
|
+
appendTransaction: (o, a, s) => {
|
|
556
|
+
if (!o.length)
|
|
557
|
+
return;
|
|
558
|
+
const [l] = o;
|
|
559
|
+
if (!l)
|
|
560
|
+
return;
|
|
561
|
+
const [i] = l.steps;
|
|
562
|
+
if (l.getMeta("hardbreak")) {
|
|
563
|
+
if (!(i instanceof $e))
|
|
564
|
+
return;
|
|
565
|
+
const { from: d } = i;
|
|
566
|
+
return s.tr.setNodeMarkup(d, n, void 0, []);
|
|
567
|
+
}
|
|
568
|
+
if (i instanceof Se) {
|
|
569
|
+
let d = s.tr;
|
|
570
|
+
const { from: m, to: f } = i;
|
|
571
|
+
return s.doc.nodesBetween(m, f, (p, b) => {
|
|
572
|
+
p.type === n && (d = d.setNodeMarkup(b, n, void 0, []));
|
|
573
|
+
}), d;
|
|
574
|
+
}
|
|
557
575
|
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
})
|
|
576
|
+
})
|
|
577
|
+
]
|
|
578
|
+
};
|
|
579
|
+
}), ke = Array(6).fill(0).map((c, e) => e + 1), C = I("TurnIntoHeading"), Me = I("DowngradeHeading"), j = new T("MILKDOWN_HEADING_ID"), nt = new T("MILKDOWN_HEADING_HASH"), st = (c) => c.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "-").toLowerCase().trim(), ot = (c, e, t) => {
|
|
562
580
|
let r = !1;
|
|
563
|
-
const n = (
|
|
564
|
-
const
|
|
565
|
-
|
|
581
|
+
const n = (o, a) => {
|
|
582
|
+
const s = o.tr;
|
|
583
|
+
o.doc.descendants((l, i) => {
|
|
566
584
|
if (l.type === e && !r) {
|
|
567
585
|
if (l.textContent.trim().length === 0)
|
|
568
586
|
return;
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
...
|
|
572
|
-
id:
|
|
587
|
+
const u = l.attrs, g = t(l);
|
|
588
|
+
u.id !== g && s.setMeta(j, !0).setNodeMarkup(i, void 0, {
|
|
589
|
+
...u,
|
|
590
|
+
id: g
|
|
573
591
|
});
|
|
574
592
|
}
|
|
575
|
-
}), a(
|
|
593
|
+
}), a(s);
|
|
576
594
|
};
|
|
577
|
-
return new
|
|
595
|
+
return new H({
|
|
578
596
|
key: j,
|
|
579
597
|
props: {
|
|
580
598
|
handleDOMEvents: {
|
|
581
599
|
compositionstart: () => (r = !0, !1),
|
|
582
600
|
compositionend: () => {
|
|
583
601
|
r = !1;
|
|
584
|
-
const
|
|
602
|
+
const o = c.get(B);
|
|
585
603
|
return setTimeout(() => {
|
|
586
|
-
n(
|
|
604
|
+
n(o.state, (a) => o.dispatch(a));
|
|
587
605
|
}, 0), !1;
|
|
588
606
|
}
|
|
589
607
|
}
|
|
590
608
|
},
|
|
591
|
-
appendTransaction: (
|
|
609
|
+
appendTransaction: (o, a, s) => {
|
|
592
610
|
let l = null;
|
|
593
|
-
return
|
|
611
|
+
return o.every((i) => !i.getMeta(j)) && o.some((i) => i.docChanged) && n(s, (i) => {
|
|
594
612
|
l = i;
|
|
595
613
|
}), l;
|
|
596
614
|
},
|
|
597
|
-
view: (
|
|
598
|
-
const a =
|
|
599
|
-
let
|
|
615
|
+
view: (o) => {
|
|
616
|
+
const a = o.state.doc;
|
|
617
|
+
let s = o.state.tr;
|
|
600
618
|
return a.descendants((l, i) => {
|
|
601
|
-
l.type.name === "heading" && l.attrs.level && (l.attrs.id || (
|
|
619
|
+
l.type.name === "heading" && l.attrs.level && (l.attrs.id || (s = s.setNodeMarkup(i, void 0, {
|
|
602
620
|
...l.attrs,
|
|
603
621
|
id: t(l)
|
|
604
622
|
})));
|
|
605
|
-
}),
|
|
623
|
+
}), o.dispatch(s), {};
|
|
606
624
|
}
|
|
607
625
|
});
|
|
608
|
-
},
|
|
609
|
-
key:
|
|
626
|
+
}, at = (c, e, t) => new H({
|
|
627
|
+
key: nt,
|
|
610
628
|
state: {
|
|
611
629
|
init: () => O.empty,
|
|
612
630
|
apply: (r) => {
|
|
613
|
-
const n = c.get(
|
|
631
|
+
const n = c.get(B);
|
|
614
632
|
if (!n.hasFocus || !n.editable)
|
|
615
633
|
return O.empty;
|
|
616
|
-
const { $from:
|
|
634
|
+
const { $from: o } = r.selection, a = o.node();
|
|
617
635
|
if (a.type !== e)
|
|
618
636
|
return O.empty;
|
|
619
|
-
const
|
|
620
|
-
i.textContent = l(
|
|
621
|
-
const
|
|
622
|
-
const
|
|
623
|
-
return
|
|
637
|
+
const s = a.attrs.level, l = (g) => Array(g).fill(0).map((d) => "#").join(""), i = document.createElement("span");
|
|
638
|
+
i.textContent = l(s), i.contentEditable = "false", t.themeManager.onFlush(() => {
|
|
639
|
+
const g = t.getStyle(({ css: d }) => {
|
|
640
|
+
const m = Te(t.themeManager);
|
|
641
|
+
return d`
|
|
624
642
|
margin-right: 4px;
|
|
625
|
-
color: ${
|
|
643
|
+
color: ${m("primary")};
|
|
626
644
|
`;
|
|
627
645
|
});
|
|
628
|
-
|
|
646
|
+
g && (i.className = g);
|
|
629
647
|
});
|
|
630
|
-
const
|
|
631
|
-
return O.create(r.doc, [
|
|
648
|
+
const u = J.widget(o.before() + 1, i, { side: -1 });
|
|
649
|
+
return O.create(r.doc, [u]);
|
|
632
650
|
}
|
|
633
651
|
},
|
|
634
652
|
props: {
|
|
@@ -642,9 +660,9 @@ const k = {
|
|
|
642
660
|
return this.getState(r);
|
|
643
661
|
}
|
|
644
662
|
}
|
|
645
|
-
}),
|
|
646
|
-
var
|
|
647
|
-
const t = "heading", r = (
|
|
663
|
+
}), lt = w((c, e) => {
|
|
664
|
+
var o, a;
|
|
665
|
+
const t = "heading", r = (o = e == null ? void 0 : e.getId) != null ? o : st, n = (a = e == null ? void 0 : e.displayHashtag) != null ? a : !0;
|
|
648
666
|
return {
|
|
649
667
|
id: t,
|
|
650
668
|
schema: () => ({
|
|
@@ -659,67 +677,67 @@ const k = {
|
|
|
659
677
|
default: 1
|
|
660
678
|
}
|
|
661
679
|
},
|
|
662
|
-
parseDOM: ke.map((
|
|
663
|
-
tag: `h${
|
|
680
|
+
parseDOM: ke.map((s) => ({
|
|
681
|
+
tag: `h${s}`,
|
|
664
682
|
getAttrs: (l) => {
|
|
665
683
|
if (!(l instanceof HTMLElement))
|
|
666
684
|
throw D(l);
|
|
667
|
-
return { level:
|
|
685
|
+
return { level: s, id: l.id };
|
|
668
686
|
}
|
|
669
687
|
})),
|
|
670
|
-
toDOM: (
|
|
671
|
-
`h${
|
|
688
|
+
toDOM: (s) => [
|
|
689
|
+
`h${s.attrs.level}`,
|
|
672
690
|
{
|
|
673
|
-
id:
|
|
674
|
-
class: c.getClassName(
|
|
691
|
+
id: s.attrs.id || r(s),
|
|
692
|
+
class: c.getClassName(s.attrs, `heading h${s.attrs.level}`)
|
|
675
693
|
},
|
|
676
694
|
0
|
|
677
695
|
],
|
|
678
696
|
parseMarkdown: {
|
|
679
|
-
match: ({ type:
|
|
680
|
-
runner: (
|
|
681
|
-
const
|
|
682
|
-
|
|
697
|
+
match: ({ type: s }) => s === t,
|
|
698
|
+
runner: (s, l, i) => {
|
|
699
|
+
const u = l.depth;
|
|
700
|
+
s.openNode(i, { level: u }), s.next(l.children), s.closeNode();
|
|
683
701
|
}
|
|
684
702
|
},
|
|
685
703
|
toMarkdown: {
|
|
686
|
-
match: (
|
|
687
|
-
runner: (
|
|
688
|
-
var
|
|
689
|
-
if (
|
|
690
|
-
const
|
|
691
|
-
l.content.forEach((
|
|
692
|
-
f !== l.childCount - 1 &&
|
|
693
|
-
}),
|
|
704
|
+
match: (s) => s.type.name === t,
|
|
705
|
+
runner: (s, l) => {
|
|
706
|
+
var u;
|
|
707
|
+
if (s.openNode("heading", void 0, { depth: l.attrs.level }), l.childCount >= 1 && ((u = l.lastChild) == null ? void 0 : u.type.name) === "hardbreak") {
|
|
708
|
+
const g = [];
|
|
709
|
+
l.content.forEach((d, m, f) => {
|
|
710
|
+
f !== l.childCount - 1 && g.push(d);
|
|
711
|
+
}), s.next(ge.fromArray(g));
|
|
694
712
|
} else
|
|
695
|
-
|
|
696
|
-
|
|
713
|
+
s.next(l.content);
|
|
714
|
+
s.closeNode();
|
|
697
715
|
}
|
|
698
716
|
}
|
|
699
717
|
}),
|
|
700
|
-
inputRules: (
|
|
701
|
-
const
|
|
702
|
-
if (
|
|
703
|
-
let
|
|
704
|
-
return
|
|
705
|
-
level:
|
|
718
|
+
inputRules: (s, l) => ke.map((i) => G(new RegExp(`^(#{1,${i}})\\s$`), s, () => {
|
|
719
|
+
const u = l.get(B), { $from: g } = u.state.selection, d = g.node();
|
|
720
|
+
if (d.type.name === "heading") {
|
|
721
|
+
let m = Number(d.attrs.level) + Number(i);
|
|
722
|
+
return m > 6 && (m = 6), {
|
|
723
|
+
level: m
|
|
706
724
|
};
|
|
707
725
|
}
|
|
708
726
|
return {
|
|
709
727
|
level: i
|
|
710
728
|
};
|
|
711
729
|
})),
|
|
712
|
-
commands: (
|
|
713
|
-
M(C, (i = 1) => i < 1 ? E(i === 0 && l.get(A).nodes.paragraph ||
|
|
714
|
-
M(Me, () => (i,
|
|
715
|
-
const { $from:
|
|
716
|
-
if (
|
|
730
|
+
commands: (s, l) => [
|
|
731
|
+
M(C, (i = 1) => i < 1 ? E(i === 0 && l.get(A).nodes.paragraph || s) : E(i === 0 && l.get(A).nodes.paragraph || s, { level: i })),
|
|
732
|
+
M(Me, () => (i, u, g) => {
|
|
733
|
+
const { $from: d } = i.selection, m = d.node();
|
|
734
|
+
if (m.type !== s || !i.selection.empty || d.parentOffset !== 0)
|
|
717
735
|
return !1;
|
|
718
|
-
const f =
|
|
719
|
-
return f ? (
|
|
720
|
-
...
|
|
736
|
+
const f = m.attrs.level - 1;
|
|
737
|
+
return f ? (u == null || u(i.tr.setNodeMarkup(i.selection.$from.before(), void 0, {
|
|
738
|
+
...m.attrs,
|
|
721
739
|
level: f
|
|
722
|
-
})), !0) : E(l.get(A).nodes.paragraph ||
|
|
740
|
+
})), !0) : E(l.get(A).nodes.paragraph || s)(i, u, g);
|
|
723
741
|
})
|
|
724
742
|
],
|
|
725
743
|
shortcuts: {
|
|
@@ -731,12 +749,12 @@ const k = {
|
|
|
731
749
|
[k.H6]: h(C, "Mod-Alt-6", 6),
|
|
732
750
|
[k.DowngradeHeading]: h(Me, ["Backspace", "Delete"])
|
|
733
751
|
},
|
|
734
|
-
prosePlugins: (
|
|
735
|
-
const i = [
|
|
736
|
-
return n && i.push(
|
|
752
|
+
prosePlugins: (s, l) => {
|
|
753
|
+
const i = [ot(l, s, r)];
|
|
754
|
+
return n && i.push(at(l, s, c)), i;
|
|
737
755
|
}
|
|
738
756
|
};
|
|
739
|
-
}), z = "hr", Ce = I("InsertHr"),
|
|
757
|
+
}), z = "hr", Ce = I("InsertHr"), ct = w((c) => ({
|
|
740
758
|
id: z,
|
|
741
759
|
schema: () => ({
|
|
742
760
|
group: "block",
|
|
@@ -756,23 +774,23 @@ const k = {
|
|
|
756
774
|
}
|
|
757
775
|
}),
|
|
758
776
|
inputRules: (e) => [
|
|
759
|
-
new me(/^(?:---|___\s|\*\*\*\s)$/, (t, r, n,
|
|
777
|
+
new me(/^(?:---|___\s|\*\*\*\s)$/, (t, r, n, o) => {
|
|
760
778
|
const { tr: a } = t;
|
|
761
|
-
return r[0] && a.replaceWith(n - 1,
|
|
779
|
+
return r[0] && a.replaceWith(n - 1, o, e.create()), a;
|
|
762
780
|
})
|
|
763
781
|
],
|
|
764
782
|
commands: (e, t) => [
|
|
765
783
|
M(Ce, () => (r, n) => {
|
|
766
784
|
if (!n)
|
|
767
785
|
return !0;
|
|
768
|
-
const
|
|
786
|
+
const o = t.get(A).node("paragraph"), { tr: a, selection: s } = r, { from: l } = s, i = e.create();
|
|
769
787
|
if (!i)
|
|
770
788
|
return !0;
|
|
771
|
-
const
|
|
772
|
-
return
|
|
789
|
+
const u = a.replaceSelectionWith(i).insert(l, o), g = Le.findFrom(u.doc.resolve(l), 1, !0);
|
|
790
|
+
return g && n(u.setSelection(g).scrollIntoView()), !0;
|
|
773
791
|
})
|
|
774
792
|
]
|
|
775
|
-
})), se = I("ModifyImage"), De = I("InsertImage"), S = "image",
|
|
793
|
+
})), se = I("ModifyImage"), De = I("InsertImage"), S = "image", it = new T("MILKDOWN_IMAGE_INPUT"), ut = w((c, e) => ({
|
|
776
794
|
id: "image",
|
|
777
795
|
schema: () => ({
|
|
778
796
|
inline: !0,
|
|
@@ -813,11 +831,11 @@ const k = {
|
|
|
813
831
|
parseMarkdown: {
|
|
814
832
|
match: ({ type: t }) => t === S,
|
|
815
833
|
runner: (t, r, n) => {
|
|
816
|
-
const
|
|
834
|
+
const o = r.url, a = r.alt, s = r.title;
|
|
817
835
|
t.addNode(n, {
|
|
818
|
-
src:
|
|
836
|
+
src: o,
|
|
819
837
|
alt: a,
|
|
820
|
-
title:
|
|
838
|
+
title: s
|
|
821
839
|
});
|
|
822
840
|
}
|
|
823
841
|
},
|
|
@@ -833,111 +851,111 @@ const k = {
|
|
|
833
851
|
}
|
|
834
852
|
}),
|
|
835
853
|
commands: (t) => [
|
|
836
|
-
M(De, (r = "") => (n,
|
|
837
|
-
if (!s)
|
|
838
|
-
return !0;
|
|
839
|
-
const { tr: a } = n, o = t.create({ src: r });
|
|
854
|
+
M(De, (r = "") => (n, o) => {
|
|
840
855
|
if (!o)
|
|
841
856
|
return !0;
|
|
842
|
-
const
|
|
843
|
-
|
|
857
|
+
const { tr: a } = n, s = t.create({ src: r });
|
|
858
|
+
if (!s)
|
|
859
|
+
return !0;
|
|
860
|
+
const l = a.replaceSelectionWith(s);
|
|
861
|
+
return o(l.scrollIntoView()), !0;
|
|
844
862
|
}),
|
|
845
|
-
M(se, (r = "") => (n,
|
|
863
|
+
M(se, (r = "") => (n, o) => {
|
|
846
864
|
const a = K(n.selection, t);
|
|
847
865
|
if (!a)
|
|
848
866
|
return !1;
|
|
849
|
-
const { tr:
|
|
850
|
-
return
|
|
867
|
+
const { tr: s } = n;
|
|
868
|
+
return o == null || o(s.setNodeMarkup(a.pos, void 0, { ...a.node.attrs, loading: !0, src: r }).scrollIntoView()), !0;
|
|
851
869
|
})
|
|
852
870
|
],
|
|
853
871
|
inputRules: (t) => [
|
|
854
|
-
new me(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/, (r, n,
|
|
855
|
-
const [
|
|
856
|
-
return
|
|
872
|
+
new me(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/, (r, n, o, a) => {
|
|
873
|
+
const [s, l, i = "", u] = n, { tr: g } = r;
|
|
874
|
+
return s && g.replaceWith(o, a, t.create({ src: i, alt: l, title: u })), g;
|
|
857
875
|
})
|
|
858
876
|
],
|
|
859
877
|
view: () => (t) => {
|
|
860
|
-
var i,
|
|
878
|
+
var i, u;
|
|
861
879
|
let r = t;
|
|
862
|
-
const n = (i = e == null ? void 0 : e.placeholder) != null ? i : "Add an Image",
|
|
880
|
+
const n = (i = e == null ? void 0 : e.placeholder) != null ? i : "Add an Image", o = (u = e == null ? void 0 : e.isBlock) != null ? u : !1, a = c.themeManager.get("image", {
|
|
863
881
|
placeholder: n,
|
|
864
|
-
isBlock:
|
|
882
|
+
isBlock: o
|
|
865
883
|
});
|
|
866
884
|
if (!a)
|
|
867
885
|
return {};
|
|
868
|
-
const { dom:
|
|
886
|
+
const { dom: s, onUpdate: l } = a;
|
|
869
887
|
return l(r), {
|
|
870
|
-
dom:
|
|
871
|
-
update: (
|
|
888
|
+
dom: s,
|
|
889
|
+
update: (g) => g.type.name !== S ? !1 : (r = g, l(r), !0),
|
|
872
890
|
selectNode: () => {
|
|
873
|
-
|
|
891
|
+
s.classList.add("ProseMirror-selectednode");
|
|
874
892
|
},
|
|
875
893
|
deselectNode: () => {
|
|
876
|
-
|
|
894
|
+
s.classList.remove("ProseMirror-selectednode");
|
|
877
895
|
}
|
|
878
896
|
};
|
|
879
897
|
},
|
|
880
898
|
prosePlugins: (t, r) => [
|
|
881
|
-
new
|
|
882
|
-
key:
|
|
899
|
+
new H({
|
|
900
|
+
key: it,
|
|
883
901
|
view: (n) => {
|
|
884
|
-
var i,
|
|
885
|
-
const
|
|
886
|
-
placeholder: (
|
|
887
|
-
buttonText: (
|
|
888
|
-
onUpdate: (
|
|
889
|
-
r.get(we).call(se,
|
|
902
|
+
var i, u, g;
|
|
903
|
+
const o = c.themeManager.get("input-chip", {
|
|
904
|
+
placeholder: (u = (i = e == null ? void 0 : e.input) == null ? void 0 : i.placeholder) != null ? u : "Input Image Link",
|
|
905
|
+
buttonText: (g = e == null ? void 0 : e.input) == null ? void 0 : g.buttonText,
|
|
906
|
+
onUpdate: (d) => {
|
|
907
|
+
r.get(we).call(se, d);
|
|
890
908
|
}
|
|
891
909
|
});
|
|
892
|
-
if (!
|
|
910
|
+
if (!o)
|
|
893
911
|
return {};
|
|
894
|
-
const a = (
|
|
895
|
-
const
|
|
896
|
-
return
|
|
897
|
-
}, l = (
|
|
898
|
-
if (!
|
|
912
|
+
const a = (d) => Boolean(d.hasFocus() && t && K(d.state.selection, t)), s = (d) => {
|
|
913
|
+
const m = K(d.state.selection, t);
|
|
914
|
+
return m ? m.node.attrs.src : void 0;
|
|
915
|
+
}, l = (d) => {
|
|
916
|
+
if (!d.editable)
|
|
899
917
|
return;
|
|
900
|
-
a(
|
|
918
|
+
a(d) ? (o.show(d), o.update(s(d))) : o.hide();
|
|
901
919
|
};
|
|
902
|
-
return
|
|
903
|
-
update: (
|
|
904
|
-
(
|
|
920
|
+
return o.init(n), l(n), {
|
|
921
|
+
update: (d, m) => {
|
|
922
|
+
(m == null ? void 0 : m.doc.eq(d.state.doc)) && m.selection.eq(d.state.selection) || l(d);
|
|
905
923
|
},
|
|
906
924
|
destroy: () => {
|
|
907
|
-
|
|
925
|
+
o.destroy();
|
|
908
926
|
}
|
|
909
927
|
};
|
|
910
928
|
}
|
|
911
929
|
})
|
|
912
930
|
]
|
|
913
|
-
})), Ie = "list_item", oe = I("SplitListItem"), ae = I("SinkListItem"), le = I("LiftListItem"),
|
|
931
|
+
})), Ie = "list_item", oe = I("SplitListItem"), ae = I("SinkListItem"), le = I("LiftListItem"), dt = new T("MILKDOWN_KEEP_LIST_ORDER"), mt = (c) => {
|
|
914
932
|
const e = (t, r) => {
|
|
915
933
|
const n = Ee("ordered_list", t.schema);
|
|
916
|
-
let
|
|
917
|
-
t.doc.descendants((a,
|
|
934
|
+
let o = t.tr;
|
|
935
|
+
t.doc.descendants((a, s, l, i) => {
|
|
918
936
|
if (a.type === c && (l == null ? void 0 : l.type) === n) {
|
|
919
|
-
let
|
|
920
|
-
const
|
|
921
|
-
a.attrs.listType !== "ordered" && (
|
|
922
|
-
const
|
|
923
|
-
if (
|
|
924
|
-
const
|
|
925
|
-
|
|
937
|
+
let u = !1;
|
|
938
|
+
const g = { ...a.attrs };
|
|
939
|
+
a.attrs.listType !== "ordered" && (g.listType = "ordered", u = !0);
|
|
940
|
+
const d = l == null ? void 0 : l.maybeChild(i - 1);
|
|
941
|
+
if (d && d.type === c && d.attrs.listType === "ordered") {
|
|
942
|
+
const m = d.attrs.label;
|
|
943
|
+
g.label = `${Number(m.slice(0, -1)) + 1}.`, u = !0;
|
|
926
944
|
}
|
|
927
|
-
a.attrs.label === "\u2022" && (
|
|
945
|
+
a.attrs.label === "\u2022" && (g.label = `${i + 1}.`, u = !0), u && (o = o.setNodeMarkup(s, void 0, g));
|
|
928
946
|
}
|
|
929
|
-
}), r(
|
|
947
|
+
}), r(o);
|
|
930
948
|
};
|
|
931
|
-
return new
|
|
932
|
-
key:
|
|
949
|
+
return new H({
|
|
950
|
+
key: dt,
|
|
933
951
|
appendTransaction: (t, r, n) => {
|
|
934
|
-
let
|
|
952
|
+
let o = null;
|
|
935
953
|
return t.some((a) => a.docChanged) && e(n, (a) => {
|
|
936
|
-
|
|
937
|
-
}),
|
|
954
|
+
o = a;
|
|
955
|
+
}), o;
|
|
938
956
|
}
|
|
939
957
|
});
|
|
940
|
-
},
|
|
958
|
+
}, gt = w((c) => ({
|
|
941
959
|
id: Ie,
|
|
942
960
|
schema: () => ({
|
|
943
961
|
group: "listItem",
|
|
@@ -979,8 +997,8 @@ const k = {
|
|
|
979
997
|
parseMarkdown: {
|
|
980
998
|
match: ({ type: e, checked: t }) => e === "listItem" && t === null,
|
|
981
999
|
runner: (e, t, r) => {
|
|
982
|
-
const n = t.label != null ? `${t.label}.` : "\u2022",
|
|
983
|
-
e.openNode(r, { label: n, listType:
|
|
1000
|
+
const n = t.label != null ? `${t.label}.` : "\u2022", o = t.label != null ? "ordered" : "bullet";
|
|
1001
|
+
e.openNode(r, { label: n, listType: o }), e.next(t.children), e.closeNode();
|
|
984
1002
|
}
|
|
985
1003
|
},
|
|
986
1004
|
toMarkdown: {
|
|
@@ -992,8 +1010,8 @@ const k = {
|
|
|
992
1010
|
}),
|
|
993
1011
|
inputRules: (e) => [W(/^\s*([-+*])\s$/, e)],
|
|
994
1012
|
commands: (e) => [
|
|
995
|
-
M(oe, () =>
|
|
996
|
-
M(ae, () =>
|
|
1013
|
+
M(oe, () => Re(e)),
|
|
1014
|
+
M(ae, () => Be(e)),
|
|
997
1015
|
M(le, () => Pe(e))
|
|
998
1016
|
],
|
|
999
1017
|
shortcuts: {
|
|
@@ -1001,8 +1019,8 @@ const k = {
|
|
|
1001
1019
|
[k.SinkListItem]: h(ae, "Mod-]"),
|
|
1002
1020
|
[k.LiftListItem]: h(le, "Mod-[")
|
|
1003
1021
|
},
|
|
1004
|
-
prosePlugins: (e) => [
|
|
1005
|
-
})), ce = I("WrapInOrderedList"), be = "ordered_list",
|
|
1022
|
+
prosePlugins: (e) => [mt(e)]
|
|
1023
|
+
})), ce = I("WrapInOrderedList"), be = "ordered_list", ft = w((c) => ({
|
|
1006
1024
|
id: be,
|
|
1007
1025
|
schema: () => ({
|
|
1008
1026
|
content: "listItem+",
|
|
@@ -1050,7 +1068,7 @@ const k = {
|
|
|
1050
1068
|
shortcuts: {
|
|
1051
1069
|
[k.OrderedList]: h(ce, "Mod-Alt-7")
|
|
1052
1070
|
}
|
|
1053
|
-
})), ie = I("TurnIntoText"), ye = "paragraph",
|
|
1071
|
+
})), ie = I("TurnIntoText"), ye = "paragraph", pt = w((c) => ({
|
|
1054
1072
|
id: ye,
|
|
1055
1073
|
schema: () => ({
|
|
1056
1074
|
content: "inline*",
|
|
@@ -1068,10 +1086,10 @@ const k = {
|
|
|
1068
1086
|
runner: (e, t) => {
|
|
1069
1087
|
var n;
|
|
1070
1088
|
if (e.openNode("paragraph"), t.childCount >= 1 && ((n = t.lastChild) == null ? void 0 : n.type.name) === "hardbreak") {
|
|
1071
|
-
const
|
|
1072
|
-
t.content.forEach((a,
|
|
1073
|
-
l !== t.childCount - 1 &&
|
|
1074
|
-
}), e.next(ge.fromArray(
|
|
1089
|
+
const o = [];
|
|
1090
|
+
t.content.forEach((a, s, l) => {
|
|
1091
|
+
l !== t.childCount - 1 && o.push(a);
|
|
1092
|
+
}), e.next(ge.fromArray(o));
|
|
1075
1093
|
} else
|
|
1076
1094
|
e.next(t.content);
|
|
1077
1095
|
e.closeNode();
|
|
@@ -1082,7 +1100,7 @@ const k = {
|
|
|
1082
1100
|
shortcuts: {
|
|
1083
1101
|
[k.Text]: h(ie, "Mod-Alt-0")
|
|
1084
1102
|
}
|
|
1085
|
-
})),
|
|
1103
|
+
})), ht = w(() => ({
|
|
1086
1104
|
id: "text",
|
|
1087
1105
|
schema: () => ({
|
|
1088
1106
|
group: "inline",
|
|
@@ -1099,62 +1117,62 @@ const k = {
|
|
|
1099
1117
|
}
|
|
1100
1118
|
}
|
|
1101
1119
|
})
|
|
1102
|
-
})),
|
|
1120
|
+
})), kt = [
|
|
1103
1121
|
et(),
|
|
1104
|
-
|
|
1105
|
-
|
|
1122
|
+
pt(),
|
|
1123
|
+
rt(),
|
|
1106
1124
|
Ge(),
|
|
1107
1125
|
Ze(),
|
|
1108
1126
|
Je(),
|
|
1127
|
+
ft(),
|
|
1109
1128
|
gt(),
|
|
1110
|
-
mt(),
|
|
1111
|
-
at(),
|
|
1112
1129
|
lt(),
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1130
|
+
ct(),
|
|
1131
|
+
ut(),
|
|
1132
|
+
ht()
|
|
1133
|
+
], Mt = () => {
|
|
1116
1134
|
function c(e) {
|
|
1117
1135
|
qe(e, "list", (t) => {
|
|
1118
1136
|
var r;
|
|
1119
1137
|
if (t.ordered) {
|
|
1120
1138
|
const n = (r = t.start) != null ? r : 1;
|
|
1121
|
-
t.children.forEach((
|
|
1122
|
-
|
|
1139
|
+
t.children.forEach((o, a) => {
|
|
1140
|
+
o.label = a + n;
|
|
1123
1141
|
});
|
|
1124
1142
|
return;
|
|
1125
1143
|
}
|
|
1126
1144
|
});
|
|
1127
1145
|
}
|
|
1128
1146
|
return c;
|
|
1129
|
-
},
|
|
1130
|
-
function
|
|
1147
|
+
}, It = (c) => !!c.children, bt = (c) => c.type === "html";
|
|
1148
|
+
function yt(c, e) {
|
|
1131
1149
|
return t(c, 0, null)[0];
|
|
1132
|
-
function t(r, n,
|
|
1133
|
-
if (
|
|
1150
|
+
function t(r, n, o) {
|
|
1151
|
+
if (It(r)) {
|
|
1134
1152
|
const a = [];
|
|
1135
|
-
for (let
|
|
1136
|
-
const i = r.children[
|
|
1153
|
+
for (let s = 0, l = r.children.length; s < l; s++) {
|
|
1154
|
+
const i = r.children[s];
|
|
1137
1155
|
if (i) {
|
|
1138
|
-
const
|
|
1139
|
-
if (
|
|
1140
|
-
for (let
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1156
|
+
const u = t(i, s, r);
|
|
1157
|
+
if (u)
|
|
1158
|
+
for (let g = 0, d = u.length; g < d; g++) {
|
|
1159
|
+
const m = u[g];
|
|
1160
|
+
m && a.push(m);
|
|
1143
1161
|
}
|
|
1144
1162
|
}
|
|
1145
1163
|
}
|
|
1146
1164
|
r.children = a;
|
|
1147
1165
|
}
|
|
1148
|
-
return e(r, n,
|
|
1166
|
+
return e(r, n, o);
|
|
1149
1167
|
}
|
|
1150
1168
|
}
|
|
1151
|
-
const
|
|
1169
|
+
const Nt = () => {
|
|
1152
1170
|
function c(e) {
|
|
1153
|
-
|
|
1171
|
+
yt(e, (t) => bt(t) ? [] : [t]);
|
|
1154
1172
|
}
|
|
1155
1173
|
return c;
|
|
1156
|
-
},
|
|
1157
|
-
key:
|
|
1174
|
+
}, wt = new T("MILKDOWN_INLINE_NODES_CURSOR"), ue = new H({
|
|
1175
|
+
key: wt,
|
|
1158
1176
|
state: {
|
|
1159
1177
|
init() {
|
|
1160
1178
|
return !1;
|
|
@@ -1178,22 +1196,22 @@ const yt = () => {
|
|
|
1178
1196
|
},
|
|
1179
1197
|
decorations(c) {
|
|
1180
1198
|
if (ue.getState(c)) {
|
|
1181
|
-
const r = c.selection.$from.pos, n = document.createElement("span"),
|
|
1199
|
+
const r = c.selection.$from.pos, n = document.createElement("span"), o = J.widget(r, n, {
|
|
1182
1200
|
side: -1
|
|
1183
|
-
}), a = document.createElement("span"),
|
|
1201
|
+
}), a = document.createElement("span"), s = J.widget(r, a);
|
|
1184
1202
|
return setTimeout(() => {
|
|
1185
1203
|
n.contentEditable = "true", a.contentEditable = "true";
|
|
1186
|
-
}), O.create(c.doc, [
|
|
1204
|
+
}), O.create(c.doc, [o, s]);
|
|
1187
1205
|
}
|
|
1188
1206
|
return O.empty;
|
|
1189
1207
|
}
|
|
1190
1208
|
}
|
|
1191
|
-
}),
|
|
1209
|
+
}), Lt = [
|
|
1192
1210
|
He(() => ({
|
|
1193
1211
|
prosePlugins: () => [ue],
|
|
1194
|
-
remarkPlugins: () => [We,
|
|
1212
|
+
remarkPlugins: () => [We, Nt, Mt]
|
|
1195
1213
|
}))()
|
|
1196
|
-
],
|
|
1214
|
+
], xt = Ne.create([...kt, ...ze]), Pt = Ne.create([...Lt, ...xt]), Wt = {
|
|
1197
1215
|
ToggleInlineCode: Q,
|
|
1198
1216
|
ToggleItalic: X,
|
|
1199
1217
|
ToggleLink: xe,
|
|
@@ -1215,6 +1233,7 @@ const yt = () => {
|
|
|
1215
1233
|
};
|
|
1216
1234
|
export {
|
|
1217
1235
|
Me as DowngradeHeading,
|
|
1236
|
+
tt as HardbreakFilterPluginKey,
|
|
1218
1237
|
ne as InsertHardbreak,
|
|
1219
1238
|
Ce as InsertHr,
|
|
1220
1239
|
De as InsertImage,
|
|
@@ -1239,26 +1258,26 @@ export {
|
|
|
1239
1258
|
Je as bulletList,
|
|
1240
1259
|
Ze as codeFence,
|
|
1241
1260
|
Ke as codeInline,
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1261
|
+
Wt as commands,
|
|
1262
|
+
Pt as commonmark,
|
|
1263
|
+
xt as commonmarkNodes,
|
|
1264
|
+
Lt as commonmarkPlugins,
|
|
1246
1265
|
et as doc,
|
|
1247
1266
|
Fe as em,
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1267
|
+
rt as hardbreak,
|
|
1268
|
+
lt as heading,
|
|
1269
|
+
nt as headingHashPluginKey,
|
|
1251
1270
|
j as headingIdPluginKey,
|
|
1252
|
-
|
|
1253
|
-
|
|
1271
|
+
ct as hr,
|
|
1272
|
+
ut as image,
|
|
1254
1273
|
Ve as link,
|
|
1255
|
-
|
|
1274
|
+
gt as listItem,
|
|
1256
1275
|
ze as marks,
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1276
|
+
kt as nodes,
|
|
1277
|
+
ft as orderedList,
|
|
1278
|
+
pt as paragraph,
|
|
1260
1279
|
je as strong,
|
|
1261
|
-
|
|
1280
|
+
ht as text,
|
|
1262
1281
|
Ye as tildeInputRegex
|
|
1263
1282
|
};
|
|
1264
1283
|
//# sourceMappingURL=index.es.js.map
|