@blocknote/core 0.30.0 → 0.31.0

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 (245) hide show
  1. package/dist/blocknote.cjs +9 -9
  2. package/dist/blocknote.cjs.map +1 -1
  3. package/dist/blocknote.js +2771 -2245
  4. package/dist/blocknote.js.map +1 -1
  5. package/dist/comments.cjs.map +1 -1
  6. package/dist/comments.js.map +1 -1
  7. package/dist/{en-D4taoCs4.cjs → en-BXVKCwYt.cjs} +2 -2
  8. package/dist/en-BXVKCwYt.cjs.map +1 -0
  9. package/dist/{en-B7ycW7c8.js → en-qGo6sk9V.js} +2 -3
  10. package/dist/en-qGo6sk9V.js.map +1 -0
  11. package/dist/locales.cjs +1 -1
  12. package/dist/locales.cjs.map +1 -1
  13. package/dist/locales.js +20 -39
  14. package/dist/locales.js.map +1 -1
  15. package/dist/style.css +1 -1
  16. package/dist/webpack-stats.json +1 -1
  17. package/package.json +8 -7
  18. package/src/api/README.md +1 -1
  19. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +19 -14
  20. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +7 -8
  21. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
  22. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +12 -12
  23. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +14 -14
  24. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +16 -16
  25. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +8 -8
  26. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +12 -12
  27. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +8 -8
  28. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +10 -10
  29. package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +2 -2
  30. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2816 -0
  31. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +200 -42
  32. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +104 -34
  33. package/src/api/blockManipulation/getBlock/getBlock.ts +9 -9
  34. package/src/api/blockManipulation/insertContentAt.ts +1 -1
  35. package/src/api/blockManipulation/selections/selection.ts +59 -12
  36. package/src/api/blockManipulation/selections/{textCursorPosition/textCursorPosition.ts → textCursorPosition.ts} +13 -13
  37. package/src/api/blockManipulation/tables/tables.test.ts +106 -106
  38. package/src/api/blockManipulation/tables/tables.ts +35 -35
  39. package/src/api/clipboard/fromClipboard/fileDropExtension.ts +2 -2
  40. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +9 -9
  41. package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +3 -3
  42. package/src/api/clipboard/fromClipboard/pasteExtension.ts +3 -3
  43. package/src/api/clipboard/toClipboard/copyExtension.ts +22 -22
  44. package/src/api/exporters/html/externalHTMLExporter.ts +6 -6
  45. package/src/api/exporters/html/internalHTMLSerializer.ts +3 -3
  46. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +16 -16
  47. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +14 -14
  48. package/src/api/exporters/markdown/markdownExporter.ts +3 -3
  49. package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +3 -3
  50. package/src/api/getBlockInfoFromPos.ts +6 -6
  51. package/src/api/nodeConversions/blockToNode.ts +31 -28
  52. package/src/api/nodeConversions/fragmentToBlocks.ts +1 -1
  53. package/src/api/nodeConversions/nodeToBlock.ts +240 -41
  54. package/src/api/nodeUtil.test.ts +16 -16
  55. package/src/api/nodeUtil.ts +10 -10
  56. package/src/api/parsers/html/parseHTML.ts +1 -1
  57. package/src/api/parsers/html/util/nestedLists.ts +2 -2
  58. package/src/api/parsers/markdown/parseMarkdown.ts +1 -1
  59. package/src/api/pmUtil.ts +7 -7
  60. package/src/api/positionMapping.test.ts +3 -3
  61. package/src/api/positionMapping.ts +5 -5
  62. package/src/blocks/AudioBlockContent/AudioBlockContent.ts +4 -4
  63. package/src/blocks/CodeBlockContent/CodeBlockContent.ts +18 -18
  64. package/src/blocks/FileBlockContent/FileBlockContent.ts +2 -2
  65. package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +2 -2
  66. package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +6 -6
  67. package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +2 -2
  68. package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +1 -1
  69. package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +7 -7
  70. package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +1 -1
  71. package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +1 -1
  72. package/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +2 -2
  73. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +6 -6
  74. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +4 -4
  75. package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +4 -4
  76. package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +10 -10
  77. package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
  78. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +1 -1
  79. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +4 -4
  80. package/src/blocks/ListItemBlockContent/getListItemContent.ts +5 -5
  81. package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +1 -1
  82. package/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.ts +3 -3
  83. package/src/blocks/PageBreakBlockContent/schema.ts +2 -2
  84. package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +3 -3
  85. package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +4 -4
  86. package/src/blocks/README.md +1 -1
  87. package/src/blocks/TableBlockContent/TableBlockContent.ts +37 -7
  88. package/src/blocks/TableBlockContent/TableExtension.ts +3 -3
  89. package/src/blocks/VideoBlockContent/VideoBlockContent.ts +4 -4
  90. package/src/blocks/defaultBlockHelpers.ts +8 -8
  91. package/src/blocks/defaultBlockTypeGuards.ts +16 -16
  92. package/src/blocks/defaultBlocks.ts +3 -3
  93. package/src/comments/threadstore/DefaultThreadStoreAuth.ts +3 -3
  94. package/src/comments/threadstore/ThreadStore.ts +1 -1
  95. package/src/comments/threadstore/TipTapThreadStore.ts +10 -10
  96. package/src/comments/threadstore/yjs/RESTYjsThreadStore.ts +4 -4
  97. package/src/comments/threadstore/yjs/YjsThreadStore.test.ts +2 -2
  98. package/src/comments/threadstore/yjs/YjsThreadStore.ts +14 -14
  99. package/src/comments/threadstore/yjs/YjsThreadStoreBase.ts +1 -1
  100. package/src/comments/threadstore/yjs/yjsHelpers.ts +6 -6
  101. package/src/editor/Block.css +35 -1
  102. package/src/editor/BlockNoteEditor.test.ts +10 -3
  103. package/src/editor/BlockNoteEditor.ts +95 -38
  104. package/src/editor/BlockNoteExtension.ts +26 -0
  105. package/src/editor/BlockNoteExtensions.ts +38 -22
  106. package/src/editor/BlockNoteSchema.ts +4 -4
  107. package/src/editor/BlockNoteTipTapEditor.ts +33 -12
  108. package/src/editor/README.md +1 -1
  109. package/src/editor/cursorPositionTypes.ts +1 -1
  110. package/src/editor/editor.css +15 -3
  111. package/src/editor/selectionTypes.ts +1 -1
  112. package/src/editor/transformPasted.ts +2 -2
  113. package/src/exporter/Exporter.ts +5 -5
  114. package/src/exporter/mapping.ts +7 -7
  115. package/src/extensions/BackgroundColor/BackgroundColorMark.ts +1 -1
  116. package/src/extensions/Collaboration/CursorPlugin.ts +15 -9
  117. package/src/extensions/Collaboration/ForkYDocPlugin.test.ts +166 -0
  118. package/src/extensions/Collaboration/ForkYDocPlugin.ts +174 -0
  119. package/src/extensions/Collaboration/SyncPlugin.ts +7 -4
  120. package/src/extensions/Collaboration/UndoPlugin.ts +7 -4
  121. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +30 -0
  122. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +30 -0
  123. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -0
  124. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -0
  125. package/src/extensions/Comments/CommentsPlugin.ts +80 -75
  126. package/src/extensions/Comments/userstore/UserStore.ts +2 -2
  127. package/src/extensions/FilePanel/FilePanelPlugin.ts +56 -55
  128. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +60 -30
  129. package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +26 -26
  130. package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +33 -32
  131. package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +45 -42
  132. package/src/extensions/Placeholder/PlaceholderPlugin.ts +113 -110
  133. package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +179 -170
  134. package/src/extensions/README.md +1 -1
  135. package/src/extensions/ShowSelection/ShowSelectionPlugin.ts +22 -19
  136. package/src/extensions/SideMenu/MultipleNodeSelection.ts +1 -1
  137. package/src/extensions/SideMenu/SideMenuPlugin.ts +49 -48
  138. package/src/extensions/SideMenu/dragging.ts +8 -8
  139. package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +176 -176
  140. package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -2
  141. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +16 -16
  142. package/src/extensions/Suggestions/SuggestionMarks.ts +175 -0
  143. package/src/extensions/TableHandles/TableHandlesPlugin.ts +199 -195
  144. package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
  145. package/src/extensions/UniqueID/UniqueID.ts +6 -6
  146. package/src/extensions/getDraggableBlockFromElement.ts +1 -1
  147. package/src/fonts/inter.css +18 -9
  148. package/src/i18n/locales/ar.ts +0 -1
  149. package/src/i18n/locales/de.ts +0 -1
  150. package/src/i18n/locales/en.ts +0 -1
  151. package/src/i18n/locales/es.ts +0 -1
  152. package/src/i18n/locales/fr.ts +0 -1
  153. package/src/i18n/locales/hr.ts +0 -1
  154. package/src/i18n/locales/is.ts +0 -1
  155. package/src/i18n/locales/it.ts +0 -1
  156. package/src/i18n/locales/ja.ts +0 -1
  157. package/src/i18n/locales/ko.ts +0 -1
  158. package/src/i18n/locales/nl.ts +0 -1
  159. package/src/i18n/locales/no.ts +0 -1
  160. package/src/i18n/locales/pl.ts +0 -1
  161. package/src/i18n/locales/pt.ts +0 -1
  162. package/src/i18n/locales/ru.ts +0 -1
  163. package/src/i18n/locales/sk.ts +0 -1
  164. package/src/i18n/locales/uk.ts +0 -1
  165. package/src/i18n/locales/vi.ts +0 -1
  166. package/src/i18n/locales/zh-tw.ts +0 -1
  167. package/src/i18n/locales/zh.ts +0 -1
  168. package/src/index.ts +18 -8
  169. package/src/locales.ts +1 -1
  170. package/src/pm-nodes/BlockContainer.ts +1 -1
  171. package/src/pm-nodes/BlockGroup.ts +2 -2
  172. package/src/pm-nodes/Doc.ts +5 -4
  173. package/src/schema/README.md +1 -1
  174. package/src/schema/blocks/createSpec.ts +14 -14
  175. package/src/schema/blocks/internal.ts +17 -17
  176. package/src/schema/blocks/types.ts +25 -25
  177. package/src/schema/inlineContent/createSpec.ts +16 -20
  178. package/src/schema/inlineContent/internal.ts +9 -9
  179. package/src/schema/inlineContent/types.ts +26 -26
  180. package/src/schema/propTypes.ts +8 -8
  181. package/src/schema/styles/createSpec.ts +2 -2
  182. package/src/schema/styles/internal.ts +7 -7
  183. package/src/schema/styles/types.ts +2 -2
  184. package/src/util/EventEmitter.ts +4 -4
  185. package/src/util/README.md +1 -1
  186. package/src/util/combineByGroup.ts +1 -1
  187. package/src/util/table.ts +33 -30
  188. package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +1 -1
  189. package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.d.ts +4 -0
  190. package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.d.ts +1 -0
  191. package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.d.ts +3 -1
  192. package/types/src/api/blockManipulation/selections/selection.d.ts +10 -0
  193. package/types/src/api/blockManipulation/selections/textCursorPosition.d.ts +5 -0
  194. package/types/src/api/blockManipulation/transactions.test.d.ts +0 -0
  195. package/types/src/api/clipboard/clipboardExternal.test.d.ts +1 -0
  196. package/types/src/api/clipboard/clipboardInternal.test.d.ts +1 -0
  197. package/types/src/api/clipboard/testUtil.d.ts +541 -0
  198. package/types/src/api/exporters/html/htmlConversion.test.d.ts +1 -0
  199. package/types/src/api/exporters/markdown/markdownExporter.test.d.ts +1 -0
  200. package/types/src/api/nodeConversions/nodeConversions.test.d.ts +1 -0
  201. package/types/src/api/nodeConversions/nodeToBlock.d.ts +39 -2
  202. package/types/src/api/parsers/html/parseHTML.test.d.ts +1 -0
  203. package/types/src/api/parsers/markdown/parseMarkdown.test.d.ts +1 -0
  204. package/types/src/api/pmUtil.d.ts +3 -3
  205. package/types/src/api/testUtil/cases/customBlocks.d.ts +670 -0
  206. package/types/src/api/testUtil/cases/customInlineContent.d.ts +558 -0
  207. package/types/src/api/testUtil/cases/customStyles.d.ts +552 -0
  208. package/types/src/api/testUtil/cases/defaultSchema.d.ts +4 -0
  209. package/types/src/api/testUtil/index.d.ts +14 -0
  210. package/types/src/api/testUtil/partialBlockTestUtil.d.ts +9 -0
  211. package/types/src/api/testUtil/paste.d.ts +2 -0
  212. package/types/src/blocks/CodeBlockContent/defaultSupportedLanguages.d.ts +6 -0
  213. package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +9 -1
  214. package/types/src/editor/BlockNoteEditor.d.ts +58 -10
  215. package/types/src/editor/BlockNoteExtension.d.ts +9 -0
  216. package/types/src/editor/BlockNoteExtensions.d.ts +2 -2
  217. package/types/src/editor/BlockNoteTipTapEditor.d.ts +2 -2
  218. package/types/src/extensions/Collaboration/CursorPlugin.d.ts +3 -3
  219. package/types/src/extensions/Collaboration/ForkYDocPlugin.d.ts +41 -0
  220. package/types/src/extensions/Collaboration/ForkYDocPlugin.test.d.ts +1 -0
  221. package/types/src/extensions/Collaboration/SyncPlugin.d.ts +3 -3
  222. package/types/src/extensions/Collaboration/UndoPlugin.d.ts +3 -3
  223. package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +17 -0
  224. package/types/src/extensions/Comments/CommentsPlugin.d.ts +2 -4
  225. package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +3 -4
  226. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +5 -5
  227. package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +3 -4
  228. package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +2 -3
  229. package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +2 -3
  230. package/types/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.d.ts +2 -3
  231. package/types/src/extensions/ShowSelection/ShowSelectionPlugin.d.ts +2 -3
  232. package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +3 -4
  233. package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +2 -4
  234. package/types/src/extensions/Suggestions/SuggestionMarks.d.ts +4 -0
  235. package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +5 -6
  236. package/types/src/i18n/locales/en.d.ts +0 -1
  237. package/types/src/i18n/locales/sk.d.ts +0 -1
  238. package/types/src/index.d.ts +15 -8
  239. package/dist/en-B7ycW7c8.js.map +0 -1
  240. package/dist/en-D4taoCs4.cjs.map +0 -1
  241. package/dist/tsconfig.tsbuildinfo +0 -1
  242. package/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap +0 -844
  243. package/src/api/blockManipulation/selections/selection.test.ts +0 -72
  244. package/src/api/blockManipulation/selections/textCursorPosition/__snapshots__/textCursorPosition.test.ts.snap +0 -316
  245. package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +0 -74
