@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
@@ -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
 
@@ -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,14 +95,14 @@ 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 };
108
- }
108
+ }
@@ -15,17 +15,17 @@ const getEditor = setupTestEnv();
15
15
  function splitBlock(
16
16
  posInBlock: number,
17
17
  keepType?: boolean,
18
- keepProps?: boolean
18
+ keepProps?: boolean,
19
19
  ) {
20
20
  getEditor()._tiptapEditor.commands.command(
21
- splitBlockCommand(posInBlock, keepType, keepProps)
21
+ splitBlockCommand(posInBlock, keepType, keepProps),
22
22
  );
23
23
  }
24
24
 
25
25
  function setSelectionWithOffset(
26
26
  doc: Node,
27
27
  targetBlockId: string,
28
- offset: number
28
+ offset: number,
29
29
  ) {
30
30
  const posInfo = getNodeById(targetBlockId, doc);
31
31
  if (!posInfo) {
@@ -40,8 +40,8 @@ function setSelectionWithOffset(
40
40
 
41
41
  getEditor().transact((tr) =>
42
42
  tr.setSelection(
43
- TextSelection.create(doc, info.blockContent.beforePos + offset + 1)
44
- )
43
+ TextSelection.create(doc, info.blockContent.beforePos + offset + 1),
44
+ ),
45
45
  );
46
46
  }
47
47
 
@@ -83,7 +83,7 @@ describe("Test splitBlocks", () => {
83
83
 
84
84
  splitBlock(
85
85
  getEditor().transact((tr) => tr.selection.anchor),
86
- true
86
+ true,
87
87
  );
88
88
 
89
89
  expect(getEditor().document).toMatchSnapshot();
@@ -96,7 +96,7 @@ describe("Test splitBlocks", () => {
96
96
 
97
97
  splitBlock(
98
98
  getEditor().transact((tr) => tr.selection.anchor),
99
- false
99
+ false,
100
100
  );
101
101
 
102
102
  expect(getEditor().document).toMatchSnapshot();
@@ -110,7 +110,7 @@ describe("Test splitBlocks", () => {
110
110
  splitBlock(
111
111
  getEditor().transact((tr) => tr.selection.anchor),
112
112
  false,
113
- true
113
+ true,
114
114
  );
115
115
 
116
116
  expect(getEditor().document).toMatchSnapshot();
@@ -124,7 +124,7 @@ describe("Test splitBlocks", () => {
124
124
  splitBlock(
125
125
  getEditor().transact((tr) => tr.selection.anchor),
126
126
  false,
127
- false
127
+ false,
128
128
  );
129
129
 
130
130
  expect(getEditor().document).toMatchSnapshot();
@@ -138,7 +138,7 @@ describe("Test splitBlocks", () => {
138
138
  splitBlock(getEditor().transact((tr) => tr.selection.anchor));
139
139
 
140
140
  const bnBlock = getEditor().transact(
141
- (tr) => getBlockInfoFromTransaction(tr).bnBlock
141
+ (tr) => getBlockInfoFromTransaction(tr).bnBlock,
142
142
  );
143
143
 
144
144
  const anchorIsAtStartOfNewBlock =
@@ -8,7 +8,7 @@ import {
8
8
  export const splitBlockCommand = (
9
9
  posInBlock: number,
10
10
  keepType?: boolean,
11
- keepProps?: boolean
11
+ keepProps?: boolean,
12
12
  ) => {
13
13
  return ({
14
14
  state,
@@ -23,7 +23,7 @@ export const splitBlockCommand = (
23
23
 
24
24
  if (!info.isBlockContainer) {
25
25
  throw new Error(
26
- `BlockContainer expected when calling splitBlock, position ${posInBlock}`
26
+ `BlockContainer expected when calling splitBlock, position ${posInBlock}`,
27
27
  );
28
28
  }
29
29