@blocknote/core 0.4.0 → 0.4.3

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 (87) hide show
  1. package/dist/blocknote.js +12371 -12268
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +20 -20
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +2 -2
  7. package/src/BlockNoteEditor.ts +237 -14
  8. package/src/BlockNoteExtensions.ts +19 -15
  9. package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +616 -0
  10. package/src/api/blockManipulation/blockManipulation.test.ts +172 -0
  11. package/src/api/blockManipulation/blockManipulation.ts +25 -14
  12. package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +346 -0
  13. package/src/api/formatConversions/formatConversions.test.ts +766 -0
  14. package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +268 -0
  15. package/src/api/nodeConversions/nodeConversions.test.ts +244 -0
  16. package/src/api/nodeConversions/nodeConversions.ts +167 -58
  17. package/src/api/nodeConversions/testUtil.ts +61 -0
  18. package/src/api/util/nodeUtil.ts +38 -0
  19. package/src/editor.module.css +1 -0
  20. package/src/extensions/Blocks/api/blockTypes.ts +14 -9
  21. package/src/extensions/Blocks/api/cursorPositionTypes.ts +2 -0
  22. package/src/extensions/Blocks/api/inlineContentTypes.ts +27 -36
  23. package/src/extensions/Blocks/nodes/Block.module.css +39 -36
  24. package/src/extensions/Blocks/nodes/BlockContainer.ts +15 -14
  25. package/src/extensions/DraggableBlocks/DraggableBlocksPlugin.ts +149 -87
  26. package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +31 -0
  27. package/src/extensions/SlashMenu/SlashMenuExtension.ts +10 -7
  28. package/src/extensions/SlashMenu/{defaultSlashCommands.tsx → defaultSlashMenuItems.tsx} +59 -106
  29. package/src/extensions/SlashMenu/index.ts +3 -7
  30. package/src/index.ts +2 -3
  31. package/src/shared/plugins/suggestion/SuggestionItem.ts +2 -13
  32. package/src/shared/plugins/suggestion/SuggestionPlugin.ts +31 -18
  33. package/src/shared/utils.ts +6 -0
  34. package/types/src/BlockNoteEditor.d.ts +82 -8
  35. package/types/src/BlockNoteExtensions.d.ts +5 -4
  36. package/types/src/api/Editor.d.ts +26 -6
  37. package/types/src/api/blockManipulation/blockManipulation.d.ts +5 -5
  38. package/types/src/api/blockManipulation/blockManipulation.test.d.ts +1 -0
  39. package/types/src/api/formatConversions/formatConversions.test.d.ts +1 -0
  40. package/types/src/api/nodeConversions/nodeConversions.d.ts +11 -4
  41. package/types/src/api/nodeConversions/nodeConversions.test.d.ts +1 -0
  42. package/types/src/api/nodeConversions/testUtil.d.ts +2 -0
  43. package/types/src/api/util/nodeUtil.d.ts +8 -0
  44. package/types/src/extensions/Blocks/api/blockTypes.d.ts +10 -9
  45. package/types/src/extensions/Blocks/api/cursorPositionTypes.d.ts +2 -0
  46. package/types/src/extensions/Blocks/api/inlineContentTypes.d.ts +25 -19
  47. package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +15 -0
  48. package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +20 -0
  49. package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +4 -2
  50. package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +5 -0
  51. package/types/src/extensions/SlashMenu/index.d.ts +3 -3
  52. package/types/src/index.d.ts +2 -3
  53. package/types/src/shared/plugins/suggestion/SuggestionItem.d.ts +3 -11
  54. package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +4 -4
  55. package/types/src/shared/utils.d.ts +3 -0
  56. package/src/api/Editor.ts +0 -142
  57. package/src/extensions/SlashMenu/SlashMenuItem.ts +0 -34
  58. package/types/src/EditorElement.d.ts +0 -7
  59. package/types/src/api/Document.d.ts +0 -5
  60. package/types/src/api/removeUnderlinesRehypePlugin.d.ts +0 -6
  61. package/types/src/api/simplifyBlocksRehypePlugin.d.ts +0 -16
  62. package/types/src/extensions/Blocks/BlockAttributes.d.ts +0 -2
  63. package/types/src/extensions/Blocks/MultipleNodeSelection.d.ts +0 -24
  64. package/types/src/extensions/Blocks/api/apiTypes.d.ts +0 -18
  65. package/types/src/extensions/Blocks/api/styleTypes.d.ts +0 -22
  66. package/types/src/extensions/Blocks/apiTypes.d.ts +0 -16
  67. package/types/src/extensions/Blocks/nodes/Block.d.ts +0 -24
  68. package/types/src/extensions/Blocks/nodes/BlockContent/BlockContentTypes.d.ts +0 -4
  69. package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContentTypes.d.ts +0 -4
  70. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContentTypes.d.ts +0 -2
  71. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContentTypes.d.ts +0 -2
  72. package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContentTypes.d.ts +0 -2
  73. package/types/src/extensions/Blocks/nodes/BlockTypes/HeadingBlock/HeadingContent.d.ts +0 -8
  74. package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/ListItemContent.d.ts +0 -8
  75. package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/OrderedListItemIndexPlugin.d.ts +0 -2
  76. package/types/src/extensions/Blocks/nodes/BlockTypes/TextBlock/TextContent.d.ts +0 -6
  77. package/types/src/extensions/BubbleMenu/BubbleMenuExtension.d.ts +0 -8
  78. package/types/src/extensions/BubbleMenu/BubbleMenuFactoryTypes.d.ts +0 -27
  79. package/types/src/extensions/BubbleMenu/BubbleMenuPlugin.d.ts +0 -44
  80. package/types/src/extensions/DraggableBlocks/BlockMenuFactoryTypes.d.ts +0 -12
  81. package/types/src/extensions/DraggableBlocks/DragMenuFactoryTypes.d.ts +0 -18
  82. package/types/src/extensions/Hyperlinks/HyperlinkMark.d.ts +0 -8
  83. package/types/src/extensions/Hyperlinks/HyperlinkMenuFactoryTypes.d.ts +0 -11
  84. package/types/src/extensions/Hyperlinks/HyperlinkMenuPlugin.d.ts +0 -11
  85. package/types/src/extensions/Paragraph/FixedParagraph.d.ts +0 -1
  86. package/types/src/extensions/SlashMenu/defaultCommands.d.ts +0 -8
  87. package/types/src/utils.d.ts +0 -2
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "homepage": "https://github.com/yousefed/blocknote",
4
4
  "private": false,
