@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
@@ -13,10 +13,10 @@ import { getPmSchema } from "../../pmUtil.js";
13
13
  export function getBlock<
14
14
  BSchema extends BlockSchema,
15
15
  I extends InlineContentSchema,
16
- S extends StyleSchema
16
+ S extends StyleSchema,
17
17
  >(
18
18
  doc: Node,
19
- blockIdentifier: BlockIdentifier
19
+ blockIdentifier: BlockIdentifier,
20
20
  ): Block<BSchema, I, S> | undefined {
21
21
  const id =
22
22
  typeof blockIdentifier === "string" ? blockIdentifier : blockIdentifier.id;
@@ -33,10 +33,10 @@ export function getBlock<
33
33
  export function getPrevBlock<
34
34
  BSchema extends BlockSchema,
35
35
  I extends InlineContentSchema,
36
- S extends StyleSchema
36
+ S extends StyleSchema,
37
37
  >(
38
38
  doc: Node,
39
- blockIdentifier: BlockIdentifier
39
+ blockIdentifier: BlockIdentifier,
40
40
  ): Block<BSchema, I, S> | undefined {
41
41
  const id =
42
42
  typeof blockIdentifier === "string" ? blockIdentifier : blockIdentifier.id;
@@ -59,10 +59,10 @@ export function getPrevBlock<
59
59
  export function getNextBlock<
60
60
  BSchema extends BlockSchema,
61
61
  I extends InlineContentSchema,
62
- S extends StyleSchema
62
+ S extends StyleSchema,
63
63
  >(
64
64
  doc: Node,
65
- blockIdentifier: BlockIdentifier
65
+ blockIdentifier: BlockIdentifier,
66
66
  ): Block<BSchema, I, S> | undefined {
67
67
  const id =
68
68
  typeof blockIdentifier === "string" ? blockIdentifier : blockIdentifier.id;
@@ -73,7 +73,7 @@ export function getNextBlock<
73
73
  }
74
74
 
75
75
  const $posAfterNode = doc.resolve(
76
- posInfo.posBeforeNode + posInfo.node.nodeSize
76
+ posInfo.posBeforeNode + posInfo.node.nodeSize,
77
77
  );
78
78
  const nodeToConvert = $posAfterNode.nodeAfter;
79
79
  if (!nodeToConvert) {
@@ -86,10 +86,10 @@ export function getNextBlock<
86
86
  export function getParentBlock<
87
87
  BSchema extends BlockSchema,
88
88
  I extends InlineContentSchema,
89
- S extends StyleSchema
89
+ S extends StyleSchema,
90
90
  >(
91
91
  doc: Node,
92
- blockIdentifier: BlockIdentifier
92
+ blockIdentifier: BlockIdentifier,
93
93
  ): Block<BSchema, I, S> | undefined {
94
94
  const id =
95
95
  typeof blockIdentifier === "string" ? blockIdentifier : blockIdentifier.id;
@@ -10,7 +10,7 @@ export function insertContentAt(
10
10
  nodes: Node[],
11
11
  options: {
12
12
  updateSelection: boolean;
13
- } = { updateSelection: true }
13
+ } = { updateSelection: true },
14
14
  ) {
15
15
  // don’t dispatch an empty fragment because this can lead to strange errors
16
16
  // if (content.toString() === "<>") {
@@ -17,7 +17,7 @@ import { getBlockNoteSchema, getPmSchema } from "../../pmUtil.js";
17
17
  export function getSelection<
18
18
  BSchema extends BlockSchema,
19
19
  I extends InlineContentSchema,
20
- S extends StyleSchema
20
+ S extends StyleSchema,
21
21
  >(tr: Transaction): Selection<BSchema, I, S> | undefined {
22
22
  const pmSchema = getPmSchema(tr);
23
23
  // Return undefined if the selection is collapsed or a node is selected.
@@ -26,10 +26,10 @@ export function getSelection<
26
26
  }
27
27
 
28
28
  const $startBlockBeforePos = tr.doc.resolve(
29
- getNearestBlockPos(tr.doc, tr.selection.from).posBeforeNode
29
+ getNearestBlockPos(tr.doc, tr.selection.from).posBeforeNode,
30
30
  );
31
31
  const $endBlockBeforePos = tr.doc.resolve(
32
- getNearestBlockPos(tr.doc, tr.selection.to).posBeforeNode
32
+ getNearestBlockPos(tr.doc, tr.selection.to).posBeforeNode,
33
33
  );
34
34
 
35
35
  // Converts the node at the given index and depth around `$startBlockBeforePos`
@@ -37,14 +37,14 @@ export function getSelection<
37
37
  // at the depth of `$startBlockBeforePos`.
38
38
  const indexToBlock = (
39
39
  index: number,
40
- depth?: number
40
+ depth?: number,
41
41
  ): Block<BSchema, I, S> => {
42
42
  const pos = $startBlockBeforePos.posAtIndex(index, depth);
43
43
  const node = tr.doc.resolve(pos).nodeAfter;
44
44
 
45
45
  if (!node) {
46
46
  throw new Error(
47
- `Error getting selection - node not found at position ${pos}`
47
+ `Error getting selection - node not found at position ${pos}`,
48
48
  );
49
49
  }
50
50
 
@@ -120,7 +120,7 @@ export function getSelection<
120
120
 
121
121
  if (blocks.length === 0) {
122
122
  throw new Error(
123
- `Error getting selection - selection doesn't span any blocks (${tr.selection})`
123
+ `Error getting selection - selection doesn't span any blocks (${tr.selection})`,
124
124
  );
125
125
  }
126
126
 
@@ -132,7 +132,7 @@ export function getSelection<
132
132
  export function setSelection(
133
133
  tr: Transaction,
134
134
  startBlock: BlockIdentifier,
135
- endBlock: BlockIdentifier
135
+ endBlock: BlockIdentifier,
136
136
  ) {
137
137
  const startBlockId =
138
138
  typeof startBlock === "string" ? startBlock : startBlock.id;
@@ -142,7 +142,7 @@ export function setSelection(
142
142
 
143
143
  if (startBlockId === endBlockId) {
144
144
  throw new Error(
145
- `Attempting to set selection with the same anchor and head blocks (id ${startBlockId})`
145
+ `Attempting to set selection with the same anchor and head blocks (id ${startBlockId})`,
146
146
  );
147
147
  }
148
148
  const anchorPosInfo = getNodeById(startBlockId, tr.doc);
@@ -171,12 +171,12 @@ export function setSelection(
171
171
  anchorBlockConfig.content === "none"
172
172
  ) {
173
173
  throw new Error(
174
- `Attempting to set selection anchor in block without content (id ${startBlockId})`
174
+ `Attempting to set selection anchor in block without content (id ${startBlockId})`,
175
175
  );
176
176
  }
177
177
  if (!headBlockInfo.isBlockContainer || headBlockConfig.content === "none") {
178
178
  throw new Error(
179
- `Attempting to set selection anchor in block without content (id ${endBlockId})`
179
+ `Attempting to set selection anchor in block without content (id ${endBlockId})`,
180
180
  );
181
181
  }
182
182
 
@@ -201,7 +201,7 @@ export function setSelection(
201
201
  tableMap.positionAt(
202
202
  tableMap.height - 1,
203
203
  tableMap.width - 1,
204
- headBlockInfo.blockContent.node
204
+ headBlockInfo.blockContent.node,
205
205
  ) +
206
206
  1;
207
207
  const lastCellNodeSize = tr.doc.resolve(lastCellPos).nodeAfter!.nodeSize;
@@ -15,7 +15,7 @@ describe("Test getTextCursorPosition & setTextCursorPosition", () => {
15
15
  });
16
16
 
17
17
  expect(
18
- getEditor().transact((tr) => getTextCursorPosition(tr))
18
+ getEditor().transact((tr) => getTextCursorPosition(tr)),
19
19
  ).toMatchSnapshot();
20
20
  });
21
21
 
@@ -25,7 +25,7 @@ describe("Test getTextCursorPosition & setTextCursorPosition", () => {
25
25
  });
26
26
 
27
27
  expect(
28
- getEditor().transact((tr) => getTextCursorPosition(tr))
28
+ getEditor().transact((tr) => getTextCursorPosition(tr)),
29
29
  ).toMatchSnapshot();
30
30
  });
31
31
 
@@ -35,7 +35,7 @@ describe("Test getTextCursorPosition & setTextCursorPosition", () => {
35
35
  });
36
36
 
37
37
  expect(
38
- getEditor().transact((tr) => getTextCursorPosition(tr))
38
+ getEditor().transact((tr) => getTextCursorPosition(tr)),
39
39
  ).toMatchSnapshot();
40
40
  });
41
41
 
@@ -45,7 +45,7 @@ describe("Test getTextCursorPosition & setTextCursorPosition", () => {
45
45
  });
46
46
 
47
47
  expect(
48
- getEditor().transact((tr) => getTextCursorPosition(tr))
48
+ getEditor().transact((tr) => getTextCursorPosition(tr)),
49
49
  ).toMatchSnapshot();
50
50
  });
