@hocuspocus/extension-throttle 2.13.7 → 2.14.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.
|
@@ -88,6 +88,8 @@ export declare class HocuspocusProvider extends EventEmitter {
|
|
|
88
88
|
intervals: any;
|
|
89
89
|
isConnected: boolean;
|
|
90
90
|
constructor(configuration: HocuspocusProviderConfiguration);
|
|
91
|
+
boundDocumentUpdateHandler: (update: Uint8Array, origin: any) => void;
|
|
92
|
+
boundAwarenessUpdateHandler: ({ added, updated, removed }: any, origin: any) => void;
|
|
91
93
|
boundBroadcastChannelSubscriber: (data: ArrayBuffer) => void;
|
|
92
94
|
boundPageHide: () => void;
|
|
93
95
|
boundOnOpen: (event: Event) => Promise<void>;
|
|
@@ -2,8 +2,13 @@ import type { AbstractType, YArrayEvent } from 'yjs';
|
|
|
2
2
|
import * as Y from 'yjs';
|
|
3
3
|
import { HocuspocusProvider, HocuspocusProviderConfiguration } from './HocuspocusProvider.js';
|
|
4
4
|
import { TiptapCollabProviderWebsocket } from './TiptapCollabProviderWebsocket.js';
|
|
5
|
-
import type { TCollabComment, TCollabThread, THistoryVersion } from './types.js';
|
|
6
|
-
export type TiptapCollabProviderConfiguration = Required<Pick<HocuspocusProviderConfiguration, 'name'>> & Partial<HocuspocusProviderConfiguration> & (Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'websocketProvider'>> | Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'appId'>> | Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'baseUrl'>>) & Pick<AdditionalTiptapCollabProviderConfiguration, 'user'
|
|
5
|
+
import type { DeleteCommentOptions, TCollabComment, TCollabThread, THistoryVersion } from './types.js';
|
|
6
|
+
export type TiptapCollabProviderConfiguration = Required<Pick<HocuspocusProviderConfiguration, 'name'>> & Partial<HocuspocusProviderConfiguration> & (Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'websocketProvider'>> | Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'appId'>> | Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'baseUrl'>>) & Pick<AdditionalTiptapCollabProviderConfiguration, 'user'> & {
|
|
7
|
+
/**
|
|
8
|
+
* Pass `true` if you want to delete a thread when the first comment is deleted.
|
|
9
|
+
*/
|
|
10
|
+
deleteThreadOnFirstCommentDelete?: boolean;
|
|
11
|
+
};
|
|
7
12
|
export interface AdditionalTiptapCollabProviderConfiguration {
|
|
8
13
|
/**
|
|
9
14
|
* A Hocuspocus Cloud App ID, get one here: https://cloud.tiptap.dev
|
|
@@ -43,21 +48,103 @@ export declare class TiptapCollabProvider extends HocuspocusProvider {
|
|
|
43
48
|
isAutoVersioning(): boolean;
|
|
44
49
|
enableAutoVersioning(): 1;
|
|
45
50
|
disableAutoVersioning(): 0;
|
|
51
|
+
/**
|
|
52
|
+
* Returns all users in the document as Y.Map objects
|
|
53
|
+
* @returns An array of Y.Map objects
|
|
54
|
+
*/
|
|
46
55
|
private getYThreads;
|
|
56
|
+
/**
|
|
57
|
+
* Finds all threads in the document and returns them as JSON objects
|
|
58
|
+
* @returns An array of threads as JSON objects
|
|
59
|
+
*/
|
|
47
60
|
getThreads<Data, CommentData>(): TCollabThread<Data, CommentData>[];
|
|
61
|
+
/**
|
|
62
|
+
* Find the index of a thread by its id
|
|
63
|
+
* @param id The thread id
|
|
64
|
+
* @returns The index of the thread or null if not found
|
|
65
|
+
*/
|
|
48
66
|
private getThreadIndex;
|
|
67
|
+
/**
|
|
68
|
+
* Gets a single thread by its id
|
|
69
|
+
* @param id The thread id
|
|
70
|
+
* @returns The thread as a JSON object or null if not found
|
|
71
|
+
*/
|
|
49
72
|
getThread<Data, CommentData>(id: string): TCollabThread<Data, CommentData> | null;
|
|
73
|
+
/**
|
|
74
|
+
* Gets a single thread by its id as a Y.Map object
|
|
75
|
+
* @param id The thread id
|
|
76
|
+
* @returns The thread as a Y.Map object or null if not found
|
|
77
|
+
*/
|
|
50
78
|
private getYThread;
|
|
51
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Create a new thread
|
|
81
|
+
* @param data The thread data
|
|
82
|
+
* @returns The created thread
|
|
83
|
+
*/
|
|
84
|
+
createThread(data: Omit<TCollabThread, 'id' | 'createdAt' | 'updatedAt' | 'comments' | 'deletedComments'>): TCollabThread;
|
|
85
|
+
/**
|
|
86
|
+
* Update a specific thread
|
|
87
|
+
* @param id The thread id
|
|
88
|
+
* @param data New data for the thread
|
|
89
|
+
* @returns The updated thread or null if the thread is not found
|
|
90
|
+
*/
|
|
52
91
|
updateThread(id: TCollabThread['id'], data: Partial<Pick<TCollabThread, 'data'> & {
|
|
53
92
|
resolvedAt: TCollabThread['resolvedAt'] | null;
|
|
54
93
|
}>): TCollabThread;
|
|
94
|
+
/**
|
|
95
|
+
* Delete a specific thread and all its comments
|
|
96
|
+
* @param id The thread id
|
|
97
|
+
* @returns void
|
|
98
|
+
*/
|
|
55
99
|
deleteThread(id: TCollabThread['id']): void;
|
|
56
|
-
|
|
57
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Returns comments from a thread, either deleted or not
|
|
102
|
+
* @param threadId The thread id
|
|
103
|
+
* @param includeDeleted If you want to include deleted comments, defaults to `false`
|
|
104
|
+
* @returns The comments or null if the thread is not found
|
|
105
|
+
*/
|
|
106
|
+
getThreadComments(threadId: TCollabThread['id'], includeDeleted?: boolean): TCollabComment[] | null;
|
|
107
|
+
/**
|
|
108
|
+
* Get a single comment from a specific thread
|
|
109
|
+
* @param threadId The thread id
|
|
110
|
+
* @param commentId The comment id
|
|
111
|
+
* @param includeDeleted If you want to include deleted comments in the search
|
|
112
|
+
* @returns The comment or null if not found
|
|
113
|
+
*/
|
|
114
|
+
getThreadComment(threadId: TCollabThread['id'], commentId: TCollabComment['id'], includeDeleted?: boolean): TCollabComment | null;
|
|
115
|
+
/**
|
|
116
|
+
* Adds a comment to a thread
|
|
117
|
+
* @param threadId The thread id
|
|
118
|
+
* @param data The comment data
|
|
119
|
+
* @returns The updated thread or null if the thread is not found
|
|
120
|
+
* @example addComment('123', { content: 'Hello world', data: { author: 'Maria Doe' } })
|
|
121
|
+
*/
|
|
58
122
|
addComment(threadId: TCollabThread['id'], data: Omit<TCollabComment, 'id' | 'updatedAt' | 'createdAt'>): TCollabThread;
|
|
123
|
+
/**
|
|
124
|
+
* Update a comment in a thread
|
|
125
|
+
* @param threadId The thread id
|
|
126
|
+
* @param commentId The comment id
|
|
127
|
+
* @param data The new comment data
|
|
128
|
+
* @returns The updated thread or null if the thread or comment is not found
|
|
129
|
+
* @example updateComment('123', { content: 'The new content', data: { attachments: ['file1.jpg'] }})
|
|
130
|
+
*/
|
|
59
131
|
updateComment(threadId: TCollabThread['id'], commentId: TCollabComment['id'], data: Partial<Pick<TCollabComment, 'data' | 'content'>>): TCollabThread;
|
|
60
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Deletes a comment from a thread
|
|
134
|
+
* @param threadId The thread id
|
|
135
|
+
* @param commentId The comment id
|
|
136
|
+
* @param options A set of options that control how the comment is deleted
|
|
137
|
+
* @returns The updated thread or null if the thread or comment is not found
|
|
138
|
+
*/
|
|
139
|
+
deleteComment(threadId: TCollabThread['id'], commentId: TCollabComment['id'], options: DeleteCommentOptions): TCollabThread | null | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* Start watching threads for changes
|
|
142
|
+
* @param callback The callback function to be called when a thread changes
|
|
143
|
+
*/
|
|
61
144
|
watchThreads(callback: () => void): void;
|
|
145
|
+
/**
|
|
146
|
+
* Stop watching threads for changes
|
|
147
|
+
* @param callback The callback function to be removed
|
|
148
|
+
*/
|
|
62
149
|
unwatchThreads(callback: () => void): void;
|
|
63
150
|
}
|
|
@@ -90,12 +90,14 @@ export type TCollabThread<Data = any, CommentData = any> = {
|
|
|
90
90
|
updatedAt: number;
|
|
91
91
|
resolvedAt?: string;
|
|
92
92
|
comments: TCollabComment<CommentData>[];
|
|
93
|
+
deletedComments: TCollabComment<CommentData>[];
|
|
93
94
|
data: Data;
|
|
94
95
|
};
|
|
95
96
|
export type TCollabComment<Data = any> = {
|
|
96
97
|
id: string;
|
|
97
|
-
createdAt:
|
|
98
|
-
updatedAt:
|
|
98
|
+
createdAt: string;
|
|
99
|
+
updatedAt: string;
|
|
100
|
+
deletedAt?: string;
|
|
99
101
|
data: Data;
|
|
100
102
|
content: any;
|
|
101
103
|
};
|
|
@@ -144,3 +146,13 @@ export type THistoryDocumentRevertedEvent = {
|
|
|
144
146
|
event: 'document.reverted';
|
|
145
147
|
version: number;
|
|
146
148
|
};
|
|
149
|
+
export type DeleteCommentOptions = {
|
|
150
|
+
/**
|
|
151
|
+
* If `true`, the thread will also be deleted if the deleted comment was the first comment in the thread.
|
|
152
|
+
*/
|
|
153
|
+
deleteThread?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* If `true`, will remove the content of the deleted comment
|
|
156
|
+
*/
|
|
157
|
+
deleteContent?: boolean;
|
|
158
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-throttle",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"description": "hocuspocus throttle extension",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@hocuspocus/server": "^2.
|
|
31
|
+
"@hocuspocus/server": "^2.14.0"
|
|
32
32
|
},
|
|
33
33
|
"gitHead": "b3454a4ca289a84ddfb7fa5607a2d4b8d5c37e9d"
|
|
34
34
|
}
|