@@ -9,13 +9,13 @@ import * as Y from "yjs";
9
9
  import { createDropFileExtension } from "../api/clipboard/fromClipboard/fileDropExtension.js";
10
10
  import { createPasteFromClipboardExtension } from "../api/clipboard/fromClipboard/pasteExtension.js";
11
11
  import { createCopyToClipboardExtension } from "../api/clipboard/toClipboard/copyExtension.js";
12
+ import type { ThreadStore } from "../comments/index.js";
12
13
  import { BackgroundColorExtension } from "../extensions/BackgroundColor/BackgroundColorExtension.js";
13
14
  import { CursorPlugin } from "../extensions/Collaboration/CursorPlugin.js";
14
- import { UndoPlugin } from "../extensions/Collaboration/UndoPlugin.js";
15
15
  import { SyncPlugin } from "../extensions/Collaboration/SyncPlugin.js";
16
+ import { UndoPlugin } from "../extensions/Collaboration/UndoPlugin.js";
16
17
  import { CommentMark } from "../extensions/Comments/CommentMark.js";
17
18
  import { CommentsPlugin } from "../extensions/Comments/CommentsPlugin.js";
18
- import type { ThreadStore } from "../comments/index.js";
19
19
  import { FilePanelProsemirrorPlugin } from "../extensions/FilePanel/FilePanelPlugin.js";
