@blocknote/core 0.47.2 → 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 (124) 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 -4216
  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/api/parsers/html/parseHTML.ts +2 -0
  56. package/src/api/parsers/html/util/normalizeWhitespace.ts +87 -0
  57. package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +17 -23
  58. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +346 -0
  59. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +143 -71
  60. package/src/editor/Block.css +5 -8
  61. package/src/editor/BlockNoteEditor.ts +38 -1
  62. package/src/editor/editor.css +0 -20
  63. package/src/editor/managers/ExtensionManager/extensions.ts +12 -1
  64. package/src/editor/performance.test.ts +134 -0
  65. package/src/extensions/Collaboration/ForkYDoc.test.ts +115 -103
  66. package/src/extensions/Placeholder/Placeholder.ts +1 -1
  67. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +86 -0
  68. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +33 -49
  69. package/src/extensions/SideMenu/SideMenu.ts +14 -8
  70. package/src/extensions/TableHandles/TableHandles.ts +14 -0
  71. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +57 -17
  72. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +9 -8
  73. package/src/index.ts +1 -1
  74. package/src/schema/blocks/createSpec.ts +6 -2
  75. package/src/schema/inlineContent/types.ts +0 -1
  76. package/src/vite-env.d.ts +6 -0
  77. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +14 -1
  78. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +1 -0
  79. package/types/src/api/parsers/html/util/normalizeWhitespace.d.ts +6 -0
  80. package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +1 -0
  81. package/types/src/editor/BlockNoteEditor.d.ts +13 -0
  82. package/types/src/editor/performance.test.d.ts +1 -0
  83. package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +1 -0
  84. package/types/src/extensions/SideMenu/SideMenu.d.ts +6 -0
  85. package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -0
  86. package/dist/BlockNoteExtension-BWw0r8Gy.cjs +0 -2
  87. package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +0 -1
  88. package/dist/BlockNoteExtension-C2X7LW-V.js +0 -25
  89. package/dist/BlockNoteExtension-C2X7LW-V.js.map +0 -1
  90. package/dist/BlockNoteSchema-CCs_V3lo.cjs +0 -2
  91. package/dist/BlockNoteSchema-CCs_V3lo.cjs.map +0 -1
  92. package/dist/BlockNoteSchema-ooiKsd5B.js +0 -270
  93. package/dist/BlockNoteSchema-ooiKsd5B.js.map +0 -1
  94. package/dist/EventEmitter-CLwfmbqG.cjs +0 -2
  95. package/dist/EventEmitter-CLwfmbqG.cjs.map +0 -1
  96. package/dist/EventEmitter-CjSwpTbz.js +0 -27
  97. package/dist/EventEmitter-CjSwpTbz.js.map +0 -1
  98. package/dist/ShowSelection-B0ch3unP.js +0 -51
  99. package/dist/ShowSelection-B0ch3unP.js.map +0 -1
  100. package/dist/ShowSelection-BxnbRvy4.cjs +0 -2
  101. package/dist/ShowSelection-BxnbRvy4.cjs.map +0 -1
  102. package/dist/TrailingNode-GzE59m_7.js +0 -2288
  103. package/dist/TrailingNode-GzE59m_7.js.map +0 -1
  104. package/dist/TrailingNode-n0WdMPUl.cjs +0 -2
  105. package/dist/TrailingNode-n0WdMPUl.cjs.map +0 -1
  106. package/dist/blockToNode-BNoNIXU7.js +0 -1140
  107. package/dist/blockToNode-BNoNIXU7.js.map +0 -1
  108. package/dist/blockToNode-CumVjgem.cjs +0 -7
  109. package/dist/blockToNode-CumVjgem.cjs.map +0 -1
  110. package/dist/blocknote.cjs.map +0 -1
  111. package/dist/blocknote.js.map +0 -1
  112. package/dist/blocks.cjs.map +0 -1
  113. package/dist/blocks.js.map +0 -1
  114. package/dist/defaultBlocks-Dg9kQWXm.cjs +0 -6
  115. package/dist/defaultBlocks-Dg9kQWXm.cjs.map +0 -1
  116. package/dist/defaultBlocks-ZzGbYgQn.js +0 -3284
  117. package/dist/defaultBlocks-ZzGbYgQn.js.map +0 -1
  118. package/dist/en-Cl87Uuyf.cjs +0 -2
  119. package/dist/en-Cl87Uuyf.cjs.map +0 -1
  120. package/dist/en-njEqD7AG.js +0 -408
  121. package/dist/en-njEqD7AG.js.map +0 -1
  122. package/dist/extensions.cjs.map +0 -1
  123. package/dist/extensions.js.map +0 -1
  124. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,3313 @@
