@milkdown/preset-gfm 6.2.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/footnote/definition.d.ts.map +1 -1
- package/lib/footnote/reference.d.ts.map +1 -1
- package/lib/index.es.js +1802 -2369
- package/lib/index.es.js.map +1 -1
- package/lib/supported-keys.d.ts +1 -0
- package/lib/supported-keys.d.ts.map +1 -1
- package/lib/table/nodes/index.d.ts +0 -3
- package/lib/table/nodes/index.d.ts.map +1 -1
- package/lib/table/operator-plugin/calc-pos.d.ts.map +1 -1
- package/lib/table/operator-plugin/helper.d.ts +1 -1
- package/lib/table/operator-plugin/helper.d.ts.map +1 -1
- package/lib/table/plugin/auto-insert-zero-space.d.ts +3 -0
- package/lib/table/plugin/auto-insert-zero-space.d.ts.map +1 -0
- package/lib/table/{nodes → plugin}/cell-selection.d.ts +0 -0
- package/lib/table/plugin/cell-selection.d.ts.map +1 -0
- package/lib/table/plugin/column-resizing.d.ts +17 -0
- package/lib/table/plugin/column-resizing.d.ts.map +1 -0
- package/lib/table/{nodes → plugin}/commands.d.ts +0 -0
- package/lib/table/plugin/commands.d.ts.map +1 -0
- package/lib/table/{nodes → plugin}/copy-paste.d.ts +0 -0
- package/lib/table/plugin/copy-paste.d.ts.map +1 -0
- package/lib/table/{nodes → plugin}/fix-tables.d.ts +0 -0
- package/lib/table/plugin/fix-tables.d.ts.map +1 -0
- package/lib/table/plugin/index.d.ts +4 -0
- package/lib/table/plugin/index.d.ts.map +1 -0
- package/lib/table/{nodes → plugin}/schema.d.ts +0 -0
- package/lib/table/plugin/schema.d.ts.map +1 -0
- package/lib/table/{nodes → plugin}/table-editing.d.ts +1 -1
- package/lib/table/plugin/table-editing.d.ts.map +1 -0
- package/lib/table/{nodes → plugin}/table-map.d.ts +0 -0
- package/lib/table/plugin/table-map.d.ts.map +1 -0
- package/lib/table/{nodes → plugin}/table-view.d.ts +0 -0
- package/lib/table/plugin/table-view.d.ts.map +1 -0
- package/lib/table/{nodes → plugin}/types.d.ts +0 -0
- package/lib/table/plugin/types.d.ts.map +1 -0
- package/lib/table/{nodes → plugin}/util.d.ts +0 -0
- package/lib/table/plugin/util.d.ts.map +1 -0
- package/lib/table/utils.d.ts +3 -3
- package/lib/table/utils.d.ts.map +1 -1
- package/lib/task-list-item.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/footnote/definition.ts +3 -1
- package/src/footnote/reference.ts +2 -1
- package/src/table/command.ts +1 -1
- package/src/table/nodes/index.ts +7 -9
- package/src/table/operator-plugin/actions.ts +1 -1
- package/src/table/operator-plugin/calc-pos.ts +3 -2
- package/src/table/operator-plugin/helper.ts +2 -2
- package/src/table/operator-plugin/index.ts +1 -1
- package/src/table/plugin/auto-insert-zero-space.ts +51 -0
- package/src/table/{nodes → plugin}/cell-selection.ts +0 -0
- package/src/table/{nodes → plugin}/column-resizing.ts +0 -0
- package/src/table/{nodes → plugin}/commands.ts +0 -0
- package/src/table/{nodes → plugin}/copy-paste.ts +0 -0
- package/src/table/{nodes → plugin}/fix-tables.ts +0 -0
- package/src/table/plugin/index.ts +4 -0
- package/src/table/{nodes → plugin}/schema.ts +0 -0
- package/src/table/{nodes → plugin}/table-editing.ts +0 -0
- package/src/table/{nodes → plugin}/table-map.ts +0 -0
- package/src/table/{nodes → plugin}/table-view.ts +0 -0
- package/src/table/{nodes → plugin}/types.ts +0 -0
- package/src/table/{nodes → plugin}/util.ts +0 -0
- package/src/table/utils.ts +29 -23
- package/src/task-list-item.ts +2 -1
- package/lib/table/nodes/cell-selection.d.ts.map +0 -1
- package/lib/table/nodes/column-resizing.d.ts +0 -10
- package/lib/table/nodes/column-resizing.d.ts.map +0 -1
- package/lib/table/nodes/commands.d.ts.map +0 -1
- package/lib/table/nodes/copy-paste.d.ts.map +0 -1
- package/lib/table/nodes/fix-tables.d.ts.map +0 -1
- package/lib/table/nodes/schema.d.ts.map +0 -1
- package/lib/table/nodes/table-editing.d.ts.map +0 -1
- package/lib/table/nodes/table-map.d.ts.map +0 -1
- package/lib/table/nodes/table-view.d.ts.map +0 -1
- package/lib/table/nodes/types.d.ts.map +0 -1
- package/lib/table/nodes/util.d.ts.map +0 -1
package/lib/index.es.js
CHANGED
|
@@ -1,66 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { SupportedKeys as SupportedKeys$2, commonmark, commands as commands$1 } from "@milkdown/preset-commonmark";
|
|
21
|
-
export { InsertHardbreak, InsertHr, InsertImage, LiftListItem, ModifyImage, ModifyLink, SinkListItem, SplitListItem, ToggleBold, ToggleInlineCode, ToggleItalic, ToggleLink, TurnIntoCodeFence, TurnIntoHeading, TurnIntoText, WrapInBlockquote, WrapInBulletList, WrapInOrderedList, blockquote, bulletList, codeFence, codeInline, commonmark, commonmarkNodes, commonmarkPlugins, doc, em, hardbreak, heading, hr, image, link, listItem, orderedList, paragraph, strong, text } from "@milkdown/preset-commonmark";
|
|
22
|
-
import { $prose, createNode, createPlugin, createShortcut, createMark, AtomList, $remark } from "@milkdown/utils";
|
|
23
|
-
import remarkGFM from "remark-gfm";
|
|
24
|
-
import { inputRules, InputRule, wrappingInputRule } from "@milkdown/prose/inputrules";
|
|
25
|
-
import { createCmdKey, editorViewCtx, createCmd, commandsCtx, themeManagerCtx, ThemeIcon, ThemeBorder, ThemeShadow, getPalette, ThemeSize, schemaCtx } from "@milkdown/core";
|
|
26
|
-
import { findSelectedNodeOfType, findParentNode, cloneTr, calculateNodePosition, markRule } from "@milkdown/prose";
|
|
27
|
-
import { PluginKey, NodeSelection, Plugin, Selection, SelectionRange, TextSelection } from "@milkdown/prose/state";
|
|
28
|
-
import { toggleMark, wrapIn } from "@milkdown/prose/commands";
|
|
29
|
-
import { Fragment, Slice } from "@milkdown/prose/model";
|
|
30
|
-
import { Decoration, DecorationSet } from "@milkdown/prose/view";
|
|
31
|
-
import { keydownHandler } from "@milkdown/prose/keymap";
|
|
32
|
-
import { Transform } from "@milkdown/prose/transform";
|
|
33
|
-
import { splitListItem, sinkListItem, liftListItem } from "@milkdown/prose/schema-list";
|
|
34
|
-
const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/;
|
|
35
|
-
const proseUrlPlugin = () => inputRules({
|
|
1
|
+
import { SupportedKeys as st, commonmark as rt, commands as it } from "@milkdown/preset-commonmark";
|
|
2
|
+
import { InsertHardbreak as mo, InsertHr as go, InsertImage as wo, LiftListItem as bo, ModifyImage as Co, ModifyLink as yo, SinkListItem as ko, SplitListItem as Ao, ToggleBold as Mo, ToggleInlineCode as No, ToggleItalic as So, ToggleLink as Ro, TurnIntoCodeFence as xo, TurnIntoHeading as To, TurnIntoText as Lo, WrapInBlockquote as vo, WrapInBulletList as Eo, WrapInOrderedList as Io, blockquote as $o, bulletList as Do, codeFence as _o, codeInline as Oo, commonmark as zo, commonmarkNodes as Fo, commonmarkPlugins as Bo, doc as Po, em as Wo, hardbreak as Ho, heading as jo, hr as Ko, image as qo, link as Uo, listItem as Xo, orderedList as Vo, paragraph as Zo, strong as Go, text as Jo } from "@milkdown/preset-commonmark";
|
|
3
|
+
import { $prose as ct, createNode as be, createPlugin as at, createShortcut as $, createMark as dt, AtomList as ut, $remark as ft } from "@milkdown/utils";
|
|
4
|
+
import pt from "remark-gfm";
|
|
5
|
+
import { inputRules as ht, InputRule as Ce, wrappingInputRule as Ve } from "@milkdown/prose/inputrules";
|
|
6
|
+
import { createCmdKey as x, editorViewCtx as ee, createCmd as S, commandsCtx as Ze, themeManagerCtx as L, ThemeIcon as v, ThemeBorder as mt, ThemeShadow as gt, getPalette as wt, ThemeSize as Re, schemaCtx as re } from "@milkdown/core";
|
|
7
|
+
import { expectDomTypeError as ye, missingRootElement as bt } from "@milkdown/exception";
|
|
8
|
+
import { findSelectedNodeOfType as P, findParentNode as Ct, cloneTr as Ge, calculateNodePosition as yt, browser as xe, markRule as Te } from "@milkdown/prose";
|
|
9
|
+
import { PluginKey as O, NodeSelection as te, Plugin as B, Selection as N, SelectionRange as kt, TextSelection as D } from "@milkdown/prose/state";
|
|
10
|
+
import { toggleMark as At, wrapIn as Mt } from "@milkdown/prose/commands";
|
|
11
|
+
import { Fragment as E, Slice as _ } from "@milkdown/prose/model";
|
|
12
|
+
import { Decoration as ke, DecorationSet as Ae } from "@milkdown/prose/view";
|
|
13
|
+
import { keydownHandler as Nt } from "@milkdown/prose/keymap";
|
|
14
|
+
import { Transform as St } from "@milkdown/prose/transform";
|
|
15
|
+
import { splitListItem as Rt, sinkListItem as xt, liftListItem as Tt } from "@milkdown/prose/schema-list";
|
|
16
|
+
const Lt = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/, vt = () => ht({
|
|
36
17
|
rules: [
|
|
37
|
-
new
|
|
38
|
-
var
|
|
39
|
-
const { schema:
|
|
40
|
-
|
|
41
|
-
if (!text2)
|
|
42
|
-
return null;
|
|
43
|
-
const link2 = (_a = schema2.marks["link"]) == null ? void 0 : _a.create({ href: text2 });
|
|
44
|
-
if (!link2)
|
|
18
|
+
new Ce(Lt, (o, e, t, n) => {
|
|
19
|
+
var a;
|
|
20
|
+
const { schema: l } = o, [s] = e;
|
|
21
|
+
if (!s)
|
|
45
22
|
return null;
|
|
46
|
-
|
|
23
|
+
const r = (a = l.marks.link) == null ? void 0 : a.create({ href: s });
|
|
24
|
+
return r ? o.tr.replaceWith(t, n, l.text(s)).addMark(t, s.length + t, r) : null;
|
|
47
25
|
})
|
|
48
26
|
]
|
|
49
|
-
})
|
|
50
|
-
const
|
|
51
|
-
const getFootnoteRefId = (label) => `footnote-ref-${label}`;
|
|
52
|
-
const getFootnoteDefId = (label) => `footnote-def-${label}`;
|
|
53
|
-
const key$2 = new PluginKey("MILKDOWN_FOOTNOTE_DEF_INPUT");
|
|
54
|
-
const ModifyFootnoteDef = createCmdKey("ModifyFootnoteDef");
|
|
55
|
-
const footnoteDefinition = createNode((utils) => {
|
|
56
|
-
const id2 = "footnote_definition";
|
|
57
|
-
const markdownId = "footnoteDefinition";
|
|
27
|
+
}), Et = ct(() => vt()), Je = (o) => `footnote-ref-${o}`, Ye = (o) => `footnote-def-${o}`, It = new O("MILKDOWN_FOOTNOTE_DEF_INPUT"), Le = x("ModifyFootnoteDef"), $t = be((o) => {
|
|
28
|
+
const e = "footnote_definition", t = "footnoteDefinition";
|
|
58
29
|
return {
|
|
59
|
-
id:
|
|
60
|
-
schema: (
|
|
30
|
+
id: e,
|
|
31
|
+
schema: (n) => ({
|
|
61
32
|
group: "block",
|
|
62
33
|
content: "block+",
|
|
63
|
-
defining:
|
|
34
|
+
defining: !0,
|
|
64
35
|
attrs: {
|
|
65
36
|
label: {
|
|
66
37
|
default: ""
|
|
@@ -68,148 +39,115 @@ const footnoteDefinition = createNode((utils) => {
|
|
|
68
39
|
},
|
|
69
40
|
parseDOM: [
|
|
70
41
|
{
|
|
71
|
-
tag: `div[data-type="${
|
|
72
|
-
getAttrs: (
|
|
73
|
-
if (!(
|
|
74
|
-
throw
|
|
75
|
-
}
|
|
42
|
+
tag: `div[data-type="${e}"]`,
|
|
43
|
+
getAttrs: (l) => {
|
|
44
|
+
if (!(l instanceof HTMLElement))
|
|
45
|
+
throw ye(l);
|
|
76
46
|
return {
|
|
77
|
-
label:
|
|
47
|
+
label: l.dataset.label
|
|
78
48
|
};
|
|
79
|
-
}
|
|
49
|
+
},
|
|
50
|
+
contentElement: "dd"
|
|
80
51
|
}
|
|
81
52
|
],
|
|
82
|
-
toDOM: (
|
|
83
|
-
const label =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
dt.onclick = () => {
|
|
88
|
-
const view = ctx.get(editorViewCtx);
|
|
89
|
-
const selection = NodeSelection.create(view.state.doc, view.state.selection.from - 2);
|
|
90
|
-
view.dispatch(view.state.tr.setSelection(selection));
|
|
91
|
-
};
|
|
92
|
-
const a = document.createElement("a");
|
|
93
|
-
a.href = `#${getFootnoteRefId(label)}`;
|
|
94
|
-
a.contentEditable = "false";
|
|
95
|
-
a.textContent = "\u21A9";
|
|
96
|
-
a.onmousedown = (e) => {
|
|
97
|
-
e.preventDefault();
|
|
53
|
+
toDOM: (l) => {
|
|
54
|
+
const s = l.attrs.label, r = o.getClassName(l.attrs, "footnote-definition"), a = document.createElement("dt");
|
|
55
|
+
a.textContent = `[${s}]:`, a.onclick = () => {
|
|
56
|
+
const c = n.get(ee), d = te.create(c.state.doc, c.state.selection.from - 2);
|
|
57
|
+
c.dispatch(c.state.tr.setSelection(d));
|
|
98
58
|
};
|
|
99
|
-
|
|
59
|
+
const i = document.createElement("a");
|
|
60
|
+
return i.href = `#${Je(s)}`, i.contentEditable = "false", i.textContent = "\u21A9", i.onmousedown = (c) => {
|
|
61
|
+
c.preventDefault();
|
|
62
|
+
}, [
|
|
100
63
|
"div",
|
|
101
64
|
{
|
|
102
|
-
class:
|
|
103
|
-
"data-label":
|
|
104
|
-
"data-type":
|
|
105
|
-
id:
|
|
65
|
+
class: r,
|
|
66
|
+
"data-label": s,
|
|
67
|
+
"data-type": e,
|
|
68
|
+
id: Ye(s)
|
|
106
69
|
},
|
|
107
|
-
["div", { class: "footnote-definition_content" },
|
|
108
|
-
["div", { class: "footnote-definition_anchor" },
|
|
70
|
+
["div", { class: "footnote-definition_content" }, a, ["dd", 0]],
|
|
71
|
+
["div", { class: "footnote-definition_anchor" }, i]
|
|
109
72
|
];
|
|
110
73
|
},
|
|
111
74
|
parseMarkdown: {
|
|
112
|
-
match: ({ type }) =>
|
|
113
|
-
runner: (
|
|
114
|
-
|
|
115
|
-
label:
|
|
116
|
-
}).next(
|
|
75
|
+
match: ({ type: l }) => l === t,
|
|
76
|
+
runner: (l, s, r) => {
|
|
77
|
+
l.openNode(r, {
|
|
78
|
+
label: s.label
|
|
79
|
+
}).next(s.children).closeNode();
|
|
117
80
|
}
|
|
118
81
|
},
|
|
119
82
|
toMarkdown: {
|
|
120
|
-
match: (
|
|
121
|
-
runner: (
|
|
122
|
-
|
|
123
|
-
label:
|
|
124
|
-
identifier:
|
|
125
|
-
}).next(
|
|
83
|
+
match: (l) => l.type.name === e,
|
|
84
|
+
runner: (l, s) => {
|
|
85
|
+
l.openNode(t, void 0, {
|
|
86
|
+
label: s.attrs.label,
|
|
87
|
+
identifier: s.attrs.label
|
|
88
|
+
}).next(s.content).closeNode();
|
|
126
89
|
}
|
|
127
90
|
}
|
|
128
91
|
}),
|
|
129
|
-
commands: (
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
if (!
|
|
133
|
-
return
|
|
134
|
-
const { tr } =
|
|
135
|
-
|
|
136
|
-
dispatch == null ? void 0 : dispatch(_tr.setSelection(NodeSelection.create(_tr.doc, node.pos)));
|
|
137
|
-
return true;
|
|
92
|
+
commands: (n) => [
|
|
93
|
+
S(Le, (l = "") => (s, r) => {
|
|
94
|
+
const a = P(s.selection, n);
|
|
95
|
+
if (!a)
|
|
96
|
+
return !1;
|
|
97
|
+
const { tr: i } = s, c = i.setNodeMarkup(a.pos, void 0, { ...a.node.attrs, label: l });
|
|
98
|
+
return r == null || r(c.setSelection(te.create(c.doc, a.pos))), !0;
|
|
138
99
|
})
|
|
139
100
|
],
|
|
140
|
-
inputRules: (
|
|
141
|
-
|
|
142
|
-
var
|
|
143
|
-
const label = (_a = match[1]) != null ? _a : "footnote";
|
|
101
|
+
inputRules: (n) => [
|
|
102
|
+
Ve(/(?:\[\^)([^:]+)(?::)$/, n, (l) => {
|
|
103
|
+
var r;
|
|
144
104
|
return {
|
|
145
|
-
label
|
|
105
|
+
label: (r = l[1]) != null ? r : "footnote"
|
|
146
106
|
};
|
|
147
|
-
}, () =>
|
|
107
|
+
}, () => !1)
|
|
148
108
|
],
|
|
149
|
-
prosePlugins: (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
inputChipRenderer.init(editorView);
|
|
185
|
-
renderByView(editorView);
|
|
186
|
-
return {
|
|
187
|
-
update: (view, prevState) => {
|
|
188
|
-
const isEqualSelection = (prevState == null ? void 0 : prevState.doc.eq(view.state.doc)) && prevState.selection.eq(view.state.selection);
|
|
189
|
-
if (isEqualSelection)
|
|
190
|
-
return;
|
|
191
|
-
renderByView(view);
|
|
192
|
-
},
|
|
193
|
-
destroy: () => {
|
|
194
|
-
inputChipRenderer.destroy();
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
})
|
|
199
|
-
];
|
|
200
|
-
}
|
|
109
|
+
prosePlugins: (n, l) => [
|
|
110
|
+
new B({
|
|
111
|
+
key: It,
|
|
112
|
+
view: (s) => {
|
|
113
|
+
const r = o.themeManager.get("input-chip", {
|
|
114
|
+
width: "12em",
|
|
115
|
+
placeholder: "Input Footnote Label",
|
|
116
|
+
onUpdate: (d) => {
|
|
117
|
+
l.get(Ze).call(Le, d);
|
|
118
|
+
},
|
|
119
|
+
isBindMode: !0
|
|
120
|
+
});
|
|
121
|
+
if (!r)
|
|
122
|
+
return {};
|
|
123
|
+
const a = (d) => Boolean(n && P(d.state.selection, n)), i = (d) => {
|
|
124
|
+
const u = P(d.state.selection, n);
|
|
125
|
+
return u ? u.node.attrs.label : void 0;
|
|
126
|
+
}, c = (d) => {
|
|
127
|
+
if (!d.editable)
|
|
128
|
+
return;
|
|
129
|
+
a(d) ? (r.show(d), r.update(i(d))) : r.hide();
|
|
130
|
+
};
|
|
131
|
+
return r.init(s), c(s), {
|
|
132
|
+
update: (d, u) => {
|
|
133
|
+
(u == null ? void 0 : u.doc.eq(d.state.doc)) && u.selection.eq(d.state.selection) || c(d);
|
|
134
|
+
},
|
|
135
|
+
destroy: () => {
|
|
136
|
+
r.destroy();
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
]
|
|
201
142
|
};
|
|
202
|
-
})
|
|
203
|
-
const
|
|
204
|
-
const key$1 = new PluginKey("MILKDOWN_FOOTNOTE_REF_INPUT");
|
|
205
|
-
const footnoteReference = createNode((utils) => {
|
|
206
|
-
const id2 = "footnote_reference";
|
|
143
|
+
}), ve = x("ModifyFootnoteRef"), Dt = new O("MILKDOWN_FOOTNOTE_REF_INPUT"), _t = be((o) => {
|
|
144
|
+
const e = "footnote_reference";
|
|
207
145
|
return {
|
|
208
|
-
id:
|
|
209
|
-
schema: (
|
|
146
|
+
id: e,
|
|
147
|
+
schema: (t) => ({
|
|
210
148
|
group: "inline",
|
|
211
|
-
inline:
|
|
212
|
-
atom:
|
|
149
|
+
inline: !0,
|
|
150
|
+
atom: !0,
|
|
213
151
|
attrs: {
|
|
214
152
|
label: {
|
|
215
153
|
default: ""
|
|
@@ -217,521 +155,396 @@ const footnoteReference = createNode((utils) => {
|
|
|
217
155
|
},
|
|
218
156
|
parseDOM: [
|
|
219
157
|
{
|
|
220
|
-
tag: `sup[data-type="${
|
|
221
|
-
getAttrs: (
|
|
222
|
-
if (!(
|
|
223
|
-
throw
|
|
224
|
-
}
|
|
158
|
+
tag: `sup[data-type="${e}"]`,
|
|
159
|
+
getAttrs: (n) => {
|
|
160
|
+
if (!(n instanceof HTMLElement))
|
|
161
|
+
throw ye(n);
|
|
225
162
|
return {
|
|
226
|
-
label:
|
|
163
|
+
label: n.dataset.label
|
|
227
164
|
};
|
|
228
165
|
}
|
|
229
166
|
}
|
|
230
167
|
],
|
|
231
|
-
toDOM: (
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const view = ctx.get(editorViewCtx);
|
|
239
|
-
if (view.editable) {
|
|
240
|
-
e.preventDefault();
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
a.ondblclick = () => {
|
|
244
|
-
const view = ctx.get(editorViewCtx);
|
|
245
|
-
if (view.editable) {
|
|
246
|
-
window.location.href = href;
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
return [
|
|
168
|
+
toDOM: (n) => {
|
|
169
|
+
const l = n.attrs.label, s = document.createElement("a"), r = `#${Ye(l)}`;
|
|
170
|
+
return s.href = r, s.textContent = `[${l}]`, s.onclick = (a) => {
|
|
171
|
+
t.get(ee).editable && a.preventDefault();
|
|
172
|
+
}, s.ondblclick = () => {
|
|
173
|
+
t.get(ee).editable && (window.location.href = r);
|
|
174
|
+
}, [
|
|
250
175
|
"sup",
|
|
251
176
|
{
|
|
252
|
-
"data-label":
|
|
253
|
-
"data-type":
|
|
254
|
-
id:
|
|
177
|
+
"data-label": l,
|
|
178
|
+
"data-type": e,
|
|
179
|
+
id: Je(l)
|
|
255
180
|
},
|
|
256
|
-
|
|
181
|
+
s
|
|
257
182
|
];
|
|
258
183
|
},
|
|
259
184
|
parseMarkdown: {
|
|
260
|
-
match: ({ type }) =>
|
|
261
|
-
runner: (
|
|
262
|
-
|
|
263
|
-
label:
|
|
185
|
+
match: ({ type: n }) => n === "footnoteReference",
|
|
186
|
+
runner: (n, l, s) => {
|
|
187
|
+
n.addNode(s, {
|
|
188
|
+
label: l.label
|
|
264
189
|
});
|
|
265
190
|
}
|
|
266
191
|
},
|
|
267
192
|
toMarkdown: {
|
|
268
|
-
match: (
|
|
269
|
-
runner: (
|
|
270
|
-
|
|
271
|
-
label:
|
|
272
|
-
identifier:
|
|
193
|
+
match: (n) => n.type.name === e,
|
|
194
|
+
runner: (n, l) => {
|
|
195
|
+
n.addNode("footnoteReference", void 0, void 0, {
|
|
196
|
+
label: l.attrs.label,
|
|
197
|
+
identifier: l.attrs.label
|
|
273
198
|
});
|
|
274
199
|
}
|
|
275
200
|
}
|
|
276
201
|
}),
|
|
277
|
-
commands: (
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
if (!
|
|
281
|
-
return
|
|
282
|
-
const { tr } =
|
|
283
|
-
|
|
284
|
-
dispatch == null ? void 0 : dispatch(_tr.setSelection(NodeSelection.create(_tr.doc, node.pos)));
|
|
285
|
-
return true;
|
|
202
|
+
commands: (t) => [
|
|
203
|
+
S(ve, (n = "") => (l, s) => {
|
|
204
|
+
const r = P(l.selection, t);
|
|
205
|
+
if (!r)
|
|
206
|
+
return !1;
|
|
207
|
+
const { tr: a } = l, i = a.setNodeMarkup(r.pos, void 0, { ...r.node.attrs, label: n });
|
|
208
|
+
return s == null || s(i.setSelection(te.create(i.doc, r.pos))), !0;
|
|
286
209
|
})
|
|
287
210
|
],
|
|
288
|
-
inputRules: (
|
|
289
|
-
new
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
const $end = state.doc.resolve(end);
|
|
293
|
-
if (!$start.parent.canReplaceWith(index, $end.index(), nodeType)) {
|
|
211
|
+
inputRules: (t) => [
|
|
212
|
+
new Ce(/(?:\[\^)([^\]]+)(?:\])$/, (n, l, s, r) => {
|
|
213
|
+
const a = n.doc.resolve(s), i = a.index(), c = n.doc.resolve(r);
|
|
214
|
+
if (!a.parent.canReplaceWith(i, c.index(), t))
|
|
294
215
|
return null;
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
label
|
|
216
|
+
const d = l[1];
|
|
217
|
+
return n.tr.replaceRangeWith(s, r, t.create({
|
|
218
|
+
label: d
|
|
299
219
|
}));
|
|
300
220
|
})
|
|
301
221
|
],
|
|
302
|
-
prosePlugins: (
|
|
303
|
-
const
|
|
222
|
+
prosePlugins: (t, n) => {
|
|
223
|
+
const l = o.themeManager.get("input-chip", {
|
|
304
224
|
width: "12em",
|
|
305
225
|
placeholder: "Input Footnote Label",
|
|
306
|
-
onUpdate: (
|
|
307
|
-
|
|
226
|
+
onUpdate: (i) => {
|
|
227
|
+
n.get(Ze).call(ve, i);
|
|
308
228
|
},
|
|
309
|
-
isBindMode:
|
|
229
|
+
isBindMode: !0
|
|
310
230
|
});
|
|
311
|
-
if (!
|
|
231
|
+
if (!l)
|
|
312
232
|
return [];
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
233
|
+
const s = (i) => Boolean(t && P(i.state.selection, t)), r = (i) => {
|
|
234
|
+
const c = P(i.state.selection, t);
|
|
235
|
+
return c ? c.node.attrs.label : void 0;
|
|
236
|
+
}, a = (i) => {
|
|
237
|
+
if (!i.editable)
|
|
317
238
|
return;
|
|
318
|
-
|
|
319
|
-
return value;
|
|
320
|
-
};
|
|
321
|
-
const renderByView = (view) => {
|
|
322
|
-
if (!view.editable) {
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
const display = shouldDisplay(view);
|
|
326
|
-
if (display) {
|
|
327
|
-
inputChipRenderer.show(view);
|
|
328
|
-
inputChipRenderer.update(getCurrentLabel(view));
|
|
329
|
-
} else {
|
|
330
|
-
inputChipRenderer.hide();
|
|
331
|
-
}
|
|
239
|
+
s(i) ? (l.show(i), l.update(r(i))) : l.hide();
|
|
332
240
|
};
|
|
333
241
|
return [
|
|
334
|
-
new
|
|
335
|
-
key:
|
|
336
|
-
view: (
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
renderByView(view);
|
|
345
|
-
},
|
|
346
|
-
destroy: () => {
|
|
347
|
-
inputChipRenderer.destroy();
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
}
|
|
242
|
+
new B({
|
|
243
|
+
key: Dt,
|
|
244
|
+
view: (i) => (l.init(i), a(i), {
|
|
245
|
+
update: (c, d) => {
|
|
246
|
+
(d == null ? void 0 : d.doc.eq(c.state.doc)) && d.selection.eq(c.state.selection) || a(c);
|
|
247
|
+
},
|
|
248
|
+
destroy: () => {
|
|
249
|
+
l.destroy();
|
|
250
|
+
}
|
|
251
|
+
})
|
|
351
252
|
})
|
|
352
253
|
];
|
|
353
254
|
}
|
|
354
255
|
};
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
cache.set(key2, value);
|
|
360
|
-
return value;
|
|
361
|
-
};
|
|
362
|
-
class Rect {
|
|
363
|
-
constructor(left, top, right, bottom) {
|
|
364
|
-
this.left = left;
|
|
365
|
-
this.top = top;
|
|
366
|
-
this.right = right;
|
|
367
|
-
this.bottom = bottom;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
class TableMap {
|
|
371
|
-
constructor(width, height, map, problems) {
|
|
372
|
-
this.width = width;
|
|
373
|
-
this.height = height;
|
|
374
|
-
this.map = map;
|
|
375
|
-
this.problems = problems;
|
|
376
|
-
this.width = width;
|
|
377
|
-
this.height = height;
|
|
378
|
-
this.map = map;
|
|
379
|
-
this.problems = problems;
|
|
380
|
-
}
|
|
381
|
-
findCell(pos) {
|
|
382
|
-
for (let i = 0; i < this.map.length; i++) {
|
|
383
|
-
const curPos = this.map[i];
|
|
384
|
-
if (curPos != pos)
|
|
385
|
-
continue;
|
|
386
|
-
const left = i % this.width, top = i / this.width | 0;
|
|
387
|
-
let right = left + 1, bottom = top + 1;
|
|
388
|
-
for (let j = 1; right < this.width && this.map[i + j] == curPos; j++)
|
|
389
|
-
right++;
|
|
390
|
-
for (let j = 1; bottom < this.height && this.map[i + this.width * j] == curPos; j++)
|
|
391
|
-
bottom++;
|
|
392
|
-
return new Rect(left, top, right, bottom);
|
|
393
|
-
}
|
|
394
|
-
throw new RangeError("No cell with offset " + pos + " found");
|
|
395
|
-
}
|
|
396
|
-
colCount(pos) {
|
|
397
|
-
for (let i = 0; i < this.map.length; i++)
|
|
398
|
-
if (this.map[i] == pos)
|
|
399
|
-
return i % this.width;
|
|
400
|
-
throw new RangeError("No cell with offset " + pos + " found");
|
|
401
|
-
}
|
|
402
|
-
nextCell(pos, axis, dir) {
|
|
403
|
-
const { left, right, top, bottom } = this.findCell(pos);
|
|
404
|
-
if (axis == "horiz") {
|
|
405
|
-
if (dir < 0 ? left == 0 : right == this.width)
|
|
406
|
-
return void 0;
|
|
407
|
-
return this.map[top * this.width + (dir < 0 ? left - 1 : right)];
|
|
408
|
-
} else {
|
|
409
|
-
if (dir < 0 ? top == 0 : bottom == this.height)
|
|
410
|
-
return void 0;
|
|
411
|
-
return this.map[left + this.width * (dir < 0 ? top - 1 : bottom)];
|
|
412
|
-
}
|
|
256
|
+
}), Qe = /* @__PURE__ */ new WeakMap(), Ot = (o) => Qe.get(o), zt = (o, e) => (Qe.set(o, e), e);
|
|
257
|
+
class Ee {
|
|
258
|
+
constructor(e, t, n, l) {
|
|
259
|
+
this.left = e, this.top = t, this.right = n, this.bottom = l;
|
|
413
260
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
261
|
+
}
|
|
262
|
+
class g {
|
|
263
|
+
constructor(e, t, n, l) {
|
|
264
|
+
this.width = e, this.height = t, this.map = n, this.problems = l, this.width = e, this.height = t, this.map = n, this.problems = l;
|
|
265
|
+
}
|
|
266
|
+
findCell(e) {
|
|
267
|
+
for (let t = 0; t < this.map.length; t++) {
|
|
268
|
+
const n = this.map[t];
|
|
269
|
+
if (n != e)
|
|
270
|
+
continue;
|
|
271
|
+
const l = t % this.width, s = t / this.width | 0;
|
|
272
|
+
let r = l + 1, a = s + 1;
|
|
273
|
+
for (let i = 1; r < this.width && this.map[t + i] == n; i++)
|
|
274
|
+
r++;
|
|
275
|
+
for (let i = 1; a < this.height && this.map[t + this.width * i] == n; i++)
|
|
276
|
+
a++;
|
|
277
|
+
return new Ee(l, s, r, a);
|
|
278
|
+
}
|
|
279
|
+
throw new RangeError("No cell with offset " + e + " found");
|
|
280
|
+
}
|
|
281
|
+
colCount(e) {
|
|
282
|
+
for (let t = 0; t < this.map.length; t++)
|
|
283
|
+
if (this.map[t] == e)
|
|
284
|
+
return t % this.width;
|
|
285
|
+
throw new RangeError("No cell with offset " + e + " found");
|
|
286
|
+
}
|
|
287
|
+
nextCell(e, t, n) {
|
|
288
|
+
const { left: l, right: s, top: r, bottom: a } = this.findCell(e);
|
|
289
|
+
return t == "horiz" ? (n < 0 ? l == 0 : s == this.width) ? void 0 : this.map[r * this.width + (n < 0 ? l - 1 : s)] : (n < 0 ? r == 0 : a == this.height) ? void 0 : this.map[l + this.width * (n < 0 ? r - 1 : a)];
|
|
290
|
+
}
|
|
291
|
+
rectBetween(e, t) {
|
|
292
|
+
const { left: n, right: l, top: s, bottom: r } = this.findCell(e), { left: a, right: i, top: c, bottom: d } = this.findCell(t);
|
|
293
|
+
return new Ee(Math.min(n, a), Math.min(s, c), Math.max(l, i), Math.max(r, d));
|
|
294
|
+
}
|
|
295
|
+
cellsInRect(e) {
|
|
296
|
+
const t = [], n = {};
|
|
297
|
+
for (let l = e.top; l < e.bottom; l++)
|
|
298
|
+
for (let s = e.left; s < e.right; s++) {
|
|
299
|
+
const r = l * this.width + s, a = this.map[r];
|
|
300
|
+
n[a] || (n[a] = !0, (s != e.left || !s || this.map[r - 1] != a) && (l != e.top || !l || this.map[r - this.width] != a) && t.push(a));
|
|
429
301
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
return index == rowEndIndex ? rowEnd - 1 : this.map[index];
|
|
302
|
+
return t;
|
|
303
|
+
}
|
|
304
|
+
positionAt(e, t, n) {
|
|
305
|
+
for (let l = 0, s = 0; ; l++) {
|
|
306
|
+
const r = s + n.child(l).nodeSize;
|
|
307
|
+
if (l == e) {
|
|
308
|
+
let a = t + e * this.width;
|
|
309
|
+
const i = (e + 1) * this.width;
|
|
310
|
+
for (; a < i && this.map[a] < s; )
|
|
311
|
+
a++;
|
|
312
|
+
return a == i ? r - 1 : this.map[a];
|
|
442
313
|
}
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
static get(
|
|
447
|
-
return
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
function
|
|
451
|
-
if (
|
|
452
|
-
throw new RangeError("Not a table node: " +
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
for (let
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
mapPos++;
|
|
465
|
-
if (i == rowNode.childCount)
|
|
314
|
+
s = r;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
static get(e) {
|
|
318
|
+
return Ot(e) || zt(e, Ft(e));
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function Ft(o) {
|
|
322
|
+
if (o.type.spec.tableRole != "table")
|
|
323
|
+
throw new RangeError("Not a table node: " + o.type.name);
|
|
324
|
+
const e = Bt(o), t = o.childCount, n = [], l = [];
|
|
325
|
+
let s = 0, r;
|
|
326
|
+
for (let c = 0, d = e * t; c < d; c++)
|
|
327
|
+
n[c] = 0;
|
|
328
|
+
for (let c = 0, d = 0; c < t; c++) {
|
|
329
|
+
const u = o.child(c);
|
|
330
|
+
d++;
|
|
331
|
+
for (let h = 0; ; h++) {
|
|
332
|
+
for (; s < n.length && n[s] != 0; )
|
|
333
|
+
s++;
|
|
334
|
+
if (h == u.childCount)
|
|
466
335
|
break;
|
|
467
|
-
const
|
|
468
|
-
for (let
|
|
469
|
-
if (
|
|
470
|
-
(
|
|
336
|
+
const b = u.child(h), { colspan: w, rowspan: C, colwidth: Se } = b.attrs;
|
|
337
|
+
for (let H = 0; H < C; H++) {
|
|
338
|
+
if (H + c >= t) {
|
|
339
|
+
(r || (r = [])).push({
|
|
471
340
|
type: "overlong_rowspan",
|
|
472
|
-
pos,
|
|
473
|
-
n:
|
|
341
|
+
pos: d,
|
|
342
|
+
n: C - H
|
|
474
343
|
});
|
|
475
344
|
break;
|
|
476
345
|
}
|
|
477
|
-
const
|
|
478
|
-
for (let
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
if (colW) {
|
|
490
|
-
const widthIndex = (start + w) % width * 2, prev = colWidths[widthIndex];
|
|
491
|
-
if (prev == null || prev != colW && colWidths[widthIndex + 1] == 1) {
|
|
492
|
-
colWidths[widthIndex] = colW;
|
|
493
|
-
colWidths[widthIndex + 1] = 1;
|
|
494
|
-
} else if (prev == colW) {
|
|
495
|
-
colWidths[widthIndex + 1]++;
|
|
496
|
-
}
|
|
346
|
+
const le = s + H * e;
|
|
347
|
+
for (let z = 0; z < w; z++) {
|
|
348
|
+
n[le + z] == 0 ? n[le + z] = d : (r || (r = [])).push({
|
|
349
|
+
type: "collision",
|
|
350
|
+
row: c,
|
|
351
|
+
pos: d,
|
|
352
|
+
n: w - z
|
|
353
|
+
});
|
|
354
|
+
const X = Se && Se[z];
|
|
355
|
+
if (X) {
|
|
356
|
+
const j = (le + z) % e * 2, se = l[j];
|
|
357
|
+
se == null || se != X && l[j + 1] == 1 ? (l[j] = X, l[j + 1] = 1) : se == X && l[j + 1]++;
|
|
497
358
|
}
|
|
498
359
|
}
|
|
499
360
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
let rowWidth = 0;
|
|
526
|
-
if (hasRowSpan)
|
|
527
|
-
for (let j = 0; j < row; j++) {
|
|
528
|
-
const prevRow = table2.child(j);
|
|
529
|
-
for (let i = 0; i < prevRow.childCount; i++) {
|
|
530
|
-
const cell = prevRow.child(i);
|
|
531
|
-
if (j + cell.attrs["rowspan"] > row)
|
|
532
|
-
rowWidth += cell.attrs["colspan"];
|
|
361
|
+
s += w, d += b.nodeSize;
|
|
362
|
+
}
|
|
363
|
+
const f = (c + 1) * e;
|
|
364
|
+
let p = 0;
|
|
365
|
+
for (; s < f; )
|
|
366
|
+
n[s++] == 0 && p++;
|
|
367
|
+
p && (r || (r = [])).push({ type: "missing", row: c, n: p }), d++;
|
|
368
|
+
}
|
|
369
|
+
const a = new g(e, t, n, r);
|
|
370
|
+
let i = !1;
|
|
371
|
+
for (let c = 0; !i && c < l.length; c += 2)
|
|
372
|
+
l[c] != null && l[c + 1] < t && (i = !0);
|
|
373
|
+
return i && Pt(a, l, o), a;
|
|
374
|
+
}
|
|
375
|
+
function Bt(o) {
|
|
376
|
+
let e = -1, t = !1;
|
|
377
|
+
for (let n = 0; n < o.childCount; n++) {
|
|
378
|
+
const l = o.child(n);
|
|
379
|
+
let s = 0;
|
|
380
|
+
if (t)
|
|
381
|
+
for (let r = 0; r < n; r++) {
|
|
382
|
+
const a = o.child(r);
|
|
383
|
+
for (let i = 0; i < a.childCount; i++) {
|
|
384
|
+
const c = a.child(i);
|
|
385
|
+
r + c.attrs.rowspan > n && (s += c.attrs.colspan);
|
|
533
386
|
}
|
|
534
387
|
}
|
|
535
|
-
for (let
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
if (cell.attrs["rowspan"] > 1)
|
|
539
|
-
hasRowSpan = true;
|
|
388
|
+
for (let r = 0; r < l.childCount; r++) {
|
|
389
|
+
const a = l.child(r);
|
|
390
|
+
s += a.attrs.colspan, a.attrs.rowspan > 1 && (t = !0);
|
|
540
391
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
map.problems = [];
|
|
551
|
-
for (let i = 0, seen = {}; i < map.map.length; i++) {
|
|
552
|
-
const pos = map.map[i];
|
|
553
|
-
if (seen[pos])
|
|
392
|
+
e == -1 ? e = s : e != s && (e = Math.max(e, s));
|
|
393
|
+
}
|
|
394
|
+
return e;
|
|
395
|
+
}
|
|
396
|
+
function Pt(o, e, t) {
|
|
397
|
+
o.problems || (o.problems = []);
|
|
398
|
+
for (let n = 0, l = {}; n < o.map.length; n++) {
|
|
399
|
+
const s = o.map[n];
|
|
400
|
+
if (l[s])
|
|
554
401
|
continue;
|
|
555
|
-
|
|
556
|
-
const
|
|
557
|
-
let
|
|
558
|
-
for (let
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
colwidth: updated
|
|
568
|
-
});
|
|
402
|
+
l[s] = !0;
|
|
403
|
+
const r = t.nodeAt(s);
|
|
404
|
+
let a = null;
|
|
405
|
+
for (let i = 0; i < r.attrs.colspan; i++) {
|
|
406
|
+
const c = (n + i) % o.width, d = e[c * 2];
|
|
407
|
+
d != null && (!r.attrs.colwidth || r.attrs.colwidth[i] != d) && ((a || (a = Wt(r.attrs)))[i] = d);
|
|
408
|
+
}
|
|
409
|
+
a && o.problems.unshift({
|
|
410
|
+
type: "colwidth mismatch",
|
|
411
|
+
pos: s,
|
|
412
|
+
colwidth: a
|
|
413
|
+
});
|
|
569
414
|
}
|
|
570
415
|
}
|
|
571
|
-
function
|
|
572
|
-
if (
|
|
573
|
-
return
|
|
574
|
-
const
|
|
575
|
-
for (let
|
|
576
|
-
|
|
577
|
-
return
|
|
578
|
-
}
|
|
579
|
-
class
|
|
580
|
-
constructor(
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
const
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
const ranges = cells.map((pos) => {
|
|
587
|
-
const cell = table2.nodeAt(pos), from = pos + start + 1;
|
|
588
|
-
return new SelectionRange(doc2.resolve(from), doc2.resolve(from + cell.content.size));
|
|
416
|
+
function Wt(o) {
|
|
417
|
+
if (o.colwidth)
|
|
418
|
+
return o.colwidth.slice();
|
|
419
|
+
const e = [];
|
|
420
|
+
for (let t = 0; t < o.colspan; t++)
|
|
421
|
+
e.push(0);
|
|
422
|
+
return e;
|
|
423
|
+
}
|
|
424
|
+
class m extends N {
|
|
425
|
+
constructor(e, t = e) {
|
|
426
|
+
const n = e.node(-1), l = g.get(n), s = e.start(-1), r = l.rectBetween(e.pos - s, t.pos - s), a = e.node(0), i = l.cellsInRect(r).filter((d) => d != t.pos - s);
|
|
427
|
+
i.unshift(t.pos - s);
|
|
428
|
+
const c = i.map((d) => {
|
|
429
|
+
const u = n.nodeAt(d), f = d + s + 1;
|
|
430
|
+
return new kt(a.resolve(f), a.resolve(f + u.content.size));
|
|
589
431
|
});
|
|
590
|
-
super(
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
this.$anchorCell =
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
const $anchorCell = doc2.resolve(mapping.map(this.$anchorCell.pos));
|
|
598
|
-
const $headCell = doc2.resolve(mapping.map(this.$headCell.pos));
|
|
599
|
-
if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {
|
|
600
|
-
const tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);
|
|
601
|
-
if (tableChanged && this.isRowSelection())
|
|
602
|
-
return CellSelection.rowSelection($anchorCell, $headCell);
|
|
603
|
-
else if (tableChanged && this.isColSelection())
|
|
604
|
-
return CellSelection.colSelection($anchorCell, $headCell);
|
|
605
|
-
else
|
|
606
|
-
return new CellSelection($anchorCell, $headCell);
|
|
432
|
+
super(c[0].$from, c[0].$to, c), this.$anchorCell = e, this.$headCell = t, this.$anchorCell = e, this.$headCell = t;
|
|
433
|
+
}
|
|
434
|
+
map(e, t) {
|
|
435
|
+
const n = e.resolve(t.map(this.$anchorCell.pos)), l = e.resolve(t.map(this.$headCell.pos));
|
|
436
|
+
if (de(n) && de(l) && Ne(n, l)) {
|
|
437
|
+
const s = this.$anchorCell.node(-1) != n.node(-1);
|
|
438
|
+
return s && this.isRowSelection() ? m.rowSelection(n, l) : s && this.isColSelection() ? m.colSelection(n, l) : new m(n, l);
|
|
607
439
|
}
|
|
608
|
-
return
|
|
440
|
+
return D.between(n, l);
|
|
609
441
|
}
|
|
610
442
|
content() {
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
let attrs = cell.attrs;
|
|
625
|
-
if (extraLeft > 0)
|
|
626
|
-
attrs = removeColSpan(attrs, 0, extraLeft);
|
|
627
|
-
if (extraRight > 0)
|
|
628
|
-
attrs = removeColSpan(attrs, attrs["colspan"] - extraRight, extraRight);
|
|
629
|
-
if (cellRect.left < rect.left)
|
|
630
|
-
cell = cell.type.createAndFill(attrs);
|
|
631
|
-
else
|
|
632
|
-
cell = cell.type.create(attrs, cell.content);
|
|
443
|
+
const e = this.$anchorCell.node(-1), t = g.get(e), n = this.$anchorCell.start(-1), l = t.rectBetween(this.$anchorCell.pos - n, this.$headCell.pos - n), s = {}, r = [];
|
|
444
|
+
for (let i = l.top; i < l.bottom; i++) {
|
|
445
|
+
const c = [];
|
|
446
|
+
for (let d = i * t.width + l.left, u = l.left; u < l.right; u++, d++) {
|
|
447
|
+
const f = t.map[d];
|
|
448
|
+
if (!s[f]) {
|
|
449
|
+
s[f] = !0;
|
|
450
|
+
const p = t.findCell(f);
|
|
451
|
+
let h = e.nodeAt(f);
|
|
452
|
+
const b = l.left - p.left, w = p.right - l.right;
|
|
453
|
+
if (b > 0 || w > 0) {
|
|
454
|
+
let C = h.attrs;
|
|
455
|
+
b > 0 && (C = F(C, 0, b)), w > 0 && (C = F(C, C.colspan - w, w)), p.left < l.left ? h = h.type.createAndFill(C) : h = h.type.create(C, h.content);
|
|
633
456
|
}
|
|
634
|
-
if (
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
cell = cell.type.createAndFill(attrs);
|
|
638
|
-
else
|
|
639
|
-
cell = cell.type.create(attrs, cell.content);
|
|
457
|
+
if (p.top < l.top || p.bottom > l.bottom) {
|
|
458
|
+
const C = y(h.attrs, "rowspan", Math.min(p.bottom, l.bottom) - Math.max(p.top, l.top));
|
|
459
|
+
p.top < l.top ? h = h.type.createAndFill(C) : h = h.type.create(C, h.content);
|
|
640
460
|
}
|
|
641
|
-
|
|
461
|
+
c.push(h);
|
|
642
462
|
}
|
|
643
463
|
}
|
|
644
|
-
|
|
464
|
+
r.push(e.child(i).copy(E.from(c)));
|
|
645
465
|
}
|
|
646
|
-
const
|
|
647
|
-
return new
|
|
648
|
-
}
|
|
649
|
-
replace(
|
|
650
|
-
const
|
|
651
|
-
for (let
|
|
652
|
-
const { $from, $to } =
|
|
653
|
-
|
|
466
|
+
const a = this.isColSelection() && this.isRowSelection() ? e : r;
|
|
467
|
+
return new _(E.from(a), 1, 1);
|
|
468
|
+
}
|
|
469
|
+
replace(e, t = _.empty) {
|
|
470
|
+
const n = e.steps.length, l = this.ranges;
|
|
471
|
+
for (let r = 0; r < l.length; r++) {
|
|
472
|
+
const { $from: a, $to: i } = l[r], c = e.mapping.slice(n);
|
|
473
|
+
e.replace(c.map(a.pos), c.map(i.pos), r ? _.empty : t);
|
|
654
474
|
}
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
tr.setSelection(sel);
|
|
475
|
+
const s = N.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)), -1);
|
|
476
|
+
s && e.setSelection(s);
|
|
658
477
|
}
|
|
659
|
-
replaceWith(
|
|
660
|
-
this.replace(
|
|
478
|
+
replaceWith(e, t) {
|
|
479
|
+
this.replace(e, new _(E.from(t), 0, 0));
|
|
661
480
|
}
|
|
662
|
-
forEachCell(
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
f(table2.nodeAt(cells[i]), start + cells[i]);
|
|
481
|
+
forEachCell(e) {
|
|
482
|
+
const t = this.$anchorCell.node(-1), n = g.get(t), l = this.$anchorCell.start(-1), s = n.cellsInRect(n.rectBetween(this.$anchorCell.pos - l, this.$headCell.pos - l));
|
|
483
|
+
for (let r = 0; r < s.length; r++)
|
|
484
|
+
e(t.nodeAt(s[r]), l + s[r]);
|
|
667
485
|
}
|
|
668
486
|
isColSelection() {
|
|
669
|
-
const
|
|
670
|
-
if (Math.min(
|
|
671
|
-
return
|
|
672
|
-
const
|
|
673
|
-
return Math.max(
|
|
674
|
-
}
|
|
675
|
-
static colSelection(
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
const left = map.map[anchorRect.left];
|
|
682
|
-
$anchorCell = doc2.resolve(start + left);
|
|
487
|
+
const e = this.$anchorCell.index(-1), t = this.$headCell.index(-1);
|
|
488
|
+
if (Math.min(e, t) > 0)
|
|
489
|
+
return !1;
|
|
490
|
+
const n = e + this.$anchorCell.nodeAfter.attrs.rowspan, l = t + this.$headCell.nodeAfter.attrs.rowspan;
|
|
491
|
+
return Math.max(n, l) == this.$headCell.node(-1).childCount;
|
|
492
|
+
}
|
|
493
|
+
static colSelection(e, t = e) {
|
|
494
|
+
const n = g.get(e.node(-1)), l = e.start(-1), s = n.findCell(e.pos - l), r = n.findCell(t.pos - l), a = e.node(0);
|
|
495
|
+
if (s.top <= r.top) {
|
|
496
|
+
if (s.top > 0) {
|
|
497
|
+
const i = n.map[s.left];
|
|
498
|
+
e = a.resolve(l + i);
|
|
683
499
|
}
|
|
684
|
-
if (
|
|
685
|
-
const
|
|
686
|
-
|
|
500
|
+
if (r.bottom < n.height) {
|
|
501
|
+
const i = n.map[n.width * (n.height - 1) + r.right - 1];
|
|
502
|
+
t = a.resolve(l + i);
|
|
687
503
|
}
|
|
688
504
|
} else {
|
|
689
|
-
if (
|
|
690
|
-
const
|
|
691
|
-
|
|
505
|
+
if (r.top > 0) {
|
|
506
|
+
const i = n.map[s.left];
|
|
507
|
+
t = a.resolve(l + i);
|
|
692
508
|
}
|
|
693
|
-
if (
|
|
694
|
-
const
|
|
695
|
-
|
|
509
|
+
if (s.bottom < n.height) {
|
|
510
|
+
const i = n.map[n.width * (n.height - 1) + s.right - 1];
|
|
511
|
+
e = a.resolve(l + i);
|
|
696
512
|
}
|
|
697
513
|
}
|
|
698
|
-
return new
|
|
514
|
+
return new m(e, t);
|
|
699
515
|
}
|
|
700
516
|
isRowSelection() {
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
if (anchorRect.left > 0) {
|
|
717
|
-
const pos = map.map[anchorRect.top * map.width];
|
|
718
|
-
$anchorCell = doc2.resolve(start + pos);
|
|
517
|
+
const e = g.get(this.$anchorCell.node(-1)), t = this.$anchorCell.start(-1), n = e.colCount(this.$anchorCell.pos - t), l = e.colCount(this.$headCell.pos - t);
|
|
518
|
+
if (Math.min(n, l) > 0)
|
|
519
|
+
return !1;
|
|
520
|
+
const s = n + this.$anchorCell.nodeAfter.attrs.colspan, r = l + this.$headCell.nodeAfter.attrs.colspan;
|
|
521
|
+
return Math.max(s, r) == e.width;
|
|
522
|
+
}
|
|
523
|
+
eq(e) {
|
|
524
|
+
return e instanceof m && e.$anchorCell.pos == this.$anchorCell.pos && e.$headCell.pos == this.$headCell.pos;
|
|
525
|
+
}
|
|
526
|
+
static rowSelection(e, t = e) {
|
|
527
|
+
const n = g.get(e.node(-1)), l = e.start(-1), s = n.findCell(e.pos - l), r = n.findCell(t.pos - l), a = e.node(0);
|
|
528
|
+
if (s.left <= r.left) {
|
|
529
|
+
if (s.left > 0) {
|
|
530
|
+
const i = n.map[s.top * n.width];
|
|
531
|
+
e = a.resolve(l + i);
|
|
719
532
|
}
|
|
720
|
-
if (
|
|
721
|
-
const
|
|
722
|
-
|
|
533
|
+
if (r.right < n.width) {
|
|
534
|
+
const i = n.map[n.width * (r.top + 1) - 1];
|
|
535
|
+
t = a.resolve(l + i);
|
|
723
536
|
}
|
|
724
537
|
} else {
|
|
725
|
-
if (
|
|
726
|
-
const
|
|
727
|
-
|
|
538
|
+
if (r.left > 0) {
|
|
539
|
+
const i = n.map[r.top * n.width];
|
|
540
|
+
t = a.resolve(l + i);
|
|
728
541
|
}
|
|
729
|
-
if (
|
|
730
|
-
const
|
|
731
|
-
|
|
542
|
+
if (s.right < n.width) {
|
|
543
|
+
const i = n.map[n.width * (s.top + 1) - 1];
|
|
544
|
+
e = a.resolve(l + i);
|
|
732
545
|
}
|
|
733
546
|
}
|
|
734
|
-
return new
|
|
547
|
+
return new m(e, t);
|
|
735
548
|
}
|
|
736
549
|
toJSON() {
|
|
737
550
|
return {
|
|
@@ -740,148 +553,119 @@ class CellSelection extends Selection {
|
|
|
740
553
|
head: this.$headCell.pos
|
|
741
554
|
};
|
|
742
555
|
}
|
|
743
|
-
static fromJSON(
|
|
744
|
-
return new
|
|
556
|
+
static fromJSON(e, t) {
|
|
557
|
+
return new m(e.resolve(t.anchor), e.resolve(t.head));
|
|
745
558
|
}
|
|
746
|
-
static create(
|
|
747
|
-
return new
|
|
559
|
+
static create(e, t, n = t) {
|
|
560
|
+
return new m(e.resolve(t), e.resolve(n));
|
|
748
561
|
}
|
|
749
562
|
getBookmark() {
|
|
750
|
-
return new
|
|
563
|
+
return new Me(this.$anchorCell.pos, this.$headCell.pos);
|
|
751
564
|
}
|
|
752
565
|
}
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
class
|
|
756
|
-
constructor(
|
|
757
|
-
this.anchor = anchor;
|
|
758
|
-
this.head = head;
|
|
759
|
-
this.anchor = anchor;
|
|
760
|
-
this.head = head;
|
|
566
|
+
m.prototype.visible = !1;
|
|
567
|
+
N.jsonID("cell", m);
|
|
568
|
+
class Me {
|
|
569
|
+
constructor(e, t) {
|
|
570
|
+
this.anchor = e, this.head = t, this.anchor = e, this.head = t;
|
|
761
571
|
}
|
|
762
|
-
map(
|
|
763
|
-
return new
|
|
572
|
+
map(e) {
|
|
573
|
+
return new Me(e.map(this.anchor), e.map(this.head));
|
|
764
574
|
}
|
|
765
|
-
resolve(
|
|
766
|
-
const
|
|
767
|
-
|
|
768
|
-
return new CellSelection($anchorCell, $headCell);
|
|
769
|
-
else
|
|
770
|
-
return Selection.near($headCell, 1);
|
|
575
|
+
resolve(e) {
|
|
576
|
+
const t = e.resolve(this.anchor), n = e.resolve(this.head);
|
|
577
|
+
return t.parent.type.spec.tableRole == "row" && n.parent.type.spec.tableRole == "row" && t.index() < t.parent.childCount && n.index() < n.parent.childCount && Ne(t, n) ? new m(t, n) : N.near(n, 1);
|
|
771
578
|
}
|
|
772
579
|
}
|
|
773
|
-
function
|
|
774
|
-
if (!(
|
|
580
|
+
function Ht(o) {
|
|
581
|
+
if (!(o.selection instanceof m))
|
|
775
582
|
return null;
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
});
|
|
780
|
-
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
for (let i = $from.depth; i > 0; i--) {
|
|
798
|
-
const node = $from.node(i);
|
|
799
|
-
if (node.type.spec["tableRole"] === "cell" || node.type.spec["tableRole"] === "header_cell") {
|
|
800
|
-
fromCellBoundaryNode = node;
|
|
583
|
+
const e = [];
|
|
584
|
+
return o.selection.forEachCell((t, n) => {
|
|
585
|
+
e.push(ke.node(n, n + t.nodeSize, { class: "selectedCell" }));
|
|
586
|
+
}), Ae.create(o.doc, e);
|
|
587
|
+
}
|
|
588
|
+
function jt({ $from: o, $to: e }) {
|
|
589
|
+
if (o.pos == e.pos || o.pos < o.pos - 6)
|
|
590
|
+
return !1;
|
|
591
|
+
let t = o.pos, n = e.pos, l = o.depth;
|
|
592
|
+
for (; l >= 0 && !(o.after(l + 1) < o.end(l)); l--, t++)
|
|
593
|
+
;
|
|
594
|
+
for (let s = e.depth; s >= 0 && !(e.before(s + 1) > e.start(s)); s--, n--)
|
|
595
|
+
;
|
|
596
|
+
return t == n && /row|table/.test(o.node(l).type.spec.tableRole);
|
|
597
|
+
}
|
|
598
|
+
function Kt({ $from: o, $to: e }) {
|
|
599
|
+
let t, n;
|
|
600
|
+
for (let l = o.depth; l > 0; l--) {
|
|
601
|
+
const s = o.node(l);
|
|
602
|
+
if (s.type.spec.tableRole === "cell" || s.type.spec.tableRole === "header_cell") {
|
|
603
|
+
t = s;
|
|
801
604
|
break;
|
|
802
605
|
}
|
|
803
606
|
}
|
|
804
|
-
for (let
|
|
805
|
-
const
|
|
806
|
-
if (
|
|
807
|
-
|
|
607
|
+
for (let l = e.depth; l > 0; l--) {
|
|
608
|
+
const s = e.node(l);
|
|
609
|
+
if (s.type.spec.tableRole === "cell" || s.type.spec.tableRole === "header_cell") {
|
|
610
|
+
n = s;
|
|
808
611
|
break;
|
|
809
612
|
}
|
|
810
613
|
}
|
|
811
|
-
return
|
|
812
|
-
}
|
|
813
|
-
function
|
|
814
|
-
const
|
|
815
|
-
let
|
|
816
|
-
if (
|
|
817
|
-
if (
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
const
|
|
821
|
-
|
|
822
|
-
} else if (!
|
|
823
|
-
const
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
return tr;
|
|
836
|
-
}
|
|
837
|
-
function getCellAttrs(dom, extraAttrs) {
|
|
838
|
-
const widthAttr = dom.getAttribute("data-colwidth");
|
|
839
|
-
const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr) ? widthAttr.split(",").map((s) => Number(s)) : null;
|
|
840
|
-
const colspan = Number(dom.getAttribute("colspan") || 1);
|
|
841
|
-
const result = {
|
|
842
|
-
colspan,
|
|
843
|
-
rowspan: Number(dom.getAttribute("rowspan") || 1),
|
|
844
|
-
colwidth: widths && widths.length == colspan ? widths : null
|
|
614
|
+
return t !== n && e.parentOffset === 0;
|
|
615
|
+
}
|
|
616
|
+
function qt(o, e, t) {
|
|
617
|
+
const n = (e || o).selection, l = (e || o).doc;
|
|
618
|
+
let s, r;
|
|
619
|
+
if (n instanceof te && (r = n.node.type.spec.tableRole)) {
|
|
620
|
+
if (r == "cell" || r == "header_cell")
|
|
621
|
+
s = m.create(l, n.from);
|
|
622
|
+
else if (r == "row") {
|
|
623
|
+
const a = l.resolve(n.from + 1);
|
|
624
|
+
s = m.rowSelection(a, a);
|
|
625
|
+
} else if (!t) {
|
|
626
|
+
const a = g.get(n.node), i = n.from + 1, c = a.map[a.width * a.height - 1], d = i + c;
|
|
627
|
+
s = m.create(l, i + 1, d);
|
|
628
|
+
}
|
|
629
|
+
} else
|
|
630
|
+
n instanceof D && jt(n) ? s = D.create(l, n.from) : n instanceof D && Kt(n) && (s = D.create(l, n.$from.start(), n.$from.end()));
|
|
631
|
+
return s && (e || (e = o.tr)).setSelection(s), e;
|
|
632
|
+
}
|
|
633
|
+
function Ie(o, e) {
|
|
634
|
+
const t = o.getAttribute("data-colwidth"), n = t && /^\d+(,\d+)*$/.test(t) ? t.split(",").map((r) => Number(r)) : null, l = Number(o.getAttribute("colspan") || 1), s = {
|
|
635
|
+
colspan: l,
|
|
636
|
+
rowspan: Number(o.getAttribute("rowspan") || 1),
|
|
637
|
+
colwidth: n && n.length == l ? n : null
|
|
845
638
|
};
|
|
846
|
-
for (const
|
|
847
|
-
const
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
const setter = extraAttrs[prop].setDOMAttr;
|
|
864
|
-
if (setter)
|
|
865
|
-
setter(node.attrs[prop], attrs);
|
|
866
|
-
}
|
|
867
|
-
return attrs;
|
|
868
|
-
}
|
|
869
|
-
function tableNodesSpecCreator(options) {
|
|
870
|
-
const extraAttrs = options.cellAttributes || {};
|
|
871
|
-
const cellAttrs = {
|
|
639
|
+
for (const r in e) {
|
|
640
|
+
const a = e[r].getFromDOM, i = a && a(o);
|
|
641
|
+
i != null && (s[r] = i);
|
|
642
|
+
}
|
|
643
|
+
return s;
|
|
644
|
+
}
|
|
645
|
+
function $e(o, e) {
|
|
646
|
+
const t = {};
|
|
647
|
+
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(","));
|
|
648
|
+
for (const n in e) {
|
|
649
|
+
const l = e[n].setDOMAttr;
|
|
650
|
+
l && l(o.attrs[n], t);
|
|
651
|
+
}
|
|
652
|
+
return t;
|
|
653
|
+
}
|
|
654
|
+
function Ut(o) {
|
|
655
|
+
const e = o.cellAttributes || {}, t = {
|
|
872
656
|
colspan: { default: 1 },
|
|
873
657
|
rowspan: { default: 1 },
|
|
874
658
|
colwidth: { default: null }
|
|
875
659
|
};
|
|
876
|
-
for (const
|
|
877
|
-
|
|
878
|
-
const
|
|
879
|
-
|
|
660
|
+
for (const s in e)
|
|
661
|
+
t[s] = { default: e[s].default };
|
|
662
|
+
const n = t;
|
|
663
|
+
return {
|
|
880
664
|
table: {
|
|
881
665
|
content: "table_row+",
|
|
882
666
|
tableRole: "table",
|
|
883
|
-
isolating:
|
|
884
|
-
group:
|
|
667
|
+
isolating: !0,
|
|
668
|
+
group: o.tableGroup,
|
|
885
669
|
parseDOM: [{ tag: "table" }],
|
|
886
670
|
toDOM() {
|
|
887
671
|
return ["table", ["tbody", 0]];
|
|
@@ -896,396 +680,466 @@ function tableNodesSpecCreator(options) {
|
|
|
896
680
|
}
|
|
897
681
|
},
|
|
898
682
|
table_cell: {
|
|
899
|
-
content:
|
|
900
|
-
attrs:
|
|
683
|
+
content: o.cellContent,
|
|
684
|
+
attrs: n,
|
|
901
685
|
tableRole: "cell",
|
|
902
|
-
isolating:
|
|
903
|
-
parseDOM: [{ tag: "td", getAttrs: (
|
|
904
|
-
toDOM(
|
|
905
|
-
return ["td",
|
|
686
|
+
isolating: !0,
|
|
687
|
+
parseDOM: [{ tag: "td", getAttrs: (s) => Ie(s, e) }],
|
|
688
|
+
toDOM(s) {
|
|
689
|
+
return ["td", $e(s, e), 0];
|
|
906
690
|
}
|
|
907
691
|
},
|
|
908
692
|
table_header: {
|
|
909
|
-
content:
|
|
910
|
-
attrs:
|
|
693
|
+
content: o.cellContent,
|
|
694
|
+
attrs: n,
|
|
911
695
|
tableRole: "header_cell",
|
|
912
|
-
isolating:
|
|
913
|
-
parseDOM: [{ tag: "th", getAttrs: (
|
|
914
|
-
toDOM(
|
|
915
|
-
return ["th",
|
|
696
|
+
isolating: !0,
|
|
697
|
+
parseDOM: [{ tag: "th", getAttrs: (s) => Ie(s, e) }],
|
|
698
|
+
toDOM(s) {
|
|
699
|
+
return ["th", $e(s, e), 0];
|
|
916
700
|
}
|
|
917
701
|
}
|
|
918
702
|
};
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
if (role)
|
|
928
|
-
result[role] = type;
|
|
703
|
+
}
|
|
704
|
+
function A(o) {
|
|
705
|
+
let e = o.cached.tableNodeTypes;
|
|
706
|
+
if (!e) {
|
|
707
|
+
e = o.cached.tableNodeTypes = {};
|
|
708
|
+
for (const t in o.nodes) {
|
|
709
|
+
const n = o.nodes[t], l = n == null ? void 0 : n.spec.tableRole;
|
|
710
|
+
l && (e[l] = n);
|
|
929
711
|
}
|
|
930
712
|
}
|
|
931
|
-
return
|
|
713
|
+
return e;
|
|
932
714
|
}
|
|
933
|
-
const
|
|
715
|
+
const V = Ut({
|
|
934
716
|
tableGroup: "block",
|
|
935
717
|
cellContent: "paragraph",
|
|
936
718
|
cellAttributes: {
|
|
937
719
|
alignment: {
|
|
938
720
|
default: "left",
|
|
939
|
-
getFromDOM: (
|
|
940
|
-
setDOMAttr: (
|
|
941
|
-
|
|
721
|
+
getFromDOM: (o) => o.style.textAlign || "left",
|
|
722
|
+
setDOMAttr: (o, e) => {
|
|
723
|
+
e.style = `text-align: ${o || "left"}`;
|
|
942
724
|
}
|
|
943
725
|
}
|
|
944
726
|
}
|
|
945
727
|
});
|
|
946
|
-
function
|
|
947
|
-
for (let
|
|
948
|
-
if (
|
|
949
|
-
return
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
return
|
|
956
|
-
}
|
|
957
|
-
function
|
|
958
|
-
return
|
|
959
|
-
}
|
|
960
|
-
function
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
const
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
if (
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
function columnIsHeader(map, table2, col) {
|
|
1026
|
-
const headerCell = tableNodeTypes(table2.type.schema).header_cell;
|
|
1027
|
-
for (let row = 0; row < map.height; row++) {
|
|
1028
|
-
const pos = map.map[col + row * map.width];
|
|
1029
|
-
if (table2.nodeAt(pos).type != headerCell)
|
|
1030
|
-
return false;
|
|
1031
|
-
}
|
|
1032
|
-
return true;
|
|
1033
|
-
}
|
|
1034
|
-
const exitTable = (node) => (state, dispatch) => {
|
|
1035
|
-
if (!isInTable(state)) {
|
|
1036
|
-
return false;
|
|
1037
|
-
}
|
|
1038
|
-
const { $head } = state.selection;
|
|
1039
|
-
const pos = $head.after();
|
|
1040
|
-
const tr = state.tr.replaceWith(pos, pos, node.createAndFill());
|
|
1041
|
-
tr.setSelection(Selection.near(tr.doc.resolve(pos), 1));
|
|
1042
|
-
dispatch == null ? void 0 : dispatch(tr.scrollIntoView());
|
|
1043
|
-
return true;
|
|
728
|
+
function U(o) {
|
|
729
|
+
for (let e = o.depth - 1; e > 0; e--)
|
|
730
|
+
if (o.node(e).type.spec.tableRole == "row")
|
|
731
|
+
return o.node(0).resolve(o.before(e + 1));
|
|
732
|
+
}
|
|
733
|
+
function de(o) {
|
|
734
|
+
return o.parent.type.spec.tableRole == "row" ? o.nodeAfter : null;
|
|
735
|
+
}
|
|
736
|
+
function Xt(o) {
|
|
737
|
+
return o.node(0).resolve(o.pos + o.nodeAfter.nodeSize);
|
|
738
|
+
}
|
|
739
|
+
function Ne(o, e) {
|
|
740
|
+
return o.depth == e.depth && o.pos >= e.start(-1) && o.pos <= e.end(-1);
|
|
741
|
+
}
|
|
742
|
+
function et(o, e, t) {
|
|
743
|
+
const n = o.start(-1), s = g.get(o.node(-1)).nextCell(o.pos - n, e, t);
|
|
744
|
+
return s == null ? null : o.node(0).resolve(n + s);
|
|
745
|
+
}
|
|
746
|
+
function y(o, e, t) {
|
|
747
|
+
const n = {};
|
|
748
|
+
for (const l in o)
|
|
749
|
+
n[l] = o[l];
|
|
750
|
+
return n[e] = t, n;
|
|
751
|
+
}
|
|
752
|
+
function F(o, e, t = 1) {
|
|
753
|
+
const n = y(o, "colspan", o.colspan - t);
|
|
754
|
+
if (n.colwidth) {
|
|
755
|
+
const l = n.colwidth;
|
|
756
|
+
n.colwidth = l.slice(), l.splice(e, t), l.some((s) => s > 0) || (n.colwidth = null);
|
|
757
|
+
}
|
|
758
|
+
return n;
|
|
759
|
+
}
|
|
760
|
+
function M(o) {
|
|
761
|
+
const e = o.selection.$head;
|
|
762
|
+
for (let t = e.depth; t > 0; t--)
|
|
763
|
+
if (e.node(t).type.spec.tableRole == "row")
|
|
764
|
+
return !0;
|
|
765
|
+
return !1;
|
|
766
|
+
}
|
|
767
|
+
function ne(o) {
|
|
768
|
+
const e = o.selection;
|
|
769
|
+
return e instanceof m ? e.$anchorCell.pos > e.$headCell.pos ? e.$anchorCell : e.$headCell : e.node && e.node.type.spec.tableRole == "cell" ? e.$anchor : U(e.$head) || Vt(e.$head);
|
|
770
|
+
}
|
|
771
|
+
function Vt(o) {
|
|
772
|
+
for (let e = o.nodeAfter, t = o.pos; e; e = e.firstChild, t++) {
|
|
773
|
+
const n = e.type.spec.tableRole;
|
|
774
|
+
if (n == "cell" || n == "header_cell")
|
|
775
|
+
return o.doc.resolve(t);
|
|
776
|
+
}
|
|
777
|
+
for (let e = o.nodeBefore, t = o.pos; e; e = e.lastChild, t--) {
|
|
778
|
+
const n = e.type.spec.tableRole;
|
|
779
|
+
if (n == "cell" || n == "header_cell")
|
|
780
|
+
return o.doc.resolve(t - e.nodeSize);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
function Zt(o, e, t = 1) {
|
|
784
|
+
const n = y(o, "colspan", o.colspan + t);
|
|
785
|
+
if (n.colwidth) {
|
|
786
|
+
const l = n.colwidth;
|
|
787
|
+
n.colwidth = l.slice();
|
|
788
|
+
for (let s = 0; s < t; s++)
|
|
789
|
+
l.splice(e, 0, 0);
|
|
790
|
+
}
|
|
791
|
+
return n;
|
|
792
|
+
}
|
|
793
|
+
function Gt(o, e, t) {
|
|
794
|
+
const n = A(e.type.schema).header_cell;
|
|
795
|
+
for (let l = 0; l < o.height; l++) {
|
|
796
|
+
const s = o.map[t + l * o.width];
|
|
797
|
+
if (e.nodeAt(s).type != n)
|
|
798
|
+
return !1;
|
|
799
|
+
}
|
|
800
|
+
return !0;
|
|
801
|
+
}
|
|
802
|
+
const Jt = (o) => (e, t) => {
|
|
803
|
+
if (!M(e))
|
|
804
|
+
return !1;
|
|
805
|
+
const { $head: n } = e.selection, l = n.after(), s = e.tr.replaceWith(l, l, o.createAndFill());
|
|
806
|
+
return s.setSelection(N.near(s.doc.resolve(l), 1)), t == null || t(s.scrollIntoView()), !0;
|
|
1044
807
|
};
|
|
1045
|
-
|
|
1046
|
-
const
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
const
|
|
1056
|
-
if (
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
808
|
+
function W(o) {
|
|
809
|
+
const e = o.selection, t = ne(o), n = t.node(-1), l = t.start(-1), s = g.get(n);
|
|
810
|
+
let r;
|
|
811
|
+
return e instanceof m ? r = s.rectBetween(e.$anchorCell.pos - l, e.$headCell.pos - l) : r = s.findCell(t.pos - l), r.tableStart = l, r.map = s, r.table = n, r;
|
|
812
|
+
}
|
|
813
|
+
function tt(o, { map: e, tableStart: t, table: n }, l) {
|
|
814
|
+
e = e, n = n, t = t;
|
|
815
|
+
let s = l > 0 ? -1 : 0;
|
|
816
|
+
Gt(e, n, l + s) && (s = l == 0 || l == e.width ? null : 0);
|
|
817
|
+
for (let r = 0; r < e.height; r++) {
|
|
818
|
+
const a = r * e.width + l;
|
|
819
|
+
if (l > 0 && l < e.width && e.map[a - 1] == e.map[a]) {
|
|
820
|
+
const i = e.map[a], c = n.nodeAt(i);
|
|
821
|
+
o.setNodeMarkup(o.mapping.map(t + i), null, Zt(c.attrs, l - e.colCount(i))), r += c.attrs.rowspan - 1;
|
|
822
|
+
} else {
|
|
823
|
+
const i = e.map[a + s], c = s == null ? A(n.type.schema).cell : n.nodeAt(i).type, d = e.positionAt(r, l, n);
|
|
824
|
+
o.insert(o.mapping.map(t + d), c.createAndFill());
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return o;
|
|
828
|
+
}
|
|
829
|
+
const Yt = (o, e) => {
|
|
830
|
+
if (!M(o))
|
|
831
|
+
return !1;
|
|
832
|
+
if (e) {
|
|
833
|
+
const t = W(o);
|
|
834
|
+
e(tt(o.tr, t, t.left));
|
|
835
|
+
}
|
|
836
|
+
return !0;
|
|
837
|
+
}, Qt = (o, e) => {
|
|
838
|
+
if (!M(o))
|
|
839
|
+
return !1;
|
|
840
|
+
if (e) {
|
|
841
|
+
const t = W(o);
|
|
842
|
+
e(tt(o.tr, t, t.right));
|
|
843
|
+
}
|
|
844
|
+
return !0;
|
|
1065
845
|
};
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
846
|
+
function en(o, { map: e, table: t, tableStart: n }, l) {
|
|
847
|
+
e = e, t = t, n = n;
|
|
848
|
+
const s = o.mapping.maps.length;
|
|
849
|
+
for (let r = 0; r < e.height; ) {
|
|
850
|
+
const a = r * e.width + l, i = e.map[a], c = t.nodeAt(i);
|
|
851
|
+
if (l > 0 && e.map[a - 1] == i || l < e.width - 1 && e.map[a + 1] == i)
|
|
852
|
+
o.setNodeMarkup(o.mapping.slice(s).map(n + i), null, F(c.attrs, l - e.colCount(i)));
|
|
853
|
+
else {
|
|
854
|
+
const d = o.mapping.slice(s).map(n + i);
|
|
855
|
+
o.delete(d, d + c.nodeSize);
|
|
856
|
+
}
|
|
857
|
+
r += c.attrs.rowspan;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
const tn = (o, e) => {
|
|
861
|
+
if (!M(o))
|
|
862
|
+
return !1;
|
|
863
|
+
if (e) {
|
|
864
|
+
const t = W(o), n = o.tr;
|
|
865
|
+
if (t.left == 0 && t.right == t.map.width)
|
|
866
|
+
return !1;
|
|
867
|
+
for (let l = t.right - 1; en(n, t, l), l != t.left; l--)
|
|
868
|
+
t.table = t.tableStart ? n.doc.nodeAt(t.tableStart - 1) : n.doc, t.map = g.get(t.table);
|
|
869
|
+
e(n);
|
|
870
|
+
}
|
|
871
|
+
return !0;
|
|
1085
872
|
};
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
873
|
+
function nn(o, { map: e, tableStart: t, table: n }, l) {
|
|
874
|
+
e = e, n = n, t = t;
|
|
875
|
+
let s = 0;
|
|
876
|
+
for (let i = 0; i < l; i++)
|
|
877
|
+
s += n.child(i).nodeSize;
|
|
878
|
+
const r = s + n.child(l).nodeSize, a = o.mapping.maps.length;
|
|
879
|
+
o.delete(s + t, r + t);
|
|
880
|
+
for (let i = 0, c = l * e.width; i < e.width; i++, c++) {
|
|
881
|
+
const d = e.map[c];
|
|
882
|
+
if (l > 0 && d == e.map[c - e.width]) {
|
|
883
|
+
const u = n.nodeAt(d).attrs;
|
|
884
|
+
o.setNodeMarkup(o.mapping.slice(a).map(d + t), null, y(u, "rowspan", u.rowspan - 1)), i += u.colspan - 1;
|
|
885
|
+
} else if (l < e.width && d == e.map[c + e.width]) {
|
|
886
|
+
const u = n.nodeAt(d), f = u.type.create(y(u.attrs, "rowspan", u.attrs.rowspan - 1), u.content), p = e.positionAt(l + 1, i, n);
|
|
887
|
+
o.insert(o.mapping.slice(a).map(t + p), f), i += u.attrs.colspan - 1;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
const on = (o, e) => {
|
|
892
|
+
if (!M(o))
|
|
893
|
+
return !1;
|
|
894
|
+
if (e) {
|
|
895
|
+
const t = W(o), n = o.tr;
|
|
896
|
+
if (t.top == 0 && t.bottom == t.map.height)
|
|
897
|
+
return !1;
|
|
898
|
+
for (let l = t.bottom - 1; nn(n, t, l), l != t.top; l--)
|
|
899
|
+
t.table = t.tableStart ? n.doc.nodeAt(t.tableStart - 1) : n.doc, t.map = g.get(t.table);
|
|
900
|
+
e(n);
|
|
901
|
+
}
|
|
902
|
+
return !0;
|
|
1092
903
|
};
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
const
|
|
1098
|
-
if (
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
904
|
+
function ie(o, e) {
|
|
905
|
+
return (t, n) => {
|
|
906
|
+
if (!M(t))
|
|
907
|
+
return !1;
|
|
908
|
+
const l = ne(t);
|
|
909
|
+
if (l.nodeAfter.attrs[o] === e)
|
|
910
|
+
return !1;
|
|
911
|
+
if (n) {
|
|
912
|
+
const s = t.tr;
|
|
913
|
+
t.selection instanceof m ? t.selection.forEachCell((r, a) => {
|
|
914
|
+
r.attrs[o] !== e && s.setNodeMarkup(a, null, y(r.attrs, o, e));
|
|
915
|
+
}) : s.setNodeMarkup(l.pos, null, y(l.nodeAfter.attrs, o, e)), n(s);
|
|
916
|
+
}
|
|
917
|
+
return !0;
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
function ln(o, e) {
|
|
921
|
+
if (e < 0) {
|
|
922
|
+
const t = o.nodeBefore;
|
|
923
|
+
if (t)
|
|
924
|
+
return o.pos - t.nodeSize;
|
|
925
|
+
for (let n = o.index(-1) - 1, l = o.before(); n >= 0; n--) {
|
|
926
|
+
const s = o.node(-1).child(n);
|
|
927
|
+
if (s.childCount)
|
|
928
|
+
return l - 1 - s.lastChild.nodeSize;
|
|
929
|
+
l -= s.nodeSize;
|
|
1105
930
|
}
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1111
|
-
|
|
931
|
+
} else {
|
|
932
|
+
if (o.index() < o.parent.childCount - 1)
|
|
933
|
+
return o.pos + o.nodeAfter.nodeSize;
|
|
934
|
+
const t = o.node(-1);
|
|
935
|
+
for (let n = o.indexAfter(-1), l = o.after(); n < t.childCount; n++) {
|
|
936
|
+
const s = t.child(n);
|
|
937
|
+
if (s.childCount)
|
|
938
|
+
return l + 1;
|
|
939
|
+
l += s.nodeSize;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
function De(o) {
|
|
944
|
+
return (e, t) => {
|
|
945
|
+
if (!M(e))
|
|
946
|
+
return !1;
|
|
947
|
+
const n = ln(ne(e), o);
|
|
948
|
+
if (n == null)
|
|
949
|
+
return !1;
|
|
950
|
+
if (t) {
|
|
951
|
+
const l = e.doc.resolve(n);
|
|
952
|
+
t(e.tr.setSelection(D.between(l, Xt(l))).scrollIntoView());
|
|
953
|
+
}
|
|
954
|
+
return !0;
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
const sn = (o, e) => {
|
|
958
|
+
const t = o.selection.$anchor;
|
|
959
|
+
for (let n = t.depth; n > 0; n--)
|
|
960
|
+
if (t.node(n).type.spec.tableRole == "table")
|
|
961
|
+
return e && e(o.tr.delete(t.before(n), t.after(n)).scrollIntoView()), !0;
|
|
962
|
+
return !1;
|
|
963
|
+
}, oe = (o) => Ct((e) => e.type.spec.tableRole === "table")(o), rn = (o) => (e) => {
|
|
964
|
+
const t = oe(e);
|
|
965
|
+
if (!t)
|
|
1112
966
|
return;
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
967
|
+
const n = g.get(t.node);
|
|
968
|
+
if (!(o < 0 || o >= n.width))
|
|
969
|
+
return n.cellsInRect({ left: o, right: o + 1, top: 0, bottom: n.height }).map((l) => {
|
|
970
|
+
const s = t.node.nodeAt(l);
|
|
971
|
+
if (!s)
|
|
972
|
+
return;
|
|
973
|
+
const r = l + t.start;
|
|
974
|
+
return {
|
|
975
|
+
pos: r,
|
|
976
|
+
start: r + 1,
|
|
977
|
+
node: s
|
|
978
|
+
};
|
|
979
|
+
}).filter((l) => l != null);
|
|
980
|
+
}, cn = (o) => (e) => {
|
|
981
|
+
const t = oe(e);
|
|
982
|
+
if (!t)
|
|
983
|
+
return;
|
|
984
|
+
const n = g.get(t.node);
|
|
985
|
+
if (!(o < 0 || o >= n.height))
|
|
986
|
+
return n.cellsInRect({ left: 0, right: n.width, top: o, bottom: o + 1 }).map((l) => {
|
|
987
|
+
const s = t.node.nodeAt(l);
|
|
988
|
+
if (!s)
|
|
989
|
+
return;
|
|
990
|
+
const r = l + t.start;
|
|
991
|
+
return {
|
|
992
|
+
pos: r,
|
|
993
|
+
start: r + 1,
|
|
994
|
+
node: s
|
|
995
|
+
};
|
|
996
|
+
}).filter((l) => l != null);
|
|
997
|
+
}, _e = (o, e = 3, t = 3) => {
|
|
998
|
+
const { cell: n, header_cell: l, row: s, table: r } = A(o), a = Array(t).fill(0).map(() => n.createAndFill(null)), i = Array(t).fill(0).map(() => l.createAndFill(null)), c = Array(e).fill(0).map((d, u) => s.create(null, u === 0 ? i : a));
|
|
999
|
+
return r.create(null, c);
|
|
1000
|
+
}, Oe = (o) => (e) => (t) => {
|
|
1001
|
+
const n = oe(t.selection), l = o === "row";
|
|
1002
|
+
if (n) {
|
|
1003
|
+
const s = g.get(n.node);
|
|
1004
|
+
if (e >= 0 && e < (l ? s.height : s.width)) {
|
|
1005
|
+
const r = s.positionAt(l ? e : s.height - 1, l ? s.width - 1 : e, n.node), a = t.doc.resolve(n.start + r), i = l ? m.rowSelection : m.colSelection, c = s.positionAt(l ? e : 0, l ? 0 : e, n.node), d = t.doc.resolve(n.start + c);
|
|
1006
|
+
return Ge(t.setSelection(i(a, d)));
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
return t;
|
|
1010
|
+
}, an = (o) => {
|
|
1011
|
+
const e = oe(o);
|
|
1012
|
+
if (!e)
|
|
1013
|
+
return;
|
|
1014
|
+
const t = g.get(e.node);
|
|
1015
|
+
return t.cellsInRect({
|
|
1116
1016
|
left: 0,
|
|
1117
|
-
right:
|
|
1017
|
+
right: t.width,
|
|
1118
1018
|
top: 0,
|
|
1119
|
-
bottom:
|
|
1019
|
+
bottom: t.height
|
|
1020
|
+
}).map((l) => {
|
|
1021
|
+
const s = e.node.nodeAt(l), r = l + e.start;
|
|
1022
|
+
return { pos: r, start: r + 1, node: s };
|
|
1120
1023
|
});
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
const cells = getCellsInTable(tr.selection);
|
|
1129
|
-
if (cells && cells[0]) {
|
|
1130
|
-
const $firstCell = tr.doc.resolve(cells[0].pos);
|
|
1131
|
-
const last = cells[cells.length - 1];
|
|
1132
|
-
if (last) {
|
|
1133
|
-
const $lastCell = tr.doc.resolve(last.pos);
|
|
1134
|
-
return cloneTr(tr.setSelection(new CellSelection($lastCell, $firstCell)));
|
|
1024
|
+
}, dn = (o) => {
|
|
1025
|
+
const e = an(o.selection);
|
|
1026
|
+
if (e && e[0]) {
|
|
1027
|
+
const t = o.doc.resolve(e[0].pos), n = e[e.length - 1];
|
|
1028
|
+
if (n) {
|
|
1029
|
+
const l = o.doc.resolve(n.pos);
|
|
1030
|
+
return Ge(o.setSelection(new m(l, t)));
|
|
1135
1031
|
}
|
|
1136
1032
|
}
|
|
1137
|
-
return
|
|
1033
|
+
return o;
|
|
1138
1034
|
};
|
|
1139
|
-
function
|
|
1140
|
-
const
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
const { cell: cellType, row: rowType } = tableNodeTypes(table2.type.schema);
|
|
1144
|
-
const cells = Array(map.width).fill(0).map((_, col) => {
|
|
1145
|
-
const headerCol = table2.nodeAt(map.map[col]);
|
|
1146
|
-
return cellType.createAndFill({ alignment: headerCol == null ? void 0 : headerCol.attrs["alignment"] });
|
|
1035
|
+
function ze(o, { map: e, tableStart: t, table: n }, l) {
|
|
1036
|
+
const s = Array(l).fill(0).reduce((c, d, u) => c + n.child(u).nodeSize, t), { cell: r, row: a } = A(n.type.schema), i = Array(e.width).fill(0).map((c, d) => {
|
|
1037
|
+
const u = n.nodeAt(e.map[d]);
|
|
1038
|
+
return r.createAndFill({ alignment: u == null ? void 0 : u.attrs.alignment });
|
|
1147
1039
|
});
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
const
|
|
1152
|
-
const isFirstRowSelected = (selection) => {
|
|
1153
|
-
const map = TableMap.get(selection.$anchorCell.node(-1));
|
|
1154
|
-
const start = selection.$anchorCell.start(-1);
|
|
1155
|
-
const cells = map.cellsInRect({
|
|
1040
|
+
return o.insert(s, a.create(null, i)), o;
|
|
1041
|
+
}
|
|
1042
|
+
const T = (o) => o.state.selection, un = (o) => {
|
|
1043
|
+
const e = g.get(o.$anchorCell.node(-1)), t = o.$anchorCell.start(-1), n = e.cellsInRect({
|
|
1156
1044
|
left: 0,
|
|
1157
|
-
right:
|
|
1045
|
+
right: e.width,
|
|
1158
1046
|
top: 0,
|
|
1159
1047
|
bottom: 1
|
|
1160
|
-
});
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
Object.values(actions).forEach((item) => {
|
|
1171
|
-
var _a;
|
|
1172
|
-
const disable = (_a = item.disable) == null ? void 0 : _a.call(item, view);
|
|
1173
|
-
if (disable) {
|
|
1174
|
-
item.$.classList.add("hide");
|
|
1048
|
+
}), l = e.cellsInRect(e.rectBetween(o.$anchorCell.pos - t, o.$headCell.pos - t));
|
|
1049
|
+
for (let s = 0, r = n.length; s < r; s++)
|
|
1050
|
+
if (l.indexOf(n[s]) === -1)
|
|
1051
|
+
return !1;
|
|
1052
|
+
return !0;
|
|
1053
|
+
}, fn = (o, e) => {
|
|
1054
|
+
Object.values(o).forEach((t) => {
|
|
1055
|
+
var l;
|
|
1056
|
+
if ((l = t.disable) == null ? void 0 : l.call(t, e)) {
|
|
1057
|
+
t.$.classList.add("hide");
|
|
1175
1058
|
return;
|
|
1176
1059
|
}
|
|
1177
|
-
|
|
1060
|
+
t.$.classList.remove("hide");
|
|
1178
1061
|
});
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1062
|
+
}, pn = (o) => {
|
|
1063
|
+
var e, t, n, l, s, r, a, i;
|
|
1182
1064
|
return {
|
|
1183
1065
|
[0]: {
|
|
1184
|
-
$: (
|
|
1185
|
-
command: () =>
|
|
1186
|
-
disable: (
|
|
1066
|
+
$: (e = o.get(L).get(v, "leftArrow")) == null ? void 0 : e.dom,
|
|
1067
|
+
command: () => Yt,
|
|
1068
|
+
disable: (c) => !T(c).isColSelection()
|
|
1187
1069
|
},
|
|
1188
1070
|
[1]: {
|
|
1189
|
-
$: (
|
|
1190
|
-
command: () =>
|
|
1191
|
-
disable: (
|
|
1071
|
+
$: (t = o.get(L).get(v, "rightArrow")) == null ? void 0 : t.dom,
|
|
1072
|
+
command: () => Qt,
|
|
1073
|
+
disable: (c) => !T(c).isColSelection()
|
|
1192
1074
|
},
|
|
1193
1075
|
[2]: {
|
|
1194
|
-
$: (
|
|
1195
|
-
command: () => (
|
|
1196
|
-
if (!
|
|
1197
|
-
return
|
|
1198
|
-
if (
|
|
1199
|
-
const
|
|
1200
|
-
|
|
1076
|
+
$: (n = o.get(L).get(v, "upArrow")) == null ? void 0 : n.dom,
|
|
1077
|
+
command: () => (c, d) => {
|
|
1078
|
+
if (!M(c))
|
|
1079
|
+
return !1;
|
|
1080
|
+
if (d) {
|
|
1081
|
+
const u = W(c);
|
|
1082
|
+
d(ze(c.tr, u, u.top));
|
|
1201
1083
|
}
|
|
1202
|
-
return
|
|
1084
|
+
return !0;
|
|
1203
1085
|
},
|
|
1204
|
-
disable: (
|
|
1086
|
+
disable: (c) => !T(c).isRowSelection() || T(c).$head.parent.type.name === "table_header"
|
|
1205
1087
|
},
|
|
1206
1088
|
[3]: {
|
|
1207
|
-
$: (
|
|
1208
|
-
command: () => (
|
|
1209
|
-
if (!
|
|
1210
|
-
return
|
|
1211
|
-
if (
|
|
1212
|
-
const
|
|
1213
|
-
|
|
1089
|
+
$: (l = o.get(L).get(v, "downArrow")) == null ? void 0 : l.dom,
|
|
1090
|
+
command: () => (c, d) => {
|
|
1091
|
+
if (!M(c))
|
|
1092
|
+
return !1;
|
|
1093
|
+
if (d) {
|
|
1094
|
+
const u = W(c);
|
|
1095
|
+
d(ze(c.tr, u, u.bottom));
|
|
1214
1096
|
}
|
|
1215
|
-
return
|
|
1097
|
+
return !0;
|
|
1216
1098
|
},
|
|
1217
|
-
disable: (
|
|
1099
|
+
disable: (c) => !T(c).isRowSelection()
|
|
1218
1100
|
},
|
|
1219
1101
|
[4]: {
|
|
1220
|
-
$: (
|
|
1221
|
-
command: () =>
|
|
1222
|
-
disable: (
|
|
1102
|
+
$: (s = o.get(L).get(v, "alignLeft")) == null ? void 0 : s.dom,
|
|
1103
|
+
command: () => ie("alignment", "left"),
|
|
1104
|
+
disable: (c) => !T(c).isColSelection()
|
|
1223
1105
|
},
|
|
1224
1106
|
[5]: {
|
|
1225
|
-
$: (
|
|
1226
|
-
command: () =>
|
|
1227
|
-
disable: (
|
|
1107
|
+
$: (r = o.get(L).get(v, "alignCenter")) == null ? void 0 : r.dom,
|
|
1108
|
+
command: () => ie("alignment", "center"),
|
|
1109
|
+
disable: (c) => !T(c).isColSelection()
|
|
1228
1110
|
},
|
|
1229
1111
|
[6]: {
|
|
1230
|
-
$: (
|
|
1231
|
-
command: () =>
|
|
1232
|
-
disable: (
|
|
1112
|
+
$: (a = o.get(L).get(v, "alignRight")) == null ? void 0 : a.dom,
|
|
1113
|
+
command: () => ie("alignment", "right"),
|
|
1114
|
+
disable: (c) => !T(c).isColSelection()
|
|
1233
1115
|
},
|
|
1234
1116
|
[7]: {
|
|
1235
|
-
$: (
|
|
1236
|
-
command: (
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1239
|
-
const isRow = selection.isRowSelection();
|
|
1240
|
-
if (isCol && isRow) {
|
|
1241
|
-
return deleteTable;
|
|
1242
|
-
}
|
|
1243
|
-
if (isCol) {
|
|
1244
|
-
return deleteColumn;
|
|
1245
|
-
}
|
|
1246
|
-
return deleteRow;
|
|
1117
|
+
$: (i = o.get(L).get(v, "delete")) == null ? void 0 : i.dom,
|
|
1118
|
+
command: (c, d) => {
|
|
1119
|
+
const u = T(d), f = u.isColSelection(), p = u.isRowSelection();
|
|
1120
|
+
return f && p ? sn : f ? tn : on;
|
|
1247
1121
|
},
|
|
1248
|
-
disable: (
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1251
|
-
if (selection.isColSelection()) {
|
|
1252
|
-
return false;
|
|
1253
|
-
}
|
|
1254
|
-
return isFirstRowSelected(selection);
|
|
1255
|
-
}
|
|
1256
|
-
return false;
|
|
1122
|
+
disable: (c) => {
|
|
1123
|
+
const d = T(c);
|
|
1124
|
+
return d.isRowSelection() ? d.isColSelection() ? !1 : un(d) : !1;
|
|
1257
1125
|
}
|
|
1258
1126
|
}
|
|
1259
1127
|
};
|
|
1260
|
-
}
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
}
|
|
1270
|
-
let left = !isRow ? selected.left - parent.left + (selected.width - target.width) / 2 : selected.left - parent.left - target.width / 2 - 8;
|
|
1271
|
-
const top = selected.top - parent.top - target.height - (isCol ? 14 : 0) - 14 + $editor.scrollTop;
|
|
1272
|
-
if (left < 0) {
|
|
1273
|
-
left = 0;
|
|
1274
|
-
}
|
|
1275
|
-
return [top, left];
|
|
1128
|
+
}, hn = (o, e) => {
|
|
1129
|
+
const { selection: t } = o.state, n = t.isColSelection(), l = t.isRowSelection();
|
|
1130
|
+
yt(o, e, (s, r, a) => {
|
|
1131
|
+
const i = e.parentElement;
|
|
1132
|
+
if (!i)
|
|
1133
|
+
throw bt();
|
|
1134
|
+
let c = l ? s.left - a.left - r.width / 2 - 8 : s.left - a.left + (s.width - r.width) / 2;
|
|
1135
|
+
const d = s.top - a.top - r.height - (n ? 14 : 0) - 14 + i.scrollTop;
|
|
1136
|
+
return c < 0 && (c = 0), [d, c];
|
|
1276
1137
|
});
|
|
1277
1138
|
};
|
|
1278
|
-
var
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
return ToolTipPos2;
|
|
1283
|
-
})(ToolTipPos || {});
|
|
1284
|
-
const injectStyle = (themeManager, { css, injectGlobal }) => {
|
|
1285
|
-
const palette = getPalette(themeManager);
|
|
1286
|
-
const radius = themeManager.get(ThemeSize, "radius");
|
|
1287
|
-
const lineWidth = themeManager.get(ThemeSize, "lineWidth");
|
|
1288
|
-
injectGlobal`
|
|
1139
|
+
var R = /* @__PURE__ */ ((o) => (o.Left = "Left", o.Top = "Top", o.Point = "Point", o))(R || {});
|
|
1140
|
+
const mn = (o, { css: e, injectGlobal: t }) => {
|
|
1141
|
+
const n = wt(o), l = o.get(Re, "radius"), s = o.get(Re, "lineWidth");
|
|
1142
|
+
return t`
|
|
1289
1143
|
.milkdown {
|
|
1290
1144
|
.tableWrapper {
|
|
1291
1145
|
table {
|
|
@@ -1306,12 +1160,12 @@ const injectStyle = (themeManager, { css, injectGlobal }) => {
|
|
|
1306
1160
|
width: 100%;
|
|
1307
1161
|
display: block;
|
|
1308
1162
|
transition: all 0.2s ease-in-out;
|
|
1309
|
-
background: ${
|
|
1163
|
+
background: ${n("secondary", 0.12)};
|
|
1310
1164
|
content: '';
|
|
1311
1165
|
}
|
|
1312
1166
|
|
|
1313
1167
|
&:hover::after {
|
|
1314
|
-
background: ${
|
|
1168
|
+
background: ${n("secondary", 0.38)};
|
|
1315
1169
|
}
|
|
1316
1170
|
}
|
|
1317
1171
|
|
|
@@ -1346,8 +1200,7 @@ const injectStyle = (themeManager, { css, injectGlobal }) => {
|
|
|
1346
1200
|
}
|
|
1347
1201
|
}
|
|
1348
1202
|
}
|
|
1349
|
-
|
|
1350
|
-
return css`
|
|
1203
|
+
`, e`
|
|
1351
1204
|
display: inline-flex;
|
|
1352
1205
|
cursor: pointer;
|
|
1353
1206
|
z-index: 2;
|
|
@@ -1356,17 +1209,17 @@ const injectStyle = (themeManager, { css, injectGlobal }) => {
|
|
|
1356
1209
|
|
|
1357
1210
|
position: absolute;
|
|
1358
1211
|
|
|
1359
|
-
border-radius: ${
|
|
1212
|
+
border-radius: ${l};
|
|
1360
1213
|
|
|
1361
|
-
${
|
|
1362
|
-
${
|
|
1214
|
+
${o.get(mt, void 0)};
|
|
1215
|
+
${o.get(gt, void 0)};
|
|
1363
1216
|
|
|
1364
1217
|
overflow: hidden;
|
|
1365
|
-
background: ${
|
|
1218
|
+
background: ${n("surface")};
|
|
1366
1219
|
|
|
1367
1220
|
.icon {
|
|
1368
1221
|
position: relative;
|
|
1369
|
-
color: ${
|
|
1222
|
+
color: ${n("solid", 0.87)};
|
|
1370
1223
|
|
|
1371
1224
|
width: 2em;
|
|
1372
1225
|
line-height: 2em;
|
|
@@ -1374,11 +1227,11 @@ const injectStyle = (themeManager, { css, injectGlobal }) => {
|
|
|
1374
1227
|
transition: all 0.4s ease-in-out;
|
|
1375
1228
|
|
|
1376
1229
|
&:hover {
|
|
1377
|
-
background-color: ${
|
|
1230
|
+
background-color: ${n("secondary", 0.12)};
|
|
1378
1231
|
}
|
|
1379
1232
|
|
|
1380
1233
|
&.active {
|
|
1381
|
-
color: ${
|
|
1234
|
+
color: ${n("primary")};
|
|
1382
1235
|
}
|
|
1383
1236
|
|
|
1384
1237
|
&:not(:last-child)::after {
|
|
@@ -1386,9 +1239,9 @@ const injectStyle = (themeManager, { css, injectGlobal }) => {
|
|
|
1386
1239
|
position: absolute;
|
|
1387
1240
|
right: 0;
|
|
1388
1241
|
top: 0;
|
|
1389
|
-
width: ${
|
|
1242
|
+
width: ${s};
|
|
1390
1243
|
bottom: 0;
|
|
1391
|
-
background: ${
|
|
1244
|
+
background: ${n("line")};
|
|
1392
1245
|
}
|
|
1393
1246
|
}
|
|
1394
1247
|
|
|
@@ -1397,1463 +1250,1043 @@ const injectStyle = (themeManager, { css, injectGlobal }) => {
|
|
|
1397
1250
|
display: none;
|
|
1398
1251
|
}
|
|
1399
1252
|
`;
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
case ToolTipPos.Left: {
|
|
1253
|
+
}, gn = (o) => {
|
|
1254
|
+
switch (o) {
|
|
1255
|
+
case R.Left:
|
|
1404
1256
|
return "milkdown-cell-left";
|
|
1405
|
-
|
|
1406
|
-
case ToolTipPos.Top: {
|
|
1257
|
+
case R.Top:
|
|
1407
1258
|
return "milkdown-cell-top";
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
default: {
|
|
1259
|
+
case R.Point:
|
|
1260
|
+
default:
|
|
1411
1261
|
return "milkdown-cell-point";
|
|
1412
|
-
}
|
|
1413
1262
|
}
|
|
1414
1263
|
};
|
|
1415
|
-
function
|
|
1416
|
-
return
|
|
1417
|
-
var
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
if (!view)
|
|
1425
|
-
return;
|
|
1426
|
-
e.preventDefault();
|
|
1427
|
-
switch (pos) {
|
|
1428
|
-
case ToolTipPos.Point: {
|
|
1429
|
-
view.dispatch(selectTable(view.state.tr));
|
|
1430
|
-
return;
|
|
1431
|
-
}
|
|
1432
|
-
case ToolTipPos.Left: {
|
|
1433
|
-
view.dispatch(selectLine("row")(index)(view.state.tr));
|
|
1434
|
-
return;
|
|
1435
|
-
}
|
|
1436
|
-
case ToolTipPos.Top: {
|
|
1437
|
-
view.dispatch(selectLine("col")(index)(view.state.tr));
|
|
1438
|
-
return;
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
});
|
|
1442
|
-
return div;
|
|
1443
|
-
});
|
|
1444
|
-
}
|
|
1445
|
-
const operatorPlugin = (ctx, utils) => {
|
|
1446
|
-
return new Plugin({
|
|
1447
|
-
key: new PluginKey("MILKDOWN_TABLE_OP"),
|
|
1448
|
-
props: {
|
|
1449
|
-
decorations: (state) => {
|
|
1450
|
-
const decorations = [];
|
|
1451
|
-
const leftCells = getCellsInColumn(0)(state.selection);
|
|
1452
|
-
if (!leftCells)
|
|
1453
|
-
return null;
|
|
1454
|
-
const topCells = getCellsInRow(0)(state.selection);
|
|
1455
|
-
if (!topCells)
|
|
1456
|
-
return null;
|
|
1457
|
-
const [topLeft] = leftCells;
|
|
1458
|
-
decorations.push(createWidget(ctx, topLeft, ToolTipPos.Point));
|
|
1459
|
-
leftCells.forEach((cell, i) => {
|
|
1460
|
-
decorations.push(createWidget(ctx, cell, ToolTipPos.Left, i));
|
|
1461
|
-
});
|
|
1462
|
-
topCells.forEach((cell, i) => {
|
|
1463
|
-
decorations.push(createWidget(ctx, cell, ToolTipPos.Top, i));
|
|
1464
|
-
});
|
|
1465
|
-
return DecorationSet.create(state.doc, decorations);
|
|
1466
|
-
}
|
|
1467
|
-
},
|
|
1468
|
-
view: (editorView) => {
|
|
1469
|
-
var _a;
|
|
1470
|
-
const items = Object.fromEntries(Object.entries(createActions(ctx)).filter(([, value]) => value.$ != null));
|
|
1471
|
-
const tooltip = document.createElement("div");
|
|
1472
|
-
utils.themeManager.onFlush(() => {
|
|
1473
|
-
const style = utils.getStyle((emotion) => injectStyle(utils.themeManager, emotion));
|
|
1474
|
-
if (style) {
|
|
1475
|
-
tooltip.classList.add(style);
|
|
1476
|
-
}
|
|
1477
|
-
});
|
|
1478
|
-
tooltip.classList.add("table-tooltip", "hide");
|
|
1479
|
-
Object.values(items).forEach(({ $ }) => tooltip.appendChild($));
|
|
1480
|
-
(_a = editorView.dom.parentNode) == null ? void 0 : _a.appendChild(tooltip);
|
|
1481
|
-
const listener = (e) => {
|
|
1482
|
-
if (!editorView)
|
|
1483
|
-
return;
|
|
1484
|
-
e.stopPropagation();
|
|
1485
|
-
e.preventDefault();
|
|
1486
|
-
Object.values(items).forEach(({ $, command }) => {
|
|
1487
|
-
if ($.contains(e.target)) {
|
|
1488
|
-
command(e, editorView)(editorView.state, editorView.dispatch, editorView);
|
|
1489
|
-
}
|
|
1490
|
-
});
|
|
1491
|
-
};
|
|
1492
|
-
const hide = () => {
|
|
1493
|
-
tooltip.classList.add("hide");
|
|
1494
|
-
};
|
|
1495
|
-
tooltip.addEventListener("mousedown", listener);
|
|
1496
|
-
return {
|
|
1497
|
-
update: (view, prevState) => {
|
|
1498
|
-
const state = view.state;
|
|
1499
|
-
if ((prevState == null ? void 0 : prevState.doc.eq(state.doc)) && prevState.selection.eq(state.selection))
|
|
1264
|
+
function ce(o, e, t, n = 0) {
|
|
1265
|
+
return ke.widget(e.pos + 1, (l) => {
|
|
1266
|
+
var r;
|
|
1267
|
+
const s = document.createElement("div");
|
|
1268
|
+
return s.classList.add(gn(t)), t === R.Point && s.appendChild((r = o.get(L).get(v, "select")) == null ? void 0 : r.dom), s.addEventListener("mousedown", (a) => {
|
|
1269
|
+
if (!!l)
|
|
1270
|
+
switch (a.preventDefault(), t) {
|
|
1271
|
+
case R.Point: {
|
|
1272
|
+
l.dispatch(dn(l.state.tr));
|
|
1500
1273
|
return;
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1274
|
+
}
|
|
1275
|
+
case R.Left: {
|
|
1276
|
+
l.dispatch(Oe("row")(n)(l.state.tr));
|
|
1504
1277
|
return;
|
|
1505
1278
|
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
hide();
|
|
1279
|
+
case R.Top: {
|
|
1280
|
+
l.dispatch(Oe("col")(n)(l.state.tr));
|
|
1509
1281
|
return;
|
|
1510
1282
|
}
|
|
1511
|
-
tooltip.classList.remove("hide");
|
|
1512
|
-
calculatePosition(view, tooltip);
|
|
1513
|
-
},
|
|
1514
|
-
destroy: () => {
|
|
1515
|
-
tooltip.removeEventListener("mousedown", listener);
|
|
1516
|
-
tooltip.remove();
|
|
1517
1283
|
}
|
|
1518
|
-
|
|
1519
|
-
}
|
|
1284
|
+
}), s;
|
|
1520
1285
|
});
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1286
|
+
}
|
|
1287
|
+
const wn = (o, e) => new B({
|
|
1288
|
+
key: new O("MILKDOWN_TABLE_OP"),
|
|
1289
|
+
props: {
|
|
1290
|
+
decorations: (t) => {
|
|
1291
|
+
const n = [], l = rn(0)(t.selection);
|
|
1292
|
+
if (!l)
|
|
1293
|
+
return null;
|
|
1294
|
+
const s = cn(0)(t.selection);
|
|
1295
|
+
if (!s)
|
|
1296
|
+
return null;
|
|
1297
|
+
const [r] = l;
|
|
1298
|
+
return n.push(ce(o, r, R.Point)), l.forEach((a, i) => {
|
|
1299
|
+
n.push(ce(o, a, R.Left, i));
|
|
1300
|
+
}), s.forEach((a, i) => {
|
|
1301
|
+
n.push(ce(o, a, R.Top, i));
|
|
1302
|
+
}), Ae.create(t.doc, n);
|
|
1303
|
+
}
|
|
1304
|
+
},
|
|
1305
|
+
view: (t) => {
|
|
1306
|
+
var a;
|
|
1307
|
+
const n = Object.fromEntries(Object.entries(pn(o)).filter(([, i]) => i.$ != null)), l = document.createElement("div");
|
|
1308
|
+
e.themeManager.onFlush(() => {
|
|
1309
|
+
const i = e.getStyle((c) => mn(e.themeManager, c));
|
|
1310
|
+
i && l.classList.add(i);
|
|
1311
|
+
}), l.classList.add("table-tooltip", "hide"), Object.values(n).forEach(({ $: i }) => l.appendChild(i)), (a = t.dom.parentNode) == null || a.appendChild(l);
|
|
1312
|
+
const s = (i) => {
|
|
1313
|
+
!t || (i.stopPropagation(), i.preventDefault(), Object.values(n).forEach(({ $: c, command: d }) => {
|
|
1314
|
+
c.contains(i.target) && d(i, t)(t.state, t.dispatch, t);
|
|
1315
|
+
}));
|
|
1316
|
+
}, r = () => {
|
|
1317
|
+
l.classList.add("hide");
|
|
1318
|
+
};
|
|
1319
|
+
return l.addEventListener("mousedown", s), {
|
|
1320
|
+
update: (i, c) => {
|
|
1321
|
+
const d = i.state;
|
|
1322
|
+
if ((c == null ? void 0 : c.doc.eq(d.doc)) && c.selection.eq(d.selection))
|
|
1323
|
+
return;
|
|
1324
|
+
if (!(d.selection instanceof m) || !i.editable) {
|
|
1325
|
+
r();
|
|
1326
|
+
return;
|
|
1327
|
+
}
|
|
1328
|
+
if (fn(n, i), Object.values(n).every(({ $: f }) => f.classList.contains("hide"))) {
|
|
1329
|
+
r();
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
l.classList.remove("hide"), hn(i, l);
|
|
1333
|
+
},
|
|
1334
|
+
destroy: () => {
|
|
1335
|
+
l.removeEventListener("mousedown", s), l.remove();
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
}), bn = (o) => o.type.name === "paragraph" && o.nodeSize === 2, Cn = (o) => o.type.name === "paragraph", yn = new O("plugin_autoInsertZeroSpace"), kn = () => new B({
|
|
1340
|
+
key: yn,
|
|
1341
|
+
props: {
|
|
1342
|
+
handleDOMEvents: {
|
|
1343
|
+
compositionstart(o) {
|
|
1344
|
+
const { state: e, dispatch: t } = o, { tr: n, selection: l } = e, { $from: s } = l;
|
|
1345
|
+
return xe.safari && M(e) && l.empty && bn(s.parent) && t(n.insertText("\u2060", s.start())), !1;
|
|
1346
|
+
},
|
|
1347
|
+
compositionend(o) {
|
|
1348
|
+
const { state: e, dispatch: t } = o, { tr: n, selection: l } = e, { $from: s } = l;
|
|
1349
|
+
return xe.safari && M(e) && l.empty && Cn(s.parent) && s.parent.textContent.startsWith("\u2060") && t(n.delete(s.start(), s.start() + 1)), !1;
|
|
1565
1350
|
}
|
|
1566
1351
|
}
|
|
1567
1352
|
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1353
|
+
});
|
|
1354
|
+
class An {
|
|
1355
|
+
constructor(e, t) {
|
|
1356
|
+
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")), ue(e, this.colgroup, this.table, t), this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
1572
1357
|
}
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1358
|
+
update(e) {
|
|
1359
|
+
return e.type != this.node.type ? !1 : (this.node = e, ue(e, this.colgroup, this.table, this.cellMinWidth), !0);
|
|
1360
|
+
}
|
|
1361
|
+
ignoreMutation(e) {
|
|
1362
|
+
return e.type == "attributes" && (e.target == this.table || this.colgroup.contains(e.target));
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
function ue(o, e, t, n, l, s) {
|
|
1366
|
+
var d;
|
|
1367
|
+
let r = 0, a = !0, i = e.firstChild;
|
|
1368
|
+
const c = o.firstChild;
|
|
1369
|
+
for (let u = 0, f = 0; u < c.childCount; u++) {
|
|
1370
|
+
const { colspan: p, colwidth: h } = c.child(u).attrs;
|
|
1371
|
+
for (let b = 0; b < p; b++, f++) {
|
|
1372
|
+
const w = l == f ? s : h && h[b], C = w ? w + "px" : "";
|
|
1373
|
+
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;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
for (; i; ) {
|
|
1377
|
+
const u = i.nextSibling;
|
|
1378
|
+
(d = i.parentNode) == null || d.removeChild(i), i = u;
|
|
1579
1379
|
}
|
|
1380
|
+
a ? (t.style.width = r + "px", t.style.minWidth = "") : (t.style.width = "", t.style.minWidth = r + "px");
|
|
1580
1381
|
}
|
|
1581
|
-
const
|
|
1582
|
-
function
|
|
1583
|
-
handleWidth = 5,
|
|
1584
|
-
cellMinWidth = 25,
|
|
1585
|
-
View =
|
|
1586
|
-
lastColumnResizable =
|
|
1382
|
+
const k = new O("tableColumnResizing");
|
|
1383
|
+
function Mn({
|
|
1384
|
+
handleWidth: o = 5,
|
|
1385
|
+
cellMinWidth: e = 25,
|
|
1386
|
+
View: t = An,
|
|
1387
|
+
lastColumnResizable: n = !0
|
|
1587
1388
|
} = {}) {
|
|
1588
|
-
|
|
1589
|
-
key,
|
|
1389
|
+
return new B({
|
|
1390
|
+
key: k,
|
|
1590
1391
|
state: {
|
|
1591
|
-
init(
|
|
1592
|
-
this.spec.props.nodeViews[
|
|
1593
|
-
return new ResizeState(-1, false);
|
|
1392
|
+
init(s, r) {
|
|
1393
|
+
return this.spec.props.nodeViews[A(r.schema).table.name] = (a) => new t(a, e), new q(-1, !1);
|
|
1594
1394
|
},
|
|
1595
|
-
apply(
|
|
1596
|
-
return
|
|
1395
|
+
apply(s, r) {
|
|
1396
|
+
return r.apply(s);
|
|
1597
1397
|
}
|
|
1598
1398
|
},
|
|
1599
1399
|
props: {
|
|
1600
|
-
attributes(
|
|
1601
|
-
|
|
1602
|
-
return pluginState.activeHandle > -1 ? { class: "resize-cursor" } : void 0;
|
|
1400
|
+
attributes(s) {
|
|
1401
|
+
return k.getState(s).activeHandle > -1 ? { class: "resize-cursor" } : void 0;
|
|
1603
1402
|
},
|
|
1604
1403
|
handleDOMEvents: {
|
|
1605
|
-
mousemove(
|
|
1606
|
-
|
|
1404
|
+
mousemove(s, r) {
|
|
1405
|
+
Nn(s, r, o, n);
|
|
1607
1406
|
},
|
|
1608
|
-
mouseleave(
|
|
1609
|
-
|
|
1407
|
+
mouseleave(s) {
|
|
1408
|
+
Sn(s);
|
|
1610
1409
|
},
|
|
1611
|
-
mousedown(
|
|
1612
|
-
|
|
1410
|
+
mousedown(s, r) {
|
|
1411
|
+
Rn(s, r, e);
|
|
1613
1412
|
}
|
|
1614
1413
|
},
|
|
1615
|
-
decorations(
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1618
|
-
return handleDecorations(state, pluginState.activeHandle);
|
|
1619
|
-
return null;
|
|
1414
|
+
decorations(s) {
|
|
1415
|
+
const r = k.getState(s);
|
|
1416
|
+
return r.activeHandle > -1 ? In(s, r.activeHandle) : null;
|
|
1620
1417
|
},
|
|
1621
1418
|
nodeViews: {}
|
|
1622
1419
|
}
|
|
1623
1420
|
});
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
if (
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
if (event.clientX - left <= handleWidth)
|
|
1657
|
-
cell = edgeCell(view, event, "left");
|
|
1658
|
-
else if (right - event.clientX <= handleWidth)
|
|
1659
|
-
cell = edgeCell(view, event, "right");
|
|
1660
|
-
}
|
|
1661
|
-
if (cell != pluginState.activeHandle) {
|
|
1662
|
-
if (!lastColumnResizable && cell !== -1) {
|
|
1663
|
-
const $cell = view.state.doc.resolve(cell);
|
|
1664
|
-
const table2 = $cell.node(-1), map = TableMap.get(table2), start = $cell.start(-1);
|
|
1665
|
-
const col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs["colspan"] - 1;
|
|
1666
|
-
if (col == map.width - 1) {
|
|
1421
|
+
}
|
|
1422
|
+
class q {
|
|
1423
|
+
constructor(e, t) {
|
|
1424
|
+
this.activeHandle = e, this.dragging = t, this.activeHandle = e, this.dragging = t;
|
|
1425
|
+
}
|
|
1426
|
+
apply(e) {
|
|
1427
|
+
let t = this;
|
|
1428
|
+
const n = e.getMeta(k);
|
|
1429
|
+
if (n && n.setHandle != null)
|
|
1430
|
+
return new q(n.setHandle, null);
|
|
1431
|
+
if (n && n.setDragging !== void 0)
|
|
1432
|
+
return new q(t.activeHandle, n.setDragging);
|
|
1433
|
+
if (t.activeHandle > -1 && e.docChanged) {
|
|
1434
|
+
let l = e.mapping.map(t.activeHandle, -1);
|
|
1435
|
+
de(e.doc.resolve(l)) || (l = 0), t = new q(l, t.dragging);
|
|
1436
|
+
}
|
|
1437
|
+
return t;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
function Nn(o, e, t, n) {
|
|
1441
|
+
const l = k.getState(o.state);
|
|
1442
|
+
if (!l.dragging) {
|
|
1443
|
+
const s = Tn(e.target);
|
|
1444
|
+
let r = -1;
|
|
1445
|
+
if (s) {
|
|
1446
|
+
const { left: a, right: i } = s.getBoundingClientRect();
|
|
1447
|
+
e.clientX - a <= t ? r = Fe(o, e, "left") : i - e.clientX <= t && (r = Fe(o, e, "right"));
|
|
1448
|
+
}
|
|
1449
|
+
if (r != l.activeHandle) {
|
|
1450
|
+
if (!n && r !== -1) {
|
|
1451
|
+
const a = o.state.doc.resolve(r), i = a.node(-1), c = g.get(i), d = a.start(-1);
|
|
1452
|
+
if (c.colCount(a.pos - d) + a.nodeAfter.attrs.colspan - 1 == c.width - 1)
|
|
1667
1453
|
return;
|
|
1668
|
-
}
|
|
1669
1454
|
}
|
|
1670
|
-
|
|
1455
|
+
nt(o, r);
|
|
1671
1456
|
}
|
|
1672
1457
|
}
|
|
1673
1458
|
}
|
|
1674
|
-
function
|
|
1675
|
-
const
|
|
1676
|
-
|
|
1677
|
-
updateHandle(view, -1);
|
|
1459
|
+
function Sn(o) {
|
|
1460
|
+
const e = k.getState(o.state);
|
|
1461
|
+
e.activeHandle > -1 && !e.dragging && nt(o, -1);
|
|
1678
1462
|
}
|
|
1679
|
-
function
|
|
1680
|
-
const
|
|
1681
|
-
if (
|
|
1682
|
-
return
|
|
1683
|
-
const
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
setDragging: { startX: event.clientX, startWidth: width }
|
|
1463
|
+
function Rn(o, e, t) {
|
|
1464
|
+
const n = k.getState(o.state);
|
|
1465
|
+
if (n.activeHandle == -1 || n.dragging)
|
|
1466
|
+
return !1;
|
|
1467
|
+
const l = o.state.doc.nodeAt(n.activeHandle), s = xn(o, n.activeHandle, l.attrs);
|
|
1468
|
+
o.dispatch(o.state.tr.setMeta(k, {
|
|
1469
|
+
setDragging: { startX: e.clientX, startWidth: s }
|
|
1687
1470
|
}));
|
|
1688
|
-
function
|
|
1689
|
-
window.removeEventListener("mouseup",
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
parts--;
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
return domWidth / parts;
|
|
1724
|
-
}
|
|
1725
|
-
function domCellAround(target) {
|
|
1726
|
-
while (target && target.nodeName != "TD" && target.nodeName != "TH")
|
|
1727
|
-
target = target.classList.contains("ProseMirror") ? null : target.parentNode;
|
|
1728
|
-
return target;
|
|
1729
|
-
}
|
|
1730
|
-
function edgeCell(view, event, side) {
|
|
1731
|
-
const found = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
1732
|
-
if (!found)
|
|
1471
|
+
function r(i) {
|
|
1472
|
+
window.removeEventListener("mouseup", r), window.removeEventListener("mousemove", a);
|
|
1473
|
+
const c = k.getState(o.state);
|
|
1474
|
+
c.dragging && (Ln(o, c.activeHandle, Be(c.dragging, i, t)), o.dispatch(o.state.tr.setMeta(k, { setDragging: null })));
|
|
1475
|
+
}
|
|
1476
|
+
function a(i) {
|
|
1477
|
+
if (!i.which)
|
|
1478
|
+
return r(i);
|
|
1479
|
+
const c = k.getState(o.state), d = Be(c.dragging, i, t);
|
|
1480
|
+
vn(o, c.activeHandle, d, t);
|
|
1481
|
+
}
|
|
1482
|
+
return window.addEventListener("mouseup", r), window.addEventListener("mousemove", a), e.preventDefault(), !0;
|
|
1483
|
+
}
|
|
1484
|
+
function xn(o, e, { colspan: t, colwidth: n }) {
|
|
1485
|
+
const l = n && n[n.length - 1];
|
|
1486
|
+
if (l)
|
|
1487
|
+
return l;
|
|
1488
|
+
const s = o.domAtPos(e);
|
|
1489
|
+
let a = s.node.childNodes[s.offset].offsetWidth, i = t;
|
|
1490
|
+
if (n)
|
|
1491
|
+
for (let c = 0; c < t; c++)
|
|
1492
|
+
n[c] && (a -= n[c], i--);
|
|
1493
|
+
return a / i;
|
|
1494
|
+
}
|
|
1495
|
+
function Tn(o) {
|
|
1496
|
+
for (; o && o.nodeName != "TD" && o.nodeName != "TH"; )
|
|
1497
|
+
o = o.classList.contains("ProseMirror") ? null : o.parentNode;
|
|
1498
|
+
return o;
|
|
1499
|
+
}
|
|
1500
|
+
function Fe(o, e, t) {
|
|
1501
|
+
const n = o.posAtCoords({ left: e.clientX, top: e.clientY });
|
|
1502
|
+
if (!n)
|
|
1733
1503
|
return -1;
|
|
1734
|
-
const { pos } =
|
|
1735
|
-
|
|
1736
|
-
if (!$cell)
|
|
1504
|
+
const { pos: l } = n, s = U(o.state.doc.resolve(l));
|
|
1505
|
+
if (!s)
|
|
1737
1506
|
return -1;
|
|
1738
|
-
if (
|
|
1739
|
-
return
|
|
1740
|
-
const
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
const tr = view.state.tr;
|
|
1756
|
-
for (let row = 0; row < map.height; row++) {
|
|
1757
|
-
const mapIndex = row * map.width + col;
|
|
1758
|
-
if (row && map.map[mapIndex] == map.map[mapIndex - map.width])
|
|
1507
|
+
if (t == "right")
|
|
1508
|
+
return s.pos;
|
|
1509
|
+
const r = g.get(s.node(-1)), a = s.start(-1), i = r.map.indexOf(s.pos - a);
|
|
1510
|
+
return i % r.width == 0 ? -1 : a + r.map[i - 1];
|
|
1511
|
+
}
|
|
1512
|
+
function Be(o, e, t) {
|
|
1513
|
+
const n = e.clientX - o.startX;
|
|
1514
|
+
return Math.max(t, o.startWidth + n);
|
|
1515
|
+
}
|
|
1516
|
+
function nt(o, e) {
|
|
1517
|
+
o.dispatch(o.state.tr.setMeta(k, { setHandle: e }));
|
|
1518
|
+
}
|
|
1519
|
+
function Ln(o, e, t) {
|
|
1520
|
+
const n = o.state.doc.resolve(e), l = n.node(-1), s = g.get(l), r = n.start(-1), a = s.colCount(n.pos - r) + n.nodeAfter.attrs.colspan - 1, i = o.state.tr;
|
|
1521
|
+
for (let c = 0; c < s.height; c++) {
|
|
1522
|
+
const d = c * s.width + a;
|
|
1523
|
+
if (c && s.map[d] == s.map[d - s.width])
|
|
1759
1524
|
continue;
|
|
1760
|
-
const
|
|
1761
|
-
|
|
1762
|
-
if (attrs["colwidth"] && attrs["colwidth"][index] == width)
|
|
1525
|
+
const u = s.map[d], { attrs: f } = l.nodeAt(u), p = f.colspan == 1 ? 0 : a - s.colCount(u);
|
|
1526
|
+
if (f.colwidth && f.colwidth[p] == t)
|
|
1763
1527
|
continue;
|
|
1764
|
-
const
|
|
1765
|
-
|
|
1766
|
-
tr.setNodeMarkup(start + pos, null, setAttr(attrs, "colwidth", colwidth));
|
|
1767
|
-
}
|
|
1768
|
-
if (tr.docChanged)
|
|
1769
|
-
view.dispatch(tr);
|
|
1770
|
-
}
|
|
1771
|
-
function displayColumnWidth(view, cell, width, cellMinWidth) {
|
|
1772
|
-
const $cell = view.state.doc.resolve(cell);
|
|
1773
|
-
const table2 = $cell.node(-1), start = $cell.start(-1);
|
|
1774
|
-
const col = TableMap.get(table2).colCount($cell.pos - start) + $cell.nodeAfter.attrs["colspan"] - 1;
|
|
1775
|
-
let dom = view.domAtPos($cell.start(-1)).node;
|
|
1776
|
-
while (dom.nodeName != "TABLE")
|
|
1777
|
-
dom = dom.parentNode;
|
|
1778
|
-
updateColumns(table2, dom.firstChild, dom, cellMinWidth, col, width);
|
|
1779
|
-
}
|
|
1780
|
-
function zeroes(n) {
|
|
1781
|
-
const result = [];
|
|
1782
|
-
for (let i = 0; i < n; i++)
|
|
1783
|
-
result.push(0);
|
|
1784
|
-
return result;
|
|
1785
|
-
}
|
|
1786
|
-
function handleDecorations(state, cell) {
|
|
1787
|
-
const decorations = [];
|
|
1788
|
-
const $cell = state.doc.resolve(cell);
|
|
1789
|
-
const table2 = $cell.node(-1), map = TableMap.get(table2), start = $cell.start(-1);
|
|
1790
|
-
const col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs["colspan"];
|
|
1791
|
-
for (let row = 0; row < map.height; row++) {
|
|
1792
|
-
const index = col + row * map.width - 1;
|
|
1793
|
-
if ((col == map.width || map.map[index] != map.map[index + 1]) && (row == 0 || map.map[index - 1] != map.map[index - 1 - map.width])) {
|
|
1794
|
-
const cellPos = map.map[index];
|
|
1795
|
-
const pos = start + cellPos + table2.nodeAt(cellPos).nodeSize - 1;
|
|
1796
|
-
const dom = document.createElement("div");
|
|
1797
|
-
dom.className = "column-resize-handle";
|
|
1798
|
-
decorations.push(Decoration.widget(pos, dom));
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
return DecorationSet.create(state.doc, decorations);
|
|
1802
|
-
}
|
|
1803
|
-
function selectedRect(state) {
|
|
1804
|
-
const sel = state.selection, $pos = selectionCell(state);
|
|
1805
|
-
const table2 = $pos.node(-1), tableStart = $pos.start(-1), map = TableMap.get(table2);
|
|
1806
|
-
let rect;
|
|
1807
|
-
if (sel instanceof CellSelection)
|
|
1808
|
-
rect = map.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart);
|
|
1809
|
-
else
|
|
1810
|
-
rect = map.findCell($pos.pos - tableStart);
|
|
1811
|
-
rect.tableStart = tableStart;
|
|
1812
|
-
rect.map = map;
|
|
1813
|
-
rect.table = table2;
|
|
1814
|
-
return rect;
|
|
1815
|
-
}
|
|
1816
|
-
function addColumn(tr, { map, tableStart, table: table2 }, col) {
|
|
1817
|
-
map = map;
|
|
1818
|
-
table2 = table2;
|
|
1819
|
-
tableStart = tableStart;
|
|
1820
|
-
let refColumn = col > 0 ? -1 : 0;
|
|
1821
|
-
if (columnIsHeader(map, table2, col + refColumn))
|
|
1822
|
-
refColumn = col == 0 || col == map.width ? null : 0;
|
|
1823
|
-
for (let row = 0; row < map.height; row++) {
|
|
1824
|
-
const index = row * map.width + col;
|
|
1825
|
-
if (col > 0 && col < map.width && map.map[index - 1] == map.map[index]) {
|
|
1826
|
-
const pos = map.map[index], cell = table2.nodeAt(pos);
|
|
1827
|
-
tr.setNodeMarkup(tr.mapping.map(tableStart + pos), null, addColSpan(cell.attrs, col - map.colCount(pos)));
|
|
1828
|
-
row += cell.attrs["rowspan"] - 1;
|
|
1829
|
-
} else {
|
|
1830
|
-
const offset = map.map[index + refColumn];
|
|
1831
|
-
const type = refColumn == null ? tableNodeTypes(table2.type.schema).cell : table2.nodeAt(offset).type;
|
|
1832
|
-
const pos = map.positionAt(row, col, table2);
|
|
1833
|
-
tr.insert(tr.mapping.map(tableStart + pos), type.createAndFill());
|
|
1834
|
-
}
|
|
1528
|
+
const h = f.colwidth ? f.colwidth.slice() : En(f.colspan);
|
|
1529
|
+
h[p] = t, i.setNodeMarkup(r + u, null, y(f, "colwidth", h));
|
|
1835
1530
|
}
|
|
1836
|
-
|
|
1531
|
+
i.docChanged && o.dispatch(i);
|
|
1837
1532
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
}
|
|
1845
|
-
return true;
|
|
1846
|
-
};
|
|
1847
|
-
const addColumnAfter = (state, dispatch) => {
|
|
1848
|
-
if (!isInTable(state))
|
|
1849
|
-
return false;
|
|
1850
|
-
if (dispatch) {
|
|
1851
|
-
const rect = selectedRect(state);
|
|
1852
|
-
dispatch(addColumn(state.tr, rect, rect.right));
|
|
1853
|
-
}
|
|
1854
|
-
return true;
|
|
1855
|
-
};
|
|
1856
|
-
function removeColumn(tr, { map, table: table2, tableStart }, col) {
|
|
1857
|
-
map = map;
|
|
1858
|
-
table2 = table2;
|
|
1859
|
-
tableStart = tableStart;
|
|
1860
|
-
const mapStart = tr.mapping.maps.length;
|
|
1861
|
-
for (let row = 0; row < map.height; ) {
|
|
1862
|
-
const index = row * map.width + col, pos = map.map[index], cell = table2.nodeAt(pos);
|
|
1863
|
-
if (col > 0 && map.map[index - 1] == pos || col < map.width - 1 && map.map[index + 1] == pos) {
|
|
1864
|
-
tr.setNodeMarkup(tr.mapping.slice(mapStart).map(tableStart + pos), null, removeColSpan(cell.attrs, col - map.colCount(pos)));
|
|
1865
|
-
} else {
|
|
1866
|
-
const start = tr.mapping.slice(mapStart).map(tableStart + pos);
|
|
1867
|
-
tr.delete(start, start + cell.nodeSize);
|
|
1868
|
-
}
|
|
1869
|
-
row += cell.attrs["rowspan"];
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
const deleteColumn = (state, dispatch) => {
|
|
1873
|
-
if (!isInTable(state))
|
|
1874
|
-
return false;
|
|
1875
|
-
if (dispatch) {
|
|
1876
|
-
const rect = selectedRect(state), tr = state.tr;
|
|
1877
|
-
if (rect.left == 0 && rect.right == rect.map.width)
|
|
1878
|
-
return false;
|
|
1879
|
-
for (let i = rect.right - 1; ; i--) {
|
|
1880
|
-
removeColumn(tr, rect, i);
|
|
1881
|
-
if (i == rect.left)
|
|
1882
|
-
break;
|
|
1883
|
-
rect.table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
1884
|
-
rect.map = TableMap.get(rect.table);
|
|
1885
|
-
}
|
|
1886
|
-
dispatch(tr);
|
|
1887
|
-
}
|
|
1888
|
-
return true;
|
|
1889
|
-
};
|
|
1890
|
-
function removeRow(tr, { map, tableStart, table: table2 }, row) {
|
|
1891
|
-
map = map;
|
|
1892
|
-
table2 = table2;
|
|
1893
|
-
tableStart = tableStart;
|
|
1894
|
-
let rowPos = 0;
|
|
1895
|
-
for (let i = 0; i < row; i++)
|
|
1896
|
-
rowPos += table2.child(i).nodeSize;
|
|
1897
|
-
const nextRow = rowPos + table2.child(row).nodeSize;
|
|
1898
|
-
const mapFrom = tr.mapping.maps.length;
|
|
1899
|
-
tr.delete(rowPos + tableStart, nextRow + tableStart);
|
|
1900
|
-
for (let col = 0, index = row * map.width; col < map.width; col++, index++) {
|
|
1901
|
-
const pos = map.map[index];
|
|
1902
|
-
if (row > 0 && pos == map.map[index - map.width]) {
|
|
1903
|
-
const attrs = table2.nodeAt(pos).attrs;
|
|
1904
|
-
tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, setAttr(attrs, "rowspan", attrs["rowspan"] - 1));
|
|
1905
|
-
col += attrs["colspan"] - 1;
|
|
1906
|
-
} else if (row < map.width && pos == map.map[index + map.width]) {
|
|
1907
|
-
const cell = table2.nodeAt(pos);
|
|
1908
|
-
const copy = cell.type.create(setAttr(cell.attrs, "rowspan", cell.attrs["rowspan"] - 1), cell.content);
|
|
1909
|
-
const newPos = map.positionAt(row + 1, col, table2);
|
|
1910
|
-
tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy);
|
|
1911
|
-
col += cell.attrs["colspan"] - 1;
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1533
|
+
function vn(o, e, t, n) {
|
|
1534
|
+
const l = o.state.doc.resolve(e), s = l.node(-1), r = l.start(-1), a = g.get(s).colCount(l.pos - r) + l.nodeAfter.attrs.colspan - 1;
|
|
1535
|
+
let i = o.domAtPos(l.start(-1)).node;
|
|
1536
|
+
for (; i.nodeName != "TABLE"; )
|
|
1537
|
+
i = i.parentNode;
|
|
1538
|
+
ue(s, i.firstChild, i, n, a, t);
|
|
1914
1539
|
}
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
if (rect.top == 0 && rect.bottom == rect.map.height)
|
|
1921
|
-
return false;
|
|
1922
|
-
for (let i = rect.bottom - 1; ; i--) {
|
|
1923
|
-
removeRow(tr, rect, i);
|
|
1924
|
-
if (i == rect.top)
|
|
1925
|
-
break;
|
|
1926
|
-
rect.table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
1927
|
-
rect.map = TableMap.get(rect.table);
|
|
1928
|
-
}
|
|
1929
|
-
dispatch(tr);
|
|
1930
|
-
}
|
|
1931
|
-
return true;
|
|
1932
|
-
};
|
|
1933
|
-
function setCellAttr(name, value) {
|
|
1934
|
-
return (state, dispatch) => {
|
|
1935
|
-
if (!isInTable(state))
|
|
1936
|
-
return false;
|
|
1937
|
-
const $cell = selectionCell(state);
|
|
1938
|
-
if ($cell.nodeAfter.attrs[name] === value)
|
|
1939
|
-
return false;
|
|
1940
|
-
if (dispatch) {
|
|
1941
|
-
const tr = state.tr;
|
|
1942
|
-
if (state.selection instanceof CellSelection)
|
|
1943
|
-
state.selection.forEachCell((node, pos) => {
|
|
1944
|
-
if (node.attrs[name] !== value)
|
|
1945
|
-
tr.setNodeMarkup(pos, null, setAttr(node.attrs, name, value));
|
|
1946
|
-
});
|
|
1947
|
-
else
|
|
1948
|
-
tr.setNodeMarkup($cell.pos, null, setAttr($cell.nodeAfter.attrs, name, value));
|
|
1949
|
-
dispatch(tr);
|
|
1950
|
-
}
|
|
1951
|
-
return true;
|
|
1952
|
-
};
|
|
1540
|
+
function En(o) {
|
|
1541
|
+
const e = [];
|
|
1542
|
+
for (let t = 0; t < o; t++)
|
|
1543
|
+
e.push(0);
|
|
1544
|
+
return e;
|
|
1953
1545
|
}
|
|
1954
|
-
function
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
if (rowNode.childCount)
|
|
1962
|
-
return rowEnd - 1 - rowNode.lastChild.nodeSize;
|
|
1963
|
-
rowEnd -= rowNode.nodeSize;
|
|
1964
|
-
}
|
|
1965
|
-
} else {
|
|
1966
|
-
if ($cell.index() < $cell.parent.childCount - 1)
|
|
1967
|
-
return $cell.pos + $cell.nodeAfter.nodeSize;
|
|
1968
|
-
const table2 = $cell.node(-1);
|
|
1969
|
-
for (let row = $cell.indexAfter(-1), rowStart = $cell.after(); row < table2.childCount; row++) {
|
|
1970
|
-
const rowNode = table2.child(row);
|
|
1971
|
-
if (rowNode.childCount)
|
|
1972
|
-
return rowStart + 1;
|
|
1973
|
-
rowStart += rowNode.nodeSize;
|
|
1546
|
+
function In(o, e) {
|
|
1547
|
+
const t = [], n = o.doc.resolve(e), l = n.node(-1), s = g.get(l), r = n.start(-1), a = s.colCount(n.pos - r) + n.nodeAfter.attrs.colspan;
|
|
1548
|
+
for (let i = 0; i < s.height; i++) {
|
|
1549
|
+
const c = a + i * s.width - 1;
|
|
1550
|
+
if ((a == s.width || s.map[c] != s.map[c + 1]) && (i == 0 || s.map[c - 1] != s.map[c - 1 - s.width])) {
|
|
1551
|
+
const d = s.map[c], u = r + d + l.nodeAt(d).nodeSize - 1, f = document.createElement("div");
|
|
1552
|
+
f.className = "column-resize-handle", t.push(ke.widget(u, f));
|
|
1974
1553
|
}
|
|
1975
1554
|
}
|
|
1976
|
-
return;
|
|
1977
|
-
}
|
|
1978
|
-
function goToNextCell(direction) {
|
|
1979
|
-
return (state, dispatch) => {
|
|
1980
|
-
if (!isInTable(state))
|
|
1981
|
-
return false;
|
|
1982
|
-
const cell = findNextCell(selectionCell(state), direction);
|
|
1983
|
-
if (cell == null)
|
|
1984
|
-
return false;
|
|
1985
|
-
if (dispatch) {
|
|
1986
|
-
const $cell = state.doc.resolve(cell);
|
|
1987
|
-
dispatch(state.tr.setSelection(TextSelection.between($cell, moveCellForward($cell))).scrollIntoView());
|
|
1988
|
-
}
|
|
1989
|
-
return true;
|
|
1990
|
-
};
|
|
1555
|
+
return Ae.create(o.doc, t);
|
|
1991
1556
|
}
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
for (let d = $pos.depth; d > 0; d--) {
|
|
1995
|
-
const node = $pos.node(d);
|
|
1996
|
-
if (node.type.spec["tableRole"] == "table") {
|
|
1997
|
-
if (dispatch)
|
|
1998
|
-
dispatch(state.tr.delete($pos.before(d), $pos.after(d)).scrollIntoView());
|
|
1999
|
-
return true;
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
return false;
|
|
2003
|
-
};
|
|
2004
|
-
function pastedCells(slice) {
|
|
2005
|
-
if (!slice.size)
|
|
1557
|
+
function $n(o) {
|
|
1558
|
+
if (!o.size)
|
|
2006
1559
|
return null;
|
|
2007
|
-
let { content, openStart, openEnd } =
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
if (left || right)
|
|
2021
|
-
cells = fitSlice(tableNodeTypes(schema2).row, new Slice(cells, left, right)).content;
|
|
2022
|
-
rows.push(cells);
|
|
2023
|
-
}
|
|
2024
|
-
} else if (role == "cell" || role == "header_cell") {
|
|
2025
|
-
rows.push(openStart || openEnd ? fitSlice(tableNodeTypes(schema2).row, new Slice(content, openStart, openEnd)).content : content);
|
|
2026
|
-
} else {
|
|
1560
|
+
let { content: e, openStart: t, openEnd: n } = o;
|
|
1561
|
+
for (; e.childCount == 1 && (t > 0 && n > 0 || e.firstChild.type.spec.tableRole == "table"); )
|
|
1562
|
+
t--, n--, e = e.firstChild.content;
|
|
1563
|
+
const l = e.firstChild, s = l.type.spec.tableRole, r = l.type.schema, a = [];
|
|
1564
|
+
if (s == "row")
|
|
1565
|
+
for (let i = 0; i < e.childCount; i++) {
|
|
1566
|
+
let c = e.child(i).content;
|
|
1567
|
+
const d = i ? 0 : Math.max(0, t - 1), u = i < e.childCount - 1 ? 0 : Math.max(0, n - 1);
|
|
1568
|
+
(d || u) && (c = fe(A(r).row, new _(c, d, u)).content), a.push(c);
|
|
1569
|
+
}
|
|
1570
|
+
else if (s == "cell" || s == "header_cell")
|
|
1571
|
+
a.push(t || n ? fe(A(r).row, new _(e, t, n)).content : e);
|
|
1572
|
+
else
|
|
2027
1573
|
return null;
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
let
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
return
|
|
2055
|
-
}
|
|
2056
|
-
function
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
for (let col = added[row] || 0, i = 0; col < newWidth; i++) {
|
|
2067
|
-
let cell = frag.child(i % frag.childCount);
|
|
2068
|
-
if (col + cell.attrs["colspan"] > newWidth)
|
|
2069
|
-
cell = cell.type.create(removeColSpan(cell.attrs, cell.attrs["colspan"], col + cell.attrs["colspan"] - newWidth), cell.content);
|
|
2070
|
-
cells.push(cell);
|
|
2071
|
-
col += cell.attrs["colspan"];
|
|
2072
|
-
for (let j = 1; j < cell.attrs["rowspan"]; j++)
|
|
2073
|
-
added[row + j] = (added[row + j] || 0) + cell.attrs["colspan"];
|
|
2074
|
-
}
|
|
2075
|
-
newRows.push(Fragment.from(cells));
|
|
2076
|
-
}
|
|
2077
|
-
rows = newRows;
|
|
2078
|
-
width = newWidth;
|
|
2079
|
-
}
|
|
2080
|
-
if (height != newHeight) {
|
|
2081
|
-
const newRows = [];
|
|
2082
|
-
for (let row = 0, i = 0; row < newHeight; row++, i++) {
|
|
2083
|
-
const cells = [], source = rows[i % height];
|
|
2084
|
-
for (let j = 0; j < source.childCount; j++) {
|
|
2085
|
-
let cell = source.child(j);
|
|
2086
|
-
if (row + cell.attrs["rowspan"] > newHeight)
|
|
2087
|
-
cell = cell.type.create(setAttr(cell.attrs, "rowspan", Math.max(1, newHeight - cell.attrs["rowspan"])), cell.content);
|
|
2088
|
-
cells.push(cell);
|
|
1574
|
+
return Dn(r, a);
|
|
1575
|
+
}
|
|
1576
|
+
function Dn(o, e) {
|
|
1577
|
+
const t = [];
|
|
1578
|
+
for (let l = 0; l < e.length; l++) {
|
|
1579
|
+
const s = e[l];
|
|
1580
|
+
for (let r = s.childCount - 1; r >= 0; r--) {
|
|
1581
|
+
const { rowspan: a, colspan: i } = s.child(r).attrs;
|
|
1582
|
+
for (let c = l; c < l + a; c++)
|
|
1583
|
+
t[c] = (t[c] || 0) + i;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
let n = 0;
|
|
1587
|
+
for (let l = 0; l < t.length; l++)
|
|
1588
|
+
n = Math.max(n, t[l]);
|
|
1589
|
+
for (let l = 0; l < t.length; l++)
|
|
1590
|
+
if (l >= e.length && e.push(E.empty), t[l] < n) {
|
|
1591
|
+
const s = A(o).cell.createAndFill(), r = [];
|
|
1592
|
+
for (let a = t[l]; a < n; a++)
|
|
1593
|
+
r.push(s);
|
|
1594
|
+
e[l] = e[l].append(E.from(r));
|
|
1595
|
+
}
|
|
1596
|
+
return { height: e.length, width: n, rows: e };
|
|
1597
|
+
}
|
|
1598
|
+
function fe(o, e) {
|
|
1599
|
+
const t = o.createAndFill();
|
|
1600
|
+
return new St(t).replace(0, t.content.size, e).doc;
|
|
1601
|
+
}
|
|
1602
|
+
function _n({ width: o, height: e, rows: t }, n, l) {
|
|
1603
|
+
if (o != n) {
|
|
1604
|
+
const s = [], r = [];
|
|
1605
|
+
for (let a = 0; a < t.length; a++) {
|
|
1606
|
+
const i = t[a], c = [];
|
|
1607
|
+
for (let d = s[a] || 0, u = 0; d < n; u++) {
|
|
1608
|
+
let f = i.child(u % i.childCount);
|
|
1609
|
+
d + f.attrs.colspan > n && (f = f.type.create(F(f.attrs, f.attrs.colspan, d + f.attrs.colspan - n), f.content)), c.push(f), d += f.attrs.colspan;
|
|
1610
|
+
for (let p = 1; p < f.attrs.rowspan; p++)
|
|
1611
|
+
s[a + p] = (s[a + p] || 0) + f.attrs.colspan;
|
|
2089
1612
|
}
|
|
2090
|
-
|
|
2091
|
-
}
|
|
2092
|
-
rows = newRows;
|
|
2093
|
-
height = newHeight;
|
|
2094
|
-
}
|
|
2095
|
-
return { width, height, rows };
|
|
2096
|
-
}
|
|
2097
|
-
function growTable(tr, map, table2, start, width, height, mapFrom) {
|
|
2098
|
-
const schema2 = tr.doc.type.schema, types = tableNodeTypes(schema2);
|
|
2099
|
-
let empty, emptyHead;
|
|
2100
|
-
if (width > map.width) {
|
|
2101
|
-
for (let row = 0, rowEnd = 0; row < map.height; row++) {
|
|
2102
|
-
const rowNode = table2.child(row);
|
|
2103
|
-
rowEnd += rowNode.nodeSize;
|
|
2104
|
-
const cells = [];
|
|
2105
|
-
let add;
|
|
2106
|
-
if (rowNode.lastChild == null || rowNode.lastChild.type == types.cell)
|
|
2107
|
-
add = empty || (empty = types.cell.createAndFill());
|
|
2108
|
-
else
|
|
2109
|
-
add = emptyHead || (emptyHead = types.header_cell.createAndFill());
|
|
2110
|
-
for (let i = map.width; i < width; i++)
|
|
2111
|
-
cells.push(add);
|
|
2112
|
-
tr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start), cells);
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
|
-
if (height > map.height) {
|
|
2116
|
-
const cells = [];
|
|
2117
|
-
for (let i = 0, start2 = (map.height - 1) * map.width; i < Math.max(map.width, width); i++) {
|
|
2118
|
-
const header = i >= map.width ? false : table2.nodeAt(map.map[start2 + i]).type == types.header_cell;
|
|
2119
|
-
cells.push(header ? emptyHead || (emptyHead = types.header_cell.createAndFill()) : empty || (empty = types.cell.createAndFill()));
|
|
2120
|
-
}
|
|
2121
|
-
const emptyRow = types.row.create(null, Fragment.from(cells)), rows = [];
|
|
2122
|
-
for (let i = map.height; i < height; i++)
|
|
2123
|
-
rows.push(emptyRow);
|
|
2124
|
-
tr.insert(tr.mapping.slice(mapFrom).map(start + table2.nodeSize - 2), rows);
|
|
2125
|
-
}
|
|
2126
|
-
return !!(empty || emptyHead);
|
|
2127
|
-
}
|
|
2128
|
-
function isolateHorizontal(tr, map, table2, start, left, right, top, mapFrom) {
|
|
2129
|
-
if (top == 0 || top == map.height)
|
|
2130
|
-
return false;
|
|
2131
|
-
let found = false;
|
|
2132
|
-
for (let col = left; col < right; col++) {
|
|
2133
|
-
const index = top * map.width + col, pos = map.map[index];
|
|
2134
|
-
if (map.map[index - map.width] == pos) {
|
|
2135
|
-
found = true;
|
|
2136
|
-
const cell = table2.nodeAt(pos);
|
|
2137
|
-
const { top: cellTop, left: cellLeft } = map.findCell(pos);
|
|
2138
|
-
tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + start), null, setAttr(cell.attrs, "rowspan", top - cellTop));
|
|
2139
|
-
tr.insert(tr.mapping.slice(mapFrom).map(map.positionAt(top, cellLeft, table2)), cell.type.createAndFill(setAttr(cell.attrs, "rowspan", cellTop + cell.attrs["rowspan"] - top)));
|
|
2140
|
-
col += cell.attrs["colspan"] - 1;
|
|
1613
|
+
r.push(E.from(c));
|
|
2141
1614
|
}
|
|
1615
|
+
t = r, o = n;
|
|
2142
1616
|
}
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
const index = row * map.width + left, pos = map.map[index];
|
|
2151
|
-
if (map.map[index - 1] == pos) {
|
|
2152
|
-
found = true;
|
|
2153
|
-
const cell = table2.nodeAt(pos), cellLeft = map.colCount(pos);
|
|
2154
|
-
const updatePos = tr.mapping.slice(mapFrom).map(pos + start);
|
|
2155
|
-
tr.setNodeMarkup(updatePos, null, removeColSpan(cell.attrs, left - cellLeft, cell.attrs["colspan"] - (left - cellLeft)));
|
|
2156
|
-
tr.insert(updatePos + cell.nodeSize, cell.type.createAndFill(removeColSpan(cell.attrs, 0, left - cellLeft)));
|
|
2157
|
-
row += cell.attrs["rowspan"] - 1;
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
return found;
|
|
2161
|
-
}
|
|
2162
|
-
function insertCells(state, dispatch, tableStart, rect, cells) {
|
|
2163
|
-
let table2 = tableStart ? state.doc.nodeAt(tableStart - 1) : state.doc, map = TableMap.get(table2);
|
|
2164
|
-
const { top, left } = rect;
|
|
2165
|
-
const right = left + cells.width, bottom = top + cells.height;
|
|
2166
|
-
const tr = state.tr;
|
|
2167
|
-
let mapFrom = 0;
|
|
2168
|
-
function recomp() {
|
|
2169
|
-
table2 = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;
|
|
2170
|
-
map = TableMap.get(table2);
|
|
2171
|
-
mapFrom = tr.mapping.maps.length;
|
|
2172
|
-
}
|
|
2173
|
-
if (growTable(tr, map, table2, tableStart, right, bottom, mapFrom))
|
|
2174
|
-
recomp();
|
|
2175
|
-
if (isolateHorizontal(tr, map, table2, tableStart, left, right, top, mapFrom))
|
|
2176
|
-
recomp();
|
|
2177
|
-
if (isolateHorizontal(tr, map, table2, tableStart, left, right, bottom, mapFrom))
|
|
2178
|
-
recomp();
|
|
2179
|
-
if (isolateVertical(tr, map, table2, tableStart, top, bottom, left, mapFrom))
|
|
2180
|
-
recomp();
|
|
2181
|
-
if (isolateVertical(tr, map, table2, tableStart, top, bottom, right, mapFrom))
|
|
2182
|
-
recomp();
|
|
2183
|
-
for (let row = top; row < bottom; row++) {
|
|
2184
|
-
const from = map.positionAt(row, left, table2), to = map.positionAt(row, right, table2);
|
|
2185
|
-
tr.replace(tr.mapping.slice(mapFrom).map(from + tableStart), tr.mapping.slice(mapFrom).map(to + tableStart), new Slice(cells.rows[row - top], 0, 0));
|
|
2186
|
-
}
|
|
2187
|
-
recomp();
|
|
2188
|
-
tr.setSelection(new CellSelection(tr.doc.resolve(tableStart + map.positionAt(top, left, table2)), tr.doc.resolve(tableStart + map.positionAt(bottom - 1, right - 1, table2))));
|
|
2189
|
-
dispatch(tr);
|
|
2190
|
-
}
|
|
2191
|
-
const fixTablesKey = new PluginKey("fix-tables");
|
|
2192
|
-
function changedDescendants(old, cur, offset, f) {
|
|
2193
|
-
const oldSize = old.childCount, curSize = cur.childCount;
|
|
2194
|
-
outer:
|
|
2195
|
-
for (let i = 0, j = 0; i < curSize; i++) {
|
|
2196
|
-
const child = cur.child(i);
|
|
2197
|
-
for (let scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) {
|
|
2198
|
-
if (old.child(scan) == child) {
|
|
2199
|
-
j = scan + 1;
|
|
2200
|
-
offset += child.nodeSize;
|
|
2201
|
-
continue outer;
|
|
2202
|
-
}
|
|
1617
|
+
if (e != l) {
|
|
1618
|
+
const s = [];
|
|
1619
|
+
for (let r = 0, a = 0; r < l; r++, a++) {
|
|
1620
|
+
const i = [], c = t[a % e];
|
|
1621
|
+
for (let d = 0; d < c.childCount; d++) {
|
|
1622
|
+
let u = c.child(d);
|
|
1623
|
+
r + u.attrs.rowspan > l && (u = u.type.create(y(u.attrs, "rowspan", Math.max(1, l - u.attrs.rowspan)), u.content)), i.push(u);
|
|
2203
1624
|
}
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
1625
|
+
s.push(E.from(i));
|
|
1626
|
+
}
|
|
1627
|
+
t = s, e = l;
|
|
1628
|
+
}
|
|
1629
|
+
return { width: o, height: e, rows: t };
|
|
1630
|
+
}
|
|
1631
|
+
function On(o, e, t, n, l, s, r) {
|
|
1632
|
+
const a = o.doc.type.schema, i = A(a);
|
|
1633
|
+
let c, d;
|
|
1634
|
+
if (l > e.width)
|
|
1635
|
+
for (let u = 0, f = 0; u < e.height; u++) {
|
|
1636
|
+
const p = t.child(u);
|
|
1637
|
+
f += p.nodeSize;
|
|
1638
|
+
const h = [];
|
|
1639
|
+
let b;
|
|
1640
|
+
p.lastChild == null || p.lastChild.type == i.cell ? b = c || (c = i.cell.createAndFill()) : b = d || (d = i.header_cell.createAndFill());
|
|
1641
|
+
for (let w = e.width; w < l; w++)
|
|
1642
|
+
h.push(b);
|
|
1643
|
+
o.insert(o.mapping.slice(r).map(f - 1 + n), h);
|
|
1644
|
+
}
|
|
1645
|
+
if (s > e.height) {
|
|
1646
|
+
const u = [];
|
|
1647
|
+
for (let h = 0, b = (e.height - 1) * e.width; h < Math.max(e.width, l); h++) {
|
|
1648
|
+
const w = h >= e.width ? !1 : t.nodeAt(e.map[b + h]).type == i.header_cell;
|
|
1649
|
+
u.push(w ? d || (d = i.header_cell.createAndFill()) : c || (c = i.cell.createAndFill()));
|
|
1650
|
+
}
|
|
1651
|
+
const f = i.row.create(null, E.from(u)), p = [];
|
|
1652
|
+
for (let h = e.height; h < s; h++)
|
|
1653
|
+
p.push(f);
|
|
1654
|
+
o.insert(o.mapping.slice(r).map(n + t.nodeSize - 2), p);
|
|
1655
|
+
}
|
|
1656
|
+
return !!(c || d);
|
|
1657
|
+
}
|
|
1658
|
+
function Pe(o, e, t, n, l, s, r, a) {
|
|
1659
|
+
if (r == 0 || r == e.height)
|
|
1660
|
+
return !1;
|
|
1661
|
+
let i = !1;
|
|
1662
|
+
for (let c = l; c < s; c++) {
|
|
1663
|
+
const d = r * e.width + c, u = e.map[d];
|
|
1664
|
+
if (e.map[d - e.width] == u) {
|
|
1665
|
+
i = !0;
|
|
1666
|
+
const f = t.nodeAt(u), { top: p, left: h } = e.findCell(u);
|
|
1667
|
+
o.setNodeMarkup(o.mapping.slice(a).map(u + n), null, y(f.attrs, "rowspan", r - p)), o.insert(o.mapping.slice(a).map(e.positionAt(r, h, t)), f.type.createAndFill(y(f.attrs, "rowspan", p + f.attrs.rowspan - r))), c += f.attrs.colspan - 1;
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
return i;
|
|
1671
|
+
}
|
|
1672
|
+
function We(o, e, t, n, l, s, r, a) {
|
|
1673
|
+
if (r == 0 || r == e.width)
|
|
1674
|
+
return !1;
|
|
1675
|
+
let i = !1;
|
|
1676
|
+
for (let c = l; c < s; c++) {
|
|
1677
|
+
const d = c * e.width + r, u = e.map[d];
|
|
1678
|
+
if (e.map[d - 1] == u) {
|
|
1679
|
+
i = !0;
|
|
1680
|
+
const f = t.nodeAt(u), p = e.colCount(u), h = o.mapping.slice(a).map(u + n);
|
|
1681
|
+
o.setNodeMarkup(h, null, F(f.attrs, r - p, f.attrs.colspan - (r - p))), o.insert(h + f.nodeSize, f.type.createAndFill(F(f.attrs, 0, r - p))), c += f.attrs.rowspan - 1;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
return i;
|
|
1685
|
+
}
|
|
1686
|
+
function He(o, e, t, n, l) {
|
|
1687
|
+
let s = t ? o.doc.nodeAt(t - 1) : o.doc, r = g.get(s);
|
|
1688
|
+
const { top: a, left: i } = n, c = i + l.width, d = a + l.height, u = o.tr;
|
|
1689
|
+
let f = 0;
|
|
1690
|
+
function p() {
|
|
1691
|
+
s = t ? u.doc.nodeAt(t - 1) : u.doc, r = g.get(s), f = u.mapping.maps.length;
|
|
1692
|
+
}
|
|
1693
|
+
On(u, r, s, t, c, d, f) && p(), Pe(u, r, s, t, i, c, a, f) && p(), Pe(u, r, s, t, i, c, d, f) && p(), We(u, r, s, t, a, d, i, f) && p(), We(u, r, s, t, a, d, c, f) && p();
|
|
1694
|
+
for (let h = a; h < d; h++) {
|
|
1695
|
+
const b = r.positionAt(h, i, s), w = r.positionAt(h, c, s);
|
|
1696
|
+
u.replace(u.mapping.slice(f).map(b + t), u.mapping.slice(f).map(w + t), new _(l.rows[h - a], 0, 0));
|
|
1697
|
+
}
|
|
1698
|
+
p(), u.setSelection(new m(u.doc.resolve(t + r.positionAt(a, i, s)), u.doc.resolve(t + r.positionAt(d - 1, c - 1, s)))), e(u);
|
|
1699
|
+
}
|
|
1700
|
+
const zn = new O("fix-tables");
|
|
1701
|
+
function ot(o, e, t, n) {
|
|
1702
|
+
const l = o.childCount, s = e.childCount;
|
|
1703
|
+
e:
|
|
1704
|
+
for (let r = 0, a = 0; r < s; r++) {
|
|
1705
|
+
const i = e.child(r);
|
|
1706
|
+
for (let c = a, d = Math.min(l, r + 3); c < d; c++)
|
|
1707
|
+
if (o.child(c) == i) {
|
|
1708
|
+
a = c + 1, t += i.nodeSize;
|
|
1709
|
+
continue e;
|
|
1710
|
+
}
|
|
1711
|
+
n(i, t), a < l && 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;
|
|
2210
1712
|
}
|
|
2211
1713
|
}
|
|
2212
|
-
function
|
|
2213
|
-
let
|
|
2214
|
-
const
|
|
2215
|
-
|
|
2216
|
-
tr = fixTable(state, node, pos, tr);
|
|
1714
|
+
function Fn(o, e) {
|
|
1715
|
+
let t;
|
|
1716
|
+
const n = (l, s) => {
|
|
1717
|
+
l.type.spec.tableRole == "table" && (t = Bn(o, l, s, t));
|
|
2217
1718
|
};
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
const
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
if (
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
} else if (
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
const tableEditingKey = new PluginKey("selectingCells");
|
|
2277
|
-
function domInCell(view, dom) {
|
|
2278
|
-
for (; dom && dom != view.dom; dom = dom.parentNode)
|
|
2279
|
-
if (dom.nodeName == "TD" || dom.nodeName == "TH")
|
|
2280
|
-
return dom;
|
|
2281
|
-
return;
|
|
2282
|
-
}
|
|
2283
|
-
function cellUnderMouse(view, event) {
|
|
2284
|
-
const mousePos = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
2285
|
-
if (!mousePos)
|
|
2286
|
-
return null;
|
|
2287
|
-
return mousePos ? cellAround(view.state.doc.resolve(mousePos.pos)) : null;
|
|
2288
|
-
}
|
|
2289
|
-
function handleMouseDown(view, event) {
|
|
2290
|
-
const startEvent = event;
|
|
2291
|
-
if (startEvent.ctrlKey || startEvent.metaKey)
|
|
1719
|
+
return e ? e.doc != o.doc && ot(e.doc, o.doc, 0, n) : o.doc.descendants(n), t;
|
|
1720
|
+
}
|
|
1721
|
+
function Bn(o, e, t, n) {
|
|
1722
|
+
const l = g.get(e);
|
|
1723
|
+
if (!l.problems)
|
|
1724
|
+
return n;
|
|
1725
|
+
n || (n = o.tr);
|
|
1726
|
+
const s = [];
|
|
1727
|
+
for (let i = 0; i < l.height; i++)
|
|
1728
|
+
s.push(0);
|
|
1729
|
+
for (let i = 0; i < l.problems.length; i++) {
|
|
1730
|
+
const c = l.problems[i];
|
|
1731
|
+
if (c.type == "collision") {
|
|
1732
|
+
const d = e.nodeAt(c.pos);
|
|
1733
|
+
for (let u = 0; u < d.attrs.rowspan; u++)
|
|
1734
|
+
s[c.row + u] += c.n;
|
|
1735
|
+
n.setNodeMarkup(n.mapping.map(t + 1 + c.pos), null, F(d.attrs, d.attrs.colspan - c.n, c.n));
|
|
1736
|
+
} else if (c.type == "missing")
|
|
1737
|
+
s[c.row] += c.n;
|
|
1738
|
+
else if (c.type == "overlong_rowspan") {
|
|
1739
|
+
const d = e.nodeAt(c.pos);
|
|
1740
|
+
n.setNodeMarkup(n.mapping.map(t + 1 + c.pos), null, y(d.attrs, "rowspan", d.attrs.rowspan - c.n));
|
|
1741
|
+
} else if (c.type == "colwidth mismatch") {
|
|
1742
|
+
const d = e.nodeAt(c.pos);
|
|
1743
|
+
n.setNodeMarkup(n.mapping.map(t + 1 + c.pos), null, y(d.attrs, "colwidth", c.colwidth));
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
let r, a;
|
|
1747
|
+
for (let i = 0; i < s.length; i++)
|
|
1748
|
+
s[i] && (r == null && (r = i), a = i);
|
|
1749
|
+
for (let i = 0, c = t + 1; i < l.height; i++) {
|
|
1750
|
+
const d = e.child(i), u = c + d.nodeSize, f = s[i];
|
|
1751
|
+
if (f > 0) {
|
|
1752
|
+
let p = "cell";
|
|
1753
|
+
d.firstChild && (p = d.firstChild.type.spec.tableRole);
|
|
1754
|
+
const h = [];
|
|
1755
|
+
for (let w = 0; w < f; w++)
|
|
1756
|
+
h.push(A(o.schema)[p].createAndFill());
|
|
1757
|
+
const b = (i == 0 || r == i - 1) && a == i ? c + 1 : u - 1;
|
|
1758
|
+
n.insert(n.mapping.map(b), h);
|
|
1759
|
+
}
|
|
1760
|
+
c = u;
|
|
1761
|
+
}
|
|
1762
|
+
return n.setMeta(zn, { fixTables: !0 });
|
|
1763
|
+
}
|
|
1764
|
+
const I = new O("selectingCells");
|
|
1765
|
+
function je(o, e) {
|
|
1766
|
+
for (; e && e != o.dom; e = e.parentNode)
|
|
1767
|
+
if (e.nodeName == "TD" || e.nodeName == "TH")
|
|
1768
|
+
return e;
|
|
1769
|
+
}
|
|
1770
|
+
function ae(o, e) {
|
|
1771
|
+
const t = o.posAtCoords({ left: e.clientX, top: e.clientY });
|
|
1772
|
+
return t && t ? U(o.state.doc.resolve(t.pos)) : null;
|
|
1773
|
+
}
|
|
1774
|
+
function Pn(o, e) {
|
|
1775
|
+
const t = e;
|
|
1776
|
+
if (t.ctrlKey || t.metaKey)
|
|
2292
1777
|
return;
|
|
2293
|
-
const
|
|
2294
|
-
let
|
|
2295
|
-
if (
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
startEvent.preventDefault();
|
|
2301
|
-
} else if (!startDOMCell) {
|
|
1778
|
+
const n = je(o, t.target);
|
|
1779
|
+
let l;
|
|
1780
|
+
if (t.shiftKey && o.state.selection instanceof m)
|
|
1781
|
+
s(o.state.selection.$anchorCell, t), t.preventDefault();
|
|
1782
|
+
else if (t.shiftKey && n && (l = U(o.state.selection.$anchor)) != null && ae(o, t).pos != l.pos)
|
|
1783
|
+
s(l, t), t.preventDefault();
|
|
1784
|
+
else if (!n)
|
|
2302
1785
|
return;
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
$head = $anchor2;
|
|
1786
|
+
function s(i, c) {
|
|
1787
|
+
let d = ae(o, c);
|
|
1788
|
+
const u = I.getState(o.state) == null;
|
|
1789
|
+
if (!d || !Ne(i, d))
|
|
1790
|
+
if (u)
|
|
1791
|
+
d = i;
|
|
2310
1792
|
else
|
|
2311
1793
|
return;
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
if (starting)
|
|
2317
|
-
tr.setMeta(tableEditingKey, $anchor2.pos);
|
|
2318
|
-
view.dispatch(tr);
|
|
1794
|
+
const f = new m(i, d);
|
|
1795
|
+
if (u || !o.state.selection.eq(f)) {
|
|
1796
|
+
const p = o.state.tr.setSelection(f);
|
|
1797
|
+
u && p.setMeta(I, i.pos), o.dispatch(p);
|
|
2319
1798
|
}
|
|
2320
1799
|
}
|
|
2321
|
-
function
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
}
|
|
2345
|
-
function handleTripleClick(view, pos) {
|
|
2346
|
-
const doc2 = view.state.doc, $cell = cellAround(doc2.resolve(pos));
|
|
2347
|
-
if (!$cell)
|
|
2348
|
-
return false;
|
|
2349
|
-
view.dispatch(view.state.tr.setSelection(new CellSelection($cell)));
|
|
2350
|
-
return true;
|
|
2351
|
-
}
|
|
2352
|
-
function maybeSetSelection(state, dispatch, selection) {
|
|
2353
|
-
if (selection.eq(state.selection))
|
|
2354
|
-
return false;
|
|
2355
|
-
if (dispatch)
|
|
2356
|
-
dispatch(state.tr.setSelection(selection).scrollIntoView());
|
|
2357
|
-
return true;
|
|
2358
|
-
}
|
|
2359
|
-
function atEndOfCell(view, axis, dir) {
|
|
2360
|
-
if (!(view.state.selection instanceof TextSelection))
|
|
1800
|
+
function r() {
|
|
1801
|
+
o.root.removeEventListener("mouseup", r), o.root.removeEventListener("dragstart", r), o.root.removeEventListener("mousemove", a), I.getState(o.state) != null && o.dispatch(o.state.tr.setMeta(I, -1));
|
|
1802
|
+
}
|
|
1803
|
+
function a(i) {
|
|
1804
|
+
const c = I.getState(o.state);
|
|
1805
|
+
let d;
|
|
1806
|
+
if (c != null)
|
|
1807
|
+
d = o.state.doc.resolve(c);
|
|
1808
|
+
else if (je(o, i.target) != n && (d = ae(o, t), !d))
|
|
1809
|
+
return r();
|
|
1810
|
+
d && s(d, i);
|
|
1811
|
+
}
|
|
1812
|
+
o.root.addEventListener("mouseup", r), o.root.addEventListener("dragstart", r), o.root.addEventListener("mousemove", a);
|
|
1813
|
+
}
|
|
1814
|
+
function Wn(o, e) {
|
|
1815
|
+
const t = o.state.doc, n = U(t.resolve(e));
|
|
1816
|
+
return n ? (o.dispatch(o.state.tr.setSelection(new m(n))), !0) : !1;
|
|
1817
|
+
}
|
|
1818
|
+
function Y(o, e, t) {
|
|
1819
|
+
return t.eq(o.selection) ? !1 : (e && e(o.tr.setSelection(t).scrollIntoView()), !0);
|
|
1820
|
+
}
|
|
1821
|
+
function lt(o, e, t) {
|
|
1822
|
+
if (!(o.state.selection instanceof D))
|
|
2361
1823
|
return null;
|
|
2362
|
-
const { $head } =
|
|
2363
|
-
for (let
|
|
2364
|
-
const
|
|
2365
|
-
if (index != (
|
|
1824
|
+
const { $head: n } = o.state.selection;
|
|
1825
|
+
for (let l = n.depth - 1; l >= 0; l--) {
|
|
1826
|
+
const s = n.node(l);
|
|
1827
|
+
if ((t < 0 ? n.index(l) : n.indexAfter(l)) != (t < 0 ? 0 : s.childCount))
|
|
2366
1828
|
return null;
|
|
2367
|
-
if (
|
|
2368
|
-
const
|
|
2369
|
-
|
|
2370
|
-
return view.endOfTextblock(dirStr) ? cellPos : null;
|
|
1829
|
+
if (s.type.spec.tableRole == "cell" || s.type.spec.tableRole == "header_cell") {
|
|
1830
|
+
const a = n.before(l), i = e == "vert" ? t > 0 ? "down" : "up" : t > 0 ? "right" : "left";
|
|
1831
|
+
return o.endOfTextblock(i) ? a : null;
|
|
2371
1832
|
}
|
|
2372
1833
|
}
|
|
2373
1834
|
return null;
|
|
2374
1835
|
}
|
|
2375
|
-
function
|
|
2376
|
-
return (
|
|
2377
|
-
const
|
|
2378
|
-
if (
|
|
2379
|
-
return
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
if ($next)
|
|
2392
|
-
newSel = Selection.near($next, 1);
|
|
2393
|
-
else if (dir < 0)
|
|
2394
|
-
newSel = Selection.near(state.doc.resolve($cell.before(-1)), -1);
|
|
2395
|
-
else
|
|
2396
|
-
newSel = Selection.near(state.doc.resolve($cell.after(-1)), 1);
|
|
2397
|
-
return maybeSetSelection(state, dispatch, newSel);
|
|
1836
|
+
function Z(o, e) {
|
|
1837
|
+
return (t, n, l) => {
|
|
1838
|
+
const s = t.selection;
|
|
1839
|
+
if (s instanceof m)
|
|
1840
|
+
return Y(t, n, N.near(s.$headCell, e));
|
|
1841
|
+
if (o != "horiz" && !s.empty)
|
|
1842
|
+
return !1;
|
|
1843
|
+
const r = lt(l, o, e);
|
|
1844
|
+
if (r == null)
|
|
1845
|
+
return !1;
|
|
1846
|
+
if (o == "horiz")
|
|
1847
|
+
return Y(t, n, N.near(t.doc.resolve(s.head + e), e));
|
|
1848
|
+
{
|
|
1849
|
+
const a = t.doc.resolve(r), i = et(a, o, e);
|
|
1850
|
+
let c;
|
|
1851
|
+
return i ? c = N.near(i, 1) : e < 0 ? c = N.near(t.doc.resolve(a.before(-1)), -1) : c = N.near(t.doc.resolve(a.after(-1)), 1), Y(t, n, c);
|
|
2398
1852
|
}
|
|
2399
1853
|
};
|
|
2400
1854
|
}
|
|
2401
|
-
function
|
|
2402
|
-
return (
|
|
2403
|
-
let
|
|
2404
|
-
if (!(
|
|
2405
|
-
const
|
|
2406
|
-
if (
|
|
2407
|
-
return
|
|
2408
|
-
|
|
2409
|
-
}
|
|
2410
|
-
const
|
|
2411
|
-
|
|
2412
|
-
return false;
|
|
2413
|
-
return maybeSetSelection(state, dispatch, new CellSelection(sel.$anchorCell, $head));
|
|
1855
|
+
function G(o, e) {
|
|
1856
|
+
return (t, n, l) => {
|
|
1857
|
+
let s = t.selection;
|
|
1858
|
+
if (!(s instanceof m)) {
|
|
1859
|
+
const a = lt(l, o, e);
|
|
1860
|
+
if (a == null)
|
|
1861
|
+
return !1;
|
|
1862
|
+
s = new m(t.doc.resolve(a));
|
|
1863
|
+
}
|
|
1864
|
+
const r = et(s.$headCell, o, e);
|
|
1865
|
+
return r ? Y(t, n, new m(s.$anchorCell, r)) : !1;
|
|
2414
1866
|
};
|
|
2415
1867
|
}
|
|
2416
|
-
function
|
|
2417
|
-
const
|
|
2418
|
-
if (!(
|
|
2419
|
-
return
|
|
2420
|
-
if (
|
|
2421
|
-
const
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
"Shift-
|
|
2437
|
-
|
|
2438
|
-
"
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
"Mod-Backspace": deleteCellSelection,
|
|
2442
|
-
Delete: deleteCellSelection,
|
|
2443
|
-
"Mod-Delete": deleteCellSelection
|
|
1868
|
+
function J(o, e) {
|
|
1869
|
+
const t = o.selection;
|
|
1870
|
+
if (!(t instanceof m))
|
|
1871
|
+
return !1;
|
|
1872
|
+
if (e) {
|
|
1873
|
+
const n = o.tr, l = A(o.schema).cell.createAndFill().content;
|
|
1874
|
+
t.forEachCell((s, r) => {
|
|
1875
|
+
s.content.eq(l) || n.replace(n.mapping.map(r + 1), n.mapping.map(r + s.nodeSize - 1), new _(l, 0, 0));
|
|
1876
|
+
}), n.docChanged && e(n);
|
|
1877
|
+
}
|
|
1878
|
+
return !0;
|
|
1879
|
+
}
|
|
1880
|
+
const Hn = Nt({
|
|
1881
|
+
ArrowLeft: Z("horiz", -1),
|
|
1882
|
+
ArrowRight: Z("horiz", 1),
|
|
1883
|
+
ArrowUp: Z("vert", -1),
|
|
1884
|
+
ArrowDown: Z("vert", 1),
|
|
1885
|
+
"Shift-ArrowLeft": G("horiz", -1),
|
|
1886
|
+
"Shift-ArrowRight": G("horiz", 1),
|
|
1887
|
+
"Shift-ArrowUp": G("vert", -1),
|
|
1888
|
+
"Shift-ArrowDown": G("vert", 1),
|
|
1889
|
+
Backspace: J,
|
|
1890
|
+
"Mod-Backspace": J,
|
|
1891
|
+
Delete: J,
|
|
1892
|
+
"Mod-Delete": J
|
|
2444
1893
|
});
|
|
2445
|
-
function
|
|
2446
|
-
if (!
|
|
2447
|
-
return
|
|
2448
|
-
let
|
|
2449
|
-
const
|
|
2450
|
-
if (
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
return false;
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
function tableEditing({ allowTableNodeSelection = false } = {}) {
|
|
2471
|
-
return new Plugin({
|
|
2472
|
-
key: tableEditingKey,
|
|
1894
|
+
function jn(o, e, t) {
|
|
1895
|
+
if (!M(o.state))
|
|
1896
|
+
return !1;
|
|
1897
|
+
let n = $n(t);
|
|
1898
|
+
const l = o.state.selection;
|
|
1899
|
+
if (l instanceof m) {
|
|
1900
|
+
n || (n = {
|
|
1901
|
+
width: 1,
|
|
1902
|
+
height: 1,
|
|
1903
|
+
rows: [E.from(fe(A(o.state.schema).cell, t))]
|
|
1904
|
+
});
|
|
1905
|
+
const s = l.$anchorCell.node(-1), r = l.$anchorCell.start(-1), a = g.get(s).rectBetween(l.$anchorCell.pos - r, l.$headCell.pos - r);
|
|
1906
|
+
return n = _n(n, a.right - a.left, a.bottom - a.top), He(o.state, o.dispatch, r, a, n), !0;
|
|
1907
|
+
} else if (n) {
|
|
1908
|
+
const s = ne(o.state), r = s.start(-1);
|
|
1909
|
+
return He(o.state, o.dispatch, r, g.get(s.node(-1)).findCell(s.pos - r), n), !0;
|
|
1910
|
+
} else
|
|
1911
|
+
return !1;
|
|
1912
|
+
}
|
|
1913
|
+
function Kn({ allowTableNodeSelection: o = !1 } = {}) {
|
|
1914
|
+
return new B({
|
|
1915
|
+
key: I,
|
|
2473
1916
|
state: {
|
|
2474
1917
|
init() {
|
|
2475
1918
|
return null;
|
|
2476
1919
|
},
|
|
2477
|
-
apply(
|
|
2478
|
-
const
|
|
2479
|
-
if (
|
|
2480
|
-
return
|
|
2481
|
-
if (
|
|
2482
|
-
return
|
|
2483
|
-
const { deleted, pos } =
|
|
2484
|
-
return
|
|
1920
|
+
apply(e, t) {
|
|
1921
|
+
const n = e.getMeta(I);
|
|
1922
|
+
if (n != null)
|
|
1923
|
+
return n == -1 ? null : n;
|
|
1924
|
+
if (t == null || !e.docChanged)
|
|
1925
|
+
return t;
|
|
1926
|
+
const { deleted: l, pos: s } = e.mapping.mapResult(t);
|
|
1927
|
+
return l ? null : s;
|
|
2485
1928
|
}
|
|
2486
1929
|
},
|
|
2487
1930
|
props: {
|
|
2488
|
-
decorations:
|
|
1931
|
+
decorations: Ht,
|
|
2489
1932
|
handleDOMEvents: {
|
|
2490
|
-
mousedown:
|
|
1933
|
+
mousedown: Pn
|
|
2491
1934
|
},
|
|
2492
|
-
createSelectionBetween(
|
|
2493
|
-
|
|
2494
|
-
return view.state.selection;
|
|
2495
|
-
return null;
|
|
1935
|
+
createSelectionBetween(e) {
|
|
1936
|
+
return I.getState(e.state) != null ? e.state.selection : null;
|
|
2496
1937
|
},
|
|
2497
|
-
handleTripleClick,
|
|
2498
|
-
handleKeyDown,
|
|
2499
|
-
handlePaste
|
|
1938
|
+
handleTripleClick: Wn,
|
|
1939
|
+
handleKeyDown: Hn,
|
|
1940
|
+
handlePaste: jn
|
|
2500
1941
|
},
|
|
2501
|
-
appendTransaction(
|
|
2502
|
-
return
|
|
1942
|
+
appendTransaction(e, t, n) {
|
|
1943
|
+
return qt(n, Fn(n, t), o);
|
|
2503
1944
|
}
|
|
2504
1945
|
});
|
|
2505
1946
|
}
|
|
2506
|
-
const
|
|
1947
|
+
const Q = {
|
|
2507
1948
|
NextCell: "NextCell",
|
|
2508
1949
|
PrevCell: "PrevCell",
|
|
2509
1950
|
ExitTable: "ExitTable"
|
|
2510
|
-
}
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
const align = node["align"];
|
|
2525
|
-
const children = node.children.map((x, i) => __spreadProps(__spreadValues({}, x), {
|
|
2526
|
-
align,
|
|
2527
|
-
isHeader: i === 0
|
|
2528
|
-
}));
|
|
2529
|
-
state.openNode(type);
|
|
2530
|
-
state.next(children);
|
|
2531
|
-
state.closeNode();
|
|
2532
|
-
}
|
|
2533
|
-
},
|
|
2534
|
-
toMarkdown: {
|
|
2535
|
-
match: (node) => node.type.name === "table",
|
|
2536
|
-
runner: (state, node) => {
|
|
2537
|
-
var _a;
|
|
2538
|
-
const firstLine = (_a = node.content.firstChild) == null ? void 0 : _a.content;
|
|
2539
|
-
if (!firstLine)
|
|
2540
|
-
return;
|
|
2541
|
-
const align = [];
|
|
2542
|
-
firstLine.forEach((cell) => {
|
|
2543
|
-
align.push(cell.attrs["alignment"]);
|
|
2544
|
-
});
|
|
2545
|
-
state.openNode("table", void 0, { align });
|
|
2546
|
-
state.next(node.content);
|
|
2547
|
-
state.closeNode();
|
|
2548
|
-
}
|
|
1951
|
+
}, Ke = x("PrevCell"), qe = x("NextCell"), Ue = x("BreakTable"), qn = x("InsertTable"), Un = new O("MILKDOWN_TABLE_CONTENT_FILTER"), Xn = at((o) => ({
|
|
1952
|
+
schema: () => ({
|
|
1953
|
+
node: {
|
|
1954
|
+
table: {
|
|
1955
|
+
...V.table,
|
|
1956
|
+
parseMarkdown: {
|
|
1957
|
+
match: (e) => e.type === "table",
|
|
1958
|
+
runner: (e, t, n) => {
|
|
1959
|
+
const l = t.align, s = t.children.map((r, a) => ({
|
|
1960
|
+
...r,
|
|
1961
|
+
align: l,
|
|
1962
|
+
isHeader: a === 0
|
|
1963
|
+
}));
|
|
1964
|
+
e.openNode(n), e.next(s), e.closeNode();
|
|
2549
1965
|
}
|
|
2550
|
-
}
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
state.closeNode();
|
|
2563
|
-
}
|
|
2564
|
-
},
|
|
2565
|
-
toMarkdown: {
|
|
2566
|
-
match: (node) => node.type.name === "table_row",
|
|
2567
|
-
runner: (state, node) => {
|
|
2568
|
-
state.openNode("tableRow");
|
|
2569
|
-
state.next(node.content);
|
|
2570
|
-
state.closeNode();
|
|
2571
|
-
}
|
|
1966
|
+
},
|
|
1967
|
+
toMarkdown: {
|
|
1968
|
+
match: (e) => e.type.name === "table",
|
|
1969
|
+
runner: (e, t) => {
|
|
1970
|
+
var s;
|
|
1971
|
+
const n = (s = t.content.firstChild) == null ? void 0 : s.content;
|
|
1972
|
+
if (!n)
|
|
1973
|
+
return;
|
|
1974
|
+
const l = [];
|
|
1975
|
+
n.forEach((r) => {
|
|
1976
|
+
l.push(r.attrs.alignment);
|
|
1977
|
+
}), e.openNode("table", void 0, { align: l }), e.next(t.content), e.closeNode();
|
|
2572
1978
|
}
|
|
2573
|
-
}
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
}
|
|
1979
|
+
}
|
|
1980
|
+
},
|
|
1981
|
+
table_row: {
|
|
1982
|
+
...V.table_row,
|
|
1983
|
+
parseMarkdown: {
|
|
1984
|
+
match: (e) => e.type === "tableRow",
|
|
1985
|
+
runner: (e, t, n) => {
|
|
1986
|
+
const l = t.align, s = t.children.map((r, a) => ({
|
|
1987
|
+
...r,
|
|
1988
|
+
align: l[a],
|
|
1989
|
+
isHeader: t.isHeader
|
|
1990
|
+
}));
|
|
1991
|
+
e.openNode(n), e.next(s), e.closeNode();
|
|
2587
1992
|
}
|
|
2588
|
-
}
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
const align = node["align"];
|
|
2594
|
-
state.openNode(type, { alignment: align });
|
|
2595
|
-
state.openNode(state.schema.nodes["paragraph"]);
|
|
2596
|
-
state.next(node.children);
|
|
2597
|
-
state.closeNode();
|
|
2598
|
-
state.closeNode();
|
|
2599
|
-
}
|
|
2600
|
-
},
|
|
2601
|
-
toMarkdown: {
|
|
2602
|
-
match: (node) => node.type.name === "table_header",
|
|
2603
|
-
runner: (state, node) => {
|
|
2604
|
-
state.openNode("tableCell");
|
|
2605
|
-
state.next(node.content);
|
|
2606
|
-
state.closeNode();
|
|
2607
|
-
}
|
|
1993
|
+
},
|
|
1994
|
+
toMarkdown: {
|
|
1995
|
+
match: (e) => e.type.name === "table_row",
|
|
1996
|
+
runner: (e, t) => {
|
|
1997
|
+
e.openNode("tableRow"), e.next(t.content), e.closeNode();
|
|
2608
1998
|
}
|
|
2609
|
-
})
|
|
2610
|
-
}
|
|
2611
|
-
}),
|
|
2612
|
-
inputRules: (nodeType, ctx) => [
|
|
2613
|
-
new InputRule(/^\|\|\s$/, (state, _match, start, end) => {
|
|
2614
|
-
const $start = state.doc.resolve(start);
|
|
2615
|
-
if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType.table))
|
|
2616
|
-
return null;
|
|
2617
|
-
const tableNode = createTable(ctx.get(schemaCtx));
|
|
2618
|
-
const tr = state.tr.replaceRangeWith(start, end, tableNode).scrollIntoView();
|
|
2619
|
-
return tr.setSelection(TextSelection.create(tr.doc, start + 3));
|
|
2620
|
-
})
|
|
2621
|
-
],
|
|
2622
|
-
commands: (_, ctx) => [
|
|
2623
|
-
createCmd(PrevCell, () => goToNextCell(-1)),
|
|
2624
|
-
createCmd(NextCell, () => goToNextCell(1)),
|
|
2625
|
-
createCmd(BreakTable, () => exitTable(ctx.get(schemaCtx).nodes["paragraph"])),
|
|
2626
|
-
createCmd(InsertTable, () => (state, dispatch) => {
|
|
2627
|
-
const { selection, tr } = state;
|
|
2628
|
-
const { from } = selection;
|
|
2629
|
-
const table2 = createTable(ctx.get(schemaCtx));
|
|
2630
|
-
const _tr = tr.replaceSelectionWith(table2);
|
|
2631
|
-
const sel = Selection.findFrom(_tr.doc.resolve(from), 1, true);
|
|
2632
|
-
if (sel) {
|
|
2633
|
-
dispatch == null ? void 0 : dispatch(_tr.setSelection(sel));
|
|
2634
1999
|
}
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
key: TableContentFilterPluginKey,
|
|
2650
|
-
filterTransaction: (tr, state) => {
|
|
2651
|
-
const isInsertHr = tr.getMeta("hardbreak");
|
|
2652
|
-
const [step] = tr.steps;
|
|
2653
|
-
if (isInsertHr && step) {
|
|
2654
|
-
const { from } = step;
|
|
2655
|
-
const $from = state.doc.resolve(from);
|
|
2656
|
-
let curDepth = $from.depth;
|
|
2657
|
-
let canApply = true;
|
|
2658
|
-
while (curDepth > 0) {
|
|
2659
|
-
if ($from.node(curDepth).type.name === "table") {
|
|
2660
|
-
canApply = false;
|
|
2661
|
-
}
|
|
2662
|
-
curDepth--;
|
|
2663
|
-
}
|
|
2664
|
-
return canApply;
|
|
2665
|
-
}
|
|
2666
|
-
return true;
|
|
2000
|
+
},
|
|
2001
|
+
table_cell: {
|
|
2002
|
+
...V.table_cell,
|
|
2003
|
+
parseMarkdown: {
|
|
2004
|
+
match: (e) => e.type === "tableCell" && !e.isHeader,
|
|
2005
|
+
runner: (e, t, n) => {
|
|
2006
|
+
const l = t.align;
|
|
2007
|
+
e.openNode(n, { alignment: l }).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode();
|
|
2008
|
+
}
|
|
2009
|
+
},
|
|
2010
|
+
toMarkdown: {
|
|
2011
|
+
match: (e) => e.type.name === "table_cell",
|
|
2012
|
+
runner: (e, t) => {
|
|
2013
|
+
e.openNode("tableCell").next(t.content).closeNode();
|
|
2667
2014
|
}
|
|
2668
|
-
})
|
|
2669
|
-
];
|
|
2670
|
-
}
|
|
2671
|
-
};
|
|
2672
|
-
});
|
|
2673
|
-
const SupportedKeys = __spreadProps(__spreadValues(__spreadValues({}, SupportedKeys$2), SupportedKeys$1), {
|
|
2674
|
-
StrikeThrough: "StrikeThrough",
|
|
2675
|
-
TaskList: "TaskList"
|
|
2676
|
-
});
|
|
2677
|
-
const ToggleStrikeThrough = createCmdKey("ToggleStrikeThrough");
|
|
2678
|
-
const id = "strike_through";
|
|
2679
|
-
const strikeThrough = createMark((utils) => {
|
|
2680
|
-
return {
|
|
2681
|
-
id,
|
|
2682
|
-
schema: () => ({
|
|
2683
|
-
parseDOM: [
|
|
2684
|
-
{ tag: "del" },
|
|
2685
|
-
{ style: "text-decoration", getAttrs: (value) => value === "line-through" }
|
|
2686
|
-
],
|
|
2687
|
-
toDOM: (mark) => ["del", { class: utils.getClassName(mark.attrs, "strike-through") }],
|
|
2688
|
-
parseMarkdown: {
|
|
2689
|
-
match: (node) => node.type === "delete",
|
|
2690
|
-
runner: (state, node, markType) => {
|
|
2691
|
-
state.openMark(markType);
|
|
2692
|
-
state.next(node.children);
|
|
2693
|
-
state.closeMark(markType);
|
|
2694
2015
|
}
|
|
2695
2016
|
},
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2017
|
+
table_header: {
|
|
2018
|
+
...V.table_header,
|
|
2019
|
+
parseMarkdown: {
|
|
2020
|
+
match: (e) => e.type === "tableCell" && !!e.isHeader,
|
|
2021
|
+
runner: (e, t, n) => {
|
|
2022
|
+
const l = t.align;
|
|
2023
|
+
e.openNode(n, { alignment: l }), e.openNode(e.schema.nodes.paragraph), e.next(t.children), e.closeNode(), e.closeNode();
|
|
2024
|
+
}
|
|
2025
|
+
},
|
|
2026
|
+
toMarkdown: {
|
|
2027
|
+
match: (e) => e.type.name === "table_header",
|
|
2028
|
+
runner: (e, t) => {
|
|
2029
|
+
e.openNode("tableCell"), e.next(t.content), e.closeNode();
|
|
2030
|
+
}
|
|
2700
2031
|
}
|
|
2701
2032
|
}
|
|
2702
|
-
}
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2033
|
+
}
|
|
2034
|
+
}),
|
|
2035
|
+
inputRules: (e, t) => [
|
|
2036
|
+
new Ce(/^\|\|\s$/, (n, l, s, r) => {
|
|
2037
|
+
const a = n.doc.resolve(s);
|
|
2038
|
+
if (!a.node(-1).canReplaceWith(a.index(-1), a.indexAfter(-1), e.table))
|
|
2039
|
+
return null;
|
|
2040
|
+
const i = _e(t.get(re)), c = n.tr.replaceRangeWith(s, r, i).scrollIntoView();
|
|
2041
|
+
return c.setSelection(D.create(c.doc, s + 3));
|
|
2042
|
+
})
|
|
2043
|
+
],
|
|
2044
|
+
commands: (e, t) => [
|
|
2045
|
+
S(Ke, () => De(-1)),
|
|
2046
|
+
S(qe, () => De(1)),
|
|
2047
|
+
S(Ue, () => Jt(t.get(re).nodes.paragraph)),
|
|
2048
|
+
S(qn, () => (n, l) => {
|
|
2049
|
+
const { selection: s, tr: r } = n, { from: a } = s, i = _e(t.get(re)), c = r.replaceSelectionWith(i), d = N.findFrom(c.doc.resolve(a), 1, !0);
|
|
2050
|
+
return d && (l == null || l(c.setSelection(d))), !0;
|
|
2051
|
+
})
|
|
2052
|
+
],
|
|
2053
|
+
shortcuts: {
|
|
2054
|
+
[Q.NextCell]: $(qe, "Mod-]"),
|
|
2055
|
+
[Q.PrevCell]: $(Ke, "Mod-["),
|
|
2056
|
+
[Q.ExitTable]: $(Ue, "Mod-Enter")
|
|
2057
|
+
},
|
|
2058
|
+
prosePlugins: (e, t) => [
|
|
2059
|
+
wn(t, o),
|
|
2060
|
+
kn(),
|
|
2061
|
+
Mn(),
|
|
2062
|
+
Kn(),
|
|
2063
|
+
new B({
|
|
2064
|
+
key: Un,
|
|
2065
|
+
filterTransaction: (n, l) => {
|
|
2066
|
+
const s = n.getMeta("hardbreak"), [r] = n.steps;
|
|
2067
|
+
if (s && r) {
|
|
2068
|
+
const { from: a } = r, i = l.doc.resolve(a);
|
|
2069
|
+
let c = i.depth, d = !0;
|
|
2070
|
+
for (; c > 0; )
|
|
2071
|
+
i.node(c).type.name === "table" && (d = !1), c--;
|
|
2072
|
+
return d;
|
|
2073
|
+
}
|
|
2074
|
+
return !0;
|
|
2075
|
+
}
|
|
2076
|
+
})
|
|
2077
|
+
]
|
|
2078
|
+
})), K = {
|
|
2079
|
+
...st,
|
|
2080
|
+
...Q,
|
|
2081
|
+
StrikeThrough: "StrikeThrough",
|
|
2082
|
+
TaskList: "TaskList"
|
|
2083
|
+
}, pe = x("ToggleStrikeThrough"), Xe = "strike_through", Vn = dt((o) => ({
|
|
2084
|
+
id: Xe,
|
|
2085
|
+
schema: () => ({
|
|
2086
|
+
parseDOM: [
|
|
2087
|
+
{ tag: "del" },
|
|
2088
|
+
{ style: "text-decoration", getAttrs: (e) => e === "line-through" }
|
|
2706
2089
|
],
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2090
|
+
toDOM: (e) => ["del", { class: o.getClassName(e.attrs, "strike-through") }],
|
|
2091
|
+
parseMarkdown: {
|
|
2092
|
+
match: (e) => e.type === "delete",
|
|
2093
|
+
runner: (e, t, n) => {
|
|
2094
|
+
e.openMark(n), e.next(t.children), e.closeMark(n);
|
|
2095
|
+
}
|
|
2096
|
+
},
|
|
2097
|
+
toMarkdown: {
|
|
2098
|
+
match: (e) => e.type.name === Xe,
|
|
2099
|
+
runner: (e, t) => {
|
|
2100
|
+
e.withMark(t, "delete");
|
|
2101
|
+
}
|
|
2710
2102
|
}
|
|
2711
|
-
}
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2103
|
+
}),
|
|
2104
|
+
inputRules: (e) => [
|
|
2105
|
+
Te(/(?:~~)([^~]+)(?:~~)$/, e),
|
|
2106
|
+
Te(/(?:^|[^~])(~([^~]+)~)$/, e)
|
|
2107
|
+
],
|
|
2108
|
+
commands: (e) => [S(pe, () => At(e))],
|
|
2109
|
+
shortcuts: {
|
|
2110
|
+
[K.StrikeThrough]: $(pe, "Mod-Alt-x")
|
|
2111
|
+
}
|
|
2112
|
+
})), he = x("SplitTaskListItem"), me = x("SinkTaskListItem"), ge = x("LiftTaskListItem"), we = x("TurnIntoTaskList"), Zn = be((o) => {
|
|
2113
|
+
const e = "task_list_item";
|
|
2719
2114
|
return {
|
|
2720
|
-
id:
|
|
2721
|
-
schema: (
|
|
2115
|
+
id: e,
|
|
2116
|
+
schema: (t) => ({
|
|
2722
2117
|
group: "listItem",
|
|
2723
2118
|
content: "paragraph block*",
|
|
2724
|
-
defining:
|
|
2119
|
+
defining: !0,
|
|
2725
2120
|
priority: 60,
|
|
2726
2121
|
attrs: {
|
|
2727
2122
|
checked: {
|
|
2728
|
-
default:
|
|
2123
|
+
default: !1
|
|
2729
2124
|
}
|
|
2730
2125
|
},
|
|
2731
2126
|
parseDOM: [
|
|
2732
2127
|
{
|
|
2733
2128
|
tag: 'li[data-type="task-item"]',
|
|
2734
|
-
getAttrs: (
|
|
2735
|
-
if (!(
|
|
2736
|
-
throw
|
|
2737
|
-
}
|
|
2738
|
-
return { checked: dom.dataset["checked"] === "true" };
|
|
2129
|
+
getAttrs: (n) => {
|
|
2130
|
+
if (!(n instanceof HTMLElement))
|
|
2131
|
+
throw ye(n);
|
|
2132
|
+
return { checked: n.dataset.checked === "true" };
|
|
2739
2133
|
}
|
|
2740
2134
|
}
|
|
2741
2135
|
],
|
|
2742
|
-
toDOM: (
|
|
2743
|
-
const
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
checkbox.onchange = (event) => {
|
|
2748
|
-
const target = event.target;
|
|
2749
|
-
if (!(target instanceof HTMLInputElement))
|
|
2136
|
+
toDOM: (n) => {
|
|
2137
|
+
const l = document.createElement("input");
|
|
2138
|
+
return l.type = "checkbox", l.checked = n.attrs.checked, l.className = o.getClassName(n.attrs, "task-list-item_checkbox"), l.onchange = (s) => {
|
|
2139
|
+
const r = s.target;
|
|
2140
|
+
if (!(r instanceof HTMLInputElement))
|
|
2750
2141
|
return;
|
|
2751
|
-
const
|
|
2752
|
-
if (!
|
|
2753
|
-
|
|
2142
|
+
const a = t.get(ee);
|
|
2143
|
+
if (!a.editable) {
|
|
2144
|
+
l.checked = !l.checked;
|
|
2754
2145
|
return;
|
|
2755
2146
|
}
|
|
2756
|
-
const { top, left } =
|
|
2757
|
-
|
|
2758
|
-
if (!result)
|
|
2147
|
+
const { top: i, left: c } = r.getBoundingClientRect(), d = a.posAtCoords({ top: i, left: c });
|
|
2148
|
+
if (!d)
|
|
2759
2149
|
return;
|
|
2760
|
-
const { tr } =
|
|
2761
|
-
|
|
2762
|
-
checked:
|
|
2150
|
+
const { tr: u } = a.state;
|
|
2151
|
+
a.dispatch(u.setNodeMarkup(d.inside, void 0, {
|
|
2152
|
+
checked: r.checked
|
|
2763
2153
|
}));
|
|
2764
|
-
}
|
|
2765
|
-
return [
|
|
2154
|
+
}, [
|
|
2766
2155
|
"li",
|
|
2767
2156
|
{
|
|
2768
2157
|
"data-type": "task-item",
|
|
2769
|
-
"data-checked":
|
|
2770
|
-
class:
|
|
2158
|
+
"data-checked": n.attrs.checked ? "true" : "false",
|
|
2159
|
+
class: o.getClassName(n.attrs, "task-list-item")
|
|
2771
2160
|
},
|
|
2772
|
-
|
|
2773
|
-
["span", { class:
|
|
2161
|
+
l,
|
|
2162
|
+
["span", { class: o.getClassName(n.attrs, "task-list-item_body") }, 0]
|
|
2774
2163
|
];
|
|
2775
2164
|
},
|
|
2776
2165
|
parseMarkdown: {
|
|
2777
|
-
match: ({ type, checked }) =>
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
runner: (state, node, type) => {
|
|
2781
|
-
state.openNode(type, { checked: node["checked"] });
|
|
2782
|
-
state.next(node.children);
|
|
2783
|
-
state.closeNode();
|
|
2166
|
+
match: ({ type: n, checked: l }) => n === "listItem" && l !== null,
|
|
2167
|
+
runner: (n, l, s) => {
|
|
2168
|
+
n.openNode(s, { checked: l.checked }), n.next(l.children), n.closeNode();
|
|
2784
2169
|
}
|
|
2785
2170
|
},
|
|
2786
2171
|
toMarkdown: {
|
|
2787
|
-
match: (
|
|
2788
|
-
runner: (
|
|
2789
|
-
|
|
2790
|
-
state.next(node.content);
|
|
2791
|
-
state.closeNode();
|
|
2172
|
+
match: (n) => n.type.name === e,
|
|
2173
|
+
runner: (n, l) => {
|
|
2174
|
+
n.openNode("listItem", void 0, { checked: l.attrs.checked }), n.next(l.content), n.closeNode();
|
|
2792
2175
|
}
|
|
2793
2176
|
}
|
|
2794
2177
|
}),
|
|
2795
|
-
inputRules: (
|
|
2796
|
-
|
|
2797
|
-
checked:
|
|
2178
|
+
inputRules: (t) => [
|
|
2179
|
+
Ve(/^\s*(\[([ |x])\])\s$/, t, (n) => ({
|
|
2180
|
+
checked: n[n.length - 1] === "x"
|
|
2798
2181
|
}))
|
|
2799
2182
|
],
|
|
2800
|
-
commands: (
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2183
|
+
commands: (t) => [
|
|
2184
|
+
S(he, () => Rt(t)),
|
|
2185
|
+
S(me, () => xt(t)),
|
|
2186
|
+
S(ge, () => Tt(t)),
|
|
2187
|
+
S(we, () => Mt(t))
|
|
2805
2188
|
],
|
|
2806
2189
|
shortcuts: {
|
|
2807
|
-
[
|
|
2808
|
-
[
|
|
2809
|
-
[
|
|
2810
|
-
[
|
|
2190
|
+
[K.NextListItem]: $(he, "Enter"),
|
|
2191
|
+
[K.SinkListItem]: $(me, "Mod-]"),
|
|
2192
|
+
[K.LiftListItem]: $(ge, "Mod-["),
|
|
2193
|
+
[K.TaskList]: $(we, "Mod-Alt-9")
|
|
2811
2194
|
},
|
|
2812
|
-
view: () => (
|
|
2813
|
-
let
|
|
2814
|
-
const
|
|
2815
|
-
editable: () =>
|
|
2816
|
-
onChange: (
|
|
2817
|
-
const { tr } =
|
|
2818
|
-
|
|
2819
|
-
checked:
|
|
2195
|
+
view: () => (t, n, l) => {
|
|
2196
|
+
let s = t;
|
|
2197
|
+
const r = o.themeManager.get("task-list-item", {
|
|
2198
|
+
editable: () => n.editable,
|
|
2199
|
+
onChange: (d) => {
|
|
2200
|
+
const { tr: u } = n.state;
|
|
2201
|
+
n.dispatch(u.setNodeMarkup(l(), void 0, {
|
|
2202
|
+
checked: d
|
|
2820
2203
|
}));
|
|
2821
2204
|
}
|
|
2822
2205
|
});
|
|
2823
|
-
if (!
|
|
2206
|
+
if (!r)
|
|
2824
2207
|
return {};
|
|
2825
|
-
const { dom, contentDOM, onUpdate } =
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
update: (updatedNode) => {
|
|
2831
|
-
if (updatedNode.type.name !== id2)
|
|
2832
|
-
return false;
|
|
2833
|
-
currNode = updatedNode;
|
|
2834
|
-
onUpdate(currNode);
|
|
2835
|
-
return true;
|
|
2836
|
-
}
|
|
2208
|
+
const { dom: a, contentDOM: i, onUpdate: c } = r;
|
|
2209
|
+
return c(s), {
|
|
2210
|
+
dom: a,
|
|
2211
|
+
contentDOM: i,
|
|
2212
|
+
update: (d) => d.type.name !== e ? !1 : (s = d, c(s), !0)
|
|
2837
2213
|
};
|
|
2838
2214
|
}
|
|
2839
2215
|
};
|
|
2840
|
-
})
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2216
|
+
}), uo = ut.create([
|
|
2217
|
+
...rt,
|
|
2218
|
+
ft(() => pt),
|
|
2219
|
+
Xn(),
|
|
2220
|
+
Et,
|
|
2221
|
+
Vn(),
|
|
2222
|
+
Zn(),
|
|
2223
|
+
_t(),
|
|
2224
|
+
$t()
|
|
2225
|
+
]), fo = {
|
|
2226
|
+
...it,
|
|
2227
|
+
ToggleStrikeThrough: pe,
|
|
2228
|
+
TurnIntoTaskList: we,
|
|
2229
|
+
SinkTaskListItem: me,
|
|
2230
|
+
LiftTaskListItem: ge,
|
|
2231
|
+
SplitTaskListItem: he
|
|
2232
|
+
};
|
|
2233
|
+
export {
|
|
2234
|
+
Ue as BreakTable,
|
|
2235
|
+
mo as InsertHardbreak,
|
|
2236
|
+
go as InsertHr,
|
|
2237
|
+
wo as InsertImage,
|
|
2238
|
+
qn as InsertTable,
|
|
2239
|
+
bo as LiftListItem,
|
|
2240
|
+
ge as LiftTaskListItem,
|
|
2241
|
+
Le as ModifyFootnoteDef,
|
|
2242
|
+
ve as ModifyFootnoteRef,
|
|
2243
|
+
Co as ModifyImage,
|
|
2244
|
+
yo as ModifyLink,
|
|
2245
|
+
qe as NextCell,
|
|
2246
|
+
Ke as PrevCell,
|
|
2247
|
+
ko as SinkListItem,
|
|
2248
|
+
me as SinkTaskListItem,
|
|
2249
|
+
Ao as SplitListItem,
|
|
2250
|
+
he as SplitTaskListItem,
|
|
2251
|
+
K as SupportedKeys,
|
|
2252
|
+
Mo as ToggleBold,
|
|
2253
|
+
No as ToggleInlineCode,
|
|
2254
|
+
So as ToggleItalic,
|
|
2255
|
+
Ro as ToggleLink,
|
|
2256
|
+
pe as ToggleStrikeThrough,
|
|
2257
|
+
xo as TurnIntoCodeFence,
|
|
2258
|
+
To as TurnIntoHeading,
|
|
2259
|
+
we as TurnIntoTaskList,
|
|
2260
|
+
Lo as TurnIntoText,
|
|
2261
|
+
vo as WrapInBlockquote,
|
|
2262
|
+
Eo as WrapInBulletList,
|
|
2263
|
+
Io as WrapInOrderedList,
|
|
2264
|
+
$o as blockquote,
|
|
2265
|
+
Do as bulletList,
|
|
2266
|
+
_o as codeFence,
|
|
2267
|
+
Oo as codeInline,
|
|
2268
|
+
fo as commands,
|
|
2269
|
+
zo as commonmark,
|
|
2270
|
+
Fo as commonmarkNodes,
|
|
2271
|
+
Bo as commonmarkPlugins,
|
|
2272
|
+
_e as createTable,
|
|
2273
|
+
Po as doc,
|
|
2274
|
+
Wo as em,
|
|
2275
|
+
$t as footnoteDefinition,
|
|
2276
|
+
_t as footnoteReference,
|
|
2277
|
+
uo as gfm,
|
|
2278
|
+
Ho as hardbreak,
|
|
2279
|
+
jo as heading,
|
|
2280
|
+
Ko as hr,
|
|
2281
|
+
qo as image,
|
|
2282
|
+
Uo as link,
|
|
2283
|
+
Xo as listItem,
|
|
2284
|
+
Vo as orderedList,
|
|
2285
|
+
Zo as paragraph,
|
|
2286
|
+
Vn as strikeThrough,
|
|
2287
|
+
Go as strong,
|
|
2288
|
+
Xn as table,
|
|
2289
|
+
Zn as taskListItem,
|
|
2290
|
+
Jo as text
|
|
2291
|
+
};
|
|
2859
2292
|
//# sourceMappingURL=index.es.js.map
|