@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
@@ -30,7 +30,7 @@ import { getBlockSchema } from "../pmUtil.js";
30
30
  */
31
31
  export function contentNodeToTableContent<
32
32
  I extends InlineContentSchema,
33
- S extends StyleSchema
33
+ S extends StyleSchema,
34
34
  >(contentNode: Node, inlineContentSchema: I, styleSchema: S) {
35
35
  const ret: TableContent<I, S> = {
36
36
  type: "tableContent",
@@ -70,34 +70,37 @@ export function contentNodeToTableContent<
70
70
  // Convert cell content to inline content and merge adjacent styled text nodes
71
71
  const content = cellNode.content.content
72
72
  .map((child) =>
73
- contentNodeToInlineContent(child, inlineContentSchema, styleSchema)
73
+ contentNodeToInlineContent(child, inlineContentSchema, styleSchema),
74
74
  )
75
75
  // The reason that we merge this content is that we allow table cells to contain multiple tableParagraph nodes
76
76
  // So that we can leverage prosemirror-tables native merging
77
77
  // If the schema only allowed a single tableParagraph node, then the merging would not work and cause prosemirror to fit the content into a new cell
78
- .reduce((acc, contentPartial) => {
79
- if (!acc.length) {
80
- return contentPartial;
81
- }
78
+ .reduce(
79
+ (acc, contentPartial) => {
80
+ if (!acc.length) {
81
+ return contentPartial;
82
+ }
82
83
 
83
- const last = acc[acc.length - 1];
84
- const first = contentPartial[0];
84
+ const last = acc[acc.length - 1];
85
+ const first = contentPartial[0];
85
86
 
86
- // Only merge if the last and first content are both styled text nodes and have the same styles
87
- if (
88
- first &&
89
- isStyledTextInlineContent(last) &&
90
- isStyledTextInlineContent(first) &&
91
- JSON.stringify(last.styles) === JSON.stringify(first.styles)
92
- ) {
93
- // Join them together if they have the same styles
94
- last.text += "\n" + first.text;
95
- acc.push(...contentPartial.slice(1));
87
+ // Only merge if the last and first content are both styled text nodes and have the same styles
88
+ if (
89
+ first &&
90
+ isStyledTextInlineContent(last) &&
91
+ isStyledTextInlineContent(first) &&
92
+ JSON.stringify(last.styles) === JSON.stringify(first.styles)
93
+ ) {
94
+ // Join them together if they have the same styles
95
+ last.text += "\n" + first.text;
96
+ acc.push(...contentPartial.slice(1));
97
+ return acc;
98
+ }
99
+ acc.push(...contentPartial);
96
100
  return acc;
97
- }
98
- acc.push(...contentPartial);
99
- return acc;
100
- }, [] as InlineContent<I, S>[]);
101
+ },
102
+ [] as InlineContent<I, S>[],
103
+ );
101
104
 
102
105
  return {
103
106
  type: "tableCell",
@@ -135,7 +138,7 @@ export function contentNodeToTableContent<
135
138
  */
136
139
  export function contentNodeToInlineContent<
137
140
  I extends InlineContentSchema,
138
- S extends StyleSchema
141
+ S extends StyleSchema,
139
142
  >(contentNode: Node, inlineContentSchema: I, styleSchema: S) {
140
143
  const content: InlineContent<any, S>[] = [];
141
144
  let currentContent: InlineContent<any, S> | undefined = undefined;
@@ -182,7 +185,7 @@ export function contentNodeToInlineContent<
182
185
  }
183
186
 
184
187
  content.push(
185
- nodeToCustomInlineContent(node, inlineContentSchema, styleSchema)
188
+ nodeToCustomInlineContent(node, inlineContentSchema, styleSchema),
186
189
  );
187
190
 
188
191
  return;
@@ -259,7 +262,8 @@ export function contentNodeToInlineContent<
259
262
  // Styles are the same.
260
263
  if (
261
264
  JSON.stringify(
262
- currentContent.content[currentContent.content.length - 1].styles
265
+ currentContent.content[currentContent.content.length - 1]
266
+ .styles,
263
267
  ) === JSON.stringify(styles)
264
268
  ) {
265
269
  currentContent.content[currentContent.content.length - 1].text +=
@@ -336,7 +340,7 @@ export function contentNodeToInlineContent<
336
340
 
337
341
  export function nodeToCustomInlineContent<
338
342
  I extends InlineContentSchema,
339
- S extends StyleSchema
343
+ S extends StyleSchema,
340
344
  >(node: Node, inlineContentSchema: I, styleSchema: S): InlineContent<I, S> {
341
345
  if (node.type.name === "text" || node.type.name === "link") {
342
346
  throw new Error("unexpected");
@@ -363,7 +367,7 @@ export function nodeToCustomInlineContent<
363
367
  content = contentNodeToInlineContent(
364
368
  node,
365
369
  inlineContentSchema,
366
- styleSchema
370
+ styleSchema,
367
371
  ) as any; // TODO: is this safe? could we have Links here that are undesired?
368
372
  } else {
369
373
  content = undefined;
@@ -385,14 +389,14 @@ export function nodeToCustomInlineContent<
385
389
  export function nodeToBlock<
386
390
  BSchema extends BlockSchema,
387
391
  I extends InlineContentSchema,
388
- S extends StyleSchema
392
+ S extends StyleSchema,
389
393
  >(
390
394
  node: Node,
391
395
  schema: Schema,
392
396
  blockSchema: BSchema = getBlockSchema(schema) as BSchema,
393
397
  inlineContentSchema: I = getInlineContentSchema(schema) as I,
394
398
  styleSchema: S = getStyleSchema(schema) as S,
395
- blockCache = getBlockCache(schema)
399
+ blockCache = getBlockCache(schema),
396
400
  ): Block<BSchema, I, S> {
397
401
  if (!node.type.isInGroup("bnBlock")) {
398
402
  throw Error("Node should be a bnBlock, but is instead: " + node.type.name);
@@ -445,8 +449,8 @@ export function nodeToBlock<
445
449
  blockSchema,
446
450
  inlineContentSchema,
447
451
  styleSchema,
448
- blockCache
449
- )
452
+ blockCache,
453
+ ),
450
454
  );
451
455
  });
452
456
 
@@ -459,7 +463,7 @@ export function nodeToBlock<
459
463
  content = contentNodeToInlineContent(
460
464
  blockInfo.blockContent.node,
461
465
  inlineContentSchema,
462
- styleSchema
466
+ styleSchema,
463
467
  );
464
468
  } else if (blockConfig.content === "table") {
465
469
  if (!blockInfo.isBlockContainer) {
@@ -468,7 +472,7 @@ export function nodeToBlock<
468
472
  content = contentNodeToTableContent(
469
473
  blockInfo.blockContent.node,
470
474
  inlineContentSchema,
471
- styleSchema
475
+ styleSchema,
472
476
  );
473
477
  } else if (blockConfig.content === "none") {
474
478
  content = undefined;
@@ -27,7 +27,7 @@ describe("Test getBlocksChangedByTransaction", () => {
27
27
  });
28
28
 
29
29
  await expect(blocksChanged).toMatchFileSnapshot(
30
- "__snapshots__/blocks-inserted.json"
30
+ "__snapshots__/blocks-inserted.json",
31
31
  );
32
32
  });
33
33
 
@@ -41,14 +41,14 @@ describe("Test getBlocksChangedByTransaction", () => {
41
41
  },
42
42
  ],
43
43
  "paragraph-0",
44
- "after"
44
+ "after",
45
45
  );
46
46
 
47
47
  return getBlocksChangedByTransaction(tr);
48
48
  });
