@blocknote/core 0.25.2 → 0.26.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 (63) hide show
  1. package/dist/blocknote.cjs +7 -7
  2. package/dist/blocknote.cjs.map +1 -1
  3. package/dist/blocknote.js +759 -618
  4. package/dist/blocknote.js.map +1 -1
  5. package/dist/comments.cjs +1 -1
  6. package/dist/comments.cjs.map +1 -1
  7. package/dist/comments.js +45 -44
  8. package/dist/comments.js.map +1 -1
  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 +2 -2
  13. package/src/api/nodeConversions/nodeToBlock.ts +1 -0
  14. package/src/api/parsers/html/__snapshots__/parse-2-tables.json +129 -0
  15. package/src/api/parsers/html/parseHTML.test.ts +35 -0
  16. package/src/comments/threadstore/yjs/YjsThreadStore.ts +1 -0
  17. package/src/comments/threadstore/yjs/yjsHelpers.ts +3 -1
  18. package/src/comments/types.ts +4 -0
  19. package/src/editor/Block.css +1 -1
  20. package/src/editor/BlockNoteEditor.ts +1 -1
  21. package/src/editor/BlockNoteTipTapEditor.ts +18 -7
  22. package/src/extensions/Comments/CommentsPlugin.ts +76 -29
  23. package/src/extensions/SideMenu/dragging.ts +13 -0
  24. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +6 -2
  25. package/src/extensions/TableHandles/TableHandlesPlugin.ts +24 -23
  26. package/src/i18n/locales/ar.ts +4 -0
  27. package/src/i18n/locales/de.ts +15 -1
  28. package/src/i18n/locales/en.ts +4 -0
  29. package/src/i18n/locales/es.ts +15 -1
  30. package/src/i18n/locales/fr.ts +4 -0
  31. package/src/i18n/locales/hr.ts +21 -4
  32. package/src/i18n/locales/is.ts +4 -0
  33. package/src/i18n/locales/it.ts +15 -1
  34. package/src/i18n/locales/ja.ts +4 -0
  35. package/src/i18n/locales/ko.ts +4 -0
  36. package/src/i18n/locales/nl.ts +4 -0
  37. package/src/i18n/locales/no.ts +4 -0
  38. package/src/i18n/locales/pl.ts +4 -0
  39. package/src/i18n/locales/pt.ts +4 -0
  40. package/src/i18n/locales/ru.ts +4 -0
  41. package/src/i18n/locales/uk.ts +4 -0
  42. package/src/i18n/locales/vi.ts +4 -0
  43. package/src/i18n/locales/zh.ts +4 -0
  44. package/types/src/comments/types.d.ts +4 -0
  45. package/types/src/editor/BlockNoteTipTapEditor.d.ts +2 -1
  46. package/types/src/extensions/Comments/CommentsPlugin.d.ts +16 -1
  47. package/types/src/extensions/Comments/threadstore/DefaultThreadStoreAuth.d.ts +47 -0
  48. package/types/src/extensions/Comments/threadstore/ThreadStore.d.ts +121 -0
  49. package/types/src/extensions/Comments/threadstore/ThreadStoreAuth.d.ts +12 -0
  50. package/types/src/extensions/Comments/threadstore/TipTapThreadStore.d.ts +97 -0
  51. package/types/src/extensions/Comments/threadstore/yjs/RESTYjsThreadStore.d.ts +83 -0
  52. package/types/src/extensions/Comments/threadstore/yjs/YjsThreadStore.d.ts +79 -0
  53. package/types/src/extensions/Comments/threadstore/yjs/YjsThreadStore.test.d.ts +1 -0
  54. package/types/src/extensions/Comments/threadstore/yjs/YjsThreadStoreBase.d.ts +15 -0
  55. package/types/src/extensions/Comments/threadstore/yjs/yjsHelpers.d.ts +13 -0
  56. package/types/src/extensions/Comments/types.d.ts +109 -0
  57. package/types/src/i18n/locales/de.d.ts +2 -304
  58. package/types/src/i18n/locales/en.d.ts +4 -0
  59. package/types/src/i18n/locales/es.d.ts +2 -269
  60. package/types/src/i18n/locales/hr.d.ts +2 -266
  61. package/types/src/i18n/locales/it.d.ts +2 -269
  62. package/types/src/models/User.d.ts +5 -0
  63. package/types/src/blocks/CodeBlockContent/shiki.bundle.d.ts +0 -82
