@blocknote/core 0.24.1 → 0.25.0

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 (149) hide show
  1. package/dist/blocknote.cjs +12 -0
  2. package/dist/blocknote.cjs.map +1 -0
  3. package/dist/blocknote.js +5028 -3444
  4. package/dist/blocknote.js.map +1 -1
  5. package/dist/comments.cjs +2 -0
  6. package/dist/comments.cjs.map +1 -0
  7. package/dist/comments.js +593 -0
  8. package/dist/comments.js.map +1 -0
  9. package/dist/style.css +1 -1
  10. package/dist/tsconfig.tsbuildinfo +1 -1
  11. package/dist/webpack-stats.json +1 -1
  12. package/package.json +39 -26
  13. package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +1022 -378
  14. package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +730 -270
  15. package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +3100 -1260
  16. package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap +438 -162
  17. package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +1168 -432
  18. package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +930 -378
  19. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2485 -1015
  20. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +28 -1
  21. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +1 -1
  22. package/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap +292 -108
  23. package/src/api/blockManipulation/setupTestEnv.ts +14 -1
  24. package/src/api/blockManipulation/tables/tables.test.ts +1987 -0
  25. package/src/api/blockManipulation/tables/tables.ts +887 -0
  26. package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html +66 -24
  27. package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html +66 -24
  28. package/src/api/clipboard/__snapshots__/external/pasteImage.html +66 -24
  29. package/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html +66 -24
  30. package/src/api/clipboard/__snapshots__/external/pasteTable.html +132 -48
  31. package/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html +136 -44
  32. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +36 -14
  33. package/src/api/clipboard/toClipboard/copyExtension.ts +2 -3
  34. package/src/api/exporters/html/__snapshots__/table/headerCols/external.html +1 -0
  35. package/src/api/exporters/html/__snapshots__/table/headerCols/internal.html +1 -0
  36. package/src/api/exporters/html/__snapshots__/table/headerRows/external.html +1 -0
  37. package/src/api/exporters/html/__snapshots__/table/headerRows/internal.html +1 -0
  38. package/src/api/exporters/html/__snapshots__/table/headersRows/external.html +1 -0
  39. package/src/api/exporters/html/__snapshots__/table/headersRows/internal.html +1 -0
  40. package/src/api/exporters/html/__snapshots__/table/mixedCellColors/external.html +1 -0
  41. package/src/api/exporters/html/__snapshots__/table/mixedCellColors/internal.html +1 -0
  42. package/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/external.html +1 -0
  43. package/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/internal.html +1 -0
  44. package/src/api/exporters/markdown/__snapshots__/table/headerCols/markdown.md +4 -0
  45. package/src/api/exporters/markdown/__snapshots__/table/headerRows/markdown.md +4 -0
  46. package/src/api/exporters/markdown/__snapshots__/table/mixedCellColors/markdown.md +5 -0
  47. package/src/api/exporters/markdown/__snapshots__/table/mixedRowspansAndColspans/markdown.md +5 -0
  48. package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +985 -20
  49. package/src/api/nodeConversions/blockToNode.ts +63 -20
  50. package/src/api/nodeConversions/nodeToBlock.ts +75 -13
  51. package/src/api/parsers/html/__snapshots__/parse-notion-html.json +145 -54
  52. package/src/api/testUtil/cases/defaultSchema.ts +782 -9
  53. package/src/api/testUtil/partialBlockTestUtil.ts +39 -4
  54. package/src/blocks/TableBlockContent/TableBlockContent.ts +11 -5
  55. package/src/blocks/defaultBlockTypeGuards.ts +8 -0
  56. package/src/comments/index.ts +9 -0
  57. package/src/comments/models/User.ts +8 -0
  58. package/src/comments/threadstore/DefaultThreadStoreAuth.ts +106 -0
  59. package/src/comments/threadstore/ThreadStore.ts +134 -0
  60. package/src/comments/threadstore/ThreadStoreAuth.ts +13 -0
  61. package/src/comments/threadstore/TipTapThreadStore.ts +292 -0
  62. package/src/comments/threadstore/yjs/RESTYjsThreadStore.ts +144 -0
  63. package/src/comments/threadstore/yjs/YjsThreadStore.test.ts +294 -0
  64. package/src/comments/threadstore/yjs/YjsThreadStore.ts +340 -0
  65. package/src/comments/threadstore/yjs/YjsThreadStoreBase.ts +48 -0
  66. package/src/comments/threadstore/yjs/yjsHelpers.ts +121 -0
  67. package/src/comments/types.ts +117 -0
  68. package/src/editor/Block.css +16 -8
  69. package/src/editor/BlockNoteEditor.ts +269 -92
  70. package/src/editor/BlockNoteExtensions.ts +24 -1
  71. package/src/editor/BlockNoteTipTapEditor.ts +5 -1
  72. package/src/editor/editor.css +17 -0
  73. package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +1 -1
  74. package/src/extensions/Comments/CommentMark.ts +61 -0
  75. package/src/extensions/Comments/CommentsPlugin.ts +301 -0
  76. package/src/extensions/Comments/userstore/UserStore.ts +72 -0
  77. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +16 -10
  78. package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +3 -3
  79. package/src/extensions/ShowSelection/ShowSelectionPlugin.ts +52 -0
  80. package/src/extensions/SideMenu/SideMenuPlugin.ts +22 -9
  81. package/src/extensions/TableHandles/TableHandlesPlugin.ts +409 -57
  82. package/src/extensions/TextAlignment/TextAlignmentExtension.ts +2 -0
  83. package/src/extensions/TextColor/TextColorExtension.ts +1 -1
  84. package/src/extensions/UniqueID/UniqueID.ts +8 -3
  85. package/src/i18n/locales/ar.ts +23 -0
  86. package/src/i18n/locales/de.ts +15 -0
  87. package/src/i18n/locales/en.ts +25 -1
  88. package/src/i18n/locales/es.ts +16 -1
  89. package/src/i18n/locales/fr.ts +23 -0
  90. package/src/i18n/locales/hr.ts +18 -0
  91. package/src/i18n/locales/index.ts +1 -0
  92. package/src/i18n/locales/is.ts +24 -1
  93. package/src/i18n/locales/it.ts +21 -0
  94. package/src/i18n/locales/ja.ts +23 -0
  95. package/src/i18n/locales/ko.ts +23 -0
  96. package/src/i18n/locales/nl.ts +23 -0
  97. package/src/i18n/locales/no.ts +346 -0
  98. package/src/i18n/locales/pl.ts +23 -0
  99. package/src/i18n/locales/pt.ts +23 -0
  100. package/src/i18n/locales/ru.ts +23 -0
  101. package/src/i18n/locales/uk.ts +23 -0
  102. package/src/i18n/locales/vi.ts +23 -0
  103. package/src/i18n/locales/zh.ts +23 -0
  104. package/src/index.ts +6 -4
  105. package/src/schema/blocks/types.ts +32 -2
  106. package/src/util/browser.ts +1 -1
  107. package/src/util/table.ts +107 -0
  108. package/types/src/api/blockManipulation/tables/tables.d.ts +343 -0
  109. package/types/src/api/blockManipulation/tables/tables.test.d.ts +1 -0
  110. package/types/src/api/clipboard/toClipboard/copyExtension.d.ts +1 -1
  111. package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +1 -2
  112. package/types/src/blocks/defaultBlockTypeGuards.d.ts +3 -0
  113. package/types/src/comments/index.d.ts +9 -0
  114. package/types/src/comments/models/User.d.ts +8 -0
  115. package/types/src/comments/threadstore/DefaultThreadStoreAuth.d.ts +47 -0
  116. package/types/src/comments/threadstore/ThreadStore.d.ts +121 -0
  117. package/types/src/comments/threadstore/ThreadStoreAuth.d.ts +12 -0
  118. package/types/src/comments/threadstore/TipTapThreadStore.d.ts +97 -0
  119. package/types/src/comments/threadstore/yjs/RESTYjsThreadStore.d.ts +83 -0
  120. package/types/src/comments/threadstore/yjs/YjsThreadStore.d.ts +79 -0
  121. package/types/src/comments/threadstore/yjs/YjsThreadStore.test.d.ts +1 -0
  122. package/types/src/comments/threadstore/yjs/YjsThreadStoreBase.d.ts +15 -0
  123. package/types/src/comments/threadstore/yjs/yjsHelpers.d.ts +13 -0
  124. package/types/src/comments/types.d.ts +109 -0
  125. package/types/src/editor/BlockNoteEditor.d.ts +146 -66
  126. package/types/src/editor/BlockNoteExtensions.d.ts +4 -0
  127. package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +1 -1
  128. package/types/src/extensions/Comments/CommentMark.d.ts +2 -0
  129. package/types/src/extensions/Comments/CommentsPlugin.d.ts +49 -0
  130. package/types/src/extensions/Comments/userstore/UserStore.d.ts +31 -0
  131. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +1 -1
  132. package/types/src/extensions/ShowSelection/ShowSelectionPlugin.d.ts +15 -0
  133. package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +1 -0
  134. package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +66 -1
  135. package/types/src/i18n/locales/de.d.ts +15 -0
  136. package/types/src/i18n/locales/en.d.ts +20 -0
  137. package/types/src/i18n/locales/es.d.ts +15 -0
  138. package/types/src/i18n/locales/hr.d.ts +18 -0
  139. package/types/src/i18n/locales/index.d.ts +1 -0
  140. package/types/src/i18n/locales/it.d.ts +21 -0
  141. package/types/src/i18n/locales/no.d.ts +2 -0
  142. package/types/src/index.d.ts +5 -4
  143. package/types/src/pm-nodes/BlockContainer.d.ts +2 -2
  144. package/types/src/pm-nodes/BlockGroup.d.ts +2 -2
  145. package/types/src/schema/blocks/types.d.ts +23 -2
  146. package/types/src/util/browser.d.ts +1 -1
  147. package/types/src/util/table.d.ts +12 -0
  148. package/dist/blocknote.umd.cjs +0 -11
  149. package/dist/blocknote.umd.cjs.map +0 -1
