@milkdown/preset-commonmark 7.5.0 → 7.5.8
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/__internal__/serialize-text.d.ts.map +1 -1
- package/lib/__internal__/with-meta.d.ts.map +1 -1
- package/lib/composed/commands.d.ts.map +1 -1
- package/lib/composed/inputrules.d.ts.map +1 -1
- package/lib/composed/keymap.d.ts.map +1 -1
- package/lib/composed/schema.d.ts.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +412 -269
- package/lib/index.es.js.map +1 -1
- package/lib/mark/emphasis.d.ts.map +1 -1
- package/lib/mark/inline-code.d.ts.map +1 -1
- package/lib/mark/link.d.ts.map +1 -1
- package/lib/mark/strong.d.ts.map +1 -1
- package/lib/node/blockquote.d.ts.map +1 -1
- package/lib/node/bullet-list.d.ts.map +1 -1
- package/lib/node/code-block.d.ts.map +1 -1
- package/lib/node/hardbreak.d.ts.map +1 -1
- package/lib/node/heading.d.ts.map +1 -1
- package/lib/node/hr.d.ts.map +1 -1
- package/lib/node/html.d.ts.map +1 -1
- package/lib/node/image.d.ts.map +1 -1
- package/lib/node/list-item.d.ts.map +1 -1
- package/lib/node/ordered-list.d.ts.map +1 -1
- package/lib/node/paragraph.d.ts.map +1 -1
- package/lib/plugin/hardbreak-clear-mark-plugin.d.ts.map +1 -1
- package/lib/plugin/hardbreak-filter-plugin.d.ts.map +1 -1
- package/lib/plugin/inline-nodes-cursor-plugin.d.ts.map +1 -1
- package/lib/plugin/remark-add-order-in-list-plugin.d.ts.map +1 -1
- package/lib/plugin/remark-html-transformer.d.ts.map +1 -1
- package/lib/plugin/remark-inline-link-plugin.d.ts.map +1 -1
- package/lib/plugin/remark-line-break.d.ts.map +1 -1
- package/lib/plugin/remark-marker-plugin.d.ts.map +1 -1
- package/lib/plugin/sync-heading-id-plugin.d.ts.map +1 -1
- package/lib/plugin/sync-list-order-plugin.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/__internal__/serialize-text.ts +3 -4
- package/src/__internal__/with-meta.ts +4 -1
- package/src/composed/commands.ts +7 -1
- package/src/composed/inputrules.ts +14 -2
- package/src/composed/keymap.ts +10 -1
- package/src/composed/schema.ts +10 -1
- package/src/index.ts +16 -2
- package/src/mark/emphasis.ts +19 -9
- package/src/mark/inline-code.ts +40 -30
- package/src/mark/link.ts +55 -45
- package/src/mark/strong.ts +13 -7
- package/src/node/blockquote.ts +34 -20
- package/src/node/bullet-list.ts +20 -7
- package/src/node/code-block.ts +43 -18
- package/src/node/doc.ts +1 -1
- package/src/node/hardbreak.ts +49 -28
- package/src/node/heading.ts +44 -27
- package/src/node/hr.ts +27 -28
- package/src/node/html.ts +10 -8
- package/src/node/image.ts +57 -43
- package/src/node/list-item.ts +35 -18
- package/src/node/ordered-list.ts +31 -15
- package/src/node/paragraph.ts +10 -10
- package/src/node/text.ts +1 -1
- package/src/plugin/hardbreak-clear-mark-plugin.ts +16 -9
- package/src/plugin/hardbreak-filter-plugin.ts +5 -3
- package/src/plugin/inline-nodes-cursor-plugin.ts +13 -6
- package/src/plugin/remark-add-order-in-list-plugin.ts +13 -10
- package/src/plugin/remark-html-transformer.ts +24 -17
- package/src/plugin/remark-inline-link-plugin.ts +4 -1
- package/src/plugin/remark-line-break.ts +39 -26
- package/src/plugin/remark-marker-plugin.ts +14 -7
- package/src/plugin/sync-heading-id-plugin.ts +12 -9
- package/src/plugin/sync-list-order-plugin.ts +12 -11
package/lib/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $markAttr as U, $markSchema as G, $command as
|
|
2
|
-
import { remarkStringifyOptionsCtx as Ye, commandsCtx as
|
|
1
|
+
import { $markAttr as U, $markSchema as G, $command as u, $inputRule as h, $useKeymap as f, $node as Qe, $nodeAttr as N, $nodeSchema as I, $ctx as Xe, $remark as D, $prose as _ } from "@milkdown/utils";
|
|
2
|
+
import { remarkStringifyOptionsCtx as Ye, commandsCtx as g, editorViewCtx as At } from "@milkdown/core";
|
|
3
3
|
import { toggleMark as J, setBlockType as K, wrapIn as Q } from "@milkdown/prose/commands";
|
|
4
4
|
import { Fragment as wt } from "@milkdown/prose/model";
|
|
5
5
|
import { expectDomTypeError as A } from "@milkdown/exception";
|
|
@@ -71,7 +71,7 @@ n(R.ctx, {
|
|
|
71
71
|
displayName: "MarkSchemaCtx<emphasis>",
|
|
72
72
|
group: "Emphasis"
|
|
73
73
|
});
|
|
74
|
-
const te =
|
|
74
|
+
const te = u("ToggleEmphasis", (t) => () => J(R.type(t)));
|
|
75
75
|
n(te, {
|
|
76
76
|
displayName: "Command<toggleEmphasisCommand>",
|
|
77
77
|
group: "Emphasis"
|
|
@@ -100,7 +100,7 @@ const re = f("emphasisKeymap", {
|
|
|
100
100
|
ToggleEmphasis: {
|
|
101
101
|
shortcuts: "Mod-i",
|
|
102
102
|
command: (t) => {
|
|
103
|
-
const e = t.get(
|
|
103
|
+
const e = t.get(g);
|
|
104
104
|
return () => e.call(te.key);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -153,7 +153,7 @@ n($.ctx, {
|
|
|
153
153
|
displayName: "MarkSchemaCtx<strong>",
|
|
154
154
|
group: "Strong"
|
|
155
155
|
});
|
|
156
|
-
const ne =
|
|
156
|
+
const ne = u("ToggleStrong", (t) => () => J($.type(t)));
|
|
157
157
|
n(ne, {
|
|
158
158
|
displayName: "Command<toggleStrongCommand>",
|
|
159
159
|
group: "Strong"
|
|
@@ -171,7 +171,7 @@ const oe = f("strongKeymap", {
|
|
|
171
171
|
ToggleBold: {
|
|
172
172
|
shortcuts: ["Mod-b"],
|
|
173
173
|
command: (t) => {
|
|
174
|
-
const e = t.get(
|
|
174
|
+
const e = t.get(g);
|
|
175
175
|
return () => e.call(ne.key);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
@@ -216,20 +216,24 @@ n(x.ctx, {
|
|
|
216
216
|
displayName: "MarkSchemaCtx<inlineCode>",
|
|
217
217
|
group: "InlineCode"
|
|
218
218
|
});
|
|
219
|
-
const le =
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
o.removeMark(s, l,
|
|
226
|
-
|
|
227
|
-
|
|
219
|
+
const le = u(
|
|
220
|
+
"ToggleInlineCode",
|
|
221
|
+
(t) => () => (e, r) => {
|
|
222
|
+
const { selection: a, tr: o } = e;
|
|
223
|
+
if (a.empty) return !1;
|
|
224
|
+
const { from: s, to: l } = a;
|
|
225
|
+
return e.doc.rangeHasMark(s, l, x.type(t)) ? (r == null || r(o.removeMark(s, l, x.type(t))), !0) : (Object.keys(e.schema.marks).filter(
|
|
226
|
+
(m) => m !== x.type.name
|
|
227
|
+
).map((m) => e.schema.marks[m]).forEach((m) => {
|
|
228
|
+
o.removeMark(s, l, m);
|
|
229
|
+
}), r == null || r(o.addMark(s, l, x.type(t).create())), !0);
|
|
230
|
+
}
|
|
231
|
+
);
|
|
228
232
|
n(le, {
|
|
229
233
|
displayName: "Command<toggleInlineCodeCommand>",
|
|
230
234
|
group: "InlineCode"
|
|
231
235
|
});
|
|
232
|
-
const lt = h((t) => j(/(
|
|
236
|
+
const lt = h((t) => j(/(?:`)([^`]+)(?:`)$/, x.type(t)));
|
|
233
237
|
n(lt, {
|
|
234
238
|
displayName: "InputRule<inlineCodeInputRule>",
|
|
235
239
|
group: "InlineCode"
|
|
@@ -238,7 +242,7 @@ const ie = f("inlineCodeKeymap", {
|
|
|
238
242
|
ToggleInlineCode: {
|
|
239
243
|
shortcuts: "Mod-e",
|
|
240
244
|
command: (t) => {
|
|
241
|
-
const e = t.get(
|
|
245
|
+
const e = t.get(g);
|
|
242
246
|
return () => e.call(le.key);
|
|
243
247
|
}
|
|
244
248
|
}
|
|
@@ -265,9 +269,11 @@ const B = G("link", (t) => ({
|
|
|
265
269
|
{
|
|
266
270
|
tag: "a[href]",
|
|
267
271
|
getAttrs: (e) => {
|
|
268
|
-
if (!(e instanceof HTMLElement))
|
|
269
|
-
|
|
270
|
-
|
|
272
|
+
if (!(e instanceof HTMLElement)) throw A(e);
|
|
273
|
+
return {
|
|
274
|
+
href: e.getAttribute("href"),
|
|
275
|
+
title: e.getAttribute("title")
|
|
276
|
+
};
|
|
271
277
|
}
|
|
272
278
|
}
|
|
273
279
|
],
|
|
@@ -293,29 +299,32 @@ n(B.mark, {
|
|
|
293
299
|
displayName: "MarkSchema<link>",
|
|
294
300
|
group: "Link"
|
|
295
301
|
});
|
|
296
|
-
const it =
|
|
302
|
+
const it = u(
|
|
303
|
+
"ToggleLink",
|
|
304
|
+
(t) => (e = {}) => J(B.type(t), e)
|
|
305
|
+
);
|
|
297
306
|
n(it, {
|
|
298
307
|
displayName: "Command<toggleLinkCommand>",
|
|
299
308
|
group: "Link"
|
|
300
309
|
});
|
|
301
|
-
const dt =
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return !1;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
310
|
+
const dt = u(
|
|
311
|
+
"UpdateLink",
|
|
312
|
+
(t) => (e = {}) => (r, a) => {
|
|
313
|
+
if (!a) return !1;
|
|
314
|
+
let o, s = -1;
|
|
315
|
+
const { selection: l } = r, { from: i, to: d } = l;
|
|
316
|
+
if (r.doc.nodesBetween(i, i === d ? d + 1 : d, (y, b) => {
|
|
317
|
+
if (B.type(t).isInSet(y.marks))
|
|
318
|
+
return o = y, s = b, !1;
|
|
319
|
+
}), !o) return !1;
|
|
320
|
+
const m = o.marks.find(({ type: y }) => y === B.type(t));
|
|
321
|
+
if (!m) return !1;
|
|
322
|
+
const p = s, c = s + o.nodeSize, { tr: k } = r, C = B.type(t).create({ ...m.attrs, ...e });
|
|
323
|
+
return C ? (a(
|
|
324
|
+
k.removeMark(p, c, m).addMark(p, c, C).setSelection(new Y(k.selection.$anchor)).scrollIntoView()
|
|
325
|
+
), !0) : !1;
|
|
326
|
+
}
|
|
327
|
+
);
|
|
319
328
|
n(dt, {
|
|
320
329
|
displayName: "Command<updateLinkCommand>",
|
|
321
330
|
group: "Link"
|
|
@@ -370,7 +379,10 @@ n(w.ctx, {
|
|
|
370
379
|
displayName: "NodeSchemaCtx<paragraph>",
|
|
371
380
|
group: "Paragraph"
|
|
372
381
|
});
|
|
373
|
-
const pe =
|
|
382
|
+
const pe = u(
|
|
383
|
+
"TurnIntoText",
|
|
384
|
+
(t) => () => K(w.type(t))
|
|
385
|
+
);
|
|
374
386
|
n(pe, {
|
|
375
387
|
displayName: "Command<turnIntoTextCommand>",
|
|
376
388
|
group: "Paragraph"
|
|
@@ -379,7 +391,7 @@ const ce = f("paragraphKeymap", {
|
|
|
379
391
|
TurnIntoText: {
|
|
380
392
|
shortcuts: "Mod-Alt-0",
|
|
381
393
|
command: (t) => {
|
|
382
|
-
const e = t.get(
|
|
394
|
+
const e = t.get(g);
|
|
383
395
|
return () => e.call(pe.key);
|
|
384
396
|
}
|
|
385
397
|
}
|
|
@@ -396,7 +408,10 @@ const Dt = Array(6).fill(0).map((t, e) => e + 1);
|
|
|
396
408
|
function _t(t) {
|
|
397
409
|
return Ht(t.textContent);
|
|
398
410
|
}
|
|
399
|
-
const z = Xe(
|
|
411
|
+
const z = Xe(
|
|
412
|
+
_t,
|
|
413
|
+
"headingIdGenerator"
|
|
414
|
+
);
|
|
400
415
|
n(z, {
|
|
401
416
|
displayName: "Ctx<HeadingIdGenerator>",
|
|
402
417
|
group: "Heading"
|
|
@@ -423,8 +438,7 @@ const H = I("heading", (t) => {
|
|
|
423
438
|
parseDOM: Dt.map((r) => ({
|
|
424
439
|
tag: `h${r}`,
|
|
425
440
|
getAttrs: (a) => {
|
|
426
|
-
if (!(a instanceof HTMLElement))
|
|
427
|
-
throw A(a);
|
|
441
|
+
if (!(a instanceof HTMLElement)) throw A(a);
|
|
428
442
|
return { level: r, id: a.id };
|
|
429
443
|
}
|
|
430
444
|
})),
|
|
@@ -459,36 +473,43 @@ n(H.ctx, {
|
|
|
459
473
|
displayName: "NodeSchemaCtx<heading>",
|
|
460
474
|
group: "Heading"
|
|
461
475
|
});
|
|
462
|
-
const pt = h((t) => Ze(
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
476
|
+
const pt = h((t) => Ze(
|
|
477
|
+
/^(?<hashes>#+)\s$/,
|
|
478
|
+
H.type(t),
|
|
479
|
+
(e) => {
|
|
480
|
+
var l, i;
|
|
481
|
+
const r = ((i = (l = e.groups) == null ? void 0 : l.hashes) == null ? void 0 : i.length) || 0, a = t.get(At), { $from: o } = a.state.selection, s = o.node();
|
|
482
|
+
if (s.type.name === "heading") {
|
|
483
|
+
let d = Number(s.attrs.level) + Number(r);
|
|
484
|
+
return d > 6 && (d = 6), { level: d };
|
|
485
|
+
}
|
|
486
|
+
return { level: r };
|
|
468
487
|
}
|
|
469
|
-
|
|
470
|
-
}));
|
|
488
|
+
));
|
|
471
489
|
n(pt, {
|
|
472
490
|
displayName: "InputRule<wrapInHeadingInputRule>",
|
|
473
491
|
group: "Heading"
|
|
474
492
|
});
|
|
475
|
-
const L =
|
|
493
|
+
const L = u("WrapInHeading", (t) => (e) => (e ?? (e = 1), e < 1 ? K(w.type(t)) : K(H.type(t), { level: e })));
|
|
476
494
|
n(L, {
|
|
477
495
|
displayName: "Command<wrapInHeadingCommand>",
|
|
478
496
|
group: "Heading"
|
|
479
497
|
});
|
|
480
|
-
const ge =
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
})
|
|
498
|
+
const ge = u(
|
|
499
|
+
"DowngradeHeading",
|
|
500
|
+
(t) => () => (e, r, a) => {
|
|
501
|
+
const { $from: o } = e.selection, s = o.node();
|
|
502
|
+
if (s.type !== H.type(t) || !e.selection.empty || o.parentOffset !== 0)
|
|
503
|
+
return !1;
|
|
504
|
+
const l = s.attrs.level - 1;
|
|
505
|
+
return l ? (r == null || r(
|
|
506
|
+
e.tr.setNodeMarkup(e.selection.$from.before(), void 0, {
|
|
507
|
+
...s.attrs,
|
|
508
|
+
level: l
|
|
509
|
+
})
|
|
510
|
+
), !0) : K(w.type(t))(e, r, a);
|
|
511
|
+
}
|
|
512
|
+
);
|
|
492
513
|
n(ge, {
|
|
493
514
|
displayName: "Command<downgradeHeadingCommand>",
|
|
494
515
|
group: "Heading"
|
|
@@ -497,49 +518,49 @@ const ke = f("headingKeymap", {
|
|
|
497
518
|
TurnIntoH1: {
|
|
498
519
|
shortcuts: "Mod-Alt-1",
|
|
499
520
|
command: (t) => {
|
|
500
|
-
const e = t.get(
|
|
521
|
+
const e = t.get(g);
|
|
501
522
|
return () => e.call(L.key, 1);
|
|
502
523
|
}
|
|
503
524
|
},
|
|
504
525
|
TurnIntoH2: {
|
|
505
526
|
shortcuts: "Mod-Alt-2",
|
|
506
527
|
command: (t) => {
|
|
507
|
-
const e = t.get(
|
|
528
|
+
const e = t.get(g);
|
|
508
529
|
return () => e.call(L.key, 2);
|
|
509
530
|
}
|
|
510
531
|
},
|
|
511
532
|
TurnIntoH3: {
|
|
512
533
|
shortcuts: "Mod-Alt-3",
|
|
513
534
|
command: (t) => {
|
|
514
|
-
const e = t.get(
|
|
535
|
+
const e = t.get(g);
|
|
515
536
|
return () => e.call(L.key, 3);
|
|
516
537
|
}
|
|
517
538
|
},
|
|
518
539
|
TurnIntoH4: {
|
|
519
540
|
shortcuts: "Mod-Alt-4",
|
|
520
541
|
command: (t) => {
|
|
521
|
-
const e = t.get(
|
|
542
|
+
const e = t.get(g);
|
|
522
543
|
return () => e.call(L.key, 4);
|
|
523
544
|
}
|
|
524
545
|
},
|
|
525
546
|
TurnIntoH5: {
|
|
526
547
|
shortcuts: "Mod-Alt-5",
|
|
527
548
|
command: (t) => {
|
|
528
|
-
const e = t.get(
|
|
549
|
+
const e = t.get(g);
|
|
529
550
|
return () => e.call(L.key, 5);
|
|
530
551
|
}
|
|
531
552
|
},
|
|
532
553
|
TurnIntoH6: {
|
|
533
554
|
shortcuts: "Mod-Alt-6",
|
|
534
555
|
command: (t) => {
|
|
535
|
-
const e = t.get(
|
|
556
|
+
const e = t.get(g);
|
|
536
557
|
return () => e.call(L.key, 6);
|
|
537
558
|
}
|
|
538
559
|
},
|
|
539
560
|
DowngradeHeading: {
|
|
540
561
|
shortcuts: ["Delete", "Backspace"],
|
|
541
562
|
command: (t) => {
|
|
542
|
-
const e = t.get(
|
|
563
|
+
const e = t.get(g);
|
|
543
564
|
return () => e.call(ge.key);
|
|
544
565
|
}
|
|
545
566
|
}
|
|
@@ -557,25 +578,28 @@ n(ye, {
|
|
|
557
578
|
displayName: "Attr<blockquote>",
|
|
558
579
|
group: "Blockquote"
|
|
559
580
|
});
|
|
560
|
-
const q = I(
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
e
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
e.
|
|
581
|
+
const q = I(
|
|
582
|
+
"blockquote",
|
|
583
|
+
(t) => ({
|
|
584
|
+
content: "block+",
|
|
585
|
+
group: "block",
|
|
586
|
+
defining: !0,
|
|
587
|
+
parseDOM: [{ tag: "blockquote" }],
|
|
588
|
+
toDOM: (e) => ["blockquote", t.get(ye.key)(e), 0],
|
|
589
|
+
parseMarkdown: {
|
|
590
|
+
match: ({ type: e }) => e === "blockquote",
|
|
591
|
+
runner: (e, r, a) => {
|
|
592
|
+
e.openNode(a).next(r.children).closeNode();
|
|
593
|
+
}
|
|
594
|
+
},
|
|
595
|
+
toMarkdown: {
|
|
596
|
+
match: (e) => e.type.name === "blockquote",
|
|
597
|
+
runner: (e, r) => {
|
|
598
|
+
e.openNode("blockquote").next(r.content).closeNode();
|
|
599
|
+
}
|
|
576
600
|
}
|
|
577
|
-
}
|
|
578
|
-
|
|
601
|
+
})
|
|
602
|
+
);
|
|
579
603
|
n(q.node, {
|
|
580
604
|
displayName: "NodeSchema<blockquote>",
|
|
581
605
|
group: "Blockquote"
|
|
@@ -584,12 +608,17 @@ n(q.ctx, {
|
|
|
584
608
|
displayName: "NodeSchemaCtx<blockquote>",
|
|
585
609
|
group: "Blockquote"
|
|
586
610
|
});
|
|
587
|
-
const ct = h(
|
|
611
|
+
const ct = h(
|
|
612
|
+
(t) => X(/^\s*>\s$/, q.type(t))
|
|
613
|
+
);
|
|
588
614
|
n(ct, {
|
|
589
615
|
displayName: "InputRule<wrapInBlockquoteInputRule>",
|
|
590
616
|
group: "Blockquote"
|
|
591
617
|
});
|
|
592
|
-
const he =
|
|
618
|
+
const he = u(
|
|
619
|
+
"WrapInBlockquote",
|
|
620
|
+
(t) => () => Q(q.type(t))
|
|
621
|
+
);
|
|
593
622
|
n(he, {
|
|
594
623
|
displayName: "Command<wrapInBlockquoteCommand>",
|
|
595
624
|
group: "Blockquote"
|
|
@@ -598,7 +627,7 @@ const fe = f("blockquoteKeymap", {
|
|
|
598
627
|
WrapInBlockquote: {
|
|
599
628
|
shortcuts: "Mod-Shift-b",
|
|
600
629
|
command: (t) => {
|
|
601
|
-
const e = t.get(
|
|
630
|
+
const e = t.get(g);
|
|
602
631
|
return () => e.call(he.key);
|
|
603
632
|
}
|
|
604
633
|
}
|
|
@@ -635,8 +664,7 @@ const W = I("code_block", (t) => ({
|
|
|
635
664
|
tag: "pre",
|
|
636
665
|
preserveWhitespace: "full",
|
|
637
666
|
getAttrs: (e) => {
|
|
638
|
-
if (!(e instanceof HTMLElement))
|
|
639
|
-
throw A(e);
|
|
667
|
+
if (!(e instanceof HTMLElement)) throw A(e);
|
|
640
668
|
return { language: e.dataset.language };
|
|
641
669
|
}
|
|
642
670
|
}
|
|
@@ -677,22 +705,37 @@ n(W.ctx, {
|
|
|
677
705
|
displayName: "NodeSchemaCtx<codeBlock>",
|
|
678
706
|
group: "CodeBlock"
|
|
679
707
|
});
|
|
680
|
-
const ut = h(
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
708
|
+
const ut = h(
|
|
709
|
+
(t) => Ze(
|
|
710
|
+
/^```(?<language>[a-z]*)?[\s\n]$/,
|
|
711
|
+
W.type(t),
|
|
712
|
+
(e) => {
|
|
713
|
+
var r;
|
|
714
|
+
return {
|
|
715
|
+
language: ((r = e.groups) == null ? void 0 : r.language) ?? ""
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
)
|
|
719
|
+
);
|
|
686
720
|
n(ut, {
|
|
687
721
|
displayName: "InputRule<createCodeBlockInputRule>",
|
|
688
722
|
group: "CodeBlock"
|
|
689
723
|
});
|
|
690
|
-
const Ie =
|
|
724
|
+
const Ie = u(
|
|
725
|
+
"CreateCodeBlock",
|
|
726
|
+
(t) => (e = "") => K(W.type(t), { language: e })
|
|
727
|
+
);
|
|
691
728
|
n(Ie, {
|
|
692
729
|
displayName: "Command<createCodeBlockCommand>",
|
|
693
730
|
group: "CodeBlock"
|
|
694
731
|
});
|
|
695
|
-
const Et =
|
|
732
|
+
const Et = u(
|
|
733
|
+
"UpdateCodeBlockLanguage",
|
|
734
|
+
() => ({ pos: t, language: e } = {
|
|
735
|
+
pos: -1,
|
|
736
|
+
language: ""
|
|
737
|
+
}) => (r, a) => t >= 0 ? (a == null || a(r.tr.setNodeAttribute(t, "language", e)), !0) : !1
|
|
738
|
+
);
|
|
696
739
|
n(Et, {
|
|
697
740
|
displayName: "Command<updateCodeBlockLanguageCommand>",
|
|
698
741
|
group: "CodeBlock"
|
|
@@ -701,7 +744,7 @@ const Ce = f("codeBlockKeymap", {
|
|
|
701
744
|
CreateCodeBlock: {
|
|
702
745
|
shortcuts: "Mod-Alt-c",
|
|
703
746
|
command: (t) => {
|
|
704
|
-
const e = t.get(
|
|
747
|
+
const e = t.get(g);
|
|
705
748
|
return () => e.call(Ie.key);
|
|
706
749
|
}
|
|
707
750
|
}
|
|
@@ -737,8 +780,7 @@ const v = I("image", (t) => ({
|
|
|
737
780
|
{
|
|
738
781
|
tag: "img[src]",
|
|
739
782
|
getAttrs: (e) => {
|
|
740
|
-
if (!(e instanceof HTMLElement))
|
|
741
|
-
throw A(e);
|
|
783
|
+
if (!(e instanceof HTMLElement)) throw A(e);
|
|
742
784
|
return {
|
|
743
785
|
src: e.getAttribute("src") || "",
|
|
744
786
|
alt: e.getAttribute("alt") || "",
|
|
@@ -778,34 +820,49 @@ n(v.ctx, {
|
|
|
778
820
|
displayName: "NodeSchemaCtx<image>",
|
|
779
821
|
group: "Image"
|
|
780
822
|
});
|
|
781
|
-
const gt =
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
823
|
+
const gt = u(
|
|
824
|
+
"InsertImage",
|
|
825
|
+
(t) => (e = {}) => (r, a) => {
|
|
826
|
+
if (!a) return !0;
|
|
827
|
+
const { src: o = "", alt: s = "", title: l = "" } = e, i = v.type(t).create({ src: o, alt: s, title: l });
|
|
828
|
+
return i && a(r.tr.replaceSelectionWith(i).scrollIntoView()), !0;
|
|
829
|
+
}
|
|
830
|
+
);
|
|
787
831
|
n(gt, {
|
|
788
832
|
displayName: "Command<insertImageCommand>",
|
|
789
833
|
group: "Image"
|
|
790
834
|
});
|
|
791
|
-
const kt =
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
835
|
+
const kt = u(
|
|
836
|
+
"UpdateImage",
|
|
837
|
+
(t) => (e = {}) => (r, a) => {
|
|
838
|
+
const o = Bt(
|
|
839
|
+
r.selection,
|
|
840
|
+
v.type(t)
|
|
841
|
+
);
|
|
842
|
+
if (!o) return !1;
|
|
843
|
+
const { node: s, pos: l } = o, i = { ...s.attrs }, { src: d, alt: m, title: p } = e;
|
|
844
|
+
return d !== void 0 && (i.src = d), m !== void 0 && (i.alt = m), p !== void 0 && (i.title = p), a == null || a(
|
|
845
|
+
r.tr.setNodeMarkup(l, void 0, i).scrollIntoView()
|
|
846
|
+
), !0;
|
|
847
|
+
}
|
|
848
|
+
);
|
|
798
849
|
n(kt, {
|
|
799
850
|
displayName: "Command<updateImageCommand>",
|
|
800
851
|
group: "Image"
|
|
801
852
|
});
|
|
802
|
-
const Pt = h(
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
853
|
+
const Pt = h(
|
|
854
|
+
(t) => new et(
|
|
855
|
+
/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,
|
|
856
|
+
(e, r, a, o) => {
|
|
857
|
+
const [s, l, i = "", d] = r;
|
|
858
|
+
return s ? e.tr.replaceWith(
|
|
859
|
+
a,
|
|
860
|
+
o,
|
|
861
|
+
v.type(t).create({ src: i, alt: l, title: d })
|
|
862
|
+
) : null;
|
|
863
|
+
}
|
|
864
|
+
)
|
|
865
|
+
);
|
|
809
866
|
n(Pt, {
|
|
810
867
|
displayName: "InputRule<insertImageInputRule>",
|
|
811
868
|
group: "Image"
|
|
@@ -827,13 +884,21 @@ const S = I("hardbreak", (t) => ({
|
|
|
827
884
|
}
|
|
828
885
|
},
|
|
829
886
|
selectable: !1,
|
|
830
|
-
parseDOM: [
|
|
887
|
+
parseDOM: [
|
|
888
|
+
{ tag: "br" },
|
|
889
|
+
{
|
|
890
|
+
tag: 'span[data-type="hardbreak"]',
|
|
891
|
+
getAttrs: () => ({ isInline: !0 })
|
|
892
|
+
}
|
|
893
|
+
],
|
|
831
894
|
toDOM: (e) => e.attrs.isInline ? ["span", t.get(V.key)(e), " "] : ["br", t.get(V.key)(e)],
|
|
832
895
|
parseMarkdown: {
|
|
833
896
|
match: ({ type: e }) => e === "break",
|
|
834
897
|
runner: (e, r, a) => {
|
|
835
898
|
var o;
|
|
836
|
-
e.addNode(a, {
|
|
899
|
+
e.addNode(a, {
|
|
900
|
+
isInline: !!((o = r.data) != null && o.isInline)
|
|
901
|
+
});
|
|
837
902
|
}
|
|
838
903
|
},
|
|
839
904
|
leafText: () => `
|
|
@@ -854,20 +919,28 @@ n(S.ctx, {
|
|
|
854
919
|
displayName: "NodeSchemaCtx<hardbreak>",
|
|
855
920
|
group: "Hardbreak"
|
|
856
921
|
});
|
|
857
|
-
const be =
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
922
|
+
const be = u(
|
|
923
|
+
"InsertHardbreak",
|
|
924
|
+
(t) => () => (e, r) => {
|
|
925
|
+
var s;
|
|
926
|
+
const { selection: a, tr: o } = e;
|
|
927
|
+
if (!(a instanceof Y)) return !1;
|
|
928
|
+
if (a.empty) {
|
|
929
|
+
const l = a.$from.node();
|
|
930
|
+
if (l.childCount > 0 && ((s = l.lastChild) == null ? void 0 : s.type.name) === "hardbreak")
|
|
931
|
+
return r == null || r(
|
|
932
|
+
o.replaceRangeWith(
|
|
933
|
+
a.to - 1,
|
|
934
|
+
a.to,
|
|
935
|
+
e.schema.node("paragraph")
|
|
936
|
+
).setSelection(tt.near(o.doc.resolve(a.to))).scrollIntoView()
|
|
937
|
+
), !0;
|
|
938
|
+
}
|
|
939
|
+
return r == null || r(
|
|
940
|
+
o.setMeta("hardbreak", !0).replaceSelectionWith(S.type(t).create()).scrollIntoView()
|
|
941
|
+
), !0;
|
|
868
942
|
}
|
|
869
|
-
|
|
870
|
-
});
|
|
943
|
+
);
|
|
871
944
|
n(be, {
|
|
872
945
|
displayName: "Command<insertHardbreakCommand>",
|
|
873
946
|
group: "Hardbreak"
|
|
@@ -876,7 +949,7 @@ const Le = f("hardbreakKeymap", {
|
|
|
876
949
|
InsertHardbreak: {
|
|
877
950
|
shortcuts: "Shift-Enter",
|
|
878
951
|
command: (t) => {
|
|
879
|
-
const e = t.get(
|
|
952
|
+
const e = t.get(g);
|
|
880
953
|
return () => e.call(be.key);
|
|
881
954
|
}
|
|
882
955
|
}
|
|
@@ -919,26 +992,26 @@ n(F.ctx, {
|
|
|
919
992
|
displayName: "NodeSchemaCtx<hr>",
|
|
920
993
|
group: "Hr"
|
|
921
994
|
});
|
|
922
|
-
const yt = h(
|
|
923
|
-
/^(?:---|___\s|\*\*\*\s)$/,
|
|
924
|
-
(e, r, a, o) => {
|
|
995
|
+
const yt = h(
|
|
996
|
+
(t) => new et(/^(?:---|___\s|\*\*\*\s)$/, (e, r, a, o) => {
|
|
925
997
|
const { tr: s } = e;
|
|
926
998
|
return r[0] && s.replaceWith(a - 1, o, F.type(t).create()), s;
|
|
927
|
-
}
|
|
928
|
-
)
|
|
999
|
+
})
|
|
1000
|
+
);
|
|
929
1001
|
n(yt, {
|
|
930
1002
|
displayName: "InputRule<insertHrInputRule>",
|
|
931
1003
|
group: "Hr"
|
|
932
1004
|
});
|
|
933
|
-
const ht =
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
return !0;
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
}
|
|
1005
|
+
const ht = u(
|
|
1006
|
+
"InsertHr",
|
|
1007
|
+
(t) => () => (e, r) => {
|
|
1008
|
+
if (!r) return !0;
|
|
1009
|
+
const a = w.node.type(t).create(), { tr: o, selection: s } = e, { from: l } = s, i = F.type(t).create();
|
|
1010
|
+
if (!i) return !0;
|
|
1011
|
+
const d = o.replaceSelectionWith(i).insert(l, a), m = tt.findFrom(d.doc.resolve(l), 1, !0);
|
|
1012
|
+
return m && r(d.setSelection(m).scrollIntoView()), !0;
|
|
1013
|
+
}
|
|
1014
|
+
);
|
|
942
1015
|
n(ht, {
|
|
943
1016
|
displayName: "Command<insertHrCommand>",
|
|
944
1017
|
group: "Hr"
|
|
@@ -960,8 +1033,7 @@ const O = I("bullet_list", (t) => ({
|
|
|
960
1033
|
{
|
|
961
1034
|
tag: "ul",
|
|
962
1035
|
getAttrs: (e) => {
|
|
963
|
-
if (!(e instanceof HTMLElement))
|
|
964
|
-
throw A(e);
|
|
1036
|
+
if (!(e instanceof HTMLElement)) throw A(e);
|
|
965
1037
|
return {
|
|
966
1038
|
spread: e.dataset.spread
|
|
967
1039
|
};
|
|
@@ -986,7 +1058,10 @@ const O = I("bullet_list", (t) => ({
|
|
|
986
1058
|
toMarkdown: {
|
|
987
1059
|
match: (e) => e.type.name === "bullet_list",
|
|
988
1060
|
runner: (e, r) => {
|
|
989
|
-
e.openNode("list", void 0, {
|
|
1061
|
+
e.openNode("list", void 0, {
|
|
1062
|
+
ordered: !1,
|
|
1063
|
+
spread: r.attrs.spread === "true"
|
|
1064
|
+
}).next(r.content).closeNode();
|
|
990
1065
|
}
|
|
991
1066
|
}
|
|
992
1067
|
}));
|
|
@@ -998,12 +1073,17 @@ n(O.ctx, {
|
|
|
998
1073
|
displayName: "NodeSchemaCtx<bulletList>",
|
|
999
1074
|
group: "BulletList"
|
|
1000
1075
|
});
|
|
1001
|
-
const ft = h(
|
|
1076
|
+
const ft = h(
|
|
1077
|
+
(t) => X(/^\s*([-+*])\s$/, O.type(t))
|
|
1078
|
+
);
|
|
1002
1079
|
n(ft, {
|
|
1003
1080
|
displayName: "InputRule<wrapInBulletListInputRule>",
|
|
1004
1081
|
group: "BulletList"
|
|
1005
1082
|
});
|
|
1006
|
-
const Ae =
|
|
1083
|
+
const Ae = u(
|
|
1084
|
+
"WrapInBulletList",
|
|
1085
|
+
(t) => () => Q(O.type(t))
|
|
1086
|
+
);
|
|
1007
1087
|
n(Ae, {
|
|
1008
1088
|
displayName: "Command<wrapInBulletListCommand>",
|
|
1009
1089
|
group: "BulletList"
|
|
@@ -1012,7 +1092,7 @@ const we = f("bulletListKeymap", {
|
|
|
1012
1092
|
WrapInBulletList: {
|
|
1013
1093
|
shortcuts: "Mod-Alt-8",
|
|
1014
1094
|
command: (t) => {
|
|
1015
|
-
const e = t.get(
|
|
1095
|
+
const e = t.get(g);
|
|
1016
1096
|
return () => e.call(Ae.key);
|
|
1017
1097
|
}
|
|
1018
1098
|
}
|
|
@@ -1045,8 +1125,7 @@ const T = I("ordered_list", (t) => ({
|
|
|
1045
1125
|
{
|
|
1046
1126
|
tag: "ol",
|
|
1047
1127
|
getAttrs: (e) => {
|
|
1048
|
-
if (!(e instanceof HTMLElement))
|
|
1049
|
-
throw A(e);
|
|
1128
|
+
if (!(e instanceof HTMLElement)) throw A(e);
|
|
1050
1129
|
return {
|
|
1051
1130
|
spread: e.dataset.spread,
|
|
1052
1131
|
order: e.hasAttribute("start") ? Number(e.getAttribute("start")) : 1
|
|
@@ -1073,7 +1152,11 @@ const T = I("ordered_list", (t) => ({
|
|
|
1073
1152
|
toMarkdown: {
|
|
1074
1153
|
match: (e) => e.type.name === "ordered_list",
|
|
1075
1154
|
runner: (e, r) => {
|
|
1076
|
-
e.openNode("list", void 0, {
|
|
1155
|
+
e.openNode("list", void 0, {
|
|
1156
|
+
ordered: !0,
|
|
1157
|
+
start: 1,
|
|
1158
|
+
spread: r.attrs.spread === "true"
|
|
1159
|
+
}), e.next(r.content), e.closeNode();
|
|
1077
1160
|
}
|
|
1078
1161
|
}
|
|
1079
1162
|
}));
|
|
@@ -1085,17 +1168,22 @@ n(T.ctx, {
|
|
|
1085
1168
|
displayName: "NodeSchemaCtx<orderedList>",
|
|
1086
1169
|
group: "OrderedList"
|
|
1087
1170
|
});
|
|
1088
|
-
const Nt = h(
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
))
|
|
1171
|
+
const Nt = h(
|
|
1172
|
+
(t) => X(
|
|
1173
|
+
/^\s*(\d+)\.\s$/,
|
|
1174
|
+
T.type(t),
|
|
1175
|
+
(e) => ({ order: Number(e[1]) }),
|
|
1176
|
+
(e, r) => r.childCount + r.attrs.order === Number(e[1])
|
|
1177
|
+
)
|
|
1178
|
+
);
|
|
1094
1179
|
n(Nt, {
|
|
1095
1180
|
displayName: "InputRule<wrapInOrderedListInputRule>",
|
|
1096
1181
|
group: "OrderedList"
|
|
1097
1182
|
});
|
|
1098
|
-
const Be =
|
|
1183
|
+
const Be = u(
|
|
1184
|
+
"WrapInOrderedList",
|
|
1185
|
+
(t) => () => Q(T.type(t))
|
|
1186
|
+
);
|
|
1099
1187
|
n(Be, {
|
|
1100
1188
|
displayName: "Command<wrapInOrderedListCommand>",
|
|
1101
1189
|
group: "OrderedList"
|
|
@@ -1104,7 +1192,7 @@ const Re = f("orderedListKeymap", {
|
|
|
1104
1192
|
WrapInOrderedList: {
|
|
1105
1193
|
shortcuts: "Mod-Alt-7",
|
|
1106
1194
|
command: (t) => {
|
|
1107
|
-
const e = t.get(
|
|
1195
|
+
const e = t.get(g);
|
|
1108
1196
|
return () => e.call(Be.key);
|
|
1109
1197
|
}
|
|
1110
1198
|
}
|
|
@@ -1141,8 +1229,7 @@ const M = I("list_item", (t) => ({
|
|
|
1141
1229
|
{
|
|
1142
1230
|
tag: "li",
|
|
1143
1231
|
getAttrs: (e) => {
|
|
1144
|
-
if (!(e instanceof HTMLElement))
|
|
1145
|
-
throw A(e);
|
|
1232
|
+
if (!(e instanceof HTMLElement)) throw A(e);
|
|
1146
1233
|
return {
|
|
1147
1234
|
label: e.dataset.label,
|
|
1148
1235
|
listType: e.dataset.listType,
|
|
@@ -1171,7 +1258,9 @@ const M = I("list_item", (t) => ({
|
|
|
1171
1258
|
toMarkdown: {
|
|
1172
1259
|
match: (e) => e.type.name === "list_item",
|
|
1173
1260
|
runner: (e, r) => {
|
|
1174
|
-
e.openNode("listItem", void 0, {
|
|
1261
|
+
e.openNode("listItem", void 0, {
|
|
1262
|
+
spread: r.attrs.spread === "true"
|
|
1263
|
+
}), e.next(r.content), e.closeNode();
|
|
1175
1264
|
}
|
|
1176
1265
|
}
|
|
1177
1266
|
}));
|
|
@@ -1183,17 +1272,26 @@ n(M.ctx, {
|
|
|
1183
1272
|
displayName: "NodeSchemaCtx<listItem>",
|
|
1184
1273
|
group: "ListItem"
|
|
1185
1274
|
});
|
|
1186
|
-
const Oe =
|
|
1275
|
+
const Oe = u(
|
|
1276
|
+
"SinkListItem",
|
|
1277
|
+
(t) => () => Rt(M.type(t))
|
|
1278
|
+
);
|
|
1187
1279
|
n(Oe, {
|
|
1188
1280
|
displayName: "Command<sinkListItemCommand>",
|
|
1189
1281
|
group: "ListItem"
|
|
1190
1282
|
});
|
|
1191
|
-
const Te =
|
|
1283
|
+
const Te = u(
|
|
1284
|
+
"LiftListItem",
|
|
1285
|
+
(t) => () => rt(M.type(t))
|
|
1286
|
+
);
|
|
1192
1287
|
n(Te, {
|
|
1193
1288
|
displayName: "Command<liftListItemCommand>",
|
|
1194
1289
|
group: "ListItem"
|
|
1195
1290
|
});
|
|
1196
|
-
const Ke =
|
|
1291
|
+
const Ke = u(
|
|
1292
|
+
"SplitListItem",
|
|
1293
|
+
(t) => () => vt(M.type(t))
|
|
1294
|
+
);
|
|
1197
1295
|
n(Ke, {
|
|
1198
1296
|
displayName: "Command<splitListItemCommand>",
|
|
1199
1297
|
group: "ListItem"
|
|
@@ -1201,16 +1299,17 @@ n(Ke, {
|
|
|
1201
1299
|
function $t(t) {
|
|
1202
1300
|
return (e, r, a) => {
|
|
1203
1301
|
const { selection: o } = e;
|
|
1204
|
-
if (!(o instanceof Y))
|
|
1205
|
-
return !1;
|
|
1302
|
+
if (!(o instanceof Y)) return !1;
|
|
1206
1303
|
const { empty: s, $from: l } = o;
|
|
1207
|
-
if (!s || l.parentOffset !== 0)
|
|
1208
|
-
return !1;
|
|
1304
|
+
if (!s || l.parentOffset !== 0) return !1;
|
|
1209
1305
|
const i = l.node(-1);
|
|
1210
1306
|
return i.type !== M.type(t) || i.firstChild !== l.node() || l.node(-2).childCount > 1 ? !1 : rt(M.type(t))(e, r, a);
|
|
1211
1307
|
};
|
|
1212
1308
|
}
|
|
1213
|
-
const De =
|
|
1309
|
+
const De = u(
|
|
1310
|
+
"LiftFirstListItem",
|
|
1311
|
+
(t) => () => $t(t)
|
|
1312
|
+
);
|
|
1214
1313
|
n(De, {
|
|
1215
1314
|
displayName: "Command<liftFirstListItemCommand>",
|
|
1216
1315
|
group: "ListItem"
|
|
@@ -1219,28 +1318,28 @@ const _e = f("listItemKeymap", {
|
|
|
1219
1318
|
NextListItem: {
|
|
1220
1319
|
shortcuts: "Enter",
|
|
1221
1320
|
command: (t) => {
|
|
1222
|
-
const e = t.get(
|
|
1321
|
+
const e = t.get(g);
|
|
1223
1322
|
return () => e.call(Ke.key);
|
|
1224
1323
|
}
|
|
1225
1324
|
},
|
|
1226
1325
|
SinkListItem: {
|
|
1227
1326
|
shortcuts: ["Tab", "Mod-]"],
|
|
1228
1327
|
command: (t) => {
|
|
1229
|
-
const e = t.get(
|
|
1328
|
+
const e = t.get(g);
|
|
1230
1329
|
return () => e.call(Oe.key);
|
|
1231
1330
|
}
|
|
1232
1331
|
},
|
|
1233
1332
|
LiftListItem: {
|
|
1234
1333
|
shortcuts: ["Shift-Tab", "Mod-["],
|
|
1235
1334
|
command: (t) => {
|
|
1236
|
-
const e = t.get(
|
|
1335
|
+
const e = t.get(g);
|
|
1237
1336
|
return () => e.call(Te.key);
|
|
1238
1337
|
}
|
|
1239
1338
|
},
|
|
1240
1339
|
LiftFirstListItem: {
|
|
1241
1340
|
shortcuts: ["Backspace", "Delete"],
|
|
1242
1341
|
command: (t) => {
|
|
1243
|
-
const e = t.get(
|
|
1342
|
+
const e = t.get(g);
|
|
1244
1343
|
return () => e.call(De.key);
|
|
1245
1344
|
}
|
|
1246
1345
|
}
|
|
@@ -1294,12 +1393,14 @@ const Pe = I("html", (t) => ({
|
|
|
1294
1393
|
};
|
|
1295
1394
|
return r.textContent = e.attrs.value, ["span", a, e.attrs.value];
|
|
1296
1395
|
},
|
|
1297
|
-
parseDOM: [
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1396
|
+
parseDOM: [
|
|
1397
|
+
{
|
|
1398
|
+
tag: 'span[data-type="html"]',
|
|
1399
|
+
getAttrs: (e) => ({
|
|
1400
|
+
value: e.dataset.value ?? ""
|
|
1401
|
+
})
|
|
1402
|
+
}
|
|
1403
|
+
],
|
|
1303
1404
|
parseMarkdown: {
|
|
1304
1405
|
match: ({ type: e }) => e === "html",
|
|
1305
1406
|
runner: (e, r, a) => {
|
|
@@ -1400,16 +1501,19 @@ const qt = [
|
|
|
1400
1501
|
re,
|
|
1401
1502
|
ie,
|
|
1402
1503
|
oe
|
|
1403
|
-
].flat(), $e = D(
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
e.
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
}
|
|
1504
|
+
].flat(), $e = D(
|
|
1505
|
+
"remarkAddOrderInList",
|
|
1506
|
+
() => () => (t) => {
|
|
1507
|
+
Z(t, "list", (e) => {
|
|
1508
|
+
if (e.ordered) {
|
|
1509
|
+
const r = e.start ?? 1;
|
|
1510
|
+
e.children.forEach((a, o) => {
|
|
1511
|
+
a.label = o + r;
|
|
1512
|
+
});
|
|
1513
|
+
}
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
);
|
|
1413
1517
|
n($e.plugin, {
|
|
1414
1518
|
displayName: "Remark<remarkAddOrderInListPlugin>",
|
|
1415
1519
|
group: "Remark"
|
|
@@ -1418,23 +1522,32 @@ n($e.options, {
|
|
|
1418
1522
|
displayName: "RemarkConfig<remarkAddOrderInListPlugin>",
|
|
1419
1523
|
group: "Remark"
|
|
1420
1524
|
});
|
|
1421
|
-
const qe = D(
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1525
|
+
const qe = D(
|
|
1526
|
+
"remarkLineBreak",
|
|
1527
|
+
() => () => (t) => {
|
|
1528
|
+
const e = /[\t ]*(?:\r?\n|\r)/g;
|
|
1529
|
+
Z(
|
|
1530
|
+
t,
|
|
1531
|
+
"text",
|
|
1532
|
+
(r, a, o) => {
|
|
1533
|
+
if (!r.value || typeof r.value != "string") return;
|
|
1534
|
+
const s = [];
|
|
1535
|
+
let l = 0;
|
|
1536
|
+
e.lastIndex = 0;
|
|
1537
|
+
let i = e.exec(r.value);
|
|
1538
|
+
for (; i; ) {
|
|
1539
|
+
const m = i.index;
|
|
1540
|
+
l !== m && s.push({
|
|
1541
|
+
type: "text",
|
|
1542
|
+
value: r.value.slice(l, m)
|
|
1543
|
+
}), s.push({ type: "break", data: { isInline: !0 } }), l = m + i[0].length, i = e.exec(r.value);
|
|
1544
|
+
}
|
|
1545
|
+
if (s.length > 0 && o && typeof a == "number")
|
|
1546
|
+
return l < r.value.length && s.push({ type: "text", value: r.value.slice(l) }), o.children.splice(a, 1, ...s), a + s.length;
|
|
1547
|
+
}
|
|
1548
|
+
);
|
|
1549
|
+
}
|
|
1550
|
+
);
|
|
1438
1551
|
n(qe.plugin, {
|
|
1439
1552
|
displayName: "Remark<remarkLineBreak>",
|
|
1440
1553
|
group: "Remark"
|
|
@@ -1443,7 +1556,10 @@ n(qe.options, {
|
|
|
1443
1556
|
displayName: "RemarkConfig<remarkLineBreak>",
|
|
1444
1557
|
group: "Remark"
|
|
1445
1558
|
});
|
|
1446
|
-
const We = D(
|
|
1559
|
+
const We = D(
|
|
1560
|
+
"remarkInlineLink",
|
|
1561
|
+
() => Kt
|
|
1562
|
+
);
|
|
1447
1563
|
n(We.plugin, {
|
|
1448
1564
|
displayName: "Remark<remarkInlineLinkPlugin>",
|
|
1449
1565
|
group: "Remark"
|
|
@@ -1463,8 +1579,8 @@ function zt(t, e) {
|
|
|
1463
1579
|
if (m) {
|
|
1464
1580
|
const p = r(m, i, a);
|
|
1465
1581
|
if (p)
|
|
1466
|
-
for (let
|
|
1467
|
-
const C = p[
|
|
1582
|
+
for (let c = 0, k = p.length; c < k; c++) {
|
|
1583
|
+
const C = p[c];
|
|
1468
1584
|
C && l.push(C);
|
|
1469
1585
|
}
|
|
1470
1586
|
}
|
|
@@ -1474,9 +1590,12 @@ function zt(t, e) {
|
|
|
1474
1590
|
return e(a, o, s);
|
|
1475
1591
|
}
|
|
1476
1592
|
}
|
|
1477
|
-
const Fe = D(
|
|
1478
|
-
|
|
1479
|
-
|
|
1593
|
+
const Fe = D(
|
|
1594
|
+
"remarkHTMLTransformer",
|
|
1595
|
+
() => () => (t) => {
|
|
1596
|
+
zt(t, (e, r, a) => jt(e) ? ((a == null ? void 0 : a.type) === "root" && (e.children = [{ ...e }], delete e.value, e.type = "paragraph"), [e]) : [e]);
|
|
1597
|
+
}
|
|
1598
|
+
);
|
|
1480
1599
|
n(Fe.plugin, {
|
|
1481
1600
|
displayName: "Remark<remarkHtmlTransformer>",
|
|
1482
1601
|
group: "Remark"
|
|
@@ -1485,12 +1604,19 @@ n(Fe.options, {
|
|
|
1485
1604
|
displayName: "RemarkConfig<remarkHtmlTransformer>",
|
|
1486
1605
|
group: "Remark"
|
|
1487
1606
|
});
|
|
1488
|
-
const Ve = D(
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1607
|
+
const Ve = D(
|
|
1608
|
+
"remarkMarker",
|
|
1609
|
+
() => () => (t, e) => {
|
|
1610
|
+
const r = (a) => e.value.charAt(a.position.start.offset);
|
|
1611
|
+
Z(
|
|
1612
|
+
t,
|
|
1613
|
+
(a) => ["strong", "emphasis"].includes(a.type),
|
|
1614
|
+
(a) => {
|
|
1615
|
+
a.marker = r(a);
|
|
1616
|
+
}
|
|
1617
|
+
);
|
|
1618
|
+
}
|
|
1619
|
+
);
|
|
1494
1620
|
n(Ve.plugin, {
|
|
1495
1621
|
displayName: "Remark<remarkMarker>",
|
|
1496
1622
|
group: "Remark"
|
|
@@ -1501,15 +1627,16 @@ n(Ve.options, {
|
|
|
1501
1627
|
});
|
|
1502
1628
|
const Ct = _(() => {
|
|
1503
1629
|
let t = !1;
|
|
1504
|
-
const e = new E(
|
|
1630
|
+
const e = new E(
|
|
1631
|
+
"MILKDOWN_INLINE_NODES_CURSOR"
|
|
1632
|
+
), r = new P({
|
|
1505
1633
|
key: e,
|
|
1506
1634
|
state: {
|
|
1507
1635
|
init() {
|
|
1508
1636
|
return !1;
|
|
1509
1637
|
},
|
|
1510
1638
|
apply(a) {
|
|
1511
|
-
if (!a.selection.empty)
|
|
1512
|
-
return !1;
|
|
1639
|
+
if (!a.selection.empty) return !1;
|
|
1513
1640
|
const o = a.selection.$from, s = o.nodeBefore, l = o.nodeAfter;
|
|
1514
1641
|
return !!(s && l && s.isInline && !s.isText && l.isInline && !l.isText);
|
|
1515
1642
|
}
|
|
@@ -1553,23 +1680,30 @@ n(Ct, {
|
|
|
1553
1680
|
const Mt = _((t) => new P({
|
|
1554
1681
|
key: new E("MILKDOWN_HARDBREAK_MARKS"),
|
|
1555
1682
|
appendTransaction: (e, r, a) => {
|
|
1556
|
-
if (!e.length)
|
|
1557
|
-
return;
|
|
1683
|
+
if (!e.length) return;
|
|
1558
1684
|
const [o] = e;
|
|
1559
|
-
if (!o)
|
|
1560
|
-
return;
|
|
1685
|
+
if (!o) return;
|
|
1561
1686
|
const [s] = o.steps;
|
|
1562
1687
|
if (o.getMeta("hardbreak")) {
|
|
1563
|
-
if (!(s instanceof Ot))
|
|
1564
|
-
return;
|
|
1688
|
+
if (!(s instanceof Ot)) return;
|
|
1565
1689
|
const { from: d } = s;
|
|
1566
|
-
return a.tr.setNodeMarkup(
|
|
1690
|
+
return a.tr.setNodeMarkup(
|
|
1691
|
+
d,
|
|
1692
|
+
S.type(t),
|
|
1693
|
+
void 0,
|
|
1694
|
+
[]
|
|
1695
|
+
);
|
|
1567
1696
|
}
|
|
1568
1697
|
if (s instanceof Tt) {
|
|
1569
1698
|
let d = a.tr;
|
|
1570
1699
|
const { from: m, to: p } = s;
|
|
1571
|
-
return a.doc.nodesBetween(m, p, (
|
|
1572
|
-
|
|
1700
|
+
return a.doc.nodesBetween(m, p, (c, k) => {
|
|
1701
|
+
c.type === S.type(t) && (d = d.setNodeMarkup(
|
|
1702
|
+
k,
|
|
1703
|
+
S.type(t),
|
|
1704
|
+
void 0,
|
|
1705
|
+
[]
|
|
1706
|
+
));
|
|
1573
1707
|
}), d;
|
|
1574
1708
|
}
|
|
1575
1709
|
}
|
|
@@ -1578,7 +1712,10 @@ n(Mt, {
|
|
|
1578
1712
|
displayName: "Prose<hardbreakClearMarkPlugin>",
|
|
1579
1713
|
group: "Prose"
|
|
1580
1714
|
});
|
|
1581
|
-
const Ue = Xe(
|
|
1715
|
+
const Ue = Xe(
|
|
1716
|
+
["table", "code_block"],
|
|
1717
|
+
"hardbreakFilterNodes"
|
|
1718
|
+
);
|
|
1582
1719
|
n(Ue, {
|
|
1583
1720
|
displayName: "Ctx<hardbreakFilterNodes>",
|
|
1584
1721
|
group: "Prose"
|
|
@@ -1606,18 +1743,18 @@ n(bt, {
|
|
|
1606
1743
|
});
|
|
1607
1744
|
const Lt = _((t) => {
|
|
1608
1745
|
const e = new E("MILKDOWN_HEADING_ID"), r = (a) => {
|
|
1609
|
-
if (a.composing)
|
|
1610
|
-
return;
|
|
1746
|
+
if (a.composing) return;
|
|
1611
1747
|
const o = t.get(z.key), s = a.state.tr.setMeta("addToHistory", !1);
|
|
1612
1748
|
let l = !1;
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
const
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1749
|
+
const i = {};
|
|
1750
|
+
a.state.doc.descendants((d, m) => {
|
|
1751
|
+
if (d.type === H.type(t)) {
|
|
1752
|
+
if (d.textContent.trim().length === 0) return;
|
|
1753
|
+
const p = d.attrs;
|
|
1754
|
+
let c = o(d);
|
|
1755
|
+
i[c] ? (i[c] += 1, c += `-#${i[c]}`) : i[c] = 1, p.id !== c && (l = !0, s.setMeta(e, !0).setNodeMarkup(m, void 0, {
|
|
1756
|
+
...p,
|
|
1757
|
+
id: c
|
|
1621
1758
|
}));
|
|
1622
1759
|
}
|
|
1623
1760
|
}), l && a.dispatch(s);
|
|
@@ -1637,28 +1774,27 @@ n(Lt, {
|
|
|
1637
1774
|
});
|
|
1638
1775
|
const xt = _((t) => {
|
|
1639
1776
|
const e = (r) => {
|
|
1640
|
-
if (r.composing || !r.editable)
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
return p.label !== C && (p.label = C, g = !0), g;
|
|
1777
|
+
if (r.composing || !r.editable) return;
|
|
1778
|
+
const a = T.type(t), o = O.type(t), s = M.type(t), l = r.state, i = (p, c) => {
|
|
1779
|
+
let k = !1;
|
|
1780
|
+
const C = `${c + 1}.`;
|
|
1781
|
+
return p.label !== C && (p.label = C, k = !0), k;
|
|
1646
1782
|
};
|
|
1647
1783
|
let d = l.tr, m = !1;
|
|
1648
|
-
l.doc.descendants((p,
|
|
1784
|
+
l.doc.descendants((p, c, k, C) => {
|
|
1649
1785
|
if (p.type === o) {
|
|
1650
|
-
const
|
|
1651
|
-
(
|
|
1786
|
+
const y = p.maybeChild(0);
|
|
1787
|
+
(y == null ? void 0 : y.type) === s && y.attrs.listType === "ordered" && (m = !0, d.setNodeMarkup(c, a, { spread: "true" }), p.descendants((b, Ge, Qt, St) => {
|
|
1652
1788
|
if (b.type === s) {
|
|
1653
1789
|
const je = { ...b.attrs };
|
|
1654
1790
|
i(je, St) && (d = d.setNodeMarkup(Ge, void 0, je));
|
|
1655
1791
|
}
|
|
1656
1792
|
return !1;
|
|
1657
1793
|
}));
|
|
1658
|
-
} else if (p.type === s && (
|
|
1659
|
-
const
|
|
1794
|
+
} else if (p.type === s && (k == null ? void 0 : k.type) === a) {
|
|
1795
|
+
const y = { ...p.attrs };
|
|
1660
1796
|
let b = !1;
|
|
1661
|
-
|
|
1797
|
+
y.listType !== "ordered" && (y.listType = "ordered", b = !0), (k == null ? void 0 : k.maybeChild(0)) && (b = i(y, C)), b && (d = d.setNodeMarkup(c, void 0, y), m = !0);
|
|
1662
1798
|
}
|
|
1663
1799
|
}), m && r.dispatch(d.setMeta("addToHistory", !1));
|
|
1664
1800
|
};
|
|
@@ -1687,7 +1823,14 @@ const Jt = [
|
|
|
1687
1823
|
Ve,
|
|
1688
1824
|
Lt,
|
|
1689
1825
|
xt
|
|
1690
|
-
].flat(), cr = [
|
|
1826
|
+
].flat(), cr = [
|
|
1827
|
+
qt,
|
|
1828
|
+
Wt,
|
|
1829
|
+
Ft,
|
|
1830
|
+
Vt,
|
|
1831
|
+
Ut,
|
|
1832
|
+
Jt
|
|
1833
|
+
].flat();
|
|
1691
1834
|
export {
|
|
1692
1835
|
ye as blockquoteAttr,
|
|
1693
1836
|
fe as blockquoteKeymap,
|