@blocknote/core 0.30.0 → 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 (148) hide show
  1. package/dist/blocknote.cjs +2 -2
  2. package/dist/blocknote.cjs.map +1 -1
  3. package/dist/blocknote.js +22 -20
  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/style.css +1 -1
  8. package/dist/tsconfig.tsbuildinfo +1 -1
  9. package/dist/webpack-stats.json +1 -1
  10. package/package.json +5 -3
  11. package/src/api/README.md +1 -1
  12. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +19 -14
  13. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +5 -5
  14. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
  15. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +12 -12
  16. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +14 -14
  17. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +16 -16
  18. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +8 -8
  19. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +12 -12
  20. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +7 -7
  21. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +10 -10
  22. package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +2 -2
  23. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -42
  24. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +18 -18
  25. package/src/api/blockManipulation/getBlock/getBlock.ts +9 -9
  26. package/src/api/blockManipulation/insertContentAt.ts +1 -1
  27. package/src/api/blockManipulation/selections/selection.ts +11 -11
  28. package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +7 -7
  29. package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +6 -6
  30. package/src/api/blockManipulation/tables/tables.test.ts +106 -106
  31. package/src/api/blockManipulation/tables/tables.ts +35 -35
  32. package/src/api/clipboard/fromClipboard/fileDropExtension.ts +2 -2
  33. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +9 -9
  34. package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +3 -3
  35. package/src/api/clipboard/fromClipboard/pasteExtension.ts +3 -3
  36. package/src/api/clipboard/toClipboard/copyExtension.ts +22 -22
  37. package/src/api/exporters/html/externalHTMLExporter.ts +6 -6
  38. package/src/api/exporters/html/internalHTMLSerializer.ts +3 -3
  39. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +16 -16
  40. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +14 -14
  41. package/src/api/exporters/markdown/markdownExporter.ts +3 -3
  42. package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +3 -3
  43. package/src/api/getBlockInfoFromPos.ts +6 -6
  44. package/src/api/nodeConversions/blockToNode.ts +26 -26
  45. package/src/api/nodeConversions/fragmentToBlocks.ts +1 -1
  46. package/src/api/nodeConversions/nodeToBlock.ts +37 -33
  47. package/src/api/nodeUtil.test.ts +16 -16
  48. package/src/api/nodeUtil.ts +10 -10
  49. package/src/api/parsers/html/parseHTML.ts +1 -1
  50. package/src/api/parsers/html/util/nestedLists.ts +2 -2
  51. package/src/api/parsers/markdown/parseMarkdown.ts +1 -1
  52. package/src/api/pmUtil.ts +4 -4
  53. package/src/api/positionMapping.test.ts +3 -3
  54. package/src/api/positionMapping.ts +5 -5
  55. package/src/blocks/AudioBlockContent/AudioBlockContent.ts +4 -4
  56. package/src/blocks/CodeBlockContent/CodeBlockContent.ts +12 -12
  57. package/src/blocks/FileBlockContent/FileBlockContent.ts +2 -2
  58. package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +2 -2
  59. package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +5 -5
  60. package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +2 -2
  61. package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +1 -1
  62. package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +7 -7
  63. package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +1 -1
  64. package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +1 -1
  65. package/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +2 -2
  66. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +6 -6
  67. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +4 -4
  68. package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +4 -4
  69. package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +10 -10
  70. package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
  71. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +1 -1
  72. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +4 -4
  73. package/src/blocks/ListItemBlockContent/getListItemContent.ts +5 -5
  74. package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +1 -1
  75. package/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.ts +3 -3
  76. package/src/blocks/PageBreakBlockContent/schema.ts +2 -2
  77. package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +3 -3
  78. package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +4 -4
  79. package/src/blocks/README.md +1 -1
  80. package/src/blocks/TableBlockContent/TableBlockContent.ts +5 -5
  81. package/src/blocks/TableBlockContent/TableExtension.ts +3 -3
  82. package/src/blocks/VideoBlockContent/VideoBlockContent.ts +4 -4
  83. package/src/blocks/defaultBlockHelpers.ts +8 -8
  84. package/src/blocks/defaultBlockTypeGuards.ts +16 -16
  85. package/src/blocks/defaultBlocks.ts +3 -3
  86. package/src/comments/threadstore/DefaultThreadStoreAuth.ts +3 -3
  87. package/src/comments/threadstore/ThreadStore.ts +1 -1
  88. package/src/comments/threadstore/TipTapThreadStore.ts +10 -10
  89. package/src/comments/threadstore/yjs/RESTYjsThreadStore.ts +4 -4
  90. package/src/comments/threadstore/yjs/YjsThreadStore.test.ts +2 -2
  91. package/src/comments/threadstore/yjs/YjsThreadStore.ts +14 -14
  92. package/src/comments/threadstore/yjs/YjsThreadStoreBase.ts +1 -1
  93. package/src/comments/threadstore/yjs/yjsHelpers.ts +6 -6
  94. package/src/editor/Block.css +8 -0
  95. package/src/editor/BlockNoteEditor.test.ts +3 -3
  96. package/src/editor/BlockNoteEditor.ts +7 -1
  97. package/src/editor/BlockNoteExtensions.ts +10 -10
  98. package/src/editor/BlockNoteSchema.ts +4 -4
  99. package/src/editor/BlockNoteTipTapEditor.ts +10 -10
  100. package/src/editor/README.md +1 -1
  101. package/src/editor/cursorPositionTypes.ts +1 -1
  102. package/src/editor/editor.css +15 -3
  103. package/src/editor/selectionTypes.ts +1 -1
  104. package/src/editor/transformPasted.ts +2 -2
  105. package/src/exporter/Exporter.ts +5 -5
  106. package/src/exporter/mapping.ts +7 -7
  107. package/src/extensions/BackgroundColor/BackgroundColorMark.ts +1 -1
  108. package/src/extensions/Collaboration/CursorPlugin.ts +2 -2
  109. package/src/extensions/Comments/CommentsPlugin.ts +9 -9
  110. package/src/extensions/Comments/userstore/UserStore.ts +2 -2
  111. package/src/extensions/FilePanel/FilePanelPlugin.ts +7 -7
  112. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +4 -4
  113. package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +26 -26
  114. package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +11 -11
  115. package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +4 -4
  116. package/src/extensions/Placeholder/PlaceholderPlugin.ts +10 -10
  117. package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +2 -2
  118. package/src/extensions/README.md +1 -1
  119. package/src/extensions/SideMenu/MultipleNodeSelection.ts +1 -1
  120. package/src/extensions/SideMenu/SideMenuPlugin.ts +31 -31
  121. package/src/extensions/SideMenu/dragging.ts +8 -8
  122. package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +17 -17
  123. package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -2
  124. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +12 -12
  125. package/src/extensions/TableHandles/TableHandlesPlugin.ts +54 -53
  126. package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
  127. package/src/extensions/UniqueID/UniqueID.ts +6 -6
  128. package/src/extensions/getDraggableBlockFromElement.ts +1 -1
  129. package/src/fonts/inter.css +18 -9
  130. package/src/locales.ts +1 -1
  131. package/src/pm-nodes/BlockGroup.ts +1 -1
  132. package/src/pm-nodes/Doc.ts +4 -4
  133. package/src/schema/README.md +1 -1
  134. package/src/schema/blocks/createSpec.ts +14 -14
  135. package/src/schema/blocks/internal.ts +17 -17
  136. package/src/schema/blocks/types.ts +25 -25
  137. package/src/schema/inlineContent/createSpec.ts +16 -20
  138. package/src/schema/inlineContent/internal.ts +9 -9
  139. package/src/schema/inlineContent/types.ts +26 -26
  140. package/src/schema/propTypes.ts +8 -8
  141. package/src/schema/styles/createSpec.ts +2 -2
  142. package/src/schema/styles/internal.ts +7 -7
  143. package/src/schema/styles/types.ts +2 -2
  144. package/src/util/EventEmitter.ts +4 -4
  145. package/src/util/README.md +1 -1
  146. package/src/util/combineByGroup.ts +1 -1
  147. package/src/util/table.ts +33 -30
  148. package/types/src/editor/BlockNoteEditor.d.ts +3 -1