@@ -2,6 +2,7 @@ import { AnyExtension, EditorOptions } from "@tiptap/core";
2
2
  import { Node, Schema } from "prosemirror-model";
3
3
  import * as Y from "yjs";
4
4
  import { Block, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from "../blocks/defaultBlocks.js";
5
+ import type { CommentsPlugin } from "../extensions/Comments/CommentsPlugin.js";
5
6
  import { FilePanelProsemirrorPlugin } from "../extensions/FilePanel/FilePanelPlugin.js";
6
7
  import { FormattingToolbarProsemirrorPlugin } from "../extensions/FormattingToolbar/FormattingToolbarPlugin.js";
7
8
  import { LinkToolbarProsemirrorPlugin } from "../extensions/LinkToolbar/LinkToolbarPlugin.js";
@@ -17,7 +18,9 @@ import { BlockNoteTipTapEditor } from "./BlockNoteTipTapEditor.js";
17
18
  import { Dictionary } from "../i18n/dictionary.js";
18
19
  import { Plugin, Transaction } from "@tiptap/pm/state";
19
20
  import { EditorView } from "prosemirror-view";
21
+ import type { ThreadStore, User } from "../comments/index.js";
20
22
  import "../style.css";
23
+ import { EventEmitter } from "../util/EventEmitter.js";
21
24
  export type BlockNoteExtensionFactory = (editor: BlockNoteEditor<any, any, any>) => BlockNoteExtension;
22
25
  export type BlockNoteExtension = AnyExtension | {
23
26
  plugin: Plugin;
@@ -29,51 +32,6 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
29
32
  * @default true
30
33
  */
31
34
  animations?: boolean;
32
- /**
33
- * Disable internal extensions (based on keys / extension name)
34
- */
35
- disableExtensions: string[];
36
- /**
37
- * A dictionary object containing translations for the editor.
38
- */
39
- dictionary?: Dictionary & Record<string, any>;
40
- /**
41
- * @deprecated, provide placeholders via dictionary instead
42
- */
43
- placeholders: Record<string | "default" | "emptyDocument", string | undefined>;
44
- /**
45
- * An object containing attributes that should be added to HTML elements of the editor.
46
- *
47
- * @example { editor: { class: "my-editor-class" } }
48
- */
49
- domAttributes: Partial<BlockNoteDOMAttributes>;
50
- /**
51
- * The content that should be in the editor when it's created, represented as an array of partial block objects.
52
- */
53
- initialContent: PartialBlock<NoInfer<BSchema>, NoInfer<ISchema>, NoInfer<SSchema>>[];
54
- /**
55
- * Use default BlockNote font and reset the styles of <p> <li> <h1> elements etc., that are used in BlockNote.
56
- *
57
- * @default true
58
- */
59
- defaultStyles: boolean;
60
- schema: BlockNoteSchema<BSchema, ISchema, SSchema>;
61
- /**
62
- * The `uploadFile` method is what the editor uses when files need to be uploaded (for example when selecting an image to upload).
63
- * This method should set when creating the editor as this is application-specific.
64
- *
65
- * `undefined` means the application doesn't support file uploads.
66
- *
67
- * @param file The file that should be uploaded.
68
- * @returns The URL of the uploaded file OR an object containing props that should be set on the file block (such as an id)
69
- */
70
- uploadFile: (file: File, blockId?: string) => Promise<string | Record<string, any>>;
71
- /**
72
- * Resolve a URL of a file block to one that can be displayed or downloaded. This can be used for creating authenticated URL or
73
- * implementing custom protocols / schemes
74
- * @returns The URL that's
75
- */
76
- resolveFileUrl: (url: string) => Promise<string>;
77
35
  /**
78
36
  * When enabled, allows for collaboration between multiple users.
79
37
  */
@@ -105,23 +63,51 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
105
63
  */
106
64
  showCursorLabels?: "always" | "activity";
107
65
  };
66
+ comments: {
67
+ threadStore: ThreadStore;
68
+ };
108
69
  /**
109
- * additional tiptap options, undocumented
70
+ * Use default BlockNote font and reset the styles of <p> <li> <h1> elements etc., that are used in BlockNote.
71
+ *
72
+ * @default true
110
73
  */
111
- _tiptapOptions: Partial<EditorOptions>;
74
+ defaultStyles: boolean;
112
75
  /**
113
- * (experimental) add extra prosemirror plugins or tiptap extensions to the editor
76
+ * A dictionary object containing translations for the editor.
114
77
  */
115
- _extensions: Record<string, BlockNoteExtension | BlockNoteExtensionFactory>;
116
- trailingBlock?: boolean;
78
+ dictionary?: Dictionary & Record<string, any>;
117
79
  /**
118
- * Boolean indicating whether the editor is in headless mode.
119
- * Headless mode means we can use features like importing / exporting blocks,
120
- * but there's no underlying editor (UI) instantiated.
80
+ * Disable internal extensions (based on keys / extension name)
81
+ */
82
+ disableExtensions: string[];
83
+ /**
84
+ * An object containing attributes that should be added to HTML elements of the editor.
121
85
  *
122
- * You probably don't need to set this manually, but use the `server-util` package instead that uses this option internally
86
+ * @example { editor: { class: "my-editor-class" } }
123
87
  */
124
- _headless: boolean;
88
+ domAttributes: Partial<BlockNoteDOMAttributes>;
89
+ dropCursor?: (opts: {
90
+ editor: BlockNoteEditor<NoInfer<BSchema>, NoInfer<ISchema>, NoInfer<SSchema>>;
91
+ color?: string | false;
92
+ width?: number;
93
+ class?: string;
94
+ }) => Plugin;
95
+ /**
96
+ * The content that should be in the editor when it's created, represented as an array of partial block objects.
97
+ */
98
+ initialContent: PartialBlock<NoInfer<BSchema>, NoInfer<ISchema>, NoInfer<SSchema>>[];
99
+ /**
100
+ * @deprecated, provide placeholders via dictionary instead
101
+ */
102
+ placeholders: Record<string | "default" | "emptyDocument", string | undefined>;
103
+ /**
104
+ * Resolve a URL of a file block to one that can be displayed or downloaded. This can be used for creating authenticated URL or
105
+ * implementing custom protocols / schemes
106
+ * @returns The URL that's
107
+ */
108
+ resolveFileUrl: (url: string) => Promise<string>;
109
+ resolveUsers: (userIds: string[]) => Promise<User[]>;
110
+ schema: BlockNoteSchema<BSchema, ISchema, SSchema>;
125
111
  /**
126
112
  * A flag indicating whether to set an HTML ID for every block
127
113
  *
@@ -131,7 +117,14 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
131
117
  * (note that the id is always set on the `data-id` attribute)
132
118
  */
133
119
  setIdAttribute?: boolean;
134
- dropCursor?: (opts: any) => Plugin;
120
+ /**
121
+ * The detection mode for showing the side menu - "viewport" always shows the
122
+ * side menu for the block next to the mouse cursor, while "editor" only shows
123
+ * it when hovering the editor or the side menu itself.
124
+ *
125
+ * @default "viewport"
126
+ */
127
+ sideMenuDetection: "viewport" | "editor";
135
128
  /**
136
129
  Select desired behavior when pressing `Tab` (or `Shift-Tab`). Specifically,
137
130
  what should happen when a user has selected multiple blocks while a toolbar
@@ -147,17 +140,70 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
147
140
  */
148
141
  tabBehavior: "prefer-navigate-ui" | "prefer-indent";
149
142
  /**
150
- * The detection mode for showing the side menu - "viewport" always shows the
151
- * side menu for the block next to the mouse cursor, while "editor" only shows
152
- * it when hovering the editor or the side menu itself.
143
+ * Allows enabling / disabling features of tables.
144
+ */
145
+ tables?: {
146
+ /**
147
+ * Whether to allow splitting and merging cells within a table.
148
+ *
149
+ * @default false
150
+ */
151
+ splitCells?: boolean;
152
+ /**
153
+ * Whether to allow changing the background color of cells.
154
+ *
155
+ * @default false
156
+ */
157
+ cellBackgroundColor?: boolean;
158
+ /**
159
+ * Whether to allow changing the text color of cells.
160
+ *
161
+ * @default false
162
+ */
163
+ cellTextColor?: boolean;
164
+ /**
165
+ * Whether to allow changing cells into headers.
166
+ *
167
+ * @default false
168
+ */
169
+ headers?: boolean;
170
+ };
171
+ trailingBlock?: boolean;
172
+ /**
173
+ * The `uploadFile` method is what the editor uses when files need to be uploaded (for example when selecting an image to upload).
174
+ * This method should set when creating the editor as this is application-specific.
153
175
  *
154
- * @default "viewport"
176
+ * `undefined` means the application doesn't support file uploads.
177
+ *
178
+ * @param file The file that should be uploaded.
179
+ * @returns The URL of the uploaded file OR an object containing props that should be set on the file block (such as an id)
155
180
  */
156
- sideMenuDetection: "viewport" | "editor";
181
+ uploadFile: (file: File, blockId?: string) => Promise<string | Record<string, any>>;
182
+ /**
183
+ * additional tiptap options, undocumented
184
+ */
185
+ _tiptapOptions: Partial<EditorOptions>;
186
+ /**
187
+ * (experimental) add extra prosemirror plugins or tiptap extensions to the editor
188
+ */
189
+ _extensions: Record<string, BlockNoteExtension | BlockNoteExtensionFactory>;
190
+ /**
191
+ * Boolean indicating whether the editor is in headless mode.
192
+ * Headless mode means we can use features like importing / exporting blocks,
193
+ * but there's no underlying editor (UI) instantiated.
194
+ *
195
+ * You probably don't need to set this manually, but use the `server-util` package instead that uses this option internally
196
+ */
197
+ _headless: boolean;
157
198
  };
