@milkdown/preset-gfm 7.3.6 → 7.5.0

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__/index.d.ts.map +1 -1
  2. package/lib/__internal__/with-meta.d.ts.map +1 -1
  3. package/lib/composed/commands.d.ts +5 -1
  4. package/lib/composed/commands.d.ts.map +1 -1
  5. package/lib/composed/index.d.ts.map +1 -1
  6. package/lib/composed/inputrules.d.ts.map +1 -1
  7. package/lib/composed/keymap.d.ts.map +1 -1
  8. package/lib/composed/plugins.d.ts.map +1 -1
  9. package/lib/composed/schema.d.ts.map +1 -1
  10. package/lib/index.d.ts.map +1 -1
  11. package/lib/index.es.js +545 -482
  12. package/lib/index.es.js.map +1 -1
  13. package/lib/mark/index.d.ts.map +1 -1
  14. package/lib/mark/strike-through.d.ts.map +1 -1
  15. package/lib/node/footnote/definition.d.ts.map +1 -1
  16. package/lib/node/footnote/index.d.ts.map +1 -1
  17. package/lib/node/footnote/reference.d.ts.map +1 -1
  18. package/lib/node/index.d.ts.map +1 -1
  19. package/lib/node/table/command.d.ts +33 -0
  20. package/lib/node/table/command.d.ts.map +1 -0
  21. package/lib/node/table/index.d.ts +3 -30
  22. package/lib/node/table/index.d.ts.map +1 -1
  23. package/lib/node/table/input.d.ts +3 -0
  24. package/lib/node/table/input.d.ts.map +1 -0
  25. package/lib/node/table/schema.d.ts +6 -0
  26. package/lib/node/table/schema.d.ts.map +1 -0
  27. package/lib/node/table/utils.d.ts +21 -7
  28. package/lib/node/table/utils.d.ts.map +1 -1
  29. package/lib/node/task-list-item.d.ts.map +1 -1
  30. package/lib/plugin/auto-insert-span-plugin.d.ts +2 -0
  31. package/lib/plugin/auto-insert-span-plugin.d.ts.map +1 -0
  32. package/lib/plugin/column-resizing-plugin.d.ts.map +1 -1
  33. package/lib/plugin/index.d.ts +2 -1
  34. package/lib/plugin/index.d.ts.map +1 -1
  35. package/lib/plugin/keep-table-align-plugin.d.ts +2 -0
  36. package/lib/plugin/keep-table-align-plugin.d.ts.map +1 -0
  37. package/lib/plugin/remark-gfm-plugin.d.ts.map +1 -1
  38. package/lib/plugin/table-editing-plugin.d.ts.map +1 -1
  39. package/package.json +12 -17
  40. package/src/__internal__/index.ts +0 -2
  41. package/src/__internal__/with-meta.ts +0 -1
  42. package/src/composed/commands.ts +2 -3
  43. package/src/composed/index.ts +0 -1
  44. package/src/composed/inputrules.ts +0 -1
  45. package/src/composed/keymap.ts +0 -1
  46. package/src/composed/plugins.ts +5 -6
  47. package/src/composed/schema.ts +11 -2
  48. package/src/index.ts +1 -3
  49. package/src/mark/index.ts +0 -1
  50. package/src/mark/strike-through.ts +0 -1
  51. package/src/node/footnote/definition.ts +0 -2
  52. package/src/node/footnote/index.ts +0 -1
  53. package/src/node/footnote/reference.ts +0 -2
  54. package/src/node/index.ts +0 -1
  55. package/src/node/table/command.ts +228 -0
  56. package/src/node/table/index.ts +3 -451
  57. package/src/node/table/input.ts +73 -0
  58. package/src/node/table/schema.ts +216 -0
  59. package/src/node/table/utils.ts +49 -20
  60. package/src/node/task-list-item.ts +1 -2
  61. package/src/plugin/auto-insert-span-plugin.ts +12 -0
  62. package/src/plugin/column-resizing-plugin.ts +0 -1
  63. package/src/plugin/index.ts +2 -2
  64. package/src/plugin/keep-table-align-plugin.ts +60 -0
  65. package/src/plugin/remark-gfm-plugin.ts +0 -1
  66. package/src/plugin/table-editing-plugin.ts +1 -2
  67. package/lib/plugin/auto-insert-zero-space-plugin.d.ts +0 -2
  68. package/lib/plugin/auto-insert-zero-space-plugin.d.ts.map +0 -1
  69. package/src/plugin/auto-insert-zero-space-plugin.ts +0 -56
package/lib/index.es.js CHANGED
@@ -1,14 +1,15 @@
1
- import { expectDomTypeError as O } from "@milkdown/exception";
2
- import { paragraphSchema as ee, listItemSchema as $e } from "@milkdown/preset-commonmark";
3
- import { InputRule as te } from "@milkdown/prose/inputrules";
4
- import { $markAttr as Pe, $markSchema as _e, $command as h, $inputRule as B, $useKeymap as oe, $nodeSchema as k, $prose as F, $remark as Ee } from "@milkdown/utils";
1
+ import { expectDomTypeError as K } from "@milkdown/exception";
2
+ import { paragraphSchema as De, listItemSchema as Ee } from "@milkdown/preset-commonmark";
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 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, addColumnBefore as We, addColumnAfter as ze, selectedRect as ae, setCellAttr as je, columnResizing as Ve, tableEditing as Ue } from "@milkdown/prose/tables";
5
6
  import { commandsCtx as A } from "@milkdown/core";
6
- import { TextSelection as De, Selection as ne, PluginKey as Oe, Plugin as Be } from "@milkdown/prose/state";
7
- import { TableMap as g, CellSelection as y, tableNodes as Fe, goToNextCell as le, isInTable as N, deleteTable as Ke, deleteColumn as He, deleteRow as Le, addColumnBefore as We, addColumnAfter as Ge, selectedRect as re, setCellAttr as ze, columnResizing as je, tableEditing as Ze } from "@milkdown/prose/tables";
8
- import { markRule as Ve, findParentNode as Ue, cloneTr as x, browser as X } from "@milkdown/prose";
9
7
  import { toggleMark as Xe } from "@milkdown/prose/commands";
