@milkdown/preset-gfm 6.2.0 → 6.3.2

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.
Files changed (80) hide show
  1. package/lib/footnote/definition.d.ts.map +1 -1
  2. package/lib/footnote/reference.d.ts.map +1 -1
  3. package/lib/index.d.ts +1 -1
  4. package/lib/index.d.ts.map +1 -1
  5. package/lib/index.es.js +1795 -2381
  6. package/lib/index.es.js.map +1 -1
  7. package/lib/supported-keys.d.ts +1 -0
  8. package/lib/supported-keys.d.ts.map +1 -1
  9. package/lib/table/nodes/index.d.ts +0 -5
  10. package/lib/table/nodes/index.d.ts.map +1 -1
  11. package/lib/table/operator-plugin/calc-pos.d.ts.map +1 -1
  12. package/lib/table/operator-plugin/helper.d.ts +1 -1
  13. package/lib/table/operator-plugin/helper.d.ts.map +1 -1
  14. package/lib/table/plugin/auto-insert-zero-space.d.ts +3 -0
  15. package/lib/table/plugin/auto-insert-zero-space.d.ts.map +1 -0
  16. package/lib/table/{nodes → plugin}/cell-selection.d.ts +0 -0
  17. package/lib/table/plugin/cell-selection.d.ts.map +1 -0
  18. package/lib/table/plugin/column-resizing.d.ts +17 -0
  19. package/lib/table/plugin/column-resizing.d.ts.map +1 -0
  20. package/lib/table/{nodes → plugin}/commands.d.ts +0 -0
  21. package/lib/table/plugin/commands.d.ts.map +1 -0
  22. package/lib/table/{nodes → plugin}/copy-paste.d.ts +0 -0
  23. package/lib/table/plugin/copy-paste.d.ts.map +1 -0
  24. package/lib/table/{nodes → plugin}/fix-tables.d.ts +0 -0
  25. package/lib/table/plugin/fix-tables.d.ts.map +1 -0
  26. package/lib/table/plugin/index.d.ts +4 -0
  27. package/lib/table/plugin/index.d.ts.map +1 -0
  28. package/lib/table/{nodes → plugin}/schema.d.ts +0 -0
  29. package/lib/table/plugin/schema.d.ts.map +1 -0
  30. package/lib/table/{nodes → plugin}/table-editing.d.ts +1 -1
  31. package/lib/table/plugin/table-editing.d.ts.map +1 -0
  32. package/lib/table/{nodes → plugin}/table-map.d.ts +0 -0
  33. package/lib/table/plugin/table-map.d.ts.map +1 -0
  34. package/lib/table/{nodes → plugin}/table-view.d.ts +0 -0
  35. package/lib/table/plugin/table-view.d.ts.map +1 -0
  36. package/lib/table/{nodes → plugin}/types.d.ts +0 -0
  37. package/lib/table/plugin/types.d.ts.map +1 -0
  38. package/lib/table/{nodes → plugin}/util.d.ts +0 -0
  39. package/lib/table/plugin/util.d.ts.map +1 -0
  40. package/lib/table/utils.d.ts +3 -3
  41. package/lib/table/utils.d.ts.map +1 -1
  42. package/lib/task-list-item.d.ts.map +1 -1
  43. package/package.json +8 -7
  44. package/src/footnote/definition.ts +3 -1
  45. package/src/footnote/reference.ts +2 -1
  46. package/src/index.ts +1 -1
  47. package/src/table/command.ts +1 -1
  48. package/src/table/nodes/index.ts +7 -37
  49. package/src/table/operator-plugin/actions.ts +1 -1
  50. package/src/table/operator-plugin/calc-pos.ts +3 -2
  51. package/src/table/operator-plugin/helper.ts +2 -2
  52. package/src/table/operator-plugin/index.ts +1 -1
  53. package/src/table/operator-plugin/style.ts +12 -12
  54. package/src/table/plugin/auto-insert-zero-space.ts +51 -0
  55. package/src/table/{nodes → plugin}/cell-selection.ts +0 -0
  56. package/src/table/{nodes → plugin}/column-resizing.ts +0 -0
  57. package/src/table/{nodes → plugin}/commands.ts +0 -0
  58. package/src/table/{nodes → plugin}/copy-paste.ts +0 -0
  59. package/src/table/{nodes → plugin}/fix-tables.ts +0 -0
  60. package/src/table/plugin/index.ts +4 -0
  61. package/src/table/{nodes → plugin}/schema.ts +0 -0
  62. package/src/table/{nodes → plugin}/table-editing.ts +0 -0
  63. package/src/table/{nodes → plugin}/table-map.ts +0 -0
  64. package/src/table/{nodes → plugin}/table-view.ts +0 -0
  65. package/src/table/{nodes → plugin}/types.ts +0 -0
  66. package/src/table/{nodes → plugin}/util.ts +0 -0
  67. package/src/table/utils.ts +29 -23
  68. package/src/task-list-item.ts +2 -1
  69. package/lib/table/nodes/cell-selection.d.ts.map +0 -1
  70. package/lib/table/nodes/column-resizing.d.ts +0 -10
  71. package/lib/table/nodes/column-resizing.d.ts.map +0 -1
  72. package/lib/table/nodes/commands.d.ts.map +0 -1
  73. package/lib/table/nodes/copy-paste.d.ts.map +0 -1
  74. package/lib/table/nodes/fix-tables.d.ts.map +0 -1
  75. package/lib/table/nodes/schema.d.ts.map +0 -1
  76. package/lib/table/nodes/table-editing.d.ts.map +0 -1
  77. package/lib/table/nodes/table-map.d.ts.map +0 -1
  78. package/lib/table/nodes/table-view.d.ts.map +0 -1
  79. package/lib/table/nodes/types.d.ts.map +0 -1
  80. package/lib/table/nodes/util.d.ts.map +0 -1