20
20
  import { FormattingToolbarProsemirrorPlugin } from "../extensions/FormattingToolbar/FormattingToolbarPlugin.js";
21
21
  import { HardBreak } from "../extensions/HardBreak/HardBreak.js";
@@ -31,6 +31,11 @@ import { PreviousBlockTypePlugin } from "../extensions/PreviousBlockType/Previou
31
31
  import { ShowSelectionPlugin } from "../extensions/ShowSelection/ShowSelectionPlugin.js";
32
32
  import { SideMenuProsemirrorPlugin } from "../extensions/SideMenu/SideMenuPlugin.js";
33
33
  import { SuggestionMenuProseMirrorPlugin } from "../extensions/SuggestionMenu/SuggestionPlugin.js";
34
+ import {
35
+ SuggestionAddMark,
36
+ SuggestionDeleteMark,
37
+ SuggestionModificationMark,
38
+ } from "../extensions/Suggestions/SuggestionMarks.js";
34
39
  import { TableHandlesProsemirrorPlugin } from "../extensions/TableHandles/TableHandlesPlugin.js";
35
40
  import { TextAlignmentExtension } from "../extensions/TextAlignment/TextAlignmentExtension.js";
36
41
  import { TextColorExtension } from "../extensions/TextColor/TextColorExtension.js";
