@blocknote/core 0.29.1 → 0.30.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 (182) hide show
  1. package/README.md +125 -0
  2. package/dist/blocknote.cjs +9 -9
  3. package/dist/blocknote.cjs.map +1 -1
  4. package/dist/blocknote.js +1501 -1359
  5. package/dist/blocknote.js.map +1 -1
  6. package/dist/comments.cjs.map +1 -1
  7. package/dist/comments.js.map +1 -1
  8. package/dist/locales.cjs +1 -1
  9. package/dist/locales.cjs.map +1 -1
  10. package/dist/locales.js +751 -9
  11. package/dist/locales.js.map +1 -1
  12. package/dist/style.css +1 -1
  13. package/dist/tsconfig.tsbuildinfo +1 -1
  14. package/dist/webpack-stats.json +1 -1
  15. package/package.json +7 -8
  16. package/src/api/README.md +1 -1
  17. package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -7
  18. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +19 -14
  19. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +5 -5
  20. package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -5
  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/__snapshots__/moveBlocks.test.ts.snap +0 -20
  24. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +14 -14
  25. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +16 -16
  26. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +8 -8
  27. package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -12
  28. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +12 -12
  29. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +7 -7
  30. package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -6
  31. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +10 -10
  32. package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +2 -2
  33. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -17
  34. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -42
  35. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +18 -18
  36. package/src/api/blockManipulation/getBlock/getBlock.ts +9 -9
  37. package/src/api/blockManipulation/insertContentAt.ts +1 -1
  38. package/src/api/blockManipulation/selections/selection.ts +11 -11
  39. package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +7 -7
  40. package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +6 -6
  41. package/src/api/blockManipulation/tables/tables.test.ts +106 -106
  42. package/src/api/blockManipulation/tables/tables.ts +35 -35
  43. package/src/api/clipboard/fromClipboard/fileDropExtension.ts +2 -2
  44. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +9 -9
  45. package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +3 -3
  46. package/src/api/clipboard/fromClipboard/pasteExtension.ts +21 -3
  47. package/src/api/clipboard/toClipboard/copyExtension.ts +22 -22
  48. package/src/api/exporters/html/externalHTMLExporter.ts +6 -6
  49. package/src/api/exporters/html/internalHTMLSerializer.ts +3 -3
  50. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +16 -16
  51. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +14 -14
  52. package/src/api/exporters/markdown/markdownExporter.ts +3 -3
  53. package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +3 -3
  54. package/src/api/getBlockInfoFromPos.ts +6 -6
  55. package/src/api/nodeConversions/blockToNode.ts +26 -26
  56. package/src/api/nodeConversions/fragmentToBlocks.ts +1 -1
  57. package/src/api/nodeConversions/nodeToBlock.ts +37 -33
  58. package/src/api/nodeUtil.test.ts +16 -16
  59. package/src/api/nodeUtil.ts +10 -10
  60. package/src/api/parsers/html/parseHTML.ts +1 -1
  61. package/src/api/parsers/html/util/nestedLists.ts +2 -2
  62. package/src/api/parsers/markdown/parseMarkdown.ts +1 -1
  63. package/src/api/pmUtil.ts +4 -4
  64. package/src/api/positionMapping.test.ts +3 -3
  65. package/src/api/positionMapping.ts +5 -5
  66. package/src/blocks/AudioBlockContent/AudioBlockContent.ts +9 -4
  67. package/src/blocks/CodeBlockContent/CodeBlockContent.ts +40 -26
  68. package/src/blocks/FileBlockContent/FileBlockContent.ts +7 -2
  69. package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +2 -2
  70. package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +5 -5
  71. package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +2 -2
  72. package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +1 -1
  73. package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +15 -8
  74. package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +1 -1
  75. package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +1 -1
  76. package/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +2 -2
  77. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +9 -6
  78. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +14 -6
  79. package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +13 -29
  80. package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +24 -13
  81. package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
  82. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +1 -1
  83. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +13 -30
  84. package/src/blocks/ListItemBlockContent/getListItemContent.ts +115 -0
  85. package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +1 -1
  86. package/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.ts +3 -3
  87. package/src/blocks/PageBreakBlockContent/schema.ts +2 -2
  88. package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +9 -5
  89. package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +10 -5
  90. package/src/blocks/README.md +1 -1
  91. package/src/blocks/TableBlockContent/TableBlockContent.ts +76 -19
  92. package/src/blocks/TableBlockContent/TableExtension.ts +3 -3
  93. package/src/blocks/VideoBlockContent/VideoBlockContent.ts +14 -6
  94. package/src/blocks/defaultBlockHelpers.ts +24 -8
  95. package/src/blocks/defaultBlockTypeGuards.ts +16 -16
  96. package/src/blocks/defaultBlocks.ts +3 -3
  97. package/src/comments/threadstore/DefaultThreadStoreAuth.ts +3 -3
  98. package/src/comments/threadstore/ThreadStore.ts +1 -1
  99. package/src/comments/threadstore/TipTapThreadStore.ts +10 -10
  100. package/src/comments/threadstore/yjs/RESTYjsThreadStore.ts +4 -4
  101. package/src/comments/threadstore/yjs/YjsThreadStore.test.ts +2 -2
  102. package/src/comments/threadstore/yjs/YjsThreadStore.ts +14 -14
  103. package/src/comments/threadstore/yjs/YjsThreadStoreBase.ts +1 -1
  104. package/src/comments/threadstore/yjs/yjsHelpers.ts +6 -6
  105. package/src/editor/Block.css +10 -1
  106. package/src/editor/BlockNoteEditor.test.ts +3 -3
  107. package/src/editor/BlockNoteEditor.ts +110 -61
  108. package/src/editor/BlockNoteExtensions.ts +24 -15
  109. package/src/editor/BlockNoteSchema.ts +4 -4
  110. package/src/editor/BlockNoteTipTapEditor.ts +10 -10
  111. package/src/editor/README.md +1 -1
  112. package/src/editor/cursorPositionTypes.ts +1 -1
  113. package/src/editor/editor.css +15 -3
  114. package/src/editor/selectionTypes.ts +1 -1
  115. package/src/editor/transformPasted.ts +2 -2
  116. package/src/exporter/Exporter.ts +5 -5
  117. package/src/exporter/mapping.ts +7 -7
  118. package/src/extensions/BackgroundColor/BackgroundColorMark.ts +1 -1
  119. package/src/extensions/Collaboration/CursorPlugin.ts +152 -0
  120. package/src/extensions/Collaboration/SyncPlugin.ts +15 -0
  121. package/src/extensions/Collaboration/UndoPlugin.ts +14 -0
  122. package/src/extensions/Comments/CommentsPlugin.ts +9 -9
  123. package/src/extensions/Comments/userstore/UserStore.ts +2 -2
  124. package/src/extensions/FilePanel/FilePanelPlugin.ts +37 -28
  125. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +6 -8
  126. package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +29 -26
  127. package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +11 -11
  128. package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +4 -4
  129. package/src/extensions/Placeholder/PlaceholderPlugin.ts +10 -10
  130. package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +2 -2
  131. package/src/extensions/README.md +1 -1
  132. package/src/extensions/SideMenu/MultipleNodeSelection.ts +1 -1
  133. package/src/extensions/SideMenu/SideMenuPlugin.ts +31 -31
  134. package/src/extensions/SideMenu/dragging.ts +8 -8
  135. package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +17 -17
  136. package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -2
  137. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +12 -12
  138. package/src/extensions/TableHandles/TableHandlesPlugin.ts +54 -53
  139. package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
  140. package/src/extensions/UniqueID/UniqueID.ts +6 -6
  141. package/src/extensions/getDraggableBlockFromElement.ts +1 -1
  142. package/src/fonts/inter.css +18 -9
  143. package/src/i18n/locales/index.ts +2 -0
  144. package/src/i18n/locales/ru.ts +2 -2
  145. package/src/i18n/locales/sk.ts +355 -0
  146. package/src/i18n/locales/zh-tw.ts +390 -0
  147. package/src/locales.ts +1 -1
  148. package/src/pm-nodes/BlockContainer.ts +7 -6
  149. package/src/pm-nodes/BlockGroup.ts +1 -1
  150. package/src/pm-nodes/Doc.ts +4 -4
  151. package/src/schema/README.md +1 -1
  152. package/src/schema/blocks/createSpec.ts +15 -15
  153. package/src/schema/blocks/internal.ts +17 -18
  154. package/src/schema/blocks/types.ts +27 -26
  155. package/src/schema/inlineContent/createSpec.ts +16 -20
  156. package/src/schema/inlineContent/internal.ts +9 -9
  157. package/src/schema/inlineContent/types.ts +26 -26
  158. package/src/schema/propTypes.ts +8 -8
  159. package/src/schema/styles/createSpec.ts +2 -2
  160. package/src/schema/styles/internal.ts +7 -7
  161. package/src/schema/styles/types.ts +2 -2
  162. package/src/util/EventEmitter.ts +4 -4
  163. package/src/util/README.md +1 -1
  164. package/src/util/combineByGroup.ts +1 -1
  165. package/src/util/table.ts +33 -30
  166. package/types/src/api/blockManipulation/setupTestEnv.d.ts +8 -4
  167. package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +8 -4
  168. package/types/src/blocks/ListItemBlockContent/getListItemContent.d.ts +28 -0
  169. package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +8 -4
  170. package/types/src/blocks/defaultBlockHelpers.d.ts +1 -0
  171. package/types/src/blocks/defaultBlocks.d.ts +16 -8
  172. package/types/src/editor/BlockNoteEditor.d.ts +21 -2
  173. package/types/src/extensions/Collaboration/CursorPlugin.d.ts +31 -0
  174. package/types/src/extensions/Collaboration/SyncPlugin.d.ts +7 -0
  175. package/types/src/extensions/Collaboration/UndoPlugin.d.ts +6 -0
  176. package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +1 -1
  177. package/types/src/i18n/locales/index.d.ts +2 -0
  178. package/types/src/i18n/locales/sk.d.ts +313 -0
  179. package/types/src/i18n/locales/zh-tw.d.ts +2 -0
  180. package/types/src/schema/blocks/types.d.ts +2 -1
  181. package/src/extensions/Collaboration/createCollaborationExtensions.ts +0 -147
  182. package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +0 -17
