@blocknote/core 0.2.0 → 0.2.1-alpha.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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <a href="https://discord.gg/aDQxXezfNj"><img alt="Discord" src="https://img.shields.io/badge/Chat on discord%20-%237289DA.svg?&style=for-the-badge&logo=discord&logoColor=white"/></a> <a href="https://matrix.to/#/#typecell-space:matrix.org"><img alt="Matrix" src="https://img.shields.io/badge/Chat on matrix%20-%23000.svg?&style=for-the-badge&logo=matrix&logoColor=white"/></a>
4
4
 
5
- [![npm version](https://badge.fury.io/js/%40blocknote%2Fcore.svg)](https://badge.fury.io/js/%40blocknote%2Fcore)
5
+ [![npm version](https://badge.fury.io/js/%40blocknote%2Freact.svg)](https://badge.fury.io/js/%40blocknote%2Freact)
6
6
 
7
7
  **Welcome to BlockNote editor: a "Notion-style" block-based extensible text editor built on top of [Prosemirror](https://prosemirror.net/) and [Tiptap](https://tiptap.dev/).**
8
8
 
package/dist/blocknote.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var re = Object.defineProperty;
2
2
  var ie = (o, e, t) => e in o ? re(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
3
  var h = (o, e, t) => (ie(o, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { combineTransactionSteps as Q, getChangedRanges as X, findChildren as _, Node as w, mergeAttributes as N, InputRule as U, isTextSelection as se, isNodeSelection as ae, posToDOMRect as Z, Extension as E, findParentNode as de, getMarkRange as W, findChildrenInRange as le, extensions as P, Editor as ce } from "@tiptap/core";
4
+ import { combineTransactionSteps as Q, getChangedRanges as X, findChildren as _, Node as w, mergeAttributes as N, InputRule as U, isTextSelection as se, isNodeSelection as ae, posToDOMRect as Z, Extension as E, findParentNode as de, getMarkRange as K, findChildrenInRange as le, extensions as P, Editor as ce } from "@tiptap/core";
5
5
  import ue from "@tiptap/extension-bold";
6
6
  import he from "@tiptap/extension-code";
7
7
  import pe from "@tiptap/extension-dropcursor";
@@ -12,8 +12,8 @@ import ke from "@tiptap/extension-italic";
12
12
  import ye from "@tiptap/extension-strike";
13
13
  import be from "@tiptap/extension-text";
14
14
  import ve from "@tiptap/extension-underline";
15
- import { Slice as $, Fragment as ee } from "prosemirror-model";
16
- import { PluginKey as I, Plugin as T, TextSelection as K, Selection as F, NodeSelection as Ie } from "prosemirror-state";
15
+ import { Slice as z, Fragment as ee } from "prosemirror-model";
16
+ import { PluginKey as v, Plugin as T, TextSelection as W, Selection as F, NodeSelection as Ie } from "prosemirror-state";
17
17
  import * as Te from "prosemirror-view";
18
18
  import { Decoration as L, DecorationSet as O } from "prosemirror-view";
19
19
  import { escapeRegExp as V } from "lodash";
@@ -51,7 +51,7 @@ function k(o, e) {
51
51
  depth: a
52
52
  };
53
53
  }
54
- const Y = new I("previous-blocks"), Me = {
54
+ const Y = new v("previous-blocks"), Me = {
55
55
  listItemType: "list-item-type",
56
56
  listItemIndex: "list-item-index",
57
57
  headingLevel: "heading-level",
@@ -142,7 +142,7 @@ const Y = new I("previous-blocks"), Me = {
142
142
  }), O.create(o.doc, t);
143
143
  }
144
144
  }
145
- }), Se = "_blockOuter_r256c_5", xe = "_block_r256c_5", Ee = "_blockContent_r256c_25", Pe = "_blockGroup_r256c_53", Ae = "_isEmpty_r256c_238", Ne = "_isFilter_r256c_239", He = "_hasAnchor_r256c_252", v = {
145
+ }), Se = "_blockOuter_r256c_5", xe = "_block_r256c_5", Ee = "_blockContent_r256c_25", Pe = "_blockGroup_r256c_53", Ae = "_isEmpty_r256c_238", Ne = "_isFilter_r256c_239", He = "_hasAnchor_r256c_252", I = {
146
146
  blockOuter: Se,
147
147
  block: xe,
148
148
  blockContent: Ee,
@@ -193,13 +193,13 @@ const Y = new I("previous-blocks"), Me = {
193
193
  return [
194
194
  "div",
195
195
  N(e, {
196
- class: v.blockOuter,
196
+ class: I.blockOuter,
197
197
  "data-node-type": "block-outer"
198
198
  }),
199
199
  [
200
200
  "div",
201
201
  N(e, {
202
- class: v.block,
202
+ class: I.block,
203
203
  "data-node-type": this.name
204
204
  }),
205
205
  0
@@ -218,7 +218,7 @@ const Y = new I("previous-blocks"), Me = {
218
218
  return !1;
219
219
  const { startPos: a, endPos: d } = r;
220
220
  return n && (e.tr.deleteRange(a, d), e.tr.setSelection(
221
- new K(e.doc.resolve(a + 1))
221
+ new W(e.doc.resolve(a + 1))
222
222
  ), t.focus()), !0;
223
223
  },
224
224
  BNMergeBlocks: (o) => ({ state: e, dispatch: t }) => {
@@ -240,7 +240,7 @@ const Y = new I("previous-blocks"), Me = {
240
240
  if (u--, l = k(e.doc, u), l === void 0)
241
241
  return !1;
242
242
  return t && (e.tr.deleteRange(s, s + i.nodeSize), e.tr.insertText(i.textContent, u - 1), e.tr.setSelection(
243
- new K(e.doc.resolve(u - 1))
243
+ new W(e.doc.resolve(u - 1))
244
244
  )), !0;
245
245
  },
246
246
  BNSplitBlock: (o, e) => ({ state: t, dispatch: n }) => {
@@ -258,7 +258,7 @@ const Y = new I("previous-blocks"), Me = {
258
258
  return n && t.tr.replace(
259
259
  i,
260
260
  s,
261
- new $(f, c, c)
261
+ new z(f, c, c)
262
262
  ), !0;
263
263
  },
264
264
  BNSetContentType: (o, e) => ({ state: t, dispatch: n }) => {
@@ -413,7 +413,7 @@ const Y = new I("previous-blocks"), Me = {
413
413
  return [
414
414
  "div",
415
415
  N(this.options.HTMLAttributes, o, {
416
- class: v.blockGroup,
416
+ class: I.blockGroup,
417
417
  "data-node-type": "block-group"
418
418
  }),
419
419
  0
@@ -436,7 +436,7 @@ const Y = new I("previous-blocks"), Me = {
436
436
  return [
437
437
  "div",
438
438
  {
439
- class: v.blockContent,
439
+ class: I.blockContent,
440
440
  "data-content-type": this.name
441
441
  },
442
442
  ["p", 0]
@@ -495,13 +495,13 @@ const Y = new I("previous-blocks"), Me = {
495
495
  return console.log(o.attrs), [
496
496
  "div",
497
497
  N(e, {
498
- class: v.blockContent,
498
+ class: I.blockContent,
499
499
  "data-content-type": this.name
500
500
  }),
501
501
  ["h" + o.attrs.headingLevel, 0]
502
502
  ];
503
503
  }
504
- }), De = new I("ordered-list-item-index"), _e = () => new T({
504
+ }), De = new v("ordered-list-item-index"), _e = () => new T({
505
505
  key: De,
506
506
  appendTransaction: (o, e, t) => {
507
507
  const n = t.tr;
@@ -617,13 +617,13 @@ const Y = new I("previous-blocks"), Me = {
617
617
  return [
618
618
  "div",
619
619
  N(o, {
620
- class: v.blockContent,
620
+ class: I.blockContent,
621
621
  "data-content-type": this.name
622
622
  }),
623
623
  ["li", 0]
624
624
  ];
625
625
  }
626
- }), ze = [
626
+ }), $e = [
627
627
  Re,
628
628
  Fe,
629
629
  Ue,
@@ -635,7 +635,7 @@ const Y = new I("previous-blocks"), Me = {
635
635
  content: "blockGroup"
636
636
  })
637
637
  ];
638
- class $e {
638
+ class ze {
639
639
  constructor({
640
640
  editor: e,
641
641
  formattingToolbarFactory: t,
@@ -773,8 +773,8 @@ class $e {
773
773
  }
774
774
  }
775
775
  const qe = (o) => new T({
776
- key: new I("FormattingToolbarPlugin"),
777
- view: (e) => new $e({ view: e, ...o })
776
+ key: new v("FormattingToolbarPlugin"),
777
+ view: (e) => new ze({ view: e, ...o })
778
778
  }), Ge = E.create({
779
779
  name: "FormattingToolbarExtension",
780
780
  addProseMirrorPlugins() {
@@ -786,7 +786,7 @@ const qe = (o) => new T({
786
786
  qe({
787
787
  editor: this.editor,
788
788
  formattingToolbarFactory: this.options.formattingToolbarFactory,
789
- pluginKey: new I("FormattingToolbarPlugin")
789
+ pluginKey: new v("FormattingToolbarPlugin")
790
790
  })
791
791
  ];
792
792
  }
@@ -805,7 +805,7 @@ class A extends F {
805
805
  return new A(t.resolve(n), t.resolve(r));
806
806
  }
807
807
  content() {
808
- return new $(ee.from(this.nodes), 0, 0);
808
+ return new z(ee.from(this.nodes), 0, 0);
809
809
  }
810
810
  eq(t) {
811
811
  if (!(t instanceof A) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to)
@@ -826,8 +826,8 @@ class A extends F {
826
826
  return { type: "node", anchor: this.anchor, head: this.head };
827
827
  }
828
828
  }
829
- const We = de((o) => o.type.name === "block");
830
- function Ke(o, e) {
829
+ const Ke = de((o) => o.type.name === "block");
830
+ function We(o, e) {
831
831
  if (!e.empty)
832
832
  return;
833
833
  const t = e.$anchor.nodeBefore;
@@ -955,7 +955,7 @@ function je({
955
955
  to: u.to
956
956
  }, l.query = "", l.active = !0, l.type = (b = i.getMeta(o)) == null ? void 0 : b.type, l.selectedItemIndex = 0;
957
957
  } else if (s.active) {
958
- const g = Ke(
958
+ const g = We(
959
959
  s.type === "slash" ? t : "",
960
960
  p.selection
961
961
  );
@@ -1011,7 +1011,7 @@ function je({
1011
1011
  if (!s)
1012
1012
  return null;
1013
1013
  if (u === "drag") {
1014
- const l = We(i.selection);
1014
+ const l = Ke(i.selection);
1015
1015
  if (l)
1016
1016
  return O.create(i.doc, [
1017
1017
  L.node(
@@ -1126,7 +1126,7 @@ const Je = {
1126
1126
  "Used for the body of your document",
1127
1127
  S("Mod-Alt-0")
1128
1128
  )
1129
- }, q = new I("suggestions-slash-commands"), Qe = E.create({
1129
+ }, q = new v("suggestions-slash-commands"), Qe = E.create({
1130
1130
  name: "slash-command",
1131
1131
  addOptions() {
1132
1132
  return {
@@ -1155,7 +1155,7 @@ const Je = {
1155
1155
  })
1156
1156
  ];
1157
1157
  }
1158
- }), Xe = "_bnEditor_xixap_3", Ze = "_bnRoot_xixap_13", et = "_dragPreview_xixap_27", z = {
1158
+ }), Xe = "_bnEditor_xixap_3", Ze = "_bnRoot_xixap_13", et = "_dragPreview_xixap_27", $ = {
1159
1159
  bnEditor: Xe,
1160
1160
  bnRoot: Ze,
1161
1161
  dragPreview: et
@@ -1227,7 +1227,7 @@ function J(o, e, t = e) {
1227
1227
  );
1228
1228
  for (let s = r.childElementCount - 1; s >= 0; s--)
1229
1229
  (s > i || s < d) && n.removeChild(n.children[s]);
1230
- M = n, M.className = z.dragPreview, document.body.appendChild(M);
1230
+ M = n, M.className = $.dragPreview, document.body.appendChild(M);
1231
1231
  }
1232
1232
  function at() {
1233
1233
  M !== void 0 && (document.body.removeChild(M), M = void 0);
@@ -1358,7 +1358,7 @@ class lt {
1358
1358
  }
1359
1359
  }
1360
1360
  const ct = (o) => new T({
1361
- key: new I("DraggableBlocksPlugin"),
1361
+ key: new v("DraggableBlocksPlugin"),
1362
1362
  view: () => new lt({
1363
1363
  editor: o.editor,
1364
1364
  blockMenuFactory: o.blockSideMenuFactory,
@@ -1379,7 +1379,7 @@ const ct = (o) => new T({
1379
1379
  })
1380
1380
  ];
1381
1381
  }
1382
- }), ht = new I("HyperlinkToolbarPlugin");
1382
+ }), ht = new v("HyperlinkToolbarPlugin");
1383
1383
  class pt {
1384
1384
  constructor({ editor: e, hyperlinkToolbarFactory: t }) {
1385
1385
  h(this, "editor");
@@ -1404,7 +1404,7 @@ class pt {
1404
1404
  ), i = d.marks();
1405
1405
  for (const s of i)
1406
1406
  if (s.type.name === e.schema.mark("link").type.name) {
1407
- this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange = W(
1407
+ this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange = K(
1408
1408
  d,
1409
1409
  s.type,
1410
1410
  s.attrs
@@ -1424,7 +1424,7 @@ class pt {
1424
1424
  const d = this.editor.state.selection.$from.marks();
1425
1425
  for (const i of d)
1426
1426
  if (i.type.name === this.editor.schema.mark("link").type.name) {
1427
- this.keyboardHoveredHyperlinkMark = i, this.keyboardHoveredHyperlinkMarkRange = W(
1427
+ this.keyboardHoveredHyperlinkMark = i, this.keyboardHoveredHyperlinkMarkRange = K(
1428
1428
  this.editor.state.selection.$from,
1429
1429
  i.type,
1430
1430
  i.attrs
@@ -1519,7 +1519,7 @@ const mt = (o, e) => new T({
1519
1519
  addKeyboardShortcuts: () => ({
1520
1520
  "Mod-Alt-0": () => !1
1521
1521
  })
1522
- }), kt = E.create({
1522
+ }), kt = new v("blocknote-placeholder"), yt = E.create({
1523
1523
  name: "placeholder",
1524
1524
  addOptions() {
1525
1525
  return {
@@ -1536,6 +1536,7 @@ const mt = (o, e) => new T({
1536
1536
  addProseMirrorPlugins() {
1537
1537
  return [
1538
1538
  new T({
1539
+ key: kt,
1539
1540
  props: {
1540
1541
  decorations: (o) => {
1541
1542
  const { doc: e, selection: t } = o, n = q.getState(o), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: a } = t, d = [];
@@ -1557,10 +1558,10 @@ const mt = (o, e) => new T({
1557
1558
  })
1558
1559
  ];
1559
1560
  }
1560
- }), yt = E.create({
1561
+ }), bt = E.create({
1561
1562
  name: "trailingNode",
1562
1563
  addProseMirrorPlugins() {
1563
- const o = new I(this.name);
1564
+ const o = new v(this.name);
1564
1565
  return [
1565
1566
  new T({
1566
1567
  key: o,
@@ -1590,20 +1591,20 @@ const mt = (o, e) => new T({
1590
1591
  ];
1591
1592
  }
1592
1593
  });
1593
- function bt(o, e = JSON.stringify) {
1594
+ function vt(o, e = JSON.stringify) {
1594
1595
  const t = {};
1595
1596
  return o.filter((n) => {
1596
1597
  const r = e(n);
1597
1598
  return Object.prototype.hasOwnProperty.call(t, r) ? !1 : t[r] = !0;
1598
1599
  });
1599
1600
  }
1600
- function vt(o) {
1601
+ function It(o) {
1601
1602
  const e = o.filter(
1602
1603
  (n, r) => o.indexOf(n) !== r
1603
1604
  );
1604
- return bt(e);
1605
+ return vt(e);
1605
1606
  }
1606
- const It = E.create({
1607
+ const Tt = E.create({
1607
1608
  name: "uniqueID",
1608
1609
  priority: 1e4,
1609
1610
  addOptions() {
@@ -1643,7 +1644,7 @@ const It = E.create({
1643
1644
  let o = null, e = !1;
1644
1645
  return [
1645
1646
  new T({
1646
- key: new I("uniqueID"),
1647
+ key: new v("uniqueID"),
1647
1648
  appendTransaction: (t, n, r) => {
1648
1649
  console.log("appendTransaction");
1649
1650
  const a = t.some((f) => f.docChanged) && !n.doc.eq(r.doc), d = this.options.filterTransaction && t.some((f) => {
@@ -1661,7 +1662,7 @@ const It = E.create({
1661
1662
  r.doc,
1662
1663
  f,
1663
1664
  (C) => s.includes(C.type.name)
1664
- ), b = y.map(({ node: C }) => C.attrs[c]).filter((C) => C !== null), g = vt(b);
1665
+ ), b = y.map(({ node: C }) => C.attrs[c]).filter((C) => C !== null), g = It(b);
1665
1666
  y.forEach(({ node: C, pos: H }) => {
1666
1667
  var R;
1667
1668
  const G = (R = i.doc.nodeAt(H)) === null || R === void 0 ? void 0 : R.attrs[c];
@@ -1725,7 +1726,7 @@ const It = E.create({
1725
1726
  i.push(c);
1726
1727
  }), ee.from(i);
1727
1728
  };
1728
- return e = !1, new $(
1729
+ return e = !1, new z(
1729
1730
  a(t.content),
1730
1731
  t.openStart,
1731
1732
  t.openEnd
@@ -1735,11 +1736,11 @@ const It = E.create({
1735
1736
  })
1736
1737
  ];
1737
1738
  }
1738
- }), Gt = w.create({
1739
+ }), Kt = w.create({
1739
1740
  name: "doc",
1740
1741
  topNode: !0,
1741
1742
  content: "block+"
1742
- }), Tt = (o) => {
1743
+ }), Ct = (o) => {
1743
1744
  const e = [
1744
1745
  P.ClipboardTextSerializer,
1745
1746
  P.Commands,
@@ -1747,14 +1748,14 @@ const It = E.create({
1747
1748
  P.FocusEvents,
1748
1749
  P.Tabindex,
1749
1750
  me,
1750
- kt.configure({
1751
- emptyNodeClass: v.isEmpty,
1752
- hasAnchorClass: v.hasAnchor,
1753
- isFilterClass: v.isFilter,
1751
+ yt.configure({
1752
+ emptyNodeClass: I.isEmpty,
1753
+ hasAnchorClass: I.hasAnchor,
1754
+ isFilterClass: I.isFilter,
1754
1755
  includeChildren: !0,
1755
1756
  showOnlyCurrent: !1
1756
1757
  }),
1757
- It.configure({
1758
+ Tt.configure({
1758
1759
  types: ["block"]
1759
1760
  }),
1760
1761
  fe,
@@ -1765,10 +1766,10 @@ const It = E.create({
1765
1766
  ye,
1766
1767
  ve,
1767
1768
  gt,
1768
- ...ze,
1769
+ ...$e,
1769
1770
  pe.configure({ width: 5, color: "#ddeeff" }),
1770
1771
  ge,
1771
- yt
1772
+ bt
1772
1773
  ];
1773
1774
  return o.blockSideMenuFactory && e.push(
1774
1775
  ut.configure({
@@ -1787,7 +1788,7 @@ const It = E.create({
1787
1788
  slashMenuFactory: o.slashMenuFactory
1788
1789
  })
1789
1790
  ), e;
1790
- }, Ct = {
1791
+ }, Bt = {
1791
1792
  enableInputRules: !0,
1792
1793
  enablePasteRules: !0,
1793
1794
  enableCoreExtensions: !1
@@ -1796,20 +1797,20 @@ class Wt {
1796
1797
  constructor(e = {}) {
1797
1798
  h(this, "tiptapEditor");
1798
1799
  var a, d, i;
1799
- const t = Tt(
1800
+ const t = Ct(
1800
1801
  e.uiFactories || {}
1801
1802
  );
1802
1803
  let n = e.disableHistoryExtension ? t.filter((s) => s.name !== "history") : t;
1803
1804
  const r = {
1804
- ...Ct,
1805
+ ...Bt,
1805
1806
  ...e,
1806
1807
  extensions: e.enableBlockNoteExtensions === !1 ? e.extensions : [...e.extensions || [], ...n],
1807
1808
  editorProps: {
1808
1809
  attributes: {
1809
1810
  ...((a = e.editorProps) == null ? void 0 : a.attributes) || {},
1810
1811
  class: [
1811
- z.bnEditor,
1812
- z.bnRoot,
1812
+ $.bnEditor,
1813
+ $.bnRoot,
1813
1814
  ((i = (d = e.editorProps) == null ? void 0 : d.attributes) == null ? void 0 : i.class) || ""
1814
1815
  ].join(" ")
1815
1816
  }
@@ -1820,9 +1821,9 @@ class Wt {
1820
1821
  }
1821
1822
  export {
1822
1823
  Wt as BlockNoteEditor,
1823
- Gt as Document,
1824
+ Kt as Document,
1824
1825
  B as SlashMenuGroups,
1825
1826
  x as SlashMenuItem,
1826
- Tt as getBlockNoteExtensions
1827
+ Ct as getBlockNoteExtensions
1827
1828
  };
1828
1829
  //# sourceMappingURL=blocknote.js.map