49
49
 
50
50
  await expect(blocksChanged).toMatchFileSnapshot(
51
- "__snapshots__/blocks-inserted-nested.json"
51
+ "__snapshots__/blocks-inserted-nested.json",
52
52
  );
53
53
  });
54
54
 
@@ -59,7 +59,7 @@ describe("Test getBlocksChangedByTransaction", () => {
59
59
  });
60
60
 
61
61
  await expect(blocksChanged).toMatchFileSnapshot(
62
- "__snapshots__/blocks-deleted.json"
62
+ "__snapshots__/blocks-deleted.json",
63
63
  );
64
64
  });
65
65
 
@@ -70,7 +70,7 @@ describe("Test getBlocksChangedByTransaction", () => {
70
70
  });
71
71
 
72
72
  await expect(blocksChanged).toMatchFileSnapshot(
73
- "__snapshots__/blocks-deleted-nested-deep.json"
73
+ "__snapshots__/blocks-deleted-nested-deep.json",
74
74
  );
75
75
  });
76
76
 
@@ -81,7 +81,7 @@ describe("Test getBlocksChangedByTransaction", () => {
81
81
  });
82
82
 
83
83
  await expect(blocksChanged).toMatchFileSnapshot(
84
- "__snapshots__/blocks-deleted-nested.json"
84
+ "__snapshots__/blocks-deleted-nested.json",
85
85
  );
