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