@milkdown/preset-commonmark 6.4.1 → 6.4.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 +222 -215
- package/lib/index.es.js.map +1 -1
- package/lib/plugin/inline-sync/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/plugin/inline-sync/index.ts +12 -1
package/lib/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMark as R, createShortcut as h, createNode as w, pipe as Oe, createPlugin as Se, AtomList as be } from "@milkdown/utils";
|
|
2
|
-
import { createCmdKey as y, createCmd as M, commandsCtx as we, editorViewCtx as
|
|
3
|
-
import { toggleMark as me, wrapIn as pe, setBlockType as
|
|
2
|
+
import { createCmdKey as y, createCmd as M, commandsCtx as we, editorViewCtx as S, schemaCtx as P, getPalette as Ae, createSlice as Ee, serializerCtx as ve, parserCtx as _e } from "@milkdown/core";
|
|
3
|
+
import { toggleMark as me, wrapIn as pe, setBlockType as A } from "@milkdown/prose/commands";
|
|
4
4
|
import { expectDomTypeError as L, missingRootElement as $e } from "@milkdown/exception";
|
|
5
5
|
import { calculateTextPosition as Pe, cloneTr as Be, findSelectedNodeOfType as K, getNodeFromSchema as Re } from "@milkdown/prose";
|
|
6
6
|
import { PluginKey as T, TextSelection as J, Plugin as x, NodeSelection as We, Selection as Le } from "@milkdown/prose/state";
|
|
@@ -54,13 +54,13 @@ const k = {
|
|
|
54
54
|
}),
|
|
55
55
|
commands: (e) => [
|
|
56
56
|
M(Z, () => (t, r) => {
|
|
57
|
-
const { selection: n, tr:
|
|
57
|
+
const { selection: n, tr: o } = t;
|
|
58
58
|
if (n.empty)
|
|
59
59
|
return !1;
|
|
60
|
-
const { from: l, to:
|
|
61
|
-
return t.doc.rangeHasMark(l,
|
|
62
|
-
|
|
63
|
-
}), r == null || r(
|
|
60
|
+
const { from: l, to: s } = n;
|
|
61
|
+
return t.doc.rangeHasMark(l, s, e) ? (r == null || r(o.removeMark(l, s, e)), !0) : (Object.keys(t.schema.marks).filter((u) => u !== e.name).map((u) => t.schema.marks[u]).forEach((u) => {
|
|
62
|
+
o.removeMark(l, s, u);
|
|
63
|
+
}), r == null || r(o.addMark(l, s, e.create())), !0);
|
|
64
64
|
})
|
|
65
65
|
],
|
|
66
66
|
shortcuts: {
|
|
@@ -114,8 +114,8 @@ const k = {
|
|
|
114
114
|
parseMarkdown: {
|
|
115
115
|
match: (t) => t.type === "link",
|
|
116
116
|
runner: (t, r, n) => {
|
|
117
|
-
const
|
|
118
|
-
t.openMark(n, { href:
|
|
117
|
+
const o = r.url, l = r.title;
|
|
118
|
+
t.openMark(n, { href: o, title: l }), t.next(r.children), t.closeMark(n);
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
121
|
toMarkdown: {
|
|
@@ -130,24 +130,24 @@ const k = {
|
|
|
130
130
|
}),
|
|
131
131
|
commands: (t) => [
|
|
132
132
|
M(xe, (r = "") => me(t, { href: r })),
|
|
133
|
-
M(te, (r = "") => (n,
|
|
133
|
+
M(te, (r = "") => (n, o) => {
|
|
134
134
|
var I;
|
|
135
|
-
if (!
|
|
135
|
+
if (!o)
|
|
136
136
|
return !1;
|
|
137
137
|
const { marks: l } = n.schema;
|
|
138
|
-
let
|
|
138
|
+
let s, c = -1;
|
|
139
139
|
const { selection: i } = n, { from: u, to: f } = i;
|
|
140
140
|
if (n.doc.nodesBetween(u, u === f ? f + 1 : f, (b, H) => {
|
|
141
141
|
var C;
|
|
142
142
|
if ((C = l.link) != null && C.isInSet(b.marks))
|
|
143
|
-
return
|
|
144
|
-
}), !
|
|
143
|
+
return s = b, c = H, !1;
|
|
144
|
+
}), !s)
|
|
145
145
|
return !1;
|
|
146
|
-
const d =
|
|
146
|
+
const d = s.marks.find(({ type: b }) => b === t);
|
|
147
147
|
if (!d)
|
|
148
148
|
return !1;
|
|
149
|
-
const m = c, p = c +
|
|
150
|
-
return N ? (
|
|
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(g.removeMark(m, p, d).addMark(m, p, N).setSelection(new J(g.selection.$anchor)).scrollIntoView()), !0) : !1;
|
|
151
151
|
})
|
|
152
152
|
],
|
|
153
153
|
prosePlugins: (t, r) => {
|
|
@@ -155,7 +155,7 @@ const k = {
|
|
|
155
155
|
return [
|
|
156
156
|
new x({
|
|
157
157
|
key: Je,
|
|
158
|
-
view: (
|
|
158
|
+
view: (o) => {
|
|
159
159
|
var u, f, d;
|
|
160
160
|
const l = a.themeManager.get("input-chip", {
|
|
161
161
|
placeholder: (f = (u = e == null ? void 0 : e.input) == null ? void 0 : u.placeholder) != null ? f : "Input Web Link",
|
|
@@ -176,7 +176,7 @@ const k = {
|
|
|
176
176
|
});
|
|
177
177
|
if (!l)
|
|
178
178
|
return {};
|
|
179
|
-
const
|
|
179
|
+
const s = (m) => {
|
|
180
180
|
const { selection: p, doc: g } = m.state, { from: N, to: I } = p;
|
|
181
181
|
if (!m.hasFocus())
|
|
182
182
|
return !1;
|
|
@@ -202,9 +202,9 @@ const k = {
|
|
|
202
202
|
}, i = (m) => {
|
|
203
203
|
if (!m.editable)
|
|
204
204
|
return;
|
|
205
|
-
|
|
205
|
+
s(m) ? (l.show(m), l.update(c(m))) : l.hide();
|
|
206
206
|
};
|
|
207
|
-
return l.init(
|
|
207
|
+
return l.init(o), i(o), {
|
|
208
208
|
update: (m, p) => {
|
|
209
209
|
(p == null ? void 0 : p.doc.eq(m.state.doc)) && p.selection.eq(m.state.selection) || requestAnimationFrame(() => {
|
|
210
210
|
i(m);
|
|
@@ -306,8 +306,8 @@ const k = {
|
|
|
306
306
|
parseMarkdown: {
|
|
307
307
|
match: ({ type: t, ordered: r }) => t === "list" && !r,
|
|
308
308
|
runner: (t, r, n) => {
|
|
309
|
-
const
|
|
310
|
-
t.openNode(n, { spread:
|
|
309
|
+
const o = r.spread != null ? `${r.spread}` : "false";
|
|
310
|
+
t.openNode(n, { spread: o }).next(r.children).closeNode();
|
|
311
311
|
}
|
|
312
312
|
},
|
|
313
313
|
toMarkdown: {
|
|
@@ -363,20 +363,20 @@ const k = {
|
|
|
363
363
|
tag: "div.code-fence-container",
|
|
364
364
|
preserveWhitespace: "full",
|
|
365
365
|
getAttrs: (n) => {
|
|
366
|
-
var
|
|
366
|
+
var o;
|
|
367
367
|
if (!(n instanceof HTMLElement))
|
|
368
368
|
throw L(n);
|
|
369
|
-
return { language: (
|
|
369
|
+
return { language: (o = n.querySelector("pre")) == null ? void 0 : o.dataset.language };
|
|
370
370
|
},
|
|
371
|
-
getContent: (n,
|
|
371
|
+
getContent: (n, o) => {
|
|
372
372
|
var c, i;
|
|
373
373
|
if (!(n instanceof HTMLElement))
|
|
374
374
|
throw L(n);
|
|
375
375
|
const l = (i = (c = n.querySelector("pre")) == null ? void 0 : c.textContent) != null ? i : "";
|
|
376
376
|
if (!l)
|
|
377
377
|
return B.empty;
|
|
378
|
-
const
|
|
379
|
-
return B.from(
|
|
378
|
+
const s = o.text(l);
|
|
379
|
+
return B.from(s);
|
|
380
380
|
}
|
|
381
381
|
},
|
|
382
382
|
{
|
|
@@ -390,33 +390,33 @@ const k = {
|
|
|
390
390
|
}
|
|
391
391
|
],
|
|
392
392
|
toDOM: (n) => {
|
|
393
|
-
const
|
|
393
|
+
const o = document.createElement("select");
|
|
394
394
|
return t.forEach((l) => {
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
}),
|
|
398
|
-
const
|
|
399
|
-
if (!(
|
|
395
|
+
const s = document.createElement("option");
|
|
396
|
+
s.value = l, s.innerText = l || "--", l === n.attrs.language && (s.selected = !0), o.appendChild(s);
|
|
397
|
+
}), o.onchange = (l) => {
|
|
398
|
+
const s = l.target;
|
|
399
|
+
if (!(s instanceof HTMLSelectElement))
|
|
400
400
|
return;
|
|
401
|
-
const c = r.get(
|
|
401
|
+
const c = r.get(S);
|
|
402
402
|
if (!c.editable) {
|
|
403
|
-
|
|
403
|
+
s.value = n.attrs.language;
|
|
404
404
|
return;
|
|
405
405
|
}
|
|
406
|
-
const { top: i, left: u } =
|
|
406
|
+
const { top: i, left: u } = s.getBoundingClientRect(), f = c.posAtCoords({ top: i, left: u });
|
|
407
407
|
if (!f)
|
|
408
408
|
return;
|
|
409
409
|
const { tr: d } = c.state;
|
|
410
410
|
c.dispatch(d.setNodeMarkup(f.inside, void 0, {
|
|
411
411
|
...n.attrs,
|
|
412
|
-
language:
|
|
412
|
+
language: s.value
|
|
413
413
|
}));
|
|
414
414
|
}, [
|
|
415
415
|
"div",
|
|
416
416
|
{
|
|
417
417
|
class: "code-fence-container"
|
|
418
418
|
},
|
|
419
|
-
|
|
419
|
+
o,
|
|
420
420
|
[
|
|
421
421
|
"pre",
|
|
422
422
|
{
|
|
@@ -429,61 +429,61 @@ const k = {
|
|
|
429
429
|
},
|
|
430
430
|
parseMarkdown: {
|
|
431
431
|
match: ({ type: n }) => n === "code",
|
|
432
|
-
runner: (n,
|
|
433
|
-
const
|
|
434
|
-
n.openNode(l, { language:
|
|
432
|
+
runner: (n, o, l) => {
|
|
433
|
+
const s = o.lang, c = o.value;
|
|
434
|
+
n.openNode(l, { language: s }), c && n.addText(c), n.closeNode();
|
|
435
435
|
}
|
|
436
436
|
},
|
|
437
437
|
toMarkdown: {
|
|
438
438
|
match: (n) => n.type.name === z,
|
|
439
|
-
runner: (n,
|
|
439
|
+
runner: (n, o) => {
|
|
440
440
|
var l;
|
|
441
|
-
n.addNode("code", void 0, ((l =
|
|
442
|
-
lang:
|
|
441
|
+
n.addNode("code", void 0, ((l = o.content.firstChild) == null ? void 0 : l.text) || "", {
|
|
442
|
+
lang: o.attrs.language
|
|
443
443
|
});
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
}),
|
|
447
447
|
inputRules: (r) => [
|
|
448
448
|
Q(nt, r, (n) => {
|
|
449
|
-
const [
|
|
450
|
-
if (!!
|
|
449
|
+
const [o, l] = n;
|
|
450
|
+
if (!!o)
|
|
451
451
|
return { language: l };
|
|
452
452
|
}),
|
|
453
453
|
Q(st, r, (n) => {
|
|
454
|
-
const [
|
|
455
|
-
if (!!
|
|
454
|
+
const [o, l] = n;
|
|
455
|
+
if (!!o)
|
|
456
456
|
return { language: l };
|
|
457
457
|
})
|
|
458
458
|
],
|
|
459
|
-
commands: (r) => [M(oe, () =>
|
|
459
|
+
commands: (r) => [M(oe, () => A(r))],
|
|
460
460
|
shortcuts: {
|
|
461
461
|
[k.CodeFence]: h(oe, "Mod-Alt-c")
|
|
462
462
|
},
|
|
463
|
-
view: () => (r, n,
|
|
463
|
+
view: () => (r, n, o) => {
|
|
464
464
|
let l = r;
|
|
465
|
-
const
|
|
465
|
+
const s = (g) => {
|
|
466
466
|
const { tr: N } = n.state;
|
|
467
|
-
n.dispatch(N.setNodeMarkup(
|
|
467
|
+
n.dispatch(N.setNodeMarkup(o(), void 0, {
|
|
468
468
|
fold: !0,
|
|
469
469
|
language: g
|
|
470
470
|
}));
|
|
471
471
|
}, c = () => {
|
|
472
472
|
const { tr: g } = n.state;
|
|
473
|
-
n.dispatch(g.setNodeMarkup(
|
|
473
|
+
n.dispatch(g.setNodeMarkup(o(), void 0, {
|
|
474
474
|
...l.attrs,
|
|
475
475
|
fold: !0
|
|
476
476
|
}));
|
|
477
477
|
}, i = () => {
|
|
478
478
|
const { tr: g } = n.state;
|
|
479
|
-
n.dispatch(g.setNodeMarkup(
|
|
479
|
+
n.dispatch(g.setNodeMarkup(o(), void 0, {
|
|
480
480
|
...l.attrs,
|
|
481
481
|
fold: !1
|
|
482
482
|
}));
|
|
483
483
|
}, u = a.themeManager.get("code-fence", {
|
|
484
484
|
onBlur: c,
|
|
485
485
|
onFocus: i,
|
|
486
|
-
onSelectLanguage:
|
|
486
|
+
onSelectLanguage: s,
|
|
487
487
|
editable: () => n.editable,
|
|
488
488
|
languageList: t
|
|
489
489
|
});
|
|
@@ -528,7 +528,7 @@ const k = {
|
|
|
528
528
|
toDOM: (n) => ["br", { class: a.getClassName(n.attrs, "hardbreak") }],
|
|
529
529
|
parseMarkdown: {
|
|
530
530
|
match: ({ type: n }) => n === "break",
|
|
531
|
-
runner: (n,
|
|
531
|
+
runner: (n, o, l) => {
|
|
532
532
|
n.addNode(l);
|
|
533
533
|
}
|
|
534
534
|
},
|
|
@@ -540,13 +540,13 @@ const k = {
|
|
|
540
540
|
}
|
|
541
541
|
}),
|
|
542
542
|
commands: (n) => [
|
|
543
|
-
M(ae, () => (
|
|
543
|
+
M(ae, () => (o, l) => {
|
|
544
544
|
var i;
|
|
545
|
-
const { selection:
|
|
546
|
-
if (
|
|
547
|
-
const u =
|
|
545
|
+
const { selection: s, tr: c } = o;
|
|
546
|
+
if (s.empty) {
|
|
547
|
+
const u = s.$from.node();
|
|
548
548
|
if (u.childCount > 0 && ((i = u.lastChild) == null ? void 0 : i.type.name) === "hardbreak")
|
|
549
|
-
return l == null || l(c.replaceRangeWith(
|
|
549
|
+
return l == null || l(c.replaceRangeWith(s.to - 1, s.to, o.schema.node("paragraph")).setSelection(Le.near(c.doc.resolve(s.to))).scrollIntoView()), !0;
|
|
550
550
|
}
|
|
551
551
|
return l == null || l(c.setMeta("hardbreak", !0).replaceSelectionWith(n.create()).scrollIntoView()), !0;
|
|
552
552
|
})
|
|
@@ -557,9 +557,9 @@ const k = {
|
|
|
557
557
|
prosePlugins: (n) => [
|
|
558
558
|
new x({
|
|
559
559
|
key: lt,
|
|
560
|
-
filterTransaction: (
|
|
561
|
-
const
|
|
562
|
-
if (
|
|
560
|
+
filterTransaction: (o, l) => {
|
|
561
|
+
const s = o.getMeta("hardbreak"), [c] = o.steps;
|
|
562
|
+
if (s && c) {
|
|
563
563
|
const { from: i } = c, u = l.doc.resolve(i);
|
|
564
564
|
let f = u.depth, d = !0;
|
|
565
565
|
for (; f > 0; )
|
|
@@ -571,10 +571,10 @@ const k = {
|
|
|
571
571
|
}),
|
|
572
572
|
new x({
|
|
573
573
|
key: new T("MILKDOWN_HARDBREAK_MARKS"),
|
|
574
|
-
appendTransaction: (
|
|
575
|
-
if (!
|
|
574
|
+
appendTransaction: (o, l, s) => {
|
|
575
|
+
if (!o.length)
|
|
576
576
|
return;
|
|
577
|
-
const [c] =
|
|
577
|
+
const [c] = o;
|
|
578
578
|
if (!c)
|
|
579
579
|
return;
|
|
580
580
|
const [i] = c.steps;
|
|
@@ -582,12 +582,12 @@ const k = {
|
|
|
582
582
|
if (!(i instanceof qe))
|
|
583
583
|
return;
|
|
584
584
|
const { from: d } = i;
|
|
585
|
-
return
|
|
585
|
+
return s.tr.setNodeMarkup(d, n, void 0, []);
|
|
586
586
|
}
|
|
587
587
|
if (i instanceof Ke) {
|
|
588
|
-
let d =
|
|
588
|
+
let d = s.tr;
|
|
589
589
|
const { from: m, to: p } = i;
|
|
590
|
-
return
|
|
590
|
+
return s.doc.nodesBetween(m, p, (g, N) => {
|
|
591
591
|
g.type === n && (d = d.setNodeMarkup(N, n, void 0, []));
|
|
592
592
|
}), d;
|
|
593
593
|
}
|
|
@@ -597,20 +597,20 @@ const k = {
|
|
|
597
597
|
};
|
|
598
598
|
}), ke = Array(6).fill(0).map((a, e) => e + 1), D = y("TurnIntoHeading"), Me = y("DowngradeHeading"), U = new T("MILKDOWN_HEADING_ID"), it = new T("MILKDOWN_HEADING_HASH"), ut = (a) => a.textContent.replace(/[\p{P}\p{S}]/gu, "").replace(/\s/g, "-").toLowerCase().trim(), dt = (a, e, t) => {
|
|
599
599
|
let r = !1;
|
|
600
|
-
const n = (
|
|
601
|
-
const
|
|
600
|
+
const n = (o, l) => {
|
|
601
|
+
const s = o.tr.setMeta("addToHistory", !1);
|
|
602
602
|
let c = !1;
|
|
603
|
-
|
|
603
|
+
o.doc.descendants((i, u) => {
|
|
604
604
|
if (i.type === e && !r) {
|
|
605
605
|
if (i.textContent.trim().length === 0)
|
|
606
606
|
return;
|
|
607
607
|
const f = i.attrs, d = t(i);
|
|
608
|
-
f.id !== d && (c = !0,
|
|
608
|
+
f.id !== d && (c = !0, s.setMeta(U, !0).setNodeMarkup(u, void 0, {
|
|
609
609
|
...f,
|
|
610
610
|
id: d
|
|
611
611
|
}));
|
|
612
612
|
}
|
|
613
|
-
}), c && l(
|
|
613
|
+
}), c && l(s);
|
|
614
614
|
};
|
|
615
615
|
return new x({
|
|
616
616
|
key: U,
|
|
@@ -619,28 +619,28 @@ const k = {
|
|
|
619
619
|
compositionstart: () => (r = !0, !1),
|
|
620
620
|
compositionend: () => {
|
|
621
621
|
r = !1;
|
|
622
|
-
const
|
|
622
|
+
const o = a.get(S);
|
|
623
623
|
return setTimeout(() => {
|
|
624
|
-
n(
|
|
624
|
+
n(o.state, (l) => o.dispatch(l));
|
|
625
625
|
}, 0), !1;
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
628
|
},
|
|
629
|
-
appendTransaction: (
|
|
629
|
+
appendTransaction: (o, l, s) => {
|
|
630
630
|
let c = null;
|
|
631
|
-
return
|
|
631
|
+
return o.every((i) => !i.getMeta(U)) && o.some((i) => i.docChanged) && n(s, (i) => {
|
|
632
632
|
c = i;
|
|
633
633
|
}), c;
|
|
634
634
|
},
|
|
635
|
-
view: (
|
|
636
|
-
const l =
|
|
637
|
-
let
|
|
635
|
+
view: (o) => {
|
|
636
|
+
const l = o.state.doc;
|
|
637
|
+
let s = o.state.tr.setMeta("addToHistory", !1);
|
|
638
638
|
return l.descendants((c, i) => {
|
|
639
|
-
c.type.name === "heading" && c.attrs.level && (c.attrs.id || (
|
|
639
|
+
c.type.name === "heading" && c.attrs.level && (c.attrs.id || (s = s.setNodeMarkup(i, void 0, {
|
|
640
640
|
...c.attrs,
|
|
641
641
|
id: t(c)
|
|
642
642
|
})));
|
|
643
|
-
}),
|
|
643
|
+
}), o.dispatch(s), {};
|
|
644
644
|
}
|
|
645
645
|
});
|
|
646
646
|
}, ft = (a, e, t) => new x({
|
|
@@ -649,14 +649,14 @@ const k = {
|
|
|
649
649
|
init: () => O.empty,
|
|
650
650
|
apply: (r) => {
|
|
651
651
|
var f;
|
|
652
|
-
const n = a.get(
|
|
652
|
+
const n = a.get(S);
|
|
653
653
|
if (!((f = n.hasFocus) != null && f.call(n)) || !n.editable)
|
|
654
654
|
return O.empty;
|
|
655
|
-
const { $from:
|
|
655
|
+
const { $from: o } = r.selection, l = o.node();
|
|
656
656
|
if (l.type !== e)
|
|
657
657
|
return O.empty;
|
|
658
|
-
const
|
|
659
|
-
i.textContent = c(
|
|
658
|
+
const s = l.attrs.level, c = (d) => Array(d).fill(0).map((m) => "#").join(""), i = document.createElement("span");
|
|
659
|
+
i.textContent = c(s), i.contentEditable = "false", t.themeManager.onFlush(() => {
|
|
660
660
|
const d = t.getStyle(({ css: m }) => {
|
|
661
661
|
const p = Ae(t.themeManager);
|
|
662
662
|
return m`
|
|
@@ -666,7 +666,7 @@ const k = {
|
|
|
666
666
|
});
|
|
667
667
|
d && (i.className = d);
|
|
668
668
|
});
|
|
669
|
-
const u = X.widget(
|
|
669
|
+
const u = X.widget(o.before() + 1, i, { side: -1 });
|
|
670
670
|
return O.create(r.doc, [u]);
|
|
671
671
|
}
|
|
672
672
|
},
|
|
@@ -682,8 +682,8 @@ const k = {
|
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
684
|
}), mt = w((a, e) => {
|
|
685
|
-
var
|
|
686
|
-
const t = "heading", r = (
|
|
685
|
+
var o, l;
|
|
686
|
+
const t = "heading", r = (o = e == null ? void 0 : e.getId) != null ? o : ut, n = (l = e == null ? void 0 : e.displayHashtag) != null ? l : !0;
|
|
687
687
|
return {
|
|
688
688
|
id: t,
|
|
689
689
|
schema: () => ({
|
|
@@ -698,46 +698,46 @@ const k = {
|
|
|
698
698
|
default: 1
|
|
699
699
|
}
|
|
700
700
|
},
|
|
701
|
-
parseDOM: ke.map((
|
|
702
|
-
tag: `h${
|
|
701
|
+
parseDOM: ke.map((s) => ({
|
|
702
|
+
tag: `h${s}`,
|
|
703
703
|
getAttrs: (c) => {
|
|
704
704
|
if (!(c instanceof HTMLElement))
|
|
705
705
|
throw L(c);
|
|
706
|
-
return { level:
|
|
706
|
+
return { level: s, id: c.id };
|
|
707
707
|
}
|
|
708
708
|
})),
|
|
709
|
-
toDOM: (
|
|
710
|
-
`h${
|
|
709
|
+
toDOM: (s) => [
|
|
710
|
+
`h${s.attrs.level}`,
|
|
711
711
|
{
|
|
712
|
-
id:
|
|
713
|
-
class: a.getClassName(
|
|
712
|
+
id: s.attrs.id || r(s),
|
|
713
|
+
class: a.getClassName(s.attrs, `heading h${s.attrs.level}`)
|
|
714
714
|
},
|
|
715
715
|
0
|
|
716
716
|
],
|
|
717
717
|
parseMarkdown: {
|
|
718
|
-
match: ({ type:
|
|
719
|
-
runner: (
|
|
718
|
+
match: ({ type: s }) => s === t,
|
|
719
|
+
runner: (s, c, i) => {
|
|
720
720
|
const u = c.depth;
|
|
721
|
-
|
|
721
|
+
s.openNode(i, { level: u }), s.next(c.children), s.closeNode();
|
|
722
722
|
}
|
|
723
723
|
},
|
|
724
724
|
toMarkdown: {
|
|
725
|
-
match: (
|
|
726
|
-
runner: (
|
|
725
|
+
match: (s) => s.type.name === t,
|
|
726
|
+
runner: (s, c) => {
|
|
727
727
|
var u;
|
|
728
|
-
if (
|
|
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
729
|
const f = [];
|
|
730
730
|
c.content.forEach((d, m, p) => {
|
|
731
731
|
p !== c.childCount - 1 && f.push(d);
|
|
732
|
-
}),
|
|
732
|
+
}), s.next(B.fromArray(f));
|
|
733
733
|
} else
|
|
734
|
-
|
|
735
|
-
|
|
734
|
+
s.next(c.content);
|
|
735
|
+
s.closeNode();
|
|
736
736
|
}
|
|
737
737
|
}
|
|
738
738
|
}),
|
|
739
|
-
inputRules: (
|
|
740
|
-
const u = c.get(
|
|
739
|
+
inputRules: (s, c) => ke.map((i) => Q(new RegExp(`^(#{1,${i}})\\s$`), s, () => {
|
|
740
|
+
const u = c.get(S), { $from: f } = u.state.selection, d = f.node();
|
|
741
741
|
if (d.type.name === "heading") {
|
|
742
742
|
let m = Number(d.attrs.level) + Number(i);
|
|
743
743
|
return m > 6 && (m = 6), {
|
|
@@ -748,17 +748,17 @@ const k = {
|
|
|
748
748
|
level: i
|
|
749
749
|
};
|
|
750
750
|
})),
|
|
751
|
-
commands: (
|
|
752
|
-
M(D, (i = 1) => i < 1 ?
|
|
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
753
|
M(Me, () => (i, u, f) => {
|
|
754
754
|
const { $from: d } = i.selection, m = d.node();
|
|
755
|
-
if (m.type !==
|
|
755
|
+
if (m.type !== s || !i.selection.empty || d.parentOffset !== 0)
|
|
756
756
|
return !1;
|
|
757
757
|
const p = m.attrs.level - 1;
|
|
758
758
|
return p ? (u == null || u(i.tr.setNodeMarkup(i.selection.$from.before(), void 0, {
|
|
759
759
|
...m.attrs,
|
|
760
760
|
level: p
|
|
761
|
-
})), !0) :
|
|
761
|
+
})), !0) : A(c.get(P).nodes.paragraph || s)(i, u, f);
|
|
762
762
|
})
|
|
763
763
|
],
|
|
764
764
|
shortcuts: {
|
|
@@ -770,9 +770,9 @@ const k = {
|
|
|
770
770
|
[k.H6]: h(D, "Mod-Alt-6", 6),
|
|
771
771
|
[k.DowngradeHeading]: h(Me, ["Backspace", "Delete"])
|
|
772
772
|
},
|
|
773
|
-
prosePlugins: (
|
|
774
|
-
const i = [dt(c,
|
|
775
|
-
return n && i.push(ft(c,
|
|
773
|
+
prosePlugins: (s, c) => {
|
|
774
|
+
const i = [dt(c, s, r)];
|
|
775
|
+
return n && i.push(ft(c, s, a)), i;
|
|
776
776
|
}
|
|
777
777
|
};
|
|
778
778
|
}), V = "hr", Te = y("InsertHr"), pt = w((a) => ({
|
|
@@ -795,19 +795,19 @@ const k = {
|
|
|
795
795
|
}
|
|
796
796
|
}),
|
|
797
797
|
inputRules: (e) => [
|
|
798
|
-
new Ce(/^(?:---|___\s|\*\*\*\s)$/, (t, r, n,
|
|
798
|
+
new Ce(/^(?:---|___\s|\*\*\*\s)$/, (t, r, n, o) => {
|
|
799
799
|
const { tr: l } = t;
|
|
800
|
-
return r[0] && l.replaceWith(n - 1,
|
|
800
|
+
return r[0] && l.replaceWith(n - 1, o, e.create()), l;
|
|
801
801
|
})
|
|
802
802
|
],
|
|
803
803
|
commands: (e, t) => [
|
|
804
804
|
M(Te, () => (r, n) => {
|
|
805
805
|
if (!n)
|
|
806
806
|
return !0;
|
|
807
|
-
const
|
|
807
|
+
const o = t.get(P).node("paragraph"), { tr: l, selection: s } = r, { from: c } = s, i = e.create();
|
|
808
808
|
if (!i)
|
|
809
809
|
return !0;
|
|
810
|
-
const u = l.replaceSelectionWith(i).insert(c,
|
|
810
|
+
const u = l.replaceSelectionWith(i).insert(c, o), f = Le.findFrom(u.doc.resolve(c), 1, !0);
|
|
811
811
|
return f && n(u.setSelection(f).scrollIntoView()), !0;
|
|
812
812
|
})
|
|
813
813
|
]
|
|
@@ -851,11 +851,11 @@ const k = {
|
|
|
851
851
|
parseMarkdown: {
|
|
852
852
|
match: ({ type: t }) => t === $,
|
|
853
853
|
runner: (t, r, n) => {
|
|
854
|
-
const
|
|
854
|
+
const o = r.url, l = r.alt, s = r.title;
|
|
855
855
|
t.addNode(n, {
|
|
856
|
-
src:
|
|
856
|
+
src: o,
|
|
857
857
|
alt: l,
|
|
858
|
-
title:
|
|
858
|
+
title: s
|
|
859
859
|
});
|
|
860
860
|
}
|
|
861
861
|
},
|
|
@@ -871,47 +871,47 @@ const k = {
|
|
|
871
871
|
}
|
|
872
872
|
}),
|
|
873
873
|
commands: (t) => [
|
|
874
|
-
M(He, (r = "") => (n,
|
|
875
|
-
if (!s)
|
|
876
|
-
return !0;
|
|
877
|
-
const { tr: l } = n, o = t.create({ src: r });
|
|
874
|
+
M(He, (r = "") => (n, o) => {
|
|
878
875
|
if (!o)
|
|
879
876
|
return !0;
|
|
880
|
-
const
|
|
881
|
-
|
|
877
|
+
const { tr: l } = n, s = t.create({ src: r });
|
|
878
|
+
if (!s)
|
|
879
|
+
return !0;
|
|
880
|
+
const c = l.replaceSelectionWith(s);
|
|
881
|
+
return o(c.scrollIntoView()), !0;
|
|
882
882
|
}),
|
|
883
|
-
M(le, (r = "") => (n,
|
|
883
|
+
M(le, (r = "") => (n, o) => {
|
|
884
884
|
const l = K(n.selection, t);
|
|
885
885
|
if (!l)
|
|
886
886
|
return !1;
|
|
887
|
-
const { tr:
|
|
888
|
-
return
|
|
887
|
+
const { tr: s } = n;
|
|
888
|
+
return o == null || o(s.setNodeMarkup(l.pos, void 0, { ...l.node.attrs, loading: !0, src: r }).scrollIntoView()), !0;
|
|
889
889
|
})
|
|
890
890
|
],
|
|
891
891
|
inputRules: (t) => [
|
|
892
|
-
new Ce(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/, (r, n,
|
|
893
|
-
const [
|
|
894
|
-
return
|
|
892
|
+
new Ce(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/, (r, n, o, l) => {
|
|
893
|
+
const [s, c, i = "", u] = n, { tr: f } = r;
|
|
894
|
+
return s && f.replaceWith(o, l, t.create({ src: i, alt: c, title: u })), f;
|
|
895
895
|
})
|
|
896
896
|
],
|
|
897
897
|
view: () => (t) => {
|
|
898
898
|
var i, u;
|
|
899
899
|
let r = t;
|
|
900
|
-
const n = (i = e == null ? void 0 : e.placeholder) != null ? i : "Add an Image",
|
|
900
|
+
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, l = a.themeManager.get("image", {
|
|
901
901
|
placeholder: n,
|
|
902
|
-
isBlock:
|
|
902
|
+
isBlock: o
|
|
903
903
|
});
|
|
904
904
|
if (!l)
|
|
905
905
|
return {};
|
|
906
|
-
const { dom:
|
|
906
|
+
const { dom: s, onUpdate: c } = l;
|
|
907
907
|
return c(r), {
|
|
908
|
-
dom:
|
|
908
|
+
dom: s,
|
|
909
909
|
update: (f) => f.type.name !== $ ? !1 : (r = f, c(r), !0),
|
|
910
910
|
selectNode: () => {
|
|
911
|
-
|
|
911
|
+
s.classList.add("ProseMirror-selectednode");
|
|
912
912
|
},
|
|
913
913
|
deselectNode: () => {
|
|
914
|
-
|
|
914
|
+
s.classList.remove("ProseMirror-selectednode");
|
|
915
915
|
}
|
|
916
916
|
};
|
|
917
917
|
},
|
|
@@ -920,29 +920,29 @@ const k = {
|
|
|
920
920
|
key: gt,
|
|
921
921
|
view: (n) => {
|
|
922
922
|
var i, u, f;
|
|
923
|
-
const
|
|
923
|
+
const o = a.themeManager.get("input-chip", {
|
|
924
924
|
placeholder: (u = (i = e == null ? void 0 : e.input) == null ? void 0 : i.placeholder) != null ? u : "Input Image Link",
|
|
925
925
|
buttonText: (f = e == null ? void 0 : e.input) == null ? void 0 : f.buttonText,
|
|
926
926
|
onUpdate: (d) => {
|
|
927
927
|
r.get(we).call(le, d);
|
|
928
928
|
}
|
|
929
929
|
});
|
|
930
|
-
if (!
|
|
930
|
+
if (!o)
|
|
931
931
|
return {};
|
|
932
|
-
const l = (d) => Boolean(d.hasFocus() && t && K(d.state.selection, t)),
|
|
932
|
+
const l = (d) => Boolean(d.hasFocus() && t && K(d.state.selection, t)), s = (d) => {
|
|
933
933
|
const m = K(d.state.selection, t);
|
|
934
934
|
return m ? m.node.attrs.src : void 0;
|
|
935
935
|
}, c = (d) => {
|
|
936
936
|
if (!d.editable)
|
|
937
937
|
return;
|
|
938
|
-
l(d) ? (
|
|
938
|
+
l(d) ? (o.show(d), o.update(s(d))) : o.hide();
|
|
939
939
|
};
|
|
940
|
-
return
|
|
940
|
+
return o.init(n), c(n), {
|
|
941
941
|
update: (d, m) => {
|
|
942
942
|
(m == null ? void 0 : m.doc.eq(d.state.doc)) && m.selection.eq(d.state.selection) || c(d);
|
|
943
943
|
},
|
|
944
944
|
destroy: () => {
|
|
945
|
-
|
|
945
|
+
o.destroy();
|
|
946
946
|
}
|
|
947
947
|
};
|
|
948
948
|
}
|
|
@@ -951,24 +951,24 @@ const k = {
|
|
|
951
951
|
})), ye = "list_item", ce = y("SplitListItem"), ie = y("SinkListItem"), ue = y("LiftListItem"), kt = new T("MILKDOWN_KEEP_LIST_ORDER"), Mt = (a) => {
|
|
952
952
|
const e = (t, r) => {
|
|
953
953
|
const n = Re("ordered_list", t.schema);
|
|
954
|
-
let
|
|
955
|
-
t.doc.descendants((l,
|
|
954
|
+
let o = t.tr;
|
|
955
|
+
t.doc.descendants((l, s, c, i) => {
|
|
956
956
|
if (l.type === a && (c == null ? void 0 : c.type) === n) {
|
|
957
957
|
let u = !1;
|
|
958
958
|
const f = { ...l.attrs };
|
|
959
959
|
l.attrs.listType !== "ordered" && (f.listType = "ordered", u = !0);
|
|
960
960
|
const d = c == null ? void 0 : c.maybeChild(0);
|
|
961
|
-
d && d.type === a && d.attrs.listType === "ordered" && (f.label = `${i + 1}.`, u = !0), l.attrs.label === "\u2022" && (f.label = `${i + 1}.`, u = !0), u && (
|
|
961
|
+
d && d.type === a && d.attrs.listType === "ordered" && (f.label = `${i + 1}.`, u = !0), l.attrs.label === "\u2022" && (f.label = `${i + 1}.`, u = !0), u && (o = o.setNodeMarkup(s, void 0, f));
|
|
962
962
|
}
|
|
963
|
-
}), r(
|
|
963
|
+
}), r(o);
|
|
964
964
|
};
|
|
965
965
|
return new x({
|
|
966
966
|
key: kt,
|
|
967
967
|
appendTransaction: (t, r, n) => {
|
|
968
|
-
let
|
|
968
|
+
let o = null;
|
|
969
969
|
return t.some((l) => l.docChanged) && e(n, (l) => {
|
|
970
|
-
|
|
971
|
-
}),
|
|
970
|
+
o = l;
|
|
971
|
+
}), o;
|
|
972
972
|
}
|
|
973
973
|
});
|
|
974
974
|
}, yt = w((a) => ({
|
|
@@ -1023,8 +1023,8 @@ const k = {
|
|
|
1023
1023
|
parseMarkdown: {
|
|
1024
1024
|
match: ({ type: e, checked: t }) => e === "listItem" && t === null,
|
|
1025
1025
|
runner: (e, t, r) => {
|
|
1026
|
-
const n = t.label != null ? `${t.label}.` : "\u2022",
|
|
1027
|
-
e.openNode(r, { label: n, listType:
|
|
1026
|
+
const n = t.label != null ? `${t.label}.` : "\u2022", o = t.label != null ? "ordered" : "bullet", l = t.spread != null ? `${t.spread}` : "true";
|
|
1027
|
+
e.openNode(r, { label: n, listType: o, spread: l }), e.next(t.children), e.closeNode();
|
|
1028
1028
|
}
|
|
1029
1029
|
},
|
|
1030
1030
|
toMarkdown: {
|
|
@@ -1120,17 +1120,17 @@ const k = {
|
|
|
1120
1120
|
runner: (e, t) => {
|
|
1121
1121
|
var n;
|
|
1122
1122
|
if (e.openNode("paragraph"), t.childCount >= 1 && ((n = t.lastChild) == null ? void 0 : n.type.name) === "hardbreak") {
|
|
1123
|
-
const
|
|
1124
|
-
t.content.forEach((l,
|
|
1125
|
-
c !== t.childCount - 1 &&
|
|
1126
|
-
}), e.next(B.fromArray(
|
|
1123
|
+
const o = [];
|
|
1124
|
+
t.content.forEach((l, s, c) => {
|
|
1125
|
+
c !== t.childCount - 1 && o.push(l);
|
|
1126
|
+
}), e.next(B.fromArray(o));
|
|
1127
1127
|
} else
|
|
1128
1128
|
e.next(t.content);
|
|
1129
1129
|
e.closeNode();
|
|
1130
1130
|
}
|
|
1131
1131
|
}
|
|
1132
1132
|
}),
|
|
1133
|
-
commands: (e) => [M(fe, () =>
|
|
1133
|
+
commands: (e) => [M(fe, () => A(e))],
|
|
1134
1134
|
shortcuts: {
|
|
1135
1135
|
[k.Text]: h(fe, "Mod-Alt-0")
|
|
1136
1136
|
}
|
|
@@ -1170,8 +1170,8 @@ const k = {
|
|
|
1170
1170
|
var r;
|
|
1171
1171
|
if (t.ordered) {
|
|
1172
1172
|
const n = (r = t.start) != null ? r : 1;
|
|
1173
|
-
t.children.forEach((
|
|
1174
|
-
|
|
1173
|
+
t.children.forEach((o, l) => {
|
|
1174
|
+
o.label = l + n;
|
|
1175
1175
|
});
|
|
1176
1176
|
return;
|
|
1177
1177
|
}
|
|
@@ -1181,13 +1181,13 @@ const k = {
|
|
|
1181
1181
|
}, Ct = (a) => !!a.children, xt = (a) => a.type === "html";
|
|
1182
1182
|
function Tt(a, e) {
|
|
1183
1183
|
return t(a, 0, null)[0];
|
|
1184
|
-
function t(r, n,
|
|
1184
|
+
function t(r, n, o) {
|
|
1185
1185
|
if (Ct(r)) {
|
|
1186
1186
|
const l = [];
|
|
1187
|
-
for (let
|
|
1188
|
-
const i = r.children[
|
|
1187
|
+
for (let s = 0, c = r.children.length; s < c; s++) {
|
|
1188
|
+
const i = r.children[s];
|
|
1189
1189
|
if (i) {
|
|
1190
|
-
const u = t(i,
|
|
1190
|
+
const u = t(i, s, r);
|
|
1191
1191
|
if (u)
|
|
1192
1192
|
for (let f = 0, d = u.length; f < d; f++) {
|
|
1193
1193
|
const m = u[f];
|
|
@@ -1197,7 +1197,7 @@ function Tt(a, e) {
|
|
|
1197
1197
|
}
|
|
1198
1198
|
r.children = l;
|
|
1199
1199
|
}
|
|
1200
|
-
return e(r, n,
|
|
1200
|
+
return e(r, n, o);
|
|
1201
1201
|
}
|
|
1202
1202
|
}
|
|
1203
1203
|
const Ht = () => {
|
|
@@ -1216,35 +1216,35 @@ const Ht = () => {
|
|
|
1216
1216
|
apply(t) {
|
|
1217
1217
|
if (!t.selection.empty)
|
|
1218
1218
|
return !1;
|
|
1219
|
-
const r = t.selection.$from, n = r.nodeBefore,
|
|
1220
|
-
return !!(n &&
|
|
1219
|
+
const r = t.selection.$from, n = r.nodeBefore, o = r.nodeAfter;
|
|
1220
|
+
return !!(n && o && n.isInline && !n.isText && o.isInline && !o.isText);
|
|
1221
1221
|
}
|
|
1222
1222
|
},
|
|
1223
1223
|
props: {
|
|
1224
1224
|
handleDOMEvents: {
|
|
1225
1225
|
compositionend: (t, r) => a ? (a = !1, requestAnimationFrame(() => {
|
|
1226
1226
|
if (e.getState(t.state)) {
|
|
1227
|
-
const
|
|
1228
|
-
r.preventDefault(), t.dispatch(t.state.tr.insertText(r.data || "",
|
|
1227
|
+
const o = t.state.selection.from;
|
|
1228
|
+
r.preventDefault(), t.dispatch(t.state.tr.insertText(r.data || "", o));
|
|
1229
1229
|
}
|
|
1230
1230
|
}), !0) : !1,
|
|
1231
1231
|
compositionstart: (t) => (e.getState(t.state) && (a = !0), !1),
|
|
1232
1232
|
beforeinput: (t, r) => {
|
|
1233
1233
|
if (e.getState(t.state) && r instanceof InputEvent && r.data && !a) {
|
|
1234
|
-
const
|
|
1235
|
-
return r.preventDefault(), t.dispatch(t.state.tr.insertText(r.data || "",
|
|
1234
|
+
const o = t.state.selection.from;
|
|
1235
|
+
return r.preventDefault(), t.dispatch(t.state.tr.insertText(r.data || "", o)), !0;
|
|
1236
1236
|
}
|
|
1237
1237
|
return !1;
|
|
1238
1238
|
}
|
|
1239
1239
|
},
|
|
1240
1240
|
decorations(t) {
|
|
1241
1241
|
if (e.getState(t)) {
|
|
1242
|
-
const
|
|
1242
|
+
const o = t.selection.$from.pos, l = document.createElement("span"), s = X.widget(o, l, {
|
|
1243
1243
|
side: -1
|
|
1244
|
-
}), c = document.createElement("span"), i = X.widget(
|
|
1244
|
+
}), c = document.createElement("span"), i = X.widget(o, c);
|
|
1245
1245
|
return setTimeout(() => {
|
|
1246
1246
|
l.contentEditable = "true", c.contentEditable = "true";
|
|
1247
|
-
}), O.create(t.doc, [
|
|
1247
|
+
}), O.create(t.doc, [s, i]);
|
|
1248
1248
|
}
|
|
1249
1249
|
return O.empty;
|
|
1250
1250
|
}
|
|
@@ -1262,20 +1262,20 @@ const Ht = () => {
|
|
|
1262
1262
|
const r = a.split(""), n = r[e];
|
|
1263
1263
|
return r[e] && r[t] && (r[e] = r[t], r[t] = n), r.join("").toString();
|
|
1264
1264
|
}, vt = (a) => (e) => e.replace(St(a), ""), _t = (a) => (e) => {
|
|
1265
|
-
const t = e.indexOf(a.hole), r = e.charAt(t - 1), n = e.charAt(t + 1),
|
|
1266
|
-
return n ? r &&
|
|
1265
|
+
const t = e.indexOf(a.hole), r = e.charAt(t - 1), n = e.charAt(t + 1), o = /[^\w]|_/;
|
|
1266
|
+
return n ? r && o.test(r) && o.test(n) ? a.punctuation : a.char : a.punctuation;
|
|
1267
1267
|
}, $t = (a, e, t) => {
|
|
1268
1268
|
let r = e, n = !1;
|
|
1269
|
-
return a.descendants((
|
|
1269
|
+
return a.descendants((o) => {
|
|
1270
1270
|
var l;
|
|
1271
1271
|
if (n)
|
|
1272
1272
|
return !1;
|
|
1273
|
-
if (
|
|
1274
|
-
const
|
|
1275
|
-
if (
|
|
1276
|
-
return n = !0, r +=
|
|
1273
|
+
if (o.isText) {
|
|
1274
|
+
const s = (l = o.text) == null ? void 0 : l.indexOf(t);
|
|
1275
|
+
if (s != null && s >= 0)
|
|
1276
|
+
return n = !0, r += s, !1;
|
|
1277
1277
|
}
|
|
1278
|
-
r +=
|
|
1278
|
+
r += o.nodeSize;
|
|
1279
1279
|
}), r;
|
|
1280
1280
|
}, Pt = {
|
|
1281
1281
|
placeholderConfig: {
|
|
@@ -1296,15 +1296,15 @@ const Ht = () => {
|
|
|
1296
1296
|
const { selection: e } = a, { $from: t } = e;
|
|
1297
1297
|
return t.node();
|
|
1298
1298
|
}, Rt = (a, e, t, r) => {
|
|
1299
|
-
const n = a.get(ve),
|
|
1300
|
-
return n(
|
|
1299
|
+
const n = a.get(ve), o = e.schema.topNodeType.create(void 0, [t, ...r]);
|
|
1300
|
+
return n(o);
|
|
1301
1301
|
}, Wt = (a, e) => {
|
|
1302
|
-
const t = a.get(E), r = t.placeholderConfig.hole, [n = "", ...
|
|
1302
|
+
const t = a.get(E), r = t.placeholderConfig.hole, [n = "", ...o] = e.split(`
|
|
1303
1303
|
|
|
1304
1304
|
`), l = (u) => t.movePlaceholder(r, u);
|
|
1305
1305
|
let c = Oe(vt(r), l, At)(n);
|
|
1306
1306
|
const i = _t(t.placeholderConfig)(c);
|
|
1307
|
-
return c = c.replace(r, i), c = [c, ...
|
|
1307
|
+
return c = c.replace(r, i), c = [c, ...o].join(`
|
|
1308
1308
|
|
|
1309
1309
|
`), [c, i];
|
|
1310
1310
|
}, qt = (a, e) => {
|
|
@@ -1320,46 +1320,53 @@ const Ht = () => {
|
|
|
1320
1320
|
|
|
1321
1321
|
`)[0] || "", De = (a, e) => {
|
|
1322
1322
|
try {
|
|
1323
|
-
const t = Kt(a, e), r = Bt(e), n = Rt(a, e, r, t), [
|
|
1324
|
-
return !
|
|
1323
|
+
const t = Kt(a, e), r = Bt(e), n = Rt(a, e, r, t), [o, l] = Wt(a, n), s = qt(a, o);
|
|
1324
|
+
return !s || r.type !== s.type ? null : (s.attrs = { ...r.attrs }, s.descendants((c) => {
|
|
1325
1325
|
var f;
|
|
1326
1326
|
const u = c.marks.find((d) => d.type.name === "link");
|
|
1327
1327
|
u && ((f = c.text) == null ? void 0 : f.includes(l)) && u.attrs.href.includes(l) && (u.attrs.href = u.attrs.href.replace(l, ""));
|
|
1328
1328
|
}), {
|
|
1329
|
-
text: Ft(
|
|
1329
|
+
text: Ft(o),
|
|
1330
1330
|
prevNode: r,
|
|
1331
|
-
nextNode:
|
|
1331
|
+
nextNode: s,
|
|
1332
1332
|
placeholder: l
|
|
1333
1333
|
});
|
|
1334
1334
|
} catch {
|
|
1335
1335
|
return null;
|
|
1336
1336
|
}
|
|
1337
1337
|
}, jt = (a, e, t, r, n) => {
|
|
1338
|
-
const { placeholderConfig:
|
|
1339
|
-
let
|
|
1340
|
-
const c = t.apply(
|
|
1338
|
+
const { placeholderConfig: o } = a.get(E), l = o.hole;
|
|
1339
|
+
let s = t.tr.setMeta(e, !0).insertText(l, t.selection.from);
|
|
1340
|
+
const c = t.apply(s), i = De(a, c);
|
|
1341
1341
|
if (!i)
|
|
1342
1342
|
return;
|
|
1343
1343
|
const { $from: u } = c.selection, f = u.before(), d = u.after(), m = $t(i.nextNode, f, i.placeholder);
|
|
1344
|
-
|
|
1345
|
-
}, Y = new T("MILKDOWN_INLINE_SYNC"), zt = (a) =>
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1344
|
+
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 T("MILKDOWN_INLINE_SYNC"), zt = (a) => {
|
|
1346
|
+
let e = null;
|
|
1347
|
+
return new x({
|
|
1348
|
+
key: Y,
|
|
1349
|
+
state: {
|
|
1350
|
+
init: () => null,
|
|
1351
|
+
apply: (r, n, o, l) => {
|
|
1352
|
+
var p;
|
|
1353
|
+
const s = a.get(S);
|
|
1354
|
+
if (!((p = s.hasFocus) != null && p.call(s)) || !s.editable || !r.docChanged || r.getMeta(Y))
|
|
1355
|
+
return null;
|
|
1356
|
+
const i = De(a, l);
|
|
1357
|
+
if (!i)
|
|
1358
|
+
return null;
|
|
1359
|
+
e && (cancelAnimationFrame(e), e = null);
|
|
1360
|
+
const { prevNode: u, nextNode: f, text: d } = i, { shouldSyncNode: m } = a.get(E);
|
|
1361
|
+
return m({ prevNode: u, nextNode: f, ctx: a, tr: r, text: d }) && (e = requestAnimationFrame(() => {
|
|
1362
|
+
e = null;
|
|
1363
|
+
const { dispatch: g, state: N } = a.get(S);
|
|
1364
|
+
jt(a, Y, N, g, u.attrs);
|
|
1365
|
+
})), null;
|
|
1366
|
+
}
|
|
1360
1367
|
}
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1368
|
+
});
|
|
1369
|
+
}, Ut = [
|
|
1363
1370
|
Se(() => ({
|
|
1364
1371
|
prosePlugins: (a, e) => [Ot(), zt(e)],
|
|
1365
1372
|
remarkPlugins: () => [Ue, Ht, Lt]
|