@blocknote/core 0.32.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/blocknote.js CHANGED
@@ -3,8 +3,8 @@ var co = (e, n, t) => n in e ? lo(e, n, { enumerable: !0, configurable: !0, writ
3
3
  var p = (e, n, t) => co(e, typeof n != "symbol" ? n + "" : n, t);
4
4
  import { Slice as X, Fragment as R, DOMSerializer as cn, DOMParser as je, Node as uo } from "prosemirror-model";
5
5
  import { ReplaceStep as dn, ReplaceAroundStep as rt, Mapping as po } from "prosemirror-transform";
6
- import { Extension as _, combineTransactionSteps as un, getChangedRanges as pn, findChildrenInRange as st, Node as oe, Mark as re, isTextSelection as hn, InputRule as ce, callOrReturn as ho, getExtensionField as fo, mergeAttributes as wt, selectionToInsertionEnd as mo, isNodeSelection as it, posToDOMRect as _e, getMarkRange as Ht, findChildren as Dt, findParentNode as go, extensions as ke, Editor as bo, createDocument as ko, getSchema as wo } from "@tiptap/core";
7
- import { Plugin as N, PluginKey as U, TextSelection as O, NodeSelection as ge, Selection as Re, EditorState as yo } from "prosemirror-state";
6
+ import { Extension as _, combineTransactionSteps as un, getChangedRanges as pn, findChildrenInRange as st, Node as oe, Mark as re, isTextSelection as hn, InputRule as ce, callOrReturn as ho, getExtensionField as fo, mergeAttributes as wt, selectionToInsertionEnd as mo, isNodeSelection as it, posToDOMRect as Ue, getMarkRange as Ht, findChildren as Dt, findParentNode as go, extensions as we, Editor as bo, createDocument as ko, getSchema as wo } from "@tiptap/core";
7
+ import { Plugin as N, PluginKey as U, TextSelection as O, NodeSelection as be, Selection as Ve, EditorState as yo } from "prosemirror-state";
8
8
  import { v4 as fn } from "uuid";
9
9
  import { createHighlightPlugin as Co } from "prosemirror-highlight";
10
10
  import { createParser as vo } from "prosemirror-highlight/shiki";
@@ -15,12 +15,12 @@ import xo from "@tiptap/extension-strike";
15
15
  import Mo from "@tiptap/extension-underline";
16
16
  import { TableCell as To } from "@tiptap/extension-table-cell";
17
17
  import { TableHeader as Po } from "@tiptap/extension-table-header";
18
- import { goToNextCell as Ot, columnResizing as Io, tableEditing as Lo, TableView as Ao, CellSelection as Se, TableMap as Rt, addRowBefore as No, addRowAfter as Ho, addColumnBefore as Do, addColumnAfter as Oo, deleteRow as Ro, deleteColumn as Vo, mergeCells as _o, splitCell as Uo } from "prosemirror-tables";
18
+ import { goToNextCell as Ot, columnResizing as Io, tableEditing as Lo, TableView as Ao, CellSelection as Be, TableMap as Rt, addRowBefore as No, addRowAfter as Ho, addColumnBefore as Do, addColumnAfter as Oo, deleteRow as Ro, deleteColumn as Vo, mergeCells as _o, splitCell as Uo } from "prosemirror-tables";
19
19
  import { Gapcursor as $o } from "@tiptap/extension-gapcursor";
20
20
  import { History as Fo } from "@tiptap/extension-history";
21
21
  import { Link as zo } from "@tiptap/extension-link";
22
22
  import { Text as Wo } from "@tiptap/extension-text";
23
- import { yCursorPlugin as jo, defaultSelectionBuilder as Go, ySyncPlugin as qo, yUndoPlugin as Ko, ySyncPluginKey as de, getRelativeSelection as Jo, absolutePositionToRelativePosition as Xo, relativePositionToAbsolutePosition as Yo, yUndoPluginKey as Le, yCursorPluginKey as Zo, undoCommand as Qo, redoCommand as er } from "y-prosemirror";
23
+ import { yCursorPlugin as jo, defaultSelectionBuilder as Go, ySyncPlugin as qo, yUndoPlugin as Ko, ySyncPluginKey as de, getRelativeSelection as Jo, absolutePositionToRelativePosition as Xo, relativePositionToAbsolutePosition as Yo, yUndoPluginKey as Ae, yCursorPluginKey as Zo, undoCommand as Qo, redoCommand as er } from "y-prosemirror";
24
24
  import { DecorationSet as G, Decoration as Y, EditorView as tr } from "prosemirror-view";
25
25
  import * as ie from "yjs";
26
26
  import { undo as nr, redo as or } from "prosemirror-history";
@@ -240,7 +240,7 @@ function ue(e) {
240
240
  }
241
241
  function at(e) {
242
242
  var n, t, o, r, s;
243
- return yt(e) ? { ...e } : Ce(e) ? {
243
+ return yt(e) ? { ...e } : ve(e) ? {
244
244
  type: "tableCell",
245
245
  content: [].concat(e.content),
246
246
  props: {
@@ -262,13 +262,13 @@ function at(e) {
262
262
  }
263
263
  };
264
264
  }
265
- function Ce(e) {
265
+ function ve(e) {
266
266
  return e != null && typeof e != "string" && !Array.isArray(e) && e.type === "tableCell";
267
267
  }
268
268
  function yt(e) {
269
- return Ce(e) && e.props !== void 0 && e.content !== void 0;
269
+ return ve(e) && e.props !== void 0 && e.content !== void 0;
270
270
  }
271
- function ve(e) {
271
+ function Ee(e) {
272
272
  return yt(e) ? e.props.colspan ?? 1 : 1;
273
273
  }
274
274
  function lt(e) {
@@ -289,7 +289,12 @@ function J(e, n = "Ctrl") {
289
289
  return lr() ? e.replace("Mod", "⌘") : e.replace("Mod", n);
290
290
  }
291
291
  function te(...e) {
292
- return e.filter((n) => n).join(" ");
292
+ return [
293
+ // Converts to & from set to remove duplicates.
294
+ ...new Set(
295
+ e.filter((n) => n).join(" ").split(" ")
296
+ )
297
+ ].join(" ");
293
298
  }
294
299
  const Hl = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
295
300
  function $(e, n, t, o) {
@@ -351,7 +356,7 @@ const T = {
351
356
  values: ["left", "center", "right", "justify"]
352
357
  }
353
358
  }, gn = ["backgroundColor", "textColor"];
354
- function Ue(e) {
359
+ function $e(e) {
355
360
  return "data-" + e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
356
361
  }
357
362
  function Ol(e) {
@@ -359,7 +364,7 @@ function Ol(e) {
359
364
  return !n.length || // invalid?
360
365
  n[n.length - 1] === "" ? e : n[n.length - 1];
361
366
  }
362
- function Be(e) {
367
+ function xe(e) {
363
368
  const n = {};
364
369
  return Object.entries(e).filter(([t, o]) => !gn.includes(t)).forEach(([t, o]) => {
365
370
  n[t] = {
@@ -369,7 +374,7 @@ function Be(e) {
369
374
  // value is the same as its default, we don't display an HTML
370
375
  // attribute for it.
371
376
  parseHTML: (r) => {
372
- const s = r.getAttribute(Ue(t));
377
+ const s = r.getAttribute($e(t));
373
378
  if (s === null)
374
379
  return null;
375
380
  if (o.default === void 0 && o.type === "boolean" || o.default !== void 0 && typeof o.default == "boolean")
@@ -381,7 +386,7 @@ function Be(e) {
381
386
  return s;
382
387
  },
383
388
  renderHTML: (r) => r[t] !== o.default ? {
384
- [Ue(t)]: r[t]
389
+ [$e(t)]: r[t]
385
390
  } : {}
386
391
  };
387
392
  }), n;
@@ -399,7 +404,7 @@ function Ct(e, n, t, o) {
399
404
  throw new Error("Block type does not match");
400
405
  return a;
401
406
  }
402
- function Ae(e, n, t, o, r = !1, s) {
407
+ function Ne(e, n, t, o, r = !1, s) {
403
408
  const i = document.createElement("div");
404
409
  if (s !== void 0)
405
410
  for (const [a, l] of Object.entries(s))
@@ -410,7 +415,7 @@ function Ae(e, n, t, o, r = !1, s) {
410
415
  ), i.setAttribute("data-content-type", n);
411
416
  for (const [a, l] of Object.entries(t)) {
412
417
  const d = o[a].default;
413
- !gn.includes(a) && l !== d && i.setAttribute(Ue(a), l);
418
+ !gn.includes(a) && l !== d && i.setAttribute($e(a), l);
414
419
  }
415
420
  return r && i.setAttribute("data-file-block", ""), i.appendChild(e.dom), e.contentDOM !== void 0 && (e.contentDOM.className = te(
416
421
  "bn-inline-content",
@@ -472,7 +477,7 @@ function dr(e, n) {
472
477
  }
473
478
  }), t;
474
479
  }
475
- function xe(e, n) {
480
+ function Me(e, n) {
476
481
  const t = K({
477
482
  name: e.type,
478
483
  content: e.content === "inline" ? "inline*" : "",
@@ -480,14 +485,14 @@ function xe(e, n) {
480
485
  selectable: e.isSelectable ?? !0,
481
486
  isolating: !0,
482
487
  addAttributes() {
483
- return Be(e.propSchema);
488
+ return xe(e.propSchema);
484
489
  },
485
490
  parseHTML() {
486
491
  return dr(e, n.parse);
487
492
  },
488
493
  renderHTML({ HTMLAttributes: o }) {
489
494
  const r = document.createElement("div");
490
- return Ae(
495
+ return Ne(
491
496
  {
492
497
  dom: r,
493
498
  contentDOM: e.content === "inline" ? r : void 0
@@ -507,7 +512,7 @@ function xe(e, n) {
507
512
  r,
508
513
  this.editor,
509
514
  e.type
510
- ), i = ((c = this.options.domAttributes) == null ? void 0 : c.blockContent) || {}, a = n.render(s, r), l = Ae(
515
+ ), i = ((c = this.options.domAttributes) == null ? void 0 : c.blockContent) || {}, a = n.render(s, r), l = Ne(
511
516
  a,
512
517
  s.type,
513
518
  s.props,
@@ -528,7 +533,7 @@ function xe(e, n) {
528
533
  toInternalHTML: (o, r) => {
529
534
  var a;
530
535
  const s = ((a = t.options.domAttributes) == null ? void 0 : a.blockContent) || {}, i = n.render(o, r);
531
- return Ae(
536
+ return Ne(
532
537
  i,
533
538
  o.type,
534
539
  o.props,
@@ -547,7 +552,7 @@ function xe(e, n) {
547
552
  o,
548
553
  r
549
554
  );
550
- return i === void 0 && (i = n.render(o, r)), Ae(
555
+ return i === void 0 && (i = n.render(o, r)), Ne(
551
556
  i,
552
557
  o.type,
553
558
  o.props,
@@ -640,7 +645,7 @@ function vt(e, n) {
640
645
  function ne(e) {
641
646
  return vt(e.node, e.posBeforeNode);
642
647
  }
643
- function Me(e) {
648
+ function Te(e) {
644
649
  if (!e.nodeAfter)
645
650
  throw new Error(
646
651
  `Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`
@@ -661,17 +666,17 @@ function I(e) {
661
666
  function wn(e) {
662
667
  return e.cached.blockNoteEditor;
663
668
  }
664
- function Te(e) {
669
+ function Pe(e) {
665
670
  return wn(e).schema;
666
671
  }
667
672
  function Et(e) {
668
- return Te(e).blockSchema;
673
+ return Pe(e).blockSchema;
669
674
  }
670
675
  function St(e) {
671
- return Te(e).inlineContentSchema;
676
+ return Pe(e).inlineContentSchema;
672
677
  }
673
- function be(e) {
674
- return Te(e).styleSchema;
678
+ function ke(e) {
679
+ return Pe(e).styleSchema;
675
680
  }
676
681
  function Bt(e) {
677
682
  return wn(e).blockCache;
@@ -845,7 +850,7 @@ function ct(e, n, t) {
845
850
  content: s
846
851
  };
847
852
  }
848
- function v(e, n, t = Et(n), o = St(n), r = be(n), s = Bt(n)) {
853
+ function v(e, n, t = Et(n), o = St(n), r = ke(n), s = Bt(n)) {
849
854
  var g;
850
855
  if (!e.type.isInGroup("bnBlock"))
851
856
  throw Error("Node should be a bnBlock, but is instead: " + e.type.name);
@@ -909,7 +914,7 @@ function v(e, n, t = Et(n), o = St(n), r = be(n), s = Bt(n)) {
909
914
  };
910
915
  return s == null || s.set(e, m), m;
911
916
  }
912
- function ur(e, n, t = Et(n), o = St(n), r = be(n), s = Bt(n)) {
917
+ function ur(e, n, t = Et(n), o = St(n), r = ke(n), s = Bt(n)) {
913
918
  const i = [];
914
919
  return e.firstChild.descendants((a) => (i.push(
915
920
  v(
@@ -922,7 +927,7 @@ function ur(e, n, t = Et(n), o = St(n), r = be(n), s = Bt(n)) {
922
927
  )
923
928
  ), !1)), i;
924
929
  }
925
- function pr(e, n, t = Et(n), o = St(n), r = be(n), s = Bt(n)) {
930
+ function pr(e, n, t = Et(n), o = St(n), r = ke(n), s = Bt(n)) {
926
931
  function i(a, l, c) {
927
932
  if (a.type.name !== "blockGroup")
928
933
  throw new Error("unexpected");
@@ -993,7 +998,7 @@ function Ut(e, n, t, o) {
993
998
  return e.dom.setAttribute("data-inline-content-type", n), Object.entries(t).filter(([r, s]) => {
994
999
  const i = o[r];
995
1000
  return s !== i.default;
996
- }).map(([r, s]) => [Ue(r), s]).forEach(([r, s]) => e.dom.setAttribute(r, s)), e.contentDOM !== void 0 && e.contentDOM.setAttribute("data-editable", ""), e;
1001
+ }).map(([r, s]) => [$e(r), s]).forEach(([r, s]) => e.dom.setAttribute(r, s)), e.contentDOM !== void 0 && e.contentDOM.setAttribute("data-editable", ""), e;
997
1002
  }
998
1003
  function hr(e) {
999
1004
  return {
@@ -1046,7 +1051,7 @@ function Rl(e, n) {
1046
1051
  atom: e.content === "none",
1047
1052
  content: e.content === "styled" ? "inline*" : "",
1048
1053
  addAttributes() {
1049
- return Be(e.propSchema);
1054
+ return xe(e.propSchema);
1050
1055
  },
1051
1056
  addKeyboardShortcuts() {
1052
1057
  return hr(e);
@@ -1195,7 +1200,7 @@ function se(e) {
1195
1200
  };
1196
1201
  for (let s = 0; s < e.content.rows.length; s++)
1197
1202
  for (let i = 0; i < e.content.rows[s].cells.length; i++) {
1198
- const a = at(e.content.rows[s].cells[i]), l = lt(a), c = ve(a), { row: d, col: u } = r(s, i);
1203
+ const a = at(e.content.rows[s].cells[i]), l = lt(a), c = Ee(a), { row: d, col: u } = r(s, i);
1199
1204
  for (let h = d; h < d + l; h++)
1200
1205
  for (let f = u; f < u + c; f++) {
1201
1206
  if (o[h][f])
@@ -1213,7 +1218,7 @@ function se(e) {
1213
1218
  }
1214
1219
  return o;
1215
1220
  }
1216
- function Ee(e) {
1221
+ function Se(e) {
1217
1222
  const n = /* @__PURE__ */ new Set();
1218
1223
  return e.map((t) => ({
1219
1224
  cells: t.map((o) => n.has(o.row + ":" + o.col) ? !1 : (n.add(o.row + ":" + o.col), o.cell)).filter((o) => o !== !1)
@@ -1236,7 +1241,7 @@ function xt(e) {
1236
1241
  return e.content.rows.forEach((o) => {
1237
1242
  let r = 0;
1238
1243
  o.cells.forEach((s) => {
1239
- r += ve(s);
1244
+ r += Ee(s);
1240
1245
  }), t = Math.max(t, r);
1241
1246
  }), { height: n, width: t };
1242
1247
  }
@@ -1311,7 +1316,7 @@ function yr(e, n, t, o = se(e)) {
1311
1316
  return o.forEach((i) => {
1312
1317
  const [a] = i.splice(r, 1);
1313
1318
  i.splice(s, 0, a);
1314
- }), Ee(o);
1319
+ }), Se(o);
1315
1320
  }
1316
1321
  function Cr(e, n, t, o = se(e)) {
1317
1322
  const { row: r } = pe(
@@ -1329,10 +1334,10 @@ function Cr(e, n, t, o = se(e)) {
1329
1334
  e,
1330
1335
  o
1331
1336
  ), [i] = o.splice(r, 1);
1332
- return o.splice(s, 0, i), Ee(o);
1337
+ return o.splice(s, 0, i), Se(o);
1333
1338
  }
1334
1339
  function pt(e) {
1335
- return e ? Ce(e) ? pt(e.content) : typeof e == "string" ? e.length === 0 : Array.isArray(e) ? e.every(
1340
+ return e ? ve(e) ? pt(e.content) : typeof e == "string" ? e.length === 0 : Array.isArray(e) ? e.every(
1336
1341
  (n) => typeof n == "string" ? n.length === 0 : ue(n) ? n.text.length === 0 : mn(n) ? typeof n.content == "string" ? n.content.length === 0 : n.content.every((t) => t.text.length === 0) : !1
1337
1342
  ) : !1 : !0;
1338
1343
  }
@@ -1350,7 +1355,7 @@ function vr(e, n, t = se(e)) {
1350
1355
  );
1351
1356
  t[i] = t[i].slice(0, a);
1352
1357
  }
1353
- return Ee(t);
1358
+ return Se(t);
1354
1359
  }
1355
1360
  let o = 0;
1356
1361
  for (let s = t.length - 1; s >= 0 && t[s].every(
@@ -1358,7 +1363,7 @@ function vr(e, n, t = se(e)) {
1358
1363
  ); s--)
1359
1364
  o++;
1360
1365
  const r = Math.min(o, t.length - 1);
1361
- return t.splice(t.length - r, r), Ee(t);
1366
+ return t.splice(t.length - r, r), Se(t);
1362
1367
  }
1363
1368
  function Er(e, n, t, o = se(e)) {
1364
1369
  const { width: r, height: s } = xt(e);
@@ -1388,7 +1393,7 @@ function Er(e, n, t, o = se(e)) {
1388
1393
  o.push(a);
1389
1394
  }
1390
1395
  else t < 0 && o.splice(s + t, -1 * t);
1391
- return Ee(o);
1396
+ return Se(o);
1392
1397
  }
1393
1398
  function Bn(e, n, t) {
1394
1399
  const o = dt(e, t);
@@ -1402,11 +1407,11 @@ function Bn(e, n, t) {
1402
1407
  }
1403
1408
  function xn(e, n, t) {
1404
1409
  const o = ut(e, t);
1405
- if (!o.some((l) => ve(l.cell) > 1))
1410
+ if (!o.some((l) => Ee(l.cell) > 1))
1406
1411
  return !0;
1407
1412
  let s = t, i = t;
1408
1413
  return o.forEach((l) => {
1409
- const c = ve(l.cell);
1414
+ const c = Ee(l.cell);
1410
1415
  s = Math.max(s, l.col + c - 1), i = Math.min(i, l.col);
1411
1416
  }), n < t ? t === s : t === i;
1412
1417
  }
@@ -1461,7 +1466,7 @@ function ht(e, n, t, o) {
1461
1466
  );
1462
1467
  return r;
1463
1468
  }
1464
- function W(e, n, t, o = be(n)) {
1469
+ function W(e, n, t, o = ke(n)) {
1465
1470
  const r = [];
1466
1471
  for (const s of e)
1467
1472
  typeof s == "string" ? r.push(
@@ -1473,7 +1478,7 @@ function W(e, n, t, o = be(n)) {
1473
1478
  );
1474
1479
  return r;
1475
1480
  }
1476
- function Je(e, n, t = be(n)) {
1481
+ function Je(e, n, t = ke(n)) {
1477
1482
  const o = [], r = new Array(e.headerRows ?? 0).fill(!0), s = new Array(e.headerCols ?? 0).fill(!0), i = e.columnWidths ?? [];
1478
1483
  for (let a = 0; a < e.rows.length; a++) {
1479
1484
  const l = e.rows[a], c = [], d = r[a];
@@ -1490,14 +1495,14 @@ function Je(e, n, t = be(n)) {
1490
1495
  let w = i[k.col] ? [i[k.col]] : null;
1491
1496
  if (f) if (typeof f == "string")
1492
1497
  b = n.text(f);
1493
- else if (Ce(f)) {
1498
+ else if (ve(f)) {
1494
1499
  f.content && (b = W(
1495
1500
  f.content,
1496
1501
  n,
1497
1502
  "tableParagraph",
1498
1503
  t
1499
1504
  ));
1500
- const x = ve(f);
1505
+ const x = Ee(f);
1501
1506
  x > 1 && (w = new Array(x).fill(!1).map((L, z) => i[k.col + z] ?? void 0));
1502
1507
  } else
1503
1508
  b = W(
@@ -1508,7 +1513,7 @@ function Je(e, n, t = be(n)) {
1508
1513
  );
1509
1514
  const y = n.nodes[m || d ? "tableHeader" : "tableCell"].createChecked(
1510
1515
  {
1511
- ...Ce(f) ? f.props : {},
1516
+ ...ve(f) ? f.props : {},
1512
1517
  colwidth: w
1513
1518
  },
1514
1519
  n.nodes.tableParagraph.createChecked(g, b)
@@ -1549,7 +1554,7 @@ function Mn(e, n, t) {
1549
1554
  throw new q(e.content.type);
1550
1555
  return o;
1551
1556
  }
1552
- function he(e, n, t = be(n)) {
1557
+ function he(e, n, t = ke(n)) {
1553
1558
  let o = e.id;
1554
1559
  o === void 0 && (o = Ge.options.generateID());
1555
1560
  const r = [];
@@ -1702,7 +1707,7 @@ const D = (e, n) => ({
1702
1707
  dispatch: o
1703
1708
  }) => (o && Tn(t, e, n), !0);
1704
1709
  function Tn(e, n, t, o, r) {
1705
- const s = Me(e.doc.resolve(n)), i = I(e);
1710
+ const s = Te(e.doc.resolve(n)), i = I(e);
1706
1711
  if (o !== void 0 && r !== void 0 && o > r)
1707
1712
  throw new Error("Invalid replaceFromPos or replaceToPos");
1708
1713
  const a = i.nodes[s.blockNoteType], l = i.nodes[t.type || s.blockNoteType], c = l.isInGroup("bnBlock") ? l : i.nodes.blockContainer;
@@ -2203,7 +2208,7 @@ const Nn = (e, n, t, o) => {
2203
2208
  return e.props.showPreview ? (n = document.createElement("audio"), n.src = e.props.url) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? Tt(n, e.props.caption) : Ze(n, e.props.caption) : {
2204
2209
  dom: n
2205
2210
  };
2206
- }, jr = xe($r, {
2211
+ }, jr = Me($r, {
2207
2212
  render: Fr,
2208
2213
  parse: zr,
2209
2214
  toExternalHTML: Wr
@@ -2496,7 +2501,7 @@ const Jr = re.create({
2496
2501
  return n.href = e.props.url, n.textContent = e.props.name || e.props.url, e.props.caption ? Ze(n, e.props.caption) : {
2497
2502
  dom: n
2498
2503
  };
2499
- }, rs = xe(es, {
2504
+ }, rs = Me(es, {
2500
2505
  render: ts,
2501
2506
  parse: ns,
2502
2507
  toExternalHTML: os
@@ -2572,7 +2577,7 @@ const Jr = re.create({
2572
2577
  content: "inline*",
2573
2578
  group: "blockContent",
2574
2579
  addAttributes() {
2575
- return Be(Dn);
2580
+ return xe(Dn);
2576
2581
  },
2577
2582
  addInputRules() {
2578
2583
  return [
@@ -2805,7 +2810,7 @@ const Jr = re.create({
2805
2810
  return e.props.showPreview ? (n = document.createElement("img"), n.src = e.props.url, n.alt = e.props.name || e.props.caption || "BlockNote image", e.props.previewWidth && (n.width = e.props.previewWidth)) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? Tt(n, e.props.caption) : Ze(n, e.props.caption) : {
2806
2811
  dom: n
2807
2812
  };
2808
- }, ms = xe(us, {
2813
+ }, ms = Me(us, {
2809
2814
  render: ps,
2810
2815
  parse: hs,
2811
2816
  toExternalHTML: fs
@@ -3048,7 +3053,7 @@ const ws = {
3048
3053
  content: "inline*",
3049
3054
  group: "blockContent",
3050
3055
  addAttributes() {
3051
- return Be(Vn);
3056
+ return xe(Vn);
3052
3057
  },
3053
3058
  addInputRules() {
3054
3059
  return [
@@ -3269,7 +3274,7 @@ const ws = {
3269
3274
  priority: 90,
3270
3275
  addAttributes() {
3271
3276
  return {
3272
- ...Be(_n),
3277
+ ...xe(_n),
3273
3278
  // the index attribute is only used internally (it's not part of the blocknote schema)
3274
3279
  // that's why it's defined explicitly here, and not part of the prop schema
3275
3280
  index: {
@@ -3760,7 +3765,7 @@ const Us = Q(
3760
3765
  return e.props.showPreview ? (n = document.createElement("video"), n.src = e.props.url, e.props.previewWidth && (n.width = e.props.previewWidth)) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? Tt(n, e.props.caption) : Ze(n, e.props.caption) : {
3761
3766
  dom: n
3762
3767
  };
3763
- }, qs = xe(zs, {
3768
+ }, qs = Me(zs, {
3764
3769
  render: Ws,
3765
3770
  parse: js,
3766
3771
  toExternalHTML: Gs
@@ -3817,7 +3822,7 @@ function Wl(e, n, t) {
3817
3822
  return Zs(e, n.type, t);
3818
3823
  }
3819
3824
  function Xt(e) {
3820
- return e instanceof Se;
3825
+ return e instanceof Be;
3821
3826
  }
3822
3827
  const jl = async (e) => {
3823
3828
  const n = new FormData();
@@ -4079,7 +4084,7 @@ function nt(e) {
4079
4084
  Object.entries(e).filter(([, n]) => n !== void 0)
4080
4085
  );
4081
4086
  }
4082
- class Pe {
4087
+ class Ie {
4083
4088
  constructor(n) {
4084
4089
  p(this, "blockSpecs");
4085
4090
  p(this, "inlineContentSpecs");
@@ -4096,7 +4101,7 @@ class Pe {
4096
4101
  ), this.styleSchema = En(this.styleSpecs);
4097
4102
  }
4098
4103
  static create(n) {
4099
- return new Pe(n);
4104
+ return new Ie(n);
4100
4105
  }
4101
4106
  }
4102
4107
  const ei = {
@@ -4120,15 +4125,15 @@ const ei = {
4120
4125
  return e.setAttribute("data-page-break", ""), {
4121
4126
  dom: e
4122
4127
  };
4123
- }, ri = xe(ei, {
4128
+ }, ri = Me(ei, {
4124
4129
  render: ti,
4125
4130
  parse: ni,
4126
4131
  toExternalHTML: oi
4127
- }), Wn = Pe.create({
4132
+ }), Wn = Ie.create({
4128
4133
  blockSpecs: {
4129
4134
  pageBreak: ri
4130
4135
  }
4131
- }), Kl = (e) => Pe.create({
4136
+ }), Kl = (e) => Ie.create({
4132
4137
  blockSpecs: {
4133
4138
  ...e.blockSpecs,
4134
4139
  ...Wn.blockSpecs
@@ -4154,14 +4159,14 @@ function Jl(e) {
4154
4159
  function ii(e) {
4155
4160
  return e.transact((n) => {
4156
4161
  const t = Z(n.doc, n.selection.anchor);
4157
- if (n.selection instanceof Se)
4162
+ if (n.selection instanceof Be)
4158
4163
  return {
4159
4164
  type: "cell",
4160
4165
  anchorBlockId: t.node.attrs.id,
4161
4166
  anchorCellOffset: n.selection.$anchorCell.pos - t.posBeforeNode,
4162
4167
  headCellOffset: n.selection.$headCell.pos - t.posBeforeNode
4163
4168
  };
4164
- if (n.selection instanceof ge)
4169
+ if (n.selection instanceof be)
4165
4170
  return {
4166
4171
  type: "node",
4167
4172
  anchorBlockId: t.node.attrs.id
@@ -4187,13 +4192,13 @@ function ai(e, n) {
4187
4192
  );
4188
4193
  let o;
4189
4194
  if (n.type === "cell")
4190
- o = Se.create(
4195
+ o = Be.create(
4191
4196
  e.doc,
4192
4197
  t + n.anchorCellOffset,
4193
4198
  t + n.headCellOffset
4194
4199
  );
4195
4200
  else if (n.type === "node")
4196
- o = ge.create(e.doc, t + 1);
4201
+ o = be.create(e.doc, t + 1);
4197
4202
  else {
4198
4203
  const i = (s = F(n.headBlockId, e.doc)) == null ? void 0 : s.posBeforeNode;
4199
4204
  if (i === void 0)
@@ -4418,7 +4423,7 @@ function wi(e) {
4418
4423
  };
4419
4424
  }
4420
4425
  function yi(e, n, t) {
4421
- const o = typeof n == "string" ? n : n.id, r = typeof t == "string" ? t : t.id, s = I(e), i = Te(s);
4426
+ const o = typeof n == "string" ? n : n.id, r = typeof t == "string" ? t : t.id, s = I(e), i = Pe(s);
4422
4427
  if (o === r)
4423
4428
  throw new Error(
4424
4429
  `Attempting to set selection with the same anchor and head blocks (id ${o})`
@@ -4489,14 +4494,14 @@ function vi(e) {
4489
4494
  };
4490
4495
  }
4491
4496
  function Xn(e, n, t = "start") {
4492
- const o = typeof n == "string" ? n : n.id, r = I(e.doc), s = Te(r), i = F(o, e.doc);
4497
+ const o = typeof n == "string" ? n : n.id, r = I(e.doc), s = Pe(r), i = F(o, e.doc);
4493
4498
  if (!i)
4494
4499
  throw new Error(`Block with ID ${o} not found`);
4495
4500
  const a = ne(i), l = s.blockSchema[a.blockNoteType].content;
4496
4501
  if (a.isBlockContainer) {
4497
4502
  const c = a.blockContent;
4498
4503
  if (l === "none") {
4499
- e.setSelection(ge.create(e.doc, c.beforePos));
4504
+ e.setSelection(be.create(e.doc, c.beforePos));
4500
4505
  return;
4501
4506
  }
4502
4507
  if (l === "inline")
@@ -4907,7 +4912,7 @@ function to(e) {
4907
4912
  function Qi(e, n, t) {
4908
4913
  var a;
4909
4914
  let o = !1;
4910
- const r = e.state.selection instanceof Se;
4915
+ const r = e.state.selection instanceof Be;
4911
4916
  if (!r) {
4912
4917
  const l = e.state.doc.slice(
4913
4918
  e.state.selection.from,
@@ -4952,7 +4957,7 @@ function Qi(e, n, t) {
4952
4957
  function no(e, n) {
4953
4958
  "node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && n.transact(
4954
4959
  (i) => i.setSelection(
4955
- new ge(i.doc.resolve(e.state.selection.from - 1))
4960
+ new be(i.doc.resolve(e.state.selection.from - 1))
4956
4961
  )
4957
4962
  );
4958
4963
  const t = e.serializeForClipboard(
@@ -5003,7 +5008,7 @@ const Qt = () => {
5003
5008
  return;
5004
5009
  e.transact(
5005
5010
  (i) => i.setSelection(
5006
- new ge(
5011
+ new be(
5007
5012
  i.doc.resolve(n.state.selection.from - 1)
5008
5013
  )
5009
5014
  )
@@ -5070,7 +5075,7 @@ class A extends Nt {
5070
5075
  get priority() {
5071
5076
  }
5072
5077
  }
5073
- const ze = class ze extends A {
5078
+ const me = class me extends A {
5074
5079
  constructor(t) {
5075
5080
  super();
5076
5081
  p(this, "provider");
@@ -5078,7 +5083,7 @@ const ze = class ze extends A {
5078
5083
  p(this, "renderCursor", (t, o) => {
5079
5084
  let r = this.recentlyUpdatedCursors.get(o);
5080
5085
  if (!r) {
5081
- const s = (this.collaboration.renderCursor ?? ze.defaultCursorRender)(t);
5086
+ const s = (this.collaboration.renderCursor ?? me.defaultCursorRender)(t);
5082
5087
  this.collaboration.showCursorLabels !== "always" && (s.addEventListener("mouseenter", () => {
5083
5088
  const i = this.recentlyUpdatedCursors.get(o);
5084
5089
  i.element.setAttribute("data-active", ""), i.hideTimeout && (clearTimeout(i.hideTimeout), this.recentlyUpdatedCursors.set(o, {
@@ -5131,16 +5136,31 @@ const ze = class ze extends A {
5131
5136
  get priority() {
5132
5137
  return 999;
5133
5138
  }
5139
+ /**
5140
+ * Determine whether the foreground color should be white or black based on a provided background color
5141
+ * Inspired by: https://stackoverflow.com/a/3943023
5142
+ *
5143
+ */
5144
+ static isDarkColor(t) {
5145
+ const o = t.charAt(0) === "#" ? t.substring(1, 7) : t, r = parseInt(o.substring(0, 2), 16), s = parseInt(o.substring(2, 4), 16), i = parseInt(o.substring(4, 6), 16), l = [r / 255, s / 255, i / 255].map((d) => d <= 0.03928 ? d / 12.92 : Math.pow((d + 0.055) / 1.055, 2.4));
5146
+ return 0.2126 * l[0] + 0.7152 * l[1] + 0.0722 * l[2] <= 0.179;
5147
+ }
5134
5148
  };
5135
- p(ze, "defaultCursorRender", (t) => {
5149
+ p(me, "defaultCursorRender", (t) => {
5136
5150
  const o = document.createElement("span");
5137
5151
  o.classList.add("bn-collaboration-cursor__base");
5138
5152
  const r = document.createElement("span");
5139
- r.setAttribute("contentedEditable", "false"), r.classList.add("bn-collaboration-cursor__caret"), r.setAttribute("style", `background-color: ${t.color}`);
5153
+ r.setAttribute("contentedEditable", "false"), r.classList.add("bn-collaboration-cursor__caret"), r.setAttribute(
5154
+ "style",
5155
+ `background-color: ${t.color}; color: ${me.isDarkColor(t.color) ? "white" : "black"}`
5156
+ );
5140
5157
  const s = document.createElement("span");
5141
- return s.classList.add("bn-collaboration-cursor__label"), s.setAttribute("style", `background-color: ${t.color}`), s.insertBefore(document.createTextNode(t.name), null), r.insertBefore(s, null), o.insertBefore(document.createTextNode("⁠"), null), o.insertBefore(r, null), o.insertBefore(document.createTextNode("⁠"), null), o;
5158
+ return s.classList.add("bn-collaboration-cursor__label"), s.setAttribute(
5159
+ "style",
5160
+ `background-color: ${t.color}; color: ${me.isDarkColor(t.color) ? "white" : "black"}`
5161
+ ), s.insertBefore(document.createTextNode(t.name), null), r.insertBefore(s, null), o.insertBefore(document.createTextNode("⁠"), null), o.insertBefore(r, null), o.insertBefore(document.createTextNode("⁠"), null), o;
5142
5162
  });
5143
- let $e = ze;
5163
+ let Fe = me;
5144
5164
  class gt extends A {
5145
5165
  static key() {
5146
5166
  return "ySyncPlugin";
@@ -5254,7 +5274,7 @@ class na extends Nt {
5254
5274
  return this.on("update", t);
5255
5275
  }
5256
5276
  }
5257
- const Ne = new U("blocknote-comments"), oa = "SET_SELECTED_THREAD_ID";
5277
+ const He = new U("blocknote-comments"), oa = "SET_SELECTED_THREAD_ID";
5258
5278
  function ra(e, n) {
5259
5279
  const t = /* @__PURE__ */ new Map();
5260
5280
  return e.descendants((o, r) => {
@@ -5331,7 +5351,7 @@ class sa extends A {
5331
5351
  const s = this;
5332
5352
  this.addProsemirrorPlugin(
5333
5353
  new N({
5334
- key: Ne,
5354
+ key: He,
5335
5355
  state: {
5336
5356
  init() {
5337
5357
  return {
@@ -5339,7 +5359,7 @@ class sa extends A {
5339
5359
  };
5340
5360
  },
5341
5361
  apply(i, a) {
5342
- const l = i.getMeta(Ne);
5362
+ const l = i.getMeta(He);
5343
5363
  if (!i.docChanged && !l)
5344
5364
  return a;
5345
5365
  const c = i.docChanged ? ra(i.doc, s.markType) : s.threadPositions;
@@ -5367,7 +5387,7 @@ class sa extends A {
5367
5387
  props: {
5368
5388
  decorations(i) {
5369
5389
  var a;
5370
- return ((a = Ne.getState(i)) == null ? void 0 : a.decorations) ?? G.empty;
5390
+ return ((a = He.getState(i)) == null ? void 0 : a.decorations) ?? G.empty;
5371
5391
  },
5372
5392
  /**
5373
5393
  * Handle click on a thread mark and mark it as selected
@@ -5411,7 +5431,7 @@ class sa extends A {
5411
5431
  selectThread(t, o = !0) {
5412
5432
  var r, s;
5413
5433
  if (this.selectedThreadId !== t && (this.selectedThreadId = t, this.emitStateUpdate(), this.editor.transact(
5414
- (i) => i.setMeta(Ne, {
5434
+ (i) => i.setMeta(He, {
5415
5435
  name: oa
5416
5436
  })
5417
5437
  ), t && o)) {
@@ -5662,7 +5682,7 @@ class la {
5662
5682
  if (i)
5663
5683
  return i.getBoundingClientRect();
5664
5684
  }
5665
- return _e(this.pmView, r, s);
5685
+ return Ue(this.pmView, r, s);
5666
5686
  }
5667
5687
  }
5668
5688
  const ca = new U(
@@ -5721,21 +5741,21 @@ const ua = oe.create({
5721
5741
  t.index(t.depth - 1),
5722
5742
  t.depth - 1
5723
5743
  );
5724
- return Me(
5744
+ return Te(
5725
5745
  e.resolve(o)
5726
5746
  );
5727
- }, Ve = (e, n) => {
5747
+ }, _e = (e, n) => {
5728
5748
  const t = e.resolve(n), o = t.index();
5729
5749
  if (o === 0)
5730
5750
  return;
5731
5751
  const r = t.posAtIndex(o - 1);
5732
- return Me(
5752
+ return Te(
5733
5753
  e.resolve(r)
5734
5754
  );
5735
5755
  }, ro = (e, n) => {
5736
5756
  for (; n.childContainer; ) {
5737
5757
  const t = n.childContainer.node, o = e.resolve(n.childContainer.beforePos + 1).posAtIndex(t.childCount - 1);
5738
- n = Me(e.resolve(o));
5758
+ n = Te(e.resolve(o));
5739
5759
  }
5740
5760
  return n;
5741
5761
  }, pa = (e, n) => e.isBlockContainer && e.blockContent.node.type.spec.content === "inline*" && e.blockContent.node.childCount > 0 && n.isBlockContainer && n.blockContent.node.type.spec.content === "inline*", ha = (e, n, t, o) => {
@@ -5771,7 +5791,7 @@ const ua = oe.create({
5771
5791
  state: n,
5772
5792
  dispatch: t
5773
5793
  }) => {
5774
- const o = n.doc.resolve(e), r = Me(o), s = Ve(
5794
+ const o = n.doc.resolve(e), r = Te(o), s = _e(
5775
5795
  n.doc,
5776
5796
  r.bnBlock.beforePos
5777
5797
  );
@@ -5824,7 +5844,7 @@ const ua = oe.create({
5824
5844
  }),
5825
5845
  () => r.command(({ state: s, dispatch: i }) => {
5826
5846
  const a = C(s);
5827
- if (!a.isBlockContainer || !(s.selection.from === a.blockContent.beforePos + 1) || Ve(
5847
+ if (!a.isBlockContainer || !(s.selection.from === a.blockContent.beforePos + 1) || _e(
5828
5848
  s.doc,
5829
5849
  a.bnBlock.beforePos
5830
5850
  ))
@@ -5928,7 +5948,7 @@ const ua = oe.create({
5928
5948
  if (!i.isBlockContainer)
5929
5949
  return !1;
5930
5950
  if (i.blockContent.node.childCount === 0 && i.blockContent.node.type.spec.content === "inline*") {
5931
- const l = Ve(
5951
+ const l = _e(
5932
5952
  s.doc,
5933
5953
  i.bnBlock.beforePos
5934
5954
  );
@@ -5963,7 +5983,7 @@ const ua = oe.create({
5963
5983
  const i = C(s);
5964
5984
  if (!i.isBlockContainer)
5965
5985
  throw new Error("todo");
5966
- const a = s.selection.from === i.blockContent.beforePos + 1, l = s.selection.empty, c = Ve(
5986
+ const a = s.selection.from === i.blockContent.beforePos + 1, l = s.selection.empty, c = _e(
5967
5987
  s.doc,
5968
5988
  i.bnBlock.beforePos
5969
5989
  );
@@ -6137,7 +6157,7 @@ class ma {
6137
6157
  });
6138
6158
  p(this, "scrollHandler", () => {
6139
6159
  var n;
6140
- this.linkMark !== void 0 && (n = this.state) != null && n.show && (this.state.referencePos = _e(
6160
+ this.linkMark !== void 0 && (n = this.state) != null && n.show && (this.state.referencePos = Ue(
6141
6161
  this.pmView,
6142
6162
  this.linkMarkRange.from,
6143
6163
  this.linkMarkRange.to
@@ -6203,7 +6223,7 @@ class ma {
6203
6223
  if (this.mouseHoveredLinkMark && o && (this.linkMark = this.mouseHoveredLinkMark, this.linkMarkRange = this.mouseHoveredLinkMarkRange), this.keyboardHoveredLinkMark && (this.linkMark = this.keyboardHoveredLinkMark, this.linkMarkRange = this.keyboardHoveredLinkMarkRange), this.linkMark && this.editor.isEditable) {
6204
6224
  this.state = {
6205
6225
  show: !0,
6206
- referencePos: _e(
6226
+ referencePos: Ue(
6207
6227
  this.pmView,
6208
6228
  this.linkMarkRange.from,
6209
6229
  this.linkMarkRange.to
@@ -6559,7 +6579,7 @@ function so(e, n) {
6559
6579
  if (((o = e.getAttribute) == null ? void 0 : o.call(e, "data-node-type")) === "blockContainer")
6560
6580
  return { node: e, id: e.getAttribute("data-id") };
6561
6581
  }
6562
- class le extends Re {
6582
+ class le extends Ve {
6563
6583
  constructor(t, o) {
6564
6584
  super(t, o);
6565
6585
  p(this, "nodes");
@@ -6585,7 +6605,7 @@ class le extends Re {
6585
6605
  }
6586
6606
  map(t, o) {
6587
6607
  const r = o.mapResult(this.from), s = o.mapResult(this.to);
6588
- return s.deleted ? Re.near(t.resolve(r.pos)) : r.deleted ? Re.near(t.resolve(s.pos)) : new le(
6608
+ return s.deleted ? Ve.near(t.resolve(r.pos)) : r.deleted ? Ve.near(t.resolve(s.pos)) : new le(
6589
6609
  t.resolve(r.pos),
6590
6610
  t.resolve(s.pos)
6591
6611
  );
@@ -6594,7 +6614,7 @@ class le extends Re {
6594
6614
  return { type: "multiple-node", anchor: this.anchor, head: this.head };
6595
6615
  }
6596
6616
  }
6597
- Re.jsonID("multiple-node", le);
6617
+ Ve.jsonID("multiple-node", le);
6598
6618
  let j;
6599
6619
  function Ma(e, n) {
6600
6620
  let t, o;
@@ -6648,13 +6668,13 @@ function Ta(e, n, t) {
6648
6668
  d && u ? (o.dispatch(
6649
6669
  o.state.tr.setSelection(le.create(a, l, c))
6650
6670
  ), sn(o, l, c)) : (o.dispatch(
6651
- o.state.tr.setSelection(ge.create(o.state.doc, s))
6671
+ o.state.tr.setSelection(be.create(o.state.doc, s))
6652
6672
  ), sn(o, s));
6653
6673
  const h = o.state.selection.content(), f = t.pmSchema, m = o.serializeForClipboard(h).dom.innerHTML, g = Xe(f, t), b = to(h.content), k = g.exportBlocks(b, {}), w = Lt(k);
6654
6674
  e.dataTransfer.clearData(), e.dataTransfer.setData("blocknote/html", m), e.dataTransfer.setData("text/html", k), e.dataTransfer.setData("text/plain", w), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setDragImage(j, 0, 0);
6655
6675
  }
6656
6676
  }
6657
- const we = 0.1;
6677
+ const ye = 0.1;
6658
6678
  function kt(e, n, t, o = !0) {
6659
6679
  const r = e.root.elementsFromPoint(
6660
6680
  // bit hacky - offset x position to right to account for the width of sidemenu itself
@@ -6877,7 +6897,7 @@ class Ia {
6877
6897
  }
6878
6898
  createSyntheticEvent(n) {
6879
6899
  const t = new Event(n.type, n), o = this.pmView.dom.firstChild.getBoundingClientRect();
6880
- return t.clientX = n.clientX, t.clientY = n.clientY, n.clientX < o.left && n.clientX > o.left - o.width * we ? t.clientX = o.left + o.width * we / 2 : n.clientX > o.right && n.clientX < o.right + o.width * we ? t.clientX = o.right - o.width * we / 2 : (n.clientX < o.left || n.clientX > o.right) && (t.clientX = o.left + we * o.width * 2), t.clientY = Math.min(
6900
+ return t.clientX = n.clientX, t.clientY = n.clientY, n.clientX < o.left && n.clientX > o.left - o.width * ye ? t.clientX = o.left + o.width * ye / 2 : n.clientX > o.right && n.clientX < o.right + o.width * ye ? t.clientX = o.right - o.width * ye / 2 : (n.clientX < o.left || n.clientX > o.right) && (t.clientX = o.left + ye * o.width * 2), t.clientY = Math.min(
6881
6901
  Math.max(n.clientY, o.top),
6882
6902
  o.top + o.height
6883
6903
  ), t.dataTransfer = n.dataTransfer, t.preventDefault = () => n.preventDefault(), t.synthetic = !0, t;
@@ -6974,16 +6994,16 @@ class Aa extends A {
6974
6994
  return this.on("update", t);
6975
6995
  }
6976
6996
  }
6977
- const He = /* @__PURE__ */ new Map();
6997
+ const De = /* @__PURE__ */ new Map();
6978
6998
  function Na(e) {
6979
- if (He.has(e))
6980
- return He.get(e);
6999
+ if (De.has(e))
7000
+ return De.get(e);
6981
7001
  const n = new po();
6982
7002
  return e._tiptapEditor.on("transaction", ({ transaction: t }) => {
6983
7003
  n.appendMapping(t.mapping);
6984
7004
  }), e._tiptapEditor.on("destroy", () => {
6985
- He.delete(e);
6986
- }), He.set(e, n), n;
7005
+ De.delete(e);
7006
+ }), De.set(e, n), n;
6987
7007
  }
6988
7008
  function Ha(e, n, t = "left") {
6989
7009
  const o = de.getState(
@@ -7032,7 +7052,7 @@ class Oa {
7032
7052
  }
7033
7053
  });
7034
7054
  p(this, "closeMenu", () => {
7035
- this.editor.transact((n) => n.setMeta(me, null));
7055
+ this.editor.transact((n) => n.setMeta(ge, null));
7036
7056
  });
7037
7057
  p(this, "clearQuery", () => {
7038
7058
  this.pluginState !== void 0 && this.editor._tiptapEditor.chain().focus().deleteRange({
@@ -7053,7 +7073,7 @@ class Oa {
7053
7073
  }
7054
7074
  update(n, t) {
7055
7075
  var c;
7056
- const o = me.getState(t), r = me.getState(
7076
+ const o = ge.getState(t), r = ge.getState(
7057
7077
  n.state
7058
7078
  ), s = o === void 0 && r !== void 0, i = o !== void 0 && r === void 0;
7059
7079
  if (!s && !(o !== void 0 && r !== void 0) && !i)
@@ -7076,7 +7096,7 @@ class Oa {
7076
7096
  (n = this.rootEl) == null || n.removeEventListener("scroll", this.handleScroll, !0);
7077
7097
  }
7078
7098
  }
7079
- const me = new U("SuggestionMenuPlugin");
7099
+ const ge = new U("SuggestionMenuPlugin");
7080
7100
  class Ra extends A {
7081
7101
  constructor(t) {
7082
7102
  super();
@@ -7096,7 +7116,7 @@ class Ra extends A {
7096
7116
  const o = this.triggerCharacters;
7097
7117
  this.addProsemirrorPlugin(
7098
7118
  new N({
7099
- key: me,
7119
+ key: ge,
7100
7120
  view: () => (this.view = new Oa(
7101
7121
  t,
7102
7122
  (r, s) => {
@@ -7111,7 +7131,7 @@ class Ra extends A {
7111
7131
  apply: (r, s, i, a) => {
7112
7132
  if (r.getMeta("orderedListIndexing") !== void 0 || r.selection.$from.parent.type.spec.code)
7113
7133
  return s;
7114
- const l = r.getMeta(me);
7134
+ const l = r.getMeta(ge);
7115
7135
  if (typeof l == "object" && l !== null) {
7116
7136
  s && this.closeMenu();
7117
7137
  const d = Ha(
@@ -7152,11 +7172,19 @@ class Ra extends A {
7152
7172
  },
7153
7173
  props: {
7154
7174
  handleTextInput(r, s, i, a) {
7155
- return o.includes(a) ? (r.dispatch(r.state.tr.insertText(a)), r.dispatch(
7156
- r.state.tr.setMeta(me, {
7157
- triggerCharacter: a
7158
- }).scrollIntoView()
7159
- ), !0) : !1;
7175
+ if (s === i) {
7176
+ const l = r.state.doc;
7177
+ for (const c of o) {
7178
+ const d = c.length > 1 ? l.textBetween(s - c.length, s) + a : a;
7179
+ if (c === d)
7180
+ return r.dispatch(r.state.tr.insertText(a)), r.dispatch(
7181
+ r.state.tr.setMeta(ge, {
7182
+ triggerCharacter: d
7183
+ }).scrollIntoView()
7184
+ ), !0;
7185
+ }
7186
+ }
7187
+ return !1;
7160
7188
  },
7161
7189
  // Setup decorator on the currently active suggestion.
7162
7190
  decorations(r) {
@@ -7358,7 +7386,7 @@ function an(e) {
7358
7386
  function $a(e) {
7359
7387
  V && (e instanceof Document ? e.body.removeChild(V) : e.removeChild(V), V = void 0);
7360
7388
  }
7361
- function De(e) {
7389
+ function Oe(e) {
7362
7390
  return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
7363
7391
  }
7364
7392
  function Fa(e) {
@@ -7454,7 +7482,7 @@ class Wa {
7454
7482
  referencePosCell: w || (g = this.state) == null ? void 0 : g.referencePosCell
7455
7483
  };
7456
7484
  } else {
7457
- const b = De(t.domNode), k = De(t.domNode.parentElement), w = t.domNode.getBoundingClientRect();
7485
+ const b = Oe(t.domNode), k = Oe(t.domNode.parentElement), w = t.domNode.getBoundingClientRect();
7458
7486
  if (this.state !== void 0 && this.state.show && this.tableId === r.id && this.state.rowIndex === k && this.state.colIndex === b)
7459
7487
  return;
7460
7488
  this.state = {
@@ -7496,10 +7524,10 @@ class Wa {
7496
7524
  return;
7497
7525
  const r = o[0];
7498
7526
  let s = !1;
7499
- const i = De(r.parentElement), a = De(r), l = this.state.draggingState.draggedCellOrientation === "row" ? this.state.rowIndex : this.state.colIndex, d = (this.state.draggingState.draggedCellOrientation === "row" ? i : a) !== l;
7527
+ const i = Oe(r.parentElement), a = Oe(r), l = this.state.draggingState.draggedCellOrientation === "row" ? this.state.rowIndex : this.state.colIndex, d = (this.state.draggingState.draggedCellOrientation === "row" ? i : a) !== l;
7500
7528
  (this.state.rowIndex !== i || this.state.colIndex !== a) && (this.state.rowIndex = i, this.state.colIndex = a, this.state.referencePosCell = r.getBoundingClientRect(), s = !0);
7501
7529
  const u = this.state.draggingState.draggedCellOrientation === "row" ? t.top : t.left;
7502
- this.state.draggingState.mousePos !== u && (this.state.draggingState.mousePos = u, s = !0), s && this.emitUpdate(), d && this.editor.transact((f) => f.setMeta(ye, !0));
7530
+ this.state.draggingState.mousePos !== u && (this.state.draggingState.mousePos = u, s = !0), s && this.emitUpdate(), d && this.editor.transact((f) => f.setMeta(Ce, !0));
7503
7531
  });
7504
7532
  p(this, "dropHandler", (n) => {
7505
7533
  if (this.mouseState = "up", this.state === void 0 || this.state.draggingState === void 0)
@@ -7600,7 +7628,7 @@ class Wa {
7600
7628
  );
7601
7629
  }
7602
7630
  }
7603
- const ye = new U("TableHandlesPlugin");
7631
+ const Ce = new U("TableHandlesPlugin");
7604
7632
  class ja extends A {
7605
7633
  constructor(t) {
7606
7634
  super();
@@ -7619,7 +7647,7 @@ class ja extends A {
7619
7647
  originalIndex: this.view.state.colIndex,
7620
7648
  mousePos: t.clientX
7621
7649
  }, this.view.emitUpdate(), this.editor.transact(
7622
- (o) => o.setMeta(ye, {
7650
+ (o) => o.setMeta(Ce, {
7623
7651
  draggedCellOrientation: this.view.state.draggingState.draggedCellOrientation,
7624
7652
  originalIndex: this.view.state.colIndex,
7625
7653
  newIndex: this.view.state.colIndex,
@@ -7643,7 +7671,7 @@ class ja extends A {
7643
7671
  originalIndex: this.view.state.rowIndex,
7644
7672
  mousePos: t.clientY
7645
7673
  }, this.view.emitUpdate(), this.editor.transact(
7646
- (o) => o.setMeta(ye, {
7674
+ (o) => o.setMeta(Ce, {
7647
7675
  draggedCellOrientation: this.view.state.draggingState.draggedCellOrientation,
7648
7676
  originalIndex: this.view.state.rowIndex,
7649
7677
  newIndex: this.view.state.rowIndex,
@@ -7662,7 +7690,7 @@ class ja extends A {
7662
7690
  throw new Error(
7663
7691
  "Attempted to drag table row, but no table block was hovered prior."
7664
7692
  );
7665
- if (this.view.state.draggingState = void 0, this.view.emitUpdate(), this.editor.transact((t) => t.setMeta(ye, null)), !this.editor.prosemirrorView)
7693
+ if (this.view.state.draggingState = void 0, this.view.emitUpdate(), this.editor.transact((t) => t.setMeta(Ce, null)), !this.editor.prosemirrorView)
7666
7694
  throw new Error("Editor view not initialized.");
7667
7695
  $a(this.editor.prosemirrorView.root);
7668
7696
  });
@@ -7705,7 +7733,7 @@ class ja extends A {
7705
7733
  c.posAtIndex(r.col)
7706
7734
  ), u = t.tr;
7707
7735
  return u.setSelection(
7708
- new Se(l, d)
7736
+ new Be(l, d)
7709
7737
  ), t.apply(u);
7710
7738
  });
7711
7739
  /**
@@ -7809,7 +7837,7 @@ class ja extends A {
7809
7837
  p(this, "addRowsOrColumns", (t, o, r) => Er(t, o, r));
7810
7838
  this.editor = t, this.addProsemirrorPlugin(
7811
7839
  new N({
7812
- key: ye,
7840
+ key: Ce,
7813
7841
  view: (o) => (this.view = new Wa(t, o, (r) => {
7814
7842
  this.emit("update", r);
7815
7843
  }), this.view),
@@ -8098,12 +8126,12 @@ class Qa extends A {
8098
8126
  ie.applyUpdate(o, ie.encodeStateAsUpdate(t.doc));
8099
8127
  const r = this.findTypeInOtherYdoc(t, o);
8100
8128
  this.forkedState = {
8101
- undoStack: Le.getState(this.editor.prosemirrorState).undoManager.undoStack,
8129
+ undoStack: Ae.getState(this.editor.prosemirrorState).undoManager.undoStack,
8102
8130
  originalFragment: t,
8103
8131
  forkedFragment: r
8104
8132
  }, this.editor._tiptapEditor.unregisterPlugin([
8105
8133
  Zo,
8106
- Le,
8134
+ Ae,
8107
8135
  de
8108
8136
  ]), this.editor._tiptapEditor.registerPlugin(
8109
8137
  new gt(r).plugins[0]
@@ -8119,9 +8147,9 @@ class Qa extends A {
8119
8147
  merge({ keepChanges: t }) {
8120
8148
  if (!this.forkedState)
8121
8149
  return;
8122
- this.editor._tiptapEditor.unregisterPlugin(de), this.editor._tiptapEditor.unregisterPlugin(Le);
8150
+ this.editor._tiptapEditor.unregisterPlugin(de), this.editor._tiptapEditor.unregisterPlugin(Ae);
8123
8151
  const { originalFragment: o, forkedFragment: r, undoStack: s } = this.forkedState;
8124
- if (this.editor.extensions.ySyncPlugin = new gt(o), this.editor.extensions.yCursorPlugin = new $e(
8152
+ if (this.editor.extensions.ySyncPlugin = new gt(o), this.editor.extensions.yCursorPlugin = new Fe(
8125
8153
  this.collaboration
8126
8154
  ), this.editor.extensions.yUndoPlugin = new bt({
8127
8155
  editor: this.editor
@@ -8131,7 +8159,7 @@ class Qa extends A {
8131
8159
  this.editor.extensions.yCursorPlugin.plugins[0]
8132
8160
  ), this.editor._tiptapEditor.registerPlugin(
8133
8161
  this.editor.extensions.yUndoPlugin.plugins[0]
8134
- ), Le.getState(
8162
+ ), Ae.getState(
8135
8163
  this.editor.prosemirrorState
8136
8164
  ).undoManager.undoStack = s, t) {
8137
8165
  const i = ie.encodeStateAsUpdate(
@@ -8148,7 +8176,7 @@ const el = (e) => {
8148
8176
  const n = {}, t = tl(e);
8149
8177
  for (const s of t)
8150
8178
  n[s.name] = s;
8151
- e.collaboration && (n.ySyncPlugin = new gt(e.collaboration.fragment), n.yUndoPlugin = new bt({ editor: e.editor }), (r = e.collaboration.provider) != null && r.awareness && (n.yCursorPlugin = new $e(e.collaboration)), n.forkYDocPlugin = new Qa({
8179
+ e.collaboration && (n.ySyncPlugin = new gt(e.collaboration.fragment), n.yUndoPlugin = new bt({ editor: e.editor }), (r = e.collaboration.provider) != null && r.awareness && (n.yCursorPlugin = new Fe(e.collaboration)), n.forkYDocPlugin = new Qa({
8152
8180
  editor: e.editor,
8153
8181
  collaboration: e.collaboration
8154
8182
  })), n.formattingToolbar = new da(
@@ -8169,11 +8197,11 @@ const el = (e) => {
8169
8197
  let ln = !1;
8170
8198
  const tl = (e) => {
8171
8199
  const n = [
8172
- ke.ClipboardTextSerializer,
8173
- ke.Commands,
8174
- ke.Editable,
8175
- ke.FocusEvents,
8176
- ke.Tabindex,
8200
+ we.ClipboardTextSerializer,
8201
+ we.Commands,
8202
+ we.Editable,
8203
+ we.FocusEvents,
8204
+ we.Tabindex,
8177
8205
  // DevTools,
8178
8206
  $o,
8179
8207
  // DropCursor,
@@ -8472,8 +8500,8 @@ p(We, "create", (t, o) => {
8472
8500
  r && (globalThis.window.setTimeout = r);
8473
8501
  }
8474
8502
  });
8475
- let Fe = We;
8476
- Fe.prototype.createView = function() {
8503
+ let ze = We;
8504
+ ze.prototype.createView = function() {
8477
8505
  this.options.onPaste = this.options.onDrop = void 0;
8478
8506
  };
8479
8507
  const il = {
@@ -8604,7 +8632,7 @@ class ao extends Nt {
8604
8632
  };
8605
8633
  const r = {
8606
8634
  defaultStyles: !0,
8607
- schema: t.schema || Pe.create(),
8635
+ schema: t.schema || Ie.create(),
8608
8636
  _headless: !1,
8609
8637
  ...t,
8610
8638
  placeholders: {
@@ -8667,15 +8695,15 @@ class ao extends Nt {
8667
8695
  }();
8668
8696
  }), this.formattingToolbar = this.extensions.formattingToolbar, this.linkToolbar = this.extensions.linkToolbar, this.sideMenu = this.extensions.sideMenu, this.suggestionMenus = this.extensions.suggestionMenus, this.filePanel = this.extensions.filePanel, this.tableHandles = this.extensions.tableHandles, this.comments = this.extensions.comments, this.showSelectionPlugin = this.extensions.showSelection, this.forkYDocPlugin = this.extensions.forkYDocPlugin, r.uploadFile) {
8669
8697
  const M = r.uploadFile;
8670
- this.uploadFile = async (B, Ie) => {
8698
+ this.uploadFile = async (B, Le) => {
8671
8699
  this.onUploadStartCallbacks.forEach(
8672
- (ee) => ee.apply(this, [Ie])
8700
+ (ee) => ee.apply(this, [Le])
8673
8701
  );
8674
8702
  try {
8675
- return await M(B, Ie);
8703
+ return await M(B, Le);
8676
8704
  } finally {
8677
8705
  this.onUploadEndCallbacks.forEach(
8678
- (ee) => ee.apply(this, [Ie])
8706
+ (ee) => ee.apply(this, [Le])
8679
8707
  );
8680
8708
  }
8681
8709
  };
@@ -8734,7 +8762,7 @@ class ao extends Nt {
8734
8762
  transformPasted: rl
8735
8763
  }
8736
8764
  };
8737
- this.headless ? this.pmSchema = wo(l.extensions) : (this._tiptapEditor = Fe.create(
8765
+ this.headless ? this.pmSchema = wo(l.extensions) : (this._tiptapEditor = ze.create(
8738
8766
  l,
8739
8767
  this.schema.styleSchema
8740
8768
  ), this.pmSchema = this._tiptapEditor.schema), this.pmSchema.cached.blockNoteEditor = this, this.emit("create");
@@ -9359,7 +9387,7 @@ class ao extends Nt {
9359
9387
  if (i)
9360
9388
  return i.getBoundingClientRect();
9361
9389
  }
9362
- return _e(this.prosemirrorView, r, s);
9390
+ return Ue(this.prosemirrorView, r, s);
9363
9391
  }
9364
9392
  get isEmpty() {
9365
9393
  const t = this.document;
@@ -9531,9 +9559,9 @@ function ec(e) {
9531
9559
  createStyleMapping: (n) => n
9532
9560
  };
9533
9561
  }
9534
- let Oe;
9562
+ let Re;
9535
9563
  async function al() {
9536
- return Oe || (Oe = (async () => {
9564
+ return Re || (Re = (async () => {
9537
9565
  const [e, n] = await Promise.all([
9538
9566
  import("emoji-mart"),
9539
9567
  // use a dynamic import to encourage bundle-splitting
@@ -9541,7 +9569,7 @@ async function al() {
9541
9569
  import("@emoji-mart/data")
9542
9570
  ]), t = "default" in e ? e.default : e, o = "default" in n ? n.default : n;
9543
9571
  return await t.init({ data: o }), { emojiMart: t, emojiData: o };
9544
- })(), Oe);
9572
+ })(), Re);
9545
9573
  }
9546
9574
  async function tc(e, n) {
9547
9575
  if (!Xs("text", e))
@@ -9567,7 +9595,7 @@ export {
9567
9595
  jr as AudioBlock,
9568
9596
  ao as BlockNoteEditor,
9569
9597
  A as BlockNoteExtension,
9570
- Pe as BlockNoteSchema,
9598
+ Ie as BlockNoteSchema,
9571
9599
  Zl as COLORS_DARK_MODE_DEFAULT,
9572
9600
  Yl as COLORS_DEFAULT,
9573
9601
  Kr as CodeBlock,
@@ -9610,7 +9638,7 @@ export {
9610
9638
  Wr as audioToExternalHTML,
9611
9639
  he as blockToNode,
9612
9640
  Bi as blocksToMarkdown,
9613
- Ue as camelToDataKebab,
9641
+ $e as camelToDataKebab,
9614
9642
  Wl as checkBlockHasDefaultProp,
9615
9643
  Ys as checkBlockIsDefaultType,
9616
9644
  $l as checkBlockIsFileBlock,
@@ -9625,7 +9653,7 @@ export {
9625
9653
  Ke as contentNodeToInlineContent,
9626
9654
  yn as contentNodeToTableContent,
9627
9655
  Or as createAddFileButton,
9628
- xe as createBlockSpec,
9656
+ Me as createBlockSpec,
9629
9657
  Q as createBlockSpecFromStronglyTypedTiptapNode,
9630
9658
  $ as createDefaultBlockDOMOutputSpec,
9631
9659
  Xe as createExternalHTMLExporter,
@@ -9670,16 +9698,16 @@ export {
9670
9698
  Bt as getBlockCache,
9671
9699
  Ct as getBlockFromPos,
9672
9700
  ne as getBlockInfo,
9673
- Me as getBlockInfoFromResolvedPos,
9701
+ Te as getBlockInfoFromResolvedPos,
9674
9702
  C as getBlockInfoFromSelection,
9675
9703
  qe as getBlockInfoFromTransaction,
9676
9704
  vt as getBlockInfoWithManualOffset,
9677
9705
  el as getBlockNoteExtensions,
9678
- Te as getBlockNoteSchema,
9706
+ Pe as getBlockNoteSchema,
9679
9707
  Et as getBlockSchema,
9680
9708
  kn as getBlockSchemaFromSpecs,
9681
9709
  Mr as getBlocksChangedByTransaction,
9682
- ve as getColspan,
9710
+ Ee as getColspan,
9683
9711
  tc as getDefaultEmojiPickerItems,
9684
9712
  Gl as getDefaultSlashMenuItems,
9685
9713
  gr as getInlineContentParseRules,
@@ -9695,7 +9723,7 @@ export {
9695
9723
  mi as getPrevBlock,
9696
9724
  lt as getRowspan,
9697
9725
  wr as getStyleParseRules,
9698
- be as getStyleSchema,
9726
+ ke as getStyleSchema,
9699
9727
  En as getStyleSchemaFromSpecs,
9700
9728
  us as imageBlockConfig,
9701
9729
  hs as imageParse,
@@ -9711,7 +9739,7 @@ export {
9711
9739
  Vt as isLinkInlineContent,
9712
9740
  ft as isNodeBlock,
9713
9741
  mn as isPartialLinkInlineContent,
9714
- Ce as isPartialTableCell,
9742
+ ve as isPartialTableCell,
9715
9743
  Hl as isSafari,
9716
9744
  ue as isStyledTextInlineContent,
9717
9745
  yt as isTableCell,
@@ -9732,7 +9760,7 @@ export {
9732
9760
  oi as pageBreakToExternalHTML,
9733
9761
  Gt as parseEmbedElement,
9734
9762
  Ye as parseFigureElement,
9735
- Be as propsToAttributes,
9763
+ xe as propsToAttributes,
9736
9764
  pr as prosemirrorSliceToSlicedBlocks,
9737
9765
  Ft as removeAndInsertBlocks,
9738
9766
  no as selectedFragmentToHTML,
@@ -9741,7 +9769,7 @@ export {
9741
9769
  La as sideMenuPluginKey,
9742
9770
  br as stylePropsToAttributes,
9743
9771
  Je as tableContentToNodes,
9744
- ye as tableHandlesPluginKey,
9772
+ Ce as tableHandlesPluginKey,
9745
9773
  Ha as trackPosition,
9746
9774
  Ir as updateBlock,
9747
9775
  D as updateBlockCommand,
@@ -9753,6 +9781,6 @@ export {
9753
9781
  Ws as videoRender,
9754
9782
  Gs as videoToExternalHTML,
9755
9783
  Kl as withPageBreak,
9756
- Ae as wrapInBlockStructure
9784
+ Ne as wrapInBlockStructure
9757
9785
  };
9758
9786
  //# sourceMappingURL=blocknote.js.map