@clevertask/scribe 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -9
- package/dist/{BarMenu-BG_w4DVo.js → BarMenu-5S2vKAtc.js} +1 -1
- package/dist/components/Menu/BarMenu.js +1 -1
- package/dist/components/Menu/BubbleMenu.js +2 -2
- package/dist/components/Menu/LinkBubbleMenu.d.ts.map +1 -1
- package/dist/components/Menu/LinkBubbleMenu.js +58 -44
- package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
- package/dist/components/Menu/linkBubbleMenuPlugin.d.ts +1 -0
- package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -1
- package/dist/components/Menu/linkBubbleMenuPlugin.js +4 -2
- package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
- package/dist/components/Scribe/extension/extension-link.js +1 -1
- package/dist/components/Scribe/extension/extension-markdown-paste.js +11 -11
- package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
- package/dist/components/Scribe/extension/index.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/index.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
- package/dist/components/Scribe/extension/tableOfContents.js +4 -4
- package/dist/components/Scribe/index.js +3 -3
- package/dist/dist-DErUltkU.js +3245 -0
- package/dist/{dist-BgEySLwo.js → dist-wYqYXEOz.js} +1 -1
- package/dist/{extension-BVGWENts.js → extension-6I5t1ZxQ.js} +1744 -2294
- package/dist/{extension-link-CMRfHUc5.js → extension-link-DJy7XDoj.js} +62 -62
- package/dist/{menus-D9OsP28c.js → menus-m_EkiaUN.js} +66 -66
- package/dist/{slashCommand-B6Iz1i0d.js → slashCommand-DuSH9sXJ.js} +46 -45
- package/dist/utils/index.js +2 -2
- package/package.json +3 -2
- package/dist/dist-BMKyBtRa.js +0 -7023
- package/dist/dist-FrapLVQu.js +0 -3513
- package/dist/tables-CXpUVKdw.js +0 -1347
package/dist/tables-CXpUVKdw.js
DELETED
|
@@ -1,1347 +0,0 @@
|
|
|
1
|
-
import { C as e, O as t, a as n, c as r, i, o as a, p as o, r as s, s as c } from "./dist-FrapLVQu.js";
|
|
2
|
-
import { H as l, U as u, V as d } from "./dist-BMKyBtRa.js";
|
|
3
|
-
//#region node_modules/.pnpm/prosemirror-tables@1.8.5/node_modules/prosemirror-tables/dist/index.js
|
|
4
|
-
var f, p;
|
|
5
|
-
if (typeof WeakMap < "u") {
|
|
6
|
-
let e = /* @__PURE__ */ new WeakMap();
|
|
7
|
-
f = (t) => e.get(t), p = (t, n) => (e.set(t, n), n);
|
|
8
|
-
} else {
|
|
9
|
-
let e = [], t = 0;
|
|
10
|
-
f = (t) => {
|
|
11
|
-
for (let n = 0; n < e.length; n += 2) if (e[n] == t) return e[n + 1];
|
|
12
|
-
}, p = (n, r) => (t == 10 && (t = 0), e[t++] = n, e[t++] = r);
|
|
13
|
-
}
|
|
14
|
-
var m = class {
|
|
15
|
-
constructor(e, t, n, r) {
|
|
16
|
-
this.width = e, this.height = t, this.map = n, this.problems = r;
|
|
17
|
-
}
|
|
18
|
-
findCell(e) {
|
|
19
|
-
for (let t = 0; t < this.map.length; t++) {
|
|
20
|
-
let n = this.map[t];
|
|
21
|
-
if (n != e) continue;
|
|
22
|
-
let r = t % this.width, i = t / this.width | 0, a = r + 1, o = i + 1;
|
|
23
|
-
for (let e = 1; a < this.width && this.map[t + e] == n; e++) a++;
|
|
24
|
-
for (let e = 1; o < this.height && this.map[t + this.width * e] == n; e++) o++;
|
|
25
|
-
return {
|
|
26
|
-
left: r,
|
|
27
|
-
top: i,
|
|
28
|
-
right: a,
|
|
29
|
-
bottom: o
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
throw RangeError(`No cell with offset ${e} found`);
|
|
33
|
-
}
|
|
34
|
-
colCount(e) {
|
|
35
|
-
for (let t = 0; t < this.map.length; t++) if (this.map[t] == e) return t % this.width;
|
|
36
|
-
throw RangeError(`No cell with offset ${e} found`);
|
|
37
|
-
}
|
|
38
|
-
nextCell(e, t, n) {
|
|
39
|
-
let { left: r, right: i, top: a, bottom: o } = this.findCell(e);
|
|
40
|
-
return t == "horiz" ? (n < 0 ? r == 0 : i == this.width) ? null : this.map[a * this.width + (n < 0 ? r - 1 : i)] : (n < 0 ? a == 0 : o == this.height) ? null : this.map[r + this.width * (n < 0 ? a - 1 : o)];
|
|
41
|
-
}
|
|
42
|
-
rectBetween(e, t) {
|
|
43
|
-
let { left: n, right: r, top: i, bottom: a } = this.findCell(e), { left: o, right: s, top: c, bottom: l } = this.findCell(t);
|
|
44
|
-
return {
|
|
45
|
-
left: Math.min(n, o),
|
|
46
|
-
top: Math.min(i, c),
|
|
47
|
-
right: Math.max(r, s),
|
|
48
|
-
bottom: Math.max(a, l)
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
cellsInRect(e) {
|
|
52
|
-
let t = [], n = {};
|
|
53
|
-
for (let r = e.top; r < e.bottom; r++) for (let i = e.left; i < e.right; i++) {
|
|
54
|
-
let a = r * this.width + i, o = this.map[a];
|
|
55
|
-
n[o] || (n[o] = !0, !(i == e.left && i && this.map[a - 1] == o || r == e.top && r && this.map[a - this.width] == o) && t.push(o));
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
}
|
|
59
|
-
positionAt(e, t, n) {
|
|
60
|
-
for (let r = 0, i = 0;; r++) {
|
|
61
|
-
let a = i + n.child(r).nodeSize;
|
|
62
|
-
if (r == e) {
|
|
63
|
-
let n = t + e * this.width, r = (e + 1) * this.width;
|
|
64
|
-
for (; n < r && this.map[n] < i;) n++;
|
|
65
|
-
return n == r ? a - 1 : this.map[n];
|
|
66
|
-
}
|
|
67
|
-
i = a;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
static get(e) {
|
|
71
|
-
return f(e) || p(e, h(e));
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
function h(e) {
|
|
75
|
-
if (e.type.spec.tableRole != "table") throw RangeError("Not a table node: " + e.type.name);
|
|
76
|
-
let t = ee(e), n = e.childCount, r = [], i = 0, a = null, o = [];
|
|
77
|
-
for (let e = 0, i = t * n; e < i; e++) r[e] = 0;
|
|
78
|
-
for (let s = 0, c = 0; s < n; s++) {
|
|
79
|
-
let l = e.child(s);
|
|
80
|
-
c++;
|
|
81
|
-
for (let e = 0;; e++) {
|
|
82
|
-
for (; i < r.length && r[i] != 0;) i++;
|
|
83
|
-
if (e == l.childCount) break;
|
|
84
|
-
let u = l.child(e), { colspan: d, rowspan: f, colwidth: p } = u.attrs;
|
|
85
|
-
for (let e = 0; e < f; e++) {
|
|
86
|
-
if (e + s >= n) {
|
|
87
|
-
(a ||= []).push({
|
|
88
|
-
type: "overlong_rowspan",
|
|
89
|
-
pos: c,
|
|
90
|
-
n: f - e
|
|
91
|
-
});
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
let l = i + e * t;
|
|
95
|
-
for (let e = 0; e < d; e++) {
|
|
96
|
-
r[l + e] == 0 ? r[l + e] = c : (a ||= []).push({
|
|
97
|
-
type: "collision",
|
|
98
|
-
row: s,
|
|
99
|
-
pos: c,
|
|
100
|
-
n: d - e
|
|
101
|
-
});
|
|
102
|
-
let n = p && p[e];
|
|
103
|
-
if (n) {
|
|
104
|
-
let r = (l + e) % t * 2, i = o[r];
|
|
105
|
-
i == null || i != n && o[r + 1] == 1 ? (o[r] = n, o[r + 1] = 1) : i == n && o[r + 1]++;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
i += d, c += u.nodeSize;
|
|
110
|
-
}
|
|
111
|
-
let u = (s + 1) * t, d = 0;
|
|
112
|
-
for (; i < u;) r[i++] == 0 && d++;
|
|
113
|
-
d && (a ||= []).push({
|
|
114
|
-
type: "missing",
|
|
115
|
-
row: s,
|
|
116
|
-
n: d
|
|
117
|
-
}), c++;
|
|
118
|
-
}
|
|
119
|
-
(t === 0 || n === 0) && (a ||= []).push({ type: "zero_sized" });
|
|
120
|
-
let s = new m(t, n, r, a), c = !1;
|
|
121
|
-
for (let e = 0; !c && e < o.length; e += 2) o[e] != null && o[e + 1] < n && (c = !0);
|
|
122
|
-
return c && te(s, o, e), s;
|
|
123
|
-
}
|
|
124
|
-
function ee(e) {
|
|
125
|
-
let t = -1, n = !1;
|
|
126
|
-
for (let r = 0; r < e.childCount; r++) {
|
|
127
|
-
let i = e.child(r), a = 0;
|
|
128
|
-
if (n) for (let t = 0; t < r; t++) {
|
|
129
|
-
let n = e.child(t);
|
|
130
|
-
for (let e = 0; e < n.childCount; e++) {
|
|
131
|
-
let i = n.child(e);
|
|
132
|
-
t + i.attrs.rowspan > r && (a += i.attrs.colspan);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
for (let e = 0; e < i.childCount; e++) {
|
|
136
|
-
let t = i.child(e);
|
|
137
|
-
a += t.attrs.colspan, t.attrs.rowspan > 1 && (n = !0);
|
|
138
|
-
}
|
|
139
|
-
t == -1 ? t = a : t != a && (t = Math.max(t, a));
|
|
140
|
-
}
|
|
141
|
-
return t;
|
|
142
|
-
}
|
|
143
|
-
function te(e, t, n) {
|
|
144
|
-
e.problems ||= [];
|
|
145
|
-
let r = {};
|
|
146
|
-
for (let i = 0; i < e.map.length; i++) {
|
|
147
|
-
let a = e.map[i];
|
|
148
|
-
if (r[a]) continue;
|
|
149
|
-
r[a] = !0;
|
|
150
|
-
let o = n.nodeAt(a);
|
|
151
|
-
if (!o) throw RangeError(`No cell with offset ${a} found`);
|
|
152
|
-
let s = null, c = o.attrs;
|
|
153
|
-
for (let n = 0; n < c.colspan; n++) {
|
|
154
|
-
let r = t[(i + n) % e.width * 2];
|
|
155
|
-
r != null && (!c.colwidth || c.colwidth[n] != r) && ((s ||= ne(c))[n] = r);
|
|
156
|
-
}
|
|
157
|
-
s && e.problems.unshift({
|
|
158
|
-
type: "colwidth mismatch",
|
|
159
|
-
pos: a,
|
|
160
|
-
colwidth: s
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
function ne(e) {
|
|
165
|
-
if (e.colwidth) return e.colwidth.slice();
|
|
166
|
-
let t = [];
|
|
167
|
-
for (let n = 0; n < e.colspan; n++) t.push(0);
|
|
168
|
-
return t;
|
|
169
|
-
}
|
|
170
|
-
function g(e) {
|
|
171
|
-
let t = e.cached.tableNodeTypes;
|
|
172
|
-
if (!t) {
|
|
173
|
-
t = e.cached.tableNodeTypes = {};
|
|
174
|
-
for (let n in e.nodes) {
|
|
175
|
-
let r = e.nodes[n], i = r.spec.tableRole;
|
|
176
|
-
i && (t[i] = r);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return t;
|
|
180
|
-
}
|
|
181
|
-
var _ = new n("selectingCells");
|
|
182
|
-
function v(e) {
|
|
183
|
-
for (let t = e.depth - 1; t > 0; t--) if (e.node(t).type.spec.tableRole == "row") return e.node(0).resolve(e.before(t + 1));
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
function re(e) {
|
|
187
|
-
for (let t = e.depth; t > 0; t--) {
|
|
188
|
-
let n = e.node(t).type.spec.tableRole;
|
|
189
|
-
if (n === "cell" || n === "header_cell") return e.node(t);
|
|
190
|
-
}
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
function y(e) {
|
|
194
|
-
let t = e.selection.$head;
|
|
195
|
-
for (let e = t.depth; e > 0; e--) if (t.node(e).type.spec.tableRole == "row") return !0;
|
|
196
|
-
return !1;
|
|
197
|
-
}
|
|
198
|
-
function b(e) {
|
|
199
|
-
let t = e.selection;
|
|
200
|
-
if ("$anchorCell" in t && t.$anchorCell) return t.$anchorCell.pos > t.$headCell.pos ? t.$anchorCell : t.$headCell;
|
|
201
|
-
if ("node" in t && t.node && t.node.type.spec.tableRole == "cell") return t.$anchor;
|
|
202
|
-
let n = v(t.$head) || ie(t.$head);
|
|
203
|
-
if (n) return n;
|
|
204
|
-
throw RangeError(`No cell found around position ${t.head}`);
|
|
205
|
-
}
|
|
206
|
-
function ie(e) {
|
|
207
|
-
for (let t = e.nodeAfter, n = e.pos; t; t = t.firstChild, n++) {
|
|
208
|
-
let r = t.type.spec.tableRole;
|
|
209
|
-
if (r == "cell" || r == "header_cell") return e.doc.resolve(n);
|
|
210
|
-
}
|
|
211
|
-
for (let t = e.nodeBefore, n = e.pos; t; t = t.lastChild, n--) {
|
|
212
|
-
let r = t.type.spec.tableRole;
|
|
213
|
-
if (r == "cell" || r == "header_cell") return e.doc.resolve(n - t.nodeSize);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function x(e) {
|
|
217
|
-
return e.parent.type.spec.tableRole == "row" && !!e.nodeAfter;
|
|
218
|
-
}
|
|
219
|
-
function ae(e) {
|
|
220
|
-
return e.node(0).resolve(e.pos + e.nodeAfter.nodeSize);
|
|
221
|
-
}
|
|
222
|
-
function S(e, t) {
|
|
223
|
-
return e.depth == t.depth && e.pos >= t.start(-1) && e.pos <= t.end(-1);
|
|
224
|
-
}
|
|
225
|
-
function C(e, t, n) {
|
|
226
|
-
let r = e.node(-1), i = m.get(r), a = e.start(-1), o = i.nextCell(e.pos - a, t, n);
|
|
227
|
-
return o == null ? null : e.node(0).resolve(a + o);
|
|
228
|
-
}
|
|
229
|
-
function w(e, t, n = 1) {
|
|
230
|
-
let r = {
|
|
231
|
-
...e,
|
|
232
|
-
colspan: e.colspan - n
|
|
233
|
-
};
|
|
234
|
-
return r.colwidth && (r.colwidth = r.colwidth.slice(), r.colwidth.splice(t, n), r.colwidth.some((e) => e > 0) || (r.colwidth = null)), r;
|
|
235
|
-
}
|
|
236
|
-
function T(e, t, n = 1) {
|
|
237
|
-
let r = {
|
|
238
|
-
...e,
|
|
239
|
-
colspan: e.colspan + n
|
|
240
|
-
};
|
|
241
|
-
if (r.colwidth) {
|
|
242
|
-
r.colwidth = r.colwidth.slice();
|
|
243
|
-
for (let e = 0; e < n; e++) r.colwidth.splice(t, 0, 0);
|
|
244
|
-
}
|
|
245
|
-
return r;
|
|
246
|
-
}
|
|
247
|
-
function oe(e, t, n) {
|
|
248
|
-
let r = g(t.type.schema).header_cell;
|
|
249
|
-
for (let i = 0; i < e.height; i++) if (t.nodeAt(e.map[n + i * e.width]).type != r) return !1;
|
|
250
|
-
return !0;
|
|
251
|
-
}
|
|
252
|
-
var E = class n extends a {
|
|
253
|
-
constructor(e, t = e) {
|
|
254
|
-
let n = e.node(-1), r = m.get(n), i = e.start(-1), a = r.rectBetween(e.pos - i, t.pos - i), o = e.node(0), s = r.cellsInRect(a).filter((e) => e != t.pos - i);
|
|
255
|
-
s.unshift(t.pos - i);
|
|
256
|
-
let l = s.map((e) => {
|
|
257
|
-
let t = n.nodeAt(e);
|
|
258
|
-
if (!t) throw RangeError(`No cell with offset ${e} found`);
|
|
259
|
-
let r = i + e + 1;
|
|
260
|
-
return new c(o.resolve(r), o.resolve(r + t.content.size));
|
|
261
|
-
});
|
|
262
|
-
super(l[0].$from, l[0].$to, l), this.$anchorCell = e, this.$headCell = t;
|
|
263
|
-
}
|
|
264
|
-
map(e, t) {
|
|
265
|
-
let i = e.resolve(t.map(this.$anchorCell.pos)), a = e.resolve(t.map(this.$headCell.pos));
|
|
266
|
-
if (x(i) && x(a) && S(i, a)) {
|
|
267
|
-
let e = this.$anchorCell.node(-1) != i.node(-1);
|
|
268
|
-
return e && this.isRowSelection() ? n.rowSelection(i, a) : e && this.isColSelection() ? n.colSelection(i, a) : new n(i, a);
|
|
269
|
-
}
|
|
270
|
-
return r.between(i, a);
|
|
271
|
-
}
|
|
272
|
-
content() {
|
|
273
|
-
let n = this.$anchorCell.node(-1), r = m.get(n), i = this.$anchorCell.start(-1), a = r.rectBetween(this.$anchorCell.pos - i, this.$headCell.pos - i), o = {}, s = [];
|
|
274
|
-
for (let t = a.top; t < a.bottom; t++) {
|
|
275
|
-
let i = [];
|
|
276
|
-
for (let e = t * r.width + a.left, s = a.left; s < a.right; s++, e++) {
|
|
277
|
-
let t = r.map[e];
|
|
278
|
-
if (o[t]) continue;
|
|
279
|
-
o[t] = !0;
|
|
280
|
-
let s = r.findCell(t), c = n.nodeAt(t);
|
|
281
|
-
if (!c) throw RangeError(`No cell with offset ${t} found`);
|
|
282
|
-
let l = a.left - s.left, u = s.right - a.right;
|
|
283
|
-
if (l > 0 || u > 0) {
|
|
284
|
-
let e = c.attrs;
|
|
285
|
-
if (l > 0 && (e = w(e, 0, l)), u > 0 && (e = w(e, e.colspan - u, u)), s.left < a.left) {
|
|
286
|
-
if (c = c.type.createAndFill(e), !c) throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`);
|
|
287
|
-
} else c = c.type.create(e, c.content);
|
|
288
|
-
}
|
|
289
|
-
if (s.top < a.top || s.bottom > a.bottom) {
|
|
290
|
-
let e = {
|
|
291
|
-
...c.attrs,
|
|
292
|
-
rowspan: Math.min(s.bottom, a.bottom) - Math.max(s.top, a.top)
|
|
293
|
-
};
|
|
294
|
-
c = s.top < a.top ? c.type.createAndFill(e) : c.type.create(e, c.content);
|
|
295
|
-
}
|
|
296
|
-
i.push(c);
|
|
297
|
-
}
|
|
298
|
-
s.push(n.child(t).copy(e.from(i)));
|
|
299
|
-
}
|
|
300
|
-
let c = this.isColSelection() && this.isRowSelection() ? n : s;
|
|
301
|
-
return new t(e.from(c), 1, 1);
|
|
302
|
-
}
|
|
303
|
-
replace(e, n = t.empty) {
|
|
304
|
-
let r = e.steps.length, i = this.ranges;
|
|
305
|
-
for (let a = 0; a < i.length; a++) {
|
|
306
|
-
let { $from: o, $to: s } = i[a], c = e.mapping.slice(r);
|
|
307
|
-
e.replace(c.map(o.pos), c.map(s.pos), a ? t.empty : n);
|
|
308
|
-
}
|
|
309
|
-
let o = a.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)), -1);
|
|
310
|
-
o && e.setSelection(o);
|
|
311
|
-
}
|
|
312
|
-
replaceWith(n, r) {
|
|
313
|
-
this.replace(n, new t(e.from(r), 0, 0));
|
|
314
|
-
}
|
|
315
|
-
forEachCell(e) {
|
|
316
|
-
let t = this.$anchorCell.node(-1), n = m.get(t), r = this.$anchorCell.start(-1), i = n.cellsInRect(n.rectBetween(this.$anchorCell.pos - r, this.$headCell.pos - r));
|
|
317
|
-
for (let n = 0; n < i.length; n++) e(t.nodeAt(i[n]), r + i[n]);
|
|
318
|
-
}
|
|
319
|
-
isColSelection() {
|
|
320
|
-
let e = this.$anchorCell.index(-1), t = this.$headCell.index(-1);
|
|
321
|
-
if (Math.min(e, t) > 0) return !1;
|
|
322
|
-
let n = e + this.$anchorCell.nodeAfter.attrs.rowspan, r = t + this.$headCell.nodeAfter.attrs.rowspan;
|
|
323
|
-
return Math.max(n, r) == this.$headCell.node(-1).childCount;
|
|
324
|
-
}
|
|
325
|
-
static colSelection(e, t = e) {
|
|
326
|
-
let r = e.node(-1), i = m.get(r), a = e.start(-1), o = i.findCell(e.pos - a), s = i.findCell(t.pos - a), c = e.node(0);
|
|
327
|
-
return o.top <= s.top ? (o.top > 0 && (e = c.resolve(a + i.map[o.left])), s.bottom < i.height && (t = c.resolve(a + i.map[i.width * (i.height - 1) + s.right - 1]))) : (s.top > 0 && (t = c.resolve(a + i.map[s.left])), o.bottom < i.height && (e = c.resolve(a + i.map[i.width * (i.height - 1) + o.right - 1]))), new n(e, t);
|
|
328
|
-
}
|
|
329
|
-
isRowSelection() {
|
|
330
|
-
let e = this.$anchorCell.node(-1), t = m.get(e), n = this.$anchorCell.start(-1), r = t.colCount(this.$anchorCell.pos - n), i = t.colCount(this.$headCell.pos - n);
|
|
331
|
-
if (Math.min(r, i) > 0) return !1;
|
|
332
|
-
let a = r + this.$anchorCell.nodeAfter.attrs.colspan, o = i + this.$headCell.nodeAfter.attrs.colspan;
|
|
333
|
-
return Math.max(a, o) == t.width;
|
|
334
|
-
}
|
|
335
|
-
eq(e) {
|
|
336
|
-
return e instanceof n && e.$anchorCell.pos == this.$anchorCell.pos && e.$headCell.pos == this.$headCell.pos;
|
|
337
|
-
}
|
|
338
|
-
static rowSelection(e, t = e) {
|
|
339
|
-
let r = e.node(-1), i = m.get(r), a = e.start(-1), o = i.findCell(e.pos - a), s = i.findCell(t.pos - a), c = e.node(0);
|
|
340
|
-
return o.left <= s.left ? (o.left > 0 && (e = c.resolve(a + i.map[o.top * i.width])), s.right < i.width && (t = c.resolve(a + i.map[i.width * (s.top + 1) - 1]))) : (s.left > 0 && (t = c.resolve(a + i.map[s.top * i.width])), o.right < i.width && (e = c.resolve(a + i.map[i.width * (o.top + 1) - 1]))), new n(e, t);
|
|
341
|
-
}
|
|
342
|
-
toJSON() {
|
|
343
|
-
return {
|
|
344
|
-
type: "cell",
|
|
345
|
-
anchor: this.$anchorCell.pos,
|
|
346
|
-
head: this.$headCell.pos
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
static fromJSON(e, t) {
|
|
350
|
-
return new n(e.resolve(t.anchor), e.resolve(t.head));
|
|
351
|
-
}
|
|
352
|
-
static create(e, t, r = t) {
|
|
353
|
-
return new n(e.resolve(t), e.resolve(r));
|
|
354
|
-
}
|
|
355
|
-
getBookmark() {
|
|
356
|
-
return new se(this.$anchorCell.pos, this.$headCell.pos);
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
E.prototype.visible = !1, a.jsonID("cell", E);
|
|
360
|
-
var se = class e {
|
|
361
|
-
constructor(e, t) {
|
|
362
|
-
this.anchor = e, this.head = t;
|
|
363
|
-
}
|
|
364
|
-
map(t) {
|
|
365
|
-
return new e(t.map(this.anchor), t.map(this.head));
|
|
366
|
-
}
|
|
367
|
-
resolve(e) {
|
|
368
|
-
let t = e.resolve(this.anchor), n = e.resolve(this.head);
|
|
369
|
-
return t.parent.type.spec.tableRole == "row" && n.parent.type.spec.tableRole == "row" && t.index() < t.parent.childCount && n.index() < n.parent.childCount && S(t, n) ? new E(t, n) : a.near(n, 1);
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
function ce(e) {
|
|
373
|
-
if (!(e.selection instanceof E)) return null;
|
|
374
|
-
let t = [];
|
|
375
|
-
return e.selection.forEachCell((e, n) => {
|
|
376
|
-
t.push(l.node(n, n + e.nodeSize, { class: "selectedCell" }));
|
|
377
|
-
}), u.create(e.doc, t);
|
|
378
|
-
}
|
|
379
|
-
function le({ $from: e, $to: t }) {
|
|
380
|
-
if (e.pos == t.pos || e.pos < t.pos - 6) return !1;
|
|
381
|
-
let n = e.pos, r = t.pos, i = e.depth;
|
|
382
|
-
for (; i >= 0 && !(e.after(i + 1) < e.end(i)); i--, n++);
|
|
383
|
-
for (let e = t.depth; e >= 0 && !(t.before(e + 1) > t.start(e)); e--, r--);
|
|
384
|
-
return n == r && /row|table/.test(e.node(i).type.spec.tableRole);
|
|
385
|
-
}
|
|
386
|
-
function ue({ $from: e, $to: t }) {
|
|
387
|
-
let n, r;
|
|
388
|
-
for (let t = e.depth; t > 0; t--) {
|
|
389
|
-
let r = e.node(t);
|
|
390
|
-
if (r.type.spec.tableRole === "cell" || r.type.spec.tableRole === "header_cell") {
|
|
391
|
-
n = r;
|
|
392
|
-
break;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
for (let e = t.depth; e > 0; e--) {
|
|
396
|
-
let n = t.node(e);
|
|
397
|
-
if (n.type.spec.tableRole === "cell" || n.type.spec.tableRole === "header_cell") {
|
|
398
|
-
r = n;
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
return n !== r && t.parentOffset === 0;
|
|
403
|
-
}
|
|
404
|
-
function de(e, t, n) {
|
|
405
|
-
let i = (t || e).selection, a = (t || e).doc, o, c;
|
|
406
|
-
if (i instanceof s && (c = i.node.type.spec.tableRole)) {
|
|
407
|
-
if (c == "cell" || c == "header_cell") o = E.create(a, i.from);
|
|
408
|
-
else if (c == "row") {
|
|
409
|
-
let e = a.resolve(i.from + 1);
|
|
410
|
-
o = E.rowSelection(e, e);
|
|
411
|
-
} else if (!n) {
|
|
412
|
-
let e = m.get(i.node), t = i.from + 1, n = t + e.map[e.width * e.height - 1];
|
|
413
|
-
o = E.create(a, t + 1, n);
|
|
414
|
-
}
|
|
415
|
-
} else i instanceof r && le(i) ? o = r.create(a, i.from) : i instanceof r && ue(i) && (o = r.create(a, i.$from.start(), i.$from.end()));
|
|
416
|
-
return o && (t ||= e.tr).setSelection(o), t;
|
|
417
|
-
}
|
|
418
|
-
var fe = new n("fix-tables");
|
|
419
|
-
function D(e, t, n, r) {
|
|
420
|
-
let i = e.childCount, a = t.childCount;
|
|
421
|
-
outer: for (let o = 0, s = 0; o < a; o++) {
|
|
422
|
-
let a = t.child(o);
|
|
423
|
-
for (let t = s, r = Math.min(i, o + 3); t < r; t++) if (e.child(t) == a) {
|
|
424
|
-
s = t + 1, n += a.nodeSize;
|
|
425
|
-
continue outer;
|
|
426
|
-
}
|
|
427
|
-
r(a, n), s < i && e.child(s).sameMarkup(a) ? D(e.child(s), a, n + 1, r) : a.nodesBetween(0, a.content.size, r, n + 1), n += a.nodeSize;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
function O(e, t) {
|
|
431
|
-
let n, r = (t, r) => {
|
|
432
|
-
t.type.spec.tableRole == "table" && (n = pe(e, t, r, n));
|
|
433
|
-
};
|
|
434
|
-
return t ? t.doc != e.doc && D(t.doc, e.doc, 0, r) : e.doc.descendants(r), n;
|
|
435
|
-
}
|
|
436
|
-
function pe(e, t, n, r) {
|
|
437
|
-
let i = m.get(t);
|
|
438
|
-
if (!i.problems) return r;
|
|
439
|
-
r ||= e.tr;
|
|
440
|
-
let a = [];
|
|
441
|
-
for (let e = 0; e < i.height; e++) a.push(0);
|
|
442
|
-
for (let e = 0; e < i.problems.length; e++) {
|
|
443
|
-
let o = i.problems[e];
|
|
444
|
-
if (o.type == "collision") {
|
|
445
|
-
let e = t.nodeAt(o.pos);
|
|
446
|
-
if (!e) continue;
|
|
447
|
-
let i = e.attrs;
|
|
448
|
-
for (let e = 0; e < i.rowspan; e++) a[o.row + e] += o.n;
|
|
449
|
-
r.setNodeMarkup(r.mapping.map(n + 1 + o.pos), null, w(i, i.colspan - o.n, o.n));
|
|
450
|
-
} else if (o.type == "missing") a[o.row] += o.n;
|
|
451
|
-
else if (o.type == "overlong_rowspan") {
|
|
452
|
-
let e = t.nodeAt(o.pos);
|
|
453
|
-
if (!e) continue;
|
|
454
|
-
r.setNodeMarkup(r.mapping.map(n + 1 + o.pos), null, {
|
|
455
|
-
...e.attrs,
|
|
456
|
-
rowspan: e.attrs.rowspan - o.n
|
|
457
|
-
});
|
|
458
|
-
} else if (o.type == "colwidth mismatch") {
|
|
459
|
-
let e = t.nodeAt(o.pos);
|
|
460
|
-
if (!e) continue;
|
|
461
|
-
r.setNodeMarkup(r.mapping.map(n + 1 + o.pos), null, {
|
|
462
|
-
...e.attrs,
|
|
463
|
-
colwidth: o.colwidth
|
|
464
|
-
});
|
|
465
|
-
} else if (o.type == "zero_sized") {
|
|
466
|
-
let e = r.mapping.map(n);
|
|
467
|
-
r.delete(e, e + t.nodeSize);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
let o, s;
|
|
471
|
-
for (let e = 0; e < a.length; e++) a[e] && (o ??= e, s = e);
|
|
472
|
-
for (let c = 0, l = n + 1; c < i.height; c++) {
|
|
473
|
-
let n = t.child(c), i = l + n.nodeSize, u = a[c];
|
|
474
|
-
if (u > 0) {
|
|
475
|
-
let t = "cell";
|
|
476
|
-
n.firstChild && (t = n.firstChild.type.spec.tableRole);
|
|
477
|
-
let a = [];
|
|
478
|
-
for (let n = 0; n < u; n++) {
|
|
479
|
-
let n = g(e.schema)[t].createAndFill();
|
|
480
|
-
n && a.push(n);
|
|
481
|
-
}
|
|
482
|
-
let d = (c == 0 || o == c - 1) && s == c ? l + 1 : i - 1;
|
|
483
|
-
r.insert(r.mapping.map(d), a);
|
|
484
|
-
}
|
|
485
|
-
l = i;
|
|
486
|
-
}
|
|
487
|
-
return r.setMeta(fe, { fixTables: !0 });
|
|
488
|
-
}
|
|
489
|
-
function k(e) {
|
|
490
|
-
let t = e.selection, n = b(e), r = n.node(-1), i = n.start(-1), a = m.get(r);
|
|
491
|
-
return {
|
|
492
|
-
...t instanceof E ? a.rectBetween(t.$anchorCell.pos - i, t.$headCell.pos - i) : a.findCell(n.pos - i),
|
|
493
|
-
tableStart: i,
|
|
494
|
-
map: a,
|
|
495
|
-
table: r
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
function A(e, { map: t, tableStart: n, table: r }, i) {
|
|
499
|
-
let a = i > 0 ? -1 : 0;
|
|
500
|
-
oe(t, r, i + a) && (a = i == 0 || i == t.width ? null : 0);
|
|
501
|
-
for (let o = 0; o < t.height; o++) {
|
|
502
|
-
let s = o * t.width + i;
|
|
503
|
-
if (i > 0 && i < t.width && t.map[s - 1] == t.map[s]) {
|
|
504
|
-
let a = t.map[s], c = r.nodeAt(a);
|
|
505
|
-
e.setNodeMarkup(e.mapping.map(n + a), null, T(c.attrs, i - t.colCount(a))), o += c.attrs.rowspan - 1;
|
|
506
|
-
} else {
|
|
507
|
-
let c = a == null ? g(r.type.schema).cell : r.nodeAt(t.map[s + a]).type, l = t.positionAt(o, i, r);
|
|
508
|
-
e.insert(e.mapping.map(n + l), c.createAndFill());
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
return e;
|
|
512
|
-
}
|
|
513
|
-
function me(e, t) {
|
|
514
|
-
if (!y(e)) return !1;
|
|
515
|
-
if (t) {
|
|
516
|
-
let n = k(e);
|
|
517
|
-
t(A(e.tr, n, n.left));
|
|
518
|
-
}
|
|
519
|
-
return !0;
|
|
520
|
-
}
|
|
521
|
-
function he(e, t) {
|
|
522
|
-
if (!y(e)) return !1;
|
|
523
|
-
if (t) {
|
|
524
|
-
let n = k(e);
|
|
525
|
-
t(A(e.tr, n, n.right));
|
|
526
|
-
}
|
|
527
|
-
return !0;
|
|
528
|
-
}
|
|
529
|
-
function ge(e, { map: t, table: n, tableStart: r }, i) {
|
|
530
|
-
let a = e.mapping.maps.length;
|
|
531
|
-
for (let o = 0; o < t.height;) {
|
|
532
|
-
let s = o * t.width + i, c = t.map[s], l = n.nodeAt(c), u = l.attrs;
|
|
533
|
-
if (i > 0 && t.map[s - 1] == c || i < t.width - 1 && t.map[s + 1] == c) e.setNodeMarkup(e.mapping.slice(a).map(r + c), null, w(u, i - t.colCount(c)));
|
|
534
|
-
else {
|
|
535
|
-
let t = e.mapping.slice(a).map(r + c);
|
|
536
|
-
e.delete(t, t + l.nodeSize);
|
|
537
|
-
}
|
|
538
|
-
o += u.rowspan;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
function _e(e, t) {
|
|
542
|
-
if (!y(e)) return !1;
|
|
543
|
-
if (t) {
|
|
544
|
-
let n = k(e), r = e.tr;
|
|
545
|
-
if (n.left == 0 && n.right == n.map.width) return !1;
|
|
546
|
-
for (let e = n.right - 1; ge(r, n, e), e != n.left; e--) {
|
|
547
|
-
let e = n.tableStart ? r.doc.nodeAt(n.tableStart - 1) : r.doc;
|
|
548
|
-
if (!e) throw RangeError("No table found");
|
|
549
|
-
n.table = e, n.map = m.get(e);
|
|
550
|
-
}
|
|
551
|
-
t(r);
|
|
552
|
-
}
|
|
553
|
-
return !0;
|
|
554
|
-
}
|
|
555
|
-
function ve(e, t, n) {
|
|
556
|
-
let r = g(t.type.schema).header_cell;
|
|
557
|
-
for (let i = 0; i < e.width; i++) if (t.nodeAt(e.map[i + n * e.width])?.type != r) return !1;
|
|
558
|
-
return !0;
|
|
559
|
-
}
|
|
560
|
-
function j(e, { map: t, tableStart: n, table: r }, i) {
|
|
561
|
-
let a = n;
|
|
562
|
-
for (let e = 0; e < i; e++) a += r.child(e).nodeSize;
|
|
563
|
-
let o = [], s = i > 0 ? -1 : 0;
|
|
564
|
-
ve(t, r, i + s) && (s = i == 0 || i == t.height ? null : 0);
|
|
565
|
-
for (let a = 0, c = t.width * i; a < t.width; a++, c++) if (i > 0 && i < t.height && t.map[c] == t.map[c - t.width]) {
|
|
566
|
-
let i = t.map[c], o = r.nodeAt(i).attrs;
|
|
567
|
-
e.setNodeMarkup(n + i, null, {
|
|
568
|
-
...o,
|
|
569
|
-
rowspan: o.rowspan + 1
|
|
570
|
-
}), a += o.colspan - 1;
|
|
571
|
-
} else {
|
|
572
|
-
let e = (s == null ? g(r.type.schema).cell : r.nodeAt(t.map[c + s * t.width])?.type)?.createAndFill();
|
|
573
|
-
e && o.push(e);
|
|
574
|
-
}
|
|
575
|
-
return e.insert(a, g(r.type.schema).row.create(null, o)), e;
|
|
576
|
-
}
|
|
577
|
-
function ye(e, t) {
|
|
578
|
-
if (!y(e)) return !1;
|
|
579
|
-
if (t) {
|
|
580
|
-
let n = k(e);
|
|
581
|
-
t(j(e.tr, n, n.top));
|
|
582
|
-
}
|
|
583
|
-
return !0;
|
|
584
|
-
}
|
|
585
|
-
function be(e, t) {
|
|
586
|
-
if (!y(e)) return !1;
|
|
587
|
-
if (t) {
|
|
588
|
-
let n = k(e);
|
|
589
|
-
t(j(e.tr, n, n.bottom));
|
|
590
|
-
}
|
|
591
|
-
return !0;
|
|
592
|
-
}
|
|
593
|
-
function xe(e, { map: t, table: n, tableStart: r }, i) {
|
|
594
|
-
let a = 0;
|
|
595
|
-
for (let e = 0; e < i; e++) a += n.child(e).nodeSize;
|
|
596
|
-
let o = a + n.child(i).nodeSize, s = e.mapping.maps.length;
|
|
597
|
-
e.delete(a + r, o + r);
|
|
598
|
-
let c = /* @__PURE__ */ new Set();
|
|
599
|
-
for (let a = 0, o = i * t.width; a < t.width; a++, o++) {
|
|
600
|
-
let l = t.map[o];
|
|
601
|
-
if (!c.has(l)) {
|
|
602
|
-
if (c.add(l), i > 0 && l == t.map[o - t.width]) {
|
|
603
|
-
let t = n.nodeAt(l).attrs;
|
|
604
|
-
e.setNodeMarkup(e.mapping.slice(s).map(l + r), null, {
|
|
605
|
-
...t,
|
|
606
|
-
rowspan: t.rowspan - 1
|
|
607
|
-
}), a += t.colspan - 1;
|
|
608
|
-
} else if (i < t.height && l == t.map[o + t.width]) {
|
|
609
|
-
let o = n.nodeAt(l), c = o.attrs, u = o.type.create({
|
|
610
|
-
...c,
|
|
611
|
-
rowspan: o.attrs.rowspan - 1
|
|
612
|
-
}, o.content), d = t.positionAt(i + 1, a, n);
|
|
613
|
-
e.insert(e.mapping.slice(s).map(r + d), u), a += c.colspan - 1;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
function M(e, t) {
|
|
619
|
-
if (!y(e)) return !1;
|
|
620
|
-
if (t) {
|
|
621
|
-
let n = k(e), r = e.tr;
|
|
622
|
-
if (n.top == 0 && n.bottom == n.map.height) return !1;
|
|
623
|
-
for (let e = n.bottom - 1; xe(r, n, e), e != n.top; e--) {
|
|
624
|
-
let e = n.tableStart ? r.doc.nodeAt(n.tableStart - 1) : r.doc;
|
|
625
|
-
if (!e) throw RangeError("No table found");
|
|
626
|
-
n.table = e, n.map = m.get(n.table);
|
|
627
|
-
}
|
|
628
|
-
t(r);
|
|
629
|
-
}
|
|
630
|
-
return !0;
|
|
631
|
-
}
|
|
632
|
-
function N(e) {
|
|
633
|
-
let t = e.content;
|
|
634
|
-
return t.childCount == 1 && t.child(0).isTextblock && t.child(0).childCount == 0;
|
|
635
|
-
}
|
|
636
|
-
function Se({ width: e, height: t, map: n }, r) {
|
|
637
|
-
let i = r.top * e + r.left, a = i, o = (r.bottom - 1) * e + r.left, s = i + (r.right - r.left - 1);
|
|
638
|
-
for (let t = r.top; t < r.bottom; t++) {
|
|
639
|
-
if (r.left > 0 && n[a] == n[a - 1] || r.right < e && n[s] == n[s + 1]) return !0;
|
|
640
|
-
a += e, s += e;
|
|
641
|
-
}
|
|
642
|
-
for (let a = r.left; a < r.right; a++) {
|
|
643
|
-
if (r.top > 0 && n[i] == n[i - e] || r.bottom < t && n[o] == n[o + e]) return !0;
|
|
644
|
-
i++, o++;
|
|
645
|
-
}
|
|
646
|
-
return !1;
|
|
647
|
-
}
|
|
648
|
-
function Ce(t, n) {
|
|
649
|
-
let r = t.selection;
|
|
650
|
-
if (!(r instanceof E) || r.$anchorCell.pos == r.$headCell.pos) return !1;
|
|
651
|
-
let i = k(t), { map: a } = i;
|
|
652
|
-
if (Se(a, i)) return !1;
|
|
653
|
-
if (n) {
|
|
654
|
-
let r = t.tr, o = {}, s = e.empty, c, l;
|
|
655
|
-
for (let e = i.top; e < i.bottom; e++) for (let t = i.left; t < i.right; t++) {
|
|
656
|
-
let n = a.map[e * a.width + t], u = i.table.nodeAt(n);
|
|
657
|
-
if (!(o[n] || !u)) if (o[n] = !0, c == null) c = n, l = u;
|
|
658
|
-
else {
|
|
659
|
-
N(u) || (s = s.append(u.content));
|
|
660
|
-
let e = r.mapping.map(n + i.tableStart);
|
|
661
|
-
r.delete(e, e + u.nodeSize);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
if (c == null || l == null) return !0;
|
|
665
|
-
if (r.setNodeMarkup(c + i.tableStart, null, {
|
|
666
|
-
...T(l.attrs, l.attrs.colspan, i.right - i.left - l.attrs.colspan),
|
|
667
|
-
rowspan: i.bottom - i.top
|
|
668
|
-
}), s.size > 0) {
|
|
669
|
-
let e = c + 1 + l.content.size, t = N(l) ? c + 1 : e;
|
|
670
|
-
r.replaceWith(t + i.tableStart, e + i.tableStart, s);
|
|
671
|
-
}
|
|
672
|
-
r.setSelection(new E(r.doc.resolve(c + i.tableStart))), n(r);
|
|
673
|
-
}
|
|
674
|
-
return !0;
|
|
675
|
-
}
|
|
676
|
-
function we(e, t) {
|
|
677
|
-
let n = g(e.schema);
|
|
678
|
-
return Te(({ node: e }) => n[e.type.spec.tableRole])(e, t);
|
|
679
|
-
}
|
|
680
|
-
function Te(e) {
|
|
681
|
-
return (t, n) => {
|
|
682
|
-
let r = t.selection, i, a;
|
|
683
|
-
if (r instanceof E) {
|
|
684
|
-
if (r.$anchorCell.pos != r.$headCell.pos) return !1;
|
|
685
|
-
i = r.$anchorCell.nodeAfter, a = r.$anchorCell.pos;
|
|
686
|
-
} else {
|
|
687
|
-
if (i = re(r.$from), !i) return !1;
|
|
688
|
-
a = v(r.$from)?.pos;
|
|
689
|
-
}
|
|
690
|
-
if (i == null || a == null || i.attrs.colspan == 1 && i.attrs.rowspan == 1) return !1;
|
|
691
|
-
if (n) {
|
|
692
|
-
let o = i.attrs, s = [], c = o.colwidth;
|
|
693
|
-
o.rowspan > 1 && (o = {
|
|
694
|
-
...o,
|
|
695
|
-
rowspan: 1
|
|
696
|
-
}), o.colspan > 1 && (o = {
|
|
697
|
-
...o,
|
|
698
|
-
colspan: 1
|
|
699
|
-
});
|
|
700
|
-
let l = k(t), u = t.tr;
|
|
701
|
-
for (let e = 0; e < l.right - l.left; e++) s.push(c ? {
|
|
702
|
-
...o,
|
|
703
|
-
colwidth: c && c[e] ? [c[e]] : null
|
|
704
|
-
} : o);
|
|
705
|
-
let d;
|
|
706
|
-
for (let t = l.top; t < l.bottom; t++) {
|
|
707
|
-
let n = l.map.positionAt(t, l.left, l.table);
|
|
708
|
-
t == l.top && (n += i.nodeSize);
|
|
709
|
-
for (let r = l.left, a = 0; r < l.right; r++, a++) (r != l.left || t != l.top) && u.insert(d = u.mapping.map(n + l.tableStart, 1), e({
|
|
710
|
-
node: i,
|
|
711
|
-
row: t,
|
|
712
|
-
col: r
|
|
713
|
-
}).createAndFill(s[a]));
|
|
714
|
-
}
|
|
715
|
-
u.setNodeMarkup(a, e({
|
|
716
|
-
node: i,
|
|
717
|
-
row: l.top,
|
|
718
|
-
col: l.left
|
|
719
|
-
}), s[0]), r instanceof E && u.setSelection(new E(u.doc.resolve(r.$anchorCell.pos), d ? u.doc.resolve(d) : void 0)), n(u);
|
|
720
|
-
}
|
|
721
|
-
return !0;
|
|
722
|
-
};
|
|
723
|
-
}
|
|
724
|
-
function Ee(e, t) {
|
|
725
|
-
return function(n, r) {
|
|
726
|
-
if (!y(n)) return !1;
|
|
727
|
-
let i = b(n);
|
|
728
|
-
if (i.nodeAfter.attrs[e] === t) return !1;
|
|
729
|
-
if (r) {
|
|
730
|
-
let a = n.tr;
|
|
731
|
-
n.selection instanceof E ? n.selection.forEachCell((n, r) => {
|
|
732
|
-
n.attrs[e] !== t && a.setNodeMarkup(r, null, {
|
|
733
|
-
...n.attrs,
|
|
734
|
-
[e]: t
|
|
735
|
-
});
|
|
736
|
-
}) : a.setNodeMarkup(i.pos, null, {
|
|
737
|
-
...i.nodeAfter.attrs,
|
|
738
|
-
[e]: t
|
|
739
|
-
}), r(a);
|
|
740
|
-
}
|
|
741
|
-
return !0;
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
function De(e) {
|
|
745
|
-
return function(t, n) {
|
|
746
|
-
if (!y(t)) return !1;
|
|
747
|
-
if (n) {
|
|
748
|
-
let r = g(t.schema), i = k(t), a = t.tr, o = i.map.cellsInRect(e == "column" ? {
|
|
749
|
-
left: i.left,
|
|
750
|
-
top: 0,
|
|
751
|
-
right: i.right,
|
|
752
|
-
bottom: i.map.height
|
|
753
|
-
} : e == "row" ? {
|
|
754
|
-
left: 0,
|
|
755
|
-
top: i.top,
|
|
756
|
-
right: i.map.width,
|
|
757
|
-
bottom: i.bottom
|
|
758
|
-
} : i), s = o.map((e) => i.table.nodeAt(e));
|
|
759
|
-
for (let e = 0; e < o.length; e++) s[e].type == r.header_cell && a.setNodeMarkup(i.tableStart + o[e], r.cell, s[e].attrs);
|
|
760
|
-
if (a.steps.length === 0) for (let e = 0; e < o.length; e++) a.setNodeMarkup(i.tableStart + o[e], r.header_cell, s[e].attrs);
|
|
761
|
-
n(a);
|
|
762
|
-
}
|
|
763
|
-
return !0;
|
|
764
|
-
};
|
|
765
|
-
}
|
|
766
|
-
function P(e, t, n) {
|
|
767
|
-
let r = t.map.cellsInRect({
|
|
768
|
-
left: 0,
|
|
769
|
-
top: 0,
|
|
770
|
-
right: e == "row" ? t.map.width : 1,
|
|
771
|
-
bottom: e == "column" ? t.map.height : 1
|
|
772
|
-
});
|
|
773
|
-
for (let e = 0; e < r.length; e++) {
|
|
774
|
-
let i = t.table.nodeAt(r[e]);
|
|
775
|
-
if (i && i.type !== n.header_cell) return !1;
|
|
776
|
-
}
|
|
777
|
-
return !0;
|
|
778
|
-
}
|
|
779
|
-
function F(e, t) {
|
|
780
|
-
return t ||= { useDeprecatedLogic: !1 }, t.useDeprecatedLogic ? De(e) : function(t, n) {
|
|
781
|
-
if (!y(t)) return !1;
|
|
782
|
-
if (n) {
|
|
783
|
-
let r = g(t.schema), i = k(t), a = t.tr, o = P("row", i, r), s = P("column", i, r), c = (e === "column" ? o : e === "row" && s) ? 1 : 0, l = e == "column" ? {
|
|
784
|
-
left: 0,
|
|
785
|
-
top: c,
|
|
786
|
-
right: 1,
|
|
787
|
-
bottom: i.map.height
|
|
788
|
-
} : e == "row" ? {
|
|
789
|
-
left: c,
|
|
790
|
-
top: 0,
|
|
791
|
-
right: i.map.width,
|
|
792
|
-
bottom: 1
|
|
793
|
-
} : i, u = e == "column" ? s ? r.cell : r.header_cell : e == "row" ? o ? r.cell : r.header_cell : r.cell;
|
|
794
|
-
i.map.cellsInRect(l).forEach((e) => {
|
|
795
|
-
let t = e + i.tableStart, n = a.doc.nodeAt(t);
|
|
796
|
-
n && a.setNodeMarkup(t, u, n.attrs);
|
|
797
|
-
}), n(a);
|
|
798
|
-
}
|
|
799
|
-
return !0;
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
F("row", { useDeprecatedLogic: !0 }), F("column", { useDeprecatedLogic: !0 });
|
|
803
|
-
var Oe = F("cell", { useDeprecatedLogic: !0 });
|
|
804
|
-
function ke(e, t) {
|
|
805
|
-
if (t < 0) {
|
|
806
|
-
let t = e.nodeBefore;
|
|
807
|
-
if (t) return e.pos - t.nodeSize;
|
|
808
|
-
for (let t = e.index(-1) - 1, n = e.before(); t >= 0; t--) {
|
|
809
|
-
let r = e.node(-1).child(t), i = r.lastChild;
|
|
810
|
-
if (i) return n - 1 - i.nodeSize;
|
|
811
|
-
n -= r.nodeSize;
|
|
812
|
-
}
|
|
813
|
-
} else {
|
|
814
|
-
if (e.index() < e.parent.childCount - 1) return e.pos + e.nodeAfter.nodeSize;
|
|
815
|
-
let t = e.node(-1);
|
|
816
|
-
for (let n = e.indexAfter(-1), r = e.after(); n < t.childCount; n++) {
|
|
817
|
-
let e = t.child(n);
|
|
818
|
-
if (e.childCount) return r + 1;
|
|
819
|
-
r += e.nodeSize;
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
return null;
|
|
823
|
-
}
|
|
824
|
-
function Ae(e) {
|
|
825
|
-
return function(t, n) {
|
|
826
|
-
if (!y(t)) return !1;
|
|
827
|
-
let i = ke(b(t), e);
|
|
828
|
-
if (i == null) return !1;
|
|
829
|
-
if (n) {
|
|
830
|
-
let e = t.doc.resolve(i);
|
|
831
|
-
n(t.tr.setSelection(r.between(e, ae(e))).scrollIntoView());
|
|
832
|
-
}
|
|
833
|
-
return !0;
|
|
834
|
-
};
|
|
835
|
-
}
|
|
836
|
-
function je(e, t) {
|
|
837
|
-
let n = e.selection.$anchor;
|
|
838
|
-
for (let r = n.depth; r > 0; r--) if (n.node(r).type.spec.tableRole == "table") return t && t(e.tr.delete(n.before(r), n.after(r)).scrollIntoView()), !0;
|
|
839
|
-
return !1;
|
|
840
|
-
}
|
|
841
|
-
function I(e, n) {
|
|
842
|
-
let r = e.selection;
|
|
843
|
-
if (!(r instanceof E)) return !1;
|
|
844
|
-
if (n) {
|
|
845
|
-
let i = e.tr, a = g(e.schema).cell.createAndFill().content;
|
|
846
|
-
r.forEachCell((e, n) => {
|
|
847
|
-
e.content.eq(a) || i.replace(i.mapping.map(n + 1), i.mapping.map(n + e.nodeSize - 1), new t(a, 0, 0));
|
|
848
|
-
}), i.docChanged && n(i);
|
|
849
|
-
}
|
|
850
|
-
return !0;
|
|
851
|
-
}
|
|
852
|
-
function Me(e) {
|
|
853
|
-
if (e.size === 0) return null;
|
|
854
|
-
let { content: n, openStart: r, openEnd: i } = e;
|
|
855
|
-
for (; n.childCount == 1 && (r > 0 && i > 0 || n.child(0).type.spec.tableRole == "table");) r--, i--, n = n.child(0).content;
|
|
856
|
-
let a = n.child(0), o = a.type.spec.tableRole, s = a.type.schema, c = [];
|
|
857
|
-
if (o == "row") for (let e = 0; e < n.childCount; e++) {
|
|
858
|
-
let a = n.child(e).content, o = e ? 0 : Math.max(0, r - 1), l = e < n.childCount - 1 ? 0 : Math.max(0, i - 1);
|
|
859
|
-
(o || l) && (a = L(g(s).row, new t(a, o, l)).content), c.push(a);
|
|
860
|
-
}
|
|
861
|
-
else if (o == "cell" || o == "header_cell") c.push(r || i ? L(g(s).row, new t(n, r, i)).content : n);
|
|
862
|
-
else return null;
|
|
863
|
-
return Ne(s, c);
|
|
864
|
-
}
|
|
865
|
-
function Ne(t, n) {
|
|
866
|
-
let r = [];
|
|
867
|
-
for (let e = 0; e < n.length; e++) {
|
|
868
|
-
let t = n[e];
|
|
869
|
-
for (let n = t.childCount - 1; n >= 0; n--) {
|
|
870
|
-
let { rowspan: i, colspan: a } = t.child(n).attrs;
|
|
871
|
-
for (let t = e; t < e + i; t++) r[t] = (r[t] || 0) + a;
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
let i = 0;
|
|
875
|
-
for (let e = 0; e < r.length; e++) i = Math.max(i, r[e]);
|
|
876
|
-
for (let a = 0; a < r.length; a++) if (a >= n.length && n.push(e.empty), r[a] < i) {
|
|
877
|
-
let o = g(t).cell.createAndFill(), s = [];
|
|
878
|
-
for (let e = r[a]; e < i; e++) s.push(o);
|
|
879
|
-
n[a] = n[a].append(e.from(s));
|
|
880
|
-
}
|
|
881
|
-
return {
|
|
882
|
-
height: n.length,
|
|
883
|
-
width: i,
|
|
884
|
-
rows: n
|
|
885
|
-
};
|
|
886
|
-
}
|
|
887
|
-
function L(e, t) {
|
|
888
|
-
let n = e.createAndFill();
|
|
889
|
-
return new o(n).replace(0, n.content.size, t).doc;
|
|
890
|
-
}
|
|
891
|
-
function Pe({ width: t, height: n, rows: r }, i, a) {
|
|
892
|
-
if (t != i) {
|
|
893
|
-
let n = [], a = [];
|
|
894
|
-
for (let t = 0; t < r.length; t++) {
|
|
895
|
-
let o = r[t], s = [];
|
|
896
|
-
for (let e = n[t] || 0, r = 0; e < i; r++) {
|
|
897
|
-
let a = o.child(r % o.childCount);
|
|
898
|
-
e + a.attrs.colspan > i && (a = a.type.createChecked(w(a.attrs, a.attrs.colspan, e + a.attrs.colspan - i), a.content)), s.push(a), e += a.attrs.colspan;
|
|
899
|
-
for (let e = 1; e < a.attrs.rowspan; e++) n[t + e] = (n[t + e] || 0) + a.attrs.colspan;
|
|
900
|
-
}
|
|
901
|
-
a.push(e.from(s));
|
|
902
|
-
}
|
|
903
|
-
r = a, t = i;
|
|
904
|
-
}
|
|
905
|
-
if (n != a) {
|
|
906
|
-
let t = [];
|
|
907
|
-
for (let i = 0, o = 0; i < a; i++, o++) {
|
|
908
|
-
let s = [], c = r[o % n];
|
|
909
|
-
for (let e = 0; e < c.childCount; e++) {
|
|
910
|
-
let t = c.child(e);
|
|
911
|
-
i + t.attrs.rowspan > a && (t = t.type.create({
|
|
912
|
-
...t.attrs,
|
|
913
|
-
rowspan: Math.max(1, a - t.attrs.rowspan)
|
|
914
|
-
}, t.content)), s.push(t);
|
|
915
|
-
}
|
|
916
|
-
t.push(e.from(s));
|
|
917
|
-
}
|
|
918
|
-
r = t, n = a;
|
|
919
|
-
}
|
|
920
|
-
return {
|
|
921
|
-
width: t,
|
|
922
|
-
height: n,
|
|
923
|
-
rows: r
|
|
924
|
-
};
|
|
925
|
-
}
|
|
926
|
-
function Fe(t, n, r, i, a, o, s) {
|
|
927
|
-
let c = t.doc.type.schema, l = g(c), u, d;
|
|
928
|
-
if (a > n.width) for (let e = 0, o = 0; e < n.height; e++) {
|
|
929
|
-
let c = r.child(e);
|
|
930
|
-
o += c.nodeSize;
|
|
931
|
-
let f = [], p;
|
|
932
|
-
p = c.lastChild == null || c.lastChild.type == l.cell ? u ||= l.cell.createAndFill() : d ||= l.header_cell.createAndFill();
|
|
933
|
-
for (let e = n.width; e < a; e++) f.push(p);
|
|
934
|
-
t.insert(t.mapping.slice(s).map(o - 1 + i), f);
|
|
935
|
-
}
|
|
936
|
-
if (o > n.height) {
|
|
937
|
-
let c = [];
|
|
938
|
-
for (let e = 0, t = (n.height - 1) * n.width; e < Math.max(n.width, a); e++) {
|
|
939
|
-
let i = e >= n.width ? !1 : r.nodeAt(n.map[t + e]).type == l.header_cell;
|
|
940
|
-
c.push(i ? d ||= l.header_cell.createAndFill() : u ||= l.cell.createAndFill());
|
|
941
|
-
}
|
|
942
|
-
let f = l.row.create(null, e.from(c)), p = [];
|
|
943
|
-
for (let e = n.height; e < o; e++) p.push(f);
|
|
944
|
-
t.insert(t.mapping.slice(s).map(i + r.nodeSize - 2), p);
|
|
945
|
-
}
|
|
946
|
-
return !!(u || d);
|
|
947
|
-
}
|
|
948
|
-
function R(e, t, n, r, i, a, o, s) {
|
|
949
|
-
if (o == 0 || o == t.height) return !1;
|
|
950
|
-
let c = !1;
|
|
951
|
-
for (let l = i; l < a; l++) {
|
|
952
|
-
let i = o * t.width + l, a = t.map[i];
|
|
953
|
-
if (t.map[i - t.width] == a) {
|
|
954
|
-
c = !0;
|
|
955
|
-
let i = n.nodeAt(a), { top: u, left: d } = t.findCell(a);
|
|
956
|
-
e.setNodeMarkup(e.mapping.slice(s).map(a + r), null, {
|
|
957
|
-
...i.attrs,
|
|
958
|
-
rowspan: o - u
|
|
959
|
-
}), e.insert(e.mapping.slice(s).map(t.positionAt(o, d, n)), i.type.createAndFill({
|
|
960
|
-
...i.attrs,
|
|
961
|
-
rowspan: u + i.attrs.rowspan - o
|
|
962
|
-
})), l += i.attrs.colspan - 1;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
return c;
|
|
966
|
-
}
|
|
967
|
-
function z(e, t, n, r, i, a, o, s) {
|
|
968
|
-
if (o == 0 || o == t.width) return !1;
|
|
969
|
-
let c = !1;
|
|
970
|
-
for (let l = i; l < a; l++) {
|
|
971
|
-
let i = l * t.width + o, a = t.map[i];
|
|
972
|
-
if (t.map[i - 1] == a) {
|
|
973
|
-
c = !0;
|
|
974
|
-
let i = n.nodeAt(a), u = t.colCount(a), d = e.mapping.slice(s).map(a + r);
|
|
975
|
-
e.setNodeMarkup(d, null, w(i.attrs, o - u, i.attrs.colspan - (o - u))), e.insert(d + i.nodeSize, i.type.createAndFill(w(i.attrs, 0, o - u))), l += i.attrs.rowspan - 1;
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
return c;
|
|
979
|
-
}
|
|
980
|
-
function B(e, n, r, i, a) {
|
|
981
|
-
let o = r ? e.doc.nodeAt(r - 1) : e.doc;
|
|
982
|
-
if (!o) throw Error("No table found");
|
|
983
|
-
let s = m.get(o), { top: c, left: l } = i, u = l + a.width, d = c + a.height, f = e.tr, p = 0;
|
|
984
|
-
function h() {
|
|
985
|
-
if (o = r ? f.doc.nodeAt(r - 1) : f.doc, !o) throw Error("No table found");
|
|
986
|
-
s = m.get(o), p = f.mapping.maps.length;
|
|
987
|
-
}
|
|
988
|
-
Fe(f, s, o, r, u, d, p) && h(), R(f, s, o, r, l, u, c, p) && h(), R(f, s, o, r, l, u, d, p) && h(), z(f, s, o, r, c, d, l, p) && h(), z(f, s, o, r, c, d, u, p) && h();
|
|
989
|
-
for (let e = c; e < d; e++) {
|
|
990
|
-
let n = s.positionAt(e, l, o), i = s.positionAt(e, u, o);
|
|
991
|
-
f.replace(f.mapping.slice(p).map(n + r), f.mapping.slice(p).map(i + r), new t(a.rows[e - c], 0, 0));
|
|
992
|
-
}
|
|
993
|
-
h(), f.setSelection(new E(f.doc.resolve(r + s.positionAt(c, l, o)), f.doc.resolve(r + s.positionAt(d - 1, u - 1, o)))), n(f);
|
|
994
|
-
}
|
|
995
|
-
var Ie = d({
|
|
996
|
-
ArrowLeft: H("horiz", -1),
|
|
997
|
-
ArrowRight: H("horiz", 1),
|
|
998
|
-
ArrowUp: H("vert", -1),
|
|
999
|
-
ArrowDown: H("vert", 1),
|
|
1000
|
-
"Shift-ArrowLeft": U("horiz", -1),
|
|
1001
|
-
"Shift-ArrowRight": U("horiz", 1),
|
|
1002
|
-
"Shift-ArrowUp": U("vert", -1),
|
|
1003
|
-
"Shift-ArrowDown": U("vert", 1),
|
|
1004
|
-
Backspace: I,
|
|
1005
|
-
"Mod-Backspace": I,
|
|
1006
|
-
Delete: I,
|
|
1007
|
-
"Mod-Delete": I
|
|
1008
|
-
});
|
|
1009
|
-
function V(e, t, n) {
|
|
1010
|
-
return !n.eq(e.selection) && (t && t(e.tr.setSelection(n).scrollIntoView()), !0);
|
|
1011
|
-
}
|
|
1012
|
-
function H(e, t) {
|
|
1013
|
-
return (n, r, i) => {
|
|
1014
|
-
if (!i) return !1;
|
|
1015
|
-
let o = n.selection;
|
|
1016
|
-
if (o instanceof E) return V(n, r, a.near(o.$headCell, t));
|
|
1017
|
-
if (e != "horiz" && !o.empty) return !1;
|
|
1018
|
-
let s = W(i, e, t);
|
|
1019
|
-
if (s == null) return !1;
|
|
1020
|
-
if (e == "horiz") return V(n, r, a.near(n.doc.resolve(o.head + t), t));
|
|
1021
|
-
{
|
|
1022
|
-
let i = n.doc.resolve(s), o = C(i, e, t), c;
|
|
1023
|
-
return c = o ? a.near(o, 1) : t < 0 ? a.near(n.doc.resolve(i.before(-1)), -1) : a.near(n.doc.resolve(i.after(-1)), 1), V(n, r, c);
|
|
1024
|
-
}
|
|
1025
|
-
};
|
|
1026
|
-
}
|
|
1027
|
-
function U(e, t) {
|
|
1028
|
-
return (n, r, i) => {
|
|
1029
|
-
if (!i) return !1;
|
|
1030
|
-
let a = n.selection, o;
|
|
1031
|
-
if (a instanceof E) o = a;
|
|
1032
|
-
else {
|
|
1033
|
-
let r = W(i, e, t);
|
|
1034
|
-
if (r == null) return !1;
|
|
1035
|
-
o = new E(n.doc.resolve(r));
|
|
1036
|
-
}
|
|
1037
|
-
let s = C(o.$headCell, e, t);
|
|
1038
|
-
return s ? V(n, r, new E(o.$anchorCell, s)) : !1;
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
|
-
function Le(e, t) {
|
|
1042
|
-
let n = e.state.doc, r = v(n.resolve(t));
|
|
1043
|
-
return r ? (e.dispatch(e.state.tr.setSelection(new E(r))), !0) : !1;
|
|
1044
|
-
}
|
|
1045
|
-
function Re(t, n, r) {
|
|
1046
|
-
if (!y(t.state)) return !1;
|
|
1047
|
-
let i = Me(r), a = t.state.selection;
|
|
1048
|
-
if (a instanceof E) {
|
|
1049
|
-
i ||= {
|
|
1050
|
-
width: 1,
|
|
1051
|
-
height: 1,
|
|
1052
|
-
rows: [e.from(L(g(t.state.schema).cell, r))]
|
|
1053
|
-
};
|
|
1054
|
-
let n = a.$anchorCell.node(-1), o = a.$anchorCell.start(-1), s = m.get(n).rectBetween(a.$anchorCell.pos - o, a.$headCell.pos - o);
|
|
1055
|
-
return i = Pe(i, s.right - s.left, s.bottom - s.top), B(t.state, t.dispatch, o, s, i), !0;
|
|
1056
|
-
}
|
|
1057
|
-
if (i) {
|
|
1058
|
-
let e = b(t.state), n = e.start(-1);
|
|
1059
|
-
return B(t.state, t.dispatch, n, m.get(e.node(-1)).findCell(e.pos - n), i), !0;
|
|
1060
|
-
}
|
|
1061
|
-
return !1;
|
|
1062
|
-
}
|
|
1063
|
-
function ze(e, t) {
|
|
1064
|
-
if (t.button != 0 || t.ctrlKey || t.metaKey) return;
|
|
1065
|
-
let n = G(e, t.target), r;
|
|
1066
|
-
if (t.shiftKey && e.state.selection instanceof E) i(e.state.selection.$anchorCell, t), t.preventDefault();
|
|
1067
|
-
else if (t.shiftKey && n && (r = v(e.state.selection.$anchor)) != null && K(e, t)?.pos != r.pos) i(r, t), t.preventDefault();
|
|
1068
|
-
else if (!n) return;
|
|
1069
|
-
function i(t, n) {
|
|
1070
|
-
let r = K(e, n), i = _.getState(e.state) == null;
|
|
1071
|
-
if (!r || !S(t, r)) if (i) r = t;
|
|
1072
|
-
else return;
|
|
1073
|
-
let a = new E(t, r);
|
|
1074
|
-
if (i || !e.state.selection.eq(a)) {
|
|
1075
|
-
let n = e.state.tr.setSelection(a);
|
|
1076
|
-
i && n.setMeta(_, t.pos), e.dispatch(n);
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
function a() {
|
|
1080
|
-
e.root.removeEventListener("mouseup", a), e.root.removeEventListener("dragstart", a), e.root.removeEventListener("mousemove", o), _.getState(e.state) != null && e.dispatch(e.state.tr.setMeta(_, -1));
|
|
1081
|
-
}
|
|
1082
|
-
function o(r) {
|
|
1083
|
-
let o = r, s = _.getState(e.state), c;
|
|
1084
|
-
if (s != null) c = e.state.doc.resolve(s);
|
|
1085
|
-
else if (G(e, o.target) != n && (c = K(e, t), !c)) return a();
|
|
1086
|
-
c && i(c, o);
|
|
1087
|
-
}
|
|
1088
|
-
e.root.addEventListener("mouseup", a), e.root.addEventListener("dragstart", a), e.root.addEventListener("mousemove", o);
|
|
1089
|
-
}
|
|
1090
|
-
function W(e, t, n) {
|
|
1091
|
-
if (!(e.state.selection instanceof r)) return null;
|
|
1092
|
-
let { $head: i } = e.state.selection;
|
|
1093
|
-
for (let r = i.depth - 1; r >= 0; r--) {
|
|
1094
|
-
let a = i.node(r);
|
|
1095
|
-
if ((n < 0 ? i.index(r) : i.indexAfter(r)) != (n < 0 ? 0 : a.childCount)) return null;
|
|
1096
|
-
if (a.type.spec.tableRole == "cell" || a.type.spec.tableRole == "header_cell") {
|
|
1097
|
-
let a = i.before(r), o = t == "vert" ? n > 0 ? "down" : "up" : n > 0 ? "right" : "left";
|
|
1098
|
-
return e.endOfTextblock(o) ? a : null;
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
return null;
|
|
1102
|
-
}
|
|
1103
|
-
function G(e, t) {
|
|
1104
|
-
for (; t && t != e.dom; t = t.parentNode) if (t.nodeName == "TD" || t.nodeName == "TH") return t;
|
|
1105
|
-
return null;
|
|
1106
|
-
}
|
|
1107
|
-
function K(e, t) {
|
|
1108
|
-
let n = e.posAtCoords({
|
|
1109
|
-
left: t.clientX,
|
|
1110
|
-
top: t.clientY
|
|
1111
|
-
});
|
|
1112
|
-
if (!n) return null;
|
|
1113
|
-
let { inside: r, pos: i } = n;
|
|
1114
|
-
return r >= 0 && v(e.state.doc.resolve(r)) || v(e.state.doc.resolve(i));
|
|
1115
|
-
}
|
|
1116
|
-
var Be = class {
|
|
1117
|
-
constructor(e, t) {
|
|
1118
|
-
this.node = e, this.defaultCellMinWidth = t, this.dom = document.createElement("div"), this.dom.className = "tableWrapper", this.table = this.dom.appendChild(document.createElement("table")), this.table.style.setProperty("--default-cell-min-width", `${t}px`), this.colgroup = this.table.appendChild(document.createElement("colgroup")), q(e, this.colgroup, this.table, t), this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
1119
|
-
}
|
|
1120
|
-
update(e) {
|
|
1121
|
-
return e.type == this.node.type && (this.node = e, q(e, this.colgroup, this.table, this.defaultCellMinWidth), !0);
|
|
1122
|
-
}
|
|
1123
|
-
ignoreMutation(e) {
|
|
1124
|
-
return e.type == "attributes" && (e.target == this.table || this.colgroup.contains(e.target));
|
|
1125
|
-
}
|
|
1126
|
-
};
|
|
1127
|
-
function q(e, t, n, r, i, a) {
|
|
1128
|
-
let o = 0, s = !0, c = t.firstChild, l = e.firstChild;
|
|
1129
|
-
if (l) {
|
|
1130
|
-
for (let e = 0, n = 0; e < l.childCount; e++) {
|
|
1131
|
-
let { colspan: u, colwidth: d } = l.child(e).attrs;
|
|
1132
|
-
for (let e = 0; e < u; e++, n++) {
|
|
1133
|
-
let l = i == n ? a : d && d[e], u = l ? l + "px" : "";
|
|
1134
|
-
if (o += l || r, l || (s = !1), c) c.style.width != u && (c.style.width = u), c = c.nextSibling;
|
|
1135
|
-
else {
|
|
1136
|
-
let e = document.createElement("col");
|
|
1137
|
-
e.style.width = u, t.appendChild(e);
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
for (; c;) {
|
|
1142
|
-
var u;
|
|
1143
|
-
let e = c.nextSibling;
|
|
1144
|
-
(u = c.parentNode) == null || u.removeChild(c), c = e;
|
|
1145
|
-
}
|
|
1146
|
-
s ? (n.style.width = o + "px", n.style.minWidth = "") : (n.style.width = "", n.style.minWidth = o + "px");
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
var J = new n("tableColumnResizing");
|
|
1150
|
-
function Ve({ handleWidth: e = 5, cellMinWidth: t = 25, defaultCellMinWidth: n = 100, View: r = Be, lastColumnResizable: a = !0 } = {}) {
|
|
1151
|
-
let o = new i({
|
|
1152
|
-
key: J,
|
|
1153
|
-
state: {
|
|
1154
|
-
init(e, t) {
|
|
1155
|
-
var i;
|
|
1156
|
-
let a = (i = o.spec) == null || (i = i.props) == null ? void 0 : i.nodeViews, s = g(t.schema).table.name;
|
|
1157
|
-
return r && a && (a[s] = (e, t) => new r(e, n, t)), new He(-1, !1);
|
|
1158
|
-
},
|
|
1159
|
-
apply(e, t) {
|
|
1160
|
-
return t.apply(e);
|
|
1161
|
-
}
|
|
1162
|
-
},
|
|
1163
|
-
props: {
|
|
1164
|
-
attributes: (e) => {
|
|
1165
|
-
let t = J.getState(e);
|
|
1166
|
-
return t && t.activeHandle > -1 ? { class: "resize-cursor" } : {};
|
|
1167
|
-
},
|
|
1168
|
-
handleDOMEvents: {
|
|
1169
|
-
mousemove: (t, n) => {
|
|
1170
|
-
Ue(t, n, e, a);
|
|
1171
|
-
},
|
|
1172
|
-
mouseleave: (e) => {
|
|
1173
|
-
We(e);
|
|
1174
|
-
},
|
|
1175
|
-
mousedown: (e, r) => {
|
|
1176
|
-
Ge(e, r, t, n);
|
|
1177
|
-
}
|
|
1178
|
-
},
|
|
1179
|
-
decorations: (e) => {
|
|
1180
|
-
let t = J.getState(e);
|
|
1181
|
-
if (t && t.activeHandle > -1) return Ye(e, t.activeHandle);
|
|
1182
|
-
},
|
|
1183
|
-
nodeViews: {}
|
|
1184
|
-
}
|
|
1185
|
-
});
|
|
1186
|
-
return o;
|
|
1187
|
-
}
|
|
1188
|
-
var He = class e {
|
|
1189
|
-
constructor(e, t) {
|
|
1190
|
-
this.activeHandle = e, this.dragging = t;
|
|
1191
|
-
}
|
|
1192
|
-
apply(t) {
|
|
1193
|
-
let n = this, r = t.getMeta(J);
|
|
1194
|
-
if (r && r.setHandle != null) return new e(r.setHandle, !1);
|
|
1195
|
-
if (r && r.setDragging !== void 0) return new e(n.activeHandle, r.setDragging);
|
|
1196
|
-
if (n.activeHandle > -1 && t.docChanged) {
|
|
1197
|
-
let r = t.mapping.map(n.activeHandle, -1);
|
|
1198
|
-
return x(t.doc.resolve(r)) || (r = -1), new e(r, n.dragging);
|
|
1199
|
-
}
|
|
1200
|
-
return n;
|
|
1201
|
-
}
|
|
1202
|
-
};
|
|
1203
|
-
function Ue(e, t, n, r) {
|
|
1204
|
-
if (!e.editable) return;
|
|
1205
|
-
let i = J.getState(e.state);
|
|
1206
|
-
if (i && !i.dragging) {
|
|
1207
|
-
let a = Ke(t.target), o = -1;
|
|
1208
|
-
if (a) {
|
|
1209
|
-
let { left: r, right: i } = a.getBoundingClientRect();
|
|
1210
|
-
t.clientX - r <= n ? o = X(e, t, "left", n) : i - t.clientX <= n && (o = X(e, t, "right", n));
|
|
1211
|
-
}
|
|
1212
|
-
if (o != i.activeHandle) {
|
|
1213
|
-
if (!r && o !== -1) {
|
|
1214
|
-
let t = e.state.doc.resolve(o), n = t.node(-1), r = m.get(n), i = t.start(-1);
|
|
1215
|
-
if (r.colCount(t.pos - i) + t.nodeAfter.attrs.colspan - 1 == r.width - 1) return;
|
|
1216
|
-
}
|
|
1217
|
-
Q(e, o);
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
function We(e) {
|
|
1222
|
-
if (!e.editable) return;
|
|
1223
|
-
let t = J.getState(e.state);
|
|
1224
|
-
t && t.activeHandle > -1 && !t.dragging && Q(e, -1);
|
|
1225
|
-
}
|
|
1226
|
-
function Ge(e, t, n, r) {
|
|
1227
|
-
if (!e.editable) return !1;
|
|
1228
|
-
let i = e.dom.ownerDocument.defaultView ?? window, a = J.getState(e.state);
|
|
1229
|
-
if (!a || a.activeHandle == -1 || a.dragging) return !1;
|
|
1230
|
-
let o = e.state.doc.nodeAt(a.activeHandle), s = Y(e, a.activeHandle, o.attrs);
|
|
1231
|
-
e.dispatch(e.state.tr.setMeta(J, { setDragging: {
|
|
1232
|
-
startX: t.clientX,
|
|
1233
|
-
startWidth: s
|
|
1234
|
-
} }));
|
|
1235
|
-
function c(t) {
|
|
1236
|
-
i.removeEventListener("mouseup", c), i.removeEventListener("mousemove", l);
|
|
1237
|
-
let r = J.getState(e.state);
|
|
1238
|
-
r?.dragging && (qe(e, r.activeHandle, Z(r.dragging, t, n)), e.dispatch(e.state.tr.setMeta(J, { setDragging: null })));
|
|
1239
|
-
}
|
|
1240
|
-
function l(t) {
|
|
1241
|
-
if (!t.which) return c(t);
|
|
1242
|
-
let i = J.getState(e.state);
|
|
1243
|
-
if (i && i.dragging) {
|
|
1244
|
-
let a = Z(i.dragging, t, n);
|
|
1245
|
-
$(e, i.activeHandle, a, r);
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
return $(e, a.activeHandle, s, r), i.addEventListener("mouseup", c), i.addEventListener("mousemove", l), t.preventDefault(), !0;
|
|
1249
|
-
}
|
|
1250
|
-
function Y(e, t, { colspan: n, colwidth: r }) {
|
|
1251
|
-
let i = r && r[r.length - 1];
|
|
1252
|
-
if (i) return i;
|
|
1253
|
-
let a = e.domAtPos(t), o = a.node.childNodes[a.offset].offsetWidth, s = n;
|
|
1254
|
-
if (r) for (let e = 0; e < n; e++) r[e] && (o -= r[e], s--);
|
|
1255
|
-
return o / s;
|
|
1256
|
-
}
|
|
1257
|
-
function Ke(e) {
|
|
1258
|
-
for (; e && e.nodeName != "TD" && e.nodeName != "TH";) e = e.classList && e.classList.contains("ProseMirror") ? null : e.parentNode;
|
|
1259
|
-
return e;
|
|
1260
|
-
}
|
|
1261
|
-
function X(e, t, n, r) {
|
|
1262
|
-
let i = n == "right" ? -r : r, a = e.posAtCoords({
|
|
1263
|
-
left: t.clientX + i,
|
|
1264
|
-
top: t.clientY
|
|
1265
|
-
});
|
|
1266
|
-
if (!a) return -1;
|
|
1267
|
-
let { pos: o } = a, s = v(e.state.doc.resolve(o));
|
|
1268
|
-
if (!s) return -1;
|
|
1269
|
-
if (n == "right") return s.pos;
|
|
1270
|
-
let c = m.get(s.node(-1)), l = s.start(-1), u = c.map.indexOf(s.pos - l);
|
|
1271
|
-
return u % c.width == 0 ? -1 : l + c.map[u - 1];
|
|
1272
|
-
}
|
|
1273
|
-
function Z(e, t, n) {
|
|
1274
|
-
let r = t.clientX - e.startX;
|
|
1275
|
-
return Math.max(n, e.startWidth + r);
|
|
1276
|
-
}
|
|
1277
|
-
function Q(e, t) {
|
|
1278
|
-
e.dispatch(e.state.tr.setMeta(J, { setHandle: t }));
|
|
1279
|
-
}
|
|
1280
|
-
function qe(e, t, n) {
|
|
1281
|
-
let r = e.state.doc.resolve(t), i = r.node(-1), a = m.get(i), o = r.start(-1), s = a.colCount(r.pos - o) + r.nodeAfter.attrs.colspan - 1, c = e.state.tr;
|
|
1282
|
-
for (let e = 0; e < a.height; e++) {
|
|
1283
|
-
let t = e * a.width + s;
|
|
1284
|
-
if (e && a.map[t] == a.map[t - a.width]) continue;
|
|
1285
|
-
let r = a.map[t], l = i.nodeAt(r).attrs, u = l.colspan == 1 ? 0 : s - a.colCount(r);
|
|
1286
|
-
if (l.colwidth && l.colwidth[u] == n) continue;
|
|
1287
|
-
let d = l.colwidth ? l.colwidth.slice() : Je(l.colspan);
|
|
1288
|
-
d[u] = n, c.setNodeMarkup(o + r, null, {
|
|
1289
|
-
...l,
|
|
1290
|
-
colwidth: d
|
|
1291
|
-
});
|
|
1292
|
-
}
|
|
1293
|
-
c.docChanged && e.dispatch(c);
|
|
1294
|
-
}
|
|
1295
|
-
function $(e, t, n, r) {
|
|
1296
|
-
let i = e.state.doc.resolve(t), a = i.node(-1), o = i.start(-1), s = m.get(a).colCount(i.pos - o) + i.nodeAfter.attrs.colspan - 1, c = e.domAtPos(i.start(-1)).node;
|
|
1297
|
-
for (; c && c.nodeName != "TABLE";) c = c.parentNode;
|
|
1298
|
-
c && q(a, c.firstChild, c, r, s, n);
|
|
1299
|
-
}
|
|
1300
|
-
function Je(e) {
|
|
1301
|
-
return Array(e).fill(0);
|
|
1302
|
-
}
|
|
1303
|
-
function Ye(e, t) {
|
|
1304
|
-
let n = [], r = e.doc.resolve(t), i = r.node(-1);
|
|
1305
|
-
if (!i) return u.empty;
|
|
1306
|
-
let a = m.get(i), o = r.start(-1), s = a.colCount(r.pos - o) + r.nodeAfter.attrs.colspan - 1;
|
|
1307
|
-
for (let t = 0; t < a.height; t++) {
|
|
1308
|
-
let r = s + t * a.width;
|
|
1309
|
-
if ((s == a.width - 1 || a.map[r] != a.map[r + 1]) && (t == 0 || a.map[r] != a.map[r - a.width])) {
|
|
1310
|
-
let t = a.map[r], s = o + t + i.nodeAt(t).nodeSize - 1, c = document.createElement("div");
|
|
1311
|
-
c.className = "column-resize-handle", J.getState(e)?.dragging && n.push(l.node(o + t, o + t + i.nodeAt(t).nodeSize, { class: "column-resize-dragging" })), n.push(l.widget(s, c));
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
return u.create(e.doc, n);
|
|
1315
|
-
}
|
|
1316
|
-
function Xe({ allowTableNodeSelection: e = !1 } = {}) {
|
|
1317
|
-
return new i({
|
|
1318
|
-
key: _,
|
|
1319
|
-
state: {
|
|
1320
|
-
init() {
|
|
1321
|
-
return null;
|
|
1322
|
-
},
|
|
1323
|
-
apply(e, t) {
|
|
1324
|
-
let n = e.getMeta(_);
|
|
1325
|
-
if (n != null) return n == -1 ? null : n;
|
|
1326
|
-
if (t == null || !e.docChanged) return t;
|
|
1327
|
-
let { deleted: r, pos: i } = e.mapping.mapResult(t);
|
|
1328
|
-
return r ? null : i;
|
|
1329
|
-
}
|
|
1330
|
-
},
|
|
1331
|
-
props: {
|
|
1332
|
-
decorations: ce,
|
|
1333
|
-
handleDOMEvents: { mousedown: ze },
|
|
1334
|
-
createSelectionBetween(e) {
|
|
1335
|
-
return _.getState(e.state) == null ? null : e.state.selection;
|
|
1336
|
-
},
|
|
1337
|
-
handleTripleClick: Le,
|
|
1338
|
-
handleKeyDown: Ie,
|
|
1339
|
-
handlePaste: Re
|
|
1340
|
-
},
|
|
1341
|
-
appendTransaction(t, n, r) {
|
|
1342
|
-
return de(r, O(r, n), e);
|
|
1343
|
-
}
|
|
1344
|
-
});
|
|
1345
|
-
}
|
|
1346
|
-
//#endregion
|
|
1347
|
-
export { Oe as _, ye as a, M as c, Ae as d, Ce as f, F as g, Xe as h, be as i, je as l, we as m, he as n, Ve as o, Ee as p, me as r, _e as s, E as t, O as u };
|