5
5
  "license": "MPL-2.0",
6
- "version": "0.4.0",
6
+ "version": "0.4.3",
7
7
  "files": [
8
8
  "dist",
9
9
  "types",
@@ -106,5 +106,5 @@
106
106
  "access": "public",
107
107
  "registry": "https://registry.npmjs.org/"
108
108
  },
109
- "gitHead": "aa88219581e5427fd86c759b827ffc2b2f3af99b"
109
+ "gitHead": "4f578e0a8676b815316bdeb978cd4748d948868c"
110
110
  }
@@ -1,20 +1,41 @@
1
1
  import { Editor, EditorOptions } from "@tiptap/core";
2
-
2
+ import { Node } from "prosemirror-model";
3
3
  // import "./blocknote.css";
4
- import { Editor as EditorAPI } from "./api/Editor";
4
+ import { Block, PartialBlock } from "./extensions/Blocks/api/blockTypes";
5
5
  import { getBlockNoteExtensions, UiFactories } from "./BlockNoteExtensions";
6
6
  import styles from "./editor.module.css";
7
- import { defaultSlashCommands, SlashCommand } from "./extensions/SlashMenu";
7
+ import {
8
+ defaultSlashMenuItems,
9
+ BaseSlashMenuItem,
10
+ } from "./extensions/SlashMenu";
11
+ import { Editor as TiptapEditor } from "@tiptap/core/dist/packages/core/src/Editor";
12
+ import { nodeToBlock } from "./api/nodeConversions/nodeConversions";
13
+ import { TextCursorPosition } from "./extensions/Blocks/api/cursorPositionTypes";
14
+ import { getBlockInfoFromPos } from "./extensions/Blocks/helpers/getBlockInfoFromPos";
15
+ import { getNodeById } from "./api/util/nodeUtil";
16
+ import {
17
+ insertBlocks,
18
+ updateBlock,
19
+ removeBlocks,
20
+ replaceBlocks,
21
+ } from "./api/blockManipulation/blockManipulation";
22
+ import {
23
+ blocksToHTML,
24
+ HTMLToBlocks,
25
+ blocksToMarkdown,
26
+ markdownToBlocks,
27
+ } from "./api/formatConversions/formatConversions";
8
28
 
