@blocknote/core 0.47.3 → 0.48.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 (121) hide show
  1. package/dist/BlockNoteExtension-B6RhuQ3V.js +27 -0
  2. package/dist/BlockNoteExtension-B6RhuQ3V.js.map +1 -0
  3. package/dist/BlockNoteExtension-ab0REuob.cjs +2 -0
  4. package/dist/BlockNoteExtension-ab0REuob.cjs.map +1 -0
  5. package/dist/EventEmitter-CuPnGDYt.js +22 -0
  6. package/dist/EventEmitter-CuPnGDYt.js.map +1 -0
  7. package/dist/EventEmitter-DHdSnYCD.cjs +2 -0
  8. package/dist/EventEmitter-DHdSnYCD.cjs.map +1 -0
  9. package/dist/ShowSelection-BsHFfdMi.js +29 -0
  10. package/dist/ShowSelection-BsHFfdMi.js.map +1 -0
  11. package/dist/ShowSelection-DhXglbt8.cjs +2 -0
  12. package/dist/ShowSelection-DhXglbt8.cjs.map +1 -0
  13. package/dist/blocknote.cjs +1 -5
  14. package/dist/blocknote.js +7 -4256
  15. package/dist/blocks-BEvIOzln.cjs +11 -0
  16. package/dist/blocks-BEvIOzln.cjs.map +1 -0
  17. package/dist/blocks-DYl7UTS4.js +3313 -0
  18. package/dist/blocks-DYl7UTS4.js.map +1 -0
  19. package/dist/blocks.cjs +1 -2
  20. package/dist/blocks.js +2 -74
  21. package/dist/comments.cjs +2 -2
  22. package/dist/comments.cjs.map +1 -1
  23. package/dist/comments.js +604 -900
  24. package/dist/comments.js.map +1 -1
  25. package/dist/en-C4ykW581.cjs +2 -0
  26. package/dist/en-C4ykW581.cjs.map +1 -0
  27. package/dist/en-QsSI16s5.js +453 -0
  28. package/dist/en-QsSI16s5.js.map +1 -0
  29. package/dist/extensions-3nf9PPhA.js +1495 -0
  30. package/dist/extensions-3nf9PPhA.js.map +1 -0
  31. package/dist/extensions-D9y6evn6.cjs +2 -0
  32. package/dist/extensions-D9y6evn6.cjs.map +1 -0
  33. package/dist/extensions.cjs +1 -2
  34. package/dist/extensions.js +4 -36
  35. package/dist/locales.cjs +2 -2
  36. package/dist/locales.cjs.map +1 -1
  37. package/dist/locales.js +10049 -9111
  38. package/dist/locales.js.map +1 -1
  39. package/dist/src-BKJH7Jla.cjs +5 -0
  40. package/dist/src-BKJH7Jla.cjs.map +1 -0
  41. package/dist/src-Hjv1f5lc.js +2386 -0
  42. package/dist/src-Hjv1f5lc.js.map +1 -0
  43. package/dist/style.css +2 -1
  44. package/dist/webpack-stats.json +1 -1
  45. package/dist/yjs.cjs +2 -2
  46. package/dist/yjs.cjs.map +1 -1
  47. package/dist/yjs.js +20 -38
  48. package/dist/yjs.js.map +1 -1
  49. package/package.json +8 -8
  50. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +15 -1
  51. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +5 -0
  52. package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +1095 -0
  53. package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +661 -0
  54. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +128 -11
  55. package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +17 -23
  56. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +346 -0
  57. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +143 -71
  58. package/src/editor/Block.css +5 -8
  59. package/src/editor/BlockNoteEditor.ts +38 -1
  60. package/src/editor/editor.css +0 -20
  61. package/src/editor/managers/ExtensionManager/extensions.ts +12 -1
  62. package/src/editor/performance.test.ts +134 -0
  63. package/src/extensions/Collaboration/ForkYDoc.test.ts +115 -103
  64. package/src/extensions/Placeholder/Placeholder.ts +1 -1
  65. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +86 -0
  66. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +33 -49
  67. package/src/extensions/SideMenu/SideMenu.ts +14 -8
  68. package/src/extensions/TableHandles/TableHandles.ts +14 -0
  69. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +57 -17
  70. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +9 -8
  71. package/src/index.ts +1 -1
  72. package/src/schema/blocks/createSpec.ts +6 -2
  73. package/src/schema/inlineContent/types.ts +0 -1
  74. package/src/vite-env.d.ts +6 -0
  75. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +14 -1
  76. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +1 -0
  77. package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +1 -0
  78. package/types/src/editor/BlockNoteEditor.d.ts +13 -0
  79. package/types/src/editor/performance.test.d.ts +1 -0
  80. package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +1 -0
  81. package/types/src/extensions/SideMenu/SideMenu.d.ts +6 -0
  82. package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -0
  83. package/dist/BlockNoteExtension-BWw0r8Gy.cjs +0 -2
  84. package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +0 -1
  85. package/dist/BlockNoteExtension-C2X7LW-V.js +0 -25
  86. package/dist/BlockNoteExtension-C2X7LW-V.js.map +0 -1
  87. package/dist/BlockNoteSchema-CCs_V3lo.cjs +0 -2
  88. package/dist/BlockNoteSchema-CCs_V3lo.cjs.map +0 -1
  89. package/dist/BlockNoteSchema-ooiKsd5B.js +0 -270
  90. package/dist/BlockNoteSchema-ooiKsd5B.js.map +0 -1
  91. package/dist/EventEmitter-CLwfmbqG.cjs +0 -2
  92. package/dist/EventEmitter-CLwfmbqG.cjs.map +0 -1
  93. package/dist/EventEmitter-CjSwpTbz.js +0 -27
  94. package/dist/EventEmitter-CjSwpTbz.js.map +0 -1
  95. package/dist/ShowSelection-B0ch3unP.js +0 -51
  96. package/dist/ShowSelection-B0ch3unP.js.map +0 -1
  97. package/dist/ShowSelection-BxnbRvy4.cjs +0 -2
  98. package/dist/ShowSelection-BxnbRvy4.cjs.map +0 -1
  99. package/dist/TrailingNode-GzE59m_7.js +0 -2288
  100. package/dist/TrailingNode-GzE59m_7.js.map +0 -1
  101. package/dist/TrailingNode-n0WdMPUl.cjs +0 -2
  102. package/dist/TrailingNode-n0WdMPUl.cjs.map +0 -1
  103. package/dist/blockToNode-BNoNIXU7.js +0 -1140
  104. package/dist/blockToNode-BNoNIXU7.js.map +0 -1
  105. package/dist/blockToNode-CumVjgem.cjs +0 -7
  106. package/dist/blockToNode-CumVjgem.cjs.map +0 -1
  107. package/dist/blocknote.cjs.map +0 -1
  108. package/dist/blocknote.js.map +0 -1
  109. package/dist/blocks.cjs.map +0 -1
  110. package/dist/blocks.js.map +0 -1
  111. package/dist/defaultBlocks-Dg9kQWXm.cjs +0 -6
  112. package/dist/defaultBlocks-Dg9kQWXm.cjs.map +0 -1
  113. package/dist/defaultBlocks-ZzGbYgQn.js +0 -3284
  114. package/dist/defaultBlocks-ZzGbYgQn.js.map +0 -1
  115. package/dist/en-Cl87Uuyf.cjs +0 -2
  116. package/dist/en-Cl87Uuyf.cjs.map +0 -1
  117. package/dist/en-njEqD7AG.js +0 -408
  118. package/dist/en-njEqD7AG.js.map +0 -1
  119. package/dist/extensions.cjs.map +0 -1
  120. package/dist/extensions.js.map +0 -1
  121. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,2386 @@
