@blocknote/core 0.47.0 → 0.47.2

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 (77) hide show
  1. package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +1 -1
  2. package/dist/BlockNoteExtension-C2X7LW-V.js.map +1 -1
  3. package/dist/{BlockNoteSchema-DT4bdXj5.cjs → BlockNoteSchema-CCs_V3lo.cjs} +2 -2
  4. package/dist/{BlockNoteSchema-DT4bdXj5.cjs.map → BlockNoteSchema-CCs_V3lo.cjs.map} +1 -1
  5. package/dist/{BlockNoteSchema-1r-ln0Q0.js → BlockNoteSchema-ooiKsd5B.js} +2 -2
  6. package/dist/{BlockNoteSchema-1r-ln0Q0.js.map → BlockNoteSchema-ooiKsd5B.js.map} +1 -1
  7. package/dist/{TrailingNode-DZag-Nvu.js → TrailingNode-GzE59m_7.js} +588 -416
  8. package/dist/TrailingNode-GzE59m_7.js.map +1 -0
  9. package/dist/TrailingNode-n0WdMPUl.cjs +2 -0
  10. package/dist/TrailingNode-n0WdMPUl.cjs.map +1 -0
  11. package/dist/blocknote.cjs +4 -4
  12. package/dist/blocknote.cjs.map +1 -1
  13. package/dist/blocknote.js +1206 -955
  14. package/dist/blocknote.js.map +1 -1
  15. package/dist/blocks.cjs +1 -1
  16. package/dist/blocks.js +2 -2
  17. package/dist/comments.cjs.map +1 -1
  18. package/dist/comments.js.map +1 -1
  19. package/dist/defaultBlocks-Dg9kQWXm.cjs +6 -0
  20. package/dist/defaultBlocks-Dg9kQWXm.cjs.map +1 -0
  21. package/dist/{defaultBlocks-BSOEW3GR.js → defaultBlocks-ZzGbYgQn.js} +627 -543
  22. package/dist/defaultBlocks-ZzGbYgQn.js.map +1 -0
  23. package/dist/extensions.cjs +1 -1
  24. package/dist/extensions.cjs.map +1 -1
  25. package/dist/extensions.js +33 -54
  26. package/dist/extensions.js.map +1 -1
  27. package/dist/locales.cjs +1 -1
  28. package/dist/locales.cjs.map +1 -1
  29. package/dist/locales.js +25 -24
  30. package/dist/locales.js.map +1 -1
  31. package/dist/style.css +1 -1
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/dist/webpack-stats.json +1 -1
  34. package/package.json +1 -10
  35. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +33 -7
  36. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
  37. package/src/blocks/Heading/block.ts +48 -1
  38. package/src/blocks/ListItem/ToggleListItem/block.ts +51 -1
  39. package/src/blocks/Paragraph/block.ts +1 -1
  40. package/src/blocks/getDetailsContent.ts +77 -0
  41. package/src/comments/threadstore/TipTapThreadStore.ts +5 -5
  42. package/src/comments/threadstore/tiptap/types.ts +131 -0
  43. package/src/editor/Block.css +6 -0
  44. package/src/editor/BlockNoteEditor.ts +9 -14
  45. package/src/editor/managers/ExtensionManager/symbol.ts +0 -1
  46. package/src/editor/managers/SelectionManager.ts +3 -1
  47. package/src/extensions/Collaboration/YCursorPlugin.ts +3 -1
  48. package/src/extensions/DropCursor/DropCursor.ts +262 -25
  49. package/src/extensions/DropCursor/utils.ts +195 -0
  50. package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +191 -0
  51. package/src/extensions/SuggestionMenu/SuggestionMenu.ts +28 -11
  52. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +438 -53
  53. package/src/i18n/locales/fa.ts +4 -21
  54. package/src/i18n/locales/index.ts +1 -1
  55. package/src/i18n/locales/ru.ts +1 -1
  56. package/src/i18n/locales/uz.ts +22 -4
  57. package/src/index.ts +1 -0
  58. package/src/schema/blocks/createSpec.ts +35 -45
  59. package/src/schema/blocks/types.ts +101 -1
  60. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +5 -0
  61. package/types/src/blocks/getDetailsContent.d.ts +19 -0
  62. package/types/src/comments/threadstore/TipTapThreadStore.d.ts +1 -1
  63. package/types/src/comments/threadstore/tiptap/types.d.ts +73 -0
  64. package/types/src/editor/BlockNoteEditor.d.ts +6 -9
  65. package/types/src/extensions/DropCursor/DropCursor.d.ts +42 -5
  66. package/types/src/extensions/DropCursor/utils.d.ts +48 -0
  67. package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +12 -3
  68. package/types/src/extensions/SuggestionMenu/SuggestionMenu.test.d.ts +1 -0
  69. package/types/src/index.d.ts +1 -0
  70. package/types/src/schema/blocks/createSpec.d.ts +3 -3
  71. package/types/src/schema/blocks/types.d.ts +31 -1
  72. package/dist/TrailingNode-DZag-Nvu.js.map +0 -1
  73. package/dist/TrailingNode-tesI8f7N.cjs +0 -2
  74. package/dist/TrailingNode-tesI8f7N.cjs.map +0 -1
  75. package/dist/defaultBlocks-BSOEW3GR.js.map +0 -1
  76. package/dist/defaultBlocks-D049Pbme.cjs +0 -6
  77. package/dist/defaultBlocks-D049Pbme.cjs.map +0 -1
@@ -23,19 +23,37 @@ export const uz: Dictionary = {
23
23
  heading_4: {
24
24
  title: "4-darajali sarlavha",
25
25
  subtext: "Yana kichik bo‘limlar uchun ishlatiladi",
26
- aliases: ["h4", "heading4", "subheading4", "sarlavha4", "kichik_sarlavha4"],
26
+ aliases: [
27
+ "h4",
28
+ "heading4",
29
+ "subheading4",
30
+ "sarlavha4",
31
+ "kichik_sarlavha4",
32
+ ],
27
33
  group: "Kichik sarlavhalar",
28
34
  },
29
35
  heading_5: {
30
36
  title: "5-darajali sarlavha",
31
37
  subtext: "Kichik bo‘lim sarlavhalari uchun",
32
- aliases: ["h5", "heading5", "subheading5", "sarlavha5", "kichik_sarlavha5"],
38
+ aliases: [
39
+ "h5",
40
+ "heading5",
41
+ "subheading5",
42
+ "sarlavha5",
43
+ "kichik_sarlavha5",
44
+ ],
33
45
  group: "Kichik sarlavhalar",
34
46
  },
35
47
  heading_6: {
36
48
  title: "6-darajali sarlavha",
37
49
  subtext: "Eng past darajadagi sarlavha",
38
- aliases: ["h6", "heading6", "subheading6", "sarlavha6", "kichik_sarlavha6"],
50
+ aliases: [
51
+ "h6",
52
+ "heading6",
53
+ "subheading6",
54
+ "sarlavha6",
55
+ "kichik_sarlavha6",
56
+ ],
39
57
  group: "Kichik sarlavhalar",
40
58
  },
41
59
  toggle_heading: {
@@ -418,4 +436,4 @@ export const uz: Dictionary = {
418
436
  generic: {
419
437
  ctrl_shortcut: "Ctrl",
420
438
  },
421
- };
439
+ };
package/src/index.ts CHANGED
@@ -14,6 +14,7 @@ export * from "./editor/BlockNoteExtension.js";
14
14
  export * from "./editor/defaultColors.js";
15
15
  export * from "./editor/selectionTypes.js";
16
16
  export * from "./exporter/index.js";
17
+ export * from "./extensions/index.js";
17
18
  export * from "./extensions-shared/UiElementPosition.js";
18
19
  export * from "./i18n/dictionary.js";
19
20
  export * from "./schema/index.js";
@@ -14,7 +14,9 @@ import {
14
14
  } from "./internal.js";
15
15
  import {
16
16
  BlockConfig,
17
+ BlockConfigOrCreator,
17
18
  BlockImplementation,
19
+ BlockImplementationOrCreator,
18
20
  BlockSpec,
19
21
  LooseBlockSpec,
20
22
  } from "./types.js";
@@ -76,10 +78,15 @@ export function getParseRules<
76
78
  config.content === "inline" || config.content === "none"
77
79
  ? (node, schema) => {
78
80
  if (implementation.parseContent) {
79
- return implementation.parseContent({
81
+ const result = implementation.parseContent({
80
82
  el: node as HTMLElement,
81
83
  schema,
82
84
  });
85
+ // parseContent may return undefined to fall through to
86
+ // the default inline content parsing below.
87
+ if (result !== undefined) {
88
+ return result;
89
+ }
83
90
  }
84
91
 
85
92
  if (config.content === "inline") {
@@ -210,6 +217,8 @@ export function addNodeAndExtensionsToSpec<
210
217
 
211
218
  // See explanation for why `update` is not implemented for NodeViews
212
219
  // https://github.com/TypeCellOS/BlockNote/pull/1904#discussion_r2313461464
220
+ // TODO: in a future version, we might want to implement updates so that
221
+ // vanilla blocks don't always re-render entirely (https://github.com/TypeCellOS/BlockNote/issues/220)
213
222
  return nodeView;
214
223
  };
215
224
  },
@@ -295,18 +304,17 @@ export function createBlockSpec<
295
304
  const TOptions extends Partial<Record<string, any>> | undefined = undefined,
296
305
  >(
297
306
  blockConfigOrCreator: BlockConfig<TName, TProps, TContent>,
298
- blockImplementationOrCreator:
299
- | BlockImplementation<TName, TProps, TContent>
307
+ blockImplementationOrCreator: BlockImplementationOrCreator<
308
+ BlockConfig<TName, TProps, TContent>,
309
+ TOptions
310
+ >,
311
+ extensionsOrCreator?:
312
+ | (ExtensionFactoryInstance | Extension)[]
300
313
  | (TOptions extends undefined
301
- ? () => BlockImplementation<TName, TProps, TContent>
314
+ ? () => (ExtensionFactoryInstance | Extension)[]
302
315
  : (
303
316
  options: Partial<TOptions>,
304
- ) => BlockImplementation<TName, TProps, TContent>),
305
- extensionsOrCreator?:
306
- | ExtensionFactoryInstance[]
307
- | (TOptions extends undefined
308
- ? () => ExtensionFactoryInstance[]
309
- : (options: Partial<TOptions>) => ExtensionFactoryInstance[]),
317
+ ) => (ExtensionFactoryInstance | Extension)[]),
310
318
  ): (options?: Partial<TOptions>) => BlockSpec<TName, TProps, TContent>;
311
319
  export function createBlockSpec<
312
320
  const TName extends string,
@@ -316,30 +324,17 @@ export function createBlockSpec<
316
324
  const TOptions extends Partial<Record<string, any>>,
317
325
  >(
318
326
  blockCreator: (options: Partial<TOptions>) => BlockConf,
319
- blockImplementationOrCreator:
320
- | BlockImplementation<
321
- BlockConf["type"],
322
- BlockConf["propSchema"],
323
- BlockConf["content"]
324
- >
327
+ blockImplementationOrCreator: BlockImplementationOrCreator<
328
+ BlockConf,
329
+ TOptions
330
+ >,
331
+ extensionsOrCreator?:
332
+ | (ExtensionFactoryInstance | Extension)[]
325
333
  | (TOptions extends undefined
326
- ? () => BlockImplementation<
327
- BlockConf["type"],
328
- BlockConf["propSchema"],
329
- BlockConf["content"]
330
- >
334
+ ? () => (ExtensionFactoryInstance | Extension)[]
331
335
  : (
332
336
  options: Partial<TOptions>,
333
- ) => BlockImplementation<
334
- BlockConf["type"],
335
- BlockConf["propSchema"],
336
- BlockConf["content"]
337
- >),
338
- extensionsOrCreator?:
339
- | ExtensionFactoryInstance[]
340
- | (TOptions extends undefined
341
- ? () => ExtensionFactoryInstance[]
342
- : (options: Partial<TOptions>) => ExtensionFactoryInstance[]),
337
+ ) => (ExtensionFactoryInstance | Extension)[]),
343
338
  ): (
344
339
  options?: Partial<TOptions>,
345
340
  ) => BlockSpec<
@@ -353,23 +348,18 @@ export function createBlockSpec<
353
348
  const TContent extends "inline" | "none",
354
349
  const TOptions extends Partial<Record<string, any>> | undefined = undefined,
355
350
  >(
356
- blockConfigOrCreator:
357
- | BlockConfig<TName, TProps, TContent>
358
- | (TOptions extends undefined
359
- ? () => BlockConfig<TName, TProps, TContent>
360
- : (options: Partial<TOptions>) => BlockConfig<TName, TProps, TContent>),
361
- blockImplementationOrCreator:
362
- | BlockImplementation<TName, TProps, TContent>
351
+ blockConfigOrCreator: BlockConfigOrCreator<TName, TProps, TContent, TOptions>,
352
+ blockImplementationOrCreator: BlockImplementationOrCreator<
353
+ BlockConfig<TName, TProps, TContent>,
354
+ TOptions
355
+ >,
356
+ extensionsOrCreator?:
357
+ | (ExtensionFactoryInstance | Extension)[]
363
358
  | (TOptions extends undefined
364
- ? () => BlockImplementation<TName, TProps, TContent>
359
+ ? () => (ExtensionFactoryInstance | Extension)[]
365
360
  : (
366
361
  options: Partial<TOptions>,
367
- ) => BlockImplementation<TName, TProps, TContent>),
368
- extensionsOrCreator?:
369
- | ExtensionFactoryInstance[]
370
- | (TOptions extends undefined
371
- ? () => ExtensionFactoryInstance[]
372
- : (options: Partial<TOptions>) => ExtensionFactoryInstance[]),
362
+ ) => (ExtensionFactoryInstance | Extension)[]),
373
363
  ): (options?: Partial<TOptions>) => BlockSpec<TName, TProps, TContent> {
374
364
  return (options = {} as TOptions) => {
375
365
  const blockConfig =
@@ -86,6 +86,34 @@ export interface BlockConfig<
86
86
  // e.g. tables, alerts (with title & content)
87
87
  }
88
88
 
89
+ /**
90
+ * BlockConfigOrCreator is a union type of BlockConfig and a function that returns a BlockConfig.
91
+ * This is used to create block configs that can be passed to the createBlockSpec function.
92
+ */
93
+ export type BlockConfigOrCreator<
94
+ TName extends string = string,
95
+ TProps extends PropSchema = PropSchema,
96
+ TContent extends "inline" | "none" = "inline" | "none",
97
+ TOptions extends Record<string, any> | undefined =
98
+ | Record<string, any>
99
+ | undefined,
100
+ > =
101
+ | BlockConfig<TName, TProps, TContent>
102
+ | (TOptions extends undefined
103
+ ? () => BlockConfig<TName, TProps, TContent>
104
+ : (options: Partial<TOptions>) => BlockConfig<TName, TProps, TContent>);
105
+
106
+ /**
107
+ * ExtractBlockConfigFromConfigOrCreator is a helper type that extracts the BlockConfig type from a BlockConfigOrCreator.
108
+ */
109
+ export type ExtractBlockConfigFromConfigOrCreator<
110
+ ConfigOrCreator extends
111
+ | BlockConfig<string, PropSchema, "inline" | "none">
112
+ | ((...args: any[]) => BlockConfig<string, PropSchema, "inline" | "none">),
113
+ > = ConfigOrCreator extends (...args: any[]) => infer Config
114
+ ? Config
115
+ : ConfigOrCreator;
116
+
89
117
  // restrict content to "inline" and "none" only
90
118
  export type CustomBlockConfig<
91
119
  T extends string = string,
@@ -104,6 +132,32 @@ export type BlockSpec<
104
132
  extensions?: (Extension | ExtensionFactoryInstance)[];
105
133
  };
106
134
 
135
+ /**
136
+ * BlockSpecOrCreator is a union type of BlockSpec and a function that returns a BlockSpec.
137
+ * This is used to create block specs that can be passed to the createBlockSpec function.
138
+ */
139
+ export type BlockSpecOrCreator<
140
+ T extends string = string,
141
+ PS extends PropSchema = PropSchema,
142
+ C extends "inline" | "none" | "table" = "inline" | "none" | "table",
143
+ TOptions extends Record<string, any> | undefined =
144
+ | Record<string, any>
145
+ | undefined,
146
+ > =
147
+ | BlockSpec<T, PS, C>
148
+ | (TOptions extends undefined
149
+ ? () => BlockSpec<T, PS, C>
150
+ : (options: Partial<TOptions>) => BlockSpec<T, PS, C>);
151
+
152
+ /**
153
+ * ExtractBlockSpecFromSpecOrCreator is a helper type that extracts the BlockSpec type from a BlockSpecOrCreator.
154
+ */
155
+ export type ExtractBlockSpecFromSpecOrCreator<
156
+ SpecOrCreator extends
157
+ | BlockSpec<string, PropSchema, "inline" | "none">
158
+ | ((...args: any[]) => BlockSpec<string, PropSchema, "inline" | "none">),
159
+ > = SpecOrCreator extends (...args: any[]) => infer Spec ? Spec : SpecOrCreator;
160
+
107
161
  /**
108
162
  * This allows de-coupling the types that we display to users versus the types we expose internally.
109
163
  *
@@ -146,6 +200,7 @@ export type LooseBlockSpec<
146
200
  | {
147
201
  dom: HTMLElement | DocumentFragment;
148
202
  contentDOM?: HTMLElement;
203
+ childrenDOM?: HTMLElement;
149
204
  }
150
205
  | undefined;
151
206
 
@@ -203,6 +258,7 @@ export type BlockSpecs = {
203
258
  | {
204
259
  dom: HTMLElement | DocumentFragment;
205
260
  contentDOM?: HTMLElement;
261
+ childrenDOM?: HTMLElement;
206
262
  }
207
263
  | undefined;
208
264
  };
@@ -476,6 +532,7 @@ export type BlockImplementation<
476
532
  | {
477
533
  dom: HTMLElement | DocumentFragment;
478
534
  contentDOM?: HTMLElement;
535
+ childrenDOM?: HTMLElement;
479
536
  }
480
537
  | undefined;
481
538
 
@@ -494,9 +551,52 @@ export type BlockImplementation<
494
551
  * Advanced parsing function that controls how content within the block is parsed.
495
552
  * This is not recommended to use, and is only useful for advanced use cases.
496
553
  */
497
- parseContent?: (options: { el: HTMLElement; schema: Schema }) => Fragment;
554
+ parseContent?: (options: {
555
+ el: HTMLElement;
556
+ schema: Schema;
557
+ }) => Fragment | undefined;
498
558
  };
499
559
 
560
+ /**
561
+ * BlockImplementationOrCreator is a union type of BlockImplementation and a function that returns a BlockImplementation.
562
+ * This is used to create block implementations that can be passed to the createBlockSpec function.
563
+ */
564
+ export type BlockImplementationOrCreator<
565
+ ConfigOrCreator extends BlockConfigOrCreator = BlockConfigOrCreator,
566
+ TOptions extends Record<string, any> | undefined =
567
+ | Record<string, any>
568
+ | undefined,
569
+ Config extends
570
+ ExtractBlockConfigFromConfigOrCreator<ConfigOrCreator> = ExtractBlockConfigFromConfigOrCreator<ConfigOrCreator>,
571
+ > =
572
+ | BlockImplementation<Config["type"], Config["propSchema"], Config["content"]>
573
+ | (TOptions extends undefined
574
+ ? () => BlockImplementation<
575
+ Config["type"],
576
+ Config["propSchema"],
577
+ Config["content"]
578
+ >
579
+ : (
580
+ options: Partial<TOptions>,
581
+ ) => BlockImplementation<
582
+ Config["type"],
583
+ Config["propSchema"],
584
+ Config["content"]
585
+ >);
586
+
587
+ /**
588
+ * ExtractBlockImplementationFromImplementationOrCreator is a helper type that extracts the BlockImplementation type from a BlockImplementationOrCreator.
589
+ */
590
+ export type ExtractBlockImplementationFromImplementationOrCreator<
591
+ ImplementationOrCreator extends
592
+ | BlockImplementation<string, PropSchema, "inline" | "none">
593
+ | ((
594
+ ...args: any[]
595
+ ) => BlockImplementation<string, PropSchema, "inline" | "none">),
596
+ > = ImplementationOrCreator extends (...args: any[]) => infer Implementation
597
+ ? Implementation
598
+ : ImplementationOrCreator;
599
+
500
600
  // restrict content to "inline" and "none" only
501
601
  export type CustomBlockImplementation<
502
602
  T extends string = string,
@@ -11,6 +11,11 @@ export declare const getParentBlockInfo: (doc: Node, beforePos: number) => Block
11
11
  * or undefined if the given block is the first sibling.
12
12
  */
13
13
  export declare const getPrevBlockInfo: (doc: Node, beforePos: number) => BlockInfo | undefined;
14
+ /**
15
+ * Returns the block info from the sibling block after (below) the given block,
16
+ * or undefined if the given block is the last sibling.
17
+ */
18
+ export declare const getNextBlockInfo: (doc: Node, beforePos: number) => BlockInfo | undefined;
14
19
  /**
15
20
  * If a block has children like this:
16
21
  * A
@@ -0,0 +1,19 @@
1
+ import { Fragment, Schema } from "prosemirror-model";
2
+ /**
3
+ * Parses a `<details>` element into a block's inline content + nested children.
4
+ *
5
+ * Given:
6
+ * <details>
7
+ * <summary>inline content here</summary>
8
+ * <p>child block 1</p>
9
+ * <p>child block 2</p>
10
+ * </details>
11
+ *
12
+ * Returns a Fragment shaped like:
13
+ * [inline content, blockGroup<blockContainer<child1>, blockContainer<child2>>]
14
+ *
15
+ * ProseMirror's "fitting" algorithm will place the inline content into the
16
+ * block node, and lift the blockGroup into the parent blockContainer as
17
+ * nested children. This is the same mechanism used by `getListItemContent`.
18
+ */
19
+ export declare function getDetailsContent(details: HTMLElement, schema: Schema, nodeName: string): Fragment;
@@ -1,7 +1,7 @@
1
- import type { TiptapCollabProvider } from "@hocuspocus/provider";
2
1
  import { CommentBody, ThreadData } from "../types.js";
3
2
  import { ThreadStore } from "./ThreadStore.js";
4
3
  import { ThreadStoreAuth } from "./ThreadStoreAuth.js";
4
+ import type { TiptapCollabProvider } from "./tiptap/types.js";
5
5
  /**
6
6
  * The `TiptapThreadStore` integrates with Tiptap's collaboration provider for comment management.
7
7
  * You can pass a `TiptapCollabProvider` to the constructor which takes care of storing the comments.
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Tiptap comment types have moved to a private tiptap package and we don't want to create a dependency on it.
3
+ * We've extracted the types from https://github.com/ueberdosis/hocuspocus/blob/v2.15.3/packages/provider/src/types.ts
4
+ * and added them here.
5
+ */
6
+ export type TCollabThread<Data = any, CommentData = any> = {
7
+ id: string;
8
+ createdAt: number;
9
+ updatedAt: number;
10
+ deletedAt: number | null;
11
+ resolvedAt?: string;
12
+ comments: TCollabComment<CommentData>[];
13
+ deletedComments: TCollabComment<CommentData>[];
14
+ data: Data;
15
+ };
16
+ export type TCollabComment<Data = any> = {
17
+ id: string;
18
+ createdAt: string;
19
+ updatedAt: string;
20
+ deletedAt?: string;
21
+ data: Data;
22
+ content: any;
23
+ };
24
+ export type ThreadType = "archived" | "unarchived";
25
+ export type GetThreadsOptions = {
26
+ /**
27
+ * The types of threads to get
28
+ * @default ['unarchived']
29
+ */
30
+ types?: Array<ThreadType>;
31
+ };
32
+ export type DeleteCommentOptions = {
33
+ /**
34
+ * If `true`, the thread will also be deleted if the deleted comment was the first comment in the thread.
35
+ */
36
+ deleteThread?: boolean;
37
+ /**
38
+ * If `true`, will remove the content of the deleted comment
39
+ */
40
+ deleteContent?: boolean;
41
+ };
42
+ export type DeleteThreadOptions = {
43
+ /**
44
+ * If `true`, will remove the comments on the thread,
45
+ * otherwise will only mark the thread as deleted
46
+ * and keep the comments
47
+ * @default false
48
+ */
49
+ deleteComments?: boolean;
50
+ /**
51
+ * If `true`, will forcefully remove the thread and all comments,
52
+ * otherwise will only mark the thread as deleted
53
+ * and keep the comments
54
+ * @default false
55
+ */
56
+ force?: boolean;
57
+ };
58
+ export type TiptapCollabProvider = {
59
+ getThread<Data, CommentData>(id: string): TCollabThread<Data, CommentData> | null;
60
+ getThreads<Data, CommentData>(options?: GetThreadsOptions): TCollabThread<Data, CommentData>[];
61
+ createThread(data: Omit<TCollabThread, "id" | "createdAt" | "updatedAt" | "deletedAt" | "comments" | "deletedComments">): TCollabThread;
62
+ addComment(threadId: TCollabThread["id"], data: Omit<TCollabComment, "id" | "updatedAt" | "createdAt">): TCollabThread;
63
+ updateComment(threadId: TCollabThread["id"], commentId: TCollabComment["id"], data: Partial<Pick<TCollabComment, "data" | "content">>): TCollabThread;
64
+ deleteComment(threadId: TCollabThread["id"], commentId: TCollabComment["id"], options?: DeleteCommentOptions): TCollabThread;
65
+ getThreadComments(threadId: TCollabThread["id"], includeDeleted?: boolean): TCollabComment[] | null;
66
+ getThreadComment(threadId: TCollabThread["id"], commentId: TCollabComment["id"], includeDeleted?: boolean): TCollabComment | null;
67
+ deleteThread(id: TCollabThread["id"], options?: DeleteThreadOptions): TCollabThread;
68
+ updateThread(id: TCollabThread["id"], data: Partial<Pick<TCollabThread, "data"> & {
69
+ resolvedAt: TCollabThread["resolvedAt"] | null;
70
+ }>): TCollabThread;
71
+ watchThreads(callback: () => void): void;
72
+ unwatchThreads(callback: () => void): void;
73
+ };
@@ -1,9 +1,10 @@
1
1
  import { EditorOptions, FocusPosition, Editor as TiptapEditor } from "@tiptap/core";
2
- import { type Command, type Plugin, type Transaction } from "@tiptap/pm/state";
2
+ import { type Command, type Transaction } from "@tiptap/pm/state";
3
3
  import { Node, Schema } from "prosemirror-model";
4
4
  import type { BlocksChanged } from "../api/getBlocksChangedByTransaction.js";
5
5
  import { Block, BlockNoteSchema, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from "../blocks/index.js";
6
6
  import type { CollaborationOptions } from "../extensions/Collaboration/Collaboration.js";
7
+ import { DropCursorOptions } from "../extensions/index.js";
7
8
  import type { Dictionary } from "../i18n/dictionary.js";
8
9
  import type { BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSpecs, CustomBlockNoteSchema, InlineContentSchema, InlineContentSpecs, PartialInlineContent, Styles, StyleSchema, StyleSpecs } from "../schema/index.js";
9
10
  import "../style.css";
@@ -62,15 +63,11 @@ export interface BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema ext
62
63
  */
63
64
  domAttributes?: Partial<BlockNoteDOMAttributes>;
64
65
  /**
65
- * A replacement indicator to use when dragging and dropping blocks. Uses the [ProseMirror drop cursor](https://github.com/ProseMirror/prosemirror-dropcursor), or a modified version when [Column Blocks](https://www.blocknotejs.org/docs/document-structure#column-blocks) are enabled.
66
- * @remarks `() => Plugin`
66
+ * Options for configuring the drop cursor behavior when dragging and dropping blocks.
67
+ * Allows customization of cursor appearance and drop position computation through hooks.
68
+ * @remarks `DropCursorOptions`
67
69
  */
68
- dropCursor?: (opts: {
69
- editor: BlockNoteEditor<NoInfer<BSchema>, NoInfer<ISchema>, NoInfer<SSchema>>;
70
- color?: string | false;
71
- width?: number;
72
- class?: string;
73
- }) => Plugin;
70
+ dropCursor?: DropCursorOptions;
74
71
  /**
75
72
  * The content that should be in the editor when it's created, represented as an array of {@link PartialBlock} objects.
76
73
  *
@@ -1,5 +1,42 @@
1
- import { BlockNoteEditorOptions } from "../../editor/BlockNoteEditor.js";
2
- export declare const DropCursorExtension: (options: Pick<BlockNoteEditorOptions<any, any, any>, "dropCursor">) => import("../../index.js").ExtensionFactoryInstance<{
3
- readonly key: "dropCursor";
4
- readonly prosemirrorPlugins: readonly [import("prosemirror-state").Plugin<any>];
5
- }>;
1
+ import type { EditorView } from "prosemirror-view";
2
+ import { type DropCursorPosition } from "./utils.js";
3
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
4
+ export declare const DRAG_EXCLUSION_CLASSNAME = "bn-drag-exclude";
5
+ /**
6
+ * Context passed to the computeDropPosition hook.
7
+ */
8
+ export interface ComputeDropPositionContext {
9
+ editor: BlockNoteEditor<any, any, any>;
10
+ event: DragEvent;
11
+ view: EditorView;
12
+ defaultPosition: DropCursorPosition | null;
13
+ }
14
+ /**
15
+ * Hooks for customizing drop cursor behavior.
16
+ */
17
+ export interface DropCursorHooks {
18
+ /**
19
+ * Compute cursor position and orientation.
20
+ * Return null to prevent dropping (no cursor shown).
21
+ */
22
+ computeDropPosition?: (context: ComputeDropPositionContext) => DropCursorPosition | null;
23
+ }
24
+ /**
25
+ * Options for the DropCursor extension.
26
+ */
27
+ export interface DropCursorOptions {
28
+ width?: number;
29
+ color?: string | false;
30
+ exclude?: string;
31
+ hooks?: DropCursorHooks;
32
+ }
33
+ /**
34
+ * Drop cursor visualization based on prosemirror-dropcursor:
35
+ * https://github.com/ProseMirror/prosemirror-dropcursor/blob/master/src/dropcursor.ts
36
+ *
37
+ * Refactored to use BlockNote extension pattern with mount callback and AbortSignal
38
+ * for lifecycle management instead of ProseMirror PluginView.
39
+ */
40
+ export declare const DropCursorExtension: (options: {
41
+ dropCursor?: DropCursorOptions;
42
+ }) => import("../../index.js").ExtensionFactoryInstance<import("../../index.js").Extension<any, string>>;
@@ -0,0 +1,48 @@
1
+ import type { EditorView } from "prosemirror-view";
2
+ /**
3
+ * The orientation of the drop cursor.
4
+ */
5
+ export type DropCursorOrientation = "inline" | "block-horizontal" | "block-vertical-left" | "block-vertical-right";
6
+ /**
7
+ * The position and orientation of the drop cursor.
8
+ */
9
+ export type DropCursorPosition = {
10
+ pos: number;
11
+ orientation: DropCursorOrientation;
12
+ };
13
+ /**
14
+ * Bounding rectangle in viewport coordinates (e.g. from getBoundingClientRect).
15
+ */
16
+ export type Rect = {
17
+ left: number;
18
+ right: number;
19
+ top: number;
20
+ bottom: number;
21
+ };
22
+ /**
23
+ * Returns true if the element or any ancestor has the given CSS class.
24
+ * Used to skip drop cursor for elements marked with the exclusion class (e.g. drag handles).
25
+ */
26
+ export declare function hasExclusionClassname(element: Element | null, exclude: string): boolean;
27
+ /**
28
+ * Computes the viewport rect for a block-level drop cursor (horizontal line between blocks
29
+ * or vertical line on left/right edge). Returns null for inline positions or when no DOM node exists.
30
+ */
31
+ export declare function getBlockDropRect(view: EditorView, cursorPos: DropCursorPosition, width: number, scaleX: number, scaleY: number): Rect | null;
32
+ /**
33
+ * Computes the viewport rect for an inline drop cursor (vertical line within text).
34
+ */
35
+ export declare function getInlineDropRect(view: EditorView, cursorPos: DropCursorPosition, width: number, scaleX: number): Rect;
36
+ /**
37
+ * Applies orientation-specific CSS classes to the drop cursor element so it can be
38
+ * styled correctly (e.g. horizontal vs vertical line, inline vs block).
39
+ */
40
+ export declare function applyOrientationClasses(el: HTMLElement, orientation: DropCursorOrientation): void;
41
+ /**
42
+ * Returns the offset of the parent element for converting viewport coordinates to
43
+ * parent-relative coordinates. Handles document.body and static positioning.
44
+ */
45
+ export declare function getParentOffsets(parent: HTMLElement | null): {
46
+ parentLeft: number;
47
+ parentTop: number;
48
+ };
@@ -1,4 +1,4 @@
1
- import { Plugin } from "prosemirror-state";
1
+ import { Plugin, Transaction } from "prosemirror-state";
2
2
  import { UiElementPosition } from "../../extensions-shared/UiElementPosition.js";
3
3
  export type SuggestionMenuState = UiElementPosition & {
4
4
  query: string;
@@ -12,6 +12,15 @@ type SuggestionPluginState = {
12
12
  decorationId: string;
13
13
  ignoreQueryLength?: boolean;
14
14
  } | undefined;
15
+ export type SuggestionMenuOptions = {
16
+ triggerCharacter: string;
17
+ /**
18
+ * Optional callback to determine whether the suggestion menu should be
19
+ * opened in the current editor state. Return `false` to prevent the
20
+ * menu from opening (e.g. when the cursor is inside table content).
21
+ */
22
+ shouldOpen?: (tr: Transaction) => boolean;
23
+ };
15
24
  /**
16
25
  * A ProseMirror plugin for suggestions, designed to make '/'-commands possible as well as mentions.
17
26
  *
@@ -40,8 +49,8 @@ export declare const SuggestionMenu: (options?: any) => import("../../index.js")
40
49
  } & {
41
50
  triggerCharacter: string;
42
51
  }) | undefined>;
43
- readonly addTriggerCharacter: (triggerCharacter: string) => void;
44
- readonly removeTriggerCharacter: (triggerCharacter: string) => void;
52
+ readonly addSuggestionMenu: (options: SuggestionMenuOptions) => void;
53
+ readonly removeSuggestionMenu: (triggerCharacter: string) => void;
45
54
  readonly closeMenu: () => void;
46
55
  readonly clearQuery: () => void;
47
56
  readonly shown: () => boolean;
@@ -14,6 +14,7 @@ export * from "./editor/BlockNoteExtension.js";
14
14
  export * from "./editor/defaultColors.js";
15
15
  export * from "./editor/selectionTypes.js";
16
16
  export * from "./exporter/index.js";
17
+ export * from "./extensions/index.js";
17
18
  export * from "./extensions-shared/UiElementPosition.js";
18
19
  export * from "./i18n/dictionary.js";
19
20
  export * from "./schema/index.js";
@@ -3,7 +3,7 @@ import { TagParseRule } from "@tiptap/pm/model";
3
3
  import { NodeView } from "@tiptap/pm/view";
4
4
  import { Extension, ExtensionFactoryInstance } from "../../editor/BlockNoteExtension.js";
5
5
  import { PropSchema } from "../propTypes.js";
6
- import { BlockConfig, BlockImplementation, BlockSpec, LooseBlockSpec } from "./types.js";
6
+ import { BlockConfig, BlockImplementation, BlockImplementationOrCreator, BlockSpec, LooseBlockSpec } from "./types.js";
7
7
  export declare function applyNonSelectableBlockFix(nodeView: NodeView, editor: Editor): void;
8
8
  export declare function getParseRules<TName extends string, TProps extends PropSchema, TContent extends "inline" | "none" | "table">(config: BlockConfig<TName, TProps, TContent>, implementation: BlockImplementation<TName, TProps, TContent>): TagParseRule[];
9
9
  export declare function addNodeAndExtensionsToSpec<TName extends string, TProps extends PropSchema, TContent extends "inline" | "none" | "table">(blockConfig: BlockConfig<TName, TProps, TContent>, blockImplementation: BlockImplementation<TName, TProps, TContent>, extensions?: (ExtensionFactoryInstance | Extension)[], priority?: number): LooseBlockSpec<TName, TProps, TContent>;
@@ -15,5 +15,5 @@ export declare function createBlockConfig<TCallback extends (options: Partial<Re
15
15
  * Helper function to create a block definition.
16
16
  * Can accept either functions that return the required objects, or the objects directly.
17
17
  */
18
- export declare function createBlockSpec<const TName extends string, const TProps extends PropSchema, const TContent extends "inline" | "none", const TOptions extends Partial<Record<string, any>> | undefined = undefined>(blockConfigOrCreator: BlockConfig<TName, TProps, TContent>, blockImplementationOrCreator: BlockImplementation<TName, TProps, TContent> | (TOptions extends undefined ? () => BlockImplementation<TName, TProps, TContent> : (options: Partial<TOptions>) => BlockImplementation<TName, TProps, TContent>), extensionsOrCreator?: ExtensionFactoryInstance[] | (TOptions extends undefined ? () => ExtensionFactoryInstance[] : (options: Partial<TOptions>) => ExtensionFactoryInstance[])): (options?: Partial<TOptions>) => BlockSpec<TName, TProps, TContent>;
19
- export declare function createBlockSpec<const TName extends string, const TProps extends PropSchema, const TContent extends "inline" | "none", const BlockConf extends BlockConfig<TName, TProps, TContent>, const TOptions extends Partial<Record<string, any>>>(blockCreator: (options: Partial<TOptions>) => BlockConf, blockImplementationOrCreator: BlockImplementation<BlockConf["type"], BlockConf["propSchema"], BlockConf["content"]> | (TOptions extends undefined ? () => BlockImplementation<BlockConf["type"], BlockConf["propSchema"], BlockConf["content"]> : (options: Partial<TOptions>) => BlockImplementation<BlockConf["type"], BlockConf["propSchema"], BlockConf["content"]>), extensionsOrCreator?: ExtensionFactoryInstance[] | (TOptions extends undefined ? () => ExtensionFactoryInstance[] : (options: Partial<TOptions>) => ExtensionFactoryInstance[])): (options?: Partial<TOptions>) => BlockSpec<BlockConf["type"], BlockConf["propSchema"], BlockConf["content"]>;
18
+ export declare function createBlockSpec<const TName extends string, const TProps extends PropSchema, const TContent extends "inline" | "none", const TOptions extends Partial<Record<string, any>> | undefined = undefined>(blockConfigOrCreator: BlockConfig<TName, TProps, TContent>, blockImplementationOrCreator: BlockImplementationOrCreator<BlockConfig<TName, TProps, TContent>, TOptions>, extensionsOrCreator?: (ExtensionFactoryInstance | Extension)[] | (TOptions extends undefined ? () => (ExtensionFactoryInstance | Extension)[] : (options: Partial<TOptions>) => (ExtensionFactoryInstance | Extension)[])): (options?: Partial<TOptions>) => BlockSpec<TName, TProps, TContent>;
19
+ export declare function createBlockSpec<const TName extends string, const TProps extends PropSchema, const TContent extends "inline" | "none", const BlockConf extends BlockConfig<TName, TProps, TContent>, const TOptions extends Partial<Record<string, any>>>(blockCreator: (options: Partial<TOptions>) => BlockConf, blockImplementationOrCreator: BlockImplementationOrCreator<BlockConf, TOptions>, extensionsOrCreator?: (ExtensionFactoryInstance | Extension)[] | (TOptions extends undefined ? () => (ExtensionFactoryInstance | Extension)[] : (options: Partial<TOptions>) => (ExtensionFactoryInstance | Extension)[])): (options?: Partial<TOptions>) => BlockSpec<BlockConf["type"], BlockConf["propSchema"], BlockConf["content"]>;