@blocknote/core 0.41.1 → 0.42.1

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