@@ -231,7 +231,6 @@ exports[`Test moveBlocksDown > Basic 1`] = `
231
231
  "backgroundColor": "default",
232
232
  "caption": "",
233
233
  "name": "",
234
- "previewWidth": 512,
235
234
  "showPreview": true,
236
235
  "textAlignment": "left",
237
236
  "url": "https://via.placeholder.com/150",
@@ -798,7 +797,6 @@ exports[`Test moveBlocksDown > Into children 1`] = `
798
797
  "backgroundColor": "default",
799
798
  "caption": "",
800
799
  "name": "",
801
- "previewWidth": 512,
802
800
  "showPreview": true,
803
801
  "textAlignment": "left",
804
802
  "url": "https://via.placeholder.com/150",
@@ -1365,7 +1363,6 @@ exports[`Test moveBlocksDown > Last block 1`] = `
1365
1363
  "backgroundColor": "default",
1366
1364
  "caption": "",
1367
1365
  "name": "",
1368
- "previewWidth": 512,
1369
1366
  "showPreview": true,
1370
1367
  "textAlignment": "left",
1371
1368
  "url": "https://via.placeholder.com/150",
@@ -1932,7 +1929,6 @@ exports[`Test moveBlocksDown > Multiple blocks 1`] = `
1932
1929
  "backgroundColor": "default",