@@ -20,11 +20,15 @@ function setSelectionToNextContentEditableBlock<
20
20
  I extends InlineContentSchema,
21
21
  S extends StyleSchema
22
22
  >(editor: BlockNoteEditor<BSchema, I, S>) {
23
- let block = editor.getTextCursorPosition().block;
23
+ let block: Block<BSchema, I, S> | undefined =
24
+ editor.getTextCursorPosition().block;
24
25
  let contentType = editor.schema.blockSchema[block.type].content;
25
26
 
26
27
  while (contentType === "none") {
27
- block = editor.getTextCursorPosition().nextBlock!;
28
+ block = editor.getTextCursorPosition().nextBlock;
29
+ if (block === undefined) {
30
+ return;
31
+ }
28
32
  contentType = editor.schema.blockSchema[block.type].content as
29
33
  | "inline"
30
34
  | "table"
@@ -1,10 +1,10 @@
1
1
  import { Plugin, PluginKey, PluginView } from "prosemirror-state";
2
2
  import {
3
+ CellSelection,
3
4
  addColumnAfter,
4
5
  addColumnBefore,
5
6
  addRowAfter,
6
7
  addRowBefore,
7
- CellSelection,
8
8
  deleteColumn,
9
9
  deleteRow,
10
10
  mergeCells,
@@ -12,6 +12,7 @@ import {
12
12
  } from "prosemirror-tables";
13
13
  import { Decoration, DecorationSet, EditorView } from "prosemirror-view";
14
14
  import {
15
+ RelativeCellIndices,
15
16
  addRowsOrColumns,
16
17
  areInSameColumn,
17
18
  canColumnBeDraggedInto,
@@ -22,7 +23,6 @@ import {
22
23
  getDimensionsOfTable,
23
24
  moveColumn,
24
25
  moveRow,
25
- RelativeCellIndices,
26
26
  } from "../../api/blockManipulation/tables/tables.js";
27
27
  import { nodeToBlock } from "../../api/nodeConversions/nodeToBlock.js";
28
28
  import { getNodeById } from "../../api/nodeUtil.js";
@@ -539,7 +539,12 @@ export class TableHandlesView<
539
539
 
540
540
  // Hide handles if the table block has been removed.
541
541
  this.state.block = this.editor.getBlock(this.state.block.id)!;
542
- if (!this.state.block) {
542
+ if (
543
+ !this.state.block ||
544
+ // when collaborating, the table element might be replaced and out of date
545
+ // because yjs replaces the element when for example you change the color via the side menu
546
+ !this.tableElement?.isConnected
547
+ ) {
543
548
  this.state.show = false;
544
549
  this.state.showAddOrRemoveRowsButton = false;
545
550
  this.state.showAddOrRemoveColumnsButton = false;
@@ -569,6 +574,7 @@ export class TableHandlesView<
569
574
 
570
575
  // Update bounding boxes.
571
576
  const tableBody = this.tableElement!.querySelector("tbody");
577
+
572
578
  if (!tableBody) {
573
579
  throw new Error(
574
580
  "Table block does not contain a 'tbody' HTML element. This should never happen."
@@ -656,32 +662,27 @@ export class TableHandlesProsemirrorPlugin<
656
662
  }
657
663
 
658
664
  const decorations: Decoration[] = [];
659
-
660
- if (newIndex === this.view.state.draggingState.originalIndex) {
661
- return DecorationSet.create(state.doc, decorations);
662
- } else if (
663
- this.view.state.draggingState.draggedCellOrientation === "row" &&
664
- !canRowBeDraggedInto(
665
- this.view.state.block,
666
- this.view.state.draggingState.originalIndex,
667
- newIndex
668
- )
669
- ) {
670
- return DecorationSet.create(state.doc, decorations);
671
- } else if (
672
- this.view.state.draggingState.draggedCellOrientation === "col" &&
673
- !canColumnBeDraggedInto(
674
- this.view.state.block,
675
- this.view.state.draggingState.originalIndex,
676
- newIndex
677
- )
665
+ const { block, draggingState } = this.view.state;
666
+ const { originalIndex, draggedCellOrientation } = draggingState;
667
+
668
+ // Return empty decorations if:
669
+ // - Dragging to same position
670
+ // - No block exists
671
+ // - Row drag not allowed
672
+ // - Column drag not allowed
673
+ if (
674
+ newIndex === originalIndex ||
675
+ !block ||
676
+ (draggedCellOrientation === "row" &&
677
+ !canRowBeDraggedInto(block, originalIndex, newIndex)) ||
678
+ (draggedCellOrientation === "col" &&
679
+ !canColumnBeDraggedInto(block, originalIndex, newIndex))
678
680
  ) {
679
681
  return DecorationSet.create(state.doc, decorations);
680
682
  }
681
683
 
682
684
  // Gets the table to show the drop cursor in.
683
685
  const tableResolvedPos = state.doc.resolve(this.view.tablePos + 1);
684
- const originalIndex = this.view.state.draggingState.originalIndex;
685
686
 
686
687
  if (this.view.state.draggingState.draggedCellOrientation === "row") {
687
688
  const cellsInRow = getCellsAtRowHandle(
@@ -325,6 +325,10 @@ export const ar: Dictionary = {
325
325
  reactions: {
326
326
  reacted_by: "تفاعل بواسطة",
327
327
  },
328
+ sidebar: {
329
+ marked_as_resolved: "تم وضع علامة كتم الحل",
330
+ more_replies: (count) => `${count} ردود أخرى`,
331
+ },
328
332
  },
329
333
  generic: {
330
334
  ctrl_shortcut: "Ctrl",
@@ -1,4 +1,6 @@
1
- export const de = {
1
+ import { Dictionary } from "../dictionary.js";
2
+
3
+ export const de: Dictionary = {
2
4
  slash_menu: {
3
5
  heading: {
4
6
  title: "Überschrift 1",
@@ -154,6 +156,8 @@ export const de = {
154
156
  drag_handle: {
155
157
  delete_menuitem: "Löschen",
156
158
  colors_menuitem: "Farben",
159
+ header_row_menuitem: "Kopfzeile",
160
+ header_column_menuitem: "Kopfspalte",
157
161
  },
158
162
  table_handle: {
159
163
  delete_column_menuitem: "Spalte löschen",
@@ -162,6 +166,9 @@ export const de = {
162
166
  add_right_menuitem: "Spalte rechts hinzufügen",
163
167
  add_above_menuitem: "Zeile oberhalb hinzufügen",
164
168
  add_below_menuitem: "Zeile unterhalb hinzufügen",
169
+ split_cell_menuitem: "Zelle teilen",
170
+ merge_cells_menuitem: "Zellen zusammenführen",
171
+ background_color_menuitem: "Hintergrundfarbe",
165
172
  },
166
173
  suggestion_menu: {
167
174
  no_items_title: "Keine Elemente gefunden",
@@ -276,6 +283,9 @@ export const de = {
276
283
  align_justify: {
277
284
  tooltip: "Text Blocksatz",
278
285
  },
286
+ table_cell_merge: {
287
+ tooltip: "Zellen zusammenführen",
288
+ },
279
289
  comment: {
280
290
  tooltip: "Kommentar hinzufügen",
281
291
  },
@@ -329,6 +339,10 @@ export const de = {
329
339
  reactions: {
330
340
  reacted_by: "Reagiert von",
331
341
  },
342
+ sidebar: {
343
+ marked_as_resolved: "Als gelöst markiert",
344
+ more_replies: (count) => `${count} weitere Antworten`,
345
+ },
332
346
  },
333
347
  generic: {
334
348
  ctrl_shortcut: "Strg",
@@ -340,6 +340,10 @@ export const en = {
340
340
  reactions: {
341
341
  reacted_by: "Reacted by",
342
342
  },
343
+ sidebar: {
344
+ marked_as_resolved: "Marked as resolved",
345
+ more_replies: (count: number) => `${count} more replies`,
346
+ },
343
347
  },
344
348
  generic: {
345
349
  ctrl_shortcut: "Ctrl",
@@ -1,4 +1,6 @@
1
- export const es = {
1
+ import { Dictionary } from "../dictionary.js";
2
+
3
+ export const es: Dictionary = {
2
4
  slash_menu: {
3
5
  heading: {
4
6
  title: "Encabezado 1",
@@ -153,6 +155,8 @@ export const es = {
153
155
  drag_handle: {
154
156
  delete_menuitem: "Eliminar",
155
157
  colors_menuitem: "Colores",
158
+ header_row_menuitem: "Fila de encabezado",
159
+ header_column_menuitem: "Columna de encabezado",
156
160
  },
157
161
  table_handle: {
158
162
  delete_column_menuitem: "Eliminar columna",
@@ -161,6 +165,9 @@ export const es = {
161
165
  add_right_menuitem: "Agregar columna a la derecha",
162
166
  add_above_menuitem: "Agregar fila arriba",
163
167
  add_below_menuitem: "Agregar fila abajo",
168
+ split_cell_menuitem: "Dividir celda",
169
+ merge_cells_menuitem: "Combinar celdas",
170
+ background_color_menuitem: "Color de fondo",
164
171
  },
165
172
  suggestion_menu: {
166
173
  no_items_title: "No se encontraron elementos",
@@ -275,6 +282,9 @@ export const es = {
275
282
  align_justify: {
276
283
  tooltip: "Justificar texto",
277
284
  },
285
+ table_cell_merge: {
286
+ tooltip: "Combinar celdas",
287
+ },
278
288
  comment: {
279
289
  tooltip: "Añadir comentario",
280
290
  },
@@ -328,6 +338,10 @@ export const es = {
328
338
  reactions: {
329
339
  reacted_by: "Reaccionado por",
330
340
  },
341
+ sidebar: {
342
+ marked_as_resolved: "Marcado como resuelto",
343
+ more_replies: (count) => `${count} respuestas más`,
344
+ },
331
345
  },
332
346
  generic: {
333
347
  ctrl_shortcut: "Ctrl",
@@ -364,6 +364,10 @@ export const fr: Dictionary = {
364
364
  reactions: {
365
365
  reacted_by: "Réagi par",
366
366
  },
367
+ sidebar: {
368
+ marked_as_resolved: "Marqué comme résolu",
369
+ more_replies: (count) => `${count} réponses de plus`,
370
+ },
367
371
  },
368
372
  generic: {
369
373
  ctrl_shortcut: "Ctrl",
@@ -1,4 +1,6 @@
1
- export const hr = {
1
+ import { Dictionary } from "../dictionary.js";
2
+
3
+ export const hr: Dictionary = {
2
4
  slash_menu: {
3
5
  heading: {
4
6
  title: "Naslov 1",
@@ -68,6 +70,12 @@ export const hr = {
68
70
  aliases: ["tablica"],
69
71
  group: "Napredno",
70
72
  },
73
+ code_block: {
74
+ title: "Blok koda",
75
+ subtext: "Blok koda sa sintaksnim isticanjem",
76
+ aliases: ["code", "pre"],
77
+ group: "Osnovni blokovi",
78
+ },
71
79
  page_break: {
72
80
  title: "Prijelom stranice",
73
81
  subtext: "Razdjelnik stranice",
@@ -128,9 +136,6 @@ export const hr = {
128
136
  aliases: ["emoji", "emotikon", "emocija", "lice"],
129
137
  group: "Ostalo",
130
138
  },
131
- comment: {
132
- tooltip: "Dodaj komentar",
133
- },
134
139
  },
135
140
  placeholders: {
136
141
  default: "Unesi tekst ili upiši ‘/’ za naredbe",
@@ -164,6 +169,8 @@ export const hr = {
164
169
  drag_handle: {
165
170
  delete_menuitem: "Ukloni",
166
171
  colors_menuitem: "Boje",
172
+ header_row_menuitem: "Zaglavni redak",
173
+ header_column_menuitem: "Zaglavni stupac",
167
174
  },
168
175
  table_handle: {
169
176
  delete_column_menuitem: "Ukloni stupac",
@@ -172,6 +179,9 @@ export const hr = {
172
179
  add_right_menuitem: "Dodaj stupac desno",
173
180
  add_above_menuitem: "Dodaj redak iznad",
174
181
  add_below_menuitem: "Dodaj redak ispod",
182
+ split_cell_menuitem: "Podijeli ćeliju",
183
+ merge_cells_menuitem: "Spoji ćelije",
184
+ background_color_menuitem: "Boja pozadine",
175
185
  },
176
186
  suggestion_menu: {
177
187
  no_items_title: "Stavke nisu pronađene",
@@ -287,6 +297,9 @@ export const hr = {
287
297
  align_justify: {
288
298
  tooltip: "Poravnaj tekst obostrano",
289
299
  },
300
+ table_cell_merge: {
301
+ tooltip: "Spoji ćelije",
302
+ },
290
303
  comment: {
291
304
  tooltip: "Dodaj komentar",
292
305
  },
@@ -340,6 +353,10 @@ export const hr = {
340
353
  reactions: {
341
354
  reacted_by: "Reagirao/la",
342
355
  },
356
+ sidebar: {
357
+ marked_as_resolved: "Označeno kao riješeno",
358
+ more_replies: (count) => `${count} dodatnih odgovora`,
359
+ },
343
360
  },
344
361
  generic: {
345
362
  ctrl_shortcut: "Ctrl",
@@ -332,6 +332,10 @@ export const is: Dictionary = {
332
332
  reactions: {
333
333
  reacted_by: "Brást við af",
334
334
  },
335
+ sidebar: {
336
+ marked_as_resolved: "Merkt sem leyst",
337
+ more_replies: (count) => `${count} fleiri svör`,
338
+ },
335
339
  },
336
340
  generic: {
337
341
  ctrl_shortcut: "Ctrl",
@@ -1,4 +1,6 @@
1
- export const it = {
1
+ import { Dictionary } from "../dictionary.js";
2
+
3
+ export const it: Dictionary = {
2
4
  slash_menu: {
3
5
  heading: {
4
6
  title: "Intestazione 1",
@@ -155,6 +157,8 @@ export const it = {
155
157
  drag_handle: {
156
158
  delete_menuitem: "Elimina",
157
159
  colors_menuitem: "Colori",
160
+ header_row_menuitem: "Riga intestazione",
161
+ header_column_menuitem: "Colonna intestazione",
158
162
  },
159
163
  table_handle: {
160
164
  delete_column_menuitem: "Elimina colonna",
@@ -163,6 +167,9 @@ export const it = {
163
167
  add_right_menuitem: "Aggiungi colonna a destra",
164
168
  add_above_menuitem: "Aggiungi riga sopra",
165
169
  add_below_menuitem: "Aggiungi riga sotto",
170
+ split_cell_menuitem: "Dividi cella",
171
+ merge_cells_menuitem: "Unisci celle",
172
+ background_color_menuitem: "Colore di sfondo",
166
173
  },
167
174
  suggestion_menu: {
168
175
  no_items_title: "Nessun elemento trovato",
@@ -278,6 +285,9 @@ export const it = {
278
285
  align_justify: {
279
286
  tooltip: "Giustifica testo",
280
287
  },
288
+ table_cell_merge: {
289
+ tooltip: "Unisci celle",
290
+ },
281
291
  comment: {
282
292
  tooltip: "Aggiungi commento",
283
293
  },
@@ -331,6 +341,10 @@ export const it = {
331
341
  reactions: {
332
342
  reacted_by: "Reagito da",
333
343
  },
344
+ sidebar: {
345
+ marked_as_resolved: "Contrassegnato come risolto",
346
+ more_replies: (count) => `${count} altre risposte`,
347
+ },
334
348
  },
335
349
  generic: {
336
350
  ctrl_shortcut: "Ctrl",
@@ -360,6 +360,10 @@ export const ja: Dictionary = {
360
360
  reactions: {
361
361
  reacted_by: "リアクションした人",
362
362
  },
363
+ sidebar: {
364
+ marked_as_resolved: "解決済みとしてマーク",
365
+ more_replies: (count) => `${count} 件の追加返信`,
366
+ },
363
367
  },
364
368
  generic: {
365
369
  ctrl_shortcut: "Ctrl",
@@ -353,6 +353,10 @@ export const ko: Dictionary = {
353
353
  reactions: {
354
354
  reacted_by: "반응한 사람",
355
355
  },
356
+ sidebar: {
357
+ marked_as_resolved: "해결됨으로 표시됨",
358
+ more_replies: (count) => `${count}개의 추가 답글`,
359
+ },
356
360
  },
357
361
  generic: {
358
362
  ctrl_shortcut: "Ctrl",
@@ -339,6 +339,10 @@ export const nl: Dictionary = {
339
339
  reactions: {
340
340
  reacted_by: "Gereageerd door",
341
341
  },
342
+ sidebar: {
343
+ marked_as_resolved: "Gemarkeerd als opgelost",
344
+ more_replies: (count) => `${count} extra reacties`,
345
+ },
342
346
  },
343
347
  generic: {
344
348
  ctrl_shortcut: "Ctrl",
@@ -339,6 +339,10 @@ export const no: Dictionary = {
339
339
  reactions: {
340
340
  reacted_by: "Reagert av",
341
341
  },
342
+ sidebar: {
343
+ marked_as_resolved: "Merket som løst",
344
+ more_replies: (count) => `${count} flere svar`,
345
+ },
342
346
  },
343
347
  generic: {
344
348
  ctrl_shortcut: "Ctrl",
@@ -324,6 +324,10 @@ export const pl: Dictionary = {
324
324
  reactions: {
325
325
  reacted_by: "Zareagowali",
326
326
  },
327
+ sidebar: {
328
+ marked_as_resolved: "Oznaczone jako rozwiązane",
329
+ more_replies: (count) => `${count} więcej odpowiedzi`,
330
+ },
327
331
  },
328
332
  generic: {
329
333
  ctrl_shortcut: "Ctrl",
@@ -332,6 +332,10 @@ export const pt: Dictionary = {
332
332
  reactions: {
333
333
  reacted_by: "Reagido por",
334
334
  },
335
+ sidebar: {
336
+ marked_as_resolved: "Marcado como resolvido",
337
+ more_replies: (count) => `${count} respostas a mais`,
338
+ },
335
339
  },
336
340
  generic: {
337
341
  ctrl_shortcut: "Ctrl",
@@ -367,6 +367,10 @@ export const ru: Dictionary = {
367
367
  reactions: {
368
368
  reacted_by: "Отреагировал(а)",
369
369
  },
370
+ sidebar: {
371
+ marked_as_resolved: "Отмечено как решенное",
372
+ more_replies: (count) => `${count} дополнительных ответов`,
373
+ },
370
374
  },
371
375
  generic: {
372
376
  ctrl_shortcut: "Ctrl",
@@ -364,6 +364,10 @@ export const uk: Dictionary = {
364
364
  reactions: {
365
365
  reacted_by: "Відреагував(ла)",
366
366
  },
367
+ sidebar: {
368
+ marked_as_resolved: "Позначено як вирішене",
369
+ more_replies: (count) => `${count} додаткових відповідей`,
370
+ },
367
371
  },
368
372
  generic: {
369
373
  ctrl_shortcut: "Ctrl",
@@ -339,6 +339,10 @@ export const vi: Dictionary = {
339
339
  reactions: {
340
340
  reacted_by: "Phản ứng bởi",
341
341
  },
342
+ sidebar: {
343
+ marked_as_resolved: "Đã đánh dấu là đã giải quyết",
344
+ more_replies: (count) => `${count} câu trả lời nữa`,
345
+ },
342
346
  },
343
347
  generic: {
344
348
  ctrl_shortcut: "Ctrl",
@@ -373,6 +373,10 @@ export const zh: Dictionary = {
373
373
  reactions: {
374
374
  reacted_by: "已回应",
375
375
  },
376
+ sidebar: {
377
+ marked_as_resolved: "标记为已解决",
378
+ more_replies: (count) => `还有 ${count} 条回复`,
379
+ },
376
380
  },
377
381
  generic: {
378
382
  ctrl_shortcut: "Ctrl",
@@ -97,6 +97,10 @@ export type ThreadData = {
97
97
  * The date when the thread was marked as resolved.
98
98
  */
99
99
  resolvedUpdatedAt?: Date;
100
+ /**
101
+ * The id of the user that marked the thread as resolved.
102
+ */
103
+ resolvedBy?: string;
100
104
  /**
101
105
  * You can use this store any additional information about the thread.
102
106
  */
@@ -3,6 +3,7 @@ import { Editor as TiptapEditor } from "@tiptap/core";
3
3
  import { EditorState, Transaction } from "@tiptap/pm/state";
4
4
  import { PartialBlock } from "../blocks/defaultBlocks.js";
5
5
  import { StyleSchema } from "../schema/index.js";
6
+ import type { BlockNoteEditor } from "./BlockNoteEditor.js";
6
7
  export type BlockNoteTipTapEditorOptions = Partial<Omit<EditorOptions, "content">> & {
7
8
  content: PartialBlock<any, any, any>[];
8
9
  };
@@ -25,5 +26,5 @@ export declare class BlockNoteTipTapEditor extends TiptapEditor {
25
26
  *
26
27
  * @param element DOM element to mount to, ur null / undefined to destroy
27
28
  */
28
- mount: (element?: HTMLElement | null, contentComponent?: any) => void;
29
+ mount: (blockNoteEditor: BlockNoteEditor<any, any, any>, element?: HTMLElement | null, contentComponent?: any) => void;
29
30
  }
@@ -9,8 +9,19 @@ export declare class CommentsPlugin extends EventEmitter<any> {
9
9
  private readonly markType;
10
10
  readonly plugin: Plugin;
11
11
  readonly userStore: UserStore<User>;
12
+ /**
13
+ * Whether a comment is currently being composed
14
+ */
12
15
  private pendingComment;
16
+ /**
17
+ * The currently selected thread id
18
+ */
13
19
  private selectedThreadId;
20
+ /**
21
+ * Store the positions of all threads in the document.
22
+ * this can be used later to implement a floating sidebar
23
+ */
24
+ private threadPositions;
14
25
  private emitStateUpdate;
15
26
  /**
16
27
  * when a thread is resolved or deleted, we need to update the marks to reflect the new state
@@ -23,11 +34,15 @@ export declare class CommentsPlugin extends EventEmitter<any> {
23
34
  onUpdate(callback: (state: {
24
35
  pendingComment: boolean;
25
36
  selectedThreadId: string | undefined;
37
+ threadPositions: Map<string, {
38
+ from: number;
39
+ to: number;
40
+ }>;
26
41
  }) => void): () => void;
27
42
  /**
28
43
  * Set the selected thread
29
44
  */
30
- selectThread(threadId: string | undefined): void;
45
+ selectThread(threadId: string | undefined, scrollToThread?: boolean): void;
31
46
  /**
32
47
  * Start a pending comment (e.g.: when clicking the "Add comment" button)
33
48
  */
@@ -0,0 +1,47 @@
1
+ import { CommentData, ThreadData } from "../types.js";
2
+ import { ThreadStoreAuth } from "./ThreadStoreAuth.js";
3
+ export declare class DefaultThreadStoreAuth extends ThreadStoreAuth {
4
+ private readonly userId;
5
+ private readonly role;
6
+ constructor(userId: string, role: "comment" | "editor");
7
+ /**
8
+ * Auth: should be possible by anyone with comment access
9
+ */
10
+ canCreateThread(): boolean;
11
+ /**
12
+ * Auth: should be possible by anyone with comment access
13
+ */
14
+ canAddComment(_thread: ThreadData): boolean;
15
+ /**
16
+ * Auth: should only be possible by the comment author
17
+ */
18
+ canUpdateComment(comment: CommentData): boolean;
19
+ /**
20
+ * Auth: should be possible by the comment author OR an editor of the document
21
+ */
22
+ canDeleteComment(comment: CommentData): boolean;
23
+ /**
24
+ * Auth: should only be possible by an editor of the document
25
+ */
26
+ canDeleteThread(_thread: ThreadData): boolean;
27
+ /**
28
+ * Auth: should be possible by anyone with comment access
29
+ */
30
+ canResolveThread(_thread: ThreadData): boolean;
31
+ /**
32
+ * Auth: should be possible by anyone with comment access
33
+ */
34
+ canUnresolveThread(_thread: ThreadData): boolean;
35
+ /**
36
+ * Auth: should be possible by anyone with comment access
37
+ *
38
+ * Note: will also check if the user has already reacted with the same emoji. TBD: is that a nice design or should this responsibility be outside of auth?
39
+ */
40
+ canAddReaction(comment: CommentData, emoji?: string): boolean;
41
+ /**
42
+ * Auth: should be possible by anyone with comment access
43
+ *
44
+ * Note: will also check if the user has already reacted with the same emoji. TBD: is that a nice design or should this responsibility be outside of auth?
45
+ */
46
+ canDeleteReaction(comment: CommentData, emoji?: string): boolean;
47
+ }