@blocknote/core 0.50.0 → 0.51.1

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 (103) hide show
  1. package/dist/blocknote.cjs +1 -1
  2. package/dist/blocknote.js +4 -4
  3. package/dist/{blocks-UU7EM-QM.js → blocks-D0lMxErU.js} +397 -368
  4. package/dist/blocks-D0lMxErU.js.map +1 -0
  5. package/dist/blocks-KyMOxPT3.cjs +11 -0
  6. package/dist/blocks-KyMOxPT3.cjs.map +1 -0
  7. package/dist/blocks.cjs +1 -1
  8. package/dist/blocks.js +2 -2
  9. package/dist/extensions-Cutrafjg.cjs +52 -0
  10. package/dist/extensions-Cutrafjg.cjs.map +1 -0
  11. package/dist/{extensions-CkLT--Nc.js → extensions-D2mx2C9y.js} +622 -353
  12. package/dist/extensions-D2mx2C9y.js.map +1 -0
  13. package/dist/extensions.cjs +1 -1
  14. package/dist/extensions.js +3 -3
  15. package/dist/locales.cjs +1 -1
  16. package/dist/locales.cjs.map +1 -1
  17. package/dist/locales.js +1 -1
  18. package/dist/locales.js.map +1 -1
  19. package/dist/src-D5R5YzV7.cjs +21 -0
  20. package/dist/src-D5R5YzV7.cjs.map +1 -0
  21. package/dist/{src-SVFpMAWE.js → src-Dvmif2FY.js} +1070 -564
  22. package/dist/src-Dvmif2FY.js.map +1 -0
  23. package/dist/style.css +1 -1
  24. package/dist/webpack-stats.json +1 -1
  25. package/dist/yjs.cjs +1 -1
  26. package/dist/yjs.js +8 -8
  27. package/package.json +1 -13
  28. package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +7 -7
  29. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +5 -3
  30. package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +5 -5
  31. package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +2550 -291
  32. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +83 -2
  33. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +103 -42
  34. package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +0 -143
  35. package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +12 -12
  36. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +5 -3
  37. package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +6 -6
  38. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +22 -22
  39. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +12 -8
  40. package/src/api/blockManipulation/setupTestEnv.ts +1 -1
  41. package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +2 -6
  42. package/src/api/clipboard/fromClipboard/pasteExtension.ts +7 -2
  43. package/src/api/clipboard/toClipboard/copyExtension.ts +12 -1
  44. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +12 -4
  45. package/src/api/exporters/markdown/htmlToMarkdown.ts +813 -0
  46. package/src/api/exporters/markdown/markdownExporter.ts +2 -21
  47. package/src/api/nodeConversions/blockToNode.ts +3 -2
  48. package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +122 -107
  49. package/src/api/parsers/html/util/nestedLists.test.ts +1 -12
  50. package/src/api/parsers/markdown/markdownToHtml.ts +1194 -0
  51. package/src/api/parsers/markdown/parseMarkdown.ts +2 -101
  52. package/src/blocks/Audio/block.ts +1 -4
  53. package/src/blocks/Code/block.test.ts +258 -0
  54. package/src/blocks/File/block.ts +1 -4
  55. package/src/blocks/File/helpers/render/createFileBlockWrapper.ts +7 -2
  56. package/src/blocks/Image/block.ts +9 -6
  57. package/src/blocks/ListItem/BulletListItem/block.ts +7 -4
  58. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +3 -4
  59. package/src/blocks/Video/block.ts +4 -5
  60. package/src/blocks/Video/parseVideoElement.ts +2 -1
  61. package/src/editor/Block.css +8 -0
  62. package/src/editor/BlockNoteEditor.test.ts +10 -4
  63. package/src/editor/BlockNoteEditor.ts +30 -13
  64. package/src/editor/managers/BlockManager.ts +10 -6
  65. package/src/editor/managers/ExtensionManager/index.ts +80 -25
  66. package/src/editor/performance.test.ts +2 -2
  67. package/src/editor/transformPasted.test.ts +295 -0
  68. package/src/editor/transformPasted.ts +77 -0
  69. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +1 -12
  70. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +0 -11
  71. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -1
  72. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -1
  73. package/src/extensions/SideMenu/dragging.ts +7 -10
  74. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +21 -0
  75. package/src/extensions/TrailingNode/TrailingNode.ts +124 -65
  76. package/src/i18n/locales/fr.ts +1 -1
  77. package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.d.ts +13 -2
  78. package/types/src/api/clipboard/fromClipboard/handleVSCodePaste.d.ts +1 -1
  79. package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +1 -0
  80. package/types/src/api/exporters/markdown/htmlToMarkdown.d.ts +11 -0
  81. package/types/src/api/parsers/markdown/markdownToHtml.d.ts +5 -0
  82. package/types/src/blocks/Code/block.test.d.ts +1 -0
  83. package/types/src/blocks/Video/block.d.ts +2 -0
  84. package/types/src/blocks/Video/parseVideoElement.d.ts +1 -0
  85. package/types/src/editor/BlockNoteEditor.d.ts +20 -6
  86. package/types/src/editor/managers/BlockManager.d.ts +8 -4
  87. package/types/src/editor/transformPasted.test.d.ts +1 -0
  88. package/types/src/extensions/TrailingNode/TrailingNode.d.ts +8 -3
  89. package/dist/blocks-BFnTypT-.cjs +0 -11
  90. package/dist/blocks-BFnTypT-.cjs.map +0 -1
  91. package/dist/blocks-UU7EM-QM.js.map +0 -1
  92. package/dist/extensions-CYsFi5Is.cjs +0 -2
  93. package/dist/extensions-CYsFi5Is.cjs.map +0 -1
  94. package/dist/extensions-CkLT--Nc.js.map +0 -1
  95. package/dist/src-DsJ6yzs9.cjs +0 -5
  96. package/dist/src-DsJ6yzs9.cjs.map +0 -1
  97. package/dist/src-SVFpMAWE.js.map +0 -1
  98. package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +0 -42
  99. package/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.ts +0 -19
  100. package/src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.ts +0 -39
  101. package/types/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.d.ts +0 -7
  102. package/types/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.d.ts +0 -2
  103. package/types/src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.d.ts +0 -6
@@ -1,42 +1,35 @@
1
- import { At as e, Bt as t, Dt as n, Et as r, Ft as i, It as a, Lt as o, Mt as s, Nt as c, Pt as l, Rn as u, Rt as d, an as f, dn as p, g as m, h, ht as g, in as _, jt as ee, kt as v, r as te, zt as ne } from "./blocks-UU7EM-QM.js";
2
- import { n as y, t as b } from "./BlockNoteExtension-B6RhuQ3V.js";
3
- import { DOMSerializer as x, Fragment as S, Slice as re } from "prosemirror-model";
4
- import { dropPoint as ie } from "prosemirror-transform";
5
- import { combineTransactionSteps as ae, findChildrenInRange as C, posToDOMRect as oe } from "@tiptap/core";
6
- import { NodeSelection as se, Plugin as w, PluginKey as T, Selection as E, TextSelection as ce } from "prosemirror-state";
7
- import { uuidv4 as le } from "lib0/random";
8
- import { DOMParser as ue, Slice as de } from "@tiptap/pm/model";
9
- import { CellSelection as fe, addColumnAfter as pe, addColumnBefore as me, addRowAfter as he, addRowBefore as ge, deleteColumn as _e, deleteRow as ve, mergeCells as ye, splitCell as be } from "prosemirror-tables";
10
- import { Plugin as D, PluginKey as O, TextSelection as xe } from "@tiptap/pm/state";
11
- import { Decoration as k, DecorationSet as A } from "prosemirror-view";
12
- import { defaultSelectionBuilder as Se, redoCommand as Ce, undoCommand as we, yCursorPlugin as Te, ySyncPlugin as Ee, yUndoPlugin as De, yUndoPluginKey as j } from "y-prosemirror";
13
- import Oe from "fast-deep-equal";
14
- import * as M from "yjs";
15
- import { history as ke, redo as Ae, undo as je } from "@tiptap/pm/history";
16
- import Me from "rehype-parse";
17
- import Ne from "rehype-remark";
18
- import Pe from "remark-gfm";
19
- import Fe from "remark-stringify";
20
- import { unified as Ie } from "unified";
21
- import { fromDom as Le } from "hast-util-from-dom";
22
- import { visit as Re } from "unist-util-visit";
1
+ import { At as e, Bt as t, Dt as n, Ft as r, It as i, Lt as a, Mt as o, Nt as s, Ot as c, Pt as l, Rt as u, Vt as d, _ as f, an as p, fn as m, g as h, gt as g, jt as ee, on as te, r as ne, zn as re, zt as ie } from "./blocks-D0lMxErU.js";
2
+ import { n as _, t as v } from "./BlockNoteExtension-B6RhuQ3V.js";
3
+ import { DOMSerializer as ae, Fragment as y, Slice as oe } from "prosemirror-model";
4
+ import { dropPoint as se } from "prosemirror-transform";
5
+ import { combineTransactionSteps as ce, findChildrenInRange as le, posToDOMRect as ue } from "@tiptap/core";
6
+ import { NodeSelection as de, Plugin as b, PluginKey as x, Selection as S, TextSelection as fe } from "prosemirror-state";
7
+ import { uuidv4 as pe } from "lib0/random";
8
+ import { DOMParser as me, Slice as he } from "@tiptap/pm/model";
9
+ import { CellSelection as ge, addColumnAfter as _e, addColumnBefore as ve, addRowAfter as ye, addRowBefore as be, deleteColumn as xe, deleteRow as Se, mergeCells as Ce, splitCell as we } from "prosemirror-tables";
10
+ import { Plugin as C, PluginKey as Te, TextSelection as Ee } from "@tiptap/pm/state";
11
+ import { Decoration as w, DecorationSet as T } from "prosemirror-view";
12
+ import { defaultSelectionBuilder as De, redoCommand as Oe, undoCommand as ke, yCursorPlugin as Ae, ySyncPlugin as je, yUndoPlugin as Me, yUndoPluginKey as E } from "y-prosemirror";
13
+ import Ne from "fast-deep-equal";
14
+ import * as D from "yjs";
15
+ import { history as Pe, redo as Fe, undo as Ie } from "@tiptap/pm/history";
23
16
  //#region src/api/exporters/html/util/serializeBlocksExternalHTML.ts
