@milkdown/preset-commonmark 6.4.0 → 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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
|
4
|
-
import { expectDomTypeError 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
|
+
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";
|
|
7
7
|
import { wrappingInputRule as W, textblockTypeInputRule as Q, InputRule as Ce } from "@milkdown/prose/inputrules";
|
|
@@ -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: {
|
|
@@ -93,8 +93,8 @@ const k = {
|
|
|
93
93
|
shortcuts: {
|
|
94
94
|
[k.Em]: h(ee, "Mod-i")
|
|
95
95
|
}
|
|
96
|
-
})), Je = new T("MILKDOWN_LINK_INPUT"), xe = y("ToggleLink"), te = y("ModifyLink"),
|
|
97
|
-
id:
|
|
96
|
+
})), Je = new T("MILKDOWN_LINK_INPUT"), xe = y("ToggleLink"), te = y("ModifyLink"), v = "link", Qe = R((a, e) => ({
|
|
97
|
+
id: v,
|
|
98
98
|
schema: () => ({
|
|
99
99
|
attrs: {
|
|
100
100
|
href: {},
|
|
@@ -105,21 +105,21 @@ const k = {
|
|
|
105
105
|
tag: "a[href]",
|
|
106
106
|
getAttrs: (t) => {
|
|
107
107
|
if (!(t instanceof HTMLElement))
|
|
108
|
-
throw
|
|
108
|
+
throw L(t);
|
|
109
109
|
return { href: t.getAttribute("href"), title: t.getAttribute("title") };
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
],
|
|
113
|
-
toDOM: (t) => ["a", { ...t.attrs, class: a.getClassName(t.attrs,
|
|
113
|
+
toDOM: (t) => ["a", { ...t.attrs, class: a.getClassName(t.attrs, v) }],
|
|
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: {
|
|
122
|
-
match: (t) => t.type.name ===
|
|
122
|
+
match: (t) => t.type.name === v,
|
|
123
123
|
runner: (t, r) => {
|
|
124
124
|
t.withMark(r, "link", void 0, {
|
|
125
125
|
title: r.attrs.title,
|
|
@@ -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
|
-
var
|
|
142
|
-
if ((
|
|
143
|
-
return
|
|
144
|
-
}), !
|
|
141
|
+
var C;
|
|
142
|
+
if ((C = l.link) != null && C.isInSet(b.marks))
|
|
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",
|
|
@@ -168,15 +168,15 @@ const k = {
|
|
|
168
168
|
const H = m.dom.parentElement;
|
|
169
169
|
if (!H)
|
|
170
170
|
throw $e();
|
|
171
|
-
const
|
|
172
|
-
let q = g.left - b.left - (I.width -
|
|
171
|
+
const C = N.left - g.left;
|
|
172
|
+
let q = g.left - b.left - (I.width - C) / 2, ge = g.bottom - b.top + 14 + H.scrollTop;
|
|
173
173
|
return n && (ge = g.top - b.top - I.height - 14 + H.scrollTop), q < 0 && (q = 0), [ge, q];
|
|
174
174
|
});
|
|
175
175
|
}
|
|
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;
|
|
@@ -184,7 +184,7 @@ const k = {
|
|
|
184
184
|
return n = !1, !0;
|
|
185
185
|
if (p instanceof We) {
|
|
186
186
|
const { node: b } = p;
|
|
187
|
-
if (b.type.name === "image" && b.marks.findIndex((H) => H.type.name ===
|
|
187
|
+
if (b.type.name === "image" && b.marks.findIndex((H) => H.type.name === v) > -1)
|
|
188
188
|
return n = !0, !0;
|
|
189
189
|
}
|
|
190
190
|
return !1;
|
|
@@ -192,19 +192,19 @@ const k = {
|
|
|
192
192
|
const { selection: p } = m.state;
|
|
193
193
|
let g;
|
|
194
194
|
const { from: N, to: I } = p;
|
|
195
|
-
if (m.state.doc.nodesBetween(N, N === I ? I + 1 : I, (
|
|
196
|
-
if (t.isInSet(
|
|
197
|
-
return g =
|
|
195
|
+
if (m.state.doc.nodesBetween(N, N === I ? I + 1 : I, (C) => {
|
|
196
|
+
if (t.isInSet(C.marks))
|
|
197
|
+
return g = C, !1;
|
|
198
198
|
}), !g)
|
|
199
199
|
return;
|
|
200
|
-
const b = g.marks.find((
|
|
200
|
+
const b = g.marks.find((C) => C.type === t);
|
|
201
201
|
return b ? b.attrs.href : void 0;
|
|
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);
|
|
@@ -288,7 +288,7 @@ const k = {
|
|
|
288
288
|
tag: "ul",
|
|
289
289
|
getAttrs: (t) => {
|
|
290
290
|
if (!(t instanceof HTMLElement))
|
|
291
|
-
throw
|
|
291
|
+
throw L(t);
|
|
292
292
|
return {
|
|
293
293
|
spread: t.dataset.spread
|
|
294
294
|
};
|
|
@@ -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
|
-
throw
|
|
369
|
-
return { language: (
|
|
368
|
+
throw L(n);
|
|
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
|
-
throw
|
|
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
|
{
|
|
@@ -384,39 +384,39 @@ const k = {
|
|
|
384
384
|
preserveWhitespace: "full",
|
|
385
385
|
getAttrs: (n) => {
|
|
386
386
|
if (!(n instanceof HTMLElement))
|
|
387
|
-
throw
|
|
387
|
+
throw L(n);
|
|
388
388
|
return { language: n.dataset.language };
|
|
389
389
|
}
|
|
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
|
-
throw
|
|
706
|
-
return { level:
|
|
705
|
+
throw L(c);
|
|
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
|
]
|
|
@@ -832,7 +832,7 @@ const k = {
|
|
|
832
832
|
tag: "img[src]",
|
|
833
833
|
getAttrs: (t) => {
|
|
834
834
|
if (!(t instanceof HTMLElement))
|
|
835
|
-
throw
|
|
835
|
+
throw L(t);
|
|
836
836
|
return {
|
|
837
837
|
src: t.getAttribute("src") || "",
|
|
838
838
|
alt: t.getAttribute("alt") || "",
|
|
@@ -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) => ({
|
|
@@ -993,14 +993,19 @@ const k = {
|
|
|
993
993
|
tag: "li.list-item",
|
|
994
994
|
getAttrs: (e) => {
|
|
995
995
|
if (!(e instanceof HTMLElement))
|
|
996
|
-
throw
|
|
996
|
+
throw L(e);
|
|
997
997
|
return {
|
|
998
998
|
label: e.dataset.label,
|
|
999
999
|
listType: e.dataset["list-type"],
|
|
1000
1000
|
spread: e.dataset.spread
|
|
1001
1001
|
};
|
|
1002
1002
|
},
|
|
1003
|
-
contentElement:
|
|
1003
|
+
contentElement: (e) => {
|
|
1004
|
+
if (!(e instanceof HTMLElement))
|
|
1005
|
+
throw L(e);
|
|
1006
|
+
const t = e.querySelector(".list-item_body");
|
|
1007
|
+
return t || e;
|
|
1008
|
+
}
|
|
1004
1009
|
},
|
|
1005
1010
|
{ tag: "li" }
|
|
1006
1011
|
],
|
|
@@ -1018,8 +1023,8 @@ const k = {
|
|
|
1018
1023
|
parseMarkdown: {
|
|
1019
1024
|
match: ({ type: e, checked: t }) => e === "listItem" && t === null,
|
|
1020
1025
|
runner: (e, t, r) => {
|
|
1021
|
-
const n = t.label != null ? `${t.label}.` : "\u2022",
|
|
1022
|
-
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();
|
|
1023
1028
|
}
|
|
1024
1029
|
},
|
|
1025
1030
|
toMarkdown: {
|
|
@@ -1059,7 +1064,7 @@ const k = {
|
|
|
1059
1064
|
tag: "ol",
|
|
1060
1065
|
getAttrs: (e) => {
|
|
1061
1066
|
if (!(e instanceof HTMLElement))
|
|
1062
|
-
throw
|
|
1067
|
+
throw L(e);
|
|
1063
1068
|
return {
|
|
1064
1069
|
spread: e.dataset.spread,
|
|
1065
1070
|
order: e.hasAttribute("start") ? Number(e.getAttribute("start")) : 1
|
|
@@ -1115,17 +1120,17 @@ const k = {
|
|
|
1115
1120
|
runner: (e, t) => {
|
|
1116
1121
|
var n;
|
|
1117
1122
|
if (e.openNode("paragraph"), t.childCount >= 1 && ((n = t.lastChild) == null ? void 0 : n.type.name) === "hardbreak") {
|
|
1118
|
-
const
|
|
1119
|
-
t.content.forEach((l,
|
|
1120
|
-
c !== t.childCount - 1 &&
|
|
1121
|
-
}), 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));
|
|
1122
1127
|
} else
|
|
1123
1128
|
e.next(t.content);
|
|
1124
1129
|
e.closeNode();
|
|
1125
1130
|
}
|
|
1126
1131
|
}
|
|
1127
1132
|
}),
|
|
1128
|
-
commands: (e) => [M(fe, () =>
|
|
1133
|
+
commands: (e) => [M(fe, () => A(e))],
|
|
1129
1134
|
shortcuts: {
|
|
1130
1135
|
[k.Text]: h(fe, "Mod-Alt-0")
|
|
1131
1136
|
}
|
|
@@ -1165,8 +1170,8 @@ const k = {
|
|
|
1165
1170
|
var r;
|
|
1166
1171
|
if (t.ordered) {
|
|
1167
1172
|
const n = (r = t.start) != null ? r : 1;
|
|
1168
|
-
t.children.forEach((
|
|
1169
|
-
|
|
1173
|
+
t.children.forEach((o, l) => {
|
|
1174
|
+
o.label = l + n;
|
|
1170
1175
|
});
|
|
1171
1176
|
return;
|
|
1172
1177
|
}
|
|
@@ -1176,13 +1181,13 @@ const k = {
|
|
|
1176
1181
|
}, Ct = (a) => !!a.children, xt = (a) => a.type === "html";
|
|
1177
1182
|
function Tt(a, e) {
|
|
1178
1183
|
return t(a, 0, null)[0];
|
|
1179
|
-
function t(r, n,
|
|
1184
|
+
function t(r, n, o) {
|
|
1180
1185
|
if (Ct(r)) {
|
|
1181
1186
|
const l = [];
|
|
1182
|
-
for (let
|
|
1183
|
-
const i = r.children[
|
|
1187
|
+
for (let s = 0, c = r.children.length; s < c; s++) {
|
|
1188
|
+
const i = r.children[s];
|
|
1184
1189
|
if (i) {
|
|
1185
|
-
const u = t(i,
|
|
1190
|
+
const u = t(i, s, r);
|
|
1186
1191
|
if (u)
|
|
1187
1192
|
for (let f = 0, d = u.length; f < d; f++) {
|
|
1188
1193
|
const m = u[f];
|
|
@@ -1192,7 +1197,7 @@ function Tt(a, e) {
|
|
|
1192
1197
|
}
|
|
1193
1198
|
r.children = l;
|
|
1194
1199
|
}
|
|
1195
|
-
return e(r, n,
|
|
1200
|
+
return e(r, n, o);
|
|
1196
1201
|
}
|
|
1197
1202
|
}
|
|
1198
1203
|
const Ht = () => {
|
|
@@ -1211,35 +1216,35 @@ const Ht = () => {
|
|
|
1211
1216
|
apply(t) {
|
|
1212
1217
|
if (!t.selection.empty)
|
|
1213
1218
|
return !1;
|
|
1214
|
-
const r = t.selection.$from, n = r.nodeBefore,
|
|
1215
|
-
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);
|
|
1216
1221
|
}
|
|
1217
1222
|
},
|
|
1218
1223
|
props: {
|
|
1219
1224
|
handleDOMEvents: {
|
|
1220
1225
|
compositionend: (t, r) => a ? (a = !1, requestAnimationFrame(() => {
|
|
1221
1226
|
if (e.getState(t.state)) {
|
|
1222
|
-
const
|
|
1223
|
-
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));
|
|
1224
1229
|
}
|
|
1225
1230
|
}), !0) : !1,
|
|
1226
1231
|
compositionstart: (t) => (e.getState(t.state) && (a = !0), !1),
|
|
1227
1232
|
beforeinput: (t, r) => {
|
|
1228
1233
|
if (e.getState(t.state) && r instanceof InputEvent && r.data && !a) {
|
|
1229
|
-
const
|
|
1230
|
-
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;
|
|
1231
1236
|
}
|
|
1232
1237
|
return !1;
|
|
1233
1238
|
}
|
|
1234
1239
|
},
|
|
1235
1240
|
decorations(t) {
|
|
1236
1241
|
if (e.getState(t)) {
|
|
1237
|
-
const
|
|
1242
|
+
const o = t.selection.$from.pos, l = document.createElement("span"), s = X.widget(o, l, {
|
|
1238
1243
|
side: -1
|
|
1239
|
-
}), c = document.createElement("span"), i = X.widget(
|
|
1244
|
+
}), c = document.createElement("span"), i = X.widget(o, c);
|
|
1240
1245
|
return setTimeout(() => {
|
|
1241
1246
|
l.contentEditable = "true", c.contentEditable = "true";
|
|
1242
|
-
}), O.create(t.doc, [
|
|
1247
|
+
}), O.create(t.doc, [s, i]);
|
|
1243
1248
|
}
|
|
1244
1249
|
return O.empty;
|
|
1245
1250
|
}
|
|
@@ -1253,24 +1258,24 @@ const Ht = () => {
|
|
|
1253
1258
|
e = e.replace(G, r), t = e.match(G);
|
|
1254
1259
|
}
|
|
1255
1260
|
return e;
|
|
1256
|
-
},
|
|
1261
|
+
}, Et = (a, e, t) => {
|
|
1257
1262
|
const r = a.split(""), n = r[e];
|
|
1258
1263
|
return r[e] && r[t] && (r[e] = r[t], r[t] = n), r.join("").toString();
|
|
1259
|
-
},
|
|
1260
|
-
const t = e.indexOf(a.hole), r = e.charAt(t - 1), n = e.charAt(t + 1),
|
|
1261
|
-
return n ? r &&
|
|
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), o = /[^\w]|_/;
|
|
1266
|
+
return n ? r && o.test(r) && o.test(n) ? a.punctuation : a.char : a.punctuation;
|
|
1262
1267
|
}, $t = (a, e, t) => {
|
|
1263
1268
|
let r = e, n = !1;
|
|
1264
|
-
return a.descendants((
|
|
1269
|
+
return a.descendants((o) => {
|
|
1265
1270
|
var l;
|
|
1266
1271
|
if (n)
|
|
1267
1272
|
return !1;
|
|
1268
|
-
if (
|
|
1269
|
-
const
|
|
1270
|
-
if (
|
|
1271
|
-
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;
|
|
1272
1277
|
}
|
|
1273
|
-
r +=
|
|
1278
|
+
r += o.nodeSize;
|
|
1274
1279
|
}), r;
|
|
1275
1280
|
}, Pt = {
|
|
1276
1281
|
placeholderConfig: {
|
|
@@ -1284,29 +1289,29 @@ const Ht = () => {
|
|
|
1284
1289
|
const t = ["*", "_"];
|
|
1285
1290
|
let r = e.indexOf(a);
|
|
1286
1291
|
for (; t.includes(e[r - 1] || "") && t.includes(e[r + 1] || ""); )
|
|
1287
|
-
e =
|
|
1292
|
+
e = Et(e, r, r + 1), r = r + 1;
|
|
1288
1293
|
return e;
|
|
1289
1294
|
}
|
|
1290
|
-
},
|
|
1295
|
+
}, E = Ee(Pt, "inlineSyncConfig"), Bt = (a) => {
|
|
1291
1296
|
const { selection: e } = a, { $from: t } = e;
|
|
1292
1297
|
return t.node();
|
|
1293
1298
|
}, Rt = (a, e, t, r) => {
|
|
1294
|
-
const n = a.get(
|
|
1295
|
-
return n(
|
|
1299
|
+
const n = a.get(ve), o = e.schema.topNodeType.create(void 0, [t, ...r]);
|
|
1300
|
+
return n(o);
|
|
1296
1301
|
}, Wt = (a, e) => {
|
|
1297
|
-
const t = a.get(
|
|
1302
|
+
const t = a.get(E), r = t.placeholderConfig.hole, [n = "", ...o] = e.split(`
|
|
1298
1303
|
|
|
1299
1304
|
`), l = (u) => t.movePlaceholder(r, u);
|
|
1300
|
-
let c = Oe(
|
|
1305
|
+
let c = Oe(vt(r), l, At)(n);
|
|
1301
1306
|
const i = _t(t.placeholderConfig)(c);
|
|
1302
|
-
return c = c.replace(r, i), c = [c, ...
|
|
1307
|
+
return c = c.replace(r, i), c = [c, ...o].join(`
|
|
1303
1308
|
|
|
1304
1309
|
`), [c, i];
|
|
1305
1310
|
}, qt = (a, e) => {
|
|
1306
1311
|
const r = a.get(_e)(e);
|
|
1307
1312
|
return r ? r.firstChild : null;
|
|
1308
1313
|
}, Kt = (a, e) => {
|
|
1309
|
-
const { globalNodes: t } = a.get(
|
|
1314
|
+
const { globalNodes: t } = a.get(E), r = [];
|
|
1310
1315
|
return e.doc.descendants((n) => {
|
|
1311
1316
|
if (t.includes(n.type.name) || t.includes(n.type))
|
|
1312
1317
|
return r.push(n), !1;
|
|
@@ -1315,50 +1320,57 @@ const Ht = () => {
|
|
|
1315
1320
|
|
|
1316
1321
|
`)[0] || "", De = (a, e) => {
|
|
1317
1322
|
try {
|
|
1318
|
-
const t = Kt(a, e), r = Bt(e), n = Rt(a, e, r, t), [
|
|
1319
|
-
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) => {
|
|
1320
1325
|
var f;
|
|
1321
1326
|
const u = c.marks.find((d) => d.type.name === "link");
|
|
1322
1327
|
u && ((f = c.text) == null ? void 0 : f.includes(l)) && u.attrs.href.includes(l) && (u.attrs.href = u.attrs.href.replace(l, ""));
|
|
1323
1328
|
}), {
|
|
1324
|
-
text: Ft(
|
|
1329
|
+
text: Ft(o),
|
|
1325
1330
|
prevNode: r,
|
|
1326
|
-
nextNode:
|
|
1331
|
+
nextNode: s,
|
|
1327
1332
|
placeholder: l
|
|
1328
1333
|
});
|
|
1329
1334
|
} catch {
|
|
1330
1335
|
return null;
|
|
1331
1336
|
}
|
|
1332
1337
|
}, jt = (a, e, t, r, n) => {
|
|
1333
|
-
const { placeholderConfig:
|
|
1334
|
-
let
|
|
1335
|
-
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);
|
|
1336
1341
|
if (!i)
|
|
1337
1342
|
return;
|
|
1338
1343
|
const { $from: u } = c.selection, f = u.before(), d = u.after(), m = $t(i.nextNode, f, i.placeholder);
|
|
1339
|
-
|
|
1340
|
-
}, Y = new T("MILKDOWN_INLINE_SYNC"), zt = (a) =>
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
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
|
+
}
|
|
1355
1367
|
}
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1368
|
+
});
|
|
1369
|
+
}, Ut = [
|
|
1358
1370
|
Se(() => ({
|
|
1359
1371
|
prosePlugins: (a, e) => [Ot(), zt(e)],
|
|
1360
1372
|
remarkPlugins: () => [Ue, Ht, Lt]
|
|
1361
|
-
}), [
|
|
1373
|
+
}), [E])()
|
|
1362
1374
|
], Vt = be.create([...wt, ...Ze]), lr = be.create([...Ut, ...Vt]), cr = {
|
|
1363
1375
|
ToggleInlineCode: Z,
|
|
1364
1376
|
ToggleItalic: ee,
|
|
@@ -1418,7 +1430,7 @@ export {
|
|
|
1418
1430
|
U as headingIdPluginKey,
|
|
1419
1431
|
pt as hr,
|
|
1420
1432
|
ht as image,
|
|
1421
|
-
|
|
1433
|
+
E as inlineSyncConfigCtx,
|
|
1422
1434
|
Qe as link,
|
|
1423
1435
|
yt as listItem,
|
|
1424
1436
|
Ze as marks,
|