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