1933
1930
  "caption": "",
1934
1931
  "name": "",
1935
- "previewWidth": 512,
1936
1932
  "showPreview": true,
1937
1933
  "textAlignment": "left",
1938
1934
  "url": "https://via.placeholder.com/150",
@@ -2499,7 +2495,6 @@ exports[`Test moveBlocksDown > Multiple blocks ending in block with children 1`]
2499
2495
  "backgroundColor": "default",
2500
2496
  "caption": "",
2501
2497
  "name": "",
2502
- "previewWidth": 512,
2503
2498
  "showPreview": true,
2504
2499
  "textAlignment": "left",
2505
2500
  "url": "https://via.placeholder.com/150",
@@ -3066,7 +3061,6 @@ exports[`Test moveBlocksDown > Multiple blocks ending in nested block 1`] = `
3066
3061
  "backgroundColor": "default",
3067
3062
  "caption": "",
3068
3063
  "name": "",
3069
- "previewWidth": 512,
3070
3064
  "showPreview": true,
3071
3065
  "textAlignment": "left",
3072
3066
  "url": "https://via.placeholder.com/150",
@@ -3643,7 +3637,6 @@ exports[`Test moveBlocksDown > Multiple blocks starting and ending in nested blo
3643
3637
  "backgroundColor": "default",
3644
3638
  "caption": "",
3645
3639
  "name": "",
3646
- "previewWidth": 512,
3647
3640
  "showPreview": true,
3648
3641
  "textAlignment": "left",
3649
3642
  "url": "https://via.placeholder.com/150",