158
- export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> {
199
+ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> extends EventEmitter<{
200
+ create: void;
201
+ }> {
159
202
  protected readonly options: Partial<BlockNoteEditorOptions<any, any, any>>;
160
- private readonly _pmSchema;
203
+ /**
204
+ * The underlying prosemirror schema
205
+ */
206
+ readonly pmSchema: Schema;
161
207
  /**
162
208
  * extensions that are added to the editor, can be tiptap extensions or prosemirror plugins
163
209
  */
@@ -202,6 +248,8 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
202
248
  readonly suggestionMenus: SuggestionMenuProseMirrorPlugin<BSchema, ISchema, SSchema>;
203
249
  readonly filePanel?: FilePanelProsemirrorPlugin<ISchema, SSchema>;
204
250
  readonly tableHandles?: TableHandlesProsemirrorPlugin<ISchema, SSchema>;
251
+ readonly comments?: CommentsPlugin;
252
+ private readonly showSelectionPlugin;
205
253
  /**
206
254
  * The `uploadFile` method is what the editor uses when files need to be uploaded (for example when selecting an image to upload).
207
255
  * This method should set when creating the editor as this is application-specific.
@@ -215,17 +263,35 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
215
263
  private onUploadStartCallbacks;
216
264
  private onUploadEndCallbacks;
217
265
  readonly resolveFileUrl?: (url: string) => Promise<string>;
218
- get pmSchema(): Schema<any, any>;
266
+ readonly resolveUsers?: (userIds: string[]) => Promise<User[]>;
267
+ /**
268
+ * Editor settings
269
+ */
270
+ readonly settings: {
271
+ tables: {
272
+ splitCells: boolean;
273
+ cellBackgroundColor: boolean;
274
+ cellTextColor: boolean;
275
+ headers: boolean;
276
+ };
277
+ };
219
278
  static create<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema>(options?: Partial<BlockNoteEditorOptions<BSchema, ISchema, SSchema>>): BlockNoteEditor<BSchema, ISchema, SSchema>;
220
279
  protected constructor(options: Partial<BlockNoteEditorOptions<any, any, any>>);
221
- dispatch(tr: Transaction): void;
280
+ dispatch: (tr: Transaction) => void;
222
281
  /**
223
282
  * Mount the editor to a parent DOM element. Call mount(undefined) to clean up
224
283
  *
225
284
  * @warning Not needed to call manually when using React, use BlockNoteView to take care of mounting
226
285
  */
227
286
  mount: (parentElement?: HTMLElement | null, contentComponent?: any) => void;
287
+ /**
288
+ * Get the underlying prosemirror view
289
+ */
228
290
  get prosemirrorView(): EditorView | undefined;
291
+ /**
292
+ * Get the underlying prosemirror state
293
+ */
294
+ get prosemirrorState(): import("prosemirror-state").EditorState;
229
295
  get domElement(): HTMLDivElement | undefined;
230
296
  isFocused(): boolean;
231
297
  focus(): void;
@@ -284,11 +350,15 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
284
350
  /**
285
351
  * Executes a callback whenever the editor's contents change.
286
352
  * @param callback The callback to execute.
353
+ *
354
+ * @deprecated use `onChange` instead
287
355
  */
288
356
  onEditorContentChange(callback: () => void): void;
289
357
  /**
290
358
  * Executes a callback whenever the editor's selection changes.
291
359
  * @param callback The callback to execute.
360
+ *
361
+ * @deprecated use `onSelectionChange` instead
292
362
  */
293
363
  onEditorSelectionChange(callback: () => void): void;
294
364
  /**
@@ -479,9 +549,19 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
479
549
  * @param callback The callback to execute.
480
550
  * @returns A function to remove the callback.
481
551
  */
482
- onSelectionChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>) => void): (() => void) | undefined;
552
+ onSelectionChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>) => void, includeSelectionChangedByRemote?: boolean): (() => void) | undefined;
553
+ /**
554
+ * A callback function that runs when the editor has been initialized.
555
+ *
556
+ * This can be useful for plugins to initialize themselves after the editor has been initialized.
557
+ */
558
+ onCreate(callback: () => void): () => void;
559
+ getSelectionBoundingBox(): DOMRect | undefined;
560
+ get isEmpty(): boolean;
483
561
  openSuggestionMenu(triggerCharacter: string, pluginState?: {
484
562
  deleteTriggerCharacter?: boolean;
485
563
  ignoreQueryLength?: boolean;
486
564
  }): void;
