Skip to content

Commit 389cb3c

Browse files
authored
fix: remove @hocuspocus/provider peer dependency by inlining tiptap comment types BLO-1064 (#2564)
1 parent d18a801 commit 389cb3c

File tree

5 files changed

+137
-47
lines changed

5 files changed

+137
-47
lines changed

docs/content/docs/features/collaboration/comments.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ import {
9696
TiptapThreadStore,
9797
DefaultThreadStoreAuth,
9898
} from "@blocknote/core/comments";
99-
import { TiptapCollabProvider } from "@hocuspocus/provider";
99+
import { TiptapCollabProvider } from "@tiptap-pro/provider";
100100

101101
// Create a TiptapCollabProvider (you probably have this already)
102102
const provider = new TiptapCollabProvider({

packages/core/package.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,6 @@
143143
"vite-plugin-eslint": "^1.8.1",
144144
"vitest": "^2.1.9"
145145
},
146-
"peerDependencies": {
147-
"@hocuspocus/provider": "^2.15.2 || ^3.0.0"
148-
},
149-
"peerDependenciesMeta": {
150-
"@hocuspocus/provider": {
151-
"optional": true
152-
}
153-
},
154146
"eslintConfig": {
155147
"extends": [
156148
"../../.eslintrc.json"

packages/core/src/comments/threadstore/TipTapThreadStore.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import type {
2-
TCollabComment,
3-
TCollabThread,
4-
TiptapCollabProvider,
5-
} from "@hocuspocus/provider";
61
import {
72
CommentBody,
83
CommentData,
@@ -11,6 +6,11 @@ import {
116
} from "../types.js";
127
import { ThreadStore } from "./ThreadStore.js";
138
import { ThreadStoreAuth } from "./ThreadStoreAuth.js";
9+
import type {
10+
TCollabComment,
11+
TCollabThread,
12+
TiptapCollabProvider,
13+
} from "./tiptap/types.js";
1414

1515
type ReactionAsTiptapData = {
1616
emoji: string;
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/**
2+
* Tiptap comment types have moved to a private tiptap package and we don't want to create a dependency on it.
3+
* We've extracted the types from https://github.com/ueberdosis/hocuspocus/blob/v2.15.3/packages/provider/src/types.ts
4+
* and added them here.
5+
*/
6+
7+
export type TCollabThread<Data = any, CommentData = any> = {
8+
id: string;
9+
createdAt: number;
10+
updatedAt: number;
11+
deletedAt: number | null;
12+
resolvedAt?: string; // (new Date()).toISOString()
13+
comments: TCollabComment<CommentData>[];
14+
deletedComments: TCollabComment<CommentData>[];
15+
data: Data;
16+
};
17+
18+
export type TCollabComment<Data = any> = {
19+
id: string;
20+
createdAt: string;
21+
updatedAt: string;
22+
deletedAt?: string;
23+
data: Data;
24+
content: any;
25+
};
26+
27+
export type ThreadType = "archived" | "unarchived";
28+
29+
export type GetThreadsOptions = {
30+
/**
31+
* The types of threads to get
32+
* @default ['unarchived']
33+
*/
34+
types?: Array<ThreadType>;
35+
};
36+
37+
export type DeleteCommentOptions = {
38+
/**
39+
* If `true`, the thread will also be deleted if the deleted comment was the first comment in the thread.
40+
*/
41+
deleteThread?: boolean;
42+
43+
/**
44+
* If `true`, will remove the content of the deleted comment
45+
*/
46+
deleteContent?: boolean;
47+
};
48+
49+
export type DeleteThreadOptions = {
50+
/**
51+
* If `true`, will remove the comments on the thread,
52+
* otherwise will only mark the thread as deleted
53+
* and keep the comments
54+
* @default false
55+
*/
56+
deleteComments?: boolean;
57+
58+
/**
59+
* If `true`, will forcefully remove the thread and all comments,
60+
* otherwise will only mark the thread as deleted
61+
* and keep the comments
62+
* @default false
63+
*/
64+
force?: boolean;
65+
};
66+
67+
export type TiptapCollabProvider = {
68+
getThread<Data, CommentData>(
69+
id: string,
70+
): TCollabThread<Data, CommentData> | null;
71+
72+
getThreads<Data, CommentData>(
73+
options?: GetThreadsOptions,
74+
): TCollabThread<Data, CommentData>[];
75+
createThread(
76+
data: Omit<
77+
TCollabThread,
78+
| "id"
79+
| "createdAt"
80+
| "updatedAt"
81+
| "deletedAt"
82+
| "comments"
83+
| "deletedComments"
84+
>,
85+
): TCollabThread;
86+
87+
addComment(
88+
threadId: TCollabThread["id"],
89+
data: Omit<TCollabComment, "id" | "updatedAt" | "createdAt">,
90+
): TCollabThread;
91+
92+
updateComment(
93+
threadId: TCollabThread["id"],
94+
commentId: TCollabComment["id"],
95+
data: Partial<Pick<TCollabComment, "data" | "content">>,
96+
): TCollabThread;
97+
98+
deleteComment(
99+
threadId: TCollabThread["id"],
100+
commentId: TCollabComment["id"],
101+
options?: DeleteCommentOptions,
102+
): TCollabThread;
103+
104+
getThreadComments(
105+
threadId: TCollabThread["id"],
106+
includeDeleted?: boolean,
107+
): TCollabComment[] | null;
108+
109+
getThreadComment(
110+
threadId: TCollabThread["id"],
111+
commentId: TCollabComment["id"],
112+
includeDeleted?: boolean,
113+
): TCollabComment | null;
114+
115+
deleteThread(
116+
id: TCollabThread["id"],
117+
options?: DeleteThreadOptions,
118+
): TCollabThread;
119+
120+
updateThread(
121+
id: TCollabThread["id"],
122+
data: Partial<
123+
Pick<TCollabThread, "data"> & {
124+
resolvedAt: TCollabThread["resolvedAt"] | null;
125+
}
126+
>,
127+
): TCollabThread;
128+
129+
watchThreads(callback: () => void): void;
130+
unwatchThreads(callback: () => void): void;
131+
};

pnpm-lock.yaml

Lines changed: 0 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)