@@ -4210,7 +4203,6 @@ exports[`Test moveBlocksDown > Multiple blocks starting in block with children 1
4210
4203
  "backgroundColor": "default",
4211
4204
  "caption": "",
4212
4205
  "name": "",
4213
- "previewWidth": 512,
4214
4206
  "showPreview": true,
4215
4207
  "textAlignment": "left",
4216
4208
  "url": "https://via.placeholder.com/150",
@@ -4776,7 +4768,6 @@ exports[`Test moveBlocksDown > Multiple blocks starting in nested block 1`] = `
4776
4768
  "backgroundColor": "default",
4777
4769
  "caption": "",
4778
4770
  "name": "",
4779
- "previewWidth": 512,
4780
4771
  "showPreview": true,
4781
4772
  "textAlignment": "left",
4782
4773
  "url": "https://via.placeholder.com/150",
@@ -5343,7 +5334,6 @@ exports[`Test moveBlocksDown > Out of children 1`] = `
5343
5334
  "backgroundColor": "default",
5344
5335
  "caption": "",
5345
5336
  "name": "",
5346
- "previewWidth": 512,
5347
5337
  "showPreview": true,
5348
5338
  "textAlignment": "left",
5349
5339
  "url": "https://via.placeholder.com/150",
@@ -5909,7 +5899,6 @@ exports[`Test moveBlocksUp > Basic 1`] = `
5909
5899
  "backgroundColor": "default",
5910
5900
  "caption": "",
5911
5901
  "name": "",
5912
- "previewWidth": 512,
5913
5902
  "showPreview": true,
5914
5903
  "textAlignment": "left",
5915
5904
  "url": "https://via.placeholder.com/150",
@@ -6476,7 +6465,6 @@ exports[`Test moveBlocksUp > First block 1`] = `
6476
6465
  "backgroundColor": "default",
6477
6466
  "caption": "",
6478
6467
  "name": "",
6479
- "previewWidth": 512,
6480
6468
  "showPreview": true,
6481
6469
  "textAlignment": "left",
6482
6470
  "url": "https://via.placeholder.com/150",
@@ -7043,7 +7031,6 @@ exports[`Test moveBlocksUp > Into children 1`] = `
7043
7031
  "backgroundColor": "default",
7044
7032
  "caption": "",
7045
7033
  "name": "",
7046
- "previewWidth": 512,
7047
7034
  "showPreview": true,
7048
7035
  "textAlignment": "left",
7049
7036
  "url": "https://via.placeholder.com/150",
@@ -7610,7 +7597,6 @@ exports[`Test moveBlocksUp > Multiple blocks 1`] = `
7610
7597
  "backgroundColor": "default",
7611
7598
  "caption": "",
7612
7599
  "name": "",
7613
- "previewWidth": 512,
7614
7600
  "showPreview": true,
7615
7601
  "textAlignment": "left",
7616
7602
  "url": "https://via.placeholder.com/150",
@@ -8177,7 +8163,6 @@ exports[`Test moveBlocksUp > Multiple blocks ending in block with children 1`] =
8177
8163
  "backgroundColor": "default",
8178
8164
  "caption": "",
8179
8165
  "name": "",
8180
- "previewWidth": 512,
8181
8166
  "showPreview": true,
8182
8167
  "textAlignment": "left",
8183
8168
  "url": "https://via.placeholder.com/150",
@@ -8744,7 +8729,6 @@ exports[`Test moveBlocksUp > Multiple blocks ending in nested block 1`] = `
8744
8729
  "backgroundColor": "default",
8745
8730
  "caption": "",
8746
8731
  "name": "",
8747
- "previewWidth": 512,
8748
8732
  "showPreview": true,
8749
8733
  "textAlignment": "left",
8750
8734
  "url": "https://via.placeholder.com/150",
@@ -9293,7 +9277,6 @@ exports[`Test moveBlocksUp > Multiple blocks starting and ending in nested block
9293
9277
  "backgroundColor": "default",
9294
9278
  "caption": "",
9295
9279
  "name": "",
9296
- "previewWidth": 512,
9297
9280
  "showPreview": true,
9298
9281
  "textAlignment": "left",
9299
9282
  "url": "https://via.placeholder.com/150",
@@ -9877,7 +9860,6 @@ exports[`Test moveBlocksUp > Multiple blocks starting in block with children 1`]
9877
9860
  "backgroundColor": "default",
9878
9861
  "caption": "",
9879
9862
  "name": "",
9880
- "previewWidth": 512,
9881
9863
  "showPreview": true,
9882
9864
  "textAlignment": "left",
9883
9865
  "url": "https://via.placeholder.com/150",
@@ -10443,7 +10425,6 @@ exports[`Test moveBlocksUp > Multiple blocks starting in nested block 1`] = `
10443
10425
  "backgroundColor": "default",
10444
10426
  "caption": "",
10445
10427
  "name": "",
10446
- "previewWidth": 512,
10447
10428
  "showPreview": true,
10448
10429
  "textAlignment": "left",
10449
10430
  "url": "https://via.placeholder.com/150",
@@ -11010,7 +10991,6 @@ exports[`Test moveBlocksUp > Out of children 1`] = `
11010
10991
  "backgroundColor": "default",
11011
10992
  "caption": "",
11012
10993
  "name": "",
11013
- "previewWidth": 512,
11014
10994
  "showPreview": true,
11015
10995
  "textAlignment": "left",
11016
10996
  "url": "https://via.placeholder.com/150",
@@ -14,11 +14,11 @@ const getEditor = setupTestEnv();
14
14
 
15
15
  function makeSelectionSpanContent(selectionType: "text" | "node" | "cell") {
16
16
  const blockInfo = getEditor().transact((tr) =>
17
- getBlockInfoFromTransaction(tr)
17
+ getBlockInfoFromTransaction(tr),
18
18
  );
19
19
  if (!blockInfo.isBlockContainer) {
20
20
  throw new Error(
21
- `Selection points to a ${blockInfo.blockNoteType} node, not a blockContainer node`
21
+ `Selection points to a ${blockInfo.blockNoteType} node, not a blockContainer node`,
22
22
  );
23
23
  }
24
24
  const { blockContent } = blockInfo;
@@ -30,13 +30,13 @@ function makeSelectionSpanContent(selectionType: "text" | "node" | "cell") {
30
30
  CellSelection.create(
31
31
  tr.doc,
32
32
  tr.doc.resolve(blockContent.beforePos + 3).before(),
33
- tr.doc.resolve(blockContent.afterPos - 3).before()
34
- )
35
- )
33
+ tr.doc.resolve(blockContent.afterPos - 3).before(),
34
+ ),
35
+ ),
36
36
  );
37
37
  } else if (selectionType === "node") {
38
38
  editor.transact((tr) =>
39
- tr.setSelection(NodeSelection.create(tr.doc, blockContent.beforePos))
39
+ tr.setSelection(NodeSelection.create(tr.doc, blockContent.beforePos)),
40
40
  );
41
41
  } else {
42
42
  editor.transact((tr) =>
@@ -44,9 +44,9 @@ function makeSelectionSpanContent(selectionType: "text" | "node" | "cell") {
44
44
  TextSelection.create(
45
45
  tr.doc,
46
46
  blockContent.beforePos + 1,
47
- blockContent.afterPos - 1
48
- )
49
- )
47
+ blockContent.afterPos - 1,
48
+ ),
49
+ ),
50
50
  );
51
51
  }
52
52
  }
@@ -63,7 +63,7 @@ describe("Test moveSelectedBlockAndSelection", () => {
63
63
  makeSelectionSpanContent("text");
64
64
 
65
65
  expect(
66
- selection.eq(getEditor().transact((tr) => tr.selection))
66
+ selection.eq(getEditor().transact((tr) => tr.selection)),
67
67
  ).toBeTruthy();
68
68
  });
69
69
 
@@ -78,7 +78,7 @@ describe("Test moveSelectedBlockAndSelection", () => {
78
78
  makeSelectionSpanContent("node");
79
79
 
80
80
  expect(
81
- selection.eq(getEditor().transact((tr) => tr.selection))
81
+ selection.eq(getEditor().transact((tr) => tr.selection)),
82
82
  ).toBeTruthy();
83
83
  });
84
84
 
@@ -93,7 +93,7 @@ describe("Test moveSelectedBlockAndSelection", () => {
93
93
  makeSelectionSpanContent("cell");
94
94
 
95
95
  expect(
96
- selection.eq(getEditor().transact((tr) => tr.selection))
96
+ selection.eq(getEditor().transact((tr) => tr.selection)),
97
97
  ).toBeTruthy();
98
98
  });
99
99
 
@@ -106,7 +106,7 @@ describe("Test moveSelectedBlockAndSelection", () => {
106
106
  getEditor().setSelection("paragraph-1", "paragraph-2");
107
107
 
108
108
  expect(
109
- selection.eq(getEditor().transact((tr) => tr.selection))
109
+ selection.eq(getEditor().transact((tr) => tr.selection)),
110
110
  ).toBeTruthy();
111
111
  });
112
112
 
@@ -119,7 +119,7 @@ describe("Test moveSelectedBlockAndSelection", () => {
119
119
  getEditor().setSelection("paragraph-6", "table-0");
120
120
 
121
121
  expect(
122
- selection.eq(getEditor().transact((tr) => tr.selection))
122
+ selection.eq(getEditor().transact((tr) => tr.selection)),
123
123
  ).toBeTruthy();
124
124
  });
125
125
  });
@@ -41,7 +41,7 @@ type BlockSelectionData = (
41
41
  * @param editor The BlockNote editor instance to get the selection data from.
42
42
  */
43
43
  function getBlockSelectionData(
44
- editor: BlockNoteEditor<any, any, any>
44
+ editor: BlockNoteEditor<any, any, any>,
45
45
  ): BlockSelectionData {
46
46
  return editor.transact((tr) => {
47
47
  const anchorBlockPosInfo = getNearestBlockPos(tr.doc, tr.selection.anchor);
@@ -87,12 +87,12 @@ function getBlockSelectionData(
87
87
  */
88
88
  function updateBlockSelectionFromData(
89
89
  tr: Transaction,
90
- data: BlockSelectionData
90
+ data: BlockSelectionData,
91
91
  ) {
92
92
  const anchorBlockPos = getNodeById(data.anchorBlockId, tr.doc)?.posBeforeNode;
93
93
  if (anchorBlockPos === undefined) {
94
94
  throw new Error(
95
- `Could not find block with ID ${data.anchorBlockId} to update selection`
95
+ `Could not find block with ID ${data.anchorBlockId} to update selection`,
96
96
  );
97
97
  }
98
98
 
@@ -101,7 +101,7 @@ function updateBlockSelectionFromData(
101
101
  selection = CellSelection.create(
102
102
  tr.doc,
103
103
  anchorBlockPos + data.anchorCellOffset,
104
- anchorBlockPos + data.headCellOffset
104
+ anchorBlockPos + data.headCellOffset,
105
105
  );
106
106
  } else if (data.type === "node") {
107
107
  selection = NodeSelection.create(tr.doc, anchorBlockPos + 1);
@@ -109,14 +109,14 @@ function updateBlockSelectionFromData(
109
109
  const headBlockPos = getNodeById(data.headBlockId, tr.doc)?.posBeforeNode;
110
110
  if (headBlockPos === undefined) {
111
111
  throw new Error(
112
- `Could not find block with ID ${data.headBlockId} to update selection`
112
+ `Could not find block with ID ${data.headBlockId} to update selection`,
113
113
  );
114
114
  }
115
115
 
116
116
  selection = TextSelection.create(
117
117
  tr.doc,
118
118
  anchorBlockPos + data.anchorOffset,
119
- headBlockPos + data.headOffset
119
+ headBlockPos + data.headOffset,
120
120
  );
121
121
  }
122
122
 
@@ -130,7 +130,7 @@ function updateBlockSelectionFromData(
130
130
  * @param blocks The blocks to flatten.
131
131
  */
132
132
  function flattenColumns(
133
- blocks: Block<any, any, any>[]
133
+ blocks: Block<any, any, any>[],
134
134
  ): Block<any, any, any>[] {
135
135
  return blocks
136
136
  .map((block) => {
@@ -161,7 +161,7 @@ function flattenColumns(
161
161
  export function moveSelectedBlocksAndSelection(
162
162
  editor: BlockNoteEditor<any, any, any>,
163
163
  referenceBlock: BlockIdentifier,
164
- placement: "before" | "after"
164
+ placement: "before" | "after",
165
165
  ) {
166
166
  // We want this to be a single step in the undo history
167
167
  editor.transact((tr) => {
@@ -198,7 +198,7 @@ function checkPlacementIsValid(parentBlock?: Block<any, any, any>): boolean {
198
198
  function getMoveUpPlacement(
199
199
  editor: BlockNoteEditor<any, any, any>,
200
200
  prevBlock?: Block<any, any, any>,
201
- parentBlock?: Block<any, any, any>
201
+ parentBlock?: Block<any, any, any>,
202
202
  ):
203
203
  | { referenceBlock: BlockIdentifier; placement: "before" | "after" }
204
204
  | undefined {
@@ -230,7 +230,7 @@ function getMoveUpPlacement(
230
230
  placement === "after"
231
231
  ? referenceBlock
232
232
  : editor.getPrevBlock(referenceBlock),
233
- referenceBlockParent
233
+ referenceBlockParent,
234
234
  );
235
235
  }
236
236
 
@@ -250,7 +250,7 @@ function getMoveUpPlacement(
250
250
  function getMoveDownPlacement(
251
251
  editor: BlockNoteEditor<any, any, any>,
252
252
  nextBlock?: Block<any, any, any>,
253
- parentBlock?: Block<any, any, any>
253
+ parentBlock?: Block<any, any, any>,
254
254
  ):
255
255
  | { referenceBlock: BlockIdentifier; placement: "before" | "after" }
256
256
  | undefined {
@@ -282,7 +282,7 @@ function getMoveDownPlacement(
282
282
  placement === "before"
283
283
  ? referenceBlock
284
284
  : editor.getNextBlock(referenceBlock),
285
- referenceBlockParent
285
+ referenceBlockParent,
286
286
  );
287
287
  }
288
288
 
@@ -297,7 +297,7 @@ export function moveBlocksUp(editor: BlockNoteEditor<any, any, any>) {
297
297
  const moveUpPlacement = getMoveUpPlacement(
298
298
  editor,
299
299
  editor.getPrevBlock(block),
300
- editor.getParentBlock(block)
300
+ editor.getParentBlock(block),
301
301
  );
302
302
 
303
303
  if (!moveUpPlacement) {
@@ -307,7 +307,7 @@ export function moveBlocksUp(editor: BlockNoteEditor<any, any, any>) {
307
307
  moveSelectedBlocksAndSelection(
308
308
  editor,
309
309
  moveUpPlacement.referenceBlock,
310
- moveUpPlacement.placement
310
+ moveUpPlacement.placement,
311
311
  );
312
312
  });
313
313
  }
@@ -322,7 +322,7 @@ export function moveBlocksDown(editor: BlockNoteEditor<any, any, any>) {
322
322
  const moveDownPlacement = getMoveDownPlacement(
323
323
  editor,
324
324
  editor.getNextBlock(block),
325
- editor.getParentBlock(block)
325
+ editor.getParentBlock(block),
326
326
  );
327
327
 
328
328
  if (!moveDownPlacement) {
@@ -332,7 +332,7 @@ export function moveBlocksDown(editor: BlockNoteEditor<any, any, any>) {
332
332
  moveSelectedBlocksAndSelection(
333
333
  editor,
334
334
  moveDownPlacement.referenceBlock,
335
- moveDownPlacement.placement
335
+ moveDownPlacement.placement,
336
336
  );
337
337
  });
338
338
  }
@@ -18,7 +18,7 @@ function sinkListItem(itemType: NodeType, groupType: NodeType) {
18
18
  $to,
19
19
  (node) =>
20
20
  node.childCount > 0 &&
21
- (node.type.name === "blockGroup" || node.type.name === "column") // change necessary to not look at first item child type
21
+ (node.type.name === "blockGroup" || node.type.name === "column"), // change necessary to not look at first item child type
22
22
  );
23
23
  if (!range) {
24
24
  return false;
@@ -38,10 +38,10 @@ function sinkListItem(itemType: NodeType, groupType: NodeType) {
38
38
  const inner = Fragment.from(nestedBefore ? itemType.create() : null);
39
39
  const slice = new Slice(
40
40
  Fragment.from(
41
- itemType.create(null, Fragment.from(groupType.create(null, inner))) // change necessary to create "groupType" instead of parent.type
41
+ itemType.create(null, Fragment.from(groupType.create(null, inner))), // change necessary to create "groupType" instead of parent.type
42
42
  ),
43
43
  nestedBefore ? 3 : 1,
44
- 0
44
+ 0,
45
45
  );
46
46
 
47
47
  const before = range.start;
@@ -56,10 +56,10 @@ function sinkListItem(itemType: NodeType, groupType: NodeType) {
56
56
  after,
57
57
  slice,
58
58
  1,
59
- true
60
- )
59
+ true,
60
+ ),
61
61
  )
62
- .scrollIntoView()
62
+ .scrollIntoView(),
63
63
  );
64
64
  }
65
65
  return true;
@@ -70,8 +70,8 @@ export function nestBlock(editor: BlockNoteEditor<any, any, any>) {
70
70
  return editor.exec((state, dispatch) =>
71
71
  sinkListItem(
72
72
  state.schema.nodes["blockContainer"],
73
- state.schema.nodes["blockGroup"]
74
- )(state, dispatch)
73
+ state.schema.nodes["blockGroup"],
74
+ )(state, dispatch),
75
75
  );
76
76
  }
77
77
 
@@ -144,7 +144,6 @@ exports[`Test replaceBlocks > Remove multiple consecutive blocks 1`] = `
144
144
  "backgroundColor": "default",
145
145
  "caption": "",
146
146
  "name": "",
147
- "previewWidth": 512,
148
147
  "showPreview": true,
149
148
  "textAlignment": "left",
150
149
  "url": "https://via.placeholder.com/150",
@@ -694,7 +693,6 @@ exports[`Test replaceBlocks > Remove multiple non-consecutive blocks 1`] = `
694
693
  "backgroundColor": "default",
695
694
  "caption": "",
696
695
  "name": "",
697
- "previewWidth": 512,
698
696
  "showPreview": true,
699
697
  "textAlignment": "left",
700
698
  "url": "https://via.placeholder.com/150",
@@ -991,7 +989,6 @@ exports[`Test replaceBlocks > Remove single block 1`] = `
991
989
  "backgroundColor": "default",
992
990
  "caption": "",
993
991
  "name": "",
994
- "previewWidth": 512,
995
992
  "showPreview": true,
996
993
  "textAlignment": "left",
997
994
  "url": "https://via.placeholder.com/150",
@@ -1522,7 +1519,6 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with multiple
1522
1519
  "backgroundColor": "default",
1523
1520
  "caption": "",
1524
1521
  "name": "",
1525
- "previewWidth": 512,
1526
1522
  "showPreview": true,
1527
1523
  "textAlignment": "left",
1528
1524
  "url": "https://via.placeholder.com/150",
@@ -2013,7 +2009,6 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with single ba
2013
2009
  "backgroundColor": "default",
2014
2010
  "caption": "",
2015
2011
  "name": "",
2016
- "previewWidth": 512,
2017
2012
  "showPreview": true,
2018
2013
  "textAlignment": "left",
2019
2014
  "url": "https://via.placeholder.com/150",
@@ -2561,7 +2556,6 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with single co
2561
2556
  "backgroundColor": "default",
2562
2557
  "caption": "",
2563
2558
  "name": "",
2564
- "previewWidth": 512,
2565
2559
  "showPreview": true,
2566
2560
  "textAlignment": "left",
2567
2561
  "url": "https://via.placeholder.com/150",
@@ -3162,7 +3156,6 @@ exports[`Test replaceBlocks > Replace multiple non-consecutive blocks with multi
3162
3156
  "backgroundColor": "default",
3163
3157
  "caption": "",
3164
3158
  "name": "",
3165
- "previewWidth": 512,
3166
3159
  "showPreview": true,
3167
3160
  "textAlignment": "left",
3168
3161
  "url": "https://via.placeholder.com/150",
@@ -3470,7 +3463,6 @@ exports[`Test replaceBlocks > Replace multiple non-consecutive blocks with singl
3470
3463
  "backgroundColor": "default",
3471
3464
  "caption": "",
3472
3465
  "name": "",
3473
- "previewWidth": 512,
3474
3466
  "showPreview": true,
3475
3467
  "textAlignment": "left",
3476
3468
  "url": "https://via.placeholder.com/150",
@@ -3835,7 +3827,6 @@ exports[`Test replaceBlocks > Replace multiple non-consecutive blocks with singl
3835
3827
  "backgroundColor": "default",
3836
3828
  "caption": "",
3837
3829
  "name": "",
3838
- "previewWidth": 512,
3839
3830
  "showPreview": true,
3840
3831
  "textAlignment": "left",
3841
3832
  "url": "https://via.placeholder.com/150",
@@ -4183,7 +4174,6 @@ exports[`Test replaceBlocks > Replace single block with multiple 1`] = `
4183
4174
  "backgroundColor": "default",
4184
4175
  "caption": "",
4185
4176
  "name": "",
4186
- "previewWidth": 512,
4187
4177
  "showPreview": true,
4188
4178
  "textAlignment": "left",
4189
4179
  "url": "https://via.placeholder.com/150",
@@ -4744,7 +4734,6 @@ exports[`Test replaceBlocks > Replace single block with single basic 1`] = `
4744
4734
  "backgroundColor": "default",
4745
4735
  "caption": "",
4746
4736
  "name": "",
4747
- "previewWidth": 512,
4748
4737
  "showPreview": true,
4749
4738
  "textAlignment": "left",
4750
4739
  "url": "https://via.placeholder.com/150",
@@ -5362,7 +5351,6 @@ exports[`Test replaceBlocks > Replace single block with single complex 1`] = `
5362
5351
  "backgroundColor": "default",
5363
5352
  "caption": "",
5364
5353
  "name": "",
5365
- "previewWidth": 512,
5366
5354
  "showPreview": true,
5367
5355
  "textAlignment": "left",
5368
5356
  "url": "https://via.placeholder.com/150",
@@ -11,10 +11,10 @@ const getEditor = setupTestEnv();
11
11
  function replaceBlocks(
12
12
  editor: BlockNoteEditor,
13
13
  blocksToRemove: BlockIdentifier[],
14
- blocksToInsert: PartialBlock<any, any, any>[]
14
+ blocksToInsert: PartialBlock<any, any, any>[],
15
15
  ) {
16
16
  return editor.transact((tr) =>
17
- removeAndInsertBlocks(tr, blocksToRemove, blocksToInsert)
17
+ removeAndInsertBlocks(tr, blocksToRemove, blocksToInsert),
18
18
  );
19
19
  }
20
20
 
@@ -29,7 +29,7 @@ describe("Test replaceBlocks", () => {
29
29
  replaceBlocks(
30
30
  getEditor(),
31
31
  ["paragraph-0", "paragraph-1", "paragraph-with-children"],
32
- []
32
+ [],
33
33
  );
34
34
 
35
35
  expect(getEditor().document).toMatchSnapshot();
@@ -39,7 +39,7 @@ describe("Test replaceBlocks", () => {
39
39
  replaceBlocks(
40
40
  getEditor(),
41
41
  ["paragraph-0", "table-0", "heading-with-everything"],
42
- []
42
+ [],
43
43
  );
44
44
 
45
45
  expect(getEditor().document).toMatchSnapshot();
@@ -55,7 +55,7 @@ describe("Test replaceBlocks", () => {
55
55
  replaceBlocks(
56
56
  getEditor(),
57
57
  ["paragraph-0", "paragraph-1", "paragraph-with-children"],
58
- [{ type: "paragraph" }]
58
+ [{ type: "paragraph" }],
59
59
  );
60
60
 
61
61
  expect(getEditor().document).toMatchSnapshot();
@@ -65,7 +65,7 @@ describe("Test replaceBlocks", () => {
65
65
  replaceBlocks(
66
66
  getEditor(),
67
67
  ["paragraph-0", "table-0", "heading-with-everything"],
68
- [{ type: "paragraph" }]
68
+ [{ type: "paragraph" }],
69
69
  );
70
70
 
71
71
  expect(getEditor().document).toMatchSnapshot();
@@ -79,7 +79,7 @@ describe("Test replaceBlocks", () => {
79
79
  { type: "paragraph", content: "Inserted paragraph 1" },
80
80
  { type: "paragraph", content: "Inserted paragraph 2" },
81
81
  { type: "paragraph", content: "Inserted paragraph 3" },
82
- ]
82
+ ],
83
83
  );
84
84
 
85
85
  expect(getEditor().document).toMatchSnapshot();
@@ -93,7 +93,7 @@ describe("Test replaceBlocks", () => {
93
93
  { type: "paragraph", content: "Inserted paragraph 1" },
94
94
  { type: "paragraph", content: "Inserted paragraph 2" },
95
95
  { type: "paragraph", content: "Inserted paragraph 3" },
96
- ]
96
+ ],
97
97
  );
98
98
 
99
99
  expect(getEditor().document).toMatchSnapshot();
@@ -107,7 +107,7 @@ describe("Test replaceBlocks", () => {
107
107
  { type: "paragraph", content: "Inserted paragraph 1" },
108
108
  { type: "paragraph", content: "Inserted paragraph 2" },
109
109
  { type: "paragraph", content: "Inserted paragraph 3" },
110
- ]
110
+ ],
111
111
  );
112
112
 
113
113
  expect(getEditor().document).toMatchSnapshot();
@@ -147,7 +147,7 @@ describe("Test replaceBlocks", () => {
147
147
  },
148
148
  ],
149
149
  },
150
- ]
150
+ ],
151
151
  );
152
152
 
153
153
  expect(getEditor().document).toMatchSnapshot();
@@ -187,7 +187,7 @@ describe("Test replaceBlocks", () => {
187
187
  },
188
188
  ],
189
189
  },
190
- ]
190
+ ],
191
191
  );
192
192
 
193
193
  expect(getEditor().document).toMatchSnapshot();
@@ -227,7 +227,7 @@ describe("Test replaceBlocks", () => {
227
227
  },
228
228
  ],
229
229
  },