565
+ getForceSelectionVisible(): boolean;
566
+ setForceSelectionVisible(forceSelectionVisible: boolean): void;
487
567
  }
@@ -1,5 +1,6 @@
1
1
  import { Plugin } from "prosemirror-state";
2
2
  import * as Y from "yjs";
3
+ import type { ThreadStore } from "../comments/index.js";
3
4
  import { BlockNoteDOMAttributes, BlockSchema, BlockSpecs, InlineContentSchema, InlineContentSpecs, StyleSchema, StyleSpecs } from "../schema/index.js";
4
5
  import type { BlockNoteEditor, BlockNoteExtension } from "./BlockNoteEditor.js";
5
6
  type ExtensionOptions<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
@@ -28,6 +29,9 @@ type ExtensionOptions<BSchema extends BlockSchema, I extends InlineContentSchema
28
29
  placeholders: Record<string | "default" | "emptyDocument", string | undefined>;
29
30
  tabBehavior?: "prefer-navigate-ui" | "prefer-indent";
30
31
  sideMenuDetection: "viewport" | "editor";
32
+ comments?: {
33
+ threadStore: ThreadStore;
34
+ };
31
35
  };
32
36
  /**
33
37
  * Get all the Tiptap extensions BlockNote is configured with by default
@@ -9,7 +9,7 @@ export declare const createCollaborationExtensions: (collaboration: {
9
9
  provider: any;
10
10
  renderCursor?: (user: any) => HTMLElement;
11
11
  showCursorLabels?: "always" | "activity";
12
- }) => (import("@tiptap/core").Extension<import("@tiptap/extension-collaboration").CollaborationOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-collaboration-cursor").CollaborationCursorOptions, {
12
+ }) => (import("@tiptap/core").Extension<import("@tiptap/extension-collaboration").CollaborationOptions, import("@tiptap/extension-collaboration").CollaborationStorage> | import("@tiptap/core").Extension<import("@tiptap/extension-collaboration-cursor").CollaborationCursorOptions, {
13
13
  users: {
14
14
  [key: string]: any;
15
15
  clientId: number;
@@ -0,0 +1,2 @@
1
+ import { Mark } from "@tiptap/core";
2
+ export declare const CommentMark: Mark<any, any>;
@@ -0,0 +1,49 @@
1
+ import { Plugin } from "prosemirror-state";
2
+ import type { CommentBody, ThreadStore, User } from "../../comments/index.js";
3
+ import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
4
+ import { EventEmitter } from "../../util/EventEmitter.js";
5
+ import { UserStore } from "./userstore/UserStore.js";
6
+ export declare class CommentsPlugin extends EventEmitter<any> {
7
+ private readonly editor;
8
+ readonly threadStore: ThreadStore;
9
+ private readonly markType;
10
+ readonly plugin: Plugin;
11
+ readonly userStore: UserStore<User>;
12
+ private pendingComment;
13
+ private selectedThreadId;
14
+ private emitStateUpdate;
15
+ /**
16
+ * when a thread is resolved or deleted, we need to update the marks to reflect the new state
17
+ */
18
+ private updateMarksFromThreads;
19
+ constructor(editor: BlockNoteEditor<any, any, any>, threadStore: ThreadStore, markType: string);
20
+ /**
21
+ * Subscribe to state updates
22
+ */
23
+ onUpdate(callback: (state: {
24
+ pendingComment: boolean;
25
+ selectedThreadId: string | undefined;
26
+ }) => void): () => void;
27
+ /**
28
+ * Set the selected thread
29
+ */
30
+ selectThread(threadId: string | undefined): void;
31
+ /**
32
+ * Start a pending comment (e.g.: when clicking the "Add comment" button)
33
+ */
34
+ startPendingComment(): void;
35
+ /**
36
+ * Stop a pending comment (e.g.: user closes the comment composer)
37
+ */
38
+ stopPendingComment(): void;
39
+ /**
40
+ * Create a thread at the current selection
41
+ */
42
+ createThread(options: {
43
+ initialComment: {
44
+ body: CommentBody;
45
+ metadata?: any;
46
+ };
47
+ metadata?: any;
48
+ }): Promise<void>;
49
+ }
@@ -0,0 +1,31 @@
1
+ import type { User } from "../../../comments/index.js";
2
+ import { EventEmitter } from "../../../util/EventEmitter.js";
3
+ /**
4
+ * The `UserStore` is used to retrieve and cache information about users.
5
+ *
6
+ * It does this by calling `resolveUsers` (which is user-defined in the Editor Options)
7
+ * for users that are not yet cached.
8
+ */
9
+ export declare class UserStore<U extends User> extends EventEmitter<any> {
10
+ private readonly resolveUsers;
11
+ private userCache;
12
+ private loadingUsers;
13
+ constructor(resolveUsers: (userIds: string[]) => Promise<U[]>);
14
+ /**
15
+ * Load information about users based on an array of user ids.
16
+ */
17
+ loadUsers(userIds: string[]): Promise<void>;
18
+ /**
19
+ * Retrieve information about a user based on their id, if cached.
20
+ *
21
+ * The user will have to be loaded via `loadUsers` first
22
+ */
23
+ getUser(userId: string): U | undefined;
24
+ /**
25
+ * Subscribe to changes in the user store.
26
+ *
27
+ * @param cb - The callback to call when the user store changes.
28
+ * @returns A function to unsubscribe from the user store.
29
+ */
30
+ subscribe(cb: (users: Map<string, U>) => void): () => void;
31
+ }
@@ -21,7 +21,7 @@ export declare class FormattingToolbarView implements PluginView {
21
21
  constructor(editor: BlockNoteEditor<BlockSchema, InlineContentSchema, StyleSchema>, pmView: EditorView, emitUpdate: (state: FormattingToolbarState) => void);
22
22
  blurHandler: (event: FocusEvent) => void;
23
23
  viewMousedownHandler: () => void;
24
- viewMouseupHandler: () => void;
24
+ mouseupHandler: () => void;
25
25
  dragHandler: () => void;
26
26
  scrollHandler: () => void;
27
27
  update(view: EditorView, oldState?: EditorState): void;
@@ -0,0 +1,15 @@
1
+ import { Plugin } from "prosemirror-state";
2
+ import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
3
+ /**
4
+ * Plugin that shows adds a decoration around the current selection
5
+ * This can be used to highlight the current selection in the UI even when the
6
+ * text editor is not focused.
7
+ */
8
+ export declare class ShowSelectionPlugin {
9
+ private readonly editor;
10
+ readonly plugin: Plugin;
11
+ private enabled;
12
+ constructor(editor: BlockNoteEditor<any, any, any>);
13
+ setEnabled(enabled: boolean): void;
14
+ getEnabled(): boolean;
15
+ }
@@ -25,6 +25,7 @@ export declare class SideMenuView<BSchema extends BlockSchema, I extends InlineC
25
25
  updateState: (state: SideMenuState<BSchema, I, S>) => void;
26
26
  updateStateFromMousePos: () => void;
27
27
  onDrop: (event: DragEvent) => void;
28
+ onDragEnd: () => void;
28
29
  /**
29
30
  * If a block is being dragged, ProseMirror usually gets the context of what's
30
31
  * being dragged from `view.dragging`, which is automatically set when a
@@ -1,5 +1,6 @@
1
1
  import { Plugin, PluginKey, PluginView } from "prosemirror-state";
2
2
  import { EditorView } from "prosemirror-view";
3
+ import { RelativeCellIndices } from "../../api/blockManipulation/tables/tables.js";
3
4
  import { DefaultBlockSchema } from "../../blocks/defaultBlocks.js";
4
5
  import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
5
6
  import { BlockFromConfigNoChildren, BlockSchemaWithBlock, InlineContentSchema, StyleSchema } from "../../schema/index.js";
@@ -36,7 +37,7 @@ export declare class TableHandlesView<I extends InlineContentSchema, S extends S
36
37
  mouseUpHandler: (event: MouseEvent) => void;
37
38
  mouseMoveHandler: (event: MouseEvent) => false | undefined;
38
39
  dragOverHandler: (event: DragEvent) => void;
39
- dropHandler: (event: DragEvent) => void;
40
+ dropHandler: (event: DragEvent) => boolean;
40
41
  update(): void;
41
42
  destroy(): void;
42
43
  }
@@ -78,4 +79,68 @@ export declare class TableHandlesProsemirrorPlugin<I extends InlineContentSchema
78
79
  * same cell regardless of which cell is hovered by the mouse cursor.
79
80
  */
80
81
  unfreezeHandles: () => void;
82
+ getCellsAtRowHandle: (block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, relativeRowIndex: RelativeCellIndices["row"]) => (RelativeCellIndices & {
83
+ cell: import("../../schema/index.js").TableCell<any, any>;
84
+ })[];
85
+ /**
86
+ * Get all the cells in a column of the table block.
87
+ */
88
+ getCellsAtColumnHandle: (block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, relativeColumnIndex: RelativeCellIndices["col"]) => (RelativeCellIndices & {
89
+ cell: import("../../schema/index.js").TableCell<any, any>;
90
+ })[];
91
+ /**
92
+ * Sets the selection to the given cell or a range of cells.
93
+ * @returns The new state after the selection has been set.
94
+ */
95
+ private setCellSelection;
96
+ /**
97
+ * Adds a row or column to the table using prosemirror-table commands
98
+ */
99
+ addRowOrColumn: (index: RelativeCellIndices["row"] | RelativeCellIndices["col"], direction: {
100
+ orientation: "row";
101
+ side: "above" | "below";
102
+ } | {
103
+ orientation: "column";
104
+ side: "left" | "right";
105
+ }) => boolean;
106
+ /**
107
+ * Removes a row or column from the table using prosemirror-table commands
108
+ */
109
+ removeRowOrColumn: (index: RelativeCellIndices["row"] | RelativeCellIndices["col"], direction: "row" | "column") => boolean;
110
+ /**
111
+ * Merges the cells in the table block.
112
+ */
113
+ mergeCells: (cellsToMerge?: {
114
+ relativeStartCell: RelativeCellIndices;
115
+ relativeEndCell: RelativeCellIndices;
116
+ }) => boolean;
117
+ /**
118
+ * Splits the cell in the table block.
119
+ * If no cell is provided, the current cell selected will be split.
120
+ */
121
+ splitCell: (relativeCellToSplit?: RelativeCellIndices) => boolean;
122
+ /**
123
+ * Gets the start and end cells of the current cell selection.
124
+ * @returns The start and end cells of the current cell selection.
125
+ */
126
+ getCellSelection: () => undefined | {
127
+ from: RelativeCellIndices;
128
+ to: RelativeCellIndices;
129
+ /**
130
+ * All of the cells that are within the selected range.
131
+ */
132
+ cells: RelativeCellIndices[];
133
+ };
134
+ /**
135
+ * Gets the direction of the merge based on the current cell selection.
136
+ *
137
+ * Returns undefined when there is no cell selection, or the selection is not within a table.
138
+ */
139
+ getMergeDirection: (block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any> | undefined) => "vertical" | "horizontal" | undefined;
140
+ cropEmptyRowsOrColumns: (block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, removeEmpty: "columns" | "rows") => {
141
+ cells: (import("../../schema/index.js").StyledText<any> | import("../../schema/index.js").Link<any> | import("../../schema/index.js").CustomInlineContentFromConfig<any, any>)[][] | import("../../schema/index.js").TableCell<any, any>[];
142
+ }[];
143
+ addRowsOrColumns: (block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, addType: "columns" | "rows", numToAdd: number) => {
144
+ cells: (import("../../schema/index.js").StyledText<any> | import("../../schema/index.js").Link<any> | import("../../schema/index.js").CustomInlineContentFromConfig<any, any>)[][] | import("../../schema/index.js").TableCell<any, any>[];
145
+ }[];
81
146
  }
