@blocknote/core 0.44.2 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +1 -1
  2. package/dist/BlockNoteExtension-C2X7LW-V.js.map +1 -1
  3. package/dist/{BlockNoteSchema-BsTi0fNS.js → BlockNoteSchema-DsMVJZv4.js} +2 -2
  4. package/dist/{BlockNoteSchema-BsTi0fNS.js.map → BlockNoteSchema-DsMVJZv4.js.map} +1 -1
  5. package/dist/{BlockNoteSchema-CBNkNhkw.cjs → BlockNoteSchema-qt4Czo0-.cjs} +2 -2
  6. package/dist/{BlockNoteSchema-CBNkNhkw.cjs.map → BlockNoteSchema-qt4Czo0-.cjs.map} +1 -1
  7. package/dist/ShowSelection-B0ch3unP.js +51 -0
  8. package/dist/ShowSelection-B0ch3unP.js.map +1 -0
  9. package/dist/ShowSelection-BxnbRvy4.cjs +2 -0
  10. package/dist/ShowSelection-BxnbRvy4.cjs.map +1 -0
  11. package/dist/{TrailingNode-CG2a-HDA.js → TrailingNode-C-Kyrtf1.js} +715 -709
  12. package/dist/TrailingNode-C-Kyrtf1.js.map +1 -0
  13. package/dist/TrailingNode-W7GJVng5.cjs +2 -0
  14. package/dist/TrailingNode-W7GJVng5.cjs.map +1 -0
  15. package/dist/{blockToNode-DBNbhwwC.js → blockToNode-BNoNIXU7.js} +2 -2
  16. package/dist/{blockToNode-DBNbhwwC.js.map → blockToNode-BNoNIXU7.js.map} +1 -1
  17. package/dist/{blockToNode-w7H99R6p.cjs → blockToNode-CumVjgem.cjs} +2 -2
  18. package/dist/{blockToNode-w7H99R6p.cjs.map → blockToNode-CumVjgem.cjs.map} +1 -1
  19. package/dist/blocknote.cjs +4 -4
  20. package/dist/blocknote.cjs.map +1 -1
  21. package/dist/blocknote.js +1118 -1077
  22. package/dist/blocknote.js.map +1 -1
  23. package/dist/blocks.cjs +1 -1
  24. package/dist/blocks.js +2 -2
  25. package/dist/comments.cjs +1 -1
  26. package/dist/comments.cjs.map +1 -1
  27. package/dist/comments.js +3 -3
  28. package/dist/comments.js.map +1 -1
  29. package/dist/{defaultBlocks-B63ufZ5N.js → defaultBlocks-CXOCngjC.js} +273 -312
  30. package/dist/defaultBlocks-CXOCngjC.js.map +1 -0
  31. package/dist/defaultBlocks-IsUGVZIq.cjs +6 -0
  32. package/dist/defaultBlocks-IsUGVZIq.cjs.map +1 -0
  33. package/dist/extensions.cjs +1 -1
  34. package/dist/extensions.js +4 -4
  35. package/dist/style.css +1 -1
  36. package/dist/tsconfig.tsbuildinfo +1 -1
  37. package/dist/webpack-stats.json +1 -1
  38. package/dist/yjs.cjs +1 -1
  39. package/dist/yjs.js +1 -1
  40. package/package.json +18 -18
  41. package/src/api/blockManipulation/selections/selection.ts +9 -4
  42. package/src/api/blockManipulation/tables/tables.test.ts +140 -0
  43. package/src/api/blockManipulation/tables/tables.ts +1 -1
  44. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +17 -0
  45. package/src/api/parsers/markdown/parseMarkdown.ts +11 -0
  46. package/src/blocks/ListItem/BulletListItem/block.ts +1 -1
  47. package/src/blocks/ListItem/CheckListItem/block.ts +6 -4
  48. package/src/blocks/ListItem/NumberedListItem/block.ts +6 -2
  49. package/src/comments/extension.ts +6 -2
  50. package/src/editor/Block.css +1 -1
  51. package/src/editor/BlockNoteEditor.test.ts +0 -1
  52. package/src/editor/BlockNoteEditor.ts +9 -39
  53. package/src/editor/BlockNoteExtension.ts +5 -0
  54. package/src/editor/managers/EventManager.ts +1 -1
  55. package/src/editor/managers/ExtensionManager/extensions.ts +3 -13
  56. package/src/editor/managers/ExtensionManager/index.ts +7 -2
  57. package/src/editor/managers/SelectionManager.ts +10 -10
  58. package/src/extensions/BlockChange/BlockChange.ts +2 -2
  59. package/src/extensions/Collaboration/Collaboration.ts +55 -0
  60. package/src/extensions/Collaboration/ForkYDoc.ts +4 -9
  61. package/src/extensions/Collaboration/YCursorPlugin.ts +56 -60
  62. package/src/extensions/Collaboration/YSync.ts +2 -2
  63. package/src/extensions/Collaboration/YUndo.ts +2 -2
  64. package/src/extensions/LinkToolbar/LinkToolbar.ts +1 -1
  65. package/src/extensions/ShowSelection/ShowSelection.ts +14 -4
  66. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +40 -68
  67. package/src/extensions/TableHandles/TableHandles.ts +9 -5
  68. package/src/index.ts +2 -1
  69. package/src/schema/blocks/createSpec.ts +3 -0
  70. package/src/util/expandToWords.ts +38 -0
  71. package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
  72. package/types/src/editor/BlockNoteEditor.d.ts +5 -34
  73. package/types/src/editor/BlockNoteExtension.d.ts +4 -0
  74. package/types/src/editor/managers/SelectionManager.d.ts +4 -4
  75. package/types/src/extensions/Collaboration/Collaboration.d.ts +76 -0
  76. package/types/src/extensions/Collaboration/ForkYDoc.d.ts +2 -11
  77. package/types/src/extensions/Collaboration/YCursorPlugin.d.ts +3 -11
  78. package/types/src/extensions/Collaboration/YSync.d.ts +2 -4
  79. package/types/src/extensions/Collaboration/YUndo.d.ts +1 -1
  80. package/types/src/extensions/ShowSelection/ShowSelection.d.ts +10 -4
  81. package/types/src/index.d.ts +2 -1
  82. package/types/src/util/expandToWords.d.ts +13 -0
  83. package/dist/ShowSelection-BW37oJ6h.cjs +0 -2
  84. package/dist/ShowSelection-BW37oJ6h.cjs.map +0 -1
  85. package/dist/ShowSelection-Dz-NEase.js +0 -43
  86. package/dist/ShowSelection-Dz-NEase.js.map +0 -1
  87. package/dist/TrailingNode-CG2a-HDA.js.map +0 -1
  88. package/dist/TrailingNode-Du4SNHun.cjs +0 -2
  89. package/dist/TrailingNode-Du4SNHun.cjs.map +0 -1
  90. package/dist/defaultBlocks-B63ufZ5N.js.map +0 -1
  91. package/dist/defaultBlocks-BX6UxQa8.cjs +0 -6
  92. package/dist/defaultBlocks-BX6UxQa8.cjs.map +0 -1
