@blocknote/core 0.52.0 → 0.53.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 (65) hide show
  1. package/dist/blocknote.cjs +1 -1
  2. package/dist/blocknote.js +6 -6
  3. package/dist/{blocks-CiuUGa1E.js → blocks-BEJW9OM_.js} +516 -476
  4. package/dist/blocks-BEJW9OM_.js.map +1 -0
  5. package/dist/blocks-BPmJglFo.cjs +12 -0
  6. package/dist/blocks-BPmJglFo.cjs.map +1 -0
  7. package/dist/blocks.cjs +1 -1
  8. package/dist/blocks.js +2 -2
  9. package/dist/extensions-AitWbYdJ.cjs +52 -0
  10. package/dist/extensions-AitWbYdJ.cjs.map +1 -0
  11. package/dist/{extensions-CrUGDOks.js → extensions-BR5hkAio.js} +421 -391
  12. package/dist/extensions-BR5hkAio.js.map +1 -0
  13. package/dist/extensions.cjs +1 -1
  14. package/dist/extensions.js +3 -3
  15. package/dist/src-BHPuOo7W.cjs +21 -0
  16. package/dist/src-BHPuOo7W.cjs.map +1 -0
  17. package/dist/{src-DTF83Cl9.js → src-BUXut68d.js} +797 -779
  18. package/dist/src-BUXut68d.js.map +1 -0
  19. package/dist/style.css +1 -1
  20. package/dist/webpack-stats.json +1 -1
  21. package/dist/y.cjs +1 -1
  22. package/dist/y.js +9 -9
  23. package/dist/yjs.cjs +1 -1
  24. package/dist/yjs.js +1 -1
  25. package/package.json +14 -14
  26. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +10 -1
  27. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +42 -8
  28. package/src/api/exporters/markdown/markdownExporter.ts +10 -1
  29. package/src/api/parsers/html/parseHTML.ts +43 -0
  30. package/src/blocks/Table/TableExtension.test.ts +102 -0
  31. package/src/blocks/ToggleWrapper/createToggleWrapper.ts +16 -5
  32. package/src/blocks/defaultBlockTypeGuards.ts +6 -0
  33. package/src/editor/Block.css +51 -1
  34. package/src/extensions/SideMenu/SideMenu.ts +20 -3
  35. package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +118 -0
  36. package/src/extensions/SuggestionMenu/SuggestionMenu.ts +40 -27
  37. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +13 -3
  38. package/src/extensions/TableHandles/TableHandles.ts +25 -12
  39. package/src/extensions/TrailingNode/TrailingNode.ts +98 -32
  40. package/src/index.ts +1 -0
  41. package/src/schema/blocks/createSpec.ts +16 -3
  42. package/src/schema/blocks/internal.test.ts +86 -0
  43. package/src/schema/blocks/internal.ts +64 -0
  44. package/src/schema/inlineContent/createSpec.ts +9 -1
  45. package/src/schema/nodeViewMutations.test.ts +121 -0
  46. package/src/schema/nodeViewMutations.ts +46 -0
  47. package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +13 -0
  48. package/types/src/blocks/defaultBlockTypeGuards.d.ts +2 -0
  49. package/types/src/extensions/SideMenu/SideMenu.d.ts +5 -0
  50. package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +6 -0
  51. package/types/src/extensions/TrailingNode/TrailingNode.d.ts +5 -4
  52. package/types/src/index.d.ts +1 -0
  53. package/types/src/schema/blocks/internal.d.ts +21 -0
  54. package/types/src/schema/blocks/internal.test.d.ts +1 -0
  55. package/types/src/schema/nodeViewMutations.d.ts +3 -0
  56. package/types/src/schema/nodeViewMutations.test.d.ts +1 -0
  57. package/dist/blocks-BqHv0xhc.cjs +0 -12
  58. package/dist/blocks-BqHv0xhc.cjs.map +0 -1
  59. package/dist/blocks-CiuUGa1E.js.map +0 -1
  60. package/dist/extensions-CrUGDOks.js.map +0 -1
  61. package/dist/extensions-Ghr9QqqR.cjs +0 -52
  62. package/dist/extensions-Ghr9QqqR.cjs.map +0 -1
  63. package/dist/src-DTF83Cl9.js.map +0 -1
  64. package/dist/src-OfbaVbMw.cjs +0 -21
  65. package/dist/src-OfbaVbMw.cjs.map +0 -1
@@ -1,39 +1,38 @@
1
- import { $n as e, At as t, Bt as n, Ft as r, Ht as i, In as a, It as o, Lt as s, Mt as c, Nt as l, Pt as u, Rt as d, Ut as f, Vt as p, _ as m, bn as h, g, kt as ee, r as te, yn as _, zt as v } from "./blocks-CiuUGa1E.js";
1
+ import { At as e, Bt as t, Ft as n, Ht as r, It as i, Lt as a, Nt as o, Pt as s, Rt as c, Sn as l, Ut as u, Vt as d, Wt as f, _ as p, g as m, jt as h, nr as g, r as ee, v as _, xn as v, zn as te, zt as ne } from "./blocks-BEJW9OM_.js";
2
2
  import { n as y, t as b } from "./BlockNoteExtension-B_IEJHS8.js";
3
- import { n as ne } from "./UserStore-QbbPFj0z.js";
4
- import { DOMSerializer as x, Fragment as S, Slice as re } from "prosemirror-model";
5
- import { Mapping as ie, dropPoint as ae } from "prosemirror-transform";
6
- import { combineTransactionSteps as oe, findChildrenInRange as se, posToDOMRect as ce } from "@tiptap/core";
7
- import { uuidv4 as le } from "lib0/random";
8
- import { NodeSelection as ue, Plugin as C, PluginKey as w, Selection as T, TextSelection as de } from "prosemirror-state";
9
- import { DOMParser as fe, Slice as pe } from "@tiptap/pm/model";
10
- import { CellSelection as me, addColumnAfter as he, addColumnBefore as ge, addRowAfter as _e, addRowBefore as ve, deleteColumn as ye, deleteRow as be, mergeCells as xe, splitCell as Se } from "prosemirror-tables";
11
- import { Plugin as Ce, PluginKey as we, TextSelection as Te } from "@tiptap/pm/state";
3
+ import { n as re } from "./UserStore-QbbPFj0z.js";
4
+ import { DOMSerializer as ie, Fragment as ae, Slice as oe } from "prosemirror-model";
5
+ import { Mapping as x, dropPoint as se } from "prosemirror-transform";
6
+ import { combineTransactionSteps as ce, findChildrenInRange as S, posToDOMRect as le } from "@tiptap/core";
7
+ import { uuidv4 as ue } from "lib0/random";
8
+ import { NodeSelection as de, Plugin as C, PluginKey as w, Selection as T, TextSelection as fe } from "prosemirror-state";
9
+ import { DOMParser as pe, Slice as me } from "@tiptap/pm/model";
10
+ import { CellSelection as he, addColumnAfter as ge, addColumnBefore as _e, addRowAfter as ve, addRowBefore as ye, deleteColumn as be, deleteRow as xe, mergeCells as Se, splitCell as Ce } from "prosemirror-tables";
11
+ import { Plugin as we, PluginKey as Te, TextSelection as Ee } from "@tiptap/pm/state";
12
12
  import { Decoration as E, DecorationSet as D } from "prosemirror-view";