package/lib/index.es.js CHANGED
@@ -1,66 +1,37 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
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 ho, InsertHr as mo, InsertImage as go, LiftListItem as wo, ModifyImage as bo, ModifyLink as Co, SinkListItem as yo, SplitListItem as ko, ToggleBold as Ao, ToggleInlineCode as Mo, ToggleItalic as So, ToggleLink as No, TurnIntoCodeFence as xo, TurnIntoHeading as Ro, TurnIntoText as To, WrapInBlockquote as Lo, WrapInBulletList as vo, WrapInOrderedList as Eo, blockquote as Io, bulletList as $o, codeFence as Do, codeInline as Oo, commonmark as _o, commonmarkNodes as zo, commonmarkPlugins as Fo, doc as Bo, em as Po, HardbreakFilterPluginKey as Wo, heading as Ho, hr as jo, image as Ko, link as qo, listItem as Uo, orderedList as Xo, paragraph as Vo, strong as Zo, text as Go } 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 R, editorViewCtx as ee, createCmd as N, commandsCtx as Ze, themeManagerCtx as L, ThemeIcon as v, ThemeBorder as mt, ThemeShadow as gt, getPalette as wt, ThemeSize as xe, schemaCtx as re } from "@milkdown/core";
7
+ import { expectDomTypeError as ye, missingRootElement as bt } from "@milkdown/exception";
8
+ import { findSelectedNodeOfType as B, findParentNode as Ct, cloneTr as Ge, calculateNodePosition as yt, browser as Re, markRule as Te } from "@milkdown/prose";
9
+ import { PluginKey as F, NodeSelection as te, Plugin as W, Selection as S, 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 O } from "@milkdown/prose/model";
12
+ import { Decoration as ke, DecorationSet as Ae } from "@milkdown/prose/view";
13
+ import { keydownHandler as St } from "@milkdown/prose/keymap";
14
+ import { Transform as Nt } from "@milkdown/prose/transform";
15
+ import { splitListItem as xt, sinkListItem as Rt, 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 InputRule(urlRegex, (state, match, start, end) => {
38
- var _a;
39
- const { schema: schema2 } = state;
40
- const [text2] = match;
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
- return state.tr.replaceWith(start, end, schema2.text(text2)).addMark(start, text2.length + start, link2);
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 urlPlugin = $prose(() => proseUrlPlugin());
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 F("MILKDOWN_FOOTNOTE_DEF_INPUT"), Le = R("ModifyFootnoteDef"), $t = be((o) => {
28
+ const e = "footnote_definition", t = "footnoteDefinition";
58
29
  return {
59
- id: id2,
60
- schema: (ctx) => ({
30
+ id: e,
31
+ schema: (n) => ({
61
32
  group: "block",
62
33
  content: "block+",
63
- defining: true,
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="${id2}"]`,
72
- getAttrs: (dom) => {
73
- if (!(dom instanceof HTMLElement)) {
74
- throw new Error();
75
- }
42
+ tag: `div[data-type="${e}"]`,
43
+ getAttrs: (l) => {
44
+ if (!(l instanceof HTMLElement))
45
+ throw ye(l);
76
46
  return {
77
- label: dom.dataset["label"]
47
+ label: l.dataset.label
78
48
  };
79
- }
49
+ },
50
+ contentElement: "dd"
80
51
  }
81
52
  ],
82
- toDOM: (node) => {
83
- const label = node.attrs["label"];
84
- const className = utils.getClassName(node.attrs, "footnote-definition");
85
- const dt = document.createElement("dt");
86
- dt.textContent = `[${label}]:`;
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
- return [
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: className,
103
- "data-label": label,
104
- "data-type": id2,
105
- id: getFootnoteDefId(label)
65
+ class: r,
66
+ "data-label": s,
67
+ "data-type": e,
68
+ id: Ye(s)
106
69
  },
107
- ["div", { class: "footnote-definition_content" }, dt, ["dd", 0]],
108
- ["div", { class: "footnote-definition_anchor" }, a]
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 }) => type === markdownId,
113
- runner: (state, node, type) => {
114
- state.openNode(type, {
115
- label: node["label"]
116
- }).next(node.children).closeNode();
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: (node) => node.type.name === id2,
121
- runner: (state, node) => {
122
- state.openNode(markdownId, void 0, {
123
- label: node.attrs["label"],
124
- identifier: node.attrs["label"]
125
- }).next(node.content).closeNode();
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: (nodeType) => [
130
- createCmd(ModifyFootnoteDef, (label = "") => (state, dispatch) => {
131
- const node = findSelectedNodeOfType(state.selection, nodeType);
132
- if (!node)
133
- return false;
134
- const { tr } = state;
135
- const _tr = tr.setNodeMarkup(node.pos, void 0, __spreadProps(__spreadValues({}, node.node.attrs), { label }));
136
- dispatch == null ? void 0 : dispatch(_tr.setSelection(NodeSelection.create(_tr.doc, node.pos)));
137
- return true;
92
+ commands: (n) => [
93
+ N(Le, (l = "") => (s, r) => {
94
+ const a = B(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: (nodeType) => [
141
- wrappingInputRule(/(?:\[\^)([^:]+)(?::)$/, nodeType, (match) => {
142
- var _a;
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
- }, () => false)
107
+ }, () => !1)
148
108
  ],
149
- prosePlugins: (type, ctx) => {
150
- return [
151
- new Plugin({
152
- key: key$2,
153
- view: (editorView) => {
154
- const inputChipRenderer = utils.themeManager.get("input-chip", {
155
- width: "12em",
156
- placeholder: "Input Footnote Label",
157
- onUpdate: (value) => {
158
- ctx.get(commandsCtx).call(ModifyFootnoteDef, value);
159
- },
160
- isBindMode: true
161
- });
162
- if (!inputChipRenderer)
163
- return {};
164
- const shouldDisplay = (view) => Boolean(type && findSelectedNodeOfType(view.state.selection, type));
165
- const getCurrentLabel = (view) => {
166
- const result = findSelectedNodeOfType(view.state.selection, type);
167
- if (!result)
168
- return;
169
- const value = result.node.attrs["label"];
170
- return value;
171
- };
172
- const renderByView = (view) => {
173
- if (!view.editable) {
174
- return;
175
- }
176
- const display = shouldDisplay(view);
177
- if (display) {
178
- inputChipRenderer.show(view);
179
- inputChipRenderer.update(getCurrentLabel(view));
180
- } else {
181
- inputChipRenderer.hide();
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 W({
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 && B(d.state.selection, n)), i = (d) => {
124
+ const u = B(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 ModifyFootnoteRef = createCmdKey("ModifyFootnoteRef");
204
- const key$1 = new PluginKey("MILKDOWN_FOOTNOTE_REF_INPUT");
205
- const footnoteReference = createNode((utils) => {
206
- const id2 = "footnote_reference";
143
+ }), ve = R("ModifyFootnoteRef"), Dt = new F("MILKDOWN_FOOTNOTE_REF_INPUT"), Ot = be((o) => {
144
+ const e = "footnote_reference";
207
145
  return {
208
- id: id2,
209
- schema: (ctx) => ({
146
+ id: e,
147
+ schema: (t) => ({
210
148
  group: "inline",
211
- inline: true,
212
- atom: true,
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="${id2}"]`,
221
- getAttrs: (dom) => {
222
- if (!(dom instanceof HTMLElement)) {
223
- throw new Error();
224
- }
158
+ tag: `sup[data-type="${e}"]`,
159
+ getAttrs: (n) => {
160
+ if (!(n instanceof HTMLElement))
161
+ throw ye(n);
225
162
  return {
226
- label: dom.dataset["label"]
163
+ label: n.dataset.label
227
164
  };
228
165
  }
229
166
  }
230
167
  ],
231
- toDOM: (node) => {
232
- const label = node.attrs["label"];
233
- const a = document.createElement("a");
234
- const href = `#${getFootnoteDefId(label)}`;
235
- a.href = href;
236
- a.textContent = `[${label}]`;
237
- a.onclick = (e) => {
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": label,
253
- "data-type": id2,
254
- id: getFootnoteRefId(label)
177
+ "data-label": l,
178
+ "data-type": e,
179
+ id: Je(l)
255
180
  },
256
- a
181
+ s
257
182
  ];
258
183
  },
259
184
  parseMarkdown: {
260
- match: ({ type }) => type === "footnoteReference",
261
- runner: (state, node, type) => {
262
- state.addNode(type, {
263
- label: node["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: (node) => node.type.name === id2,
269
- runner: (state, node) => {
270
- state.addNode("footnoteReference", void 0, void 0, {
271
- label: node.attrs["label"],
272
- identifier: node.attrs["label"]
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: (nodeType) => [
278
- createCmd(ModifyFootnoteRef, (label = "") => (state, dispatch) => {
279
- const node = findSelectedNodeOfType(state.selection, nodeType);
280
- if (!node)
281
- return false;
282
- const { tr } = state;
283
- const _tr = tr.setNodeMarkup(node.pos, void 0, __spreadProps(__spreadValues({}, node.node.attrs), { label }));
284
- dispatch == null ? void 0 : dispatch(_tr.setSelection(NodeSelection.create(_tr.doc, node.pos)));
285
- return true;
202
+ commands: (t) => [
203
+ N(ve, (n = "") => (l, s) => {
204
+ const r = B(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: (nodeType) => [
289
- new InputRule(/(?:\[\^)([^\]]+)(?:\])$/, (state, match, start, end) => {
290
- const $start = state.doc.resolve(start);
291
- const index = $start.index();
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
- const label = match[1];
297
- return state.tr.replaceRangeWith(start, end, nodeType.create({
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: (type, ctx) => {
303
- const inputChipRenderer = utils.themeManager.get("input-chip", {
222
+ prosePlugins: (t, n) => {
223
+ const l = o.themeManager.get("input-chip", {
304
224
  width: "12em",
305
225
  placeholder: "Input Footnote Label",
306
- onUpdate: (value) => {
307
- ctx.get(commandsCtx).call(ModifyFootnoteRef, value);
226
+ onUpdate: (i) => {
227
+ n.get(Ze).call(ve, i);
308
228
  },
309
- isBindMode: true
229
+ isBindMode: !0
310
230
  });
311
- if (!inputChipRenderer)
231
+ if (!l)
312
232
  return [];
313
- const shouldDisplay = (view) => Boolean(type && findSelectedNodeOfType(view.state.selection, type));
314
- const getCurrentLabel = (view) => {
315
- const result = findSelectedNodeOfType(view.state.selection, type);
316
- if (!result)
317
- return;
318
- const value = result.node.attrs["label"];
319
- return value;
320
- };
321
- const renderByView = (view) => {
322
- if (!view.editable) {
233
+ const s = (i) => Boolean(t && B(i.state.selection, t)), r = (i) => {
234
+ const c = B(i.state.selection, t);
235
+ return c ? c.node.attrs.label : void 0;
236
+ }, a = (i) => {
237
+ if (!i.editable)
323
238
  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 Plugin({
335
- key: key$1,
336
- view: (editorView) => {
337
- inputChipRenderer.init(editorView);
338
- renderByView(editorView);
339
- return {
340
- update: (view, prevState) => {
341
- const isEqualSelection = (prevState == null ? void 0 : prevState.doc.eq(view.state.doc)) && prevState.selection.eq(view.state.selection);
342
- if (isEqualSelection)
343
- return;
344
- renderByView(view);
345
- },
346
- destroy: () => {
347
- inputChipRenderer.destroy();
348
- }
349
- };
350
- }
242
+ new W({
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
- const cache = /* @__PURE__ */ new WeakMap();
357
- const readFromCache = (key2) => cache.get(key2);
358
- const addToCache = (key2, value) => {
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(), _t = (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
- rectBetween(a, b) {
415
- const { left: leftA, right: rightA, top: topA, bottom: bottomA } = this.findCell(a);
416
- const { left: leftB, right: rightB, top: topB, bottom: bottomB } = this.findCell(b);
417
- return new Rect(Math.min(leftA, leftB), Math.min(topA, topB), Math.max(rightA, rightB), Math.max(bottomA, bottomB));
418
- }
419
- cellsInRect(rect) {
420
- const result = [], seen = {};
421
- for (let row = rect.top; row < rect.bottom; row++) {
422
- for (let col = rect.left; col < rect.right; col++) {
423
- const index = row * this.width + col, pos = this.map[index];
424
- if (seen[pos])
425
- continue;
426
- seen[pos] = true;
427
- if ((col != rect.left || !col || this.map[index - 1] != pos) && (row != rect.top || !row || this.map[index - this.width] != pos))
428
- result.push(pos);
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
- return result;
432
- }
433
- positionAt(row, col, table2) {
434
- for (let i = 0, rowStart = 0; ; i++) {
435
- const rowEnd = rowStart + table2.child(i).nodeSize;
436
- if (i == row) {
437
- let index = col + row * this.width;
438
- const rowEndIndex = (row + 1) * this.width;
439
- while (index < rowEndIndex && this.map[index] < rowStart)
440
- index++;
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
- rowStart = rowEnd;
444
- }
445
- }
446
- static get(table2) {
447
- return readFromCache(table2) || addToCache(table2, computeMap(table2));
448
- }
449
- }
450
- function computeMap(table2) {
451
- if (table2.type.spec["tableRole"] != "table")
452
- throw new RangeError("Not a table node: " + table2.type.name);
453
- const width = findWidth(table2), height = table2.childCount;
454
- const map = [];
455
- const colWidths = [];
456
- let mapPos = 0, problems = void 0;
457
- for (let i = 0, e = width * height; i < e; i++)
458
- map[i] = 0;
459
- for (let row = 0, pos = 0; row < height; row++) {
460
- const rowNode = table2.child(row);
461
- pos++;
462
- for (let i = 0; ; i++) {
463
- while (mapPos < map.length && map[mapPos] != 0)
464
- mapPos++;
465
- if (i == rowNode.childCount)
314
+ s = r;
315
+ }
316
+ }
317
+ static get(e) {
318
+ return _t(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 cellNode = rowNode.child(i), { colspan, rowspan, colwidth } = cellNode.attrs;
468
- for (let h = 0; h < rowspan; h++) {
469
- if (h + row >= height) {
470
- (problems || (problems = [])).push({
336
+ const b = u.child(h), { colspan: w, rowspan: C, colwidth: Ne } = 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: rowspan - h
341
+ pos: d,
342
+ n: C - H
474
343
  });
475
344
  break;
476
345
  }
477
- const start = mapPos + h * width;
478
- for (let w = 0; w < colspan; w++) {
479
- if (map[start + w] == 0)
480
- map[start + w] = pos;
481
- else
482
- (problems || (problems = [])).push({
483
- type: "collision",
484
- row,
485
- pos,
486
- n: colspan - w
487
- });
488
- const colW = colwidth && colwidth[w];
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 _ = 0; _ < w; _++) {
348
+ n[le + _] == 0 ? n[le + _] = d : (r || (r = [])).push({
349
+ type: "collision",
350
+ row: c,
351
+ pos: d,
352
+ n: w - _
353
+ });
354
+ const X = Ne && Ne[_];
355
+ if (X) {
356
+ const j = (le + _) % 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
- mapPos += colspan;
501
- pos += cellNode.nodeSize;
502
- }
503
- const expectedPos = (row + 1) * width;
504
- let missing = 0;
505
- while (mapPos < expectedPos)
506
- if (map[mapPos++] == 0)
507
- missing++;
508
- if (missing)
509
- (problems || (problems = [])).push({ type: "missing", row, n: missing });
510
- pos++;
511
- }
512
- const tableMap = new TableMap(width, height, map, problems);
513
- let badWidths = false;
514
- for (let i = 0; !badWidths && i < colWidths.length; i += 2)
515
- if (colWidths[i] != null && colWidths[i + 1] < height)
516
- badWidths = true;
517
- if (badWidths)
518
- findBadColWidths(tableMap, colWidths, table2);
519
- return tableMap;
520
- }
521
- function findWidth(table2) {
522
- let width = -1, hasRowSpan = false;
523
- for (let row = 0; row < table2.childCount; row++) {
524
- const rowNode = table2.child(row);
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 i = 0; i < rowNode.childCount; i++) {
536
- const cell = rowNode.child(i);
537
- rowWidth += cell.attrs["colspan"];
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
- if (width == -1)
542
- width = rowWidth;
543
- else if (width != rowWidth)
544
- width = Math.max(width, rowWidth);
545
- }
546
- return width;
547
- }
548
- function findBadColWidths(map, colWidths, table2) {
549
- if (!map.problems)
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
- seen[pos] = true;
556
- const node = table2.nodeAt(pos);
557
- let updated = null;
558
- for (let j = 0; j < node.attrs["colspan"]; j++) {
559
- const col = (i + j) % map.width, colWidth = colWidths[col * 2];
560
- if (colWidth != null && (!node.attrs["colwidth"] || node.attrs["colwidth"][j] != colWidth))
561
- (updated || (updated = freshColWidth(node.attrs)))[j] = colWidth;
562
- }
563
- if (updated)
564
- map.problems.unshift({
565
- type: "colwidth mismatch",
566
- pos,
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 freshColWidth(attrs) {
572
- if (attrs["colwidth"])
573
- return attrs["colwidth"].slice();
574
- const result = [];
575
- for (let i = 0; i < attrs["colspan"]; i++)
576
- result.push(0);
577
- return result;
578
- }
579
- class CellSelection extends Selection {
580
- constructor($anchorCell, $headCell = $anchorCell) {
581
- const table2 = $anchorCell.node(-1), map = TableMap.get(table2), start = $anchorCell.start(-1);
582
- const rect = map.rectBetween($anchorCell.pos - start, $headCell.pos - start);
583
- const doc2 = $anchorCell.node(0);
584
- const cells = map.cellsInRect(rect).filter((p) => p != $headCell.pos - start);
585
- cells.unshift($headCell.pos - start);
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 S {
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(ranges[0].$from, ranges[0].$to, ranges);
591
- this.$anchorCell = $anchorCell;
592
- this.$headCell = $headCell;
593
- this.$anchorCell = $anchorCell;
594
- this.$headCell = $headCell;
595
- }
596
- map(doc2, mapping) {
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) && Se(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 TextSelection.between($anchorCell, $headCell);
440
+ return D.between(n, l);
609
441
  }
610
442
  content() {
611
- const table2 = this.$anchorCell.node(-1), map = TableMap.get(table2), start = this.$anchorCell.start(-1);
612
- const rect = map.rectBetween(this.$anchorCell.pos - start, this.$headCell.pos - start);
613
- const seen = {}, rows = [];
614
- for (let row = rect.top; row < rect.bottom; row++) {
615
- const rowContent = [];
616
- for (let index = row * map.width + rect.left, col = rect.left; col < rect.right; col++, index++) {
617
- const pos = map.map[index];
618
- if (!seen[pos]) {
619
- seen[pos] = true;
620
- const cellRect = map.findCell(pos);
621
- let cell = table2.nodeAt(pos);
622
- const extraLeft = rect.left - cellRect.left, extraRight = cellRect.right - rect.right;
623
- if (extraLeft > 0 || extraRight > 0) {
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 = z(C, 0, b)), w > 0 && (C = z(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 (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {
635
- const attrs = setAttr(cell.attrs, "rowspan", Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top));
636
- if (cellRect.top < rect.top)
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
- rowContent.push(cell);
461
+ c.push(h);
642
462
  }
643
463
  }
644
- rows.push(table2.child(row).copy(Fragment.from(rowContent)));
464
+ r.push(e.child(i).copy(E.from(c)));
645
465
  }
646
- const fragment = this.isColSelection() && this.isRowSelection() ? table2 : rows;
647
- return new Slice(Fragment.from(fragment), 1, 1);
648
- }
649
- replace(tr, content = Slice.empty) {
650
- const mapFrom = tr.steps.length, ranges = this.ranges;
651
- for (let i = 0; i < ranges.length; i++) {
652
- const { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);
653
- tr.replace(mapping.map($from.pos), mapping.map($to.pos), i ? Slice.empty : content);
466
+ const a = this.isColSelection() && this.isRowSelection() ? e : r;
467
+ return new O(E.from(a), 1, 1);
468
+ }
469
+ replace(e, t = O.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 ? O.empty : t);
654
474
  }
655
- const sel = Selection.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);
656
- if (sel)
657
- tr.setSelection(sel);
475
+ const s = S.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)), -1);
476
+ s && e.setSelection(s);
658
477
  }
659
- replaceWith(tr, node) {
660
- this.replace(tr, new Slice(Fragment.from(node), 0, 0));
478
+ replaceWith(e, t) {
479
+ this.replace(e, new O(E.from(t), 0, 0));
661
480
  }
662
- forEachCell(f) {
663
- const table2 = this.$anchorCell.node(-1), map = TableMap.get(table2), start = this.$anchorCell.start(-1);
664
- const cells = map.cellsInRect(map.rectBetween(this.$anchorCell.pos - start, this.$headCell.pos - start));
665
- for (let i = 0; i < cells.length; i++)
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 anchorTop = this.$anchorCell.index(-1), headTop = this.$headCell.index(-1);
670
- if (Math.min(anchorTop, headTop) > 0)
671
- return false;
672
- const anchorBot = anchorTop + this.$anchorCell.nodeAfter.attrs["rowspan"], headBot = headTop + this.$headCell.nodeAfter.attrs["rowspan"];
673
- return Math.max(anchorBot, headBot) == this.$headCell.node(-1).childCount;
674
- }
675
- static colSelection($anchorCell, $headCell = $anchorCell) {
676
- const map = TableMap.get($anchorCell.node(-1)), start = $anchorCell.start(-1);
677
- const anchorRect = map.findCell($anchorCell.pos - start), headRect = map.findCell($headCell.pos - start);
678
- const doc2 = $anchorCell.node(0);
679
- if (anchorRect.top <= headRect.top) {
680
- if (anchorRect.top > 0) {
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 (headRect.bottom < map.height) {
685
- const pos = map.map[map.width * (map.height - 1) + headRect.right - 1];
686
- $headCell = doc2.resolve(start + pos);
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 (headRect.top > 0) {
690
- const left = map.map[anchorRect.left];
691
- $headCell = doc2.resolve(start + left);
505
+ if (r.top > 0) {
506
+ const i = n.map[s.left];
507
+ t = a.resolve(l + i);
692
508
  }
693
- if (anchorRect.bottom < map.height) {
694
- const pos = map.map[map.width * (map.height - 1) + anchorRect.right - 1];
695
- $anchorCell = doc2.resolve(start + pos);
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 CellSelection($anchorCell, $headCell);
514
+ return new m(e, t);
699
515
  }
700
516
  isRowSelection() {
701
- const map = TableMap.get(this.$anchorCell.node(-1)), start = this.$anchorCell.start(-1);
702
- const anchorLeft = map.colCount(this.$anchorCell.pos - start), headLeft = map.colCount(this.$headCell.pos - start);
703
- if (Math.min(anchorLeft, headLeft) > 0)
704
- return false;
705
- const anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs["colspan"], headRight = headLeft + this.$headCell.nodeAfter.attrs["colspan"];
706
- return Math.max(anchorRight, headRight) == map.width;
707
- }
708
- eq(other) {
709
- return other instanceof CellSelection && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;
710
- }
711
- static rowSelection($anchorCell, $headCell = $anchorCell) {
712
- const map = TableMap.get($anchorCell.node(-1)), start = $anchorCell.start(-1);
713
- const anchorRect = map.findCell($anchorCell.pos - start), headRect = map.findCell($headCell.pos - start);
714
- const doc2 = $anchorCell.node(0);
715
- if (anchorRect.left <= headRect.left) {
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 (headRect.right < map.width) {
721
- const pos = map.map[map.width * (headRect.top + 1) - 1];
722
- $headCell = doc2.resolve(start + pos);
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 (headRect.left > 0) {
726
- const pos = map.map[headRect.top * map.width];
727
- $headCell = doc2.resolve(start + pos);
538
+ if (r.left > 0) {
539
+ const i = n.map[r.top * n.width];
540
+ t = a.resolve(l + i);
728
541
  }
729
- if (anchorRect.right < map.width) {
730
- const pos = map.map[map.width * (anchorRect.top + 1) - 1];
731
- $anchorCell = doc2.resolve(start + pos);
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 CellSelection($anchorCell, $headCell);
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(doc2, json) {
744
- return new CellSelection(doc2.resolve(json.anchor), doc2.resolve(json.head));
556
+ static fromJSON(e, t) {
557
+ return new m(e.resolve(t.anchor), e.resolve(t.head));
745
558
  }
746
- static create(doc2, anchorCell, headCell = anchorCell) {
747
- return new CellSelection(doc2.resolve(anchorCell), doc2.resolve(headCell));
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 CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
563
+ return new Me(this.$anchorCell.pos, this.$headCell.pos);
751
564
  }
752
565
  }
753
- CellSelection.prototype.visible = false;
754
- Selection.jsonID("cell", CellSelection);
755
- class CellBookmark {
756
- constructor(anchor, head) {
757
- this.anchor = anchor;
758
- this.head = head;
759
- this.anchor = anchor;
760
- this.head = head;
566
+ m.prototype.visible = !1;
567
+ S.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(mapping) {
763
- return new CellBookmark(mapping.map(this.anchor), mapping.map(this.head));
572
+ map(e) {
573
+ return new Me(e.map(this.anchor), e.map(this.head));
764
574
  }
765
- resolve(doc2) {
766
- const $anchorCell = doc2.resolve(this.anchor), $headCell = doc2.resolve(this.head);
767
- if ($anchorCell.parent.type.spec["tableRole"] == "row" && $headCell.parent.type.spec["tableRole"] == "row" && $anchorCell.index() < $anchorCell.parent.childCount && $headCell.index() < $headCell.parent.childCount && inSameTable($anchorCell, $headCell))
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 && Se(t, n) ? new m(t, n) : S.near(n, 1);
771
578
  }
772
579
  }
773
- function drawCellSelection(state) {
774
- if (!(state.selection instanceof CellSelection))
580
+ function Ht(o) {
581
+ if (!(o.selection instanceof m))
775
582
  return null;
776
- const cells = [];
777
- state.selection.forEachCell((node, pos) => {
778
- cells.push(Decoration.node(pos, pos + node.nodeSize, { class: "selectedCell" }));
779
- });
780
- return DecorationSet.create(state.doc, cells);
781
- }
782
- function isCellBoundarySelection({ $from, $to }) {
783
- if ($from.pos == $to.pos || $from.pos < $from.pos - 6)
784
- return false;
785
- let afterFrom = $from.pos, beforeTo = $to.pos, depth = $from.depth;
786
- for (; depth >= 0; depth--, afterFrom++)
787
- if ($from.after(depth + 1) < $from.end(depth))
788
- break;
789
- for (let d = $to.depth; d >= 0; d--, beforeTo--)
790
- if ($to.before(d + 1) > $to.start(d))
791
- break;
792
- return afterFrom == beforeTo && /row|table/.test($from.node(depth).type.spec["tableRole"]);
793
- }
794
- function isTextSelectionAcrossCells({ $from, $to }) {
795
- let fromCellBoundaryNode;
796
- let toCellBoundaryNode;
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 i = $to.depth; i > 0; i--) {
805
- const node = $to.node(i);
806
- if (node.type.spec["tableRole"] === "cell" || node.type.spec["tableRole"] === "header_cell") {
807
- toCellBoundaryNode = node;
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 fromCellBoundaryNode !== toCellBoundaryNode && $to.parentOffset === 0;
812
- }
813
- function normalizeSelection(state, tr, allowTableNodeSelection) {
814
- const sel = (tr || state).selection, doc2 = (tr || state).doc;
815
- let normalize, role;
816
- if (sel instanceof NodeSelection && (role = sel.node.type.spec["tableRole"])) {
817
- if (role == "cell" || role == "header_cell") {
818
- normalize = CellSelection.create(doc2, sel.from);
819
- } else if (role == "row") {
820
- const $cell = doc2.resolve(sel.from + 1);
821
- normalize = CellSelection.rowSelection($cell, $cell);
822
- } else if (!allowTableNodeSelection) {
823
- const map = TableMap.get(sel.node), start = sel.from + 1;
824
- const pos = map.map[map.width * map.height - 1];
825
- const lastCell = start + pos;
826
- normalize = CellSelection.create(doc2, start + 1, lastCell);
827
- }
828
- } else if (sel instanceof TextSelection && isCellBoundarySelection(sel)) {
829
- normalize = TextSelection.create(doc2, sel.from);
830
- } else if (sel instanceof TextSelection && isTextSelectionAcrossCells(sel)) {
831
- normalize = TextSelection.create(doc2, sel.$from.start(), sel.$from.end());
832
- }
833
- if (normalize)
834
- (tr || (tr = state.tr)).setSelection(normalize);
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 prop in extraAttrs) {
847
- const getter = extraAttrs[prop].getFromDOM;
848
- const value = getter && getter(dom);
849
- if (value != null)
850
- result[prop] = value;
851
- }
852
- return result;
853
- }
854
- function setCellAttrs(node, extraAttrs) {
855
- const attrs = {};
856
- if (node.attrs["colspan"] != 1)
857
- attrs["colspan"] = node.attrs["colspan"];
858
- if (node.attrs["rowspan"] != 1)
859
- attrs["rowspan"] = node.attrs["rowspan"];
860
- if (node.attrs["colwidth"])
861
- attrs["data-colwidth"] = node.attrs["colwidth"].join(",");
862
- for (const prop in extraAttrs) {
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 prop in extraAttrs)
877
- cellAttrs[prop] = { default: extraAttrs[prop].default };
878
- const finalAttrs = cellAttrs;
879
- const schema2 = {
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: true,
884
- group: options.tableGroup,
667
+ isolating: !0,
668
+ group: o.tableGroup,
885
669
  parseDOM: [{ tag: "table" }],
886
670
  toDOM() {
887
671
  return ["table", ["tbody", 0]];
@@ -896,401 +680,471 @@ function tableNodesSpecCreator(options) {
896
680
  }
897
681
  },
898
682
  table_cell: {
899
- content: options.cellContent,
900
- attrs: finalAttrs,
683
+ content: o.cellContent,
684
+ attrs: n,
901
685
  tableRole: "cell",
902
- isolating: true,
903
- parseDOM: [{ tag: "td", getAttrs: (dom) => getCellAttrs(dom, extraAttrs) }],
904
- toDOM(node) {
905
- return ["td", setCellAttrs(node, extraAttrs), 0];
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: options.cellContent,
910
- attrs: finalAttrs,
693
+ content: o.cellContent,
694
+ attrs: n,
911
695
  tableRole: "header_cell",
912
- isolating: true,
913
- parseDOM: [{ tag: "th", getAttrs: (dom) => getCellAttrs(dom, extraAttrs) }],
914
- toDOM(node) {
915
- return ["th", setCellAttrs(node, extraAttrs), 0];
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
- return schema2;
920
- }
921
- function tableNodeTypes(schema2) {
922
- let result = schema2.cached["tableNodeTypes"];
923
- if (!result) {
924
- result = schema2.cached["tableNodeTypes"] = {};
925
- for (const name in schema2.nodes) {
926
- const type = schema2.nodes[name], role = type == null ? void 0 : type.spec["tableRole"];
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 result;
713
+ return e;
932
714
  }
933
- const schema = tableNodesSpecCreator({
715
+ const V = Ut({
934
716
  tableGroup: "block",
935
717
  cellContent: "paragraph",
936
718
  cellAttributes: {
937
719
  alignment: {
938
720
  default: "left",
939
- getFromDOM: (dom) => dom.style.textAlign || "left",
940
- setDOMAttr: (value, attrs) => {
941
- attrs["style"] = `text-align: ${value || "left"}`;
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 cellAround($pos) {
947
- for (let d = $pos.depth - 1; d > 0; d--)
948
- if ($pos.node(d).type.spec["tableRole"] == "row")
949
- return $pos.node(0).resolve($pos.before(d + 1));
950
- return void 0;
951
- }
952
- function pointsAtCell($pos) {
953
- if ($pos.parent.type.spec["tableRole"] == "row")
954
- return $pos.nodeAfter;
955
- return null;
956
- }
957
- function moveCellForward($pos) {
958
- return $pos.node(0).resolve($pos.pos + $pos.nodeAfter.nodeSize);
959
- }
960
- function inSameTable($a, $b) {
961
- return $a.depth == $b.depth && $a.pos >= $b.start(-1) && $a.pos <= $b.end(-1);
962
- }
963
- function nextCell($pos, axis, dir) {
964
- const start = $pos.start(-1), map = TableMap.get($pos.node(-1));
965
- const moved = map.nextCell($pos.pos - start, axis, dir);
966
- return moved == null ? null : $pos.node(0).resolve(start + moved);
967
- }
968
- function setAttr(attrs, name, value) {
969
- const result = {};
970
- for (const prop in attrs)
971
- result[prop] = attrs[prop];
972
- result[name] = value;
973
- return result;
974
- }
975
- function removeColSpan(attrs, pos, n = 1) {
976
- const result = setAttr(attrs, "colspan", attrs["colspan"] - n);
977
- if (result["colwidth"]) {
978
- const widths = result["colwidth"];
979
- result["colwidth"] = widths.slice();
980
- widths.splice(pos, n);
981
- if (!widths.some((w) => w > 0))
982
- result["colwidth"] = null;
983
- }
984
- return result;
985
- }
986
- function isInTable(state) {
987
- const $head = state.selection.$head;
988
- for (let d = $head.depth; d > 0; d--)
989
- if ($head.node(d).type.spec["tableRole"] == "row")
990
- return true;
991
- return false;
992
- }
993
- function selectionCell(state) {
994
- const sel = state.selection;
995
- if (sel instanceof CellSelection) {
996
- return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
997
- } else if (sel.node && sel.node.type.spec["tableRole"] == "cell") {
998
- return sel.$anchor;
999
- }
1000
- return cellAround(sel.$head) || cellNear(sel.$head);
1001
- }
1002
- function cellNear($pos) {
1003
- for (let after = $pos.nodeAfter, pos = $pos.pos; after; after = after.firstChild, pos++) {
1004
- const role = after.type.spec["tableRole"];
1005
- if (role == "cell" || role == "header_cell")
1006
- return $pos.doc.resolve(pos);
1007
- }
1008
- for (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {
1009
- const role = before.type.spec["tableRole"];
1010
- if (role == "cell" || role == "header_cell")
1011
- return $pos.doc.resolve(pos - before.nodeSize);
1012
- }
1013
- return;
1014
- }
1015
- function addColSpan(attrs, pos, n = 1) {
1016
- const result = setAttr(attrs, "colspan", attrs["colspan"] + n);
1017
- if (result["colwidth"]) {
1018
- const widths = result["colwidth"];
1019
- result["colwidth"] = widths.slice();
1020
- for (let i = 0; i < n; i++)
1021
- widths.splice(pos, 0, 0);
1022
- }
1023
- return result;
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 Se(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 z(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(S.near(s.doc.resolve(l), 1)), t == null || t(s.scrollIntoView()), !0;
1044
807
  };
1045
- const findTable = (selection) => findParentNode((node) => node.type.spec["tableRole"] === "table")(selection);
1046
- const getCellsInColumn = (columnIndex) => (selection) => {
1047
- const table2 = findTable(selection);
1048
- if (!table2)
1049
- return void 0;
1050
- const map = TableMap.get(table2.node);
1051
- if (columnIndex < 0 || columnIndex >= map.width) {
1052
- return void 0;
1053
- }
1054
- return map.cellsInRect({ left: columnIndex, right: columnIndex + 1, top: 0, bottom: map.height }).map((pos) => {
1055
- const node = table2.node.nodeAt(pos);
1056
- if (!node)
1057
- throw new Error();
1058
- const start = pos + table2.start;
1059
- return {
1060
- pos: start,
1061
- start: start + 1,
1062
- node
1063
- };
1064
- });
808
+ function P(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 = P(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 = P(o);
842
+ e(tt(o.tr, t, t.right));
843
+ }
844
+ return !0;
1065
845
  };
1066
- const getCellsInRow = (rowIndex) => (selection) => {
1067
- const table2 = findTable(selection);
1068
- if (!table2)
1069
- return void 0;
1070
- const map = TableMap.get(table2.node);
1071
- if (rowIndex < 0 || rowIndex >= map.height) {
1072
- return void 0;
1073
- }
1074
- return map.cellsInRect({ left: 0, right: map.width, top: rowIndex, bottom: rowIndex + 1 }).map((pos) => {
1075
- const node = table2.node.nodeAt(pos);
1076
- if (!node)
1077
- throw new Error();
1078
- const start = pos + table2.start;
1079
- return {
1080
- pos: start,
1081
- start: start + 1,
1082
- node
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, z(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 = P(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
- const createTable = (schema2, rowsCount = 3, colsCount = 3) => {
1087
- const { cell: tableCell, header_cell: tableHeader, row: tableRow, table: table2 } = tableNodeTypes(schema2);
1088
- const cells = Array(colsCount).fill(0).map(() => tableCell.createAndFill(null));
1089
- const headerCells = Array(colsCount).fill(0).map(() => tableHeader.createAndFill(null));
1090
- const rows = Array(rowsCount).fill(0).map((_, i) => tableRow.create(null, i === 0 ? headerCells : cells));
1091
- return table2.create(null, rows);
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 = P(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
- const selectLine = (type) => (index) => (tr) => {
1094
- const table2 = findTable(tr.selection);
1095
- const isRowSelection = type === "row";
1096
- if (table2) {
1097
- const map = TableMap.get(table2.node);
1098
- if (index >= 0 && index < (isRowSelection ? map.height : map.width)) {
1099
- const lastCell = map.positionAt(isRowSelection ? index : map.height - 1, isRowSelection ? map.width - 1 : index, table2.node);
1100
- const $lastCell = tr.doc.resolve(table2.start + lastCell);
1101
- const createCellSelection = isRowSelection ? CellSelection.rowSelection : CellSelection.colSelection;
1102
- const firstCell = map.positionAt(isRowSelection ? index : 0, isRowSelection ? 0 : index, table2.node);
1103
- const $firstCell = tr.doc.resolve(table2.start + firstCell);
1104
- return cloneTr(tr.setSelection(createCellSelection($lastCell, $firstCell)));
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
- return tr;
1108
- };
1109
- const getCellsInTable = (selection) => {
1110
- const table2 = findTable(selection);
1111
- if (!table2) {
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
- const map = TableMap.get(table2.node);
1115
- const cells = map.cellsInRect({
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
+ }, Oe = (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
+ }, _e = (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: map.width,
1017
+ right: t.width,
1118
1018
  top: 0,
1119
- bottom: map.height
1120
- });
1121
- return cells.map((nodePos) => {
1122
- const node = table2.node.nodeAt(nodePos);
1123
- const pos = nodePos + table2.start;
1124
- return { pos, start: pos + 1, node };
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 };
1125
1023
  });
1126
- };
1127
- const selectTable = (tr) => {
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 tr;
1033
+ return o;
1138
1034
  };
1139
- function addRowWithAlignment(tr, { map, tableStart, table: table2 }, row) {
1140
- const rowPos = Array(row).fill(0).reduce((acc, _, i) => {
1141
- return acc + table2.child(i).nodeSize;
1142
- }, tableStart);
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
- tr.insert(rowPos, rowType.create(null, cells));
1149
- return tr;
1150
- }
1151
- const getCellSelection = (view) => view.state.selection;
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: map.width,
1045
+ right: e.width,
1158
1046
  top: 0,
1159
1047
  bottom: 1
1160
- });
1161
- const selectedCells = map.cellsInRect(map.rectBetween(selection.$anchorCell.pos - start, selection.$headCell.pos - start));
1162
- for (let i = 0, count = cells.length; i < count; i++) {
1163
- if (selectedCells.indexOf(cells[i]) === -1) {
1164
- return false;
1165
- }
1166
- }
1167
- return true;
1168
- };
1169
- const calculateItem = (actions, view) => {
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
- item.$.classList.remove("hide");
1060
+ t.$.classList.remove("hide");
1178
1061
  });
1179
- };
1180
- const createActions = (ctx) => {
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
- $: (_a = ctx.get(themeManagerCtx).get(ThemeIcon, "leftArrow")) == null ? void 0 : _a.dom,
1185
- command: () => addColumnBefore,
1186
- disable: (view) => !getCellSelection(view).isColSelection()
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
- $: (_b = ctx.get(themeManagerCtx).get(ThemeIcon, "rightArrow")) == null ? void 0 : _b.dom,
1190
- command: () => addColumnAfter,
1191
- disable: (view) => !getCellSelection(view).isColSelection()
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
- $: (_c = ctx.get(themeManagerCtx).get(ThemeIcon, "upArrow")) == null ? void 0 : _c.dom,
1195
- command: () => (state, dispatch) => {
1196
- if (!isInTable(state))
1197
- return false;
1198
- if (dispatch) {
1199
- const rect = selectedRect(state);
1200
- dispatch(addRowWithAlignment(state.tr, rect, rect.top));
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 = P(c);
1082
+ d(ze(c.tr, u, u.top));
1201
1083
  }
1202
- return true;
1084
+ return !0;
1203
1085
  },
1204
- disable: (view) => !getCellSelection(view).isRowSelection() || getCellSelection(view).$head.parent.type.name === "table_header"
1086
+ disable: (c) => !T(c).isRowSelection() || T(c).$head.parent.type.name === "table_header"
1205
1087
  },
1206
1088
  [3]: {
1207
- $: (_d = ctx.get(themeManagerCtx).get(ThemeIcon, "downArrow")) == null ? void 0 : _d.dom,
1208
- command: () => (state, dispatch) => {
1209
- if (!isInTable(state))
1210
- return false;
1211
- if (dispatch) {
1212
- const rect = selectedRect(state);
1213
- dispatch(addRowWithAlignment(state.tr, rect, rect.bottom));
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 = P(c);
1095
+ d(ze(c.tr, u, u.bottom));
1214
1096
  }
1215
- return true;
1097
+ return !0;
1216
1098
  },
1217
- disable: (view) => !getCellSelection(view).isRowSelection()
1099
+ disable: (c) => !T(c).isRowSelection()
1218
1100
  },
1219
1101
  [4]: {
1220
- $: (_e = ctx.get(themeManagerCtx).get(ThemeIcon, "alignLeft")) == null ? void 0 : _e.dom,
1221
- command: () => setCellAttr("alignment", "left"),
1222
- disable: (view) => !getCellSelection(view).isColSelection()
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
- $: (_f = ctx.get(themeManagerCtx).get(ThemeIcon, "alignCenter")) == null ? void 0 : _f.dom,
1226
- command: () => setCellAttr("alignment", "center"),
1227
- disable: (view) => !getCellSelection(view).isColSelection()
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
- $: (_g = ctx.get(themeManagerCtx).get(ThemeIcon, "alignRight")) == null ? void 0 : _g.dom,
1231
- command: () => setCellAttr("alignment", "right"),
1232
- disable: (view) => !getCellSelection(view).isColSelection()
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
- $: (_h = ctx.get(themeManagerCtx).get(ThemeIcon, "delete")) == null ? void 0 : _h.dom,
1236
- command: (_, view) => {
1237
- const selection = getCellSelection(view);
1238
- const isCol = selection.isColSelection();
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: (view) => {
1249
- const selection = getCellSelection(view);
1250
- if (selection.isRowSelection()) {
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 calculatePosition = (view, dom) => {
1262
- const { selection } = view.state;
1263
- const isCol = selection.isColSelection();
1264
- const isRow = selection.isRowSelection();
1265
- calculateNodePosition(view, dom, (selected, target, parent) => {
1266
- const $editor = dom.parentElement;
1267
- if (!$editor) {
1268
- throw new Error();
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 ToolTipPos = /* @__PURE__ */ ((ToolTipPos2) => {
1279
- ToolTipPos2["Left"] = "Left";
1280
- ToolTipPos2["Top"] = "Top";
1281
- ToolTipPos2["Point"] = "Point";
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 x = /* @__PURE__ */ ((o) => (o.Left = "Left", o.Top = "Top", o.Point = "Point", o))(x || {});
1140
+ const mn = (o, { css: e, injectGlobal: t }) => {
1141
+ const n = wt(o), l = o.get(xe, "radius"), s = o.get(xe, "lineWidth");
1142
+ return t`
1289
1143
  .milkdown {
1290
1144
  .tableWrapper {
1291
1145
  table {
1292
- width: calc(100% - 2em) !important;
1293
- margin: 1em 0 1em 1em !important;
1146
+ width: calc(100% - 32px) !important;
1147
+ margin: 16px 0 16px 16px !important;
1294
1148
 
1295
1149
  .milkdown-cell-left,
1296
1150
  .milkdown-cell-point,
@@ -1306,34 +1160,34 @@ const injectStyle = (themeManager, { css, injectGlobal }) => {
1306
1160
  width: 100%;
1307
1161
  display: block;
1308
1162
  transition: all 0.2s ease-in-out;
1309
- background: ${palette("secondary", 0.12)};
1163
+ background: ${n("secondary", 0.12)};
1310
1164
  content: '';
1311
1165
  }
1312
1166
 
1313
1167
  &:hover::after {
1314
- background: ${palette("secondary", 0.38)};
1168
+ background: ${n("secondary", 0.38)};
1315
1169
  }
1316
1170
  }
1317
1171
 
1318
1172
  .milkdown-cell-left {
1319
- left: calc(-6px - 0.5em);
1173
+ left: -14px;
1320
1174
  top: 0;
1321
1175
  bottom: 0;
1322
- width: 0.5em;
1176
+ width: 8px;
1323
1177
  }
1324
1178
 
1325
1179
  .milkdown-cell-top {
1326
1180
  left: 0;
1327
1181
  right: 0;
1328
- top: calc(-6px - 0.5em);
1329
- height: 0.5em;
1182
+ top: -14px;
1183
+ height: 8px;
1330
1184
  }
1331
1185
 
1332
1186
  .milkdown-cell-point {
1333
- left: calc(-2px - 1em);
1334
- top: calc(-2px - 1em);
1335
- width: 1em;
1336
- height: 1em;
1187
+ left: -18px;
1188
+ top: -18px;
1189
+ width: 16px;
1190
+ height: 16px;
1337
1191
 
1338
1192
  .icon {
1339
1193
  position: absolute;
@@ -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,29 +1209,29 @@ const injectStyle = (themeManager, { css, injectGlobal }) => {
1356
1209
 
1357
1210
  position: absolute;
1358
1211
 
1359
- border-radius: ${radius};
1212
+ border-radius: ${l};
1360
1213
 
1361
- ${themeManager.get(ThemeBorder, void 0)};
1362
- ${themeManager.get(ThemeShadow, void 0)};
1214
+ ${o.get(mt, void 0)};
1215
+ ${o.get(gt, void 0)};
1363
1216
 
1364
1217
  overflow: hidden;
1365
- background: ${palette("surface")};
1218
+ background: ${n("surface")};
1366
1219
 
1367
1220
  .icon {
1368
1221
  position: relative;
1369
- color: ${palette("solid", 0.87)};
1222
+ color: ${n("solid", 0.87)};
1370
1223
 
1371
- width: 2em;
1372
- line-height: 2em;
1224
+ width: 48px;
1225
+ line-height: 48px;
1373
1226
  text-align: center;
1374
1227
  transition: all 0.4s ease-in-out;
1375
1228
 
1376
1229
  &:hover {
1377
- background-color: ${palette("secondary", 0.12)};
1230
+ background-color: ${n("secondary", 0.12)};
1378
1231
  }
1379
1232
 
1380
1233
  &.active {
1381
- color: ${palette("primary")};
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: ${lineWidth};
1242
+ width: ${s};
1390
1243
  bottom: 0;
1391
- background: ${palette("line")};
1244
+ background: ${n("line")};
1392
1245
  }
1393
1246
  }
1394
1247
 
@@ -1397,1463 +1250,1024 @@ const injectStyle = (themeManager, { css, injectGlobal }) => {
1397
1250
  display: none;
1398
1251
  }
1399
1252
  `;
1400
- };
1401
- const calculateClassName = (pos) => {
1402
- switch (pos) {
1403
- case ToolTipPos.Left: {
1253
+ }, gn = (o) => {
1254
+ switch (o) {
1255
+ case x.Left:
1404
1256
  return "milkdown-cell-left";
1405
- }
1406
- case ToolTipPos.Top: {
1257
+ case x.Top:
1407
1258
  return "milkdown-cell-top";
1408
- }
1409
- case ToolTipPos.Point:
1410
- default: {
1259
+ case x.Point:
1260
+ default:
1411
1261
  return "milkdown-cell-point";
1412
- }
1413
1262
  }
1414
1263
  };
1415
- function createWidget(ctx, cell, pos, index = 0) {
1416
- return Decoration.widget(cell.pos + 1, (view) => {
1417
- var _a;
1418
- const div = document.createElement("div");
1419
- div.classList.add(calculateClassName(pos));
1420
- if (pos === ToolTipPos.Point) {
1421
- div.appendChild((_a = ctx.get(themeManagerCtx).get(ThemeIcon, "select")) == null ? void 0 : _a.dom);
1422
- }
1423
- div.addEventListener("mousedown", (e) => {
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 === x.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 x.Point: {
1272
+ l.dispatch(dn(l.state.tr));
1500
1273
  return;
1501
- const isCellSelection = state.selection instanceof CellSelection;
1502
- if (!isCellSelection || !view.editable) {
1503
- hide();
1274
+ }
1275
+ case x.Left: {
1276
+ l.dispatch(_e("row")(n)(l.state.tr));
1504
1277
  return;
1505
1278
  }
1506
- calculateItem(items, view);
1507
- if (Object.values(items).every(({ $ }) => $.classList.contains("hide"))) {
1508
- hide();
1279
+ case x.Top: {
1280
+ l.dispatch(_e("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
- class TableView {
1523
- constructor(node, cellMinWidth) {
1524
- this.node = node;
1525
- this.cellMinWidth = cellMinWidth;
1526
- this.node = node;
1527
- this.cellMinWidth = cellMinWidth;
1528
- this.dom = document.createElement("div");
1529
- this.dom.className = "tableWrapper";
1530
- this.table = this.dom.appendChild(document.createElement("table"));
1531
- this.colgroup = this.table.appendChild(document.createElement("colgroup"));
1532
- updateColumns(node, this.colgroup, this.table, cellMinWidth);
1533
- this.contentDOM = this.table.appendChild(document.createElement("tbody"));
1534
- }
1535
- update(node) {
1536
- if (node.type != this.node.type)
1537
- return false;
1538
- this.node = node;
1539
- updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
1540
- return true;
1541
- }
1542
- ignoreMutation(record) {
1543
- return record.type == "attributes" && (record.target == this.table || this.colgroup.contains(record.target));
1544
- }
1545
- }
1546
- function updateColumns(node, colgroup, table2, cellMinWidth, overrideCol, overrideValue) {
1547
- var _a;
1548
- let totalWidth = 0, fixedWidth = true;
1549
- let nextDOM = colgroup.firstChild;
1550
- const row = node.firstChild;
1551
- for (let i = 0, col = 0; i < row.childCount; i++) {
1552
- const { colspan, colwidth } = row.child(i).attrs;
1553
- for (let j = 0; j < colspan; j++, col++) {
1554
- const hasWidth = overrideCol == col ? overrideValue : colwidth && colwidth[j];
1555
- const cssWidth = hasWidth ? hasWidth + "px" : "";
1556
- totalWidth += hasWidth || cellMinWidth;
1557
- if (!hasWidth)
1558
- fixedWidth = false;
1559
- if (!nextDOM) {
1560
- colgroup.appendChild(document.createElement("col")).style.width = cssWidth;
1561
- } else {
1562
- if (nextDOM.style.width != cssWidth)
1563
- nextDOM.style.width = cssWidth;
1564
- nextDOM = nextDOM.nextSibling;
1286
+ }
1287
+ const wn = (o, e) => new W({
1288
+ key: new F("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, x.Point)), l.forEach((a, i) => {
1299
+ n.push(ce(o, a, x.Left, i));
1300
+ }), s.forEach((a, i) => {
1301
+ n.push(ce(o, a, x.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 F("plugin_autoInsertZeroSpace"), kn = () => new W({
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 Re.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 Re.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
- while (nextDOM) {
1569
- const after = nextDOM.nextSibling;
1570
- (_a = nextDOM.parentNode) == null ? void 0 : _a.removeChild(nextDOM);
1571
- nextDOM = after;
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
- if (fixedWidth) {
1574
- table2.style.width = totalWidth + "px";
1575
- table2.style.minWidth = "";
1576
- } else {
1577
- table2.style.width = "";
1578
- table2.style.minWidth = totalWidth + "px";
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));
1579
1363
  }
1580
1364
  }
1581
- const key = new PluginKey("tableColumnResizing");
1582
- function columnResizing({
1583
- handleWidth = 5,
1584
- cellMinWidth = 25,
1585
- View = TableView,
1586
- lastColumnResizable = true
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;
1379
+ }
1380
+ a ? (t.style.width = r + "px", t.style.minWidth = "") : (t.style.width = "", t.style.minWidth = r + "px");
1381
+ }
1382
+ const k = new F("tableColumnResizing");
1383
+ function Mn({
1384
+ handleWidth: o = 5,
1385
+ cellMinWidth: e = 25,
1386
+ View: t = An,
1387
+ lastColumnResizable: n = !0
1587
1388
  } = {}) {
1588
- const plugin = new Plugin({
1589
- key,
1389
+ return new W({
1390
+ key: k,
1590
1391
  state: {
1591
- init(_, state) {
1592
- this.spec.props.nodeViews[tableNodeTypes(state.schema).table.name] = (node) => new View(node, cellMinWidth);
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(tr, prev) {
1596
- return prev.apply(tr);
1395
+ apply(s, r) {
1396
+ return r.apply(s);
1597
1397
  }
1598
1398
  },
1599
1399
  props: {
1600
- attributes(state) {
1601
- const pluginState = key.getState(state);
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(view, event) {
1606
- handleMouseMove(view, event, handleWidth, lastColumnResizable);
1404
+ mousemove(s, r) {
1405
+ Sn(s, r, o, n);
1607
1406
  },
1608
- mouseleave(view) {
1609
- handleMouseLeave(view);
1407
+ mouseleave(s) {
1408
+ Nn(s);
1610
1409
  },
1611
- mousedown(view, event) {
1612
- handleMouseDown$1(view, event, cellMinWidth);
1410
+ mousedown(s, r) {
1411
+ xn(s, r, e);
1613
1412
  }
1614
1413
  },
1615
- decorations(state) {
1616
- const pluginState = key.getState(state);
1617
- if (pluginState.activeHandle > -1)
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
- return plugin;
1625
- }
1626
- class ResizeState {
1627
- constructor(activeHandle, dragging) {
1628
- this.activeHandle = activeHandle;
1629
- this.dragging = dragging;
1630
- this.activeHandle = activeHandle;
1631
- this.dragging = dragging;
1632
- }
1633
- apply(tr) {
1634
- let state = this;
1635
- const action = tr.getMeta(key);
1636
- if (action && action.setHandle != null)
1637
- return new ResizeState(action.setHandle, null);
1638
- if (action && action.setDragging !== void 0)
1639
- return new ResizeState(state.activeHandle, action.setDragging);
1640
- if (state.activeHandle > -1 && tr.docChanged) {
1641
- let handle = tr.mapping.map(state.activeHandle, -1);
1642
- if (!pointsAtCell(tr.doc.resolve(handle)))
1643
- handle = 0;
1644
- state = new ResizeState(handle, state.dragging);
1645
- }
1646
- return state;
1647
- }
1648
- }
1649
- function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
1650
- const pluginState = key.getState(view.state);
1651
- if (!pluginState.dragging) {
1652
- const target = domCellAround(event.target);
1653
- let cell = -1;
1654
- if (target) {
1655
- const { left, right } = target.getBoundingClientRect();
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 Sn(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
- updateHandle(view, cell);
1455
+ nt(o, r);
1671
1456
  }
1672
1457
  }
1673
1458
  }
1674
- function handleMouseLeave(view) {
1675
- const pluginState = key.getState(view.state);
1676
- if (pluginState.activeHandle > -1 && !pluginState.dragging)
1677
- updateHandle(view, -1);
1459
+ function Nn(o) {
1460
+ const e = k.getState(o.state);
1461
+ e.activeHandle > -1 && !e.dragging && nt(o, -1);
1678
1462
  }
1679
- function handleMouseDown$1(view, event, cellMinWidth) {
1680
- const pluginState = key.getState(view.state);
1681
- if (pluginState.activeHandle == -1 || pluginState.dragging)
1682
- return false;
1683
- const cell = view.state.doc.nodeAt(pluginState.activeHandle);
1684
- const width = currentColWidth(view, pluginState.activeHandle, cell.attrs);
1685
- view.dispatch(view.state.tr.setMeta(key, {
1686
- setDragging: { startX: event.clientX, startWidth: width }
1463
+ function xn(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 = Rn(o, n.activeHandle, l.attrs);
1468
+ o.dispatch(o.state.tr.setMeta(k, {
1469
+ setDragging: { startX: e.clientX, startWidth: s }
1687
1470
  }));
1688
- function finish(event2) {
1689
- window.removeEventListener("mouseup", finish);
1690
- window.removeEventListener("mousemove", move);
1691
- const pluginState2 = key.getState(view.state);
1692
- if (pluginState2.dragging) {
1693
- updateColumnWidth(view, pluginState2.activeHandle, draggedWidth(pluginState2.dragging, event2, cellMinWidth));
1694
- view.dispatch(view.state.tr.setMeta(key, { setDragging: null }));
1695
- }
1696
- }
1697
- function move(event2) {
1698
- if (!event2.which)
1699
- return finish(event2);
1700
- const pluginState2 = key.getState(view.state);
1701
- const dragged = draggedWidth(pluginState2.dragging, event2, cellMinWidth);
1702
- displayColumnWidth(view, pluginState2.activeHandle, dragged, cellMinWidth);
1703
- }
1704
- window.addEventListener("mouseup", finish);
1705
- window.addEventListener("mousemove", move);
1706
- event.preventDefault();
1707
- return true;
1708
- }
1709
- function currentColWidth(view, cellPos, { colspan, colwidth }) {
1710
- const width = colwidth && colwidth[colwidth.length - 1];
1711
- if (width)
1712
- return width;
1713
- const dom = view.domAtPos(cellPos);
1714
- const node = dom.node.childNodes[dom.offset];
1715
- let domWidth = node.offsetWidth, parts = colspan;
1716
- if (colwidth) {
1717
- for (let i = 0; i < colspan; i++)
1718
- if (colwidth[i]) {
1719
- domWidth -= colwidth[i];
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 Rn(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 } = found;
1735
- const $cell = cellAround(view.state.doc.resolve(pos));
1736
- if (!$cell)
1504
+ const { pos: l } = n, s = U(o.state.doc.resolve(l));
1505
+ if (!s)
1737
1506
  return -1;
1738
- if (side == "right")
1739
- return $cell.pos;
1740
- const map = TableMap.get($cell.node(-1)), start = $cell.start(-1);
1741
- const index = map.map.indexOf($cell.pos - start);
1742
- return index % map.width == 0 ? -1 : start + map.map[index - 1];
1743
- }
1744
- function draggedWidth(dragging, event, cellMinWidth) {
1745
- const offset = event.clientX - dragging.startX;
1746
- return Math.max(cellMinWidth, dragging.startWidth + offset);
1747
- }
1748
- function updateHandle(view, value) {
1749
- view.dispatch(view.state.tr.setMeta(key, { setHandle: value }));
1750
- }
1751
- function updateColumnWidth(view, cell, width) {
1752
- const $cell = view.state.doc.resolve(cell);
1753
- const table2 = $cell.node(-1), map = TableMap.get(table2), start = $cell.start(-1);
1754
- const col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs["colspan"] - 1;
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 pos = map.map[mapIndex], { attrs } = table2.nodeAt(pos);
1761
- const index = attrs["colspan"] == 1 ? 0 : col - map.colCount(pos);
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 colwidth = attrs["colwidth"] ? attrs["colwidth"].slice() : zeroes(attrs["colspan"]);
1765
- colwidth[index] = width;
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
- return tr;
1531
+ i.docChanged && o.dispatch(i);
1837
1532
  }
1838
- const addColumnBefore = (state, dispatch) => {
1839
- if (!isInTable(state))
1840
- return false;
1841
- if (dispatch) {
1842
- const rect = selectedRect(state);
1843
- dispatch(addColumn(state.tr, rect, rect.left));
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
- const deleteRow = (state, dispatch) => {
1916
- if (!isInTable(state))
1917
- return false;
1918
- if (dispatch) {
1919
- const rect = selectedRect(state), tr = state.tr;
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 findNextCell($cell, dir) {
1955
- if (dir < 0) {
1956
- const before = $cell.nodeBefore;
1957
- if (before)
1958
- return $cell.pos - before.nodeSize;
1959
- for (let row = $cell.index(-1) - 1, rowEnd = $cell.before(); row >= 0; row--) {
1960
- const rowNode = $cell.node(-1).child(row);
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
- const deleteTable = (state, dispatch) => {
1993
- const $pos = state.selection.$anchor;
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 } = slice;
2008
- while (content.childCount == 1 && (openStart > 0 && openEnd > 0 || content.firstChild.type.spec["tableRole"] == "table")) {
2009
- openStart--;
2010
- openEnd--;
2011
- content = content.firstChild.content;
2012
- }
2013
- const first = content.firstChild, role = first.type.spec["tableRole"];
2014
- const schema2 = first.type.schema, rows = [];
2015
- if (role == "row") {
2016
- for (let i = 0; i < content.childCount; i++) {
2017
- let cells = content.child(i).content;
2018
- const left = i ? 0 : Math.max(0, openStart - 1);
2019
- const right = i < content.childCount - 1 ? 0 : Math.max(0, openEnd - 1);
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 O(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 O(e, t, n)).content : e);
1572
+ else
2027
1573
  return null;
2028
- }
2029
- return ensureRectangular(schema2, rows);
2030
- }
2031
- function ensureRectangular(schema2, rows) {
2032
- const widths = [];
2033
- for (let i = 0; i < rows.length; i++) {
2034
- const row = rows[i];
2035
- for (let j = row.childCount - 1; j >= 0; j--) {
2036
- const { rowspan, colspan } = row.child(j).attrs;
2037
- for (let r = i; r < i + rowspan; r++)
2038
- widths[r] = (widths[r] || 0) + colspan;
2039
- }
2040
- }
2041
- let width = 0;
2042
- for (let r = 0; r < widths.length; r++)
2043
- width = Math.max(width, widths[r]);
2044
- for (let r = 0; r < widths.length; r++) {
2045
- if (r >= rows.length)
2046
- rows.push(Fragment.empty);
2047
- if (widths[r] < width) {
2048
- const empty = tableNodeTypes(schema2).cell.createAndFill(), cells = [];
2049
- for (let i = widths[r]; i < width; i++)
2050
- cells.push(empty);
2051
- rows[r] = rows[r].append(Fragment.from(cells));
2052
- }
2053
- }
2054
- return { height: rows.length, width, rows };
2055
- }
2056
- function fitSlice(nodeType, slice) {
2057
- const node = nodeType.createAndFill();
2058
- const tr = new Transform(node).replace(0, node.content.size, slice);
2059
- return tr.doc;
2060
- }
2061
- function clipCells({ width, height, rows }, newWidth, newHeight) {
2062
- if (width != newWidth) {
2063
- const added = [], newRows = [];
2064
- for (let row = 0; row < rows.length; row++) {
2065
- const frag = rows[row], cells = [];
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"];
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 Nt(t).replace(0, t.content.size, e).doc;
1601
+ }
1602
+ function On({ 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(z(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;
2074
1612
  }
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);
2089
- }
2090
- newRows.push(Fragment.from(cells));
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
- return found;
2144
- }
2145
- function isolateVertical(tr, map, table2, start, top, bottom, left, mapFrom) {
2146
- if (left == 0 || left == map.width)
2147
- return false;
2148
- let found = false;
2149
- for (let row = top; row < bottom; row++) {
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
- f(child, offset);
2205
- if (j < oldSize && old.child(j).sameMarkup(child))
2206
- changedDescendants(old.child(j), child, offset + 1, f);
2207
- else
2208
- child.nodesBetween(0, child.content.size, f, offset + 1);
2209
- offset += child.nodeSize;
1625
+ s.push(E.from(i));
1626
+ }
1627
+ t = s, e = l;
1628
+ }
1629
+ return { width: o, height: e, rows: t };
1630
+ }
1631
+ function _n(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, z(f.attrs, r - p, f.attrs.colspan - (r - p))), o.insert(h + f.nodeSize, f.type.createAndFill(z(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
+ _n(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 O(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 F("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 fixTables(state, oldState) {
2213
- let tr;
2214
- const check = (node, pos) => {
2215
- if (node.type.spec["tableRole"] == "table")
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
- if (!oldState)
2219
- state.doc.descendants(check);
2220
- else if (oldState.doc != state.doc)
2221
- changedDescendants(oldState.doc, state.doc, 0, check);
2222
- return tr;
2223
- }
2224
- function fixTable(state, table2, tablePos, tr) {
2225
- const map = TableMap.get(table2);
2226
- if (!map.problems)
2227
- return tr;
2228
- if (!tr)
2229
- tr = state.tr;
2230
- const mustAdd = [];
2231
- for (let i = 0; i < map.height; i++)
2232
- mustAdd.push(0);
2233
- for (let i = 0; i < map.problems.length; i++) {
2234
- const prob = map.problems[i];
2235
- if (prob.type == "collision") {
2236
- const cell = table2.nodeAt(prob.pos);
2237
- for (let j = 0; j < cell.attrs["rowspan"]; j++)
2238
- mustAdd[prob.row + j] += prob.n;
2239
- tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, removeColSpan(cell.attrs, cell.attrs["colspan"] - prob.n, prob.n));
2240
- } else if (prob.type == "missing") {
2241
- mustAdd[prob.row] += prob.n;
2242
- } else if (prob.type == "overlong_rowspan") {
2243
- const cell = table2.nodeAt(prob.pos);
2244
- tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, setAttr(cell.attrs, "rowspan", cell.attrs["rowspan"] - prob.n));
2245
- } else if (prob.type == "colwidth mismatch") {
2246
- const cell = table2.nodeAt(prob.pos);
2247
- tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, setAttr(cell.attrs, "colwidth", prob.colwidth));
2248
- }
2249
- }
2250
- let first, last;
2251
- for (let i = 0; i < mustAdd.length; i++)
2252
- if (mustAdd[i]) {
2253
- if (first == null)
2254
- first = i;
2255
- last = i;
2256
- }
2257
- for (let i = 0, pos = tablePos + 1; i < map.height; i++) {
2258
- const row = table2.child(i);
2259
- const end = pos + row.nodeSize;
2260
- const add = mustAdd[i];
2261
- if (add > 0) {
2262
- let tableNodeType = "cell";
2263
- if (row.firstChild) {
2264
- tableNodeType = row.firstChild.type.spec["tableRole"];
2265
- }
2266
- const nodes = [];
2267
- for (let j = 0; j < add; j++)
2268
- nodes.push(tableNodeTypes(state.schema)[tableNodeType].createAndFill());
2269
- const side = (i == 0 || first == i - 1) && last == i ? pos + 1 : end - 1;
2270
- tr.insert(tr.mapping.map(side), nodes);
2271
- }
2272
- pos = end;
2273
- }
2274
- return tr.setMeta(fixTablesKey, { fixTables: true });
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, z(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 F("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 startDOMCell = domInCell(view, startEvent.target);
2294
- let $anchor;
2295
- if (startEvent.shiftKey && view.state.selection instanceof CellSelection) {
2296
- setCellSelection(view.state.selection.$anchorCell, startEvent);
2297
- startEvent.preventDefault();
2298
- } else if (startEvent.shiftKey && startDOMCell && ($anchor = cellAround(view.state.selection.$anchor)) != null && cellUnderMouse(view, startEvent).pos != $anchor.pos) {
2299
- setCellSelection($anchor, startEvent);
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
- function setCellSelection($anchor2, event2) {
2305
- let $head = cellUnderMouse(view, event2);
2306
- const starting = tableEditingKey.getState(view.state) == null;
2307
- if (!$head || !inSameTable($anchor2, $head)) {
2308
- if (starting)
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 || !Se(i, d))
1790
+ if (u)
1791
+ d = i;
2310
1792
  else
2311
1793
  return;
2312
- }
2313
- const selection = new CellSelection($anchor2, $head);
2314
- if (starting || !view.state.selection.eq(selection)) {
2315
- const tr = view.state.tr.setSelection(selection);
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 stop() {
2322
- view.root.removeEventListener("mouseup", stop);
2323
- view.root.removeEventListener("dragstart", stop);
2324
- view.root.removeEventListener("mousemove", move);
2325
- if (tableEditingKey.getState(view.state) != null)
2326
- view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));
2327
- }
2328
- function move(event2) {
2329
- const anchor = tableEditingKey.getState(view.state);
2330
- let $anchor2;
2331
- if (anchor != null) {
2332
- $anchor2 = view.state.doc.resolve(anchor);
2333
- } else if (domInCell(view, event2.target) != startDOMCell) {
2334
- $anchor2 = cellUnderMouse(view, startEvent);
2335
- if (!$anchor2)
2336
- return stop();
2337
- }
2338
- if ($anchor2)
2339
- setCellSelection($anchor2, event2);
2340
- }
2341
- view.root.addEventListener("mouseup", stop);
2342
- view.root.addEventListener("dragstart", stop);
2343
- view.root.addEventListener("mousemove", move);
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 } = view.state.selection;
2363
- for (let d = $head.depth - 1; d >= 0; d--) {
2364
- const parent = $head.node(d), index = dir < 0 ? $head.index(d) : $head.indexAfter(d);
2365
- if (index != (dir < 0 ? 0 : parent.childCount))
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 (parent.type.spec["tableRole"] == "cell" || parent.type.spec["tableRole"] == "header_cell") {
2368
- const cellPos = $head.before(d);
2369
- const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
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 arrow(axis, dir) {
2376
- return (state, dispatch, view) => {
2377
- const sel = state.selection;
2378
- if (sel instanceof CellSelection) {
2379
- return maybeSetSelection(state, dispatch, Selection.near(sel.$headCell, dir));
2380
- }
2381
- if (axis != "horiz" && !sel.empty)
2382
- return false;
2383
- const end = atEndOfCell(view, axis, dir);
2384
- if (end == null)
2385
- return false;
2386
- if (axis == "horiz") {
2387
- return maybeSetSelection(state, dispatch, Selection.near(state.doc.resolve(sel.head + dir), dir));
2388
- } else {
2389
- const $cell = state.doc.resolve(end), $next = nextCell($cell, axis, dir);
2390
- let newSel;
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, S.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, S.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 = S.near(i, 1) : e < 0 ? c = S.near(t.doc.resolve(a.before(-1)), -1) : c = S.near(t.doc.resolve(a.after(-1)), 1), Y(t, n, c);
2398
1852
  }
2399
1853
  };
2400
1854
  }
2401
- function shiftArrow(axis, dir) {
2402
- return (state, dispatch, view) => {
2403
- let sel = state.selection;
2404
- if (!(sel instanceof CellSelection)) {
2405
- const end = atEndOfCell(view, axis, dir);
2406
- if (end == null)
2407
- return false;
2408
- sel = new CellSelection(state.doc.resolve(end));
2409
- }
2410
- const $head = nextCell(sel.$headCell, axis, dir);
2411
- if (!$head)
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 deleteCellSelection(state, dispatch) {
2417
- const sel = state.selection;
2418
- if (!(sel instanceof CellSelection))
2419
- return false;
2420
- if (dispatch) {
2421
- const tr = state.tr, baseContent = tableNodeTypes(state.schema).cell.createAndFill().content;
2422
- sel.forEachCell((cell, pos) => {
2423
- if (!cell.content.eq(baseContent))
2424
- tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1), new Slice(baseContent, 0, 0));
2425
- });
2426
- if (tr.docChanged)
2427
- dispatch(tr);
2428
- }
2429
- return true;
2430
- }
2431
- const handleKeyDown = keydownHandler({
2432
- ArrowLeft: arrow("horiz", -1),
2433
- ArrowRight: arrow("horiz", 1),
2434
- ArrowUp: arrow("vert", -1),
2435
- ArrowDown: arrow("vert", 1),
2436
- "Shift-ArrowLeft": shiftArrow("horiz", -1),
2437
- "Shift-ArrowRight": shiftArrow("horiz", 1),
2438
- "Shift-ArrowUp": shiftArrow("vert", -1),
2439
- "Shift-ArrowDown": shiftArrow("vert", 1),
2440
- Backspace: deleteCellSelection,
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 O(l, 0, 0));
1876
+ }), n.docChanged && e(n);
1877
+ }
1878
+ return !0;
1879
+ }
1880
+ const Hn = St({
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 handlePaste(view, _, slice) {
2446
- if (!isInTable(view.state))
2447
- return false;
2448
- let cells = pastedCells(slice);
2449
- const sel = view.state.selection;
2450
- if (sel instanceof CellSelection) {
2451
- if (!cells)
2452
- cells = {
2453
- width: 1,
2454
- height: 1,
2455
- rows: [Fragment.from(fitSlice(tableNodeTypes(view.state.schema).cell, slice))]
2456
- };
2457
- const table2 = sel.$anchorCell.node(-1), start = sel.$anchorCell.start(-1);
2458
- const rect = TableMap.get(table2).rectBetween(sel.$anchorCell.pos - start, sel.$headCell.pos - start);
2459
- cells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);
2460
- insertCells(view.state, view.dispatch, start, rect, cells);
2461
- return true;
2462
- } else if (cells) {
2463
- const $cell = selectionCell(view.state), start = $cell.start(-1);
2464
- insertCells(view.state, view.dispatch, start, TableMap.get($cell.node(-1)).findCell($cell.pos - start), cells);
2465
- return true;
2466
- } else {
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 = On(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 W({
1915
+ key: I,
2473
1916
  state: {
2474
1917
  init() {
2475
1918
  return null;
2476
1919
  },
2477
- apply(tr, cur) {
2478
- const set = tr.getMeta(tableEditingKey);
2479
- if (set != null)
2480
- return set == -1 ? null : set;
2481
- if (cur == null || !tr.docChanged)
2482
- return cur;
2483
- const { deleted, pos } = tr.mapping.mapResult(cur);
2484
- return deleted ? null : pos;
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: drawCellSelection,
1931
+ decorations: Ht,
2489
1932
  handleDOMEvents: {
2490
- mousedown: handleMouseDown
1933
+ mousedown: Pn
2491
1934
  },
2492
- createSelectionBetween(view) {
2493
- if (tableEditingKey.getState(view.state) != null)
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(_, oldState, state) {
2502
- return normalizeSelection(state, fixTables(state, oldState), allowTableNodeSelection);
1942
+ appendTransaction(e, t, n) {
1943
+ return qt(n, Fn(n, t), o);
2503
1944
  }
2504
1945
  });
2505
1946
  }
2506
- const SupportedKeys$1 = {
1947
+ const Q = {
2507
1948
  NextCell: "NextCell",
2508
1949
  PrevCell: "PrevCell",
2509
1950
  ExitTable: "ExitTable"
2510
- };
2511
- const PrevCell = createCmdKey("PrevCell");
2512
- const NextCell = createCmdKey("NextCell");
2513
- const BreakTable = createCmdKey("BreakTable");
2514
- const InsertTable = createCmdKey("InsertTable");
2515
- const TableContentFilterPluginKey = new PluginKey("MILKDOWN_TABLE_CONTENT_FILTER");
2516
- const table = createPlugin((utils) => {
2517
- return {
2518
- schema: () => ({
2519
- node: {
2520
- table: __spreadProps(__spreadValues({}, schema.table), {
2521
- parseMarkdown: {
2522
- match: (node) => node.type === "table",
2523
- runner: (state, node, type) => {
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 = R("PrevCell"), qe = R("NextCell"), Ue = R("BreakTable"), qn = R("InsertTable"), Un = 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
- table_row: __spreadProps(__spreadValues({}, schema.table_row), {
2552
- parseMarkdown: {
2553
- match: (node) => node.type === "tableRow",
2554
- runner: (state, node, type) => {
2555
- const align = node["align"];
2556
- const children = node.children.map((x, i) => __spreadProps(__spreadValues({}, x), {
2557
- align: align[i],
2558
- isHeader: node["isHeader"]
2559
- }));
2560
- state.openNode(type);
2561
- state.next(children);
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
- table_cell: __spreadProps(__spreadValues({}, schema.table_cell), {
2575
- parseMarkdown: {
2576
- match: (node) => node.type === "tableCell" && !node["isHeader"],
2577
- runner: (state, node, type) => {
2578
- const align = node["align"];
2579
- state.openNode(type, { alignment: align }).openNode(state.schema.nodes["paragraph"]).next(node.children).closeNode().closeNode();
2580
- }
2581
- },
2582
- toMarkdown: {
2583
- match: (node) => node.type.name === "table_cell",
2584
- runner: (state, node) => {
2585
- state.openNode("tableCell").next(node.content).closeNode();
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
- table_header: __spreadProps(__spreadValues({}, schema.table_header), {
2590
- parseMarkdown: {
2591
- match: (node) => node.type === "tableCell" && !!node["isHeader"],
2592
- runner: (state, node, type) => {
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
- return true;
2636
- })
2637
- ],
2638
- shortcuts: {
2639
- [SupportedKeys$1.NextCell]: createShortcut(NextCell, "Mod-]"),
2640
- [SupportedKeys$1.PrevCell]: createShortcut(PrevCell, "Mod-["),
2641
- [SupportedKeys$1.ExitTable]: createShortcut(BreakTable, "Mod-Enter")
2642
- },
2643
- prosePlugins: (_, ctx) => {
2644
- return [
2645
- operatorPlugin(ctx, utils),
2646
- columnResizing({}),
2647
- tableEditing(),
2648
- new Plugin({
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
- toMarkdown: {
2697
- match: (mark) => mark.type.name === id,
2698
- runner: (state, mark) => {
2699
- state.withMark(mark, "delete");
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
- inputRules: (markType) => [
2704
- markRule(/(?:~~)([^~]+)(?:~~)$/, markType),
2705
- markRule(/(?:^|[^~])(~([^~]+)~)$/, markType)
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 = Oe(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
+ N(Ke, () => De(-1)),
2046
+ N(qe, () => De(1)),
2047
+ N(Ue, () => Jt(t.get(re).nodes.paragraph)),
2048
+ N(qn, () => (n, l) => {
2049
+ const { selection: s, tr: r } = n, { from: a } = s, i = Oe(t.get(re)), c = r.replaceSelectionWith(i), d = S.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) => [wn(t, o), kn(), Mn(), Kn()]
2059
+ })), K = {
2060
+ ...st,
2061
+ ...Q,
2062
+ StrikeThrough: "StrikeThrough",
2063
+ TaskList: "TaskList"
2064
+ }, pe = R("ToggleStrikeThrough"), Xe = "strike_through", Xn = dt((o) => ({
2065
+ id: Xe,
2066
+ schema: () => ({
2067
+ parseDOM: [
2068
+ { tag: "del" },
2069
+ { style: "text-decoration", getAttrs: (e) => e === "line-through" }
2706
2070
  ],
2707
- commands: (markType) => [createCmd(ToggleStrikeThrough, () => toggleMark(markType))],
2708
- shortcuts: {
2709
- [SupportedKeys.StrikeThrough]: createShortcut(ToggleStrikeThrough, "Mod-Alt-x")
2071
+ toDOM: (e) => ["del", { class: o.getClassName(e.attrs, "strike-through") }],
2072
+ parseMarkdown: {
2073
+ match: (e) => e.type === "delete",
2074
+ runner: (e, t, n) => {
2075
+ e.openMark(n), e.next(t.children), e.closeMark(n);
2076
+ }
2077
+ },
2078
+ toMarkdown: {
2079
+ match: (e) => e.type.name === Xe,
2080
+ runner: (e, t) => {
2081
+ e.withMark(t, "delete");
2082
+ }
2710
2083
  }
2711
- };
2712
- });
2713
- const SplitTaskListItem = createCmdKey("SplitTaskListItem");
2714
- const SinkTaskListItem = createCmdKey("SinkTaskListItem");
2715
- const LiftTaskListItem = createCmdKey("LiftTaskListItem");
2716
- const TurnIntoTaskList = createCmdKey("TurnIntoTaskList");
2717
- const taskListItem = createNode((utils) => {
2718
- const id2 = "task_list_item";
2084
+ }),
2085
+ inputRules: (e) => [
2086
+ Te(/(?:~~)([^~]+)(?:~~)$/, e),
2087
+ Te(/(?:^|[^~])(~([^~]+)~)$/, e)
2088
+ ],
2089
+ commands: (e) => [N(pe, () => At(e))],
2090
+ shortcuts: {
2091
+ [K.StrikeThrough]: $(pe, "Mod-Alt-x")
2092
+ }
2093
+ })), he = R("SplitTaskListItem"), me = R("SinkTaskListItem"), ge = R("LiftTaskListItem"), we = R("TurnIntoTaskList"), Vn = be((o) => {
2094
+ const e = "task_list_item";
2719
2095
  return {
2720
- id: id2,
2721
- schema: (ctx) => ({
2096
+ id: e,
2097
+ schema: (t) => ({
2722
2098
  group: "listItem",
2723
2099
  content: "paragraph block*",
2724
- defining: true,
2100
+ defining: !0,
2725
2101
  priority: 60,
2726
2102
  attrs: {
2727
2103
  checked: {
2728
- default: false
2104
+ default: !1
2729
2105
  }
2730
2106
  },
2731
2107
  parseDOM: [
2732
2108
  {
2733
2109
  tag: 'li[data-type="task-item"]',
2734
- getAttrs: (dom) => {
2735
- if (!(dom instanceof HTMLElement)) {
2736
- throw new Error();
2737
- }
2738
- return { checked: dom.dataset["checked"] === "true" };
2110
+ getAttrs: (n) => {
2111
+ if (!(n instanceof HTMLElement))
2112
+ throw ye(n);
2113
+ return { checked: n.dataset.checked === "true" };
2739
2114
  }
2740
2115
  }
2741
2116
  ],
2742
- toDOM: (node) => {
2743
- const checkbox = document.createElement("input");
2744
- checkbox.type = "checkbox";
2745
- checkbox.checked = node.attrs["checked"];
2746
- checkbox.className = utils.getClassName(node.attrs, "task-list-item_checkbox");
2747
- checkbox.onchange = (event) => {
2748
- const target = event.target;
2749
- if (!(target instanceof HTMLInputElement))
2117
+ toDOM: (n) => {
2118
+ const l = document.createElement("input");
2119
+ return l.type = "checkbox", l.checked = n.attrs.checked, l.className = o.getClassName(n.attrs, "task-list-item_checkbox"), l.onchange = (s) => {
2120
+ const r = s.target;
2121
+ if (!(r instanceof HTMLInputElement))
2750
2122
  return;
2751
- const view = ctx.get(editorViewCtx);
2752
- if (!view.editable) {
2753
- checkbox.checked = !checkbox.checked;
2123
+ const a = t.get(ee);
2124
+ if (!a.editable) {
2125
+ l.checked = !l.checked;
2754
2126
  return;
2755
2127
  }
2756
- const { top, left } = target.getBoundingClientRect();
2757
- const result = view.posAtCoords({ top, left });
2758
- if (!result)
2128
+ const { top: i, left: c } = r.getBoundingClientRect(), d = a.posAtCoords({ top: i, left: c });
2129
+ if (!d)
2759
2130
  return;
2760
- const { tr } = view.state;
2761
- view.dispatch(tr.setNodeMarkup(result.inside, void 0, {
2762
- checked: target.checked
2131
+ const { tr: u } = a.state;
2132
+ a.dispatch(u.setNodeMarkup(d.inside, void 0, {
2133
+ checked: r.checked
2763
2134
  }));
2764
- };
2765
- return [
2135
+ }, [
2766
2136
  "li",
2767
2137
  {
2768
2138
  "data-type": "task-item",
2769
- "data-checked": node.attrs["checked"] ? "true" : "false",
2770
- class: utils.getClassName(node.attrs, "task-list-item")
2139
+ "data-checked": n.attrs.checked ? "true" : "false",
2140
+ class: o.getClassName(n.attrs, "task-list-item")
2771
2141
  },
2772
- checkbox,
2773
- ["span", { class: utils.getClassName(node.attrs, "task-list-item_body") }, 0]
2142
+ l,
2143
+ ["span", { class: o.getClassName(n.attrs, "task-list-item_body") }, 0]
2774
2144
  ];
2775
2145
  },
2776
2146
  parseMarkdown: {
2777
- match: ({ type, checked }) => {
2778
- return type === "listItem" && checked !== null;
2779
- },
2780
- runner: (state, node, type) => {
2781
- state.openNode(type, { checked: node["checked"] });
2782
- state.next(node.children);
2783
- state.closeNode();
2147
+ match: ({ type: n, checked: l }) => n === "listItem" && l !== null,
2148
+ runner: (n, l, s) => {
2149
+ n.openNode(s, { checked: l.checked }), n.next(l.children), n.closeNode();
2784
2150
  }
2785
2151
  },
2786
2152
  toMarkdown: {
2787
- match: (node) => node.type.name === id2,
2788
- runner: (state, node) => {
2789
- state.openNode("listItem", void 0, { checked: node.attrs["checked"] });
2790
- state.next(node.content);
2791
- state.closeNode();
2153
+ match: (n) => n.type.name === e,
2154
+ runner: (n, l) => {
2155
+ n.openNode("listItem", void 0, { checked: l.attrs.checked }), n.next(l.content), n.closeNode();
2792
2156
  }
2793
2157
  }
2794
2158
  }),
2795
- inputRules: (nodeType) => [
2796
- wrappingInputRule(/^\s*(\[([ |x])\])\s$/, nodeType, (match) => ({
2797
- checked: match[match.length - 1] === "x"
2159
+ inputRules: (t) => [
2160
+ Ve(/^\s*(\[([ |x])\])\s$/, t, (n) => ({
2161
+ checked: n[n.length - 1] === "x"
2798
2162
  }))
2799
2163
  ],
2800
- commands: (nodeType) => [
2801
- createCmd(SplitTaskListItem, () => splitListItem(nodeType)),
2802
- createCmd(SinkTaskListItem, () => sinkListItem(nodeType)),
2803
- createCmd(LiftTaskListItem, () => liftListItem(nodeType)),
2804
- createCmd(TurnIntoTaskList, () => wrapIn(nodeType))
2164
+ commands: (t) => [
2165
+ N(he, () => xt(t)),
2166
+ N(me, () => Rt(t)),
2167
+ N(ge, () => Tt(t)),
2168
+ N(we, () => Mt(t))
2805
2169
  ],
2806
2170
  shortcuts: {
2807
- [SupportedKeys.NextListItem]: createShortcut(SplitTaskListItem, "Enter"),
2808
- [SupportedKeys.SinkListItem]: createShortcut(SinkTaskListItem, "Mod-]"),
2809
- [SupportedKeys.LiftListItem]: createShortcut(LiftTaskListItem, "Mod-["),
2810
- [SupportedKeys.TaskList]: createShortcut(TurnIntoTaskList, "Mod-Alt-9")
2171
+ [K.NextListItem]: $(he, "Enter"),
2172
+ [K.SinkListItem]: $(me, "Mod-]"),
2173
+ [K.LiftListItem]: $(ge, "Mod-["),
2174
+ [K.TaskList]: $(we, "Mod-Alt-9")
2811
2175
  },
2812
- view: () => (node, view, getPos) => {
2813
- let currNode = node;
2814
- const renderer = utils.themeManager.get("task-list-item", {
2815
- editable: () => view.editable,
2816
- onChange: (selected) => {
2817
- const { tr } = view.state;
2818
- view.dispatch(tr.setNodeMarkup(getPos(), void 0, {
2819
- checked: selected
2176
+ view: () => (t, n, l) => {
2177
+ let s = t;
2178
+ const r = o.themeManager.get("task-list-item", {
2179
+ editable: () => n.editable,
2180
+ onChange: (d) => {
2181
+ const { tr: u } = n.state;
2182
+ n.dispatch(u.setNodeMarkup(l(), void 0, {
2183
+ checked: d
2820
2184
  }));
2821
2185
  }
2822
2186
  });
2823
- if (!renderer)
2187
+ if (!r)
2824
2188
  return {};
2825
- const { dom, contentDOM, onUpdate } = renderer;
2826
- onUpdate(currNode);
2827
- return {
2828
- dom,
2829
- contentDOM,
2830
- update: (updatedNode) => {
2831
- if (updatedNode.type.name !== id2)
2832
- return false;
2833
- currNode = updatedNode;
2834
- onUpdate(currNode);
2835
- return true;
2836
- }
2189
+ const { dom: a, contentDOM: i, onUpdate: c } = r;
2190
+ return c(s), {
2191
+ dom: a,
2192
+ contentDOM: i,
2193
+ update: (d) => d.type.name !== e ? !1 : (s = d, c(s), !0)
2837
2194
  };
2838
2195
  }
2839
2196
  };
2840
- });
2841
- const gfm = AtomList.create([
2842
- ...commonmark,
2843
- $remark(() => remarkGFM),
2844
- table(),
2845
- urlPlugin,
2846
- strikeThrough(),
2847
- taskListItem(),
2848
- footnoteReference(),
2849
- footnoteDefinition()
2850
- ]);
2851
- const commands = __spreadProps(__spreadValues({}, commands$1), {
2852
- ToggleStrikeThrough,
2853
- TurnIntoTaskList,
2854
- SinkTaskListItem,
2855
- LiftTaskListItem,
2856
- SplitTaskListItem
2857
- });
2858
- export { BreakTable, InsertTable, LiftTaskListItem, ModifyFootnoteDef, ModifyFootnoteRef, NextCell, PrevCell, SinkTaskListItem, SplitTaskListItem, SupportedKeys, ToggleStrikeThrough, TurnIntoTaskList, commands, createTable, footnoteDefinition, footnoteReference, gfm, strikeThrough, table, taskListItem };
2197
+ }), ao = ut.create([
2198
+ ...rt,
2199
+ ft(() => pt),
2200
+ Un(),
2201
+ Et,
2202
+ Xn(),
2203
+ Vn(),
2204
+ Ot(),
2205
+ $t()
2206
+ ]), uo = {
2207
+ ...it,
2208
+ ToggleStrikeThrough: pe,
2209
+ TurnIntoTaskList: we,
2210
+ SinkTaskListItem: me,
2211
+ LiftTaskListItem: ge,
2212
+ SplitTaskListItem: he
2213
+ };
2214
+ export {
2215
+ Ue as BreakTable,
2216
+ ho as InsertHardbreak,
2217
+ mo as InsertHr,
2218
+ go as InsertImage,
2219
+ qn as InsertTable,
2220
+ wo as LiftListItem,
2221
+ ge as LiftTaskListItem,
2222
+ Le as ModifyFootnoteDef,
2223
+ ve as ModifyFootnoteRef,
2224
+ bo as ModifyImage,
2225
+ Co as ModifyLink,
2226
+ qe as NextCell,
2227
+ Ke as PrevCell,
2228
+ yo as SinkListItem,
2229
+ me as SinkTaskListItem,
2230
+ ko as SplitListItem,
2231
+ he as SplitTaskListItem,
2232
+ K as SupportedKeys,
2233
+ Ao as ToggleBold,
2234
+ Mo as ToggleInlineCode,
2235
+ So as ToggleItalic,
2236
+ No as ToggleLink,
2237
+ pe as ToggleStrikeThrough,
2238
+ xo as TurnIntoCodeFence,
2239
+ Ro as TurnIntoHeading,
2240
+ we as TurnIntoTaskList,
2241
+ To as TurnIntoText,
2242
+ Lo as WrapInBlockquote,
2243
+ vo as WrapInBulletList,
2244
+ Eo as WrapInOrderedList,
2245
+ Io as blockquote,
2246
+ $o as bulletList,
2247
+ Do as codeFence,
2248
+ Oo as codeInline,
2249
+ uo as commands,
2250
+ _o as commonmark,
2251
+ zo as commonmarkNodes,
2252
+ Fo as commonmarkPlugins,
2253
+ Oe as createTable,
2254
+ Bo as doc,
2255
+ Po as em,
2256
+ $t as footnoteDefinition,
2257
+ Ot as footnoteReference,
2258
+ ao as gfm,
2259
+ Wo as hardbreak,
2260
+ Ho as heading,
2261
+ jo as hr,
2262
+ Ko as image,
2263
+ qo as link,
2264
+ Uo as listItem,
2265
+ Xo as orderedList,
2266
+ Vo as paragraph,
2267
+ Xn as strikeThrough,
2268
+ Zo as strong,
2269
+ Un as table,
2270
+ Vn as taskListItem,
2271
+ Go as text
2272
+ };
2859
2273
  //# sourceMappingURL=index.es.js.map