1
+ import { n as e, t } from "./BlockNoteExtension-B6RhuQ3V.js";
2
+ import { DOMParser as n, Fragment as r, Slice as i } from "prosemirror-model";
3
+ import { Mapping as a, ReplaceStep as o } from "prosemirror-transform";
4
+ import { Extension as s, Mark as c, Node as l, callOrReturn as u, combineTransactionSteps as d, findChildrenInRange as f, findParentNode as p, getChangedRanges as m, getExtensionField as h, mergeAttributes as g } from "@tiptap/core";
5
+ import { Plugin as _, PluginKey as v, TextSelection as ee } from "prosemirror-state";
6
+ import { v4 as te } from "uuid";
7
+ import { DOMParser as ne, DOMSerializer as re, Fragment as ie } from "@tiptap/pm/model";
8
+ import { CellSelection as ae, TableMap as oe, TableView as se, columnResizing as ce, goToNextCell as le, tableEditing as ue } from "prosemirror-tables";
9
+ import { createHighlightPlugin as de } from "prosemirror-highlight";
10
+ import { createParser as fe } from "prosemirror-highlight/shiki";
11
+ import { Plugin as pe, PluginKey as me } from "@tiptap/pm/state";
12
+ import { Decoration as he, DecorationSet as ge } from "@tiptap/pm/view";
13
+ import { Decoration as _e, DecorationSet as ve } from "prosemirror-view";
14
+ import { absolutePositionToRelativePosition as ye, relativePositionToAbsolutePosition as be, ySyncPluginKey as xe } from "y-prosemirror";
15
+ import Se from "@tiptap/extension-bold";
16
+ import Ce from "@tiptap/extension-code";
17
+ import we from "@tiptap/extension-italic";
18
+ import Te from "@tiptap/extension-strike";
19
+ import Ee from "@tiptap/extension-underline";
20
+ //#region src/extensions/tiptap-extensions/UniqueID/UniqueID.ts
21
+ function De(e, t = JSON.stringify) {
22
+ let n = {};
23
+ return e.filter((e) => {
24
+ let r = t(e);
25
+ return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
26
+ });
27
+ }
28
+ function Oe(e) {
29
+ return De(e.filter((t, n) => e.indexOf(t) !== n));
30
+ }
31
+ var ke = s.create({
32
+ name: "uniqueID",
33
+ priority: 1e4,
34
+ addOptions() {
35
+ return {
36
+ attributeName: "id",
37
+ types: [],
38
+ setIdAttribute: !1,
39
+ isWithinEditor: void 0,
40
+ generateID: () => {
41
+ if (typeof window < "u" && window.__TEST_OPTIONS) {
42
+ let e = window.__TEST_OPTIONS;
43
+ return e.mockID === void 0 ? e.mockID = 0 : e.mockID++, e.mockID.toString();
44
+ }
45
+ return te();
46
+ },
47
+ filterTransaction: null
48
+ };
49
+ },
50
+ addGlobalAttributes() {
51
+ return [{
52
+ types: this.options.types,
53
+ attributes: { [this.options.attributeName]: {
54
+ default: null,
55
+ parseHTML: (e) => e.getAttribute(`data-${this.options.attributeName}`),
56
+ renderHTML: (e) => {
57
+ let t = { [`data-${this.options.attributeName}`]: e[this.options.attributeName] };
58
+ return this.options.setIdAttribute ? {
59
+ ...t,
60
+ id: e[this.options.attributeName]
61
+ } : t;
62
+ }
63
+ } }
64
+ }];
65
+ },
66
+ addProseMirrorPlugins() {
67
+ let { isWithinEditor: e } = this.options, t = null, n = !1;
68
+ return [new _({
69
+ key: new v("uniqueID"),
70
+ appendTransaction: (e, t, n) => {
71
+ let r = e.some((e) => e.docChanged) && !t.doc.eq(n.doc), i = this.options.filterTransaction && e.some((e) => !this.options.filterTransaction?.(e));
72
+ if (!r || i) return;
73
+ let { tr: a } = n, { types: o, attributeName: s, generateID: c } = this.options, l = d(t.doc, e), { mapping: u } = l;
74
+ if (m(l).forEach(({ newRange: e }) => {
75
+ let r = f(n.doc, e, (e) => o.includes(e.type.name)), i = Oe(r.map(({ node: e }) => e.attrs[s]).filter((e) => e !== null));
76
+ r.forEach(({ node: e, pos: r }) => {
77
+ let o = a.doc.nodeAt(r)?.attrs[s];
78
+ if (o === null) {
79
+ let i = t.doc.type.createAndFill().content;
80
+ if (t.doc.content.findDiffStart(i) === null) {
81
+ let t = JSON.parse(JSON.stringify(n.doc.toJSON()));
82
+ if (t.content[0].content[0].attrs.id = "initialBlockId", JSON.stringify(t.content) === JSON.stringify(i.toJSON())) {
83
+ a.setNodeMarkup(r, void 0, {
84
+ ...e.attrs,
85
+ [s]: "initialBlockId"
86
+ });
87
+ return;
88
+ }
89
+ }
90
+ a.setNodeMarkup(r, void 0, {
91
+ ...e.attrs,
92
+ [s]: c()
93
+ });
94
+ return;
95
+ }
96
+ let { deleted: l } = u.invert().mapResult(r);
97
+ l && i.includes(o) && a.setNodeMarkup(r, void 0, {
98
+ ...e.attrs,
99
+ [s]: c()
100
+ });
101
+ });
102
+ }), a.steps.length) return a.setMeta("uniqueID", !0), a;
103
+ },
104
+ view(n) {
105
+ let r = (r) => {
106
+ let i = n.dom.parentElement;
107
+ t = i?.contains(r.target) || e?.(r.target) ? i : null;
108
+ };
109
+ return window.addEventListener("dragstart", r), { destroy() {
110
+ window.removeEventListener("dragstart", r);
111
+ } };
112
+ },
113
+ props: {
114
+ handleDOMEvents: {
115
+ drop: (e, r) => (n = t !== e.dom.parentElement || r.dataTransfer?.effectAllowed === "copy", t = null, !1),
116
+ paste: () => (n = !0, !1)
117
+ },
118
+ transformPasted: (e) => {
119
+ if (!n) return e;
120
+ let { types: t, attributeName: a } = this.options, o = (e) => {
121
+ let n = [];
122
+ return e.forEach((e) => {
123
+ if (e.isText) {
124
+ n.push(e);
125
+ return;
126
+ }
127
+ if (!t.includes(e.type.name)) {
128
+ n.push(e.copy(o(e.content)));
129
+ return;
130
+ }
131
+ let r = e.type.create({
132
+ ...e.attrs,
133
+ [a]: null
134
+ }, o(e.content), e.marks);
135
+ n.push(r);
136
+ }), r.from(n);
137
+ };
138
+ return n = !1, new i(o(e.content), e.openStart, e.openEnd);
139
+ }
140
+ }
141
+ })];
142
+ }
143
+ });
144
+ //#endregion
145
+ //#region src/schema/inlineContent/types.ts
146
+ function Ae(e) {
147
+ return e.type === "link";
148
+ }
149
+ function je(e) {
150
+ return typeof e != "string" && e.type === "link";
151
+ }
152
+ function y(e) {
153
+ return typeof e != "string" && e.type === "text";
154
+ }
155
+ //#endregion
156
+ //#region src/util/table.ts
157
+ function Me(e) {
158
+ return Ne(e) ? { ...e } : b(e) ? {
159
+ type: "tableCell",
160
+ content: [].concat(e.content),
161
+ props: {
162
+ backgroundColor: e.props?.backgroundColor ?? "default",
163
+ textColor: e.props?.textColor ?? "default",
164
+ textAlignment: e.props?.textAlignment ?? "left",
165
+ colspan: e.props?.colspan ?? 1,
166
+ rowspan: e.props?.rowspan ?? 1
167
+ }
168
+ } : {
169
+ type: "tableCell",
170
+ content: [].concat(e),
171
+ props: {
172
+ backgroundColor: "default",
173
+ textColor: "default",
174
+ textAlignment: "left",
175
+ colspan: 1,
176
+ rowspan: 1
177
+ }
178
+ };
179
+ }
180
+ function b(e) {
181
+ return e != null && typeof e != "string" && !Array.isArray(e) && e.type === "tableCell";
182
+ }
183
+ function Ne(e) {
184
+ return b(e) && e.props !== void 0 && e.content !== void 0;
185
+ }
186
+ function x(e) {
187
+ return Ne(e) ? e.props.colspan ?? 1 : 1;
188
+ }
189
+ function Pe(e) {
190
+ return Ne(e) ? e.props.rowspan ?? 1 : 1;
191
+ }
192
+ //#endregion
193
+ //#region src/util/typescript.ts
194
+ var S = class extends Error {
195
+ constructor(e) {
196
+ super(`Unreachable case: ${e}`);
197
+ }
198
+ };
199
+ function Fe(e, t = !0) {
200
+ let { "data-test": n, ...r } = e;
201
+ if (Object.keys(r).length > 0 && t) throw Error("Object must be empty " + JSON.stringify(e));
202
+ }
203
+ //#endregion
204
+ //#region src/util/browser.ts
205
+ var Ie = () => typeof navigator < "u" && (/Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent));
206
+ function C(e, t = "Ctrl") {
207
+ return Ie() ? e.replace("Mod", "⌘") : e.replace("Mod", t);
208
+ }
209
+ function w(...e) {
210
+ return [...new Set(e.filter((e) => e).join(" ").split(" "))].join(" ");
211
+ }
212
+ var Le = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
213
+ //#endregion
214
+ //#region src/blocks/defaultBlockHelpers.ts
215
+ function Re(e, t, n, r) {
216
+ let i = document.createElement("div");
217
+ i.className = w("bn-block-content", n.class), i.setAttribute("data-content-type", e);
218
+ for (let [e, t] of Object.entries(n)) e !== "class" && i.setAttribute(e, t);
219
+ let a = document.createElement(t);
220
+ a.className = w("bn-inline-content", r.class);
221
+ for (let [e, t] of Object.entries(r)) e !== "class" && a.setAttribute(e, t);
222
+ return i.appendChild(a), {
223
+ dom: i,
224
+ contentDOM: a
225
+ };
226
+ }
227
+ var ze = (e, t) => {
228
+ let n = U(e, t.pmSchema);
229
+ n.type.name === "blockContainer" && (n = n.firstChild);
230
+ let r = t.pmSchema.nodes[n.type.name].spec.toDOM;
231
+ if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
232
+ let i = r(n);
233
+ if (typeof i != "object" || !("dom" in i)) throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.");
234
+ return i;
235
+ };
236
+ function Be(e, t = "<br>") {
237
+ let n = e.querySelectorAll("p");
238
+ if (n.length > 1) {
239
+ let e = n[0];
240
+ for (let r = 1; r < n.length; r++) {
241
+ let i = n[r];
242
+ e.innerHTML += t + i.innerHTML, i.remove();
243
+ }
244
+ }
245
+ }
246
+ //#endregion
247
+ //#region src/util/string.ts
248
+ function T(e) {
249
+ return "data-" + e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
250
+ }
251
+ function Ve(e) {
252
+ let t = e.split("/");
253
+ return !t.length || t[t.length - 1] === "" ? e : t[t.length - 1];
254
+ }
255
+ function He(e) {
256
+ let t = [
257
+ "mp4",
258
+ "webm",
259
+ "ogg",
260
+ "mov",
261
+ "mkv",
262
+ "flv",
263
+ "avi",
264
+ "wmv",
265
+ "m4v"
266
+ ];
267
+ try {
268
+ let n = new URL(e).pathname.split(".").pop()?.toLowerCase() || "";
269
+ return t.includes(n);
270
+ } catch {
271
+ return !1;
272
+ }
273
+ }
274
+ //#endregion
275
+ //#region src/schema/blocks/internal.ts
276
+ function Ue(e) {
277
+ let t = {};
278
+ return Object.entries(e).forEach(([e, n]) => {
279
+ t[e] = {
280
+ default: n.default,
281
+ keepOnSplit: !0,
282
+ parseHTML: (t) => {
283
+ let r = t.getAttribute(T(e));
284
+ if (r === null) return null;
285
+ if (n.default === void 0 && n.type === "boolean" || n.default !== void 0 && typeof n.default == "boolean") return r === "true" ? !0 : r === "false" ? !1 : null;
286
+ if (n.default === void 0 && n.type === "number" || n.default !== void 0 && typeof n.default == "number") {
287
+ let e = parseFloat(r);
288
+ return !Number.isNaN(e) && Number.isFinite(e) ? e : null;
289
+ }
290
+ return r;
291
+ },
292
+ renderHTML: (t) => t[e] === n.default ? {} : { [T(e)]: t[e] }
293
+ };
294
+ }), t;
295
+ }
296
+ function We(e, t, n, r) {
297
+ let i = e();
298
+ if (i === void 0) throw Error("Cannot find node position");
299
+ let a = n.state.doc.resolve(i).node().attrs.id;
300
+ if (!a) throw Error("Block doesn't have id");
301
+ let o = t.getBlock(a);
302
+ if (o.type !== r) throw Error("Block type does not match");
303
+ return o;
304
+ }
305
+ function E(e, t, n, r, i = !1, a) {
306
+ let o = document.createElement("div");
307
+ if (a !== void 0) for (let [e, t] of Object.entries(a)) e !== "class" && o.setAttribute(e, t);
308
+ o.className = w("bn-block-content", a?.class || ""), o.setAttribute("data-content-type", t);
309
+ for (let [e, t] of Object.entries(n)) t !== r[e].default && o.setAttribute(T(e), t);
310
+ return i && o.setAttribute("data-file-block", ""), o.appendChild(e.dom), e.contentDOM && (e.contentDOM.className = w("bn-inline-content", e.contentDOM.className)), {
311
+ ...e,
312
+ dom: o
313
+ };
314
+ }
315
+ function Ge(e, t, n) {
316
+ return {
317
+ config: {
318
+ type: e.type,
319
+ content: e.content,
320
+ propSchema: t
321
+ },
322
+ implementation: {
323
+ node: e.node,
324
+ render: ze,
325
+ toExternalHTML: ze
326
+ },
327
+ extensions: n
328
+ };
329
+ }
330
+ //#endregion
331
+ //#region src/schema/blocks/createSpec.ts
332
+ function Ke(e, t) {
333
+ e.stopEvent = (e) => (e.type === "mousedown" && setTimeout(() => {
334
+ t.view.dom.blur();
335
+ }, 10), !0);
336
+ }
337
+ function qe(e, t) {
338
+ let n = [{
339
+ tag: "[data-content-type=" + e.type + "]",
340
+ contentElement: ".bn-inline-content"
341
+ }];
342
+ return t.parse && n.push({
343
+ tag: "*",
344
+ getAttrs(e) {
345
+ if (typeof e == "string") return !1;
346
+ let n = t.parse?.(e);
347
+ return n === void 0 ? !1 : n;
348
+ },
349
+ preserveWhitespace: !0,
350
+ getContent: e.content === "inline" || e.content === "none" ? (n, r) => {
351
+ if (t.parseContent) {
352
+ let e = t.parseContent({
353
+ el: n,
354
+ schema: r
355
+ });
356
+ if (e !== void 0) return e;
357
+ }
358
+ if (e.content === "inline") {
359
+ let e = n.cloneNode(!0);
360
+ return Be(e, t.meta?.code ? "\n" : "<br>"), ne.fromSchema(r).parse(e, {
361
+ topNode: r.nodes.paragraph.create(),
362
+ preserveWhitespace: !0
363
+ }).content;
364
+ }
365
+ return ie.empty;
366
+ } : void 0
367
+ }), n;
368
+ }
369
+ function Je(e, t, n, r) {
370
+ let i = t.node || l.create({
371
+ name: e.type,
372
+ content: e.content === "inline" ? "inline*" : e.content === "none" ? "" : e.content,
373
+ group: "blockContent",
374
+ selectable: t.meta?.selectable ?? !0,
375
+ isolating: t.meta?.isolating ?? !0,
376
+ code: t.meta?.code ?? !1,
377
+ defining: t.meta?.defining ?? !0,
378
+ priority: r,
379
+ addAttributes() {
380
+ return Ue(e.propSchema);
381
+ },
382
+ parseHTML() {
383
+ return qe(e, t);
384
+ },
385
+ renderHTML({ HTMLAttributes: n }) {
386
+ let r = document.createElement("div");
387
+ return E({
388
+ dom: r,
389
+ contentDOM: e.content === "inline" ? r : void 0
390
+ }, e.type, {}, e.propSchema, t.meta?.fileBlockAccept !== void 0, n);
391
+ },
392
+ addNodeView() {
393
+ return (n) => {
394
+ let r = this.options.editor, i = We(n.getPos, r, this.editor, e.type), a = this.options.domAttributes?.blockContent || {}, o = t.render.call({
395
+ blockContentDOMAttributes: a,
396
+ props: n,
397
+ renderType: "nodeView"
398
+ }, i, r);
399
+ return t.meta?.selectable === !1 && Ke(o, this.editor), o;
400
+ };
401
+ }
402
+ });
403
+ if (i.name !== e.type) throw Error("Node name does not match block type. This is a bug in BlockNote.");
404
+ return {
405
+ config: e,
406
+ implementation: {
407
+ ...t,
408
+ node: i,
409
+ render(e, n) {
410
+ let r = i.options.domAttributes?.blockContent || {};
411
+ return t.render.call({
412
+ blockContentDOMAttributes: r,
413
+ props: void 0,
414
+ renderType: "dom"
415
+ }, e, n);
416
+ },
417
+ toExternalHTML: (e, n, r) => {
418
+ let a = i.options.domAttributes?.blockContent || {};
419
+ return t.toExternalHTML?.call({ blockContentDOMAttributes: a }, e, n, r) ?? t.render.call({
420
+ blockContentDOMAttributes: a,
421
+ renderType: "dom",
422
+ props: void 0
423
+ }, e, n);
424
+ }
425
+ },
426
+ extensions: n
427
+ };
428
+ }
429
+ function D(e) {
430
+ return e;
431
+ }
432
+ function O(e, t, n) {
433
+ return (r = {}) => {
434
+ let i = typeof e == "function" ? e(r) : e, a = typeof t == "function" ? t(r) : t, o = n ? typeof n == "function" ? n(r) : n : void 0;
435
+ return {
436
+ config: i,
437
+ implementation: {
438
+ ...a,
439
+ toExternalHTML(e, t, n) {
440
+ let r = a.toExternalHTML?.call({ blockContentDOMAttributes: this.blockContentDOMAttributes }, e, t, n);
441
+ if (r !== void 0) return E(r, e.type, e.props, i.propSchema, a.meta?.fileBlockAccept !== void 0);
442
+ },
443
+ render(e, t) {
444
+ return E(a.render.call({
445
+ blockContentDOMAttributes: this.blockContentDOMAttributes,
446
+ renderType: this.renderType,
447
+ props: this.props
448
+ }, e, t), e.type, e.props, i.propSchema, a.meta?.fileBlockAccept !== void 0, this.blockContentDOMAttributes);
449
+ }
450
+ },
451
+ extensions: o
452
+ };
453
+ };
454
+ }
455
+ //#endregion
456
+ //#region src/api/getBlockInfoFromPos.ts
457
+ function Ye(e, t) {
458
+ let n = e.resolve(t);
459
+ if (n.nodeAfter && n.nodeAfter.type.isInGroup("bnBlock")) return {
460
+ posBeforeNode: n.pos,
461
+ node: n.nodeAfter
462
+ };
463
+ let r = n.depth, i = n.node(r);
464
+ for (; r > 0;) {
465
+ if (i.type.isInGroup("bnBlock")) return {
466
+ posBeforeNode: n.before(r),
467
+ node: i
468
+ };
469
+ r--, i = n.node(r);
470
+ }
471
+ let a = [];
472
+ e.descendants((e, t) => {
473
+ e.type.isInGroup("bnBlock") && a.push(t);
474
+ }), console.warn(`Position ${t} is not within a blockContainer node.`);
475
+ let o = e.resolve(a.find((e) => e >= t) || a[a.length - 1]);
476
+ return {
477
+ posBeforeNode: o.pos,
478
+ node: o.nodeAfter
479
+ };
480
+ }
481
+ function Xe(e, t) {
482
+ if (!e.type.isInGroup("bnBlock")) throw Error(`Attempted to get bnBlock node at position but found node of different type ${e.type.name}`);
483
+ let n = e, r = t, i = {
484
+ node: n,
485
+ beforePos: r,
486
+ afterPos: r + n.nodeSize
487
+ };
488
+ if (n.type.name === "blockContainer") {
489
+ let e, t;
490
+ if (n.forEach((n, i) => {
491
+ if (n.type.spec.group === "blockContent") {
492
+ let t = n, a = r + i + 1;
493
+ e = {
494
+ node: t,
495
+ beforePos: a,
496
+ afterPos: a + n.nodeSize
497
+ };
498
+ } else if (n.type.name === "blockGroup") {
499
+ let e = n, a = r + i + 1;
500
+ t = {
501
+ node: e,
502
+ beforePos: a,
503
+ afterPos: a + n.nodeSize
504
+ };
505
+ }
506
+ }), !e) throw Error(`blockContainer node does not contain a blockContent node in its children: ${n}`);
507
+ return {
508
+ isBlockContainer: !0,
509
+ bnBlock: i,
510
+ blockContent: e,
511
+ childContainer: t,
512
+ blockNoteType: e.node.type.name
513
+ };
514
+ } else {
515
+ if (!i.node.type.isInGroup("childContainer")) throw Error(`bnBlock node is not in the childContainer group: ${i.node}`);
516
+ return {
517
+ isBlockContainer: !1,
518
+ bnBlock: i,
519
+ childContainer: i,
520
+ blockNoteType: i.node.type.name
521
+ };
522
+ }
523
+ }
524
+ function k(e) {
525
+ return Xe(e.node, e.posBeforeNode);
526
+ }
527
+ function Ze(e) {
528
+ if (!e.nodeAfter) throw Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);
529
+ return Xe(e.nodeAfter, e.pos);
530
+ }
531
+ function Qe(e) {
532
+ return k(Ye(e.doc, e.selection.anchor));
533
+ }
534
+ function $e(e) {
535
+ return k(Ye(e.doc, e.selection.anchor));
536
+ }
537
+ //#endregion
538
+ //#region src/api/pmUtil.ts
539
+ function A(e) {
540
+ return "doc" in e ? e.doc.type.schema : e.type.schema;
541
+ }
542
+ function et(e) {
543
+ return e.cached.blockNoteEditor;
544
+ }
545
+ function j(e) {
546
+ return et(e).schema;
547
+ }
548
+ function M(e) {
549
+ return j(e).blockSchema;
550
+ }
551
+ function N(e) {
552
+ return j(e).inlineContentSchema;
553
+ }
554
+ function P(e) {
555
+ return j(e).styleSchema;
556
+ }
557
+ function F(e) {
558
+ return et(e).blockCache;
559
+ }
560
+ //#endregion
561
+ //#region src/api/nodeConversions/nodeToBlock.ts
562
+ function tt(e, t, n) {
563
+ let r = {
564
+ type: "tableContent",
565
+ columnWidths: [],
566
+ headerRows: void 0,
567
+ headerCols: void 0,
568
+ rows: []
569
+ }, i = [];
570
+ e.content.forEach((e, a, o) => {
571
+ let s = { cells: [] };
572
+ o === 0 && e.content.forEach((e) => {
573
+ let t = e.attrs.colwidth;
574
+ t ??= Array(e.attrs.colspan ?? 1).fill(void 0), r.columnWidths.push(...t);
575
+ }), s.cells = e.content.content.map((e, r) => (i[o] || (i[o] = []), i[o][r] = e.type.name === "tableHeader", {
576
+ type: "tableCell",
577
+ content: e.content.content.map((e) => nt(e, t, n)).reduce((e, t) => {
578
+ if (!e.length) return t;
579
+ let n = e[e.length - 1], r = t[0];
580
+ return r && y(n) && y(r) && JSON.stringify(n.styles) === JSON.stringify(r.styles) ? (n.text += "\n" + r.text, e.push(...t.slice(1)), e) : (e.push(...t), e);
581
+ }, []),
582
+ props: {
583
+ colspan: e.attrs.colspan,
584
+ rowspan: e.attrs.rowspan,
585
+ backgroundColor: e.attrs.backgroundColor,
586
+ textColor: e.attrs.textColor,
587
+ textAlignment: e.attrs.textAlignment
588
+ }
589
+ })), r.rows.push(s);
590
+ });
591
+ for (let e = 0; e < i.length; e++) i[e]?.every((e) => e) && (r.headerRows = (r.headerRows ?? 0) + 1);
592
+ for (let e = 0; e < i[0]?.length; e++) i?.every((t) => t[e]) && (r.headerCols = (r.headerCols ?? 0) + 1);
593
+ return r;
594
+ }
595
+ function nt(e, t, n) {
596
+ let r = [], i;
597
+ return e.content.forEach((e) => {
598
+ if (e.type.name === "hardBreak") {
599
+ if (i) if (y(i)) i.text += "\n";
600
+ else if (Ae(i)) i.content[i.content.length - 1].text += "\n";
601
+ else throw Error("unexpected");
602
+ else i = {
603
+ type: "text",
604
+ text: "\n",
605
+ styles: {}
606
+ };
607
+ return;
608
+ }
609
+ if (e.type.name !== "link" && e.type.name !== "text") {
610
+ if (!t[e.type.name]) {
611
+ console.warn("unrecognized inline content type", e.type.name);
612
+ return;
613
+ }
614
+ i &&= (r.push(i), void 0), r.push(rt(e, t, n));
615
+ return;
616
+ }
617
+ let a = {}, o;
618
+ for (let t of e.marks) if (t.type.name === "link") o = t;
619
+ else {
620
+ let e = n[t.type.name];
621
+ if (!e) {
622
+ if (t.type.spec.blocknoteIgnore) continue;
623
+ throw Error(`style ${t.type.name} not found in styleSchema`);
624
+ }
625
+ if (e.propSchema === "boolean") a[e.type] = !0;
626
+ else if (e.propSchema === "string") a[e.type] = t.attrs.stringValue;
627
+ else throw new S(e.propSchema);
628
+ }
629
+ i ? y(i) ? o ? (r.push(i), i = {
630
+ type: "link",
631
+ href: o.attrs.href,
632
+ content: [{
633
+ type: "text",
634
+ text: e.textContent,
635
+ styles: a
636
+ }]
637
+ }) : JSON.stringify(i.styles) === JSON.stringify(a) ? i.text += e.textContent : (r.push(i), i = {
638
+ type: "text",
639
+ text: e.textContent,
640
+ styles: a
641
+ }) : Ae(i) && (o ? i.href === o.attrs.href ? JSON.stringify(i.content[i.content.length - 1].styles) === JSON.stringify(a) ? i.content[i.content.length - 1].text += e.textContent : i.content.push({
642
+ type: "text",
643
+ text: e.textContent,
644
+ styles: a
645
+ }) : (r.push(i), i = {
646
+ type: "link",
647
+ href: o.attrs.href,
648
+ content: [{
649
+ type: "text",
650
+ text: e.textContent,
651
+ styles: a
652
+ }]
653
+ }) : (r.push(i), i = {
654
+ type: "text",
655
+ text: e.textContent,
656
+ styles: a
657
+ })) : i = o ? {
658
+ type: "link",
659
+ href: o.attrs.href,
660
+ content: [{
661
+ type: "text",
662
+ text: e.textContent,
663
+ styles: a
664
+ }]
665
+ } : {
666
+ type: "text",
667
+ text: e.textContent,
668
+ styles: a
669
+ };
670
+ }), i && r.push(i), r;
671
+ }
672
+ function rt(e, t, n) {
673
+ if (e.type.name === "text" || e.type.name === "link") throw Error("unexpected");
674
+ let r = {}, i = t[e.type.name];
675
+ for (let [t, n] of Object.entries(e.attrs)) {
676
+ if (!i) throw Error("ic node is of an unrecognized type: " + e.type.name);
677
+ t in i.propSchema && (r[t] = n);
678
+ }
679
+ let a;
680
+ return a = i.content === "styled" ? nt(e, t, n) : void 0, {
681
+ type: e.type.name,
682
+ props: r,
683
+ content: a
684
+ };
685
+ }
686
+ function I(e, t, n = M(t), r = N(t), i = P(t), a = F(t)) {
687
+ if (!e.type.isInGroup("bnBlock")) throw Error("Node should be a bnBlock, but is instead: " + e.type.name);
688
+ let o = a?.get(e);
689
+ if (o) return o;
690
+ let s = Xe(e, 0), c = s.bnBlock.node.attrs.id;
691
+ c === null && (c = ke.options.generateID());
692
+ let l = n[s.blockNoteType];
693
+ if (!l) throw Error("Block is of an unrecognized type: " + s.blockNoteType);
694
+ let u = {};
695
+ for (let [t, n] of Object.entries({
696
+ ...e.attrs,
697
+ ...s.isBlockContainer ? s.blockContent.node.attrs : {}
698
+ })) {
699
+ let e = l.propSchema;
700
+ t in e && !(e[t].default === void 0 && n === void 0) && (u[t] = n);
701
+ }
702
+ let d = n[s.blockNoteType], f = [];
703
+ s.childContainer?.node.forEach((e) => {
704
+ f.push(I(e, t, n, r, i, a));
705
+ });
706
+ let p;
707
+ if (d.content === "inline") {
708
+ if (!s.isBlockContainer) throw Error("impossible");
709
+ p = nt(s.blockContent.node, r, i);
710
+ } else if (d.content === "table") {
711
+ if (!s.isBlockContainer) throw Error("impossible");
712
+ p = tt(s.blockContent.node, r, i);
713
+ } else if (d.content === "none") p = void 0;
714
+ else throw new S(d.content);
715
+ let m = {
716
+ id: c,
717
+ type: d.type,
718
+ props: u,
719
+ content: p,
720
+ children: f
721
+ };
722
+ return a?.set(e, m), m;
723
+ }
724
+ function it(e, t = A(e), n = M(t), r = N(t), i = P(t), a = F(t)) {
725
+ let o = [];
726
+ return e.firstChild && e.firstChild.descendants((e) => (o.push(I(e, t, n, r, i, a)), !1)), o;
727
+ }
728
+ function at(e, t, n = M(t), r = N(t), i = P(t), a = F(t)) {
729
+ function o(e, s, c) {
730
+ if (e.type.name !== "blockGroup") throw Error("unexpected");
731
+ let l = [], u, d;
732
+ return e.forEach((f, p, m) => {
733
+ if (f.type.name !== "blockContainer") throw Error("unexpected");
734
+ if (f.childCount === 0) return;
735
+ if (f.childCount === 0 || f.childCount > 2) throw Error("unexpected, blockContainer.childCount: " + f.childCount);
736
+ let h = m === 0, g = m === e.childCount - 1;
737
+ if (f.firstChild.type.name === "blockGroup") {
738
+ if (!h) throw Error("unexpected");
739
+ let e = o(f.firstChild, Math.max(0, s - 1), g ? Math.max(0, c - 1) : 0);
740
+ u = e.blockCutAtStart, g && (d = e.blockCutAtEnd), l.push(...e.blocks);
741
+ return;
742
+ }
743
+ let _ = I(f, t, n, r, i, a), v = f.childCount > 1 ? f.child(1) : void 0, ee = [];
744
+ if (v) {
745
+ let e = o(v, 0, g ? Math.max(0, c - 1) : 0);
746
+ ee = e.blocks, g && (d = e.blockCutAtEnd);
747
+ }
748
+ g && !v && c > 1 && (d = _.id), h && s > 1 && (u = _.id), l.push({
749
+ ..._,
750
+ children: ee
751
+ });
752
+ }), {
753
+ blocks: l,
754
+ blockCutAtStart: u,
755
+ blockCutAtEnd: d
756
+ };
757
+ }
758
+ if (e.content.childCount === 0) return {
759
+ blocks: [],
760
+ blockCutAtStart: void 0,
761
+ blockCutAtEnd: void 0
762
+ };
763
+ if (e.content.childCount !== 1) throw Error("slice must be a single block, did you forget includeParents=true?");
764
+ return o(e.content.firstChild, Math.max(e.openStart - 1, 0), Math.max(e.openEnd - 1, 0));
765
+ }
766
+ //#endregion
767
+ //#region src/schema/inlineContent/internal.ts
768
+ function ot(e, t, n, r) {
769
+ return e.dom.setAttribute("data-inline-content-type", t), Object.entries(n).filter(([e, t]) => t !== r[e].default).map(([e, t]) => [T(e), t]).forEach(([t, n]) => e.dom.setAttribute(t, n)), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
770
+ }
771
+ function st(e) {
772
+ return { Backspace: ({ editor: t }) => {
773
+ let n = t.state.selection.$from;
774
+ return t.state.selection.empty && n.node().type.name === e.type && n.parentOffset === 0;
775
+ } };
776
+ }
777
+ function ct(e, t) {
778
+ return {
779
+ config: e,
780
+ implementation: t
781
+ };
782
+ }
783
+ function lt(e, t, n) {
784
+ return ct({
785
+ type: e.name,
786
+ propSchema: t,
787
+ content: e.config.content === "inline*" ? "styled" : "none"
788
+ }, {
789
+ ...n,
790
+ node: e
791
+ });
792
+ }
793
+ function ut(e) {
794
+ return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
795
+ }
796
+ //#endregion
797
+ //#region src/schema/styles/internal.ts
798
+ function dt(e) {
799
+ return e === "boolean" ? {} : { stringValue: {
800
+ default: void 0,
801
+ keepOnSplit: !0,
802
+ parseHTML: (e) => e.getAttribute("data-value"),
803
+ renderHTML: (e) => e.stringValue === void 0 ? {} : { "data-value": e.stringValue }
804
+ } };
805
+ }
806
+ function L(e, t, n, r) {
807
+ return e.dom.setAttribute("data-style-type", t), r === "string" && e.dom.setAttribute("data-value", n), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
808
+ }
809
+ function ft(e, t) {
810
+ return {
811
+ config: e,
812
+ implementation: t
813
+ };
814
+ }
815
+ function R(e, t) {
816
+ return ft({
817
+ type: e.name,
818
+ propSchema: t
819
+ }, {
820
+ mark: e,
821
+ render(t, n) {
822
+ let r = n.pmSchema.marks[e.name].spec.toDOM;
823
+ if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
824
+ let i = n.pmSchema.mark(e.name, { stringValue: t }), a = re.renderSpec(document, r(i, !0));
825
+ if (typeof a != "object" || !("dom" in a)) throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.");
826
+ return a;
827
+ },
828
+ toExternalHTML(t, n) {
829
+ let r = n.pmSchema.marks[e.name].spec.toDOM;
830
+ if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
831
+ let i = n.pmSchema.mark(e.name, { stringValue: t }), a = re.renderSpec(document, r(i, !0));
832
+ if (typeof a != "object" || !("dom" in a)) throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.");
833
+ return a;
834
+ }
835
+ });
836
+ }
837
+ function pt(e) {
838
+ return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
839
+ }
840
+ //#endregion
841
+ //#region src/schema/styles/createSpec.ts
842
+ function mt(e, t) {
843
+ let n = [{
844
+ tag: `[data-style-type="${e.type}"]`,
845
+ contentElement: (e) => {
846
+ let t = e;
847
+ return t.matches("[data-editable]") ? t : t.querySelector("[data-editable]") || t;
848
+ }
849
+ }];
850
+ return t && n.push({
851
+ tag: "*",
852
+ consuming: !1,
853
+ getAttrs(e) {
854
+ if (typeof e == "string") return !1;
855
+ let n = t?.(e);
856
+ return n === void 0 ? !1 : { stringValue: n };
857
+ }
858
+ }), n;
859
+ }
860
+ function ht(e, t) {
861
+ let n = c.create({
862
+ name: e.type,
863
+ addAttributes() {
864
+ return dt(e.propSchema);
865
+ },
866
+ parseHTML() {
867
+ return mt(e, t.parse);
868
+ },
869
+ renderHTML({ mark: n }) {
870
+ return L((t.toExternalHTML || t.render)(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
871
+ },
872
+ addMarkView() {
873
+ return ({ mark: n }) => L(t.render(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
874
+ }
875
+ });
876
+ return ft(e, {
877
+ ...t,
878
+ mark: n,
879
+ render: (n) => L(t.render(n), e.type, n, e.propSchema),
880
+ toExternalHTML: (n) => L((t.toExternalHTML || t.render)(n), e.type, n, e.propSchema)
881
+ });
882
+ }
883
+ //#endregion
884
+ //#region src/util/topo-sort.ts
885
+ function gt(e) {
886
+ let t = vt(e), { roots: n, nonRoots: r } = yt(t), i = [];
887
+ for (; n.size;) {
888
+ i.push(n);
889
+ let r = /* @__PURE__ */ new Set();
890
+ for (let i of n) {
891
+ let n = e.get(i);
892
+ if (n) for (let e of n) {
893
+ let n = t.get(e);
894
+ if (n === void 0) continue;
895
+ let i = n - 1;
896
+ t.set(e, i), i === 0 && r.add(e);
897
+ }
898
+ }
899
+ n = r;
900
+ }
901
+ if (r = yt(t).nonRoots, r.size) throw Error(`Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(r).join(", ")}`);
902
+ return i;
903
+ }
904
+ function _t(e) {
905
+ return gt(bt(e));
906
+ }
907
+ function vt(e) {
908
+ let t = /* @__PURE__ */ new Map();
909
+ for (let [n, r] of e.entries()) {
910
+ t.has(n) || t.set(n, 0);
911
+ for (let e of r) {
912
+ let n = t.get(e) ?? 0;
913
+ t.set(e, n + 1);
914
+ }
915
+ }
916
+ return t;
917
+ }
918
+ function yt(e) {
919
+ let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
920
+ for (let [r, i] of e.entries()) i === 0 ? t.add(r) : n.add(r);
921
+ return {
922
+ roots: t,
923
+ nonRoots: n
924
+ };
925
+ }
926
+ function bt(e) {
927
+ let t = /* @__PURE__ */ new Map();
928
+ for (let [n, r] of e.entries()) {
929
+ t.has(n) || t.set(n, /* @__PURE__ */ new Set());
930
+ for (let e of r) t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(n);
931
+ }
932
+ return t;
933
+ }
934
+ function xt() {
935
+ return /* @__PURE__ */ new Map();
936
+ }
937
+ function St(e, t, n) {
938
+ return e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n), e;
939
+ }
940
+ function Ct(e) {
941
+ let t = xt();
942
+ for (let n of e) Array.isArray(n.runsBefore) && n.runsBefore.length > 0 ? n.runsBefore.forEach((e) => {
943
+ St(t, n.key, e);
944
+ }) : St(t, "default", n.key);
945
+ let n = _t(t), r = n.findIndex((e) => e.has("default"));
946
+ return (e) => 91 + (n.findIndex((t) => t.has(e)) + r) * 10;
947
+ }
948
+ //#endregion
949
+ //#region src/schema/schema.ts
950
+ function wt(e) {
951
+ return e && Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
952
+ }
953
+ var Tt = class {
954
+ BlockNoteEditor = "only for types";
955
+ Block = "only for types";
956
+ PartialBlock = "only for types";
957
+ inlineContentSpecs;
958
+ styleSpecs;
959
+ blockSpecs;
960
+ blockSchema;
961
+ inlineContentSchema;
962
+ styleSchema;
963
+ constructor(e) {
964
+ this.opts = e;
965
+ let { blockSpecs: t, inlineContentSpecs: n, styleSpecs: r, blockSchema: i, inlineContentSchema: a, styleSchema: o } = this.init();
966
+ this.blockSpecs = t, this.styleSpecs = r, this.styleSchema = o, this.inlineContentSpecs = n, this.blockSchema = i, this.inlineContentSchema = a;
967
+ }
968
+ init() {
969
+ let e = Ct(Object.entries({
970
+ ...this.opts.blockSpecs,
971
+ ...this.opts.inlineContentSpecs,
972
+ ...this.opts.styleSpecs
973
+ }).map(([e, t]) => ({
974
+ key: e,
975
+ runsBefore: t.implementation?.runsBefore ?? []
976
+ }))), t = Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([t, n]) => [t, Je(n.config, n.implementation, n.extensions, e(t))])), n = Object.fromEntries(Object.entries(this.opts.inlineContentSpecs).map(([t, n]) => typeof n.config == "object" ? [t, {
977
+ ...n,
978
+ implementation: {
979
+ ...n.implementation,
980
+ node: n.implementation?.node.extend({ priority: e(t) })
981
+ }
982
+ }] : [t, n])), r = Object.fromEntries(Object.entries(this.opts.styleSpecs).map(([t, n]) => [t, {
983
+ ...n,
984
+ implementation: {
985
+ ...n.implementation,
986
+ mark: n.implementation?.mark.extend({ priority: e(t) })
987
+ }
988
+ }]));
989
+ return {
990
+ blockSpecs: t,
991
+ blockSchema: Object.fromEntries(Object.entries(t).map(([e, t]) => [e, t.config])),
992
+ inlineContentSpecs: wt(n),
993
+ styleSpecs: wt(r),
994
+ inlineContentSchema: ut(n),
995
+ styleSchema: pt(r)
996
+ };
997
+ }
998
+ extend(e) {
999
+ Object.assign(this.opts.blockSpecs, e.blockSpecs), Object.assign(this.opts.inlineContentSpecs, e.inlineContentSpecs), Object.assign(this.opts.styleSpecs, e.styleSpecs);
1000
+ let { blockSpecs: t, inlineContentSpecs: n, styleSpecs: r, blockSchema: i, inlineContentSchema: a, styleSchema: o } = this.init();
1001
+ return this.blockSpecs = t, this.styleSpecs = r, this.styleSchema = o, this.inlineContentSpecs = n, this.blockSchema = i, this.inlineContentSchema = a, this;
1002
+ }
1003
+ };
1004
+ //#endregion
1005
+ //#region src/api/blockManipulation/tables/tables.ts
1006
+ function z(e) {
1007
+ let { height: t, width: n } = Et(e), r = Array(t).fill(!1).map(() => Array(n).fill(null)), i = (e, i) => {
1008
+ for (let a = e; a < t; a++) for (let e = i; e < n; e++) if (!r[a][e]) return {
1009
+ row: a,
1010
+ col: e
1011
+ };
1012
+ throw Error("Unable to create occupancy grid for table, no more available cells");
1013
+ };
1014
+ for (let t = 0; t < e.content.rows.length; t++) for (let n = 0; n < e.content.rows[t].cells.length; n++) {
1015
+ let a = Me(e.content.rows[t].cells[n]), o = Pe(a), s = x(a), { row: c, col: l } = i(t, n);
1016
+ for (let e = c; e < c + o; e++) for (let i = l; i < l + s; i++) {
1017
+ if (r[e][i]) throw Error(`Unable to create occupancy grid for table, cell at ${e},${i} is already occupied`);
1018
+ r[e][i] = {
1019
+ row: t,
1020
+ col: n,
1021
+ rowspan: o,
1022
+ colspan: s,
1023
+ cell: a
1024
+ };
1025
+ }
1026
+ }
1027
+ return r;
1028
+ }
1029
+ function B(e) {
1030
+ let t = /* @__PURE__ */ new Set();
1031
+ return e.map((e) => ({ cells: e.map((e) => t.has(e.row + ":" + e.col) ? !1 : (t.add(e.row + ":" + e.col), e.cell)).filter((e) => e !== !1) }));
1032
+ }
1033
+ function V(e, t, n = z(t)) {
1034
+ for (let t = 0; t < n.length; t++) for (let r = 0; r < n[t].length; r++) {
1035
+ let i = n[t][r];
1036
+ if (i && i.row === e.row && i.col === e.col) return {
1037
+ row: t,
1038
+ col: r,
1039
+ cell: i.cell
1040
+ };
1041
+ }
1042
+ throw Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`);
1043
+ }
1044
+ function Et(e) {
1045
+ let t = e.content.rows.length, n = 0;
1046
+ return e.content.rows.forEach((e) => {
1047
+ let t = 0;
1048
+ e.cells.forEach((e) => {
1049
+ t += x(e);
1050
+ }), n = Math.max(n, t);
1051
+ }), {
1052
+ height: t,
1053
+ width: n
1054
+ };
1055
+ }
1056
+ function Dt(e, t, n = z(t)) {
1057
+ let r = n[e.row]?.[e.col];
1058
+ if (r) return {
1059
+ row: r.row,
1060
+ col: r.col,
1061
+ cell: r.cell
1062
+ };
1063
+ }
1064
+ function Ot(e, t) {
1065
+ let n = z(e);
1066
+ if (t < 0 || t >= n.length) return [];
1067
+ let r = 0;
1068
+ for (let e = 0; e < t; e++) {
1069
+ let e = n[r]?.[0];
1070
+ if (!e) return [];
1071
+ r += e.rowspan;
1072
+ }
1073
+ let i = Array(n[0].length).fill(!1).map((t, i) => Dt({
1074
+ row: r,
1075
+ col: i
1076
+ }, e, n)).filter((e) => e !== void 0);
1077
+ return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
1078
+ }
1079
+ function kt(e, t) {
1080
+ let n = z(e);
1081
+ if (t < 0 || t >= n[0].length) return [];
1082
+ let r = 0;
1083
+ for (let e = 0; e < t; e++) {
1084
+ let e = n[0]?.[r];
1085
+ if (!e) return [];
1086
+ r += e.colspan;
1087
+ }
1088
+ let i = Array(n.length).fill(!1).map((t, i) => Dt({
1089
+ row: i,
1090
+ col: r
1091
+ }, e, n)).filter((e) => e !== void 0);
1092
+ return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
1093
+ }
1094
+ function At(e, t, n, r = z(e)) {
1095
+ let { col: i } = V({
1096
+ row: 0,
1097
+ col: t
1098
+ }, e, r), { col: a } = V({
1099
+ row: 0,
1100
+ col: n
1101
+ }, e, r);
1102
+ return r.forEach((e) => {
1103
+ let [t] = e.splice(i, 1);
1104
+ e.splice(a, 0, t);
1105
+ }), B(r);
1106
+ }
1107
+ function jt(e, t, n, r = z(e)) {
1108
+ let { row: i } = V({
1109
+ row: t,
1110
+ col: 0
1111
+ }, e, r), { row: a } = V({
1112
+ row: n,
1113
+ col: 0
1114
+ }, e, r), [o] = r.splice(i, 1);
1115
+ return r.splice(a, 0, o), B(r);
1116
+ }
1117
+ function Mt(e) {
1118
+ return e ? b(e) ? Mt(e.content) : typeof e == "string" ? e.length === 0 : Array.isArray(e) ? e.every((e) => typeof e == "string" ? e.length === 0 : y(e) ? e.text.length === 0 : je(e) ? typeof e.content == "string" ? e.content.length === 0 : e.content.every((e) => e.text.length === 0) : !1) : !1 : !0;
1119
+ }
1120
+ function Nt(e, t, n = z(e)) {
1121
+ if (t === "columns") {
1122
+ let e = 0;
1123
+ for (let t = n[0].length - 1; t >= 0 && n.every((e) => Mt(e[t].cell) && e[t].colspan === 1); t--) e++;
1124
+ for (let t = n.length - 1; t >= 0; t--) {
1125
+ let r = Math.max(n[t].length - e, 1);
1126
+ n[t] = n[t].slice(0, r);
1127
+ }
1128
+ return B(n);
1129
+ }
1130
+ let r = 0;
1131
+ for (let e = n.length - 1; e >= 0 && n[e].every((e) => Mt(e.cell) && e.rowspan === 1); e--) r++;
1132
+ let i = Math.min(r, n.length - 1);
1133
+ return n.splice(n.length - i, i), B(n);
1134
+ }
1135
+ function Pt(e, t, n, r = z(e)) {
1136
+ let { width: i, height: a } = Et(e);
1137
+ if (t === "columns") r.forEach((e, t) => {
1138
+ if (n >= 0) for (let r = 0; r < n; r++) e.push({
1139
+ row: t,
1140
+ col: Math.max(...e.map((e) => e.col)) + 1,
1141
+ rowspan: 1,
1142
+ colspan: 1,
1143
+ cell: Me("")
1144
+ });
1145
+ else e.splice(i + n, -1 * n);
1146
+ });
1147
+ else if (n > 0) for (let e = 0; e < n; e++) {
1148
+ let t = Array(i).fill(null).map((t, n) => ({
1149
+ row: a + e,
1150
+ col: n,
1151
+ rowspan: 1,
1152
+ colspan: 1,
1153
+ cell: Me("")
1154
+ }));
1155
+ r.push(t);
1156
+ }
1157
+ else n < 0 && r.splice(a + n, -1 * n);
1158
+ return B(r);
1159
+ }
1160
+ function Ft(e, t, n) {
1161
+ let r = Ot(e, n);
1162
+ if (!r.some((e) => Pe(e.cell) > 1)) return !0;
1163
+ let i = n, a = n;
1164
+ return r.forEach((e) => {
1165
+ let t = Pe(e.cell);
1166
+ i = Math.max(i, e.row + t - 1), a = Math.min(a, e.row);
1167
+ }), t < n ? n === i : n === a;
1168
+ }
1169
+ function It(e, t, n) {
1170
+ let r = kt(e, n);
1171
+ if (!r.some((e) => x(e.cell) > 1)) return !0;
1172
+ let i = n, a = n;
1173
+ return r.forEach((e) => {
1174
+ let t = x(e.cell);
1175
+ i = Math.max(i, e.col + t - 1), a = Math.min(a, e.col);
1176
+ }), t < n ? n === i : n === a;
1177
+ }
1178
+ function Lt(e, t, n) {
1179
+ let r = V(e, n), i = V(t, n);
1180
+ return r.col === i.col;
1181
+ }
1182
+ //#endregion
1183
+ //#region src/api/nodeConversions/blockToNode.ts
1184
+ function Rt(e, t, n, r) {
1185
+ let i = [];
1186
+ for (let [r, a] of Object.entries(e.styles || {})) {
1187
+ let e = n[r];
1188
+ if (!e) throw Error(`style ${r} not found in styleSchema`);
1189
+ if (e.propSchema === "boolean") a && i.push(t.mark(r));
1190
+ else if (e.propSchema === "string") a && i.push(t.mark(r, { stringValue: a }));
1191
+ else throw new S(e.propSchema);
1192
+ }
1193
+ return !r || !t.nodes[r].spec.code ? e.text.split(/(\n)/g).filter((e) => e.length > 0).map((e) => e === "\n" ? t.nodes.hardBreak.createChecked() : t.text(e, i)) : e.text.length > 0 ? [t.text(e.text, i)] : [];
1194
+ }
1195
+ function zt(e, t, n) {
1196
+ let r = t.marks.link.create({ href: e.href });
1197
+ return Bt(e.content, t, n).map((e) => {
1198
+ if (e.type.name === "text") return e.mark([...e.marks, r]);
1199
+ if (e.type.name === "hardBreak") return e;
1200
+ throw Error("unexpected node type");
1201
+ });
1202
+ }
1203
+ function Bt(e, t, n, r) {
1204
+ let i = [];
1205
+ if (typeof e == "string") return i.push(...Rt({
1206
+ type: "text",
1207
+ text: e,
1208
+ styles: {}
1209
+ }, t, n, r)), i;
1210
+ for (let a of e) i.push(...Rt(a, t, n, r));
1211
+ return i;
1212
+ }
1213
+ function H(e, t, n, r = P(t)) {
1214
+ let i = [];
1215
+ for (let a of e) typeof a == "string" ? i.push(...Bt(a, t, r, n)) : je(a) ? i.push(...zt(a, t, r)) : y(a) ? i.push(...Bt([a], t, r, n)) : i.push(Ht(a, t, r));
1216
+ return i;
1217
+ }
1218
+ function Vt(e, t, n = P(t)) {
1219
+ let r = [], i = Array(e.headerRows ?? 0).fill(!0), a = Array(e.headerCols ?? 0).fill(!0), o = e.columnWidths ?? [];
1220
+ for (let s = 0; s < e.rows.length; s++) {
1221
+ let c = e.rows[s], l = [], u = i[s];
1222
+ for (let r = 0; r < c.cells.length; r++) {
1223
+ let i = c.cells[r], d = a[r], f = null, p = V({
1224
+ row: s,
1225
+ col: r
1226
+ }, {
1227
+ type: "table",
1228
+ content: e
1229
+ }), m = o[p.col] ? [o[p.col]] : null;
1230
+ if (i) if (typeof i == "string") f = t.text(i);
1231
+ else if (b(i)) {
1232
+ i.content && (f = H(i.content, t, "tableParagraph", n));
1233
+ let e = x(i);
1234
+ e > 1 && (m = Array(e).fill(!1).map((e, t) => o[p.col + t] ?? void 0));
1235
+ } else f = H(i, t, "tableParagraph", n);
1236
+ let h = t.nodes[d || u ? "tableHeader" : "tableCell"].createChecked({
1237
+ ...b(i) ? i.props : {},
1238
+ colwidth: m
1239
+ }, t.nodes.tableParagraph.createChecked(void 0, f));
1240
+ l.push(h);
1241
+ }
1242
+ let d = t.nodes.tableRow.createChecked({}, l);
1243
+ r.push(d);
1244
+ }
1245
+ return r;
1246
+ }
1247
+ function Ht(e, t, n) {
1248
+ let r, i = e.type;
1249
+ if (i === void 0 && (i = "paragraph"), !t.nodes[i]) throw Error(`node type ${i} not found in schema`);
1250
+ if (!e.content) r = t.nodes[i].createChecked(e.props);
1251
+ else if (typeof e.content == "string") {
1252
+ let a = H([e.content], t, i, n);
1253
+ r = t.nodes[i].createChecked(e.props, a);
1254
+ } else if (Array.isArray(e.content)) {
1255
+ let a = H(e.content, t, i, n);
1256
+ r = t.nodes[i].createChecked(e.props, a);
1257
+ } else if (e.content.type === "tableContent") {
1258
+ let a = Vt(e.content, t, n);
1259
+ r = t.nodes[i].createChecked(e.props, a);
1260
+ } else throw new S(e.content.type);
1261
+ return r;
1262
+ }
1263
+ function U(e, t, n = P(t)) {
1264
+ let r = e.id;
1265
+ r === void 0 && (r = ke.options.generateID());
1266
+ let i = [];
1267
+ if (e.children) for (let r of e.children) i.push(U(r, t, n));
1268
+ if (!e.type || t.nodes[e.type].isInGroup("blockContent")) {
1269
+ let a = Ht(e, t, n), o = i.length > 0 ? t.nodes.blockGroup.createChecked({}, i) : void 0;
1270
+ return t.nodes.blockContainer.createChecked({
1271
+ id: r,
1272
+ ...e.props
1273
+ }, o ? [a, o] : a);
1274
+ } else if (t.nodes[e.type].isInGroup("bnBlock")) return t.nodes[e.type].createChecked({
1275
+ id: r,
1276
+ ...e.props
1277
+ }, i);
1278
+ else throw Error(`block type ${e.type} doesn't match blockContent or bnBlock group`);
1279
+ }
1280
+ //#endregion
1281
+ //#region src/api/nodeUtil.ts
1282
+ function Ut(e, t) {
1283
+ let n, r;
1284
+ if (t.firstChild.descendants((t, i) => n ? !1 : !Wt(t) || t.attrs.id !== e ? !0 : (n = t, r = i + 1, !1)), !(n === void 0 || r === void 0)) return {
1285
+ node: n,
1286
+ posBeforeNode: r
1287
+ };
1288
+ }
1289
+ function Wt(e) {
1290
+ return e.type.isInGroup("bnBlock");
1291
+ }
1292
+ //#endregion
1293
+ //#region src/api/blockManipulation/commands/updateBlock/updateBlock.ts
1294
+ var Gt = (e, t) => ({ tr: n, dispatch: r }) => (r && W(n, e, t), !0);
1295
+ function W(e, t, n, r, i) {
1296
+ let a = Ze(e.doc.resolve(t)), o = null;
1297
+ a.blockNoteType === "table" && (o = Yt(e));
1298
+ let s = A(e);
1299
+ if (r !== void 0 && i !== void 0 && r > i) throw Error("Invalid replaceFromPos or replaceToPos");
1300
+ let c = s.nodes[a.blockNoteType], l = s.nodes[n.type || a.blockNoteType], u = l.isInGroup("bnBlock") ? l : s.nodes.blockContainer;
1301
+ if (a.isBlockContainer && l.isInGroup("blockContent")) {
1302
+ let t = r !== void 0 && r > a.blockContent.beforePos && r < a.blockContent.afterPos ? r - a.blockContent.beforePos - 1 : void 0, o = i !== void 0 && i > a.blockContent.beforePos && i < a.blockContent.afterPos ? i - a.blockContent.beforePos - 1 : void 0;
1303
+ qt(n, e, a), Kt(n, e, c, l, a, t, o);
1304
+ } else if (!a.isBlockContainer && l.isInGroup("bnBlock")) qt(n, e, a);
1305
+ else {
1306
+ let t = I(a.bnBlock.node, s);
1307
+ e.replaceWith(a.bnBlock.beforePos, a.bnBlock.afterPos, U({
1308
+ children: t.children,
1309
+ ...n
1310
+ }, s));
1311
+ return;
1312
+ }
1313
+ e.setNodeMarkup(a.bnBlock.beforePos, u, {
1314
+ ...a.bnBlock.node.attrs,
1315
+ ...n.props
1316
+ }), o && Xt(e, a, o);
1317
+ }
1318
+ function Kt(e, t, n, a, o, s, c) {
1319
+ let l = A(t), u = "keep";
1320
+ if (e.content) if (typeof e.content == "string") u = H([e.content], l, a.name);
1321
+ else if (Array.isArray(e.content)) u = H(e.content, l, a.name);
1322
+ else if (e.content.type === "tableContent") u = Vt(e.content, l);
1323
+ else throw new S(e.content.type);
1324
+ else n.spec.content === "" || a.spec.content !== n.spec.content && (u = []);
1325
+ if (u === "keep") t.setNodeMarkup(o.blockContent.beforePos, a, {
1326
+ ...o.blockContent.node.attrs,
1327
+ ...e.props
1328
+ });
1329
+ else if (s !== void 0 || c !== void 0) {
1330
+ t.setNodeMarkup(o.blockContent.beforePos, a, {
1331
+ ...o.blockContent.node.attrs,
1332
+ ...e.props
1333
+ });
1334
+ let n = o.blockContent.beforePos + 1 + (s ?? 0), l = o.blockContent.beforePos + 1 + (c ?? o.blockContent.node.content.size), d = t.doc.resolve(o.blockContent.beforePos).depth, f = t.doc.resolve(n).depth, p = t.doc.resolve(l).depth;
1335
+ t.replace(n, l, new i(r.from(u), f - d - 1, p - d - 1));
1336
+ } else t.replaceWith(o.blockContent.beforePos, o.blockContent.afterPos, a.createChecked({
1337
+ ...o.blockContent.node.attrs,
1338
+ ...e.props
1339
+ }, u));
1340
+ }
1341
+ function qt(e, t, n) {
1342
+ let a = A(t);
1343
+ if (e.children !== void 0 && e.children.length > 0) {
1344
+ let s = e.children.map((e) => U(e, a));
1345
+ if (n.childContainer) t.step(new o(n.childContainer.beforePos + 1, n.childContainer.afterPos - 1, new i(r.from(s), 0, 0)));
1346
+ else {
1347
+ if (!n.isBlockContainer) throw Error("impossible");
1348
+ t.insert(n.blockContent.afterPos, a.nodes.blockGroup.createChecked({}, s));
1349
+ }
1350
+ }
1351
+ }
1352
+ function Jt(e, t, n, r, i) {
1353
+ let a = typeof t == "string" ? t : t.id, o = Ut(a, e.doc);
1354
+ if (!o) throw Error(`Block with ID ${a} not found`);
1355
+ return W(e, o.posBeforeNode, n, r, i), I(e.doc.resolve(o.posBeforeNode + 1).node(), A(e));
1356
+ }
1357
+ function Yt(e) {
1358
+ let t = "selection" in e ? e.selection : null;
1359
+ if (!(t instanceof ee)) return null;
1360
+ let n = e.doc.resolve(t.head), r = -1, i = -1;
1361
+ for (let e = n.depth; e >= 0; e--) {
1362
+ let t = n.node(e).type.name;
1363
+ if (r < 0 && (t === "tableCell" || t === "tableHeader") && (r = e), t === "table") {
1364
+ i = e;
1365
+ break;
1366
+ }
1367
+ }
1368
+ if (r < 0 || i < 0) return null;
1369
+ let a = n.before(r), o = n.before(i), s = e.doc.nodeAt(o);
1370
+ if (!s || s.type.name !== "table") return null;
1371
+ let c = oe.get(s), l = a - (o + 1), u = c.map.indexOf(l);
1372
+ if (u < 0) return null;
1373
+ let d = Math.floor(u / c.width), f = u % c.width, p = a + 1 + 1;
1374
+ return {
1375
+ row: d,
1376
+ col: f,
1377
+ offset: Math.max(0, t.head - p)
1378
+ };
1379
+ }
1380
+ function Xt(e, t, n) {
1381
+ if (t.blockNoteType !== "table") return !1;
1382
+ let r = -1;
1383
+ if (t.isBlockContainer) r = e.mapping.map(t.blockContent.beforePos);
1384
+ else {
1385
+ let n = e.mapping.map(t.bnBlock.beforePos), i = n + (e.doc.nodeAt(n)?.nodeSize || 0);
1386
+ e.doc.nodesBetween(n, i, (e, t) => e.type.name === "table" ? (r = t, !1) : !0);
1387
+ }
1388
+ let i = r >= 0 ? e.doc.nodeAt(r) : null;
1389
+ if (!i || i.type.name !== "table") return !1;
1390
+ let a = oe.get(i), o = Math.max(0, Math.min(n.row, a.height - 1)), s = Math.max(0, Math.min(n.col, a.width - 1)), c = o * a.width + s, l = a.map[c];
1391
+ if (l == null) return !1;
1392
+ let u = r + 1 + l + 1, d = e.doc.nodeAt(u), f = u + 1, p = d ? d.content.size : 0, m = f + Math.max(0, Math.min(n.offset, p));
1393
+ return "selection" in e && e.setSelection(ee.create(e.doc, m)), !0;
1394
+ }
1395
+ //#endregion
1396
+ //#region src/editor/defaultColors.ts
1397
+ var G = {
1398
+ gray: {
1399
+ text: "#9b9a97",
1400
+ background: "#ebeced"
1401
+ },
1402
+ brown: {
1403
+ text: "#64473a",
1404
+ background: "#e9e5e3"
1405
+ },
1406
+ red: {
1407
+ text: "#e03e3e",
1408
+ background: "#fbe4e4"
1409
+ },
1410
+ orange: {
1411
+ text: "#d9730d",
1412
+ background: "#f6e9d9"
1413
+ },
1414
+ yellow: {
1415
+ text: "#dfab01",
1416
+ background: "#fbf3db"
1417
+ },
1418
+ green: {
1419
+ text: "#4d6461",
1420
+ background: "#ddedea"
1421
+ },
1422
+ blue: {
1423
+ text: "#0b6e99",
1424
+ background: "#ddebf1"
1425
+ },
1426
+ purple: {
1427
+ text: "#6940a5",
1428
+ background: "#eae4f2"
1429
+ },
1430
+ pink: {
1431
+ text: "#ad1a72",
1432
+ background: "#f4dfeb"
1433
+ }
1434
+ }, Zt = {
1435
+ gray: {
1436
+ text: "#bebdb8",
1437
+ background: "#9b9a97"
1438
+ },
1439
+ brown: {
1440
+ text: "#8e6552",
1441
+ background: "#64473a"
1442
+ },
1443
+ red: {
1444
+ text: "#ec4040",
1445
+ background: "#be3434"
1446
+ },
1447
+ orange: {
1448
+ text: "#e3790d",
1449
+ background: "#b7600a"
1450
+ },
1451
+ yellow: {
1452
+ text: "#dfab01",
1453
+ background: "#b58b00"
1454
+ },
1455
+ green: {
1456
+ text: "#6b8b87",
1457
+ background: "#4d6461"
1458
+ },
1459
+ blue: {
1460
+ text: "#0e87bc",
1461
+ background: "#0b6e99"
1462
+ },
1463
+ purple: {
1464
+ text: "#8552d7",
1465
+ background: "#6940a5"
1466
+ },
1467
+ pink: {
1468
+ text: "#da208f",
1469
+ background: "#ad1a72"
1470
+ }
1471
+ }, K = {
1472
+ backgroundColor: { default: "default" },
1473
+ textColor: { default: "default" },
1474
+ textAlignment: {
1475
+ default: "left",
1476
+ values: [
1477
+ "left",
1478
+ "center",
1479
+ "right",
1480
+ "justify"
1481
+ ]
1482
+ }
1483
+ }, q = (e) => {
1484
+ let t = {};
1485
+ return e.hasAttribute("data-background-color") ? t.backgroundColor = e.getAttribute("data-background-color") : e.style.backgroundColor && (t.backgroundColor = e.style.backgroundColor), e.hasAttribute("data-text-color") ? t.textColor = e.getAttribute("data-text-color") : e.style.color && (t.textColor = e.style.color), t.textAlignment = K.textAlignment.values.includes(e.style.textAlign) ? e.style.textAlign : void 0, t;
1486
+ }, J = (e, t) => {
1487
+ e.backgroundColor && e.backgroundColor !== K.backgroundColor.default && (t.style.backgroundColor = e.backgroundColor in G ? G[e.backgroundColor].background : e.backgroundColor), e.textColor && e.textColor !== K.textColor.default && (t.style.color = e.textColor in G ? G[e.textColor].text : e.textColor), e.textAlignment && e.textAlignment !== K.textAlignment.default && (t.style.textAlign = e.textAlignment);
1488
+ }, Qt = (e = "backgroundColor") => ({
1489
+ default: K.backgroundColor.default,
1490
+ parseHTML: (e) => e.hasAttribute("data-background-color") ? e.getAttribute("data-background-color") : e.style.backgroundColor ? e.style.backgroundColor : K.backgroundColor.default,
1491
+ renderHTML: (t) => t[e] === K.backgroundColor.default ? {} : { "data-background-color": t[e] }
1492
+ }), $t = (e = "textColor") => ({
1493
+ default: K.textColor.default,
1494
+ parseHTML: (e) => e.hasAttribute("data-text-color") ? e.getAttribute("data-text-color") : e.style.color ? e.style.color : K.textColor.default,
1495
+ renderHTML: (t) => t[e] === K.textColor.default ? {} : { "data-text-color": t[e] }
1496
+ }), en = (e = "textAlignment") => ({
1497
+ default: K.textAlignment.default,
1498
+ parseHTML: (e) => e.hasAttribute("data-text-alignment") ? e.getAttribute("data-text-alignment") : e.style.textAlign ? e.style.textAlign : K.textAlignment.default,
1499
+ renderHTML: (t) => t[e] === K.textAlignment.default ? {} : { "data-text-alignment": t[e] }
1500
+ }), tn = (e, t) => {
1501
+ let n = e.querySelector(t);
1502
+ if (n) return {
1503
+ targetElement: n,
1504
+ caption: e.querySelector("figcaption")?.textContent ?? void 0
1505
+ };
1506
+ }, Y = t(({ editor: t }) => {
1507
+ let n = e(void 0);
1508
+ function r() {
1509
+ n.setState(void 0);
1510
+ }
1511
+ return {
1512
+ key: "filePanel",
1513
+ store: n,
1514
+ mount({ signal: e }) {
1515
+ let n = t.onChange(r, !1), i = t.onSelectionChange(r, !1);
1516
+ e.addEventListener("abort", () => {
1517
+ n(), i();
1518
+ });
1519
+ },
1520
+ closeMenu: r,
1521
+ showMenu(e) {
1522
+ n.setState(e);
1523
+ }
1524
+ };
1525
+ }), nn = (e, t, n) => {
1526
+ let r = document.createElement("div");
1527
+ r.className = "bn-add-file-button";
1528
+ let i = document.createElement("div");
1529
+ i.className = "bn-add-file-button-icon", n ? i.appendChild(n) : i.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z\"></path></svg>", r.appendChild(i);
1530
+ let a = document.createElement("p");
1531
+ a.className = "bn-add-file-button-text", a.innerHTML = e.type in t.dictionary.file_blocks.add_button_text ? t.dictionary.file_blocks.add_button_text[e.type] : t.dictionary.file_blocks.add_button_text.file, r.appendChild(a);
1532
+ let o = (e) => {
1533
+ e.preventDefault(), e.stopPropagation();
1534
+ }, s = () => {
1535
+ t.isEditable && t.getExtension(Y)?.showMenu(e.id);
1536
+ };
1537
+ return r.addEventListener("mousedown", o, !0), r.addEventListener("click", s, !0), {
1538
+ dom: r,
1539
+ destroy: () => {
1540
+ r.removeEventListener("mousedown", o, !0), r.removeEventListener("click", s, !0);
1541
+ }
1542
+ };
1543
+ }, rn = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z\"></path></svg>", an = (e) => {
1544
+ let t = document.createElement("div");
1545
+ t.className = "bn-file-name-with-icon";
1546
+ let n = document.createElement("div");
1547
+ n.className = "bn-file-icon", n.innerHTML = rn, t.appendChild(n);
1548
+ let r = document.createElement("p");
1549
+ return r.className = "bn-file-name", r.textContent = e.props.name, t.appendChild(r), { dom: t };
1550
+ }, on = (e, t, n, r) => {
1551
+ let i = document.createElement("div");
1552
+ if (i.className = "bn-file-block-content-wrapper", e.props.url === "") {
1553
+ let n = nn(e, t, r);
1554
+ i.appendChild(n.dom);
1555
+ let a = t.onUploadStart((t) => {
1556
+ if (t === e.id) {
1557
+ i.removeChild(n.dom);
1558
+ let e = document.createElement("div");
1559
+ e.className = "bn-file-loading-preview", e.textContent = "Loading...", i.appendChild(e);
1560
+ }
1561
+ });
1562
+ return {
1563
+ dom: i,
1564
+ destroy: () => {
1565
+ a(), n.destroy();
1566
+ }
1567
+ };
1568
+ }
1569
+ let a = { dom: i };
1570
+ if (e.props.showPreview === !1 || !n) {
1571
+ let t = an(e);
1572
+ i.appendChild(t.dom), a.destroy = () => {
1573
+ t.destroy?.();
1574
+ };
1575
+ } else i.appendChild(n.dom);
1576
+ if (e.props.caption) {
1577
+ let t = document.createElement("p");
1578
+ t.className = "bn-file-caption", t.textContent = e.props.caption, i.appendChild(t);
1579
+ }
1580
+ return a;
1581
+ }, sn = (e, t) => {
1582
+ let n = document.createElement("figure"), r = document.createElement("figcaption");
1583
+ return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
1584
+ }, X = (e, t) => {
1585
+ let n = document.createElement("div"), r = document.createElement("p");
1586
+ return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
1587
+ }, cn = (e) => ({ url: e.src || void 0 }), ln = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z\"></path></svg>", un = D((e) => ({
1588
+ type: "audio",
1589
+ propSchema: {
1590
+ backgroundColor: K.backgroundColor,
1591
+ name: { default: "" },
1592
+ url: { default: "" },
1593
+ caption: { default: "" },
1594
+ showPreview: { default: !0 }
1595
+ },
1596
+ content: "none"
1597
+ })), dn = (e = {}) => (e) => {
1598
+ if (e.tagName === "AUDIO") {
1599
+ if (e.closest("figure")) return;
1600
+ let { backgroundColor: t } = q(e);
1601
+ return {
1602
+ ...cn(e),
1603
+ backgroundColor: t
1604
+ };
1605
+ }
1606
+ if (e.tagName === "FIGURE") {
1607
+ let t = tn(e, "audio");
1608
+ if (!t) return;
1609
+ let { targetElement: n, caption: r } = t, { backgroundColor: i } = q(e);
1610
+ return {
1611
+ ...cn(n),
1612
+ backgroundColor: i,
1613
+ caption: r
1614
+ };
1615
+ }
1616
+ }, fn = (e = {}) => (t, n) => {
1617
+ let r = document.createElement("div");
1618
+ r.innerHTML = e.icon ?? "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z\"></path></svg>";
1619
+ let i = document.createElement("audio");
1620
+ return i.className = "bn-audio", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
1621
+ i.src = e;
1622
+ }) : i.src = t.props.url, i.controls = !0, i.contentEditable = "false", i.draggable = !1, on(t, n, { dom: i }, r.firstElementChild);
1623
+ }, pn = (e = {}) => (e, t) => {
1624
+ if (!e.props.url) {
1625
+ let e = document.createElement("p");
1626
+ return e.textContent = "Add audio", { dom: e };
1627
+ }
1628
+ let n;
1629
+ return e.props.showPreview ? (n = document.createElement("audio"), n.src = e.props.url) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? sn(n, e.props.caption) : X(n, e.props.caption) : { dom: n };
1630
+ }, mn = O(un, (e) => ({
1631
+ meta: { fileBlockAccept: ["audio/*"] },
1632
+ parse: dn(e),
1633
+ render: fn(e),
1634
+ toExternalHTML: pn(e),
1635
+ runsBefore: ["file"]
1636
+ })), hn = Symbol.for("blocknote.shikiParser"), gn = Symbol.for("blocknote.shikiHighlighterPromise");
1637
+ function _n(e) {
1638
+ let t = globalThis, n, r, i = !1;
1639
+ return de({
1640
+ parser: (a) => {
1641
+ if (!e.createHighlighter) return process.env.NODE_ENV === "development" && !i && (console.log("For syntax highlighting of code blocks, you must provide a `createCodeBlockSpec({ createHighlighter: () => ... })` function"), i = !0), [];
1642
+ if (!n) return t[gn] = t[gn] || e.createHighlighter(), t[gn].then((e) => {
1643
+ n = e;
1644
+ });
1645
+ let o = bn(e, a.language);
1646
+ return !o || o === "text" || o === "none" || o === "plaintext" || o === "txt" ? [] : n.getLoadedLanguages().includes(o) ? (r || (r = t[hn] || fe(n), t[hn] = r), r(a)) : n.loadLanguage(o);
1647
+ },
1648
+ languageExtractor: (e) => e.attrs.language,
1649
+ nodeTypes: ["codeBlock"]
1650
+ });
1651
+ }
1652
+ //#endregion
1653
+ //#region src/blocks/Code/block.ts
1654
+ var vn = D(({ defaultLanguage: e = "text" }) => ({
1655
+ type: "codeBlock",
1656
+ propSchema: { language: { default: e } },
1657
+ content: "inline"
1658
+ })), yn = O(vn, (e) => ({
1659
+ meta: {
1660
+ code: !0,
1661
+ defining: !0,
1662
+ isolating: !1
1663
+ },
1664
+ parse: (e) => {
1665
+ if (e.tagName !== "PRE" || e.childElementCount !== 1 || e.firstElementChild?.tagName !== "CODE") return;
1666
+ let t = e.firstElementChild;
1667
+ return { language: t.getAttribute("data-language") || t.className.split(" ").find((e) => e.includes("language-"))?.replace("language-", "") };
1668
+ },
1669
+ parseContent: ({ el: e, schema: t }) => {
1670
+ let n = ne.fromSchema(t), r = e.firstElementChild;
1671
+ return n.parse(r, {
1672
+ preserveWhitespace: "full",
1673
+ topNode: t.nodes.codeBlock.create()
1674
+ }).content;
1675
+ },
1676
+ render(t, n) {
1677
+ let r = document.createDocumentFragment(), i = document.createElement("pre"), a = document.createElement("code");
1678
+ i.appendChild(a);
1679
+ let o;
1680
+ if (e.supportedLanguages) {
1681
+ let i = document.createElement("select");
1682
+ if (Object.entries(e.supportedLanguages ?? {}).forEach(([e, { name: t }]) => {
1683
+ let n = document.createElement("option");
1684
+ n.value = e, n.text = t, i.appendChild(n);
1685
+ }), i.value = t.props.language || e.defaultLanguage || "text", n.isEditable) {
1686
+ let e = (e) => {
1687
+ let r = e.target.value;
1688
+ n.updateBlock(t.id, { props: { language: r } });
1689
+ };
1690
+ i.addEventListener("change", e), o = () => i.removeEventListener("change", e);
1691
+ } else i.disabled = !0;
1692
+ let a = document.createElement("div");
1693
+ a.contentEditable = "false", a.appendChild(i), r.appendChild(a);
1694
+ }
1695
+ return r.appendChild(i), {
1696
+ dom: r,
1697
+ contentDOM: a,
1698
+ destroy: () => {
1699
+ o?.();
1700
+ }
1701
+ };
1702
+ },
1703
+ toExternalHTML(e) {
1704
+ let t = document.createElement("pre"), n = document.createElement("code");
1705
+ return n.className = `language-${e.props.language}`, n.dataset.language = e.props.language, t.appendChild(n), {
1706
+ dom: t,
1707
+ contentDOM: n
1708
+ };
1709
+ }
1710
+ }), (e) => [t({
1711
+ key: "code-block-highlighter",
1712
+ prosemirrorPlugins: [_n(e)]
1713
+ }), t({
1714
+ key: "code-block-keyboard-shortcuts",
1715
+ keyboardShortcuts: {
1716
+ Delete: ({ editor: e }) => e.transact((t) => {
1717
+ let { block: n } = e.getTextCursorPosition();
1718
+ if (n.type !== "codeBlock") return !1;
1719
+ let { $from: r } = t.selection;
1720
+ return r.parent.textContent ? !1 : (e.removeBlocks([n]), !0);
1721
+ }),
1722
+ Tab: ({ editor: t }) => e.indentLineWithTab === !1 ? !1 : t.transact((e) => {
1723
+ let { block: n } = t.getTextCursorPosition();
1724
+ return n.type === "codeBlock" ? (e.insertText(" "), !0) : !1;
1725
+ }),
1726
+ Enter: ({ editor: e }) => e.transact((t) => {
1727
+ let { block: n, nextBlock: r } = e.getTextCursorPosition();
1728
+ if (n.type !== "codeBlock") return !1;
1729
+ let { $from: i } = t.selection, a = i.parentOffset === i.parent.nodeSize - 2, o = i.parent.textContent.endsWith("\n\n");
1730
+ if (a && o) {
1731
+ if (t.delete(i.pos - 2, i.pos), r) return e.setTextCursorPosition(r, "start"), !0;
1732
+ let [a] = e.insertBlocks([{ type: "paragraph" }], n, "after");
1733
+ return e.setTextCursorPosition(a, "start"), !0;
1734
+ }
1735
+ return t.insertText("\n"), !0;
1736
+ }),
1737
+ "Shift-Enter": ({ editor: e }) => e.transact(() => {
1738
+ let { block: t } = e.getTextCursorPosition();
1739
+ if (t.type !== "codeBlock") return !1;
1740
+ let [n] = e.insertBlocks([{ type: "paragraph" }], t, "after");
1741
+ return e.setTextCursorPosition(n, "start"), !0;
1742
+ })
1743
+ },
1744
+ inputRules: [{
1745
+ find: /^```(.*?)\s$/,
1746
+ replace: ({ match: t }) => {
1747
+ let n = t[1].trim();
1748
+ return {
1749
+ type: "codeBlock",
1750
+ props: { language: { language: bn(e, n) ?? n }.language },
1751
+ content: []
1752
+ };
1753
+ }
1754
+ }]
1755
+ })]);
1756
+ function bn(e, t) {
1757
+ return Object.entries(e.supportedLanguages ?? {}).find(([e, { aliases: n }]) => n?.includes(t) || e === t)?.[0];
1758
+ }
1759
+ //#endregion
1760
+ //#region src/blocks/Divider/block.ts
1761
+ var xn = D(() => ({
1762
+ type: "divider",
1763
+ propSchema: {},
1764
+ content: "none"
1765
+ })), Sn = O(xn, {
1766
+ meta: { isolating: !1 },
1767
+ parse(e) {
1768
+ if (e.tagName === "HR") return {};
1769
+ },
1770
+ render() {
1771
+ return { dom: document.createElement("hr") };
1772
+ }
1773
+ }, [t({
1774
+ key: "divider-block-shortcuts",
1775
+ inputRules: [{
1776
+ find: RegExp("^---$"),
1777
+ replace() {
1778
+ return {
1779
+ type: "divider",
1780
+ props: {},
1781
+ content: []
1782
+ };
1783
+ }
1784
+ }]
1785
+ })]), Cn = (e) => ({ url: e.src || void 0 }), wn = D(() => ({
1786
+ type: "file",
1787
+ propSchema: {
1788
+ backgroundColor: K.backgroundColor,
1789
+ name: { default: "" },
1790
+ url: { default: "" },
1791
+ caption: { default: "" }
1792
+ },
1793
+ content: "none"
1794
+ })), Tn = () => (e) => {
1795
+ if (e.tagName === "EMBED") {
1796
+ if (e.closest("figure")) return;
1797
+ let { backgroundColor: t } = q(e);
1798
+ return {
1799
+ ...Cn(e),
1800
+ backgroundColor: t
1801
+ };
1802
+ }
1803
+ if (e.tagName === "FIGURE") {
1804
+ let t = tn(e, "embed");
1805
+ if (!t) return;
1806
+ let { targetElement: n, caption: r } = t, { backgroundColor: i } = q(e);
1807
+ return {
1808
+ ...Cn(n),
1809
+ backgroundColor: i,
1810
+ caption: r
1811
+ };
1812
+ }
1813
+ }, En = O(wn, {
1814
+ meta: { fileBlockAccept: ["*/*"] },
1815
+ parse: Tn(),
1816
+ render(e, t) {
1817
+ return on(e, t);
1818
+ },
1819
+ toExternalHTML(e) {
1820
+ if (!e.props.url) {
1821
+ let e = document.createElement("p");
1822
+ return e.textContent = "Add file", { dom: e };
1823
+ }
1824
+ let t = document.createElement("a");
1825
+ return t.href = e.props.url, t.textContent = e.props.name || e.props.url, e.props.caption ? X(t, e.props.caption) : { dom: t };
1826
+ }
1827
+ });
1828
+ //#endregion
1829
+ //#region src/blocks/getDetailsContent.ts
1830
+ function Dn(e, t, i) {
1831
+ let a = n.fromSchema(t), o = e.querySelector(":scope > summary"), s;
1832
+ if (o) {
1833
+ let e = o.cloneNode(!0);
1834
+ Be(e), s = a.parse(e, {
1835
+ topNode: t.nodes.paragraph.create(),
1836
+ preserveWhitespace: !0
1837
+ }).content;
1838
+ } else s = r.empty;
1839
+ let c = document.createElement("div");
1840
+ c.setAttribute("data-node-type", "blockGroup");
1841
+ let l = !1;
1842
+ for (let t of Array.from(e.childNodes)) t.tagName !== "SUMMARY" && (t.nodeType === 3 && !t.textContent?.trim() || (l = !0, c.appendChild(t.cloneNode(!0))));
1843
+ let u = t.nodes[i].create({}, s);
1844
+ if (!l) return u.content;
1845
+ let d = a.parse(c, { topNode: t.nodes.blockGroup.create() });
1846
+ return d.content.size > 0 ? u.content.addToEnd(d) : u.content;
1847
+ }
1848
+ //#endregion
1849
+ //#region src/blocks/ToggleWrapper/createToggleWrapper.ts
1850
+ var On = {
1851
+ set: (e, t) => window.localStorage.setItem(`toggle-${e.id}`, t ? "true" : "false"),
1852
+ get: (e) => window.localStorage.getItem(`toggle-${e.id}`) === "true"
1853
+ }, kn = (e, t, n, r = On) => {
1854
+ if ("isToggleable" in e.props && !e.props.isToggleable) return { dom: n };
1855
+ let i = document.createElement("div"), a = document.createElement("div");
1856
+ a.className = "bn-toggle-wrapper";
1857
+ let o = document.createElement("button");
1858
+ o.className = "bn-toggle-button", o.type = "button", o.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"CURRENTCOLOR\"><path d=\"M320-200v-560l440 280-440 280Z\"/></svg>";
1859
+ let s = (e) => e.preventDefault();
1860
+ o.addEventListener("mousedown", s);
1861
+ let c = () => {
1862
+ a.getAttribute("data-show-children") === "true" ? (a.setAttribute("data-show-children", "false"), r.set(t.getBlock(e), !1), i.contains(l) && i.removeChild(l)) : (a.setAttribute("data-show-children", "true"), r.set(t.getBlock(e), !0), t.isEditable && t.getBlock(e)?.children.length === 0 && !i.contains(l) && i.appendChild(l));
1863
+ };
1864
+ o.addEventListener("click", c), a.appendChild(o), a.appendChild(n);
1865
+ let l = document.createElement("button");
1866
+ l.className = "bn-toggle-add-block-button", l.type = "button", l.textContent = t.dictionary.toggle_blocks.add_block_button;
1867
+ let u = (e) => e.preventDefault();
1868
+ l.addEventListener("mousedown", u);
1869
+ let d = () => {
1870
+ t.transact(() => {
1871
+ let n = t.updateBlock(e, { children: [{}] });
1872
+ t.setTextCursorPosition(n.children[0].id, "end"), t.focus();
1873
+ });
1874
+ };
1875
+ l.addEventListener("click", d), i.appendChild(a);
1876
+ let f = e.children.length, p = t.onChange(() => {
1877
+ let n = t.getBlock(e)?.children.length ?? 0;
1878
+ n > f ? (a.getAttribute("data-show-children") === "false" && (a.setAttribute("data-show-children", "true"), r.set(t.getBlock(e), !0)), i.contains(l) && i.removeChild(l)) : n === 0 && n < f && (a.getAttribute("data-show-children") === "true" && (a.setAttribute("data-show-children", "false"), r.set(t.getBlock(e), !1)), i.contains(l) && i.removeChild(l)), f = n;
1879
+ });
1880
+ return r.get(e) ? (a.setAttribute("data-show-children", "true"), t.isEditable && e.children.length === 0 && i.appendChild(l)) : a.setAttribute("data-show-children", "false"), {
1881
+ dom: i,
1882
+ ignoreMutation: (e) => e instanceof MutationRecord && (e.type === "attributes" && e.target === a && e.attributeName === "data-show-children" || e.type === "childList" && (e.addedNodes[0] === l || e.removedNodes[0] === l)),
1883
+ destroy: () => {
1884
+ o.removeEventListener("mousedown", s), o.removeEventListener("click", c), l.removeEventListener("mousedown", u), l.removeEventListener("click", d), p?.();
1885
+ }
1886
+ };
1887
+ }, An = [
1888
+ 1,
1889
+ 2,
1890
+ 3,
1891
+ 4,
1892
+ 5,
1893
+ 6
1894
+ ], jn = (e) => ({ editor: t }) => {
1895
+ let n = t.getTextCursorPosition();
1896
+ return t.schema.blockSchema[n.block.type].content === "inline" ? (t.updateBlock(n.block, {
1897
+ type: "heading",
1898
+ props: { level: e }
1899
+ }), !0) : !1;
1900
+ }, Mn = D(({ defaultLevel: e = 1, levels: t = An, allowToggleHeadings: n = !0 } = {}) => ({
1901
+ type: "heading",
1902
+ propSchema: {
1903
+ ...K,
1904
+ level: {
1905
+ default: e,
1906
+ values: t
1907
+ },
1908
+ ...n ? { isToggleable: {
1909
+ default: !1,
1910
+ optional: !0
1911
+ } } : {}
1912
+ },
1913
+ content: "inline"
1914
+ })), Nn = O(Mn, ({ allowToggleHeadings: e = !0 } = {}) => ({
1915
+ meta: { isolating: !1 },
1916
+ parse(t) {
1917
+ if (e && t.tagName === "DETAILS") {
1918
+ let e = t.querySelector(":scope > summary");
1919
+ if (!e) return;
1920
+ let n = e.querySelector("h1, h2, h3, h4, h5, h6");
1921
+ return n ? {
1922
+ ...q(n),
1923
+ level: parseInt(n.tagName[1]),
1924
+ isToggleable: !0
1925
+ } : void 0;
1926
+ }
1927
+ let n;
1928
+ switch (t.tagName) {
1929
+ case "H1":
1930
+ n = 1;
1931
+ break;
1932
+ case "H2":
1933
+ n = 2;
1934
+ break;
1935
+ case "H3":
1936
+ n = 3;
1937
+ break;
1938
+ case "H4":
1939
+ n = 4;
1940
+ break;
1941
+ case "H5":
1942
+ n = 5;
1943
+ break;
1944
+ case "H6":
1945
+ n = 6;
1946
+ break;
1947
+ default: return;
1948
+ }
1949
+ return {
1950
+ ...q(t),
1951
+ level: n
1952
+ };
1953
+ },
1954
+ ...e ? { parseContent: ({ el: e, schema: t }) => {
1955
+ if (e.tagName === "DETAILS") return Dn(e, t, "heading");
1956
+ } } : {},
1957
+ runsBefore: ["toggleListItem"],
1958
+ render(t, n) {
1959
+ let r = document.createElement(`h${t.props.level}`);
1960
+ return e ? {
1961
+ ...kn(t, n, r),
1962
+ contentDOM: r
1963
+ } : {
1964
+ dom: r,
1965
+ contentDOM: r
1966
+ };
1967
+ },
1968
+ toExternalHTML(t) {
1969
+ let n = document.createElement(`h${t.props.level}`);
1970
+ if (J(t.props, n), e && t.props.isToggleable) {
1971
+ let e = document.createElement("details");
1972
+ e.setAttribute("open", "");
1973
+ let t = document.createElement("summary");
1974
+ return t.appendChild(n), e.appendChild(t), {
1975
+ dom: e,
1976
+ contentDOM: n,
1977
+ childrenDOM: e
1978
+ };
1979
+ }
1980
+ return {
1981
+ dom: n,
1982
+ contentDOM: n
1983
+ };
1984
+ }
1985
+ }), ({ levels: e = An } = {}) => [t({
1986
+ key: "heading-shortcuts",
1987
+ keyboardShortcuts: Object.fromEntries(e.map((e) => [`Mod-Alt-${e}`, jn(e)]) ?? []),
1988
+ inputRules: e.map((e) => ({
1989
+ find: RegExp(`^(#{${e}})\\s$`),
1990
+ replace({ match: e }) {
1991
+ return {
1992
+ type: "heading",
1993
+ props: { level: e[1].length }
1994
+ };
1995
+ }
1996
+ }))
1997
+ })]), Pn = (e, t, n, r, i) => {
1998
+ let { dom: a, destroy: o } = on(e, t, n, i), s = a;
1999
+ s.style.position = "relative", e.props.url && e.props.showPreview && (e.props.previewWidth ? s.style.width = `${e.props.previewWidth}px` : s.style.width = "fit-content");
2000
+ let c = document.createElement("div");
2001
+ c.className = "bn-resize-handle", c.style.left = "4px", c.style.display = "none", r.appendChild(c);
2002
+ let l = document.createElement("div");
2003
+ l.className = "bn-resize-handle", l.style.right = "4px", l.style.display = "none", r.appendChild(l);
2004
+ let u = document.createElement("div");
2005
+ u.style.position = "absolute", u.style.height = "100%", u.style.width = "100%";
2006
+ let d, f = e.props.previewWidth, p = (n) => {
2007
+ if (!d) {
2008
+ t.isEditable || (c.style.display = "none", l.style.display = "none");
2009
+ return;
2010
+ }
2011
+ let r, i = "touches" in n ? n.touches[0].clientX : n.clientX;
2012
+ r = e.props.textAlignment === "center" ? d.handleUsed === "left" ? d.initialWidth + (d.initialClientX - i) * 2 : d.initialWidth + (i - d.initialClientX) * 2 : d.handleUsed === "left" ? d.initialWidth + d.initialClientX - i : d.initialWidth + i - d.initialClientX, f = Math.min(Math.max(r, 64), t.domElement?.firstElementChild?.clientWidth || Number.MAX_VALUE), s.style.width = `${f}px`;
2013
+ }, m = (n) => {
2014
+ (!n.target || !s.contains(n.target) || !t.isEditable) && (c.style.display = "none", l.style.display = "none"), d && (d = void 0, s.contains(u) && s.removeChild(u), t.updateBlock(e, { props: { previewWidth: f } }));
2015
+ }, h = () => {
2016
+ t.isEditable && (c.style.display = "", l.style.display = "");
2017
+ }, g = (e) => {
2018
+ e.relatedTarget === c || e.relatedTarget === l || d || t.isEditable && (c.style.display = "none", l.style.display = "none");
2019
+ }, _ = (e) => {
2020
+ e.preventDefault(), s.contains(u) || s.appendChild(u);
2021
+ let t = "touches" in e ? e.touches[0].clientX : e.clientX;
2022
+ d = {
2023
+ handleUsed: "left",
2024
+ initialWidth: s.clientWidth,
2025
+ initialClientX: t
2026
+ };
2027
+ }, v = (e) => {
2028
+ e.preventDefault(), s.contains(u) || s.appendChild(u);
2029
+ let t = "touches" in e ? e.touches[0].clientX : e.clientX;
2030
+ d = {
2031
+ handleUsed: "right",
2032
+ initialWidth: s.clientWidth,
2033
+ initialClientX: t
2034
+ };
2035
+ };
2036
+ return window.addEventListener("mousemove", p), window.addEventListener("touchmove", p), window.addEventListener("mouseup", m), window.addEventListener("touchend", m), s.addEventListener("mouseenter", h), s.addEventListener("mouseleave", g), c.addEventListener("mousedown", _), c.addEventListener("touchstart", _), l.addEventListener("mousedown", v), l.addEventListener("touchstart", v), {
2037
+ dom: s,
2038
+ destroy: () => {
2039
+ o?.(), window.removeEventListener("mousemove", p), window.removeEventListener("touchmove", p), window.removeEventListener("mouseup", m), window.removeEventListener("touchend", m), s.removeEventListener("mouseenter", h), s.removeEventListener("mouseleave", g), c.removeEventListener("mousedown", _), c.removeEventListener("touchstart", _), l.removeEventListener("mousedown", v), l.removeEventListener("touchstart", v);
2040
+ }
2041
+ };
2042
+ }, Fn = (e) => ({
2043
+ url: e.src || void 0,
2044
+ previewWidth: e.width || void 0,
2045
+ name: e.alt || void 0
2046
+ }), In = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z\"></path></svg>", Ln = D((e = {}) => ({
2047
+ type: "image",
2048
+ propSchema: {
2049
+ textAlignment: K.textAlignment,
2050
+ backgroundColor: K.backgroundColor,
2051
+ name: { default: "" },
2052
+ url: { default: "" },
2053
+ caption: { default: "" },
2054
+ showPreview: { default: !0 },
2055
+ previewWidth: {
2056
+ default: void 0,
2057
+ type: "number"
2058
+ }
2059
+ },
2060
+ content: "none"
2061
+ })), Rn = (e = {}) => (e) => {
2062
+ if (e.tagName === "IMG") {
2063
+ if (e.closest("figure")) return;
2064
+ let { backgroundColor: t } = q(e);
2065
+ return {
2066
+ ...Fn(e),
2067
+ backgroundColor: t
2068
+ };
2069
+ }
2070
+ if (e.tagName === "FIGURE") {
2071
+ let t = tn(e, "img");
2072
+ if (!t) return;
2073
+ let { targetElement: n, caption: r } = t, { backgroundColor: i } = q(e);
2074
+ return {
2075
+ ...Fn(n),
2076
+ backgroundColor: i,
2077
+ caption: r
2078
+ };
2079
+ }
2080
+ }, zn = (e = {}) => (t, n) => {
2081
+ let r = document.createElement("div");
2082
+ r.innerHTML = e.icon ?? "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z\"></path></svg>";
2083
+ let i = document.createElement("div");
2084
+ i.className = "bn-visual-media-wrapper";
2085
+ let a = document.createElement("img");
2086
+ return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
2087
+ a.src = e;
2088
+ }) : a.src = t.props.url, a.alt = t.props.name || t.props.caption || "BlockNote image", a.contentEditable = "false", a.draggable = !1, i.appendChild(a), Pn(t, n, { dom: i }, i, r.firstElementChild);
2089
+ }, Bn = (e = {}) => (e, t) => {
2090
+ if (!e.props.url) {
2091
+ let e = document.createElement("p");
2092
+ return e.textContent = "Add image", { dom: e };
2093
+ }
2094
+ let n;
2095
+ return e.props.showPreview ? (n = document.createElement("img"), n.src = e.props.url, n.alt = e.props.name || e.props.caption || "BlockNote image", e.props.previewWidth && (n.width = e.props.previewWidth)) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? sn(n, e.props.caption) : X(n, e.props.caption) : { dom: n };
2096
+ }, Vn = O(Ln, (e) => ({
2097
+ meta: { fileBlockAccept: ["image/*"] },
2098
+ parse: Rn(e),
2099
+ render: zn(e),
2100
+ toExternalHTML: Bn(e),
2101
+ runsBefore: ["file"]
2102
+ })), Hn = (e, t, n) => ({ state: r, dispatch: i }) => i ? Un(r.tr, e, t, n) : !0, Un = (e, t, n, r) => {
2103
+ let i = k(Ye(e.doc, t));
2104
+ if (!i.isBlockContainer) return !1;
2105
+ let a = A(e), o = [{
2106
+ type: i.bnBlock.node.type,
2107
+ attrs: r ? {
2108
+ ...i.bnBlock.node.attrs,
2109
+ id: void 0
2110
+ } : {}
2111
+ }, {
2112
+ type: n ? i.blockContent.node.type : a.nodes.paragraph,
2113
+ attrs: r ? { ...i.blockContent.node.attrs } : {}
2114
+ }];
2115
+ return e.split(t, 2, o), !0;
2116
+ }, Wn = (e, t) => {
2117
+ let { blockInfo: n, selectionEmpty: r } = e.transact((e) => ({
2118
+ blockInfo: $e(e),
2119
+ selectionEmpty: e.selection.anchor === e.selection.head
2120
+ }));
2121
+ if (!n.isBlockContainer) return !1;
2122
+ let { bnBlock: i, blockContent: a } = n;
2123
+ return a.node.type.name !== t || !r ? !1 : a.node.childCount === 0 ? (e.transact((e) => {
2124
+ W(e, i.beforePos, {
2125
+ type: "paragraph",
2126
+ props: {}
2127
+ });
2128
+ }), !0) : a.node.childCount > 0 ? e.transact((e) => (e.deleteSelection(), Un(e, e.selection.from, !0))) : !1;
2129
+ };
2130
+ //#endregion
2131
+ //#region src/blocks/ListItem/getListItemContent.ts
2132
+ function Gn(e, t, i) {
2133
+ let a = n.fromSchema(t), o = e, s = document.createElement("div");
2134
+ s.setAttribute("data-node-type", "blockGroup");
2135
+ for (let e of Array.from(o.childNodes)) s.appendChild(e.cloneNode(!0));
2136
+ let c = a.parse(s, { topNode: t.nodes.blockGroup.create() });
2137
+ c.firstChild?.firstChild?.type.name === "checkListItem" && (c = c.copy(c.content.cut(c.firstChild.firstChild.nodeSize + 2)));
2138
+ let l = c.firstChild?.firstChild;
2139
+ if (!l?.isTextblock) return r.from(c);
2140
+ let u = t.nodes[i].create({}, l.content), d = c.content.cut(l.nodeSize + 2);
2141
+ if (d.size > 0) {
2142
+ let e = c.copy(d);
2143
+ return u.content.addToEnd(e);
2144
+ }
2145
+ return u.content;
2146
+ }
2147
+ //#endregion
2148
+ //#region src/blocks/ListItem/BulletListItem/block.ts
2149
+ var Kn = D(() => ({
2150
+ type: "bulletListItem",
2151
+ propSchema: { ...K },
2152
+ content: "inline"
2153
+ })), qn = O(Kn, {
2154
+ meta: { isolating: !1 },
2155
+ parse(e) {
2156
+ if (e.tagName !== "LI") return;
2157
+ let t = e.parentElement;
2158
+ if (t !== null && (t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL")) return q(e);
2159
+ },
2160
+ parseContent: ({ el: e, schema: t }) => Gn(e, t, "bulletListItem"),
2161
+ render() {
2162
+ let e = document.createElement("p");
2163
+ return {
2164
+ dom: e,
2165
+ contentDOM: e
2166
+ };
2167
+ },
2168
+ toExternalHTML(e) {
2169
+ let t = document.createElement("li"), n = document.createElement("p");
2170
+ return J(e.props, t), t.appendChild(n), {
2171
+ dom: t,
2172
+ contentDOM: n
2173
+ };
2174
+ }
2175
+ }, [t({
2176
+ key: "bullet-list-item-shortcuts",
2177
+ keyboardShortcuts: {
2178
+ Enter: ({ editor: e }) => Wn(e, "bulletListItem"),
2179
+ "Mod-Shift-8": ({ editor: e }) => {
2180
+ let t = e.getTextCursorPosition();
2181
+ return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
2182
+ type: "bulletListItem",
2183
+ props: {}
2184
+ }), !0) : !1;
2185
+ }
2186
+ },
2187
+ inputRules: [{
2188
+ find: /^\s?[-+*]\s$/,
2189
+ replace({ editor: e }) {
2190
+ if (Qe(e.prosemirrorState).blockNoteType !== "heading") return {
2191
+ type: "bulletListItem",
2192
+ props: {}
2193
+ };
2194
+ }
2195
+ }]
2196
+ })]), Jn = D(() => ({
2197
+ type: "checkListItem",
2198
+ propSchema: {
2199
+ ...K,
2200
+ checked: {
2201
+ default: !1,
2202
+ type: "boolean"
2203
+ }
2204
+ },
2205
+ content: "inline"
2206
+ })), Yn = O(Jn, {
2207
+ meta: { isolating: !1 },
2208
+ parse(e) {
2209
+ if (e.tagName === "input") return e.closest("[data-content-type]") || e.closest("li") ? void 0 : e.type === "checkbox" ? { checked: e.checked } : void 0;
2210
+ if (e.tagName !== "LI") return;
2211
+ let t = e.parentElement;
2212
+ if (t !== null && (t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL")) {
2213
+ let t = e.querySelector("input[type=checkbox]") || null;
2214
+ return t === null ? void 0 : {
2215
+ ...q(e),
2216
+ checked: t.checked
2217
+ };
2218
+ }
2219
+ },
2220
+ parseContent: ({ el: e, schema: t }) => Gn(e, t, "checkListItem"),
2221
+ render(e, t) {
2222
+ let n = document.createDocumentFragment(), r = document.createElement("input");
2223
+ r.type = "checkbox", r.checked = e.props.checked, e.props.checked && r.setAttribute("checked", ""), r.disabled = !t.isEditable, r.addEventListener("change", () => {
2224
+ t.isEditable && t.updateBlock(e, { props: { checked: !e.props.checked } });
2225
+ });
2226
+ let i = document.createElement("p"), a = document.createElement("div");
2227
+ return a.contentEditable = "false", a.appendChild(r), n.appendChild(a), n.appendChild(i), {
2228
+ dom: n,
2229
+ contentDOM: i
2230
+ };
2231
+ },
2232
+ toExternalHTML(e) {
2233
+ let t = document.createElement("li"), n = document.createElement("input");
2234
+ n.type = "checkbox", n.checked = e.props.checked, e.props.checked && n.setAttribute("checked", "");
2235
+ let r = document.createElement("p");
2236
+ return J(e.props, t), t.appendChild(n), t.appendChild(r), {
2237
+ dom: t,
2238
+ contentDOM: r
2239
+ };
2240
+ },
2241
+ runsBefore: ["bulletListItem"]
2242
+ }, [t({
2243
+ key: "check-list-item-shortcuts",
2244
+ keyboardShortcuts: {
2245
+ Enter: ({ editor: e }) => Wn(e, "checkListItem"),
2246
+ "Mod-Shift-9": ({ editor: e }) => {
2247
+ let t = e.getTextCursorPosition();
2248
+ return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
2249
+ type: "checkListItem",
2250
+ props: {}
2251
+ }), !0) : !1;
2252
+ }
2253
+ },
2254
+ inputRules: [{
2255
+ find: /^\s?\[\s*\]\s$/,
2256
+ replace() {
2257
+ return {
2258
+ type: "checkListItem",
2259
+ props: { checked: !1 }
2260
+ };
2261
+ }
2262
+ }, {
2263
+ find: /^\s?\[[Xx]\]\s$/,
2264
+ replace() {
2265
+ return {
2266
+ type: "checkListItem",
2267
+ props: { checked: !0 }
2268
+ };
2269
+ }
2270
+ }]
2271
+ })]);
2272
+ //#endregion
2273
+ //#region src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts
2274
+ function Xn(e, t, n, r) {
2275
+ let i = !!e.firstChild.attrs.start, a = k({
2276
+ posBeforeNode: t,
2277
+ node: e
2278
+ });
2279
+ if (!a.isBlockContainer) throw Error("impossible");
2280
+ let o = n.doc.resolve(a.bnBlock.beforePos).nodeBefore, s = o ? r.get(o) : void 0;
2281
+ if (s !== void 0) {
2282
+ let t = s + 1;
2283
+ return r.set(e, t), {
2284
+ index: t,
2285
+ isFirst: !1,
2286
+ hasStart: i
2287
+ };
2288
+ }
2289
+ let c = [{
2290
+ node: e,
2291
+ pos: t
2292
+ }], l = o, u = a.bnBlock.beforePos;
2293
+ for (; l && r.get(l) === void 0;) {
2294
+ let e = k({
2295
+ posBeforeNode: u - l.nodeSize,
2296
+ node: l
2297
+ });
2298
+ if (e.blockNoteType !== "numberedListItem") break;
2299
+ c.push({
2300
+ node: l,
2301
+ pos: u - l.nodeSize
2302
+ });
2303
+ let t = n.doc.resolve(e.bnBlock.beforePos).nodeBefore;
2304
+ u = e.bnBlock.beforePos, l = t;
2305
+ }
2306
+ let d, f, p = c[c.length - 1], m = k({
2307
+ posBeforeNode: p.pos,
2308
+ node: p.node
2309
+ });
2310
+ if (!m.isBlockContainer) throw Error("impossible");
2311
+ let h = n.doc.resolve(m.bnBlock.beforePos).nodeBefore, g = h ? r.get(h) : void 0;
2312
+ g === void 0 ? (d = (p.node.firstChild.attrs.start || 1) - 1, f = !0) : (d = g, f = !1);
2313
+ for (let e = c.length - 1; e >= 0; e--) {
2314
+ let t = c[e];
2315
+ f && e < c.length - 1 && (f = !1), d++, r.set(t.node, d);
2316
+ }
2317
+ return {
2318
+ index: d,
2319
+ isFirst: c.length === 1 ? f || g === void 0 : !1,
2320
+ hasStart: i
2321
+ };
2322
+ }
2323
+ function Zn(e, t) {
2324
+ let n = /* @__PURE__ */ new Map(), r = t.decorations.map(e.mapping, e.doc), i = e.changedRange();
2325
+ if (!i) return { decorations: r };
2326
+ let a = [], o = /* @__PURE__ */ new Set();
2327
+ e.doc.nodesBetween(i.from, e.doc.nodeSize - 2, (t, s, c) => {
2328
+ if (c && o.has(c)) return !1;
2329
+ if (t.type.name === "blockContainer" && t.firstChild.type.name === "numberedListItem") {
2330
+ let { index: l, isFirst: u, hasStart: d } = Xn(t, s, e, n), f = e.doc.nodeAt(s + 1);
2331
+ if (r.find(s + 1, s + 1 + f.nodeSize, (e) => e.index === l && e.isFirst === u && e.hasStart === d).length === 0) a.push(he.node(s + 1, s + 1 + f.nodeSize, { "data-index": l.toString() }, {
2332
+ index: l,
2333
+ isFirst: u,
2334
+ hasStart: d
2335
+ }));
2336
+ else if (s >= i.to && c) return o.add(c), !1;
2337
+ }
2338
+ });
2339
+ let s = a.flatMap((e) => r.find(e.from, e.to));
2340
+ return { decorations: r.remove(s).add(e.doc, a) };
2341
+ }
2342
+ var Qn = () => new pe({
2343
+ key: new me("numbered-list-indexing-decorations"),
2344
+ state: {
2345
+ init(e, t) {
2346
+ return Zn(t.tr, { decorations: ge.empty });
2347
+ },
2348
+ apply(e, t) {
2349
+ return !e.docChanged && t.decorations ? t : Zn(e, t);
2350
+ }
2351
+ },
2352
+ props: { decorations(e) {
2353
+ return this.getState(e)?.decorations ?? ge.empty;
2354
+ } }
2355
+ }), $n = D(() => ({
2356
+ type: "numberedListItem",
2357
+ propSchema: {
2358
+ ...K,
2359
+ start: {
2360
+ default: void 0,
2361
+ type: "number"
2362
+ }
2363
+ },
2364
+ content: "inline"
2365
+ })), er = O($n, {
2366
+ meta: { isolating: !1 },
2367
+ parse(e) {
2368
+ if (e.tagName !== "LI") return;
2369
+ let t = e.parentElement;
2370
+ if (t !== null && (t.tagName === "OL" || t.tagName === "DIV" && t.parentElement?.tagName === "OL")) {
2371
+ let n = parseInt(t.getAttribute("start") || "1"), r = q(e);
2372
+ return e.previousElementSibling || n === 1 ? r : {
2373
+ ...r,
2374
+ start: n
2375
+ };
2376
+ }
2377
+ },
2378
+ parseContent: ({ el: e, schema: t }) => Gn(e, t, "numberedListItem"),
2379
+ render() {
2380
+ let e = document.createElement("p");
2381
+ return {
2382
+ dom: e,
2383
+ contentDOM: e
2384
+ };
2385
+ },
2386
+ toExternalHTML(e) {
2387
+ let t = document.createElement("li"), n = document.createElement("p");
2388
+ return J(e.props, t), t.appendChild(n), {
2389
+ dom: t,
2390
+ contentDOM: n
2391
+ };
2392
+ }
2393
+ }, [t({
2394
+ key: "numbered-list-item-shortcuts",
2395
+ inputRules: [{
2396
+ find: /^\s?(\d+)\.\s$/,
2397
+ replace({ match: e, editor: t }) {
2398
+ if (Qe(t.prosemirrorState).blockNoteType === "heading") return;
2399
+ let n = parseInt(e[1]);
2400
+ return {
2401
+ type: "numberedListItem",
2402
+ props: { start: n === 1 ? void 0 : n }
2403
+ };
2404
+ }
2405
+ }],
2406
+ keyboardShortcuts: {
2407
+ Enter: ({ editor: e }) => Wn(e, "numberedListItem"),
2408
+ "Mod-Shift-7": ({ editor: e }) => {
2409
+ let t = e.getTextCursorPosition();
2410
+ return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
2411
+ type: "numberedListItem",
2412
+ props: {}
2413
+ }), !0) : !1;
2414
+ }
2415
+ },
2416
+ prosemirrorPlugins: [Qn()]
2417
+ })]), tr = D(() => ({
2418
+ type: "toggleListItem",
2419
+ propSchema: { ...K },
2420
+ content: "inline"
2421
+ })), nr = O(tr, {
2422
+ meta: { isolating: !1 },
2423
+ parse(e) {
2424
+ if (e.tagName === "DETAILS") return q(e);
2425
+ if (e.tagName === "LI") {
2426
+ let t = e.parentElement;
2427
+ if (t && (t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL") && e.querySelector(":scope > details")) return q(e);
2428
+ }
2429
+ },
2430
+ parseContent: ({ el: e, schema: t }) => {
2431
+ let n = e.tagName === "DETAILS" ? e : e.querySelector(":scope > details");
2432
+ if (!n) throw Error("No details found in toggleListItem parseContent");
2433
+ return Dn(n, t, "toggleListItem");
2434
+ },
2435
+ runsBefore: ["bulletListItem"],
2436
+ render(e, t) {
2437
+ let n = document.createElement("p");
2438
+ return {
2439
+ ...kn(e, t, n),
2440
+ contentDOM: n
2441
+ };
2442
+ },
2443
+ toExternalHTML(e) {
2444
+ let t = document.createElement("li"), n = document.createElement("details");
2445
+ n.setAttribute("open", "");
2446
+ let r = document.createElement("summary"), i = document.createElement("p");
2447
+ return r.appendChild(i), n.appendChild(r), J(e.props, t), t.appendChild(n), {
2448
+ dom: t,
2449
+ contentDOM: i,
2450
+ childrenDOM: n
2451
+ };
2452
+ }
2453
+ }, [t({
2454
+ key: "toggle-list-item-shortcuts",
2455
+ keyboardShortcuts: {
2456
+ Enter: ({ editor: e }) => Wn(e, "toggleListItem"),
2457
+ "Mod-Shift-6": ({ editor: e }) => {
2458
+ let t = e.getTextCursorPosition();
2459
+ return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
2460
+ type: "toggleListItem",
2461
+ props: {}
2462
+ }), !0) : !1;
2463
+ }
2464
+ }
2465
+ })]), rr = D(() => ({
2466
+ type: "pageBreak",
2467
+ propSchema: {},
2468
+ content: "none"
2469
+ })), ir = O(rr, {
2470
+ parse(e) {
2471
+ if (e.tagName === "DIV" && e.hasAttribute("data-page-break")) return {};
2472
+ },
2473
+ render() {
2474
+ let e = document.createElement("div");
2475
+ return e.setAttribute("data-page-break", ""), { dom: e };
2476
+ },
2477
+ toExternalHTML() {
2478
+ let e = document.createElement("div");
2479
+ return e.setAttribute("data-page-break", ""), { dom: e };
2480
+ }
2481
+ }), ar = (e) => e.extend({ blockSpecs: { pageBreak: ir() } }), or = D(() => ({
2482
+ type: "paragraph",
2483
+ propSchema: K,
2484
+ content: "inline"
2485
+ })), sr = O(or, {
2486
+ meta: { isolating: !1 },
2487
+ parse: (e) => {
2488
+ if (e.tagName === "P" && e.textContent?.trim()) return q(e);
2489
+ },
2490
+ render: () => {
2491
+ let e = document.createElement("p");
2492
+ return {
2493
+ dom: e,
2494
+ contentDOM: e
2495
+ };
2496
+ },
2497
+ toExternalHTML: (e) => {
2498
+ let t = document.createElement("p");
2499
+ return J(e.props, t), {
2500
+ dom: t,
2501
+ contentDOM: t
2502
+ };
2503
+ },
2504
+ runsBefore: ["default", "heading"]
2505
+ }, [t({
2506
+ key: "paragraph-shortcuts",
2507
+ keyboardShortcuts: { "Mod-Alt-0": ({ editor: e }) => {
2508
+ let t = e.getTextCursorPosition();
2509
+ return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
2510
+ type: "paragraph",
2511
+ props: {}
2512
+ }), !0) : !1;
2513
+ } }
2514
+ })]), cr = D(() => ({
2515
+ type: "quote",
2516
+ propSchema: {
2517
+ backgroundColor: K.backgroundColor,
2518
+ textColor: K.textColor
2519
+ },
2520
+ content: "inline"
2521
+ })), lr = O(cr, {
2522
+ meta: { isolating: !1 },
2523
+ parse(e) {
2524
+ if (e.tagName === "BLOCKQUOTE") {
2525
+ let { backgroundColor: t, textColor: n } = q(e);
2526
+ return {
2527
+ backgroundColor: t,
2528
+ textColor: n
2529
+ };
2530
+ }
2531
+ },
2532
+ render() {
2533
+ let e = document.createElement("blockquote");
2534
+ return {
2535
+ dom: e,
2536
+ contentDOM: e
2537
+ };
2538
+ },
2539
+ toExternalHTML(e) {
2540
+ let t = document.createElement("blockquote");
2541
+ return J(e.props, t), {
2542
+ dom: t,
2543
+ contentDOM: t
2544
+ };
2545
+ }
2546
+ }, [t({
2547
+ key: "quote-block-shortcuts",
2548
+ keyboardShortcuts: { "Mod-Alt-q": ({ editor: e }) => {
2549
+ let t = e.getTextCursorPosition();
2550
+ return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
2551
+ type: "quote",
2552
+ props: {}
2553
+ }), !0) : !1;
2554
+ } },
2555
+ inputRules: [{
2556
+ find: RegExp("^>\\s$"),
2557
+ replace() {
2558
+ return {
2559
+ type: "quote",
2560
+ props: {}
2561
+ };
2562
+ }
2563
+ }]
2564
+ })]), ur = 120, dr = 31, fr = s.create({
2565
+ name: "BlockNoteTableExtension",
2566
+ addProseMirrorPlugins: () => [ce({
2567
+ cellMinWidth: 35,
2568
+ defaultCellMinWidth: 120,
2569
+ View: null
2570
+ }), ue()],
2571
+ addKeyboardShortcuts() {
2572
+ return {
2573
+ Enter: () => this.editor.state.selection.empty && this.editor.state.selection.$head.parent.type.name === "tableParagraph" ? (this.editor.commands.insertContent({ type: "hardBreak" }), !0) : !1,
2574
+ Backspace: () => {
2575
+ let e = this.editor.state.selection, t = e.empty, n = e.$head.parentOffset === 0, r = e.$head.node().type.name === "tableParagraph";
2576
+ return t && n && r;
2577
+ },
2578
+ Tab: () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) => le(1)(e, t, n)),
2579
+ "Shift-Tab": () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) => le(-1)(e, t, n))
2580
+ };
2581
+ },
2582
+ extendNodeSchema(e) {
2583
+ return { tableRole: u(h(e, "tableRole", {
2584
+ name: e.name,
2585
+ options: e.options,
2586
+ storage: e.storage
2587
+ })) };
2588
+ }
2589
+ }), pr = { textColor: K.textColor }, mr = l.create({
2590
+ name: "tableHeader",
2591
+ addOptions() {
2592
+ return { HTMLAttributes: {} };
2593
+ },
2594
+ content: "tableContent+",
2595
+ addAttributes() {
2596
+ return {
2597
+ colspan: { default: 1 },
2598
+ rowspan: { default: 1 },
2599
+ colwidth: {
2600
+ default: null,
2601
+ parseHTML: (e) => {
2602
+ let t = e.getAttribute("colwidth");
2603
+ return t ? t.split(",").map((e) => parseInt(e, 10)) : null;
2604
+ }
2605
+ }
2606
+ };
2607
+ },
2608
+ tableRole: "header_cell",
2609
+ isolating: !0,
2610
+ parseHTML() {
2611
+ return [{
2612
+ tag: "th",
2613
+ getContent: (e, t) => yr(e, t)
2614
+ }];
2615
+ },
2616
+ renderHTML({ HTMLAttributes: e }) {
2617
+ return [
2618
+ "th",
2619
+ g(this.options.HTMLAttributes, e),
2620
+ 0
2621
+ ];
2622
+ }
2623
+ }), hr = l.create({
2624
+ name: "tableCell",
2625
+ addOptions() {
2626
+ return { HTMLAttributes: {} };
2627
+ },
2628
+ content: "tableContent+",
2629
+ addAttributes() {
2630
+ return {
2631
+ colspan: { default: 1 },
2632
+ rowspan: { default: 1 },
2633
+ colwidth: {
2634
+ default: null,
2635
+ parseHTML: (e) => {
2636
+ let t = e.getAttribute("colwidth");
2637
+ return t ? t.split(",").map((e) => parseInt(e, 10)) : null;
2638
+ }
2639
+ }
2640
+ };
2641
+ },
2642
+ tableRole: "cell",
2643
+ isolating: !0,
2644
+ parseHTML() {
2645
+ return [{
2646
+ tag: "td",
2647
+ getContent: (e, t) => yr(e, t)
2648
+ }];
2649
+ },
2650
+ renderHTML({ HTMLAttributes: e }) {
2651
+ return [
2652
+ "td",
2653
+ g(this.options.HTMLAttributes, e),
2654
+ 0
2655
+ ];
2656
+ }
2657
+ }), gr = l.create({
2658
+ name: "table",
2659
+ content: "tableRow+",
2660
+ group: "blockContent",
2661
+ tableRole: "table",
2662
+ marks: "deletion insertion modification",
2663
+ isolating: !0,
2664
+ parseHTML() {
2665
+ return [{ tag: "table" }];
2666
+ },
2667
+ renderHTML({ node: e, HTMLAttributes: t }) {
2668
+ let n = Re(this.name, "table", {
2669
+ ...this.options.domAttributes?.blockContent || {},
2670
+ ...t
2671
+ }, this.options.domAttributes?.inlineContent || {}), r = document.createElement("colgroup");
2672
+ for (let t of e.children[0].children) if (t.attrs.colwidth) for (let e of t.attrs.colwidth) {
2673
+ let t = document.createElement("col");
2674
+ e && (t.style = `width: ${e}px`), r.appendChild(t);
2675
+ }
2676
+ else r.appendChild(document.createElement("col"));
2677
+ return n.dom.firstChild?.appendChild(r), n;
2678
+ },
2679
+ addNodeView() {
2680
+ return ({ node: e, HTMLAttributes: t }) => {
2681
+ class n extends se {
2682
+ constructor(e, t, n) {
2683
+ super(e, t), this.node = e, this.cellMinWidth = t, this.blockContentHTMLAttributes = n;
2684
+ let r = document.createElement("div");
2685
+ r.className = w("bn-block-content", n.class), r.setAttribute("data-content-type", "table");
2686
+ for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
2687
+ let i = this.dom, a = document.createElement("div");
2688
+ a.className = "tableWrapper-inner", a.appendChild(i.firstChild), i.appendChild(a), r.appendChild(i);
2689
+ let o = document.createElement("div");
2690
+ o.className = "table-widgets-container", o.style.position = "relative", i.appendChild(o), this.dom = r;
2691
+ }
2692
+ ignoreMutation(e) {
2693
+ return !e.target.closest(".tableWrapper-inner") || super.ignoreMutation(e);
2694
+ }
2695
+ }
2696
+ return new n(e, 120, {
2697
+ ...this.options.domAttributes?.blockContent || {},
2698
+ ...t
2699
+ });
2700
+ };
2701
+ }
2702
+ }), _r = l.create({
2703
+ name: "tableParagraph",
2704
+ group: "tableContent",
2705
+ content: "inline*",
2706
+ parseHTML() {
2707
+ return [{
2708
+ tag: "p",
2709
+ getAttrs: (e) => {
2710
+ if (typeof e == "string" || !e.textContent || !e.closest("[data-content-type]")) return !1;
2711
+ let t = e.parentElement;
2712
+ return t === null ? !1 : t.tagName === "TD" || t.tagName === "TH" ? {} : !1;
2713
+ },
2714
+ node: "tableParagraph"
2715
+ }];
2716
+ },
2717
+ renderHTML({ HTMLAttributes: e }) {
2718
+ return [
2719
+ "p",
2720
+ e,
2721
+ 0
2722
+ ];
2723
+ }
2724
+ }), vr = l.create({
2725
+ name: "tableRow",
2726
+ addOptions() {
2727
+ return { HTMLAttributes: {} };
2728
+ },
2729
+ content: "(tableCell | tableHeader)+",
2730
+ tableRole: "row",
2731
+ marks: "deletion insertion modification",
2732
+ parseHTML() {
2733
+ return [{ tag: "tr" }];
2734
+ },
2735
+ renderHTML({ HTMLAttributes: e }) {
2736
+ return [
2737
+ "tr",
2738
+ g(this.options.HTMLAttributes, e),
2739
+ 0
2740
+ ];
2741
+ }
2742
+ });
2743
+ function yr(e, t) {
2744
+ let i = n.fromSchema(t).parse(e, { topNode: t.nodes.blockGroup.create() }), a = [];
2745
+ return i.content.descendants((e) => {
2746
+ if (e.isInline) return a.push(e), !1;
2747
+ }), r.fromArray(a);
2748
+ }
2749
+ var br = () => Ge({
2750
+ node: gr,
2751
+ type: "table",
2752
+ content: "table"
2753
+ }, pr, [t({
2754
+ key: "table-extensions",
2755
+ tiptapExtensions: [
2756
+ fr,
2757
+ _r,
2758
+ mr,
2759
+ hr,
2760
+ vr
2761
+ ]
2762
+ }), t({
2763
+ key: "table-keyboard-delete",
2764
+ keyboardShortcuts: { Backspace: ({ editor: e }) => {
2765
+ if (!(e.prosemirrorState.selection instanceof ae)) return !1;
2766
+ let t = e.getTextCursorPosition().block, n = t.content, r = 0;
2767
+ for (let e of n.rows) for (let t of e.cells) {
2768
+ if ("type" in t && t.content.length > 0 || !("type" in t) && t.length > 0) return !1;
2769
+ r++;
2770
+ }
2771
+ let i = 0;
2772
+ return e.prosemirrorState.selection.forEachCell(() => {
2773
+ i++;
2774
+ }), i < r ? !1 : (e.transact(() => {
2775
+ (e.getPrevBlock(t) || e.getNextBlock(t)) && e.setTextCursorPosition(t), e.removeBlocks([t]);
2776
+ }), !0);
2777
+ } }
2778
+ })]), xr = (e) => ({
2779
+ url: e.src || void 0,
2780
+ previewWidth: e.width || void 0
2781
+ }), Sr = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z\"></path></svg>", Cr = D((e) => ({
2782
+ type: "video",
2783
+ propSchema: {
2784
+ textAlignment: K.textAlignment,
2785
+ backgroundColor: K.backgroundColor,
2786
+ name: { default: "" },
2787
+ url: { default: "" },
2788
+ caption: { default: "" },
2789
+ showPreview: { default: !0 },
2790
+ previewWidth: {
2791
+ default: void 0,
2792
+ type: "number"
2793
+ }
2794
+ },
2795
+ content: "none"
2796
+ })), wr = (e) => (e) => {
2797
+ if (e.tagName === "VIDEO") {
2798
+ if (e.closest("figure")) return;
2799
+ let { backgroundColor: t } = q(e);
2800
+ return {
2801
+ ...xr(e),
2802
+ backgroundColor: t
2803
+ };
2804
+ }
2805
+ if (e.tagName === "FIGURE") {
2806
+ let t = tn(e, "video");
2807
+ if (!t) return;
2808
+ let { targetElement: n, caption: r } = t, { backgroundColor: i } = q(e);
2809
+ return {
2810
+ ...xr(n),
2811
+ backgroundColor: i,
2812
+ caption: r
2813
+ };
2814
+ }
2815
+ }, Tr = O(Cr, (e) => ({
2816
+ meta: { fileBlockAccept: ["video/*"] },
2817
+ parse: wr(e),
2818
+ render(t, n) {
2819
+ let r = document.createElement("div");
2820
+ r.innerHTML = e.icon ?? "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z\"></path></svg>";
2821
+ let i = document.createElement("div");
2822
+ i.className = "bn-visual-media-wrapper";
2823
+ let a = document.createElement("video");
2824
+ return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
2825
+ a.src = e;
2826
+ }) : a.src = t.props.url, a.controls = !0, a.contentEditable = "false", a.draggable = !1, a.width = t.props.previewWidth, i.appendChild(a), Pn(t, n, { dom: i }, i, r.firstElementChild);
2827
+ },
2828
+ toExternalHTML(e) {
2829
+ if (!e.props.url) {
2830
+ let e = document.createElement("p");
2831
+ return e.textContent = "Add video", { dom: e };
2832
+ }
2833
+ let t;
2834
+ return e.props.showPreview ? (t = document.createElement("video"), t.src = e.props.url, e.props.previewWidth && (t.width = e.props.previewWidth)) : (t = document.createElement("a"), t.href = e.props.url, t.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? sn(t, e.props.caption) : X(t, e.props.caption) : { dom: t };
2835
+ },
2836
+ runsBefore: ["file"]
2837
+ })), Er = async (e) => {
2838
+ let t = new FormData();
2839
+ return t.append("file", e), (await (await fetch("https://tmpfiles.org/api/v1/upload", {
2840
+ method: "POST",
2841
+ body: t
2842
+ })).json()).data.url.replace("tmpfiles.org/", "tmpfiles.org/dl/");
2843
+ };
2844
+ //#endregion
2845
+ //#region src/blocks/defaultBlockTypeGuards.ts
2846
+ function Z(e, t, n) {
2847
+ if (!(t in e.schema.blockSpecs)) return !1;
2848
+ if (!n) return !0;
2849
+ for (let [r, i] of Object.entries(n)) {
2850
+ if (!(r in e.schema.blockSpecs[t].config.propSchema)) return !1;
2851
+ if (typeof i == "string") {
2852
+ if (e.schema.blockSpecs[t].config.propSchema[r].default !== void 0 && typeof e.schema.blockSpecs[t].config.propSchema[r].default !== i || e.schema.blockSpecs[t].config.propSchema[r].type !== void 0 && e.schema.blockSpecs[t].config.propSchema[r].type !== i) return !1;
2853
+ } else {
2854
+ if (e.schema.blockSpecs[t].config.propSchema[r].default !== i.default || e.schema.blockSpecs[t].config.propSchema[r].default === void 0 && i.default === void 0 && e.schema.blockSpecs[t].config.propSchema[r].type !== i.type || typeof e.schema.blockSpecs[t].config.propSchema[r].values != typeof i.values) return !1;
2855
+ if (typeof e.schema.blockSpecs[t].config.propSchema[r].values == "object" && typeof i.values == "object") {
2856
+ for (let n of i.values) if (!e.schema.blockSpecs[t].config.propSchema[r].values.includes(n)) return !1;
2857
+ }
2858
+ }
2859
+ }
2860
+ return !0;
2861
+ }
2862
+ function Dr(e, t, n, r) {
2863
+ return Z(t, n, r) && e.type === n;
2864
+ }
2865
+ function Or(e) {
2866
+ return e instanceof ae;
2867
+ }
2868
+ //#endregion
2869
+ //#region src/api/positionMapping.ts
2870
+ var kr = /* @__PURE__ */ new Map();
2871
+ function Ar(e) {
2872
+ if (kr.has(e)) return kr.get(e);
2873
+ let t = new a();
2874
+ return e._tiptapEditor.on("transaction", ({ transaction: e }) => {
2875
+ t.appendMapping(e.mapping);
2876
+ }), e._tiptapEditor.on("destroy", () => {
2877
+ kr.delete(e);
2878
+ }), kr.set(e, t), t;
2879
+ }
2880
+ function jr(e, t, n = "left") {
2881
+ let r = xe.getState(e.prosemirrorState);
2882
+ if (!r) {
2883
+ let r = Ar(e), i = r.maps.length;
2884
+ return () => r.slice(i).map(t, n === "left" ? -1 : 1);
2885
+ }
2886
+ let i = ye(t + (n === "right" ? 1 : -1), r.binding.type, r.binding.mapping);
2887
+ return () => {
2888
+ let t = xe.getState(e.prosemirrorState), r = be(t.doc, t.binding.type, i, t.binding.mapping);
2889
+ if (r === null) throw Error("Position not found, cannot track positions");
2890
+ return r + (n === "right" ? -1 : 1);
2891
+ };
2892
+ }
2893
+ //#endregion
2894
+ //#region src/extensions/SuggestionMenu/SuggestionMenu.ts
2895
+ var Mr = p((e) => e.type.name === "blockContainer"), Nr = class {
2896
+ state;
2897
+ emitUpdate;
2898
+ rootEl;
2899
+ pluginState;
2900
+ constructor(e, t, n) {
2901
+ this.editor = e, this.pluginState = void 0, this.emitUpdate = (e) => {
2902
+ if (!this.state) throw Error("Attempting to update uninitialized suggestions menu");
2903
+ t(e, {
2904
+ ...this.state,
2905
+ ignoreQueryLength: this.pluginState?.ignoreQueryLength
2906
+ });
2907
+ }, this.rootEl = n.root, this.rootEl?.addEventListener("scroll", this.handleScroll, !0);
2908
+ }
2909
+ handleScroll = () => {
2910
+ if (this.state?.show) {
2911
+ let e = this.rootEl?.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);
2912
+ if (!e) return;
2913
+ this.state.referencePos = e.getBoundingClientRect().toJSON(), this.emitUpdate(this.pluginState.triggerCharacter);
2914
+ }
2915
+ };
2916
+ update(e, t) {
2917
+ let n = Q.getState(t), r = Q.getState(e.state), i = n === void 0 && r !== void 0, a = n !== void 0 && r === void 0;
2918
+ if (!i && !(n !== void 0 && r !== void 0) && !a) return;
2919
+ if (this.pluginState = a ? n : r, a || !this.editor.isEditable) {
2920
+ this.state && (this.state.show = !1), this.emitUpdate(this.pluginState.triggerCharacter);
2921
+ return;
2922
+ }
2923
+ let o = this.rootEl?.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);
2924
+ this.editor.isEditable && o && (this.state = {
2925
+ show: !0,
2926
+ referencePos: o.getBoundingClientRect().toJSON(),
2927
+ query: this.pluginState.query
2928
+ }, this.emitUpdate(this.pluginState.triggerCharacter));
2929
+ }
2930
+ destroy() {
2931
+ this.rootEl?.removeEventListener("scroll", this.handleScroll, !0);
2932
+ }
2933
+ closeMenu = () => {
2934
+ this.editor.transact((e) => e.setMeta(Q, null));
2935
+ };
2936
+ clearQuery = () => {
2937
+ this.pluginState !== void 0 && this.editor._tiptapEditor.chain().focus().deleteRange({
2938
+ from: this.pluginState.queryStartPos() - (this.pluginState.deleteTriggerCharacter ? this.pluginState.triggerCharacter.length : 0),
2939
+ to: this.editor.transact((e) => e.selection.from)
2940
+ }).run();
2941
+ };
2942
+ }, Q = new v("SuggestionMenuPlugin"), Pr = t(({ editor: t }) => {
2943
+ let n = /* @__PURE__ */ new Map(), r, i = e(void 0);
2944
+ return {
2945
+ key: "suggestionMenu",
2946
+ store: i,
2947
+ addSuggestionMenu: (e) => {
2948
+ n.set(e.triggerCharacter, e);
2949
+ },
2950
+ removeSuggestionMenu: (e) => {
2951
+ n.delete(e);
2952
+ },
2953
+ closeMenu: () => {
2954
+ r?.closeMenu();
2955
+ },
2956
+ clearQuery: () => {
2957
+ r?.clearQuery();
2958
+ },
2959
+ shown: () => r?.state?.show || !1,
2960
+ openSuggestionMenu: (e, n) => {
2961
+ t.headless || (t.focus(), t.transact((t) => {
2962
+ n?.deleteTriggerCharacter && t.insertText(e), t.scrollIntoView().setMeta(Q, {
2963
+ triggerCharacter: e,
2964
+ deleteTriggerCharacter: n?.deleteTriggerCharacter || !1,
2965
+ ignoreQueryLength: n?.ignoreQueryLength || !1
2966
+ });
2967
+ }));
2968
+ },
2969
+ prosemirrorPlugins: [new _({
2970
+ key: Q,
2971
+ view: (e) => (r = new Nr(t, (e, t) => {
2972
+ i.setState({
2973
+ ...t,
2974
+ triggerCharacter: e
2975
+ });
2976
+ }, e), r),
2977
+ state: {
2978
+ init() {},
2979
+ apply: (e, n, i, a) => {
2980
+ if (e.selection.$from.parent.type.spec.code) return n;
2981
+ let o = e.getMeta(Q);
2982
+ if (typeof o == "object" && o) {
2983
+ n && r?.closeMenu();
2984
+ let e = jr(t, a.selection.from - o.triggerCharacter.length);
2985
+ return {
2986
+ triggerCharacter: o.triggerCharacter,
2987
+ deleteTriggerCharacter: o.deleteTriggerCharacter !== !1,
2988
+ queryStartPos: () => e() + o.triggerCharacter.length,
2989
+ query: "",
2990
+ decorationId: `id_${Math.floor(Math.random() * 4294967295)}`,
2991
+ ignoreQueryLength: o?.ignoreQueryLength
2992
+ };
2993
+ }
2994
+ if (n === void 0) return n;
2995
+ if (a.selection.from !== a.selection.to || o === null || e.getMeta("focus") || e.getMeta("blur") || e.getMeta("pointer") || n.triggerCharacter !== void 0 && a.selection.from < n.queryStartPos() || !a.selection.$from.sameParent(a.doc.resolve(n.queryStartPos()))) return;
2996
+ let s = { ...n };
2997
+ return s.query = a.doc.textBetween(n.queryStartPos(), a.selection.from), s;
2998
+ }
2999
+ },
3000
+ props: {
3001
+ handleTextInput(e, t, r, i) {
3002
+ if (t === r) {
3003
+ let r = e.state.doc;
3004
+ for (let [a, o] of n) {
3005
+ let n = a.length > 1 ? r.textBetween(t - a.length, t) + i : i;
3006
+ if (a === n) {
3007
+ if (o.shouldOpen && !o.shouldOpen(e.state.tr)) continue;
3008
+ return e.dispatch(e.state.tr.insertText(i)), e.dispatch(e.state.tr.setMeta(Q, { triggerCharacter: n }).scrollIntoView()), !0;
3009
+ }
3010
+ }
3011
+ }
3012
+ return !1;
3013
+ },
3014
+ decorations(e) {
3015
+ let t = this.getState(e);
3016
+ if (t === void 0) return null;
3017
+ if (!t.deleteTriggerCharacter) {
3018
+ let n = Mr(e.selection);
3019
+ if (n) return ve.create(e.doc, [_e.node(n.pos, n.pos + n.node.nodeSize, {
3020
+ nodeName: "span",
3021
+ class: "bn-suggestion-decorator",
3022
+ "data-decoration-id": t.decorationId
3023
+ })]);
3024
+ }
3025
+ return ve.create(e.doc, [_e.inline(t.queryStartPos() - t.triggerCharacter.length, t.queryStartPos(), {
3026
+ nodeName: "span",
3027
+ class: "bn-suggestion-decorator",
3028
+ "data-decoration-id": t.decorationId
3029
+ })]);
3030
+ }
3031
+ }
3032
+ })]
3033
+ };
3034
+ });
3035
+ //#endregion
3036
+ //#region src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts
3037
+ function Fr(e) {
3038
+ let t = e.getTextCursorPosition().block, n = e.schema.blockSchema[t.type].content;
3039
+ for (; n === "none";) {
3040
+ if (t = e.getTextCursorPosition().nextBlock, t === void 0) return;
3041
+ n = e.schema.blockSchema[t.type].content, e.setTextCursorPosition(t, "end");
3042
+ }
3043
+ }
3044
+ function $(e, t) {
3045
+ let n = e.getTextCursorPosition().block;
3046
+ if (n.content === void 0) throw Error("Slash Menu open in a block that doesn't contain content.");
3047
+ let r;
3048
+ return Array.isArray(n.content) && (n.content.length === 1 && y(n.content[0]) && n.content[0].type === "text" && n.content[0].text === "/" || n.content.length === 0) ? (r = e.updateBlock(n, t), e.setTextCursorPosition(r)) : (r = e.insertBlocks([t], n, "after")[0], e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)), Fr(e), r;
3049
+ }
3050
+ function Ir(e) {
3051
+ let t = [];
3052
+ return Z(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e <= 3).forEach((n) => {
3053
+ t.push({
3054
+ onItemClick: () => {
3055
+ $(e, {
3056
+ type: "heading",
3057
+ props: { level: n }
3058
+ });
3059
+ },
3060
+ badge: C(`Mod-Alt-${n}`),
3061
+ key: n === 1 ? "heading" : `heading_${n}`,
3062
+ ...e.dictionary.slash_menu[n === 1 ? "heading" : `heading_${n}`]
3063
+ });
3064
+ }), Z(e, "quote") && t.push({
3065
+ onItemClick: () => {
3066
+ $(e, { type: "quote" });
3067
+ },
3068
+ key: "quote",
3069
+ ...e.dictionary.slash_menu.quote
3070
+ }), Z(e, "toggleListItem") && t.push({
3071
+ onItemClick: () => {
3072
+ $(e, { type: "toggleListItem" });
3073
+ },
3074
+ badge: C("Mod-Shift-6"),
3075
+ key: "toggle_list",
3076
+ ...e.dictionary.slash_menu.toggle_list
3077
+ }), Z(e, "numberedListItem") && t.push({
3078
+ onItemClick: () => {
3079
+ $(e, { type: "numberedListItem" });
3080
+ },
3081
+ badge: C("Mod-Shift-7"),
3082
+ key: "numbered_list",
3083
+ ...e.dictionary.slash_menu.numbered_list
3084
+ }), Z(e, "bulletListItem") && t.push({
3085
+ onItemClick: () => {
3086
+ $(e, { type: "bulletListItem" });
3087
+ },
3088
+ badge: C("Mod-Shift-8"),
3089
+ key: "bullet_list",
3090
+ ...e.dictionary.slash_menu.bullet_list
3091
+ }), Z(e, "checkListItem") && t.push({
3092
+ onItemClick: () => {
3093
+ $(e, { type: "checkListItem" });
3094
+ },
3095
+ badge: C("Mod-Shift-9"),
3096
+ key: "check_list",
3097
+ ...e.dictionary.slash_menu.check_list
3098
+ }), Z(e, "paragraph") && t.push({
3099
+ onItemClick: () => {
3100
+ $(e, { type: "paragraph" });
3101
+ },
3102
+ badge: C("Mod-Alt-0"),
3103
+ key: "paragraph",
3104
+ ...e.dictionary.slash_menu.paragraph
3105
+ }), Z(e, "codeBlock") && t.push({
3106
+ onItemClick: () => {
3107
+ $(e, { type: "codeBlock" });
3108
+ },
3109
+ badge: C("Mod-Alt-c"),
3110
+ key: "code_block",
3111
+ ...e.dictionary.slash_menu.code_block
3112
+ }), Z(e, "divider") && t.push({
3113
+ onItemClick: () => {
3114
+ $(e, { type: "divider" });
3115
+ },
3116
+ key: "divider",
3117
+ ...e.dictionary.slash_menu.divider
3118
+ }), Z(e, "table") && t.push({
3119
+ onItemClick: () => {
3120
+ $(e, {
3121
+ type: "table",
3122
+ content: {
3123
+ type: "tableContent",
3124
+ rows: [{ cells: [
3125
+ "",
3126
+ "",
3127
+ ""
3128
+ ] }, { cells: [
3129
+ "",
3130
+ "",
3131
+ ""
3132
+ ] }]
3133
+ }
3134
+ });
3135
+ },
3136
+ badge: void 0,
3137
+ key: "table",
3138
+ ...e.dictionary.slash_menu.table
3139
+ }), Z(e, "image", { url: "string" }) && t.push({
3140
+ onItemClick: () => {
3141
+ let t = $(e, { type: "image" });
3142
+ e.getExtension(Y)?.showMenu(t.id);
3143
+ },
3144
+ key: "image",
3145
+ ...e.dictionary.slash_menu.image
3146
+ }), Z(e, "video", { url: "string" }) && t.push({
3147
+ onItemClick: () => {
3148
+ let t = $(e, { type: "video" });
3149
+ e.getExtension(Y)?.showMenu(t.id);
3150
+ },
3151
+ key: "video",
3152
+ ...e.dictionary.slash_menu.video
3153
+ }), Z(e, "audio", { url: "string" }) && t.push({
3154
+ onItemClick: () => {
3155
+ let t = $(e, { type: "audio" });
3156
+ e.getExtension(Y)?.showMenu(t.id);
3157
+ },
3158
+ key: "audio",
3159
+ ...e.dictionary.slash_menu.audio
3160
+ }), Z(e, "file", { url: "string" }) && t.push({
3161
+ onItemClick: () => {
3162
+ let t = $(e, { type: "file" });
3163
+ e.getExtension(Y)?.showMenu(t.id);
3164
+ },
3165
+ key: "file",
3166
+ ...e.dictionary.slash_menu.file
3167
+ }), Z(e, "heading", {
3168
+ level: "number",
3169
+ isToggleable: "boolean"
3170
+ }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e <= 3).forEach((n) => {
3171
+ t.push({
3172
+ onItemClick: () => {
3173
+ $(e, {
3174
+ type: "heading",
3175
+ props: {
3176
+ level: n,
3177
+ isToggleable: !0
3178
+ }
3179
+ });
3180
+ },
3181
+ key: n === 1 ? "toggle_heading" : `toggle_heading_${n}`,
3182
+ ...e.dictionary.slash_menu[n === 1 ? "toggle_heading" : `toggle_heading_${n}`]
3183
+ });
3184
+ }), Z(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e > 3).forEach((n) => {
3185
+ t.push({
3186
+ onItemClick: () => {
3187
+ $(e, {
3188
+ type: "heading",
3189
+ props: { level: n }
3190
+ });
3191
+ },
3192
+ badge: C(`Mod-Alt-${n}`),
3193
+ key: `heading_${n}`,
3194
+ ...e.dictionary.slash_menu[`heading_${n}`]
3195
+ });
3196
+ }), t.push({
3197
+ onItemClick: () => {
3198
+ e.getExtension(Pr)?.openSuggestionMenu(":", {
3199
+ deleteTriggerCharacter: !0,
3200
+ ignoreQueryLength: !0
3201
+ });
3202
+ },
3203
+ key: "emoji",
3204
+ ...e.dictionary.slash_menu.emoji
3205
+ }), t;
3206
+ }
3207
+ function Lr(e, t) {
3208
+ return e.filter(({ title: e, aliases: n }) => e.toLowerCase().includes(t.toLowerCase()) || n && n.filter((e) => e.toLowerCase().includes(t.toLowerCase())).length !== 0);
3209
+ }
3210
+ //#endregion
3211
+ //#region src/blocks/PageBreak/getPageBreakSlashMenuItems.ts
3212
+ function Rr(e) {
3213
+ return "pageBreak" in e.schema.blockSchema;
3214
+ }
3215
+ function zr(e) {
3216
+ let t = [];
3217
+ return Rr(e) && t.push({
3218
+ ...e.dictionary.slash_menu.page_break,
3219
+ onItemClick: () => {
3220
+ $(e, { type: "pageBreak" });
3221
+ },
3222
+ key: "page_break"
3223
+ }), t;
3224
+ }
3225
+ //#endregion
3226
+ //#region src/blocks/defaultBlocks.ts
3227
+ var Br = {
3228
+ audio: mn(),
3229
+ bulletListItem: qn(),
3230
+ checkListItem: Yn(),
3231
+ codeBlock: yn(),
3232
+ divider: Sn(),
3233
+ file: En(),
3234
+ heading: Nn(),
3235
+ image: Vn(),
3236
+ numberedListItem: er(),
3237
+ paragraph: sr(),
3238
+ quote: lr(),
3239
+ table: br(),
3240
+ toggleListItem: nr(),
3241
+ video: Tr()
3242
+ }, Vr = ht({
3243
+ type: "textColor",
3244
+ propSchema: "string"
3245
+ }, {
3246
+ render: () => {
3247
+ let e = document.createElement("span");
3248
+ return {
3249
+ dom: e,
3250
+ contentDOM: e
3251
+ };
3252
+ },
3253
+ toExternalHTML: (e) => {
3254
+ let t = document.createElement("span");
3255
+ return e !== K.textColor.default && (t.style.color = e in G ? G[e].text : e), {
3256
+ dom: t,
3257
+ contentDOM: t
3258
+ };
3259
+ },
3260
+ parse: (e) => {
3261
+ if (e.tagName === "SPAN" && e.style.color) return e.style.color;
3262
+ }
3263
+ }), Hr = ht({
3264
+ type: "backgroundColor",
3265
+ propSchema: "string"
3266
+ }, {
3267
+ render: () => {
3268
+ let e = document.createElement("span");
3269
+ return {
3270
+ dom: e,
3271
+ contentDOM: e
3272
+ };
3273
+ },
3274
+ toExternalHTML: (e) => {
3275
+ let t = document.createElement("span");
3276
+ return e !== K.backgroundColor.default && (t.style.backgroundColor = e in G ? G[e].background : e), {
3277
+ dom: t,
3278
+ contentDOM: t
3279
+ };
3280
+ },
3281
+ parse: (e) => {
3282
+ if (e.tagName === "SPAN" && e.style.backgroundColor) return e.style.backgroundColor;
3283
+ }
3284
+ }), Ur = {
3285
+ bold: R(Se, "boolean"),
3286
+ italic: R(we, "boolean"),
3287
+ underline: R(Ee, "boolean"),
3288
+ strike: R(Te, "boolean"),
3289
+ code: R(Ce, "boolean"),
3290
+ textColor: Vr,
3291
+ backgroundColor: Hr
3292
+ }, Wr = pt(Ur), Gr = {
3293
+ text: {
3294
+ config: "text",
3295
+ implementation: {}
3296
+ },
3297
+ link: {
3298
+ config: "link",
3299
+ implementation: {}
3300
+ }
3301
+ }, Kr = ut(Gr), qr = class e extends Tt {
3302
+ static create(t) {
3303
+ return new e({
3304
+ blockSpecs: t?.blockSpecs ?? Br,
3305
+ inlineContentSpecs: t?.inlineContentSpecs ?? Gr,
3306
+ styleSpecs: t?.styleSpecs ?? Ur
3307
+ });
3308
+ }
3309
+ };
3310
+ //#endregion
3311
+ export { En as $, ct as $t, rr as A, He as An, Vt as At, qn as B, x as Bn, jt as Bt, pr as C, qe as Cn, Jt as Ct, lr as D, E as Dn, Wt as Dt, cr as E, Ue as En, Ut as Et, $n as F, Ie as Fn, Nt as Ft, Rn as G, Ae as Gn, L as Gt, In as H, b as Hn, Ct as Ht, er as I, Le as In, kt as It, Mn as J, ke as Jn, pt as Jt, zn as K, je as Kn, ft as Kt, Yn as L, w as Ln, Ot as Lt, ar as M, ze as Mn, Lt as Mt, tr as N, Be as Nn, It as Nt, or as O, T as On, U as Ot, nr as P, C as Pn, Ft as Pt, wn as Q, lt as Qt, Jn as R, S as Rn, Et as Rt, br as S, O as Sn, Yt as St, ur as T, We as Tn, W as Tt, Ln as U, Ne as Un, ht as Ut, Hn as V, Pe as Vn, Tt as Vt, Vn as W, Me as Wn, mt as Wt, kn as X, ot as Xt, Nn as Y, dt as Yt, On as Z, st as Zt, Er as _, Xe as _n, en as _t, Wr as a, rt as an, bn as at, Tr as b, Ke as bn, Zt as bt, zr as c, j as cn, fn as ct, $ as d, A as dn, mn as dt, ut as en, Tn as et, Pr as f, P as fn, cn as ft, Or as g, $e as gn, Qt as gt, Z as h, Qe as hn, K as ht, Gr as i, I as in, yn as it, ir as j, Re as jn, Pt as jt, sr as k, Ve as kn, H as kt, Lr as l, M as ln, pn as lt, Dr as m, Ze as mn, J as mt, Br as n, tt as nn, Sn as nt, Ur as o, at as on, ln as ot, jr as p, k as pn, Y as pt, Bn as q, y as qn, R as qt, Kr as r, it as rn, vn as rt, Rr as s, F as sn, dn as st, qr as t, nt as tn, xn as tt, Ir as u, N as un, un as ut, Sr as v, Ye as vn, $t as vt, dr as w, Ge as wn, Gt as wt, wr as x, D as xn, G as xt, Cr as y, Je as yn, q as yt, Kn as z, Fe as zn, At as zt };
3312
+
3313
+ //# sourceMappingURL=blocks-DYl7UTS4.js.map