@fileverse-dev/ddoc 3.0.54 → 3.0.55-comment-fix-1

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.
@@ -1,4 +1,4 @@
1
1
  import { CommentContextType, CommentProviderProps } from './types';
2
2
 
3
- export declare const CommentProvider: ({ children, editor, initialComments, setInitialComments, username, setUsername, activeCommentId, setActiveCommentId, focusCommentWithActiveId, onNewComment, onCommentReply, ensResolutionUrl, onResolveComment, onUnresolveComment, onDeleteComment, isConnected, connectViaWallet, isLoading, connectViaUsername, isDDocOwner, onInlineComment, onComment, setCommentDrawerOpen, }: CommentProviderProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const CommentProvider: ({ children, editor, ydoc, initialComments, setInitialComments, username, setUsername, activeCommentId, setActiveCommentId, focusCommentWithActiveId, onNewComment, onCommentReply, ensResolutionUrl, onResolveComment, onUnresolveComment, onDeleteComment, isConnected, connectViaWallet, isLoading, connectViaUsername, isDDocOwner, onInlineComment, onComment, setCommentDrawerOpen, }: CommentProviderProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export declare const useComments: () => CommentContextType;
@@ -1,9 +1,10 @@
1
1
  import { Editor } from '@tiptap/react';
2
2
  import { IComment } from '../../../extensions/comment';
3
3
  import { SetStateAction } from 'react';
4
- import { CommentAccountProps } from '../../../types';
4
+ import { CommentAccountProps, CommentMutationMeta } from '../../../types';
5
5
  import { EnsStatus } from '../types';
6
6
 
7
+ import * as Y from 'yjs';
7
8
  export interface CommentContextType extends CommentAccountProps {
8
9
  comments: IComment[];
9
10
  setComments: React.Dispatch<SetStateAction<IComment[]>>;
@@ -67,13 +68,14 @@ export interface CommentContextType extends CommentAccountProps {
67
68
  export interface CommentProviderProps extends CommentAccountProps {
68
69
  children: React.ReactNode;
69
70
  editor: Editor;
71
+ ydoc: Y.Doc;
70
72
  initialComments?: IComment[];
71
73
  setInitialComments?: React.Dispatch<SetStateAction<IComment[]>>;
72
74
  onCommentReply?: (activeCommentId: string, reply: IComment) => void;
73
- onNewComment?: (newComment: IComment) => void;
74
- onResolveComment?: (activeCommentId: string) => void;
75
- onUnresolveComment?: (activeCommentId: string) => void;
76
- onDeleteComment?: (activeCommentId: string) => void;
75
+ onNewComment?: (newComment: IComment, meta?: CommentMutationMeta) => void;
76
+ onResolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
77
+ onUnresolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
78
+ onDeleteComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
77
79
  username: string | null;
78
80
  setUsername?: React.Dispatch<SetStateAction<string>>;
79
81
  activeCommentId: string | null;
@@ -17,6 +17,12 @@ export type InlineCommentData = {
17
17
  highlightedTextContent: string;
18
18
  handleClick: boolean;
19
19
  };
20
+ export type CommentMutationType = 'create' | 'resolve' | 'unresolve' | 'delete';
21
+ export interface CommentMutationMeta {
22
+ type: CommentMutationType;
23
+ updateChunk: string;
24
+ tabId: string;
25
+ }
20
26
  export interface CommentAccountProps {
21
27
  isConnected?: boolean;
22
28
  connectViaWallet?: () => Promise<void>;
@@ -83,10 +89,10 @@ export interface DdocProps extends CommentAccountProps {
83
89
  initialComments?: IComment[];
84
90
  setInitialComments?: React.Dispatch<SetStateAction<IComment[]>>;
85
91
  onCommentReply?: (activeCommentId: string, reply: IComment) => void;
86
- onNewComment?: (newComment: IComment) => void;
87
- onResolveComment?: (activeCommentId: string) => void;
88
- onUnresolveComment?: (activeCommentId: string) => void;
89
- onDeleteComment?: (activeCommentId: string) => void;
92
+ onNewComment?: (newComment: IComment, meta?: CommentMutationMeta) => void;
93
+ onResolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
94
+ onUnresolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
95
+ onDeleteComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
90
96
  showTOC?: boolean;
91
97
  setShowTOC?: React.Dispatch<SetStateAction<boolean>>;
92
98
  extensions?: Record<string, Extension | any>;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/ddoc",
3
3
  "private": false,
4
4
  "description": "DDoc",
5
- "version": "3.0.54",
5
+ "version": "3.0.55-comment-fix-1",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
8
8
  "exports": {