86
86
  });
87
87
 
@@ -97,7 +97,7 @@ describe("Test getBlocksChangedByTransaction", () => {
97
97
  });
98
98
 
99
99
  await expect(blocksChanged).toMatchFileSnapshot(
100
- "__snapshots__/blocks-updated.json"
100
+ "__snapshots__/blocks-updated.json",
101
101
  );
102
102
  });
103
103
 
@@ -113,7 +113,7 @@ describe("Test getBlocksChangedByTransaction", () => {
113
113
  });
114
114
 
115
115
  await expect(blocksChanged).toMatchFileSnapshot(
116
- "__snapshots__/blocks-updated-nested.json"
116
+ "__snapshots__/blocks-updated-nested.json",
117
117
  );
118
118
  });
119
119
 
@@ -127,7 +127,7 @@ describe("Test getBlocksChangedByTransaction", () => {
127
127
  });
128
128
 
129
129
  await expect(blocksChanged).toMatchFileSnapshot(
130
- "__snapshots__/blocks-updated-nested-deep.json"
130
+ "__snapshots__/blocks-updated-nested-deep.json",
131
131
  );
132
132
  });
133
133
 
@@ -146,7 +146,7 @@ describe("Test getBlocksChangedByTransaction", () => {
146
146
  });
147
147
 
148
148
  await expect(blocksChanged).toMatchFileSnapshot(
149
- "__snapshots__/blocks-updated-nested-multiple.json"
149
+ "__snapshots__/blocks-updated-nested-multiple.json",
150
150
  );
151
151
  });
152
152
 
@@ -167,7 +167,7 @@ describe("Test getBlocksChangedByTransaction", () => {
167
167
  });
168
168
 
169
169
  await expect(blocksChanged).toMatchFileSnapshot(
170
- "__snapshots__/blocks-updated-single.json"
170
+ "__snapshots__/blocks-updated-single.json",
171
171
  );
172
172
  });
173
173
 
@@ -188,7 +188,7 @@ describe("Test getBlocksChangedByTransaction", () => {
188
188
  });
189
189
 
190
190
  await expect(blocksChanged).toMatchFileSnapshot(
191
- "__snapshots__/blocks-updated-multiple.json"
191
+ "__snapshots__/blocks-updated-multiple.json",
192
192
  );
193
193
  });
194
194
 
@@ -197,19 +197,19 @@ describe("Test getBlocksChangedByTransaction", () => {
197
197
  editor.insertBlocks(
198
198
  [{ type: "paragraph", content: "ABC" }],
199
199
  "paragraph-0",
200
- "after"
200
+ "after",
201
201
  );
202
202
  editor.insertBlocks(
203
203
  [{ type: "paragraph", content: "DEF" }],
204
204
  "paragraph-1",
205
- "after"
205
+ "after",
206
206
  );
207
207
 
208
208
  return getBlocksChangedByTransaction(tr);
209
209
  });
210
210
 
211
211
  await expect(blocksChanged).toMatchFileSnapshot(
212
- "__snapshots__/blocks-updated-multiple-insert.json"
212
+ "__snapshots__/blocks-updated-multiple-insert.json",
213
213
  );
214
214
  });
215
215
 
@@ -222,7 +222,7 @@ describe("Test getBlocksChangedByTransaction", () => {
222
222
  });
223
223
 
