@milkdown/preset-gfm 7.2.3 → 7.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.es.js +159 -160
- package/lib/index.es.js.map +1 -1
- package/lib/mark/strike-through.d.ts.map +1 -1
- package/lib/node/table/index.d.ts.map +1 -1
- package/lib/node/table/utils.d.ts +3 -2
- package/lib/node/table/utils.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/mark/strike-through.ts +3 -5
- package/src/node/table/index.ts +16 -13
- package/src/node/table/utils.ts +9 -8
- package/src/plugin/auto-insert-zero-space-plugin.ts +2 -2
package/lib/index.es.js
CHANGED
|
@@ -2,10 +2,11 @@ import { expectDomTypeError as O } from "@milkdown/exception";
|
|
|
2
2
|
import { paragraphSchema as Q, listItemSchema as Ie } from "@milkdown/preset-commonmark";
|
|
3
3
|
import { InputRule as Y } from "@milkdown/prose/inputrules";
|
|
4
4
|
import { $markAttr as $e, $markSchema as _e, $command as h, $useKeymap as ee, $nodeSchema as k, $inputRule as te, $prose as B, $remark as Pe } from "@milkdown/utils";
|
|
5
|
-
import { commandsCtx as
|
|
5
|
+
import { commandsCtx as A } from "@milkdown/core";
|
|
6
6
|
import { TextSelection as Ee, Selection as oe, PluginKey as De, Plugin as Oe } from "@milkdown/prose/state";
|
|
7
7
|
import { TableMap as g, CellSelection as y, tableNodes as Be, goToNextCell as ne, isInTable as N, deleteTable as Ke, deleteColumn as He, deleteRow as Le, addColumnBefore as Fe, addColumnAfter as We, selectedRect as le, setCellAttr as ze, columnResizing as Ge, tableEditing as je } from "@milkdown/prose/tables";
|
|
8
|
-
import {
|
|
8
|
+
import { findParentNode as Ze, cloneTr as M, browser as V } from "@milkdown/prose";
|
|
9
|
+
import { toggleMark as Ve } from "@milkdown/prose/commands";
|
|
9
10
|
import Ue from "remark-gfm";
|
|
10
11
|
const d = (e, t) => (Object.assign(e, {
|
|
11
12
|
meta: {
|
|
@@ -44,10 +45,7 @@ d(x.ctx, {
|
|
|
44
45
|
displayName: "MarkSchemaCtx<strikethrough>",
|
|
45
46
|
group: "Strikethrough"
|
|
46
47
|
});
|
|
47
|
-
const H = h("ToggleStrikeThrough", () => () =>
|
|
48
|
-
const e = x.type();
|
|
49
|
-
return Ze(e, "~~");
|
|
50
|
-
});
|
|
48
|
+
const H = h("ToggleStrikeThrough", (e) => () => Ve(x.type(e)));
|
|
51
49
|
d(H, {
|
|
52
50
|
displayName: "Command<ToggleStrikethrough>",
|
|
53
51
|
group: "Strikethrough"
|
|
@@ -56,7 +54,7 @@ const L = ee("strikeThroughKeymap", {
|
|
|
56
54
|
ToggleStrikethrough: {
|
|
57
55
|
shortcuts: "Mod-Alt-x",
|
|
58
56
|
command: (e) => {
|
|
59
|
-
const t = e.get(
|
|
57
|
+
const t = e.get(A);
|
|
60
58
|
return () => t.call(H.key);
|
|
61
59
|
}
|
|
62
60
|
}
|
|
@@ -69,10 +67,10 @@ d(L.shortcuts, {
|
|
|
69
67
|
displayName: "Keymap<strikethrough>",
|
|
70
68
|
group: "Strikethrough"
|
|
71
69
|
});
|
|
72
|
-
const re = (e = 3,
|
|
73
|
-
const
|
|
74
|
-
return T.type().create(null,
|
|
75
|
-
}, w = (e) =>
|
|
70
|
+
const re = (e, t = 3, n = 3) => {
|
|
71
|
+
const o = Array(n).fill(0).map(() => R.type(e).createAndFill()), l = Array(n).fill(0).map(() => I.type(e).createAndFill()), r = Array(t).fill(0).map((s, c) => S.type(e).create(null, c === 0 ? l : o));
|
|
72
|
+
return T.type(e).create(null, r);
|
|
73
|
+
}, w = (e) => Ze((t) => t.type.spec.tableRole === "table")(e), b = (e, t) => {
|
|
76
74
|
const n = w(t);
|
|
77
75
|
if (!n)
|
|
78
76
|
return;
|
|
@@ -82,10 +80,10 @@ const re = (e = 3, t = 3) => {
|
|
|
82
80
|
const r = n.node.nodeAt(l);
|
|
83
81
|
if (!r)
|
|
84
82
|
return;
|
|
85
|
-
const
|
|
83
|
+
const s = l + n.start;
|
|
86
84
|
return {
|
|
87
|
-
pos:
|
|
88
|
-
start:
|
|
85
|
+
pos: s,
|
|
86
|
+
start: s + 1,
|
|
89
87
|
node: r
|
|
90
88
|
};
|
|
91
89
|
}).filter((l) => l != null);
|
|
@@ -99,10 +97,10 @@ const re = (e = 3, t = 3) => {
|
|
|
99
97
|
const r = n.node.nodeAt(l);
|
|
100
98
|
if (!r)
|
|
101
99
|
return;
|
|
102
|
-
const
|
|
100
|
+
const s = l + n.start;
|
|
103
101
|
return {
|
|
104
|
-
pos:
|
|
105
|
-
start:
|
|
102
|
+
pos: s,
|
|
103
|
+
start: s + 1,
|
|
106
104
|
node: r
|
|
107
105
|
};
|
|
108
106
|
}).filter((l) => l != null);
|
|
@@ -117,8 +115,8 @@ const re = (e = 3, t = 3) => {
|
|
|
117
115
|
top: 0,
|
|
118
116
|
bottom: n.height
|
|
119
117
|
}).map((l) => {
|
|
120
|
-
const r = t.node.nodeAt(l),
|
|
121
|
-
return { pos:
|
|
118
|
+
const r = t.node.nodeAt(l), s = l + t.start;
|
|
119
|
+
return { pos: s, start: s + 1, node: r };
|
|
122
120
|
});
|
|
123
121
|
}, qe = (e) => {
|
|
124
122
|
const t = Xe(e.selection);
|
|
@@ -126,47 +124,47 @@ const re = (e = 3, t = 3) => {
|
|
|
126
124
|
const n = e.doc.resolve(t[0].pos), o = t[t.length - 1];
|
|
127
125
|
if (o) {
|
|
128
126
|
const l = e.doc.resolve(o.pos);
|
|
129
|
-
return
|
|
127
|
+
return M(e.setSelection(new y(l, n)));
|
|
130
128
|
}
|
|
131
129
|
}
|
|
132
130
|
return e;
|
|
133
131
|
};
|
|
134
|
-
function ae(e, { map:
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
return R.type().createAndFill({ alignment:
|
|
132
|
+
function ae(e, t, { map: n, tableStart: o, table: l }, r) {
|
|
133
|
+
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) => {
|
|
134
|
+
const a = l.nodeAt(n.map[m]);
|
|
135
|
+
return R.type(e).createAndFill({ alignment: a == null ? void 0 : a.attrs.alignment });
|
|
138
136
|
});
|
|
139
|
-
return
|
|
137
|
+
return t.insert(s, S.type(e).create(null, c)), t;
|
|
140
138
|
}
|
|
141
139
|
const se = (e) => (t) => (n) => {
|
|
142
140
|
const o = w(n.selection), l = e === "row";
|
|
143
141
|
if (o) {
|
|
144
142
|
const r = g.get(o.node);
|
|
145
143
|
if (t >= 0 && t < (l ? r.height : r.width)) {
|
|
146
|
-
const
|
|
144
|
+
const s = r.positionAt(
|
|
147
145
|
l ? t : r.height - 1,
|
|
148
146
|
l ? r.width - 1 : t,
|
|
149
147
|
o.node
|
|
150
|
-
),
|
|
151
|
-
return
|
|
148
|
+
), 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);
|
|
149
|
+
return M(n.setSelection(i(c, a)));
|
|
152
150
|
}
|
|
153
151
|
}
|
|
154
152
|
return n;
|
|
155
153
|
}, Je = se("row"), Qe = se("col"), U = (e) => e[0].map((t, n) => e.map((o) => o[n])), ce = (e, t) => {
|
|
156
154
|
const n = [], o = g.get(e);
|
|
157
155
|
for (let r = 0; r < o.height; r++) {
|
|
158
|
-
const
|
|
159
|
-
for (let
|
|
160
|
-
if (!t[r][
|
|
156
|
+
const s = e.child(r), c = [];
|
|
157
|
+
for (let i = 0; i < o.width; i++) {
|
|
158
|
+
if (!t[r][i])
|
|
161
159
|
continue;
|
|
162
|
-
const m = o.map[r * o.width +
|
|
163
|
-
Object.assign({},
|
|
164
|
-
|
|
165
|
-
|
|
160
|
+
const m = o.map[r * o.width + i], a = t[r][i], p = e.nodeAt(m).type.createChecked(
|
|
161
|
+
Object.assign({}, a.attrs),
|
|
162
|
+
a.content,
|
|
163
|
+
a.marks
|
|
166
164
|
);
|
|
167
|
-
|
|
165
|
+
c.push(p);
|
|
168
166
|
}
|
|
169
|
-
n.push(
|
|
167
|
+
n.push(s.type.createChecked(s.attrs, c, s.marks));
|
|
170
168
|
}
|
|
171
169
|
return e.type.createChecked(
|
|
172
170
|
e.attrs,
|
|
@@ -177,21 +175,21 @@ const se = (e) => (t) => (n) => {
|
|
|
177
175
|
const t = g.get(e), n = [];
|
|
178
176
|
for (let o = 0; o < t.height; o++) {
|
|
179
177
|
const l = [], r = {};
|
|
180
|
-
for (let
|
|
181
|
-
const
|
|
182
|
-
if (r[
|
|
178
|
+
for (let s = 0; s < t.width; s++) {
|
|
179
|
+
const c = t.map[o * t.width + s], i = e.nodeAt(c), m = t.findCell(c);
|
|
180
|
+
if (r[c] || m.top !== o) {
|
|
183
181
|
l.push(null);
|
|
184
182
|
continue;
|
|
185
183
|
}
|
|
186
|
-
r[
|
|
184
|
+
r[c] = !0, l.push(i);
|
|
187
185
|
}
|
|
188
186
|
n.push(l);
|
|
189
187
|
}
|
|
190
188
|
return n;
|
|
191
189
|
}, de = (e, t, n, o) => {
|
|
192
|
-
const l = t[0] > n[0] ? -1 : 1, r = e.splice(t[0], t.length),
|
|
193
|
-
let
|
|
194
|
-
return o === -1 && l === 1 ?
|
|
190
|
+
const l = t[0] > n[0] ? -1 : 1, r = e.splice(t[0], t.length), s = r.length % 2 === 0 ? 1 : 0;
|
|
191
|
+
let c;
|
|
192
|
+
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;
|
|
195
193
|
}, Ye = (e, t, n, o) => {
|
|
196
194
|
let l = U(ie(e.node));
|
|
197
195
|
return l = de(l, t, n, o), l = U(l), ce(e.node, l);
|
|
@@ -200,122 +198,122 @@ const se = (e) => (t) => (n) => {
|
|
|
200
198
|
return l = de(l, t, n, o), ce(e.node, l);
|
|
201
199
|
}, X = (e, t) => {
|
|
202
200
|
let n = e, o = e;
|
|
203
|
-
for (let
|
|
204
|
-
const u = b(
|
|
201
|
+
for (let a = e; a >= 0; a--) {
|
|
202
|
+
const u = b(a, t.selection);
|
|
205
203
|
u && u.forEach((p) => {
|
|
206
|
-
const f = p.node.attrs.colspan +
|
|
207
|
-
f >= n && (n =
|
|
204
|
+
const f = p.node.attrs.colspan + a - 1;
|
|
205
|
+
f >= n && (n = a), f > o && (o = f);
|
|
208
206
|
});
|
|
209
207
|
}
|
|
210
|
-
for (let
|
|
211
|
-
const u = b(
|
|
208
|
+
for (let a = e; a <= o; a++) {
|
|
209
|
+
const u = b(a, t.selection);
|
|
212
210
|
u && u.forEach((p) => {
|
|
213
|
-
const f = p.node.attrs.colspan +
|
|
211
|
+
const f = p.node.attrs.colspan + a - 1;
|
|
214
212
|
p.node.attrs.colspan > 1 && f > o && (o = f);
|
|
215
213
|
});
|
|
216
214
|
}
|
|
217
215
|
const l = [];
|
|
218
|
-
for (let
|
|
219
|
-
const u = b(
|
|
220
|
-
u && u.length && l.push(
|
|
216
|
+
for (let a = n; a <= o; a++) {
|
|
217
|
+
const u = b(a, t.selection);
|
|
218
|
+
u && u.length && l.push(a);
|
|
221
219
|
}
|
|
222
220
|
n = l[0], o = l[l.length - 1];
|
|
223
|
-
const r = b(n, t.selection),
|
|
221
|
+
const r = b(n, t.selection), s = C(0, t.selection), c = t.doc.resolve(
|
|
224
222
|
r[r.length - 1].pos
|
|
225
223
|
);
|
|
226
|
-
let
|
|
227
|
-
for (let
|
|
228
|
-
const u = b(
|
|
224
|
+
let i;
|
|
225
|
+
for (let a = o; a >= n; a--) {
|
|
226
|
+
const u = b(a, t.selection);
|
|
229
227
|
if (u && u.length) {
|
|
230
|
-
for (let p =
|
|
231
|
-
if (
|
|
232
|
-
|
|
228
|
+
for (let p = s.length - 1; p >= 0; p--)
|
|
229
|
+
if (s[p].pos === u[0].pos) {
|
|
230
|
+
i = u[0];
|
|
233
231
|
break;
|
|
234
232
|
}
|
|
235
|
-
if (
|
|
233
|
+
if (i)
|
|
236
234
|
break;
|
|
237
235
|
}
|
|
238
236
|
}
|
|
239
|
-
const m = t.doc.resolve(
|
|
240
|
-
return { $anchor:
|
|
237
|
+
const m = t.doc.resolve(i.pos);
|
|
238
|
+
return { $anchor: c, $head: m, indexes: l };
|
|
241
239
|
}, q = (e, t) => {
|
|
242
240
|
let n = e, o = e;
|
|
243
|
-
for (let
|
|
244
|
-
C(
|
|
245
|
-
const f = p.node.attrs.rowspan +
|
|
246
|
-
f >= n && (n =
|
|
241
|
+
for (let a = e; a >= 0; a--)
|
|
242
|
+
C(a, t.selection).forEach((p) => {
|
|
243
|
+
const f = p.node.attrs.rowspan + a - 1;
|
|
244
|
+
f >= n && (n = a), f > o && (o = f);
|
|
247
245
|
});
|
|
248
|
-
for (let
|
|
249
|
-
C(
|
|
250
|
-
const f = p.node.attrs.rowspan +
|
|
246
|
+
for (let a = e; a <= o; a++)
|
|
247
|
+
C(a, t.selection).forEach((p) => {
|
|
248
|
+
const f = p.node.attrs.rowspan + a - 1;
|
|
251
249
|
p.node.attrs.rowspan > 1 && f > o && (o = f);
|
|
252
250
|
});
|
|
253
251
|
const l = [];
|
|
254
|
-
for (let
|
|
255
|
-
const u = C(
|
|
256
|
-
u && u.length && l.push(
|
|
252
|
+
for (let a = n; a <= o; a++) {
|
|
253
|
+
const u = C(a, t.selection);
|
|
254
|
+
u && u.length && l.push(a);
|
|
257
255
|
}
|
|
258
256
|
n = l[0], o = l[l.length - 1];
|
|
259
|
-
const r = C(n, t.selection),
|
|
260
|
-
let
|
|
261
|
-
for (let
|
|
262
|
-
const u = C(
|
|
257
|
+
const r = C(n, t.selection), s = b(0, t.selection), c = t.doc.resolve(r[r.length - 1].pos);
|
|
258
|
+
let i;
|
|
259
|
+
for (let a = o; a >= n; a--) {
|
|
260
|
+
const u = C(a, t.selection);
|
|
263
261
|
if (u && u.length) {
|
|
264
|
-
for (let p =
|
|
265
|
-
if (
|
|
266
|
-
|
|
262
|
+
for (let p = s.length - 1; p >= 0; p--)
|
|
263
|
+
if (s[p].pos === u[0].pos) {
|
|
264
|
+
i = u[0];
|
|
267
265
|
break;
|
|
268
266
|
}
|
|
269
|
-
if (
|
|
267
|
+
if (i)
|
|
270
268
|
break;
|
|
271
269
|
}
|
|
272
270
|
}
|
|
273
|
-
const m = t.doc.resolve(
|
|
274
|
-
return { $anchor:
|
|
271
|
+
const m = t.doc.resolve(i.pos);
|
|
272
|
+
return { $anchor: c, $head: m, indexes: l };
|
|
275
273
|
};
|
|
276
274
|
function tt(e, t, n, o = !0) {
|
|
277
275
|
const l = w(e.selection);
|
|
278
276
|
if (!l)
|
|
279
277
|
return e;
|
|
280
|
-
const { indexes: r } = X(t, e), { indexes:
|
|
278
|
+
const { indexes: r } = X(t, e), { indexes: s } = X(n, e);
|
|
281
279
|
if (r.includes(n))
|
|
282
280
|
return e;
|
|
283
|
-
const
|
|
281
|
+
const c = Ye(
|
|
284
282
|
l,
|
|
285
283
|
r,
|
|
286
|
-
|
|
284
|
+
s,
|
|
287
285
|
0
|
|
288
|
-
),
|
|
286
|
+
), i = M(e).replaceWith(
|
|
289
287
|
l.pos,
|
|
290
288
|
l.pos + l.node.nodeSize,
|
|
291
|
-
|
|
289
|
+
c
|
|
292
290
|
);
|
|
293
291
|
if (!o)
|
|
294
|
-
return
|
|
295
|
-
const m = g.get(
|
|
296
|
-
return
|
|
292
|
+
return i;
|
|
293
|
+
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, _ = m.positionAt(0, u, c), P = i.doc.resolve(a + _);
|
|
294
|
+
return i.setSelection($(f, P));
|
|
297
295
|
}
|
|
298
296
|
function ot(e, t, n, o = !0) {
|
|
299
297
|
const l = w(e.selection);
|
|
300
298
|
if (!l)
|
|
301
299
|
return e;
|
|
302
|
-
const { indexes: r } = q(t, e), { indexes:
|
|
300
|
+
const { indexes: r } = q(t, e), { indexes: s } = q(n, e);
|
|
303
301
|
if (r.includes(n))
|
|
304
302
|
return e;
|
|
305
|
-
const
|
|
303
|
+
const c = et(
|
|
306
304
|
l,
|
|
307
305
|
r,
|
|
308
|
-
|
|
306
|
+
s,
|
|
309
307
|
0
|
|
310
|
-
),
|
|
308
|
+
), i = M(e).replaceWith(
|
|
311
309
|
l.pos,
|
|
312
310
|
l.pos + l.node.nodeSize,
|
|
313
|
-
|
|
311
|
+
c
|
|
314
312
|
);
|
|
315
313
|
if (!o)
|
|
316
|
-
return
|
|
317
|
-
const m = g.get(
|
|
318
|
-
return
|
|
314
|
+
return i;
|
|
315
|
+
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, _ = m.positionAt(u, 0, c), P = i.doc.resolve(a + _);
|
|
316
|
+
return i.setSelection($(f, P));
|
|
319
317
|
}
|
|
320
318
|
const v = Be({
|
|
321
319
|
tableGroup: "block",
|
|
@@ -334,10 +332,10 @@ const v = Be({
|
|
|
334
332
|
parseMarkdown: {
|
|
335
333
|
match: (e) => e.type === "table",
|
|
336
334
|
runner: (e, t, n) => {
|
|
337
|
-
const o = t.align, l = t.children.map((r,
|
|
335
|
+
const o = t.align, l = t.children.map((r, s) => ({
|
|
338
336
|
...r,
|
|
339
337
|
align: o,
|
|
340
|
-
isHeader:
|
|
338
|
+
isHeader: s === 0
|
|
341
339
|
}));
|
|
342
340
|
e.openNode(n), e.next(l), e.closeNode();
|
|
343
341
|
}
|
|
@@ -369,9 +367,9 @@ const S = k("table_row", () => ({
|
|
|
369
367
|
parseMarkdown: {
|
|
370
368
|
match: (e) => e.type === "tableRow",
|
|
371
369
|
runner: (e, t, n) => {
|
|
372
|
-
const o = t.align, l = t.children.map((r,
|
|
370
|
+
const o = t.align, l = t.children.map((r, s) => ({
|
|
373
371
|
...r,
|
|
374
|
-
align: o[
|
|
372
|
+
align: o[s],
|
|
375
373
|
isHeader: t.isHeader
|
|
376
374
|
}));
|
|
377
375
|
e.openNode(n), e.next(l), e.closeNode();
|
|
@@ -440,18 +438,19 @@ d(I.ctx, {
|
|
|
440
438
|
displayName: "NodeSchemaCtx<tableHeader>",
|
|
441
439
|
group: "Table"
|
|
442
440
|
});
|
|
443
|
-
const me = te(() => new Y(
|
|
441
|
+
const me = te((e) => new Y(
|
|
444
442
|
/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,
|
|
445
|
-
(
|
|
446
|
-
var i,
|
|
447
|
-
const
|
|
448
|
-
if (!
|
|
443
|
+
(t, n, o, l) => {
|
|
444
|
+
var i, m;
|
|
445
|
+
const r = t.doc.resolve(o);
|
|
446
|
+
if (!r.node(-1).canReplaceWith(r.index(-1), r.indexAfter(-1), T.type(e)))
|
|
449
447
|
return null;
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
Number((
|
|
453
|
-
|
|
454
|
-
|
|
448
|
+
const s = re(
|
|
449
|
+
e,
|
|
450
|
+
Number((i = n.groups) == null ? void 0 : i.row),
|
|
451
|
+
Number((m = n.groups) == null ? void 0 : m.col)
|
|
452
|
+
), c = t.tr.replaceRangeWith(o, l, s);
|
|
453
|
+
return c.setSelection(Ee.create(c.doc, o + 3)).scrollIntoView();
|
|
455
454
|
}
|
|
456
455
|
));
|
|
457
456
|
d(me, {
|
|
@@ -468,19 +467,19 @@ d(W, {
|
|
|
468
467
|
displayName: "Command<goToNextTableCellCommand>",
|
|
469
468
|
group: "Table"
|
|
470
469
|
});
|
|
471
|
-
const z = h("BreakTable", () => () => (
|
|
472
|
-
if (!N(
|
|
470
|
+
const z = h("BreakTable", (e) => () => (t, n) => {
|
|
471
|
+
if (!N(t))
|
|
473
472
|
return !1;
|
|
474
|
-
const { $head:
|
|
475
|
-
return
|
|
473
|
+
const { $head: o } = t.selection, l = o.after(), r = t.tr.replaceWith(l, l, Q.type(e).createAndFill());
|
|
474
|
+
return r.setSelection(oe.near(r.doc.resolve(l), 1)).scrollIntoView(), n == null || n(r), !0;
|
|
476
475
|
});
|
|
477
476
|
d(z, {
|
|
478
477
|
displayName: "Command<breakTableCommand>",
|
|
479
478
|
group: "Table"
|
|
480
479
|
});
|
|
481
|
-
const ue = h("InsertTable", () => ({ row:
|
|
482
|
-
const { selection:
|
|
483
|
-
return
|
|
480
|
+
const ue = h("InsertTable", (e) => ({ row: t, col: n } = {}) => (o, l) => {
|
|
481
|
+
const { selection: r, tr: s } = o, { from: c } = r, i = re(e, t, n), m = s.replaceSelectionWith(i), a = oe.findFrom(m.doc.resolve(c), 1, !0);
|
|
482
|
+
return a && m.setSelection(a), l == null || l(m), !0;
|
|
484
483
|
});
|
|
485
484
|
d(ue, {
|
|
486
485
|
displayName: "Command<insertTableCommand>",
|
|
@@ -547,12 +546,12 @@ d(ke, {
|
|
|
547
546
|
displayName: "Command<addColAfterCommand>",
|
|
548
547
|
group: "Table"
|
|
549
548
|
});
|
|
550
|
-
const we = h("AddRowBefore", () => () => (
|
|
551
|
-
if (!N(
|
|
549
|
+
const we = h("AddRowBefore", (e) => () => (t, n) => {
|
|
550
|
+
if (!N(t))
|
|
552
551
|
return !1;
|
|
553
|
-
if (
|
|
554
|
-
const
|
|
555
|
-
|
|
552
|
+
if (n) {
|
|
553
|
+
const o = le(t);
|
|
554
|
+
n(ae(e, t.tr, o, o.top));
|
|
556
555
|
}
|
|
557
556
|
return !0;
|
|
558
557
|
});
|
|
@@ -560,12 +559,12 @@ d(we, {
|
|
|
560
559
|
displayName: "Command<addRowBeforeCommand>",
|
|
561
560
|
group: "Table"
|
|
562
561
|
});
|
|
563
|
-
const Ne = h("AddRowAfter", () => () => (
|
|
564
|
-
if (!N(
|
|
562
|
+
const Ne = h("AddRowAfter", (e) => () => (t, n) => {
|
|
563
|
+
if (!N(t))
|
|
565
564
|
return !1;
|
|
566
|
-
if (
|
|
567
|
-
const
|
|
568
|
-
|
|
565
|
+
if (n) {
|
|
566
|
+
const o = le(t);
|
|
567
|
+
n(ae(e, t.tr, o, o.bottom));
|
|
569
568
|
}
|
|
570
569
|
return !0;
|
|
571
570
|
});
|
|
@@ -582,21 +581,21 @@ const G = ee("tableKeymap", {
|
|
|
582
581
|
NextCell: {
|
|
583
582
|
shortcuts: ["Mod-]", "Tab"],
|
|
584
583
|
command: (e) => {
|
|
585
|
-
const t = e.get(
|
|
584
|
+
const t = e.get(A);
|
|
586
585
|
return () => t.call(W.key);
|
|
587
586
|
}
|
|
588
587
|
},
|
|
589
588
|
PrevCell: {
|
|
590
589
|
shortcuts: ["Mod-[", "Shift-Tab"],
|
|
591
590
|
command: (e) => {
|
|
592
|
-
const t = e.get(
|
|
591
|
+
const t = e.get(A);
|
|
593
592
|
return () => t.call(F.key);
|
|
594
593
|
}
|
|
595
594
|
},
|
|
596
595
|
ExitTable: {
|
|
597
596
|
shortcuts: ["Mod-Enter"],
|
|
598
597
|
command: (e) => {
|
|
599
|
-
const t = e.get(
|
|
598
|
+
const t = e.get(A);
|
|
600
599
|
return () => t.call(z.key);
|
|
601
600
|
}
|
|
602
601
|
}
|
|
@@ -773,8 +772,8 @@ const Se = Ie.extendSchema((e) => (t) => {
|
|
|
773
772
|
n.parseMarkdown.runner(o, l, r);
|
|
774
773
|
return;
|
|
775
774
|
}
|
|
776
|
-
const
|
|
777
|
-
o.openNode(r, { label:
|
|
775
|
+
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";
|
|
776
|
+
o.openNode(r, { label: s, listType: i, spread: m, checked: c }), o.next(l.children), o.closeNode();
|
|
778
777
|
}
|
|
779
778
|
},
|
|
780
779
|
toMarkdown: {
|
|
@@ -784,8 +783,8 @@ const Se = Ie.extendSchema((e) => (t) => {
|
|
|
784
783
|
n.toMarkdown.runner(o, l);
|
|
785
784
|
return;
|
|
786
785
|
}
|
|
787
|
-
const r = l.attrs.label,
|
|
788
|
-
o.openNode("listItem", void 0, { label: r, listType:
|
|
786
|
+
const r = l.attrs.label, s = l.attrs.listType, c = l.attrs.spread === "true", i = l.attrs.checked;
|
|
787
|
+
o.openNode("listItem", void 0, { label: r, listType: s, spread: c, checked: i }), o.next(l.content), o.closeNode();
|
|
789
788
|
}
|
|
790
789
|
}
|
|
791
790
|
};
|
|
@@ -795,15 +794,15 @@ d(Se, {
|
|
|
795
794
|
group: "ListItem"
|
|
796
795
|
});
|
|
797
796
|
const Re = te(() => new Y(/^\[(?<checked>\s|x)\]\s$/, (e, t, n, o) => {
|
|
798
|
-
var
|
|
797
|
+
var a;
|
|
799
798
|
const l = e.doc.resolve(n);
|
|
800
|
-
let r = 0,
|
|
801
|
-
for (;
|
|
802
|
-
r--,
|
|
803
|
-
if (!
|
|
799
|
+
let r = 0, s = l.node(r);
|
|
800
|
+
for (; s && s.type.name !== "list_item"; )
|
|
801
|
+
r--, s = l.node(r);
|
|
802
|
+
if (!s || s.attrs.checked != null)
|
|
804
803
|
return null;
|
|
805
|
-
const
|
|
806
|
-
return m.deleteRange(n, o).setNodeMarkup(
|
|
804
|
+
const c = ((a = t.groups) == null ? void 0 : a.checked) === "x", i = l.before(r), m = e.tr;
|
|
805
|
+
return m.deleteRange(n, o).setNodeMarkup(i, void 0, { ...s.attrs, checked: c }), m;
|
|
807
806
|
}));
|
|
808
807
|
d(Re, {
|
|
809
808
|
displayName: "InputRule<wrapInTaskListInputRule>",
|
|
@@ -815,30 +814,30 @@ const nt = [
|
|
|
815
814
|
].flat(), lt = [
|
|
816
815
|
me,
|
|
817
816
|
Re
|
|
818
|
-
],
|
|
819
|
-
const
|
|
817
|
+
], Ae = B((e) => {
|
|
818
|
+
const t = new De("MILKDOWN_AUTO_INSERT_ZERO_SPACE"), n = (l) => l.type === Q.type(e), o = (l) => n(l) && l.nodeSize === 2;
|
|
820
819
|
return new Oe({
|
|
821
|
-
key:
|
|
820
|
+
key: t,
|
|
822
821
|
props: {
|
|
823
822
|
handleDOMEvents: {
|
|
824
|
-
compositionstart(
|
|
825
|
-
const { state:
|
|
826
|
-
return V.safari && N(
|
|
823
|
+
compositionstart(l) {
|
|
824
|
+
const { state: r, dispatch: s } = l, { tr: c, selection: i } = r, { $from: m } = i;
|
|
825
|
+
return V.safari && N(r) && i.empty && o(m.parent) && s(c.insertText("", m.start())), !1;
|
|
827
826
|
},
|
|
828
|
-
compositionend(
|
|
829
|
-
const { state:
|
|
830
|
-
return V.safari && N(
|
|
827
|
+
compositionend(l) {
|
|
828
|
+
const { state: r, dispatch: s } = l, { tr: c, selection: i } = r, { $from: m } = i;
|
|
829
|
+
return V.safari && N(r) && i.empty && n(m.parent) && m.parent.textContent.startsWith("") && s(c.delete(m.start(), m.start() + 1)), !1;
|
|
831
830
|
}
|
|
832
831
|
}
|
|
833
832
|
}
|
|
834
833
|
});
|
|
835
834
|
});
|
|
836
|
-
d(
|
|
835
|
+
d(Ae, {
|
|
837
836
|
displayName: "Prose<autoInsertZeroSpaceInTablePlugin>",
|
|
838
837
|
group: "Prose"
|
|
839
838
|
});
|
|
840
|
-
const
|
|
841
|
-
d(
|
|
839
|
+
const Me = B(() => Ge({}));
|
|
840
|
+
d(Me, {
|
|
842
841
|
displayName: "Prose<columnResizingPlugin>",
|
|
843
842
|
group: "Prose"
|
|
844
843
|
});
|
|
@@ -853,8 +852,8 @@ d(ve, {
|
|
|
853
852
|
group: "Remark"
|
|
854
853
|
});
|
|
855
854
|
const rt = [
|
|
856
|
-
Me,
|
|
857
855
|
Ae,
|
|
856
|
+
Me,
|
|
858
857
|
xe,
|
|
859
858
|
ve
|
|
860
859
|
], at = [
|
|
@@ -884,7 +883,7 @@ const rt = [
|
|
|
884
883
|
ke,
|
|
885
884
|
Te,
|
|
886
885
|
H
|
|
887
|
-
],
|
|
886
|
+
], Ct = [at, lt, nt, rt, st].flat();
|
|
888
887
|
export {
|
|
889
888
|
ke as addColAfterCommand,
|
|
890
889
|
ye as addColBeforeCommand,
|
|
@@ -902,7 +901,7 @@ export {
|
|
|
902
901
|
Xe as getAllCellsInTable,
|
|
903
902
|
b as getCellsInCol,
|
|
904
903
|
C as getCellsInRow,
|
|
905
|
-
|
|
904
|
+
Ct as gfm,
|
|
906
905
|
W as goToNextTableCellCommand,
|
|
907
906
|
F as goToPrevTableCellCommand,
|
|
908
907
|
lt as inputrules,
|