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