10
- import qe from "remark-gfm";
11
- function d(e, t) {
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";
10
+ import { imeSpan as et } from "prosemirror-safari-ime-span";
11
+ import tt from "remark-gfm";
12
+ function i(e, t) {
12
13
  return Object.assign(e, {
13
14
  meta: {
14
15
  package: "@milkdown/preset-gfm",
@@ -16,17 +17,17 @@ function d(e, t) {
16
17
  }
17
18
  }), e;
18
19
  }
19
- const K = Pe("strike_through");
20
- d(K, {
20
+ const W = Oe("strike_through");
21
+ i(W, {
21
22
  displayName: "Attr<strikethrough>",
22
23
  group: "Strikethrough"
23
24
  });
24
- const T = _e("strike_through", (e) => ({
25
+ const T = He("strike_through", (e) => ({
25
26
  parseDOM: [
26
27
  { tag: "del" },
27
28
  { style: "text-decoration", getAttrs: (t) => t === "line-through" }
28
29
  ],
29
- toDOM: (t) => ["del", e.get(K.key)(t)],
30
+ toDOM: (t) => ["del", e.get(W.key)(t)],
30
31
  parseMarkdown: {
31
32
  match: (t) => t.type === "delete",
32
33
  runner: (t, n, o) => {
@@ -40,53 +41,215 @@ const T = _e("strike_through", (e) => ({
40
41
  }
41
42
  }
42
43
  }));
43
- d(T.mark, {
44
+ i(T.mark, {
44
45
  displayName: "MarkSchema<strikethrough>",
45
46
  group: "Strikethrough"
46
47
  });
47
- d(T.ctx, {
48
+ i(T.ctx, {
48
49
  displayName: "MarkSchemaCtx<strikethrough>",
49
50
  group: "Strikethrough"
50
51
  });
51
- const H = h("ToggleStrikeThrough", (e) => () => Xe(T.type(e)));
52
- d(H, {
52
+ const z = g("ToggleStrikeThrough", (e) => () => Xe(T.type(e)));
53
+ i(z, {
53
54
  displayName: "Command<ToggleStrikethrough>",
54
55
  group: "Strikethrough"
55
56
  });
56
- const ae = B((e) => Ve(/~([^~]+)~$/, T.type(e)));
57
- d(ae, {
57
+ const ie = F((e) => qe(/~([^~]+)~$/, T.type(e)));
58
+ i(ie, {
58
59
  displayName: "InputRule<strikethrough>",
59
60
  group: "Strikethrough"
60
61
  });
61
- const L = oe("strikeThroughKeymap", {
62
+ const j = le("strikeThroughKeymap", {
62
63
  ToggleStrikethrough: {
63
64
  shortcuts: "Mod-Alt-x",
64
65
  command: (e) => {
65
66
  const t = e.get(A);
66
- return () => t.call(H.key);
67
+ return () => t.call(z.key);
67
68
  }
68
69
  }
69
70
  });
70
- d(L.ctx, {
71
+ i(j.ctx, {
71
72
  displayName: "KeymapCtx<strikethrough>",
72
73
  group: "Strikethrough"
73
74
  });
74
- d(L.shortcuts, {
75
+ i(j.shortcuts, {
75
76
  displayName: "Keymap<strikethrough>",
76
77
  group: "Strikethrough"
77
78
  });
78
- function se(e, t = 3, n = 3) {
79
- const o = Array(n).fill(0).map(() => M.type(e).createAndFill()), l = Array(n).fill(0).map(() => I.type(e).createAndFill()), r = Array(t).fill(0).map((s, c) => R.type(e).create(null, c === 0 ? l : o));
80
- return S.type(e).create(null, r);
79
+ const S = Le({
80
+ tableGroup: "block",
81
+ cellContent: "paragraph",
82
+ cellAttributes: {
83
+ alignment: {
84
+ default: "left",
85
+ getFromDOM: (e) => e.style.textAlign || "left",
86
+ setDOMAttr: (e, t) => {
87
+ t.style = `text-align: ${e || "left"}`;
88
+ }
89
+ }
90
+ }
91
+ }), N = C("table", () => ({
92
+ ...S.table,
93
+ content: "table_header_row table_row+",
94
+ disableDropCursor: !0,
95
+ parseMarkdown: {
96
+ match: (e) => e.type === "table",
97
+ runner: (e, t, n) => {
98
+ const o = t.align, l = t.children.map((r, s) => ({
99
+ ...r,
100
+ align: o,
101
+ isHeader: s === 0
102
+ }));
103
+ e.openNode(n), e.next(l), e.closeNode();
104
+ }
105
+ },
106
+ toMarkdown: {
107
+ match: (e) => e.type.name === "table",
108
+ runner: (e, t) => {
109
+ var l;
110
+ const n = (l = t.content.firstChild) == null ? void 0 : l.content;
111
+ if (!n)
112
+ return;
113
+ const o = [];
114
+ n.forEach((r) => {
115
+ o.push(r.attrs.alignment);
116
+ }), e.openNode("table", void 0, { align: o }), e.next(t.content), e.closeNode();
117
+ }
118
+ }
119
+ }));
120
+ i(N.node, {
121
+ displayName: "NodeSchema<table>",
122
+ group: "Table"
123
+ });
124
+ i(N.ctx, {
125
+ displayName: "NodeSchemaCtx<table>",
126
+ group: "Table"
127
+ });
128
+ const $ = C("table_header_row", () => ({
129
+ ...S.table_row,
130
+ disableDropCursor: !0,
131
+ content: "(table_header)*",
132
+ parseDOM: [{ tag: "tr[data-is-header]" }],
133
+ toDOM() {
134
+ return ["tr", { "data-is-header": !0 }, 0];
135
+ },
136
+ parseMarkdown: {
137
+ match: (e) => !!(e.type === "tableRow" && e.isHeader),
138
+ runner: (e, t, n) => {
139
+ const o = t.align, l = t.children.map((r, s) => ({
140
+ ...r,
141
+ align: o[s],
142
+ isHeader: t.isHeader
143
+ }));
144
+ e.openNode(n), e.next(l), e.closeNode();
145
+ }
146
+ },
147
+ toMarkdown: {
148
+ match: (e) => e.type.name === "table_header_row",
149
+ runner: (e, t) => {
150
+ e.openNode("tableRow", void 0, { isHeader: !0 }), e.next(t.content), e.closeNode();
151
+ }
152
+ }
153
+ }));
154
+ i($.node, {
155
+ displayName: "NodeSchema<tableHeaderRow>",
156
+ group: "Table"
157
+ });
158
+ i($.ctx, {
159
+ displayName: "NodeSchemaCtx<tableHeaderRow>",
160
+ group: "Table"
161
+ });
162
+ const R = C("table_row", () => ({
163
+ ...S.table_row,
164
+ disableDropCursor: !0,
165
+ content: "(table_cell)*",
166
+ parseMarkdown: {
167
+ match: (e) => e.type === "tableRow",
168
+ runner: (e, t, n) => {
169
+ const o = t.align, l = t.children.map((r, s) => ({
170
+ ...r,
171
+ align: o[s]
172
+ }));
173
+ e.openNode(n), e.next(l), e.closeNode();
174
+ }
175
+ },
176
+ toMarkdown: {
177
+ match: (e) => e.type.name === "table_row",
178
+ runner: (e, t) => {
179
+ e.openNode("tableRow"), e.next(t.content), e.closeNode();
180
+ }
181
+ }
182
+ }));
183
+ i(R.node, {
184
+ displayName: "NodeSchema<tableRow>",
185
+ group: "Table"
186
+ });
187
+ i(R.ctx, {
188
+ displayName: "NodeSchemaCtx<tableRow>",
189
+ group: "Table"
190
+ });
191
+ const M = C("table_cell", () => ({
192
+ ...S.table_cell,
193
+ disableDropCursor: !0,
194
+ parseMarkdown: {
195
+ match: (e) => e.type === "tableCell" && !e.isHeader,
196
+ runner: (e, t, n) => {
197
+ const o = t.align;
198
+ e.openNode(n, { alignment: o }).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode();
199
+ }
200
+ },
201
+ toMarkdown: {
202
+ match: (e) => e.type.name === "table_cell",
203
+ runner: (e, t) => {
204
+ e.openNode("tableCell").next(t.content).closeNode();
205
+ }
206
+ }
207
+ }));
208
+ i(M.node, {
209
+ displayName: "NodeSchema<tableCell>",
210
+ group: "Table"
211
+ });
212
+ i(M.ctx, {
213
+ displayName: "NodeSchemaCtx<tableCell>",
214
+ group: "Table"
215
+ });
216
+ const I = C("table_header", () => ({
217
+ ...S.table_header,
218
+ disableDropCursor: !0,
219
+ parseMarkdown: {
220
+ match: (e) => e.type === "tableCell" && !!e.isHeader,
221
+ runner: (e, t, n) => {
222
+ const o = t.align;
223
+ e.openNode(n, { alignment: o }), e.openNode(e.schema.nodes.paragraph), e.next(t.children), e.closeNode(), e.closeNode();
224
+ }
225
+ },
226
+ toMarkdown: {
227
+ match: (e) => e.type.name === "table_header",
228
+ runner: (e, t) => {
229
+ e.openNode("tableCell"), e.next(t.content), e.closeNode();
230
+ }
231
+ }
232
+ }));
233
+ i(I.node, {
234
+ displayName: "NodeSchema<tableHeader>",
235
+ group: "Table"
236
+ });
237
+ i(I.ctx, {
238
+ displayName: "NodeSchemaCtx<tableHeader>",
239
+ group: "Table"
240
+ });
241
+ function de(e, t = 3, n = 3) {
242
+ const o = Array(n).fill(0).map(() => M.type(e).createAndFill()), l = Array(n).fill(0).map(() => I.type(e).createAndFill()), r = Array(t).fill(0).map((s, c) => c === 0 ? $.type(e).create(null, l) : R.type(e).create(null, o));
243
+ return N.type(e).create(null, r);
81
244
  }
82
- function w(e) {
83
- return Ue((t) => t.type.spec.tableRole === "table")(e);
245
+ function x(e) {
246
+ return se((t) => t.type.spec.tableRole === "table")(e);
84
247
  }
85
- function b(e, t) {
86
- const n = w(t);
248
+ function y(e, t) {
249
+ const n = x(t.$from);
87
250
  if (!n)
88
251
  return;
89
- const o = g.get(n.node);
252
+ const o = h.get(n.node);
90
253
  if (!(e < 0 || e >= o.width))
91
254
  return o.cellsInRect({ left: e, right: e + 1, top: 0, bottom: o.height }).map((l) => {
92
255
  const r = n.node.nodeAt(l);
@@ -100,11 +263,11 @@ function b(e, t) {
100
263
  };
101
264
  }).filter((l) => l != null);
102
265
  }
103
- function C(e, t) {
104
- const n = w(t);
266
+ function w(e, t) {
267
+ const n = x(t.$from);
105
268
  if (!n)
106
269
  return;
107
- const o = g.get(n.node);
270
+ const o = h.get(n.node);
108
271
  if (!(e < 0 || e >= o.height))
109
272
  return o.cellsInRect({ left: 0, right: o.width, top: e, bottom: e + 1 }).map((l) => {
110
273
  const r = n.node.nodeAt(l);
@@ -118,11 +281,11 @@ function C(e, t) {
118
281
  };
119
282
  }).filter((l) => l != null);
120
283
  }
121
- function Je(e) {
122
- const t = w(e);
284
+ function ot(e) {
285
+ const t = x(e.$from);
123
286
  if (!t)
124
287
  return;
125
- const n = g.get(t.node);
288
+ const n = h.get(t.node);
126
289
  return n.cellsInRect({
127
290
  left: 0,
128
291
  right: n.width,
@@ -133,58 +296,62 @@ function Je(e) {
133
296
  return { pos: s, start: s + 1, node: r };
134
297
  });
135
298
  }
136
- function Qe(e) {
137
- const t = Je(e.selection);
299
+ function nt(e) {
300
+ const t = ot(e.selection);
138
301
  if (t && t[0]) {
139
302
  const n = e.doc.resolve(t[0].pos), o = t[t.length - 1];
140
303
  if (o) {
141
304
  const l = e.doc.resolve(o.pos);
142
- return x(e.setSelection(new y(l, n)));
305
+ return _(e.setSelection(new k(l, n)));
143
306
  }
144
307
  }
145
308
  return e;
146
309
  }
147
- function ce(e, t, { map: n, tableStart: o, table: l }, r) {
148
- const s = Array(r).fill(0).reduce((i, m, a) => i + l.child(a).nodeSize, o), c = Array(n.width).fill(0).map((i, m) => {
149
- const a = l.nodeAt(n.map[m]);
310
+ function me(e, t, { map: n, tableStart: o, table: l }, r) {
311
+ 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) => {
312
+ const a = l.nodeAt(n.map[p]);
150
313
  return M.type(e).createAndFill({ alignment: a == null ? void 0 : a.attrs.alignment });
151
314
  });
152
315
  return t.insert(s, R.type(e).create(null, c)), t;
153
316
  }
154
- function ie(e) {
155
- return (t) => (n) => {
156
- const o = w(n.selection), l = e === "row";
157
- if (o) {
158
- const r = g.get(o.node);
159
- if (t >= 0 && t < (l ? r.height : r.width)) {
160
- const s = r.positionAt(
161
- l ? t : r.height - 1,
162
- l ? r.width - 1 : t,
163
- o.node
164
- ), c = n.doc.resolve(o.start + s), i = l ? y.rowSelection : y.colSelection, m = r.positionAt(l ? t : 0, l ? 0 : t, o.node), a = n.doc.resolve(o.start + m);
165
- return x(n.setSelection(i(c, a)));
317
+ function ue(e) {
318
+ return (t, n) => (o) => {
319
+ n = n ?? o.selection.from;
320
+ const l = o.doc.resolve(n), r = se((d) => d.type.name === "table")(l), s = r ? {
321
+ node: r.node,
322
+ from: r.start
323
+ } : void 0, c = e === "row";
324
+ if (s) {
325
+ const d = h.get(s.node);
326
+ if (t >= 0 && t < (c ? d.height : d.width)) {
327
+ const p = d.positionAt(
328
+ c ? t : d.height - 1,
329
+ c ? d.width - 1 : t,
330
+ s.node
331
+ ), a = o.doc.resolve(s.from + p), m = c ? k.rowSelection : k.colSelection, u = d.positionAt(c ? t : 0, c ? 0 : t, s.node), f = o.doc.resolve(s.from + u);
332
+ return _(o.setSelection(m(a, f)));
166
333
  }
167
334
  }
168
- return n;
335
+ return o;
169
336
  };
170
337
  }
171
- const Ye = ie("row"), et = ie("col");
172
- function q(e) {
338
+ const lt = ue("row"), rt = ue("col");
339
+ function Z(e) {
173
340
  return e[0].map((t, n) => e.map((o) => o[n]));
174
341
  }
175
- function de(e, t) {
176
- const n = [], o = g.get(e);
342
+ function pe(e, t) {
343
+ const n = [], o = h.get(e);
177
344
  for (let r = 0; r < o.height; r++) {
178
345
  const s = e.child(r), c = [];
179
- for (let i = 0; i < o.width; i++) {
180
- if (!t[r][i])
346
+ for (let d = 0; d < o.width; d++) {
347
+ if (!t[r][d])
181
348
  continue;
182
- const m = o.map[r * o.width + i], a = t[r][i], p = e.nodeAt(m).type.createChecked(
349
+ const p = o.map[r * o.width + d], a = t[r][d], u = e.nodeAt(p).type.createChecked(
183
350
  Object.assign({}, a.attrs),
184
351
  a.content,
185
352
  a.marks
186
353
  );
187
- c.push(p);
354
+ c.push(u);
188
355
  }
189
356
  n.push(s.type.createChecked(s.attrs, c, s.marks));
190
357
  }
@@ -194,449 +361,329 @@ function de(e, t) {
194
361
  e.marks
195
362
  );
196
363
  }
197
- function me(e) {
198
- const t = g.get(e), n = [];
364
+ function fe(e) {
365
+ const t = h.get(e), n = [];
199
366
  for (let o = 0; o < t.height; o++) {
200
367
  const l = [], r = {};
201
368
  for (let s = 0; s < t.width; s++) {
202
- const c = t.map[o * t.width + s], i = e.nodeAt(c), m = t.findCell(c);
203
- if (r[c] || m.top !== o) {
369
+ const c = t.map[o * t.width + s], d = e.nodeAt(c), p = t.findCell(c);
370
+ if (r[c] || p.top !== o) {
204
371
  l.push(null);
205
372
  continue;
206
373
  }
207
- r[c] = !0, l.push(i);
374
+ r[c] = !0, l.push(d);
208
375
  }
209
376
  n.push(l);
210
377
  }
211
378
  return n;
212
379
  }
213
- function ue(e, t, n, o) {
380
+ function ge(e, t, n, o) {
214
381
  const l = t[0] > n[0] ? -1 : 1, r = e.splice(t[0], t.length), s = r.length % 2 === 0 ? 1 : 0;
215
382
  let c;
216
383
  return o === -1 && l === 1 ? c = n[0] - 1 : o === 1 && l === -1 ? c = n[n.length - 1] - s + 1 : c = l === -1 ? n[0] : n[n.length - 1] - s, e.splice(c, 0, ...r), e;
217
384
  }
218
- function tt(e, t, n, o) {
219
- let l = q(me(e.node));
220
- return l = ue(l, t, n, o), l = q(l), de(e.node, l);
385
+ function at(e, t, n, o) {
386
+ let l = Z(fe(e.node));
387
+ return l = ge(l, t, n, o), l = Z(l), pe(e.node, l);
221
388
  }
222
- function ot(e, t, n, o) {
223
- let l = me(e.node);
224
- return l = ue(l, t, n, o), de(e.node, l);
389
+ function st(e, t, n, o) {
390
+ let l = fe(e.node);
391
+ return l = ge(l, t, n, o), pe(e.node, l);
225
392
  }
226
- function J(e, t) {
393
+ function ee(e, t) {
227
394
  let n = e, o = e;
228
395
  for (let a = e; a >= 0; a--) {
229
- const u = b(a, t.selection);
230
- u && u.forEach((p) => {
231
- const f = p.node.attrs.colspan + a - 1;
396
+ const m = y(a, t.selection);
397
+ m && m.forEach((u) => {
398
+ const f = u.node.attrs.colspan + a - 1;
232
399
  f >= n && (n = a), f > o && (o = f);
233
400
  });
234
401
  }
235
402
  for (let a = e; a <= o; a++) {
236
- const u = b(a, t.selection);
237
- u && u.forEach((p) => {
238
- const f = p.node.attrs.colspan + a - 1;
239
- p.node.attrs.colspan > 1 && f > o && (o = f);
403
+ const m = y(a, t.selection);
404
+ m && m.forEach((u) => {
405
+ const f = u.node.attrs.colspan + a - 1;
406
+ u.node.attrs.colspan > 1 && f > o && (o = f);
240
407
  });
241
408
  }
242
409
  const l = [];
243
410
  for (let a = n; a <= o; a++) {
244
- const u = b(a, t.selection);
245
- u && u.length && l.push(a);
411
+ const m = y(a, t.selection);
412
+ m && m.length && l.push(a);
246
413
  }
247
414
  n = l[0], o = l[l.length - 1];
248
- const r = b(n, t.selection), s = C(0, t.selection), c = t.doc.resolve(
415
+ const r = y(n, t.selection), s = w(0, t.selection), c = t.doc.resolve(
249
416
  r[r.length - 1].pos
250
417
  );
251
- let i;
418
+ let d;
252
419
  for (let a = o; a >= n; a--) {
253
- const u = b(a, t.selection);
254
- if (u && u.length) {
255
- for (let p = s.length - 1; p >= 0; p--)
256
- if (s[p].pos === u[0].pos) {
257
- i = u[0];
420
+ const m = y(a, t.selection);
421
+ if (m && m.length) {
422
+ for (let u = s.length - 1; u >= 0; u--)
423
+ if (s[u].pos === m[0].pos) {
424
+ d = m[0];
258
425
  break;
259
426
  }
260
- if (i)
427
+ if (d)
261
428
  break;
262
429
  }
263
430
  }
264
- const m = t.doc.resolve(i.pos);
265
- return { $anchor: c, $head: m, indexes: l };
431
+ const p = t.doc.resolve(d.pos);
432
+ return { $anchor: c, $head: p, indexes: l };
266
433
  }
267
- function Q(e, t) {
434
+ function te(e, t) {
268
435
  let n = e, o = e;
269
436
  for (let a = e; a >= 0; a--)
270
- C(a, t.selection).forEach((p) => {
271
- const f = p.node.attrs.rowspan + a - 1;
437
+ w(a, t.selection).forEach((u) => {
438
+ const f = u.node.attrs.rowspan + a - 1;
272
439
  f >= n && (n = a), f > o && (o = f);
273
440
  });
274
441
  for (let a = e; a <= o; a++)
275
- C(a, t.selection).forEach((p) => {
276
- const f = p.node.attrs.rowspan + a - 1;
277
- p.node.attrs.rowspan > 1 && f > o && (o = f);
442
+ w(a, t.selection).forEach((u) => {
443
+ const f = u.node.attrs.rowspan + a - 1;
444
+ u.node.attrs.rowspan > 1 && f > o && (o = f);
278
445
  });
279
446
  const l = [];
280
447
  for (let a = n; a <= o; a++) {
281
- const u = C(a, t.selection);
282
- u && u.length && l.push(a);
448
+ const m = w(a, t.selection);
449
+ m && m.length && l.push(a);
283
450
  }
284
451
  n = l[0], o = l[l.length - 1];
285
- const r = C(n, t.selection), s = b(0, t.selection), c = t.doc.resolve(r[r.length - 1].pos);
286
- let i;
452
+ const r = w(n, t.selection), s = y(0, t.selection), c = t.doc.resolve(r[r.length - 1].pos);
453
+ let d;
287
454
  for (let a = o; a >= n; a--) {
288
- const u = C(a, t.selection);
289
- if (u && u.length) {
290
- for (let p = s.length - 1; p >= 0; p--)
291
- if (s[p].pos === u[0].pos) {
292
- i = u[0];
455
+ const m = w(a, t.selection);
456
+ if (m && m.length) {
457
+ for (let u = s.length - 1; u >= 0; u--)
458
+ if (s[u].pos === m[0].pos) {
459
+ d = m[0];
293
460
  break;
294
461
  }
295
- if (i)
462
+ if (d)
296
463
  break;
297
464
  }
298
465
  }
299
- const m = t.doc.resolve(i.pos);
300
- return { $anchor: c, $head: m, indexes: l };
466
+ const p = t.doc.resolve(d.pos);
467
+ return { $anchor: c, $head: p, indexes: l };
301
468
  }
302
- function nt(e, t, n, o = !0) {
303
- const l = w(e.selection);
304
- if (!l)
305
- return e;
306
- const { indexes: r } = J(t, e), { indexes: s } = J(n, e);
307
- if (r.includes(n))
308
- return e;
309
- const c = tt(
310
- l,
311
- r,
312
- s,
469
+ function ct(e) {
470
+ const { tr: t, origin: n, target: o, select: l = !0, pos: r } = e, s = r != null ? t.doc.resolve(r) : t.selection.$from, c = x(s);
471
+ if (!c)
472
+ return t;
473
+ const { indexes: d } = ee(n, t), { indexes: p } = ee(o, t);
474
+ if (d.includes(o))
475
+ return t;
476
+ const a = at(
477
+ c,
478
+ d,
479
+ p,
313
480
  0
314
- ), i = x(e).replaceWith(
315
- l.pos,
316
- l.pos + l.node.nodeSize,
317
- c
481
+ ), m = _(t).replaceWith(
482
+ c.pos,
483
+ c.pos + c.node.nodeSize,
484
+ a
318
485
  );
319
- if (!o)
320
- return i;
321
- const m = g.get(c), a = l.start, u = n, p = m.positionAt(m.height - 1, u, c), f = i.doc.resolve(a + p), $ = y.colSelection, P = m.positionAt(0, u, c), _ = i.doc.resolve(a + P);
322
- return i.setSelection($(f, _));
323
- }
324
- function lt(e, t, n, o = !0) {
325
- const l = w(e.selection);
326
486
  if (!l)
327
- return e;
328
- const { indexes: r } = Q(t, e), { indexes: s } = Q(n, e);
329
- if (r.includes(n))
330
- return e;
331
- const c = ot(
332
- l,
333
- r,
334
- s,
487
+ return m;
488
+ 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);
489
+ return m.setSelection(E(D, H));
490
+ }
491
+ function it(e) {
492
+ const { tr: t, origin: n, target: o, select: l = !0, pos: r } = e, s = r != null ? t.doc.resolve(r) : t.selection.$from, c = x(s);
493
+ if (!c)
494
+ return t;
495
+ const { indexes: d } = te(n, t), { indexes: p } = te(o, t);
496
+ if (d.includes(o))
497
+ return t;
498
+ const a = st(
499
+ c,
500
+ d,
501
+ p,
335
502
  0
336
- ), i = x(e).replaceWith(
337
- l.pos,
338
- l.pos + l.node.nodeSize,
339
- c
503
+ ), m = _(t).replaceWith(
504
+ c.pos,
505
+ c.pos + c.node.nodeSize,
506
+ a
340
507
  );
341
- if (!o)
342
- return i;
343
- const m = g.get(c), a = l.start, u = n, p = m.positionAt(u, m.width - 1, c), f = i.doc.resolve(a + p), $ = y.rowSelection, P = m.positionAt(u, 0, c), _ = i.doc.resolve(a + P);
344
- return i.setSelection($(f, _));
508
+ if (!l)
509
+ return m;
510
+ 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);
511
+ return m.setSelection(E(D, H));
345
512
  }
346
- const v = Fe({
347
- tableGroup: "block",
348
- cellContent: "paragraph",
349
- cellAttributes: {
350
- alignment: {
351
- default: "left",
352
- getFromDOM: (e) => e.style.textAlign || "left",
353
- setDOMAttr: (e, t) => {
354
- t.style = `text-align: ${e || "left"}`;
355
- }
356
- }
357
- }
358
- }), S = k("table", () => ({
359
- ...v.table,
360
- parseMarkdown: {
361
- match: (e) => e.type === "table",
362
- runner: (e, t, n) => {
363
- const o = t.align, l = t.children.map((r, s) => ({
364
- ...r,
365
- align: o,
366
- isHeader: s === 0
367
- }));
368
- e.openNode(n), e.next(l), e.closeNode();
369
- }
370
- },
371
- toMarkdown: {
372
- match: (e) => e.type.name === "table",
373
- runner: (e, t) => {
374
- var l;
375
- const n = (l = t.content.firstChild) == null ? void 0 : l.content;
376
- if (!n)
377
- return;
378
- const o = [];
379
- n.forEach((r) => {
380
- o.push(r.attrs.alignment);
381
- }), e.openNode("table", void 0, { align: o }), e.next(t.content), e.closeNode();
382
- }
383
- }
384
- }));
385
- d(S.node, {
386
- displayName: "NodeSchema<table>",
387
- group: "Table"
388
- });
389
- d(S.ctx, {
390
- displayName: "NodeSchemaCtx<table>",
391
- group: "Table"
392
- });
393
- const R = k("table_row", () => ({
394
- ...v.table_row,
395
- parseMarkdown: {
396
- match: (e) => e.type === "tableRow",
397
- runner: (e, t, n) => {
398
- const o = t.align, l = t.children.map((r, s) => ({
399
- ...r,
400
- align: o[s],
401
- isHeader: t.isHeader
402
- }));
403
- e.openNode(n), e.next(l), e.closeNode();
404
- }
405
- },
406
- toMarkdown: {
407
- match: (e) => e.type.name === "table_row",
408
- runner: (e, t) => {
409
- e.openNode("tableRow"), e.next(t.content), e.closeNode();
410
- }
411
- }
412
- }));
413
- d(R.node, {
414
- displayName: "NodeSchema<tableRow>",
415
- group: "Table"
416
- });
417
- d(R.ctx, {
418
- displayName: "NodeSchemaCtx<tableRow>",
419
- group: "Table"
420
- });
421
- const M = k("table_cell", () => ({
422
- ...v.table_cell,
423
- parseMarkdown: {
424
- match: (e) => e.type === "tableCell" && !e.isHeader,
425
- runner: (e, t, n) => {
426
- const o = t.align;
427
- e.openNode(n, { alignment: o }).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode();
428
- }
429
- },
430
- toMarkdown: {
431
- match: (e) => e.type.name === "table_cell",
432
- runner: (e, t) => {
433
- e.openNode("tableCell").next(t.content).closeNode();
434
- }
435
- }
436
- }));
437
- d(M.node, {
438
- displayName: "NodeSchema<tableCell>",
439
- group: "Table"
440
- });
441
- d(M.ctx, {
442
- displayName: "NodeSchemaCtx<tableCell>",
443
- group: "Table"
444
- });
445
- const I = k("table_header", () => ({
446
- ...v.table_header,
447
- parseMarkdown: {
448
- match: (e) => e.type === "tableCell" && !!e.isHeader,
449
- runner: (e, t, n) => {
450
- const o = t.align;
451
- e.openNode(n, { alignment: o }), e.openNode(e.schema.nodes.paragraph), e.next(t.children), e.closeNode(), e.closeNode();
452
- }
453
- },
454
- toMarkdown: {
455
- match: (e) => e.type.name === "table_header",
456
- runner: (e, t) => {
457
- e.openNode("tableCell"), e.next(t.content), e.closeNode();
458
- }
459
- }
460
- }));
461
- d(I.node, {
462
- displayName: "NodeSchema<tableHeader>",
463
- group: "Table"
464
- });
465
- d(I.ctx, {
466
- displayName: "NodeSchemaCtx<tableHeader>",
467
- group: "Table"
468
- });
469
- const pe = B((e) => new te(
470
- /^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,
471
- (t, n, o, l) => {
472
- var i, m;
473
- const r = t.doc.resolve(o);
474
- if (!r.node(-1).canReplaceWith(r.index(-1), r.indexAfter(-1), S.type(e)))
475
- return null;
476
- const s = se(
477
- e,
478
- Number((i = n.groups) == null ? void 0 : i.row),
479
- Number((m = n.groups) == null ? void 0 : m.col)
480
- ), c = t.tr.replaceRangeWith(o, l, s);
481
- return c.setSelection(De.create(c.doc, o + 3)).scrollIntoView();
482
- }
483
- ));
484
- d(pe, {
485
- displayName: "InputRule<insertTableInputRule>",
486
- group: "Table"
487
- });
488
- const W = h("GoToPrevTableCell", () => () => le(-1));
489
- d(W, {
513
+ const V = g("GoToPrevTableCell", () => () => re(-1));
514
+ i(V, {
490
515
  displayName: "Command<goToPrevTableCellCommand>",
491
516
  group: "Table"
492
517
  });
493
- const G = h("GoToNextTableCell", () => () => le(1));
494
- d(G, {
518
+ const U = g("GoToNextTableCell", () => () => re(1));
519
+ i(U, {
495
520
  displayName: "Command<goToNextTableCellCommand>",
496
521
  group: "Table"
497
522
  });
498
- const z = h("BreakTable", (e) => () => (t, n) => {
499
- if (!N(t))
523
+ const X = g("ExitTable", (e) => () => (t, n) => {
524
+ if (!G(t))
500
525
  return !1;
501
- const { $head: o } = t.selection, l = o.after(), r = t.tr.replaceWith(l, l, ee.type(e).createAndFill());
502
- return r.setSelection(ne.near(r.doc.resolve(l), 1)).scrollIntoView(), n == null || n(r), !0;
526
+ const { $head: o } = t.selection, l = Je(o, N.type(e));
527
+ if (!l)
528
+ return !1;
529
+ const { to: r } = l, s = t.tr.replaceWith(r, r, De.type(e).createAndFill());
530
+ return s.setSelection(ce.near(s.doc.resolve(r), 1)).scrollIntoView(), n == null || n(s), !0;
503
531
  });
504
- d(z, {
532
+ i(X, {
505
533
  displayName: "Command<breakTableCommand>",
506
534
  group: "Table"
507
535
  });
508
- const fe = h("InsertTable", (e) => ({ row: t, col: n } = {}) => (o, l) => {
509
- const { selection: r, tr: s } = o, { from: c } = r, i = se(e, t, n), m = s.replaceSelectionWith(i), a = ne.findFrom(m.doc.resolve(c), 1, !0);
510
- return a && m.setSelection(a), l == null || l(m), !0;
536
+ const he = g("InsertTable", (e) => ({ row: t, col: n } = {}) => (o, l) => {
537
+ const { selection: r, tr: s } = o, { from: c } = r, d = de(e, t, n), p = s.replaceSelectionWith(d), a = ce.findFrom(p.doc.resolve(c), 1, !0);
538
+ return a && p.setSelection(a), l == null || l(p), !0;
511
539
  });
512
- d(fe, {
540
+ i(he, {
513
541
  displayName: "Command<insertTableCommand>",
514
542
  group: "Table"
515
543
  });
516
- const he = h("MoveRow", () => ({ from: e, to: t } = {}) => (n, o) => {
517
- const { tr: l } = n;
518
- return !!(o == null ? void 0 : o(lt(l, e ?? 0, t ?? 0, !0)));
544
+ const be = g("MoveRow", () => ({ from: e, to: t, pos: n } = {}) => (o, l) => {
545
+ const { tr: r } = o;
546
+ return !!(l == null ? void 0 : l(it({ tr: r, origin: e ?? 0, target: t ?? 0, pos: n, select: !0 })));
519
547
  });
520
- d(he, {
548
+ i(be, {
521
549
  displayName: "Command<moveRowCommand>",
522
550
  group: "Table"
523
551
  });
524
- const ge = h("MoveCol", () => ({ from: e, to: t } = {}) => (n, o) => {
525
- const { tr: l } = n;
526
- return !!(o == null ? void 0 : o(nt(l, e ?? 0, t ?? 0, !0)));
552
+ const Ce = g("MoveCol", () => ({ from: e, to: t, pos: n } = {}) => (o, l) => {
553
+ const { tr: r } = o;
554
+ return !!(l == null ? void 0 : l(ct({ tr: r, origin: e ?? 0, target: t ?? 0, pos: n, select: !0 })));
527
555
  });
528
- d(ge, {
556
+ i(Ce, {
529
557
  displayName: "Command<moveColCommand>",
530
558
  group: "Table"
531
559
  });
532
- const be = h("SelectRow", () => (e = 0) => (t, n) => {
560
+ const ye = g("SelectRow", () => (e = { index: 0 }) => (t, n) => {
533
561
  const { tr: o } = t;
534
- return !!(n == null ? void 0 : n(Ye(e)(o)));
562
+ return !!(n == null ? void 0 : n(lt(e.index, e.pos)(o)));
535
563
  });
536
- d(be, {
564
+ i(ye, {
537
565
  displayName: "Command<selectRowCommand>",
538
566
  group: "Table"
539
567
  });
540
- const Ce = h("SelectCol", () => (e = 0) => (t, n) => {
568
+ const we = g("SelectCol", () => (e = { index: 0 }) => (t, n) => {
541
569
  const { tr: o } = t;
542
- return !!(n == null ? void 0 : n(et(e)(o)));
570
+ return !!(n == null ? void 0 : n(rt(e.index, e.pos)(o)));
543
571
  });
544
- d(Ce, {
572
+ i(we, {
545
573
  displayName: "Command<selectColCommand>",
546
574
  group: "Table"
547
575
  });
548
- const ye = h("SelectTable", () => () => (e, t) => {
576
+ const ke = g("SelectTable", () => () => (e, t) => {
549
577
  const { tr: n } = e;
550
- return !!(t == null ? void 0 : t(Qe(n)));
578
+ return !!(t == null ? void 0 : t(nt(n)));
551
579
  });
552
- d(ye, {
580
+ i(ke, {
553
581
  displayName: "Command<selectTableCommand>",
554
582
  group: "Table"
555
583
  });
556
- const ke = h("DeleteSelectedCells", () => () => (e, t) => {
584
+ const Ne = g("DeleteSelectedCells", () => () => (e, t) => {
557
585
  const { selection: n } = e;
558
- if (!(n instanceof y))
586
+ if (!(n instanceof k))
559
587
  return !1;
560
588
  const o = n.isRowSelection(), l = n.isColSelection();
561
- return o && l ? Ke(e, t) : l ? He(e, t) : Le(e, t);
589
+ return o && l ? Ke(e, t) : l ? Fe(e, t) : Ge(e, t);
562
590
  });
563
- d(ke, {
591
+ i(Ne, {
564
592
  displayName: "Command<deleteSelectedCellsCommand>",
565
593
  group: "Table"
566
594
  });
567
- const we = h("AddColBefore", () => () => We);
568
- d(we, {
595
+ const Te = g("AddColBefore", () => () => We);
596
+ i(Te, {
569
597
  displayName: "Command<addColBeforeCommand>",
570
598
  group: "Table"
571
599
  });
572
- const Ne = h("AddColAfter", () => () => Ge);
573
- d(Ne, {
600
+ const Se = g("AddColAfter", () => () => ze);
601
+ i(Se, {
574
602
  displayName: "Command<addColAfterCommand>",
575
603
  group: "Table"
576
604
  });
577
- const Te = h("AddRowBefore", (e) => () => (t, n) => {
578
- if (!N(t))
605
+ const Re = g("AddRowBefore", (e) => () => (t, n) => {
606
+ if (!G(t))
579
607
  return !1;
580
608
  if (n) {
581
- const o = re(t);
582
- n(ce(e, t.tr, o, o.top));
609
+ const o = ae(t);
610
+ n(me(e, t.tr, o, o.top));
583
611
  }
584
612
  return !0;
585
613
  });
586
- d(Te, {
614
+ i(Re, {
587
615
  displayName: "Command<addRowBeforeCommand>",
588
616
  group: "Table"
589
617
  });
590
- const Se = h("AddRowAfter", (e) => () => (t, n) => {
591
- if (!N(t))
618
+ const Me = g("AddRowAfter", (e) => () => (t, n) => {
619
+ if (!G(t))
592
620
  return !1;
593
621
  if (n) {
594
- const o = re(t);
595
- n(ce(e, t.tr, o, o.bottom));
622
+ const o = ae(t);
623
+ n(me(e, t.tr, o, o.bottom));
596
624
  }
597
625
  return !0;
598
626
  });
599
- d(Se, {
627
+ i(Me, {
600
628
  displayName: "Command<addRowAfterCommand>",
601
629
  group: "Table"
602
630
  });
603
- const Re = h("SetAlign", () => (e = "left") => ze("alignment", e));
604
- d(Re, {
631
+ const xe = g("SetAlign", () => (e = "left") => je("alignment", e));
632
+ i(xe, {
605
633
  displayName: "Command<setAlignCommand>",
606
634
  group: "Table"
607
635
  });
608
- const j = oe("tableKeymap", {
636
+ const Ae = F((e) => new ne(
637
+ /^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,
638
+ (t, n, o, l) => {
639
+ var d, p;
640
+ const r = t.doc.resolve(o);
641
+ if (!r.node(-1).canReplaceWith(r.index(-1), r.indexAfter(-1), N.type(e)))
642
+ return null;
643
+ const s = de(
644
+ e,
645
+ Number((d = n.groups) == null ? void 0 : d.row),
646
+ Number((p = n.groups) == null ? void 0 : p.col)
647
+ ), c = t.tr.replaceRangeWith(o, l, s);
648
+ return c.setSelection(Qe.create(c.doc, o + 3)).scrollIntoView();
649
+ }
650
+ ));
651
+ i(Ae, {
652
+ displayName: "InputRule<insertTableInputRule>",
653
+ group: "Table"
654
+ });
655
+ const q = le("tableKeymap", {
609
656
  NextCell: {
610
657
  shortcuts: ["Mod-]", "Tab"],
611
658
  command: (e) => {
612
659
  const t = e.get(A);
613
- return () => t.call(G.key);
660
+ return () => t.call(U.key);
614
661
  }
615
662
  },
616
663
  PrevCell: {
617
664
  shortcuts: ["Mod-[", "Shift-Tab"],
618
665
  command: (e) => {
619
666
  const t = e.get(A);
620
- return () => t.call(W.key);
667
+ return () => t.call(V.key);
621
668
  }
622
669
  },
623
670
  ExitTable: {
624
671
  shortcuts: ["Mod-Enter"],
625
672
  command: (e) => {
626
673
  const t = e.get(A);
627
- return () => t.call(z.key);
674
+ return () => t.call(X.key);
628
675
  }
629
676
  }
630
677
  });
631
- d(j.ctx, {
678
+ i(q.ctx, {
632
679
  displayName: "KeymapCtx<table>",
633
680
  group: "Table"
634
681
  });
635
- d(j.shortcuts, {
682
+ i(q.shortcuts, {
636
683
  displayName: "Keymap<table>",
637
684
  group: "Table"
638
685
  });
639
- const E = "footnote_definition", Y = "footnoteDefinition", Z = k("footnote_definition", () => ({
686
+ const B = "footnote_definition", oe = "footnoteDefinition", J = C("footnote_definition", () => ({
640
687
  group: "block",
641
688
  content: "block+",
642
689
  defining: !0,
@@ -647,10 +694,10 @@ const E = "footnote_definition", Y = "footnoteDefinition", Z = k("footnote_defin
647
694
  },
648
695
  parseDOM: [
649
696
  {
650
- tag: `dl[data-type="${E}"]`,
697
+ tag: `dl[data-type="${B}"]`,
651
698
  getAttrs: (e) => {
652
699
  if (!(e instanceof HTMLElement))
653
- throw O(e);
700
+ throw K(e);
654
701
  return {
655
702
  label: e.dataset.label
656
703
  };
@@ -665,14 +712,14 @@ const E = "footnote_definition", Y = "footnoteDefinition", Z = k("footnote_defin
665
712
  {
666
713
  // TODO: add a prosemirror plugin to sync label on change
667
714
  "data-label": t,
668
- "data-type": E
715
+ "data-type": B
669
716
  },
670
717
  ["dt", t],
671
718
  ["dd", 0]
672
719
  ];
673
720
  },
674
721
  parseMarkdown: {
675
- match: ({ type: e }) => e === Y,
722
+ match: ({ type: e }) => e === oe,
676
723
  runner: (e, t, n) => {
677
724
  e.openNode(n, {
678
725
  label: t.label
@@ -680,24 +727,24 @@ const E = "footnote_definition", Y = "footnoteDefinition", Z = k("footnote_defin
680
727
  }
681
728
  },
682
729
  toMarkdown: {
683
- match: (e) => e.type.name === E,
730
+ match: (e) => e.type.name === B,
684
731
  runner: (e, t) => {
685
- e.openNode(Y, void 0, {
732
+ e.openNode(oe, void 0, {
686
733
  label: t.attrs.label,
687
734
  identifier: t.attrs.label
688
735
  }).next(t.content).closeNode();
689
736
  }
690
737
  }
691
738
  }));
692
- d(Z.ctx, {
739
+ i(J.ctx, {
693
740
  displayName: "NodeSchemaCtx<footnodeDef>",
694
741
  group: "footnote"
695
742
  });
696
- d(Z.node, {
743
+ i(J.node, {
697
744
  displayName: "NodeSchema<footnodeDef>",
698
745
  group: "footnote"
699
746
  });
700
- const D = "footnote_reference", V = k("footnote_reference", () => ({
747
+ const L = "footnote_reference", Q = C("footnote_reference", () => ({
701
748
  group: "inline",
702
749
  inline: !0,
703
750
  atom: !0,
@@ -708,10 +755,10 @@ const D = "footnote_reference", V = k("footnote_reference", () => ({
708
755
  },
709
756
  parseDOM: [
710
757
  {
711
- tag: `sup[data-type="${D}"]`,
758
+ tag: `sup[data-type="${L}"]`,
712
759
  getAttrs: (e) => {
713
760
  if (!(e instanceof HTMLElement))
714
- throw O(e);
761
+ throw K(e);
715
762
  return {
716
763
  label: e.dataset.label
717
764
  };
@@ -725,7 +772,7 @@ const D = "footnote_reference", V = k("footnote_reference", () => ({
725
772
  {
726
773
  // TODO: add a prosemirror plugin to sync label on change
727
774
  "data-label": t,
728
- "data-type": D
775
+ "data-type": L
729
776
  },
730
777
  t
731
778
  ];
@@ -739,7 +786,7 @@ const D = "footnote_reference", V = k("footnote_reference", () => ({
739
786
  }
740
787
  },
741
788
  toMarkdown: {
742
- match: (e) => e.type.name === D,
789
+ match: (e) => e.type.name === L,
743
790
  runner: (e, t) => {
744
791
  e.addNode("footnoteReference", void 0, void 0, {
745
792
  label: t.attrs.label,
@@ -748,15 +795,15 @@ const D = "footnote_reference", V = k("footnote_reference", () => ({
748
795
  }
749
796
  }
750
797
  }));
751
- d(V.ctx, {
798
+ i(Q.ctx, {
752
799
  displayName: "NodeSchemaCtx<footnodeRef>",
753
800
  group: "footnote"
754
801
  });
755
- d(V.node, {
802
+ i(Q.node, {
756
803
  displayName: "NodeSchema<footnodeRef>",
757
804
  group: "footnote"
758
805
  });
759
- const Me = $e.extendSchema((e) => (t) => {
806
+ const ve = Ee.extendSchema((e) => (t) => {
760
807
  const n = e(t);
761
808
  return {
762
809
  ...n,
@@ -771,10 +818,10 @@ const Me = $e.extendSchema((e) => (t) => {
771
818
  tag: 'li[data-item-type="task"]',
772
819
  getAttrs: (o) => {
773
820
  if (!(o instanceof HTMLElement))
774
- throw O(o);
821
+ throw K(o);
775
822
  return {
776
823
  label: o.dataset.label,
777
- listType: o.dataset["list-type"],
824
+ listType: o.dataset.listType,
778
825
  spread: o.dataset.spread,
779
826
  checked: o.dataset.checked ? o.dataset.checked === "true" : null
780
827
  };
@@ -800,8 +847,8 @@ const Me = $e.extendSchema((e) => (t) => {
800
847
  n.parseMarkdown.runner(o, l, r);
801
848
  return;
802
849
  }
803
- const s = l.label != null ? `${l.label}.` : "•", c = l.checked != null ? !!l.checked : null, i = l.label != null ? "ordered" : "bullet", m = l.spread != null ? `${l.spread}` : "true";
804
- o.openNode(r, { label: s, listType: i, spread: m, checked: c }), o.next(l.children), o.closeNode();
850
+ const s = l.label != null ? `${l.label}.` : "•", c = l.checked != null ? !!l.checked : null, d = l.label != null ? "ordered" : "bullet", p = l.spread != null ? `${l.spread}` : "true";
851
+ o.openNode(r, { label: s, listType: d, spread: p, checked: c }), o.next(l.children), o.closeNode();
805
852
  }
806
853
  },
807
854
  toMarkdown: {
@@ -811,17 +858,17 @@ const Me = $e.extendSchema((e) => (t) => {
811
858
  n.toMarkdown.runner(o, l);
812
859
  return;
813
860
  }
814
- const r = l.attrs.label, s = l.attrs.listType, c = l.attrs.spread === "true", i = l.attrs.checked;
815
- o.openNode("listItem", void 0, { label: r, listType: s, spread: c, checked: i }), o.next(l.content), o.closeNode();
861
+ const r = l.attrs.label, s = l.attrs.listType, c = l.attrs.spread === "true", d = l.attrs.checked;
862
+ o.openNode("listItem", void 0, { label: r, listType: s, spread: c, checked: d }), o.next(l.content), o.closeNode();
816
863
  }
817
864
  }
818
865
  };
819
866
  });
820
- d(Me, {
867
+ i(ve, {
821
868
  displayName: "NodeSchema<listItem>",
822
869
  group: "ListItem"
823
870
  });
824
- const Ae = B(() => new te(/^\[(?<checked>\s|x)\]\s$/, (e, t, n, o) => {
871
+ const _e = F(() => new ne(/^\[(?<checked>\s|x)\]\s$/, (e, t, n, o) => {
825
872
  var a;
826
873
  const l = e.doc.resolve(n);
827
874
  let r = 0, s = l.node(r);
@@ -829,148 +876,164 @@ const Ae = B(() => new te(/^\[(?<checked>\s|x)\]\s$/, (e, t, n, o) => {
829
876
  r--, s = l.node(r);
830
877
  if (!s || s.attrs.checked != null)
831
878
  return null;
832
- const c = ((a = t.groups) == null ? void 0 : a.checked) === "x", i = l.before(r), m = e.tr;
833
- return m.deleteRange(n, o).setNodeMarkup(i, void 0, { ...s.attrs, checked: c }), m;
879
+ const c = ((a = t.groups) == null ? void 0 : a.checked) === "x", d = l.before(r), p = e.tr;
880
+ return p.deleteRange(n, o).setNodeMarkup(d, void 0, { ...s.attrs, checked: c }), p;
834
881
  }));
835
- d(Ae, {
882
+ i(_e, {
836
883
  displayName: "InputRule<wrapInTaskListInputRule>",
837
884
  group: "ListItem"
838
885
  });
839
- const rt = [
840
- L,
841
- j
842
- ].flat(), at = [
843
- pe,
844
- Ae
845
- ], st = [
846
- ae
847
- ], xe = F((e) => {
848
- const t = new Oe("MILKDOWN_AUTO_INSERT_ZERO_SPACE"), n = (l) => l.type === ee.type(e), o = (l) => n(l) && l.nodeSize === 2;
849
- return new Be({
850
- key: t,
851
- props: {
852
- handleDOMEvents: {
853
- compositionstart(l) {
854
- const { state: r, dispatch: s } = l, { tr: c, selection: i } = r, { $from: m } = i;
855
- return X.safari && N(r) && i.empty && o(m.parent) && s(c.insertText("⁠", m.start())), !1;
856
- },
857
- compositionend(l) {
858
- const { state: r, dispatch: s } = l, { tr: c, selection: i } = r, { $from: m } = i;
859
- return X.safari && N(r) && i.empty && n(m.parent) && m.parent.textContent.startsWith("⁠") && s(c.delete(m.start(), m.start() + 1)), !1;
860
- }
861
- }
862
- }
863
- });
864
- });
865
- d(xe, {
866
- displayName: "Prose<autoInsertZeroSpaceInTablePlugin>",
886
+ const dt = [
887
+ j,
888
+ q
889
+ ].flat(), mt = [
890
+ Ae,
891
+ _e
892
+ ], ut = [
893
+ ie
894
+ ], $e = v(() => et);
895
+ i($e, {
896
+ displayName: "Prose<autoInsertSpanPlugin>",
867
897
  group: "Prose"
868
898
  });
869
- const ve = F(() => je({}));
870
- d(ve, {
899
+ const pt = v(() => Ve({}));
900
+ i(pt, {
871
901
  displayName: "Prose<columnResizingPlugin>",
872
902
  group: "Prose"
873
903
  });
874
- const Ie = F(() => Ze());
875
- d(Ie, {
904
+ const Ie = v(() => Ue({ allowTableNodeSelection: !0 }));
905
+ i(Ie, {
876
906
  displayName: "Prose<tableEditingPlugin>",
877
907
  group: "Prose"
878
908
  });
879
- const U = Ee("remarkGFM", () => qe);
880
- d(U.plugin, {
909
+ const Y = Be("remarkGFM", () => tt);
910
+ i(Y.plugin, {
881
911
  displayName: "Remark<remarkGFMPlugin>",
882
912
  group: "Remark"
883
913
  });
884
- d(U.options, {
914
+ i(Y.options, {
885
915
  displayName: "RemarkConfig<remarkGFMPlugin>",
886
916
  group: "Remark"
887
917
  });
888
- const ct = [
889
- xe,
918
+ const ft = new Ye("MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN");
919
+ function gt(e, t) {
920
+ let n = 0;
921
+ return t.forEach((o, l, r) => {
922
+ o === e && (n = r);
923
+ }), n;
924
+ }
925
+ const Pe = v(() => new Ze({
926
+ key: ft,
927
+ appendTransaction: (e, t, n) => {
928
+ let o;
929
+ const l = (r, s) => {
930
+ if (o || (o = n.tr), r.type.name !== "table_cell")
931
+ return;
932
+ const c = n.doc.resolve(s), d = c.node(c.depth), a = c.node(c.depth - 1).firstChild;
933
+ if (!a)
934
+ return;
935
+ const m = gt(r, d), u = a.maybeChild(m);
936
+ if (!u)
937
+ return;
938
+ const f = u.attrs.alignment, b = r.attrs.alignment;
939
+ f !== b && o.setNodeMarkup(s, void 0, { ...r.attrs, alignment: f });
940
+ };
941
+ return t.doc !== n.doc && n.doc.descendants(l), o;
942
+ }
943
+ }));
944
+ i(Pe, {
945
+ displayName: "Prose<keepTableAlignPlugin>",
946
+ group: "Prose"
947
+ });
948
+ const ht = [
949
+ Pe,
950
+ $e,
951
+ Y,
952
+ Ie
953
+ ].flat(), bt = [
890
954
  ve,
891
- Ie,
892
- U
893
- ].flat(), it = [
894
- Me,
895
- S,
955
+ N,
956
+ $,
896
957
  R,
897
958
  I,
898
959
  M,
899
- Z,
900
- V,
901
- K,
902
- T
903
- ].flat(), dt = [
904
- G,
960
+ J,
961
+ Q,
905
962
  W,
906
- z,
907
- fe,
963
+ T
964
+ ].flat(), Ct = [
965
+ U,
966
+ V,
967
+ X,
908
968
  he,
909
- ge,
910
969
  be,
911
970
  Ce,
912
971
  ye,
913
- ke,
914
- Te,
915
- Se,
916
972
  we,
973
+ ke,
917
974
  Ne,
918
975
  Re,
919
- H
920
- ], wt = [it, at, st, rt, ct, dt].flat();
976
+ Me,
977
+ Te,
978
+ Se,
979
+ xe,
980
+ z
981
+ ], _t = [bt, mt, ut, dt, Ct, ht].flat();
921
982
  export {
922
- Ne as addColAfterCommand,
923
- we as addColBeforeCommand,
924
- Se as addRowAfterCommand,
925
- Te as addRowBeforeCommand,
926
- ce as addRowWithAlignment,
927
- xe as autoInsertZeroSpaceInTablePlugin,
928
- z as breakTableCommand,
929
- ve as columnResizingPlugin,
930
- dt as commands,
931
- se as createTable,
932
- ke as deleteSelectedCellsCommand,
933
- Me as extendListItemSchemaForTask,
934
- w as findTable,
935
- Z as footnoteDefinitionSchema,
936
- V as footnoteReferenceSchema,
937
- Je as getAllCellsInTable,
938
- b as getCellsInCol,
939
- C as getCellsInRow,
940
- wt as gfm,
941
- G as goToNextTableCellCommand,
942
- W as goToPrevTableCellCommand,
943
- at as inputRules,
944
- fe as insertTableCommand,
945
- pe as insertTableInputRule,
946
- rt as keymap,
947
- st as markInputRules,
948
- nt as moveCol,
949
- ge as moveColCommand,
950
- lt as moveRow,
951
- he as moveRowCommand,
952
- ct as plugins,
953
- U as remarkGFMPlugin,
954
- it as schema,
955
- et as selectCol,
956
- Ce as selectColCommand,
957
- ie as selectLine,
958
- Ye as selectRow,
959
- be as selectRowCommand,
960
- Qe as selectTable,
961
- ye as selectTableCommand,
962
- Re as setAlignCommand,
963
- K as strikethroughAttr,
964
- ae as strikethroughInputRule,
965
- L as strikethroughKeymap,
983
+ Se as addColAfterCommand,
984
+ Te as addColBeforeCommand,
985
+ Me as addRowAfterCommand,
986
+ Re as addRowBeforeCommand,
987
+ me as addRowWithAlignment,
988
+ $e as autoInsertSpanPlugin,
989
+ pt as columnResizingPlugin,
990
+ Ct as commands,
991
+ de as createTable,
992
+ Ne as deleteSelectedCellsCommand,
993
+ X as exitTable,
994
+ ve as extendListItemSchemaForTask,
995
+ x as findTable,
996
+ J as footnoteDefinitionSchema,
997
+ Q as footnoteReferenceSchema,
998
+ ot as getAllCellsInTable,
999
+ y as getCellsInCol,
1000
+ w as getCellsInRow,
1001
+ _t as gfm,
1002
+ U as goToNextTableCellCommand,
1003
+ V as goToPrevTableCellCommand,
1004
+ mt as inputRules,
1005
+ he as insertTableCommand,
1006
+ Ae as insertTableInputRule,
1007
+ Pe as keepTableAlignPlugin,
1008
+ dt as keymap,
1009
+ ut as markInputRules,
1010
+ ct as moveCol,
1011
+ Ce as moveColCommand,
1012
+ it as moveRow,
1013
+ be as moveRowCommand,
1014
+ ht as plugins,
1015
+ Y as remarkGFMPlugin,
1016
+ bt as schema,
1017
+ rt as selectCol,
1018
+ we as selectColCommand,
1019
+ ue as selectLine,
1020
+ lt as selectRow,
1021
+ ye as selectRowCommand,
1022
+ nt as selectTable,
1023
+ ke as selectTableCommand,
1024
+ xe as setAlignCommand,
1025
+ W as strikethroughAttr,
1026
+ ie as strikethroughInputRule,
1027
+ j as strikethroughKeymap,
966
1028
  T as strikethroughSchema,
967
1029
  M as tableCellSchema,
968
1030
  Ie as tableEditingPlugin,
1031
+ $ as tableHeaderRowSchema,
969
1032
  I as tableHeaderSchema,
970
- j as tableKeymap,
1033
+ q as tableKeymap,
971
1034
  R as tableRowSchema,
972
- S as tableSchema,
973
- H as toggleStrikethroughCommand,
974
- Ae as wrapInTaskListInputRule
1035
+ N as tableSchema,
1036
+ z as toggleStrikethroughCommand,
1037
+ _e as wrapInTaskListInputRule
975
1038
  };
976
1039
  //# sourceMappingURL=index.es.js.map