13
- import Ee from "fast-deep-equal";
14
- import { history as De, redo as Oe, undo as ke } from "@tiptap/pm/history";
15
- //#region src/api/exporters/html/util/serializeBlocksExternalHTML.ts
16
- function Ae(e) {
13
+ import De from "fast-deep-equal";
14
+ import { history as Oe, redo as ke, undo as Ae } from "@tiptap/pm/history";
15
+ function je(e) {
17
16
  let t = Array.from(e.classList).filter((e) => !e.startsWith("bn-")) || [];
18
17
  t.length > 0 ? e.className = t.join(" ") : e.removeAttribute("class");
19
18
  }
20
- function O(e, t, n, r) {
19
+ function Me(e, t, n, r) {
21
20
  let i;
22
21
  if (!t) throw Error("blockContent is required");
23
- if (typeof t == "string") i = c([t], e.pmSchema, r?.blockType);
24
- else if (Array.isArray(t)) i = c(t, e.pmSchema, r?.blockType);
25
- else if (t.type === "tableContent") i = l(t, e.pmSchema);
26
- else throw new a(t.type);
27
- let o = (r?.document ?? document).createDocumentFragment();
22
+ if (typeof t == "string") i = o([t], e.pmSchema, r?.blockType);
23
+ else if (Array.isArray(t)) i = o(t, e.pmSchema, r?.blockType);
24
+ else if (t.type === "tableContent") i = s(t, e.pmSchema);
25
+ else throw new te(t.type);
26
+ let a = (r?.document ?? document).createDocumentFragment();
28
27
  for (let t of i) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
29
28
  let i = e.schema.inlineContentSpecs[t.type.name].implementation;
30
29
  if (i) {
31
- let a = h(t, e.schema.inlineContentSchema, e.schema.styleSchema), s = i.toExternalHTML ? i.toExternalHTML(a, e) : i.render.call({
30
+ let o = l(t, e.schema.inlineContentSchema, e.schema.styleSchema), s = i.toExternalHTML ? i.toExternalHTML(o, e) : i.render.call({
32
31
  renderType: "dom",
33
32
  props: void 0
34
- }, a, () => {}, e);
33
+ }, o, () => {}, e);
35
34
  if (s) {
36
- if (o.appendChild(s.dom), s.contentDOM) {
35
+ if (a.appendChild(s.dom), s.contentDOM) {
37
36
  let e = n.serializeFragment(t.content, r);
38
37
  s.contentDOM.dataset.editable = "", s.contentDOM.appendChild(e);
39
38
  }
@@ -46,17 +45,17 @@ function O(e, t, n, r) {
46
45
  let t = (e.schema.styleSpecs[r.type.name].implementation.toExternalHTML ?? e.schema.styleSpecs[r.type.name].implementation.render)(r.attrs.stringValue, e);
47
46
  t.contentDOM.appendChild(n), n = t.dom;
48
47
  } else {
49
- let e = r.type.spec.toDOM(r, !0), t = x.renderSpec(document, e);
48
+ let e = r.type.spec.toDOM(r, !0), t = ie.renderSpec(document, e);
50
49
  t.contentDOM.appendChild(n), n = t.dom;
51
50
  }
52
- o.appendChild(n);
51
+ a.appendChild(n);
53
52
  } else {
54
- let e = n.serializeFragment(S.from([t]), r);
55
- o.appendChild(e);
53
+ let e = n.serializeFragment(ae.from([t]), r);
54
+ a.appendChild(e);
56
55
  }
57
- return o.childNodes.length === 1 && o.firstChild?.nodeType === 1 && Ae(o.firstChild), o;
56
+ return a.childNodes.length === 1 && a.firstChild?.nodeType === 1 && je(a.firstChild), a;
58
57
  }
59
- function je(e, t, n, r, i, a, o, s) {
58
+ function Ne(e, t, n, r, i, a, o, s) {
60
59
  let c = s?.document ?? document, l = t.pmSchema.nodes.blockContainer, u = n.props || {};
61
60
  for (let [e, r] of Object.entries(t.schema.blockSchema[n.type].propSchema)) !(e in u) && r.default !== void 0 && (u[e] = r.default);
62
61
  let d = l.spec?.toDOM?.(l.create({
@@ -72,14 +71,18 @@ function je(e, t, n, r, i, a, o, s) {
72
71
  if (m.dom.classList.contains("bn-block-content")) {
73
72
  let e = [...f, ...Array.from(m.dom.attributes)].filter((e) => e.name.startsWith("data") && e.name !== "data-content-type" && e.name !== "data-file-block" && e.name !== "data-node-view-wrapper" && e.name !== "data-node-type" && e.name !== "data-id" && e.name !== "data-editable");
74
73
  for (let t of e) m.dom.firstChild.setAttribute(t.name, t.value);
75
- Ae(m.dom.firstChild), o > 0 && m.dom.firstChild.setAttribute("data-nesting-level", o.toString()), h.append(...Array.from(m.dom.childNodes));
74
+ je(m.dom.firstChild), o > 0 && m.dom.firstChild.setAttribute("data-nesting-level", o.toString()), h.append(...Array.from(m.dom.childNodes));
76
75
  } else h.append(m.dom), o > 0 && m.dom.setAttribute("data-nesting-level", o.toString());
77
- if (m.contentDOM && n.content) {
78
- let e = O(t, n.content, r, {
79
- ...s,
80
- blockType: n.type
81
- });
82
- m.contentDOM.appendChild(e);
76
+ if (m.contentDOM) {
77
+ if (n.content) {
78
+ let e = Me(t, n.content, r, {
79
+ ...s,
80
+ blockType: n.type
81
+ });
82
+ m.contentDOM.appendChild(e);
83
+ }
84
+ let e = t.pmSchema.nodes[n.type];
85
+ e?.inlineContent && !e.spec.code && m.contentDOM.childNodes.length === 0 && m.contentDOM.appendChild(c.createTextNode(""));
83
86
  }
84
87
  let g;
85
88
  if (i.has(n.type) ? g = "OL" : a.has(n.type) && (g = "UL"), g) {
@@ -91,20 +94,20 @@ function je(e, t, n, r, i, a, o, s) {
91
94
  } else e.append(h);
92
95
  if (n.children && n.children.length > 0) {
93
96
  let l = c.createDocumentFragment();
94
- if (Me(l, t, n.children, r, i, a, o + 1, s), e.lastChild?.nodeName === "UL" || e.lastChild?.nodeName === "OL") for (; l.firstChild?.nodeName === "UL" || l.firstChild?.nodeName === "OL";) e.lastChild.lastChild.appendChild(l.firstChild);
97
+ if (O(l, t, n.children, r, i, a, o + 1, s), e.lastChild?.nodeName === "UL" || e.lastChild?.nodeName === "OL") for (; l.firstChild?.nodeName === "UL" || l.firstChild?.nodeName === "OL";) e.lastChild.lastChild.appendChild(l.firstChild);
95
98
  "childrenDOM" in m && m.childrenDOM ? m.childrenDOM.append(l) : t.pmSchema.nodes[n.type].isInGroup("blockContent") ? e.append(l) : m.contentDOM?.append(l);
96
99
  }
97
100
  }
98
- var Me = (e, t, n, r, i, a, o = 0, s) => {
99
- for (let c of n) je(e, t, c, r, i, a, o, s);
100
- }, Ne = (e, t, n, r, i, a) => {
101
+ var O = (e, t, n, r, i, a, o = 0, s) => {
102
+ for (let c of n) Ne(e, t, c, r, i, a, o, s);
103
+ }, Pe = (e, t, n, r, i, a) => {
101
104
  let o = (a?.document ?? document).createDocumentFragment();
102
- return Me(o, e, t, n, r, i, 0, a), o;
105
+ return O(o, e, t, n, r, i, 0, a), o;
103
106
  }, k = (e, t) => {
104
- let n = x.fromSchema(e);
107
+ let n = ie.fromSchema(e);
105
108
  return {
106
109
  exportBlocks: (e, r) => {
107
- let i = Ne(t, e, n, new Set(["numberedListItem"]), new Set([
110
+ let i = Pe(t, e, n, new Set(["numberedListItem"]), new Set([
108
111
  "bulletListItem",
109
112
  "checkListItem",
110
113
  "toggleListItem"
@@ -112,38 +115,38 @@ var Me = (e, t, n, r, i, a, o = 0, s) => {
112
115
  return a.append(i), a.innerHTML;
113
116
  },
114
117
  exportInlineContent: (e, r) => {
115
- let i = O(t, e, n, r), a = document.createElement("div");
118
+ let i = Me(t, e, n, r), a = document.createElement("div");
116
119
  return a.append(i.cloneNode(!0)), a.innerHTML;
117
120
  }
118
121
  };
119
122
  };
120
123
  //#endregion
121
124
  //#region src/api/getBlocksChangedByTransaction.ts
122
- function Pe(n, r) {
123
- if (r === 0) return;
124
- let i = n.resolve(r);
125
- for (let r = i.depth; r > 0; r--) {
126
- let a = i.node(r);
127
- if (t(a)) return e(a, n);
125
+ function Fe(e, t) {
126
+ if (t === 0) return;
127
+ let n = e.resolve(t);
128
+ for (let t = n.depth; t > 0; t--) {
129
+ let r = n.node(t);
130
+ if (h(r)) return g(r, e);
128
131
  }
129
132
  }
130
- function Fe(e) {
133
+ function Ie(e) {
131
134
  return e.getMeta("paste") ? { type: "paste" } : e.getMeta("uiEvent") === "drop" ? { type: "drop" } : e.getMeta("history$") ? { type: e.getMeta("history$").redo ? "redo" : "undo" } : e.getMeta("y-sync$") ? e.getMeta("y-sync$").isUndoRedoOperation ? { type: "undo-redo" } : { type: "yjs-remote" } : { type: "local" };
132
135
  }
133
- function Ie(n) {
134
- let r = {}, i = {};
135
- return n.descendants((a, o) => {
136
- if (!t(a)) return !0;
137
- let s = Pe(n, o), c = s ?? "__root__";
138
- i[c] || (i[c] = []);
139
- let l = _(a, n), u = e(a, n);
140
- return r[u] = {
141
- block: l,
142
- parentId: s
143
- }, i[c].push(u), !0;
136
+ function A(e) {
137
+ let t = {}, n = {};
138
+ return e.descendants((r, i) => {
139
+ if (!h(r)) return !0;
140
+ let a = Fe(e, i), o = a ?? "__root__";
141
+ n[o] || (n[o] = []);
142
+ let s = v(r, e), c = g(r, e);
143
+ return t[c] = {
144
+ block: s,
145
+ parentId: a
146
+ }, n[o].push(c), !0;
144
147
  }), {
145
- byId: r,
146
- childrenByParent: i
148
+ byId: t,
149
+ childrenByParent: n
147
150
  };
148
151
  }
149
152
  function Le(e, t) {
@@ -171,7 +174,7 @@ function Le(e, t) {
171
174
  return n;
172
175
  }
173
176
  function Re(e, t = []) {
174
- let n = Fe(e), r = oe(e.before, [e, ...t]), i = Ie(r.before), a = Ie(r.doc), o = [], s = /* @__PURE__ */ new Set();
177
+ let n = Ie(e), r = ce(e.before, [e, ...t]), i = A(r.before), a = A(r.doc), o = [], s = /* @__PURE__ */ new Set();
175
178
  Object.keys(a.byId).filter((e) => !(e in i.byId)).forEach((e) => {
176
179
  o.push({
177
180
  type: "insert",
@@ -188,7 +191,7 @@ function Re(e, t = []) {
188
191
  }), s.add(e);
189
192
  }), Object.keys(a.byId).filter((e) => e in i.byId).forEach((e) => {
190
193
  let t = i.byId[e], r = a.byId[e];
191
- t.parentId === r.parentId ? Ee({
194
+ t.parentId === r.parentId ? De({
192
195
  ...t.block,
193
196
  children: void 0
194
197
  }, {
@@ -337,7 +340,7 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
337
340
  if (i && !d) {
338
341
  let t = i.pos;
339
342
  if (r.dragging && r.dragging.slice) {
340
- let e = ae(r.state.doc, t, r.dragging.slice);
343
+ let e = se(r.state.doc, t, r.dragging.slice);
341
344
  e != null && (t = e);
342
345
  }
343
346
  let a = !r.state.doc.resolve(t).parent.inlineContent, c = {
@@ -380,9 +383,9 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
380
383
  };
381
384
  }), qe = b(() => ({
382
385
  key: "history",
383
- prosemirrorPlugins: [De()],
384
- undoCommand: ke,
385
- redoCommand: Oe
386
+ prosemirrorPlugins: [Oe()],
387
+ undoCommand: Ae,
388
+ redoCommand: ke
386
389
  })), Je = b(({ editor: e }) => {
387
390
  function t(t) {
388
391
  let n = e.prosemirrorView.nodeDOM(t);
@@ -404,7 +407,7 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
404
407
  return n.text;
405
408
  },
406
409
  get position() {
407
- return ce(e.prosemirrorView, n.from, n.to).toJSON();
410
+ return le(e.prosemirrorView, n.from, n.to).toJSON();
408
411
  }
409
412
  };
410
413
  }
@@ -451,7 +454,7 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
451
454
  if (t.key.length === 1) return t.preventDefault(), !0;
452
455
  if (t.key === "Enter" && !t.isComposing && !t.shiftKey && !t.altKey && !t.ctrlKey && !t.metaKey) {
453
456
  let t = e.state.tr;
454
- return e.dispatch(t.insert(e.state.tr.selection.$to.after(), e.state.schema.nodes.paragraph.createChecked()).setSelection(new de(t.doc.resolve(e.state.tr.selection.$to.after() + 1)))), !0;
457
+ return e.dispatch(t.insert(e.state.tr.selection.$to.after(), e.state.schema.nodes.paragraph.createChecked()).setSelection(new fe(t.doc.resolve(e.state.tr.selection.$to.after() + 1)))), !0;
455
458
  }
456
459
  }
457
460
  return !1;
@@ -464,7 +467,7 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
464
467
  prosemirrorPlugins: [new C({
465
468
  key: $e,
466
469
  view: (t) => {
467
- let r = `placeholder-selector-${le()}`;
470
+ let r = `placeholder-selector-${ue()}`;
468
471
  t.dom.classList.add(r);
469
472
  let i = document.createElement("style"), a = e._tiptapEditor.options.injectNonce;
470
473
  a && i.setAttribute("nonce", a), t.root instanceof window.ShadowRoot ? t.root.append(i) : t.root.head.appendChild(i);
@@ -498,9 +501,9 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
498
501
  })]
499
502
  };
500
503
  }), tt = b(({ editor: e }) => {
501
- let t = new ie(), n = 0;
504
+ let t = new x(), n = 0;
502
505
  function r() {
503
- t = new ie(), n = 0;
506
+ t = new x(), n = 0;
504
507
  }
505
508
  let i = typeof FinalizationRegistry < "u" ? new FinalizationRegistry(() => {
506
509
  n--, n === 0 && r();
@@ -526,20 +529,20 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
526
529
  depth: "depth",
527
530
  "depth-change": "depth-change"
528
531
  }, it = b(() => {
529
- let t;
532
+ let e;
530
533
  return {
531
534
  key: "previousBlockType",
532
535
  prosemirrorPlugins: [new C({
533
536
  key: nt,
534
- view(e) {
537
+ view(t) {
535
538
  return {
536
- update: async (e, n) => {
537
- this.key?.getState(e.state).updatedBlocks.size > 0 && (t = setTimeout(() => {
538
- e.dispatch(e.state.tr.setMeta(nt, { clearUpdate: !0 }));
539
+ update: async (t, n) => {
540
+ this.key?.getState(t.state).updatedBlocks.size > 0 && (e = setTimeout(() => {
541
+ t.dispatch(t.state.tr.setMeta(nt, { clearUpdate: !0 }));
539
542
  }, 0));
540
543
  },
541
544
  destroy: () => {
542
- t && clearTimeout(t);
545
+ e && clearTimeout(e);
543
546
  }
544
547
  };
545
548
  },
@@ -551,53 +554,53 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
551
554
  updatedBlocks: /* @__PURE__ */ new Set()
552
555
  };
553
556
  },
554
- apply(t, n, r, i) {
555
- if (n.currentTransactionOldBlockAttrs = {}, n.updatedBlocks.clear(), !t.docChanged) return n;
556
- let a = t.changedRange();
557
- if (!a) return n;
558
- let o = t.mapping.invert(), s = {
559
- from: o.map(a.from, -1),
560
- to: o.map(a.to, 1)
561
- }, c = {}, l = se(r.doc, s, (e) => e.attrs.id), u = new Map(l.map((t) => [e(t.node, r.doc), t])), d = se(i.doc, a, (e) => e.attrs.id);
562
- for (let t of d) {
563
- let a = e(t.node, i.doc), o = u.get(a), s = o?.node.firstChild, l = t.node.firstChild;
564
- if (o && s && l) {
565
- let e = {
566
- index: l.attrs.index,
567
- level: l.attrs.level,
568
- type: l.type.name,
569
- depth: i.doc.resolve(t.pos).depth
557
+ apply(e, t, n, r) {
558
+ if (t.currentTransactionOldBlockAttrs = {}, t.updatedBlocks.clear(), !e.docChanged) return t;
559
+ let i = e.changedRange();
560
+ if (!i) return t;
561
+ let a = e.mapping.invert(), o = {
562
+ from: a.map(i.from, -1),
563
+ to: a.map(i.to, 1)
564
+ }, s = {}, c = S(n.doc, o, (e) => e.attrs.id), l = new Map(c.map((e) => [g(e.node, n.doc), e])), u = S(r.doc, i, (e) => e.attrs.id);
565
+ for (let e of u) {
566
+ let i = g(e.node, r.doc), a = l.get(i), o = a?.node.firstChild, c = e.node.firstChild;
567
+ if (a && o && c) {
568
+ let l = {
569
+ index: c.attrs.index,
570
+ level: c.attrs.level,
571
+ type: c.type.name,
572
+ depth: r.doc.resolve(e.pos).depth
570
573
  }, u = {
571
- index: s.attrs.index,
572
- level: s.attrs.level,
573
- type: s.type.name,
574
- depth: r.doc.resolve(o.pos).depth
574
+ index: o.attrs.index,
575
+ level: o.attrs.level,
576
+ type: o.type.name,
577
+ depth: n.doc.resolve(a.pos).depth
575
578
  };
576
- c[a] = u, n.currentTransactionOldBlockAttrs[a] = u, (u.index !== e.index || u.level !== e.level || u.type !== e.type || u.depth !== e.depth) && (u["depth-change"] = u.depth - e.depth, n.updatedBlocks.add(a));
579
+ s[i] = u, t.currentTransactionOldBlockAttrs[i] = u, (u.index !== l.index || u.level !== l.level || u.type !== l.type || u.depth !== l.depth) && (u["depth-change"] = u.depth - l.depth, t.updatedBlocks.add(i));
577
580
  }
578
581
  }
579
- return n.prevTransactionOldBlockAttrs = c, n;
582
+ return t.prevTransactionOldBlockAttrs = s, t;
580
583
  }
581
584
  },
582
- props: { decorations(t) {
583
- let n = this.getState(t);
584
- if (n.updatedBlocks.size === 0) return;
585
- let r = [];
586
- return t.doc.descendants((i, a) => {
587
- if (!i.attrs.id) return;
588
- let o = e(i, t.doc);
589
- if (!n.updatedBlocks.has(o)) return;
590
- let s = n.currentTransactionOldBlockAttrs[o], c = {};
591
- for (let [e, t] of Object.entries(s)) c["data-prev-" + rt[e]] = t || "none";
592
- r.push(E.node(a, a + i.nodeSize, { ...c }));
593
- }), D.create(t.doc, r);
585
+ props: { decorations(e) {
586
+ let t = this.getState(e);
587
+ if (t.updatedBlocks.size === 0) return;
588
+ let n = [];
589
+ return e.doc.descendants((r, i) => {
590
+ if (!r.attrs.id) return;
591
+ let a = g(r, e.doc);
592
+ if (!t.updatedBlocks.has(a)) return;
593
+ let o = t.currentTransactionOldBlockAttrs[a], s = {};
594
+ for (let [e, t] of Object.entries(o)) s["data-prev-" + rt[e]] = t || "none";
595
+ n.push(E.node(i, i + r.nodeSize, { ...s }));
596
+ }), D.create(e.doc, n);
594
597
  } }
595
598
  })]
596
599
  };
597
600
  });
598
601
  //#endregion
599
602
  //#region src/extensions/getDraggableBlockFromElement.ts
600
- function A(e, t) {
603
+ function at(e, t) {
601
604
  for (; e && e.parentElement && e.parentElement !== t.dom && e.getAttribute?.("data-node-type") !== "blockContainer";) e = e.parentElement;
602
605
  if (e.getAttribute?.("data-node-type") === "blockContainer") return {
603
606
  node: e,
@@ -606,7 +609,7 @@ function A(e, t) {
606
609
  }
607
610
  //#endregion
608
611
  //#region src/api/exporters/markdown/htmlToMarkdown.ts
609
- function at(e) {
612
+ function ot(e) {
610
613
  let t = document.createElement("div");
611
614
  return t.innerHTML = e, j(t, {
612
615
  indent: "",
@@ -626,40 +629,40 @@ function M(e, t) {
626
629
  if (e.nodeType !== 1) return "";
627
630
  let n = e;
628
631
  switch (n.tagName.toLowerCase()) {
629
- case "p": return ot(n, t);
632
+ case "p": return st(n, t);
630
633
  case "h1":
631
634
  case "h2":
632
635
  case "h3":
633
636
  case "h4":
634
637
  case "h5":
635
- case "h6": return N(n, t);
636
- case "blockquote": return st(n, t);
637
- case "pre": return ct(n, t);
638
- case "ul": return ut(n, t);
639
- case "ol": return dt(n, t);
640
- case "table": return pt(n, t);
638
+ case "h6": return ct(n, t);
639
+ case "blockquote": return lt(n, t);
640
+ case "pre": return ut(n, t);
641
+ case "ul": return pt(n, t);
642
+ case "ol": return mt(n, t);
643
+ case "table": return _t(n, t);
641
644
  case "hr": return t.indent + "***\n\n";
642
- case "img": return ht(n, t);
643
- case "video": return gt(n, t);
644
- case "audio": return _t(n, t);
645
- case "embed": return vt(n, t);
646
- case "figure": return yt(n, t);
647
- case "a": return xt(n, t);
648
- case "details": return wt(n, t);
645
+ case "img": return yt(n, t);
646
+ case "video": return bt(n, t);
647
+ case "audio": return xt(n, t);
648
+ case "embed": return St(n, t);
649
+ case "figure": return Ct(n, t);
650
+ case "a": return L(n, t);
651
+ case "details": return Et(n, t);
649
652
  case "div": return j(n, t);
650
653
  case "br": return "";
651
654
  default: return j(n, t);
652
655
  }
653
656
  }
654
- function ot(e, t) {
655
- let n = Et(B(e));
657
+ function st(e, t) {
658
+ let n = Dt(z(e));
656
659
  return t.inListItem ? n : t.indent + n + "\n\n";
657
660
  }
658
- function N(e, t) {
659
- let n = parseInt(e.tagName[1], 10), r = "#".repeat(n) + " ", i = B(e);
661
+ function ct(e, t) {
662
+ let n = parseInt(e.tagName[1], 10), r = "#".repeat(n) + " ", i = z(e);
660
663
  return t.indent + r + i + "\n\n";
661
664
  }
662
- function st(e, t) {
665
+ function lt(e, t) {
663
666
  let n = Array.from(e.children).filter((e) => {
664
667
  let t = e.tagName.toLowerCase();
665
668
  return [
@@ -674,43 +677,43 @@ function st(e, t) {
674
677
  }), r;
675
678
  if (n.length > 0) {
676
679
  let e = [];
677
- for (let t of n) t.tagName.toLowerCase() === "p" ? e.push(B(t)) : e.push(M(t, {
680
+ for (let t of n) t.tagName.toLowerCase() === "p" ? e.push(z(t)) : e.push(M(t, {
678
681
  indent: "",
679
682
  inListItem: !1
680
683
  }).trim());
681
684
  r = e.join("\n\n");
682
- } else r = B(e);
685
+ } else r = z(e);
683
686
  return r.split("\n").map((e) => t.indent + "> " + e).join("\n") + "\n\n";
684
687
  }
685
- function ct(e, t) {
688
+ function ut(e, t) {
686
689
  let n = e.querySelector("code");
687
690
  if (!n) return "";
688
- let r = n.getAttribute("data-language") || lt(n.className) || "", i = P(n), a = Math.max(0, ...(i.match(/`+/g) ?? []).map((e) => e.length)), o = "`".repeat(Math.max(3, a + 1));
691
+ let r = n.getAttribute("data-language") || ft(n.className) || "", i = dt(n), a = Math.max(0, ...(i.match(/`+/g) ?? []).map((e) => e.length)), o = "`".repeat(Math.max(3, a + 1));
689
692
  return i ? t.indent + o + r + "\n" + i + (i.endsWith("\n") ? "" : "\n") + o + "\n\n" : t.indent + o + r + "\n" + o + "\n\n";
690
693
  }
691
- function P(e) {
694
+ function dt(e) {
692
695
  let t = "";
693
- for (let n of Array.from(e.childNodes)) n.nodeType === 3 ? t += n.textContent || "" : n.nodeType === 1 && (n.tagName.toLowerCase() === "br" ? t += "\n" : t += P(n));
696
+ for (let n of Array.from(e.childNodes)) n.nodeType === 3 ? t += n.textContent || "" : n.nodeType === 1 && (n.tagName.toLowerCase() === "br" ? t += "\n" : t += dt(n));
694
697
  return t;
695
698
  }
696
- function lt(e) {
699
+ function ft(e) {
697
700
  let t = e.match(/language-(\S+)/);
698
701
  return t ? t[1] : "";
699
702
  }
700
- function ut(e, t) {
703
+ function pt(e, t) {
701
704
  let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li");
702
- for (let e of r) n += F(e, "bullet", t);
705
+ for (let e of r) n += ht(e, "bullet", t);
703
706
  return t.inListItem || (n += "\n"), n;
704
707
  }
705
- function dt(e, t) {
708
+ function mt(e, t) {
706
709
  let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li"), i = parseInt(e.getAttribute("start") || "1", 10);
707
710
  for (let e = 0; e < r.length; e++) {
708
711
  let a = i + e;
709
- n += F(r[e], "ordered", t, a);
712
+ n += ht(r[e], "ordered", t, a);
710
713
  }
711
714
  return t.inListItem || (n += "\n"), n;
712
715
  }
713
- function F(e, t, n, r) {
716
+ function ht(e, t, n, r) {
714
717
  let i = null, a = null;
715
718
  for (let t of Array.from(e.children)) {
716
719
  let e = t.tagName.toLowerCase();
@@ -721,8 +724,8 @@ function F(e, t, n, r) {
721
724
  let c, l;
722
725
  if (a) {
723
726
  let e = a.querySelector("summary")?.querySelector("p");
724
- l = a, c = e ? B(e) : "";
725
- } else l = ft(e, i), c = l ? B(l) : "";
727
+ l = a, c = e ? z(e) : "";
728
+ } else l = gt(e, i), c = l ? z(l) : "";
726
729
  let u = n.indent + o + c + "\n", d = n.indent + " ".repeat(s), f = {
727
730
  indent: d,
728
731
  inListItem: !0
@@ -730,7 +733,7 @@ function F(e, t, n, r) {
730
733
  if (a) {
731
734
  let e = a.querySelector("summary");
732
735
  for (let t of Array.from(a.children)) if (t !== e) if (t.tagName.toLowerCase() === "p") {
733
- let e = B(t);
736
+ let e = z(t);
734
737
  u += "\n" + d + e + "\n";
735
738
  } else u += M(t, f);
736
739
  }
@@ -739,13 +742,13 @@ function F(e, t, n, r) {
739
742
  let t = e.tagName.toLowerCase();
740
743
  if (!(e === l || e === i) && t !== "input") if (t === "ul" || t === "ol") u += M(e, f);
741
744
  else if (t === "p") {
742
- let t = B(e);
745
+ let t = z(e);
743
746
  u += "\n" + d + t + "\n";
744
747
  } else u += "\n" + M(e, f);
745
748
  }
746
749
  return u;
747
750
  }
748
- function ft(e, t) {
751
+ function gt(e, t) {
749
752
  for (let n of Array.from(e.children)) {
750
753
  if (n === t || n.tagName.toLowerCase() === "input") continue;
751
754
  let e = n.tagName.toLowerCase();
@@ -753,7 +756,7 @@ function ft(e, t) {
753
756
  }
754
757
  return null;
755
758
  }
756
- function pt(e, t) {
759
+ function _t(e, t) {
757
760
  let n = e.querySelector("colgroup"), r = 0;
758
761
  n && (r = n.querySelectorAll("col").length);
759
762
  let i = [], a = !1, o = e.querySelectorAll("tr"), s = [];
@@ -763,7 +766,7 @@ function pt(e, t) {
763
766
  n.forEach((e) => {
764
767
  for (; s[t][i] !== void 0;) i++;
765
768
  t === 0 && e.tagName.toLowerCase() === "th" && (a = !0);
766
- let n = mt(B(e).trim()), r = parseInt(e.getAttribute("colspan") || "1", 10), o = parseInt(e.getAttribute("rowspan") || "1", 10);
769
+ let n = vt(z(e).trim()), r = parseInt(e.getAttribute("colspan") || "1", 10), o = parseInt(e.getAttribute("rowspan") || "1", 10);
767
770
  for (let e = 0; e < o; e++) for (let a = 0; a < r; a++) {
768
771
  let r = t + e;
769
772
  s[r] || (s[r] = []), s[r][i + a] = e === 0 && a === 0 ? n : "";
@@ -788,19 +791,19 @@ function pt(e, t) {
788
791
  }
789
792
  let l = "";
790
793
  if (a) {
791
- l += t.indent + I(i[0], c, r) + "\n", l += t.indent + L(c, r) + "\n";
792
- for (let e = 1; e < i.length; e++) l += t.indent + I(i[e], c, r) + "\n";
794
+ l += t.indent + N(i[0], c, r) + "\n", l += t.indent + P(c, r) + "\n";
795
+ for (let e = 1; e < i.length; e++) l += t.indent + N(i[e], c, r) + "\n";
793
796
  } else {
794
797
  let e = Array(r).fill("");
795
- l += t.indent + I(e, c, r) + "\n", l += t.indent + L(c, r) + "\n";
796
- for (let e of i) l += t.indent + I(e, c, r) + "\n";
798
+ l += t.indent + N(e, c, r) + "\n", l += t.indent + P(c, r) + "\n";
799
+ for (let e of i) l += t.indent + N(e, c, r) + "\n";
797
800
  }
798
801
  return l += "\n", l;
799
802
  }
800
- function mt(e) {
803
+ function vt(e) {
801
804
  return e.replace(/\|/g, "\\|");
802
805
  }
803
- function I(e, t, n) {
806
+ function N(e, t, n) {
804
807
  let r = [];
805
808
  for (let i = 0; i < n; i++) {
806
809
  let n = i < e.length ? e[i] : "";
@@ -808,65 +811,65 @@ function I(e, t, n) {
808
811
  }
809
812
  return "|" + r.join("|") + "|";
810
813
  }
811
- function L(e, t) {
814
+ function P(e, t) {
812
815
  let n = [];
813
816
  for (let r = 0; r < t; r++) n.push(" " + "-".repeat(e[r]) + " ");
814
817
  return "|" + n.join("|") + "|";
815
818
  }
816
- function ht(e, t) {
819
+ function yt(e, t) {
817
820
  let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
818
821
  return n ? t.indent + `![${r}](${n})\n\n` : "\n\n";
819
822
  }
820
- function gt(e, t) {
823
+ function bt(e, t) {
821
824
  let n = e.getAttribute("src") || e.getAttribute("data-url") || "", r = e.getAttribute("data-name") || e.getAttribute("title") || "";
822
825
  return n ? t.indent + `![${r}](${n})\n\n` : "\n\n";
823
826
  }
824
- function _t(e, t) {
827
+ function xt(e, t) {
825
828
  let n = e.getAttribute("src") || "";
826
- return n ? t.indent + `<audio src="${z(n)}" controls></audio>\n\n` : "\n\n";
829
+ return n ? t.indent + `<audio src="${I(n)}" controls></audio>\n\n` : "\n\n";
827
830
  }
828
- function vt(e, t) {
831
+ function St(e, t) {
829
832
  let n = e.getAttribute("src") || "";
830
833
  return n ? t.indent + `[](${n})\n\n` : "\n\n";
831
834
  }
832
- function yt(e, t) {
835
+ function Ct(e, t) {
833
836
  let n = e.querySelector("img"), r = e.querySelector("video"), i = e.querySelector("audio"), a = e.querySelector("a"), o = e.querySelector("figcaption")?.textContent?.trim() || "";
834
- return n ? R("img", n.getAttribute("src") || "", n.getAttribute("alt") || "", o, t) : r ? R("video", r.getAttribute("src") || r.getAttribute("data-url") || "", r.getAttribute("data-name") || r.getAttribute("title") || "", o, t) : i ? R("audio", i.getAttribute("src") || "", "", o, t) : a ? xt(a, t) : "";
837
+ return n ? F("img", n.getAttribute("src") || "", n.getAttribute("alt") || "", o, t) : r ? F("video", r.getAttribute("src") || r.getAttribute("data-url") || "", r.getAttribute("data-name") || r.getAttribute("title") || "", o, t) : i ? F("audio", i.getAttribute("src") || "", "", o, t) : a ? L(a, t) : "";
835
838
  }
836
- function R(e, t, n, r, i) {
839
+ function F(e, t, n, r, i) {
837
840
  if (!t) return "";
838
841
  if (!r && e !== "audio") return i.indent + `![${n}](${t})\n\n`;
839
- let a = n && n !== r ? e === "img" ? ` alt="${z(n)}"` : e === "video" ? ` data-name="${z(n)}"` : "" : "", o = e === "img" ? `<img${a} src="${z(t)}">` : `<${e} src="${z(t)}"${a} controls></${e}>`, s = r ? `<figcaption>${bt(r)}</figcaption>` : "";
842
+ let a = n && n !== r ? e === "img" ? ` alt="${I(n)}"` : e === "video" ? ` data-name="${I(n)}"` : "" : "", o = e === "img" ? `<img${a} src="${I(t)}">` : `<${e} src="${I(t)}"${a} controls></${e}>`, s = r ? `<figcaption>${wt(r)}</figcaption>` : "";
840
843
  return i.indent + `<figure>${o}${s}</figure>\n\n`;
841
844
  }
842
- function z(e) {
845
+ function I(e) {
843
846
  return e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
844
847
  }
845
- function bt(e) {
848
+ function wt(e) {
846
849
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
847
850
  }
848
- function xt(e, t) {
851
+ function L(e, t) {
849
852
  let n = e.getAttribute("href") || "", r = e.textContent?.trim() || "";
850
- return n ? t.indent + St(r, n) + "\n\n" : t.indent + r + "\n\n";
853
+ return n ? t.indent + R(r, n) + "\n\n" : t.indent + r + "\n\n";
851
854
  }
852
- function St(e, t) {
853
- return !e || e === t ? t : `[${e}](${Ct(t)})`;
855
+ function R(e, t) {
856
+ return !e || e === t ? t : `[${e}](${Tt(t)})`;
854
857
  }
855
- function Ct(e) {
858
+ function Tt(e) {
856
859
  return e.replace(/[\\()]/g, "\\$&");
857
860
  }
858
- function wt(e, t) {
861
+ function Et(e, t) {
859
862
  let n = e.querySelector("summary");
860
863
  if (!n) return j(e, t);
861
864
  let r = n.querySelector("h1, h2, h3, h4, h5, h6");
862
865
  if (r) {
863
- let i = N(r, t);
866
+ let i = ct(r, t);
864
867
  for (let r of Array.from(e.children)) r !== n && (i += M(r, t));
865
868
  return i;
866
869
  }
867
870
  return j(n, t);
868
871
  }
869
- function B(e) {
872
+ function z(e) {
870
873
  let t = "";
871
874
  for (let n of Array.from(e.childNodes)) if (n.nodeType === 3) t += n.textContent || "";
872
875
  else if (n.nodeType === 1) {
@@ -874,19 +877,19 @@ function B(e) {
874
877
  switch (e.tagName.toLowerCase()) {
875
878
  case "strong":
876
879
  case "b": {
877
- let { content: n, trailing: r } = Tt(B(e));
880
+ let { content: n, trailing: r } = B(z(e));
878
881
  n ? t += `**${n}**${r}` : t += r;
879
882
  break;
880
883
  }
881
884
  case "em":
882
885
  case "i": {
883
- let { content: n, trailing: r } = Tt(B(e));
886
+ let { content: n, trailing: r } = B(z(e));
884
887
  n ? t += `*${n}*${r}` : t += r;
885
888
  break;
886
889
  }
887
890
  case "s":
888
891
  case "del":
889
- t += `~~${B(e)}~~`;
892
+ t += `~~${z(e)}~~`;
890
893
  break;
891
894
  case "code": {
892
895
  let n = e.textContent || "", r = Math.max(0, ...(n.match(/`+/g) ?? []).map((e) => e.length)), i = "`".repeat(r + 1), a = n.startsWith("`") || n.endsWith("`");
@@ -894,18 +897,18 @@ function B(e) {
894
897
  break;
895
898
  }
896
899
  case "u":
897
- t += B(e);
900
+ t += z(e);
898
901
  break;
899
902
  case "a": {
900
- let n = e.getAttribute("href") || "", r = B(e);
901
- t += St(r, n);
903
+ let n = e.getAttribute("href") || "", r = z(e);
904
+ t += R(r, n);
902
905
  break;
903
906
  }
904
907
  case "br":
905
908
  t += "\\\n";
906
909
  break;
907
910
  case "span":
908
- t += B(e);
911
+ t += z(e);
909
912
  break;
910
913
  case "img": {
911
914
  let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
@@ -918,17 +921,17 @@ function B(e) {
918
921
  break;
919
922
  }
920
923
  case "p":
921
- t += B(e);
924
+ t += z(e);
922
925
  break;
923
926
  case "input": break;
924
927
  default:
925
- t += B(e);
928
+ t += z(e);
926
929
  break;
927
930
  }
928
931
  }
929
932
  return t;
930
933
  }
931
- function Tt(e) {
934
+ function B(e) {
932
935
  let t = e.match(/^(.*?)(\s*)$/);
933
936
  return t ? {
934
937
  content: t[1],
@@ -938,25 +941,25 @@ function Tt(e) {
938
941
  trailing: ""
939
942
  };
940
943
  }
941
- function Et(e) {
944
+ function Dt(e) {
942
945
  let t = e.replace(/^(\\\n)+/, "");
943
946
  return t = t.replace(/(\\\n)+$/, ""), t;
944
947
  }
945
948
  //#endregion
946
949
  //#region src/api/exporters/markdown/markdownExporter.ts
947
950
  function V(e) {
948
- return at(e);
951
+ return ot(e.split("").join(""));
949
952
  }
950
- function Dt(e, t, n, r) {
953
+ function Ot(e, t, n, r) {
951
954
  return V(k(t, n).exportBlocks(e, r));
952
955
  }
953
956
  //#endregion
954
957
  //#region src/api/nodeConversions/fragmentToBlocks.ts
955
- function Ot(e) {
958
+ function kt(e) {
956
959
  let t = [];
957
960
  return e.descendants((e) => e.type.name === "blockContainer" && e.firstChild?.type.name === "blockGroup" ? !0 : e.type.name === "columnList" && e.childCount === 1 ? (e.firstChild?.forEach((n) => {
958
- t.push(_(n, e));
959
- }), !1) : e.type.isInGroup("bnBlock") ? (t.push(_(e, e)), !1) : !0), t;
961
+ t.push(v(n, e));
962
+ }), !1) : e.type.isInGroup("bnBlock") ? (t.push(v(e, e)), !1) : !0), t;
960
963
  }
961
964
  //#endregion
962
965
  //#region src/extensions/SideMenu/MultipleNodeSelection.ts
@@ -973,7 +976,7 @@ var H = class e extends T {
973
976
  return new e(t.resolve(n), t.resolve(r));
974
977
  }
975
978
  content() {
976
- return new re(S.from(this.nodes), 0, 0);
979
+ return new oe(ae.from(this.nodes), 0, 0);
977
980
  }
978
981
  eq(t) {
979
982
  if (!(t instanceof e) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to) return !1;
@@ -996,7 +999,7 @@ T.jsonID("multiple-node", H);
996
999
  //#endregion
997
1000
  //#region src/extensions/SideMenu/dragging.ts
998
1001
  var U;
999
- function kt(e, t) {
1002
+ function At(e, t) {
1000
1003
  let n, r, i = t.resolve(e.from).node().type.spec.group === "blockContent", a = t.resolve(e.to).node().type.spec.group === "blockContent", o = Math.min(e.$anchor.depth, e.$head.depth);
1001
1004
  if (i && a) {
1002
1005
  let i = e.$from.start(o - 1), a = e.$to.end(o - 1);
@@ -1007,40 +1010,40 @@ function kt(e, t) {
1007
1010
  to: r
1008
1011
  };
1009
1012
  }
1010
- function At(e, t, n = t) {
1013
+ function jt(e, t, n = t) {
1011
1014
  t === n && (n += e.state.doc.resolve(t + 1).node().nodeSize);
1012
1015
  let r = e.domAtPos(t).node.cloneNode(!0), i = e.domAtPos(t).node, a = (e, t) => Array.prototype.indexOf.call(e.children, t), o = a(i, e.domAtPos(t + 1).node.parentElement), s = a(i, e.domAtPos(n - 1).node.parentElement);
1013
1016
  for (let e = i.childElementCount - 1; e >= 0; e--) (e > s || e < o) && r.removeChild(r.children[e]);
1014
- jt(e.root), U = r, U.querySelectorAll("iframe, embed, object").forEach((e) => e.parentElement?.removeChild(e));
1017
+ Mt(e.root), U = r, U.querySelectorAll("iframe, embed, object").forEach((e) => e.parentElement?.removeChild(e));
1015
1018
  let c = e.dom.className.split(" ").filter((e) => e !== "ProseMirror" && e !== "bn-root" && e !== "bn-editor").join(" ");
1016
1019
  U.className = U.className + " bn-drag-preview " + c, e.root instanceof ShadowRoot ? e.root.appendChild(U) : e.root.body.appendChild(U);
1017
1020
  }
1018
- function jt(e) {
1021
+ function Mt(e) {
1019
1022
  U !== void 0 && (e instanceof ShadowRoot ? e.removeChild(U) : e.body.removeChild(U), U = void 0);
1020
1023
  }
1021
- function Mt(e, t, n) {
1022
- if (!e.dataTransfer || n.headless) return;
1023
- let r = n.prosemirrorView, i = ee(t.id, r.state.doc);
1024
- if (!i) throw Error(`Block with ID ${t.id} not found`);
1025
- let a = i.posBeforeNode;
1026
- if (a != null) {
1027
- let t = r.state.selection, i = r.state.doc, { from: o, to: s } = kt(t, i), c = o <= a && a < s, l = t.$anchor.node() !== t.$head.node() || t instanceof H;
1028
- c && l ? (r.dispatch(r.state.tr.setSelection(H.create(i, o, s))), At(r, o, s)) : (r.dispatch(r.state.tr.setSelection(ue.create(r.state.doc, a))), At(r, a));
1029
- let u = r.state.selection.content(), d = n.pmSchema, f = r.serializeForClipboard(u).dom.innerHTML, p = k(d, n), m = Ot(u.content), h = p.exportBlocks(m, {}), g = V(h);
1030
- e.dataTransfer.clearData(), e.dataTransfer.setData("blocknote/html", f), e.dataTransfer.setData("text/html", h), e.dataTransfer.setData("text/plain", g), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setDragImage(U, 0, 0);
1024
+ function Nt(t, n, r) {
1025
+ if (!t.dataTransfer || r.headless) return;
1026
+ let i = r.prosemirrorView, a = e(n.id, i.state.doc);
1027
+ if (!a) throw Error(`Block with ID ${n.id} not found`);
1028
+ let o = a.posBeforeNode;
1029
+ if (o != null) {
1030
+ let e = i.state.selection, n = i.state.doc, { from: a, to: s } = At(e, n), c = a <= o && o < s, l = e.$anchor.node() !== e.$head.node() || e instanceof H;
1031
+ c && l ? (i.dispatch(i.state.tr.setSelection(H.create(n, a, s))), jt(i, a, s)) : (i.dispatch(i.state.tr.setSelection(de.create(i.state.doc, o))), jt(i, o));
1032
+ let u = i.state.selection.content(), d = r.pmSchema, f = i.serializeForClipboard(u).dom.innerHTML, p = k(d, r), m = kt(u.content), h = p.exportBlocks(m, {}), g = V(h);
1033
+ t.dataTransfer.clearData(), t.dataTransfer.setData("blocknote/html", f), t.dataTransfer.setData("text/html", h), t.dataTransfer.setData("text/plain", g), t.dataTransfer.effectAllowed = "move", t.dataTransfer.setDragImage(U, 0, 0);
1031
1034
  }
1032
1035
  }
1033
1036
  //#endregion
1034
1037
  //#region src/extensions/SideMenu/SideMenu.ts
1035
- var Nt = 250;
1038
+ var Pt = 250;
1036
1039
  function W(e, t, n = !0) {
1037
1040
  let r = e.root.elementsFromPoint(t.left, t.top);
1038
1041
  for (let i of r) if (e.dom.contains(i)) return n && i.closest("[data-node-type=columnList]") ? W(e, {
1039
1042
  left: t.left + 50,
1040
1043
  top: t.top
1041
- }, !1) : A(i, e);
1044
+ }, !1) : at(i, e);
1042
1045
  }
1043
- function Pt(e, t) {
1046
+ function Ft(e, t) {
1044
1047
  if (!t.dom.firstChild) return;
1045
1048
  let n = t.dom.firstChild.getBoundingClientRect(), r = W(t, {
1046
1049
  left: Math.min(Math.max(n.left + 10, e.x), n.right - 10),
@@ -1051,7 +1054,7 @@ function Pt(e, t) {
1051
1054
  top: e.y
1052
1055
  }, !1);
1053
1056
  }
1054
- var Ft = class {
1057
+ var It = class {
1055
1058
  editor;
1056
1059
  pmView;
1057
1060
  state;
@@ -1075,21 +1078,25 @@ var Ft = class {
1075
1078
  clientX: this.mousePos.x,
1076
1079
  clientY: this.mousePos.y
1077
1080
  });
1078
- if (e?.element !== this.pmView.dom || e.distance > Nt) {
1081
+ if (e?.element !== this.pmView.dom || e.distance > Pt) {
1079
1082
  this.state?.show && (this.state.show = !1, this.updateState(this.state));
1080
1083
  return;
1081
1084
  }
1082
- let t = Pt(this.mousePos, this.pmView);
1085
+ let t = Ft(this.mousePos, this.pmView);
1083
1086
  if (!t || !this.editor.isEditable) {
1084
1087
  this.state?.show && (this.state.show = !1, this.updateState(this.state));
1085
1088
  return;
1086
1089
  }
1087
1090
  if (!(this.state?.show && this.hoveredBlock?.hasAttribute("data-id") && this.hoveredBlock?.getAttribute("data-id") === t.id) && (this.hoveredBlock = t.node, this.editor.isEditable)) {
1088
- let e = t.node.getBoundingClientRect(), n = t.node.closest("[data-node-type=column]");
1091
+ let e = t.node.getBoundingClientRect(), n = t.node.closest("[data-node-type=column]"), r = this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"));
1092
+ if (!r) {
1093
+ this.state?.show && (this.state.show = !1, this.hoveredBlock = void 0, this.emitUpdate(this.state));
1094
+ return;
1095
+ }
1089
1096
  this.state = {
1090
1097
  show: !0,
1091
1098
  referencePos: new DOMRect(n ? n.firstElementChild.getBoundingClientRect().x : this.pmView.dom.firstChild.getBoundingClientRect().x, e.y, e.width, e.height),
1092
- block: this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))
1099
+ block: r
1093
1100
  }, this.updateState(this.state);
1094
1101
  }
1095
1102
  };
@@ -1098,9 +1105,9 @@ var Ft = class {
1098
1105
  if (!t || this.pmView.dragging) return;
1099
1106
  let n = document.createElement("div");
1100
1107
  n.innerHTML = t;
1101
- let r = fe.fromSchema(this.pmView.state.schema).parse(n, { topNode: this.pmView.state.schema.nodes.blockGroup.create() });
1108
+ let r = pe.fromSchema(this.pmView.state.schema).parse(n, { topNode: this.pmView.state.schema.nodes.blockGroup.create() });
1102
1109
  this.pmView.dragging = {
1103
- slice: new pe(r.content, 0, 0),
1110
+ slice: new me(r.content, 0, 0),
1104
1111
  move: !0
1105
1112
  };
1106
1113
  };
@@ -1132,7 +1139,7 @@ var Ft = class {
1132
1139
  getDragEventContext = (e) => {
1133
1140
  if (!(this.pmView.dragging !== null || this.isDragOrigin || e.dataTransfer?.types.includes("blocknote/html") || e.target instanceof Node && this.pmView.dom.contains(e.target))) return;
1134
1141
  let t = !e.dataTransfer?.types.includes("blocknote/html") && !!this.pmView.dragging, n = !!this.isDragOrigin, r = t || n, i = this.findClosestEditorElement(e);
1135
- if (!i || i.distance > Nt) return;
1142
+ if (!i || i.distance > Pt) return;
1136
1143
  let a = i.element === this.pmView.dom, o = a && i.distance === 0;
1137
1144
  if (!(!a && !r)) return {
1138
1145
  isDropPoint: a,
@@ -1150,7 +1157,7 @@ var Ft = class {
1150
1157
  let { isDropPoint: n, isDropWithinEditorBounds: r, isDragOrigin: i } = t;
1151
1158
  if (!r && n && this.dispatchSyntheticEvent(e), n) {
1152
1159
  if (this.pmView.dragging) return;
1153
- this.pmView.dispatch(this.pmView.state.tr.setSelection(Te.create(this.pmView.state.tr.doc, this.pmView.state.tr.selection.anchor)));
1160
+ this.pmView.dispatch(this.pmView.state.tr.setSelection(Ee.create(this.pmView.state.tr.doc, this.pmView.state.tr.selection.anchor)));
1154
1161
  return;
1155
1162
  } else if (i) {
1156
1163
  setTimeout(() => this.pmView.dispatch(this.pmView.state.tr.deleteSelection()), 0);
@@ -1186,22 +1193,25 @@ var Ft = class {
1186
1193
  destroy() {
1187
1194
  this.state?.show && (this.state.show = !1, this.emitUpdate(this.state)), this.pmView.root.removeEventListener("mousemove", this.onMouseMove, !0), this.pmView.root.removeEventListener("dragstart", this.onDragStart), this.pmView.root.removeEventListener("dragover", this.onDragOver), this.pmView.root.removeEventListener("drop", this.onDrop, !0), this.pmView.root.removeEventListener("dragend", this.onDragEnd, !0), this.pmView.root.removeEventListener("keydown", this.onKeyDown, !0);
1188
1195
  }
1189
- }, It = new we("SideMenuPlugin"), Lt = b(({ editor: e }) => {
1196
+ }, Lt = new Te("SideMenuPlugin"), Rt = b(({ editor: e }) => {
1190
1197
  let t, n = y(void 0);
1191
1198
  return {
1192
1199
  key: "sideMenu",
1193
1200
  store: n,
1194
- prosemirrorPlugins: [new Ce({
1195
- key: It,
1196
- view: (r) => (t = new Ft(e, r, (e) => {
1201
+ prosemirrorPlugins: [new we({
1202
+ key: Lt,
1203
+ view: (r) => (t = new It(e, r, (e) => {
1197
1204
  n.setState({ ...e });
1198
1205
  }), t)
1199
1206
  })],
1200
1207
  blockDragStart(n, r) {
1201
- t && (t.isDragOrigin = !0), Mt(n, r, e);
1208
+ t && (t.isDragOrigin = !0), Nt(n, r, e);
1202
1209
  },
1203
1210
  blockDragEnd() {
1204
- jt(e.prosemirrorView.root), t && (t.isDragOrigin = !1), e.blur();
1211
+ Mt(e.prosemirrorView.root), t && (t.isDragOrigin = !1), e.blur();
1212
+ },
1213
+ get menuFrozen() {
1214
+ return t.menuFrozen;
1205
1215
  },
1206
1216
  freezeMenu() {
1207
1217
  t.menuFrozen = !0, t.state.show = !0, t.emitUpdate(t.state);
@@ -1214,7 +1224,7 @@ var Ft = class {
1214
1224
  }
1215
1225
  };
1216
1226
  }), G;
1217
- async function Rt() {
1227
+ async function zt() {
1218
1228
  return G || (G = (async () => {
1219
1229
  let [e, t] = await Promise.all([import("emoji-mart"), import("@emoji-mart/data")]), n = "default" in e ? e.default : e, r = "default" in t ? t.default : t;
1220
1230
  return await n.init({ data: r }), {
@@ -1223,9 +1233,9 @@ async function Rt() {
1223
1233
  };
1224
1234
  })(), G);
1225
1235
  }
1226
- async function zt(e, t) {
1227
- if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !== te.text) return [];
1228
- let { emojiData: n, emojiMart: r } = await Rt();
1236
+ async function Bt(e, t) {
1237
+ if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !== ee.text) return [];
1238
+ let { emojiData: n, emojiMart: r } = await zt();
1229
1239
  return (t.trim() === "" ? Object.values(n.emojis) : await r.SearchIndex.search(t)).map((t) => ({
1230
1240
  id: t.skins[0].native,
1231
1241
  onItemClick: () => e.insertInlineContent(t.skins[0].native + " ")
@@ -1234,16 +1244,16 @@ async function zt(e, t) {
1234
1244
  //#endregion
1235
1245
  //#region src/extensions/TableHandles/TableHandles.ts
1236
1246
  var K;
1237
- function Bt(e) {
1247
+ function Vt(e) {
1238
1248
  K || (K = document.createElement("div"), K.innerHTML = "_", K.style.opacity = "0", K.style.height = "1px", K.style.width = "1px", e instanceof Document ? e.body.appendChild(K) : e.appendChild(K));
1239
1249
  }
1240
- function Vt(e) {
1250
+ function Ht(e) {
1241
1251
  K &&= (e instanceof Document ? e.body.removeChild(K) : e.removeChild(K), void 0);
1242
1252
  }
1243
1253
  function q(e) {
1244
1254
  return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
1245
1255
  }
1246
- function Ht(e) {
1256
+ function Ut(e) {
1247
1257
  let t = e;
1248
1258
  for (; t && t.nodeName !== "TD" && t.nodeName !== "TH" && !t.classList.contains("tableWrapper");) {
1249
1259
  if (t.classList.contains("ProseMirror")) return;
@@ -1261,11 +1271,11 @@ function Ht(e) {
1261
1271
  tbodyNode: t.querySelector("tbody")
1262
1272
  };
1263
1273
  }
1264
- function Ut(e, t) {
1274
+ function Wt(e, t) {
1265
1275
  let n = t.querySelectorAll(e);
1266
1276
  for (let e = 0; e < n.length; e++) n[e].style.visibility = "hidden";
1267
1277
  }
1268
- var Wt = class {
1278
+ var Gt = class {
1269
1279
  editor;
1270
1280
  pmView;
1271
1281
  state;
@@ -1287,65 +1297,65 @@ var Wt = class {
1287
1297
  mouseUpHandler = (e) => {
1288
1298
  this.mouseState = "up", this.mouseMoveHandler(e);
1289
1299
  };
1290
- mouseMoveHandler = (e) => {
1291
- if (this.menuFrozen || this.mouseState === "selecting" || !(e.target instanceof Element) || !this.pmView.dom.contains(e.target)) return;
1292
- let t = Ht(e.target);
1293
- if (t?.type === "cell" && this.mouseState === "down" && !this.state?.draggingState) {
1300
+ mouseMoveHandler = (t) => {
1301
+ if (this.menuFrozen || this.mouseState === "selecting" || !(t.target instanceof Element) || !this.pmView.dom.contains(t.target)) return;
1302
+ let n = Ut(t.target);
1303
+ if (n?.type === "cell" && this.mouseState === "down" && !this.state?.draggingState) {
1294
1304
  this.mouseState = "selecting", this.state?.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
1295
1305
  return;
1296
1306
  }
1297
- if (!t || !this.editor.isEditable) {
1307
+ if (!n || !this.editor.isEditable) {
1298
1308
  this.state?.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
1299
1309
  return;
1300
1310
  }
1301
- if (!t.tbodyNode) return;
1302
- let n = t.tbodyNode.getBoundingClientRect(), r = A(t.domNode, this.pmView);
1303
- if (!r) return;
1304
- this.tableElement = r.node;
1305
- let i, { pmNodeInfo: a, doc: o } = this.editor.transact((e) => ({
1306
- pmNodeInfo: ee(r.id, e.doc),
1307
- doc: e.doc
1311
+ if (!n.tbodyNode) return;
1312
+ let r = n.tbodyNode.getBoundingClientRect(), i = at(n.domNode, this.pmView);
1313
+ if (!i) return;
1314
+ this.tableElement = i.node;
1315
+ let a, { pmNodeInfo: o, doc: s } = this.editor.transact((t) => ({
1316
+ pmNodeInfo: e(i.id, t.doc),
1317
+ doc: t.doc
1308
1318
  }));
1309
- if (!a) throw Error(`Block with ID ${r.id} not found`);
1310
- let s = _(a.node, o);
1311
- if (g(this.editor, "table") && (this.tablePos = a.posBeforeNode + 1, i = s), !i) return;
1312
- this.tableId = r.id;
1313
- let c = t.domNode.closest(".tableWrapper")?.querySelector(".table-widgets-container");
1314
- if (t?.type === "wrapper") {
1315
- let t = e.clientY >= n.bottom - 1 && e.clientY < n.bottom + 20, r = e.clientX >= n.right - 1 && e.clientX < n.right + 20, a = this.state?.block?.id !== i.id || e.clientX > n.right || e.clientY > n.bottom;
1319
+ if (!o) throw Error(`Block with ID ${i.id} not found`);
1320
+ let c = v(o.node, s);
1321
+ if (m(this.editor, "table") && (this.tablePos = o.posBeforeNode + 1, a = c), !a) return;
1322
+ this.tableId = i.id;
1323
+ let l = n.domNode.closest(".tableWrapper")?.querySelector(".table-widgets-container");
1324
+ if (n?.type === "wrapper") {
1325
+ let e = t.clientY >= r.bottom - 1 && t.clientY < r.bottom + 20, n = t.clientX >= r.right - 1 && t.clientX < r.right + 20, i = this.state?.block?.id !== a.id || t.clientX > r.right || t.clientY > r.bottom;
1316
1326
  this.state = {
1317
1327
  ...this.state,
1318
1328
  show: !0,
1319
- showAddOrRemoveRowsButton: t,
1320
- showAddOrRemoveColumnsButton: r,
1321
- referencePosTable: n,
1322
- block: i,
1323
- widgetContainer: c,
1324
- colIndex: a ? void 0 : this.state?.colIndex,
1325
- rowIndex: a ? void 0 : this.state?.rowIndex,
1326
- referencePosCell: a ? void 0 : this.state?.referencePosCell
1329
+ showAddOrRemoveRowsButton: e,
1330
+ showAddOrRemoveColumnsButton: n,
1331
+ referencePosTable: r,
1332
+ block: a,
1333
+ widgetContainer: l,
1334
+ colIndex: i ? void 0 : this.state?.colIndex,
1335
+ rowIndex: i ? void 0 : this.state?.rowIndex,
1336
+ referencePosCell: i ? void 0 : this.state?.referencePosCell
1327
1337
  };
1328
1338
  } else {
1329
- let e = q(t.domNode), a = q(t.domNode.parentElement), o = t.domNode.getBoundingClientRect();
1330
- if (this.state !== void 0 && this.state.show && this.tableId === r.id && this.state.rowIndex === a && this.state.colIndex === e) return;
1339
+ let e = q(n.domNode), t = q(n.domNode.parentElement), o = n.domNode.getBoundingClientRect();
1340
+ if (this.state !== void 0 && this.state.show && this.tableId === i.id && this.state.rowIndex === t && this.state.colIndex === e) return;
1331
1341
  this.state = {
1332
1342
  show: !0,
1333
- showAddOrRemoveColumnsButton: e === i.content.rows[0].cells.length - 1,
1334
- showAddOrRemoveRowsButton: a === i.content.rows.length - 1,
1335
- referencePosTable: n,
1336
- block: i,
1343
+ showAddOrRemoveColumnsButton: e === a.content.rows[0].cells.length - 1,
1344
+ showAddOrRemoveRowsButton: t === a.content.rows.length - 1,
1345
+ referencePosTable: r,
1346
+ block: a,
1337
1347
  draggingState: void 0,
1338
1348
  referencePosCell: o,
1339
1349
  colIndex: e,
1340
- rowIndex: a,
1341
- widgetContainer: c
1350
+ rowIndex: t,
1351
+ widgetContainer: l
1342
1352
  };
1343
1353
  }
1344
1354
  return this.emitUpdate(), !1;
1345
1355
  };
1346
1356
  dragOverHandler = (e) => {
1347
1357
  if (this.state?.draggingState === void 0) return;
1348
- e.preventDefault(), e.dataTransfer.dropEffect = "move", Ut(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline", this.pmView.root);
1358
+ e.preventDefault(), e.dataTransfer.dropEffect = "move", Wt(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline", this.pmView.root);
1349
1359
  let t = {
1350
1360
  left: Math.min(Math.max(e.clientX, this.state.referencePosTable.left + 1), this.state.referencePosTable.right - 1),
1351
1361
  top: Math.min(Math.max(e.clientY, this.state.referencePosTable.top + 1), this.state.referencePosTable.bottom - 1)
@@ -1362,9 +1372,9 @@ var Wt = class {
1362
1372
  e.preventDefault();
1363
1373
  let { draggingState: t, colIndex: n, rowIndex: r } = this.state;
1364
1374
  this.state.draggingState = void 0;
1365
- let a = this.state.block.content.columnWidths;
1375
+ let i = this.state.block.content.columnWidths;
1366
1376
  if (t.draggedCellOrientation === "row") {
1367
- if (!s(this.state.block, t.originalIndex, r)) return !1;
1377
+ if (!c(this.state.block, t.originalIndex, r)) return !1;
1368
1378
  let e = f(this.state.block, t.originalIndex, r);
1369
1379
  this.editor.updateBlock(this.state.block, {
1370
1380
  type: "table",
@@ -1374,13 +1384,13 @@ var Wt = class {
1374
1384
  }
1375
1385
  });
1376
1386
  } else {
1377
- if (!o(this.state.block, t.originalIndex, n)) return !1;
1378
- let e = i(this.state.block, t.originalIndex, n), [r] = a.splice(t.originalIndex, 1);
1379
- a.splice(n, 0, r), this.editor.updateBlock(this.state.block, {
1387
+ if (!a(this.state.block, t.originalIndex, n)) return !1;
1388
+ let e = u(this.state.block, t.originalIndex, n), [r] = i.splice(t.originalIndex, 1);
1389
+ i.splice(n, 0, r), this.editor.updateBlock(this.state.block, {
1380
1390
  type: "table",
1381
1391
  content: {
1382
1392
  ...this.state.block.content,
1383
- columnWidths: a,
1393
+ columnWidths: i,
1384
1394
  rows: e
1385
1395
  }
1386
1396
  });
@@ -1389,107 +1399,109 @@ var Wt = class {
1389
1399
  };
1390
1400
  update() {
1391
1401
  if (!this.state || !this.state.show) return;
1392
- if (this.state.block = this.editor.getBlock(this.state.block.id), !this.state.block || this.state.block.type !== "table" || !this.tableElement?.isConnected) {
1402
+ let e = this.editor.getBlock(this.state.block.id);
1403
+ if (!e || e.type !== "table" || !this.tableElement?.isConnected) {
1393
1404
  this.state = void 0, this.tableId = void 0, this.tableElement = void 0, this.emitUpdate();
1394
1405
  return;
1395
1406
  }
1396
- let { height: e, width: t } = p(this.state.block);
1397
- 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));
1398
- let n = this.tableElement.querySelector("tbody");
1399
- if (!n) throw Error("Table block does not contain a 'tbody' HTML element. This should never happen.");
1407
+ this.state.block = e;
1408
+ let { height: t, width: n } = r(this.state.block);
1409
+ this.state.rowIndex !== void 0 && this.state.colIndex !== void 0 && (this.state.rowIndex >= t && (this.state.rowIndex = t - 1), this.state.colIndex >= n && (this.state.colIndex = n - 1));
1410
+ let i = this.tableElement.querySelector("tbody");
1411
+ if (!i) throw Error("Table block does not contain a 'tbody' HTML element. This should never happen.");
1400
1412
  if (this.state.rowIndex !== void 0 && this.state.colIndex !== void 0) {
1401
- let e = n.children[this.state.rowIndex].children[this.state.colIndex];
1413
+ let e = i.children[this.state.rowIndex].children[this.state.colIndex];
1402
1414
  e ? this.state.referencePosCell = e.getBoundingClientRect() : (this.state.rowIndex = void 0, this.state.colIndex = void 0);
1403
1415
  }
1404
- this.state.referencePosTable = n.getBoundingClientRect(), this.emitUpdate();
1416
+ this.state.referencePosTable = i.getBoundingClientRect(), this.emitUpdate();
1405
1417
  }
1406
1418
  destroy() {
1407
1419
  this.pmView.dom.removeEventListener("mousemove", this.mouseMoveHandler), window.removeEventListener("mouseup", this.mouseUpHandler), this.pmView.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.pmView.root.removeEventListener("dragover", this.dragOverHandler), this.pmView.root.removeEventListener("drop", this.dropHandler);
1408
1420
  }
1409
- }, J = new w("TableHandlesPlugin"), Gt = b(({ editor: e }) => {
1410
- let t, i = y(void 0);
1421
+ }, J = new w("TableHandlesPlugin"), Kt = b(({ editor: e }) => {
1422
+ let r, o = y(void 0);
1411
1423
  return {
1412
1424
  key: "tableHandles",
1413
- store: i,
1425
+ store: o,
1414
1426
  prosemirrorPlugins: [new C({
1415
1427
  key: J,
1416
- view: (n) => (t = new Wt(e, n, (e) => {
1417
- i.setState(e?.block ? {
1428
+ view: (t) => (r = new Gt(e, t, (e) => {
1429
+ o.setState(e?.block ? {
1418
1430
  ...e,
1419
1431
  draggingState: e.draggingState ? { ...e.draggingState } : void 0
1420
1432
  } : void 0);
1421
- }), t),
1433
+ }), r),
1422
1434
  props: { decorations: (e) => {
1423
- if (t === void 0 || t.state === void 0 || t.state.draggingState === void 0 || t.tablePos === void 0) return;
1424
- let r = t.state.draggingState.draggedCellOrientation === "row" ? t.state.rowIndex : t.state.colIndex;
1425
- if (r === void 0) return;
1426
- let i = [], { block: a, draggingState: c } = t.state, { originalIndex: l, draggedCellOrientation: u } = c;
1427
- if (r === l || !a || u === "row" && !s(a, l, r) || u === "col" && !o(a, l, r)) return D.create(e.doc, i);
1428
- let d = e.doc.resolve(t.tablePos + 1);
1429
- return t.state.draggingState.draggedCellOrientation === "row" ? n(t.state.block, r).forEach(({ row: t, col: n }) => {
1430
- let a = e.doc.resolve(d.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(n) + 1), s = o.node(), c = o.pos + (r > l ? s.nodeSize - 2 : 0);
1435
+ if (r === void 0 || r.state === void 0 || r.state.draggingState === void 0 || r.tablePos === void 0) return;
1436
+ let n = r.state.draggingState.draggedCellOrientation === "row" ? r.state.rowIndex : r.state.colIndex;
1437
+ if (n === void 0) return;
1438
+ let i = [], { block: o, draggingState: s } = r.state, { originalIndex: l, draggedCellOrientation: u } = s;
1439
+ if (n === l || !o || u === "row" && !c(o, l, n) || u === "col" && !a(o, l, n)) return D.create(e.doc, i);
1440
+ let f = e.doc.resolve(r.tablePos + 1);
1441
+ return r.state.draggingState.draggedCellOrientation === "row" ? d(r.state.block, n).forEach(({ row: t, col: r }) => {
1442
+ let a = e.doc.resolve(f.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(r) + 1), s = o.node(), c = o.pos + (n > l ? s.nodeSize - 2 : 0);
1431
1443
  i.push(E.widget(c, () => {
1432
1444
  let e = document.createElement("div");
1433
- return e.className = "bn-table-drop-cursor", e.style.left = "0", e.style.right = "0", r > l ? e.style.bottom = "-2px" : e.style.top = "-3px", e.style.height = "4px", e;
1445
+ return e.className = "bn-table-drop-cursor", e.style.left = "0", e.style.right = "0", n > l ? e.style.bottom = "-2px" : e.style.top = "-3px", e.style.height = "4px", e;
1434
1446
  }));
1435
- }) : v(t.state.block, r).forEach(({ row: t, col: n }) => {
1436
- let a = e.doc.resolve(d.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(n) + 1), s = o.node(), c = o.pos + (r > l ? s.nodeSize - 2 : 0);
1447
+ }) : t(r.state.block, n).forEach(({ row: t, col: r }) => {
1448
+ let a = e.doc.resolve(f.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(r) + 1), s = o.node(), c = o.pos + (n > l ? s.nodeSize - 2 : 0);
1437
1449
  i.push(E.widget(c, () => {
1438
1450
  let e = document.createElement("div");
1439
- return e.className = "bn-table-drop-cursor", e.style.top = "0", e.style.bottom = "0", r > l ? e.style.right = "-2px" : e.style.left = "-3px", e.style.width = "4px", e;
1451
+ return e.className = "bn-table-drop-cursor", e.style.top = "0", e.style.bottom = "0", n > l ? e.style.right = "-2px" : e.style.left = "-3px", e.style.width = "4px", e;
1440
1452
  }));
1441
1453
  }), D.create(e.doc, i);
1442
1454
  } }
1443
1455
  })],
1444
- colDragStart(n) {
1445
- if (t === void 0 || t.state === void 0 || t.state.colIndex === void 0) throw Error("Attempted to drag table column, but no table block was hovered prior.");
1446
- t.state.draggingState = {
1456
+ colDragStart(t) {
1457
+ if (r === void 0 || r.state === void 0 || r.state.colIndex === void 0) throw Error("Attempted to drag table column, but no table block was hovered prior.");
1458
+ r.state.draggingState = {
1447
1459
  draggedCellOrientation: "col",
1448
- originalIndex: t.state.colIndex,
1449
- mousePos: n.clientX
1450
- }, t.emitUpdate(), e.transact((e) => e.setMeta(J, {
1451
- draggedCellOrientation: t.state.draggingState.draggedCellOrientation,
1452
- originalIndex: t.state.colIndex,
1453
- newIndex: t.state.colIndex,
1454
- tablePos: t.tablePos
1455
- })), !e.headless && (Bt(e.prosemirrorView.root), n.dataTransfer.setDragImage(K, 0, 0), n.dataTransfer.effectAllowed = "move");
1460
+ originalIndex: r.state.colIndex,
1461
+ mousePos: t.clientX
1462
+ }, r.emitUpdate(), e.transact((e) => e.setMeta(J, {
1463
+ draggedCellOrientation: r.state.draggingState.draggedCellOrientation,
1464
+ originalIndex: r.state.colIndex,
1465
+ newIndex: r.state.colIndex,
1466
+ tablePos: r.tablePos
1467
+ })), !e.headless && (Vt(e.prosemirrorView.root), t.dataTransfer.setDragImage(K, 0, 0), t.dataTransfer.effectAllowed = "move");
1456
1468
  },
1457
- rowDragStart(n) {
1458
- if (t.state === void 0 || t.state.rowIndex === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
1459
- t.state.draggingState = {
1469
+ rowDragStart(t) {
1470
+ if (r.state === void 0 || r.state.rowIndex === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
1471
+ r.state.draggingState = {
1460
1472
  draggedCellOrientation: "row",
1461
- originalIndex: t.state.rowIndex,
1462
- mousePos: n.clientY
1463
- }, t.emitUpdate(), e.transact((e) => e.setMeta(J, {
1464
- draggedCellOrientation: t.state.draggingState.draggedCellOrientation,
1465
- originalIndex: t.state.rowIndex,
1466
- newIndex: t.state.rowIndex,
1467
- tablePos: t.tablePos
1468
- })), !e.headless && (Bt(e.prosemirrorView.root), n.dataTransfer.setDragImage(K, 0, 0), n.dataTransfer.effectAllowed = "copyMove");
1473
+ originalIndex: r.state.rowIndex,
1474
+ mousePos: t.clientY
1475
+ }, r.emitUpdate(), e.transact((e) => e.setMeta(J, {
1476
+ draggedCellOrientation: r.state.draggingState.draggedCellOrientation,
1477
+ originalIndex: r.state.rowIndex,
1478
+ newIndex: r.state.rowIndex,
1479
+ tablePos: r.tablePos
1480
+ })), !e.headless && (Vt(e.prosemirrorView.root), t.dataTransfer.setDragImage(K, 0, 0), t.dataTransfer.effectAllowed = "copyMove");
1469
1481
  },
1470
1482
  dragEnd() {
1471
- if (t.state === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
1472
- t.state.draggingState = void 0, t.emitUpdate(), e.transact((e) => e.setMeta(J, null)), !e.headless && Vt(e.prosemirrorView.root);
1483
+ if (r.state === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
1484
+ r.state.draggingState = void 0, r.emitUpdate(), e.transact((e) => e.setMeta(J, null)), !e.headless && Ht(e.prosemirrorView.root);
1473
1485
  },
1474
1486
  freezeHandles() {
1475
- t.menuFrozen = !0;
1487
+ r.menuFrozen = !0;
1476
1488
  },
1477
1489
  unfreezeHandles() {
1478
- t.menuFrozen = !1;
1490
+ r.menuFrozen = !1;
1479
1491
  },
1480
1492
  hideHandlesIfNotFrozen() {
1481
- !t.menuFrozen && t.state?.show && (t.state.show = !1, t.state.showAddOrRemoveRowsButton = !1, t.state.showAddOrRemoveColumnsButton = !1, t.emitUpdate());
1493
+ !r.menuFrozen && r.state?.show && (r.state.show = !1, r.state.showAddOrRemoveRowsButton = !1, r.state.showAddOrRemoveColumnsButton = !1, r.emitUpdate());
1482
1494
  },
1483
1495
  getCellsAtRowHandle(e, t) {
1484
- return n(e, t);
1496
+ return d(e, t);
1485
1497
  },
1486
- getCellsAtColumnHandle(e, t) {
1487
- return v(e, t);
1498
+ getCellsAtColumnHandle(e, n) {
1499
+ return t(e, n);
1488
1500
  },
1489
- setCellSelection(e, n, r = n) {
1490
- if (!t) throw Error("Table handles view not initialized");
1491
- let i = e.doc.resolve(t.tablePos + 1), a = e.doc.resolve(i.posAtIndex(n.row) + 1), o = e.doc.resolve(a.posAtIndex(n.col)), s = e.doc.resolve(i.posAtIndex(r.row) + 1), c = e.doc.resolve(s.posAtIndex(r.col)), l = e.tr;
1492
- return l.setSelection(new me(o, c)), e.apply(l);
1501
+ setCellSelection(e, t, n = t) {
1502
+ if (!r) throw Error("Table handles view not initialized");
1503
+ let i = e.doc.resolve(r.tablePos + 1), a = e.doc.resolve(i.posAtIndex(t.row) + 1), o = e.doc.resolve(a.posAtIndex(t.col)), s = e.doc.resolve(i.posAtIndex(n.row) + 1), c = e.doc.resolve(s.posAtIndex(n.col)), l = e.tr;
1504
+ return l.setSelection(new he(o, c)), e.apply(l);
1493
1505
  },
1494
1506
  addRowOrColumn(t, n) {
1495
1507
  e.exec((e, r) => {
@@ -1500,33 +1512,36 @@ var Wt = class {
1500
1512
  row: 0,
1501
1513
  col: t
1502
1514
  });
1503
- return n.orientation === "row" ? n.side === "above" ? ve(i, r) : _e(i, r) : n.side === "left" ? ge(i, r) : he(i, r);
1515
+ return n.orientation === "row" ? n.side === "above" ? ye(i, r) : ve(i, r) : n.side === "left" ? _e(i, r) : ge(i, r);
1504
1516
  });
1505
1517
  },
1506
1518
  removeRowOrColumn(t, n) {
1507
- return n === "row" ? e.exec((e, n) => be(this.setCellSelection(e, {
1519
+ return n === "row" ? e.exec((e, n) => xe(this.setCellSelection(e, {
1508
1520
  row: t,
1509
1521
  col: 0
1510
- }), n)) : e.exec((e, n) => ye(this.setCellSelection(e, {
1522
+ }), n)) : e.exec((e, n) => be(this.setCellSelection(e, {
1511
1523
  row: 0,
1512
1524
  col: t
1513
1525
  }), n));
1514
1526
  },
1515
1527
  mergeCells(t) {
1516
- return e.exec((e, n) => xe(t ? this.setCellSelection(e, t.relativeStartCell, t.relativeEndCell) : e, n));
1528
+ return e.exec((e, n) => Se(t ? this.setCellSelection(e, t.relativeStartCell, t.relativeEndCell) : e, n));
1517
1529
  },
1518
1530
  splitCell(t) {
1519
- return e.exec((e, n) => Se(t ? this.setCellSelection(e, t) : e, n));
1531
+ return e.exec((e, n) => Ce(t ? this.setCellSelection(e, t) : e, n));
1520
1532
  },
1521
1533
  getCellSelection() {
1522
1534
  return e.transact((e) => {
1523
1535
  let t = e.selection, n = t.$from, r = t.$to;
1524
- if (m(t)) {
1536
+ if (_(t)) {
1525
1537
  let { ranges: e } = t;
1526
1538
  e.forEach((e) => {
1527
1539
  n = e.$from.min(n ?? e.$from), r = e.$to.max(r ?? e.$to);
1528
1540
  });
1529
- } else if (n = e.doc.resolve(t.$from.pos - t.$from.parentOffset - 1), r = e.doc.resolve(t.$to.pos - t.$to.parentOffset - 1), n.pos === 0 || r.pos === 0) return;
1541
+ } else {
1542
+ let i = t.$from.pos - t.$from.parentOffset - 1, a = t.$to.pos - t.$to.parentOffset - 1;
1543
+ if (i < 0 || a < 0 || (n = e.doc.resolve(i), r = e.doc.resolve(a), !p(n.parent) || !p(r.parent))) return;
1544
+ }
1530
1545
  let i = e.doc.resolve(n.pos - n.parentOffset - 1), a = e.doc.resolve(r.pos - r.parentOffset - 1), o = e.doc.resolve(i.pos - i.parentOffset - 1), s = n.index(i.depth), c = i.index(o.depth), l = r.index(a.depth), u = a.index(o.depth), d = [];
1531
1546
  for (let e = c; e <= u; e++) for (let t = s; t <= l; t++) d.push({
1532
1547
  row: e,
@@ -1547,40 +1562,53 @@ var Wt = class {
1547
1562
  },
1548
1563
  getMergeDirection(t) {
1549
1564
  return e.transact((e) => {
1550
- let n = m(e.selection) ? e.selection : void 0;
1565
+ let n = _(e.selection) ? e.selection : void 0;
1551
1566
  if (!n || !t || n.ranges.length <= 1) return;
1552
- let i = this.getCellSelection();
1553
- if (i) return r(i.from, i.to, t) ? "vertical" : "horizontal";
1567
+ let r = this.getCellSelection();
1568
+ if (r) return i(r.from, r.to, t) ? "vertical" : "horizontal";
1554
1569
  });
1555
1570
  },
1556
1571
  cropEmptyRowsOrColumns(e, t) {
1557
- return d(e, t);
1572
+ return ne(e, t);
1558
1573
  },
1559
- addRowsOrColumns(e, t, n) {
1560
- return u(e, t, n);
1574
+ addRowsOrColumns(e, t, r) {
1575
+ return n(e, t, r);
1561
1576
  }
1562
1577
  };
1563
1578
  }), Y = new w("trailingNode");
1564
- function Kt(e, t) {
1565
- if (!t) return !1;
1566
- let n = e.lastChild?.lastChild, r = n?.firstChild;
1567
- return !(n?.type.name === "blockContainer" && r?.type.name === "paragraph" && r.content.size === 0);
1579
+ function X(e) {
1580
+ let t = e.lastChild, n = t?.firstChild;
1581
+ return !(t?.type.name === "blockContainer" && n?.type.name === "paragraph" && n.content.size === 0);
1582
+ }
1583
+ function qt(e) {
1584
+ if (!e.type.schema.nodes.column) {
1585
+ let t = e.lastChild;
1586
+ return t && X(t) ? [e.content.size - 1] : [];
1587
+ }
1588
+ let t = [];
1589
+ return e.descendants((e, n, r) => e.isTextblock ? !1 : ((e.type.name === "column" || e.type.name === "blockGroup" && r?.type.name === "doc") && X(e) && t.push(n + e.nodeSize - 1), !0)), t;
1568
1590
  }
1569
- var qt = b(({ editor: e }) => {
1591
+ var Jt = b(({ editor: e }) => {
1570
1592
  function t(t) {
1571
1593
  return E.widget(t, () => {
1572
1594
  let t = document.createElement("div");
1573
- return t.className = "bn-trailing-block", t.contentEditable = "false", t.addEventListener("mousedown", (t) => {
1574
- t.preventDefault(), e.transact((t) => {
1575
- let [n] = e.insertBlocks([{ type: "paragraph" }], e.document[e.document.length - 1], "after");
1595
+ return t.className = "bn-trailing-block", t.contentEditable = "false", t.addEventListener("mousedown", (n) => {
1596
+ n.preventDefault();
1597
+ let r = e.prosemirrorView;
1598
+ if (!r) return;
1599
+ let i = r.state.doc.resolve(r.posAtDOM(t, 0)).parent.lastChild?.attrs.id;
1600
+ i && (e.transact((t) => {
1601
+ let [n] = e.insertBlocks([{ type: "paragraph" }], i, "after");
1576
1602
  e.setTextCursorPosition(n, "start"), t.scrollIntoView();
1577
- }), e.prosemirrorView?.focus();
1603
+ }), r.focus());
1578
1604
  }), t;
1579
1605
  }, { side: 1 });
1580
1606
  }
1581
1607
  function n(e, n, r) {
1582
- let i = n.map(e.mapping, e.doc), a = i.find(), o = a.length > 0;
1583
- return o === Kt(e.doc, r) ? i : o ? i.remove(a) : i.add(e.doc, [t(e.doc.content.size - 1)]);
1608
+ let i = n.map(e.mapping, e.doc), a = new Set(r ? qt(e.doc) : []), o = /* @__PURE__ */ new Set(), s = [];
1609
+ for (let e of i.find()) a.has(e.from) && !o.has(e.from) ? o.add(e.from) : s.push(e);
1610
+ let c = [...a].filter((e) => !o.has(e)), l = i;
1611
+ return s.length > 0 && (l = l.remove(s)), c.length > 0 && (l = l.add(e.doc, c.map(t))), l;
1584
1612
  }
1585
1613
  return {
1586
1614
  key: "trailingNode",
@@ -1603,21 +1631,23 @@ var qt = b(({ editor: e }) => {
1603
1631
  let { selection: r } = t.state;
1604
1632
  if (!r.empty) return !1;
1605
1633
  let i = T.atEnd(t.state.doc);
1606
- return r.$head.pos !== i.$head.pos || !Kt(t.state.doc, e.isEditable) ? !1 : (n.preventDefault(), !0);
1634
+ if (r.$head.pos !== i.$head.pos) return !1;
1635
+ let a = t.state.doc.lastChild;
1636
+ return !e.isEditable || !a || !X(a) ? !1 : (n.preventDefault(), !0);
1607
1637
  }
1608
1638
  }
1609
1639
  })]
1610
1640
  };
1611
- }), X = Symbol("bn-current-version");
1612
- function Z(e) {
1641
+ }), Z = Symbol("bn-current-version");
1642
+ function Q(e) {
1613
1643
  return [...e].sort((e, t) => t.createdAt - e.createdAt);
1614
1644
  }
1615
- function Q(e) {
1645
+ function $(e) {
1616
1646
  let t = typeof e == "object" ? e.id : e;
1617
1647
  throw Error(`Snapshot not found: ${String(t)}`);
1618
1648
  }
1619
- var Jt = b(({ options: e, editor: t }) => {
1620
- let { endpoints: n, preview: r, getCurrentDocument: i, serializeCurrentContent: a, resolveUsers: o } = typeof e == "function" ? e(t) : e, s = typeof n == "function" ? n(t) : n, c = ne(o), l = y({
1649
+ var Yt = b(({ options: e, editor: t }) => {
1650
+ let { endpoints: n, preview: r, getCurrentDocument: i, serializeCurrentContent: a, resolveUsers: o } = typeof e == "function" ? e(t) : e, s = typeof n == "function" ? n(t) : n, c = re(o), l = y({
1621
1651
  snapshots: [],
1622
1652
  previewedSnapshotId: void 0,
1623
1653
  compareToSnapshotId: void 0
@@ -1625,14 +1655,14 @@ var Jt = b(({ options: e, editor: t }) => {
1625
1655
  let t = typeof e == "object" ? e.id : e;
1626
1656
  return l.state.snapshots.find((e) => e.id === t);
1627
1657
  }, d = async () => {
1628
- let e = Z(await s.list());
1658
+ let e = Q(await s.list());
1629
1659
  return l.setState((t) => ({
1630
1660
  ...t,
1631
1661
  snapshots: e
1632
1662
  })), e;
1633
1663
  }, f = async (e, t) => {
1634
1664
  let n = u(e);
1635
- n || Q(e);
1665
+ n || $(e);
1636
1666
  let i = t?.compareTo ? u(t.compareTo) : void 0;
1637
1667
  l.setState((e) => ({
1638
1668
  ...e,
@@ -1651,11 +1681,11 @@ var Jt = b(({ options: e, editor: t }) => {
1651
1681
  let t = e?.compareTo ? u(e.compareTo) : void 0;
1652
1682
  l.setState((e) => ({
1653
1683
  ...e,
1654
- previewedSnapshotId: X,
1684
+ previewedSnapshotId: Z,
1655
1685
  compareToSnapshotId: t?.id
1656
1686
  }));
1657
1687
  let n = {
1658
- id: X,
1688
+ id: Z,
1659
1689
  createdAt: Date.now(),
1660
1690
  updatedAt: Date.now()
1661
1691
  }, i, o;
@@ -1688,26 +1718,26 @@ var Jt = b(({ options: e, editor: t }) => {
1688
1718
  });
1689
1719
  l.setState((e) => ({
1690
1720
  ...e,
1691
- snapshots: Z([...e.snapshots, t])
1721
+ snapshots: Q([...e.snapshots, t])
1692
1722
  }));
1693
1723
  let n = await s.list();
1694
1724
  return l.setState((e) => ({
1695
1725
  ...e,
1696
- snapshots: Z(n.some((e) => e.id === t.id) ? n : [...n, t])
1726
+ snapshots: Q(n.some((e) => e.id === t.id) ? n : [...n, t])
1697
1727
  })), t;
1698
1728
  } : void 0,
1699
1729
  canRestore: s.restore !== void 0,
1700
1730
  restore: s.restore ? async (e) => {
1701
1731
  m();
1702
1732
  let t = u(e);
1703
- t || Q(e);
1733
+ t || $(e);
1704
1734
  let n = await s.restore(i(), t);
1705
1735
  return r.applyRestore(n), await d(), n;
1706
1736
  } : void 0,
1707
1737
  canRename: s.rename !== void 0,
1708
1738
  rename: s.rename ? async (e, t) => {
1709
1739
  let n = u(e);
1710
- n || Q(e), await s.rename(n, t), l.setState((n) => ({
1740
+ n || $(e), await s.rename(n, t), l.setState((n) => ({
1711
1741
  ...n,
1712
1742
  snapshots: n.snapshots.map((n) => n.id === e ? {
1713
1743
  ...n,
@@ -1719,7 +1749,7 @@ var Jt = b(({ options: e, editor: t }) => {
1719
1749
  canRemove: s.remove !== void 0,
1720
1750
  remove: s.remove ? async (e) => {
1721
1751
  let t = u(e);
1722
- t || Q(e), (l.state.previewedSnapshotId === t.id || l.state.compareToSnapshotId === t.id) && m(), await s.remove(t), l.setState((e) => ({
1752
+ t || $(e), (l.state.previewedSnapshotId === t.id || l.state.compareToSnapshotId === t.id) && m(), await s.remove(t), l.setState((e) => ({
1723
1753
  ...e,
1724
1754
  snapshots: e.snapshots.filter((e) => e.id !== t.id)
1725
1755
  })), await d();
@@ -1732,10 +1762,10 @@ var Jt = b(({ options: e, editor: t }) => {
1732
1762
  });
1733
1763
  //#endregion
1734
1764
  //#region src/extensions/Versioning/inMemoryVersioning.ts
1735
- function Yt(e) {
1736
- return e.id === X ? "Current version" : e.name ?? "Unnamed version";
1737
- }
1738
1765
  function Xt(e) {
1766
+ return e.id === Z ? "Current version" : e.name ?? "Unnamed version";
1767
+ }
1768
+ function Zt(e) {
1739
1769
  let t, n = !1, r = (t) => {
1740
1770
  e.replaceBlocks(e.document, t);
1741
1771
  }, i = () => e.getExtension("diffVersioning");
@@ -1747,7 +1777,7 @@ function Xt(e) {
1747
1777
  t === void 0 && (t = e.document);
1748
1778
  let l = i();
1749
1779
  if (o && l) {
1750
- l.renderDiff(a, o, c && Yt(c.snapshot)), n = !0;
1780
+ l.renderDiff(a, o, c && Xt(c.snapshot)), n = !0;
1751
1781
  return;
1752
1782
  }
1753
1783
  n = !1, r(a);
@@ -1764,11 +1794,11 @@ function Xt(e) {
1764
1794
  }
1765
1795
  };
1766
1796
  }
1767
- function $() {
1797
+ function Qt() {
1768
1798
  let e = [], t = /* @__PURE__ */ new Map(), n = 1;
1769
1799
  return {
1770
1800
  async list() {
1771
- return Z([...e]);
1801
+ return Q([...e]);
1772
1802
  },
1773
1803
  async create(r, i) {
1774
1804
  let a = Date.now(), o = String(n++), s = {
@@ -1808,23 +1838,23 @@ function $() {
1808
1838
  }
1809
1839
  };
1810
1840
  }
1811
- function Zt(e) {
1812
- let t = $();
1841
+ function $t(e) {
1842
+ let t = Qt();
1813
1843
  return {
1814
1844
  endpoints: {
1815
1845
  ...t,
1816
1846
  list: async () => [{
1817
- id: X,
1847
+ id: Z,
1818
1848
  createdAt: Date.now(),
1819
1849
  updatedAt: Date.now()
1820
1850
  }, ...await t.list()]
1821
1851
  },
1822
- preview: Xt(e),
1852
+ preview: Zt(e),
1823
1853
  getCurrentDocument: () => e.document,
1824
1854
  serializeCurrentContent: () => e.document
1825
1855
  };
1826
1856
  }
1827
1857
  //#endregion
1828
- export { k as A, Ye as C, Ke as D, Ge as E, ze as O, Xe as S, qe as T, V as _, Jt as a, et as b, Gt as c, zt as d, Lt as f, Dt as g, Ot as h, X as i, Re as k, Wt as l, It as m, Zt as n, Z as o, Ft as p, $ as r, qt as s, Xt as t, J as u, it as v, Je as w, Qe as x, tt as y };
1858
+ export { k as A, Ye as C, Ke as D, Ge as E, ze as O, Xe as S, qe as T, V as _, Yt as a, et as b, Kt as c, Bt as d, Rt as f, Ot as g, kt as h, Z as i, Re as k, Gt as l, Lt as m, $t as n, Q as o, It as p, Qt as r, Jt as s, Zt as t, J as u, it as v, Je as w, Qe as x, tt as y };
1829
1859
 
1830
- //# sourceMappingURL=extensions-CrUGDOks.js.map
1860
+ //# sourceMappingURL=extensions-BR5hkAio.js.map