@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
@@ -17,7 +17,7 @@ function addAttributesAndRemoveClasses(element: HTMLElement) {
17
17
  // Removes all BlockNote specific class names.
18
18
  const className =
19
19
  Array.from(element.classList).filter(
20
- (className) => !className.startsWith("bn-")
20
+ (className) => !className.startsWith("bn-"),
21
21
  ) || [];
22
22
 
23
23
  if (className.length > 0) {
@@ -30,12 +30,12 @@ function addAttributesAndRemoveClasses(element: HTMLElement) {
30
30
  export function serializeInlineContentExternalHTML<
31
31
  BSchema extends BlockSchema,
32
32
  I extends InlineContentSchema,
33
- S extends StyleSchema
33
+ S extends StyleSchema,
34
34
  >(
35
35
  editor: BlockNoteEditor<any, I, S>,
36
36
  blockContent: PartialBlock<BSchema, I, S>["content"],
37
37
  serializer: DOMSerializer,
38
- options?: { document?: Document }
38
+ options?: { document?: Document },
39
39
  ) {
40
40
  let nodes: any;
41
41
 
@@ -72,7 +72,7 @@ export function serializeInlineContentExternalHTML<
72
72
  function serializeBlock<
73
73
  BSchema extends BlockSchema,
74
74
  I extends InlineContentSchema,
75
- S extends StyleSchema
75
+ S extends StyleSchema,
76
76
  >(
77
77
  fragment: DocumentFragment,
78
78
  editor: BlockNoteEditor<BSchema, I, S>,
@@ -80,7 +80,7 @@ function serializeBlock<
80
80
  serializer: DOMSerializer,
81
81
  orderedListItemBlockTypes: Set<string>,
82
82
  unorderedListItemBlockTypes: Set<string>,
83
- options?: { document?: Document }
83
+ options?: { document?: Document },
84
84
  ) {
85
85
  const doc = options?.document ?? document;
86
86
  const BC_NODE = editor.pmSchema.nodes["blockContainer"];
@@ -90,7 +90,7 @@ function serializeBlock<
90
90
  if (!block.props) {
91
91
  props = {};
92
92
  for (const [name, spec] of Object.entries(
93
- editor.schema.blockSchema[block.type as any].propSchema
93
+ editor.schema.blockSchema[block.type as any].propSchema,
94
94
  )) {
95
95
  if (spec.default !== undefined) {
96
96
  (props as any)[name] = spec.default;
@@ -102,7 +102,7 @@ function serializeBlock<
102
102
  BC_NODE.create({
103
103
  id: block.id,
104
104
  ...props,
105
- })
105
+ }),
106
106
  ) as {
107
107
  dom: HTMLElement;
108
108
  contentDOM?: HTMLElement;
@@ -130,7 +130,7 @@ function serializeBlock<
130
130
  attr.name !== "data-node-type" &&
131
131
  attr.name !== "data-id" &&
132
132
  attr.name !== "data-index" &&
133
- attr.name !== "data-editable"
133
+ attr.name !== "data-editable",
134
134
  );
135
135
 
136
136
  // ret.dom = ret.dom.firstChild! as any;
@@ -149,7 +149,7 @@ function serializeBlock<
149
149
  editor,
150
150
  block.content as any, // TODO
151
151
  serializer,
152
- options
152
+ options,
153
153
  );
154
154
 
155
155
  ret.contentDOM.appendChild(ic);
@@ -187,7 +187,7 @@ function serializeBlock<
187
187
  serializer,
188
188
  orderedListItemBlockTypes,
189
189
  unorderedListItemBlockTypes,
190
- options
190
+ options,
191
191
  );
192
192
  if (
193
193
  fragment.lastChild?.nodeName === "UL" ||
@@ -215,7 +215,7 @@ function serializeBlock<
215
215
  const serializeBlocksToFragment = <
216
216
  BSchema extends BlockSchema,
217
217
  I extends InlineContentSchema,
218
- S extends StyleSchema
218
+ S extends StyleSchema,
219
219
  >(
220
220
  fragment: DocumentFragment,
221
221
  editor: BlockNoteEditor<BSchema, I, S>,
@@ -223,7 +223,7 @@ const serializeBlocksToFragment = <
223
223
  serializer: DOMSerializer,
224
224
  orderedListItemBlockTypes: Set<string>,
225
225
  unorderedListItemBlockTypes: Set<string>,
226
- options?: { document?: Document }
226
+ options?: { document?: Document },
227
227
  ) => {
228
228
  for (const block of blocks) {
229
229
  serializeBlock(
@@ -233,7 +233,7 @@ const serializeBlocksToFragment = <
233
233
  serializer,
234
234
  orderedListItemBlockTypes,
235
235
  unorderedListItemBlockTypes,
236
- options
236
+ options,
237
237
  );
238
238
  }
239
239
  };
@@ -241,14 +241,14 @@ const serializeBlocksToFragment = <
241
241
  export const serializeBlocksExternalHTML = <
242
242
  BSchema extends BlockSchema,
243
243
  I extends InlineContentSchema,
244
- S extends StyleSchema
244
+ S extends StyleSchema,
245
245
  >(
246
246
  editor: BlockNoteEditor<BSchema, I, S>,
247
247
  blocks: PartialBlock<BSchema, I, S>[],
248
248
  serializer: DOMSerializer,
249
249
  orderedListItemBlockTypes: Set<string>,
250
250
  unorderedListItemBlockTypes: Set<string>,
251
- options?: { document?: Document }
251
+ options?: { document?: Document },
252
252
  ) => {
253
253
  const doc = options?.document ?? document;
254
254
  const fragment = doc.createDocumentFragment();
@@ -260,7 +260,7 @@ export const serializeBlocksExternalHTML = <
260
260
  serializer,
261
261
  orderedListItemBlockTypes,
262
262
  unorderedListItemBlockTypes,
263
- options
263
+ options,
264
264
  );
265
265
  return fragment;
266
266
  };
@@ -16,13 +16,13 @@ import {
16
16
  export function serializeInlineContentInternalHTML<
17
17
  BSchema extends BlockSchema,
18
18
  I extends InlineContentSchema,
19
- S extends StyleSchema
19
+ S extends StyleSchema,
20
20
  >(
21
21
  editor: BlockNoteEditor<any, I, S>,
22
22
  blockContent: PartialBlock<BSchema, I, S>["content"],
23
23
  serializer: DOMSerializer,
24
24
  blockType?: string,
25
- options?: { document?: Document }
25
+ options?: { document?: Document },
26
26
  ) {
27
27
  let nodes: any;
28
28
 
@@ -50,13 +50,13 @@ export function serializeInlineContentInternalHTML<
50
50
  function serializeBlock<
51
51
  BSchema extends BlockSchema,
52
52
  I extends InlineContentSchema,
53
- S extends StyleSchema
53
+ S extends StyleSchema,
54
54
  >(
55
55
  editor: BlockNoteEditor<BSchema, I, S>,
56
56
  block: PartialBlock<BSchema, I, S>,
57
57
  serializer: DOMSerializer,
58
58
  listIndex: number,
59
- options?: { document?: Document }
59
+ options?: { document?: Document },
60
60
  ) {
61
61
  const BC_NODE = editor.pmSchema.nodes["blockContainer"];
62
62
 
@@ -65,7 +65,7 @@ function serializeBlock<
65
65
  if (!block.props) {
66
66
  props = {};
67
67
  for (const [name, spec] of Object.entries(
68
- editor.schema.blockSchema[block.type as any].propSchema
68
+ editor.schema.blockSchema[block.type as any].propSchema,
69
69
  )) {
70
70
  if (spec.default !== undefined) {
71
71
  (props as any)[name] = spec.default;
@@ -92,7 +92,7 @@ function serializeBlock<
92
92
  block.content as any, // TODO
93
93
  serializer,
94
94
  block.type,
95
- options
95
+ options,
96
96
  );
97
97
  ret.contentDOM.appendChild(ic);
98
98
  }
@@ -105,7 +105,7 @@ function serializeBlock<
105
105
  editor,
106
106
  block.children,
107
107
  serializer,
108
- options
108
+ options,
109
109
  );
110
110
 
111
111
  ret.contentDOM?.append(fragment);
@@ -118,7 +118,7 @@ function serializeBlock<
118
118
  BC_NODE.create({
119
119
  id: block.id,
120
120
  ...props,
121
- })
121
+ }),
122
122
  ) as {
123
123
  dom: HTMLElement;
124
124
  contentDOM?: HTMLElement;
@@ -128,7 +128,7 @@ function serializeBlock<
128
128
 
129
129
  if (block.children && block.children.length > 0) {
130
130
  bc.contentDOM?.appendChild(
131
- serializeBlocksInternalHTML(editor, block.children, serializer, options)
131
+ serializeBlocksInternalHTML(editor, block.children, serializer, options),
132
132
  );
133
133
  }
134
134
  return bc.dom;
@@ -137,12 +137,12 @@ function serializeBlock<
137
137
  function serializeBlocks<
138
138
  BSchema extends BlockSchema,
139
139
  I extends InlineContentSchema,
140
- S extends StyleSchema
140
+ S extends StyleSchema,
141
141
  >(
142
142
  editor: BlockNoteEditor<BSchema, I, S>,
143
143
  blocks: PartialBlock<BSchema, I, S>[],
144
144
  serializer: DOMSerializer,
145
- options?: { document?: Document }
145
+ options?: { document?: Document },
146
146
  ) {
147
147
  const doc = options?.document ?? document;
148
148
  const fragment = doc.createDocumentFragment();
@@ -159,7 +159,7 @@ function serializeBlocks<
159
159
  block,
160
160
  serializer,
161
161
  listIndex,
162
- options
162
+ options,
163
163
  );
164
164
  fragment.appendChild(blockDOM);
165
165
  }
@@ -170,12 +170,12 @@ function serializeBlocks<
170
170
  export const serializeBlocksInternalHTML = <
171
171
  BSchema extends BlockSchema,
172
172
  I extends InlineContentSchema,
173
- S extends StyleSchema
173
+ S extends StyleSchema,
174
174
  >(
175
175
  editor: BlockNoteEditor<BSchema, I, S>,
176
176
  blocks: PartialBlock<BSchema, I, S>[],
177
177
  serializer: DOMSerializer,
178
- options?: { document?: Document }
178
+ options?: { document?: Document },
179
179
  ) => {
180
180
  const BG_NODE = editor.pmSchema.nodes["blockGroup"];
181
181
 
@@ -21,7 +21,7 @@ export function cleanHTMLToMarkdown(cleanHTMLString: string) {
21
21
 
22
22
  if (!deps) {
23
23
  throw new Error(
24
- "cleanHTMLToMarkdown requires ESM dependencies to be initialized"
24
+ "cleanHTMLToMarkdown requires ESM dependencies to be initialized",
25
25
  );
26
26
  }
27
27
 
@@ -43,12 +43,12 @@ export function cleanHTMLToMarkdown(cleanHTMLString: string) {
43
43
  export async function blocksToMarkdown<
44
44
  BSchema extends BlockSchema,
45
45
  I extends InlineContentSchema,
46
- S extends StyleSchema
46
+ S extends StyleSchema,
47
47
  >(
48
48
  blocks: PartialBlock<BSchema, I, S>[],
49
49
  schema: Schema,
50
50
  editor: BlockNoteEditor<BSchema, I, S>,
51
- options: { document?: Document }
51
+ options: { document?: Document },
52
52
  ): Promise<string> {
53
53
  await initializeESMDependencies();
54
54
  const exporter = createExternalHTMLExporter(schema, editor);
@@ -11,7 +11,7 @@ export function addSpacesToCheckboxes() {
11
11
 
12
12
  if (!deps) {
13
13
  throw new Error(
14
- "addSpacesToCheckboxes requires ESM dependencies to be initialized"
14
+ "addSpacesToCheckboxes requires ESM dependencies to be initialized",
15
15
  );
16
16
  }
17
17
 
@@ -38,8 +38,8 @@ export function addSpacesToCheckboxes() {
38
38
  0,
39
39
  0,
40
40
  deps.hastUtilFromDom.fromDom(
41
- document.createTextNode(" ")
42
- ) as HASTElement
41
+ document.createTextNode(" "),
42
+ ) as HASTElement,
43
43
  );
44
44
  } else {
45
45
  helper(child as HASTParent);
@@ -101,7 +101,7 @@ export function getNearestBlockPos(doc: Node, pos: number) {
101
101
 
102
102
  const resolvedPos = doc.resolve(
103
103
  allBlockContainerPositions.find((position) => position >= pos) ||
104
- allBlockContainerPositions[allBlockContainerPositions.length - 1]
104
+ allBlockContainerPositions[allBlockContainerPositions.length - 1],
105
105
  );
106
106
  return {
107
107
  posBeforeNode: resolvedPos.pos,
@@ -122,11 +122,11 @@ export function getNearestBlockPos(doc: Node, pos: number) {
122
122
  */
123
123
  export function getBlockInfoWithManualOffset(
124
124
  node: Node,
125
- bnBlockBeforePosOffset: number
125
+ bnBlockBeforePosOffset: number,
126
126
  ): BlockInfo {
127
127
  if (!node.type.isInGroup("bnBlock")) {
128
128
  throw new Error(
129
- `Attempted to get bnBlock node at position but found node of different type ${node.type}`
129
+ `Attempted to get bnBlock node at position but found node of different type ${node.type}`,
130
130
  );
131
131
  }
132
132
 
@@ -171,7 +171,7 @@ export function getBlockInfoWithManualOffset(
171
171
 
172
172
  if (!blockContent) {
173
173
  throw new Error(
174
- `blockContainer node does not contain a blockContent node in its children: ${bnBlockNode}`
174
+ `blockContainer node does not contain a blockContent node in its children: ${bnBlockNode}`,
175
175
  );
176
176
  }
177
177
 
@@ -185,7 +185,7 @@ export function getBlockInfoWithManualOffset(
185
185
  } else {
186
186
  if (!bnBlock.node.type.isInGroup("childContainer")) {
187
187
  throw new Error(
188
- `bnBlock node is not in the childContainer group: ${bnBlock.node}`
188
+ `bnBlock node is not in the childContainer group: ${bnBlock.node}`,
189
189
  );
190
190
  }
191
191
 
@@ -222,7 +222,7 @@ export function getBlockInfo(posInfo: { posBeforeNode: number; node: Node }) {
222
222
  export function getBlockInfoFromResolvedPos(resolvedPos: ResolvedPos) {
223
223
  if (!resolvedPos.nodeAfter) {
224
224
  throw new Error(
225
- `Attempted to get blockContainer node at position ${resolvedPos.pos} but a node at this position does not exist`
225
+ `Attempted to get blockContainer node at position ${resolvedPos.pos} but a node at this position does not exist`,
226
226
  );
227
227
  }
228
228
  return getBlockInfoWithManualOffset(resolvedPos.nodeAfter, resolvedPos.pos);
@@ -29,7 +29,7 @@ function styledTextToNodes<T extends StyleSchema>(
29
29
  styledText: StyledText<T>,
30
30
  schema: Schema,
31
31
  styleSchema: T,
32
- blockType?: string
32
+ blockType?: string,
33
33
  ): Node[] {
34
34
  const marks: Mark[] = [];
35
35
 
@@ -79,7 +79,7 @@ function styledTextToNodes<T extends StyleSchema>(
79
79
  function linkToNodes(
80
80
  link: PartialLink<StyleSchema>,
81
81
  schema: Schema,
82
- styleSchema: StyleSchema
82
+ styleSchema: StyleSchema,
83
83
  ): Node[] {
84
84
  const linkMark = schema.marks.link.create({
85
85
  href: link.href,
@@ -95,7 +95,7 @@ function linkToNodes(
95
95
  return node;
96
96
  }
97
97
  throw new Error("unexpected node type");
98
- }
98
+ },
99
99
  );
100
100
  }
101
101
 
@@ -107,7 +107,7 @@ function styledTextArrayToNodes<S extends StyleSchema>(
107
107
  content: string | StyledText<S>[],
108
108
  schema: Schema,
109
109
  styleSchema: S,
110
- blockType?: string
110
+ blockType?: string,
111
111
  ): Node[] {
112
112
  const nodes: Node[] = [];
113
113
 
@@ -117,15 +117,15 @@ function styledTextArrayToNodes<S extends StyleSchema>(
117
117
  { type: "text", text: content, styles: {} },
118
118
  schema,
119
119
  styleSchema,
120
- blockType
121
- )
120
+ blockType,
121
+ ),
122
122
  );
123
123
  return nodes;
124
124
  }
125
125
 
126
126
  for (const styledText of content) {
127
127
  nodes.push(
128
- ...styledTextToNodes(styledText, schema, styleSchema, blockType)
128
+ ...styledTextToNodes(styledText, schema, styleSchema, blockType),
129
129
  );
130
130
  }
131
131
  return nodes;
@@ -136,29 +136,29 @@ function styledTextArrayToNodes<S extends StyleSchema>(
136
136
  */
137
137
  export function inlineContentToNodes<
138
138
  I extends InlineContentSchema,
139
- S extends StyleSchema
139
+ S extends StyleSchema,
140
140
  >(
141
141
  blockContent: PartialInlineContent<I, S>,
142
142
  schema: Schema,
143
143
  blockType?: string,
144
- styleSchema: S = getStyleSchema(schema)
144
+ styleSchema: S = getStyleSchema(schema),
145
145
  ): Node[] {
146
146
  const nodes: Node[] = [];
147
147
 
148
148
  for (const content of blockContent) {
149
149
  if (typeof content === "string") {
150
150
  nodes.push(
151
- ...styledTextArrayToNodes(content, schema, styleSchema, blockType)
151
+ ...styledTextArrayToNodes(content, schema, styleSchema, blockType),
152
152
  );
153
153
  } else if (isPartialLinkInlineContent(content)) {
154
154
  nodes.push(...linkToNodes(content, schema, styleSchema));
155
155
  } else if (isStyledTextInlineContent(content)) {
156
156
  nodes.push(
157
- ...styledTextArrayToNodes([content], schema, styleSchema, blockType)
157
+ ...styledTextArrayToNodes([content], schema, styleSchema, blockType),
158
158
  );
159
159
  } else {
160
160
  nodes.push(
161
- blockOrInlineContentToContentNode(content, schema, styleSchema)
161
+ blockOrInlineContentToContentNode(content, schema, styleSchema),
162
162
  );
163
163
  }
164
164
  }
@@ -170,11 +170,11 @@ export function inlineContentToNodes<
170
170
  */
171
171
  export function tableContentToNodes<
172
172
  I extends InlineContentSchema,
173
- S extends StyleSchema
173
+ S extends StyleSchema,
174
174
  >(
175
175
  tableContent: PartialTableContent<I, S>,
176
176
  schema: Schema,
177
- styleSchema: StyleSchema = getStyleSchema(schema)
177
+ styleSchema: StyleSchema = getStyleSchema(schema),
178
178
  ): Node[] {
179
179
  const rowNodes: Node[] = [];
180
180
  // Header rows and columns are used to determine the type of the cell
@@ -207,7 +207,7 @@ export function tableContentToNodes<
207
207
  row: rowIndex,
208
208
  col: cellIndex,
209
209
  },
210
- { type: "table", content: tableContent } as any
210
+ { type: "table", content: tableContent } as any,
211
211
  );
212
212
 
213
213
  // Assume the column width is the width of the cell at the absolute cell index
@@ -227,7 +227,7 @@ export function tableContentToNodes<
227
227
  cell.content,
228
228
  schema,
229
229
  "tableParagraph",
230
- styleSchema
230
+ styleSchema,
231
231
  );
232
232
  }
233
233
  const colspan = getColspan(cell);
@@ -244,7 +244,7 @@ export function tableContentToNodes<
244
244
  cell,
245
245
  schema,
246
246
  "tableParagraph",
247
- styleSchema
247
+ styleSchema,
248
248
  );
249
249
  }
250
250
 
@@ -255,7 +255,7 @@ export function tableContentToNodes<
255
255
  ...(isPartialTableCell(cell) ? cell.props : {}),
256
256
  colwidth,
257
257
  },
258
- schema.nodes["tableParagraph"].createChecked(attrs, content)
258
+ schema.nodes["tableParagraph"].createChecked(attrs, content),
259
259
  );
260
260
  columnNodes.push(cellNode);
261
261
  }
@@ -270,7 +270,7 @@ function blockOrInlineContentToContentNode(
270
270
  | PartialBlock<any, any, any>
271
271
  | PartialCustomInlineContentFromConfig<any, any>,
272
272
  schema: Schema,
273
- styleSchema: StyleSchema
273
+ styleSchema: StyleSchema,
274
274
  ) {
275
275
  let contentNode: Node;
276
276
  let type = block.type;
@@ -291,7 +291,7 @@ function blockOrInlineContentToContentNode(
291
291
  [block.content],
292
292
  schema,
293
293
  type,
294
- styleSchema
294
+ styleSchema,
295
295
  );
296
296
  contentNode = schema.nodes[type].createChecked(block.props, nodes);
297
297
  } else if (Array.isArray(block.content)) {
@@ -299,7 +299,7 @@ function blockOrInlineContentToContentNode(
299
299
  block.content,
300
300
  schema,
301
301
  type,
302
- styleSchema
302
+ styleSchema,
303
303
  );
304
304
  contentNode = schema.nodes[type].createChecked(block.props, nodes);
305
305
  } else if (block.content.type === "tableContent") {
@@ -317,7 +317,7 @@ function blockOrInlineContentToContentNode(
317
317
  export function blockToNode(
318
318
  block: PartialBlock<any, any, any>,
319
319
  schema: Schema,
320
- styleSchema: StyleSchema = getStyleSchema(schema)
320
+ styleSchema: StyleSchema = getStyleSchema(schema),
321
321
  ) {
322
322
  let id = block.id;
323
323
 
@@ -343,7 +343,7 @@ export function blockToNode(
343
343
  const contentNode = blockOrInlineContentToContentNode(
344
344
  block,
345
345
  schema,
346
- styleSchema
346
+ styleSchema,
347
347
  );
348
348
 
349
349
  const groupNode =
@@ -356,7 +356,7 @@ export function blockToNode(
356
356
  id: id,
357
357
  ...block.props,
358
358
  },
359
- groupNode ? [contentNode, groupNode] : contentNode
359
+ groupNode ? [contentNode, groupNode] : contentNode,
360
360
  );
361
361
  } else if (schema.nodes[block.type].isInGroup("bnBlock")) {
362
362
  // this is a bnBlock node like Column or ColumnList that directly translates to a prosemirror node
@@ -365,11 +365,11 @@ export function blockToNode(
365
365
  id: id,
366
366
  ...block.props,
367
367
  },
368
- children
368
+ children,
369
369
  );
370
370
  } else {
371
371
  throw new Error(
372
- `block type ${block.type} doesn't match blockContent or bnBlock group`
372
+ `block type ${block.type} doesn't match blockContent or bnBlock group`,
373
373
  );
374
374
  }
375
375
  }
@@ -14,7 +14,7 @@ import { nodeToBlock } from "./nodeToBlock.js";
14
14
  export function fragmentToBlocks<
15
15
  B extends BlockSchema,
16
16
  I extends InlineContentSchema,
17
- S extends StyleSchema
17
+ S extends StyleSchema,
18
18
  >(fragment: Fragment) {
19
19
  // first convert selection to blocknote-style blocks, and then
20
20
  // pass these to the exporter