@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.
Files changed (69) hide show
  1. package/lib/__internal__/serialize-text.d.ts.map +1 -1
  2. package/lib/__internal__/with-meta.d.ts.map +1 -1
  3. package/lib/composed/commands.d.ts.map +1 -1
  4. package/lib/composed/inputrules.d.ts.map +1 -1
  5. package/lib/composed/keymap.d.ts.map +1 -1
  6. package/lib/composed/schema.d.ts.map +1 -1
  7. package/lib/index.d.ts.map +1 -1
  8. package/lib/index.es.js +412 -269
  9. package/lib/index.es.js.map +1 -1
  10. package/lib/mark/emphasis.d.ts.map +1 -1
  11. package/lib/mark/inline-code.d.ts.map +1 -1
  12. package/lib/mark/link.d.ts.map +1 -1
  13. package/lib/mark/strong.d.ts.map +1 -1
  14. package/lib/node/blockquote.d.ts.map +1 -1
  15. package/lib/node/bullet-list.d.ts.map +1 -1
  16. package/lib/node/code-block.d.ts.map +1 -1
  17. package/lib/node/hardbreak.d.ts.map +1 -1
  18. package/lib/node/heading.d.ts.map +1 -1
  19. package/lib/node/hr.d.ts.map +1 -1
  20. package/lib/node/html.d.ts.map +1 -1
  21. package/lib/node/image.d.ts.map +1 -1
  22. package/lib/node/list-item.d.ts.map +1 -1
  23. package/lib/node/ordered-list.d.ts.map +1 -1
  24. package/lib/node/paragraph.d.ts.map +1 -1
  25. package/lib/plugin/hardbreak-clear-mark-plugin.d.ts.map +1 -1
  26. package/lib/plugin/hardbreak-filter-plugin.d.ts.map +1 -1
  27. package/lib/plugin/inline-nodes-cursor-plugin.d.ts.map +1 -1
  28. package/lib/plugin/remark-add-order-in-list-plugin.d.ts.map +1 -1
  29. package/lib/plugin/remark-html-transformer.d.ts.map +1 -1
  30. package/lib/plugin/remark-inline-link-plugin.d.ts.map +1 -1
  31. package/lib/plugin/remark-line-break.d.ts.map +1 -1
  32. package/lib/plugin/remark-marker-plugin.d.ts.map +1 -1
  33. package/lib/plugin/sync-heading-id-plugin.d.ts.map +1 -1
  34. package/lib/plugin/sync-list-order-plugin.d.ts.map +1 -1
  35. package/package.json +7 -7
  36. package/src/__internal__/serialize-text.ts +3 -4
  37. package/src/__internal__/with-meta.ts +4 -1
  38. package/src/composed/commands.ts +7 -1
  39. package/src/composed/inputrules.ts +14 -2
  40. package/src/composed/keymap.ts +10 -1
  41. package/src/composed/schema.ts +10 -1
  42. package/src/index.ts +16 -2
  43. package/src/mark/emphasis.ts +19 -9
  44. package/src/mark/inline-code.ts +40 -30
  45. package/src/mark/link.ts +55 -45
  46. package/src/mark/strong.ts +13 -7
  47. package/src/node/blockquote.ts +34 -20
  48. package/src/node/bullet-list.ts +20 -7
  49. package/src/node/code-block.ts +43 -18
  50. package/src/node/doc.ts +1 -1
  51. package/src/node/hardbreak.ts +49 -28
  52. package/src/node/heading.ts +44 -27
  53. package/src/node/hr.ts +27 -28
  54. package/src/node/html.ts +10 -8
  55. package/src/node/image.ts +57 -43
  56. package/src/node/list-item.ts +35 -18
  57. package/src/node/ordered-list.ts +31 -15
  58. package/src/node/paragraph.ts +10 -10
  59. package/src/node/text.ts +1 -1
  60. package/src/plugin/hardbreak-clear-mark-plugin.ts +16 -9
  61. package/src/plugin/hardbreak-filter-plugin.ts +5 -3
  62. package/src/plugin/inline-nodes-cursor-plugin.ts +13 -6
  63. package/src/plugin/remark-add-order-in-list-plugin.ts +13 -10
  64. package/src/plugin/remark-html-transformer.ts +24 -17
  65. package/src/plugin/remark-inline-link-plugin.ts +4 -1
  66. package/src/plugin/remark-line-break.ts +39 -26
  67. package/src/plugin/remark-marker-plugin.ts +14 -7
  68. package/src/plugin/sync-heading-id-plugin.ts +12 -9
  69. 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 c, $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 u, editorViewCtx as At } from "@milkdown/core";
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 = c("ToggleEmphasis", (t) => () => J(R.type(t)));
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(u);
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 = c("ToggleStrong", (t) => () => J($.type(t)));
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(u);
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 = c("ToggleInlineCode", (t) => () => (e, r) => {
220
- const { selection: a, tr: o } = e;
221
- if (a.empty)
222
- return !1;
223
- const { from: s, to: l } = a;
224
- 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((m) => m !== x.type.name).map((m) => e.schema.marks[m]).forEach((m) => {
225
- o.removeMark(s, l, m);
226
- }), r == null || r(o.addMark(s, l, x.type(t).create())), !0);
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(/(?:\`)([^\`]+)(?:\`)$/, x.type(t)));
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(u);
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
- throw A(e);
270
- return { href: e.getAttribute("href"), title: e.getAttribute("title") };
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 = c("ToggleLink", (t) => (e = {}) => J(B.type(t), e));
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 = c("UpdateLink", (t) => (e = {}) => (r, a) => {
302
- if (!a)
303
- return !1;
304
- let o, s = -1;
305
- const { selection: l } = r, { from: i, to: d } = l;
306
- if (r.doc.nodesBetween(i, i === d ? d + 1 : d, (k, b) => {
307
- if (B.type(t).isInSet(k.marks))
308
- return o = k, s = b, !1;
309
- }), !o)
310
- return !1;
311
- const m = o.marks.find(({ type: k }) => k === B.type(t));
312
- if (!m)
313
- return !1;
314
- const p = s, y = s + o.nodeSize, { tr: g } = r, C = B.type(t).create({ ...m.attrs, ...e });
315
- return C ? (a(
316
- g.removeMark(p, y, m).addMark(p, y, C).setSelection(new Y(g.selection.$anchor)).scrollIntoView()
317
- ), !0) : !1;
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 = c("TurnIntoText", (t) => () => K(w.type(t)));
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(u);
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(_t, "headingIdGenerator");
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(/^(?<hashes>#+)\s$/, H.type(t), (e) => {
463
- var l, i;
464
- 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();
465
- if (s.type.name === "heading") {
466
- let d = Number(s.attrs.level) + Number(r);
467
- return d > 6 && (d = 6), { level: d };
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
- return { level: r };
470
- }));
488
+ ));
471
489
  n(pt, {
472
490
  displayName: "InputRule<wrapInHeadingInputRule>",
473
491
  group: "Heading"
474
492
  });
475
- const L = c("WrapInHeading", (t) => (e) => (e ?? (e = 1), e < 1 ? K(w.type(t)) : K(H.type(t), { level: e })));
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 = c("DowngradeHeading", (t) => () => (e, r, a) => {
481
- const { $from: o } = e.selection, s = o.node();
482
- if (s.type !== H.type(t) || !e.selection.empty || o.parentOffset !== 0)
483
- return !1;
484
- const l = s.attrs.level - 1;
485
- return l ? (r == null || r(
486
- e.tr.setNodeMarkup(e.selection.$from.before(), void 0, {
487
- ...s.attrs,
488
- level: l
489
- })
490
- ), !0) : K(w.type(t))(e, r, a);
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(u);
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(u);
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(u);
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(u);
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(u);
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(u);
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(u);
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("blockquote", (t) => ({
561
- content: "block+",
562
- group: "block",
563
- defining: !0,
564
- parseDOM: [{ tag: "blockquote" }],
565
- toDOM: (e) => ["blockquote", t.get(ye.key)(e), 0],
566
- parseMarkdown: {
567
- match: ({ type: e }) => e === "blockquote",
568
- runner: (e, r, a) => {
569
- e.openNode(a).next(r.children).closeNode();
570
- }
571
- },
572
- toMarkdown: {
573
- match: (e) => e.type.name === "blockquote",
574
- runner: (e, r) => {
575
- e.openNode("blockquote").next(r.content).closeNode();
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((t) => X(/^\s*>\s$/, q.type(t)));
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 = c("WrapInBlockquote", (t) => () => Q(q.type(t)));
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(u);
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((t) => Ze(/^```(?<language>[a-z]*)?[\s\n]$/, W.type(t), (e) => {
681
- var r;
682
- return {
683
- language: ((r = e.groups) == null ? void 0 : r.language) ?? ""
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 = c("CreateCodeBlock", (t) => (e = "") => K(W.type(t), { language: e }));
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 = c("UpdateCodeBlockLanguage", () => ({ pos: t, language: e } = { pos: -1, language: "" }) => (r, a) => t >= 0 ? (a == null || a(r.tr.setNodeAttribute(t, "language", e)), !0) : !1);
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(u);
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 = c("InsertImage", (t) => (e = {}) => (r, a) => {
782
- if (!a)
783
- return !0;
784
- const { src: o = "", alt: s = "", title: l = "" } = e, i = v.type(t).create({ src: o, alt: s, title: l });
785
- return i && a(r.tr.replaceSelectionWith(i).scrollIntoView()), !0;
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 = c("UpdateImage", (t) => (e = {}) => (r, a) => {
792
- const o = Bt(r.selection, v.type(t));
793
- if (!o)
794
- return !1;
795
- const { node: s, pos: l } = o, i = { ...s.attrs }, { src: d, alt: m, title: p } = e;
796
- return d !== void 0 && (i.src = d), m !== void 0 && (i.alt = m), p !== void 0 && (i.title = p), a == null || a(r.tr.setNodeMarkup(l, void 0, i).scrollIntoView()), !0;
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((t) => new et(
803
- /!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,
804
- (e, r, a, o) => {
805
- const [s, l, i = "", d] = r;
806
- return s ? e.tr.replaceWith(a, o, v.type(t).create({ src: i, alt: l, title: d })) : null;
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: [{ tag: "br" }, { tag: 'span[data-type="hardbreak"]', getAttrs: () => ({ isInline: !0 }) }],
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, { isInline: !!((o = r.data) != null && o.isInline) });
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 = c("InsertHardbreak", (t) => () => (e, r) => {
858
- var s;
859
- const { selection: a, tr: o } = e;
860
- if (!(a instanceof Y))
861
- return !1;
862
- if (a.empty) {
863
- const l = a.$from.node();
864
- if (l.childCount > 0 && ((s = l.lastChild) == null ? void 0 : s.type.name) === "hardbreak")
865
- return r == null || r(
866
- o.replaceRangeWith(a.to - 1, a.to, e.schema.node("paragraph")).setSelection(tt.near(o.doc.resolve(a.to))).scrollIntoView()
867
- ), !0;
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
- return r == null || r(o.setMeta("hardbreak", !0).replaceSelectionWith(S.type(t).create()).scrollIntoView()), !0;
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(u);
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((t) => new et(
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 = c("InsertHr", (t) => () => (e, r) => {
934
- if (!r)
935
- return !0;
936
- const a = w.node.type(t).create(), { tr: o, selection: s } = e, { from: l } = s, i = F.type(t).create();
937
- if (!i)
938
- return !0;
939
- const d = o.replaceSelectionWith(i).insert(l, a), m = tt.findFrom(d.doc.resolve(l), 1, !0);
940
- return m && r(d.setSelection(m).scrollIntoView()), !0;
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, { ordered: !1, spread: r.attrs.spread === "true" }).next(r.content).closeNode();
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((t) => X(/^\s*([-+*])\s$/, O.type(t)));
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 = c("WrapInBulletList", (t) => () => Q(O.type(t)));
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(u);
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, { ordered: !0, start: 1, spread: r.attrs.spread === "true" }), e.next(r.content), e.closeNode();
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((t) => X(
1089
- /^\s*(\d+)\.\s$/,
1090
- T.type(t),
1091
- (e) => ({ order: Number(e[1]) }),
1092
- (e, r) => r.childCount + r.attrs.order === Number(e[1])
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 = c("WrapInOrderedList", (t) => () => Q(T.type(t)));
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(u);
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, { spread: r.attrs.spread === "true" }), e.next(r.content), e.closeNode();
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 = c("SinkListItem", (t) => () => Rt(M.type(t)));
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 = c("LiftListItem", (t) => () => rt(M.type(t)));
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 = c("SplitListItem", (t) => () => vt(M.type(t)));
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 = c("LiftFirstListItem", (t) => () => $t(t));
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(u);
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(u);
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(u);
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(u);
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
- tag: 'span[data-type="html"]',
1299
- getAttrs: (e) => ({
1300
- value: e.dataset.value ?? ""
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("remarkAddOrderInList", () => () => (t) => {
1404
- Z(t, "list", (e) => {
1405
- if (e.ordered) {
1406
- const r = e.start ?? 1;
1407
- e.children.forEach((a, o) => {
1408
- a.label = o + r;
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("remarkLineBreak", () => () => (t) => {
1422
- const e = /[\t ]*(?:\r?\n|\r)/g;
1423
- Z(t, "text", (r, a, o) => {
1424
- if (!r.value || typeof r.value != "string")
1425
- return;
1426
- const s = [];
1427
- let l = 0;
1428
- e.lastIndex = 0;
1429
- let i = e.exec(r.value);
1430
- for (; i; ) {
1431
- const m = i.index;
1432
- l !== m && s.push({ type: "text", value: r.value.slice(l, m) }), s.push({ type: "break", data: { isInline: !0 } }), l = m + i[0].length, i = e.exec(r.value);
1433
- }
1434
- if (s.length > 0 && o && typeof a == "number")
1435
- return l < r.value.length && s.push({ type: "text", value: r.value.slice(l) }), o.children.splice(a, 1, ...s), a + s.length;
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("remarkInlineLink", () => Kt);
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 y = 0, g = p.length; y < g; y++) {
1467
- const C = p[y];
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("remarkHTMLTransformer", () => () => (t) => {
1478
- 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]);
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("remarkMarker", () => () => (t, e) => {
1489
- const r = (a) => e.value.charAt(a.position.start.offset);
1490
- Z(t, (a) => ["strong", "emphasis"].includes(a.type), (a) => {
1491
- a.marker = r(a);
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("MILKDOWN_INLINE_NODES_CURSOR"), r = new P({
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(d, S.type(t), void 0, []);
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, (y, g) => {
1572
- y.type === S.type(t) && (d = d.setNodeMarkup(g, S.type(t), void 0, []));
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(["table", "code_block"], "hardbreakFilterNodes");
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
- a.state.doc.descendants((i, d) => {
1614
- if (i.type === H.type(t)) {
1615
- if (i.textContent.trim().length === 0)
1616
- return;
1617
- const m = i.attrs, p = o(i);
1618
- m.id !== p && (l = !0, s.setMeta(e, !0).setNodeMarkup(d, void 0, {
1619
- ...m,
1620
- id: p
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
- return;
1642
- const a = T.type(t), o = O.type(t), s = M.type(t), l = r.state, i = (p, y) => {
1643
- let g = !1;
1644
- const C = `${y + 1}.`;
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, y, g, C) => {
1784
+ l.doc.descendants((p, c, k, C) => {
1649
1785
  if (p.type === o) {
1650
- const k = p.maybeChild(0);
1651
- (k == null ? void 0 : k.type) === s && k.attrs.listType === "ordered" && (m = !0, d.setNodeMarkup(y, a, { spread: "true" }), p.descendants((b, Ge, Qt, St) => {
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 && (g == null ? void 0 : g.type) === a) {
1659
- const k = { ...p.attrs };
1794
+ } else if (p.type === s && (k == null ? void 0 : k.type) === a) {
1795
+ const y = { ...p.attrs };
1660
1796
  let b = !1;
1661
- k.listType !== "ordered" && (k.listType = "ordered", b = !0), (g == null ? void 0 : g.maybeChild(0)) && (b = i(k, C)), b && (d = d.setNodeMarkup(y, void 0, k), m = !0);
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 = [qt, Wt, Ft, Vt, Ut, Jt].flat();
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,