9
29
  export type BlockNoteEditorOptions = {
30
+ // TODO: Figure out if enableBlockNoteExtensions/disableHistoryExtension are needed and document them.
10
31
  enableBlockNoteExtensions: boolean;
11
32
  disableHistoryExtension: boolean;
12
33
  uiFactories: UiFactories;
13
- slashCommands: SlashCommand[];
34
+ slashCommands: BaseSlashMenuItem[];
14
35
  parentElement: HTMLElement;
15
36
  editorDOMAttributes: Record<string, string>;
16
- onUpdate: () => void;
17
- onCreate: () => void;
37
+ onUpdate: (editor: BlockNoteEditor) => void;
38
+ onCreate: (editor: BlockNoteEditor) => void;
18
39
 
19
40
  // tiptap options, undocumented
20
41
  _tiptapOptions: any;
@@ -26,8 +47,9 @@ const blockNoteTipTapOptions = {
26
47
  enableCoreExtensions: false,
27
48
  };
28
49
 
29
- export class BlockNoteEditor extends EditorAPI {
30
- public readonly _tiptapEditor: Editor & { contentComponent: any };
50
+ export class BlockNoteEditor {
51
+ public readonly _tiptapEditor: TiptapEditor & { contentComponent: any };
52
+ private blockCache = new WeakMap<Node, Block>();
31
53
 
32
54
  public get domElement() {
33
55
  return this._tiptapEditor.view.dom as HTMLDivElement;
@@ -35,8 +57,9 @@ export class BlockNoteEditor extends EditorAPI {
35
57
 
36
58
  constructor(options: Partial<BlockNoteEditorOptions> = {}) {
37
59
  const blockNoteExtensions = getBlockNoteExtensions({
60
+ editor: this,
38
61
  uiFactories: options.uiFactories || {},
39
- slashCommands: options.slashCommands || defaultSlashCommands,
62
+ slashCommands: options.slashCommands || defaultSlashMenuItems,
40
63
  });
41
64
 
42
65
  let extensions = options.disableHistoryExtension
@@ -47,10 +70,10 @@ export class BlockNoteEditor extends EditorAPI {
47
70
  ...blockNoteTipTapOptions,
48
71
  ...options._tiptapOptions,
49
72
  onUpdate: () => {
50
- options.onUpdate?.();
73
+ options.onUpdate?.(this);
51
74
  },
52
75
  onCreate: () => {
53
- options.onCreate?.();
76
+ options.onCreate?.(this);
54
77
  },
55
78
  extensions:
56
79
  options.enableBlockNoteExtensions === false
@@ -68,10 +91,210 @@ export class BlockNoteEditor extends EditorAPI {
68
91
  },
69
92
  };
70
93
 
71
- const _tiptapEditor = new Editor(tiptapOptions) as Editor & {
94
+ this._tiptapEditor = new Editor(tiptapOptions) as Editor & {
72
95
  contentComponent: any;
73
96
  };
74
- super(_tiptapEditor);
75
- this._tiptapEditor = _tiptapEditor;
97
+ }
98
+
99
+ /**
100
+ * Gets a list of all top-level blocks that are in the editor.
101
+ */
102
+ public get topLevelBlocks(): Block[] {
103
+ const blocks: Block[] = [];
104
+
105
+ this._tiptapEditor.state.doc.firstChild!.descendants((node) => {
106
+ blocks.push(nodeToBlock(node, this.blockCache));
107
+
108
+ return false;
109
+ });
110
+
111
+ return blocks;
112
+ }
113
+
114
+ /**
115
+ * Traverses all blocks in the editor, including all nested blocks, and executes a callback for each. The traversal is
116
+ * depth-first, which is the same order as blocks appear in the editor by y-coordinate.
117
+ * @param callback The callback to execute for each block.
118
+ * @param reverse Whether the blocks should be traversed in reverse order.
119
+ */
120
+ public allBlocks(
121
+ callback: (block: Block) => void,
122
+ reverse: boolean = false
123
+ ): void {
124
+ function helper(blocks: Block[]) {
125
+ if (reverse) {
126
+ for (const block of blocks.reverse()) {
127
+ helper(block.children);
128
+ callback(block);
129
+ }
130
+ } else {
131
+ for (const block of blocks) {
132
+ callback(block);
133
+ helper(block.children);
134
+ }
135
+ }
136
+ }
137
+
138
+ helper(this.topLevelBlocks);
139
+ }
140
+
141
+ /**
142
+ * Gets information regarding the position of the text cursor in the editor.
143
+ */
144
+ public getTextCursorPosition(): TextCursorPosition {
145
+ const { node, depth, startPos, endPos } = getBlockInfoFromPos(
146
+ this._tiptapEditor.state.doc,
147
+ this._tiptapEditor.state.selection.from
148
+ )!;
149
+
150
+ // Index of the current blockContainer node relative to its parent blockGroup.
151
+ const nodeIndex = this._tiptapEditor.state.doc
152
+ .resolve(endPos)
153
+ .index(depth - 1);
154
+ // Number of the parent blockGroup's child blockContainer nodes.
155
+ const numNodes = this._tiptapEditor.state.doc
156
+ .resolve(endPos + 1)
157
+ .node().childCount;
158
+
159
+ // Gets previous blockContainer node at the same nesting level, if the current node isn't the first child.
160
+ let prevNode: Node | undefined = undefined;
161
+ if (nodeIndex > 0) {
162
+ prevNode = this._tiptapEditor.state.doc.resolve(startPos - 2).node();
163
+ }
164
+
165
+ // Gets next blockContainer node at the same nesting level, if the current node isn't the last child.
166
+ let nextNode: Node | undefined = undefined;
167
+ if (nodeIndex < numNodes - 1) {
168
+ nextNode = this._tiptapEditor.state.doc.resolve(endPos + 2).node();
169
+ }
170
+
171
+ return {
172
+ block: nodeToBlock(node, this.blockCache),
173
+ prevBlock:
174
+ prevNode === undefined
175
+ ? undefined
176
+ : nodeToBlock(prevNode, this.blockCache),
177
+ nextBlock:
178
+ nextNode === undefined
179
+ ? undefined
180
+ : nodeToBlock(nextNode, this.blockCache),
181
+ };
182
+ }
183
+
184
+ public setTextCursorPosition(
185
+ block: Block,
186
+ placement: "start" | "end" = "start"
187
+ ) {
188
+ const { posBeforeNode } = getNodeById(
189
+ block.id,
190
+ this._tiptapEditor.state.doc
191
+ );
192
+ const { startPos, contentNode } = getBlockInfoFromPos(
193
+ this._tiptapEditor.state.doc,
194
+ posBeforeNode + 2
195
+ )!;
196
+
197
+ if (placement === "start") {
198
+ this._tiptapEditor.commands.setTextSelection(startPos + 1);
199
+ } else {
200
+ this._tiptapEditor.commands.setTextSelection(
201
+ startPos + contentNode.nodeSize - 1
202
+ );
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Inserts multiple blocks before, after, or nested inside an existing block in the editor.
208
+ * @param blocksToInsert An array of blocks to insert.
209
+ * @param blockToInsertAt An existing block, marking where the new blocks should be inserted at.
210
+ * @param placement Determines whether the blocks should be inserted just before, just after, or nested inside the
211
+ * existing block.
212
+ */
213
+ public insertBlocks(
214
+ blocksToInsert: PartialBlock[],
215
+ blockToInsertAt: Block,
216
+ placement: "before" | "after" | "nested" = "before"
217
+ ): void {
218
+ insertBlocks(
219
+ blocksToInsert,
220
+ blockToInsertAt,
221
+ placement,
222
+ this._tiptapEditor
223
+ );
224
+ }
225
+
226
+ /**
227
+ * Updates a block in the editor to the given specification.
228
+ * @param blockToUpdate The block that should be updated.
229
+ * @param updatedBlock The specification that the block should be updated to.
230
+ */
231
+ public updateBlock(blockToUpdate: Block, updatedBlock: PartialBlock) {
232
+ updateBlock(blockToUpdate, updatedBlock, this._tiptapEditor);
233
+ }
234
+
235
+ /**
236
+ * Removes multiple blocks from the editor. Throws an error if any of the blocks could not be found.
237
+ * @param blocksToRemove An array of blocks that should be removed.
238
+ */
239
+ public removeBlocks(blocksToRemove: Block[]) {
240
+ removeBlocks(blocksToRemove, this._tiptapEditor);
241
+ }
242
+
243
+ /**
244
+ * Replaces multiple blocks in the editor with several other blocks. If the provided blocks to remove are not adjacent
245
+ * to each other, the new blocks are inserted at the position of the first block in the array. Throws an error if any
246
+ * of the blocks could not be found.
247
+ * @param blocksToRemove An array of blocks that should be replaced.
248
+ * @param blocksToInsert An array of blocks to replace the old ones with.
249
+ */
250
+ public replaceBlocks(
251
+ blocksToRemove: Block[],
252
+ blocksToInsert: PartialBlock[]
253
+ ) {
254
+ replaceBlocks(blocksToRemove, blocksToInsert, this._tiptapEditor);
255
+ }
256
+
257
+ /**
258
+ * Executes a callback function whenever the editor's content changes.
259
+ * @param callback The callback function to execute.
260
+ */
261
+ public onContentChange(callback: () => void) {
262
+ this._tiptapEditor.on("update", callback);
263
+ }
264
+
265
+ /**
266
+ * Serializes a list of blocks into an HTML string. The output is not the same as what's rendered by the editor, and
267
+ * is simplified in order to better conform to HTML standards. Block structuring elements are removed, children of
268
+ * blocks which aren't list items are lifted out of them, and list items blocks are wrapped in `ul`/`ol` tags.
269
+ * @param blocks The list of blocks to serialize into HTML.
270
+ */
271
+ public async blocksToHTML(blocks: Block[]): Promise<string> {
272
+ return blocksToHTML(blocks, this._tiptapEditor.schema);
273
+ }
274
+
275
+ /**
276
+ * Creates a list of blocks from an HTML string.
277
+ * @param htmlString The HTML string to create a list of blocks from.
278
+ */
279
+ public async HTMLToBlocks(htmlString: string): Promise<Block[]> {
280
+ return HTMLToBlocks(htmlString, this._tiptapEditor.schema);
281
+ }
282
+
283
+ /**
284
+ * Serializes a list of blocks into a Markdown string. The output is simplified as Markdown does not support all
285
+ * features of BlockNote. Block structuring elements are removed, children of blocks which aren't list items are
286
+ * lifted out of them, and certain styles are removed.
287
+ * @param blocks The list of blocks to serialize into Markdown.
288
+ */
289
+ public async blocksToMarkdown(blocks: Block[]): Promise<string> {
290
+ return blocksToMarkdown(blocks, this._tiptapEditor.schema);
291
+ }
292
+
293
+ /**
294
+ * Creates a list of blocks from a Markdown string.
295
+ * @param markdownString The Markdown string to create a list of blocks from.
296
+ */
297
+ public async markdownToBlocks(markdownString: string): Promise<Block[]> {
298
+ return markdownToBlocks(markdownString, this._tiptapEditor.schema);
76
299
  }
77
300
  }
@@ -1,16 +1,18 @@
1
1
  import { Extensions, extensions } from "@tiptap/core";
2
2
 
3
- import Bold from "@tiptap/extension-bold";
4
- import Code from "@tiptap/extension-code";
5
- import DropCursor from "@tiptap/extension-dropcursor";
6
- import GapCursor from "@tiptap/extension-gapcursor";
7
- import HardBreak from "@tiptap/extension-hard-break";
3
+ import { BlockNoteEditor } from "./BlockNoteEditor";
4
+
5
+ import { Bold } from "@tiptap/extension-bold";
6
+ import { Code } from "@tiptap/extension-code";
7
+ import { Dropcursor } from "@tiptap/extension-dropcursor";
8
+ import { Gapcursor } from "@tiptap/extension-gapcursor";
9
+ import { HardBreak } from "@tiptap/extension-hard-break";
8
10
  import { History } from "@tiptap/extension-history";
9
- import Italic from "@tiptap/extension-italic";
11
+ import { Italic } from "@tiptap/extension-italic";
10
12
  import { Link } from "@tiptap/extension-link";
11
- import Strike from "@tiptap/extension-strike";
12
- import Text from "@tiptap/extension-text";
13
- import Underline from "@tiptap/extension-underline";
13
+ import { Strike } from "@tiptap/extension-strike";
14
+ import { Text } from "@tiptap/extension-text";
15
+ import { Underline } from "@tiptap/extension-underline";
14
16
  import { BackgroundColorExtension } from "./extensions/BackgroundColor/BackgroundColorExtension";
15
17
  import { BackgroundColorMark } from "./extensions/BackgroundColor/BackgroundColorMark";
16
18
  import { blocks } from "./extensions/Blocks";
@@ -22,8 +24,8 @@ import { FormattingToolbarFactory } from "./extensions/FormattingToolbar/Formatt
22
24
  import HyperlinkMark from "./extensions/HyperlinkToolbar/HyperlinkMark";
23
25
  import { HyperlinkToolbarFactory } from "./extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes";
24
26
  import { Placeholder } from "./extensions/Placeholder/PlaceholderExtension";
25
- import { SlashCommand, SlashMenuExtension } from "./extensions/SlashMenu";
26
- import { SlashMenuItem } from "./extensions/SlashMenu/SlashMenuItem";
27
+ import { SlashMenuExtension } from "./extensions/SlashMenu";
28
+ import { BaseSlashMenuItem } from "./extensions/SlashMenu";
27
29
  import { TextAlignmentExtension } from "./extensions/TextAlignment/TextAlignmentExtension";
28
30
  import { TextColorExtension } from "./extensions/TextColor/TextColorExtension";
29
31
  import { TextColorMark } from "./extensions/TextColor/TextColorMark";
@@ -34,7 +36,7 @@ import { SuggestionsMenuFactory } from "./shared/plugins/suggestion/SuggestionsM
34
36
  export type UiFactories = Partial<{
35
37
  formattingToolbarFactory: FormattingToolbarFactory;
36
38
  hyperlinkToolbarFactory: HyperlinkToolbarFactory;
37
- slashMenuFactory: SuggestionsMenuFactory<SlashMenuItem>;
39
+ slashMenuFactory: SuggestionsMenuFactory<BaseSlashMenuItem>;
38
40
  blockSideMenuFactory: BlockSideMenuFactory;
39
41
  }>;
40
42
 
@@ -42,8 +44,9 @@ export type UiFactories = Partial<{
42
44
  * Get all the Tiptap extensions BlockNote is configured with by default
43
45
  */
44
46
  export const getBlockNoteExtensions = (opts: {
47
+ editor: BlockNoteEditor;
45
48
  uiFactories: UiFactories;
46
- slashCommands: SlashCommand[];
49
+ slashCommands: BaseSlashMenuItem[];
47
50
  }) => {
48
51
  const ret: Extensions = [
49
52
  extensions.ClipboardTextSerializer,
@@ -53,7 +56,7 @@ export const getBlockNoteExtensions = (opts: {
53
56
  extensions.Tabindex,
54
57
 
55
58
  // DevTools,
56
- GapCursor,
59
+ Gapcursor,
57
60
 
58
61
  // DropCursor,
59
62
  Placeholder.configure({
@@ -87,7 +90,7 @@ export const getBlockNoteExtensions = (opts: {
87
90
  // custom blocks:
88
91
  ...blocks,
89
92
 
90
- DropCursor.configure({ width: 5, color: "#ddeeff" }),
93
+ Dropcursor.configure({ width: 5, color: "#ddeeff" }),
91
94
  History,
92
95
  // This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
93
96
  // should be handled before Enter handlers in other components like splitListItem
@@ -123,6 +126,7 @@ export const getBlockNoteExtensions = (opts: {
123
126
  if (opts.uiFactories.slashMenuFactory) {
124
127
  ret.push(
125
128
  SlashMenuExtension.configure({
129
+ editor: opts.editor,
126
130
  commands: opts.slashCommands,
127
131
  slashMenuFactory: opts.uiFactories.slashMenuFactory,
128
132
  })