230
- ]
230
+ ],
231
231
  );
232
232
 
233
233
  expect(getEditor().document).toMatchSnapshot();
@@ -14,11 +14,11 @@ import { getPmSchema } from "../../../pmUtil.js";
14
14
  export function removeAndInsertBlocks<
15
15
  BSchema extends BlockSchema,
16
16
  I extends InlineContentSchema,
17
- S extends StyleSchema
17
+ S extends StyleSchema,
18
18
  >(
19
19
  tr: Transaction,
20
20
  blocksToRemove: BlockIdentifier[],
21
- blocksToInsert: PartialBlock<BSchema, I, S>[]
21
+ blocksToInsert: PartialBlock<BSchema, I, S>[],
22
22
  ): {
23
23
  insertedBlocks: Block<BSchema, I, S>[];
24
24
  removedBlocks: Block<BSchema, I, S>[];
@@ -27,13 +27,13 @@ export function removeAndInsertBlocks<
27
27
  // Converts the `PartialBlock`s to ProseMirror nodes to insert them into the
28
28
  // document.
29
29
  const nodesToInsert: Node[] = blocksToInsert.map((block) =>
30
- blockToNode(block, pmSchema)
30
+ blockToNode(block, pmSchema),
31
31
  );
32
32
 
33
33
  const idsOfBlocksToRemove = new Set<string>(
34
34
  blocksToRemove.map((block) =>
35
- typeof block === "string" ? block : block.id
36
- )
35
+ typeof block === "string" ? block : block.id,
36
+ ),
37
37
  );
38
38
  const removedBlocks: Block<BSchema, I, S>[] = [];
39
39
 
@@ -95,13 +95,13 @@ export function removeAndInsertBlocks<
95
95
 
96
96
  throw Error(
97
97
  "Blocks with the following IDs could not be found in the editor: " +
98
- notFoundIds
98
+ notFoundIds,
99
99
  );
100
100
  }
101
101
 
102
102
  // Converts the nodes created from `blocksToInsert` into full `Block`s.
103
103
  const insertedBlocks = nodesToInsert.map((node) =>
104
- nodeToBlock(node, pmSchema)
104
+ nodeToBlock(node, pmSchema),
105
105
  );
106
106
 
107
107
  return { insertedBlocks, removedBlocks };