@blocknote/core 0.47.1 → 0.47.3

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 (74) 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-CwhtPpVC.cjs → BlockNoteSchema-CCs_V3lo.cjs} +2 -2
  4. package/dist/{BlockNoteSchema-CwhtPpVC.cjs.map → BlockNoteSchema-CCs_V3lo.cjs.map} +1 -1
  5. package/dist/{BlockNoteSchema-dmbNkHA-.js → BlockNoteSchema-ooiKsd5B.js} +2 -2
  6. package/dist/{BlockNoteSchema-dmbNkHA-.js.map → BlockNoteSchema-ooiKsd5B.js.map} +1 -1
  7. package/dist/{TrailingNode-F9hX_UlQ.js → TrailingNode-GzE59m_7.js} +585 -415
  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 +938 -862
  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-Caw1U1oV.js → defaultBlocks-ZzGbYgQn.js} +611 -530
  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 +4 -1
  36. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
  37. package/src/api/parsers/html/parseHTML.ts +2 -0
  38. package/src/api/parsers/html/util/normalizeWhitespace.ts +87 -0
  39. package/src/blocks/Heading/block.ts +48 -1
  40. package/src/blocks/ListItem/ToggleListItem/block.ts +51 -1
  41. package/src/blocks/Paragraph/block.ts +1 -1
  42. package/src/blocks/getDetailsContent.ts +77 -0
  43. package/src/comments/threadstore/TipTapThreadStore.ts +5 -5
  44. package/src/comments/threadstore/tiptap/types.ts +131 -0
  45. package/src/editor/Block.css +6 -0
  46. package/src/editor/BlockNoteEditor.ts +9 -14
  47. package/src/editor/managers/ExtensionManager/symbol.ts +0 -1
  48. package/src/editor/managers/SelectionManager.ts +3 -1
  49. package/src/extensions/DropCursor/DropCursor.ts +262 -25
  50. package/src/extensions/DropCursor/utils.ts +195 -0
  51. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +15 -10
  52. package/src/i18n/locales/fa.ts +4 -21
  53. package/src/i18n/locales/index.ts +1 -1
  54. package/src/i18n/locales/ru.ts +1 -1
  55. package/src/i18n/locales/uz.ts +22 -4
  56. package/src/index.ts +1 -0
  57. package/src/schema/blocks/createSpec.ts +33 -45
  58. package/src/schema/blocks/types.ts +101 -1
  59. package/types/src/api/parsers/html/util/normalizeWhitespace.d.ts +6 -0
  60. package/types/src/blocks/getDetailsContent.d.ts +19 -0
  61. package/types/src/comments/threadstore/TipTapThreadStore.d.ts +1 -1
  62. package/types/src/comments/threadstore/tiptap/types.d.ts +73 -0
  63. package/types/src/editor/BlockNoteEditor.d.ts +6 -9
  64. package/types/src/extensions/DropCursor/DropCursor.d.ts +42 -5
  65. package/types/src/extensions/DropCursor/utils.d.ts +48 -0
  66. package/types/src/index.d.ts +1 -0
  67. package/types/src/schema/blocks/createSpec.d.ts +3 -3
  68. package/types/src/schema/blocks/types.d.ts +31 -1
  69. package/dist/TrailingNode-DHOdUVUO.cjs +0 -2
  70. package/dist/TrailingNode-DHOdUVUO.cjs.map +0 -1
  71. package/dist/TrailingNode-F9hX_UlQ.js.map +0 -1
  72. package/dist/defaultBlocks-CSB5GiAu.cjs +0 -6
  73. package/dist/defaultBlocks-CSB5GiAu.cjs.map +0 -1
  74. package/dist/defaultBlocks-Caw1U1oV.js.map +0 -1
@@ -538,7 +538,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
538
538
  // Deletes the next block at either the same or lower nesting level, if
539
539
  // the selection is empty and at the end of the block. If both the
540
540
  // current and next blocks have inline content, the next block's
541
- // content is appended to the current block's. The next block's own
541
+ // content is appended to the current block's. The next block's own
542
542
  // children are unindented before it's deleted.
543
543
  () =>
