@blocknote/core 0.25.1 → 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 (65) hide show
  1. package/dist/blocknote.cjs +7 -7
  2. package/dist/blocknote.cjs.map +1 -1
  3. package/dist/blocknote.js +781 -646
  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 +3 -2
  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/ThreadStore.ts +1 -1
  17. package/src/comments/threadstore/yjs/YjsThreadStore.ts +1 -0
  18. package/src/comments/threadstore/yjs/yjsHelpers.ts +3 -1
  19. package/src/comments/types.ts +4 -0
  20. package/src/editor/Block.css +1 -1
  21. package/src/editor/BlockNoteEditor.ts +1 -7
  22. package/src/editor/BlockNoteTipTapEditor.ts +18 -7
  23. package/src/extensions/Comments/CommentMark.ts +0 -1
  24. package/src/extensions/Comments/CommentsPlugin.ts +79 -30
  25. package/src/extensions/SideMenu/dragging.ts +13 -0
  26. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +6 -2
  27. package/src/extensions/TableHandles/TableHandlesPlugin.ts +25 -26
  28. package/src/i18n/locales/ar.ts +4 -0
  29. package/src/i18n/locales/de.ts +15 -1
  30. package/src/i18n/locales/en.ts +4 -0
  31. package/src/i18n/locales/es.ts +15 -1
  32. package/src/i18n/locales/fr.ts +4 -0
  33. package/src/i18n/locales/hr.ts +21 -4
  34. package/src/i18n/locales/is.ts +4 -0
  35. package/src/i18n/locales/it.ts +15 -1
  36. package/src/i18n/locales/ja.ts +4 -0
  37. package/src/i18n/locales/ko.ts +4 -0
  38. package/src/i18n/locales/nl.ts +4 -0
  39. package/src/i18n/locales/no.ts +4 -0
  40. package/src/i18n/locales/pl.ts +4 -0
  41. package/src/i18n/locales/pt.ts +4 -0
  42. package/src/i18n/locales/ru.ts +4 -0
  43. package/src/i18n/locales/uk.ts +4 -0
  44. package/src/i18n/locales/vi.ts +4 -0
  45. package/src/i18n/locales/zh.ts +4 -0
  46. package/types/src/comments/threadstore/ThreadStore.d.ts +1 -1
  47. package/types/src/comments/types.d.ts +4 -0
  48. package/types/src/editor/BlockNoteTipTapEditor.d.ts +2 -1
  49. package/types/src/extensions/Comments/CommentsPlugin.d.ts +16 -1
  50. package/types/src/extensions/Comments/threadstore/DefaultThreadStoreAuth.d.ts +47 -0
  51. package/types/src/extensions/Comments/threadstore/ThreadStore.d.ts +121 -0
  52. package/types/src/extensions/Comments/threadstore/ThreadStoreAuth.d.ts +12 -0
  53. package/types/src/extensions/Comments/threadstore/TipTapThreadStore.d.ts +97 -0
  54. package/types/src/extensions/Comments/threadstore/yjs/RESTYjsThreadStore.d.ts +83 -0
  55. package/types/src/extensions/Comments/threadstore/yjs/YjsThreadStore.d.ts +79 -0
  56. package/types/src/extensions/Comments/threadstore/yjs/YjsThreadStore.test.d.ts +1 -0
  57. package/types/src/extensions/Comments/threadstore/yjs/YjsThreadStoreBase.d.ts +15 -0
  58. package/types/src/extensions/Comments/threadstore/yjs/yjsHelpers.d.ts +13 -0
  59. package/types/src/extensions/Comments/types.d.ts +109 -0
  60. package/types/src/i18n/locales/de.d.ts +2 -304
  61. package/types/src/i18n/locales/en.d.ts +4 -0
  62. package/types/src/i18n/locales/es.d.ts +2 -269
  63. package/types/src/i18n/locales/hr.d.ts +2 -266
  64. package/types/src/i18n/locales/it.d.ts +2 -269
  65. package/types/src/models/User.d.ts +5 -0
@@ -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",
@@ -22,7 +22,7 @@ export declare abstract class ThreadStore {
22
22
  head: number;
23
23
  anchor: number;
24
24
  };