@@ -48,7 +48,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
48
48
  updateBlockCommand(blockInfo.bnBlock.beforePos, {
49
49
  type: "paragraph",
50
50
  props: {},
51
- })
51
+ }),
52
52
  );
53
53
  }
54
54
 
@@ -114,7 +114,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
114
114
 
115
115
  const prevBlockInfo = getPrevBlockInfo(
116
116
  state.doc,
117
- blockInfo.bnBlock.beforePos
117
+ blockInfo.bnBlock.beforePos,
118
118
  );
119
119
 
120
120
  if (prevBlockInfo) {
@@ -124,7 +124,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
124
124
 
125
125
  const parentBlockInfo = getParentBlockInfo(
126
126
  state.doc,
127
- blockInfo.bnBlock.beforePos
127
+ blockInfo.bnBlock.beforePos,
128
128
  );
129
129
 
130
130
  if (parentBlockInfo?.blockNoteType !== "column") {
@@ -135,7 +135,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
135
135
 
136
136
  const columnList = getParentBlockInfo(
137
137
  state.doc,
138
- column.bnBlock.beforePos
138
+ column.bnBlock.beforePos,
139
139
  );
140
140
  if (columnList?.blockNoteType !== "columnList") {
141
141
  throw new Error("parent of column is not a column list");
@@ -156,7 +156,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
156
156
  const blockToMove = state.doc.slice(
157
157
  blockInfo.bnBlock.beforePos,
158
158
  blockInfo.bnBlock.afterPos,
159
- false
159
+ false,
160
160
  );
161
161
 
162
162
  /*
@@ -180,8 +180,8 @@ export const KeyboardShortcutsExtension = Extension.create<{
180
180
  columnList.bnBlock.afterPos - 2,
181
181
  blockToMove,
182
182
  blockToMove.size, // append existing content to blockToMove
183
- false
184
- )
183
+ false,
184
+ ),
185
185
  );
186
186
  const pos = state.tr.doc.resolve(column.bnBlock.beforePos);
187
187
  state.tr.setSelection(TextSelection.between(pos, pos));
@@ -197,11 +197,11 @@ export const KeyboardShortcutsExtension = Extension.create<{
197
197
  column.bnBlock.beforePos - 1,
198
198
  blockToMove,
199
199
  0, // prepend existing content to blockToMove
200
- false
201
- )
200
+ false,
201
+ ),
202
202
  );
203
203
  const pos = state.tr.doc.resolve(
204
- state.tr.mapping.map(column.bnBlock.beforePos - 1)
204
+ state.tr.mapping.map(column.bnBlock.beforePos - 1),
205
205
  );
206
206
  state.tr.setSelection(TextSelection.between(pos, pos));
207
207
  }
@@ -210,43 +210,43 @@ export const KeyboardShortcutsExtension = Extension.create<{
210
210
  // delete column
211
211
  state.tr.delete(
212
212
  column.bnBlock.beforePos,
213
- column.bnBlock.afterPos
213
+ column.bnBlock.afterPos,
214
214
  );
215
215
 
216
216
  // move before columnlist
217
217
  state.tr.insert(
218
218
  columnList.bnBlock.beforePos,
219
- blockToMove.content
219
+ blockToMove.content,
220
220
  );
221
221
 
222
222
  const pos = state.tr.doc.resolve(
223
- columnList.bnBlock.beforePos
223
+ columnList.bnBlock.beforePos,
224
224
  );
225
225
  state.tr.setSelection(TextSelection.between(pos, pos));
226
226
  } else {
227
227
  // just delete the </column><column> closing and opening tags to merge the columns
228
228
  state.tr.delete(
229
229
  column.bnBlock.beforePos - 1,
230
- column.bnBlock.beforePos + 1
230
+ column.bnBlock.beforePos + 1,
231
231
  );
232
232
  }
233
233
  } else {
234
234
  // delete block
235
235
  state.tr.delete(
236
236
  blockInfo.bnBlock.beforePos,
237
- blockInfo.bnBlock.afterPos
237
+ blockInfo.bnBlock.afterPos,
238
238
  );
239
239
  if (isFirstColumn) {
240
240
  // move before columnlist
241
241
  state.tr.insert(
242
242
  columnList.bnBlock.beforePos - 1,
243
- blockToMove.content
243
+ blockToMove.content,
244
244
  );
245
245
  } else {
246
246
  // append block to previous column
247
247
  state.tr.insert(
248
248
  column.bnBlock.beforePos - 1,
249
- blockToMove.content
249
+ blockToMove.content,
250
250
  );
251
251
  }
252
252
  const pos = state.tr.doc.resolve(column.bnBlock.beforePos - 1);
@@ -272,7 +272,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
272
272
  if (blockEmpty) {
273
273
  const prevBlockInfo = getPrevBlockInfo(
274
274
  state.doc,
275
- blockInfo.bnBlock.beforePos
275
+ blockInfo.bnBlock.beforePos,
276
276
  );
277
277
  if (!prevBlockInfo || !prevBlockInfo.isBlockContainer) {
278
278
  return false;
@@ -291,7 +291,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
291
291
  const lastCellParagraphEndPos = lastCellEndPos - 1;
292
292
 
293
293
  chainedCommands = chainedCommands.setTextSelection(
294
- lastCellParagraphEndPos
294
+ lastCellParagraphEndPos,
295
295
  );
296
296
  } else if (
297
297
  prevBlockInfo.blockContent.node.type.spec.content === ""
@@ -301,7 +301,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
301
301
  prevBlockInfo.blockContent.node.nodeSize;
302
302
 
303
303
  chainedCommands = chainedCommands.setNodeSelection(
304
- nonEditableBlockContentStartPos
304
+ nonEditableBlockContentStartPos,
305
305
  );
306
306
  } else {
307
307
  const blockContentStartPos =
@@ -341,13 +341,13 @@ export const KeyboardShortcutsExtension = Extension.create<{
341
341
 
342
342
  const prevBlockInfo = getPrevBlockInfo(
343
343
  state.doc,
344
- blockInfo.bnBlock.beforePos
344
+ blockInfo.bnBlock.beforePos,
345
345
  );
346
346
 
347
347
  if (prevBlockInfo && selectionAtBlockStart && selectionEmpty) {
348
348
  const bottomBlock = getBottomNestedBlockInfo(
349
349
  state.doc,
350
- prevBlockInfo
350
+ prevBlockInfo,
351
351
  );
352
352
 
353
353
  if (!bottomBlock.isBlockContainer) {
@@ -368,7 +368,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
368
368
  from: blockInfo.bnBlock.beforePos,
369
369
  to: blockInfo.bnBlock.afterPos,
370
370
  },
371
- bottomBlock.bnBlock.afterPos
371
+ bottomBlock.bnBlock.afterPos,
372
372
  )
373
373
  .deleteRange({
374
374
  from: bottomBlock.bnBlock.beforePos,
@@ -521,7 +521,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
521
521
  .insert(newBlockInsertionPos, newBlock)
522
522
  .scrollIntoView();
523
523
  state.tr.setSelection(
524
- new TextSelection(state.doc.resolve(newBlockContentPos))
524
+ new TextSelection(state.doc.resolve(newBlockContentPos)),
525
525
  );
526
526
  }
527
527
 
@@ -551,8 +551,8 @@ export const KeyboardShortcutsExtension = Extension.create<{
551
551
  splitBlockCommand(
552
552
  state.selection.from,
553
553
  selectionAtBlockStart,
554
- selectionAtBlockStart
555
- )
554
+ selectionAtBlockStart,
555
+ ),
556
556
  )
557
557
  .run();
558
558
 
@@ -41,7 +41,7 @@ class LinkToolbarView implements PluginView {
41
41
  constructor(
42
42
  private readonly editor: BlockNoteEditor<any, any, any>,
43
43
  private readonly pmView: EditorView,
44
- emitUpdate: (state: LinkToolbarState) => void
44
+ emitUpdate: (state: LinkToolbarState) => void,
45
45
  ) {
46
46
  this.emitUpdate = () => {
47
47
  if (!this.state) {
@@ -70,7 +70,7 @@ class LinkToolbarView implements PluginView {
70
70
  this.pmView.root.addEventListener(
71
71
  "click",
72
72
  this.clickHandler as EventListener,
73
- true
73
+ true,
74
74
  );
75
75
 
76
76
  // Setting capture=true ensures that any parent container of the editor that
@@ -146,7 +146,7 @@ class LinkToolbarView implements PluginView {
146
146
  this.state.referencePos = posToDOMRect(
147
147
  this.pmView,
148
148
  this.linkMarkRange!.from,
149
- this.linkMarkRange!.to
149
+ this.linkMarkRange!.to,
150
150
  );
151
151
  this.emitUpdate();
152
152
  }
@@ -160,7 +160,7 @@ class LinkToolbarView implements PluginView {
160
160
  tr.addMark(
161
161
  this.linkMarkRange!.from,
162
162
  this.linkMarkRange!.from + text.length,
163
- pmSchema.mark("link", { href: url })
163
+ pmSchema.mark("link", { href: url }),
164
164
  );
165
165
  });
166
166
  this.pmView.focus();
@@ -177,9 +177,9 @@ class LinkToolbarView implements PluginView {
177
177
  .removeMark(
178
178
  this.linkMarkRange!.from,
179
179
  this.linkMarkRange!.to,
180
- this.linkMark!.type
180
+ this.linkMark!.type,
181
181
  )
182
- .setMeta("preventAutolink", true)
182
+ .setMeta("preventAutolink", true),
183
183
  );
184
184
  this.pmView.focus();
185
185
 
@@ -226,7 +226,7 @@ class LinkToolbarView implements PluginView {
226
226
  getMarkRange(
227
227
  this.pmView.state.selection.$from,
228
228
  mark.type,
229
- mark.attrs
229
+ mark.attrs,
230
230
  ) || undefined;
231
231
 
232
232
  break;
@@ -251,12 +251,12 @@ class LinkToolbarView implements PluginView {
251
251
  referencePos: posToDOMRect(
252
252
  this.pmView,
253
253
  this.linkMarkRange!.from,
254
- this.linkMarkRange!.to
254
+ this.linkMarkRange!.to,
255
255
  ),
256
256
  url: this.linkMark!.attrs.href,
257
257
  text: this.pmView.state.doc.textBetween(
258
258
  this.linkMarkRange!.from,
259
- this.linkMarkRange!.to
259
+ this.linkMarkRange!.to,
260
260
  ),
261
261
  };
262
262
  this.emitUpdate();
@@ -290,7 +290,7 @@ class LinkToolbarView implements PluginView {
290
290
  this.pmView.root.removeEventListener(
291
291
  "click",
292
292
  this.clickHandler as EventListener,
293
- true
293
+ true,
294
294
  );
295
295
  }
296
296
  }
@@ -300,7 +300,7 @@ export const linkToolbarPluginKey = new PluginKey("LinkToolbarPlugin");
300
300
  export class LinkToolbarProsemirrorPlugin<
301
301
  BSchema extends BlockSchema,
302
302
  I extends InlineContentSchema,
303
- S extends StyleSchema
303
+ S extends StyleSchema,
304
304
  > extends EventEmitter<any> {
305
305
  private view: LinkToolbarView | undefined;
306
306
  public readonly plugin: Plugin;
@@ -47,13 +47,13 @@ export class NodeSelectionKeyboardPlugin {
47
47
  tr
48
48
  .insert(
49
49
  view.state.tr.selection.$to.after(),
50
- view.state.schema.nodes["paragraph"].createChecked()
50
+ view.state.schema.nodes["paragraph"].createChecked(),
51
51
  )
52
52
  .setSelection(
53
53
  new TextSelection(
54
- tr.doc.resolve(view.state.tr.selection.$to.after() + 1)
55
- )
56
- )
54
+ tr.doc.resolve(view.state.tr.selection.$to.after() + 1),
55
+ ),
56
+ ),
57
57
  );
58
58
 
59
59
  return true;
@@ -12,7 +12,7 @@ export class PlaceholderPlugin {
12
12
  placeholders: Record<
13
13
  string | "default" | "emptyDocument",
14
14
  string | undefined
15
- >
15
+ >,
16
16
  ) {
17
17
  this.plugin = new Plugin({
18
18
  key: PLUGIN_KEY,
@@ -51,8 +51,8 @@ export class PlaceholderPlugin {
51
51
 
52
52
  styleSheet.insertRule(
53
53
  `${getSelector(blockTypeSelector)} { content: ${JSON.stringify(
54
- placeholder
55
- )}; }`
54
+ placeholder,
55
+ )}; }`,
56
56
  );
57
57
  }
58
58
 
@@ -62,21 +62,21 @@ export class PlaceholderPlugin {
62
62
  // placeholder for when there's only one empty block
63
63
  styleSheet.insertRule(
64
64
  `${getSelector(onlyBlockSelector)} { content: ${JSON.stringify(
65
- emptyPlaceholder
66
- )}; }`
65
+ emptyPlaceholder,
66
+ )}; }`,
67
67
  );
68
68
 
69
69
  // placeholder for default blocks, only when the cursor is in the block (mustBeFocused)
70
70
  styleSheet.insertRule(
71
71
  `${getSelector(mustBeFocusedSelector)} { content: ${JSON.stringify(
72
- defaultPlaceholder
73
- )}; }`
72
+ defaultPlaceholder,
73
+ )}; }`,
74
74
  );
75
75
  } catch (e) {
76
76
  // eslint-disable-next-line no-console
77
77
  console.warn(
78
78
  `Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)`,
79
- e
79
+ e,
80
80
  );
81
81
  }
82
82
 
@@ -115,7 +115,7 @@ export class PlaceholderPlugin {
115
115
  decs.push(
116
116
  Decoration.node(2, 4, {
117
117
  "data-is-only-empty-block": "true",
118
- })
118
+ }),
119
119
  );
120
120
  }
121
121
 
@@ -128,7 +128,7 @@ export class PlaceholderPlugin {
128
128
  decs.push(
129
129
  Decoration.node(before, before + node.nodeSize, {
130
130
  "data-is-empty-and-focused": "true",
131
- })
131
+ }),
132
132
  );
133
133
  }
134
134
 
@@ -37,7 +37,7 @@ export class PreviousBlockTypePlugin {
37
37
  // for one DOM-render the decorations have been applied
38
38
  timeout = setTimeout(() => {
39
39
  view.dispatch(
40
- view.state.tr.setMeta(PLUGIN_KEY, { clearUpdate: true })
40
+ view.state.tr.setMeta(PLUGIN_KEY, { clearUpdate: true }),
41
41
  );
42
42
  }, 0);
43
43
  }
@@ -93,7 +93,7 @@ export class PreviousBlockTypePlugin {
93
93
 
94
94
  const oldNodes = findChildren(oldState.doc, (node) => node.attrs.id);
95
95
  const oldNodesById = new Map(
96
- oldNodes.map((node) => [node.node.attrs.id, node])
96
+ oldNodes.map((node) => [node.node.attrs.id, node]),
97
97
  );
98
98
  const newNodes = findChildren(newState.doc, (node) => node.attrs.id);
99
99
 
@@ -1,3 +1,3 @@
1
1
  ### @blocknote/core/src/extensions
2
2
 
3
- All extra extensions for TipTap / Prosemirror needed to implement the Prosemirror UX and editor behavior.
3
+ All extra extensions for TipTap / Prosemirror needed to implement the Prosemirror UX and editor behavior.
@@ -77,7 +77,7 @@ export class MultipleNodeSelection extends Selection {
77
77
 
78
78
  return new MultipleNodeSelection(
79
79
  doc.resolve(fromResult.pos),
80
- doc.resolve(toResult.pos)
80
+ doc.resolve(toResult.pos),
81
81
  );
82
82
  }
83
83
 
@@ -24,7 +24,7 @@ import { dragStart, unsetDragImage } from "./dragging.js";
24
24
  export type SideMenuState<
25
25
  BSchema extends BlockSchema,
26
26
  I extends InlineContentSchema,
27
- S extends StyleSchema
27
+ S extends StyleSchema,
28
28
  > = UiElementPosition & {
29
29
  // The block that the side menu is attached to.
30
30
  block: Block<BSchema, I, S>;
@@ -36,12 +36,12 @@ function getBlockFromCoords(
36
36
  view: EditorView,
37
37
  coords: { left: number; top: number },
38
38
  sideMenuDetection: "viewport" | "editor",
39
- adjustForColumns = true
39
+ adjustForColumns = true,
40
40
  ) {
41
41
  const elements = view.root.elementsFromPoint(
42
42
  // bit hacky - offset x position to right to account for the width of sidemenu itself
43
43
  coords.left + (sideMenuDetection === "editor" ? 50 : 0),
44
- coords.top
44
+ coords.top,
45
45
  );
46
46
 
47
47
  for (const element of elements) {
@@ -59,7 +59,7 @@ function getBlockFromCoords(
59
59
  top: coords.top,
60
60
  },
61
61
  sideMenuDetection,
62
- false
62
+ false,
63
63
  );
64
64
  }
65
65
  }
@@ -74,7 +74,7 @@ function getBlockFromMousePos(
74
74
  y: number;
75
75
  },
76
76
  view: EditorView,
77
- sideMenuDetection: "viewport" | "editor"
77
+ sideMenuDetection: "viewport" | "editor",
78
78
  ): { node: HTMLElement; id: string } | undefined {
79
79
  // Editor itself may have padding or other styling which affects
80
80
  // size/position, so we get the boundingRect of the first child (i.e. the
@@ -137,7 +137,7 @@ function getBlockFromMousePos(
137
137
  export class SideMenuView<
138
138
  BSchema extends BlockSchema,
139
139
  I extends InlineContentSchema,
140
- S extends StyleSchema
140
+ S extends StyleSchema,
141
141
  > implements PluginView
142
142
  {
143
143
  public state?: SideMenuState<BSchema, I, S>;
@@ -155,7 +155,7 @@ export class SideMenuView<
155
155
  private readonly editor: BlockNoteEditor<BSchema, I, S>,
156
156
  private readonly sideMenuDetection: "viewport" | "editor",
157
157
  private readonly pmView: EditorView,
158
- emitUpdate: (state: SideMenuState<BSchema, I, S>) => void
158
+ emitUpdate: (state: SideMenuState<BSchema, I, S>) => void,
159
159
  ) {
160
160
  this.emitUpdate = () => {
161
161
  if (!this.state) {
@@ -167,21 +167,21 @@ export class SideMenuView<
167
167
 
168
168
  this.pmView.root.addEventListener(
169
169
  "dragstart",
170
- this.onDragStart as EventListener
170
+ this.onDragStart as EventListener,
171
171
  );
172
172
  this.pmView.root.addEventListener(
173
173
  "dragover",
174
- this.onDragOver as EventListener
174
+ this.onDragOver as EventListener,
175
175
  );
176
176
  this.pmView.root.addEventListener(
177
177
  "drop",
178
178
  this.onDrop as EventListener,
179
- true
179
+ true,
180
180
  );
181
181
  this.pmView.root.addEventListener(
182
182
  "dragend",
183
183
  this.onDragEnd as EventListener,
184
- true
184
+ true,
185
185
  );
186
186
  initializeESMDependencies();
187
187
 
@@ -189,14 +189,14 @@ export class SideMenuView<
189
189
  this.pmView.root.addEventListener(
190
190
  "mousemove",
191
191
  this.onMouseMove as EventListener,
192
- true
192
+ true,
193
193
  );
194
194
 
195
195
  // Hides and unfreezes the menu whenever the user presses a key.
196
196
  this.pmView.root.addEventListener(
197
197
  "keydown",
198
198
  this.onKeyDown as EventListener,
199
- true
199
+ true,
200
200
  );
201
201
 
202
202
  // Setting capture=true ensures that any parent container of the editor that
@@ -218,7 +218,7 @@ export class SideMenuView<
218
218
  const block = getBlockFromMousePos(
219
219
  this.mousePos,
220
220
  this.pmView,
221
- this.sideMenuDetection
221
+ this.sideMenuDetection,
222
222
  );
223
223
 
224
224
  // Closes the menu if the mouse cursor is beyond the editor vertically.
@@ -270,10 +270,10 @@ export class SideMenuView<
270
270
  ).getBoundingClientRect().x,
271
271
  blockContentBoundingBox.y,
272
272
  blockContentBoundingBox.width,
273
- blockContentBoundingBox.height
273
+ blockContentBoundingBox.height,
274
274
  ),
275
275
  block: this.editor.getBlock(
276
- this.hoveredBlock!.getAttribute("data-id")!
276
+ this.hoveredBlock!.getAttribute("data-id")!,
277
277
  )!,
278
278
  });
279
279
  }
@@ -312,9 +312,9 @@ export class SideMenuView<
312
312
  this.pmView.state.tr.setSelection(
313
313
  TextSelection.create(
314
314
  this.pmView.state.tr.doc,
315
- this.pmView.state.tr.selection.to
316
- )
317
- )
315
+ this.pmView.state.tr.selection.to,
316
+ ),
317
+ ),
318
318
  );
319
319
  } else if (this.isDragOrigin && this.pmView.dom !== parentEditorElement) {
320
320
  // Because the editor from which the block originates doesn't get a drop
@@ -330,7 +330,7 @@ export class SideMenuView<
330
330
  // handle the event.
331
331
  setTimeout(
332
332
  () => this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),
333
- 0
333
+ 0,
334
334
  );
335
335
  }
336
336
  }
@@ -535,7 +535,7 @@ export class SideMenuView<
535
535
 
536
536
  evt.clientY = Math.min(
537
537
  Math.max(event.clientY, editorBoundingBox.top),
538
- editorBoundingBox.top + editorBoundingBox.height
538
+ editorBoundingBox.top + editorBoundingBox.height,
539
539
  );
540
540
 
541
541
  evt.dataTransfer = event.dataTransfer;
@@ -573,30 +573,30 @@ export class SideMenuView<
573
573
  this.pmView.root.removeEventListener(
574
574
  "mousemove",
575
575
  this.onMouseMove as EventListener,
576
- true
576
+ true,
577
577
  );
578
578
  this.pmView.root.removeEventListener(
579
579
  "dragstart",
580
- this.onDragStart as EventListener
580
+ this.onDragStart as EventListener,
581
581
  );
582
582
  this.pmView.root.removeEventListener(
583
583
  "dragover",
584
- this.onDragOver as EventListener
584
+ this.onDragOver as EventListener,
585
585
  );
586
586
  this.pmView.root.removeEventListener(
587
587
  "drop",
588
588
  this.onDrop as EventListener,
589
- true
589
+ true,
590
590
  );
591
591
  this.pmView.root.removeEventListener(
592
592
  "dragend",
593
593
  this.onDragEnd as EventListener,
594
- true
594
+ true,
595
595
  );
596
596
  this.pmView.root.removeEventListener(
597
597
  "keydown",
598
598
  this.onKeyDown as EventListener,
599
- true
599
+ true,
600
600
  );
601
601
  this.pmView.root.removeEventListener("scroll", this.onScroll, true);
602
602
  }
@@ -607,14 +607,14 @@ export const sideMenuPluginKey = new PluginKey("SideMenuPlugin");
607
607
  export class SideMenuProsemirrorPlugin<
608
608
  BSchema extends BlockSchema,
609
609
  I extends InlineContentSchema,
610
- S extends StyleSchema
610
+ S extends StyleSchema,
611
611
  > extends EventEmitter<any> {
612
612
  public view: SideMenuView<BSchema, I, S> | undefined;
613
613
  public readonly plugin: Plugin;
614
614
 
615
615
  constructor(
616
616
  private readonly editor: BlockNoteEditor<BSchema, I, S>,
617
- sideMenuDetection: "viewport" | "editor"
617
+ sideMenuDetection: "viewport" | "editor",
618
618
  ) {
619
619
  super();
620
620
  this.plugin = new Plugin({
@@ -626,7 +626,7 @@ export class SideMenuProsemirrorPlugin<
626
626
  editorView,
627
627
  (state) => {
628
628
  this.emit("update", state);
629
- }
629
+ },
630
630
  );
631
631
  return this.view;
632
632
  },
@@ -645,7 +645,7 @@ export class SideMenuProsemirrorPlugin<
645
645
  dataTransfer: DataTransfer | null;
646
646
  clientY: number;
647
647
  },
648
- block: Block<BSchema, I, S>
648
+ block: Block<BSchema, I, S>,
649
649
  ) => {
650
650
  if (this.view) {
651
651
  this.view.isDragOrigin = true;
@@ -21,7 +21,7 @@ let dragImageElement: Element | undefined;
21
21
  export type SideMenuState<
22
22
  BSchema extends BlockSchema,
23
23
  I extends InlineContentSchema,
24
- S extends StyleSchema
24
+ S extends StyleSchema,
25
25
  > = UiElementPosition & {
26
26
  // The block that the side menu is attached to.
27
27
  block: Block<BSchema, I, S>;
@@ -81,12 +81,12 @@ function setDragImage(view: EditorView, from: number, to = from) {
81
81
  const firstSelectedBlockIndex = getElementIndex(
82
82
  parent,
83
83
  // Expects from position to be just before the first selected block.
84
- view.domAtPos(from + 1).node.parentElement!
84
+ view.domAtPos(from + 1).node.parentElement!,
85
85
  );
86
86
  const lastSelectedBlockIndex = getElementIndex(
87
87
  parent,
88
88
  // Expects to position to be just after the last selected block.
89
- view.domAtPos(to - 1).node.parentElement!
89
+ view.domAtPos(to - 1).node.parentElement!,
90
90
  );
91
91
 
92
92
  for (let i = parent.childElementCount - 1; i >= 0; i--) {
@@ -120,7 +120,7 @@ function setDragImage(view: EditorView, from: number, to = from) {
120
120
  (className) =>
121
121
  className !== "ProseMirror" &&
122
122
  className !== "bn-root" &&
123
- className !== "bn-editor"
123
+ className !== "bn-editor",
124
124
  )
125
125
  .join(" ");
126
126
 
@@ -149,11 +149,11 @@ export function unsetDragImage(rootEl: Document | ShadowRoot) {
149
149
  export function dragStart<
150
150
  BSchema extends BlockSchema,
151
151
  I extends InlineContentSchema,
152
- S extends StyleSchema
152
+ S extends StyleSchema,
153
153
  >(
154
154
  e: { dataTransfer: DataTransfer | null; clientY: number },
155
155
  block: Block<BSchema, I, S>,
156
- editor: BlockNoteEditor<BSchema, I, S>
156
+ editor: BlockNoteEditor<BSchema, I, S>,
157
157
  ) {
158
158
  if (!e.dataTransfer) {
159
159
  return;
@@ -183,12 +183,12 @@ export function dragStart<
183
183
 
184
184
  if (draggedBlockInSelection && multipleBlocksSelected) {
185
185
  view.dispatch(
186
- view.state.tr.setSelection(MultipleNodeSelection.create(doc, from, to))
186
+ view.state.tr.setSelection(MultipleNodeSelection.create(doc, from, to)),
187
187
  );
188
188
  setDragImage(view, from, to);
189
189
  } else {
190
190
  view.dispatch(
191
- view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos))
191
+ view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos)),
192
192
  );
193
193
  setDragImage(view, pos);
194
194
  }