@blocknote/xl-multi-column 0.38.0 → 0.39.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.
@@ -1,12 +1,12 @@
1
- var F = Object.defineProperty;
2
- var Y = (o, e, t) => e in o ? F(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var p = (o, e, t) => Y(o, typeof e != "symbol" ? e + "" : e, t);
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
- import { Extension as J } from "@tiptap/core";
6
- import { Plugin as H, PluginKey as Q } from "prosemirror-state";
7
- import { DecorationSet as B, Decoration as D } from "prosemirror-view";
1
+ var K = Object.defineProperty;
2
+ var F = (o, e, t) => e in o ? K(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var p = (o, e, t) => F(o, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Extension as Y, Node as R } from "@tiptap/core";
5
+ import { getNodeById as O, createBlockSpecFromTiptapNode as j, BlockNoteSchema as Z, getBlockInfo as q, nodeToBlock as x, UniqueID as $, getNearestBlockPos as J, insertOrUpdateBlock as B } from "@blocknote/core";
6
+ import { Plugin as z, PluginKey as Q } from "prosemirror-state";
7
+ import { DecorationSet as D, Decoration as S } from "prosemirror-view";
8
8
  import { dropPoint as ee } from "prosemirror-transform";
9
- import { jsx as T } from "react/jsx-runtime";
9
+ import { jsx as N } from "react/jsx-runtime";
10
10
  import v from "react";
11
11
  const te = {
12
12
  slash_menu: {
@@ -251,7 +251,7 @@ const te = {
251
251
  vi: pe,
252
252
  zh: fe
253
253
  }, Symbol.toStringTag, { value: "Module" }));
254
- function N(o) {
254
+ function T(o) {
255
255
  if (!o.dictionary.multi_column)
256
256
  throw new Error("Multi-column dictionary not found");
257
257
  return o.dictionary.multi_column;
@@ -277,7 +277,7 @@ class ge {
277
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"), u = 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 = O(a, this.view.state.doc), m = O(
281
281
  s,
282
282
  this.view.state.doc
283
283
  );
@@ -373,22 +373,22 @@ class ge {
373
373
  this.view.dom.removeEventListener("mousedown", this.mouseDownHandler), document.body.removeEventListener("mousemove", this.mouseMoveHandler), document.body.removeEventListener("mouseup", this.mouseUpHandler);
374
374
  }
375
375
  }
376
- const be = (o) => new H({
376
+ const be = (o) => new z({
377
377
  key: C,
378
378
  props: {
379
379
  // This adds a border between the columns when the user is
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" ? B.empty : B.create(e.doc, [
384
- D.node(
383
+ return !t || t.type === "default" ? D.empty : D.create(e.doc, [
384
+ S.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
- D.node(
391
+ S.node(
392
392
  t.rightColumn.posBeforeNode,
393
393
  t.rightColumn.posBeforeNode + t.rightColumn.node.nodeSize,
394
394
  {
@@ -406,12 +406,12 @@ const be = (o) => new H({
406
406
  }
407
407
  },
408
408
  view: (e) => new ge(o, e)
409
- }), we = (o) => J.create({
409
+ }), we = (o) => Y.create({
410
410
  name: "columnResize",
411
411
  addProseMirrorPlugins() {
412
412
  return [be(o)];
413
413
  }
414
- }), Ce = R({
414
+ }), Ce = R.create({
415
415
  name: "column",
416
416
  group: "bnBlock childContainer",
417
417
  // A block always contains content, and optionally a blockGroup which contains nested blocks
@@ -470,7 +470,7 @@ const be = (o) => new H({
470
470
  addExtensions() {
471
471
  return [we(this.options.editor)];
472
472
  }
473
- }), ve = R({
473
+ }), ve = R.create({
474
474
  name: "columnList",
475
475
  group: "childContainer bnBlock blockGroupChild",
476
476
  // A block always contains content, and optionally a blockGroup which contains nested blocks
@@ -498,33 +498,41 @@ const be = (o) => new H({
498
498
  contentDOM: e
499
499
  };
500
500
  }
501
- }), W = j(Ce, {
502
- width: {
503
- default: 1
501
+ }), H = j(
502
+ {
503
+ node: Ce,
504
+ type: "column",
505
+ content: "none"
506
+ },
507
+ {
508
+ width: {
509
+ default: 1
510
+ }
504
511
  }
505
- }), A = j(
506
- ve,
512
+ ), W = j(
513
+ {
514
+ node: ve,
515
+ type: "columnList",
516
+ content: "none"
517
+ },
507
518
  {}
508
- ), M = z.create({
519
+ ), M = Z.create({
509
520
  blockSpecs: {
510
- column: W,
511
- columnList: A
521
+ column: H,
522
+ columnList: W
512
523
  }
513
- }), Ve = (o) => z.create({
524
+ }), Ve = (o) => o.extend({
514
525
  blockSpecs: {
515
- ...o.blockSpecs,
516
- column: W,
517
- columnList: A
518
- },
519
- inlineContentSpecs: o.inlineContentSpecs,
520
- styleSpecs: o.styleSpecs
526
+ column: H,
527
+ columnList: W
528
+ }
521
529
  }), k = 0.1;
522
530
  function ye(o) {
523
531
  return { left: o.clientX, top: o.clientY };
524
532
  }
525
533
  function Xe(o) {
526
534
  const e = o.editor;
527
- return new H({
535
+ return new z({
528
536
  view(t) {
529
537
  return new ke(t, o);
530
538
  },
@@ -533,17 +541,17 @@ function Xe(o) {
533
541
  const c = t.posAtCoords(ye(n));
534
542
  if (!c)
535
543
  throw new Error("Could not get event position");
536
- const l = V(t.state, c), i = Z(l), a = t.nodeDOM(l.posBeforeNode).getBoundingClientRect();
544
+ const l = A(t.state, c), i = q(l), a = t.nodeDOM(l.posBeforeNode).getBoundingClientRect();
537
545
  let s = "regular";
538
546
  if (n.clientX <= a.left + a.width * k && (s = "left"), n.clientX >= a.right - a.width * k && (s = "right"), s === "regular")
539
547
  return !1;
540
- const u = S(
548
+ const u = x(
541
549
  r.content.child(0),
542
550
  e.pmSchema
543
551
  // TODO: cache?
544
552
  );
545
553
  if (i.blockNoteType === "column") {
546
- const m = t.state.doc.resolve(i.bnBlock.beforePos).node(), h = S(
554
+ const m = t.state.doc.resolve(i.bnBlock.beforePos).node(), h = x(
547
555
  m,
548
556
  e.pmSchema
549
557
  );
@@ -558,25 +566,25 @@ function Xe(o) {
558
566
  y.props.width = y.props.width * b;
559
567
  });
560
568
  }
561
- const x = h.children.findIndex(
569
+ const E = h.children.findIndex(
562
570
  (b) => b.id === i.bnBlock.node.attrs.id
563
- ), K = h.children.map((b) => ({
571
+ ), G = h.children.map((b) => ({
564
572
  ...b,
565
573
  children: b.children.filter(
566
574
  (y) => y.id !== u.id
567
575
  )
568
- })).filter((b) => b.children.length > 0).toSpliced(s === "left" ? x : x + 1, 0, {
576
+ })).filter((b) => b.children.length > 0).toSpliced(s === "left" ? E : E + 1, 0, {
569
577
  type: "column",
570
578
  children: [u],
571
579
  props: {},
572
580
  content: void 0,
573
- id: q.options.generateID()
581
+ id: $.options.generateID()
574
582
  });
575
583
  e.getBlock(u.id) && e.removeBlocks([u]), e.updateBlock(h, {
576
- children: K
584
+ children: G
577
585
  });
578
586
  } else {
579
- const m = S(i.bnBlock.node, e.pmSchema);
587
+ const m = x(i.bnBlock.node, e.pmSchema);
580
588
  if (m.id === u.id)
581
589
  return;
582
590
  const h = s === "left" ? [u, m] : [m, u];
@@ -713,7 +721,7 @@ class ke {
713
721
  }), 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
722
  if (t && !d) {
715
723
  let c = "regular", l = t.pos;
716
- const i = V(this.editorView.state, t), a = this.editorView.nodeDOM(i.posBeforeNode).getBoundingClientRect();
724
+ const i = A(this.editorView.state, t), a = this.editorView.nodeDOM(i.posBeforeNode).getBoundingClientRect();
717
725
  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) {
718
726
  const s = ee(
719
727
  this.editorView.state.doc,
@@ -735,24 +743,24 @@ class ke {
735
743
  (e.target === this.editorView.dom || !this.editorView.dom.contains(e.relatedTarget)) && this.setCursor(void 0);
736
744
  }
737
745
  }
738
- function V(o, e) {
739
- const t = $(o.doc, e.pos);
746
+ function A(o, e) {
747
+ const t = J(o.doc, e.pos);
740
748
  let n = o.doc.resolve(t.posBeforeNode);
741
749
  return n.parent.type.name === "column" && (n = o.doc.resolve(n.before())), {
742
750
  posBeforeNode: n.pos,
743
751
  node: n.nodeAfter
744
752
  };
745
753
  }
746
- var X = {
754
+ var V = {
747
755
  color: void 0,
748
756
  size: void 0,
749
757
  className: void 0,
750
758
  style: void 0,
751
759
  attr: void 0
752
- }, I = v.createContext && /* @__PURE__ */ v.createContext(X), _e = ["attr", "size", "title"];
760
+ }, I = v.createContext && /* @__PURE__ */ v.createContext(V), _e = ["attr", "size", "title"];
753
761
  function Pe(o, e) {
754
762
  if (o == null) return {};
755
- var t = Se(o, e), n, r;
763
+ var t = xe(o, e), n, r;
756
764
  if (Object.getOwnPropertySymbols) {
757
765
  var d = Object.getOwnPropertySymbols(o);
758
766
  for (r = 0; r < d.length; r++)
@@ -760,7 +768,7 @@ function Pe(o, e) {
760
768
  }
761
769
  return t;
762
770
  }
763
- function Se(o, e) {
771
+ function xe(o, e) {
764
772
  if (o == null) return {};
765
773
  var t = {};
766
774
  for (var n in o)
@@ -794,21 +802,21 @@ function P(o) {
794
802
  for (var e = 1; e < arguments.length; e++) {
795
803
  var t = arguments[e] != null ? arguments[e] : {};
796
804
  e % 2 ? L(Object(t), !0).forEach(function(n) {
797
- xe(o, n, t[n]);
805
+ Ee(o, n, t[n]);
798
806
  }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t)) : L(Object(t)).forEach(function(n) {
799
807
  Object.defineProperty(o, n, Object.getOwnPropertyDescriptor(t, n));
800
808
  });
801
809
  }
802
810
  return o;
803
811
  }
804
- function xe(o, e, t) {
805
- return e = Ee(e), e in o ? Object.defineProperty(o, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : o[e] = t, o;
812
+ function Ee(o, e, t) {
813
+ return e = Oe(e), e in o ? Object.defineProperty(o, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : o[e] = t, o;
806
814
  }
807
- function Ee(o) {
808
- var e = Oe(o, "string");
815
+ function Oe(o) {
816
+ var e = Be(o, "string");
809
817
  return typeof e == "symbol" ? e : e + "";
810
818
  }
811
- function Oe(o, e) {
819
+ function Be(o, e) {
812
820
  if (typeof o != "object" || !o) return o;
813
821
  var t = o[Symbol.toPrimitive];
814
822
  if (t !== void 0) {
@@ -818,17 +826,17 @@ function Oe(o, e) {
818
826
  }
819
827
  return (e === "string" ? String : Number)(o);
820
828
  }
821
- function U(o) {
829
+ function X(o) {
822
830
  return o && o.map((e, t) => /* @__PURE__ */ v.createElement(e.tag, P({
823
831
  key: t
824
- }, e.attr), U(e.child)));
832
+ }, e.attr), X(e.child)));
825
833
  }
826
- function G(o) {
827
- return (e) => /* @__PURE__ */ v.createElement(Be, _({
834
+ function U(o) {
835
+ return (e) => /* @__PURE__ */ v.createElement(De, _({
828
836
  attr: P({}, o.attr)
829
- }, e), U(o.child));
837
+ }, e), X(o.child));
830
838
  }
831
- function Be(o) {
839
+ function De(o) {
832
840
  var e = (t) => {
833
841
  var {
834
842
  attr: n,
@@ -849,25 +857,25 @@ function Be(o) {
849
857
  xmlns: "http://www.w3.org/2000/svg"
850
858
  }), d && /* @__PURE__ */ v.createElement("title", null, d), o.children);
851
859
  };
852
- return I !== void 0 ? /* @__PURE__ */ v.createElement(I.Consumer, null, (t) => e(t)) : e(X);
853
- }
854
- function De(o) {
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);
860
+ return I !== void 0 ? /* @__PURE__ */ v.createElement(I.Consumer, null, (t) => e(t)) : e(V);
856
861
  }
857
- function Te(o) {
858
- 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 -1zm6 -1v18m6 -18v18" }, child: [] }] })(o);
862
+ function Se(o) {
863
+ return U({ 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);
859
864
  }
860
865
  function Ne(o) {
866
+ return U({ 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 -1zm6 -1v18m6 -18v18" }, child: [] }] })(o);
867
+ }
868
+ function Te(o) {
861
869
  return "column" in o.schema.blockSchema && o.schema.blockSchema.columnList === M.blockSchema.columnList && "column" in o.schema.blockSchema && o.schema.blockSchema.column === M.blockSchema.column;
862
870
  }
863
871
  function Ue(o) {
864
872
  const e = [];
865
- return Ne(o) && e.push(
873
+ return Te(o) && e.push(
866
874
  {
867
- ...N(o).slash_menu.two_columns,
868
- icon: /* @__PURE__ */ T(De, { size: 18 }),
875
+ ...T(o).slash_menu.two_columns,
876
+ icon: /* @__PURE__ */ N(Se, { size: 18 }),
869
877
  onItemClick: () => {
870
- O(o, {
878
+ B(o, {
871
879
  type: "columnList",
872
880
  children: [
873
881
  {
@@ -891,10 +899,10 @@ function Ue(o) {
891
899
  }
892
900
  },
893
901
  {
894
- ...N(o).slash_menu.three_columns,
895
- icon: /* @__PURE__ */ T(Te, { size: 18 }),
902
+ ...T(o).slash_menu.three_columns,
903
+ icon: /* @__PURE__ */ N(Ne, { size: 18 }),
896
904
  onItemClick: () => {
897
- O(o, {
905
+ B(o, {
898
906
  type: "columnList",
899
907
  children: [
900
908
  {
@@ -928,10 +936,10 @@ function Ue(o) {
928
936
  ), e;
929
937
  }
930
938
  export {
931
- W as ColumnBlock,
932
- A as ColumnListBlock,
933
- Ne as checkMultiColumnBlocksInSchema,
934
- N as getMultiColumnDictionary,
939
+ H as ColumnBlock,
940
+ W as ColumnListBlock,
941
+ Te as checkMultiColumnBlocksInSchema,
942
+ T as getMultiColumnDictionary,
935
943
  Ue as getMultiColumnSlashMenuItems,
936
944
  Ae as locales,
937
945
  Xe as multiColumnDropCursor,