544
544
  commands.command(({ state }) => {
@@ -708,15 +708,20 @@ export const KeyboardShortcutsExtension = Extension.create<{
708
708
  nextBlockInfo.blockContent.node.childCount === 0);
709
709
 
710
710
  if (nextBlockNotTableAndNoContent) {
711
- const childBlocks =
712
- nextBlockInfo.bnBlock.node.lastChild!.content;
713
- return chain()
714
- .deleteRange({
715
- from: nextBlockInfo.bnBlock.beforePos,
716
- to: nextBlockInfo.bnBlock.afterPos,
717
- })
718
- .insertContentAt(blockInfo.bnBlock.afterPos, nextBlockInfo.bnBlock.node.childCount === 2 ? childBlocks : null)
719
- .run();
711
+ const childBlocks =
712
+ nextBlockInfo.bnBlock.node.lastChild!.content;
713
+ return chain()
714
+ .deleteRange({
715
+ from: nextBlockInfo.bnBlock.beforePos,
716
+ to: nextBlockInfo.bnBlock.afterPos,
717
+ })
718
+ .insertContentAt(
719
+ blockInfo.bnBlock.afterPos,
720
+ nextBlockInfo.bnBlock.node.childCount === 2
721
+ ? childBlocks
722
+ : null,
723
+ )
724
+ .run();
720
725
  }
721
726
  }
722
727
 
@@ -81,7 +81,7 @@ export const fa = {
81
81
  check_list: {
82
82
  title: "بازینه",
83
83
  subtext: "فهرست با جعبه انتخاب",
84
- aliases: ["چک لیست", "لیست انجام کار", "لیست تیک دار","بازینه"],
84
+ aliases: ["چک لیست", "لیست انجام کار", "لیست تیک دار", "بازینه"],
85
85
  group: "بلوک‌های پایه",
86
86
  },
87
87
  paragraph: {
@@ -111,36 +111,19 @@ export const fa = {
111
111
  image: {
112
112
  title: "تصویر",
113
113
  subtext: "تصویر با قابلیت تغییر اندازه و زیرنویس",
114
- aliases: [
115
- "تصویر",
116
- "عکس",
117
- "آپلود تصویر",
118
- "مدیا",
119
- "لینک عکس",
120
- ],
114
+ aliases: ["تصویر", "عکس", "آپلود تصویر", "مدیا", "لینک عکس"],
121
115
  group: "رسانه",
122
116
  },
123
117
  video: {
124
118
  title: "ویدیو",
125
119
  subtext: "ویدیو با قابلیت تغییر اندازه و زیرنویس",
126
- aliases: [
127
- "ویدیو",
128
- "فیلم",
129
- "آپلود ویدیو",
130
- "مدیا",
131
- ],
120
+ aliases: ["ویدیو", "فیلم", "آپلود ویدیو", "مدیا"],
132
121
  group: "رسانه",
133
122
  },
134
123
  audio: {
135
124
  title: "صوتی",
136
125
  subtext: "فایل صوتی جاسازی شده با زیرنویس",
137
- aliases: [
138
- "صوتی",
139
- "صدا",
140
- "آهنگ",
141
- "موسیقی",
142
- "آپلود صدا",
143
- ],
126
+ aliases: ["صوتی", "صدا", "آهنگ", "موسیقی", "آپلود صدا"],
144
127
  group: "رسانه",
145
128
  },
146
129
  file: {
@@ -20,4 +20,4 @@ export * from "./uk.js";
20
20
  export * from "./vi.js";
21
21
  export * from "./zh.js";
22
22
  export * from "./zh-tw.js";
23
- export * from "./uz.js";
23
+ export * from "./uz.js";
@@ -272,7 +272,7 @@ export const ru: Dictionary = {
272
272
  text_title: "Текст",
273
273
  background_title: "Задний фон",
274
274
  colors: {
275
- default: "По умолчинию",
275
+ default: "По умолчанию",
276
276
  gray: "Серый",
277
277
  brown: "Коричневый",
278
278
  red: "Красный",
@@ -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") {
@@ -297,18 +304,17 @@ export function createBlockSpec<
297
304
  const TOptions extends Partial<Record<string, any>> | undefined = undefined,
298
305
  >(
299
306
  blockConfigOrCreator: BlockConfig<TName, TProps, TContent>,
300
- blockImplementationOrCreator:
301
- | BlockImplementation<TName, TProps, TContent>
307
+ blockImplementationOrCreator: BlockImplementationOrCreator<
308
+ BlockConfig<TName, TProps, TContent>,
309
+ TOptions
310
+ >,
311
+ extensionsOrCreator?:
312
+ | (ExtensionFactoryInstance | Extension)[]
302
313
  | (TOptions extends undefined
303
- ? () => BlockImplementation<TName, TProps, TContent>
314
+ ? () => (ExtensionFactoryInstance | Extension)[]
304
315
  : (
305
316
  options: Partial<TOptions>,
306
- ) => BlockImplementation<TName, TProps, TContent>),
307
- extensionsOrCreator?:
308
- | ExtensionFactoryInstance[]
309
- | (TOptions extends undefined
310
- ? () => ExtensionFactoryInstance[]
311
- : (options: Partial<TOptions>) => ExtensionFactoryInstance[]),
317
+ ) => (ExtensionFactoryInstance | Extension)[]),
312
318
  ): (options?: Partial<TOptions>) => BlockSpec<TName, TProps, TContent>;
313
319
  export function createBlockSpec<
314
320
  const TName extends string,
@@ -318,30 +324,17 @@ export function createBlockSpec<
318
324
  const TOptions extends Partial<Record<string, any>>,
319
325
  >(
320
326
  blockCreator: (options: Partial<TOptions>) => BlockConf,
321
- blockImplementationOrCreator:
322
- | BlockImplementation<
323
- BlockConf["type"],
324
- BlockConf["propSchema"],
325
- BlockConf["content"]
326
- >
327
+ blockImplementationOrCreator: BlockImplementationOrCreator<
328
+ BlockConf,
329
+ TOptions
330
+ >,
331
+ extensionsOrCreator?:
332
+ | (ExtensionFactoryInstance | Extension)[]
327
333
  | (TOptions extends undefined
328
- ? () => BlockImplementation<
329
- BlockConf["type"],
330
- BlockConf["propSchema"],
331
- BlockConf["content"]
332
- >
334
+ ? () => (ExtensionFactoryInstance | Extension)[]
333
335
  : (
334
336
  options: Partial<TOptions>,
335
- ) => BlockImplementation<
336
- BlockConf["type"],
337
- BlockConf["propSchema"],
338
- BlockConf["content"]
339
- >),
340
- extensionsOrCreator?:
341
- | ExtensionFactoryInstance[]
342
- | (TOptions extends undefined
343
- ? () => ExtensionFactoryInstance[]
344
- : (options: Partial<TOptions>) => ExtensionFactoryInstance[]),
337
+ ) => (ExtensionFactoryInstance | Extension)[]),
345
338
  ): (
346
339
  options?: Partial<TOptions>,
347
340
  ) => BlockSpec<
@@ -355,23 +348,18 @@ export function createBlockSpec<
355
348
  const TContent extends "inline" | "none",
356
349
  const TOptions extends Partial<Record<string, any>> | undefined = undefined,
357
350
  >(
358
- blockConfigOrCreator:
359
- | BlockConfig<TName, TProps, TContent>
360
- | (TOptions extends undefined
361
- ? () => BlockConfig<TName, TProps, TContent>
362
- : (options: Partial<TOptions>) => BlockConfig<TName, TProps, TContent>),
363
- blockImplementationOrCreator:
364
- | 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)[]
365
358
  | (TOptions extends undefined
366
- ? () => BlockImplementation<TName, TProps, TContent>
359
+ ? () => (ExtensionFactoryInstance | Extension)[]
367
360
  : (
368
361
  options: Partial<TOptions>,
369
- ) => BlockImplementation<TName, TProps, TContent>),
370
- extensionsOrCreator?:
371
- | ExtensionFactoryInstance[]
372
- | (TOptions extends undefined
373
- ? () => ExtensionFactoryInstance[]
374
- : (options: Partial<TOptions>) => ExtensionFactoryInstance[]),
362
+ ) => (ExtensionFactoryInstance | Extension)[]),
375
363
  ): (options?: Partial<TOptions>) => BlockSpec<TName, TProps, TContent> {
376
364
  return (options = {} as TOptions) => {
377
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,
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Normalizes whitespace in HTML text nodes to match standard CSS
3
+ * white-space:normal behavior. Skipped for Notion HTML which intentionally
4
+ * uses `\n` for hard breaks.
5
+ */
6
+ export declare function preprocessHTMLWhitespace(element: HTMLElement): void;
@@ -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>>;