25
- yjs: {
25
+ yjs?: {
26
26
  head: any;
27
27
  anchor: any;
28
28
  };
@@ -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
+ }
@@ -0,0 +1,121 @@
1
+ import { CommentBody, CommentData, ThreadData } from "../types.js";
2
+ import { ThreadStoreAuth } from "./ThreadStoreAuth.js";
3
+ /**
4
+ * ThreadStore is an abstract class that defines the interface
5
+ * to read / add / update / delete threads and comments.
6
+ */
7
+ export declare abstract class ThreadStore {
8
+ readonly auth: ThreadStoreAuth;
9
+ constructor(auth: ThreadStoreAuth);
10
+ /**
11
+ * A "thread" in the ThreadStore only contains information about the content
12
+ * of the thread / comments. It does not contain information about the position.
13
+ *
14
+ * This function can be implemented to store the thread in the document (by creating a mark)
15
+ * If not implemented, default behavior will apply (creating the mark via TipTap)
16
+ * See CommentsPlugin.ts for more details.
17
+ */
18
+ abstract addThreadToDocument?(options: {
19
+ threadId: string;
20
+ selection: {
21
+ prosemirror: {
22
+ head: number;
23
+ anchor: number;
24
+ };
25
+ yjs: {
26
+ head: any;
27
+ anchor: any;
28
+ };
29
+ };
30
+ }): Promise<void>;
31
+ /**
32
+ * Creates a new thread with an initial comment.
33
+ */
34
+ abstract createThread(options: {
35
+ initialComment: {
36
+ body: CommentBody;
37
+ metadata?: any;
38
+ };
39
+ metadata?: any;
40
+ }): Promise<ThreadData>;
41
+ /**
42
+ * Adds a comment to a thread.
43
+ */
44
+ abstract addComment(options: {
45
+ comment: {
46
+ body: CommentBody;
47
+ metadata?: any;
48
+ };
49
+ threadId: string;
50
+ }): Promise<CommentData>;
51
+ /**
52
+ * Updates a comment in a thread.
53
+ */
54
+ abstract updateComment(options: {
55
+ comment: {
56
+ body: CommentBody;
57
+ metadata?: any;
58
+ };
59
+ threadId: string;
60
+ commentId: string;
61
+ }): Promise<void>;
62
+ /**
63
+ * Deletes a comment from a thread.
64
+ */
65
+ abstract deleteComment(options: {
66
+ threadId: string;
67
+ commentId: string;
68
+ }): Promise<void>;
69
+ /**
70
+ * Deletes a thread.
71
+ */
72
+ abstract deleteThread(options: {
73
+ threadId: string;
74
+ }): Promise<void>;
75
+ /**
76
+ * Marks a thread as resolved.
77
+ */
78
+ abstract resolveThread(options: {
79
+ threadId: string;
80
+ }): Promise<void>;
81
+ /**
82
+ * Marks a thread as unresolved.
83
+ */
84
+ abstract unresolveThread(options: {
85
+ threadId: string;
86
+ }): Promise<void>;
87
+ /**
88
+ * Adds a reaction to a comment.
89
+ *
90
+ * Auth: should be possible by anyone with comment access
91
+ */
92
+ abstract addReaction(options: {
93
+ threadId: string;
94
+ commentId: string;
95
+ emoji: string;
96
+ }): Promise<void>;
97
+ /**
98
+ * Deletes a reaction from a comment.
99
+ *
100
+ * Auth: should be possible by the reaction author
101
+ */
102
+ abstract deleteReaction(options: {
103
+ threadId: string;
104
+ commentId: string;
105
+ emoji: string;
106
+ }): Promise<void>;
107
+ /**
108
+ * Retrieve data for a specific thread.
109
+ */
110
+ abstract getThread(threadId: string): ThreadData;
111
+ /**
112
+ * Retrieve all threads.
113
+ */
114
+ abstract getThreads(): Map<string, ThreadData>;
115
+ /**
116
+ * Subscribe to changes in the thread store.
117
+ *
118
+ * @returns a function to unsubscribe from the thread store
119
+ */
120
+ abstract subscribe(cb: (threads: Map<string, ThreadData>) => void): () => void;
121
+ }
@@ -0,0 +1,12 @@
1
+ import { CommentData, ThreadData } from "../types.js";
2
+ export declare abstract class ThreadStoreAuth {
3
+ abstract canCreateThread(): boolean;
4
+ abstract canAddComment(thread: ThreadData): boolean;
5
+ abstract canUpdateComment(comment: CommentData): boolean;
6
+ abstract canDeleteComment(comment: CommentData): boolean;
7
+ abstract canDeleteThread(thread: ThreadData): boolean;
8
+ abstract canResolveThread(thread: ThreadData): boolean;
9
+ abstract canUnresolveThread(thread: ThreadData): boolean;
10
+ abstract canAddReaction(comment: CommentData, emoji?: string): boolean;
11
+ abstract canDeleteReaction(comment: CommentData, emoji?: string): boolean;
12
+ }
@@ -0,0 +1,97 @@
1
+ import type { TiptapCollabProvider } from "@hocuspocus/provider";
2
+ import { CommentBody, ThreadData } from "../types.js";
3
+ import { ThreadStore } from "./ThreadStore.js";
4
+ import { ThreadStoreAuth } from "./ThreadStoreAuth.js";
5
+ /**
6
+ * The `TiptapThreadStore` integrates with Tiptap's collaboration provider for comment management.
7
+ * You can pass a `TiptapCollabProvider` to the constructor which takes care of storing the comments.
8
+ *
9
+ * Under the hood, this actually works similarly to the `YjsThreadStore` implementation. (comments are stored in the Yjs document)
10
+ */
11
+ export declare class TiptapThreadStore extends ThreadStore {
12
+ private readonly userId;
13
+ private readonly provider;
14
+ constructor(userId: string, provider: TiptapCollabProvider, auth: ThreadStoreAuth);
15
+ /**
16
+ * Creates a new thread with an initial comment.
17
+ */
18
+ createThread(options: {
19
+ initialComment: {
20
+ body: CommentBody;
21
+ metadata?: any;
22
+ };
23
+ metadata?: any;
24
+ }): Promise<ThreadData>;
25
+ addThreadToDocument: undefined;
26
+ /**
27
+ * Adds a comment to a thread.
28
+ */
29
+ addComment(options: {
30
+ comment: {
31
+ body: CommentBody;
32
+ metadata?: any;
33
+ };
34
+ threadId: string;
35
+ }): Promise<CommentBody>;
36
+ /**
37
+ * Updates a comment in a thread.
38
+ */
39
+ updateComment(options: {
40
+ comment: {
41
+ body: CommentBody;
42
+ metadata?: any;
43
+ };
44
+ threadId: string;
45
+ commentId: string;
46
+ }): Promise<void>;
47
+ private tiptapCommentToCommentData;
48
+ private tiptapThreadToThreadData;
49
+ /**
50
+ * Deletes a comment from a thread.
51
+ */
52
+ deleteComment(options: {
53
+ threadId: string;
54
+ commentId: string;
55
+ }): Promise<void>;
56
+ /**
57
+ * Deletes a thread.
58
+ */
59
+ deleteThread(options: {
60
+ threadId: string;
61
+ }): Promise<void>;
62
+ /**
63
+ * Marks a thread as resolved.
64
+ */
65
+ resolveThread(options: {
66
+ threadId: string;
67
+ }): Promise<void>;
68
+ /**
69
+ * Marks a thread as unresolved.
70
+ */
71
+ unresolveThread(options: {
72
+ threadId: string;
73
+ }): Promise<void>;
74
+ /**
75
+ * Adds a reaction to a comment.
76
+ *
77
+ * Auth: should be possible by anyone with comment access
78
+ */
79
+ addReaction(options: {
80
+ threadId: string;
81
+ commentId: string;
82
+ emoji: string;
83
+ }): Promise<void>;
84
+ /**
85
+ * Deletes a reaction from a comment.
86
+ *
87
+ * Auth: should be possible by the reaction author
88
+ */
89
+ deleteReaction(options: {
90
+ threadId: string;
91
+ commentId: string;
92
+ emoji: string;
93
+ }): Promise<void>;
94
+ getThread(threadId: string): ThreadData;
95
+ getThreads(): Map<string, ThreadData>;
96
+ subscribe(cb: (threads: Map<string, ThreadData>) => void): () => void;
97
+ }
@@ -0,0 +1,83 @@
1
+ import * as Y from "yjs";
2
+ import { CommentBody } from "../../types.js";
3
+ import { ThreadStoreAuth } from "../ThreadStoreAuth.js";
4
+ import { YjsThreadStoreBase } from "./YjsThreadStoreBase.js";
5
+ /**
6
+ * This is a REST-based implementation of the YjsThreadStoreBase.
7
+ * It Reads data directly from the underlying document (same as YjsThreadStore),
8
+ * but for Writes, it sends data to a REST API that should:
9
+ * - check the user has the correct permissions to make the desired changes
10
+ * - apply the updates to the underlying Yjs document
11
+ *
12
+ * (see https://github.com/TypeCellOS/BlockNote-demo-nextjs-hocuspocus)
13
+ *
14
+ * The reason we still use the Yjs document as underlying storage is that it makes it easy to
15
+ * sync updates in real-time to other collaborators.
16
+ * (but technically, you could also implement a different storage altogether
17
+ * and not store the thread related data in the Yjs document)
18
+ */
19
+ export declare class RESTYjsThreadStore extends YjsThreadStoreBase {
20
+ private readonly BASE_URL;
21
+ private readonly headers;
22
+ constructor(BASE_URL: string, headers: Record<string, string>, threadsYMap: Y.Map<any>, auth: ThreadStoreAuth);
23
+ private doRequest;
24
+ addThreadToDocument: (options: {
25
+ threadId: string;
26
+ selection: {
27
+ prosemirror: {
28
+ head: number;
29
+ anchor: number;
30
+ };
31
+ yjs: {
32
+ head: any;
33
+ anchor: any;
34
+ };
35
+ };
36
+ }) => Promise<any>;
37
+ createThread: (options: {
38
+ initialComment: {
39
+ body: CommentBody;
40
+ metadata?: any;
41
+ };
42
+ metadata?: any;
43
+ }) => Promise<any>;
44
+ addComment: (options: {
45
+ comment: {
46
+ body: CommentBody;
47
+ metadata?: any;
48
+ };
49
+ threadId: string;
50
+ }) => Promise<any>;
51
+ updateComment: (options: {
52
+ comment: {
53
+ body: CommentBody;
54
+ metadata?: any;
55
+ };
56
+ threadId: string;
57
+ commentId: string;
58
+ }) => Promise<any>;
59
+ deleteComment: (options: {
60
+ threadId: string;
61
+ commentId: string;
62
+ softDelete?: boolean;
63
+ }) => Promise<any>;
64
+ deleteThread: (options: {
65
+ threadId: string;
66
+ }) => Promise<any>;
67
+ resolveThread: (options: {
68
+ threadId: string;
69
+ }) => Promise<any>;
70
+ unresolveThread: (options: {
71
+ threadId: string;
72
+ }) => Promise<any>;
73
+ addReaction: (options: {
74
+ threadId: string;
75
+ commentId: string;
76
+ emoji: string;
77
+ }) => Promise<any>;
78
+ deleteReaction: (options: {
79
+ threadId: string;
80
+ commentId: string;
81
+ emoji: string;
82
+ }) => Promise<any>;
83
+ }
@@ -0,0 +1,79 @@
1
+ import * as Y from "yjs";
2
+ import { CommentBody, ThreadData } from "../../types.js";
3
+ import { ThreadStoreAuth } from "../ThreadStoreAuth.js";
4
+ import { YjsThreadStoreBase } from "./YjsThreadStoreBase.js";
5
+ /**
6
+ * This is a Yjs-based implementation of the ThreadStore interface.
7
+ *
8
+ * It reads and writes thread / comments information directly to the underlying Yjs Document.
9
+ *
10
+ * @important While this is the easiest to add to your app, there are two challenges:
11
+ * - The user needs to be able to write to the Yjs document to store the information.
12
+ * So a user without write access to the Yjs document cannot leave any comments.
13
+ * - Even with write access, the operations are not secure. Unless your Yjs server
14
+ * guards against malicious operations, it's technically possible for one user to make changes to another user's comments, etc.
15
+ * (even though these options are not visible in the UI, a malicious user can make unauthorized changes to the underlying Yjs document)
16
+ */
17
+ export declare class YjsThreadStore extends YjsThreadStoreBase {
18
+ private readonly userId;
19
+ constructor(userId: string, threadsYMap: Y.Map<any>, auth: ThreadStoreAuth);
20
+ private transact;
21
+ createThread: (options: {
22
+ initialComment: {
23
+ body: CommentBody;
24
+ metadata?: any;
25
+ };
26
+ metadata?: any;
27
+ }) => Promise<ThreadData>;
28
+ addThreadToDocument: undefined;
29
+ addComment: (options: {
30
+ comment: {
31
+ body: CommentBody;
32
+ metadata?: any;
33
+ };
34
+ threadId: string;
35
+ }) => Promise<{
36
+ type: "comment";
37
+ id: string;
38
+ userId: string;
39
+ createdAt: Date;
40
+ updatedAt: Date;
41
+ reactions: import("../../types.js").CommentReactionData[];
42
+ metadata: any;
43
+ } & {
44
+ deletedAt?: undefined;
45
+ body: any;
46
+ }>;
47
+ updateComment: (options: {
48
+ comment: {
49
+ body: CommentBody;
50
+ metadata?: any;
51
+ };
52
+ threadId: string;
53
+ commentId: string;
54
+ }) => Promise<void>;
55
+ deleteComment: (options: {
56
+ threadId: string;
57
+ commentId: string;
58
+ softDelete?: boolean | undefined;
59
+ }) => Promise<void>;
60
+ deleteThread: (options: {
61
+ threadId: string;
62
+ }) => Promise<void>;
63
+ resolveThread: (options: {
64
+ threadId: string;
65
+ }) => Promise<void>;
66
+ unresolveThread: (options: {
67
+ threadId: string;
68
+ }) => Promise<void>;
69
+ addReaction: (options: {
70
+ threadId: string;
71
+ commentId: string;
72
+ emoji: string;
73
+ }) => Promise<void>;
74
+ deleteReaction: (options: {
75
+ threadId: string;
76
+ commentId: string;
77
+ emoji: string;
78
+ }) => Promise<void>;
79
+ }
@@ -0,0 +1,15 @@
1
+ import * as Y from "yjs";
2
+ import { ThreadData } from "../../types.js";
3
+ import { ThreadStore } from "../ThreadStore.js";
4
+ import { ThreadStoreAuth } from "../ThreadStoreAuth.js";
5
+ /**
6
+ * This is an abstract class that only implements the READ methods required by the ThreadStore interface.
7
+ * The data is read from a Yjs Map.
8
+ */
9
+ export declare abstract class YjsThreadStoreBase extends ThreadStore {
10
+ protected readonly threadsYMap: Y.Map<any>;
11
+ constructor(threadsYMap: Y.Map<any>, auth: ThreadStoreAuth);
12
+ getThread(threadId: string): ThreadData;
13
+ getThreads(): Map<string, ThreadData>;
14
+ subscribe(cb: (threads: Map<string, ThreadData>) => void): () => void;
15
+ }
@@ -0,0 +1,13 @@
1
+ import * as Y from "yjs";
2
+ import { CommentData, ThreadData } from "../../types.js";
3
+ export declare function commentToYMap(comment: CommentData): Y.Map<any>;
4
+ export declare function threadToYMap(thread: ThreadData): Y.Map<unknown>;
5
+ type SingleUserCommentReactionData = {
6
+ emoji: string;
7
+ createdAt: Date;
8
+ userId: string;
9
+ };
10
+ export declare function yMapToReaction(yMap: Y.Map<any>): SingleUserCommentReactionData;
11
+ export declare function yMapToComment(yMap: Y.Map<any>): CommentData;
12
+ export declare function yMapToThread(yMap: Y.Map<any>): ThreadData;
13
+ export {};