@@ -1,77 +1,77 @@
1
- var Ee = Object.defineProperty;
2
- var Ie = (n, e, o) => e in n ? Ee(n, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[e] = o;
3
- var b = (n, e, o) => Ie(n, typeof e != "symbol" ? e + "" : e, o);
4
- import { Plugin as T, PluginKey as P, NodeSelection as ae, TextSelection as le, Selection as L } from "prosemirror-state";
5
- import { combineTransactionSteps as Be, getMarkRange as Te, posToDOMRect as Pe, findChildren as X } from "@tiptap/core";
6
- import Oe from "fast-deep-equal";
7
- import { i as j, t as De, U as Ae, n as Me, g as N, a as R, c as ce, m as Le, e as de, f as Ne, h as Re, j as Ve, k as He, l as Fe, o as q, p as W } from "./blockToNode-DBNbhwwC.js";
8
- import { ai as ue, a2 as G, aj as he, $ as $e, a1 as J } from "./defaultBlocks-B63ufZ5N.js";
1
+ var Ie = Object.defineProperty;
2
+ var Be = (n, e, t) => e in n ? Ie(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var b = (n, e, t) => Be(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Plugin as T, PluginKey as P, NodeSelection as le, TextSelection as ce, Selection as N } from "prosemirror-state";
5
+ import { combineTransactionSteps as Te, getMarkRange as Pe, posToDOMRect as Oe, findChildren as j } from "@tiptap/core";
6
+ import De from "fast-deep-equal";
7
+ import { i as q, t as Ae, U as Me, n as Ne, g as R, a as L, c as de, m as Re, e as ue, f as Le, h as Ve, j as He, k as Fe, l as $e, o as W, p as G } from "./blockToNode-BNoNIXU7.js";
8
+ import { ai as he, a2 as J, aj as me, $ as Ue, a1 as Q } from "./defaultBlocks-CXOCngjC.js";
9
9
  import { c as k, a as H } from "./BlockNoteExtension-C2X7LW-V.js";
10
- import { yCursorPlugin as Ue, defaultSelectionBuilder as _e, ySyncPlugin as ze, redoCommand as Ke, undoCommand as Ye, yUndoPlugin as Xe, yUndoPluginKey as Q } from "y-prosemirror";
10
+ import { yCursorPlugin as _e, defaultSelectionBuilder as ze, ySyncPlugin as Ke, redoCommand as Ye, undoCommand as Xe, yUndoPlugin as je, yUndoPluginKey as Z } from "y-prosemirror";
11
11
  import * as I from "yjs";
12
- import { PluginKey as me, Plugin as pe, TextSelection as je } from "@tiptap/pm/state";
13
- import { dropCursor as qe } from "prosemirror-dropcursor";
14
- import { redo as We, undo as Ge, history as Je } from "@tiptap/pm/history";
12
+ import { PluginKey as pe, Plugin as fe, TextSelection as qe } from "@tiptap/pm/state";
13
+ import { dropCursor as We } from "prosemirror-dropcursor";
14
+ import { redo as Ge, undo as Je, history as Qe } from "@tiptap/pm/history";
15
15
  import { Decoration as A, DecorationSet as V } from "prosemirror-view";
16
- import { v4 as Qe } from "uuid";
17
- import { DOMParser as Ze, Slice as et } from "@tiptap/pm/model";
18
- import { DOMSerializer as fe, Fragment as ge, Slice as tt } from "prosemirror-model";
19
- import ot from "rehype-parse";
20
- import nt from "rehype-remark";
21
- import rt from "remark-gfm";
22
- import st from "remark-stringify";
23
- import { unified as it } from "unified";
24
- import { fromDom as at } from "hast-util-from-dom";
25
- import { visit as lt } from "unist-util-visit";
26
- import { splitCell as ct, mergeCells as dt, deleteRow as ut, deleteColumn as ht, addRowBefore as mt, addRowAfter as pt, addColumnBefore as ft, addColumnAfter as gt, CellSelection as wt } from "prosemirror-tables";
27
- function we(n) {
16
+ import { v4 as Ze } from "uuid";
17
+ import { DOMParser as et, Slice as tt } from "@tiptap/pm/model";
18
+ import { DOMSerializer as ge, Fragment as we, Slice as ot } from "prosemirror-model";
19
+ import nt from "rehype-parse";
20
+ import rt from "rehype-remark";
21
+ import st from "remark-gfm";
22
+ import it from "remark-stringify";
23
+ import { unified as at } from "unified";
24
+ import { fromDom as lt } from "hast-util-from-dom";
25
+ import { visit as ct } from "unist-util-visit";
26
+ import { splitCell as dt, mergeCells as ut, deleteRow as ht, deleteColumn as mt, addRowBefore as pt, addRowAfter as ft, addColumnBefore as gt, addColumnAfter as wt, CellSelection as yt } from "prosemirror-tables";
27
+ function ye(n) {
28
28
  const e = Array.from(n.classList).filter(
29
- (o) => !o.startsWith("bn-")
29
+ (t) => !t.startsWith("bn-")
30
30
  ) || [];
31
31
  e.length > 0 ? n.className = e.join(" ") : n.removeAttribute("class");
32
32
  }
33
- function ye(n, e, o, t) {
33
+ function be(n, e, t, o) {
34
34
  var a;
35
35
  let r;
36
36
  if (e)
37
37
  if (typeof e == "string")
38
- r = j([e], n.pmSchema);
38
+ r = q([e], n.pmSchema);
39
39
  else if (Array.isArray(e))
40
- r = j(e, n.pmSchema);
40
+ r = q(e, n.pmSchema);
41
41
  else if (e.type === "tableContent")
42
- r = De(e, n.pmSchema);
42
+ r = Ae(e, n.pmSchema);
43
43
  else
44
- throw new Ae(e.type);
44
+ throw new Me(e.type);
45
45
  else throw new Error("blockContent is required");
46
- const i = ((t == null ? void 0 : t.document) ?? document).createDocumentFragment();
46
+ const i = ((o == null ? void 0 : o.document) ?? document).createDocumentFragment();
47
47
  for (const c of r)
48
48
  if (c.type.name !== "text" && n.schema.inlineContentSchema[c.type.name]) {
49
49
  const l = n.schema.inlineContentSpecs[c.type.name].implementation;
50
50
  if (l) {
51
- const m = Me(
51
+ const u = Ne(
52
52
  c,
53
53
  n.schema.inlineContentSchema,
54
54
  n.schema.styleSchema
55
55
  ), h = l.toExternalHTML ? l.toExternalHTML(
56
- m,
56
+ u,
57
57
  n
58
58
  ) : l.render.call(
59
59
  {
60
60
  renderType: "dom",
61
61
  props: void 0
62
62
  },
63
- m,
63
+ u,
64
64
  () => {
65
65
  },
66
66
  n
67
67
  );
68
68
  if (h) {
69
69
  if (i.appendChild(h.dom), h.contentDOM) {
70
- const f = o.serializeFragment(
70
+ const g = t.serializeFragment(
71
71
  c.content,
72
- t
72
+ o
73
73
  );
74
- h.contentDOM.dataset.editable = "", h.contentDOM.appendChild(f);
74
+ h.contentDOM.dataset.editable = "", h.contentDOM.appendChild(g);
75
75
  }
76
76
  continue;
77
77
  }
@@ -80,328 +80,273 @@ function ye(n, e, o, t) {
80
80
  let l = document.createTextNode(
81
81
  c.textContent
82
82
  );
83
- for (const m of c.marks.toReversed())
84
- if (m.type.name in n.schema.styleSpecs) {
85
- const h = (n.schema.styleSpecs[m.type.name].implementation.toExternalHTML ?? n.schema.styleSpecs[m.type.name].implementation.render)(m.attrs.stringValue, n);
83
+ for (const u of c.marks.toReversed())
84
+ if (u.type.name in n.schema.styleSpecs) {
85
+ const h = (n.schema.styleSpecs[u.type.name].implementation.toExternalHTML ?? n.schema.styleSpecs[u.type.name].implementation.render)(u.attrs.stringValue, n);
86
86
  h.contentDOM.appendChild(l), l = h.dom;
87
87
  } else {
88
- const h = m.type.spec.toDOM(m, !0), f = fe.renderSpec(document, h);
89
- f.contentDOM.appendChild(l), l = f.dom;
88
+ const h = u.type.spec.toDOM(u, !0), g = ge.renderSpec(document, h);
89
+ g.contentDOM.appendChild(l), l = g.dom;
90
90
  }
91
91
  i.appendChild(l);
92
92
  } else {
93
- const l = o.serializeFragment(
94
- ge.from([c]),
95
- t
93
+ const l = t.serializeFragment(
94
+ we.from([c]),
95
+ o
96
96
  );
97
97
  i.appendChild(l);
98
98
  }
99
- return i.childNodes.length === 1 && ((a = i.firstChild) == null ? void 0 : a.nodeType) === 1 && we(i.firstChild), i;
99
+ return i.childNodes.length === 1 && ((a = i.firstChild) == null ? void 0 : a.nodeType) === 1 && ye(i.firstChild), i;
100
100
  }
101
- function yt(n, e, o, t, r, s, i) {
102
- var p, w, y, E, O, _, z, K, Y;
103
- const a = (i == null ? void 0 : i.document) ?? document, c = e.pmSchema.nodes.blockContainer, l = o.props || {};
101
+ function bt(n, e, t, o, r, s, i, a) {
102
+ var w, y, E, O, _, z, K, Y, X;
103
+ const c = (a == null ? void 0 : a.document) ?? document, l = e.pmSchema.nodes.blockContainer, u = t.props || {};
104
104
  for (const [v, S] of Object.entries(
105
- e.schema.blockSchema[o.type].propSchema
105
+ e.schema.blockSchema[t.type].propSchema
106
106
  ))
107
- !(v in l) && S.default !== void 0 && (l[v] = S.default);
108
- const m = (w = (p = c.spec) == null ? void 0 : p.toDOM) == null ? void 0 : w.call(
109
- p,
110
- c.create({
111
- id: o.id,
112
- ...l
107
+ !(v in u) && S.default !== void 0 && (u[v] = S.default);
108
+ const h = (y = (w = l.spec) == null ? void 0 : w.toDOM) == null ? void 0 : y.call(
109
+ w,
110
+ l.create({
111
+ id: t.id,
112
+ ...u
113
113
  })
114
- ), h = Array.from(m.dom.attributes), f = e.blockImplementations[o.type].implementation, u = ((y = f.toExternalHTML) == null ? void 0 : y.call(
114
+ ), g = Array.from(h.dom.attributes), m = e.blockImplementations[t.type].implementation, p = ((E = m.toExternalHTML) == null ? void 0 : E.call(
115
115
  {},
116
- { ...o, props: l },
116
+ { ...t, props: u },
117
117
  e
118
- )) || f.render.call(
118
+ )) || m.render.call(
119
119
  {},
120
- { ...o, props: l },
120
+ { ...t, props: u },
121
121
  e
122
- ), g = a.createDocumentFragment();
123
- if (u.dom.classList.contains("bn-block-content")) {
122
+ ), d = c.createDocumentFragment();
123
+ if (p.dom.classList.contains("bn-block-content")) {
124
124
  const v = [
125
- ...h,
126
- ...Array.from(u.dom.attributes)
125
+ ...g,
126
+ ...Array.from(p.dom.attributes)
127
127
  ].filter(
128
128
  (S) => S.name.startsWith("data") && S.name !== "data-content-type" && S.name !== "data-file-block" && S.name !== "data-node-view-wrapper" && S.name !== "data-node-type" && S.name !== "data-id" && S.name !== "data-editable"
129
129
  );
130
130
  for (const S of v)
131
- u.dom.firstChild.setAttribute(S.name, S.value);
132
- we(u.dom.firstChild), g.append(...Array.from(u.dom.childNodes));
131
+ p.dom.firstChild.setAttribute(S.name, S.value);
132
+ ye(p.dom.firstChild), i > 0 && p.dom.firstChild.setAttribute(
133
+ "data-nesting-level",
134
+ i.toString()
135
+ ), d.append(...Array.from(p.dom.childNodes));
133
136
  } else
134
- g.append(u.dom);
135
- if (u.contentDOM && o.content) {
136
- const v = ye(
137
+ d.append(p.dom), i > 0 && p.dom.setAttribute(
138
+ "data-nesting-level",
139
+ i.toString()
140
+ );
141
+ if (p.contentDOM && t.content) {
142
+ const v = be(
137
143
  e,
138
- o.content,
144
+ t.content,
139
145
  // TODO
140
- t,
141
- i
146
+ o,
147
+ a
142
148
  );
143
- u.contentDOM.appendChild(v);
149
+ p.contentDOM.appendChild(v);
144
150
  }
145
- let d;
146
- if (r.has(o.type) ? d = "OL" : s.has(o.type) && (d = "UL"), d) {
147
- if (((E = n.lastChild) == null ? void 0 : E.nodeName) !== d) {
148
- const v = a.createElement(d);
149
- d === "OL" && "start" in l && l.start && (l == null ? void 0 : l.start) !== 1 && v.setAttribute("start", l.start + ""), n.append(v);
151
+ let f;
152
+ if (r.has(t.type) ? f = "OL" : s.has(t.type) && (f = "UL"), f) {
153
+ if (((O = n.lastChild) == null ? void 0 : O.nodeName) !== f) {
154
+ const v = c.createElement(f);
155
+ f === "OL" && "start" in u && u.start && (u == null ? void 0 : u.start) !== 1 && v.setAttribute("start", u.start + ""), n.append(v);
150
156
  }
151
- n.lastChild.appendChild(g);
157
+ n.lastChild.appendChild(d);
152
158
  } else
153
- n.append(g);
154
- if (o.children && o.children.length > 0) {
155
- const v = a.createDocumentFragment();
156
- if (be(
159
+ n.append(d);
160
+ if (t.children && t.children.length > 0) {
161
+ const v = c.createDocumentFragment();
162
+ if (ve(
157
163
  v,
158
164
  e,
159
- o.children,
160
- t,
165
+ t.children,
166
+ o,
161
167
  r,
162
168
  s,
163
- i
164
- ), ((O = n.lastChild) == null ? void 0 : O.nodeName) === "UL" || ((_ = n.lastChild) == null ? void 0 : _.nodeName) === "OL")
165
- for (; ((z = v.firstChild) == null ? void 0 : z.nodeName) === "UL" || ((K = v.firstChild) == null ? void 0 : K.nodeName) === "OL"; )
169
+ i + 1,
170
+ a
171
+ ), ((_ = n.lastChild) == null ? void 0 : _.nodeName) === "UL" || ((z = n.lastChild) == null ? void 0 : z.nodeName) === "OL")
172
+ for (; ((K = v.firstChild) == null ? void 0 : K.nodeName) === "UL" || ((Y = v.firstChild) == null ? void 0 : Y.nodeName) === "OL"; )
166
173
  n.lastChild.lastChild.appendChild(v.firstChild);
167
- e.pmSchema.nodes[o.type].isInGroup("blockContent") ? n.append(v) : (Y = u.contentDOM) == null || Y.append(v);
174
+ e.pmSchema.nodes[t.type].isInGroup("blockContent") ? n.append(v) : (X = p.contentDOM) == null || X.append(v);
168
175
  }
169
176
  }
170
- const be = (n, e, o, t, r, s, i) => {
171
- for (const a of o)
172
- yt(
177
+ const ve = (n, e, t, o, r, s, i = 0, a) => {
178
+ for (const c of t)
179
+ bt(
173
180
  n,
174
181
  e,
175
- a,
176
- t,
182
+ c,
183
+ o,
177
184
  r,
178
185
  s,
179
- i
186
+ i,
187
+ a
180
188
  );
181
- }, bt = (n, e, o, t, r, s) => {
189
+ }, vt = (n, e, t, o, r, s) => {
182
190
  const a = ((s == null ? void 0 : s.document) ?? document).createDocumentFragment();
183
- return be(
191
+ return ve(
184
192
  a,
185
193
  n,
186
194
  e,
187
- o,
188
195
  t,
196
+ o,
189
197
  r,
198
+ 0,
190
199
  s
191
200
  ), a;
192
- }, ve = (n, e) => {
193
- const o = fe.fromSchema(n);
201
+ }, ke = (n, e) => {
202
+ const t = ge.fromSchema(n);
194
203
  return {
195
- exportBlocks: (t, r) => {
196
- const s = bt(
204
+ exportBlocks: (o, r) => {
205
+ const s = vt(
197
206
  e,
198
- t,
199
207
  o,
208
+ t,
200
209
  /* @__PURE__ */ new Set(["numberedListItem"]),
201
210
  /* @__PURE__ */ new Set(["bulletListItem", "checkListItem", "toggleListItem"]),
202
211
  r
203
212
  ), i = document.createElement("div");
204
213
  return i.append(s), i.innerHTML;
205
214
  },
206
- exportInlineContent: (t, r) => {
207
- const s = ye(
215
+ exportInlineContent: (o, r) => {
216
+ const s = be(
208
217
  e,
209
- t,
210
218
  o,
219
+ t,
211
220
  r
212
221
  ), i = document.createElement("div");
213
222
  return i.append(s.cloneNode(!0)), i.innerHTML;
214
223
  }
215
224
  };
216
225
  };
217
- function vt(n, e) {
226
+ function kt(n, e) {
218
227
  if (e === 0)
219
228
  return;
220
- const o = n.resolve(e);
221
- for (let t = o.depth; t > 0; t--) {
222
- const r = o.node(t);
223
- if (ue(r))
229
+ const t = n.resolve(e);
230
+ for (let o = t.depth; o > 0; o--) {
231
+ const r = t.node(o);
232
+ if (he(r))
224
233
  return r.attrs.id;
225
234
  }
226
235
  }
227
- function kt(n) {
236
+ function Ct(n) {
228
237
  return n.getMeta("paste") ? { type: "paste" } : n.getMeta("uiEvent") === "drop" ? { type: "drop" } : n.getMeta("history$") ? {
229
238
  type: n.getMeta("history$").redo ? "redo" : "undo"
230
239
  } : n.getMeta("y-sync$") ? n.getMeta("y-sync$").isUndoRedoOperation ? { type: "undo-redo" } : { type: "yjs-remote" } : { type: "local" };
231
240
  }
232
- function Z(n) {
233
- const e = "__root__", o = {}, t = {}, r = N(n);
241
+ function ee(n) {
242
+ const e = "__root__", t = {}, o = {}, r = R(n);
234
243
  return n.descendants((s, i) => {
235
- if (!ue(s))
244
+ if (!he(s))
236
245
  return !0;
237
- const a = vt(n, i), c = a ?? e;
238
- t[c] || (t[c] = []);
239
- const l = R(s, r);
240
- return o[s.attrs.id] = { block: l, parentId: a }, t[c].push(s.attrs.id), !0;
241
- }), { byId: o, childrenByParent: t };
246
+ const a = kt(n, i), c = a ?? e;
247
+ o[c] || (o[c] = []);
248
+ const l = L(s, r);
249
+ return t[s.attrs.id] = { block: l, parentId: a }, o[c].push(s.attrs.id), !0;
250
+ }), { byId: t, childrenByParent: o };
242
251
  }
243
- function Ct(n, e) {
244
- const o = /* @__PURE__ */ new Set();
252
+ function St(n, e) {
253
+ const t = /* @__PURE__ */ new Set();
245
254
  if (!n || !e)
246
- return o;
247
- const t = new Set(n), r = e.filter((d) => t.has(d)), s = n.filter(
255
+ return t;
256
+ const o = new Set(n), r = e.filter((d) => o.has(d)), s = n.filter(
248
257
  (d) => r.includes(d)
249
258
  );
250
259
  if (s.length <= 1 || r.length <= 1)
251
- return o;
260
+ return t;
252
261
  const i = {};
253
262
  for (let d = 0; d < s.length; d++)
254
263
  i[s[d]] = d;
255
- const a = r.map((d) => i[d]), c = a.length, l = [], m = [], h = new Array(c).fill(-1), f = (d, p) => {
264
+ const a = r.map((d) => i[d]), c = a.length, l = [], u = [], h = new Array(c).fill(-1), g = (d, f) => {
256
265
  let w = 0, y = d.length;
257
266
  for (; w < y; ) {
258
267
  const E = w + y >>> 1;
259
- d[E] < p ? w = E + 1 : y = E;
268
+ d[E] < f ? w = E + 1 : y = E;
260
269
  }
261
270
  return w;
262
271
  };
263
272
  for (let d = 0; d < c; d++) {
264
- const p = a[d], w = f(l, p);
265
- w > 0 && (h[d] = m[w - 1]), w === l.length ? (l.push(p), m.push(d)) : (l[w] = p, m[w] = d);
273
+ const f = a[d], w = g(l, f);
274
+ w > 0 && (h[d] = u[w - 1]), w === l.length ? (l.push(f), u.push(d)) : (l[w] = f, u[w] = d);
266
275
  }
267
- const u = /* @__PURE__ */ new Set();
268
- let g = m[m.length - 1] ?? -1;
269
- for (; g !== -1; )
270
- u.add(g), g = h[g];
276
+ const m = /* @__PURE__ */ new Set();
277
+ let p = u[u.length - 1] ?? -1;
278
+ for (; p !== -1; )
279
+ m.add(p), p = h[p];
271
280
  for (let d = 0; d < r.length; d++)
272
- u.has(d) || o.add(r[d]);
273
- return o;
281
+ m.has(d) || t.add(r[d]);
282
+ return t;
274
283
  }
275
- function St(n, e = []) {
276
- const o = kt(n), t = Be(n.before, [
284
+ function xt(n, e = []) {
285
+ const t = Ct(n), o = Te(n.before, [
277
286
  n,
278
287
  ...e
279
- ]), r = Z(
280
- t.before
281
- ), s = Z(
282
- t.doc
288
+ ]), r = ee(
289
+ o.before
290
+ ), s = ee(
291
+ o.doc
283
292
  ), i = [], a = /* @__PURE__ */ new Set();
284
- Object.keys(s.byId).filter((u) => !(u in r.byId)).forEach((u) => {
293
+ Object.keys(s.byId).filter((m) => !(m in r.byId)).forEach((m) => {
285
294
  i.push({
286
295
  type: "insert",
287
- block: s.byId[u].block,
288
- source: o,
296
+ block: s.byId[m].block,
297
+ source: t,
289
298
  prevBlock: void 0
290
- }), a.add(u);
291
- }), Object.keys(r.byId).filter((u) => !(u in s.byId)).forEach((u) => {
299
+ }), a.add(m);
300
+ }), Object.keys(r.byId).filter((m) => !(m in s.byId)).forEach((m) => {
292
301
  i.push({
293
302
  type: "delete",
294
- block: r.byId[u].block,
295
- source: o,
303
+ block: r.byId[m].block,
304
+ source: t,
296
305
  prevBlock: void 0
297
- }), a.add(u);
298
- }), Object.keys(s.byId).filter((u) => u in r.byId).forEach((u) => {
306
+ }), a.add(m);
307
+ }), Object.keys(s.byId).filter((m) => m in r.byId).forEach((m) => {
299
308
  var w, y;
300
- const g = r.byId[u], d = s.byId[u];
301
- g.parentId !== d.parentId ? (i.push({
309
+ const p = r.byId[m], d = s.byId[m];
310
+ p.parentId !== d.parentId ? (i.push({
302
311
  type: "move",
303
312
  block: d.block,
304
- prevBlock: g.block,
305
- source: o,
306
- prevParent: g.parentId ? (w = r.byId[g.parentId]) == null ? void 0 : w.block : void 0,
313
+ prevBlock: p.block,
314
+ source: t,
315
+ prevParent: p.parentId ? (w = r.byId[p.parentId]) == null ? void 0 : w.block : void 0,
307
316
  currentParent: d.parentId ? (y = s.byId[d.parentId]) == null ? void 0 : y.block : void 0
308
- }), a.add(u)) : Oe(
309
- { ...g.block, children: void 0 },
317
+ }), a.add(m)) : De(
318
+ { ...p.block, children: void 0 },
310
319
  { ...d.block, children: void 0 }
311
320
  ) || (i.push({
312
321
  type: "update",
313
322
  block: d.block,
314
- prevBlock: g.block,
315
- source: o
316
- }), a.add(u));
323
+ prevBlock: p.block,
324
+ source: t
325
+ }), a.add(m));
317
326
  });
318
- const c = r.childrenByParent, l = s.childrenByParent, m = "__root__", h = /* @__PURE__ */ new Set([
327
+ const c = r.childrenByParent, l = s.childrenByParent, u = "__root__", h = /* @__PURE__ */ new Set([
319
328
  ...Object.keys(c),
320
329
  ...Object.keys(l)
321
- ]), f = /* @__PURE__ */ new Set();
322
- return h.forEach((u) => {
323
- const g = Ct(
324
- c[u],
325
- l[u]
330
+ ]), g = /* @__PURE__ */ new Set();
331
+ return h.forEach((m) => {
332
+ const p = St(
333
+ c[m],
334
+ l[m]
326
335
  );
327
- g.size !== 0 && g.forEach((d) => {
336
+ p.size !== 0 && p.forEach((d) => {
328
337
  var E, O;
329
- const p = r.byId[d], w = s.byId[d];
330
- !p || !w || p.parentId !== w.parentId || a.has(d) || (p.parentId ?? m) !== u || f.has(d) || (f.add(d), i.push({
338
+ const f = r.byId[d], w = s.byId[d];
339
+ !f || !w || f.parentId !== w.parentId || a.has(d) || (f.parentId ?? u) !== m || g.has(d) || (g.add(d), i.push({
331
340
  type: "move",
332
341
  block: w.block,
333
- prevBlock: p.block,
334
- source: o,
335
- prevParent: p.parentId ? (E = r.byId[p.parentId]) == null ? void 0 : E.block : void 0,
342
+ prevBlock: f.block,
343
+ source: t,
344
+ prevParent: f.parentId ? (E = r.byId[f.parentId]) == null ? void 0 : E.block : void 0,
336
345
  currentParent: w.parentId ? (O = s.byId[w.parentId]) == null ? void 0 : O.block : void 0
337
346
  }), a.add(d));
338
347
  });
339
348
  }), i;
340
349
  }
341
- function xt() {
342
- const n = (e) => {
343
- let o = e.children.length;
344
- for (let t = 0; t < o; t++) {
345
- const r = e.children[t];
346
- if (r.type === "element" && (n(r), r.tagName === "u"))
347
- if (r.children.length > 0) {
348
- e.children.splice(t, 1, ...r.children);
349
- const s = r.children.length - 1;
350
- o += s, t += s;
351
- } else
352
- e.children.splice(t, 1), o--, t--;
353
- }
354
- };
355
- return n;
356
- }
357
- function Et() {
358
- const n = (e) => {
359
- var o;
360
- if (e.children && "length" in e.children && e.children.length)
361
- for (let t = e.children.length - 1; t >= 0; t--) {
362
- const r = e.children[t], s = t + 1 < e.children.length ? e.children[t + 1] : void 0;
363
- r.type === "element" && r.tagName === "input" && ((o = r.properties) == null ? void 0 : o.type) === "checkbox" && (s == null ? void 0 : s.type) === "element" && s.tagName === "p" ? (s.tagName = "span", s.children.splice(
364
- 0,
365
- 0,
366
- at(document.createTextNode(" "))
367
- )) : n(r);
368
- }
369
- };
370
- return n;
371
- }
372
- function It() {
373
- return (n) => {
374
- lt(n, "element", (e, o, t) => {
375
- var r, s, i, a;
376
- if (t && e.tagName === "video") {
377
- const c = ((r = e.properties) == null ? void 0 : r.src) || ((s = e.properties) == null ? void 0 : s["data-url"]) || "", l = ((i = e.properties) == null ? void 0 : i.title) || ((a = e.properties) == null ? void 0 : a["data-name"]) || "";
378
- t.children[o] = {
379
- type: "text",
380
- value: `![${l}](${c})`
381
- };
382
- }
383
- });
384
- };
385
- }
386
- function ke(n) {
387
- return it().use(ot, { fragment: !0 }).use(It).use(xt).use(Et).use(nt).use(rt).use(st, {
388
- handlers: { text: (o) => o.value }
389
- }).processSync(n).value;
390
- }
391
- function po(n, e, o, t) {
392
- const s = ve(e, o).exportBlocks(n, t);
393
- return ke(s);
394
- }
395
- function Bt(n) {
396
- const e = [];
397
- return n.descendants((o) => {
398
- var r, s;
399
- const t = N(o);
400
- return o.type.name === "blockContainer" && ((r = o.firstChild) == null ? void 0 : r.type.name) === "blockGroup" ? !0 : o.type.name === "columnList" && o.childCount === 1 ? ((s = o.firstChild) == null || s.forEach((i) => {
401
- e.push(R(i, t));
402
- }), !1) : o.type.isInGroup("bnBlock") ? (e.push(R(o, t)), !1) : !0;
403
- }), e;
404
- }
405
350
  const fo = k(() => {
406
351
  const n = [];
407
352
  return {
@@ -410,10 +355,10 @@ const fo = k(() => {
410
355
  new T({
411
356
  key: new P("blockChange"),
412
357
  filterTransaction: (e) => {
413
- let o;
414
- return n.reduce((t, r) => t === !1 ? t : r({
358
+ let t;
359
+ return n.reduce((o, r) => o === !1 ? o : r({
415
360
  getChanges() {
416
- return o || (o = St(e), o);
361
+ return t || (t = xt(e), t);
417
362
  },
418
363
  tr: e
419
364
  }) !== !1, !0);
@@ -433,40 +378,38 @@ const fo = k(() => {
433
378
  }
434
379
  };
435
380
  });
436
- function ee(n) {
437
- const e = n.charAt(0) === "#" ? n.substring(1, 7) : n, o = parseInt(e.substring(0, 2), 16), t = parseInt(e.substring(2, 4), 16), r = parseInt(e.substring(4, 6), 16), i = [o / 255, t / 255, r / 255].map((c) => c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));
381
+ function te(n) {
382
+ const e = n.charAt(0) === "#" ? n.substring(1, 7) : n, t = parseInt(e.substring(0, 2), 16), o = parseInt(e.substring(2, 4), 16), r = parseInt(e.substring(4, 6), 16), i = [t / 255, o / 255, r / 255].map((c) => c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));
438
383
  return 0.2126 * i[0] + 0.7152 * i[1] + 0.0722 * i[2] <= 0.179;
439
384
  }
440
- function Tt(n) {
385
+ function Et(n) {
441
386
  const e = document.createElement("span");
442
387
  e.classList.add("bn-collaboration-cursor__base");
443
- const o = document.createElement("span");
444
- o.setAttribute("contentedEditable", "false"), o.classList.add("bn-collaboration-cursor__caret"), o.setAttribute(
388
+ const t = document.createElement("span");
389
+ t.setAttribute("contentedEditable", "false"), t.classList.add("bn-collaboration-cursor__caret"), t.setAttribute(
445
390
  "style",
446
- `background-color: ${n.color}; color: ${ee(n.color) ? "white" : "black"}`
391
+ `background-color: ${n.color}; color: ${te(n.color) ? "white" : "black"}`
447
392
  );
448
- const t = document.createElement("span");
449
- return t.classList.add("bn-collaboration-cursor__label"), t.setAttribute(
393
+ const o = document.createElement("span");
394
+ return o.classList.add("bn-collaboration-cursor__label"), o.setAttribute(
450
395
  "style",
451
- `background-color: ${n.color}; color: ${ee(n.color) ? "white" : "black"}`
452
- ), t.insertBefore(document.createTextNode(n.name), null), o.insertBefore(t, null), e.insertBefore(document.createTextNode("⁠"), null), e.insertBefore(o, null), e.insertBefore(document.createTextNode("⁠"), null), e;
396
+ `background-color: ${n.color}; color: ${te(n.color) ? "white" : "black"}`
397
+ ), o.insertBefore(document.createTextNode(n.name), null), t.insertBefore(o, null), e.insertBefore(document.createTextNode("⁠"), null), e.insertBefore(t, null), e.insertBefore(document.createTextNode("⁠"), null), e;
453
398
  }
454
- const te = k(
455
- ({
456
- options: n
457
- }) => {
458
- const e = /* @__PURE__ */ new Map();
459
- return n.provider && "awareness" in n.provider && typeof n.provider.awareness == "object" && ("setLocalStateField" in n.provider.awareness && typeof n.provider.awareness.setLocalStateField == "function" && n.provider.awareness.setLocalStateField("user", n.user), "on" in n.provider.awareness && typeof n.provider.awareness.on == "function" && n.showCursorLabels !== "always" && n.provider.awareness.on(
399
+ const oe = k(
400
+ ({ options: n }) => {
401
+ const e = /* @__PURE__ */ new Map(), t = n.provider && "awareness" in n.provider && typeof n.provider.awareness == "object" ? n.provider.awareness : void 0;
402
+ return t && ("setLocalStateField" in t && typeof t.setLocalStateField == "function" && t.setLocalStateField("user", n.user), "on" in t && typeof t.on == "function" && n.showCursorLabels !== "always" && t.on(
460
403
  "change",
461
404
  ({
462
405
  updated: o
463
406
  }) => {
464
- for (const t of o) {
465
- const r = e.get(t);
466
- r && (r.element.setAttribute("data-active", ""), r.hideTimeout && clearTimeout(r.hideTimeout), e.set(t, {
467
- element: r.element,
407
+ for (const r of o) {
408
+ const s = e.get(r);
409
+ s && (s.element.setAttribute("data-active", ""), s.hideTimeout && clearTimeout(s.hideTimeout), e.set(r, {
410
+ element: s.element,
468
411
  hideTimeout: setTimeout(() => {
469
- r.element.removeAttribute("data-active");
412
+ s.element.removeAttribute("data-active");
470
413
  }, 2e3)
471
414
  }));
472
415
  }
@@ -474,99 +417,96 @@ const te = k(
474
417
  )), {
475
418
  key: "yCursor",
476
419
  prosemirrorPlugins: [
477
- Ue(n.provider.awareness, {
478
- selectionBuilder: _e,
479
- cursorBuilder(o, t) {
480
- let r = e.get(t);
481
- if (!r) {
482
- const s = (n.renderCursor ?? Tt)(o);
483
- n.showCursorLabels !== "always" && (s.addEventListener("mouseenter", () => {
484
- const i = e.get(t);
485
- i.element.setAttribute("data-active", ""), i.hideTimeout && (clearTimeout(i.hideTimeout), e.set(t, {
486
- element: i.element,
420
+ t ? _e(t, {
421
+ selectionBuilder: ze,
422
+ cursorBuilder(o, r) {
423
+ let s = e.get(r);
424
+ if (!s) {
425
+ const i = (n.renderCursor ?? Et)(o);
426
+ n.showCursorLabels !== "always" && (i.addEventListener("mouseenter", () => {
427
+ const a = e.get(r);
428
+ a.element.setAttribute("data-active", ""), a.hideTimeout && (clearTimeout(a.hideTimeout), e.set(r, {
429
+ element: a.element,
487
430
  hideTimeout: void 0
488
431
  }));
489
- }), s.addEventListener("mouseleave", () => {
490
- const i = e.get(t);
491
- e.set(t, {
492
- element: i.element,
432
+ }), i.addEventListener("mouseleave", () => {
433
+ const a = e.get(r);
434
+ e.set(r, {
435
+ element: a.element,
493
436
  hideTimeout: setTimeout(() => {
494
- i.element.removeAttribute("data-active");
437
+ a.element.removeAttribute("data-active");
495
438
  }, 2e3)
496
439
  });
497
- })), r = {
498
- element: s,
440
+ })), s = {
441
+ element: i,
499
442
  hideTimeout: void 0
500
- }, e.set(t, r);
443
+ }, e.set(r, s);
501
444
  }
502
- return r.element;
445
+ return s.element;
503
446
  }
504
- })
505
- ],
447
+ }) : void 0
448
+ ].filter(Boolean),
506
449
  dependsOn: ["ySync"],
507
450
  updateUser(o) {
508
- n.provider.awareness.setLocalStateField("user", o);
451
+ t == null || t.setLocalStateField("user", o);
509
452
  }
510
453
  };
511
454
  }
512
455
  ), F = k(
513
456
  ({ options: n }) => ({
514
457
  key: "ySync",
515
- prosemirrorPlugins: [ze(n.fragment)],
458
+ prosemirrorPlugins: [Ke(n.fragment)],
516
459
  runsBefore: ["default"]
517
460
  })
518
- ), $ = k(({ editor: n }) => ({
461
+ ), $ = k(() => ({
519
462
  key: "yUndo",
520
- prosemirrorPlugins: [Xe({ trackedOrigins: [n] })],
463
+ prosemirrorPlugins: [je()],
521
464
  dependsOn: ["yCursor", "ySync"],
522
- undoCommand: Ye,
523
- redoCommand: Ke
465
+ undoCommand: Xe,
466
+ redoCommand: Ye
524
467
  }));
525
- function Pt(n, e) {
526
- const o = n.doc;
468
+ function It(n, e) {
469
+ const t = n.doc;
527
470
  if (n._item === null) {
528
- const t = Array.from(o.share.keys()).find(
529
- (r) => o.share.get(r) === n
471
+ const o = Array.from(t.share.keys()).find(
472
+ (r) => t.share.get(r) === n
530
473
  );
531
- if (t == null)
474
+ if (o == null)
532
475
  throw new Error("type does not exist in other ydoc");
533
- return e.get(t, n.constructor);
476
+ return e.get(o, n.constructor);
534
477
  } else {
535
- const t = n._item, r = e.store.clients.get(t.id.client) ?? [], s = I.findIndexSS(r, t.id.clock);
478
+ const o = n._item, r = e.store.clients.get(o.id.client) ?? [], s = I.findIndexSS(r, o.id.clock);
536
479
  return r[s].content.type;
537
480
  }
538
481
  }
539
482
  const go = k(
540
- ({
541
- editor: n,
542
- options: e
543
- }) => {
544
- let o;
545
- const t = H({ isForked: !1 });
483
+ ({ editor: n, options: e }) => {
484
+ let t;
485
+ const o = H({ isForked: !1 });
546
486
  return {
547
487
  key: "yForkDoc",
548
- store: t,
488
+ store: o,
549
489
  /**
550
490
  * Fork the Y.js document from syncing to the remote,
551
491
  * allowing modifications to the document without affecting the remote.
552
492
  * These changes can later be rolled back or applied to the remote.
553
493
  */
554
494
  fork() {
555
- if (o)
495
+ if (t)
556
496
  return;
557
497
  const r = e.fragment;
558
498
  if (!r)
559
499
  throw new Error("No fragment to fork from");
560
500
  const s = new I.Doc();
561
501
  I.applyUpdate(s, I.encodeStateAsUpdate(r.doc));
562
- const i = Pt(r, s);
563
- o = {
564
- undoStack: Q.getState(n.prosemirrorState).undoManager.undoStack,
502
+ const i = It(r, s);
503
+ t = {
504
+ undoStack: Z.getState(n.prosemirrorState).undoManager.undoStack,
565
505
  originalFragment: r,
566
506
  forkedFragment: i
567
507
  }, n.unregisterExtension([
568
508
  $,
569
- te,
509
+ oe,
570
510
  F
571
511
  ]);
572
512
  const a = {
@@ -576,8 +516,8 @@ const go = k(
576
516
  n.registerExtension([
577
517
  F(a),
578
518
  // No need to register the cursor plugin again, it's a local fork
579
- $({})
580
- ]), t.setState({ isForked: !0 });
519
+ $()
520
+ ]), o.setState({ isForked: !0 });
581
521
  },
582
522
  /**
583
523
  * Resume syncing the Y.js document to the remote
@@ -585,15 +525,15 @@ const go = k(
585
525
  * Otherwise, the original document will be restored and the changes will be discarded.
586
526
  */
587
527
  merge({ keepChanges: r }) {
588
- if (!o)
528
+ if (!t)
589
529
  return;
590
530
  n.unregisterExtension(["ySync", "yCursor", "yUndo"]);
591
- const { originalFragment: s, forkedFragment: i, undoStack: a } = o;
531
+ const { originalFragment: s, forkedFragment: i, undoStack: a } = t;
592
532
  if (n.registerExtension([
593
533
  F(e),
594
- te(e),
595
- $({})
596
- ]), Q.getState(
534
+ oe(e),
535
+ $()
536
+ ]), Z.getState(
597
537
  n.prosemirrorState
598
538
  ).undoManager.undoStack = a, r) {
599
539
  const c = I.encodeStateAsUpdate(
@@ -602,28 +542,28 @@ const go = k(
602
542
  );
603
543
  I.applyUpdate(s.doc, c, n);
604
544
  }
605
- o = void 0, t.setState({ isForked: !1 });
545
+ t = void 0, o.setState({ isForked: !1 });
606
546
  }
607
547
  };
608
548
  }
609
549
  ), Ce = (n, e) => {
610
- e(n), n.forEach((o) => {
611
- o instanceof I.XmlElement && Ce(o, e);
550
+ e(n), n.forEach((t) => {
551
+ t instanceof I.XmlElement && Ce(t, e);
612
552
  });
613
- }, Ot = (n, e) => {
614
- const o = /* @__PURE__ */ new Map();
615
- return n.forEach((t) => {
616
- t instanceof I.XmlElement && Ce(t, (r) => {
553
+ }, Bt = (n, e) => {
554
+ const t = /* @__PURE__ */ new Map();
555
+ return n.forEach((o) => {
556
+ o instanceof I.XmlElement && Ce(o, (r) => {
617
557
  if (r.nodeName === "blockContainer" && r.hasAttribute("id")) {
618
558
  const s = r.getAttribute("textColor"), i = r.getAttribute("backgroundColor"), a = {
619
- textColor: s === G.textColor.default ? void 0 : s,
620
- backgroundColor: i === G.backgroundColor.default ? void 0 : i
559
+ textColor: s === J.textColor.default ? void 0 : s,
560
+ backgroundColor: i === J.backgroundColor.default ? void 0 : i
621
561
  };
622
- (a.textColor || a.backgroundColor) && o.set(r.getAttribute("id"), a);
562
+ (a.textColor || a.backgroundColor) && t.set(r.getAttribute("id"), a);
623
563
  }
624
564
  });
625
- }), o.size === 0 ? !1 : (e.doc.descendants((t, r) => {
626
- if (t.type.name === "blockContainer" && o.has(t.attrs.id)) {
565
+ }), t.size === 0 ? !1 : (e.doc.descendants((o, r) => {
566
+ if (o.type.name === "blockContainer" && t.has(o.attrs.id)) {
627
567
  const s = e.doc.nodeAt(r + 1);
628
568
  if (!s)
629
569
  throw new Error("No element found");
@@ -631,27 +571,27 @@ const go = k(
631
571
  // preserve existing attributes
632
572
  ...s.attrs,
633
573
  // add the textColor and backgroundColor attributes
634
- ...o.get(t.attrs.id)
574
+ ...t.get(o.attrs.id)
635
575
  });
636
576
  }
637
577
  }), !0);
638
- }, Dt = [Ot], wo = k(
578
+ }, Tt = [Bt], wo = k(
639
579
  ({ options: n }) => {
640
580
  let e = !1;
641
- const o = new me("schemaMigration");
581
+ const t = new pe("schemaMigration");
642
582
  return {
643
583
  key: "schemaMigration",
644
584
  prosemirrorPlugins: [
645
- new pe({
646
- key: o,
647
- appendTransaction: (t, r, s) => {
585
+ new fe({
586
+ key: t,
587
+ appendTransaction: (o, r, s) => {
648
588
  if (e || // If any of the transactions are not due to a yjs sync, we don't need to run the migration
649
- !t.some((a) => a.getMeta("y-sync$")) || // If none of the transactions result in a document change, we don't need to run the migration
650
- t.every((a) => !a.docChanged) || // If the fragment is still empty, we can't run the migration (since it has not yet been applied to the Y.Doc)
589
+ !o.some((a) => a.getMeta("y-sync$")) || // If none of the transactions result in a document change, we don't need to run the migration
590
+ o.every((a) => !a.docChanged) || // If the fragment is still empty, we can't run the migration (since it has not yet been applied to the Y.Doc)
651
591
  !n.fragment.firstChild)
652
592
  return;
653
593
  const i = s.tr;
654
- for (const a of Dt)
594
+ for (const a of Tt)
655
595
  a(n.fragment, i);
656
596
  if (e = !0, !!i.docChanged)
657
597
  return i;
@@ -667,7 +607,7 @@ const go = k(
667
607
  }) => ({
668
608
  key: "dropCursor",
669
609
  prosemirrorPlugins: [
670
- (e.dropCursor ?? qe)({
610
+ (e.dropCursor ?? We)({
671
611
  width: 5,
672
612
  color: "#ddeeff",
673
613
  editor: n
@@ -675,24 +615,24 @@ const go = k(
675
615
  ]
676
616
  })
677
617
  ), bo = k(({ editor: n }) => {
678
- const e = H(!1), o = () => n.transact((t) => {
618
+ const e = H(!1), t = () => n.transact((o) => {
679
619
  var s;
680
- if (t.selection.empty || t.selection instanceof ae && (t.selection.node.type.spec.content === "inline*" || ((s = t.selection.node.firstChild) == null ? void 0 : s.type.spec.content) === "inline*") || t.selection instanceof le && t.doc.textBetween(t.selection.from, t.selection.to).length === 0)
620
+ if (o.selection.empty || o.selection instanceof le && (o.selection.node.type.spec.content === "inline*" || ((s = o.selection.node.firstChild) == null ? void 0 : s.type.spec.content) === "inline*") || o.selection instanceof ce && o.doc.textBetween(o.selection.from, o.selection.to).length === 0)
681
621
  return !1;
682
622
  let r = !1;
683
- return t.selection.content().content.descendants((i) => (i.type.spec.code && (r = !0), !r)), !r;
623
+ return o.selection.content().content.descendants((i) => (i.type.spec.code && (r = !0), !r)), !r;
684
624
  });
685
625
  return {
686
626
  key: "formattingToolbar",
687
627
  store: e,
688
- mount({ dom: t, signal: r }) {
628
+ mount({ dom: o, signal: r }) {
689
629
  let s = !1;
690
630
  const i = n.onChange(() => {
691
- s || e.setState(o());
631
+ s || e.setState(t());
692
632
  }), a = n.onSelectionChange(() => {
693
- s || e.setState(o());
633
+ s || e.setState(t());
694
634
  });
695
- t.addEventListener(
635
+ o.addEventListener(
696
636
  "pointerdown",
697
637
  () => {
698
638
  s = !0, e.setState(!1);
@@ -701,10 +641,10 @@ const go = k(
701
641
  ), n.prosemirrorView.root.addEventListener(
702
642
  "pointerup",
703
643
  () => {
704
- s = !1, n.isFocused() && e.setState(o());
644
+ s = !1, n.isFocused() && e.setState(t());
705
645
  },
706
646
  { signal: r, capture: !0 }
707
- ), t.addEventListener(
647
+ ), o.addEventListener(
708
648
  "pointercancel",
709
649
  () => {
710
650
  s = !1;
@@ -720,9 +660,9 @@ const go = k(
720
660
  };
721
661
  }), vo = k(() => ({
722
662
  key: "history",
723
- prosemirrorPlugins: [Je()],
724
- undoCommand: Ge,
725
- redoCommand: We
663
+ prosemirrorPlugins: [Qe()],
664
+ undoCommand: Je,
665
+ redoCommand: Ge
726
666
  })), ko = k(({ editor: n }) => {
727
667
  function e(r) {
728
668
  let s = n.prosemirrorView.nodeDOM(r);
@@ -733,12 +673,12 @@ const go = k(
733
673
  }
734
674
  return null;
735
675
  }
736
- function o(r, s) {
676
+ function t(r, s) {
737
677
  return n.transact((i) => {
738
- const a = i.doc.resolve(r), c = a.marks().find((m) => m.type.name === s);
678
+ const a = i.doc.resolve(r), c = a.marks().find((u) => u.type.name === s);
739
679
  if (!c)
740
680
  return;
741
- const l = Te(a, c.type);
681
+ const l = Pe(a, c.type);
742
682
  if (l)
743
683
  return {
744
684
  range: l,
@@ -747,7 +687,7 @@ const go = k(
747
687
  return i.doc.textBetween(l.from, l.to);
748
688
  },
749
689
  get position() {
750
- return Pe(
690
+ return Oe(
751
691
  n.prosemirrorView,
752
692
  l.from,
753
693
  l.to
@@ -756,27 +696,27 @@ const go = k(
756
696
  };
757
697
  });
758
698
  }
759
- function t() {
699
+ function o() {
760
700
  return n.transact((r) => {
761
701
  const s = r.selection;
762
702
  if (s.empty)
763
- return o(s.anchor, "link");
703
+ return t(s.anchor, "link");
764
704
  });
765
705
  }
766
706
  return {
767
707
  key: "linkToolbar",
768
- getLinkAtSelection: t,
708
+ getLinkAtSelection: o,
769
709
  getLinkElementAtPos: e,
770
- getMarkAtPos: o,
710
+ getMarkAtPos: t,
771
711
  getLinkAtElement(r) {
772
712
  return n.transact(() => {
773
713
  const s = n.prosemirrorView.posAtDOM(r, 0) + 1;
774
- return o(s, "link");
714
+ return t(s, "link");
775
715
  });
776
716
  },
777
717
  editLink(r, s, i = n.transact((a) => a.selection.anchor)) {
778
718
  n.transact((a) => {
779
- const c = N(a), { range: l } = o(i + 1, "link") || {
719
+ const c = R(a), { range: l } = t(i + 1, "link") || {
780
720
  range: {
781
721
  from: a.selection.from,
782
722
  to: a.selection.to
@@ -791,7 +731,7 @@ const go = k(
791
731
  },
792
732
  deleteLink(r = n.transact((s) => s.selection.anchor)) {
793
733
  n.transact((s) => {
794
- const i = N(s), { range: a } = o(r + 1, "link") || {
734
+ const i = R(s), { range: a } = t(r + 1, "link") || {
795
735
  range: {
796
736
  from: s.selection.from,
797
737
  to: s.selection.to
@@ -815,12 +755,12 @@ const go = k(
815
755
  "sms",
816
756
  "cid",
817
757
  "xmpp"
818
- ], So = "https", At = new P("node-selection-keyboard"), xo = k(
758
+ ], So = "https", Pt = new P("node-selection-keyboard"), xo = k(
819
759
  () => ({
820
760
  key: "nodeSelectionKeyboard",
821
761
  prosemirrorPlugins: [
822
762
  new T({
823
- key: At,
763
+ key: Pt,
824
764
  props: {
825
765
  handleKeyDown: (n, e) => {
826
766
  if ("node" in n.state.selection) {
@@ -829,14 +769,14 @@ const go = k(
829
769
  if (e.key.length === 1)
830
770
  return e.preventDefault(), !0;
831
771
  if (e.key === "Enter" && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey) {
832
- const o = n.state.tr;
772
+ const t = n.state.tr;
833
773
  return n.dispatch(
834
- o.insert(
774
+ t.insert(
835
775
  n.state.tr.selection.$to.after(),
836
776
  n.state.schema.nodes.paragraph.createChecked()
837
777
  ).setSelection(
838
- new le(
839
- o.doc.resolve(
778
+ new ce(
779
+ t.doc.resolve(
840
780
  n.state.tr.selection.$to.after() + 1
841
781
  )
842
782
  )
@@ -850,44 +790,44 @@ const go = k(
850
790
  })
851
791
  ]
852
792
  })
853
- ), Mt = new P("blocknote-placeholder"), Eo = k(
793
+ ), Ot = new P("blocknote-placeholder"), Eo = k(
854
794
  ({
855
795
  editor: n,
856
796
  options: e
857
797
  }) => {
858
- const o = e.placeholders;
798
+ const t = e.placeholders;
859
799
  return {
860
800
  key: "placeholder",
861
801
  prosemirrorPlugins: [
862
802
  new T({
863
- key: Mt,
864
- view: (t) => {
865
- const r = `placeholder-selector-${Qe()}`;
866
- t.dom.classList.add(r);
803
+ key: Ot,
804
+ view: (o) => {
805
+ const r = `placeholder-selector-${Ze()}`;
806
+ o.dom.classList.add(r);
867
807
  const s = document.createElement("style"), i = n._tiptapEditor.options.injectNonce;
868
- i && s.setAttribute("nonce", i), t.root instanceof window.ShadowRoot ? t.root.append(s) : t.root.head.appendChild(s);
808
+ i && s.setAttribute("nonce", i), o.root instanceof window.ShadowRoot ? o.root.append(s) : o.root.head.appendChild(s);
869
809
  const a = s.sheet, c = (l = "") => `.${r} .bn-block-content${l} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`;
870
810
  try {
871
811
  const {
872
812
  default: l,
873
- emptyDocument: m,
813
+ emptyDocument: u,
874
814
  ...h
875
- } = o || {};
876
- for (const [g, d] of Object.entries(h)) {
877
- const p = `[data-content-type="${g}"]`;
815
+ } = t || {};
816
+ for (const [p, d] of Object.entries(h)) {
817
+ const f = `[data-content-type="${p}"]`;
878
818
  a.insertRule(
879
- `${c(p)} { content: ${JSON.stringify(
819
+ `${c(f)} { content: ${JSON.stringify(
880
820
  d
881
821
  )}; }`
882
822
  );
883
823
  }
884
- const f = "[data-is-only-empty-block]", u = "[data-is-empty-and-focused]";
824
+ const g = "[data-is-only-empty-block]", m = "[data-is-empty-and-focused]";
885
825
  a.insertRule(
886
- `${c(f)} { content: ${JSON.stringify(
887
- m
826
+ `${c(g)} { content: ${JSON.stringify(
827
+ u
888
828
  )}; }`
889
829
  ), a.insertRule(
890
- `${c(u)} { content: ${JSON.stringify(
830
+ `${c(m)} { content: ${JSON.stringify(
891
831
  l
892
832
  )}; }`
893
833
  );
@@ -899,17 +839,17 @@ const go = k(
899
839
  }
900
840
  return {
901
841
  destroy: () => {
902
- t.root instanceof window.ShadowRoot ? t.root.removeChild(s) : t.root.head.removeChild(s);
842
+ o.root instanceof window.ShadowRoot ? o.root.removeChild(s) : o.root.head.removeChild(s);
903
843
  }
904
844
  };
905
845
  },
906
846
  props: {
907
- decorations: (t) => {
908
- const { doc: r, selection: s } = t;
847
+ decorations: (o) => {
848
+ const { doc: r, selection: s } = o;
909
849
  if (!n.isEditable || !s.empty || s.$from.parent.type.spec.code)
910
850
  return;
911
851
  const i = [];
912
- t.doc.content.size === 6 && i.push(
852
+ o.doc.content.size === 6 && i.push(
913
853
  A.node(2, 4, {
914
854
  "data-is-only-empty-block": "true"
915
855
  })
@@ -930,7 +870,7 @@ const go = k(
930
870
  ]
931
871
  };
932
872
  }
933
- ), oe = new P("previous-blocks"), Lt = {
873
+ ), ne = new P("previous-blocks"), Dt = {
934
874
  // Numbered List Items
935
875
  index: "index",
936
876
  // Headings
@@ -945,14 +885,14 @@ const go = k(
945
885
  key: "previousBlockType",
946
886
  prosemirrorPlugins: [
947
887
  new T({
948
- key: oe,
888
+ key: ne,
949
889
  view(e) {
950
890
  return {
951
- update: async (o, t) => {
891
+ update: async (t, o) => {
952
892
  var r;
953
- ((r = this.key) == null ? void 0 : r.getState(o.state).updatedBlocks.size) > 0 && (n = setTimeout(() => {
954
- o.dispatch(
955
- o.state.tr.setMeta(oe, { clearUpdate: !0 })
893
+ ((r = this.key) == null ? void 0 : r.getState(t.state).updatedBlocks.size) > 0 && (n = setTimeout(() => {
894
+ t.dispatch(
895
+ t.state.tr.setMeta(ne, { clearUpdate: !0 })
956
896
  );
957
897
  }, 0));
958
898
  },
@@ -972,55 +912,55 @@ const go = k(
972
912
  updatedBlocks: /* @__PURE__ */ new Set()
973
913
  };
974
914
  },
975
- apply(e, o, t, r) {
976
- if (o.currentTransactionOldBlockAttrs = {}, o.updatedBlocks.clear(), !e.docChanged || t.doc.eq(r.doc))
977
- return o;
978
- const s = {}, i = X(
979
- t.doc,
915
+ apply(e, t, o, r) {
916
+ if (t.currentTransactionOldBlockAttrs = {}, t.updatedBlocks.clear(), !e.docChanged || o.doc.eq(r.doc))
917
+ return t;
918
+ const s = {}, i = j(
919
+ o.doc,
980
920
  (l) => l.attrs.id
981
921
  ), a = new Map(
982
922
  i.map((l) => [l.node.attrs.id, l])
983
- ), c = X(
923
+ ), c = j(
984
924
  r.doc,
985
925
  (l) => l.attrs.id
986
926
  );
987
927
  for (const l of c) {
988
- const m = a.get(l.node.attrs.id), h = m == null ? void 0 : m.node.firstChild, f = l.node.firstChild;
989
- if (m && h && f) {
990
- const u = {
991
- index: f.attrs.index,
992
- level: f.attrs.level,
993
- type: f.type.name,
928
+ const u = a.get(l.node.attrs.id), h = u == null ? void 0 : u.node.firstChild, g = l.node.firstChild;
929
+ if (u && h && g) {
930
+ const m = {
931
+ index: g.attrs.index,
932
+ level: g.attrs.level,
933
+ type: g.type.name,
994
934
  depth: r.doc.resolve(l.pos).depth
995
- }, g = {
935
+ }, p = {
996
936
  index: h.attrs.index,
997
937
  level: h.attrs.level,
998
938
  type: h.type.name,
999
- depth: t.doc.resolve(m.pos).depth
939
+ depth: o.doc.resolve(u.pos).depth
1000
940
  };
1001
- s[l.node.attrs.id] = g, o.currentTransactionOldBlockAttrs[l.node.attrs.id] = g, JSON.stringify(g) !== JSON.stringify(u) && (g["depth-change"] = g.depth - u.depth, o.updatedBlocks.add(l.node.attrs.id));
941
+ s[l.node.attrs.id] = p, t.currentTransactionOldBlockAttrs[l.node.attrs.id] = p, JSON.stringify(p) !== JSON.stringify(m) && (p["depth-change"] = p.depth - m.depth, t.updatedBlocks.add(l.node.attrs.id));
1002
942
  }
1003
943
  }
1004
- return o.prevTransactionOldBlockAttrs = s, o;
944
+ return t.prevTransactionOldBlockAttrs = s, t;
1005
945
  }
1006
946
  },
1007
947
  props: {
1008
948
  decorations(e) {
1009
- const o = this.getState(e);
1010
- if (o.updatedBlocks.size === 0)
949
+ const t = this.getState(e);
950
+ if (t.updatedBlocks.size === 0)
1011
951
  return;
1012
- const t = [];
952
+ const o = [];
1013
953
  return e.doc.descendants((r, s) => {
1014
- if (!r.attrs.id || !o.updatedBlocks.has(r.attrs.id))
954
+ if (!r.attrs.id || !t.updatedBlocks.has(r.attrs.id))
1015
955
  return;
1016
- const i = o.currentTransactionOldBlockAttrs[r.attrs.id], a = {};
1017
- for (const [l, m] of Object.entries(i))
1018
- a["data-prev-" + Lt[l]] = m || "none";
956
+ const i = t.currentTransactionOldBlockAttrs[r.attrs.id], a = {};
957
+ for (const [l, u] of Object.entries(i))
958
+ a["data-prev-" + Dt[l]] = u || "none";
1019
959
  const c = A.node(s, s + r.nodeSize, {
1020
960
  ...a
1021
961
  });
1022
- t.push(c);
1023
- }), V.create(e.doc, t);
962
+ o.push(c);
963
+ }), V.create(e.doc, o);
1024
964
  }
1025
965
  }
1026
966
  })
@@ -1028,110 +968,174 @@ const go = k(
1028
968
  };
1029
969
  });
1030
970
  function Se(n, e) {
1031
- var o, t;
1032
- for (; n && n.parentElement && n.parentElement !== e.dom && ((o = n.getAttribute) == null ? void 0 : o.call(n, "data-node-type")) !== "blockContainer"; )
971
+ var t, o;
972
+ for (; n && n.parentElement && n.parentElement !== e.dom && ((t = n.getAttribute) == null ? void 0 : t.call(n, "data-node-type")) !== "blockContainer"; )
1033
973
  n = n.parentElement;
1034
- if (((t = n.getAttribute) == null ? void 0 : t.call(n, "data-node-type")) === "blockContainer")
974
+ if (((o = n.getAttribute) == null ? void 0 : o.call(n, "data-node-type")) === "blockContainer")
1035
975
  return { node: n, id: n.getAttribute("data-id") };
1036
976
  }
1037
- class B extends L {
1038
- constructor(o, t) {
1039
- super(o, t);
977
+ function At() {
978
+ const n = (e) => {
979
+ let t = e.children.length;
980
+ for (let o = 0; o < t; o++) {
981
+ const r = e.children[o];
982
+ if (r.type === "element" && (n(r), r.tagName === "u"))
983
+ if (r.children.length > 0) {
984
+ e.children.splice(o, 1, ...r.children);
985
+ const s = r.children.length - 1;
986
+ t += s, o += s;
987
+ } else
988
+ e.children.splice(o, 1), t--, o--;
989
+ }
990
+ };
991
+ return n;
992
+ }
993
+ function Mt() {
994
+ const n = (e) => {
995
+ var t;
996
+ if (e.children && "length" in e.children && e.children.length)
997
+ for (let o = e.children.length - 1; o >= 0; o--) {
998
+ const r = e.children[o], s = o + 1 < e.children.length ? e.children[o + 1] : void 0;
999
+ r.type === "element" && r.tagName === "input" && ((t = r.properties) == null ? void 0 : t.type) === "checkbox" && (s == null ? void 0 : s.type) === "element" && s.tagName === "p" ? (s.tagName = "span", s.children.splice(
1000
+ 0,
1001
+ 0,
1002
+ lt(document.createTextNode(" "))
1003
+ )) : n(r);
1004
+ }
1005
+ };
1006
+ return n;
1007
+ }
1008
+ function Nt() {
1009
+ return (n) => {
1010
+ ct(n, "element", (e, t, o) => {
1011
+ var r, s, i, a;
1012
+ if (o && e.tagName === "video") {
1013
+ const c = ((r = e.properties) == null ? void 0 : r.src) || ((s = e.properties) == null ? void 0 : s["data-url"]) || "", l = ((i = e.properties) == null ? void 0 : i.title) || ((a = e.properties) == null ? void 0 : a["data-name"]) || "";
1014
+ o.children[t] = {
1015
+ type: "text",
1016
+ value: `![${l}](${c})`
1017
+ };
1018
+ }
1019
+ });
1020
+ };
1021
+ }
1022
+ function xe(n) {
1023
+ return at().use(nt, { fragment: !0 }).use(Nt).use(At).use(Mt).use(rt).use(st).use(it, {
1024
+ handlers: { text: (t) => t.value }
1025
+ }).processSync(n).value;
1026
+ }
1027
+ function Bo(n, e, t, o) {
1028
+ const s = ke(e, t).exportBlocks(n, o);
1029
+ return xe(s);
1030
+ }
1031
+ function Rt(n) {
1032
+ const e = [];
1033
+ return n.descendants((t) => {
1034
+ var r, s;
1035
+ const o = R(t);
1036
+ return t.type.name === "blockContainer" && ((r = t.firstChild) == null ? void 0 : r.type.name) === "blockGroup" ? !0 : t.type.name === "columnList" && t.childCount === 1 ? ((s = t.firstChild) == null || s.forEach((i) => {
1037
+ e.push(L(i, o));
1038
+ }), !1) : t.type.isInGroup("bnBlock") ? (e.push(L(t, o)), !1) : !0;
1039
+ }), e;
1040
+ }
1041
+ class B extends N {
1042
+ constructor(t, o) {
1043
+ super(t, o);
1040
1044
  b(this, "nodes");
1041
- const r = o.node();
1042
- this.nodes = [], o.doc.nodesBetween(o.pos, t.pos, (s, i, a) => {
1045
+ const r = t.node();
1046
+ this.nodes = [], t.doc.nodesBetween(t.pos, o.pos, (s, i, a) => {
1043
1047
  if (a !== null && a.eq(r))
1044
1048
  return this.nodes.push(s), !1;
1045
1049
  });
1046
1050
  }
1047
- static create(o, t, r = t) {
1048
- return new B(o.resolve(t), o.resolve(r));
1051
+ static create(t, o, r = o) {
1052
+ return new B(t.resolve(o), t.resolve(r));
1049
1053
  }
1050
1054
  content() {
1051
- return new tt(ge.from(this.nodes), 0, 0);
1055
+ return new ot(we.from(this.nodes), 0, 0);
1052
1056
  }
1053
- eq(o) {
1054
- if (!(o instanceof B) || this.nodes.length !== o.nodes.length || this.from !== o.from || this.to !== o.to)
1057
+ eq(t) {
1058
+ if (!(t instanceof B) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to)
1055
1059
  return !1;
1056
- for (let t = 0; t < this.nodes.length; t++)
1057
- if (!this.nodes[t].eq(o.nodes[t]))
1060
+ for (let o = 0; o < this.nodes.length; o++)
1061
+ if (!this.nodes[o].eq(t.nodes[o]))
1058
1062
  return !1;
1059
1063
  return !0;
1060
1064
  }
1061
- map(o, t) {
1062
- const r = t.mapResult(this.from), s = t.mapResult(this.to);
1063
- return s.deleted ? L.near(o.resolve(r.pos)) : r.deleted ? L.near(o.resolve(s.pos)) : new B(
1064
- o.resolve(r.pos),
1065
- o.resolve(s.pos)
1065
+ map(t, o) {
1066
+ const r = o.mapResult(this.from), s = o.mapResult(this.to);
1067
+ return s.deleted ? N.near(t.resolve(r.pos)) : r.deleted ? N.near(t.resolve(s.pos)) : new B(
1068
+ t.resolve(r.pos),
1069
+ t.resolve(s.pos)
1066
1070
  );
1067
1071
  }
1068
1072
  toJSON() {
1069
1073
  return { type: "multiple-node", anchor: this.anchor, head: this.head };
1070
1074
  }
1071
1075
  }
1072
- L.jsonID("multiple-node", B);
1076
+ N.jsonID("multiple-node", B);
1073
1077
  let x;
1074
- function Nt(n, e) {
1075
- let o, t;
1078
+ function Lt(n, e) {
1079
+ let t, o;
1076
1080
  const r = e.resolve(n.from).node().type.spec.group === "blockContent", s = e.resolve(n.to).node().type.spec.group === "blockContent", i = Math.min(n.$anchor.depth, n.$head.depth);
1077
1081
  if (r && s) {
1078
1082
  const a = n.$from.start(i - 1), c = n.$to.end(i - 1);
1079
- o = e.resolve(a - 1).pos, t = e.resolve(c + 1).pos;
1083
+ t = e.resolve(a - 1).pos, o = e.resolve(c + 1).pos;
1080
1084
  } else
1081
- o = n.from, t = n.to;
1082
- return { from: o, to: t };
1085
+ t = n.from, o = n.to;
1086
+ return { from: t, to: o };
1083
1087
  }
1084
- function ne(n, e, o = e) {
1085
- e === o && (o += n.state.doc.resolve(e + 1).node().nodeSize);
1086
- const t = n.domAtPos(e).node.cloneNode(!0), r = n.domAtPos(e).node, s = (h, f) => Array.prototype.indexOf.call(h.children, f), i = s(
1088
+ function re(n, e, t = e) {
1089
+ e === t && (t += n.state.doc.resolve(e + 1).node().nodeSize);
1090
+ const o = n.domAtPos(e).node.cloneNode(!0), r = n.domAtPos(e).node, s = (h, g) => Array.prototype.indexOf.call(h.children, g), i = s(
1087
1091
  r,
1088
1092
  // Expects from position to be just before the first selected block.
1089
1093
  n.domAtPos(e + 1).node.parentElement
1090
1094
  ), a = s(
1091
1095
  r,
1092
1096
  // Expects to position to be just after the last selected block.
1093
- n.domAtPos(o - 1).node.parentElement
1097
+ n.domAtPos(t - 1).node.parentElement
1094
1098
  );
1095
1099
  for (let h = r.childElementCount - 1; h >= 0; h--)
1096
- (h > a || h < i) && t.removeChild(t.children[h]);
1097
- xe(n.root), x = t;
1100
+ (h > a || h < i) && o.removeChild(o.children[h]);
1101
+ Ee(n.root), x = o;
1098
1102
  const c = x.getElementsByTagName("iframe");
1099
1103
  for (let h = 0; h < c.length; h++) {
1100
- const f = c[h], u = f.parentElement;
1101
- u && u.removeChild(f);
1104
+ const g = c[h], m = g.parentElement;
1105
+ m && m.removeChild(g);
1102
1106
  }
1103
- const m = n.dom.className.split(" ").filter(
1107
+ const u = n.dom.className.split(" ").filter(
1104
1108
  (h) => h !== "ProseMirror" && h !== "bn-root" && h !== "bn-editor"
1105
1109
  ).join(" ");
1106
- x.className = x.className + " bn-drag-preview " + m, n.root instanceof ShadowRoot ? n.root.appendChild(x) : n.root.body.appendChild(x);
1110
+ x.className = x.className + " bn-drag-preview " + u, n.root instanceof ShadowRoot ? n.root.appendChild(x) : n.root.body.appendChild(x);
1107
1111
  }
1108
- function xe(n) {
1112
+ function Ee(n) {
1109
1113
  x !== void 0 && (n instanceof ShadowRoot ? n.removeChild(x) : n.body.removeChild(x), x = void 0);
1110
1114
  }
1111
- function Rt(n, e, o) {
1112
- if (!n.dataTransfer || o.headless)
1115
+ function Vt(n, e, t) {
1116
+ if (!n.dataTransfer || t.headless)
1113
1117
  return;
1114
- const t = o.prosemirrorView, r = he(e.id, t.state.doc);
1118
+ const o = t.prosemirrorView, r = me(e.id, o.state.doc);
1115
1119
  if (!r)
1116
1120
  throw new Error(`Block with ID ${e.id} not found`);
1117
1121
  const s = r.posBeforeNode;
1118
1122
  if (s != null) {
1119
- const i = t.state.selection, a = t.state.doc, { from: c, to: l } = Nt(i, a), m = c <= s && s < l, h = i.$anchor.node() !== i.$head.node() || i instanceof B;
1120
- m && h ? (t.dispatch(
1121
- t.state.tr.setSelection(B.create(a, c, l))
1122
- ), ne(t, c, l)) : (t.dispatch(
1123
- t.state.tr.setSelection(ae.create(t.state.doc, s))
1124
- ), ne(t, s));
1125
- const f = t.state.selection.content(), u = o.pmSchema, g = t.serializeForClipboard(f).dom.innerHTML, d = ve(u, o), p = Bt(f.content), w = d.exportBlocks(p, {}), y = ke(w);
1126
- n.dataTransfer.clearData(), n.dataTransfer.setData("blocknote/html", g), n.dataTransfer.setData("text/html", w), n.dataTransfer.setData("text/plain", y), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(x, 0, 0);
1123
+ const i = o.state.selection, a = o.state.doc, { from: c, to: l } = Lt(i, a), u = c <= s && s < l, h = i.$anchor.node() !== i.$head.node() || i instanceof B;
1124
+ u && h ? (o.dispatch(
1125
+ o.state.tr.setSelection(B.create(a, c, l))
1126
+ ), re(o, c, l)) : (o.dispatch(
1127
+ o.state.tr.setSelection(le.create(o.state.doc, s))
1128
+ ), re(o, s));
1129
+ const g = o.state.selection.content(), m = t.pmSchema, p = o.serializeForClipboard(g).dom.innerHTML, d = ke(m, t), f = Rt(g.content), w = d.exportBlocks(f, {}), y = xe(w);
1130
+ n.dataTransfer.clearData(), n.dataTransfer.setData("blocknote/html", p), n.dataTransfer.setData("text/html", w), n.dataTransfer.setData("text/plain", y), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(x, 0, 0);
1127
1131
  }
1128
1132
  }
1129
- const re = 250;
1130
- function U(n, e, o = !0) {
1131
- const t = n.root.elementsFromPoint(e.left, e.top);
1132
- for (const r of t)
1133
+ const se = 250;
1134
+ function U(n, e, t = !0) {
1135
+ const o = n.root.elementsFromPoint(e.left, e.top);
1136
+ for (const r of o)
1133
1137
  if (n.dom.contains(r))
1134
- return o && r.closest("[data-node-type=columnList]") ? U(
1138
+ return t && r.closest("[data-node-type=columnList]") ? U(
1135
1139
  n,
1136
1140
  {
1137
1141
  // TODO can we do better than this?
@@ -1142,17 +1146,17 @@ function U(n, e, o = !0) {
1142
1146
  !1
1143
1147
  ) : Se(r, n);
1144
1148
  }
1145
- function Vt(n, e) {
1149
+ function Ht(n, e) {
1146
1150
  if (!e.dom.firstChild)
1147
1151
  return;
1148
- const o = e.dom.firstChild.getBoundingClientRect(), t = {
1152
+ const t = e.dom.firstChild.getBoundingClientRect(), o = {
1149
1153
  // Clamps the x position to the editor's bounding box.
1150
1154
  left: Math.min(
1151
- Math.max(o.left + 10, n.x),
1152
- o.right - 10
1155
+ Math.max(t.left + 10, n.x),
1156
+ t.right - 10
1153
1157
  ),
1154
1158
  top: n.y
1155
- }, r = U(e, t);
1159
+ }, r = U(e, o);
1156
1160
  if (!r)
1157
1161
  return;
1158
1162
  const s = r.node.getBoundingClientRect();
@@ -1165,8 +1169,8 @@ function Vt(n, e) {
1165
1169
  !1
1166
1170
  );
1167
1171
  }
1168
- class Ht {
1169
- constructor(e, o, t) {
1172
+ class Ft {
1173
+ constructor(e, t, o) {
1170
1174
  b(this, "state");
1171
1175
  b(this, "emitUpdate");
1172
1176
  b(this, "mousePos");
@@ -1177,24 +1181,24 @@ class Ht {
1177
1181
  this.state = e, this.emitUpdate(this.state);
1178
1182
  });
1179
1183
  b(this, "updateStateFromMousePos", () => {
1180
- var t, r, s, i, a;
1184
+ var o, r, s, i, a;
1181
1185
  if (this.menuFrozen || !this.mousePos)
1182
1186
  return;
1183
1187
  const e = this.findClosestEditorElement({
1184
1188
  clientX: this.mousePos.x,
1185
1189
  clientY: this.mousePos.y
1186
1190
  });
1187
- if ((e == null ? void 0 : e.element) !== this.pmView.dom || e.distance > re) {
1188
- (t = this.state) != null && t.show && (this.state.show = !1, this.updateState(this.state));
1191
+ if ((e == null ? void 0 : e.element) !== this.pmView.dom || e.distance > se) {
1192
+ (o = this.state) != null && o.show && (this.state.show = !1, this.updateState(this.state));
1189
1193
  return;
1190
1194
  }
1191
- const o = Vt(this.mousePos, this.pmView);
1192
- if (!o || !this.editor.isEditable) {
1195
+ const t = Ht(this.mousePos, this.pmView);
1196
+ if (!t || !this.editor.isEditable) {
1193
1197
  (r = this.state) != null && r.show && (this.state.show = !1, this.updateState(this.state));
1194
1198
  return;
1195
1199
  }
1196
- if (!((s = this.state) != null && s.show && ((i = this.hoveredBlock) != null && i.hasAttribute("data-id")) && ((a = this.hoveredBlock) == null ? void 0 : a.getAttribute("data-id")) === o.id) && (this.hoveredBlock = o.node, this.editor.isEditable)) {
1197
- const c = o.node.getBoundingClientRect(), l = o.node.closest("[data-node-type=column]");
1200
+ if (!((s = this.state) != null && s.show && ((i = this.hoveredBlock) != null && i.hasAttribute("data-id")) && ((a = this.hoveredBlock) == null ? void 0 : a.getAttribute("data-id")) === t.id) && (this.hoveredBlock = t.node, this.editor.isEditable)) {
1201
+ const c = t.node.getBoundingClientRect(), l = t.node.closest("[data-node-type=column]");
1198
1202
  this.state = {
1199
1203
  show: !0,
1200
1204
  referencePos: new DOMRect(
@@ -1235,16 +1239,16 @@ class Ht {
1235
1239
  */
1236
1240
  b(this, "onDragStart", (e) => {
1237
1241
  var i;
1238
- const o = (i = e.dataTransfer) == null ? void 0 : i.getData("blocknote/html");
1239
- if (!o || this.pmView.dragging)
1242
+ const t = (i = e.dataTransfer) == null ? void 0 : i.getData("blocknote/html");
1243
+ if (!t || this.pmView.dragging)
1240
1244
  return;
1241
- const t = document.createElement("div");
1242
- t.innerHTML = o;
1243
- const s = Ze.fromSchema(this.pmView.state.schema).parse(t, {
1245
+ const o = document.createElement("div");
1246
+ o.innerHTML = t;
1247
+ const s = et.fromSchema(this.pmView.state.schema).parse(o, {
1244
1248
  topNode: this.pmView.state.schema.nodes.blockGroup.create()
1245
1249
  });
1246
1250
  this.pmView.dragging = {
1247
- slice: new et(s.content, 0, 0),
1251
+ slice: new tt(s.content, 0, 0),
1248
1252
  move: !0
1249
1253
  };
1250
1254
  });
@@ -1252,17 +1256,17 @@ class Ht {
1252
1256
  * Finds the closest editor visually to the given coordinates
1253
1257
  */
1254
1258
  b(this, "findClosestEditorElement", (e) => {
1255
- const o = Array.from(this.pmView.root.querySelectorAll(".bn-editor"));
1256
- if (o.length === 0)
1259
+ const t = Array.from(this.pmView.root.querySelectorAll(".bn-editor"));
1260
+ if (t.length === 0)
1257
1261
  return null;
1258
- let t = o[0], r = Number.MAX_VALUE;
1259
- return o.forEach((s) => {
1262
+ let o = t[0], r = Number.MAX_VALUE;
1263
+ return t.forEach((s) => {
1260
1264
  const i = s.querySelector(".bn-block-group").getBoundingClientRect(), a = e.clientX < i.left ? i.left - e.clientX : e.clientX > i.right ? e.clientX - i.right : 0, c = e.clientY < i.top ? i.top - e.clientY : e.clientY > i.bottom ? e.clientY - i.bottom : 0, l = Math.sqrt(
1261
1265
  Math.pow(a, 2) + Math.pow(c, 2)
1262
1266
  );
1263
- l < r && (r = l, t = s);
1267
+ l < r && (r = l, o = s);
1264
1268
  }), {
1265
- element: t,
1269
+ element: o,
1266
1270
  distance: r
1267
1271
  };
1268
1272
  });
@@ -1282,12 +1286,12 @@ class Ht {
1282
1286
  b(this, "onDragOver", (e) => {
1283
1287
  if (e.synthetic)
1284
1288
  return;
1285
- const o = this.getDragEventContext(e);
1286
- if (!o || !o.isDropPoint) {
1289
+ const t = this.getDragEventContext(e);
1290
+ if (!t || !t.isDropPoint) {
1287
1291
  this.closeDropCursor();
1288
1292
  return;
1289
1293
  }
1290
- o.isDropPoint && !o.isDropWithinEditorBounds && this.dispatchSyntheticEvent(e);
1294
+ t.isDropPoint && !t.isDropWithinEditorBounds && this.dispatchSyntheticEvent(e);
1291
1295
  });
1292
1296
  /**
1293
1297
  * Closes the drop-cursor for the current editor
@@ -1306,8 +1310,8 @@ class Ht {
1306
1310
  */
1307
1311
  b(this, "getDragEventContext", (e) => {
1308
1312
  var c;
1309
- const o = !((c = e.dataTransfer) != null && c.types.includes("blocknote/html")) && !!this.pmView.dragging, t = !!this.isDragOrigin, r = o || t, s = this.findClosestEditorElement(e);
1310
- if (!s || s.distance > re)
1313
+ const t = !((c = e.dataTransfer) != null && c.types.includes("blocknote/html")) && !!this.pmView.dragging, o = !!this.isDragOrigin, r = t || o, s = this.findClosestEditorElement(e);
1314
+ if (!s || s.distance > se)
1311
1315
  return;
1312
1316
  const i = s.element === this.pmView.dom, a = i && s.distance === 0;
1313
1317
  if (!(!i && !r))
@@ -1333,18 +1337,18 @@ class Ht {
1333
1337
  b(this, "onDrop", (e) => {
1334
1338
  if (e.synthetic)
1335
1339
  return;
1336
- const o = this.getDragEventContext(e);
1337
- if (!o) {
1340
+ const t = this.getDragEventContext(e);
1341
+ if (!t) {
1338
1342
  this.closeDropCursor();
1339
1343
  return;
1340
1344
  }
1341
- const { isDropPoint: t, isDropWithinEditorBounds: r, isDragOrigin: s } = o;
1342
- if (!r && t && this.dispatchSyntheticEvent(e), t) {
1345
+ const { isDropPoint: o, isDropWithinEditorBounds: r, isDragOrigin: s } = t;
1346
+ if (!r && o && this.dispatchSyntheticEvent(e), o) {
1343
1347
  if (this.pmView.dragging)
1344
1348
  return;
1345
1349
  this.pmView.dispatch(
1346
1350
  this.pmView.state.tr.setSelection(
1347
- je.create(
1351
+ qe.create(
1348
1352
  this.pmView.state.tr.doc,
1349
1353
  this.pmView.state.tr.selection.anchor
1350
1354
  )
@@ -1363,18 +1367,18 @@ class Ht {
1363
1367
  e.synthetic || (this.pmView.dragging = null);
1364
1368
  });
1365
1369
  b(this, "onKeyDown", (e) => {
1366
- var o;
1367
- (o = this.state) != null && o.show && this.editor.isFocused() && (this.state.show = !1, this.emitUpdate(this.state));
1370
+ var t;
1371
+ (t = this.state) != null && t.show && this.editor.isFocused() && (this.state.show = !1, this.emitUpdate(this.state));
1368
1372
  });
1369
1373
  b(this, "onMouseMove", (e) => {
1370
1374
  var s;
1371
1375
  if (this.menuFrozen)
1372
1376
  return;
1373
1377
  this.mousePos = { x: e.clientX, y: e.clientY };
1374
- const o = this.pmView.dom.getBoundingClientRect(), t = this.mousePos.x > o.left && this.mousePos.x < o.right && this.mousePos.y > o.top && this.mousePos.y < o.bottom, r = this.pmView.dom.parentElement;
1378
+ const t = this.pmView.dom.getBoundingClientRect(), o = this.mousePos.x > t.left && this.mousePos.x < t.right && this.mousePos.y > t.top && this.mousePos.y < t.bottom, r = this.pmView.dom.parentElement;
1375
1379
  if (
1376
1380
  // Cursor is within the editor area
1377
- t && // An element is hovered
1381
+ o && // An element is hovered
1378
1382
  e && e.target && // Element is outside the editor
1379
1383
  !(r === e.target || r.contains(e.target))
1380
1384
  ) {
@@ -1383,10 +1387,10 @@ class Ht {
1383
1387
  }
1384
1388
  this.updateStateFromMousePos();
1385
1389
  });
1386
- this.editor = e, this.pmView = o, this.emitUpdate = () => {
1390
+ this.editor = e, this.pmView = t, this.emitUpdate = () => {
1387
1391
  if (!this.state)
1388
1392
  throw new Error("Attempting to update uninitialized side menu");
1389
- t(this.state);
1393
+ o(this.state);
1390
1394
  }, this.pmView.root.addEventListener(
1391
1395
  "dragstart",
1392
1396
  this.onDragStart
@@ -1412,14 +1416,14 @@ class Ht {
1412
1416
  );
1413
1417
  }
1414
1418
  dispatchSyntheticEvent(e) {
1415
- const o = new Event(e.type, e), t = this.pmView.dom.firstChild.getBoundingClientRect();
1416
- o.clientX = e.clientX, o.clientY = e.clientY, o.clientX = Math.min(
1417
- Math.max(e.clientX, t.left),
1418
- t.left + t.width
1419
- ), o.clientY = Math.min(
1420
- Math.max(e.clientY, t.top),
1421
- t.top + t.height
1422
- ), o.dataTransfer = e.dataTransfer, o.preventDefault = () => e.preventDefault(), o.synthetic = !0, this.pmView.dom.dispatchEvent(o);
1419
+ const t = new Event(e.type, e), o = this.pmView.dom.firstChild.getBoundingClientRect();
1420
+ t.clientX = e.clientX, t.clientY = e.clientY, t.clientX = Math.min(
1421
+ Math.max(e.clientX, o.left),
1422
+ o.left + o.width
1423
+ ), t.clientY = Math.min(
1424
+ Math.max(e.clientY, o.top),
1425
+ o.top + o.height
1426
+ ), t.dataTransfer = e.dataTransfer, t.preventDefault = () => e.preventDefault(), t.synthetic = !0, this.pmView.dom.dispatchEvent(t);
1423
1427
  }
1424
1428
  // Needed in cases where the editor state updates without the mouse cursor
1425
1429
  // moving, as some state updates can require a side menu update. For example,
@@ -1428,9 +1432,9 @@ class Ht {
1428
1432
  // allowing the user to click the button again without moving the cursor. This
1429
1433
  // would otherwise not update the side menu, and so clicking the button again
1430
1434
  // would attempt to remove the same block again, causing an error.
1431
- update(e, o) {
1435
+ update(e, t) {
1432
1436
  var r;
1433
- !o.doc.eq(this.pmView.state.doc) && ((r = this.state) != null && r.show) && this.updateStateFromMousePos();
1437
+ !t.doc.eq(this.pmView.state.doc) && ((r = this.state) != null && r.show) && this.updateStateFromMousePos();
1434
1438
  }
1435
1439
  destroy() {
1436
1440
  var e;
@@ -1459,33 +1463,33 @@ class Ht {
1459
1463
  );
1460
1464
  }
1461
1465
  }
1462
- const Ft = new me("SideMenuPlugin"), Bo = k(({ editor: n }) => {
1466
+ const $t = new pe("SideMenuPlugin"), To = k(({ editor: n }) => {
1463
1467
  let e;
1464
- const o = H(
1468
+ const t = H(
1465
1469
  void 0
1466
1470
  );
1467
1471
  return {
1468
1472
  key: "sideMenu",
1469
- store: o,
1473
+ store: t,
1470
1474
  prosemirrorPlugins: [
1471
- new pe({
1472
- key: Ft,
1473
- view: (t) => (e = new Ht(n, t, (r) => {
1474
- o.setState({ ...r });
1475
+ new fe({
1476
+ key: $t,
1477
+ view: (o) => (e = new Ft(n, o, (r) => {
1478
+ t.setState({ ...r });
1475
1479
  }), e)
1476
1480
  })
1477
1481
  ],
1478
1482
  /**
1479
1483
  * Handles drag & drop events for blocks.
1480
1484
  */
1481
- blockDragStart(t, r) {
1482
- e && (e.isDragOrigin = !0), Rt(t, r, n);
1485
+ blockDragStart(o, r) {
1486
+ e && (e.isDragOrigin = !0), Vt(o, r, n);
1483
1487
  },
1484
1488
  /**
1485
1489
  * Handles drag & drop events for blocks.
1486
1490
  */
1487
1491
  blockDragEnd() {
1488
- xe(n.prosemirrorView.root), e && (e.isDragOrigin = !1), n.blur();
1492
+ Ee(n.prosemirrorView.root), e && (e.isDragOrigin = !1), n.blur();
1489
1493
  },
1490
1494
  /**
1491
1495
  * Freezes the side menu. When frozen, the side menu will stay
@@ -1506,24 +1510,24 @@ const Ft = new me("SideMenuPlugin"), Bo = k(({ editor: n }) => {
1506
1510
  };
1507
1511
  });
1508
1512
  let C;
1509
- function se(n) {
1513
+ function ie(n) {
1510
1514
  C || (C = document.createElement("div"), C.innerHTML = "_", C.style.opacity = "0", C.style.height = "1px", C.style.width = "1px", n instanceof Document ? n.body.appendChild(C) : n.appendChild(C));
1511
1515
  }
1512
- function $t(n) {
1516
+ function Ut(n) {
1513
1517
  C && (n instanceof Document ? n.body.removeChild(C) : n.removeChild(C), C = void 0);
1514
1518
  }
1515
1519
  function M(n) {
1516
1520
  return Array.prototype.indexOf.call(n.parentElement.childNodes, n);
1517
1521
  }
1518
- function Ut(n) {
1522
+ function _t(n) {
1519
1523
  let e = n;
1520
1524
  for (; e && e.nodeName !== "TD" && e.nodeName !== "TH" && !e.classList.contains("tableWrapper"); ) {
1521
1525
  if (e.classList.contains("ProseMirror"))
1522
1526
  return;
1523
- const o = e.parentNode;
1524
- if (!o || !(o instanceof Element))
1527
+ const t = e.parentNode;
1528
+ if (!t || !(t instanceof Element))
1525
1529
  return;
1526
- e = o;
1530
+ e = t;
1527
1531
  }
1528
1532
  return e.nodeName === "TD" || e.nodeName === "TH" ? {
1529
1533
  type: "cell",
@@ -1535,13 +1539,13 @@ function Ut(n) {
1535
1539
  tbodyNode: e.querySelector("tbody")
1536
1540
  };
1537
1541
  }
1538
- function _t(n, e) {
1539
- const o = e.querySelectorAll(n);
1540
- for (let t = 0; t < o.length; t++)
1541
- o[t].style.visibility = "hidden";
1542
+ function zt(n, e) {
1543
+ const t = e.querySelectorAll(n);
1544
+ for (let o = 0; o < t.length; o++)
1545
+ t[o].style.visibility = "hidden";
1542
1546
  }
1543
- class zt {
1544
- constructor(e, o, t) {
1547
+ class Kt {
1548
+ constructor(e, t, o) {
1545
1549
  b(this, "state");
1546
1550
  b(this, "emitUpdate");
1547
1551
  b(this, "tableId");
@@ -1557,69 +1561,69 @@ class zt {
1557
1561
  this.mouseState = "up", this.mouseMoveHandler(e);
1558
1562
  });
1559
1563
  b(this, "mouseMoveHandler", (e) => {
1560
- var l, m, h, f, u, g, d;
1564
+ var l, u, h, g, m, p, d;
1561
1565
  if (this.menuFrozen || this.mouseState === "selecting" || !(e.target instanceof Element) || !this.pmView.dom.contains(e.target))
1562
1566
  return;
1563
- const o = Ut(e.target);
1564
- if ((o == null ? void 0 : o.type) === "cell" && this.mouseState === "down" && !((l = this.state) != null && l.draggingState)) {
1565
- this.mouseState = "selecting", (m = this.state) != null && m.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
1567
+ const t = _t(e.target);
1568
+ if ((t == null ? void 0 : t.type) === "cell" && this.mouseState === "down" && !((l = this.state) != null && l.draggingState)) {
1569
+ this.mouseState = "selecting", (u = this.state) != null && u.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
1566
1570
  return;
1567
1571
  }
1568
- if (!o || !this.editor.isEditable) {
1572
+ if (!t || !this.editor.isEditable) {
1569
1573
  (h = this.state) != null && h.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
1570
1574
  return;
1571
1575
  }
1572
- if (!o.tbodyNode)
1576
+ if (!t.tbodyNode)
1573
1577
  return;
1574
- const t = o.tbodyNode.getBoundingClientRect(), r = Se(o.domNode, this.pmView);
1578
+ const o = t.tbodyNode.getBoundingClientRect(), r = Se(t.domNode, this.pmView);
1575
1579
  if (!r)
1576
1580
  return;
1577
1581
  this.tableElement = r.node;
1578
1582
  let s;
1579
1583
  const i = this.editor.transact(
1580
- (p) => he(r.id, p.doc)
1584
+ (f) => me(r.id, f.doc)
1581
1585
  );
1582
1586
  if (!i)
1583
1587
  throw new Error(`Block with ID ${r.id} not found`);
1584
- const a = R(
1588
+ const a = L(
1585
1589
  i.node,
1586
1590
  this.editor.pmSchema,
1587
1591
  this.editor.schema.blockSchema,
1588
1592
  this.editor.schema.inlineContentSchema,
1589
1593
  this.editor.schema.styleSchema
1590
1594
  );
1591
- if ($e(this.editor, "table") && (this.tablePos = i.posBeforeNode + 1, s = a), !s)
1595
+ if (Ue(this.editor, "table") && (this.tablePos = i.posBeforeNode + 1, s = a), !s)
1592
1596
  return;
1593
1597
  this.tableId = r.id;
1594
- const c = (f = o.domNode.closest(".tableWrapper")) == null ? void 0 : f.querySelector(".table-widgets-container");
1595
- if ((o == null ? void 0 : o.type) === "wrapper") {
1596
- const p = e.clientY >= t.bottom - 1 && // -1 to account for fractions of pixels in "bottom"
1597
- e.clientY < t.bottom + 20, w = e.clientX >= t.right - 1 && e.clientX < t.right + 20, y = e.clientX > t.right || e.clientY > t.bottom;
1598
+ const c = (g = t.domNode.closest(".tableWrapper")) == null ? void 0 : g.querySelector(".table-widgets-container");
1599
+ if ((t == null ? void 0 : t.type) === "wrapper") {
1600
+ const f = e.clientY >= o.bottom - 1 && // -1 to account for fractions of pixels in "bottom"
1601
+ e.clientY < o.bottom + 20, w = e.clientX >= o.right - 1 && e.clientX < o.right + 20, y = e.clientX > o.right || e.clientY > o.bottom;
1598
1602
  this.state = {
1599
1603
  ...this.state,
1600
1604
  show: !0,
1601
- showAddOrRemoveRowsButton: p,
1605
+ showAddOrRemoveRowsButton: f,
1602
1606
  showAddOrRemoveColumnsButton: w,
1603
- referencePosTable: t,
1607
+ referencePosTable: o,
1604
1608
  block: s,
1605
1609
  widgetContainer: c,
1606
- colIndex: y || (u = this.state) == null ? void 0 : u.colIndex,
1607
- rowIndex: y || (g = this.state) == null ? void 0 : g.rowIndex,
1610
+ colIndex: y || (m = this.state) == null ? void 0 : m.colIndex,
1611
+ rowIndex: y || (p = this.state) == null ? void 0 : p.rowIndex,
1608
1612
  referencePosCell: y || (d = this.state) == null ? void 0 : d.referencePosCell
1609
1613
  };
1610
1614
  } else {
1611
- const p = M(o.domNode), w = M(o.domNode.parentElement), y = o.domNode.getBoundingClientRect();
1612
- if (this.state !== void 0 && this.state.show && this.tableId === r.id && this.state.rowIndex === w && this.state.colIndex === p)
1615
+ const f = M(t.domNode), w = M(t.domNode.parentElement), y = t.domNode.getBoundingClientRect();
1616
+ if (this.state !== void 0 && this.state.show && this.tableId === r.id && this.state.rowIndex === w && this.state.colIndex === f)
1613
1617
  return;
1614
1618
  this.state = {
1615
1619
  show: !0,
1616
- showAddOrRemoveColumnsButton: p === s.content.rows[0].cells.length - 1,
1620
+ showAddOrRemoveColumnsButton: f === s.content.rows[0].cells.length - 1,
1617
1621
  showAddOrRemoveRowsButton: w === s.content.rows.length - 1,
1618
- referencePosTable: t,
1622
+ referencePosTable: o,
1619
1623
  block: s,
1620
1624
  draggingState: void 0,
1621
1625
  referencePosCell: y,
1622
- colIndex: p,
1626
+ colIndex: f,
1623
1627
  rowIndex: w,
1624
1628
  widgetContainer: c
1625
1629
  };
@@ -1627,14 +1631,14 @@ class zt {
1627
1631
  return this.emitUpdate(), !1;
1628
1632
  });
1629
1633
  b(this, "dragOverHandler", (e) => {
1630
- var f;
1631
- if (((f = this.state) == null ? void 0 : f.draggingState) === void 0)
1634
+ var g;
1635
+ if (((g = this.state) == null ? void 0 : g.draggingState) === void 0)
1632
1636
  return;
1633
- e.preventDefault(), e.dataTransfer.dropEffect = "move", _t(
1637
+ e.preventDefault(), e.dataTransfer.dropEffect = "move", zt(
1634
1638
  ".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",
1635
1639
  this.pmView.root
1636
1640
  );
1637
- const o = {
1641
+ const t = {
1638
1642
  left: Math.min(
1639
1643
  Math.max(e.clientX, this.state.referencePosTable.left + 1),
1640
1644
  this.state.referencePosTable.right - 1
@@ -1643,17 +1647,17 @@ class zt {
1643
1647
  Math.max(e.clientY, this.state.referencePosTable.top + 1),
1644
1648
  this.state.referencePosTable.bottom - 1
1645
1649
  )
1646
- }, t = this.pmView.root.elementsFromPoint(o.left, o.top).filter(
1647
- (u) => u.tagName === "TD" || u.tagName === "TH"
1650
+ }, o = this.pmView.root.elementsFromPoint(t.left, t.top).filter(
1651
+ (m) => m.tagName === "TD" || m.tagName === "TH"
1648
1652
  );
1649
- if (t.length === 0)
1653
+ if (o.length === 0)
1650
1654
  return;
1651
- const r = t[0];
1655
+ const r = o[0];
1652
1656
  let s = !1;
1653
- const i = M(r.parentElement), a = M(r), c = this.state.draggingState.draggedCellOrientation === "row" ? this.state.rowIndex : this.state.colIndex, m = (this.state.draggingState.draggedCellOrientation === "row" ? i : a) !== c;
1657
+ const i = M(r.parentElement), a = M(r), c = this.state.draggingState.draggedCellOrientation === "row" ? this.state.rowIndex : this.state.colIndex, u = (this.state.draggingState.draggedCellOrientation === "row" ? i : a) !== c;
1654
1658
  (this.state.rowIndex !== i || this.state.colIndex !== a) && (this.state.rowIndex = i, this.state.colIndex = a, this.state.referencePosCell = r.getBoundingClientRect(), s = !0);
1655
- const h = this.state.draggingState.draggedCellOrientation === "row" ? o.top : o.left;
1656
- this.state.draggingState.mousePos !== h && (this.state.draggingState.mousePos = h, s = !0), s && this.emitUpdate(), m && this.editor.transact((u) => u.setMeta(D, !0));
1659
+ const h = this.state.draggingState.draggedCellOrientation === "row" ? t.top : t.left;
1660
+ this.state.draggingState.mousePos !== h && (this.state.draggingState.mousePos = h, s = !0), s && this.emitUpdate(), u && this.editor.transact((m) => m.setMeta(D, !0));
1657
1661
  });
1658
1662
  b(this, "dropHandler", (e) => {
1659
1663
  if (this.mouseState = "up", this.state === void 0 || this.state.draggingState === void 0)
@@ -1663,17 +1667,17 @@ class zt {
1663
1667
  "Attempted to drop table row or column, but no table block was hovered prior."
1664
1668
  );
1665
1669
  e.preventDefault();
1666
- const { draggingState: o, colIndex: t, rowIndex: r } = this.state, s = this.state.block.content.columnWidths;
1667
- if (o.draggedCellOrientation === "row") {
1668
- if (!ce(
1670
+ const { draggingState: t, colIndex: o, rowIndex: r } = this.state, s = this.state.block.content.columnWidths;
1671
+ if (t.draggedCellOrientation === "row") {
1672
+ if (!de(
1669
1673
  this.state.block,
1670
- o.originalIndex,
1674
+ t.originalIndex,
1671
1675
  r
1672
1676
  ))
1673
1677
  return !1;
1674
- const i = Le(
1678
+ const i = Re(
1675
1679
  this.state.block,
1676
- o.originalIndex,
1680
+ t.originalIndex,
1677
1681
  r
1678
1682
  );
1679
1683
  this.editor.updateBlock(this.state.block, {
@@ -1684,18 +1688,18 @@ class zt {
1684
1688
  }
1685
1689
  });
1686
1690
  } else {
1687
- if (!de(
1691
+ if (!ue(
1688
1692
  this.state.block,
1689
- o.originalIndex,
1690
- t
1693
+ t.originalIndex,
1694
+ o
1691
1695
  ))
1692
1696
  return !1;
1693
- const i = Ne(
1697
+ const i = Le(
1694
1698
  this.state.block,
1695
- o.originalIndex,
1696
- t
1697
- ), [a] = s.splice(o.originalIndex, 1);
1698
- s.splice(t, 0, a), this.editor.updateBlock(this.state.block, {
1699
+ t.originalIndex,
1700
+ o
1701
+ ), [a] = s.splice(t.originalIndex, 1);
1702
+ s.splice(o, 0, a), this.editor.updateBlock(this.state.block, {
1699
1703
  type: "table",
1700
1704
  content: {
1701
1705
  ...this.state.block.content,
@@ -1706,14 +1710,14 @@ class zt {
1706
1710
  }
1707
1711
  return this.editor.setTextCursorPosition(this.state.block.id), !0;
1708
1712
  });
1709
- this.editor = e, this.pmView = o, this.emitUpdate = () => {
1713
+ this.editor = e, this.pmView = t, this.emitUpdate = () => {
1710
1714
  if (!this.state)
1711
1715
  throw new Error("Attempting to update uninitialized image toolbar");
1712
- t(this.state);
1713
- }, o.dom.addEventListener("mousemove", this.mouseMoveHandler), o.dom.addEventListener("mousedown", this.viewMousedownHandler), window.addEventListener("mouseup", this.mouseUpHandler), o.root.addEventListener(
1716
+ o(this.state);
1717
+ }, t.dom.addEventListener("mousemove", this.mouseMoveHandler), t.dom.addEventListener("mousedown", this.viewMousedownHandler), window.addEventListener("mouseup", this.mouseUpHandler), t.root.addEventListener(
1714
1718
  "dragover",
1715
1719
  this.dragOverHandler
1716
- ), o.root.addEventListener(
1720
+ ), t.root.addEventListener(
1717
1721
  "drop",
1718
1722
  this.dropHandler
1719
1723
  );
@@ -1729,20 +1733,20 @@ class zt {
1729
1733
  this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate();
1730
1734
  return;
1731
1735
  }
1732
- const { height: e, width: o } = Re(
1736
+ const { height: e, width: t } = Ve(
1733
1737
  this.state.block
1734
1738
  );
1735
- this.state.rowIndex !== void 0 && this.state.colIndex !== void 0 && (this.state.rowIndex >= e && (this.state.rowIndex = e - 1), this.state.colIndex >= o && (this.state.colIndex = o - 1));
1736
- const t = this.tableElement.querySelector("tbody");
1737
- if (!t)
1739
+ this.state.rowIndex !== void 0 && this.state.colIndex !== void 0 && (this.state.rowIndex >= e && (this.state.rowIndex = e - 1), this.state.colIndex >= t && (this.state.colIndex = t - 1));
1740
+ const o = this.tableElement.querySelector("tbody");
1741
+ if (!o)
1738
1742
  throw new Error(
1739
1743
  "Table block does not contain a 'tbody' HTML element. This should never happen."
1740
1744
  );
1741
1745
  if (this.state.rowIndex !== void 0 && this.state.colIndex !== void 0) {
1742
- const i = t.children[this.state.rowIndex].children[this.state.colIndex];
1746
+ const i = o.children[this.state.rowIndex].children[this.state.colIndex];
1743
1747
  i ? this.state.referencePosCell = i.getBoundingClientRect() : (this.state.rowIndex = void 0, this.state.colIndex = void 0);
1744
1748
  }
1745
- this.state.referencePosTable = t.getBoundingClientRect(), this.emitUpdate();
1749
+ this.state.referencePosTable = o.getBoundingClientRect(), this.emitUpdate();
1746
1750
  }
1747
1751
  destroy() {
1748
1752
  this.pmView.dom.removeEventListener("mousemove", this.mouseMoveHandler), window.removeEventListener("mouseup", this.mouseUpHandler), this.pmView.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.pmView.root.removeEventListener(
@@ -1754,43 +1758,45 @@ class zt {
1754
1758
  );
1755
1759
  }
1756
1760
  }
1757
- const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
1761
+ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
1758
1762
  let e;
1759
- const o = H(void 0);
1763
+ const t = H(void 0);
1760
1764
  return {
1761
1765
  key: "tableHandles",
1762
- store: o,
1766
+ store: t,
1763
1767
  prosemirrorPlugins: [
1764
1768
  new T({
1765
1769
  key: D,
1766
- view: (t) => (e = new zt(n, t, (r) => {
1767
- o.setState({
1768
- ...r,
1769
- draggingState: r.draggingState ? { ...r.draggingState } : void 0
1770
- });
1770
+ view: (o) => (e = new Kt(n, o, (r) => {
1771
+ t.setState(
1772
+ r.block ? {
1773
+ ...r,
1774
+ draggingState: r.draggingState ? { ...r.draggingState } : void 0
1775
+ } : void 0
1776
+ );
1771
1777
  }), e),
1772
1778
  // We use decorations to render the drop cursor when dragging a table row
1773
1779
  // or column. The decorations are updated in the `dragOverHandler` method.
1774
1780
  props: {
1775
- decorations: (t) => {
1781
+ decorations: (o) => {
1776
1782
  if (e === void 0 || e.state === void 0 || e.state.draggingState === void 0 || e.tablePos === void 0)
1777
1783
  return;
1778
1784
  const r = e.state.draggingState.draggedCellOrientation === "row" ? e.state.rowIndex : e.state.colIndex;
1779
1785
  if (r === void 0)
1780
1786
  return;
1781
1787
  const s = [], { block: i, draggingState: a } = e.state, { originalIndex: c, draggedCellOrientation: l } = a;
1782
- if (r === c || !i || l === "row" && !ce(i, c, r) || l === "col" && !de(i, c, r))
1783
- return V.create(t.doc, s);
1784
- const m = t.doc.resolve(e.tablePos + 1);
1785
- return e.state.draggingState.draggedCellOrientation === "row" ? W(
1788
+ if (r === c || !i || l === "row" && !de(i, c, r) || l === "col" && !ue(i, c, r))
1789
+ return V.create(o.doc, s);
1790
+ const u = o.doc.resolve(e.tablePos + 1);
1791
+ return e.state.draggingState.draggedCellOrientation === "row" ? G(
1786
1792
  e.state.block,
1787
1793
  r
1788
- ).forEach(({ row: f, col: u }) => {
1789
- const g = t.doc.resolve(
1790
- m.posAtIndex(f) + 1
1791
- ), d = t.doc.resolve(
1792
- g.posAtIndex(u) + 1
1793
- ), p = d.node(), w = d.pos + (r > c ? p.nodeSize - 2 : 0);
1794
+ ).forEach(({ row: g, col: m }) => {
1795
+ const p = o.doc.resolve(
1796
+ u.posAtIndex(g) + 1
1797
+ ), d = o.doc.resolve(
1798
+ p.posAtIndex(m) + 1
1799
+ ), f = d.node(), w = d.pos + (r > c ? f.nodeSize - 2 : 0);
1794
1800
  s.push(
1795
1801
  // The widget is a small bar which spans the width of the cell.
1796
1802
  A.widget(w, () => {
@@ -1798,15 +1804,15 @@ const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
1798
1804
  return y.className = "bn-table-drop-cursor", y.style.left = "0", y.style.right = "0", r > c ? y.style.bottom = "-2px" : y.style.top = "-3px", y.style.height = "4px", y;
1799
1805
  })
1800
1806
  );
1801
- }) : q(
1807
+ }) : W(
1802
1808
  e.state.block,
1803
1809
  r
1804
- ).forEach(({ row: f, col: u }) => {
1805
- const g = t.doc.resolve(
1806
- m.posAtIndex(f) + 1
1807
- ), d = t.doc.resolve(
1808
- g.posAtIndex(u) + 1
1809
- ), p = d.node(), w = d.pos + (r > c ? p.nodeSize - 2 : 0);
1810
+ ).forEach(({ row: g, col: m }) => {
1811
+ const p = o.doc.resolve(
1812
+ u.posAtIndex(g) + 1
1813
+ ), d = o.doc.resolve(
1814
+ p.posAtIndex(m) + 1
1815
+ ), f = d.node(), w = d.pos + (r > c ? f.nodeSize - 2 : 0);
1810
1816
  s.push(
1811
1817
  // The widget is a small bar which spans the height of the cell.
1812
1818
  A.widget(w, () => {
@@ -1814,7 +1820,7 @@ const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
1814
1820
  return y.className = "bn-table-drop-cursor", y.style.top = "0", y.style.bottom = "0", r > c ? y.style.right = "-2px" : y.style.left = "-3px", y.style.width = "4px", y;
1815
1821
  })
1816
1822
  );
1817
- }), V.create(t.doc, s);
1823
+ }), V.create(o.doc, s);
1818
1824
  }
1819
1825
  }
1820
1826
  })
@@ -1823,7 +1829,7 @@ const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
1823
1829
  * Callback that should be set on the `dragStart` event for whichever element
1824
1830
  * is used as the column drag handle.
1825
1831
  */
1826
- colDragStart(t) {
1832
+ colDragStart(o) {
1827
1833
  if (e === void 0 || e.state === void 0 || e.state.colIndex === void 0)
1828
1834
  throw new Error(
1829
1835
  "Attempted to drag table column, but no table block was hovered prior."
@@ -1831,7 +1837,7 @@ const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
1831
1837
  e.state.draggingState = {
1832
1838
  draggedCellOrientation: "col",
1833
1839
  originalIndex: e.state.colIndex,
1834
- mousePos: t.clientX
1840
+ mousePos: o.clientX
1835
1841
  }, e.emitUpdate(), n.transact(
1836
1842
  (r) => r.setMeta(D, {
1837
1843
  draggedCellOrientation: e.state.draggingState.draggedCellOrientation,
@@ -1839,13 +1845,13 @@ const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
1839
1845
  newIndex: e.state.colIndex,
1840
1846
  tablePos: e.tablePos
1841
1847
  })
1842
- ), !n.headless && (se(n.prosemirrorView.root), t.dataTransfer.setDragImage(C, 0, 0), t.dataTransfer.effectAllowed = "move");
1848
+ ), !n.headless && (ie(n.prosemirrorView.root), o.dataTransfer.setDragImage(C, 0, 0), o.dataTransfer.effectAllowed = "move");
1843
1849
  },
1844
1850
  /**
1845
1851
  * Callback that should be set on the `dragStart` event for whichever element
1846
1852
  * is used as the row drag handle.
1847
1853
  */
1848
- rowDragStart(t) {
1854
+ rowDragStart(o) {
1849
1855
  if (e.state === void 0 || e.state.rowIndex === void 0)
1850
1856
  throw new Error(
1851
1857
  "Attempted to drag table row, but no table block was hovered prior."
@@ -1853,7 +1859,7 @@ const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
1853
1859
  e.state.draggingState = {
1854
1860
  draggedCellOrientation: "row",
1855
1861
  originalIndex: e.state.rowIndex,
1856
- mousePos: t.clientY
1862
+ mousePos: o.clientY
1857
1863
  }, e.emitUpdate(), n.transact(
1858
1864
  (r) => r.setMeta(D, {
1859
1865
  draggedCellOrientation: e.state.draggingState.draggedCellOrientation,
@@ -1861,7 +1867,7 @@ const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
1861
1867
  newIndex: e.state.rowIndex,
1862
1868
  tablePos: e.tablePos
1863
1869
  })
1864
- ), !n.headless && (se(n.prosemirrorView.root), t.dataTransfer.setDragImage(C, 0, 0), t.dataTransfer.effectAllowed = "copyMove");
1870
+ ), !n.headless && (ie(n.prosemirrorView.root), o.dataTransfer.setDragImage(C, 0, 0), o.dataTransfer.effectAllowed = "copyMove");
1865
1871
  },
1866
1872
  /**
1867
1873
  * Callback that should be set on the `dragEnd` event for both the element
@@ -1872,7 +1878,7 @@ const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
1872
1878
  throw new Error(
1873
1879
  "Attempted to drag table row, but no table block was hovered prior."
1874
1880
  );
1875
- e.state.draggingState = void 0, e.emitUpdate(), n.transact((t) => t.setMeta(D, null)), !n.headless && $t(n.prosemirrorView.root);
1881
+ e.state.draggingState = void 0, e.emitUpdate(), n.transact((o) => o.setMeta(D, null)), !n.headless && Ut(n.prosemirrorView.root);
1876
1882
  },
1877
1883
  /**
1878
1884
  * Freezes the drag handles. When frozen, they will stay attached to the same
@@ -1888,88 +1894,88 @@ const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
1888
1894
  unfreezeHandles() {
1889
1895
  e.menuFrozen = !1;
1890
1896
  },
1891
- getCellsAtRowHandle(t, r) {
1892
- return W(t, r);
1897
+ getCellsAtRowHandle(o, r) {
1898
+ return G(o, r);
1893
1899
  },
1894
1900
  /**
1895
1901
  * Get all the cells in a column of the table block.
1896
1902
  */
1897
- getCellsAtColumnHandle(t, r) {
1898
- return q(t, r);
1903
+ getCellsAtColumnHandle(o, r) {
1904
+ return W(o, r);
1899
1905
  },
1900
1906
  /**
1901
1907
  * Sets the selection to the given cell or a range of cells.
1902
1908
  * @returns The new state after the selection has been set.
1903
1909
  */
1904
- setCellSelection(t, r, s = r) {
1910
+ setCellSelection(o, r, s = r) {
1905
1911
  if (!e)
1906
1912
  throw new Error("Table handles view not initialized");
1907
- const i = t.doc.resolve(e.tablePos + 1), a = t.doc.resolve(
1913
+ const i = o.doc.resolve(e.tablePos + 1), a = o.doc.resolve(
1908
1914
  i.posAtIndex(r.row) + 1
1909
- ), c = t.doc.resolve(
1915
+ ), c = o.doc.resolve(
1910
1916
  // No need for +1, since CellSelection expects the position before the cell
1911
1917
  a.posAtIndex(r.col)
1912
- ), l = t.doc.resolve(
1918
+ ), l = o.doc.resolve(
1913
1919
  i.posAtIndex(s.row) + 1
1914
- ), m = t.doc.resolve(
1920
+ ), u = o.doc.resolve(
1915
1921
  // No need for +1, since CellSelection expects the position before the cell
1916
1922
  l.posAtIndex(s.col)
1917
- ), h = t.tr;
1923
+ ), h = o.tr;
1918
1924
  return h.setSelection(
1919
- new wt(c, m)
1920
- ), t.apply(h);
1925
+ new yt(c, u)
1926
+ ), o.apply(h);
1921
1927
  },
1922
1928
  /**
1923
1929
  * Adds a row or column to the table using prosemirror-table commands
1924
1930
  */
1925
- addRowOrColumn(t, r) {
1931
+ addRowOrColumn(o, r) {
1926
1932
  n.exec((s, i) => {
1927
1933
  const a = this.setCellSelection(
1928
1934
  s,
1929
- r.orientation === "row" ? { row: t, col: 0 } : { row: 0, col: t }
1935
+ r.orientation === "row" ? { row: o, col: 0 } : { row: 0, col: o }
1930
1936
  );
1931
- return r.orientation === "row" ? r.side === "above" ? mt(a, i) : pt(a, i) : r.side === "left" ? ft(a, i) : gt(a, i);
1937
+ return r.orientation === "row" ? r.side === "above" ? pt(a, i) : ft(a, i) : r.side === "left" ? gt(a, i) : wt(a, i);
1932
1938
  });
1933
1939
  },
1934
1940
  /**
1935
1941
  * Removes a row or column from the table using prosemirror-table commands
1936
1942
  */
1937
- removeRowOrColumn(t, r) {
1943
+ removeRowOrColumn(o, r) {
1938
1944
  return r === "row" ? n.exec((s, i) => {
1939
1945
  const a = this.setCellSelection(s, {
1940
- row: t,
1946
+ row: o,
1941
1947
  col: 0
1942
1948
  });
1943
- return ut(a, i);
1949
+ return ht(a, i);
1944
1950
  }) : n.exec((s, i) => {
1945
1951
  const a = this.setCellSelection(s, {
1946
1952
  row: 0,
1947
- col: t
1953
+ col: o
1948
1954
  });
1949
- return ht(a, i);
1955
+ return mt(a, i);
1950
1956
  });
1951
1957
  },
1952
1958
  /**
1953
1959
  * Merges the cells in the table block.
1954
1960
  */
1955
- mergeCells(t) {
1961
+ mergeCells(o) {
1956
1962
  return n.exec((r, s) => {
1957
- const i = t ? this.setCellSelection(
1963
+ const i = o ? this.setCellSelection(
1958
1964
  r,
1959
- t.relativeStartCell,
1960
- t.relativeEndCell
1965
+ o.relativeStartCell,
1966
+ o.relativeEndCell
1961
1967
  ) : r;
1962
- return dt(i, s);
1968
+ return ut(i, s);
1963
1969
  });
1964
1970
  },
1965
1971
  /**
1966
1972
  * Splits the cell in the table block.
1967
1973
  * If no cell is provided, the current cell selected will be split.
1968
1974
  */
1969
- splitCell(t) {
1975
+ splitCell(o) {
1970
1976
  return n.exec((r, s) => {
1971
- const i = t ? this.setCellSelection(r, t) : r;
1972
- return ct(i, s);
1977
+ const i = o ? this.setCellSelection(r, o) : r;
1978
+ return dt(i, s);
1973
1979
  });
1974
1980
  },
1975
1981
  /**
@@ -1977,36 +1983,36 @@ const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
1977
1983
  * @returns The start and end cells of the current cell selection.
1978
1984
  */
1979
1985
  getCellSelection() {
1980
- return n.transact((t) => {
1981
- const r = t.selection;
1986
+ return n.transact((o) => {
1987
+ const r = o.selection;
1982
1988
  let s = r.$from, i = r.$to;
1983
- if (J(r)) {
1989
+ if (Q(r)) {
1984
1990
  const { ranges: d } = r;
1985
- d.forEach((p) => {
1986
- s = p.$from.min(s ?? p.$from), i = p.$to.max(i ?? p.$to);
1991
+ d.forEach((f) => {
1992
+ s = f.$from.min(s ?? f.$from), i = f.$to.max(i ?? f.$to);
1987
1993
  });
1988
- } else if (s = t.doc.resolve(
1994
+ } else if (s = o.doc.resolve(
1989
1995
  r.$from.pos - r.$from.parentOffset - 1
1990
- ), i = t.doc.resolve(
1996
+ ), i = o.doc.resolve(
1991
1997
  r.$to.pos - r.$to.parentOffset - 1
1992
1998
  ), s.pos === 0 || i.pos === 0)
1993
1999
  return;
1994
- const a = t.doc.resolve(
2000
+ const a = o.doc.resolve(
1995
2001
  s.pos - s.parentOffset - 1
1996
- ), c = t.doc.resolve(i.pos - i.parentOffset - 1), l = t.doc.resolve(a.pos - a.parentOffset - 1), m = s.index(a.depth), h = a.index(l.depth), f = i.index(c.depth), u = c.index(l.depth), g = [];
1997
- for (let d = h; d <= u; d++)
1998
- for (let p = m; p <= f; p++)
1999
- g.push({ row: d, col: p });
2002
+ ), c = o.doc.resolve(i.pos - i.parentOffset - 1), l = o.doc.resolve(a.pos - a.parentOffset - 1), u = s.index(a.depth), h = a.index(l.depth), g = i.index(c.depth), m = c.index(l.depth), p = [];
2003
+ for (let d = h; d <= m; d++)
2004
+ for (let f = u; f <= g; f++)
2005
+ p.push({ row: d, col: f });
2000
2006
  return {
2001
2007
  from: {
2002
2008
  row: h,
2003
- col: m
2009
+ col: u
2004
2010
  },
2005
2011
  to: {
2006
- row: u,
2007
- col: f
2012
+ row: m,
2013
+ col: g
2008
2014
  },
2009
- cells: g
2015
+ cells: p
2010
2016
  };
2011
2017
  });
2012
2018
  },
@@ -2015,31 +2021,31 @@ const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
2015
2021
  *
2016
2022
  * Returns undefined when there is no cell selection, or the selection is not within a table.
2017
2023
  */
2018
- getMergeDirection(t) {
2024
+ getMergeDirection(o) {
2019
2025
  return n.transact((r) => {
2020
- const s = J(r.selection) ? r.selection : void 0;
2021
- if (!s || !t || // Only offer the merge button if there is more than one cell selected.
2026
+ const s = Q(r.selection) ? r.selection : void 0;
2027
+ if (!s || !o || // Only offer the merge button if there is more than one cell selected.
2022
2028
  s.ranges.length <= 1)
2023
2029
  return;
2024
2030
  const i = this.getCellSelection();
2025
2031
  if (i)
2026
- return Fe(i.from, i.to, t) ? "vertical" : "horizontal";
2032
+ return $e(i.from, i.to, o) ? "vertical" : "horizontal";
2027
2033
  });
2028
2034
  },
2029
- cropEmptyRowsOrColumns(t, r) {
2030
- return He(t, r);
2035
+ cropEmptyRowsOrColumns(o, r) {
2036
+ return Fe(o, r);
2031
2037
  },
2032
- addRowsOrColumns(t, r, s) {
2033
- return Ve(t, r, s);
2038
+ addRowsOrColumns(o, r, s) {
2039
+ return He(o, r, s);
2034
2040
  }
2035
2041
  };
2036
- }), ie = new P("trailingNode"), Po = k(() => ({
2042
+ }), ae = new P("trailingNode"), Oo = k(() => ({
2037
2043
  key: "trailingNode",
2038
2044
  prosemirrorPlugins: [
2039
2045
  new T({
2040
- key: ie,
2041
- appendTransaction: (n, e, o) => {
2042
- const { doc: t, tr: r, schema: s } = o, i = ie.getState(o), a = t.content.size - 2, c = s.nodes.blockContainer, l = s.nodes.paragraph;
2046
+ key: ae,
2047
+ appendTransaction: (n, e, t) => {
2048
+ const { doc: o, tr: r, schema: s } = t, i = ae.getState(t), a = o.content.size - 2, c = s.nodes.blockContainer, l = s.nodes.paragraph;
2043
2049
  if (i)
2044
2050
  return r.insert(
2045
2051
  a,
@@ -2052,15 +2058,15 @@ const D = new P("TableHandlesPlugin"), To = k(({ editor: n }) => {
2052
2058
  apply: (n, e) => {
2053
2059
  if (!n.docChanged)
2054
2060
  return e;
2055
- let o = n.doc.lastChild;
2056
- if (!o || o.type.name !== "blockGroup")
2061
+ let t = n.doc.lastChild;
2062
+ if (!t || t.type.name !== "blockGroup")
2057
2063
  throw new Error("Expected blockGroup");
2058
- if (o = o.lastChild, !o || o.type.name !== "blockContainer")
2064
+ if (t = t.lastChild, !t || t.type.name !== "blockContainer")
2059
2065
  return !0;
2060
- const t = o.firstChild;
2061
- if (!t)
2066
+ const o = t.firstChild;
2067
+ if (!o)
2062
2068
  throw new Error("Expected blockContent");
2063
- return o.nodeSize > 4 || t.type.spec.content !== "inline*";
2069
+ return t.nodeSize > 4 || o.type.spec.content !== "inline*";
2064
2070
  }
2065
2071
  }
2066
2072
  })
@@ -2075,24 +2081,24 @@ export {
2075
2081
  xo as N,
2076
2082
  Eo as P,
2077
2083
  wo as S,
2078
- zt as T,
2084
+ Kt as T,
2079
2085
  Co as V,
2080
- te as Y,
2086
+ oe as Y,
2081
2087
  F as a,
2082
2088
  $ as b,
2083
2089
  bo as c,
2084
2090
  So as d,
2085
2091
  Io as e,
2086
- Ht as f,
2087
- Bo as g,
2088
- To as h,
2089
- Po as i,
2090
- St as j,
2091
- ve as k,
2092
- po as l,
2093
- ke as m,
2094
- Bt as n,
2095
- Ft as s,
2092
+ Ft as f,
2093
+ To as g,
2094
+ Po as h,
2095
+ Oo as i,
2096
+ xt as j,
2097
+ ke as k,
2098
+ Bo as l,
2099
+ xe as m,
2100
+ Rt as n,
2101
+ $t as s,
2096
2102
  D as t
2097
2103
  };
2098
- //# sourceMappingURL=TrailingNode-CG2a-HDA.js.map
2104
+ //# sourceMappingURL=TrailingNode-C-Kyrtf1.js.map