@@ -97,6 +97,9 @@ export declare const de: {
97
97
  bulletListItem: string;
98
98
  numberedListItem: string;
99
99
  checkListItem: string;
100
+ new_comment: string;
101
+ edit_comment: string;
102
+ comment_reply: string;
100
103
  };
101
104
  file_blocks: {
102
105
  image: {
@@ -283,6 +286,18 @@ export declare const de: {
283
286
  url_placeholder: string;
284
287
  };
285
288
  };
289
+ comments: {
290
+ actions: {
291
+ add_reaction: string;
292
+ resolve: string;
293
+ edit_comment: string;
294
+ delete_comment: string;
295
+ more_actions: string;
296
+ };
297
+ reactions: {
298
+ reacted_by: string;
299
+ };
300
+ };
286
301
  generic: {
287
302
  ctrl_shortcut: string;
288
303
  };
@@ -113,6 +113,8 @@ export declare const en: {
113
113
  drag_handle: {
114
114
  delete_menuitem: string;
115
115
  colors_menuitem: string;
116
+ header_row_menuitem: string;
117
+ header_column_menuitem: string;
116
118
  };
117
119
  table_handle: {
118
120
  delete_column_menuitem: string;
@@ -121,6 +123,9 @@ export declare const en: {
121
123
  add_right_menuitem: string;
122
124
  add_above_menuitem: string;
123
125
  add_below_menuitem: string;
126
+ split_cell_menuitem: string;
127
+ merge_cells_menuitem: string;
128
+ background_color_menuitem: string;
124
129
  };
125
130
  suggestion_menu: {
126
131
  no_items_title: string;
@@ -210,6 +215,9 @@ export declare const en: {
210
215
  align_justify: {
211
216
  tooltip: string;
212
217
  };
218
+ table_cell_merge: {
219
+ tooltip: string;
220
+ };
213
221
  comment: {
214
222
  tooltip: string;
215
223
  };
@@ -242,6 +250,18 @@ export declare const en: {
242
250
  url_placeholder: string;
243
251
  };
244
252
  };
253
+ comments: {
254
+ actions: {
255
+ add_reaction: string;
256
+ resolve: string;
257
+ edit_comment: string;
258
+ delete_comment: string;
259
+ more_actions: string;
260
+ };
261
+ reactions: {
262
+ reacted_by: string;
263
+ };
264
+ };
245
265
  generic: {
246
266
  ctrl_shortcut: string;
247
267
  };
@@ -97,6 +97,9 @@ export declare const es: {
97
97
  bulletListItem: string;
98
98
  numberedListItem: string;
99
99
  checkListItem: string;
100
+ new_comment: string;
101
+ edit_comment: string;
102
+ comment_reply: string;
100
103
  };
101
104
  file_blocks: {
102
105
  image: {
@@ -248,6 +251,18 @@ export declare const es: {
248
251
  url_placeholder: string;
249
252
  };
250
253
  };
254
+ comments: {
255
+ actions: {
256
+ add_reaction: string;
257
+ resolve: string;
258
+ edit_comment: string;
259
+ delete_comment: string;
260
+ more_actions: string;
261
+ };
262
+ reactions: {
263
+ reacted_by: string;
264
+ };
265
+ };
251
266
  generic: {
252
267
  ctrl_shortcut: string;
253
268
  };