@blocknote/xl-multi-column 0.35.0 → 0.36.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.
@@ -4,7 +4,7 @@ var p = (o, e, t) => Y(o, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { getNodeById as E, createStronglyTypedTiptapNode as R, createBlockSpecFromStronglyTypedTiptapNode as j, BlockNoteSchema as z, getBlockInfo as Z, nodeToBlock as S, UniqueID as q, getNearestBlockPos as $, insertOrUpdateBlock as O } from "@blocknote/core";
5
5
  import { Extension as J } from "@tiptap/core";
6
6
  import { Plugin as H, PluginKey as Q } from "prosemirror-state";
7
- import { DecorationSet as D, Decoration as B } from "prosemirror-view";
7
+ import { DecorationSet as B, Decoration as D } from "prosemirror-view";
8
8
  import { dropPoint as ee } from "prosemirror-transform";
9
9
  import { jsx as T } from "react/jsx-runtime";
10
10
  import v from "react";
@@ -274,21 +274,21 @@ class ge {
274
274
  );
275
275
  if (!n)
276
276
  return { type: "default" };
277
- const r = e.clientX, u = n.getBoundingClientRect(), c = r < u.left + this.RESIZE_MARGIN_WIDTH_PX ? "left" : r > u.right - this.RESIZE_MARGIN_WIDTH_PX ? "right" : "none", l = c === "left" ? n.previousElementSibling : c === "right" ? n.nextElementSibling : void 0;
277
+ const r = e.clientX, d = n.getBoundingClientRect(), c = r < d.left + this.RESIZE_MARGIN_WIDTH_PX ? "left" : r > d.right - this.RESIZE_MARGIN_WIDTH_PX ? "right" : "none", l = c === "left" ? n.previousElementSibling : c === "right" ? n.nextElementSibling : void 0;
278
278
  if (!l)
279
279
  return { type: "default" };
280
- const i = c === "left" ? l : n, g = c === "left" ? n : l, a = i.getAttribute("data-id"), s = g.getAttribute("data-id"), d = E(a, this.view.state.doc), m = E(
280
+ const i = c === "left" ? l : n, g = c === "left" ? n : l, a = i.getAttribute("data-id"), s = g.getAttribute("data-id"), u = E(a, this.view.state.doc), m = E(
281
281
  s,
282
282
  this.view.state.doc
283
283
  );
284
- if (!d || !m || !d.posBeforeNode)
284
+ if (!u || !m || !u.posBeforeNode)
285
285
  throw new Error("Column not found");
286
286
  return {
287
287
  type: "hover",
288
288
  leftColumn: {
289
289
  element: i,
290
290
  id: a,
291
- ...d
291
+ ...u
292
292
  },
293
293
  rightColumn: {
294
294
  element: g,
@@ -305,7 +305,7 @@ class ge {
305
305
  if (t.type === "default")
306
306
  return;
307
307
  e.preventDefault();
308
- const n = e.clientX, r = t.leftColumn.element.getBoundingClientRect().width, u = t.rightColumn.element.getBoundingClientRect().width, c = t.leftColumn.node.attrs.width, l = t.rightColumn.node.attrs.width;
308
+ const n = e.clientX, r = t.leftColumn.element.getBoundingClientRect().width, d = t.rightColumn.element.getBoundingClientRect().width, c = t.leftColumn.node.attrs.width, l = t.rightColumn.node.attrs.width;
309
309
  t = {
310
310
  type: "resize",
311
311
  startPos: n,
@@ -316,7 +316,7 @@ class ge {
316
316
  },
317
317
  rightColumn: {
318
318
  ...t.rightColumn,
319
- widthPx: u,
319
+ widthPx: d,
320
320
  widthPercent: l
321
321
  }
322
322
  }, this.view.dispatch(
@@ -333,16 +333,16 @@ class ge {
333
333
  if (!t)
334
334
  return;
335
335
  if (t.type !== "resize") {
336
- const a = this.getColumnHoverOrDefaultState(e), s = t.type === "default" && a.type === "default", d = t.type !== "default" && a.type !== "default" && t.leftColumn.id === a.leftColumn.id && t.rightColumn.id === a.rightColumn.id;
337
- if (s || d || a.type === "hover" && ((g = (i = this.editor.sideMenu.view) == null ? void 0 : i.state) != null && g.show))
336
+ const a = this.getColumnHoverOrDefaultState(e), s = t.type === "default" && a.type === "default", u = t.type !== "default" && a.type !== "default" && t.leftColumn.id === a.leftColumn.id && t.rightColumn.id === a.rightColumn.id;
337
+ if (s || u || a.type === "hover" && ((g = (i = this.editor.sideMenu.view) == null ? void 0 : i.state) != null && g.show))
338
338
  return;
339
339
  this.view.dispatch(
340
340
  this.view.state.tr.setMeta(C, a)
341
341
  );
342
342
  return;
343
343
  }
344
- const r = (e.clientX - t.startPos) * t.leftColumn.widthPercent, u = (t.leftColumn.widthPx + r) / t.leftColumn.widthPx - 1;
345
- let c = t.leftColumn.widthPercent + u, l = t.rightColumn.widthPercent - u;
344
+ const r = (e.clientX - t.startPos) * t.leftColumn.widthPercent, d = (t.leftColumn.widthPx + r) / t.leftColumn.widthPx - 1;
345
+ let c = t.leftColumn.widthPercent + d, l = t.rightColumn.widthPercent - d;
346
346
  c < this.COLUMN_MIN_WIDTH_PERCENT ? (l -= this.COLUMN_MIN_WIDTH_PERCENT - c, c = this.COLUMN_MIN_WIDTH_PERCENT) : l < this.COLUMN_MIN_WIDTH_PERCENT && (c -= this.COLUMN_MIN_WIDTH_PERCENT - l, l = this.COLUMN_MIN_WIDTH_PERCENT), this.view.dispatch(
347
347
  this.view.state.tr.setNodeAttribute(
348
348
  t.leftColumn.posBeforeNode,
@@ -380,15 +380,15 @@ const be = (o) => new H({
380
380
  // resizing them or when the cursor is near their boundary.
381
381
  decorations: (e) => {
382
382
  const t = C.getState(e);
383
- return !t || t.type === "default" ? D.empty : D.create(e.doc, [
384
- B.node(
383
+ return !t || t.type === "default" ? B.empty : B.create(e.doc, [
384
+ D.node(
385
385
  t.leftColumn.posBeforeNode,
386
386
  t.leftColumn.posBeforeNode + t.leftColumn.node.nodeSize,
387
387
  {
388
388
  style: "box-shadow: 4px 0 0 #ccc; cursor: col-resize"
389
389
  }
390
390
  ),
391
- B.node(
391
+ D.node(
392
392
  t.rightColumn.posBeforeNode,
393
393
  t.rightColumn.posBeforeNode + t.rightColumn.node.nodeSize,
394
394
  {
@@ -529,7 +529,7 @@ function Xe(o) {
529
529
  return new ke(t, o);
530
530
  },
531
531
  props: {
532
- handleDrop(t, n, r, u) {
532
+ handleDrop(t, n, r, d) {
533
533
  const c = t.posAtCoords(ye(n));
534
534
  if (!c)
535
535
  throw new Error("Could not get event position");
@@ -537,7 +537,7 @@ function Xe(o) {
537
537
  let s = "regular";
538
538
  if (n.clientX <= a.left + a.width * k && (s = "left"), n.clientX >= a.right - a.width * k && (s = "right"), s === "regular")
539
539
  return !1;
540
- const d = S(
540
+ const u = S(
541
541
  r.content.child(0),
542
542
  e.pmSchema
543
543
  // TODO: cache?
@@ -563,24 +563,24 @@ function Xe(o) {
563
563
  ), K = h.children.map((b) => ({
564
564
  ...b,
565
565
  children: b.children.filter(
566
- (y) => y.id !== d.id
566
+ (y) => y.id !== u.id
567
567
  )
568
568
  })).filter((b) => b.children.length > 0).toSpliced(s === "left" ? x : x + 1, 0, {
569
569
  type: "column",
570
- children: [d],
570
+ children: [u],
571
571
  props: {},
572
572
  content: void 0,
573
573
  id: q.options.generateID()
574
574
  });
575
- e.removeBlocks([d]), e.updateBlock(h, {
575
+ e.getBlock(u.id) && e.removeBlocks([u]), e.updateBlock(h, {
576
576
  children: K
577
577
  });
578
578
  } else {
579
579
  const m = S(i.bnBlock.node, e.pmSchema);
580
- if (m.id === d.id)
580
+ if (m.id === u.id)
581
581
  return;
582
- const h = s === "left" ? [d, m] : [m, d];
583
- e.removeBlocks([d]), e.replaceBlocks(
582
+ const h = s === "left" ? [u, m] : [m, u];
583
+ e.getBlock(u.id) && e.removeBlocks([u]), e.replaceBlocks(
584
584
  [m],
585
585
  [
586
586
  {
@@ -608,8 +608,8 @@ class ke {
608
608
  p(this, "timeout");
609
609
  p(this, "handlers");
610
610
  this.editorView = e, this.width = t.width ?? 1, this.color = t.color === !1 ? void 0 : t.color || "black", this.class = t.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((n) => {
611
- const r = (u) => {
612
- this[n](u);
611
+ const r = (d) => {
612
+ this[n](d);
613
613
  };
614
614
  return e.dom.addEventListener(
615
615
  n,
@@ -642,10 +642,10 @@ class ke {
642
642
  throw new Error("updateOverlay called with no cursor position");
643
643
  const e = this.editorView.state.doc.resolve(this.cursorPos.pos), t = !e.parent.inlineContent;
644
644
  let n;
645
- const r = this.editorView.dom, u = r.getBoundingClientRect(), c = u.width / r.offsetWidth, l = u.height / r.offsetHeight;
645
+ const r = this.editorView.dom, d = r.getBoundingClientRect(), c = d.width / r.offsetWidth, l = d.height / r.offsetHeight;
646
646
  if (t) {
647
- const s = e.nodeBefore, d = e.nodeAfter;
648
- if (s || d)
647
+ const s = e.nodeBefore, u = e.nodeAfter;
648
+ if (s || u)
649
649
  if (this.cursorPos.position === "left" || this.cursorPos.position === "right") {
650
650
  const m = this.editorView.nodeDOM(this.cursorPos.pos);
651
651
  if (!m)
@@ -666,7 +666,7 @@ class ke {
666
666
  if (m) {
667
667
  const h = m.getBoundingClientRect();
668
668
  let f = s ? h.bottom : h.top;
669
- s && d && (f = (f + this.editorView.nodeDOM(this.cursorPos.pos).getBoundingClientRect().top) / 2);
669
+ s && u && (f = (f + this.editorView.nodeDOM(this.cursorPos.pos).getBoundingClientRect().top) / 2);
670
670
  const w = this.width / 2 * l;
671
671
  this.cursorPos.position === "regular" && (n = {
672
672
  left: h.left,
@@ -678,10 +678,10 @@ class ke {
678
678
  }
679
679
  }
680
680
  if (!n) {
681
- const s = this.editorView.coordsAtPos(this.cursorPos.pos), d = this.width / 2 * c;
681
+ const s = this.editorView.coordsAtPos(this.cursorPos.pos), u = this.width / 2 * c;
682
682
  n = {
683
- left: s.left - d,
684
- right: s.left + d,
683
+ left: s.left - u,
684
+ right: s.left + u,
685
685
  top: s.top,
686
686
  bottom: s.bottom
687
687
  };
@@ -695,8 +695,8 @@ class ke {
695
695
  if (!i || i === document.body && getComputedStyle(i).position === "static")
696
696
  g = -window.scrollX, a = -window.scrollY;
697
697
  else {
698
- const s = i.getBoundingClientRect(), d = s.width / i.offsetWidth, m = s.height / i.offsetHeight;
699
- g = s.left - i.scrollLeft * d, a = s.top - i.scrollTop * m;
698
+ const s = i.getBoundingClientRect(), u = s.width / i.offsetWidth, m = s.height / i.offsetHeight;
699
+ g = s.left - i.scrollLeft * u, a = s.top - i.scrollTop * m;
700
700
  }
701
701
  this.element.style.left = (n.left - g) / c + "px", this.element.style.top = (n.top - a) / l + "px", this.element.style.width = (n.right - n.left) / c + "px", this.element.style.height = (n.bottom - n.top) / l + "px";
702
702
  }
@@ -710,8 +710,8 @@ class ke {
710
710
  const t = this.editorView.posAtCoords({
711
711
  left: e.clientX,
712
712
  top: e.clientY
713
- }), n = t && t.inside >= 0 && this.editorView.state.doc.nodeAt(t.inside), r = n && n.type.spec.disableDropCursor, u = typeof r == "function" ? r(this.editorView, t, e) : r;
714
- if (t && !u) {
713
+ }), n = t && t.inside >= 0 && this.editorView.state.doc.nodeAt(t.inside), r = n && n.type.spec.disableDropCursor, d = typeof r == "function" ? r(this.editorView, t, e) : r;
714
+ if (t && !d) {
715
715
  let c = "regular", l = t.pos;
716
716
  const i = V(this.editorView.state, t), a = this.editorView.nodeDOM(i.posBeforeNode).getBoundingClientRect();
717
717
  if (e.clientX <= a.left + a.width * k && (c = "left", l = i.posBeforeNode), e.clientX >= a.right - a.width * k && (c = "right", l = i.posBeforeNode), c === "regular" && this.editorView.dragging && this.editorView.dragging.slice) {
@@ -754,9 +754,9 @@ function Pe(o, e) {
754
754
  if (o == null) return {};
755
755
  var t = Se(o, e), n, r;
756
756
  if (Object.getOwnPropertySymbols) {
757
- var u = Object.getOwnPropertySymbols(o);
758
- for (r = 0; r < u.length; r++)
759
- n = u[r], !(e.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(o, n) && (t[n] = o[n]);
757
+ var d = Object.getOwnPropertySymbols(o);
758
+ for (r = 0; r < d.length; r++)
759
+ n = d[r], !(e.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(o, n) && (t[n] = o[n]);
760
760
  }
761
761
  return t;
762
762
  }
@@ -824,16 +824,16 @@ function U(o) {
824
824
  }, e.attr), U(e.child)));
825
825
  }
826
826
  function G(o) {
827
- return (e) => /* @__PURE__ */ v.createElement(De, _({
827
+ return (e) => /* @__PURE__ */ v.createElement(Be, _({
828
828
  attr: P({}, o.attr)
829
829
  }, e), U(o.child));
830
830
  }
831
- function De(o) {
831
+ function Be(o) {
832
832
  var e = (t) => {
833
833
  var {
834
834
  attr: n,
835
835
  size: r,
836
- title: u
836
+ title: d
837
837
  } = o, c = Pe(o, _e), l = r || t.size || "1em", i;
838
838
  return t.className && (i = t.className), o.className && (i = (i ? i + " " : "") + o.className), /* @__PURE__ */ v.createElement("svg", _({
839
839
  stroke: "currentColor",
@@ -847,11 +847,11 @@ function De(o) {
847
847
  height: l,
848
848
  width: l,
849
849
  xmlns: "http://www.w3.org/2000/svg"
850
- }), u && /* @__PURE__ */ v.createElement("title", null, u), o.children);
850
+ }), d && /* @__PURE__ */ v.createElement("title", null, d), o.children);
851
851
  };
852
852
  return I !== void 0 ? /* @__PURE__ */ v.createElement(I.Consumer, null, (t) => e(t)) : e(X);
853
853
  }
854
- function Be(o) {
854
+ function De(o) {
855
855
  return G({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "M3 3m0 1a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v16a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1zm9 -1v18" }, child: [] }] })(o);
856
856
  }
857
857
  function Te(o) {
@@ -865,7 +865,7 @@ function Ue(o) {
865
865
  return Ne(o) && e.push(
866
866
  {
867
867
  ...N(o).slash_menu.two_columns,
868
- icon: /* @__PURE__ */ T(Be, { size: 18 }),
868
+ icon: /* @__PURE__ */ T(De, { size: 18 }),
869
869
  onItemClick: () => {
870
870
  O(o, {
871
871
  type: "columnList",