@@ -49,13 +54,14 @@ import {
49
54
  import type {
50
55
  BlockNoteEditor,
51
56
  BlockNoteEditorOptions,
52
- BlockNoteExtension,
57
+ SupportedExtension,
53
58
  } from "./BlockNoteEditor.js";
59
+ import { ForkYDocPlugin } from "../extensions/Collaboration/ForkYDocPlugin.js";
54
60
 
55
61
  type ExtensionOptions<
56
62
  BSchema extends BlockSchema,
57
63
  I extends InlineContentSchema,
58
- S extends StyleSchema
64
+ S extends StyleSchema,
59
65
  > = {
60
66
  editor: BlockNoteEditor<BSchema, I, S>;
61
67
  domAttributes: Partial<BlockNoteDOMAttributes>;
@@ -97,11 +103,11 @@ type ExtensionOptions<
97
103
  export const getBlockNoteExtensions = <
98
104
  BSchema extends BlockSchema,
99
105
  I extends InlineContentSchema,
100
- S extends StyleSchema
106
+ S extends StyleSchema,
101
107
  >(
102
- opts: ExtensionOptions<BSchema, I, S>
108
+ opts: ExtensionOptions<BSchema, I, S>,
103
109
  ) => {
104
- const ret: Record<string, BlockNoteExtension> = {};
110
+ const ret: Record<string, SupportedExtension> = {};
105
111
  const tiptapExtensions = getTipTapExtensions(opts);
106
112
 
107
113
  for (const ext of tiptapExtensions) {
@@ -115,17 +121,21 @@ export const getBlockNoteExtensions = <
115
121
  if (opts.collaboration.provider?.awareness) {
116
122
  ret["yCursorPlugin"] = new CursorPlugin(opts.collaboration);
117
123
  }
124
+ ret["forkYDocPlugin"] = new ForkYDocPlugin({
125
+ editor: opts.editor,
126
+ collaboration: opts.collaboration,
127
+ });
118
128
  }
119
129
 
120
130
  // Note: this is pretty hardcoded and will break when user provides plugins with same keys.
121
131
  // Define name on plugins instead and not make this a map?
122
132
  ret["formattingToolbar"] = new FormattingToolbarProsemirrorPlugin(
123
- opts.editor
133
+ opts.editor,
124
134
  );
125
135
  ret["linkToolbar"] = new LinkToolbarProsemirrorPlugin(opts.editor);
126
136
  ret["sideMenu"] = new SideMenuProsemirrorPlugin(
127
137
  opts.editor,
128
- opts.sideMenuDetection
138
+ opts.sideMenuDetection,
129
139
  );
130
140
  ret["suggestionMenus"] = new SuggestionMenuProseMirrorPlugin(opts.editor);
131
141
  ret["filePanel"] = new FilePanelProsemirrorPlugin(opts.editor as any);
@@ -139,14 +149,6 @@ export const getBlockNoteExtensions = <
139
149
  ret["tableHandles"] = new TableHandlesProsemirrorPlugin(opts.editor as any);
140
150
  }
141
151
 
142
- ret["dropCursor"] = {
143
- plugin: opts.dropCursor({
144
- width: 5,
145
- color: "#ddeeff",
146
- editor: opts.editor,
147
- }),
148
- };
149
-
150
152
  ret["nodeSelectionKeyboard"] = new NodeSelectionKeyboardPlugin();
151
153
 
152
154
  ret["showSelection"] = new ShowSelectionPlugin(opts.editor);
@@ -155,7 +157,7 @@ export const getBlockNoteExtensions = <
155
157
  ret["comments"] = new CommentsPlugin(
156
158
  opts.editor,
157
159
  opts.comments.threadStore,
158
- CommentMark.name
160
+ CommentMark.name,
159
161
  );
160
162
  }
161
163
 
@@ -175,9 +177,9 @@ let LINKIFY_INITIALIZED = false;
175
177
  const getTipTapExtensions = <
176
178
  BSchema extends BlockSchema,
177
179
  I extends InlineContentSchema,
178
- S extends StyleSchema
180
+ S extends StyleSchema,
179
181
  >(
180
- opts: ExtensionOptions<BSchema, I, S>
182
+ opts: ExtensionOptions<BSchema, I, S>,
181
183
  ) => {
182
184
  const tiptapExtensions: AnyExtension[] = [
183
185
  extensions.ClipboardTextSerializer,
@@ -190,6 +192,17 @@ const getTipTapExtensions = <
190
192
  Gapcursor,
191
193
 
192
194
  // DropCursor,
195
+ Extension.create({
196
+ name: "dropCursor",
197
+ addProseMirrorPlugins: () => [
198
+ opts.dropCursor({
199
+ width: 5,
200
+ color: "#ddeeff",
201
+ editor: opts.editor,
202
+ }),
203
+ ],
204
+ }),
205
+
193
206
  UniqueID.configure({
194
207
  // everything from bnBlock group (nodes that represent a BlockNote block should have an id)
195
208
  types: ["blockContainer", "columnList", "column"],
@@ -202,6 +215,9 @@ const getTipTapExtensions = <
202
215
  Text,
203
216
 
204
217
  // marks:
218
+ SuggestionAddMark,
219
+ SuggestionDeleteMark,
220
+ SuggestionModificationMark,
205
221
  Link.extend({
206
222
  inclusive: false,
207
223
  }).configure({
@@ -264,7 +280,7 @@ const getTipTapExtensions = <
264
280
  ext.configure({
265
281
  editor: opts.editor,
266
282
  domAttributes: opts.domAttributes,
267
- })
283
+ }),
268
284
  ),
269
285
  // the actual node itself
270
286
  blockSpec.implementation.node.configure({
@@ -282,7 +298,7 @@ const getTipTapExtensions = <
282
298
  prioritizeMarkdownOverHTML?: boolean;
283
299
  plainTextAsMarkdown?: boolean;
284
300
  }) => boolean | undefined;
285
- }) => context.defaultPasteHandler())
301
+ }) => context.defaultPasteHandler()),
286
302
  ),
