@pie-element/shared-editor-runtime 0.1.1-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/dist/browser/dist-86k79VvK.js +1829 -0
- package/dist/browser/dist-86k79VvK.js.map +1 -0
- package/dist/browser/dist-BiHYI9ZI.js +3508 -0
- package/dist/browser/dist-BiHYI9ZI.js.map +1 -0
- package/dist/browser/dist-BzUsSMiM.js +933 -0
- package/dist/browser/dist-BzUsSMiM.js.map +1 -0
- package/dist/browser/dist-DlTupuCB.js +8000 -0
- package/dist/browser/dist-DlTupuCB.js.map +1 -0
- package/dist/browser/dist-DyMj6m6j.js +996 -0
- package/dist/browser/dist-DyMj6m6j.js.map +1 -0
- package/dist/browser/prosemirror-state/index.js +2 -0
- package/dist/browser/tiptap-core/index.js +2 -0
- package/dist/browser/tiptap-extension-character-count/index.js +7 -0
- package/dist/browser/tiptap-extension-character-count/index.js.map +1 -0
- package/dist/browser/tiptap-extension-image/index.js +133 -0
- package/dist/browser/tiptap-extension-image/index.js.map +1 -0
- package/dist/browser/tiptap-extension-list-item/index.js +7 -0
- package/dist/browser/tiptap-extension-list-item/index.js.map +1 -0
- package/dist/browser/tiptap-extension-placeholder/index.js +7 -0
- package/dist/browser/tiptap-extension-placeholder/index.js.map +1 -0
- package/dist/browser/tiptap-extension-subscript/index.js +37 -0
- package/dist/browser/tiptap-extension-subscript/index.js.map +1 -0
- package/dist/browser/tiptap-extension-superscript/index.js +37 -0
- package/dist/browser/tiptap-extension-superscript/index.js.map +1 -0
- package/dist/browser/tiptap-extension-table/index.js +2 -0
- package/dist/browser/tiptap-extension-table-cell/index.js +7 -0
- package/dist/browser/tiptap-extension-table-cell/index.js.map +1 -0
- package/dist/browser/tiptap-extension-table-header/index.js +7 -0
- package/dist/browser/tiptap-extension-table-header/index.js.map +1 -0
- package/dist/browser/tiptap-extension-table-row/index.js +7 -0
- package/dist/browser/tiptap-extension-table-row/index.js.map +1 -0
- package/dist/browser/tiptap-extension-text-align/index.js +49 -0
- package/dist/browser/tiptap-extension-text-align/index.js.map +1 -0
- package/dist/browser/tiptap-extension-text-style/index.js +166 -0
- package/dist/browser/tiptap-extension-text-style/index.js.map +1 -0
- package/dist/browser/tiptap-extensions/index.js +2 -0
- package/dist/browser/tiptap-pm-state/index.js +2 -0
- package/dist/browser/tiptap-starter-kit/index.js +1642 -0
- package/dist/browser/tiptap-starter-kit/index.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,1829 @@
|
|
|
1
|
+
import { Bn as e, Hn as t, J as n, Vn as r, gn as i, it as a, m as o, s, w as c } from "./dist-DlTupuCB.js";
|
|
2
|
+
import { a as l, c as u, i as d, k as f, m as p, o as m, r as ee, s as te, w as h } from "./dist-BiHYI9ZI.js";
|
|
3
|
+
//#region ../../../node_modules/.bun/prosemirror-tables@1.8.5/node_modules/prosemirror-tables/dist/index.js
|
|
4
|
+
var g, _;
|
|
5
|
+
if (typeof WeakMap < "u") {
|
|
6
|
+
let e = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
g = (t) => e.get(t), _ = (t, n) => (e.set(t, n), n);
|
|
8
|
+
} else {
|
|
9
|
+
let e = [], t = 0;
|
|
10
|
+
g = (t) => {
|
|
11
|
+
for (let n = 0; n < e.length; n += 2) if (e[n] == t) return e[n + 1];
|
|
12
|
+
}, _ = (n, r) => (t == 10 && (t = 0), e[t++] = n, e[t++] = r);
|
|
13
|
+
}
|
|
14
|
+
var v = 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 g(e) || _(e, ne(e));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
function ne(e) {
|
|
75
|
+
if (e.type.spec.tableRole != "table") throw RangeError("Not a table node: " + e.type.name);
|
|
76
|
+
let t = re(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 v(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 && ie(s, o, e), s;
|
|
123
|
+
}
|
|
124
|
+
function re(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 ie(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 ||= ae(c))[n] = r);
|
|
156
|
+
}
|
|
157
|
+
s && e.problems.unshift({
|
|
158
|
+
type: "colwidth mismatch",
|
|
159
|
+
pos: a,
|
|
160
|
+
colwidth: s
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function ae(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 y(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 b = new l("selectingCells");
|
|
182
|
+
function x(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 oe(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 S(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 C(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 = x(t.$head) || se(t.$head);
|
|
203
|
+
if (n) return n;
|
|
204
|
+
throw RangeError(`No cell found around position ${t.head}`);
|
|
205
|
+
}
|
|
206
|
+
function se(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 w(e) {
|
|
217
|
+
return e.parent.type.spec.tableRole == "row" && !!e.nodeAfter;
|
|
218
|
+
}
|
|
219
|
+
function ce(e) {
|
|
220
|
+
return e.node(0).resolve(e.pos + e.nodeAfter.nodeSize);
|
|
221
|
+
}
|
|
222
|
+
function T(e, t) {
|
|
223
|
+
return e.depth == t.depth && e.pos >= t.start(-1) && e.pos <= t.end(-1);
|
|
224
|
+
}
|
|
225
|
+
function le(e, t, n) {
|
|
226
|
+
let r = e.node(-1), i = v.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 E(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 ue(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 de(e, t, n) {
|
|
248
|
+
let r = y(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 D = class e extends m {
|
|
253
|
+
constructor(e, t = e) {
|
|
254
|
+
let n = e.node(-1), r = v.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 c = 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 te(o.resolve(r), o.resolve(r + t.content.size));
|
|
261
|
+
});
|
|
262
|
+
super(c[0].$from, c[0].$to, c), this.$anchorCell = e, this.$headCell = t;
|
|
263
|
+
}
|
|
264
|
+
map(t, n) {
|
|
265
|
+
let r = t.resolve(n.map(this.$anchorCell.pos)), i = t.resolve(n.map(this.$headCell.pos));
|
|
266
|
+
if (w(r) && w(i) && T(r, i)) {
|
|
267
|
+
let t = this.$anchorCell.node(-1) != r.node(-1);
|
|
268
|
+
return t && this.isRowSelection() ? e.rowSelection(r, i) : t && this.isColSelection() ? e.colSelection(r, i) : new e(r, i);
|
|
269
|
+
}
|
|
270
|
+
return u.between(r, i);
|
|
271
|
+
}
|
|
272
|
+
content() {
|
|
273
|
+
let e = this.$anchorCell.node(-1), t = v.get(e), n = this.$anchorCell.start(-1), r = t.rectBetween(this.$anchorCell.pos - n, this.$headCell.pos - n), i = {}, a = [];
|
|
274
|
+
for (let n = r.top; n < r.bottom; n++) {
|
|
275
|
+
let o = [];
|
|
276
|
+
for (let a = n * t.width + r.left, s = r.left; s < r.right; s++, a++) {
|
|
277
|
+
let n = t.map[a];
|
|
278
|
+
if (i[n]) continue;
|
|
279
|
+
i[n] = !0;
|
|
280
|
+
let s = t.findCell(n), c = e.nodeAt(n);
|
|
281
|
+
if (!c) throw RangeError(`No cell with offset ${n} found`);
|
|
282
|
+
let l = r.left - s.left, u = s.right - r.right;
|
|
283
|
+
if (l > 0 || u > 0) {
|
|
284
|
+
let e = c.attrs;
|
|
285
|
+
if (l > 0 && (e = E(e, 0, l)), u > 0 && (e = E(e, e.colspan - u, u)), s.left < r.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 < r.top || s.bottom > r.bottom) {
|
|
290
|
+
let e = {
|
|
291
|
+
...c.attrs,
|
|
292
|
+
rowspan: Math.min(s.bottom, r.bottom) - Math.max(s.top, r.top)
|
|
293
|
+
};
|
|
294
|
+
c = s.top < r.top ? c.type.createAndFill(e) : c.type.create(e, c.content);
|
|
295
|
+
}
|
|
296
|
+
o.push(c);
|
|
297
|
+
}
|
|
298
|
+
a.push(e.child(n).copy(h.from(o)));
|
|
299
|
+
}
|
|
300
|
+
let o = this.isColSelection() && this.isRowSelection() ? e : a;
|
|
301
|
+
return new f(h.from(o), 1, 1);
|
|
302
|
+
}
|
|
303
|
+
replace(e, t = f.empty) {
|
|
304
|
+
let n = e.steps.length, r = this.ranges;
|
|
305
|
+
for (let i = 0; i < r.length; i++) {
|
|
306
|
+
let { $from: a, $to: o } = r[i], s = e.mapping.slice(n);
|
|
307
|
+
e.replace(s.map(a.pos), s.map(o.pos), i ? f.empty : t);
|
|
308
|
+
}
|
|
309
|
+
let i = m.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)), -1);
|
|
310
|
+
i && e.setSelection(i);
|
|
311
|
+
}
|
|
312
|
+
replaceWith(e, t) {
|
|
313
|
+
this.replace(e, new f(h.from(t), 0, 0));
|
|
314
|
+
}
|
|
315
|
+
forEachCell(e) {
|
|
316
|
+
let t = this.$anchorCell.node(-1), n = v.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(t, n = t) {
|
|
326
|
+
let r = t.node(-1), i = v.get(r), a = t.start(-1), o = i.findCell(t.pos - a), s = i.findCell(n.pos - a), c = t.node(0);
|
|
327
|
+
return o.top <= s.top ? (o.top > 0 && (t = c.resolve(a + i.map[o.left])), s.bottom < i.height && (n = c.resolve(a + i.map[i.width * (i.height - 1) + s.right - 1]))) : (s.top > 0 && (n = c.resolve(a + i.map[s.left])), o.bottom < i.height && (t = c.resolve(a + i.map[i.width * (i.height - 1) + o.right - 1]))), new e(t, n);
|
|
328
|
+
}
|
|
329
|
+
isRowSelection() {
|
|
330
|
+
let e = this.$anchorCell.node(-1), t = v.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(t) {
|
|
336
|
+
return t instanceof e && t.$anchorCell.pos == this.$anchorCell.pos && t.$headCell.pos == this.$headCell.pos;
|
|
337
|
+
}
|
|
338
|
+
static rowSelection(t, n = t) {
|
|
339
|
+
let r = t.node(-1), i = v.get(r), a = t.start(-1), o = i.findCell(t.pos - a), s = i.findCell(n.pos - a), c = t.node(0);
|
|
340
|
+
return o.left <= s.left ? (o.left > 0 && (t = c.resolve(a + i.map[o.top * i.width])), s.right < i.width && (n = c.resolve(a + i.map[i.width * (s.top + 1) - 1]))) : (s.left > 0 && (n = c.resolve(a + i.map[s.top * i.width])), o.right < i.width && (t = c.resolve(a + i.map[i.width * (o.top + 1) - 1]))), new e(t, n);
|
|
341
|
+
}
|
|
342
|
+
toJSON() {
|
|
343
|
+
return {
|
|
344
|
+
type: "cell",
|
|
345
|
+
anchor: this.$anchorCell.pos,
|
|
346
|
+
head: this.$headCell.pos
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
static fromJSON(t, n) {
|
|
350
|
+
return new e(t.resolve(n.anchor), t.resolve(n.head));
|
|
351
|
+
}
|
|
352
|
+
static create(t, n, r = n) {
|
|
353
|
+
return new e(t.resolve(n), t.resolve(r));
|
|
354
|
+
}
|
|
355
|
+
getBookmark() {
|
|
356
|
+
return new fe(this.$anchorCell.pos, this.$headCell.pos);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
D.prototype.visible = !1, m.jsonID("cell", D);
|
|
360
|
+
var fe = 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 && T(t, n) ? new D(t, n) : m.near(n, 1);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
function pe(e) {
|
|
373
|
+
if (!(e.selection instanceof D)) return null;
|
|
374
|
+
let n = [];
|
|
375
|
+
return e.selection.forEachCell((e, t) => {
|
|
376
|
+
n.push(r.node(t, t + e.nodeSize, { class: "selectedCell" }));
|
|
377
|
+
}), t.create(e.doc, n);
|
|
378
|
+
}
|
|
379
|
+
function me({ $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 he({ $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 ge(e, t, n) {
|
|
405
|
+
let r = (t || e).selection, i = (t || e).doc, a, o;
|
|
406
|
+
if (r instanceof ee && (o = r.node.type.spec.tableRole)) {
|
|
407
|
+
if (o == "cell" || o == "header_cell") a = D.create(i, r.from);
|
|
408
|
+
else if (o == "row") {
|
|
409
|
+
let e = i.resolve(r.from + 1);
|
|
410
|
+
a = D.rowSelection(e, e);
|
|
411
|
+
} else if (!n) {
|
|
412
|
+
let e = v.get(r.node), t = r.from + 1, n = t + e.map[e.width * e.height - 1];
|
|
413
|
+
a = D.create(i, t + 1, n);
|
|
414
|
+
}
|
|
415
|
+
} else r instanceof u && me(r) ? a = u.create(i, r.from) : r instanceof u && he(r) && (a = u.create(i, r.$from.start(), r.$from.end()));
|
|
416
|
+
return a && (t ||= e.tr).setSelection(a), t;
|
|
417
|
+
}
|
|
418
|
+
var _e = new l("fix-tables");
|
|
419
|
+
function O(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) ? O(e.child(s), a, n + 1, r) : a.nodesBetween(0, a.content.size, r, n + 1), n += a.nodeSize;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
function k(e, t) {
|
|
431
|
+
let n, r = (t, r) => {
|
|
432
|
+
t.type.spec.tableRole == "table" && (n = ve(e, t, r, n));
|
|
433
|
+
};
|
|
434
|
+
return t ? t.doc != e.doc && O(t.doc, e.doc, 0, r) : e.doc.descendants(r), n;
|
|
435
|
+
}
|
|
436
|
+
function ve(e, t, n, r) {
|
|
437
|
+
let i = v.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, E(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 = y(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(_e, { fixTables: !0 });
|
|
488
|
+
}
|
|
489
|
+
function A(e) {
|
|
490
|
+
let t = e.selection, n = C(e), r = n.node(-1), i = n.start(-1), a = v.get(r);
|
|
491
|
+
return {
|
|
492
|
+
...t instanceof D ? 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 j(e, { map: t, tableStart: n, table: r }, i) {
|
|
499
|
+
let a = i > 0 ? -1 : 0;
|
|
500
|
+
de(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, ue(c.attrs, i - t.colCount(a))), o += c.attrs.rowspan - 1;
|
|
506
|
+
} else {
|
|
507
|
+
let c = a == null ? y(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 ye(e, t) {
|
|
514
|
+
if (!S(e)) return !1;
|
|
515
|
+
if (t) {
|
|
516
|
+
let n = A(e);
|
|
517
|
+
t(j(e.tr, n, n.left));
|
|
518
|
+
}
|
|
519
|
+
return !0;
|
|
520
|
+
}
|
|
521
|
+
function be(e, t) {
|
|
522
|
+
if (!S(e)) return !1;
|
|
523
|
+
if (t) {
|
|
524
|
+
let n = A(e);
|
|
525
|
+
t(j(e.tr, n, n.right));
|
|
526
|
+
}
|
|
527
|
+
return !0;
|
|
528
|
+
}
|
|
529
|
+
function xe(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, E(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 Se(e, t) {
|
|
542
|
+
if (!S(e)) return !1;
|
|
543
|
+
if (t) {
|
|
544
|
+
let n = A(e), r = e.tr;
|
|
545
|
+
if (n.left == 0 && n.right == n.map.width) return !1;
|
|
546
|
+
for (let e = n.right - 1; xe(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 = v.get(e);
|
|
550
|
+
}
|
|
551
|
+
t(r);
|
|
552
|
+
}
|
|
553
|
+
return !0;
|
|
554
|
+
}
|
|
555
|
+
function Ce(e, t, n) {
|
|
556
|
+
let r = y(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 M(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
|
+
Ce(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 ? y(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, y(r.type.schema).row.create(null, o)), e;
|
|
576
|
+
}
|
|
577
|
+
function we(e, t) {
|
|
578
|
+
if (!S(e)) return !1;
|
|
579
|
+
if (t) {
|
|
580
|
+
let n = A(e);
|
|
581
|
+
t(M(e.tr, n, n.top));
|
|
582
|
+
}
|
|
583
|
+
return !0;
|
|
584
|
+
}
|
|
585
|
+
function Te(e, t) {
|
|
586
|
+
if (!S(e)) return !1;
|
|
587
|
+
if (t) {
|
|
588
|
+
let n = A(e);
|
|
589
|
+
t(M(e.tr, n, n.bottom));
|
|
590
|
+
}
|
|
591
|
+
return !0;
|
|
592
|
+
}
|
|
593
|
+
function Ee(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 De(e, t) {
|
|
619
|
+
if (!S(e)) return !1;
|
|
620
|
+
if (t) {
|
|
621
|
+
let n = A(e), r = e.tr;
|
|
622
|
+
if (n.top == 0 && n.bottom == n.map.height) return !1;
|
|
623
|
+
for (let e = n.bottom - 1; Ee(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 = v.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 Oe({ 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 P(e, t) {
|
|
649
|
+
let n = e.selection;
|
|
650
|
+
if (!(n instanceof D) || n.$anchorCell.pos == n.$headCell.pos) return !1;
|
|
651
|
+
let r = A(e), { map: i } = r;
|
|
652
|
+
if (Oe(i, r)) return !1;
|
|
653
|
+
if (t) {
|
|
654
|
+
let n = e.tr, a = {}, o = h.empty, s, c;
|
|
655
|
+
for (let e = r.top; e < r.bottom; e++) for (let t = r.left; t < r.right; t++) {
|
|
656
|
+
let l = i.map[e * i.width + t], u = r.table.nodeAt(l);
|
|
657
|
+
if (!(a[l] || !u)) if (a[l] = !0, s == null) s = l, c = u;
|
|
658
|
+
else {
|
|
659
|
+
N(u) || (o = o.append(u.content));
|
|
660
|
+
let e = n.mapping.map(l + r.tableStart);
|
|
661
|
+
n.delete(e, e + u.nodeSize);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
if (s == null || c == null) return !0;
|
|
665
|
+
if (n.setNodeMarkup(s + r.tableStart, null, {
|
|
666
|
+
...ue(c.attrs, c.attrs.colspan, r.right - r.left - c.attrs.colspan),
|
|
667
|
+
rowspan: r.bottom - r.top
|
|
668
|
+
}), o.size > 0) {
|
|
669
|
+
let e = s + 1 + c.content.size, t = N(c) ? s + 1 : e;
|
|
670
|
+
n.replaceWith(t + r.tableStart, e + r.tableStart, o);
|
|
671
|
+
}
|
|
672
|
+
n.setSelection(new D(n.doc.resolve(s + r.tableStart))), t(n);
|
|
673
|
+
}
|
|
674
|
+
return !0;
|
|
675
|
+
}
|
|
676
|
+
function F(e, t) {
|
|
677
|
+
let n = y(e.schema);
|
|
678
|
+
return ke(({ node: e }) => n[e.type.spec.tableRole])(e, t);
|
|
679
|
+
}
|
|
680
|
+
function ke(e) {
|
|
681
|
+
return (t, n) => {
|
|
682
|
+
let r = t.selection, i, a;
|
|
683
|
+
if (r instanceof D) {
|
|
684
|
+
if (r.$anchorCell.pos != r.$headCell.pos) return !1;
|
|
685
|
+
i = r.$anchorCell.nodeAfter, a = r.$anchorCell.pos;
|
|
686
|
+
} else {
|
|
687
|
+
if (i = oe(r.$from), !i) return !1;
|
|
688
|
+
a = x(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 = A(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 D && u.setSelection(new D(u.doc.resolve(r.$anchorCell.pos), d ? u.doc.resolve(d) : void 0)), n(u);
|
|
720
|
+
}
|
|
721
|
+
return !0;
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
function Ae(e, t) {
|
|
725
|
+
return function(n, r) {
|
|
726
|
+
if (!S(n)) return !1;
|
|
727
|
+
let i = C(n);
|
|
728
|
+
if (i.nodeAfter.attrs[e] === t) return !1;
|
|
729
|
+
if (r) {
|
|
730
|
+
let a = n.tr;
|
|
731
|
+
n.selection instanceof D ? 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 je(e) {
|
|
745
|
+
return function(t, n) {
|
|
746
|
+
if (!S(t)) return !1;
|
|
747
|
+
if (n) {
|
|
748
|
+
let r = y(t.schema), i = A(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 I(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 L(e, t) {
|
|
780
|
+
return t ||= { useDeprecatedLogic: !1 }, t.useDeprecatedLogic ? je(e) : function(t, n) {
|
|
781
|
+
if (!S(t)) return !1;
|
|
782
|
+
if (n) {
|
|
783
|
+
let r = y(t.schema), i = A(t), a = t.tr, o = I("row", i, r), s = I("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
|
+
L("row", { useDeprecatedLogic: !0 }), L("column", { useDeprecatedLogic: !0 });
|
|
803
|
+
var Me = L("cell", { useDeprecatedLogic: !0 });
|
|
804
|
+
function Ne(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 R(e) {
|
|
825
|
+
return function(t, n) {
|
|
826
|
+
if (!S(t)) return !1;
|
|
827
|
+
let r = Ne(C(t), e);
|
|
828
|
+
if (r == null) return !1;
|
|
829
|
+
if (n) {
|
|
830
|
+
let e = t.doc.resolve(r);
|
|
831
|
+
n(t.tr.setSelection(u.between(e, ce(e))).scrollIntoView());
|
|
832
|
+
}
|
|
833
|
+
return !0;
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
function Pe(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 z(e, t) {
|
|
842
|
+
let n = e.selection;
|
|
843
|
+
if (!(n instanceof D)) return !1;
|
|
844
|
+
if (t) {
|
|
845
|
+
let r = e.tr, i = y(e.schema).cell.createAndFill().content;
|
|
846
|
+
n.forEachCell((e, t) => {
|
|
847
|
+
e.content.eq(i) || r.replace(r.mapping.map(t + 1), r.mapping.map(t + e.nodeSize - 1), new f(i, 0, 0));
|
|
848
|
+
}), r.docChanged && t(r);
|
|
849
|
+
}
|
|
850
|
+
return !0;
|
|
851
|
+
}
|
|
852
|
+
function Fe(e) {
|
|
853
|
+
if (e.size === 0) return null;
|
|
854
|
+
let { content: t, openStart: n, openEnd: r } = e;
|
|
855
|
+
for (; t.childCount == 1 && (n > 0 && r > 0 || t.child(0).type.spec.tableRole == "table");) n--, r--, t = t.child(0).content;
|
|
856
|
+
let i = t.child(0), a = i.type.spec.tableRole, o = i.type.schema, s = [];
|
|
857
|
+
if (a == "row") for (let e = 0; e < t.childCount; e++) {
|
|
858
|
+
let i = t.child(e).content, a = e ? 0 : Math.max(0, n - 1), c = e < t.childCount - 1 ? 0 : Math.max(0, r - 1);
|
|
859
|
+
(a || c) && (i = B(y(o).row, new f(i, a, c)).content), s.push(i);
|
|
860
|
+
}
|
|
861
|
+
else if (a == "cell" || a == "header_cell") s.push(n || r ? B(y(o).row, new f(t, n, r)).content : t);
|
|
862
|
+
else return null;
|
|
863
|
+
return Ie(o, s);
|
|
864
|
+
}
|
|
865
|
+
function Ie(e, t) {
|
|
866
|
+
let n = [];
|
|
867
|
+
for (let e = 0; e < t.length; e++) {
|
|
868
|
+
let r = t[e];
|
|
869
|
+
for (let t = r.childCount - 1; t >= 0; t--) {
|
|
870
|
+
let { rowspan: i, colspan: a } = r.child(t).attrs;
|
|
871
|
+
for (let t = e; t < e + i; t++) n[t] = (n[t] || 0) + a;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
let r = 0;
|
|
875
|
+
for (let e = 0; e < n.length; e++) r = Math.max(r, n[e]);
|
|
876
|
+
for (let i = 0; i < n.length; i++) if (i >= t.length && t.push(h.empty), n[i] < r) {
|
|
877
|
+
let a = y(e).cell.createAndFill(), o = [];
|
|
878
|
+
for (let e = n[i]; e < r; e++) o.push(a);
|
|
879
|
+
t[i] = t[i].append(h.from(o));
|
|
880
|
+
}
|
|
881
|
+
return {
|
|
882
|
+
height: t.length,
|
|
883
|
+
width: r,
|
|
884
|
+
rows: t
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
function B(e, t) {
|
|
888
|
+
let n = e.createAndFill();
|
|
889
|
+
return new p(n).replace(0, n.content.size, t).doc;
|
|
890
|
+
}
|
|
891
|
+
function Le({ width: e, height: t, rows: n }, r, i) {
|
|
892
|
+
if (e != r) {
|
|
893
|
+
let t = [], i = [];
|
|
894
|
+
for (let e = 0; e < n.length; e++) {
|
|
895
|
+
let a = n[e], o = [];
|
|
896
|
+
for (let n = t[e] || 0, i = 0; n < r; i++) {
|
|
897
|
+
let s = a.child(i % a.childCount);
|
|
898
|
+
n + s.attrs.colspan > r && (s = s.type.createChecked(E(s.attrs, s.attrs.colspan, n + s.attrs.colspan - r), s.content)), o.push(s), n += s.attrs.colspan;
|
|
899
|
+
for (let n = 1; n < s.attrs.rowspan; n++) t[e + n] = (t[e + n] || 0) + s.attrs.colspan;
|
|
900
|
+
}
|
|
901
|
+
i.push(h.from(o));
|
|
902
|
+
}
|
|
903
|
+
n = i, e = r;
|
|
904
|
+
}
|
|
905
|
+
if (t != i) {
|
|
906
|
+
let e = [];
|
|
907
|
+
for (let r = 0, a = 0; r < i; r++, a++) {
|
|
908
|
+
let o = [], s = n[a % t];
|
|
909
|
+
for (let e = 0; e < s.childCount; e++) {
|
|
910
|
+
let t = s.child(e);
|
|
911
|
+
r + t.attrs.rowspan > i && (t = t.type.create({
|
|
912
|
+
...t.attrs,
|
|
913
|
+
rowspan: Math.max(1, i - t.attrs.rowspan)
|
|
914
|
+
}, t.content)), o.push(t);
|
|
915
|
+
}
|
|
916
|
+
e.push(h.from(o));
|
|
917
|
+
}
|
|
918
|
+
n = e, t = i;
|
|
919
|
+
}
|
|
920
|
+
return {
|
|
921
|
+
width: e,
|
|
922
|
+
height: t,
|
|
923
|
+
rows: n
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
function Re(e, t, n, r, i, a, o) {
|
|
927
|
+
let s = e.doc.type.schema, c = y(s), l, u;
|
|
928
|
+
if (i > t.width) for (let a = 0, s = 0; a < t.height; a++) {
|
|
929
|
+
let d = n.child(a);
|
|
930
|
+
s += d.nodeSize;
|
|
931
|
+
let f = [], p;
|
|
932
|
+
p = d.lastChild == null || d.lastChild.type == c.cell ? l ||= c.cell.createAndFill() : u ||= c.header_cell.createAndFill();
|
|
933
|
+
for (let e = t.width; e < i; e++) f.push(p);
|
|
934
|
+
e.insert(e.mapping.slice(o).map(s - 1 + r), f);
|
|
935
|
+
}
|
|
936
|
+
if (a > t.height) {
|
|
937
|
+
let s = [];
|
|
938
|
+
for (let e = 0, r = (t.height - 1) * t.width; e < Math.max(t.width, i); e++) {
|
|
939
|
+
let i = e >= t.width ? !1 : n.nodeAt(t.map[r + e]).type == c.header_cell;
|
|
940
|
+
s.push(i ? u ||= c.header_cell.createAndFill() : l ||= c.cell.createAndFill());
|
|
941
|
+
}
|
|
942
|
+
let d = c.row.create(null, h.from(s)), f = [];
|
|
943
|
+
for (let e = t.height; e < a; e++) f.push(d);
|
|
944
|
+
e.insert(e.mapping.slice(o).map(r + n.nodeSize - 2), f);
|
|
945
|
+
}
|
|
946
|
+
return !!(l || u);
|
|
947
|
+
}
|
|
948
|
+
function V(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 ze(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, E(i.attrs, o - u, i.attrs.colspan - (o - u))), e.insert(d + i.nodeSize, i.type.createAndFill(E(i.attrs, 0, o - u))), l += i.attrs.rowspan - 1;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
return c;
|
|
979
|
+
}
|
|
980
|
+
function Be(e, t, n, r, i) {
|
|
981
|
+
let a = n ? e.doc.nodeAt(n - 1) : e.doc;
|
|
982
|
+
if (!a) throw Error("No table found");
|
|
983
|
+
let o = v.get(a), { top: s, left: c } = r, l = c + i.width, u = s + i.height, d = e.tr, p = 0;
|
|
984
|
+
function m() {
|
|
985
|
+
if (a = n ? d.doc.nodeAt(n - 1) : d.doc, !a) throw Error("No table found");
|
|
986
|
+
o = v.get(a), p = d.mapping.maps.length;
|
|
987
|
+
}
|
|
988
|
+
Re(d, o, a, n, l, u, p) && m(), V(d, o, a, n, c, l, s, p) && m(), V(d, o, a, n, c, l, u, p) && m(), ze(d, o, a, n, s, u, c, p) && m(), ze(d, o, a, n, s, u, l, p) && m();
|
|
989
|
+
for (let e = s; e < u; e++) {
|
|
990
|
+
let t = o.positionAt(e, c, a), r = o.positionAt(e, l, a);
|
|
991
|
+
d.replace(d.mapping.slice(p).map(t + n), d.mapping.slice(p).map(r + n), new f(i.rows[e - s], 0, 0));
|
|
992
|
+
}
|
|
993
|
+
m(), d.setSelection(new D(d.doc.resolve(n + o.positionAt(s, c, a)), d.doc.resolve(n + o.positionAt(u - 1, l - 1, a)))), t(d);
|
|
994
|
+
}
|
|
995
|
+
var Ve = e({
|
|
996
|
+
ArrowLeft: U("horiz", -1),
|
|
997
|
+
ArrowRight: U("horiz", 1),
|
|
998
|
+
ArrowUp: U("vert", -1),
|
|
999
|
+
ArrowDown: U("vert", 1),
|
|
1000
|
+
"Shift-ArrowLeft": W("horiz", -1),
|
|
1001
|
+
"Shift-ArrowRight": W("horiz", 1),
|
|
1002
|
+
"Shift-ArrowUp": W("vert", -1),
|
|
1003
|
+
"Shift-ArrowDown": W("vert", 1),
|
|
1004
|
+
Backspace: z,
|
|
1005
|
+
"Mod-Backspace": z,
|
|
1006
|
+
Delete: z,
|
|
1007
|
+
"Mod-Delete": z
|
|
1008
|
+
});
|
|
1009
|
+
function H(e, t, n) {
|
|
1010
|
+
return n.eq(e.selection) ? !1 : (t && t(e.tr.setSelection(n).scrollIntoView()), !0);
|
|
1011
|
+
}
|
|
1012
|
+
function U(e, t) {
|
|
1013
|
+
return (n, r, i) => {
|
|
1014
|
+
if (!i) return !1;
|
|
1015
|
+
let a = n.selection;
|
|
1016
|
+
if (a instanceof D) return H(n, r, m.near(a.$headCell, t));
|
|
1017
|
+
if (e != "horiz" && !a.empty) return !1;
|
|
1018
|
+
let o = Ge(i, e, t);
|
|
1019
|
+
if (o == null) return !1;
|
|
1020
|
+
if (e == "horiz") return H(n, r, m.near(n.doc.resolve(a.head + t), t));
|
|
1021
|
+
{
|
|
1022
|
+
let i = n.doc.resolve(o), a = le(i, e, t), s;
|
|
1023
|
+
return s = a ? m.near(a, 1) : t < 0 ? m.near(n.doc.resolve(i.before(-1)), -1) : m.near(n.doc.resolve(i.after(-1)), 1), H(n, r, s);
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
function W(e, t) {
|
|
1028
|
+
return (n, r, i) => {
|
|
1029
|
+
if (!i) return !1;
|
|
1030
|
+
let a = n.selection, o;
|
|
1031
|
+
if (a instanceof D) o = a;
|
|
1032
|
+
else {
|
|
1033
|
+
let r = Ge(i, e, t);
|
|
1034
|
+
if (r == null) return !1;
|
|
1035
|
+
o = new D(n.doc.resolve(r));
|
|
1036
|
+
}
|
|
1037
|
+
let s = le(o.$headCell, e, t);
|
|
1038
|
+
return s ? H(n, r, new D(o.$anchorCell, s)) : !1;
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
function He(e, t) {
|
|
1042
|
+
let n = e.state.doc, r = x(n.resolve(t));
|
|
1043
|
+
return r ? (e.dispatch(e.state.tr.setSelection(new D(r))), !0) : !1;
|
|
1044
|
+
}
|
|
1045
|
+
function Ue(e, t, n) {
|
|
1046
|
+
if (!S(e.state)) return !1;
|
|
1047
|
+
let r = Fe(n), i = e.state.selection;
|
|
1048
|
+
if (i instanceof D) {
|
|
1049
|
+
r ||= {
|
|
1050
|
+
width: 1,
|
|
1051
|
+
height: 1,
|
|
1052
|
+
rows: [h.from(B(y(e.state.schema).cell, n))]
|
|
1053
|
+
};
|
|
1054
|
+
let t = i.$anchorCell.node(-1), a = i.$anchorCell.start(-1), o = v.get(t).rectBetween(i.$anchorCell.pos - a, i.$headCell.pos - a);
|
|
1055
|
+
return r = Le(r, o.right - o.left, o.bottom - o.top), Be(e.state, e.dispatch, a, o, r), !0;
|
|
1056
|
+
} else if (r) {
|
|
1057
|
+
let t = C(e.state), n = t.start(-1);
|
|
1058
|
+
return Be(e.state, e.dispatch, n, v.get(t.node(-1)).findCell(t.pos - n), r), !0;
|
|
1059
|
+
} else return !1;
|
|
1060
|
+
}
|
|
1061
|
+
function We(e, t) {
|
|
1062
|
+
if (t.button != 0 || t.ctrlKey || t.metaKey) return;
|
|
1063
|
+
let n = Ke(e, t.target), r;
|
|
1064
|
+
if (t.shiftKey && e.state.selection instanceof D) i(e.state.selection.$anchorCell, t), t.preventDefault();
|
|
1065
|
+
else if (t.shiftKey && n && (r = x(e.state.selection.$anchor)) != null && G(e, t)?.pos != r.pos) i(r, t), t.preventDefault();
|
|
1066
|
+
else if (!n) return;
|
|
1067
|
+
function i(t, n) {
|
|
1068
|
+
let r = G(e, n), i = b.getState(e.state) == null;
|
|
1069
|
+
if (!r || !T(t, r)) if (i) r = t;
|
|
1070
|
+
else return;
|
|
1071
|
+
let a = new D(t, r);
|
|
1072
|
+
if (i || !e.state.selection.eq(a)) {
|
|
1073
|
+
let n = e.state.tr.setSelection(a);
|
|
1074
|
+
i && n.setMeta(b, t.pos), e.dispatch(n);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
function a() {
|
|
1078
|
+
e.root.removeEventListener("mouseup", a), e.root.removeEventListener("dragstart", a), e.root.removeEventListener("mousemove", o), b.getState(e.state) != null && e.dispatch(e.state.tr.setMeta(b, -1));
|
|
1079
|
+
}
|
|
1080
|
+
function o(r) {
|
|
1081
|
+
let o = r, s = b.getState(e.state), c;
|
|
1082
|
+
if (s != null) c = e.state.doc.resolve(s);
|
|
1083
|
+
else if (Ke(e, o.target) != n && (c = G(e, t), !c)) return a();
|
|
1084
|
+
c && i(c, o);
|
|
1085
|
+
}
|
|
1086
|
+
e.root.addEventListener("mouseup", a), e.root.addEventListener("dragstart", a), e.root.addEventListener("mousemove", o);
|
|
1087
|
+
}
|
|
1088
|
+
function Ge(e, t, n) {
|
|
1089
|
+
if (!(e.state.selection instanceof u)) return null;
|
|
1090
|
+
let { $head: r } = e.state.selection;
|
|
1091
|
+
for (let i = r.depth - 1; i >= 0; i--) {
|
|
1092
|
+
let a = r.node(i);
|
|
1093
|
+
if ((n < 0 ? r.index(i) : r.indexAfter(i)) != (n < 0 ? 0 : a.childCount)) return null;
|
|
1094
|
+
if (a.type.spec.tableRole == "cell" || a.type.spec.tableRole == "header_cell") {
|
|
1095
|
+
let a = r.before(i), o = t == "vert" ? n > 0 ? "down" : "up" : n > 0 ? "right" : "left";
|
|
1096
|
+
return e.endOfTextblock(o) ? a : null;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
return null;
|
|
1100
|
+
}
|
|
1101
|
+
function Ke(e, t) {
|
|
1102
|
+
for (; t && t != e.dom; t = t.parentNode) if (t.nodeName == "TD" || t.nodeName == "TH") return t;
|
|
1103
|
+
return null;
|
|
1104
|
+
}
|
|
1105
|
+
function G(e, t) {
|
|
1106
|
+
let n = e.posAtCoords({
|
|
1107
|
+
left: t.clientX,
|
|
1108
|
+
top: t.clientY
|
|
1109
|
+
});
|
|
1110
|
+
if (!n) return null;
|
|
1111
|
+
let { inside: r, pos: i } = n;
|
|
1112
|
+
return r >= 0 && x(e.state.doc.resolve(r)) || x(e.state.doc.resolve(i));
|
|
1113
|
+
}
|
|
1114
|
+
var qe = class {
|
|
1115
|
+
constructor(e, t) {
|
|
1116
|
+
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")), K(e, this.colgroup, this.table, t), this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
1117
|
+
}
|
|
1118
|
+
update(e) {
|
|
1119
|
+
return e.type == this.node.type ? (this.node = e, K(e, this.colgroup, this.table, this.defaultCellMinWidth), !0) : !1;
|
|
1120
|
+
}
|
|
1121
|
+
ignoreMutation(e) {
|
|
1122
|
+
return e.type == "attributes" && (e.target == this.table || this.colgroup.contains(e.target));
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
function K(e, t, n, r, i, a) {
|
|
1126
|
+
let o = 0, s = !0, c = t.firstChild, l = e.firstChild;
|
|
1127
|
+
if (l) {
|
|
1128
|
+
for (let e = 0, n = 0; e < l.childCount; e++) {
|
|
1129
|
+
let { colspan: u, colwidth: d } = l.child(e).attrs;
|
|
1130
|
+
for (let e = 0; e < u; e++, n++) {
|
|
1131
|
+
let l = i == n ? a : d && d[e], u = l ? l + "px" : "";
|
|
1132
|
+
if (o += l || r, l || (s = !1), c) c.style.width != u && (c.style.width = u), c = c.nextSibling;
|
|
1133
|
+
else {
|
|
1134
|
+
let e = document.createElement("col");
|
|
1135
|
+
e.style.width = u, t.appendChild(e);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
for (; c;) {
|
|
1140
|
+
var u;
|
|
1141
|
+
let e = c.nextSibling;
|
|
1142
|
+
(u = c.parentNode) == null || u.removeChild(c), c = e;
|
|
1143
|
+
}
|
|
1144
|
+
s ? (n.style.width = o + "px", n.style.minWidth = "") : (n.style.width = "", n.style.minWidth = o + "px");
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
var q = new l("tableColumnResizing");
|
|
1148
|
+
function Je({ handleWidth: e = 5, cellMinWidth: t = 25, defaultCellMinWidth: n = 100, View: r = qe, lastColumnResizable: i = !0 } = {}) {
|
|
1149
|
+
let a = new d({
|
|
1150
|
+
key: q,
|
|
1151
|
+
state: {
|
|
1152
|
+
init(e, t) {
|
|
1153
|
+
var i;
|
|
1154
|
+
let o = (i = a.spec) == null || (i = i.props) == null ? void 0 : i.nodeViews, s = y(t.schema).table.name;
|
|
1155
|
+
return r && o && (o[s] = (e, t) => new r(e, n, t)), new Ye(-1, !1);
|
|
1156
|
+
},
|
|
1157
|
+
apply(e, t) {
|
|
1158
|
+
return t.apply(e);
|
|
1159
|
+
}
|
|
1160
|
+
},
|
|
1161
|
+
props: {
|
|
1162
|
+
attributes: (e) => {
|
|
1163
|
+
let t = q.getState(e);
|
|
1164
|
+
return t && t.activeHandle > -1 ? { class: "resize-cursor" } : {};
|
|
1165
|
+
},
|
|
1166
|
+
handleDOMEvents: {
|
|
1167
|
+
mousemove: (t, n) => {
|
|
1168
|
+
Xe(t, n, e, i);
|
|
1169
|
+
},
|
|
1170
|
+
mouseleave: (e) => {
|
|
1171
|
+
Ze(e);
|
|
1172
|
+
},
|
|
1173
|
+
mousedown: (e, r) => {
|
|
1174
|
+
Qe(e, r, t, n);
|
|
1175
|
+
}
|
|
1176
|
+
},
|
|
1177
|
+
decorations: (e) => {
|
|
1178
|
+
let t = q.getState(e);
|
|
1179
|
+
if (t && t.activeHandle > -1) return st(e, t.activeHandle);
|
|
1180
|
+
},
|
|
1181
|
+
nodeViews: {}
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
return a;
|
|
1185
|
+
}
|
|
1186
|
+
var Ye = class e {
|
|
1187
|
+
constructor(e, t) {
|
|
1188
|
+
this.activeHandle = e, this.dragging = t;
|
|
1189
|
+
}
|
|
1190
|
+
apply(t) {
|
|
1191
|
+
let n = this, r = t.getMeta(q);
|
|
1192
|
+
if (r && r.setHandle != null) return new e(r.setHandle, !1);
|
|
1193
|
+
if (r && r.setDragging !== void 0) return new e(n.activeHandle, r.setDragging);
|
|
1194
|
+
if (n.activeHandle > -1 && t.docChanged) {
|
|
1195
|
+
let r = t.mapping.map(n.activeHandle, -1);
|
|
1196
|
+
return w(t.doc.resolve(r)) || (r = -1), new e(r, n.dragging);
|
|
1197
|
+
}
|
|
1198
|
+
return n;
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
function Xe(e, t, n, r) {
|
|
1202
|
+
if (!e.editable) return;
|
|
1203
|
+
let i = q.getState(e.state);
|
|
1204
|
+
if (i && !i.dragging) {
|
|
1205
|
+
let a = et(t.target), o = -1;
|
|
1206
|
+
if (a) {
|
|
1207
|
+
let { left: r, right: i } = a.getBoundingClientRect();
|
|
1208
|
+
t.clientX - r <= n ? o = tt(e, t, "left", n) : i - t.clientX <= n && (o = tt(e, t, "right", n));
|
|
1209
|
+
}
|
|
1210
|
+
if (o != i.activeHandle) {
|
|
1211
|
+
if (!r && o !== -1) {
|
|
1212
|
+
let t = e.state.doc.resolve(o), n = t.node(-1), r = v.get(n), i = t.start(-1);
|
|
1213
|
+
if (r.colCount(t.pos - i) + t.nodeAfter.attrs.colspan - 1 == r.width - 1) return;
|
|
1214
|
+
}
|
|
1215
|
+
rt(e, o);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
function Ze(e) {
|
|
1220
|
+
if (!e.editable) return;
|
|
1221
|
+
let t = q.getState(e.state);
|
|
1222
|
+
t && t.activeHandle > -1 && !t.dragging && rt(e, -1);
|
|
1223
|
+
}
|
|
1224
|
+
function Qe(e, t, n, r) {
|
|
1225
|
+
if (!e.editable) return !1;
|
|
1226
|
+
let i = e.dom.ownerDocument.defaultView ?? window, a = q.getState(e.state);
|
|
1227
|
+
if (!a || a.activeHandle == -1 || a.dragging) return !1;
|
|
1228
|
+
let o = e.state.doc.nodeAt(a.activeHandle), s = $e(e, a.activeHandle, o.attrs);
|
|
1229
|
+
e.dispatch(e.state.tr.setMeta(q, { setDragging: {
|
|
1230
|
+
startX: t.clientX,
|
|
1231
|
+
startWidth: s
|
|
1232
|
+
} }));
|
|
1233
|
+
function c(t) {
|
|
1234
|
+
i.removeEventListener("mouseup", c), i.removeEventListener("mousemove", l);
|
|
1235
|
+
let r = q.getState(e.state);
|
|
1236
|
+
r?.dragging && (it(e, r.activeHandle, nt(r.dragging, t, n)), e.dispatch(e.state.tr.setMeta(q, { setDragging: null })));
|
|
1237
|
+
}
|
|
1238
|
+
function l(t) {
|
|
1239
|
+
if (!t.which) return c(t);
|
|
1240
|
+
let i = q.getState(e.state);
|
|
1241
|
+
if (i && i.dragging) {
|
|
1242
|
+
let a = nt(i.dragging, t, n);
|
|
1243
|
+
at(e, i.activeHandle, a, r);
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
return at(e, a.activeHandle, s, r), i.addEventListener("mouseup", c), i.addEventListener("mousemove", l), t.preventDefault(), !0;
|
|
1247
|
+
}
|
|
1248
|
+
function $e(e, t, { colspan: n, colwidth: r }) {
|
|
1249
|
+
let i = r && r[r.length - 1];
|
|
1250
|
+
if (i) return i;
|
|
1251
|
+
let a = e.domAtPos(t), o = a.node.childNodes[a.offset].offsetWidth, s = n;
|
|
1252
|
+
if (r) for (let e = 0; e < n; e++) r[e] && (o -= r[e], s--);
|
|
1253
|
+
return o / s;
|
|
1254
|
+
}
|
|
1255
|
+
function et(e) {
|
|
1256
|
+
for (; e && e.nodeName != "TD" && e.nodeName != "TH";) e = e.classList && e.classList.contains("ProseMirror") ? null : e.parentNode;
|
|
1257
|
+
return e;
|
|
1258
|
+
}
|
|
1259
|
+
function tt(e, t, n, r) {
|
|
1260
|
+
let i = n == "right" ? -r : r, a = e.posAtCoords({
|
|
1261
|
+
left: t.clientX + i,
|
|
1262
|
+
top: t.clientY
|
|
1263
|
+
});
|
|
1264
|
+
if (!a) return -1;
|
|
1265
|
+
let { pos: o } = a, s = x(e.state.doc.resolve(o));
|
|
1266
|
+
if (!s) return -1;
|
|
1267
|
+
if (n == "right") return s.pos;
|
|
1268
|
+
let c = v.get(s.node(-1)), l = s.start(-1), u = c.map.indexOf(s.pos - l);
|
|
1269
|
+
return u % c.width == 0 ? -1 : l + c.map[u - 1];
|
|
1270
|
+
}
|
|
1271
|
+
function nt(e, t, n) {
|
|
1272
|
+
let r = t.clientX - e.startX;
|
|
1273
|
+
return Math.max(n, e.startWidth + r);
|
|
1274
|
+
}
|
|
1275
|
+
function rt(e, t) {
|
|
1276
|
+
e.dispatch(e.state.tr.setMeta(q, { setHandle: t }));
|
|
1277
|
+
}
|
|
1278
|
+
function it(e, t, n) {
|
|
1279
|
+
let r = e.state.doc.resolve(t), i = r.node(-1), a = v.get(i), o = r.start(-1), s = a.colCount(r.pos - o) + r.nodeAfter.attrs.colspan - 1, c = e.state.tr;
|
|
1280
|
+
for (let e = 0; e < a.height; e++) {
|
|
1281
|
+
let t = e * a.width + s;
|
|
1282
|
+
if (e && a.map[t] == a.map[t - a.width]) continue;
|
|
1283
|
+
let r = a.map[t], l = i.nodeAt(r).attrs, u = l.colspan == 1 ? 0 : s - a.colCount(r);
|
|
1284
|
+
if (l.colwidth && l.colwidth[u] == n) continue;
|
|
1285
|
+
let d = l.colwidth ? l.colwidth.slice() : ot(l.colspan);
|
|
1286
|
+
d[u] = n, c.setNodeMarkup(o + r, null, {
|
|
1287
|
+
...l,
|
|
1288
|
+
colwidth: d
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
c.docChanged && e.dispatch(c);
|
|
1292
|
+
}
|
|
1293
|
+
function at(e, t, n, r) {
|
|
1294
|
+
let i = e.state.doc.resolve(t), a = i.node(-1), o = i.start(-1), s = v.get(a).colCount(i.pos - o) + i.nodeAfter.attrs.colspan - 1, c = e.domAtPos(i.start(-1)).node;
|
|
1295
|
+
for (; c && c.nodeName != "TABLE";) c = c.parentNode;
|
|
1296
|
+
c && K(a, c.firstChild, c, r, s, n);
|
|
1297
|
+
}
|
|
1298
|
+
function ot(e) {
|
|
1299
|
+
return Array(e).fill(0);
|
|
1300
|
+
}
|
|
1301
|
+
function st(e, n) {
|
|
1302
|
+
let i = [], a = e.doc.resolve(n), o = a.node(-1);
|
|
1303
|
+
if (!o) return t.empty;
|
|
1304
|
+
let s = v.get(o), c = a.start(-1), l = s.colCount(a.pos - c) + a.nodeAfter.attrs.colspan - 1;
|
|
1305
|
+
for (let t = 0; t < s.height; t++) {
|
|
1306
|
+
let n = l + t * s.width;
|
|
1307
|
+
if ((l == s.width - 1 || s.map[n] != s.map[n + 1]) && (t == 0 || s.map[n] != s.map[n - s.width])) {
|
|
1308
|
+
let t = s.map[n], a = c + t + o.nodeAt(t).nodeSize - 1, l = document.createElement("div");
|
|
1309
|
+
l.className = "column-resize-handle", q.getState(e)?.dragging && i.push(r.node(c + t, c + t + o.nodeAt(t).nodeSize, { class: "column-resize-dragging" })), i.push(r.widget(a, l));
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
return t.create(e.doc, i);
|
|
1313
|
+
}
|
|
1314
|
+
function ct({ allowTableNodeSelection: e = !1 } = {}) {
|
|
1315
|
+
return new d({
|
|
1316
|
+
key: b,
|
|
1317
|
+
state: {
|
|
1318
|
+
init() {
|
|
1319
|
+
return null;
|
|
1320
|
+
},
|
|
1321
|
+
apply(e, t) {
|
|
1322
|
+
let n = e.getMeta(b);
|
|
1323
|
+
if (n != null) return n == -1 ? null : n;
|
|
1324
|
+
if (t == null || !e.docChanged) return t;
|
|
1325
|
+
let { deleted: r, pos: i } = e.mapping.mapResult(t);
|
|
1326
|
+
return r ? null : i;
|
|
1327
|
+
}
|
|
1328
|
+
},
|
|
1329
|
+
props: {
|
|
1330
|
+
decorations: pe,
|
|
1331
|
+
handleDOMEvents: { mousedown: We },
|
|
1332
|
+
createSelectionBetween(e) {
|
|
1333
|
+
return b.getState(e.state) == null ? null : e.state.selection;
|
|
1334
|
+
},
|
|
1335
|
+
handleTripleClick: He,
|
|
1336
|
+
handleKeyDown: Ve,
|
|
1337
|
+
handlePaste: Ue
|
|
1338
|
+
},
|
|
1339
|
+
appendTransaction(t, n, r) {
|
|
1340
|
+
return ge(r, k(r, n), e);
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
//#endregion
|
|
1345
|
+
//#region ../../../node_modules/.bun/@tiptap+extension-table@3.31.3+9ea2bbe04937c6bd/node_modules/@tiptap/extension-table/dist/index.js
|
|
1346
|
+
function J(e) {
|
|
1347
|
+
return e === "left" || e === "right" || e === "center" ? e : null;
|
|
1348
|
+
}
|
|
1349
|
+
function lt(e) {
|
|
1350
|
+
let t = (e.style.textAlign || "").trim().toLowerCase(), n = (e.getAttribute("align") || "").trim().toLowerCase();
|
|
1351
|
+
return J(t || n);
|
|
1352
|
+
}
|
|
1353
|
+
function ut(e) {
|
|
1354
|
+
return J(e?.align);
|
|
1355
|
+
}
|
|
1356
|
+
function dt() {
|
|
1357
|
+
return {
|
|
1358
|
+
default: null,
|
|
1359
|
+
parseHTML: (e) => lt(e),
|
|
1360
|
+
renderHTML: (e) => e.align ? { style: `text-align: ${e.align}` } : {}
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
function ft(e) {
|
|
1364
|
+
let t = e.parentElement, n = e.closest("table");
|
|
1365
|
+
if (!t || !n) return null;
|
|
1366
|
+
let r = Array.from(t.children).indexOf(e), i = n.querySelectorAll("colgroup > col")[r]?.getAttribute("width");
|
|
1367
|
+
return i ? [parseInt(i, 10)] : null;
|
|
1368
|
+
}
|
|
1369
|
+
function pt(e) {
|
|
1370
|
+
let t = e.getAttribute("colwidth");
|
|
1371
|
+
return t ? t.split(",").map((e) => parseInt(e, 10)) : ft(e);
|
|
1372
|
+
}
|
|
1373
|
+
var mt = /[ \t\r\n\f]+/g;
|
|
1374
|
+
function ht(e) {
|
|
1375
|
+
return e.children.length > 0 ? !1 : (e.textContent ?? "").replace(mt, "") === "";
|
|
1376
|
+
}
|
|
1377
|
+
function Y(e) {
|
|
1378
|
+
let t = e.createAndFill();
|
|
1379
|
+
if (!t) throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);
|
|
1380
|
+
return t.content;
|
|
1381
|
+
}
|
|
1382
|
+
var gt = o.create({
|
|
1383
|
+
name: "tableCell",
|
|
1384
|
+
addOptions() {
|
|
1385
|
+
return { HTMLAttributes: {} };
|
|
1386
|
+
},
|
|
1387
|
+
content: "block+",
|
|
1388
|
+
addAttributes() {
|
|
1389
|
+
return {
|
|
1390
|
+
colspan: { default: 1 },
|
|
1391
|
+
rowspan: { default: 1 },
|
|
1392
|
+
colwidth: {
|
|
1393
|
+
default: null,
|
|
1394
|
+
parseHTML: pt
|
|
1395
|
+
},
|
|
1396
|
+
align: dt()
|
|
1397
|
+
};
|
|
1398
|
+
},
|
|
1399
|
+
tableRole: "cell",
|
|
1400
|
+
isolating: !0,
|
|
1401
|
+
parseHTML() {
|
|
1402
|
+
return [{
|
|
1403
|
+
tag: "td",
|
|
1404
|
+
getAttrs: (e) => ht(e) ? {} : !1,
|
|
1405
|
+
getContent: (e, t) => Y(t.nodes[this.name])
|
|
1406
|
+
}, { tag: "td" }];
|
|
1407
|
+
},
|
|
1408
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
1409
|
+
return [
|
|
1410
|
+
"td",
|
|
1411
|
+
i(this.options.HTMLAttributes, e),
|
|
1412
|
+
0
|
|
1413
|
+
];
|
|
1414
|
+
}
|
|
1415
|
+
}), _t = o.create({
|
|
1416
|
+
name: "tableHeader",
|
|
1417
|
+
addOptions() {
|
|
1418
|
+
return { HTMLAttributes: {} };
|
|
1419
|
+
},
|
|
1420
|
+
content: "block+",
|
|
1421
|
+
addAttributes() {
|
|
1422
|
+
return {
|
|
1423
|
+
colspan: { default: 1 },
|
|
1424
|
+
rowspan: { default: 1 },
|
|
1425
|
+
colwidth: {
|
|
1426
|
+
default: null,
|
|
1427
|
+
parseHTML: pt
|
|
1428
|
+
},
|
|
1429
|
+
align: dt()
|
|
1430
|
+
};
|
|
1431
|
+
},
|
|
1432
|
+
tableRole: "header_cell",
|
|
1433
|
+
isolating: !0,
|
|
1434
|
+
parseHTML() {
|
|
1435
|
+
return [{
|
|
1436
|
+
tag: "th",
|
|
1437
|
+
getAttrs: (e) => ht(e) ? {} : !1,
|
|
1438
|
+
getContent: (e, t) => Y(t.nodes[this.name])
|
|
1439
|
+
}, { tag: "th" }];
|
|
1440
|
+
},
|
|
1441
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
1442
|
+
return [
|
|
1443
|
+
"th",
|
|
1444
|
+
i(this.options.HTMLAttributes, e),
|
|
1445
|
+
0
|
|
1446
|
+
];
|
|
1447
|
+
}
|
|
1448
|
+
}), vt = o.create({
|
|
1449
|
+
name: "tableRow",
|
|
1450
|
+
addOptions() {
|
|
1451
|
+
return { HTMLAttributes: {} };
|
|
1452
|
+
},
|
|
1453
|
+
content: "(tableCell | tableHeader)*",
|
|
1454
|
+
tableRole: "row",
|
|
1455
|
+
parseHTML() {
|
|
1456
|
+
return [{ tag: "tr" }];
|
|
1457
|
+
},
|
|
1458
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
1459
|
+
return [
|
|
1460
|
+
"tr",
|
|
1461
|
+
i(this.options.HTMLAttributes, e),
|
|
1462
|
+
0
|
|
1463
|
+
];
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
function X(e, t) {
|
|
1467
|
+
return t ? ["width", `${Math.max(t, e)}px`] : ["min-width", `${e}px`];
|
|
1468
|
+
}
|
|
1469
|
+
function Z(e, t, n, r, i, a) {
|
|
1470
|
+
let o = 0, s = !0, c = t.firstChild, l = e.firstChild;
|
|
1471
|
+
if (l !== null) for (let e = 0, n = 0; e < l.childCount; e += 1) {
|
|
1472
|
+
let { colspan: u, colwidth: d } = l.child(e).attrs;
|
|
1473
|
+
for (let e = 0; e < u; e += 1, n += 1) {
|
|
1474
|
+
let l = i === n ? a : d && d[e], u = l ? `${l}px` : "";
|
|
1475
|
+
if (o += l || r, l || (s = !1), c) {
|
|
1476
|
+
if (c.style.width !== u) {
|
|
1477
|
+
let [e, t] = X(r, l);
|
|
1478
|
+
c.style.setProperty(e, t);
|
|
1479
|
+
}
|
|
1480
|
+
c = c.nextSibling;
|
|
1481
|
+
} else {
|
|
1482
|
+
let e = document.createElement("col"), [n, i] = X(r, l);
|
|
1483
|
+
e.style.setProperty(n, i), t.appendChild(e);
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
for (; c;) {
|
|
1488
|
+
var u;
|
|
1489
|
+
let e = c.nextSibling;
|
|
1490
|
+
(u = c.parentNode) == null || u.removeChild(c), c = e;
|
|
1491
|
+
}
|
|
1492
|
+
let d = e.attrs.style && typeof e.attrs.style == "string" && /\bwidth\s*:/i.test(e.attrs.style);
|
|
1493
|
+
s && !d ? (n.style.width = `${o}px`, n.style.minWidth = "") : (n.style.width = "", n.style.minWidth = `${o}px`);
|
|
1494
|
+
}
|
|
1495
|
+
var yt = class {
|
|
1496
|
+
constructor(e, t, n, r = {}) {
|
|
1497
|
+
this.node = e, this.cellMinWidth = t, this.dom = document.createElement("div"), this.dom.className = "tableWrapper", this.table = this.dom.appendChild(document.createElement("table"));
|
|
1498
|
+
for (let [e, t] of Object.entries(r)) t != null && (e === "style" ? this.table.style.cssText = String(t) : this.table.setAttribute(e, String(t)));
|
|
1499
|
+
e.attrs.style && (this.table.style.cssText = e.attrs.style), this.colgroup = this.table.appendChild(document.createElement("colgroup")), Z(e, this.colgroup, this.table, t), this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
1500
|
+
}
|
|
1501
|
+
update(e) {
|
|
1502
|
+
return e.type === this.node.type ? (this.node = e, Z(e, this.colgroup, this.table, this.cellMinWidth), !0) : !1;
|
|
1503
|
+
}
|
|
1504
|
+
ignoreMutation(e) {
|
|
1505
|
+
let t = e.target, n = this.dom.contains(t), r = this.contentDOM.contains(t);
|
|
1506
|
+
return !!(n && !r && (e.type === "attributes" || e.type === "childList" || e.type === "characterData"));
|
|
1507
|
+
}
|
|
1508
|
+
};
|
|
1509
|
+
function bt(e, t, n, r) {
|
|
1510
|
+
let i = 0, a = !0, o = [], s = e.firstChild;
|
|
1511
|
+
if (!s) return {};
|
|
1512
|
+
for (let e = 0, c = 0; e < s.childCount; e += 1) {
|
|
1513
|
+
let { colspan: l, colwidth: u } = s.child(e).attrs;
|
|
1514
|
+
for (let e = 0; e < l; e += 1, c += 1) {
|
|
1515
|
+
let s = n === c ? r : u && u[e];
|
|
1516
|
+
i += s || t, s || (a = !1);
|
|
1517
|
+
let [l, d] = X(t, s);
|
|
1518
|
+
o.push(["col", { style: `${l}: ${d}` }]);
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
let c = a ? `${i}px` : "", l = a ? "" : `${i}px`;
|
|
1522
|
+
return {
|
|
1523
|
+
colgroup: [
|
|
1524
|
+
"colgroup",
|
|
1525
|
+
{},
|
|
1526
|
+
...o
|
|
1527
|
+
],
|
|
1528
|
+
tableWidth: c,
|
|
1529
|
+
tableMinWidth: l
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
function xt(e, t) {
|
|
1533
|
+
return t ? e.createChecked(null, t) : e.createAndFill();
|
|
1534
|
+
}
|
|
1535
|
+
function St(e) {
|
|
1536
|
+
if (e.cached.tableNodeTypes) return e.cached.tableNodeTypes;
|
|
1537
|
+
let t = {};
|
|
1538
|
+
return Object.keys(e.nodes).forEach((n) => {
|
|
1539
|
+
let r = e.nodes[n];
|
|
1540
|
+
r.spec.tableRole && (t[r.spec.tableRole] = r);
|
|
1541
|
+
}), e.cached.tableNodeTypes = t, t;
|
|
1542
|
+
}
|
|
1543
|
+
function Ct(e, t, n, r, i) {
|
|
1544
|
+
let a = St(e), o = [], s = [];
|
|
1545
|
+
for (let e = 0; e < n; e += 1) {
|
|
1546
|
+
let e = xt(a.cell, i);
|
|
1547
|
+
if (e && s.push(e), r) {
|
|
1548
|
+
let e = xt(a.header_cell, i);
|
|
1549
|
+
e && o.push(e);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
let c = [];
|
|
1553
|
+
for (let e = 0; e < t; e += 1) c.push(a.row.createChecked(null, r && e === 0 ? o : s));
|
|
1554
|
+
return a.table.createChecked(null, c);
|
|
1555
|
+
}
|
|
1556
|
+
function wt(e) {
|
|
1557
|
+
return e instanceof D;
|
|
1558
|
+
}
|
|
1559
|
+
var Q = ({ editor: e }) => {
|
|
1560
|
+
let { selection: t } = e.state;
|
|
1561
|
+
if (!wt(t)) return !1;
|
|
1562
|
+
let r = 0;
|
|
1563
|
+
return n(t.ranges[0].$from, (e) => e.type.name === "table")?.node.descendants((e) => {
|
|
1564
|
+
if (e.type.name === "table") return !1;
|
|
1565
|
+
["tableCell", "tableHeader"].includes(e.type.name) && (r += 1);
|
|
1566
|
+
}), r === t.ranges.length ? (e.commands.deleteTable(), !0) : !1;
|
|
1567
|
+
};
|
|
1568
|
+
function Tt(e, t) {
|
|
1569
|
+
let r = e.mapping.map(t);
|
|
1570
|
+
if (n(e.selection.$from, (e) => e.type.name === "table")?.pos === r) return;
|
|
1571
|
+
let i = e.doc.nodeAt(r);
|
|
1572
|
+
if (!i) return;
|
|
1573
|
+
let a = r + i.nodeSize - 1;
|
|
1574
|
+
e.setSelection(u.near(e.doc.resolve(a), -1));
|
|
1575
|
+
}
|
|
1576
|
+
var Et = "";
|
|
1577
|
+
function Dt(e) {
|
|
1578
|
+
let t = "", n = 0;
|
|
1579
|
+
for (; n < e.length;) {
|
|
1580
|
+
if (e[n] === "\\" && n + 1 < e.length) {
|
|
1581
|
+
t += e[n] + e[n + 1], n += 2;
|
|
1582
|
+
continue;
|
|
1583
|
+
}
|
|
1584
|
+
if (e[n] !== "`") {
|
|
1585
|
+
t += e[n++];
|
|
1586
|
+
continue;
|
|
1587
|
+
}
|
|
1588
|
+
let r = 0;
|
|
1589
|
+
for (; n + r < e.length && e[n + r] === "`";) r += 1;
|
|
1590
|
+
let i = n + r, a = !1;
|
|
1591
|
+
for (; i < e.length;) {
|
|
1592
|
+
if (e[i] !== "`") {
|
|
1593
|
+
i += 1;
|
|
1594
|
+
continue;
|
|
1595
|
+
}
|
|
1596
|
+
let o = 0;
|
|
1597
|
+
for (; i + o < e.length && e[i + o] === "`";) o += 1;
|
|
1598
|
+
if (o === r) {
|
|
1599
|
+
let o = e.slice(n + r, i);
|
|
1600
|
+
t += e.slice(n, n + r) + o.replace(/\\\||\|/g, (e) => e === "|" ? "\\|" : e) + e.slice(i, i + r), n = i + r, a = !0;
|
|
1601
|
+
break;
|
|
1602
|
+
}
|
|
1603
|
+
i += o;
|
|
1604
|
+
}
|
|
1605
|
+
a || (t += e.slice(n, n + r), n += r);
|
|
1606
|
+
}
|
|
1607
|
+
return t;
|
|
1608
|
+
}
|
|
1609
|
+
function Ot(e) {
|
|
1610
|
+
return e.split("\n").map((e) => !e.includes("|") || !e.includes("`") ? e : Dt(e)).join("\n");
|
|
1611
|
+
}
|
|
1612
|
+
function kt(e) {
|
|
1613
|
+
return (e || "").replace(/\s+/g, " ").trim();
|
|
1614
|
+
}
|
|
1615
|
+
function At(e, t, n = {}) {
|
|
1616
|
+
let r = n.cellLineSeparator ?? "";
|
|
1617
|
+
if (!e || !e.content || e.content.length === 0) return "";
|
|
1618
|
+
let i = [];
|
|
1619
|
+
e.content.forEach((e) => {
|
|
1620
|
+
let n = [];
|
|
1621
|
+
e.content && e.content.forEach((e) => {
|
|
1622
|
+
let i = "";
|
|
1623
|
+
i = e.content && Array.isArray(e.content) && e.content.length > 1 ? e.content.map((e) => t.renderChildren(e)).join(r) : e.content ? t.renderChildren(e.content) : "";
|
|
1624
|
+
let a = kt(i.split(r).join("\n").replace(/[ \t]*\r?\n[ \t]*/g, "<br>")), o = e.type === "tableHeader", s = ut(e.attrs);
|
|
1625
|
+
n.push({
|
|
1626
|
+
text: a,
|
|
1627
|
+
isHeader: o,
|
|
1628
|
+
align: s
|
|
1629
|
+
});
|
|
1630
|
+
}), i.push(n);
|
|
1631
|
+
});
|
|
1632
|
+
let a = i.reduce((e, t) => Math.max(e, t.length), 0);
|
|
1633
|
+
if (a === 0) return "";
|
|
1634
|
+
let o = Array.from({ length: a }).fill(0);
|
|
1635
|
+
i.forEach((e) => {
|
|
1636
|
+
for (let t = 0; t < a; t += 1) {
|
|
1637
|
+
let n = (e[t]?.text || "").length;
|
|
1638
|
+
n > o[t] && (o[t] = n), o[t] < 3 && (o[t] = 3);
|
|
1639
|
+
}
|
|
1640
|
+
});
|
|
1641
|
+
let s = (e, t) => e + " ".repeat(Math.max(0, t - e.length)), c = i[0], l = c.some((e) => e.isHeader), u = Array.from({ length: a }).fill(null);
|
|
1642
|
+
i.forEach((e) => {
|
|
1643
|
+
for (let t = 0; t < a; t += 1) !u[t] && e[t]?.align && (u[t] = e[t].align);
|
|
1644
|
+
});
|
|
1645
|
+
let d = "\n", f = Array.from({ length: a }).map((e, t) => l && c[t] && c[t].text || "");
|
|
1646
|
+
return d += `| ${f.map((e, t) => s(e, o[t])).join(" | ")} |\n`, d += `| ${o.map((e, t) => {
|
|
1647
|
+
let n = Math.max(3, e), r = u[t];
|
|
1648
|
+
return r === "left" ? `:${"-".repeat(n)}` : r === "right" ? `${"-".repeat(n)}:` : r === "center" ? `:${"-".repeat(n)}:` : "-".repeat(n);
|
|
1649
|
+
}).join(" | ")} |\n`, (l ? i.slice(1) : i).forEach((e) => {
|
|
1650
|
+
d += `| ${Array.from({ length: a }).fill(0).map((t, n) => s(e[n] && e[n].text || "", o[n])).join(" | ")} |\n`;
|
|
1651
|
+
}), d;
|
|
1652
|
+
}
|
|
1653
|
+
var $ = o.create({
|
|
1654
|
+
name: "table",
|
|
1655
|
+
addOptions() {
|
|
1656
|
+
return {
|
|
1657
|
+
HTMLAttributes: {},
|
|
1658
|
+
resizable: !1,
|
|
1659
|
+
renderWrapper: !1,
|
|
1660
|
+
handleWidth: 5,
|
|
1661
|
+
cellMinWidth: 25,
|
|
1662
|
+
View: yt,
|
|
1663
|
+
lastColumnResizable: !0,
|
|
1664
|
+
allowTableNodeSelection: !1
|
|
1665
|
+
};
|
|
1666
|
+
},
|
|
1667
|
+
content: "tableRow+",
|
|
1668
|
+
tableRole: "table",
|
|
1669
|
+
isolating: !0,
|
|
1670
|
+
group: "block",
|
|
1671
|
+
parseHTML() {
|
|
1672
|
+
return [{ tag: "table" }];
|
|
1673
|
+
},
|
|
1674
|
+
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
1675
|
+
let { colgroup: n, tableWidth: r, tableMinWidth: a } = bt(e, this.options.cellMinWidth), o = t.style;
|
|
1676
|
+
function s() {
|
|
1677
|
+
return o || (r ? `width: ${r}` : `min-width: ${a}`);
|
|
1678
|
+
}
|
|
1679
|
+
let c = [
|
|
1680
|
+
"table",
|
|
1681
|
+
i(this.options.HTMLAttributes, t, { style: s() }),
|
|
1682
|
+
n,
|
|
1683
|
+
["tbody", 0]
|
|
1684
|
+
];
|
|
1685
|
+
return this.options.renderWrapper ? [
|
|
1686
|
+
"div",
|
|
1687
|
+
{ class: "tableWrapper" },
|
|
1688
|
+
c
|
|
1689
|
+
] : c;
|
|
1690
|
+
},
|
|
1691
|
+
parseMarkdown: (e, t) => {
|
|
1692
|
+
let n = [], r = Array.isArray(e.align) ? e.align : [];
|
|
1693
|
+
if (e.header) {
|
|
1694
|
+
let i = [];
|
|
1695
|
+
e.header.forEach((e, n) => {
|
|
1696
|
+
let a = J(r[n] ?? e.align), o = a ? { align: a } : {};
|
|
1697
|
+
i.push(t.createNode("tableHeader", o, [{
|
|
1698
|
+
type: "paragraph",
|
|
1699
|
+
content: t.parseInline(e.tokens)
|
|
1700
|
+
}]));
|
|
1701
|
+
}), n.push(t.createNode("tableRow", {}, i));
|
|
1702
|
+
}
|
|
1703
|
+
return e.rows && e.rows.forEach((e) => {
|
|
1704
|
+
let i = [];
|
|
1705
|
+
e.forEach((e, n) => {
|
|
1706
|
+
let a = J(r[n] ?? e.align), o = a ? { align: a } : {};
|
|
1707
|
+
i.push(t.createNode("tableCell", o, [{
|
|
1708
|
+
type: "paragraph",
|
|
1709
|
+
content: t.parseInline(e.tokens)
|
|
1710
|
+
}]));
|
|
1711
|
+
}), n.push(t.createNode("tableRow", {}, i));
|
|
1712
|
+
}), t.createNode("table", void 0, n);
|
|
1713
|
+
},
|
|
1714
|
+
renderMarkdown: (e, t) => At(e, t),
|
|
1715
|
+
markdownTokenizer: {
|
|
1716
|
+
name: "table",
|
|
1717
|
+
level: "block",
|
|
1718
|
+
start: (e) => {
|
|
1719
|
+
let t = e.split("\n");
|
|
1720
|
+
if (t.length < 2) return -1;
|
|
1721
|
+
let n = t[1];
|
|
1722
|
+
return !/^[ \t|:]*-[ \t|:-]*$/.test(n) || !n.includes("|") ? -1 : t[0].includes("|") ? 0 : -1;
|
|
1723
|
+
},
|
|
1724
|
+
tokenize(e, t, n) {
|
|
1725
|
+
let r = e.indexOf("\n\n"), i = r >= 0 ? e.slice(0, r) : e, a = i.split("\n");
|
|
1726
|
+
if (a.length < 2) return;
|
|
1727
|
+
let o = a[1];
|
|
1728
|
+
if (!/^[ \t|:]*-[ \t|:-]*$/.test(o) || !o.includes("|")) return;
|
|
1729
|
+
let s = Ot(i);
|
|
1730
|
+
if (s === i) return;
|
|
1731
|
+
let c = n.blockTokens(s)[0];
|
|
1732
|
+
if (c?.type !== "table" || !c.raw) return;
|
|
1733
|
+
let l = c.raw.split("\n").length, u = e.split("\n").slice(0, l).join("\n");
|
|
1734
|
+
return {
|
|
1735
|
+
...c,
|
|
1736
|
+
raw: u
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
},
|
|
1740
|
+
addCommands() {
|
|
1741
|
+
return {
|
|
1742
|
+
insertTable: ({ rows: e = 3, cols: t = 3, withHeaderRow: n = !0 } = {}) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
1743
|
+
let o = Ct(a.schema, e, t, n);
|
|
1744
|
+
if (i) {
|
|
1745
|
+
let e = r.selection.from + 1;
|
|
1746
|
+
r.replaceSelectionWith(o).scrollIntoView().setSelection(u.near(r.doc.resolve(e)));
|
|
1747
|
+
}
|
|
1748
|
+
return !0;
|
|
1749
|
+
},
|
|
1750
|
+
addColumnBefore: () => ({ state: e, dispatch: t }) => ye(e, t),
|
|
1751
|
+
addColumnAfter: () => ({ state: e, dispatch: t }) => be(e, t),
|
|
1752
|
+
deleteColumn: () => ({ state: e, dispatch: t }) => {
|
|
1753
|
+
let r = n(e.selection.$from, (e) => e.type.name === "table");
|
|
1754
|
+
return Se(e, t && ((e) => {
|
|
1755
|
+
r && Tt(e, r.pos), t(e);
|
|
1756
|
+
}));
|
|
1757
|
+
},
|
|
1758
|
+
addRowBefore: () => ({ state: e, dispatch: t }) => we(e, t),
|
|
1759
|
+
addRowAfter: () => ({ state: e, dispatch: t }) => Te(e, t),
|
|
1760
|
+
deleteRow: () => ({ state: e, dispatch: t }) => {
|
|
1761
|
+
let r = n(e.selection.$from, (e) => e.type.name === "table");
|
|
1762
|
+
return De(e, t && ((e) => {
|
|
1763
|
+
r && Tt(e, r.pos), t(e);
|
|
1764
|
+
}));
|
|
1765
|
+
},
|
|
1766
|
+
deleteTable: () => ({ state: e, dispatch: t }) => Pe(e, t),
|
|
1767
|
+
mergeCells: () => ({ state: e, dispatch: t }) => P(e, t),
|
|
1768
|
+
splitCell: () => ({ state: e, dispatch: t }) => F(e, t),
|
|
1769
|
+
toggleHeaderColumn: () => ({ state: e, dispatch: t }) => L("column")(e, t),
|
|
1770
|
+
toggleHeaderRow: () => ({ state: e, dispatch: t }) => L("row")(e, t),
|
|
1771
|
+
toggleHeaderCell: () => ({ state: e, dispatch: t }) => Me(e, t),
|
|
1772
|
+
mergeOrSplit: () => ({ state: e, dispatch: t }) => P(e, t) ? !0 : F(e, t),
|
|
1773
|
+
setCellAttribute: (e, t) => ({ state: n, dispatch: r }) => Ae(e, t)(n, r),
|
|
1774
|
+
goToNextCell: () => ({ state: e, dispatch: t }) => R(1)(e, t),
|
|
1775
|
+
goToPreviousCell: () => ({ state: e, dispatch: t }) => R(-1)(e, t),
|
|
1776
|
+
fixTables: () => ({ state: e, dispatch: t }) => (t && k(e), !0),
|
|
1777
|
+
setCellSelection: (e) => ({ tr: t, dispatch: n }) => {
|
|
1778
|
+
if (n) {
|
|
1779
|
+
let n = D.create(t.doc, e.anchorCell, e.headCell);
|
|
1780
|
+
t.setSelection(n);
|
|
1781
|
+
}
|
|
1782
|
+
return !0;
|
|
1783
|
+
}
|
|
1784
|
+
};
|
|
1785
|
+
},
|
|
1786
|
+
addKeyboardShortcuts() {
|
|
1787
|
+
return {
|
|
1788
|
+
Tab: () => this.editor.commands.goToNextCell() ? !0 : this.editor.can().addRowAfter() ? this.editor.chain().addRowAfter().goToNextCell().run() : !1,
|
|
1789
|
+
"Shift-Tab": () => this.editor.commands.goToPreviousCell(),
|
|
1790
|
+
Backspace: Q,
|
|
1791
|
+
"Mod-Backspace": Q,
|
|
1792
|
+
Delete: Q,
|
|
1793
|
+
"Mod-Delete": Q
|
|
1794
|
+
};
|
|
1795
|
+
},
|
|
1796
|
+
addProseMirrorPlugins() {
|
|
1797
|
+
return [...this.options.resizable && this.editor.isEditable ? [Je({
|
|
1798
|
+
handleWidth: this.options.handleWidth,
|
|
1799
|
+
cellMinWidth: this.options.cellMinWidth,
|
|
1800
|
+
defaultCellMinWidth: this.options.cellMinWidth,
|
|
1801
|
+
View: this.options.View,
|
|
1802
|
+
lastColumnResizable: this.options.lastColumnResizable
|
|
1803
|
+
})] : [], ct({ allowTableNodeSelection: this.options.allowTableNodeSelection })];
|
|
1804
|
+
},
|
|
1805
|
+
addNodeView() {
|
|
1806
|
+
let e = this.options.resizable && this.editor.isEditable, t = this.options.View;
|
|
1807
|
+
return e || !t ? null : ({ node: e, view: n, HTMLAttributes: r }) => {
|
|
1808
|
+
let a = i(this.options.HTMLAttributes, r);
|
|
1809
|
+
return new t(e, this.options.cellMinWidth, n, a);
|
|
1810
|
+
};
|
|
1811
|
+
},
|
|
1812
|
+
extendNodeSchema(e) {
|
|
1813
|
+
return { tableRole: c(a(e, "tableRole", {
|
|
1814
|
+
name: e.name,
|
|
1815
|
+
options: e.options,
|
|
1816
|
+
storage: e.storage
|
|
1817
|
+
})) };
|
|
1818
|
+
}
|
|
1819
|
+
}), jt = s.create({
|
|
1820
|
+
name: "tableKit",
|
|
1821
|
+
addExtensions() {
|
|
1822
|
+
let e = [];
|
|
1823
|
+
return this.options.table !== !1 && e.push($.configure(this.options.table)), this.options.tableCell !== !1 && e.push(gt.configure(this.options.tableCell)), this.options.tableHeader !== !1 && e.push(_t.configure(this.options.tableHeader)), this.options.tableRow !== !1 && e.push(vt.configure(this.options.tableRow)), e;
|
|
1824
|
+
}
|
|
1825
|
+
});
|
|
1826
|
+
//#endregion
|
|
1827
|
+
export { jt as a, bt as c, Ot as d, At as f, _t as i, Ct as l, $ as n, vt as o, Z as p, gt as r, yt as s, Et as t, Dt as u };
|
|
1828
|
+
|
|
1829
|
+
//# sourceMappingURL=dist-86k79VvK.js.map
|