24
- function N(e) {
17
+ function Le(e) {
25
18
  let t = Array.from(e.classList).filter((e) => !e.startsWith("bn-")) || [];
26
19
  t.length > 0 ? e.className = t.join(" ") : e.removeAttribute("class");
27
20
  }
28
- function P(t, n, r, i) {
21
+ function Re(t, n, r, i) {
29
22
  let a;
30
23
  if (!n) throw Error("blockContent is required");
31
- if (typeof n == "string") a = v([n], t.pmSchema);
32
- else if (Array.isArray(n)) a = v(n, t.pmSchema);
33
- else if (n.type === "tableContent") a = e(n, t.pmSchema);
34
- else throw new u(n.type);
24
+ if (typeof n == "string") a = e([n], t.pmSchema, i?.blockType);
25
+ else if (Array.isArray(n)) a = e(n, t.pmSchema, i?.blockType);
26
+ else if (n.type === "tableContent") a = ee(n, t.pmSchema);
27
+ else throw new re(n.type);
35
28
  let o = (i?.document ?? document).createDocumentFragment();
36
29
  for (let e of a) if (e.type.name !== "text" && t.schema.inlineContentSchema[e.type.name]) {
37
30
  let n = t.schema.inlineContentSpecs[e.type.name].implementation;
38
31
  if (n) {
39
- let a = f(e, t.schema.inlineContentSchema, t.schema.styleSchema), s = n.toExternalHTML ? n.toExternalHTML(a, t) : n.render.call({
32
+ let a = te(e, t.schema.inlineContentSchema, t.schema.styleSchema), s = n.toExternalHTML ? n.toExternalHTML(a, t) : n.render.call({
40
33
  renderType: "dom",
41
34
  props: void 0
42
35
  }, a, () => {}, t);
@@ -54,15 +47,15 @@ function P(t, n, r, i) {
54
47
  let e = (t.schema.styleSpecs[r.type.name].implementation.toExternalHTML ?? t.schema.styleSpecs[r.type.name].implementation.render)(r.attrs.stringValue, t);
55
48
  e.contentDOM.appendChild(n), n = e.dom;
56
49
  } else {
57
- let e = r.type.spec.toDOM(r, !0), t = x.renderSpec(document, e);
50
+ let e = r.type.spec.toDOM(r, !0), t = ae.renderSpec(document, e);
58
51
  t.contentDOM.appendChild(n), n = t.dom;
59
52
  }
60
53
  o.appendChild(n);
61
54
  } else {
62
- let t = r.serializeFragment(S.from([e]), i);
55
+ let t = r.serializeFragment(y.from([e]), i);
63
56
  o.appendChild(t);
64
57
  }
65
- return o.childNodes.length === 1 && o.firstChild?.nodeType === 1 && N(o.firstChild), o;
58
+ return o.childNodes.length === 1 && o.firstChild?.nodeType === 1 && Le(o.firstChild), o;
66
59
  }
67
60
  function ze(e, t, n, r, i, a, o, s) {
68
61
  let c = s?.document ?? document, l = t.pmSchema.nodes.blockContainer, u = n.props || {};
@@ -80,10 +73,13 @@ function ze(e, t, n, r, i, a, o, s) {
80
73
  if (m.dom.classList.contains("bn-block-content")) {
81
74
  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");
82
75
  for (let t of e) m.dom.firstChild.setAttribute(t.name, t.value);
83
- N(m.dom.firstChild), o > 0 && m.dom.firstChild.setAttribute("data-nesting-level", o.toString()), h.append(...Array.from(m.dom.childNodes));
76
+ Le(m.dom.firstChild), o > 0 && m.dom.firstChild.setAttribute("data-nesting-level", o.toString()), h.append(...Array.from(m.dom.childNodes));
84
77
  } else h.append(m.dom), o > 0 && m.dom.setAttribute("data-nesting-level", o.toString());
85
78
  if (m.contentDOM && n.content) {
86
- let e = P(t, n.content, r, s);
79
+ let e = Re(t, n.content, r, {
80
+ ...s,
81
+ blockType: n.type
82
+ });
87
83
  m.contentDOM.appendChild(e);
88
84
  }
89
85
  let g;
@@ -96,20 +92,20 @@ function ze(e, t, n, r, i, a, o, s) {
96
92
  } else e.append(h);
97
93
  if (n.children && n.children.length > 0) {
98
94
  let l = c.createDocumentFragment();
99
- if (F(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
+ if (Be(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);
100
96
  "childrenDOM" in m && m.childrenDOM ? m.childrenDOM.append(l) : t.pmSchema.nodes[n.type].isInGroup("blockContent") ? e.append(l) : m.contentDOM?.append(l);
101
97
  }
102
98
  }
103
- var F = (e, t, n, r, i, a, o = 0, s) => {
99
+ var Be = (e, t, n, r, i, a, o = 0, s) => {
104
100
  for (let c of n) ze(e, t, c, r, i, a, o, s);
105
- }, Be = (e, t, n, r, i, a) => {
101
+ }, Ve = (e, t, n, r, i, a) => {
106
102
  let o = (a?.document ?? document).createDocumentFragment();
107
- return F(o, e, t, n, r, i, 0, a), o;
108
- }, I = (e, t) => {
109
- let n = x.fromSchema(e);
103
+ return Be(o, e, t, n, r, i, 0, a), o;
104
+ }, O = (e, t) => {
105
+ let n = ae.fromSchema(e);
110
106
  return {
111
107
  exportBlocks: (e, r) => {
112
- let i = Be(t, e, n, new Set(["numberedListItem"]), new Set([
108
+ let i = Ve(t, e, n, new Set(["numberedListItem"]), new Set([
113
109
  "bulletListItem",
114
110
  "checkListItem",
115
111
  "toggleListItem"
@@ -117,41 +113,41 @@ var F = (e, t, n, r, i, a, o = 0, s) => {
117
113
  return a.append(i), a.innerHTML;
118
114
  },
119
115
  exportInlineContent: (e, r) => {
120
- let i = P(t, e, n, r), a = document.createElement("div");
116
+ let i = Re(t, e, n, r), a = document.createElement("div");
121
117
  return a.append(i.cloneNode(!0)), a.innerHTML;
122
118
  }
123
119
  };
124
120
  };
125
121
  //#endregion
126
122
  //#region src/api/getBlocksChangedByTransaction.ts
127
- function Ve(e, t) {
123
+ function He(e, t) {
128
124
  if (t === 0) return;
129
- let r = e.resolve(t);
130
- for (let e = r.depth; e > 0; e--) {
131
- let t = r.node(e);
132
- if (n(t)) return t.attrs.id;
125
+ let n = e.resolve(t);
126
+ for (let e = n.depth; e > 0; e--) {
127
+ let t = n.node(e);
128
+ if (c(t)) return t.attrs.id;
133
129
  }
134
130
  }
135
- function He(e) {
131
+ function Ue(e) {
136
132
  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" };
137
133
  }
138
- function L(e) {
139
- let t = {}, r = {}, i = p(e);
140
- return e.descendants((a, o) => {
141
- if (!n(a)) return !0;
142
- let s = Ve(e, o), c = s ?? "__root__";
143
- r[c] || (r[c] = []);
144
- let l = _(a, i);
145
- return t[a.attrs.id] = {
134
+ function We(e) {
135
+ let t = {}, n = {}, r = m(e);
136
+ return e.descendants((i, a) => {
137
+ if (!c(i)) return !0;
138
+ let o = He(e, a), s = o ?? "__root__";
139
+ n[s] || (n[s] = []);
140
+ let l = p(i, r);
141
+ return t[i.attrs.id] = {
146
142
  block: l,
147
- parentId: s
148
- }, r[c].push(a.attrs.id), !0;
143
+ parentId: o
144
+ }, n[s].push(i.attrs.id), !0;
149
145
  }), {
150
146
  byId: t,
151
- childrenByParent: r
147
+ childrenByParent: n
152
148
  };
153
149
  }
154
- function Ue(e, t) {
150
+ function Ge(e, t) {
155
151
  let n = /* @__PURE__ */ new Set();
156
152
  if (!e || !t) return n;
157
153
  let r = new Set(e), i = t.filter((e) => r.has(e)), a = e.filter((e) => i.includes(e));
@@ -175,8 +171,8 @@ function Ue(e, t) {
175
171
  for (let e = 0; e < i.length; e++) p.has(e) || n.add(i[e]);
176
172
  return n;
177
173
  }
178
- function R(e, t = []) {
179
- let n = He(e), r = ae(e.before, [e, ...t]), i = L(r.before), a = L(r.doc), o = [], s = /* @__PURE__ */ new Set();
174
+ function Ke(e, t = []) {
175
+ let n = Ue(e), r = ce(e.before, [e, ...t]), i = We(r.before), a = We(r.doc), o = [], s = /* @__PURE__ */ new Set();
180
176
  Object.keys(a.byId).filter((e) => !(e in i.byId)).forEach((e) => {
181
177
  o.push({
182
178
  type: "insert",
@@ -193,7 +189,7 @@ function R(e, t = []) {
193
189
  }), s.add(e);
194
190
  }), Object.keys(a.byId).filter((e) => e in i.byId).forEach((e) => {
195
191
  let t = i.byId[e], r = a.byId[e];
196
- t.parentId === r.parentId ? Oe({
192
+ t.parentId === r.parentId ? Ne({
197
193
  ...t.block,
198
194
  children: void 0
199
195
  }, {
@@ -215,7 +211,7 @@ function R(e, t = []) {
215
211
  });
216
212
  let c = i.childrenByParent, l = a.childrenByParent, u = new Set([...Object.keys(c), ...Object.keys(l)]), d = /* @__PURE__ */ new Set();
217
213
  return u.forEach((e) => {
218
- let t = Ue(c[e], l[e]);
214
+ let t = Ge(c[e], l[e]);
219
215
  t.size !== 0 && t.forEach((t) => {
220
216
  let r = i.byId[t], c = a.byId[t];
221
217
  !r || !c || r.parentId === c.parentId && (s.has(t) || (r.parentId ?? "__root__") === e && (d.has(t) || (d.add(t), o.push({
@@ -231,17 +227,17 @@ function R(e, t = []) {
231
227
  }
232
228
  //#endregion
233
229
  //#region src/extensions/BlockChange/BlockChange.ts
234
- var We = b(() => {
230
+ var qe = v(() => {
235
231
  let e = [];
236
232
  return {
237
233
  key: "blockChange",
238
- prosemirrorPlugins: [new w({
239
- key: new T("blockChange"),
234
+ prosemirrorPlugins: [new b({
235
+ key: new x("blockChange"),
240
236
  filterTransaction: (t) => {
241
237
  let n;
242
238
  return e.reduce((e, r) => e === !1 ? e : r({
243
239
  getChanges() {
244
- return n || (n = R(t), n);
240
+ return n || (n = Ke(t), n);
245
241
  },
246
242
  tr: t
247
243
  }) !== !1, !0);
@@ -256,7 +252,7 @@ var We = b(() => {
256
252
  });
257
253
  //#endregion
258
254
  //#region src/extensions/Collaboration/YCursorPlugin.ts
259
- function z(e) {
255
+ function Je(e) {
260
256
  let t = e.charAt(0) === "#" ? e.substring(1, 7) : e, n = parseInt(t.substring(0, 2), 16), r = parseInt(t.substring(2, 4), 16), i = parseInt(t.substring(4, 6), 16), a = [
261
257
  n / 255,
262
258
  r / 255,
@@ -264,15 +260,15 @@ function z(e) {
264
260
  ].map((e) => e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4);
265
261
  return .2126 * a[0] + .7152 * a[1] + .0722 * a[2] <= .179;
266
262
  }
267
- function Ge(e) {
263
+ function Ye(e) {
268
264
  let t = document.createElement("span");
269
265
  t.classList.add("bn-collaboration-cursor__base");
270
266
  let n = document.createElement("span");
271
- n.setAttribute("contentedEditable", "false"), n.classList.add("bn-collaboration-cursor__caret"), n.setAttribute("style", `background-color: ${e.color}; color: ${z(e.color) ? "white" : "black"}`);
267
+ n.setAttribute("contentedEditable", "false"), n.classList.add("bn-collaboration-cursor__caret"), n.setAttribute("style", `background-color: ${e.color}; color: ${Je(e.color) ? "white" : "black"}`);
272
268
  let r = document.createElement("span");
273
- return r.classList.add("bn-collaboration-cursor__label"), r.setAttribute("style", `background-color: ${e.color}; color: ${z(e.color) ? "white" : "black"}`), r.insertBefore(document.createTextNode(e.name), null), n.insertBefore(r, null), t.insertBefore(document.createTextNode("⁠"), null), t.insertBefore(n, null), t.insertBefore(document.createTextNode("⁠"), null), t;
269
+ return r.classList.add("bn-collaboration-cursor__label"), r.setAttribute("style", `background-color: ${e.color}; color: ${Je(e.color) ? "white" : "black"}`), r.insertBefore(document.createTextNode(e.name), null), n.insertBefore(r, null), t.insertBefore(document.createTextNode("⁠"), null), t.insertBefore(n, null), t.insertBefore(document.createTextNode("⁠"), null), t;
274
270
  }
275
- var B = b(({ options: e }) => {
271
+ var k = v(({ options: e }) => {
276
272
  let t = /* @__PURE__ */ new Map(), n = e.provider && "awareness" in e.provider && typeof e.provider.awareness == "object" ? e.provider.awareness : void 0;
277
273
  return n && ("setLocalStateField" in n && typeof n.setLocalStateField == "function" && n.setLocalStateField("user", e.user), "on" in n && typeof n.on == "function" && e.showCursorLabels !== "always" && n.on("change", ({ updated: e }) => {
278
274
  for (let n of e) {
@@ -288,12 +284,12 @@ var B = b(({ options: e }) => {
288
284
  }
289
285
  })), {
290
286
  key: "yCursor",
291
- prosemirrorPlugins: [n ? Te(n, {
292
- selectionBuilder: Se,
287
+ prosemirrorPlugins: [n ? Ae(n, {
288
+ selectionBuilder: De,
293
289
  cursorBuilder(n, r) {
294
290
  let i = t.get(r);
295
291
  if (!i) {
296
- let a = (e.renderCursor ?? Ge)(n);
292
+ let a = (e.renderCursor ?? Ye)(n);
297
293
  e.showCursorLabels !== "always" && (a.addEventListener("mouseenter", () => {
298
294
  let e = t.get(r);
299
295
  e.element.setAttribute("data-active", ""), e.hideTimeout && (clearTimeout(e.hideTimeout), t.set(r, {
@@ -321,20 +317,20 @@ var B = b(({ options: e }) => {
321
317
  n?.setLocalStateField("user", e);
322
318
  }
323
319
  };
324
- }), V = b(({ options: e }) => ({
320
+ }), A = v(({ options: e }) => ({
325
321
  key: "ySync",
326
- prosemirrorPlugins: [Ee(e.fragment)],
322
+ prosemirrorPlugins: [je(e.fragment)],
327
323
  runsBefore: ["default"]
328
- })), H = b(() => ({
324
+ })), j = v(() => ({
329
325
  key: "yUndo",
330
- prosemirrorPlugins: [De()],
326
+ prosemirrorPlugins: [Me()],
331
327
  dependsOn: ["yCursor", "ySync"],
332
- undoCommand: we,
333
- redoCommand: Ce
328
+ undoCommand: ke,
329
+ redoCommand: Oe
334
330
  }));
335
331
  //#endregion
336
332
  //#region src/extensions/Collaboration/ForkYDoc.ts
337
- function Ke(e, t) {
333
+ function Xe(e, t) {
338
334
  let n = e.doc;
339
335
  if (e._item === null) {
340
336
  let r = Array.from(n.share.keys()).find((t) => n.share.get(t) === e);
@@ -342,11 +338,11 @@ function Ke(e, t) {
342
338
  return t.get(r, e.constructor);
343
339
  } else {
344
340
  let n = e._item, r = t.store.clients.get(n.id.client) ?? [];
345
- return r[M.findIndexSS(r, n.id.clock)].content.type;
341
+ return r[D.findIndexSS(r, n.id.clock)].content.type;
346
342
  }
347
343
  }
348
- var qe = b(({ editor: e, options: t }) => {
349
- let n, r = y({ isForked: !1 });
344
+ var Ze = v(({ editor: e, options: t }) => {
345
+ let n, r = _({ isForked: !1 });
350
346
  return {
351
347
  key: "yForkDoc",
352
348
  store: r,
@@ -354,23 +350,23 @@ var qe = b(({ editor: e, options: t }) => {
354
350
  if (n) return;
355
351
  let i = t.fragment;
356
352
  if (!i) throw Error("No fragment to fork from");
357
- let a = new M.Doc();
358
- M.applyUpdate(a, M.encodeStateAsUpdate(i.doc));
359
- let o = Ke(i, a);
353
+ let a = new D.Doc();
354
+ D.applyUpdate(a, D.encodeStateAsUpdate(i.doc));
355
+ let o = Xe(i, a);
360
356
  n = {
361
- undoStack: j.getState(e.prosemirrorState).undoManager.undoStack,
357
+ undoStack: E.getState(e.prosemirrorState).undoManager.undoStack,
362
358
  originalFragment: i,
363
359
  forkedFragment: o
364
360
  }, e.unregisterExtension([
365
- H,
366
- B,
367
- V
361
+ j,
362
+ k,
363
+ A
368
364
  ]);
369
365
  let s = {
370
366
  ...t,
371
367
  fragment: o
372
368
  };
373
- e.registerExtension([V(s), H()]), r.setState({ isForked: !0 });
369
+ e.registerExtension([A(s), j()]), r.setState({ isForked: !0 });
374
370
  },
375
371
  merge({ keepChanges: i }) {
376
372
  if (!n) return;
@@ -381,24 +377,24 @@ var qe = b(({ editor: e, options: t }) => {
381
377
  ]);
382
378
  let { originalFragment: a, forkedFragment: o, undoStack: s } = n;
383
379
  if (e.registerExtension([
384
- V(t),
385
- B(t),
386
- H()
387
- ]), j.getState(e.prosemirrorState).undoManager.undoStack = s, i) {
388
- let t = M.encodeStateAsUpdate(o.doc, M.encodeStateVector(a.doc));
389
- M.applyUpdate(a.doc, t, e);
380
+ A(t),
381
+ k(t),
382
+ j()
383
+ ]), E.getState(e.prosemirrorState).undoManager.undoStack = s, i) {
384
+ let t = D.encodeStateAsUpdate(o.doc, D.encodeStateVector(a.doc));
385
+ D.applyUpdate(a.doc, t, e);
390
386
  }
391
387
  n = void 0, r.setState({ isForked: !1 });
392
388
  }
393
389
  };
394
- }), U = (e, t) => {
390
+ }), M = (e, t) => {
395
391
  t(e), e.forEach((e) => {
396
- e instanceof M.XmlElement && U(e, t);
392
+ e instanceof D.XmlElement && M(e, t);
397
393
  });
398
- }, Je = [(e, t) => {
394
+ }, Qe = [(e, t) => {
399
395
  let n = /* @__PURE__ */ new Map();
400
396
  return e.forEach((e) => {
401
- e instanceof M.XmlElement && U(e, (e) => {
397
+ e instanceof D.XmlElement && M(e, (e) => {
402
398
  if (e.nodeName === "blockContainer" && e.hasAttribute("id")) {
403
399
  let t = e.getAttribute("textColor"), r = e.getAttribute("backgroundColor"), i = {
404
400
  textColor: t === g.textColor.default ? void 0 : t,
@@ -417,16 +413,16 @@ var qe = b(({ editor: e, options: t }) => {
417
413
  });
418
414
  }
419
415
  }), !0);
420
- }], Ye = b(({ options: e }) => {
416
+ }], $e = v(({ options: e }) => {
421
417
  let t = !1;
422
418
  return {
423
419
  key: "schemaMigration",
424
- prosemirrorPlugins: [new D({
425
- key: new O("schemaMigration"),
420
+ prosemirrorPlugins: [new C({
421
+ key: new Te("schemaMigration"),
426
422
  appendTransaction: (n, r, i) => {
427
423
  if (t || !n.some((e) => e.getMeta("y-sync$")) || n.every((e) => !e.docChanged) || !e.fragment.firstChild) return;
428
424
  let a = i.tr;
429
- for (let t of Je) t(e.fragment, a);
425
+ for (let t of Qe) t(e.fragment, a);
430
426
  if (t = !0, a.docChanged) return a;
431
427
  }
432
428
  })]
@@ -434,10 +430,10 @@ var qe = b(({ editor: e, options: t }) => {
434
430
  });
435
431
  //#endregion
436
432
  //#region src/extensions/DropCursor/utils.ts
437
- function W(e, t) {
433
+ function et(e, t) {
438
434
  return !e || !t ? !1 : !!e.closest(`.${t}`);
439
435
  }
440
- function Xe(e, t, n, r, i) {
436
+ function tt(e, t, n, r, i) {
441
437
  let a = e.state.doc.resolve(t.pos);
442
438
  if (a.parent.inlineContent || t.orientation === "inline") return null;
443
439
  let o = a.nodeBefore, s = a.nodeAfter;
@@ -464,7 +460,7 @@ function Xe(e, t, n, r, i) {
464
460
  bottom: f + p
465
461
  };
466
462
  }
467
- function Ze(e, t, n, r) {
463
+ function nt(e, t, n, r) {
468
464
  let i = e.coordsAtPos(t.pos), a = n / 2 * r;
469
465
  return {
470
466
  left: i.left - a,
@@ -473,10 +469,10 @@ function Ze(e, t, n, r) {
473
469
  bottom: i.bottom
474
470
  };
475
471
  }
476
- function Qe(e, t) {
472
+ function rt(e, t) {
477
473
  e.classList.toggle("prosemirror-dropcursor-inline", t === "inline"), e.classList.toggle("prosemirror-dropcursor-block-horizontal", t === "block-horizontal"), e.classList.toggle("prosemirror-dropcursor-block-vertical-left", t === "block-vertical-left"), e.classList.toggle("prosemirror-dropcursor-block-vertical-right", t === "block-vertical-right"), e.classList.toggle("prosemirror-dropcursor-block", t === "block-horizontal"), e.classList.toggle("prosemirror-dropcursor-vertical", t === "block-vertical-left" || t === "block-vertical-right");
478
474
  }
479
- function $e(e) {
475
+ function it(e) {
480
476
  if (!e || e === document.body && getComputedStyle(e).position === "static") return {
481
477
  parentLeft: -window.pageXOffset,
482
478
  parentTop: -window.pageYOffset
@@ -489,7 +485,7 @@ function $e(e) {
489
485
  }
490
486
  //#endregion
491
487
  //#region src/extensions/DropCursor/DropCursor.ts
492
- var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
488
+ var at = "bn-drag-exclude", ot = v(({ editor: e, options: t }) => {
493
489
  let n = null, r = null, i = -1, a = null, o = {
494
490
  width: t.dropCursor?.width ?? 5,
495
491
  color: t.dropCursor?.color ?? "#ddeeff",
@@ -499,9 +495,9 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
499
495
  e?.pos === n?.pos && e?.orientation === n?.orientation || (n = e, e == null ? (r && r.parentNode && r.parentNode.removeChild(r), r = null) : c());
500
496
  }, c = () => {
501
497
  if (!n) return;
502
- let t = e.prosemirrorView, i = t.dom, a = i.getBoundingClientRect(), s = a.width / i.offsetWidth, c = a.height / i.offsetHeight, l = Xe(t, n, o.width, s, c) ?? Ze(t, n, o.width, s), u = t.dom.offsetParent;
503
- r || (r = u.appendChild(document.createElement("div")), r.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", o.color && (r.style.backgroundColor = o.color)), Qe(r, n.orientation);
504
- let { parentLeft: d, parentTop: f } = $e(u);
498
+ let t = e.prosemirrorView, i = t.dom, a = i.getBoundingClientRect(), s = a.width / i.offsetWidth, c = a.height / i.offsetHeight, l = tt(t, n, o.width, s, c) ?? nt(t, n, o.width, s), u = t.dom.offsetParent;
499
+ r || (r = u.appendChild(document.createElement("div")), r.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", o.color && (r.style.backgroundColor = o.color)), rt(r, n.orientation);
500
+ let { parentLeft: d, parentTop: f } = it(u);
505
501
  r.style.left = (l.left - d) / s + "px", r.style.top = (l.top - f) / c + "px", r.style.width = (l.right - l.left) / s + "px", r.style.height = (l.bottom - l.top) / c + "px";
506
502
  }, l = (e) => {
507
503
  clearTimeout(i), i = window.setTimeout(() => s(null), e);
@@ -510,7 +506,7 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
510
506
  a = t.target instanceof Element ? t.target : null;
511
507
  }, d = (t) => {
512
508
  let n = t;
513
- if (a && W(a, o.exclude) || n.target instanceof Element && W(n.target, o.exclude)) return;
509
+ if (a && et(a, o.exclude) || n.target instanceof Element && et(n.target, o.exclude)) return;
514
510
  let r = e.prosemirrorView;
515
511
  if (!r.editable) return;
516
512
  let i = r.posAtCoords({
@@ -520,7 +516,7 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
520
516
  if (i && !d) {
521
517
  let t = i.pos;
522
518
  if (r.dragging && r.dragging.slice) {
523
- let e = ie(r.state.doc, t, r.dragging.slice);
519
+ let e = se(r.state.doc, t, r.dragging.slice);
524
520
  e != null && (t = e);
525
521
  }
526
522
  let a = !r.state.doc.resolve(t).parent.inlineContent, c = {
@@ -561,48 +557,12 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
561
557
  });
562
558
  }
563
559
  };
564
- }), nt = b(({ editor: e }) => {
565
- let t = y(!1), n = () => e.transact((e) => {
566
- if (e.selection.empty || e.selection instanceof ce && e.doc.textBetween(e.selection.from, e.selection.to).length === 0) return !1;
567
- let t = !1;
568
- return e.selection.content().content.descendants((e) => (e.type.spec.code && (t = !0), !t)), !t;
569
- });
570
- return {
571
- key: "formattingToolbar",
572
- store: t,
573
- mount({ dom: r, signal: i }) {
574
- let a = !1, o = !1, s = e.onChange(() => {
575
- a || o || t.setState(n());
576
- }), c = e.onSelectionChange(() => {
577
- a || o || t.setState(n());
578
- });
579
- r.addEventListener("pointerdown", () => {
580
- a = !0, t.setState(!1);
581
- }, { signal: i }), e.prosemirrorView.root.addEventListener("pointerup", () => {
582
- a = !1, e.isFocused() && t.setState(n());
583
- }, {
584
- signal: i,
585
- capture: !0
586
- }), r.addEventListener("pointercancel", () => {
587
- a = !0;
588
- }, {
589
- signal: i,
590
- capture: !0
591
- }), e.prosemirrorView.root.addEventListener("dragstart", () => {
592
- o = !0, t.setState(!1);
593
- }, { signal: i }), e.prosemirrorView.root.addEventListener("dragend", () => {
594
- o = !1;
595
- }, { signal: i }), i.addEventListener("abort", () => {
596
- s(), c();
597
- });
598
- }
599
- };
600
- }), rt = b(() => ({
560
+ }), st = v(() => ({
601
561
  key: "history",
602
- prosemirrorPlugins: [ke()],
603
- undoCommand: je,
604
- redoCommand: Ae
605
- })), it = b(({ editor: e }) => {
562
+ prosemirrorPlugins: [Pe()],
563
+ undoCommand: Ie,
564
+ redoCommand: Fe
565
+ })), ct = v(({ editor: e }) => {
606
566
  function t(t) {
607
567
  let n = e.prosemirrorView.nodeDOM(t);
608
568
  for (; n && n.parentElement;) {
@@ -623,7 +583,7 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
623
583
  return n.text;
624
584
  },
625
585
  get position() {
626
- return oe(e.prosemirrorView, n.from, n.to).toJSON();
586
+ return ue(e.prosemirrorView, n.from, n.to).toJSON();
627
587
  }
628
588
  };
629
589
  }
@@ -649,7 +609,7 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
649
609
  e.deleteLink(t);
650
610
  }
651
611
  };
652
- }), at = [
612
+ }), lt = [
653
613
  "http",
654
614
  "https",
655
615
  "ftp",
@@ -660,30 +620,30 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
660
620
  "sms",
661
621
  "cid",
662
622
  "xmpp"
663
- ], ot = "https", st = new T("node-selection-keyboard"), ct = b(() => ({
623
+ ], ut = "https", dt = new x("node-selection-keyboard"), ft = v(() => ({
664
624
  key: "nodeSelectionKeyboard",
665
- prosemirrorPlugins: [new w({
666
- key: st,
625
+ prosemirrorPlugins: [new b({
626
+ key: dt,
667
627
  props: { handleKeyDown: (e, t) => {
668
628
  if ("node" in e.state.selection) {
669
629
  if (t.ctrlKey || t.metaKey) return !1;
670
630
  if (t.key.length === 1) return t.preventDefault(), !0;
671
631
  if (t.key === "Enter" && !t.isComposing && !t.shiftKey && !t.altKey && !t.ctrlKey && !t.metaKey) {
672
632
  let t = e.state.tr;
673
- return e.dispatch(t.insert(e.state.tr.selection.$to.after(), e.state.schema.nodes.paragraph.createChecked()).setSelection(new ce(t.doc.resolve(e.state.tr.selection.$to.after() + 1)))), !0;
633
+ 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;
674
634
  }
675
635
  }
676
636
  return !1;
677
637
  } }
678
638
  })]
679
- })), lt = new T("blocknote-placeholder"), ut = b(({ editor: e, options: t }) => {
639
+ })), pt = new x("blocknote-placeholder"), mt = v(({ editor: e, options: t }) => {
680
640
  let n = t.placeholders;
681
641
  return {
682
642
  key: "placeholder",
683
- prosemirrorPlugins: [new w({
684
- key: lt,
643
+ prosemirrorPlugins: [new b({
644
+ key: pt,
685
645
  view: (t) => {
686
- let r = `placeholder-selector-${le()}`;
646
+ let r = `placeholder-selector-${pe()}`;
687
647
  t.dom.classList.add(r);
688
648
  let i = document.createElement("style"), a = e._tiptapEditor.options.injectNonce;
689
649
  a && i.setAttribute("nonce", a), t.root instanceof window.ShadowRoot ? t.root.append(i) : t.root.head.appendChild(i);
@@ -706,33 +666,33 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
706
666
  let { doc: n, selection: r } = t;
707
667
  if (!e.isEditable || !r.empty || r.$from.parent.type.spec.code) return;
708
668
  let i = [];
709
- t.doc.content.size === 6 && i.push(k.node(2, 4, { "data-is-only-empty-block": "true" }));
669
+ t.doc.content.size === 6 && i.push(w.node(2, 4, { "data-is-only-empty-block": "true" }));
710
670
  let a = r.$anchor, o = a.parent;
711
671
  if (o.content.size === 0) {
712
672
  let e = a.before();
713
- i.push(k.node(e, e + o.nodeSize, { "data-is-empty-and-focused": "true" }));
673
+ i.push(w.node(e, e + o.nodeSize, { "data-is-empty-and-focused": "true" }));
714
674
  }
715
- return A.create(n, i);
675
+ return T.create(n, i);
716
676
  } }
717
677
  })]
718
678
  };
719
- }), dt = new T("previous-blocks"), ft = {
679
+ }), ht = new x("previous-blocks"), gt = {
720
680
  index: "index",
721
681
  level: "level",
722
682
  type: "type",
723
683
  depth: "depth",
724
684
  "depth-change": "depth-change"
725
- }, pt = b(() => {
685
+ }, _t = v(() => {
726
686
  let e;
727
687
  return {
728
688
  key: "previousBlockType",
729
- prosemirrorPlugins: [new w({
730
- key: dt,
689
+ prosemirrorPlugins: [new b({
690
+ key: ht,
731
691
  view(t) {
732
692
  return {
733
693
  update: async (t, n) => {
734
694
  this.key?.getState(t.state).updatedBlocks.size > 0 && (e = setTimeout(() => {
735
- t.dispatch(t.state.tr.setMeta(dt, { clearUpdate: !0 }));
695
+ t.dispatch(t.state.tr.setMeta(ht, { clearUpdate: !0 }));
736
696
  }, 0));
737
697
  },
738
698
  destroy: () => {
@@ -755,7 +715,7 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
755
715
  let a = e.mapping.invert(), o = {
756
716
  from: a.map(i.from, -1),
757
717
  to: a.map(i.to, 1)
758
- }, s = {}, c = C(n.doc, o, (e) => e.attrs.id), l = new Map(c.map((e) => [e.node.attrs.id, e])), u = C(r.doc, i, (e) => e.attrs.id);
718
+ }, s = {}, c = le(n.doc, o, (e) => e.attrs.id), l = new Map(c.map((e) => [e.node.attrs.id, e])), u = le(r.doc, i, (e) => e.attrs.id);
759
719
  for (let e of u) {
760
720
  let i = l.get(e.node.attrs.id), a = i?.node.firstChild, o = e.node.firstChild;
761
721
  if (i && a && o) {
@@ -783,16 +743,16 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
783
743
  return e.doc.descendants((e, r) => {
784
744
  if (!e.attrs.id || !t.updatedBlocks.has(e.attrs.id)) return;
785
745
  let i = t.currentTransactionOldBlockAttrs[e.attrs.id], a = {};
786
- for (let [e, t] of Object.entries(i)) a["data-prev-" + ft[e]] = t || "none";
787
- n.push(k.node(r, r + e.nodeSize, { ...a }));
788
- }), A.create(e.doc, n);
746
+ for (let [e, t] of Object.entries(i)) a["data-prev-" + gt[e]] = t || "none";
747
+ n.push(w.node(r, r + e.nodeSize, { ...a }));
748
+ }), T.create(e.doc, n);
789
749
  } }
790
750
  })]
791
751
  };
792
752
  });
793
753
  //#endregion
794
754
  //#region src/extensions/getDraggableBlockFromElement.ts
795
- function mt(e, t) {
755
+ function vt(e, t) {
796
756
  for (; e && e.parentElement && e.parentElement !== t.dom && e.getAttribute?.("data-node-type") !== "blockContainer";) e = e.parentElement;
797
757
  if (e.getAttribute?.("data-node-type") === "blockContainer") return {
798
758
  node: e,
@@ -800,69 +760,365 @@ function mt(e, t) {
800
760
  };
801
761
  }
802
762
  //#endregion
803
- //#region src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.ts
804
- function ht() {
805
- let e = (t) => {
806
- let n = t.children.length;
807
- for (let r = 0; r < n; r++) {
808
- let i = t.children[r];
809
- if (i.type === "element" && (e(i), i.tagName === "u")) if (i.children.length > 0) {
810
- t.children.splice(r, 1, ...i.children);
811
- let e = i.children.length - 1;
812
- n += e, r += e;
813
- } else t.children.splice(r, 1), n--, r--;
814
- }
763
+ //#region src/api/exporters/markdown/htmlToMarkdown.ts
764
+ function yt(e) {
765
+ let t = document.createElement("div");
766
+ return t.innerHTML = e, N(t, {
767
+ indent: "",
768
+ inListItem: !1
769
+ }).trim() + "\n";
770
+ }
771
+ function N(e, t) {
772
+ let n = "", r = Array.from(e.childNodes);
773
+ for (let e = 0; e < r.length; e++) {
774
+ let i = r[e];
775
+ n += P(i, t);
776
+ }
777
+ return n;
778
+ }
779
+ function P(e, t) {
780
+ if (e.nodeType === 3) return e.textContent || "";
781
+ if (e.nodeType !== 1) return "";
782
+ let n = e;
783
+ switch (n.tagName.toLowerCase()) {
784
+ case "p": return bt(n, t);
785
+ case "h1":
786
+ case "h2":
787
+ case "h3":
788
+ case "h4":
789
+ case "h5":
790
+ case "h6": return F(n, t);
791
+ case "blockquote": return xt(n, t);
792
+ case "pre": return St(n, t);
793
+ case "ul": return wt(n, t);
794
+ case "ol": return Tt(n, t);
795
+ case "table": return Dt(n, t);
796
+ case "hr": return t.indent + "***\n\n";
797
+ case "img": return kt(n, t);
798
+ case "video": return At(n, t);
799
+ case "audio": return jt(n, t);
800
+ case "embed": return Mt(n, t);
801
+ case "figure": return Nt(n, t);
802
+ case "a": return H(n, t);
803
+ case "details": return Lt(n, t);
804
+ case "div": return N(n, t);
805
+ case "br": return "";
806
+ default: return N(n, t);
807
+ }
808
+ }
809
+ function bt(e, t) {
810
+ let n = zt(U(e));
811
+ return t.inListItem ? n : t.indent + n + "\n\n";
812
+ }
813
+ function F(e, t) {
814
+ let n = parseInt(e.tagName[1], 10), r = "#".repeat(n) + " ", i = U(e);
815
+ return t.indent + r + i + "\n\n";
816
+ }
817
+ function xt(e, t) {
818
+ let n = Array.from(e.children).filter((e) => {
819
+ let t = e.tagName.toLowerCase();
820
+ return [
821
+ "p",
822
+ "ul",
823
+ "ol",
824
+ "pre",
825
+ "blockquote",
826
+ "table",
827
+ "hr"
828
+ ].includes(t);
829
+ }), r;
830
+ if (n.length > 0) {
831
+ let e = [];
832
+ for (let t of n) t.tagName.toLowerCase() === "p" ? e.push(U(t)) : e.push(P(t, {
833
+ indent: "",
834
+ inListItem: !1
835
+ }).trim());
836
+ r = e.join("\n\n");
837
+ } else r = U(e);
838
+ return r.split("\n").map((e) => t.indent + "> " + e).join("\n") + "\n\n";
839
+ }
840
+ function St(e, t) {
841
+ let n = e.querySelector("code");
842
+ if (!n) return "";
843
+ let r = n.getAttribute("data-language") || Ct(n.className) || "", i = I(n), a = Math.max(0, ...(i.match(/`+/g) ?? []).map((e) => e.length)), o = "`".repeat(Math.max(3, a + 1));
844
+ return i ? t.indent + o + r + "\n" + i + (i.endsWith("\n") ? "" : "\n") + o + "\n\n" : t.indent + o + r + "\n" + o + "\n\n";
845
+ }
846
+ function I(e) {
847
+ let t = "";
848
+ for (let n of Array.from(e.childNodes)) n.nodeType === 3 ? t += n.textContent || "" : n.nodeType === 1 && (n.tagName.toLowerCase() === "br" ? t += "\n" : t += I(n));
849
+ return t;
850
+ }
851
+ function Ct(e) {
852
+ let t = e.match(/language-(\S+)/);
853
+ return t ? t[1] : "";
854
+ }
855
+ function wt(e, t) {
856
+ let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li");
857
+ for (let e of r) n += L(e, "bullet", t);
858
+ return t.inListItem || (n += "\n"), n;
859
+ }
860
+ function Tt(e, t) {
861
+ let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li"), i = parseInt(e.getAttribute("start") || "1", 10);
862
+ for (let e = 0; e < r.length; e++) {
863
+ let a = i + e;
864
+ n += L(r[e], "ordered", t, a);
865
+ }
866
+ return t.inListItem || (n += "\n"), n;
867
+ }
868
+ function L(e, t, n, r) {
869
+ let i = null, a = null;
870
+ for (let t of Array.from(e.children)) {
871
+ let e = t.tagName.toLowerCase();
872
+ e === "input" && t.type === "checkbox" && (i = t), e === "details" && (a = t);
873
+ }
874
+ let o, s;
875
+ i ? (o = `* ${i.checked ? "[x]" : "[ ]"} `, s = 2) : t === "ordered" ? (o = `${r}. `, s = o.length) : (o = "* ", s = 2);
876
+ let c, l;
877
+ if (a) {
878
+ let e = a.querySelector("summary")?.querySelector("p");
879
+ l = a, c = e ? U(e) : "";
880
+ } else l = Et(e, i), c = l ? U(l) : "";
881
+ let u = n.indent + o + c + "\n", d = n.indent + " ".repeat(s), f = {
882
+ indent: d,
883
+ inListItem: !0
815
884
  };
816
- return e;
885
+ if (a) {
886
+ let e = a.querySelector("summary");
887
+ for (let t of Array.from(a.children)) if (t !== e) if (t.tagName.toLowerCase() === "p") {
888
+ let e = U(t);
889
+ u += "\n" + d + e + "\n";
890
+ } else u += P(t, f);
891
+ }
892
+ let p = Array.from(e.children);
893
+ for (let e of p) {
894
+ let t = e.tagName.toLowerCase();
895
+ if (!(e === l || e === i) && t !== "input") if (t === "ul" || t === "ol") u += P(e, f);
896
+ else if (t === "p") {
897
+ let t = U(e);
898
+ u += "\n" + d + t + "\n";
899
+ } else u += "\n" + P(e, f);
900
+ }
901
+ return u;
817
902
  }
818
- //#endregion
819
- //#region src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts
820
- function gt() {
821
- let e = (t) => {
822
- if (t.children && "length" in t.children && t.children.length) for (let n = t.children.length - 1; n >= 0; n--) {
823
- let r = t.children[n], i = n + 1 < t.children.length ? t.children[n + 1] : void 0;
824
- r.type === "element" && r.tagName === "input" && r.properties?.type === "checkbox" && i?.type === "element" && i.tagName === "p" ? (i.tagName = "span", i.children.splice(0, 0, Le(document.createTextNode(" ")))) : e(r);
903
+ function Et(e, t) {
904
+ for (let n of Array.from(e.children)) {
905
+ if (n === t || n.tagName.toLowerCase() === "input") continue;
906
+ let e = n.tagName.toLowerCase();
907
+ if (e === "p" || e === "span") return n;
908
+ }
909
+ return null;
910
+ }
911
+ function Dt(e, t) {
912
+ let n = e.querySelector("colgroup"), r = 0;
913
+ n && (r = n.querySelectorAll("col").length);
914
+ let i = [], a = !1, o = e.querySelectorAll("tr"), s = [];
915
+ o.forEach((e, t) => {
916
+ s[t] || (s[t] = []);
917
+ let n = e.querySelectorAll("th, td"), i = 0;
918
+ n.forEach((e) => {
919
+ for (; s[t][i] !== void 0;) i++;
920
+ t === 0 && e.tagName.toLowerCase() === "th" && (a = !0);
921
+ let n = Ot(U(e).trim()), r = parseInt(e.getAttribute("colspan") || "1", 10), o = parseInt(e.getAttribute("rowspan") || "1", 10);
922
+ for (let e = 0; e < o; e++) for (let a = 0; a < r; a++) {
923
+ let r = t + e;
924
+ s[r] || (s[r] = []), s[r][i + a] = e === 0 && a === 0 ? n : "";
925
+ }
926
+ i += r;
927
+ }), s[t] && (r = Math.max(r, s[t].length));
928
+ });
929
+ for (let e of s) {
930
+ let t = [];
931
+ for (let n = 0; n < r; n++) t.push(e && e[n] !== void 0 ? e[n] ?? "" : "");
932
+ i.push(t);
933
+ }
934
+ if (i.length === 0) return "";
935
+ let c = [];
936
+ for (let e = 0; e < r; e++) {
937
+ let t = 3;
938
+ for (let n of i) {
939
+ let r = e < n.length ? n[e].length : 0;
940
+ t = Math.max(t, r);
825
941
  }
826
- };
827
- return e;
942
+ c.push(Math.max(t, 10));
943
+ }
944
+ let l = "";
945
+ if (a) {
946
+ l += t.indent + R(i[0], c, r) + "\n", l += t.indent + z(c, r) + "\n";
947
+ for (let e = 1; e < i.length; e++) l += t.indent + R(i[e], c, r) + "\n";
948
+ } else {
949
+ let e = Array(r).fill("");
950
+ l += t.indent + R(e, c, r) + "\n", l += t.indent + z(c, r) + "\n";
951
+ for (let e of i) l += t.indent + R(e, c, r) + "\n";
952
+ }
953
+ return l += "\n", l;
828
954
  }
829
- //#endregion
830
- //#region src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.ts
831
- function _t() {
832
- return (e) => {
833
- Re(e, "element", (e, t, n) => {
834
- if (n && e.tagName === "video") {
835
- let r = e.properties?.src || e.properties?.["data-url"] || "", i = e.properties?.title || e.properties?.["data-name"] || "";
836
- n.children[t] = {
837
- type: "text",
838
- value: `![${i}](${r})`
839
- };
955
+ function Ot(e) {
956
+ return e.replace(/\|/g, "\\|");
957
+ }
958
+ function R(e, t, n) {
959
+ let r = [];
960
+ for (let i = 0; i < n; i++) {
961
+ let n = i < e.length ? e[i] : "";
962
+ r.push(" " + n.padEnd(t[i]) + " ");
963
+ }
964
+ return "|" + r.join("|") + "|";
965
+ }
966
+ function z(e, t) {
967
+ let n = [];
968
+ for (let r = 0; r < t; r++) n.push(" " + "-".repeat(e[r]) + " ");
969
+ return "|" + n.join("|") + "|";
970
+ }
971
+ function kt(e, t) {
972
+ let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
973
+ return n ? t.indent + `![${r}](${n})\n\n` : "\n\n";
974
+ }
975
+ function At(e, t) {
976
+ let n = e.getAttribute("src") || e.getAttribute("data-url") || "", r = e.getAttribute("data-name") || e.getAttribute("title") || "";
977
+ return n ? t.indent + `![${r}](${n})\n\n` : "\n\n";
978
+ }
979
+ function jt(e, t) {
980
+ let n = e.getAttribute("src") || "";
981
+ return n ? t.indent + `<audio src="${V(n)}" controls></audio>\n\n` : "\n\n";
982
+ }
983
+ function Mt(e, t) {
984
+ let n = e.getAttribute("src") || "";
985
+ return n ? t.indent + `[](${n})\n\n` : "\n\n";
986
+ }
987
+ function Nt(e, t) {
988
+ let n = e.querySelector("img"), r = e.querySelector("video"), i = e.querySelector("audio"), a = e.querySelector("a"), o = e.querySelector("figcaption")?.textContent?.trim() || "";
989
+ return n ? B("img", n.getAttribute("src") || "", n.getAttribute("alt") || "", o, t) : r ? B("video", r.getAttribute("src") || r.getAttribute("data-url") || "", r.getAttribute("data-name") || r.getAttribute("title") || "", o, t) : i ? B("audio", i.getAttribute("src") || "", "", o, t) : a ? H(a, t) : "";
990
+ }
991
+ function B(e, t, n, r, i) {
992
+ if (!t) return "";
993
+ if (!r && e !== "audio") return i.indent + `![${n}](${t})\n\n`;
994
+ let a = n && n !== r ? e === "img" ? ` alt="${V(n)}"` : e === "video" ? ` data-name="${V(n)}"` : "" : "", o = e === "img" ? `<img${a} src="${V(t)}">` : `<${e} src="${V(t)}"${a} controls></${e}>`, s = r ? `<figcaption>${Pt(r)}</figcaption>` : "";
995
+ return i.indent + `<figure>${o}${s}</figure>\n\n`;
996
+ }
997
+ function V(e) {
998
+ return e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
999
+ }
1000
+ function Pt(e) {
1001
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1002
+ }
1003
+ function H(e, t) {
1004
+ let n = e.getAttribute("href") || "", r = e.textContent?.trim() || "";
1005
+ return n ? t.indent + Ft(r, n) + "\n\n" : t.indent + r + "\n\n";
1006
+ }
1007
+ function Ft(e, t) {
1008
+ return !e || e === t ? t : `[${e}](${It(t)})`;
1009
+ }
1010
+ function It(e) {
1011
+ return e.replace(/[\\()]/g, "\\$&");
1012
+ }
1013
+ function Lt(e, t) {
1014
+ let n = e.querySelector("summary");
1015
+ if (!n) return N(e, t);
1016
+ let r = n.querySelector("h1, h2, h3, h4, h5, h6");
1017
+ if (r) {
1018
+ let i = F(r, t);
1019
+ for (let r of Array.from(e.children)) r !== n && (i += P(r, t));
1020
+ return i;
1021
+ }
1022
+ return N(n, t);
1023
+ }
1024
+ function U(e) {
1025
+ let t = "";
1026
+ for (let n of Array.from(e.childNodes)) if (n.nodeType === 3) t += n.textContent || "";
1027
+ else if (n.nodeType === 1) {
1028
+ let e = n;
1029
+ switch (e.tagName.toLowerCase()) {
1030
+ case "strong":
1031
+ case "b": {
1032
+ let { content: n, trailing: r } = Rt(U(e));
1033
+ n ? t += `**${n}**${r}` : t += r;
1034
+ break;
840
1035
  }
841
- });
1036
+ case "em":
1037
+ case "i": {
1038
+ let { content: n, trailing: r } = Rt(U(e));
1039
+ n ? t += `*${n}*${r}` : t += r;
1040
+ break;
1041
+ }
1042
+ case "s":
1043
+ case "del":
1044
+ t += `~~${U(e)}~~`;
1045
+ break;
1046
+ case "code": {
1047
+ let n = e.textContent || "", r = Math.max(0, ...(n.match(/`+/g) ?? []).map((e) => e.length)), i = "`".repeat(r + 1), a = n.startsWith("`") || n.endsWith("`");
1048
+ t += i + (a ? ` ${n} ` : n) + i;
1049
+ break;
1050
+ }
1051
+ case "u":
1052
+ t += U(e);
1053
+ break;
1054
+ case "a": {
1055
+ let n = e.getAttribute("href") || "", r = U(e);
1056
+ t += Ft(r, n);
1057
+ break;
1058
+ }
1059
+ case "br":
1060
+ t += "\\\n";
1061
+ break;
1062
+ case "span":
1063
+ t += U(e);
1064
+ break;
1065
+ case "img": {
1066
+ let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
1067
+ t += `![${r}](${n})`;
1068
+ break;
1069
+ }
1070
+ case "video": {
1071
+ let n = e.getAttribute("src") || e.getAttribute("data-url") || "", r = e.getAttribute("data-name") || e.getAttribute("title") || "";
1072
+ t += `![${r}](${n})`;
1073
+ break;
1074
+ }
1075
+ case "p":
1076
+ t += U(e);
1077
+ break;
1078
+ case "input": break;
1079
+ default:
1080
+ t += U(e);
1081
+ break;
1082
+ }
1083
+ }
1084
+ return t;
1085
+ }
1086
+ function Rt(e) {
1087
+ let t = e.match(/^(.*?)(\s*)$/);
1088
+ return t ? {
1089
+ content: t[1],
1090
+ trailing: t[2]
1091
+ } : {
1092
+ content: e,
1093
+ trailing: ""
842
1094
  };
843
1095
  }
1096
+ function zt(e) {
1097
+ let t = e.replace(/^(\\\n)+/, "");
1098
+ return t = t.replace(/(\\\n)+$/, ""), t;
1099
+ }
844
1100
  //#endregion
845
1101
  //#region src/api/exporters/markdown/markdownExporter.ts
846
- function G(e) {
847
- return Ie().use(Me, { fragment: !0 }).use(_t).use(ht).use(gt).use(Ne).use(Pe).use(Fe, { handlers: { text: (e) => e.value } }).processSync(e).value;
1102
+ function W(e) {
1103
+ return yt(e);
848
1104
  }
849
- function vt(e, t, n, r) {
850
- return G(I(t, n).exportBlocks(e, r));
1105
+ function Bt(e, t, n, r) {
1106
+ return W(O(t, n).exportBlocks(e, r));
851
1107
  }
852
1108
  //#endregion
853
1109
  //#region src/api/nodeConversions/fragmentToBlocks.ts
854
- function yt(e) {
1110
+ function Vt(e) {
855
1111
  let t = [];
856
1112
  return e.descendants((e) => {
857
- let n = p(e);
1113
+ let n = m(e);
858
1114
  return e.type.name === "blockContainer" && e.firstChild?.type.name === "blockGroup" ? !0 : e.type.name === "columnList" && e.childCount === 1 ? (e.firstChild?.forEach((e) => {
859
- t.push(_(e, n));
860
- }), !1) : e.type.isInGroup("bnBlock") ? (t.push(_(e, n)), !1) : !0;
1115
+ t.push(p(e, n));
1116
+ }), !1) : e.type.isInGroup("bnBlock") ? (t.push(p(e, n)), !1) : !0;
861
1117
  }), t;
862
1118
  }
863
1119
  //#endregion
864
1120
  //#region src/extensions/SideMenu/MultipleNodeSelection.ts
865
- var K = class e extends E {
1121
+ var G = class e extends S {
866
1122
  nodes;
867
1123
  constructor(e, t) {
868
1124
  super(e, t);
@@ -875,7 +1131,7 @@ var K = class e extends E {
875
1131
  return new e(t.resolve(n), t.resolve(r));
876
1132
  }
877
1133
  content() {
878
- return new re(S.from(this.nodes), 0, 0);
1134
+ return new oe(y.from(this.nodes), 0, 0);
879
1135
  }
880
1136
  eq(t) {
881
1137
  if (!(t instanceof e) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to) return !1;
@@ -884,7 +1140,7 @@ var K = class e extends E {
884
1140
  }
885
1141
  map(t, n) {
886
1142
  let r = n.mapResult(this.from), i = n.mapResult(this.to);
887
- return i.deleted ? E.near(t.resolve(r.pos)) : r.deleted ? E.near(t.resolve(i.pos)) : new e(t.resolve(r.pos), t.resolve(i.pos));
1143
+ return i.deleted ? S.near(t.resolve(r.pos)) : r.deleted ? S.near(t.resolve(i.pos)) : new e(t.resolve(r.pos), t.resolve(i.pos));
888
1144
  }
889
1145
  toJSON() {
890
1146
  return {
@@ -894,11 +1150,11 @@ var K = class e extends E {
894
1150
  };
895
1151
  }
896
1152
  };
897
- E.jsonID("multiple-node", K);
1153
+ S.jsonID("multiple-node", G);
898
1154
  //#endregion
899
1155
  //#region src/extensions/SideMenu/dragging.ts
900
- var q;
901
- function bt(e, t) {
1156
+ var K;
1157
+ function Ht(e, t) {
902
1158
  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);
903
1159
  if (i && a) {
904
1160
  let i = e.$from.start(o - 1), a = e.$to.end(o - 1);
@@ -909,56 +1165,51 @@ function bt(e, t) {
909
1165
  to: r
910
1166
  };
911
1167
  }
912
- function xt(e, t, n = t) {
1168
+ function Ut(e, t, n = t) {
913
1169
  t === n && (n += e.state.doc.resolve(t + 1).node().nodeSize);
914
1170
  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);
915
1171
  for (let e = i.childElementCount - 1; e >= 0; e--) (e > s || e < o) && r.removeChild(r.children[e]);
916
- St(e.root), q = r;
917
- let c = q.getElementsByTagName("iframe");
918
- for (let e = 0; e < c.length; e++) {
919
- let t = c[e], n = t.parentElement;
920
- n && n.removeChild(t);
921
- }
922
- let l = e.dom.className.split(" ").filter((e) => e !== "ProseMirror" && e !== "bn-root" && e !== "bn-editor").join(" ");
923
- q.className = q.className + " bn-drag-preview " + l, e.root instanceof ShadowRoot ? e.root.appendChild(q) : e.root.body.appendChild(q);
1172
+ Wt(e.root), K = r, K.querySelectorAll("iframe, embed, object").forEach((e) => e.parentElement?.removeChild(e));
1173
+ let c = e.dom.className.split(" ").filter((e) => e !== "ProseMirror" && e !== "bn-root" && e !== "bn-editor").join(" ");
1174
+ K.className = K.className + " bn-drag-preview " + c, e.root instanceof ShadowRoot ? e.root.appendChild(K) : e.root.body.appendChild(K);
924
1175
  }
925
- function St(e) {
926
- q !== void 0 && (e instanceof ShadowRoot ? e.removeChild(q) : e.body.removeChild(q), q = void 0);
1176
+ function Wt(e) {
1177
+ K !== void 0 && (e instanceof ShadowRoot ? e.removeChild(K) : e.body.removeChild(K), K = void 0);
927
1178
  }
928
- function Ct(e, t, n) {
929
- if (!e.dataTransfer || n.headless) return;
930
- let i = n.prosemirrorView, a = r(t.id, i.state.doc);
1179
+ function Gt(e, t, r) {
1180
+ if (!e.dataTransfer || r.headless) return;
1181
+ let i = r.prosemirrorView, a = n(t.id, i.state.doc);
931
1182
  if (!a) throw Error(`Block with ID ${t.id} not found`);
932
1183
  let o = a.posBeforeNode;
933
1184
  if (o != null) {
934
- let t = i.state.selection, r = i.state.doc, { from: a, to: s } = bt(t, r), c = a <= o && o < s, l = t.$anchor.node() !== t.$head.node() || t instanceof K;
935
- c && l ? (i.dispatch(i.state.tr.setSelection(K.create(r, a, s))), xt(i, a, s)) : (i.dispatch(i.state.tr.setSelection(se.create(i.state.doc, o))), xt(i, o));
936
- let u = i.state.selection.content(), d = n.pmSchema, f = i.serializeForClipboard(u).dom.innerHTML, p = I(d, n), m = yt(u.content), h = p.exportBlocks(m, {}), g = G(h);
937
- 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(q, 0, 0);
1185
+ let t = i.state.selection, n = i.state.doc, { from: a, to: s } = Ht(t, n), c = a <= o && o < s, l = t.$anchor.node() !== t.$head.node() || t instanceof G;
1186
+ c && l ? (i.dispatch(i.state.tr.setSelection(G.create(n, a, s))), Ut(i, a, s)) : (i.dispatch(i.state.tr.setSelection(de.create(i.state.doc, o))), Ut(i, o));
1187
+ let u = i.state.selection.content(), d = r.pmSchema, f = i.serializeForClipboard(u).dom.innerHTML, p = O(d, r), m = Vt(u.content), h = p.exportBlocks(m, {}), g = W(h);
1188
+ 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(K, 0, 0);
938
1189
  }
939
1190
  }
940
1191
  //#endregion
941
1192
  //#region src/extensions/SideMenu/SideMenu.ts
942
- var wt = 250;
943
- function J(e, t, n = !0) {
1193
+ var Kt = 250;
1194
+ function q(e, t, n = !0) {
944
1195
  let r = e.root.elementsFromPoint(t.left, t.top);
945
- for (let i of r) if (e.dom.contains(i)) return n && i.closest("[data-node-type=columnList]") ? J(e, {
1196
+ for (let i of r) if (e.dom.contains(i)) return n && i.closest("[data-node-type=columnList]") ? q(e, {
946
1197
  left: t.left + 50,
947
1198
  top: t.top
948
- }, !1) : mt(i, e);
1199
+ }, !1) : vt(i, e);
949
1200
  }
950
- function Tt(e, t) {
1201
+ function qt(e, t) {
951
1202
  if (!t.dom.firstChild) return;
952
- let n = t.dom.firstChild.getBoundingClientRect(), r = J(t, {
1203
+ let n = t.dom.firstChild.getBoundingClientRect(), r = q(t, {
953
1204
  left: Math.min(Math.max(n.left + 10, e.x), n.right - 10),
954
1205
  top: e.y
955
1206
  });
956
- if (r) return J(t, {
1207
+ if (r) return q(t, {
957
1208
  left: r.node.getBoundingClientRect().right - 10,
958
1209
  top: e.y
959
1210
  }, !1);
960
1211
  }
961
- var Et = class {
1212
+ var J = class {
962
1213
  state;
963
1214
  emitUpdate;
964
1215
  mousePos;
@@ -980,11 +1231,11 @@ var Et = class {
980
1231
  clientX: this.mousePos.x,
981
1232
  clientY: this.mousePos.y
982
1233
  });
983
- if (e?.element !== this.pmView.dom || e.distance > wt) {
1234
+ if (e?.element !== this.pmView.dom || e.distance > Kt) {
984
1235
  this.state?.show && (this.state.show = !1, this.updateState(this.state));
985
1236
  return;
986
1237
  }
987
- let t = Tt(this.mousePos, this.pmView);
1238
+ let t = qt(this.mousePos, this.pmView);
988
1239
  if (!t || !this.editor.isEditable) {
989
1240
  this.state?.show && (this.state.show = !1, this.updateState(this.state));
990
1241
  return;
@@ -1003,9 +1254,9 @@ var Et = class {
1003
1254
  if (!t || this.pmView.dragging) return;
1004
1255
  let n = document.createElement("div");
1005
1256
  n.innerHTML = t;
1006
- let r = ue.fromSchema(this.pmView.state.schema).parse(n, { topNode: this.pmView.state.schema.nodes.blockGroup.create() });
1257
+ let r = me.fromSchema(this.pmView.state.schema).parse(n, { topNode: this.pmView.state.schema.nodes.blockGroup.create() });
1007
1258
  this.pmView.dragging = {
1008
- slice: new de(r.content, 0, 0),
1259
+ slice: new he(r.content, 0, 0),
1009
1260
  move: !0
1010
1261
  };
1011
1262
  };
@@ -1037,7 +1288,7 @@ var Et = class {
1037
1288
  getDragEventContext = (e) => {
1038
1289
  if (!(this.pmView.dragging !== null || this.isDragOrigin || e.dataTransfer?.types.includes("blocknote/html") || e.target instanceof Node && this.pmView.dom.contains(e.target))) return;
1039
1290
  let t = !e.dataTransfer?.types.includes("blocknote/html") && !!this.pmView.dragging, n = !!this.isDragOrigin, r = t || n, i = this.findClosestEditorElement(e);
1040
- if (!i || i.distance > wt) return;
1291
+ if (!i || i.distance > Kt) return;
1041
1292
  let a = i.element === this.pmView.dom, o = a && i.distance === 0;
1042
1293
  if (!(!a && !r)) return {
1043
1294
  isDropPoint: a,
@@ -1055,7 +1306,7 @@ var Et = class {
1055
1306
  let { isDropPoint: n, isDropWithinEditorBounds: r, isDragOrigin: i } = t;
1056
1307
  if (!r && n && this.dispatchSyntheticEvent(e), n) {
1057
1308
  if (this.pmView.dragging) return;
1058
- this.pmView.dispatch(this.pmView.state.tr.setSelection(xe.create(this.pmView.state.tr.doc, this.pmView.state.tr.selection.anchor)));
1309
+ this.pmView.dispatch(this.pmView.state.tr.setSelection(Ee.create(this.pmView.state.tr.doc, this.pmView.state.tr.selection.anchor)));
1059
1310
  return;
1060
1311
  } else if (i) {
1061
1312
  setTimeout(() => this.pmView.dispatch(this.pmView.state.tr.deleteSelection()), 0);
@@ -1091,22 +1342,22 @@ var Et = class {
1091
1342
  destroy() {
1092
1343
  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);
1093
1344
  }
1094
- }, Dt = new O("SideMenuPlugin"), Ot = b(({ editor: e }) => {
1095
- let t, n = y(void 0);
1345
+ }, Jt = new Te("SideMenuPlugin"), Yt = v(({ editor: e }) => {
1346
+ let t, n = _(void 0);
1096
1347
  return {
1097
1348
  key: "sideMenu",
1098
1349
  store: n,
1099
- prosemirrorPlugins: [new D({
1100
- key: Dt,
1101
- view: (r) => (t = new Et(e, r, (e) => {
1350
+ prosemirrorPlugins: [new C({
1351
+ key: Jt,
1352
+ view: (r) => (t = new J(e, r, (e) => {
1102
1353
  n.setState({ ...e });
1103
1354
  }), t)
1104
1355
  })],
1105
1356
  blockDragStart(n, r) {
1106
- t && (t.isDragOrigin = !0), Ct(n, r, e);
1357
+ t && (t.isDragOrigin = !0), Gt(n, r, e);
1107
1358
  },
1108
1359
  blockDragEnd() {
1109
- St(e.prosemirrorView.root), t && (t.isDragOrigin = !1), e.blur();
1360
+ Wt(e.prosemirrorView.root), t && (t.isDragOrigin = !1), e.blur();
1110
1361
  },
1111
1362
  freezeMenu() {
1112
1363
  t.menuFrozen = !0, t.state.show = !0, t.emitUpdate(t.state);
@@ -1119,7 +1370,7 @@ var Et = class {
1119
1370
  }
1120
1371
  };
1121
1372
  }), Y;
1122
- async function kt() {
1373
+ async function Xt() {
1123
1374
  return Y || (Y = (async () => {
1124
1375
  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;
1125
1376
  return await n.init({ data: r }), {
@@ -1128,9 +1379,9 @@ async function kt() {
1128
1379
  };
1129
1380
  })(), Y);
1130
1381
  }
1131
- async function At(e, t) {
1132
- if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !== te.text) return [];
1133
- let { emojiData: n, emojiMart: r } = await kt();
1382
+ async function Zt(e, t) {
1383
+ if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !== ne.text) return [];
1384
+ let { emojiData: n, emojiMart: r } = await Xt();
1134
1385
  return (t.trim() === "" ? Object.values(n.emojis) : await r.SearchIndex.search(t)).map((t) => ({
1135
1386
  id: t.skins[0].native,
1136
1387
  onItemClick: () => e.insertInlineContent(t.skins[0].native + " ")
@@ -1139,16 +1390,16 @@ async function At(e, t) {
1139
1390
  //#endregion
1140
1391
  //#region src/extensions/TableHandles/TableHandles.ts
1141
1392
  var X;
1142
- function jt(e) {
1393
+ function Qt(e) {
1143
1394
  X || (X = document.createElement("div"), X.innerHTML = "_", X.style.opacity = "0", X.style.height = "1px", X.style.width = "1px", e instanceof Document ? e.body.appendChild(X) : e.appendChild(X));
1144
1395
  }
1145
- function Mt(e) {
1396
+ function $t(e) {
1146
1397
  X &&= (e instanceof Document ? e.body.removeChild(X) : e.removeChild(X), void 0);
1147
1398
  }
1148
1399
  function Z(e) {
1149
1400
  return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
1150
1401
  }
1151
- function Nt(e) {
1402
+ function en(e) {
1152
1403
  let t = e;
1153
1404
  for (; t && t.nodeName !== "TD" && t.nodeName !== "TH" && !t.classList.contains("tableWrapper");) {
1154
1405
  if (t.classList.contains("ProseMirror")) return;
@@ -1166,11 +1417,11 @@ function Nt(e) {
1166
1417
  tbodyNode: t.querySelector("tbody")
1167
1418
  };
1168
1419
  }
1169
- function Pt(e, t) {
1420
+ function tn(e, t) {
1170
1421
  let n = t.querySelectorAll(e);
1171
1422
  for (let e = 0; e < n.length; e++) n[e].style.visibility = "hidden";
1172
1423
  }
1173
- var Ft = class {
1424
+ var nn = class {
1174
1425
  state;
1175
1426
  emitUpdate;
1176
1427
  tableId;
@@ -1193,7 +1444,7 @@ var Ft = class {
1193
1444
  };
1194
1445
  mouseMoveHandler = (e) => {
1195
1446
  if (this.menuFrozen || this.mouseState === "selecting" || !(e.target instanceof Element) || !this.pmView.dom.contains(e.target)) return;
1196
- let t = Nt(e.target);
1447
+ let t = en(e.target);
1197
1448
  if (t?.type === "cell" && this.mouseState === "down" && !this.state?.draggingState) {
1198
1449
  this.mouseState = "selecting", this.state?.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
1199
1450
  return;
@@ -1203,23 +1454,23 @@ var Ft = class {
1203
1454
  return;
1204
1455
  }
1205
1456
  if (!t.tbodyNode) return;
1206
- let n = t.tbodyNode.getBoundingClientRect(), i = mt(t.domNode, this.pmView);
1457
+ let r = t.tbodyNode.getBoundingClientRect(), i = vt(t.domNode, this.pmView);
1207
1458
  if (!i) return;
1208
1459
  this.tableElement = i.node;
1209
- let a, o = this.editor.transact((e) => r(i.id, e.doc));
1460
+ let a, o = this.editor.transact((e) => n(i.id, e.doc));
1210
1461
  if (!o) throw Error(`Block with ID ${i.id} not found`);
1211
- let s = _(o.node, this.editor.pmSchema, this.editor.schema.blockSchema, this.editor.schema.inlineContentSchema, this.editor.schema.styleSchema);
1462
+ let s = p(o.node, this.editor.pmSchema, this.editor.schema.blockSchema, this.editor.schema.inlineContentSchema, this.editor.schema.styleSchema);
1212
1463
  if (h(this.editor, "table") && (this.tablePos = o.posBeforeNode + 1, a = s), !a) return;
1213
1464
  this.tableId = i.id;
1214
1465
  let c = t.domNode.closest(".tableWrapper")?.querySelector(".table-widgets-container");
1215
1466
  if (t?.type === "wrapper") {
1216
- let t = e.clientY >= n.bottom - 1 && e.clientY < n.bottom + 20, r = e.clientX >= n.right - 1 && e.clientX < n.right + 20, i = this.state?.block.id !== a.id || e.clientX > n.right || e.clientY > n.bottom;
1467
+ let t = e.clientY >= r.bottom - 1 && e.clientY < r.bottom + 20, n = e.clientX >= r.right - 1 && e.clientX < r.right + 20, i = this.state?.block.id !== a.id || e.clientX > r.right || e.clientY > r.bottom;
1217
1468
  this.state = {
1218
1469
  ...this.state,
1219
1470
  show: !0,
1220
1471
  showAddOrRemoveRowsButton: t,
1221
- showAddOrRemoveColumnsButton: r,
1222
- referencePosTable: n,
1472
+ showAddOrRemoveColumnsButton: n,
1473
+ referencePosTable: r,
1223
1474
  block: a,
1224
1475
  widgetContainer: c,
1225
1476
  colIndex: i ? void 0 : this.state?.colIndex,
@@ -1227,18 +1478,18 @@ var Ft = class {
1227
1478
  referencePosCell: i ? void 0 : this.state?.referencePosCell
1228
1479
  };
1229
1480
  } else {
1230
- let e = Z(t.domNode), r = Z(t.domNode.parentElement), o = t.domNode.getBoundingClientRect();
1231
- if (this.state !== void 0 && this.state.show && this.tableId === i.id && this.state.rowIndex === r && this.state.colIndex === e) return;
1481
+ let e = Z(t.domNode), n = Z(t.domNode.parentElement), o = t.domNode.getBoundingClientRect();
1482
+ if (this.state !== void 0 && this.state.show && this.tableId === i.id && this.state.rowIndex === n && this.state.colIndex === e) return;
1232
1483
  this.state = {
1233
1484
  show: !0,
1234
1485
  showAddOrRemoveColumnsButton: e === a.content.rows[0].cells.length - 1,
1235
- showAddOrRemoveRowsButton: r === a.content.rows.length - 1,
1236
- referencePosTable: n,
1486
+ showAddOrRemoveRowsButton: n === a.content.rows.length - 1,
1487
+ referencePosTable: r,
1237
1488
  block: a,
1238
1489
  draggingState: void 0,
1239
1490
  referencePosCell: o,
1240
1491
  colIndex: e,
1241
- rowIndex: r,
1492
+ rowIndex: n,
1242
1493
  widgetContainer: c
1243
1494
  };
1244
1495
  }
@@ -1246,7 +1497,7 @@ var Ft = class {
1246
1497
  };
1247
1498
  dragOverHandler = (e) => {
1248
1499
  if (this.state?.draggingState === void 0) return;
1249
- e.preventDefault(), e.dataTransfer.dropEffect = "move", Pt(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline", this.pmView.root);
1500
+ e.preventDefault(), e.dataTransfer.dropEffect = "move", tn(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline", this.pmView.root);
1250
1501
  let t = {
1251
1502
  left: Math.min(Math.max(e.clientX, this.state.referencePosTable.left + 1), this.state.referencePosTable.right - 1),
1252
1503
  top: Math.min(Math.max(e.clientY, this.state.referencePosTable.top + 1), this.state.referencePosTable.bottom - 1)
@@ -1261,12 +1512,12 @@ var Ft = class {
1261
1512
  if (this.mouseState = "up", this.state === void 0 || this.state.draggingState === void 0) return !1;
1262
1513
  if (this.state.rowIndex === void 0 || this.state.colIndex === void 0) throw Error("Attempted to drop table row or column, but no table block was hovered prior.");
1263
1514
  e.preventDefault();
1264
- let { draggingState: n, colIndex: r, rowIndex: i } = this.state;
1515
+ let { draggingState: n, colIndex: i, rowIndex: a } = this.state;
1265
1516
  this.state.draggingState = void 0;
1266
- let a = this.state.block.content.columnWidths;
1517
+ let o = this.state.block.content.columnWidths;
1267
1518
  if (n.draggedCellOrientation === "row") {
1268
- if (!l(this.state.block, n.originalIndex, i)) return !1;
1269
- let e = t(this.state.block, n.originalIndex, i);
1519
+ if (!r(this.state.block, n.originalIndex, a)) return !1;
1520
+ let e = d(this.state.block, n.originalIndex, a);
1270
1521
  this.editor.updateBlock(this.state.block, {
1271
1522
  type: "table",
1272
1523
  content: {
@@ -1275,13 +1526,13 @@ var Ft = class {
1275
1526
  }
1276
1527
  });
1277
1528
  } else {
1278
- if (!c(this.state.block, n.originalIndex, r)) return !1;
1279
- let e = ne(this.state.block, n.originalIndex, r), [t] = a.splice(n.originalIndex, 1);
1280
- a.splice(r, 0, t), this.editor.updateBlock(this.state.block, {
1529
+ if (!l(this.state.block, n.originalIndex, i)) return !1;
1530
+ let e = t(this.state.block, n.originalIndex, i), [r] = o.splice(n.originalIndex, 1);
1531
+ o.splice(i, 0, r), this.editor.updateBlock(this.state.block, {
1281
1532
  type: "table",
1282
1533
  content: {
1283
1534
  ...this.state.block.content,
1284
- columnWidths: a,
1535
+ columnWidths: o,
1285
1536
  rows: e
1286
1537
  }
1287
1538
  });
@@ -1294,7 +1545,7 @@ var Ft = class {
1294
1545
  this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate();
1295
1546
  return;
1296
1547
  }
1297
- let { height: e, width: t } = d(this.state.block);
1548
+ let { height: e, width: t } = ie(this.state.block);
1298
1549
  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));
1299
1550
  let n = this.tableElement.querySelector("tbody");
1300
1551
  if (!n) throw Error("Table block does not contain a 'tbody' HTML element. This should never happen.");
@@ -1307,14 +1558,14 @@ var Ft = class {
1307
1558
  destroy() {
1308
1559
  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);
1309
1560
  }
1310
- }, Q = new T("TableHandlesPlugin"), It = b(({ editor: e }) => {
1311
- let t, n = y(void 0);
1561
+ }, Q = new x("TableHandlesPlugin"), rn = v(({ editor: e }) => {
1562
+ let t, n = _(void 0);
1312
1563
  return {
1313
1564
  key: "tableHandles",
1314
1565
  store: n,
1315
- prosemirrorPlugins: [new w({
1566
+ prosemirrorPlugins: [new b({
1316
1567
  key: Q,
1317
- view: (r) => (t = new Ft(e, r, (e) => {
1568
+ view: (r) => (t = new nn(e, r, (e) => {
1318
1569
  n.setState(e.block ? {
1319
1570
  ...e,
1320
1571
  draggingState: e.draggingState ? { ...e.draggingState } : void 0
@@ -1324,22 +1575,22 @@ var Ft = class {
1324
1575
  if (t === void 0 || t.state === void 0 || t.state.draggingState === void 0 || t.tablePos === void 0) return;
1325
1576
  let n = t.state.draggingState.draggedCellOrientation === "row" ? t.state.rowIndex : t.state.colIndex;
1326
1577
  if (n === void 0) return;
1327
- let r = [], { block: i, draggingState: s } = t.state, { originalIndex: u, draggedCellOrientation: d } = s;
1328
- if (n === u || !i || d === "row" && !l(i, u, n) || d === "col" && !c(i, u, n)) return A.create(e.doc, r);
1578
+ let i = [], { block: o, draggingState: s } = t.state, { originalIndex: c, draggedCellOrientation: d } = s;
1579
+ if (n === c || !o || d === "row" && !r(o, c, n) || d === "col" && !l(o, c, n)) return T.create(e.doc, i);
1329
1580
  let f = e.doc.resolve(t.tablePos + 1);
1330
- return t.state.draggingState.draggedCellOrientation === "row" ? o(t.state.block, n).forEach(({ row: t, col: i }) => {
1331
- let a = e.doc.resolve(f.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(i) + 1), s = o.node(), c = o.pos + (n > u ? s.nodeSize - 2 : 0);
1332
- r.push(k.widget(c, () => {
1581
+ return t.state.draggingState.draggedCellOrientation === "row" ? u(t.state.block, n).forEach(({ row: t, col: r }) => {
1582
+ let a = e.doc.resolve(f.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(r) + 1), s = o.node(), l = o.pos + (n > c ? s.nodeSize - 2 : 0);
1583
+ i.push(w.widget(l, () => {
1333
1584
  let e = document.createElement("div");
1334
- return e.className = "bn-table-drop-cursor", e.style.left = "0", e.style.right = "0", n > u ? e.style.bottom = "-2px" : e.style.top = "-3px", e.style.height = "4px", e;
1585
+ return e.className = "bn-table-drop-cursor", e.style.left = "0", e.style.right = "0", n > c ? e.style.bottom = "-2px" : e.style.top = "-3px", e.style.height = "4px", e;
1335
1586
  }));
1336
- }) : a(t.state.block, n).forEach(({ row: t, col: i }) => {
1337
- let a = e.doc.resolve(f.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(i) + 1), s = o.node(), c = o.pos + (n > u ? s.nodeSize - 2 : 0);
1338
- r.push(k.widget(c, () => {
1587
+ }) : a(t.state.block, n).forEach(({ row: t, col: r }) => {
1588
+ let a = e.doc.resolve(f.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(r) + 1), s = o.node(), l = o.pos + (n > c ? s.nodeSize - 2 : 0);
1589
+ i.push(w.widget(l, () => {
1339
1590
  let e = document.createElement("div");
1340
- return e.className = "bn-table-drop-cursor", e.style.top = "0", e.style.bottom = "0", n > u ? e.style.right = "-2px" : e.style.left = "-3px", e.style.width = "4px", e;
1591
+ return e.className = "bn-table-drop-cursor", e.style.top = "0", e.style.bottom = "0", n > c ? e.style.right = "-2px" : e.style.left = "-3px", e.style.width = "4px", e;
1341
1592
  }));
1342
- }), A.create(e.doc, r);
1593
+ }), T.create(e.doc, i);
1343
1594
  } }
1344
1595
  })],
1345
1596
  colDragStart(n) {
@@ -1353,7 +1604,7 @@ var Ft = class {
1353
1604
  originalIndex: t.state.colIndex,
1354
1605
  newIndex: t.state.colIndex,
1355
1606
  tablePos: t.tablePos
1356
- })), !e.headless && (jt(e.prosemirrorView.root), n.dataTransfer.setDragImage(X, 0, 0), n.dataTransfer.effectAllowed = "move");
1607
+ })), !e.headless && (Qt(e.prosemirrorView.root), n.dataTransfer.setDragImage(X, 0, 0), n.dataTransfer.effectAllowed = "move");
1357
1608
  },
1358
1609
  rowDragStart(n) {
1359
1610
  if (t.state === void 0 || t.state.rowIndex === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
@@ -1366,11 +1617,11 @@ var Ft = class {
1366
1617
  originalIndex: t.state.rowIndex,
1367
1618
  newIndex: t.state.rowIndex,
1368
1619
  tablePos: t.tablePos
1369
- })), !e.headless && (jt(e.prosemirrorView.root), n.dataTransfer.setDragImage(X, 0, 0), n.dataTransfer.effectAllowed = "copyMove");
1620
+ })), !e.headless && (Qt(e.prosemirrorView.root), n.dataTransfer.setDragImage(X, 0, 0), n.dataTransfer.effectAllowed = "copyMove");
1370
1621
  },
1371
1622
  dragEnd() {
1372
1623
  if (t.state === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
1373
- t.state.draggingState = void 0, t.emitUpdate(), e.transact((e) => e.setMeta(Q, null)), !e.headless && Mt(e.prosemirrorView.root);
1624
+ t.state.draggingState = void 0, t.emitUpdate(), e.transact((e) => e.setMeta(Q, null)), !e.headless && $t(e.prosemirrorView.root);
1374
1625
  },
1375
1626
  freezeHandles() {
1376
1627
  t.menuFrozen = !0;
@@ -1382,7 +1633,7 @@ var Ft = class {
1382
1633
  !t.menuFrozen && t.state?.show && (t.state.show = !1, t.state.showAddOrRemoveRowsButton = !1, t.state.showAddOrRemoveColumnsButton = !1, t.emitUpdate());
1383
1634
  },
1384
1635
  getCellsAtRowHandle(e, t) {
1385
- return o(e, t);
1636
+ return u(e, t);
1386
1637
  },
1387
1638
  getCellsAtColumnHandle(e, t) {
1388
1639
  return a(e, t);
@@ -1390,7 +1641,7 @@ var Ft = class {
1390
1641
  setCellSelection(e, n, r = n) {
1391
1642
  if (!t) throw Error("Table handles view not initialized");
1392
1643
  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;
1393
- return l.setSelection(new fe(o, c)), e.apply(l);
1644
+ return l.setSelection(new ge(o, c)), e.apply(l);
1394
1645
  },
1395
1646
  addRowOrColumn(t, n) {
1396
1647
  e.exec((e, r) => {
@@ -1401,28 +1652,28 @@ var Ft = class {
1401
1652
  row: 0,
1402
1653
  col: t
1403
1654
  });
1404
- return n.orientation === "row" ? n.side === "above" ? ge(i, r) : he(i, r) : n.side === "left" ? me(i, r) : pe(i, r);
1655
+ return n.orientation === "row" ? n.side === "above" ? be(i, r) : ye(i, r) : n.side === "left" ? ve(i, r) : _e(i, r);
1405
1656
  });
1406
1657
  },
1407
1658
  removeRowOrColumn(t, n) {
1408
- return n === "row" ? e.exec((e, n) => ve(this.setCellSelection(e, {
1659
+ return n === "row" ? e.exec((e, n) => Se(this.setCellSelection(e, {
1409
1660
  row: t,
1410
1661
  col: 0
1411
- }), n)) : e.exec((e, n) => _e(this.setCellSelection(e, {
1662
+ }), n)) : e.exec((e, n) => xe(this.setCellSelection(e, {
1412
1663
  row: 0,
1413
1664
  col: t
1414
1665
  }), n));
1415
1666
  },
1416
1667
  mergeCells(t) {
1417
- return e.exec((e, n) => ye(t ? this.setCellSelection(e, t.relativeStartCell, t.relativeEndCell) : e, n));
1668
+ return e.exec((e, n) => Ce(t ? this.setCellSelection(e, t.relativeStartCell, t.relativeEndCell) : e, n));
1418
1669
  },
1419
1670
  splitCell(t) {
1420
- return e.exec((e, n) => be(t ? this.setCellSelection(e, t) : e, n));
1671
+ return e.exec((e, n) => we(t ? this.setCellSelection(e, t) : e, n));
1421
1672
  },
1422
1673
  getCellSelection() {
1423
1674
  return e.transact((e) => {
1424
1675
  let t = e.selection, n = t.$from, r = t.$to;
1425
- if (m(t)) {
1676
+ if (f(t)) {
1426
1677
  let { ranges: e } = t;
1427
1678
  e.forEach((e) => {
1428
1679
  n = e.$from.min(n ?? e.$from), r = e.$to.max(r ?? e.$to);
@@ -1448,7 +1699,7 @@ var Ft = class {
1448
1699
  },
1449
1700
  getMergeDirection(t) {
1450
1701
  return e.transact((e) => {
1451
- let n = m(e.selection) ? e.selection : void 0;
1702
+ let n = f(e.selection) ? e.selection : void 0;
1452
1703
  if (!n || !t || n.ranges.length <= 1) return;
1453
1704
  let r = this.getCellSelection();
1454
1705
  if (r) return s(r.from, r.to, t) ? "vertical" : "horizontal";
@@ -1458,32 +1709,50 @@ var Ft = class {
1458
1709
  return i(e, t);
1459
1710
  },
1460
1711
  addRowsOrColumns(e, t, n) {
1461
- return ee(e, t, n);
1712
+ return o(e, t, n);
1462
1713
  }
1463
1714
  };
1464
- }), $ = new T("trailingNode"), Lt = b(() => ({
1465
- key: "trailingNode",
1466
- prosemirrorPlugins: [new w({
1467
- key: $,
1468
- appendTransaction: (e, t, n) => {
1469
- let { doc: r, tr: i, schema: a } = n, o = $.getState(n), s = r.content.size - 2, c = a.nodes.blockContainer, l = a.nodes.paragraph;
1470
- if (o) return i.insert(s, c.create(void 0, l.create()));
1471
- },
1472
- state: {
1473
- init: (e, t) => {},
1474
- apply: (e, t) => {
1475
- if (!e.docChanged) return t;
1476
- let n = e.doc.lastChild;
1477
- if (!n || n.type.name !== "blockGroup") throw Error("Expected blockGroup");
1478
- if (n = n.lastChild, !n || n.type.name !== "blockContainer") return !0;
1479
- let r = n.firstChild;
1480
- if (!r) throw Error("Expected blockContent");
1481
- return n.nodeSize > 4 || r.type.spec.content !== "inline*";
1482
- }
1483
- }
1484
- })]
1485
- }));
1715
+ }), $ = new x("trailingNode");
1716
+ function an(e, t) {
1717
+ if (!t) return !1;
1718
+ let n = e.lastChild?.lastChild, r = n?.firstChild;
1719
+ return !(n?.type.name === "blockContainer" && r?.type.name === "paragraph" && r.content.size === 0);
1720
+ }
1721
+ var on = v(({ editor: e }) => {
1722
+ function t(t) {
1723
+ return w.widget(t, () => {
1724
+ let t = document.createElement("div");
1725
+ return t.className = "bn-trailing-block", t.contentEditable = "false", t.addEventListener("mousedown", (t) => {
1726
+ t.preventDefault(), e.transact((t) => {
1727
+ let [n] = e.insertBlocks([{ type: "paragraph" }], e.document[e.document.length - 1], "after");
1728
+ e.setTextCursorPosition(n, "start"), t.scrollIntoView();
1729
+ }), e.prosemirrorView?.focus();
1730
+ }), t;
1731
+ }, { side: 1 });
1732
+ }
1733
+ function n(e, n, r) {
1734
+ let i = n.map(e.mapping, e.doc), a = i.find(), o = a.length > 0;
1735
+ return o === an(e.doc, r) ? i : o ? i.remove(a) : i.add(e.doc, [t(e.doc.content.size - 1)]);
1736
+ }
1737
+ return {
1738
+ key: "trailingNode",
1739
+ prosemirrorPlugins: [new b({
1740
+ key: $,
1741
+ state: {
1742
+ init: (t, r) => n(r.tr, T.empty, e.isEditable),
1743
+ apply: (t, r) => !t.docChanged && !t.getMeta($) ? r : n(t, r, e.isEditable)
1744
+ },
1745
+ view(e) {
1746
+ let t = e.editable;
1747
+ return { update(e) {
1748
+ e.editable !== t && (t = e.editable, e.dispatch(e.state.tr.setMeta($, !0)));
1749
+ } };
1750
+ },
1751
+ props: { decorations: (e) => $.getState(e) }
1752
+ })]
1753
+ };
1754
+ });
1486
1755
  //#endregion
1487
- export { qe as C, We as D, B as E, R as O, Ye as S, V as T, it as _, At as a, et as b, Dt as c, G as d, pt as f, at as g, ot as h, Q as i, I as k, yt as l, ct as m, It as n, Ot as o, ut as p, Ft as r, Et as s, Lt as t, vt as u, rt as v, H as w, tt as x, nt as y };
1756
+ export { j as C, Ke as D, qe as E, O, Ze as S, k as T, ct as _, Zt as a, ot as b, Jt as c, W as d, _t as f, lt as g, ut as h, Q as i, Vt as l, ft as m, rn as n, Yt as o, mt as p, nn as r, J as s, on as t, Bt as u, st as v, A as w, $e as x, at as y };
1488
1757
 
1489
- //# sourceMappingURL=extensions-CkLT--Nc.js.map
1758
+ //# sourceMappingURL=extensions-D2mx2C9y.js.map