287
303
  createDropFileExtension(opts.editor),
288
304
 
@@ -28,14 +28,14 @@ function removeUndefined<T extends Record<string, any> | undefined>(obj: T): T {
28
28
  return obj;
29
29
  }
30
30
  return Object.fromEntries(
31
- Object.entries(obj).filter(([, value]) => value !== undefined)
31
+ Object.entries(obj).filter(([, value]) => value !== undefined),
32
32
  ) as T;
33
33
  }
34
34
 
35
35
  export class BlockNoteSchema<
36
36
  BSchema extends BlockSchema,
37
37
  ISchema extends InlineContentSchema,
38
- SSchema extends StyleSchema
38
+ SSchema extends StyleSchema,
39
39
  > {
40
40
  public readonly blockSpecs: BlockSpecs;
41
41
  public readonly inlineContentSpecs: InlineContentSpecs;
@@ -61,7 +61,7 @@ export class BlockNoteSchema<
61
61
  public static create<
62
62
  BSpecs extends BlockSpecs = typeof defaultBlockSpecs,
63
63
  ISpecs extends InlineContentSpecs = typeof defaultInlineContentSpecs,
64
- SSpecs extends StyleSpecs = typeof defaultStyleSpecs
64
+ SSpecs extends StyleSpecs = typeof defaultStyleSpecs,
65
65
  >(options?: {
66
66
  /**
67
67
  * A list of custom block types that should be available in the editor.
@@ -100,7 +100,7 @@ export class BlockNoteSchema<
100
100
 
101
101
  this.blockSchema = getBlockSchemaFromSpecs(this.blockSpecs) as any;
102
102
  this.inlineContentSchema = getInlineContentSchemaFromSpecs(
103
- this.inlineContentSpecs
103
+ this.inlineContentSpecs,
104
104
  ) as any;
105
105
  this.styleSchema = getStyleSchemaFromSpecs(this.styleSpecs) as any;
106
106
  }
@@ -1,5 +1,9 @@
1
- import { Editor, EditorOptions, createDocument } from "@tiptap/core";
2
- import { Editor as TiptapEditor } from "@tiptap/core";
1
+ import {
2
+ Editor,
3
+ EditorOptions,
4
+ Editor as TiptapEditor,
5
+ createDocument,
6
+ } from "@tiptap/core";
3
7
 
4
8
  import { Node } from "@tiptap/pm/model";
5
9
 
@@ -26,7 +30,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
26
30
 
27
31
  public static create = (
28
32
  options: BlockNoteTipTapEditorOptions,
29
- styleSchema: StyleSchema
33
+ styleSchema: StyleSchema,
30
34
  ) => {
31
35
  // because we separate the constructor from the creation of the view,
32
36
  // we need to patch setTimeout to prevent this code from having any effect:
@@ -48,7 +52,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
48
52
 
49
53
  protected constructor(
50
54
  options: BlockNoteTipTapEditorOptions,
51
- styleSchema: StyleSchema
55
+ styleSchema: StyleSchema,
52
56
  ) {
53
57
  // possible fix for next.js server side rendering
54
58
  // const d = globalThis.document;
@@ -93,7 +97,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
93
97
 
94
98
  try {
95
99
  const pmNodes = options?.content.map((b) =>
96
- blockToNode(b, this.schema, styleSchema).toJSON()
100
+ blockToNode(b, this.schema, styleSchema).toJSON(),
97
101
  );
98
102
  doc = createDocument(
99
103
  {
@@ -106,17 +110,17 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
106
110
  ],
107
111
  },
108
112
  this.schema,
109
- this.options.parseOptions
113
+ this.options.parseOptions,
110
114
  );
111
115
  } catch (e) {
112
116
  // eslint-disable-next-line no-console
113
117
  console.error(
114
118
  "Error creating document from blocks passed as `initialContent`. Caused by exception: ",
115
- e
119
+ e,
116
120
  );
117
121
  throw new Error(
118
122
  "Error creating document from blocks passed as `initialContent`:\n" +
119
- +JSON.stringify(options.content)
123
+ +JSON.stringify(options.content),
120
124
  );
121
125
  }
122
126
 
@@ -141,6 +145,10 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
141
145
  if (!this.view) {
142
146
  // before view has been initialized
143
147
  this._state = this.state.apply(transaction);
148
+ this.emit("transaction", {
149
+ editor: this,
150
+ transaction,
151
+ });
144
152
  return;
145
153
  }
146
154
  // This is a verbatim copy of the default dispatch method, but with the following changes:
@@ -216,12 +224,25 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
216
224
  });
217
225
  }
218
226
 
227
+ // a helper method that can enable plugins before the view has been initialized
228
+ // currently only used for testing
229
+ forceEnablePlugins() {
230
+ if (this.view) {
231
+ throw new Error(
232
+ "forcePluginsEnabled called after view has been initialized",
233
+ );
234
+ }
235
+ this._state = this.state.reconfigure({
236
+ plugins: this.extensionManager.plugins,
237
+ });
238
+ }
239
+
219
240
  /**
220
241
  * Replace the default `createView` method with a custom one - which we call on mount
221
242
  */
222
243
  private createViewAlternative(
223
244
  blockNoteEditor: BlockNoteEditor<any, any, any>,
224
- contentComponent?: any
245
+ contentComponent?: any,
225
246
  ) {
226
247
  (this as any).contentComponent = contentComponent;
227
248
 
@@ -244,7 +265,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
244
265
  state: this.state,
245
266
  markViews,
246
267
  nodeViews: this.extensionManager.nodeViews,
247
- }
268
+ },
248
269
  );
249
270
 
250
271
  // `editor.view` is not yet available at this time.
@@ -263,7 +284,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
263
284
  this.commands.focus(
264
285
  this.options.autofocus ||
265
286
  this.options.element.getAttribute("data-bn-autofocus") === "true",
266
- { scrollIntoView: false }
287
+ { scrollIntoView: false },
267
288
  );
268
289
  this.emit("create", { editor: this });
269
290
  this.isInitialized = true;
@@ -277,7 +298,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
277
298
  public mount = (
278
299
  blockNoteEditor: BlockNoteEditor<any, any, any>,
279
300
  element?: HTMLElement | null,
280
- contentComponent?: any
301
+ contentComponent?: any,
281
302
  ) => {
282
303
  if (!element) {
283
304
  this.destroy();
@@ -1,3 +1,3 @@
1
1
  ### @blocknote/core/src/editor
2
2
 
3
- Contains main functions to set up the editor
3
+ Contains main functions to set up the editor
@@ -8,7 +8,7 @@ import {
8
8
  export type TextCursorPosition<
9
9
  BSchema extends BlockSchema,
10
10
  I extends InlineContentSchema,
11
- S extends StyleSchema
11
+ S extends StyleSchema,
12
12
  > = {
13
13
  block: Block<BSchema, I, S>;
14
14
  prevBlock: Block<BSchema, I, S> | undefined;
@@ -55,9 +55,21 @@ Tippy popups that are appended to document.body directly
55
55
  .bn-default-styles {
56
56
  font-size: 16px;
57
57
  font-weight: normal;
58
- font-family: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont,
59
- "Open Sans", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell",
60
- "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
58
+ font-family:
59
+ "Inter",
60
+ "SF Pro Display",
61
+ -apple-system,
62
+ BlinkMacSystemFont,
63
+ "Open Sans",
64
+ "Segoe UI",
65
+ "Roboto",
66
+ "Oxygen",
67
+ "Ubuntu",
68
+ "Cantarell",
69
+ "Fira Sans",
70
+ "Droid Sans",
71
+ "Helvetica Neue",
72
+ sans-serif;
61
73
  -webkit-font-smoothing: antialiased;
62
74
  -moz-osx-font-smoothing: grayscale;
63
75
  }
@@ -8,7 +8,7 @@ import {
8
8
  export type Selection<
9
9
  BSchema extends BlockSchema,
10
10
  I extends InlineContentSchema,
11
- S extends StyleSchema
11
+ S extends StyleSchema,
12
12
  > = {
13
13
  blocks: Block<BSchema, I, S>[];
14
14
  };
@@ -36,7 +36,7 @@ export function wrapTableRows(f: Fragment, schema: Schema) {
36
36
  // create new table to wrap tableRow with
37
37
  const newTable = schema.nodes.table.createChecked(
38
38
  undefined,
39
- f.child(i)
39
+ f.child(i),
40
40
  );
41
41
  newItems.push(newTable);
42
42
  }
@@ -96,7 +96,7 @@ export function transformPasted(slice: Slice, view: EditorView) {
96
96
  }
97
97
  const container = view.state.schema.nodes.blockContainer.createChecked(
98
98
  undefined,
99
- content
99
+ content,
100
100
  );
101
101
  f = f.replaceChild(i, container);
102
102
  }
@@ -42,7 +42,7 @@ export abstract class Exporter<
42
42
  RB,
43
43
  RI,
44
44
  RS,
45
- TS
45
+ TS,
46
46
  > {
47
47
  public constructor(
48
48
  _schema: BlockNoteSchema<B, I, S>, // only used for type inference
@@ -51,7 +51,7 @@ export abstract class Exporter<
51
51
  inlineContentMapping: InlineContentMapping<I, S, RI, TS>;
52
52
  styleMapping: StyleMapping<S, RS>;
53
53
  },
54
- public readonly options: ExporterOptions
54
+ public readonly options: ExporterOptions,
55
55
  ) {}
56
56
 
57
57
  public async resolveFile(url: string) {
@@ -76,7 +76,7 @@ export abstract class Exporter<
76
76
  public mapInlineContent(inlineContent: InlineContent<I, S>) {
77
77
  return this.mappings.inlineContentMapping[inlineContent.type](
78
78
  inlineContent,
79
- this
79
+ this,
80
80
  );
81
81
  }
82
82
 
@@ -89,13 +89,13 @@ export abstract class Exporter<
89
89
  public async mapBlock(
90
90
  block: BlockFromConfig<B[keyof B], I, S>,
91
91
  nestingLevel: number,
92
- numberedListIndex: number
92
+ numberedListIndex: number,
93
93
  ) {
94
94
  return this.mappings.blockMapping[block.type](
95
95
  block,
96
96
  this,
97
97
  nestingLevel,
98
- numberedListIndex
98
+ numberedListIndex,
99
99
  );
100
100
  }
101
101
  }
@@ -17,7 +17,7 @@ export type BlockMapping<
17
17
  I extends InlineContentSchema,
18
18
  S extends StyleSchema,
19
19
  RB,
20
- RI
20
+ RI,
21
21
  > = {
22
22
  [K in keyof B]: (
23
23
  block: BlockFromConfigNoChildren<B[K], I, S>,
@@ -26,7 +26,7 @@ export type BlockMapping<
26
26
  // this is why there are many `any` types here (same for types below)
27
27
  exporter: Exporter<any, any, any, RB, RI, any, any>,
28
28
  nestingLevel: number,
29
- numberedListIndex?: number
29
+ numberedListIndex?: number,
30
30
  ) => RB | Promise<RB>;
31
31
  };
32
32
 
@@ -37,11 +37,11 @@ export type InlineContentMapping<
37
37
  I extends InlineContentSchema,
38
38
  S extends StyleSchema,
39
39
  RI,
40
- TS
40
+ TS,
41
41
  > = {
42
42
  [K in keyof I]: (
43
43
  inlineContent: InlineContentFromConfig<I[K], S>,
44
- exporter: Exporter<any, I, S, any, RI, any, TS>
44
+ exporter: Exporter<any, I, S, any, RI, any, TS>,
45
45
  ) => RI;
46
46
  };
47
47
 
@@ -51,7 +51,7 @@ export type InlineContentMapping<
51
51
  export type StyleMapping<S extends StyleSchema, RS> = {
52
52
  [K in keyof S]: (
53
53
  style: Styles<S>[K],
54
- exporter: Exporter<any, any, any, any, any, RS, any>
54
+ exporter: Exporter<any, any, any, any, any, RS, any>,
55
55
  ) => RS;
56
56
  };
57
57
 
@@ -62,13 +62,13 @@ export type StyleMapping<S extends StyleSchema, RS> = {
62
62
  export function mappingFactory<
63
63
  B extends BlockSchema,
64
64
  I extends InlineContentSchema,
65
- S extends StyleSchema
65
+ S extends StyleSchema,
66
66
  >(_schema: BlockNoteSchema<B, I, S>) {
67
67
  return {
68
68
  createBlockMapping: <R, RI>(mapping: BlockMapping<B, I, S, R, RI>) =>
69
69
  mapping,
70
70
  createInlineContentMapping: <R, RS>(
71
- mapping: InlineContentMapping<I, S, R, RS>
71
+ mapping: InlineContentMapping<I, S, R, RS>,
72
72
  ) => mapping,
73
73
  createStyleMapping: <R>(mapping: StyleMapping<S, R>) => mapping,
74
74
  };
@@ -44,5 +44,5 @@ const BackgroundColorMark = Mark.create({
44
44
 
45
45
  export const BackgroundColor = createStyleSpecFromTipTapMark(
46
46
  BackgroundColorMark,
47
- "string"
47
+ "string",
48
48
  );
@@ -1,7 +1,7 @@
1
- import { Plugin } from "prosemirror-state";
2
1
  import { defaultSelectionBuilder, yCursorPlugin } from "y-prosemirror";
3
2
  import { Awareness } from "y-protocols/awareness.js";
4
3
  import * as Y from "yjs";
4
+ import { BlockNoteExtension } from "../../editor/BlockNoteExtension.js";
5
5
 
6
6
  export type CollaborationUser = {
7
7
  name: string;
@@ -9,8 +9,11 @@ export type CollaborationUser = {
9
9
  [key: string]: string;
10
10
  };
11
11
 
12
- export class CursorPlugin {
13
- public plugin: Plugin;
12
+ export class CursorPlugin extends BlockNoteExtension {
13
+ public static name() {
14
+ return "yCursorPlugin";
15
+ }
16
+
14
17
  private provider: { awareness: Awareness };
15
18
  private recentlyUpdatedCursors: Map<
16
19
  number,
@@ -23,8 +26,9 @@ export class CursorPlugin {
23
26
  provider: { awareness: Awareness };
24
27
  renderCursor?: (user: CollaborationUser) => HTMLElement;
25
28
  showCursorLabels?: "always" | "activity";
26
- }
29
+ },
27
30
  ) {
31
+ super();
28
32
  this.provider = collaboration.provider;
29
33
  this.recentlyUpdatedCursors = new Map();
30
34
 
@@ -58,14 +62,16 @@ export class CursorPlugin {
58
62
  });
59
63
  }
60
64
  }
61
- }
65
+ },
62
66
  );
63
67
  }
64
68
 
65
- this.plugin = yCursorPlugin(this.provider.awareness, {
66
- selectionBuilder: defaultSelectionBuilder,
67
- cursorBuilder: this.renderCursor,
68
- });
69
+ this.addProsemirrorPlugin(
70
+ yCursorPlugin(this.provider.awareness, {
71
+ selectionBuilder: defaultSelectionBuilder,
72
+ cursorBuilder: this.renderCursor,
73
+ }),
74
+ );
69
75
  }
70
76
 
71
77
  public get priority() {