@milkdown/preset-gfm 6.5.4 → 7.0.0-next.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.
- package/lib/composed/commands.d.ts +8 -0
- package/lib/composed/commands.d.ts.map +1 -0
- package/lib/composed/index.d.ts +6 -0
- package/lib/composed/index.d.ts.map +1 -0
- package/lib/composed/inputrules.d.ts +3 -0
- package/lib/composed/inputrules.d.ts.map +1 -0
- package/lib/composed/keymap.d.ts +3 -0
- package/lib/composed/keymap.d.ts.map +1 -0
- package/lib/composed/plugins.d.ts +3 -0
- package/lib/composed/plugins.d.ts.map +1 -0
- package/lib/composed/schema.d.ts +3 -0
- package/lib/composed/schema.d.ts.map +1 -0
- package/lib/index.d.ts +4 -34
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +633 -2328
- package/lib/index.es.js.map +1 -1
- package/lib/mark/index.d.ts +2 -0
- package/lib/mark/index.d.ts.map +1 -0
- package/lib/mark/strike-through.d.ts +4 -0
- package/lib/mark/strike-through.d.ts.map +1 -0
- package/lib/node/footnote/definition.d.ts +2 -0
- package/lib/node/footnote/definition.d.ts.map +1 -0
- package/lib/{footnote → node/footnote}/index.d.ts +0 -0
- package/lib/node/footnote/index.d.ts.map +1 -0
- package/lib/node/footnote/reference.d.ts +2 -0
- package/lib/node/footnote/reference.d.ts.map +1 -0
- package/lib/node/index.d.ts +4 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/table/index.d.ts +32 -0
- package/lib/node/table/index.d.ts.map +1 -0
- package/lib/node/table/utils.d.ts +27 -0
- package/lib/node/table/utils.d.ts.map +1 -0
- package/lib/node/task-list-item.d.ts +2 -0
- package/lib/node/task-list-item.d.ts.map +1 -0
- package/lib/plugin/auto-insert-zero-space-plugin.d.ts +2 -0
- package/lib/plugin/auto-insert-zero-space-plugin.d.ts.map +1 -0
- package/lib/plugin/column-resizing-plugin.d.ts +2 -0
- package/lib/plugin/column-resizing-plugin.d.ts.map +1 -0
- package/lib/plugin/index.d.ts +5 -0
- package/lib/plugin/index.d.ts.map +1 -0
- package/lib/plugin/remark-gfm-plugin.d.ts +2 -0
- package/lib/plugin/remark-gfm-plugin.d.ts.map +1 -0
- package/lib/plugin/table-editing-plugin.d.ts +2 -0
- package/lib/plugin/table-editing-plugin.d.ts.map +1 -0
- package/package.json +13 -10
- package/src/composed/commands.ts +23 -0
- package/src/composed/index.ts +6 -0
- package/src/composed/inputrules.ts +7 -0
- package/src/composed/keymap.ts +9 -0
- package/src/composed/plugins.ts +10 -0
- package/src/composed/schema.ts +18 -0
- package/src/index.ts +5 -89
- package/src/mark/index.ts +2 -0
- package/src/mark/strike-through.ts +39 -0
- package/src/node/footnote/definition.ts +68 -0
- package/src/{footnote → node/footnote}/index.ts +0 -0
- package/src/node/footnote/reference.ts +58 -0
- package/src/node/index.ts +4 -0
- package/src/node/table/index.ts +283 -0
- package/src/node/table/utils.ts +489 -0
- package/src/node/task-list-item.ts +87 -0
- package/src/{table/plugin/auto-insert-zero-space.ts → plugin/auto-insert-zero-space-plugin.ts} +13 -15
- package/src/plugin/column-resizing-plugin.ts +4 -0
- package/src/plugin/index.ts +5 -0
- package/src/plugin/remark-gfm-plugin.ts +5 -0
- package/src/plugin/table-editing-plugin.ts +4 -0
- package/lib/footnote/definition.d.ts +0 -3
- package/lib/footnote/definition.d.ts.map +0 -1
- package/lib/footnote/index.d.ts.map +0 -1
- package/lib/footnote/reference.d.ts +0 -3
- package/lib/footnote/reference.d.ts.map +0 -1
- package/lib/footnote/utils.d.ts +0 -3
- package/lib/footnote/utils.d.ts.map +0 -1
- package/lib/strike-through.d.ts +0 -3
- package/lib/strike-through.d.ts.map +0 -1
- package/lib/supported-keys.d.ts +0 -28
- package/lib/supported-keys.d.ts.map +0 -1
- package/lib/table/command.d.ts +0 -4
- package/lib/table/command.d.ts.map +0 -1
- package/lib/table/index.d.ts +0 -10
- package/lib/table/index.d.ts.map +0 -1
- package/lib/table/nodes/index.d.ts +0 -12
- package/lib/table/nodes/index.d.ts.map +0 -1
- package/lib/table/operator-plugin/actions.d.ts +0 -20
- package/lib/table/operator-plugin/actions.d.ts.map +0 -1
- package/lib/table/operator-plugin/calc-pos.d.ts +0 -3
- package/lib/table/operator-plugin/calc-pos.d.ts.map +0 -1
- package/lib/table/operator-plugin/constant.d.ts +0 -6
- package/lib/table/operator-plugin/constant.d.ts.map +0 -1
- package/lib/table/operator-plugin/helper.d.ts +0 -7
- package/lib/table/operator-plugin/helper.d.ts.map +0 -1
- package/lib/table/operator-plugin/index.d.ts +0 -6
- package/lib/table/operator-plugin/index.d.ts.map +0 -1
- package/lib/table/operator-plugin/style.d.ts +0 -3
- package/lib/table/operator-plugin/style.d.ts.map +0 -1
- package/lib/table/operator-plugin/widget.d.ts +0 -8
- package/lib/table/operator-plugin/widget.d.ts.map +0 -1
- package/lib/table/plugin/auto-insert-zero-space.d.ts +0 -3
- package/lib/table/plugin/auto-insert-zero-space.d.ts.map +0 -1
- package/lib/table/plugin/cell-selection.d.ts +0 -40
- package/lib/table/plugin/cell-selection.d.ts.map +0 -1
- package/lib/table/plugin/column-resizing.d.ts +0 -18
- package/lib/table/plugin/column-resizing.d.ts.map +0 -1
- package/lib/table/plugin/commands.d.ts +0 -30
- package/lib/table/plugin/commands.d.ts.map +0 -1
- package/lib/table/plugin/copy-paste.d.ts +0 -14
- package/lib/table/plugin/copy-paste.d.ts.map +0 -1
- package/lib/table/plugin/fix-tables.d.ts +0 -7
- package/lib/table/plugin/fix-tables.d.ts.map +0 -1
- package/lib/table/plugin/index.d.ts +0 -4
- package/lib/table/plugin/index.d.ts.map +0 -1
- package/lib/table/plugin/schema.d.ts +0 -4
- package/lib/table/plugin/schema.d.ts.map +0 -1
- package/lib/table/plugin/table-editing.d.ts +0 -9
- package/lib/table/plugin/table-editing.d.ts.map +0 -1
- package/lib/table/plugin/table-map.d.ts +0 -44
- package/lib/table/plugin/table-map.d.ts.map +0 -1
- package/lib/table/plugin/table-view.d.ts +0 -15
- package/lib/table/plugin/table-view.d.ts.map +0 -1
- package/lib/table/plugin/types.d.ts +0 -15
- package/lib/table/plugin/types.d.ts.map +0 -1
- package/lib/table/plugin/util.d.ts +0 -16
- package/lib/table/plugin/util.d.ts.map +0 -1
- package/lib/table/utils.d.ts +0 -21
- package/lib/table/utils.d.ts.map +0 -1
- package/lib/task-list-item.d.ts +0 -9
- package/lib/task-list-item.d.ts.map +0 -1
- package/src/footnote/definition.ts +0 -187
- package/src/footnote/reference.ts +0 -178
- package/src/footnote/utils.ts +0 -4
- package/src/strike-through.ts +0 -43
- package/src/supported-keys.ts +0 -13
- package/src/table/command.ts +0 -20
- package/src/table/index.ts +0 -13
- package/src/table/nodes/index.ts +0 -189
- package/src/table/operator-plugin/actions.ts +0 -116
- package/src/table/operator-plugin/calc-pos.ts +0 -36
- package/src/table/operator-plugin/constant.ts +0 -7
- package/src/table/operator-plugin/helper.ts +0 -39
- package/src/table/operator-plugin/index.ts +0 -110
- package/src/table/operator-plugin/style.ts +0 -123
- package/src/table/operator-plugin/widget.ts +0 -57
- package/src/table/plugin/cell-selection.ts +0 -381
- package/src/table/plugin/column-resizing.ts +0 -288
- package/src/table/plugin/commands.ts +0 -594
- package/src/table/plugin/copy-paste.ts +0 -322
- package/src/table/plugin/fix-tables.ts +0 -132
- package/src/table/plugin/index.ts +0 -4
- package/src/table/plugin/schema.ts +0 -120
- package/src/table/plugin/table-editing.ts +0 -369
- package/src/table/plugin/table-map.ts +0 -345
- package/src/table/plugin/table-view.ts +0 -80
- package/src/table/plugin/types.ts +0 -16
- package/src/table/plugin/util.ts +0 -119
- package/src/table/utils.ts +0 -165
- package/src/task-list-item.ts +0 -159
package/lib/index.es.js
CHANGED
|
@@ -1,2410 +1,715 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
id: e,
|
|
23
|
-
schema: (n) => ({
|
|
24
|
-
group: "block",
|
|
25
|
-
content: "block+",
|
|
26
|
-
defining: !0,
|
|
27
|
-
attrs: {
|
|
28
|
-
label: {
|
|
29
|
-
default: ""
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
parseDOM: [
|
|
33
|
-
{
|
|
34
|
-
tag: `div[data-type="${e}"]`,
|
|
35
|
-
getAttrs: (s) => {
|
|
36
|
-
if (!(s instanceof HTMLElement))
|
|
37
|
-
throw Ae(s);
|
|
38
|
-
return {
|
|
39
|
-
label: s.dataset.label
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
contentElement: "dd"
|
|
43
|
-
}
|
|
44
|
-
],
|
|
45
|
-
toDOM: (s) => {
|
|
46
|
-
const l = s.attrs.label, r = o.getClassName(s.attrs, "footnote-definition"), a = document.createElement("dt");
|
|
47
|
-
a.textContent = `[${l}]:`, a.onclick = () => {
|
|
48
|
-
const c = n.get(U), d = oe.create(c.state.doc, c.state.selection.from - 2);
|
|
49
|
-
c.dispatch(c.state.tr.setSelection(d));
|
|
50
|
-
};
|
|
51
|
-
const i = document.createElement("a");
|
|
52
|
-
return i.href = `#${Ye(l)}`, i.contentEditable = "false", i.textContent = "\u21A9", i.onmousedown = (c) => {
|
|
53
|
-
c.preventDefault();
|
|
54
|
-
}, [
|
|
55
|
-
"div",
|
|
56
|
-
{
|
|
57
|
-
class: r,
|
|
58
|
-
"data-label": l,
|
|
59
|
-
"data-type": e,
|
|
60
|
-
id: Ze(l)
|
|
61
|
-
},
|
|
62
|
-
["div", { class: "footnote-definition_content" }, a, ["dd", 0]],
|
|
63
|
-
["div", { class: "footnote-definition_anchor" }, i]
|
|
64
|
-
];
|
|
65
|
-
},
|
|
66
|
-
parseMarkdown: {
|
|
67
|
-
match: ({ type: s }) => s === t,
|
|
68
|
-
runner: (s, l, r) => {
|
|
69
|
-
s.openNode(r, {
|
|
70
|
-
label: l.label
|
|
71
|
-
}).next(l.children).closeNode();
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
toMarkdown: {
|
|
75
|
-
match: (s) => s.type.name === e,
|
|
76
|
-
runner: (s, l) => {
|
|
77
|
-
s.openNode(t, void 0, {
|
|
78
|
-
label: l.attrs.label,
|
|
79
|
-
identifier: l.attrs.label
|
|
80
|
-
}).next(l.content).closeNode();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}),
|
|
84
|
-
commands: (n) => [
|
|
85
|
-
N(ve, (s = "") => (l, r) => {
|
|
86
|
-
const a = W(l.selection, n);
|
|
87
|
-
if (!a)
|
|
88
|
-
return !1;
|
|
89
|
-
const { tr: i } = l, c = i.setNodeMarkup(a.pos, void 0, { ...a.node.attrs, label: s });
|
|
90
|
-
return r == null || r(c.setSelection(oe.create(c.doc, a.pos))), !0;
|
|
91
|
-
})
|
|
92
|
-
],
|
|
93
|
-
inputRules: (n) => [
|
|
94
|
-
Je(
|
|
95
|
-
/(?:\[\^)([^:]+)(?::)$/,
|
|
96
|
-
n,
|
|
97
|
-
(s) => {
|
|
98
|
-
var r;
|
|
99
|
-
return {
|
|
100
|
-
label: (r = s[1]) != null ? r : "footnote"
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
|
-
() => !1
|
|
104
|
-
)
|
|
105
|
-
],
|
|
106
|
-
prosePlugins: (n, s) => [
|
|
107
|
-
new H({
|
|
108
|
-
key: Lt,
|
|
109
|
-
view: (l) => {
|
|
110
|
-
const r = o.themeManager.get("input-chip", {
|
|
111
|
-
width: "12em",
|
|
112
|
-
placeholder: "Input Footnote Label",
|
|
113
|
-
onUpdate: (d) => {
|
|
114
|
-
s.get(Ve).call(ve, d);
|
|
115
|
-
},
|
|
116
|
-
isBindMode: !0
|
|
117
|
-
});
|
|
118
|
-
if (!r)
|
|
119
|
-
return {};
|
|
120
|
-
const a = (d) => Boolean(n && W(d.state.selection, n)), i = (d) => {
|
|
121
|
-
const f = W(d.state.selection, n);
|
|
122
|
-
return f ? f.node.attrs.label : void 0;
|
|
123
|
-
}, c = (d) => {
|
|
124
|
-
if (!d.editable)
|
|
125
|
-
return;
|
|
126
|
-
a(d) ? (r.show(d), r.update(i(d))) : r.hide();
|
|
127
|
-
};
|
|
128
|
-
return r.init(l), c(l), {
|
|
129
|
-
update: (d, f) => {
|
|
130
|
-
(f == null ? void 0 : f.doc.eq(d.state.doc)) && f.selection.eq(d.state.selection) || c(d);
|
|
131
|
-
},
|
|
132
|
-
destroy: () => {
|
|
133
|
-
r.destroy();
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
]
|
|
139
|
-
};
|
|
140
|
-
}), Ee = R("ModifyFootnoteRef"), Et = new B("MILKDOWN_FOOTNOTE_REF_INPUT"), $t = ke((o) => {
|
|
141
|
-
const e = "footnote_reference";
|
|
142
|
-
return {
|
|
143
|
-
id: e,
|
|
144
|
-
schema: (t) => ({
|
|
145
|
-
group: "inline",
|
|
146
|
-
inline: !0,
|
|
147
|
-
atom: !0,
|
|
148
|
-
attrs: {
|
|
149
|
-
label: {
|
|
150
|
-
default: ""
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
parseDOM: [
|
|
154
|
-
{
|
|
155
|
-
tag: `sup[data-type="${e}"]`,
|
|
156
|
-
getAttrs: (n) => {
|
|
157
|
-
if (!(n instanceof HTMLElement))
|
|
158
|
-
throw Ae(n);
|
|
159
|
-
return {
|
|
160
|
-
label: n.dataset.label
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
],
|
|
165
|
-
toDOM: (n) => {
|
|
166
|
-
const s = n.attrs.label, l = document.createElement("a"), r = `#${Ze(s)}`;
|
|
167
|
-
return l.href = r, l.textContent = `[${s}]`, l.onclick = (a) => {
|
|
168
|
-
t.get(U).editable && a.preventDefault();
|
|
169
|
-
}, l.ondblclick = () => {
|
|
170
|
-
t.get(U).editable && (window.location.href = r);
|
|
171
|
-
}, [
|
|
172
|
-
"sup",
|
|
173
|
-
{
|
|
174
|
-
"data-label": s,
|
|
175
|
-
"data-type": e,
|
|
176
|
-
id: Ye(s)
|
|
177
|
-
},
|
|
178
|
-
l
|
|
179
|
-
];
|
|
180
|
-
},
|
|
181
|
-
parseMarkdown: {
|
|
182
|
-
match: ({ type: n }) => n === "footnoteReference",
|
|
183
|
-
runner: (n, s, l) => {
|
|
184
|
-
n.addNode(l, {
|
|
185
|
-
label: s.label
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
toMarkdown: {
|
|
190
|
-
match: (n) => n.type.name === e,
|
|
191
|
-
runner: (n, s) => {
|
|
192
|
-
n.addNode("footnoteReference", void 0, void 0, {
|
|
193
|
-
label: s.attrs.label,
|
|
194
|
-
identifier: s.attrs.label
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}),
|
|
199
|
-
commands: (t) => [
|
|
200
|
-
N(Ee, (n = "") => (s, l) => {
|
|
201
|
-
const r = W(s.selection, t);
|
|
202
|
-
if (!r)
|
|
203
|
-
return !1;
|
|
204
|
-
const { tr: a } = s, i = a.setNodeMarkup(r.pos, void 0, { ...r.node.attrs, label: n });
|
|
205
|
-
return l == null || l(i.setSelection(oe.create(i.doc, r.pos))), !0;
|
|
206
|
-
})
|
|
207
|
-
],
|
|
208
|
-
inputRules: (t) => [
|
|
209
|
-
new ue(/(?:\[\^)([^\]]+)(?:\])$/, (n, s, l, r) => {
|
|
210
|
-
const a = n.doc.resolve(l), i = a.index(), c = n.doc.resolve(r);
|
|
211
|
-
if (!a.parent.canReplaceWith(i, c.index(), t))
|
|
212
|
-
return null;
|
|
213
|
-
const d = s[1];
|
|
214
|
-
return n.tr.replaceRangeWith(
|
|
215
|
-
l,
|
|
216
|
-
r,
|
|
217
|
-
t.create({
|
|
218
|
-
label: d
|
|
219
|
-
})
|
|
220
|
-
);
|
|
221
|
-
})
|
|
222
|
-
],
|
|
223
|
-
prosePlugins: (t, n) => {
|
|
224
|
-
const s = o.themeManager.get("input-chip", {
|
|
225
|
-
width: "12em",
|
|
226
|
-
placeholder: "Input Footnote Label",
|
|
227
|
-
onUpdate: (i) => {
|
|
228
|
-
n.get(Ve).call(Ee, i);
|
|
229
|
-
},
|
|
230
|
-
isBindMode: !0
|
|
231
|
-
});
|
|
232
|
-
if (!s)
|
|
233
|
-
return [];
|
|
234
|
-
const l = (i) => Boolean(t && W(i.state.selection, t)), r = (i) => {
|
|
235
|
-
const c = W(i.state.selection, t);
|
|
236
|
-
return c ? c.node.attrs.label : void 0;
|
|
237
|
-
}, a = (i) => {
|
|
238
|
-
if (!i.editable)
|
|
239
|
-
return;
|
|
240
|
-
l(i) ? (s.show(i), s.update(r(i))) : s.hide();
|
|
241
|
-
};
|
|
242
|
-
return [
|
|
243
|
-
new H({
|
|
244
|
-
key: Et,
|
|
245
|
-
view: (i) => (s.init(i), a(i), {
|
|
246
|
-
update: (c, d) => {
|
|
247
|
-
(d == null ? void 0 : d.doc.eq(c.state.doc)) && d.selection.eq(c.state.selection) || a(c);
|
|
248
|
-
},
|
|
249
|
-
destroy: () => {
|
|
250
|
-
s.destroy();
|
|
251
|
-
}
|
|
252
|
-
})
|
|
253
|
-
})
|
|
254
|
-
];
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
}), Qe = /* @__PURE__ */ new WeakMap(), It = (o) => Qe.get(o), Dt = (o, e) => (Qe.set(o, e), e);
|
|
258
|
-
class $e {
|
|
259
|
-
constructor(e, t, n, s) {
|
|
260
|
-
I(this, "tableStart");
|
|
261
|
-
I(this, "map");
|
|
262
|
-
I(this, "table");
|
|
263
|
-
this.left = e, this.top = t, this.right = n, this.bottom = s;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
class g {
|
|
267
|
-
constructor(e, t, n, s) {
|
|
268
|
-
this.width = e, this.height = t, this.map = n, this.problems = s, this.width = e, this.height = t, this.map = n, this.problems = s;
|
|
269
|
-
}
|
|
270
|
-
findCell(e) {
|
|
271
|
-
for (let t = 0; t < this.map.length; t++) {
|
|
272
|
-
const n = this.map[t];
|
|
273
|
-
if (n != e)
|
|
274
|
-
continue;
|
|
275
|
-
const s = t % this.width, l = t / this.width | 0;
|
|
276
|
-
let r = s + 1, a = l + 1;
|
|
277
|
-
for (let i = 1; r < this.width && this.map[t + i] == n; i++)
|
|
278
|
-
r++;
|
|
279
|
-
for (let i = 1; a < this.height && this.map[t + this.width * i] == n; i++)
|
|
280
|
-
a++;
|
|
281
|
-
return new $e(s, l, r, a);
|
|
282
|
-
}
|
|
283
|
-
throw new RangeError(`No cell with offset ${e} found`);
|
|
284
|
-
}
|
|
285
|
-
colCount(e) {
|
|
286
|
-
for (let t = 0; t < this.map.length; t++)
|
|
287
|
-
if (this.map[t] == e)
|
|
288
|
-
return t % this.width;
|
|
289
|
-
throw new RangeError(`No cell with offset ${e} found`);
|
|
290
|
-
}
|
|
291
|
-
nextCell(e, t, n) {
|
|
292
|
-
const { left: s, right: l, top: r, bottom: a } = this.findCell(e);
|
|
293
|
-
return t == "horiz" ? (n < 0 ? s == 0 : l == this.width) ? void 0 : this.map[r * this.width + (n < 0 ? s - 1 : l)] : (n < 0 ? r == 0 : a == this.height) ? void 0 : this.map[s + this.width * (n < 0 ? r - 1 : a)];
|
|
294
|
-
}
|
|
295
|
-
rectBetween(e, t) {
|
|
296
|
-
const {
|
|
297
|
-
left: n,
|
|
298
|
-
right: s,
|
|
299
|
-
top: l,
|
|
300
|
-
bottom: r
|
|
301
|
-
} = this.findCell(e), {
|
|
302
|
-
left: a,
|
|
303
|
-
right: i,
|
|
304
|
-
top: c,
|
|
305
|
-
bottom: d
|
|
306
|
-
} = this.findCell(t);
|
|
307
|
-
return new $e(
|
|
308
|
-
Math.min(n, a),
|
|
309
|
-
Math.min(l, c),
|
|
310
|
-
Math.max(s, i),
|
|
311
|
-
Math.max(r, d)
|
|
312
|
-
);
|
|
313
|
-
}
|
|
314
|
-
cellsInRect(e) {
|
|
315
|
-
const t = [], n = {};
|
|
316
|
-
for (let s = e.top; s < e.bottom; s++)
|
|
317
|
-
for (let l = e.left; l < e.right; l++) {
|
|
318
|
-
const r = s * this.width + l, a = this.map[r];
|
|
319
|
-
n[a] || (n[a] = !0, (l != e.left || !l || this.map[r - 1] != a) && (s != e.top || !s || this.map[r - this.width] != a) && t.push(a));
|
|
320
|
-
}
|
|
321
|
-
return t;
|
|
322
|
-
}
|
|
323
|
-
positionAt(e, t, n) {
|
|
324
|
-
for (let s = 0, l = 0; ; s++) {
|
|
325
|
-
const r = l + n.child(s).nodeSize;
|
|
326
|
-
if (s == e) {
|
|
327
|
-
let a = t + e * this.width;
|
|
328
|
-
const i = (e + 1) * this.width;
|
|
329
|
-
for (; a < i && this.map[a] < l; )
|
|
330
|
-
a++;
|
|
331
|
-
return a == i ? r - 1 : this.map[a];
|
|
332
|
-
}
|
|
333
|
-
l = r;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
static get(e) {
|
|
337
|
-
return It(e) || Dt(e, Ot(e));
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
function Ot(o) {
|
|
341
|
-
if (o.type.spec.tableRole != "table")
|
|
342
|
-
throw new RangeError(`Not a table node: ${o.type.name}`);
|
|
343
|
-
const e = _t(o), t = o.childCount, n = [], s = [];
|
|
344
|
-
let l = 0, r;
|
|
345
|
-
for (let c = 0, d = e * t; c < d; c++)
|
|
346
|
-
n[c] = 0;
|
|
347
|
-
for (let c = 0, d = 0; c < t; c++) {
|
|
348
|
-
const f = o.child(c);
|
|
349
|
-
d++;
|
|
350
|
-
for (let h = 0; ; h++) {
|
|
351
|
-
for (; l < n.length && n[l] != 0; )
|
|
352
|
-
l++;
|
|
353
|
-
if (h == f.childCount)
|
|
354
|
-
break;
|
|
355
|
-
const b = f.child(h), { colspan: w, rowspan: C, colwidth: Re } = b.attrs;
|
|
356
|
-
for (let j = 0; j < C; j++) {
|
|
357
|
-
if (j + c >= t) {
|
|
358
|
-
(r || (r = [])).push({
|
|
359
|
-
type: "overlong_rowspan",
|
|
360
|
-
pos: d,
|
|
361
|
-
n: C - j
|
|
362
|
-
});
|
|
363
|
-
break;
|
|
364
|
-
}
|
|
365
|
-
const re = l + j * e;
|
|
366
|
-
for (let z = 0; z < w; z++) {
|
|
367
|
-
n[re + z] == 0 ? n[re + z] = d : (r || (r = [])).push({
|
|
368
|
-
type: "collision",
|
|
369
|
-
row: c,
|
|
370
|
-
pos: d,
|
|
371
|
-
n: w - z
|
|
372
|
-
});
|
|
373
|
-
const G = Re && Re[z];
|
|
374
|
-
if (G) {
|
|
375
|
-
const K = (re + z) % e * 2, ie = s[K];
|
|
376
|
-
ie == null || ie != G && s[K + 1] == 1 ? (s[K] = G, s[K + 1] = 1) : ie == G && s[K + 1]++;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
l += w, d += b.nodeSize;
|
|
381
|
-
}
|
|
382
|
-
const u = (c + 1) * e;
|
|
383
|
-
let p = 0;
|
|
384
|
-
for (; l < u; )
|
|
385
|
-
n[l++] == 0 && p++;
|
|
386
|
-
p && (r || (r = [])).push({ type: "missing", row: c, n: p }), d++;
|
|
387
|
-
}
|
|
388
|
-
const a = new g(e, t, n, r);
|
|
389
|
-
let i = !1;
|
|
390
|
-
for (let c = 0; !i && c < s.length; c += 2)
|
|
391
|
-
s[c] != null && s[c + 1] < t && (i = !0);
|
|
392
|
-
return i && zt(a, s, o), a;
|
|
393
|
-
}
|
|
394
|
-
function _t(o) {
|
|
395
|
-
let e = -1, t = !1;
|
|
396
|
-
for (let n = 0; n < o.childCount; n++) {
|
|
397
|
-
const s = o.child(n);
|
|
398
|
-
let l = 0;
|
|
399
|
-
if (t)
|
|
400
|
-
for (let r = 0; r < n; r++) {
|
|
401
|
-
const a = o.child(r);
|
|
402
|
-
for (let i = 0; i < a.childCount; i++) {
|
|
403
|
-
const c = a.child(i);
|
|
404
|
-
r + c.attrs.rowspan > n && (l += c.attrs.colspan);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
for (let r = 0; r < s.childCount; r++) {
|
|
408
|
-
const a = s.child(r);
|
|
409
|
-
l += a.attrs.colspan, a.attrs.rowspan > 1 && (t = !0);
|
|
410
|
-
}
|
|
411
|
-
e == -1 ? e = l : e != l && (e = Math.max(e, l));
|
|
412
|
-
}
|
|
413
|
-
return e;
|
|
414
|
-
}
|
|
415
|
-
function zt(o, e, t) {
|
|
416
|
-
o.problems || (o.problems = []);
|
|
417
|
-
for (let n = 0, s = {}; n < o.map.length; n++) {
|
|
418
|
-
const l = o.map[n];
|
|
419
|
-
if (s[l])
|
|
420
|
-
continue;
|
|
421
|
-
s[l] = !0;
|
|
422
|
-
const r = t.nodeAt(l);
|
|
423
|
-
let a = null;
|
|
424
|
-
for (let i = 0; i < r.attrs.colspan; i++) {
|
|
425
|
-
const c = (n + i) % o.width, d = e[c * 2];
|
|
426
|
-
d != null && (!r.attrs.colwidth || r.attrs.colwidth[i] != d) && ((a || (a = Ft(r.attrs)))[i] = d);
|
|
427
|
-
}
|
|
428
|
-
a && o.problems.unshift({
|
|
429
|
-
type: "colwidth mismatch",
|
|
430
|
-
pos: l,
|
|
431
|
-
colwidth: a
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
function Ft(o) {
|
|
436
|
-
if (o.colwidth)
|
|
437
|
-
return o.colwidth.slice();
|
|
438
|
-
const e = [];
|
|
439
|
-
for (let t = 0; t < o.colspan; t++)
|
|
440
|
-
e.push(0);
|
|
441
|
-
return e;
|
|
442
|
-
}
|
|
443
|
-
class m extends S {
|
|
444
|
-
constructor(e, t = e) {
|
|
445
|
-
const n = e.node(-1), s = g.get(n), l = e.start(-1), r = s.rectBetween(e.pos - l, t.pos - l), a = e.node(0), i = s.cellsInRect(r).filter((d) => d != t.pos - l);
|
|
446
|
-
i.unshift(t.pos - l);
|
|
447
|
-
const c = i.map((d) => {
|
|
448
|
-
const f = n.nodeAt(d), u = d + l + 1;
|
|
449
|
-
return new kt(a.resolve(u), a.resolve(u + f.content.size));
|
|
450
|
-
});
|
|
451
|
-
super(c[0].$from, c[0].$to, c), this.$anchorCell = e, this.$headCell = t, this.$anchorCell = e, this.$headCell = t;
|
|
452
|
-
}
|
|
453
|
-
map(e, t) {
|
|
454
|
-
const n = e.resolve(t.map(this.$anchorCell.pos)), s = e.resolve(t.map(this.$headCell.pos));
|
|
455
|
-
if (pe(n) && pe(s) && xe(n, s)) {
|
|
456
|
-
const l = this.$anchorCell.node(-1) != n.node(-1);
|
|
457
|
-
return l && this.isRowSelection() ? m.rowSelection(n, s) : l && this.isColSelection() ? m.colSelection(n, s) : new m(n, s);
|
|
458
|
-
}
|
|
459
|
-
return E.between(n, s);
|
|
460
|
-
}
|
|
461
|
-
content() {
|
|
462
|
-
const e = this.$anchorCell.node(-1), t = g.get(e), n = this.$anchorCell.start(-1), s = t.rectBetween(this.$anchorCell.pos - n, this.$headCell.pos - n), l = {}, r = [];
|
|
463
|
-
for (let i = s.top; i < s.bottom; i++) {
|
|
464
|
-
const c = [];
|
|
465
|
-
for (let d = i * t.width + s.left, f = s.left; f < s.right; f++, d++) {
|
|
466
|
-
const u = t.map[d];
|
|
467
|
-
if (!l[u]) {
|
|
468
|
-
l[u] = !0;
|
|
469
|
-
const p = t.findCell(u);
|
|
470
|
-
let h = e.nodeAt(u);
|
|
471
|
-
const b = s.left - p.left, w = p.right - s.right;
|
|
472
|
-
if (b > 0 || w > 0) {
|
|
473
|
-
let C = h.attrs;
|
|
474
|
-
b > 0 && (C = F(C, 0, b)), w > 0 && (C = F(C, C.colspan - w, w)), p.left < s.left ? h = h.type.createAndFill(C) : h = h.type.create(C, h.content);
|
|
475
|
-
}
|
|
476
|
-
if (p.top < s.top || p.bottom > s.bottom) {
|
|
477
|
-
const C = y(
|
|
478
|
-
h.attrs,
|
|
479
|
-
"rowspan",
|
|
480
|
-
Math.min(p.bottom, s.bottom) - Math.max(p.top, s.top)
|
|
481
|
-
);
|
|
482
|
-
p.top < s.top ? h = h.type.createAndFill(C) : h = h.type.create(C, h.content);
|
|
483
|
-
}
|
|
484
|
-
c.push(h);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
r.push(e.child(i).copy($.from(c)));
|
|
488
|
-
}
|
|
489
|
-
const a = this.isColSelection() && this.isRowSelection() ? e : r;
|
|
490
|
-
return new _($.from(a), 1, 1);
|
|
491
|
-
}
|
|
492
|
-
replace(e, t = _.empty) {
|
|
493
|
-
const n = e.steps.length, s = this.ranges;
|
|
494
|
-
for (let r = 0; r < s.length; r++) {
|
|
495
|
-
const { $from: a, $to: i } = s[r], c = e.mapping.slice(n);
|
|
496
|
-
e.replace(c.map(a.pos), c.map(i.pos), r ? _.empty : t);
|
|
497
|
-
}
|
|
498
|
-
const l = S.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)), -1);
|
|
499
|
-
l && e.setSelection(l);
|
|
500
|
-
}
|
|
501
|
-
replaceWith(e, t) {
|
|
502
|
-
this.replace(e, new _($.from(t), 0, 0));
|
|
503
|
-
}
|
|
504
|
-
forEachCell(e) {
|
|
505
|
-
const t = this.$anchorCell.node(-1), n = g.get(t), s = this.$anchorCell.start(-1), l = n.cellsInRect(n.rectBetween(this.$anchorCell.pos - s, this.$headCell.pos - s));
|
|
506
|
-
for (let r = 0; r < l.length; r++)
|
|
507
|
-
e(t.nodeAt(l[r]), s + l[r]);
|
|
508
|
-
}
|
|
509
|
-
isColSelection() {
|
|
510
|
-
const e = this.$anchorCell.index(-1), t = this.$headCell.index(-1);
|
|
511
|
-
if (Math.min(e, t) > 0)
|
|
512
|
-
return !1;
|
|
513
|
-
const n = e + this.$anchorCell.nodeAfter.attrs.rowspan, s = t + this.$headCell.nodeAfter.attrs.rowspan;
|
|
514
|
-
return Math.max(n, s) == this.$headCell.node(-1).childCount;
|
|
515
|
-
}
|
|
516
|
-
static colSelection(e, t = e) {
|
|
517
|
-
const n = g.get(e.node(-1)), s = e.start(-1), l = n.findCell(e.pos - s), r = n.findCell(t.pos - s), a = e.node(0);
|
|
518
|
-
if (l.top <= r.top) {
|
|
519
|
-
if (l.top > 0) {
|
|
520
|
-
const i = n.map[l.left];
|
|
521
|
-
e = a.resolve(s + i);
|
|
522
|
-
}
|
|
523
|
-
if (r.bottom < n.height) {
|
|
524
|
-
const i = n.map[n.width * (n.height - 1) + r.right - 1];
|
|
525
|
-
t = a.resolve(s + i);
|
|
526
|
-
}
|
|
527
|
-
} else {
|
|
528
|
-
if (r.top > 0) {
|
|
529
|
-
const i = n.map[l.left];
|
|
530
|
-
t = a.resolve(s + i);
|
|
531
|
-
}
|
|
532
|
-
if (l.bottom < n.height) {
|
|
533
|
-
const i = n.map[n.width * (n.height - 1) + l.right - 1];
|
|
534
|
-
e = a.resolve(s + i);
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
return new m(e, t);
|
|
538
|
-
}
|
|
539
|
-
isRowSelection() {
|
|
540
|
-
const e = g.get(this.$anchorCell.node(-1)), t = this.$anchorCell.start(-1), n = e.colCount(this.$anchorCell.pos - t), s = e.colCount(this.$headCell.pos - t);
|
|
541
|
-
if (Math.min(n, s) > 0)
|
|
542
|
-
return !1;
|
|
543
|
-
const l = n + this.$anchorCell.nodeAfter.attrs.colspan, r = s + this.$headCell.nodeAfter.attrs.colspan;
|
|
544
|
-
return Math.max(l, r) == e.width;
|
|
545
|
-
}
|
|
546
|
-
eq(e) {
|
|
547
|
-
return e instanceof m && e.$anchorCell.pos == this.$anchorCell.pos && e.$headCell.pos == this.$headCell.pos;
|
|
548
|
-
}
|
|
549
|
-
static rowSelection(e, t = e) {
|
|
550
|
-
const n = g.get(e.node(-1)), s = e.start(-1), l = n.findCell(e.pos - s), r = n.findCell(t.pos - s), a = e.node(0);
|
|
551
|
-
if (l.left <= r.left) {
|
|
552
|
-
if (l.left > 0) {
|
|
553
|
-
const i = n.map[l.top * n.width];
|
|
554
|
-
e = a.resolve(s + i);
|
|
555
|
-
}
|
|
556
|
-
if (r.right < n.width) {
|
|
557
|
-
const i = n.map[n.width * (r.top + 1) - 1];
|
|
558
|
-
t = a.resolve(s + i);
|
|
559
|
-
}
|
|
560
|
-
} else {
|
|
561
|
-
if (r.left > 0) {
|
|
562
|
-
const i = n.map[r.top * n.width];
|
|
563
|
-
t = a.resolve(s + i);
|
|
564
|
-
}
|
|
565
|
-
if (l.right < n.width) {
|
|
566
|
-
const i = n.map[n.width * (l.top + 1) - 1];
|
|
567
|
-
e = a.resolve(s + i);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
return new m(e, t);
|
|
571
|
-
}
|
|
572
|
-
toJSON() {
|
|
573
|
-
return {
|
|
574
|
-
type: "cell",
|
|
575
|
-
anchor: this.$anchorCell.pos,
|
|
576
|
-
head: this.$headCell.pos
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
static fromJSON(e, t) {
|
|
580
|
-
return new m(e.resolve(t.anchor), e.resolve(t.head));
|
|
581
|
-
}
|
|
582
|
-
static create(e, t, n = t) {
|
|
583
|
-
return new m(e.resolve(t), e.resolve(n));
|
|
584
|
-
}
|
|
585
|
-
getBookmark() {
|
|
586
|
-
return new Ne(this.$anchorCell.pos, this.$headCell.pos);
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
m.prototype.visible = !1;
|
|
590
|
-
S.jsonID("cell", m);
|
|
591
|
-
class Ne {
|
|
592
|
-
constructor(e, t) {
|
|
593
|
-
this.anchor = e, this.head = t, this.anchor = e, this.head = t;
|
|
594
|
-
}
|
|
595
|
-
map(e) {
|
|
596
|
-
return new Ne(e.map(this.anchor), e.map(this.head));
|
|
597
|
-
}
|
|
598
|
-
resolve(e) {
|
|
599
|
-
const t = e.resolve(this.anchor), n = e.resolve(this.head);
|
|
600
|
-
return t.parent.type.spec.tableRole == "row" && n.parent.type.spec.tableRole == "row" && t.index() < t.parent.childCount && n.index() < n.parent.childCount && xe(t, n) ? new m(t, n) : S.near(n, 1);
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
function Bt(o) {
|
|
604
|
-
if (!(o.selection instanceof m))
|
|
605
|
-
return null;
|
|
606
|
-
const e = [];
|
|
607
|
-
return o.selection.forEachCell((t, n) => {
|
|
608
|
-
e.push(Me.node(n, n + t.nodeSize, { class: "selectedCell" }));
|
|
609
|
-
}), Se.create(o.doc, e);
|
|
610
|
-
}
|
|
611
|
-
function Wt({ $from: o, $to: e }) {
|
|
612
|
-
if (o.pos == e.pos || o.pos < o.pos - 6)
|
|
613
|
-
return !1;
|
|
614
|
-
let t = o.pos, n = e.pos, s = o.depth;
|
|
615
|
-
for (; s >= 0 && !(o.after(s + 1) < o.end(s)); s--, t++)
|
|
616
|
-
;
|
|
617
|
-
for (let l = e.depth; l >= 0 && !(e.before(l + 1) > e.start(l)); l--, n--)
|
|
618
|
-
;
|
|
619
|
-
return t == n && /row|table/.test(o.node(s).type.spec.tableRole);
|
|
620
|
-
}
|
|
621
|
-
function Pt({ $from: o, $to: e }) {
|
|
622
|
-
let t, n;
|
|
623
|
-
for (let s = o.depth; s > 0; s--) {
|
|
624
|
-
const l = o.node(s);
|
|
625
|
-
if (l.type.spec.tableRole === "cell" || l.type.spec.tableRole === "header_cell") {
|
|
626
|
-
t = l;
|
|
627
|
-
break;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
for (let s = e.depth; s > 0; s--) {
|
|
631
|
-
const l = e.node(s);
|
|
632
|
-
if (l.type.spec.tableRole === "cell" || l.type.spec.tableRole === "header_cell") {
|
|
633
|
-
n = l;
|
|
634
|
-
break;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
return t !== n && e.parentOffset === 0;
|
|
638
|
-
}
|
|
639
|
-
function Ht(o, e, t) {
|
|
640
|
-
const n = (e || o).selection, s = (e || o).doc;
|
|
641
|
-
let l, r;
|
|
642
|
-
if (n instanceof oe && (r = n.node.type.spec.tableRole)) {
|
|
643
|
-
if (r == "cell" || r == "header_cell")
|
|
644
|
-
l = m.create(s, n.from);
|
|
645
|
-
else if (r == "row") {
|
|
646
|
-
const a = s.resolve(n.from + 1);
|
|
647
|
-
l = m.rowSelection(a, a);
|
|
648
|
-
} else if (!t) {
|
|
649
|
-
const a = g.get(n.node), i = n.from + 1, c = a.map[a.width * a.height - 1], d = i + c;
|
|
650
|
-
l = m.create(s, i + 1, d);
|
|
651
|
-
}
|
|
652
|
-
} else
|
|
653
|
-
n instanceof E && Wt(n) ? l = E.create(s, n.from) : n instanceof E && Pt(n) && (l = E.create(s, n.$from.start(), n.$from.end()));
|
|
654
|
-
return l && (e || (e = o.tr)).setSelection(l), e;
|
|
655
|
-
}
|
|
656
|
-
function Ie(o, e) {
|
|
657
|
-
const t = o.getAttribute("data-colwidth"), n = t && /^\d+(,\d+)*$/.test(t) ? t.split(",").map((r) => Number(r)) : null, s = Number(o.getAttribute("colspan") || 1), l = {
|
|
658
|
-
colspan: s,
|
|
659
|
-
rowspan: Number(o.getAttribute("rowspan") || 1),
|
|
660
|
-
colwidth: n && n.length == s ? n : null
|
|
661
|
-
};
|
|
662
|
-
for (const r in e) {
|
|
663
|
-
const a = e[r].getFromDOM, i = a && a(o);
|
|
664
|
-
i != null && (l[r] = i);
|
|
665
|
-
}
|
|
666
|
-
return l;
|
|
667
|
-
}
|
|
668
|
-
function De(o, e) {
|
|
669
|
-
const t = {};
|
|
670
|
-
o.attrs.colspan != 1 && (t.colspan = o.attrs.colspan), o.attrs.rowspan != 1 && (t.rowspan = o.attrs.rowspan), o.attrs.colwidth && (t["data-colwidth"] = o.attrs.colwidth.join(","));
|
|
671
|
-
for (const n in e) {
|
|
672
|
-
const s = e[n].setDOMAttr;
|
|
673
|
-
s && s(o.attrs[n], t);
|
|
674
|
-
}
|
|
675
|
-
return t;
|
|
676
|
-
}
|
|
677
|
-
function jt(o) {
|
|
678
|
-
const e = o.cellAttributes || {}, t = {
|
|
679
|
-
colspan: { default: 1 },
|
|
680
|
-
rowspan: { default: 1 },
|
|
681
|
-
colwidth: { default: null }
|
|
682
|
-
};
|
|
683
|
-
for (const l in e)
|
|
684
|
-
t[l] = { default: e[l].default };
|
|
685
|
-
const n = t;
|
|
686
|
-
return {
|
|
687
|
-
table: {
|
|
688
|
-
content: "table_row+",
|
|
689
|
-
tableRole: "table",
|
|
690
|
-
isolating: !0,
|
|
691
|
-
group: o.tableGroup,
|
|
692
|
-
parseDOM: [{ tag: "table" }],
|
|
693
|
-
toDOM() {
|
|
694
|
-
return ["table", ["tbody", 0]];
|
|
695
|
-
}
|
|
696
|
-
},
|
|
697
|
-
table_row: {
|
|
698
|
-
content: "(table_cell | table_header)*",
|
|
699
|
-
tableRole: "row",
|
|
700
|
-
parseDOM: [{ tag: "tr" }],
|
|
701
|
-
toDOM() {
|
|
702
|
-
return ["tr", 0];
|
|
703
|
-
}
|
|
704
|
-
},
|
|
705
|
-
table_cell: {
|
|
706
|
-
content: o.cellContent,
|
|
707
|
-
attrs: n,
|
|
708
|
-
tableRole: "cell",
|
|
709
|
-
isolating: !0,
|
|
710
|
-
parseDOM: [{ tag: "td", getAttrs: (l) => Ie(l, e) }],
|
|
711
|
-
toDOM(l) {
|
|
712
|
-
return ["td", De(l, e), 0];
|
|
713
|
-
}
|
|
714
|
-
},
|
|
715
|
-
table_header: {
|
|
716
|
-
content: o.cellContent,
|
|
717
|
-
attrs: n,
|
|
718
|
-
tableRole: "header_cell",
|
|
719
|
-
isolating: !0,
|
|
720
|
-
parseDOM: [{ tag: "th", getAttrs: (l) => Ie(l, e) }],
|
|
721
|
-
toDOM(l) {
|
|
722
|
-
return ["th", De(l, e), 0];
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
};
|
|
726
|
-
}
|
|
727
|
-
function A(o) {
|
|
728
|
-
let e = o.cached.tableNodeTypes;
|
|
729
|
-
if (!e) {
|
|
730
|
-
e = o.cached.tableNodeTypes = {};
|
|
731
|
-
for (const t in o.nodes) {
|
|
732
|
-
const n = o.nodes[t], s = n == null ? void 0 : n.spec.tableRole;
|
|
733
|
-
s && (e[s] = n);
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
return e;
|
|
737
|
-
}
|
|
738
|
-
const Y = jt({
|
|
739
|
-
tableGroup: "block",
|
|
740
|
-
cellContent: "paragraph",
|
|
741
|
-
cellAttributes: {
|
|
742
|
-
alignment: {
|
|
743
|
-
default: "left",
|
|
744
|
-
getFromDOM: (o) => o.style.textAlign || "left",
|
|
745
|
-
setDOMAttr: (o, e) => {
|
|
746
|
-
e.style = `text-align: ${o || "left"}`;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
|
-
function V(o) {
|
|
752
|
-
for (let e = o.depth - 1; e > 0; e--)
|
|
753
|
-
if (o.node(e).type.spec.tableRole == "row")
|
|
754
|
-
return o.node(0).resolve(o.before(e + 1));
|
|
755
|
-
}
|
|
756
|
-
function pe(o) {
|
|
757
|
-
return o.parent.type.spec.tableRole == "row" ? o.nodeAfter : null;
|
|
758
|
-
}
|
|
759
|
-
function Kt(o) {
|
|
760
|
-
return o.node(0).resolve(o.pos + o.nodeAfter.nodeSize);
|
|
761
|
-
}
|
|
762
|
-
function xe(o, e) {
|
|
763
|
-
return o.depth == e.depth && o.pos >= e.start(-1) && o.pos <= e.end(-1);
|
|
764
|
-
}
|
|
765
|
-
function et(o, e, t) {
|
|
766
|
-
const n = o.start(-1), l = g.get(o.node(-1)).nextCell(o.pos - n, e, t);
|
|
767
|
-
return l == null ? null : o.node(0).resolve(n + l);
|
|
768
|
-
}
|
|
769
|
-
function y(o, e, t) {
|
|
770
|
-
const n = {};
|
|
771
|
-
for (const s in o)
|
|
772
|
-
n[s] = o[s];
|
|
773
|
-
return n[e] = t, n;
|
|
774
|
-
}
|
|
775
|
-
function F(o, e, t = 1) {
|
|
776
|
-
const n = y(o, "colspan", o.colspan - t);
|
|
777
|
-
if (n.colwidth) {
|
|
778
|
-
const s = n.colwidth;
|
|
779
|
-
n.colwidth = s.slice(), s.splice(e, t), s.some((l) => l > 0) || (n.colwidth = null);
|
|
780
|
-
}
|
|
781
|
-
return n;
|
|
782
|
-
}
|
|
783
|
-
function M(o) {
|
|
784
|
-
const e = o.selection.$head;
|
|
785
|
-
for (let t = e.depth; t > 0; t--)
|
|
786
|
-
if (e.node(t).type.spec.tableRole == "row")
|
|
787
|
-
return !0;
|
|
788
|
-
return !1;
|
|
789
|
-
}
|
|
790
|
-
function se(o) {
|
|
791
|
-
const e = o.selection;
|
|
792
|
-
return e instanceof m ? e.$anchorCell.pos > e.$headCell.pos ? e.$anchorCell : e.$headCell : e.node && e.node.type.spec.tableRole == "cell" ? e.$anchor : V(e.$head) || qt(e.$head);
|
|
793
|
-
}
|
|
794
|
-
function qt(o) {
|
|
795
|
-
for (let e = o.nodeAfter, t = o.pos; e; e = e.firstChild, t++) {
|
|
796
|
-
const n = e.type.spec.tableRole;
|
|
797
|
-
if (n == "cell" || n == "header_cell")
|
|
798
|
-
return o.doc.resolve(t);
|
|
799
|
-
}
|
|
800
|
-
for (let e = o.nodeBefore, t = o.pos; e; e = e.lastChild, t--) {
|
|
801
|
-
const n = e.type.spec.tableRole;
|
|
802
|
-
if (n == "cell" || n == "header_cell")
|
|
803
|
-
return o.doc.resolve(t - e.nodeSize);
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
function Xt(o, e, t = 1) {
|
|
807
|
-
const n = y(o, "colspan", o.colspan + t);
|
|
808
|
-
if (n.colwidth) {
|
|
809
|
-
const s = n.colwidth;
|
|
810
|
-
n.colwidth = s.slice();
|
|
811
|
-
for (let l = 0; l < t; l++)
|
|
812
|
-
s.splice(e, 0, 0);
|
|
813
|
-
}
|
|
814
|
-
return n;
|
|
815
|
-
}
|
|
816
|
-
function Ut(o, e, t) {
|
|
817
|
-
const n = A(e.type.schema).header_cell;
|
|
818
|
-
for (let s = 0; s < o.height; s++) {
|
|
819
|
-
const l = o.map[t + s * o.width];
|
|
820
|
-
if (e.nodeAt(l).type != n)
|
|
821
|
-
return !1;
|
|
822
|
-
}
|
|
823
|
-
return !0;
|
|
824
|
-
}
|
|
825
|
-
const Vt = (o) => (e, t) => {
|
|
826
|
-
if (!M(e))
|
|
827
|
-
return !1;
|
|
828
|
-
const { $head: n } = e.selection, s = n.after(), l = e.tr.replaceWith(s, s, o.createAndFill());
|
|
829
|
-
return l.setSelection(S.near(l.doc.resolve(s), 1)), t == null || t(l.scrollIntoView()), !0;
|
|
830
|
-
};
|
|
831
|
-
function P(o) {
|
|
832
|
-
const e = o.selection, t = se(o), n = t.node(-1), s = t.start(-1), l = g.get(n);
|
|
833
|
-
let r;
|
|
834
|
-
return e instanceof m ? r = l.rectBetween(e.$anchorCell.pos - s, e.$headCell.pos - s) : r = l.findCell(t.pos - s), r.tableStart = s, r.map = l, r.table = n, r;
|
|
835
|
-
}
|
|
836
|
-
function tt(o, { map: e, tableStart: t, table: n }, s) {
|
|
837
|
-
e = e, n = n, t = t;
|
|
838
|
-
let l = s > 0 ? -1 : 0;
|
|
839
|
-
Ut(e, n, s + l) && (l = s == 0 || s == e.width ? null : 0);
|
|
840
|
-
for (let r = 0; r < e.height; r++) {
|
|
841
|
-
const a = r * e.width + s;
|
|
842
|
-
if (s > 0 && s < e.width && e.map[a - 1] == e.map[a]) {
|
|
843
|
-
const i = e.map[a], c = n.nodeAt(i);
|
|
844
|
-
o.setNodeMarkup(o.mapping.map(t + i), null, Xt(c.attrs, s - e.colCount(i))), r += c.attrs.rowspan - 1;
|
|
845
|
-
} else {
|
|
846
|
-
const i = e.map[a + l], c = l == null ? A(n.type.schema).cell : n.nodeAt(i).type, d = e.positionAt(r, s, n);
|
|
847
|
-
o.insert(o.mapping.map(t + d), c.createAndFill());
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
return o;
|
|
851
|
-
}
|
|
852
|
-
const Gt = (o, e) => {
|
|
853
|
-
if (!M(o))
|
|
854
|
-
return !1;
|
|
855
|
-
if (e) {
|
|
856
|
-
const t = P(o);
|
|
857
|
-
e(tt(o.tr, t, t.left));
|
|
858
|
-
}
|
|
859
|
-
return !0;
|
|
860
|
-
}, Jt = (o, e) => {
|
|
861
|
-
if (!M(o))
|
|
862
|
-
return !1;
|
|
863
|
-
if (e) {
|
|
864
|
-
const t = P(o);
|
|
865
|
-
e(tt(o.tr, t, t.right));
|
|
866
|
-
}
|
|
867
|
-
return !0;
|
|
868
|
-
};
|
|
869
|
-
function Yt(o, { map: e, table: t, tableStart: n }, s) {
|
|
870
|
-
e = e, t = t, n = n;
|
|
871
|
-
const l = o.mapping.maps.length;
|
|
872
|
-
for (let r = 0; r < e.height; ) {
|
|
873
|
-
const a = r * e.width + s, i = e.map[a], c = t.nodeAt(i);
|
|
874
|
-
if (s > 0 && e.map[a - 1] == i || s < e.width - 1 && e.map[a + 1] == i)
|
|
875
|
-
o.setNodeMarkup(
|
|
876
|
-
o.mapping.slice(l).map(n + i),
|
|
877
|
-
null,
|
|
878
|
-
F(c.attrs, s - e.colCount(i))
|
|
879
|
-
);
|
|
880
|
-
else {
|
|
881
|
-
const d = o.mapping.slice(l).map(n + i);
|
|
882
|
-
o.delete(d, d + c.nodeSize);
|
|
1
|
+
import { expectDomTypeError as $ } from "@milkdown/exception";
|
|
2
|
+
import { paragraphSchema as W, listItemSchema as ne } from "@milkdown/preset-commonmark";
|
|
3
|
+
import { commandsCtx as S } from "@milkdown/core";
|
|
4
|
+
import { InputRule as le } from "@milkdown/prose/inputrules";
|
|
5
|
+
import { TextSelection as re, Selection as K, PluginKey as se, Plugin as ce } from "@milkdown/prose/state";
|
|
6
|
+
import { TableMap as h, CellSelection as C, tableNodes as ae, goToNextCell as L, isInTable as y, deleteTable as ie, deleteColumn as de, deleteRow as ue, addColumnBefore as me, addColumnAfter as fe, selectedRect as z, setCellAttr as pe, columnResizing as he, tableEditing as be } from "@milkdown/prose/tables";
|
|
7
|
+
import { $markSchema as ge, $command as p, $useKeymap as G, $nodeSchema as w, $inputRule as Ce, $prose as _, $remark as we } from "@milkdown/utils";
|
|
8
|
+
import { findParentNode as ke, cloneTr as T, browser as D } from "@milkdown/prose";
|
|
9
|
+
import { toggleMark as ye } from "@milkdown/prose/commands";
|
|
10
|
+
import Se from "remark-gfm";
|
|
11
|
+
const j = ge("strike_through", () => ({
|
|
12
|
+
inclusive: !1,
|
|
13
|
+
parseDOM: [
|
|
14
|
+
{ tag: "del" },
|
|
15
|
+
{ style: "text-decoration", getAttrs: (e) => e === "line-through" }
|
|
16
|
+
],
|
|
17
|
+
toDOM: () => ["del"],
|
|
18
|
+
parseMarkdown: {
|
|
19
|
+
match: (e) => e.type === "delete",
|
|
20
|
+
runner: (e, t, n) => {
|
|
21
|
+
e.openMark(n), e.next(t.children), e.closeMark(n);
|
|
883
22
|
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
return !1;
|
|
890
|
-
if (e) {
|
|
891
|
-
const t = P(o), n = o.tr;
|
|
892
|
-
if (t.left == 0 && t.right == t.map.width)
|
|
893
|
-
return !1;
|
|
894
|
-
for (let s = t.right - 1; Yt(n, t, s), s != t.left; s--)
|
|
895
|
-
t.table = t.tableStart ? n.doc.nodeAt(t.tableStart - 1) : n.doc, t.map = g.get(t.table);
|
|
896
|
-
e(n);
|
|
897
|
-
}
|
|
898
|
-
return !0;
|
|
899
|
-
};
|
|
900
|
-
function Qt(o, { map: e, tableStart: t, table: n }, s) {
|
|
901
|
-
e = e, n = n, t = t;
|
|
902
|
-
let l = 0;
|
|
903
|
-
for (let i = 0; i < s; i++)
|
|
904
|
-
l += n.child(i).nodeSize;
|
|
905
|
-
const r = l + n.child(s).nodeSize, a = o.mapping.maps.length;
|
|
906
|
-
o.delete(l + t, r + t);
|
|
907
|
-
for (let i = 0, c = s * e.width; i < e.width; i++, c++) {
|
|
908
|
-
const d = e.map[c];
|
|
909
|
-
if (s > 0 && d == e.map[c - e.width]) {
|
|
910
|
-
const f = n.nodeAt(d).attrs;
|
|
911
|
-
o.setNodeMarkup(
|
|
912
|
-
o.mapping.slice(a).map(d + t),
|
|
913
|
-
null,
|
|
914
|
-
y(f, "rowspan", f.rowspan - 1)
|
|
915
|
-
), i += f.colspan - 1;
|
|
916
|
-
} else if (s < e.width && d == e.map[c + e.width]) {
|
|
917
|
-
const f = n.nodeAt(d), u = f.type.create(y(f.attrs, "rowspan", f.attrs.rowspan - 1), f.content), p = e.positionAt(s + 1, i, n);
|
|
918
|
-
o.insert(o.mapping.slice(a).map(t + p), u), i += f.attrs.colspan - 1;
|
|
23
|
+
},
|
|
24
|
+
toMarkdown: {
|
|
25
|
+
match: (e) => e.type.name === "strike_through",
|
|
26
|
+
runner: (e, t) => {
|
|
27
|
+
e.withMark(t, "delete");
|
|
919
28
|
}
|
|
920
29
|
}
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
if (t.top == 0 && t.bottom == t.map.height)
|
|
928
|
-
return !1;
|
|
929
|
-
for (let s = t.bottom - 1; Qt(n, t, s), s != t.top; s--)
|
|
930
|
-
t.table = t.tableStart ? n.doc.nodeAt(t.tableStart - 1) : n.doc, t.map = g.get(t.table);
|
|
931
|
-
e(n);
|
|
932
|
-
}
|
|
933
|
-
return !0;
|
|
934
|
-
};
|
|
935
|
-
function ce(o, e) {
|
|
936
|
-
return (t, n) => {
|
|
937
|
-
if (!M(t))
|
|
938
|
-
return !1;
|
|
939
|
-
const s = se(t);
|
|
940
|
-
if (s.nodeAfter.attrs[o] === e)
|
|
941
|
-
return !1;
|
|
942
|
-
if (n) {
|
|
943
|
-
const l = t.tr;
|
|
944
|
-
t.selection instanceof m ? t.selection.forEachCell((r, a) => {
|
|
945
|
-
r.attrs[o] !== e && l.setNodeMarkup(a, null, y(r.attrs, o, e));
|
|
946
|
-
}) : l.setNodeMarkup(s.pos, null, y(s.nodeAfter.attrs, o, e)), n(l);
|
|
947
|
-
}
|
|
948
|
-
return !0;
|
|
949
|
-
};
|
|
950
|
-
}
|
|
951
|
-
function tn(o, e) {
|
|
952
|
-
if (e < 0) {
|
|
953
|
-
const t = o.nodeBefore;
|
|
954
|
-
if (t)
|
|
955
|
-
return o.pos - t.nodeSize;
|
|
956
|
-
for (let n = o.index(-1) - 1, s = o.before(); n >= 0; n--) {
|
|
957
|
-
const l = o.node(-1).child(n);
|
|
958
|
-
if (l.childCount)
|
|
959
|
-
return s - 1 - l.lastChild.nodeSize;
|
|
960
|
-
s -= l.nodeSize;
|
|
961
|
-
}
|
|
962
|
-
} else {
|
|
963
|
-
if (o.index() < o.parent.childCount - 1)
|
|
964
|
-
return o.pos + o.nodeAfter.nodeSize;
|
|
965
|
-
const t = o.node(-1);
|
|
966
|
-
for (let n = o.indexAfter(-1), s = o.after(); n < t.childCount; n++) {
|
|
967
|
-
const l = t.child(n);
|
|
968
|
-
if (l.childCount)
|
|
969
|
-
return s + 1;
|
|
970
|
-
s += l.nodeSize;
|
|
30
|
+
})), V = p("ToggleStrikeThrough", () => () => ye(j.type())), Te = G("strikeThroughKeymap", {
|
|
31
|
+
ToggleStrikethrough: {
|
|
32
|
+
shortcuts: "Mod-Alt-x",
|
|
33
|
+
command: (e) => {
|
|
34
|
+
const t = e.get(S);
|
|
35
|
+
return () => t.call(V.key);
|
|
971
36
|
}
|
|
972
37
|
}
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
return (
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
if (n == null)
|
|
980
|
-
return !1;
|
|
981
|
-
if (t) {
|
|
982
|
-
const s = e.doc.resolve(n);
|
|
983
|
-
t(e.tr.setSelection(E.between(s, Kt(s))).scrollIntoView());
|
|
984
|
-
}
|
|
985
|
-
return !0;
|
|
986
|
-
};
|
|
987
|
-
}
|
|
988
|
-
const nn = (o, e) => {
|
|
989
|
-
const t = o.selection.$anchor;
|
|
990
|
-
for (let n = t.depth; n > 0; n--)
|
|
991
|
-
if (t.node(n).type.spec.tableRole == "table")
|
|
992
|
-
return e && e(o.tr.delete(t.before(n), t.after(n)).scrollIntoView()), !0;
|
|
993
|
-
return !1;
|
|
994
|
-
}, le = (o) => Ct((e) => e.type.spec.tableRole === "table")(o), on = (o) => (e) => {
|
|
995
|
-
const t = le(e);
|
|
996
|
-
if (!t)
|
|
38
|
+
}), Z = (e = 3, t = 3) => {
|
|
39
|
+
const n = Array(t).fill(0).map(() => O.type().createAndFill()), o = Array(t).fill(0).map(() => Y.type().createAndFill()), l = Array(e).fill(0).map((r, s) => I.type().create(null, s === 0 ? o : n));
|
|
40
|
+
return E.type().create(null, l);
|
|
41
|
+
}, k = (e) => ke((t) => t.type.spec.tableRole === "table")(e), b = (e, t) => {
|
|
42
|
+
const n = k(t);
|
|
43
|
+
if (!n)
|
|
997
44
|
return;
|
|
998
|
-
const
|
|
999
|
-
if (!(
|
|
1000
|
-
return
|
|
1001
|
-
const
|
|
1002
|
-
if (!
|
|
45
|
+
const o = h.get(n.node);
|
|
46
|
+
if (!(e < 0 || e >= o.width))
|
|
47
|
+
return o.cellsInRect({ left: e, right: e + 1, top: 0, bottom: o.height }).map((l) => {
|
|
48
|
+
const r = n.node.nodeAt(l);
|
|
49
|
+
if (!r)
|
|
1003
50
|
return;
|
|
1004
|
-
const
|
|
51
|
+
const s = l + n.start;
|
|
1005
52
|
return {
|
|
1006
|
-
pos:
|
|
1007
|
-
start:
|
|
1008
|
-
node:
|
|
53
|
+
pos: s,
|
|
54
|
+
start: s + 1,
|
|
55
|
+
node: r
|
|
1009
56
|
};
|
|
1010
|
-
}).filter((
|
|
1011
|
-
},
|
|
1012
|
-
const
|
|
1013
|
-
if (!
|
|
57
|
+
}).filter((l) => l != null);
|
|
58
|
+
}, g = (e, t) => {
|
|
59
|
+
const n = k(t);
|
|
60
|
+
if (!n)
|
|
1014
61
|
return;
|
|
1015
|
-
const
|
|
1016
|
-
if (!(
|
|
1017
|
-
return
|
|
1018
|
-
const
|
|
1019
|
-
if (!
|
|
62
|
+
const o = h.get(n.node);
|
|
63
|
+
if (!(e < 0 || e >= o.height))
|
|
64
|
+
return o.cellsInRect({ left: 0, right: o.width, top: e, bottom: e + 1 }).map((l) => {
|
|
65
|
+
const r = n.node.nodeAt(l);
|
|
66
|
+
if (!r)
|
|
1020
67
|
return;
|
|
1021
|
-
const
|
|
68
|
+
const s = l + n.start;
|
|
1022
69
|
return {
|
|
1023
|
-
pos:
|
|
1024
|
-
start:
|
|
1025
|
-
node:
|
|
70
|
+
pos: s,
|
|
71
|
+
start: s + 1,
|
|
72
|
+
node: r
|
|
1026
73
|
};
|
|
1027
|
-
}).filter((
|
|
1028
|
-
},
|
|
1029
|
-
const
|
|
1030
|
-
|
|
1031
|
-
}, _e = (o) => (e) => (t) => {
|
|
1032
|
-
const n = le(t.selection), s = o === "row";
|
|
1033
|
-
if (n) {
|
|
1034
|
-
const l = g.get(n.node);
|
|
1035
|
-
if (e >= 0 && e < (s ? l.height : l.width)) {
|
|
1036
|
-
const r = l.positionAt(
|
|
1037
|
-
s ? e : l.height - 1,
|
|
1038
|
-
s ? l.width - 1 : e,
|
|
1039
|
-
n.node
|
|
1040
|
-
), a = t.doc.resolve(n.start + r), i = s ? m.rowSelection : m.colSelection, c = l.positionAt(s ? e : 0, s ? 0 : e, n.node), d = t.doc.resolve(n.start + c);
|
|
1041
|
-
return Ge(t.setSelection(i(a, d)));
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
return t;
|
|
1045
|
-
}, ln = (o) => {
|
|
1046
|
-
const e = le(o);
|
|
1047
|
-
if (!e)
|
|
74
|
+
}).filter((l) => l != null);
|
|
75
|
+
}, Me = (e) => {
|
|
76
|
+
const t = k(e);
|
|
77
|
+
if (!t)
|
|
1048
78
|
return;
|
|
1049
|
-
const
|
|
1050
|
-
return
|
|
79
|
+
const n = h.get(t.node);
|
|
80
|
+
return n.cellsInRect({
|
|
1051
81
|
left: 0,
|
|
1052
|
-
right:
|
|
82
|
+
right: n.width,
|
|
1053
83
|
top: 0,
|
|
1054
|
-
bottom:
|
|
1055
|
-
}).map((
|
|
1056
|
-
const
|
|
1057
|
-
return { pos:
|
|
84
|
+
bottom: n.height
|
|
85
|
+
}).map((l) => {
|
|
86
|
+
const r = t.node.nodeAt(l), s = l + t.start;
|
|
87
|
+
return { pos: s, start: s + 1, node: r };
|
|
1058
88
|
});
|
|
1059
|
-
},
|
|
1060
|
-
const
|
|
1061
|
-
if (
|
|
1062
|
-
const
|
|
1063
|
-
if (
|
|
1064
|
-
const
|
|
1065
|
-
return
|
|
89
|
+
}, Ae = (e) => {
|
|
90
|
+
const t = Me(e.selection);
|
|
91
|
+
if (t && t[0]) {
|
|
92
|
+
const n = e.doc.resolve(t[0].pos), o = t[t.length - 1];
|
|
93
|
+
if (o) {
|
|
94
|
+
const l = e.doc.resolve(o.pos);
|
|
95
|
+
return T(e.setSelection(new C(l, n)));
|
|
1066
96
|
}
|
|
1067
97
|
}
|
|
1068
|
-
return
|
|
98
|
+
return e;
|
|
1069
99
|
};
|
|
1070
|
-
function
|
|
1071
|
-
const
|
|
1072
|
-
const
|
|
1073
|
-
return
|
|
100
|
+
function U(e, { map: t, tableStart: n, table: o }, l) {
|
|
101
|
+
const r = Array(l).fill(0).reduce((i, a, u) => i + o.child(u).nodeSize, n), s = Array(t.width).fill(0).map((i, a) => {
|
|
102
|
+
const u = o.nodeAt(t.map[a]);
|
|
103
|
+
return O.type().createAndFill({ alignment: u == null ? void 0 : u.attrs.alignment });
|
|
1074
104
|
});
|
|
1075
|
-
return
|
|
105
|
+
return e.insert(r, I.type().create(null, s)), e;
|
|
1076
106
|
}
|
|
1077
|
-
const
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
return !1;
|
|
1089
|
-
return !0;
|
|
1090
|
-
}, an = (o, e) => {
|
|
1091
|
-
Object.values(o).forEach((t) => {
|
|
1092
|
-
var s;
|
|
1093
|
-
if ((s = t.disable) == null ? void 0 : s.call(t, e)) {
|
|
1094
|
-
t.$.classList.add("hide");
|
|
1095
|
-
return;
|
|
107
|
+
const X = (e) => (t) => (n) => {
|
|
108
|
+
const o = k(n.selection), l = e === "row";
|
|
109
|
+
if (o) {
|
|
110
|
+
const r = h.get(o.node);
|
|
111
|
+
if (t >= 0 && t < (l ? r.height : r.width)) {
|
|
112
|
+
const s = r.positionAt(
|
|
113
|
+
l ? t : r.height - 1,
|
|
114
|
+
l ? r.width - 1 : t,
|
|
115
|
+
o.node
|
|
116
|
+
), i = n.doc.resolve(o.start + s), a = l ? C.rowSelection : C.colSelection, u = r.positionAt(l ? t : 0, l ? 0 : t, o.node), c = n.doc.resolve(o.start + u);
|
|
117
|
+
return T(n.setSelection(a(i, c)));
|
|
1096
118
|
}
|
|
1097
|
-
t.$.classList.remove("hide");
|
|
1098
|
-
});
|
|
1099
|
-
}, dn = (o) => {
|
|
1100
|
-
var e, t, n, s, l, r, a, i;
|
|
1101
|
-
return {
|
|
1102
|
-
[0]: {
|
|
1103
|
-
$: (e = o.get(L).get(v, "leftArrow")) == null ? void 0 : e.dom,
|
|
1104
|
-
command: () => Gt,
|
|
1105
|
-
disable: (c) => !T(c).isColSelection()
|
|
1106
|
-
},
|
|
1107
|
-
[1]: {
|
|
1108
|
-
$: (t = o.get(L).get(v, "rightArrow")) == null ? void 0 : t.dom,
|
|
1109
|
-
command: () => Jt,
|
|
1110
|
-
disable: (c) => !T(c).isColSelection()
|
|
1111
|
-
},
|
|
1112
|
-
[2]: {
|
|
1113
|
-
$: (n = o.get(L).get(v, "upArrow")) == null ? void 0 : n.dom,
|
|
1114
|
-
command: () => (c, d) => {
|
|
1115
|
-
if (!M(c))
|
|
1116
|
-
return !1;
|
|
1117
|
-
if (d) {
|
|
1118
|
-
const f = P(c);
|
|
1119
|
-
d(ze(c.tr, f, f.top));
|
|
1120
|
-
}
|
|
1121
|
-
return !0;
|
|
1122
|
-
},
|
|
1123
|
-
disable: (c) => !T(c).isRowSelection() || T(c).$head.parent.type.name === "table_header"
|
|
1124
|
-
},
|
|
1125
|
-
[3]: {
|
|
1126
|
-
$: (s = o.get(L).get(v, "downArrow")) == null ? void 0 : s.dom,
|
|
1127
|
-
command: () => (c, d) => {
|
|
1128
|
-
if (!M(c))
|
|
1129
|
-
return !1;
|
|
1130
|
-
if (d) {
|
|
1131
|
-
const f = P(c);
|
|
1132
|
-
d(ze(c.tr, f, f.bottom));
|
|
1133
|
-
}
|
|
1134
|
-
return !0;
|
|
1135
|
-
},
|
|
1136
|
-
disable: (c) => !T(c).isRowSelection()
|
|
1137
|
-
},
|
|
1138
|
-
[4]: {
|
|
1139
|
-
$: (l = o.get(L).get(v, "alignLeft")) == null ? void 0 : l.dom,
|
|
1140
|
-
command: () => ce("alignment", "left"),
|
|
1141
|
-
disable: (c) => !T(c).isColSelection()
|
|
1142
|
-
},
|
|
1143
|
-
[5]: {
|
|
1144
|
-
$: (r = o.get(L).get(v, "alignCenter")) == null ? void 0 : r.dom,
|
|
1145
|
-
command: () => ce("alignment", "center"),
|
|
1146
|
-
disable: (c) => !T(c).isColSelection()
|
|
1147
|
-
},
|
|
1148
|
-
[6]: {
|
|
1149
|
-
$: (a = o.get(L).get(v, "alignRight")) == null ? void 0 : a.dom,
|
|
1150
|
-
command: () => ce("alignment", "right"),
|
|
1151
|
-
disable: (c) => !T(c).isColSelection()
|
|
1152
|
-
},
|
|
1153
|
-
[7]: {
|
|
1154
|
-
$: (i = o.get(L).get(v, "delete")) == null ? void 0 : i.dom,
|
|
1155
|
-
command: (c, d) => {
|
|
1156
|
-
const f = T(d), u = f.isColSelection(), p = f.isRowSelection();
|
|
1157
|
-
return u && p ? nn : u ? Zt : en;
|
|
1158
|
-
},
|
|
1159
|
-
disable: (c) => {
|
|
1160
|
-
const d = T(c);
|
|
1161
|
-
return d.isRowSelection() ? d.isColSelection() ? !1 : cn(d) : !1;
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
};
|
|
1165
|
-
}, fn = (o, e) => {
|
|
1166
|
-
const { selection: t } = o.state, n = t.isColSelection(), s = t.isRowSelection();
|
|
1167
|
-
yt(o, e, (l, r, a) => {
|
|
1168
|
-
const i = e.parentElement;
|
|
1169
|
-
if (!i)
|
|
1170
|
-
throw bt();
|
|
1171
|
-
let c = s ? l.left - a.left - r.width / 2 - 8 : l.left - a.left + (l.width - r.width) / 2, d = l.top - a.top - r.height - (n ? 14 : 0) - 14 + i.scrollTop;
|
|
1172
|
-
c < 0 && (c = 0);
|
|
1173
|
-
const f = i.clientWidth - (r.width + 4);
|
|
1174
|
-
return c > f && (c = f), d < i.scrollTop && (d = l.top - a.top + 14 + i.scrollTop), [d, c];
|
|
1175
|
-
});
|
|
1176
|
-
};
|
|
1177
|
-
var x = /* @__PURE__ */ ((o) => (o.Left = "Left", o.Top = "Top", o.Point = "Point", o))(x || {});
|
|
1178
|
-
const un = (o, { css: e, injectGlobal: t }) => {
|
|
1179
|
-
const n = mt(o), s = o.get(Te, "radius"), l = o.get(Te, "lineWidth");
|
|
1180
|
-
return t`
|
|
1181
|
-
.milkdown {
|
|
1182
|
-
.tableWrapper {
|
|
1183
|
-
table {
|
|
1184
|
-
width: calc(100% - 32px) !important;
|
|
1185
|
-
margin: 16px 0 16px 16px !important;
|
|
1186
|
-
|
|
1187
|
-
.milkdown-cell-left,
|
|
1188
|
-
.milkdown-cell-point,
|
|
1189
|
-
.milkdown-cell-top {
|
|
1190
|
-
position: absolute;
|
|
1191
|
-
|
|
1192
|
-
&::after {
|
|
1193
|
-
cursor: pointer;
|
|
1194
|
-
position: absolute;
|
|
1195
|
-
top: 0;
|
|
1196
|
-
left: 0;
|
|
1197
|
-
height: 100%;
|
|
1198
|
-
width: 100%;
|
|
1199
|
-
display: block;
|
|
1200
|
-
transition: all 0.2s ease-in-out;
|
|
1201
|
-
background: ${n("secondary", 0.12)};
|
|
1202
|
-
content: '';
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
&:hover::after {
|
|
1206
|
-
background: ${n("secondary", 0.38)};
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
.milkdown-cell-left {
|
|
1211
|
-
left: -14px;
|
|
1212
|
-
top: 0;
|
|
1213
|
-
bottom: 0;
|
|
1214
|
-
width: 8px;
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
.milkdown-cell-top {
|
|
1218
|
-
left: 0;
|
|
1219
|
-
right: 0;
|
|
1220
|
-
top: -14px;
|
|
1221
|
-
height: 8px;
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
.milkdown-cell-point {
|
|
1225
|
-
left: -18px;
|
|
1226
|
-
top: -18px;
|
|
1227
|
-
width: 16px;
|
|
1228
|
-
height: 16px;
|
|
1229
|
-
|
|
1230
|
-
.icon {
|
|
1231
|
-
position: absolute;
|
|
1232
|
-
top: 0;
|
|
1233
|
-
bottom: 0;
|
|
1234
|
-
left: 0;
|
|
1235
|
-
right: 0;
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
`, e`
|
|
1242
|
-
display: inline-flex;
|
|
1243
|
-
cursor: pointer;
|
|
1244
|
-
z-index: 2;
|
|
1245
|
-
|
|
1246
|
-
justify-content: space-evenly;
|
|
1247
|
-
|
|
1248
|
-
position: absolute;
|
|
1249
|
-
|
|
1250
|
-
border-radius: ${s};
|
|
1251
|
-
|
|
1252
|
-
${o.get(gt, void 0)};
|
|
1253
|
-
${o.get(wt, void 0)};
|
|
1254
|
-
|
|
1255
|
-
overflow: hidden;
|
|
1256
|
-
background: ${n("surface")};
|
|
1257
|
-
|
|
1258
|
-
.icon {
|
|
1259
|
-
position: relative;
|
|
1260
|
-
color: ${n("solid", 0.87)};
|
|
1261
|
-
|
|
1262
|
-
width: 48px;
|
|
1263
|
-
line-height: 48px;
|
|
1264
|
-
text-align: center;
|
|
1265
|
-
transition: all 0.4s ease-in-out;
|
|
1266
|
-
|
|
1267
|
-
&:hover {
|
|
1268
|
-
background-color: ${n("secondary", 0.12)};
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
&.active {
|
|
1272
|
-
color: ${n("primary")};
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
&:not(:last-child)::after {
|
|
1276
|
-
content: '';
|
|
1277
|
-
position: absolute;
|
|
1278
|
-
right: 0;
|
|
1279
|
-
top: 0;
|
|
1280
|
-
width: ${l};
|
|
1281
|
-
bottom: 0;
|
|
1282
|
-
background: ${n("line")};
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
&.hide,
|
|
1287
|
-
.hide {
|
|
1288
|
-
display: none;
|
|
1289
|
-
}
|
|
1290
|
-
`;
|
|
1291
|
-
}, pn = (o) => {
|
|
1292
|
-
switch (o) {
|
|
1293
|
-
case x.Left:
|
|
1294
|
-
return "milkdown-cell-left";
|
|
1295
|
-
case x.Top:
|
|
1296
|
-
return "milkdown-cell-top";
|
|
1297
|
-
case x.Point:
|
|
1298
|
-
default:
|
|
1299
|
-
return "milkdown-cell-point";
|
|
1300
119
|
}
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
const
|
|
1306
|
-
|
|
1307
|
-
if (
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
return;
|
|
1316
|
-
}
|
|
1317
|
-
case x.Top:
|
|
1318
|
-
s.dispatch(_e("col")(n)(s.state.tr));
|
|
1319
|
-
}
|
|
1320
|
-
}), l;
|
|
1321
|
-
});
|
|
1322
|
-
}
|
|
1323
|
-
const hn = (o, e) => new H({
|
|
1324
|
-
key: new B("MILKDOWN_TABLE_OP"),
|
|
1325
|
-
props: {
|
|
1326
|
-
decorations: (t) => {
|
|
1327
|
-
if (!o.get(U).editable)
|
|
1328
|
-
return null;
|
|
1329
|
-
const s = [], l = on(0)(t.selection);
|
|
1330
|
-
if (!l)
|
|
1331
|
-
return null;
|
|
1332
|
-
const r = sn(0)(t.selection);
|
|
1333
|
-
if (!r)
|
|
1334
|
-
return null;
|
|
1335
|
-
const [a] = l;
|
|
1336
|
-
return s.push(de(o, a, x.Point)), l.forEach((i, c) => {
|
|
1337
|
-
s.push(de(o, i, x.Left, c));
|
|
1338
|
-
}), r.forEach((i, c) => {
|
|
1339
|
-
s.push(de(o, i, x.Top, c));
|
|
1340
|
-
}), Se.create(t.doc, s);
|
|
120
|
+
return n;
|
|
121
|
+
}, Re = X("row"), ve = X("col"), P = (e) => e[0].map((t, n) => e.map((o) => o[n])), q = (e, t) => {
|
|
122
|
+
const n = [], o = h.get(e);
|
|
123
|
+
for (let r = 0; r < o.height; r++) {
|
|
124
|
+
const s = e.child(r), i = [];
|
|
125
|
+
for (let a = 0; a < o.width; a++) {
|
|
126
|
+
if (!t[r][a])
|
|
127
|
+
continue;
|
|
128
|
+
const u = o.map[r * o.width + a], c = t[r][a], m = e.nodeAt(u).type.createChecked(
|
|
129
|
+
Object.assign({}, c.attrs),
|
|
130
|
+
c.content,
|
|
131
|
+
c.marks
|
|
132
|
+
);
|
|
133
|
+
i.push(m);
|
|
1341
134
|
}
|
|
1342
|
-
|
|
1343
|
-
view: (t) => {
|
|
1344
|
-
var a;
|
|
1345
|
-
const n = Object.fromEntries(Object.entries(dn(o)).filter(([, i]) => i.$ != null)), s = document.createElement("div");
|
|
1346
|
-
e.themeManager.onFlush(() => {
|
|
1347
|
-
const i = e.getStyle((c) => un(e.themeManager, c));
|
|
1348
|
-
i && s.classList.add(i);
|
|
1349
|
-
}), s.classList.add("table-tooltip", "hide"), Object.values(n).forEach(({ $: i }) => s.appendChild(i)), (a = t.dom.parentNode) == null || a.appendChild(s);
|
|
1350
|
-
const l = (i) => {
|
|
1351
|
-
!t || (i.stopPropagation(), i.preventDefault(), Object.values(n).forEach(({ $: c, command: d }) => {
|
|
1352
|
-
c.contains(i.target) && d(i, t)(t.state, t.dispatch, t);
|
|
1353
|
-
}));
|
|
1354
|
-
}, r = () => {
|
|
1355
|
-
s.classList.add("hide");
|
|
1356
|
-
};
|
|
1357
|
-
return s.addEventListener("mousedown", l), {
|
|
1358
|
-
update: (i, c) => {
|
|
1359
|
-
const d = i.state;
|
|
1360
|
-
if ((c == null ? void 0 : c.doc.eq(d.doc)) && c.selection.eq(d.selection))
|
|
1361
|
-
return;
|
|
1362
|
-
if (!(d.selection instanceof m) || !i.editable) {
|
|
1363
|
-
r();
|
|
1364
|
-
return;
|
|
1365
|
-
}
|
|
1366
|
-
if (an(n, i), Object.values(n).every(({ $: u }) => u.classList.contains("hide"))) {
|
|
1367
|
-
r();
|
|
1368
|
-
return;
|
|
1369
|
-
}
|
|
1370
|
-
s.classList.remove("hide"), fn(i, s);
|
|
1371
|
-
},
|
|
1372
|
-
destroy: () => {
|
|
1373
|
-
s.removeEventListener("mousedown", l), s.remove();
|
|
1374
|
-
}
|
|
1375
|
-
};
|
|
135
|
+
n.push(s.type.createChecked(s.attrs, i, s.marks));
|
|
1376
136
|
}
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
137
|
+
return e.type.createChecked(
|
|
138
|
+
e.attrs,
|
|
139
|
+
n,
|
|
140
|
+
e.marks
|
|
141
|
+
);
|
|
142
|
+
}, J = (e) => {
|
|
143
|
+
const t = h.get(e), n = [];
|
|
144
|
+
for (let o = 0; o < t.height; o++) {
|
|
145
|
+
const l = [], r = {};
|
|
146
|
+
for (let s = 0; s < t.width; s++) {
|
|
147
|
+
const i = t.map[o * t.width + s], a = e.nodeAt(i), u = t.findCell(i);
|
|
148
|
+
if (r[i] || u.top !== o) {
|
|
149
|
+
l.push(null);
|
|
150
|
+
continue;
|
|
1388
151
|
}
|
|
152
|
+
r[i] = !0, l.push(a);
|
|
1389
153
|
}
|
|
154
|
+
n.push(l);
|
|
1390
155
|
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
156
|
+
return n;
|
|
157
|
+
}, Q = (e, t, n, o) => {
|
|
158
|
+
const l = t[0] > n[0] ? -1 : 1, r = e.splice(t[0], t.length), s = r.length % 2 === 0 ? 1 : 0;
|
|
159
|
+
let i;
|
|
160
|
+
return o === -1 && l === 1 ? i = n[0] - 1 : o === 1 && l === -1 ? i = n[n.length - 1] - s + 1 : i = l === -1 ? n[0] : n[n.length - 1] - s, e.splice(i, 0, ...r), e;
|
|
161
|
+
}, Ne = (e, t, n, o) => {
|
|
162
|
+
let l = P(J(e.node));
|
|
163
|
+
return l = Q(l, t, n, o), l = P(l), q(e.node, l);
|
|
164
|
+
}, xe = (e, t, n, o) => {
|
|
165
|
+
let l = J(e.node);
|
|
166
|
+
return l = Q(l, t, n, o), q(e.node, l);
|
|
167
|
+
}, B = (e, t) => {
|
|
168
|
+
let n = e, o = e;
|
|
169
|
+
for (let c = e; c >= 0; c--) {
|
|
170
|
+
const d = b(c, t.selection);
|
|
171
|
+
d && d.forEach((m) => {
|
|
172
|
+
const f = m.node.attrs.colspan + c - 1;
|
|
173
|
+
f >= n && (n = c), f > o && (o = f);
|
|
174
|
+
});
|
|
1405
175
|
}
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
const { colspan: p, colwidth: h } = c.child(f).attrs;
|
|
1413
|
-
for (let b = 0; b < p; b++, u++) {
|
|
1414
|
-
const w = s == u ? l : h && h[b], C = w ? `${w}px` : "";
|
|
1415
|
-
r += w || n, w || (a = !1), i ? (i.style.width != C && (i.style.width = C), i = i.nextSibling) : e.appendChild(document.createElement("col")).style.width = C;
|
|
1416
|
-
}
|
|
176
|
+
for (let c = e; c <= o; c++) {
|
|
177
|
+
const d = b(c, t.selection);
|
|
178
|
+
d && d.forEach((m) => {
|
|
179
|
+
const f = m.node.attrs.colspan + c - 1;
|
|
180
|
+
m.node.attrs.colspan > 1 && f > o && (o = f);
|
|
181
|
+
});
|
|
1417
182
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
183
|
+
const l = [];
|
|
184
|
+
for (let c = n; c <= o; c++) {
|
|
185
|
+
const d = b(c, t.selection);
|
|
186
|
+
d && d.length && l.push(c);
|
|
1421
187
|
}
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
init(l, r) {
|
|
1435
|
-
return this.spec.props.nodeViews[A(r.schema).table.name] = (a) => new t(a, e), new X(-1, !1);
|
|
1436
|
-
},
|
|
1437
|
-
apply(l, r) {
|
|
1438
|
-
return r.apply(l);
|
|
1439
|
-
}
|
|
1440
|
-
},
|
|
1441
|
-
props: {
|
|
1442
|
-
attributes(l) {
|
|
1443
|
-
return k.getState(l).activeHandle > -1 ? { class: "resize-cursor" } : void 0;
|
|
1444
|
-
},
|
|
1445
|
-
handleDOMEvents: {
|
|
1446
|
-
mousemove(l, r) {
|
|
1447
|
-
!l.editable || kn(l, r, o, n);
|
|
1448
|
-
},
|
|
1449
|
-
mouseleave(l) {
|
|
1450
|
-
!l.editable || An(l);
|
|
1451
|
-
},
|
|
1452
|
-
mousedown(l, r) {
|
|
1453
|
-
!l.editable || Mn(l, r, e);
|
|
188
|
+
n = l[0], o = l[l.length - 1];
|
|
189
|
+
const r = b(n, t.selection), s = g(0, t.selection), i = t.doc.resolve(
|
|
190
|
+
r[r.length - 1].pos
|
|
191
|
+
);
|
|
192
|
+
let a;
|
|
193
|
+
for (let c = o; c >= n; c--) {
|
|
194
|
+
const d = b(c, t.selection);
|
|
195
|
+
if (d && d.length) {
|
|
196
|
+
for (let m = s.length - 1; m >= 0; m--)
|
|
197
|
+
if (s[m].pos === d[0].pos) {
|
|
198
|
+
a = d[0];
|
|
199
|
+
break;
|
|
1454
200
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
const r = k.getState(l);
|
|
1458
|
-
return r.activeHandle > -1 ? Ln(l, r.activeHandle) : null;
|
|
1459
|
-
},
|
|
1460
|
-
nodeViews: {}
|
|
1461
|
-
}
|
|
1462
|
-
});
|
|
1463
|
-
}
|
|
1464
|
-
class X {
|
|
1465
|
-
constructor(e, t) {
|
|
1466
|
-
this.activeHandle = e, this.dragging = t, this.activeHandle = e, this.dragging = t;
|
|
1467
|
-
}
|
|
1468
|
-
apply(e) {
|
|
1469
|
-
let t = this;
|
|
1470
|
-
const n = e.getMeta(k);
|
|
1471
|
-
if (n && n.setHandle != null)
|
|
1472
|
-
return new X(n.setHandle, null);
|
|
1473
|
-
if (n && n.setDragging !== void 0)
|
|
1474
|
-
return new X(t.activeHandle, n.setDragging);
|
|
1475
|
-
if (t.activeHandle > -1 && e.docChanged) {
|
|
1476
|
-
let s = e.mapping.map(t.activeHandle, -1);
|
|
1477
|
-
pe(e.doc.resolve(s)) || (s = 0), t = new X(s, t.dragging);
|
|
201
|
+
if (a)
|
|
202
|
+
break;
|
|
1478
203
|
}
|
|
1479
|
-
return t;
|
|
1480
204
|
}
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
205
|
+
const u = t.doc.resolve(a.pos);
|
|
206
|
+
return { $anchor: i, $head: u, indexes: l };
|
|
207
|
+
}, F = (e, t) => {
|
|
208
|
+
let n = e, o = e;
|
|
209
|
+
for (let c = e; c >= 0; c--)
|
|
210
|
+
g(c, t.selection).forEach((m) => {
|
|
211
|
+
const f = m.node.attrs.rowspan + c - 1;
|
|
212
|
+
f >= n && (n = c), f > o && (o = f);
|
|
213
|
+
});
|
|
214
|
+
for (let c = e; c <= o; c++)
|
|
215
|
+
g(c, t.selection).forEach((m) => {
|
|
216
|
+
const f = m.node.attrs.rowspan + c - 1;
|
|
217
|
+
m.node.attrs.rowspan > 1 && f > o && (o = f);
|
|
218
|
+
});
|
|
219
|
+
const l = [];
|
|
220
|
+
for (let c = n; c <= o; c++) {
|
|
221
|
+
const d = g(c, t.selection);
|
|
222
|
+
d && d.length && l.push(c);
|
|
223
|
+
}
|
|
224
|
+
n = l[0], o = l[l.length - 1];
|
|
225
|
+
const r = g(n, t.selection), s = b(0, t.selection), i = t.doc.resolve(r[r.length - 1].pos);
|
|
226
|
+
let a;
|
|
227
|
+
for (let c = o; c >= n; c--) {
|
|
228
|
+
const d = g(c, t.selection);
|
|
229
|
+
if (d && d.length) {
|
|
230
|
+
for (let m = s.length - 1; m >= 0; m--)
|
|
231
|
+
if (s[m].pos === d[0].pos) {
|
|
232
|
+
a = d[0];
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
if (a)
|
|
236
|
+
break;
|
|
1498
237
|
}
|
|
1499
238
|
}
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
239
|
+
const u = t.doc.resolve(a.pos);
|
|
240
|
+
return { $anchor: i, $head: u, indexes: l };
|
|
241
|
+
};
|
|
242
|
+
function $e(e, t, n, o = !0) {
|
|
243
|
+
const l = k(e.selection);
|
|
244
|
+
if (!l)
|
|
245
|
+
return e;
|
|
246
|
+
const { indexes: r } = B(t, e), { indexes: s } = B(n, e);
|
|
247
|
+
if (r.includes(n))
|
|
248
|
+
return e;
|
|
249
|
+
const i = Ne(
|
|
250
|
+
l,
|
|
251
|
+
r,
|
|
252
|
+
s,
|
|
253
|
+
0
|
|
254
|
+
), a = T(e).replaceWith(
|
|
255
|
+
l.pos,
|
|
256
|
+
l.pos + l.node.nodeSize,
|
|
257
|
+
i
|
|
1514
258
|
);
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
}
|
|
1520
|
-
function a(i) {
|
|
1521
|
-
if (!i.which)
|
|
1522
|
-
return r(i);
|
|
1523
|
-
const c = k.getState(o.state), d = Be(c.dragging, i, t);
|
|
1524
|
-
Rn(o, c.activeHandle, d, t);
|
|
1525
|
-
}
|
|
1526
|
-
return window.addEventListener("mouseup", r), window.addEventListener("mousemove", a), e.preventDefault(), !0;
|
|
259
|
+
if (!o)
|
|
260
|
+
return a;
|
|
261
|
+
const u = h.get(i), c = l.start, d = n, m = u.positionAt(u.height - 1, d, i), f = a.doc.resolve(c + m), A = C.colSelection, R = u.positionAt(0, d, i), v = a.doc.resolve(c + R);
|
|
262
|
+
return a.setSelection(A(f, v));
|
|
1527
263
|
}
|
|
1528
|
-
function
|
|
1529
|
-
const
|
|
1530
|
-
if (s)
|
|
1531
|
-
return s;
|
|
1532
|
-
const l = o.domAtPos(e);
|
|
1533
|
-
let a = l.node.childNodes[l.offset].offsetWidth, i = t;
|
|
1534
|
-
if (n)
|
|
1535
|
-
for (let c = 0; c < t; c++)
|
|
1536
|
-
n[c] && (a -= n[c], i--);
|
|
1537
|
-
return a / i;
|
|
1538
|
-
}
|
|
1539
|
-
function Nn(o) {
|
|
1540
|
-
for (; o && o.nodeName != "TD" && o.nodeName != "TH"; )
|
|
1541
|
-
o = o.classList.contains("ProseMirror") ? null : o.parentNode;
|
|
1542
|
-
return o;
|
|
1543
|
-
}
|
|
1544
|
-
function Fe(o, e, t) {
|
|
1545
|
-
const n = o.posAtCoords({ left: e.clientX, top: e.clientY });
|
|
1546
|
-
if (!n)
|
|
1547
|
-
return -1;
|
|
1548
|
-
const { pos: s } = n, l = V(o.state.doc.resolve(s));
|
|
264
|
+
function _e(e, t, n, o = !0) {
|
|
265
|
+
const l = k(e.selection);
|
|
1549
266
|
if (!l)
|
|
1550
|
-
return
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
continue;
|
|
1569
|
-
const f = l.map[d], { attrs: u } = s.nodeAt(f), p = u.colspan == 1 ? 0 : a - l.colCount(f);
|
|
1570
|
-
if (u.colwidth && u.colwidth[p] == t)
|
|
1571
|
-
continue;
|
|
1572
|
-
const h = u.colwidth ? u.colwidth.slice() : Tn(u.colspan);
|
|
1573
|
-
h[p] = t, i.setNodeMarkup(r + f, null, y(u, "colwidth", h));
|
|
1574
|
-
}
|
|
1575
|
-
i.docChanged && o.dispatch(i);
|
|
1576
|
-
}
|
|
1577
|
-
function Rn(o, e, t, n) {
|
|
1578
|
-
const s = o.state.doc.resolve(e), l = s.node(-1), r = s.start(-1), a = g.get(l).colCount(s.pos - r) + s.nodeAfter.attrs.colspan - 1;
|
|
1579
|
-
let i = o.domAtPos(s.start(-1)).node;
|
|
1580
|
-
for (; i.nodeName != "TABLE"; )
|
|
1581
|
-
i = i.parentNode;
|
|
1582
|
-
he(l, i.firstChild, i, n, a, t);
|
|
1583
|
-
}
|
|
1584
|
-
function Tn(o) {
|
|
1585
|
-
const e = [];
|
|
1586
|
-
for (let t = 0; t < o; t++)
|
|
1587
|
-
e.push(0);
|
|
1588
|
-
return e;
|
|
1589
|
-
}
|
|
1590
|
-
function Ln(o, e) {
|
|
1591
|
-
const t = [], n = o.doc.resolve(e), s = n.node(-1), l = g.get(s), r = n.start(-1), a = l.colCount(n.pos - r) + n.nodeAfter.attrs.colspan;
|
|
1592
|
-
for (let i = 0; i < l.height; i++) {
|
|
1593
|
-
const c = a + i * l.width - 1;
|
|
1594
|
-
if ((a == l.width || l.map[c] != l.map[c + 1]) && (i == 0 || l.map[c - 1] != l.map[c - 1 - l.width])) {
|
|
1595
|
-
const d = l.map[c], f = r + d + s.nodeAt(d).nodeSize - 1, u = document.createElement("div");
|
|
1596
|
-
u.className = "column-resize-handle", t.push(Me.widget(f, u));
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
return Se.create(o.doc, t);
|
|
1600
|
-
}
|
|
1601
|
-
function vn(o) {
|
|
1602
|
-
if (!o.size)
|
|
1603
|
-
return null;
|
|
1604
|
-
let { content: e, openStart: t, openEnd: n } = o;
|
|
1605
|
-
for (; e.childCount == 1 && (t > 0 && n > 0 || e.firstChild.type.spec.tableRole == "table"); )
|
|
1606
|
-
t--, n--, e = e.firstChild.content;
|
|
1607
|
-
const s = e.firstChild, l = s.type.spec.tableRole, r = s.type.schema, a = [];
|
|
1608
|
-
if (l == "row")
|
|
1609
|
-
for (let i = 0; i < e.childCount; i++) {
|
|
1610
|
-
let c = e.child(i).content;
|
|
1611
|
-
const d = i ? 0 : Math.max(0, t - 1), f = i < e.childCount - 1 ? 0 : Math.max(0, n - 1);
|
|
1612
|
-
(d || f) && (c = me(A(r).row, new _(c, d, f)).content), a.push(c);
|
|
1613
|
-
}
|
|
1614
|
-
else if (l == "cell" || l == "header_cell")
|
|
1615
|
-
a.push(
|
|
1616
|
-
t || n ? me(A(r).row, new _(e, t, n)).content : e
|
|
1617
|
-
);
|
|
1618
|
-
else
|
|
1619
|
-
return null;
|
|
1620
|
-
return En(r, a);
|
|
267
|
+
return e;
|
|
268
|
+
const { indexes: r } = F(t, e), { indexes: s } = F(n, e);
|
|
269
|
+
if (r.includes(n))
|
|
270
|
+
return e;
|
|
271
|
+
const i = xe(
|
|
272
|
+
l,
|
|
273
|
+
r,
|
|
274
|
+
s,
|
|
275
|
+
0
|
|
276
|
+
), a = T(e).replaceWith(
|
|
277
|
+
l.pos,
|
|
278
|
+
l.pos + l.node.nodeSize,
|
|
279
|
+
i
|
|
280
|
+
);
|
|
281
|
+
if (!o)
|
|
282
|
+
return a;
|
|
283
|
+
const u = h.get(i), c = l.start, d = n, m = u.positionAt(d, u.width - 1, i), f = a.doc.resolve(c + m), A = C.rowSelection, R = u.positionAt(d, 0, i), v = a.doc.resolve(c + R);
|
|
284
|
+
return a.setSelection(A(f, v));
|
|
1621
285
|
}
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
286
|
+
const M = ae({
|
|
287
|
+
tableGroup: "block",
|
|
288
|
+
cellContent: "paragraph",
|
|
289
|
+
cellAttributes: {
|
|
290
|
+
alignment: {
|
|
291
|
+
default: "left",
|
|
292
|
+
getFromDOM: (e) => e.style.textAlign || "left",
|
|
293
|
+
setDOMAttr: (e, t) => {
|
|
294
|
+
t.style = `text-align: ${e || "left"}`;
|
|
295
|
+
}
|
|
1630
296
|
}
|
|
1631
297
|
}
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
const l =
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
298
|
+
}), E = w("table", () => ({
|
|
299
|
+
...M.table,
|
|
300
|
+
parseMarkdown: {
|
|
301
|
+
match: (e) => e.type === "table",
|
|
302
|
+
runner: (e, t, n) => {
|
|
303
|
+
const o = t.align, l = t.children.map((r, s) => ({
|
|
304
|
+
...r,
|
|
305
|
+
align: o,
|
|
306
|
+
isHeader: s === 0
|
|
307
|
+
}));
|
|
308
|
+
e.openNode(n), e.next(l), e.closeNode();
|
|
1641
309
|
}
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
310
|
+
},
|
|
311
|
+
toMarkdown: {
|
|
312
|
+
match: (e) => e.type.name === "table",
|
|
313
|
+
runner: (e, t) => {
|
|
314
|
+
var l;
|
|
315
|
+
const n = (l = t.content.firstChild) == null ? void 0 : l.content;
|
|
316
|
+
if (!n)
|
|
317
|
+
return;
|
|
318
|
+
const o = [];
|
|
319
|
+
n.forEach((r) => {
|
|
320
|
+
o.push(r.attrs.alignment);
|
|
321
|
+
}), e.openNode("table", void 0, { align: o }), e.next(t.content), e.closeNode();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
})), I = w("table_row", () => ({
|
|
325
|
+
...M.table_row,
|
|
326
|
+
parseMarkdown: {
|
|
327
|
+
match: (e) => e.type === "tableRow",
|
|
328
|
+
runner: (e, t, n) => {
|
|
329
|
+
const o = t.align, l = t.children.map((r, s) => ({
|
|
330
|
+
...r,
|
|
331
|
+
align: o[s],
|
|
332
|
+
isHeader: t.isHeader
|
|
333
|
+
}));
|
|
334
|
+
e.openNode(n), e.next(l), e.closeNode();
|
|
1663
335
|
}
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
const i = [], c = t[a % e];
|
|
1670
|
-
for (let d = 0; d < c.childCount; d++) {
|
|
1671
|
-
let f = c.child(d);
|
|
1672
|
-
r + f.attrs.rowspan > s && (f = f.type.create(
|
|
1673
|
-
y(f.attrs, "rowspan", Math.max(1, s - f.attrs.rowspan)),
|
|
1674
|
-
f.content
|
|
1675
|
-
)), i.push(f);
|
|
1676
|
-
}
|
|
1677
|
-
l.push($.from(i));
|
|
336
|
+
},
|
|
337
|
+
toMarkdown: {
|
|
338
|
+
match: (e) => e.type.name === "table_row",
|
|
339
|
+
runner: (e, t) => {
|
|
340
|
+
e.openNode("tableRow"), e.next(t.content), e.closeNode();
|
|
1678
341
|
}
|
|
1679
|
-
t = l, e = s;
|
|
1680
342
|
}
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
const p = t.child(f);
|
|
1689
|
-
u += p.nodeSize;
|
|
1690
|
-
const h = [];
|
|
1691
|
-
let b;
|
|
1692
|
-
p.lastChild == null || p.lastChild.type == i.cell ? b = c || (c = i.cell.createAndFill()) : b = d || (d = i.header_cell.createAndFill());
|
|
1693
|
-
for (let w = e.width; w < s; w++)
|
|
1694
|
-
h.push(b);
|
|
1695
|
-
o.insert(o.mapping.slice(r).map(u - 1 + n), h);
|
|
343
|
+
})), O = w("table_cell", () => ({
|
|
344
|
+
...M.table_cell,
|
|
345
|
+
parseMarkdown: {
|
|
346
|
+
match: (e) => e.type === "tableCell" && !e.isHeader,
|
|
347
|
+
runner: (e, t, n) => {
|
|
348
|
+
const o = t.align;
|
|
349
|
+
e.openNode(n, { alignment: o }).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode();
|
|
1696
350
|
}
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
w ? d || (d = i.header_cell.createAndFill()) : c || (c = i.cell.createAndFill())
|
|
1703
|
-
);
|
|
351
|
+
},
|
|
352
|
+
toMarkdown: {
|
|
353
|
+
match: (e) => e.type.name === "table_cell",
|
|
354
|
+
runner: (e, t) => {
|
|
355
|
+
e.openNode("tableCell").next(t.content).closeNode();
|
|
1704
356
|
}
|
|
1705
|
-
const u = i.row.create(null, $.from(f)), p = [];
|
|
1706
|
-
for (let h = e.height; h < l; h++)
|
|
1707
|
-
p.push(u);
|
|
1708
|
-
o.insert(o.mapping.slice(r).map(n + t.nodeSize - 2), p);
|
|
1709
357
|
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
const d = r * e.width + c, f = e.map[d];
|
|
1718
|
-
if (e.map[d - e.width] == f) {
|
|
1719
|
-
i = !0;
|
|
1720
|
-
const u = t.nodeAt(f), { top: p, left: h } = e.findCell(f);
|
|
1721
|
-
o.setNodeMarkup(
|
|
1722
|
-
o.mapping.slice(a).map(f + n),
|
|
1723
|
-
null,
|
|
1724
|
-
y(u.attrs, "rowspan", r - p)
|
|
1725
|
-
), o.insert(
|
|
1726
|
-
o.mapping.slice(a).map(e.positionAt(r, h, t)),
|
|
1727
|
-
u.type.createAndFill(y(u.attrs, "rowspan", p + u.attrs.rowspan - r))
|
|
1728
|
-
), c += u.attrs.colspan - 1;
|
|
358
|
+
})), Y = w("table_header", () => ({
|
|
359
|
+
...M.table_header,
|
|
360
|
+
parseMarkdown: {
|
|
361
|
+
match: (e) => e.type === "tableCell" && !!e.isHeader,
|
|
362
|
+
runner: (e, t, n) => {
|
|
363
|
+
const o = t.align;
|
|
364
|
+
e.openNode(n, { alignment: o }), e.openNode(e.schema.nodes.paragraph), e.next(t.children), e.closeNode(), e.closeNode();
|
|
1729
365
|
}
|
|
1730
|
-
}
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
366
|
+
},
|
|
367
|
+
toMarkdown: {
|
|
368
|
+
match: (e) => e.type.name === "table_header",
|
|
369
|
+
runner: (e, t) => {
|
|
370
|
+
e.openNode("tableCell"), e.next(t.content), e.closeNode();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
})), Ee = Ce(() => new le(
|
|
374
|
+
/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,
|
|
375
|
+
(e, t, n, o) => {
|
|
376
|
+
var i, a;
|
|
377
|
+
const l = e.doc.resolve(n);
|
|
378
|
+
if (!l.node(-1).canReplaceWith(l.index(-1), l.indexAfter(-1), E.type()))
|
|
379
|
+
return null;
|
|
380
|
+
const r = Z(
|
|
381
|
+
Number((i = t.groups) == null ? void 0 : i.row),
|
|
382
|
+
Number((a = t.groups) == null ? void 0 : a.col)
|
|
383
|
+
), s = e.tr.replaceRangeWith(n, o, r).scrollIntoView();
|
|
384
|
+
return s.setSelection(re.create(s.doc, n + 3));
|
|
385
|
+
}
|
|
386
|
+
)), ee = p("GoToPrevTableCell", () => () => L(-1)), te = p("GoToNextTableCell", () => () => L(1)), oe = p("BreakTable", () => () => (e, t) => {
|
|
387
|
+
if (!y(e))
|
|
1735
388
|
return !1;
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
}
|
|
1752
|
-
return
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
389
|
+
const { $head: n } = e.selection, o = n.after(), l = e.tr.replaceWith(o, o, W.type().createAndFill());
|
|
390
|
+
return l.setSelection(K.near(l.doc.resolve(o), 1)).scrollIntoView(), t == null || t(l), !0;
|
|
391
|
+
}), Ie = p("InsertTable", () => ({ row: e, col: t } = {}) => (n, o) => {
|
|
392
|
+
const { selection: l, tr: r } = n, { from: s } = l, i = Z(e, t), a = r.replaceSelectionWith(i), u = K.findFrom(a.doc.resolve(s), 1, !0);
|
|
393
|
+
return u && (o == null || o(a.setSelection(u))), !0;
|
|
394
|
+
}), Oe = p("MoveRow", () => ({ from: e, to: t } = {}) => (n, o) => {
|
|
395
|
+
const { tr: l } = n, r = o == null ? void 0 : o(_e(l, e ?? 0, t ?? 0, !0));
|
|
396
|
+
return Boolean(r);
|
|
397
|
+
}), De = p("MoveCol", () => ({ from: e, to: t } = {}) => (n, o) => {
|
|
398
|
+
const { tr: l } = n, r = o == null ? void 0 : o($e(l, e ?? 0, t ?? 0, !0));
|
|
399
|
+
return Boolean(r);
|
|
400
|
+
}), Pe = p("SelectRow", () => (e = 0) => (t, n) => {
|
|
401
|
+
const { tr: o } = t, l = n == null ? void 0 : n(Re(e)(o));
|
|
402
|
+
return Boolean(l);
|
|
403
|
+
}), Be = p("SelectCol", () => (e = 0) => (t, n) => {
|
|
404
|
+
const { tr: o } = t, l = n == null ? void 0 : n(ve(e)(o));
|
|
405
|
+
return Boolean(l);
|
|
406
|
+
}), Fe = p("SelectTable", () => () => (e, t) => {
|
|
407
|
+
const { tr: n } = e, o = t == null ? void 0 : t(Ae(n));
|
|
408
|
+
return Boolean(o);
|
|
409
|
+
}), He = p("DeleteSelectedCells", () => () => (e, t) => {
|
|
410
|
+
const { selection: n } = e;
|
|
411
|
+
if (!(n instanceof C))
|
|
412
|
+
return !1;
|
|
413
|
+
const o = n.isRowSelection(), l = n.isColSelection();
|
|
414
|
+
return o && l ? ie(e, t) : l ? de(e, t) : ue(e, t);
|
|
415
|
+
}), We = p("AddColBefore", () => () => me), Ke = p("AddColAfter", () => () => fe), Le = p("AddRowBefore", () => () => (e, t) => {
|
|
416
|
+
if (!y(e))
|
|
417
|
+
return !1;
|
|
418
|
+
if (t) {
|
|
419
|
+
const n = z(e);
|
|
420
|
+
t(U(e.tr, n, n.top));
|
|
1760
421
|
}
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
);
|
|
422
|
+
return !0;
|
|
423
|
+
}), ze = p("AddRowAfter", () => () => (e, t) => {
|
|
424
|
+
if (!y(e))
|
|
425
|
+
return !1;
|
|
426
|
+
if (t) {
|
|
427
|
+
const n = z(e);
|
|
428
|
+
t(U(e.tr, n, n.bottom));
|
|
1769
429
|
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
)
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
const Dn = new B("fix-tables");
|
|
1778
|
-
function ot(o, e, t, n) {
|
|
1779
|
-
const s = o.childCount, l = e.childCount;
|
|
1780
|
-
e:
|
|
1781
|
-
for (let r = 0, a = 0; r < l; r++) {
|
|
1782
|
-
const i = e.child(r);
|
|
1783
|
-
for (let c = a, d = Math.min(s, r + 3); c < d; c++)
|
|
1784
|
-
if (o.child(c) == i) {
|
|
1785
|
-
a = c + 1, t += i.nodeSize;
|
|
1786
|
-
continue e;
|
|
1787
|
-
}
|
|
1788
|
-
n(i, t), a < s && o.child(a).sameMarkup(i) ? ot(o.child(a), i, t + 1, n) : i.nodesBetween(0, i.content.size, n, t + 1), t += i.nodeSize;
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
function On(o, e) {
|
|
1792
|
-
let t;
|
|
1793
|
-
const n = (s, l) => {
|
|
1794
|
-
s.type.spec.tableRole == "table" && (t = _n(o, s, l, t));
|
|
1795
|
-
};
|
|
1796
|
-
return e ? e.doc != o.doc && ot(e.doc, o.doc, 0, n) : o.doc.descendants(n), t;
|
|
1797
|
-
}
|
|
1798
|
-
function _n(o, e, t, n) {
|
|
1799
|
-
const s = g.get(e);
|
|
1800
|
-
if (!s.problems)
|
|
1801
|
-
return n;
|
|
1802
|
-
n || (n = o.tr);
|
|
1803
|
-
const l = [];
|
|
1804
|
-
for (let i = 0; i < s.height; i++)
|
|
1805
|
-
l.push(0);
|
|
1806
|
-
for (let i = 0; i < s.problems.length; i++) {
|
|
1807
|
-
const c = s.problems[i];
|
|
1808
|
-
if (c.type == "collision") {
|
|
1809
|
-
const d = e.nodeAt(c.pos);
|
|
1810
|
-
for (let f = 0; f < d.attrs.rowspan; f++)
|
|
1811
|
-
l[c.row + f] += c.n;
|
|
1812
|
-
n.setNodeMarkup(
|
|
1813
|
-
n.mapping.map(t + 1 + c.pos),
|
|
1814
|
-
null,
|
|
1815
|
-
F(d.attrs, d.attrs.colspan - c.n, c.n)
|
|
1816
|
-
);
|
|
1817
|
-
} else if (c.type == "missing")
|
|
1818
|
-
l[c.row] += c.n;
|
|
1819
|
-
else if (c.type == "overlong_rowspan") {
|
|
1820
|
-
const d = e.nodeAt(c.pos);
|
|
1821
|
-
n.setNodeMarkup(
|
|
1822
|
-
n.mapping.map(t + 1 + c.pos),
|
|
1823
|
-
null,
|
|
1824
|
-
y(d.attrs, "rowspan", d.attrs.rowspan - c.n)
|
|
1825
|
-
);
|
|
1826
|
-
} else if (c.type == "colwidth mismatch") {
|
|
1827
|
-
const d = e.nodeAt(c.pos);
|
|
1828
|
-
n.setNodeMarkup(
|
|
1829
|
-
n.mapping.map(t + 1 + c.pos),
|
|
1830
|
-
null,
|
|
1831
|
-
y(d.attrs, "colwidth", c.colwidth)
|
|
1832
|
-
);
|
|
430
|
+
return !0;
|
|
431
|
+
}), Ge = p("SetAlign", () => (e = "left") => pe("alignment", e)), je = G("tableKeymap", {
|
|
432
|
+
NextCell: {
|
|
433
|
+
shortcuts: ["Mod-]", "Tab"],
|
|
434
|
+
command: (e) => {
|
|
435
|
+
const t = e.get(S);
|
|
436
|
+
return () => t.call(te.key);
|
|
1833
437
|
}
|
|
1834
|
-
}
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
if (u > 0) {
|
|
1841
|
-
let p = "cell";
|
|
1842
|
-
d.firstChild && (p = d.firstChild.type.spec.tableRole);
|
|
1843
|
-
const h = [];
|
|
1844
|
-
for (let w = 0; w < u; w++)
|
|
1845
|
-
h.push(A(o.schema)[p].createAndFill());
|
|
1846
|
-
const b = (i == 0 || r == i - 1) && a == i ? c + 1 : f - 1;
|
|
1847
|
-
n.insert(n.mapping.map(b), h);
|
|
438
|
+
},
|
|
439
|
+
PrevCell: {
|
|
440
|
+
shortcuts: ["Mod-[", "Shift-Tab"],
|
|
441
|
+
command: (e) => {
|
|
442
|
+
const t = e.get(S);
|
|
443
|
+
return () => t.call(ee.key);
|
|
1848
444
|
}
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
const
|
|
1854
|
-
|
|
1855
|
-
for (; e && e != o.dom; e = e.parentNode)
|
|
1856
|
-
if (e.nodeName == "TD" || e.nodeName == "TH")
|
|
1857
|
-
return e;
|
|
1858
|
-
}
|
|
1859
|
-
function fe(o, e) {
|
|
1860
|
-
const t = o.posAtCoords({
|
|
1861
|
-
left: e.clientX,
|
|
1862
|
-
top: e.clientY
|
|
1863
|
-
});
|
|
1864
|
-
return t && t ? V(o.state.doc.resolve(t.pos)) : null;
|
|
1865
|
-
}
|
|
1866
|
-
function zn(o, e) {
|
|
1867
|
-
const t = e;
|
|
1868
|
-
if (t.ctrlKey || t.metaKey)
|
|
1869
|
-
return;
|
|
1870
|
-
const n = je(o, t.target);
|
|
1871
|
-
let s;
|
|
1872
|
-
if (t.shiftKey && o.state.selection instanceof m)
|
|
1873
|
-
l(o.state.selection.$anchorCell, t), t.preventDefault();
|
|
1874
|
-
else if (t.shiftKey && n && (s = V(o.state.selection.$anchor)) != null && fe(o, t).pos != s.pos)
|
|
1875
|
-
l(s, t), t.preventDefault();
|
|
1876
|
-
else if (!n)
|
|
1877
|
-
return;
|
|
1878
|
-
function l(i, c) {
|
|
1879
|
-
let d = fe(o, c);
|
|
1880
|
-
const f = D.getState(o.state) == null;
|
|
1881
|
-
if (!d || !xe(i, d))
|
|
1882
|
-
if (f)
|
|
1883
|
-
d = i;
|
|
1884
|
-
else
|
|
1885
|
-
return;
|
|
1886
|
-
const u = new m(i, d);
|
|
1887
|
-
if (f || !o.state.selection.eq(u)) {
|
|
1888
|
-
const p = o.state.tr.setSelection(u);
|
|
1889
|
-
f && p.setMeta(D, i.pos), o.dispatch(p);
|
|
445
|
+
},
|
|
446
|
+
ExitTable: {
|
|
447
|
+
shortcuts: ["Mod-Enter"],
|
|
448
|
+
command: (e) => {
|
|
449
|
+
const t = e.get(S);
|
|
450
|
+
return () => t.call(oe.key);
|
|
1890
451
|
}
|
|
1891
452
|
}
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
d = o.state.doc.resolve(c);
|
|
1900
|
-
else if (je(o, i.target) != n && (d = fe(o, t), !d))
|
|
1901
|
-
return r();
|
|
1902
|
-
d && l(d, i);
|
|
1903
|
-
}
|
|
1904
|
-
o.root.addEventListener("mouseup", r), o.root.addEventListener("dragstart", r), o.root.addEventListener("mousemove", a);
|
|
1905
|
-
}
|
|
1906
|
-
function Fn(o, e) {
|
|
1907
|
-
const t = o.state.doc, n = V(t.resolve(e));
|
|
1908
|
-
return n ? (o.dispatch(o.state.tr.setSelection(new m(n))), !0) : !1;
|
|
1909
|
-
}
|
|
1910
|
-
function te(o, e, t) {
|
|
1911
|
-
return t.eq(o.selection) ? !1 : (e && e(o.tr.setSelection(t).scrollIntoView()), !0);
|
|
1912
|
-
}
|
|
1913
|
-
function st(o, e, t) {
|
|
1914
|
-
if (!(o.state.selection instanceof E))
|
|
1915
|
-
return null;
|
|
1916
|
-
const { $head: n } = o.state.selection;
|
|
1917
|
-
for (let s = n.depth - 1; s >= 0; s--) {
|
|
1918
|
-
const l = n.node(s);
|
|
1919
|
-
if ((t < 0 ? n.index(s) : n.indexAfter(s)) != (t < 0 ? 0 : l.childCount))
|
|
1920
|
-
return null;
|
|
1921
|
-
if (l.type.spec.tableRole == "cell" || l.type.spec.tableRole == "header_cell") {
|
|
1922
|
-
const a = n.before(s), i = e == "vert" ? t > 0 ? "down" : "up" : t > 0 ? "right" : "left";
|
|
1923
|
-
return o.endOfTextblock(i) ? a : null;
|
|
453
|
+
}), N = "footnote_definition", H = "footnoteDefinition", Ve = w("footnote_definition", () => ({
|
|
454
|
+
group: "block",
|
|
455
|
+
content: "block+",
|
|
456
|
+
defining: !0,
|
|
457
|
+
attrs: {
|
|
458
|
+
label: {
|
|
459
|
+
default: ""
|
|
1924
460
|
}
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
}
|
|
1928
|
-
function Z(o, e) {
|
|
1929
|
-
return (t, n, s) => {
|
|
1930
|
-
const l = t.selection;
|
|
1931
|
-
if (l instanceof m)
|
|
1932
|
-
return te(
|
|
1933
|
-
t,
|
|
1934
|
-
n,
|
|
1935
|
-
S.near(l.$headCell, e)
|
|
1936
|
-
);
|
|
1937
|
-
if (o != "horiz" && !l.empty)
|
|
1938
|
-
return !1;
|
|
1939
|
-
const r = st(s, o, e);
|
|
1940
|
-
if (r == null)
|
|
1941
|
-
return !1;
|
|
1942
|
-
if (o == "horiz")
|
|
1943
|
-
return te(
|
|
1944
|
-
t,
|
|
1945
|
-
n,
|
|
1946
|
-
S.near(t.doc.resolve(l.head + e), e)
|
|
1947
|
-
);
|
|
461
|
+
},
|
|
462
|
+
parseDOM: [
|
|
1948
463
|
{
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
return (t, n, s) => {
|
|
1957
|
-
let l = t.selection;
|
|
1958
|
-
if (!(l instanceof m)) {
|
|
1959
|
-
const a = st(s, o, e);
|
|
1960
|
-
if (a == null)
|
|
1961
|
-
return !1;
|
|
1962
|
-
l = new m(t.doc.resolve(a));
|
|
1963
|
-
}
|
|
1964
|
-
const r = et(l.$headCell, o, e);
|
|
1965
|
-
return r ? te(
|
|
1966
|
-
t,
|
|
1967
|
-
n,
|
|
1968
|
-
new m(l.$anchorCell, r)
|
|
1969
|
-
) : !1;
|
|
1970
|
-
};
|
|
1971
|
-
}
|
|
1972
|
-
function ee(o, e) {
|
|
1973
|
-
const t = o.selection;
|
|
1974
|
-
if (!(t instanceof m))
|
|
1975
|
-
return !1;
|
|
1976
|
-
if (e) {
|
|
1977
|
-
const n = o.tr, s = A(o.schema).cell.createAndFill().content;
|
|
1978
|
-
t.forEachCell((l, r) => {
|
|
1979
|
-
l.content.eq(s) || n.replace(
|
|
1980
|
-
n.mapping.map(r + 1),
|
|
1981
|
-
n.mapping.map(r + l.nodeSize - 1),
|
|
1982
|
-
new _(s, 0, 0)
|
|
1983
|
-
);
|
|
1984
|
-
}), n.docChanged && e(n);
|
|
1985
|
-
}
|
|
1986
|
-
return !0;
|
|
1987
|
-
}
|
|
1988
|
-
const Bn = St({
|
|
1989
|
-
ArrowLeft: Z("horiz", -1),
|
|
1990
|
-
ArrowRight: Z("horiz", 1),
|
|
1991
|
-
ArrowUp: Z("vert", -1),
|
|
1992
|
-
ArrowDown: Z("vert", 1),
|
|
1993
|
-
"Shift-ArrowLeft": Q("horiz", -1),
|
|
1994
|
-
"Shift-ArrowRight": Q("horiz", 1),
|
|
1995
|
-
"Shift-ArrowUp": Q("vert", -1),
|
|
1996
|
-
"Shift-ArrowDown": Q("vert", 1),
|
|
1997
|
-
Backspace: ee,
|
|
1998
|
-
"Mod-Backspace": ee,
|
|
1999
|
-
Delete: ee,
|
|
2000
|
-
"Mod-Delete": ee
|
|
2001
|
-
});
|
|
2002
|
-
function Wn(o, e, t) {
|
|
2003
|
-
if (!M(o.state))
|
|
2004
|
-
return !1;
|
|
2005
|
-
let n = vn(t);
|
|
2006
|
-
const s = o.state.selection;
|
|
2007
|
-
if (s instanceof m) {
|
|
2008
|
-
n || (n = {
|
|
2009
|
-
width: 1,
|
|
2010
|
-
height: 1,
|
|
2011
|
-
rows: [
|
|
2012
|
-
$.from(
|
|
2013
|
-
me(A(o.state.schema).cell, t)
|
|
2014
|
-
)
|
|
2015
|
-
]
|
|
2016
|
-
});
|
|
2017
|
-
const l = s.$anchorCell.node(-1), r = s.$anchorCell.start(-1), a = g.get(l).rectBetween(
|
|
2018
|
-
s.$anchorCell.pos - r,
|
|
2019
|
-
s.$headCell.pos - r
|
|
2020
|
-
);
|
|
2021
|
-
return n = $n(n, a.right - a.left, a.bottom - a.top), He(o.state, o.dispatch, r, a, n), !0;
|
|
2022
|
-
} else if (n) {
|
|
2023
|
-
const l = se(o.state), r = l.start(-1);
|
|
2024
|
-
return He(
|
|
2025
|
-
o.state,
|
|
2026
|
-
o.dispatch,
|
|
2027
|
-
r,
|
|
2028
|
-
g.get(l.node(-1)).findCell(l.pos - r),
|
|
2029
|
-
n
|
|
2030
|
-
), !0;
|
|
2031
|
-
} else
|
|
2032
|
-
return !1;
|
|
2033
|
-
}
|
|
2034
|
-
function Pn({ allowTableNodeSelection: o = !1 } = {}) {
|
|
2035
|
-
return new H({
|
|
2036
|
-
key: D,
|
|
2037
|
-
state: {
|
|
2038
|
-
init() {
|
|
2039
|
-
return null;
|
|
2040
|
-
},
|
|
2041
|
-
apply(e, t) {
|
|
2042
|
-
const n = e.getMeta(D);
|
|
2043
|
-
if (n != null)
|
|
2044
|
-
return n == -1 ? null : n;
|
|
2045
|
-
if (t == null || !e.docChanged)
|
|
2046
|
-
return t;
|
|
2047
|
-
const { deleted: s, pos: l } = e.mapping.mapResult(t);
|
|
2048
|
-
return s ? null : l;
|
|
2049
|
-
}
|
|
2050
|
-
},
|
|
2051
|
-
props: {
|
|
2052
|
-
decorations: Bt,
|
|
2053
|
-
handleDOMEvents: {
|
|
2054
|
-
mousedown: zn
|
|
2055
|
-
},
|
|
2056
|
-
createSelectionBetween(e) {
|
|
2057
|
-
return D.getState(e.state) != null ? e.state.selection : null;
|
|
464
|
+
tag: `dl[data-type="${N}"]`,
|
|
465
|
+
getAttrs: (e) => {
|
|
466
|
+
if (!(e instanceof HTMLElement))
|
|
467
|
+
throw $(e);
|
|
468
|
+
return {
|
|
469
|
+
label: e.dataset.label
|
|
470
|
+
};
|
|
2058
471
|
},
|
|
2059
|
-
|
|
2060
|
-
handleKeyDown: Bn,
|
|
2061
|
-
handlePaste: Wn
|
|
2062
|
-
},
|
|
2063
|
-
appendTransaction(e, t, n) {
|
|
2064
|
-
return Ht(
|
|
2065
|
-
n,
|
|
2066
|
-
On(n, t),
|
|
2067
|
-
o
|
|
2068
|
-
);
|
|
472
|
+
contentElement: "dd"
|
|
2069
473
|
}
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
const
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
node: {
|
|
2079
|
-
table: {
|
|
2080
|
-
...Y.table,
|
|
2081
|
-
parseMarkdown: {
|
|
2082
|
-
match: (e) => e.type === "table",
|
|
2083
|
-
runner: (e, t, n) => {
|
|
2084
|
-
const s = t.align, l = t.children.map((r, a) => ({
|
|
2085
|
-
...r,
|
|
2086
|
-
align: s,
|
|
2087
|
-
isHeader: a === 0
|
|
2088
|
-
}));
|
|
2089
|
-
e.openNode(n), e.next(l), e.closeNode();
|
|
2090
|
-
}
|
|
2091
|
-
},
|
|
2092
|
-
toMarkdown: {
|
|
2093
|
-
match: (e) => e.type.name === "table",
|
|
2094
|
-
runner: (e, t) => {
|
|
2095
|
-
var l;
|
|
2096
|
-
const n = (l = t.content.firstChild) == null ? void 0 : l.content;
|
|
2097
|
-
if (!n)
|
|
2098
|
-
return;
|
|
2099
|
-
const s = [];
|
|
2100
|
-
n.forEach((r) => {
|
|
2101
|
-
s.push(r.attrs.alignment);
|
|
2102
|
-
}), e.openNode("table", void 0, { align: s }), e.next(t.content), e.closeNode();
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
},
|
|
2106
|
-
table_row: {
|
|
2107
|
-
...Y.table_row,
|
|
2108
|
-
parseMarkdown: {
|
|
2109
|
-
match: (e) => e.type === "tableRow",
|
|
2110
|
-
runner: (e, t, n) => {
|
|
2111
|
-
const s = t.align, l = t.children.map((r, a) => ({
|
|
2112
|
-
...r,
|
|
2113
|
-
align: s[a],
|
|
2114
|
-
isHeader: t.isHeader
|
|
2115
|
-
}));
|
|
2116
|
-
e.openNode(n), e.next(l), e.closeNode();
|
|
2117
|
-
}
|
|
2118
|
-
},
|
|
2119
|
-
toMarkdown: {
|
|
2120
|
-
match: (e) => e.type.name === "table_row",
|
|
2121
|
-
runner: (e, t) => {
|
|
2122
|
-
e.openNode("tableRow"), e.next(t.content), e.closeNode();
|
|
2123
|
-
}
|
|
2124
|
-
}
|
|
2125
|
-
},
|
|
2126
|
-
table_cell: {
|
|
2127
|
-
...Y.table_cell,
|
|
2128
|
-
parseMarkdown: {
|
|
2129
|
-
match: (e) => e.type === "tableCell" && !e.isHeader,
|
|
2130
|
-
runner: (e, t, n) => {
|
|
2131
|
-
const s = t.align;
|
|
2132
|
-
e.openNode(n, { alignment: s }).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode();
|
|
2133
|
-
}
|
|
2134
|
-
},
|
|
2135
|
-
toMarkdown: {
|
|
2136
|
-
match: (e) => e.type.name === "table_cell",
|
|
2137
|
-
runner: (e, t) => {
|
|
2138
|
-
e.openNode("tableCell").next(t.content).closeNode();
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
474
|
+
],
|
|
475
|
+
toDOM: (e) => {
|
|
476
|
+
const t = e.attrs.label;
|
|
477
|
+
return [
|
|
478
|
+
"dl",
|
|
479
|
+
{
|
|
480
|
+
"data-label": t,
|
|
481
|
+
"data-type": N
|
|
2141
482
|
},
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
483
|
+
["dt", t],
|
|
484
|
+
["dd", 0]
|
|
485
|
+
];
|
|
486
|
+
},
|
|
487
|
+
parseMarkdown: {
|
|
488
|
+
match: ({ type: e }) => e === H,
|
|
489
|
+
runner: (e, t, n) => {
|
|
490
|
+
e.openNode(n, {
|
|
491
|
+
label: t.label
|
|
492
|
+
}).next(t.children).closeNode();
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
toMarkdown: {
|
|
496
|
+
match: (e) => e.type.name === N,
|
|
497
|
+
runner: (e, t) => {
|
|
498
|
+
e.openNode(H, void 0, {
|
|
499
|
+
label: t.attrs.label,
|
|
500
|
+
identifier: t.attrs.label
|
|
501
|
+
}).next(t.content).closeNode();
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
})), x = "footnote_reference", Ze = w("footnote_reference", () => ({
|
|
505
|
+
group: "inline",
|
|
506
|
+
inline: !0,
|
|
507
|
+
atom: !0,
|
|
508
|
+
attrs: {
|
|
509
|
+
label: {
|
|
510
|
+
default: ""
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
parseDOM: [
|
|
514
|
+
{
|
|
515
|
+
tag: `sup[data-type="${x}"]`,
|
|
516
|
+
getAttrs: (e) => {
|
|
517
|
+
if (!(e instanceof HTMLElement))
|
|
518
|
+
throw $(e);
|
|
519
|
+
return {
|
|
520
|
+
label: e.dataset.label
|
|
521
|
+
};
|
|
2157
522
|
}
|
|
2158
523
|
}
|
|
2159
|
-
}),
|
|
2160
|
-
inputRules: (e, t) => [
|
|
2161
|
-
new ue(/^\|\|\s$/, (n, s, l, r) => {
|
|
2162
|
-
const a = n.doc.resolve(l);
|
|
2163
|
-
if (!a.node(-1).canReplaceWith(a.index(-1), a.indexAfter(-1), e.table))
|
|
2164
|
-
return null;
|
|
2165
|
-
const i = ae(t.get(J)), c = n.tr.replaceRangeWith(l, r, i).scrollIntoView();
|
|
2166
|
-
return c.setSelection(E.create(c.doc, l + 3));
|
|
2167
|
-
}),
|
|
2168
|
-
new ue(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/, (n, s, l, r) => {
|
|
2169
|
-
var d, f;
|
|
2170
|
-
const a = n.doc.resolve(l);
|
|
2171
|
-
if (!a.node(-1).canReplaceWith(a.index(-1), a.indexAfter(-1), e.table))
|
|
2172
|
-
return null;
|
|
2173
|
-
const i = ae(
|
|
2174
|
-
t.get(J),
|
|
2175
|
-
Number((d = s.groups) == null ? void 0 : d.row),
|
|
2176
|
-
Number((f = s.groups) == null ? void 0 : f.col)
|
|
2177
|
-
), c = n.tr.replaceRangeWith(l, r, i).scrollIntoView();
|
|
2178
|
-
return c.setSelection(E.create(c.doc, l + 3));
|
|
2179
|
-
})
|
|
2180
524
|
],
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
[ne.NextCell]: O(qe, "Mod-]"),
|
|
2192
|
-
[ne.PrevCell]: O(Ke, "Mod-["),
|
|
2193
|
-
[ne.ExitTable]: O(Xe, "Mod-Enter")
|
|
525
|
+
toDOM: (e) => {
|
|
526
|
+
const t = e.attrs.label;
|
|
527
|
+
return [
|
|
528
|
+
"sup",
|
|
529
|
+
{
|
|
530
|
+
"data-label": t,
|
|
531
|
+
"data-type": x
|
|
532
|
+
},
|
|
533
|
+
t
|
|
534
|
+
];
|
|
2194
535
|
},
|
|
2195
|
-
|
|
2196
|
-
})
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
parseMarkdown: {
|
|
2211
|
-
match: (e) => e.type === "delete",
|
|
2212
|
-
runner: (e, t, n) => {
|
|
2213
|
-
e.openMark(n), e.next(t.children), e.closeMark(n);
|
|
2214
|
-
}
|
|
2215
|
-
},
|
|
2216
|
-
toMarkdown: {
|
|
2217
|
-
match: (e) => e.type.name === Ue,
|
|
2218
|
-
runner: (e, t) => {
|
|
2219
|
-
e.withMark(t, "delete");
|
|
2220
|
-
}
|
|
536
|
+
parseMarkdown: {
|
|
537
|
+
match: ({ type: e }) => e === "footnoteReference",
|
|
538
|
+
runner: (e, t, n) => {
|
|
539
|
+
e.addNode(n, {
|
|
540
|
+
label: t.label
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
toMarkdown: {
|
|
545
|
+
match: (e) => e.type.name === x,
|
|
546
|
+
runner: (e, t) => {
|
|
547
|
+
e.addNode("footnoteReference", void 0, void 0, {
|
|
548
|
+
label: t.attrs.label,
|
|
549
|
+
identifier: t.attrs.label
|
|
550
|
+
});
|
|
2221
551
|
}
|
|
2222
|
-
}),
|
|
2223
|
-
commands: (e) => [N(ge, () => At(e))],
|
|
2224
|
-
shortcuts: {
|
|
2225
|
-
[q.StrikeThrough]: O(ge, "Mod-Alt-x")
|
|
2226
552
|
}
|
|
2227
|
-
})),
|
|
2228
|
-
const
|
|
553
|
+
})), Ue = ne.extendSchema((e) => (t) => {
|
|
554
|
+
const n = e(t);
|
|
2229
555
|
return {
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
}
|
|
556
|
+
...n,
|
|
557
|
+
attrs: {
|
|
558
|
+
...n.attrs,
|
|
559
|
+
checked: {
|
|
560
|
+
default: null
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
parseDOM: [
|
|
564
|
+
{
|
|
565
|
+
tag: 'li[data-item-type="task"]',
|
|
566
|
+
getAttrs: (o) => {
|
|
567
|
+
if (!(o instanceof HTMLElement))
|
|
568
|
+
throw $(o);
|
|
569
|
+
return {
|
|
570
|
+
label: o.dataset.label,
|
|
571
|
+
listType: o.dataset["list-type"],
|
|
572
|
+
spread: o.dataset.spread,
|
|
573
|
+
checked: o.dataset.checked ? o.dataset.checked === "true" : null
|
|
574
|
+
};
|
|
2249
575
|
}
|
|
2250
|
-
],
|
|
2251
|
-
toDOM: (n) => {
|
|
2252
|
-
const s = document.createElement("input");
|
|
2253
|
-
return s.type = "checkbox", s.checked = n.attrs.checked, s.className = o.getClassName(n.attrs, "task-list-item_checkbox"), s.onchange = (l) => {
|
|
2254
|
-
const r = l.target;
|
|
2255
|
-
if (!(r instanceof HTMLInputElement))
|
|
2256
|
-
return;
|
|
2257
|
-
const a = t.get(U);
|
|
2258
|
-
if (!a.editable) {
|
|
2259
|
-
s.checked = !s.checked;
|
|
2260
|
-
return;
|
|
2261
|
-
}
|
|
2262
|
-
const { top: i, left: c } = r.getBoundingClientRect(), d = a.posAtCoords({ top: i, left: c });
|
|
2263
|
-
if (!d)
|
|
2264
|
-
return;
|
|
2265
|
-
const { tr: f } = a.state;
|
|
2266
|
-
a.dispatch(
|
|
2267
|
-
f.setNodeMarkup(d.inside, void 0, {
|
|
2268
|
-
checked: r.checked
|
|
2269
|
-
})
|
|
2270
|
-
);
|
|
2271
|
-
}, [
|
|
2272
|
-
"li",
|
|
2273
|
-
{
|
|
2274
|
-
"data-type": "task-item",
|
|
2275
|
-
"data-checked": n.attrs.checked ? "true" : "false",
|
|
2276
|
-
class: o.getClassName(n.attrs, "task-list-item")
|
|
2277
|
-
},
|
|
2278
|
-
s,
|
|
2279
|
-
["span", { class: o.getClassName(n.attrs, "task-list-item_body") }, 0]
|
|
2280
|
-
];
|
|
2281
576
|
},
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
577
|
+
...(n == null ? void 0 : n.parseDOM) || []
|
|
578
|
+
],
|
|
579
|
+
toDOM: (o) => n.toDOM && o.attrs.checked == null ? n.toDOM(o) : [
|
|
580
|
+
"li",
|
|
581
|
+
{
|
|
582
|
+
"data-item-type": "task",
|
|
583
|
+
"data-label": o.attrs.label,
|
|
584
|
+
"data-list-type": o.attrs.listType,
|
|
585
|
+
"data-spread": o.attrs.spread,
|
|
586
|
+
"data-checked": o.attrs.checked
|
|
2287
587
|
},
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
588
|
+
0
|
|
589
|
+
],
|
|
590
|
+
parseMarkdown: {
|
|
591
|
+
match: ({ type: o }) => o === "listItem",
|
|
592
|
+
runner: (o, l, r) => {
|
|
593
|
+
if (l.checked == null) {
|
|
594
|
+
n.parseMarkdown.runner(o, l, r);
|
|
595
|
+
return;
|
|
2292
596
|
}
|
|
597
|
+
const s = l.label != null ? `${l.label}.` : "•", i = l.checked != null ? Boolean(l.checked) : null, a = l.label != null ? "ordered" : "bullet", u = l.spread != null ? `${l.spread}` : "true";
|
|
598
|
+
o.openNode(r, { label: s, listType: a, spread: u, checked: i }), o.next(l.children), o.closeNode();
|
|
2293
599
|
}
|
|
2294
|
-
}),
|
|
2295
|
-
inputRules: (t) => [
|
|
2296
|
-
Je(/^\s*(\[([ |x])\])\s$/, t, (n) => ({
|
|
2297
|
-
checked: n[n.length - 1] === "x"
|
|
2298
|
-
}))
|
|
2299
|
-
],
|
|
2300
|
-
commands: (t) => [
|
|
2301
|
-
N(we, () => xt(t)),
|
|
2302
|
-
N(be, () => Rt(t)),
|
|
2303
|
-
N(Ce, () => Tt(t)),
|
|
2304
|
-
N(ye, () => Mt(t))
|
|
2305
|
-
],
|
|
2306
|
-
shortcuts: {
|
|
2307
|
-
[q.NextListItem]: O(we, "Enter"),
|
|
2308
|
-
[q.SinkListItem]: O(be, "Mod-]"),
|
|
2309
|
-
[q.LiftListItem]: O(Ce, "Mod-["),
|
|
2310
|
-
[q.TaskList]: O(ye, "Mod-Alt-9")
|
|
2311
600
|
},
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
n.dispatch(
|
|
2319
|
-
f.setNodeMarkup(s(), void 0, {
|
|
2320
|
-
checked: d
|
|
2321
|
-
})
|
|
2322
|
-
);
|
|
601
|
+
toMarkdown: {
|
|
602
|
+
match: (o) => o.type.name === "list_item",
|
|
603
|
+
runner: (o, l) => {
|
|
604
|
+
if (l.attrs.checked == null) {
|
|
605
|
+
n.toMarkdown.runner(o, l);
|
|
606
|
+
return;
|
|
2323
607
|
}
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
const { dom: a, contentDOM: i, onUpdate: c } = r;
|
|
2328
|
-
return c(l), {
|
|
2329
|
-
dom: a,
|
|
2330
|
-
contentDOM: i,
|
|
2331
|
-
update: (d) => d.type.name !== e ? !1 : (l = d, c(l), !0)
|
|
2332
|
-
};
|
|
608
|
+
const r = l.attrs.label, s = l.attrs.listType, i = l.attrs.spread === "true", a = l.attrs.checked;
|
|
609
|
+
o.openNode("listItem", void 0, { label: r, listType: s, spread: i, checked: a }), o.next(l.content), o.closeNode();
|
|
610
|
+
}
|
|
2333
611
|
}
|
|
2334
612
|
};
|
|
2335
|
-
}),
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
613
|
+
}), Xe = [
|
|
614
|
+
Te,
|
|
615
|
+
je
|
|
616
|
+
].flat(), qe = [
|
|
617
|
+
Ee
|
|
618
|
+
], Je = _(() => {
|
|
619
|
+
const e = new se("MILKDOWN_AUTO_INSERT_ZERO_SPACE"), t = (o) => o.type === W.type(), n = (o) => t(o) && o.nodeSize === 2;
|
|
620
|
+
return new ce({
|
|
621
|
+
key: e,
|
|
622
|
+
props: {
|
|
623
|
+
handleDOMEvents: {
|
|
624
|
+
compositionstart(o) {
|
|
625
|
+
const { state: l, dispatch: r } = o, { tr: s, selection: i } = l, { $from: a } = i;
|
|
626
|
+
return D.safari && y(l) && i.empty && n(a.parent) && r(s.insertText("", a.start())), !1;
|
|
627
|
+
},
|
|
628
|
+
compositionend(o) {
|
|
629
|
+
const { state: l, dispatch: r } = o, { tr: s, selection: i } = l, { $from: a } = i;
|
|
630
|
+
return D.safari && y(l) && i.empty && t(a.parent) && a.parent.textContent.startsWith("") && r(s.delete(a.start(), a.start() + 1)), !1;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
}), Qe = _(() => he({})), Ye = _(() => be()), et = we(() => Se), tt = [
|
|
636
|
+
Je,
|
|
637
|
+
Qe,
|
|
638
|
+
Ye,
|
|
639
|
+
et
|
|
640
|
+
], ot = [
|
|
641
|
+
Ue,
|
|
642
|
+
E,
|
|
643
|
+
I,
|
|
644
|
+
Y,
|
|
645
|
+
O,
|
|
646
|
+
Ve,
|
|
647
|
+
Ze,
|
|
648
|
+
j
|
|
649
|
+
].flat(), nt = [
|
|
650
|
+
te,
|
|
651
|
+
ee,
|
|
652
|
+
oe,
|
|
653
|
+
Ie,
|
|
654
|
+
Oe,
|
|
655
|
+
De,
|
|
656
|
+
Pe,
|
|
657
|
+
Be,
|
|
658
|
+
Fe,
|
|
659
|
+
He,
|
|
660
|
+
Le,
|
|
661
|
+
ze,
|
|
662
|
+
We,
|
|
663
|
+
Ke,
|
|
664
|
+
Ge,
|
|
665
|
+
V
|
|
666
|
+
], pt = [ot, qe, Xe, tt, nt].flat();
|
|
2351
667
|
export {
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
Po as hr,
|
|
2399
|
-
Ho as image,
|
|
2400
|
-
jo as link,
|
|
2401
|
-
Ko as listItem,
|
|
2402
|
-
qo as orderedList,
|
|
2403
|
-
Xo as paragraph,
|
|
2404
|
-
Kn as strikeThrough,
|
|
2405
|
-
Uo as strong,
|
|
2406
|
-
jn as table,
|
|
2407
|
-
qn as taskListItem,
|
|
2408
|
-
Vo as text
|
|
668
|
+
Ke as addColAfterCommand,
|
|
669
|
+
We as addColBeforeCommand,
|
|
670
|
+
ze as addRowAfterCommand,
|
|
671
|
+
Le as addRowBeforeCommand,
|
|
672
|
+
U as addRowWithAlignment,
|
|
673
|
+
oe as breakTableCommand,
|
|
674
|
+
nt as commands,
|
|
675
|
+
J as convertTableNodeToArrayOfRows,
|
|
676
|
+
Z as createTable,
|
|
677
|
+
He as deleteSelectedCellsCommand,
|
|
678
|
+
Ue as extendListItemSchemaForTask,
|
|
679
|
+
k as findTable,
|
|
680
|
+
Ve as footnoteDefinitionSchema,
|
|
681
|
+
Ze as footnoteReferenceSchema,
|
|
682
|
+
Me as getAllCellsInTable,
|
|
683
|
+
b as getCellsInColumn,
|
|
684
|
+
g as getCellsInRow,
|
|
685
|
+
pt as gfm,
|
|
686
|
+
te as goToNextTableCellCommand,
|
|
687
|
+
ee as goToPrevTableCellCommand,
|
|
688
|
+
qe as inputrules,
|
|
689
|
+
Ie as insertTableCommand,
|
|
690
|
+
Ee as insertTableInputRule,
|
|
691
|
+
Xe as keymap,
|
|
692
|
+
$e as moveCol,
|
|
693
|
+
De as moveColCommand,
|
|
694
|
+
_e as moveRow,
|
|
695
|
+
Oe as moveRowCommand,
|
|
696
|
+
tt as plugins,
|
|
697
|
+
ot as schema,
|
|
698
|
+
ve as selectCol,
|
|
699
|
+
Be as selectColCommand,
|
|
700
|
+
X as selectLine,
|
|
701
|
+
Re as selectRow,
|
|
702
|
+
Pe as selectRowCommand,
|
|
703
|
+
Ae as selectTable,
|
|
704
|
+
Fe as selectTableCommand,
|
|
705
|
+
Ge as setAlignCommand,
|
|
706
|
+
Te as strikethroughKeymap,
|
|
707
|
+
j as strikethroughSchema,
|
|
708
|
+
O as tableCellSchema,
|
|
709
|
+
Y as tableHeaderSchema,
|
|
710
|
+
je as tableKeymap,
|
|
711
|
+
I as tableRowSchema,
|
|
712
|
+
E as tableSchema,
|
|
713
|
+
V as toggleStrikethroughCommand
|
|
2409
714
|
};
|
|
2410
715
|
//# sourceMappingURL=index.es.js.map
|