51
51
 
@@ -55,7 +55,7 @@ describe("Test getTextCursorPosition & setTextCursorPosition", () => {
55
55
  });
56
56
 
57
57
  expect(
58
- getEditor().transact((tr) => tr.selection.$from.parentOffset) === 0
58
+ getEditor().transact((tr) => tr.selection.$from.parentOffset) === 0,
59
59
  ).toBeTruthy();
60
60
  });
61
61
 
@@ -67,8 +67,8 @@ describe("Test getTextCursorPosition & setTextCursorPosition", () => {
67
67
  expect(
68
68
  getEditor().transact((tr) => tr.selection.$from.parentOffset) ===
69
69
  getEditor().transact(
70
- (tr) => tr.selection.$from.node().firstChild!.nodeSize
71
- )
70
+ (tr) => tr.selection.$from.node().firstChild!.nodeSize,
71
+ ),
72
72
  ).toBeTruthy();
73
73
  });
74
74
  });
@@ -23,7 +23,7 @@ import { getBlockNoteSchema, getPmSchema } from "../../../pmUtil.js";
23
23
  export function getTextCursorPosition<
24
24
  BSchema extends BlockSchema,
25
25
  I extends InlineContentSchema,
26
- S extends StyleSchema
26
+ S extends StyleSchema,
27
27
  >(tr: Transaction): TextCursorPosition<BSchema, I, S> {
28
28
  const { bnBlock } = getBlockInfoFromTransaction(tr);
29
29
  const pmSchema = getPmSchema(tr.doc);
@@ -58,7 +58,7 @@ export function getTextCursorPosition<
58
58
  export function setTextCursorPosition(
59
59
  tr: Transaction,
60
60
  targetBlock: BlockIdentifier,
61
- placement: "start" | "end" = "start"
61
+ placement: "start" | "end" = "start",
62
62
  ) {
63
63
  const id = typeof targetBlock === "string" ? targetBlock : targetBlock.id;
64
64
  const pmSchema = getPmSchema(tr.doc);
@@ -84,11 +84,11 @@ export function setTextCursorPosition(
84
84
  if (contentType === "inline") {
85
85
  if (placement === "start") {
86
86
  tr.setSelection(
87
- TextSelection.create(tr.doc, blockContent.beforePos + 1)
87
+ TextSelection.create(tr.doc, blockContent.beforePos + 1),
88
88
  );
89
89
  } else {
90
90
  tr.setSelection(
91
- TextSelection.create(tr.doc, blockContent.afterPos - 1)
91
+ TextSelection.create(tr.doc, blockContent.afterPos - 1),
92
92
  );
93
93
  }
94
94
  } else if (contentType === "table") {
@@ -97,11 +97,11 @@ export function setTextCursorPosition(
97
97
  // and `tableCell` nodes to get to the `tableParagraph` node we want to
98
98
  // set the selection in.
99
99
  tr.setSelection(
100
- TextSelection.create(tr.doc, blockContent.beforePos + 4)
100
+ TextSelection.create(tr.doc, blockContent.beforePos + 4),
101
101
  );
102
102
  } else {
103
103
  tr.setSelection(
104
- TextSelection.create(tr.doc, blockContent.afterPos - 4)
104
+ TextSelection.create(tr.doc, blockContent.afterPos - 4),
105
105
  );
106
106
  }
107
107
  } else {