1
+ import { An as e, At as t, Ct as n, En as r, Et as i, Ht as a, Jn as o, Ln as s, Ot as c, Qt as l, Rn as u, Tt as d, V as f, Xt as p, Zt as m, an as h, cn as ee, dn as g, f as te, gn as _, gt as ne, hn as v, in as y, kt as b, mn as x, nn as re, on as ie, pn as S, pt as C, rn as ae, t as oe, tn as se, vn as w, vt as ce, wt as le } from "./blocks-DYl7UTS4.js";
2
+ import { C as ue, D as de, E as fe, O as pe, S as me, T as he, _ as ge, d as _e, f as ve, g as ye, h as be, k as xe, l as Se, m as Ce, n as we, o as Te, p as Ee, t as De, u as Oe, v as ke, w as Ae, x as je, y as T } from "./extensions-3nf9PPhA.js";
3
+ import { r as Me, t as Ne } from "./BlockNoteExtension-B6RhuQ3V.js";
4
+ import { t as Pe } from "./ShowSelection-BsHFfdMi.js";
5
+ import { t as Fe } from "./en-QsSI16s5.js";
6
+ import { t as Ie } from "./EventEmitter-CuPnGDYt.js";
7
+ import { DOMParser as Le, DOMSerializer as Re, Fragment as E, Node as ze, NodeRange as Be, Slice as D } from "prosemirror-model";
8
+ import { ReplaceAroundStep as O, ReplaceStep as Ve, canJoin as He, liftTarget as Ue } from "prosemirror-transform";
9
+ import { Editor as We, Extension as k, Mark as A, Node as j, createDocument as Ge, extensions as M, findParentNodeClosestToPos as Ke, getSchema as qe, isNodeSelection as Je, mergeAttributes as Ye, posToDOMRect as Xe, selectionToInsertionEnd as Ze } from "@tiptap/core";
10
+ import { NodeSelection as N, Plugin as P, TextSelection as F } from "prosemirror-state";
11
+ import { Fragment as I, Slice as L } from "@tiptap/pm/model";
12
+ import { CellSelection as R, TableMap as Qe } from "prosemirror-tables";
13
+ import { TextSelection as $e } from "@tiptap/pm/state";
14
+ import et from "remark-gfm";
15
+ import { unified as tt } from "unified";
16
+ import nt from "remark-parse";
17
+ import rt, { defaultHandlers as it } from "remark-rehype";
18
+ import at from "rehype-stringify";
19
+ import { InputRule as ot, inputRules as st } from "@handlewithcare/prosemirror-inputrules";
20
+ import { keymap as ct } from "@tiptap/pm/keymap";
21
+ import { Gapcursor as lt } from "@tiptap/extensions/gap-cursor";
22
+ import { Link as ut } from "@tiptap/extension-link";
23
+ import { Text as dt } from "@tiptap/extension-text";
24
+ //#region src/schema/inlineContent/createSpec.ts
25
+ function ft(e, t) {
26
+ let n = [{
27
+ tag: `[data-inline-content-type="${e.type}"]`,
28
+ contentElement: (e) => {
29
+ let t = e;
30
+ return t.matches("[data-editable]") ? t : t.querySelector("[data-editable]") || t;
31
+ }
32
+ }];
33
+ return t && n.push({
34
+ tag: "*",
35
+ getAttrs(e) {
36
+ if (typeof e == "string") return !1;
37
+ let n = t?.(e);
38
+ return n === void 0 ? !1 : n;
39
+ }
40
+ }), n;
41
+ }
42
+ function pt(e, t) {
43
+ return l(j.create({
44
+ name: e.type,
45
+ inline: !0,
46
+ group: "inline",
47
+ draggable: t.meta?.draggable,
48
+ selectable: e.content === "styled",
49
+ atom: e.content === "none",
50
+ content: e.content === "styled" ? "inline*" : "",
51
+ addAttributes() {
52
+ return r(e.propSchema);
53
+ },
54
+ addKeyboardShortcuts() {
55
+ return m(e);
56
+ },
57
+ parseHTML() {
58
+ return ft(e, t.parse);
59
+ },
60
+ renderHTML({ node: n }) {
61
+ let r = this.options.editor;
62
+ return p(t.render.call({
63
+ renderType: "dom",
64
+ props: void 0
65
+ }, h(n, r.schema.inlineContentSchema, r.schema.styleSchema), () => {}, r), e.type, n.attrs, e.propSchema);
66
+ },
67
+ addNodeView() {
68
+ return (n) => {
69
+ let { node: r, getPos: i } = n, a = this.options.editor;
70
+ return p(t.render.call({
71
+ renderType: "nodeView",
72
+ props: n
73
+ }, h(r, a.schema.inlineContentSchema, a.schema.styleSchema), (e) => {
74
+ let t = b([e], a.pmSchema), n = i();
75
+ n && a.transact((e) => e.replaceWith(n, n + r.nodeSize, t));
76
+ }, a), e.type, r.attrs, e.propSchema);
77
+ };
78
+ }
79
+ }), e.propSchema, {
80
+ ...t,
81
+ toExternalHTML: t.toExternalHTML,
82
+ render(n, r, i) {
83
+ return p(t.render(n, r, i), e.type, n.props, e.propSchema);
84
+ }
85
+ });
86
+ }
87
+ //#endregion
88
+ //#region src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts
89
+ function mt(e, t, n, r = "before") {
90
+ let a = typeof n == "string" ? n : n.id, o = g(e), s = t.map((e) => c(e, o)), l = i(a, e.doc);
91
+ if (!l) throw Error(`Block with ID ${a} not found`);
92
+ let u = l.posBeforeNode;
93
+ return r === "after" && (u += l.node.nodeSize), e.step(new Ve(u, u, new D(E.from(s), 0, 0))), s.map((e) => y(e, o));
94
+ }
95
+ //#endregion
96
+ //#region src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts
97
+ function z(e) {
98
+ if (!e || e.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
99
+ let t = e.firstChild;
100
+ if (!t) throw Error("Invalid column: does not have child node.");
101
+ let n = t.firstChild;
102
+ if (!n) throw Error("Invalid blockContainer: does not have child node.");
103
+ return e.childCount === 1 && t.childCount === 1 && n.type.name === "paragraph" && n.content.content.length === 0;
104
+ }
105
+ function ht(e, t) {
106
+ let n = e.doc.resolve(t), r = n.nodeAfter;
107
+ if (!r || r.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
108
+ for (let t = r.childCount - 1; t >= 0; t--) {
109
+ let r = e.doc.resolve(n.pos + 1).posAtIndex(t), i = e.doc.resolve(r).nodeAfter;
110
+ if (!i || i.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
111
+ z(i) && e.delete(r, r + i.nodeSize);
112
+ }
113
+ }
114
+ function B(e, t) {
115
+ ht(e, t);
116
+ let n = e.doc.resolve(t).nodeAfter;
117
+ if (!n || n.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
118
+ if (n.childCount > 2) return;
119
+ if (n.childCount < 2) throw Error("Invalid columnList: contains fewer than two children.");
120
+ let r = t + 1, i = e.doc.resolve(r).nodeAfter, a = t + n.nodeSize - 1, o = e.doc.resolve(a).nodeBefore;
121
+ if (!i || !o) throw Error("Invalid columnList: does not contain children.");
122
+ let s = z(i), c = z(o);
123
+ if (s && c) {
124
+ e.delete(t, t + n.nodeSize);
125
+ return;
126
+ }
127
+ if (s) {
128
+ e.step(new O(t, t + n.nodeSize, a - o.nodeSize + 1, a - 1, D.empty, 0, !1));
129
+ return;
130
+ }
131
+ if (c) {
132
+ e.step(new O(t, t + n.nodeSize, r + 1, r + i.nodeSize - 1, D.empty, 0, !1));
133
+ return;
134
+ }
135
+ }
136
+ //#endregion
137
+ //#region src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts
138
+ function V(e, t, n) {
139
+ let r = g(e), i = n.map((e) => c(e, r)), a = new Set(t.map((e) => typeof e == "string" ? e : e.id)), o = [], s = /* @__PURE__ */ new Set(), l = typeof t[0] == "string" ? t[0] : t[0].id, u = 0;
140
+ if (e.doc.descendants((t, c) => {
141
+ if (a.size === 0) return !1;
142
+ if (!t.type.isInGroup("bnBlock") || !a.has(t.attrs.id)) return !0;
143
+ if (o.push(y(t, r)), a.delete(t.attrs.id), n.length > 0 && t.attrs.id === l) {
144
+ let t = e.doc.nodeSize;
145
+ e.insert(c, i);
146
+ let n = e.doc.nodeSize;
147
+ u += t - n;
148
+ }
149
+ let d = e.doc.nodeSize, f = e.doc.resolve(c - u);
150
+ f.node().type.name === "column" ? s.add(f.before(-1)) : f.node().type.name === "columnList" && s.add(f.before()), f.node().type.name === "blockGroup" && f.node(f.depth - 1).type.name !== "doc" && f.node().childCount === 1 ? e.delete(f.before(), f.after()) : e.delete(c - u, c - u + t.nodeSize);
151
+ let p = e.doc.nodeSize;
152
+ return u += d - p, !1;
153
+ }), a.size > 0) {
154
+ let e = [...a].join("\n");
155
+ throw Error("Blocks with the following IDs could not be found in the editor: " + e);
156
+ }
157
+ return s.forEach((t) => B(e, t)), {
158
+ insertedBlocks: i.map((e) => y(e, r)),
159
+ removedBlocks: o
160
+ };
161
+ }
162
+ //#endregion
163
+ //#region src/api/exporters/html/util/serializeBlocksInternalHTML.ts
164
+ function gt(e, n, r, i, a) {
165
+ let o;
166
+ if (!n) throw Error("blockContent is required");
167
+ if (typeof n == "string") o = b([n], e.pmSchema, i);
168
+ else if (Array.isArray(n)) o = b(n, e.pmSchema, i);
169
+ else if (n.type === "tableContent") o = t(n, e.pmSchema);
170
+ else throw new u(n.type);
171
+ let s = (a?.document ?? document).createDocumentFragment();
172
+ for (let t of o) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
173
+ let n = e.schema.inlineContentSpecs[t.type.name].implementation;
174
+ if (n) {
175
+ let i = h(t, e.schema.inlineContentSchema, e.schema.styleSchema), o = n.render.call({
176
+ renderType: "dom",
177
+ props: void 0
178
+ }, i, () => {}, e);
179
+ if (o) {
180
+ if (s.appendChild(o.dom), o.contentDOM) {
181
+ let e = r.serializeFragment(t.content, a);
182
+ o.contentDOM.dataset.editable = "", o.contentDOM.appendChild(e);
183
+ }
184
+ continue;
185
+ }
186
+ }
187
+ } else if (t.type.name === "text") {
188
+ let n = document.createTextNode(t.textContent);
189
+ for (let r of t.marks.toReversed()) if (r.type.name in e.schema.styleSpecs) {
190
+ let t = e.schema.styleSpecs[r.type.name].implementation.render(r.attrs.stringValue, e);
191
+ t.contentDOM.appendChild(n), n = t.dom;
192
+ } else {
193
+ let e = r.type.spec.toDOM(r, !0), t = Re.renderSpec(document, e);
194
+ t.contentDOM.appendChild(n), n = t.dom;
195
+ }
196
+ s.appendChild(n);
197
+ } else {
198
+ let e = r.serializeFragment(E.from([t]), a);
199
+ s.appendChild(e);
200
+ }
201
+ return s;
202
+ }
203
+ function _t(e, t, n, r) {
204
+ let i = e.pmSchema.nodes.blockContainer, a = t.props || {};
205
+ for (let [n, r] of Object.entries(e.schema.blockSchema[t.type].propSchema)) !(n in a) && r.default !== void 0 && (a[n] = r.default);
206
+ let o = t.children || [], s = e.blockImplementations[t.type].implementation.render.call({
207
+ renderType: "dom",
208
+ props: void 0
209
+ }, {
210
+ ...t,
211
+ props: a,
212
+ children: o
213
+ }, e);
214
+ if (s.contentDOM && t.content) {
215
+ let i = gt(e, t.content, n, t.type, r);
216
+ s.contentDOM.appendChild(i);
217
+ }
218
+ if (e.pmSchema.nodes[t.type].isInGroup("bnBlock")) {
219
+ if (t.children && t.children.length > 0) {
220
+ let i = vt(e, t.children, n, r);
221
+ s.contentDOM?.append(i);
222
+ }
223
+ return s.dom;
224
+ }
225
+ let c = i.spec?.toDOM?.(i.create({
226
+ id: t.id,
227
+ ...a
228
+ }));
229
+ return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(H(e, t.children, n, r)), c.dom;
230
+ }
231
+ function vt(e, t, n, r) {
232
+ let i = (r?.document ?? document).createDocumentFragment();
233
+ for (let a of t) {
234
+ let t = _t(e, a, n, r);
235
+ i.appendChild(t);
236
+ }
237
+ return i;
238
+ }
239
+ var H = (e, t, n, r) => {
240
+ let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o = vt(e, t, n, r);
241
+ return a.contentDOM?.appendChild(o), a.dom;
242
+ }, yt = (e) => (e.querySelectorAll("[data-content-type=\"numberedListItem\"]").forEach((e) => {
243
+ let t = e.closest(".bn-block-outer")?.previousElementSibling?.querySelector("[data-content-type=\"numberedListItem\"]");
244
+ if (!t) e.setAttribute("data-index", e.getAttribute("data-start") || "1");
245
+ else {
246
+ let n = t.getAttribute("data-index");
247
+ e.setAttribute("data-index", (parseInt(n || "0") + 1).toString());
248
+ }
249
+ }), e), bt = (e) => (e.querySelectorAll("[data-content-type=\"checkListItem\"] input").forEach((e) => {
250
+ e.disabled = !0;
251
+ }), e), xt = (e) => (e.querySelectorAll(".bn-toggle-wrapper[data-show-children=\"false\"]").forEach((e) => {
252
+ e.setAttribute("data-show-children", "true");
253
+ }), e), St = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
254
+ e.setAttribute("style", "--default-cell-min-width: 120px;"), e.setAttribute("data-show-children", "true");
255
+ }), e), Ct = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
256
+ let t = document.createElement("div");
257
+ t.className = "tableWrapper";
258
+ let n = document.createElement("div");
259
+ n.className = "tableWrapper-inner", t.appendChild(n), e.parentElement?.appendChild(t), t.appendChild(e);
260
+ }), e), wt = (e) => (e.querySelectorAll(".bn-inline-content:empty").forEach((e) => {
261
+ let t = document.createElement("span");
262
+ t.className = "ProseMirror-trailingBreak", t.setAttribute("style", "display: inline-block;"), e.appendChild(t);
263
+ }), e), U = (e, t) => {
264
+ let n = Re.fromSchema(e), r = [
265
+ yt,
266
+ bt,
267
+ xt,
268
+ St,
269
+ Ct,
270
+ wt
271
+ ];
272
+ return { serializeBlocks: (e, i) => {
273
+ let a = H(t, e, n, i);
274
+ for (let e of r) a = e(a);
275
+ return a.outerHTML;
276
+ } };
277
+ };
278
+ //#endregion
279
+ //#region src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts
280
+ function Tt(e) {
281
+ return e.transact((e) => {
282
+ let t = w(e.doc, e.selection.anchor);
283
+ if (e.selection instanceof R) return {
284
+ type: "cell",
285
+ anchorBlockId: t.node.attrs.id,
286
+ anchorCellOffset: e.selection.$anchorCell.pos - t.posBeforeNode,
287
+ headCellOffset: e.selection.$headCell.pos - t.posBeforeNode
288
+ };
289
+ if (e.selection instanceof N) return {
290
+ type: "node",
291
+ anchorBlockId: t.node.attrs.id
292
+ };
293
+ {
294
+ let n = w(e.doc, e.selection.head);
295
+ return {
296
+ type: "text",
297
+ anchorBlockId: t.node.attrs.id,
298
+ headBlockId: n.node.attrs.id,
299
+ anchorOffset: e.selection.anchor - t.posBeforeNode,
300
+ headOffset: e.selection.head - n.posBeforeNode
301
+ };
302
+ }
303
+ });
304
+ }
305
+ function Et(e, t) {
306
+ let n = i(t.anchorBlockId, e.doc)?.posBeforeNode;
307
+ if (n === void 0) throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);
308
+ let r;
309
+ if (t.type === "cell") r = R.create(e.doc, n + t.anchorCellOffset, n + t.headCellOffset);
310
+ else if (t.type === "node") r = N.create(e.doc, n + 1);
311
+ else {
312
+ let a = i(t.headBlockId, e.doc)?.posBeforeNode;
313
+ if (a === void 0) throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);
314
+ r = F.create(e.doc, n + t.anchorOffset, a + t.headOffset);
315
+ }
316
+ e.setSelection(r);
317
+ }
318
+ function W(e) {
319
+ return e.map((e) => e.type === "columnList" ? e.children.map((e) => W(e.children)).flat() : {
320
+ ...e,
321
+ children: W(e.children)
322
+ }).flat();
323
+ }
324
+ function Dt(e, t, n) {
325
+ e.transact((r) => {
326
+ let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a = Tt(e);
327
+ e.removeBlocks(i), e.insertBlocks(W(i), t, n), Et(r, a);
328
+ });
329
+ }
330
+ function Ot(e) {
331
+ return !e || e.type !== "columnList";
332
+ }
333
+ function kt(e, t, n) {
334
+ let r, i;
335
+ if (t ? t.children.length > 0 ? (r = t.children[t.children.length - 1], i = "after") : (r = t, i = "before") : n && (r = n, i = "before"), !r || !i) return;
336
+ let a = e.getParentBlock(r);
337
+ return Ot(a) ? {
338
+ referenceBlock: r,
339
+ placement: i
340
+ } : kt(e, i === "after" ? r : e.getPrevBlock(r), a);
341
+ }
342
+ function At(e, t, n) {
343
+ let r, i;
344
+ if (t ? t.children.length > 0 ? (r = t.children[0], i = "before") : (r = t, i = "after") : n && (r = n, i = "after"), !r || !i) return;
345
+ let a = e.getParentBlock(r);
346
+ return Ot(a) ? {
347
+ referenceBlock: r,
348
+ placement: i
349
+ } : At(e, i === "before" ? r : e.getNextBlock(r), a);
350
+ }
351
+ function jt(e) {
352
+ e.transact(() => {
353
+ let t = e.getSelection()?.blocks[0] || e.getTextCursorPosition().block, n = kt(e, e.getPrevBlock(t), e.getParentBlock(t));
354
+ n && Dt(e, n.referenceBlock, n.placement);
355
+ });
356
+ }
357
+ function Mt(e) {
358
+ e.transact(() => {
359
+ let t = e.getSelection(), n = t?.blocks[t?.blocks.length - 1] || e.getTextCursorPosition().block, r = At(e, e.getNextBlock(n), e.getParentBlock(n));
360
+ r && Dt(e, r.referenceBlock, r.placement);
361
+ });
362
+ }
363
+ //#endregion
364
+ //#region src/api/blockManipulation/commands/nestBlock/nestBlock.ts
365
+ function Nt(e, t, n) {
366
+ let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
367
+ if (!a) return !1;
368
+ let o = a.startIndex;
369
+ if (o === 0) return !1;
370
+ let s = a.parent.child(o - 1);
371
+ if (s.type !== t) return !1;
372
+ let c = s.lastChild && s.lastChild.type === n, l = E.from(c ? t.create() : null), u = new D(E.from(t.create(null, E.from(n.create(null, l)))), c ? 3 : 1, 0), d = a.start, f = a.end;
373
+ return e.step(new O(d - (c ? 3 : 1), f, d, f, u, 1, !0)).scrollIntoView(), !0;
374
+ }
375
+ function Pt(e) {
376
+ return e.transact((t) => Nt(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
377
+ }
378
+ function Ft(e, t, n, r) {
379
+ let i = r.end, a = r.$to.end(r.depth);
380
+ if (i < a) {
381
+ let o = r.parent.child(r.endIndex - 1), s = o.lastChild && o.lastChild.type === n;
382
+ e.step(new O(i - (s ? 2 : 1), a, i, a, new D(E.from(t.create(null, n.create())), s ? 2 : 1, 0), s ? 0 : 1, !0)), r = new Be(e.doc.resolve(r.$from.pos), e.doc.resolve(a), r.depth);
383
+ }
384
+ let o = Ue(r);
385
+ if (o == null) return !1;
386
+ e.lift(r, o);
387
+ let s = e.doc.resolve(e.mapping.map(i, -1) - 1);
388
+ return He(e.doc, s.pos) && s.nodeBefore.type === s.nodeAfter.type && e.join(s.pos), e.scrollIntoView(), !0;
389
+ }
390
+ function G(e, t, n) {
391
+ let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
392
+ return a && r.node(a.depth - 1).type === t ? Ft(e, t, n, a) : !1;
393
+ }
394
+ function It(e) {
395
+ return e.transact((t) => G(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
396
+ }
397
+ function Lt(e) {
398
+ return e.transact((e) => {
399
+ let { bnBlock: t } = _(e);
400
+ return e.doc.resolve(t.beforePos).nodeBefore !== null;
401
+ });
402
+ }
403
+ function Rt(e) {
404
+ return e.transact((e) => {
405
+ let { bnBlock: t } = _(e);
406
+ return e.doc.resolve(t.beforePos).depth > 1;
407
+ });
408
+ }
409
+ //#endregion
410
+ //#region src/api/blockManipulation/getBlock/getBlock.ts
411
+ function zt(e, t) {
412
+ let n = typeof t == "string" ? t : t.id, r = g(e), a = i(n, e);
413
+ if (a) return y(a.node, r);
414
+ }
415
+ function Bt(e, t) {
416
+ let n = i(typeof t == "string" ? t : t.id, e), r = g(e);
417
+ if (!n) return;
418
+ let a = e.resolve(n.posBeforeNode).nodeBefore;
419
+ if (a) return y(a, r);
420
+ }
421
+ function Vt(e, t) {
422
+ let n = i(typeof t == "string" ? t : t.id, e), r = g(e);
423
+ if (!n) return;
424
+ let a = e.resolve(n.posBeforeNode + n.node.nodeSize).nodeAfter;
425
+ if (a) return y(a, r);
426
+ }
427
+ function Ht(e, t) {
428
+ let n = typeof t == "string" ? t : t.id, r = g(e), a = i(n, e);
429
+ if (!a) return;
430
+ let o = e.resolve(a.posBeforeNode), s = o.node(), c = o.node(-1), l = c.type.name === "doc" ? void 0 : s.type.name === "blockGroup" ? c : s;
431
+ if (l) return y(l, r);
432
+ }
433
+ //#endregion
434
+ //#region src/editor/managers/BlockManager.ts
435
+ var Ut = class {
436
+ constructor(e) {
437
+ this.editor = e;
438
+ }
439
+ get document() {
440
+ return this.editor.transact((e) => ae(e.doc, this.editor.pmSchema));
441
+ }
442
+ getBlock(e) {
443
+ return this.editor.transact((t) => zt(t.doc, e));
444
+ }
445
+ getPrevBlock(e) {
446
+ return this.editor.transact((t) => Bt(t.doc, e));
447
+ }
448
+ getNextBlock(e) {
449
+ return this.editor.transact((t) => Vt(t.doc, e));
450
+ }
451
+ getParentBlock(e) {
452
+ return this.editor.transact((t) => Ht(t.doc, e));
453
+ }
454
+ forEachBlock(e, t = !1) {
455
+ let n = this.document.slice();
456
+ t && n.reverse();
457
+ function r(n) {
458
+ for (let i of n) if (e(i) === !1 || !r(t ? i.children.slice().reverse() : i.children)) return !1;
459
+ return !0;
460
+ }
461
+ r(n);
462
+ }
463
+ insertBlocks(e, t, n = "before") {
464
+ return this.editor.transact((r) => mt(r, e, t, n));
465
+ }
466
+ updateBlock(e, t) {
467
+ return this.editor.transact((r) => n(r, e, t));
468
+ }
469
+ removeBlocks(e) {
470
+ return this.editor.transact((t) => V(t, e, []).removedBlocks);
471
+ }
472
+ replaceBlocks(e, t) {
473
+ return this.editor.transact((n) => V(n, e, t));
474
+ }
475
+ canNestBlock() {
476
+ return Lt(this.editor);
477
+ }
478
+ nestBlock() {
479
+ Pt(this.editor);
480
+ }
481
+ canUnnestBlock() {
482
+ return Rt(this.editor);
483
+ }
484
+ unnestBlock() {
485
+ It(this.editor);
486
+ }
487
+ moveBlocksUp() {
488
+ return jt(this.editor);
489
+ }
490
+ moveBlocksDown() {
491
+ return Mt(this.editor);
492
+ }
493
+ }, Wt = class extends Ie {
494
+ constructor(e) {
495
+ super(), this.editor = e, e.on("create", () => {
496
+ e._tiptapEditor.on("update", ({ transaction: t, appendedTransactions: n }) => {
497
+ this.emit("onChange", {
498
+ editor: e,
499
+ transaction: t,
500
+ appendedTransactions: n
501
+ });
502
+ }), e._tiptapEditor.on("selectionUpdate", ({ transaction: t }) => {
503
+ this.emit("onSelectionChange", {
504
+ editor: e,
505
+ transaction: t
506
+ });
507
+ }), e._tiptapEditor.on("mount", () => {
508
+ this.emit("onMount", { editor: e });
509
+ }), e._tiptapEditor.on("unmount", () => {
510
+ this.emit("onUnmount", { editor: e });
511
+ });
512
+ });
513
+ }
514
+ onChange(e, t = !0) {
515
+ let n = ({ transaction: n, appendedTransactions: r }) => {
516
+ !t && Gt(n) || e(this.editor, { getChanges() {
517
+ return pe(n, r);
518
+ } });
519
+ };
520
+ return this.on("onChange", n), () => {
521
+ this.off("onChange", n);
522
+ };
523
+ }
524
+ onSelectionChange(e, t = !1) {
525
+ let n = (n) => {
526
+ !t && Gt(n.transaction) || e(this.editor);
527
+ };
528
+ return this.on("onSelectionChange", n), () => {
529
+ this.off("onSelectionChange", n);
530
+ };
531
+ }
532
+ onMount(e) {
533
+ return this.on("onMount", e), () => {
534
+ this.off("onMount", e);
535
+ };
536
+ }
537
+ onUnmount(e) {
538
+ return this.on("onUnmount", e), () => {
539
+ this.off("onUnmount", e);
540
+ };
541
+ }
542
+ };
543
+ function Gt(e) {
544
+ return !!e.getMeta("y-sync$");
545
+ }
546
+ //#endregion
547
+ //#region src/api/parsers/html/util/nestedLists.ts
548
+ function Kt(e) {
549
+ return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
550
+ }
551
+ function qt(e) {
552
+ return e.nodeType === 3 && !/\S/.test(e.nodeValue || "");
553
+ }
554
+ function Jt(e) {
555
+ e.querySelectorAll("li > ul, li > ol").forEach((e) => {
556
+ let t = Kt(e), n = e.parentElement, r = Array.from(n.childNodes).slice(t + 1);
557
+ e.remove(), r.forEach((e) => {
558
+ e.remove();
559
+ }), n.insertAdjacentElement("afterend", e), r.reverse().forEach((t) => {
560
+ if (qt(t)) return;
561
+ let n = document.createElement("li");
562
+ n.append(t), e.insertAdjacentElement("afterend", n);
563
+ }), n.childNodes.length === 0 && n.remove();
564
+ });
565
+ }
566
+ function Yt(e) {
567
+ e.querySelectorAll("li + ul, li + ol").forEach((e) => {
568
+ let t = e.previousElementSibling, n = document.createElement("div");
569
+ t.insertAdjacentElement("afterend", n), n.append(t);
570
+ let r = document.createElement("div");
571
+ for (r.setAttribute("data-node-type", "blockGroup"), n.append(r); n.nextElementSibling?.nodeName === "UL" || n.nextElementSibling?.nodeName === "OL";) r.append(n.nextElementSibling);
572
+ });
573
+ }
574
+ var Xt = null;
575
+ function Zt() {
576
+ return Xt ||= document.implementation.createHTMLDocument("title");
577
+ }
578
+ function Qt(e) {
579
+ if (typeof e == "string") {
580
+ let t = Zt().createElement("div");
581
+ t.innerHTML = e, e = t;
582
+ }
583
+ return Jt(e), Yt(e), e;
584
+ }
585
+ //#endregion
586
+ //#region src/api/parsers/html/util/normalizeWhitespace.ts
587
+ function $t(e) {
588
+ let t = e.ownerDocument.createTreeWalker(e, 128), n;
589
+ for (; n = t.nextNode();) if (/^\s*notionvc:/.test(n.nodeValue || "")) return !0;
590
+ return !1;
591
+ }
592
+ function en(e) {
593
+ let t = new Set(["PRE", "CODE"]), n = e.ownerDocument.createTreeWalker(e, 4, { acceptNode(n) {
594
+ let r = n.parentElement;
595
+ for (; r && r !== e;) {
596
+ if (t.has(r.tagName)) return 2;
597
+ r = r.parentElement;
598
+ }
599
+ return 1;
600
+ } }), r = [], i;
601
+ for (; i = n.nextNode();) r.push(i);
602
+ for (let e of r) e.nodeValue && /[\r\n]/.test(e.nodeValue) && (e.nodeValue = e.nodeValue.replace(/[ \t\r\n\f]+/g, " "));
603
+ }
604
+ function tn(e) {
605
+ $t(e) || en(e);
606
+ }
607
+ //#endregion
608
+ //#region src/api/parsers/html/parseHTML.ts
609
+ function K(e, t) {
610
+ let n = Qt(e);
611
+ tn(n);
612
+ let r = Le.fromSchema(t).parse(n, { topNode: t.nodes.blockGroup.create() }), i = [];
613
+ for (let e = 0; e < r.childCount; e++) i.push(y(r.child(e), t));
614
+ return i;
615
+ }
616
+ //#endregion
617
+ //#region src/api/parsers/markdown/parseMarkdown.ts
618
+ function nn(e, t) {
619
+ let n = t.value ? t.value : "", r = {};
620
+ t.lang && (r["data-language"] = t.lang);
621
+ let i = {
622
+ type: "element",
623
+ tagName: "code",
624
+ properties: r,
625
+ children: [{
626
+ type: "text",
627
+ value: n
628
+ }]
629
+ };
630
+ return t.meta && (i.data = { meta: t.meta }), e.patch(t, i), i = e.applyData(t, i), i = {
631
+ type: "element",
632
+ tagName: "pre",
633
+ properties: {},
634
+ children: [i]
635
+ }, e.patch(t, i), i;
636
+ }
637
+ function rn(e, t) {
638
+ let n = String(t?.url || ""), r = t?.title ? String(t.title) : void 0, i = {
639
+ type: "element",
640
+ tagName: "video",
641
+ properties: {
642
+ src: n,
643
+ "data-name": r,
644
+ "data-url": n,
645
+ controls: !0
646
+ },
647
+ children: []
648
+ };
649
+ return e.patch?.(t, i), i = e.applyData ? e.applyData(t, i) : i, i;
650
+ }
651
+ function q(t) {
652
+ return tt().use(nt).use(et).use(rt, { handlers: {
653
+ ...it,
654
+ image: (t, n) => e(String(n?.url || "")) ? rn(t, n) : it.image(t, n),
655
+ code: nn,
656
+ blockquote: (e, t) => {
657
+ let n = {
658
+ type: "element",
659
+ tagName: "blockquote",
660
+ properties: {},
661
+ children: e.wrap(e.all(t), !1)
662
+ };
663
+ return e.patch(t, n), e.applyData(t, n);
664
+ }
665
+ } }).use(at).processSync(t).value;
666
+ }
667
+ function an(e, t) {
668
+ return K(q(e), t);
669
+ }
670
+ //#endregion
671
+ //#region src/editor/managers/ExportManager.ts
672
+ var on = class {
673
+ constructor(e) {
674
+ this.editor = e;
675
+ }
676
+ blocksToHTMLLossy(e = this.editor.document) {
677
+ return xe(this.editor.pmSchema, this.editor).exportBlocks(e, {});
678
+ }
679
+ blocksToFullHTML(e = this.editor.document) {
680
+ return U(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
681
+ }
682
+ tryParseHTMLToBlocks(e) {
683
+ return K(e, this.editor.pmSchema);
684
+ }
685
+ blocksToMarkdownLossy(e = this.editor.document) {
686
+ return Oe(e, this.editor.pmSchema, this.editor, {});
687
+ }
688
+ tryParseMarkdownToBlocks(e) {
689
+ return an(e, this.editor.pmSchema);
690
+ }
691
+ pasteHTML(e, t = !1) {
692
+ let n = e;
693
+ if (!t) {
694
+ let t = this.tryParseHTMLToBlocks(e);
695
+ n = this.blocksToFullHTML(t);
696
+ }
697
+ n && this.editor.prosemirrorView?.pasteHTML(n);
698
+ }
699
+ pasteText(e) {
700
+ return this.editor.prosemirrorView?.pasteText(e);
701
+ }
702
+ pasteMarkdown(e) {
703
+ let t = q(e);
704
+ return this.pasteHTML(t);
705
+ }
706
+ }, J = [
707
+ "vscode-editor-data",
708
+ "blocknote/html",
709
+ "text/markdown",
710
+ "text/html",
711
+ "text/plain",
712
+ "Files"
713
+ ];
714
+ //#endregion
715
+ //#region src/api/clipboard/fromClipboard/handleFileInsertion.ts
716
+ function sn(e, t) {
717
+ if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
718
+ return e === t;
719
+ }
720
+ function cn(e, t) {
721
+ let n = e.split("/"), r = t.split("/");
722
+ if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
723
+ if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
724
+ return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
725
+ }
726
+ function ln(e, t, n, r = "after") {
727
+ let i;
728
+ return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
729
+ }
730
+ async function un(e, t) {
731
+ if (!t.uploadFile) {
732
+ console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
733
+ return;
734
+ }
735
+ let n = "dataTransfer" in e ? e.dataTransfer : e.clipboardData;
736
+ if (n === null) return;
737
+ let r = null;
738
+ for (let e of J) if (n.types.includes(e)) {
739
+ r = e;
740
+ break;
741
+ }
742
+ if (r !== "Files") return;
743
+ let i = n.items;
744
+ if (i) {
745
+ e.preventDefault();
746
+ for (let n = 0; n < i.length; n++) {
747
+ let r = "file";
748
+ for (let e of Object.values(t.schema.blockSpecs)) for (let t of e.implementation.meta?.fileBlockAccept || []) {
749
+ let a = t.startsWith("."), o = i[n].getAsFile();
750
+ if (o && (!a && o.type && cn(i[n].type, t) || a && sn("." + o.name.split(".").pop(), t))) {
751
+ r = e.config.type;
752
+ break;
753
+ }
754
+ }
755
+ let a = i[n].getAsFile();
756
+ if (a) {
757
+ let n = {
758
+ type: r,
759
+ props: { name: a.name }
760
+ }, i;
761
+ if (e.type === "paste") {
762
+ let e = t.getTextCursorPosition().block;
763
+ i = ln(t, e, n);
764
+ } else if (e.type === "drop") {
765
+ let r = {
766
+ left: e.clientX,
767
+ top: e.clientY
768
+ }, a = t.prosemirrorView.posAtCoords(r);
769
+ if (!a) return;
770
+ i = t.transact((e) => {
771
+ let i = w(e.doc, a.pos), o = (t.domElement?.querySelector(`[data-id="${i.node.attrs.id}"]`))?.getBoundingClientRect();
772
+ return ln(t, t.getBlock(i.node.attrs.id), n, o && (o.top + o.bottom) / 2 > r.top ? "before" : "after");
773
+ });
774
+ } else return;
775
+ let o = await t.uploadFile(a, i), s = typeof o == "string" ? { props: { url: o } } : { ...o };
776
+ t.updateBlock(i, s);
777
+ }
778
+ }
779
+ }
780
+ }
781
+ //#endregion
782
+ //#region src/api/clipboard/fromClipboard/fileDropExtension.ts
783
+ var dn = (e) => k.create({
784
+ name: "dropFile",
785
+ addProseMirrorPlugins() {
786
+ return [new P({ props: { handleDOMEvents: { drop(t, n) {
787
+ if (!e.isEditable) return;
788
+ let r = null;
789
+ for (let e of J) if (n.dataTransfer.types.includes(e)) {
790
+ r = e;
791
+ break;
792
+ }
793
+ return r === null ? !0 : r === "Files" ? (un(n, e), !0) : !1;
794
+ } } } })];
795
+ }
796
+ }), fn = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, pn = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, mn = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, hn = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, gn = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, _n = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, vn = /\n{2} {0,3}-{2,48}\n{2}/, yn = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, bn = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, xn = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, Sn = /^\s*\|(.+\|)+\s*$/m, Cn = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, wn = /^\s*\|(.+\|)+\s*$/m, Tn = (e) => fn.test(e) || pn.test(e) || mn.test(e) || hn.test(e) || gn.test(e) || _n.test(e) || vn.test(e) || yn.test(e) || bn.test(e) || xn.test(e) || Sn.test(e) || Cn.test(e) || wn.test(e);
797
+ //#endregion
798
+ //#region src/api/clipboard/fromClipboard/handleVSCodePaste.ts
799
+ async function En(e, t) {
800
+ let { schema: n } = t.state;
801
+ if (!e.clipboardData) return !1;
802
+ let r = e.clipboardData.getData("text/plain");
803
+ if (!r) return !1;
804
+ if (!n.nodes.codeBlock) return t.pasteText(r), !0;
805
+ let i = e.clipboardData.getData("vscode-editor-data"), a = (i ? JSON.parse(i) : void 0)?.mode;
806
+ return a ? (t.pasteHTML(`<pre><code class="language-${a}">${r.replace(/\r\n?/g, "\n")}</code></pre>`), !0) : !1;
807
+ }
808
+ //#endregion
809
+ //#region src/api/clipboard/fromClipboard/pasteExtension.ts
810
+ function Dn({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
811
+ if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
812
+ let n = e.clipboardData?.getData("text/plain");
813
+ if (n) return t.pasteText(n), !0;
814
+ }
815
+ let i;
816
+ for (let t of J) if (e.clipboardData.types.includes(t)) {
817
+ i = t;
818
+ break;
819
+ }
820
+ if (!i) return !0;
821
+ if (i === "vscode-editor-data") return En(e, t.prosemirrorView), !0;
822
+ if (i === "Files") return un(e, t), !0;
823
+ let a = e.clipboardData.getData(i);
824
+ if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
825
+ if (i === "text/markdown") return t.pasteMarkdown(a), !0;
826
+ if (n) {
827
+ let n = e.clipboardData.getData("text/plain");
828
+ if (Tn(n)) return t.pasteMarkdown(n), !0;
829
+ }
830
+ return i === "text/html" ? (t.pasteHTML(a), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
831
+ }
832
+ var On = (e, t) => k.create({
833
+ name: "pasteFromClipboard",
834
+ addProseMirrorPlugins() {
835
+ return [new P({ props: { handleDOMEvents: { paste(n, r) {
836
+ if (r.preventDefault(), e.isEditable) return t({
837
+ event: r,
838
+ editor: e,
839
+ defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => Dn({
840
+ event: r,
841
+ editor: e,
842
+ prioritizeMarkdownOverHTML: t,
843
+ plainTextAsMarkdown: n
844
+ })
845
+ });
846
+ } } } })];
847
+ }
848
+ });
849
+ //#endregion
850
+ //#region src/api/clipboard/toClipboard/copyExtension.ts
851
+ function kn(e, t, n) {
852
+ let r = !1, i = e.state.selection instanceof R;
853
+ if (!i) {
854
+ let n = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, i = [];
855
+ for (let e = 0; e < n.childCount; e++) i.push(n.child(e));
856
+ r = i.find((e) => e.type.isInGroup("bnBlock") || e.type.name === "blockGroup" || e.type.spec.group === "blockContent") === void 0, r && (t = n);
857
+ }
858
+ let a, o = xe(e.state.schema, n);
859
+ if (i) {
860
+ t.firstChild?.type.name === "table" && (t = t.firstChild.content);
861
+ let e = re(t, n.schema.inlineContentSchema, n.schema.styleSchema);
862
+ a = `<table>${o.exportInlineContent(e, {})}</table>`;
863
+ } else if (r) {
864
+ let e = se(t, n.schema.inlineContentSchema, n.schema.styleSchema);
865
+ a = o.exportInlineContent(e, {});
866
+ } else {
867
+ let e = Se(t);
868
+ a = o.exportBlocks(e, {});
869
+ }
870
+ return a;
871
+ }
872
+ function Y(e, t) {
873
+ "node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new N(t.doc.resolve(e.state.selection.from - 1))));
874
+ let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i = kn(e, r, t);
875
+ return {
876
+ clipboardHTML: n,
877
+ externalHTML: i,
878
+ markdown: _e(i)
879
+ };
880
+ }
881
+ var An = () => {
882
+ let e = window.getSelection();
883
+ if (!e || e.isCollapsed) return !0;
884
+ let t = e.focusNode;
885
+ for (; t;) {
886
+ if (t instanceof HTMLElement && t.getAttribute("contenteditable") === "false") return !0;
887
+ t = t.parentElement;
888
+ }
889
+ return !1;
890
+ }, jn = (e, t, n) => {
891
+ n.preventDefault(), n.clipboardData.clearData();
892
+ let { clipboardHTML: r, externalHTML: i, markdown: a } = Y(t, e);
893
+ n.clipboardData.setData("blocknote/html", r), n.clipboardData.setData("text/html", i), n.clipboardData.setData("text/plain", a);
894
+ }, Mn = (e) => k.create({
895
+ name: "copyToClipboard",
896
+ addProseMirrorPlugins() {
897
+ return [new P({ props: { handleDOMEvents: {
898
+ copy(t, n) {
899
+ return An() || jn(e, t, n), !0;
900
+ },
901
+ cut(t, n) {
902
+ return An() ? !0 : (jn(e, t, n), t.editable && t.dispatch(t.state.tr.deleteSelection()), !0);
903
+ },
904
+ dragstart(t, n) {
905
+ if (!("node" in t.state.selection) || t.state.selection.node.type.spec.group !== "blockContent") return;
906
+ e.transact((e) => e.setSelection(new N(e.doc.resolve(t.state.selection.from - 1)))), n.preventDefault(), n.dataTransfer.clearData();
907
+ let { clipboardHTML: r, externalHTML: i, markdown: a } = Y(t, e);
908
+ return n.dataTransfer.setData("blocknote/html", r), n.dataTransfer.setData("text/html", i), n.dataTransfer.setData("text/plain", a), !0;
909
+ }
910
+ } } })];
911
+ }
912
+ }), Nn = k.create({
913
+ name: "blockBackgroundColor",
914
+ addGlobalAttributes() {
915
+ return [{
916
+ types: ["tableCell", "tableHeader"],
917
+ attributes: { backgroundColor: ne() }
918
+ }];
919
+ }
920
+ }), Pn = j.create({
921
+ name: "hardBreak",
922
+ inline: !0,
923
+ group: "inline",
924
+ selectable: !1,
925
+ linebreakReplacement: !0,
926
+ priority: 10,
927
+ parseHTML() {
928
+ return [{ tag: "br" }];
929
+ },
930
+ renderHTML({ HTMLAttributes: e }) {
931
+ return ["br", Ye(this.options.HTMLAttributes, e)];
932
+ },
933
+ renderText() {
934
+ return "\n";
935
+ }
936
+ }), X = (e, t) => {
937
+ let n = e.resolve(t), r = n.depth - 1;
938
+ if (r < 1) return;
939
+ let i = n.before(r), a = e.resolve(i).nodeAfter;
940
+ if (a) return a.type.spec.group?.includes("bnBlock") ? x(e.resolve(i)) : X(e, i);
941
+ }, Z = (e, t) => {
942
+ let n = e.resolve(t), r = n.index();
943
+ if (r === 0) return;
944
+ let i = n.posAtIndex(r - 1);
945
+ return x(e.resolve(i));
946
+ }, Q = (e, t) => {
947
+ let n = e.resolve(t), r = n.index();
948
+ if (r === n.node().childCount - 1) return;
949
+ let i = n.posAtIndex(r + 1);
950
+ return x(e.resolve(i));
951
+ }, $ = (e, t) => {
952
+ for (; t.childContainer;) {
953
+ let n = t.childContainer.node, r = e.resolve(t.childContainer.beforePos + 1).posAtIndex(n.childCount - 1);
954
+ t = x(e.resolve(r));
955
+ }
956
+ return t;
957
+ }, Fn = (e, t) => e.isBlockContainer && e.blockContent.node.type.spec.content === "inline*" && e.blockContent.node.childCount > 0 && t.isBlockContainer && t.blockContent.node.type.spec.content === "inline*", In = (e, t, n, r) => {
958
+ if (!r.isBlockContainer) throw Error(`Attempted to merge block at position ${r.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but next block is not a block container`);
959
+ if (r.childContainer) {
960
+ let n = e.doc.resolve(r.childContainer.beforePos + 1), i = e.doc.resolve(r.childContainer.afterPos - 1), a = n.blockRange(i);
961
+ if (t) {
962
+ let t = e.doc.resolve(r.bnBlock.beforePos);
963
+ e.tr.lift(a, t.depth);
964
+ }
965
+ }
966
+ if (t) {
967
+ if (!n.isBlockContainer) throw Error(`Attempted to merge block at position ${r.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but previous block is not a block container`);
968
+ t(e.tr.delete(n.blockContent.afterPos - 1, r.blockContent.beforePos + 1));
969
+ }
970
+ return !0;
971
+ }, Ln = (e) => ({ state: t, dispatch: n }) => {
972
+ let r = x(t.doc.resolve(e)), i = Z(t.doc, r.bnBlock.beforePos);
973
+ if (!i) return !1;
974
+ let a = $(t.doc, i);
975
+ return Fn(a, r) ? In(t, n, a, r) : !1;
976
+ }, Rn = k.create({
977
+ priority: 50,
978
+ addKeyboardShortcuts() {
979
+ let e = () => this.editor.commands.first(({ chain: e, commands: t }) => [
980
+ () => t.deleteSelection(),
981
+ () => t.undoInputRule(),
982
+ () => t.command(({ state: e }) => {
983
+ let n = v(e);
984
+ if (!n.isBlockContainer) return !1;
985
+ let r = e.selection.from === n.blockContent.beforePos + 1, i = n.blockContent.node.type.name === "paragraph";
986
+ return r && !i ? t.command(le(n.bnBlock.beforePos, {
987
+ type: "paragraph",
988
+ props: {}
989
+ })) : !1;
990
+ }),
991
+ () => t.command(({ state: e, tr: t }) => {
992
+ let n = v(e);
993
+ if (!n.isBlockContainer) return !1;
994
+ let { blockContent: r } = n;
995
+ return e.selection.from === r.beforePos + 1 ? G(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
996
+ }),
997
+ () => t.command(({ state: t }) => {
998
+ let n = v(t);
999
+ if (!n.isBlockContainer) return !1;
1000
+ let { bnBlock: r, blockContent: i } = n, a = Z(t.doc, n.bnBlock.beforePos);
1001
+ if (!a || !a.isBlockContainer || a.blockContent.node.type.spec.content !== "inline*") return !1;
1002
+ let o = t.selection.from === i.beforePos + 1, s = t.selection.empty, c = r.beforePos;
1003
+ return o && s ? e().command(Ln(c)).scrollIntoView().run() : !1;
1004
+ }),
1005
+ () => t.command(({ state: e, tr: t, dispatch: n }) => {
1006
+ let r = v(e);
1007
+ if (!r.isBlockContainer || e.selection.from !== r.blockContent.beforePos + 1) return !1;
1008
+ let i = Z(e.doc, r.bnBlock.beforePos);
1009
+ if (!i || i.isBlockContainer) return !1;
1010
+ if (n) {
1011
+ let e = i.bnBlock.afterPos - 1, n = t.doc.resolve(e - 1);
1012
+ return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(F.near(t.doc.resolve(n.pos + 1))), !0;
1013
+ }
1014
+ return !1;
1015
+ }),
1016
+ () => t.command(({ state: e, tr: t, dispatch: n }) => {
1017
+ let r = v(e);
1018
+ if (!r.isBlockContainer || t.selection.from !== r.blockContent.beforePos + 1) return !1;
1019
+ let i = t.doc.resolve(r.bnBlock.beforePos);
1020
+ if (i.nodeBefore || i.node().type.name !== "column") return !1;
1021
+ let a = t.doc.resolve(r.bnBlock.beforePos), o = t.doc.resolve(a.before()), s = o.before();
1022
+ return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), B(t, s), o.pos === s + 1 ? (t.insert(s, r.bnBlock.node), t.setSelection(F.near(t.doc.resolve(s)))) : (t.insert(o.pos - 1, r.bnBlock.node), t.setSelection(F.near(t.doc.resolve(o.pos))))), !0;
1023
+ }),
1024
+ () => t.command(({ state: t }) => {
1025
+ let n = v(t);
1026
+ if (!n.isBlockContainer) return !1;
1027
+ if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
1028
+ let r = Z(t.doc, n.bnBlock.beforePos);
1029
+ if (!r) return !1;
1030
+ let i = $(t.doc, r);
1031
+ if (!i.isBlockContainer || !i || !i.isBlockContainer) return !1;
1032
+ let a = e();
1033
+ if (n.childContainer && a.insertContentAt(n.bnBlock.afterPos, n.childContainer?.node.content), i.blockContent.node.type.spec.content === "tableRow+") {
1034
+ let e = n.bnBlock.beforePos - 1 - 1 - 1 - 1 - 1;
1035
+ a = a.setTextSelection(e);
1036
+ } else if (i.blockContent.node.type.spec.content === "") a = a.setNodeSelection(i.blockContent.beforePos);
1037
+ else {
1038
+ let e = i.blockContent.afterPos - 1;
1039
+ a = a.setTextSelection(e);
1040
+ }
1041
+ return a.deleteRange({
1042
+ from: n.bnBlock.beforePos,
1043
+ to: n.bnBlock.afterPos
1044
+ }).scrollIntoView().run();
1045
+ }
1046
+ return !1;
1047
+ }),
1048
+ () => t.command(({ state: t }) => {
1049
+ let n = v(t);
1050
+ if (!n.isBlockContainer) return !1;
1051
+ let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a = Z(t.doc, n.bnBlock.beforePos);
1052
+ if (a && r && i) {
1053
+ let r = $(t.doc, a);
1054
+ if (!r.isBlockContainer) return !1;
1055
+ if (r.blockContent.node.type.spec.content === "" || r.blockContent.node.type.spec.content === "inline*" && r.blockContent.node.childCount === 0) return e().cut({
1056
+ from: n.bnBlock.beforePos,
1057
+ to: n.bnBlock.afterPos
1058
+ }, r.bnBlock.afterPos).deleteRange({
1059
+ from: r.bnBlock.beforePos,
1060
+ to: r.bnBlock.afterPos
1061
+ }).run();
1062
+ }
1063
+ return !1;
1064
+ })
1065
+ ]), t = () => this.editor.commands.first(({ chain: e, commands: t }) => [
1066
+ () => t.deleteSelection(),
1067
+ () => t.command(({ state: t }) => {
1068
+ let n = v(t);
1069
+ if (!n.isBlockContainer || !n.childContainer) return !1;
1070
+ let { blockContent: r, childContainer: i } = n, a = t.selection.from === r.afterPos - 1, o = t.selection.empty, s = x(t.doc.resolve(i.beforePos + 1));
1071
+ if (!s.isBlockContainer) return !1;
1072
+ if (a && o) {
1073
+ let n = s.blockContent.node, a = n.type.spec.content === "inline*", o = r.node.type.spec.content === "inline*";
1074
+ return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content || E.empty).deleteRange(i.node.childCount === 1 ? {
1075
+ from: i.beforePos,
1076
+ to: i.afterPos
1077
+ } : {
1078
+ from: s.bnBlock.beforePos,
1079
+ to: s.bnBlock.afterPos
1080
+ }).insertContentAt(t.selection.from, a && o ? n.content : null).setTextSelection(t.selection.from).scrollIntoView().run();
1081
+ }
1082
+ return !1;
1083
+ }),
1084
+ () => t.command(({ state: t }) => {
1085
+ let n = v(t);
1086
+ if (!n.isBlockContainer) return !1;
1087
+ let { bnBlock: r, blockContent: i } = n, a = Q(t.doc, n.bnBlock.beforePos);
1088
+ if (!a || !a.isBlockContainer) return !1;
1089
+ let o = t.selection.from === i.afterPos - 1, s = t.selection.empty, c = r.afterPos;
1090
+ return o && s ? e().command(Ln(c)).scrollIntoView().run() : !1;
1091
+ }),
1092
+ () => t.command(({ state: e, tr: t, dispatch: n }) => {
1093
+ let r = v(e);
1094
+ if (!r.isBlockContainer || e.selection.from !== r.blockContent.afterPos - 1) return !1;
1095
+ let i = Q(e.doc, r.bnBlock.beforePos);
1096
+ if (!i || i.isBlockContainer) return !1;
1097
+ if (n) {
1098
+ let e = i.bnBlock.beforePos + 1, n = t.doc.resolve(e + 1);
1099
+ return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize), B(t, i.bnBlock.beforePos), t.insert(r.bnBlock.afterPos, n.nodeAfter), t.setSelection(F.near(t.doc.resolve(n.pos))), !0;
1100
+ }
1101
+ return !1;
1102
+ }),
1103
+ () => t.command(({ state: e, tr: t, dispatch: n }) => {
1104
+ let r = v(e);
1105
+ if (!r.isBlockContainer || t.selection.from !== r.blockContent.afterPos - 1) return !1;
1106
+ let i = t.doc.resolve(r.bnBlock.afterPos);
1107
+ if (i.nodeAfter || i.node().type.name !== "column") return !1;
1108
+ let a = t.doc.resolve(r.bnBlock.afterPos), o = t.doc.resolve(a.after()), s = o.after();
1109
+ if (n) {
1110
+ let e = o.pos === s - 1 ? s : o.pos + 1, n = x(t.doc.resolve(e));
1111
+ t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos), B(t, s - o.node().nodeSize), t.insert(a.pos, n.bnBlock.node), t.setSelection(F.near(t.doc.resolve(e)));
1112
+ }
1113
+ return !0;
1114
+ }),
1115
+ () => t.command(({ state: t }) => {
1116
+ let n = v(t);
1117
+ if (!n.isBlockContainer) return !1;
1118
+ let { blockContent: r } = n, i = t.selection.from === r.afterPos - 1, a = t.selection.empty;
1119
+ if (i && a) {
1120
+ let i = (e, t) => {
1121
+ let n = Q(e, t);
1122
+ if (n) return n;
1123
+ let r = X(e, t);
1124
+ if (r) return i(e, r.bnBlock.beforePos);
1125
+ }, a = i(t.doc, n.bnBlock.beforePos);
1126
+ if (!a || !a.isBlockContainer) return !1;
1127
+ let o = a.blockContent.node, s = o.type.spec.content === "inline*", c = r.node.type.spec.content === "inline*";
1128
+ return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content || E.empty).deleteRange({
1129
+ from: a.bnBlock.beforePos,
1130
+ to: a.bnBlock.afterPos
1131
+ }).insertContentAt(t.selection.from, s && c ? o.content : null).setTextSelection(t.selection.from).scrollIntoView().run();
1132
+ }
1133
+ return !1;
1134
+ }),
1135
+ () => t.command(({ state: t }) => {
1136
+ let n = v(t);
1137
+ if (!n.isBlockContainer) return !1;
1138
+ if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
1139
+ let r = Q(t.doc, n.bnBlock.beforePos);
1140
+ if (!r || !r.isBlockContainer) return !1;
1141
+ let i = e();
1142
+ if (r.blockContent.node.type.spec.content === "tableRow+") {
1143
+ let e = n.bnBlock.afterPos + 1 + 1 + 1 + 1 + 1;
1144
+ i = i.setTextSelection(e);
1145
+ } else i = r.blockContent.node.type.spec.content === "" ? i.setNodeSelection(r.blockContent.beforePos) : i.setTextSelection(r.blockContent.beforePos + 1);
1146
+ return i.deleteRange({
1147
+ from: n.bnBlock.beforePos,
1148
+ to: n.bnBlock.afterPos
1149
+ }).scrollIntoView().run();
1150
+ }
1151
+ return !1;
1152
+ }),
1153
+ () => t.command(({ state: t }) => {
1154
+ let n = v(t);
1155
+ if (!n.isBlockContainer) return !1;
1156
+ let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a = Q(t.doc, n.bnBlock.beforePos);
1157
+ if (!a || !a.isBlockContainer) return !1;
1158
+ if (a && r && i && (a.blockContent.node.type.spec.content === "" || a.blockContent.node.type.spec.content === "inline*" && a.blockContent.node.childCount === 0)) {
1159
+ let t = a.bnBlock.node.lastChild.content;
1160
+ return e().deleteRange({
1161
+ from: a.bnBlock.beforePos,
1162
+ to: a.bnBlock.afterPos
1163
+ }).insertContentAt(n.bnBlock.afterPos, a.bnBlock.node.childCount === 2 ? t : null).run();
1164
+ }
1165
+ return !1;
1166
+ })
1167
+ ]), n = (e = !1) => this.editor.commands.first(({ commands: t, tr: n }) => [
1168
+ () => t.command(({ state: e, tr: t }) => {
1169
+ let n = v(e);
1170
+ if (!n.isBlockContainer) return !1;
1171
+ let { bnBlock: r, blockContent: i } = n, { depth: a } = e.doc.resolve(r.beforePos), o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = i.node.childCount === 0;
1172
+ return o && s && c && a > 1 ? G(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
1173
+ }),
1174
+ () => t.command(({ state: t }) => {
1175
+ let r = v(t), i = this.options.editor.schema.blockSchema[r.blockNoteType].meta?.hardBreakShortcut ?? "shift+enter";
1176
+ if (i === "none") return !1;
1177
+ if (i === "shift+enter" && e || i === "enter") {
1178
+ let e = n.storedMarks || n.selection.$head.marks().filter((e) => this.editor.extensionManager.splittableMarks.includes(e.type.name));
1179
+ return n.insert(n.selection.head, n.doc.type.schema.nodes.hardBreak.create()).ensureMarks(e), !0;
1180
+ }
1181
+ return !1;
1182
+ }),
1183
+ () => t.command(({ state: e, dispatch: t, tr: n }) => {
1184
+ let r = v(e);
1185
+ if (!r.isBlockContainer) return !1;
1186
+ let { bnBlock: i, blockContent: a } = r, o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = a.node.childCount === 0;
1187
+ if (o && s && c) {
1188
+ let a = i.afterPos, o = a + 2;
1189
+ if (t) {
1190
+ let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0, r.childContainer?.node].filter((e) => e !== void 0));
1191
+ n.insert(a, t).setSelection(new F(n.doc.resolve(o))).scrollIntoView(), r.childContainer && n.delete(r.childContainer.beforePos, r.childContainer.afterPos);
1192
+ }
1193
+ return !0;
1194
+ }
1195
+ return !1;
1196
+ }),
1197
+ () => t.command(({ state: e, chain: t }) => {
1198
+ let n = v(e);
1199
+ if (!n.isBlockContainer) return !1;
1200
+ let { blockContent: r } = n, i = e.selection.$anchor.parentOffset === 0;
1201
+ return r.node.childCount === 0 ? !1 : (t().deleteSelection().command(f(e.selection.from, i, i)).run(), !0);
1202
+ })
1203
+ ]);
1204
+ return {
1205
+ Backspace: e,
1206
+ Delete: t,
1207
+ Enter: () => n(),
1208
+ "Shift-Enter": () => n(!0),
1209
+ Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(T)?.store.state || this.options.editor.getExtension(C)?.store.state !== void 0) ? !1 : Pt(this.options.editor),
1210
+ "Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(T)?.store.state || this.options.editor.getExtension(C)?.store.state !== void 0) ? !1 : It(this.options.editor),
1211
+ "Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
1212
+ "Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
1213
+ "Mod-z": () => this.options.editor.undo(),
1214
+ "Mod-y": () => this.options.editor.redo(),
1215
+ "Shift-Mod-z": () => this.options.editor.redo()
1216
+ };
1217
+ }
1218
+ }), zn = A.create({
1219
+ name: "insertion",
1220
+ inclusive: !1,
1221
+ excludes: "deletion modification insertion",
1222
+ addAttributes() {
1223
+ return { id: {
1224
+ default: null,
1225
+ validate: "number"
1226
+ } };
1227
+ },
1228
+ extendMarkSchema(e) {
1229
+ return e.name === "insertion" ? {
1230
+ blocknoteIgnore: !0,
1231
+ inclusive: !1,
1232
+ toDOM(e, t) {
1233
+ return [
1234
+ "ins",
1235
+ {
1236
+ "data-id": String(e.attrs.id),
1237
+ "data-inline": String(t),
1238
+ ...!t && { style: "display: contents" }
1239
+ },
1240
+ 0
1241
+ ];
1242
+ },
1243
+ parseDOM: [{
1244
+ tag: "ins",
1245
+ getAttrs(e) {
1246
+ return e.dataset.id ? { id: parseInt(e.dataset.id, 10) } : !1;
1247
+ }
1248
+ }]
1249
+ } : {};
1250
+ }
1251
+ }), Bn = A.create({
1252
+ name: "deletion",
1253
+ inclusive: !1,
1254
+ excludes: "insertion modification deletion",
1255
+ addAttributes() {
1256
+ return { id: {
1257
+ default: null,
1258
+ validate: "number"
1259
+ } };
1260
+ },
1261
+ extendMarkSchema(e) {
1262
+ return e.name === "deletion" ? {
1263
+ blocknoteIgnore: !0,
1264
+ inclusive: !1,
1265
+ toDOM(e, t) {
1266
+ return [
1267
+ "del",
1268
+ {
1269
+ "data-id": String(e.attrs.id),
1270
+ "data-inline": String(t),
1271
+ ...!t && { style: "display: contents" }
1272
+ },
1273
+ 0
1274
+ ];
1275
+ },
1276
+ parseDOM: [{
1277
+ tag: "del",
1278
+ getAttrs(e) {
1279
+ return e.dataset.id ? { id: parseInt(e.dataset.id, 10) } : !1;
1280
+ }
1281
+ }]
1282
+ } : {};
1283
+ }
1284
+ }), Vn = A.create({
1285
+ name: "modification",
1286
+ inclusive: !1,
1287
+ excludes: "deletion insertion",
1288
+ addAttributes() {
1289
+ return {
1290
+ id: {
1291
+ default: null,
1292
+ validate: "number"
1293
+ },
1294
+ type: { validate: "string" },
1295
+ attrName: {
1296
+ default: null,
1297
+ validate: "string|null"
1298
+ },
1299
+ previousValue: { default: null },
1300
+ newValue: { default: null }
1301
+ };
1302
+ },
1303
+ extendMarkSchema(e) {
1304
+ return e.name === "modification" ? {
1305
+ blocknoteIgnore: !0,
1306
+ inclusive: !1,
1307
+ toDOM(e, t) {
1308
+ return [
1309
+ t ? "span" : "div",
1310
+ {
1311
+ "data-type": "modification",
1312
+ "data-id": String(e.attrs.id),
1313
+ "data-mod-type": e.attrs.type,
1314
+ "data-mod-prev-val": JSON.stringify(e.attrs.previousValue),
1315
+ "data-mod-new-val": JSON.stringify(e.attrs.newValue)
1316
+ },
1317
+ 0
1318
+ ];
1319
+ },
1320
+ parseDOM: [{
1321
+ tag: "span[data-type='modification']",
1322
+ getAttrs(e) {
1323
+ return e.dataset.id ? {
1324
+ id: parseInt(e.dataset.id, 10),
1325
+ type: e.dataset.modType,
1326
+ previousValue: e.dataset.modPrevVal,
1327
+ newValue: e.dataset.modNewVal
1328
+ } : !1;
1329
+ }
1330
+ }, {
1331
+ tag: "div[data-type='modification']",
1332
+ getAttrs(e) {
1333
+ return e.dataset.id ? {
1334
+ id: parseInt(e.dataset.id, 10),
1335
+ type: e.dataset.modType,
1336
+ previousValue: e.dataset.modPrevVal
1337
+ } : !1;
1338
+ }
1339
+ }]
1340
+ } : {};
1341
+ }
1342
+ }), Hn = k.create({
1343
+ name: "textAlignment",
1344
+ addGlobalAttributes() {
1345
+ return [{
1346
+ types: ["tableCell", "tableHeader"],
1347
+ attributes: { textAlignment: {
1348
+ default: "left",
1349
+ parseHTML: (e) => e.getAttribute("data-text-alignment"),
1350
+ renderHTML: (e) => e.textAlignment === "left" ? {} : { "data-text-alignment": e.textAlignment }
1351
+ } }
1352
+ }];
1353
+ }
1354
+ }), Un = k.create({
1355
+ name: "blockTextColor",
1356
+ addGlobalAttributes() {
1357
+ return [{
1358
+ types: [
1359
+ "table",
1360
+ "tableCell",
1361
+ "tableHeader"
1362
+ ],
1363
+ attributes: { textColor: ce() }
1364
+ }];
1365
+ }
1366
+ }), Wn = {
1367
+ blockColor: "data-block-color",
1368
+ blockStyle: "data-block-style",
1369
+ id: "data-id",
1370
+ depth: "data-depth",
1371
+ depthChange: "data-depth-change"
1372
+ }, Gn = j.create({
1373
+ name: "blockContainer",
1374
+ group: "blockGroupChild bnBlock",
1375
+ content: "blockContent blockGroup?",
1376
+ priority: 50,
1377
+ defining: !0,
1378
+ marks: "insertion modification deletion",
1379
+ parseHTML() {
1380
+ return [{
1381
+ tag: "div[data-node-type=" + this.name + "]",
1382
+ getAttrs: (e) => {
1383
+ if (typeof e == "string") return !1;
1384
+ let t = {};
1385
+ for (let [n, r] of Object.entries(Wn)) e.getAttribute(r) && (t[n] = e.getAttribute(r));
1386
+ return t;
1387
+ }
1388
+ }, {
1389
+ tag: "div[data-node-type=\"blockOuter\"]",
1390
+ skip: !0
1391
+ }];
1392
+ },
1393
+ renderHTML({ HTMLAttributes: e }) {
1394
+ let t = document.createElement("div");
1395
+ t.className = "bn-block-outer", t.setAttribute("data-node-type", "blockOuter");
1396
+ for (let [n, r] of Object.entries(e)) n !== "class" && t.setAttribute(n, r);
1397
+ let n = {
1398
+ ...this.options.domAttributes?.block || {},
1399
+ ...e
1400
+ }, r = document.createElement("div");
1401
+ r.className = s("bn-block", n.class), r.setAttribute("data-node-type", this.name);
1402
+ for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
1403
+ return t.appendChild(r), {
1404
+ dom: t,
1405
+ contentDOM: r
1406
+ };
1407
+ }
1408
+ }), Kn = j.create({
1409
+ name: "blockGroup",
1410
+ group: "childContainer",
1411
+ content: "blockGroupChild+",
1412
+ marks: "deletion insertion modification",
1413
+ parseHTML() {
1414
+ return [{
1415
+ tag: "div",
1416
+ getAttrs: (e) => typeof e == "string" ? !1 : e.getAttribute("data-node-type") === "blockGroup" ? null : !1
1417
+ }];
1418
+ },
1419
+ renderHTML({ HTMLAttributes: e }) {
1420
+ let t = {
1421
+ ...this.options.domAttributes?.blockGroup || {},
1422
+ ...e
1423
+ }, n = document.createElement("div");
1424
+ n.className = s("bn-block-group", t.class), n.setAttribute("data-node-type", "blockGroup");
1425
+ for (let [e, r] of Object.entries(t)) e !== "class" && n.setAttribute(e, r);
1426
+ return {
1427
+ dom: n,
1428
+ contentDOM: n
1429
+ };
1430
+ }
1431
+ }), qn = j.create({
1432
+ name: "doc",
1433
+ topNode: !0,
1434
+ content: "blockGroup",
1435
+ marks: "insertion modification deletion"
1436
+ }), Jn = Ne(({ options: e }) => ({
1437
+ key: "collaboration",
1438
+ blockNoteExtensions: [
1439
+ ue(e),
1440
+ fe(e),
1441
+ he(e),
1442
+ Ae(),
1443
+ me(e)
1444
+ ]
1445
+ })), Yn = !1;
1446
+ function Xn(e, t) {
1447
+ let n = [
1448
+ M.ClipboardTextSerializer,
1449
+ M.Commands,
1450
+ M.Editable,
1451
+ M.FocusEvents,
1452
+ M.Tabindex,
1453
+ lt,
1454
+ o.configure({
1455
+ types: [
1456
+ "blockContainer",
1457
+ "columnList",
1458
+ "column"
1459
+ ],
1460
+ setIdAttribute: t.setIdAttribute,
1461
+ isWithinEditor: e.isWithinEditor
1462
+ }),
1463
+ Pn,
1464
+ dt,
1465
+ zn,
1466
+ Bn,
1467
+ Vn,
1468
+ ut.extend({ inclusive: !1 }).extend({ addAttributes() {
1469
+ let e = this.parent?.() || {};
1470
+ return delete e.title, e;
1471
+ } }).configure({
1472
+ defaultProtocol: be,
1473
+ protocols: Yn ? [] : ye
1474
+ }),
1475
+ ...Object.values(e.schema.styleSpecs).map((t) => t.implementation.mark.configure({ editor: e })),
1476
+ Un,
1477
+ Nn,
1478
+ Hn,
1479
+ k.create({
1480
+ name: "OverrideEscape",
1481
+ addKeyboardShortcuts: () => ({ Escape: () => e.getExtension(te)?.shown() ? !1 : (e.blur(), !0) })
1482
+ }),
1483
+ qn,
1484
+ Gn.configure({
1485
+ editor: e,
1486
+ domAttributes: t.domAttributes
1487
+ }),
1488
+ Rn.configure({
1489
+ editor: e,
1490
+ tabBehavior: t.tabBehavior
1491
+ }),
1492
+ Kn.configure({ domAttributes: t.domAttributes }),
1493
+ ...Object.values(e.schema.inlineContentSpecs).filter((e) => e.config !== "link" && e.config !== "text").map((t) => t.implementation.node.configure({ editor: e })),
1494
+ ...Object.values(e.schema.blockSpecs).flatMap((n) => [..."node" in n.implementation ? [n.implementation.node.configure({
1495
+ editor: e,
1496
+ domAttributes: t.domAttributes
1497
+ })] : []]),
1498
+ Mn(e),
1499
+ On(e, t.pasteHandler || ((e) => e.defaultPasteHandler())),
1500
+ dn(e)
1501
+ ];
1502
+ return Yn = !0, n;
1503
+ }
1504
+ function Zn(e, t) {
1505
+ let n = [
1506
+ de(),
1507
+ je(t),
1508
+ C(t),
1509
+ T(t),
1510
+ ge(t),
1511
+ Ce(),
1512
+ Ee(t),
1513
+ Pe(t),
1514
+ Te(t),
1515
+ te(t),
1516
+ ...t.trailingBlock === !1 ? [] : [De()]
1517
+ ];
1518
+ return t.collaboration ? n.push(Jn(t.collaboration)) : n.push(ke()), "table" in e.schema.blockSpecs && n.push(we(t)), t.animations !== !1 && n.push(ve()), n;
1519
+ }
1520
+ //#endregion
1521
+ //#region src/editor/managers/ExtensionManager/index.ts
1522
+ var Qn = class {
1523
+ disabledExtensions = /* @__PURE__ */ new Set();
1524
+ extensions = [];
1525
+ abortMap = /* @__PURE__ */ new Map();
1526
+ extensionFactories = /* @__PURE__ */ new Map();
1527
+ extensionPlugins = /* @__PURE__ */ new Map();
1528
+ constructor(e, t) {
1529
+ this.editor = e, this.options = t, e.onMount(() => {
1530
+ for (let t of this.extensions) if (t.mount) {
1531
+ let n = new window.AbortController(), r = t.mount({
1532
+ dom: e.prosemirrorView.dom,
1533
+ root: e.prosemirrorView.root,
1534
+ signal: n.signal
1535
+ });
1536
+ r && n.signal.addEventListener("abort", () => {
1537
+ r();
1538
+ }), this.abortMap.set(t, n);
1539
+ }
1540
+ }), e.onUnmount(() => {
1541
+ for (let [e, t] of this.abortMap.entries()) this.abortMap.delete(e), t.abort();
1542
+ }), this.disabledExtensions = new Set(t.disableExtensions || []);
1543
+ for (let e of Zn(this.editor, this.options)) this.addExtension(e);
1544
+ for (let e of this.options.extensions ?? []) this.addExtension(e);
1545
+ for (let e of Object.values(this.editor.schema.blockSpecs)) for (let t of e.extensions ?? []) this.addExtension(t);
1546
+ }
1547
+ registerExtension(e) {
1548
+ let t = [].concat(e).filter(Boolean);
1549
+ if (!t.length) {
1550
+ console.warn("No extensions found to register", e);
1551
+ return;
1552
+ }
1553
+ let n = t.map((e) => this.addExtension(e)).filter(Boolean), r = /* @__PURE__ */ new Set();
1554
+ for (let e of n) e?.tiptapExtensions && console.warn(`Extension ${e.key} has tiptap extensions, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`, e), e?.inputRules?.length && console.warn(`Extension ${e.key} has input rules, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`, e), this.getProsemirrorPluginsFromExtension(e).plugins.forEach((e) => {
1555
+ r.add(e);
1556
+ });
1557
+ this.updatePlugins((e) => [...e, ...r]);
1558
+ }
1559
+ addExtension(e) {
1560
+ let t;
1561
+ if (t = typeof e == "function" ? e({ editor: this.editor }) : e, !(!t || this.disabledExtensions.has(t.key))) {
1562
+ if (typeof e == "function") {
1563
+ let e = t[Me];
1564
+ typeof e == "function" && this.extensionFactories.set(e, t);
1565
+ }
1566
+ if (this.extensions.push(t), t.blockNoteExtensions) for (let e of t.blockNoteExtensions) this.addExtension(e);
1567
+ return t;
1568
+ }
1569
+ }
1570
+ resolveExtensions(e) {
1571
+ let t = [];
1572
+ if (typeof e == "function") {
1573
+ let n = this.extensionFactories.get(e);
1574
+ n && t.push(n);
1575
+ } else if (Array.isArray(e)) for (let n of e) t.push(...this.resolveExtensions(n));
1576
+ else if (typeof e == "object" && "key" in e) t.push(e);
1577
+ else if (typeof e == "string") {
1578
+ let n = this.extensions.find((t) => t.key === e);
1579
+ n && t.push(n);
1580
+ }
1581
+ return t;
1582
+ }
1583
+ unregisterExtension(e) {
1584
+ let t = this.resolveExtensions(e);
1585
+ if (!t.length) {
1586
+ console.warn("No extensions found to unregister", e);
1587
+ return;
1588
+ }
1589
+ let n = !1, r = /* @__PURE__ */ new Set();
1590
+ for (let i of t) this.extensions = this.extensions.filter((e) => e !== i), this.extensionFactories.forEach((e, t) => {
1591
+ e === i && this.extensionFactories.delete(t);
1592
+ }), this.abortMap.get(i)?.abort(), this.abortMap.delete(i), this.extensionPlugins.get(i)?.forEach((e) => {
1593
+ r.add(e);
1594
+ }), this.extensionPlugins.delete(i), i.tiptapExtensions && !n && (n = !0, console.warn(`Extension ${i.key} has tiptap extensions, but they will not be removed. Please separate the extension into multiple extensions if you want to remove them, or re-initialize the editor.`, e));
1595
+ this.updatePlugins((e) => e.filter((e) => !r.has(e)));
1596
+ }
1597
+ updatePlugins(e) {
1598
+ let t = this.editor.prosemirrorState, n = t.reconfigure({ plugins: e(t.plugins.slice()) });
1599
+ this.editor.prosemirrorView.updateState(n);
1600
+ }
1601
+ getTiptapExtensions() {
1602
+ let e = Xn(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = a(this.extensions), n = /* @__PURE__ */ new Map();
1603
+ for (let r of this.extensions) {
1604
+ r.tiptapExtensions && e.push(...r.tiptapExtensions);
1605
+ let i = t(r.key), { plugins: a, inputRules: o } = this.getProsemirrorPluginsFromExtension(r);
1606
+ a.length && e.push(k.create({
1607
+ name: r.key,
1608
+ priority: i,
1609
+ addProseMirrorPlugins: () => a
1610
+ })), o.length && (n.has(i) || n.set(i, []), n.get(i).push(...o));
1611
+ }
1612
+ e.push(k.create({
1613
+ name: "blocknote-input-rules",
1614
+ addProseMirrorPlugins() {
1615
+ let e = [];
1616
+ return Array.from(n.keys()).sort().reverse().forEach((t) => {
1617
+ e.push(...n.get(t));
1618
+ }), [st({ rules: e })];
1619
+ }
1620
+ }));
1621
+ for (let t of this.options._tiptapOptions?.extensions ?? []) e.push(t);
1622
+ return e;
1623
+ }
1624
+ getProsemirrorPluginsFromExtension(e) {
1625
+ let t = [...e.prosemirrorPlugins ?? []], n = [];
1626
+ return !e.prosemirrorPlugins?.length && !Object.keys(e.keyboardShortcuts || {}).length && !e.inputRules?.length ? {
1627
+ plugins: t,
1628
+ inputRules: n
1629
+ } : (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new ot(e.find, (t, n, r, i) => {
1630
+ let a = e.replace({
1631
+ match: n,
1632
+ range: {
1633
+ from: r,
1634
+ to: i
1635
+ },
1636
+ editor: this.editor
1637
+ });
1638
+ if (a) {
1639
+ let e = this.editor.getTextCursorPosition();
1640
+ if (this.editor.schema.blockSchema[e.block.type].content !== "inline") return null;
1641
+ let n = _(t.tr), o = t.tr.deleteRange(r, i);
1642
+ return d(o, n.bnBlock.beforePos, a), o;
1643
+ }
1644
+ return null;
1645
+ }))), Object.keys(e.keyboardShortcuts || {}).length && t.push(ct(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([e, t]) => [e, () => t({ editor: this.editor })])))), {
1646
+ plugins: t,
1647
+ inputRules: n
1648
+ });
1649
+ }
1650
+ getExtensions() {
1651
+ return new Map(this.extensions.map((e) => [e.key, e]));
1652
+ }
1653
+ getExtension(e) {
1654
+ if (typeof e == "string") return this.extensions.find((t) => t.key === e) || void 0;
1655
+ if (typeof e == "function") return this.extensionFactories.get(e) || void 0;
1656
+ throw Error(`Invalid extension type: ${typeof e}`);
1657
+ }
1658
+ hasExtension(e) {
1659
+ return typeof e == "string" ? this.extensions.some((t) => t.key === e) : typeof e == "object" && "key" in e ? this.extensions.some((t) => t.key === e.key) : typeof e == "function" ? this.extensionFactories.has(e) : !1;
1660
+ }
1661
+ };
1662
+ //#endregion
1663
+ //#region src/util/expandToWords.ts
1664
+ function $n(e, t) {
1665
+ let { $from: n, $to: r } = t;
1666
+ if (n.pos > n.start() && n.pos < e.content.size) {
1667
+ let t = e.textBetween(n.pos, n.pos + 1);
1668
+ if (/^[\w\p{P}]$/u.test(t)) {
1669
+ let t = e.textBetween(n.start(), n.pos).match(/[\w\p{P}]+$/u);
1670
+ t && (n = e.resolve(n.pos - t[0].length));
1671
+ }
1672
+ }
1673
+ if (r.pos < r.end() && r.pos > 0) {
1674
+ let t = e.textBetween(r.pos - 1, r.pos);
1675
+ if (/^[\w\p{P}]$/u.test(t)) {
1676
+ let t = e.textBetween(r.pos, r.end()).match(/^[\w\p{P}]+/u);
1677
+ t && (r = e.resolve(r.pos + t[0].length));
1678
+ }
1679
+ }
1680
+ return {
1681
+ $from: n,
1682
+ $to: r,
1683
+ from: n.pos,
1684
+ to: r.pos
1685
+ };
1686
+ }
1687
+ //#endregion
1688
+ //#region src/api/blockManipulation/selections/selection.ts
1689
+ function er(e) {
1690
+ let t = g(e);
1691
+ if (e.selection.empty || "node" in e.selection) return;
1692
+ let n = e.doc.resolve(w(e.doc, e.selection.from).posBeforeNode), r = e.doc.resolve(w(e.doc, e.selection.to).posBeforeNode), i = (r, i) => {
1693
+ let a = n.posAtIndex(r, i), o = e.doc.resolve(a).nodeAfter;
1694
+ if (!o) throw Error(`Error getting selection - node not found at position ${a}`);
1695
+ return y(o, t);
1696
+ }, a = [], o = n.sharedDepth(r.pos), s = n.index(o), c = r.index(o);
1697
+ if (n.depth > o) {
1698
+ a.push(y(n.nodeAfter, t));
1699
+ for (let e = n.depth; e > o; e--) if (n.node(e).type.isInGroup("childContainer")) {
1700
+ let t = n.index(e) + 1, r = n.node(e).childCount;
1701
+ for (let n = t; n < r; n++) a.push(i(n, e));
1702
+ }
1703
+ } else a.push(i(s, o));
1704
+ for (let e = s + 1; e <= c; e++) a.push(i(e, o));
1705
+ if (a.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
1706
+ return { blocks: a };
1707
+ }
1708
+ function tr(e, t, n) {
1709
+ let r = typeof t == "string" ? t : t.id, a = typeof n == "string" ? n : n.id, o = ee(g(e));
1710
+ if (r === a) throw Error(`Attempting to set selection with the same anchor and head blocks (id ${r})`);
1711
+ let s = i(r, e.doc);
1712
+ if (!s) throw Error(`Block with ID ${r} not found`);
1713
+ let c = i(a, e.doc);
1714
+ if (!c) throw Error(`Block with ID ${a} not found`);
1715
+ let l = S(s), u = S(c), d = o.blockSchema[l.blockNoteType], f = o.blockSchema[u.blockNoteType];
1716
+ if (!l.isBlockContainer || d.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${r})`);
1717
+ if (!u.isBlockContainer || f.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${a})`);
1718
+ let p, m;
1719
+ if (d.content === "table") {
1720
+ let e = Qe.get(l.blockContent.node);
1721
+ p = l.blockContent.beforePos + e.positionAt(0, 0, l.blockContent.node) + 1 + 2;
1722
+ } else p = l.blockContent.beforePos + 1;
1723
+ if (f.content === "table") {
1724
+ let t = Qe.get(u.blockContent.node), n = u.blockContent.beforePos + t.positionAt(t.height - 1, t.width - 1, u.blockContent.node) + 1;
1725
+ m = n + e.doc.resolve(n).nodeAfter.nodeSize - 2;
1726
+ } else m = u.blockContent.afterPos - 1;
1727
+ e.setSelection(F.create(e.doc, p, m));
1728
+ }
1729
+ function nr(e, t = !1) {
1730
+ let n = g(e), r = t ? $n(e.doc, e.selection) : e.selection, i = r.$from, a = r.$to;
1731
+ for (; a.parentOffset >= a.parent.nodeSize - 2 && a.depth > 0;) a = e.doc.resolve(a.pos + 1);
1732
+ for (; a.parentOffset === 0 && a.depth > 0;) a = e.doc.resolve(a.pos - 1);
1733
+ for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
1734
+ for (; i.parentOffset >= i.parent.nodeSize - 2 && i.depth > 0;) i = e.doc.resolve(i.pos + 1);
1735
+ let o = ie(e.doc.slice(i.pos, a.pos, !0), n);
1736
+ return {
1737
+ _meta: {
1738
+ startPos: i.pos,
1739
+ endPos: a.pos
1740
+ },
1741
+ ...o
1742
+ };
1743
+ }
1744
+ //#endregion
1745
+ //#region src/api/blockManipulation/selections/textCursorPosition.ts
1746
+ function rr(e) {
1747
+ let { bnBlock: t } = _(e), n = g(e.doc), r = e.doc.resolve(t.beforePos), i = r.nodeBefore, a = e.doc.resolve(t.afterPos).nodeAfter, o;
1748
+ return r.depth > 1 && (o = r.node(), o.type.isInGroup("bnBlock") || (o = r.node(r.depth - 1))), {
1749
+ block: y(t.node, n),
1750
+ prevBlock: i === null ? void 0 : y(i, n),
1751
+ nextBlock: a === null ? void 0 : y(a, n),
1752
+ parentBlock: o === void 0 ? void 0 : y(o, n)
1753
+ };
1754
+ }
1755
+ function ir(e, t, n = "start") {
1756
+ let r = typeof t == "string" ? t : t.id, a = ee(g(e.doc)), o = i(r, e.doc);
1757
+ if (!o) throw Error(`Block with ID ${r} not found`);
1758
+ let s = S(o), c = a.blockSchema[s.blockNoteType].content;
1759
+ if (s.isBlockContainer) {
1760
+ let t = s.blockContent;
1761
+ if (c === "none") {
1762
+ e.setSelection(N.create(e.doc, t.beforePos));
1763
+ return;
1764
+ }
1765
+ if (c === "inline") n === "start" ? e.setSelection(F.create(e.doc, t.beforePos + 1)) : e.setSelection(F.create(e.doc, t.afterPos - 1));
1766
+ else if (c === "table") n === "start" ? e.setSelection(F.create(e.doc, t.beforePos + 4)) : e.setSelection(F.create(e.doc, t.afterPos - 4));
1767
+ else throw new u(c);
1768
+ } else ir(e, (n === "start" ? s.childContainer.node.firstChild : s.childContainer.node.lastChild).attrs.id, n);
1769
+ }
1770
+ //#endregion
1771
+ //#region src/editor/managers/SelectionManager.ts
1772
+ var ar = class {
1773
+ constructor(e) {
1774
+ this.editor = e;
1775
+ }
1776
+ getSelection() {
1777
+ return this.editor.transact((e) => er(e));
1778
+ }
1779
+ getSelectionCutBlocks(e = !1) {
1780
+ return this.editor.transact((t) => nr(t, e));
1781
+ }
1782
+ setSelection(e, t) {
1783
+ return this.editor.transact((n) => tr(n, e, t));
1784
+ }
1785
+ getTextCursorPosition() {
1786
+ return this.editor.transact((e) => rr(e));
1787
+ }
1788
+ setTextCursorPosition(e, t = "start") {
1789
+ return this.editor.transact((n) => ir(n, e, t));
1790
+ }
1791
+ getSelectionBoundingBox() {
1792
+ if (!this.editor.prosemirrorView) return;
1793
+ let { selection: e } = this.editor.prosemirrorState, { ranges: t } = e, n = Math.min(...t.map((e) => e.$from.pos)), r = Math.max(...t.map((e) => e.$to.pos));
1794
+ if (Je(e)) {
1795
+ let e = this.editor.prosemirrorView.nodeDOM(n);
1796
+ if (e) return e.getBoundingClientRect();
1797
+ }
1798
+ return Xe(this.editor.prosemirrorView, n, r).toJSON();
1799
+ }
1800
+ }, or = class {
1801
+ constructor(e) {
1802
+ this.editor = e;
1803
+ }
1804
+ activeTransaction = null;
1805
+ can(e) {
1806
+ try {
1807
+ return this.isInCan = !0, e();
1808
+ } finally {
1809
+ this.isInCan = !1;
1810
+ }
1811
+ }
1812
+ isInCan = !1;
1813
+ exec(e) {
1814
+ if (this.activeTransaction) throw Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");
1815
+ if (this.isInCan) return this.canExec(e);
1816
+ let t = this.prosemirrorState, n = this.prosemirrorView;
1817
+ return e(t, (e) => this.prosemirrorView.dispatch(e), n);
1818
+ }
1819
+ canExec(e) {
1820
+ if (this.activeTransaction) throw Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");
1821
+ let t = this.prosemirrorState, n = this.prosemirrorView;
1822
+ return e(t, void 0, n);
1823
+ }
1824
+ transact(e) {
1825
+ if (this.activeTransaction) return e(this.activeTransaction);
1826
+ try {
1827
+ this.activeTransaction = this.editor._tiptapEditor.state.tr;
1828
+ let t = e(this.activeTransaction), n = this.activeTransaction;
1829
+ return this.activeTransaction = null, n && (n.docChanged || n.selectionSet || n.scrolledIntoView || n.storedMarksSet || !n.isGeneric) && this.prosemirrorView.dispatch(n), t;
1830
+ } finally {
1831
+ this.activeTransaction = null;
1832
+ }
1833
+ }
1834
+ get prosemirrorState() {
1835
+ if (this.activeTransaction) throw Error("`prosemirrorState` should not be called within a `transact` call, move the `prosemirrorState` call outside of the `transact` call or use `editor.transact` to read the current editor state");
1836
+ return this.editor._tiptapEditor.state;
1837
+ }
1838
+ get prosemirrorView() {
1839
+ return this.editor._tiptapEditor.view;
1840
+ }
1841
+ isFocused() {
1842
+ return this.prosemirrorView?.hasFocus() || !1;
1843
+ }
1844
+ focus() {
1845
+ this.prosemirrorView?.focus();
1846
+ }
1847
+ get isEditable() {
1848
+ if (!this.editor._tiptapEditor) {
1849
+ if (!this.editor.headless) throw Error("no editor, but also not headless?");
1850
+ return !1;
1851
+ }
1852
+ return this.editor._tiptapEditor.isEditable === void 0 ? !0 : this.editor._tiptapEditor.isEditable;
1853
+ }
1854
+ set isEditable(e) {
1855
+ if (!this.editor._tiptapEditor) {
1856
+ if (!this.editor.headless) throw Error("no editor, but also not headless?");
1857
+ return;
1858
+ }
1859
+ this.editor._tiptapEditor.options.editable !== e && this.editor._tiptapEditor.setEditable(e);
1860
+ }
1861
+ undo() {
1862
+ let e = this.editor.getExtension("yUndo");
1863
+ if (e) return this.exec(e.undoCommand);
1864
+ let t = this.editor.getExtension("history");
1865
+ if (t) return this.exec(t.undoCommand);
1866
+ throw Error("No undo plugin found");
1867
+ }
1868
+ redo() {
1869
+ let e = this.editor.getExtension("yUndo");
1870
+ if (e) return this.exec(e.redoCommand);
1871
+ let t = this.editor.getExtension("history");
1872
+ if (t) return this.exec(t.redoCommand);
1873
+ throw Error("No redo plugin found");
1874
+ }
1875
+ };
1876
+ //#endregion
1877
+ //#region src/api/blockManipulation/insertContentAt.ts
1878
+ function sr(e, t, n, r = { updateSelection: !0 }) {
1879
+ let { from: i, to: a } = typeof t == "number" ? {
1880
+ from: t,
1881
+ to: t
1882
+ } : {
1883
+ from: t.from,
1884
+ to: t.to
1885
+ }, o = !0, s = !0, c = "";
1886
+ if (n.forEach((e) => {
1887
+ e.check(), o && e.isText && e.marks.length === 0 ? c += e.text : o = !1, s = s ? e.isBlock : !1;
1888
+ }), i === a && s) {
1889
+ let { parent: t } = e.doc.resolve(i);
1890
+ t.isTextblock && !t.type.spec.code && !t.childCount && (--i, a += 1);
1891
+ }
1892
+ return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection && Ze(e, e.steps.length - 1, -1), !0;
1893
+ }
1894
+ //#endregion
1895
+ //#region src/editor/managers/StyleManager.ts
1896
+ var cr = class {
1897
+ constructor(e) {
1898
+ this.editor = e;
1899
+ }
1900
+ insertInlineContent(e, { updateSelection: t = !1 } = {}) {
1901
+ let n = b(e, this.editor.pmSchema);
1902
+ this.editor.transact((e) => {
1903
+ sr(e, {
1904
+ from: e.selection.from,
1905
+ to: e.selection.to
1906
+ }, n, { updateSelection: t });
1907
+ });
1908
+ }
1909
+ getActiveStyles() {
1910
+ return this.editor.transact((e) => {
1911
+ let t = {}, n = e.selection.$to.marks();
1912
+ for (let e of n) {
1913
+ let n = this.editor.schema.styleSchema[e.type.name];
1914
+ if (!n) {
1915
+ e.type.name !== "link" && !e.type.spec.blocknoteIgnore && console.warn("mark not found in styleschema", e.type.name);
1916
+ continue;
1917
+ }
1918
+ n.propSchema === "boolean" ? t[n.type] = !0 : t[n.type] = e.attrs.stringValue;
1919
+ }
1920
+ return t;
1921
+ });
1922
+ }
1923
+ addStyles(e) {
1924
+ for (let [t, n] of Object.entries(e)) {
1925
+ let e = this.editor.schema.styleSchema[t];
1926
+ if (!e) throw Error(`style ${t} not found in styleSchema`);
1927
+ if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.setMark(t);
1928
+ else if (e.propSchema === "string") this.editor._tiptapEditor.commands.setMark(t, { stringValue: n });
1929
+ else throw new u(e.propSchema);
1930
+ }
1931
+ }
1932
+ removeStyles(e) {
1933
+ for (let t of Object.keys(e)) this.editor._tiptapEditor.commands.unsetMark(t);
1934
+ }
1935
+ toggleStyles(e) {
1936
+ for (let [t, n] of Object.entries(e)) {
1937
+ let e = this.editor.schema.styleSchema[t];
1938
+ if (!e) throw Error(`style ${t} not found in styleSchema`);
1939
+ if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.toggleMark(t);
1940
+ else if (e.propSchema === "string") this.editor._tiptapEditor.commands.toggleMark(t, { stringValue: n });
1941
+ else throw new u(e.propSchema);
1942
+ }
1943
+ }
1944
+ getSelectedText() {
1945
+ return this.editor.transact((e) => e.doc.textBetween(e.selection.from, e.selection.to));
1946
+ }
1947
+ getSelectedLinkUrl() {
1948
+ return this.editor._tiptapEditor.getAttributes("link").href;
1949
+ }
1950
+ createLink(e, t) {
1951
+ if (e === "") return;
1952
+ let n = this.editor.pmSchema.mark("link", { href: e });
1953
+ this.editor.transact((e) => {
1954
+ let { from: r, to: i } = e.selection;
1955
+ t ? e.insertText(t, r, i).addMark(r, r + t.length, n) : e.setSelection($e.create(e.doc, i)).addMark(r, i, n);
1956
+ });
1957
+ }
1958
+ };
1959
+ //#endregion
1960
+ //#region src/editor/transformPasted.ts
1961
+ function lr(e) {
1962
+ return Ke(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
1963
+ }
1964
+ function ur(e, t) {
1965
+ let n = t.nodes.hardBreak, r = I.empty;
1966
+ return e.forEach((e) => {
1967
+ e.isTextblock && e.childCount > 0 ? (r = r.append(e.content), r = r.addToEnd(n.create())) : e.isText ? r = r.addToEnd(e) : e.isBlock && e.childCount > 0 && (r = r.append(ur(e.content, t)), r = r.addToEnd(n.create()));
1968
+ }), r.lastChild?.type === n && (r = r.cut(0, r.size - 1)), r;
1969
+ }
1970
+ function dr(e, t) {
1971
+ let n = [];
1972
+ return e.forEach((e, r, i) => {
1973
+ i !== t && n.push(e);
1974
+ }), I.from(n);
1975
+ }
1976
+ function fr(e, t) {
1977
+ let n = [];
1978
+ for (let r = 0; r < e.childCount; r++) if (e.child(r).type.name === "tableRow") if (n.length > 0 && n[n.length - 1].type.name === "table") {
1979
+ let t = n[n.length - 1], i = t.copy(t.content.addToEnd(e.child(r)));
1980
+ n[n.length - 1] = i;
1981
+ } else {
1982
+ let i = t.nodes.table.createChecked(void 0, e.child(r));
1983
+ n.push(i);
1984
+ }
1985
+ else n.push(e.child(r));
1986
+ return e = I.from(n), e;
1987
+ }
1988
+ function pr(e, t) {
1989
+ let n = I.from(e.content);
1990
+ if (n = fr(n, t.state.schema), lr(t)) {
1991
+ let e = !1;
1992
+ if (n.descendants((t) => {
1993
+ t.type.isInGroup("tableContent") && (e = !0);
1994
+ }), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new L(ur(n, t.state.schema), 0, 0);
1995
+ }
1996
+ if (!mr(n, t)) return new L(n, e.openStart, e.openEnd);
1997
+ for (let e = 0; e < n.childCount; e++) if (n.child(e).type.spec.group === "blockContent") {
1998
+ let r = [n.child(e)];
1999
+ if (e + 1 < n.childCount && n.child(e + 1).type.name === "blockGroup") {
2000
+ let t = n.child(e + 1).child(0).child(0);
2001
+ (t.type.name === "bulletListItem" || t.type.name === "numberedListItem" || t.type.name === "checkListItem") && (r.push(n.child(e + 1)), n = dr(n, e + 1));
2002
+ }
2003
+ let i = t.state.schema.nodes.blockContainer.createChecked(void 0, r);
2004
+ n = n.replaceChild(e, i);
2005
+ }
2006
+ return new L(n, e.openStart, e.openEnd);
2007
+ }
2008
+ function mr(e, t) {
2009
+ let n = e.childCount === 1, r = e.firstChild?.type.spec.content === "inline*", i = e.firstChild?.type.spec.content === "tableRow+";
2010
+ if (n) {
2011
+ if (r) return !1;
2012
+ if (i) {
2013
+ let e = v(t.state);
2014
+ if (e.isBlockContainer) return e.blockContent.node.type.spec.content !== "tableRow+";
2015
+ }
2016
+ }
2017
+ return !0;
2018
+ }
2019
+ //#endregion
2020
+ //#region src/editor/BlockNoteEditor.ts
2021
+ var hr = {
2022
+ enableInputRules: !0,
2023
+ enablePasteRules: !0,
2024
+ enableCoreExtensions: !1
2025
+ }, gr = class e extends Ie {
2026
+ pmSchema;
2027
+ _tiptapEditor;
2028
+ elementRenderer = null;
2029
+ blockCache = /* @__PURE__ */ new WeakMap();
2030
+ dictionary;
2031
+ schema;
2032
+ blockImplementations;
2033
+ inlineContentImplementations;
2034
+ styleImplementations;
2035
+ uploadFile;
2036
+ onUploadStartCallbacks = [];
2037
+ onUploadEndCallbacks = [];
2038
+ resolveFileUrl;
2039
+ settings;
2040
+ static create(t) {
2041
+ return new e(t ?? {});
2042
+ }
2043
+ constructor(e) {
2044
+ super(), this.options = e, this.dictionary = e.dictionary || Fe, this.settings = { tables: {
2045
+ splitCells: e?.tables?.splitCells ?? !1,
2046
+ cellBackgroundColor: e?.tables?.cellBackgroundColor ?? !1,
2047
+ cellTextColor: e?.tables?.cellTextColor ?? !1,
2048
+ headers: e?.tables?.headers ?? !1
2049
+ } };
2050
+ let t = {
2051
+ defaultStyles: !0,
2052
+ schema: e.schema || oe.create(),
2053
+ ...e,
2054
+ placeholders: {
2055
+ ...this.dictionary.placeholders,
2056
+ ...e.placeholders
2057
+ }
2058
+ };
2059
+ if (this.schema = t.schema, this.blockImplementations = t.schema.blockSpecs, this.inlineContentImplementations = t.schema.inlineContentSpecs, this.styleImplementations = t.schema.styleSpecs, t.uploadFile) {
2060
+ let e = t.uploadFile;
2061
+ this.uploadFile = async (t, n) => {
2062
+ this.onUploadStartCallbacks.forEach((e) => e.apply(this, [n]));
2063
+ try {
2064
+ return await e(t, n);
2065
+ } finally {
2066
+ this.onUploadEndCallbacks.forEach((e) => e.apply(this, [n]));
2067
+ }
2068
+ };
2069
+ }
2070
+ this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new Wt(this), this._extensionManager = new Qn(this, t);
2071
+ let n = this._extensionManager.getTiptapExtensions(), r = this._extensionManager.hasExtension("ySync") || this._extensionManager.hasExtension("liveblocksExtension");
2072
+ r && t.initialContent && console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");
2073
+ let i = {
2074
+ ...hr,
2075
+ ...t._tiptapOptions,
2076
+ element: null,
2077
+ autofocus: t.autofocus ?? !1,
2078
+ extensions: n,
2079
+ editorProps: {
2080
+ ...t._tiptapOptions?.editorProps,
2081
+ attributes: {
2082
+ tabIndex: "0",
2083
+ ...t._tiptapOptions?.editorProps?.attributes,
2084
+ ...t.domAttributes?.editor,
2085
+ class: s("bn-editor", t.defaultStyles ? "bn-default-styles" : "", t.domAttributes?.editor?.class || "")
2086
+ },
2087
+ transformPasted: pr
2088
+ }
2089
+ };
2090
+ try {
2091
+ let e = t.initialContent || (r ? [{
2092
+ type: "paragraph",
2093
+ id: "initialBlockId"
2094
+ }] : [{
2095
+ type: "paragraph",
2096
+ id: o.options.generateID()
2097
+ }]);
2098
+ if (!Array.isArray(e) || e.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + e);
2099
+ let n = qe(i.extensions), a = Ge({
2100
+ type: "doc",
2101
+ content: [{
2102
+ type: "blockGroup",
2103
+ content: e.map((e) => c(e, n, this.schema.styleSchema).toJSON())
2104
+ }]
2105
+ }, n, i.parseOptions);
2106
+ this._tiptapEditor = new We({
2107
+ ...i,
2108
+ content: a.toJSON()
2109
+ }), this.pmSchema = this._tiptapEditor.schema;
2110
+ } catch (e) {
2111
+ throw Error("Error creating document from blocks passed as `initialContent`", { cause: e });
2112
+ }
2113
+ let a, l = this.pmSchema.nodes.doc.createAndFill;
2114
+ this.pmSchema.nodes.doc.createAndFill = (...e) => {
2115
+ if (a) return a;
2116
+ let t = l.apply(this.pmSchema.nodes.doc, e), n = JSON.parse(JSON.stringify(t.toJSON()));
2117
+ return n.content[0].content[0].attrs.id = "initialBlockId", a = ze.fromJSON(this.pmSchema, n), a;
2118
+ }, this.pmSchema.cached.blockNoteEditor = this, this._blockManager = new Ut(this), this._exportManager = new on(this), this._selectionManager = new ar(this), this._stateManager = new or(this), this._styleManager = new cr(this), this.emit("create");
2119
+ }
2120
+ _blockManager;
2121
+ _eventManager;
2122
+ _exportManager;
2123
+ _extensionManager;
2124
+ _selectionManager;
2125
+ _stateManager;
2126
+ _styleManager;
2127
+ get extensions() {
2128
+ return this._extensionManager.getExtensions();
2129
+ }
2130
+ exec(e) {
2131
+ return this._stateManager.exec(e);
2132
+ }
2133
+ canExec(e) {
2134
+ return this._stateManager.canExec(e);
2135
+ }
2136
+ transact(e) {
2137
+ return this._stateManager.transact(e);
2138
+ }
2139
+ unregisterExtension = (...e) => this._extensionManager.unregisterExtension(...e);
2140
+ registerExtension = (...e) => this._extensionManager.registerExtension(...e);
2141
+ getExtension = ((...e) => this._extensionManager.getExtension(...e));
2142
+ mount = (e) => {
2143
+ let t = e.getRootNode();
2144
+ typeof ShadowRoot < "u" && t instanceof ShadowRoot ? t.appendChild(this.portalElement) : document.body.appendChild(this.portalElement), this._tiptapEditor.mount({ mount: e });
2145
+ };
2146
+ unmount = () => {
2147
+ this.portalElement?.remove(), this._tiptapEditor.unmount();
2148
+ };
2149
+ get prosemirrorState() {
2150
+ return this._stateManager.prosemirrorState;
2151
+ }
2152
+ get prosemirrorView() {
2153
+ return this._stateManager.prosemirrorView;
2154
+ }
2155
+ get domElement() {
2156
+ if (!this.headless) return this.prosemirrorView?.dom;
2157
+ }
2158
+ _portalElement;
2159
+ get portalElement() {
2160
+ if (typeof document > "u") throw Error("Portal element accessed, but not available in headless mode");
2161
+ return this._portalElement ||= document.createElement("div"), this._portalElement;
2162
+ }
2163
+ isWithinEditor = (e) => !!(this.domElement?.parentElement?.contains(e) || this.portalElement?.contains(e));
2164
+ isFocused() {
2165
+ return this.headless ? !1 : this.prosemirrorView?.hasFocus() || !1;
2166
+ }
2167
+ get headless() {
2168
+ return !this._tiptapEditor.isInitialized;
2169
+ }
2170
+ focus() {
2171
+ this.headless || this.prosemirrorView.focus();
2172
+ }
2173
+ blur() {
2174
+ this.headless || this.domElement?.blur();
2175
+ }
2176
+ onUploadStart(e) {
2177
+ return this.onUploadStartCallbacks.push(e), () => {
2178
+ let t = this.onUploadStartCallbacks.indexOf(e);
2179
+ t > -1 && this.onUploadStartCallbacks.splice(t, 1);
2180
+ };
2181
+ }
2182
+ onUploadEnd(e) {
2183
+ return this.onUploadEndCallbacks.push(e), () => {
2184
+ let t = this.onUploadEndCallbacks.indexOf(e);
2185
+ t > -1 && this.onUploadEndCallbacks.splice(t, 1);
2186
+ };
2187
+ }
2188
+ get topLevelBlocks() {
2189
+ return this.document;
2190
+ }
2191
+ get document() {
2192
+ return this._blockManager.document;
2193
+ }
2194
+ getBlock(e) {
2195
+ return this._blockManager.getBlock(e);
2196
+ }
2197
+ getPrevBlock(e) {
2198
+ return this._blockManager.getPrevBlock(e);
2199
+ }
2200
+ getNextBlock(e) {
2201
+ return this._blockManager.getNextBlock(e);
2202
+ }
2203
+ getParentBlock(e) {
2204
+ return this._blockManager.getParentBlock(e);
2205
+ }
2206
+ forEachBlock(e, t = !1) {
2207
+ this._blockManager.forEachBlock(e, t);
2208
+ }
2209
+ onEditorContentChange(e) {
2210
+ this._tiptapEditor.on("update", e);
2211
+ }
2212
+ onEditorSelectionChange(e) {
2213
+ this._tiptapEditor.on("selectionUpdate", e);
2214
+ }
2215
+ onBeforeChange(e) {
2216
+ return this._extensionManager.getExtension(de).subscribe(e);
2217
+ }
2218
+ getTextCursorPosition() {
2219
+ return this._selectionManager.getTextCursorPosition();
2220
+ }
2221
+ setTextCursorPosition(e, t = "start") {
2222
+ return this._selectionManager.setTextCursorPosition(e, t);
2223
+ }
2224
+ getSelection() {
2225
+ return this._selectionManager.getSelection();
2226
+ }
2227
+ getSelectionCutBlocks(e = !1) {
2228
+ return this._selectionManager.getSelectionCutBlocks(e);
2229
+ }
2230
+ setSelection(e, t) {
2231
+ return this._selectionManager.setSelection(e, t);
2232
+ }
2233
+ get isEditable() {
2234
+ return this._stateManager.isEditable;
2235
+ }
2236
+ set isEditable(e) {
2237
+ this._stateManager.isEditable = e;
2238
+ }
2239
+ insertBlocks(e, t, n = "before") {
2240
+ return this._blockManager.insertBlocks(e, t, n);
2241
+ }
2242
+ updateBlock(e, t) {
2243
+ return this._blockManager.updateBlock(e, t);
2244
+ }
2245
+ removeBlocks(e) {
2246
+ return this._blockManager.removeBlocks(e);
2247
+ }
2248
+ replaceBlocks(e, t) {
2249
+ return this._blockManager.replaceBlocks(e, t);
2250
+ }
2251
+ undo() {
2252
+ return this._stateManager.undo();
2253
+ }
2254
+ redo() {
2255
+ return this._stateManager.redo();
2256
+ }
2257
+ insertInlineContent(e, { updateSelection: t = !1 } = {}) {
2258
+ this._styleManager.insertInlineContent(e, { updateSelection: t });
2259
+ }
2260
+ getActiveStyles() {
2261
+ return this._styleManager.getActiveStyles();
2262
+ }
2263
+ addStyles(e) {
2264
+ this._styleManager.addStyles(e);
2265
+ }
2266
+ removeStyles(e) {
2267
+ this._styleManager.removeStyles(e);
2268
+ }
2269
+ toggleStyles(e) {
2270
+ this._styleManager.toggleStyles(e);
2271
+ }
2272
+ getSelectedText() {
2273
+ return this._styleManager.getSelectedText();
2274
+ }
2275
+ getSelectedLinkUrl() {
2276
+ return this._styleManager.getSelectedLinkUrl();
2277
+ }
2278
+ createLink(e, t) {
2279
+ this._styleManager.createLink(e, t);
2280
+ }
2281
+ canNestBlock() {
2282
+ return this._blockManager.canNestBlock();
2283
+ }
2284
+ nestBlock() {
2285
+ this._blockManager.nestBlock();
2286
+ }
2287
+ canUnnestBlock() {
2288
+ return this._blockManager.canUnnestBlock();
2289
+ }
2290
+ unnestBlock() {
2291
+ this._blockManager.unnestBlock();
2292
+ }
2293
+ moveBlocksUp() {
2294
+ return this._blockManager.moveBlocksUp();
2295
+ }
2296
+ moveBlocksDown() {
2297
+ return this._blockManager.moveBlocksDown();
2298
+ }
2299
+ blocksToHTMLLossy(e = this.document) {
2300
+ return this._exportManager.blocksToHTMLLossy(e);
2301
+ }
2302
+ blocksToFullHTML(e = this.document) {
2303
+ return this._exportManager.blocksToFullHTML(e);
2304
+ }
2305
+ tryParseHTMLToBlocks(e) {
2306
+ return this._exportManager.tryParseHTMLToBlocks(e);
2307
+ }
2308
+ blocksToMarkdownLossy(e = this.document) {
2309
+ return this._exportManager.blocksToMarkdownLossy(e);
2310
+ }
2311
+ tryParseMarkdownToBlocks(e) {
2312
+ return this._exportManager.tryParseMarkdownToBlocks(e);
2313
+ }
2314
+ onChange(e, t) {
2315
+ return this._eventManager.onChange(e, t);
2316
+ }
2317
+ onSelectionChange(e, t) {
2318
+ return this._eventManager.onSelectionChange(e, t);
2319
+ }
2320
+ onMount(e) {
2321
+ this._eventManager.onMount(e);
2322
+ }
2323
+ onUnmount(e) {
2324
+ this._eventManager.onUnmount(e);
2325
+ }
2326
+ getSelectionBoundingBox() {
2327
+ return this._selectionManager.getSelectionBoundingBox();
2328
+ }
2329
+ get isEmpty() {
2330
+ let e = this.document;
2331
+ return e.length === 0 || e.length === 1 && e[0].type === "paragraph" && e[0].content.length === 0;
2332
+ }
2333
+ pasteHTML(e, t = !1) {
2334
+ this._exportManager.pasteHTML(e, t);
2335
+ }
2336
+ pasteText(e) {
2337
+ return this._exportManager.pasteText(e);
2338
+ }
2339
+ pasteMarkdown(e) {
2340
+ return this._exportManager.pasteMarkdown(e);
2341
+ }
2342
+ }, _r = class {
2343
+ constructor(e, t, n) {
2344
+ this.mappings = t, this.options = n;
2345
+ }
2346
+ async resolveFile(e) {
2347
+ if (!this.options?.resolveFileUrl) return (await fetch(e)).blob();
2348
+ let t = await this.options.resolveFileUrl(e);
2349
+ return t instanceof Blob ? t : (await fetch(t)).blob();
2350
+ }
2351
+ mapStyles(e) {
2352
+ return Object.entries(e).map(([e, t]) => this.mappings.styleMapping[e](t, this));
2353
+ }
2354
+ mapInlineContent(e) {
2355
+ return this.mappings.inlineContentMapping[e.type](e, this);
2356
+ }
2357
+ transformInlineContent(e) {
2358
+ return e.map((e) => this.mapInlineContent(e));
2359
+ }
2360
+ async mapBlock(e, t, n, r) {
2361
+ return this.mappings.blockMapping[e.type](e, this, t, n, r);
2362
+ }
2363
+ };
2364
+ //#endregion
2365
+ //#region src/exporter/mapping.ts
2366
+ function vr(e) {
2367
+ return {
2368
+ createBlockMapping: (e) => e,
2369
+ createInlineContentMapping: (e) => e,
2370
+ createStyleMapping: (e) => e
2371
+ };
2372
+ }
2373
+ //#endregion
2374
+ //#region src/util/combineByGroup.ts
2375
+ function yr(e, ...t) {
2376
+ let n = [...e];
2377
+ for (let e of t) for (let t of e) {
2378
+ let e = n.findLastIndex((e) => e.group === t.group);
2379
+ e === -1 ? n.push(t) : n.splice(e + 1, 0, t);
2380
+ }
2381
+ return n;
2382
+ }
2383
+ //#endregion
2384
+ export { z as _, $n as a, pt as b, q as c, Vt as d, Ht as f, B as g, V as h, gr as i, K as l, U as m, vr as n, Y as o, Bt as p, _r as r, an as s, yr as t, zt as u, ht as v, ft as x, mt as y };
2385
+
2386
+ //# sourceMappingURL=src-Hjv1f5lc.js.map