@blocknote/core 0.47.0 → 0.47.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/{BlockNoteSchema-DT4bdXj5.cjs → BlockNoteSchema-CwhtPpVC.cjs} +2 -2
  2. package/dist/{BlockNoteSchema-DT4bdXj5.cjs.map → BlockNoteSchema-CwhtPpVC.cjs.map} +1 -1
  3. package/dist/{BlockNoteSchema-1r-ln0Q0.js → BlockNoteSchema-dmbNkHA-.js} +2 -2
  4. package/dist/{BlockNoteSchema-1r-ln0Q0.js.map → BlockNoteSchema-dmbNkHA-.js.map} +1 -1
  5. package/dist/TrailingNode-DHOdUVUO.cjs +2 -0
  6. package/dist/TrailingNode-DHOdUVUO.cjs.map +1 -0
  7. package/dist/{TrailingNode-DZag-Nvu.js → TrailingNode-F9hX_UlQ.js} +5 -3
  8. package/dist/TrailingNode-F9hX_UlQ.js.map +1 -0
  9. package/dist/blocknote.cjs +4 -4
  10. package/dist/blocknote.cjs.map +1 -1
  11. package/dist/blocknote.js +1169 -954
  12. package/dist/blocknote.js.map +1 -1
  13. package/dist/blocks.cjs +1 -1
  14. package/dist/blocks.js +2 -2
  15. package/dist/{defaultBlocks-D049Pbme.cjs → defaultBlocks-CSB5GiAu.cjs} +5 -5
  16. package/dist/defaultBlocks-CSB5GiAu.cjs.map +1 -0
  17. package/dist/{defaultBlocks-BSOEW3GR.js → defaultBlocks-Caw1U1oV.js} +47 -44
  18. package/dist/defaultBlocks-Caw1U1oV.js.map +1 -0
  19. package/dist/extensions.cjs +1 -1
  20. package/dist/extensions.js +3 -3
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/dist/webpack-stats.json +1 -1
  23. package/package.json +1 -1
  24. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +30 -7
  25. package/src/extensions/Collaboration/YCursorPlugin.ts +3 -1
  26. package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +191 -0
  27. package/src/extensions/SuggestionMenu/SuggestionMenu.ts +28 -11
  28. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +433 -53
  29. package/src/schema/blocks/createSpec.ts +2 -0
  30. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +5 -0
  31. package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +12 -3
  32. package/types/src/extensions/SuggestionMenu/SuggestionMenu.test.d.ts +1 -0
  33. package/dist/TrailingNode-DZag-Nvu.js.map +0 -1
  34. package/dist/TrailingNode-tesI8f7N.cjs +0 -2
  35. package/dist/TrailingNode-tesI8f7N.cjs.map +0 -1
  36. package/dist/defaultBlocks-BSOEW3GR.js.map +0 -1
  37. package/dist/defaultBlocks-D049Pbme.cjs.map +0 -1
@@ -14,10 +14,10 @@ import at from "@tiptap/extension-code";
14
14
  import st from "@tiptap/extension-italic";
15
15
  import it from "@tiptap/extension-strike";
16
16
  import ct from "@tiptap/extension-underline";
17
- import { DOMParser as xe, Fragment as lt, DOMSerializer as ie } from "@tiptap/pm/model";
17
+ import { DOMParser as Se, Fragment as lt, DOMSerializer as ie } from "@tiptap/pm/model";
18
18
  import { createHighlightPlugin as dt } from "prosemirror-highlight";
19
19
  import { createParser as ut } from "prosemirror-highlight/shiki";
20
- import { Slice as Se, Fragment as F, DOMParser as we } from "prosemirror-model";
20
+ import { Slice as xe, Fragment as F, DOMParser as we } from "prosemirror-model";
21
21
  import { Plugin as pt, PluginKey as ft } from "@tiptap/pm/state";
22
22
  import { DecorationSet as ce, Decoration as ht } from "@tiptap/pm/view";
23
23
  const mt = () => typeof navigator < "u" && (/Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent));
@@ -219,7 +219,7 @@ function Et(e, t) {
219
219
  i,
220
220
  (a = t.meta) != null && a.code ? `
221
221
  ` : "<br>"
222
- ), xe.fromSchema(r).parse(i, {
222
+ ), Se.fromSchema(r).parse(i, {
223
223
  topNode: r.nodes.paragraph.create(),
224
224
  preserveWhitespace: !0
225
225
  }).content;
@@ -387,14 +387,14 @@ function bo(e) {
387
387
  }
388
388
  };
