@hocuspocus/extension-database 2.14.0 → 2.15.1-rc.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.
|
@@ -2,7 +2,7 @@ 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
|
|
5
|
+
import { type DeleteCommentOptions, type DeleteThreadOptions, type GetThreadsOptions, type TCollabComment, type TCollabThread, type THistoryVersion } from './types.js';
|
|
6
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
7
|
/**
|
|
8
8
|
* Pass `true` if you want to delete a thread when the first comment is deleted.
|
|
@@ -55,9 +55,10 @@ export declare class TiptapCollabProvider extends HocuspocusProvider {
|
|
|
55
55
|
private getYThreads;
|
|
56
56
|
/**
|
|
57
57
|
* Finds all threads in the document and returns them as JSON objects
|
|
58
|
+
* @options Options to control the output of the threads (e.g. include deleted threads)
|
|
58
59
|
* @returns An array of threads as JSON objects
|
|
59
60
|
*/
|
|
60
|
-
getThreads<Data, CommentData>(): TCollabThread<Data, CommentData>[];
|
|
61
|
+
getThreads<Data, CommentData>(options?: GetThreadsOptions): TCollabThread<Data, CommentData>[];
|
|
61
62
|
/**
|
|
62
63
|
* Find the index of a thread by its id
|
|
63
64
|
* @param id The thread id
|
|
@@ -81,7 +82,7 @@ export declare class TiptapCollabProvider extends HocuspocusProvider {
|
|
|
81
82
|
* @param data The thread data
|
|
82
83
|
* @returns The created thread
|
|
83
84
|
*/
|
|
84
|
-
createThread(data: Omit<TCollabThread, 'id' | 'createdAt' | 'updatedAt' | 'comments' | 'deletedComments'>): TCollabThread;
|
|
85
|
+
createThread(data: Omit<TCollabThread, 'id' | 'createdAt' | 'updatedAt' | 'deletedAt' | 'comments' | 'deletedComments'>): TCollabThread;
|
|
85
86
|
/**
|
|
86
87
|
* Update a specific thread
|
|
87
88
|
* @param id The thread id
|
|
@@ -92,11 +93,21 @@ export declare class TiptapCollabProvider extends HocuspocusProvider {
|
|
|
92
93
|
resolvedAt: TCollabThread['resolvedAt'] | null;
|
|
93
94
|
}>): TCollabThread;
|
|
94
95
|
/**
|
|
95
|
-
*
|
|
96
|
+
* Handle the deletion of a thread. By default, the thread and it's comments are not deleted, but marked as deleted
|
|
97
|
+
* via the `deletedAt` property. Forceful deletion can be enabled by setting the `force` option to `true`.
|
|
98
|
+
*
|
|
99
|
+
* If you only want to delete the comments of a thread, you can set the `deleteComments` option to `true`.
|
|
100
|
+
* @param id The thread id
|
|
101
|
+
* @param options A set of options that control how the thread is deleted
|
|
102
|
+
* @returns The deleted thread or null if the thread is not found
|
|
103
|
+
*/
|
|
104
|
+
deleteThread(id: TCollabThread['id'], options?: DeleteThreadOptions): TCollabThread | null | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Tries to restore a deleted thread
|
|
96
107
|
* @param id The thread id
|
|
97
|
-
* @returns
|
|
108
|
+
* @returns The restored thread or null if the thread is not found
|
|
98
109
|
*/
|
|
99
|
-
|
|
110
|
+
restoreThread(id: TCollabThread['id']): TCollabThread | null;
|
|
100
111
|
/**
|
|
101
112
|
* Returns comments from a thread, either deleted or not
|
|
102
113
|
* @param threadId The thread id
|
|
@@ -88,6 +88,7 @@ export type TCollabThread<Data = any, CommentData = any> = {
|
|
|
88
88
|
id: string;
|
|
89
89
|
createdAt: number;
|
|
90
90
|
updatedAt: number;
|
|
91
|
+
deletedAt: number | null;
|
|
91
92
|
resolvedAt?: string;
|
|
92
93
|
comments: TCollabComment<CommentData>[];
|
|
93
94
|
deletedComments: TCollabComment<CommentData>[];
|
|
@@ -156,3 +157,30 @@ export type DeleteCommentOptions = {
|
|
|
156
157
|
*/
|
|
157
158
|
deleteContent?: boolean;
|
|
158
159
|
};
|
|
160
|
+
export type DeleteThreadOptions = {
|
|
161
|
+
/**
|
|
162
|
+
* If `true`, will remove the comments on the thread,
|
|
163
|
+
* otherwise will only mark the thread as deleted
|
|
164
|
+
* and keep the comments
|
|
165
|
+
* @default false
|
|
166
|
+
*/
|
|
167
|
+
deleteComments?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* If `true`, will forcefully remove the thread and all comments,
|
|
170
|
+
* otherwise will only mark the thread as deleted
|
|
171
|
+
* and keep the comments
|
|
172
|
+
* @default false
|
|
173
|
+
*/
|
|
174
|
+
force?: boolean;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* The type of thread
|
|
178
|
+
*/
|
|
179
|
+
export type ThreadType = 'archived' | 'unarchived';
|
|
180
|
+
export type GetThreadsOptions = {
|
|
181
|
+
/**
|
|
182
|
+
* The types of threads to get
|
|
183
|
+
* @default ['unarchived']
|
|
184
|
+
*/
|
|
185
|
+
types?: Array<ThreadType>;
|
|
186
|
+
};
|
|
@@ -95,7 +95,7 @@ export declare class Hocuspocus {
|
|
|
95
95
|
* Runs the given callback after each hook.
|
|
96
96
|
*/
|
|
97
97
|
hooks<T extends HookName>(name: T, payload: HookPayloadByName[T], callback?: Function | null): Promise<any>;
|
|
98
|
-
unloadDocument(document: Document):
|
|
98
|
+
unloadDocument(document: Document): Promise<any>;
|
|
99
99
|
enableDebugging(): void;
|
|
100
100
|
enableMessageLogging(): void;
|
|
101
101
|
disableLogging(): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { HocuspocusProvider, HocuspocusProviderConfiguration, HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
|
|
1
|
+
import { HocuspocusProvider, HocuspocusProviderConfiguration, HocuspocusProviderWebsocket, HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
|
|
2
2
|
import { Hocuspocus } from '@hocuspocus/server';
|
|
3
|
-
export declare const newHocuspocusProvider: (server: Hocuspocus, options?: Partial<HocuspocusProviderConfiguration>, websocketOptions?: Partial<HocuspocusProviderWebsocketConfiguration
|
|
3
|
+
export declare const newHocuspocusProvider: (server: Hocuspocus, options?: Partial<HocuspocusProviderConfiguration>, websocketOptions?: Partial<HocuspocusProviderWebsocketConfiguration>, websocketProvider?: HocuspocusProviderWebsocket) => HocuspocusProvider;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-database",
|
|
3
3
|
"description": "a generic Hocuspocus persistence driver for the database",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.15.1-rc.0",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"hocuspocus",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@hocuspocus/server": "^2.
|
|
30
|
+
"@hocuspocus/server": "^2.15.1-rc.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"yjs": "^13.6.8"
|