@milkdown/preset-gfm 7.6.2 → 7.6.3

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/README.md CHANGED
@@ -4,7 +4,7 @@ The gfm preset of [milkdown](https://milkdown.dev/).
4
4
 
5
5
  # Official Documentation
6
6
 
7
- Documentation can be found on the [Milkdown website](https://milkdown.dev/docs/api/preset-gfm).
7
+ Documentation can be found on the [Milkdown website](https://milkdown.dev/).
8
8
 
9
9
  # License
10
10
 
package/lib/index.es.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { expectDomTypeError as K } from "@milkdown/exception";
2
2
  import { paragraphSchema as De, listItemSchema as Ee } from "@milkdown/preset-commonmark";
3
3
  import { InputRule as ne } from "@milkdown/prose/inputrules";
4
- import { $markAttr as Oe, $markSchema as He, $command as g, $inputRule as F, $useKeymap as le, $nodeSchema as C, $prose as _, $remark as Be } from "@milkdown/utils";
5
- import { tableNodes as Le, TableMap as h, CellSelection as k, goToNextCell as re, isInTable as G, deleteTable as Ke, deleteColumn as Fe, deleteRow as Ge, addColumnBefore as We, addColumnAfter as ze, selectedRect as ae, setCellAttr as je, columnResizing as Ve, tableEditing as Ue } from "@milkdown/prose/tables";
4
+ import { $markAttr as Oe, $markSchema as He, $inputRule as F, $useKeymap as le, $command as g, $nodeSchema as C, $prose as v, $remark as Be } from "@milkdown/utils";
5
+ import { tableNodes as Le, TableMap as h, CellSelection as k, goToNextCell as re, isInTable as G, deleteTable as Ke, deleteColumn as Fe, deleteRow as Ge, selectedRect as ae, addColumnBefore as We, addColumnAfter as ze, setCellAttr as je, columnResizing as Ve, tableEditing as Ue } from "@milkdown/prose/tables";
6
6
  import { commandsCtx as A } from "@milkdown/core";
7
7
  import { toggleMark as Xe } from "@milkdown/prose/commands";
8
- import { markRule as qe, findParentNodeClosestToPos as se, cloneTr as $, findParentNodeType as Je } from "@milkdown/prose";
9
- import { Selection as ce, TextSelection as Qe, PluginKey as Ye, Plugin as Ze } from "@milkdown/prose/state";
8
+ import { markRule as qe, findParentNodeClosestToPos as se, cloneTr as _, findParentNodeType as Je } from "@milkdown/prose";
9
+ import { Selection as ce, TextSelection as Qe, Plugin as Ye, PluginKey as Ze } from "@milkdown/prose/state";
10
10
  import { imeSpan as et } from "prosemirror-safari-ime-span";
11
11
  import tt from "remark-gfm";
12
12
  function i(e, t) {
@@ -130,7 +130,7 @@ i(N.ctx, {
130
130
  displayName: "NodeSchemaCtx<table>",
131
131
  group: "Table"
132
132
  });
133
- const I = C("table_header_row", () => ({
133
+ const $ = C("table_header_row", () => ({
134
134
  ...S.table_row,
135
135
  disableDropCursor: !0,
136
136
  content: "(table_header)*",
@@ -156,11 +156,11 @@ const I = C("table_header_row", () => ({
156
156
  }
157
157
  }
158
158
  }));
159
- i(I.node, {
159
+ i($.node, {
160
160
  displayName: "NodeSchema<tableHeaderRow>",
161
161
  group: "Table"
162
162
  });
163
- i(I.ctx, {
163
+ i($.ctx, {
164
164
  displayName: "NodeSchemaCtx<tableHeaderRow>",
165
165
  group: "Table"
166
166
  });
@@ -218,7 +218,7 @@ i(x.ctx, {
218
218
  displayName: "NodeSchemaCtx<tableCell>",
219
219
  group: "Table"
220
220
  });
221
- const v = C("table_header", () => ({
221
+ const I = C("table_header", () => ({
222
222
  ...S.table_header,
223
223
  disableDropCursor: !0,
224
224
  parseMarkdown: {
@@ -235,17 +235,17 @@ const v = C("table_header", () => ({
235
235
  }
236
236
  }
237
237
  }));
238
- i(v.node, {
238
+ i(I.node, {
239
239
  displayName: "NodeSchema<tableHeader>",
240
240
  group: "Table"
241
241
  });
242
- i(v.ctx, {
242
+ i(I.ctx, {
243
243
  displayName: "NodeSchemaCtx<tableHeader>",
244
244
  group: "Table"
245
245
  });
246
246
  function de(e, t = 3, n = 3) {
247
- const o = Array(n).fill(0).map(() => x.type(e).createAndFill()), l = Array(n).fill(0).map(() => v.type(e).createAndFill()), r = Array(t).fill(0).map(
248
- (s, c) => c === 0 ? I.type(e).create(null, l) : R.type(e).create(null, o)
247
+ const o = Array(n).fill(0).map(() => x.type(e).createAndFill()), l = Array(n).fill(0).map(() => I.type(e).createAndFill()), r = Array(t).fill(0).map(
248
+ (s, c) => c === 0 ? $.type(e).create(null, l) : R.type(e).create(null, o)
249
249
  );
250
250
  return N.type(e).create(null, r);
251
251
  }
@@ -316,19 +316,19 @@ function nt(e) {
316
316
  const n = e.doc.resolve(t[0].pos), o = t[t.length - 1];
317
317
  if (o) {
318
318
  const l = e.doc.resolve(o.pos);
319
- return $(e.setSelection(new k(l, n)));
319
+ return _(e.setSelection(new k(l, n)));
320
320
  }
321
321
  }
322
322
  return e;
323
323
  }
324
- function ue(e, t, { map: n, tableStart: o, table: l }, r) {
324
+ function me(e, t, { map: n, tableStart: o, table: l }, r) {
325
325
  const s = Array(r).fill(0).reduce((d, p, a) => d + l.child(a).nodeSize, o), c = Array(n.width).fill(0).map((d, p) => {
326
326
  const a = l.nodeAt(n.map[p]);
327
327
  return x.type(e).createAndFill({ alignment: a == null ? void 0 : a.attrs.alignment });
328
328
  });
329
329
  return t.insert(s, R.type(e).create(null, c)), t;
330
330
  }
331
- function me(e) {
331
+ function ue(e) {
332
332
  return (t, n) => (o) => {
333
333
  n = n ?? o.selection.from;
334
334
  const l = o.doc.resolve(n), r = se(
@@ -344,14 +344,14 @@ function me(e) {
344
344
  c ? t : d.height - 1,
345
345
  c ? d.width - 1 : t,
346
346
  s.node
347
- ), a = o.doc.resolve(s.from + p), u = c ? k.rowSelection : k.colSelection, m = d.positionAt(
347
+ ), a = o.doc.resolve(s.from + p), m = c ? k.rowSelection : k.colSelection, u = d.positionAt(
348
348
  c ? t : 0,
349
349
  c ? 0 : t,
350
350
  s.node
351
- ), f = o.doc.resolve(s.from + m);
352
- return $(
351
+ ), f = o.doc.resolve(s.from + u);
352
+ return _(
353
353
  o.setSelection(
354
- u(a, f)
354
+ m(a, f)
355
355
  )
356
356
  );
357
357
  }
@@ -359,7 +359,7 @@ function me(e) {
359
359
  return o;
360
360
  };
361
361
  }
362
- const lt = me("row"), rt = me("col");
362
+ const lt = ue("row"), rt = ue("col");
363
363
  function Z(e) {
364
364
  return e[0].map((t, n) => e.map((o) => o[n]));
365
365
  }
@@ -369,12 +369,12 @@ function pe(e, t) {
369
369
  const s = e.child(r), c = [];
370
370
  for (let d = 0; d < o.width; d++) {
371
371
  if (!t[r][d]) continue;
372
- const p = o.map[r * o.width + d], a = t[r][d], m = e.nodeAt(p).type.createChecked(
372
+ const p = o.map[r * o.width + d], a = t[r][d], u = e.nodeAt(p).type.createChecked(
373
373
  Object.assign({}, a.attrs),
374
374
  a.content,
375
375
  a.marks
376
376
  );
377
- c.push(m);
377
+ c.push(u);
378
378
  }
379
379
  n.push(s.type.createChecked(s.attrs, c, s.marks));
380
380
  }
@@ -416,23 +416,23 @@ function st(e, t, n, o) {
416
416
  function ee(e, t) {
417
417
  let n = e, o = e;
418
418
  for (let a = e; a >= 0; a--) {
419
- const u = y(a, t.selection);
420
- u && u.forEach((m) => {
421
- const f = m.node.attrs.colspan + a - 1;
419
+ const m = y(a, t.selection);
420
+ m && m.forEach((u) => {
421
+ const f = u.node.attrs.colspan + a - 1;
422
422
  f >= n && (n = a), f > o && (o = f);
423
423
  });
424
424
  }
425
425
  for (let a = e; a <= o; a++) {
426
- const u = y(a, t.selection);
427
- u && u.forEach((m) => {
428
- const f = m.node.attrs.colspan + a - 1;
429
- m.node.attrs.colspan > 1 && f > o && (o = f);
426
+ const m = y(a, t.selection);
427
+ m && m.forEach((u) => {
428
+ const f = u.node.attrs.colspan + a - 1;
429
+ u.node.attrs.colspan > 1 && f > o && (o = f);
430
430
  });
431
431
  }
432
432
  const l = [];
433
433
  for (let a = n; a <= o; a++) {
434
- const u = y(a, t.selection);
435
- u && u.length && l.push(a);
434
+ const m = y(a, t.selection);
435
+ m && m.length && l.push(a);
436
436
  }
437
437
  n = l[0], o = l[l.length - 1];
438
438
  const r = y(n, t.selection), s = w(0, t.selection), c = t.doc.resolve(
@@ -440,11 +440,11 @@ function ee(e, t) {
440
440
  );
441
441
  let d;
442
442
  for (let a = o; a >= n; a--) {
443
- const u = y(a, t.selection);
444
- if (u && u.length) {
445
- for (let m = s.length - 1; m >= 0; m--)
446
- if (s[m].pos === u[0].pos) {
447
- d = u[0];
443
+ const m = y(a, t.selection);
444
+ if (m && m.length) {
445
+ for (let u = s.length - 1; u >= 0; u--)
446
+ if (s[u].pos === m[0].pos) {
447
+ d = m[0];
448
448
  break;
449
449
  }
450
450
  if (d) break;
@@ -456,19 +456,19 @@ function ee(e, t) {
456
456
  function te(e, t) {
457
457
  let n = e, o = e;
458
458
  for (let a = e; a >= 0; a--)
459
- w(a, t.selection).forEach((m) => {
460
- const f = m.node.attrs.rowspan + a - 1;
459
+ w(a, t.selection).forEach((u) => {
460
+ const f = u.node.attrs.rowspan + a - 1;
461
461
  f >= n && (n = a), f > o && (o = f);
462
462
  });
463
463
  for (let a = e; a <= o; a++)
464
- w(a, t.selection).forEach((m) => {
465
- const f = m.node.attrs.rowspan + a - 1;
466
- m.node.attrs.rowspan > 1 && f > o && (o = f);
464
+ w(a, t.selection).forEach((u) => {
465
+ const f = u.node.attrs.rowspan + a - 1;
466
+ u.node.attrs.rowspan > 1 && f > o && (o = f);
467
467
  });
468
468
  const l = [];
469
469
  for (let a = n; a <= o; a++) {
470
- const u = w(a, t.selection);
471
- u && u.length && l.push(a);
470
+ const m = w(a, t.selection);
471
+ m && m.length && l.push(a);
472
472
  }
473
473
  n = l[0], o = l[l.length - 1];
474
474
  const r = w(n, t.selection), s = y(0, t.selection), c = t.doc.resolve(
@@ -476,11 +476,11 @@ function te(e, t) {
476
476
  );
477
477
  let d;
478
478
  for (let a = o; a >= n; a--) {
479
- const u = w(a, t.selection);
480
- if (u && u.length) {
481
- for (let m = s.length - 1; m >= 0; m--)
482
- if (s[m].pos === u[0].pos) {
483
- d = u[0];
479
+ const m = w(a, t.selection);
480
+ if (m && m.length) {
481
+ for (let u = s.length - 1; u >= 0; u--)
482
+ if (s[u].pos === m[0].pos) {
483
+ d = m[0];
484
484
  break;
485
485
  }
486
486
  if (d) break;
@@ -498,28 +498,28 @@ function ct(e) {
498
498
  c,
499
499
  d,
500
500
  p
501
- ), u = $(t).replaceWith(
501
+ ), m = _(t).replaceWith(
502
502
  c.pos,
503
503
  c.pos + c.node.nodeSize,
504
504
  a
505
505
  );
506
- if (!l) return u;
507
- const m = h.get(a), f = c.start, b = o, P = m.positionAt(m.height - 1, b, a), D = u.doc.resolve(f + P), E = k.colSelection, O = m.positionAt(0, b, a), H = u.doc.resolve(f + O);
508
- return u.setSelection(E(D, H));
506
+ if (!l) return m;
507
+ const u = h.get(a), f = c.start, b = o, P = u.positionAt(u.height - 1, b, a), D = m.doc.resolve(f + P), E = k.colSelection, O = u.positionAt(0, b, a), H = m.doc.resolve(f + O);
508
+ return m.setSelection(E(D, H));
509
509
  }
510
510
  function it(e) {
511
511
  const { tr: t, origin: n, target: o, select: l = !0, pos: r } = e, s = r != null ? t.doc.resolve(r) : t.selection.$from, c = M(s);
512
512
  if (!c) return t;
513
513
  const { indexes: d } = te(n, t), { indexes: p } = te(o, t);
514
514
  if (d.includes(o)) return t;
515
- const a = st(c, d, p), u = $(t).replaceWith(
515
+ const a = st(c, d, p), m = _(t).replaceWith(
516
516
  c.pos,
517
517
  c.pos + c.node.nodeSize,
518
518
  a
519
519
  );
520
- if (!l) return u;
521
- const m = h.get(a), f = c.start, b = o, P = m.positionAt(b, m.width - 1, a), D = u.doc.resolve(f + P), E = k.rowSelection, O = m.positionAt(b, 0, a), H = u.doc.resolve(f + O);
522
- return u.setSelection(E(D, H));
520
+ if (!l) return m;
521
+ const u = h.get(a), f = c.start, b = o, P = u.positionAt(b, u.width - 1, a), D = m.doc.resolve(f + P), E = k.rowSelection, O = u.positionAt(b, 0, a), H = m.doc.resolve(f + O);
522
+ return m.setSelection(E(D, H));
523
523
  }
524
524
  const V = g(
525
525
  "GoToPrevTableCell",
@@ -660,7 +660,7 @@ const Re = g(
660
660
  if (!G(t)) return !1;
661
661
  if (n) {
662
662
  const o = ae(t);
663
- n(ue(e, t.tr, o, o.top));
663
+ n(me(e, t.tr, o, o.top));
664
664
  }
665
665
  return !0;
666
666
  }
@@ -675,7 +675,7 @@ const xe = g(
675
675
  if (!G(t)) return !1;
676
676
  if (n) {
677
677
  const o = ae(t);
678
- n(ue(e, t.tr, o, o.bottom));
678
+ n(me(e, t.tr, o, o.bottom));
679
679
  }
680
680
  return !0;
681
681
  }
@@ -872,7 +872,7 @@ i(Q.node, {
872
872
  displayName: "NodeSchema<footnodeRef>",
873
873
  group: "footnote"
874
874
  });
875
- const _e = Ee.extendSchema(
875
+ const ve = Ee.extendSchema(
876
876
  (e) => (t) => {
877
877
  const n = e(t);
878
878
  return {
@@ -939,11 +939,11 @@ const _e = Ee.extendSchema(
939
939
  };
940
940
  }
941
941
  );
942
- i(_e, {
942
+ i(ve, {
943
943
  displayName: "NodeSchema<listItem>",
944
944
  group: "ListItem"
945
945
  });
946
- const $e = F(() => new ne(
946
+ const _e = F(() => new ne(
947
947
  /^\[(?<checked>\s|x)\]\s$/,
948
948
  (e, t, n, o) => {
949
949
  var a;
@@ -959,30 +959,30 @@ const $e = F(() => new ne(
959
959
  }), p;
960
960
  }
961
961
  ));
962
- i($e, {
962
+ i(_e, {
963
963
  displayName: "InputRule<wrapInTaskListInputRule>",
964
964
  group: "ListItem"
965
965
  });
966
966
  const dt = [
967
967
  j,
968
968
  q
969
- ].flat(), ut = [
969
+ ].flat(), mt = [
970
970
  Ae,
971
- $e
972
- ], mt = [ie], Ie = _(() => et);
973
- i(Ie, {
971
+ _e
972
+ ], ut = [ie], $e = v(() => et);
973
+ i($e, {
974
974
  displayName: "Prose<autoInsertSpanPlugin>",
975
975
  group: "Prose"
976
976
  });
977
- const pt = _(() => Ve({}));
977
+ const pt = v(() => Ve({}));
978
978
  i(pt, {
979
979
  displayName: "Prose<columnResizingPlugin>",
980
980
  group: "Prose"
981
981
  });
982
- const ve = _(
982
+ const Ie = v(
983
983
  () => Ue({ allowTableNodeSelection: !0 })
984
984
  );
985
- i(ve, {
985
+ i(Ie, {
986
986
  displayName: "Prose<tableEditingPlugin>",
987
987
  group: "Prose"
988
988
  });
@@ -995,14 +995,14 @@ i(Y.options, {
995
995
  displayName: "RemarkConfig<remarkGFMPlugin>",
996
996
  group: "Remark"
997
997
  });
998
- const ft = new Ye("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");
998
+ const ft = new Ze("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");
999
999
  function gt(e, t) {
1000
1000
  let n = 0;
1001
1001
  return t.forEach((o, l, r) => {
1002
1002
  o === e && (n = r);
1003
1003
  }), n;
1004
1004
  }
1005
- const Pe = _(() => new Ze({
1005
+ const Pe = v(() => new Ye({
1006
1006
  key: ft,
1007
1007
  appendTransaction: (e, t, n) => {
1008
1008
  let o;
@@ -1010,9 +1010,9 @@ const Pe = _(() => new Ze({
1010
1010
  if (o || (o = n.tr), r.type.name !== "table_cell") return;
1011
1011
  const c = n.doc.resolve(s), d = c.node(c.depth), a = c.node(c.depth - 1).firstChild;
1012
1012
  if (!a) return;
1013
- const u = gt(r, d), m = a.maybeChild(u);
1014
- if (!m) return;
1015
- const f = m.attrs.alignment, b = r.attrs.alignment;
1013
+ const m = gt(r, d), u = a.maybeChild(m);
1014
+ if (!u) return;
1015
+ const f = u.attrs.alignment, b = r.attrs.alignment;
1016
1016
  f !== b && o.setNodeMarkup(s, void 0, { ...r.attrs, alignment: f });
1017
1017
  };
1018
1018
  return t.doc !== n.doc && n.doc.descendants(l), o;
@@ -1024,15 +1024,15 @@ i(Pe, {
1024
1024
  });
1025
1025
  const ht = [
1026
1026
  Pe,
1027
- Ie,
1027
+ $e,
1028
1028
  Y,
1029
- ve
1029
+ Ie
1030
1030
  ].flat(), bt = [
1031
- _e,
1031
+ ve,
1032
1032
  N,
1033
- I,
1033
+ $,
1034
1034
  R,
1035
- v,
1035
+ I,
1036
1036
  x,
1037
1037
  J,
1038
1038
  Q,
@@ -1055,10 +1055,10 @@ const ht = [
1055
1055
  Se,
1056
1056
  Me,
1057
1057
  z
1058
- ], $t = [
1058
+ ], _t = [
1059
1059
  bt,
1060
- ut,
1061
1060
  mt,
1061
+ ut,
1062
1062
  dt,
1063
1063
  Ct,
1064
1064
  ht
@@ -1068,29 +1068,29 @@ export {
1068
1068
  Te as addColBeforeCommand,
1069
1069
  xe as addRowAfterCommand,
1070
1070
  Re as addRowBeforeCommand,
1071
- ue as addRowWithAlignment,
1072
- Ie as autoInsertSpanPlugin,
1071
+ me as addRowWithAlignment,
1072
+ $e as autoInsertSpanPlugin,
1073
1073
  pt as columnResizingPlugin,
1074
1074
  Ct as commands,
1075
1075
  de as createTable,
1076
1076
  Ne as deleteSelectedCellsCommand,
1077
1077
  X as exitTable,
1078
- _e as extendListItemSchemaForTask,
1078
+ ve as extendListItemSchemaForTask,
1079
1079
  M as findTable,
1080
1080
  J as footnoteDefinitionSchema,
1081
1081
  Q as footnoteReferenceSchema,
1082
1082
  ot as getAllCellsInTable,
1083
1083
  y as getCellsInCol,
1084
1084
  w as getCellsInRow,
1085
- $t as gfm,
1085
+ _t as gfm,
1086
1086
  U as goToNextTableCellCommand,
1087
1087
  V as goToPrevTableCellCommand,
1088
- ut as inputRules,
1088
+ mt as inputRules,
1089
1089
  he as insertTableCommand,
1090
1090
  Ae as insertTableInputRule,
1091
1091
  Pe as keepTableAlignPlugin,
1092
1092
  dt as keymap,
1093
- mt as markInputRules,
1093
+ ut as markInputRules,
1094
1094
  ct as moveCol,
1095
1095
  Ce as moveColCommand,
1096
1096
  it as moveRow,
@@ -1100,7 +1100,7 @@ export {
1100
1100
  bt as schema,
1101
1101
  rt as selectCol,
1102
1102
  we as selectColCommand,
1103
- me as selectLine,
1103
+ ue as selectLine,
1104
1104
  lt as selectRow,
1105
1105
  ye as selectRowCommand,
1106
1106
  nt as selectTable,
@@ -1111,13 +1111,13 @@ export {
1111
1111
  j as strikethroughKeymap,
1112
1112
  T as strikethroughSchema,
1113
1113
  x as tableCellSchema,
1114
- ve as tableEditingPlugin,
1115
- I as tableHeaderRowSchema,
1116
- v as tableHeaderSchema,
1114
+ Ie as tableEditingPlugin,
1115
+ $ as tableHeaderRowSchema,
1116
+ I as tableHeaderSchema,
1117
1117
  q as tableKeymap,
1118
1118
  R as tableRowSchema,
1119
1119
  N as tableSchema,
1120
1120
  z as toggleStrikethroughCommand,
1121
- $e as wrapInTaskListInputRule
1121
+ _e as wrapInTaskListInputRule
1122
1122
  };
1123
1123
  //# sourceMappingURL=index.es.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@milkdown/preset-gfm",
3
3
  "type": "module",
4
- "version": "7.6.2",
4
+ "version": "7.6.3",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -37,15 +37,15 @@
37
37
  "prosemirror-safari-ime-span": "^1.0.1",
38
38
  "remark-gfm": "^4.0.0",
39
39
  "tslib": "^2.8.1",
40
- "@milkdown/exception": "7.6.2",
41
- "@milkdown/utils": "7.6.2"
40
+ "@milkdown/exception": "7.6.3",
41
+ "@milkdown/utils": "7.6.3"
42
42
  },
43
43
  "devDependencies": {
44
- "@milkdown/ctx": "7.6.2",
45
- "@milkdown/core": "7.6.2",
46
- "@milkdown/preset-commonmark": "7.6.2",
47
- "@milkdown/prose": "7.6.2",
48
- "@milkdown/transformer": "7.6.2"
44
+ "@milkdown/core": "7.6.3",
45
+ "@milkdown/preset-commonmark": "7.6.3",
46
+ "@milkdown/ctx": "7.6.3",
47
+ "@milkdown/prose": "7.6.3",
48
+ "@milkdown/transformer": "7.6.3"
49
49
  },
50
50
  "nx": {
51
51
  "targets": {