224
224
  await expect(blocksChanged).toMatchFileSnapshot(
225
- "__snapshots__/blocks-updated-content-inserted.json"
225
+ "__snapshots__/blocks-updated-content-inserted.json",
226
226
  );
227
227
  });
228
228
  });
@@ -22,7 +22,7 @@ import { getPmSchema } from "./pmUtil.js";
22
22
  */
23
23
  export function getNodeById(
24
24
  id: string,
25
- doc: Node
25
+ doc: Node,
26
26
  ): { node: Node; posBeforeNode: number } | undefined {
27
27
  let targetNode: Node | undefined = undefined;
28
28
  let posBeforeNode: number | undefined = undefined;
@@ -98,7 +98,7 @@ export type BlockChangeSource =
98
98
  export type BlocksChanged<
99
99
  BSchema extends BlockSchema = DefaultBlockSchema,
100
100
  ISchema extends InlineContentSchema = DefaultInlineContentSchema,
101
- SSchema extends StyleSchema = DefaultStyleSchema
101
+ SSchema extends StyleSchema = DefaultStyleSchema,
102
102
  > = Array<
103
103
  {
104
104
  /**
@@ -134,10 +134,10 @@ export type BlocksChanged<
134
134
  function areBlocksDifferentExcludingChildren<
135
135
  BSchema extends BlockSchema,
136
136
  ISchema extends InlineContentSchema,
137
- SSchema extends StyleSchema
137
+ SSchema extends StyleSchema,
138
138
  >(
139
139
  block1: Block<BSchema, ISchema, SSchema>,
140
- block2: Block<BSchema, ISchema, SSchema>
140
+ block2: Block<BSchema, ISchema, SSchema>,
141
141
  ): boolean {
142
142
  // TODO use an actual diff algorithm
143
143
  // Compare all properties except children
@@ -158,10 +158,10 @@ function areBlocksDifferentExcludingChildren<
158
158
  export function getBlocksChangedByTransaction<
159
159
  BSchema extends BlockSchema = DefaultBlockSchema,
160
160
  ISchema extends InlineContentSchema = DefaultInlineContentSchema,
161
- SSchema extends StyleSchema = DefaultStyleSchema
161
+ SSchema extends StyleSchema = DefaultStyleSchema,
162
162
  >(
163
163
  transaction: Transaction,
164
- appendedTransactions: Transaction[] = []
164
+ appendedTransactions: Transaction[] = [],
165
165
  ): BlocksChanged<BSchema, ISchema, SSchema> {
166
166
  let source: BlockChangeSource = { type: "local" };
167
167
 
@@ -198,7 +198,7 @@ export function getBlocksChangedByTransaction<
198
198
  return findChildrenInRange(
199
199
  combinedTransaction.before,
200
200
  range.oldRange,
201
- isNodeBlock
201
+ isNodeBlock,
202
202
  );
203
203
  })
204
204
  .map(({ node }) => nodeToBlock(node, pmSchema));
@@ -208,7 +208,7 @@ export function getBlocksChangedByTransaction<
208
208
  return findChildrenInRange(
209
209
  combinedTransaction.doc,
210
210
  range.newRange,
211
- isNodeBlock
211
+ isNodeBlock,
212
212
  );
213
213
  })
214
214
  .map(({ node }) => nodeToBlock(node, pmSchema));
@@ -216,12 +216,12 @@ export function getBlocksChangedByTransaction<
216
216
  const nextBlocks = new Map(
217
217
  nextAffectedBlocks.map((block) => {
218
218
  return [block.id, block];
219
- })
219
+ }),
220
220
  );
221
221
  const prevBlocks = new Map(
222
222
  prevAffectedBlocks.map((block) => {
223
223
  return [block.id, block];
224
- })
224
+ }),
225
225
  );
226
226
 
227
227
  const changes: BlocksChanged<BSchema, ISchema, SSchema> = [];
@@ -11,7 +11,7 @@ import { nestedListsToBlockNoteStructure } from "./util/nestedLists.js";
11
11
  export async function HTMLToBlocks<
12
12
  BSchema extends BlockSchema,
13
13
  I extends InlineContentSchema,
14
- S extends StyleSchema
14
+ S extends StyleSchema,
15
15
  >(html: string, pmSchema: Schema): Promise<Block<BSchema, I, S>[]> {
16
16
  const htmlNode = nestedListsToBlockNoteStructure(html);
17
17
  const parser = DOMParser.fromSchema(pmSchema);
@@ -33,7 +33,7 @@ function liftNestedListsToParent(element: HTMLElement) {
33
33
  const index = getChildIndex(list);
34
34
  const parentListItem = list.parentElement!;
35
35
  const siblingsAfter = Array.from(parentListItem.childNodes).slice(
36
- index + 1
36
+ index + 1,
37
37
  );
38
38
  list.remove();
39
39
  siblingsAfter.forEach((sibling) => {
@@ -110,7 +110,7 @@ function detachedDoc() {
110
110
  }
111
111
 
112
112
  export function nestedListsToBlockNoteStructure(
113
- elementOrHTML: HTMLElement | string
113
+ elementOrHTML: HTMLElement | string,
114
114
  ) {
115
115
  if (typeof elementOrHTML === "string") {
116
116
  const element = detachedDoc().createElement("div");
@@ -70,7 +70,7 @@ export async function markdownToHTML(markdown: string): Promise<string> {
70
70
  export async function markdownToBlocks<
71
71
  BSchema extends BlockSchema,
72
72
  I extends InlineContentSchema,
73
- S extends StyleSchema
73
+ S extends StyleSchema,
74
74
  >(markdown: string, pmSchema: Schema): Promise<Block<BSchema, I, S>[]> {
75
75
  const htmlString = await markdownToHTML(markdown);
76
76
 
package/src/api/pmUtil.ts CHANGED
@@ -16,7 +16,7 @@ export function getPmSchema(trOrNode: Transaction | Node) {
16
16
  function getBlockNoteEditor<
17
17
  BSchema extends BlockSchema,
18
18
  I extends InlineContentSchema,
19
- S extends StyleSchema
19
+ S extends StyleSchema,
20
20
  >(schema: Schema): BlockNoteEditor<BSchema, I, S> {
21
21
  return schema.cached.blockNoteEditor as BlockNoteEditor<BSchema, I, S>;
22
22
  }
@@ -24,7 +24,7 @@ function getBlockNoteEditor<
24
24
  export function getBlockNoteSchema<
25
25
  BSchema extends BlockSchema,
26
26
  I extends InlineContentSchema,
27
- S extends StyleSchema
27
+ S extends StyleSchema,
28
28
  >(schema: Schema): BlockNoteSchema<BSchema, I, S> {
29
29
  return getBlockNoteEditor(schema).schema as unknown as BlockNoteSchema<
30
30
  BSchema,
@@ -34,13 +34,13 @@ export function getBlockNoteSchema<
34
34
  }
35
35
 
36
36
  export function getBlockSchema<BSchema extends BlockSchema>(
37
- schema: Schema
37
+ schema: Schema,
38
38
  ): BSchema {
39
39
  return getBlockNoteSchema(schema).blockSchema as BSchema;
40
40
  }
41
41
 
42
42
  export function getInlineContentSchema<I extends InlineContentSchema>(
43
- schema: Schema
43
+ schema: Schema,
44
44
  ): I {
45
45
  return getBlockNoteSchema(schema).inlineContentSchema as I;
46
46
  }
@@ -23,7 +23,7 @@ describe("PositionStorage with local editor", () => {
23
23
 
24
24
  expect(editor._tiptapEditor.on).toHaveBeenCalledWith(
25
25
  "transaction",
26
- expect.any(Function)
26
+ expect.any(Function),
27
27
  );
28
28
  });
29
29
  });
@@ -59,7 +59,7 @@ describe("PositionStorage with local editor", () => {
59
59
  },
60
60
  ],
61
61
  editor.document[0],
62
- "before"
62
+ "before",
63
63
  );
64
64
 
65
65
  // Start tracking
@@ -98,7 +98,7 @@ describe("PositionStorage with local editor", () => {
98
98
  },
99
99
  ],
100
100
  editor.document[0],
101
- "before"
101
+ "before",
102
102
  );
103
103
  // Start tracking
104
104
  const getPos = trackPosition(editor, 10);
@@ -59,10 +59,10 @@ export function trackPosition(
59
59
  /**
60
60
  * This is the side of the position to track. "left" is the default. "right" would move with the change if the change is in the right direction.
61
61
  */
62
- side: "left" | "right" = "left"
62
+ side: "left" | "right" = "left",
63
63
  ): () => number {
64
64
  const ySyncPluginState = ySyncPluginKey.getState(
65
- editor._tiptapEditor.state
65
+ editor._tiptapEditor.state,
66
66
  ) as {
67
67
  doc: Y.Doc;
68
68
  binding: ProsemirrorBinding;
@@ -90,18 +90,18 @@ export function trackPosition(
90
90
  // Track the position after the position if we are on the right side
91
91
  position + (side === "right" ? 1 : 0),
92
92
  ySyncPluginState.binding.type,
93
- ySyncPluginState.binding.mapping
93
+ ySyncPluginState.binding.mapping,
94
94
  );
95
95
 
96
96
  return () => {
97
97
  const curYSyncPluginState = ySyncPluginKey.getState(
98
- editor._tiptapEditor.state
98
+ editor._tiptapEditor.state,
99
99
  ) as typeof ySyncPluginState;
100
100
  const pos = relativePositionToAbsolutePosition(
101
101
  curYSyncPluginState.doc,
102
102
  curYSyncPluginState.binding.type,
103
103
  relativePosition,
104
- curYSyncPluginState.binding.mapping
104
+ curYSyncPluginState.binding.mapping,
105
105
  );
106
106
 
107
107
  // This can happen if the element is garbage collected
@@ -47,7 +47,7 @@ export const audioBlockConfig = {
47
47
 
48
48
  export const audioRender = (
49
49
  block: BlockFromConfig<typeof audioBlockConfig, any, any>,
50
- editor: BlockNoteEditor<any, any, any>
50
+ editor: BlockNoteEditor<any, any, any>,
51
51
  ) => {
52
52
  const icon = document.createElement("div");
53
53
  icon.innerHTML = FILE_AUDIO_ICON_SVG;
@@ -70,12 +70,12 @@ export const audioRender = (
70
70
  editor,
71
71
  { dom: audio },
72
72
  editor.dictionary.file_blocks.audio.add_button_text,
73
- icon.firstElementChild as HTMLElement
73
+ icon.firstElementChild as HTMLElement,
74
74
  );
75
75
  };
76
76
 
77
77
  export const audioParse = (
78
- element: HTMLElement
78
+ element: HTMLElement,
79
79
  ): Partial<Props<typeof audioBlockConfig.propSchema>> | undefined => {
80
80
  if (element.tagName === "AUDIO") {
81
81
  // Ignore if parent figure has already been parsed.
@@ -104,7 +104,7 @@ export const audioParse = (
104
104
  };
105
105
 
106
106
  export const audioToExternalHTML = (
107
- block: BlockFromConfig<typeof audioBlockConfig, any, any>
107
+ block: BlockFromConfig<typeof audioBlockConfig, any, any>,
108
108
  ) => {
109
109
  if (!block.props.url) {
110
110
  const div = document.createElement("p");
@@ -64,7 +64,7 @@ type CodeBlockConfigOptions = {
64
64
 
65
65
  export const shikiParserSymbol = Symbol.for("blocknote.shikiParser");
66
66
  export const shikiHighlighterPromiseSymbol = Symbol.for(
67
- "blocknote.shikiHighlighterPromise"
67
+ "blocknote.shikiHighlighterPromise",
68
68
  );
69
69
  export const defaultCodeBlockPropSchema = {
70
70
  language: {
@@ -166,7 +166,7 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
166
166
  {
167
167
  ...(this.options.domAttributes?.inlineContent || {}),
168
168
  ...HTMLAttributes,
169
- }
169
+ },
170
170
  );
171
171
 
172
172
  dom.removeChild(contentDOM);
@@ -192,7 +192,7 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
192
192
  ...(this.options.domAttributes?.blockContent || {}),
193
193
  ...HTMLAttributes,
194
194
  },
195
- this.options.domAttributes?.inlineContent || {}
195
+ this.options.domAttributes?.inlineContent || {},
196
196
  );
197
197
  const handleLanguageChange = (event: Event) => {
198
198
  const language = (event.target as HTMLSelectElement).value;
@@ -205,7 +205,7 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
205
205
  };
206
206
 
207
207
  Object.entries(
208
- options.editor.settings.codeBlock.supportedLanguages
208
+ options.editor.settings.codeBlock.supportedLanguages,
209
209
  ).forEach(([id, { name }]) => {
210
210
  const option = document.createElement("option");
211
211
 
@@ -256,7 +256,7 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
256
256
  if (process.env.NODE_ENV === "development" && !hasWarned) {
257
257
  // eslint-disable-next-line no-console
258
258
  console.log(
259
- "For syntax highlighting of code blocks, you must provide a `codeBlock.createHighlighter` function"
259
+ "For syntax highlighting of code blocks, you must provide a `codeBlock.createHighlighter` function",
260
260
  );
261
261
  hasWarned = true;
262
262
  }
@@ -270,12 +270,12 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
270
270
  return globalThisForShiki[shikiHighlighterPromiseSymbol].then(
271
271
  (createdHighlighter) => {
272
272
  highlighter = createdHighlighter;
273
- }
273
+ },
274
274
  );
275
275
  }
276
276
  const language = getLanguageId(
277
277
  options.editor.settings.codeBlock,
278
- parserOptions.language!
278
+ parserOptions.language!,
279
279
  );
280
280
 
281
281
  if (
@@ -331,7 +331,7 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
331
331
  .canReplaceWith(
332
332
  $start.index(-1),
333
333
  $start.indexAfter(-1),
334
- this.type
334
+ this.type,
335
335
  )
336
336
  ) {
337
337
  return null;
@@ -418,7 +418,7 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
418
418
  $from.pos - $from.parentOffset + $from.parent.nodeSize,
419
419
  {
420
420
  type: "paragraph",
421
- }
421
+ },
422
422
  )
423
423
  .run();
424
424
 
@@ -430,16 +430,16 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
430
430
 
431
431
  export const CodeBlock = createBlockSpecFromStronglyTypedTiptapNode(
432
432
  CodeBlockContent,
433
- defaultCodeBlockPropSchema
433
+ defaultCodeBlockPropSchema,
434
434
  );
435
435
 
436
436
  function getLanguageId(
437
437
  options: CodeBlockOptions,
438
- languageName: string
438
+ languageName: string,
439
439
  ): string | undefined {
440
440
  return Object.entries(options.supportedLanguages).find(
441
441
  ([id, { aliases }]) => {
442
442
  return aliases?.includes(languageName) || id === languageName;
443
- }
443
+ },
444
444
  )?.[0];
445
445
  }
@@ -36,7 +36,7 @@ export const fileBlockConfig = {
36
36
 
37
37
  export const fileRender = (
38
38
  block: BlockFromConfig<typeof fileBlockConfig, any, any>,
39
- editor: BlockNoteEditor<any, any, any>
39
+ editor: BlockNoteEditor<any, any, any>,
40
40
  ) => {
41
41
  return createFileBlockWrapper(block, editor);
42
42
  };
@@ -69,7 +69,7 @@ export const fileParse = (element: HTMLElement) => {
69
69
  };
70
70
 
71
71
  export const fileToExternalHTML = (
72
- block: BlockFromConfig<typeof fileBlockConfig, any, any>
72
+ block: BlockFromConfig<typeof fileBlockConfig, any, any>,
73
73
  ) => {
74
74
  if (!block.props.url) {
75
75
  const div = document.createElement("p");
@@ -1,9 +1,9 @@
1
1
  export const parseFigureElement = (
2
2
  figureElement: HTMLElement,
3
- targetTag: string
3
+ targetTag: string,
4
4
  ) => {
5
5
  const targetElement = figureElement.querySelector(
6
- targetTag
6
+ targetTag,
7
7
  ) as HTMLElement | null;
8
8
  if (!targetElement) {
9
9
  return undefined;