389
389
  }
390
- function xt(e, t) {
390
+ function St(e, t) {
391
391
  return {
392
392
  config: e,
393
393
  implementation: t
394
394
  };
395
395
  }
396
396
  function Co(e, t, n) {
397
- return xt(
397
+ return St(
398
398
  {
399
399
  type: e.name,
400
400
  propSchema: t,
@@ -406,7 +406,7 @@ function Co(e, t, n) {
406
406
  }
407
407
  );
408
408
  }
409
- function St(e) {
409
+ function xt(e) {
410
410
  return Object.fromEntries(
411
411
  Object.entries(e).map(([t, n]) => [t, n.config])
412
412
  );
@@ -650,7 +650,7 @@ function At(e, t, n, o, r, a, s) {
650
650
  t.replace(
651
651
  l,
652
652
  u,
653
- new Se(
653
+ new xe(
654
654
  F.from(c),
655
655
  p - d - 1,
656
656
  m - d - 1
@@ -678,7 +678,7 @@ function de(e, t, n) {
678
678
  new ze(
679
679
  n.childContainer.beforePos + 1,
680
680
  n.childContainer.afterPos - 1,
681
- new Se(F.from(r), 0, 0)
681
+ new xe(F.from(r), 0, 0)
682
682
  )
683
683
  );
684
684
  else {
@@ -711,10 +711,10 @@ function Pt(e) {
711
711
  return null;
712
712
  const n = e.doc.resolve(t.head);
713
713
  let o = -1, r = -1;
714
- for (let S = n.depth; S >= 0; S--) {
715
- const x = n.node(S).type.name;
716
- if (o < 0 && (x === "tableCell" || x === "tableHeader") && (o = S), x === "table") {
717
- r = S;
714
+ for (let x = n.depth; x >= 0; x--) {
715
+ const S = n.node(x).type.name;
716
+ if (o < 0 && (S === "tableCell" || S === "tableHeader") && (o = x), S === "table") {
717
+ r = x;
718
718
  break;
719
719
  }
720
720
  }
@@ -730,15 +730,15 @@ function Pt(e) {
730
730
  return { row: d, col: p, offset: E };
731
731
  }
732
732
  function Nt(e, t, n) {
733
- var S;
733
+ var x;
734
734
  if (t.blockNoteType !== "table")
735
735
  return !1;
736
736
  let o = -1;
737
737
  if (t.isBlockContainer)
738
738
  o = e.mapping.map(t.blockContent.beforePos);
739
739
  else {
740
- const x = e.mapping.map(t.bnBlock.beforePos), P = x + (((S = e.doc.nodeAt(x)) == null ? void 0 : S.nodeSize) || 0);
741
- e.doc.nodesBetween(x, P, (g, w) => g.type.name === "table" ? (o = w, !1) : !0);
740
+ const S = e.mapping.map(t.bnBlock.beforePos), P = S + (((x = e.doc.nodeAt(S)) == null ? void 0 : x.nodeSize) || 0);
741
+ e.doc.nodesBetween(S, P, (g, w) => g.type.name === "table" ? (o = w, !1) : !0);
742
742
  }
743
743
  const r = o >= 0 ? e.doc.nodeAt(o) : null;
744
744
  if (!r || r.type.name !== "table")
@@ -847,13 +847,13 @@ const T = {
847
847
  renderHTML: (t) => t[e] === h.backgroundColor.default ? {} : {
848
848
  "data-background-color": t[e]
849
849
  }
850
- }), xo = (e = "textColor") => ({
850
+ }), So = (e = "textColor") => ({
851
851
  default: h.textColor.default,
852
852
  parseHTML: (t) => t.hasAttribute("data-text-color") ? t.getAttribute("data-text-color") : t.style.color ? t.style.color : h.textColor.default,
853
853
  renderHTML: (t) => t[e] === h.textColor.default ? {} : {
854
854
  "data-text-color": t[e]
855
855
  }
856
- }), So = (e = "textAlignment") => ({
856
+ }), xo = (e = "textAlignment") => ({
857
857
  default: h.textAlignment.default,
858
858
  parseHTML: (t) => t.hasAttribute("data-text-alignment") ? t.getAttribute("data-text-alignment") : t.style.textAlign ? t.style.textAlign : h.textAlignment.default,
859
859
  renderHTML: (t) => t[e] === h.textAlignment.default ? {} : {
@@ -1100,7 +1100,7 @@ const Ut = ({ defaultLanguage: e = "text" }) => ({
1100
1100
  return { language: n.getAttribute("data-language") || ((a = n.className.split(" ").find((s) => s.includes("language-"))) == null ? void 0 : a.replace("language-", "")) };
1101
1101
  },
1102
1102
  parseContent: ({ el: t, schema: n }) => {
1103
- const o = xe.fromSchema(n), r = t.firstElementChild;
1103
+ const o = Se.fromSchema(n), r = t.firstElementChild;
1104
1104
  return o.parse(r, {
1105
1105
  preserveWhitespace: "full",
1106
1106
  topNode: n.nodes.codeBlock.create()
@@ -1502,9 +1502,9 @@ const jt = () => ({
1502
1502
  }));
1503
1503
  }, E = () => {
1504
1504
  t.isEditable && (o.appendChild(c), o.appendChild(l));
1505
- }, S = (g) => {
1506
- g.relatedTarget === c || g.relatedTarget === l || d || t.isEditable && o.contains(c) && o.contains(l) && (o.removeChild(c), o.removeChild(l));
1507
1505
  }, x = (g) => {
1506
+ g.relatedTarget === c || g.relatedTarget === l || d || t.isEditable && o.contains(c) && o.contains(l) && (o.removeChild(c), o.removeChild(l));
1507
+ }, S = (g) => {
1508
1508
  g.preventDefault(), i.contains(u) || i.appendChild(u);
1509
1509
  const w = "touches" in g ? g.touches[0].clientX : g.clientX;
1510
1510
  d = {
@@ -1521,12 +1521,12 @@ const jt = () => ({
1521
1521
  initialClientX: w
1522
1522
  };
1523
1523
  };
1524
- return window.addEventListener("mousemove", m), window.addEventListener("touchmove", m), window.addEventListener("mouseup", f), window.addEventListener("touchend", f), i.addEventListener("mouseenter", E), i.addEventListener("mouseleave", S), c.addEventListener(
1524
+ return window.addEventListener("mousemove", m), window.addEventListener("touchmove", m), window.addEventListener("mouseup", f), window.addEventListener("touchend", f), i.addEventListener("mouseenter", E), i.addEventListener("mouseleave", x), c.addEventListener(
1525
1525
  "mousedown",
1526
- x
1526
+ S
1527
1527
  ), c.addEventListener(
1528
1528
  "touchstart",
1529
- x
1529
+ S
1530
1530
  ), l.addEventListener(
1531
1531
  "mousedown",
1532
1532
  P
@@ -1536,12 +1536,12 @@ const jt = () => ({
1536
1536
  ), {
1537
1537
  dom: i,
1538
1538
  destroy: () => {
1539
- s == null || s(), window.removeEventListener("mousemove", m), window.removeEventListener("touchmove", m), window.removeEventListener("mouseup", f), window.removeEventListener("touchend", f), i.removeEventListener("mouseenter", E), i.removeEventListener("mouseleave", S), c.removeEventListener(
1539
+ s == null || s(), window.removeEventListener("mousemove", m), window.removeEventListener("touchmove", m), window.removeEventListener("mouseup", f), window.removeEventListener("touchend", f), i.removeEventListener("mouseenter", E), i.removeEventListener("mouseleave", x), c.removeEventListener(
1540
1540
  "mousedown",
1541
- x
1541
+ S
1542
1542
  ), c.removeEventListener(
1543
1543
  "touchstart",
1544
- x
1544
+ S
1545
1545
  ), l.removeEventListener(
1546
1546
  "mousedown",
1547
1547
  P
@@ -2203,7 +2203,7 @@ const un = () => new pt({
2203
2203
  }
2204
2204
  }), En = {
2205
2205
  textColor: h.textColor
2206
- }, xn = N.create({
2206
+ }, Sn = N.create({
2207
2207
  name: "tableHeader",
2208
2208
  addOptions() {
2209
2209
  return {
@@ -2254,7 +2254,7 @@ const un = () => new pt({
2254
2254
  0
2255
2255
  ];
2256
2256
  }
2257
- }), Sn = N.create({
2257
+ }), xn = N.create({
2258
2258
  name: "tableCell",
2259
2259
  addOptions() {
2260
2260
  return {
@@ -2430,8 +2430,8 @@ const Tn = () => vt(
2430
2430
  tiptapExtensions: [
2431
2431
  yn,
2432
2432
  Mn,
2433
- xn,
2434
2433
  Sn,
2434
+ xn,
2435
2435
  Ln
2436
2436
  ]
2437
2437
  }),
@@ -2667,17 +2667,17 @@ class On {
2667
2667
  }
2668
2668
  }
2669
2669
  const B = new Ze("SuggestionMenuPlugin"), _n = k(({ editor: e }) => {
2670
- const t = [];
2670
+ const t = /* @__PURE__ */ new Map();
2671
2671
  let n;
2672
2672
  const o = ve(void 0);
2673
2673
  return {
2674
2674
  key: "suggestionMenu",
2675
2675
  store: o,
2676
- addTriggerCharacter: (r) => {
2677
- t.push(r);
2676
+ addSuggestionMenu: (r) => {
2677
+ t.set(r.triggerCharacter, r);
2678
2678
  },
2679
- removeTriggerCharacter: (r) => {
2680
- t.splice(t.indexOf(r), 1);
2679
+ removeSuggestionMenu: (r) => {
2680
+ t.delete(r);
2681
2681
  },
2682
2682
  closeMenu: () => {
2683
2683
  n == null || n.closeMenu();
@@ -2760,14 +2760,17 @@ const B = new Ze("SuggestionMenuPlugin"), _n = k(({ editor: e }) => {
2760
2760
  handleTextInput(r, a, s, i) {
2761
2761
  if (a === s) {
2762
2762
  const c = r.state.doc;
2763
- for (const l of t) {
2764
- const u = l.length > 1 ? c.textBetween(a - l.length, a) + i : i;
2765
- if (l === u)
2763
+ for (const [l, u] of t) {
2764
+ const d = l.length > 1 ? c.textBetween(a - l.length, a) + i : i;
2765
+ if (l === d) {
2766
+ if (u.shouldOpen && !u.shouldOpen(r.state.tr))
2767
+ continue;
2766
2768
  return r.dispatch(r.state.tr.insertText(i)), r.dispatch(
2767
2769
  r.state.tr.setMeta(B, {
2768
- triggerCharacter: u
2770
+ triggerCharacter: d
2769
2771
  }).scrollIntoView()
2770
2772
  ), !0;
2773
+ }
2771
2774
  }
2772
2775
  }
2773
2776
  return !1;
@@ -3087,7 +3090,7 @@ const Po = {
3087
3090
  }, No = Mt(Fn), $n = {
3088
3091
  text: { config: "text", implementation: {} },
3089
3092
  link: { config: "link", implementation: {} }
3090
- }, Ho = St(
3093
+ }, Ho = xt(
3091
3094
  $n
3092
3095
  );
3093
3096
  export {
@@ -3126,13 +3129,13 @@ export {
3126
3129
  v as a3,
3127
3130
  A as a4,
3128
3131
  Eo as a5,
3129
- xo as a6,
3130
- So as a7,
3132
+ So as a6,
3133
+ xo as a7,
3131
3134
  I as a8,
3132
3135
  _n as a9,
3133
3136
  Z as aA,
3134
3137
  vt as aB,
3135
- xt as aC,
3138
+ St as aC,
3136
3139
  Lt as aD,
3137
3140
  Le as aE,
3138
3141
  wt as aF,
@@ -3150,7 +3153,7 @@ export {
3150
3153
  Ao as ac,
3151
3154
  ho as ad,
3152
3155
  Mt as ae,
3153
- St as af,
3156
+ xt as af,
3154
3157
  mo as ag,
3155
3158
  y as ah,
3156
3159
  Bt as ai,
@@ -3197,4 +3200,4 @@ export {
3197
3200
  cn as y,
3198
3201
  ln as z
3199
3202
  };
3200
- //# sourceMappingURL=defaultBlocks-BSOEW3GR.js.map
3203
+ //# sourceMappingURL=defaultBlocks-Caw1U1oV.js.map