Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/content/docs/features/collaboration/comments.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ import {
TiptapThreadStore,
DefaultThreadStoreAuth,
} from "@blocknote/core/comments";
import { TiptapCollabProvider } from "@hocuspocus/provider";
import { TiptapCollabProvider } from "@tiptap-pro/provider";

// Create a TiptapCollabProvider (you probably have this already)
const provider = new TiptapCollabProvider({
Expand Down
8 changes: 0 additions & 8 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,6 @@
"vite-plugin-eslint": "^1.8.1",
"vitest": "^2.1.9"
},
"peerDependencies": {
"@hocuspocus/provider": "^2.15.2 || ^3.0.0"
},
"peerDependenciesMeta": {
"@hocuspocus/provider": {
"optional": true
}
},
"eslintConfig": {
"extends": [
"../../.eslintrc.json"
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/comments/threadstore/TipTapThreadStore.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import type {
TCollabComment,
TCollabThread,
TiptapCollabProvider,
} from "@hocuspocus/provider";
import {
CommentBody,
CommentData,
Expand All @@ -11,6 +6,11 @@ import {
} from "../types.js";
import { ThreadStore } from "./ThreadStore.js";
import { ThreadStoreAuth } from "./ThreadStoreAuth.js";
import type {
TCollabComment,
TCollabThread,
TiptapCollabProvider,
} from "./tiptap/types.js";

type ReactionAsTiptapData = {
emoji: string;
Expand Down
131 changes: 131 additions & 0 deletions packages/core/src/comments/threadstore/tiptap/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/**
* Tiptap comment types have moved to a private tiptap package and we don't want to create a dependency on it.
* We've extracted the types from https://github.com/ueberdosis/hocuspocus/blob/v2.15.3/packages/provider/src/types.ts
* and added them here.
*/

export type TCollabThread<Data = any, CommentData = any> = {
id: string;
createdAt: number;
updatedAt: number;
deletedAt: number | null;
resolvedAt?: string; // (new Date()).toISOString()
comments: TCollabComment<CommentData>[];
deletedComments: TCollabComment<CommentData>[];
data: Data;
};

export type TCollabComment<Data = any> = {
id: string;
createdAt: string;
updatedAt: string;
deletedAt?: string;
data: Data;
content: any;
};

export type ThreadType = "archived" | "unarchived";

export type GetThreadsOptions = {
/**
* The types of threads to get
* @default ['unarchived']
*/
types?: Array<ThreadType>;
};

export type DeleteCommentOptions = {
/**
* If `true`, the thread will also be deleted if the deleted comment was the first comment in the thread.
*/
deleteThread?: boolean;

/**
* If `true`, will remove the content of the deleted comment
*/
deleteContent?: boolean;
};

export type DeleteThreadOptions = {
/**
* If `true`, will remove the comments on the thread,
* otherwise will only mark the thread as deleted
* and keep the comments
* @default false
*/
deleteComments?: boolean;

/**
* If `true`, will forcefully remove the thread and all comments,
* otherwise will only mark the thread as deleted
* and keep the comments
* @default false
*/
force?: boolean;
};

export type TiptapCollabProvider = {
getThread<Data, CommentData>(
id: string,
): TCollabThread<Data, CommentData> | null;

getThreads<Data, CommentData>(
options?: GetThreadsOptions,
): TCollabThread<Data, CommentData>[];
createThread(
data: Omit<
TCollabThread,
| "id"
| "createdAt"
| "updatedAt"
| "deletedAt"
| "comments"
| "deletedComments"
>,
): TCollabThread;

addComment(
threadId: TCollabThread["id"],
data: Omit<TCollabComment, "id" | "updatedAt" | "createdAt">,
): TCollabThread;

updateComment(
threadId: TCollabThread["id"],
commentId: TCollabComment["id"],
data: Partial<Pick<TCollabComment, "data" | "content">>,
): TCollabThread;

deleteComment(
threadId: TCollabThread["id"],
commentId: TCollabComment["id"],
options?: DeleteCommentOptions,
): TCollabThread;

getThreadComments(
threadId: TCollabThread["id"],
includeDeleted?: boolean,
): TCollabComment[] | null;

getThreadComment(
threadId: TCollabThread["id"],
commentId: TCollabComment["id"],
includeDeleted?: boolean,
): TCollabComment | null;

deleteThread(
id: TCollabThread["id"],
options?: DeleteThreadOptions,
): TCollabThread;

updateThread(
id: TCollabThread["id"],
data: Partial<
Pick<TCollabThread, "data"> & {
resolvedAt: TCollabThread["resolvedAt"] | null;
}
>,
): TCollabThread;

watchThreads(callback: () => void): void;
unwatchThreads(callback: () => void): void;
};
33 changes: 0 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading